@camstack/addon-admin-ui 1.2.648 → 1.2.650
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.
- package/CHANGELOG.md +18 -0
- package/dist/assets/Addons-66AtY5mu.js +5 -0
- package/dist/assets/{AdminPage-BoBZR6uA.js → AdminPage-tWFzmkA7.js} +1 -1
- package/dist/assets/{AdminSectionedPage-L4C7Phdd.js → AdminSectionedPage-D00S68ny.js} +1 -1
- package/dist/assets/AiProfiles-DoPAcfxw.js +3 -0
- package/dist/assets/{BootstrapSettingsForm-BYyiguAD.js → BootstrapSettingsForm-ObiD-4-l.js} +1 -1
- package/dist/assets/{Build-C7W-XZrf.js → Build-MKmgkbmb.js} +4 -4
- package/dist/assets/{Calendars-mymGxZsU.js → Calendars-D3mhCBNC.js} +1 -1
- package/dist/assets/{CameraGrids-Bj3Z_Pcc.js → CameraGrids-C0n7qSaN.js} +1 -1
- package/dist/assets/{Cluster-CgMRCsps.js → Cluster-x_aFWP8q.js} +1 -1
- package/dist/assets/{CompositionBlockEditor-COm_6ogX.js → CompositionBlockEditor-xMJURnzF.js} +2 -2
- package/dist/assets/{CompositionEditorPage-CP_PHsfM.js → CompositionEditorPage-C1X6QW6w.js} +1 -1
- package/dist/assets/Data-DjvjUZ88.js +2 -0
- package/dist/assets/DeviceDetail-DkfzIA36.js +2 -0
- package/dist/assets/{Devices-IeMtX8HI.js → Devices-CRz_XyZv.js} +1 -1
- package/dist/assets/{EmbedDevicePage-DZgb5GB6.js → EmbedDevicePage-BA8S4eB2.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-DbcUQsaR.js → EmbedPlayerPage-DwvtigtA.js} +1 -1
- package/dist/assets/History-Bbh7GyuR.js +1 -0
- package/dist/assets/Identity-BTU7dHsy.js +1 -0
- package/dist/assets/InstancesTable-D0ePlG0O.js +1 -0
- package/dist/assets/IntegrationDetail-CNpwj5mL.js +1 -0
- package/dist/assets/IntegrationWizard-y3tDHsc8.js +1 -0
- package/dist/assets/{Integrations-ChpwR1bq.js → Integrations-2rOn7RrQ.js} +2 -2
- package/dist/assets/Integrations-BghPCCUX.js +1 -0
- package/dist/assets/Library-Durt7-NC.js +1 -0
- package/dist/assets/Locations-DYIW2-f6.js +3 -0
- package/dist/assets/{Logs-Bf7lB4Fl.js → Logs-D72sIrph.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-DsRgL9Jd.js → MaskShapeCanvas-BxTTlAfh.js} +1 -1
- package/dist/assets/{MotionZonesSettings-BWECPN2p.js → MotionZonesSettings-ieLDWpte.js} +1 -1
- package/dist/assets/MyAccess-BQTBSq6K.js +2 -0
- package/dist/assets/Network-CwqR0gPE.js +1 -0
- package/dist/assets/NodeAddonsSettingsPanel-CgMvgFAN.js +2 -0
- package/dist/assets/Notifications-DmJTTHb2.js +1 -0
- package/dist/assets/Pipeline-K1nNCknb.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-CxsDkPmw.js → PrivacyMaskSettings-BmYR9i5a.js} +1 -1
- package/dist/assets/Recordings-DFhEOydB.js +1 -0
- package/dist/assets/{RemoteGrid-rdbpCVSQ.js → RemoteGrid-CnvWN_Q7.js} +1 -1
- package/dist/assets/ScanSubnetEditor-COYKrOUZ.js +1 -0
- package/dist/assets/{SceneMonitorEditor-Bgq5w1mw.js → SceneMonitorEditor-DeQ9ymYM.js} +1 -1
- package/dist/assets/SessionsList-CchnaZDu.js +2 -0
- package/dist/assets/{Showroom-DJYzUxEc.js → Showroom-y8XDooe0.js} +1 -1
- package/dist/assets/StorageLocationsTable-CEuzgMli.js +1 -0
- package/dist/assets/{System-BFzxJ3an.js → System-B5rn1ItC.js} +1 -1
- package/dist/assets/{Templates-CMOSFF23.js → Templates-Bk06ZJwK.js} +1 -1
- package/dist/assets/{Terminal-COBZmFpS.js → Terminal-CrDf4D63.js} +5 -5
- package/dist/assets/{TrainingProviders-B91sOQOt.js → TrainingProviders-DtxFhEAZ.js} +1 -1
- package/dist/assets/{Viewer-vnvh2eNL.js → Viewer-Dod1J2kQ.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-GkPyO1aX.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Ck0PhSCH.js} +1 -1
- package/dist/assets/{action-draft-DB5j6cca.js → action-draft-CbHoxLjI.js} +1 -1
- package/dist/assets/{ai-page.helpers-CQPhp13c.js → ai-page.helpers-C6ls8wz_.js} +1 -1
- package/dist/assets/{assignment-candidates-ywq2QZGE.js → assignment-candidates-DWPnaRvD.js} +1 -1
- package/dist/assets/{authed-media-BpBHZnVV.js → authed-media-DSqxjKn1.js} +1 -1
- package/dist/assets/{board-model-CpqXB5lD.js → board-model-BjCZ9N9K.js} +1 -1
- package/dist/assets/client-DLGNlJDt.js +1114 -0
- package/dist/assets/{command-vocab-Dk_f6ivd.js → command-vocab-D-Mb5eIw.js} +1 -1
- package/dist/assets/{create-composition-CuDTI4oW.js → create-composition-Ds7Ik4DO.js} +1 -1
- package/dist/assets/device-detail-D8-PST69.js +1 -0
- package/dist/assets/{device-integration-icon-Du0OOWVL.js → device-integration-icon-CIwY5XXY.js} +1 -1
- package/dist/assets/device-picker-model-DBhTfKm0.js +1 -0
- package/dist/assets/{dist-C0Eyz4-R.js → dist-1yU8tcrp.js} +39 -39
- package/dist/assets/{dist-Dx1IuG2H.js → dist-hKqDc_W9.js} +1 -1
- package/dist/assets/{format-BoPK6WDS.js → format-B7kl8sLY.js} +1 -1
- package/dist/assets/{hostInit-R6aRLO6f.js → hostInit-De1tBXdJ.js} +1 -1
- package/dist/assets/i18n-CcjpDLHK.js +1 -0
- package/dist/assets/icons-B6WiLi5J.js +1 -0
- package/dist/assets/index-DgOWypvk.js +4 -0
- package/dist/assets/index-SyR6jUqA.css +2 -0
- package/dist/assets/{linked-devices-model-l7VwE3qS.js → linked-devices-model-eYoI_73X.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-f5c7db8d.js → mf-entry-bootstrap-0-959d6f36.js} +2 -2
- package/dist/assets/mount-DBhTfKm0.js +1 -0
- package/dist/assets/{notification-rule-status-7H1KxBu5.js → notification-rule-status-DkXZfwuk.js} +1 -1
- package/dist/assets/player-overlays-BMit2yun.js +1 -0
- package/dist/assets/remoteEntry-DCzIPVEe.js +1 -0
- package/dist/assets/scissors-Bbq6WhOK.js +1 -0
- package/dist/assets/src-Dg912oqK.js +250 -0
- package/dist/assets/step-inspector-model-BmSCuJai.js +1 -0
- package/dist/assets/{use-scenes-feed-0tdRPh1u.js → use-scenes-feed-DBj0OZCW.js} +1 -1
- package/dist/assets/{use-stationary-objects-B-7xI3IZ.js → use-stationary-objects-DtRd8lhr.js} +1 -1
- package/dist/assets/{useAdminDeviceRemoval-DyJlz4Qu.js → useAdminDeviceRemoval-d9P0Cpza.js} +1 -1
- package/dist/assets/useEventInvalidation-DBhTfKm0.js +1 -0
- package/dist/assets/{useNodeUrlSelection-Cd7C-Q8s.js → useNodeUrlSelection-Cut66SbO.js} +1 -1
- package/dist/assets/{useTemplateSave-DjD9dD7s.js → useTemplateSave-CEcw08D0.js} +1 -1
- package/dist/assets/{video-BV-3O_ZC.js → video-De6y5yax.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-qyH7YtIe.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DAlkrz1F.js} +2 -2
- package/dist/index.html +9 -9
- package/dist/server/addon.js +20 -2
- package/package.json +2 -2
- package/dist/assets/Addons-BRJLrkwT.js +0 -5
- package/dist/assets/AiProfiles-DlucJ2e_.js +0 -3
- package/dist/assets/Data-BhXREBZ6.js +0 -2
- package/dist/assets/DeviceDetail-Bgqvz6LO.js +0 -2
- package/dist/assets/History-B4cuBJ9s.js +0 -1
- package/dist/assets/Identity-DiMZm2ME.js +0 -1
- package/dist/assets/InstancesTable-pH3oYjHd.js +0 -1
- package/dist/assets/IntegrationDetail-ClV3Saht.js +0 -1
- package/dist/assets/IntegrationWizard-DXKqbhGb.js +0 -1
- package/dist/assets/Integrations-ChAwiavW.js +0 -1
- package/dist/assets/Library-B-Y18dDd.js +0 -1
- package/dist/assets/Locations-rKV353P0.js +0 -3
- package/dist/assets/MyAccess-DvyNpsOp.js +0 -2
- package/dist/assets/Network-CMZXMxES.js +0 -1
- package/dist/assets/NodeAddonsSettingsPanel-Cqw9BMNg.js +0 -2
- package/dist/assets/Notifications-tmDmEumh.js +0 -1
- package/dist/assets/Pipeline-CVkKmqvo.js +0 -1
- package/dist/assets/Recordings-C_LVPbT_.js +0 -1
- package/dist/assets/ScanSubnetEditor-C7lmoWdP.js +0 -1
- package/dist/assets/SessionsList-tD4A7E3T.js +0 -2
- package/dist/assets/StorageLocationsTable-FczbEPcL.js +0 -1
- package/dist/assets/client-Dzzkm60X.js +0 -1114
- package/dist/assets/device-detail-QogRNcnP.js +0 -1
- package/dist/assets/device-picker-model-DQQApnAQ.js +0 -1
- package/dist/assets/i18n-DWUEvjgE.js +0 -1
- package/dist/assets/icons-Dhc1mBIs.js +0 -1
- package/dist/assets/index-BK_1kQTJ.js +0 -4
- package/dist/assets/index-DcUA-A3F.css +0 -2
- package/dist/assets/mount-DQQApnAQ.js +0 -1
- package/dist/assets/player-overlays-DpoShe47.js +0 -1
- package/dist/assets/remoteEntry-CRdIUxja.js +0 -1
- package/dist/assets/scissors-BgY-d4kD.js +0 -1
- package/dist/assets/src-5h33Ujaz.js +0 -253
- package/dist/assets/step-inspector-model-CRzHv57F.js +0 -1
- package/dist/assets/useEventInvalidation-DQQApnAQ.js +0 -1
package/dist/index.html
CHANGED
|
@@ -150,18 +150,18 @@
|
|
|
150
150
|
})
|
|
151
151
|
})()
|
|
152
152
|
</script>
|
|
153
|
-
<script type="module" crossorigin src="./assets/mf-entry-bootstrap-0-
|
|
153
|
+
<script type="module" crossorigin src="./assets/mf-entry-bootstrap-0-959d6f36.js"></script>
|
|
154
154
|
<link rel="modulepreload" crossorigin href="./assets/chevron-down-CBb-F8DT.js">
|
|
155
155
|
<link rel="modulepreload" crossorigin href="./assets/__vite-browser-external-B6QEsNSJ.js">
|
|
156
|
-
<link rel="modulepreload" crossorigin href="./assets/client-
|
|
157
|
-
<link rel="modulepreload" crossorigin href="./assets/player-overlays-
|
|
158
|
-
<link rel="modulepreload" crossorigin href="./assets/src-
|
|
156
|
+
<link rel="modulepreload" crossorigin href="./assets/client-DLGNlJDt.js">
|
|
157
|
+
<link rel="modulepreload" crossorigin href="./assets/player-overlays-BMit2yun.js">
|
|
158
|
+
<link rel="modulepreload" crossorigin href="./assets/src-Dg912oqK.js">
|
|
159
159
|
<link rel="modulepreload" crossorigin href="./assets/useTranslation-BJr-n0es.js">
|
|
160
|
-
<link rel="modulepreload" crossorigin href="./assets/i18n-
|
|
161
|
-
<link rel="modulepreload" crossorigin href="./assets/video-
|
|
162
|
-
<link rel="modulepreload" crossorigin href="./assets/mount-
|
|
163
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
164
|
-
<link rel="modulepreload" crossorigin href="./assets/hostInit-
|
|
160
|
+
<link rel="modulepreload" crossorigin href="./assets/i18n-CcjpDLHK.js">
|
|
161
|
+
<link rel="modulepreload" crossorigin href="./assets/video-De6y5yax.js">
|
|
162
|
+
<link rel="modulepreload" crossorigin href="./assets/mount-DBhTfKm0.js">
|
|
163
|
+
<link rel="stylesheet" crossorigin href="./assets/index-SyR6jUqA.css">
|
|
164
|
+
<link rel="modulepreload" crossorigin href="./assets/hostInit-De1tBXdJ.js"><link rel="modulepreload" crossorigin href="./assets/index-DgOWypvk.js"><link rel="modulepreload" crossorigin href="./assets/remoteEntry-DCzIPVEe.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Ck0PhSCH.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_client__loadShare__.js-8kv6pj9W.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DzoL8nR8.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-BPba2g2p.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-ZBKFTPET.js"></head>
|
|
165
165
|
<body>
|
|
166
166
|
<div id="root"></div>
|
|
167
167
|
<!-- Lock the app shell at 1x zoom. iOS Safari ignores `user-scalable=no`
|
package/dist/server/addon.js
CHANGED
|
@@ -56111,6 +56111,12 @@ var IntegrationLiteSchema = object({
|
|
|
56111
56111
|
var AvailableIntegrationTypeSchema = object({
|
|
56112
56112
|
addonId: string(),
|
|
56113
56113
|
name: string(),
|
|
56114
|
+
/**
|
|
56115
|
+
* Product name a new integration is prefilled from (`<label> - Home`).
|
|
56116
|
+
* Absent: the client uses `name`. Set when the catalog title is not the
|
|
56117
|
+
* product (Bosch SHC, MQTT).
|
|
56118
|
+
*/
|
|
56119
|
+
providerLabel: string().optional(),
|
|
56114
56120
|
description: string(),
|
|
56115
56121
|
iconUrl: string().nullable(),
|
|
56116
56122
|
color: string(),
|
|
@@ -66893,6 +66899,13 @@ var NcRuleInputSchema = object({
|
|
|
66893
66899
|
*/
|
|
66894
66900
|
groupingSec: number$1().int().min(5).max(60).optional(),
|
|
66895
66901
|
/**
|
|
66902
|
+
* Hold deliveries of this rule to one target and, when two or more arrive
|
|
66903
|
+
* before the window ends, send them as one summary. Absent = the kind's
|
|
66904
|
+
* default (`groupWithinSecOf`): 5 s for a system-event rule, 0 for every
|
|
66905
|
+
* other kind. `0` sends each delivery as it does today.
|
|
66906
|
+
*/
|
|
66907
|
+
groupWithinSec: number$1().int().min(0).max(300).optional(),
|
|
66908
|
+
/**
|
|
66896
66909
|
* ASK ME TO CONFIRM DETECTIONS (#243): a DETECTION notification of this rule
|
|
66897
66910
|
* carries "Correct" / "Wrong" buttons (and, where the channel has room, a
|
|
66898
66911
|
* "Wrong, it is a <class>" choice). A tap marks the track for retraining, the
|
|
@@ -67329,7 +67342,12 @@ var NcHistoryEntrySchema = object({
|
|
|
67329
67342
|
* Assistant export) must render as "no image right now", never as a
|
|
67330
67343
|
* broken link.
|
|
67331
67344
|
*/
|
|
67332
|
-
artifactIds: array(string().min(1)).optional()
|
|
67345
|
+
artifactIds: array(string().min(1)).optional(),
|
|
67346
|
+
/**
|
|
67347
|
+
* When this row was folded into a group-window summary, the outbox id of
|
|
67348
|
+
* that one notification. Absent on a row that was sent as itself.
|
|
67349
|
+
*/
|
|
67350
|
+
groupedInto: string().min(1).optional()
|
|
67333
67351
|
});
|
|
67334
67352
|
/**
|
|
67335
67353
|
* Query filter for `getHistory` (spec §4.2). Every field is a narrowing
|
|
@@ -95789,7 +95807,7 @@ var AdminUIAddon = class extends BaseAddon {
|
|
|
95789
95807
|
capability: adminUiCapability,
|
|
95790
95808
|
provider: {
|
|
95791
95809
|
getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
|
|
95792
|
-
getVersion: async () => ({ version: "1.2.
|
|
95810
|
+
getVersion: async () => ({ version: "1.2.650" })
|
|
95793
95811
|
}
|
|
95794
95812
|
}];
|
|
95795
95813
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-admin-ui",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.650",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Admin UI — Vite frontend build and server-side addon",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
}
|
|
51
51
|
],
|
|
52
52
|
"requires": {
|
|
53
|
-
"server": ">=1.2.
|
|
53
|
+
"server": ">=1.2.847"
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{B as e,C as t,J as n,K as r,R as i,S as a,V as o,Y as s,et as c,o as l,x as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{An as d,Bt as f,Ei as p,Jn as m,Kt as h,Mn as g,Nn as _,Or as v,Pi as y,Q as b,St as x,Un as S,Vi as C,Wi as w,Yt as T,cr as ee,ct as te,ot as ne,ui as re,ut as E,vn as D}from"./player-overlays-DpoShe47.js";import{uc as O}from"./client-Dzzkm60X.js";import{t as ie}from"./chevron-down-CBb-F8DT.js";import{a as k,p as A}from"./video-BV-3O_ZC.js";import{$d as j,$i as ae,Fc as oe,Hr as se,If as ce,Ji as le,Jr as ue,Ki as M,Kr as de,Nf as N,Qi as fe,Sn as pe,Ud as me,Ur as P,Us as F,Wi as he,Wr as ge,Xi as I,Yi as _e,Zi as L,aa as ve,ar as R,ca as z,cr as B,fa as V,ia as ye,la as H,ma as be,mr as xe,na as U,or as W,pa as Se,pt as Ce,qi as G,qr as we,ra as Te,rt as Ee,sa as De,sf as Oe,sr as ke,ta as K,ua as Ae,xn as je}from"./src-5h33Ujaz.js";import{t as q}from"./useTranslation-BJr-n0es.js";import"./mount-DQQApnAQ.js";import{Kr as Me,Qr as Ne,Xr as Pe}from"./index-BK_1kQTJ.js";import{t as Fe}from"./AdminPage-BoBZR6uA.js";import{i as Ie,r as Le,t as Re}from"./addon-kind-filter-CEGKkC1O.js";import{n as J,t as ze}from"./framework-packages-B0ugw-Ay.js";import{t as Y}from"./NodeAddonsSettingsPanel-Cqw9BMNg.js";import{n as X,r as Be,t as Ve}from"./useNodeUrlSelection-Cd7C-Q8s.js";function He(e){if(e===void 0)return null;switch(e.state){case`failed`:case`refused`:case`missing`:case`crashed`:return{kind:e.state,...e.reason===void 0?{}:{reason:e.reason}};default:return null}}c();var Ue={queued:{icon:p,bg:`bg-muted text-foreground-subtle`,labelKey:`addons.addonRowBadge.queued`},updating:{icon:v,bg:`bg-primary/10 text-primary`,labelKey:`addons.addonRowBadge.updating`,spin:!0},"done-pending-restart":{icon:S,bg:`bg-amber-500/10 text-amber-700`,labelKey:`addons.addonRowBadge.pendingRestart`},done:{icon:w,bg:`bg-success/10 text-success`,labelKey:`addons.addonRowBadge.done`},failed:{icon:k,bg:`bg-danger/10 text-danger`,labelKey:`addons.addonRowBadge.failed`}};function Z({item:e}){let{t:n}=q(),r=Ue[e.status],i=r.icon;return t(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded ${r.bg}`,title:e.error,children:[a(i,{className:`w-2.5 h-2.5 ${r.spin?`animate-spin`:``}`}),n(r.labelKey)]})}var Q=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),We=new Set([`done`,`failed`,`skipped`]);function Ge(e){return!We.has(e.phase)&&!Q.has(e.jobState)}function Ke(e,t){let n=new Map,r=[...e].sort((e,t)=>e.createdAtMs-t.createdAtMs);for(let e of r){let r=Q.has(e.state);for(let i of e.tasks)r&&i.finishedAtMs!==null&&t-i.finishedAtMs>6e4||n.set(i.packageName,{jobId:e.jobId,packageName:i.packageName,phase:i.phase,fromVersion:i.fromVersion,toVersion:i.toVersion,error:i.error,jobState:e.state,finishedAtMs:i.finishedAtMs})}return n}function qe(){let{data:e}=U({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=ce(O.AddonsJobProgress,e=>e.job.jobId);return r(()=>{let n=new Map;for(let t of e??[])n.set(t.jobId,t);for(let[e,r]of t)n.set(e,r.job);return Ke([...n.values()],Date.now())},[e,t])}var Je={queued:{icon:p,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.queued`},fetching:{icon:v,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.fetching`,spin:!0},staged:{icon:v,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.staged`,spin:!0},validating:{icon:v,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.validating`,spin:!0},applying:{icon:v,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.applying`,spin:!0},restarting:{icon:v,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,labelKey:`addons.jobProgress.restarting`,spin:!0},applied:{icon:v,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.finalizing`,spin:!0},done:{icon:w,cls:`bg-success/10 text-success`,labelKey:`addons.jobProgress.updated`},failed:{icon:k,cls:`bg-danger/10 text-danger`,labelKey:`addons.jobProgress.failed`},skipped:{icon:D,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.skipped`}};function Ye({progress:e}){let{t:n}=q(),r=Je[e.phase],i=r.icon,o=e.error??`${e.packageName}: ${e.fromVersion??`?`} → ${e.toVersion}`;return t(`span`,{"data-testid":`addon-job-progress`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded shrink-0 ${r.cls}`,title:o,children:[a(i,{className:`w-2.5 h-2.5 ${r.spin?`animate-spin`:``}`}),n(r.labelKey),t(`span`,{className:`font-mono`,children:[`→ `,e.toVersion]})]})}function Xe(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 Ze(e){let t=e.version===null?``:` ${e.version}`,n=e.isOnline?``:` (offline: removed when it reconnects)`;return`- ${e.nodeName}${t}${n}`}function Qe(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(Ze)];return n.length>0&&r.push(`Could not ask: ${n.join(`, `)} — not included.`),r.push(`This cannot be undone.`),r.join(`
|
|
2
|
-
`)}function $e(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 et={uninstalled:`uninstalled`,"not-installed":`was not installed`,refused:`REFUSED`,failed:`FAILED`,"pending-reconnect":`offline — removed when it reconnects`};function tt(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)}: ${et[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 nt={},rt=3e4,it=`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 at({packageName:e,displayName:n,selectedNode:r,hideNodeAction:i,disabled:o}){let{t:s}=q(),c=l(),u=te(),d=ne(),f=K(nt,{staleTime:rt}),p=f.data?.installations??[],m=(f.data?.unreachable??[]).map(e=>e.nodeId),h=Xe(p,e),g=e=>h.find(t=>t.nodeId===e)?.nodeName??(e===r.id?r.name:e),_=Se({onSettled:()=>{c.invalidateQueries({queryKey:[[`addons`]]}),c.invalidateQueries({queryKey:[[`addonPages`]]}),c.invalidateQueries({queryKey:[[`capabilities`]]}),c.invalidateQueries({queryKey:[[`nodes`]]})}}),v=async e=>{await d({title:e.success?s(`addons.addonUninstallControls.uninstalled`,`{{displayName}} uninstalled`,{displayName:n}):s(`addons.addonUninstallControls.notEveryNodeWasCleaned`,`{{displayName}}: not every node was cleaned`,{displayName:n}),message:tt(e,g),variant:e.success?`default`:`danger`})},y=async t=>{try{await v(await _.mutateAsync({packageName:e,...t}))}catch(e){await d({title:s(`addons.addonUninstallControls.uninstallFailed`,`Uninstall {{displayName}} failed`,{displayName:n}),message:e instanceof Error?e.message:String(e),variant:`danger`})}},b=async()=>{let e=h.filter(e=>e.nodeId!==r.id);await u({title:s(`addons.addonUninstallControls.uninstallFrom`,`Uninstall {{displayName}} from {{name}}?`,{displayName:n,name:r.name}),message:$e(n,r.name,e),confirmLabel:s(`addons.addonUninstallControls.uninstall`,`Uninstall`),variant:`danger`})&&await y(r.isHub?{}:{nodeId:r.id})},x=async()=>{let t=(await f.refetch()).data;if(t===void 0){await d({title:s(`addons.addonUninstallControls.cannotListTheNodes`,`Cannot list the nodes`),message:s(`addons.addonUninstallControls.theHubDidNotAnswer`,`The hub did not answer which nodes have this package — nothing was removed.`),variant:`danger`});return}let r=Xe(t.installations,e);await u({title:s(`addons.addonUninstallControls.uninstallEverywhere`,`Uninstall {{displayName}} everywhere?`,{displayName:n}),message:Qe(n,r,t.unreachable.map(e=>e.nodeId)),confirmLabel:s(`addons.addonUninstallControls.uninstallFromNodeS`,`Uninstall from {{length}} node(s)`,{length:r.length}),variant:`danger`})&&await y({everywhere:!0})},S=_.isPending||o===!0;return t(`div`,{className:`flex items-center gap-1.5`,children:[i!==!0&&t(j,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),b()},disabled:S,className:it,title:s(`addons.addonUninstallControls.uninstallFrom2`,`Uninstall from {{name}}`,{name:r.name}),children:[a(T,{className:`h-3 w-3`}),_.isPending?s(`addons.addonUninstallControls.removing`,`Removing...`):s(`addons.addonUninstallControls.uninstall`,`Uninstall`)]}),(h.length>1||i===!0||m.length>0)&&t(j,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),x()},disabled:S,className:it,title:s(`addons.addonUninstallControls.uninstallFromEveryNodeThat`,`Uninstall from every node that has it`),children:[a(A,{className:`h-3 w-3`}),h.length>0?s(`addons.uninstallControls.everywhereCount`,{count:h.length}):s(`addons.uninstallControls.everywhere`)]})]})}function ot(e){return typeof e.deprecated==`string`&&e.deprecated.length>0}function st(e,t){return t?e:e.filter(e=>e.distTags.includes(`latest`)||!ot(e))}function ct(e){return e.length-st(e,!1).length}c();function lt({packageName:e,currentVersion:n,installSource:r,onInstall:i,onClose:o,onSelect:c,selectedVersion:l}){let{t:d}=q(),p=r===`upload`||r===`local`,[m,h]=s(!1),{data:g,isLoading:_,isError:y}=L({name:e}),b=g?st(g,m):[],S=g?ct(g):0;return t(`div`,{className:`fixed z-50 w-72 rounded-lg border border-border bg-surface shadow-xl overflow-hidden`,style:{top:`auto`,bottom:`auto`},ref:e=>{if(!e)return;let t=e.parentElement?.getBoundingClientRect();if(!t)return;let n=window.innerHeight-t.bottom,r=t.top;n<280&&r>n?(e.style.bottom=`${window.innerHeight-t.top+4}px`,e.style.top=`auto`):(e.style.top=`${t.bottom+4}px`,e.style.bottom=`auto`),e.style.right=`${window.innerWidth-t.right}px`},onClick:e=>e.stopPropagation(),children:[t(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[a(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle font-medium`,children:d(`addons.versionPicker.versions`,`Versions`)}),a(j,{variant:`unstyled`,type:`button`,onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:a(x,{className:`h-3 w-3`})})]}),p&&t(`div`,{className:`flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]`,children:[a(f,{className:`h-3 w-3 mt-0.5 text-cyan-500 shrink-0`}),t(`div`,{className:`text-cyan-700 dark:text-cyan-200`,children:[a(`span`,{className:`font-semibold`,children:d(`addons.versionPicker.inPlace`,{kind:r===`upload`?d(`addons.versionPicker.uploadedCopy`,`Uploaded copy`):d(`addons.versionPicker.localCopy`,`Local copy`)})}),` `,a(Me,{i18nKey:`addons.versionPicker.reinstall`,values:{version:n},components:{mono:a(`span`,{className:`font-mono`})}})]})]}),_&&t(`div`,{className:`flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle`,children:[a(v,{className:`h-3.5 w-3.5 animate-spin`}),d(`addons.versionPicker.loadingVersions`,`Loading versions...`)]}),y&&a(`div`,{className:`px-3 py-4 text-center text-[10px] text-danger`,children:d(`addons.versionPicker.registryError`,`Could not load versions from the registry.`)}),b.length>0&&a(`div`,{className:`max-h-64 overflow-auto divide-y divide-border`,children:b.map(e=>{let r=e.version===n,o=c!==void 0&&e.version===l,s=/-(alpha|beta|rc|dev|canary|next)/i.test(e.version),f=t(u,{children:[a(`span`,{className:`font-mono flex-1 text-left ${r?`text-primary font-semibold`:s?`text-amber-400`:`text-foreground`}`,children:e.version}),r&&a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium bg-primary/10 text-primary`,children:d(`common.current`)}),e.distTags.map(e=>a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e===`latest`?`bg-emerald-500/15 text-emerald-400`:e===`beta`?`bg-amber-500/15 text-amber-400`:`bg-gray-500/15 text-gray-400`}`,children:e},e)),ot(e)&&a(`span`,{className:`text-[9px] text-red-400 line-through`,children:d(`common.deprecated`)}),a(`span`,{className:`text-[9px] text-foreground-subtle shrink-0`,children:new Date(e.publishedAt).toLocaleDateString()})]});return c?t(j,{variant:`unstyled`,type:`button`,"aria-label":d(`addons.versionPicker.select`,`Select {{version}}`,{version:e.version}),onClick:()=>c(e.version),className:`w-full flex items-center gap-2 px-3 py-2 text-[11px] ${o?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,o?a(w,{className:`h-3 w-3 text-primary shrink-0`}):a(`span`,{className:`w-3 shrink-0`})]},e.version):t(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${r?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,a(j,{variant:`unstyled`,type:`button`,onClick:()=>i(e.version),className:`shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors`,title:r?d(`addons.versionPicker.reInstallFromNpm`,`Re-install {{version}} from npm`,{version:e.version}):d(`addons.versionPicker.install`,`Install {{version}}`,{version:e.version}),children:a(re,{className:`h-3 w-3`})})]},e.version)})}),!_&&!y&&g&&g.length===0&&a(`div`,{className:`py-4 text-center text-[10px] text-foreground-subtle`,children:d(`addons.versionPicker.noVersionsFound`,`No versions found`)}),S>0&&a(j,{type:`button`,variant:`ghost`,size:`sm`,className:`h-auto w-full justify-start rounded-none border-t border-border px-3 py-2 text-left text-[10px] font-normal text-foreground-subtle`,onClick:()=>h(e=>!e),children:m?d(`addons.versionPicker.hideOlder`,`Hide older versions`):d(`addons.versionPicker.showOlder`,`Show older versions ({{count}})`,{count:S})})]})}c();var ut=`device-export`;function dt(e){return e.capabilities.some(e=>(typeof e==`string`?e:e.name)===ut)}function ft(e){return e!==`local`&&e!==`upload`}function pt({isBundle:e,installSource:n,addonId:r,iconPath:i,color:o}){let[c,l]=s(!1),u=o?{backgroundColor:`${o.startsWith(`#`)?o:`#${o}`}26`}:void 0,d=e?`bg-indigo-500/20 text-indigo-700 dark:text-indigo-300`:`bg-purple-500/20 text-purple-700 dark:text-purple-300`,p=r&&i?b(`/api/addon-assets/${r}/${i}`):null,h=!!p&&!c;return t(`div`,{className:`relative flex-shrink-0`,children:[a(`div`,{className:`h-8 w-8 rounded-md flex items-center justify-center ${u?``:d}`,style:u,children:h?a(`img`,{src:p,alt:r,className:`h-4 w-4`,onError:()=>l(!0)}):a(e?ee:m,{className:`h-3.5 w-3.5`})}),n===`local`&&a(`span`,{className:`absolute -top-1.5 -left-1.5 text-[7px] font-bold leading-none bg-orange-500 text-white px-1 py-0.5 rounded -rotate-12 shadow-sm`,children:`DEV`}),ft(n)&&a(`span`,{className:`absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm`,children:a(`svg`,{viewBox:`0 0 780 250`,className:`w-[11px] h-[11px]`,children:a(`path`,{fill:`#fff`,d:`M240 250h100V50h100v200h340V0H0v250z`})})}),n===`upload`&&a(`span`,{className:`absolute -top-1.5 -left-1.5 flex items-center justify-center h-4 w-4 rounded bg-cyan-500 -rotate-12 shadow-sm`,children:a(f,{className:`h-2.5 w-2.5 text-white`})})]})}function mt({version:e,availableUpdate:n,selectedVersion:r,isUpdating:i,installSource:o,disabled:s,onUpdate:c,onOpenPicker:l,children:u}){let{t:d}=q();if(i)return t(`span`,{className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border border-blue-500/30 bg-blue-500/10 text-blue-400 shrink-0`,children:[a(v,{className:`h-3 w-3 animate-spin`}),d(`addons.addonCard.updating`,`Updating…`)]});if(n){let i=r??n;return t(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[c&&t(j,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:s,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-semibold border border-blue-500/30 bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,title:d(`addons.addonCard.updateTo`,`Update to {{target}}`,{target:i}),children:[a(re,{className:`h-3 w-3`}),d(`addons.addonCard.update`,`Update`)]}),t(j,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:s,"aria-label":d(`addons.addonCard.selectVersionToInstall`,`Select version to install`),title:d(`addons.addonCard.installedUpdateAvailableSelectedTap`,`Installed {{version}} — update available. Selected {{target}}; tap to choose another version.`,{version:e,target:i}),className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-bold font-mono border border-amber-500/40 bg-amber-500/15 text-amber-500 hover:bg-amber-500/25 animate-pulse disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[a(`span`,{className:`font-normal opacity-70`,children:e}),a(`span`,{className:`font-normal opacity-70`,children:`→`}),i,a(ie,{className:`h-3 w-3`})]}),u]})}return t(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[t(j,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:s,className:[`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-bold font-mono border transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,o===`local`?`border-orange-500/30 bg-orange-500/10 text-orange-400 hover:bg-orange-500/20`:`border-emerald-500/30 bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20`].join(` `),title:d(`addons.addonCard.versionTapToViewAll`,`Version {{version}} — tap to view all versions`,{version:e}),children:[e,a(ie,{className:`h-3 w-3 opacity-50`})]}),u]})}function ht({addonId:e}){let t=l(),{data:n=`inherit`}=G({addonId:e}),r=H({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addons`,`getAddonAutoUpdate`]]})}});return a(`div`,{className:`flex rounded-lg border border-border overflow-hidden text-[10px] font-medium`,children:[`inherit`,`off`,`latest`,`beta`].map(t=>a(j,{variant:`unstyled`,type:`button`,onClick:n=>{n.stopPropagation(),r.mutate({addonId:e,channel:t})},disabled:r.isPending,className:`px-2.5 py-1 transition-colors capitalize ${n===t?t===`inherit`?`bg-gray-700/50 text-gray-700 dark:text-gray-300`:t===`off`?`bg-gray-700 text-gray-700 dark:text-gray-300`:t===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${t===`inherit`?``:`border-l border-border`}`,children:t},t))})}var gt={id:`hub`,name:`Hub`,isHub:!0};function _t({addon:e,clusterStatus:n,hideVersion:r,availableUpdate:i,blockedUpdate:c,onUpdateServer:f,onUpdate:p,isUpdating:m,jobProgress:h,bundle:g,bulkItem:v,disabledByBulk:y,isSystem:b,selectedNode:w}){let{t:T}=q(),[te,ne]=s(!1),[re,E]=s(!1),[D,O]=s(null);o(()=>{O(null)},[i]);let A=D??i,[ae,oe]=s(!1),[ce,le]=s(!1),[M,N]=s(`logs`),F=l(),he=Pe(),{manifest:I}=e,_e=!g&&!I.protected&&I.removable!==!1,L=!!g,R=g?.displayName??I.name,z=g?.packageName??I.packageName,B=g?.version??I.packageVersion??I.version,V=g?.installSource??e.installSource,ye=g?g.bundle?.description??g.addons[0]?.manifest.description:I.description,H=ve({onSuccess:()=>{F.invalidateQueries({queryKey:[[`addons`]]})}}),be=fe({onSuccess:()=>{F.invalidateQueries({queryKey:[[`addons`]]}),F.invalidateQueries({queryKey:[[`addonPages`]]}),F.invalidateQueries({queryKey:[[`capabilities`]]}),F.invalidateQueries({queryKey:[[`integrations`]]})}}),xe=De({onSuccess:()=>{F.invalidateQueries({queryKey:[[`addons`]]}),F.invalidateQueries({queryKey:[[`alerts`]]})}}),U=e.health,W=U?.phase===`failed`&&!U.inGracePeriod,Se=W&&U?.nextRetryAt&&!U.retrying,G=He(e.process);return t(`div`,{className:`rounded-md border bg-surface overflow-hidden ${W?`border-red-500/50`:`border-border`}`,children:[W&&U&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(k,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),t(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-xs font-semibold text-danger`,children:T(`addons.addonCard.failedToLoad`,{attempt:U.retryCount})}),a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:U.lastError?.message??T(`addons.addonCard.unknownError`,`Unknown error`)}),Se&&U.nextRetryAt&&a(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:T(`addons.addonCard.autoRetryAt`,{time:new Date(U.nextRetryAt).toLocaleTimeString()})})]}),t(j,{variant:`unstyled`,type:`button`,disabled:xe.isPending||U.retrying,onClick:e=>{e.stopPropagation(),xe.mutate({packageName:z})},className:`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-semibold border border-red-400/40 bg-red-400/10 text-red-700 dark:text-red-300 hover:bg-red-400/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors shrink-0`,title:T(`addons.addonCard.resetRetryCounterAndForce`,`Reset retry counter and force immediate reload`),children:[a(S,{className:`h-3 w-3 ${xe.isPending||U.retrying?`animate-spin`:``}`}),T(`addons.addonCard.retryNow`,`Retry now`)]})]}),G!==null&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(k,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),t(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-xs font-semibold text-danger`,children:T(`addons.addonCard.processProblem.${G.kind}`)}),G.reason!==void 0&&a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:G.reason})]})]}),t(`div`,{className:`flex items-start gap-2.5 px-3 py-2`,children:[a(pt,{isBundle:L||!!I.components&&I.components.length>1,installSource:V,addonId:L?g.addons[0]?.manifest.id:I.id,iconPath:L?g.bundle?.icon??g.addons[0]?.manifest.icon:I.icon,color:L?g.addons[0]?.manifest.color:I.color}),t(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`flex items-start justify-between gap-2`,children:[a(`span`,{className:`text-xs font-semibold text-foreground truncate min-w-0`,children:R}),!r&&a(mt,{version:B,availableUpdate:i,...A===void 0?{}:{selectedVersion:A},isUpdating:m,installSource:V,disabled:y,...p&&A!==void 0?{onUpdate:()=>p(A)}:{},onOpenPicker:()=>E(e=>!e),children:re&&a(lt,{packageName:z,currentVersion:B,...V?{installSource:V}:{},...i!==void 0&&A!==void 0?{selectedVersion:A,onSelect:e=>{O(e),E(!1)}}:{},onInstall:e=>{E(!1),be.mutate({packageName:z,version:e})},onClose:()=>E(!1)})})]}),t(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[z!==R&&a(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:z}),L&&t(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,children:[a(ee,{className:`h-3 w-3`}),g.addons.length]}),b&&t(`span`,{className:`text-[10px] rounded-full bg-amber-500/15 text-amber-700 dark:text-amber-300 px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,title:T(`addons.addonCard.systemPackageUpdatingRestartsThe`,`System package — updating restarts the hub`),children:[a(S,{className:`h-3 w-3`}),T(`addons.addonCard.system`,`System`)]}),v!=null&&a(Z,{item:v}),c!==void 0&&a(me,{variant:`warning`,title:T(`addons.addonCard.updateHeldTitle`,{defaultValue:`{{latest}} is held until the server is {{required}} or newer`,latest:c.latestVersion,required:c.requiredServer}),children:T(`addons.addonCard.requiresServer`,{defaultValue:`requires server ≥ {{version}}`,version:c.requiredServer})}),c!==void 0&&f!==void 0&&a(j,{type:`button`,size:`sm`,variant:`secondary`,onClick:f,children:T(`clusterUpdate.updateServer`,`Update server`)}),h!=null&&a(Ye,{progress:h})]}),ye&&a(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:ye}),!L&&e.process&&t(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.mode===`forked`?`bg-blue-500/15 text-blue-400`:`bg-gray-500/15 text-gray-400`}`,children:e.process.mode===`forked`?T(`addons.addonCard.forked`):T(`addons.addonCard.inProcess`)}),e.process.pid!=null&&t(`span`,{className:`text-[9px] font-mono text-foreground-subtle`,children:[`PID `,e.process.pid]}),a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.state===`running`?`bg-emerald-500/15 text-emerald-400`:G===null?`bg-gray-500/15 text-gray-400`:`bg-red-500/15 text-red-400`}`,children:e.process.state})]})]})]}),!L&&t(`div`,{className:`flex items-center gap-1 px-3 py-1 border-t border-border/50 bg-surface-hover/20`,children:[t(j,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),H.mutate({addonId:I.id})},disabled:H.isPending||y,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border border-border text-foreground-subtle hover:text-blue-400 hover:border-blue-500/30 hover:bg-blue-500/10 disabled:opacity-50 transition-colors`,children:[a(S,{className:`h-3 w-3 ${H.isPending?`animate-spin`:``}`}),T(`addons.addonCard.restart`,`Restart`)]}),t(j,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),oe(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${ae?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[a(_,{className:`h-3 w-3`}),T(`addons.addonCard.logs`,`Logs`)]}),!L&&t(j,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),le(!0)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${ce?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[a(d,{className:`h-3 w-3`}),T(`addons.addonCard.settings`,`Settings`)]}),a(`div`,{className:`flex-1`}),_e&&a(at,{packageName:I.packageName,displayName:I.name,selectedNode:w??gt,disabled:y})]}),n&&n.nodes.length>1&&!L&&t(`div`,{className:`border-t border-border px-3 py-1.5 bg-muted/10`,children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle mb-1.5`,children:T(`addons.addonCard.clusterDeployment`,`Cluster Deployment`)}),a(`div`,{className:`space-y-1`,children:n.nodes.map(e=>t(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[a(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`offline`?`bg-muted-foreground/30`:e.synced?`bg-success`:`bg-amber-500`}`}),a(`span`,{className:`font-medium text-foreground min-w-[60px]`,children:e.name}),a(`span`,{className:`font-mono text-foreground-subtle`,children:e.version}),!e.synced&&e.status!==`offline`&&a(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20`,children:T(`addons.addonCard.outdated`)}),e.status===`offline`&&a(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:T(`common.offline`)}),e.synced&&e.status!==`offline`&&a(`span`,{className:`text-[9px] text-success`,children:T(`common.synced`)})]},e.nodeId))})]}),ae&&!L&&t(`div`,{className:`border-t border-border`,children:[t(`div`,{className:`flex items-center px-3 py-0.5 bg-surface-hover/20 border-b border-border/50`,children:[t(`div`,{className:`flex rounded border border-border overflow-hidden text-[9px]`,children:[a(j,{variant:`unstyled`,type:`button`,onClick:()=>N(`logs`),className:`px-2 py-0.5 transition-colors ${M===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:T(`addons.addonCard.logs`,`Logs`)}),a(j,{variant:`unstyled`,type:`button`,onClick:()=>N(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${M===`events`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:T(`addons.addonCard.events`,`Events`)})]}),a(`div`,{className:`flex-1`}),a(j,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),oe(!1)},className:`text-foreground-subtle hover:text-foreground`,children:a(x,{className:`h-3.5 w-3.5`})})]}),M===`logs`&&a(pe,{addonId:I.id,maxHeight:`max-h-64`,showFilters:!1}),M===`events`&&a(je,{addonId:I.id,category:`addon.*`,maxHeight:`max-h-64`})]}),L&&t(u,{children:[a(j,{variant:`unstyled`,type:`button`,onClick:()=>ne(e=>!e),className:`w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors`,children:a(te?C:ie,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),te&&a(`div`,{className:`border-t border-border px-2.5 py-1.5 space-y-1.5`,children:g.addons.map(e=>a(_t,{addon:e,hideVersion:!0},e.manifest.id))})]}),ce&&!L&&a(se,{open:!0,onOpenChange:e=>!e&&le(!1),children:t(ge,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(we,{children:t(ue,{className:`flex items-center gap-2`,children:[a(d,{className:`h-4 w-4 text-primary`}),T(`addons.addonCard.settingsTitle`,{name:R})]})}),t(P,{className:`space-y-4`,children:[a(`div`,{className:`text-[10px] text-foreground-subtle mb-2`,children:T(`addons.addonCard.clusterWideSettingsOneValue`,`Cluster-wide settings — one value for every node. Per-node settings live under Cluster → the node → Settings.`)}),a(Y,{nodeId:null,addonIds:[I.id],level:`global`,fieldScope:`cluster`,emptyMessage:T(`addons.addonCard.thisAddonExposesNoCluster`,`This addon exposes no cluster-wide settings. Anything it can configure is per-node — open it from Cluster → the node → Settings.`)}),dt(I)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:T(`addons.addonCard.deviceExport`,`Device export`)}),a(Ce,{addonId:I.id,onOpenDevice:e=>he(`/devices/${e}`)})]}),ft(V)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:T(`addons.addonCard.autoUpdate`,`Auto-Update`)}),a(ht,{addonId:I.id})]}),I.components&&I.components.length>0&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:T(`addons.addonCard.components`,{count:I.components.length})}),a(`div`,{className:`flex flex-wrap gap-1`,children:I.components.map(e=>a(`span`,{className:`text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono`,children:e},e))})]})]}),a(de,{children:a(j,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>le(!1),children:T(`common.close`,`Close`)})})]})})]})}c();var vt=`.tgz,.tar.gz,.zip`;function yt({onUploadSuccess:e}){let{t:r}=q(),[o,c]=s(!1),l=n(null),d=i(async t=>{c(!0);let n=new FormData;n.append(`file`,t);let r=localStorage.getItem(`camstack_admin_token`)??``;try{(await(await fetch(b(`/api/addons/upload`),{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:n})).json()).success&&e()}finally{c(!1)}},[e]);return t(u,{children:[a(xe,{ref:l,accept:vt,onChange:i(e=>{let t=e.target.files?.[0];t&&d(t),e.target.value=``},[d]),className:`hidden`}),t(j,{variant:`unstyled`,type:`button`,onClick:()=>l.current?.click(),disabled:o,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,children:[o?a(v,{className:`w-3.5 h-3.5 animate-spin`}):a(f,{className:`w-3.5 h-3.5`}),o?r(`addons.addonUploadZone.uploading`,`Uploading...`):r(`addons.addonUploadZone.upload`,`Upload`)]})]})}var bt=/```[^\n]*\n([\s\S]*?)```/g;function xt(e){let t=[],n=0;for(let r of e.matchAll(bt)){let i=r.index??0;i>n&&t.push({kind:`text`,body:e.slice(n,i)}),t.push({kind:`code`,body:r[1]??``}),n=i+r[0].length}return n<e.length&&t.push({kind:`text`,body:e.slice(n)}),t}function St(e){let t=e.trim();return t.startsWith(`https://`)||t.startsWith(`http://`)?t:null}function Ct(e,t){let n=[],r=/(\*\*[^*]+\*\*|`[^`]+`|\[[^\]]+\]\([^)]+\))/g,i=0,o=0;for(let s of e.matchAll(r)){let r=s.index??0;r>i&&n.push(e.slice(i,r));let c=s[0],l=`${t}-${o}`;if(o+=1,c.startsWith(`**`))n.push(a(`strong`,{children:c.slice(2,-2)},l));else if(c.startsWith("`"))n.push(a(`code`,{className:`font-mono text-[0.9em]`,children:c.slice(1,-1)},l));else{let e=/^\[([^\]]+)\]\(([^)]+)\)$/.exec(c),t=e?.[1]??c,r=e?St(e[2]??``):null;n.push(r?a(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:`text-primary underline`,children:t},l):a(`span`,{children:t},l))}i=r+c.length}return i<e.length&&n.push(e.slice(i)),n}function wt(e,t){let n=e.split(`
|
|
5
|
-
`),r=[],i=[],o=[],s=0,c=()=>{if(i.length===0)return;let e=i.join(` `).trim();i=[],e.length!==0&&(r.push(a(`p`,{className:`mb-2 last:mb-0`,children:Ct(e,`${t}-p-${s}`)},`${t}-p-${s}`)),s+=1)},l=()=>{if(o.length===0)return;let e=o;o=[],r.push(a(`ul`,{className:`mb-2 list-disc pl-4 last:mb-0`,children:e.map((e,n)=>a(`li`,{children:Ct(e,`${t}-li-${s}-${n}`)},`${t}-li-${s}-${n}`))},`${t}-ul-${s}`)),s+=1};for(let e of n){let n=/^(#{1,3})\s+(.*)$/.exec(e),u=/^\s*[-*]\s+(.*)$/.exec(e);if(n){c(),l();let e=n[1]?.length??1,i=Ct(n[2]??``,`${t}-h-${s}`),o=e===1?`text-sm font-semibold mb-2`:`text-xs font-semibold mb-1.5 mt-2`;r.push(a(e===1?`h3`:`h4`,{className:o,children:i},`${t}-h-${s}`)),s+=1;continue}if(u){c(),o=[...o,u[1]??``];continue}if(e.trim().length===0){c(),l();continue}l(),i=[...i,e.trim()]}return c(),l(),r}function Tt({markdown:e}){return a(`div`,{className:`text-xs text-foreground leading-relaxed`,children:xt(e).map((e,t)=>e.kind===`code`?a(`pre`,{className:`mb-2 overflow-auto rounded-md bg-surface-hover p-2 font-mono text-[10px] last:mb-0`,children:e.body.replace(/\n$/,``)},`code-${t}`):a(`div`,{children:wt(e.body,`b${t}`)},`text-${t}`))})}c();function Et(e){return e.replace(/^@camstack\/(addon-)?/,``)}function Dt(e,t,n){let r=st(e,n);return r.some(e=>e.version===t)?r:[{version:t,distTags:[],deprecated:void 0},...r]}function Ot({pending:e,failed:n,body:r,missing:i}){let{t:o}=q();return e?t(`div`,{className:`flex items-center gap-2 py-6 text-xs text-foreground-subtle`,children:[a(v,{className:`h-3.5 w-3.5 animate-spin`}),o(`addons.installDialog.loadingDocument`,`Loading…`)]}):n||r===void 0?a(`p`,{className:`py-4 text-xs text-danger`,children:o(`addons.installDialog.couldNotLoadDocument`,`Could not load this file from the registry.`)}):r.status===`ok`&&r.markdown!==void 0?a(Tt,{markdown:r.markdown}):r.status===`error`?a(`p`,{className:`py-4 text-xs text-danger`,children:o(`addons.installDialog.documentError`,`Could not load this file. {{message}}`,{message:r.message??``})}):a(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:i})}function kt({target:e,installing:n,installError:r,onClose:i,onInstall:o}){let{t:c}=q(),[l,u]=s(e.version),[d,f]=s(!1),p=L({name:e.name}),m=I({name:e.name,version:l}),h=p.data??[],g=ct(h),_=Dt(h,l,d),y=m.data;return a(se,{open:!0,onOpenChange:e=>!e&&i(),children:t(ge,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(we,{children:a(ue,{children:c(`addons.installDialog.title`,`Install {{name}}`,{name:Et(e.name)})})}),t(P,{className:`space-y-3`,children:[a(`p`,{className:`font-mono text-[10px] text-foreground-subtle`,children:e.name}),e.description.length>0&&a(`p`,{className:`text-xs text-foreground`,children:e.description}),t(`div`,{className:`space-y-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:c(`addons.installDialog.version`,`Version`)}),a(E,{"aria-label":c(`addons.installDialog.version`,`Version`),value:l,options:_.map(e=>({value:e.version,label:ot(e)?c(`addons.installDialog.deprecatedVersion`,`{{version}} (deprecated)`,{version:e.version}):e.version})),onChange:e=>u(e.target.value)}),p.isError&&a(`p`,{className:`text-[10px] text-danger`,children:c(`addons.versionPicker.registryError`,`Could not load versions from the registry.`)}),g>0&&a(j,{type:`button`,variant:`ghost`,size:`sm`,className:`h-auto justify-start px-0 text-[10px] font-normal text-foreground-subtle underline`,onClick:()=>f(e=>!e),children:d?c(`addons.versionPicker.hideOlder`,`Hide older versions`):c(`addons.versionPicker.showOlder`,`Show older versions ({{count}})`,{count:g})})]}),t(R,{defaultValue:`readme`,children:[t(ke,{children:[a(B,{value:`readme`,children:c(`addons.installDialog.readme`,`README`)}),a(B,{value:`changelog`,children:c(`addons.installDialog.changelog`,`CHANGELOG`)})]}),a(W,{value:`readme`,children:a(`div`,{className:`max-h-80 overflow-auto rounded-md border border-border bg-background p-3`,children:a(Ot,{pending:m.isPending,failed:m.isError,body:y?.readme,missing:c(`addons.installDialog.missingReadme`,`This package has no README.`)})})}),a(W,{value:`changelog`,children:a(`div`,{className:`max-h-80 overflow-auto rounded-md border border-border bg-background p-3`,children:a(Ot,{pending:m.isPending,failed:m.isError,body:y?.changelog,missing:c(`addons.installDialog.missingChangelog`,`This package has no CHANGELOG.`)})})})]}),r!=null&&r.length>0&&a(`p`,{className:`text-xs text-danger`,children:r})]}),t(de,{children:[a(j,{type:`button`,variant:`outline`,size:`sm`,onClick:i,children:c(`common.cancel`,`Cancel`)}),a(j,{type:`button`,size:`sm`,disabled:n||l.length===0,onClick:()=>o(e.name,l),children:n?a(v,{className:`h-3.5 w-3.5 animate-spin`}):c(`addons.installDialog.install`,`Install`)})]})]})})}function At(e,t){let n=new Map;for(let r of e){if(r.isHub||r.onHub||J(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 jt({selectedNode:e}){let{t:n}=q(),{data:r}=K(nt,{staleTime:rt});if(r===void 0)return null;let i=At(r.installations,e),o=r.unreachable.filter(t=>e.isHub||t.nodeId===e.id);return i.length===0&&o.length===0?null:t(`div`,{className:`rounded-lg border border-warning/30 bg-warning/5 px-3 py-2.5 space-y-2`,children:[t(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold text-foreground`,children:[a(h,{className:`h-3.5 w-3.5 text-warning`}),e.isHub?n(`addons.nodeOnlyPackagesPanel.installedOnAgentsButNot`,`Installed on agents but not on the hub`):n(`addons.nodeOnlyPackagesPanel.installedOnButNotOn`,`Installed on {{name}} but not on the hub`,{name:e.name})]}),o.length>0&&a(`div`,{className:`text-[10px] text-foreground-subtle`,children:n(`addons.nodeOnlyPackagesPanel.unreachable`,{nodes:o.map(e=>e.nodeId).join(`, `)})}),i.map(n=>t(`div`,{className:`flex items-center justify-between gap-3 flex-wrap rounded-md border border-border bg-surface px-3 py-2`,children:[t(`div`,{className:`min-w-0`,children:[a(`div`,{className:`text-xs font-mono text-foreground break-all`,children:n.packageName}),a(`div`,{className:`text-[10px] text-foreground-subtle`,children:n.rows.map(e=>`${e.nodeName}${e.version===null?``:` ${e.version}`}${e.isOnline?``:` (offline)`}`).join(` · `)})]}),a(at,{packageName:n.packageName,displayName:n.packageName,selectedNode:e,hideNodeAction:e.isHub})]},n.packageName))]})}function Mt({addon:e,installing:n,onInstall:r}){let{t:i}=q();return t(`div`,{className:`flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors`,children:[a(`div`,{className:`w-6 h-6 rounded-md bg-primary/10 flex items-center justify-center text-primary text-[9px] font-bold shrink-0`,children:e.name.replace(`@camstack/addon-`,``).charAt(0).toUpperCase()}),t(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[a(`span`,{className:`text-[11px] font-semibold break-words`,children:e.name.replace(/^@camstack\/(addon-)?/,``)}),t(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`v`,e.version]})]}),a(`div`,{className:`font-mono text-[9px] text-foreground-subtle/80 truncate`,children:e.name}),e.description&&a(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.description})]}),e.installed?a(me,{variant:`success`,icon:a(w,{className:`h-3 w-3`}),children:e.installedVersion??i(`system.capabilityCatalog.installed`,`Installed`)}):t(j,{size:`sm`,onClick:()=>r(e),disabled:n,className:`shrink-0`,children:[n?a(v,{className:`h-3 w-3 animate-spin`}):a(re,{className:`h-3 w-3`}),i(`system.capabilityCatalog.install`,`Install`)]})]})}function Nt({capability:e,installing:n,onInstall:r}){let{t:i}=q(),{data:o,isPending:s,isError:c}=z({capability:e}),l;if(c)l=a(`div`,{className:`px-3 py-2 text-xs text-danger`,children:i(`system.capabilityCatalog.couldNotSearchTheNpm`,`Could not search the npm catalog right now. Try again in a moment.`)});else if(s||o===void 0)l=t(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-foreground-subtle`,children:[a(v,{className:`h-3 w-3 animate-spin`}),i(`system.capabilityCatalog.searchingTheNpmCatalog`,`Searching the npm catalog…`)]});else{let t=o.filter(e=>!e.installed);l=t.length===0?a(`div`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:o.length===0?i(`system.capabilityCatalog.noPublishedAddonDeclaresThe`,`No published addon declares the "{{capability}}" capability.`,{capability:e}):i(`system.capabilityCatalog.everyPublishedAddonThatDeclares`,`Every published addon that declares "{{capability}}" is already installed.`,{capability:e})}):a(`div`,{className:`divide-y divide-border`,children:t.map(e=>a(Mt,{addon:e,installing:n,onInstall:r},e.name))})}return t(`section`,{className:`rounded-md border border-border bg-surface overflow-hidden`,"aria-label":i(`system.capabilityCatalog.availableToInstall`,`Available to install`),children:[a(`h2`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:i(`system.capabilityCatalog.availableToInstall`,`Available to install`)}),l]})}c();function Pt(e){return e===`npm`||e===`dev`?e:null}var Ft=`rounded-full border border-primary bg-primary/10 px-2 py-0.5 text-[10px] text-foreground`,It=`rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-muted hover:bg-surface-hover`,Lt=[{seconds:900,label:`15m`},{seconds:3600,label:`1h`},{seconds:21600,label:`6h`},{seconds:43200,label:`12h`},{seconds:86400,label:`24h`}],Rt={id:`hub`,name:`Hub`,isHub:!0,isOnline:!0};function zt(e,t){let n=e??`hub-only`;return n===`any-node`?!0:n===`hub-only`?t:!t}function Bt(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 Ht(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 Ut({addons:c,clusterStatus:u,selectedNode:d,onRefresh:f,listPhase:p}){let{t:m}=q(),h=l(),[_,b]=s(``),[x,C]=s(!1),w=e(_),[T,ee]=s(!1),ne=n(null);o(()=>{if(!T)return;let e=e=>{ne.current&&!ne.current.contains(e.target)&&ee(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[T]);let{data:D}=Te({nodeId:d.id}),O=r(()=>{let e=new Map;for(let t of D??[])t.blockedBy===void 0&&e.set(t.name,t.latestVersion);return e},[D]),ie=r(()=>{let e=new Map;for(let t of D??[]){let n=t.blockedBy?.find(e=>e.kind===`server-too-old`);n!==void 0&&e.set(t.name,{latestVersion:t.latestVersion,requiredServer:n.required})}return e},[D]),k=r(()=>(D??[]).filter(e=>!e.isSystem&&e.blockedBy===void 0).length,[D]),[A,ae]=s(()=>new Set),[oe,se]=s(()=>new Map),ce=i(e=>{ae(t=>new Set(t).add(e))},[]),ue=i(e=>{ae(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),M=i((e,t)=>{se(n=>new Map(n).set(e,t))},[]),de=i(e=>{se(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),N=be({onMutate:e=>{ce(e.name),de(e.name)},onSuccess:(e,t)=>{ue(t.name);let n=e;if(n&&n.success===!1){M(t.name,n.error??`Update failed (no error message returned by server)`);return}h.invalidateQueries({queryKey:[[`addons`]]}),h.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]})},onError:(e,t)=>{ue(t.name),M(t.name,e instanceof Error?e.message:String(e))}}),pe=qe(),me=n(new Set);o(()=>{let e=new Set;for(let[t,n]of pe)Ge(n)&&e.add(t);let t=[...me.current].some(t=>!e.has(t));me.current=e,t&&(h.invalidateQueries({queryKey:[[`addons`]]}),h.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[pe,h]);let{data:P}=le(void 0),ge=he({onSuccess:()=>{h.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),I=Ae({onSuccess:()=>{h.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:L,isFetching:ve}=z({query:w||void 0},{enabled:T}),R=V(),{data:B}=_e(void 0),ye=B?.requestedAt,[H,xe]=s(null),[U,W]=s(!1);o(()=>{if(B?.kind===`framework-bulk-update`&&B.requestedAt!==H){xe(B.requestedAt),W(!0);let e=window.setTimeout(()=>W(!1),6e3);return()=>window.clearTimeout(e)}},[ye,H,B]),te();let Se=i(async()=>{let e=(D??[]).filter(e=>!e.isSystem&&e.blockedBy===void 0);if(e.length!==0){if(!d.isHub){for(let t of e)await N.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,N]),[Ce,G]=s(null),[we,Ee]=s(null),De=e=>{Ee(null),G(e)},ke=fe({onSuccess:()=>{G(null),Ee(null),h.invalidateQueries({queryKey:[[`addons`]]}),h.invalidateQueries({queryKey:[[`addonPages`]]}),h.invalidateQueries({queryKey:[[`capabilities`]]}),h.invalidateQueries({queryKey:[[`integrations`]]})},onError:e=>{Ee(e instanceof Error?e.message:`Install failed`)}}),[K,je]=s(`type`),[Me,Pe]=s(()=>typeof window>`u`?`grouped`:window.localStorage.getItem(`camstack.addons.viewMode`)===`flat`?`flat`:`grouped`),Fe=e=>{Pe(e),typeof window<`u`&&window.localStorage.setItem(`camstack.addons.viewMode`,e)},[J,Y]=Ne(),X=J.get(`capability`),Ve=J.get(`updatable`)===`1`,Ue=J.get(`error`)===`1`,Z=Pt(J.get(`source`)),Q=Ie(J.get(Re))===`integration`,{data:We}=F(void 0,{enabled:Q}),Ke=r(()=>We===void 0?null:new Set(We.map(e=>e.addonId)),[We]),Je=i(e=>{let t=new URLSearchParams(J);e?t.set(Re,`integration`):t.delete(Re),Y(t,{replace:!0})},[J,Y]),Ye=i(e=>{let t=new URLSearchParams(J);e?t.set(`updatable`,`1`):t.delete(`updatable`),Y(t,{replace:!0})},[J,Y]),Xe=i(e=>{let t=new URLSearchParams(J);e?t.set(`error`,`1`):t.delete(`error`),Y(t,{replace:!0})},[J,Y]),Ze=i(e=>{let t=new URLSearchParams(J);e===null?t.delete(`source`):t.set(`source`,e),Y(t,{replace:!0})},[J,Y]),Qe=r(()=>c.filter(e=>He(e.process)!==null).length,[c]),$e=r(()=>{let e=c.filter(e=>!ze(e.manifest.packageName));return d.isHub||(e=e.filter(e=>zt(e.placement,d.isHub))),X&&(e=e.filter(e=>(e.manifest.capabilities??[]).some(e=>(typeof e==`string`?e:e.name)===X))),Q&&(e=[...Le(e,Ke)]),Ve&&(e=e.filter(e=>{let t=e.manifest.packageName;return t!==void 0&&O.has(t)})),Z!==null&&(e=e.filter(e=>Bt(e.installSource)===Z)),Ue&&(e=e.filter(e=>He(e.process)!==null)),e},[c,d.isHub,X,Ve,Z,Ue,Q,Ke,O]),et=()=>{let e=new URLSearchParams(J);e.delete(`capability`),Y(e,{replace:!0})},tt=Me===`flat`?$e:Ht($e),nt=r(()=>{let e=[...tt];switch(K){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},[tt,K]);return t(`div`,{className:`space-y-3`,children:[a(Be,{open:x,onOpenChange:C}),[...oe.entries()].map(([e,n])=>a(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-2.5 py-1.5 text-[11px]`,children:t(`div`,{className:`flex items-start justify-between gap-3`,children:[t(`div`,{className:`space-y-0.5`,children:[a(`div`,{className:`font-medium text-danger`,children:m(`systemPage.addons.updateFailed`,{name:e})}),a(`div`,{className:`text-foreground-subtle font-mono`,children:n})]}),a(j,{variant:`unstyled`,type:`button`,onClick:()=>de(e),className:`text-foreground-subtle hover:text-foreground text-[10px]`,children:m(`common.dismiss`)})]})},e)),t(`div`,{className:`flex items-center gap-x-2 gap-y-1.5 flex-wrap`,children:[t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:m(`admin.system.addons.sort`,`Sort:`)}),t(E,{wrapperClassName:`inline-block w-auto`,value:K,onChange:e=>je(e.target.value),children:[a(`option`,{value:`type`,children:m(`admin.system.addons.bundlesFirst`,`Bundles first`)}),a(`option`,{value:`name`,children:m(`admin.system.addons.name`,`Name`)}),a(`option`,{value:`source`,children:m(`admin.system.addons.installSource`,`Install source`)})]})]}),t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:m(`admin.system.addons.view`,`View:`)}),a(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`grouped`,`flat`].map(e=>a(j,{variant:`unstyled`,type:`button`,onClick:()=>Fe(e),className:`px-2 py-1 transition-colors capitalize ${Me===e?`bg-primary/10 text-primary`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`}`,title:e===`grouped`?m(`admin.system.addons.groupMultiAddonPackagesInto`,`Group multi-addon packages into a bundle card`):m(`admin.system.addons.showEveryAddonAsIts`,`Show every addon as its own card`),children:e},e))})]}),d.isHub&&t(`div`,{className:`flex items-center gap-1.5`,children:[a(S,{className:`h-3 w-3 text-foreground-subtle`}),a(`span`,{className:`text-[10px] text-foreground-subtle`,children:m(`admin.system.addons.autoUpdate`,`Auto-Update:`)}),a(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`off`,`latest`,`beta`].map(e=>a(j,{variant:`unstyled`,type:`button`,onClick:()=>ge.mutate({channel:e}),disabled:ge.isPending,className:`px-2 py-1 transition-colors capitalize ${P?.channel===e?e===`off`?`bg-gray-700 text-gray-200`:e===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${e===`off`?``:`border-l border-border`}`,children:e},e))})]}),d.isHub&&t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:m(`admin.system.addons.checkEvery`,`Check every:`)}),a(E,{wrapperClassName:`inline-block w-auto`,className:`font-medium text-foreground-subtle`,value:P?.updateCheckIntervalSeconds??21600,disabled:I.isPending||P===void 0,onChange:e=>{P!==void 0&&I.mutate({channel:P.channel,updateCheckIntervalSeconds:Number(e.target.value)})},children:Lt.map(e=>a(`option`,{value:e.seconds,children:e.label},e.seconds))})]}),k>0&&t(j,{variant:`unstyled`,type:`button`,onClick:()=>void Se(),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?a(v,{className:`w-3 h-3 animate-spin`}):a(re,{className:`w-3 h-3`}),R.isPending?m(`admin.system.addons.updating`,`Updating…`):m(`admin.system.addons.updateAll`,`Update All ({{nonSystemUpdateCount}})`,{nonSystemUpdateCount:k})]})]}),t(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`group`,"aria-label":m(`admin.system.addons.filterInstalledAddons`,`Filter installed addons`),children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:m(`admin.system.addons.filter`,`Filter:`)}),[{id:`integrations`,label:m(`admin.system.addons.integrations`,`Integrations`),pressed:Q,toggle:()=>Je(!Q)},{id:`updatable`,label:m(`admin.system.addons.updatable`,`Updatable`),pressed:Ve,toggle:()=>Ye(!Ve)},{id:`error`,label:m(`admin.system.addons.inError`,`In error ({{count}})`,{count:Qe}),pressed:Ue,toggle:()=>Xe(!Ue)},{id:`npm`,label:`npm`,pressed:Z===`npm`,toggle:()=>Ze(Z===`npm`?null:`npm`)},{id:`dev`,label:m(`admin.system.addons.dev`,`Dev`),pressed:Z===`dev`,toggle:()=>Ze(Z===`dev`?null:`dev`)}].map(e=>a(j,{variant:`unstyled`,type:`button`,"aria-pressed":e.pressed,onClick:e.toggle,className:e.pressed?Ft:It,children:e.label},e.id))]}),t(`div`,{className:`flex flex-col gap-1.5 sm:flex-row sm:items-center sm:gap-2`,children:[t(`div`,{className:`relative flex-1 min-w-0 sm:min-w-[200px]`,ref:ne,children:[a(Oe,{type:`text`,searchHotkey:!0,value:_,onChange:e=>{b(e.target.value),ee(!0)},onFocus:()=>ee(!0),placeholder:m(`admin.system.addons.searchAddonsOnNpm`,`Search addons on npm...`),"aria-label":m(`admin.system.addons.searchAddonsOnNpm2`,`Search addons on npm`),disabled:R.isPending,leftSlot:a(g,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),rightSlot:ve?a(v,{className:`h-3 w-3 animate-spin`}):void 0}),T&&L&&L.length>0&&t(`div`,{className:`absolute left-0 right-0 top-full mt-1 z-40 rounded-md border border-border bg-surface shadow-xl overflow-hidden`,children:[L.length>0&&a(`div`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:m(`systemPage.addons.npmResults`,{count:L.length})}),L&&L.length>0&&a(`div`,{className:`max-h-72 overflow-auto divide-y divide-border`,children:L.map(e=>a(Mt,{addon:e,installing:ke.isPending,onInstall:e=>De({name:e.name,version:e.version,description:e.description})},e.name))})]})]}),a(yt,{onUploadSuccess:()=>{h.invalidateQueries({queryKey:[[`addons`]]}),f()}})]}),X&&t(`div`,{className:`flex items-center gap-2 px-2.5 py-1.5 rounded-md bg-primary/10 border border-primary/30 text-xs`,children:[a(`span`,{className:`text-foreground-subtle`,children:m(`admin.system.addons.filteringByCapability`,`Filtering by capability:`)}),a(`span`,{className:`font-mono text-primary font-semibold`,children:X}),a(j,{variant:`unstyled`,type:`button`,onClick:et,className:`ml-auto text-xs text-foreground-subtle hover:text-foreground underline`,children:m(`admin.system.addons.clear`,`Clear`)})]}),X&&a(Nt,{capability:X,installing:ke.isPending,onInstall:e=>De({name:e.name,version:e.version,description:e.description})}),X&&$e.length>0&&a(`h2`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:m(`admin.system.addons.installed`,`Installed`)}),U&&t(`div`,{className:`fixed top-[calc(env(safe-area-inset-top)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 flex items-start gap-2 px-3 py-2.5 rounded-md border border-green-500/30 bg-green-500/10 shadow-lg max-w-sm pointer-events-auto`,children:[a(y,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),t(`div`,{children:[a(`div`,{className:`text-[11px] font-semibold text-foreground`,children:m(`admin.system.addons.bulkUpdateCompleted`,`Bulk update completed`)}),a(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:m(`admin.system.addons.systemPackagesUpdatedHubRestarted`,`System packages updated — hub restarted successfully.`)})]})]}),p===`pending`&&t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[a(v,{className:`h-3 w-3 animate-spin`}),m(`admin.system.addons.loadingInstalled`,`Loading installed addons…`)]}),p===`error`&&a(`div`,{className:`text-xs text-danger`,children:m(`admin.system.addons.failedToLoadAddons`,`Failed to load addons`)}),p===`ready`&&$e.length===0&&a(`div`,{className:`text-xs text-foreground-subtle`,children:c.length===0?m(`admin.system.addons.noAddonsInstalled`,`No addons installed`):X?m(`admin.system.addons.noInstalledAddonDeclaresThe`,`No installed addon declares the "{{capabilityFilter}}" capability. Any addon you can install appears under "Available to install" above.`,{capabilityFilter:X}):m(`admin.system.addons.noAddonsCompatibleWithPlacement`,`No addons compatible with {{name}} (placement filter active)`,{name:d.name})}),a(`div`,{className:`space-y-1.5`,children:p===`ready`&&nt.map(e=>{let t=$(e)?e.bundle.packageName:e.manifest.packageName,n=O.get(t),r=ie.get(t),i=$(e)?e.representative:e,o=n?e=>N.mutate({name:t,version:e,nodeId:d.id}):void 0,s=pe.get(t)??null,c=s!==null&&Ge(s);return a(_t,{addon:i,clusterStatus:u?.[i.manifest.id],bundle:$(e)?e.bundle:void 0,availableUpdate:n,...r===void 0?{}:{blockedUpdate:r},...r===void 0?{}:{onUpdateServer:()=>C(!0)},isUpdating:A.has(t)||c,jobProgress:s,onUpdate:o,disabledByBulk:R.isPending,selectedNode:d},$(e)?t:e.manifest.id)})}),Ce!==null&&a(kt,{target:Ce,installing:ke.isPending,installError:we,onClose:()=>G(null),onInstall:(e,t)=>ke.mutate({packageName:e,version:t})})]})}function Wt(){let{t:e}=q(),r=l(),{data:i}=oe(void 0),{nodes:s}=N(),{selection:c,selectNode:u,requestedNodeId:d}=Ve(s.length>0?s:[Rt]),f=c.node??Rt,p=f.id,m=s.length>0?c.staleNodeId:null,{data:h,isLoading:g,isError:_}=ae({nodeId:p}),v=M(),y=ye(),b=v.isPending||y.isPending,x=async()=>{await v.mutateAsync({nodeId:p}),await y.mutateAsync(),r.invalidateQueries({queryKey:[[`addons`]]})},C=n(v);C.current=v;let w=n(d??`hub`);o(()=>{C.current.mutate({nodeId:w.current})},[]);let T=(h??[]).map(Vt).filter(e=>e!==null);return t(Fe,{children:[t(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[a(Ee,{selectedNodeId:p,onSelect:u}),t(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[!g&&!_&&a(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium`,children:e(`systemPage.addons.installedCount`,{count:T.length})}),t(j,{variant:`unstyled`,type:`button`,onClick:()=>void x(),disabled:b,className:`inline-flex items-center gap-1 px-2 py-1 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,title:e(`admin.system.addons.reFetchAddonsCheckNpm`,`Re-fetch addons + check npm for new versions`),children:[a(S,{className:`w-3 h-3 ${b?`animate-spin`:``}`}),e(`admin.system.addons.checkForUpdates`,`Check for updates`)]})]})]}),a(X,{staleNodeId:m,shownNodeName:f.name}),a(jt,{selectedNode:f}),a(Ut,{addons:T,clusterStatus:i,selectedNode:f,onRefresh:()=>void x(),listPhase:g?`pending`:_?`error`:`ready`})]})}export{Wt as AddonsPage};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,o as l,t as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{D as d,G as f,L as p,Mn as m,Or as h,Q as g,St as _,Yi as v,Yr as y,Yt as b,cn as x,gt as S,jn as C,pn as w,ta as T,ui as E,ut as D}from"./player-overlays-DpoShe47.js";import{yi as O}from"./client-Dzzkm60X.js";import{n as k,t as A}from"./send-D_NAoo3n.js";import{t as j}from"./message-square-plus-_aGccjyj.js";import{$d as M,H as ee,Io as N,Mf as P,Oi as F,Ud as I,Un as te,Vd as L,Vn as R,Wd as z,Wn as B,at as V,cf as ne,di as H,gr as re,ii as U,ki as W,sf as ie}from"./src-5h33Ujaz.js";import{t as G}from"./i18n-DWUEvjgE.js";import{t as K}from"./useTranslation-BJr-n0es.js";import"./mount-DQQApnAQ.js";import{Qr as q,X as J,x as Y}from"./index-BK_1kQTJ.js";import{t as X}from"./AdminSectionedPage-L4C7Phdd.js";import{t as ae}from"./AdminPage-BoBZR6uA.js";import{t as oe}from"./InstancesTable-pH3oYjHd.js";import{a as se,c as ce,d as le,f as ue,i as de,l as Z,n as fe,o as pe,p as me,r as he,s as ge,t as _e,u as ve}from"./ai-page.helpers-CQPhp13c.js";c();function ye(){let{t}=K(),n=S(),r=W({functionCap:`llm`}).data??[],a=s({queryKey:fe,queryFn:()=>n.trpcClient.llm.getDefaults.query({})}),o=u({mutationFn:e=>n.trpcClient.llm.setDefault.mutate({selector:{purpose:e.purpose},profileId:e.profileId}),onSuccess:()=>{a.refetch()}}),c=e=>(a.data??[]).find(t=>`purpose`in t.selector&&t.selector.purpose===e)?.profileId??``,l=e=>e===`vision`?t(`ai.defaultVision`,`Default vision profile`):t(`ai.defaultText`,`Default text profile`);return i(R,{headingId:`ai-profiles-defaults`,title:t(`ai.defaultsTitle`,`Defaults`),children:i(`div`,{className:`${d} grid gap-4 sm:grid-cols-2`,children:he.map(({purpose:n,visionOnly:a})=>{let s=a?r.filter(Z):r,u=c(n),d=r.find(e=>e.id===u);return e(`div`,{children:[i(re,{className:`mb-1 block`,htmlFor:`llm-default-${n}`,children:l(n)}),i(D,{id:`llm-default-${n}`,"aria-label":l(n),value:u,onChange:e=>o.mutate({purpose:n,profileId:e.target.value===``?null:e.target.value}),options:[{value:``,label:t(`ai.none`,`None`)},...u!==``&&!s.some(e=>e.id===u)?[{value:u,label:d?.name??u}]:[],...s.map(e=>({value:e.id,label:ge(e)===``?e.name:`${e.name} · ${ge(e)}`}))]}),u!==``&&d===void 0&&i(`p`,{className:`mt-1 text-xs text-danger`,children:t(`ai.defaultMissing`,`This default names a profile that no longer exists.`)}),d!==void 0&&!d.enabled&&i(`p`,{className:`mt-1 text-xs text-warning`,children:t(`ai.defaultDisabled`,`This default profile is disabled — callers resolve to no profile.`)}),o.error!=null&&i(`p`,{className:`mt-1 text-xs text-danger`,children:String(o.error)})]},n)})})})}var be=2e3;function Q(e){return G.t(`system.aiModelPicker.sizeGb`,{value:(e/1e9).toFixed(2)})}function xe(e){return e===null?``:e.model.kind===`catalog`?`catalog:${e.model.catalogId}`:e.model.kind===`path`?`node:${e.modelId}`:`custom`}function Se({nodeId:t,value:r,onChange:a}){let{t:c}=K(),l=S(),[d,f]=o(``),[p,g]=o(null),[_,v]=o(!1),y=s({queryKey:_e,queryFn:()=>l.trpcClient.llm.listModelCatalog.query({})}),b=s({queryKey:[`llm`,`listNodeModels`,t],queryFn:()=>l.trpcClient.llm.listNodeModels.query({nodeId:t})}),x=u({mutationFn:e=>l.trpcClient.llm.resolveModelRef.mutate(e),onSuccess:e=>{g(e),v(!1),e.ok&&a({model:e.model,modelId:e.label,supportsVision:e.purpose===`vision`})}}),C=u({mutationFn:e=>l.trpcClient.llm.installModel.mutate({nodeId:t,model:e}),onSuccess:()=>{v(!0),b.refetch()}}),w=s({queryKey:de,enabled:C.isPending,refetchInterval:C.isPending?be:!1,queryFn:()=>l.trpcClient.llm.listRuntimeNodes.query({})}).data?.find(e=>e.nodeId===t)?.status?.download,T=n(()=>{let e=(y.data??[]).map(e=>({value:`catalog:${e.id}`,label:`${e.label} · ${e.quantization} · ${Q(e.sizeBytes)}`})),n=(b.data??[]).filter(e=>e.catalogId===void 0&&e.path!==void 0).map(e=>({value:`node:${e.file}`,label:c(`ai.onNode`,`{{file}} · {{size}} · on {{node}}`,{file:e.file,size:Q(e.sizeBytes),node:t})})),r=p?.ok===!0?[{value:`custom`,label:`${p.label} · ${Q(p.totalBytes)}`}]:[];return[{value:``,label:c(`ai.selectModel`,`Select a model…`)},...e,...n,...r]},[y.data,b.data,p,t,c]),O=e=>{if(e===``){a(null);return}if(e===`custom`){if(p?.ok!==!0)return;a({model:p.model,modelId:p.label,supportsVision:p.purpose===`vision`});return}if(e.startsWith(`catalog:`)){let t=e.slice(8),n=y.data?.find(e=>e.id===t);a({model:{kind:`catalog`,catalogId:t},modelId:t,supportsVision:n?.purpose===`vision`});return}let t=e.slice(5),n=b.data?.find(e=>e.file===t);n?.path!==void 0&&a({model:{kind:`path`,path:n.path},modelId:t,supportsVision:!1})},k=e=>{d.trim()!==``&&x.mutate({ref:d.trim(),...e===void 0?{}:{maxBytes:e}})};return e(`div`,{className:`space-y-3`,children:[i(V,{label:c(`ai.model`,`Model`),required:!0,children:i(D,{id:`ai-model`,"aria-label":c(`ai.model`,`Model`),value:xe(r),options:T,onChange:e=>O(e.target.value)})}),i(V,{label:c(`ai.hfTitle`,`Add a model from Hugging Face`),description:c(`ai.hfHint`,`Paste a GGUF file URL, or type org/repo — add :QUANT (e.g. unsloth/Qwen3.6-35B-A3B-GGUF:UD-Q4_K_M) when the repo publishes more than one quantization.`),children:e(`div`,{className:`flex gap-2`,children:[i(ie,{"aria-label":c(`ai.hfTitle`,`Add a model from Hugging Face`),value:d,onChange:e=>f(e.target.value),placeholder:c(`system.aiModelPicker.unslothQwen3635bA3b`,`unsloth/Qwen3.6-35B-A3B-GGUF:UD-Q4_K_M`),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),k())}}),e(M,{size:`sm`,variant:`secondary`,type:`button`,disabled:d.trim()===``||x.isPending,onClick:()=>k(),children:[x.isPending?i(h,{className:`h-3.5 w-3.5 animate-spin`}):i(m,{className:`h-3.5 w-3.5`}),c(`ai.hfCheck`,`Check`)]})]})}),x.isError&&i(L,{message:x.error instanceof Error?x.error.message:c(`common.error`,`Error`)}),p?.ok===!1&&i(L,{message:p.message,action:e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(p.candidates??[]).map(e=>i(M,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>{let t=`${d.trim().split(`:`)[0]??``}:${e}`;f(t),x.mutate({ref:t})},children:e},e)),p.requiredBytes!==void 0&&i(M,{size:`sm`,variant:`secondary`,type:`button`,onClick:()=>k(p.requiredBytes),children:c(`ai.hfOverride`,`Install anyway ({{size}})`,{size:Q(p.requiredBytes)})})]})}),p?.ok===!0&&e(`div`,{className:`space-y-2 rounded-md border border-border bg-surface p-2.5`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[i(`span`,{className:`text-[11px] font-medium text-foreground`,children:p.label}),i(I,{variant:p.purpose===`vision`?`info`:`default`,children:p.purpose}),i(I,{variant:`default`,children:Q(p.totalBytes)})]}),p.extraFilenames.length>0&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:c(`ai.hfExtras`,`Also downloads: {{files}}`,{files:p.extraFilenames.join(`, `)})}),e(`div`,{className:`flex items-center gap-2`,children:[e(M,{size:`sm`,type:`button`,disabled:C.isPending||_,onClick:()=>C.mutate(p.model),children:[C.isPending?i(h,{className:`h-3.5 w-3.5 animate-spin`}):i(E,{className:`h-3.5 w-3.5`}),_?c(`ai.hfInstalled`,`Downloaded`):c(`ai.hfInstall`,`Download to {{node}}`,{node:t})]}),w!==void 0&&i(`span`,{className:`text-[10px] text-foreground-subtle`,children:w.phase===`verifying`?c(`ai.hfVerifying`,`verifying {{file}}…`,{file:w.file}):c(`ai.hfDownloading`,`{{file}} ({{index}}/{{count}}) — {{done}}{{total}}`,{file:w.file,index:w.fileIndex,count:w.fileCount,done:Q(w.downloadedBytes),total:w.totalBytes===void 0?``:` / ${Q(w.totalBytes)}`})})]}),C.isError&&i(L,{message:C.error instanceof Error?C.error.message:c(`common.error`,`Error`)})]})]})}function Ce({value:t,onChange:n}){let{t:r}=K(),a=S(),o=s({queryKey:de,queryFn:()=>a.trpcClient.llm.listRuntimeNodes.query({})});return e(`div`,{children:[i(`div`,{className:`mb-1 text-[11px] font-medium text-foreground`,children:r(`ai.appleNode`,`Mac that runs it`)}),o.isPending&&e(`div`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(h,{className:`h-3.5 w-3.5 animate-spin`}),r(`ai.appleAsking`,`Asking the nodes…`)]}),o.isError&&i(`p`,{className:`text-[11px] text-danger`,children:o.error instanceof Error?o.error.message:r(`ai.runtimesFailed`,`Failed to read runtime nodes`)}),o.isSuccess&&o.data.length===0&&i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}),o.isSuccess&&o.data.length>0&&i(`div`,{role:`radiogroup`,className:`space-y-1.5`,children:o.data.map(a=>{let o=pe(a),s=o.nodeId===t;return e(M,{variant:`unstyled`,type:`button`,role:`radio`,"aria-checked":s,disabled:!o.selectable&&!s,onClick:()=>n(o.nodeId),className:`flex w-full items-center justify-between gap-2 rounded-md border px-3 py-2 text-left text-xs transition-colors disabled:cursor-not-allowed disabled:opacity-60 ${s?`border-primary bg-primary/10`:`border-border bg-surface hover:bg-surface-hover`}`,children:[e(`span`,{className:`min-w-0`,children:[i(`span`,{className:`block font-medium text-foreground`,children:o.nodeId}),o.detail!==null&&i(`span`,{className:`block truncate text-[10px] text-foreground-subtle`,children:o.detail})]}),i(I,{variant:o.tone,children:r(o.labelKey,o.labelDefault)})]},o.nodeId)})}),i(`p`,{className:`mt-1.5 text-[10px] leading-relaxed text-foreground-subtle`,children:r(`ai.appleHint`,`Text only for now — notification titles and summaries. Apple refuses prompts framed as surveillance; when it does, the next profile in the chain answers instead.`)})]})}function we(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function Te({providerConfig:e,onProviderConfigChange:t}){return i(Ce,{value:we(e,`nodeId`),onChange:n=>t({...e,nodeId:n})})}function Ee({providerConfig:e,onProviderConfigChange:t,model:n,onModelChange:r}){let a=O.safeParse(e.model),o=a.success?{model:a.data,modelId:n.id,supportsVision:n.supportsVision}:null;return i(Se,{nodeId:we(e,`nodeId`)??`hub`,value:o,onChange:n=>{if(n===null){let{model:n,...i}=e;t(i),r({id:``,supportsVision:!1});return}t({...e,model:n.model}),r({id:n.modelId,supportsVision:n.supportsVision})}})}var De=new Map([[`ai/apple-node`,Te],[`ai/managed-model`,Ee]]);function Oe(e){return De.get(e)??null}c();function $(e,t){let n=e[t];return typeof n==`string`?n:``}function ke({row:a}){let{t:c}=K(),d=S(),f=l(),p=s({queryKey:n(()=>[J,a.addonId,`ai-lead`,a.id],[a]),queryFn:async()=>{let e=d.trpcClient.integrationInstances,[t,n]=await Promise.all([e.describe.query({addonId:a.addonId}),e.getInstance.query({addonId:a.addonId,id:a.id})]);return{description:t,instance:n}}}),[m,g]=o({}),_=t({}),v=t(!1),y=u({mutationFn:e=>d.trpcClient.integrationInstances.updateInstance.mutate({addonId:a.addonId,id:a.id,values:e}),onSuccess:async()=>{await f.invalidateQueries({queryKey:[J]}),await f.invalidateQueries({queryKey:[F]}),g({})}}),b=r(e=>{_.current={..._.current,...e},g(t=>({...t,...e})),!v.current&&(v.current=!0,queueMicrotask(()=>{let e=_.current;_.current={},v.current=!1,y.mutate(e)}))},[y]),x=p.data?.description.kinds?.find(e=>e.id===a.kindId),C=p.data?.instance?.formValues,w=n(()=>({...C,...m}),[C,m]),T=x?.widgets??[],E=T.some(e=>e.placement===`model`),O=n(()=>({...$(w,`nodeId`)===``?{}:{nodeId:$(w,`nodeId`)},...typeof w.modelRef==`object`&&w.modelRef!==null?{model:w.modelRef}:{}}),[w]),k={id:$(w,`model`),supportsVision:w.supportsVision===!0},A=u({mutationFn:()=>d.trpcClient.llm.listModels.mutate({addonId:a.addonId,kind:a.kindId??``,profileId:a.id})});if(p.isPending)return null;if(p.isError)return i(L,{variant:`warning`,message:p.error.message});let j=A.data?.ok===!0?A.data.models:[],ee=A.data?.ok===!1?A.data:null,N=e=>{let t=j.find(t=>t.id===e);b({model:e,...t?.features?.vision===void 0?{}:{supportsVision:t.features.vision}})};return e(`div`,{className:`space-y-3`,"data-testid":`ai-profile-lead`,children:[T.map(({id:e})=>{let t=Oe(e);return t===null?i(L,{variant:`warning`,message:c(`ai.unknownWidget`,`This provider needs an editor part this build does not have ({{id}}).`,{id:e})},e):i(t,{providerConfig:O,onProviderConfigChange:e=>b({...$(e,`nodeId`)===$(O,`nodeId`)?{}:{nodeId:$(e,`nodeId`)},...e.model!==void 0&&e.model!==O.model?{modelRef:e.model}:{}}),model:k,onModelChange:e=>b({model:e.id,supportsVision:e.supportsVision})},e)}),!E&&e(V,{label:c(`ai.model`,`Model`),children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(M,{size:`sm`,variant:`secondary`,type:`button`,disabled:A.isPending,onClick:()=>A.mutate(),children:[A.isPending?i(h,{className:`h-3.5 w-3.5 animate-spin`}):null,c(`ai.loadModels`,`Load models`)]}),j.length>0&&i(D,{"aria-label":c(`ai.model`,`Model`),value:k.id,onChange:e=>N(e.target.value),options:[...j.some(e=>e.id===k.id)||k.id===``?[]:[{value:k.id,label:k.id}],...j.map(e=>({value:e.id,label:e.label??e.id}))]})]}),ee!==null&&i(`p`,{className:`mt-1 text-xs text-danger`,children:ee.message}),A.isError&&i(`p`,{className:`mt-1 text-xs text-danger`,children:A.error.message})]}),y.isError&&i(L,{variant:`warning`,message:y.error.message})]})}c();var Ae=5e3;function je(e){return G.t(`system.aiRuntimes.sizeGb`,{value:(e/1e9).toFixed(1)})}function Me(){let{t}=K(),r=S(),a=s({queryKey:de,refetchInterval:Ae,queryFn:()=>r.trpcClient.llm.listRuntimeNodes.query({})}),o=n(()=>[{key:`node`,header:t(`ai.colNode`,`Node`),render:e=>i(`span`,{className:`font-medium text-foreground`,children:e.nodeId})},{key:`state`,header:t(`ai.colState`,`State`),nowrap:!0,render:n=>e(`span`,{className:`flex items-center gap-1.5`,children:[i(I,{variant:me(n),children:t(ue(n))}),n.status?.downloadProgress!==void 0&&i(I,{variant:`info`,children:`${String(Math.round(n.status.downloadProgress*100))}%`})]})},{key:`model`,header:t(`ai.colModel`,`Model`),render:e=>i(`span`,{className:`text-foreground`,children:e.status?.modelId??`—`})},{key:`disk`,header:t(`ai.colDisk`,`On disk`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums text-foreground-muted`,children:e.disk===void 0?`—`:je(e.disk.modelsBytes)})},{key:`features`,header:t(`ai.colFeature`,`Feature`),render:n=>{let r=le(n);if(r.length===0)return i(`span`,{className:`text-foreground-subtle`,children:`—`});let a=r.flatMap(e=>e.detail===null?[]:[e.detail]);return e(`span`,{className:`flex flex-col items-start gap-0.5`,children:[i(`span`,{className:`flex flex-wrap gap-1`,children:r.map(e=>i(I,{variant:e.tone,children:t(e.labelKey)},e.id))}),a.length>0&&i(`span`,{className:`text-foreground-subtle`,children:a.join(` · `)})]})}},{key:`error`,header:t(`ai.colError`,`Error`),render:e=>e.error===void 0?i(`span`,{className:`text-foreground-subtle`,children:`—`}):i(`span`,{className:`text-danger`,children:e.error})}],[t]),c=a.data??[];return i(R,{headingId:`ai-runtimes-list`,title:t(`ai.runtimesList`,`Nodes`),children:a.isPending?e(`div`,{className:`${d} space-y-2`,"data-testid":`ai-runtimes-loading`,children:[i(z,{className:`h-8 w-full`}),i(z,{className:`h-8 w-full`})]}):a.isError?i(`div`,{className:d,children:i(L,{title:t(`ai.runtimesFailed`,`Failed to read runtime nodes`),message:a.error instanceof Error?a.error.message:t(`common.error`,`Error`),onRetry:()=>void a.refetch()})}):c.length===0?i(U,{icon:C,title:t(`ai.noRuntimesTitle`,`No runtime nodes`),description:t(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}):i(te,{columns:o,rows:c,rowKey:e=>e.nodeId,minWidthPx:760,bordered:!1,maxBodyHeight:B})})}var Ne=g(`/addon/ai/test-chat`),Pe=g(`/addon/ai/test-chat/chats`),Fe=6e5;function Ie(e){let t=e.firstTokenTimeoutMs;if(!(typeof t!=`number`||!Number.isFinite(t)||t<=0))return Math.min(Math.round(t),Fe)}function Le(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Re(e){if(!Le(e))return null;let t=e.kind;return t!==`snapshot`&&t!==`track`||typeof e.mimeType!=`string`||typeof e.sizeBytes!=`number`?null:{kind:t,mimeType:e.mimeType,sizeBytes:e.sizeBytes,...typeof e.mediaKind==`string`?{mediaKind:e.mediaKind}:{},...typeof e.capturedAt==`number`?{capturedAt:e.capturedAt}:{},...typeof e.thumbnailBase64==`string`?{thumbnailBase64:e.thumbnailBase64}:{}}}var ze=[`resolving-image`,`connecting`,`first-token-wait`,`streaming`];function Be(e){let t;try{t=JSON.parse(e)}catch{return null}if(!Le(t))return null;switch(t.kind){case`status`:{let e=ze.find(e=>e===t.phase);return e===void 0?null:{kind:`status`,phase:e}}case`meta`:return typeof t.profileName!=`string`||typeof t.model!=`string`?null:{kind:`meta`,profileName:t.profileName,model:t.model,mediaSent:Re(t.mediaSent),streamed:t.streamed===!0,firstTokenTimeoutMs:typeof t.firstTokenTimeoutMs==`number`?t.firstTokenTimeoutMs:0};case`token`:return typeof t.text==`string`?{kind:`token`,text:t.text}:null;case`done`:return{kind:`done`,inputTokens:typeof t.inputTokens==`number`?t.inputTokens:0,outputTokens:typeof t.outputTokens==`number`?t.outputTokens:0,latencyMs:typeof t.latencyMs==`number`?t.latencyMs:0,truncated:t.truncated===!0,...typeof t.conversationId==`string`?{conversationId:t.conversationId}:{}};case`error`:return{kind:`error`,code:typeof t.code==`string`?t.code:`adapter-error`,message:typeof t.message==`string`?t.message:G.t(`helpers.aiTestChat.providerError`)};default:return null}}async function*Ve(e){let t=e.getReader(),n=new TextDecoder,r=``;try{for(;;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a=r.indexOf(`
|
|
2
|
-
`);for(;a>=0;){let e=r.slice(0,a).trim();if(r=r.slice(a+1),e.length>0){let t=Be(e);t!==null&&(yield t)}a=r.indexOf(`
|
|
3
|
-
`)}}let e=r.trim();if(e.length>0){let t=Be(e);t!==null&&(yield t)}}finally{t.releaseLock()}}function He(e){return e.filter(e=>e.failed!==!0&&e.content.length>0).map(e=>({role:e.role,content:e.content}))}function Ue(e){return e.thumbnailBase64===void 0||e.thumbnailBase64.length===0?null:`data:${e.mimeType};base64,${e.thumbnailBase64}`}function We(e){return e.messages.map((t,n)=>{let r=t.mediaSent??void 0;return{id:`${e.id}-${String(n)}`,role:t.role,content:t.content,...t.attachment===void 0?{}:{attachmentRef:t.attachment,attachmentKind:t.attachment.kind},...r===void 0?{}:{attachment:r}}})}function Ge(e){let t=e.sizeBytes<1024*1024?`${(e.sizeBytes/1024).toFixed(0)} KB`:`${(e.sizeBytes/(1024*1024)).toFixed(1)} MB`,n=[e.kind===`snapshot`?`camera snapshot`:`track best-shot`,t];return e.mediaKind!==void 0&&n.push(e.mediaKind),e.capturedAt!==void 0&&n.push(new Date(e.capturedAt).toLocaleTimeString()),n.join(` · `)}function Ke(e,t){switch(e){case`resolving-image`:return G.t(`helpers.aiTestChat.phaseImage`);case`connecting`:return G.t(`helpers.aiTestChat.phaseConnecting`);case`first-token-wait`:return t>0?G.t(`helpers.aiTestChat.phaseWaitUpTo`,{seconds:Math.round(t/1e3)}):G.t(`helpers.aiTestChat.phaseWait`);case`streaming`:return G.t(`helpers.aiTestChat.phaseAnswering`)}}c();var qe=[`pipelineAnalytics`,`listRecentTracks`,`ai-test`],Je=360*60*1e3,Ye=40,Xe=160,Ze={phase:`connecting`,firstTokenTimeoutMs:0,text:``,mediaSent:null};function Qe(){let{t:s}=K();S();let[c,l]=o(``),[u,f]=o(``),[m,h]=o(``),[g,y]=o([]),[C,w]=o(null),[E,O]=o(`none`),[k,N]=o(`throwaway`),[P,F]=o(null),[I,te]=o([]),[z,B]=o(null),[V,H]=o(null),U=t(null);a(()=>()=>U.current?.abort(),[]);let G=r(async()=>{let e=await fetch(Pe,{credentials:`same-origin`});e.ok&&te((await e.json()).chats??[])},[]);a(()=>{k===`persistent`&&G()},[k,G]);let q=W({functionCap:`llm`}),J=n(()=>(q.data??[]).filter(e=>e.enabled),[q.data]),Y=J.find(e=>e.id===c)??null,X=V!==null,ae=r(async(e,t)=>{let n=new AbortController;U.current=n,B(null);let r=Ie(Y===null?{}:ve(Y));H({...Ze,firstTokenTimeoutMs:r??0});let i=``,a=null,o,l=null,d=null,f;try{let s=await fetch(Ne,{method:`POST`,headers:{"content-type":`application/json`},credentials:`same-origin`,signal:n.signal,body:JSON.stringify({profileId:c,messages:e,...u.trim()===``?{}:{system:u.trim()},...t===void 0?{}:{attachment:t},...r===void 0?{}:{firstTokenTimeoutMs:r},...k===`persistent`?{persist:!0,...P===null?{}:{conversationId:P}}:{}})});if(!s.ok||s.body===null){let e=await s.text().catch(()=>``);throw Error(e.length>0?e:`HTTP ${String(s.status)}`)}for await(let e of Ve(s.body))switch(e.kind){case`status`:H(t=>({...t??Ze,phase:e.phase}));break;case`meta`:a=e.mediaSent,o=e.model,H(t=>({...t??Ze,firstTokenTimeoutMs:e.firstTokenTimeoutMs,mediaSent:e.mediaSent}));break;case`token`:i+=e.text,H(e=>({...e??Ze,text:i}));break;case`done`:d={outputTokens:e.outputTokens,latencyMs:e.latencyMs},f=e.conversationId;break;case`error`:l=`${e.code}: ${e.message}`;break}}catch(e){n.signal.aborted||B(e instanceof Error?e.message:s(`common.error`,`Error`))}finally{U.current=null,H(null)}f!==void 0&&(F(f),G());let p=n.signal.aborted&&i.length>0;l===null&&i.length===0&&!p||y(e=>[...e,{id:`a-${String(Date.now())}`,role:`assistant`,content:l??i,...l===null?{}:{failed:!0},...a===null?{}:{attachment:a},...o!==void 0&&l===null?{model:o}:{},...d===null?{}:d}])},[k,P,Y,c,G,u,s]),oe=r(()=>{let e=m.trim();if(e===``||c===``||X)return;let t={id:`u-${String(Date.now())}`,role:`user`,content:e,...C===null?{}:{attachmentLabel:C.label,attachmentKind:C.ref.kind}},n=[...g,t];y(n),h(``);let r=C?.ref;w(null),O(`none`),ae(k===`persistent`&&P!==null?[{role:`user`,content:e}]:He(n),r)},[k,P,m,C,c,ae,X,g]),se=()=>U.current?.abort(),ce=()=>{U.current?.abort(),y([]),w(null),h(``),B(null),H(null),F(null)},le=async e=>{U.current?.abort();let t=await fetch(`${Pe}/${e}`,{credentials:`same-origin`});if(!t.ok)return;let n=await t.json();F(e),y(We(n)),H(null),B(null)};return e(`div`,{className:p,children:[i(R,{headingId:`ai-test-setup`,title:s(`ai.testSetup`,`Setup`),children:e(`div`,{className:`${d} space-y-3`,children:[e(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[e(`div`,{children:[i(re,{className:`mb-1 block`,htmlFor:`ai-test-profile`,children:s(`ai.profile`,`Profile`)}),i(D,{id:`ai-test-profile`,value:c,onChange:e=>l(e.target.value),options:[{value:``,label:s(`ai.selectProfile`,`Select a profile…`)},...J.map(e=>({value:e.id,label:`${e.name} · ${ge(e)}${Z(e)?` · vision`:``}`}))]}),J.length===0&&!q.isLoading&&i(`p`,{className:`mt-1 text-xs text-foreground-subtle`,children:s(`ai.noEnabledProfiles`,`No enabled profile. Add one on the Profiles tab.`)})]}),e(`div`,{children:[i(re,{className:`mb-1 block`,htmlFor:`ai-test-system`,children:s(`ai.systemPrompt`,`System prompt (optional)`)}),i(ie,{id:`ai-test-system`,value:u,onChange:e=>f(e.target.value),placeholder:s(`ai.systemPlaceholder`,`Answer in one short sentence.`)})]})]}),i(ee,{label:s(`ai.chatMode`,`Conversation mode`),value:k,options:[{value:`throwaway`,label:s(`ai.throwawayMode`,`Throwaway`)},{value:`persistent`,label:s(`ai.saveConversation`,`Save conversation`)}],onChange:e=>{N(e),e===`throwaway`&&F(null)}}),k===`persistent`&&e(`div`,{className:`space-y-2`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:s(`ai.testSubtitlePersistent`,`Conversations are saved for you and can be reopened. Throwaway mode is still available.`)}),e(M,{size:`sm`,variant:`secondary`,type:`button`,onClick:ce,children:[i(j,{className:`h-3.5 w-3.5`}),s(`ai.newChat`,`New chat`)]}),I.length>0&&i(`div`,{className:`max-h-36 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:I.map(e=>i(`button`,{type:`button`,onClick:()=>void le(e.id),className:`flex w-full px-2.5 py-1.5 text-left text-xs hover:bg-surface-hover ${e.id===P?`bg-primary/10`:``}`,children:i(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:e.title})},e.id))})]}),i(`p`,{className:`text-xs text-foreground-subtle`,children:s(`ai.streamNote`,`The answer streams as the model produces it. A cold model can take a while to load — the status line says which phase it is in.`)}),Y!==null&&!Z(Y)&&i(`p`,{className:`text-xs text-warning`,children:s(`ai.notVision`,`This profile is not vision-capable — an attached image will be refused before anything is read.`)})]})}),z!==null&&i(L,{title:s(`ai.chatFailed`,`The test call failed`),message:z}),e(R,{headingId:`ai-test-conversation`,title:s(`ai.testConversation`,`Conversation`),actions:e(M,{size:`sm`,variant:`ghost`,type:`button`,disabled:g.length===0&&C===null,onClick:ce,children:[i(b,{className:`h-3.5 w-3.5`}),s(`ai.clearChat`,`Clear`)]}),children:[i($e,{turns:g,live:V}),e(`div`,{className:`${d} space-y-2 border-t border-border`,children:[C!==null&&e(`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`?i(v,{className:`h-3.5 w-3.5 text-foreground-subtle`}):i(T,{className:`h-3.5 w-3.5 text-foreground-subtle`}),i(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,children:C.label}),i(ne,{size:`sm`,variant:`ghost`,type:`button`,icon:_,"aria-label":s(`ai.removeAttachment`,`Remove attachment`),onClick:()=>w(null)})]}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(M,{size:`sm`,variant:E===`snapshot`?`primary`:`outline`,type:`button`,onClick:()=>O(E===`snapshot`?`none`:`snapshot`),children:[i(v,{className:`h-3.5 w-3.5`}),s(`ai.attachSnapshot`,`Camera snapshot`)]}),e(M,{size:`sm`,variant:E===`track`?`primary`:`outline`,type:`button`,onClick:()=>O(E===`track`?`none`:`track`),children:[i(T,{className:`h-3.5 w-3.5`}),s(`ai.attachTrack`,`Recent track`)]})]}),E===`snapshot`&&i(nt,{onPick:(e,t)=>{w({ref:{kind:`snapshot`,deviceId:e.id},label:s(`ai.snapshotOf`,`Snapshot of {{name}}`,{name:t})}),O(`none`)}}),E===`track`&&i(it,{onPick:(e,t)=>{w({ref:{kind:`track`,trackId:e.trackId,deviceId:e.deviceId},label:s(`ai.trackOf`,`{{class}} on {{name}}`,{class:e.label??e.className,name:t})}),O(`none`)}}),e(`div`,{className:`flex items-center gap-2`,children:[i(ie,{value:m,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),oe())},placeholder:s(`ai.messagePlaceholder`,`Ask the model something…`),"aria-label":s(`ai.message`,`Message`)}),X?e(M,{size:`sm`,variant:`secondary`,type:`button`,onClick:se,children:[i(x,{className:`h-3.5 w-3.5`}),s(`ai.stop`,`Stop`)]}):e(M,{size:`sm`,type:`button`,disabled:m.trim()===``||c===``,onClick:oe,children:[i(A,{className:`h-3.5 w-3.5`}),s(`ai.send`,`Send`)]})]})]})]})]})}function $e({turns:t,live:n}){let{t:r}=K();return t.length===0&&n===null?i(U,{icon:k,title:r(`ai.chatEmptyTitle`,`No messages yet`),description:r(`ai.chatEmpty`,`Pick a profile, optionally attach a camera snapshot or a recent track, and send a message. Nothing here is saved.`)}):e(`div`,{className:`max-h-[50vh] space-y-2 overflow-y-auto ${d}`,children:[t.map(e=>i(et,{turn:e},e.id)),n!==null&&e(`div`,{className:`space-y-1`,children:[n.mediaSent!==null&&i(tt,{attachment:n.mediaSent}),n.text.length>0&&i(et,{turn:{id:`live`,role:`assistant`,content:n.text},streaming:!0}),e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(h,{className:`h-3.5 w-3.5 animate-spin`}),Ke(n.phase,n.firstTokenTimeoutMs)]})]})]})}function et({turn:t,streaming:n=!1}){let{t:r}=K(),a=t.role===`user`,o=t.failed===!0?`border-danger/40 bg-danger/10`:`border-border bg-surface`;return i(`div`,{className:`flex ${a?`justify-end`:`justify-start`}`,children:e(`div`,{className:`max-w-[85%] rounded-lg border px-3 py-2 ${a?`border-primary/40 bg-primary/10`:o}`,children:[e(`p`,{className:`whitespace-pre-wrap break-words text-xs text-foreground`,children:[t.content,n&&i(`span`,{className:`ml-0.5 animate-pulse text-primary`,children:`▌`})]}),t.attachment!==void 0&&i(tt,{attachment:t.attachment}),t.attachmentLabel!==void 0&&e(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[t.attachmentKind===`track`?i(T,{className:`h-3 w-3`}):i(v,{className:`h-3 w-3`}),t.attachmentLabel]}),t.attachment!==void 0&&e(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[t.attachment.kind===`snapshot`?i(v,{className:`h-3 w-3`}):i(T,{className:`h-3 w-3`}),Ge(t.attachment)]}),t.model!==void 0&&i(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:r(`system.aiTestChat.tokMs`,`{{model}} · {{value2}} tok · {{value3}} ms`,{model:t.model,value2:String(t.outputTokens??0),value3:String(t.latencyMs??0)})})]})})}function tt({attachment:e}){let{t}=K(),n=Ue(e);return n===null?null:i(`img`,{src:n,alt:t(`system.aiTestChat.sentToTheModel`,`sent to the model`),className:`mt-1 max-h-32 rounded-md border border-border object-contain`})}function nt({onPick:e}){let{t}=K(),n=N({isCamera:!0,projection:`slim`}),r=(n.data??[]).filter(e=>!e.disabled);return n.isLoading?i(h,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`ai.noCameras`,`No camera found.`)}):i(`div`,{className:`grid max-h-56 grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-4`,children:r.map(t=>i(rt,{device:t,onPick:e},t.id))})}function rt({device:t,onPick:n}){let{t:r}=K(),a=H(t,`compact`),{src:o}=f(t.id,{width:Xe});return e(`button`,{type:`button`,onClick:()=>n(t,a),className:`overflow-hidden rounded-md border border-border bg-surface text-left transition-colors hover:border-primary/50`,children:[i(`span`,{className:`block aspect-video w-full bg-background-elevated`,children:o!==null&&i(`img`,{src:o,alt:``,className:`h-full w-full object-cover`,loading:`lazy`})}),e(`span`,{className:`flex items-center gap-1 px-2 py-1`,children:[!t.online&&i(I,{variant:`warning`,children:r(`common.off`)}),i(`span`,{className:`truncate text-[10px] text-foreground`,children:a})]})]})}function it({onPick:t}){let{t:r}=K(),a=S(),o=N({isCamera:!0,projection:`slim`}),c=n(()=>(o.data??[]).map(e=>e.id),[o.data]),l=n(()=>{let e=new Map;for(let t of o.data??[])e.set(t.id,t.name);return e},[o.data]),u=s({queryKey:[...qe,c.length],enabled:c.length>0,queryFn:()=>a.trpcClient.pipelineAnalytics.listRecentTracks.query({deviceIds:[...c],since:Date.now()-Je,limit:Ye,projection:`slim`})});if(o.isLoading||u.isLoading)return i(h,{className:`h-4 w-4 animate-spin text-foreground-subtle`});let d=u.data?.tracks??[];return d.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`ai.noTracks`,`No track in the last 6 hours.`)}):i(`div`,{className:`max-h-56 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:d.map(n=>e(`button`,{type:`button`,onClick:()=>t(n,l.get(n.deviceId)??String(n.deviceId)),className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-[11px] hover:bg-surface-hover`,children:[i(T,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),i(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:n.label??n.className}),i(`span`,{className:`shrink-0 text-foreground-subtle`,children:l.get(n.deviceId)??n.deviceId}),i(`span`,{className:`shrink-0 text-foreground-subtle`,children:new Date(n.lastSeen).toLocaleTimeString()})]},n.trackId))})}c();var at=1440*60*1e3,ot=[1,7,30,90];function st(){let{t}=K(),r=S(),[a,c]=o(7),l=n(()=>{let e=new Date;return e.setHours(0,0,0,0),e.getTime()-(a-1)*at},[a]),u=W({functionCap:`llm`}),f=s({queryKey:[...se,a],queryFn:()=>r.trpcClient.llm.getUsage.query({since:l})}),p=n(()=>{let e=new Map;for(let t of u.data??[])e.set(t.id,t.name);return e},[u.data]),m=n(()=>[{key:`day`,header:t(`ai.colDay`,`Day`),nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:e.day})},{key:`consumer`,header:t(`ai.colConsumer`,`Consumer`),nowrap:!0,render:e=>i(`span`,{className:`text-foreground`,children:e.consumer})},{key:`profile`,header:t(`ai.colProfile`,`Profile`),render:e=>i(`span`,{className:`text-foreground`,children:p.get(e.profileId)??e.profileId})},{key:`calls`,header:t(`ai.colCalls`,`Calls`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:String(e.calls)})},{key:`okErr`,header:t(`ai.colOkErr`,`OK / err`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums ${e.errorCalls>0?`text-danger`:``}`,children:`${String(e.okCalls)} / ${String(e.errorCalls)}`})},{key:`tokens`,header:t(`ai.colTokens`,`In / out tok`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:`${String(e.inputTokens)} / ${String(e.outputTokens)}`})},{key:`latency`,header:t(`ai.colAvgMs`,`Avg ms`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:String(Math.round(e.avgLatencyMs))})}],[p,t]),h=f.data??[],g=i(`div`,{className:`w-36`,children:i(D,{"aria-label":t(`ai.window`,`Window`),value:String(a),options:ot.map(e=>({value:String(e),label:t(`ai.lastDays`,`Last {{days}} days`,{days:e})})),onChange:e=>c(Number(e.target.value))})});return i(R,{headingId:`ai-usage-list`,title:t(`ai.usageList`,`Rollup`),actions:g,children:f.isPending?e(`div`,{className:`${d} space-y-2`,"data-testid":`ai-usage-loading`,children:[i(z,{className:`h-8 w-full`}),i(z,{className:`h-8 w-full`}),i(z,{className:`h-8 w-full`})]}):f.isError?i(`div`,{className:d,children:i(L,{title:t(`ai.usageFailed`,`Failed to read usage`),message:f.error instanceof Error?f.error.message:t(`common.error`,`Error`),onRetry:()=>void f.refetch()})}):h.length===0?i(U,{icon:y,title:t(`ai.noUsage`,`No AI calls in this window.`)}):i(te,{columns:m,rows:h,rowKey:e=>`${e.day}|${e.consumer}|${e.profileId}`,minWidthPx:720,bordered:!1,maxBodyHeight:B})})}c();var ct=`llm`,lt=[`profiles`,`runtimes`,`usage`,`test`],ut=[`instance`,`instance-new`];function dt(e){return lt.some(t=>t===e)}function ft(){let{t:e}=K(),t=P(ct),[n]=q(),r=Y(`/system/ai`,{t:e,isAdmin:!0})??{icon:w,title:e(`system.ai`,`AI`)};if(t!==`present`)return i(ae,{icon:r.icon,title:r.title,children:i(gt,{presence:t})});let a=n.get(`tab`),o=dt(a)?a:`profiles`,s={profiles:e(`ai.profilesSubtitle`,`One row = one usable model endpoint. The defaults below decide who answers when a feature names no profile.`),runtimes:e(`ai.runtimesSubtitle`,`Nodes advertising the llm-runtime capability: what each has loaded, what it is downloading, and how much model data sits on its disk.`),usage:e(`ai.usageSubtitle`,`Server-side rollup per day, consumer and profile — never raw call rows. Errors are counted, so a profile that always fails is visible here before a feature reports it.`),test:e(`ai.testSubtitle`,`A throwaway conversation with one profile. Attach a live camera snapshot or a recent track to check the model can actually read a picture. Nothing is saved — only the usage row.`)};return i(X,{icon:r.icon,title:r.title,subtitle:s[o],defaultSection:`profiles`,sectionsLabel:`${r.title} sections`,sections:[{id:`profiles`,label:e(`ai.tabProfiles`,`Profiles`),content:i(ht,{}),ownedParams:ut},{id:`runtimes`,label:e(`ai.tabRuntimes`,`Runtimes`),content:i(Me,{})},{id:`usage`,label:e(`ai.tabUsage`,`Usage`),content:i(st,{})},{id:`test`,label:e(`ai.tabTest`,`Test`),content:i(Qe,{})}]})}function pt(e,t,n){let r=e.kind===`instance`?t.get(e.id):void 0;return r===void 0?void 0:n(r)}function mt(e,t){let n=t=>pt(t,e,ge)??``,r=t=>pt(t,e,Z)??!1,a=t=>pt(t,e,ce)??``;return[{key:`model`,header:t(`ai.colModel`,`Model`),sortValue:n,render:e=>i(`span`,{className:`font-mono text-xs text-foreground-muted`,children:n(e)||`—`})},{key:`vision`,header:t(`ai.colVision`,`Vision`),sortValue:e=>+!!r(e),render:e=>r(e)?i(I,{variant:`info`,children:t(`ai.vision`,`vision`)}):null},{key:`node`,header:t(`ai.colNode`,`Node`),sortValue:a,render:e=>i(`span`,{className:`text-xs text-foreground-muted`,children:a(e)||`—`})}]}function ht(){let{t}=K(),r=W({functionCap:ct}),a=n(()=>new Map((r.data??[]).map(e=>[e.id,e])),[r.data]),o=n(()=>mt(a,t),[a,t]);return e(`div`,{className:p,children:[i(ye,{}),i(oe,{functionCap:ct,icon:w,title:t(`ai.profilesList`,`Profiles`),subtitle:t(`ai.profilesTableSubtitle`,`Each profile is one model endpoint; switch one off to keep it without using it.`),emptyTitle:t(`ai.noProfilesTitle`,`No AI profiles yet`),emptyDescription:t(`ai.noProfilesDescription`,`Add a profile to give features a model to talk to.`),addLabel:t(`ai.addProfile`,`Add profile`),extraColumns:o,lead:e=>i(ke,{row:e})})]})}function gt({presence:t}){let{t:n}=K();return t===`pending`?e(`div`,{className:`space-y-3`,"data-testid":`ai-presence-pending`,children:[i(z,{className:`h-8 w-64`}),i(z,{className:`h-40 w-full`})]}):t===`unknown`?i(L,{title:n(`ai.presenceUnknownTitle`,`Could not check whether AI is installed`),message:n(`ai.presenceUnknown`,`The hub did not answer the capability check. Reload the page to try again.`)}):i(U,{icon:w,title:n(`ai.absentTitle`,`AI is not installed`),description:n(`ai.absentDescription`,`Install the AI addon from System → Addons to add model profiles.`)})}export{ft as AiProfilesPage,ft as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$n as l,Aa as u,D as d,Dn as f,Ei as p,Er as m,Fr as h,Hi as g,Jn as _,Kt as v,Mn as y,Oa as b,Oi as x,Or as S,Pi as C,Q as w,Qn as ee,Tr as T,Ui as te,Xi as E,Yt as D,ba as ne,ct as O,ha as re,hi as k,ii as ie,ir as ae,jn as A,lt as oe,ot as j,ui as se,ut as ce,vi as le,xa as ue,zn as M}from"./player-overlays-DpoShe47.js";import{bi as de}from"./client-Dzzkm60X.js";import{t as fe}from"./chevron-down-CBb-F8DT.js";import{a as pe,f as me}from"./video-BV-3O_ZC.js";import{t as he}from"./circle-slash-Duh934sZ.js";import{n as ge,t as _e}from"./database-zap-DHuELz_w.js";import{t as ve}from"./hard-drive-download-C6N6tovA.js";import{$d as N,$s as ye,Aa as be,Ca as xe,Da as Se,Ea as Ce,Fa as we,Fn as Te,Gr as Ee,Hd as De,Hr as P,Ia as Oe,J as ke,Jr as F,Kr as I,La as Ae,Ma as je,Mf as Me,Na as Ne,Nn as Pe,Oa as Fe,Pa as Ie,Pn as Le,Q as Re,Qs as ze,Rf as Be,Sa as Ve,Ta as He,Ud as L,Un as R,Ur as z,Vd as B,Vn as Ue,Wn as We,Wr as V,Xs as Ge,Ys as Ke,Z as qe,Zs as Je,ac as Ye,ar as Xe,at as H,bo as Ze,cf as U,cr as W,ec as Qe,ef as $e,ic as et,ii as tt,ja as nt,ka as rt,nc as it,oa as at,or as ot,qr as G,rc as st,sf as K,sr as ct,tc as lt,wa as ut}from"./src-5h33Ujaz.js";import{t as q}from"./i18n-DWUEvjgE.js";import{t as J}from"./useTranslation-BJr-n0es.js";import"./mount-DQQApnAQ.js";import{E as dt,Jr as ft,Kr as pt,Qr as mt,x as ht}from"./index-BK_1kQTJ.js";import{t as gt}from"./AdminSectionedPage-L4C7Phdd.js";import{t as _t}from"./AdminPage-BoBZR6uA.js";import{n as vt}from"./authed-media-BpBHZnVV.js";import{t as Y}from"./format-size-DIxKXxtj.js";import{n as yt}from"./InstancesTable-pH3oYjHd.js";import{t as bt}from"./StorageLocationsTable-FczbEPcL.js";function xt(){return r(_t,{embedded:!0,children:r(bt,{})})}o();var St={settings:{labelKey:`helpers.backupDatabases.settings.label`,descriptionKey:`helpers.backupDatabases.settings.description`,shortKey:`helpers.backupDatabases.settings.short`},events:{labelKey:`helpers.backupDatabases.events.label`,descriptionKey:`helpers.backupDatabases.events.description`,shortKey:`helpers.backupDatabases.events.short`},history:{labelKey:`helpers.backupDatabases.history.label`,descriptionKey:`helpers.backupDatabases.history.description`,shortKey:`helpers.backupDatabases.history.short`}},Ct=Object.keys(St),wt=[`settings`];function Tt(){return q.t(`helpers.backupDatabases.notCreated`)}function Et(e){return q.t(St[e].labelKey)}function Dt(e){return q.t(St[e].shortKey)}function Ot(e){return q.t(St[e].descriptionKey)}function X(e){let t=new Set(e);return Ct.filter(e=>t.has(e))}function kt(e){return e!==void 0&&e.length>0?X(e):wt}function At(e){return X(e)}function jt(e,t){return t===void 0||!t.answered?`unknown`:t.databases.includes(e)?`present`:`absent`}function Mt(e,t,n){return jt(e,t)===`absent`&&!n.has(e)}function Nt(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function Pt(e){return!e.includes(`settings`)}function Ft(e){return{databases:[...At(e)]}}function It(e,t){return e!==void 0&&e.length>0?X(e):t!==void 0&&t.length>0?X(t.map(e=>e.databaseId??`settings`)):wt}function Z({databases:e}){return r(`span`,{className:`text-xs font-medium uppercase tracking-wide text-foreground-muted`,"data-testid":`backup-database-badges`,children:e.map(e=>Dt(e)).join(` · `)})}var Lt=[[`backup`,`listDestinations`]],Rt=[`backup`,`listArchives`];function zt({destinationId:i,restoreSupported:o,onOpenRestoreWizard:c}){let{t:l}=J(),u=s(),d=O(),{data:f,isLoading:p,isError:m}=Fe({destinationId:i}),h=f??[],g=xe({onSuccess:()=>{u.invalidateQueries({queryKey:[[...Rt]]}),u.invalidateQueries({queryKey:Lt})}}),_=n(async e=>{await d({title:l(`backup.archiveList.deleteThisArchive`,`Delete this archive?`),message:l(`backup.archiveList.permanentlyDeletesAndFrees`,`Permanently deletes "{{value1}}" and frees {{value2}}.`,{value1:e.label??e.id,value2:Y(e.sizeBytes)}),confirmLabel:l(`common.delete`,`Delete`),variant:`danger`})&&g.mutate({destinationId:i,backupId:e.id})},[d,i,g,l]),[v,y]=a(null),b=n(async e=>{y(e.id);try{let t=await vt(Bt(i,e.id)),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${e.label??e.id}.tar.gz${e.encryption===void 0?``:`.csbk`}`,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(n)}finally{y(null)}},[i]),x=t(()=>[...h].toSorted((e,t)=>t.createdAt-e.createdAt),[h]);return p?r(`div`,{className:`text-xs text-foreground-subtle animate-pulse py-2`,children:l(`backup.archiveList.loadingArchives`,`Loading archives…`)}):m?r(`div`,{className:`text-xs text-danger py-2`,children:l(`backup.archiveList.failedToReadManifestFor`,`Failed to read manifest for this destination`)}):x.length===0?r(`div`,{className:`text-xs text-foreground-subtle italic py-2`,children:l(`backup.archiveList.noArchivesAtThisDestination`,`No archives at this destination yet.`)}):r(R,{columns:[{key:`when`,header:l(`backup.archiveList.when`,`When`),sortValue:e=>e.createdAt,render:e=>r(`span`,{className:`tabular-nums`,children:Vt(e.createdAt)})},{key:`label`,header:l(`backup.archiveList.label`,`Label`),sortValue:e=>e.label??null,render:t=>e(`span`,{className:`inline-flex items-center gap-1`,children:[t.encryption!==void 0&&r(T,{className:`h-3 w-3 text-success`,"aria-label":l(`backup.archiveList.encryptedRestoreNeedsBackupKey`,`encrypted — restore needs backup key {{keyId}}`,{keyId:t.encryption.keyId})}),t.label??r(`span`,{className:`text-foreground-subtle italic`,children:`—`})]})},{key:`databases`,header:l(`backup.archiveList.databases`,`Databases`),nowrap:!1,notSortableReason:`Database badges`,render:e=>r(Z,{databases:kt(e.databases)})},{key:`includes`,header:l(`backup.archiveList.files`,`Files`),nowrap:!1,notSortableReason:`Location list`,render:e=>e.locations.length>0?r(`span`,{className:`text-foreground-subtle`,children:e.locations.join(`, `)}):r(`span`,{className:`text-foreground-subtle italic`,children:l(`common.none`)})},{key:`size`,header:l(`backup.archiveList.size`,`Size`),align:`right`,sortValue:e=>e.sizeBytes,render:e=>r(`span`,{className:`tabular-nums`,children:Y(e.sizeBytes)})},{key:`actions`,header:``,align:`right`,notSortableReason:`Actions`,render:t=>e(`span`,{className:`flex items-center justify-end gap-1`,children:[e(N,{variant:`ghost`,size:`sm`,onClick:()=>{b(t)},disabled:v===t.id,title:l(`backup.archiveList.downloadArchive`,`Download archive`),children:[v===t.id?r(S,{className:`h-3 w-3 animate-spin`}):r(se,{className:`h-3 w-3`}),l(`backup.archiveList.download`,`Download`)]}),o&&c&&e(N,{variant:`ghost`,size:`sm`,onClick:()=>c({destinationId:i,archiveId:t.id}),title:l(`backup.archiveList.restoreFromThisArchive`,`Restore from this archive`),children:[r(M,{className:`h-3 w-3`}),l(`backup.archiveList.restore`,`Restore`)]}),r(U,{variant:`ghost`,size:`sm`,icon:D,"aria-label":l(`backup.archiveList.delete`,`Delete {{value1}}`,{value1:t.label??t.id}),disabled:g.isPending,onClick:()=>{_(t)}})]})}],rows:x,rowKey:e=>e.id,minWidthPx:760,emptyMessage:l(`backup.archiveList.noArchivesAtThisDestination`,`No archives at this destination yet.`)})}function Bt(e,t){return w(`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`)}function Vt(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})}o();var Ht=[[`backup`,`listSchedules`]];function Ut({onEdit:i,onOpenRestoreWizard:o}){let{t:s}=J(),{data:c,isLoading:l,isError:u,error:d,refetch:f}=je(),p=c??[],m=be().data??[],h=t(()=>{let e=new Map;for(let t of m)e.set(t.id,t);return e},[m]),[g,_]=a(null),v=n(e=>{_(t=>t===e?null:e)},[]),y=t(()=>Wt({destById:h,expandedId:g,onToggleExpand:v,onEdit:i}),[h,g,v,i]);return l?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle animate-pulse`,children:[r(S,{className:`h-3.5 w-3.5 animate-spin`}),s(`backup.backupEntriesTable.loadingBackupEntries`,`Loading backup entries…`)]}):u?r(B,{title:s(`backup.backupEntriesTable.failedToLoadBackupEntries`,`Failed to load backup entries`),message:d instanceof Error?d.message:s(`backup.backupEntriesTable.unknownError`,`Unknown error`),onRetry:()=>void f()}):p.length===0?r(tt,{icon:E,title:s(`backup.backupEntriesTable.noBackupEntriesYet`,`No backup entries yet`),description:s(`backup.backupEntriesTable.createOneToScheduleBackups`,`Create one to schedule backups across one or more storage locations.`)}):r(R,{columns:y,rows:p,rowKey:e=>e.id,minWidthPx:980,maxBodyHeight:We,emptyMessage:s(`backup.backupEntriesTable.noBackupEntriesYet`,`No backup entries yet`),onRowClick:e=>i(e),isExpanded:e=>e.id===g,renderExpanded:e=>r(Zt,{row:e,destById:h,...o?{onOpenRestoreWizard:o}:{}})})}function Wt(t){return[{key:`expand`,header:``,width:`w-8`,nowrap:!0,notSortableReason:`Expand control`,render:e=>{let n=t.expandedId===e.id;return r(U,{variant:`ghost`,size:`sm`,icon:n?fe:g,"aria-label":n?q.t(`backup.backupEntriesTable.hideArchives`,`Hide archives`):q.t(`backup.backupEntriesTable.showArchives`,`Show archives`),"aria-expanded":n,onClick:n=>{n.stopPropagation(),t.onToggleExpand(e.id)}})}},{key:`entry`,header:q.t(`backup.backupEntriesTable.entry`,`Entry`),sortValue:e=>e.label,render:t=>e(`span`,{className:`flex min-w-0 flex-col`,children:[r(`span`,{className:`truncate font-medium text-foreground`,children:t.label||q.t(`backup.backupEntriesTable.unnamed`,`(unnamed)`)}),t.lastRunAt!==void 0&&r(`span`,{className:`text-[10px] text-foreground-subtle`,children:q.t(`backup.backupEntriesTable.lastRun`,{when:new Date(t.lastRunAt).toLocaleString()})})]})},{key:`enabled`,header:q.t(`backup.backupEntriesTable.enabled`,`Enabled`),width:`w-20`,nowrap:!0,sortValue:e=>+!!e.enabled,render:e=>r(`span`,{onClick:e=>e.stopPropagation(),children:r(Jt,{row:e})})},{key:`databases`,header:q.t(`backup.backupEntriesTable.backsUp`,`Backs up`),nowrap:!1,notSortableReason:`Database badges`,render:e=>r(Z,{databases:kt(e.databases)})},{key:`locations`,header:q.t(`backup.backupEntriesTable.locations`,`Locations`),nowrap:!1,notSortableReason:`Location chips`,render:e=>r(Gt,{row:e,destById:t.destById})},{key:`retention`,header:q.t(`backup.backupEntriesTable.retention`,`Retention`),width:`w-24`,nowrap:!0,sortValue:e=>e.retentionCount,render:e=>r(`span`,{onClick:e=>e.stopPropagation(),children:r(Yt,{row:e})})},{key:`schedule`,header:q.t(`backup.backupEntriesTable.schedule`,`Schedule`),width:`w-48`,nowrap:!0,sortValue:e=>e.cron,render:e=>r(Kt,{row:e})},{key:`actions`,header:``,align:`right`,nowrap:!0,notSortableReason:`Actions`,render:e=>r(`span`,{onClick:e=>e.stopPropagation(),children:r(Xt,{row:e,onEdit:()=>t.onEdit(e)})})}]}function Gt({row:e,destById:t}){let{t:n}=J();return e.locationIds.length===0?r(`span`,{className:`text-[11px] italic text-danger`,children:n(`backup.backupEntriesTable.noLocations`,`No locations`)}):r(`span`,{className:`flex flex-wrap gap-1`,children:e.locationIds.map(e=>r(`span`,{className:`inline-flex items-center rounded border border-border bg-background px-1.5 py-0.5 text-[10px] text-foreground`,title:e,children:t.get(e)?.displayName??e},e))})}function Kt({row:t}){let{t:n}=J(),i=t.cron.trim().length>0;return e(`span`,{className:`flex flex-col items-start gap-0.5`,children:[e(`span`,{className:`inline-flex items-center gap-1`,children:[r(E,{className:`h-3 w-3 text-foreground-subtle`}),r(`span`,{className:`font-mono text-[11px] text-foreground`,children:i?t.cron:n(`backup.backupEntriesTable.manual`,`Manual`)})]}),i&&t.nextRunAt!==void 0&&r(`span`,{className:`text-[10px] text-foreground-subtle`,children:q.t(`common.nextRun`,{when:new Date(t.nextRunAt).toLocaleString()})})]})}function qt(e){return t(()=>({id:e.id,label:e.label,cron:e.cron,locationIds:[...e.locationIds],retentionCount:e.retentionCount,...e.dataSources?{dataSources:[...e.dataSources]}:{},...e.databases?{databases:[...e.databases]}:{}}),[e])}function Jt({row:e}){let{t}=J(),n=s(),i=Ae({onSuccess:()=>{n.invalidateQueries({queryKey:Ht})}}),a=qt(e);return r(`label`,{className:`inline-flex cursor-pointer items-center`,children:r(b,{className:`accent-primary`,checked:e.enabled,disabled:i.isPending,onChange:e=>i.mutate({...a,enabled:e.target.checked}),"aria-label":t(`backup.backupEntriesTable.enable`,`Enable {{value1}}`,{value1:e.label||e.id})})})}function Yt({row:e}){let{t}=J(),n=s(),o=Ae({onSuccess:()=>{n.invalidateQueries({queryKey:Ht})}}),c=qt(e),[l,u]=a(String(e.retentionCount));return i(()=>{u(String(e.retentionCount))},[e.retentionCount]),r(K,{type:`number`,min:1,max:1e3,value:l,disabled:o.isPending,onChange:e=>u(e.target.value),onBlur:()=>{let t=Number.parseInt(l,10);if(Number.isNaN(t)||t<1){u(String(e.retentionCount));return}t!==e.retentionCount&&o.mutate({...c,enabled:e.enabled,retentionCount:t})},onKeyDown:t=>{t.key===`Enter`&&t.target.blur(),t.key===`Escape`&&u(String(e.retentionCount))},className:`w-16`,"aria-label":t(`backup.backupEntriesTable.retentionFor`,`Retention for {{value1}}`,{value1:e.label||e.id})})}function Xt({row:t,onEdit:n}){let{t:i}=J(),a=s(),o=O(),c=ut({onSuccess:()=>{a.invalidateQueries({queryKey:Ht})}}),u=Oe({onMutate:()=>{a.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})},onSuccess:()=>{a.invalidateQueries({queryKey:[[`backup`,`listArchives`]]}),a.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]}),a.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})}}),d=()=>{t.locationIds.length!==0&&u.mutate({destinations:[...t.locationIds],...t.dataSources&&t.dataSources.length>0?{locations:[...t.dataSources]}:{},label:t.label,retentionCount:t.retentionCount,databases:[...kt(t.databases)]})},f=async()=>{await o({title:i(`backup.backupEntriesTable.deleteBackupEntry`,`Delete backup entry?`),message:i(`backup.backupEntriesTable.willStopRunningExistingArchives`,`"{{value1}}" will stop running. Existing archives are kept.`,{value1:t.label||t.id}),confirmLabel:i(`common.delete`,`Delete`),variant:`warning`})&&c.mutate({id:t.id})};return e(`span`,{className:`flex items-center justify-end gap-1.5`,children:[e(N,{size:`sm`,type:`button`,onClick:d,disabled:u.isPending||t.locationIds.length===0,title:i(`backup.backupEntriesTable.runThisEntryNow`,`Run this entry now`),children:[u.isPending?r(S,{className:`h-3 w-3 animate-spin`}):r(l,{className:`h-3 w-3`}),i(`backup.backupEntriesTable.runNow`,`Run now`)]}),r(U,{variant:`ghost`,size:`sm`,icon:ae,"aria-label":i(`backup.backupEntriesTable.edit`,`Edit {{value1}}`,{value1:t.label||t.id}),onClick:n}),r(U,{variant:`ghost`,size:`sm`,icon:D,"aria-label":i(`backup.backupEntriesTable.delete`,`Delete {{value1}}`,{value1:t.label||t.id}),disabled:c.isPending,onClick:()=>{f()}})]})}function Zt({row:t,destById:n,onOpenRestoreWizard:i}){let{t:a}=J();return e(`div`,{className:`space-y-4 rounded-lg border border-border bg-background/30 px-4 py-3`,children:[r(`p`,{className:`text-[11px] font-medium text-foreground-subtle`,children:a(`backup.backupEntriesTable.archivesFor`,{name:t.label||t.id})}),t.locationIds.length===0&&r(`p`,{className:`text-xs italic text-foreground-subtle`,children:a(`backup.backupEntriesTable.thisEntryHasNoLocations`,`This entry has no locations selected.`)}),t.locationIds.map(t=>e(`div`,{className:`space-y-1.5`,children:[r(`div`,{className:`text-[11px] font-medium text-foreground-subtle`,children:n.get(t)?.displayName??t}),r(zt,{destinationId:t,restoreSupported:n.get(t)?.restoreSupported??!0,...i?{onOpenRestoreWizard:i}:{}})]},t))]})}function Qt({selected:t,onChange:n,disabled:i=!1,testId:a=`backup-databases`}){let{t:o}=J(),s=rt().data,c=t.size>0&&Pt(X(t)),l=t.size===0?`Pick at least one.`:c?`Snapshots only: configuration and files are not part of this backup.`:null;return r(H,{label:o(`backup.backupDatabasePicker.whatToBackUp`,`What to back up`),required:!0,...l===null?{}:{description:l},children:r(`div`,{className:`divide-y divide-border rounded border border-border bg-background`,"data-testid":a,children:Ct.map(o=>{let c=jt(o,s),l=i||Mt(o,s,t);return e(`label`,{className:`flex items-start gap-2 px-3 py-2 text-xs ${l?`opacity-60`:`cursor-pointer hover:bg-primary/5`}`,children:[r(b,{checked:t.has(o),disabled:l,onChange:()=>n(Nt(t,o)),"data-testid":`${a}-${o}`}),e(`span`,{className:`min-w-0 flex-1`,children:[r(`span`,{className:`flex flex-wrap items-center gap-1.5 text-foreground`,children:Et(o)}),r(`span`,{className:`block text-[11px] text-foreground-subtle`,children:c===`absent`?Tt():Ot(o)})]})]},o)})})})}o();function $t({onClose:t}){let{t:n}=J(),i=s(),[o,c]=a(new Set(wt)),u=Oe({onMutate:()=>{i.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})},onSuccess:()=>{i.invalidateQueries({queryKey:[[`backup`,`listArchives`]]}),i.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]}),i.invalidateQueries({queryKey:[[`backup`,`listRuns`]]}),t()}});return r(P,{open:!0,onOpenChange:e=>!e&&t(),children:e(V,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(G,{children:[r(F,{children:n(`backup.backupNowDialog.backUpNow`,`Back up now`)}),r(`p`,{className:`text-xs text-foreground-subtle`,children:n(`backup.backupNowDialog.runsOnceAndWritesThe`,`Runs once and writes the archive to every enabled backup location.`)})]}),r(z,{children:e(`div`,{className:`p-4`,children:[r(Qt,{selected:o,onChange:c,disabled:u.isPending,testId:`backup-now-databases`}),u.error&&r(`p`,{role:`alert`,className:`pt-2 text-xs text-danger`,children:u.error.message})]})}),e(I,{children:[r(N,{variant:`outline`,size:`sm`,onClick:t,children:n(`common.cancel`,`Cancel`)}),e(N,{size:`sm`,onClick:()=>{o.size!==0&&u.mutate(Ft(o))},disabled:o.size===0||u.isPending,"data-testid":`backup-now-run`,children:[u.isPending?r(S,{className:`h-3.5 w-3.5 animate-spin`}):r(l,{className:`h-3.5 w-3.5`}),n(`backup.backupNowDialog.backUpNow`,`Back up now`)]})]})]})})}o();function en(e){return e===null?`—`:new Date(e).toLocaleString()}function tn(e){let t=new Blob([`${e.secretKey}\n`],{type:`text/plain`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`camstack-backup-key-${e.keyId}.txt`,r.click(),URL.revokeObjectURL(n)}function nn({revealed:t,onDone:n}){let{t:i}=J(),[o,s]=a(!1),[c,l]=a(!1);return r(P,{open:!0,onOpenChange:e=>!e&&o&&n(),children:e(V,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`border-danger/40`,"aria-labelledby":`backup-key-title`,children:[r(G,{children:r(F,{id:`backup-key-title`,children:i(`backup.encryptionCard.yourKey`,{keyId:t.keyId})})}),e(z,{className:`space-y-3`,children:[e(`p`,{className:`flex items-start gap-2 rounded-md border border-danger/40 bg-danger/10 p-2 text-xs text-foreground`,children:[r(v,{className:`mt-0.5 h-4 w-4 shrink-0 text-danger`}),r(`span`,{children:i(`backup.backupEncryptionCard.thisKeyIsShownOnly`,`This key is shown only once. CamStack does not keep it — not the hub, not its database, not its backups. Without it, an encrypted backup cannot be restored by anyone, including you. Store it in a password manager or print it, away from this server.`)})]}),r(`div`,{className:`break-all rounded-md border border-border bg-background p-2 font-mono text-xs text-foreground select-all`,children:t.secretKey}),e(`div`,{className:`flex flex-wrap gap-2`,children:[e(N,{size:`sm`,variant:`outline`,onClick:()=>{navigator.clipboard?.writeText(t.secretKey).then(()=>l(!0))},children:[r(le,{className:`mr-1 h-3.5 w-3.5`}),c?i(`backup.backupEncryptionCard.copied`,`Copied`):i(`common.copy`,`Copy`)]}),e(N,{size:`sm`,variant:`outline`,onClick:()=>tn(t),children:[r(se,{className:`mr-1 h-3.5 w-3.5`}),i(`backup.backupEncryptionCard.downloadAsFile`,`Download as file`)]})]}),e(`label`,{className:`flex items-center gap-2 text-xs text-foreground`,children:[r(b,{checked:o,onChange:e=>s(e.target.checked),className:`accent-primary`}),i(`backup.backupEncryptionCard.iHaveStoredThisKey`,`I have stored this key somewhere safe, off this server.`)]})]}),r(I,{children:r(N,{size:`sm`,disabled:!o,onClick:n,children:i(`backup.backupEncryptionCard.iHaveStoredIt`,`I have stored it`)})})]})})}function rn(){let{t}=J(),n=Ce(),i=we(),o=He(),s=O(),[l,u]=a(null),[d,f]=a(null),p=n.data?.enabled??!1,h=n.data?.active??null,g=(n.data?.keys??[]).filter(e=>e.retiredAt!==null),_=async()=>{if(await s({title:p?t(`backup.backupEncryptionCard.replaceTheBackupKey`,`Replace the backup key`):t(`backup.backupEncryptionCard.encryptBackups`,`Encrypt backups`),message:p?t(`backup.backupEncryptionCard.aNewKeyIsGenerated`,`A new key is generated and shown once; new backups are encrypted to it. Older backups keep needing the key they were made with — keep that one too.`):t(`backup.backupEncryptionCard.aBackupKeyIsGenerated`,`A backup key is generated and shown once. Every new backup is encrypted to it, and restoring one will ask for it. Existing backups stay as they are.`),confirmLabel:p?t(`backup.backupEncryptionCard.generateANewKey`,`Generate a new key`):t(`backup.backupEncryptionCard.generateTheKey`,`Generate the key`),variant:`warning`})){f(null);try{let e=await i.mutateAsync({});u({keyId:e.keyId,secretKey:e.secretKey})}catch(e){f(e instanceof Error?e.message:String(e))}}},v=async()=>{if(await s({title:t(`backup.backupEncryptionCard.turnBackupEncryptionOff`,`Turn backup encryption off`),message:t(`backup.backupEncryptionCard.newBackupsWillBeWritten`,`New backups will be written unencrypted. Existing encrypted backups still need their key to be restored.`),confirmLabel:t(`backup.backupEncryptionCard.turnOff`,`Turn off`),variant:`danger`})){f(null);try{await o.mutateAsync({}),n.refetch()}catch(e){f(e instanceof Error?e.message:String(e))}}};return e(`div`,{className:`space-y-2 rounded-lg border border-border bg-surface p-4`,children:[e(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[e(`div`,{className:`flex items-center gap-2`,children:[p?r(T,{className:`h-4 w-4 text-success`}):r(m,{className:`h-4 w-4 text-foreground-subtle`}),r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`backup.backupEncryptionCard.encryption`,`Encryption`)}),r(`span`,{className:`text-xs text-foreground-subtle`,children:p&&h!==null?t(`backup.backupEncryptionCard.onKeySince`,`On — key {{keyId}}, since {{value2}}`,{keyId:h.keyId,value2:en(h.createdAt)}):t(`backup.backupEncryptionCard.offBackupsAreNotEncrypted`,`Off — backups are not encrypted`)})]}),r(`div`,{className:`flex gap-2`,children:p?e(c,{children:[r(N,{size:`sm`,variant:`outline`,disabled:i.isPending,onClick:()=>void _(),children:t(`backup.backupEncryptionCard.replaceKey`,`Replace key`)}),r(N,{size:`sm`,variant:`outline`,disabled:o.isPending,onClick:()=>void v(),children:t(`backup.backupEncryptionCard.turnOff`,`Turn off`)})]}):r(N,{size:`sm`,disabled:i.isPending,onClick:()=>void _(),children:t(`backup.backupEncryptionCard.enableEncryption`,`Enable encryption`)})})]}),r(`p`,{className:`text-xs text-foreground-subtle`,children:t(`backup.backupEncryptionCard.archivesAreEncryptedOnThis`,`Archives are encrypted on this server before they reach any destination. The server keeps only a public key, so it can encrypt scheduled backups but cannot decrypt them — only your backup key can. Covers the database snapshot, addon data (HomeKit pairing, Matter fabric, Tailscale state) and TLS.`)}),g.length>0&&e(`div`,{className:`text-xs`,children:[r(`p`,{className:`text-foreground-subtle`,children:t(`backup.backupEncryptionCard.olderKeysBackupsMadeWith`,`Older keys (backups made with them still need them):`)}),r(`ul`,{className:`font-mono text-foreground`,children:g.map(t=>e(`li`,{children:[t.keyId,` · `,en(t.createdAt),` → `,en(t.retiredAt)]},t.keyId))})]}),d!==null&&r(`p`,{className:`text-xs text-danger`,children:d}),l!==null&&r(nn,{revealed:l,onDone:()=>{u(null),n.refetch()}})]})}o();var an=[{id:`manual`,labelKey:`backup.cronEditor.presetManual`,cron:``},{id:`hourly`,labelKey:`backup.cronEditor.presetHourly`,cron:`0 * * * *`,descriptionKey:`backup.cronEditor.presetHourlyDesc`},{id:`every-3h`,labelKey:`backup.cronEditor.preset3h`,cron:`0 */3 * * *`,description:`00:00, 03:00, 06:00, 09:00 …`},{id:`every-6h`,labelKey:`backup.cronEditor.preset6h`,cron:`0 */6 * * *`,description:`00:00, 06:00, 12:00, 18:00`},{id:`daily-3am`,labelKey:`backup.cronEditor.presetDaily`,cron:`0 3 * * *`,descriptionKey:`backup.cronEditor.presetDailyDesc`},{id:`weekly-sun`,labelKey:`backup.cronEditor.presetWeekly`,cron:`0 3 * * 0`,descriptionKey:`backup.cronEditor.presetWeeklyDesc`}];function on(e){let t=e.trim();for(let e of an)if(e.cron===t)return e.id;return`custom`}function sn({value:t,onChange:n,previewCount:o=5,disabled:s=!1}){let{t:c}=J(),l=on(t),[u,d]=a(l===`custom`);i(()=>{l!==`custom`&&d(!1)},[l]);let f=un(t,250),p=Ne({cron:f,count:o},{enabled:f.trim().length>0}),m=p.data??null,h=e=>{d(!1),n(e.cron)},g=u||l===`custom`;return e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`backup.cronEditor.schedulePreset`,`Schedule preset`)}),e(`div`,{className:`flex flex-wrap gap-1.5`,children:[an.map(e=>r(N,{variant:`unstyled`,type:`button`,onClick:()=>h(e),disabled:s,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(!u&&l===e.id?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),title:e.descriptionKey===void 0?e.description??c(e.labelKey):c(e.descriptionKey),children:c(e.labelKey)},e.id)),r(N,{variant:`unstyled`,type:`button`,onClick:()=>{d(!0),t.trim().length===0&&n(`0 3 * * *`)},disabled:s,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(g?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),children:c(`backup.cronEditor.custom`,`Custom…`)})]})]}),g&&e(`div`,{className:`space-y-1`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`backup.cronEditor.cronExpression5FieldPosix`,`Cron expression (5-field POSIX)`)}),r(K,{type:`text`,value:t,onChange:e=>n(e.target.value),disabled:s,placeholder:`0 3 * * *`,spellCheck:!1,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`}),e(`p`,{className:`text-[10px] text-foreground-subtle`,children:[c(`backup.cronEditor.format`,`Format:`),` `,r(pt,{i18nKey:`backup.cronEditor.formatLine`,components:{code:r(`span`,{className:`font-mono`})}})]})]}),r(cn,{cron:f,preview:m,loading:p.isFetching})]})}function cn({cron:t,preview:n,loading:i}){let{t:a}=J();return i&&n===null?e(`div`,{className:`flex items-center gap-2 rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:[r(S,{className:`h-3 w-3 animate-spin`}),a(`backup.cronEditor.validating`,`Validating…`)]}):n===null?null:n.ok?n.nextRuns.length===0?r(`div`,{className:`rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:a(`backup.cronEditor.noFutureRunsMatchThis`,`No future runs match this expression.`)}):e(`div`,{className:`space-y-1`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:a(`backup.cronEditor.nextRuns`,`Next runs`)}),r(`ul`,{className:`rounded border border-border bg-background/40 divide-y divide-border`,children:n.nextRuns.map((t,n)=>e(`li`,{className:`flex items-center justify-between px-3 py-1.5 text-[11px]`,children:[r(`span`,{className:`text-foreground tabular-nums`,children:new Date(t).toLocaleString()}),r(`span`,{className:`text-foreground-subtle text-[10px] tabular-nums`,children:ln(t)})]},`${t}-${n}`))})]}):r(`div`,{className:`rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:n.error??a(`backup.cronEditor.invalidCronExpression`,`Invalid cron expression`)})}function ln(e){let t=e-Date.now();if(t<=0)return q.t(`helpers.relativeTime.now`);let n=Math.floor(t/1e3);if(n<60)return q.t(`helpers.relativeTime.inSeconds`,{count:n});let r=Math.floor(n/60);if(r<60)return q.t(`helpers.relativeTime.inMinutes`,{count:r});let i=Math.floor(r/60);if(i<24)return q.t(`helpers.relativeTime.inHours`,{count:i});let a=Math.floor(i/24);return q.t(`helpers.relativeTime.inDays`,{count:a})}function un(e,n){let[r,o]=a(e),s=t(()=>e,[e]);return i(()=>{let e=setTimeout(()=>o(s),n);return()=>clearTimeout(e)},[s,n]),r}o();var dn=[[`backup`,`listSchedules`]];function fn({entry:n,onClose:i,onSaved:o}){let{t:c}=J(),l=s(),u=be(),d=u.data??[],[f,p]=a(n?.label??``),[m,h]=a(n?.cron??`0 3 * * *`),[g,_]=a(n?.enabled??!0),[v,y]=a(String(n?.retentionCount??7)),[x,C]=a(new Set(n?.locationIds??[])),[w,ee]=a(new Set(n===null?wt:kt(n.databases))),T=Ae({onSuccess:()=>{l.invalidateQueries({queryKey:dn}),o()}}),te=e=>{C(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},D=Number.parseInt(v,10),ne=t(()=>f.trim().length>0&&x.size>0&&w.size>0&&!Number.isNaN(D)&&D>=1&&D<=1e3,[f,x,w,D]),O=()=>{ne&&T.mutate({...n?{id:n.id}:{},label:f.trim(),cron:m.trim(),enabled:g,locationIds:Array.from(x),retentionCount:D,databases:[...At(w)]})},re=T.error instanceof Error?T.error.message:null;return r(Re,{open:!0,onClose:i,title:n?c(`backup.backupEntryModal.editBackupEntry`,`Edit backup entry`):c(`backup.backupEntryModal.newBackupEntry`,`New backup entry`),icon:E,error:re,width:`lg`,testId:`backup-entry-form`,footer:e(N,{size:`sm`,type:`button`,onClick:O,disabled:!ne||T.isPending,children:[T.isPending?r(S,{className:`h-3.5 w-3.5 animate-spin`}):null,n?c(`common.save`,`Save`):c(`backup.backupEntryModal.createEntry`,`Create entry`)]}),children:e(`div`,{className:`space-y-4`,children:[r(H,{label:c(`backup.backupEntryModal.name`,`Name`),required:!0,children:r(K,{value:f,onChange:e=>p(e.target.value),placeholder:c(`backup.backupEntryModal.nightlyOffsite`,`Nightly offsite`),autoFocus:!0,"data-testid":`backup-entry-name`})}),e(H,{label:c(`backup.backupEntryModal.locationsSelected`,`Locations ({{value1}} selected)`,{value1:String(x.size)}),required:!0,children:[u.isLoading&&e(`div`,{className:`flex items-center gap-2 px-1 py-2 text-xs text-foreground-subtle`,children:[r(S,{className:`h-3.5 w-3.5 animate-spin`}),c(`backup.backupEntryModal.loadingLocations`,`Loading locations…`)]}),!u.isLoading&&d.length===0&&r(`div`,{className:`rounded border border-border bg-background px-3 py-2 text-xs text-foreground-subtle italic`,children:c(`backup.backupEntryModal.noBackupsStorageLocationsConfigured`,"No `backups` storage locations configured. Add one in Settings → Storage first.")}),d.length>0&&r(`div`,{className:`max-h-52 divide-y divide-border overflow-y-auto rounded border border-border bg-background`,children:d.map(t=>e(`label`,{className:`flex cursor-pointer items-center justify-between px-3 py-2 text-xs hover:bg-primary/5`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(b,{checked:x.has(t.id),onChange:()=>te(t.id),className:`accent-primary`}),r(`span`,{className:`text-foreground`,children:t.displayName})]}),e(`div`,{className:`flex items-center gap-1.5`,children:[r(`span`,{className:`rounded border border-border bg-surface px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-foreground-subtle`,children:t.kind}),r(`span`,{className:`font-mono text-[10px] text-foreground-subtle`,children:t.id})]})]},t.id))})]}),r(Qt,{selected:w,onChange:ee,disabled:T.isPending,testId:`backup-entry-databases`}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[r(H,{label:c(`backup.backupEntryModal.retentionArchivesKept`,`Retention (archives kept)`),required:!0,children:r(K,{type:`number`,min:1,max:1e3,value:v,onChange:e=>y(e.target.value),"data-testid":`backup-entry-retention`})}),r(H,{label:c(`backup.backupEntryModal.enabled`,`Enabled`),description:c(`backup.backupEntryModal.runOnScheduleWhenChecked`,`Run on schedule when checked.`),children:e(`label`,{className:`inline-flex cursor-pointer items-center gap-2 py-1.5 text-xs text-foreground`,children:[r(b,{checked:g,onChange:e=>_(e.target.checked),className:`accent-primary`,"data-testid":`backup-entry-enabled`}),r(`span`,{children:c(`backup.backupEntryModal.runOnSchedule`,`Run on schedule`)})]})})]}),r(H,{label:c(`backup.backupEntryModal.schedule`,`Schedule`),children:r(sn,{value:m,onChange:h,disabled:T.isPending})})]})})}o();var pn=2e3,mn=5e3;function hn(e){return e.state===`queued`||e.state===`running`}function gn(e){if(e.state===`queued`)return{title:q.t(`backup.backupRunsPanel.cancelQueuedBackupRun`,`Cancel queued backup run?`),message:q.t(`backup.backupRunsPanel.thisRunHasNotStarted`,`This run has not started. Cancelling removes it from the queue — nothing has been written, nothing is deleted.`),confirmLabel:q.t(`backup.backupRunsPanel.cancelRun`,`Cancel run`),variant:`warning`};let t=e.completedDestinationIds.length,n=t>0?`${t===1?`The 1 destination`:`The ${t} destinations`} that already completed KEEP${t===1?`S`:``} the archive.`:`No destination has completed yet, so nothing will be kept.`;return{title:q.t(`backup.backupRunsPanel.stopThisBackupRun`,`Stop this backup run?`),message:q.t(`backup.backupRunsPanel.theHalfWrittenStagingArchive`,`The half-written staging archive is deleted and the destination currently uploading discards its partial copy. {{keptSentence}}`,{keptSentence:n}),confirmLabel:q.t(`backup.backupRunsPanel.stopRun`,`Stop run`),variant:`danger`}}function _n(){let e=O(),[t,i]=a(null),o=nt(void 0,{refetchInterval:e=>(e.state.data??[]).some(hn)?pn:mn}),s=Ve({onSettled:()=>{i(null),o.refetch()}}),c=n(async t=>{await e(gn(t))&&(i(t.id),s.mutate({runId:t.id}))},[e,s]);return r(vn,{queryState:o.isError?`error`:o.data===void 0?`pending`:`ready`,runs:o.data??[],cancelingId:t,onCancelRequest:e=>{c(e)},now:Date.now()})}function vn({queryState:t,runs:n,cancelingId:i,onCancelRequest:a,now:o}){let{t:s}=J(),c=t===`ready`&&n.some(hn),l=n.filter(e=>e.state===`running`),u=n.filter(e=>e.state===`queued`),d=n.filter(e=>!hn(e)),f=[...l,...u,...d];return e(`section`,{className:`rounded-lg border border-border bg-surface`,children:[e(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border`,children:[r(`h2`,{className:`text-xs font-semibold text-foreground`,children:s(`backup.backupRunsPanel.runs`,`Runs`)}),c&&e(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium text-primary`,title:s(`backup.backupRunsPanel.aBackupRunIsIn`,`A backup run is in progress`),children:[r(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary animate-pulse`}),s(`backup.runsPanel.live`)]}),r(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:s(`backup.backupRunsPanel.oneRunExecutesAtA`,`One run executes at a time — queued runs wait in line.`)})]}),t===`pending`&&r(`div`,{className:`px-3 py-2.5 text-xs text-foreground-subtle animate-pulse`,children:s(`backup.backupRunsPanel.checkingForBackupRuns`,`Checking for backup runs…`)}),t===`error`&&r(`div`,{className:`px-3 py-2.5 text-xs text-danger`,children:s(`backup.backupRunsPanel.couldNotReadBackupRuns`,`Could not read backup runs — the orchestrator did not answer.`)}),t===`ready`&&n.length===0&&r(`div`,{className:`px-3 py-2.5 text-xs text-foreground-subtle italic`,children:s(`backup.backupRunsPanel.noBackupRunsYetRuns`,`No backup runs yet. Runs appear here the moment one starts — manual or scheduled.`)}),t===`ready`&&n.length>0&&r(`div`,{className:`overflow-x-auto`,children:e(`table`,{className:`w-full text-xs min-w-[720px]`,children:[r(`thead`,{children:e(`tr`,{className:`text-foreground-subtle bg-background/30`,children:[r(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:s(`backup.backupRunsPanel.run`,`Run`)}),r(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:s(`backup.backupRunsPanel.state`,`State`)}),r(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:s(`backup.backupRunsPanel.progress`,`Progress`)}),r(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:s(`backup.backupRunsPanel.destinations`,`Destinations`)}),r(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:s(`backup.backupRunsPanel.timing`,`Timing`)}),r(`th`,{className:`text-right px-3 py-1.5 font-medium w-28`,children:s(`backup.backupRunsPanel.actions`,`Actions`)})]})}),r(`tbody`,{children:f.map(e=>r(yn,{run:e,canceling:i===e.id,onCancelRequest:a,now:o},e.id))})]})})]})}function yn({run:t,canceling:n,onCancelRequest:i,now:a}){let{t:o}=J(),s=hn(t);return e(`tr`,{className:`border-t border-border hover:bg-primary/5 align-top`,children:[r(`td`,{className:`px-3 py-2`,children:r(`div`,{className:`text-foreground`,title:t.id,children:t.label??r(`span`,{className:`text-foreground-subtle italic`,children:o(`backup.runsPanel.manual`)})})}),e(`td`,{className:`px-3 py-2`,children:[r(bn,{run:t}),t.state===`failed`&&t.error!==void 0&&r(`div`,{className:`mt-1 text-[10px] text-danger max-w-56 truncate`,title:t.error,children:t.error})]}),r(`td`,{className:`px-3 py-2`,children:r(xn,{run:t})}),r(`td`,{className:`px-3 py-2`,children:r(Sn,{run:t})}),r(`td`,{className:`px-3 py-2 text-foreground-subtle tabular-nums`,children:r(Cn,{run:t,now:a})}),r(`td`,{className:`px-3 py-2`,children:r(`div`,{className:`flex justify-end`,children:s&&e(N,{variant:`unstyled`,onClick:()=>i(t),disabled:n,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:t.state===`queued`?o(`backup.backupRunsPanel.removeThisRunFromThe`,`Remove this run from the queue before it starts`):o(`backup.backupRunsPanel.stopThisRunTheHalf`,`Stop this run — the half-written archive is discarded`),children:[n?r(S,{className:`h-3 w-3 animate-spin`}):r(re,{className:`h-3 w-3`}),t.state===`queued`?o(`common.cancel`,`Cancel`):o(`backup.backupRunsPanel.stop`,`Stop`)]})})})]})}function bn({run:t}){let{t:n}=J();switch(t.state){case`queued`:return e(`span`,{className:`inline-flex items-center gap-1 rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:[r(p,{className:`h-3 w-3`}),n(`backup.backupRunsPanel.queued`,`Queued`)]});case`running`:return e(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:[r(S,{className:`h-3 w-3 animate-spin`}),t.phase===`uploading`?n(`backup.backupRunsPanel.uploading`,`Uploading`):n(`backup.backupRunsPanel.buildingArchive`,`Building archive`)]});case`succeeded`:return e(`span`,{className:`inline-flex items-center gap-1 rounded bg-success/10 px-1.5 py-0.5 text-[10px] font-medium text-success`,children:[r(C,{className:`h-3 w-3`}),n(`backup.backupRunsPanel.succeeded`,`Succeeded`)]});case`failed`:return e(`span`,{className:`inline-flex items-center gap-1 rounded bg-danger/10 px-1.5 py-0.5 text-[10px] font-medium text-danger`,children:[r(x,{className:`h-3 w-3`}),n(`backup.backupRunsPanel.failed`,`Failed`)]});case`cancelled`:return e(`span`,{className:`inline-flex items-center gap-1 rounded bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:text-amber-300`,title:n(`backup.backupRunsPanel.stoppedBeforeCompletingEveryDestination`,`Stopped before completing every destination — not a success`),children:[r(he,{className:`h-3 w-3`}),n(`backup.backupRunsPanel.stopped`,`Stopped`)]})}}function xn({run:t}){let{t:n}=J();if(t.state===`queued`)return r(`span`,{className:`text-foreground-subtle`,children:t.queuePosition===void 0?r(`span`,{className:`italic`,children:n(`backup.backupRunsPanel.waitingItsTurn`,`waiting its turn`)}):e(`span`,{className:`inline-flex items-center gap-1`,children:[r(`span`,{className:t.queuePosition===1?`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`:`rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-medium`,children:wn(t.queuePosition)}),n(`backup.backupRunsPanel.inLine`,`in line`)]})});if(t.state===`running`&&t.phase===`building`)return e(`span`,{className:`inline-flex items-center gap-1.5 text-foreground`,children:[r(ve,{className:`h-3 w-3 text-primary`}),r(`span`,{className:`tabular-nums font-medium animate-pulse`,children:Y(t.stagedBytes)}),r(`span`,{className:`text-foreground-subtle`,children:n(`backup.backupRunsPanel.stagedSoFar`,`staged so far`)})]});if(t.state===`running`){let i=t.archiveSizeBytes;return e(`span`,{className:`inline-flex items-center gap-1.5 text-foreground`,children:[r(ge,{className:`h-3 w-3 text-primary`}),e(`span`,{className:`tabular-nums font-medium`,children:[Y(t.uploadedBytes),i===void 0?``:` / ${Y(i)}`]}),r(`span`,{className:`text-foreground-subtle`,children:n(`backup.backupRunsPanel.toCurrentDestination`,`to current destination`)})]})}let i=t.archiveSizeBytes??(t.stagedBytes>0?t.stagedBytes:void 0);return i===void 0?r(`span`,{className:`text-foreground-subtle italic`,children:`—`}):r(`span`,{className:`tabular-nums text-foreground`,children:n(`backup.runsPanel.archiveSize`,{size:Y(i)})})}function Sn({run:t}){let{t:n}=J(),i=t.destinationIds.length,a=t.completedDestinationIds.length,o=t.failedDestinationIds.length;return i===0?r(`span`,{className:`text-foreground-subtle italic`,children:n(`backup.backupRunsPanel.notResolvedYet`,`not resolved yet`)}):e(`div`,{className:`flex flex-col gap-0.5`,children:[r(`span`,{className:`text-foreground-subtle`,title:t.destinationIds.join(`, `),children:n(`backup.runsPanel.targets`,{count:i})}),e(`span`,{className:`inline-flex items-center gap-2 text-[10px]`,children:[a>0&&r(`span`,{className:`text-success`,title:n(`backup.backupRunsPanel.keptTheirArchive`,`Kept their archive: {{value1}}`,{value1:t.completedDestinationIds.join(`, `)}),children:n(`backup.runsPanel.completed`,{count:a})}),o>0&&r(`span`,{className:`text-danger`,title:n(`backup.backupRunsPanel.failed2`,`Failed: {{value1}}`,{value1:t.failedDestinationIds.join(`, `)}),children:n(`backup.runsPanel.failedCount`,{count:o})})]})]})}function Cn({run:t,now:n}){let{t:i}=J();return t.state===`queued`?r(`span`,{children:i(`backup.runsPanel.queuedAgo`,{elapsed:Tn(n-t.requestedAt)})}):t.startedAt===void 0?r(`span`,{children:`—`}):t.finishedAt===void 0?r(`span`,{children:i(`backup.runsPanel.runningFor`,{elapsed:Tn(n-t.startedAt)})}):e(`div`,{className:`flex flex-col gap-0.5`,children:[r(`span`,{children:En(t.finishedAt)}),r(`span`,{className:`text-[10px]`,children:i(`backup.runsPanel.took`,{elapsed:Tn(t.finishedAt-t.startedAt)})})]})}function wn(e){if(e<=1)return`next`;let t=e%100;if(t>=11&&t<=13)return`${e}th`;switch(e%10){case 1:return`${e}st`;case 2:return`${e}nd`;case 3:return`${e}rd`;default:return`${e}th`}}function Tn(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${String(t%60).padStart(2,`0`)}s`:`${Math.floor(n/60)}h ${String(n%60).padStart(2,`0`)}m`}function En(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}o();var Dn=[[`backup`,`list`]];function On({initialDestinationId:n,initialArchiveId:o,onClose:c,onScheduled:l}){let{t:u}=J(),d=s(),[f,p]=a(n&&o?2:1),[m,h]=a(n),[g,_]=a(o),[v,y]=a(new Set),[b,x]=a(``),{data:C}=be(),w=C??[],{data:ee,isLoading:T}=Fe({destinationId:m??``},{enabled:!!m}),te=ee??[];i(()=>{if(m!==void 0)return;let e=w.filter(e=>e.restoreSupported);e.length===1&&h(e[0].id)},[m,w]);let{data:E}=Se({destinationId:m??``,backupId:g??``},{enabled:!!m&&!!g}),D=t(()=>E?.locations??[],[E]);i(()=>{D.length!==0&&y(e=>e.size===0?new Set(D):e)},[D]);let O=Ie({onSuccess:()=>{d.invalidateQueries({queryKey:Dn}),l(),c()}}),re=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},k=te.find(e=>e.id===g),ie=k?.encryption!==void 0,ae=It(k?.databases,E?.sqliteSnapshots),A=Pt(ae),oe=!!m&&!!g,j=A||v.size>0,se=oe&&j&&!O.isPending&&(!ie||b.trim().length>0),ce=()=>{!m||!g||O.mutate({destinationId:m,backupId:g,...A?{}:{locations:[...v]},...ie?{backupSecretKey:b.trim()}:{}})};return r(P,{open:!0,onOpenChange:e=>!e&&c(),children:e(V,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(G,{children:[r(F,{children:u(`backup.restoreWizard.restoreBackup`,`Restore Backup`)}),r(`p`,{className:`text-xs text-foreground-subtle`,children:u(`backup.restoreWizard.stepOf`,{step:f,name:f===1?u(`backup.restoreWizard.pickSource`,`pick source`):f===2?u(`backup.restoreWizard.pickLocations`,`pick locations`):u(`backup.restoreWizard.confirmStep`)})})]}),e(z,{children:[f===1&&r(kn,{destinations:w,destinationId:m,onPickDestination:e=>{h(e),_(void 0),y(new Set)},archives:te,archivesLoading:T,archiveId:g,onPickArchive:_}),f===2&&r(An,{locations:D,picked:v,onToggle:re,databases:ae,snapshotsOnly:A}),f===3&&r(jn,{destinationName:w.find(e=>e.id===m)?.displayName??m??``,archive:k,picked:[...v],databases:ae,snapshotsOnly:A}),f===3&&k?.encryption!==void 0&&r(Mn,{keyId:k.encryption.keyId,value:b,onChange:x}),f===3&&O.error&&r(`p`,{role:`alert`,className:`px-4 pb-2 text-xs text-danger`,children:O.error.message})]}),e(I,{className:`justify-between`,children:[r(`div`,{children:f>1&&e(N,{variant:`outline`,size:`sm`,onClick:()=>p(e=>e===3?2:1),children:[r(ue,{className:`h-3 w-3`}),u(`common.back`,`Back`)]})}),e(`div`,{className:`flex items-center gap-2`,children:[r(N,{variant:`outline`,size:`sm`,onClick:c,children:u(`common.cancel`,`Cancel`)}),f<3?e(N,{size:`sm`,disabled:f===1&&!oe||f===2&&!j,onClick:()=>p(e=>e===1?2:3),children:[u(`common.next`,`Next`),r(ne,{className:`h-3 w-3`})]}):e(N,{size:`sm`,onClick:ce,disabled:!se,children:[O.isPending?r(S,{className:`h-3.5 w-3.5 animate-spin`}):r(M,{className:`h-3.5 w-3.5`}),u(`backup.restoreWizard.scheduleRestore`,`Schedule Restore`)]})]})]})]})})}function kn({destinations:t,destinationId:n,onPickDestination:i,archives:a,archivesLoading:o,archiveId:s,onPickArchive:c}){let{t:l}=J(),u=t.filter(e=>e.restoreSupported);return e(`div`,{className:`p-4 space-y-3`,children:[e(`div`,{className:`space-y-1.5`,children:[r(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:l(`backup.restoreWizard.destination`,`Destination`)}),r(ce,{value:n??``,onChange:e=>i(e.target.value),options:[{value:``,label:l(`backup.restoreWizard.selectDestination`,`Select destination…`)},...u.map(e=>({value:e.id,label:`${e.displayName} (${e.kind})`}))]})]}),e(`div`,{className:`space-y-1.5`,children:[r(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:l(`backup.restoreWizard.archive`,`Archive`)}),!n&&r(`div`,{className:`text-xs text-foreground-subtle italic`,children:l(`backup.restoreWizard.pickADestinationFirst`,`Pick a destination first.`)}),n&&o&&r(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:l(`backup.restoreWizard.readingArchives`,`Reading archives…`)}),n&&!o&&a.length===0&&r(`div`,{className:`text-xs text-foreground-subtle italic`,children:l(`backup.restoreWizard.noArchivesAvailableAtThis`,`No archives available at this destination.`)}),n&&a.length>0&&r(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:a.map(t=>{let n=s===t.id;return e(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs cursor-pointer ${n?`bg-primary/10`:`hover:bg-primary/5`}`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(De,{name:`archive`,checked:n,onChange:()=>c(t.id),className:`accent-primary`}),e(`div`,{children:[e(`div`,{className:`flex items-center gap-1 font-medium text-foreground`,children:[t.encryption!==void 0&&r(T,{className:`h-3 w-3 text-success`,"aria-label":l(`backup.restoreWizard.encryptedKey`,`encrypted (key {{keyId}})`,{keyId:t.encryption.keyId})}),t.label??t.id]}),r(`div`,{className:`text-[10px] text-foreground-subtle`,children:new Date(t.createdAt).toLocaleString()}),r(`div`,{className:`pt-1`,children:r(Z,{databases:It(t.databases,void 0)})})]})]}),r(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:Y(t.sizeBytes)})]},t.id)})})]})]})}function An({locations:t,picked:n,onToggle:i,databases:a,snapshotsOnly:o}){let{t:s}=J();return o?e(`div`,{className:`space-y-3 p-4`,children:[e(`div`,{className:`space-y-1.5`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`backup.restoreWizard.databasesInThisArchive`,`Databases in this archive`)}),r(Z,{databases:a})]}),r(`div`,{className:`rounded border border-info/30 bg-info/10 px-3 py-2 text-[11px] text-info`,children:s(`backup.restoreWizard.snapshotsOnlyRestoringThisArchive`,`Snapshots only: restoring this archive replaces just these databases. It does NOT touch configuration, addons, addon data or certificates.`)})]}):t.length===0?r(`div`,{className:`p-4`,children:r(`div`,{className:`text-xs text-foreground-subtle`,children:s(`backup.restoreWizard.loadingArchiveManifestIfThis`,`Loading archive manifest… If this persists, the archive may predate manifests — restoring will apply everything in the tarball.`)})}):e(`div`,{className:`p-4 space-y-3`,children:[e(`div`,{className:`space-y-1.5`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`backup.restoreWizard.databasesInThisArchive`,`Databases in this archive`)}),r(Z,{databases:a})]}),r(`div`,{className:`rounded border border-warning/30 bg-warning/10 px-3 py-2 text-[11px] text-warning`,children:s(`backup.restoreWizard.selectedEntriesWillOverwriteLive`,`Selected entries will overwrite live data on the next server restart. Unchecked entries stay current.`)}),e(`div`,{className:`space-y-1.5`,children:[r(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:s(`common.apply`,`Apply`)}),r(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:t.map(t=>e(`label`,{className:`flex items-center gap-2 px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[r(b,{checked:n.has(t),onChange:()=>i(t),className:`accent-primary`}),r(`span`,{className:`font-mono text-foreground`,children:t}),r(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:Fn(t)})]},t))})]})]})}function jn({destinationName:t,archive:n,picked:i,databases:a,snapshotsOnly:o}){let{t:s}=J();return e(`div`,{className:`p-4 space-y-3 text-xs`,children:[r(`div`,{className:`rounded border border-warning/30 bg-warning/10 px-3 py-2 text-warning`,children:s(`backup.restoreWizard.restoreIsAppliedAtNext`,`Restore is applied at next server boot. Active connections will drop when you restart.`)}),e(`dl`,{className:`space-y-1.5`,children:[r(Nn,{term:`Destination`,value:t}),r(Nn,{term:`Archive`,value:n?.label??n?.id??`—`}),n&&r(Nn,{term:`Created`,value:`${new Date(n.createdAt).toLocaleString()} · ${Y(n.sizeBytes)}`}),e(`div`,{className:`flex justify-between gap-3`,children:[r(`dt`,{className:`text-foreground-subtle`,children:s(`backup.restoreWizard.databases`,`Databases`)}),r(`dd`,{className:`text-right`,children:r(Z,{databases:a})})]}),r(Nn,{term:`Locations`,value:o?`none (configuration is not touched)`:i.length>0?i.join(`, `):`— (full archive)`})]})]})}function Mn({keyId:t,value:n,onChange:i}){let{t:a}=J();return e(`div`,{className:`space-y-1.5 px-4 pb-3`,children:[r(`label`,{htmlFor:`restore-backup-key`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:a(`backup.restoreWizard.backupKey`,`Backup key`)}),r(K,{id:`restore-backup-key`,type:`password`,autoComplete:`off`,spellCheck:!1,value:n,onChange:e=>i(e.target.value),placeholder:a(`backup.restoreWizard.camstackBackupSecretV1`,`camstack-backup-secret-v1:…`),className:`w-full rounded border border-border bg-background px-2 py-1.5 font-mono text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(pt,{i18nKey:`backup.restoreWizard.encryptedTo`,values:{keyId:t},components:{mono:r(`span`,{className:`font-mono`})}})})]})}function Nn({term:t,value:n}){return e(`div`,{className:`flex justify-between gap-3`,children:[r(`dt`,{className:`text-foreground-subtle`,children:t}),r(`dd`,{className:`text-foreground font-mono text-right truncate`,children:n})]})}var Pn={db:`Database`,addons:`Addon configs`,"addons-data":`Addon data`,tls:`TLS certificates`,cache:`Cache`,data:`Top-level data`};function Fn(e){return Pn[e]??``}o();function In(){let{t}=J(),n=O(),o=at(),{state:s,openNew:c,openEdit:u,close:d}=qe({editKey:`edit`,newKey:`new`}),f=je(),p=f.data??[],[m,h]=a(null),[g,_]=a(!1),[v,y]=a(!1),[b,x]=a(!1),C=s.mode===`edit`?p.find(e=>e.id===s.id)??null:null;i(()=>{s.mode===`edit`&&!f.isLoading&&C===null&&d()},[s.mode,f.isLoading,C,d]);let w=s.mode===`new`||s.mode===`edit`&&C!==null,T=async()=>{await n({title:t(`system.backup.restartServerNow`,`Restart server now?`),message:t(`system.backup.activeConnectionsWillDropAnd`,`Active connections will drop and the apply-backup hook will run before boot.`),confirmLabel:t(`system.backup.restart`,`Restart`),variant:`warning`})&&o.mutate({confirm:!0})};return e(_t,{embedded:!0,children:[e(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,"data-testid":`backup-actions`,children:[e(N,{variant:`outline`,size:`sm`,type:`button`,onClick:()=>x(!0),"data-testid":`backup-now`,children:[r(l,{className:`h-3.5 w-3.5`}),t(`system.backup.backUpNow`,`Back up now`)]}),e(N,{variant:`outline`,size:`sm`,type:`button`,onClick:()=>_(!0),children:[r(M,{className:`h-3.5 w-3.5`}),t(`system.backup.restore`,`Restore…`)]}),e(N,{size:`sm`,type:`button`,onClick:c,"data-testid":`backup-new-entry`,children:[r(ee,{className:`h-3.5 w-3.5`}),t(`system.backup.newEntry`,`New entry`)]})]}),v&&r(`div`,{className:`rounded-lg border border-warning/30 bg-warning/10 px-3 py-2.5 text-xs text-warning`,children:e(`div`,{className:`flex items-center justify-between gap-3`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(M,{className:`h-3.5 w-3.5`}),r(`span`,{children:t(`system.backup.restoreScheduledRestartTheServer`,`Restore scheduled. Restart the server to apply.`)})]}),e(N,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>{T()},disabled:o.isPending,children:[o.isPending?r(S,{className:`h-3.5 w-3.5 animate-spin`}):r(M,{className:`h-3.5 w-3.5`}),t(`system.backup.restartNow`,`Restart Now`)]})]})}),r(rn,{}),r(_n,{}),r(Ut,{onEdit:e=>u(e.id),onOpenRestoreWizard:e=>h(e)}),w&&r(fn,{entry:C,onClose:d,onSaved:d}),b&&r($t,{onClose:()=>x(!1)}),(m||g)&&r(On,{...m?{initialDestinationId:m.destinationId,initialArchiveId:m.archiveId}:{},onClose:()=>{h(null),_(!1)},onScheduled:()=>y(!0)})]})}var Ln=[`locked`,`reset`,`shares-backup`,`recovery-key`,`rotation-pending`,`orphans`],Rn={"key-missing":`helpers.keychainNotices.lockedKeyMissing`,"wrong-key":`helpers.keychainNotices.lockedWrongKey`,"key-file-unreadable":`helpers.keychainNotices.lockedKeyFileUnreadable`,"store-unavailable":`helpers.keychainNotices.lockedStoreUnavailable`,"not-initialized":`helpers.keychainNotices.lockedNotInitialized`,"decrypt-failed":`helpers.keychainNotices.lockedDecryptFailed`};function zn(e){let t=Rn[e];return t===void 0?e:q.t(t)}function Bn({status:e,reset:t,pendingReentry:n,orphans:r}){let i=e.keychain.state===`locked`,a=e.keySource??e.configuredSource,o=[];return e.keychain.state===`locked`&&o.push({id:`locked`,tone:`danger`,title:q.t(`helpers.keychainNotices.locked`,{reason:zn(e.keychain.reason)})}),t!==null&&t.acknowledgedAt===null&&o.push({id:`reset`,tone:`danger`,title:n>0?q.t(`helpers.keychainNotices.resetPending`,{count:n}):q.t(`helpers.keychainNotices.resetDone`)}),a.sharesBackupWithDatabase&&o.push({id:`shares-backup`,tone:`warning`,title:q.t(`helpers.keychainNotices.sharesBackup`)}),!i&&e.recoveryKeyDownloadedAt===null&&o.push({id:`recovery-key`,tone:`warning`,title:q.t(`helpers.keychainNotices.recoveryKey`)}),!i&&e.rotationPending&&o.push({id:`rotation-pending`,tone:`info`,title:q.t(`helpers.keychainNotices.rotationPending`)}),!i&&r>0&&o.push({id:`orphans`,tone:`info`,title:q.t(`helpers.keychainNotices.orphans`,{count:r})}),[...o].sort((e,t)=>Ln.indexOf(e.id)-Ln.indexOf(t.id))}var Vn={dateStyle:`short`,timeStyle:`short`};function Q(e){return e===null?`—`:new Date(e).toLocaleString(void 0,Vn)}function Hn({value:t,copyValue:n,srLabel:i,maxWidthClass:a,className:o}){let s=n??t;return e(`span`,{className:u(`flex min-w-0 items-center gap-0.5`,a),children:[r(`span`,{className:u(`min-w-0 truncate font-mono`,o),title:s,children:t}),r(Te,{value:s,srLabel:i,className:`h-6 shrink-0 px-1.5`})]})}o();var Un=new Set([`reveal`,`download-recovery-key`,`rotate-master-key`,`reset`]);function Wn(e){return[{key:`at`,header:e(`system.keychainAuditTable.colWhen`),render:e=>Q(e.at)},{key:`action`,header:e(`system.keychainAuditTable.colAction`),render:e=>r(L,{variant:Un.has(e.action)?`warning`:`default`,children:e.action})},{key:`actor`,header:e(`system.keychainAuditTable.colActor`),render:e=>r(`span`,{className:`font-mono`,children:e.actor})},{key:`ref`,header:e(`system.keychainAuditTable.colRef`),render:e=>e.ref===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):r(Hn,{value:e.ref,srLabel:`secret ref`,maxWidthClass:`max-w-[22rem]`})},{key:`detail`,header:e(`system.keychainAuditTable.colDetail`),render:e=>r(`span`,{className:`text-foreground-muted`,children:e.detail??``})}]}function Gn({entries:n}){let{t:i}=J(),[o,s]=a(0),c=t(()=>Wn(i),[i]);if(n===void 0)return r(`p`,{className:`text-xs text-foreground-subtle`,children:i(`common.loading`,`Loading…`)});let l=Math.max(1,Math.ceil(n.length/25)),u=Math.min(o,l-1),d=u*25,f=n.slice(d,d+25);return e(`div`,{className:`space-y-2`,children:[r(R,{columns:c,rows:f,rowKey:e=>e.id,minWidthPx:760,emptyMessage:i(`secrets.keychainAuditTable.nothingHasBeenAuditedYet`,`Nothing has been audited yet.`)}),n.length>25&&e(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-[11px] text-foreground-subtle`,children:[r(`span`,{children:i(n.length>=500?`system.keychainAuditTable.rangeRecent`:`system.keychainAuditTable.range`,{from:d+1,to:d+f.length,total:n.length})}),e(`span`,{className:`inline-flex items-center gap-1`,children:[r(N,{size:`sm`,variant:`outline`,"aria-label":i(`secrets.keychainAuditTable.previousPage`,`Previous page`),disabled:u===0,onClick:()=>s(u-1),children:r(te,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),e(`span`,{className:`tabular-nums`,children:[u+1,` / `,l]}),r(N,{size:`sm`,variant:`outline`,"aria-label":i(`secrets.keychainAuditTable.nextPage`,`Next page`),disabled:u>=l-1,onClick:()=>s(u+1),children:r(g,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]})]})]})}function Kn(e,t){switch(e){case`locked`:return r(N,{size:`sm`,variant:`danger`,disabled:t.busy,onClick:t.onReset,children:q.t(`secrets.keychainNoticeContent.resetKeychain`,`Reset keychain`)});case`reset`:return r(N,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onAcknowledgeReset,children:q.t(`secrets.keychainNoticeContent.dismiss`,`Dismiss`)});case`recovery-key`:return r(N,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onDownload,children:q.t(`secrets.keychainNoticeContent.download`,`Download`)});case`rotation-pending`:return r(N,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onRotate,children:q.t(`secrets.keychainNoticeContent.rotate`,`Rotate`)});case`orphans`:return r(N,{size:`sm`,variant:`outline`,onClick:t.onShowOrphans,children:q.t(`secrets.keychainNoticeContent.review`,`Review`)});case`shares-backup`:return null}}function qn(e,t){switch(e){case`locked`:return r(`p`,{children:q.t(`secrets.keychainNoticeContent.noValueCanBeRead`,`No value can be read or stored. If the master key is lost for good, Reset archives every stored value and starts a new keychain; every secret field then reads “not set”.`)});case`reset`:return t.reset===null?null:r(Jn,{reset:t.reset,pending:t.pendingReentry});case`shares-backup`:return r(`p`,{children:r(pt,{i18nKey:`secrets.keychainNoticeContent.backupKeyFile`,components:{code:r(`code`,{className:`font-mono`})}})});case`recovery-key`:return r(`p`,{children:q.t(`secrets.keychainNoticeContent.withoutACopyOfThe`,`Without a copy of the master key, the stored values cannot be recovered.`)});case`rotation-pending`:return r(`p`,{children:q.t(`secrets.keychainNoticeContent.theKeychainUnlockedWithA`,`The keychain unlocked with a previous key. Rotate to move onto the configured one.`)});case`orphans`:return null}}function Jn({reset:t,pending:n}){let{t:i}=J(),a=t.actor===`trigger-file`?i(`secrets.keychainNoticeContent.resetByTrigger`):i(`secrets.keychainNoticeContent.resetByAdmin`,{actor:t.actor});return e(`div`,{className:`space-y-1.5`,children:[r(`p`,{children:i(`secrets.keychainNoticeContent.resetDetail`,{when:Q(t.at),by:a,archived:t.archived})}),n.length>0&&r(`ul`,{className:`max-h-40 space-y-0.5 overflow-y-auto rounded-md border border-border bg-background p-2 font-mono text-[11px] text-foreground`,children:n.map(t=>e(`li`,{className:`break-all`,children:[t.owner,` · `,t.scope,` · `,t.fieldPath]},t.ref))})]})}o();var Yn=2,Xn={danger:{icon:pe,text:`text-danger`,border:`border-danger/40`},warning:{icon:v,text:`text-warning`,border:`border-warning/40`},info:{icon:h,text:`text-info`,border:`border-border`}};function Zn({notices:t,renderAction:n,renderDetail:i}){let{t:o}=J(),[s,c]=a(!1),l=t[0];if(l===void 0)return null;let d=t.length>Yn,f=d&&!s?t.slice(0,1):t,p=t.length-f.length;return e(`section`,{"aria-label":o(`secrets.keychainNotices.keychainNotices`,`Keychain notices`),className:u(`rounded-lg border bg-surface`,Xn[l.tone].border),children:[r(`ul`,{className:`divide-y divide-border`,children:f.map(e=>r(Qn,{notice:e,action:n(e.id),detail:i(e.id)},e.id))}),d&&r(`div`,{className:`border-t border-border px-3 py-1`,children:e(N,{size:`sm`,variant:`ghost`,"aria-expanded":s,onClick:()=>c(e=>!e),children:[r(fe,{className:u(`h-3.5 w-3.5 transition-transform`,s&&`rotate-180`),"aria-hidden":!0}),s?o(`secrets.keychainNotices.showLess`,`Show less`):o(`secrets.keychainNotices.more`,`{{hidden}} more`,{hidden:p})]})})]})}function Qn({notice:t,action:n,detail:i}){let{t:o}=J(),[s,c]=a(!1),l=Xn[t.tone],d=l.icon,f=i!=null,p=`keychain-notice-${t.id}`;return e(`li`,{className:`px-3 py-2`,children:[e(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[e(`p`,{className:`flex min-w-0 flex-1 items-start gap-2 text-xs text-foreground`,children:[r(d,{className:u(`mt-0.5 h-3.5 w-3.5 shrink-0`,l.text),"aria-hidden":!0}),r(`span`,{className:`min-w-0 break-words`,children:t.title})]}),e(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1.5 pl-5 sm:pl-0`,children:[f&&r(N,{size:`sm`,variant:`ghost`,"aria-expanded":s,"aria-controls":p,onClick:()=>c(e=>!e),children:o(`secrets.keychainNotices.details`,`Details`)}),n]})]}),f&&s&&r(`div`,{id:p,className:`mt-2 pl-5 text-xs text-foreground-muted`,children:i})]})}var $n={"mounted-file":`Mounted key file (/run/secrets)`,"previous-mounted-file":`Previous mounted key file`,platform:`OS keychain`,"default-file":`Default key file (data volume)`},er=8;function tr({status:t,busy:n,onDownload:i,onRotate:a,onPurge:o}){let{t:s}=J(),c=t.keychain.state===`locked`,l=t.keySource??t.configuredSource;return r(Ue,{headingId:`keychain-status`,title:s(`secrets.keychainStatusCard.keychain`,`Keychain`),icon:me,actions:e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[t.retiredWraps>0&&r(N,{size:`sm`,variant:`ghost`,disabled:n||c,onClick:o,children:s(`secrets.keychainStatusCard.purge`,{count:t.retiredWraps})}),r(N,{size:`sm`,variant:`outline`,disabled:n||c,onClick:a,children:s(`secrets.keychainStatusCard.rotateKey`,`Rotate key`)}),r(N,{size:`sm`,variant:`outline`,disabled:n||c,onClick:i,children:s(`secrets.keychainStatusCard.downloadRecoveryKey`,`Download recovery key`)})]}),children:e(`dl`,{className:`${d} grid grid-cols-1 gap-x-6 gap-y-3 sm:grid-cols-2 xl:grid-cols-4`,children:[e(nr,{label:s(`secrets.keychainStatusCard.state`,`State`),children:[c?e(L,{variant:`danger`,className:`gap-1`,children:[r(T,{className:`h-3 w-3`,"aria-hidden":!0}),s(`secrets.keychainStatusCard.locked`,`Locked`)]}):e(L,{variant:`success`,className:`gap-1`,children:[r(f,{className:`h-3 w-3`,"aria-hidden":!0}),s(`secrets.keychainStatusCard.unlocked`,`Unlocked`)]}),r(`span`,{className:`ml-2 text-foreground-subtle`,children:s(`common.stored`,{count:t.secretCount})})]}),e(nr,{label:s(`secrets.keychainStatusCard.keySource`,`Key source`),children:[r(`span`,{className:`block`,children:$n[l.kind]}),l.path!==void 0&&r(Hn,{value:l.path,srLabel:`key path`})]}),r(nr,{label:s(`secrets.keychainStatusCard.fingerprint`,`Fingerprint`),children:t.fingerprint===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):e(`span`,{className:`inline-flex items-center gap-0.5`,children:[r(`span`,{className:`font-mono`,title:t.fingerprint,children:t.fingerprint.slice(0,er)}),r(Te,{value:t.fingerprint,srLabel:`fingerprint`})]})}),r(nr,{label:s(`secrets.keychainStatusCard.recoveryKey`,`Recovery key`),children:t.recoveryKeyDownloadedAt===null?r(L,{variant:`warning`,children:s(`secrets.keychainStatusCard.notTaken`,`Not taken`)}):r(`span`,{children:s(`secrets.keychainStatusCard.taken`,{when:Q(t.recoveryKeyDownloadedAt)})})})]})})}function nr({label:t,children:n}){return e(`div`,{className:`min-w-0 text-xs`,children:[r(`dt`,{className:`text-foreground-subtle`,children:t}),r(`dd`,{className:`mt-0.5 min-w-0 text-foreground`,children:n})]})}o();var rr=1e3;function ir({revealed:t,onClose:n}){let{t:o}=J(),[s,l]=a($e);i(()=>{if(t===null)return;let e=Date.now();l($e);let r=setTimeout(n,$e),i=setInterval(()=>l(Math.max(0,$e-(Date.now()-e))),rr);return()=>{clearTimeout(r),clearInterval(i)}},[t,n]);let u=Math.ceil(s/1e3);return r(P,{open:t!==null,onOpenChange:e=>!e&&n(),children:r(V,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:t!==null&&e(c,{children:[e(G,{children:[r(F,{className:`break-all`,children:t.entry.fieldPath}),e(Ee,{className:`break-all`,children:[t.entry.owner,` · `,t.entry.scope]})]}),r(z,{children:r(`pre`,{"data-testid":`revealed-value`,className:`whitespace-pre-wrap break-all rounded-md border border-border bg-background p-3 font-mono text-xs text-foreground`,children:t.value})}),e(I,{className:`flex-col items-stretch gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[r(`p`,{className:`text-[11px] text-foreground-subtle`,children:o(`secrets.revealDialog.recorded`,{seconds:u})}),e(`div`,{className:`flex justify-end gap-2`,children:[r(Te,{value:t.value,label:o(`common.copy`,`Copy`),srLabel:`revealed value`}),r(N,{size:`sm`,variant:`outline`,onClick:n,children:o(`secrets.revealDialog.hide`,`Hide`)})]})]})]})})})}var ar={orphan:{labelKey:`secrets.secretsTableState.usageOrphan`,variant:`warning`,hintKey:`secrets.secretsTableState.usageOrphanHint`,rank:0},unknown:{labelKey:`secrets.secretsTableState.usageUnknown`,variant:`default`,hintKey:`secrets.secretsTableState.usageUnknownHint`,rank:1},"in-use":{labelKey:`secrets.secretsTableState.usageInUse`,variant:`success`,hintKey:`secrets.secretsTableState.usageInUseHint`,rank:2}},or=[{id:`all`,labelKey:`common.all`},{id:`in-use`,labelKey:`secrets.secretsTableState.usageInUse`},{id:`orphan`,labelKey:`secrets.secretsTableState.filterOrphans`},{id:`unknown`,labelKey:`secrets.secretsTableState.usageUnknown`}],sr=`system`;function cr(t){let{t:n}=J(),{secrets:i,filter:a,onFilterChange:o,onDeleteOrphans:s,deleting:c,locked:l}=t;if(i===void 0)return r(`p`,{className:`text-xs text-foreground-subtle`,children:n(`common.loading`,`Loading…`)});let u=e=>e===`all`?i.length:i.filter(t=>t.usage===e).length,d=i.filter(e=>e.usage===`orphan`).map(e=>e.ref),f=a===`all`?i:i.filter(e=>e.usage===a);return e(`div`,{className:`space-y-2`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[r(`div`,{className:`flex flex-wrap gap-1`,role:`group`,"aria-label":n(`secrets.secretsTable.filterByUsage`,`Filter by usage`),children:or.map(t=>e(N,{size:`sm`,variant:a===t.id?`secondary`:`ghost`,"aria-pressed":a===t.id,className:a===t.id?`ring-1 ring-border`:void 0,onClick:()=>o(t.id),children:[n(t.labelKey),r(`span`,{className:`text-foreground-subtle tabular-nums`,children:u(t.id)})]},t.id))}),d.length>0&&e(N,{size:`sm`,variant:`outline`,className:`ml-auto`,disabled:c||l,onClick:()=>s(d),children:[r(D,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),n(`secrets.secretsTableState.deleteOrphans`,{count:d.length})]})]}),r(R,{columns:ur(t),rows:f,rowKey:e=>e.ref,minWidthPx:860,maxBodyHeight:We,defaultSort:{columnKey:`owner`,dir:`asc`},emptyMessage:i.length===0?n(`secrets.secretsTable.noValueIsStoredIn`,`No value is stored in the keychain yet.`):n(`secrets.secretsTable.noStoredValueMatchesThis`,`No stored value matches this filter.`)})]})}function lr({owner:t}){let{t:n}=J();return e(`span`,{className:`flex items-center gap-2`,children:[r(yt,{addonId:t,fallback:t===sr?A:_,tileClassName:`bg-surface-hover text-foreground-subtle`,size:`sm`}),r(`span`,{className:`font-medium`,children:t===sr?n(`secrets.secretsTable.hubSystem`,`Hub (system)`):t})]})}function ur({locked:t,onReveal:n,revealing:i}){return[{key:`owner`,header:q.t(`secrets.secretsTable.owner`,`Owner`),render:e=>r(lr,{owner:e.owner}),sortValue:e=>e.owner},{key:`scope`,header:q.t(`secrets.secretsTable.scope`,`Scope`),render:e=>r(`span`,{className:`block max-w-[11rem] truncate font-mono`,title:e.scope,children:e.scope}),sortValue:e=>e.scope},{key:`field`,header:q.t(`secrets.secretsTable.field`,`Field`),render:e=>r(Hn,{value:e.fieldPath,copyValue:e.ref,srLabel:`secret ref`,maxWidthClass:`max-w-[16rem]`}),sortValue:e=>e.fieldPath},{key:`updated`,header:q.t(`secrets.secretsTable.updated`,`Updated`),render:e=>Q(e.updatedAt),sortValue:e=>e.updatedAt},{key:`last-read`,header:q.t(`secrets.secretsTable.lastRead`,`Last read`),render:e=>Q(e.lastReadAt),sortValue:e=>e.lastReadAt},{key:`status`,header:q.t(`secrets.secretsTable.status`,`Status`),render:e=>r(L,{variant:ar[e.usage].variant,title:q.t(ar[e.usage].hintKey),children:q.t(ar[e.usage].labelKey)}),sortValue:e=>ar[e.usage].rank},{key:`actions`,header:``,align:`right`,notSortableReason:`Actions`,render:a=>e(N,{size:`sm`,variant:`ghost`,disabled:t||i,"aria-label":q.t(`secrets.secretsTable.reveal`,`Reveal {{fieldPath}}`,{fieldPath:a.fieldPath}),title:t?q.t(`secrets.secretsTable.theKeychainIsLocked`,`The keychain is locked`):q.t(`secrets.secretsTable.revealAudited`,`Reveal (audited)`),onClick:()=>n(a),children:[r(ie,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),q.t(`secrets.secretsTable.reveal2`,`Reveal`)]})}]}function dr(e){return e instanceof Error?e.message:String(e)}function fr(e){let{t}=J(),n=O(),r=j(),i=oe(),a=Je(),o=et(),s=Qe(),c=lt(),l=Ke(),u=Ge(),d=async(t,n)=>{try{await n()}catch(e){await r({title:t,message:dr(e),variant:`danger`})}e()};return{busy:a.isPending||o.isPending||s.isPending||c.isPending,deleting:u.isPending,download:async()=>{await n({title:t(`secrets.useKeychainActions.downloadTitle`),message:t(`secrets.useKeychainActions.downloadMessage`),confirmLabel:t(`secrets.useKeychainActions.downloadConfirm`),variant:`warning`})&&await d(t(`secrets.useKeychainActions.downloadRefused`),async()=>{let e=await a.mutateAsync({});await i({title:t(`secrets.useKeychainActions.recoveryTitle`,{fingerprint:e.fingerprint}),message:t(`secrets.useKeychainActions.recoveryMessage`),defaultValue:e.key,readOnly:!0,confirmLabel:t(`secrets.useKeychainActions.recoveryDone`)})})},rotate:async()=>{await n({title:t(`secrets.useKeychainActions.rotateTitle`),message:t(`secrets.useKeychainActions.rotateMessage`),confirmLabel:t(`secrets.useKeychainActions.rotateConfirm`),variant:`warning`})&&await d(t(`secrets.useKeychainActions.rotateRefused`),async()=>{let e=await o.mutateAsync({});await r({title:t(`secrets.useKeychainActions.rotatedTitle`),message:t(`secrets.useKeychainActions.rotatedMessage`,{fingerprint:e.fingerprint})})})},purge:async()=>{await n({title:t(`secrets.useKeychainActions.purgeTitle`),message:t(`secrets.useKeychainActions.purgeMessage`),confirmLabel:t(`secrets.useKeychainActions.purgeConfirm`),variant:`warning`})&&await d(t(`secrets.useKeychainActions.purgeRefused`),async()=>{await s.mutateAsync({})})},reset:async()=>{await i({title:t(`secrets.useKeychainActions.resetTitle`),message:t(`secrets.useKeychainActions.resetMessage`,{confirmation:`RESET KEYCHAIN`}),confirmLabel:t(`secrets.useKeychainActions.resetConfirm`),validate:e=>e===`RESET KEYCHAIN`?null:t(`secrets.useKeychainActions.resetMismatch`)})===`RESET KEYCHAIN`&&await d(t(`secrets.useKeychainActions.resetRefused`),async()=>{await c.mutateAsync({confirm:de})})},acknowledgeReset:async()=>{await d(t(`secrets.useKeychainActions.dismissFailed`),async()=>{await l.mutateAsync({})})},deleteOrphans:async e=>{await n({title:t(`secrets.useKeychainActions.orphansTitle`,{count:e.length}),message:t(`secrets.useKeychainActions.orphansMessage`),confirmLabel:t(`secrets.useKeychainActions.orphansConfirm`),variant:`danger`})&&await d(t(`secrets.useKeychainActions.orphansRefused`),async()=>{let n=await u.mutateAsync({refs:[...e]});n.kept.length>0&&await r({title:t(`secrets.useKeychainActions.keptTitle`),message:t(`secrets.useKeychainActions.keptMessage`,{deleted:n.deleted.length,kept:n.kept.length})})})}}}o();var pr=`secretsView`;function mr(){let[e,t]=mt();return[e.get(pr)===`audit`?`audit`:`values`,n=>{let r=new URLSearchParams(e);n===`values`?r.delete(pr):r.set(pr,n),t(r,{replace:!0})}]}function hr(){let{t:i}=J(),o=Ye({}),s=ye({}),c=ze({limit:500}),l=it({}),u=st(),d=j(),[f,p]=mr(),[m,h]=a(`all`),[g,_]=a(null),v=fr(()=>{o.refetch(),s.refetch(),c.refetch(),l.refetch()}),y=o.data?.keychain.state===`locked`,b=t(()=>(s.data??[]).filter(e=>e.usage===`orphan`).length,[s.data]),x=t(()=>o.data===void 0?[]:Bn({status:o.data,reset:l.data?.reset??null,pendingReentry:l.data?.pendingReentry.length??0,orphans:b}),[o.data,l.data,b]),S={reset:l.data?.reset??null,pendingReentry:l.data?.pendingReentry??[],busy:v.busy,onReset:()=>void v.reset(),onAcknowledgeReset:()=>void v.acknowledgeReset(),onDownload:()=>void v.download(),onRotate:()=>void v.rotate(),onShowOrphans:()=>{h(`orphan`),p(`values`)}},C=async e=>{try{_({entry:e,value:(await u.mutateAsync({ref:e.ref})).value}),s.refetch()}catch(e){await d({title:i(`admin.system.secrets.revealRefused`,`Reveal refused`),message:dt(e),variant:`danger`})}},w=n(()=>_(null),[]);return e(_t,{embedded:!0,icon:me,title:i(`admin.system.secrets.secrets`,`Secrets`),subtitle:i(`admin.system.secrets.passwordsTokensAndKeysEncrypted`,`Passwords, tokens and keys, encrypted in the hub keychain. Values leave the hub only through an audited reveal.`),children:[r(Zn,{notices:x,renderAction:e=>Kn(e,S),renderDetail:e=>qn(e,S)}),o.data!==void 0&&r(tr,{status:o.data,busy:v.busy,onDownload:S.onDownload,onRotate:S.onRotate,onPurge:()=>void v.purge()}),e(Xe,{value:f,onValueChange:e=>p(e===`audit`?`audit`:`values`),children:[e(ct,{children:[r(W,{value:`values`,children:i(`admin.system.secrets.storedValues`,`Stored values`)}),r(W,{value:`audit`,children:i(`admin.system.secrets.audit`,`Audit`)})]}),r(ot,{value:`values`,children:r(cr,{secrets:s.data,locked:y,filter:m,onFilterChange:h,onReveal:e=>void C(e),revealing:u.isPending,onDeleteOrphans:e=>void v.deleteOrphans(e),deleting:v.deleting})}),r(ot,{value:`audit`,children:r(Gn,{entries:c.data})})]}),r(ir,{revealed:g,onClose:w})]})}o();function gr(e){return Object.entries(e).map(([e,t])=>`${e} ${t}`).join(` · `)}function _r(e){return e.reduce((e,t)=>e+Object.values(t.stores).reduce((e,t)=>e+t,0),0)}function vr(){let{t}=J(),n=O(),i=Ze(),[o,s]=a(null),[l,u]=a(null),d=async e=>{u(null);try{s(await i.mutateAsync({confirm:e}))}catch(e){u(e instanceof Error?e.message:String(e))}},f=async()=>{o===null||o.status!==`dry-run`||await n({title:t(`systemPage.deletedDevices.confirmTitle`,`Delete the data of deleted devices?`),message:o.devices.map(e=>`#${e.deviceId}: ${gr(e.stores)}`).join(`
|
|
2
|
-
`),confirmLabel:t(`systemPage.deletedDevices.confirmLabel`,`Delete`),variant:`danger`})&&await d(!0)},p=[{key:`device`,header:t(`systemPage.deletedDevices.device`,`Device`),render:e=>`#${e.deviceId}`},{key:`stores`,header:t(`systemPage.deletedDevices.stores`,`Data held`),nowrap:!1,render:e=>gr(e.stores)}];return e(`div`,{className:`space-y-4`,"data-testid":`deleted-devices-data`,children:[r(`p`,{className:`text-sm text-foreground-muted`,children:t(`systemPage.deletedDevices.intro`,`Data that still belongs to devices that were deleted before deletions were recorded: footage, events, history and per-addon settings. Scanning deletes nothing; deleting asks first and shows what goes.`)}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(N,{variant:`outline`,onClick:()=>void d(!1),disabled:i.isPending,"data-testid":`deleted-devices-scan`,children:[i.isPending?r(S,{className:`mr-2 h-4 w-4 animate-spin`}):r(y,{className:`mr-2 h-4 w-4`}),t(`systemPage.deletedDevices.scan`,`Scan`)]}),o?.status===`dry-run`&&o.devices.length>0?e(N,{variant:`danger`,onClick:()=>void f(),disabled:i.isPending,"data-testid":`deleted-devices-delete`,children:[r(D,{className:`mr-2 h-4 w-4`}),t(`systemPage.deletedDevices.delete`,`Delete the data of {{count}} devices…`,{count:o.devices.length})]}):null]}),l===null?null:r(`p`,{className:`text-sm text-danger`,children:l}),o?.status===`skipped`?r(`p`,{className:`text-sm text-warning`,"data-testid":`deleted-devices-skipped`,children:t(`systemPage.deletedDevices.skipped`,`Nothing was listed or deleted: the device list could not be trusted ({{reason}}). Try again.`,{reason:o.reason??``})}):null,o!==null&&o.status!==`skipped`?e(c,{children:[r(`p`,{className:`text-sm`,"data-testid":`deleted-devices-summary`,children:o.status===`cleaned`?t(`systemPage.deletedDevices.cleaned`,`Deleted {{rows}} items of {{count}} devices.`,{rows:_r(o.devices),count:o.devices.length}):t(`systemPage.deletedDevices.found`,`{{count}} deleted devices still hold {{rows}} items.`,{rows:_r(o.devices),count:o.devices.length})}),r(R,{columns:p,rows:o.devices,rowKey:e=>e.deviceId,emptyMessage:t(`systemPage.deletedDevices.none`,`No data belongs to a deleted device.`)}),o.unreachable.length>0?r(`p`,{className:`text-xs text-foreground-muted`,children:t(`systemPage.deletedDevices.unreachable`,`Not asked (unreachable): {{names}}`,{names:o.unreachable.join(`, `)})}):null]}):null]})}var yr=`view`,br=`kinds`,xr=`deleted-devices`;function Sr(){let{t}=J(),[n,i]=mt(),a=n.get(`view`)===`deleted-devices`?xr:br;return e(`div`,{className:d,children:[e(`div`,{className:`mb-3 space-y-2`,children:[r(Xe,{appearance:`pills`,value:a,onValueChange:e=>{i(t=>{let n=new URLSearchParams(t);return e===`kinds`?n.delete(yr):n.set(yr,e),n},{replace:!0})},children:e(ct,{className:`flex flex-wrap gap-1`,children:[r(W,{value:br,children:t(`systemPage.data.viewKinds`,`Record kinds`)}),r(W,{value:xr,children:t(`systemPage.data.viewDeletedDevices`,`Deleted devices`)})]})}),a===`kinds`?r(`p`,{className:`text-xs text-foreground-muted`,children:t(`systemPage.data.recordsUnifiedIntro`,`Every declared record kind on this hub. Entry kinds can be added, edited and deleted; the rest are read-only. Secret fields are redacted.`)}):null]}),r(a===`kinds`?ke:vr,{})]})}var Cr={applied:`success`,failed:`danger`,blocked:`warning`,held:`warning`,running:`info`,pending:`default`,"skipped-newer":`neutral`},wr={applied:`migrations.status.applied`,failed:`migrations.status.failed`,blocked:`migrations.status.blocked`,held:`migrations.status.held`,running:`migrations.status.running`,pending:`migrations.status.pending`,"skipped-newer":`migrations.status.skippedNewer`};function Tr({status:e}){let{t}=J();return r(L,{variant:Cr[e],className:`text-[10px]`,children:t(wr[e])})}var Er=[`failed`,`blocked`,`held`,`running`,`pending`,`applied`,`skipped-newer`];function Dr(e){return Er.indexOf(e)}function Or(e,t){let n=new Map(t.map(e=>[e.meta.id,e])),r=new Map;for(let t of e){let e=n.get(t.id)??null;r.set(t.id,{id:t.id,owner:t.owner,status:t.status,meta:t.meta??e?.meta??null,ledger:t,pending:e,database:t.database,seq:t.seq,appliedAt:t.appliedAt,reason:t.reason??e?.reason??null,error:t.error})}for(let e of t)r.has(e.meta.id)||r.set(e.meta.id,{id:e.meta.id,owner:e.meta.owner,status:e.state===`pending`?`pending`:e.state,meta:e.meta,ledger:null,pending:e,database:e.database,seq:e.meta.seq,appliedAt:null,reason:e.reason,error:null});return[...r.values()]}function kr(e){return e.owner===`hub`&&e.meta!==null&&e.meta.bodyKind!==`procedure`}o();var Ar={searchText:e=>[e.id,e.owner,e.meta?.description??``],facetGroups:[{id:`owner`,value:e=>e.owner},{id:`status`,value:e=>e.status}]};function jr(e){if(e===null)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString()}function Mr({rows:n,onOpen:i}){let{t:a}=J(),o=Pe(n,Ar),s=t(()=>[{key:`id`,header:a(`migrations.col.id`,`Migration`),sortValue:e=>e.id,render:t=>e(`div`,{className:`min-w-0 max-w-[22rem]`,children:[r(`div`,{className:`truncate font-mono text-xs text-foreground`,title:t.id,children:t.id}),t.meta!==null&&r(`div`,{className:`truncate text-[10px] text-foreground-subtle`,title:t.meta.description,children:t.meta.description})]})},{key:`owner`,header:a(`migrations.col.owner`,`Owner`),sortValue:e=>e.owner,render:e=>e.owner},{key:`status`,header:a(`migrations.col.status`,`Status`),sortValue:e=>Dr(e.status),render:e=>r(Tr,{status:e.status})},{key:`level`,header:a(`migrations.col.level`,`Level`),sortValue:e=>e.meta?.level??null,render:e=>e.meta?.level??`—`},{key:`body`,header:a(`migrations.col.body`,`Body`),sortValue:e=>e.meta?.bodyKind??null,render:e=>e.meta?.bodyKind??`—`},{key:`applied`,header:a(`migrations.col.applied`,`Applied`),sortValue:e=>e.appliedAt,render:e=>r(`span`,{className:`text-foreground-subtle`,children:jr(e.appliedAt)})}],[a]),c=a(`migrations.label`,`migrations`);return e(`div`,{className:`space-y-3`,children:[r(Le,{state:o.state,facets:o.facets,groups:o.groups.map(e=>({...e,label:e.id===`owner`?a(`migrations.col.owner`):a(`migrations.col.status`),...e.id===`status`?{facetLabel:e=>a(wr[e])}:{}})),labels:{searchPlaceholder:a(`migrations.searchPlaceholder`,`Search migrations`),searchLabel:a(`migrations.searchLabel`,`Search migrations`),facetsLabel:a(`migrations.facetsLabel`,`Filter migrations`),clearLabel:a(`migrations.clearFilters`,`Clear filters`)},onSearch:o.setSearch,onToggleFacet:o.toggleFacet,onToggleGroupFacet:o.toggleGroupFacet,onClear:o.clear}),r(R,{columns:s,rows:o.rows,rowKey:e=>e.id,minWidthPx:820,maxBodyHeight:We,defaultSort:{columnKey:`status`,dir:`asc`},pageSize:25,onRowClick:e=>i(e.id),paginationLabels:{navLabel:a(`migrations.pagesLabel`,`Migration pages`),previous:a(`migrations.previousPage`,`Previous`),next:a(`migrations.nextPage`,`Next`),range:(e,t,n)=>a(`migrations.range`,`{{from}}–{{to}} of {{total}}`,{from:e,to:t,total:n})},emptyMessage:o.active?a(`migrations.noMatch`,`No {{label}} match the filters.`,{label:c}):a(`migrations.empty`,`No migrations.`)})]})}function $({label:t,children:n}){return e(`div`,{className:`grid gap-0.5 py-1.5 sm:grid-cols-[10rem_1fr] sm:gap-3`,children:[r(`dt`,{className:`text-xs text-foreground-muted`,children:t}),r(`dd`,{className:`min-w-0 break-words text-sm text-foreground`,children:n})]})}function Nr({value:e}){return e===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):r(`pre`,{className:`max-h-40 overflow-auto rounded-md bg-surface p-2 font-mono text-xs text-foreground`,children:JSON.stringify(e,null,2)})}function Pr({id:t}){let{t:n}=J(),i=Be.migrations.dryRun.useQuery({id:t},{enabled:!1});return e(`div`,{className:`space-y-2`,children:[e(N,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void i.refetch(),disabled:i.isFetching,children:[i.isFetching&&r(S,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),n(`migrations.detail.dryRun`,`Run a dry run`)]}),r(`p`,{className:`text-xs text-foreground-muted`,children:n(`migrations.detail.dryRunHint`,`Runs the migration in a transaction and rolls it back. Nothing is written.`)}),i.isError&&r(B,{title:n(`migrations.detail.dryRunFailed`,`The dry run could not run`),message:i.error.message}),i.data!==void 0&&e(`div`,{className:`space-y-1 text-xs`,"data-testid":`dry-run-result`,children:[r(`div`,{className:`text-foreground`,children:i.data.ok?n(`migrations.detail.dryRunOk`,`Would change {{count}} rows`,{count:i.data.rowsChanged}):i.data.error??n(`migrations.detail.dryRunThrows`,`It would fail`)}),i.data.tables.map(t=>e(`div`,{className:`font-mono text-foreground-muted`,children:[t.table,`: `,t.before,` → `,t.after]},t.table))]})]})}function Fr({row:t,knownIds:n,onOpenRow:i,onClose:a}){let{t:o}=J(),s=r(`span`,{className:`text-foreground-subtle`,children:`—`}),l=t?.meta??null,u=t?.ledger??null;return r(P,{open:t!==null,onOpenChange:e=>!e&&a(),children:r(V,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:t!==null&&e(c,{children:[e(G,{children:[r(F,{className:`break-all font-mono text-base`,children:t.id}),r(Ee,{children:l?.description??o(`migrations.detail.noMeta`,`No catalogue on this hub lists this migration.`)})]}),e(z,{children:[e(`dl`,{className:`divide-y divide-border-subtle`,children:[r($,{label:o(`migrations.col.status`,`Status`),children:r(Tr,{status:t.status})}),t.error!==null&&r($,{label:o(`migrations.detail.error`,`Error`),children:r(`span`,{className:`text-danger`,"data-testid":`migration-error`,children:t.error})}),t.reason!==null&&r($,{label:o(`migrations.detail.reason`,`Reason`),children:t.reason}),r($,{label:o(`migrations.col.owner`,`Owner`),children:t.owner}),r($,{label:o(`migrations.col.level`,`Level`),children:l?.level??s}),r($,{label:o(`migrations.col.body`,`Body`),children:l?.bodyKind??s}),e($,{label:o(`migrations.detail.store`,`Store`),children:[l?.store??s,` · `,t.database]}),r($,{label:o(`migrations.detail.scope`,`Scope`),children:l?.scope??s}),r($,{label:o(`migrations.detail.onFailure`,`On failure`),children:l?.onFailure??s}),r($,{label:o(`migrations.detail.seq`,`Sequence in owner`),children:t.seq}),r($,{label:o(`migrations.detail.fixtureMark`,`Fixture mark`),children:l?.fixtureMark??s}),r($,{label:o(`migrations.detail.dependsOn`,`Depends on`),children:l===null||l.dependsOn.length===0?s:r(`div`,{className:`flex flex-wrap gap-1.5`,children:l.dependsOn.map(e=>n.has(e)?r(N,{type:`button`,variant:`outline`,size:`sm`,className:`font-mono text-xs`,onClick:()=>i(e),children:e},e):r(L,{variant:`neutral`,className:`font-mono text-xs`,children:e},e))})}),r($,{label:o(`migrations.col.applied`,`Applied`),children:jr(t.appliedAt)}),r($,{label:o(`migrations.detail.attempts`,`Attempts`),children:u?.attempts??s}),r($,{label:o(`migrations.detail.codeVersion`,`Code version`),children:u?.codeVersion??s}),r($,{label:o(`migrations.detail.node`,`Node`),children:u?.nodeId??s}),r($,{label:o(`migrations.detail.boot`,`Boot (snapshot id prefix)`),children:r(`span`,{className:`font-mono text-xs`,children:u?.bootId??s})}),r($,{label:o(`migrations.detail.planSummary`,`Rows changed`),children:r(Nr,{value:u?.planSummary??null})}),r($,{label:o(`migrations.detail.progress`,`Progress`),children:r(Nr,{value:u?.progress??null})})]}),kr(t)&&r(Pr,{id:t.id},t.id)]}),r(I,{children:r(N,{type:`button`,variant:`outline`,onClick:a,children:o(`migrations.detail.close`,`Close`)})})]})})})}o();var Ir=`migration`;function Lr(){let{t:n}=J(),i=Me(`migrations`),a=i===`present`,o=Be.migrations.listLedger.useQuery({},{enabled:a}),s=Be.migrations.listPending.useQuery({},{enabled:a}),[c,l]=mt(),u=c.get(Ir),f=t(()=>o.data===void 0||s.data===void 0?null:Or(o.data.entries,s.data.pending),[o.data,s.data]),p=t(()=>new Set((f??[]).map(e=>e.id)),[f]),m=f?.find(e=>e.id===u)??null,h=e=>l(t=>{let n=new URLSearchParams(t);return e===null?n.delete(Ir):n.set(Ir,e),n},{replace:!0}),g;return g=i===`pending`?r(Rr,{label:n(`migrations.loading`,`Loading migrations…`)}):i===`unknown`?r(B,{title:n(`migrations.unknownTitle`,`Could not check the migration ledger`),message:n(`migrations.unknownBody`,`The hub did not answer. Try again in a moment.`)}):i===`absent`?r(tt,{icon:_e,title:n(`migrations.absentTitle`,`No migration ledger on this hub`),description:n(`migrations.absentBody`,`Nothing on this hub provides the migrations capability.`)}):o.isError||s.isError?r(B,{title:n(`migrations.loadFailed`,`Could not load the migrations`),message:(o.error??s.error)?.message??``}):f===null?r(Rr,{label:n(`migrations.loading`,`Loading migrations…`)}):f.length===0?r(tt,{icon:_e,title:n(`migrations.empty`,`No migrations.`),description:n(`migrations.emptyBody`,`The ledger and the catalogues are both empty.`)}):r(Mr,{rows:f,onOpen:h}),e(`div`,{className:d,children:[r(`p`,{className:`mb-3 text-xs text-foreground-muted`,children:n(`migrations.intro`,`Every data migration this hub knows: what ran, what is waiting and what failed. Read-only.`)}),g,r(Fr,{row:m,knownIds:p,onOpenRow:h,onClose:()=>h(null)})]})}function Rr({label:t}){return e(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,role:`status`,children:[r(S,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),t]})}var zr={entries:null,"deleted-devices":`deleted-devices`};function Br(){let{t:e}=J(),t=ht(`/system/data`,{t:e,isAdmin:!0})??{icon:k,title:e(`system.data`,`Data`)},[n]=mt(),i=zr[n.get(`tab`)??``];if(i!==void 0){let e=new URLSearchParams(n);return e.set(`tab`,`records`),i!==null&&e.set(`view`,i),r(ft,{replace:!0,to:{search:e.toString()}})}return r(gt,{icon:t.icon,title:t.title,defaultSection:`storage`,sectionsLabel:`${t.title} sections`,sections:[{id:`storage`,label:e(`systemPage.data.storage`,`Storage`),content:r(xt,{})},{id:`records`,label:e(`systemPage.data.records`,`Records`),content:r(Sr,{}),ownedParams:[`view`,`recordsOwner`,`recordsKind`,`entryNew`,`entryEdit`]},{id:`backup`,label:e(`systemPage.data.backup`,`Backup`),content:r(In,{})},{id:`secrets`,label:e(`systemPage.data.secrets`,`Secrets`),content:r(hr,{}),ownedParams:[`secretsView`]},{id:`migrations`,label:e(`systemPage.data.migrations`,`Migrations`),content:r(Lr,{}),ownedParams:[`migration`]}]})}export{Br as DataPage};
|