@camstack/addon-admin-ui 1.2.420 → 1.2.421

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/assets/{AddonAssetIcon-CUwwTa-R.js → AddonAssetIcon-BcUAeUFA.js} +1 -1
  2. package/dist/assets/{Addons-BxDL_z8K.js → Addons-CMFKnFy_.js} +1 -1
  3. package/dist/assets/{AdminPage-CeuyYsCA.js → AdminPage-Pnx0mTsE.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-DTUh9Cod.js → AdminSectionedPage-Cwqk3VSC.js} +1 -1
  5. package/dist/assets/{AiProfiles-y6zIS3pT.js → AiProfiles-Cm-uW0cp.js} +1 -1
  6. package/dist/assets/{BrokerForm-_lvmLM2q.js → BrokerForm-C29qpKHz.js} +1 -1
  7. package/dist/assets/{Build-D1UFnKKy.js → Build-jtQNSTVm.js} +1 -1
  8. package/dist/assets/{Calendars-DIf4uwcB.js → Calendars-DXVrSwsu.js} +1 -1
  9. package/dist/assets/{Cluster-CDw7Cr8z.js → Cluster-Dt4QC5gH.js} +1 -1
  10. package/dist/assets/{ClusterStepModel-zcaZRIvK.js → ClusterStepModel-nVqIETDq.js} +1 -1
  11. package/dist/assets/{CompositionEditor-BWpcmpg6.js → CompositionEditor-CWfZxpvY.js} +1 -1
  12. package/dist/assets/{CompositionEditorPage-CDMHjuJR.js → CompositionEditorPage-D2_5GID5.js} +1 -1
  13. package/dist/assets/{Data-DYDabIHg.js → Data-PX9MYiMq.js} +1 -1
  14. package/dist/assets/{DeviceDetail-GGBbMdyL.js → DeviceDetail-CvBViCpU.js} +1 -1
  15. package/dist/assets/{DeviceDoActionFields-CRdtYlvP.js → DeviceDoActionFields-Vpw3Hlks.js} +1 -1
  16. package/dist/assets/{Devices-CyiSENRc.js → Devices-NE3Jk6_G.js} +1 -1
  17. package/dist/assets/{EmbedPlayerPage-CB66n6Ce.js → EmbedPlayerPage-o6tk8CLI.js} +1 -1
  18. package/dist/assets/{Identity-C7nTQ5HW.js → Identity-DvZevqOL.js} +1 -1
  19. package/dist/assets/{IntegrationDetail-C7V2Lw2t.js → IntegrationDetail-pyZVXw9L.js} +1 -1
  20. package/dist/assets/{IntegrationHub-I34k6eMx.js → IntegrationHub-C--iFSMN.js} +1 -1
  21. package/dist/assets/{Integrations-Btt92q19.js → Integrations-B8URUnQX.js} +1 -1
  22. package/dist/assets/{Integrations-DtRziEii.js → Integrations-Cadxh0XR.js} +1 -1
  23. package/dist/assets/{Library-CmIVJCQ-.js → Library-DHn4yJN3.js} +1 -1
  24. package/dist/assets/{Locations-CMXlnF3m.js → Locations-CMXm68gm.js} +1 -1
  25. package/dist/assets/{Logs-BzzOnW8m.js → Logs-Bg5PD7yc.js} +1 -1
  26. package/dist/assets/{MyAccess-DsKtQazv.js → MyAccess-BvJqlxVR.js} +1 -1
  27. package/dist/assets/{Network-B8KllZ1y.js → Network-Cq6PVeH5.js} +1 -1
  28. package/dist/assets/{NodeAddonsSettingsPanel-B69iZTJL.js → NodeAddonsSettingsPanel-BK1RxciP.js} +1 -1
  29. package/dist/assets/{Notifications-3e9mrTSh.js → Notifications-Cwp9_it6.js} +1 -1
  30. package/dist/assets/{Recordings-C1GA_K_d.js → Recordings-ZhXXvJqY.js} +1 -1
  31. package/dist/assets/{ScanNetworkModal-CZD2XMwr.js → ScanNetworkModal-_RdncTUH.js} +1 -1
  32. package/dist/assets/{SessionsList-BsZ4138t.js → SessionsList-Dm6Me6Pk.js} +1 -1
  33. package/dist/assets/{Showroom-B84zCph9.js → Showroom-B6NjRCzE.js} +1 -1
  34. package/dist/assets/{System-Bs16FRnw.js → System-Q5wNMpYV.js} +1 -1
  35. package/dist/assets/{Terminal-Dtpd7dA2.js → Terminal-Bq2YkQer.js} +1 -1
  36. package/dist/assets/{Viewer-5St3Etot.js → Viewer-CA-_IKP2.js} +1 -1
  37. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-fgk3R2YA.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DxkHv0jA.js} +1 -1
  38. package/dist/assets/{addon-icons-context-DGSjQzW5.js → addon-icons-context-BcFthDce.js} +1 -1
  39. package/dist/assets/{authed-media-wMr1ui8w.js → authed-media-B1N-Y_02.js} +1 -1
  40. package/dist/assets/{device-integration-icon-DNbEWHFM.js → device-integration-icon-CgVkQy_G.js} +1 -1
  41. package/dist/assets/device-picker-model-C-bu65w9.js +1 -0
  42. package/dist/assets/{hostInit-BSsVPy9C.js → hostInit-CU4FJ_9p.js} +1 -1
  43. package/dist/assets/{index-Xr95RVN2.js → index-AsTGrKva.js} +3 -3
  44. package/dist/assets/{location-owned-usage-DLdsU-mZ.js → location-owned-usage-C7aYDcAR.js} +1 -1
  45. package/dist/assets/{mf-entry-bootstrap-0-e96bc771.js → mf-entry-bootstrap-0-c3f6e5ea.js} +2 -2
  46. package/dist/assets/mount-C-bu65w9.js +1 -0
  47. package/dist/assets/{notification-schedule-field-DyI7heJv.js → notification-schedule-field-Dy4ByDYy.js} +1 -1
  48. package/dist/assets/remoteEntry-9Elsv3BT.js +1 -0
  49. package/dist/assets/{src-Bqr9lpc6.js → src-CIIJy_o8.js} +1 -1
  50. package/dist/assets/{use-scenes-feed-BD8OoH8Z.js → use-scenes-feed-DxSvhMQ5.js} +1 -1
  51. package/dist/assets/{use-stationary-objects-CaqT07d1.js → use-stationary-objects-BllXyUsy.js} +1 -1
  52. package/dist/assets/useEventInvalidation-C-bu65w9.js +1 -0
  53. package/dist/assets/{useNodeUrlSelection-DqPmoZO2.js → useNodeUrlSelection-DNAtiVHu.js} +1 -1
  54. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Dd8x1dBQ.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-LWvJP_B9.js} +2 -2
  55. package/dist/index.html +6 -6
  56. package/dist/server/addon.js +1 -1
  57. package/package.json +1 -1
  58. package/dist/assets/device-picker-model-y0YT4n_j.js +0 -1
  59. package/dist/assets/mount-y0YT4n_j.js +0 -1
  60. package/dist/assets/remoteEntry-ClveP_Ct.js +0 -1
  61. package/dist/assets/useEventInvalidation-y0YT4n_j.js +0 -1
@@ -1 +1 @@
1
- import{I as e,K as t,Q as n,S as r,V as i,W as a,b as o,o as s,q as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{It as d,Jr as f,Nt as p,Oi as m,Pn as h,Rn as g,Rr as _,Yi as v,_i as y,_n as b,ar as x,bi as S,bn as C,dn as w,dt as T,fn as E,ot as D,pi as O,un as k,yi as A,yn as j}from"./player-overlays-C20AJTgs.js";import{t as M}from"./hard-drive-download-Cf7DR1zn.js";import{t as ee}from"./memory-stick-CttSJTx_.js";import{Qr as te,Xr as ne,Zr as re,ti as ie}from"./client-CKGZv6zJ.js";import{$o as ae,Bn as N,Fc as oe,Go as se,Ht as ce,Ic as le,Lc as ue,M as de,Ns as fe,Pc as pe,Qo as me,Tt as he,U as ge,Ut as _e,Vs as ve,Wo as ye,Wt as P,Xl as be,Xs as xe,Xt as Se,Zn as Ce,Zo as we,cr as Te,dr as Ee,es as De,fu as Oe,il as ke,lr as Ae,ma as je,pu as F,rc as Me,ur as Ne,wt as Pe,yn as Fe}from"./src-Bqr9lpc6.js";import{t as I}from"./useTranslation-Bc5yH9V9.js";import{Q as Ie}from"./index-Xr95RVN2.js";import{t as Le}from"./AdminPage-CeuyYsCA.js";import{t as Re}from"./NodeAddonsSettingsPanel-B69iZTJL.js";import{f as ze,l as Be,m as Ve,u as He}from"./board-model-Bmts6hrg.js";import{t as L}from"./format-size-DIxKXxtj.js";import{n as Ue,t as We}from"./useNodeUrlSelection-DqPmoZO2.js";n();var Ge=`system-config-cluster`;function Ke(){return l(Fe,{trpc:D().trpcClient,addonId:`system-config`,nodeId:`hub`,sectionIds:[Ge],bare:!0})}function qe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Je(e){if(!qe(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 Ye(e){let t=e.trim();return!(t.length===0||t.includes(`/`)||t.includes(`?`)||t.includes(`#`)||t.includes(`@`)||t.includes(`:`))}function R(e){return e.startsWith(`172.17.`)}function Xe(e){let t=/^100\.(\d+)\./.exec(e);if(t===null)return!1;let n=Number(t[1]);return n>=64&&n<=127}function Ze(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&&!R(e)}function Qe(e,t){if(typeof t==`string`&&Ye(t))return t.trim();let n=e.filter(e=>!e.includes(`:`)),r=n.find(e=>!e.startsWith(`127.`)&&!e.startsWith(`169.254.`)&&!R(e)&&!Xe(e)&&Ze(e));if(r!==void 0)return r;for(let e of n)if(!e.startsWith(`127.`)&&!e.startsWith(`169.254.`)&&!R(e))return e;return null}function $e(e){return`http://${e}:4444/`}function et(e,t){let n=new URL($e(e));return n.searchParams.set(`ticket`,t),n.toString()}function tt(){return window.open(`about:blank`,`_blank`)}function nt(e,t){return e===null||e.closed?!1:(e.location.href=t,!0)}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 it(e){return e===`running`?`running`:e===`crashed`||e===`failed`?`error`:`stopped`}var at=[`trace`,`debug`,`info`,`warn`,`error`];function ot({proc:e,nodeId:t,defaultExpanded:n,activePanel:i,onTogglePanel:a}){let o=e.services??[],s=o.length===1,[u,d]=c(s||n),[f,p]=c(null),[h,g]=c(`info`),_=e.name.includes(`(core)`),v=me(),x=ae(),S=De(),w=async e=>{p(e);try{await v.mutateAsync({nodeId:t,addonId:e})}catch(e){console.error(`Failed to restart addon:`,e)}finally{p(null)}},T=async()=>{p(e.name);try{await x.mutateAsync({nodeId:t,processName:e.name})}catch(e){console.error(`Failed to restart process:`,e)}finally{p(null)}},D=async n=>{let r=`${t}/${e.name}`;try{await S.mutateAsync({nodeId:r,level:n}),g(n)}catch(e){console.error(`Failed to set log level:`,e)}};return r(`div`,{className:`border border-border/50 rounded-lg overflow-hidden`,children:[r(`div`,{role:s?void 0:`button`,tabIndex:s?void 0:0,onClick:s?void 0:()=>d(!u),onKeyDown:s?void 0:e=>{(e.key===`Enter`||e.key===` `)&&d(!u)},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 ${s?``:`hover:bg-muted/40 cursor-pointer`}`,children:[s?l(`span`,{className:`h-3 w-3 shrink-0`}):l(u?A:y,{className:`h-3 w-3 text-muted-foreground shrink-0`}),_?l(k,{className:`h-3.5 w-3.5 text-primary shrink-0`}):l(m,{className:`h-3.5 w-3.5 text-warning shrink-0`}),l(`span`,{className:`text-xs font-semibold min-w-0 flex-1 basis-full truncate sm:basis-auto`,children:e.name}),r(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:[`PID `,e.pid]}),l(de,{status:it(e.state),label:e.state}),r(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:[e.cpuPercent,`% CPU`]}),l(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:L(e.memoryRss)}),l(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:rt(e.uptimeSeconds)}),!_&&r(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[r(Te,{children:[l(Ee,{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:`Set log level`,children:h}),l(Ae,{align:`end`,className:`min-w-[70px] py-0.5`,children:at.map(e=>l(Ne,{onClick:()=>D(e),className:`h-auto px-2 py-1 text-[10px] font-mono ${e===h?`text-primary font-semibold`:``}`,children:e},e))})]}),l(`button`,{onClick:T,disabled:f===e.name,className:`p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:`Restart process`,children:l(b,{className:`h-3 w-3 ${f===e.name?`animate-spin`:``}`})})]})]}),u&&o.length>0&&l(`div`,{className:`divide-y divide-border/30`,children:o.map(e=>r(`div`,{children:[r(`div`,{className:`flex items-center gap-2 px-3 py-1.5 pl-9 hover:bg-muted/10 transition-colors`,children:[l(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`running`?`bg-success`:`bg-muted-foreground/30`}`}),l(`span`,{className:`text-xs font-medium flex-1 min-w-0 truncate`,children:e.addonId}),e.capabilities.length>0&&r(`div`,{className:`flex gap-1 flex-shrink-0`,children:[e.capabilities.slice(0,3).map(e=>l(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-info/10 text-info truncate max-w-[80px]`,children:e},e)),e.capabilities.length>3&&r(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,e.capabilities.length-3]})]}),r(`div`,{className:`flex items-center gap-1 shrink-0`,children:[l(`button`,{onClick:()=>a(e.addonId,`logs`),className:`p-0.5 rounded transition-colors ${i?.addonId===e.addonId&&i.type===`logs`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:`Show logs for ${e.addonId}`,children:l(E,{className:`h-3 w-3`})}),l(`button`,{onClick:()=>a(e.addonId,`events`),className:`p-0.5 rounded transition-colors ${i?.addonId===e.addonId&&i.type===`events`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:`Show events for ${e.addonId}`,children:l(C,{className:`h-3 w-3`})}),l(`button`,{onClick:()=>w(e.addonId),disabled:f===e.addonId,className:`p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:`Restart ${e.addonId}`,children:l(b,{className:`h-3 w-3 ${f===e.addonId?`animate-spin`:``}`})})]})]}),i?.addonId===e.addonId&&i.type===`logs`&&l(`div`,{className:`border-t border-border/40 bg-muted/5`,children:l(he,{addonId:e.addonId,agentId:t,maxHeight:`max-h-48`,showFilters:!1,onClose:()=>a(e.addonId,`logs`)})}),i?.addonId===e.addonId&&i.type===`events`&&l(`div`,{className:`border-t border-border/40 bg-muted/5`,children:l(Pe,{addonId:e.addonId,category:`addon.*`,maxHeight:`max-h-48`,onClose:()=>a(e.addonId,`events`)})})]},e.addonId))}),u&&o.length===0&&l(`div`,{className:`px-3 py-2 pl-9 text-[10px] text-muted-foreground`,children:`No services`})]})}function st({nodeId:e,processes:t}){let[n,r]=c(null),i=(e,t)=>{r(n=>n?.addonId===e&&n.type===t?null:{addonId:e,type:t})};return t.length===0?l(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No processes on this node`}):l(`div`,{className:`space-y-2 py-1`,children:t.map((t,r)=>l(ot,{proc:t,nodeId:e,defaultExpanded:r===0,activePanel:n,onTogglePanel:i},t.name))})}var ct={system:0,managed:1,root:2};n();function lt(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 ut(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function dt({nodeId:e}){let t=s(),n=F(`metrics.node-processes-snapshot`,t=>t.nodeId===e),{data:i}=se({nodeId:e}),o=n?.processes??i,c=a(()=>o?[...o]:[],[o]),u=a(()=>[{key:`classification`,header:`Class`,sortValue:e=>ct[e.classification],render:e=>l(`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=>l(`span`,{className:`font-mono`,children:e.pid})},{key:`ppid`,header:`PPID`,align:`right`,sortValue:e=>e.ppid,render:e=>l(`span`,{className:`font-mono text-foreground-subtle`,children:e.ppid})},{key:`addonId`,header:`Addon`,sortValue:e=>e.addonId,render:e=>l(`span`,{className:`text-foreground-subtle text-[11px]`,children:e.addonId??`—`})},{key:`command`,header:`Command`,nowrap:!1,render:e=>l(`span`,{className:`font-mono text-[10px] text-foreground-subtle break-all`,children:ut(e.command)})},{key:`cpuPercent`,header:`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=>L(e.memoryRssBytes)},{key:`uptimeSec`,header:`Uptime`,align:`right`,sortValue:e=>e.uptimeSec,render:e=>l(`span`,{className:`text-foreground-subtle`,children:lt(e.uptimeSec)})}],[]);return r(`div`,{className:`space-y-4`,children:[l(`div`,{className:`flex items-start justify-end gap-4`,children:r(`button`,{type:`button`,onClick:()=>t.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:[l(j,{className:`h-3 w-3`}),` Refresh`]})}),l(ce,{columns:u,rows:c,rowKey:e=>e.pid,minWidthPx:880,mobileMode:`cards`,maxBodyHeight:_e,emptyMessage:`Scanning…`})]})}var z={width:320,height:64},B=.8,V=Math.ceil(8*B-3)+1,H=z.width+34,U=z.height+V+1+11,ft=V+z.height+1+3+Math.ceil(8*B),pt=[1,2,5,10],mt=[1,2,4,8,16,32,64,128,256,512,1024],ht=[1,1.5,2,2.5,3,4,5],W=[4,3,5,2],gt=1e-9;function _t(e,t){if(!Number.isFinite(e)||e<=0)return!1;if(t===`bytes`){if(!Number.isInteger(e))return!1;let t=e/1024**Math.floor(Math.log(e)/Math.log(1024));return ht.some(e=>Math.abs(t-e)<gt)}let n=e/10**Math.floor(Math.log10(e));return ht.some(e=>Math.abs(n-e)<gt)}function vt(e,t,n){let r=0;for(let t of e)t!==null&&t>r&&(r=t);if(r<=t)return t;if(n===`bytes`){let e=1024**Math.floor(Math.log(r)/Math.log(1024));for(let t of mt){let n=t*e;if(n>=r)return n}return 1024*e}let i=10**Math.floor(Math.log10(r));for(let e of pt){let t=e*i;if(t>=r)return t}return 10*i}function yt(e,t){if(!Number.isFinite(e)||e<=0)return[];let n=W.find(n=>_t(e/n,t))??W[W.length-1],r=e/n,i=[];for(let e=1;e<=n;e++)i.push(r*e);return i}var bt=2.5;function xt(e){return e*bt}function G(e,t,n,r){if(e.length===0)return[];let i=e[0].atMs,a=e.at(-1).atMs-i,o=n<=0?1:n,s=r!==void 0&&r>0?r:null;return e.map((r,c)=>{let l=a>0?(r.atMs-i)/a*t.width:c/Math.max(1,e.length-1)*t.width,u=c>0?e[c-1]:void 0;return{x:l,y:r.value===null?null:t.height-Math.min(r.value,n)/o*t.height,gapBefore:s!==null&&u!==void 0&&r.atMs-u.atMs>s}})}function St(e){let t=[],n=!1;for(let r of e){if(r.y===null){n=!1;continue}r.gapBefore&&(n=!1),t.push(`${n?`L`:`M`}${r.x.toFixed(1)},${r.y.toFixed(1)}`),n=!0}return t.join(` `)}function Ct(e,t){let n=[],r=[],i=()=>{if(r.length<2){r=[];return}let e=r.map((e,t)=>`${t===0?`M`:`L`}${e.x.toFixed(1)},${e.top.toFixed(1)}`),t=[...r].reverse().map(e=>`L${e.x.toFixed(1)},${e.bottom.toFixed(1)}`);n.push(`${e.join(` `)} ${t.join(` `)} Z`),r=[]};for(let n=0;n<e.length;n++){let a=e[n],o=t[n];if(!a||!o||a.y===null||o.y===null){i();continue}(a.gapBefore||o.gapBefore)&&i(),r.push({x:a.x,top:a.y,bottom:o.y})}return i(),n.join(` `)}function wt(e,t,n=3){if(e.length<2||n<2)return[];let r=e[0].atMs,i=e.at(-1).atMs-r;if(i<=0)return[];let a=[];for(let e=0;e<n;e++){let o=e/(n-1);a.push({atMs:r+i*o,x:o*t.width,anchor:e===0?`start`:e===n-1?`end`:`middle`})}return a}function Tt(e){return e.length<2?0:Math.max(0,e.at(-1).atMs-e[0].atMs)}function Et(e){let t=[];for(let n=1;n<e.length;n++){let r=e[n];r.gapBefore&&t.push({fromX:e[n-1].x,toX:r.x})}return t}function Dt(e,t){if(e.length===0)return null;let n=0,r=1/0;for(let i=0;i<e.length;i++){let a=Math.abs(e[i].x-t);a<r&&(r=a,n=i)}return n}n();var K={main:`var(--color-chart-series-a)`,gc:`var(--color-chart-series-b)`},q=z,Ot={height:U};function kt({title:e,points:n,mainLabel:s,gcLabel:u,formatValue:d,emptyMessage:f,gapMs:p}){let m=i(),h=t(null),[g,_]=c(null),v=a(()=>{let e=n.map(e=>({atMs:e.atMs,value:e.main===null||e.gc===null?null:e.main+e.gc})),t=n.map(e=>({atMs:e.atMs,value:e.main})),r=vt(e.map(e=>e.value),25,`linear`),i=G(e,q,r,p),a=G(t,q,r,p),o=a.map(e=>({x:e.x,y:e.y===null?null:q.height,gapBefore:e.gapBefore}));return{max:r,ticks:yt(r,`linear`),upper:i,middle:a,base:o,gaps:Et(i),times:wt(e,q),spanMs:Tt(e)}},[n,p]),y=n.at(-1),b=g===null?void 0:n[g.index],x=b??y;return n.length===0||v.upper.every(e=>e.y===null)?l(Y,{title:e,children:l(zt,{message:f})}):l(Y,{title:e,legend:r(o,{children:[l(Rt,{color:K.main,label:s}),l(Rt,{color:K.gc,label:u})]}),readout:x&&x.main!==null&&x.gc!==null?r(o,{children:[b!==void 0&&l(Lt,{atMs:b.atMs,spanMs:v.spanMs}),l(X,{color:K.main,text:d(x.main)}),l(X,{color:K.gc,text:d(x.gc)})]}):null,children:r(`svg`,{ref:h,viewBox:`0 0 ${H} ${U}`,preserveAspectRatio:`none`,className:`w-full`,style:Ot,role:`img`,"aria-label":`${e}: ${s} and ${u} over time`,onMouseLeave:()=>_(null),onMouseMove:e=>{let t=e.currentTarget.getBoundingClientRect();if(t.width===0)return;let n=(e.clientX-t.left)/t.width*H-34,r=Dt(v.upper,n);r!==null&&_({index:r,xPx:v.upper[r].x})},children:[l(At,{ticks:v.ticks,max:v.max,formatValue:d}),l(It,{ticks:v.times,spanMs:v.spanMs}),r(`g`,{transform:`translate(34,${V})`,clipPath:`url(#${m})`,children:[l(`clipPath`,{id:m,children:l(`rect`,{x:0,y:0,width:q.width,height:q.height})}),l(jt,{spans:v.gaps}),l(`path`,{d:Ct(v.middle,v.base),fill:K.main,fillOpacity:.85}),l(`path`,{d:Ct(v.upper,v.middle),fill:K.gc,fillOpacity:.85,stroke:`var(--color-surface, transparent)`,strokeWidth:2}),l(`path`,{d:St(v.upper),fill:`none`,stroke:K.gc,strokeWidth:2}),g!==null&&l(`line`,{x1:g.xPx,x2:g.xPx,y1:0,y2:q.height,stroke:`currentColor`,strokeWidth:1,className:`text-foreground-subtle`})]})]})})}function J({title:e,points:n,formatValue:i,emptyMessage:s,axisFloor:u,axisScale:d=`linear`,gapMs:f}){let p=t(null),[m,h]=c(null),g=a(()=>{let e=vt(n.map(e=>e.value),u,d),t=G(n,q,e,f);return{max:e,ticks:yt(e,d),projected:t,gaps:Et(t),times:wt(n,q),spanMs:Tt(n)}},[n,u,d,f]),_=m===null?void 0:n[m.index],v=_??n.at(-1)??void 0;return n.length===0||g.projected.every(e=>e.y===null)?l(Y,{title:e,children:l(zt,{message:s})}):l(Y,{title:e,readout:v&&v.value!==null?r(o,{children:[_!==void 0&&l(Lt,{atMs:_.atMs,spanMs:g.spanMs}),l(X,{color:K.main,text:i(v.value)})]}):null,children:r(`svg`,{ref:p,viewBox:`0 0 ${H} ${U}`,preserveAspectRatio:`none`,className:`w-full`,style:Ot,role:`img`,"aria-label":e,onMouseLeave:()=>h(null),onMouseMove:e=>{let t=e.currentTarget.getBoundingClientRect();if(t.width===0)return;let n=(e.clientX-t.left)/t.width*H-34,r=Dt(g.projected,n);r!==null&&h({index:r,xPx:g.projected[r].x})},children:[l(At,{ticks:g.ticks,max:g.max,formatValue:i}),l(It,{ticks:g.times,spanMs:g.spanMs}),r(`g`,{transform:`translate(34,${V})`,children:[l(jt,{spans:g.gaps}),l(`path`,{d:St(g.projected),fill:`none`,stroke:K.main,strokeWidth:2}),m!==null&&l(`line`,{x1:m.xPx,x2:m.xPx,y1:0,y2:q.height,stroke:`currentColor`,strokeWidth:1,className:`text-foreground-subtle`})]})]})})}function At({ticks:e,max:t,formatValue:n}){let i=t<=0?1:t;return l(`g`,{className:`text-foreground-subtle`,children:e.map(e=>{let t=V+q.height-e/i*q.height;return r(`g`,{children:[l(`line`,{x1:34,x2:34+q.width,y1:t,y2:t,stroke:`currentColor`,strokeWidth:.5,strokeOpacity:.3}),l(`text`,{x:0,y:t+3,fontSize:8,fill:`currentColor`,children:n(e)})]},e)})})}function jt({spans:e}){return e.length===0?null:l(`g`,{className:`text-foreground-subtle`,children:e.map(e=>l(`rect`,{x:e.fromX,y:0,width:Math.max(1,e.toX-e.fromX),height:q.height,fill:`currentColor`,fillOpacity:.12,children:l(`title`,{children:`No samples in this interval — nothing was measured, nothing is drawn.`})},`${e.fromX}-${e.toX}`))})}var Mt=10*6e4,Nt={hour:`2-digit`,minute:`2-digit`},Pt={hour:`2-digit`,minute:`2-digit`,second:`2-digit`};function Ft(e,t){return new Date(e).toLocaleTimeString(void 0,t<Mt?Pt:Nt)}function It({ticks:e,spanMs:t}){return e.length===0?null:l(`g`,{className:`text-foreground-subtle`,children:e.map(e=>l(`text`,{x:34+e.x,y:ft,fontSize:8,textAnchor:e.anchor,fill:`currentColor`,children:Ft(e.atMs,t)},e.atMs))})}function Lt({atMs:e,spanMs:t}){return l(`span`,{className:`text-[10px] tabular-nums text-foreground-subtle`,children:Ft(e,t)})}function Y({title:e,legend:t,readout:n,children:i}){return r(`div`,{className:`min-w-0`,children:[r(`div`,{className:`flex items-baseline justify-between gap-2 mb-1`,children:[l(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:e}),l(`div`,{className:`flex items-center gap-2`,children:n})]}),i,t&&l(`div`,{className:`flex items-center gap-3 mt-1`,children:t})]})}function Rt({color:e,label:t}){return r(`span`,{className:`inline-flex items-center gap-1 text-[9px] text-foreground-subtle`,children:[l(`span`,{className:`inline-block h-2 w-2 rounded-[2px]`,style:{backgroundColor:e}}),t]})}function X({color:e,text:t}){return r(`span`,{className:`inline-flex items-center gap-1 text-[11px] tabular-nums text-foreground`,children:[l(`span`,{className:`inline-block h-2 w-2 rounded-[2px]`,style:{backgroundColor:e}}),t]})}function zt({message:e}){return l(`div`,{className:`h-16 flex items-center justify-center rounded border border-dashed border-border text-[10px] text-foreground-subtle text-center px-2`,children:e})}function Bt(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 Vt(e,t,n,r){let i=e.get(t),a=Bt(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 Ht(e,t,n){let r=e;for(let e of ie(t,n))r=Vt(r,e.key,e.kind,e.point);return r}function Ut(e,t){let n=e;for(let e of t)for(let t of e.points)n=Vt(n,e.key,e.kind,t);return n}function Wt(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 Gt=12e4;function Kt(e,t){return e===null?!1:t-e>Gt}function qt(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 Jt(e){for(let t of e.values()){let e=t.points.at(-1);if(e&&e.cpuMainPercent!==null)return!0}return!1}var Yt={key:`cpu`,dir:`desc`};function Xt(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 Zt(e){return e.points.at(-1)?.memoryRssBytes??null}function Qt(e,t,n){let r=n.trim().toLowerCase();return r===``?!0:e.toLowerCase().includes(r)||t.toLowerCase().includes(r)}function $t(e,t){return t===`memory`?Zt(e):Xt(e)}function en(e,t,n){let r=e.filter(e=>t.selectedKeys.size>0&&!t.selectedKeys.has(e.key)?!1:Qt(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=$t(e,t.sort.key),o=$t(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})}n();function tn(e,n=720){let r=F(`metrics.node-processes-snapshot`,t=>t.nodeId===e),[i,a]=c(new Map),[o,s]=c(void 0),l=t(null),{data:d,isPending:f}=ye({forNodeId:e,sinceMs:o,maxPoints:n});u(()=>{d!==void 0&&a(e=>{let t=Ut(e,d.series);return l.current=Wt(t),t})},[d]);let p=r?.timestamp;u(()=>{r==null||p===void 0||(Kt(l.current,p)&&s(l.current??0),a(e=>{let t=Ht(e,r.processes,p);return l.current=Wt(t),t}))},[p]),u(()=>{a(new Map),s(void 0),l.current=null},[e]);let m=0;for(let e of i.values())m=Math.max(m,e.points.length);return{series:qt(i),sampleCount:m,threadSplitAvailable:Jt(i),loadingRetained:f,durable:d?.durable??null,bucketMs:d?.bucketMs??null,cadenceMs:d?.cadenceMs??null,retainedSamples:d?.retainedSamples??null}}var nn=`__unclaimed__`;function rn(e,t){return{kind:e,deviceId:t,cpu:0,cpuKnown:!0,rss:0,rssKnown:!0,count:0,roles:new Set}}function an(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 on(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)??rn(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])=>an(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=rn(`unclaimed`,null);for(let e of a)o.count+=1,o.rss+=e.memoryRssBytes;return o.cpuKnown=!1,[...i,an(nn,o)]}var sn=[{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 cn(e){return e.attribution===`measured`&&e.wiredToday}function ln(){let e=new Set;for(let t of sn)cn(t)&&e.add(t.family);return e}var un=ln();function dn(e){return!un.has(e.role)||e.deviceId===null?!1:e.attribution===`measured`}function fn(e){return`${e.addonId}${e.role}${e.unit}${e.pid??`-`}`}function pn(){return{cpuSeconds:0,cpuKnown:!0,rssBytes:0,rssKnown:!0,unitCount:0,roles:new Set}}function mn(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 hn(e){return Math.round(e*10)/10}function gn(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)dn(t)&&i.set(fn(t),t);let a=new Map,o=new Set;for(let n of t.entries){if(!dn(n)||n.deviceId===null)continue;let t=fn(n);o.add(t);let r=a.get(n.deviceId)??pn();r.unitCount+=1,r.roles.add(n.role);let s=mn(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?hn(n.cpuSeconds/r*100):null,rssBytes:n.rssKnown?n.rssBytes:null,unitCount:n.unitCount,roles:[...n.roles].toSorted()}}))}function _n(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 vn(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 yn(e){let t=e.indexOf(`@`);return t===-1?{addonId:e,nodeId:null}:{addonId:e.slice(0,t),nodeId:e.slice(t+1)}}function bn(e,t){let n=yn(e);return n.nodeId===null?t.isHub:n.nodeId===t.nodeId}function Z(e,t){return e.filter(e=>bn(e.addonId,t))}n();function xn(e){let n=F(`metrics.node-processes-snapshot`,t=>t.nodeId===e.nodeId),r=ke(void 0,{staleTime:1/0,refetchOnWindowFocus:!1}),[i,a]=c(new Map),o=t(null),s=t(r.refetch);s.current=r.refetch;let l=n?.timestamp;u(()=>{l!==void 0&&s.current()},[l]),u(()=>{a(new Map),o.current=null},[e.nodeId,e.isHub]);let d=r.data,f=r.dataUpdatedAt;u(()=>{if(d===void 0||f===0)return;let t={atMs:f,entries:Z(d,e)},n=o.current;if(o.current=t,n===null)return;let r=gn(n,t);r.length!==0&&a(e=>_n(e,r))},[d,f,e.nodeId,e.isHub]);let p=d===void 0?[]:Z(d,e),m=n?.processes,h=on(p,m);return{series:vn(i),unclaimed:h.find(e=>e.kind===`unclaimed`)??null,loading:r.isPending,error:r.error===null?null:r.error.message}}function Sn(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 Cn=25,wn=64*1024*1024,Tn=1e4;function En({scope:e,cadenceMs:t}){let{t:n}=I(),i=xn(e),{data:a=[]}=je({isCamera:!0,projection:`slim`}),o=Sn(a),s=xt(t??Tn);return r(`section`,{className:`space-y-3`,children:[i.error!==null&&r(`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:[l(p,{className:`h-3 w-3 mt-0.5 shrink-0`}),l(`span`,{children:n(`cameraLoad.readFailed`,`Could not read the load contributions: {{error}}. This is a failed read, NOT an idle cluster.`,{error:i.error})})]}),l(On,{unclaimed:i.unclaimed}),i.series.length===0&&i.error===null&&l(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:i.loading?n(`cameraLoad.loading`,`Reading what the addons report…`):n(`cameraLoad.waitingWindow`,`No per-camera window yet.`)}),l(`div`,{className:`space-y-3`,children:i.series.map(e=>r(`div`,{className:`rounded-lg border border-border p-3`,children:[r(`div`,{className:`flex items-baseline justify-between gap-2 mb-2`,children:[l(Dn,{deviceId:e.deviceId,name:o.get(e.deviceId)}),l(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`cameraLoad.unitCount`,`{{count}} unit(s): {{roles}}`,{count:e.points.at(-1)?.unitCount??0,roles:(e.points.at(-1)?.roles??[]).join(`, `)})})]}),r(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[l(J,{title:n(`cameraLoad.cpuTitle`,`CPU % of one core (delta)`),points:e.points.map(e=>({atMs:e.atMs,value:e.cpuPercent})),formatValue:e=>`${e.toFixed(1)}%`,axisFloor:Cn,gapMs:s,emptyMessage:n(`cameraLoad.cpuUnavailable`,`No measurable window yet.`)}),l(J,{title:n(`cameraLoad.memoryTitle`,`Memory RSS`),points:e.points.map(e=>({atMs:e.atMs,value:e.rssBytes})),formatValue:L,axisFloor:wn,axisScale:`bytes`,gapMs:s,emptyMessage:n(`cameraLoad.memoryUnavailable`,`No memory reported.`)})]})]},e.deviceId))})]})}function Dn({deviceId:e,name:t}){let{t:n}=I();return t===void 0?l(`span`,{className:`text-xs font-medium text-foreground`,children:n(`cameraLoad.deviceLabel`,`Camera {{deviceId}}`,{deviceId:e})}):r(`span`,{className:`flex items-baseline gap-1.5 min-w-0`,children:[l(`span`,{className:`text-xs font-medium text-foreground truncate`,children:t}),r(`span`,{className:`shrink-0 text-[10px] font-mono text-foreground-subtle`,children:[`#`,e]})]})}function On({unclaimed:e}){let{t}=I();return e===null||e.unitCount===0?null:l(`div`,{className:`flex items-center gap-2`,children:l(`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?`—`:L(e.rssBytes)})})})}n();var kn=256*1024*1024,An=1e4;function jn({nodeId:e,isHub:t}){let{t:n}=I(),{series:i,sampleCount:o,threadSplitAvailable:s,loadingRetained:u,bucketMs:d,cadenceMs:f}=tn(e),[m,h]=c(``),[g,_]=c(new Set),[v,y]=c(Yt),b=e=>e.key===`__root__`?n(`clusterLoad.bucketRoot`,`Node supervisor`):e.key===`__unattributed__`?n(`clusterLoad.bucketUnattributed`,`Unattributed processes`):e.key,x=xt(d??f??An),S=a(()=>en(i,{search:m,selectedKeys:g,sort:v},b),[i,m,g,v]),C=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return r(`div`,{className:`space-y-4`,children:[l(Mn,{bucketMs:d,cadenceMs:f}),!s&&o>0&&r(`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:[l(p,{className:`h-3 w-3 mt-0.5 shrink-0`}),l(`span`,{children:n(`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.`)})]}),o===0&&l(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:u?n(`clusterLoad.loadingRetained`,`Reading the retained series from this node…`):n(`clusterLoad.waitingFirstSample`,`No retained samples for this node — waiting for the next snapshot (up to 20s). The chart needs two to draw a rate.`)}),i.length>0&&r(`div`,{className:`space-y-2`,children:[r(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r(`label`,{className:`relative flex-1 min-w-[160px]`,children:[l(w,{className:`pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-foreground-subtle`}),l(`input`,{type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:n(`clusterLoad.searchPlaceholder`,`Find a runner…`),"aria-label":n(`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`})]}),l(Nn,{sort:v,onChange:y})]}),r(`div`,{className:`flex flex-wrap items-center gap-1`,children:[i.map(e=>{let t=g.has(e.key);return l(`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)}),g.size>0&&r(`button`,{type:`button`,onClick:()=>_(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:[l(T,{className:`h-2.5 w-2.5`}),n(`clusterLoad.clearFilter`,`All runners`)]})]})]}),i.length>0&&S.length===0&&l(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:n(`clusterLoad.noMatches`,`No runner matches this search on {{count}} present. The node is reporting — the filter is hiding them.`,{count:i.length})}),l(`div`,{className:`space-y-3`,children:S.map(e=>r(`div`,{className:`rounded-lg border border-border p-3`,children:[r(`div`,{className:`flex items-baseline justify-between gap-2 mb-2`,children:[l(`span`,{className:`text-xs font-medium text-foreground`,children:b(e)}),l(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`clusterLoad.processCount`,`{{count}} process(es)`,{count:e.points.at(-1)?.processCount??0})})]}),r(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[l(kt,{title:s?n(`clusterLoad.cpuTitle`,`CPU % of one core`):n(`clusterLoad.cpuTitleLifetime`,`CPU % (ps lifetime average)`),mainLabel:n(`clusterLoad.seriesMain`,`Main threads`),gcLabel:n(`clusterLoad.seriesGc`,`GC / V8 helpers`),points:e.points.map(e=>({atMs:e.atMs,main:e.cpuMainPercent,gc:e.cpuGcPercent})),formatValue:e=>`${e.toFixed(0)}%`,gapMs:x,emptyMessage:n(`clusterLoad.cpuUnavailable`,`No thread split on this node. Lifetime average: {{avg}}%`,{avg:(e.points.at(-1)?.cpuLifetimePercent??0).toFixed(1)})}),l(J,{title:n(`clusterLoad.memoryTitle`,`Memory RSS`),points:e.points.map(e=>({atMs:e.atMs,value:e.memoryRssBytes})),formatValue:L,axisFloor:kn,axisScale:`bytes`,gapMs:x,emptyMessage:n(`clusterLoad.memoryUnavailable`,`No memory samples yet.`)})]})]},e.key))}),l(En,{scope:{nodeId:e,isHub:t},cadenceMs:f})]})}function Mn({bucketMs:e,cadenceMs:t}){let{t:n}=I();return e===null?null:l(`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 Nn({sort:e,onChange:t}){let{t:n}=I(),i=[{key:`cpu`,label:n(`clusterLoad.sortCpu`,`CPU`)},{key:`memory`,label:n(`clusterLoad.sortMemory`,`Memory`)},{key:`name`,label:n(`clusterLoad.sortName`,`Name`)}];return r(`div`,{className:`flex items-center gap-1`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`clusterLoad.sortBy`,`Sort by`)}),i.map(n=>{let i=e.key===n.key;return r(`button`,{type:`button`,"aria-pressed":i,onClick:()=>t(i?{key:n.key,dir:e.dir===`desc`?`asc`:`desc`}:{key:n.key,dir:n.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:[n.label,i&&(e.dir===`desc`?` ↓`:` ↑`)]},n.key)})]})}var Pn=`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 Fn({nodeId:e,addonIds:t}){return t.length===0?l(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No addons on this node`}):l(`div`,{className:`w-full py-2`,children:l(Re,{nodeId:e,addonIds:t,level:`global`,fieldScope:`perNode`,emptyMessage:Pn,selfTabbed:!0})})}n();function In({nodeId:e,addons:t}){let n=s(),{data:r,isLoading:i}=fe({nodeId:e}),o=a(()=>{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]),c=Me({onSuccess:()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCapabilityBindings`]]})}});return o.length===0?l(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No capabilities on this node`}):l(ce,{columns:[{key:`capName`,header:`Capability`,width:`w-1/2`,sortValue:e=>e.capName,render:e=>l(`span`,{className:`font-medium`,children:e.capName})},{key:`provider`,header:`Bound provider`,render:t=>{let n=r?.[t.capName]??t.providers[0]??``,a=t.providers.length===1;return l(`select`,{value:n,onChange:n=>c.mutate({nodeId:e,capName:t.capName,addonId:n.target.value}),disabled:a||c.isPending||i,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?`Only one provider installed — choice becomes available once a second addon registers this capability`:void 0,children:t.providers.map(e=>l(`option`,{value:e,children:e},e))})}}],rows:o,rowKey:e=>e.capName,minWidthPx:520,mobileMode:`cards`,maxBodyHeight:_e})}n();function Ln(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 Rn(e){let[t,n]=c(!1),[i,a]=c(e.name),o=s(),u=we({onSuccess:()=>{o.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}}),d=(e.localIps??[]).filter(e=>!e.includes(`:`)),f=(e.localIps??[]).filter(e=>e.includes(`:`)),p=async()=>{if(!i.trim()||i===e.name){n(!1);return}try{await u.mutateAsync({nodeId:e.nodeId,name:i.trim()}),n(!1)}catch(e){console.error(`Rename failed:`,e)}},m=[[`Node ID`,l(`span`,{className:`font-mono text-xs`,children:e.nodeId})],[`Display Name`,t?r(`div`,{className:`flex items-center gap-1.5`,children:[l(`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:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&p(),e.key===`Escape`&&n(!1)},disabled:u.isPending,autoFocus:!0}),l(`button`,{onClick:()=>void p(),disabled:u.isPending,className:`p-0.5 text-success hover:bg-success/10 rounded`,title:`Save`,children:l(S,{className:`h-3.5 w-3.5`})}),l(`button`,{onClick:()=>n(!1),className:`p-0.5 text-muted-foreground hover:bg-muted rounded`,title:`Cancel`,children:l(T,{className:`h-3.5 w-3.5`})})]}):r(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-xs`,children:e.name}),!e.isHub&&l(`button`,{onClick:()=>{a(e.name),n(!0)},className:`p-0.5 text-muted-foreground hover:text-primary rounded`,title:`Rename`,children:l(h,{className:`h-3 w-3`})})]})],[`Hostname`,l(`span`,{className:`text-xs`,children:e.hostname})],[`Role`,e.isHub?l(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary font-medium`,children:`Hub`}):l(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-medium`,children:`Agent`})],[`Root Package`,e.rootPackage?r(`span`,{className:`font-mono text-xs`,children:[e.rootPackage.name,`@`,e.rootPackage.version]}):l(`span`,{className:`text-xs text-muted-foreground`,children:`—`})],[`Platform`,r(`span`,{className:`text-xs`,children:[e.platform,` / `,e.arch]})],[`CPU`,r(`span`,{className:`text-xs`,children:[e.cpuModel??`—`,` (`,e.cpuCores,` cores)`]})],[`Memory`,l(`span`,{className:`text-xs`,children:e.memoryMB>0?`${(e.memoryMB/1024).toFixed(1)} GB`:`—`})],[`Uptime`,l(`span`,{className:`text-xs`,children:Ln(e.uptime)})],[`Engines`,e.engines.length>0?l(`div`,{className:`flex flex-wrap gap-1`,children:e.engines.map(e=>l(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium`,children:e},e))}):l(`span`,{className:`text-xs text-muted-foreground`,children:`—`})]];return d.length>0&&m.push([`IPv4`,l(`div`,{className:`flex flex-wrap gap-1.5`,children:d.map((e,t)=>l(`span`,{className:`font-mono text-xs px-1.5 py-0.5 rounded bg-muted`,children:e},`${e}-${t}`))})]),f.length>0&&m.push([`IPv6`,l(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map((e,t)=>l(`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}`))})]),l(`div`,{className:`py-2`,children:l(`table`,{className:`w-full text-sm`,children:l(`tbody`,{children:m.map(([e,t],n)=>r(`tr`,{className:n%2==0?`bg-muted/20`:``,children:[l(`td`,{className:`py-1.5 px-2 text-xs font-medium text-muted-foreground w-28 align-top whitespace-nowrap`,children:e}),l(`td`,{className:`py-1.5 px-2`,children:t})]},e))})})})}n();function zn({nodeId:e,value:t,detectedHosts:n,status:i,errorMessage:a,onCommit:o}){let[s,d]=c(t??``);u(()=>{d(t??``)},[t]);let f=n[0],p=f===void 0?`auto-detect`:`auto: ${f}`,m=i===`pending`,h=s.trim(),g=h!==(t??``),_=g&&!m,v=()=>{_&&o(e,h.length>0?h:null)};return r(`div`,{className:`flex items-center gap-1.5`,children:[l(be,{"aria-label":`Reachable host for ${e}`,type:`text`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:p,value:s,disabled:m,onChange:e=>d(e.target.value),onBlur:v,onKeyDown:e=>{e.key===`Enter`&&v(),e.key===`Escape`&&d(t??``)},className:`w-36`}),r(N,{variant:`outline`,size:`sm`,onClick:v,disabled:!_,"aria-label":`Save reachable host for ${e}`,title:`Save reachable host`,children:[m?l(x,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):l(S,{className:`h-3 w-3`,"aria-hidden":`true`}),`Save`]}),!g&&!m&&i===`success`&&l(S,{className:`h-3.5 w-3.5 shrink-0 text-success`,"aria-label":`Saved`,role:`img`}),i===`error`&&l(`span`,{title:a??`Failed to save reachable host`,children:l(O,{className:`h-3.5 w-3.5 shrink-0 text-danger`,"aria-label":a??`Failed to save reachable host`,role:`img`})})]})}n();function Bn(e){let t=re.safeParse(ze(e,`color`));return t.success?t.data:null}function Vn(e,t){return t.variables?.agentNodeId===e?t.isPending?`pending`:t.isError?`error`:t.isSuccess?`success`:`idle`:`idle`}function Hn({nodeId:e,detectedHosts:t}){let{t:n}=I(),i=s(),o=ve(void 0),c=xe({onSuccess:()=>Be(i)}),u=xe({onSuccess:()=>Be(i)}),d=a(()=>o.data?.find(t=>t.nodeId===e)?.settings,[o.data,e]),f=Bn(d)??(o.isLoading?null:te(e)),p=Ve(d,`reachableHost`),m=Vn(e,c),h=m===`error`?He(c.error):null,g=t.filter(e=>!e.includes(`:`)),_=t=>{t!==f&&u.mutate({agentNodeId:e,color:t})};return r(`div`,{className:`rounded-lg border border-border bg-surface/40 divide-y divide-border px-3`,children:[l(P,{label:n(`nodes.general.nodeColour`,`Node colour`),children:l(`div`,{role:`group`,"aria-label":n(`nodes.general.nodeColourGroup`,`Node colour`),className:`flex flex-wrap gap-2`,children:ne.map(e=>{let t=f===e;return l(N,{type:`button`,role:`radio`,"aria-checked":t,"aria-label":e,variant:`outline`,size:`sm`,disabled:o.isLoading||u.isPending,title:e,onClick:()=>_(e),className:`h-6 w-6 min-w-6 shrink-0 rounded-full border-0 p-0 ${Se(e)} ${t?`ring-2 ring-primary ring-offset-2 ring-offset-background`:`opacity-80 hover:opacity-100`}`,children:l(`span`,{className:`sr-only`,children:e})},e)})})}),l(P,{label:n(`nodes.general.reachableHost`,`Reachable host`),children:l(zn,{nodeId:e,value:p,detectedHosts:g,status:m,errorMessage:h,onCommit:(e,t)=>{c.mutate({agentNodeId:e,reachableHost:t})}})})]})}n();var Un=[[`serverManagement`,`getServerPackageStatus`]];function Wn({label:e,tone:t}){return l(`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:e,value:t}){return r(`div`,{className:`flex items-center justify-between gap-4 text-sm`,children:[l(`span`,{className:`text-foreground-subtle`,children:e}),l(`span`,{className:`font-mono text-foreground`,children:t??`—`})]})}function Gn({runningVersion:e,latestVersion:t,seedVersion:n,nodeRuntimeVersion:i,labelRunning:a,labelLatest:o,labelSeed:s,labelRuntime:c}){return l(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-sm`,children:[{key:`running`,label:a,value:e},{key:`latest`,label:o,value:t},{key:`seed`,label:s,value:n},{key:`runtime`,label:c,value:i}].map(({key:e,label:t,value:n})=>r(`span`,{className:`inline-flex items-baseline gap-1`,children:[l(`span`,{className:`text-foreground-subtle`,children:t}),l(`span`,{className:`font-mono text-foreground`,children:n??`—`})]},e))})}var Kn={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 qn(e){return e.outcome===`failed`?`error`:(e.outcome,e.accepted?`ok`:`warn`)}function Jn(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 Yn({node:t}){let{t:n}=I(),i=s(),a=Ce(),[o,u]=c(!1),[d,f]=c(null),p=t.isHub?void 0:{nodeId:t.id},m=le(p,{refetchInterval:1e4,enabled:t.isOnline,retry:1}),h=m.data??null,g=e(()=>{i.invalidateQueries({queryKey:Un})},[i]),_=oe({onSettled:g}),y=pe({onSettled:g}),S=ue({onSettled:g}),C=e(async()=>{if(h?.latestVersion==null){f({tone:`warn`,text:n(`serverManagement.outcomeNoTarget`,`No target version is known for this node — run "Check for update" first.`)});return}if(await a({title:n(`serverManagement.confirmUpdateTitle`,`Update node root package`),message:n(`serverManagement.confirmUpdateBody`,`Install {{pkg}}@{{version}} on "{{node}}" and restart to apply.`,{pkg:h.packageName,version:h.latestVersion,node:t.name}),confirmLabel:n(`serverManagement.confirmUpdateAction`,`Update & restart`)})){f(null);try{let e=await y.mutateAsync({version:h.latestVersion,...p});f({tone:qn(e),text:e.message}),e.restarting&&u(!0)}catch(e){f({tone:`warn`,text:Jn(n,e)})}}},[y,a,t.name,p,h,n]),w=e(async()=>{if(await a({title:n(`serverManagement.confirmRestartTitle`,`Restart node`),message:n(`serverManagement.confirmRestartBody`,`Restart "{{node}}"? In-flight requests to this node are dropped.`,{node:t.name}),confirmLabel:n(`serverManagement.confirmRestartAction`,`Restart`),variant:`warning`})){f(null);try{let e=await S.mutateAsync(p);f({tone:qn(e),text:e.message}),e.restarting&&u(!0)}catch(e){f({tone:`warn`,text:Jn(n,e)})}}},[a,t.name,S,p,n]),T=()=>{switch(h?.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`}}},E=()=>{if(h==null)return null;switch(h.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 h.restartRequired===!0?{label:n(`serverManagement.stateRestartRequired`,`restart required`),tone:`warn`}:h.updateAvailable?{label:n(`serverManagement.stateUpdateAvailable`,`update available`),tone:`warn`}:{label:n(`serverManagement.stateUpToDate`,`up to date`),tone:`ok`}}},D=h?.bootMode===`workspace`,O=t.isOnline&&h!=null&&!D&&h.updateAvailable&&h.updateState===`idle`&&!y.isPending,k=t.isOnline&&h!=null&&h.updateState===`idle`&&!S.isPending,A=t.isOnline?E():null;return r(`div`,{className:`space-y-4 py-2`,children:[r(`div`,{className:`flex items-center justify-between gap-3`,children:[r(`div`,{className:`flex items-center gap-2 min-w-0`,children:[l(`span`,{className:`font-mono text-xs text-foreground-subtle truncate`,children:h?.packageName??t.rootPackage?.name??`@camstack/server`}),t.isOnline&&h!=null&&l(Wn,{...T()})]}),A!=null&&l(Wn,{...A})]}),!t.isOnline&&l(Q,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:t.rootPackage?.version??null}),t.isOnline&&m.isLoading&&r(`div`,{className:`flex items-center gap-2 text-sm text-foreground-subtle`,children:[l(x,{className:`h-4 w-4 animate-spin`}),n(`common.loading`,`Loading…`)]}),t.isOnline&&m.isError&&r(`div`,{className:`space-y-1.5`,children:[l(`p`,{className:`text-sm text-danger`,children:n(`serverManagement.loadError`,`Could not load the node root-package status.`)}),t.rootPackage!=null&&l(Q,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:t.rootPackage.version})]}),t.isOnline&&h!=null&&r(`div`,{className:`space-y-1.5`,children:[l(Gn,{runningVersion:h.runningVersion,latestVersion:h.latestVersion,seedVersion:h.seedVersion,nodeRuntimeVersion:h.nodeRuntimeVersion,labelRunning:n(`serverManagement.runningVersionShort`,`Running`),labelLatest:n(`serverManagement.latestVersionShort`,`Latest`),labelSeed:n(`serverManagement.imageSeedShort`,`Seed`),labelRuntime:n(`serverManagement.nodeRuntimeVersionShort`,`Node.js`)}),h.pendingVersion!=null&&l(Q,{label:n(`serverManagement.pendingVersion`,`Staged (applies on restart)`),value:h.pendingVersion}),h.installedVersion!=null&&h.installedVersion!==h.runningVersion&&l(Q,{label:n(`serverManagement.installedVersion`,`Installed on disk (runs after restart)`),value:h.installedVersion})]}),t.isOnline&&h?.imageContract?.state===`behind-series`&&r(`div`,{className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs leading-relaxed text-danger`,children:[l(`p`,{className:`mb-0.5 font-semibold`,children:n(`serverManagement.imageContractDiverged`,`Container image diverges from the deployment contract`)}),l(`p`,{children:h.imageContract.message})]}),t.isOnline&&D&&l(`p`,{className:`text-xs text-foreground-subtle`,children:n(`serverManagement.workspaceNote`,`Development workspace detected — runtime updates are disabled (the dev loop resolves code from the workspace).`)}),d!=null&&l(`p`,{role:`status`,className:`rounded border px-2 py-1.5 text-xs leading-relaxed ${Kn[d.tone]}`,children:d.text}),o&&r(`div`,{className:`flex items-center gap-2 text-sm text-warning`,children:[l(x,{className:`h-4 w-4 animate-spin`}),n(`serverManagement.nodeRestarting`,`The node is restarting to apply the change…`)]}),t.isOnline&&r(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[r(`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:_.isPending||h?.updateState===`staging`,onClick:()=>_.mutate(p),children:[_.isPending?l(x,{className:`h-3.5 w-3.5 animate-spin`}):l(j,{className:`h-3.5 w-3.5`}),n(`serverManagement.checkForUpdate`,`Check for update`)]}),O&&r(`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 C(),children:[y.isPending?l(x,{className:`h-3.5 w-3.5 animate-spin`}):l(v,{className:`h-3.5 w-3.5`}),n(`serverManagement.updateTo`,`Update to {{version}}`,{version:h?.latestVersion??``})]}),r(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-surface-muted disabled:opacity-50`,disabled:!k,onClick:()=>void w(),children:[S.isPending?l(x,{className:`h-3.5 w-3.5 animate-spin`}):l(b,{className:`h-3.5 w-3.5`}),n(`serverManagement.restart`,`Restart`)]})]}),t.isOnline&&h?.lastCheckedAtMs!=null&&r(`p`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[l(M,{className:`h-3 w-3`}),n(`serverManagement.lastChecked`,`Last checked: {{when}}`,{when:new Date(h.lastCheckedAtMs).toLocaleString()})]})]})}n();function Xn(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 Zn({node:t}){let n=D(),i=s(),[u,p]=c(`info`),[m,h]=c(!1),[g,v]=c(null),y=t.processes??[],b=t.addons.map(e=>e.id),x=ve(void 0),S=a(()=>{let e=x.data?.find(e=>e.nodeId===t.id);return Xn(e?.settings)},[x.data,t.id]),[C,w]=c(!1),[T,E]=c(null),[O,k]=c(null),A=e(async()=>{if(C||t.isHub)return;let e=Qe(t.localIps??[],S);if(e===null){E(`No LAN IPv4 on this node — open its :4444 URL by hand.`),k(null);return}let r=tt();w(!0),E(null),k(null);try{let i=Je(await n.trpcClient.addons.custom.mutate({addonId:`system-config`,action:`mintAgentUiUnlockTicket`,input:{nodeId:t.id,dashboardBaseUrl:$e(e)}})),a=i===null?null:i.dashboardUrl??et(e,i.ticket);if(a===null){r?.close(),E(`Hub did not return an unlock ticket.`);return}nt(r,a)||(k(a),E(`Browser blocked the new tab — click the link below (or allow popups for this site).`))}catch(e){r?.close(),E(e instanceof Error?e.message:String(e))}finally{w(!1)}},[t.id,t.isHub,t.localIps,C,S,n.trpcClient]),j=async()=>{if(!m){h(!0),v(null);try{await n.trpcClient.pipelineOrchestrator.removeAgentSettings.mutate({agentNodeId:t.id}).catch(()=>void 0);let e=await n.trpcClient.clusterNodes.forgetNode.mutate({nodeId:t.id});v({tone:e.stillListed?`warn`:`ok`,text:e.message}),e.stillListed||i.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}catch(e){v({tone:`warn`,text:`Forget failed: ${e instanceof Error?e.message:String(e)}`})}finally{h(!1)}}};return t.isOnline?r(`div`,{className:`border border-border rounded-xl`,children:[r(`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:[r(`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:[l(`div`,{className:`w-2.5 h-2.5 rounded-full bg-success shrink-0`}),l(`span`,{className:`text-sm font-semibold shrink-0`,children:t.name}),r(`span`,{className:`text-xs text-muted-foreground min-w-0 truncate`,children:[t.cpuModel??t.platform,` ·`,` `,t.memoryMB>0?`${Math.round(t.memoryMB/1024)}GB`:``,` · `,t.arch]})]}),t.engines.map(e=>l(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium shrink-0`,children:e},e)),r(`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&&r(`button`,{type:`button`,onClick:()=>void A(),disabled:C,title:`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:[l(_,{className:`h-3 w-3`}),C?`Opening…`:`Open dashboard`]}),r(`span`,{className:`flex items-center gap-1`,children:[l(f,{className:`h-3 w-3`}),` `,t.cpuPercent,`%`]}),r(`span`,{className:`flex items-center gap-1`,children:[l(ee,{className:`h-3 w-3`}),` `,t.memoryPercent,`%`]})]})]}),(T!==null||O!==null)&&r(`p`,{role:`status`,className:`px-4 pt-2 text-xs text-warning`,children:[T,O!==null&&r(o,{children:[` `,l(`a`,{href:O,target:`_blank`,rel:`noreferrer`,className:`underline text-foreground`,children:`Open dashboard`})]})]}),l(`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=>l(`button`,{onClick:()=>p(e),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${u===e?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:e===`info`?`General`:e===`forks`?`Forks (${y.length})`:e===`processes`?`Processes`:e===`load`?`Load`:e===`settings`?`Settings`:`Capabilities`},e))}),r(`div`,{className:`px-4 py-2`,children:[u===`info`&&r(`div`,{className:`space-y-3`,children:[l(Rn,{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}),l(Hn,{nodeId:t.id,detectedHosts:t.localIps??[]}),l(`div`,{className:`border-t border-border pt-1`,children:l(Yn,{node:{id:t.id,name:t.name,isHub:t.isHub,isOnline:t.isOnline,rootPackage:t.rootPackage??null}})})]}),u===`forks`&&l(st,{nodeId:t.id,processes:y}),u===`processes`&&l(dt,{nodeId:t.id}),u===`load`&&l(jn,{nodeId:t.id,isHub:t.isHub}),u===`settings`&&l(Fn,{nodeId:t.id,addonIds:b}),u===`capabilities`&&l(In,{nodeId:t.id,addons:t.addons})]})]}):r(`div`,{className:`border border-border rounded-xl overflow-hidden opacity-60`,children:[r(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 bg-muted/30`,children:[l(`div`,{className:`w-2.5 h-2.5 rounded-full bg-destructive shrink-0`}),l(`span`,{className:`text-sm font-semibold shrink-0`,children:t.name}),r(`span`,{className:`text-xs text-muted-foreground min-w-0 truncate`,children:[t.cpuModel??t.platform,` ·`,` `,t.memoryMB>0?`${Math.round(t.memoryMB/1024)}GB`:``,` · `,t.arch]}),t.engines.map(e=>l(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium`,children:e},e)),t.rootPackage&&r(`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]}),l(`span`,{className:`ml-auto text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`})]}),r(`div`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[r(`span`,{className:`text-xs text-muted-foreground`,children:[t.lastSeen?`Last seen ${new Date(t.lastSeen).toLocaleString()} — `:``,t.addons.length,` addon`,t.addons.length===1?``:`s`,` assigned; will resume when node reconnects`]}),r(`button`,{type:`button`,onClick:()=>void j(),disabled:m,title:`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:[l(d,{className:`h-3 w-3`}),m?`Forgetting…`:`Forget node`]})]}),g!=null&&l(`p`,{role:`status`,className:`px-4 pb-3 text-xs leading-relaxed ${g.tone===`ok`?`text-success`:`text-warning`}`,children:g.text})]})}var $=3,Qn=7e3;function $n(e){return[...e].sort((e,t)=>e.isHub===t.isHub?0:e.isHub?1:-1)}function er(e){return e.isHub?{}:{nodeId:e.id}}function tr(e){return e.updateState===`staging`||e.updateState===`pending-restart`||e.pendingVersion!==null?!0:!e.updateAvailable}async function nr(e,t){let n=er(e),r=`no answer`;for(let i=1;i<=$;i+=1)try{let r=await t.readStatus(n);return tr(r)?{nodeId:e.id,nodeName:e.name,outcome:`applied`,detail:`Connection dropped, and the node confirms the update landed (state ${r.updateState}, running ${r.runningVersion??`unknown`}).`}:{nodeId:e.id,nodeName:e.name,outcome:`failed`,detail:`Connection dropped and the node came back unchanged (still ${r.runningVersion??`unknown`}, update still available). Nothing was staged.`}}catch(e){r=e instanceof Error?e.message:String(e),i<$&&await t.wait(Qn)}return{nodeId:e.id,nodeName:e.name,outcome:`unconfirmed`,detail:`Connection dropped and the node could not be confirmed after ${$} attempts (${r}). It may be restarting — re-check this node.`}}function rr(e){return e.accepted?`applied`:e.outcome===`failed`?`failed`:`refused`}async function ir(e,t){let n=[];for(let r of $n(e))try{let e=await t.apply(er(r));n.push({nodeId:r.id,nodeName:r.name,outcome:rr(e),detail:e.message})}catch{n.push(await nr(r,t))}return n}n();function ar(){let{nodes:e,isLoading:t}=Oe(),n=a(()=>e??[],[e]);return{nodes:n,isLoading:t&&n.length===0}}var or={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 sr(){let{t}=I(),n=Ce(),{nodes:i,isLoading:s}=ar(),[d,f]=Ie(),{selection:p,selectNode:m}=We(i),h=p.node,_=a(()=>i.filter(e=>e.isOnline),[i]),y=_.length,b=i.filter(e=>!e.isOnline).length,S=pe(),C=D(),[w,T]=c(!1),[E,O]=c([]),k=d.get(`unlockNode`),A=d.get(`returnTo`),[j,M]=c(null);u(()=>{if(k===null||A===null)return;let e=!1;return(async()=>{try{let t=await C.trpcClient.addons.custom.mutate({addonId:`system-config`,action:`mintAgentUiUnlockTicket`,input:{nodeId:k,dashboardBaseUrl:A}});if(e)return;let n=Je(t),r=n===null?null:n.dashboardUrl??(()=>{let e=new URL(A);return e.searchParams.set(`ticket`,n.ticket),e.toString()})();if(r===null){M(`Could not mint an unlock ticket.`);return}let i=new URLSearchParams(d);i.delete(`unlockNode`),i.delete(`returnTo`),f(i,{replace:!0}),window.location.assign(r)}catch(t){e||M(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[k,A,d,f,C.trpcClient]);let ee=e(async()=>{let e=_.map(e=>({id:e.id,name:e.name,isHub:e.isHub}));if(await n({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`})){T(!0),O([]);try{O(await ir(e,{apply:e=>S.mutateAsync(e),readStatus:e=>C.trpcClient.serverManagement.getServerPackageStatus.query(e),wait:e=>new Promise(t=>setTimeout(t,e))}))}finally{T(!1)}}},[S,n,_,C,t]);return r(Le,{icon:g,title:t(`nav.nodes`,`Nodes`),subtitle:t(`cluster.subtitle`,`One node at a time — topology, packages and the cluster secret agents need to join.`),actions:r(o,{children:[y>0&&r(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-xs text-success`,children:[y,` online`]}),b>0&&r(`span`,{className:`rounded-full bg-destructive/10 px-2 py-0.5 text-xs text-destructive`,children:[b,` offline`]}),y>1&&r(N,{type:`button`,size:`sm`,disabled:w,title:t(`serverManagement.updateAllHint`,`Sequenced agents-first, hub-last — up-to-date nodes are skipped.`),onClick:()=>void ee(),children:[w?l(x,{className:`h-3.5 w-3.5 animate-spin`}):l(v,{className:`h-3.5 w-3.5`}),t(`serverManagement.updateAll`,`Update all nodes`)]})]}),children:[E.length>0&&l(`ul`,{"aria-label":`update-all-report`,className:`flex flex-col gap-1 text-xs`,children:E.map(e=>r(`li`,{"data-outcome":e.outcome,className:`rounded border px-2 py-1 ${or[e.outcome]}`,children:[l(`span`,{className:`font-medium`,children:e.nodeName}),l(`span`,{className:`mx-1 uppercase tracking-wide`,children:e.outcome}),l(`span`,{className:`opacity-80`,children:e.detail})]},e.nodeId))}),j!==null&&r(`p`,{role:`alert`,className:`rounded border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning`,children:[`Unlock from agent failed: `,j]}),l(Ke,{}),s?l(`div`,{className:`flex items-center justify-center py-12 text-muted-foreground`,children:`Loading cluster topology...`}):h===null?l(`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.`)}):r(`div`,{className:`flex flex-col gap-3`,children:[l(Ue,{staleNodeId:p.staleNodeId,shownNodeName:h.name}),l(ge,{selectedNodeId:h.id,onSelect:m,allowOffline:!0,alwaysShow:!0}),l(Zn,{node:h})]})]})}export{sr as ClusterPage};
1
+ import{I as e,K as t,Q as n,S as r,V as i,W as a,b as o,o as s,q as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{It as d,Jr as f,Nt as p,Oi as m,Pn as h,Rn as g,Rr as _,Yi as v,_i as y,_n as b,ar as x,bi as S,bn as C,dn as w,dt as T,fn as E,ot as D,pi as O,un as k,yi as A,yn as j}from"./player-overlays-C20AJTgs.js";import{t as M}from"./hard-drive-download-Cf7DR1zn.js";import{t as ee}from"./memory-stick-CttSJTx_.js";import{Qr as te,Xr as ne,Zr as re,ti as ie}from"./client-CKGZv6zJ.js";import{$o as ae,Bn as N,Fc as oe,Go as se,Ht as ce,Ic as le,Lc as ue,M as de,Ns as fe,Pc as pe,Qo as me,Tt as he,U as ge,Ut as _e,Vs as ve,Wo as ye,Wt as P,Xl as be,Xs as xe,Xt as Se,Zn as Ce,Zo as we,cr as Te,dr as Ee,es as De,fu as Oe,il as ke,lr as Ae,ma as je,pu as F,rc as Me,ur as Ne,wt as Pe,yn as Fe}from"./src-CIIJy_o8.js";import{t as I}from"./useTranslation-Bc5yH9V9.js";import{Q as Ie}from"./index-AsTGrKva.js";import{t as Le}from"./AdminPage-Pnx0mTsE.js";import{t as Re}from"./NodeAddonsSettingsPanel-BK1RxciP.js";import{f as ze,l as Be,m as Ve,u as He}from"./board-model-Bmts6hrg.js";import{t as L}from"./format-size-DIxKXxtj.js";import{n as Ue,t as We}from"./useNodeUrlSelection-DNAtiVHu.js";n();var Ge=`system-config-cluster`;function Ke(){return l(Fe,{trpc:D().trpcClient,addonId:`system-config`,nodeId:`hub`,sectionIds:[Ge],bare:!0})}function qe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Je(e){if(!qe(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 Ye(e){let t=e.trim();return!(t.length===0||t.includes(`/`)||t.includes(`?`)||t.includes(`#`)||t.includes(`@`)||t.includes(`:`))}function R(e){return e.startsWith(`172.17.`)}function Xe(e){let t=/^100\.(\d+)\./.exec(e);if(t===null)return!1;let n=Number(t[1]);return n>=64&&n<=127}function Ze(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&&!R(e)}function Qe(e,t){if(typeof t==`string`&&Ye(t))return t.trim();let n=e.filter(e=>!e.includes(`:`)),r=n.find(e=>!e.startsWith(`127.`)&&!e.startsWith(`169.254.`)&&!R(e)&&!Xe(e)&&Ze(e));if(r!==void 0)return r;for(let e of n)if(!e.startsWith(`127.`)&&!e.startsWith(`169.254.`)&&!R(e))return e;return null}function $e(e){return`http://${e}:4444/`}function et(e,t){let n=new URL($e(e));return n.searchParams.set(`ticket`,t),n.toString()}function tt(){return window.open(`about:blank`,`_blank`)}function nt(e,t){return e===null||e.closed?!1:(e.location.href=t,!0)}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 it(e){return e===`running`?`running`:e===`crashed`||e===`failed`?`error`:`stopped`}var at=[`trace`,`debug`,`info`,`warn`,`error`];function ot({proc:e,nodeId:t,defaultExpanded:n,activePanel:i,onTogglePanel:a}){let o=e.services??[],s=o.length===1,[u,d]=c(s||n),[f,p]=c(null),[h,g]=c(`info`),_=e.name.includes(`(core)`),v=me(),x=ae(),S=De(),w=async e=>{p(e);try{await v.mutateAsync({nodeId:t,addonId:e})}catch(e){console.error(`Failed to restart addon:`,e)}finally{p(null)}},T=async()=>{p(e.name);try{await x.mutateAsync({nodeId:t,processName:e.name})}catch(e){console.error(`Failed to restart process:`,e)}finally{p(null)}},D=async n=>{let r=`${t}/${e.name}`;try{await S.mutateAsync({nodeId:r,level:n}),g(n)}catch(e){console.error(`Failed to set log level:`,e)}};return r(`div`,{className:`border border-border/50 rounded-lg overflow-hidden`,children:[r(`div`,{role:s?void 0:`button`,tabIndex:s?void 0:0,onClick:s?void 0:()=>d(!u),onKeyDown:s?void 0:e=>{(e.key===`Enter`||e.key===` `)&&d(!u)},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 ${s?``:`hover:bg-muted/40 cursor-pointer`}`,children:[s?l(`span`,{className:`h-3 w-3 shrink-0`}):l(u?A:y,{className:`h-3 w-3 text-muted-foreground shrink-0`}),_?l(k,{className:`h-3.5 w-3.5 text-primary shrink-0`}):l(m,{className:`h-3.5 w-3.5 text-warning shrink-0`}),l(`span`,{className:`text-xs font-semibold min-w-0 flex-1 basis-full truncate sm:basis-auto`,children:e.name}),r(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:[`PID `,e.pid]}),l(de,{status:it(e.state),label:e.state}),r(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:[e.cpuPercent,`% CPU`]}),l(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:L(e.memoryRss)}),l(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:rt(e.uptimeSeconds)}),!_&&r(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[r(Te,{children:[l(Ee,{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:`Set log level`,children:h}),l(Ae,{align:`end`,className:`min-w-[70px] py-0.5`,children:at.map(e=>l(Ne,{onClick:()=>D(e),className:`h-auto px-2 py-1 text-[10px] font-mono ${e===h?`text-primary font-semibold`:``}`,children:e},e))})]}),l(`button`,{onClick:T,disabled:f===e.name,className:`p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:`Restart process`,children:l(b,{className:`h-3 w-3 ${f===e.name?`animate-spin`:``}`})})]})]}),u&&o.length>0&&l(`div`,{className:`divide-y divide-border/30`,children:o.map(e=>r(`div`,{children:[r(`div`,{className:`flex items-center gap-2 px-3 py-1.5 pl-9 hover:bg-muted/10 transition-colors`,children:[l(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`running`?`bg-success`:`bg-muted-foreground/30`}`}),l(`span`,{className:`text-xs font-medium flex-1 min-w-0 truncate`,children:e.addonId}),e.capabilities.length>0&&r(`div`,{className:`flex gap-1 flex-shrink-0`,children:[e.capabilities.slice(0,3).map(e=>l(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-info/10 text-info truncate max-w-[80px]`,children:e},e)),e.capabilities.length>3&&r(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,e.capabilities.length-3]})]}),r(`div`,{className:`flex items-center gap-1 shrink-0`,children:[l(`button`,{onClick:()=>a(e.addonId,`logs`),className:`p-0.5 rounded transition-colors ${i?.addonId===e.addonId&&i.type===`logs`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:`Show logs for ${e.addonId}`,children:l(E,{className:`h-3 w-3`})}),l(`button`,{onClick:()=>a(e.addonId,`events`),className:`p-0.5 rounded transition-colors ${i?.addonId===e.addonId&&i.type===`events`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:`Show events for ${e.addonId}`,children:l(C,{className:`h-3 w-3`})}),l(`button`,{onClick:()=>w(e.addonId),disabled:f===e.addonId,className:`p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:`Restart ${e.addonId}`,children:l(b,{className:`h-3 w-3 ${f===e.addonId?`animate-spin`:``}`})})]})]}),i?.addonId===e.addonId&&i.type===`logs`&&l(`div`,{className:`border-t border-border/40 bg-muted/5`,children:l(he,{addonId:e.addonId,agentId:t,maxHeight:`max-h-48`,showFilters:!1,onClose:()=>a(e.addonId,`logs`)})}),i?.addonId===e.addonId&&i.type===`events`&&l(`div`,{className:`border-t border-border/40 bg-muted/5`,children:l(Pe,{addonId:e.addonId,category:`addon.*`,maxHeight:`max-h-48`,onClose:()=>a(e.addonId,`events`)})})]},e.addonId))}),u&&o.length===0&&l(`div`,{className:`px-3 py-2 pl-9 text-[10px] text-muted-foreground`,children:`No services`})]})}function st({nodeId:e,processes:t}){let[n,r]=c(null),i=(e,t)=>{r(n=>n?.addonId===e&&n.type===t?null:{addonId:e,type:t})};return t.length===0?l(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No processes on this node`}):l(`div`,{className:`space-y-2 py-1`,children:t.map((t,r)=>l(ot,{proc:t,nodeId:e,defaultExpanded:r===0,activePanel:n,onTogglePanel:i},t.name))})}var ct={system:0,managed:1,root:2};n();function lt(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 ut(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function dt({nodeId:e}){let t=s(),n=F(`metrics.node-processes-snapshot`,t=>t.nodeId===e),{data:i}=se({nodeId:e}),o=n?.processes??i,c=a(()=>o?[...o]:[],[o]),u=a(()=>[{key:`classification`,header:`Class`,sortValue:e=>ct[e.classification],render:e=>l(`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=>l(`span`,{className:`font-mono`,children:e.pid})},{key:`ppid`,header:`PPID`,align:`right`,sortValue:e=>e.ppid,render:e=>l(`span`,{className:`font-mono text-foreground-subtle`,children:e.ppid})},{key:`addonId`,header:`Addon`,sortValue:e=>e.addonId,render:e=>l(`span`,{className:`text-foreground-subtle text-[11px]`,children:e.addonId??`—`})},{key:`command`,header:`Command`,nowrap:!1,render:e=>l(`span`,{className:`font-mono text-[10px] text-foreground-subtle break-all`,children:ut(e.command)})},{key:`cpuPercent`,header:`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=>L(e.memoryRssBytes)},{key:`uptimeSec`,header:`Uptime`,align:`right`,sortValue:e=>e.uptimeSec,render:e=>l(`span`,{className:`text-foreground-subtle`,children:lt(e.uptimeSec)})}],[]);return r(`div`,{className:`space-y-4`,children:[l(`div`,{className:`flex items-start justify-end gap-4`,children:r(`button`,{type:`button`,onClick:()=>t.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:[l(j,{className:`h-3 w-3`}),` Refresh`]})}),l(ce,{columns:u,rows:c,rowKey:e=>e.pid,minWidthPx:880,mobileMode:`cards`,maxBodyHeight:_e,emptyMessage:`Scanning…`})]})}var z={width:320,height:64},B=.8,V=Math.ceil(8*B-3)+1,H=z.width+34,U=z.height+V+1+11,ft=V+z.height+1+3+Math.ceil(8*B),pt=[1,2,5,10],mt=[1,2,4,8,16,32,64,128,256,512,1024],ht=[1,1.5,2,2.5,3,4,5],W=[4,3,5,2],gt=1e-9;function _t(e,t){if(!Number.isFinite(e)||e<=0)return!1;if(t===`bytes`){if(!Number.isInteger(e))return!1;let t=e/1024**Math.floor(Math.log(e)/Math.log(1024));return ht.some(e=>Math.abs(t-e)<gt)}let n=e/10**Math.floor(Math.log10(e));return ht.some(e=>Math.abs(n-e)<gt)}function vt(e,t,n){let r=0;for(let t of e)t!==null&&t>r&&(r=t);if(r<=t)return t;if(n===`bytes`){let e=1024**Math.floor(Math.log(r)/Math.log(1024));for(let t of mt){let n=t*e;if(n>=r)return n}return 1024*e}let i=10**Math.floor(Math.log10(r));for(let e of pt){let t=e*i;if(t>=r)return t}return 10*i}function yt(e,t){if(!Number.isFinite(e)||e<=0)return[];let n=W.find(n=>_t(e/n,t))??W[W.length-1],r=e/n,i=[];for(let e=1;e<=n;e++)i.push(r*e);return i}var bt=2.5;function xt(e){return e*bt}function G(e,t,n,r){if(e.length===0)return[];let i=e[0].atMs,a=e.at(-1).atMs-i,o=n<=0?1:n,s=r!==void 0&&r>0?r:null;return e.map((r,c)=>{let l=a>0?(r.atMs-i)/a*t.width:c/Math.max(1,e.length-1)*t.width,u=c>0?e[c-1]:void 0;return{x:l,y:r.value===null?null:t.height-Math.min(r.value,n)/o*t.height,gapBefore:s!==null&&u!==void 0&&r.atMs-u.atMs>s}})}function St(e){let t=[],n=!1;for(let r of e){if(r.y===null){n=!1;continue}r.gapBefore&&(n=!1),t.push(`${n?`L`:`M`}${r.x.toFixed(1)},${r.y.toFixed(1)}`),n=!0}return t.join(` `)}function Ct(e,t){let n=[],r=[],i=()=>{if(r.length<2){r=[];return}let e=r.map((e,t)=>`${t===0?`M`:`L`}${e.x.toFixed(1)},${e.top.toFixed(1)}`),t=[...r].reverse().map(e=>`L${e.x.toFixed(1)},${e.bottom.toFixed(1)}`);n.push(`${e.join(` `)} ${t.join(` `)} Z`),r=[]};for(let n=0;n<e.length;n++){let a=e[n],o=t[n];if(!a||!o||a.y===null||o.y===null){i();continue}(a.gapBefore||o.gapBefore)&&i(),r.push({x:a.x,top:a.y,bottom:o.y})}return i(),n.join(` `)}function wt(e,t,n=3){if(e.length<2||n<2)return[];let r=e[0].atMs,i=e.at(-1).atMs-r;if(i<=0)return[];let a=[];for(let e=0;e<n;e++){let o=e/(n-1);a.push({atMs:r+i*o,x:o*t.width,anchor:e===0?`start`:e===n-1?`end`:`middle`})}return a}function Tt(e){return e.length<2?0:Math.max(0,e.at(-1).atMs-e[0].atMs)}function Et(e){let t=[];for(let n=1;n<e.length;n++){let r=e[n];r.gapBefore&&t.push({fromX:e[n-1].x,toX:r.x})}return t}function Dt(e,t){if(e.length===0)return null;let n=0,r=1/0;for(let i=0;i<e.length;i++){let a=Math.abs(e[i].x-t);a<r&&(r=a,n=i)}return n}n();var K={main:`var(--color-chart-series-a)`,gc:`var(--color-chart-series-b)`},q=z,Ot={height:U};function kt({title:e,points:n,mainLabel:s,gcLabel:u,formatValue:d,emptyMessage:f,gapMs:p}){let m=i(),h=t(null),[g,_]=c(null),v=a(()=>{let e=n.map(e=>({atMs:e.atMs,value:e.main===null||e.gc===null?null:e.main+e.gc})),t=n.map(e=>({atMs:e.atMs,value:e.main})),r=vt(e.map(e=>e.value),25,`linear`),i=G(e,q,r,p),a=G(t,q,r,p),o=a.map(e=>({x:e.x,y:e.y===null?null:q.height,gapBefore:e.gapBefore}));return{max:r,ticks:yt(r,`linear`),upper:i,middle:a,base:o,gaps:Et(i),times:wt(e,q),spanMs:Tt(e)}},[n,p]),y=n.at(-1),b=g===null?void 0:n[g.index],x=b??y;return n.length===0||v.upper.every(e=>e.y===null)?l(Y,{title:e,children:l(zt,{message:f})}):l(Y,{title:e,legend:r(o,{children:[l(Rt,{color:K.main,label:s}),l(Rt,{color:K.gc,label:u})]}),readout:x&&x.main!==null&&x.gc!==null?r(o,{children:[b!==void 0&&l(Lt,{atMs:b.atMs,spanMs:v.spanMs}),l(X,{color:K.main,text:d(x.main)}),l(X,{color:K.gc,text:d(x.gc)})]}):null,children:r(`svg`,{ref:h,viewBox:`0 0 ${H} ${U}`,preserveAspectRatio:`none`,className:`w-full`,style:Ot,role:`img`,"aria-label":`${e}: ${s} and ${u} over time`,onMouseLeave:()=>_(null),onMouseMove:e=>{let t=e.currentTarget.getBoundingClientRect();if(t.width===0)return;let n=(e.clientX-t.left)/t.width*H-34,r=Dt(v.upper,n);r!==null&&_({index:r,xPx:v.upper[r].x})},children:[l(At,{ticks:v.ticks,max:v.max,formatValue:d}),l(It,{ticks:v.times,spanMs:v.spanMs}),r(`g`,{transform:`translate(34,${V})`,clipPath:`url(#${m})`,children:[l(`clipPath`,{id:m,children:l(`rect`,{x:0,y:0,width:q.width,height:q.height})}),l(jt,{spans:v.gaps}),l(`path`,{d:Ct(v.middle,v.base),fill:K.main,fillOpacity:.85}),l(`path`,{d:Ct(v.upper,v.middle),fill:K.gc,fillOpacity:.85,stroke:`var(--color-surface, transparent)`,strokeWidth:2}),l(`path`,{d:St(v.upper),fill:`none`,stroke:K.gc,strokeWidth:2}),g!==null&&l(`line`,{x1:g.xPx,x2:g.xPx,y1:0,y2:q.height,stroke:`currentColor`,strokeWidth:1,className:`text-foreground-subtle`})]})]})})}function J({title:e,points:n,formatValue:i,emptyMessage:s,axisFloor:u,axisScale:d=`linear`,gapMs:f}){let p=t(null),[m,h]=c(null),g=a(()=>{let e=vt(n.map(e=>e.value),u,d),t=G(n,q,e,f);return{max:e,ticks:yt(e,d),projected:t,gaps:Et(t),times:wt(n,q),spanMs:Tt(n)}},[n,u,d,f]),_=m===null?void 0:n[m.index],v=_??n.at(-1)??void 0;return n.length===0||g.projected.every(e=>e.y===null)?l(Y,{title:e,children:l(zt,{message:s})}):l(Y,{title:e,readout:v&&v.value!==null?r(o,{children:[_!==void 0&&l(Lt,{atMs:_.atMs,spanMs:g.spanMs}),l(X,{color:K.main,text:i(v.value)})]}):null,children:r(`svg`,{ref:p,viewBox:`0 0 ${H} ${U}`,preserveAspectRatio:`none`,className:`w-full`,style:Ot,role:`img`,"aria-label":e,onMouseLeave:()=>h(null),onMouseMove:e=>{let t=e.currentTarget.getBoundingClientRect();if(t.width===0)return;let n=(e.clientX-t.left)/t.width*H-34,r=Dt(g.projected,n);r!==null&&h({index:r,xPx:g.projected[r].x})},children:[l(At,{ticks:g.ticks,max:g.max,formatValue:i}),l(It,{ticks:g.times,spanMs:g.spanMs}),r(`g`,{transform:`translate(34,${V})`,children:[l(jt,{spans:g.gaps}),l(`path`,{d:St(g.projected),fill:`none`,stroke:K.main,strokeWidth:2}),m!==null&&l(`line`,{x1:m.xPx,x2:m.xPx,y1:0,y2:q.height,stroke:`currentColor`,strokeWidth:1,className:`text-foreground-subtle`})]})]})})}function At({ticks:e,max:t,formatValue:n}){let i=t<=0?1:t;return l(`g`,{className:`text-foreground-subtle`,children:e.map(e=>{let t=V+q.height-e/i*q.height;return r(`g`,{children:[l(`line`,{x1:34,x2:34+q.width,y1:t,y2:t,stroke:`currentColor`,strokeWidth:.5,strokeOpacity:.3}),l(`text`,{x:0,y:t+3,fontSize:8,fill:`currentColor`,children:n(e)})]},e)})})}function jt({spans:e}){return e.length===0?null:l(`g`,{className:`text-foreground-subtle`,children:e.map(e=>l(`rect`,{x:e.fromX,y:0,width:Math.max(1,e.toX-e.fromX),height:q.height,fill:`currentColor`,fillOpacity:.12,children:l(`title`,{children:`No samples in this interval — nothing was measured, nothing is drawn.`})},`${e.fromX}-${e.toX}`))})}var Mt=10*6e4,Nt={hour:`2-digit`,minute:`2-digit`},Pt={hour:`2-digit`,minute:`2-digit`,second:`2-digit`};function Ft(e,t){return new Date(e).toLocaleTimeString(void 0,t<Mt?Pt:Nt)}function It({ticks:e,spanMs:t}){return e.length===0?null:l(`g`,{className:`text-foreground-subtle`,children:e.map(e=>l(`text`,{x:34+e.x,y:ft,fontSize:8,textAnchor:e.anchor,fill:`currentColor`,children:Ft(e.atMs,t)},e.atMs))})}function Lt({atMs:e,spanMs:t}){return l(`span`,{className:`text-[10px] tabular-nums text-foreground-subtle`,children:Ft(e,t)})}function Y({title:e,legend:t,readout:n,children:i}){return r(`div`,{className:`min-w-0`,children:[r(`div`,{className:`flex items-baseline justify-between gap-2 mb-1`,children:[l(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:e}),l(`div`,{className:`flex items-center gap-2`,children:n})]}),i,t&&l(`div`,{className:`flex items-center gap-3 mt-1`,children:t})]})}function Rt({color:e,label:t}){return r(`span`,{className:`inline-flex items-center gap-1 text-[9px] text-foreground-subtle`,children:[l(`span`,{className:`inline-block h-2 w-2 rounded-[2px]`,style:{backgroundColor:e}}),t]})}function X({color:e,text:t}){return r(`span`,{className:`inline-flex items-center gap-1 text-[11px] tabular-nums text-foreground`,children:[l(`span`,{className:`inline-block h-2 w-2 rounded-[2px]`,style:{backgroundColor:e}}),t]})}function zt({message:e}){return l(`div`,{className:`h-16 flex items-center justify-center rounded border border-dashed border-border text-[10px] text-foreground-subtle text-center px-2`,children:e})}function Bt(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 Vt(e,t,n,r){let i=e.get(t),a=Bt(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 Ht(e,t,n){let r=e;for(let e of ie(t,n))r=Vt(r,e.key,e.kind,e.point);return r}function Ut(e,t){let n=e;for(let e of t)for(let t of e.points)n=Vt(n,e.key,e.kind,t);return n}function Wt(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 Gt=12e4;function Kt(e,t){return e===null?!1:t-e>Gt}function qt(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 Jt(e){for(let t of e.values()){let e=t.points.at(-1);if(e&&e.cpuMainPercent!==null)return!0}return!1}var Yt={key:`cpu`,dir:`desc`};function Xt(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 Zt(e){return e.points.at(-1)?.memoryRssBytes??null}function Qt(e,t,n){let r=n.trim().toLowerCase();return r===``?!0:e.toLowerCase().includes(r)||t.toLowerCase().includes(r)}function $t(e,t){return t===`memory`?Zt(e):Xt(e)}function en(e,t,n){let r=e.filter(e=>t.selectedKeys.size>0&&!t.selectedKeys.has(e.key)?!1:Qt(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=$t(e,t.sort.key),o=$t(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})}n();function tn(e,n=720){let r=F(`metrics.node-processes-snapshot`,t=>t.nodeId===e),[i,a]=c(new Map),[o,s]=c(void 0),l=t(null),{data:d,isPending:f}=ye({forNodeId:e,sinceMs:o,maxPoints:n});u(()=>{d!==void 0&&a(e=>{let t=Ut(e,d.series);return l.current=Wt(t),t})},[d]);let p=r?.timestamp;u(()=>{r==null||p===void 0||(Kt(l.current,p)&&s(l.current??0),a(e=>{let t=Ht(e,r.processes,p);return l.current=Wt(t),t}))},[p]),u(()=>{a(new Map),s(void 0),l.current=null},[e]);let m=0;for(let e of i.values())m=Math.max(m,e.points.length);return{series:qt(i),sampleCount:m,threadSplitAvailable:Jt(i),loadingRetained:f,durable:d?.durable??null,bucketMs:d?.bucketMs??null,cadenceMs:d?.cadenceMs??null,retainedSamples:d?.retainedSamples??null}}var nn=`__unclaimed__`;function rn(e,t){return{kind:e,deviceId:t,cpu:0,cpuKnown:!0,rss:0,rssKnown:!0,count:0,roles:new Set}}function an(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 on(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)??rn(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])=>an(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=rn(`unclaimed`,null);for(let e of a)o.count+=1,o.rss+=e.memoryRssBytes;return o.cpuKnown=!1,[...i,an(nn,o)]}var sn=[{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 cn(e){return e.attribution===`measured`&&e.wiredToday}function ln(){let e=new Set;for(let t of sn)cn(t)&&e.add(t.family);return e}var un=ln();function dn(e){return!un.has(e.role)||e.deviceId===null?!1:e.attribution===`measured`}function fn(e){return`${e.addonId}${e.role}${e.unit}${e.pid??`-`}`}function pn(){return{cpuSeconds:0,cpuKnown:!0,rssBytes:0,rssKnown:!0,unitCount:0,roles:new Set}}function mn(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 hn(e){return Math.round(e*10)/10}function gn(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)dn(t)&&i.set(fn(t),t);let a=new Map,o=new Set;for(let n of t.entries){if(!dn(n)||n.deviceId===null)continue;let t=fn(n);o.add(t);let r=a.get(n.deviceId)??pn();r.unitCount+=1,r.roles.add(n.role);let s=mn(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?hn(n.cpuSeconds/r*100):null,rssBytes:n.rssKnown?n.rssBytes:null,unitCount:n.unitCount,roles:[...n.roles].toSorted()}}))}function _n(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 vn(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 yn(e){let t=e.indexOf(`@`);return t===-1?{addonId:e,nodeId:null}:{addonId:e.slice(0,t),nodeId:e.slice(t+1)}}function bn(e,t){let n=yn(e);return n.nodeId===null?t.isHub:n.nodeId===t.nodeId}function Z(e,t){return e.filter(e=>bn(e.addonId,t))}n();function xn(e){let n=F(`metrics.node-processes-snapshot`,t=>t.nodeId===e.nodeId),r=ke(void 0,{staleTime:1/0,refetchOnWindowFocus:!1}),[i,a]=c(new Map),o=t(null),s=t(r.refetch);s.current=r.refetch;let l=n?.timestamp;u(()=>{l!==void 0&&s.current()},[l]),u(()=>{a(new Map),o.current=null},[e.nodeId,e.isHub]);let d=r.data,f=r.dataUpdatedAt;u(()=>{if(d===void 0||f===0)return;let t={atMs:f,entries:Z(d,e)},n=o.current;if(o.current=t,n===null)return;let r=gn(n,t);r.length!==0&&a(e=>_n(e,r))},[d,f,e.nodeId,e.isHub]);let p=d===void 0?[]:Z(d,e),m=n?.processes,h=on(p,m);return{series:vn(i),unclaimed:h.find(e=>e.kind===`unclaimed`)??null,loading:r.isPending,error:r.error===null?null:r.error.message}}function Sn(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 Cn=25,wn=64*1024*1024,Tn=1e4;function En({scope:e,cadenceMs:t}){let{t:n}=I(),i=xn(e),{data:a=[]}=je({isCamera:!0,projection:`slim`}),o=Sn(a),s=xt(t??Tn);return r(`section`,{className:`space-y-3`,children:[i.error!==null&&r(`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:[l(p,{className:`h-3 w-3 mt-0.5 shrink-0`}),l(`span`,{children:n(`cameraLoad.readFailed`,`Could not read the load contributions: {{error}}. This is a failed read, NOT an idle cluster.`,{error:i.error})})]}),l(On,{unclaimed:i.unclaimed}),i.series.length===0&&i.error===null&&l(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:i.loading?n(`cameraLoad.loading`,`Reading what the addons report…`):n(`cameraLoad.waitingWindow`,`No per-camera window yet.`)}),l(`div`,{className:`space-y-3`,children:i.series.map(e=>r(`div`,{className:`rounded-lg border border-border p-3`,children:[r(`div`,{className:`flex items-baseline justify-between gap-2 mb-2`,children:[l(Dn,{deviceId:e.deviceId,name:o.get(e.deviceId)}),l(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`cameraLoad.unitCount`,`{{count}} unit(s): {{roles}}`,{count:e.points.at(-1)?.unitCount??0,roles:(e.points.at(-1)?.roles??[]).join(`, `)})})]}),r(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[l(J,{title:n(`cameraLoad.cpuTitle`,`CPU % of one core (delta)`),points:e.points.map(e=>({atMs:e.atMs,value:e.cpuPercent})),formatValue:e=>`${e.toFixed(1)}%`,axisFloor:Cn,gapMs:s,emptyMessage:n(`cameraLoad.cpuUnavailable`,`No measurable window yet.`)}),l(J,{title:n(`cameraLoad.memoryTitle`,`Memory RSS`),points:e.points.map(e=>({atMs:e.atMs,value:e.rssBytes})),formatValue:L,axisFloor:wn,axisScale:`bytes`,gapMs:s,emptyMessage:n(`cameraLoad.memoryUnavailable`,`No memory reported.`)})]})]},e.deviceId))})]})}function Dn({deviceId:e,name:t}){let{t:n}=I();return t===void 0?l(`span`,{className:`text-xs font-medium text-foreground`,children:n(`cameraLoad.deviceLabel`,`Camera {{deviceId}}`,{deviceId:e})}):r(`span`,{className:`flex items-baseline gap-1.5 min-w-0`,children:[l(`span`,{className:`text-xs font-medium text-foreground truncate`,children:t}),r(`span`,{className:`shrink-0 text-[10px] font-mono text-foreground-subtle`,children:[`#`,e]})]})}function On({unclaimed:e}){let{t}=I();return e===null||e.unitCount===0?null:l(`div`,{className:`flex items-center gap-2`,children:l(`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?`—`:L(e.rssBytes)})})})}n();var kn=256*1024*1024,An=1e4;function jn({nodeId:e,isHub:t}){let{t:n}=I(),{series:i,sampleCount:o,threadSplitAvailable:s,loadingRetained:u,bucketMs:d,cadenceMs:f}=tn(e),[m,h]=c(``),[g,_]=c(new Set),[v,y]=c(Yt),b=e=>e.key===`__root__`?n(`clusterLoad.bucketRoot`,`Node supervisor`):e.key===`__unattributed__`?n(`clusterLoad.bucketUnattributed`,`Unattributed processes`):e.key,x=xt(d??f??An),S=a(()=>en(i,{search:m,selectedKeys:g,sort:v},b),[i,m,g,v]),C=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return r(`div`,{className:`space-y-4`,children:[l(Mn,{bucketMs:d,cadenceMs:f}),!s&&o>0&&r(`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:[l(p,{className:`h-3 w-3 mt-0.5 shrink-0`}),l(`span`,{children:n(`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.`)})]}),o===0&&l(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:u?n(`clusterLoad.loadingRetained`,`Reading the retained series from this node…`):n(`clusterLoad.waitingFirstSample`,`No retained samples for this node — waiting for the next snapshot (up to 20s). The chart needs two to draw a rate.`)}),i.length>0&&r(`div`,{className:`space-y-2`,children:[r(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r(`label`,{className:`relative flex-1 min-w-[160px]`,children:[l(w,{className:`pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-foreground-subtle`}),l(`input`,{type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:n(`clusterLoad.searchPlaceholder`,`Find a runner…`),"aria-label":n(`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`})]}),l(Nn,{sort:v,onChange:y})]}),r(`div`,{className:`flex flex-wrap items-center gap-1`,children:[i.map(e=>{let t=g.has(e.key);return l(`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)}),g.size>0&&r(`button`,{type:`button`,onClick:()=>_(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:[l(T,{className:`h-2.5 w-2.5`}),n(`clusterLoad.clearFilter`,`All runners`)]})]})]}),i.length>0&&S.length===0&&l(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:n(`clusterLoad.noMatches`,`No runner matches this search on {{count}} present. The node is reporting — the filter is hiding them.`,{count:i.length})}),l(`div`,{className:`space-y-3`,children:S.map(e=>r(`div`,{className:`rounded-lg border border-border p-3`,children:[r(`div`,{className:`flex items-baseline justify-between gap-2 mb-2`,children:[l(`span`,{className:`text-xs font-medium text-foreground`,children:b(e)}),l(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`clusterLoad.processCount`,`{{count}} process(es)`,{count:e.points.at(-1)?.processCount??0})})]}),r(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[l(kt,{title:s?n(`clusterLoad.cpuTitle`,`CPU % of one core`):n(`clusterLoad.cpuTitleLifetime`,`CPU % (ps lifetime average)`),mainLabel:n(`clusterLoad.seriesMain`,`Main threads`),gcLabel:n(`clusterLoad.seriesGc`,`GC / V8 helpers`),points:e.points.map(e=>({atMs:e.atMs,main:e.cpuMainPercent,gc:e.cpuGcPercent})),formatValue:e=>`${e.toFixed(0)}%`,gapMs:x,emptyMessage:n(`clusterLoad.cpuUnavailable`,`No thread split on this node. Lifetime average: {{avg}}%`,{avg:(e.points.at(-1)?.cpuLifetimePercent??0).toFixed(1)})}),l(J,{title:n(`clusterLoad.memoryTitle`,`Memory RSS`),points:e.points.map(e=>({atMs:e.atMs,value:e.memoryRssBytes})),formatValue:L,axisFloor:kn,axisScale:`bytes`,gapMs:x,emptyMessage:n(`clusterLoad.memoryUnavailable`,`No memory samples yet.`)})]})]},e.key))}),l(En,{scope:{nodeId:e,isHub:t},cadenceMs:f})]})}function Mn({bucketMs:e,cadenceMs:t}){let{t:n}=I();return e===null?null:l(`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 Nn({sort:e,onChange:t}){let{t:n}=I(),i=[{key:`cpu`,label:n(`clusterLoad.sortCpu`,`CPU`)},{key:`memory`,label:n(`clusterLoad.sortMemory`,`Memory`)},{key:`name`,label:n(`clusterLoad.sortName`,`Name`)}];return r(`div`,{className:`flex items-center gap-1`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`clusterLoad.sortBy`,`Sort by`)}),i.map(n=>{let i=e.key===n.key;return r(`button`,{type:`button`,"aria-pressed":i,onClick:()=>t(i?{key:n.key,dir:e.dir===`desc`?`asc`:`desc`}:{key:n.key,dir:n.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:[n.label,i&&(e.dir===`desc`?` ↓`:` ↑`)]},n.key)})]})}var Pn=`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 Fn({nodeId:e,addonIds:t}){return t.length===0?l(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No addons on this node`}):l(`div`,{className:`w-full py-2`,children:l(Re,{nodeId:e,addonIds:t,level:`global`,fieldScope:`perNode`,emptyMessage:Pn,selfTabbed:!0})})}n();function In({nodeId:e,addons:t}){let n=s(),{data:r,isLoading:i}=fe({nodeId:e}),o=a(()=>{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]),c=Me({onSuccess:()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCapabilityBindings`]]})}});return o.length===0?l(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No capabilities on this node`}):l(ce,{columns:[{key:`capName`,header:`Capability`,width:`w-1/2`,sortValue:e=>e.capName,render:e=>l(`span`,{className:`font-medium`,children:e.capName})},{key:`provider`,header:`Bound provider`,render:t=>{let n=r?.[t.capName]??t.providers[0]??``,a=t.providers.length===1;return l(`select`,{value:n,onChange:n=>c.mutate({nodeId:e,capName:t.capName,addonId:n.target.value}),disabled:a||c.isPending||i,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?`Only one provider installed — choice becomes available once a second addon registers this capability`:void 0,children:t.providers.map(e=>l(`option`,{value:e,children:e},e))})}}],rows:o,rowKey:e=>e.capName,minWidthPx:520,mobileMode:`cards`,maxBodyHeight:_e})}n();function Ln(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 Rn(e){let[t,n]=c(!1),[i,a]=c(e.name),o=s(),u=we({onSuccess:()=>{o.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}}),d=(e.localIps??[]).filter(e=>!e.includes(`:`)),f=(e.localIps??[]).filter(e=>e.includes(`:`)),p=async()=>{if(!i.trim()||i===e.name){n(!1);return}try{await u.mutateAsync({nodeId:e.nodeId,name:i.trim()}),n(!1)}catch(e){console.error(`Rename failed:`,e)}},m=[[`Node ID`,l(`span`,{className:`font-mono text-xs`,children:e.nodeId})],[`Display Name`,t?r(`div`,{className:`flex items-center gap-1.5`,children:[l(`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:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&p(),e.key===`Escape`&&n(!1)},disabled:u.isPending,autoFocus:!0}),l(`button`,{onClick:()=>void p(),disabled:u.isPending,className:`p-0.5 text-success hover:bg-success/10 rounded`,title:`Save`,children:l(S,{className:`h-3.5 w-3.5`})}),l(`button`,{onClick:()=>n(!1),className:`p-0.5 text-muted-foreground hover:bg-muted rounded`,title:`Cancel`,children:l(T,{className:`h-3.5 w-3.5`})})]}):r(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-xs`,children:e.name}),!e.isHub&&l(`button`,{onClick:()=>{a(e.name),n(!0)},className:`p-0.5 text-muted-foreground hover:text-primary rounded`,title:`Rename`,children:l(h,{className:`h-3 w-3`})})]})],[`Hostname`,l(`span`,{className:`text-xs`,children:e.hostname})],[`Role`,e.isHub?l(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary font-medium`,children:`Hub`}):l(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-medium`,children:`Agent`})],[`Root Package`,e.rootPackage?r(`span`,{className:`font-mono text-xs`,children:[e.rootPackage.name,`@`,e.rootPackage.version]}):l(`span`,{className:`text-xs text-muted-foreground`,children:`—`})],[`Platform`,r(`span`,{className:`text-xs`,children:[e.platform,` / `,e.arch]})],[`CPU`,r(`span`,{className:`text-xs`,children:[e.cpuModel??`—`,` (`,e.cpuCores,` cores)`]})],[`Memory`,l(`span`,{className:`text-xs`,children:e.memoryMB>0?`${(e.memoryMB/1024).toFixed(1)} GB`:`—`})],[`Uptime`,l(`span`,{className:`text-xs`,children:Ln(e.uptime)})],[`Engines`,e.engines.length>0?l(`div`,{className:`flex flex-wrap gap-1`,children:e.engines.map(e=>l(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium`,children:e},e))}):l(`span`,{className:`text-xs text-muted-foreground`,children:`—`})]];return d.length>0&&m.push([`IPv4`,l(`div`,{className:`flex flex-wrap gap-1.5`,children:d.map((e,t)=>l(`span`,{className:`font-mono text-xs px-1.5 py-0.5 rounded bg-muted`,children:e},`${e}-${t}`))})]),f.length>0&&m.push([`IPv6`,l(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map((e,t)=>l(`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}`))})]),l(`div`,{className:`py-2`,children:l(`table`,{className:`w-full text-sm`,children:l(`tbody`,{children:m.map(([e,t],n)=>r(`tr`,{className:n%2==0?`bg-muted/20`:``,children:[l(`td`,{className:`py-1.5 px-2 text-xs font-medium text-muted-foreground w-28 align-top whitespace-nowrap`,children:e}),l(`td`,{className:`py-1.5 px-2`,children:t})]},e))})})})}n();function zn({nodeId:e,value:t,detectedHosts:n,status:i,errorMessage:a,onCommit:o}){let[s,d]=c(t??``);u(()=>{d(t??``)},[t]);let f=n[0],p=f===void 0?`auto-detect`:`auto: ${f}`,m=i===`pending`,h=s.trim(),g=h!==(t??``),_=g&&!m,v=()=>{_&&o(e,h.length>0?h:null)};return r(`div`,{className:`flex items-center gap-1.5`,children:[l(be,{"aria-label":`Reachable host for ${e}`,type:`text`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:p,value:s,disabled:m,onChange:e=>d(e.target.value),onBlur:v,onKeyDown:e=>{e.key===`Enter`&&v(),e.key===`Escape`&&d(t??``)},className:`w-36`}),r(N,{variant:`outline`,size:`sm`,onClick:v,disabled:!_,"aria-label":`Save reachable host for ${e}`,title:`Save reachable host`,children:[m?l(x,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):l(S,{className:`h-3 w-3`,"aria-hidden":`true`}),`Save`]}),!g&&!m&&i===`success`&&l(S,{className:`h-3.5 w-3.5 shrink-0 text-success`,"aria-label":`Saved`,role:`img`}),i===`error`&&l(`span`,{title:a??`Failed to save reachable host`,children:l(O,{className:`h-3.5 w-3.5 shrink-0 text-danger`,"aria-label":a??`Failed to save reachable host`,role:`img`})})]})}n();function Bn(e){let t=re.safeParse(ze(e,`color`));return t.success?t.data:null}function Vn(e,t){return t.variables?.agentNodeId===e?t.isPending?`pending`:t.isError?`error`:t.isSuccess?`success`:`idle`:`idle`}function Hn({nodeId:e,detectedHosts:t}){let{t:n}=I(),i=s(),o=ve(void 0),c=xe({onSuccess:()=>Be(i)}),u=xe({onSuccess:()=>Be(i)}),d=a(()=>o.data?.find(t=>t.nodeId===e)?.settings,[o.data,e]),f=Bn(d)??(o.isLoading?null:te(e)),p=Ve(d,`reachableHost`),m=Vn(e,c),h=m===`error`?He(c.error):null,g=t.filter(e=>!e.includes(`:`)),_=t=>{t!==f&&u.mutate({agentNodeId:e,color:t})};return r(`div`,{className:`rounded-lg border border-border bg-surface/40 divide-y divide-border px-3`,children:[l(P,{label:n(`nodes.general.nodeColour`,`Node colour`),children:l(`div`,{role:`group`,"aria-label":n(`nodes.general.nodeColourGroup`,`Node colour`),className:`flex flex-wrap gap-2`,children:ne.map(e=>{let t=f===e;return l(N,{type:`button`,role:`radio`,"aria-checked":t,"aria-label":e,variant:`outline`,size:`sm`,disabled:o.isLoading||u.isPending,title:e,onClick:()=>_(e),className:`h-6 w-6 min-w-6 shrink-0 rounded-full border-0 p-0 ${Se(e)} ${t?`ring-2 ring-primary ring-offset-2 ring-offset-background`:`opacity-80 hover:opacity-100`}`,children:l(`span`,{className:`sr-only`,children:e})},e)})})}),l(P,{label:n(`nodes.general.reachableHost`,`Reachable host`),children:l(zn,{nodeId:e,value:p,detectedHosts:g,status:m,errorMessage:h,onCommit:(e,t)=>{c.mutate({agentNodeId:e,reachableHost:t})}})})]})}n();var Un=[[`serverManagement`,`getServerPackageStatus`]];function Wn({label:e,tone:t}){return l(`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:e,value:t}){return r(`div`,{className:`flex items-center justify-between gap-4 text-sm`,children:[l(`span`,{className:`text-foreground-subtle`,children:e}),l(`span`,{className:`font-mono text-foreground`,children:t??`—`})]})}function Gn({runningVersion:e,latestVersion:t,seedVersion:n,nodeRuntimeVersion:i,labelRunning:a,labelLatest:o,labelSeed:s,labelRuntime:c}){return l(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-sm`,children:[{key:`running`,label:a,value:e},{key:`latest`,label:o,value:t},{key:`seed`,label:s,value:n},{key:`runtime`,label:c,value:i}].map(({key:e,label:t,value:n})=>r(`span`,{className:`inline-flex items-baseline gap-1`,children:[l(`span`,{className:`text-foreground-subtle`,children:t}),l(`span`,{className:`font-mono text-foreground`,children:n??`—`})]},e))})}var Kn={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 qn(e){return e.outcome===`failed`?`error`:(e.outcome,e.accepted?`ok`:`warn`)}function Jn(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 Yn({node:t}){let{t:n}=I(),i=s(),a=Ce(),[o,u]=c(!1),[d,f]=c(null),p=t.isHub?void 0:{nodeId:t.id},m=le(p,{refetchInterval:1e4,enabled:t.isOnline,retry:1}),h=m.data??null,g=e(()=>{i.invalidateQueries({queryKey:Un})},[i]),_=oe({onSettled:g}),y=pe({onSettled:g}),S=ue({onSettled:g}),C=e(async()=>{if(h?.latestVersion==null){f({tone:`warn`,text:n(`serverManagement.outcomeNoTarget`,`No target version is known for this node — run "Check for update" first.`)});return}if(await a({title:n(`serverManagement.confirmUpdateTitle`,`Update node root package`),message:n(`serverManagement.confirmUpdateBody`,`Install {{pkg}}@{{version}} on "{{node}}" and restart to apply.`,{pkg:h.packageName,version:h.latestVersion,node:t.name}),confirmLabel:n(`serverManagement.confirmUpdateAction`,`Update & restart`)})){f(null);try{let e=await y.mutateAsync({version:h.latestVersion,...p});f({tone:qn(e),text:e.message}),e.restarting&&u(!0)}catch(e){f({tone:`warn`,text:Jn(n,e)})}}},[y,a,t.name,p,h,n]),w=e(async()=>{if(await a({title:n(`serverManagement.confirmRestartTitle`,`Restart node`),message:n(`serverManagement.confirmRestartBody`,`Restart "{{node}}"? In-flight requests to this node are dropped.`,{node:t.name}),confirmLabel:n(`serverManagement.confirmRestartAction`,`Restart`),variant:`warning`})){f(null);try{let e=await S.mutateAsync(p);f({tone:qn(e),text:e.message}),e.restarting&&u(!0)}catch(e){f({tone:`warn`,text:Jn(n,e)})}}},[a,t.name,S,p,n]),T=()=>{switch(h?.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`}}},E=()=>{if(h==null)return null;switch(h.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 h.restartRequired===!0?{label:n(`serverManagement.stateRestartRequired`,`restart required`),tone:`warn`}:h.updateAvailable?{label:n(`serverManagement.stateUpdateAvailable`,`update available`),tone:`warn`}:{label:n(`serverManagement.stateUpToDate`,`up to date`),tone:`ok`}}},D=h?.bootMode===`workspace`,O=t.isOnline&&h!=null&&!D&&h.updateAvailable&&h.updateState===`idle`&&!y.isPending,k=t.isOnline&&h!=null&&h.updateState===`idle`&&!S.isPending,A=t.isOnline?E():null;return r(`div`,{className:`space-y-4 py-2`,children:[r(`div`,{className:`flex items-center justify-between gap-3`,children:[r(`div`,{className:`flex items-center gap-2 min-w-0`,children:[l(`span`,{className:`font-mono text-xs text-foreground-subtle truncate`,children:h?.packageName??t.rootPackage?.name??`@camstack/server`}),t.isOnline&&h!=null&&l(Wn,{...T()})]}),A!=null&&l(Wn,{...A})]}),!t.isOnline&&l(Q,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:t.rootPackage?.version??null}),t.isOnline&&m.isLoading&&r(`div`,{className:`flex items-center gap-2 text-sm text-foreground-subtle`,children:[l(x,{className:`h-4 w-4 animate-spin`}),n(`common.loading`,`Loading…`)]}),t.isOnline&&m.isError&&r(`div`,{className:`space-y-1.5`,children:[l(`p`,{className:`text-sm text-danger`,children:n(`serverManagement.loadError`,`Could not load the node root-package status.`)}),t.rootPackage!=null&&l(Q,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:t.rootPackage.version})]}),t.isOnline&&h!=null&&r(`div`,{className:`space-y-1.5`,children:[l(Gn,{runningVersion:h.runningVersion,latestVersion:h.latestVersion,seedVersion:h.seedVersion,nodeRuntimeVersion:h.nodeRuntimeVersion,labelRunning:n(`serverManagement.runningVersionShort`,`Running`),labelLatest:n(`serverManagement.latestVersionShort`,`Latest`),labelSeed:n(`serverManagement.imageSeedShort`,`Seed`),labelRuntime:n(`serverManagement.nodeRuntimeVersionShort`,`Node.js`)}),h.pendingVersion!=null&&l(Q,{label:n(`serverManagement.pendingVersion`,`Staged (applies on restart)`),value:h.pendingVersion}),h.installedVersion!=null&&h.installedVersion!==h.runningVersion&&l(Q,{label:n(`serverManagement.installedVersion`,`Installed on disk (runs after restart)`),value:h.installedVersion})]}),t.isOnline&&h?.imageContract?.state===`behind-series`&&r(`div`,{className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs leading-relaxed text-danger`,children:[l(`p`,{className:`mb-0.5 font-semibold`,children:n(`serverManagement.imageContractDiverged`,`Container image diverges from the deployment contract`)}),l(`p`,{children:h.imageContract.message})]}),t.isOnline&&D&&l(`p`,{className:`text-xs text-foreground-subtle`,children:n(`serverManagement.workspaceNote`,`Development workspace detected — runtime updates are disabled (the dev loop resolves code from the workspace).`)}),d!=null&&l(`p`,{role:`status`,className:`rounded border px-2 py-1.5 text-xs leading-relaxed ${Kn[d.tone]}`,children:d.text}),o&&r(`div`,{className:`flex items-center gap-2 text-sm text-warning`,children:[l(x,{className:`h-4 w-4 animate-spin`}),n(`serverManagement.nodeRestarting`,`The node is restarting to apply the change…`)]}),t.isOnline&&r(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[r(`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:_.isPending||h?.updateState===`staging`,onClick:()=>_.mutate(p),children:[_.isPending?l(x,{className:`h-3.5 w-3.5 animate-spin`}):l(j,{className:`h-3.5 w-3.5`}),n(`serverManagement.checkForUpdate`,`Check for update`)]}),O&&r(`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 C(),children:[y.isPending?l(x,{className:`h-3.5 w-3.5 animate-spin`}):l(v,{className:`h-3.5 w-3.5`}),n(`serverManagement.updateTo`,`Update to {{version}}`,{version:h?.latestVersion??``})]}),r(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-surface-muted disabled:opacity-50`,disabled:!k,onClick:()=>void w(),children:[S.isPending?l(x,{className:`h-3.5 w-3.5 animate-spin`}):l(b,{className:`h-3.5 w-3.5`}),n(`serverManagement.restart`,`Restart`)]})]}),t.isOnline&&h?.lastCheckedAtMs!=null&&r(`p`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[l(M,{className:`h-3 w-3`}),n(`serverManagement.lastChecked`,`Last checked: {{when}}`,{when:new Date(h.lastCheckedAtMs).toLocaleString()})]})]})}n();function Xn(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 Zn({node:t}){let n=D(),i=s(),[u,p]=c(`info`),[m,h]=c(!1),[g,v]=c(null),y=t.processes??[],b=t.addons.map(e=>e.id),x=ve(void 0),S=a(()=>{let e=x.data?.find(e=>e.nodeId===t.id);return Xn(e?.settings)},[x.data,t.id]),[C,w]=c(!1),[T,E]=c(null),[O,k]=c(null),A=e(async()=>{if(C||t.isHub)return;let e=Qe(t.localIps??[],S);if(e===null){E(`No LAN IPv4 on this node — open its :4444 URL by hand.`),k(null);return}let r=tt();w(!0),E(null),k(null);try{let i=Je(await n.trpcClient.addons.custom.mutate({addonId:`system-config`,action:`mintAgentUiUnlockTicket`,input:{nodeId:t.id,dashboardBaseUrl:$e(e)}})),a=i===null?null:i.dashboardUrl??et(e,i.ticket);if(a===null){r?.close(),E(`Hub did not return an unlock ticket.`);return}nt(r,a)||(k(a),E(`Browser blocked the new tab — click the link below (or allow popups for this site).`))}catch(e){r?.close(),E(e instanceof Error?e.message:String(e))}finally{w(!1)}},[t.id,t.isHub,t.localIps,C,S,n.trpcClient]),j=async()=>{if(!m){h(!0),v(null);try{await n.trpcClient.pipelineOrchestrator.removeAgentSettings.mutate({agentNodeId:t.id}).catch(()=>void 0);let e=await n.trpcClient.clusterNodes.forgetNode.mutate({nodeId:t.id});v({tone:e.stillListed?`warn`:`ok`,text:e.message}),e.stillListed||i.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}catch(e){v({tone:`warn`,text:`Forget failed: ${e instanceof Error?e.message:String(e)}`})}finally{h(!1)}}};return t.isOnline?r(`div`,{className:`border border-border rounded-xl`,children:[r(`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:[r(`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:[l(`div`,{className:`w-2.5 h-2.5 rounded-full bg-success shrink-0`}),l(`span`,{className:`text-sm font-semibold shrink-0`,children:t.name}),r(`span`,{className:`text-xs text-muted-foreground min-w-0 truncate`,children:[t.cpuModel??t.platform,` ·`,` `,t.memoryMB>0?`${Math.round(t.memoryMB/1024)}GB`:``,` · `,t.arch]})]}),t.engines.map(e=>l(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium shrink-0`,children:e},e)),r(`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&&r(`button`,{type:`button`,onClick:()=>void A(),disabled:C,title:`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:[l(_,{className:`h-3 w-3`}),C?`Opening…`:`Open dashboard`]}),r(`span`,{className:`flex items-center gap-1`,children:[l(f,{className:`h-3 w-3`}),` `,t.cpuPercent,`%`]}),r(`span`,{className:`flex items-center gap-1`,children:[l(ee,{className:`h-3 w-3`}),` `,t.memoryPercent,`%`]})]})]}),(T!==null||O!==null)&&r(`p`,{role:`status`,className:`px-4 pt-2 text-xs text-warning`,children:[T,O!==null&&r(o,{children:[` `,l(`a`,{href:O,target:`_blank`,rel:`noreferrer`,className:`underline text-foreground`,children:`Open dashboard`})]})]}),l(`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=>l(`button`,{onClick:()=>p(e),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${u===e?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:e===`info`?`General`:e===`forks`?`Forks (${y.length})`:e===`processes`?`Processes`:e===`load`?`Load`:e===`settings`?`Settings`:`Capabilities`},e))}),r(`div`,{className:`px-4 py-2`,children:[u===`info`&&r(`div`,{className:`space-y-3`,children:[l(Rn,{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}),l(Hn,{nodeId:t.id,detectedHosts:t.localIps??[]}),l(`div`,{className:`border-t border-border pt-1`,children:l(Yn,{node:{id:t.id,name:t.name,isHub:t.isHub,isOnline:t.isOnline,rootPackage:t.rootPackage??null}})})]}),u===`forks`&&l(st,{nodeId:t.id,processes:y}),u===`processes`&&l(dt,{nodeId:t.id}),u===`load`&&l(jn,{nodeId:t.id,isHub:t.isHub}),u===`settings`&&l(Fn,{nodeId:t.id,addonIds:b}),u===`capabilities`&&l(In,{nodeId:t.id,addons:t.addons})]})]}):r(`div`,{className:`border border-border rounded-xl overflow-hidden opacity-60`,children:[r(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 bg-muted/30`,children:[l(`div`,{className:`w-2.5 h-2.5 rounded-full bg-destructive shrink-0`}),l(`span`,{className:`text-sm font-semibold shrink-0`,children:t.name}),r(`span`,{className:`text-xs text-muted-foreground min-w-0 truncate`,children:[t.cpuModel??t.platform,` ·`,` `,t.memoryMB>0?`${Math.round(t.memoryMB/1024)}GB`:``,` · `,t.arch]}),t.engines.map(e=>l(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium`,children:e},e)),t.rootPackage&&r(`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]}),l(`span`,{className:`ml-auto text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`})]}),r(`div`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[r(`span`,{className:`text-xs text-muted-foreground`,children:[t.lastSeen?`Last seen ${new Date(t.lastSeen).toLocaleString()} — `:``,t.addons.length,` addon`,t.addons.length===1?``:`s`,` assigned; will resume when node reconnects`]}),r(`button`,{type:`button`,onClick:()=>void j(),disabled:m,title:`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:[l(d,{className:`h-3 w-3`}),m?`Forgetting…`:`Forget node`]})]}),g!=null&&l(`p`,{role:`status`,className:`px-4 pb-3 text-xs leading-relaxed ${g.tone===`ok`?`text-success`:`text-warning`}`,children:g.text})]})}var $=3,Qn=7e3;function $n(e){return[...e].sort((e,t)=>e.isHub===t.isHub?0:e.isHub?1:-1)}function er(e){return e.isHub?{}:{nodeId:e.id}}function tr(e){return e.updateState===`staging`||e.updateState===`pending-restart`||e.pendingVersion!==null?!0:!e.updateAvailable}async function nr(e,t){let n=er(e),r=`no answer`;for(let i=1;i<=$;i+=1)try{let r=await t.readStatus(n);return tr(r)?{nodeId:e.id,nodeName:e.name,outcome:`applied`,detail:`Connection dropped, and the node confirms the update landed (state ${r.updateState}, running ${r.runningVersion??`unknown`}).`}:{nodeId:e.id,nodeName:e.name,outcome:`failed`,detail:`Connection dropped and the node came back unchanged (still ${r.runningVersion??`unknown`}, update still available). Nothing was staged.`}}catch(e){r=e instanceof Error?e.message:String(e),i<$&&await t.wait(Qn)}return{nodeId:e.id,nodeName:e.name,outcome:`unconfirmed`,detail:`Connection dropped and the node could not be confirmed after ${$} attempts (${r}). It may be restarting — re-check this node.`}}function rr(e){return e.accepted?`applied`:e.outcome===`failed`?`failed`:`refused`}async function ir(e,t){let n=[];for(let r of $n(e))try{let e=await t.apply(er(r));n.push({nodeId:r.id,nodeName:r.name,outcome:rr(e),detail:e.message})}catch{n.push(await nr(r,t))}return n}n();function ar(){let{nodes:e,isLoading:t}=Oe(),n=a(()=>e??[],[e]);return{nodes:n,isLoading:t&&n.length===0}}var or={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 sr(){let{t}=I(),n=Ce(),{nodes:i,isLoading:s}=ar(),[d,f]=Ie(),{selection:p,selectNode:m}=We(i),h=p.node,_=a(()=>i.filter(e=>e.isOnline),[i]),y=_.length,b=i.filter(e=>!e.isOnline).length,S=pe(),C=D(),[w,T]=c(!1),[E,O]=c([]),k=d.get(`unlockNode`),A=d.get(`returnTo`),[j,M]=c(null);u(()=>{if(k===null||A===null)return;let e=!1;return(async()=>{try{let t=await C.trpcClient.addons.custom.mutate({addonId:`system-config`,action:`mintAgentUiUnlockTicket`,input:{nodeId:k,dashboardBaseUrl:A}});if(e)return;let n=Je(t),r=n===null?null:n.dashboardUrl??(()=>{let e=new URL(A);return e.searchParams.set(`ticket`,n.ticket),e.toString()})();if(r===null){M(`Could not mint an unlock ticket.`);return}let i=new URLSearchParams(d);i.delete(`unlockNode`),i.delete(`returnTo`),f(i,{replace:!0}),window.location.assign(r)}catch(t){e||M(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[k,A,d,f,C.trpcClient]);let ee=e(async()=>{let e=_.map(e=>({id:e.id,name:e.name,isHub:e.isHub}));if(await n({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`})){T(!0),O([]);try{O(await ir(e,{apply:e=>S.mutateAsync(e),readStatus:e=>C.trpcClient.serverManagement.getServerPackageStatus.query(e),wait:e=>new Promise(t=>setTimeout(t,e))}))}finally{T(!1)}}},[S,n,_,C,t]);return r(Le,{icon:g,title:t(`nav.nodes`,`Nodes`),subtitle:t(`cluster.subtitle`,`One node at a time — topology, packages and the cluster secret agents need to join.`),actions:r(o,{children:[y>0&&r(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-xs text-success`,children:[y,` online`]}),b>0&&r(`span`,{className:`rounded-full bg-destructive/10 px-2 py-0.5 text-xs text-destructive`,children:[b,` offline`]}),y>1&&r(N,{type:`button`,size:`sm`,disabled:w,title:t(`serverManagement.updateAllHint`,`Sequenced agents-first, hub-last — up-to-date nodes are skipped.`),onClick:()=>void ee(),children:[w?l(x,{className:`h-3.5 w-3.5 animate-spin`}):l(v,{className:`h-3.5 w-3.5`}),t(`serverManagement.updateAll`,`Update all nodes`)]})]}),children:[E.length>0&&l(`ul`,{"aria-label":`update-all-report`,className:`flex flex-col gap-1 text-xs`,children:E.map(e=>r(`li`,{"data-outcome":e.outcome,className:`rounded border px-2 py-1 ${or[e.outcome]}`,children:[l(`span`,{className:`font-medium`,children:e.nodeName}),l(`span`,{className:`mx-1 uppercase tracking-wide`,children:e.outcome}),l(`span`,{className:`opacity-80`,children:e.detail})]},e.nodeId))}),j!==null&&r(`p`,{role:`alert`,className:`rounded border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning`,children:[`Unlock from agent failed: `,j]}),l(Ke,{}),s?l(`div`,{className:`flex items-center justify-center py-12 text-muted-foreground`,children:`Loading cluster topology...`}):h===null?l(`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.`)}):r(`div`,{className:`flex flex-col gap-3`,children:[l(Ue,{staleNodeId:p.staleNodeId,shownNodeName:h.name}),l(ge,{selectedNodeId:h.id,onSelect:m,allowOffline:!0,alwaysShow:!0}),l(Zn,{node:h})]})]})}export{sr as ClusterPage};