@camstack/addon-admin-ui 1.2.626 → 1.2.627
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 +14 -0
- package/dist/assets/Addons-cUjIvOvT.js +5 -0
- package/dist/assets/{AdminPage-dLt1mKEa.js → AdminPage-BGjbZ_DP.js} +1 -1
- package/dist/assets/{AdminSectionedPage-BYn7-4dT.js → AdminSectionedPage-0BLzsere.js} +1 -1
- package/dist/assets/AiProfiles-BmCrxSUR.js +3 -0
- package/dist/assets/{Authentication-CykaHfAJ.js → Authentication-BANp-rCQ.js} +1 -1
- package/dist/assets/{Build-DvxNre5q.js → Build-CshYezTz.js} +3 -3
- package/dist/assets/Calendars-nijSSBBn.js +1 -0
- package/dist/assets/{CameraGrids-WkOqz0ai.js → CameraGrids-BhMnY-U6.js} +1 -1
- package/dist/assets/Cluster-e11_2684.js +1 -0
- package/dist/assets/{CompositionBlockEditor-B6GFdIeM.js → CompositionBlockEditor-Tlz_skRr.js} +2 -2
- package/dist/assets/{CompositionEditorPage-B8-97pRO.js → CompositionEditorPage-Ry64j4qy.js} +1 -1
- package/dist/assets/{Data-CDo9vIwN.js → Data-CTbC0GG5.js} +2 -2
- package/dist/assets/{DeviceDetail-BBanvUVD.js → DeviceDetail-D9HCHrZA.js} +2 -2
- package/dist/assets/{DeviceDoActionFields-CAAMOfrL.js → DeviceDoActionFields-fbxUHBmB.js} +1 -1
- package/dist/assets/{Devices-CelRF0ak.js → Devices-DTyTQ5cG.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-CMOLFarm.js → EmbedPlayerPage-BHG81kfU.js} +1 -1
- package/dist/assets/History-C4qZ3gqF.js +1 -0
- package/dist/assets/Identity-B1OuI6MD.js +1 -0
- package/dist/assets/{InstanceSwitchCell-BQekirNX.js → InstanceSwitchCell-BE6j8roj.js} +1 -1
- package/dist/assets/InstancesTable-B7rabb_v.js +1 -0
- package/dist/assets/IntegrationDetail-4XDFzceS.js +1 -0
- package/dist/assets/{IntegrationHub-jVzJirPk.js → IntegrationHub-Dh_MHAvj.js} +1 -1
- package/dist/assets/Integrations-CEP5cZG6.js +2 -0
- package/dist/assets/Integrations-CGNp6nto.js +1 -0
- package/dist/assets/{Library-DCDTlPnF.js → Library-DUuHG1yU.js} +1 -1
- package/dist/assets/Locations-CktpOpxD.js +3 -0
- package/dist/assets/{Logs-DOFxrXxZ.js → Logs-BPm2952O.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-C6vw0mq_.js → MaskShapeCanvas-CaIwcviU.js} +1 -1
- package/dist/assets/{MotionZonesSettings-BPLgHoj3.js → MotionZonesSettings-B8humXZO.js} +1 -1
- package/dist/assets/MyAccess-IwGnqYJk.js +2 -0
- package/dist/assets/{Network-CRBMMSjJ.js → Network-Bx8pmtNT.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-BGB_St7Q.js → NodeAddonsSettingsPanel-Ch9_AwqF.js} +1 -1
- package/dist/assets/Notifications-C8aadgSQ.js +1 -0
- package/dist/assets/{Pipeline-CHz7NNm6.js → Pipeline-Bfx8XPU_.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-mpx3kl1W.js → PrivacyMaskSettings-DdMBB4Li.js} +1 -1
- package/dist/assets/Recordings-hnmLWqEZ.js +1 -0
- package/dist/assets/{ScanSubnetEditor-MFkKIxnM.js → ScanSubnetEditor-DEYVzz3F.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-HTEqKGnK.js → SceneMonitorEditor-BsbHr1g7.js} +1 -1
- package/dist/assets/SessionsList-zMHONQk5.js +2 -0
- package/dist/assets/{Showroom-CyZpVw5e.js → Showroom-CgyJscUi.js} +1 -1
- package/dist/assets/{StorageLocationsTable-DznxRZnK.js → StorageLocationsTable-DcJtsyAI.js} +1 -1
- package/dist/assets/System-D5Pndm3I.js +1 -0
- package/dist/assets/{Templates-DAIsSP23.js → Templates-lRI27MQE.js} +1 -1
- package/dist/assets/{Terminal-C1QNo9AN.js → Terminal-BhSCbzcJ.js} +3 -3
- package/dist/assets/{TrainingProviders-DbqfB5Q6.js → TrainingProviders-BDa6e9MH.js} +1 -1
- package/dist/assets/{Viewer-CZuKd6lk.js → Viewer-CkpAWx9q.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CSfv8t1Z.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CumqQOpu.js} +1 -1
- package/dist/assets/{addon-icons-context-WCP6A9AS.js → addon-icons-context-6Mrqvr1U.js} +1 -1
- package/dist/assets/{ai-page.helpers-CJk-hY0M.js → ai-page.helpers-DSmy92dV.js} +1 -1
- package/dist/assets/{archive-CvMfQY3E.js → archive-CfaRqsyD.js} +1 -1
- package/dist/assets/{assignment-candidates-DN-VoSTA.js → assignment-candidates-BbMu5YB7.js} +1 -1
- package/dist/assets/{authed-media-DkaeZ1M8.js → authed-media-BXlwKDeE.js} +1 -1
- package/dist/assets/{bell-off-B4ksiU12.js → bell-off-BxDCQl12.js} +1 -1
- package/dist/assets/{board-model-D-CIwcV1.js → board-model-I1a0N13b.js} +1 -1
- package/dist/assets/{boxes-C9Y0YvOc.js → boxes-Q4Vaj8rD.js} +1 -1
- package/dist/assets/{calendar-clock-CqZRVSc3.js → calendar-clock-CXL7OclM.js} +1 -1
- package/dist/assets/circle-slash-BXDMKEqg.js +1 -0
- package/dist/assets/client-COYx-TFD.js +809 -0
- package/dist/assets/create-composition-Dm3hnlaE.js +2 -0
- package/dist/assets/crop-BpJdhjaO.js +1 -0
- package/dist/assets/{database-zap-Bk33ph_X.js → database-zap-By2T-LnV.js} +1 -1
- package/dist/assets/{device-integration-icon-Duw74rkd.js → device-integration-icon-DxdEgan-.js} +1 -1
- package/dist/assets/device-picker-model-B4F-5cg2.js +1 -0
- package/dist/assets/dist-BR3ExdiJ.js +809 -0
- package/dist/assets/{dist-Dli1FBe2.js → dist-Dqaqf70C.js} +1 -1
- package/dist/assets/{eraser-C1LaIkqO.js → eraser-VwId2IQr.js} +1 -1
- package/dist/assets/{file-up-CODncsO3.js → file-up-DQifBI2e.js} +1 -1
- package/dist/assets/{format-C7beVF9i.js → format-CU8vLl_T.js} +1 -1
- package/dist/assets/{hard-drive-download-gFUluoPC.js → hard-drive-download-CQruQQxy.js} +1 -1
- package/dist/assets/{hostInit-OZrStRqO.js → hostInit-D3bru2MD.js} +1 -1
- package/dist/assets/i18n-CfXX-iuz.js +1 -0
- package/dist/assets/{icons-BM3wcj03.js → icons-BrUjXoAZ.js} +1 -1
- package/dist/assets/index-BIUMsvsC.js +4 -0
- package/dist/assets/{key-BSgMvX5L.js → key-B35noUmR.js} +1 -1
- package/dist/assets/{key-square-CX058EfV.js → key-square-DzO9u0uD.js} +1 -1
- package/dist/assets/{layers-DgoxyPih.js → layers-BG9W-1M5.js} +1 -1
- package/dist/assets/{link-2-off-DmtgBwh-.js → link-2-off-Co-R-jQs.js} +1 -1
- package/dist/assets/{linked-devices-model-B_gqV5Gg.js → linked-devices-model-uwG0psGj.js} +1 -1
- package/dist/assets/{list-ordered-C0l-Wwk-.js → list-ordered-DIKai4La.js} +1 -1
- package/dist/assets/{memory-stick-BSUaqG9H.js → memory-stick-CIR0HAOO.js} +1 -1
- package/dist/assets/{message-square-plus-spORh6qX.js → message-square-plus-DOdNu6ys.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-762c2049.js → mf-entry-bootstrap-0-686859d1.js} +2 -2
- package/dist/assets/{mic-off-DiGyKjsE.js → mic-off-BiujQ8W3.js} +1 -1
- package/dist/assets/{monitor-off-CatAL1-V.js → monitor-off-7S_2iZ-C.js} +1 -1
- package/dist/assets/{monitor-smartphone-CrChoiUo.js → monitor-smartphone-BLCTjHAL.js} +1 -1
- package/dist/assets/mount-B4F-5cg2.js +1 -0
- package/dist/assets/{notification-rule-status-BaZr2lCj.js → notification-rule-status-Cb4jx34Y.js} +1 -1
- package/dist/assets/{player-overlays-CC-b3--a.js → player-overlays-Dl8i669l.js} +1 -1
- package/dist/assets/remoteEntry-DWDUtJXh.js +1 -0
- package/dist/assets/{ruler-6Q54d4xt.js → ruler-BeM-m4O5.js} +1 -1
- package/dist/assets/{scissors-BBC_GGoc.js → scissors-DY0_cgnp.js} +1 -1
- package/dist/assets/{search-x-CHDiifxm.js → search-x-_pziDXsR.js} +1 -1
- package/dist/assets/{send-CwDFB9fX.js → send-CUC0A2_t.js} +1 -1
- package/dist/assets/{settings-2-C5tt8eea.js → settings-2-BSRK8TEC.js} +1 -1
- package/dist/assets/{shapes-C5Nnn9NE.js → shapes-BN2HBJ_3.js} +1 -1
- package/dist/assets/{sigma-BSlFNDI5.js → sigma-DfN2Jhy4.js} +1 -1
- package/dist/assets/{speaker-ydML9LxI.js → speaker-CHLYh6wT.js} +1 -1
- package/dist/assets/src-DzmVXlVl.js +100 -0
- package/dist/assets/{sso-popup-C6eP07wS.js → sso-popup-Ch2mRf6V.js} +1 -1
- package/dist/assets/{step-inspector-model-CEg8vezx.js → step-inspector-model-DKYOqORK.js} +1 -1
- package/dist/assets/{table-2-CeAydAOI.js → table-2-gx6_SlYD.js} +1 -1
- package/dist/assets/{timer-reset-B_Ta8kGS.js → timer-reset-Iy3ZgMXB.js} +1 -1
- package/dist/assets/{tv-BdJr-riI.js → tv-BXIsODbK.js} +1 -1
- package/dist/assets/{unlink-DzO14DVn.js → unlink-B_U8L0Wx.js} +1 -1
- package/dist/assets/{usb-W-ktPgHL.js → usb-OCXp5uEl.js} +1 -1
- package/dist/assets/{use-device-bound-caps-xJuEMYyg.js → use-device-bound-caps-BOAx-vk3.js} +1 -1
- package/dist/assets/{use-scenes-feed-BFZqBAYX.js → use-scenes-feed--8rfo18P.js} +1 -1
- package/dist/assets/{use-stationary-objects-CHjUAUSJ.js → use-stationary-objects-CZE5lmtm.js} +1 -1
- package/dist/assets/{useAdminDeviceRemoval-YiBXHBHP.js → useAdminDeviceRemoval-D2MzHW1R.js} +1 -1
- package/dist/assets/useEventInvalidation-B4F-5cg2.js +1 -0
- package/dist/assets/{useNodeUrlSelection-D9CPif56.js → useNodeUrlSelection-DtbPWifx.js} +1 -1
- package/dist/assets/{useTemplateSave-DBc8G5sM.js → useTemplateSave-CeQLDKqQ.js} +1 -1
- package/dist/assets/user-round-B2WYnao7.js +1 -0
- package/dist/assets/{user-x--TnMk2gT.js → user-x-7OBQLt0v.js} +1 -1
- package/dist/assets/{variable-Bz8zKWo2.js → variable-CuVMBdXX.js} +1 -1
- package/dist/assets/{video-b4uGYAxS.js → video-Cae__dYz.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Cs7a4rE-.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DsLUyALP.js} +2 -2
- package/dist/index.html +10 -10
- package/dist/server/addon.js +59 -97
- package/package.json +2 -2
- package/dist/assets/Addons-B4N1LxY8.js +0 -5
- package/dist/assets/AiProfiles-DcAkO0SI.js +0 -3
- package/dist/assets/Calendars-D_iMy7Yy.js +0 -1
- package/dist/assets/Cluster-CyLi0SW_.js +0 -1
- package/dist/assets/History-Cvy2subh.js +0 -1
- package/dist/assets/Identity-DrFBCRWk.js +0 -1
- package/dist/assets/InstancesTable-Bt8qoWMR.js +0 -1
- package/dist/assets/IntegrationDetail-DvlDDD_J.js +0 -1
- package/dist/assets/Integrations-B9p5_Qf7.js +0 -1
- package/dist/assets/Integrations-HUB0bAoi.js +0 -2
- package/dist/assets/Locations-1E3b4qVs.js +0 -3
- package/dist/assets/MyAccess-CShkG3rs.js +0 -2
- package/dist/assets/Notifications-CEls0HQ3.js +0 -1
- package/dist/assets/Recordings-Bccg5edp.js +0 -1
- package/dist/assets/SessionsList-CLTlUoNj.js +0 -2
- package/dist/assets/System-C-k3Rz-I.js +0 -1
- package/dist/assets/circle-slash-DDhnvhLN.js +0 -1
- package/dist/assets/client-kWeONSGL.js +0 -809
- package/dist/assets/create-composition-CNJkzaMb.js +0 -2
- package/dist/assets/crop-D1l0Xs25.js +0 -1
- package/dist/assets/device-picker-model-DCNN-HPV.js +0 -1
- package/dist/assets/dist-DXhYk_uu.js +0 -809
- package/dist/assets/i18n-Cmy3cCDH.js +0 -1
- package/dist/assets/index-DwCHDODI.js +0 -4
- package/dist/assets/mount-DCNN-HPV.js +0 -1
- package/dist/assets/remoteEntry-C16PJyFZ.js +0 -1
- package/dist/assets/src-DGSNF4l8.js +0 -100
- package/dist/assets/useEventInvalidation-DCNN-HPV.js +0 -1
- package/dist/assets/user-round-D8euVsR1.js +0 -1
|
@@ -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{$n as u,An as d,Cn as f,D as p,Di as m,Fi as h,Fn as g,Gi as _,Ii as v,Kt as y,Ln as b,Ni as x,Pn as S,Sn as C,Un as w,Ut as T,Yn as E,br as D,bt as O,ct as k,ei as A,fa as j,ht as M,ki as N,ui as ee,ut as P,vn as F,wn as I,xi as L}from"./player-overlays-CC-b3--a.js";import{Go as te,Ko as ne,Zo as re,qo as ie}from"./client-kWeONSGL.js";import{t as ae}from"./hard-drive-download-gFUluoPC.js";import{t as oe}from"./memory-stick-BSUaqG9H.js";import{t as se}from"./unlink-DzO14DVn.js";import{$u as ce,Bn as le,Br as ue,Di as de,Dl as fe,Ff as R,Fi as pe,Fl as me,Fr as he,Ft as z,Gc as ge,Go as _e,Ic as ve,Ii as ye,Ir as be,Jr as xe,Ju as Se,Kc as Ce,Kn as we,Lc as Te,Ln as Ee,Lr as De,Mf as B,Mt as Oe,Ni as ke,Pi as Ae,Qu as je,Rn as V,Rr as Me,Uc as Ne,Vr as Pe,W as Fe,Wc as Ie,Wl as Le,Xl as Re,Xr as ze,Xu as Be,Yr as H,Yu as Ve,Zu as He,_n as Ue,hf as We,jf as Ge,qu as Ke,sf as U,vd as qe,vn as Je,vt as Ye,yi as W,zn as G,zr as Xe}from"./src-DGSNF4l8.js";import{t as K}from"./i18n-Cmy3cCDH.js";import{t as q}from"./useTranslation-BJr-n0es.js";import{Br as Ze,g as Qe}from"./index-DwCHDODI.js";import{n as $e}from"./format-C7beVF9i.js";import{t as et}from"./AdminPage-dLt1mKEa.js";import{t as tt}from"./NodeAddonsSettingsPanel-BGB_St7Q.js";import{_ as nt,f as rt,h as it,p as at}from"./board-model-D-CIwcV1.js";import{t as J}from"./format-size-DIxKXxtj.js";import{n as ot,t as st}from"./useNodeUrlSelection-D9CPif56.js";s();var ct={unpaired:`Not paired`,pending:`Pairing…`,paired:`Paired`},lt=new Set([`paired`,`rejected`,`failed`,`expired`]);function Y(e){return lt.has(e)}function ut(e){return e.replace(/\D/g,``).slice(0,6)}function dt(e){return e.length===6}function ft(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 pt(e,t){return e.includes(`:`)?`[${e}]:${t}`:`${e}:${t}`}function mt(e){return e.length<=23?e:`${e.slice(0,20)}…`}function ht({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 gt(e){return e===`awaiting-both`||e===`awaiting-hub`}var _t={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`},vt=2e3,yt=1e3;function bt(e){return e.message.length>0?e.message:K.t(`pairing.agentsFoundSection.requestFailed`)}function xt(e){return e.length===6?`${e.slice(0,3)} ${e.slice(3)}`:e}function St(e){let[t,n]=o(()=>Date.now());return a(()=>{if(!e)return;let t=setInterval(()=>n(Date.now()),yt);return()=>clearInterval(t)},[e]),t}function Ct({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=R.agentPairing.beginPairing.useMutation(),x=R.agentPairing.confirmPairing.useMutation(),S=R.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(bt(e))})}},[n]);let C=R.agentPairing.getPairing.useQuery({pairingId:d??``},{enabled:d!==null,refetchInterval:e=>{let t=e.state.data?.state;return t!==void 0&&Y(t)?!1:vt}}),w=wt(x.data??S.data??null,C.data??null),T=ht({view:w,beginError:p}),E=w!==null&&Y(w.state),O=t(!1);a(()=>{if(!E){O.current=!1;return}O.current||(O.current=!0,s())},[E,s]);let k=St(w!==null&&!E),A=()=>{d===null||!dt(h)||(v(null),x.mutate({pairingId:d,code:h},{onError:e=>{v(bt(e)),g(``)}}))};return i(he,{open:n!==null,onOpenChange:e=>!e&&r(),children:e(De,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(ue,{children:[i(Pe,{children:u(`pairing.pairingDialog.title`,{node:n?.nodeId??``})}),i(Me,{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:pt(n.host,n.port)})})]}),e(be,{className:`space-y-4`,children:[i(Tt,{phase:T}),T===`send-failed`&&p!==null&&i(H,{title:u(`pairing.pairingDialog.couldNotStartThePairing`,`Could not start the pairing`),message:p}),w!==null&&!E&&i(Et,{view:w,phase:T,now:k,typed:h,onType:e=>g(ut(e)),onSubmit:A,confirmError:_,busy:x.isPending}),T===`paired`&&w!==null&&i(Dt,{nodeId:w.nodeId,onOpenNode:c,onClose:r}),E&&T!==`paired`&&w?.failure!=null&&i(H,{message:w.failure})]}),i(Xe,{children:E||T===`send-failed`?i(W,{type:`button`,variant:`outline`,onClick:r,children:u(`common.close`,`Close`)}):e(l,{children:[i(W,{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`)}),gt(T)&&e(W,{type:`button`,disabled:!dt(h)||x.isPending,onClick:A,children:[x.isPending&&i(D,{className:`h-4 w-4 animate-spin`}),u(`common.confirm`,`Confirm`)]})]})})]})})}function wt(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 Tt({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(D,{className:`h-4 w-4 animate-spin`}),r&&i(m,{className:`h-4 w-4`}),a&&i(L,{className:`h-4 w-4`}),_t[t]]})}function Et({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:xt(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).`)})]}),gt(n)?i(`form`,{className:`space-y-2`,onSubmit:e=>{e.preventDefault(),s()},children:i(z,{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(U,{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:ft(t.expiresAt,r)})})]})]})}function Dt({nodeId:t,onOpenNode:n,onClose:r}){let{t:a}=q(),{nodes:o}=Ge(),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(F,{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(W,{type:`button`,size:`sm`,variant:`outline`,disabled:!s,onClick:()=>{r(),n(t)},children:a(`pairing.pairingDialog.openNode`,`Open node`)})]})}var Ot={paired:`success`,pending:`warning`,unpaired:`default`};function kt({state:t,connected:n}){let{t:r}=q();return e(`span`,{className:`inline-flex items-center gap-1.5`,children:[i(de,{variant:Ot[t],className:`text-[10px]`,children:ct[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 At(e){if(e.trim().length===0)return;let t=Number(e);return Number.isInteger(t)&&t>=1&&t<=65535?t:null}function jt({onOpenNode:t}){let{t:r}=q(),a=k(),s=R.useUtils(),c=R.agentPairing.listDiscoveredAgents.useQuery(void 0,{refetchInterval:15e3}),[u,d]=o(null),[f,m]=o(null),[h,g]=o(!1),[_,v]=o(``),[y,x]=o(``),[C,T]=o(null),[E,O]=o(!1),A=()=>void s.agentPairing.listDiscoveredAgents.invalidate(),j=R.agentPairing.addAgentByAddress.useMutation({onSuccess:()=>{g(!1),v(``),x(``),T(null),A()},onError:e=>T(e.message)}),M=R.agentPairing.unpairAgent.useMutation({onSuccess:e=>{m({tone:`success`,message:`${e.nodeId}: ${e.next}${e.agentNotified?``:` The agent could not be told; forget the hub on its own page.`}`}),A()},onError:e=>m({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]),ee=async()=>{O(!0);try{await s.agentPairing.listDiscoveredAgents.fetch({refresh:!0}),A()}finally{O(!1)}},P=()=>{let e=At(y);if(e===null){T(`The port must be a whole number between 1 and 65535.`);return}T(null),j.mutate({host:_.trim(),...e===void 0?{}:{port:e}})},F=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`})&&(m(null),M.mutate({nodeId:e.nodeId}))},I=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:pt(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(kt,{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:mt(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(W,{type:`button`,size:`sm`,onClick:()=>d({nodeId:e.nodeId,host:e.host,port:e.port}),children:r(`pairing.agentsFoundSection.pair`,`Pair`)}):e.state===`paired`?i(W,{type:`button`,size:`sm`,variant:`outline`,disabled:M.isPending,onClick:()=>void F(e),children:r(`pairing.agentsFoundSection.unpair2`,`Unpair`)}):e.state===`pending`&&t!==null?i(W,{type:`button`,size:`sm`,onClick:()=>d({nodeId:e.nodeId,host:e.host,port:e.port,pairingId:t.pairingId}),children:r(`pairing.agentsFoundSection.resume`,`Resume`)}):null}}],[M.isPending,r]);return e(Ee,{headingId:`agents-found`,title:r(`pairing.agentsFoundSection.agentsFoundOnTheNetwork`,`Agents found on the network`),icon:b,testId:`agents-found`,actions:e(l,{children:[e(W,{type:`button`,size:`sm`,variant:`outline`,disabled:E,onClick:()=>void ee(),children:[E?i(D,{className:`h-3.5 w-3.5 animate-spin`}):i(S,{className:`h-3.5 w-3.5`}),r(`pairing.agentsFoundSection.scan`,`Scan`)]}),e(W,{type:`button`,size:`sm`,onClick:()=>g(e=>!e),children:[i(w,{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.`)}),h&&e(`form`,{"aria-label":r(`pairing.agentsFoundSection.addAgentByAddress`,`Add agent by address`),className:`flex flex-wrap items-start gap-2`,onSubmit:e=>{e.preventDefault(),_.trim().length>0&&!j.isPending&&P()},children:[i(z,{label:r(`pairing.agentsFoundSection.address`,`Address`),description:r(`pairing.agentsFoundSection.aPrivateOrLocalAddress`,`A private or local address only.`),...C===null?{}:{error:C},children:i(U,{value:_,onChange:e=>v(e.target.value),placeholder:`192.0.2.20`,"aria-label":r(`pairing.agentsFoundSection.agentAddress`,`Agent address`),autoComplete:`off`})}),i(z,{label:r(`pairing.agentsFoundSection.port`,`Port`),description:r(`pairing.agentsFoundSection.optional`,`Optional.`),children:i(U,{value:y,onChange:e=>x(e.target.value),placeholder:`4444`,inputMode:`numeric`,"aria-label":r(`pairing.agentsFoundSection.agentPort`,`Agent port`),className:`w-24`})}),e(W,{type:`submit`,size:`sm`,className:`mt-5`,disabled:_.trim().length===0||j.isPending,children:[j.isPending&&i(D,{className:`h-3.5 w-3.5 animate-spin`}),r(`common.add`,`Add`)]})]}),f!==null&&i(`p`,{role:`status`,className:`rounded border px-3 py-2 text-xs ${f.tone===`success`?`border-success/30 text-foreground`:`border-danger/40 text-danger`}`,children:f.message}),c.isError?i(H,{title:r(`pairing.agentsFoundSection.couldNotListAgents`,`Could not list agents`),message:c.error?.message??r(`pairing.agentsFoundSection.requestFailed`,`Request failed`),onRetry:A}):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(ze,{icon:b,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(G,{columns:I,rows:N,rowKey:e=>e.nodeId,minWidthPx:720,defaultSort:{columnKey:`state`,dir:`asc`}})]}),i(Ct,{target:u,onClose:()=>d(null),onSettled:A,onOpenNode:t})]})}function Mt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Nt(e){if(!Mt(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 Pt(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 Ft(e){let t=/^100\.(\d+)\./.exec(e);if(t===null)return!1;let n=Number(t[1]);return n>=64&&n<=127}function It(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 Lt(e,t){if(typeof t==`string`&&Pt(t))return t.trim();let n=e.filter(e=>!e.includes(`:`)),r=n.find(e=>!e.startsWith(`127.`)&&!e.startsWith(`169.254.`)&&!Z(e)&&!Ft(e)&&It(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 Rt(e){return`http://${e}:4444/`}function zt(e,t){let n=new URL(Rt(e));return n.searchParams.set(`ticket`,t),n.toString()}function Bt(){return window.open(`about:blank`,`_blank`)}function Vt(e,t){return e===null||e.closed?!1:(e.location.href=t,!0)}function Ht({node:t}){let{info:n}=Qe();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 Ut(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 Wt(e){return e===`running`?`running`:e===`crashed`||e===`failed`?`error`:`stopped`}var Gt=[`trace`,`debug`,`info`,`warn`,`error`];function Kt({proc:t,nodeId:n,defaultExpanded:r,activePanel:a,onTogglePanel:s}){let{t:c}=q(),l=t.services??[],u=l.length===1,[f,p]=o(u||r),[m,v]=o(null),[y,b]=o(`info`),S=t.name.includes(`(core)`),w=Ie(),T=ge(),E=Ce(),D=async e=>{v(e);try{await w.mutateAsync({nodeId:n,addonId:e})}catch(e){console.error(`Failed to restart addon:`,e)}finally{v(null)}},O=async()=>{v(t.name);try{await T.mutateAsync({nodeId:n,processName:t.name})}catch(e){console.error(`Failed to restart process:`,e)}finally{v(null)}},k=async e=>{let r=`${n}/${t.name}`;try{await E.mutateAsync({nodeId:r,level:e}),b(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:()=>p(!f),onKeyDown:u?void 0:e=>{(e.key===`Enter`||e.key===` `)&&p(!f)},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(f?h:x,{className:`h-3 w-3 text-muted-foreground shrink-0`}),S?i(C,{className:`h-3.5 w-3.5 text-primary shrink-0`}):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(Ye,{status:Wt(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:Ut(t.uptimeSeconds)}),!S&&e(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[e(ke,{children:[i(ye,{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:y}),i(Ae,{align:`end`,className:`min-w-[70px] py-0.5`,children:Gt.map(e=>i(pe,{onClick:()=>k(e),className:`h-auto px-2 py-1 text-[10px] font-mono ${e===y?`text-primary font-semibold`:``}`,children:e},e))})]}),i(W,{variant:`unstyled`,onClick:O,disabled:m===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(d,{className:`h-3 w-3 ${m===t.name?`animate-spin`:``}`})})]})]}),f&&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(W,{variant:`unstyled`,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(I,{className:`h-3 w-3`})}),i(W,{variant:`unstyled`,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(g,{className:`h-3 w-3`})}),i(W,{variant:`unstyled`,onClick:()=>D(t.addonId),disabled:m===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(d,{className:`h-3 w-3 ${m===t.addonId?`animate-spin`:``}`})})]})]}),a?.addonId===t.addonId&&a.type===`logs`&&i(`div`,{className:`border-t border-border/40 bg-muted/5`,children:i(Je,{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(Ue,{addonId:t.addonId,category:`addon.*`,maxHeight:`max-h-48`,onClose:()=>s(t.addonId,`events`)})})]},t.addonId))}),f&&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 qt({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(Kt,{proc:t,nodeId:e,defaultExpanded:n===0,activePanel:r,onTogglePanel:s},t.name))})}var Jt={system:0,managed:1,root:2};s();function Yt(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 Xt(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function Zt({nodeId:t}){let{t:r}=q(),a=c(),o=B(`metrics.node-processes-snapshot`,e=>e.nodeId===t),{data:s}=Te({nodeId:t}),l=o?.processes??s,u=n(()=>l?[...l]:[],[l]),d=n(()=>[{key:`classification`,header:r(`cluster.processesTab.class`,`Class`),sortValue:e=>Jt[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:Xt(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:Yt(e.uptimeSec)})}],[r]);return e(`div`,{className:`space-y-4`,children:[i(`div`,{className:`flex items-start justify-end gap-4`,children:e(W,{variant:`unstyled`,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(S,{className:`h-3 w-3`}),` `,r(`common.refresh`)]})}),i(G,{columns:d,rows:u,rowKey:e=>e.pid,minWidthPx:880,maxBodyHeight:le,emptyMessage:r(`cluster.processesTab.scanning`,`Scanning…`)})]})}s();var Qt=96;function $t({title:e,points:t,mainLabel:r,gcLabel:a,formatValue:o,emptyMessage:s,gapMs:c}){return i(Fe,{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:Qt,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(Fe,{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:Qt,formatValue:e=>r(e),axisFor:()=>({floor:o,scale:s}),emptyMessage:a})}function en(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 tn(e,t,n,r){let i=e.get(t),a=en(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 nn(e,t,n){let r=e;for(let e of re(t,n))r=tn(r,e.key,e.kind,e.point);return r}function rn(e,t){let n=e;for(let e of t)for(let t of e.points)n=tn(n,e.key,e.kind,t);return n}function an(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 on=12e4;function sn(e,t){return e===null?!1:t-e>on}function cn(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 ln(e){for(let t of e.values()){let e=t.points.at(-1);if(e&&e.cpuMainPercent!==null)return!0}return!1}var un={key:`cpu`,dir:`desc`};function dn(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 fn(e){return e.points.at(-1)?.memoryRssBytes??null}function pn(e,t,n){let r=n.trim().toLowerCase();return r===``?!0:e.toLowerCase().includes(r)||t.toLowerCase().includes(r)}function mn(e,t){return t===`memory`?fn(e):dn(e)}function hn(e,t,n){let r=e.filter(e=>t.selectedKeys.size>0&&!t.selectedKeys.has(e.key)?!1:pn(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=mn(e,t.sort.key),o=mn(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 gn(e,n=720){let r=B(`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}=ve({forNodeId:e,sinceMs:c,maxPoints:n});a(()=>{d!==void 0&&s(e=>{let t=rn(e,d.series);return u.current=an(t),t})},[d]);let p=r?.timestamp;a(()=>{r==null||p===void 0||(sn(u.current,p)&&l(u.current??0),s(e=>{let t=nn(e,r.processes,p);return u.current=an(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:cn(i),sampleCount:m,threadSplitAvailable:ln(i),loadingRetained:f,durable:d?.durable??null,bucketMs:d?.bucketMs??null,cadenceMs:d?.cadenceMs??null,retainedSamples:d?.retainedSamples??null}}var _n=`__unclaimed__`;function vn(e,t){return{kind:e,deviceId:t,cpu:0,cpuKnown:!0,rss:0,rssKnown:!0,count:0,roles:new Set}}function yn(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 bn(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)??vn(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])=>yn(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=vn(`unclaimed`,null);for(let e of a)o.count+=1,o.rss+=e.memoryRssBytes;return o.cpuKnown=!1,[...i,yn(_n,o)]}var xn=[{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 Sn(e){return e.attribution===`measured`&&e.wiredToday}function Cn(){let e=new Set;for(let t of xn)Sn(t)&&e.add(t.family);return e}var wn=Cn();function Tn(e){return!wn.has(e.role)||e.deviceId===null?!1:e.attribution===`measured`}function En(e){return`${e.addonId}${e.role}${e.unit}${e.pid??`-`}`}function Dn(){return{cpuSeconds:0,cpuKnown:!0,rssBytes:0,rssKnown:!0,unitCount:0,roles:new Set}}function On(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 kn(e){return Math.round(e*10)/10}function An(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)Tn(t)&&i.set(En(t),t);let a=new Map,o=new Set;for(let n of t.entries){if(!Tn(n)||n.deviceId===null)continue;let t=En(n);o.add(t);let r=a.get(n.deviceId)??Dn();r.unitCount+=1,r.roles.add(n.role);let s=On(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?kn(n.cpuSeconds/r*100):null,rssBytes:n.rssKnown?n.rssBytes:null,unitCount:n.unitCount,roles:[...n.roles].toSorted()}}))}function jn(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 Mn(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 Nn(e){let t=e.indexOf(`@`);return t===-1?{addonId:e,nodeId:null}:{addonId:e.slice(0,t),nodeId:e.slice(t+1)}}function Pn(e,t){let n=Nn(e);return n.nodeId===null?t.isHub:n.nodeId===t.nodeId}function Fn(e,t){return e.filter(e=>Pn(e.addonId,t))}s();function In(e){let n=B(`metrics.node-processes-snapshot`,t=>t.nodeId===e.nodeId),r=qe(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:Fn(d,e)},n=c.current;if(c.current=t,n===null)return;let r=An(n,t);r.length!==0&&s(e=>jn(e,r))},[d,f,e.nodeId,e.isHub]);let p=d===void 0?[]:Fn(d,e),m=n?.processes,h=bn(p,m);return{series:Mn(i),unclaimed:h.find(e=>e.kind===`unclaimed`)??null,loading:r.isPending,error:r.error===null?null:r.error.message}}function Ln(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 Rn=25,zn=64*1024*1024,Bn=1e4;function Vn({scope:t,cadenceMs:n}){let{t:r}=q(),a=In(t),{data:o=[]}=_e({isCamera:!0,projection:`slim`}),s=Ln(o),c=xe(n??Bn);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(T,{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(Un,{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(Hn,{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:Rn,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:zn,axisScale:`bytes`,gapMs:c,emptyMessage:r(`cameraLoad.memoryUnavailable`,`No memory reported.`)})]})]},t.deviceId))})]})}function Hn({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 Un({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 Wn=256*1024*1024,Gn=1e4;function Kn({nodeId:r,isHub:a}){let s=t(null);We(s);let{t:c}=q(),{series:l,sampleCount:u,threadSplitAvailable:d,loadingRetained:p,bucketMs:m,cadenceMs:h}=gn(r),[g,_]=o(``),[v,y]=o(new Set),[b,x]=o(un),S=e=>e.key===`__root__`?c(`clusterLoad.bucketRoot`,`Node supervisor`):e.key===`__unattributed__`?c(`clusterLoad.bucketUnattributed`,`Unattributed processes`):e.key,C=xe(m??h??Gn),w=n(()=>hn(l,{search:g,selectedKeys:v,sort:b},S),[l,g,v,b]),E=e=>{y(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(qn,{bucketMs:m,cadenceMs:h}),!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(T,{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:p?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(f,{className:`pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-foreground-subtle`}),i(U,{ref:s,type:`search`,value:g,onChange:e=>_(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(Jn,{sort:b,onChange:x})]}),e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[l.map(e=>{let t=v.has(e.key);return i(W,{variant:`unstyled`,type:`button`,"aria-pressed":t,onClick:()=>E(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:S(e)},e.key)}),v.size>0&&e(W,{variant:`unstyled`,type:`button`,onClick:()=>y(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(O,{className:`h-2.5 w-2.5`}),c(`clusterLoad.clearFilter`,`All runners`)]})]})]}),l.length>0&&w.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:w.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:S(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($t,{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:C,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:Wn,axisScale:`bytes`,gapMs:C,emptyMessage:c(`clusterLoad.memoryUnavailable`,`No memory samples yet.`)})]})]},t.key))}),i(Vn,{scope:{nodeId:r,isHub:a},cadenceMs:h})]})}function qn({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 Jn({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(W,{variant:`unstyled`,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 Yn=`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 Xn({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(tt,{nodeId:e,addonIds:t,level:`global`,fieldScope:`perNode`,emptyMessage:Yn,selfTabbed:!0})})}s();function Zn({nodeId:e,addons:t}){let{t:r}=q(),a=c(),{data:o,isLoading:s}=fe({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=Re({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(G,{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(P,{value:n,onChange:n=>u.mutate({nodeId:e,capName:t.capName,addonId:n.target.value}),disabled:a||u.isPending||s,className:`w-full`,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:le})}s();function Qn(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 $n(t){let{t:n}=q(),[r,a]=o(!1),[s,l]=o(t.name),u=c(),d=Ne({onSuccess:()=>{u.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}}),f=(t.localIps??[]).filter(e=>!e.includes(`:`)),p=(t.localIps??[]).filter(e=>e.includes(`:`)),m=async()=>{if(!s.trim()||s===t.name){a(!1);return}try{await d.mutateAsync({nodeId:t.nodeId,name:s.trim()}),a(!1)}catch(e){console.error(`Rename failed:`,e)}},h=[[`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(U,{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`&&m(),e.key===`Escape`&&a(!1)},disabled:d.isPending,autoFocus:!0}),i(W,{variant:`unstyled`,onClick:()=>void m(),disabled:d.isPending,className:`p-0.5 text-success hover:bg-success/10 rounded`,title:n(`common.save`,`Save`),children:i(v,{className:`h-3.5 w-3.5`})}),i(W,{variant:`unstyled`,onClick:()=>a(!1),className:`p-0.5 text-muted-foreground hover:bg-muted rounded`,title:n(`common.cancel`,`Cancel`),children:i(O,{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(W,{variant:`unstyled`,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(E,{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:Qn(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 f.length>0&&h.push([`IPv4`,i(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map((e,t)=>i(`span`,{className:`font-mono text-xs px-1.5 py-0.5 rounded bg-muted`,children:e},`${e}-${t}`))})]),p.length>0&&h.push([`IPv6`,i(`div`,{className:`flex flex-wrap gap-1.5`,children:p.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:h.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 er({nodeId:t,value:n,detectedHosts:r,status:s,errorMessage:c,onCommit:l}){let{t:u}=q(),[d,f]=o(n??``);a(()=>{f(n??``)},[n]);let p=r[0],m=p===void 0?`auto-detect`:`auto: ${p}`,h=s===`pending`,g=d.trim(),_=g!==(n??``),y=_&&!h,b=()=>{y&&l(t,g.length>0?g:null)};return e(`div`,{className:`flex items-center gap-1.5`,children:[i(U,{"aria-label":u(`placementBoard.reachableHostInput.reachableHostFor`,`Reachable host for {{nodeId}}`,{nodeId:t}),type:`text`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:m,value:d,disabled:h,onChange:e=>f(e.target.value),onBlur:b,onKeyDown:e=>{e.key===`Enter`&&b(),e.key===`Escape`&&f(n??``)},className:`w-36`}),e(W,{variant:`outline`,size:`sm`,onClick:b,disabled:!y,"aria-label":u(`placementBoard.reachableHostInput.saveReachableHostFor`,`Save reachable host for {{nodeId}}`,{nodeId:t}),title:u(`placementBoard.reachableHostInput.saveReachableHost`,`Save reachable host`),children:[h?i(D,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):i(v,{className:`h-3 w-3`,"aria-hidden":`true`}),u(`common.save`,`Save`)]}),!_&&!h&&s===`success`&&i(v,{className:`h-3.5 w-3.5 shrink-0 text-success`,"aria-label":u(`placementBoard.reachableHostInput.saved`,`Saved`),role:`img`}),s===`error`&&i(`span`,{title:c??u(`placementBoard.reachableHostInput.failedToSaveReachableHost`,`Failed to save reachable host`),children:i(N,{className:`h-3.5 w-3.5 shrink-0 text-danger`,"aria-label":c??u(`placementBoard.reachableHostInput.failedToSaveReachableHost`,`Failed to save reachable host`),role:`img`})})]})}s();function tr(e){let t=ne.safeParse(it(e,`color`));return t.success?t.data:null}function nr(e,t){return t.variables?.agentNodeId===e?t.isPending?`pending`:t.isError?`error`:t.isSuccess?`success`:`idle`:`idle`}function rr({nodeId:t,detectedHosts:r}){let{t:a}=q(),o=c(),s=me(void 0),l=Le({onSuccess:()=>rt(o)}),u=Le({onSuccess:()=>rt(o)}),d=n(()=>s.data?.find(e=>e.nodeId===t)?.settings,[s.data,t]),f=tr(d)??(s.isLoading?null:ie(t)),p=nt(d,`reachableHost`),m=nr(t,l),h=m===`error`?at(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(V,{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:te.map(e=>{let t=f===e;return i(W,{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 ${we(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(V,{label:a(`nodes.general.reachableHost`,`Reachable host`),children:i(er,{nodeId:t,value:p,detectedHosts:g,status:m,errorMessage:h,onCommit:(e,t)=>{l.mutate({agentNodeId:e,reachableHost:t})}})})]})}s();var ir=512,ar=65536,or=[[`serverManagement`,`getLaunchOverrides`]];function sr(e){let t=e.trim();if(t===``)return null;if(!/^[0-9]+$/.test(t))return;let n=Number(t);return n>=ir&&n<=ar?n:void 0}var cr=e=>e==null?``:String(e);function lr({node:t}){let{t:n}=q(),r=c(),s=t.isHub?void 0:{nodeId:t.id},l=Ve(s,{enabled:t.isOnline,retry:1}),u=ce({onSuccess:()=>{r.invalidateQueries({queryKey:or})}}),[d,f]=o(``),[p,m]=o(``),[h,g]=o(null),_=l.data;a(()=>{_!==void 0&&(f(cr(_.heapMb)),m(cr(_.rssBudgetMb)))},[_]);let v=async()=>{let e=sr(d),r=t.isHub?sr(p):null;if(e===void 0||r===void 0){g(n(`nodes.launch.invalid`,`Enter a whole number between {{min}} and {{max}} MB, or leave the field empty.`,{min:ir,max:ar}));return}g(null);try{g((await u.mutateAsync({...s,heapMb:e,...t.isHub?{rssBudgetMb:r}:{}})).restartRequired?n(`nodes.launch.saved`,`Saved. Takes effect on restart.`):n(`nodes.launch.savedNow`,`Saved.`))}catch(e){g(e instanceof Error?e.message:n(`nodes.launch.failed`,`Save failed.`))}};return e(`div`,{className:`rounded-lg border border-border bg-surface/40 divide-y divide-border px-3`,children:[i(V,{label:n(`nodes.launch.heap`,`Heap ceiling (MB)`),children:i(U,{type:`number`,inputMode:`numeric`,"aria-label":n(`nodes.launch.heap`,`Heap ceiling (MB)`),placeholder:n(`nodes.launch.default`,`Default`),value:d,onChange:e=>f(e.target.value),disabled:!t.isOnline||l.isLoading})}),t.isHub&&i(V,{label:n(`nodes.launch.rss`,`RSS budget (MB)`),children:i(U,{type:`number`,inputMode:`numeric`,"aria-label":n(`nodes.launch.rss`,`RSS budget (MB)`),placeholder:n(`nodes.launch.default`,`Default`),value:p,onChange:e=>m(e.target.value),disabled:!t.isOnline||l.isLoading})}),i(V,{label:n(`nodes.launch.restartNote`,`Takes effect on restart`),actions:i(W,{type:`button`,size:`sm`,onClick:()=>void v(),disabled:!t.isOnline||u.isPending,children:n(`common.save`,`Save`)}),children:h??``})]})}s();var ur=3*6e4,dr={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 fr({desktopApp:t,nodeName:n,routingInput:s,onSettled:c}){let{t:l}=q(),u=k(),f=He({onSettled:c}),[p,m]=o(null),[h,g]=o(!1),[_,v]=o(null);a(()=>{p!=null&&t.version!==p.fromVersion&&(m(null),g(!1))},[t.version,p]),a(()=>{if(p==null)return;let e=Math.max(0,p.startedAtMs+ur-Date.now()),t=setTimeout(()=>g(!0),e);return()=>clearTimeout(t)},[p]);let y=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]),b=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`})){v(null),g(!1);try{let e=await f.mutateAsync(s);e.accepted?m({fromVersion:t.version,startedAtMs:Date.now()}):e.reason!=null&&v(y(e.reason))}catch(e){v(e instanceof Error?e.message:String(e))}}},[u,t,f,n,y,s,l]),x=p!=null&&!h,{update:S}=t,C=null;t.stale?C={label:l(`serverManagement.desktopStale`,`app state unknown (last seen {{when}})`,{when:$e(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&&!x&&!f.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 ${dr[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(W,{size:`sm`,onClick:()=>void b(),children:[i(d,{className:`h-3.5 w-3.5`}),l(`serverManagement.desktopInstallAction`,`Install update & restart`)]}),(f.isPending||x)&&e(`div`,{className:`flex items-center gap-2 text-sm text-warning`,children:[i(D,{className:`h-4 w-4 animate-spin`}),l(`serverManagement.desktopRestarting`,`The desktop app is restarting to install the update…`)]}),p!=null&&h&&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.`)}),_!=null&&i(`p`,{role:`status`,className:`text-xs text-warning`,children:_})]})}s();var pr=[[`serverManagement`,`getServerPackageStatus`]];function mr({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 hr({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 gr={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 _r(e){return e.outcome===`failed`?`error`:(e.outcome,e.accepted?`ok`:`warn`)}function vr(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 yr({node:t}){let{t:n}=q(),a=c(),s=k(),[l,u]=o(!1),[f,p]=o(null),m=t.isHub?void 0:{nodeId:t.id},h=Be(m,{refetchInterval:1e4,enabled:t.isOnline,retry:1}),g=h.data??null,_=r(()=>{a.invalidateQueries({queryKey:pr})},[a]),v=Se({onSettled:_}),y=Ke({onSettled:_}),b=je({onSettled:_}),x=r(async()=>{if(g?.latestVersion==null){p({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`)})){p(null);try{let e=await y.mutateAsync({version:g.latestVersion,...m});p({tone:_r(e),text:e.message}),e.restarting&&u(!0)}catch(e){p({tone:`warn`,text:vr(n,e)})}}},[y,s,t.name,m,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`})){p(null);try{let e=await b.mutateAsync(m);p({tone:_r(e),text:e.message}),e.restarting&&u(!0)}catch(e){p({tone:`warn`,text:vr(n,e)})}}},[s,t.name,b,m,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`,O=t.isOnline&&g!=null&&!E&&g.updateAvailable&&g.updateState===`idle`&&!y.isPending,A=t.isOnline&&g!=null&&g.updateState===`idle`&&!b.isPending,M=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(mr,{...w()})]}),M!=null&&i(mr,{...M})]}),!t.isOnline&&i($,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:t.rootPackage?.version??null}),t.isOnline&&h.isLoading&&e(`div`,{className:`flex items-center gap-2 text-sm text-foreground-subtle`,children:[i(D,{className:`h-4 w-4 animate-spin`}),n(`common.loading`,`Loading…`)]}),t.isOnline&&h.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(hr,{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(fr,{desktopApp:g.desktopApp,nodeName:t.name,routingInput:m,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).`)}),f!=null&&i(`p`,{role:`status`,className:`rounded border px-2 py-1.5 text-xs leading-relaxed ${gr[f.tone]}`,children:f.text}),l&&e(`div`,{className:`flex items-center gap-2 text-sm text-warning`,children:[i(D,{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(W,{variant:`unstyled`,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(m),children:[v.isPending?i(D,{className:`h-3.5 w-3.5 animate-spin`}):i(S,{className:`h-3.5 w-3.5`}),n(`serverManagement.checkForUpdate`,`Check for update`)]}),O&&e(W,{variant:`unstyled`,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 x(),children:[y.isPending?i(D,{className:`h-3.5 w-3.5 animate-spin`}):i(j,{className:`h-3.5 w-3.5`}),n(`serverManagement.updateTo`,`Update to {{version}}`,{version:g?.latestVersion??``})]}),e(W,{variant:`unstyled`,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:!A,onClick:()=>void C(),children:[b.isPending?i(D,{className:`h-3.5 w-3.5 animate-spin`}):i(d,{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(ae,{className:`h-3 w-3`}),n(`serverManagement.lastChecked`,`Last checked: {{when}}`,{when:new Date(g.lastCheckedAtMs).toLocaleString()})]})]})}s();function br(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 xr({node:t}){let{t:a}=q(),s=M(),u=c(),d=k(),[f,p]=o(!1),[m,h]=o(`info`),[g,_]=o(!1),[v,b]=o(null),x=t.processes??[],S=t.addons.map(e=>e.id),C=me(void 0),w=n(()=>{let e=C.data?.find(e=>e.nodeId===t.id);return br(e?.settings)},[C.data,t.id]),[T,E]=o(!1),[D,O]=o(null),[j,N]=o(null),P=r(async()=>{if(T||t.isHub)return;let e=Lt(t.localIps??[],w);if(e===null){O(`No LAN IPv4 on this node — open its :4444 URL by hand.`),N(null);return}let n=Bt();E(!0),O(null),N(null);try{let r=Nt(await s.trpcClient.addons.custom.mutate({addonId:`system-config`,action:`mintAgentUiUnlockTicket`,input:{nodeId:t.id,dashboardBaseUrl:Rt(e)}})),i=r===null?null:r.dashboardUrl??zt(e,r.ticket);if(i===null){n?.close(),O(`Hub did not return an unlock ticket.`);return}Vt(n,i)||(N(i),O(`Browser blocked the new tab — click the link below (or allow popups for this site).`))}catch(e){n?.close(),O(e instanceof Error?e.message:String(e))}finally{E(!1)}},[t.id,t.isHub,t.localIps,T,w,s.trpcClient]),F=async()=>{if(!g){_(!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{_(!1)}}},I=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)}}},L=t.isHub?null:e(W,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void I(),disabled:f,title:a(`cluster.nodeCard.unpairThisNodeRevokesIts`,`Unpair this node — revokes its certificates; it must be paired again to rejoin`),children:[i(se,{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(Ht,{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(W,{variant:`unstyled`,type:`button`,onClick:()=>void P(),disabled:T,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(A,{className:`h-3 w-3`}),T?a(`cluster.nodeCard.opening`,`Opening…`):a(`cluster.nodeCard.openDashboard`,`Open dashboard`)]}),L,e(`span`,{className:`flex items-center gap-1`,children:[i(ee,{className:`h-3 w-3`}),` `,t.cpuPercent,`%`]}),e(`span`,{className:`flex items-center gap-1`,children:[i(oe,{className:`h-3 w-3`}),` `,t.memoryPercent===null?a(`cluster.memoryUnknown`):`${t.memoryPercent}%`]})]})]}),v!=null&&i(`p`,{role:`status`,className:`px-4 pt-2 text-xs ${v.tone===`ok`?`text-success`:`text-warning`}`,children:v.text}),(D!==null||j!==null)&&e(`p`,{role:`status`,className:`px-4 pt-2 text-xs text-warning`,children:[D,j!==null&&e(l,{children:[` `,i(`a`,{href:j,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(W,{variant:`unstyled`,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($n,{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(rr,{nodeId:t.id,detectedHosts:t.localIps??[]}),i(`div`,{className:`border-t border-border pt-1`,children:i(yr,{node:{id:t.id,name:t.name,isHub:t.isHub,isOnline:t.isOnline,rootPackage:t.rootPackage??null}})}),i(lr,{node:{id:t.id,isHub:t.isHub,isOnline:t.isOnline}})]}),m===`forks`&&i(qt,{nodeId:t.id,processes:x}),m===`processes`&&i(Zt,{nodeId:t.id}),m===`load`&&i(Kn,{nodeId:t.id,isHub:t.isHub}),m===`settings`&&i(Xn,{nodeId:t.id,addonIds:S}),m===`capabilities`&&i(Zn,{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(Ht,{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:[L,e(W,{variant:`unstyled`,type:`button`,onClick:()=>void F(),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(y,{className:`h-3 w-3`}),g?a(`cluster.nodeCard.forgetting`,`Forgetting…`):a(`cluster.nodeCard.forgetNode`,`Forget node`)]})]})]}),v!=null&&i(`p`,{role:`status`,className:`px-4 pb-3 text-xs leading-relaxed ${v.tone===`ok`?`text-success`:`text-warning`}`,children:v.text})]})}var Sr=3,Cr=7e3,wr=36,Tr=5e3;function Er(e){return[...e].sort((e,t)=>e.isHub===t.isHub?0:e.isHub?-1:1)}function Dr(e){return e.isHub?{}:{nodeId:e.id}}function Or(e){return e.updateState===`staging`||e.updateState===`pending-restart`||e.pendingVersion!==null?!0:!e.updateAvailable}async function kr(e,t){let n=Dr(e),r=K.t(`helpers.clusterUpdateAll.noAnswer`);for(let i=1;i<=Sr;i+=1)try{let r=await t.readStatus(n);return Or(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<Sr&&await t.wait(Cr)}return{nodeId:e.id,nodeName:e.name,outcome:`unconfirmed`,detail:K.t(`helpers.clusterUpdateAll.unconfirmed`,{attempts:Sr,error:r})}}function Ar(e){return e.accepted?`applied`:e.outcome===`failed`?`failed`:`refused`}async function jr(e){for(let t=1;t<=wr;t+=1){try{let t=await e.readStatus({});if(!t.updateAvailable&&t.updateState===`idle`&&t.pendingVersion===null)return!0}catch{}t<wr&&await e.wait(Tr)}return!1}function Mr(e,t,n){return{nodeId:e.id,nodeName:e.name,outcome:`skipped`,detail:K.t(`helpers.clusterUpdateAll.skippedAfterHub`,{hub:t.name,why:n})}}async function Nr(e,t){let n=[],r=null;for(let i of Er(e)){if(r!==null){n.push(Mr(i,r.hub,r.why));continue}let a,o=!1;try{let e=await t.apply(Dr(i));o=e.outcome===`already-current`||e.reason===`already-running`,a={nodeId:i.id,nodeName:i.name,outcome:Ar(e),detail:e.message}}catch{a=await kr(i,t)}if(n.push(a),i.isHub){let s=n.length===e.length;o||(a.outcome===`applied`?!s&&!await jr(t)&&(r={hub:i,why:K.t(`helpers.clusterUpdateAll.hubNotSettled`)}):r={hub:i,why:a.outcome})}}return n}s();function Pr(){let{nodes:e,isLoading:t}=Ge(),r=n(()=>e??[],[e]);return{nodes:r,isLoading:t&&r.length===0}}var Fr={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`,skipped:`border-warning/40 bg-warning/10 text-warning`};function Ir(){let{t}=q(),s=k(),{nodes:c,isLoading:d}=Pr(),[f,p]=Ze(),{selection:m,selectNode:h}=st(c),g=m.node,_=n(()=>c.filter(e=>e.isOnline),[c]),v=_.length,y=c.filter(e=>!e.isOnline).length,b=Ke(),x=M(),[S,C]=o(!1),[w,T]=o([]),E=f.get(`unlockNode`),O=f.get(`returnTo`),[A,N]=o(null);a(()=>{if(E===null||O===null)return;let e=!1;return(async()=>{try{let t=await x.trpcClient.addons.custom.mutate({addonId:`system-config`,action:`mintAgentUiUnlockTicket`,input:{nodeId:E,dashboardBaseUrl:O}});if(e)return;let n=Nt(t),r=n===null?null:n.dashboardUrl??(()=>{let e=new URL(O);return e.searchParams.set(`ticket`,n.ticket),e.toString()})();if(r===null){N(`Could not mint an unlock ticket.`);return}let i=new URLSearchParams(f);i.delete(`unlockNode`),i.delete(`returnTo`),p(i,{replace:!0}),window.location.assign(r)}catch(t){e||N(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[E,O,f,p,x.trpcClient]);let ee=r(async()=>{let e=_.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, hub first, then the agents once the hub runs the new version. Up-to-date nodes are skipped; this page reconnects when the hub comes back.`),confirmLabel:t(`serverManagement.confirmUpdateAllAction`,`Update all & restart`),variant:`warning`})){C(!0),T([]);try{T(await Nr(e,{apply:e=>b.mutateAsync(e),readStatus:e=>x.trpcClient.serverManagement.getServerPackageStatus.query(e),wait:e=>new Promise(t=>setTimeout(t,e))}))}finally{C(!1)}}},[b,s,_,x,t]);return e(et,{icon:u,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:[v>0&&i(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-xs text-success`,children:t(`common.onlineCount`,{count:v})}),y>0&&i(`span`,{className:`rounded-full bg-destructive/10 px-2 py-0.5 text-xs text-destructive`,children:t(`common.offlineCount`,{count:y})}),v>1&&e(W,{type:`button`,size:`sm`,disabled:S,title:t(`serverManagement.updateAllHint`,`Sequenced hub-first, agents after — up-to-date nodes are skipped.`),onClick:()=>void ee(),children:[S?i(D,{className:`h-3.5 w-3.5 animate-spin`}):i(j,{className:`h-3.5 w-3.5`}),t(`serverManagement.updateAll`,`Update all nodes`)]})]}),children:[w.length>0&&i(`ul`,{"aria-label":`update-all-report`,className:`flex flex-col gap-1 text-xs`,children:w.map(t=>e(`li`,{"data-outcome":t.outcome,className:`rounded border px-2 py-1 ${Fr[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))}),A!==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:`),` `,A]}),i(jt,{onOpenNode:h}),d?i(`div`,{className:`flex items-center justify-center py-12 text-muted-foreground`,children:t(`system.cluster.loadingClusterTopology`,`Loading cluster topology...`)}):g===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(ot,{staleNodeId:m.staleNodeId,shownNodeName:g.name}),i(Oe,{selectedNodeId:g.id,onSelect:h,allowOffline:!0,alwaysShow:!0}),i(xr,{node:g})]})]})}export{Ir as ClusterPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,K as t,S as n,Y as r,et as i,i 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{En as s,Kt as c,Li as l,Nr as u,Pn as d,br as f,bt as p,ct as m,ht as h,lt as g,xa as _}from"./player-overlays-CC-b3--a.js";import{Jr as v,No as y}from"./client-kWeONSGL.js";import{A as b,Af as x,An as S,B as C,Bn as w,Br as T,D as E,Di as D,Fr as O,Go as k,H as A,I as j,Ir as M,L as ee,Ln as N,Lr as te,M as ne,N as re,O as ie,P as ae,Qr as P,R as oe,S as se,T as ce,U as le,V as ue,Vr as de,W as fe,Xr as F,Yr as I,Zr as pe,b as me,di as L,ii as he,j as R,kn as ge,nd as _e,qr as ve,si as z,vo as ye,w as be,x as xe,yi as B,yo as Se,z as Ce,zn as V,zr as we}from"./src-DGSNF4l8.js";import{t as H}from"./useTranslation-BJr-n0es.js";import{Br as Te}from"./index-DwCHDODI.js";import{t as Ee}from"./AdminPage-dLt1mKEa.js";i();function U(e,t){return e.scope===``?e.displayName:`${e.displayName} · ${t?.(e)??e.scope}`}function De(e,t,n){let r=[];for(let{device:t,series:i}of e)for(let e of i){let i={subject:{kind:`device`,deviceId:t.id},key:e.key,scope:e.scope};r.push({id:R(i),ref:i,info:e,subjectName:t.name,location:t.location??``,nodeId:``,metric:U(e,n)})}for(let{node:e,series:i}of t)for(let t of i){let i={subject:{kind:`node`,nodeId:e.id},key:t.key,scope:t.scope};r.push({id:R(i),ref:i,info:t,subjectName:e.name,location:``,nodeId:e.id,metric:U(t,n)})}return r}function Oe(e){return[e.subjectName,e.location,e.metric,e.info.key,e.info.unit??``,e.nodeId].join(` `)}function W(e,t,n){if(e.ref.subject.kind!==`device`||t===null)return e.subjectName;let r=t.byId.get(e.ref.subject.deviceId);return r===void 0?e.subjectName:he(r,`compact`,t,n)}var ke=[`energy`,`temperatures`,`nodes`,`storage`],Ae=new Set([`cap:temperature-sensor.temperature`,`cap:climate-control.currentTemp`]),G=[`addon:metrics-native/node-cpu-percent`,`addon:metrics-native/node-memory-percent`],je=`addon:storage-orchestrator/location-used-percent`;function Me(e,t){let n=(e,n)=>{let r=t.filter(e);return b((n?[...r].sort(n):r).map(e=>e.ref))};switch(e){case`energy`:return n(e=>e.ref.subject.kind===`device`&&e.info.key===`derived:energy.kwh`);case`temperatures`:return n(e=>e.ref.subject.kind===`device`&&Ae.has(e.info.key)&&e.info.scope===``,(e,t)=>e.location.localeCompare(t.location)||e.subjectName.localeCompare(t.subjectName));case`nodes`:return n(e=>e.ref.subject.kind===`node`&&G.includes(e.info.key)&&e.info.scope===``,(e,t)=>G.indexOf(e.info.key)-G.indexOf(t.info.key)||e.subjectName.localeCompare(t.subjectName));case`storage`:return n(e=>e.ref.subject.kind===`node`&&e.info.key===je)}}function Ne(e,t){let n=new Map(t.map(e=>[e.id,e])),r=[],i=[],a=[],o=[];for(let t of b(e)){let e=n.get(R(t));if(e===void 0){o.push(t);continue}e.info.key===`derived:energy.kwh`?a.push(e):e.info.kind===`boolean`||e.info.kind===`enum`?i.push(e):r.push(e)}return{lines:r,states:i,energy:a,missing:o}}function K(e){return e.subject.kind===`device`?{deviceId:e.subject.deviceId,key:e.key,scope:e.scope}:{forNodeId:e.subject.nodeId,key:e.key,scope:e.scope}}var q=`history-page`;function Pe({part:r,window:i}){let{t:a}=H(),o=_(),s=L(),c=z(),u=e=>`${W(e,s,c)} · ${e.metric}`,d=t(()=>[...r.lines,...r.states,...r.energy],[r]),f=be(t(()=>d.map(e=>K(e.ref)),[d]),i,!1),p=e=>f.status===`ok`?f.data.current.get(se(K(e.ref))):void 0,m=e=>{let t=p(e);return t?.ok?t.result:void 0};if(d.length===0)return n(F,{icon:l,title:a(`history.page.emptyTitle`,`Pick series to compare`),description:a(`history.page.emptyHint`,`Choose up to 24 series on the left, or start from a panel above.`)});if(f.status===`error`)return n(I,{title:a(`history.page.readFailed`,`History could not be read`),message:f.error});let h=f.status===`pending`,g=d.map(e=>({c:e,e:p(e)})).filter(e=>e.e?.ok===!1),v=r.lines.map((e,t)=>{let n=m(e),r=ee(e.info,n,i.from);return{id:e.id,label:u(e),unit:e.info.unit,colorIndex:t,points:r.points,gapMs:r.gapMs,interpolation:r.held&&n?.resolution===`raw`?`step`:`linear`}}),y=r.states.map((e,t)=>{let n=oe(e.info,m(e),i.from,i.to),r=ae(e.info.key,o);return{id:e.id,label:u(e),kind:e.info.kind===`boolean`?`boolean`:`enum`,colorIndex:e.info.kind===`boolean`?t:0,states:n.states,segments:n.segments,totals:n.totals,stateLabel:e.info.kind===`boolean`?e=>e===`true`?r.on:r.off:void 0}}),b=r.energy.map(e=>({c:e,...j(m(e))})),x=b[0]?.bucketMs??36e5,S=[...new Set(b.flatMap(e=>e.buckets.map(e=>e.t)))].sort((e,t)=>e-t).map(e=>({t:e,values:b.map(t=>t.buckets.find(t=>t.t===e)?.values[0]??null)}));return e(`div`,{className:`space-y-5 min-w-0`,children:[g.length>0&&n(I,{title:a(`history.page.someFailed`,`Some series could not be read`),message:g.map(e=>`${u(e.c)}: ${e.e.error}`).join(` · `)}),v.length>0&&n(fe,{title:a(`history.page.lines`,`Measurements`),series:v,range:i,height:260,syncKey:q,pending:h}),b.length>0&&n(ve,{title:a(`history.page.energy`,`Energy`),layers:b.map((e,t)=>({id:e.c.id,label:W(e.c,s,c),colorIndex:t})),buckets:S,bucketMs:x,range:i,unit:`kWh`,showTotal:!0,height:160,syncKey:q,pending:h}),y.length>0&&n(le,{title:y.length===1?y[0]?.label??``:a(`history.page.states`,`States`),rows:y,range:i,syncKey:q,pending:h})]})}function Fe(e,t){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}async function Ie(e,t){let n=[];for(let r of Fe(e,50))try{let{results:e}=await t(r),i=new Map(e.map(e=>[e.seriesId,e]));for(let e of r)n.push(i.get(e)??{seriesId:e,ok:!1,reason:`not-found`})}catch(e){let t=e instanceof Error?e.message:String(e);for(let e of r)n.push({seriesId:e,ok:!1,reason:`request-failed`,message:t})}return n}function J(e){return e.raw+e[`5m`]+e[`1h`]+e[`1d`]}function Le(e){return e.reduce((e,t)=>t.ok?{...e,deleted:e.deleted+1,points:e.points+J(t.deleted)}:{...e,refused:e.refused+1},{deleted:0,refused:0,points:0})}function Re(e,t){let n=new Map(e.map(e=>[e.seriesId,e]));return t.flatMap(e=>{let t=n.get(e.seriesId);return t===void 0?[]:[{series:t,outcome:e}]})}var Y=e=>new Date(e).toLocaleDateString(void 0,{dateStyle:`short`});function X(e,t,n){let r=t.get(e.deviceId);return r===void 0?e.reason===`device-gone`?n(`history.orphans.deviceRemoved`,`#{{id}} (removed)`,{id:e.deviceId}):n(`history.orphans.deviceId`,`#{{id}}`,{id:e.deviceId}):r}function Z(e){let t=e.displayName??e.key;return e.scope===``?t:`${t} · ${e.scope}`}function Q(t,r,i){return{key:`series`,header:i(`history.orphans.colSeries`,`Series`),render:a=>{let o=t(a);return e(`div`,{className:`min-w-0 max-w-[16rem]`,children:[n(`div`,{className:`truncate text-foreground`,title:o.key,children:Z(o)}),n(`div`,{className:`truncate text-[10px] text-foreground-subtle`,children:X(o,r,i)})]})},sortValue:e=>`${X(t(e),r,i)} ${Z(t(e))}`}}var ze=[`raw`,`5m`,`1h`,`1d`];function Be(e,t){return e===`raw`?t(`history.orphans.colRaw`,`Raw points`):e===`5m`?t(`history.orphans.col5m`,`5 min`):e===`1h`?t(`history.orphans.col1h`,`1 h`):t(`history.orphans.col1d`,`1 day`)}function Ve(t,r){return[Q(e=>e,t,r),{key:`reason`,header:r(`history.orphans.colReason`,`Reason`),render:t=>e(`div`,{className:`flex flex-col items-start gap-0.5`,children:[n(D,{variant:t.reason===`device-gone`?`warning`:`neutral`,className:`text-[10px]`,children:t.reason===`device-gone`?r(`history.orphans.deviceGone`,`Device removed`):r(`history.orphans.undeclared`,`No longer declared`)}),t.missingSince!==null&&n(`span`,{className:`text-[10px] text-foreground-subtle`,children:r(`history.orphans.since`,`since {{date}}`,{date:Y(t.missingSince)})})]}),sortValue:e=>e.reason},{key:`span`,header:r(`history.orphans.colSpan`,`Recorded`),render:t=>e(`span`,{className:`tabular-nums text-foreground-muted`,children:[Y(t.firstTs),` → `,Y(t.lastTs)]}),sortValue:e=>e.lastTs},...ze.map(e=>({key:`rows-${e}`,header:Be(e,r),align:`right`,render:t=>n(`span`,{className:`tabular-nums text-foreground-muted`,children:t.rows[e].toLocaleString()}),sortValue:t=>t.rows[e]}))]}function He(e,t){if(e.ok)return n(D,{variant:`success`,className:`text-[10px]`,children:t(`history.orphans.deleted`,{count:J(e.deleted),points:J(e.deleted).toLocaleString(),defaultValue_one:`Deleted · {{points}} point`,defaultValue_other:`Deleted · {{points}} points`})});let r=e.reason===`request-failed`?t(`history.orphans.requestFailed`,`Not sent: {{message}}`,{message:e.message}):e.reason===`not-orphan`?t(`history.orphans.refusedNotOrphan`,`Kept: no longer orphan`):e.reason===`not-found`?t(`history.orphans.refusedNotFound`,`Already gone`):t(`history.orphans.refusedFailed`,`The hub could not delete it`);return n(D,{variant:e.reason===`not-found`?`neutral`:`warning`,className:`text-[10px]`,children:r})}function Ue(e,t){return[Q(e=>e.series,e,t),{key:`result`,header:t(`history.orphans.colResult`,`Result`),render:e=>He(e.outcome,t),sortValue:e=>+!e.outcome.ok}]}i();function We({open:i,onClose:a,list:o,deviceNames:s,onDelete:l,onRefresh:u,refreshing:p}){let{t:h}=H(),g=m(),[_,v]=r(new Set),[y,b]=r(!1),[x,S]=r([]),C=t(()=>Ve(s,h),[s,h]),E=t(()=>Ue(s,h),[s,h]),D=t(()=>new Set(o.series.map(e=>String(e.seriesId))),[o.series]),k=[..._].filter(e=>D.has(e)).map(Number),A=Le(x.map(e=>e.outcome)),j=async()=>{if(await g({title:h(`history.orphans.confirmTitle`,{count:k.length,defaultValue_one:`Delete {{count}} series`,defaultValue_other:`Delete {{count}} series`}),message:h(`history.orphans.confirmMessage`,`Every recorded point of these series is removed from the hub. This cannot be undone.`),confirmLabel:h(`history.orphans.confirmLabel`,`Delete`),variant:`danger`})){b(!0);try{let e=await Ie(k,l);S(Re(o.series,e)),v(new Set)}finally{b(!1),u()}}};return n(O,{open:i,onOpenChange:e=>!e&&a(),children:e(te,{width:`xl`,placement:`sheet-on-mobile`,scroll:`body`,"data-testid":`orphan-series-dialog`,children:[n(T,{children:n(de,{children:h(`history.orphans.title`,`Series no longer linked to a device`)})}),e(M,{className:`space-y-3`,children:[n(`p`,{className:`text-xs text-foreground-muted`,children:h(`history.orphans.intro`,`Nothing records into these series any more: their device was removed, or no capability declares them now. Select the ones to delete.`)}),o.truncated&&e(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`orphan-truncated`,children:[n(`p`,{className:`text-xs text-warning`,children:h(`history.orphans.truncated`,`More series are unlinked than are listed here. Delete these, then load the rest.`)}),e(B,{size:`sm`,variant:`outline`,onClick:u,disabled:p,children:[n(d,{className:`h-3 w-3`,"aria-hidden":!0}),h(`history.orphans.loadAgain`,`Load again`)]})]}),x.length>0&&e(`div`,{className:`space-y-2`,"data-testid":`orphan-outcomes`,children:[n(`p`,{className:`text-xs text-foreground`,"aria-live":`polite`,children:h(`history.orphans.summary`,{count:A.deleted,refused:A.refused,points:A.points.toLocaleString(),defaultValue_one:`{{count}} series deleted ({{points}} points), {{refused}} kept.`,defaultValue_other:`{{count}} series deleted ({{points}} points), {{refused}} kept.`})}),n(V,{columns:E,rows:x,rowKey:e=>String(e.series.seriesId),minWidthPx:420,maxBodyHeight:`max-h-[60vh]`,emptyMessage:``})]}),n(V,{columns:C,rows:o.series,rowKey:e=>String(e.seriesId),minWidthPx:760,maxBodyHeight:w,defaultSort:{columnKey:`series`,dir:`asc`},emptyMessage:h(`history.orphans.empty`,`Every series is linked to a device.`),selection:{selected:_,onChange:v,rowLabel:e=>`${Z(e)} — ${X(e,s,h)}`,pageLabel:h(`history.orphans.selectAll`,`Select every listed series`)}})]}),e(we,{children:[n(`span`,{className:`mr-auto text-[11px] tabular-nums text-foreground`,"aria-live":`polite`,children:h(`history.orphans.selected`,{count:k.length,defaultValue_one:`{{count}} selected`,defaultValue_other:`{{count}} selected`})}),n(B,{variant:`ghost`,size:`sm`,onClick:a,children:h(`history.orphans.close`,`Close`)}),e(B,{variant:`danger`,size:`sm`,disabled:k.length===0||y,onClick:()=>void j(),children:[y?n(f,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):n(c,{className:`h-3 w-3`,"aria-hidden":!0}),h(`history.orphans.deleteSelected`,`Delete selected`)]})]})]})})}i();var Ge=5*6e4;function Ke({enabled:i}){let{t:a}=H(),[s,c]=r(!1),l=Se({},{enabled:i,staleTime:Ge}),u=k({projection:`slim`},{enabled:i}),d=ye(),f=t(()=>new Map((u.data??[]).map(e=>[e.id,e.name])),[u.data]),p=e=>d.mutateAsync({seriesIds:[...e]});if(!i||l.status===`pending`)return null;if(l.status===`error`)return n(I,{variant:`warning`,title:a(`history.orphans.checkFailedTitle`,`Could not check for unlinked series`),message:l.error.message,onRetry:()=>void l.refetch()});let m=l.data;if(m.series.length===0&&!s)return null;let h=m.series.length;return e(o,{children:[h>0&&n(I,{variant:`warning`,message:m.truncated?a(`history.orphans.noticeMore`,{count:h,defaultValue_one:`More than {{count}} series are no longer linked to a device.`,defaultValue_other:`More than {{count}} series are no longer linked to a device.`}):a(`history.orphans.notice`,{count:h,defaultValue_one:`{{count}} series is no longer linked to a device.`,defaultValue_other:`{{count}} series are no longer linked to a device.`}),action:n(B,{size:`sm`,variant:`outline`,onClick:()=>c(!0),children:a(`history.orphans.review`,`Review`)})}),n(We,{open:s,onClose:()=>c(!1),list:m,deviceNames:f,onDelete:p,onRefresh:()=>void l.refetch(),refreshing:l.isFetching})]})}i();var qe=`device`,Je=`node`;function Ye({catalog:r,selected:i,onChange:a,loading:o}){let{t:s}=H(),c=L(),l=z(),u=e=>W(e,c,l),d=ge(r,{searchText:e=>[Oe(e)],facetGroups:[{id:`subject`,value:e=>e.ref.subject.kind===`device`?qe:Je},{id:`room`,value:e=>e.location},{id:`unit`,value:e=>e.info.unit??``}]}),f=t(()=>[{key:`metric`,header:s(`history.picker.series`,`Series`),render:t=>e(`div`,{className:`min-w-0`,children:[n(`div`,{className:`truncate text-foreground`,children:t.metric}),n(`div`,{className:`truncate text-[10px] text-foreground-subtle`,children:t.location===``?u(t):`${u(t)} · ${t.location}`})]}),sortValue:e=>`${e.subjectName} ${e.metric}`},{key:`unit`,header:s(`history.picker.unit`,`Unit`),render:e=>n(`span`,{className:`text-foreground-muted`,children:e.info.unit??`—`}),sortValue:e=>e.info.unit??``}],[s,c,l]),p=i.size>=24;return e(`div`,{className:`space-y-2 min-w-0`,children:[n(S,{state:d.state,facets:[],groups:[{...d.groups.find(e=>e.id===`subject`)??{id:`subject`,facets:[],selected:[]},label:s(`history.picker.subject`,`Source`),facetLabel:e=>e===qe?s(`history.picker.devices`,`Devices`):s(`history.picker.nodes`,`Nodes`)},{...d.groups.find(e=>e.id===`room`)??{id:`room`,facets:[],selected:[]},label:s(`history.picker.room`,`Room`),facetLabel:e=>e===``?s(`history.picker.noRoom`,`No room`):e},{...d.groups.find(e=>e.id===`unit`)??{id:`unit`,facets:[],selected:[]},label:s(`history.picker.metricType`,`Unit`),facetLabel:e=>e===``?s(`history.picker.noUnit`,`States & counts`):e}],labels:{searchPlaceholder:s(`history.picker.search`,`Search device, room, metric or node…`),searchLabel:s(`history.picker.searchLabel`,`Search series`),facetsLabel:s(`history.picker.facets`,`Filters`),clearLabel:s(`history.picker.clear`,`Clear`)},onSearch:d.setSearch,onToggleFacet:d.toggleFacet,onToggleGroupFacet:d.toggleGroupFacet,onClear:d.clear}),n(`p`,{className:`text-[10px] text-foreground-subtle`,"aria-live":`polite`,children:s(`history.picker.count`,`{{count}} of {{max}} selected`,{count:i.size,max:24})}),n(V,{columns:f,rows:d.rows,rowKey:e=>e.id,maxBodyHeight:w,pageSize:50,defaultSort:{columnKey:`metric`,dir:`asc`},emptyMessage:o?s(`history.picker.loading`,`Reading the series of every device…`):d.active?s(`history.picker.emptyFiltered`,`No series match these filters.`):s(`history.picker.empty`,`Nothing is recorded yet.`),selection:{selected:i,onChange:e=>{let t=[...e].filter(e=>i.has(e)),n=[...e].filter(e=>!i.has(e));a(new Set([...t,...n].slice(0,24)))},isSelectable:e=>i.has(e.id)||!p,rowLabel:e=>`${u(e)} · ${e.metric}`,pageLabel:s(`history.picker.selectPage`,`Select every series on this page`)}})]})}i();var Xe=new Set([y.Hub,y.Container]),$=5*6e4;function Ze(){let{t:r}=H(),i=pe(`device-history`),[a,o]=Te(),c=t(()=>b(a.getAll(`s`).flatMap(e=>{let t=E(e);return t===null?[]:[t]})),[a]),d=a.get(`window`),f=ue(d)?d:`7d`,h=Ce(a.get(`range`)),_=(e,t,n)=>{let r=new URLSearchParams;for(let t of b(e))r.append(`s`,ie(t));t!==`7d`&&r.set(`window`,t);let i=n===void 0?a.get(`range`):n;t===`custom`&&i&&r.set(`range`,i),o(r,{replace:!0})},v=Qe(i===`present`),y=A(f,Date.now(),h),x=A(f,xe(Date.now(),y.to-y.from),h),S=t(()=>Ne(c,v.candidates),[c,v.candidates]),w=t(()=>new Set(c.map(R)),[c]),T=me(),D=g(),O=m(),k=async()=>{let e=await D({title:r(`history.page.saveTitle`,`Save as panel`),label:r(`history.page.saveName`,`Panel name`),confirmLabel:r(`history.page.save`,`Save`)});e===null||e.trim()===``||await T.update(t=>ne(t,{id:`panel-${Date.now().toString(36)}`,name:e.trim().slice(0,80),window:f,selection:[...c]}))},j=async(e,t)=>{await O({title:r(`history.page.deleteTitle`,`Delete panel`),message:r(`history.page.deleteMessage`,`The panel "{{name}}" is removed from your account.`,{name:t}),confirmLabel:r(`history.page.delete`,`Delete`),variant:`danger`})&&await T.update(t=>re(t,e))},M=e=>e===`energy`?r(`history.panels.energy`,`Total energy`):e===`temperatures`?r(`history.panels.temperatures`,`Temperatures by room`):e===`nodes`?r(`history.panels.nodes`,`Cluster nodes`):r(`history.panels.storage`,`Storage locations`);return n(Ee,{icon:l,title:r(`history.page.title`,`History`),subtitle:r(`history.page.subtitle`,`What devices, nodes and storage recorded over time, side by side.`),actions:i===`present`?e(B,{size:`sm`,variant:`outline`,onClick:()=>void k(),disabled:c.length===0||!T.writable,children:[n(s,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),r(`history.page.saveTitle`,`Save as panel`)]}):void 0,children:i===`pending`?n(P,{className:`h-64 w-full`}):i===`unknown`?n(I,{title:r(`history.page.presenceUnknownTitle`,`Could not reach the hub`),message:r(`history.page.presenceUnknown`,`The hub did not say whether device history is installed. Try again in a moment.`)}):i===`absent`?n(F,{icon:u,title:r(`history.page.absentTitle`,`Device history is not running on this hub`),description:r(`history.page.absent`,`Nothing is recorded until the device-history system addon is enabled.`)}):e(`div`,{className:`space-y-3 sm:space-y-4`,children:[n(Ke,{enabled:i===`present`}),e(`div`,{className:`flex flex-wrap items-center gap-2`,role:`group`,"aria-label":r(`history.page.panels`,`Panels`),children:[ke.map(e=>n(B,{size:`sm`,variant:`outline`,disabled:v.status!==`ok`,onClick:()=>_(Me(e,v.candidates),f),children:M(e)},e)),T.value.panels.map(t=>e(`span`,{className:`inline-flex items-center`,children:[n(B,{size:`sm`,variant:`secondary`,onClick:()=>_(t.selection,t.window,null),children:t.name}),n(B,{size:`sm`,variant:`ghost`,"aria-label":r(`history.page.deleteNamed`,`Delete panel {{name}}`,{name:t.name}),onClick:()=>void j(t.id,t.name),disabled:!T.writable,children:n(p,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})]},t.id))]}),e(`div`,{className:`grid grid-cols-1 gap-3 sm:gap-4 xl:grid-cols-5`,children:[n(`div`,{className:`min-w-0 xl:col-span-2`,children:n(N,{headingId:`history-picker`,title:r(`history.picker.title`,`Series`),children:n(`div`,{className:`p-2 sm:p-3`,children:v.status===`error`?n(I,{message:v.error}):n(Ye,{catalog:v.candidates,loading:v.status===`pending`,selected:w,onChange:e=>{let t=c.filter(t=>e.has(R(t))),n=v.candidates.filter(t=>e.has(t.id)&&!w.has(t.id)).map(e=>e.ref);_([...t,...n],f)}})})})}),n(`div`,{className:`min-w-0 xl:col-span-3`,children:n(N,{headingId:`history-overlay`,title:r(`history.page.overlay`,`Overlay`),actions:c.length>0?n(B,{size:`sm`,variant:`ghost`,onClick:()=>_([],f),children:r(`history.page.clear`,`Clear`)}):void 0,children:e(`div`,{className:`p-2 sm:p-3 space-y-3 min-w-0`,children:[n(ce,{value:f,onChange:e=>_(c,e),custom:h,onCustomChange:e=>_(c,`custom`,C(e))}),v.status===`pending`&&c.length>0?n(P,{className:`h-64 w-full`}):n(Pe,{part:S,window:x}),S.missing.length>0&&v.status===`ok`&&n(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`history.page.missing`,{count:S.missing.length,defaultValue_one:`{{count}} selected series is no longer recorded.`,defaultValue_other:`{{count}} selected series are no longer recorded.`})})]})})})]})]})})}function Qe(e){let{t:n}=H(),r=n(`history.picker.wholeFrame`,`Whole frame`),i=h().trpcClient,o=k({projection:`slim`},{enabled:e}),{nodes:s}=x(),c=t(()=>(o.data??[]).filter(e=>!Xe.has(String(e.type))),[o.data]),l=a({queries:c.map(t=>({queryKey:[`device-history`,`listSeries`,t.id],queryFn:()=>i.deviceHistory.listSeries.query({deviceId:t.id}),enabled:e,staleTime:$}))}),u=a({queries:s.map(t=>({queryKey:[`device-history`,`listNodeSeries`,t.id],queryFn:()=>i.deviceHistory.listNodeSeries.query({forNodeId:t.id}),enabled:e,staleTime:$}))}),d=_e({},{enabled:e,staleTime:$}),f=t(()=>new Map((d?.data??[]).map(e=>[e.id,e.displayName])),[d?.data]),p=l.map(e=>e.data),m=u.map(e=>e.data),g=t(()=>De(c.flatMap((e,t)=>{let n=p[t];return n===void 0?[]:[{device:{id:e.id,name:e.name,location:e.location??null},series:n}]}),s.flatMap((e,t)=>{let n=m[t];return n===void 0?[]:[{node:{id:e.id,name:e.name},series:n}]}),e=>{if(e.key!==`addon:pipeline-analytics/occupancy`)return f.get(e.scope)??e.scope;let{zoneId:t,className:n}=v(e.scope),i=t===``?r:t;return n===void 0?i:`${i} · ${n}`}),[c,s,f,[...l,...u].map(e=>e.dataUpdatedAt).join(`,`),r]);return o.status===`error`?{status:`error`,error:o.error.message,candidates:[]}:{status:o.status===`pending`||l.some(e=>e.isPending)||u.some(e=>e.isPending)?`pending`:`ok`,error:``,candidates:g}}export{Ze as HistoryPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,S as r,V as i,Y as a,a 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{Cr as u,D as d,Ft as f,Kt as p,Oi as m,Or as h,Pn as g,Qr as _,Sn as v,Un as y,Ut as b,Yn as x,_r as S,aa as C,br as w,bt as T,ct as E,gn as D,ht as O,ii as ee,ln as k,lt as te,ut as ne,vn as re,wn as ie,yn as ae}from"./player-overlays-CC-b3--a.js";import{Fo as A,Po as oe,l as se}from"./client-kWeONSGL.js";import{c as j,f as M,h as ce,r as N}from"./video-b4uGYAxS.js";import{t as le}from"./file-up-CODncsO3.js";import{t as ue}from"./key-BSgMvX5L.js";import{t as de}from"./monitor-smartphone-CrChoiUo.js";import{t as fe}from"./unlink-DzO14DVn.js";import{Bd as pe,Bn as me,Br as P,Cc as he,Dc as ge,Di as F,Dt as _e,Ff as I,Fr as L,Ft as R,Gd as ve,Go as z,Hd as ye,Ir as B,Jd as be,Kd as xe,Ln as V,Lr as H,Mn as Se,Nr as Ce,Oc as we,Rn as U,Tt as Te,Ud as Ee,Vd as De,Vr as W,Wd as Oe,Xd as ke,Xr as Ae,Yd as je,Yr as G,Z as Me,af as Ne,ar as Pe,bc as Fe,gt as Ie,if as Le,ir as Re,jn as ze,lr as Be,of as Ve,or as He,qd as Ue,rf as We,rr as Ge,sf as Ke,sr as qe,tr as Je,ur as Ye,vc as Xe,yi as K,zd as Ze,zn as Qe,zr as $e}from"./src-DGSNF4l8.js";import{t as q}from"./i18n-Cmy3cCDH.js";import{t as J}from"./useTranslation-BJr-n0es.js";import{Br as et,I as tt,Ir as nt,Rr as rt,S as it,a as at,d as ot,i as st,l as ct,t as lt}from"./index-DwCHDODI.js";import{t as ut}from"./AdminSectionedPage-BYn7-4dT.js";import{t as dt}from"./AdminPage-dLt1mKEa.js";import{C as ft,D as Y,E as pt,O as X,S as mt,T as ht,_ as gt,a as _t,b as vt,c as yt,d as bt,f as xt,g as St,h as Ct,i as wt,k as Tt,l as Et,m as Dt,n as Ot,o as kt,p as At,s as jt,t as Mt,u as Nt,v as Pt,w as Ft,x as It,y as Lt}from"./SessionsList-CLTlUoNj.js";import{r as Rt}from"./IntegrationHub-jVzJirPk.js";import{n as zt}from"./Authentication-CykaHfAJ.js";s();function Bt(){let{t:e}=J(),t=E(),i=I.useUtils(),o=Tt(),{data:s,isLoading:c}=ve(),l=n(()=>s??[],[s]),u=I.useQueries(e=>l.map(t=>e.userManagement.listExternalIdentities({userId:t.id}))),d=I.auth.listLoginMethods.useQuery(),[f,p]=a(null),m=je({onSuccess:()=>void i.userManagement.listExternalIdentities.invalidate(),onError:e=>p(`Remove failed: ${e.message}`)}),h=n(()=>new Map((d.data??[]).flatMap(e=>e.kind===`redirect`?[[e.id,e.label]]:[])),[d.data]),g=l.flatMap((e,t)=>u[t]?.data??[]),_=g.map(e=>({...It(e,o),kind:h.get(e.provider)??e.provider})),v=async n=>{let r=g.find(e=>vt(e)===n.id);r!==void 0&&await t({title:e(`access.externalIdentitiesSection.removeSignInLink`,`Remove sign-in link`),message:e(`access.externalIdentitiesSection.willNoLongerBeAble`,`"{{ownerName}}" will no longer be able to sign in with this {{kind}} account.`,{ownerName:n.ownerName,kind:n.kind}),confirmLabel:e(`common.remove`,`Remove`),variant:`danger`})&&(p(null),m.mutate({userId:r.userId,provider:r.provider,subject:r.subject}))};return r(Y,{notice:X(f),onDismissNotice:()=>{p(null)},id:`external-identities`,title:e(`access.externalIdentitiesSection.signInLinks`,`Sign-in links`),icon:ce,description:e(`access.externalIdentitiesSection.externalAccountsSingleSignOn`,`External accounts (single sign-on) each user linked to their CamStack account. Only the owner can link one, from their profile; an admin can remove it.`),children:r(Ft,{rows:_,label:`sign-in links`,isLoading:c||u.some(e=>e.isLoading),loadError:u.find(e=>e.isError)?.error?.message??null,emptyText:`No user has linked a sign-in account.`,expiresNone:`—`,action:{label:e(`common.remove`,`Remove`),icon:fe,isAvailable:()=>!0,onRun:e=>void v(e),busyId:null,disabled:m.isPending}})})}s();var Vt={key:`access.nouns.linkedApp`};function Ht(e){if(e.type===`category`){let t=e.target??``;return t===`device`?q.t(`access.linkedAppsSection.allDevices`):q.t(`access.linkedAppsSection.allTarget`,{target:t})}if(e.type===`device`)return`device:[${(e.targets??[]).join(`,`)}]`;let t=e;return`${t.type}:${t.target??``}`}function Ut(){let{t:e}=J(),t=E(),i=c(),o=Oe(),[s,l]=a(null),d=()=>void i.invalidateQueries({queryKey:[[`userManagement`,`listOauthSessions`]]}),f=Ue({onSuccess:d,onError:e=>l(`Revoke failed: ${e.message}`)}),m=ht(Vt,d),h=n(()=>(o.data??[]).map(e=>mt(e,e.scopes.map(Ht).join(`, `))),[o.data]),g=async n=>{await t({title:e(`access.linkedAppsSection.revokeTheLink`,`Revoke the "{{name}}" link?`,{name:n.name}),message:e(`access.linkedAppsSection.losesAccessForOnIts`,`{{name}} loses access for {{ownerName}} on its next call. Linking it again needs the account-link flow from the start.`,{name:n.name,ownerName:n.ownerName}),confirmLabel:e(`access.linkedAppsSection.revoke`,`Revoke`),variant:`danger`})&&(l(null),f.mutate({id:n.id}))},_=f.isPending?f.variables?.id??null:null;return r(Y,{notice:X(s,m.outcome),onDismissNotice:()=>{l(null),m.dismiss()},id:`linked-apps`,title:e(`access.linkedAppsSection.linkedApps`,`Linked apps`),icon:u,description:e(`access.linkedAppsSection.externalIntegrationsAlexaLinkedTo`,`External integrations (Alexa, …) linked to this hub through OAuth. Revoking one stops that integration on its next call. Already-revoked rows can be selected and removed from the list.`),children:r(Ft,{rows:h,label:e(`access.linkedAppsSection.linkedApps2`,`linked apps`),isLoading:o.isLoading,loadError:o.isError?o.error?.message??`Request failed`:null,emptyText:`No linked apps — an integration appears here once it completes the account-link flow.`,expiresNone:`—`,action:{label:e(`access.linkedAppsSection.revoke`,`Revoke`),icon:p,isAvailable:e=>e.status===`active`||e.status===`revoked`,onRun:e=>void g(e),busyId:_,disabled:f.isPending||m.busy},bulk:{revoke:m,noun:Vt,isSelectable:e=>e.status===`active`||e.status===`revoked`,quickSelect:[{label:e(`access.linkedAppsSection.selectRevoked`,`Select revoked`),match:e=>e.status===`revoked`}]}})})}var Wt=5e3;function Gt(){let{t}=J(),n=I.useUtils(),i=I.auth.cliLoginPending.useQuery(void 0,{refetchInterval:Wt}),a=I.auth.cliLoginDeny.useMutation({onSuccess:()=>void n.auth.cliLoginPending.invalidate()}),o=i.data??[];if(o.length===0)return null;let s=Date.now();return e(`div`,{className:`space-y-2 rounded-md border border-border bg-background-elevated p-3`,"data-testid":`pending-terminal-signins`,children:[e(`div`,{className:`flex items-center gap-2 text-xs font-medium text-foreground`,children:[r(N,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),t(`cliLogin.pendingTitle`,`Pending terminal sign-ins`)]}),r(`ul`,{className:`space-y-1`,children:o.map(n=>{let i=lt(n.createdAt,s);return e(`li`,{className:`flex items-center justify-between gap-3 text-xs`,children:[e(`span`,{className:`min-w-0 truncate text-foreground-muted`,children:[n.userAgent??t(`cliLogin.unknownValue`,`Unknown`),` · `,n.ip??t(`cliLogin.unknownValue`,`Unknown`),` · `,i.key===`justNow`?t(`cliLogin.ageNow`,`just now`):i.key===`seconds`?t(`cliLogin.ageSeconds`,`{{count}} s ago`,{count:i.value}):t(`cliLogin.ageMinutes`,`{{count}} min ago`,{count:i.value})]}),r(K,{type:`button`,size:`sm`,variant:`ghost`,disabled:a.isPending,onClick:()=>a.mutate({requestId:n.requestId}),children:t(`cliLogin.notMe`,`Not me`)})]},n.requestId)})}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`cliLogin.pendingHint`,`To approve one, open the approval page and type the code the terminal shows.`)})]})}s();var Kt={key:`access.nouns.session`};function qt(){let{t}=J(),i=E(),o=I.useUtils(),s=Tt(),c=I.auth.listSessions.useQuery(),[l,u]=a(null),d=()=>void o.auth.listSessions.invalidate(),f=I.auth.revokeSessions.useMutation({onSuccess:d,onError:e=>u(`Sign out failed: ${e.message}`)}),p=ht(Kt,d),m=n(()=>(c.data??[]).map(e=>ft(e,s,{client:e=>gt(e).label,method:Pt})),[c.data,s]),h=async e=>{await i({title:t(`access.loginSessionsSection.signOutThisSession`,`Sign out this session`),message:t(`access.loginSessionsSection.onWillHaveToSign`,`{{ownerName}} on {{name}} will have to sign in again.`,{ownerName:e.ownerName,name:e.name}),confirmLabel:t(`access.loginSessionsSection.signOut`,`Sign out`),variant:`danger`})&&(u(null),f.mutate({id:e.id}))};return e(Y,{notice:X(l,p.outcome),onDismissNotice:()=>{u(null),p.dismiss()},id:`login-sessions`,title:t(`access.loginSessionsSection.loginSessions`,`Login sessions`),icon:de,description:t(`access.loginSessionsSection.everyBrowserAndAppSigned`,`Every browser and app signed in to this hub, for every user. Signing one out ends it at once; it has to sign in again. Your own current session is marked and never included in a bulk sign-out.`),children:[r(Gt,{}),r(Ft,{rows:m,label:t(`common.sessionsLabel`),isLoading:c.isLoading,loadError:c.isError?c.error?.message??`Request failed`:null,emptyText:`No active sessions.`,action:{label:t(`access.loginSessionsSection.signOut`,`Sign out`),icon:j,isAvailable:e=>e.status===`active`,onRun:e=>void h(e),busyId:f.isPending&&f.variables!==void 0&&`id`in f.variables?f.variables.id:null,disabled:f.isPending||p.busy},bulk:{revoke:p,noun:Kt,isSelectable:e=>e.status===`active`}})]})}var Jt={"by-id":`helpers.authAuditWording.bulkNoun.credential`,"share-link":`helpers.authAuditWording.bulkNoun.shareLink`,"admin-token":`helpers.authAuditWording.bulkNoun.adminToken`,"login-session":`helpers.authAuditWording.bulkNoun.loginSession`};function Z(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function Yt(e,t){let n=Z(e,`tokenId`);return Z(e,`name`)??(n===null?void 0:t.get(n))??n??`?`}function Q(e){return e.filter(e=>e!==null)}function Xt(e){let t=Z(e,`prefix`);return t===null?null:q.t(`helpers.authAuditWording.prefix`,{prefix:t})}function Zt(e,t){let n=e.detail??{};switch(e.action){case`admin-token-created`:{let e=n.expiresAt;return{title:q.t(`helpers.authAuditWording.tokenCreated`,{name:Yt(n,t)}),details:Q([Xt(n),typeof e==`number`?q.t(`helpers.authAuditWording.expires`,{at:Lt(e)}):null])}}case`admin-token-used`:{let e=Z(n,`path`);return{title:q.t(`helpers.authAuditWording.tokenUsed`,{name:Yt(n,t)}),details:Q([Xt(n),e===null?null:q.t(`helpers.authAuditWording.call`,{path:e})])}}case`token-minted`:{let e=n.expiresAt;return{title:q.t(`helpers.authAuditWording.tokenMinted`,{name:Yt(n,t)}),details:Q([typeof e==`number`?q.t(`helpers.authAuditWording.expires`,{at:Lt(e)}):null])}}case`token-revoked`:return{title:q.t(`helpers.authAuditWording.anyTokenRevoked`,{name:Yt(n,t)}),details:[]};case`admin-token-revoked`:return{title:q.t(`helpers.authAuditWording.tokenRevoked`,{name:Yt(n,t)}),details:Q([Xt(n)])};case`credentials-revoked`:{let e=Z(n,`kind`)??`credential`,t=n.revoked,r=n.skipped,i=Jt[e],a=i===void 0?`${e}s`:q.t(i);return{title:q.t(`helpers.authAuditWording.bulkRevoked`,{n:typeof t==`number`?String(t):`?`,noun:a}),details:Q([typeof r==`number`&&r>0?q.t(`helpers.authAuditWording.skipped`,{count:r}):null,Z(n,`ids`)===null?null:q.t(`helpers.authAuditWording.ids`,{ids:Z(n,`ids`)??``})])}}case`second-factor-skipped`:{let e=Z(n,`method`),t=Z(n,`factors`);return{title:q.t(`helpers.authAuditWording.secondFactorSkipped`),details:Q([e===null?null:q.t(`helpers.authAuditWording.signedInWith`,{method:Pt(e)}),t===null?null:q.t(`helpers.authAuditWording.skippedFactors`,{factors:t.split(`,`).join(`, `)})])}}default:return{title:e.action,details:Object.entries(n).map(([e,t])=>`${e}: ${String(t)}`)}}}s();var Qt=100;function $t(){let{user:e}=tt();return e?.isAdmin?r(tn,{}):null}function en(){let{data:e}=ve(),{data:t}=I.auth.listTokens.useQuery(void 0);return n(()=>{let n=new Map;for(let t of e??[])n.set(t.id,t.username);let r=new Map;for(let e of t??[])r.set(e.id,e.label);return{userNameById:n,tokenNameById:r}},[e,t])}function tn(){let{t}=J(),n=I.auth.listAuthAudit.useQuery({limit:Qt}),{userNameById:i,tokenNameById:a}=en(),o=n.data??[];return e(`div`,{"data-testid":`auth-audit`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[e(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[r(ie,{className:`h-3.5 w-3.5 text-foreground-subtle`}),r(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`auth.authAuditSection.authenticationAudit`,`Authentication audit`)}),r(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:t(`auth.authAuditSection.latest`,{count:Qt})})]}),r(`div`,{className:`p-4`,children:n.isLoading?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(w,{className:`h-3.5 w-3.5 animate-spin`}),t(`auth.authAuditSection.loadingAuditTrail`,`Loading audit trail…`)]}):n.isError?e(`div`,{className:`text-[11px] text-danger`,children:[t(`auth.authAuditSection.couldNotLoadTheAudit`,`Could not load the audit trail:`),` `,n.error?.message??t(`auth.authAuditSection.requestFailed`,`Request failed`)]}):o.length===0?e(`div`,{className:`rounded border border-dashed border-border px-3 py-4 text-xs text-foreground-subtle text-center space-y-1`,children:[r(`div`,{children:t(`auth.authAuditSection.noAuthenticationEventsRecordedYet`,`No authentication events recorded yet.`)}),r(`div`,{className:`text-[11px] text-foreground-subtle/90`,children:t(`auth.authAuditSection.thisTrailRecordsAdminToken`,`This trail records admin-token create/use/revoke, trusted-network 2FA skips, and credential revokes (including single share-link revoke). Browser password logins are not listed here.`)})]}):r(`ul`,{className:`divide-y divide-border rounded-md border border-border max-h-[420px] overflow-y-auto`,children:o.map(e=>r(nn,{record:e,userName:e.userId===void 0?null:i.get(e.userId)??e.userId,tokenNameById:a},e.id))})})]})}function nn({record:t,userName:n,tokenNameById:i}){let a=Zt(t,i);return e(`li`,{"data-testid":`auth-audit-row`,className:`px-3 py-2 text-xs space-y-0.5`,children:[e(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[r(`span`,{className:`font-medium text-foreground`,children:a.title}),r(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:Lt(t.at)})]}),e(`div`,{className:`flex flex-wrap gap-x-3 text-[11px] text-foreground-subtle`,children:[n!==null&&r(`span`,{className:`text-foreground`,children:n}),t.ip!==void 0&&r(`span`,{className:`font-mono`,children:t.ip}),a.details.map(e=>r(`span`,{className:`font-mono`,children:e},e))]})]})}s();var $={loginSessions:`login-sessions`,linkedApps:`linked-apps`,tokens:`tokens`,scopedTokens:`scoped-tokens`,adminTokens:`admin-tokens`,shareLinks:`share-links`,externalIdentities:`external-identities`,audit:`auth-audit`},rn={[$.scopedTokens]:$.tokens,[$.adminTokens]:$.tokens,[$.shareLinks]:$.tokens};function an(){return[{id:$.loginSessions,label:q.t(`system.access.loginSessions`,`Login sessions`),icon:de,render:()=>r(qt,{})},{id:$.linkedApps,label:q.t(`system.access.linkedApps`,`Linked apps`),icon:u,render:()=>r(Ut,{})},{id:$.tokens,label:q.t(`system.access.tokens`,`Tokens`),icon:M,render:({createRequested:e,onCreateConsumed:t})=>r(Ct,{headerOwnsCreate:!0,createRequested:e,onCreateConsumed:t})},{id:$.externalIdentities,label:q.t(`system.access.signInLinks`,`Sign-in links`),icon:ce,render:()=>r(Bt,{})},{id:$.audit,label:q.t(`system.access.audit`,`Audit`),icon:ie,render:()=>r($t,{})}]}function on({createRequested:t=!1,onCreateConsumed:i}){let{t:a}=J(),o=n(()=>an(),[]),s=Rt({ids:n(()=>o.map(e=>e.id),[o]),answered:!0}),c=rt(),[l]=et(),u=l.get(`integration`),d=u===null?void 0:rn[u];if(d!==void 0){let e=new URLSearchParams(l);return e.set(`integration`,d),r(nt,{to:`?${e.toString()}`,replace:!0})}let f=o.find(e=>e.id===s.selectedId)??o[0];return e(`div`,{className:`flex flex-col gap-3`,"data-testid":`access-page`,children:[r(Je,{appearance:`pills`,value:f?.id??$.loginSessions,onValueChange:e=>{c(`?${ot(l,e,null,null).toString()}`)},children:r(Ge,{"aria-label":a(`system.access.credentialKinds`,`Credential kinds`),children:o.map(t=>e(Re,{value:t.id,"data-testid":`access-kind-${t.id}`,children:[r(t.icon,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),t.label]},t.id))})}),f===void 0?null:r(`div`,{role:`region`,"aria-label":f.label,"data-testid":`access-kind-body`,children:f.render({createRequested:t&&f.id===$.tokens,onCreateConsumed:i??(()=>void 0)})},f.id)]})}function sn(t,n){if(t===$.tokens)return e(K,{size:`sm`,type:`button`,"data-testid":`access-new-token`,onClick:n,children:[r(M,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),q.t(`system.access.newToken`,`New token`)]})}function cn(){let[e,t]=a(!1);return{createRequested:e,requestCreate:()=>t(!0),clearCreate:()=>t(!1)}}function ln({isPending:t,error:n,what:i,onRetry:a,children:o}){let{t:s}=J();return t?e(`div`,{className:`flex items-center gap-2 py-3 text-xs text-foreground-subtle`,role:`status`,"data-testid":`query-pending`,children:[r(w,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),s(`certificates.queryBody.reading`,{what:i})]}):n===null?o:r(G,{title:s(`certificates.queryBody.couldNotRead`,`Could not read {{what}}`,{what:i}),message:n.message.length>0?n.message:s(`certificates.queryBody.requestFailed`,`Request failed`),onRetry:a})}function un(){let{t}=J(),n=I.deviceCredentials.getDeviceCaStatus.useQuery({}),i=n.data;return r(Y,{id:`device-ca`,title:t(`certificates.deviceCaCard.deviceCertificateAuthority`,`Device certificate authority`),icon:re,description:t(`certificates.deviceCaCard.signsTheCertificateEachPaired`,`Signs the certificate each paired device holds. It is created the first time a device is paired.`),children:r(ln,{isPending:n.isPending,error:n.error,what:`the device CA`,onRetry:()=>void n.refetch(),children:i!==void 0&&e(`div`,{className:`space-y-1`,"data-testid":`device-ca-status`,children:[e(U,{label:t(`certificates.deviceCaCard.state`,`State`),children:[i.state===`ready`&&r(F,{variant:`success`,children:t(`certificates.deviceCaCard.ready`,`Ready`)}),i.state===`absent`&&r(F,{variant:`default`,children:t(`certificates.deviceCaCard.notCreatedYet`,`Not created yet`)}),i.state===`unavailable`&&r(F,{variant:`danger`,children:t(`certificates.deviceCaCard.unavailable`,`Unavailable`)})]}),i.state===`ready`&&e(l,{children:[r(U,{label:t(`certificates.deviceCaCard.subject`,`Subject`),valueClassName:`font-mono`,children:i.subject}),r(U,{label:t(`certificates.deviceCaCard.fingerprintSha256`,`Fingerprint (SHA-256)`),valueClassName:`font-mono`,children:i.fingerprintSha256}),r(U,{label:t(`certificates.deviceCaCard.validUntil`,`Valid until`),children:i.validTo})]}),i.state===`unavailable`&&r(U,{label:t(`certificates.deviceCaCard.reason`,`Reason`),children:r(`span`,{className:`text-danger`,children:i.reason})})]})})})}s();function dn(){let{t}=J(),n=I.useUtils(),i=I.deviceCredentials.getDeviceCertificateSettings.useQuery({}),[o,s]=a(null),c=I.deviceCredentials.setDeviceCertificateSettings.useMutation({onSuccess:()=>{s(null),n.deviceCredentials.getDeviceCertificateSettings.invalidate()},onError:e=>s(`Could not save: ${e.message}`)});return r(ln,{isPending:i.isPending,error:i.error,what:`the enrollment setting`,onRetry:()=>void i.refetch(),children:i.data!==void 0&&e(U,{label:t(`certificates.deviceSettingsRow.usersCanEnrollTheirOwn`,`Users can enroll their own devices`),actions:r(Pe,{checked:i.data.selfEnrollment===`allowed`,disabled:c.isPending,"aria-label":t(`certificates.deviceSettingsRow.usersCanEnrollTheirOwn`,`Users can enroll their own devices`),onCheckedChange:e=>c.mutate({selfEnrollment:e?`allowed`:`disabled`})}),children:[r(`span`,{className:`text-[11px] text-foreground-subtle`,children:i.data.selfEnrollment===`allowed`?t(`certificates.deviceSettingsRow.allowedAUserSignedIn`,`Allowed - a user signed in on a phone can keep it signed in. Pairing by QR works either way.`):t(`certificates.deviceSettingsRow.disabledOnlyAnAdminCan`,`Disabled - only an admin can pair a device, with a QR code.`)}),o!==null&&r(`span`,{className:`block text-[11px] text-danger`,children:o})]})})}s();function fn(e){let[t,n]=a(()=>Date.now());return i(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}s();var pn=80,mn=208;function hn({open:t,users:n,onClose:i,onPaired:o}){let{t:s}=J(),c=I.deviceCredentials.startEnrollment.useMutation({onSuccess:o}),[l,u]=a(``),[d,f]=a(``),p=l===``?n[0]?.id??``:l,m=c.data,h=()=>{c.reset(),f(``),i()};return r(_e,{open:t,onClose:h,title:s(`certificates.pairDeviceDialog.pairADevice`,`Pair a device`),icon:k,width:`md`,testId:`pair-device-dialog`,error:c.isError?c.error.message:null,footer:m===void 0?e(K,{type:`button`,onClick:()=>{let e=d.trim();p===``||e===``||c.mutate({userId:p,deviceName:e})},disabled:c.isPending||p===``||d.trim()===``,children:[c.isPending&&r(w,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),s(`certificates.pairDeviceDialog.createPairingCode`,`Create pairing code`)]}):r(K,{type:`button`,variant:`outline`,onClick:h,children:s(`certificates.pairDeviceDialog.done`,`Done`)}),children:m===void 0?e(`div`,{className:`space-y-3`,children:[r(`p`,{className:`text-[11px] text-foreground-subtle`,children:s(`certificates.pairDeviceDialog.createsAOneTimeCode`,`Creates a one-time code for a phone you hold. Scan it with the CamStack app on that phone; the phone then stays signed in as the chosen user until you revoke it.`)}),r(R,{label:s(`certificates.pairDeviceDialog.user`,`User`),required:!0,children:r(ne,{value:p,onChange:e=>u(e.target.value),options:n.map(e=>({value:e.id,label:e.username}))})}),r(R,{label:s(`certificates.pairDeviceDialog.deviceName`,`Device name`),required:!0,description:s(`certificates.pairDeviceDialog.howThisPhoneIsListed`,`How this phone is listed, e.g. Anna's iPhone.`),children:r(Ke,{value:d,maxLength:pn,onChange:e=>f(e.target.value),placeholder:s(`certificates.pairDeviceDialog.annaSIphone`,`Anna's iPhone`),autoFocus:!0})})]}):r(gn,{enrollUrl:m.enrollUrl,expiresAt:m.expiresAt,hubKnown:m.hubOrigin!==null,onRestart:()=>c.reset()})})}function gn({enrollUrl:t,expiresAt:n,hubKnown:i,onRestart:a}){let{t:o}=J(),s=kt(n,fn(1e3));return r(`div`,{className:`space-y-3`,"data-testid":`pair-issued`,children:e(`div`,{className:`flex flex-col items-center gap-3 sm:flex-row sm:items-start`,children:[r(`div`,{className:s.expired?`opacity-30`:void 0,children:r(Ce,{value:t,size:mn,alt:o(`certificates.pairDeviceDialog.enrollmentQrCode`,`Enrollment QR code`)})}),e(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[r(`p`,{className:`text-[11px] text-foreground-subtle`,children:o(`certificates.pairDeviceDialog.openTheCamstackAppOn`,`Open the CamStack app on the phone and scan this code. It works once.`)}),r(`div`,{className:`text-sm font-semibold tabular-nums text-foreground`,role:`timer`,"data-testid":`pair-countdown`,children:s.expired?o(`certificates.pairDeviceDialog.expiredCreateANewCode`,`Expired - create a new code`):o(`certificates.pairDeviceDialog.expiresIn`,`Expires in {{label}}`,{label:s.label})}),e(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1`,children:[r(`code`,{className:`min-w-0 flex-1 select-all break-all font-mono text-[11px] text-foreground`,children:t}),r(ze,{value:t,srLabel:`Enrollment link`})]}),!i&&e(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-1.5 text-[11px] text-foreground`,children:[r(b,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`,"aria-hidden":!0}),r(`span`,{children:o(`certificates.pairDeviceDialog.theHubCouldNotName`,`The hub could not name an address for this link, so the app must already know it.`)})]}),s.expired&&r(K,{type:`button`,variant:`outline`,size:`sm`,onClick:a,children:o(`certificates.pairDeviceDialog.newCode`,`New code`)})]})]})})}s();var _n={key:`access.nouns.device`};function vn({pairOpen:t,onPairClose:i}){let{t:o}=J(),s=E(),c=te(),l=I.useUtils(),u=I.deviceCredentials.listDeviceCredentials.useQuery({includeRevoked:!0}),d=ve(),[f,m]=a(null),[h,g]=a(null),_=()=>void l.deviceCredentials.listDeviceCredentials.invalidate(),v=e=>t=>{g(null),m(`${e} failed: ${t.message}`)},y=()=>{g(null),_()},b=I.deviceCredentials.revokeDeviceCredential.useMutation({onSuccess:y,onError:v(`Revoke`)}),S=I.deviceCredentials.deleteDeviceCredential.useMutation({onSuccess:e=>{e.result!==`deleted`&&m(e.result===`live`?`Only a revoked device can be deleted: revoke it first.`:`That device no longer exists.`),y()},onError:v(`Delete`)}),w=I.deviceCredentials.renameDeviceCredential.useMutation({onSuccess:y,onError:v(`Rename`)}),T=pt(_n,e=>b.mutateAsync({id:e}),_),D=T.busy||h!==null,O=n(()=>(u.data??[]).map(Ot),[u.data]),ee=async e=>{await s({title:o(`certificates.devicesCard.revoke`,`Revoke "{{name}}"?`,{name:e.name}),message:o(`certificates.devicesCard.sDeviceStopsSigningIn`,`{{ownerName}}'s device stops signing in at once and its open sessions end. To use it again it has to be paired anew. This cannot be undone.`,{ownerName:e.ownerName}),confirmLabel:o(`certificates.devicesCard.revoke2`,`Revoke`),variant:`danger`})&&(m(null),g(e.id),b.mutate({id:e.id}))},ne=async e=>{await s({title:o(`certificates.devicesCard.delete`,`Delete "{{name}}"?`,{name:e.name}),message:o(`certificates.devicesCard.isRemovedFromTheList`,`{{name}} is removed from the list. The audit trail keeps the revocation.`,{name:e.name}),confirmLabel:o(`common.delete`,`Delete`),variant:`danger`})&&(m(null),g(e.id),S.mutate({id:e.id}))},re=async e=>{let t=(await c({title:o(`certificates.devicesCard.renameDevice`,`Rename device`),label:o(`certificates.devicesCard.deviceName`,`Device name`),defaultValue:e.name,confirmLabel:o(`certificates.devicesCard.rename`,`Rename`)}))?.trim()??``;t===``||t===e.name||(m(null),g(e.id),w.mutate({id:e.id,deviceName:t}))},ie={label:o(`certificates.devicesCard.revoke2`,`Revoke`),icon:C,isAvailable:_t,onRun:e=>void ee(e),busyId:b.isPending?h:null,disabled:D},ae=[{label:o(`certificates.devicesCard.rename`,`Rename`),icon:x,tone:`neutral`,isAvailable:()=>!0,onRun:e=>void re(e),busyId:w.isPending?h:null,disabled:D},{label:o(`common.delete`,`Delete`),icon:p,isAvailable:wt,onRun:e=>void ne(e),busyId:S.isPending?h:null,disabled:D}];return e(Y,{id:`devices`,title:o(`certificates.devicesCard.devices`,`Devices`),icon:k,description:o(`certificates.devicesCard.phonesThatStaySignedIn`,`Phones that stay signed in with a certificate instead of a login. Revoking one signs it out at once; it has to be paired again.`),notice:X(f,T.outcome),onDismissNotice:()=>{m(null),T.dismiss()},children:[r(dn,{}),r(Ft,{rows:O,label:o(`certificates.devicesCard.label`),isLoading:u.isPending,loadError:u.error===null?null:u.error.message||`Request failed`,emptyText:`No devices paired yet.`,expiresNone:`—`,action:ie,extraActions:ae,bulk:{revoke:T,noun:_n,isSelectable:_t}}),r(hn,{open:t,users:d.data??[],onClose:i,onPaired:_})]})}var yn=/-----BEGIN CERTIFICATE-----[\s\S]+?-----END CERTIFICATE-----/,bn=/-----BEGIN ((?:RSA |EC |ENCRYPTED )?PRIVATE KEY)-----[\s\S]+?-----END \1-----/,xn={certificate:`.pem,.crt,.cer`,privateKey:`.pem,.key`,ca:`.pem,.crt,.cer`};function Sn(e,t){if(t.trim()===``)return null;if(e===`privateKey`){let e=bn.exec(t);return e===null?yn.test(t)?q.t(`helpers.pemFile.isCert`):q.t(`helpers.pemFile.notKey`):e[1]===`ENCRYPTED PRIVATE KEY`?q.t(`helpers.pemFile.encrypted`):null}return yn.test(t)?e===`certificate`&&bn.test(t)?q.t(`helpers.pemFile.certHasKey`):null:bn.test(t)?q.t(`helpers.pemFile.isKey`):q.t(`helpers.pemFile.notCert`)}function Cn(e){return e.text()}s();function wn({kind:n,label:i,value:o,onChange:s,rows:c=6}){let{t:l}=J(),u=t(null),[d,f]=a(null),[p,m]=a(null),h=p??Sn(n,o),g=`pem-${n}`,_=async e=>{let t=e.target.files?.[0];if(e.target.value=``,t!==void 0){f(t.name);try{let e=await Cn(t);m(null),s(e)}catch(e){m(`Could not read ${t.name}: ${e instanceof Error?e.message:String(e)}`)}}};return e(`div`,{className:`space-y-1`,children:[e(`div`,{className:`flex items-center justify-between gap-2`,children:[r(`label`,{htmlFor:g,className:`text-[11px] text-foreground-subtle`,children:i}),e(`div`,{className:`flex min-w-0 items-center gap-2`,children:[d!==null&&r(`span`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,"data-testid":`${g}-file-name`,children:d}),r(He,{ref:u,accept:xn[n],onChange:e=>void _(e),className:`hidden`,"data-testid":`${g}-file`}),e(K,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>u.current?.click(),children:[r(le,{className:`mr-1 h-3 w-3`}),l(`system.pemField.chooseFile`,`Choose file`)]})]})]}),r(Be,{id:g,value:o,onChange:e=>{f(null),m(null),s(e.target.value)},rows:c,"aria-invalid":h!==null,className:`w-full rounded border border-border bg-surface px-2 py-1 font-mono text-[11px]`}),h!==null&&r(`p`,{className:`text-[11px] text-danger`,role:`alert`,children:h})]})}s();var Tn=30;function En(e){let t=Date.parse(e);return!Number.isNaN(t)&&Date.now()-t<Tn*864e5}function Dn(e){if(e===null||e===``)return`—`;let t=e.replace(/:/g,``);return t.length<=16?e:`${t.slice(0,8)}…${t.slice(-8)}`}function On(){let{t}=J(),n=c(),i=Xe(void 0,{refetchInterval:15e3}),o=Fe({onSuccess:()=>void n.invalidateQueries({queryKey:[[`localNetwork`]]})}),s=he({onSuccess:()=>void n.invalidateQueries({queryKey:[[`localNetwork`]]})}),l=we({onSuccess:()=>void n.invalidateQueries({queryKey:[[`localNetwork`]]})}),u=ge({onSuccess:()=>{m(!1),g(``),v(``),b(``),n.invalidateQueries({queryKey:[[`localNetwork`]]})}}),f=i.data,[p,m]=a(!1),[h,g]=a(``),[_,v]=a(``),[y,b]=a(``),x=()=>{if(!f?.caCertPem)return;let e=new Blob([f.caCertPem],{type:`application/x-pem-file`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`camstack-ca.crt`,n.click(),URL.revokeObjectURL(t)},S=f?.mode===`uploaded`?`Uploaded`:f?.mode===`generated`?`Generated local CA`:`TLS disabled`;return r(V,{headingId:`local-access-certificate`,title:t(`system.localAccess.certificate`,`Certificate`),icon:D,children:e(`div`,{className:`${d} space-y-3`,children:[i.isError&&r(`p`,{className:`text-xs text-danger`,children:t(`system.localAccess.couldNotReadTlsStatus`,`Could not read TLS status.`)}),f?.reissueError&&r(G,{variant:`warning`,title:t(`system.localAccess.certificateReissue`,`Certificate reissue`),message:f.reissueError}),f?.restartRequired&&r(G,{variant:`warning`,title:t(`system.localAccess.restartRequired`,`Restart required`),message:t(`system.localAccess.theHttpsListenerStillServes`,`The HTTPS listener still serves the previous certificate. Restart the hub to apply it.`)}),f?.caMissing===!0&&r(G,{variant:`warning`,title:t(`system.localAccess.caMissingTitle`,`CA missing - devices cannot trust this hub`),message:t(`system.localAccess.caMissingBody`,"The uploaded certificate was not issued by a public CA and no CA was stored with it, so Download CA has nothing to hand out. Upload the certificate again together with its CA (for mkcert, the rootCA.pem in the folder `mkcert -CAROOT` prints).")}),f?.caReplacedAt!=null&&En(f.caReplacedAt)&&r(G,{variant:`warning`,title:t(`system.localAccess.caReplacedTitle`,`The local CA was replaced - re-install it on your devices`),message:t(`system.localAccess.caReplacedBody`,`The previous local CA had no name constraints: if its key ever leaked it could vouch for any website. The hub now uses a CA limited to private addresses and local names. Download it again and trust it on every phone and computer that used the old one (replaced {{when}}).`,{when:new Date(f.caReplacedAt).toLocaleString()})}),e(`dl`,{className:`grid grid-cols-1 gap-2 text-xs sm:grid-cols-2`,children:[e(`div`,{children:[r(`dt`,{className:`text-foreground-subtle`,children:t(`system.localAccess.mode`,`Mode`)}),r(`dd`,{className:`font-medium`,children:S})]}),e(`div`,{children:[r(`dt`,{className:`text-foreground-subtle`,children:t(`system.localAccess.validTo`,`Valid to`)}),r(`dd`,{className:`font-mono`,children:f?.validTo?new Date(f.validTo).toLocaleString():`—`})]}),e(`div`,{children:[r(`dt`,{className:`text-foreground-subtle`,children:t(`system.localAccess.leafSha256`,`Leaf SHA-256`)}),r(`dd`,{className:`font-mono`,title:f?.leafFingerprintSha256??void 0,children:Dn(f?.leafFingerprintSha256??null)})]}),f?.storedUpload!=null&&e(`div`,{children:[r(`dt`,{className:`text-foreground-subtle`,children:t(`system.localAccess.storedUpload`,`Stored upload`)}),r(`dd`,{className:`font-medium`,children:t(`system.localAccess.storedUploadValue`,`valid to {{validTo}}, {{ca}}`,{validTo:new Date(f.storedUpload.validTo).toLocaleDateString(),ca:f.storedUpload.hasCa?t(`system.localAccess.storedUploadWithCa`,`with its CA`):t(`system.localAccess.storedUploadNoCa`,`no CA`)})})]}),e(`div`,{children:[r(`dt`,{className:`text-foreground-subtle`,children:t(`system.localAccess.caSha256`,`CA SHA-256`)}),r(`dd`,{className:`font-mono`,title:f?.caFingerprintSha256??void 0,children:f?.mode===`uploaded`&&f.caFingerprintSha256===null?r(`span`,{className:`font-sans text-foreground-subtle`,children:t(`system.localAccess.issuerNotIncludedInThe`,`Issuer not included in the upload (not the local CA)`)}):Dn(f?.caFingerprintSha256??null)})]})]}),f&&f.sans.length>0&&r(`div`,{className:`flex flex-wrap gap-1`,children:f.sans.map(e=>r(`span`,{className:`rounded border border-border bg-surface px-1.5 py-0.5 font-mono text-[10px] text-foreground-subtle`,children:e},e))}),e(`div`,{className:`flex flex-wrap gap-2`,children:[r(Se,{label:t(`system.localAccess.regenerate`,`Regenerate`),title:t(`system.localAccess.issueANewLeaf`,`Issue a new leaf?`),description:t(`system.localAccess.issuesANewLeafUnder`,`Issues a new leaf under the current local CA. Clients that trust the CA keep working. The HTTPS listener reloads.`),confirmLabel:t(`system.localAccess.regenerate`,`Regenerate`),disabled:f?.mode===`uploaded`||o.isPending,action:()=>o.mutateAsync({})}),r(K,{size:`sm`,variant:`outline`,onClick:()=>m(e=>!e),children:t(`system.localAccess.upload`,`Upload`)}),f?.caCertPem&&r(K,{size:`sm`,variant:`outline`,onClick:x,children:t(`system.localAccess.downloadCa`,`Download CA`)}),f?.mode===`uploaded`&&r(Se,{label:t(`system.localAccess.revertToGenerated`,`Revert to generated`),title:t(`system.localAccess.revertTitle`,`Switch back to the generated certificate?`),description:t(`system.localAccess.keepsTheUploadedPair`,`Returns to the generated local CA. The uploaded certificate and its CA stay stored here; you can select them again.`),confirmLabel:t(`system.localAccess.revert`,`Revert`),disabled:s.isPending,action:()=>s.mutateAsync({})}),f?.mode===`generated`&&f.storedUpload!=null&&r(Se,{label:t(`system.localAccess.useUploaded`,`Use uploaded certificate`),title:t(`system.localAccess.useUploadedTitle`,`Serve the stored upload again?`),description:t(`system.localAccess.useUploadedDescription`,`The stored uploaded certificate replaces the generated one on the HTTPS listener. The generated certificate stays stored.`),confirmLabel:t(`system.localAccess.useUploaded`,`Use uploaded certificate`),disabled:l.isPending,action:()=>l.mutateAsync(void 0)})]}),p&&e(`div`,{className:`space-y-2 border-t border-border pt-3`,children:[r(wn,{kind:`certificate`,label:t(`system.localAccess.certificateOrFullChainPem`,`Certificate or full chain (PEM)`),value:h,onChange:g}),r(wn,{kind:`privateKey`,label:t(`system.localAccess.privateKeyPem`,`Private key (PEM)`),value:_,onChange:v}),r(wn,{kind:`ca`,label:t(`system.localAccess.caPemRequired`,`CA (PEM) - required unless the certificate comes from a public CA`),value:y,onChange:b,rows:4}),r(K,{size:`sm`,disabled:!h.trim()||!_.trim()||Sn(`certificate`,h)!==null||Sn(`privateKey`,_)!==null||Sn(`ca`,y)!==null||u.isPending,onClick:()=>u.mutate({certPem:h,keyPem:_,...y.trim()?{caPem:y}:{}}),children:t(`system.localAccess.saveCertificate`,`Save certificate`)}),u.isError&&r(`p`,{className:`text-xs text-danger`,children:u.error instanceof Error?u.error.message:t(`system.localAccess.uploadFailed`,`Upload failed`)})]})]})})}var kn={ok:`text-foreground-subtle`,soon:`text-warning`,expired:`text-danger`,unknown:`text-foreground-subtle`};function An(e){let t=e.find(e=>e.isHub);return t?.https.kind===`served`?t.https.status.caFingerprintSha256:null}function jn({https:t,mesh:n,now:i}){let{t:a}=J(),o=Xe().data?.caCertPem??``,s=()=>{if(o===``)return;let e=URL.createObjectURL(new Blob([o],{type:`application/x-pem-file`})),t=document.createElement(`a`);t.href=e,t.download=`camstack-ca.crt`,t.click(),URL.revokeObjectURL(e)},c=n?.ca,l=c?.state===`ready`?Date.parse(c.validTo):null,u=n?.listener;return e(`div`,{className:`space-y-1`,"data-testid":`ca-strip`,children:[r(U,{label:a(`certificates.caStrip.localHttpsCaSha256`,`Local HTTPS CA (SHA-256)`),valueClassName:`font-mono`,children:e(`span`,{className:`flex flex-wrap items-center gap-2`,children:[An(t)??`—`,o!==``&&e(K,{type:`button`,variant:`ghost`,size:`sm`,onClick:s,children:[r(ee,{className:`h-3 w-3`,"aria-hidden":!0}),a(`certificates.caStrip.downloadCa`,`Download CA`)]})]})}),r(U,{label:a(`certificates.caStrip.clusterCaSha256`,`Cluster CA (SHA-256)`),valueClassName:`font-mono`,children:c===void 0?`—`:c.state===`ready`?c.fingerprintSha256:r(`span`,{className:`text-danger`,children:a(`certificates.caStrip.unavailable`,{reason:c.reason})})}),c?.state===`ready`&&e(U,{label:a(`certificates.caStrip.clusterCaValidUntil`,`Cluster CA valid until`),children:[c.validTo,l!==null&&!Number.isNaN(l)&&e(`span`,{className:`ml-2 text-[10px] ${kn[Nt(l,i)]}`,children:[`(`,yt(l,i),`)`]})]}),u!==void 0&&e(U,{label:a(`certificates.caStrip.nodeListener`,`Node listener`),children:[u.state===`open`&&r(F,{variant:`success`,children:a(`certificates.caStrip.open`,`Open`)}),u.state===`not-started`&&r(F,{variant:`default`,children:a(`certificates.caStrip.notStarted`,`Not started`)}),u.state===`closed`&&e(`span`,{className:`text-danger`,children:[a(`certificates.caStrip.closedSince`,{when:bt(u.since)}),` `,u.reason]})]}),n!==void 0&&!n.registryAvailable&&e(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-1.5 text-[11px] text-foreground`,children:[r(b,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`,"aria-hidden":!0}),r(`span`,{children:a(`certificates.caStrip.theCertificateRegistryIsNot`,`The certificate registry is not up, so the node list below is incomplete.`)})]})]})}function Mn(e,t){let n=new Set;for(let t of e)n.add(t.nodeId);for(let e of t?.nodes??[])n.add(e.nodeId);return[...n].map(n=>{let r=e.find(e=>e.nodeId===n)??null,i=t?.nodes.find(e=>e.nodeId===n)??null;return{nodeId:n,isHub:r?.isHub??n===`hub`,online:r?.online??i?.online??!1,https:r,mesh:i}}).toSorted((e,t)=>Number(t.isHub)-Number(e.isHub)||e.nodeId.localeCompare(t.nodeId))}function Nn(e){return e.isHub?q.t(`helpers.nodesModel.hubReissued`):e.mesh===null?q.t(`helpers.nodesModel.noCertRecorded`):e.online?null:q.t(`helpers.certificateModel.nodeOffline`)}function Pn(e){return e.isHub||e.mesh===null?Nn(e):null}var Fn={ok:`text-foreground-subtle`,soon:`text-warning`,expired:`text-danger`,unknown:`text-foreground-subtle`},In={enroll:`Issued at enrollment`,renewal:`Issued by a renewal`,boot:`Issued at boot`,pairing:`Issued at pairing`,observed:`Observed on its connection`},Ln={uploaded:`Uploaded`,generated:`Generated`,disabled:`Disabled`};function Rn(e){let t=e.https?.https;return t?.kind===`served`?jt(t.status.validTo):null}function zn({ms:t,now:n}){return t===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):e(`div`,{children:[r(`div`,{children:bt(t)}),r(`div`,{className:`text-[10px] ${Fn[Nt(t,n)]}`,children:yt(t,n)})]})}function Bn({row:t}){let{t:n}=J(),i=t.https?.https;return i===void 0?r(`span`,{className:`text-foreground-subtle`,children:`—`}):i.kind===`served`?e(`div`,{title:i.status.leafFingerprintSha256??``,children:[r(F,{variant:`success`,className:`text-[10px]`,children:n(`certificates.nodesColumns.served`,`Served`)}),r(`span`,{className:`ml-1.5 text-[10px] text-foreground-subtle`,children:Ln[i.status.mode]}),r(`div`,{className:`mt-1 font-mono text-[10px] text-foreground-subtle`,children:At(i.status.leafFingerprintSha256)}),i.status.sans.length>0&&r(`div`,{className:`mt-0.5 max-w-[14rem] truncate font-mono text-[10px] text-foreground-subtle`,title:i.status.sans.join(`, `),children:i.status.sans.join(`, `)})]}):e(`div`,{className:`max-w-[16rem]`,children:[r(F,{variant:i.kind===`unreadable`?`danger`:`warning`,className:`text-[10px]`,children:i.kind===`unreadable`?n(`certificates.nodesColumns.unreadable`,`Unreadable`):n(`certificates.nodesColumns.notServed`,`Not served`)}),r(`div`,{className:`mt-1 whitespace-normal text-[10px] text-foreground-subtle`,children:i.reason})]})}function Vn({row:t}){let{t:n}=J(),i=t.mesh?.current??null;if(i===null)return r(`span`,{className:`text-foreground-subtle`,children:n(`certificates.nodesColumns.noneRecorded`,`None recorded`)});let a=t.mesh?.history.length??0;return e(`div`,{children:[r(`div`,{className:`font-mono text-[11px]`,title:i.serial,children:Dt(i.serial)}),r(`div`,{className:`font-mono text-[10px] text-foreground-subtle`,title:i.fingerprintSha256,children:At(i.fingerprintSha256)}),e(`div`,{className:`text-[10px] text-foreground-subtle`,children:[In[i.issuedVia],a>0?` · ${n(`certificates.nodesColumns.earlier`,{count:a})}`:``]})]})}function Hn({row:e}){let{t}=J(),n=e.mesh?.presentingCurrent??null;return n===null?r(`span`,{className:`text-foreground-subtle`,children:e.online?`—`:t(`certificates.nodesColumns.offline`,`Offline`)}):n?r(F,{variant:`success`,className:`text-[10px]`,children:t(`common.yes`,`Yes`)}):r(F,{variant:`warning`,className:`text-[10px]`,children:t(`certificates.nodesColumns.noPresentsAnother`,`No - presents another`)})}function Un(t){let n=t.icon;return e(K,{type:`button`,variant:`ghost`,size:`sm`,className:t.danger?`text-danger hover:bg-danger/10`:void 0,disabled:t.reason!==null||t.busy,title:t.reason??void 0,"aria-label":t.ariaLabel,onClick:t.onClick,children:[t.spinning?r(w,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):r(n,{className:`h-3 w-3`,"aria-hidden":!0}),t.label]})}function Wn({reasons:t}){let{t:n}=J();return e(Le,{className:`inline-block`,children:[r(Ve,{children:r(`span`,{className:`cursor-help text-[11px] text-foreground-subtle`,"data-testid":`hub-managed-note`,children:n(`certificates.nodesColumns.managedByTheHub`,`Managed by the hub`)})}),r(Ne,{children:r(`ul`,{className:`max-w-xs space-y-1 whitespace-normal text-left text-[11px]`,children:t.map(e=>r(`li`,{children:e},e))})})]})}function Gn({row:t,o:n}){let{t:i}=J(),a=t.https===null?`No HTTPS inventory for this node.`:xt(t.https).reason,o=Nn(t),s=Pn(t),c=e=>n.running?.nodeId===t.nodeId&&n.running.action===e,l=e=>!t.isHub||e===null,u=[a,o,s].filter((e,t,n)=>e!==null&&n.indexOf(e)===t);return e(`div`,{className:`flex w-44 flex-col items-end gap-1`,children:[e(`div`,{className:`flex flex-col items-end gap-0.5`,children:[l(a)&&r(Un,{label:i(`certificates.nodesColumns.renewHttps`,`Renew HTTPS`),ariaLabel:i(`certificates.nodesColumns.renewTheCertificateOn`,`Renew the certificate on {{nodeId}}`,{nodeId:t.nodeId}),icon:g,reason:a,busy:n.busy,spinning:c(`renew-https`),danger:!1,onClick:()=>n.onRenewHttps(t)}),l(o)&&r(Un,{label:c(`renew-identity`)?i(`certificates.nodesColumns.renewing`,`Renewing…`):i(`certificates.nodesColumns.renewIdentity`,`Renew identity`),ariaLabel:i(`certificates.nodesColumns.renewTheClusterCertificateOf`,`Renew the cluster certificate of {{nodeId}}`,{nodeId:t.nodeId}),icon:g,reason:o,busy:n.busy,spinning:c(`renew-identity`),danger:!1,onClick:()=>n.onRenewIdentity(t)}),l(s)&&r(Un,{label:i(`certificates.nodesColumns.revokeIdentity`,`Revoke identity`),ariaLabel:i(`certificates.nodesColumns.revokeTheClusterCertificateOf`,`Revoke the cluster certificate of {{nodeId}}`,{nodeId:t.nodeId}),icon:C,reason:s,busy:n.busy,spinning:c(`revoke-identity`),danger:!0,onClick:()=>n.onRevokeIdentity(t)})]}),t.isHub&&u.length>0&&r(Wn,{reasons:u}),!t.isHub&&a!==null&&t.https!==null&&r(`div`,{className:`w-full whitespace-normal text-right text-[10px] text-foreground-subtle`,"data-testid":`renew-reason-${t.nodeId}`,children:a}),!t.isHub&&o!==null&&r(`div`,{className:`w-full whitespace-normal text-right text-[10px] text-foreground-subtle`,"data-testid":`mesh-reason-${t.nodeId}`,children:o})]})}function Kn(t){return[{key:`node`,header:q.t(`certificates.nodesColumns.node`,`Node`),sortValue:e=>e.isHub?``:e.nodeId.toLowerCase(),render:t=>e(`div`,{className:`flex items-center gap-1.5`,children:[r(`span`,{className:`font-medium text-foreground`,children:t.nodeId}),t.nodeId===`hub`&&r(F,{variant:`info`,className:`text-[10px]`,children:q.t(`common.hubWord`)}),!t.online&&r(F,{variant:`default`,className:`text-[10px]`,children:q.t(`common.offline`)})]})},{key:`https-state`,header:`HTTPS`,notSortableReason:`A state with a reason has no single order.`,render:e=>r(Bn,{row:e})},{key:`https-expires`,header:q.t(`certificates.nodesColumns.httpsExpires`,`HTTPS expires`),sortValue:e=>Rn(e),render:e=>r(zn,{ms:Rn(e),now:t.now})},{key:`identity`,header:q.t(`certificates.nodesColumns.identity`,`Identity`),sortValue:e=>e.mesh?.current?.serial??null,render:e=>r(Vn,{row:e})},{key:`identity-expires`,header:q.t(`certificates.nodesColumns.identityExpires`,`Identity expires`),sortValue:e=>e.mesh?.current?.notAfter??null,render:e=>r(zn,{ms:e.mesh?.current?.notAfter??null,now:t.now})},{key:`presenting`,header:q.t(`certificates.nodesColumns.inUse`,`In use`),notSortableReason:`Offline nodes have no answer to order by.`,render:e=>r(Hn,{row:e})},{key:`actions`,header:q.t(`certificates.nodesColumns.actions`,`Actions`),align:`right`,notSortableReason:`Actions have no order.`,render:e=>r(Gn,{row:e,o:t})}]}s();function qn(){let{t}=J(),i=E(),o=I.useUtils(),s=fn(6e4),c=I.certificates.listHttpsCertificates.useQuery(),l=I.certificates.getMeshCertificates.useQuery(),[u,d]=a(null),[f,p]=a(null),[m,h]=a(null),g=()=>{h(null),o.certificates.listHttpsCertificates.invalidate(),o.certificates.getMeshCertificates.invalidate()},_=e=>(t,n)=>{h(null),d(`${n.nodeId}: ${e} - ${t.message}`)},y=I.certificates.renewHttpsOnNode.useMutation({onSuccess:(e,n)=>{p({tone:`success`,message:e.restartRequired?t(`certificates.nodesCard.newCertificateIssuedRestartThe`,`{{nodeId}}: new certificate issued. Restart the node to serve it.`,{nodeId:n.nodeId}):t(`certificates.nodesCard.newCertificateIssuedAndServed`,`{{nodeId}}: new certificate issued and served.`,{nodeId:n.nodeId})}),g()},onError:_(`renewal failed`)}),b=I.certificates.renewMeshOnNode.useMutation({onSuccess:e=>{p(Et(e)),g()},onError:_(`renewal could not start`)}),x=I.certificates.revokeMeshOnNode.useMutation({onSuccess:e=>{p({tone:`success`,message:`${e.nodeId}: ${e.next}`}),g()},onError:_(`revoke failed`)}),S=y.isPending||b.isPending||x.isPending,C=(e,t)=>{d(null),p(null),h({nodeId:e,action:t})},w=async e=>{await i({title:t(`certificates.nodesCard.renewHttpsOn`,`Renew HTTPS on "{{nodeId}}"?`,{nodeId:e.nodeId}),message:e.isHub?t(`certificates.nodesCard.aNewCertificateIsIssued`,`A new certificate is issued from the local CA. Clients that trust the CA keep working.`):t(`certificates.nodesCard.theNodeMakesANew`,`The node makes a new key, the hub signs it and the node switches over without a restart. It keeps serving what it had if anything fails.`),confirmLabel:t(`certificates.nodesCard.renew`,`Renew`)})&&(C(e.nodeId,`renew-https`),y.mutate({nodeId:e.nodeId}))},T=e=>{C(e.nodeId,`renew-identity`),b.mutate({nodeId:e.nodeId})},D=async e=>{await i({title:t(`certificates.nodesCard.revokeTheIdentityOf`,`Revoke the identity of "{{nodeId}}"?`,{nodeId:e.nodeId}),message:t(`certificates.nodesCard.isDisconnectedAtOnceAnd`,`{{nodeId}} is disconnected at once and can no longer connect. To bring it back it must be paired again from System → Cluster → Agents. It stays in the node list until you forget it on the Cluster page. This cannot be undone.`,{nodeId:e.nodeId}),confirmLabel:t(`certificates.nodesCard.revokeAndDisconnect`,`Revoke and disconnect`),variant:`danger`})&&(C(e.nodeId,`revoke-identity`),x.mutate({nodeId:e.nodeId}))},O=Kn({now:s,busy:S,running:m,onRenewHttps:e=>void w(e),onRenewIdentity:T,onRevokeIdentity:e=>void D(e)}),ee=n(()=>Mn(c.data??[],l.data),[c.data,l.data]),k=l.data?.registryAvailable??!0;return r(Y,{id:`nodes`,title:t(`certificates.nodesCard.nodes`,`Nodes`),icon:v,description:t(`certificates.nodesCard.eachNodeHoldsTwoCertificates`,`Each node holds two certificates: one it serves over HTTPS, one that proves its identity to the hub. Renewing replaces a certificate without a gap; revoking an identity cuts the node off until it re-joins.`),notice:X(u,f),onDismissNotice:()=>{d(null),p(null)},children:r(ln,{isPending:c.isPending||l.isPending,error:c.error??l.error,what:`node certificates`,onRetry:()=>{c.refetch(),l.refetch()},children:e(`div`,{className:`space-y-3`,children:[r(jn,{https:c.data??[],mesh:l.data,now:s}),r(Qe,{columns:O,rows:ee,rowKey:e=>e.nodeId,minWidthPx:960,maxBodyHeight:me,defaultSort:{columnKey:`node`,dir:`asc`},emptyMessage:k?t(`certificates.nodesCard.noNodesReported`,`No nodes reported.`):t(`certificates.nodesCard.theCertificateRegistryIsNot`,`The certificate registry is not available yet, so nodes cannot be listed.`)})]})})})}function Jn({pairOpen:t,onPairClose:n}){return e(`div`,{className:`space-y-4`,"data-testid":`certificates-page`,children:[r(vn,{pairOpen:t,onPairClose:n}),r(un,{}),r(On,{}),r(qn,{})]})}function Yn({userId:t,username:n,onClose:i}){let{t:a}=J(),o=E(),s=I.useUtils(),c=Ee({userId:t}),l=I.auth.listLoginMethods.useQuery(),d=je({onSuccess:()=>void s.userManagement.listExternalIdentities.invalidate()}),f=new Map((l.data??[]).flatMap(e=>e.kind===`redirect`?[[e.id,e.label]]:[])),p=c.data??[],m=async(e,r)=>{await o({title:a(`users.externalIdentitiesModal.removeSignInLink`,`Remove sign-in link`),message:a(`users.externalIdentitiesModal.willNoLongerBeAble`,`"{{username}}" will no longer be able to sign in with this {{label}} account.`,{username:n,label:r}),confirmLabel:a(`common.remove`,`Remove`),variant:`danger`})&&d.mutate({userId:t,provider:e.provider,subject:e.subject})};return r(L,{open:!0,onOpenChange:e=>!e&&i(),children:e(H,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,"data-testid":`external-identities-modal`,children:[r(P,{children:e(W,{className:`flex items-center gap-2`,children:[r(u,{className:`h-4 w-4 text-primary`}),e(`span`,{children:[a(`users.externalIdentitiesModal.linkedSignInAccounts`,`Linked sign-in accounts`),e(`span`,{className:`mt-0.5 block text-[11px] font-normal text-foreground-subtle`,children:[a(`users.externalIdentitiesModal.user`,`User:`),` `,r(`span`,{className:`font-mono`,children:n})]})]})]})}),r(B,{className:`space-y-3`,children:c.isLoading?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(w,{className:`h-3.5 w-3.5 animate-spin`}),a(`common.loading`,`Loading…`)]}):p.length===0?r(`p`,{className:`text-xs text-foreground-subtle`,children:a(`users.externalIdentitiesModal.noLinkedAccountsOnlyThe`,`No linked accounts. Only the user can link one, from their own profile page.`)}):r(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:p.map(t=>{let n=f.get(t.provider),i=n??t.provider;return e(`li`,{className:`flex items-center gap-3 px-3 py-2 text-xs`,children:[e(`div`,{className:`flex-1 min-w-0`,children:[e(`div`,{className:`font-medium text-foreground truncate`,children:[i,n===void 0&&r(`span`,{className:`ml-2 rounded bg-foreground-subtle/15 px-1.5 py-0.5 text-[10px] font-normal text-foreground-subtle`,children:a(`users.externalIdentitiesModal.providerUnavailable`,`provider unavailable`)})]}),e(`div`,{className:`text-[11px] text-foreground-subtle truncate`,children:[t.label??t.subject,` ·`,` `,new Date(t.linkedAt).toLocaleDateString()]})]}),e(K,{variant:`unstyled`,onClick:()=>void m(t,i),disabled:d.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[r(fe,{className:`h-3 w-3`}),a(`common.remove`,`Remove`)]})]},`${t.provider}|${t.subject}`)})})}),r($e,{children:r(K,{onClick:i,variant:`secondary`,children:a(`common.close`,`Close`)})})]})})}function Xn({userId:t,username:n,onClose:i}){let{t:a}=J(),o=c(),s=E(),u=ye({userId:t}),d=u.data,f=()=>o.invalidateQueries({queryKey:[[`userManagement`,`getTotpStatus`]]}),p=De({onSuccess:()=>{f(),i()}}),g=u.isLoading?`loading`:d?.enabled?`enrolled`:`not_enrolled`;return r(L,{open:!0,onOpenChange:e=>!e&&i(),children:e(H,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[r(P,{children:e(W,{className:`flex items-center gap-2`,children:[r(k,{className:`h-4 w-4 text-primary`}),e(`span`,{children:[a(`users.totpModal.twoFactorAuthentication`,`Two-factor authentication`),e(`span`,{className:`mt-0.5 block text-[11px] font-normal text-foreground-subtle`,children:[a(`users.totpModal.user`,`User:`),` `,r(`span`,{className:`font-mono`,children:n})]})]})]})}),e(B,{className:`space-y-4`,children:[g===`loading`&&e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(w,{className:`h-3.5 w-3.5 animate-spin`}),a(`users.totpModal.checkingStatus`,`Checking status…`)]}),g===`not_enrolled`&&e(`div`,{className:`rounded-md border border-border bg-surface-hover/30 px-3 py-2.5 flex items-start gap-2.5 text-xs text-foreground-subtle`,children:[r(h,{className:`h-4 w-4 mt-0.5 shrink-0`}),e(`div`,{children:[r(`div`,{className:`font-medium text-foreground`,children:a(`users.totpModal.2faNotEnrolled`,`2FA not enrolled`)}),r(`p`,{className:`mt-0.5`,children:a(`users.totpModal.onlyTheUserThemselvesCan`,`Only the user themselves can enable 2FA, from their own profile page.`)})]})]}),g===`enrolled`&&d&&e(l,{children:[e(`div`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2.5 flex items-start gap-2.5`,children:[r(m,{className:`h-4 w-4 mt-0.5 text-emerald-500 shrink-0`}),e(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[r(`div`,{className:`font-medium`,children:a(`users.totpModal.2faIsActive`,`2FA is active`)}),r(`div`,{className:`text-foreground-subtle`,children:a(`common.enrolledOn`,{when:d.confirmedAt?new Date(d.confirmedAt).toLocaleString():`—`})})]})]}),r(`div`,{className:`text-[11px] text-foreground-subtle`,children:a(`users.totpModal.removingHereClearsTheServer`,`Removing here clears the server-side secret. Use this only when the user has lost access — they'll have to re-enroll from their profile page afterwards.`)}),e(`div`,{className:`flex justify-end gap-2`,children:[r(K,{onClick:i,variant:`secondary`,children:a(`common.close`,`Close`)}),e(K,{variant:`unstyled`,onClick:async()=>{await s({title:a(`users.totpModal.remove2fa`,`Remove 2FA`),message:a(`users.totpModal.removeTwoFactorAuthenticationFor`,`Remove two-factor authentication for "{{username}}"? They'll be able to log in with just their password until they re-enroll from their own profile page.`,{username:n}),confirmLabel:a(`common.remove`,`Remove`),variant:`danger`})&&p.mutate({userId:t})},disabled:p.isPending,className:`rounded bg-danger px-3 py-1.5 text-xs font-medium text-white hover:bg-danger/90 disabled:opacity-50 inline-flex items-center gap-1`,children:[p.isPending?r(w,{className:`h-3 w-3 animate-spin`}):r(T,{className:`h-3 w-3`}),a(`users.totpModal.remove2fa`,`Remove 2FA`)]})]})]})]})]})})}s();function Zn({userId:t,username:n,onClose:i}){let{t:o}=J(),{user:s,logout:c}=tt(),l=s?.id===t,u=E(),d=I.useUtils(),f=I.auth.listSessions.useQuery({userId:t}),[p,m]=a(null),h=I.auth.revokeSessions.useMutation({onSuccess:(e,t)=>{if(l&&`userId`in t){c();return}d.auth.listSessions.invalidate()},onError:e=>m(`Sign out failed: ${e.message}`)}),g=async e=>{await u({title:o(`users.userSessionsModal.signOutThisSession`,`Sign out this session`),message:o(`users.userSessionsModal.onWillHaveToSign`,`"{{username}}" on {{label}} will have to sign in again.`,{username:n,label:gt(e.client).label}),confirmLabel:o(`users.userSessionsModal.signOut`,`Sign out`),variant:`danger`})&&(m(null),h.mutate({id:e.id}))},_=async()=>{await u({title:o(`users.userSessionsModal.signOutEverywhere`,`Sign out everywhere`),message:l?o(`users.userSessionsModal.everySessionOfYourOwn`,`Every session of your own account ends, this browser included: you will be signed out here too.`):o(`users.userSessionsModal.everySessionOfEndsAt`,`Every session of "{{username}}" ends at once; each device has to sign in again.`,{username:n}),confirmLabel:o(`users.userSessionsModal.signOutEverywhere`,`Sign out everywhere`),variant:`danger`})&&(m(null),h.mutate({userId:t}))},v=h.isPending&&h.variables!==void 0&&`id`in h.variables?h.variables.id:null;return r(L,{open:!0,onOpenChange:e=>!e&&i(),children:e(H,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,"data-testid":`user-sessions-modal`,children:[r(P,{children:e(W,{className:`flex items-center gap-2`,children:[r(de,{className:`h-4 w-4 text-primary`}),e(`span`,{children:[o(`users.userSessionsModal.activeSessions`,`Active sessions`),e(`span`,{className:`mt-0.5 block text-[11px] font-normal text-foreground-subtle`,children:[o(`users.userSessionsModal.user`,`User:`),` `,r(`span`,{className:`font-mono`,children:n})]})]})]})}),e(B,{className:`space-y-3`,children:[p!==null&&r(`div`,{className:`text-[11px] text-danger`,children:p}),r(Mt,{sessions:f.data??[],isLoading:f.isLoading,loadError:f.isError?f.error?.message??`Request failed`:null,emptyText:`No active sessions.`,onRevoke:e=>void g(e),revokingId:v})]}),e($e,{className:`justify-between`,children:[e(K,{variant:`unstyled`,onClick:()=>void _(),disabled:h.isPending||(f.data??[]).length===0,className:`inline-flex items-center gap-1.5 rounded border border-danger/40 px-2.5 py-1 text-[11px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,children:[h.isPending&&v===null?r(w,{className:`h-3 w-3 animate-spin`}):r(j,{className:`h-3 w-3`}),o(`users.userSessionsModal.signOutEverywhere`,`Sign out everywhere`)]}),r(K,{onClick:i,variant:`secondary`,children:o(`common.close`,`Close`)})]})]})})}function Qn({scopes:t,invalidReason:n}){let{t:i}=J(),a=O(),s=o({queryKey:[`auth`,`previewScope`,t,!1],enabled:n===null,queryFn:()=>a.trpcClient.auth.previewScope.query({scopes:[...t],isAdmin:!1})}),{data:c}=z({projection:`slim`}),l=c?.length??null;if(n!==null)return e(`p`,{className:`flex items-center gap-1.5 text-[11px] text-warning`,"data-testid":`role-preview`,children:[r(ae,{className:`h-3 w-3 shrink-0`}),n]});if(s.isLoading)return e(`p`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,"data-testid":`role-preview`,children:[r(w,{className:`h-3 w-3 shrink-0 animate-spin`}),i(`users.rolePreview.resolving`)]});if(s.isError||!s.data)return r(`p`,{className:`text-[11px] text-danger`,"data-testid":`role-preview`,children:i(`users.rolePreview.couldNotResolve`)});let u=s.data.viewableDeviceCount,d=s.data.device.view.all?i(`users.rolePreview.everyDevice`,{count:u}):l===null?i(`users.rolePreview.devicesVisible`,{count:u}):i(`users.rolePreview.devicesVisibleOf`,{count:u,total:l});return e(`p`,{className:`flex items-center gap-1.5 text-[11px] ${u===0?`text-warning`:`text-foreground`}`,"data-testid":`role-preview`,children:[u===0?r(ae,{className:`h-3 w-3 shrink-0`}):r(_,{className:`h-3 w-3 shrink-0 text-foreground-subtle`}),u===0?i(`users.rolePreview.noDevice`):d]})}function $n(e){let t=se(e.scopes??[]);if(t===null)return{role:e.isAdmin?`admin`:`viewer`,mode:`except`,pickedIds:[],viewer:oe,unconfigured:!e.isAdmin};let n=or(t);return{role:e.isAdmin?`admin`:`viewer`,mode:n.mode,pickedIds:n.pickedIds,viewer:sr(n.mode,n.pickedIds,t.features),unconfigured:!1}}function er(e,t){return{...e,role:t}}function tr(e,t){return{...e,mode:t,viewer:sr(t,e.pickedIds,e.viewer.features)}}function nr(e,t){let n=cr(t);return{...e,pickedIds:n,viewer:sr(e.mode,n,e.viewer.features)}}function rr(e,t,n){let r=e.viewer.features.filter(e=>e!==t),i=n?[...r,t]:r;return{...e,viewer:sr(e.mode,e.pickedIds,i)}}function ir(e){return e.role===`viewer`&&e.mode===`only`&&e.pickedIds.length===0?`no-allowed-device`:null}function ar(e){return ir(e)===null?e.role===`admin`?{isAdmin:!0,scopes:[]}:{isAdmin:!1,scopes:[e.viewer]}:null}function or(e){if(e.allow===`*`)return{mode:`except`,pickedIds:e.block};let t=new Set(e.block);return{mode:`only`,pickedIds:e.allow.filter(e=>!t.has(e))}}function sr(e,t,n){let r=cr(t);return e===`except`?{type:`viewer`,allow:`*`,block:r,features:[...n]}:{type:`viewer`,allow:r,block:[],features:[...n]}}function cr(e){return[...new Set(e)]}s();var lr=`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`;function ur(e,t){return e?`failed`:t===void 0?`pending`:`answered`}function dr(e){let t=[];for(let n of e)n.parentDeviceId===null&&t.push({id:n.id,name:n.name,type:String(n.type),...n.location===null?{}:{location:n.location}});return t}function fr({user:t,isSelf:i,onClose:o,onSubmit:s,submitting:c,error:u}){let{t:d}=J(),[f,p]=a(n(()=>$n(t),[t])),m=z({projection:`slim`}),h=m.data,g=ur(m.isError,h),_=n(()=>dr(h??[]),[h]),v=n(()=>({state:g,devices:g===`answered`?(h??[]).map(e=>({id:e.id,name:e.name})):void 0}),[g,h]),y=ir(f),b=ar(f),x=y===`no-allowed-device`?d(`users.userAccessModal.pickAllowedDevice`):null,S=e=>{p(er(f,e))},C=[{value:`except`,label:d(`users.userAccessModal.modeExcept`)},{value:`only`,label:d(`users.userAccessModal.modeOnly`)}];return r(L,{open:!0,onOpenChange:e=>!e&&o(),children:e(H,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`md:max-w-2xl`,children:[r(P,{children:r(W,{children:d(`users.userAccessModal.title`,{name:t.username})})}),e(B,{className:`space-y-4`,children:[f.unconfigured&&f.role===`viewer`&&r(G,{variant:`warning`,title:d(`users.userAccessModal.noAccessYet`),message:d(`users.userAccessModal.noAccessYetDetail`,{name:t.username})}),e(`section`,{className:`space-y-2`,children:[r(`h3`,{className:lr,children:d(`users.userAccessModal.role`)}),e(`div`,{role:`radiogroup`,"aria-label":d(`users.userAccessModal.role`),className:`grid gap-1.5 sm:grid-cols-2`,children:[r(pr,{name:`admin`,checked:f.role===`admin`,label:d(`users.userAccessModal.admin`),description:d(`users.userAccessModal.adminDescription`),onPick:()=>S(`admin`)}),r(pr,{name:`viewer`,checked:f.role===`viewer`,disabled:i,label:d(`users.userAccessModal.viewer`),description:d(i?`users.userAccessModal.cannotDemoteSelf`:`users.userAccessModal.viewerDescription`),onPick:()=>S(`viewer`)})]})]}),f.role===`viewer`&&e(l,{children:[e(`section`,{className:`space-y-3`,children:[r(`h3`,{className:lr,children:d(`users.userAccessModal.devices`)}),r(Ie,{label:d(`users.userAccessModal.whichDevices`),value:f.mode,options:C,onChange:e=>p(tr(f,e))}),r(Me,{devices:_,listState:g,fleet:v,value:[...f.pickedIds],onChange:e=>p(nr(f,e)),emptyMeansAll:f.mode===`except`,noun:`device`,testId:`viewer-device-picker`}),r(Qn,{scopes:b?.scopes??[],invalidReason:x})]}),e(`section`,{className:`space-y-2`,children:[r(`h3`,{className:lr,children:d(`users.userAccessModal.features`)}),r(`div`,{className:`space-y-1`,children:A.map(t=>e(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md p-1.5 hover:bg-surface-hover`,children:[r(Ye,{className:`mt-0.5`,checked:f.viewer.features.includes(t.id),onChange:e=>p(rr(f,t.id,e.target.checked))}),e(`span`,{className:`min-w-0`,children:[r(`span`,{className:`block text-[12px] font-medium text-foreground`,children:d(`users.viewerFeatures.${t.id}.label`,t.label)}),r(`span`,{className:`block text-[10px] text-foreground-subtle`,children:d(`users.viewerFeatures.${t.id}.description`,t.description)})]})]},t.id))})]})]}),u!==null&&r(G,{message:u})]}),e($e,{children:[r(K,{variant:`outline`,size:`sm`,onClick:o,children:d(`common.cancel`,`Cancel`)}),r(K,{size:`sm`,onClick:()=>b!==null&&s(b),disabled:c||b===null,children:c?r(w,{className:`h-3 w-3 animate-spin`}):d(`users.userAccessModal.saveAccess`)})]})]})})}function pr({name:t,checked:n,disabled:i=!1,label:a,description:o,onPick:s}){return e(`label`,{className:`flex items-start gap-2 rounded-lg border p-2.5 transition-colors ${n?`border-primary bg-primary/5`:`border-border hover:bg-surface-hover`} ${i?`cursor-not-allowed opacity-60`:`cursor-pointer`}`,children:[r(qe,{name:`user-role`,value:t,checked:n,disabled:i,onChange:s,className:`mt-0.5`}),e(`span`,{className:`min-w-0`,children:[r(`span`,{className:`block text-[12px] font-medium text-foreground`,children:a}),r(`span`,{className:`block text-[10px] text-foreground-subtle`,children:o})]})]})}s();var mr=8;function hr(){return{username:``,password:``,isAdmin:!1}}function gr(e){return{id:e.id,username:e.username,password:``,isAdmin:e.isAdmin}}function _r(e){return e instanceof Error?e.message:q.t(`admin.system.users.genericError`)}function vr(){let{t}=J(),n=c(),{user:o}=tt(),{state:s,openNew:d,openEdit:m,close:h}=Te(),[g,_]=a(null),[v,b]=a(null),[S,C]=a(!1),{data:T,isLoading:D,isError:O,error:ee,refetch:ne}=ve(),ie=E(),ae=te(),A=()=>n.invalidateQueries({queryKey:[[`userManagement`,`listUsers`]]}),oe=Ze(),se=pe({onSuccess:A}),j=ke({onSuccess:A}),M=xe({onSuccess:A}),ce=be(),[N,le]=a(null),[fe,me]=a(!1),[P,he]=a(null),[ge,F]=a(null),[I,L]=a(null),[z,ye]=a(null),B=T??[],V=s.mode===`edit`?B.find(e=>e.id===s.id)??null:null,H=()=>{_(null),b(null),C(!1),oe.reset(),j.reset(),h()};i(()=>{if(s.mode===`closed`){_(null),b(null),C(!1);return}if(s.mode===`new`){_(e=>e!==null&&e.id===void 0?e:hr());return}if(V===null){D||h();return}_(e=>e?.id===V.id?e:gr(V))},[s,V,D,h]);let Se=s.mode===`new`&&g!==null&&g.id===void 0||s.mode===`edit`&&g!==null&&V!==null;async function Ce(e){await ie({title:t(`admin.system.users.deleteUser`,`Delete user`),message:t(`admin.system.users.permanentlyDeleteUserThisCannot`,`Permanently delete user "{{username}}"? This cannot be undone — any active sessions will be revoked on next request.`,{username:e.username}),confirmLabel:t(`common.delete`,`Delete`),variant:`danger`})&&(se.mutate({id:e.id}),s.mode===`edit`&&s.id===e.id&&H())}async function we(e){let n=await ae({title:t(`admin.system.users.resetPassword`,`Reset password`),message:t(`admin.system.users.setANewPasswordFor`,`Set a new password for "{{username}}".`,{username:e.username}),label:t(`admin.system.users.newPassword`,`New password`),inputType:`password`,placeholder:t(`admin.system.users.atLeast8Characters`,`At least 8 characters`),confirmLabel:t(`admin.system.users.continue`,`Continue`),validate:e=>e.length<mr?q.t(`admin.system.users.passwordTooShort`,{min:mr}):null});n===null||n.length===0||await ie({title:t(`admin.system.users.resetPassword`,`Reset password`),message:t(`admin.system.users.resetThePasswordForThey`,`Reset the password for "{{username}}"? They will need to use the new password on their next login.`,{username:e.username}),confirmLabel:t(`common.reset`,`Reset`)})&&M.mutate({id:e.id,newPassword:n})}function U(e){he(null),le(e)}async function Ee(e,t){me(!0),he(null);try{t.isAdmin!==e.isAdmin&&await j.mutateAsync({id:e.id,isAdmin:t.isAdmin}),await ce.mutateAsync({userId:e.id,scopes:[...t.scopes]}),le(null)}catch(e){he(_r(e))}finally{me(!1),A()}}async function De(){if(g!==null){b(null);try{if(g.id===void 0){let e=g.username.trim();if(e===``||g.password.length<mr)return;await oe.mutateAsync({username:e,password:g.password,isAdmin:g.isAdmin})}else await j.mutateAsync({id:g.id,isAdmin:g.isAdmin});A(),H()}catch(e){b(_r(e))}}}function W(e){return e?new Date(typeof e==`number`?e:String(e)).toLocaleDateString(`en-GB`,{day:`2-digit`,month:`short`,year:`numeric`}):`—`}let Oe=oe.isPending||j.isPending,je=g!==null&&g.id===void 0&&g.username.trim()!==``&&g.password.length>=mr,Me=g!==null&&g.id!==void 0,Ne=Oe||(g?.id===void 0?!je:!Me),Pe=e=>se.isPending&&se.variables?.id===e.id||j.isPending&&j.variables?.id===e.id||M.isPending&&M.variables?.id===e.id,Fe=[{key:`username`,header:t(`admin.system.users.username`,`Username`),sortValue:e=>e.username,render:e=>r(`span`,{className:`font-medium text-foreground`,"data-testid":`user-open-${e.id}`,children:e.username})},{key:`scopes`,header:t(`admin.system.users.access`,`Access`),sortValue:e=>yr(e),render:n=>r(`span`,{onClick:e=>e.stopPropagation(),children:e(K,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>U(n),disabled:Pe(n),title:t(`admin.system.users.configureAccess`,`Configure access`),"data-testid":`user-access-${n.id}`,children:[r(re,{className:`h-3 w-3 shrink-0 text-foreground-subtle`}),r(br,{user:n})]})})},{key:`createdAt`,header:t(`admin.system.users.created`,`Created`),nowrap:!0,sortValue:e=>e.createdAt,render:e=>r(`span`,{className:`text-foreground-subtle`,children:W(e.createdAt)})},{key:`actions`,header:t(`admin.system.users.actions`,`Actions`),align:`right`,nowrap:!0,notSortableReason:`Row actions`,render:n=>{let i=Pe(n),a=n.id!==o?.id&&n.totpEnabled;return e(`div`,{className:`flex items-center justify-end gap-1`,onClick:e=>e.stopPropagation(),children:[e(K,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>m(n.id),disabled:i,title:t(`admin.system.users.editUser`,`Edit user`),children:[r(x,{className:`h-3 w-3`}),t(`common.edit`,`Edit`)]}),a&&e(K,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>F(n),disabled:i,title:t(`admin.system.users.removeTwoFactorAuthentication`,`Remove two-factor authentication`),children:[r(k,{className:`h-3 w-3`}),t(`admin.system.users.remove2fa`,`Remove 2FA`)]}),e(K,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>L(n),disabled:i,title:t(`admin.system.users.linkedSignInAccounts`,`Linked sign-in accounts`),children:[r(u,{className:`h-3 w-3`}),t(`admin.system.users.signInLinks`,`Sign-in links`)]}),e(K,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>ye(n),disabled:i,title:t(`admin.system.users.activeSessions`,`Active sessions`),children:[r(de,{className:`h-3 w-3`}),t(`admin.system.users.sessions`,`Sessions`)]}),e(K,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>void we(n),disabled:i,title:t(`admin.system.users.resetPassword`,`Reset password`),children:[r(ue,{className:`h-3 w-3`}),t(`admin.system.users.resetPassword`,`Reset password`)]}),e(K,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>void Ce(n),disabled:i,title:t(`admin.system.users.deleteUser`,`Delete user`),className:`text-danger hover:bg-danger/10`,children:[i?r(w,{className:`h-3 w-3 animate-spin`}):r(p,{className:`h-3 w-3`}),t(`common.delete`,`Delete`)]})]})}}];return e(dt,{embedded:!0,icon:f,title:t(`admin.system.users.users`,`Users`),subtitle:t(`admin.system.users.hubAccountsAdminFlagAccess`,`Hub accounts, admin flag, access scopes, sessions and sign-in links.`),actions:e(K,{size:`sm`,type:`button`,onClick:()=>{b(null),d()},children:[r(y,{className:`h-3.5 w-3.5`}),t(`admin.system.users.createUser`,`Create User`)]}),children:[O&&r(G,{title:t(`admin.system.users.couldNotLoadUsers`,`Could not load users`),message:_r(ee),onRetry:()=>void ne()}),D&&e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(w,{className:`h-3.5 w-3.5 animate-spin`}),t(`common.loading`,`Loading…`)]}),!D&&!O&&B.length===0&&r(Ae,{icon:f,title:t(`admin.system.users.noUsersYet`,`No users yet`),description:t(`admin.system.users.createAUserToGrant`,`Create a user to grant hub access.`)}),!D&&!O&&B.length>0&&r(Qe,{columns:Fe,rows:B,rowKey:e=>e.id,minWidthPx:560,maxBodyHeight:`max-h-[60vh]`,onRowClick:e=>m(e.id)}),r(_e,{open:Se,onClose:H,title:g?.id===void 0?t(`admin.system.users.createUser`,`Create User`):t(`admin.system.users.edit`,`Edit {{value1}}`,{value1:g.username||`user`}),icon:f,error:v,testId:`user-form-dialog`,footer:r(K,{size:`sm`,type:`button`,disabled:Ne,onClick:()=>void De(),children:Oe?e(l,{children:[r(w,{className:`h-3.5 w-3.5 animate-spin`}),t(`admin.system.users.saving`,`Saving…`)]}):g?.id===void 0?t(`admin.system.users.create`,`Create`):t(`common.save`,`Save`)}),children:g!==null&&e(`div`,{className:`space-y-3`,children:[r(R,{label:t(`admin.system.users.username`,`Username`),required:g.id===void 0,children:r(Ke,{value:g.username,onChange:e=>_({...g,username:e.target.value}),placeholder:`john`,autoFocus:g.id===void 0,disabled:g.id!==void 0,"data-testid":`user-form-username`})}),g.id===void 0&&r(R,{label:t(`admin.system.users.password`,`Password`),required:!0,description:t(`admin.system.users.atLeastCharacters`,`At least {{value1}} characters.`,{value1:String(mr)}),children:r(We,{value:g.password,onValueChange:e=>_({...g,password:e}),shown:S,onToggleShown:()=>C(e=>!e),placeholder:`••••••••`,"data-testid":`user-form-password`})}),r(R,{label:t(`admin.system.users.admin`,`Admin`),description:t(`admin.system.users.unrestrictedAccessToEveryCapability`,`Unrestricted access to every capability and device.`),children:e(`label`,{className:`inline-flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[r(Ye,{checked:g.isAdmin,onChange:e=>_({...g,isAdmin:e.target.checked}),className:`rounded border-border focus:ring-primary`,"data-testid":`user-form-admin`}),r(`span`,{children:t(`admin.system.users.admin`,`Admin`)})]})}),g.id!==void 0&&r(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`admin.system.users.toChangeThePasswordUse`,`To change the password, use Reset password on the user's row. Access scopes are configured from the Access column.`)})]})}),ge&&r(Xn,{userId:ge.id,username:ge.username,onClose:()=>F(null)}),I&&r(Yn,{userId:I.id,username:I.username,onClose:()=>L(null)}),z&&r(Zn,{userId:z.id,username:z.username,onClose:()=>ye(null)}),N&&r(fr,{user:N,isSelf:N.id===o?.id,onClose:()=>le(null),onSubmit:e=>void Ee(N,e),submitting:fe,error:P})]})}function yr(e){let t=$n(e);return t.role===`admin`?0:t.unconfigured?2:1}function br({user:t}){let{t:n}=J(),i=$n(t);if(i.role===`admin`)return r(`span`,{className:`font-medium text-foreground`,children:n(`users.accessSummary.admin`)});if(i.unconfigured)return r(`span`,{className:`font-medium text-warning`,children:n(`admin.system.users.noAccess`,`No access`)});let{allow:a,block:o,features:s}=i.viewer,c=a===`*`?n(`users.accessSummary.allDevices`):n(`users.accessSummary.devices`,{count:a.length});return e(`span`,{className:`text-foreground-subtle`,children:[r(`span`,{className:`font-medium text-foreground`,children:n(`users.accessSummary.viewer`)}),` ·`,` `,c,o.length>0&&e(l,{children:[` · `,n(`users.accessSummary.blocked`,{count:o.length})]}),s.length>0&&e(l,{children:[` · `,n(`users.accessSummary.features`,{count:s.length})]})]})}s();var xr={"api-keys":$.tokens,"linked-sessions":$.linkedApps},Sr=`certificates`;function Cr(t){return e(K,{size:`sm`,type:`button`,"data-testid":`certificates-pair-device`,onClick:t,children:[r(k,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),q.t(`systemPage.identity.pairADevice`,`Pair a device`)]})}function wr(){let{t:e}=J(),[t]=et(),n=cn(),[i,o]=a(!1),s=xr[t.get(`tab`)??``];if(s!==void 0)return r(nt,{to:ct(`access`,{integration:s}),replace:!0});let c=it(`/system/identity`,{t:e,isAdmin:!0})??{icon:S,title:e(`system.identity`,`Identity & Access`)},l=t.get(`tab`)??`users`,u=t.get(`integration`),d=l===at.access.tab?sn(u,n.requestCreate):l===`certificates`?Cr(()=>o(!0)):void 0;return r(ut,{icon:c.icon,title:c.title,defaultSection:`users`,sectionsLabel:`${c.title} sections`,actions:d,sections:[{id:`users`,label:e(`systemPage.identity.users`,`Users`),content:r(vr,{})},{id:at.access.tab,label:e(`systemPage.identity.tokensSessions`,`Tokens & sessions`),ownedParams:st.concat([St.token,St.scoped,St.admin]),content:r(on,{createRequested:n.createRequested,onCreateConsumed:n.clearCreate})},{id:Sr,label:e(`systemPage.identity.certificates`,`Certificates`),content:r(Jn,{pairOpen:i,onPairClose:()=>o(!1)})},{id:at.authentication.tab,label:e(`systemPage.identity.authentication`,`Authentication`),content:r(zt,{}),ownedParams:st}]})}export{wr as IdentityPage};
|
|
@@ -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,k as c,o as l,x as u,z as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Cr as ee,Kt as f,Pn as p,Un as m,V as h,Wn as g,Yn as te,Zi as _,an as v,br as y,ct as ne,ht as re,wn as b}from"./player-overlays-CC-b3--a.js";import{wr as x}from"./client-kWeONSGL.js";import{t as ie}from"./link-2-off-DmtgBwh-.js";import{At as ae,Br as S,Di as C,Dt as oe,Fr as w,Ir as T,Ln as se,Lr as E,Mn as D,Tt as ce,Vr as O,Xr as le,Yr as ue,_n as k,ar as A,cf as j,fa as M,ki as de,va as N,vn as P,yi as F,zn as fe}from"./src-DGSNF4l8.js";import{t as I}from"./useTranslation-BJr-n0es.js";import{n as L}from"./addon-icons-context-WCP6A9AS.js";import{$ as pe,Fr as R,J as me,Mr as he,Nr as ge,Y as _e,Z as ve,at as ye,ct as be,et as z,it as B,lt as xe,nt as Se,q as V,r as Ce,rt as we,st as Te,tt as H}from"./index-DwCHDODI.js";import{t as Ee}from"./NodeAddonsSettingsPanel-BGB_St7Q.js";import{t as De}from"./InstanceSwitchCell-BQekirNX.js";s();var U=[[[`addons`,`listCapabilityProviders`]],[[`addons`,`list`]]],W=`text-[10px]`;function G({isActive:e}){let{t}=I();return i(C,{variant:e?`success`:`default`,className:W,children:e?t(`integrationHub.addonControls.enabled`,`Enabled`):t(`integrationHub.addonControls.disabled`,`Disabled`)})}function Oe({capName:t,addonId:n,isActive:r}){let{t:a}=I(),o=l(),s=N({onSuccess:()=>{for(let e of U)o.invalidateQueries({queryKey:e})}}),c=s.isPending;return e(F,{size:`sm`,variant:r?`secondary`:`primary`,disabled:c,onClick:()=>s.mutate({capName:t,addonId:n,enabled:!r}),children:[c?i(y,{className:`h-3 w-3 animate-spin`}):i(r?v:g,{className:`h-3 w-3`}),r?a(`common.disable`,`Disable`):a(`common.enable`,`Enable`)]})}function K(){let e=l();return M({onSuccess:()=>{for(let t of U)e.invalidateQueries({queryKey:t})}})}function q({addonId:e,displayName:t,message:n}){let{t:r}=I(),a=ne(),o=K();return i(j,{icon:o.isPending?y:p,variant:`ghost`,size:`sm`,"aria-label":r(`integrationHub.addonControls.restartNamed`,`Restart {{name}}`,{name:t}),disabled:o.isPending,onClick:()=>void a({title:r(`integrationHub.addonControls.restart2`,`Restart "{{displayName}}"?`,{displayName:t}),message:n,confirmLabel:r(`integrationHub.addonControls.restart`,`Restart`),variant:`danger`}).then(t=>t?o.mutateAsync({addonId:e}):void 0)})}function ke({addonId:e,displayName:t,iconOnly:n=!1,description:r}){let{t:a}=I(),o=K(),s=r??a(`integrationHub.addonControls.restartingTheAddonBouncesIts`,`Restarting the addon bounces its subprocess — the provider will briefly drop and reconnect automatically.`);return n?i(q,{addonId:e,displayName:t,message:s}):i(D,{label:a(`integrationHub.addonControls.restart`,`Restart`),icon:p,size:`sm`,title:a(`integrationHub.addonControls.restart2`,`Restart "{{displayName}}"?`,{displayName:t}),description:s,confirmLabel:a(`integrationHub.addonControls.restart`,`Restart`),triggerVariant:`ghost`,confirmVariant:`danger`,disabled:o.isPending,action:()=>o.mutateAsync({addonId:e})})}var J=600,Y=c(null);function X({id:n,title:r,icon:a,actions:o,framed:s=!1,children:c}){let{t:l}=I(),f=d(Y),p=t(null),m=`integration-section-${n}`;Ae(p,f,n);let g=e(u,{children:[f===null?null:i(R,{to:f.sectionHref(n),"aria-label":l(`integrationHub.integrationSection.linkTo`,`Link to {{title}}`,{title:r}),title:l(`integrationHub.integrationSection.linkTo`,`Link to {{title}}`,{title:r}),className:`rounded p-0.5 text-foreground-subtle/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,children:i(ee,{className:`h-3 w-3`,"aria-hidden":!0})}),o]});return s?i(`div`,{ref:p,className:`scroll-mt-4`,children:i(se,{headingId:m,title:r,icon:a,actions:g,children:c})}):e(`section`,{ref:p,"aria-labelledby":m,className:`scroll-mt-4 space-y-2`,children:[e(`header`,{className:`flex min-h-7 flex-wrap items-center gap-2 px-0.5`,children:[a!==void 0&&i(a,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),i(`h2`,{id:m,className:`${h} min-w-0 flex-1`,children:r}),g]}),c]})}function Ae(e,t,n){let r=t?.requestedSection===n,i=t?.integrationId;a(()=>{if(!r)return;let t=()=>e.current?.scrollIntoView?.({block:`start`});t();let n=!1,i=()=>{n=!0},a=[`wheel`,`touchmove`,`keydown`];for(let e of a)window.addEventListener(e,i,{once:!0,passive:!0});let o=window.setTimeout(()=>{n||t()},J);return()=>{window.clearTimeout(o);for(let e of a)window.removeEventListener(e,i)}},[r,i,e])}s();var Z=`max-h-72`,Q=[{kind:`logs`,labelKey:`common.logs`,icon:b},{kind:`events`,labelKey:`common.events`,icon:_}];function $({addonId:t,switcher:n}){let{t:r}=I(),[a,s]=o(`logs`);return e(X,{id:Ce,title:r(`integrationHub.addonIntegrationBody.activity`,`Activity`),framed:!0,actions:i(`div`,{className:`flex flex-wrap items-center gap-2`,children:i(`div`,{role:`group`,"aria-label":r(`integrationHub.addonIntegrationBody.activityStream`,`Activity stream`),className:`flex items-center gap-1`,children:Q.map(({kind:t,labelKey:n,icon:o})=>e(F,{variant:`unstyled`,type:`button`,"aria-pressed":a===t,onClick:()=>s(t),className:`inline-flex items-center gap-1 rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${a===t?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[i(o,{className:`h-3 w-3`,"aria-hidden":!0}),r(n)]},t))})}),children:[n!==void 0&&i(`div`,{className:`px-3 pt-2`,children:n}),a===`logs`?i(P,{addonId:t,maxHeight:Z,showFilters:!1}):i(k,{addonId:t,category:`addon.*`,maxHeight:Z})]})}function je({addonId:t,title:n=`Settings`,subtitle:r,fieldScope:a,onClose:o}){return i(w,{open:!0,onOpenChange:e=>!e&&o(),children:e(E,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`md:max-w-3xl`,children:[e(S,{children:[i(O,{children:n}),r&&i(`p`,{className:`text-xs text-foreground-subtle`,children:r})]}),i(T,{children:i(Ee,{nodeId:null,addonIds:[t],level:`global`,...a===void 0?{}:{fieldScope:a}})})]})})}function Me({addonId:e,title:t,onClose:n}){return i(je,{addonId:e,title:t,fieldScope:`cluster`,onClose:n})}var Ne=`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border py-1 pl-1 pr-2.5 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,Pe=`border-primary bg-primary/10 text-primary font-medium`,Fe=`border-border bg-surface text-foreground-subtle hover:bg-surface-hover hover:text-foreground`;s();var Ie={md:{tile:`h-10 w-10 rounded-lg`,img:`h-7 w-7 rounded-md p-1`,fallback:`h-5 w-5`},sm:{tile:`h-5 w-5 rounded`,img:`h-5 w-5 rounded p-0.5`,fallback:`h-3.5 w-3.5`}};function Le({addonId:e,fallback:t,tileClassName:n,size:r=`md`}){let[a,s]=o(!1),c=L(e),l=Ie[r];return i(`div`,{className:`${l.tile} flex items-center justify-center shrink-0 ${n}`,children:a||!c?i(t,{className:l.fallback,"aria-hidden":!0}):i(`img`,{src:c,alt:``,className:`${l.img} bg-white ring-1 ring-black/5`,onError:()=>s(!0)})})}var Re={ok:`bg-success`,off:`bg-foreground-subtle/60`,error:`bg-danger`,unknown:`border border-foreground-subtle bg-transparent`};function ze(e,t){switch(t){case`ok`:return e(`instances.health.ok`,`Healthy`);case`error`:return e(`instances.health.error`,`Error`);case`off`:return e(`instances.health.off`,`Off`);case`unknown`:return e(`instances.health.unknown`,`Unknown`)}}function Be({pills:t,selected:n,onSelect:r,fallbackIcon:a,install:o}){let{t:s}=I(),c=t.length>1;return!c&&o===void 0?null:i(`div`,{className:`px-3 pt-2`,children:e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[c&&i(`div`,{role:`group`,"aria-label":s(`instances.filterByProvider`,`Filter by provider`),className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:t.map(t=>e(F,{variant:`unstyled`,type:`button`,"aria-pressed":n===t.addonId,"data-testid":`instance-pill-${t.addonId}`,onClick:()=>r(n===t.addonId?null:t.addonId),className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border py-1 pl-1 pr-2.5 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 ${n===t.addonId?`border-primary bg-primary/10 text-primary font-medium`:`border-border bg-surface text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[i(Le,{addonId:t.addonId,fallback:a,tileClassName:``,size:`sm`}),i(`span`,{className:`truncate`,children:t.name}),i(`span`,{className:`shrink-0 text-[10px] font-normal text-foreground-subtle`,children:t.count}),i(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${Re[t.health]}`,"aria-hidden":!0}),i(`span`,{className:`sr-only`,children:ze(s,t.health)})]},t.addonId))}),o!==void 0&&e(R,{to:x(o.capability),className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border py-1 pl-1 pr-2.5 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 border-dashed border-border pl-2 text-foreground-subtle hover:border-primary/50 hover:text-foreground`,children:[i(m,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),i(`span`,{className:`truncate`,children:o.label})]})]})})}function Ve({providers:t,title:n,onPick:r,onCancel:a}){let{t:o}=I();return e(oe,{open:!0,onClose:a,title:n,width:`lg`,children:[i(`p`,{className:`mb-3 text-xs text-foreground-muted`,children:o(`providerInstances.pickProvider`,`Choose which provider the new one belongs to.`)}),i(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:t.map(t=>e(`button`,{type:`button`,onClick:()=>r(t.addonId),className:`flex flex-col items-start gap-1 rounded-lg border border-border bg-surface px-3 py-3 text-left text-xs transition-colors hover:border-primary/50 hover:bg-surface-hover`,children:[i(`span`,{className:`font-medium text-foreground`,children:t.name}),t.description.length>0&&i(`span`,{className:`line-clamp-2 text-[11px] text-foreground-subtle`,children:t.description})]},t.addonId))})]})}s();var He=`instance`;function Ue(e){let t=[e.status?.detail,e.lastCheckedAt===void 0?void 0:new Date(e.lastCheckedAt).toLocaleString()].filter(e=>e!==void 0&&e.length>0);return t.length>0?t.join(` · `):void 0}function We({row:t}){let{t:n}=I();return t.enabled?e(`span`,{className:`flex flex-wrap items-center gap-1`,children:[i(C,{variant:t.configured?`success`:`default`,children:t.configured?n(`providerInstances.configured`,`Configured`):n(`providerInstances.notConfigured`,`Not configured`)}),t.status!==void 0&&i(C,{variant:t.status.state===`error`?`danger`:t.status.state===`ok`?`success`:`default`,title:Ue(t),children:B(t.status)})]}):i(`span`,{className:`flex flex-wrap items-center gap-1`,children:i(C,{variant:`default`,children:n(`providerInstances.off`,`Off`)})})}function Ge({row:e,functionCap:t}){let{t:n}=I(),r=l(),a=N({onSuccess:()=>void r.invalidateQueries()});return i(A,{checked:e.isActive,disabled:a.isPending,"aria-label":n(`providerInstances.enable`,`Enable {{name}}`,{name:e.providerName}),onCheckedChange:n=>a.mutate({capName:t,addonId:e.addonId,enabled:n})})}function Ke({functionCap:t,icon:a,title:s,subtitle:c,emptyTitle:d,emptyDescription:p,addLabel:h,install:_,extraColumns:v,lead:b,rowActions:x,canDelete:S,pageActions:oe,typedId:w,rowFilter:T}){let{t:E}=I(),D=re(),O=l(),k=ne(),A=_e(t),M=ce({editKey:He,newKey:`${He}-new`}),[N,P]=o(null),[L,R]=o(null),B=de({functionCap:`notification-output`}),V=r(e=>ye(B.data??[],e).length,[B.data]),[Ce,we]=o(null),[H,Ee]=o(null),U=n(()=>ve(A.holders),[A.holders]),W=n(()=>Se(A.functionProviders,A.rows,A.displayNames),[A.functionProviders,A.rows,A.displayNames]),G=W.some(e=>e.addonId===H)?H:null,Oe=n(()=>{let e=pe(A.rows,G);return T===void 0?e:e.filter(T)},[A.rows,G,T]),K=r(e=>A.displayNames.get(e)??e,[A.displayNames]),q=r(async e=>{P(e.key),R(null);try{let t=await D.trpcClient.integrationInstances.testInstance.mutate({addonId:e.addonId,id:e.id,values:{}});R({name:e.name,verdict:xe(t)})}catch(t){let n=t instanceof Error?t.message:String(t);R({name:e.name,verdict:{status:`inconclusive`,error:n}})}finally{P(null)}},[D]),J=r(async e=>{let t=ye(B.data??[],e.id),n=t.length>0?` ${E(`providerInstances.deletePinned`,`These notification targets use it and will stop delivering: {{names}}.`,{names:t.join(`, `)})}`:``;if(await k({title:E(`providerInstances.deleteTitle`,`Delete {{name}}?`,{name:e.name}),message:`${E(`providerInstances.deleteMessage`,`The record and its stored credentials are removed.`)}${n}`,confirmLabel:E(`common.delete`,`Delete`),variant:`danger`}))try{await D.trpcClient.integrationInstances.deleteInstance.mutate({addonId:e.addonId,id:e.id}),await O.invalidateQueries({queryKey:[me]})}catch(t){Te({title:E(`providerInstances.deleteFailed`,`Could not delete`),message:`${e.name}: ${t instanceof Error?t.message:String(t)}`,severity:`critical`})}},[k,O,D,E,B.data]),Y=n(()=>A.rows.some(e=>e.kind===`instance`&&e.kindLabel!==void 0),[A.rows]),X=r((e,t)=>{e!==void 0&&ge(he(e,t),()=>{O.invalidateQueries({queryKey:[me]})})},[O]),Ae=n(()=>[{key:`name`,nowrap:!1,header:E(`providerInstances.colName`,`Name`),sortValue:e=>e.name,render:t=>e(`span`,{className:`flex flex-col`,children:[i(`span`,{className:`font-medium ${t.kind===`instance`&&!t.enabled?`text-foreground-muted`:`text-foreground`}`,children:t.name}),t.kind===`fixed`&&t.description.length>0&&i(`span`,{className:`line-clamp-2 text-[11px] text-foreground-subtle`,title:t.description,children:t.description})]})},{key:`provider`,header:E(`providerInstances.colProvider`,`Provider`),sortValue:e=>e.providerName,render:e=>i(`span`,{className:`text-foreground-muted`,children:e.providerName})},...Y?[{key:`kind`,header:E(`providerInstances.colKind`,`Kind`),sortValue:e=>e.kind===`instance`?e.kindLabel??``:``,render:e=>i(`span`,{className:`text-foreground-muted`,children:e.kind===`instance`?e.kindLabel??``:``})}]:[],{key:`state`,header:E(`instances.colStatus`,`Status`),notSortableReason:E(`providerInstances.stateNotSortable`,`A row carries a badge, not a value to order by.`),render:e=>e.kind===`instance`?i(We,{row:e}):i(C,{variant:e.isActive?`success`:`default`,children:e.isActive?E(`instances.active`,`Active`):E(`providerInstances.off`,`Off`)})},{key:`on`,header:E(`providerInstances.colOn`,`On`),notSortableReason:E(`providerInstances.onNotSortable`,`A switch is not a value to order by.`),render:e=>e.kind===`fixed`?i(Ge,{row:e,functionCap:t}):i(De,{row:e,pinning:V(e.id)})},...v??[],{key:`actions`,align:`right`,notSortableReason:E(`providerInstances.actionsNotSortable`,`Row actions are not values.`),render:t=>e(`span`,{className:`inline-flex items-center gap-1`,children:[t.kind===`instance`&&t.connectPath!==void 0&&i(j,{icon:ee,variant:`ghost`,size:`sm`,"aria-label":E(`providerInstances.connectRow`,`Connect {{name}}`,{name:t.name}),onClick:()=>X(t.connectPath,t.id)}),t.kind===`instance`&&t.disconnectPath!==void 0&&i(j,{icon:ie,variant:`ghost`,size:`sm`,"aria-label":E(`providerInstances.disconnectRow`,`Disconnect {{name}}`,{name:t.name}),onClick:()=>X(t.disconnectPath,t.id)}),t.kind===`instance`&&t.canTest&&i(j,{icon:N===t.key?y:g,variant:`ghost`,size:`sm`,"aria-label":E(`providerInstances.testRow`,`Test {{name}}`,{name:t.name}),disabled:N!==null,onClick:()=>void q(t)}),t.kind===`instance`&&x?.(t),i(j,{icon:te,variant:`ghost`,size:`sm`,"aria-label":E(`providerInstances.editRow`,`Edit {{name}}`,{name:t.name}),onClick:()=>M.openEdit(z(t.addonId,t.kind===`instance`?t.id:void 0))}),i(ke,{iconOnly:!0,addonId:t.addonId,displayName:t.providerName,description:E(`providerInstances.restartConfirm`,`Restarts the addon on the hub. If it shares a runner group, every addon in that group restarts with it.`)}),t.kind===`instance`&&(S?.(t)??!0)&&i(j,{icon:f,variant:`ghost`,size:`sm`,"aria-label":E(`providerInstances.deleteRow`,`Delete {{name}}`,{name:t.name}),onClick:()=>void J(t)})]})}],[v,M,t,V,x,S,J,X,q,Y,E,N]),Z;Z=A.state===`error`?i(`div`,{className:`p-3`,children:i(ue,{title:E(`providerInstances.loadFailed`,`Could not load the list`),message:A.error??``,onRetry:A.refetch})}):A.state===`pending`?e(`div`,{className:`flex items-center gap-2 p-3 text-xs text-foreground-subtle`,children:[i(y,{className:`h-3 w-3 animate-spin`}),E(`providerInstances.loading`,`Loading…`)]}):A.rows.length===0?i(le,{icon:a,title:d,description:p}):i(fe,{columns:Ae,rows:Oe,rowKey:e=>e.key,bordered:!1,emptyMessage:E(`instances.noneForProvider`,`This provider has no instance yet.`)});let Q=A.holders.filter(e=>!U.includes(e)).map(e=>K(e.addonId)),$=U.length>0?void 0:Q.length>0?E(`instances.addBlocked`,`{{names}}: only one instance is allowed and it already exists.`,{names:Q.join(`, `)}):E(`instances.addNone`,`No provider here can hold instances.`);return e(se,{headingId:`provider-instances-${t}`,title:s,icon:a,children:[i(`p`,{className:`px-3 pt-2 text-xs text-foreground-muted`,children:c}),A.state===`ready`&&$!==void 0&&i(`p`,{className:`px-3 pt-1 text-[11px] text-foreground-subtle`,children:$}),A.state===`ready`&&e(u,{children:[e(ae,{children:[oe?.(A.rows.filter(e=>e.kind===`instance`)),e(F,{size:`sm`,variant:`primary`,disabled:$!==void 0,title:$,onClick:()=>{let e=U.find(e=>e.addonId===G)??(U.length===1?U[0]:void 0);e===void 0?M.openNew():M.openEdit(z(e.addonId,null))},children:[i(m,{className:`h-3.5 w-3.5`}),h]})]}),i(Be,{pills:W,selected:G,onSelect:Ee,fallbackIcon:a,..._===void 0?{}:{install:_}})]}),Z,A.state===`ready`&&A.rows.length>0&&i(qe,{rows:A.rows,selected:Ce,onSelect:we}),L!==null&&e(`div`,{className:`space-y-1 p-3`,children:[i(`p`,{className:`text-[11px] font-medium text-foreground`,children:L.name}),i(be,{verdict:L.verdict})]}),A.state===`ready`&&M.state.mode===`new`&&i(Ve,{title:h,providers:U.map(e=>({addonId:e.addonId,name:K(e.addonId),description:A.descriptions.get(e.addonId)??``})),onPick:e=>M.openEdit(z(e,null)),onCancel:M.close}),A.state===`ready`&&M.state.mode===`edit`&&i(Je,{refValue:M.state.id,data:A,nameOf:K,onClose:M.close,onOpen:(e,t)=>M.openEdit(z(e,t)),...b===void 0?{}:{lead:b},...w===void 0?{}:{typedId:w}},M.state.id)]})}function qe({rows:e,selected:t,onSelect:r}){let{t:a}=I(),o=n(()=>we(e),[e]),s=o[0];if(s===void 0)return null;let c=o.find(e=>e.addonId===t)??s;return i(`div`,{className:`p-3`,children:i($,{addonId:c.addonId,switcher:o.length>1?i(`div`,{role:`group`,"aria-label":a(`providerInstances.activityProvider`,`Activity of`),className:`flex flex-wrap items-center gap-1`,children:o.map(e=>i(F,{variant:`unstyled`,type:`button`,"aria-pressed":e.addonId===c.addonId,onClick:()=>r(e.addonId),className:`rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${e.addonId===c.addonId?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.name},e.addonId))}):void 0})})}function Je({refValue:e,data:t,nameOf:n,onClose:r,onOpen:a,lead:o,typedId:s}){let c=H(e);if(c.kind===`fixed`)return i(Me,{addonId:c.addonId,title:n(c.addonId),onClose:r});let l=t.holders.find(e=>e.addonId===c.addonId);if(l===void 0)return null;let u=c.kind===`instance`?l.instances.find(e=>e.id===c.id)??null:null;if(c.kind===`instance`&&u===null)return null;let d=t.rows.find(e=>e.kind===`instance`&&e.addonId===c.addonId&&e.id===u?.id);return i(Ye,{addonId:c.addonId,...o!==void 0&&d!==void 0?{lead:o(d)}:{},providerName:n(c.addonId),description:l.description,instance:u,onClose:r,onOpen:a,...s===void 0?{}:{typedId:s}})}function Ye(e){let{onOpen:n,onClose:r,onSaved:a,...o}=e,s=t(null),c=e.instance===null;return i(V,{...o,onSaved:e=>{c&&(s.current=e),a?.(e)},onClose:()=>{s.current===null?r():n(e.addonId,s.current)}})}export{Fe as a,Y as c,ke as d,W as f,Pe as i,Oe as l,Le as n,$ as o,Ne as r,X as s,Ke as t,G as u};
|