@camstack/addon-admin-ui 1.2.489 → 1.2.490
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/dist/assets/{AddonAssetIcon-C0cWByHj.js → AddonAssetIcon-D-9BDtpk.js} +1 -1
- package/dist/assets/{Addons-DtmmHLxt.js → Addons-51TvRwwb.js} +1 -1
- package/dist/assets/{AdminPage-D6Yva5zf.js → AdminPage-CdT4_4OP.js} +1 -1
- package/dist/assets/{AdminSectionedPage-ytDsnoAA.js → AdminSectionedPage-p7IoxWdQ.js} +1 -1
- package/dist/assets/AiProfiles-WM5GT1_g.js +3 -0
- package/dist/assets/{BrokerEditorDialog-CTEagRft.js → BrokerEditorDialog-C9R9WJ5j.js} +1 -1
- package/dist/assets/Build-DmG4Bqo3.js +40 -0
- package/dist/assets/{Calendars-BzsJnrEA.js → Calendars-CNjiX8AQ.js} +1 -1
- package/dist/assets/{Cluster-C2D1ovUW.js → Cluster-Cs8jI_us.js} +1 -1
- package/dist/assets/{CompositionBlockEditor-CYmfatQE.js → CompositionBlockEditor-DM8TH06u.js} +1 -1
- package/dist/assets/{CompositionEditorPage-B5Cgu9cj.js → CompositionEditorPage-7ZGq3V5I.js} +1 -1
- package/dist/assets/{Data-ChStbBhF.js → Data-B4v6EPpd.js} +1 -1
- package/dist/assets/DeviceDetail-DN1pAPt3.js +2 -0
- package/dist/assets/{DeviceDoActionFields-GHZBRE4Q.js → DeviceDoActionFields-Bug4MwQJ.js} +1 -1
- package/dist/assets/{Devices-Bzyikktm.js → Devices-KmaQ-LCF.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-ClpQaFoO.js → EmbedPlayerPage-BY2XhLHQ.js} +1 -1
- package/dist/assets/HelperWizard-Drtw6fE7.js +2 -0
- package/dist/assets/{History-C6N6VRgs.js → History-Cki8lIL-.js} +1 -1
- package/dist/assets/{Identity-CvFSqL46.js → Identity-BtyNBp3O.js} +1 -1
- package/dist/assets/{IntegrationDetail-AVnEA7GO.js → IntegrationDetail-CDuDFjTz.js} +1 -1
- package/dist/assets/{IntegrationHub-BqWPAkYu.js → IntegrationHub-MVJMjpE_.js} +1 -1
- package/dist/assets/{Integrations-BYiw8_da.js → Integrations-DK3VNmwY.js} +1 -1
- package/dist/assets/{Integrations-CBEyPYvE.js → Integrations-DylF9Lra.js} +1 -1
- package/dist/assets/{Library-BcuUHsq3.js → Library-CThT-nC_.js} +1 -1
- package/dist/assets/{Locations-BrPK_nfE.js → Locations-hoUXKzbY.js} +1 -1
- package/dist/assets/{Logs-D_Jnlf_J.js → Logs-CuZNCBMH.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-C1WSjh5s.js → MaskShapeCanvas-H8Uoh2Rl.js} +1 -1
- package/dist/assets/{MotionZonesSettings-BB6LidaW.js → MotionZonesSettings-D0q6jZRy.js} +1 -1
- package/dist/assets/{MyAccess-DjL1Z681.js → MyAccess-DJ_NSf4z.js} +1 -1
- package/dist/assets/{Network-DjKf4STc.js → Network-D2CWuowx.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-ivvFi7qU.js → NodeAddonsSettingsPanel-ByFvh4Ya.js} +1 -1
- package/dist/assets/Notifications-PhkAhPCl.js +1 -0
- package/dist/assets/Pipeline-CezBMByn.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-CSdKuS75.js → PrivacyMaskSettings-fx9Jt4aq.js} +1 -1
- package/dist/assets/{Recordings-Ce8DTG1O.js → Recordings-DR4bIAm9.js} +1 -1
- package/dist/assets/{ScanNetworkModal-81xkyJSk.js → ScanNetworkModal-BqRIkfLs.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-ucsduhsM.js → SceneMonitorEditor-B1yZ0Eu1.js} +1 -1
- package/dist/assets/{SessionsList-Dgrg9zT1.js → SessionsList-BgP3ZBPl.js} +1 -1
- package/dist/assets/{Showroom-CkHdCDH1.js → Showroom-H799SxeX.js} +1 -1
- package/dist/assets/{System-HvIXTTB1.js → System-CAQNJeVw.js} +1 -1
- package/dist/assets/{Terminal-CwE2WbSi.js → Terminal-CJDf-QFe.js} +1 -1
- package/dist/assets/{Viewer-B6suHwLq.js → Viewer-bvftBy-T.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BkS64PhS.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-B7Juvi98.js} +1 -1
- package/dist/assets/{addon-icons-context-BY_MClqz.js → addon-icons-context-CZDtt3fG.js} +1 -1
- package/dist/assets/{archive-DSecC29S.js → archive-C0MjJGmq.js} +1 -1
- package/dist/assets/{assignment-candidates-CCD35Rpj.js → assignment-candidates--urRZfaK.js} +1 -1
- package/dist/assets/{authed-media-Dow1_6zk.js → authed-media-CQZkp0uZ.js} +1 -1
- package/dist/assets/{bell-off-kKEnaAlY.js → bell-off-B11l1KzS.js} +1 -1
- package/dist/assets/{board-model-CGmvb_0S.js → board-model-BnBpDyVJ.js} +1 -1
- package/dist/assets/{boxes-D29FuJd_.js → boxes-B-VqzPaN.js} +1 -1
- package/dist/assets/circle-slash-DpPZDUlw.js +1 -0
- package/dist/assets/client-BXtMEX7J.js +358 -0
- package/dist/assets/{cloud-upload-CNHrN4UO.js → cloud-upload--LDpDxLV.js} +1 -1
- package/dist/assets/crop-8n46w7Ev.js +1 -0
- package/dist/assets/{device-integration-icon-Dg_7SOuH.js → device-integration-icon-DcyxPquH.js} +1 -1
- package/dist/assets/device-picker-model-BQTVmtuR.js +1 -0
- package/dist/assets/dist-DhXv40Tk.js +358 -0
- package/dist/assets/{dist-pyNtUJBC.js → dist-oBKSec40.js} +1 -1
- package/dist/assets/{eraser-DQdA4r-4.js → eraser-DolDpTaf.js} +1 -1
- package/dist/assets/{format-CvRuKl82.js → format-pVRrtm44.js} +1 -1
- package/dist/assets/{hard-drive-download-BWtxkXEP.js → hard-drive-download-Dxd7SImQ.js} +1 -1
- package/dist/assets/{hostInit-C4zImIaq.js → hostInit-CXxiiIY9.js} +1 -1
- package/dist/assets/i18n-CI5vBtLY.js +1 -0
- package/dist/assets/{icons-CeHJ12H1.js → icons-BXkvTO6P.js} +1 -1
- package/dist/assets/{index-4kmzPYxW.js → index-T3VEitv1.js} +3 -3
- package/dist/assets/{key-ibd36DX6.js → key-BBVN8veo.js} +1 -1
- package/dist/assets/{key-round-Cx5S95mB.js → key-round-DFWP4tGQ.js} +1 -1
- package/dist/assets/{layers-f2rCYTNI.js → layers-VCbN12xK.js} +1 -1
- package/dist/assets/{linked-devices-model-DBaDc0Fe.js → linked-devices-model-BuZsJyfK.js} +1 -1
- package/dist/assets/{list-ordered-DVEuSX72.js → list-ordered-Bnu2an56.js} +1 -1
- package/dist/assets/{location-owned-usage-D20qY7jM.js → location-owned-usage-CWqIQnLv.js} +1 -1
- package/dist/assets/{log-in-YSzSSnpb.js → log-in-QKfmNI9M.js} +1 -1
- package/dist/assets/{memory-stick-BxkFX9Lp.js → memory-stick-ByO8UQ_K.js} +1 -1
- package/dist/assets/{message-square-plus-CReLm1AI.js → message-square-plus-DiTP4R_X.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-3901d897.js → mf-entry-bootstrap-0-4541da62.js} +2 -2
- package/dist/assets/{mic-off-CzIbHCeE.js → mic-off-C0mR7Yh9.js} +1 -1
- package/dist/assets/{monitor-off-D6AnJas6.js → monitor-off-D4PWqGzI.js} +1 -1
- package/dist/assets/{monitor-smartphone-BYEnK_6t.js → monitor-smartphone-CfagfDx-.js} +1 -1
- package/dist/assets/mount-BQTVmtuR.js +1 -0
- package/dist/assets/{player-overlays-nQJCQERn.js → player-overlays-BiCGuJYq.js} +1 -1
- package/dist/assets/{recycle-CWMxz1Q3.js → recycle-By0RJmi2.js} +1 -1
- package/dist/assets/remoteEntry-QPteGTQh.js +1 -0
- package/dist/assets/{scan-eye-t_4fVxI4.js → scan-eye-BiviIx2-.js} +1 -1
- package/dist/assets/{scissors-DL5nVl1a.js → scissors-M9cnfGNe.js} +1 -1
- package/dist/assets/{search-x-CbPl9Xi3.js → search-x-BpDq9t4w.js} +1 -1
- package/dist/assets/{send-BQl_zLK4.js → send-CeinPhnc.js} +1 -1
- package/dist/assets/{settings-2-7F6aVC_u.js → settings-2-D03xdo5Y.js} +1 -1
- package/dist/assets/{sigma-kEBBYTCa.js → sigma-BZFLmOnk.js} +1 -1
- package/dist/assets/{speaker-CkI0pe60.js → speaker-BhDPU-6o.js} +1 -1
- package/dist/assets/src-BjL-Slsn.js +67 -0
- package/dist/assets/{step-inspector-model-HSCaPOVt.js → step-inspector-model-BIqRCy44.js} +1 -1
- package/dist/assets/{table-2-Cukv2oib.js → table-2-CgTH2D0_.js} +1 -1
- package/dist/assets/{timer-reset-hysIbh2s.js → timer-reset-kr9YJtPF.js} +1 -1
- package/dist/assets/{ungroup-D4Nql8ck.js → ungroup-DfwG9mBj.js} +1 -1
- package/dist/assets/{unlink-DNVVxO6S.js → unlink-BPmdzYDS.js} +1 -1
- package/dist/assets/{usb-DNmhv4AW.js → usb-DXw4Me1_.js} +1 -1
- package/dist/assets/{use-scenes-feed-BUQTm5ig.js → use-scenes-feed-B9V1zhs9.js} +1 -1
- package/dist/assets/{use-stationary-objects-B4f1cFoy.js → use-stationary-objects-ClCDS30T.js} +1 -1
- package/dist/assets/useEventInvalidation-BQTVmtuR.js +1 -0
- package/dist/assets/{useNodeUrlSelection-BKSL_pMO.js → useNodeUrlSelection-BWBjwQx2.js} +1 -1
- package/dist/assets/user-round-Uear1YP1.js +1 -0
- package/dist/assets/{user-x-DGZKKLZG.js → user-x-Dv1oqFyS.js} +1 -1
- package/dist/assets/{video-DEeXGFHo.js → video-C46Ugbpc.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CF1E4s_B.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Bi73_PFJ.js} +2 -2
- package/dist/index.html +9 -9
- package/dist/server/addon.js +21 -5
- package/package.json +1 -1
- package/dist/assets/AiProfiles-Dr62eghf.js +0 -3
- package/dist/assets/Build-B8CmNZth.js +0 -40
- package/dist/assets/DeviceDetail-B4rdvagQ.js +0 -2
- package/dist/assets/HelperWizard-C9VjtAAi.js +0 -2
- package/dist/assets/Notifications-Ck0_YzEY.js +0 -1
- package/dist/assets/Pipeline-4J5lhNWd.js +0 -1
- package/dist/assets/circle-slash-BEdaE_jf.js +0 -1
- package/dist/assets/client-CdHPjeIs.js +0 -358
- package/dist/assets/crop-E8rhIxyE.js +0 -1
- package/dist/assets/device-picker-model-CdWcoivb.js +0 -1
- package/dist/assets/dist-CMh2DitE.js +0 -358
- package/dist/assets/i18n-Dgilx0WT.js +0 -1
- package/dist/assets/mount-CdWcoivb.js +0 -1
- package/dist/assets/remoteEntry-BNS8ga8f.js +0 -1
- package/dist/assets/src-DzfpPZrG.js +0 -67
- package/dist/assets/useEventInvalidation-CdWcoivb.js +0 -1
- package/dist/assets/user-round-I0Uty2ao.js +0 -1
|
@@ -1 +1 @@
|
|
|
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{$i as u,An as d,Bn as f,Ci as p,D as m,In as h,Lt as g,Mi as _,Pt as v,Si as y,Sn as b,Vr as x,Zr as S,bi as C,ci as w,cn as T,dt as E,fn as D,gi as O,mi as k,mn as A,ot as j,pn as M,sr as N,wn as P,xn as F,yn as I}from"./player-overlays-nQJCQERn.js";import{ba as L,ga as ee,ha as te,ma as ne}from"./client-CdHPjeIs.js";import{t as re}from"./hard-drive-download-BWtxkXEP.js";import{t as ie}from"./memory-stick-BxkFX9Lp.js";import{t as ae}from"./unlink-DNVVxO6S.js";import{$l as oe,$r as R,$t as se,Ad as z,Cn as ce,Dd as B,Ed as le,Er as ue,P as de,Ql as fe,Sn as V,Tr as H,Xl as pe,Yc as me,Zl as he,Zr as U,_r as ge,ac as _e,at as ve,bn as ye,bu as be,dc as xe,di as Se,dr as Ce,en as we,fc as Te,fi as Ee,fl as De,fr as Oe,gr as ke,hr as Ae,ic as je,kn as Me,ld as W,mc as Ne,mr as Pe,oi as Fe,pc as Ie,pi as Le,pr as Re,rl as ze,ui as Be,vl as Ve,vt as He,wr as Ue,xn as We,xo as Ge,xt as G}from"./src-DzfpPZrG.js";import{t as K}from"./i18n-Dgilx0WT.js";import{t as q}from"./useTranslation-BJr-n0es.js";import{gr as Ke,x as qe}from"./index-4kmzPYxW.js";import{t as Je}from"./AdminPage-D6Yva5zf.js";import{t as Ye}from"./NodeAddonsSettingsPanel-ivvFi7qU.js";import{f as Xe,l as Ze,m as Qe,u as $e}from"./board-model-CGmvb_0S.js";import{t as J}from"./format-size-DIxKXxtj.js";import{n as et,t as tt}from"./useNodeUrlSelection-BKSL_pMO.js";s();var nt={unpaired:`Not paired`,pending:`Pairing…`,paired:`Paired`},rt=new Set([`paired`,`rejected`,`failed`,`expired`]);function Y(e){return rt.has(e)}function it(e){return e.replace(/\D/g,``).slice(0,6)}function at(e){return e.length===6}function ot(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 st(e,t){return e.includes(`:`)?`[${e}]:${t}`:`${e}:${t}`}function ct(e){return e.length<=23?e:`${e.slice(0,20)}…`}function lt({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 ut(e){return e===`awaiting-both`||e===`awaiting-hub`}var dt={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`},ft=2e3,pt=1e3;function mt(e){return e.message.length>0?e.message:K.t(`pairing.agentsFoundSection.requestFailed`)}function ht(e){return e.length===6?`${e.slice(0,3)} ${e.slice(3)}`:e}function gt(e){let[t,n]=o(()=>Date.now());return a(()=>{if(!e)return;let t=setInterval(()=>n(Date.now()),pt);return()=>clearInterval(t)},[e]),t}function _t({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=z.agentPairing.beginPairing.useMutation(),x=z.agentPairing.confirmPairing.useMutation(),S=z.agentPairing.rejectPairing.useMutation();a(()=>{if(n===null){y.current=null,f(null),m(null),g(``),v(null);return}y.current!==n&&(y.current=n,b.mutateAsync({host:n.host,port:n.port}).then(e=>{y.current===n&&f(e.pairingId)}).catch(e=>{y.current===n&&m(mt(e))}))},[n]);let C=z.agentPairing.getPairing.useQuery({pairingId:d??``},{enabled:d!==null,refetchInterval:e=>{let t=e.state.data?.state;return t!==void 0&&Y(t)?!1:ft}}),w=vt(x.data??S.data??null,C.data??null),T=lt({view:w,beginError:p}),E=w!==null&&Y(w.state),D=t(!1);a(()=>{if(!E){D.current=!1;return}D.current||(D.current=!0,s())},[E,s]);let O=gt(w!==null&&!E),k=()=>{d===null||!at(h)||(v(null),x.mutate({pairingId:d,code:h},{onError:e=>{v(mt(e)),g(``)}}))};return i(Ce,{open:n!==null,onOpenChange:e=>!e&&r(),children:e(Re,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(ke,{children:[i(ge,{children:u(`pairing.pairingDialog.title`,{node:n?.nodeId??``})}),i(Pe,{children:n===null?``:u(`pairing.pairingDialog.eachScreenShowsACode`,`Each screen shows a code; you type the code from the OTHER screen. Agent at {{value1}}`,{value1:st(n.host,n.port)})})]}),e(Oe,{className:`space-y-4`,children:[i(yt,{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(bt,{view:w,phase:T,now:O,typed:h,onType:e=>g(it(e)),onSubmit:k,confirmError:_,busy:x.isPending}),T===`paired`&&w!==null&&i(xt,{nodeId:w.nodeId,onOpenNode:c,onClose:r}),E&&T!==`paired`&&w?.failure!=null&&i(H,{message:w.failure})]}),i(Ae,{children:E||T===`send-failed`?i(R,{type:`button`,variant:`outline`,onClick:r,children:u(`common.close`,`Close`)}):e(l,{children:[i(R,{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`)}),ut(T)&&e(R,{type:`button`,disabled:!at(h)||x.isPending,onClick:k,children:[x.isPending&&i(N,{className:`h-4 w-4 animate-spin`}),u(`common.confirm`,`Confirm`)]})]})})]})})}function vt(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 yt({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(N,{className:`h-4 w-4 animate-spin`}),r&&i(k,{className:`h-4 w-4`}),a&&i(w,{className:`h-4 w-4`}),dt[t]]})}function bt({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 — read it out to the agent`)}),i(`p`,{"data-testid":`hub-code`,className:`mt-1 font-mono text-3xl font-semibold tracking-widest text-foreground`,children:ht(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).`)})]}),ut(n)?i(`form`,{className:`space-y-2`,onSubmit:e=>{e.preventDefault(),s()},children:i(G,{label:u(`pairing.pairingDialog.codeShownOnTheAgent`,`Code shown on the agent`),description:u(`pairing.pairingDialog.typeTheSixDigitsThe`,`Type the six digits the agent displays. Do not copy the code above.`),...c===null?{}:{error:c},children:i(W,{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:ot(t.expiresAt,r)})})]})]})}function xt({nodeId:t,onOpenNode:n,onClose:r}){let{t:a}=q(),{nodes:o}=le(),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(T,{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(R,{type:`button`,size:`sm`,variant:`outline`,disabled:!s,onClick:()=>{r(),n(t)},children:a(`pairing.pairingDialog.openNode`,`Open node`)})]})}var St={paired:`success`,pending:`warning`,unpaired:`default`};function Ct({state:t,connected:n}){let{t:r}=q();return e(`span`,{className:`inline-flex items-center gap-1.5`,children:[i(Fe,{variant:St[t],className:`text-[10px]`,children:nt[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 wt(e){if(e.trim().length===0)return;let t=Number(e);return Number.isInteger(t)&&t>=1&&t<=65535?t:null}function Tt({onOpenNode:t}){let{t:r}=q(),a=U(),s=z.useUtils(),c=z.agentPairing.listDiscoveredAgents.useQuery(void 0,{refetchInterval:15e3}),[u,f]=o(null),[p,h]=o(null),[g,_]=o(!1),[v,y]=o(``),[b,x]=o(``),[S,C]=o(null),[w,T]=o(!1),E=()=>void s.agentPairing.listDiscoveredAgents.invalidate(),D=z.agentPairing.addAgentByAddress.useMutation({onSuccess:()=>{_(!1),y(``),x(``),C(null),E()},onError:e=>C(e.message)}),O=z.agentPairing.unpairAgent.useMutation({onSuccess:e=>{h({tone:`success`,message:`${e.nodeId}: ${e.next}${e.agentNotified?``:` The agent could not be told; forget the hub on its own page.`}`}),E()},onError:e=>h({tone:`danger`,message:r(`pairing.agentsFoundSection.unpairFailed`,`Unpair failed: {{message}}`,{message:e.message})})}),k=n(()=>(c.data?.agents??[]).toSorted((e,t)=>X[e.state]-X[t.state]),[c.data]),A=async()=>{T(!0);try{await s.agentPairing.listDiscoveredAgents.fetch({refresh:!0}),E()}finally{T(!1)}},j=()=>{let e=wt(b);if(e===null){C(`The port must be a whole number between 1 and 65535.`);return}C(null),D.mutate({host:v.trim(),...e===void 0?{}:{port:e}})},M=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`})&&(h(null),O.mutate({nodeId:e.nodeId}))},I=n(()=>[{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:st(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(Ct,{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:ct(e.fingerprint)}),sortValue:e=>e.fingerprint},{key:`actions`,header:``,align:`right`,notSortableReason:`Row actions`,render:e=>e.state===`unpaired`?i(R,{type:`button`,size:`sm`,onClick:()=>f({nodeId:e.nodeId,host:e.host,port:e.port}),children:r(`pairing.agentsFoundSection.pair`,`Pair`)}):e.state===`paired`?i(R,{type:`button`,size:`sm`,variant:`outline`,disabled:O.isPending,onClick:()=>void M(e),children:r(`pairing.agentsFoundSection.unpair2`,`Unpair`)}):null}],[O.isPending,r]);return e(ye,{headingId:`agents-found`,title:r(`pairing.agentsFoundSection.agentsFoundOnTheNetwork`,`Agents found on the network`),icon:P,testId:`agents-found`,actions:e(l,{children:[e(R,{type:`button`,size:`sm`,variant:`outline`,disabled:w,onClick:()=>void A(),children:[w?i(N,{className:`h-3.5 w-3.5 animate-spin`}):i(F,{className:`h-3.5 w-3.5`}),r(`pairing.agentsFoundSection.scan`,`Scan`)]}),e(R,{type:`button`,size:`sm`,onClick:()=>_(e=>!e),children:[i(d,{className:`h-3.5 w-3.5`}),r(`pairing.agentsFoundSection.addByAddress`,`Add by address`)]})]}),children:[e(`div`,{className:`${m} 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.`)}),g&&e(`form`,{"aria-label":r(`pairing.agentsFoundSection.addAgentByAddress`,`Add agent by address`),className:`flex flex-wrap items-start gap-2`,onSubmit:e=>{e.preventDefault(),v.trim().length>0&&!D.isPending&&j()},children:[i(G,{label:r(`pairing.agentsFoundSection.address`,`Address`),description:r(`pairing.agentsFoundSection.aPrivateOrLocalAddress`,`A private or local address only.`),...S===null?{}:{error:S},children:i(W,{value:v,onChange:e=>y(e.target.value),placeholder:`192.0.2.20`,"aria-label":r(`pairing.agentsFoundSection.agentAddress`,`Agent address`),autoComplete:`off`})}),i(G,{label:r(`pairing.agentsFoundSection.port`,`Port`),description:r(`pairing.agentsFoundSection.optional`,`Optional.`),children:i(W,{value:b,onChange:e=>x(e.target.value),placeholder:`4444`,inputMode:`numeric`,"aria-label":r(`pairing.agentsFoundSection.agentPort`,`Agent port`),className:`w-24`})}),e(R,{type:`submit`,size:`sm`,className:`mt-5`,disabled:v.trim().length===0||D.isPending,children:[D.isPending&&i(N,{className:`h-3.5 w-3.5 animate-spin`}),r(`common.add`,`Add`)]})]}),p!==null&&i(`p`,{role:`status`,className:`rounded border px-3 py-2 text-xs ${p.tone===`success`?`border-success/30 text-foreground`:`border-danger/40 text-danger`}`,children:p.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:E}):c.isLoading?i(`p`,{className:`py-4 text-center text-xs text-foreground-muted`,children:r(`pairing.agentsFoundSection.lookingForAgents`,`Looking for agents…`)}):k.length===0?i(ue,{icon:P,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(V,{columns:I,rows:k,rowKey:e=>e.nodeId,minWidthPx:720,defaultSort:{columnKey:`state`,dir:`asc`}})]}),i(_t,{target:u,onClose:()=>f(null),onSettled:E,onOpenNode:t})]})}function Et(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Dt(e){if(!Et(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 Ot(e){let t=e.trim();return!(t.length===0||t.includes(`/`)||t.includes(`?`)||t.includes(`#`)||t.includes(`@`)||t.includes(`:`))}function kt(e){return e.startsWith(`172.17.`)}function At(e){let t=/^100\.(\d+)\./.exec(e);if(t===null)return!1;let n=Number(t[1]);return n>=64&&n<=127}function jt(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&&!kt(e)}function Mt(e,t){if(typeof t==`string`&&Ot(t))return t.trim();let n=e.filter(e=>!e.includes(`:`)),r=n.find(e=>!e.startsWith(`127.`)&&!e.startsWith(`169.254.`)&&!kt(e)&&!At(e)&&jt(e));if(r!==void 0)return r;for(let e of n)if(!e.startsWith(`127.`)&&!e.startsWith(`169.254.`)&&!kt(e))return e;return null}function Nt(e){return`http://${e}:4444/`}function Pt(e,t){let n=new URL(Nt(e));return n.searchParams.set(`ticket`,t),n.toString()}function Ft(){return window.open(`about:blank`,`_blank`)}function It(e,t){return e===null||e.closed?!1:(e.location.href=t,!0)}function Lt({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 Rt(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 zt(e){return e===`running`?`running`:e===`crashed`||e===`failed`?`error`:`stopped`}var Bt=[`trace`,`debug`,`info`,`warn`,`error`];function Vt({proc:t,nodeId:n,defaultExpanded:r,activePanel:a,onTogglePanel:s}){let{t:c}=q(),l=t.services??[],u=l.length===1,[d,f]=o(u||r),[p,m]=o(null),[h,g]=o(`info`),v=t.name.includes(`(core)`),x=Te(),S=Ie(),w=Ne(),T=async e=>{m(e);try{await x.mutateAsync({nodeId:n,addonId:e})}catch(e){console.error(`Failed to restart addon:`,e)}finally{m(null)}},E=async()=>{m(t.name);try{await S.mutateAsync({nodeId:n,processName:t.name})}catch(e){console.error(`Failed to restart process:`,e)}finally{m(null)}},O=async e=>{let r=`${n}/${t.name}`;try{await w.mutateAsync({nodeId:r,level:e}),g(e)}catch(e){console.error(`Failed to set log level:`,e)}};return e(`div`,{className:`border border-border/50 rounded-lg overflow-hidden`,children:[e(`div`,{role:u?void 0:`button`,tabIndex:u?void 0:0,onClick:u?void 0:()=>f(!d),onKeyDown:u?void 0:e=>{(e.key===`Enter`||e.key===` `)&&f(!d)},className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 w-full px-3 py-2 bg-muted/20 transition-colors text-left select-none ${u?``:`hover:bg-muted/40 cursor-pointer`}`,children:[u?i(`span`,{className:`h-3 w-3 shrink-0`}):i(d?y:C,{className:`h-3 w-3 text-muted-foreground shrink-0`}),v?i(D,{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(ve,{status:zt(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:Rt(t.uptimeSeconds)}),!v&&e(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[e(Be,{children:[i(Le,{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:h}),i(Se,{align:`end`,className:`min-w-[70px] py-0.5`,children:Bt.map(e=>i(Ee,{onClick:()=>O(e),className:`h-auto px-2 py-1 text-[10px] font-mono ${e===h?`text-primary font-semibold`:``}`,children:e},e))})]}),i(`button`,{onClick:E,disabled:p===t.name,className:`p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:c(`cluster.forksTab.restartProcess`,`Restart process`),children:i(I,{className:`h-3 w-3 ${p===t.name?`animate-spin`:``}`})})]})]}),d&&l.length>0&&i(`div`,{className:`divide-y divide-border/30`,children:l.map(t=>e(`div`,{children:[e(`div`,{className:`flex items-center gap-2 px-3 py-1.5 pl-9 hover:bg-muted/10 transition-colors`,children:[i(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${t.status===`running`?`bg-success`:`bg-muted-foreground/30`}`}),i(`span`,{className:`text-xs font-medium flex-1 min-w-0 truncate`,children:t.addonId}),t.capabilities.length>0&&e(`div`,{className:`flex gap-1 flex-shrink-0`,children:[t.capabilities.slice(0,3).map(e=>i(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-info/10 text-info truncate max-w-[80px]`,children:e},e)),t.capabilities.length>3&&e(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,t.capabilities.length-3]})]}),e(`div`,{className:`flex items-center gap-1 shrink-0`,children:[i(`button`,{onClick:()=>s(t.addonId,`logs`),className:`p-0.5 rounded transition-colors ${a?.addonId===t.addonId&&a.type===`logs`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:c(`cluster.forksTab.showLogsFor`,`Show logs for {{addonId}}`,{addonId:t.addonId}),children:i(A,{className:`h-3 w-3`})}),i(`button`,{onClick:()=>s(t.addonId,`events`),className:`p-0.5 rounded transition-colors ${a?.addonId===t.addonId&&a.type===`events`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:c(`cluster.forksTab.showEventsFor`,`Show events for {{addonId}}`,{addonId:t.addonId}),children:i(b,{className:`h-3 w-3`})}),i(`button`,{onClick:()=>T(t.addonId),disabled:p===t.addonId,className:`p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:c(`cluster.forksTab.restart`,`Restart {{addonId}}`,{addonId:t.addonId}),children:i(I,{className:`h-3 w-3 ${p===t.addonId?`animate-spin`:``}`})})]})]}),a?.addonId===t.addonId&&a.type===`logs`&&i(`div`,{className:`border-t border-border/40 bg-muted/5`,children:i(we,{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(se,{addonId:t.addonId,category:`addon.*`,maxHeight:`max-h-48`,onClose:()=>s(t.addonId,`events`)})})]},t.addonId))}),d&&l.length===0&&i(`div`,{className:`px-3 py-2 pl-9 text-[10px] text-muted-foreground`,children:c(`cluster.forksTab.noServices`,`No services`)})]})}function Ht({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(Vt,{proc:t,nodeId:e,defaultExpanded:n===0,activePanel:r,onTogglePanel:s},t.name))})}var Ut={system:0,managed:1,root:2};s();function Wt(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 Gt(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function Kt({nodeId:t}){let{t:r}=q(),a=c(),o=B(`metrics.node-processes-snapshot`,e=>e.nodeId===t),{data:s}=_e({nodeId:t}),l=o?.processes??s,u=n(()=>l?[...l]:[],[l]),d=n(()=>[{key:`classification`,header:r(`cluster.processesTab.class`,`Class`),sortValue:e=>Ut[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:Gt(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:Wt(e.uptimeSec)})}],[r]);return e(`div`,{className:`space-y-4`,children:[i(`div`,{className:`flex items-start justify-end gap-4`,children:e(`button`,{type:`button`,onClick:()=>a.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]}),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground hover:bg-surface-hover`,children:[i(F,{className:`h-3 w-3`}),` `,r(`common.refresh`)]})}),i(V,{columns:d,rows:u,rowKey:e=>e.pid,minWidthPx:880,maxBodyHeight:ce,emptyMessage:r(`cluster.processesTab.scanning`,`Scanning…`)})]})}s();var qt=96;function Jt({title:e,points:t,mainLabel:r,gcLabel:a,formatValue:o,emptyMessage:s,gapMs:c}){return i(de,{title:e,series:n(()=>[{id:`main`,label:r,unit:`%`,colorIndex:0,gapMs:c,points:t.map(e=>({t:e.atMs,v:e.main}))},{id:`gc`,label:a,unit:`%`,colorIndex:1,gapMs:c,points:t.map(e=>({t:e.atMs,v:e.gc}))}],[t,r,a,c]),stacked:!0,height:qt,formatValue:e=>o(e),axisFor:()=>({floor:25}),emptyMessage:s})}function Z({title:e,points:t,formatValue:r,emptyMessage:a,axisFloor:o,axisScale:s=`linear`,gapMs:c}){return i(de,{title:e,series:n(()=>[{id:`value`,label:e,unit:s===`bytes`?`B`:null,colorIndex:0,gapMs:c,points:t.map(e=>({t:e.atMs,v:e.value}))}],[t,e,s,c]),height:qt,formatValue:e=>r(e),axisFor:()=>({floor:o,scale:s}),emptyMessage:a})}function Yt(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 Xt(e,t,n,r){let i=e.get(t),a=Yt(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 Zt(e,t,n){let r=e;for(let e of L(t,n))r=Xt(r,e.key,e.kind,e.point);return r}function Qt(e,t){let n=e;for(let e of t)for(let t of e.points)n=Xt(n,e.key,e.kind,t);return n}function $t(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 en=12e4;function tn(e,t){return e===null?!1:t-e>en}function nn(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 rn(e){for(let t of e.values()){let e=t.points.at(-1);if(e&&e.cpuMainPercent!==null)return!0}return!1}var an={key:`cpu`,dir:`desc`};function on(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 sn(e){return e.points.at(-1)?.memoryRssBytes??null}function cn(e,t,n){let r=n.trim().toLowerCase();return r===``?!0:e.toLowerCase().includes(r)||t.toLowerCase().includes(r)}function ln(e,t){return t===`memory`?sn(e):on(e)}function un(e,t,n){let r=e.filter(e=>t.selectedKeys.size>0&&!t.selectedKeys.has(e.key)?!1:cn(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=ln(e,t.sort.key),o=ln(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 dn(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}=je({forNodeId:e,sinceMs:c,maxPoints:n});a(()=>{d!==void 0&&s(e=>{let t=Qt(e,d.series);return u.current=$t(t),t})},[d]);let p=r?.timestamp;a(()=>{r==null||p===void 0||(tn(u.current,p)&&l(u.current??0),s(e=>{let t=Zt(e,r.processes,p);return u.current=$t(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:nn(i),sampleCount:m,threadSplitAvailable:rn(i),loadingRetained:f,durable:d?.durable??null,bucketMs:d?.bucketMs??null,cadenceMs:d?.cadenceMs??null,retainedSamples:d?.retainedSamples??null}}var fn=`__unclaimed__`;function pn(e,t){return{kind:e,deviceId:t,cpu:0,cpuKnown:!0,rss:0,rssKnown:!0,count:0,roles:new Set}}function mn(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 hn(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)??pn(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])=>mn(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=pn(`unclaimed`,null);for(let e of a)o.count+=1,o.rss+=e.memoryRssBytes;return o.cpuKnown=!1,[...i,mn(fn,o)]}var gn=[{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 _n(e){return e.attribution===`measured`&&e.wiredToday}function vn(){let e=new Set;for(let t of gn)_n(t)&&e.add(t.family);return e}var yn=vn();function bn(e){return!yn.has(e.role)||e.deviceId===null?!1:e.attribution===`measured`}function xn(e){return`${e.addonId}${e.role}${e.unit}${e.pid??`-`}`}function Sn(){return{cpuSeconds:0,cpuKnown:!0,rssBytes:0,rssKnown:!0,unitCount:0,roles:new Set}}function Cn(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 wn(e){return Math.round(e*10)/10}function Tn(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)bn(t)&&i.set(xn(t),t);let a=new Map,o=new Set;for(let n of t.entries){if(!bn(n)||n.deviceId===null)continue;let t=xn(n);o.add(t);let r=a.get(n.deviceId)??Sn();r.unitCount+=1,r.roles.add(n.role);let s=Cn(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?wn(n.cpuSeconds/r*100):null,rssBytes:n.rssKnown?n.rssBytes:null,unitCount:n.unitCount,roles:[...n.roles].toSorted()}}))}function En(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 Dn(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 On(e){let t=e.indexOf(`@`);return t===-1?{addonId:e,nodeId:null}:{addonId:e.slice(0,t),nodeId:e.slice(t+1)}}function kn(e,t){let n=On(e);return n.nodeId===null?t.isHub:n.nodeId===t.nodeId}function An(e,t){return e.filter(e=>kn(e.addonId,t))}s();function jn(e){let n=B(`metrics.node-processes-snapshot`,t=>t.nodeId===e.nodeId),r=be(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:An(d,e)},n=c.current;if(c.current=t,n===null)return;let r=Tn(n,t);r.length!==0&&s(e=>En(e,r))},[d,f,e.nodeId,e.isHub]);let p=d===void 0?[]:An(d,e),m=n?.processes,h=hn(p,m);return{series:Dn(i),unclaimed:h.find(e=>e.kind===`unclaimed`)??null,loading:r.isPending,error:r.error===null?null:r.error.message}}function Mn(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 Nn=25,Pn=64*1024*1024,Fn=1e4;function In({scope:t,cadenceMs:n}){let{t:r}=q(),a=jn(t),{data:o=[]}=Ge({isCamera:!0,projection:`slim`}),s=Mn(o),c=Ue(n??Fn);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(v,{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(Rn,{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(Ln,{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(Z,{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:Nn,gapMs:c,emptyMessage:r(`cameraLoad.cpuUnavailable`,`No measurable window yet.`)}),i(Z,{title:r(`cameraLoad.memoryTitle`,`Memory RSS`),points:t.points.map(e=>({atMs:e.atMs,value:e.rssBytes})),formatValue:J,axisFloor:Pn,axisScale:`bytes`,gapMs:c,emptyMessage:r(`cameraLoad.memoryUnavailable`,`No memory reported.`)})]})]},t.deviceId))})]})}function Ln({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 Rn({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 zn=256*1024*1024,Bn=1e4;function Vn({nodeId:t,isHub:r}){let{t:a}=q(),{series:s,sampleCount:c,threadSplitAvailable:l,loadingRetained:u,bucketMs:d,cadenceMs:f}=dn(t),[p,m]=o(``),[h,g]=o(new Set),[_,y]=o(an),b=e=>e.key===`__root__`?a(`clusterLoad.bucketRoot`,`Node supervisor`):e.key===`__unattributed__`?a(`clusterLoad.bucketUnattributed`,`Unattributed processes`):e.key,x=Ue(d??f??Bn),S=n(()=>un(s,{search:p,selectedKeys:h,sort:_},b),[s,p,h,_]),C=e=>{g(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(Hn,{bucketMs:d,cadenceMs:f}),!l&&c>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(v,{className:`h-3 w-3 mt-0.5 shrink-0`}),i(`span`,{children:a(`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.`)})]}),c===0&&i(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:u?a(`clusterLoad.loadingRetained`,`Reading the retained series from this node…`):a(`clusterLoad.waitingFirstSample`,`No retained samples for this node — waiting for the next snapshot (up to 20s). The chart needs two to draw a rate.`)}),s.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(M,{className:`pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-foreground-subtle`}),i(`input`,{type:`search`,value:p,onChange:e=>m(e.target.value),placeholder:a(`clusterLoad.searchPlaceholder`,`Find a runner…`),"aria-label":a(`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(Un,{sort:_,onChange:y})]}),e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[s.map(e=>{let t=h.has(e.key);return i(`button`,{type:`button`,"aria-pressed":t,onClick:()=>C(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:b(e)},e.key)}),h.size>0&&e(`button`,{type:`button`,onClick:()=>g(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(E,{className:`h-2.5 w-2.5`}),a(`clusterLoad.clearFilter`,`All runners`)]})]})]}),s.length>0&&S.length===0&&i(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:a(`clusterLoad.noMatches`,`No runner matches this search on {{count}} present. The node is reporting — the filter is hiding them.`,{count:s.length})}),i(`div`,{className:`space-y-3`,children:S.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:b(t)}),i(`span`,{className:`text-[10px] text-foreground-subtle`,children:a(`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(Jt,{title:l?a(`clusterLoad.cpuTitle`,`CPU % of one core`):a(`clusterLoad.cpuTitleLifetime`,`CPU % (ps lifetime average)`),mainLabel:a(`clusterLoad.seriesMain`,`Main threads`),gcLabel:a(`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:x,emptyMessage:a(`clusterLoad.cpuUnavailable`,`No thread split on this node. Lifetime average: {{avg}}%`,{avg:(t.points.at(-1)?.cpuLifetimePercent??0).toFixed(1)})}),i(Z,{title:a(`clusterLoad.memoryTitle`,`Memory RSS`),points:t.points.map(e=>({atMs:e.atMs,value:e.memoryRssBytes})),formatValue:J,axisFloor:zn,axisScale:`bytes`,gapMs:x,emptyMessage:a(`clusterLoad.memoryUnavailable`,`No memory samples yet.`)})]})]},t.key))}),i(In,{scope:{nodeId:t,isHub:r},cadenceMs:f})]})}function Hn({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 Un({sort:t,onChange:n}){let{t:r}=q(),a=[{key:`cpu`,label:r(`clusterLoad.sortCpu`,`CPU`)},{key:`memory`,label:r(`clusterLoad.sortMemory`,`Memory`)},{key:`name`,label:r(`clusterLoad.sortName`,`Name`)}];return e(`div`,{className:`flex items-center gap-1`,children:[i(`span`,{className:`text-[10px] text-foreground-subtle`,children:r(`clusterLoad.sortBy`,`Sort by`)}),a.map(r=>{let i=t.key===r.key;return e(`button`,{type:`button`,"aria-pressed":i,onClick:()=>n(i?{key:r.key,dir:t.dir===`desc`?`asc`:`desc`}:{key:r.key,dir:r.key===`name`?`asc`:`desc`}),className:`rounded border px-1.5 py-0.5 text-[10px] transition-colors ${i?`border-primary bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground`}`,children:[r.label,i&&(t.dir===`desc`?` ↓`:` ↑`)]},r.key)})]})}var Wn=`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 Gn({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(Ye,{nodeId:e,addonIds:t,level:`global`,fieldScope:`perNode`,emptyMessage:Wn,selfTabbed:!0})})}s();function Kn({nodeId:e,addons:t}){let{t:r}=q(),a=c(),{data:o,isLoading:s}=me({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=Ve({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(V,{columns:[{key:`capName`,header:r(`cluster.nodeDetailCapabilitiesTab.capability`,`Capability`),width:`w-1/2`,sortValue:e=>e.capName,render:e=>i(`span`,{className:`font-medium`,children:e.capName})},{key:`provider`,header:r(`cluster.nodeDetailCapabilitiesTab.boundProvider`,`Bound provider`),render:t=>{let n=o?.[t.capName]??t.providers[0]??``,a=t.providers.length===1;return i(`select`,{value:n,onChange:n=>u.mutate({nodeId:e,capName:t.capName,addonId:n.target.value}),disabled:a||u.isPending||s,className:`w-full rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-60`,title:a?r(`cluster.nodeDetailCapabilitiesTab.onlyOneProviderInstalledChoice`,`Only one provider installed — choice becomes available once a second addon registers this capability`):void 0,children:t.providers.map(e=>i(`option`,{value:e,children:e},e))})}}],rows:l,rowKey:e=>e.capName,minWidthPx:520,maxBodyHeight:ce})}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 Jn(t){let{t:n}=q(),[r,a]=o(!1),[s,l]=o(t.name),u=c(),d=xe({onSuccess:()=>{u.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}}),f=(t.localIps??[]).filter(e=>!e.includes(`:`)),m=(t.localIps??[]).filter(e=>e.includes(`:`)),g=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)}},_=[[`Node ID`,i(`span`,{className:`font-mono text-xs`,children:t.nodeId})],[`Display Name`,r?e(`div`,{className:`flex items-center gap-1.5`,children:[i(`input`,{type:`text`,className:`flex-1 px-2 py-0.5 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary`,value:s,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&g(),e.key===`Escape`&&a(!1)},disabled:d.isPending,autoFocus:!0}),i(`button`,{onClick:()=>void g(),disabled:d.isPending,className:`p-0.5 text-success hover:bg-success/10 rounded`,title:n(`common.save`,`Save`),children:i(p,{className:`h-3.5 w-3.5`})}),i(`button`,{onClick:()=>a(!1),className:`p-0.5 text-muted-foreground hover:bg-muted rounded`,title:n(`common.cancel`,`Cancel`),children:i(E,{className:`h-3.5 w-3.5`})})]}):e(`div`,{className:`flex items-center gap-1.5`,children:[i(`span`,{className:`text-xs`,children:t.name}),!t.isHub&&i(`button`,{onClick:()=>{l(t.name),a(!0)},className:`p-0.5 text-muted-foreground hover:text-primary rounded`,title:n(`cluster.nodeInfoTab.rename`,`Rename`),children:i(h,{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&&_.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}`))})]),m.length>0&&_.push([`IPv6`,i(`div`,{className:`flex flex-wrap gap-1.5`,children:m.map((e,t)=>i(`span`,{className:`font-mono text-[10px] px-1.5 py-0.5 rounded bg-muted truncate max-w-[280px]`,title:e,children:e},`${e}-${t}`))})]),i(`div`,{className:`py-2`,children:i(`table`,{className:`w-full text-sm`,children:i(`tbody`,{children:_.map(([t,n],r)=>e(`tr`,{className:r%2==0?`bg-muted/20`:``,children:[i(`td`,{className:`py-1.5 px-2 text-xs font-medium text-muted-foreground w-28 align-top whitespace-nowrap`,children:t}),i(`td`,{className:`py-1.5 px-2`,children:n})]},t))})})})}s();function Yn({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 m=r[0],h=m===void 0?`auto-detect`:`auto: ${m}`,g=s===`pending`,_=d.trim(),v=_!==(n??``),y=v&&!g,b=()=>{y&&l(t,_.length>0?_:null)};return e(`div`,{className:`flex items-center gap-1.5`,children:[i(W,{"aria-label":u(`placementBoard.reachableHostInput.reachableHostFor`,`Reachable host for {{nodeId}}`,{nodeId:t}),type:`text`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:h,value:d,disabled:g,onChange:e=>f(e.target.value),onBlur:b,onKeyDown:e=>{e.key===`Enter`&&b(),e.key===`Escape`&&f(n??``)},className:`w-36`}),e(R,{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:[g?i(N,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):i(p,{className:`h-3 w-3`,"aria-hidden":`true`}),u(`common.save`,`Save`)]}),!v&&!g&&s===`success`&&i(p,{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(O,{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 Xn(e){let t=te.safeParse(Xe(e,`color`));return t.success?t.data:null}function Zn(e,t){return t.variables?.agentNodeId===e?t.isPending?`pending`:t.isError?`error`:t.isSuccess?`success`:`idle`:`idle`}function Qn({nodeId:t,detectedHosts:r}){let{t:a}=q(),o=c(),s=ze(void 0),l=De({onSuccess:()=>Ze(o)}),u=De({onSuccess:()=>Ze(o)}),d=n(()=>s.data?.find(e=>e.nodeId===t)?.settings,[s.data,t]),f=Xn(d)??(s.isLoading?null:ee(t)),p=Qe(d,`reachableHost`),m=Zn(t,l),h=m===`error`?$e(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(We,{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:ne.map(e=>{let t=f===e;return i(R,{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 ${Me(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(We,{label:a(`nodes.general.reachableHost`,`Reachable host`),children:i(Yn,{nodeId:t,value:p,detectedHosts:g,status:m,errorMessage:h,onCommit:(e,t)=>{l.mutate({agentNodeId:e,reachableHost:t})}})})]})}s();var $n=[[`serverManagement`,`getServerPackageStatus`]];function er({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 Q({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 tr({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 nr={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 rr(e){return e.outcome===`failed`?`error`:(e.outcome,e.accepted?`ok`:`warn`)}function ir(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 ar({node:t}){let{t:n}=q(),a=c(),s=U(),[l,d]=o(!1),[f,p]=o(null),m=t.isHub?void 0:{nodeId:t.id},h=fe(m,{refetchInterval:1e4,enabled:t.isOnline,retry:1}),g=h.data??null,_=r(()=>{a.invalidateQueries({queryKey:$n})},[a]),v=he({onSettled:_}),y=pe({onSettled:_}),b=oe({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:rr(e),text:e.message}),e.restarting&&d(!0)}catch(e){p({tone:`warn`,text:ir(n,e)})}}},[y,s,t.name,m,g,n]),S=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:rr(e),text:e.message}),e.restarting&&d(!0)}catch(e){p({tone:`warn`,text:ir(n,e)})}}},[s,t.name,b,m,n]),C=()=>{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`}}},w=()=>{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`}}},T=g?.bootMode===`workspace`,E=t.isOnline&&g!=null&&!T&&g.updateAvailable&&g.updateState===`idle`&&!y.isPending,D=t.isOnline&&g!=null&&g.updateState===`idle`&&!b.isPending,O=t.isOnline?w():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(er,{...C()})]}),O!=null&&i(er,{...O})]}),!t.isOnline&&i(Q,{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(N,{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(Q,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:t.rootPackage.version})]}),t.isOnline&&g!=null&&e(`div`,{className:`space-y-1.5`,children:[i(tr,{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.pendingVersion!=null&&i(Q,{label:n(`serverManagement.pendingVersion`,`Staged (applies on restart)`),value:g.pendingVersion}),g.installedVersion!=null&&g.installedVersion!==g.runningVersion&&i(Q,{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&&T&&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 ${nr[f.tone]}`,children:f.text}),l&&e(`div`,{className:`flex items-center gap-2 text-sm text-warning`,children:[i(N,{className:`h-4 w-4 animate-spin`}),n(`serverManagement.nodeRestarting`,`The node is restarting to apply the change…`)]}),t.isOnline&&e(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[e(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-surface-muted disabled:opacity-50`,disabled:v.isPending||g?.updateState===`staging`,onClick:()=>v.mutate(m),children:[v.isPending?i(N,{className:`h-3.5 w-3.5 animate-spin`}):i(F,{className:`h-3.5 w-3.5`}),n(`serverManagement.checkForUpdate`,`Check for update`)]}),E&&e(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded bg-primary px-2.5 py-1.5 text-xs font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50`,onClick:()=>void x(),children:[y.isPending?i(N,{className:`h-3.5 w-3.5 animate-spin`}):i(u,{className:`h-3.5 w-3.5`}),n(`serverManagement.updateTo`,`Update to {{version}}`,{version:g?.latestVersion??``})]}),e(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-surface-muted disabled:opacity-50`,disabled:!D,onClick:()=>void S(),children:[b.isPending?i(N,{className:`h-3.5 w-3.5 animate-spin`}):i(I,{className:`h-3.5 w-3.5`}),n(`serverManagement.restart`,`Restart`)]})]}),t.isOnline&&g?.lastCheckedAtMs!=null&&e(`p`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(re,{className:`h-3 w-3`}),n(`serverManagement.lastChecked`,`Last checked: {{when}}`,{when:new Date(g.lastCheckedAtMs).toLocaleString()})]})]})}s();function or(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 sr({node:t}){let{t:a}=q(),s=j(),u=c(),d=U(),[f,p]=o(!1),[m,h]=o(`info`),[_,v]=o(!1),[y,b]=o(null),C=t.processes??[],w=t.addons.map(e=>e.id),T=ze(void 0),E=n(()=>{let e=T.data?.find(e=>e.nodeId===t.id);return or(e?.settings)},[T.data,t.id]),[D,O]=o(!1),[k,A]=o(null),[M,N]=o(null),P=r(async()=>{if(D||t.isHub)return;let e=Mt(t.localIps??[],E);if(e===null){A(`No LAN IPv4 on this node — open its :4444 URL by hand.`),N(null);return}let n=Ft();O(!0),A(null),N(null);try{let r=Dt(await s.trpcClient.addons.custom.mutate({addonId:`system-config`,action:`mintAgentUiUnlockTicket`,input:{nodeId:t.id,dashboardBaseUrl:Nt(e)}})),i=r===null?null:r.dashboardUrl??Pt(e,r.ticket);if(i===null){n?.close(),A(`Hub did not return an unlock ticket.`);return}It(n,i)||(N(i),A(`Browser blocked the new tab — click the link below (or allow popups for this site).`))}catch(e){n?.close(),A(e instanceof Error?e.message:String(e))}finally{O(!1)}},[t.id,t.isHub,t.localIps,D,E,s.trpcClient]),F=async()=>{if(!_){v(!0),b(null);try{await s.trpcClient.pipelineOrchestrator.removeAgentSettings.mutate({agentNodeId:t.id}).catch(()=>void 0);let e=await s.trpcClient.clusterNodes.forgetNode.mutate({nodeId:t.id});b({tone:e.stillListed?`warn`:`ok`,text:e.message}),e.stillListed||u.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}catch(e){b({tone:`warn`,text:a(`cluster.nodeCard.forgetFailed`,{error:e instanceof Error?e.message:String(e)})})}finally{v(!1)}}},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(R,{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(ae,{className:`h-3 w-3`,"aria-hidden":!0}),f?a(`cluster.nodeCard.unpairing`,`Unpairing…`):a(`cluster.nodeCard.unpair2`,`Unpair`)]});return t.isOnline?e(`div`,{className:`border border-border rounded-xl`,children:[e(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 bg-muted/30 border-b border-border rounded-t-xl`,children:[e(`div`,{className:`flex min-w-0 flex-1 basis-full items-center gap-x-2 gap-y-1 sm:basis-auto sm:flex-initial`,children:[i(`div`,{className:`w-2.5 h-2.5 rounded-full bg-success shrink-0`}),i(Lt,{node:t}),e(`span`,{className:`text-xs text-muted-foreground min-w-0 truncate`,children:[t.cpuModel??t.platform,` ·`,` `,t.memoryMB>0?a(`cluster.nodeCard.gb`,`{{value1}}GB`,{value1:Math.round(t.memoryMB/1024)}):``,` `,`· `,t.arch]})]}),t.engines.map(e=>i(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium shrink-0`,title:a(`cluster.nodeInfoTab.installedRuntimesHint`,`Inference runtimes installed on this node. Its live inference devices are on Pipeline → Load balancing.`),children:e},e)),e(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-x-3 gap-y-1 text-xs text-muted-foreground w-full sm:ml-auto sm:w-auto`,children:[!t.isHub&&e(`button`,{type:`button`,onClick:()=>void P(),disabled:D,title:a(`cluster.nodeCard.openThisAgentSStatus`,`Open this agent's status dashboard (unlocks with a short-lived hub ticket)`),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[i(x,{className:`h-3 w-3`}),D?a(`cluster.nodeCard.opening`,`Opening…`):a(`cluster.nodeCard.openDashboard`,`Open dashboard`)]}),L,e(`span`,{className:`flex items-center gap-1`,children:[i(S,{className:`h-3 w-3`}),` `,t.cpuPercent,`%`]}),e(`span`,{className:`flex items-center gap-1`,children:[i(ie,{className:`h-3 w-3`}),` `,t.memoryPercent,`%`]})]})]}),y!=null&&i(`p`,{role:`status`,className:`px-4 pt-2 text-xs ${y.tone===`ok`?`text-success`:`text-warning`}`,children:y.text}),(k!==null||M!==null)&&e(`p`,{role:`status`,className:`px-4 pt-2 text-xs text-warning`,children:[k,M!==null&&e(l,{children:[` `,i(`a`,{href:M,target:`_blank`,rel:`noreferrer`,className:`underline text-foreground`,children:a(`cluster.nodeCard.openDashboard`,`Open dashboard`)})]})]}),i(`div`,{className:`sticky top-0 z-20 flex border-b border-border px-4 bg-background overflow-x-auto`,children:[`info`,`forks`,`processes`,`load`,`settings`,`capabilities`].map(e=>i(`button`,{onClick:()=>h(e),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${m===e?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:e===`info`?a(`cluster.nodeCard.general`,`General`):e===`forks`?a(`cluster.nodeCard.forks`,`Forks ({{length}})`,{length:C.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(Jn,{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(Qn,{nodeId:t.id,detectedHosts:t.localIps??[]}),i(`div`,{className:`border-t border-border pt-1`,children:i(ar,{node:{id:t.id,name:t.name,isHub:t.isHub,isOnline:t.isOnline,rootPackage:t.rootPackage??null}})})]}),m===`forks`&&i(Ht,{nodeId:t.id,processes:C}),m===`processes`&&i(Kt,{nodeId:t.id}),m===`load`&&i(Vn,{nodeId:t.id,isHub:t.isHub}),m===`settings`&&i(Gn,{nodeId:t.id,addonIds:w}),m===`capabilities`&&i(Kn,{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(Lt,{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(`button`,{type:`button`,onClick:()=>void F(),disabled:_,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(g,{className:`h-3 w-3`}),_?a(`cluster.nodeCard.forgetting`,`Forgetting…`):a(`cluster.nodeCard.forgetNode`,`Forget node`)]})]})]}),y!=null&&i(`p`,{role:`status`,className:`px-4 pb-3 text-xs leading-relaxed ${y.tone===`ok`?`text-success`:`text-warning`}`,children:y.text})]})}var $=3,cr=7e3;function lr(e){return[...e].sort((e,t)=>e.isHub===t.isHub?0:e.isHub?1:-1)}function ur(e){return e.isHub?{}:{nodeId:e.id}}function dr(e){return e.updateState===`staging`||e.updateState===`pending-restart`||e.pendingVersion!==null?!0:!e.updateAvailable}async function fr(e,t){let n=ur(e),r=K.t(`helpers.clusterUpdateAll.noAnswer`);for(let i=1;i<=$;i+=1)try{let r=await t.readStatus(n);return dr(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<$&&await t.wait(cr)}return{nodeId:e.id,nodeName:e.name,outcome:`unconfirmed`,detail:K.t(`helpers.clusterUpdateAll.unconfirmed`,{attempts:$,error:r})}}function pr(e){return e.accepted?`applied`:e.outcome===`failed`?`failed`:`refused`}async function mr(e,t){let n=[];for(let r of lr(e))try{let e=await t.apply(ur(r));n.push({nodeId:r.id,nodeName:r.name,outcome:pr(e),detail:e.message})}catch{n.push(await fr(r,t))}return n}s();function hr(){let{nodes:e,isLoading:t}=le(),r=n(()=>e??[],[e]);return{nodes:r,isLoading:t&&r.length===0}}var gr={applied:`border-success/40 bg-success/10 text-success`,refused:`border-warning/40 bg-warning/10 text-warning`,failed:`border-danger/40 bg-danger/10 text-danger`,unconfirmed:`border-warning/40 bg-warning/10 text-warning`};function _r(){let{t}=q(),s=U(),{nodes:c,isLoading:d}=hr(),[p,m]=Ke(),{selection:h,selectNode:g}=tt(c),_=h.node,v=n(()=>c.filter(e=>e.isOnline),[c]),y=v.length,b=c.filter(e=>!e.isOnline).length,x=pe(),S=j(),[C,w]=o(!1),[T,E]=o([]),D=p.get(`unlockNode`),O=p.get(`returnTo`),[k,A]=o(null);a(()=>{if(D===null||O===null)return;let e=!1;return(async()=>{try{let t=await S.trpcClient.addons.custom.mutate({addonId:`system-config`,action:`mintAgentUiUnlockTicket`,input:{nodeId:D,dashboardBaseUrl:O}});if(e)return;let n=Dt(t),r=n===null?null:n.dashboardUrl??(()=>{let e=new URL(O);return e.searchParams.set(`ticket`,n.ticket),e.toString()})();if(r===null){A(`Could not mint an unlock ticket.`);return}let i=new URLSearchParams(p);i.delete(`unlockNode`),i.delete(`returnTo`),m(i,{replace:!0}),window.location.assign(r)}catch(t){e||A(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[D,O,p,m,S.trpcClient]);let M=r(async()=>{let e=v.map(e=>({id:e.id,name:e.name,isHub:e.isHub}));if(await s({title:t(`serverManagement.confirmUpdateAllTitle`,`Update all nodes`),message:t(`serverManagement.confirmUpdateAllBody`,`Update and restart every online node, agents first, hub last. Up-to-date nodes are skipped; this page reconnects when the hub comes back.`),confirmLabel:t(`serverManagement.confirmUpdateAllAction`,`Update all & restart`),variant:`warning`})){w(!0),E([]);try{E(await mr(e,{apply:e=>x.mutateAsync(e),readStatus:e=>S.trpcClient.serverManagement.getServerPackageStatus.query(e),wait:e=>new Promise(t=>setTimeout(t,e))}))}finally{w(!1)}}},[x,s,v,S,t]);return e(Je,{icon:f,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:[y>0&&i(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-xs text-success`,children:t(`common.onlineCount`,{count:y})}),b>0&&i(`span`,{className:`rounded-full bg-destructive/10 px-2 py-0.5 text-xs text-destructive`,children:t(`common.offlineCount`,{count:b})}),y>1&&e(R,{type:`button`,size:`sm`,disabled:C,title:t(`serverManagement.updateAllHint`,`Sequenced agents-first, hub-last — up-to-date nodes are skipped.`),onClick:()=>void M(),children:[C?i(N,{className:`h-3.5 w-3.5 animate-spin`}):i(u,{className:`h-3.5 w-3.5`}),t(`serverManagement.updateAll`,`Update all nodes`)]})]}),children:[T.length>0&&i(`ul`,{"aria-label":`update-all-report`,className:`flex flex-col gap-1 text-xs`,children:T.map(t=>e(`li`,{"data-outcome":t.outcome,className:`rounded border px-2 py-1 ${gr[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))}),k!==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:`),` `,k]}),i(Tt,{onOpenNode:g}),d?i(`div`,{className:`flex items-center justify-center py-12 text-muted-foreground`,children:t(`system.cluster.loadingClusterTopology`,`Loading cluster topology...`)}):_===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(et,{staleNodeId:h.staleNodeId,shownNodeName:_.name}),i(He,{selectedNodeId:_.id,onSelect:g,allowOffline:!0,alwaysShow:!0}),i(sr,{node:_})]})]})}export{_r as ClusterPage};
|
|
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{$i as u,An as d,Bn as f,Ci as p,D as m,In as h,Lt as g,Mi as _,Pt as v,Si as y,Sn as b,Vr as x,Zr as S,bi as C,ci as w,cn as T,dt as E,fn as D,gi as O,mi as k,mn as A,ot as j,pn as M,sr as N,wn as P,xn as F,yn as I}from"./player-overlays-BiCGuJYq.js";import{ba as L,va as ee,wa as te,ya as ne}from"./client-BXtMEX7J.js";import{t as re}from"./hard-drive-download-Dxd7SImQ.js";import{t as ie}from"./memory-stick-ByO8UQ_K.js";import{t as ae}from"./unlink-BPmdzYDS.js";import{$l as oe,$r as R,$t as se,Ad as z,Cn as ce,Dd as B,Ed as le,Er as ue,P as de,Ql as fe,Sn as V,Tr as H,Xl as pe,Yc as me,Zl as he,Zr as U,_r as ge,ac as _e,at as ve,bn as ye,bu as be,dc as xe,di as Se,dr as Ce,en as we,fc as Te,fi as Ee,fl as De,fr as Oe,gr as ke,hr as Ae,ic as je,kn as Me,ld as W,mc as Ne,mr as Pe,oi as Fe,pc as Ie,pi as Le,pr as Re,rl as ze,ui as Be,vl as Ve,vt as He,wr as Ue,xn as We,xo as Ge,xt as G}from"./src-BjL-Slsn.js";import{t as K}from"./i18n-CI5vBtLY.js";import{t as q}from"./useTranslation-BJr-n0es.js";import{gr as Ke,x as qe}from"./index-T3VEitv1.js";import{t as Je}from"./AdminPage-CdT4_4OP.js";import{t as Ye}from"./NodeAddonsSettingsPanel-ByFvh4Ya.js";import{f as Xe,l as Ze,m as Qe,u as $e}from"./board-model-BnBpDyVJ.js";import{t as J}from"./format-size-DIxKXxtj.js";import{n as et,t as tt}from"./useNodeUrlSelection-BWBjwQx2.js";s();var nt={unpaired:`Not paired`,pending:`Pairing…`,paired:`Paired`},rt=new Set([`paired`,`rejected`,`failed`,`expired`]);function Y(e){return rt.has(e)}function it(e){return e.replace(/\D/g,``).slice(0,6)}function at(e){return e.length===6}function ot(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 st(e,t){return e.includes(`:`)?`[${e}]:${t}`:`${e}:${t}`}function ct(e){return e.length<=23?e:`${e.slice(0,20)}…`}function lt({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 ut(e){return e===`awaiting-both`||e===`awaiting-hub`}var dt={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`},ft=2e3,pt=1e3;function mt(e){return e.message.length>0?e.message:K.t(`pairing.agentsFoundSection.requestFailed`)}function ht(e){return e.length===6?`${e.slice(0,3)} ${e.slice(3)}`:e}function gt(e){let[t,n]=o(()=>Date.now());return a(()=>{if(!e)return;let t=setInterval(()=>n(Date.now()),pt);return()=>clearInterval(t)},[e]),t}function _t({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=z.agentPairing.beginPairing.useMutation(),x=z.agentPairing.confirmPairing.useMutation(),S=z.agentPairing.rejectPairing.useMutation();a(()=>{if(n===null){y.current=null,f(null),m(null),g(``),v(null);return}y.current!==n&&(y.current=n,b.mutateAsync({host:n.host,port:n.port}).then(e=>{y.current===n&&f(e.pairingId)}).catch(e=>{y.current===n&&m(mt(e))}))},[n]);let C=z.agentPairing.getPairing.useQuery({pairingId:d??``},{enabled:d!==null,refetchInterval:e=>{let t=e.state.data?.state;return t!==void 0&&Y(t)?!1:ft}}),w=vt(x.data??S.data??null,C.data??null),T=lt({view:w,beginError:p}),E=w!==null&&Y(w.state),D=t(!1);a(()=>{if(!E){D.current=!1;return}D.current||(D.current=!0,s())},[E,s]);let O=gt(w!==null&&!E),k=()=>{d===null||!at(h)||(v(null),x.mutate({pairingId:d,code:h},{onError:e=>{v(mt(e)),g(``)}}))};return i(Ce,{open:n!==null,onOpenChange:e=>!e&&r(),children:e(Re,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(ke,{children:[i(ge,{children:u(`pairing.pairingDialog.title`,{node:n?.nodeId??``})}),i(Pe,{children:n===null?``:u(`pairing.pairingDialog.eachScreenShowsACode`,`Each screen shows a code; you type the code from the OTHER screen. Agent at {{value1}}`,{value1:st(n.host,n.port)})})]}),e(Oe,{className:`space-y-4`,children:[i(yt,{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(bt,{view:w,phase:T,now:O,typed:h,onType:e=>g(it(e)),onSubmit:k,confirmError:_,busy:x.isPending}),T===`paired`&&w!==null&&i(xt,{nodeId:w.nodeId,onOpenNode:c,onClose:r}),E&&T!==`paired`&&w?.failure!=null&&i(H,{message:w.failure})]}),i(Ae,{children:E||T===`send-failed`?i(R,{type:`button`,variant:`outline`,onClick:r,children:u(`common.close`,`Close`)}):e(l,{children:[i(R,{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`)}),ut(T)&&e(R,{type:`button`,disabled:!at(h)||x.isPending,onClick:k,children:[x.isPending&&i(N,{className:`h-4 w-4 animate-spin`}),u(`common.confirm`,`Confirm`)]})]})})]})})}function vt(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 yt({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(N,{className:`h-4 w-4 animate-spin`}),r&&i(k,{className:`h-4 w-4`}),a&&i(w,{className:`h-4 w-4`}),dt[t]]})}function bt({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 — read it out to the agent`)}),i(`p`,{"data-testid":`hub-code`,className:`mt-1 font-mono text-3xl font-semibold tracking-widest text-foreground`,children:ht(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).`)})]}),ut(n)?i(`form`,{className:`space-y-2`,onSubmit:e=>{e.preventDefault(),s()},children:i(G,{label:u(`pairing.pairingDialog.codeShownOnTheAgent`,`Code shown on the agent`),description:u(`pairing.pairingDialog.typeTheSixDigitsThe`,`Type the six digits the agent displays. Do not copy the code above.`),...c===null?{}:{error:c},children:i(W,{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:ot(t.expiresAt,r)})})]})]})}function xt({nodeId:t,onOpenNode:n,onClose:r}){let{t:a}=q(),{nodes:o}=le(),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(T,{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(R,{type:`button`,size:`sm`,variant:`outline`,disabled:!s,onClick:()=>{r(),n(t)},children:a(`pairing.pairingDialog.openNode`,`Open node`)})]})}var St={paired:`success`,pending:`warning`,unpaired:`default`};function Ct({state:t,connected:n}){let{t:r}=q();return e(`span`,{className:`inline-flex items-center gap-1.5`,children:[i(Fe,{variant:St[t],className:`text-[10px]`,children:nt[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 wt(e){if(e.trim().length===0)return;let t=Number(e);return Number.isInteger(t)&&t>=1&&t<=65535?t:null}function Tt({onOpenNode:t}){let{t:r}=q(),a=U(),s=z.useUtils(),c=z.agentPairing.listDiscoveredAgents.useQuery(void 0,{refetchInterval:15e3}),[u,f]=o(null),[p,h]=o(null),[g,_]=o(!1),[v,y]=o(``),[b,x]=o(``),[S,C]=o(null),[w,T]=o(!1),E=()=>void s.agentPairing.listDiscoveredAgents.invalidate(),D=z.agentPairing.addAgentByAddress.useMutation({onSuccess:()=>{_(!1),y(``),x(``),C(null),E()},onError:e=>C(e.message)}),O=z.agentPairing.unpairAgent.useMutation({onSuccess:e=>{h({tone:`success`,message:`${e.nodeId}: ${e.next}${e.agentNotified?``:` The agent could not be told; forget the hub on its own page.`}`}),E()},onError:e=>h({tone:`danger`,message:r(`pairing.agentsFoundSection.unpairFailed`,`Unpair failed: {{message}}`,{message:e.message})})}),k=n(()=>(c.data?.agents??[]).toSorted((e,t)=>X[e.state]-X[t.state]),[c.data]),A=async()=>{T(!0);try{await s.agentPairing.listDiscoveredAgents.fetch({refresh:!0}),E()}finally{T(!1)}},j=()=>{let e=wt(b);if(e===null){C(`The port must be a whole number between 1 and 65535.`);return}C(null),D.mutate({host:v.trim(),...e===void 0?{}:{port:e}})},M=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`})&&(h(null),O.mutate({nodeId:e.nodeId}))},I=n(()=>[{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:st(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(Ct,{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:ct(e.fingerprint)}),sortValue:e=>e.fingerprint},{key:`actions`,header:``,align:`right`,notSortableReason:`Row actions`,render:e=>e.state===`unpaired`?i(R,{type:`button`,size:`sm`,onClick:()=>f({nodeId:e.nodeId,host:e.host,port:e.port}),children:r(`pairing.agentsFoundSection.pair`,`Pair`)}):e.state===`paired`?i(R,{type:`button`,size:`sm`,variant:`outline`,disabled:O.isPending,onClick:()=>void M(e),children:r(`pairing.agentsFoundSection.unpair2`,`Unpair`)}):null}],[O.isPending,r]);return e(ye,{headingId:`agents-found`,title:r(`pairing.agentsFoundSection.agentsFoundOnTheNetwork`,`Agents found on the network`),icon:P,testId:`agents-found`,actions:e(l,{children:[e(R,{type:`button`,size:`sm`,variant:`outline`,disabled:w,onClick:()=>void A(),children:[w?i(N,{className:`h-3.5 w-3.5 animate-spin`}):i(F,{className:`h-3.5 w-3.5`}),r(`pairing.agentsFoundSection.scan`,`Scan`)]}),e(R,{type:`button`,size:`sm`,onClick:()=>_(e=>!e),children:[i(d,{className:`h-3.5 w-3.5`}),r(`pairing.agentsFoundSection.addByAddress`,`Add by address`)]})]}),children:[e(`div`,{className:`${m} 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.`)}),g&&e(`form`,{"aria-label":r(`pairing.agentsFoundSection.addAgentByAddress`,`Add agent by address`),className:`flex flex-wrap items-start gap-2`,onSubmit:e=>{e.preventDefault(),v.trim().length>0&&!D.isPending&&j()},children:[i(G,{label:r(`pairing.agentsFoundSection.address`,`Address`),description:r(`pairing.agentsFoundSection.aPrivateOrLocalAddress`,`A private or local address only.`),...S===null?{}:{error:S},children:i(W,{value:v,onChange:e=>y(e.target.value),placeholder:`192.0.2.20`,"aria-label":r(`pairing.agentsFoundSection.agentAddress`,`Agent address`),autoComplete:`off`})}),i(G,{label:r(`pairing.agentsFoundSection.port`,`Port`),description:r(`pairing.agentsFoundSection.optional`,`Optional.`),children:i(W,{value:b,onChange:e=>x(e.target.value),placeholder:`4444`,inputMode:`numeric`,"aria-label":r(`pairing.agentsFoundSection.agentPort`,`Agent port`),className:`w-24`})}),e(R,{type:`submit`,size:`sm`,className:`mt-5`,disabled:v.trim().length===0||D.isPending,children:[D.isPending&&i(N,{className:`h-3.5 w-3.5 animate-spin`}),r(`common.add`,`Add`)]})]}),p!==null&&i(`p`,{role:`status`,className:`rounded border px-3 py-2 text-xs ${p.tone===`success`?`border-success/30 text-foreground`:`border-danger/40 text-danger`}`,children:p.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:E}):c.isLoading?i(`p`,{className:`py-4 text-center text-xs text-foreground-muted`,children:r(`pairing.agentsFoundSection.lookingForAgents`,`Looking for agents…`)}):k.length===0?i(ue,{icon:P,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(V,{columns:I,rows:k,rowKey:e=>e.nodeId,minWidthPx:720,defaultSort:{columnKey:`state`,dir:`asc`}})]}),i(_t,{target:u,onClose:()=>f(null),onSettled:E,onOpenNode:t})]})}function Et(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Dt(e){if(!Et(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 Ot(e){let t=e.trim();return!(t.length===0||t.includes(`/`)||t.includes(`?`)||t.includes(`#`)||t.includes(`@`)||t.includes(`:`))}function kt(e){return e.startsWith(`172.17.`)}function At(e){let t=/^100\.(\d+)\./.exec(e);if(t===null)return!1;let n=Number(t[1]);return n>=64&&n<=127}function jt(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&&!kt(e)}function Mt(e,t){if(typeof t==`string`&&Ot(t))return t.trim();let n=e.filter(e=>!e.includes(`:`)),r=n.find(e=>!e.startsWith(`127.`)&&!e.startsWith(`169.254.`)&&!kt(e)&&!At(e)&&jt(e));if(r!==void 0)return r;for(let e of n)if(!e.startsWith(`127.`)&&!e.startsWith(`169.254.`)&&!kt(e))return e;return null}function Nt(e){return`http://${e}:4444/`}function Pt(e,t){let n=new URL(Nt(e));return n.searchParams.set(`ticket`,t),n.toString()}function Ft(){return window.open(`about:blank`,`_blank`)}function It(e,t){return e===null||e.closed?!1:(e.location.href=t,!0)}function Lt({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 Rt(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 zt(e){return e===`running`?`running`:e===`crashed`||e===`failed`?`error`:`stopped`}var Bt=[`trace`,`debug`,`info`,`warn`,`error`];function Vt({proc:t,nodeId:n,defaultExpanded:r,activePanel:a,onTogglePanel:s}){let{t:c}=q(),l=t.services??[],u=l.length===1,[d,f]=o(u||r),[p,m]=o(null),[h,g]=o(`info`),v=t.name.includes(`(core)`),x=Te(),S=Ie(),w=Ne(),T=async e=>{m(e);try{await x.mutateAsync({nodeId:n,addonId:e})}catch(e){console.error(`Failed to restart addon:`,e)}finally{m(null)}},E=async()=>{m(t.name);try{await S.mutateAsync({nodeId:n,processName:t.name})}catch(e){console.error(`Failed to restart process:`,e)}finally{m(null)}},O=async e=>{let r=`${n}/${t.name}`;try{await w.mutateAsync({nodeId:r,level:e}),g(e)}catch(e){console.error(`Failed to set log level:`,e)}};return e(`div`,{className:`border border-border/50 rounded-lg overflow-hidden`,children:[e(`div`,{role:u?void 0:`button`,tabIndex:u?void 0:0,onClick:u?void 0:()=>f(!d),onKeyDown:u?void 0:e=>{(e.key===`Enter`||e.key===` `)&&f(!d)},className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 w-full px-3 py-2 bg-muted/20 transition-colors text-left select-none ${u?``:`hover:bg-muted/40 cursor-pointer`}`,children:[u?i(`span`,{className:`h-3 w-3 shrink-0`}):i(d?y:C,{className:`h-3 w-3 text-muted-foreground shrink-0`}),v?i(D,{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(ve,{status:zt(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:Rt(t.uptimeSeconds)}),!v&&e(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[e(Be,{children:[i(Le,{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:h}),i(Se,{align:`end`,className:`min-w-[70px] py-0.5`,children:Bt.map(e=>i(Ee,{onClick:()=>O(e),className:`h-auto px-2 py-1 text-[10px] font-mono ${e===h?`text-primary font-semibold`:``}`,children:e},e))})]}),i(`button`,{onClick:E,disabled:p===t.name,className:`p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:c(`cluster.forksTab.restartProcess`,`Restart process`),children:i(I,{className:`h-3 w-3 ${p===t.name?`animate-spin`:``}`})})]})]}),d&&l.length>0&&i(`div`,{className:`divide-y divide-border/30`,children:l.map(t=>e(`div`,{children:[e(`div`,{className:`flex items-center gap-2 px-3 py-1.5 pl-9 hover:bg-muted/10 transition-colors`,children:[i(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${t.status===`running`?`bg-success`:`bg-muted-foreground/30`}`}),i(`span`,{className:`text-xs font-medium flex-1 min-w-0 truncate`,children:t.addonId}),t.capabilities.length>0&&e(`div`,{className:`flex gap-1 flex-shrink-0`,children:[t.capabilities.slice(0,3).map(e=>i(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-info/10 text-info truncate max-w-[80px]`,children:e},e)),t.capabilities.length>3&&e(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,t.capabilities.length-3]})]}),e(`div`,{className:`flex items-center gap-1 shrink-0`,children:[i(`button`,{onClick:()=>s(t.addonId,`logs`),className:`p-0.5 rounded transition-colors ${a?.addonId===t.addonId&&a.type===`logs`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:c(`cluster.forksTab.showLogsFor`,`Show logs for {{addonId}}`,{addonId:t.addonId}),children:i(A,{className:`h-3 w-3`})}),i(`button`,{onClick:()=>s(t.addonId,`events`),className:`p-0.5 rounded transition-colors ${a?.addonId===t.addonId&&a.type===`events`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:c(`cluster.forksTab.showEventsFor`,`Show events for {{addonId}}`,{addonId:t.addonId}),children:i(b,{className:`h-3 w-3`})}),i(`button`,{onClick:()=>T(t.addonId),disabled:p===t.addonId,className:`p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:c(`cluster.forksTab.restart`,`Restart {{addonId}}`,{addonId:t.addonId}),children:i(I,{className:`h-3 w-3 ${p===t.addonId?`animate-spin`:``}`})})]})]}),a?.addonId===t.addonId&&a.type===`logs`&&i(`div`,{className:`border-t border-border/40 bg-muted/5`,children:i(we,{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(se,{addonId:t.addonId,category:`addon.*`,maxHeight:`max-h-48`,onClose:()=>s(t.addonId,`events`)})})]},t.addonId))}),d&&l.length===0&&i(`div`,{className:`px-3 py-2 pl-9 text-[10px] text-muted-foreground`,children:c(`cluster.forksTab.noServices`,`No services`)})]})}function Ht({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(Vt,{proc:t,nodeId:e,defaultExpanded:n===0,activePanel:r,onTogglePanel:s},t.name))})}var Ut={system:0,managed:1,root:2};s();function Wt(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 Gt(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function Kt({nodeId:t}){let{t:r}=q(),a=c(),o=B(`metrics.node-processes-snapshot`,e=>e.nodeId===t),{data:s}=_e({nodeId:t}),l=o?.processes??s,u=n(()=>l?[...l]:[],[l]),d=n(()=>[{key:`classification`,header:r(`cluster.processesTab.class`,`Class`),sortValue:e=>Ut[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:Gt(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:Wt(e.uptimeSec)})}],[r]);return e(`div`,{className:`space-y-4`,children:[i(`div`,{className:`flex items-start justify-end gap-4`,children:e(`button`,{type:`button`,onClick:()=>a.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]}),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground hover:bg-surface-hover`,children:[i(F,{className:`h-3 w-3`}),` `,r(`common.refresh`)]})}),i(V,{columns:d,rows:u,rowKey:e=>e.pid,minWidthPx:880,maxBodyHeight:ce,emptyMessage:r(`cluster.processesTab.scanning`,`Scanning…`)})]})}s();var qt=96;function Jt({title:e,points:t,mainLabel:r,gcLabel:a,formatValue:o,emptyMessage:s,gapMs:c}){return i(de,{title:e,series:n(()=>[{id:`main`,label:r,unit:`%`,colorIndex:0,gapMs:c,points:t.map(e=>({t:e.atMs,v:e.main}))},{id:`gc`,label:a,unit:`%`,colorIndex:1,gapMs:c,points:t.map(e=>({t:e.atMs,v:e.gc}))}],[t,r,a,c]),stacked:!0,height:qt,formatValue:e=>o(e),axisFor:()=>({floor:25}),emptyMessage:s})}function Z({title:e,points:t,formatValue:r,emptyMessage:a,axisFloor:o,axisScale:s=`linear`,gapMs:c}){return i(de,{title:e,series:n(()=>[{id:`value`,label:e,unit:s===`bytes`?`B`:null,colorIndex:0,gapMs:c,points:t.map(e=>({t:e.atMs,v:e.value}))}],[t,e,s,c]),height:qt,formatValue:e=>r(e),axisFor:()=>({floor:o,scale:s}),emptyMessage:a})}function Yt(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 Xt(e,t,n,r){let i=e.get(t),a=Yt(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 Zt(e,t,n){let r=e;for(let e of te(t,n))r=Xt(r,e.key,e.kind,e.point);return r}function Qt(e,t){let n=e;for(let e of t)for(let t of e.points)n=Xt(n,e.key,e.kind,t);return n}function $t(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 en=12e4;function tn(e,t){return e===null?!1:t-e>en}function nn(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 rn(e){for(let t of e.values()){let e=t.points.at(-1);if(e&&e.cpuMainPercent!==null)return!0}return!1}var an={key:`cpu`,dir:`desc`};function on(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 sn(e){return e.points.at(-1)?.memoryRssBytes??null}function cn(e,t,n){let r=n.trim().toLowerCase();return r===``?!0:e.toLowerCase().includes(r)||t.toLowerCase().includes(r)}function ln(e,t){return t===`memory`?sn(e):on(e)}function un(e,t,n){let r=e.filter(e=>t.selectedKeys.size>0&&!t.selectedKeys.has(e.key)?!1:cn(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=ln(e,t.sort.key),o=ln(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 dn(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}=je({forNodeId:e,sinceMs:c,maxPoints:n});a(()=>{d!==void 0&&s(e=>{let t=Qt(e,d.series);return u.current=$t(t),t})},[d]);let p=r?.timestamp;a(()=>{r==null||p===void 0||(tn(u.current,p)&&l(u.current??0),s(e=>{let t=Zt(e,r.processes,p);return u.current=$t(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:nn(i),sampleCount:m,threadSplitAvailable:rn(i),loadingRetained:f,durable:d?.durable??null,bucketMs:d?.bucketMs??null,cadenceMs:d?.cadenceMs??null,retainedSamples:d?.retainedSamples??null}}var fn=`__unclaimed__`;function pn(e,t){return{kind:e,deviceId:t,cpu:0,cpuKnown:!0,rss:0,rssKnown:!0,count:0,roles:new Set}}function mn(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 hn(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)??pn(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])=>mn(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=pn(`unclaimed`,null);for(let e of a)o.count+=1,o.rss+=e.memoryRssBytes;return o.cpuKnown=!1,[...i,mn(fn,o)]}var gn=[{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 _n(e){return e.attribution===`measured`&&e.wiredToday}function vn(){let e=new Set;for(let t of gn)_n(t)&&e.add(t.family);return e}var yn=vn();function bn(e){return!yn.has(e.role)||e.deviceId===null?!1:e.attribution===`measured`}function xn(e){return`${e.addonId}${e.role}${e.unit}${e.pid??`-`}`}function Sn(){return{cpuSeconds:0,cpuKnown:!0,rssBytes:0,rssKnown:!0,unitCount:0,roles:new Set}}function Cn(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 wn(e){return Math.round(e*10)/10}function Tn(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)bn(t)&&i.set(xn(t),t);let a=new Map,o=new Set;for(let n of t.entries){if(!bn(n)||n.deviceId===null)continue;let t=xn(n);o.add(t);let r=a.get(n.deviceId)??Sn();r.unitCount+=1,r.roles.add(n.role);let s=Cn(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?wn(n.cpuSeconds/r*100):null,rssBytes:n.rssKnown?n.rssBytes:null,unitCount:n.unitCount,roles:[...n.roles].toSorted()}}))}function En(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 Dn(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 On(e){let t=e.indexOf(`@`);return t===-1?{addonId:e,nodeId:null}:{addonId:e.slice(0,t),nodeId:e.slice(t+1)}}function kn(e,t){let n=On(e);return n.nodeId===null?t.isHub:n.nodeId===t.nodeId}function An(e,t){return e.filter(e=>kn(e.addonId,t))}s();function jn(e){let n=B(`metrics.node-processes-snapshot`,t=>t.nodeId===e.nodeId),r=be(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:An(d,e)},n=c.current;if(c.current=t,n===null)return;let r=Tn(n,t);r.length!==0&&s(e=>En(e,r))},[d,f,e.nodeId,e.isHub]);let p=d===void 0?[]:An(d,e),m=n?.processes,h=hn(p,m);return{series:Dn(i),unclaimed:h.find(e=>e.kind===`unclaimed`)??null,loading:r.isPending,error:r.error===null?null:r.error.message}}function Mn(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 Nn=25,Pn=64*1024*1024,Fn=1e4;function In({scope:t,cadenceMs:n}){let{t:r}=q(),a=jn(t),{data:o=[]}=Ge({isCamera:!0,projection:`slim`}),s=Mn(o),c=Ue(n??Fn);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(v,{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(Rn,{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(Ln,{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(Z,{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:Nn,gapMs:c,emptyMessage:r(`cameraLoad.cpuUnavailable`,`No measurable window yet.`)}),i(Z,{title:r(`cameraLoad.memoryTitle`,`Memory RSS`),points:t.points.map(e=>({atMs:e.atMs,value:e.rssBytes})),formatValue:J,axisFloor:Pn,axisScale:`bytes`,gapMs:c,emptyMessage:r(`cameraLoad.memoryUnavailable`,`No memory reported.`)})]})]},t.deviceId))})]})}function Ln({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 Rn({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 zn=256*1024*1024,Bn=1e4;function Vn({nodeId:t,isHub:r}){let{t:a}=q(),{series:s,sampleCount:c,threadSplitAvailable:l,loadingRetained:u,bucketMs:d,cadenceMs:f}=dn(t),[p,m]=o(``),[h,g]=o(new Set),[_,y]=o(an),b=e=>e.key===`__root__`?a(`clusterLoad.bucketRoot`,`Node supervisor`):e.key===`__unattributed__`?a(`clusterLoad.bucketUnattributed`,`Unattributed processes`):e.key,x=Ue(d??f??Bn),S=n(()=>un(s,{search:p,selectedKeys:h,sort:_},b),[s,p,h,_]),C=e=>{g(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(Hn,{bucketMs:d,cadenceMs:f}),!l&&c>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(v,{className:`h-3 w-3 mt-0.5 shrink-0`}),i(`span`,{children:a(`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.`)})]}),c===0&&i(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:u?a(`clusterLoad.loadingRetained`,`Reading the retained series from this node…`):a(`clusterLoad.waitingFirstSample`,`No retained samples for this node — waiting for the next snapshot (up to 20s). The chart needs two to draw a rate.`)}),s.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(M,{className:`pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-foreground-subtle`}),i(`input`,{type:`search`,value:p,onChange:e=>m(e.target.value),placeholder:a(`clusterLoad.searchPlaceholder`,`Find a runner…`),"aria-label":a(`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(Un,{sort:_,onChange:y})]}),e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[s.map(e=>{let t=h.has(e.key);return i(`button`,{type:`button`,"aria-pressed":t,onClick:()=>C(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:b(e)},e.key)}),h.size>0&&e(`button`,{type:`button`,onClick:()=>g(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(E,{className:`h-2.5 w-2.5`}),a(`clusterLoad.clearFilter`,`All runners`)]})]})]}),s.length>0&&S.length===0&&i(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:a(`clusterLoad.noMatches`,`No runner matches this search on {{count}} present. The node is reporting — the filter is hiding them.`,{count:s.length})}),i(`div`,{className:`space-y-3`,children:S.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:b(t)}),i(`span`,{className:`text-[10px] text-foreground-subtle`,children:a(`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(Jt,{title:l?a(`clusterLoad.cpuTitle`,`CPU % of one core`):a(`clusterLoad.cpuTitleLifetime`,`CPU % (ps lifetime average)`),mainLabel:a(`clusterLoad.seriesMain`,`Main threads`),gcLabel:a(`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:x,emptyMessage:a(`clusterLoad.cpuUnavailable`,`No thread split on this node. Lifetime average: {{avg}}%`,{avg:(t.points.at(-1)?.cpuLifetimePercent??0).toFixed(1)})}),i(Z,{title:a(`clusterLoad.memoryTitle`,`Memory RSS`),points:t.points.map(e=>({atMs:e.atMs,value:e.memoryRssBytes})),formatValue:J,axisFloor:zn,axisScale:`bytes`,gapMs:x,emptyMessage:a(`clusterLoad.memoryUnavailable`,`No memory samples yet.`)})]})]},t.key))}),i(In,{scope:{nodeId:t,isHub:r},cadenceMs:f})]})}function Hn({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 Un({sort:t,onChange:n}){let{t:r}=q(),a=[{key:`cpu`,label:r(`clusterLoad.sortCpu`,`CPU`)},{key:`memory`,label:r(`clusterLoad.sortMemory`,`Memory`)},{key:`name`,label:r(`clusterLoad.sortName`,`Name`)}];return e(`div`,{className:`flex items-center gap-1`,children:[i(`span`,{className:`text-[10px] text-foreground-subtle`,children:r(`clusterLoad.sortBy`,`Sort by`)}),a.map(r=>{let i=t.key===r.key;return e(`button`,{type:`button`,"aria-pressed":i,onClick:()=>n(i?{key:r.key,dir:t.dir===`desc`?`asc`:`desc`}:{key:r.key,dir:r.key===`name`?`asc`:`desc`}),className:`rounded border px-1.5 py-0.5 text-[10px] transition-colors ${i?`border-primary bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground`}`,children:[r.label,i&&(t.dir===`desc`?` ↓`:` ↑`)]},r.key)})]})}var Wn=`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 Gn({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(Ye,{nodeId:e,addonIds:t,level:`global`,fieldScope:`perNode`,emptyMessage:Wn,selfTabbed:!0})})}s();function Kn({nodeId:e,addons:t}){let{t:r}=q(),a=c(),{data:o,isLoading:s}=me({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=Ve({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(V,{columns:[{key:`capName`,header:r(`cluster.nodeDetailCapabilitiesTab.capability`,`Capability`),width:`w-1/2`,sortValue:e=>e.capName,render:e=>i(`span`,{className:`font-medium`,children:e.capName})},{key:`provider`,header:r(`cluster.nodeDetailCapabilitiesTab.boundProvider`,`Bound provider`),render:t=>{let n=o?.[t.capName]??t.providers[0]??``,a=t.providers.length===1;return i(`select`,{value:n,onChange:n=>u.mutate({nodeId:e,capName:t.capName,addonId:n.target.value}),disabled:a||u.isPending||s,className:`w-full rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-60`,title:a?r(`cluster.nodeDetailCapabilitiesTab.onlyOneProviderInstalledChoice`,`Only one provider installed — choice becomes available once a second addon registers this capability`):void 0,children:t.providers.map(e=>i(`option`,{value:e,children:e},e))})}}],rows:l,rowKey:e=>e.capName,minWidthPx:520,maxBodyHeight:ce})}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 Jn(t){let{t:n}=q(),[r,a]=o(!1),[s,l]=o(t.name),u=c(),d=xe({onSuccess:()=>{u.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}}),f=(t.localIps??[]).filter(e=>!e.includes(`:`)),m=(t.localIps??[]).filter(e=>e.includes(`:`)),g=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)}},_=[[`Node ID`,i(`span`,{className:`font-mono text-xs`,children:t.nodeId})],[`Display Name`,r?e(`div`,{className:`flex items-center gap-1.5`,children:[i(`input`,{type:`text`,className:`flex-1 px-2 py-0.5 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary`,value:s,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&g(),e.key===`Escape`&&a(!1)},disabled:d.isPending,autoFocus:!0}),i(`button`,{onClick:()=>void g(),disabled:d.isPending,className:`p-0.5 text-success hover:bg-success/10 rounded`,title:n(`common.save`,`Save`),children:i(p,{className:`h-3.5 w-3.5`})}),i(`button`,{onClick:()=>a(!1),className:`p-0.5 text-muted-foreground hover:bg-muted rounded`,title:n(`common.cancel`,`Cancel`),children:i(E,{className:`h-3.5 w-3.5`})})]}):e(`div`,{className:`flex items-center gap-1.5`,children:[i(`span`,{className:`text-xs`,children:t.name}),!t.isHub&&i(`button`,{onClick:()=>{l(t.name),a(!0)},className:`p-0.5 text-muted-foreground hover:text-primary rounded`,title:n(`cluster.nodeInfoTab.rename`,`Rename`),children:i(h,{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&&_.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}`))})]),m.length>0&&_.push([`IPv6`,i(`div`,{className:`flex flex-wrap gap-1.5`,children:m.map((e,t)=>i(`span`,{className:`font-mono text-[10px] px-1.5 py-0.5 rounded bg-muted truncate max-w-[280px]`,title:e,children:e},`${e}-${t}`))})]),i(`div`,{className:`py-2`,children:i(`table`,{className:`w-full text-sm`,children:i(`tbody`,{children:_.map(([t,n],r)=>e(`tr`,{className:r%2==0?`bg-muted/20`:``,children:[i(`td`,{className:`py-1.5 px-2 text-xs font-medium text-muted-foreground w-28 align-top whitespace-nowrap`,children:t}),i(`td`,{className:`py-1.5 px-2`,children:n})]},t))})})})}s();function Yn({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 m=r[0],h=m===void 0?`auto-detect`:`auto: ${m}`,g=s===`pending`,_=d.trim(),v=_!==(n??``),y=v&&!g,b=()=>{y&&l(t,_.length>0?_:null)};return e(`div`,{className:`flex items-center gap-1.5`,children:[i(W,{"aria-label":u(`placementBoard.reachableHostInput.reachableHostFor`,`Reachable host for {{nodeId}}`,{nodeId:t}),type:`text`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:h,value:d,disabled:g,onChange:e=>f(e.target.value),onBlur:b,onKeyDown:e=>{e.key===`Enter`&&b(),e.key===`Escape`&&f(n??``)},className:`w-36`}),e(R,{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:[g?i(N,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):i(p,{className:`h-3 w-3`,"aria-hidden":`true`}),u(`common.save`,`Save`)]}),!v&&!g&&s===`success`&&i(p,{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(O,{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 Xn(e){let t=ne.safeParse(Xe(e,`color`));return t.success?t.data:null}function Zn(e,t){return t.variables?.agentNodeId===e?t.isPending?`pending`:t.isError?`error`:t.isSuccess?`success`:`idle`:`idle`}function Qn({nodeId:t,detectedHosts:r}){let{t:a}=q(),o=c(),s=ze(void 0),l=De({onSuccess:()=>Ze(o)}),u=De({onSuccess:()=>Ze(o)}),d=n(()=>s.data?.find(e=>e.nodeId===t)?.settings,[s.data,t]),f=Xn(d)??(s.isLoading?null:L(t)),p=Qe(d,`reachableHost`),m=Zn(t,l),h=m===`error`?$e(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(We,{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:ee.map(e=>{let t=f===e;return i(R,{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 ${Me(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(We,{label:a(`nodes.general.reachableHost`,`Reachable host`),children:i(Yn,{nodeId:t,value:p,detectedHosts:g,status:m,errorMessage:h,onCommit:(e,t)=>{l.mutate({agentNodeId:e,reachableHost:t})}})})]})}s();var $n=[[`serverManagement`,`getServerPackageStatus`]];function er({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 Q({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 tr({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 nr={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 rr(e){return e.outcome===`failed`?`error`:(e.outcome,e.accepted?`ok`:`warn`)}function ir(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 ar({node:t}){let{t:n}=q(),a=c(),s=U(),[l,d]=o(!1),[f,p]=o(null),m=t.isHub?void 0:{nodeId:t.id},h=fe(m,{refetchInterval:1e4,enabled:t.isOnline,retry:1}),g=h.data??null,_=r(()=>{a.invalidateQueries({queryKey:$n})},[a]),v=he({onSettled:_}),y=pe({onSettled:_}),b=oe({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:rr(e),text:e.message}),e.restarting&&d(!0)}catch(e){p({tone:`warn`,text:ir(n,e)})}}},[y,s,t.name,m,g,n]),S=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:rr(e),text:e.message}),e.restarting&&d(!0)}catch(e){p({tone:`warn`,text:ir(n,e)})}}},[s,t.name,b,m,n]),C=()=>{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`}}},w=()=>{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`}}},T=g?.bootMode===`workspace`,E=t.isOnline&&g!=null&&!T&&g.updateAvailable&&g.updateState===`idle`&&!y.isPending,D=t.isOnline&&g!=null&&g.updateState===`idle`&&!b.isPending,O=t.isOnline?w():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(er,{...C()})]}),O!=null&&i(er,{...O})]}),!t.isOnline&&i(Q,{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(N,{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(Q,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:t.rootPackage.version})]}),t.isOnline&&g!=null&&e(`div`,{className:`space-y-1.5`,children:[i(tr,{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.pendingVersion!=null&&i(Q,{label:n(`serverManagement.pendingVersion`,`Staged (applies on restart)`),value:g.pendingVersion}),g.installedVersion!=null&&g.installedVersion!==g.runningVersion&&i(Q,{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&&T&&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 ${nr[f.tone]}`,children:f.text}),l&&e(`div`,{className:`flex items-center gap-2 text-sm text-warning`,children:[i(N,{className:`h-4 w-4 animate-spin`}),n(`serverManagement.nodeRestarting`,`The node is restarting to apply the change…`)]}),t.isOnline&&e(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[e(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-surface-muted disabled:opacity-50`,disabled:v.isPending||g?.updateState===`staging`,onClick:()=>v.mutate(m),children:[v.isPending?i(N,{className:`h-3.5 w-3.5 animate-spin`}):i(F,{className:`h-3.5 w-3.5`}),n(`serverManagement.checkForUpdate`,`Check for update`)]}),E&&e(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded bg-primary px-2.5 py-1.5 text-xs font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50`,onClick:()=>void x(),children:[y.isPending?i(N,{className:`h-3.5 w-3.5 animate-spin`}):i(u,{className:`h-3.5 w-3.5`}),n(`serverManagement.updateTo`,`Update to {{version}}`,{version:g?.latestVersion??``})]}),e(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-surface-muted disabled:opacity-50`,disabled:!D,onClick:()=>void S(),children:[b.isPending?i(N,{className:`h-3.5 w-3.5 animate-spin`}):i(I,{className:`h-3.5 w-3.5`}),n(`serverManagement.restart`,`Restart`)]})]}),t.isOnline&&g?.lastCheckedAtMs!=null&&e(`p`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(re,{className:`h-3 w-3`}),n(`serverManagement.lastChecked`,`Last checked: {{when}}`,{when:new Date(g.lastCheckedAtMs).toLocaleString()})]})]})}s();function or(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 sr({node:t}){let{t:a}=q(),s=j(),u=c(),d=U(),[f,p]=o(!1),[m,h]=o(`info`),[_,v]=o(!1),[y,b]=o(null),C=t.processes??[],w=t.addons.map(e=>e.id),T=ze(void 0),E=n(()=>{let e=T.data?.find(e=>e.nodeId===t.id);return or(e?.settings)},[T.data,t.id]),[D,O]=o(!1),[k,A]=o(null),[M,N]=o(null),P=r(async()=>{if(D||t.isHub)return;let e=Mt(t.localIps??[],E);if(e===null){A(`No LAN IPv4 on this node — open its :4444 URL by hand.`),N(null);return}let n=Ft();O(!0),A(null),N(null);try{let r=Dt(await s.trpcClient.addons.custom.mutate({addonId:`system-config`,action:`mintAgentUiUnlockTicket`,input:{nodeId:t.id,dashboardBaseUrl:Nt(e)}})),i=r===null?null:r.dashboardUrl??Pt(e,r.ticket);if(i===null){n?.close(),A(`Hub did not return an unlock ticket.`);return}It(n,i)||(N(i),A(`Browser blocked the new tab — click the link below (or allow popups for this site).`))}catch(e){n?.close(),A(e instanceof Error?e.message:String(e))}finally{O(!1)}},[t.id,t.isHub,t.localIps,D,E,s.trpcClient]),F=async()=>{if(!_){v(!0),b(null);try{await s.trpcClient.pipelineOrchestrator.removeAgentSettings.mutate({agentNodeId:t.id}).catch(()=>void 0);let e=await s.trpcClient.clusterNodes.forgetNode.mutate({nodeId:t.id});b({tone:e.stillListed?`warn`:`ok`,text:e.message}),e.stillListed||u.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}catch(e){b({tone:`warn`,text:a(`cluster.nodeCard.forgetFailed`,{error:e instanceof Error?e.message:String(e)})})}finally{v(!1)}}},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(R,{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(ae,{className:`h-3 w-3`,"aria-hidden":!0}),f?a(`cluster.nodeCard.unpairing`,`Unpairing…`):a(`cluster.nodeCard.unpair2`,`Unpair`)]});return t.isOnline?e(`div`,{className:`border border-border rounded-xl`,children:[e(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 bg-muted/30 border-b border-border rounded-t-xl`,children:[e(`div`,{className:`flex min-w-0 flex-1 basis-full items-center gap-x-2 gap-y-1 sm:basis-auto sm:flex-initial`,children:[i(`div`,{className:`w-2.5 h-2.5 rounded-full bg-success shrink-0`}),i(Lt,{node:t}),e(`span`,{className:`text-xs text-muted-foreground min-w-0 truncate`,children:[t.cpuModel??t.platform,` ·`,` `,t.memoryMB>0?a(`cluster.nodeCard.gb`,`{{value1}}GB`,{value1:Math.round(t.memoryMB/1024)}):``,` `,`· `,t.arch]})]}),t.engines.map(e=>i(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium shrink-0`,title:a(`cluster.nodeInfoTab.installedRuntimesHint`,`Inference runtimes installed on this node. Its live inference devices are on Pipeline → Load balancing.`),children:e},e)),e(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-x-3 gap-y-1 text-xs text-muted-foreground w-full sm:ml-auto sm:w-auto`,children:[!t.isHub&&e(`button`,{type:`button`,onClick:()=>void P(),disabled:D,title:a(`cluster.nodeCard.openThisAgentSStatus`,`Open this agent's status dashboard (unlocks with a short-lived hub ticket)`),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[i(x,{className:`h-3 w-3`}),D?a(`cluster.nodeCard.opening`,`Opening…`):a(`cluster.nodeCard.openDashboard`,`Open dashboard`)]}),L,e(`span`,{className:`flex items-center gap-1`,children:[i(S,{className:`h-3 w-3`}),` `,t.cpuPercent,`%`]}),e(`span`,{className:`flex items-center gap-1`,children:[i(ie,{className:`h-3 w-3`}),` `,t.memoryPercent,`%`]})]})]}),y!=null&&i(`p`,{role:`status`,className:`px-4 pt-2 text-xs ${y.tone===`ok`?`text-success`:`text-warning`}`,children:y.text}),(k!==null||M!==null)&&e(`p`,{role:`status`,className:`px-4 pt-2 text-xs text-warning`,children:[k,M!==null&&e(l,{children:[` `,i(`a`,{href:M,target:`_blank`,rel:`noreferrer`,className:`underline text-foreground`,children:a(`cluster.nodeCard.openDashboard`,`Open dashboard`)})]})]}),i(`div`,{className:`sticky top-0 z-20 flex border-b border-border px-4 bg-background overflow-x-auto`,children:[`info`,`forks`,`processes`,`load`,`settings`,`capabilities`].map(e=>i(`button`,{onClick:()=>h(e),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${m===e?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:e===`info`?a(`cluster.nodeCard.general`,`General`):e===`forks`?a(`cluster.nodeCard.forks`,`Forks ({{length}})`,{length:C.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(Jn,{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(Qn,{nodeId:t.id,detectedHosts:t.localIps??[]}),i(`div`,{className:`border-t border-border pt-1`,children:i(ar,{node:{id:t.id,name:t.name,isHub:t.isHub,isOnline:t.isOnline,rootPackage:t.rootPackage??null}})})]}),m===`forks`&&i(Ht,{nodeId:t.id,processes:C}),m===`processes`&&i(Kt,{nodeId:t.id}),m===`load`&&i(Vn,{nodeId:t.id,isHub:t.isHub}),m===`settings`&&i(Gn,{nodeId:t.id,addonIds:w}),m===`capabilities`&&i(Kn,{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(Lt,{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(`button`,{type:`button`,onClick:()=>void F(),disabled:_,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(g,{className:`h-3 w-3`}),_?a(`cluster.nodeCard.forgetting`,`Forgetting…`):a(`cluster.nodeCard.forgetNode`,`Forget node`)]})]})]}),y!=null&&i(`p`,{role:`status`,className:`px-4 pb-3 text-xs leading-relaxed ${y.tone===`ok`?`text-success`:`text-warning`}`,children:y.text})]})}var $=3,cr=7e3;function lr(e){return[...e].sort((e,t)=>e.isHub===t.isHub?0:e.isHub?1:-1)}function ur(e){return e.isHub?{}:{nodeId:e.id}}function dr(e){return e.updateState===`staging`||e.updateState===`pending-restart`||e.pendingVersion!==null?!0:!e.updateAvailable}async function fr(e,t){let n=ur(e),r=K.t(`helpers.clusterUpdateAll.noAnswer`);for(let i=1;i<=$;i+=1)try{let r=await t.readStatus(n);return dr(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<$&&await t.wait(cr)}return{nodeId:e.id,nodeName:e.name,outcome:`unconfirmed`,detail:K.t(`helpers.clusterUpdateAll.unconfirmed`,{attempts:$,error:r})}}function pr(e){return e.accepted?`applied`:e.outcome===`failed`?`failed`:`refused`}async function mr(e,t){let n=[];for(let r of lr(e))try{let e=await t.apply(ur(r));n.push({nodeId:r.id,nodeName:r.name,outcome:pr(e),detail:e.message})}catch{n.push(await fr(r,t))}return n}s();function hr(){let{nodes:e,isLoading:t}=le(),r=n(()=>e??[],[e]);return{nodes:r,isLoading:t&&r.length===0}}var gr={applied:`border-success/40 bg-success/10 text-success`,refused:`border-warning/40 bg-warning/10 text-warning`,failed:`border-danger/40 bg-danger/10 text-danger`,unconfirmed:`border-warning/40 bg-warning/10 text-warning`};function _r(){let{t}=q(),s=U(),{nodes:c,isLoading:d}=hr(),[p,m]=Ke(),{selection:h,selectNode:g}=tt(c),_=h.node,v=n(()=>c.filter(e=>e.isOnline),[c]),y=v.length,b=c.filter(e=>!e.isOnline).length,x=pe(),S=j(),[C,w]=o(!1),[T,E]=o([]),D=p.get(`unlockNode`),O=p.get(`returnTo`),[k,A]=o(null);a(()=>{if(D===null||O===null)return;let e=!1;return(async()=>{try{let t=await S.trpcClient.addons.custom.mutate({addonId:`system-config`,action:`mintAgentUiUnlockTicket`,input:{nodeId:D,dashboardBaseUrl:O}});if(e)return;let n=Dt(t),r=n===null?null:n.dashboardUrl??(()=>{let e=new URL(O);return e.searchParams.set(`ticket`,n.ticket),e.toString()})();if(r===null){A(`Could not mint an unlock ticket.`);return}let i=new URLSearchParams(p);i.delete(`unlockNode`),i.delete(`returnTo`),m(i,{replace:!0}),window.location.assign(r)}catch(t){e||A(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[D,O,p,m,S.trpcClient]);let M=r(async()=>{let e=v.map(e=>({id:e.id,name:e.name,isHub:e.isHub}));if(await s({title:t(`serverManagement.confirmUpdateAllTitle`,`Update all nodes`),message:t(`serverManagement.confirmUpdateAllBody`,`Update and restart every online node, agents first, hub last. Up-to-date nodes are skipped; this page reconnects when the hub comes back.`),confirmLabel:t(`serverManagement.confirmUpdateAllAction`,`Update all & restart`),variant:`warning`})){w(!0),E([]);try{E(await mr(e,{apply:e=>x.mutateAsync(e),readStatus:e=>S.trpcClient.serverManagement.getServerPackageStatus.query(e),wait:e=>new Promise(t=>setTimeout(t,e))}))}finally{w(!1)}}},[x,s,v,S,t]);return e(Je,{icon:f,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:[y>0&&i(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-xs text-success`,children:t(`common.onlineCount`,{count:y})}),b>0&&i(`span`,{className:`rounded-full bg-destructive/10 px-2 py-0.5 text-xs text-destructive`,children:t(`common.offlineCount`,{count:b})}),y>1&&e(R,{type:`button`,size:`sm`,disabled:C,title:t(`serverManagement.updateAllHint`,`Sequenced agents-first, hub-last — up-to-date nodes are skipped.`),onClick:()=>void M(),children:[C?i(N,{className:`h-3.5 w-3.5 animate-spin`}):i(u,{className:`h-3.5 w-3.5`}),t(`serverManagement.updateAll`,`Update all nodes`)]})]}),children:[T.length>0&&i(`ul`,{"aria-label":`update-all-report`,className:`flex flex-col gap-1 text-xs`,children:T.map(t=>e(`li`,{"data-outcome":t.outcome,className:`rounded border px-2 py-1 ${gr[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))}),k!==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:`),` `,k]}),i(Tt,{onOpenNode:g}),d?i(`div`,{className:`flex items-center justify-center py-12 text-muted-foreground`,children:t(`system.cluster.loadingClusterTopology`,`Loading cluster topology...`)}):_===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(et,{staleNodeId:h.staleNodeId,shownNodeName:_.name}),i(He,{selectedNodeId:_.id,onSelect:g,allowOffline:!0,alwaysShow:!0}),i(sr,{node:_})]})]})}export{_r as ClusterPage};
|
package/dist/assets/{CompositionBlockEditor-CYmfatQE.js → CompositionBlockEditor-DM8TH06u.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,K as t,S as n,et as r}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{
|
|
1
|
+
import{C as e,K as t,S as n,et as r}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{oa as i,ui as a}from"./client-BXtMEX7J.js";import{Pa as o,Ro as s,Tr as c,Va as l,oi as u}from"./src-BjL-Slsn.js";import{t as d}from"./useTranslation-BJr-n0es.js";import{D as f,E as p,H as m,_ as h,h as g,o as _,p as v,r as y,t as b}from"./HelperWizard-Drtw6fE7.js";r();function x({blockId:r}){let{t:x}=d(),S=o({blockId:r}),C=l(),w=s(),T=t(()=>{let e=new Set;for(let{cap:t}of g())e.add(t);for(let{cap:t}of h())e.add(t);for(let{cap:t}of p())e.add(t);return e},[]);if(S.status===`pending`)return n(`p`,{role:`status`,children:x(`compositionEditor.loading`)});if(S.status===`error`)return n(c,{title:x(`compositionEditor.loadFailed`),message:S.error.message});if(S.data.state===`not-loaded`)return n(`p`,{role:`status`,children:x(`customize.status.notLoaded`,{reason:S.data.reason})});let E=S.data.view;if(E===null)return n(`p`,{children:x(`compositionEditor.notFound`,{blockId:r})});let D=a(E.block);if(D===null)return n(`p`,{children:x(`compositionEditor.notComposition`)});if(_(D)){let e=y(D.helper,E.block.name,``);if(e===null)return n(`p`,{role:`alert`,children:x(`helper.unreadable`)});let t=E.state.kind===`answered`?E.state.state?.deviceId??null:null;return n(b,{purpose:`edit`,initial:e,start:`parameters`,saving:C.isPending,onSave:async e=>{let n=await v(e,async(n,r)=>{await C.mutateAsync({blockId:E.block.id,expectedUpdatedAt:E.block.updatedAt,block:{composition:n,...r===``?{}:{name:r}}}),t!==null&&e.room.trim()!==``&&await w.mutateAsync({deviceId:t,location:e.room.trim()}),await S.refetch()});return n.length>0?{kind:`refused`,lines:n}:{kind:`saved`,deviceId:t??0}}})}let O=m(D),k={id:0,name:E.block.name,addonId:`composer`,stableId:`composed-${r}`,type:D.target.kind===`new`?D.target.type:i.Sensor,location:``,disabled:!1,parentDeviceId:null,role:D.target.kind===`new`?D.target.role:null,online:!0,probed:!0,features:[],isCamera:!1,config:{},secretConfigPaths:[],metadata:{}},A={target:{addonId:`composer`,stableId:k.stableId},state:{kind:`present`,view:E,composition:D},saving:C.isPending,save:async e=>{if(e===null)return{kind:`refused`,reason:`cannot delete here`};try{return await C.mutateAsync({blockId:E.block.id,expectedUpdatedAt:E.block.updatedAt,block:{composition:e}}),await S.refetch(),{kind:`saved`}}catch(e){return{kind:`refused`,reason:e instanceof Error?e.message:String(e)}}}};return e(`div`,{className:`flex flex-col gap-2`,children:[n(u,{variant:O===`incomplete`?`warning`:`success`,children:x(`customize.blockStatus.${O===`incomplete`?`incomplete`:E.block.status}`)}),n(f,{device:k,handle:A,skipCaps:T})]})}export{x as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,S as t}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{
|
|
1
|
+
import{C as e,S as t}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{ui as n}from"./client-BXtMEX7J.js";import{t as r}from"./boxes-B-VqzPaN.js";import{$r as i,Pa as a}from"./src-BjL-Slsn.js";import{t as o}from"./useTranslation-BJr-n0es.js";import{dr as s,f as c,fr as l,hr as u,m as d,mr as f}from"./index-T3VEitv1.js";import{t as p}from"./CompositionBlockEditor-DM8TH06u.js";import{t as m}from"./AdminPage-CdT4_4OP.js";var h=`rounded-lg border border-border bg-surface p-4`,g=`new`;function _(){let{blockId:_}=u(),{t:v}=o(),y=f(),b=_===void 0||_===g,x=a({blockId:_??``},{enabled:!b}),S=e=>t(m,{icon:r,title:v(`compositionEditor.pageTitle`),children:e});if(b)return t(l,{to:`${c}&new=helper`,replace:!0});if(x.status===`success`&&x.data.state===`loaded`&&x.data.view!==null){let e=x.data.view;if(n(e.block)?.target.kind===`existing`){let n=e.state.kind===`answered`?e.state.state?.deviceId??null:null;if(n!==null)return S(t(`section`,{className:h,children:t(s,{className:`text-primary text-sm`,to:d(n),children:v(`compositionEditor.openOnDevice`)})}))}}return S(e(`section`,{className:`${h} flex flex-col gap-2`,children:[t(i,{variant:`ghost`,size:`sm`,onClick:()=>y(c),children:v(`compositionEditor.cancel`)}),t(p,{blockId:_??``})]}))}export{_ as CompositionEditorPage};
|