@camstack/addon-admin-ui 1.2.453 → 1.2.455

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 (131) hide show
  1. package/dist/assets/{AddonAssetIcon-D4f5QzwX.js → AddonAssetIcon-BYNabO6z.js} +1 -1
  2. package/dist/assets/Addons-B7UpJkGs.js +4 -0
  3. package/dist/assets/{AdminPage-D_zEoNvj.js → AdminPage-RJcN6Anu.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-c5oc7MKr.js → AdminSectionedPage-DvK84QvU.js} +1 -1
  5. package/dist/assets/AiProfiles-WyUbwQQi.js +3 -0
  6. package/dist/assets/{BrokerForm-WFCCMZu7.js → BrokerForm-Bua9uB8w.js} +1 -1
  7. package/dist/assets/Build-w6vEia_c.js +40 -0
  8. package/dist/assets/{Calendars-DNZptD-n.js → Calendars-ClbErr_S.js} +1 -1
  9. package/dist/assets/{Cluster-BirHrmjz.js → Cluster-DmQM6H_p.js} +1 -1
  10. package/dist/assets/ClusterStepModel-hpdBn30Y.js +1 -0
  11. package/dist/assets/{CompositionEditor-BruCgxbv.js → CompositionEditor-CpN510VP.js} +1 -1
  12. package/dist/assets/{CompositionEditorPage-CNY8Rqx0.js → CompositionEditorPage-Bicamzo6.js} +1 -1
  13. package/dist/assets/{Data-B9LAPgxz.js → Data-DoXqW90G.js} +2 -2
  14. package/dist/assets/DeviceDetail-4Vysat6s.js +2 -0
  15. package/dist/assets/{DeviceDoActionFields-Drr-gpl9.js → DeviceDoActionFields-lfq-_s87.js} +1 -1
  16. package/dist/assets/{Devices-JQ8FIcrC.js → Devices-BCTvzI3Z.js} +1 -1
  17. package/dist/assets/{EmbedPlayerPage-DMCMitj3.js → EmbedPlayerPage-BzklJ0a5.js} +1 -1
  18. package/dist/assets/History-BYogPAEo.js +1 -0
  19. package/dist/assets/{Identity-lfUuRjOX.js → Identity-DtlH2M6Y.js} +1 -1
  20. package/dist/assets/IntegrationDetail-B0PsG3wF.js +1 -0
  21. package/dist/assets/{IntegrationHub-Db0bsfLJ.js → IntegrationHub-DHgjRUIy.js} +1 -1
  22. package/dist/assets/{Integrations-CcXy5tWR.js → Integrations-CQ3JYsSK.js} +1 -1
  23. package/dist/assets/{Integrations-DNPpJ4Ja.js → Integrations-DD48mmxj.js} +1 -1
  24. package/dist/assets/Library-02NRO2CR.js +1 -0
  25. package/dist/assets/Locations-CUmRk0or.js +3 -0
  26. package/dist/assets/{Logs-DWM80Ifl.js → Logs-QE5m7m6F.js} +1 -1
  27. package/dist/assets/{MaskShapeCanvas-Chm66Qq5.js → MaskShapeCanvas-C7r7jgVz.js} +1 -1
  28. package/dist/assets/{MotionZonesSettings-CQ4kMA71.js → MotionZonesSettings-qCWVDb2U.js} +1 -1
  29. package/dist/assets/{MyAccess-DhDj6Dcu.js → MyAccess-CIhAKN-2.js} +1 -1
  30. package/dist/assets/{Network-DRNoFcHE.js → Network-CJOuBFOQ.js} +1 -1
  31. package/dist/assets/{NodeAddonsSettingsPanel-CmUo7HL7.js → NodeAddonsSettingsPanel-CTmPFs3s.js} +1 -1
  32. package/dist/assets/Notifications-WPdPSM1o.js +1 -0
  33. package/dist/assets/{PrivacyMaskSettings-CpCCSkKp.js → PrivacyMaskSettings-CBAaR7ZM.js} +1 -1
  34. package/dist/assets/{Recordings-BcWqTc1H.js → Recordings-BeU7j2Jf.js} +1 -1
  35. package/dist/assets/{ScanNetworkModal-DOkg50dW.js → ScanNetworkModal-CiOVqs0H.js} +1 -1
  36. package/dist/assets/SceneMonitorEditor-BbPp4N2N.js +1 -0
  37. package/dist/assets/{SessionsList-rvronrFR.js → SessionsList-DTdwgdgY.js} +2 -2
  38. package/dist/assets/{Showroom-BLEcXdKT.js → Showroom-or-UvZ6_.js} +1 -1
  39. package/dist/assets/{System-B6PNyCJb.js → System-DSx33GfC.js} +1 -1
  40. package/dist/assets/{Terminal-C20iOQsN.js → Terminal-B3oKTozT.js} +2 -2
  41. package/dist/assets/{Viewer-DwNTfUWw.js → Viewer-CpC1lsu6.js} +1 -1
  42. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DO5DropZ.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-cERw53qT.js} +1 -1
  43. package/dist/assets/{addon-icons-context-CO0pJapE.js → addon-icons-context-BVO6QLZm.js} +1 -1
  44. package/dist/assets/{archive-Bp0veqaX.js → archive-jvBvOOAa.js} +1 -1
  45. package/dist/assets/{authed-media-BukO6Htt.js → authed-media-DubLoRPM.js} +1 -1
  46. package/dist/assets/{bell-off-DNhCufqt.js → bell-off-h_oVtaH_.js} +1 -1
  47. package/dist/assets/{board-model-Ci-_X0u-.js → board-model-lfov_Io5.js} +1 -1
  48. package/dist/assets/{boxes-BaumwARG.js → boxes-CqZzX6pS.js} +1 -1
  49. package/dist/assets/circle-slash-DFnFtATu.js +1 -0
  50. package/dist/assets/client-Cj9cIFJV.js +358 -0
  51. package/dist/assets/{cloud-upload-C78OV2Vf.js → cloud-upload-_iPugQ2o.js} +1 -1
  52. package/dist/assets/crop-CesdRTv2.js +1 -0
  53. package/dist/assets/{device-integration-icon-B2dkF6iM.js → device-integration-icon-CFPzExgG.js} +1 -1
  54. package/dist/assets/device-picker-model-CVKD2t0V.js +1 -0
  55. package/dist/assets/{dist-BnhJ2JWA.js → dist-BYCY5p_8.js} +1 -1
  56. package/dist/assets/dist-o4U_Imrg.js +358 -0
  57. package/dist/assets/{eraser-BYMxipNr.js → eraser-RaYHha2L.js} +1 -1
  58. package/dist/assets/{hard-drive-download-ClkqTbzr.js → hard-drive-download-DobqoKaY.js} +1 -1
  59. package/dist/assets/{hostInit-BGNr3Jpq.js → hostInit-Bk_2heUx.js} +1 -1
  60. package/dist/assets/i18n-BuS8cl72.js +1 -0
  61. package/dist/assets/icons-DzYBV1xx.js +1 -0
  62. package/dist/assets/index-BuOqDa4D.css +2 -0
  63. package/dist/assets/index-CM1JjjBW.js +4 -0
  64. package/dist/assets/{key-CKrA-CfR.js → key-Dtkr3Nze.js} +1 -1
  65. package/dist/assets/{key-round-CDKQmrbu.js → key-round-CNTVmlFS.js} +1 -1
  66. package/dist/assets/{layers-UfB0_N2n.js → layers-DGhugmpj.js} +1 -1
  67. package/dist/assets/{linked-devices-model-BM0mB7nT.js → linked-devices-model-BpGYuse3.js} +1 -1
  68. package/dist/assets/{list-ordered-0mq_0UIh.js → list-ordered-DR6Fc-kF.js} +1 -1
  69. package/dist/assets/{location-owned-usage-D6ooNfJc.js → location-owned-usage-CScwnhi4.js} +1 -1
  70. package/dist/assets/{log-in-BySKT1Dy.js → log-in-B8yxXP-a.js} +1 -1
  71. package/dist/assets/{memory-stick-Dp1YfIBO.js → memory-stick-DEd977DV.js} +1 -1
  72. package/dist/assets/{message-square-plus-BWjzgumP.js → message-square-plus-czVBdg8z.js} +1 -1
  73. package/dist/assets/{mf-entry-bootstrap-0-594b555b.js → mf-entry-bootstrap-0-ffeb770c.js} +2 -2
  74. package/dist/assets/{mic-off-DiXTm9Y2.js → mic-off-CuWOtzwH.js} +1 -1
  75. package/dist/assets/{monitor-off-D3OGcghF.js → monitor-off-D1_Vx25v.js} +1 -1
  76. package/dist/assets/{monitor-smartphone-BkZrPcuL.js → monitor-smartphone-EKfsOXbl.js} +1 -1
  77. package/dist/assets/mount-CVKD2t0V.js +1 -0
  78. package/dist/assets/notification-schedule-field-i8rEjVxQ.js +1 -0
  79. package/dist/assets/player-overlays-D98Lvll4.js +1 -0
  80. package/dist/assets/{recycle-FJ49Ydss.js → recycle-BDYRIJo4.js} +1 -1
  81. package/dist/assets/remoteEntry-BtmyK6Gf.js +1 -0
  82. package/dist/assets/{scan-eye-Cd5UWfpf.js → scan-eye-BF9NJNXB.js} +1 -1
  83. package/dist/assets/{scissors-BA0EAdIJ.js → scissors-BNz1ybHC.js} +1 -1
  84. package/dist/assets/{search-x-By_wSOtV.js → search-x-DOr7Uth6.js} +1 -1
  85. package/dist/assets/send-BfMMesXE.js +1 -0
  86. package/dist/assets/{settings-2-CbNC1QI2.js → settings-2-CpTdKS6A.js} +1 -1
  87. package/dist/assets/{speaker-1RM6dadP.js → speaker-DiDPOBlm.js} +1 -1
  88. package/dist/assets/src-MJ2k3G6o.js +67 -0
  89. package/dist/assets/{timer-reset--avsGIJd.js → timer-reset-Dw4WCNKZ.js} +1 -1
  90. package/dist/assets/{ungroup-D3cHvFv0.js → ungroup-CLr3vekJ.js} +1 -1
  91. package/dist/assets/{unlink-tiyUOhU3.js → unlink-pUA2UXXM.js} +1 -1
  92. package/dist/assets/{usb-Di-8wm3J.js → usb-wx8HtogA.js} +1 -1
  93. package/dist/assets/{use-scenes-feed-CAjM8T0N.js → use-scenes-feed-DF4B8gD1.js} +1 -1
  94. package/dist/assets/{use-stationary-objects-Bjq8kJYj.js → use-stationary-objects-CPcayJEy.js} +1 -1
  95. package/dist/assets/useEventInvalidation-CVKD2t0V.js +1 -0
  96. package/dist/assets/{useNodeUrlSelection-DiojZJ0u.js → useNodeUrlSelection-Dm8ObY95.js} +1 -1
  97. package/dist/assets/user-round-vZzgqRIQ.js +1 -0
  98. package/dist/assets/{user-x-olI9Ahi1.js → user-x-CzTAjxJ0.js} +1 -1
  99. package/dist/assets/{video-jTbj0gAQ.js → video-a3E1zR0a.js} +1 -1
  100. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-D8GIXJRi.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-C-d2SXqo.js} +2 -2
  101. package/dist/index.html +11 -11
  102. package/dist/server/addon.js +152 -84
  103. package/package.json +1 -1
  104. package/dist/assets/Addons-BmgETSc4.js +0 -4
  105. package/dist/assets/AiProfiles-OmUyER08.js +0 -3
  106. package/dist/assets/Build-H3rAvJYX.js +0 -40
  107. package/dist/assets/ClusterStepModel-DXEw1-iK.js +0 -1
  108. package/dist/assets/DeviceDetail-DB8Wa7Sv.js +0 -2
  109. package/dist/assets/History-DyW5HpVM.js +0 -1
  110. package/dist/assets/IntegrationDetail-DnpseReT.js +0 -1
  111. package/dist/assets/Library-C2dLqSTC.js +0 -1
  112. package/dist/assets/Locations-e6uuHHQU.js +0 -3
  113. package/dist/assets/Notifications-BnhdNZ6f.js +0 -1
  114. package/dist/assets/SceneMonitorEditor-C1CNWxmG.js +0 -1
  115. package/dist/assets/circle-slash-D7rbiin9.js +0 -1
  116. package/dist/assets/client-BggkinSi.js +0 -358
  117. package/dist/assets/crop-CFruzwpC.js +0 -1
  118. package/dist/assets/device-picker-model-B7xNzrPL.js +0 -1
  119. package/dist/assets/dist-DTzD7Qgb.js +0 -358
  120. package/dist/assets/i18n-BimjnPQq.js +0 -1
  121. package/dist/assets/icons-DHL4FRrs.js +0 -1
  122. package/dist/assets/index-BVY_WMe1.js +0 -4
  123. package/dist/assets/index-CcCgJ28N.css +0 -2
  124. package/dist/assets/mount-B7xNzrPL.js +0 -1
  125. package/dist/assets/notification-schedule-field-BG32wqBc.js +0 -1
  126. package/dist/assets/player-overlays-BYMAZza9.js +0 -1
  127. package/dist/assets/remoteEntry-CXA3sxXs.js +0 -1
  128. package/dist/assets/send-C-dY1QlF.js +0 -1
  129. package/dist/assets/src-75D_Zlij.js +0 -67
  130. package/dist/assets/useEventInvalidation-B7xNzrPL.js +0 -1
  131. package/dist/assets/user-round-luImimaP.js +0 -1
@@ -5432,7 +5432,7 @@ var ZodIssueCode = {
5432
5432
  var ZodFirstPartyTypeKind;
5433
5433
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5434
5434
  //#endregion
5435
- //#region ../types/dist/sleep-DJFUfKvA.mjs
5435
+ //#region ../types/dist/sleep-CUp20JkO.mjs
5436
5436
  /**
5437
5437
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5438
5438
  * window to float samples (D455).
@@ -8257,7 +8257,11 @@ var ContributionSectionSchema = object({
8257
8257
  literal(4)
8258
8258
  ]).optional(),
8259
8259
  tab: string().optional(),
8260
- location: _enum(["settings", "top-tab"]).optional(),
8260
+ location: _enum([
8261
+ "settings",
8262
+ "top-tab",
8263
+ "hero"
8264
+ ]).optional(),
8261
8265
  order: number().optional(),
8262
8266
  fields: array(any())
8263
8267
  });
@@ -13194,7 +13198,11 @@ var ConfigSectionWithValuesSchema = object({
13194
13198
  literal(4)
13195
13199
  ]).optional(),
13196
13200
  tab: string().optional(),
13197
- location: _enum(["settings", "top-tab"]).optional(),
13201
+ location: _enum([
13202
+ "settings",
13203
+ "top-tab",
13204
+ "hero"
13205
+ ]).optional(),
13198
13206
  order: number().optional(),
13199
13207
  fields: array(any())
13200
13208
  });
@@ -16968,6 +16976,52 @@ var TierStatusSchema = object({
16968
16976
  countedAt: number().nullable()
16969
16977
  });
16970
16978
  /** Operator/diagnostic view: rows per tier, last runs, refusals and drops since boot. */
16979
+ /**
16980
+ * Why a series is orphan. `device-gone`: its device is absent from the
16981
+ * successful device listings (the departure clock). `undeclared`: its `cap:`
16982
+ * key is declared by no capability any more (a field a cap removed).
16983
+ */
16984
+ var DeviceHistoryOrphanReasonSchema = _enum(["device-gone", "undeclared"]);
16985
+ /** Rows held per stored tier. */
16986
+ var TierRowsSchema = object({
16987
+ raw: number().int(),
16988
+ "5m": number().int(),
16989
+ "1h": number().int(),
16990
+ "1d": number().int()
16991
+ });
16992
+ var OrphanSeriesSchema = object({
16993
+ seriesId: number().int(),
16994
+ deviceId: number().int(),
16995
+ key: string(),
16996
+ scope: string(),
16997
+ /** The metric's display name; `null` when its metric row is gone too. */
16998
+ displayName: string().nullable(),
16999
+ reason: DeviceHistoryOrphanReasonSchema,
17000
+ /** `device-gone`: since when the device has been absent; `null` otherwise. */
17001
+ missingSince: number().nullable(),
17002
+ firstTs: number(),
17003
+ lastTs: number(),
17004
+ rows: TierRowsSchema
17005
+ });
17006
+ var DeviceHistoryOrphanDeleteRefusalSchema = _enum([
17007
+ "not-found",
17008
+ "not-orphan",
17009
+ "failed"
17010
+ ]);
17011
+ var OrphanDeleteEntrySchema = discriminatedUnion("ok", [object({
17012
+ seriesId: number().int(),
17013
+ ok: literal(true),
17014
+ deleted: TierRowsSchema
17015
+ }), object({
17016
+ seriesId: number().int(),
17017
+ ok: literal(false),
17018
+ reason: DeviceHistoryOrphanDeleteRefusalSchema
17019
+ })]);
17020
+ var OrphanListSchema = object({
17021
+ series: array(OrphanSeriesSchema).readonly(),
17022
+ /** More orphans exist than {@link DEVICE_HISTORY_ORPHAN_LIST_MAX}. */
17023
+ truncated: boolean()
17024
+ });
16971
17025
  var DeviceHistoryStatusSchema = object({
16972
17026
  startedAt: number(),
16973
17027
  /** The store is declared, series loaded and the first reconcile has answered. */
@@ -17065,7 +17119,10 @@ method(object({ deviceId: number().int() }), array(SeriesInfoSchema).readonly())
17065
17119
  }), object({ enabled: boolean() }), {
17066
17120
  kind: "mutation",
17067
17121
  auth: "admin"
17068
- }), method(object({}), DeviceHistoryStatusSchema, { auth: "admin" });
17122
+ }), method(object({}), DeviceHistoryStatusSchema, { auth: "admin" }), method(object({}), OrphanListSchema, { auth: "admin" }), method(object({ seriesIds: array(number().int()).min(1).max(50) }), object({ results: array(OrphanDeleteEntrySchema).readonly() }), {
17123
+ kind: "mutation",
17124
+ auth: "admin"
17125
+ });
17069
17126
  var DeviceCaStatusSchema = discriminatedUnion("state", [
17070
17127
  object({ state: literal("absent") }),
17071
17128
  object({
@@ -54074,17 +54131,69 @@ object({
54074
54131
  });
54075
54132
  DeviceType.Sensor;
54076
54133
  /**
54077
- * Generic device-consumables capability — surfaces a device's
54078
- * maintenance items (vacuum filters/brushes, replaceable cartridges,
54079
- * descaling cycles, …) with their remaining life and an optional
54080
- * "Replaced" reset action. Device-agnostic: any provider that knows its
54081
- * device tracks consumables can register it; the cap declares no
54082
- * vocabulary of its own — the provider names each item verbatim.
54134
+ * Generic device-consumables capability — the ONE place a device reports what
54135
+ * it uses up or fills: wear parts (vacuum filters/brushes, cartridges,
54136
+ * descaling cycles), supplies it draws from (a vacuum's clean-water tank and
54137
+ * detergent, a dishwasher's salt and rinse aid) and waste it collects (a dirty
54138
+ * water tank, a dust bin). Each item carries its remaining life or fill and an
54139
+ * optional "Replaced" reset action. Device-agnostic: any provider that knows
54140
+ * its device tracks consumables registers it; the provider names each item
54141
+ * verbatim and says which `kind` it is.
54142
+ *
54143
+ * The admin UI renders it as ONE collapsible section directly under the
54144
+ * device page's hero card (`placement: 'hero'`), for every device bound to
54145
+ * this cap — never drawn by a device type's hero card itself (D915).
54083
54146
  *
54084
54147
  * Like `childLayout`, the cap is INERT until a provider sets items: no
54085
54148
  * provider populates it by guessing (no HA inference). The UI renders a
54086
54149
  * "No consumables reported" placeholder when `items` is empty.
54087
54150
  */
54151
+ /**
54152
+ * What an item IS, which decides which direction is bad:
54153
+ * - `wear` — a part that wears out (a brush, a filter); low life is bad.
54154
+ * - `supply` — something the device draws from (clean water, detergent,
54155
+ * salt, rinse aid); low or empty is bad.
54156
+ * - `waste` — something the device fills (dirty water, a dust bin); full is
54157
+ * bad.
54158
+ * Absent = `wear`.
54159
+ */
54160
+ var ConsumableKindSchema = _enum([
54161
+ "wear",
54162
+ "supply",
54163
+ "waste"
54164
+ ]);
54165
+ /**
54166
+ * What an item LOOKS like, which decides how a client draws it — independent
54167
+ * of `kind`, which decides which direction is bad:
54168
+ * - `part` — a part that wears (a brush, a filter, a mop pad): a wear bar,
54169
+ * remaining time and a reset.
54170
+ * - `tank` — a container of liquid (clean water, dirty water): a fill gauge.
54171
+ * - `product` — something bought and refilled (detergent, salt, rinse aid):
54172
+ * a stepped level and "refill".
54173
+ * - `bin` — a container that collects waste (a dust bin): a fill gauge
54174
+ * that warns when full.
54175
+ * Absent = derived from the kind ({@link consumableFormOf}).
54176
+ */
54177
+ var ConsumableFormSchema = _enum([
54178
+ "part",
54179
+ "tank",
54180
+ "product",
54181
+ "bin"
54182
+ ]);
54183
+ /** The provider's own discrete verdict on an item. */
54184
+ var ConsumableStatusSchema = _enum([
54185
+ "ok",
54186
+ "low",
54187
+ "empty",
54188
+ "full",
54189
+ "replace"
54190
+ ]);
54191
+ _enum([
54192
+ "ok",
54193
+ "low",
54194
+ "empty",
54195
+ "full"
54196
+ ]);
54088
54197
  /** Units a remaining-life counter is reported in. Closed: the panel renders
54089
54198
  * each. */
54090
54199
  var ConsumableRemainingUnitSchema = _enum([
@@ -54104,10 +54213,14 @@ var ConsumablesStatusSchema = object({
54104
54213
  key: string().min(1),
54105
54214
  /** Display name. */
54106
54215
  label: string().min(1),
54107
- /** Remaining life % when known (0..100). */
54216
+ /** Remaining life % (`wear`) or fill % (`supply`, `waste`) when known (0..100). */
54108
54217
  level: number().min(0).max(100).nullable(),
54109
- /** Discrete state when known (binary mode). */
54110
- status: _enum(["ok", "replace"]).nullable(),
54218
+ /** The provider's discrete verdict when known (binary mode). */
54219
+ status: ConsumableStatusSchema.nullable(),
54220
+ /** What the item is — decides whether low or full is bad. Absent = `wear`. */
54221
+ kind: ConsumableKindSchema.optional(),
54222
+ /** How the item is drawn (part, tank, product, bin). Absent = derived from `kind`. */
54223
+ form: ConsumableFormSchema.optional(),
54111
54224
  /** Ms epoch of the last replace, when known. */
54112
54225
  lastResetAt: number().nullable(),
54113
54226
  /** Whether `reset()` is meaningful for this item. */
@@ -54342,8 +54455,9 @@ object({
54342
54455
  status: DeviceStatusSchema
54343
54456
  });
54344
54457
  /**
54345
- * Smart-dishwasher cap — program lifecycle, door / remote-start gates,
54346
- * consumable levels (salt, rinse aid) and common program options.
54458
+ * Smart-dishwasher cap — program lifecycle, door / remote-start gates and
54459
+ * common program options. Salt and rinse aid are NOT here: they are items of
54460
+ * the device's `consumables` cap, like every other device's (D915).
54347
54461
  *
54348
54462
  * Sources: native Bosch Home Connect (`dishwasher` device type). Reusable
54349
54463
  * by any integration that exposes the same program / option surface.
@@ -54391,11 +54505,6 @@ var DishwasherAvailabilitySchema = _enum([
54391
54505
  "offline",
54392
54506
  "description-missing"
54393
54507
  ]);
54394
- var DishwasherConsumableLevelSchema = _enum([
54395
- "ok",
54396
- "low",
54397
- "empty"
54398
- ]);
54399
54508
  object({
54400
54509
  availability: DishwasherAvailabilitySchema,
54401
54510
  /** Coarse state for compact surfaces; `unavailable` whenever the appliance state is not known. */
@@ -54428,8 +54537,6 @@ object({
54428
54537
  powerOn: boolean().nullable(),
54429
54538
  /** The raw power state (`On`, `Off`, `Standby`, …); null when not known. */
54430
54539
  powerState: string().nullable(),
54431
- saltLevel: DishwasherConsumableLevelSchema.nullable(),
54432
- rinseAidLevel: DishwasherConsumableLevelSchema.nullable(),
54433
54540
  /**
54434
54541
  * True while the appliance asks for its filter to be cleaned (smart-filter, filter-system or
54435
54542
  * combined care-and-filter reminder raised); false when every such reminder reads clear; null
@@ -61212,60 +61319,17 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
61212
61319
  auth: "admin",
61213
61320
  access: "delete"
61214
61321
  });
61215
- /**
61216
- * Robot-vacuum cap. Models HA `vacuum.*` entities — anything with a
61217
- * cleaning lifecycle plus a return-to-base / locate surface and an
61218
- * optional fan-speed selector.
61219
- *
61220
- * State follows HA's canonical vacuum lifecycle: `idle` / `cleaning` /
61221
- * `paused` / `returning` / `docked` / `error`. `batteryLevel`
61222
- * (0..100) is nullable — some vacuums don't report a battery
61223
- * percentage. `fanSpeed` is the current speed token (provider-verbatim,
61224
- * e.g. `'standard'` / `'turbo'`) and `availableFanSpeeds` lists the
61225
- * tokens the hardware accepts so the UI renders only supported choices.
61226
- *
61227
- * The `setFanSpeed` method takes the bare `speed` token — the provider
61228
- * validates it against the vacuum's own list. `locate` triggers the
61229
- * find-me chirp; `returnToBase` sends it home.
61230
- *
61231
- * Consumable / waste tanks: `cleanWater` / `dirtyWater` / `detergent` /
61232
- * `dustBin` each carry a nullable `{ level (0..100 %), status ('ok' |
61233
- * 'low' | 'full') }` reading. Native providers (e.g. Dreame, Roborock)
61234
- * SHOULD populate whichever tanks the hardware has — leave a field `null`
61235
- * only when the device has no such tank at all, and use a `TankStatus`
61236
- * with both inner fields `null` when the tank exists but its level is
61237
- * currently unknown. HA `vacuum.*` entities expose no per-tank telemetry,
61238
- * so the HA provider leaves all four `null`.
61239
- */
61240
- var VacuumStateSchema = _enum([
61241
- "idle",
61242
- "cleaning",
61243
- "paused",
61244
- "returning",
61245
- "docked",
61246
- "drying",
61247
- "error"
61248
- ]);
61249
- /**
61250
- * One consumable / waste tank on a robot vacuum (clean-water, dirty-water,
61251
- * detergent or dust-bin). A tank can report a numeric fill `level` (0..100),
61252
- * a discrete `status` (binary-style hardware), or both. Both `null` means the
61253
- * level is currently unknown; the OWNING field being `null` means the
61254
- * hardware has no such tank at all.
61255
- */
61256
- var TankStatusSchema = object({
61257
- /** Numeric fill 0..100 when the hardware reports a percentage; null otherwise. */
61258
- level: number().min(0).max(100).nullable(),
61259
- /** Discrete state when the hardware is binary-mode; null otherwise. */
61260
- status: _enum([
61261
- "ok",
61262
- "low",
61263
- "full"
61264
- ]).nullable()
61265
- });
61266
61322
  object({
61267
61323
  /** Lifecycle state of the vacuum. */
61268
- state: VacuumStateSchema,
61324
+ state: _enum([
61325
+ "idle",
61326
+ "cleaning",
61327
+ "paused",
61328
+ "returning",
61329
+ "docked",
61330
+ "drying",
61331
+ "error"
61332
+ ]),
61269
61333
  /** 0..100 battery percentage. Null when the device has no battery
61270
61334
  * reading. */
61271
61335
  batteryLevel: number().min(0).max(100).nullable(),
@@ -61274,14 +61338,6 @@ object({
61274
61338
  fanSpeed: string().nullable(),
61275
61339
  /** Speed tokens the hardware accepts — drives the UI selector. */
61276
61340
  availableFanSpeeds: array(string()),
61277
- /** Clean-water (mop) tank. Null when the hardware has no clean-water tank. */
61278
- cleanWater: TankStatusSchema.nullable(),
61279
- /** Dirty-water (recovery) tank. Null when the hardware has no dirty-water tank. */
61280
- dirtyWater: TankStatusSchema.nullable(),
61281
- /** Detergent tank. Null when the hardware has no detergent tank. */
61282
- detergent: TankStatusSchema.nullable(),
61283
- /** Dust bin. Null when the hardware has no dust bin. */
61284
- dustBin: TankStatusSchema.nullable(),
61285
61341
  /** 0..100 cleaning-completion percentage of the current task, or null. */
61286
61342
  progressPercent: number().min(0).max(100).nullable(),
61287
61343
  /** Current error code (0 / null = no error). */
@@ -63822,6 +63878,12 @@ Object.freeze({
63822
63878
  addonId: null,
63823
63879
  access: "create"
63824
63880
  },
63881
+ "deviceHistory.deleteOrphanSeries": {
63882
+ capName: "device-history",
63883
+ capScope: "system",
63884
+ addonId: null,
63885
+ access: "delete"
63886
+ },
63825
63887
  "deviceHistory.getDeviceEnabled": {
63826
63888
  capName: "device-history",
63827
63889
  capScope: "system",
@@ -63840,6 +63902,12 @@ Object.freeze({
63840
63902
  addonId: null,
63841
63903
  access: "view"
63842
63904
  },
63905
+ "deviceHistory.listOrphanSeries": {
63906
+ capName: "device-history",
63907
+ capScope: "system",
63908
+ addonId: null,
63909
+ access: "view"
63910
+ },
63843
63911
  "deviceHistory.listSeries": {
63844
63912
  capName: "device-history",
63845
63913
  capScope: "system",
@@ -73845,7 +73913,7 @@ var STATE_SUMMARY_VARS = [
73845
73913
  ([...RULE_TEXT], [...COMBINED_ALARM]),
73846
73914
  ([...RULE_TEXT], [...DEVICE_EVENTS]),
73847
73915
  ([...RULE_TEXT], [...BATTERY, ...CONSUMABLE]),
73848
- ([...RULE_TEXT], [...CONSUMABLE]),
73916
+ ([...RULE_TEXT], [...CONSUMABLE, ...TANK]),
73849
73917
  ([...RULE_TEXT], [...TANK]),
73850
73918
  [...RULE_TEXT],
73851
73919
  ([...RULE_TEXT], [...UPDATES, ...ALERT_EPISODE]),
@@ -74561,7 +74629,7 @@ var AdminUIAddon = class extends BaseAddon {
74561
74629
  capability: adminUiCapability,
74562
74630
  provider: {
74563
74631
  getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
74564
- getVersion: async () => ({ version: "1.2.453" })
74632
+ getVersion: async () => ({ version: "1.2.455" })
74565
74633
  }
74566
74634
  }];
74567
74635
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-admin-ui",
3
- "version": "1.2.453",
3
+ "version": "1.2.455",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Admin UI — Vite frontend build and server-side addon",
@@ -1,4 +0,0 @@
1
- import{$ as e,B as t,G as n,J as r,L as i,S as a,b as o,o as s,q as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{Ci as d,Gr as f,It as p,Nt as m,Ot as h,Q as g,Rn as _,Si as v,Tn as y,bn as b,dt as x,fn as S,kn as C,mi as w,oi as T,or as E,pn as D,tn as O,un as ee,yi as te}from"./player-overlays-BYMAZza9.js";import{Xi as k}from"./client-BggkinSi.js";import{i as ne,l as re}from"./video-jTbj0gAQ.js";import{$n as ie,Ar as A,Au as ae,Gu as oe,Ju as j,Ms as M,Qn as se,Qr as ce,Rr as N,Tt as le,Xt as P,Zt as ue,_i as de,ai as fe,bi as F,ci as I,di as L,ei as R,er as z,fi as pe,gi as B,hi as V,hr as me,ht as he,ii as H,ir as ge,kr as U,li as W,mi as _e,ni as ve,nr as ye,oi as G,ri as be,rr as xe,ti as K,ui as Se,xi as Ce,yi as q}from"./src-75D_Zlij.js";import{t as J}from"./useTranslation-D3Is_4B6.js";import"./mount-B7xNzrPL.js";import{Z as Y,et as X,nt as we}from"./index-BVY_WMe1.js";import{t as Z}from"./AdminPage-D_zEoNvj.js";import{t as Te}from"./NodeAddonsSettingsPanel-CmUo7HL7.js";import{n as Q,t as Ee}from"./useNodeUrlSelection-DiojZJ0u.js";function De(e){if(e===void 0)return null;switch(e.state){case`failed`:case`refused`:case`missing`:case`crashed`:return{kind:e.state,...e.reason===void 0?{}:{reason:e.reason}};default:return null}}e();var Oe={queued:{icon:T,bg:`bg-muted text-foreground-subtle`,labelKey:`addons.addonRowBadge.queued`},updating:{icon:E,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:d,bg:`bg-success/10 text-success`,labelKey:`addons.addonRowBadge.done`},failed:{icon:ne,bg:`bg-danger/10 text-danger`,labelKey:`addons.addonRowBadge.failed`}};function ke({item:e}){let{t}=J(),n=Oe[e.status],r=n.icon;return a(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded ${n.bg}`,title:e.error,children:[l(r,{className:`w-2.5 h-2.5 ${n.spin?`animate-spin`:``}`}),t(n.labelKey)]})}var Ae=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),je=new Set([`done`,`failed`,`skipped`]);function Me(e){return!je.has(e.phase)&&!Ae.has(e.jobState)}function Ne(e,t){let n=new Map,r=[...e].sort((e,t)=>e.createdAtMs-t.createdAtMs);for(let e of r){let r=Ae.has(e.state);for(let i of e.tasks)r&&i.finishedAtMs!==null&&t-i.finishedAtMs>6e4||n.set(i.packageName,{jobId:e.jobId,packageName:i.packageName,phase:i.phase,fromVersion:i.fromVersion,toVersion:i.toVersion,error:i.error,jobState:e.state,finishedAtMs:i.finishedAtMs})}return n}function Pe(){let{data:e}=W({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=j(k.AddonsJobProgress,e=>e.job.jobId);return n(()=>{let n=new Map;for(let t of e??[])n.set(t.jobId,t);for(let[e,r]of t)n.set(e,r.job);return Ne([...n.values()],Date.now())},[e,t])}var Fe={queued:{icon:T,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.queued`},fetching:{icon:E,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.fetching`,spin:!0},staged:{icon:E,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.staged`,spin:!0},validating:{icon:E,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.validating`,spin:!0},applying:{icon:E,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.applying`,spin:!0},restarting:{icon:E,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,labelKey:`addons.jobProgress.restarting`,spin:!0},applied:{icon:E,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.finalizing`,spin:!0},done:{icon:d,cls:`bg-success/10 text-success`,labelKey:`addons.jobProgress.updated`},failed:{icon:ne,cls:`bg-danger/10 text-danger`,labelKey:`addons.jobProgress.failed`},skipped:{icon:O,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.skipped`}};function Ie({progress:e}){let{t}=J(),n=Fe[e.phase],r=n.icon,i=e.error??`${e.packageName}: ${e.fromVersion??`?`} → ${e.toVersion}`;return a(`span`,{"data-testid":`addon-job-progress`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded shrink-0 ${n.cls}`,title:i,children:[l(r,{className:`w-2.5 h-2.5 ${n.spin?`animate-spin`:``}`}),t(n.labelKey),a(`span`,{className:`font-mono`,children:[`→ `,e.toVersion]})]})}function Le(e,t){return e.filter(e=>e.packageName===t).slice().sort((e,t)=>e.isHub===t.isHub?e.nodeName.localeCompare(t.nodeName):e.isHub?-1:1)}function Re(e){let t=e.version===null?``:` ${e.version}`,n=e.isOnline?``:` (offline: removed when it reconnects)`;return`- ${e.nodeName}${t}${n}`}function ze(e,t,n){let r=[`${e} will be uninstalled from ${t.length} node(s). Its runners stop, its capabilities are deregistered and its code is deleted:`,...t.map(Re)];return n.length>0&&r.push(`Could not ask: ${n.join(`, `)} — not included.`),r.push(`This cannot be undone.`),r.join(`
2
- `)}function Be(e,t,n){let r=[`${e} will be uninstalled from ${t}: its runners stop and its code is deleted.`];return n.length>0&&r.push(`It stays installed on: ${n.map(e=>e.nodeName).join(`, `)}. Use "Everywhere" to remove it from every node.`),r.push(`This cannot be undone.`),r.join(`
3
- `)}var Ve={uninstalled:`uninstalled`,"not-installed":`was not installed`,refused:`REFUSED`,failed:`FAILED`,"pending-reconnect":`offline — removed when it reconnects`};function He(e,t){let n=[];for(let r of e.results){let e=r.runnersStopped.length>0?` (stopped ${r.runnersStopped.join(`, `)})`:``;n.push(`${t(r.nodeId)}: ${Ve[r.outcome]}${e}`),r.error!==void 0&&n.push(` ${r.error}`);for(let e of r.warnings)n.push(` ${e}`)}return n.join(`
4
- `)}var Ue={},We=3e4,Ge=`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-border text-foreground-subtle hover:text-red-400 hover:border-red-500/30 hover:bg-red-500/10 disabled:opacity-50 transition-colors`;function Ke({packageName:e,displayName:t,selectedNode:n,hideNodeAction:r,disabled:i}){let{t:o}=J(),c=s(),u=A(),d=U(),f=I(Ue,{staleTime:We}),m=f.data?.installations??[],h=(f.data?.unreachable??[]).map(e=>e.nodeId),g=Le(m,e),_=e=>g.find(t=>t.nodeId===e)?.nodeName??(e===n.id?n.name:e),v=F({onSettled:()=>{c.invalidateQueries({queryKey:[[`addons`]]}),c.invalidateQueries({queryKey:[[`addonPages`]]}),c.invalidateQueries({queryKey:[[`capabilities`]]}),c.invalidateQueries({queryKey:[[`nodes`]]})}}),y=async e=>{await d({title:e.success?o(`addons.addonUninstallControls.uninstalled`,`{{displayName}} uninstalled`,{displayName:t}):o(`addons.addonUninstallControls.notEveryNodeWasCleaned`,`{{displayName}}: not every node was cleaned`,{displayName:t}),message:He(e,_),variant:e.success?`default`:`danger`})},b=async n=>{try{await y(await v.mutateAsync({packageName:e,...n}))}catch(e){await d({title:o(`addons.addonUninstallControls.uninstallFailed`,`Uninstall {{displayName}} failed`,{displayName:t}),message:e instanceof Error?e.message:String(e),variant:`danger`})}},x=async()=>{let e=g.filter(e=>e.nodeId!==n.id);await u({title:o(`addons.addonUninstallControls.uninstallFrom`,`Uninstall {{displayName}} from {{name}}?`,{displayName:t,name:n.name}),message:Be(t,n.name,e),confirmLabel:o(`addons.addonUninstallControls.uninstall`,`Uninstall`),variant:`danger`})&&await b(n.isHub?{}:{nodeId:n.id})},S=async()=>{let n=(await f.refetch()).data;if(n===void 0){await d({title:o(`addons.addonUninstallControls.cannotListTheNodes`,`Cannot list the nodes`),message:o(`addons.addonUninstallControls.theHubDidNotAnswer`,`The hub did not answer which nodes have this package — nothing was removed.`),variant:`danger`});return}let r=Le(n.installations,e);await u({title:o(`addons.addonUninstallControls.uninstallEverywhere`,`Uninstall {{displayName}} everywhere?`,{displayName:t}),message:ze(t,r,n.unreachable.map(e=>e.nodeId)),confirmLabel:o(`addons.addonUninstallControls.uninstallFromNodeS`,`Uninstall from {{length}} node(s)`,{length:r.length}),variant:`danger`})&&await b({everywhere:!0})},C=v.isPending||i===!0;return a(`div`,{className:`flex items-center gap-1.5`,children:[r!==!0&&a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),x()},disabled:C,className:Ge,title:o(`addons.addonUninstallControls.uninstallFrom2`,`Uninstall from {{name}}`,{name:n.name}),children:[l(p,{className:`h-3 w-3`}),v.isPending?o(`addons.addonUninstallControls.removing`,`Removing...`):o(`addons.addonUninstallControls.uninstall`,`Uninstall`)]}),(g.length>1||r===!0||h.length>0)&&a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),S()},disabled:C,className:Ge,title:o(`addons.addonUninstallControls.uninstallFromEveryNodeThat`,`Uninstall from every node that has it`),children:[l(re,{className:`h-3 w-3`}),g.length>0?o(`addons.uninstallControls.everywhereCount`,{count:g.length}):o(`addons.uninstallControls.everywhere`)]})]})}function qe({packageName:e,currentVersion:t,installSource:n,onInstall:r,onClose:i,onSelect:s,selectedVersion:c}){let{t:u}=J(),p=n===`upload`||n===`local`,{data:m,isLoading:g}=H({name:e});return a(`div`,{className:`fixed z-50 w-72 rounded-lg border border-border bg-surface shadow-xl overflow-hidden`,style:{top:`auto`,bottom:`auto`},ref:e=>{if(!e)return;let t=e.parentElement?.getBoundingClientRect();if(!t)return;let n=window.innerHeight-t.bottom,r=t.top;n<280&&r>n?(e.style.bottom=`${window.innerHeight-t.top+4}px`,e.style.top=`auto`):(e.style.top=`${t.bottom+4}px`,e.style.bottom=`auto`),e.style.right=`${window.innerWidth-t.right}px`},onClick:e=>e.stopPropagation(),children:[a(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[l(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle font-medium`,children:u(`addons.versionPicker.versions`,`Versions`)}),l(`button`,{type:`button`,onClick:i,className:`text-foreground-subtle hover:text-foreground`,children:l(x,{className:`h-3 w-3`})})]}),p&&a(`div`,{className:`flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]`,children:[l(h,{className:`h-3 w-3 mt-0.5 text-cyan-500 shrink-0`}),a(`div`,{className:`text-cyan-700 dark:text-cyan-200`,children:[l(`span`,{className:`font-semibold`,children:u(`addons.versionPicker.inPlace`,{kind:n===`upload`?u(`addons.versionPicker.uploadedCopy`,`Uploaded copy`):u(`addons.versionPicker.localCopy`,`Local copy`)})}),` `,l(Y,{i18nKey:`addons.versionPicker.reinstall`,values:{version:t},components:{mono:l(`span`,{className:`font-mono`})}})]})]}),g&&a(`div`,{className:`flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle`,children:[l(E,{className:`h-3.5 w-3.5 animate-spin`}),u(`addons.versionPicker.loadingVersions`,`Loading versions...`)]}),m&&l(`div`,{className:`max-h-64 overflow-auto divide-y divide-border`,children:m.map(e=>{let n=e.version===t,i=s!==void 0&&e.version===c,p=/-(alpha|beta|rc|dev|canary|next)/i.test(e.version),m=a(o,{children:[l(`span`,{className:`font-mono flex-1 text-left ${n?`text-primary font-semibold`:p?`text-amber-400`:`text-foreground`}`,children:e.version}),n&&l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium bg-primary/10 text-primary`,children:u(`common.current`)}),e.distTags.map(e=>l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e===`latest`?`bg-emerald-500/15 text-emerald-400`:e===`beta`?`bg-amber-500/15 text-amber-400`:`bg-gray-500/15 text-gray-400`}`,children:e},e)),e.deprecated&&l(`span`,{className:`text-[9px] text-red-400 line-through`,children:u(`common.deprecated`)}),l(`span`,{className:`text-[9px] text-foreground-subtle shrink-0`,children:new Date(e.publishedAt).toLocaleDateString()})]});return s?a(`button`,{type:`button`,"aria-label":u(`addons.versionPicker.select`,`Select {{version}}`,{version:e.version}),onClick:()=>s(e.version),className:`w-full flex items-center gap-2 px-3 py-2 text-[11px] ${i?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[m,i?l(d,{className:`h-3 w-3 text-primary shrink-0`}):l(`span`,{className:`w-3 shrink-0`})]},e.version):a(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${n?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[m,l(`button`,{type:`button`,onClick:()=>r(e.version),className:`shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors`,title:n?u(`addons.versionPicker.reInstallFromNpm`,`Re-install {{version}} from npm`,{version:e.version}):u(`addons.versionPicker.install`,`Install {{version}}`,{version:e.version}),children:l(f,{className:`h-3 w-3`})})]},e.version)})}),m&&m.length===0&&l(`div`,{className:`py-4 text-center text-[10px] text-foreground-subtle`,children:u(`addons.versionPicker.noVersionsFound`,`No versions found`)})]})}e();var Je=`device-export`;function Ye(e){return e.capabilities.some(e=>(typeof e==`string`?e:e.name)===Je)}function Xe(e){return e!==`local`&&e!==`upload`}function Ze({isBundle:e,installSource:t,addonId:n,iconPath:i,color:o}){let[s,c]=r(!1),u=o?{backgroundColor:`${o.startsWith(`#`)?o:`#${o}`}26`}:void 0,d=e?`bg-indigo-500/20 text-indigo-700 dark:text-indigo-300`:`bg-purple-500/20 text-purple-700 dark:text-purple-300`,f=n&&i?g(`/api/addon-assets/${n}/${i}`):null,p=!!f&&!s;return a(`div`,{className:`relative flex-shrink-0`,children:[l(`div`,{className:`h-8 w-8 rounded-md flex items-center justify-center ${u?``:d}`,style:u,children:p?l(`img`,{src:f,alt:n,className:`h-4 w-4`,onError:()=>c(!0)}):l(e?_:y,{className:`h-3.5 w-3.5`})}),t===`local`&&l(`span`,{className:`absolute -top-1.5 -left-1.5 text-[7px] font-bold leading-none bg-orange-500 text-white px-1 py-0.5 rounded -rotate-12 shadow-sm`,children:`DEV`}),Xe(t)&&l(`span`,{className:`absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm`,children:l(`svg`,{viewBox:`0 0 780 250`,className:`w-[11px] h-[11px]`,children:l(`path`,{fill:`#fff`,d:`M240 250h100V50h100v200h340V0H0v250z`})})}),t===`upload`&&l(`span`,{className:`absolute -top-1.5 -left-1.5 flex items-center justify-center h-4 w-4 rounded bg-cyan-500 -rotate-12 shadow-sm`,children:l(h,{className:`h-2.5 w-2.5 text-white`})})]})}function Qe({version:e,availableUpdate:t,selectedVersion:n,isUpdating:r,installSource:i,disabled:o,onUpdate:s,onOpenPicker:c,children:u}){let{t:d}=J();if(r)return a(`span`,{className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border border-blue-500/30 bg-blue-500/10 text-blue-400 shrink-0`,children:[l(E,{className:`h-3 w-3 animate-spin`}),d(`addons.addonCard.updating`,`Updating…`)]});if(t){let r=n??t;return a(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[s&&a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s()},disabled:o,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-semibold border border-blue-500/30 bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,title:d(`addons.addonCard.updateTo`,`Update to {{target}}`,{target:r}),children:[l(f,{className:`h-3 w-3`}),d(`addons.addonCard.update`,`Update`)]}),a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:o,"aria-label":d(`addons.addonCard.selectVersionToInstall`,`Select version to install`),title:d(`addons.addonCard.installedUpdateAvailableSelectedTap`,`Installed {{version}} — update available. Selected {{target}}; tap to choose another version.`,{version:e,target:r}),className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-bold font-mono border border-amber-500/40 bg-amber-500/15 text-amber-500 hover:bg-amber-500/25 animate-pulse disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[l(`span`,{className:`font-normal opacity-70`,children:e}),l(`span`,{className:`font-normal opacity-70`,children:`→`}),r,l(v,{className:`h-3 w-3`})]}),u]})}return a(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:o,className:[`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-bold font-mono border transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,i===`local`?`border-orange-500/30 bg-orange-500/10 text-orange-400 hover:bg-orange-500/20`:`border-emerald-500/30 bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20`].join(` `),title:d(`addons.addonCard.versionTapToViewAll`,`Version {{version}} — tap to view all versions`,{version:e}),children:[e,l(v,{className:`h-3 w-3 opacity-50`})]}),u]})}function $e({addonId:e}){let t=s(),{data:n=`inherit`}=K({addonId:e}),r=B({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addons`,`getAddonAutoUpdate`]]})}});return l(`div`,{className:`flex rounded-lg border border-border overflow-hidden text-[10px] font-medium`,children:[`inherit`,`off`,`latest`,`beta`].map(t=>l(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),r.mutate({addonId:e,channel:t})},disabled:r.isPending,className:`px-2.5 py-1 transition-colors capitalize ${n===t?t===`inherit`?`bg-gray-700/50 text-gray-700 dark:text-gray-300`:t===`off`?`bg-gray-700 text-gray-700 dark:text-gray-300`:t===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${t===`inherit`?``:`border-l border-border`}`,children:t},t))})}var et={id:`hub`,name:`Hub`,isHub:!0};function tt({addon:e,agents:n=[],clusterStatus:i,hideVersion:c,availableUpdate:u,onUpdate:d,isUpdating:f,jobProgress:p,bundle:m,bulkItem:h,disabledByBulk:g,isSystem:y,selectedNode:S}){let{t:w}=J(),[T,E]=r(!1),[O,k]=r(!1),[re,A]=r(!1),[ae,oe]=r(null);t(()=>{oe(null)},[u]);let j=ae??u,[M,ce]=r(!1),[N,de]=r(!1),[F,I]=r(`logs`),L=s(),R=X(),{manifest:B}=e,V=e.installedOn??[],he=!m&&!B.protected&&B.removable!==!1,H=!!m,U=m?.displayName??B.name,W=m?.packageName??B.packageName,ve=m?.version??B.packageVersion??B.version,G=m?.installSource??e.installSource,be=m?m.bundle?.description??m.addons[0]?.manifest.description:B.description,K=pe({onSuccess:()=>{L.invalidateQueries({queryKey:[[`addons`]]})}}),Se=fe({onSuccess:()=>{L.invalidateQueries({queryKey:[[`addons`]]}),L.invalidateQueries({queryKey:[[`addonPages`]]}),L.invalidateQueries({queryKey:[[`capabilities`]]}),L.invalidateQueries({queryKey:[[`integrations`]]})}}),Ce=_e({onSuccess:()=>{L.invalidateQueries({queryKey:[[`addons`]]}),L.invalidateQueries({queryKey:[[`alerts`]]})}}),q=e.health,Y=q?.phase===`failed`&&!q.inGracePeriod,we=Y&&q?.nextRetryAt&&!q.retrying,Z=De(e.process);return a(`div`,{className:`rounded-md border bg-surface overflow-hidden ${Y?`border-red-500/50`:`border-border`}`,children:[Y&&q&&a(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[l(ne,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),a(`div`,{className:`flex-1 min-w-0`,children:[l(`div`,{className:`text-xs font-semibold text-danger`,children:w(`addons.addonCard.failedToLoad`,{attempt:q.retryCount})}),l(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:q.lastError?.message??w(`addons.addonCard.unknownError`,`Unknown error`)}),we&&q.nextRetryAt&&l(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:w(`addons.addonCard.autoRetryAt`,{time:new Date(q.nextRetryAt).toLocaleTimeString()})})]}),a(`button`,{type:`button`,disabled:Ce.isPending||q.retrying,onClick:e=>{e.stopPropagation(),Ce.mutate({packageName:W})},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:w(`addons.addonCard.resetRetryCounterAndForce`,`Reset retry counter and force immediate reload`),children:[l(b,{className:`h-3 w-3 ${Ce.isPending||q.retrying?`animate-spin`:``}`}),w(`addons.addonCard.retryNow`,`Retry now`)]})]}),Z!==null&&a(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[l(ne,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),a(`div`,{className:`flex-1 min-w-0`,children:[l(`div`,{className:`text-xs font-semibold text-danger`,children:w(`addons.addonCard.processProblem.${Z.kind}`)}),Z.reason!==void 0&&l(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:Z.reason})]})]}),a(`div`,{className:`flex items-start gap-2.5 px-3 py-2`,children:[l(Ze,{isBundle:H||!!B.components&&B.components.length>1,installSource:G,addonId:H?m.addons[0]?.manifest.id:B.id,iconPath:H?m.bundle?.icon??m.addons[0]?.manifest.icon:B.icon,color:H?m.addons[0]?.manifest.color:B.color}),a(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`flex items-start justify-between gap-2`,children:[l(`span`,{className:`text-xs font-semibold text-foreground truncate min-w-0`,children:U}),!c&&l(Qe,{version:ve,availableUpdate:u,...j===void 0?{}:{selectedVersion:j},isUpdating:f,installSource:G,disabled:g,...d&&j!==void 0?{onUpdate:()=>d(j)}:{},onOpenPicker:()=>A(e=>!e),children:re&&l(qe,{packageName:W,currentVersion:ve,...G?{installSource:G}:{},...u!==void 0&&j!==void 0?{selectedVersion:j,onSelect:e=>{oe(e),A(!1)}}:{},onInstall:e=>{A(!1),Se.mutate({packageName:W,version:e})},onClose:()=>A(!1)})})]}),a(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[W!==U&&l(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:W}),H&&a(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,children:[l(_,{className:`h-3 w-3`}),m.addons.length]}),y&&a(`span`,{className:`text-[10px] rounded-full bg-amber-500/15 text-amber-700 dark:text-amber-300 px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,title:w(`addons.addonCard.systemPackageUpdatingRestartsThe`,`System package — updating restarts the hub`),children:[l(b,{className:`h-3 w-3`}),w(`addons.addonCard.system`,`System`)]}),h!=null&&l(ke,{item:h}),p!=null&&l(Ie,{progress:p})]}),be&&l(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:be}),!H&&e.process&&a(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.mode===`forked`?`bg-blue-500/15 text-blue-400`:`bg-gray-500/15 text-gray-400`}`,children:e.process.mode===`forked`?w(`addons.addonCard.forked`):w(`addons.addonCard.inProcess`)}),e.process.pid!=null&&a(`span`,{className:`text-[9px] font-mono text-foreground-subtle`,children:[`PID `,e.process.pid]}),l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.state===`running`?`bg-emerald-500/15 text-emerald-400`:Z===null?`bg-gray-500/15 text-gray-400`:`bg-red-500/15 text-red-400`}`,children:e.process.state})]})]})]}),!H&&a(`div`,{className:`flex items-center gap-1 px-3 py-1 border-t border-border/50 bg-surface-hover/20`,children:[a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),K.mutate({addonId:B.id})},disabled:K.isPending||g,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border border-border text-foreground-subtle hover:text-blue-400 hover:border-blue-500/30 hover:bg-blue-500/10 disabled:opacity-50 transition-colors`,children:[l(b,{className:`h-3 w-3 ${K.isPending?`animate-spin`:``}`}),w(`addons.addonCard.restart`,`Restart`)]}),a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),ce(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${M?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[l(D,{className:`h-3 w-3`}),w(`addons.addonCard.logs`,`Logs`)]}),!H&&a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),de(!0)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${N?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[l(ee,{className:`h-3 w-3`}),w(`addons.addonCard.settings`,`Settings`)]}),l(`div`,{className:`flex-1`}),he&&l(Ke,{packageName:B.packageName,displayName:B.name,selectedNode:S??et,disabled:g})]}),i&&i.nodes.length>1&&!H&&a(`div`,{className:`border-t border-border px-3 py-1.5 bg-muted/10`,children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle mb-1.5`,children:w(`addons.addonCard.clusterDeployment`,`Cluster Deployment`)}),l(`div`,{className:`space-y-1`,children:i.nodes.map(e=>a(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[l(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`offline`?`bg-muted-foreground/30`:e.synced?`bg-success`:`bg-amber-500`}`}),l(`span`,{className:`font-medium text-foreground min-w-[60px]`,children:e.name}),l(`span`,{className:`font-mono text-foreground-subtle`,children:e.version}),!e.synced&&e.status!==`offline`&&l(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20`,children:w(`addons.addonCard.outdated`)}),e.status===`offline`&&l(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:w(`common.offline`)}),e.synced&&e.status!==`offline`&&l(`span`,{className:`text-[9px] text-success`,children:w(`common.synced`)})]},e.nodeId))})]}),M&&!H&&a(`div`,{className:`border-t border-border`,children:[a(`div`,{className:`flex items-center px-3 py-0.5 bg-surface-hover/20 border-b border-border/50`,children:[a(`div`,{className:`flex rounded border border-border overflow-hidden text-[9px]`,children:[l(`button`,{type:`button`,onClick:()=>I(`logs`),className:`px-2 py-0.5 transition-colors ${F===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:w(`addons.addonCard.logs`,`Logs`)}),l(`button`,{type:`button`,onClick:()=>I(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${F===`events`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:w(`addons.addonCard.events`,`Events`)})]}),l(`div`,{className:`flex-1`}),l(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),ce(!1)},className:`text-foreground-subtle hover:text-foreground`,children:l(x,{className:`h-3.5 w-3.5`})})]}),F===`logs`&&l(ue,{addonId:B.id,maxHeight:`max-h-64`,showFilters:!1}),F===`events`&&l(P,{addonId:B.id,category:`addon.*`,maxHeight:`max-h-64`})]}),H&&a(o,{children:[l(`button`,{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:l(T?te:v,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),T&&l(`div`,{className:`border-t border-border px-2.5 py-1.5 space-y-1.5`,children:m.addons.map(e=>l(tt,{addon:e,agents:n,hideVersion:!0},e.manifest.id))})]}),N&&!H&&l(se,{open:!0,onOpenChange:e=>!e&&de(!1),children:a(z,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[l(xe,{children:a(ge,{className:`flex items-center gap-2`,children:[l(ee,{className:`h-4 w-4 text-primary`}),w(`addons.addonCard.settingsTitle`,{name:U})]})}),a(ie,{className:`space-y-4`,children:[l(`div`,{className:`text-[10px] text-foreground-subtle mb-2`,children:w(`addons.addonCard.clusterWideSettingsOneValue`,`Cluster-wide settings — one value for every node. Per-node settings live under Cluster → the node → Settings.`)}),l(Te,{nodeId:null,addonIds:[B.id],level:`global`,fieldScope:`cluster`,emptyMessage:w(`addons.addonCard.thisAddonExposesNoCluster`,`This addon exposes no cluster-wide settings. Anything it can configure is per-node — open it from Cluster → the node → Settings.`)}),Ye(B)&&a(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:w(`addons.addonCard.deviceExport`,`Device export`)}),l(le,{addonId:B.id,onOpenDevice:e=>R(`/devices/${e}`)})]}),Xe(G)&&a(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:w(`addons.addonCard.autoUpdate`,`Auto-Update`)}),l($e,{addonId:B.id})]}),B.components&&B.components.length>0&&a(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:w(`addons.addonCard.components`,{count:B.components.length})}),l(`div`,{className:`flex flex-wrap gap-1`,children:B.components.map(e=>l(`span`,{className:`text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono`,children:e},e))})]}),n.length>=2&&a(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:w(`addons.addonCard.installedOn`,`Installed on`)}),a(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[V.length===0&&l(`span`,{className:`text-[10px] text-foreground-subtle`,children:w(`addons.addonCard.hubLocal`,`Hub (local)`)}),V.map(e=>l(`span`,{className:`rounded-full bg-surface-hover border border-border px-2 py-0.5 text-[10px] text-foreground-subtle`,children:e},e)),a(`div`,{className:`relative`,children:[a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),k(e=>!e)},className:`inline-flex items-center gap-1 rounded-full border border-dashed border-border px-2 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground hover:border-primary transition-colors`,title:w(`addons.addonCard.installOnMoreAgents`,`Install on more agents`),children:[l(C,{className:`h-3 w-3`}),w(`addons.addonCard.addAgent`,`Add agent`)]}),O&&a(`div`,{className:`absolute left-0 top-full mt-1 z-10 min-w-[160px] rounded-md border border-border bg-surface shadow-lg overflow-hidden`,children:[n.filter(e=>!e.isHub&&!V.includes(e.name)).map(e=>l(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),k(!1)},className:`w-full text-left px-3 py-1.5 text-[10px] text-foreground hover:bg-surface-hover transition-colors`,children:e.name},e.id)),n.filter(e=>!e.isHub&&!V.includes(e.name)).length===0&&l(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle`,children:w(`addons.addonCard.noAvailableAgents`,`No available agents`)})]})]})]})]})]}),l(ye,{children:l(me,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>de(!1),children:w(`common.close`,`Close`)})})]})})]})}e();var nt=`.tgz,.tar.gz,.zip`;function rt({onUploadSuccess:e}){let{t}=J(),[n,s]=r(!1),u=c(null),d=i(async t=>{s(!0);let n=new FormData;n.append(`file`,t);let r=localStorage.getItem(`camstack_admin_token`)??``;try{(await(await fetch(g(`/api/addons/upload`),{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:n})).json()).success&&e()}finally{s(!1)}},[e]);return a(o,{children:[l(`input`,{ref:u,type:`file`,accept:nt,onChange:i(e=>{let t=e.target.files?.[0];t&&d(t),e.target.value=``},[d]),className:`hidden`}),a(`button`,{type:`button`,onClick:()=>u.current?.click(),disabled:n,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,children:[n?l(E,{className:`w-3.5 h-3.5 animate-spin`}):l(h,{className:`w-3.5 h-3.5`}),n?t(`addons.addonUploadZone.uploading`,`Uploading...`):t(`addons.addonUploadZone.upload`,`Upload`)]})]})}var it=new Set([`@camstack/system`,`@camstack/types`,`@camstack/sdk`,`@camstack/ui-library`,`@camstack/addon-agent-ui`]);function at(e,t){let n=new Map;for(let r of e){if(r.isHub||r.onHub||it.has(r.packageName)||!t.isHub&&r.nodeId!==t.id)continue;let e=n.get(r.packageName)??[];e.push(r),n.set(r.packageName,e)}return[...n].map(([e,t])=>({packageName:e,rows:t})).sort((e,t)=>e.packageName.localeCompare(t.packageName))}function ot({selectedNode:e}){let{t}=J(),{data:n}=I(Ue,{staleTime:We});if(n===void 0)return null;let r=at(n.installations,e),i=n.unreachable.filter(t=>e.isHub||t.nodeId===e.id);return r.length===0&&i.length===0?null:a(`div`,{className:`rounded-lg border border-warning/30 bg-warning/5 px-3 py-2.5 space-y-2`,children:[a(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold text-foreground`,children:[l(m,{className:`h-3.5 w-3.5 text-warning`}),e.isHub?t(`addons.nodeOnlyPackagesPanel.installedOnAgentsButNot`,`Installed on agents but not on the hub`):t(`addons.nodeOnlyPackagesPanel.installedOnButNotOn`,`Installed on {{name}} but not on the hub`,{name:e.name})]}),i.length>0&&l(`div`,{className:`text-[10px] text-foreground-subtle`,children:t(`addons.nodeOnlyPackagesPanel.unreachable`,{nodes:i.map(e=>e.nodeId).join(`, `)})}),r.map(t=>a(`div`,{className:`flex items-center justify-between gap-3 flex-wrap rounded-md border border-border bg-surface px-3 py-2`,children:[a(`div`,{className:`min-w-0`,children:[l(`div`,{className:`text-xs font-mono text-foreground break-all`,children:t.packageName}),l(`div`,{className:`text-[10px] text-foreground-subtle`,children:t.rows.map(e=>`${e.nodeName}${e.version===null?``:` ${e.version}`}${e.isOnline?``:` (offline)`}`).join(` · `)})]}),l(Ke,{packageName:t.packageName,displayName:t.packageName,selectedNode:e,hideNodeAction:e.isHub})]},t.packageName))]})}function st({addon:e,installing:t,onInstall:n}){let{t:r}=J();return a(`div`,{className:`flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors`,children:[l(`div`,{className:`w-6 h-6 rounded-md bg-primary/10 flex items-center justify-center text-primary text-[9px] font-bold shrink-0`,children:e.name.replace(`@camstack/addon-`,``).charAt(0).toUpperCase()}),a(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[l(`span`,{className:`text-[11px] font-semibold break-words`,children:e.name.replace(/^@camstack\/(addon-)?/,``)}),a(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`v`,e.version]})]}),l(`div`,{className:`font-mono text-[9px] text-foreground-subtle/80 truncate`,children:e.name}),e.description&&l(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.description})]}),e.installed?l(N,{variant:`success`,icon:l(d,{className:`h-3 w-3`}),children:e.installedVersion??r(`system.capabilityCatalog.installed`,`Installed`)}):a(me,{size:`sm`,onClick:()=>n(e.name),disabled:t,className:`shrink-0`,children:[t?l(E,{className:`h-3 w-3 animate-spin`}):l(f,{className:`h-3 w-3`}),r(`system.capabilityCatalog.install`,`Install`)]})]})}function ct({capability:e,installing:t,onInstall:n}){let{t:r}=J(),{data:i,isPending:o,isError:s}=V({capability:e}),c;if(s)c=l(`div`,{className:`px-3 py-2 text-xs text-danger`,children:r(`system.capabilityCatalog.couldNotSearchTheNpm`,`Could not search the npm catalog right now. Try again in a moment.`)});else if(o||i===void 0)c=a(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-foreground-subtle`,children:[l(E,{className:`h-3 w-3 animate-spin`}),r(`system.capabilityCatalog.searchingTheNpmCatalog`,`Searching the npm catalog…`)]});else{let a=i.filter(e=>!e.installed);c=a.length===0?l(`div`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:i.length===0?r(`system.capabilityCatalog.noPublishedAddonDeclaresThe`,`No published addon declares the "{{capability}}" capability.`,{capability:e}):r(`system.capabilityCatalog.everyPublishedAddonThatDeclares`,`Every published addon that declares "{{capability}}" is already installed.`,{capability:e})}):l(`div`,{className:`divide-y divide-border`,children:a.map(e=>l(st,{addon:e,installing:t,onInstall:n},e.name))})}return a(`section`,{className:`rounded-md border border-border bg-surface overflow-hidden`,"aria-label":r(`system.capabilityCatalog.availableToInstall`,`Available to install`),children:[l(`h2`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:r(`system.capabilityCatalog.availableToInstall`,`Available to install`)}),c]})}e();function lt(e){return e===`npm`||e===`dev`?e:null}var ut=`rounded-full border border-primary bg-primary/10 px-2 py-0.5 text-[10px] text-foreground`,dt=`rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-muted hover:bg-surface-hover`,ft=[{seconds:900,label:`15m`},{seconds:3600,label:`1h`},{seconds:21600,label:`6h`},{seconds:43200,label:`12h`},{seconds:86400,label:`24h`}],pt=new Set([`@camstack/system`,`@camstack/types`,`@camstack/sdk`,`@camstack/shm-ring`,`@camstack/ui-library`]);function mt(e){return e!==void 0&&pt.has(e)}var ht={id:`hub`,name:`Hub`,isHub:!0,isOnline:!0};function gt(e,t){let n=e??`hub-only`;return n===`any-node`?!0:n===`hub-only`?t:!t}function _t(e){return e===`local`?`dev`:`npm`}function vt(e){let t=e;if(!t?.manifest)return null;let n={...t.manifest,name:t.manifest.name??t.manifest.id,version:t.manifest.version??`0.0.0`,capabilities:t.manifest.capabilities??[]},r=t.process,i=r?{pid:r.pid,mode:r.mode===`forked`?`forked`:`in-process`,state:r.state??`unknown`,...r.reason===void 0?{}:{reason:r.reason}}:void 0,a=t.health,o=t.declaration?.execution,s=t.manifest.execution,c=o?.placement??s?.placement;return{manifest:n,enabled:!0,source:t.source,installSource:t.installSource,installedOn:[],...i?{process:i}:{},hasBackup:t.hasBackup,...a?{health:a}:{},...c?{placement:c}:{}}}function yt(e){let t=new Map,n=[];for(let r of e){let e=r.manifest.packageName;if(!e){n.push(r);continue}let i=t.get(e);if(i)i.addons.push(r);else{let n=r.manifest.bundle,i={packageName:e,displayName:n?.displayName??r.manifest.packageDisplayName??r.manifest.name,version:r.manifest.packageVersion,addons:[r],...r.installSource===void 0?{}:{installSource:r.installSource},...n===void 0?{}:{bundle:n}};t.set(e,i)}}let r=[];for(let e of t.values())e.bundle!==void 0||e.addons.length>=2?r.push({bundle:e,representative:e.addons[0]}):r.push(e.addons[0]);return r.push(...n),r}function $(e){return`bundle`in e}function bt({addons:e,clusterStatus:o,selectedNode:d,onRefresh:p,isRefreshing:m}){let{t:h}=J(),g=s(),[_,v]=r(``),y=u(_),[x,C]=r(!1),T=c(null);t(()=>{if(!x)return;let e=e=>{T.current&&!T.current.contains(e.target)&&C(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[x]);let{data:D}=Se({nodeId:d.id}),O=n(()=>{let e=new Map;for(let t of D??[])e.set(t.name,t.latestVersion);return e},[D]),ee=n(()=>(D??[]).filter(e=>!e.isSystem).length,[D]),[te,k]=r(()=>new Set),[ne,re]=r(()=>new Map),ie=i(e=>{k(t=>new Set(t).add(e))},[]),oe=i(e=>{k(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),j=i((e,t)=>{re(n=>new Map(n).set(e,t))},[]),M=i(e=>{re(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),se=Ce({onMutate:e=>{ie(e.name),M(e.name)},onSuccess:(e,t)=>{oe(t.name);let n=e;if(n&&n.success===!1){j(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)=>{oe(t.name),j(t.name,e instanceof Error?e.message:String(e))}}),N=Pe(),le=c(new Set);t(()=>{let e=new Set;for(let[t,n]of N)Me(n)&&e.add(t);let t=[...le.current].some(t=>!e.has(t));le.current=e,t&&(g.invalidateQueries({queryKey:[[`addons`]]}),g.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[N,g]);let{data:P}=ve(void 0),ue=ce({onSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),F=de({onSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:I,isFetching:L}=V({query:y||void 0},{enabled:x}),R=q(),{data:z}=be(void 0),pe=z?.requestedAt,[B,me]=r(null),[he,H]=r(!1);t(()=>{if(z?.kind===`framework-bulk-update`&&z.requestedAt!==B){me(z.requestedAt),H(!0);let e=window.setTimeout(()=>H(!1),6e3);return()=>window.clearTimeout(e)}},[pe,B,z]),A();let ge=i(async()=>{let e=(D??[]).filter(e=>!e.isSystem);if(e.length!==0){if(!d.isHub){for(let t of e)await se.mutateAsync({name:t.name,version:t.latestVersion,nodeId:d.id});return}await R.mutateAsync({kind:`update`,targets:e.map(e=>({name:e.name,version:e.latestVersion})),nodeIds:[d.id]})}},[D,d.id,d.isHub,R,se]),U=fe({onSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`]]}),g.invalidateQueries({queryKey:[[`addonPages`]]}),g.invalidateQueries({queryKey:[[`capabilities`]]}),g.invalidateQueries({queryKey:[[`integrations`]]})}}),[W,_e]=r(`type`),[ye,G]=r(()=>typeof window>`u`?`grouped`:window.localStorage.getItem(`camstack.addons.viewMode`)===`flat`?`flat`:`grouped`),xe=e=>{G(e),typeof window<`u`&&window.localStorage.setItem(`camstack.addons.viewMode`,e)},[K,Y]=we(),X=K.get(`capability`),Z=K.get(`updatable`)===`1`,Te=K.get(`error`)===`1`,Q=lt(K.get(`source`)),Ee=i(e=>{let t=new URLSearchParams(K);e?t.set(`updatable`,`1`):t.delete(`updatable`),Y(t,{replace:!0})},[K,Y]),Oe=i(e=>{let t=new URLSearchParams(K);e?t.set(`error`,`1`):t.delete(`error`),Y(t,{replace:!0})},[K,Y]),ke=i(e=>{let t=new URLSearchParams(K);e===null?t.delete(`source`):t.set(`source`,e),Y(t,{replace:!0})},[K,Y]),Ae=n(()=>e.filter(e=>De(e.process)!==null).length,[e]),je=n(()=>{let t=e.filter(e=>!mt(e.manifest.packageName));return d.isHub||(t=t.filter(e=>gt(e.placement,d.isHub))),X&&(t=t.filter(e=>(e.manifest.capabilities??[]).some(e=>(typeof e==`string`?e:e.name)===X))),Z&&(t=t.filter(e=>{let t=e.manifest.packageName;return t!==void 0&&O.has(t)})),Q!==null&&(t=t.filter(e=>_t(e.installSource)===Q)),Te&&(t=t.filter(e=>De(e.process)!==null)),t},[e,d.isHub,X,Z,Q,Te,O]),Ne=()=>{let e=new URLSearchParams(K);e.delete(`capability`),Y(e,{replace:!0})},Fe=ye===`flat`?je:yt(je),Ie=n(()=>{let e=[...Fe];switch(W){case`type`:e.sort((e,t)=>{let n=+!$(e),r=+!$(t);if(n!==r)return n-r;let i=$(e)?e.bundle.displayName:e.manifest.name,a=$(t)?t.bundle.displayName:t.manifest.name;return i.localeCompare(a)});break;case`name`:e.sort((e,t)=>{let n=$(e)?e.bundle.displayName:e.manifest.name,r=$(t)?t.bundle.displayName:t.manifest.name;return n.localeCompare(r)});break;case`source`:e.sort((e,t)=>{let n=$(e)?e.bundle.installSource??``:e.installSource??``,r=$(t)?t.bundle.installSource??``:t.installSource??``;return n.localeCompare(r)});break}return e},[Fe,W]);return a(`div`,{className:`space-y-3`,children:[[...ne.entries()].map(([e,t])=>l(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-2.5 py-1.5 text-[11px]`,children:a(`div`,{className:`flex items-start justify-between gap-3`,children:[a(`div`,{className:`space-y-0.5`,children:[l(`div`,{className:`font-medium text-danger`,children:h(`systemPage.addons.updateFailed`,{name:e})}),l(`div`,{className:`text-foreground-subtle font-mono`,children:t})]}),l(`button`,{type:`button`,onClick:()=>M(e),className:`text-foreground-subtle hover:text-foreground text-[10px]`,children:h(`common.dismiss`)})]})},e)),a(`div`,{className:`flex items-center gap-x-2 gap-y-1.5 flex-wrap`,children:[a(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.sort`,`Sort:`)}),a(`select`,{value:W,onChange:e=>_e(e.target.value),className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:outline-none focus:border-primary/50`,children:[l(`option`,{value:`type`,children:h(`admin.system.addons.bundlesFirst`,`Bundles first`)}),l(`option`,{value:`name`,children:h(`admin.system.addons.name`,`Name`)}),l(`option`,{value:`source`,children:h(`admin.system.addons.installSource`,`Install source`)})]})]}),a(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.view`,`View:`)}),l(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`grouped`,`flat`].map(e=>l(`button`,{type:`button`,onClick:()=>xe(e),className:`px-2 py-1 transition-colors capitalize ${ye===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))})]}),d.isHub&&a(`div`,{className:`flex items-center gap-1.5`,children:[l(b,{className:`h-3 w-3 text-foreground-subtle`}),l(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.autoUpdate`,`Auto-Update:`)}),l(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`off`,`latest`,`beta`].map(e=>l(`button`,{type:`button`,onClick:()=>ue.mutate({channel:e}),disabled:ue.isPending,className:`px-2 py-1 transition-colors capitalize ${P?.channel===e?e===`off`?`bg-gray-700 text-gray-200`:e===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${e===`off`?``:`border-l border-border`}`,children:e},e))})]}),d.isHub&&a(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.checkEvery`,`Check every:`)}),l(`select`,{className:`rounded-md border border-border bg-transparent px-1.5 py-1 text-[10px] font-medium text-foreground-subtle`,value:P?.updateCheckIntervalSeconds??21600,disabled:F.isPending||P===void 0,onChange:e=>{P!==void 0&&F.mutate({channel:P.channel,updateCheckIntervalSeconds:Number(e.target.value)})},children:ft.map(e=>l(`option`,{value:e.seconds,children:e.label},e.seconds))})]}),ee>0&&a(`button`,{type:`button`,onClick:()=>void ge(),disabled:R.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:[R.isPending?l(E,{className:`w-3 h-3 animate-spin`}):l(f,{className:`w-3 h-3`}),R.isPending?h(`admin.system.addons.updating`,`Updating…`):h(`admin.system.addons.updateAll`,`Update All ({{nonSystemUpdateCount}})`,{nonSystemUpdateCount:ee})]}),a(`button`,{type:`button`,onClick:p,disabled:m||R.isPending,className:`flex items-center gap-1 px-2 py-1 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,children:[l(b,{className:`w-3 h-3 ${m?`animate-spin`:``}`}),h(`common.refresh`,`Refresh`)]})]}),a(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`group`,"aria-label":h(`admin.system.addons.filterInstalledAddons`,`Filter installed addons`),children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.filter`,`Filter:`)}),[{id:`updatable`,label:h(`admin.system.addons.updatable`,`Updatable`),pressed:Z,toggle:()=>Ee(!Z)},{id:`error`,label:h(`admin.system.addons.inError`,`In error ({{count}})`,{count:Ae}),pressed:Te,toggle:()=>Oe(!Te)},{id:`npm`,label:`npm`,pressed:Q===`npm`,toggle:()=>ke(Q===`npm`?null:`npm`)},{id:`dev`,label:h(`admin.system.addons.dev`,`Dev`),pressed:Q===`dev`,toggle:()=>ke(Q===`dev`?null:`dev`)}].map(e=>l(`button`,{type:`button`,"aria-pressed":e.pressed,onClick:e.toggle,className:e.pressed?ut:dt,children:e.label},e.id))]}),a(`div`,{className:`flex flex-col gap-1.5 sm:flex-row sm:items-center sm:gap-2`,children:[a(`div`,{className:`relative flex-1 min-w-0 sm:min-w-[200px]`,ref:T,children:[l(ae,{type:`text`,value:_,onChange:e=>{v(e.target.value),C(!0)},onFocus:()=>C(!0),placeholder:h(`admin.system.addons.searchAddonsOnNpm`,`Search addons on npm...`),"aria-label":h(`admin.system.addons.searchAddonsOnNpm2`,`Search addons on npm`),disabled:R.isPending,leftSlot:l(S,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),rightSlot:L?l(E,{className:`h-3 w-3 animate-spin`}):void 0}),x&&I&&I.length>0&&a(`div`,{className:`absolute left-0 right-0 top-full mt-1 z-40 rounded-md border border-border bg-surface shadow-xl overflow-hidden`,children:[I.length>0&&l(`div`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:h(`systemPage.addons.npmResults`,{count:I.length})}),I&&I.length>0&&l(`div`,{className:`max-h-72 overflow-auto divide-y divide-border`,children:I.map(e=>l(st,{addon:e,installing:U.isPending,onInstall:e=>U.mutate({packageName:e})},e.name))})]})]}),l(rt,{onUploadSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`]]}),p()}})]}),X&&a(`div`,{className:`flex items-center gap-2 px-2.5 py-1.5 rounded-md bg-primary/10 border border-primary/30 text-xs`,children:[l(`span`,{className:`text-foreground-subtle`,children:h(`admin.system.addons.filteringByCapability`,`Filtering by capability:`)}),l(`span`,{className:`font-mono text-primary font-semibold`,children:X}),l(`button`,{type:`button`,onClick:Ne,className:`ml-auto text-xs text-foreground-subtle hover:text-foreground underline`,children:h(`admin.system.addons.clear`,`Clear`)})]}),X&&l(ct,{capability:X,installing:U.isPending,onInstall:e=>U.mutate({packageName:e})}),X&&je.length>0&&l(`h2`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:h(`admin.system.addons.installed`,`Installed`)}),he&&a(`div`,{className:`fixed top-[calc(env(safe-area-inset-top)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 flex items-start gap-2 px-3 py-2.5 rounded-md border border-green-500/30 bg-green-500/10 shadow-lg backdrop-blur-sm max-w-sm pointer-events-auto`,children:[l(w,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),a(`div`,{children:[l(`div`,{className:`text-[11px] font-semibold text-foreground`,children:h(`admin.system.addons.bulkUpdateCompleted`,`Bulk update completed`)}),l(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:h(`admin.system.addons.systemPackagesUpdatedHubRestarted`,`System packages updated — hub restarted successfully.`)})]})]}),je.length===0&&l(`div`,{className:`text-xs text-foreground-subtle`,children:e.length===0?h(`admin.system.addons.noAddonsInstalled`,`No addons installed`):X?h(`admin.system.addons.noInstalledAddonDeclaresThe`,`No installed addon declares the "{{capabilityFilter}}" capability. Any addon you can install appears under "Available to install" above.`,{capabilityFilter:X}):h(`admin.system.addons.noAddonsCompatibleWithPlacement`,`No addons compatible with {{name}} (placement filter active)`,{name:d.name})}),l(`div`,{className:`space-y-1.5`,children:Ie.map(e=>{let t=$(e)?e.bundle.packageName:e.manifest.packageName,n=O.get(t),r=$(e)?e.representative:e,i=n?e=>se.mutate({name:t,version:e,nodeId:d.id}):void 0,a=N.get(t)??null,s=a!==null&&Me(a);return l(tt,{addon:r,clusterStatus:o?.[r.manifest.id],bundle:$(e)?e.bundle:void 0,availableUpdate:n,isUpdating:te.has(t)||s,jobProgress:a,onUpdate:i,disabledByBulk:R.isPending,selectedNode:d},$(e)?t:e.manifest.id)})})]})}function xt(){let{t:e}=J(),n=s(),{data:r}=M(void 0),{nodes:i}=oe(),{selection:o,selectNode:u,requestedNodeId:d}=Ee(i.length>0?i:[ht]),f=o.node??ht,p=f.id,m=i.length>0?o.staleNodeId:null,{data:h,isLoading:g,isError:_}=G({nodeId:p}),v=R(),y=L(),x=v.isPending||y.isPending,S=async()=>{await v.mutateAsync({nodeId:p}),await y.mutateAsync(),n.invalidateQueries({queryKey:[[`addons`]]})},C=c(v);C.current=v;let w=c(d??`hub`);t(()=>{C.current.mutate({nodeId:w.current})},[]);let T=(h??[]).map(vt).filter(e=>e!==null);return a(Z,{children:[a(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[l(he,{selectedNodeId:p,onSelect:u}),a(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[!g&&!_&&l(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium`,children:e(`systemPage.addons.installedCount`,{count:T.length})}),a(`button`,{type:`button`,onClick:()=>void S(),disabled:x,className:`inline-flex items-center gap-1 px-2 py-1 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,title:e(`admin.system.addons.reFetchAddonsCheckNpm`,`Re-fetch addons + check npm for new versions`),children:[l(b,{className:`w-3 h-3 ${x?`animate-spin`:``}`}),e(`admin.system.addons.checkForUpdates`,`Check for updates`)]})]})]}),l(Q,{staleNodeId:m,shownNodeName:f.name}),l(ot,{selectedNode:f}),g&&l(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:e(`common.loading`,`Loading…`)}),_&&l(`div`,{className:`text-xs text-danger`,children:e(`admin.system.addons.failedToLoadAddons`,`Failed to load addons`)}),!g&&!_&&l(bt,{addons:T,clusterStatus:r,selectedNode:f,onRefresh:()=>void S(),isRefreshing:x})]})}export{xt as AddonsPage};
@@ -1,3 +0,0 @@
1
- import{$ as e,B as t,G as n,J as r,L as i,S as a,a as o,b as s,q as c,t as l,x as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{D as d,Fn as f,G as p,Gr as m,It as h,L as g,Mi as _,Mr as v,Ni as y,Oi as b,On as x,Or as S,Q as C,Yt as w,Zi as T,Zr as E,Zt as D,bn as O,dn as k,dt as A,ei as j,fn as M,kn as N,or as P,ot as F}from"./player-overlays-BYMAZza9.js";import{lr as I,qi as L,ur as R}from"./client-BggkinSi.js";import{t as ee}from"./message-square-plus-BWjzgumP.js";import{t as te}from"./send-C-dY1QlF.js";import{$ as ne,Ar as z,Au as re,Nn as B,Rr as V,Tu as ie,Ya as H,_n as U,_t as ae,dt as W,fr as G,gn as K,gr as oe,hr as q,jn as se,ju as ce,lt as le,mn as J,mr as Y,pr as X,qn as ue,vt as de,zn as fe}from"./src-75D_Zlij.js";import{t as Z}from"./i18n-BimjnPQq.js";import{t as Q}from"./useTranslation-D3Is_4B6.js";import"./mount-B7xNzrPL.js";import{T as pe,nt as me}from"./index-BVY_WMe1.js";import{t as he}from"./AdminSectionedPage-c5oc7MKr.js";import{t as ge}from"./AdminPage-D_zEoNvj.js";e();var _e=`__redacted__`,ve=[`llm`,`listProfiles`],ye=[`llm`,`listProfileKinds`],be=[`llm`,`getDefaults`],xe=[`llm`,`listRuntimeNodes`],Se=[`llm`,`listModelCatalog`],Ce=[`llm`,`getUsage`],we=[{purpose:`vision`,visionOnly:!0},{purpose:`text`,visionOnly:!1}],Te=new Map([[`cloud`,j],[`plug`,x],[`cpu`,E],[`server`,k],[`sparkles`,D]]);function Ee(e){return Te.get(e)??y}function De(e){return typeof e==`string`&&e.length>0?e:void 0}function Oe(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:void 0}}function ke(e){return e===!0}function Ae(e){let t=new Map;for(let n of e){let e=t.get(n.addonId)??[];e.push(n),t.set(n.addonId,e)}return[...t.entries()].map(([e,t])=>({addonId:e,kinds:t}))}var je={deviceNotEligible:{key:`ai.appleNotEligible`,tone:`default`},appleIntelligenceNotEnabled:{key:`ai.appleIntelligenceOff`,tone:`warning`},modelNotReady:{key:`ai.appleModelNotReady`,tone:`warning`},osTooOld:{key:`ai.appleOsTooOld`,tone:`default`},helperMissing:{key:`ai.appleHelperMissing`,tone:`danger`},helperCrashed:{key:`ai.appleHelperCrashed`,tone:`danger`}};function Me(e){let t=t=>({nodeId:e.nodeId,selectable:!1,labelKey:`ai.appleUnknown`,labelDefault:Z.t(`ai.appleUnknown`),detail:t,tone:`default`});if(!e.reachable)return t(e.error??null);let n=e.apple;if(n===void 0)return t(null);switch(n.state){case`available`:return{nodeId:e.nodeId,selectable:!0,labelKey:`ai.appleAvailable`,labelDefault:Z.t(`ai.appleAvailable`),detail:Z.t(n.imageInput?`helpers.aiPage.appleDetailImages`:`helpers.aiPage.appleDetailText`,{version:n.osVersion}),tone:`success`};case`unavailable`:{let t=je[n.reason];return{nodeId:e.nodeId,selectable:!1,labelKey:t.key,labelDefault:Z.t(t.key),detail:n.detail,tone:t.tone}}case`unsupported-platform`:return{nodeId:e.nodeId,selectable:!1,labelKey:`ai.appleNotMac`,labelDefault:Z.t(`ai.appleNotMac`),detail:n.platform,tone:`default`};case`unknown`:return t(n.error)}}var Ne={temperature:[{type:`slider`,key:`temperature`,label:`Temperature`,min:0,max:2,step:.1,showValue:!0,showStepper:!0,nullable:!0,nullLabel:`Provider default`,description:`The judging gates pin this to 0 per call regardless of the profile.`}],topP:[{type:`slider`,key:`topP`,label:`Top-p`,min:0,max:1,step:.05,showValue:!0,showStepper:!0,nullable:!0,nullLabel:`Provider default`}],topK:[{type:`number`,key:`topK`,label:`Top-k`,min:1}],maxTokens:[{type:`number`,key:`maxTokens`,label:`Max output tokens`,min:1}],contextLength:[{type:`number`,key:`contextLength`,label:`Context length`,min:512,unit:`tokens`,description:`Advisory: the provider enforces its own window.`}],systemPrompt:[{type:`textarea`,key:`systemPrompt`,label:`Default system prompt`,rows:4,maxLength:4e3,span:2,description:`A caller that sends its own system prompt REPLACES this one.`}],timeoutMs:[{type:`number`,key:`timeoutMs`,label:`Total (ms)`,min:1e3,default:R.totalMs,unit:`ms`,description:`The whole generation. The only bound a non-streaming call has.`}],connectTimeoutMs:[{type:`number`,key:`connectTimeoutMs`,label:`Connect (ms)`,min:500,default:R.connectMs,unit:`ms`,description:`The TCP handshake — "is the port even open".`}],firstTokenTimeoutMs:[{type:`number`,key:`firstTokenTimeoutMs`,label:`First token (ms)`,min:1e3,default:R.firstTokenMs,unit:`ms`,description:`Accepted but silent. A cold model load lives here and can take minutes.`}],idleTimeoutMs:[{type:`number`,key:`idleTimeoutMs`,label:`Idle (ms)`,min:1e3,default:R.idleMs,unit:`ms`,description:`Output started, then stopped.`}],retry:[{type:`boolean`,key:`retryEnabled`,label:`Retry on failure`,description:`Per-consumer policy still wins: the notification gates never retry.`},{type:`number`,key:`retryMaxAttempts`,label:`Max attempts`,min:1,max:5,default:1,showWhen:{field:`retryEnabled`,equals:!0}}],toolsEnabled:[{type:`boolean`,key:`toolsEnabled`,label:`Enable tools`,description:`Lets this profile make tool calls. No tools are registered yet.`}]},Pe=[`temperature`,`topP`,`topK`,`maxTokens`,`contextLength`,`systemPrompt`],Fe=[`timeoutMs`,`connectTimeoutMs`,`firstTokenTimeoutMs`,`idleTimeoutMs`,`retry`,`toolsEnabled`];function Ie(e,t){return t.filter(t=>e.includes(t)).flatMap(e=>Ne[e])}function Le(e){let t=Ie(e,Pe);return t.length===0?null:{sections:[{id:`generation`,title:`Generation`,fields:t}]}}function Re(e){let t=Ie(e,Fe);return t.length===0?null:{sections:[{id:`bounds`,title:`Timeouts and policy`,fields:t}]}}function ze(e){return e===null?{}:{temperature:e.temperature,topP:e.topP,topK:e.topK,maxTokens:e.maxTokens,contextLength:e.contextLength,systemPrompt:e.systemPrompt,timeoutMs:e.timeoutMs,connectTimeoutMs:e.connectTimeoutMs,firstTokenTimeoutMs:e.firstTokenTimeoutMs,idleTimeoutMs:e.idleTimeoutMs,retryEnabled:e.retry.enabled,retryMaxAttempts:e.retry.maxAttempts,toolsEnabled:e.toolsEnabled}}function Be(e,t){return{...e.features,...t?.features}}function Ve(e,t){return t===null?e.modelCatalog===`static`?e.staticModels??[]:[]:t}function He(e,t,n){let r=e.profileFields,i=n.common,a=(e,t,n)=>r.includes(e)?Oe(i[e])??t:n??t,o=e=>r.includes(e)?Oe(i[e]):t?.[e],s=o(`temperature`),c=o(`topP`),l=o(`topK`),u=o(`maxTokens`),d=o(`contextLength`),f=r.includes(`systemPrompt`)?De(i.systemPrompt):t?.systemPrompt;return{id:t?.id??crypto.randomUUID(),name:n.name,kind:e.kind,addonId:e.addonId.length>0?e.addonId:`ai`,enabled:t?.enabled??!0,model:n.model,supportsVision:n.supportsVision,timeoutMs:a(`timeoutMs`,R.totalMs,t?.timeoutMs),connectTimeoutMs:a(`connectTimeoutMs`,R.connectMs,t?.connectTimeoutMs),firstTokenTimeoutMs:a(`firstTokenTimeoutMs`,R.firstTokenMs,t?.firstTokenTimeoutMs),idleTimeoutMs:a(`idleTimeoutMs`,R.idleMs,t?.idleTimeoutMs),retry:r.includes(`retry`)?{enabled:ke(i.retryEnabled),maxAttempts:Oe(i.retryMaxAttempts)??1}:t?.retry??{enabled:!1,maxAttempts:1},toolsEnabled:r.includes(`toolsEnabled`)?ke(i.toolsEnabled):t?.toolsEnabled??!1,...s===void 0?{}:{temperature:s},...c===void 0?{}:{topP:c},...l===void 0?{}:{topK:l},...u===void 0?{}:{maxTokens:u},...d===void 0?{}:{contextLength:d},...f===void 0?{}:{systemPrompt:f},providerConfig:n.providerConfig}}var Ue=2e3;function $(e){return Z.t(`system.aiModelPicker.sizeGb`,{value:(e/1e9).toFixed(2)})}function We(e){return e===null?``:e.model.kind===`catalog`?`catalog:${e.model.catalogId}`:e.model.kind===`path`?`node:${e.modelId}`:`custom`}function Ge({nodeId:e,value:t,onChange:i}){let{t:s}=Q(),c=F(),[d,f]=r(``),[p,h]=r(null),[g,_]=r(!1),v=o({queryKey:Se,queryFn:()=>c.trpcClient.llm.listModelCatalog.query({})}),y=o({queryKey:[`llm`,`listNodeModels`,e],queryFn:()=>c.trpcClient.llm.listNodeModels.query({nodeId:e})}),b=l({mutationFn:e=>c.trpcClient.llm.resolveModelRef.mutate(e),onSuccess:e=>{h(e),_(!1),e.ok&&i({model:e.model,modelId:e.label,supportsVision:e.purpose===`vision`})}}),x=l({mutationFn:t=>c.trpcClient.llm.installModel.mutate({nodeId:e,model:t}),onSuccess:()=>{_(!0),y.refetch()}}),S=o({queryKey:xe,enabled:x.isPending,refetchInterval:x.isPending?Ue:!1,queryFn:()=>c.trpcClient.llm.listRuntimeNodes.query({})}).data?.find(t=>t.nodeId===e)?.status?.download,C=n(()=>{let t=(v.data??[]).map(e=>({value:`catalog:${e.id}`,label:`${e.label} · ${e.quantization} · ${$(e.sizeBytes)}`})),n=(y.data??[]).filter(e=>e.catalogId===void 0&&e.path!==void 0).map(t=>({value:`node:${t.file}`,label:s(`ai.onNode`,`{{file}} · {{size}} · on {{node}}`,{file:t.file,size:$(t.sizeBytes),node:e})})),r=p?.ok===!0?[{value:`custom`,label:`${p.label} · ${$(p.totalBytes)}`}]:[];return[{value:``,label:s(`ai.selectModel`,`Select a model…`)},...t,...n,...r]},[v.data,y.data,p,e,s]),w=e=>{if(e===``){i(null);return}if(e===`custom`){if(p?.ok!==!0)return;i({model:p.model,modelId:p.label,supportsVision:p.purpose===`vision`});return}if(e.startsWith(`catalog:`)){let t=e.slice(8),n=v.data?.find(e=>e.id===t);i({model:{kind:`catalog`,catalogId:t},modelId:t,supportsVision:n?.purpose===`vision`});return}let t=e.slice(5),n=y.data?.find(e=>e.file===t);n?.path!==void 0&&i({model:{kind:`path`,path:n.path},modelId:t,supportsVision:!1})},T=e=>{d.trim()!==``&&b.mutate({ref:d.trim(),...e===void 0?{}:{maxBytes:e}})};return a(`div`,{className:`space-y-3`,children:[u(de,{label:s(`ai.model`,`Model`),required:!0,children:u(ie,{id:`ai-model`,"aria-label":s(`ai.model`,`Model`),value:We(t),options:C,onChange:e=>w(e.target.value)})}),u(de,{label:s(`ai.hfTitle`,`Add a model from Hugging Face`),description:s(`ai.hfHint`,`Paste a GGUF file URL, or type org/repo — add :QUANT (e.g. unsloth/Qwen3.6-35B-A3B-GGUF:UD-Q4_K_M) when the repo publishes more than one quantization.`),children:a(`div`,{className:`flex gap-2`,children:[u(re,{"aria-label":s(`ai.hfTitle`,`Add a model from Hugging Face`),value:d,onChange:e=>f(e.target.value),placeholder:s(`system.aiModelPicker.unslothQwen3635bA3b`,`unsloth/Qwen3.6-35B-A3B-GGUF:UD-Q4_K_M`),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T())}}),a(q,{size:`sm`,variant:`secondary`,type:`button`,disabled:d.trim()===``||b.isPending,onClick:()=>T(),children:[b.isPending?u(P,{className:`h-3.5 w-3.5 animate-spin`}):u(M,{className:`h-3.5 w-3.5`}),s(`ai.hfCheck`,`Check`)]})]})}),b.isError&&u(G,{message:b.error instanceof Error?b.error.message:s(`common.error`,`Error`)}),p?.ok===!1&&u(G,{message:p.message,action:a(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(p.candidates??[]).map(e=>u(q,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>{let t=`${d.trim().split(`:`)[0]??``}:${e}`;f(t),b.mutate({ref:t})},children:e},e)),p.requiredBytes!==void 0&&u(q,{size:`sm`,variant:`secondary`,type:`button`,onClick:()=>T(p.requiredBytes),children:s(`ai.hfOverride`,`Install anyway ({{size}})`,{size:$(p.requiredBytes)})})]})}),p?.ok===!0&&a(`div`,{className:`space-y-2 rounded-md border border-border bg-surface p-2.5`,children:[a(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[u(`span`,{className:`text-[11px] font-medium text-foreground`,children:p.label}),u(V,{variant:p.purpose===`vision`?`info`:`default`,children:p.purpose}),u(V,{variant:`default`,children:$(p.totalBytes)})]}),p.extraFilenames.length>0&&u(`p`,{className:`text-[10px] text-foreground-subtle`,children:s(`ai.hfExtras`,`Also downloads: {{files}}`,{files:p.extraFilenames.join(`, `)})}),a(`div`,{className:`flex items-center gap-2`,children:[a(q,{size:`sm`,type:`button`,disabled:x.isPending||g,onClick:()=>x.mutate(p.model),children:[x.isPending?u(P,{className:`h-3.5 w-3.5 animate-spin`}):u(m,{className:`h-3.5 w-3.5`}),g?s(`ai.hfInstalled`,`Downloaded`):s(`ai.hfInstall`,`Download to {{node}}`,{node:e})]}),S!==void 0&&u(`span`,{className:`text-[10px] text-foreground-subtle`,children:S.phase===`verifying`?s(`ai.hfVerifying`,`verifying {{file}}…`,{file:S.file}):s(`ai.hfDownloading`,`{{file}} ({{index}}/{{count}}) — {{done}}{{total}}`,{file:S.file,index:S.fileIndex,count:S.fileCount,done:$(S.downloadedBytes),total:S.totalBytes===void 0?``:` / ${$(S.totalBytes)}`})})]}),x.isError&&u(G,{message:x.error instanceof Error?x.error.message:s(`common.error`,`Error`)})]})]})}function Ke({value:e,onChange:t}){let{t:n}=Q(),r=F(),i=o({queryKey:xe,queryFn:()=>r.trpcClient.llm.listRuntimeNodes.query({})});return a(`div`,{children:[u(`div`,{className:`mb-1 text-[11px] font-medium text-foreground`,children:n(`ai.appleNode`,`Mac that runs it`)}),i.isPending&&a(`div`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[u(P,{className:`h-3.5 w-3.5 animate-spin`}),n(`ai.appleAsking`,`Asking the nodes…`)]}),i.isError&&u(`p`,{className:`text-[11px] text-danger`,children:i.error instanceof Error?i.error.message:n(`ai.runtimesFailed`,`Failed to read runtime nodes`)}),i.isSuccess&&i.data.length===0&&u(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}),i.isSuccess&&i.data.length>0&&u(`div`,{role:`radiogroup`,className:`space-y-1.5`,children:i.data.map(r=>{let i=Me(r),o=i.nodeId===e;return a(`button`,{type:`button`,role:`radio`,"aria-checked":o,disabled:!i.selectable&&!o,onClick:()=>t(i.nodeId),className:`flex w-full items-center justify-between gap-2 rounded-md border px-3 py-2 text-left text-xs transition-colors disabled:cursor-not-allowed disabled:opacity-60 ${o?`border-primary bg-primary/10`:`border-border bg-surface hover:bg-surface-hover`}`,children:[a(`span`,{className:`min-w-0`,children:[u(`span`,{className:`block font-medium text-foreground`,children:i.nodeId}),i.detail!==null&&u(`span`,{className:`block truncate text-[10px] text-foreground-subtle`,children:i.detail})]}),u(V,{variant:i.tone,children:n(i.labelKey,i.labelDefault)})]},i.nodeId)})}),u(`p`,{className:`mt-1.5 text-[10px] leading-relaxed text-foreground-subtle`,children:n(`ai.appleHint`,`Text only for now — notification titles and summaries. Apple refuses prompts framed as surveillance; when it does, the next profile in the chain answers instead.`)})]})}function qe(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function Je({providerConfig:e,onProviderConfigChange:t}){return u(Ke,{value:qe(e,`nodeId`),onChange:n=>t({...e,nodeId:n})})}function Ye({providerConfig:e,onProviderConfigChange:t,model:n,onModelChange:r}){let i=I.safeParse(e.model),a=i.success?{model:i.data,modelId:n.id,supportsVision:n.supportsVision}:null;return u(Ge,{nodeId:qe(e,`nodeId`)??`hub`,value:a,onChange:n=>{if(n===null){let{model:n,...i}=e;t(i),r({id:``,supportsVision:!1});return}t({...e,model:n.model}),r({id:n.modelId,supportsVision:n.supportsVision})}})}var Xe=new Map([[`ai/apple-node`,Je],[`ai/managed-model`,Ye]]);function Ze(e){return Xe.get(e)??null}e();function Qe({kind:e,className:t}){return u(Ee(e.icon),{className:t,"aria-hidden":!0})}function $e({kinds:e,onPick:t,onCancel:r}){let{t:i}=Q(),a=n(()=>Ae(e),[e]),o=n(()=>new Map(e.map(e=>[`${e.addonId}:${e.kind}`,e])),[e]);return u(W,{open:!0,onClose:r,title:i(`ai.chooseKind`,`Choose a profile type`),width:`lg`,testId:`ai-kind-picker`,children:u(ae,{emptyMessage:i(`ai.noKinds`,`No AI provider is installed.`),onPick:e=>{let n=o.get(e);n!==void 0&&t(n)},groups:a.map(e=>({id:e.addonId,label:e.addonId,tiles:e.kinds.map(t=>({key:`${e.addonId}:${t.kind}`,label:t.label,testId:`ai-kind-${t.kind}`,icon:u(Qe,{kind:t,className:`h-5 w-5 text-foreground-subtle`})}))}))})})}function et(e){return(e?.sections??[]).flatMap(e=>e.fields)}function tt(...e){let t={};for(let n of e)for(let e of et(n))`default`in e&&e.default!==void 0&&(t[e.key]=e.default);return t}function nt(e){return e==null?!1:typeof e==`string`?e.trim().length>0:!0}function rt(e,t){return et(e).filter(e=>`required`in e&&e.required===!0&&!nt(t[e.key])).map(e=>`label`in e&&typeof e.label==`string`?e.label:e.key)}var it={auth:{key:`ai.listAuth`,fallback:`Credentials refused`},network:{key:`ai.listNetwork`,fallback:`Endpoint unreachable`},unsupported:{key:`ai.listUnsupported`,fallback:`No model list`},invalid:{key:`ai.listInvalid`,fallback:`Connection incomplete`}};function at(e,t){if(t!==null)return{id:t.model,supportsVision:t.supportsVision};let n=e.modelCatalog===`static`&&e.staticModels?.length===1?e.staticModels?.[0]:void 0;return{id:n?.id??``,supportsVision:Be(e,n).vision}}function ot({kind:e,existing:t,onSave:i,onCancel:o,onChangeKind:c,saving:f,error:p}){let{t:m}=Q(),h=F(),[_,v]=r(t?.name??e.label),[y,b]=r(()=>t===null?tt(e.connectionSchema,e.advancedSchema):{...t.providerConfig}),[x,S]=r(()=>ze(t)),[C,w]=r(()=>at(e,t)),[E,D]=r(!1),k=e.providerWidgets??[],A=k.filter(e=>e.placement===`connection`),j=k.find(e=>e.placement===`model`)??null,M=n(()=>[...L(e.connectionSchema)].some(e=>t?.providerConfig[e]===_e),[t,e.connectionSchema]),N=l({mutationFn:()=>h.trpcClient.llm.listModels.mutate({addonId:e.addonId,kind:e.kind,connection:y,...t===null?{}:{profileId:t.id}})}),I=Ve(e,N.data?.ok===!0?N.data.models:null),R=I.find(e=>e.id===C.id),ee=Be(e,R),te=Le(e.profileFields),ne=Re(e.profileFields),z=rt(e.connectionSchema,y),B=k.some(e=>(e.requires??[]).some(e=>!nt(y[e]))),H=e.modelCatalog===`fetch`&&j===null,U=et(e.connectionSchema).length>0||A.length>0,ae=t=>{w({id:t,supportsVision:Be(e,I.find(e=>e.id===t)).vision})},K=f||_.trim()===``||C.id.trim()===``||z.length>0||B,oe=()=>{i(He(e,t,{name:_.trim(),model:C.id.trim(),supportsVision:e.visionEditable?C.supportsVision:!1,common:x,providerConfig:y}))},ce=t===null?m(`ai.newProfile`,`New {{kind}} profile`,{kind:e.label}):m(`ai.editProfile`,`Edit {{name}}`,{name:t.name}),le=t=>{let n=Ze(t);return n===null?u(G,{variant:`warning`,message:m(`ai.unknownWidget`,`This provider needs an editor part this build does not have ({{id}}).`,{id:t})}):u(n,{descriptor:e,providerConfig:y,onProviderConfigChange:b,model:C,onModelChange:w},t)};return u(W,{open:!0,onClose:o,title:ce,error:p,width:`lg`,testId:`ai-profile-editor`,footer:a(s,{children:[z.length>0&&u(V,{variant:`warning`,children:m(`ai.missingRequired`,`required: {{fields}}`,{fields:z.join(`, `)})}),z.length===0&&B&&u(V,{variant:`warning`,children:m(`ai.completeProvider`,`complete the provider settings`)}),z.length===0&&!B&&C.id.trim()===``&&u(V,{variant:`warning`,children:m(`ai.pickModelFirst`,`pick a model`)}),a(q,{size:`sm`,type:`button`,disabled:K,onClick:oe,children:[f&&u(P,{className:`h-3.5 w-3.5 animate-spin`}),t===null?m(`ai.createProfile`,`Create profile`):m(`ai.saveChanges`,`Save changes`)]})]}),children:a(`div`,{className:g,children:[a(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`ai-editor-provider`,children:[u(Qe,{kind:e,className:`h-4 w-4 text-foreground-subtle`}),u(`span`,{className:`text-xs font-medium text-foreground`,children:e.label}),u(V,{variant:`neutral`,children:e.addonId}),c!==void 0&&a(q,{size:`sm`,variant:`ghost`,type:`button`,onClick:c,children:[u(T,{className:`h-3.5 w-3.5`}),m(`ai.changeKind`,`Change type`)]})]}),u(de,{label:m(`ai.name`,`Name`),required:!0,children:u(re,{id:`ai-profile-name`,"aria-label":m(`ai.name`,`Name`),value:_,onChange:e=>v(e.target.value),placeholder:e.label})}),U&&u(J,{headingId:`ai-editor-connection`,title:m(`ai.sectionConnection`,`Connection`),actions:H?a(q,{size:`sm`,variant:`secondary`,type:`button`,disabled:N.isPending,onClick:()=>N.mutate(),"data-testid":`ai-verify-models`,children:[N.isPending?u(P,{className:`h-3.5 w-3.5 animate-spin`}):u(O,{className:`h-3.5 w-3.5`}),m(`ai.verifyModels`,`Verify & load models`)]}):void 0,children:a(`div`,{className:`p-2 sm:p-3 lg:p-4 space-y-3`,children:[et(e.connectionSchema).length>0&&u(ue,{bare:!0,schema:e.connectionSchema,values:y,onChange:b}),A.map(e=>le(e.id)),M&&u(`p`,{className:`text-[10px] text-foreground-subtle`,children:m(`ai.secretHint`,`A stored API key is never shown. Leave it as-is to keep it; type a new value to replace it.`)}),N.data?.ok===!0&&u(V,{variant:`success`,"data-testid":`ai-models-found`,children:m(`ai.modelsFound`,`{{count}} models found`,{count:N.data.models.length})}),N.data?.ok===!1&&u(G,{title:m(it[N.data.code]?.key??`ai.listNetwork`,it[N.data.code]?.fallback??`Endpoint unreachable`),message:N.data.message}),N.isError&&u(G,{message:N.error instanceof Error?N.error.message:m(`common.error`,`Error`)})]})}),u(J,{headingId:`ai-editor-model`,title:m(`ai.sectionModel`,`Model`),children:a(`div`,{className:`${d} space-y-3`,children:[j===null?a(s,{children:[I.length>0&&u(ie,{id:`ai-model-pick`,"aria-label":m(`ai.selectModel`,`Select a model…`),value:R===void 0?``:R.id,options:[{value:``,label:m(`ai.selectModel`,`Select a model…`)},...I.map(e=>({value:e.id,label:e.label??e.id}))],onChange:e=>{e.target.value!==``&&ae(e.target.value)}}),u(de,{label:m(`ai.customModel`,`Model id`),description:m(`ai.customModelHint`,`Pick one from the list, or type any model id the provider accepts.`),required:!0,children:u(re,{id:`ai-model-id`,"aria-label":m(`ai.customModel`,`Model id`),value:C.id,onChange:e=>w({...C,id:e.target.value}),placeholder:I[0]?.id??`model-id`})})]}):le(j.id),a(`div`,{className:`flex flex-wrap items-center gap-1.5`,"data-testid":`ai-model-features`,children:[(C.supportsVision||!e.visionEditable&&ee.vision)&&u(V,{variant:`info`,children:m(`ai.featureVision`,`vision`)}),ee.tools&&u(V,{variant:`neutral`,children:m(`ai.featureTools`,`tools`)}),ee.streaming&&u(V,{variant:`neutral`,children:m(`ai.featureStreaming`,`streaming`)})]}),e.visionEditable&&u(de,{orientation:`horizontal`,label:m(`ai.supportsVision`,`Supports vision`),description:m(`ai.supportsVisionHint`,`A vision call against a text-only profile is refused, never downgraded.`),children:u(se,{checked:C.supportsVision,onCheckedChange:e=>w({...C,supportsVision:e}),"aria-label":m(`ai.supportsVision`,`Supports vision`)})})]})}),te!==null&&u(J,{headingId:`ai-editor-generation`,title:m(`ai.sectionGeneration`,`Generation`),children:u(`div`,{className:`p-2 sm:p-3 lg:p-4`,children:u(ue,{bare:!0,schema:te,values:x,onChange:S})})}),(ne!==null||e.advancedSchema!==void 0)&&u(fe,{expanded:E,onExpandedChange:D,header:u(`span`,{className:`text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:m(`ai.sectionAdvanced`,`Advanced`)}),children:a(`div`,{className:`p-2 sm:p-3 lg:p-4 space-y-3`,children:[ne!==null&&u(ue,{bare:!0,schema:ne,values:x,onChange:S}),e.advancedSchema!==void 0&&u(ue,{bare:!0,schema:e.advancedSchema,values:y,onChange:b})]})})]})})}e();function st(e){return[{key:`name`,header:e.t(`ai.colProfile`,`Profile`),render:t=>{let n=e.kindByName.get(t.kind);return a(`span`,{className:`flex items-center gap-2`,children:[u(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface`,title:n?.label??t.kind,children:n===void 0?u(`span`,{className:`text-xs text-foreground-subtle`,children:`?`}):u(Qe,{kind:n,className:`h-4 w-4 text-foreground-subtle`})}),a(`span`,{className:`min-w-0`,children:[u(`span`,{className:`block truncate font-medium text-foreground`,children:t.name}),e.testResult?.id===t.id&&u(`span`,{className:`block truncate ${e.testResult.ok?`text-success`:`text-danger`}`,children:e.testResult.text})]})]})}},{key:`kind`,header:e.t(`ai.colKind`,`Kind`),nowrap:!0,render:t=>u(`span`,{className:`text-foreground-muted`,children:e.kindByName.get(t.kind)?.label??t.kind})},{key:`model`,header:e.t(`ai.colModel`,`Model`),render:e=>u(`span`,{className:`text-foreground`,children:e.model})},{key:`vision`,header:e.t(`ai.colVision`,`Vision`),align:`center`,nowrap:!0,render:t=>t.supportsVision?u(V,{variant:`info`,style:`outline`,children:e.t(`ai.vision`,`vision`)}):u(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`node`,header:e.t(`ai.colNode`,`Node`),nowrap:!0,render:e=>typeof e.providerConfig.nodeId==`string`?u(V,{variant:`default`,children:e.providerConfig.nodeId}):u(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`enabled`,header:e.t(`ai.colOn`,`On`),align:`center`,nowrap:!0,render:t=>u(se,{checked:t.enabled,onCheckedChange:()=>e.onToggle(t),"aria-label":Z.t(`system.aiProfilesTab.toggle`,`toggle {{name}}`,{name:t.name})})},{key:`actions`,header:``,align:`right`,nowrap:!0,render:t=>a(`span`,{className:`flex items-center justify-end gap-1`,children:[u(q,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>e.onTest(t),"aria-label":e.t(`ai.test`,`Test`),title:e.t(`ai.test`,`Test`),children:e.testingId===t.id?u(P,{className:`h-3.5 w-3.5 animate-spin`}):u(te,{className:`h-3.5 w-3.5`})}),u(q,{size:`sm`,variant:`ghost`,type:`button`,disabled:!e.kindByName.has(t.kind),onClick:()=>e.onEdit(t),"aria-label":e.t(`common.edit`,`Edit`),title:e.t(`common.edit`,`Edit`),children:u(f,{className:`h-3.5 w-3.5`})}),u(q,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>e.onDelete(t),"aria-label":e.t(`common.delete`,`Delete`),title:e.t(`common.delete`,`Delete`),children:u(h,{className:`h-3.5 w-3.5 text-danger`})})]})}]}function ct(){let{t:e}=Q(),s=F(),{state:c,openEdit:f,close:p}=le(),m=z(),[h,_]=r(null),[v,y]=r(null),[b,x]=r(null),S=o({queryKey:ve,queryFn:()=>s.trpcClient.llm.listProfiles.query({})}),C=o({queryKey:ye,queryFn:async()=>(await s.trpcClient.llm.listProfileKinds.query({})).map(({connectionSchema:e,advancedSchema:t,...n})=>({...n,connectionSchema:e,...t===void 0?{}:{advancedSchema:t}}))}),w=()=>{S.refetch()},T=i(()=>{_(null),x(null),p()},[p]);t(()=>{c.mode===`closed`&&_(null)},[c.mode]);let E=l({mutationFn:e=>s.trpcClient.llm.upsertProfile.mutate({profile:e}),onSuccess:()=>{T(),w()},onError:t=>x(t instanceof Error?t.message:e(`ai.saveFailed`,`Save failed`))}),O=l({mutationFn:e=>s.trpcClient.llm.deleteProfile.mutate({addonId:e.addonId,profileId:e.id}),onSuccess:w}),k=l({mutationFn:e=>s.trpcClient.llm.testProfile.mutate({addonId:e.addonId,profileId:e.id}),onSuccess:(e,t)=>y({id:t.id,ok:e.ok,text:e.ok?Z.t(`system.aiProfilesTab.testOk`,{text:e.text,tokens:e.usage.outputTokens,ms:e.latencyMs}):`${e.code}: ${e.message}`})}),A=S.data??[],j=n(()=>C.data??[],[C.data]),M=n(()=>{let e=new Map;for(let t of j)e.set(t.kind,t);return e},[j]),N=c.mode===`edit`?A.find(e=>e.id===c.id)??null:null,P=N===null?null:M.get(N.kind)??null,I=c.mode===`new`&&h===null,L=c.mode===`new`?h:P,R=c.mode===`edit`?N:null,ee=L!==null&&(c.mode===`new`||R!==null),te=async t=>{await m({title:e(`ai.deleteProfileTitle`,`Delete profile?`),message:e(`ai.deleteProfileMessage`,`Delete "{{name}}". Features that name it will no longer get an answer from it.`,{name:t.name}),confirmLabel:e(`common.delete`,`Delete`),variant:`danger`})&&O.mutate(t)};return a(`div`,{className:g,children:[u(lt,{profiles:A}),u(J,{headingId:`ai-profiles-list`,title:e(`ai.profilesList`,`Profiles`),children:S.isPending?a(`div`,{className:`${d} space-y-2`,"data-testid":`ai-profiles-loading`,children:[u(Y,{className:`h-8 w-full`}),u(Y,{className:`h-8 w-full`}),u(Y,{className:`h-8 w-full`})]}):S.isError?u(`div`,{className:d,children:u(G,{title:e(`ai.loadFailed`,`Failed to load profiles`),message:S.error instanceof Error?S.error.message:e(`common.error`,`Error`),onRetry:()=>void S.refetch()})}):A.length===0?u(X,{icon:D,title:e(`ai.noProfilesTitle`,`No AI profiles yet`),description:e(`ai.noProfiles`,`No AI profiles yet. Click "Add profile" to configure one.`)}):u(K,{columns:st({kindByName:M,testResult:v,testingId:k.isPending?k.variables?.id??null:null,t:e,onToggle:e=>E.mutate({...e,enabled:!e.enabled}),onTest:e=>k.mutate(e),onEdit:e=>{M.has(e.kind)&&(x(null),_(null),f(e.id))},onDelete:e=>void te(e)}),rows:A,rowKey:e=>e.id,minWidthPx:760,bordered:!1,maxBodyHeight:U})}),I&&u($e,{kinds:j,onCancel:T,onPick:e=>{x(null),_(e)}}),ee&&L!==null&&u(ot,{kind:L,existing:R,saving:E.isPending,error:b,onSave:e=>E.mutate(e),onCancel:T,...c.mode===`new`?{onChangeKind:()=>{x(null),_(null)}}:{}})]})}function lt({profiles:e}){let{t}=Q(),n=F(),r=o({queryKey:be,queryFn:()=>n.trpcClient.llm.getDefaults.query({})}),i=l({mutationFn:e=>n.trpcClient.llm.setDefault.mutate({selector:{purpose:e.purpose},profileId:e.profileId}),onSuccess:()=>{r.refetch()}}),s=e=>(r.data??[]).find(t=>`purpose`in t.selector&&t.selector.purpose===e)?.profileId??``,c=e=>e===`vision`?t(`ai.defaultVision`,`Default vision profile`):t(`ai.defaultText`,`Default text profile`);return u(J,{headingId:`ai-profiles-defaults`,title:t(`ai.defaultsTitle`,`Defaults`),children:u(`div`,{className:`${d} grid gap-4 sm:grid-cols-2`,children:we.map(({purpose:n,visionOnly:r})=>{let o=r?e.filter(e=>e.supportsVision):e,l=s(n),d=e.find(e=>e.id===l);return a(`div`,{children:[u(B,{className:`mb-1 block`,htmlFor:`llm-default-${n}`,children:c(n)}),u(ie,{id:`llm-default-${n}`,"aria-label":c(n),value:l,onChange:e=>i.mutate({purpose:n,profileId:e.target.value===``?null:e.target.value}),options:[{value:``,label:t(`ai.none`,`None`)},...l!==``&&!o.some(e=>e.id===l)?[{value:l,label:d?.name??l}]:[],...o.map(e=>({value:e.id,label:`${e.name} · ${e.model}`}))]}),l!==``&&d===void 0&&u(`p`,{className:`mt-1 text-xs text-danger`,children:t(`ai.defaultMissing`,`This default names a profile that no longer exists.`)}),d!==void 0&&!d.enabled&&u(`p`,{className:`mt-1 text-xs text-warning`,children:t(`ai.defaultDisabled`,`This default profile is disabled — callers resolve to no profile.`)}),i.error!=null&&u(`p`,{className:`mt-1 text-xs text-danger`,children:String(i.error)})]},n)})})})}e();var ut=5e3;function dt(e){return Z.t(`system.aiRuntimes.sizeGb`,{value:(e/1e9).toFixed(1)})}function ft(){let{t:e}=Q(),t=F(),r=o({queryKey:xe,refetchInterval:ut,queryFn:()=>t.trpcClient.llm.listRuntimeNodes.query({})}),i=n(()=>[{key:`node`,header:e(`ai.colNode`,`Node`),render:e=>u(`span`,{className:`font-medium text-foreground`,children:e.nodeId})},{key:`state`,header:e(`ai.colState`,`State`),nowrap:!0,render:t=>a(`span`,{className:`flex items-center gap-1.5`,children:[u(V,{variant:t.reachable?`success`:`danger`,children:t.reachable?t.status?.state??e(`ai.ready`,`ready`):e(`ai.unreachable`,`unreachable`)}),t.status?.downloadProgress!==void 0&&u(V,{variant:`info`,children:`${String(Math.round(t.status.downloadProgress*100))}%`})]})},{key:`model`,header:e(`ai.colModel`,`Model`),render:e=>u(`span`,{className:`text-foreground`,children:e.status?.modelId??`—`})},{key:`disk`,header:e(`ai.colDisk`,`On disk`),align:`right`,nowrap:!0,render:e=>u(`span`,{className:`tabular-nums text-foreground-muted`,children:e.disk===void 0?`—`:dt(e.disk.modelsBytes)})},{key:`apple`,header:e(`ai.colApple`,`Apple on-device`),render:t=>{let n=Me(t);return a(`span`,{className:`flex flex-col items-start gap-0.5`,children:[u(V,{variant:n.tone,children:e(n.labelKey,n.labelDefault)}),n.detail!==null&&u(`span`,{className:`text-foreground-subtle`,children:n.detail})]})}},{key:`error`,header:e(`ai.colError`,`Error`),render:e=>e.error===void 0?u(`span`,{className:`text-foreground-subtle`,children:`—`}):u(`span`,{className:`text-danger`,children:e.error})}],[e]),s=r.data??[];return u(J,{headingId:`ai-runtimes-list`,title:e(`ai.runtimesList`,`Nodes`),children:r.isPending?a(`div`,{className:`${d} space-y-2`,"data-testid":`ai-runtimes-loading`,children:[u(Y,{className:`h-8 w-full`}),u(Y,{className:`h-8 w-full`})]}):r.isError?u(`div`,{className:d,children:u(G,{title:e(`ai.runtimesFailed`,`Failed to read runtime nodes`),message:r.error instanceof Error?r.error.message:e(`common.error`,`Error`),onRetry:()=>void r.refetch()})}):s.length===0?u(X,{icon:k,title:e(`ai.noRuntimesTitle`,`No runtime nodes`),description:e(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}):u(K,{columns:i,rows:s,rowKey:e=>e.nodeId,minWidthPx:760,bordered:!1,maxBodyHeight:U})})}var pt=C(`/addon/ai/test-chat`),mt=C(`/addon/ai/test-chat/chats`),ht=6e5;function gt(e){let t=e.firstTokenTimeoutMs;if(!(typeof t!=`number`||!Number.isFinite(t)||t<=0))return Math.min(Math.round(t),ht)}function _t(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function vt(e){if(!_t(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 yt=[`resolving-image`,`connecting`,`first-token-wait`,`streaming`];function bt(e){let t;try{t=JSON.parse(e)}catch{return null}if(!_t(t))return null;switch(t.kind){case`status`:{let e=yt.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:vt(t.mediaSent),streamed:t.streamed===!0,firstTokenTimeoutMs:typeof t.firstTokenTimeoutMs==`number`?t.firstTokenTimeoutMs:0};case`token`:return typeof t.text==`string`?{kind:`token`,text:t.text}:null;case`done`:return{kind:`done`,inputTokens:typeof t.inputTokens==`number`?t.inputTokens:0,outputTokens:typeof t.outputTokens==`number`?t.outputTokens:0,latencyMs:typeof t.latencyMs==`number`?t.latencyMs:0,truncated:t.truncated===!0,...typeof t.conversationId==`string`?{conversationId:t.conversationId}:{}};case`error`:return{kind:`error`,code:typeof t.code==`string`?t.code:`adapter-error`,message:typeof t.message==`string`?t.message:Z.t(`helpers.aiTestChat.providerError`)};default:return null}}async function*xt(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=bt(e);t!==null&&(yield t)}a=r.indexOf(`
3
- `)}}let e=r.trim();if(e.length>0){let t=bt(e);t!==null&&(yield t)}}finally{t.releaseLock()}}function St(e){return e.filter(e=>e.failed!==!0&&e.content.length>0).map(e=>({role:e.role,content:e.content}))}function Ct(e){return e.thumbnailBase64===void 0||e.thumbnailBase64.length===0?null:`data:${e.mimeType};base64,${e.thumbnailBase64}`}function wt(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 Tt(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 Et(e,t){switch(e){case`resolving-image`:return Z.t(`helpers.aiTestChat.phaseImage`);case`connecting`:return Z.t(`helpers.aiTestChat.phaseConnecting`);case`first-token-wait`:return t>0?Z.t(`helpers.aiTestChat.phaseWaitUpTo`,{seconds:Math.round(t/1e3)}):Z.t(`helpers.aiTestChat.phaseWait`);case`streaming`:return Z.t(`helpers.aiTestChat.phaseAnswering`)}}e();var Dt=[`pipelineAnalytics`,`listRecentTracks`,`ai-test`],Ot=360*60*1e3,kt=40,At=160,jt={phase:`connecting`,firstTokenTimeoutMs:0,text:``,mediaSent:null};function Mt(){let{t:e}=Q(),s=F(),[l,f]=r(``),[p,m]=r(``),[v,y]=r(``),[x,S]=r([]),[C,T]=r(null),[E,D]=r(`none`),[O,k]=r(`throwaway`),[j,M]=r(null),[N,P]=r([]),[I,L]=r(null),[R,z]=r(null),V=c(null);t(()=>()=>V.current?.abort(),[]);let H=i(async()=>{let e=await fetch(mt,{credentials:`same-origin`});e.ok&&P((await e.json()).chats??[])},[]);t(()=>{O===`persistent`&&H()},[O,H]);let U=o({queryKey:ve,queryFn:()=>s.trpcClient.llm.listProfiles.query({})}),ae=n(()=>(U.data??[]).filter(e=>e.enabled),[U.data]),W=ae.find(e=>e.id===l)??null,K=R!==null,oe=i(async(t,n)=>{let r=new AbortController;V.current=r,L(null);let i=gt(W??{});z({...jt,firstTokenTimeoutMs:i??0});let a=``,o=null,s,c=null,u=null,d;try{let e=await fetch(pt,{method:`POST`,headers:{"content-type":`application/json`},credentials:`same-origin`,signal:r.signal,body:JSON.stringify({profileId:l,messages:t,...p.trim()===``?{}:{system:p.trim()},...n===void 0?{}:{attachment:n},...i===void 0?{}:{firstTokenTimeoutMs:i},...O===`persistent`?{persist:!0,...j===null?{}:{conversationId:j}}:{}})});if(!e.ok||e.body===null){let t=await e.text().catch(()=>``);throw Error(t.length>0?t:`HTTP ${String(e.status)}`)}for await(let t of xt(e.body))switch(t.kind){case`status`:z(e=>({...e??jt,phase:t.phase}));break;case`meta`:o=t.mediaSent,s=t.model,z(e=>({...e??jt,firstTokenTimeoutMs:t.firstTokenTimeoutMs,mediaSent:t.mediaSent}));break;case`token`:a+=t.text,z(e=>({...e??jt,text:a}));break;case`done`:u={outputTokens:t.outputTokens,latencyMs:t.latencyMs},d=t.conversationId;break;case`error`:c=`${t.code}: ${t.message}`;break}}catch(t){r.signal.aborted||L(t instanceof Error?t.message:e(`common.error`,`Error`))}finally{V.current=null,z(null)}d!==void 0&&(M(d),H());let f=r.signal.aborted&&a.length>0;c===null&&a.length===0&&!f||S(e=>[...e,{id:`a-${String(Date.now())}`,role:`assistant`,content:c??a,...c===null?{}:{failed:!0},...o===null?{}:{attachment:o},...s!==void 0&&c===null?{model:s}:{},...u===null?{}:u}])},[O,j,W,l,H,p,e]),se=i(()=>{let e=v.trim();if(e===``||l===``||K)return;let t={id:`u-${String(Date.now())}`,role:`user`,content:e,...C===null?{}:{attachmentLabel:C.label,attachmentKind:C.ref.kind}},n=[...x,t];S(n),y(``);let r=C?.ref;T(null),D(`none`),oe(O===`persistent`&&j!==null?[{role:`user`,content:e}]:St(n),r)},[O,j,v,C,l,oe,K,x]),le=()=>V.current?.abort(),Y=()=>{V.current?.abort(),S([]),T(null),y(``),L(null),z(null),M(null)},X=async e=>{V.current?.abort();let t=await fetch(`${mt}/${e}`,{credentials:`same-origin`});if(!t.ok)return;let n=await t.json();M(e),S(wt(n)),z(null),L(null)};return a(`div`,{className:g,children:[u(J,{headingId:`ai-test-setup`,title:e(`ai.testSetup`,`Setup`),children:a(`div`,{className:`${d} space-y-3`,children:[a(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[a(`div`,{children:[u(B,{className:`mb-1 block`,htmlFor:`ai-test-profile`,children:e(`ai.profile`,`Profile`)}),u(ie,{id:`ai-test-profile`,value:l,onChange:e=>f(e.target.value),options:[{value:``,label:e(`ai.selectProfile`,`Select a profile…`)},...ae.map(e=>({value:e.id,label:`${e.name} · ${e.model}${e.supportsVision?` · vision`:``}`}))]}),ae.length===0&&!U.isLoading&&u(`p`,{className:`mt-1 text-xs text-foreground-subtle`,children:e(`ai.noEnabledProfiles`,`No enabled profile. Add one on the Profiles tab.`)})]}),a(`div`,{children:[u(B,{className:`mb-1 block`,htmlFor:`ai-test-system`,children:e(`ai.systemPrompt`,`System prompt (optional)`)}),u(re,{id:`ai-test-system`,value:p,onChange:e=>m(e.target.value),placeholder:e(`ai.systemPlaceholder`,`Answer in one short sentence.`)})]})]}),u(ne,{label:e(`ai.chatMode`,`Conversation mode`),value:O,options:[{value:`throwaway`,label:e(`ai.throwawayMode`,`Throwaway`)},{value:`persistent`,label:e(`ai.saveConversation`,`Save conversation`)}],onChange:e=>{k(e),e===`throwaway`&&M(null)}}),O===`persistent`&&a(`div`,{className:`space-y-2`,children:[u(`p`,{className:`text-xs text-foreground-subtle`,children:e(`ai.testSubtitlePersistent`,`Conversations are saved for you and can be reopened. Throwaway mode is still available.`)}),a(q,{size:`sm`,variant:`secondary`,type:`button`,onClick:Y,children:[u(ee,{className:`h-3.5 w-3.5`}),e(`ai.newChat`,`New chat`)]}),N.length>0&&u(`div`,{className:`max-h-36 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:N.map(e=>u(`button`,{type:`button`,onClick:()=>void X(e.id),className:`flex w-full px-2.5 py-1.5 text-left text-xs hover:bg-surface-hover ${e.id===j?`bg-primary/10`:``}`,children:u(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:e.title})},e.id))})]}),u(`p`,{className:`text-xs text-foreground-subtle`,children:e(`ai.streamNote`,`The answer streams as the model produces it. A cold model can take a while to load — the status line says which phase it is in.`)}),W!==null&&!W.supportsVision&&u(`p`,{className:`text-xs text-warning`,children:e(`ai.notVision`,`This profile is not vision-capable — an attached image will be refused before anything is read.`)})]})}),I!==null&&u(G,{title:e(`ai.chatFailed`,`The test call failed`),message:I}),a(J,{headingId:`ai-test-conversation`,title:e(`ai.testConversation`,`Conversation`),actions:a(q,{size:`sm`,variant:`ghost`,type:`button`,disabled:x.length===0&&C===null,onClick:Y,children:[u(h,{className:`h-3.5 w-3.5`}),e(`ai.clearChat`,`Clear`)]}),children:[u(Nt,{turns:x,live:R}),a(`div`,{className:`${d} space-y-2 border-t border-border`,children:[C!==null&&a(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5`,children:[C.ref.kind===`snapshot`?u(b,{className:`h-3.5 w-3.5 text-foreground-subtle`}):u(_,{className:`h-3.5 w-3.5 text-foreground-subtle`}),u(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,children:C.label}),u(ce,{size:`sm`,variant:`ghost`,type:`button`,icon:A,"aria-label":e(`ai.removeAttachment`,`Remove attachment`),onClick:()=>T(null)})]}),a(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a(q,{size:`sm`,variant:E===`snapshot`?`primary`:`outline`,type:`button`,onClick:()=>D(E===`snapshot`?`none`:`snapshot`),children:[u(b,{className:`h-3.5 w-3.5`}),e(`ai.attachSnapshot`,`Camera snapshot`)]}),a(q,{size:`sm`,variant:E===`track`?`primary`:`outline`,type:`button`,onClick:()=>D(E===`track`?`none`:`track`),children:[u(_,{className:`h-3.5 w-3.5`}),e(`ai.attachTrack`,`Recent track`)]})]}),E===`snapshot`&&u(It,{onPick:t=>{T({ref:{kind:`snapshot`,deviceId:t.id},label:e(`ai.snapshotOf`,`Snapshot of {{name}}`,{name:t.name})}),D(`none`)}}),E===`track`&&u(Rt,{onPick:(t,n)=>{T({ref:{kind:`track`,trackId:t.trackId,deviceId:t.deviceId},label:e(`ai.trackOf`,`{{class}} on {{name}}`,{class:t.label??t.className,name:n})}),D(`none`)}}),a(`div`,{className:`flex items-center gap-2`,children:[u(re,{value:v,onChange:e=>y(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),se())},placeholder:e(`ai.messagePlaceholder`,`Ask the model something…`),"aria-label":e(`ai.message`,`Message`)}),K?a(q,{size:`sm`,variant:`secondary`,type:`button`,onClick:le,children:[u(w,{className:`h-3.5 w-3.5`}),e(`ai.stop`,`Stop`)]}):a(q,{size:`sm`,type:`button`,disabled:v.trim()===``||l===``,onClick:se,children:[u(te,{className:`h-3.5 w-3.5`}),e(`ai.send`,`Send`)]})]})]})]})]})}function Nt({turns:e,live:t}){let{t:n}=Q();return e.length===0&&t===null?u(X,{icon:v,title:n(`ai.chatEmptyTitle`,`No messages yet`),description:n(`ai.chatEmpty`,`Pick a profile, optionally attach a camera snapshot or a recent track, and send a message. Nothing here is saved.`)}):a(`div`,{className:`max-h-[50vh] space-y-2 overflow-y-auto ${d}`,children:[e.map(e=>u(Pt,{turn:e},e.id)),t!==null&&a(`div`,{className:`space-y-1`,children:[t.mediaSent!==null&&u(Ft,{attachment:t.mediaSent}),t.text.length>0&&u(Pt,{turn:{id:`live`,role:`assistant`,content:t.text},streaming:!0}),a(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[u(P,{className:`h-3.5 w-3.5 animate-spin`}),Et(t.phase,t.firstTokenTimeoutMs)]})]})]})}function Pt({turn:e,streaming:t=!1}){let{t:n}=Q(),r=e.role===`user`,i=e.failed===!0?`border-danger/40 bg-danger/10`:`border-border bg-surface`;return u(`div`,{className:`flex ${r?`justify-end`:`justify-start`}`,children:a(`div`,{className:`max-w-[85%] rounded-lg border px-3 py-2 ${r?`border-primary/40 bg-primary/10`:i}`,children:[a(`p`,{className:`whitespace-pre-wrap break-words text-xs text-foreground`,children:[e.content,t&&u(`span`,{className:`ml-0.5 animate-pulse text-primary`,children:`▌`})]}),e.attachment!==void 0&&u(Ft,{attachment:e.attachment}),e.attachmentLabel!==void 0&&a(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[e.attachmentKind===`track`?u(_,{className:`h-3 w-3`}):u(b,{className:`h-3 w-3`}),e.attachmentLabel]}),e.attachment!==void 0&&a(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[e.attachment.kind===`snapshot`?u(b,{className:`h-3 w-3`}):u(_,{className:`h-3 w-3`}),Tt(e.attachment)]}),e.model!==void 0&&u(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:n(`system.aiTestChat.tokMs`,`{{model}} · {{value2}} tok · {{value3}} ms`,{model:e.model,value2:String(e.outputTokens??0),value3:String(e.latencyMs??0)})})]})})}function Ft({attachment:e}){let{t}=Q(),n=Ct(e);return n===null?null:u(`img`,{src:n,alt:t(`system.aiTestChat.sentToTheModel`,`sent to the model`),className:`mt-1 max-h-32 rounded-md border border-border object-contain`})}function It({onPick:e}){let{t}=Q(),n=H({isCamera:!0,projection:`slim`}),r=(n.data??[]).filter(e=>!e.disabled);return n.isLoading?u(P,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r.length===0?u(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`ai.noCameras`,`No camera found.`)}):u(`div`,{className:`grid max-h-56 grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-4`,children:r.map(t=>u(Lt,{device:t,onPick:e},t.id))})}function Lt({device:e,onPick:t}){let{t:n}=Q(),{src:r}=p(e.id,{width:At});return a(`button`,{type:`button`,onClick:()=>t(e),className:`overflow-hidden rounded-md border border-border bg-surface text-left transition-colors hover:border-primary/50`,children:[u(`span`,{className:`block aspect-video w-full bg-background-elevated`,children:r!==null&&u(`img`,{src:r,alt:``,className:`h-full w-full object-cover`,loading:`lazy`})}),a(`span`,{className:`flex items-center gap-1 px-2 py-1`,children:[!e.online&&u(V,{variant:`warning`,children:n(`common.off`)}),u(`span`,{className:`truncate text-[10px] text-foreground`,children:e.name})]})]})}function Rt({onPick:e}){let{t}=Q(),r=F(),i=H({isCamera:!0,projection:`slim`}),s=n(()=>(i.data??[]).map(e=>e.id),[i.data]),c=n(()=>{let e=new Map;for(let t of i.data??[])e.set(t.id,t.name);return e},[i.data]),l=o({queryKey:[...Dt,s.length],enabled:s.length>0,queryFn:()=>r.trpcClient.pipelineAnalytics.listRecentTracks.query({deviceIds:[...s],since:Date.now()-Ot,limit:kt,projection:`slim`})});if(i.isLoading||l.isLoading)return u(P,{className:`h-4 w-4 animate-spin text-foreground-subtle`});let d=l.data?.tracks??[];return d.length===0?u(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`ai.noTracks`,`No track in the last 6 hours.`)}):u(`div`,{className:`max-h-56 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:d.map(t=>a(`button`,{type:`button`,onClick:()=>e(t,c.get(t.deviceId)??String(t.deviceId)),className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-[11px] hover:bg-surface-hover`,children:[u(_,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),u(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:t.label??t.className}),u(`span`,{className:`shrink-0 text-foreground-subtle`,children:c.get(t.deviceId)??t.deviceId}),u(`span`,{className:`shrink-0 text-foreground-subtle`,children:new Date(t.lastSeen).toLocaleTimeString()})]},t.trackId))})}e();var zt=1440*60*1e3,Bt=[1,7,30,90];function Vt(){let{t:e}=Q(),t=F(),[i,s]=r(7),c=n(()=>{let e=new Date;return e.setHours(0,0,0,0),e.getTime()-(i-1)*zt},[i]),l=o({queryKey:ve,queryFn:()=>t.trpcClient.llm.listProfiles.query({})}),f=o({queryKey:[...Ce,i],queryFn:()=>t.trpcClient.llm.getUsage.query({since:c})}),p=n(()=>{let e=new Map;for(let t of l.data??[])e.set(t.id,t.name);return e},[l.data]),m=n(()=>[{key:`day`,header:e(`ai.colDay`,`Day`),nowrap:!0,render:e=>u(`span`,{className:`tabular-nums`,children:e.day})},{key:`consumer`,header:e(`ai.colConsumer`,`Consumer`),nowrap:!0,render:e=>u(`span`,{className:`text-foreground`,children:e.consumer})},{key:`profile`,header:e(`ai.colProfile`,`Profile`),render:e=>u(`span`,{className:`text-foreground`,children:p.get(e.profileId)??e.profileId})},{key:`calls`,header:e(`ai.colCalls`,`Calls`),align:`right`,nowrap:!0,render:e=>u(`span`,{className:`tabular-nums`,children:String(e.calls)})},{key:`okErr`,header:e(`ai.colOkErr`,`OK / err`),align:`right`,nowrap:!0,render:e=>u(`span`,{className:`tabular-nums ${e.errorCalls>0?`text-danger`:``}`,children:`${String(e.okCalls)} / ${String(e.errorCalls)}`})},{key:`tokens`,header:e(`ai.colTokens`,`In / out tok`),align:`right`,nowrap:!0,render:e=>u(`span`,{className:`tabular-nums`,children:`${String(e.inputTokens)} / ${String(e.outputTokens)}`})},{key:`latency`,header:e(`ai.colAvgMs`,`Avg ms`),align:`right`,nowrap:!0,render:e=>u(`span`,{className:`tabular-nums`,children:String(Math.round(e.avgLatencyMs))})}],[p,e]),h=f.data??[],g=u(`div`,{className:`w-36`,children:u(ie,{"aria-label":e(`ai.window`,`Window`),value:String(i),options:Bt.map(t=>({value:String(t),label:e(`ai.lastDays`,`Last {{days}} days`,{days:t})})),onChange:e=>s(Number(e.target.value))})});return u(J,{headingId:`ai-usage-list`,title:e(`ai.usageList`,`Rollup`),actions:g,children:f.isPending?a(`div`,{className:`${d} space-y-2`,"data-testid":`ai-usage-loading`,children:[u(Y,{className:`h-8 w-full`}),u(Y,{className:`h-8 w-full`}),u(Y,{className:`h-8 w-full`})]}):f.isError?u(`div`,{className:d,children:u(G,{title:e(`ai.usageFailed`,`Failed to read usage`),message:f.error instanceof Error?f.error.message:e(`common.error`,`Error`),onRetry:()=>void f.refetch()})}):h.length===0?u(X,{icon:S,title:e(`ai.noUsage`,`No AI calls in this window.`)}):u(K,{columns:m,rows:h,rowKey:e=>`${e.day}|${e.consumer}|${e.profileId}`,minWidthPx:720,bordered:!1,maxBodyHeight:U})})}var Ht=`llm`,Ut=[`profiles`,`runtimes`,`usage`,`test`],Wt=[`new`,`edit`];function Gt(e){return Ut.some(t=>t===e)}function Kt(){let{t:e}=Q(),t=oe(Ht),[n]=me(),{openNew:r}=le(),i=pe(`/system/ai`,{t:e,isAdmin:!0})??{icon:D,title:e(`system.ai`,`AI`)};if(t!==`present`)return u(ge,{icon:i.icon,title:i.title,children:u(qt,{presence:t})});let o=n.get(`tab`),s=Gt(o)?o:`profiles`,c={profiles:e(`ai.profilesSubtitle`,`One row = one usable model endpoint. The defaults below decide who answers when a feature names no profile.`),runtimes:e(`ai.runtimesSubtitle`,`Nodes advertising the llm-runtime capability: what each has loaded, what it is downloading, and how much model data sits on its disk.`),usage:e(`ai.usageSubtitle`,`Server-side rollup per day, consumer and profile — never raw call rows. Errors are counted, so a profile that always fails is visible here before a feature reports it.`),test:e(`ai.testSubtitle`,`A throwaway conversation with one profile. Attach a live camera snapshot or a recent track to check the model can actually read a picture. Nothing is saved — only the usage row.`)},l=s===`profiles`?a(q,{size:`sm`,type:`button`,"data-testid":`ai-add-profile`,onClick:r,children:[u(N,{className:`h-3.5 w-3.5`}),e(`ai.addProfile`,`Add profile`)]}):void 0;return u(he,{icon:i.icon,title:i.title,subtitle:c[s],actions:l,defaultSection:`profiles`,sectionsLabel:`${i.title} sections`,sections:[{id:`profiles`,label:e(`ai.tabProfiles`,`Profiles`),content:u(ct,{}),ownedParams:Wt},{id:`runtimes`,label:e(`ai.tabRuntimes`,`Runtimes`),content:u(ft,{})},{id:`usage`,label:e(`ai.tabUsage`,`Usage`),content:u(Vt,{})},{id:`test`,label:e(`ai.tabTest`,`Test`),content:u(Mt,{})}]})}function qt({presence:e}){let{t}=Q();return e===`pending`?a(`div`,{className:`space-y-3`,"data-testid":`ai-presence-pending`,children:[u(Y,{className:`h-8 w-64`}),u(Y,{className:`h-40 w-full`})]}):e===`unknown`?u(G,{title:t(`ai.presenceUnknownTitle`,`Could not check whether AI is installed`),message:t(`ai.presenceUnknown`,`The hub did not answer the capability check. Reload the page to try again.`)}):u(X,{icon:D,title:t(`ai.absentTitle`,`AI is not installed`),description:t(`ai.absentDescription`,`Install the AI addon from System → Addons to add model profiles.`)})}export{Kt as AiProfilesPage,Kt as default};