@camstack/addon-admin-ui 1.2.527 → 1.2.529
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 +15 -0
- package/dist/assets/{AddonAssetIcon-BZ0hQcho.js → AddonAssetIcon-B1rn0DLw.js} +1 -1
- package/dist/assets/Addons-CZ_5JUVc.js +5 -0
- package/dist/assets/{AdminPage-7avIuDBh.js → AdminPage-DmkuRREx.js} +1 -1
- package/dist/assets/{AdminSectionedPage-Bd2owMGm.js → AdminSectionedPage-B_tSbkIV.js} +1 -1
- package/dist/assets/{AiProfiles-aCDtxD2T.js → AiProfiles-W2ByefcY.js} +2 -2
- package/dist/assets/{Build-SObpGxas.js → Build-BesaIcQt.js} +3 -3
- package/dist/assets/Calendars-PHb_rEbJ.js +1 -0
- package/dist/assets/Cluster-CnMcgkaB.js +1 -0
- package/dist/assets/{ComposedDeviceEditDialog-BiIiBFG-.js → ComposedDeviceEditDialog-DlxMQhZP.js} +1 -1
- package/dist/assets/{CompositionBlockEditor-BXYXXUEU.js → CompositionBlockEditor-Ctx6d-qx.js} +2 -2
- package/dist/assets/CompositionEditorPage-CVp1OM-C.js +1 -0
- package/dist/assets/Data-OpXlBhEa.js +2 -0
- package/dist/assets/DeviceDetail-CUzPIb4E.js +2 -0
- package/dist/assets/DeviceDoActionFields-D1rhgn3I.js +1 -0
- package/dist/assets/Devices-DFfVPHVt.js +1 -0
- package/dist/assets/{EmbedPlayerPage-B7MIw7cv.js → EmbedPlayerPage-D0lVyXps.js} +1 -1
- package/dist/assets/FormBuilder-BvQZWKCS.js +1 -0
- package/dist/assets/History-BLJJzgUt.js +1 -0
- package/dist/assets/Identity-B_TiHuO-.js +1 -0
- package/dist/assets/IntegrationDetail-DtTxTigM.js +1 -0
- package/dist/assets/IntegrationHub-BvDB6bjh.js +1 -0
- package/dist/assets/Integrations-CK3qys8g.js +1 -0
- package/dist/assets/Integrations-Xub2OY5T.js +1 -0
- package/dist/assets/Library-CO10lVu2.js +1 -0
- package/dist/assets/Locations-CaL7Y2a3.js +3 -0
- package/dist/assets/{Logs-CrxQn3Uq.js → Logs-Bu40SOPP.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-tJyuoOTy.js → MaskShapeCanvas-HJuLPIJP.js} +1 -1
- package/dist/assets/{MotionZonesSettings-DaGyceJa.js → MotionZonesSettings-COMPKhfx.js} +1 -1
- package/dist/assets/MyAccess-CNQzuYsW.js +2 -0
- package/dist/assets/Network-BBm6sZIX.js +1 -0
- package/dist/assets/NodeAddonsSettingsPanel-DZwxKBXw.js +1 -0
- package/dist/assets/Notifications-BS4cbFH2.js +1 -0
- package/dist/assets/Pipeline-BhNYn1U-.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-zzQcpeb0.js → PrivacyMaskSettings-C88JqmdE.js} +1 -1
- package/dist/assets/Recordings-B8VQL_Ik.js +1 -0
- package/dist/assets/{RemoteGrid-Bz_u9tq6.js → RemoteGrid-CF92aN64.js} +1 -1
- package/dist/assets/ScanNetworkModal-SyHjZF2T.js +1 -0
- package/dist/assets/{SceneMonitorEditor-B0ICySEi.js → SceneMonitorEditor-mE7W6emU.js} +1 -1
- package/dist/assets/SessionsList-BD87Vhfu.js +2 -0
- package/dist/assets/Showroom-BS88iBLb.js +1 -0
- package/dist/assets/System-D-Xj3jc0.js +1 -0
- package/dist/assets/{Templates-uAAxbV9V.js → Templates-D0V7IdcS.js} +1 -1
- package/dist/assets/{Terminal-D1fhPY66.js → Terminal-DhbVA89N.js} +5 -5
- package/dist/assets/Trans-Bsz5Pghy.js +1 -0
- package/dist/assets/{Viewer-BWN8qfBa.js → Viewer-BTxcZ-BR.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-sshFQYnL.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CmowmspB.js} +1 -1
- package/dist/assets/{addon-icons-context-BHF-RdY-.js → addon-icons-context-DZZCjo9x.js} +1 -1
- package/dist/assets/{archive-2V-x_y9T.js → archive-Bu9T4BL0.js} +1 -1
- package/dist/assets/{assignment-candidates-BpC51VXR.js → assignment-candidates-DWivr3bV.js} +1 -1
- package/dist/assets/{authed-media-CdbbdgDZ.js → authed-media-yW7W_8pm.js} +1 -1
- package/dist/assets/{bell-off-DDQ8FbF1.js → bell-off-E0Abr7jJ.js} +1 -1
- package/dist/assets/{board-model-D3wYwuI4.js → board-model-CCD7fB3T.js} +1 -1
- package/dist/assets/{boxes-BwEV9Act.js → boxes-BkzsIUkw.js} +1 -1
- package/dist/assets/circle-slash-pdaivo-U.js +1 -0
- package/dist/assets/{client-r4i0EpF6.js → client-BvflqtP1.js} +1 -1
- package/dist/assets/{cloud-upload-BII8r4p9.js → cloud-upload-BIjzjy_K.js} +1 -1
- package/dist/assets/crop-CZJDrMcX.js +1 -0
- package/dist/assets/device-integration-icon-D-OosuOg.js +1 -0
- package/dist/assets/device-picker-model-2dkiqOI6.js +1 -0
- package/dist/assets/{dist-B0LFF94V.js → dist-DoqhrZoo.js} +1 -1
- package/dist/assets/{dist-BOdjk8IV.js → dist-Gm_hHBN2.js} +1 -1
- package/dist/assets/{file-up-Bizrs9Ca.js → file-up-Cyg6A2qN.js} +1 -1
- package/dist/assets/{format-Bqo-j708.js → format-ChSVChsY.js} +1 -1
- package/dist/assets/{grip-vertical-C-qhB3oM.js → grip-vertical-CLVyc1HC.js} +1 -1
- package/dist/assets/{hard-drive-download-Dym9jihx.js → hard-drive-download-Cd122TYb.js} +1 -1
- package/dist/assets/{hostInit-bmlgmSTk.js → hostInit-DR1ykbVx.js} +1 -1
- package/dist/assets/i18n-Bg2ooh3q.js +1 -0
- package/dist/assets/icons-BSJCF6qM.js +1 -0
- package/dist/assets/index-CyqhCHax.css +2 -0
- package/dist/assets/index-DMMw81r0.js +4 -0
- package/dist/assets/{key-DddJ6bil.js → key-D_zqd1r-.js} +1 -1
- package/dist/assets/{key-round-CbCqycf3.js → key-round-pNw827HU.js} +1 -1
- package/dist/assets/{layers-C-ZqYk3U.js → layers-CFNXRt4j.js} +1 -1
- package/dist/assets/{linked-devices-model-BPUD1khJ.js → linked-devices-model-D9m6pafu.js} +1 -1
- package/dist/assets/{list-ordered-Cxznlat2.js → list-ordered-Dy6tCUD8.js} +1 -1
- package/dist/assets/location-owned-usage-DasgH3RR.js +1 -0
- package/dist/assets/{memory-stick-CLL3KiND.js → memory-stick-Bt2KoB-0.js} +1 -1
- package/dist/assets/{message-square-plus-C2nVnMG1.js → message-square-plus-rkd_X0vs.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-edf9b20a.js → mf-entry-bootstrap-0-dd19d57d.js} +2 -2
- package/dist/assets/{mic-off-CcHQBwDt.js → mic-off-DWb36TX2.js} +1 -1
- package/dist/assets/{monitor-off-DUE1gt1S.js → monitor-off-B2GWMMt_.js} +1 -1
- package/dist/assets/{monitor-smartphone-CwOoXB0L.js → monitor-smartphone-DJzvbVtx.js} +1 -1
- package/dist/assets/mount-2dkiqOI6.js +1 -0
- package/dist/assets/notification-schedule-field-B7FdiF_t.js +1 -0
- package/dist/assets/{player-overlays-Cw_gjG75.js → player-overlays-DpZIxQHp.js} +1 -1
- package/dist/assets/{recycle-hW2Os1lc.js → recycle-BWLoavmg.js} +1 -1
- package/dist/assets/remoteEntry-CD4F7fE2.js +1 -0
- package/dist/assets/{ruler-SYjqj9n_.js → ruler-C1SbVRl3.js} +1 -1
- package/dist/assets/{scan-eye-BZlKp5Ev.js → scan-eye-Bv4PGTFl.js} +1 -1
- package/dist/assets/{scissors-Prn6Kbb7.js → scissors-BsEkbrx_.js} +1 -1
- package/dist/assets/{search-x-CCA8373c.js → search-x-DE4DxdsF.js} +1 -1
- package/dist/assets/{send-C5rCH5_0.js → send-Dd0BBamd.js} +1 -1
- package/dist/assets/{settings-2-wlw_-rxi.js → settings-2-z3X6U2eo.js} +1 -1
- package/dist/assets/{shapes-Kj0bK1D8.js → shapes-D-IaC6en.js} +1 -1
- package/dist/assets/{sigma-NPxR3lj1.js → sigma-CxBVWJ85.js} +1 -1
- package/dist/assets/{speaker-CIKbprnA.js → speaker-Dy79a571.js} +1 -1
- package/dist/assets/src-KDhMZ5Ob.js +67 -0
- package/dist/assets/sso-popup-BjTl8T6g.js +1 -0
- package/dist/assets/{step-inspector-model-BKKc_lkM.js → step-inspector-model-DINPtCNq.js} +1 -1
- package/dist/assets/{table-2-Sw__YAPa.js → table-2-IUuOvuT8.js} +1 -1
- package/dist/assets/{timer-reset-BhPZYoCT.js → timer-reset-D1H0hoMf.js} +1 -1
- package/dist/assets/{unlink-DNy8sNAV.js → unlink-DTu1e00O.js} +1 -1
- package/dist/assets/{usb-CyQsTtlO.js → usb-CFK8z-TS.js} +1 -1
- package/dist/assets/{use-device-bound-caps-BQo_OD1O.js → use-device-bound-caps-DS4FtJtN.js} +1 -1
- package/dist/assets/{use-scenes-feed-BCDAv1nN.js → use-scenes-feed-CE-KFGxN.js} +1 -1
- package/dist/assets/{use-stationary-objects-BnIfyZw5.js → use-stationary-objects-CFLRkxjx.js} +1 -1
- package/dist/assets/useEventInvalidation-2dkiqOI6.js +1 -0
- package/dist/assets/useNodeUrlSelection-A-NDcCsx.js +1 -0
- package/dist/assets/user-round-BSVSJsjB.js +1 -0
- package/dist/assets/{user-x-CUkBojXx.js → user-x-KWsBR0tG.js} +1 -1
- package/dist/assets/{variable-CpgCMY_Q.js → variable-BG_qKWYf.js} +1 -1
- package/dist/assets/{video-DXegVNA2.js → video-D0guHpd1.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-2LL0aB_0.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-FCSZ5q7m.js} +2 -2
- package/dist/index.html +14 -10
- package/dist/server/addon.js +9 -1
- package/package.json +1 -1
- package/dist/assets/Addons-BAqAfY0r.js +0 -5
- package/dist/assets/BrokerEditorDialog-Cp7neyJC.js +0 -1
- package/dist/assets/Calendars-B2TORAnq.js +0 -1
- package/dist/assets/Cluster-CD4DYic_.js +0 -1
- package/dist/assets/CompositionEditorPage-Cm4C-7Z-.js +0 -1
- package/dist/assets/Data-CRPVPhFT.js +0 -2
- package/dist/assets/DeviceDetail-DNsWQGiy.js +0 -2
- package/dist/assets/DeviceDoActionFields-BEhy6_KW.js +0 -1
- package/dist/assets/Devices-CS5P4d9n.js +0 -1
- package/dist/assets/History-BbOfWf-p.js +0 -1
- package/dist/assets/Identity-Df140-fX.js +0 -1
- package/dist/assets/IntegrationDetail-B7sqZ94w.js +0 -1
- package/dist/assets/IntegrationHub-DndCuqMe.js +0 -1
- package/dist/assets/Integrations-BJh_WZAT.js +0 -1
- package/dist/assets/Integrations-DRCpstaG.js +0 -1
- package/dist/assets/Library-Cx17_SRL.js +0 -1
- package/dist/assets/Locations-Dt9LOu5v.js +0 -3
- package/dist/assets/MyAccess-Bp2dsON4.js +0 -2
- package/dist/assets/Network-DftlNAIH.js +0 -1
- package/dist/assets/NodeAddonsSettingsPanel-JIXh-CLX.js +0 -1
- package/dist/assets/Notifications-2tj0VaIS.js +0 -1
- package/dist/assets/Pipeline-CqZqLWQZ.js +0 -1
- package/dist/assets/Recordings-DoAJqZqc.js +0 -1
- package/dist/assets/ScanNetworkModal-DL-mWRtG.js +0 -1
- package/dist/assets/SessionsList-QvqpXCDN.js +0 -2
- package/dist/assets/Showroom-B6CDELO1.js +0 -1
- package/dist/assets/System-C0KUcOaJ.js +0 -1
- package/dist/assets/circle-slash-BjzSCz4-.js +0 -1
- package/dist/assets/crop-D9cpl5_W.js +0 -1
- package/dist/assets/device-integration-icon-Cf2JTj5q.js +0 -1
- package/dist/assets/device-picker-model-B_Zjyqyk.js +0 -1
- package/dist/assets/i18n-BE1bPZOs.js +0 -1
- package/dist/assets/icons-BZ8D05w2.js +0 -1
- package/dist/assets/index-DimGtYV1.css +0 -2
- package/dist/assets/index-Ohn-2iW_.js +0 -4
- package/dist/assets/location-owned-usage-DOmOvdiG.js +0 -1
- package/dist/assets/log-in-9Uirjetj.js +0 -1
- package/dist/assets/mount-B_Zjyqyk.js +0 -1
- package/dist/assets/remoteEntry-CHuAXwj-.js +0 -1
- package/dist/assets/src-nnHXOip7.js +0 -67
- package/dist/assets/useEventInvalidation-B_Zjyqyk.js +0 -1
- package/dist/assets/useNodeUrlSelection-CR_BnlEg.js +0 -1
- package/dist/assets/user-round-BY4YxbLZ.js +0 -1
|
@@ -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{Ai as d,Dn as f,Ei as p,Gn as m,Ht as h,Mn as g,Pt as _,Q as v,Qr as y,gn as b,gt as x,ki as S,ot as C,pi as w,pr as T,sn as E,st as ee,vn as D,xi as te,yn as ne,zt as re}from"./player-overlays-Cw_gjG75.js";import{Zo as O}from"./client-r4i0EpF6.js";import{i as ie,u as ae}from"./video-DXegVNA2.js";import{$i as oe,Bi as k,Cr as se,Ct as A,Dc as j,Fi as M,Gi as N,Hi as ce,Ii as P,Ji as le,Jn as ue,Ki as F,Kn as I,Li as L,Mt as de,Nd as R,Ni as z,Qi as B,Rd as fe,Ri as pe,Tr as me,Vi as he,Wi as V,Xi as ge,Yn as H,Zi as U,br as _e,cn as ve,di as ye,if as W,na as be,qi as xe,qn as Se,ra as Ce,ri as G,sf as we,sn as Te,ta as Ee,wr as De,xr as Oe,yr as ke,zi as K}from"./src-nnHXOip7.js";import{t as q}from"./useTranslation-BJr-n0es.js";import"./mount-B_Zjyqyk.js";import{br as Ae,mr as J,vr as Y}from"./index-Ohn-2iW_.js";import{t as X}from"./AdminPage-7avIuDBh.js";import{t as Z}from"./NodeAddonsSettingsPanel-JIXh-CLX.js";import{t as je}from"./framework-packages-B7oma9J4.js";import{n as Q,t as Me}from"./useNodeUrlSelection-CR_BnlEg.js";function Ne(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 Pe={queued:{icon:w,bg:`bg-muted text-foreground-subtle`,labelKey:`addons.addonRowBadge.queued`},updating:{icon:T,bg:`bg-primary/10 text-primary`,labelKey:`addons.addonRowBadge.updating`,spin:!0},"done-pending-restart":{icon:f,bg:`bg-amber-500/10 text-amber-700`,labelKey:`addons.addonRowBadge.pendingRestart`},done:{icon:d,bg:`bg-success/10 text-success`,labelKey:`addons.addonRowBadge.done`},failed:{icon:ie,bg:`bg-danger/10 text-danger`,labelKey:`addons.addonRowBadge.failed`}};function Fe({item:e}){let{t:n}=q(),r=Pe[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 Ie=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),Le=new Set([`done`,`failed`,`skipped`]);function Re(e){return!Le.has(e.phase)&&!Ie.has(e.jobState)}function ze(e,t){let n=new Map,r=[...e].sort((e,t)=>e.createdAtMs-t.createdAtMs);for(let e of r){let r=Ie.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 Be(){let{data:e}=N({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=we(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 ze([...n.values()],Date.now())},[e,t])}var Ve={queued:{icon:w,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.queued`},fetching:{icon:T,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.fetching`,spin:!0},staged:{icon:T,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.staged`,spin:!0},validating:{icon:T,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.validating`,spin:!0},applying:{icon:T,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.applying`,spin:!0},restarting:{icon:T,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,labelKey:`addons.jobProgress.restarting`,spin:!0},applied:{icon:T,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.finalizing`,spin:!0},done:{icon:d,cls:`bg-success/10 text-success`,labelKey:`addons.jobProgress.updated`},failed:{icon:ie,cls:`bg-danger/10 text-danger`,labelKey:`addons.jobProgress.failed`},skipped:{icon:E,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.skipped`}};function He({progress:e}){let{t:n}=q(),r=Ve[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 Ue(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 We(e){let t=e.version===null?``:` ${e.version}`,n=e.isOnline?``:` (offline: removed when it reconnects)`;return`- ${e.nodeName}${t}${n}`}function Ge(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(We)];return n.length>0&&r.push(`Could not ask: ${n.join(`, `)} — not included.`),r.push(`This cannot be undone.`),r.join(`
|
|
2
|
-
`)}function Ke(e,t,n){let r=[`${e} will be uninstalled from ${t}: its runners stop and its code is deleted.`];return n.length>0&&r.push(`It stays installed on: ${n.map(e=>e.nodeName).join(`, `)}. Use "Everywhere" to remove it from every node.`),r.push(`This cannot be undone.`),r.join(`
|
|
3
|
-
`)}var qe={uninstalled:`uninstalled`,"not-installed":`was not installed`,refused:`REFUSED`,failed:`FAILED`,"pending-reconnect":`offline — removed when it reconnects`};function Je(e,t){let n=[];for(let r of e.results){let e=r.runnersStopped.length>0?` (stopped ${r.runnersStopped.join(`, `)})`:``;n.push(`${t(r.nodeId)}: ${qe[r.outcome]}${e}`),r.error!==void 0&&n.push(` ${r.error}`);for(let e of r.warnings)n.push(` ${e}`)}return n.join(`
|
|
4
|
-
`)}var Ye={},Xe=3e4,Ze=`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 Qe({packageName:e,displayName:n,selectedNode:r,hideNodeAction:i,disabled:o}){let{t:s}=q(),c=l(),u=ee(),d=C(),f=V(Ye,{staleTime:Xe}),p=f.data?.installations??[],m=(f.data?.unreachable??[]).map(e=>e.nodeId),g=Ue(p,e),_=e=>g.find(t=>t.nodeId===e)?.nodeName??(e===r.id?r.name:e),v=be({onSettled:()=>{c.invalidateQueries({queryKey:[[`addons`]]}),c.invalidateQueries({queryKey:[[`addonPages`]]}),c.invalidateQueries({queryKey:[[`capabilities`]]}),c.invalidateQueries({queryKey:[[`nodes`]]})}}),y=async e=>{await d({title:e.success?s(`addons.addonUninstallControls.uninstalled`,`{{displayName}} uninstalled`,{displayName:n}):s(`addons.addonUninstallControls.notEveryNodeWasCleaned`,`{{displayName}}: not every node was cleaned`,{displayName:n}),message:Je(e,_),variant:e.success?`default`:`danger`})},b=async t=>{try{await y(await v.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`})}},x=async()=>{let e=g.filter(e=>e.nodeId!==r.id);await u({title:s(`addons.addonUninstallControls.uninstallFrom`,`Uninstall {{displayName}} from {{name}}?`,{displayName:n,name:r.name}),message:Ke(n,r.name,e),confirmLabel:s(`addons.addonUninstallControls.uninstall`,`Uninstall`),variant:`danger`})&&await b(r.isHub?{}:{nodeId:r.id})},S=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=Ue(t.installations,e);await u({title:s(`addons.addonUninstallControls.uninstallEverywhere`,`Uninstall {{displayName}} everywhere?`,{displayName:n}),message:Ge(n,r,t.unreachable.map(e=>e.nodeId)),confirmLabel:s(`addons.addonUninstallControls.uninstallFromNodeS`,`Uninstall from {{length}} node(s)`,{length:r.length}),variant:`danger`})&&await b({everywhere:!0})},w=v.isPending||o===!0;return t(`div`,{className:`flex items-center gap-1.5`,children:[i!==!0&&t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),x()},disabled:w,className:Ze,title:s(`addons.addonUninstallControls.uninstallFrom2`,`Uninstall from {{name}}`,{name:r.name}),children:[a(h,{className:`h-3 w-3`}),v.isPending?s(`addons.addonUninstallControls.removing`,`Removing...`):s(`addons.addonUninstallControls.uninstall`,`Uninstall`)]}),(g.length>1||i===!0||m.length>0)&&t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),S()},disabled:w,className:Ze,title:s(`addons.addonUninstallControls.uninstallFromEveryNodeThat`,`Uninstall from every node that has it`),children:[a(ae,{className:`h-3 w-3`}),g.length>0?s(`addons.uninstallControls.everywhereCount`,{count:g.length}):s(`addons.uninstallControls.everywhere`)]})]})}function $e(e){return typeof e.deprecated==`string`&&e.deprecated.length>0}function et(e,t){return t?e:e.filter(e=>e.distTags.includes(`latest`)||!$e(e))}function tt(e){return e.length-et(e,!1).length}c();function nt({packageName:e,currentVersion:n,installSource:r,onInstall:i,onClose:o,onSelect:c,selectedVersion:l}){let{t:f}=q(),p=r===`upload`||r===`local`,[m,h]=s(!1),{data:g,isLoading:v,isError:b}=k({name:e}),S=g?et(g,m):[],C=g?tt(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:f(`addons.versionPicker.versions`,`Versions`)}),a(`button`,{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(_,{className:`h-3 w-3 mt-0.5 text-cyan-500 shrink-0`}),t(`div`,{className:`text-cyan-700 dark:text-cyan-200`,children:[a(`span`,{className:`font-semibold`,children:f(`addons.versionPicker.inPlace`,{kind:r===`upload`?f(`addons.versionPicker.uploadedCopy`,`Uploaded copy`):f(`addons.versionPicker.localCopy`,`Local copy`)})}),` `,a(J,{i18nKey:`addons.versionPicker.reinstall`,values:{version:n},components:{mono:a(`span`,{className:`font-mono`})}})]})]}),v&&t(`div`,{className:`flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle`,children:[a(T,{className:`h-3.5 w-3.5 animate-spin`}),f(`addons.versionPicker.loadingVersions`,`Loading versions...`)]}),b&&a(`div`,{className:`px-3 py-4 text-center text-[10px] text-danger`,children:f(`addons.versionPicker.registryError`,`Could not load versions from the registry.`)}),S.length>0&&a(`div`,{className:`max-h-64 overflow-auto divide-y divide-border`,children:S.map(e=>{let r=e.version===n,o=c!==void 0&&e.version===l,s=/-(alpha|beta|rc|dev|canary|next)/i.test(e.version),p=t(u,{children:[a(`span`,{className:`font-mono flex-1 text-left ${r?`text-primary font-semibold`:s?`text-amber-400`:`text-foreground`}`,children:e.version}),r&&a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium bg-primary/10 text-primary`,children:f(`common.current`)}),e.distTags.map(e=>a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e===`latest`?`bg-emerald-500/15 text-emerald-400`:e===`beta`?`bg-amber-500/15 text-amber-400`:`bg-gray-500/15 text-gray-400`}`,children:e},e)),$e(e)&&a(`span`,{className:`text-[9px] text-red-400 line-through`,children:f(`common.deprecated`)}),a(`span`,{className:`text-[9px] text-foreground-subtle shrink-0`,children:new Date(e.publishedAt).toLocaleDateString()})]});return c?t(`button`,{type:`button`,"aria-label":f(`addons.versionPicker.select`,`Select {{version}}`,{version:e.version}),onClick:()=>c(e.version),className:`w-full flex items-center gap-2 px-3 py-2 text-[11px] ${o?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[p,o?a(d,{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:[p,a(`button`,{type:`button`,onClick:()=>i(e.version),className:`shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors`,title:r?f(`addons.versionPicker.reInstallFromNpm`,`Re-install {{version}} from npm`,{version:e.version}):f(`addons.versionPicker.install`,`Install {{version}}`,{version:e.version}),children:a(y,{className:`h-3 w-3`})})]},e.version)})}),!v&&!b&&g&&g.length===0&&a(`div`,{className:`py-4 text-center text-[10px] text-foreground-subtle`,children:f(`addons.versionPicker.noVersionsFound`,`No versions found`)}),C>0&&a(G,{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?f(`addons.versionPicker.hideOlder`,`Hide older versions`):f(`addons.versionPicker.showOlder`,`Show older versions ({{count}})`,{count:C})})]})}c();var rt=`device-export`;function it(e){return e.capabilities.some(e=>(typeof e==`string`?e:e.name)===rt)}function at(e){return e!==`local`&&e!==`upload`}function ot({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`,f=r&&i?v(`/api/addon-assets/${r}/${i}`):null,p=!!f&&!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:p?a(`img`,{src:f,alt:r,className:`h-4 w-4`,onError:()=>l(!0)}):a(e?m:g,{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`}),at(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(_,{className:`h-2.5 w-2.5 text-white`})})]})}function st({version:e,availableUpdate:n,selectedVersion:r,isUpdating:i,installSource:o,disabled:s,onUpdate:c,onOpenPicker:l,children:u}){let{t:d}=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(T,{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(`button`,{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(y,{className:`h-3 w-3`}),d(`addons.addonCard.update`,`Update`)]}),t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:s,"aria-label":d(`addons.addonCard.selectVersionToInstall`,`Select version to install`),title:d(`addons.addonCard.installedUpdateAvailableSelectedTap`,`Installed {{version}} — update available. Selected {{target}}; tap to choose another version.`,{version:e,target:i}),className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-bold font-mono border border-amber-500/40 bg-amber-500/15 text-amber-500 hover:bg-amber-500/25 animate-pulse disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[a(`span`,{className:`font-normal opacity-70`,children:e}),a(`span`,{className:`font-normal opacity-70`,children:`→`}),i,a(S,{className:`h-3 w-3`})]}),u]})}return t(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:s,className:[`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-bold font-mono border transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,o===`local`?`border-orange-500/30 bg-orange-500/10 text-orange-400 hover:bg-orange-500/20`:`border-emerald-500/30 bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20`].join(` `),title:d(`addons.addonCard.versionTapToViewAll`,`Version {{version}} — tap to view all versions`,{version:e}),children:[e,a(S,{className:`h-3 w-3 opacity-50`})]}),u]})}function ct({addonId:e}){let t=l(),{data:n=`inherit`}=P({addonId:e}),r=B({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(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),r.mutate({addonId:e,channel:t})},disabled:r.isPending,className:`px-2.5 py-1 transition-colors capitalize ${n===t?t===`inherit`?`bg-gray-700/50 text-gray-700 dark:text-gray-300`:t===`off`?`bg-gray-700 text-gray-700 dark:text-gray-300`:t===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${t===`inherit`?``:`border-l border-border`}`,children:t},t))})}var lt={id:`hub`,name:`Hub`,isHub:!0};function ut({addon:e,clusterStatus:n,hideVersion:r,availableUpdate:i,onUpdate:c,isUpdating:d,jobProgress:h,bundle:g,bulkItem:_,disabledByBulk:v,isSystem:y,selectedNode:C}){let{t:w}=q(),[T,E]=s(!1),[ee,D]=s(!1),[te,re]=s(null);o(()=>{re(null)},[i]);let O=te??i,[ae,oe]=s(!1),[k,A]=s(!1),[j,M]=s(`logs`),N=l(),ce=Y(),{manifest:P}=e,ue=!g&&!P.protected&&P.removable!==!1,F=!!g,I=g?.displayName??P.name,L=g?.packageName??P.packageName,R=g?.version??P.packageVersion??P.version,z=g?.installSource??e.installSource,B=g?g.bundle?.description??g.addons[0]?.manifest.description:P.description,fe=le({onSuccess:()=>{N.invalidateQueries({queryKey:[[`addons`]]})}}),pe=he({onSuccess:()=>{N.invalidateQueries({queryKey:[[`addons`]]}),N.invalidateQueries({queryKey:[[`addonPages`]]}),N.invalidateQueries({queryKey:[[`capabilities`]]}),N.invalidateQueries({queryKey:[[`integrations`]]})}}),V=ge({onSuccess:()=>{N.invalidateQueries({queryKey:[[`addons`]]}),N.invalidateQueries({queryKey:[[`alerts`]]})}}),H=e.health,U=H?.phase===`failed`&&!H.inGracePeriod,ye=U&&H?.nextRetryAt&&!H.retrying,W=Ne(e.process);return t(`div`,{className:`rounded-md border bg-surface overflow-hidden ${U?`border-red-500/50`:`border-border`}`,children:[U&&H&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(ie,{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:w(`addons.addonCard.failedToLoad`,{attempt:H.retryCount})}),a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:H.lastError?.message??w(`addons.addonCard.unknownError`,`Unknown error`)}),ye&&H.nextRetryAt&&a(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:w(`addons.addonCard.autoRetryAt`,{time:new Date(H.nextRetryAt).toLocaleTimeString()})})]}),t(`button`,{type:`button`,disabled:V.isPending||H.retrying,onClick:e=>{e.stopPropagation(),V.mutate({packageName:L})},className:`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-semibold border border-red-400/40 bg-red-400/10 text-red-700 dark:text-red-300 hover:bg-red-400/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors shrink-0`,title:w(`addons.addonCard.resetRetryCounterAndForce`,`Reset retry counter and force immediate reload`),children:[a(f,{className:`h-3 w-3 ${V.isPending||H.retrying?`animate-spin`:``}`}),w(`addons.addonCard.retryNow`,`Retry now`)]})]}),W!==null&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(ie,{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:w(`addons.addonCard.processProblem.${W.kind}`)}),W.reason!==void 0&&a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:W.reason})]})]}),t(`div`,{className:`flex items-start gap-2.5 px-3 py-2`,children:[a(ot,{isBundle:F||!!P.components&&P.components.length>1,installSource:z,addonId:F?g.addons[0]?.manifest.id:P.id,iconPath:F?g.bundle?.icon??g.addons[0]?.manifest.icon:P.icon,color:F?g.addons[0]?.manifest.color:P.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:I}),!r&&a(st,{version:R,availableUpdate:i,...O===void 0?{}:{selectedVersion:O},isUpdating:d,installSource:z,disabled:v,...c&&O!==void 0?{onUpdate:()=>c(O)}:{},onOpenPicker:()=>D(e=>!e),children:ee&&a(nt,{packageName:L,currentVersion:R,...z?{installSource:z}:{},...i!==void 0&&O!==void 0?{selectedVersion:O,onSelect:e=>{re(e),D(!1)}}:{},onInstall:e=>{D(!1),pe.mutate({packageName:L,version:e})},onClose:()=>D(!1)})})]}),t(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[L!==I&&a(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:L}),F&&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(m,{className:`h-3 w-3`}),g.addons.length]}),y&&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:w(`addons.addonCard.systemPackageUpdatingRestartsThe`,`System package — updating restarts the hub`),children:[a(f,{className:`h-3 w-3`}),w(`addons.addonCard.system`,`System`)]}),_!=null&&a(Fe,{item:_}),h!=null&&a(He,{progress:h})]}),B&&a(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:B}),!F&&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`?w(`addons.addonCard.forked`):w(`addons.addonCard.inProcess`)}),e.process.pid!=null&&t(`span`,{className:`text-[9px] font-mono text-foreground-subtle`,children:[`PID `,e.process.pid]}),a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.state===`running`?`bg-emerald-500/15 text-emerald-400`:W===null?`bg-gray-500/15 text-gray-400`:`bg-red-500/15 text-red-400`}`,children:e.process.state})]})]})]}),!F&&t(`div`,{className:`flex items-center gap-1 px-3 py-1 border-t border-border/50 bg-surface-hover/20`,children:[t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),fe.mutate({addonId:P.id})},disabled:fe.isPending||v,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(f,{className:`h-3 w-3 ${fe.isPending?`animate-spin`:``}`}),w(`addons.addonCard.restart`,`Restart`)]}),t(`button`,{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(ne,{className:`h-3 w-3`}),w(`addons.addonCard.logs`,`Logs`)]}),!F&&t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),A(!0)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${k?`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(b,{className:`h-3 w-3`}),w(`addons.addonCard.settings`,`Settings`)]}),a(`div`,{className:`flex-1`}),ue&&a(Qe,{packageName:P.packageName,displayName:P.name,selectedNode:C??lt,disabled:v})]}),n&&n.nodes.length>1&&!F&&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:w(`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:w(`addons.addonCard.outdated`)}),e.status===`offline`&&a(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:w(`common.offline`)}),e.synced&&e.status!==`offline`&&a(`span`,{className:`text-[9px] text-success`,children:w(`common.synced`)})]},e.nodeId))})]}),ae&&!F&&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(`button`,{type:`button`,onClick:()=>M(`logs`),className:`px-2 py-0.5 transition-colors ${j===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:w(`addons.addonCard.logs`,`Logs`)}),a(`button`,{type:`button`,onClick:()=>M(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${j===`events`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:w(`addons.addonCard.events`,`Events`)})]}),a(`div`,{className:`flex-1`}),a(`button`,{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`})})]}),j===`logs`&&a(ve,{addonId:P.id,maxHeight:`max-h-64`,showFilters:!1}),j===`events`&&a(Te,{addonId:P.id,category:`addon.*`,maxHeight:`max-h-64`})]}),F&&t(u,{children:[a(`button`,{type:`button`,onClick:()=>E(e=>!e),className:`w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors`,children:a(T?p:S,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),T&&a(`div`,{className:`border-t border-border px-2.5 py-1.5 space-y-1.5`,children:g.addons.map(e=>a(ut,{addon:e,hideVersion:!0},e.manifest.id))})]}),k&&!F&&a(ke,{open:!0,onOpenChange:e=>!e&&A(!1),children:t(Oe,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(De,{children:t(me,{className:`flex items-center gap-2`,children:[a(b,{className:`h-4 w-4 text-primary`}),w(`addons.addonCard.settingsTitle`,{name:I})]})}),t(_e,{className:`space-y-4`,children:[a(`div`,{className:`text-[10px] text-foreground-subtle mb-2`,children:w(`addons.addonCard.clusterWideSettingsOneValue`,`Cluster-wide settings — one value for every node. Per-node settings live under Cluster → the node → Settings.`)}),a(Z,{nodeId:null,addonIds:[P.id],level:`global`,fieldScope:`cluster`,emptyMessage:w(`addons.addonCard.thisAddonExposesNoCluster`,`This addon exposes no cluster-wide settings. Anything it can configure is per-node — open it from Cluster → the node → Settings.`)}),it(P)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:w(`addons.addonCard.deviceExport`,`Device export`)}),a(de,{addonId:P.id,onOpenDevice:e=>ce(`/devices/${e}`)})]}),at(z)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:w(`addons.addonCard.autoUpdate`,`Auto-Update`)}),a(ct,{addonId:P.id})]}),P.components&&P.components.length>0&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:w(`addons.addonCard.components`,{count:P.components.length})}),a(`div`,{className:`flex flex-wrap gap-1`,children:P.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(se,{children:a(G,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>A(!1),children:w(`common.close`,`Close`)})})]})})]})}c();var dt=`.tgz,.tar.gz,.zip`;function ft({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(v(`/api/addons/upload`),{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:n})).json()).success&&e()}finally{c(!1)}},[e]);return t(u,{children:[a(`input`,{ref:l,type:`file`,accept:dt,onChange:i(e=>{let t=e.target.files?.[0];t&&d(t),e.target.value=``},[d]),className:`hidden`}),t(`button`,{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(T,{className:`w-3.5 h-3.5 animate-spin`}):a(_,{className:`w-3.5 h-3.5`}),o?r(`addons.addonUploadZone.uploading`,`Uploading...`):r(`addons.addonUploadZone.upload`,`Upload`)]})]})}var pt=/```[^\n]*\n([\s\S]*?)```/g;function mt(e){let t=[],n=0;for(let r of e.matchAll(pt)){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 ht(e){let t=e.trim();return t.startsWith(`https://`)||t.startsWith(`http://`)?t:null}function gt(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?ht(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 _t(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:gt(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:gt(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=gt(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 vt({markdown:e}){return a(`div`,{className:`text-xs text-foreground leading-relaxed`,children:mt(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:_t(e.body,`b${t}`)},`text-${t}`))})}c();function yt(e){return e.replace(/^@camstack\/(addon-)?/,``)}function bt(e,t,n){let r=et(e,n);return r.some(e=>e.version===t)?r:[{version:t,distTags:[],deprecated:void 0},...r]}function xt({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(T,{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(vt,{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 St({target:e,installing:n,installError:r,onClose:i,onInstall:o}){let{t:c}=q(),[l,u]=s(e.version),[d,f]=s(!1),p=k({name:e.name}),m=K({name:e.name,version:l}),h=p.data??[],g=tt(h),_=bt(h,l,d),v=m.data;return a(ke,{open:!0,onOpenChange:e=>!e&&i(),children:t(Oe,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(De,{children:a(me,{children:c(`addons.installDialog.title`,`Install {{name}}`,{name:yt(e.name)})})}),t(_e,{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(R,{"aria-label":c(`addons.installDialog.version`,`Version`),value:l,options:_.map(e=>({value:e.version,label:$e(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(G,{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(I,{defaultValue:`readme`,children:[t(ue,{children:[a(H,{value:`readme`,children:c(`addons.installDialog.readme`,`README`)}),a(H,{value:`changelog`,children:c(`addons.installDialog.changelog`,`CHANGELOG`)})]}),a(Se,{value:`readme`,children:a(`div`,{className:`max-h-80 overflow-auto rounded-md border border-border bg-background p-3`,children:a(xt,{pending:m.isPending,failed:m.isError,body:v?.readme,missing:c(`addons.installDialog.missingReadme`,`This package has no README.`)})})}),a(Se,{value:`changelog`,children:a(`div`,{className:`max-h-80 overflow-auto rounded-md border border-border bg-background p-3`,children:a(xt,{pending:m.isPending,failed:m.isError,body:v?.changelog,missing:c(`addons.installDialog.missingChangelog`,`This package has no CHANGELOG.`)})})})]}),r!=null&&r.length>0&&a(`p`,{className:`text-xs text-danger`,children:r})]}),t(se,{children:[a(G,{type:`button`,variant:`outline`,size:`sm`,onClick:i,children:c(`common.cancel`,`Cancel`)}),a(G,{type:`button`,size:`sm`,disabled:n||l.length===0,onClick:()=>o(e.name,l),children:n?a(T,{className:`h-3.5 w-3.5 animate-spin`}):c(`addons.installDialog.install`,`Install`)})]})]})})}var Ct=new Set([`@camstack/system`,`@camstack/types`,`@camstack/sdk`,`@camstack/ui-library`,`@camstack/addon-agent-ui`]);function wt(e,t){let n=new Map;for(let r of e){if(r.isHub||r.onHub||Ct.has(r.packageName)||!t.isHub&&r.nodeId!==t.id)continue;let e=n.get(r.packageName)??[];e.push(r),n.set(r.packageName,e)}return[...n].map(([e,t])=>({packageName:e,rows:t})).sort((e,t)=>e.packageName.localeCompare(t.packageName))}function Tt({selectedNode:e}){let{t:n}=q(),{data:r}=V(Ye,{staleTime:Xe});if(r===void 0)return null;let i=wt(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(re,{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(Qe,{packageName:n.packageName,displayName:n.packageName,selectedNode:e,hideNodeAction:e.isHub})]},n.packageName))]})}function Et({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(ye,{variant:`success`,icon:a(d,{className:`h-3 w-3`}),children:e.installedVersion??i(`system.capabilityCatalog.installed`,`Installed`)}):t(G,{size:`sm`,onClick:()=>r(e),disabled:n,className:`shrink-0`,children:[n?a(T,{className:`h-3 w-3 animate-spin`}):a(y,{className:`h-3 w-3`}),i(`system.capabilityCatalog.install`,`Install`)]})]})}function Dt({capability:e,installing:n,onInstall:r}){let{t:i}=q(),{data:o,isPending:s,isError:c}=U({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(T,{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(Et,{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 Ot(e){return e===`npm`||e===`dev`?e:null}var kt=`rounded-full border border-primary bg-primary/10 px-2 py-0.5 text-[10px] text-foreground`,At=`rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-muted hover:bg-surface-hover`,jt=[{seconds:900,label:`15m`},{seconds:3600,label:`1h`},{seconds:21600,label:`6h`},{seconds:43200,label:`12h`},{seconds:86400,label:`24h`}],Mt={id:`hub`,name:`Hub`,isHub:!0,isOnline:!0};function Nt(e,t){let n=e??`hub-only`;return n===`any-node`?!0:n===`hub-only`?t:!t}function Pt(e){return e===`local`?`dev`:`npm`}function Ft(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 It(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 Lt({addons:c,clusterStatus:u,selectedNode:d,onRefresh:p,listPhase:m}){let{t:h}=q(),g=l(),[_,v]=s(``),b=e(_),[x,S]=s(!1),C=n(null);o(()=>{if(!x)return;let e=e=>{C.current&&!C.current.contains(e.target)&&S(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[x]);let{data:w}=F({nodeId:d.id}),E=r(()=>{let e=new Map;for(let t of w??[])e.set(t.name,t.latestVersion);return e},[w]),ne=r(()=>(w??[]).filter(e=>!e.isSystem).length,[w]),[re,O]=s(()=>new Set),[ie,ae]=s(()=>new Map),k=i(e=>{O(t=>new Set(t).add(e))},[]),se=i(e=>{O(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),A=i((e,t)=>{ae(n=>new Map(n).set(e,t))},[]),j=i(e=>{ae(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),M=Ce({onMutate:e=>{k(e.name),j(e.name)},onSuccess:(e,t)=>{se(t.name);let n=e;if(n&&n.success===!1){A(t.name,n.error??`Update failed (no error message returned by server)`);return}g.invalidateQueries({queryKey:[[`addons`]]}),g.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]})},onError:(e,t)=>{se(t.name),A(t.name,e instanceof Error?e.message:String(e))}}),N=Be(),ce=n(new Set);o(()=>{let e=new Set;for(let[t,n]of N)Re(n)&&e.add(t);let t=[...ce.current].some(t=>!e.has(t));ce.current=e,t&&(g.invalidateQueries({queryKey:[[`addons`]]}),g.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[N,g]);let{data:P}=L(void 0),le=z({onSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),ue=oe({onSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:I,isFetching:de}=U({query:b||void 0},{enabled:x}),R=Ee(),{data:B}=pe(void 0),me=B?.requestedAt,[V,ge]=s(null),[H,_e]=s(!1);o(()=>{if(B?.kind===`framework-bulk-update`&&B.requestedAt!==V){ge(B.requestedAt),_e(!0);let e=window.setTimeout(()=>_e(!1),6e3);return()=>window.clearTimeout(e)}},[me,V,B]),ee();let ve=i(async()=>{let e=(w??[]).filter(e=>!e.isSystem);if(e.length!==0){if(!d.isHub){for(let t of e)await M.mutateAsync({name:t.name,version:t.latestVersion,nodeId:d.id});return}await R.mutateAsync({kind:`update`,targets:e.map(e=>({name:e.name,version:e.latestVersion})),nodeIds:[d.id]})}},[w,d.id,d.isHub,R,M]),[ye,W]=s(null),[be,xe]=s(null),Se=e=>{xe(null),W(e)},G=he({onSuccess:()=>{W(null),xe(null),g.invalidateQueries({queryKey:[[`addons`]]}),g.invalidateQueries({queryKey:[[`addonPages`]]}),g.invalidateQueries({queryKey:[[`capabilities`]]}),g.invalidateQueries({queryKey:[[`integrations`]]})},onError:e=>{xe(e instanceof Error?e.message:`Install failed`)}}),[we,Te]=s(`type`),[De,Oe]=s(()=>typeof window>`u`?`grouped`:window.localStorage.getItem(`camstack.addons.viewMode`)===`flat`?`flat`:`grouped`),ke=e=>{Oe(e),typeof window<`u`&&window.localStorage.setItem(`camstack.addons.viewMode`,e)},[K,J]=Ae(),Y=K.get(`capability`),X=K.get(`updatable`)===`1`,Z=K.get(`error`)===`1`,Q=Ot(K.get(`source`)),Me=i(e=>{let t=new URLSearchParams(K);e?t.set(`updatable`,`1`):t.delete(`updatable`),J(t,{replace:!0})},[K,J]),Pe=i(e=>{let t=new URLSearchParams(K);e?t.set(`error`,`1`):t.delete(`error`),J(t,{replace:!0})},[K,J]),Fe=i(e=>{let t=new URLSearchParams(K);e===null?t.delete(`source`):t.set(`source`,e),J(t,{replace:!0})},[K,J]),Ie=r(()=>c.filter(e=>Ne(e.process)!==null).length,[c]),Le=r(()=>{let e=c.filter(e=>!je(e.manifest.packageName));return d.isHub||(e=e.filter(e=>Nt(e.placement,d.isHub))),Y&&(e=e.filter(e=>(e.manifest.capabilities??[]).some(e=>(typeof e==`string`?e:e.name)===Y))),X&&(e=e.filter(e=>{let t=e.manifest.packageName;return t!==void 0&&E.has(t)})),Q!==null&&(e=e.filter(e=>Pt(e.installSource)===Q)),Z&&(e=e.filter(e=>Ne(e.process)!==null)),e},[c,d.isHub,Y,X,Q,Z,E]),ze=()=>{let e=new URLSearchParams(K);e.delete(`capability`),J(e,{replace:!0})},Ve=De===`flat`?Le:It(Le),He=r(()=>{let e=[...Ve];switch(we){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},[Ve,we]);return t(`div`,{className:`space-y-3`,children:[[...ie.entries()].map(([e,n])=>a(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-2.5 py-1.5 text-[11px]`,children:t(`div`,{className:`flex items-start justify-between gap-3`,children:[t(`div`,{className:`space-y-0.5`,children:[a(`div`,{className:`font-medium text-danger`,children:h(`systemPage.addons.updateFailed`,{name:e})}),a(`div`,{className:`text-foreground-subtle font-mono`,children:n})]}),a(`button`,{type:`button`,onClick:()=>j(e),className:`text-foreground-subtle hover:text-foreground text-[10px]`,children:h(`common.dismiss`)})]})},e)),t(`div`,{className:`flex items-center gap-x-2 gap-y-1.5 flex-wrap`,children:[t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.sort`,`Sort:`)}),t(`select`,{value:we,onChange:e=>Te(e.target.value),className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:outline-none focus:border-primary/50`,children:[a(`option`,{value:`type`,children:h(`admin.system.addons.bundlesFirst`,`Bundles first`)}),a(`option`,{value:`name`,children:h(`admin.system.addons.name`,`Name`)}),a(`option`,{value:`source`,children:h(`admin.system.addons.installSource`,`Install source`)})]})]}),t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.view`,`View:`)}),a(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`grouped`,`flat`].map(e=>a(`button`,{type:`button`,onClick:()=>ke(e),className:`px-2 py-1 transition-colors capitalize ${De===e?`bg-primary/10 text-primary`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`}`,title:e===`grouped`?h(`admin.system.addons.groupMultiAddonPackagesInto`,`Group multi-addon packages into a bundle card`):h(`admin.system.addons.showEveryAddonAsIts`,`Show every addon as its own card`),children:e},e))})]}),d.isHub&&t(`div`,{className:`flex items-center gap-1.5`,children:[a(f,{className:`h-3 w-3 text-foreground-subtle`}),a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.autoUpdate`,`Auto-Update:`)}),a(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`off`,`latest`,`beta`].map(e=>a(`button`,{type:`button`,onClick:()=>le.mutate({channel:e}),disabled:le.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:h(`admin.system.addons.checkEvery`,`Check every:`)}),a(`select`,{className:`rounded-md border border-border bg-transparent px-1.5 py-1 text-[10px] font-medium text-foreground-subtle`,value:P?.updateCheckIntervalSeconds??21600,disabled:ue.isPending||P===void 0,onChange:e=>{P!==void 0&&ue.mutate({channel:P.channel,updateCheckIntervalSeconds:Number(e.target.value)})},children:jt.map(e=>a(`option`,{value:e.seconds,children:e.label},e.seconds))})]}),ne>0&&t(`button`,{type:`button`,onClick:()=>void ve(),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(T,{className:`w-3 h-3 animate-spin`}):a(y,{className:`w-3 h-3`}),R.isPending?h(`admin.system.addons.updating`,`Updating…`):h(`admin.system.addons.updateAll`,`Update All ({{nonSystemUpdateCount}})`,{nonSystemUpdateCount:ne})]})]}),t(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`group`,"aria-label":h(`admin.system.addons.filterInstalledAddons`,`Filter installed addons`),children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.filter`,`Filter:`)}),[{id:`updatable`,label:h(`admin.system.addons.updatable`,`Updatable`),pressed:X,toggle:()=>Me(!X)},{id:`error`,label:h(`admin.system.addons.inError`,`In error ({{count}})`,{count:Ie}),pressed:Z,toggle:()=>Pe(!Z)},{id:`npm`,label:`npm`,pressed:Q===`npm`,toggle:()=>Fe(Q===`npm`?null:`npm`)},{id:`dev`,label:h(`admin.system.addons.dev`,`Dev`),pressed:Q===`dev`,toggle:()=>Fe(Q===`dev`?null:`dev`)}].map(e=>a(`button`,{type:`button`,"aria-pressed":e.pressed,onClick:e.toggle,className:e.pressed?kt:At,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:C,children:[a(fe,{type:`text`,searchHotkey:!0,value:_,onChange:e=>{v(e.target.value),S(!0)},onFocus:()=>S(!0),placeholder:h(`admin.system.addons.searchAddonsOnNpm`,`Search addons on npm...`),"aria-label":h(`admin.system.addons.searchAddonsOnNpm2`,`Search addons on npm`),disabled:R.isPending,leftSlot:a(D,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),rightSlot:de?a(T,{className:`h-3 w-3 animate-spin`}):void 0}),x&&I&&I.length>0&&t(`div`,{className:`absolute left-0 right-0 top-full mt-1 z-40 rounded-md border border-border bg-surface shadow-xl overflow-hidden`,children:[I.length>0&&a(`div`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:h(`systemPage.addons.npmResults`,{count:I.length})}),I&&I.length>0&&a(`div`,{className:`max-h-72 overflow-auto divide-y divide-border`,children:I.map(e=>a(Et,{addon:e,installing:G.isPending,onInstall:e=>Se({name:e.name,version:e.version,description:e.description})},e.name))})]})]}),a(ft,{onUploadSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`]]}),p()}})]}),Y&&t(`div`,{className:`flex items-center gap-2 px-2.5 py-1.5 rounded-md bg-primary/10 border border-primary/30 text-xs`,children:[a(`span`,{className:`text-foreground-subtle`,children:h(`admin.system.addons.filteringByCapability`,`Filtering by capability:`)}),a(`span`,{className:`font-mono text-primary font-semibold`,children:Y}),a(`button`,{type:`button`,onClick:ze,className:`ml-auto text-xs text-foreground-subtle hover:text-foreground underline`,children:h(`admin.system.addons.clear`,`Clear`)})]}),Y&&a(Dt,{capability:Y,installing:G.isPending,onInstall:e=>Se({name:e.name,version:e.version,description:e.description})}),Y&&Le.length>0&&a(`h2`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:h(`admin.system.addons.installed`,`Installed`)}),H&&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 backdrop-blur-sm max-w-sm pointer-events-auto`,children:[a(te,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),t(`div`,{children:[a(`div`,{className:`text-[11px] font-semibold text-foreground`,children:h(`admin.system.addons.bulkUpdateCompleted`,`Bulk update completed`)}),a(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:h(`admin.system.addons.systemPackagesUpdatedHubRestarted`,`System packages updated — hub restarted successfully.`)})]})]}),m===`pending`&&t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[a(T,{className:`h-3 w-3 animate-spin`}),h(`admin.system.addons.loadingInstalled`,`Loading installed addons…`)]}),m===`error`&&a(`div`,{className:`text-xs text-danger`,children:h(`admin.system.addons.failedToLoadAddons`,`Failed to load addons`)}),m===`ready`&&Le.length===0&&a(`div`,{className:`text-xs text-foreground-subtle`,children:c.length===0?h(`admin.system.addons.noAddonsInstalled`,`No addons installed`):Y?h(`admin.system.addons.noInstalledAddonDeclaresThe`,`No installed addon declares the "{{capabilityFilter}}" capability. Any addon you can install appears under "Available to install" above.`,{capabilityFilter:Y}):h(`admin.system.addons.noAddonsCompatibleWithPlacement`,`No addons compatible with {{name}} (placement filter active)`,{name:d.name})}),a(`div`,{className:`space-y-1.5`,children:m===`ready`&&He.map(e=>{let t=$(e)?e.bundle.packageName:e.manifest.packageName,n=E.get(t),r=$(e)?e.representative:e,i=n?e=>M.mutate({name:t,version:e,nodeId:d.id}):void 0,o=N.get(t)??null,s=o!==null&&Re(o);return a(ut,{addon:r,clusterStatus:u?.[r.manifest.id],bundle:$(e)?e.bundle:void 0,availableUpdate:n,isUpdating:re.has(t)||s,jobProgress:o,onUpdate:i,disabledByBulk:R.isPending,selectedNode:d},$(e)?t:e.manifest.id)})}),ye!==null&&a(St,{target:ye,installing:G.isPending,installError:be,onClose:()=>W(null),onInstall:(e,t)=>G.mutate({packageName:e,version:t})})]})}function Rt(){let{t:e}=q(),r=l(),{data:i}=j(void 0),{nodes:s}=W(),{selection:c,selectNode:u,requestedNodeId:d}=Me(s.length>0?s:[Mt]),p=c.node??Mt,m=p.id,h=s.length>0?c.staleNodeId:null,{data:g,isLoading:_,isError:v}=ce({nodeId:m}),y=M(),b=xe(),x=y.isPending||b.isPending,S=async()=>{await y.mutateAsync({nodeId:m}),await b.mutateAsync(),r.invalidateQueries({queryKey:[[`addons`]]})},C=n(y);C.current=y;let w=n(d??`hub`);o(()=>{C.current.mutate({nodeId:w.current})},[]);let T=(g??[]).map(Ft).filter(e=>e!==null);return t(X,{children:[t(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[a(A,{selectedNodeId:m,onSelect:u}),t(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[!_&&!v&&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(`button`,{type:`button`,onClick:()=>void S(),disabled:x,className:`inline-flex items-center gap-1 px-2 py-1 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,title:e(`admin.system.addons.reFetchAddonsCheckNpm`,`Re-fetch addons + check npm for new versions`),children:[a(f,{className:`w-3 h-3 ${x?`animate-spin`:``}`}),e(`admin.system.addons.checkForUpdates`,`Check for updates`)]})]})]}),a(Q,{staleNodeId:h,shownNodeName:p.name}),a(Tt,{selectedNode:p}),a(Lt,{addons:T,clusterStatus:i,selectedNode:p,onRefresh:()=>void S(),listPhase:_?`pending`:v?`error`:`ready`})]})}export{Rt as AddonsPage};
|
|
@@ -1 +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,et as s,o as c,x as l}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Dn as u,Q as d,pr as f,qr as p}from"./player-overlays-Cw_gjG75.js";import{Vo as m}from"./client-r4i0EpF6.js";import{t as h}from"./log-in-9Uirjetj.js";import{Da as g,Ia as _,Jn as v,Kn as y,Ma as b,Na as x,Nr as S,Oa as C,Ra as w,Sn as T,Sr as E,Tr as D,Yn as O,br as k,gr as A,ka as j,ri as M,wr as N,xr as ee,yr as P}from"./src-nnHXOip7.js";import{t as F}from"./i18n-BE1bPZOs.js";import{t as I}from"./useTranslation-BJr-n0es.js";import"./mount-B_Zjyqyk.js";import{R as L,g as te,mr as ne}from"./index-Ohn-2iW_.js";s();function re(e,t){let n=e=>e.map(e=>e.type===`group`?{...e,fields:n(e.fields)}:e.type===`sub-tabs`?{...e,tabs:e.tabs.map(e=>({...e,fields:n(e.fields)}))}:e.type===`info`&&typeof e.content==`string`?{...e,content:e.content.split(`{{brokerId}}`).join(t)}:e);return{...e,sections:e.sections.map(e=>({...e,fields:n(e.fields)}))}}var ie=`broker-advanced`;function R(e){return`key`in e&&typeof e.key==`string`&&`label`in e}function ae(e){let t=new Set;for(let n of e){if(!R(n))continue;let e=n.showWhen;if(e===void 0)continue;let r=Array.isArray(e)?e:[e];for(let e of r)typeof e==`object`&&e&&`field`in e&&typeof e.field==`string`&&t.add(e.field)}return t}function oe(e,t,n){return!R(e)||e.showWhen!==void 0||t.has(e.key)?!1:n&&e.filledBySignIn===!0?!0:e.default!==void 0||e.defaultByCountry!==void 0}function se(e,t){let n=[],r=[];for(let i of e.sections){let e=ae(i.fields),a=[];for(let r of i.fields)oe(r,e,t.hasSignIn)?n.push(r):a.push(r);if(a.length>0)r.push({...i,fields:a});else if(i.description!==void 0){let{description:e,...t}=i;r.push({...t,fields:[{type:`info`,key:`${i.id}-note`,label:``,content:e}]})}}return n.length>0&&r.push({id:ie,title:t.advancedTitle,style:`accordion`,defaultCollapsed:!0,columns:1,fields:n}),{...e,sections:r}}function ce(e){if(e===void 0)return null;let t=/[-_]([A-Za-z]{2})(?:[-_]|$)/.exec(e);return t?.[1]===void 0?null:t[1].toUpperCase()}function le(e,t,n){if(e===void 0||t===null)return{};let r={};for(let i of e.sections)for(let e of i.fields){if(!R(e)||n[e.key]!==void 0)continue;let i=e.defaultByCountry;i!==void 0&&t in i&&(r[e.key]=i[t])}return r}var ue=[`starting`,`awaiting-login`,`captured`,`error`,`cancelled`],de=[`awaiting-code`,`captured`,`expired`,`error`,`cancelled`];function z(e){return typeof e==`object`&&!!e}function fe(e){return z(e)&&typeof e.sessionId==`string`&&typeof e.loginUrl==`string`}function pe(e){return z(e)&&typeof e.sessionId==`string`&&typeof e.phase==`string`&&ue.includes(e.phase)}function B(e){return z(e)&&typeof e.sessionId==`string`&&typeof e.userCode==`string`&&typeof e.verificationUrl==`string`&&typeof e.expiresAt==`number`}function me(e){return B(e)&&z(e)&&typeof e.phase==`string`&&de.includes(e.phase)}function he(e){return z(e)&&typeof e.brokerId==`string`}function V(){return{"Content-Type":`application/json`,Authorization:`Bearer ${localStorage.getItem(`camstack_admin_token`)??``}`}}async function H(e,t){try{return await e.json()}catch{throw Error(`${t} failed: HTTP ${e.status}`)}}function U(e){let t=z(e)&&typeof e.error==`string`?e.error:`Unknown error`;return Error(t)}async function W(e,t,n){let r=await fetch(d(e),{method:`POST`,headers:V(),body:JSON.stringify(t)}),i=await H(r,`Sign-in ${e.split(`/`).pop()??`request`}`);if(!r.ok)throw U(i);if(!n(i))throw Error(`Unexpected response from server`);return i}function ge(e,t){return W(`${e}/start`,t,fe)}function _e(e,t){return W(`${e}/code/start`,t,B)}async function ve(e,t){let n=new URLSearchParams({sessionId:t}),r=await fetch(d(`${e}/status?${n.toString()}`),{headers:{Authorization:V().Authorization??``}}),i=await H(r,`Sign-in status`);if(!r.ok)throw U(i);if(!me(i))throw Error(`Unexpected status response from server`);return i}async function ye(e,t){let n=new URLSearchParams({sessionId:t}),r=await fetch(d(`${e}/status?${n.toString()}`),{headers:{Authorization:V().Authorization??``}}),i=await H(r,`Sign-in status`);if(!r.ok)throw U(i);if(!pe(i))throw Error(`Unexpected status response from server`);return i}function be(e,t){return W(`${e}/commit`,{...t},he)}async function xe(e,t){try{await fetch(d(`${e}/cancel`),{method:`POST`,headers:V(),body:JSON.stringify({sessionId:t})})}catch{}}var Se=2e3,Ce=1e3;function we(e){let t=Math.max(0,Math.ceil(e/1e3));return`${Math.floor(t/60)}:${(t%60).toString().padStart(2,`0`)}`}function Te({expiresAt:e}){let{t}=I(),[n,r]=o(()=>Date.now());return a(()=>{let e=setInterval(()=>r(Date.now()),Ce);return()=>clearInterval(e)},[]),i(`span`,{className:`text-[11px] text-foreground-subtle`,children:t(`brokers.signIn.codeExpiresIn`,{time:we(e-n)})})}function Ee({basePath:n,name:s,brokerId:c,getSettings:l,disabled:d,onSignedIn:m}){let{t:g}=I(),[_,v]=o({kind:`idle`}),y=t(!0),b=t(null),x=t(null),C=r(()=>{x.current!==null&&clearInterval(x.current),x.current=null},[]),w=r(()=>{C();let e=b.current;b.current=null,e!==null&&xe(n,e)},[n,C]);a(()=>(y.current=!0,()=>{y.current=!1,w()}),[w]);let E=r(e=>{C(),y.current&&v({kind:`error`,message:e})},[C]),D=r(async e=>{C(),y.current&&v({kind:`committing`});try{let t=await be(n,{sessionId:e,name:s,...c===void 0?{}:{brokerId:c}});b.current=null,y.current&&m(t.brokerId)}catch(e){E(e instanceof Error?e.message:String(e))}},[n,c,E,s,m,C]),O=r(e=>{C(),x.current=setInterval(()=>{(async()=>{try{let t=await ve(n,e);if(t.phase===`captured`)return void await D(e);if(t.phase===`error`)return E(t.error??g(`brokers.signIn.proxyError`));if(t.phase===`expired`){C(),y.current&&v({kind:`expired`});return}t.phase===`cancelled`&&(C(),y.current&&v({kind:`idle`}))}catch{}})()},Se)},[n,D,E,C,g]),k=async()=>{w(),v({kind:`starting`});try{let e=await _e(n,l());b.current=e.sessionId,v({kind:`waiting`,code:e}),O(e.sessionId)}catch(e){E(e instanceof Error?e.message:String(e))}},A=()=>{w(),v({kind:`idle`})};if(_.kind===`idle`||_.kind===`error`||_.kind===`expired`)return e(`div`,{className:`space-y-2`,children:[_.kind===`error`&&i(S,{message:_.message}),_.kind===`expired`&&i(`p`,{className:`text-xs text-warning`,children:g(`brokers.signIn.codeExpired`)}),i(`p`,{className:`text-xs text-foreground-muted`,children:g(`brokers.signIn.codeIntro`)}),e(M,{variant:`primary`,size:`sm`,disabled:d===!0||s.trim().length===0,onClick:()=>void k(),children:[_.kind===`idle`?i(h,{className:`h-3.5 w-3.5`}):i(u,{className:`h-3.5 w-3.5`}),` `,_.kind===`idle`?g(`brokers.signIn.getCode`):g(`brokers.signIn.newCode`)]})]});if(_.kind===`starting`||_.kind===`committing`)return e(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[i(f,{className:`h-4 w-4 animate-spin flex-shrink-0`}),_.kind===`starting`?g(`brokers.signIn.starting`):g(`brokers.signIn.saving`)]});let{code:j}=_;return e(`div`,{className:`space-y-3 rounded-lg border border-border bg-surface p-3`,children:[i(`p`,{className:`text-xs text-foreground-muted`,children:g(`brokers.signIn.codeInstructions`)}),e(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-border-subtle bg-background px-3 py-2`,children:[i(`span`,{"data-testid":`device-code`,className:`font-mono text-2xl font-semibold tracking-widest text-foreground break-all`,children:j.userCode}),i(T,{value:j.userCode,srLabel:g(`brokers.signIn.copyCode`)})]}),e(M,{variant:`primary`,size:`sm`,onClick:()=>window.open(j.verificationUrl,`_blank`,`noopener,noreferrer`),children:[i(p,{className:`h-3.5 w-3.5`}),` `,g(`brokers.signIn.openCodePage`,{host:De(j.verificationUrl)})]}),e(`div`,{className:`flex flex-wrap items-center justify-between gap-2 pt-1`,children:[e(`span`,{className:`flex min-w-0 flex-col text-[11px] text-foreground-subtle`,children:[e(`span`,{className:`flex items-center gap-2`,children:[i(f,{className:`h-3 w-3 animate-spin flex-shrink-0`}),` `,g(`brokers.signIn.waitingForCode`)]}),i(Te,{expiresAt:j.expiresAt})]}),i(M,{variant:`outline`,size:`sm`,className:`shrink-0 whitespace-nowrap`,onClick:A,children:g(`brokers.signIn.cancel`)})]})]})}function De(e){try{let t=new URL(e);return`${t.host}${t.pathname===`/`?``:t.pathname}`}catch{return e}}s();var Oe=2e3;function ke(e){return e.startsWith(`/`)&&!e.startsWith(`//`)?new URL(e,window.location.origin).toString():e}function Ae({basePath:n,name:s,brokerId:c,getSettings:u,disabled:d,onSignedIn:m}){let{t:g}=I(),[_,v]=o({kind:`idle`}),y=t(!0),b=t(null),x=t(null),C=r(()=>{x.current!==null&&clearInterval(x.current),x.current=null},[]),w=r(()=>{C();let e=b.current;b.current=null,e!==null&&xe(n,e)},[n,C]);a(()=>(y.current=!0,()=>{y.current=!1,w()}),[w]);let T=r(e=>{C(),y.current&&v({kind:`error`,message:e})},[C]),E=r(async e=>{C(),y.current&&v({kind:`committing`});try{let t=await be(n,{sessionId:e,name:s,...c===void 0?{}:{brokerId:c}});b.current=null,y.current&&m(t.brokerId)}catch(e){T(e instanceof Error?e.message:String(e))}},[n,c,T,s,m,C]),D=r(e=>{C(),x.current=setInterval(()=>{(async()=>{try{let t=await ye(n,e);if(t.phase===`captured`)return void await E(e);if(t.phase===`error`)return T(t.error??g(`brokers.signIn.proxyError`));if(t.phase===`cancelled`){C(),y.current&&v({kind:`idle`});return}y.current&&v({kind:`waiting`,loginUrl:t.loginUrl,ready:t.phase===`awaiting-login`})}catch{}})()},Oe)},[n,E,T,C,g]),O=async()=>{w(),v({kind:`starting`});try{let e=await ge(n,u());b.current=e.sessionId,v({kind:`waiting`,loginUrl:e.loginUrl,ready:!1}),D(e.sessionId)}catch(e){T(e instanceof Error?e.message:String(e))}};return _.kind===`idle`||_.kind===`error`?e(`div`,{className:`space-y-2`,children:[_.kind===`error`&&i(S,{message:_.message}),i(`p`,{className:`text-xs text-foreground-muted`,children:g(`brokers.signIn.intro`)}),e(M,{variant:`primary`,size:`sm`,disabled:d===!0||s.trim().length===0,onClick:()=>void O(),children:[i(h,{className:`h-3.5 w-3.5`}),` `,_.kind===`error`?g(`common.retry`):g(`brokers.signIn.start`)]})]}):_.kind===`starting`||_.kind===`committing`?e(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[i(f,{className:`h-4 w-4 animate-spin flex-shrink-0`}),_.kind===`starting`?g(`brokers.signIn.starting`):g(`brokers.signIn.saving`)]}):e(`div`,{className:`space-y-2 rounded-lg border border-border bg-surface p-3`,children:[_.ready?e(l,{children:[i(`p`,{className:`text-xs font-semibold text-foreground`,children:g(`brokers.signIn.openLink`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:g(`brokers.signIn.afterLogin`)}),e(M,{variant:`primary`,size:`sm`,onClick:()=>window.open(ke(_.loginUrl),`_blank`,`noopener,noreferrer`),children:[i(p,{className:`h-3.5 w-3.5`}),` `,g(`brokers.signIn.openLoginPage`)]})]}):e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(f,{className:`h-4 w-4 animate-spin flex-shrink-0`}),g(`brokers.signIn.waitingForProxy`)]}),e(`div`,{className:`flex items-center justify-between gap-2 pt-1`,children:[e(`span`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[i(f,{className:`h-3 w-3 animate-spin`}),` `,g(`brokers.signIn.waitingForLogin`)]}),i(M,{variant:`outline`,size:`sm`,onClick:()=>{w(),v({kind:`idle`})},children:g(`brokers.signIn.cancel`)})]})]})}s();var je=[`device-code`];function Me({methods:t,...n}){let{t:r}=I(),a=t!==void 0&&t.length>0?t:je,[s,c]=o(null),l=s!==null&&a.includes(s)?s:a[0]??`device-code`;return e(`div`,{className:`space-y-2`,children:[a.length>1&&i(y,{value:l,onValueChange:e=>c(e===`device-code`?e:`proxy`),appearance:`pills`,children:i(v,{"aria-label":r(`brokers.signIn.method`),children:a.map(e=>i(O,{value:e,children:r(e===`device-code`?`brokers.signIn.methodDeviceCode`:`brokers.signIn.methodProxy`)},e))})}),l===`device-code`?i(Ee,{...n},`device-code`):i(Ae,{...n},`proxy`)]})}s();function G(e,t){if(!e)return t;let n=new Set;for(let r of e.sections){let e=r.fields;for(let r of e)!(`key`in r)||typeof r.key!=`string`||A(r,t,e)&&n.add(r.key)}let r={};for(let[e,i]of Object.entries(t))n.has(e)&&(r[e]=i);return r}function Ne({kind:t,addonId:r,brokerId:s,initialValues:c,onSubmit:l,onCancel:u,submitLabel:d,disabled:p,signIn:h}){let{t:g}=I(),[_,v]=o(c??{}),[y,b]=o(null),x=j({kind:t,...r===void 0?{}:{addonId:r}}),S=n(()=>{let e=x.data;if(e&&typeof e==`object`&&`sections`in e&&Array.isArray(e.sections)){let t=e;return se(m(s===void 0?t:re(t,s),_),{hasSignIn:h!==void 0,advancedTitle:g(`brokers.brokerForm.advanced`)})}},[x.data,s,_,h!==void 0,g]);a(()=>{c!==void 0&&v(c)},[c]);let C=ce(typeof navigator>`u`?void 0:navigator.language);a(()=>{if(c!==void 0)return;let e=le(S,C,_);Object.keys(e).length>0&&v(t=>({...e,...t}))},[S,C,c,_]);let T=w(),E=async()=>{b(null);let e=G(S,_);try{let n=await T.mutateAsync({kind:t,settings:e,...r===void 0?{}:{addonId:r}});b(n.ok?{ok:!0}:{ok:!1,error:n.error})}catch(e){b({ok:!1,error:e instanceof Error?e.message:String(e)})}},D=()=>{let{_calendarCatalog:e,...t}=G(S,_);l(t)},O=()=>{let e=new Set;for(let t of S?.sections??[])for(let n of t.fields)R(n)&&n.filledBySignIn===!0&&e.add(n.key);let t=G(S,_);return Object.fromEntries(Object.entries(t).filter(([t])=>!e.has(t)))};return e(`div`,{className:`space-y-3`,children:[h!==void 0&&i(Me,{basePath:h.basePath,...h.methods===void 0?{}:{methods:h.methods},name:h.name,...h.brokerId===void 0?{}:{brokerId:h.brokerId},getSettings:O,disabled:p===!0,onSignedIn:h.onSignedIn}),x.isLoading&&e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(f,{className:`h-3.5 w-3.5 animate-spin`}),` `,g(`brokers.brokerForm.loadingSchema`)]}),S&&i(L,{schema:S,values:_,onChange:v}),x.isError&&e(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:[g(`brokers.brokerForm.failedToLoadSettingsSchema`,`Failed to load settings schema:`),` `,x.error instanceof Error?x.error.message:g(`brokers.brokerForm.unknownError`,`Unknown error`)]}),!S&&!x.isLoading&&!x.isError&&i(`div`,{className:`rounded border border-warning/30 bg-warning/10 px-3 py-2 text-[11px] text-warning`,children:i(ne,{i18nKey:`brokers.brokerForm.noSchema`,values:{kind:t},components:{code:i(`code`,{className:`font-mono`})}})}),y&&i(`div`,{className:`rounded border px-3 py-2 text-[11px] ${y.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:y.ok?g(`brokers.brokerForm.connectionOk`,`Connection OK.`):g(`brokers.brokerForm.testFailed`,`Test failed: {{value1}}`,{value1:y.error??`unknown error`})}),e(`div`,{className:`flex items-center justify-between gap-2 pt-1`,children:[i(M,{variant:`outline`,size:`sm`,onClick:u,children:g(`common.cancel`,`Cancel`)}),e(`div`,{className:`flex items-center gap-2`,children:[i(M,{variant:`outline`,size:`sm`,onClick:()=>{E()},disabled:T.isPending||!S,children:T.isPending?g(`brokers.brokerForm.testing`,`Testing…`):g(`brokers.brokerForm.testConnection`,`Test connection`)}),i(M,{variant:h===void 0?`primary`:`outline`,size:`sm`,onClick:D,disabled:!S||p,children:d??g(`common.save`,`Save`)})]})]})]})}s();function K(e){return e===void 0?``:`${e.addonId??``}::${e.kind}`}function q(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`):[]}function Pe(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.addonId==`string`&&Array.isArray(e.kinds)):[]}function J(e){return typeof e==`string`&&e.length>0?e:void 0}function Fe(e){let t=new Map;for(let n of e.providers)if(!(e.addonId!==void 0&&n.addonId!==e.addonId))for(let r of n.kinds){if(e.kind!==void 0&&r.kind!==e.kind)continue;let i=J(r.interactiveConnectPath),a=J(r.interactiveDisconnectPath),o=J(r.signIn?.basePath);t.set(`${n.addonId}::${r.kind}`,{addonId:n.addonId,kind:r.kind,label:r.label,...i===void 0?{}:{interactiveConnectPath:i},...a===void 0?{}:{interactiveDisconnectPath:a},...o===void 0?{}:{signInBasePath:o},...o!==void 0&&r.signIn?.methods!==void 0&&r.signIn.methods.length>0?{signInMethods:r.signIn.methods}:{}})}for(let n of e.brokers)e.kind!==void 0&&n.kind!==e.kind||[...t.values()].some(e=>e.kind===n.kind)||t.set(`::${n.kind}`,{kind:n.kind,label:n.kind});return[...t.values()]}function Y(e){let t=x(),r=b(e.kind===void 0?{}:{kind:e.kind});return{options:n(()=>Fe({providers:Pe(t.data),brokers:q(r.data).filter(t=>e.addonId===void 0||t.addonId===e.addonId),...e.addonId===void 0?{}:{addonId:e.addonId},...e.kind===void 0?{}:{kind:e.kind}}),[t.data,r.data,e.addonId,e.kind]),isLoading:t.isLoading===!0}}var X=`kind`,Z=`name`,Q=`restore`,$=`restoreId`;function Ie(e,t={allowRestore:!0}){let n=[];return e.length>1&&n.push({type:`select`,key:X,label:F.t(`helpers.brokerIdentitySchema.kind`),options:e.map(e=>({value:e.key,label:e.label}))}),n.push({type:`text`,key:Z,label:F.t(`helpers.brokerIdentitySchema.name`),placeholder:F.t(`helpers.brokerIdentitySchema.namePlaceholder`),required:!0}),t.allowRestore&&n.push({type:`boolean`,key:Q,label:F.t(`helpers.brokerIdentitySchema.restore`),description:F.t(`helpers.brokerIdentitySchema.restoreHint`)},{type:`text`,key:$,label:F.t(`helpers.brokerIdentitySchema.originalId`),placeholder:`ha_004`,required:!0,showWhen:{field:Q,equals:!0}}),{sections:[{id:`broker-identity`,title:F.t(`helpers.brokerIdentitySchema.title`),columns:1,fields:n}]}}function Le(e){let t=t=>{let n=e[t];return typeof n==`string`?n.trim():``},n=t(X);if(n===``)return{ok:!1,problem:`Pick a kind.`};let r=t(Z);if(r===``)return{ok:!1,problem:`Enter a name before saving.`};if(e.restore!==!0)return{ok:!0,identity:{kindKey:n,name:r,restoreId:null}};let i=t($);return i===``?{ok:!1,problem:`Enter the original id, or turn restore off to create a new broker.`}:{ok:!0,identity:{kindKey:n,name:r,restoreId:i}}}s();function Re({title:t,subtitle:n,onClose:r,children:a}){return i(P,{open:!0,onOpenChange:e=>!e&&r(),children:e(ee,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(N,{children:[i(D,{children:t}),n&&i(E,{children:n})]}),i(k,{className:`space-y-3 pr-1`,children:a})]})})}function ze(e,t){let n=new Set(t.map(e=>e.trim().toLowerCase()));if(!n.has(e.toLowerCase()))return e;for(let t=2;;t++){let r=`${e} ${t}`;if(!n.has(r.toLowerCase()))return r}}function Be(e){return e.broker===void 0?i(Ve,{...e}):i(He,{...e,broker:e.broker})}function Ve({kind:r,addonId:s,onClose:u,onSaved:d}){let{t:p}=I(),m=c(),{options:h,isLoading:_}=Y({...s===void 0?{}:{addonId:s},...r===void 0?{}:{kind:r}}),v=b({}),y=n(()=>q(v.data).map(e=>e.name),[v.data]),[x,C]=o({[Z]:``,[Q]:!1,[$]:``}),[w,T]=o(null),E=h.find(e=>K(e)===x.kind)??h[0],D=K(E),O=E===void 0?``:ze(E.label,y),k=t(``);a(()=>{D!==``&&C(e=>{let t=typeof e.name==`string`?e[Z]:``,n=t===``||t===k.current;k.current=O;let r=n?O:t;return e.kind===D&&t===r?e:{...e,[X]:D,[Z]:r}})},[D,O]);let A=n(()=>Ie(h.map(e=>({key:K(e),label:e.label})),{allowRestore:E?.signInBasePath===void 0}),[h,E?.signInBasePath]),j=e=>{m.invalidateQueries({queryKey:[[`broker`,`list`]]}),d(e)},M=g({onSuccess:e=>{let t=typeof e==`object`&&e&&typeof e.id==`string`?e.id:null,n=E?.interactiveConnectPath;t!==null&&n!==void 0&&te(n,t,()=>{m.invalidateQueries({queryKey:[[`broker`,`list`]]})}),t!==null&&j(t)}}),N=Le(x),ee=N.ok?N.identity.name:``,P=e=>{if(E!==void 0){if(!N.ok){T(N.problem);return}T(null),M.mutate({kind:E.kind,name:N.identity.name,settings:e,...N.identity.restoreId===null?{}:{id:N.identity.restoreId},...E.addonId===void 0?{}:{addonId:E.addonId}})}},F=M.isPending;return i(Re,{title:p(`brokers.editor.createTitle`),subtitle:p(`brokers.editor.createSubtitle`),onClose:F?()=>{}:u,children:_&&h.length===0?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(f,{className:`h-3.5 w-3.5 animate-spin`}),` `,p(`brokers.editor.loadingKinds`)]}):E===void 0?i(S,{message:p(`brokers.editor.noProvider`)}):e(l,{children:[i(L,{schema:A,values:x,onChange:C}),w!==null&&i(S,{message:w}),M.isError&&i(S,{message:M.error instanceof Error?M.error.message:String(M.error)}),i(Ne,{kind:E.kind,...E.addonId===void 0?{}:{addonId:E.addonId},onSubmit:P,onCancel:u,submitLabel:p(F?`brokers.editor.creating`:`brokers.editor.create`),disabled:F,...E.signInBasePath===void 0?{}:{signIn:{basePath:E.signInBasePath,...E.signInMethods===void 0?{}:{methods:E.signInMethods},name:ee,onSignedIn:j}}},D)]})})}function He({broker:t,onClose:r,onSaved:a}){let{t:o}=I(),s=c(),{options:l}=Y({addonId:t.addonId,kind:t.kind}),u=l.find(e=>e.kind===t.kind),d=u?.signInBasePath,p=C({id:t.id,addonId:t.addonId}),m=_({onSuccess:()=>{s.invalidateQueries({queryKey:[[`broker`,`list`]]}),s.invalidateQueries({queryKey:[[`broker`,`getSettings`],{input:{id:t.id,addonId:t.addonId}}]}),a(t.id)}}),h=n(()=>{let e=p.data;return e&&typeof e==`object`?{...e}:{}},[p.data]),g=m.isPending;return i(Re,{title:o(`brokers.brokerManager.edit`,`Edit {{name}}`,{name:t.name}),subtitle:`${t.kind} · ${t.id}`,onClose:g?()=>{}:r,children:p.isLoading?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(f,{className:`h-3.5 w-3.5 animate-spin`}),` `,o(`brokers.brokerManager.loadingSettings`)]}):p.isError?e(`div`,{className:`space-y-3`,children:[i(S,{message:o(`brokers.brokerManager.loadSettingsFailed`,{message:p.error instanceof Error?p.error.message:o(`common.unknownError`)})}),i(`div`,{className:`flex justify-end`,children:i(M,{variant:`outline`,size:`sm`,onClick:r,children:o(`common.close`,`Close`)})})]}):e(`div`,{className:`space-y-3`,children:[m.isError&&i(S,{message:m.error instanceof Error?m.error.message:String(m.error)}),i(Ne,{kind:t.kind,addonId:t.addonId,brokerId:t.id,initialValues:h,onSubmit:e=>m.mutate({id:t.id,settings:e,addonId:t.addonId}),onCancel:r,submitLabel:g?o(`brokers.brokerManager.saving`):o(`common.save`,`Save`),disabled:g,...d===void 0?{}:{signIn:{basePath:d,...u?.signInMethods===void 0?{}:{methods:u.signInMethods},name:t.name,brokerId:t.id,onSignedIn:e=>{s.invalidateQueries({queryKey:[[`broker`,`list`]]}),a(e)}}}})]})})}export{q as n,Y as r,Be as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,K as t,R as n,S as r,Y as i,et as a,x as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Di as s,Oi as c}from"./player-overlays-Cw_gjG75.js";import{_r as l,vr as u}from"./client-r4i0EpF6.js";import{g as d}from"./video-DXegVNA2.js";import{Ba as f,Cr as p,Ha as m,Tr as h,Va as g,br as _,ri as v,wr as y,xr as b,yr as x,za as S}from"./src-nnHXOip7.js";import{t as C}from"./i18n-BE1bPZOs.js";import{t as w}from"./useTranslation-BJr-n0es.js";import{hr as T,mr as E}from"./index-Ohn-2iW_.js";import{t as D}from"./AdminPage-7avIuDBh.js";a();var O=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`];function k(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function A(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function j(e){let t=e.getDay();return k(A(e,t===0?-6:1-t))}function M(e,t){if(t===`day`){let t=k(e);return{startMs:t.getTime(),endMs:A(t,1).getTime()}}if(t===`week`){let t=j(e);return{startMs:t.getTime(),endMs:A(t,7).getTime()}}let n=new Date(e.getFullYear(),e.getMonth(),1),r=new Date(e.getFullYear(),e.getMonth()+1,0),i=j(n),a=A(j(r),7);return{startMs:i.getTime(),endMs:a.getTime()}}function N(e,t){if(t===`day`)return e.toLocaleDateString(void 0,{weekday:`long`,year:`numeric`,month:`long`,day:`numeric`});if(t===`week`){let t=j(e),n=A(t,6),r={month:`short`,day:`numeric`};return`${t.toLocaleDateString(void 0,r)} – ${n.toLocaleDateString(void 0,{...r,year:`numeric`})}`}return e.toLocaleDateString(void 0,{month:`long`,year:`numeric`})}function P(e,t,n){return t===`day`?A(e,n):t===`week`?A(e,n*7):new Date(e.getFullYear(),e.getMonth()+n,1)}function F(e,t){if(t===void 0)return e;let n=t.calendars[e.id];return n===void 0?e:{...e,visible:n.visible??e.visible,color:n.color??e.defaultColor}}function I(e){return e.providerAddonId!==void 0&&e.providerAddonId.length>0?e.providerAddonId:e.source===`ha`?`Home Assistant`:e.source}function L(e){if(e.allDay===!0)return C.t(`systemPage.calendars.allDay`);let t=new Date(e.startMs),n=new Date(e.endMs),r={hour:`2-digit`,minute:`2-digit`};return`${t.toLocaleTimeString([],r)} – ${n.toLocaleTimeString([],r)}`}function R(e){let t=l(e),n=new Date(t.startMs),r=new Date(t.endMs),i={weekday:`short`,year:`numeric`,month:`short`,day:`numeric`};if(e.allDay===!0){let e=k(n),t=A(k(r),-1);return H(e,t)?C.t(`systemPage.calendars.dayAllDay`,{date:n.toLocaleDateString(void 0,i)}):C.t(`systemPage.calendars.rangeAllDay`,{from:n.toLocaleDateString(void 0,i),to:t.toLocaleDateString(void 0,i)})}let a={hour:`2-digit`,minute:`2-digit`};return H(n,r)?`${n.toLocaleDateString(void 0,i)} · ${n.toLocaleTimeString([],a)} – ${r.toLocaleTimeString([],a)}`:`${n.toLocaleString(void 0,{...i,...a})} – ${r.toLocaleString(void 0,{...i,...a})}`}function z({label:t,children:n}){return e(`div`,{className:`grid grid-cols-[7rem_minmax(0,1fr)] gap-x-3 gap-y-1 text-sm`,children:[r(`dt`,{className:`text-foreground-subtle`,children:t}),r(`dd`,{className:`min-w-0 break-words text-foreground`,children:n})]})}function B({ev:t,calendarName:n,color:i,onClose:a}){let{t:o}=w();return r(x,{open:!0,onOpenChange:e=>!e&&a(),children:e(b,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,"data-testid":`calendars-event-detail`,children:[r(y,{children:e(`div`,{className:`flex min-w-0 items-start gap-2.5`,children:[r(`span`,{className:`mt-1.5 h-3 w-3 shrink-0 rounded-full`,style:{backgroundColor:i},"aria-hidden":!0}),r(h,{className:`min-w-0 break-words`,children:t.title})]})}),r(_,{children:e(`dl`,{className:`space-y-3`,children:[r(z,{label:o(`systemPage.calendars.when`,`When`),children:R(t)}),r(z,{label:o(`systemPage.calendars.calendar`,`Calendar`),children:n}),t.location!==void 0&&t.location.length>0?r(z,{label:o(`systemPage.calendars.location`,`Location`),children:t.location}):null,t.description!==void 0&&t.description.length>0?r(z,{label:o(`systemPage.calendars.description`,`Description`),children:r(`span`,{className:`whitespace-pre-wrap`,children:t.description})}):null]})}),r(p,{children:r(v,{type:`button`,size:`sm`,variant:`secondary`,onClick:a,children:o(`common.close`,`Close`)})})]})})}function V(e,t){return e.filter(e=>u(e,t))}function H(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function U({mode:e,onChange:t}){let{t:n}=w(),i=[{id:`month`,label:n(`systemPage.calendars.month`,`Month`)},{id:`week`,label:n(`systemPage.calendars.week`,`Week`)},{id:`day`,label:n(`systemPage.calendars.day`,`Day`)}];return r(`div`,{className:`inline-flex rounded-lg border border-border bg-surface p-0.5`,role:`group`,"aria-label":n(`systemPage.calendars.calendarView`,`Calendar view`),children:i.map(n=>r(`button`,{type:`button`,className:e===n.id?`rounded-md bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground`:`rounded-md px-2.5 py-1 text-xs font-medium text-foreground-subtle hover:text-foreground`,"aria-pressed":e===n.id,onClick:()=>t(n.id),"data-testid":`calendars-view-${n.id}`,children:n.label},n.id))})}function W({calendars:t,onToggleVisible:n,onColorChange:i,busy:a}){let{t:o}=w();return e(`aside`,{className:`w-full shrink-0 space-y-2 lg:w-56 xl:w-64`,"data-testid":`calendars-legend`,children:[r(`h2`,{className:`text-xs font-medium text-foreground-subtle`,children:o(`systemPage.calendars.calendars`,`Calendars`)}),r(`ul`,{className:`space-y-1`,children:t.map(t=>e(`li`,{className:`flex items-start gap-2 rounded-md px-1.5 py-1.5 hover:bg-surface`,children:[r(`input`,{type:`checkbox`,className:`mt-1 h-3.5 w-3.5 shrink-0 accent-primary`,checked:t.visible,disabled:a,onChange:e=>n(t.id,e.target.checked),"aria-label":o(`systemPage.calendars.show`,`Show {{name}}`,{name:t.name}),"data-testid":`calendars-visible-${t.id}`}),r(`input`,{type:`color`,className:`mt-0.5 h-6 w-6 shrink-0 cursor-pointer rounded border border-border bg-transparent p-0`,value:t.color,disabled:a,onChange:e=>i(t.id,e.target.value.toUpperCase()),"aria-label":o(`systemPage.calendars.colourFor`,`Colour for {{name}}`,{name:t.name}),"data-testid":`calendars-color-${t.id}`}),e(`div`,{className:`min-w-0 flex-1`,children:[r(`div`,{className:`truncate text-sm font-medium ${t.visible?`text-foreground`:`text-foreground-subtle`}`,children:t.name}),e(`div`,{className:`truncate text-[11px] text-foreground-subtle`,children:[I(t),t.enabled?``:` · ${o(`systemPage.calendars.unavailableAtSource`)}`]})]})]},t.id))})]})}function G({ev:t,color:n,compact:i,onSelect:a}){return r(`button`,{type:`button`,className:i?`block w-full truncate rounded px-1 py-0.5 text-left text-[10px] leading-tight text-white hover:brightness-110`:`block w-full rounded-md px-2 py-1.5 text-left text-xs text-white hover:brightness-110`,style:{backgroundColor:n},title:t.title,onClick:()=>a(t),"data-testid":`calendars-event-${t.id}`,children:i?t.title:e(o,{children:[r(`div`,{className:`font-medium`,children:t.title}),r(`div`,{className:`opacity-90`,children:L(t)})]})})}function K({anchor:t,events:n,colorById:i,today:a,onSelectEvent:o}){let{t:s}=w(),{startMs:c,endMs:l}=M(t,`month`),u=[];for(let e=new Date(c);e.getTime()<l;e=A(e,1))u.push(e);let d=t.getMonth();return e(`div`,{"data-testid":`calendars-month`,children:[r(`div`,{className:`mb-1 grid grid-cols-7 gap-px`,children:O.map(e=>r(`div`,{className:`px-1 py-1 text-center text-[11px] font-medium text-foreground-subtle`,children:e},e))}),r(`div`,{className:`grid grid-cols-7 gap-px overflow-hidden rounded-lg border border-border bg-border`,children:u.map(t=>{let c=k(t).getTime(),l=V(n,c),u=t.getMonth()!==d,f=H(t,a);return e(`div`,{className:`min-h-[5.5rem] bg-background p-1 ${u?`opacity-45`:``}`,children:[r(`div`,{className:f?`mb-1 inline-flex h-5 w-5 items-center justify-center rounded-full bg-primary text-[11px] font-semibold text-primary-foreground`:`mb-1 text-[11px] font-medium text-foreground-subtle`,children:t.getDate()}),e(`div`,{className:`space-y-0.5`,children:[l.slice(0,3).map(e=>r(G,{ev:e,color:i.get(e.calendarId)??`#64748B`,compact:!0,onSelect:o},e.id)),l.length>3?r(`div`,{className:`text-[10px] text-foreground-subtle`,children:s(`common.moreCount`,{count:l.length-3})}):null]})]},c)})})]})}function q({anchor:t,events:n,colorById:i,today:a,onSelectEvent:o}){let s=j(t);return r(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-7 sm:gap-px sm:overflow-hidden sm:rounded-lg sm:border sm:border-border sm:bg-border`,"data-testid":`calendars-week`,children:Array.from({length:7},(e,t)=>A(s,t)).map(t=>{let s=k(t).getTime(),c=V(n,s);return e(`div`,{className:`min-h-[8rem] bg-background p-2 sm:min-h-[12rem]`,children:[r(`div`,{className:H(t,a)?`mb-2 text-xs font-semibold text-primary`:`mb-2 text-xs font-medium text-foreground-subtle`,children:t.toLocaleDateString(void 0,{weekday:`short`,day:`numeric`})}),r(`div`,{className:`space-y-1`,children:c.length===0?r(`p`,{className:`text-[11px] text-foreground-subtle`,children:`—`}):c.map(e=>r(G,{ev:e,color:i.get(e.calendarId)??`#64748B`,onSelect:o},e.id))})]},s)})})}function J({anchor:t,events:n,colorById:i,calName:a,onSelectEvent:o}){let{t:s}=w(),c=V(n,k(t).getTime());return c.length===0?r(`p`,{className:`text-sm text-foreground-subtle`,"data-testid":`calendars-day-empty`,children:s(`systemPage.calendars.noEventsOnThisDay`,`No events on this day.`)}):r(`ul`,{className:`divide-y divide-border rounded-lg border border-border`,"data-testid":`calendars-day`,children:c.map(t=>r(`li`,{children:e(`button`,{type:`button`,className:`flex w-full items-start gap-3 px-3 py-3 text-left hover:bg-surface`,onClick:()=>o(t),"data-testid":`calendars-event-${t.id}`,children:[r(`span`,{className:`mt-1 h-2.5 w-2.5 shrink-0 rounded-full`,style:{backgroundColor:i.get(t.calendarId)??`#64748B`}}),e(`div`,{className:`min-w-0`,children:[r(`div`,{className:`font-medium text-sm text-foreground`,children:t.title}),e(`div`,{className:`text-xs text-foreground-subtle`,children:[L(t),` · `,a.get(t.calendarId)??t.calendarId]}),t.location!==void 0&&t.location.length>0?r(`div`,{className:`mt-0.5 text-xs text-foreground-subtle`,children:t.location}):null]})]})},t.id))})}function Y(){let{t:a}=w(),o=f(),l=S({}),u=m(),[p,h]=i(`month`),[_,v]=i(()=>k(new Date)),[y,b]=i(null),x=t(()=>k(new Date),[]),C=o.isSuccess,O=l.isSuccess&&l.data!==void 0?l.data:void 0,A=t(()=>!C||o.data===void 0?[]:o.data.map(e=>F(e,O)),[C,o.data,O]),j=t(()=>A.filter(e=>e.visible),[A]),I=t(()=>j.map(e=>e.id),[j]),L=t(()=>M(_,p),[_,p]),R=g({startMs:L.startMs,endMs:L.endMs,calendarIds:[...I]},{enabled:C&&I.length>0}),z=R.data??[],V=t(()=>{let e=new Map;for(let t of A)e.set(t.id,t.color);return e},[A]),H=t(()=>{let e=new Map;for(let t of A)e.set(t.id,t.name);return e},[A]),G=n((e,t)=>{u.mutateAsync({calendarId:e,visible:t}).then(()=>l.refetch())},[l,u]),Y=n((e,t)=>{/^#[0-9A-Fa-f]{6}$/.test(t)&&u.mutateAsync({calendarId:e,color:t}).then(()=>l.refetch())},[l,u]),X=n(()=>v(k(new Date)),[]),Z=n(()=>v(e=>P(e,p,-1)),[p]),ee=n(()=>v(e=>P(e,p,1)),[p]),Q=`inline-flex h-8 w-8 items-center justify-center rounded-lg border border-border bg-surface text-foreground hover:bg-primary/5 disabled:opacity-50`,$;return $=o.isPending?r(`p`,{className:`text-sm text-foreground-subtle`,children:a(`systemPage.calendars.loadingCalendars`,`Loading calendars…`)}):o.isError?e(`p`,{className:`text-sm text-destructive`,children:[a(`systemPage.calendars.couldNotListCalendars`,`Could not list calendars:`),` `,o.error.message]}):A.length===0?r(`p`,{className:`text-sm text-foreground-subtle`,"data-testid":`calendars-empty-sources`,children:r(E,{i18nKey:`systemPage.calendars.emptySources`,components:{link:r(T,{to:`/system/integrations?tab=calendars`,className:`text-accent underline-offset-2 hover:underline`})}})}):I.length===0?e(`div`,{className:`flex flex-col gap-4 lg:flex-row lg:items-start`,children:[r(W,{calendars:A,onToggleVisible:G,onColorChange:Y,busy:u.isPending}),r(`p`,{className:`text-sm text-foreground-subtle`,"data-testid":`calendars-empty-hidden`,children:a(`systemPage.calendars.allCalendarsAreHiddenTurn`,`All calendars are hidden. Turn one on in the legend to see events.`)})]}):e(`div`,{className:`flex flex-col gap-4 lg:flex-row lg:items-start`,children:[r(W,{calendars:A,onToggleVisible:G,onColorChange:Y,busy:u.isPending}),e(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r(U,{mode:p,onChange:h}),e(`div`,{className:`flex items-center gap-1`,children:[r(`button`,{type:`button`,className:Q,onClick:Z,"aria-label":a(`systemPage.calendars.previous`,`Previous`),"data-testid":`calendars-prev`,children:r(c,{className:`h-4 w-4`})}),r(`button`,{type:`button`,className:`inline-flex items-center rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-primary/5`,onClick:X,"data-testid":`calendars-today`,children:a(`systemPage.calendars.today`,`Today`)}),r(`button`,{type:`button`,className:Q,onClick:ee,"aria-label":a(`common.next`,`Next`),"data-testid":`calendars-next`,children:r(s,{className:`h-4 w-4`})})]}),r(`span`,{className:`text-sm font-medium text-foreground`,"data-testid":`calendars-period`,children:N(_,p)})]}),R.isPending?r(`p`,{className:`text-sm text-foreground-subtle`,children:a(`systemPage.calendars.loadingEvents`,`Loading events…`)}):R.isError?e(`p`,{className:`text-sm text-destructive`,children:[a(`systemPage.calendars.couldNotListEvents`,`Could not list events:`),` `,R.error.message]}):p===`month`?r(K,{anchor:_,events:z,colorById:V,today:x,onSelectEvent:b}):p===`week`?r(q,{anchor:_,events:z,colorById:V,today:x,onSelectEvent:b}):r(J,{anchor:_,events:z,colorById:V,calName:H,onSelectEvent:b})]})]}),e(D,{icon:d,title:a(`systemPage.calendars.calendars`,`Calendars`),subtitle:a(`systemPage.calendars.calendarsFromConnectedSourcesUsed`,`Calendars from connected sources. Used by Calendar events notification rules.`),children:[$,y===null?null:r(B,{ev:y,calendarName:H.get(y.calendarId)??y.calendarId,color:V.get(y.calendarId)??`#64748B`,onClose:()=>b(null)})]})}export{Y as CalendarsPage,Y as default};
|
|
@@ -1 +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,et as s,o as c,x as l}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ai as u,An as d,Ci as f,D as p,Di as m,Dn as h,Hn as g,Ht as _,In as v,Kn as y,On as b,Tn as x,_n as S,dt as C,gt as w,hi as T,ii as E,ki as D,oa as O,pn as k,pr as A,qr as j,st as M,vn as N,xi as P,yn as F,zi as I,zt as L}from"./player-overlays-Cw_gjG75.js";import{fo as R,mo as ee,po as te,vo as ne}from"./client-r4i0EpF6.js";import{t as re}from"./hard-drive-download-Dym9jihx.js";import{t as ie}from"./memory-stick-CLL3KiND.js";import{t as ae}from"./unlink-DNy8sNAV.js";import{Ac as oe,An as z,Cr as se,Ct as ce,Et as B,Fl as le,Fo as ue,I as de,Ln as fe,Mr as pe,Nr as V,Oc as me,On as he,Pr as ge,Rd as H,Sc as _e,Sr as ve,Su as ye,Tr as be,Uu as xe,_i as Se,af as Ce,bl as we,br as Te,bu as Ee,cn as De,di as Oe,fl as ke,gi as Ae,hi as je,jc as Me,jn as Ne,kc as Pe,kl as Fe,kn as Ie,lf as U,of as W,qd as Le,ri as G,sn as Re,ut as ze,vi as Be,vu as Ve,wr as He,xc as Ue,xr as We,xu as Ge,yr as Ke,yu as qe}from"./src-nnHXOip7.js";import{t as K}from"./i18n-BE1bPZOs.js";import{t as q}from"./useTranslation-BJr-n0es.js";import{br as Je,x as Ye}from"./index-Ohn-2iW_.js";import{n as Xe}from"./format-Bqo-j708.js";import{t as Ze}from"./AdminPage-7avIuDBh.js";import{t as Qe}from"./NodeAddonsSettingsPanel-JIXh-CLX.js";import{f as $e,l as et,m as tt,u as nt}from"./board-model-D3wYwuI4.js";import{t as J}from"./format-size-DIxKXxtj.js";import{n as rt,t as it}from"./useNodeUrlSelection-CR_BnlEg.js";s();var at={unpaired:`Not paired`,pending:`Pairing…`,paired:`Paired`},ot=new Set([`paired`,`rejected`,`failed`,`expired`]);function Y(e){return ot.has(e)}function st(e){return e.replace(/\D/g,``).slice(0,6)}function ct(e){return e.length===6}function lt(e,t){let n=Math.max(0,Math.ceil((e-t)/1e3)),r=Math.floor(n/60),i=n%60;return`${r}:${String(i).padStart(2,`0`)}`}function ut(e,t){return e.includes(`:`)?`[${e}]:${t}`:`${e}:${t}`}function dt(e){return e.length<=23?e:`${e.slice(0,20)}…`}function ft({view:e,beginError:t}){if(e===null)return t===null?`sending`:`send-failed`;switch(e.state){case`paired`:return`paired`;case`rejected`:return`rejected`;case`failed`:return`failed`;case`expired`:return`expired`;case`completing`:return`completing`;case`awaiting-confirmation`:return e.hubConfirmed&&!e.agentConfirmed?`awaiting-agent`:e.agentConfirmed&&!e.hubConfirmed?`awaiting-hub`:`awaiting-both`}}function pt(e){return e===`awaiting-both`||e===`awaiting-hub`}var mt={sending:`Sending the pairing offer to the agent…`,"send-failed":`The agent could not be reached`,"awaiting-both":`Waiting for both confirmations`,"awaiting-agent":`Confirmed here — waiting for the agent`,"awaiting-hub":`The agent is confirmed — now confirm here`,completing:`Issuing the node certificate…`,paired:`Paired`,rejected:`Pairing was rejected`,failed:`Pairing failed`,expired:`The pairing expired`},ht=2e3,gt=1e3;function _t(e){return e.message.length>0?e.message:K.t(`pairing.agentsFoundSection.requestFailed`)}function vt(e){return e.length===6?`${e.slice(0,3)} ${e.slice(3)}`:e}function yt(e){let[t,n]=o(()=>Date.now());return a(()=>{if(!e)return;let t=setInterval(()=>n(Date.now()),gt);return()=>clearInterval(t)},[e]),t}function bt({target:n,onClose:r,onSettled:s,onOpenNode:c}){let{t:u}=q(),[d,f]=o(null),[p,m]=o(null),[h,g]=o(``),[_,v]=o(null),y=t(null),b=U.agentPairing.beginPairing.useMutation(),x=U.agentPairing.confirmPairing.useMutation(),S=U.agentPairing.rejectPairing.useMutation();a(()=>{if(n===null){y.current=null,f(null),m(null),g(``),v(null);return}if(y.current!==n){if(y.current=n,n.pairingId!==void 0){f(n.pairingId);return}b.mutateAsync({host:n.host,port:n.port}).then(e=>{y.current===n&&f(e.pairingId)}).catch(e=>{y.current===n&&m(_t(e))})}},[n]);let C=U.agentPairing.getPairing.useQuery({pairingId:d??``},{enabled:d!==null,refetchInterval:e=>{let t=e.state.data?.state;return t!==void 0&&Y(t)?!1:ht}}),w=xt(x.data??S.data??null,C.data??null),T=ft({view:w,beginError:p}),E=w!==null&&Y(w.state),D=t(!1);a(()=>{if(!E){D.current=!1;return}D.current||(D.current=!0,s())},[E,s]);let O=yt(w!==null&&!E),k=()=>{d===null||!ct(h)||(v(null),x.mutate({pairingId:d,code:h},{onError:e=>{v(_t(e)),g(``)}}))};return i(Ke,{open:n!==null,onOpenChange:e=>!e&&r(),children:e(We,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(He,{children:[i(be,{children:u(`pairing.pairingDialog.title`,{node:n?.nodeId??``})}),i(ve,{children:n===null?``:u(`pairing.pairingDialog.eachScreenShowsACode`,`Both screens show the same six digits. Check they match, then type the code you read on the agent. Agent at {{value1}}`,{value1:ut(n.host,n.port)})})]}),e(Te,{className:`space-y-4`,children:[i(St,{phase:T}),T===`send-failed`&&p!==null&&i(V,{title:u(`pairing.pairingDialog.couldNotStartThePairing`,`Could not start the pairing`),message:p}),w!==null&&!E&&i(Ct,{view:w,phase:T,now:O,typed:h,onType:e=>g(st(e)),onSubmit:k,confirmError:_,busy:x.isPending}),T===`paired`&&w!==null&&i(wt,{nodeId:w.nodeId,onOpenNode:c,onClose:r}),E&&T!==`paired`&&w?.failure!=null&&i(V,{message:w.failure})]}),i(se,{children:E||T===`send-failed`?i(G,{type:`button`,variant:`outline`,onClick:r,children:u(`common.close`,`Close`)}):e(l,{children:[i(G,{type:`button`,variant:`outline`,disabled:S.isPending,onClick:()=>{if(d===null){r();return}S.mutate({pairingId:d},{onSettled:r})},children:u(`pairing.pairingDialog.reject`,`Reject`)}),pt(T)&&e(G,{type:`button`,disabled:!ct(h)||x.isPending,onClick:k,children:[x.isPending&&i(A,{className:`h-4 w-4 animate-spin`}),u(`common.confirm`,`Confirm`)]})]})})]})})}function xt(e,t){if(t===null)return e;if(e===null)return t;let n=e=>(Y(e.state)?10:e.state===`completing`?5:0)+ +!!e.hubConfirmed+ +!!e.agentConfirmed;return n(e)>n(t)?e:t}function St({phase:t}){let n=t===`sending`||t===`completing`,r=t===`paired`,a=t===`rejected`||t===`failed`||t===`expired`||t===`send-failed`;return e(`p`,{role:`status`,className:`flex items-center gap-2 text-sm font-medium ${r?`text-success`:a?`text-danger`:`text-foreground`}`,children:[n&&i(A,{className:`h-4 w-4 animate-spin`}),r&&i(P,{className:`h-4 w-4`}),a&&i(T,{className:`h-4 w-4`}),mt[t]]})}function Ct({view:t,phase:n,now:r,typed:a,onType:o,onSubmit:s,confirmError:c,busy:l}){let{t:u}=q();return e(`div`,{className:`space-y-4`,children:[e(`section`,{"aria-label":u(`pairing.pairingDialog.codeOnThisHub`,`Code on this hub`),className:`rounded-md border border-border bg-surface p-3`,children:[i(`p`,{className:`text-xs text-foreground-muted`,children:u(`pairing.pairingDialog.codeOnThisHubRead`,`Code on this hub: the agent must show the same digits`)}),i(`p`,{"data-testid":`hub-code`,className:`mt-1 font-mono text-3xl font-semibold tracking-widest text-foreground`,children:vt(t.code)}),i(`p`,{className:`mt-2 text-xs text-foreground-muted`,children:u(`pairing.pairingDialog.onTheAgentEnterThis`,`On the agent, enter this code and the agent’s local PIN (shown on the agent’s console or log, or on its own screen).`)})]}),pt(n)?i(`form`,{className:`space-y-2`,onSubmit:e=>{e.preventDefault(),s()},children:i(B,{label:u(`pairing.pairingDialog.codeShownOnTheAgent`,`Code shown on the agent`),description:u(`pairing.pairingDialog.typeTheSixDigitsThe`,`Type the six digits you read on the agent; do not paste. If they differ from the code above, stop and press Reject.`),...c===null?{}:{error:c},children:i(H,{value:a,onChange:e=>o(e.target.value),inputMode:`numeric`,autoComplete:`off`,spellCheck:!1,placeholder:`000000`,maxLength:6,disabled:l,"aria-label":u(`pairing.pairingDialog.codeShownOnTheAgent`,`Code shown on the agent`),className:`font-mono tracking-widest`})})}):i(`p`,{className:`text-xs text-foreground-muted`,children:n===`awaiting-agent`?u(`pairing.pairingDialog.youConfirmedHereTheAgent`,`You confirmed here. The agent still has to enter the hub code and its PIN.`):u(`pairing.pairingDialog.working`,`Working…`)}),e(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-xs text-foreground-muted`,children:[i(`li`,{children:t.hubConfirmed?u(`pairing.pairingDialog.hubConfirmed`,`Hub: confirmed`):u(`pairing.pairingDialog.hubNotConfirmed`,`Hub: not confirmed`)}),i(`li`,{children:t.agentConfirmed?u(`pairing.pairingDialog.agentConfirmed`,`Agent: confirmed`):u(`pairing.pairingDialog.agentNotConfirmed`,`Agent: not confirmed`)}),i(`li`,{"data-testid":`countdown`,children:u(`pairing.pairingDialog.expiresIn`,{countdown:lt(t.expiresAt,r)})})]})]})}function wt({nodeId:t,onOpenNode:n,onClose:r}){let{t:a}=q(),{nodes:o}=Ce(),s=o?.some(e=>e.id===t&&e.isOnline)===!0;return e(`div`,{className:`space-y-2 rounded-md border border-success/40 bg-success/10 p-3 text-sm`,children:[e(`p`,{className:`flex items-center gap-2 text-success`,children:[i(k,{className:`h-4 w-4`}),s?a(`pairing.pairingDialog.joinedAndRegisteredItsCapabilities`,`{{nodeId}} joined and registered its capabilities.`,{nodeId:t}):a(`pairing.pairingDialog.holdsItsCertificateWaitingFor`,`{{nodeId}} holds its certificate. Waiting for it to connect and register its capabilities…`,{nodeId:t})]}),i(G,{type:`button`,size:`sm`,variant:`outline`,disabled:!s,onClick:()=>{r(),n(t)},children:a(`pairing.pairingDialog.openNode`,`Open node`)})]})}var Tt={paired:`success`,pending:`warning`,unpaired:`default`};function Et({state:t,connected:n}){let{t:r}=q();return e(`span`,{className:`inline-flex items-center gap-1.5`,children:[i(Oe,{variant:Tt[t],className:`text-[10px]`,children:at[t]}),t===`paired`&&i(`span`,{className:`text-[10px] text-foreground-muted`,children:n?r(`common.connected`):r(`pairing.agentStateBadge.notConnected`,`not connected`)})]})}s();var X={pending:0,unpaired:1,paired:2};function Dt(e){if(e.trim().length===0)return;let t=Number(e);return Number.isInteger(t)&&t>=1&&t<=65535?t:null}function Ot({onOpenNode:t}){let{t:r}=q(),a=M(),s=U.useUtils(),c=U.agentPairing.listDiscoveredAgents.useQuery(void 0,{refetchInterval:15e3}),[u,f]=o(null),[m,g]=o(null),[_,y]=o(!1),[b,x]=o(``),[S,C]=o(``),[w,T]=o(null),[E,D]=o(!1),O=()=>void s.agentPairing.listDiscoveredAgents.invalidate(),k=U.agentPairing.addAgentByAddress.useMutation({onSuccess:()=>{y(!1),x(``),C(``),T(null),O()},onError:e=>T(e.message)}),j=U.agentPairing.unpairAgent.useMutation({onSuccess:e=>{g({tone:`success`,message:`${e.nodeId}: ${e.next}${e.agentNotified?``:` The agent could not be told; forget the hub on its own page.`}`}),O()},onError:e=>g({tone:`danger`,message:r(`pairing.agentsFoundSection.unpairFailed`,`Unpair failed: {{message}}`,{message:e.message})})}),N=n(()=>(c.data?.agents??[]).toSorted((e,t)=>X[e.state]-X[t.state]),[c.data]),P=async()=>{D(!0);try{await s.agentPairing.listDiscoveredAgents.fetch({refresh:!0}),O()}finally{D(!1)}},F=()=>{let e=Dt(S);if(e===null){T(`The port must be a whole number between 1 and 65535.`);return}T(null),k.mutate({host:b.trim(),...e===void 0?{}:{port:e}})},I=async e=>{await a({title:r(`pairing.agentsFoundSection.unpair`,`Unpair {{nodeId}}`,{nodeId:e.nodeId}),message:r(`pairing.agentsFoundSection.sCertificatesAreRevokedAt`,`{{nodeId}}'s certificates are revoked at once and it is disconnected from the mesh. It must be paired again before it can rejoin.`,{nodeId:e.nodeId}),confirmLabel:r(`pairing.agentsFoundSection.unpair2`,`Unpair`),variant:`danger`})&&(g(null),j.mutate({nodeId:e.nodeId}))},L=n(()=>[{key:`name`,header:r(`pairing.agentsFoundSection.name`,`Name`),render:e=>e.name??`—`,sortValue:e=>e.name},{key:`node`,header:r(`pairing.agentsFoundSection.node`,`Node`),render:e=>i(`span`,{className:`font-medium text-foreground`,children:e.nodeId}),sortValue:e=>e.nodeId},{key:`address`,header:r(`pairing.agentsFoundSection.address`,`Address`),render:e=>i(`span`,{className:`font-mono text-xs`,children:ut(e.host,e.port)}),sortValue:e=>e.host},{key:`version`,header:r(`pairing.agentsFoundSection.version`,`Version`),render:e=>e.version??`—`,sortValue:e=>e.version},{key:`state`,header:r(`pairing.agentsFoundSection.state`,`State`),render:e=>i(Et,{state:e.state,connected:e.connected}),sortValue:e=>X[e.state]},{key:`fingerprint`,header:r(`pairing.agentsFoundSection.certificate`,`Certificate`),render:e=>e.fingerprint===null?`—`:i(`span`,{className:`font-mono text-xs`,title:e.fingerprint,children:dt(e.fingerprint)}),sortValue:e=>e.fingerprint},{key:`actions`,header:``,align:`right`,notSortableReason:`Row actions`,render:e=>{let t=e.pairing;return e.state===`unpaired`?i(G,{type:`button`,size:`sm`,onClick:()=>f({nodeId:e.nodeId,host:e.host,port:e.port}),children:r(`pairing.agentsFoundSection.pair`,`Pair`)}):e.state===`paired`?i(G,{type:`button`,size:`sm`,variant:`outline`,disabled:j.isPending,onClick:()=>void I(e),children:r(`pairing.agentsFoundSection.unpair2`,`Unpair`)}):e.state===`pending`&&t!==null?i(G,{type:`button`,size:`sm`,onClick:()=>f({nodeId:e.nodeId,host:e.host,port:e.port,pairingId:t.pairingId}),children:r(`pairing.agentsFoundSection.resume`,`Resume`)}):null}}],[j.isPending,r]);return e(he,{headingId:`agents-found`,title:r(`pairing.agentsFoundSection.agentsFoundOnTheNetwork`,`Agents found on the network`),icon:d,testId:`agents-found`,actions:e(l,{children:[e(G,{type:`button`,size:`sm`,variant:`outline`,disabled:E,onClick:()=>void P(),children:[E?i(A,{className:`h-3.5 w-3.5 animate-spin`}):i(h,{className:`h-3.5 w-3.5`}),r(`pairing.agentsFoundSection.scan`,`Scan`)]}),e(G,{type:`button`,size:`sm`,onClick:()=>y(e=>!e),children:[i(v,{className:`h-3.5 w-3.5`}),r(`pairing.agentsFoundSection.addByAddress`,`Add by address`)]})]}),children:[e(`div`,{className:`${p} space-y-3`,children:[i(`p`,{className:`text-[11px] leading-relaxed text-foreground-muted`,children:r(`pairing.agentsFoundSection.anAgentHoldsNoSecret`,`An agent holds no secret: pairing issues it a certificate after you confirm the same six digits on this page and on the agent. Discovery needs the agent on its own IP or host networking; a Docker bridge hides it — add it by address.`)}),_&&e(`form`,{"aria-label":r(`pairing.agentsFoundSection.addAgentByAddress`,`Add agent by address`),className:`flex flex-wrap items-start gap-2`,onSubmit:e=>{e.preventDefault(),b.trim().length>0&&!k.isPending&&F()},children:[i(B,{label:r(`pairing.agentsFoundSection.address`,`Address`),description:r(`pairing.agentsFoundSection.aPrivateOrLocalAddress`,`A private or local address only.`),...w===null?{}:{error:w},children:i(H,{value:b,onChange:e=>x(e.target.value),placeholder:`192.0.2.20`,"aria-label":r(`pairing.agentsFoundSection.agentAddress`,`Agent address`),autoComplete:`off`})}),i(B,{label:r(`pairing.agentsFoundSection.port`,`Port`),description:r(`pairing.agentsFoundSection.optional`,`Optional.`),children:i(H,{value:S,onChange:e=>C(e.target.value),placeholder:`4444`,inputMode:`numeric`,"aria-label":r(`pairing.agentsFoundSection.agentPort`,`Agent port`),className:`w-24`})}),e(G,{type:`submit`,size:`sm`,className:`mt-5`,disabled:b.trim().length===0||k.isPending,children:[k.isPending&&i(A,{className:`h-3.5 w-3.5 animate-spin`}),r(`common.add`,`Add`)]})]}),m!==null&&i(`p`,{role:`status`,className:`rounded border px-3 py-2 text-xs ${m.tone===`success`?`border-success/30 text-foreground`:`border-danger/40 text-danger`}`,children:m.message}),c.isError?i(V,{title:r(`pairing.agentsFoundSection.couldNotListAgents`,`Could not list agents`),message:c.error?.message??r(`pairing.agentsFoundSection.requestFailed`,`Request failed`),onRetry:O}):c.isLoading?i(`p`,{className:`py-4 text-center text-xs text-foreground-muted`,children:r(`pairing.agentsFoundSection.lookingForAgents`,`Looking for agents…`)}):N.length===0?i(ge,{icon:d,title:r(`pairing.agentsFoundSection.noAgentsFound`,`No agents found`),description:r(`pairing.agentsFoundSection.nothingIsAdvertisingOnThis`,`Nothing is advertising on this network. Start the agent on its own IP (or host networking), or add it by address.`)}):i(z,{columns:L,rows:N,rowKey:e=>e.nodeId,minWidthPx:720,defaultSort:{columnKey:`state`,dir:`asc`}})]}),i(bt,{target:u,onClose:()=>f(null),onSettled:O,onOpenNode:t})]})}function kt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function At(e){if(!kt(e))return null;let t=e.ticket;if(typeof t!=`string`||t.length===0)return null;let n=e.dashboardUrl;return typeof n==`string`&&n.length>0?{ticket:t,dashboardUrl:n}:{ticket:t}}function jt(e){let t=e.trim();return!(t.length===0||t.includes(`/`)||t.includes(`?`)||t.includes(`#`)||t.includes(`@`)||t.includes(`:`))}function Z(e){return e.startsWith(`172.17.`)}function Mt(e){let t=/^100\.(\d+)\./.exec(e);if(t===null)return!1;let n=Number(t[1]);return n>=64&&n<=127}function Nt(e){if(e.startsWith(`10.`)||e.startsWith(`192.168.`))return!0;let t=/^172\.(\d+)\./.exec(e);if(t===null)return!1;let n=Number(t[1]);return n>=16&&n<=31&&!Z(e)}function Pt(e,t){if(typeof t==`string`&&jt(t))return t.trim();let n=e.filter(e=>!e.includes(`:`)),r=n.find(e=>!e.startsWith(`127.`)&&!e.startsWith(`169.254.`)&&!Z(e)&&!Mt(e)&&Nt(e));if(r!==void 0)return r;for(let e of n)if(!e.startsWith(`127.`)&&!e.startsWith(`169.254.`)&&!Z(e))return e;return null}function Ft(e){return`http://${e}:4444/`}function It(e,t){let n=new URL(Ft(e));return n.searchParams.set(`ticket`,t),n.toString()}function Lt(){return window.open(`about:blank`,`_blank`)}function Rt(e,t){return e===null||e.closed?!1:(e.location.href=t,!0)}function zt({node:t}){let{info:n}=Ye();return!t.isHub||n===null?i(`span`,{className:`text-sm font-semibold shrink-0`,children:t.name}):e(l,{children:[i(`span`,{className:`text-sm font-semibold shrink-0`,"data-testid":`node-title-name`,children:n.name}),n.name!==t.id&&i(`span`,{className:`text-xs text-foreground-subtle shrink-0`,"data-testid":`node-title-id`,children:t.id})]})}s();function Bt(e){if(e<60)return`${e}s`;let t=Math.floor(e/60);if(t<60)return`${t}m`;let n=Math.floor(t/60);return n<24?`${n}h ${t%60}m`:`${Math.floor(n/24)}d ${n%24}h`}function Vt(e){return e===`running`?`running`:e===`crashed`||e===`failed`?`error`:`stopped`}var Ht=[`trace`,`debug`,`info`,`warn`,`error`];function Ut({proc:t,nodeId:n,defaultExpanded:r,activePanel:a,onTogglePanel:s}){let{t:c}=q(),l=t.services??[],u=l.length===1,[d,f]=o(u||r),[p,h]=o(null),[g,_]=o(`info`),v=t.name.includes(`(core)`),y=Pe(),C=oe(),w=Me(),T=async e=>{h(e);try{await y.mutateAsync({nodeId:n,addonId:e})}catch(e){console.error(`Failed to restart addon:`,e)}finally{h(null)}},E=async()=>{h(t.name);try{await C.mutateAsync({nodeId:n,processName:t.name})}catch(e){console.error(`Failed to restart process:`,e)}finally{h(null)}},O=async e=>{let r=`${n}/${t.name}`;try{await w.mutateAsync({nodeId:r,level:e}),_(e)}catch(e){console.error(`Failed to set log level:`,e)}};return e(`div`,{className:`border border-border/50 rounded-lg overflow-hidden`,children:[e(`div`,{role:u?void 0:`button`,tabIndex:u?void 0:0,onClick:u?void 0:()=>f(!d),onKeyDown:u?void 0:e=>{(e.key===`Enter`||e.key===` `)&&f(!d)},className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 w-full px-3 py-2 bg-muted/20 transition-colors text-left select-none ${u?``:`hover:bg-muted/40 cursor-pointer`}`,children:[u?i(`span`,{className:`h-3 w-3 shrink-0`}):i(d?D:m,{className:`h-3 w-3 text-muted-foreground shrink-0`}),v?i(S,{className:`h-3.5 w-3.5 text-primary shrink-0`}):i(I,{className:`h-3.5 w-3.5 text-warning shrink-0`}),i(`span`,{className:`text-xs font-semibold min-w-0 flex-1 basis-full truncate sm:basis-auto`,children:t.name}),e(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:[`PID `,t.pid]}),i(ze,{status:Vt(t.state),label:t.state}),i(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:c(`cluster.forksTab.cpu`,{percent:t.cpuPercent})}),i(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:J(t.memoryRss)}),i(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:Bt(t.uptimeSeconds)}),!v&&e(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[e(je,{children:[i(Be,{className:`text-[9px] px-1.5 py-0.5 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors font-mono`,title:c(`cluster.forksTab.setLogLevel`,`Set log level`),children:g}),i(Ae,{align:`end`,className:`min-w-[70px] py-0.5`,children:Ht.map(e=>i(Se,{onClick:()=>O(e),className:`h-auto px-2 py-1 text-[10px] font-mono ${e===g?`text-primary font-semibold`:``}`,children:e},e))})]}),i(`button`,{onClick:E,disabled:p===t.name,className:`p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:c(`cluster.forksTab.restartProcess`,`Restart process`),children:i(x,{className:`h-3 w-3 ${p===t.name?`animate-spin`:``}`})})]})]}),d&&l.length>0&&i(`div`,{className:`divide-y divide-border/30`,children:l.map(t=>e(`div`,{children:[e(`div`,{className:`flex items-center gap-2 px-3 py-1.5 pl-9 hover:bg-muted/10 transition-colors`,children:[i(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${t.status===`running`?`bg-success`:`bg-muted-foreground/30`}`}),i(`span`,{className:`text-xs font-medium flex-1 min-w-0 truncate`,children:t.addonId}),t.capabilities.length>0&&e(`div`,{className:`flex gap-1 flex-shrink-0`,children:[t.capabilities.slice(0,3).map(e=>i(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-info/10 text-info truncate max-w-[80px]`,children:e},e)),t.capabilities.length>3&&e(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,t.capabilities.length-3]})]}),e(`div`,{className:`flex items-center gap-1 shrink-0`,children:[i(`button`,{onClick:()=>s(t.addonId,`logs`),className:`p-0.5 rounded transition-colors ${a?.addonId===t.addonId&&a.type===`logs`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:c(`cluster.forksTab.showLogsFor`,`Show logs for {{addonId}}`,{addonId:t.addonId}),children:i(F,{className:`h-3 w-3`})}),i(`button`,{onClick:()=>s(t.addonId,`events`),className:`p-0.5 rounded transition-colors ${a?.addonId===t.addonId&&a.type===`events`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:c(`cluster.forksTab.showEventsFor`,`Show events for {{addonId}}`,{addonId:t.addonId}),children:i(b,{className:`h-3 w-3`})}),i(`button`,{onClick:()=>T(t.addonId),disabled:p===t.addonId,className:`p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:c(`cluster.forksTab.restart`,`Restart {{addonId}}`,{addonId:t.addonId}),children:i(x,{className:`h-3 w-3 ${p===t.addonId?`animate-spin`:``}`})})]})]}),a?.addonId===t.addonId&&a.type===`logs`&&i(`div`,{className:`border-t border-border/40 bg-muted/5`,children:i(De,{addonId:t.addonId,agentId:n,maxHeight:`max-h-48`,showFilters:!1,onClose:()=>s(t.addonId,`logs`)})}),a?.addonId===t.addonId&&a.type===`events`&&i(`div`,{className:`border-t border-border/40 bg-muted/5`,children:i(Re,{addonId:t.addonId,category:`addon.*`,maxHeight:`max-h-48`,onClose:()=>s(t.addonId,`events`)})})]},t.addonId))}),d&&l.length===0&&i(`div`,{className:`px-3 py-2 pl-9 text-[10px] text-muted-foreground`,children:c(`cluster.forksTab.noServices`,`No services`)})]})}function Wt({nodeId:e,processes:t}){let{t:n}=q(),[r,a]=o(null),s=(e,t)=>{a(n=>n?.addonId===e&&n.type===t?null:{addonId:e,type:t})};return t.length===0?i(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:n(`cluster.forksTab.noProcessesOnThisNode`,`No processes on this node`)}):i(`div`,{className:`space-y-2 py-1`,children:t.map((t,n)=>i(Ut,{proc:t,nodeId:e,defaultExpanded:n===0,activePanel:r,onTogglePanel:s},t.name))})}var Gt={system:0,managed:1,root:2};s();function Kt(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:e<86400?`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`:`${Math.floor(e/86400)}d ${Math.floor(e%86400/3600)}h`}function qt(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function Jt({nodeId:t}){let{t:r}=q(),a=c(),o=W(`metrics.node-processes-snapshot`,e=>e.nodeId===t),{data:s}=_e({nodeId:t}),l=o?.processes??s,u=n(()=>l?[...l]:[],[l]),d=n(()=>[{key:`classification`,header:r(`cluster.processesTab.class`,`Class`),sortValue:e=>Gt[e.classification],render:e=>i(`span`,{className:`inline-block rounded-full px-1.5 py-0.5 text-[10px] font-medium ${e.classification===`root`?`bg-info/20 text-info`:e.classification===`system`?`bg-foreground-subtle/20 text-foreground-subtle`:`bg-success/20 text-success`}`,children:e.classification})},{key:`pid`,header:`PID`,align:`right`,sortValue:e=>e.pid,render:e=>i(`span`,{className:`font-mono`,children:e.pid})},{key:`ppid`,header:`PPID`,align:`right`,sortValue:e=>e.ppid,render:e=>i(`span`,{className:`font-mono text-foreground-subtle`,children:e.ppid})},{key:`addonId`,header:r(`cluster.processesTab.addon`,`Addon`),sortValue:e=>e.addonId,render:e=>i(`span`,{className:`text-foreground-subtle text-[11px]`,children:e.addonId??`—`})},{key:`command`,header:r(`cluster.processesTab.command`,`Command`),nowrap:!1,render:e=>i(`span`,{className:`font-mono text-[10px] text-foreground-subtle break-all`,children:qt(e.command)})},{key:`cpuPercent`,header:r(`cluster.processesTab.cpu`,`CPU%`),align:`right`,sortValue:e=>e.cpuPercent,render:e=>e.cpuPercent.toFixed(1)},{key:`memoryRssBytes`,header:`RSS`,align:`right`,sortValue:e=>e.memoryRssBytes,render:e=>J(e.memoryRssBytes)},{key:`uptimeSec`,header:r(`cluster.processesTab.uptime`,`Uptime`),align:`right`,sortValue:e=>e.uptimeSec,render:e=>i(`span`,{className:`text-foreground-subtle`,children:Kt(e.uptimeSec)})}],[r]);return e(`div`,{className:`space-y-4`,children:[i(`div`,{className:`flex items-start justify-end gap-4`,children:e(`button`,{type:`button`,onClick:()=>a.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]}),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground hover:bg-surface-hover`,children:[i(h,{className:`h-3 w-3`}),` `,r(`common.refresh`)]})}),i(z,{columns:d,rows:u,rowKey:e=>e.pid,minWidthPx:880,maxBodyHeight:Ne,emptyMessage:r(`cluster.processesTab.scanning`,`Scanning…`)})]})}s();var Yt=96;function Xt({title:e,points:t,mainLabel:r,gcLabel:a,formatValue:o,emptyMessage:s,gapMs:c}){return i(de,{title:e,series:n(()=>[{id:`main`,label:r,unit:`%`,colorIndex:0,gapMs:c,points:t.map(e=>({t:e.atMs,v:e.main}))},{id:`gc`,label:a,unit:`%`,colorIndex:1,gapMs:c,points:t.map(e=>({t:e.atMs,v:e.gc}))}],[t,r,a,c]),stacked:!0,height:Yt,formatValue:e=>o(e),axisFor:()=>({floor:25}),emptyMessage:s})}function Q({title:e,points:t,formatValue:r,emptyMessage:a,axisFloor:o,axisScale:s=`linear`,gapMs:c}){return i(de,{title:e,series:n(()=>[{id:`value`,label:e,unit:s===`bytes`?`B`:null,colorIndex:0,gapMs:c,points:t.map(e=>({t:e.atMs,v:e.value}))}],[t,e,s,c]),height:Yt,formatValue:e=>r(e),axisFor:()=>({floor:o,scale:s}),emptyMessage:a})}function Zt(e,t){let n=e.at(-1);return n===void 0?[t]:t.atMs>n.atMs?[...e,t]:e.some(e=>e.atMs===t.atMs)?e:[...e,t].toSorted((e,t)=>e.atMs-t.atMs)}function Qt(e,t,n,r){let i=e.get(t),a=Zt(i?.points??[],r);if(i!==void 0&&a===i.points)return e;let o=new Map(e);return o.set(t,{key:t,kind:n,points:a.slice(Math.max(0,a.length-720))}),o}function $t(e,t,n){let r=e;for(let e of ne(t,n))r=Qt(r,e.key,e.kind,e.point);return r}function en(e,t){let n=e;for(let e of t)for(let t of e.points)n=Qt(n,e.key,e.kind,t);return n}function tn(e){let t=null;for(let n of e.values()){let e=n.points.at(-1);e!==void 0&&(t===null||e.atMs>t)&&(t=e.atMs)}return t}var nn=12e4;function rn(e,t){return e===null?!1:t-e>nn}function an(e){let t=e=>{let t=e.points.at(-1);return t===void 0?-1:t.cpuMainPercent!==null&&t.cpuGcPercent!==null?t.cpuMainPercent+t.cpuGcPercent:t.cpuLifetimePercent};return[...e.values()].toSorted((e,n)=>{let r=t(n)-t(e);return r===0?e.key.localeCompare(n.key):r})}function on(e){for(let t of e.values()){let e=t.points.at(-1);if(e&&e.cpuMainPercent!==null)return!0}return!1}var sn={key:`cpu`,dir:`desc`};function cn(e){let t=e.points.at(-1);return t===void 0?null:t.cpuMainPercent!==null&&t.cpuGcPercent!==null?t.cpuMainPercent+t.cpuGcPercent:t.cpuLifetimePercent}function ln(e){return e.points.at(-1)?.memoryRssBytes??null}function un(e,t,n){let r=n.trim().toLowerCase();return r===``?!0:e.toLowerCase().includes(r)||t.toLowerCase().includes(r)}function dn(e,t){return t===`memory`?ln(e):cn(e)}function fn(e,t,n){let r=e.filter(e=>t.selectedKeys.size>0&&!t.selectedKeys.has(e.key)?!1:un(n(e),e.key,t.search)),i=(e,t)=>e.key.localeCompare(t.key);return[...r].toSorted((e,r)=>{if(t.sort.key===`name`){let a=n(e).localeCompare(n(r)),o=t.sort.dir===`asc`?a:-a;return o===0?i(e,r):o}let a=dn(e,t.sort.key),o=dn(r,t.sort.key);if(a===null&&o===null)return i(e,r);if(a===null)return 1;if(o===null)return-1;let s=t.sort.dir===`desc`?o-a:a-o;return s===0?i(e,r):s})}s();function pn(e,n=720){let r=W(`metrics.node-processes-snapshot`,t=>t.nodeId===e),[i,s]=o(new Map),[c,l]=o(void 0),u=t(null),{data:d,isPending:f}=Ue({forNodeId:e,sinceMs:c,maxPoints:n});a(()=>{d!==void 0&&s(e=>{let t=en(e,d.series);return u.current=tn(t),t})},[d]);let p=r?.timestamp;a(()=>{r==null||p===void 0||(rn(u.current,p)&&l(u.current??0),s(e=>{let t=$t(e,r.processes,p);return u.current=tn(t),t}))},[p]),a(()=>{s(new Map),l(void 0),u.current=null},[e]);let m=0;for(let e of i.values())m=Math.max(m,e.points.length);return{series:an(i),sampleCount:m,threadSplitAvailable:on(i),loadingRetained:f,durable:d?.durable??null,bucketMs:d?.bucketMs??null,cadenceMs:d?.cadenceMs??null,retainedSamples:d?.retainedSamples??null}}var mn=`__unclaimed__`;function hn(e,t){return{kind:e,deviceId:t,cpu:0,cpuKnown:!0,rss:0,rssKnown:!0,count:0,roles:new Set}}function gn(e,t){return{key:e,kind:t.kind,deviceId:t.deviceId,cpuSeconds:t.cpuKnown?Math.round(t.cpu*100)/100:null,rssBytes:t.rssKnown?t.rss:null,unitCount:t.count,roles:[...t.roles].sort()}}function _n(e,t){let n=new Map,r=new Set;for(let t of e){t.pid!==void 0&&r.add(t.pid);let e=t.deviceId!==null&&t.attribution!==`unattributable`,i=e?`device:${t.deviceId}`:`shared:${t.role}`,a=n.get(i)??hn(e?`camera`:`shared`,e?t.deviceId:null);a.count+=1,a.roles.add(t.role),t.cpuSeconds===void 0?a.cpuKnown=!1:a.cpu+=t.cpuSeconds,t.rssBytes===void 0?a.rssKnown=!1:a.rss+=t.rssBytes,n.set(i,a)}let i=[...n.entries()].map(([e,t])=>gn(e,t));if(t===void 0)return i;let a=t.filter(e=>!r.has(e.pid));if(a.length===0)return i;let o=hn(`unclaimed`,null);for(let e of a)o.count+=1,o.rss+=e.memoryRssBytes;return o.cpuKnown=!1,[...i,gn(mn,o)]}var vn=[{family:`decode`,attribution:`measured`,unit:`one forked decode-worker child per decode SESSION`,perCamera:!0,wiredToday:!0,missingLink:``,evidence:[`packages/addon-pipeline/src/session-decode/fork-decode-worker.ts:118`,`packages/addon-pipeline/src/session-decode/fork-decode-worker.ts:131`,`packages/addon-pipeline/src/pipeline-runner/index.ts:2765`,`packages/types/src/process/child-cost-registry.ts:188`]},{family:`transcode`,attribution:`measured`,unit:`one ffmpeg child per (camera, encode plan)`,perCamera:!0,wiredToday:!0,missingLink:``,evidence:[`packages/addon-pipeline/src/stream-broker/stream-broker/egress-transcode-manager.ts:960`,`packages/addon-pipeline/src/stream-broker/stream-broker/transcode-egress.ts:282`,`packages/addon-pipeline/src/stream-broker/stream-broker/transcode-egress.ts:324`,`packages/types/src/ffmpeg/sharing-key.ts:139`]},{family:`recording`,attribution:`measured`,unit:`one passthrough ffmpeg per (camera, profile)`,perCamera:!0,wiredToday:!0,missingLink:``,evidence:[`packages/addon-pipeline/src/recorder/addon/segment-writer.ts:33`,`packages/addon-pipeline/src/recorder/addon/segment-writer.ts:217`,`packages/addon-pipeline/src/recorder/addon/segment-writer.ts:279`,`packages/addon-pipeline/src/recorder/addon/recording-controller.ts:1710`]},{family:`detection`,attribution:`accounted`,unit:`a SHARED inference pool per (node, runtime, device) — no per-camera process`,perCamera:!1,wiredToday:!0,missingLink:"Nothing is missing for COUNTING — per-camera inference milliseconds, processed/shed frames and bytes-to-pool are already accumulated. What is missing is any basis for CPU seconds: `deviceId` reaches the pool as a diagnostic label and selects nothing, so cost can only ever be apportioned, never measured. Since 2026-08-27 the pool DECLARES this itself, contributing `deviceId: null` + `attribution: unattributable` rather than leaving an observer to infer it — the renunciation is data, and it is still refused by the chart gate.",evidence:[`packages/addon-pipeline/src/detection-pipeline/provider.ts:540`,`packages/addon-pipeline/src/detection-pipeline/engine/shared-inference-pool.ts:413`,`packages/types/src/interfaces/inference-engine.ts:24`,`packages/addon-pipeline/src/pipeline-runner/timing-sampler.ts:63`,`packages/addon-pipeline/src/pipeline-runner/runner.ts:353`,`packages/addon-pipeline/src/pipeline-runner/runner.ts:849`,`packages/addon-pipeline/src/pipeline-runner/frame-lazy-metrics.ts:100`]},{family:`streaming`,attribution:`measured`,unit:"one StreamBroker per `${deviceId}/${camStreamId}`, with an exact RTP ring byte counter",perCamera:!0,wiredToday:!1,missingLink:"The ffmpeg-backed ingest is now reported per camera, but that is the minority path. `rtpRingBytes` — the exact figure for the in-process case — is maintained on every push and drop and is still private and absent from `getStats()`. The three `EncodedRingBuffer`s track packets and duration and have no byte accumulator at all; the only byte figure they offer is `preRollBudgetBytes`, which is a BUDGET, not an occupancy.",evidence:[`packages/addon-pipeline/src/stream-broker/stream-broker/stream-broker.ts:2895`,`packages/addon-pipeline/src/stream-broker/rtsp/ffmpeg-push-reader.ts:189`,`packages/addon-pipeline/src/stream-broker/stream-broker/stream-broker.ts:494`,`packages/addon-pipeline/src/stream-broker/stream-broker/stream-broker.ts:498`,`packages/addon-pipeline/src/stream-broker/stream-broker/stream-broker.ts:2505`,`packages/addon-pipeline/src/stream-broker/stream-broker/pre-roll.ts:269`]}];function yn(e){return e.attribution===`measured`&&e.wiredToday}function bn(){let e=new Set;for(let t of vn)yn(t)&&e.add(t.family);return e}var xn=bn();function Sn(e){return!xn.has(e.role)||e.deviceId===null?!1:e.attribution===`measured`}function Cn(e){return`${e.addonId}${e.role}${e.unit}${e.pid??`-`}`}function wn(){return{cpuSeconds:0,cpuKnown:!0,rssBytes:0,rssKnown:!0,unitCount:0,roles:new Set}}function Tn(e,t,n){if(t.cpuSeconds===void 0)return null;if(e===void 0)return t.startedAtMs===void 0||t.startedAtMs<n?null:t.cpuSeconds;if(e.cpuSeconds===void 0||e.startedAtMs===void 0||t.startedAtMs===void 0||e.startedAtMs!==t.startedAtMs)return null;let r=t.cpuSeconds-e.cpuSeconds;return r<0?null:r}function En(e){return Math.round(e*10)/10}function Dn(e,t){let n=t.atMs-e.atMs;if(n<=0)return[];let r=n/1e3,i=new Map;for(let t of e.entries)Sn(t)&&i.set(Cn(t),t);let a=new Map,o=new Set;for(let n of t.entries){if(!Sn(n)||n.deviceId===null)continue;let t=Cn(n);o.add(t);let r=a.get(n.deviceId)??wn();r.unitCount+=1,r.roles.add(n.role);let s=Tn(i.get(t),n,e.atMs);s===null?r.cpuKnown=!1:r.cpuSeconds+=s,n.rssBytes===void 0?r.rssKnown=!1:r.rssBytes+=n.rssBytes,a.set(n.deviceId,r)}for(let[e,t]of i){if(o.has(e)||t.deviceId===null)continue;let n=a.get(t.deviceId);n!==void 0&&(n.cpuKnown=!1)}return[...a.entries()].map(([e,n])=>({deviceId:e,point:{atMs:t.atMs,cpuPercent:n.cpuKnown?En(n.cpuSeconds/r*100):null,rssBytes:n.rssKnown?n.rssBytes:null,unitCount:n.unitCount,roles:[...n.roles].toSorted()}}))}function On(e,t){if(t.length===0)return e;let n=new Map(e);for(let e of t){let t=n.get(e.deviceId),r=t?.points.at(-1);if(r!==void 0&&e.point.atMs<=r.atMs)continue;let i=[...t?.points??[],e.point];n.set(e.deviceId,{deviceId:e.deviceId,points:i.slice(Math.max(0,i.length-720))})}return n}function kn(e){let t=e=>{for(let t=e.points.length-1;t>=0;t--){let n=e.points[t]?.cpuPercent;if(n!=null)return n}return-1};return[...e.values()].toSorted((e,n)=>{let r=t(n)-t(e);return r===0?e.deviceId-n.deviceId:r})}function An(e){let t=e.indexOf(`@`);return t===-1?{addonId:e,nodeId:null}:{addonId:e.slice(0,t),nodeId:e.slice(t+1)}}function jn(e,t){let n=An(e);return n.nodeId===null?t.isHub:n.nodeId===t.nodeId}function Mn(e,t){return e.filter(e=>jn(e.addonId,t))}s();function Nn(e){let n=W(`metrics.node-processes-snapshot`,t=>t.nodeId===e.nodeId),r=xe(void 0,{staleTime:1/0,refetchOnWindowFocus:!1}),[i,s]=o(new Map),c=t(null),l=t(r.refetch);l.current=r.refetch;let u=n?.timestamp;a(()=>{u!==void 0&&l.current()},[u]),a(()=>{s(new Map),c.current=null},[e.nodeId,e.isHub]);let d=r.data,f=r.dataUpdatedAt;a(()=>{if(d===void 0||f===0)return;let t={atMs:f,entries:Mn(d,e)},n=c.current;if(c.current=t,n===null)return;let r=Dn(n,t);r.length!==0&&s(e=>On(e,r))},[d,f,e.nodeId,e.isHub]);let p=d===void 0?[]:Mn(d,e),m=n?.processes,h=_n(p,m);return{series:kn(i),unclaimed:h.find(e=>e.kind===`unclaimed`)??null,loading:r.isPending,error:r.error===null?null:r.error.message}}function Pn(e){let t=new Map;for(let n of e){let e=n.name?.trim();e===void 0||e===``||t.set(n.id,e)}return t}var Fn=25,In=64*1024*1024,Ln=1e4;function Rn({scope:t,cadenceMs:n}){let{t:r}=q(),a=Nn(t),{data:o=[]}=ue({isCamera:!0,projection:`slim`}),s=Pn(o),c=pe(n??Ln);return e(`section`,{className:`space-y-3`,children:[a.error!==null&&e(`div`,{className:`flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-[11px] text-destructive`,children:[i(L,{className:`h-3 w-3 mt-0.5 shrink-0`}),i(`span`,{children:r(`cameraLoad.readFailed`,`Could not read the load contributions: {{error}}. This is a failed read, NOT an idle cluster.`,{error:a.error})})]}),i(Bn,{unclaimed:a.unclaimed}),a.series.length===0&&a.error===null&&i(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:a.loading?r(`cameraLoad.loading`,`Reading what the addons report…`):r(`cameraLoad.waitingWindow`,`No per-camera window yet.`)}),i(`div`,{className:`space-y-3`,children:a.series.map(t=>e(`div`,{className:`rounded-lg border border-border p-3`,children:[e(`div`,{className:`flex items-baseline justify-between gap-2 mb-2`,children:[i(zn,{deviceId:t.deviceId,name:s.get(t.deviceId)}),i(`span`,{className:`text-[10px] text-foreground-subtle`,children:r(`cameraLoad.unitCount`,`{{count}} unit(s): {{roles}}`,{count:t.points.at(-1)?.unitCount??0,roles:(t.points.at(-1)?.roles??[]).join(`, `)})})]}),e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[i(Q,{title:r(`cameraLoad.cpuTitle`,`CPU % of one core (delta)`),points:t.points.map(e=>({atMs:e.atMs,value:e.cpuPercent})),formatValue:e=>`${e.toFixed(1)}%`,axisFloor:Fn,gapMs:c,emptyMessage:r(`cameraLoad.cpuUnavailable`,`No measurable window yet.`)}),i(Q,{title:r(`cameraLoad.memoryTitle`,`Memory RSS`),points:t.points.map(e=>({atMs:e.atMs,value:e.rssBytes})),formatValue:J,axisFloor:In,axisScale:`bytes`,gapMs:c,emptyMessage:r(`cameraLoad.memoryUnavailable`,`No memory reported.`)})]})]},t.deviceId))})]})}function zn({deviceId:t,name:n}){let{t:r}=q();return n===void 0?i(`span`,{className:`text-xs font-medium text-foreground`,children:r(`cameraLoad.deviceLabel`,`Camera {{deviceId}}`,{deviceId:t})}):e(`span`,{className:`flex items-baseline gap-1.5 min-w-0`,children:[i(`span`,{className:`text-xs font-medium text-foreground truncate`,children:n}),e(`span`,{className:`shrink-0 text-[10px] font-mono text-foreground-subtle`,children:[`#`,t]})]})}function Bn({unclaimed:e}){let{t}=q();return e===null||e.unitCount===0?null:i(`div`,{className:`flex items-center gap-2`,children:i(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full bg-warning/10 text-warning font-medium tabular-nums`,children:t(`cameraLoad.unclaimedBadge`,`{{count}} unclaimed · {{rss}}`,{count:e.unitCount,rss:e.rssBytes===null?`—`:J(e.rssBytes)})})})}s();var Vn=256*1024*1024,Hn=1e4;function Un({nodeId:r,isHub:a}){let s=t(null);Le(s);let{t:c}=q(),{series:l,sampleCount:u,threadSplitAvailable:d,loadingRetained:f,bucketMs:p,cadenceMs:m}=pn(r),[h,g]=o(``),[_,v]=o(new Set),[y,b]=o(sn),x=e=>e.key===`__root__`?c(`clusterLoad.bucketRoot`,`Node supervisor`):e.key===`__unattributed__`?c(`clusterLoad.bucketUnattributed`,`Unattributed processes`):e.key,S=pe(p??m??Hn),C=n(()=>fn(l,{search:h,selectedKeys:_,sort:y},x),[l,h,_,y]),T=e=>{v(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return e(`div`,{className:`space-y-4`,children:[i(Wn,{bucketMs:p,cadenceMs:m}),!d&&u>0&&e(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/40 bg-warning/5 px-3 py-2 text-[11px] text-warning`,children:[i(L,{className:`h-3 w-3 mt-0.5 shrink-0`}),i(`span`,{children:c(`clusterLoad.noThreadSplit`,`No thread-level CPU split on this node — /proc/<pid>/task is Linux-only, and the first sample after a restart has no window to measure. CPU below falls back to the ps lifetime AVERAGE, which is not a rate.`)})]}),u===0&&i(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:f?c(`clusterLoad.loadingRetained`,`Reading the retained series from this node…`):c(`clusterLoad.waitingFirstSample`,`No retained samples for this node — waiting for the next snapshot (up to 20s). The chart needs two to draw a rate.`)}),l.length>0&&e(`div`,{className:`space-y-2`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(`label`,{className:`relative flex-1 min-w-[160px]`,children:[i(N,{className:`pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-foreground-subtle`}),i(`input`,{ref:s,type:`search`,value:h,onChange:e=>g(e.target.value),placeholder:c(`clusterLoad.searchPlaceholder`,`Find a runner…`),"aria-label":c(`clusterLoad.searchLabel`,`Find a runner`),className:`w-full rounded border border-border bg-background py-1 pl-7 pr-2 text-[11px] text-foreground placeholder:text-foreground-subtle`})]}),i(Gn,{sort:y,onChange:b})]}),e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[l.map(e=>{let t=_.has(e.key);return i(`button`,{type:`button`,"aria-pressed":t,onClick:()=>T(e.key),className:`rounded-full border px-2 py-0.5 text-[10px] transition-colors ${t?`border-primary bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground`}`,children:x(e)},e.key)}),_.size>0&&e(`button`,{type:`button`,onClick:()=>v(new Set),className:`inline-flex items-center gap-1 rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground`,children:[i(w,{className:`h-2.5 w-2.5`}),c(`clusterLoad.clearFilter`,`All runners`)]})]})]}),l.length>0&&C.length===0&&i(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:c(`clusterLoad.noMatches`,`No runner matches this search on {{count}} present. The node is reporting — the filter is hiding them.`,{count:l.length})}),i(`div`,{className:`space-y-3`,children:C.map(t=>e(`div`,{className:`rounded-lg border border-border p-3`,children:[e(`div`,{className:`flex items-baseline justify-between gap-2 mb-2`,children:[i(`span`,{className:`text-xs font-medium text-foreground`,children:x(t)}),i(`span`,{className:`text-[10px] text-foreground-subtle`,children:c(`clusterLoad.processCount`,`{{count}} process(es)`,{count:t.points.at(-1)?.processCount??0})})]}),e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[i(Xt,{title:d?c(`clusterLoad.cpuTitle`,`CPU % of one core`):c(`clusterLoad.cpuTitleLifetime`,`CPU % (ps lifetime average)`),mainLabel:c(`clusterLoad.seriesMain`,`Main threads`),gcLabel:c(`clusterLoad.seriesGc`,`GC / V8 helpers`),points:t.points.map(e=>({atMs:e.atMs,main:e.cpuMainPercent,gc:e.cpuGcPercent})),formatValue:e=>`${e.toFixed(0)}%`,gapMs:S,emptyMessage:c(`clusterLoad.cpuUnavailable`,`No thread split on this node. Lifetime average: {{avg}}%`,{avg:(t.points.at(-1)?.cpuLifetimePercent??0).toFixed(1)})}),i(Q,{title:c(`clusterLoad.memoryTitle`,`Memory RSS`),points:t.points.map(e=>({atMs:e.atMs,value:e.memoryRssBytes})),formatValue:J,axisFloor:Vn,axisScale:`bytes`,gapMs:S,emptyMessage:c(`clusterLoad.memoryUnavailable`,`No memory samples yet.`)})]})]},t.key))}),i(Rn,{scope:{nodeId:r,isHub:a},cadenceMs:m})]})}function Wn({bucketMs:e,cadenceMs:t}){let{t:n}=q();return e===null?null:i(`p`,{className:`text-[10px] text-foreground-subtle`,children:t!==null&&e>t?n(`clusterLoad.captionBucket`,`1 point = {{bucket}}s (bucket MAXIMUM, not a mean)`,{bucket:Math.round(e/1e3)}):n(`clusterLoad.captionRaw`,`1 point = 1 snapshot`)})}function Gn({sort:t,onChange:n}){let{t:r}=q(),a=[{key:`cpu`,label:r(`clusterLoad.sortCpu`,`CPU`)},{key:`memory`,label:r(`clusterLoad.sortMemory`,`Memory`)},{key:`name`,label:r(`clusterLoad.sortName`,`Name`)}];return e(`div`,{className:`flex items-center gap-1`,children:[i(`span`,{className:`text-[10px] text-foreground-subtle`,children:r(`clusterLoad.sortBy`,`Sort by`)}),a.map(r=>{let i=t.key===r.key;return e(`button`,{type:`button`,"aria-pressed":i,onClick:()=>n(i?{key:r.key,dir:t.dir===`desc`?`asc`:`desc`}:{key:r.key,dir:r.key===`name`?`asc`:`desc`}),className:`rounded border px-1.5 py-0.5 text-[10px] transition-colors ${i?`border-primary bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground`}`,children:[r.label,i&&(t.dir===`desc`?` ↓`:` ↑`)]},r.key)})]})}var Kn=`No per-node settings on this node. Every other setting these addons expose is one value for the whole cluster — edit those in System → Settings, not here.`;function qn({nodeId:e,addonIds:t}){let{t:n}=q();return t.length===0?i(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:n(`cluster.nodeDetailSettingsTab.noAddonsOnThisNode`,`No addons on this node`)}):i(`div`,{className:`w-full py-2`,children:i(Qe,{nodeId:e,addonIds:t,level:`global`,fieldScope:`perNode`,emptyMessage:Kn,selfTabbed:!0})})}s();function Jn({nodeId:e,addons:t}){let{t:r}=q(),a=c(),{data:o,isLoading:s}=ke({nodeId:e}),l=n(()=>{let e=new Map;for(let n of t)for(let t of n.capabilities){let r=e.get(t)??[];r.push(n.id),e.set(t,r)}return[...e.entries()].toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({capName:e,providers:t}))},[t]),u=le({onSuccess:()=>{a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCapabilityBindings`]]})}});return l.length===0?i(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:r(`cluster.nodeDetailCapabilitiesTab.noCapabilitiesOnThisNode`,`No capabilities on this node`)}):i(z,{columns:[{key:`capName`,header:r(`cluster.nodeDetailCapabilitiesTab.capability`,`Capability`),width:`w-1/2`,sortValue:e=>e.capName,render:e=>i(`span`,{className:`font-medium`,children:e.capName})},{key:`provider`,header:r(`cluster.nodeDetailCapabilitiesTab.boundProvider`,`Bound provider`),render:t=>{let n=o?.[t.capName]??t.providers[0]??``,a=t.providers.length===1;return i(`select`,{value:n,onChange:n=>u.mutate({nodeId:e,capName:t.capName,addonId:n.target.value}),disabled:a||u.isPending||s,className:`w-full rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-60`,title:a?r(`cluster.nodeDetailCapabilitiesTab.onlyOneProviderInstalledChoice`,`Only one provider installed — choice becomes available once a second addon registers this capability`):void 0,children:t.providers.map(e=>i(`option`,{value:e,children:e},e))})}}],rows:l,rowKey:e=>e.capName,minWidthPx:520,maxBodyHeight:Ne})}s();function Yn(e){if(e==null)return`—`;let t=Math.floor(e/1e3),n=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60);return n>0?`${n}d ${r}h ${i}m`:r>0?`${r}h ${i}m`:`${i}m`}function Xn(t){let{t:n}=q(),[r,a]=o(!1),[s,l]=o(t.name),d=c(),f=me({onSuccess:()=>{d.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}}),p=(t.localIps??[]).filter(e=>!e.includes(`:`)),m=(t.localIps??[]).filter(e=>e.includes(`:`)),h=async()=>{if(!s.trim()||s===t.name){a(!1);return}try{await f.mutateAsync({nodeId:t.nodeId,name:s.trim()}),a(!1)}catch(e){console.error(`Rename failed:`,e)}},_=[[`Node ID`,i(`span`,{className:`font-mono text-xs`,children:t.nodeId})],[`Display Name`,r?e(`div`,{className:`flex items-center gap-1.5`,children:[i(`input`,{type:`text`,className:`flex-1 px-2 py-0.5 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary`,value:s,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&h(),e.key===`Escape`&&a(!1)},disabled:f.isPending,autoFocus:!0}),i(`button`,{onClick:()=>void h(),disabled:f.isPending,className:`p-0.5 text-success hover:bg-success/10 rounded`,title:n(`common.save`,`Save`),children:i(u,{className:`h-3.5 w-3.5`})}),i(`button`,{onClick:()=>a(!1),className:`p-0.5 text-muted-foreground hover:bg-muted rounded`,title:n(`common.cancel`,`Cancel`),children:i(w,{className:`h-3.5 w-3.5`})})]}):e(`div`,{className:`flex items-center gap-1.5`,children:[i(`span`,{className:`text-xs`,children:t.name}),!t.isHub&&i(`button`,{onClick:()=>{l(t.name),a(!0)},className:`p-0.5 text-muted-foreground hover:text-primary rounded`,title:n(`cluster.nodeInfoTab.rename`,`Rename`),children:i(g,{className:`h-3 w-3`})})]})],[`Hostname`,i(`span`,{className:`text-xs`,children:t.hostname})],[`Role`,t.isHub?i(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary font-medium`,children:n(`cluster.nodeInfoTab.hub`,`Hub`)}):i(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-medium`,children:n(`cluster.nodeInfoTab.agent`,`Agent`)})],[`Root Package`,t.rootPackage?e(`span`,{className:`font-mono text-xs`,children:[t.rootPackage.name,`@`,t.rootPackage.version]}):i(`span`,{className:`text-xs text-muted-foreground`,children:`—`})],[`Platform`,e(`span`,{className:`text-xs`,children:[t.platform,` / `,t.arch]})],[`CPU`,e(`span`,{className:`text-xs`,children:[t.cpuModel??`—`,` (`,n(`cluster.nodeInfoTab.cores`,{count:t.cpuCores}),`)`]})],[`Memory`,i(`span`,{className:`text-xs`,children:t.memoryMB>0?n(`cluster.nodeInfoTab.gb`,`{{value1}} GB`,{value1:(t.memoryMB/1024).toFixed(1)}):`—`})],[`Uptime`,i(`span`,{className:`text-xs`,children:Yn(t.uptime)})],[n(`cluster.nodeInfoTab.installedRuntimes`,`Installed runtimes`),t.engines.length>0?i(`div`,{className:`flex flex-wrap gap-1`,title:n(`cluster.nodeInfoTab.installedRuntimesHint`,`Inference runtimes installed on this node. Its live inference devices are on Pipeline → Load balancing.`),children:t.engines.map(e=>i(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium`,children:e},e))}):i(`span`,{className:`text-xs text-muted-foreground`,children:`—`})]];return p.length>0&&_.push([`IPv4`,i(`div`,{className:`flex flex-wrap gap-1.5`,children:p.map((e,t)=>i(`span`,{className:`font-mono text-xs px-1.5 py-0.5 rounded bg-muted`,children:e},`${e}-${t}`))})]),m.length>0&&_.push([`IPv6`,i(`div`,{className:`flex flex-wrap gap-1.5`,children:m.map((e,t)=>i(`span`,{className:`font-mono text-[10px] px-1.5 py-0.5 rounded bg-muted truncate max-w-[280px]`,title:e,children:e},`${e}-${t}`))})]),i(`div`,{className:`py-2`,children:i(`table`,{className:`w-full text-sm`,children:i(`tbody`,{children:_.map(([t,n],r)=>e(`tr`,{className:r%2==0?`bg-muted/20`:``,children:[i(`td`,{className:`py-1.5 px-2 text-xs font-medium text-muted-foreground w-28 align-top whitespace-nowrap`,children:t}),i(`td`,{className:`py-1.5 px-2`,children:n})]},t))})})})}s();function Zn({nodeId:t,value:n,detectedHosts:r,status:s,errorMessage:c,onCommit:l}){let{t:d}=q(),[p,m]=o(n??``);a(()=>{m(n??``)},[n]);let h=r[0],g=h===void 0?`auto-detect`:`auto: ${h}`,_=s===`pending`,v=p.trim(),y=v!==(n??``),b=y&&!_,x=()=>{b&&l(t,v.length>0?v:null)};return e(`div`,{className:`flex items-center gap-1.5`,children:[i(H,{"aria-label":d(`placementBoard.reachableHostInput.reachableHostFor`,`Reachable host for {{nodeId}}`,{nodeId:t}),type:`text`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:g,value:p,disabled:_,onChange:e=>m(e.target.value),onBlur:x,onKeyDown:e=>{e.key===`Enter`&&x(),e.key===`Escape`&&m(n??``)},className:`w-36`}),e(G,{variant:`outline`,size:`sm`,onClick:x,disabled:!b,"aria-label":d(`placementBoard.reachableHostInput.saveReachableHostFor`,`Save reachable host for {{nodeId}}`,{nodeId:t}),title:d(`placementBoard.reachableHostInput.saveReachableHost`,`Save reachable host`),children:[_?i(A,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):i(u,{className:`h-3 w-3`,"aria-hidden":`true`}),d(`common.save`,`Save`)]}),!y&&!_&&s===`success`&&i(u,{className:`h-3.5 w-3.5 shrink-0 text-success`,"aria-label":d(`placementBoard.reachableHostInput.saved`,`Saved`),role:`img`}),s===`error`&&i(`span`,{title:c??d(`placementBoard.reachableHostInput.failedToSaveReachableHost`,`Failed to save reachable host`),children:i(f,{className:`h-3.5 w-3.5 shrink-0 text-danger`,"aria-label":c??d(`placementBoard.reachableHostInput.failedToSaveReachableHost`,`Failed to save reachable host`),role:`img`})})]})}s();function Qn(e){let t=te.safeParse($e(e,`color`));return t.success?t.data:null}function $n(e,t){return t.variables?.agentNodeId===e?t.isPending?`pending`:t.isError?`error`:t.isSuccess?`success`:`idle`:`idle`}function er({nodeId:t,detectedHosts:r}){let{t:a}=q(),o=c(),s=we(void 0),l=Fe({onSuccess:()=>et(o)}),u=Fe({onSuccess:()=>et(o)}),d=n(()=>s.data?.find(e=>e.nodeId===t)?.settings,[s.data,t]),f=Qn(d)??(s.isLoading?null:ee(t)),p=tt(d,`reachableHost`),m=$n(t,l),h=m===`error`?nt(l.error):null,g=r.filter(e=>!e.includes(`:`)),_=e=>{e!==f&&u.mutate({agentNodeId:t,color:e})};return e(`div`,{className:`rounded-lg border border-border bg-surface/40 divide-y divide-border px-3`,children:[i(Ie,{label:a(`nodes.general.nodeColour`,`Node colour`),children:i(`div`,{role:`group`,"aria-label":a(`nodes.general.nodeColourGroup`,`Node colour`),className:`flex flex-wrap gap-2`,children:R.map(e=>{let t=f===e;return i(G,{type:`button`,role:`radio`,"aria-checked":t,"aria-label":e,variant:`outline`,size:`sm`,disabled:s.isLoading||u.isPending,title:e,onClick:()=>_(e),className:`h-6 w-6 min-w-6 shrink-0 rounded-full border-0 p-0 ${fe(e)} ${t?`ring-2 ring-primary ring-offset-2 ring-offset-background`:`opacity-80 hover:opacity-100`}`,children:i(`span`,{className:`sr-only`,children:e})},e)})})}),i(Ie,{label:a(`nodes.general.reachableHost`,`Reachable host`),children:i(Zn,{nodeId:t,value:p,detectedHosts:g,status:m,errorMessage:h,onCommit:(e,t)=>{l.mutate({agentNodeId:e,reachableHost:t})}})})]})}s();var tr=3*6e4,nr={neutral:`bg-surface-muted text-foreground-subtle`,ok:`bg-success/15 text-success`,info:`bg-info/15 text-info`,warn:`bg-warning/15 text-warning`,error:`bg-danger/15 text-danger`};function rr({desktopApp:t,nodeName:n,routingInput:s,onSettled:c}){let{t:l}=q(),u=M(),d=Ge({onSettled:c}),[f,p]=o(null),[m,h]=o(!1),[g,_]=o(null);a(()=>{f!=null&&t.version!==f.fromVersion&&(p(null),h(!1))},[t.version,f]),a(()=>{if(f==null)return;let e=Math.max(0,f.startedAtMs+tr-Date.now()),t=setTimeout(()=>h(!0),e);return()=>clearTimeout(t)},[f]);let v=r(e=>{switch(e){case`not-electron`:return l(`serverManagement.desktopRefusedNotElectron`,`This node does not run inside the desktop app.`);case`no-app-state`:return l(`serverManagement.desktopRefusedNoState`,`The desktop app has not reported its state yet.`);case`app-state-stale`:return l(`serverManagement.desktopRefusedStale`,`The desktop app stopped reporting — it is probably not running.`);case`not-downloaded`:return l(`serverManagement.desktopRefusedNotDownloaded`,`No update is downloaded yet.`)}},[l]),y=r(async()=>{if(await u({title:l(`serverManagement.desktopConfirmTitle`,`Install desktop app update`),message:l(`serverManagement.desktopConfirmBody`,`Install {{version}} on "{{node}}" and restart the desktop app? The node is offline while it restarts.`,{version:t.update.version??``,node:n}),confirmLabel:l(`serverManagement.desktopInstallAction`,`Install update & restart`),variant:`warning`})){_(null),h(!1);try{let e=await d.mutateAsync(s);e.accepted?p({fromVersion:t.version,startedAtMs:Date.now()}):e.reason!=null&&_(v(e.reason))}catch(e){_(e instanceof Error?e.message:String(e))}}},[u,t,d,n,v,s,l]),b=f!=null&&!m,{update:S}=t,C=null;t.stale?C={label:l(`serverManagement.desktopStale`,`app state unknown (last seen {{when}})`,{when:Xe(t.stateAtMs)}),tone:`warn`}:S.downloaded?C={label:l(`serverManagement.desktopReady`,`update {{version}} ready`,{version:S.version??``}),tone:`ok`}:S.available?C={label:l(`serverManagement.desktopDownloading`,`update {{version}} available — downloading`,{version:S.version??``}),tone:`info`}:S.checking?C={label:l(`serverManagement.stateChecking`,`checking…`),tone:`info`}:S.error??(C={label:l(`serverManagement.stateUpToDate`,`up to date`),tone:`ok`});let w=!t.stale&&S.downloaded&&!b&&!d.isPending;return e(`div`,{className:`space-y-1.5`,children:[e(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-1 text-sm`,children:[e(`span`,{className:`inline-flex items-baseline gap-1`,children:[i(`span`,{className:`text-foreground-subtle`,children:l(`serverManagement.desktopApp`,`Desktop app`)}),i(`span`,{className:`font-mono text-foreground`,children:t.version})]}),C!=null&&i(`span`,{className:`inline-flex items-center rounded px-2 py-0.5 text-[11px] font-medium ${nr[C.tone]}`,children:C.label})]}),!t.stale&&S.error!=null&&i(`p`,{className:`text-xs text-danger`,children:l(`serverManagement.desktopUpdateError`,`Update check failed: {{error}}`,{error:S.error})}),w&&e(G,{size:`sm`,onClick:()=>void y(),children:[i(x,{className:`h-3.5 w-3.5`}),l(`serverManagement.desktopInstallAction`,`Install update & restart`)]}),(d.isPending||b)&&e(`div`,{className:`flex items-center gap-2 text-sm text-warning`,children:[i(A,{className:`h-4 w-4 animate-spin`}),l(`serverManagement.desktopRestarting`,`The desktop app is restarting to install the update…`)]}),f!=null&&m&&i(`p`,{role:`status`,className:`text-xs text-warning`,children:l(`serverManagement.desktopRestartTimeout`,`The desktop app has not come back with a new version after 3 minutes. Check the machine.`)}),g!=null&&i(`p`,{role:`status`,className:`text-xs text-warning`,children:g})]})}s();var ir=[[`serverManagement`,`getServerPackageStatus`]];function ar({label:e,tone:t}){return i(`span`,{className:`inline-flex items-center rounded px-2 py-0.5 text-[11px] font-medium ${{neutral:`bg-surface-muted text-foreground-subtle`,ok:`bg-success/15 text-success`,info:`bg-info/15 text-info`,warn:`bg-warning/15 text-warning`,error:`bg-danger/15 text-danger`}[t]}`,children:e})}function $({label:t,value:n}){return e(`div`,{className:`flex items-center justify-between gap-4 text-sm`,children:[i(`span`,{className:`text-foreground-subtle`,children:t}),i(`span`,{className:`font-mono text-foreground`,children:n??`—`})]})}function or({runningVersion:t,latestVersion:n,seedVersion:r,nodeRuntimeVersion:a,labelRunning:o,labelLatest:s,labelSeed:c,labelRuntime:l}){return i(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-sm`,children:[{key:`running`,label:o,value:t},{key:`latest`,label:s,value:n},{key:`seed`,label:c,value:r},{key:`runtime`,label:l,value:a}].map(({key:t,label:n,value:r})=>e(`span`,{className:`inline-flex items-baseline gap-1`,children:[i(`span`,{className:`text-foreground-subtle`,children:n}),i(`span`,{className:`font-mono text-foreground`,children:r??`—`})]},t))})}var sr={ok:`border-success/40 bg-success/10 text-success`,warn:`border-warning/40 bg-warning/10 text-warning`,error:`border-danger/40 bg-danger/10 text-danger`};function cr(e){return e.outcome===`failed`?`error`:(e.outcome,e.accepted?`ok`:`warn`)}function lr(e,t){let n=t instanceof Error?t.message:String(t);return`${e(`serverManagement.outcomeDropped`,`The connection dropped and the result could not be confirmed. The node may be restarting — re-check the version above.`)} — ${n}`}function ur({node:t}){let{t:n}=q(),a=c(),s=M(),[l,u]=o(!1),[d,f]=o(null),p=t.isHub?void 0:{nodeId:t.id},m=Ee(p,{refetchInterval:1e4,enabled:t.isOnline,retry:1}),g=m.data??null,_=r(()=>{a.invalidateQueries({queryKey:ir})},[a]),v=qe({onSettled:_}),y=Ve({onSettled:_}),b=ye({onSettled:_}),S=r(async()=>{if(g?.latestVersion==null){f({tone:`warn`,text:n(`serverManagement.outcomeNoTarget`,`No target version is known for this node — run "Check for update" first.`)});return}if(await s({title:n(`serverManagement.confirmUpdateTitle`,`Update node root package`),message:n(`serverManagement.confirmUpdateBody`,`Install {{pkg}}@{{version}} on "{{node}}" and restart to apply.`,{pkg:g.packageName,version:g.latestVersion,node:t.name}),confirmLabel:n(`serverManagement.confirmUpdateAction`,`Update & restart`)})){f(null);try{let e=await y.mutateAsync({version:g.latestVersion,...p});f({tone:cr(e),text:e.message}),e.restarting&&u(!0)}catch(e){f({tone:`warn`,text:lr(n,e)})}}},[y,s,t.name,p,g,n]),C=r(async()=>{if(await s({title:n(`serverManagement.confirmRestartTitle`,`Restart node`),message:n(`serverManagement.confirmRestartBody`,`Restart "{{node}}"? In-flight requests to this node are dropped.`,{node:t.name}),confirmLabel:n(`serverManagement.confirmRestartAction`,`Restart`),variant:`warning`})){f(null);try{let e=await b.mutateAsync(p);f({tone:cr(e),text:e.message}),e.restarting&&u(!0)}catch(e){f({tone:`warn`,text:lr(n,e)})}}},[s,t.name,b,p,n]),w=()=>{switch(g?.bootMode){case`data-root`:return{label:n(`serverManagement.bootDataRoot`,`runtime-updatable`),tone:`ok`};case`workspace`:return{label:n(`serverManagement.bootWorkspace`,`dev workspace`),tone:`info`};default:return{label:n(`serverManagement.bootBaked`,`baked image seed`),tone:`neutral`}}},T=()=>{if(g==null)return null;switch(g.updateState){case`checking`:return{label:n(`serverManagement.stateChecking`,`checking…`),tone:`info`};case`staging`:return{label:n(`serverManagement.stateStaging`,`updating…`),tone:`info`};case`pending-restart`:return{label:n(`serverManagement.statePending`,`restart pending`),tone:`warn`};default:return g.restartRequired===!0?{label:n(`serverManagement.stateRestartRequired`,`restart required`),tone:`warn`}:g.updateAvailable?{label:n(`serverManagement.stateUpdateAvailable`,`update available`),tone:`warn`}:{label:n(`serverManagement.stateUpToDate`,`up to date`),tone:`ok`}}},E=g?.bootMode===`workspace`,D=t.isOnline&&g!=null&&!E&&g.updateAvailable&&g.updateState===`idle`&&!y.isPending,k=t.isOnline&&g!=null&&g.updateState===`idle`&&!b.isPending,j=t.isOnline?T():null;return e(`div`,{className:`space-y-4 py-2`,children:[e(`div`,{className:`flex items-center justify-between gap-3`,children:[e(`div`,{className:`flex items-center gap-2 min-w-0`,children:[i(`span`,{className:`font-mono text-xs text-foreground-subtle truncate`,children:g?.packageName??t.rootPackage?.name??`@camstack/server`}),t.isOnline&&g!=null&&i(ar,{...w()})]}),j!=null&&i(ar,{...j})]}),!t.isOnline&&i($,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:t.rootPackage?.version??null}),t.isOnline&&m.isLoading&&e(`div`,{className:`flex items-center gap-2 text-sm text-foreground-subtle`,children:[i(A,{className:`h-4 w-4 animate-spin`}),n(`common.loading`,`Loading…`)]}),t.isOnline&&m.isError&&e(`div`,{className:`space-y-1.5`,children:[i(`p`,{className:`text-sm text-danger`,children:n(`serverManagement.loadError`,`Could not load the node root-package status.`)}),t.rootPackage!=null&&i($,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:t.rootPackage.version})]}),t.isOnline&&g!=null&&e(`div`,{className:`space-y-1.5`,children:[i(or,{runningVersion:g.runningVersion,latestVersion:g.latestVersion,seedVersion:g.seedVersion,nodeRuntimeVersion:g.nodeRuntimeVersion,labelRunning:n(`serverManagement.runningVersionShort`,`Running`),labelLatest:n(`serverManagement.latestVersionShort`,`Latest`),labelSeed:n(`serverManagement.imageSeedShort`,`Seed`),labelRuntime:n(`serverManagement.nodeRuntimeVersionShort`,`Node.js`)}),g.desktopApp!=null&&i(rr,{desktopApp:g.desktopApp,nodeName:t.name,routingInput:p,onSettled:_}),g.pendingVersion!=null&&i($,{label:n(`serverManagement.pendingVersion`,`Staged (applies on restart)`),value:g.pendingVersion}),g.installedVersion!=null&&g.installedVersion!==g.runningVersion&&i($,{label:n(`serverManagement.installedVersion`,`Installed on disk (runs after restart)`),value:g.installedVersion})]}),t.isOnline&&g?.imageContract?.state===`behind-series`&&e(`div`,{className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs leading-relaxed text-danger`,children:[i(`p`,{className:`mb-0.5 font-semibold`,children:n(`serverManagement.imageContractDiverged`,`Container image diverges from the deployment contract`)}),i(`p`,{children:g.imageContract.message})]}),t.isOnline&&E&&i(`p`,{className:`text-xs text-foreground-subtle`,children:n(`serverManagement.workspaceNote`,`Development workspace detected — runtime updates are disabled (the dev loop resolves code from the workspace).`)}),d!=null&&i(`p`,{role:`status`,className:`rounded border px-2 py-1.5 text-xs leading-relaxed ${sr[d.tone]}`,children:d.text}),l&&e(`div`,{className:`flex items-center gap-2 text-sm text-warning`,children:[i(A,{className:`h-4 w-4 animate-spin`}),n(`serverManagement.nodeRestarting`,`The node is restarting to apply the change…`)]}),t.isOnline&&e(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[e(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-surface-muted disabled:opacity-50`,disabled:v.isPending||g?.updateState===`staging`,onClick:()=>v.mutate(p),children:[v.isPending?i(A,{className:`h-3.5 w-3.5 animate-spin`}):i(h,{className:`h-3.5 w-3.5`}),n(`serverManagement.checkForUpdate`,`Check for update`)]}),D&&e(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded bg-primary px-2.5 py-1.5 text-xs font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50`,onClick:()=>void S(),children:[y.isPending?i(A,{className:`h-3.5 w-3.5 animate-spin`}):i(O,{className:`h-3.5 w-3.5`}),n(`serverManagement.updateTo`,`Update to {{version}}`,{version:g?.latestVersion??``})]}),e(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-surface-muted disabled:opacity-50`,disabled:!k,onClick:()=>void C(),children:[b.isPending?i(A,{className:`h-3.5 w-3.5 animate-spin`}):i(x,{className:`h-3.5 w-3.5`}),n(`serverManagement.restart`,`Restart`)]})]}),t.isOnline&&g?.lastCheckedAtMs!=null&&e(`p`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(re,{className:`h-3 w-3`}),n(`serverManagement.lastChecked`,`Last checked: {{when}}`,{when:new Date(g.lastCheckedAtMs).toLocaleString()})]})]})}s();function dr(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=Reflect.get(e,`reachableHost`);return typeof t==`string`&&t.length>0?t:null}function fr({node:t}){let{t:a}=q(),s=C(),u=c(),d=M(),[f,p]=o(!1),[m,h]=o(`info`),[g,v]=o(!1),[y,b]=o(null),x=t.processes??[],S=t.addons.map(e=>e.id),w=we(void 0),T=n(()=>{let e=w.data?.find(e=>e.nodeId===t.id);return dr(e?.settings)},[w.data,t.id]),[D,O]=o(!1),[k,A]=o(null),[N,P]=o(null),F=r(async()=>{if(D||t.isHub)return;let e=Pt(t.localIps??[],T);if(e===null){A(`No LAN IPv4 on this node — open its :4444 URL by hand.`),P(null);return}let n=Lt();O(!0),A(null),P(null);try{let r=At(await s.trpcClient.addons.custom.mutate({addonId:`system-config`,action:`mintAgentUiUnlockTicket`,input:{nodeId:t.id,dashboardBaseUrl:Ft(e)}})),i=r===null?null:r.dashboardUrl??It(e,r.ticket);if(i===null){n?.close(),A(`Hub did not return an unlock ticket.`);return}Rt(n,i)||(P(i),A(`Browser blocked the new tab — click the link below (or allow popups for this site).`))}catch(e){n?.close(),A(e instanceof Error?e.message:String(e))}finally{O(!1)}},[t.id,t.isHub,t.localIps,D,T,s.trpcClient]),I=async()=>{if(!g){v(!0),b(null);try{await s.trpcClient.pipelineOrchestrator.removeAgentSettings.mutate({agentNodeId:t.id}).catch(()=>void 0);let e=await s.trpcClient.clusterNodes.forgetNode.mutate({nodeId:t.id});b({tone:e.stillListed?`warn`:`ok`,text:e.message}),e.stillListed||u.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}catch(e){b({tone:`warn`,text:a(`cluster.nodeCard.forgetFailed`,{error:e instanceof Error?e.message:String(e)})})}finally{v(!1)}}},L=async()=>{if(!f&&await d({title:a(`cluster.nodeCard.unpair`,`Unpair {{name}}`,{name:t.name}),message:a(`cluster.nodeCard.unpairItDisconnectsAndMust`,`Unpair {{name}}? It disconnects and must be paired again.`,{name:t.name}),confirmLabel:a(`cluster.nodeCard.unpair2`,`Unpair`),variant:`danger`})){p(!0),b(null);try{let e=await s.trpcClient.agentPairing.unpairAgent.mutate({nodeId:t.id});b({tone:e.agentNotified?`ok`:`warn`,text:`${e.nodeId}: ${e.next}${e.agentNotified?``:` The agent could not be told; forget the hub on its own page.`}`}),u.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}catch(e){b({tone:`warn`,text:a(`cluster.nodeCard.unpairFailed`,{error:e instanceof Error?e.message:String(e)})})}finally{p(!1)}}},R=t.isHub?null:e(G,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void L(),disabled:f,title:a(`cluster.nodeCard.unpairThisNodeRevokesIts`,`Unpair this node — revokes its certificates; it must be paired again to rejoin`),children:[i(ae,{className:`h-3 w-3`,"aria-hidden":!0}),f?a(`cluster.nodeCard.unpairing`,`Unpairing…`):a(`cluster.nodeCard.unpair2`,`Unpair`)]});return t.isOnline?e(`div`,{className:`border border-border rounded-xl`,children:[e(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 bg-muted/30 border-b border-border rounded-t-xl`,children:[e(`div`,{className:`flex min-w-0 flex-1 basis-full items-center gap-x-2 gap-y-1 sm:basis-auto sm:flex-initial`,children:[i(`div`,{className:`w-2.5 h-2.5 rounded-full bg-success shrink-0`}),i(zt,{node:t}),e(`span`,{className:`text-xs text-muted-foreground min-w-0 truncate`,children:[t.cpuModel??t.platform,` ·`,` `,t.memoryMB>0?a(`cluster.nodeCard.gb`,`{{value1}}GB`,{value1:Math.round(t.memoryMB/1024)}):``,` `,`· `,t.arch]})]}),t.engines.map(e=>i(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium shrink-0`,title:a(`cluster.nodeInfoTab.installedRuntimesHint`,`Inference runtimes installed on this node. Its live inference devices are on Pipeline → Load balancing.`),children:e},e)),e(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-x-3 gap-y-1 text-xs text-muted-foreground w-full sm:ml-auto sm:w-auto`,children:[!t.isHub&&e(`button`,{type:`button`,onClick:()=>void F(),disabled:D,title:a(`cluster.nodeCard.openThisAgentSStatus`,`Open this agent's status dashboard (unlocks with a short-lived hub ticket)`),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[i(j,{className:`h-3 w-3`}),D?a(`cluster.nodeCard.opening`,`Opening…`):a(`cluster.nodeCard.openDashboard`,`Open dashboard`)]}),R,e(`span`,{className:`flex items-center gap-1`,children:[i(E,{className:`h-3 w-3`}),` `,t.cpuPercent,`%`]}),e(`span`,{className:`flex items-center gap-1`,children:[i(ie,{className:`h-3 w-3`}),` `,t.memoryPercent===null?a(`cluster.memoryUnknown`):`${t.memoryPercent}%`]})]})]}),y!=null&&i(`p`,{role:`status`,className:`px-4 pt-2 text-xs ${y.tone===`ok`?`text-success`:`text-warning`}`,children:y.text}),(k!==null||N!==null)&&e(`p`,{role:`status`,className:`px-4 pt-2 text-xs text-warning`,children:[k,N!==null&&e(l,{children:[` `,i(`a`,{href:N,target:`_blank`,rel:`noreferrer`,className:`underline text-foreground`,children:a(`cluster.nodeCard.openDashboard`,`Open dashboard`)})]})]}),i(`div`,{className:`sticky top-0 z-20 flex border-b border-border px-4 bg-background overflow-x-auto`,children:[`info`,`forks`,`processes`,`load`,`settings`,`capabilities`].map(e=>i(`button`,{onClick:()=>h(e),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${m===e?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:e===`info`?a(`cluster.nodeCard.general`,`General`):e===`forks`?a(`cluster.nodeCard.forks`,`Forks ({{length}})`,{length:x.length}):e===`processes`?a(`cluster.nodeCard.processes`,`Processes`):e===`load`?a(`cluster.nodeCard.load`,`Load`):e===`settings`?a(`cluster.nodeCard.settings`,`Settings`):a(`cluster.nodeCard.capabilities`,`Capabilities`)},e))}),e(`div`,{className:`px-4 py-2`,children:[m===`info`&&e(`div`,{className:`space-y-3`,children:[i(Xn,{nodeId:t.id,name:t.name,hostname:t.hostname,platform:t.platform,arch:t.arch,cpuModel:t.cpuModel,cpuCores:t.cpuCores,memoryMB:t.memoryMB,engines:t.engines,isHub:t.isHub,uptime:t.uptime,localIps:t.localIps,rootPackage:t.rootPackage}),i(er,{nodeId:t.id,detectedHosts:t.localIps??[]}),i(`div`,{className:`border-t border-border pt-1`,children:i(ur,{node:{id:t.id,name:t.name,isHub:t.isHub,isOnline:t.isOnline,rootPackage:t.rootPackage??null}})})]}),m===`forks`&&i(Wt,{nodeId:t.id,processes:x}),m===`processes`&&i(Jt,{nodeId:t.id}),m===`load`&&i(Un,{nodeId:t.id,isHub:t.isHub}),m===`settings`&&i(qn,{nodeId:t.id,addonIds:S}),m===`capabilities`&&i(Jn,{nodeId:t.id,addons:t.addons})]})]}):e(`div`,{className:`border border-border rounded-xl overflow-hidden opacity-60`,children:[e(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 bg-muted/30`,children:[i(`div`,{className:`w-2.5 h-2.5 rounded-full bg-destructive shrink-0`}),i(zt,{node:t}),e(`span`,{className:`text-xs text-muted-foreground min-w-0 truncate`,children:[t.cpuModel??t.platform,` ·`,` `,t.memoryMB>0?a(`cluster.nodeCard.gb`,`{{value1}}GB`,{value1:Math.round(t.memoryMB/1024)}):``,` `,`· `,t.arch]}),t.engines.map(e=>i(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium`,title:a(`cluster.nodeInfoTab.installedRuntimesHint`,`Inference runtimes installed on this node. Its live inference devices are on Pipeline → Load balancing.`),children:e},e)),t.rootPackage&&e(`span`,{className:`text-[10px] font-mono px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:[t.rootPackage.name,`@`,t.rootPackage.version]}),i(`span`,{className:`ml-auto text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:a(`common.offline`)})]}),e(`div`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[e(`span`,{className:`text-xs text-muted-foreground`,children:[t.lastSeen?i(`span`,{className:`mr-1`,children:a(`cluster.nodeCard.lastSeen`,{when:new Date(t.lastSeen).toLocaleString()})}):null,a(`cluster.nodeCard.addonsAssigned`,{count:t.addons.length})]}),e(`div`,{className:`flex shrink-0 items-center gap-2`,children:[R,e(`button`,{type:`button`,onClick:()=>void I(),disabled:g,title:a(`cluster.nodeCard.forgetThisNodeRemovesIts`,`Forget this node — removes its saved history and pipeline assignments`),className:`flex items-center gap-1 text-xs px-2 py-1 rounded-md border border-border text-muted-foreground hover:text-destructive hover:border-destructive/50 disabled:opacity-50 transition-colors`,children:[i(_,{className:`h-3 w-3`}),g?a(`cluster.nodeCard.forgetting`,`Forgetting…`):a(`cluster.nodeCard.forgetNode`,`Forget node`)]})]})]}),y!=null&&i(`p`,{role:`status`,className:`px-4 pb-3 text-xs leading-relaxed ${y.tone===`ok`?`text-success`:`text-warning`}`,children:y.text})]})}var pr=3,mr=7e3;function hr(e){return[...e].sort((e,t)=>e.isHub===t.isHub?0:e.isHub?1:-1)}function gr(e){return e.isHub?{}:{nodeId:e.id}}function _r(e){return e.updateState===`staging`||e.updateState===`pending-restart`||e.pendingVersion!==null?!0:!e.updateAvailable}async function vr(e,t){let n=gr(e),r=K.t(`helpers.clusterUpdateAll.noAnswer`);for(let i=1;i<=pr;i+=1)try{let r=await t.readStatus(n);return _r(r)?{nodeId:e.id,nodeName:e.name,outcome:`applied`,detail:K.t(`helpers.clusterUpdateAll.landed`,{state:r.updateState,version:r.runningVersion??K.t(`helpers.clusterUpdateAll.unknown`)})}:{nodeId:e.id,nodeName:e.name,outcome:`failed`,detail:K.t(`helpers.clusterUpdateAll.unchanged`,{version:r.runningVersion??K.t(`helpers.clusterUpdateAll.unknown`)})}}catch(e){r=e instanceof Error?e.message:String(e),i<pr&&await t.wait(mr)}return{nodeId:e.id,nodeName:e.name,outcome:`unconfirmed`,detail:K.t(`helpers.clusterUpdateAll.unconfirmed`,{attempts:pr,error:r})}}function yr(e){return e.accepted?`applied`:e.outcome===`failed`?`failed`:`refused`}async function br(e,t){let n=[];for(let r of hr(e))try{let e=await t.apply(gr(r));n.push({nodeId:r.id,nodeName:r.name,outcome:yr(e),detail:e.message})}catch{n.push(await vr(r,t))}return n}s();function xr(){let{nodes:e,isLoading:t}=Ce(),r=n(()=>e??[],[e]);return{nodes:r,isLoading:t&&r.length===0}}var Sr={applied:`border-success/40 bg-success/10 text-success`,refused:`border-warning/40 bg-warning/10 text-warning`,failed:`border-danger/40 bg-danger/10 text-danger`,unconfirmed:`border-warning/40 bg-warning/10 text-warning`};function Cr(){let{t}=q(),s=M(),{nodes:c,isLoading:u}=xr(),[d,f]=Je(),{selection:p,selectNode:m}=it(c),h=p.node,g=n(()=>c.filter(e=>e.isOnline),[c]),_=g.length,v=c.filter(e=>!e.isOnline).length,b=Ve(),x=C(),[S,w]=o(!1),[T,E]=o([]),D=d.get(`unlockNode`),k=d.get(`returnTo`),[j,N]=o(null);a(()=>{if(D===null||k===null)return;let e=!1;return(async()=>{try{let t=await x.trpcClient.addons.custom.mutate({addonId:`system-config`,action:`mintAgentUiUnlockTicket`,input:{nodeId:D,dashboardBaseUrl:k}});if(e)return;let n=At(t),r=n===null?null:n.dashboardUrl??(()=>{let e=new URL(k);return e.searchParams.set(`ticket`,n.ticket),e.toString()})();if(r===null){N(`Could not mint an unlock ticket.`);return}let i=new URLSearchParams(d);i.delete(`unlockNode`),i.delete(`returnTo`),f(i,{replace:!0}),window.location.assign(r)}catch(t){e||N(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[D,k,d,f,x.trpcClient]);let P=r(async()=>{let e=g.map(e=>({id:e.id,name:e.name,isHub:e.isHub}));if(await s({title:t(`serverManagement.confirmUpdateAllTitle`,`Update all nodes`),message:t(`serverManagement.confirmUpdateAllBody`,`Update and restart every online node, agents first, hub last. Up-to-date nodes are skipped; this page reconnects when the hub comes back.`),confirmLabel:t(`serverManagement.confirmUpdateAllAction`,`Update all & restart`),variant:`warning`})){w(!0),E([]);try{E(await br(e,{apply:e=>b.mutateAsync(e),readStatus:e=>x.trpcClient.serverManagement.getServerPackageStatus.query(e),wait:e=>new Promise(t=>setTimeout(t,e))}))}finally{w(!1)}}},[b,s,g,x,t]);return e(Ze,{icon:y,title:t(`nav.nodes`,`Nodes`),subtitle:t(`cluster.subtitle`,`One node at a time — topology and packages. Agents join by pairing (certificate, no shared secret).`),actions:e(l,{children:[_>0&&i(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-xs text-success`,children:t(`common.onlineCount`,{count:_})}),v>0&&i(`span`,{className:`rounded-full bg-destructive/10 px-2 py-0.5 text-xs text-destructive`,children:t(`common.offlineCount`,{count:v})}),_>1&&e(G,{type:`button`,size:`sm`,disabled:S,title:t(`serverManagement.updateAllHint`,`Sequenced agents-first, hub-last — up-to-date nodes are skipped.`),onClick:()=>void P(),children:[S?i(A,{className:`h-3.5 w-3.5 animate-spin`}):i(O,{className:`h-3.5 w-3.5`}),t(`serverManagement.updateAll`,`Update all nodes`)]})]}),children:[T.length>0&&i(`ul`,{"aria-label":`update-all-report`,className:`flex flex-col gap-1 text-xs`,children:T.map(t=>e(`li`,{"data-outcome":t.outcome,className:`rounded border px-2 py-1 ${Sr[t.outcome]}`,children:[i(`span`,{className:`font-medium`,children:t.nodeName}),i(`span`,{className:`mx-1 uppercase tracking-wide`,children:t.outcome}),i(`span`,{className:`opacity-80`,children:t.detail})]},t.nodeId))}),j!==null&&e(`p`,{role:`alert`,className:`rounded border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning`,children:[t(`system.cluster.unlockFromAgentFailed`,`Unlock from agent failed:`),` `,j]}),i(Ot,{onOpenNode:m}),u?i(`div`,{className:`flex items-center justify-center py-12 text-muted-foreground`,children:t(`system.cluster.loadingClusterTopology`,`Loading cluster topology...`)}):h===null?i(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-xs text-foreground-subtle`,children:t(`cluster.noNodes`,`No nodes in this cluster yet.`)}):e(`div`,{className:`flex flex-col gap-3`,children:[i(rt,{staleNodeId:p.staleNodeId,shownNodeName:h.name}),i(ce,{selectedNodeId:h.id,onSelect:m,allowOffline:!0,alwaysShow:!0}),i(fr,{node:h})]})]})}export{Cr as ClusterPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,S as t}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{ji as n}from"./client-r4i0EpF6.js";import{t as r}from"./boxes-BwEV9Act.js";import{qa as i,ri as a}from"./src-nnHXOip7.js";import{t as o}from"./useTranslation-BJr-n0es.js";import{f as s,gr as c,hr as l,m as u,vr as d,yr as f}from"./index-Ohn-2iW_.js";import{t as p}from"./CompositionBlockEditor-BXYXXUEU.js";import{t as m}from"./AdminPage-7avIuDBh.js";var h=`rounded-lg border border-border bg-surface p-4`,g=`new`;function _(){let{blockId:_}=f(),{t:v}=o(),y=d(),b=_===void 0||_===g,x=i({blockId:_??``},{enabled:!b}),S=e=>t(m,{icon:r,title:v(`compositionEditor.pageTitle`),children:e});if(b)return t(c,{to:`${s}&new=helper`,replace:!0});if(x.status===`success`&&x.data.state===`loaded`&&x.data.view!==null){let e=x.data.view;if(n(e.block)?.target.kind===`existing`){let n=e.state.kind===`answered`?e.state.state?.deviceId??null:null;if(n!==null)return S(t(`section`,{className:h,children:t(l,{className:`text-primary text-sm`,to:u(n),children:v(`compositionEditor.openOnDevice`)})}))}}return S(e(`section`,{className:`${h} flex flex-col gap-2`,children:[t(a,{variant:`ghost`,size:`sm`,onClick:()=>y(s),children:v(`compositionEditor.cancel`)}),t(p,{blockId:_??``})]}))}export{_ as CompositionEditorPage};
|
|
@@ -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{$i as l,D as u,Di as d,Hn as f,Ht as p,In as m,Ln as h,Q as g,Qr as _,Tn as v,ai as y,dr as b,hi as x,ia as S,ki as C,ni as w,pi as T,pr as E,ra as D,st as O,ur as k,vn as A,xi as j,zt as M}from"./player-overlays-Cw_gjG75.js";import{n as N,t as P}from"./cloud-upload-BII8r4p9.js";import{t as F}from"./circle-slash-BjzSCz4-.js";import{t as I}from"./hard-drive-download-Dym9jihx.js";import{An as L,Ca as ee,Cr as te,Cu as R,Ea as z,Et as B,Eu as ne,Jn as re,Kn as ie,Nd as ae,Nr as oe,Pr as se,Rd as ce,Sa as le,Ta as ue,Tr as de,Tu as fe,Yi as pe,Yn as me,Zn as he,_a as ge,_t as _e,ba as ve,bo as ye,br as be,da as xe,fa as Se,ga as Ce,ha as we,jn as Te,ma as Ee,mt as De,ou as Oe,pa as ke,ri as V,va as Ae,vt as je,wa as Me,wr as Ne,wu as Pe,xa as Fe,xr as Ie,ya as H,yr as Le,yt as Re,zd as U,zu as ze}from"./src-nnHXOip7.js";import{t as W}from"./i18n-BE1bPZOs.js";import{t as G}from"./useTranslation-BJr-n0es.js";import"./mount-B_Zjyqyk.js";import{T as Be,br as Ve,gr as He,mr as Ue}from"./index-Ohn-2iW_.js";import{t as We}from"./AdminSectionedPage-Bd2owMGm.js";import{t as Ge}from"./AdminPage-7avIuDBh.js";import{n as Ke}from"./authed-media-CdbbdgDZ.js";import{t as K}from"./format-size-DIxKXxtj.js";import{a as qe,c as Je,l as Ye,n as Xe,o as Ze,s as Qe,t as $e,u as et}from"./location-owned-usage-DOmOvdiG.js";o();function tt(){let{t:n}=G(),a=s(),o=O(),{data:c,isLoading:l,isError:u}=ne({}),d=fe(),f=t(()=>d.data??[],[d.data]),{data:p}=Oe({},{refetchOnWindowFocus:!1}),m=t(()=>$e(c??[],p?.locations),[c,p?.locations]),{data:h}=Pe({},{refetchOnWindowFocus:!1}),g=t(()=>qe(h),[h]),{state:_,openNew:v,openEdit:y,close:b}=_e(),[x,S]=je(`type`),C=()=>{S(null),b()},w=e=>{S(e),v()},T=e=>{S(null),y(e.id)},E=c??[],D=_.mode===`edit`?E.find(e=>e.id===_.id)??null:null;i(()=>{_.mode===`new`&&(x===null||x===``)&&(S(null),b())},[_.mode,x,b,S]),i(()=>{_.mode===`edit`&&!l&&D===null&&(S(null),b())},[_.mode,l,D,b,S]),i(()=>{_.mode===`closed`&&x!==null&&S(null)},[_.mode,x,S]);let k=R({onSuccess:()=>{a.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),A=ze({onSuccess:()=>{a.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),j=async(e,t)=>{Ye(t)&&!await o({title:n(`system.storage.disable`,`Disable "{{displayName}}"?`,{displayName:e.displayName}),message:n(`system.storage.nothingIsDeletedSetThe`,`{{consequence}} Nothing is deleted — set the location back to Read-only or Active to bring its footage back.`,{consequence:Je(t).consequence}),confirmLabel:n(`common.disable`,`Disable`),variant:`danger`})||A.mutate(Qe(e,{mode:t}))},M=async e=>{if(await o({title:n(`system.storage.deleteLocation`,`Delete location "{{displayName}}"?`,{displayName:e.displayName}),message:n(`system.storage.thisRemovesTheLocationRecord`,`This removes the location record. Files on disk are not deleted; the underlying directory or remote path stays untouched.`),confirmLabel:n(`common.delete`,`Delete`),variant:`danger`}))try{await k.mutateAsync({id:e.id}),_.mode===`edit`&&_.id===e.id&&C()}catch(t){await o({title:n(`system.storage.deleteAnyway`,`Delete anyway?`),message:n(`system.storage.forcingNote`,{error:t instanceof Error?t.message:String(t)}),confirmLabel:n(`system.storage.forceDelete`,`Force delete`),variant:`danger`})&&k.mutate({id:e.id,force:!0},{onSuccess:()=>{_.mode===`edit`&&_.id===e.id&&C()}})}},N=t(()=>{let e=new Map;for(let t of c??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[c]),P=l||d.isLoading,F=u||d.isError,I=_.mode===`new`&&x!==null&&x!==``,L=_.mode===`edit`&&D!==null;return e(Ge,{embedded:!0,children:[P&&r(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:n(`system.storage.loadingLocations`,`Loading locations…`)}),F&&r(`div`,{className:`text-xs text-danger`,children:n(`system.storage.failedToLoadStorageLocations`,`Failed to load storage locations.`)}),!P&&!F&&e(`div`,{className:`space-y-3`,children:[f.length===0&&r(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-4 text-center text-[11px] text-foreground-subtle italic`,children:n(`system.storage.noStorageLocationsDeclaredBy`,`No storage locations declared by any installed addon.`)}),f.map(e=>r(Xe,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:N.get(e.id)??[],onAdd:w,onEdit:T,onDelete:e=>{M(e)},ownedBytesById:m,drainById:g,onSetMode:(e,t)=>{j(e,t)}},e.id))]}),I&&x!==null&&r(et,{initialType:x,onClose:C,onCreated:()=>{a.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),C()}}),L&&D!==null&&r(Ze,{location:D,onClose:C,onSaved:()=>{a.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),C()}})]})}var q={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`}},nt=Object.keys(q),J=[`settings`];function rt(){return W.t(`helpers.backupDatabases.notCreated`)}function it(e){return W.t(q[e].labelKey)}function at(e){return W.t(q[e].shortKey)}function ot(e){return W.t(q[e].descriptionKey)}function Y(e){let t=new Set(e);return nt.filter(e=>t.has(e))}function X(e){return e!==void 0&&e.length>0?Y(e):J}function st(e){return Y(e)}function ct(e,t){return t===void 0||!t.answered?`unknown`:t.databases.includes(e)?`present`:`absent`}function lt(e,t,n){return ct(e,t)===`absent`&&!n.has(e)}function ut(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function dt(e){return!e.includes(`settings`)}function ft(e){return{databases:[...st(e)]}}function pt(e,t){return e!==void 0&&e.length>0?Y(e):t!==void 0&&t.length>0?Y(t.map(e=>e.databaseId??`settings`)):J}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=>at(e)).join(` · `)})}o();var mt=[[`backup`,`listDestinations`]],ht=[`backup`,`listArchives`];function gt({destinationId:i,restoreSupported:o,onOpenRestoreWizard:c}){let{t:l}=G(),u=s(),d=O(),{data:f,isLoading:m,isError:h}=ge({destinationId:i}),g=f??[],y=Se({onSuccess:()=>{u.invalidateQueries({queryKey:[[...ht]]}),u.invalidateQueries({queryKey:mt})}}),b=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:K(e.sizeBytes)}),confirmLabel:l(`common.delete`,`Delete`),variant:`danger`})&&y.mutate({destinationId:i,backupId:e.id})},[d,i,y,l]),[x,S]=a(null),C=n(async e=>{S(e.id);try{let t=await Ke(_t(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{S(null)}},[i]),w=t(()=>[...g].toSorted((e,t)=>t.createdAt-e.createdAt),[g]);return m?r(`div`,{className:`text-xs text-foreground-subtle animate-pulse py-2`,children:l(`backup.archiveList.loadingArchives`,`Loading archives…`)}):h?r(`div`,{className:`text-xs text-danger py-2`,children:l(`backup.archiveList.failedToReadManifestFor`,`Failed to read manifest for this destination`)}):w.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(L,{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(k,{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:X(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:K(e.sizeBytes)})},{key:`actions`,header:``,align:`right`,notSortableReason:`Actions`,render:t=>e(`span`,{className:`flex items-center justify-end gap-1`,children:[e(V,{variant:`ghost`,size:`sm`,onClick:()=>{C(t)},disabled:x===t.id,title:l(`backup.archiveList.downloadArchive`,`Download archive`),children:[x===t.id?r(E,{className:`h-3 w-3 animate-spin`}):r(_,{className:`h-3 w-3`}),l(`backup.archiveList.download`,`Download`)]}),o&&c&&e(V,{variant:`ghost`,size:`sm`,onClick:()=>c({destinationId:i,archiveId:t.id}),title:l(`backup.archiveList.restoreFromThisArchive`,`Restore from this archive`),children:[r(v,{className:`h-3 w-3`}),l(`backup.archiveList.restore`,`Restore`)]}),r(U,{variant:`ghost`,size:`sm`,icon:p,"aria-label":l(`backup.archiveList.delete`,`Delete {{value1}}`,{value1:t.label??t.id}),disabled:y.isPending,onClick:()=>{b(t)}})]})}],rows:w,rowKey:e=>e.id,minWidthPx:760,emptyMessage:l(`backup.archiveList.noArchivesAtThisDestination`,`No archives at this destination yet.`)})}function _t(e,t){return g(`/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 yt=[[`backup`,`listSchedules`]];function bt({onEdit:i,onOpenRestoreWizard:o}){let{t:s}=G(),{data:c,isLoading:l,isError:u,error:d,refetch:f}=Fe(),p=c??[],m=H().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(()=>xt({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(E,{className:`h-3.5 w-3.5 animate-spin`}),s(`backup.backupEntriesTable.loadingBackupEntries`,`Loading backup entries…`)]}):u?r(oe,{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(se,{icon:N,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(L,{columns:y,rows:p,rowKey:e=>e.id,minWidthPx:980,maxBodyHeight:Te,emptyMessage:s(`backup.backupEntriesTable.noBackupEntriesYet`,`No backup entries yet`),onRowClick:e=>i(e),isExpanded:e=>e.id===g,renderExpanded:e=>r(Ot,{row:e,destById:h,...o?{onOpenRestoreWizard:o}:{}})})}function xt(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?C:d,"aria-label":n?W.t(`backup.backupEntriesTable.hideArchives`,`Hide archives`):W.t(`backup.backupEntriesTable.showArchives`,`Show archives`),"aria-expanded":n,onClick:n=>{n.stopPropagation(),t.onToggleExpand(e.id)}})}},{key:`entry`,header:W.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||W.t(`backup.backupEntriesTable.unnamed`,`(unnamed)`)}),t.lastRunAt!==void 0&&r(`span`,{className:`text-[10px] text-foreground-subtle`,children:W.t(`backup.backupEntriesTable.lastRun`,{when:new Date(t.lastRunAt).toLocaleString()})})]})},{key:`enabled`,header:W.t(`backup.backupEntriesTable.enabled`,`Enabled`),width:`w-20`,nowrap:!0,sortValue:e=>+!!e.enabled,render:e=>r(`span`,{onClick:e=>e.stopPropagation(),children:r(Tt,{row:e})})},{key:`databases`,header:W.t(`backup.backupEntriesTable.backsUp`,`Backs up`),nowrap:!1,notSortableReason:`Database badges`,render:e=>r(Z,{databases:X(e.databases)})},{key:`locations`,header:W.t(`backup.backupEntriesTable.locations`,`Locations`),nowrap:!1,notSortableReason:`Location chips`,render:e=>r(St,{row:e,destById:t.destById})},{key:`retention`,header:W.t(`backup.backupEntriesTable.retention`,`Retention`),width:`w-24`,nowrap:!0,sortValue:e=>e.retentionCount,render:e=>r(`span`,{onClick:e=>e.stopPropagation(),children:r(Et,{row:e})})},{key:`schedule`,header:W.t(`backup.backupEntriesTable.schedule`,`Schedule`),width:`w-48`,nowrap:!0,sortValue:e=>e.cron,render:e=>r(Ct,{row:e})},{key:`actions`,header:``,align:`right`,nowrap:!0,notSortableReason:`Actions`,render:e=>r(`span`,{onClick:e=>e.stopPropagation(),children:r(Dt,{row:e,onEdit:()=>t.onEdit(e)})})}]}function St({row:e,destById:t}){let{t:n}=G();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 Ct({row:t}){let{t:n}=G(),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(N,{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:W.t(`common.nextRun`,{when:new Date(t.nextRunAt).toLocaleString()})})]})}function wt(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 Tt({row:e}){let{t}=G(),n=s(),i=z({onSuccess:()=>{n.invalidateQueries({queryKey:yt})}}),a=wt(e);return r(`label`,{className:`inline-flex cursor-pointer items-center`,children:r(`input`,{type:`checkbox`,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 Et({row:e}){let{t}=G(),n=s(),o=z({onSuccess:()=>{n.invalidateQueries({queryKey:yt})}}),c=wt(e),[l,u]=a(String(e.retentionCount));return i(()=>{u(String(e.retentionCount))},[e.retentionCount]),r(ce,{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 Dt({row:t,onEdit:n}){let{t:i}=G(),a=s(),o=O(),c=ke({onSuccess:()=>{a.invalidateQueries({queryKey:yt})}}),l=ue({onMutate:()=>{a.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})},onSuccess:()=>{a.invalidateQueries({queryKey:[[`backup`,`listArchives`]]}),a.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]}),a.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})}}),u=()=>{t.locationIds.length!==0&&l.mutate({destinations:[...t.locationIds],...t.dataSources&&t.dataSources.length>0?{locations:[...t.dataSources]}:{},label:t.label,retentionCount:t.retentionCount,databases:[...X(t.databases)]})},d=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(V,{size:`sm`,type:`button`,onClick:u,disabled:l.isPending||t.locationIds.length===0,title:i(`backup.backupEntriesTable.runThisEntryNow`,`Run this entry now`),children:[l.isPending?r(E,{className:`h-3 w-3 animate-spin`}):r(h,{className:`h-3 w-3`}),i(`backup.backupEntriesTable.runNow`,`Run now`)]}),r(U,{variant:`ghost`,size:`sm`,icon:f,"aria-label":i(`backup.backupEntriesTable.edit`,`Edit {{value1}}`,{value1:t.label||t.id}),onClick:n}),r(U,{variant:`ghost`,size:`sm`,icon:p,"aria-label":i(`backup.backupEntriesTable.delete`,`Delete {{value1}}`,{value1:t.label||t.id}),disabled:c.isPending,onClick:()=>{d()}})]})}function Ot({row:t,destById:n,onOpenRestoreWizard:i}){let{t:a}=G();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(gt,{destinationId:t,restoreSupported:n.get(t)?.restoreSupported??!0,...i?{onOpenRestoreWizard:i}:{}})]},t))]})}function kt({selected:t,onChange:n,disabled:i=!1,testId:a=`backup-databases`}){let{t:o}=G(),s=Ae().data,c=t.size>0&&dt(Y(t)),l=t.size===0?`Pick at least one.`:c?`Snapshots only: configuration and files are not part of this backup.`:null;return r(B,{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:nt.map(o=>{let c=ct(o,s),l=i||lt(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(he,{checked:t.has(o),disabled:l,onChange:()=>n(ut(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:it(o)}),r(`span`,{className:`block text-[11px] text-foreground-subtle`,children:c===`absent`?rt():ot(o)})]})]},o)})})})}o();function At({onClose:t}){let{t:n}=G(),i=s(),[o,c]=a(new Set(J)),l=ue({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(Le,{open:!0,onOpenChange:e=>!e&&t(),children:e(Ie,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(Ne,{children:[r(de,{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(be,{children:e(`div`,{className:`p-4`,children:[r(kt,{selected:o,onChange:c,disabled:l.isPending,testId:`backup-now-databases`}),l.error&&r(`p`,{role:`alert`,className:`pt-2 text-xs text-danger`,children:l.error.message})]})}),e(te,{children:[r(V,{variant:`outline`,size:`sm`,onClick:t,children:n(`common.cancel`,`Cancel`)}),e(V,{size:`sm`,onClick:()=>{o.size!==0&&l.mutate(ft(o))},disabled:o.size===0||l.isPending,"data-testid":`backup-now-run`,children:[l.isPending?r(E,{className:`h-3.5 w-3.5 animate-spin`}):r(h,{className:`h-3.5 w-3.5`}),n(`backup.backupNowDialog.backUpNow`,`Back up now`)]})]})]})})}o();function jt(e){return e===null?`—`:new Date(e).toLocaleString()}function Mt(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 Nt({revealed:t,onDone:n}){let{t:i}=G(),[o,s]=a(!1),[c,l]=a(!1);return r(Le,{open:!0,onOpenChange:e=>!e&&o&&n(),children:e(Ie,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`border-danger/40`,"aria-labelledby":`backup-key-title`,children:[r(Ne,{children:r(de,{id:`backup-key-title`,children:i(`backup.encryptionCard.yourKey`,{keyId:t.keyId})})}),e(be,{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(M,{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(V,{size:`sm`,variant:`outline`,onClick:()=>{navigator.clipboard?.writeText(t.secretKey).then(()=>l(!0))},children:[r(y,{className:`mr-1 h-3.5 w-3.5`}),c?i(`backup.backupEncryptionCard.copied`,`Copied`):i(`common.copy`,`Copy`)]}),e(V,{size:`sm`,variant:`outline`,onClick:()=>Mt(t),children:[r(_,{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(`input`,{type:`checkbox`,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(te,{children:r(V,{size:`sm`,disabled:!o,onClick:n,children:i(`backup.backupEncryptionCard.iHaveStoredIt`,`I have stored it`)})})]})})}function Pt(){let{t}=G(),n=we(),i=Me(),o=Ee(),s=O(),[l,u]=a(null),[d,f]=a(null),p=n.data?.enabled??!1,m=n.data?.active??null,h=(n.data?.keys??[]).filter(e=>e.retiredAt!==null),g=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))}}},_=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(k,{className:`h-4 w-4 text-success`}):r(b,{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&&m!==null?t(`backup.backupEncryptionCard.onKeySince`,`On — key {{keyId}}, since {{value2}}`,{keyId:m.keyId,value2:jt(m.createdAt)}):t(`backup.backupEncryptionCard.offBackupsAreNotEncrypted`,`Off — backups are not encrypted`)})]}),r(`div`,{className:`flex gap-2`,children:p?e(c,{children:[r(V,{size:`sm`,variant:`outline`,disabled:i.isPending,onClick:()=>void g(),children:t(`backup.backupEncryptionCard.replaceKey`,`Replace key`)}),r(V,{size:`sm`,variant:`outline`,disabled:o.isPending,onClick:()=>void _(),children:t(`backup.backupEncryptionCard.turnOff`,`Turn off`)})]}):r(V,{size:`sm`,disabled:i.isPending,onClick:()=>void g(),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, config.yaml, addon data (HomeKit pairing, Matter fabric, Tailscale state) and TLS.`)}),h.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:h.map(t=>e(`li`,{children:[t.keyId,` · `,jt(t.createdAt),` → `,jt(t.retiredAt)]},t.keyId))})]}),d!==null&&r(`p`,{className:`text-xs text-danger`,children:d}),l!==null&&r(Nt,{revealed:l,onDone:()=>{u(null),n.refetch()}})]})}o();var Ft=[{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 It(e){let t=e.trim();for(let e of Ft)if(e.cron===t)return e.id;return`custom`}function Lt({value:t,onChange:n,previewCount:o=5,disabled:s=!1}){let{t:c}=G(),l=It(t),[u,d]=a(l===`custom`);i(()=>{l!==`custom`&&d(!1)},[l]);let f=Bt(t,250),p=le({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:[Ft.map(e=>r(`button`,{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(`button`,{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(`input`,{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(Ue,{i18nKey:`backup.cronEditor.formatLine`,components:{code:r(`span`,{className:`font-mono`})}})]})]}),r(Rt,{cron:f,preview:m,loading:p.isFetching})]})}function Rt({cron:t,preview:n,loading:i}){let{t:a}=G();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(E,{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:zt(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 zt(e){let t=e-Date.now();if(t<=0)return W.t(`helpers.relativeTime.now`);let n=Math.floor(t/1e3);if(n<60)return W.t(`helpers.relativeTime.inSeconds`,{count:n});let r=Math.floor(n/60);if(r<60)return W.t(`helpers.relativeTime.inMinutes`,{count:r});let i=Math.floor(r/60);if(i<24)return W.t(`helpers.relativeTime.inHours`,{count:i});let a=Math.floor(i/24);return W.t(`helpers.relativeTime.inDays`,{count:a})}function Bt(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 Vt=[[`backup`,`listSchedules`]];function Ht({entry:n,onClose:i,onSaved:o}){let{t:c}=G(),l=s(),u=H(),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)),[b,x]=a(new Set(n?.locationIds??[])),[S,C]=a(new Set(n===null?J:X(n.databases))),w=z({onSuccess:()=>{l.invalidateQueries({queryKey:Vt}),o()}}),T=e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},D=Number.parseInt(v,10),O=t(()=>f.trim().length>0&&b.size>0&&S.size>0&&!Number.isNaN(D)&&D>=1&&D<=1e3,[f,b,S,D]),k=()=>{O&&w.mutate({...n?{id:n.id}:{},label:f.trim(),cron:m.trim(),enabled:g,locationIds:Array.from(b),retentionCount:D,databases:[...st(S)]})},A=w.error instanceof Error?w.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:N,error:A,width:`lg`,testId:`backup-entry-form`,footer:e(V,{size:`sm`,type:`button`,onClick:k,disabled:!O||w.isPending,children:[w.isPending?r(E,{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(B,{label:c(`backup.backupEntryModal.name`,`Name`),required:!0,children:r(ce,{value:f,onChange:e=>p(e.target.value),placeholder:c(`backup.backupEntryModal.nightlyOffsite`,`Nightly offsite`),autoFocus:!0,"data-testid":`backup-entry-name`})}),e(B,{label:c(`backup.backupEntryModal.locationsSelected`,`Locations ({{value1}} selected)`,{value1:String(b.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(E,{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(`input`,{type:`checkbox`,checked:b.has(t.id),onChange:()=>T(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(kt,{selected:S,onChange:C,disabled:w.isPending,testId:`backup-entry-databases`}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[r(B,{label:c(`backup.backupEntryModal.retentionArchivesKept`,`Retention (archives kept)`),required:!0,children:r(ce,{type:`number`,min:1,max:1e3,value:v,onChange:e=>y(e.target.value),"data-testid":`backup-entry-retention`})}),r(B,{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(`input`,{type:`checkbox`,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(B,{label:c(`backup.backupEntryModal.schedule`,`Schedule`),children:r(Lt,{value:m,onChange:h,disabled:w.isPending})})]})})}o();var Ut=2e3,Wt=5e3;function Q(e){return e.state===`queued`||e.state===`running`}function Gt(e){if(e.state===`queued`)return{title:W.t(`backup.backupRunsPanel.cancelQueuedBackupRun`,`Cancel queued backup run?`),message:W.t(`backup.backupRunsPanel.thisRunHasNotStarted`,`This run has not started. Cancelling removes it from the queue — nothing has been written, nothing is deleted.`),confirmLabel:W.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:W.t(`backup.backupRunsPanel.stopThisBackupRun`,`Stop this backup run?`),message:W.t(`backup.backupRunsPanel.theHalfWrittenStagingArchive`,`The half-written staging archive is deleted and the destination currently uploading discards its partial copy. {{keptSentence}}`,{keptSentence:n}),confirmLabel:W.t(`backup.backupRunsPanel.stopRun`,`Stop run`),variant:`danger`}}function Kt(){let e=O(),[t,i]=a(null),o=ve(void 0,{refetchInterval:e=>(e.state.data??[]).some(Q)?Ut:Wt}),s=xe({onSettled:()=>{i(null),o.refetch()}}),c=n(async t=>{await e(Gt(t))&&(i(t.id),s.mutate({runId:t.id}))},[e,s]);return r(qt,{queryState:o.isError?`error`:o.data===void 0?`pending`:`ready`,runs:o.data??[],cancelingId:t,onCancelRequest:e=>{c(e)},now:Date.now()})}function qt({queryState:t,runs:n,cancelingId:i,onCancelRequest:a,now:o}){let{t:s}=G(),c=t===`ready`&&n.some(Q),l=n.filter(e=>e.state===`running`),u=n.filter(e=>e.state===`queued`),d=n.filter(e=>!Q(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(Jt,{run:e,canceling:i===e.id,onCancelRequest:a,now:o},e.id))})]})})]})}function Jt({run:t,canceling:n,onCancelRequest:i,now:a}){let{t:o}=G(),s=Q(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(Yt,{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(Xt,{run:t})}),r(`td`,{className:`px-3 py-2`,children:r(Zt,{run:t})}),r(`td`,{className:`px-3 py-2 text-foreground-subtle tabular-nums`,children:r(Qt,{run:t,now:a})}),r(`td`,{className:`px-3 py-2`,children:r(`div`,{className:`flex justify-end`,children:s&&e(`button`,{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(E,{className:`h-3 w-3 animate-spin`}):r(l,{className:`h-3 w-3`}),t.state===`queued`?o(`common.cancel`,`Cancel`):o(`backup.backupRunsPanel.stop`,`Stop`)]})})})]})}function Yt({run:t}){let{t:n}=G();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(T,{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(E,{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(j,{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(F,{className:`h-3 w-3`}),n(`backup.backupRunsPanel.stopped`,`Stopped`)]})}}function Xt({run:t}){let{t:n}=G();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:$t(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(I,{className:`h-3 w-3 text-primary`}),r(`span`,{className:`tabular-nums font-medium animate-pulse`,children:K(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(P,{className:`h-3 w-3 text-primary`}),e(`span`,{className:`tabular-nums font-medium`,children:[K(t.uploadedBytes),i===void 0?``:` / ${K(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:K(i)})})}function Zt({run:t}){let{t:n}=G(),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 Qt({run:t,now:n}){let{t:i}=G();return t.state===`queued`?r(`span`,{children:i(`backup.runsPanel.queuedAgo`,{elapsed:en(n-t.requestedAt)})}):t.startedAt===void 0?r(`span`,{children:`—`}):t.finishedAt===void 0?r(`span`,{children:i(`backup.runsPanel.runningFor`,{elapsed:en(n-t.startedAt)})}):e(`div`,{className:`flex flex-col gap-0.5`,children:[r(`span`,{children:tn(t.finishedAt)}),r(`span`,{className:`text-[10px]`,children:i(`backup.runsPanel.took`,{elapsed:en(t.finishedAt-t.startedAt)})})]})}function $t(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 en(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 tn(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}o();var nn=[[`backup`,`list`]];function rn({initialDestinationId:n,initialArchiveId:o,onClose:c,onScheduled:l}){let{t:u}=G(),d=s(),[f,p]=a(n&&o?2:1),[m,h]=a(n),[g,_]=a(o),[y,b]=a(new Set),[x,C]=a(``),{data:w}=H(),T=w??[],{data:O,isLoading:k}=ge({destinationId:m??``},{enabled:!!m}),A=O??[];i(()=>{if(m!==void 0)return;let e=T.filter(e=>e.restoreSupported);e.length===1&&h(e[0].id)},[m,T]);let{data:j}=Ce({destinationId:m??``,backupId:g??``},{enabled:!!m&&!!g}),M=t(()=>j?.locations??[],[j]);i(()=>{M.length!==0&&b(e=>e.size===0?new Set(M):e)},[M]);let N=ee({onSuccess:()=>{d.invalidateQueries({queryKey:nn}),l(),c()}}),P=e=>{b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},F=A.find(e=>e.id===g),I=F?.encryption!==void 0,L=pt(F?.databases,j?.sqliteSnapshots),R=dt(L),z=!!m&&!!g,B=R||y.size>0,ne=z&&B&&!N.isPending&&(!I||x.trim().length>0),re=()=>{!m||!g||N.mutate({destinationId:m,backupId:g,...R?{}:{locations:[...y]},...I?{backupSecretKey:x.trim()}:{}})};return r(Le,{open:!0,onOpenChange:e=>!e&&c(),children:e(Ie,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(Ne,{children:[r(de,{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(be,{children:[f===1&&r(an,{destinations:T,destinationId:m,onPickDestination:e=>{h(e),_(void 0),b(new Set)},archives:A,archivesLoading:k,archiveId:g,onPickArchive:_}),f===2&&r(on,{locations:M,picked:y,onToggle:P,databases:L,snapshotsOnly:R}),f===3&&r(sn,{destinationName:T.find(e=>e.id===m)?.displayName??m??``,archive:F,picked:[...y],databases:L,snapshotsOnly:R}),f===3&&F?.encryption!==void 0&&r(cn,{keyId:F.encryption.keyId,value:x,onChange:C}),f===3&&N.error&&r(`p`,{role:`alert`,className:`px-4 pb-2 text-xs text-danger`,children:N.error.message})]}),e(te,{className:`justify-between`,children:[r(`div`,{children:f>1&&e(V,{variant:`outline`,size:`sm`,onClick:()=>p(e=>e===3?2:1),children:[r(S,{className:`h-3 w-3`}),u(`common.back`,`Back`)]})}),e(`div`,{className:`flex items-center gap-2`,children:[r(V,{variant:`outline`,size:`sm`,onClick:c,children:u(`common.cancel`,`Cancel`)}),f<3?e(V,{size:`sm`,disabled:f===1&&!z||f===2&&!B,onClick:()=>p(e=>e===1?2:3),children:[u(`common.next`,`Next`),r(D,{className:`h-3 w-3`})]}):e(V,{size:`sm`,onClick:re,disabled:!ne,children:[N.isPending?r(E,{className:`h-3.5 w-3.5 animate-spin`}):r(v,{className:`h-3.5 w-3.5`}),u(`backup.restoreWizard.scheduleRestore`,`Schedule Restore`)]})]})]})]})})}function an({destinations:t,destinationId:n,onPickDestination:i,archives:a,archivesLoading:o,archiveId:s,onPickArchive:c}){let{t:l}=G(),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(ae,{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(`input`,{type:`radio`,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(k,{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:pt(t.databases,void 0)})})]})]}),r(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:K(t.sizeBytes)})]},t.id)})})]})]})}function on({locations:t,picked:n,onToggle:i,databases:a,snapshotsOnly:o}){let{t:s}=G();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(`input`,{type:`checkbox`,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:un(t)})]},t))})]})]})}function sn({destinationName:t,archive:n,picked:i,databases:a,snapshotsOnly:o}){let{t:s}=G();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($,{term:`Destination`,value:t}),r($,{term:`Archive`,value:n?.label??n?.id??`—`}),n&&r($,{term:`Created`,value:`${new Date(n.createdAt).toLocaleString()} · ${K(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($,{term:`Locations`,value:o?`none (configuration is not touched)`:i.length>0?i.join(`, `):`— (full archive)`})]})]})}function cn({keyId:t,value:n,onChange:i}){let{t:a}=G();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(`input`,{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(Ue,{i18nKey:`backup.restoreWizard.encryptedTo`,values:{keyId:t},components:{mono:r(`span`,{className:`font-mono`})}})})]})}function $({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 ln={db:`Database`,addons:`Addon configs`,"addons-data":`Addon data`,tls:`TLS certificates`,cache:`Cache`,data:`Top-level data`};function un(e){return ln[e]??``}o();function dn(){let{t}=G(),n=O(),o=pe(),{state:s,openNew:c,openEdit:l,close:u}=_e({editKey:`edit`,newKey:`new`}),d=Fe(),f=d.data??[],[p,g]=a(null),[_,y]=a(!1),[b,x]=a(!1),[S,C]=a(!1),w=s.mode===`edit`?f.find(e=>e.id===s.id)??null:null;i(()=>{s.mode===`edit`&&!d.isLoading&&w===null&&u()},[s.mode,d.isLoading,w,u]);let T=s.mode===`new`||s.mode===`edit`&&w!==null,D=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(Ge,{embedded:!0,children:[e(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,"data-testid":`backup-actions`,children:[e(V,{variant:`outline`,size:`sm`,type:`button`,onClick:()=>C(!0),"data-testid":`backup-now`,children:[r(h,{className:`h-3.5 w-3.5`}),t(`system.backup.backUpNow`,`Back up now`)]}),e(V,{variant:`outline`,size:`sm`,type:`button`,onClick:()=>y(!0),children:[r(v,{className:`h-3.5 w-3.5`}),t(`system.backup.restore`,`Restore…`)]}),e(V,{size:`sm`,type:`button`,onClick:c,"data-testid":`backup-new-entry`,children:[r(m,{className:`h-3.5 w-3.5`}),t(`system.backup.newEntry`,`New entry`)]})]}),b&&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(v,{className:`h-3.5 w-3.5`}),r(`span`,{children:t(`system.backup.restoreScheduledRestartTheServer`,`Restore scheduled. Restart the server to apply.`)})]}),e(V,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>{D()},disabled:o.isPending,children:[o.isPending?r(E,{className:`h-3.5 w-3.5 animate-spin`}):r(v,{className:`h-3.5 w-3.5`}),t(`system.backup.restartNow`,`Restart Now`)]})]})}),r(Pt,{}),r(Kt,{}),r(bt,{onEdit:e=>l(e.id),onOpenRestoreWizard:e=>g(e)}),T&&r(Ht,{entry:w,onClose:u,onSaved:u}),S&&r(At,{onClose:()=>C(!1)}),(p||_)&&r(rn,{...p?{initialDestinationId:p.destinationId,initialArchiveId:p.archiveId}:{},onClose:()=>{g(null),y(!1)},onScheduled:()=>x(!0)})]})}o();function fn(e){return Object.entries(e).map(([e,t])=>`${e} ${t}`).join(` · `)}function pn(e){return e.reduce((e,t)=>e+Object.values(t.stores).reduce((e,t)=>e+t,0),0)}function mn(){let{t}=G(),n=O(),i=ye(),[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}: ${fn(e.stores)}`).join(`
|
|
2
|
-
`),confirmLabel:t(`systemPage.deletedDevices.confirmLabel`,`Delete`),variant:`danger`})&&await d(!0)},m=[{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=>fn(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(V,{variant:`outline`,onClick:()=>void d(!1),disabled:i.isPending,"data-testid":`deleted-devices-scan`,children:[i.isPending?r(E,{className:`mr-2 h-4 w-4 animate-spin`}):r(A,{className:`mr-2 h-4 w-4`}),t(`systemPage.deletedDevices.scan`,`Scan`)]}),o?.status===`dry-run`&&o.devices.length>0?e(V,{variant:`danger`,onClick:()=>void f(),disabled:i.isPending,"data-testid":`deleted-devices-delete`,children:[r(p,{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:pn(o.devices),count:o.devices.length}):t(`systemPage.deletedDevices.found`,`{{count}} deleted devices still hold {{rows}} items.`,{rows:pn(o.devices),count:o.devices.length})}),r(L,{columns:m,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 hn=`view`,gn=`kinds`,_n=`deleted-devices`;function vn(){let{t}=G(),[n,i]=Ve(),a=n.get(`view`)===`deleted-devices`?_n:gn;return e(`div`,{className:u,children:[e(`div`,{className:`mb-3 space-y-2`,children:[r(ie,{appearance:`pills`,value:a,onValueChange:e=>{i(t=>{let n=new URLSearchParams(t);return e===`kinds`?n.delete(hn):n.set(hn,e),n},{replace:!0})},children:e(re,{className:`flex flex-wrap gap-1`,children:[r(me,{value:gn,children:t(`systemPage.data.viewKinds`,`Record kinds`)}),r(me,{value:_n,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`?De:mn,{})]})}var yn={entries:null,"deleted-devices":`deleted-devices`};function bn(){let{t:e}=G(),t=Be(`/system/data`,{t:e,isAdmin:!0})??{icon:w,title:e(`system.data`,`Data`)},[n]=Ve(),i=yn[n.get(`tab`)??``];if(i!==void 0){let e=new URLSearchParams(n);return e.set(`tab`,`records`),i!==null&&e.set(`view`,i),r(He,{replace:!0,to:{search:e.toString()}})}return r(We,{icon:t.icon,title:t.title,defaultSection:`storage`,sectionsLabel:`${t.title} sections`,sections:[{id:`storage`,label:e(`systemPage.data.storage`,`Storage`),content:r(tt,{})},{id:`records`,label:e(`systemPage.data.records`,`Records`),content:r(vn,{}),ownedParams:[`view`,`recordsOwner`,`recordsKind`,`entryNew`,`entryEdit`]},{id:`backup`,label:e(`systemPage.data.backup`,`Backup`),content:r(dn,{})}]})}export{bn as DataPage};
|