rigscope 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +2 -2
- package/.next/build-manifest.json +2 -2
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +3 -3
- package/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/administration/page_client-reference-manifest.js +1 -1
- package/.next/server/app/administration.html +1 -1
- package/.next/server/app/administration.rsc +3 -3
- package/.next/server/app/administration.segments/_full.segment.rsc +3 -3
- package/.next/server/app/administration.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/administration.segments/administration/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/alerts/page_client-reference-manifest.js +1 -1
- package/.next/server/app/alerts.html +1 -1
- package/.next/server/app/alerts.rsc +3 -3
- package/.next/server/app/alerts.segments/_full.segment.rsc +3 -3
- package/.next/server/app/alerts.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/alerts.segments/alerts/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/connections/page_client-reference-manifest.js +1 -1
- package/.next/server/app/connections.html +1 -1
- package/.next/server/app/connections.rsc +3 -3
- package/.next/server/app/connections.segments/_full.segment.rsc +3 -3
- package/.next/server/app/connections.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/connections.segments/connections/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/history/page.js +2 -2
- package/.next/server/app/history/page_client-reference-manifest.js +1 -1
- package/.next/server/app/history.html +1 -1
- package/.next/server/app/history.rsc +6 -6
- package/.next/server/app/history.segments/_full.segment.rsc +6 -6
- package/.next/server/app/history.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/history.segments/history/__PAGE__.segment.rsc +6 -6
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +3 -3
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/index.segments/_full.segment.rsc +3 -3
- package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/.next/server/app/login.html +1 -1
- package/.next/server/app/login.rsc +3 -3
- package/.next/server/app/login.segments/_full.segment.rsc +3 -3
- package/.next/server/app/login.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/machines/[machineId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/processes/page.js +1 -1
- package/.next/server/app/processes/page_client-reference-manifest.js +1 -1
- package/.next/server/app/processes.html +1 -1
- package/.next/server/app/processes.rsc +4 -4
- package/.next/server/app/processes.segments/_full.segment.rsc +4 -4
- package/.next/server/app/processes.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/processes.segments/processes/__PAGE__.segment.rsc +4 -4
- package/.next/server/app-paths-manifest.json +2 -2
- package/.next/server/chunks/161.js +1 -1
- package/.next/server/chunks/168.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/route-cache/APP_PAGE/16d1ab46157a868f438fa01e04bf53e805c71cddec593ea1535905c59625cd42/$/login.html +1 -0
- package/.next/server/route-cache/APP_PAGE/16d1ab46157a868f438fa01e04bf53e805c71cddec593ea1535905c59625cd42/$/login.meta +1 -0
- package/.next/server/route-cache/APP_PAGE/16d1ab46157a868f438fa01e04bf53e805c71cddec593ea1535905c59625cd42/$/login.rsc +26 -0
- package/.next/server/route-cache/APP_PAGE/16d1ab46157a868f438fa01e04bf53e805c71cddec593ea1535905c59625cd42/$/login.segments/_full.segment.rsc +26 -0
- package/.next/server/route-cache/APP_PAGE/16d1ab46157a868f438fa01e04bf53e805c71cddec593ea1535905c59625cd42/$/login.segments/_tree.segment.rsc +4 -0
- package/.next/server/route-cache/APP_PAGE/16d1ab46157a868f438fa01e04bf53e805c71cddec593ea1535905c59625cd42/$/login.segments/login/__PAGE__.segment.rsc +32 -0
- package/.next/server/route-cache/APP_PAGE/41da0ef926a63354a29f601d8e8d0a5951196c45ebcd28b7d4708fb7f56f3bf1/$/_not-found.html +1 -0
- package/.next/server/route-cache/APP_PAGE/41da0ef926a63354a29f601d8e8d0a5951196c45ebcd28b7d4708fb7f56f3bf1/$/_not-found.meta +1 -0
- package/.next/server/route-cache/APP_PAGE/41da0ef926a63354a29f601d8e8d0a5951196c45ebcd28b7d4708fb7f56f3bf1/$/_not-found.rsc +24 -0
- package/.next/server/route-cache/APP_PAGE/41da0ef926a63354a29f601d8e8d0a5951196c45ebcd28b7d4708fb7f56f3bf1/$/_not-found.segments/_full.segment.rsc +24 -0
- package/.next/server/route-cache/APP_PAGE/41da0ef926a63354a29f601d8e8d0a5951196c45ebcd28b7d4708fb7f56f3bf1/$/_not-found.segments/_not-found/__PAGE__.segment.rsc +30 -0
- package/.next/server/route-cache/APP_PAGE/41da0ef926a63354a29f601d8e8d0a5951196c45ebcd28b7d4708fb7f56f3bf1/$/_not-found.segments/_tree.segment.rsc +4 -0
- package/.next/server/route-cache/APP_PAGE/c6377dd9ce6a1c2cd100eb4344e843eb4639b9ed26f84643f77680e9eb454c4b/$/index.html +1 -0
- package/.next/server/route-cache/APP_PAGE/c6377dd9ce6a1c2cd100eb4344e843eb4639b9ed26f84643f77680e9eb454c4b/$/index.meta +1 -0
- package/.next/server/route-cache/APP_PAGE/c6377dd9ce6a1c2cd100eb4344e843eb4639b9ed26f84643f77680e9eb454c4b/$/index.rsc +26 -0
- package/.next/server/route-cache/APP_PAGE/c6377dd9ce6a1c2cd100eb4344e843eb4639b9ed26f84643f77680e9eb454c4b/$/index.segments/__PAGE__.segment.rsc +31 -0
- package/.next/server/route-cache/APP_PAGE/c6377dd9ce6a1c2cd100eb4344e843eb4639b9ed26f84643f77680e9eb454c4b/$/index.segments/_full.segment.rsc +26 -0
- package/.next/server/route-cache/APP_PAGE/c6377dd9ce6a1c2cd100eb4344e843eb4639b9ed26f84643f77680e9eb454c4b/$/index.segments/_tree.segment.rsc +3 -0
- package/.next/static/chunks/408-4fe7147e38981ee1.js +1 -0
- package/.next/static/chunks/939-514e554087419c71.js +1 -0
- package/.next/static/chunks/app/history/page-69ea64476ee5db85.js +3 -0
- package/.next/static/chunks/app/processes/{page-e471ed23a1d5632f.js → page-0e98a4a64e829c5f.js} +1 -1
- package/.next/static/css/3fbf75e4c471c6a8.css +1 -0
- package/ARCHITECTURE.md +30 -4
- package/CHANGELOG.md +47 -2
- package/dist/cli.cjs +1627 -1042
- package/dist/collector.cjs +138 -226
- package/dist/hub.cjs +7 -20
- package/dist/ops.cjs +160 -33
- package/dist/system.cjs +869 -450
- package/docs/bottlenecks.md +4 -6
- package/docs/configuration.md +2 -0
- package/docs/installation.md +42 -7
- package/docs/operations.md +32 -16
- package/docs/releasing.md +21 -17
- package/docs/system-installation.md +11 -2
- package/package.json +1 -2
- package/.next/static/chunks/408-dc6158e0bb450ef6.js +0 -1
- package/.next/static/chunks/939-2600d7c8e583d5ef.js +0 -1
- package/.next/static/chunks/app/history/page-1475454737279ee0.js +0 -3
- package/.next/static/css/e45c0c7ef5ba0336.css +0 -1
- /package/.next/static/{NE6PGEiJxUnKRceuzUWPc → xjSDCOO8Gpm5iPO9tyRG5}/_buildManifest.js +0 -0
- /package/.next/static/{NE6PGEiJxUnKRceuzUWPc → xjSDCOO8Gpm5iPO9tyRG5}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
1:"$Sreact.fragment"
|
|
2
|
+
2:"static/chunks/939-514e554087419c71.js"
|
|
3
|
+
3:"static/chunks/app/layout-4feff677c4071745.js"
|
|
4
|
+
4:I[2737,["939","$2","177","$3"],"ThemeProvider"]
|
|
5
|
+
5:I[9939,["939","$2","177","$3"],"LiveProvider"]
|
|
6
|
+
6:I[7121,[],""]
|
|
7
|
+
7:I[4581,[],""]
|
|
8
|
+
9:"static/chunks/157-0d36ebf66af048ac.js"
|
|
9
|
+
a:"static/chunks/103-c47318242b24e9ac.js"
|
|
10
|
+
b:"static/chunks/227-417939c480f50747.js"
|
|
11
|
+
c:"static/chunks/app/page-1ae9fc94c897785b.js"
|
|
12
|
+
d:I[7281,["157","$9","939","$2","103","$a","227","$b","974","$c"],"FleetView"]
|
|
13
|
+
e:I[484,[],"OutletBoundary"]
|
|
14
|
+
f:"$Sreact.suspense"
|
|
15
|
+
11:"ViewportBoundary"
|
|
16
|
+
12:I[484,[],"$11"]
|
|
17
|
+
14:"MetadataBoundary"
|
|
18
|
+
15:I[484,[],"$14"]
|
|
19
|
+
17:I[7123,[],"default",1]
|
|
20
|
+
:HL["/_next/static/css/3fbf75e4c471c6a8.css","style"]
|
|
21
|
+
8:[["children",{"s":"__PAGE__","h":512,"d":{"r":["$","$1","c",{"children":[["$","$Ld",null,{}],null,["$","$Le",null,{"children":["$","$f",null,{"name":"Next.MetadataOutlet","children":"$@10"}]}]]}],"p":false,"v":null}}]]
|
|
22
|
+
0:{"P":null,"c":["",""],"q":"","i":false,"t":{"t":{"s":"","h":528,"d":{"r":["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/3fbf75e4c471c6a8.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}]],["$","html",null,{"lang":"en","suppressHydrationWarning":true,"children":["$","body",null,{"children":["$","$L4",null,{"attribute":"class","defaultTheme":"dark","enableSystem":true,"children":["$","$L5",null,{"children":["$","$L6",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L7",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}]}]}]}]]}],"p":false,"v":null},"c":"$Q8"},"h":{"r":["$","$1","h",{"children":[null,["$","$L12",null,{"children":"$L13"}],["$","$L15",null,{"children":[["$","div",null,{"hidden":true,"children":["$","$f",null,{"name":"Next.Metadata","children":"$L16"}]}],null]}],null]}],"p":false,"v":null}},"m":"$undefined","G":["$17",[]],"S":true,"r":"$undefined","s":"$undefined","a":"$undefined","l":"$undefined","p":"$undefined","d":"$undefined","b":"xjSDCOO8Gpm5iPO9tyRG5"}
|
|
23
|
+
13:[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1"}]]
|
|
24
|
+
18:I[6869,[],"IconMark"]
|
|
25
|
+
10:null
|
|
26
|
+
16:[["$","title","0",{"children":"Fleet"}],["$","meta","1",{"name":"description","content":"Self-hosted remote system monitor — a live fleet of collectors behind one authenticated hub."}],["$","link","2",{"rel":"icon","href":"/icon.svg?3b3fa3229e2d0d7a","type":"image/svg+xml","sizes":"any"}],["$","$L18","3",{}]]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[408],{4150:(e,t,r)=>{r.d(t,{Au:()=>u,_C:()=>a,eg:()=>c});var s=r(5155),n=r(2115),i=r(6304),l=r(5078);let o=(0,n.createContext)(null);function a({children:e}){let[t,r]=(0,n.useState)(null),i=(0,n.useCallback)(e=>r(t=>t?.timeMs===e?.timeMs&&t?.source===e?.source?t:e),[]),l=(0,n.useMemo)(()=>({cursor:t,setCursor:i}),[t,i]);return(0,s.jsx)(o.Provider,{value:l,children:e})}function u({series:e,fromMs:t,toMs:r,stepMs:s,gaps:l}){let a=(0,n.useId)(),[c,d]=(0,n.useState)(null),m=(0,n.useContext)(o),f=m?m.cursor:c,p=m?m.setCursor:d,h=(0,n.useRef)(null),g=(0,n.useRef)(null),y=(0,n.useCallback)(()=>{null!==h.current&&cancelAnimationFrame(h.current),h.current=null,g.current=null},[]);(0,n.useEffect)(()=>y,[y]);let b=(0,n.useMemo)(()=>(0,i.X)(e).filter(e=>e.t<=r&&e.t+s/2>=t),[e,t,r,s]),x=f&&f.timeMs>=t-s/2&&f.timeMs<=r?f.timeMs:null,v=null!==x&&f?.source===a;(0,n.useEffect)(()=>{if(!v)return;let e=e=>{"Escape"===e.key&&(y(),p(null))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[v,p,y]);let M=()=>{y(),f?.source===a&&p(null)};return{id:a,timeMs:x,active:v,inspect:e=>{let n=Math.max(t,Math.min(r,e)),o=(0,i.bO)(b,n,s,l);g.current={timeMs:o?.t??n,source:a},null===h.current&&(h.current=requestAnimationFrame(()=>{h.current=null,p(g.current),g.current=null}))},clear:M,onKeyDown:e=>{if(y(),"Escape"===e.key)e.preventDefault(),M();else if(["ArrowLeft","ArrowRight","Home","End"].includes(e.key)){e.preventDefault();let t=(0,i.o7)(b,x,e.key);null!==t&&p({timeMs:t,source:a})}},onFocus:()=>{y(),p({timeMs:b.at(-1)?.t??r,source:a})}}}function c({id:e,timeMs:t,fraction:r,unit:i,readings:o}){let[a]=(0,n.useState)(()=>r>.5?"left":"right");return(0,s.jsxs)("div",{id:e,role:"tooltip",className:`absolute top-2 z-10 max-h-56 w-56 max-w-[calc(100%-1rem)] overflow-y-auto rounded-md border border-border bg-card p-3 text-xs text-foreground ${"left"===a?"left-2":"right-2"}`,children:[(0,s.jsx)("p",{className:"tnum font-medium",children:(0,l.r6)(t)}),(0,s.jsx)("p",{className:"mb-2 text-muted-foreground",children:"Recorded bucket average"}),(0,s.jsx)("dl",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-baseline gap-x-4 gap-y-1.5",children:o.map(({key:e,label:r,color:n,point:o})=>(0,s.jsxs)("div",{className:"contents",children:[(0,s.jsxs)("dt",{className:"flex min-w-0 items-center gap-1.5",children:[(0,s.jsx)("span",{"aria-hidden":!0,className:"h-2 w-2 shrink-0 rounded-full",style:{backgroundColor:n}}),(0,s.jsx)("span",{className:"break-words",children:r})]}),(0,s.jsxs)("dd",{className:"tnum text-right",children:[o?.avg==null?"No reading":(0,l.dd)(o.avg,i),o&&o.t!==t?(0,s.jsx)("span",{className:"block text-muted-foreground",children:(0,l.ei)(o.t)}):null]})]},e))})]})}},4567:(e,t,r)=>{r.d(t,{Cv:()=>n,H9:()=>s,Lf:()=>u,P$:()=>i,RL:()=>g,bP:()=>h,er:()=>m,oB:()=>a,ue:()=>p,yv:()=>d});let s=[{metric:"cpu.usage",label:"CPU usage",shortLabel:"CPU",unit:"percent",family:"cpu",colorSlot:0,description:"Total processor utilization"},{metric:"cpu.core",label:"Per-core CPU",shortLabel:"Per-core",unit:"percent",family:"cpu",colorSlot:0,description:"Logical-core utilization; heatmap for large selections"},{metric:"cpu.temperature",label:"CPU temperature",shortLabel:"Temperature",unit:"celsius",family:"cpu",colorSlot:3,description:"Identifiable CPU hwmon sensor temperature"},{metric:"cpu.power",label:"CPU package power",shortLabel:"Power",unit:"watts",family:"cpu",colorSlot:4,description:"Top-level RAPL package power draw"},{metric:"cpu.iowait",label:"CPU I/O wait",shortLabel:"I/O wait",unit:"percent",family:"cpu",colorSlot:2,description:"Processor time waiting on I/O"},{metric:"cpu.pressure",label:"CPU pressure",shortLabel:"Pressure",unit:"percent",family:"cpu",colorSlot:4,description:"Linux PSI CPU stall pressure (avg10)"},{metric:"memory.used",label:"Memory used",shortLabel:"Memory",unit:"bytes",family:"memory",colorSlot:1,description:"Physical memory in use"},{metric:"memory.usage",label:"Memory usage",shortLabel:"Memory %",unit:"percent",family:"memory",colorSlot:1,description:"Physical memory used as a share of total"},{metric:"memory.pressure.some",label:"Memory pressure (some)",shortLabel:"Pressure some",unit:"percent",family:"memory",colorSlot:2,description:"Linux PSI memory stall pressure, some tasks (avg10)"},{metric:"memory.pressure.full",label:"Memory pressure (full)",shortLabel:"Pressure full",unit:"percent",family:"memory",colorSlot:4,description:"Linux PSI memory stall pressure, all tasks (avg10)"},{metric:"swap.used",label:"Swap used",shortLabel:"Swap",unit:"bytes",family:"swap",colorSlot:2,description:"Swap space in use"},{metric:"gpu.utilization",label:"GPU utilization",shortLabel:"Utilization",unit:"percent",family:"gpus",colorSlot:0,description:"Per-card graphics processor utilization"},{metric:"gpu.memory.used",label:"GPU memory used",shortLabel:"VRAM",unit:"bytes",family:"gpus",colorSlot:1,description:"Per-card video memory in use"},{metric:"gpu.temperature",label:"GPU temperature",shortLabel:"Temperature",unit:"celsius",family:"gpus",colorSlot:3,description:"Per-card temperature"},{metric:"gpu.power",label:"GPU power",shortLabel:"Power",unit:"watts",family:"gpus",colorSlot:4,description:"Per-card power draw"},{metric:"fs.used",label:"Filesystem used",shortLabel:"Filesystem",unit:"bytes",family:"disks",colorSlot:1,description:"Used space per mounted filesystem"},{metric:"fs.usage",label:"Filesystem usage",shortLabel:"Filesystem %",unit:"percent",family:"disks",colorSlot:1,description:"Used capacity per mounted filesystem, derived from a positive total"},{metric:"fs.inodes.usage",label:"Inode usage",shortLabel:"Inodes %",unit:"percent",family:"disks",colorSlot:2,description:"Used inodes per filesystem where the collector can read them"},{metric:"disk.read",label:"Disk read",shortLabel:"Read",unit:"bytes_per_second",family:"disks",colorSlot:0,description:"Device read throughput"},{metric:"disk.write",label:"Disk write",shortLabel:"Write",unit:"bytes_per_second",family:"disks",colorSlot:2,description:"Device write throughput"},{metric:"disk.read.latency",label:"Disk read latency",shortLabel:"Read latency",unit:"milliseconds",family:"disks",colorSlot:0,description:"Average device read latency"},{metric:"disk.write.latency",label:"Disk write latency",shortLabel:"Write latency",unit:"milliseconds",family:"disks",colorSlot:2,description:"Average device write latency"},{metric:"disk.utilization",label:"Disk utilization",shortLabel:"Utilization",unit:"percent",family:"disks",colorSlot:3,description:"Share of time the device had I/O in flight"},{metric:"io.pressure.some",label:"I/O pressure (some)",shortLabel:"I/O some",unit:"percent",family:"disks",colorSlot:3,description:"Linux PSI I/O stall pressure, some tasks (avg10)"},{metric:"io.pressure.full",label:"I/O pressure (full)",shortLabel:"I/O full",unit:"percent",family:"disks",colorSlot:4,description:"Linux PSI I/O stall pressure, all tasks (avg10)"},{metric:"net.rx",label:"Network received",shortLabel:"Received",unit:"bytes_per_second",family:"network",colorSlot:0,description:"Interface receive rate"},{metric:"net.tx",label:"Network sent",shortLabel:"Sent",unit:"bytes_per_second",family:"network",colorSlot:2,description:"Interface transmit rate"}];function n(e,t){return e.filter(r=>{for(let[s,n,i]of[["memory","memory.used","memory.usage"],["filesystem","fs.used","fs.usage"]])if(e.includes(n)&&e.includes(i)&&(r===n||r===i))return r===("percent"===t[s]?i:n);return!0})}let i=[{id:"cpu",label:"CPU",metrics:["cpu.usage","cpu.core","cpu.iowait","cpu.pressure","cpu.temperature","cpu.power"]},{id:"memory",label:"Memory",metrics:["memory.used","memory.usage","swap.used","memory.pressure.some","memory.pressure.full"]},{id:"gpu",label:"GPU",metrics:["gpu.utilization","gpu.memory.used","gpu.temperature","gpu.power"]},{id:"disk",label:"Storage",metrics:["fs.used","fs.usage","fs.inodes.usage","disk.read","disk.write","disk.read.latency","disk.write.latency","disk.utilization","io.pressure.some","io.pressure.full"]},{id:"network",label:"Network",metrics:["net.rx","net.tx"]}],l=["var(--cpu)","var(--mem)","color-mix(in oklab, var(--swap) 75%, var(--foreground))","var(--warn)","var(--crit)","var(--accent)"],o=[void 0,"7 4","2 3","10 3 2 3","4 4","1 3"];function a(e){return s.find(t=>t.metric===e)??null}function u(e,t){let r=Math.max(0,t),s=e.colorSlot+r,n=(r+Math.floor(s/l.length))%o.length;return{color:l[s%l.length],dash:o[n]}}let c={cpu:"CPU",memory:"Memory",swap:"Swap",gpus:"GPU metrics",disks:"Disk metrics",network:"Network metrics"};function d(e,t){let r=a(t);if(null===r||void 0===e)return{available:!0,reason:null};let s=e.inventory?.capabilities?.[r.family];if(!s||"supported"===s.status)return{available:!0,reason:null};let n=s.reason?.trim();return{available:!1,reason:n?`${c[r.family]}: ${s.status} — ${n}`:`${c[r.family]} are ${s.status} on this machine.`}}function m(e){if(void 0===e)return[];let t=[],r=r=>{!(t.length>=16)&&d(e,r).available&&t.push(r)};r("cpu.usage"),r("memory.used");let s=function(e){let t=e.inventory?.memory.swapTotalBytes;if("number"==typeof t)return t;let r=e.metrics?.payload.swap;return r?.status==="ok"?r.totalBytes:null}(e);return null!==s&&s>0&&r("swap.used"),p(e,[]).length>0&&(r("gpu.utilization"),r("gpu.memory.used")),t}function f(e){let t=e.includes(":")?e.slice(e.indexOf(":")+1):e;return t.length<=18?t:`${t.slice(0,10)}…${t.slice(-4)}`}function p(e,t){let r=new Set(t.filter(e=>e.metric.startsWith("gpu.")&&""!==e.resourceId).map(e=>e.resourceId)),s=[],n=new Set;(e?.inventory?.gpus??[]).forEach(e=>{let t="supported"===e.telemetry;(t||r.has(e.id))&&(n.add(e.id),s.push({id:e.id,label:e.name.trim()||f(e.id),index:s.length,totalBytes:e.memoryTotalBytes,supported:t,hasHistory:r.has(e.id)}))});let i=e?.metrics?.payload.gpus;if(i?.status==="ok")for(let e of i.devices)n.has(e.id)||"ok"!==e.status||(n.add(e.id),s.push({id:e.id,label:f(e.id),index:s.length,totalBytes:e.memoryTotalBytes,supported:!0,hasHistory:r.has(e.id)}));for(let e of[...r].sort())n.has(e)||s.push({id:e,label:f(e),index:s.length,totalBytes:null,supported:!0,hasHistory:!0});return s}function h(e,t,r){if(""===r)return a(t)?.shortLabel??"Total";let s=a(t);if(null===s)return f(r);switch(s.family){case"gpus":{let t=e?.inventory?.gpus.find(e=>e.id===r);return t?.name.trim()||f(r)}case"disks":{if(t.startsWith("fs.")){let t=e?.inventory?.filesystems.find(e=>e.id===r);return t?.mountPoint||f(r)}let s=e?.inventory?.disks.find(e=>e.id===r);return s?.name||f(r)}case"network":{let t=e?.inventory?.network.find(e=>e.id===r);return t?.name||f(r)}case"cpu":{let e=/^core:(\d+)$/.exec(r);return e?`Core ${e[1]}`:f(r)}default:return f(r)}}function g(e){switch(e){case"percent":return"%";case"bytes":return"bytes";case"bytes_per_second":return"bytes/s";case"celsius":return"\xb0C";case"watts":return"W";case"milliseconds":return"ms";default:return e}}},5078:(e,t,r)=>{r.d(t,{Ah:()=>d,I_:()=>h,O5:()=>p,Vw:()=>M,bf:()=>v,dd:()=>c,ei:()=>m,fH:()=>g,ly:()=>n,pI:()=>s,r6:()=>f,zp:()=>i});let s=[{id:"10m",shortLabel:"10m",label:"Last 10 minutes",ms:6e5,refreshMs:1e3},{id:"1h",shortLabel:"1h",label:"Last hour",ms:36e5,refreshMs:1e3},{id:"6h",shortLabel:"6h",label:"Last 6 hours",ms:216e5,refreshMs:1e3},{id:"24h",shortLabel:"24h",label:"Last 24 hours",ms:864e5,refreshMs:1e3},{id:"7d",shortLabel:"7d",label:"Last 7 days",ms:6048e5,refreshMs:1e3}];function n(e){return s.find(t=>t.id===e)??s[0]}function i(e){return n(e).refreshMs}let l=["B","KiB","MiB","GiB","TiB","PiB"];function o(e){let t=Math.abs(e),r=0;for(;t>=1024&&r<l.length-1;)t/=1024,r+=1;return{value:e<0?-t:t,unit:l[r]}}function a(e,t){return String(Number(e.toFixed(t)))}function u(e,t=""){let{value:r,unit:s}=o(e),n=Math.abs(r)>=100?0:1;return`${a(r,n)} ${s}${t}`}function c(e,t){if(null==e||!Number.isFinite(e))return"—";switch(t){case"percent":return`${a(e,1)}%`;case"bytes":return u(e);case"bytes_per_second":return u(e,"/s");case"celsius":return`${a(e,1)}\xb0C`;case"watts":return`${a(e,1)} W`;case"milliseconds":return`${a(e,10>Math.abs(e)?2:1)} ms`;default:return a(e,2)}}function d(e,t){if(!Number.isFinite(e))return"—";switch(t){case"percent":return`${a(e,0)}%`;case"bytes":case"bytes_per_second":{let{value:r,unit:s}=o(e),n=Math.abs(r)>=10||0===r?0:1;return`${a(r,n)} ${s}${"bytes_per_second"===t?"/s":""}`}case"celsius":return`${a(e,0)}\xb0C`;case"watts":return`${a(e,0)} W`;case"milliseconds":return`${a(e,+(10>Math.abs(e)))} ms`;default:return a(e,1)}}function m(e){return new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function f(e){return new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"})}function p(e,t){let r=new Date(e);return t>=1728e5?r.toLocaleDateString(void 0,{month:"short",day:"numeric"}):t>=864e5?r.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}):r.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1})}function h(e){let t=Math.max(0,e);return t>=36e5?`${a(t/36e5,1)} h`:t>=6e4?`${a(t/6e4,1)} min`:`${a(t/1e3,1)} s`}function g(e,t,r){let s=e.filter(e=>e.toMs>=t&&e.fromMs<=r);if(0===s.length)return"No recorded gaps in this range.";let n=s.filter(e=>"dropped"===e.kind).length,i=s.length-n,l=[];i>0&&l.push(`${i} missed interval${1===i?"":"s"}`),n>0&&l.push(`${n} dropped report${1===n?"":"s"}`);let o=[...new Set(s.map(e=>e.reason).filter(e=>"string"==typeof e&&e.length>0))],a=o.length>0?` (${o.slice(0,3).join("; ")})`:"";return`${l.join(" and ")}${a}.`}function y(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function b(e){return"number"==typeof e&&Number.isFinite(e)}function x(e){return null===e||b(e)}function v(e){if(!y(e)||"string"!=typeof e.machineId||0===e.machineId.length||!b(e.fromMs)||!b(e.toMs)||e.toMs<=e.fromMs||!b(e.stepMs)||e.stepMs<=0||"raw"!==e.tier&&"1m"!==e.tier&&"1h"!==e.tier||"boolean"!=typeof e.truncated||!b(e.elapsedMs)||!Array.isArray(e.series)||!Array.isArray(e.gaps))return null;let t=[];for(let r of e.series){if(!y(r)||"string"!=typeof r.metric||"string"!=typeof r.resourceId||"string"!=typeof r.unit||!Array.isArray(r.points))return null;let e=[];for(let t of r.points){if(!y(t)||!b(t.t)||!x(t.min)||!x(t.max)||!x(t.avg))return null;e.push({t:t.t,min:t.min,max:t.max,avg:t.avg})}t.push({metric:r.metric,resourceId:r.resourceId,unit:r.unit,points:e})}let r=[];for(let t of e.gaps){if(!y(t)||!b(t.fromMs)||!b(t.toMs)||"missing"!==t.kind&&"dropped"!==t.kind)return null;let e={fromMs:t.fromMs,toMs:t.toMs,kind:t.kind};"string"==typeof t.reason&&(e.reason=t.reason),b(t.droppedRecords)&&(e.droppedRecords=t.droppedRecords),r.push(e)}return{machineId:e.machineId,fromMs:e.fromMs,toMs:e.toMs,stepMs:e.stepMs,tier:e.tier,series:t,gaps:r,truncated:e.truncated,elapsedMs:e.elapsedMs}}function M(e,t,r,s,i=600,l){let{fromMs:o,toMs:a}={fromMs:s-n(r).ms,toMs:s},u=new URLSearchParams({machineId:e,metrics:t.join(","),from:String(Math.floor(o)),to:String(Math.floor(a)),maxPoints:String(i)});return void 0!==l&&u.set("coreIds",l.join(",")),`/api/history?${u.toString()}`}},6304:(e,t,r)=>{function s(e,t,r,s){if(s.some(e=>t>e.fromMs&&t<e.toMs))return null;let n=0,i=e.length;for(;n<i;){let r=n+i>>>1;e[r].t<t?n=r+1:i=r}let l=e[n-1],o=e[n],a=l&&(!o||t-l.t<=o.t-t)?l:o;return!a||Math.abs(a.t-t)>r/2||s.some(e=>e.toMs>Math.min(t,a.t)&&e.fromMs<Math.max(t,a.t))?null:a}function n(e){return[...new Set(e.flatMap(e=>e.points.map(e=>e.t)))].sort((e,t)=>e-t).map(e=>({t:e,min:null,max:null,avg:null}))}function i(e,t,r,s,n,l=0){return Math.round(s+Math.max(0,Math.min(1,((r>0?(e-t)/r:0)-l)/(1-2*l)))*(n-s))}function l(e,t,r){return 0===e.length?null:"Home"===r?e[0].t:"End"===r||null===t?e.at(-1).t:"ArrowLeft"===r?[...e].reverse().find(e=>e.t<t)?.t??e[0].t:"ArrowRight"===r?e.find(e=>e.t>t)?.t??e.at(-1).t:t}r.d(t,{X:()=>n,bO:()=>s,o7:()=>l,yk:()=>i})},7284:(e,t,r)=>{r.d(t,{t:()=>c});var s=r(5155),n=r(2115),i=r(7726),l=r(5078),o=r(4567),a=r(6304),u=r(4150);function c(e){let{title:t,unit:r,series:c,fromMs:d,toMs:m,stepMs:f,gaps:p,hiddenKeys:h,onToggleSeries:g,emptyMessage:y,note:b}=e,x=(0,n.useMemo)(()=>c.filter(e=>!h.has(e.key)),[c,h]),v=(0,u.Au)({series:x,fromMs:d,toMs:m,stepMs:f,gaps:p}),M=(0,n.useRef)(null),k=(0,n.useMemo)(()=>x.flatMap(e=>e.points),[x]),w=k.some(e=>null!==e.avg||null!==e.min||null!==e.max),$=Math.max(1,m-d),j=(0,n.useMemo)(()=>(0,i.$z)(p,d,m,k),[p,d,m,k]),S=(0,n.useMemo)(()=>(0,i.kk)(r,k.flatMap(e=>[e.min,e.max,e.avg]).filter(e=>null!==e)),[r,k]),L=Math.max(1e-9,S.max-S.min),N=(0,n.useCallback)(e=>6+(Math.min(m,Math.max(d,e))-d)/$*788,[d,m,$]),P=(0,n.useCallback)(e=>6+(1-(e-S.min)/L)*148,[S.min,L]),I=(0,n.useMemo)(()=>x.map(t=>{let r=(0,i.o)(t.points,{stepMs:f,gaps:j,fromMs:d,toMs:m}).map(t=>(0,i.SG)(t,e.maxDrawPoints??601,f));return{...t,segments:r,envelope:r.filter(e=>e.length>1).map(e=>{let t=e.map(e=>`${N(e.t).toFixed(2)},${P(e.max??e.avg).toFixed(2)}`),r=[...e].reverse().map(e=>`${N(e.t).toFixed(2)},${P(e.min??e.avg).toFixed(2)}`);return`M${t.join("L")}L${r.join("L")}Z`}).join(" "),path:r.filter(e=>e.length>1).map(e=>e.map((e,t)=>`${0===t?"M":"L"}${N(e.t).toFixed(2)},${P(e.avg).toFixed(2)}`).join(" ")).join(" ")}}),[x,e.maxDrawPoints,f,j,d,m,N,P]),C=(0,n.useMemo)(()=>(function(e,t,r,s,n,o){if(0===r.length)return`${e} chart: no series selected.`;let a=r.map(e=>{let r=(0,i.T6)(e.points);return`${e.label}: ${function(e,t){let r=[];if(null!==e.latest){let s=null!==e.latestT?(0,l.ei)(e.latestT):null;r.push(`latest ${(0,l.dd)(e.latest,t)}${s?` at ${s}`:""}`)}return r.push(`average ${(0,l.dd)(e.avg,t)}`),null!==e.min&&null!==e.max&&r.push(`recorded range ${(0,l.dd)(e.min,t)} to ${(0,l.dd)(e.max,t)}`),r.join(", ")}(r,t)}`}),u=o>0?`${o} shaded interval${1===o?"":"s"} without stored data.`:"";return`${e} time-series chart. ${a.join(". ")}. ${u} Time range ${(0,l.ei)(s)} to ${(0,l.ei)(n)}.`})(t,r,x,d,m,j.length),[t,r,x,d,m,j.length]),A=(0,n.useMemo)(()=>new Map(c.map(e=>[e.key,(0,i.T6)(e.points)])),[c]),F=null===v.timeMs?[]:x.map(e=>({...e,point:(0,a.bO)(e.points,v.timeMs,f,p)})),D=null===v.timeMs?null:N(v.timeMs),R=`${v.id}-tooltip`,U=`${v.id}-instructions`,E=(0,n.useMemo)(()=>(0,s.jsxs)(s.Fragment,{children:[S.ticks.map(e=>(0,s.jsx)("line",{x1:6,x2:794,y1:P(e),y2:P(e),stroke:"var(--border)",strokeWidth:"1",vectorEffect:"non-scaling-stroke"},`grid-${e}`)),j.map(e=>(0,s.jsx)("rect",{x:N(e.fromMs),y:6,width:Math.max(1,N(e.toMs)-N(e.fromMs)),height:148,fill:"var(--muted-foreground)",opacity:"0.09"},`gap-${e.fromMs}-${e.toMs}-${e.kind}`)),I.map(e=>{let t=e.envelope;return""===t?null:(0,s.jsx)("path",{d:t,fill:e.color,opacity:"0.14",stroke:"none"},`band-${e.key}`)}),I.map(e=>{let t=e.path;return""===t?null:(0,s.jsx)("path",{d:t,fill:"none",stroke:e.color,strokeWidth:"2",strokeDasharray:e.dash,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"},`line-${e.key}`)}),I.flatMap(e=>e.segments.filter(e=>1===e.length).map(t=>{let r=t[0],n=N(r.t),i=P(r.avg);return(0,s.jsx)("line",{x1:n-2.5,x2:n+2.5,y1:i,y2:i,stroke:e.color,strokeWidth:"2.5",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"},`dot-${e.key}-${r.t}`)}))]}),[S,N,P,j,I]);return(0,s.jsxs)("figure",{className:`flex min-w-0 flex-col gap-2 ${e.className??""}`,children:[(0,s.jsxs)("div",{className:"flex min-h-8 flex-wrap items-center justify-between gap-2",children:[(0,s.jsx)("h3",{className:"text-xs font-medium tracking-tight text-foreground",children:t}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("span",{className:"tnum shrink-0 text-xs text-muted-foreground",children:b??(0,o.RL)(r)}),e.action]})]}),w?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex min-w-0 gap-2",children:[(0,s.jsx)("div",{"aria-hidden":!0,className:"flex h-40 w-14 shrink-0 flex-col justify-between py-0.5 text-right text-xs leading-none tnum text-muted-foreground",children:[...S.ticks].reverse().map(e=>(0,s.jsx)("span",{children:(0,l.Ah)(e,r)},e))}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"relative",onPointerLeave:v.clear,onPointerMove:e=>{let t=M.current?.getBoundingClientRect();t&&v.inspect((0,a.yk)(e.clientX,t.left,t.width,d,m,.0075))},children:[(0,s.jsx)("p",{id:U,className:"sr-only",children:"Use Left and Right arrows to inspect recorded readings, Home or End to jump, and Escape to dismiss."}),(0,s.jsxs)("svg",{ref:M,viewBox:"0 0 800 160",preserveAspectRatio:"none",role:"img","aria-label":C,tabIndex:0,"aria-describedby":`${U}${v.active?` ${R}`:""}`,onFocus:v.onFocus,onBlur:v.clear,onKeyDown:v.onKeyDown,className:"block h-40 w-full cursor-crosshair rounded-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent",children:[(0,s.jsx)("title",{children:t}),E,null!==D?(0,s.jsxs)("g",{"aria-hidden":!0,pointerEvents:"none",children:[(0,s.jsx)("line",{x1:D,x2:D,y1:6,y2:154,stroke:"var(--muted-foreground)",strokeWidth:"1",strokeDasharray:"3 3",vectorEffect:"non-scaling-stroke"}),F.map(({key:e,color:t,point:r})=>r?.avg==null?null:(0,s.jsx)("circle",{cx:N(r.t),cy:P(r.avg),r:"3.5",fill:t,stroke:"var(--card)",strokeWidth:"1.5",vectorEffect:"non-scaling-stroke"},e))]}):null]}),v.active&&null!==v.timeMs&&null!==D?(0,s.jsx)(u.eg,{id:R,timeMs:v.timeMs,fraction:D/800,unit:r,readings:F}):null]}),(0,s.jsx)("div",{"aria-hidden":!0,className:"mt-1 flex justify-between gap-2 text-xs leading-tight tnum text-muted-foreground",children:(0,i.Cf)(d,m).map((e,t,r)=>(0,s.jsx)("span",{className:`${0===t?"text-left":t===r.length-1?"text-right":"hidden text-center sm:inline"}`,children:(0,l.O5)(e,$)},e))})]})]}),(0,s.jsx)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs",children:c.map(e=>{let t=!h.has(e.key),n=A.get(e.key);return(0,s.jsxs)("label",{className:"inline-flex min-h-7 cursor-pointer items-center gap-1.5",title:t?`Hide ${e.label}`:`Show ${e.label}`,children:[(0,s.jsx)("input",{type:"checkbox",checked:t,onChange:()=>g(e.key),className:"peer sr-only"}),(0,s.jsx)("span",{"aria-hidden":!0,className:"flex h-4 w-5 shrink-0 items-center justify-center rounded-sm peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:[outline-color:var(--focus)]",children:(0,s.jsx)("svg",{viewBox:"0 0 20 8",className:"h-2 w-5","aria-hidden":!0,children:(0,s.jsx)("line",{x1:"1",y1:"4",x2:"19",y2:"4",stroke:e.color,strokeWidth:"2.5",strokeDasharray:e.dash,strokeLinecap:"round"})})}),(0,s.jsx)("span",{className:t?"text-foreground":"text-muted-foreground line-through",children:e.label}),(0,s.jsx)("span",{className:"tnum text-muted-foreground",children:(0,l.dd)(n.latest,r)})]},`legend-${e.key}`)})})]}):(0,s.jsx)("div",{className:"flex min-h-32 items-center justify-center rounded-lg border border-dashed border-border px-4 py-6 text-center text-xs text-muted-foreground",children:0===c.length?y:0===x.length?"All series are hidden. Re-enable one in the legend below.":y}),!w&&c.length>0?(0,s.jsx)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs",children:c.map(e=>{let t=!h.has(e.key);return(0,s.jsxs)("label",{className:"inline-flex min-h-7 cursor-pointer items-center gap-1.5",children:[(0,s.jsx)("input",{type:"checkbox",checked:t,onChange:()=>g(e.key),className:"peer sr-only"}),(0,s.jsx)("span",{"aria-hidden":!0,className:"flex h-4 w-5 shrink-0 items-center justify-center peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:[outline-color:var(--focus)]",children:(0,s.jsx)("svg",{viewBox:"0 0 20 8",className:"h-2 w-5","aria-hidden":!0,children:(0,s.jsx)("line",{x1:"1",y1:"4",x2:"19",y2:"4",stroke:e.color,strokeWidth:"2.5",strokeDasharray:e.dash,strokeLinecap:"round"})})}),(0,s.jsx)("span",{className:t?"text-foreground":"text-muted-foreground line-through",children:e.label})]},`legend-empty-${e.key}`)})}):null]})}},7726:(e,t,r)=>{function s(e){return null!==e.avg&&Number.isFinite(e.avg)}function n(e){return null!==e&&Number.isFinite(e)?e:null}function i(e){let t=[];for(let r of e){let e=t.at(-1);if(void 0!==e&&r.fromMs<=e.toMs){e.toMs=Math.max(e.toMs,r.toMs),"missing"===e.kind&&"dropped"===r.kind&&(e.kind="dropped"),void 0===e.reason&&void 0!==r.reason&&(e.reason=r.reason),void 0===e.droppedRecords&&void 0!==r.droppedRecords&&(e.droppedRecords=r.droppedRecords);continue}t.push({...r})}return t}function l(e,t,r,n){let l=i(e.map(e=>({...e,fromMs:Math.max(t,e.fromMs),toMs:Math.min(r,e.toMs)})).filter(e=>e.toMs>e.fromMs).sort((e,t)=>e.fromMs-t.fromMs||e.toMs-t.toMs));return void 0===n?l:function(e,t,r,n){if(0===e.length)return[];let l=[...new Set(t.filter(s).map(e=>e.t).filter(e=>Number.isFinite(e)))].sort((e,t)=>e-t),o=[];for(let t of e){let e=Math.max(r,Math.min(n,t.fromMs)),s=Math.max(r,Math.min(n,t.toMs));if(s<=e)continue;let i=Math.max(r,function(e,t){let r=0,s=e.length;for(;r<s;){let n=r+s>>>1;e[n]<=t?r=n+1:s=n}return r>0?e[r-1]:null}(l,e)??e),a=Math.min(n,function(e,t){let r=0,s=e.length;for(;r<s;){let n=r+s>>>1;e[n]<t?r=n+1:s=n}return r<e.length?e[r]:null}(l,s)??s);a<=i||o.push({...t,fromMs:i,toMs:a})}return o.sort((e,t)=>e.fromMs-t.fromMs||e.toMs-t.toMs),i(o)}(l,n,t,r)}function o(e,t,r){return Math.max(e,"1h"===t?36e5:"1m"===t?6e4:100,r??0)}function a(e,t){let r=[...e].sort((e,t)=>e.t-t.t),n=l(t.gaps,t.fromMs,t.toMs),i=Math.max(1,t.stepMs),o=[],a=[],u=()=>{a.length>0&&o.push(a),a=[]};for(let e of r){if(!s(e)){u();continue}let t=a.at(-1);if(void 0!==t){let r=!e.merged&&!t.merged&&(e.t<t.t||e.t-t.t>1.5*i),s=!0===e.gapBefore||function(e,t,r){return r.some(r=>r.toMs>e&&r.fromMs<t)}(t.t,e.t,n);(r||s)&&u()}a.push(e)}return u(),o}function u(e,t,r){if(t<=0)return[];let i=[...e].sort((e,t)=>e.t-t.t);if(i.length<=t)return i.map(e=>({...e}));let l=Math.max(2,Math.ceil(i.length/t)),o=Math.max(1,r),a=[],u=[],c=!1,d=null,m=()=>{if(0===u.length)return;let e=null,t=null,r=0,s=0;for(let i of u){let l=n(i.min),o=n(i.max);null!==l&&(null===e||l<e)&&(e=l),null!==o&&(null===t||o>t)&&(t=o);let a=n(i.avg);null!==a&&(r+=a,s+=1)}a.push({t:u[0].t,min:e,max:t,avg:s>0?r/s:null,...u.length>1?{merged:!0}:{},...c?{gapBefore:!0}:{}}),u=[],c=!1};for(let e of i){if(!s(e)){m(),a.push({...e}),d=null;continue}let t=null!==d&&e.t>=d.t&&e.t-d.t<=1.5*o;u.length>0&&(!t||u.length>=l)&&m(),0===u.length&&(c=null!==d&&!t),u.push(e),d=e}return m(),a}function c(e){let t=null,r=null,s=0,i=0,l=null,o=null,a=null,u=null;for(let c of e){if(null===c.avg)continue;(null===a||c.t<a)&&(a=c.t),(null===u||c.t>u)&&(u=c.t);let e=n(c.min),d=n(c.max);null!==e&&(null===t||e<t)&&(t=e),null!==d&&(null===r||d>r)&&(r=d),null!==c.avg&&Number.isFinite(c.avg)&&(s+=c.avg,i+=1,l=c.avg,o=c.t)}return{count:i,min:t,max:r,avg:i>0?s/i:null,latest:l,latestT:o,firstT:a,lastT:u}}function d(e){if(!Number.isFinite(e)||e<=0)return 1;let t=Math.pow(10,Math.floor(Math.log10(e))),r=e/t;return(r<=1?1:r<=2?2:r<=5?5:10)*t}function m(e,t){if("percent"===e)return{min:0,max:100,ticks:[0,25,50,75,100]};let r=t.filter(e=>null!==e&&Number.isFinite(e));if(0===r.length)return{min:0,max:1,ticks:[0,1]};let s=Math.min(...r),n=Math.max(...r);if("celsius"===e){let e=Math.max(1,(n-s)*.1);s=5*Math.floor((s-e)/5),n=5*Math.ceil((n+e)/5)}else s=0,n=n>0?n:1;n<=s&&(n=s+1);let i=d((n-s)/4),l=Math.floor(s/i)*i,o=Math.ceil(n/i)*i,a=function(e,t,r=4){if(!Number.isFinite(e)||!Number.isFinite(t))return[0,1];if(t<=e)return[e];let s=d((t-e)/Math.max(1,r)),n=Math.ceil(e/s)*s,i=[];for(let e=n;e<=t+.001*s&&i.length<20;e+=s)i.push(Number(e.toPrecision(12)));return i.length>0?i:[e,t]}(l,o,4);return{min:l,max:o,ticks:a}}function f(e,t,r=4){let s=Math.max(2,Math.floor(r)),n=Math.max(0,t-e);return Array.from({length:s},(t,r)=>e+n*r/(s-1))}r.d(t,{$z:()=>l,Cf:()=>f,SG:()=>u,T6:()=>c,jl:()=>o,kk:()=>m,o:()=>a})},9429:(e,t,r)=>{r.d(t,{n:()=>l});var s=r(2115),n=r(5078);async function i(e){let t=null;try{let r=await e.json();if(null!==r&&"object"==typeof r&&"error"in r){let e=r.error;"string"==typeof e&&(t=e)}}catch{}switch(e.status){case 401:return{kind:"unauthorized",message:"Your session is no longer accepted."};case 403:return{kind:"denied",message:t??"You do not have access to this machine's history."};case 404:return{kind:"missing",message:t??"This machine is not available to the hub."};case 429:return{kind:"rate-limited",message:t??"The hub is limiting history requests."};case 503:return{kind:"unavailable",message:t??"History is temporarily unavailable."};default:return{kind:"invalid",message:t??`The hub could not answer this history query (${e.status}).`}}}function l({machineId:e,metricsKey:t,coreIdsKey:r,range:o,enabled:a=!0,autoRefresh:u=!0,refreshNonce:c=0}){let[d,m]=(0,s.useState)({machineId:e,metricsKey:t,coreIdsKey:r,range:o}),f=d.machineId===e&&d.range===o;(0,s.useEffect)(()=>{if(!f)return void m({machineId:e,metricsKey:t,coreIdsKey:r,range:o});let s=window.setTimeout(()=>m({machineId:e,metricsKey:t,coreIdsKey:r,range:o}),300);return()=>window.clearTimeout(s)},[e,t,r,o,f]);let p=f?d:{machineId:e,metricsKey:t,coreIdsKey:r,range:o},h=p.metricsKey,g=p.coreIdsKey,y=`${e}|${h}|${o}|${g??"all"}`,[b,x]=(0,s.useState)(null),[v,M]=(0,s.useState)(null),[k,w]=(0,s.useState)(null),$=(0,s.useRef)(c);return(0,s.useEffect)(()=>{let t=$.current!==c;if($.current=c,!a||!e||!h)return;let r=!0,s=!1,l=!1,d=-1/0,m=new AbortController,f=(0,n.zp)(o),p=async(t=!1)=>{if(r&&!s&&!l){s=!0,d=Date.now(),w({key:y,manual:t});try{let t=await fetch((0,n.Vw)(e,h.split(","),o,Date.now(),600,void 0===g?void 0:g.split(",").filter(Boolean)),{signal:"function"!=typeof AbortSignal.any||"function"!=typeof AbortSignal.timeout?m.signal:AbortSignal.any([m.signal,AbortSignal.timeout(2e4)]),cache:"no-store",headers:{Accept:"application/json"}});if(!t.ok)throw await i(t);let s=(0,n.bf)(await t.json());if(null===s||s.machineId!==e)throw{kind:"invalid",message:"Unexpected history response."};if(!r)return;x({key:y,range:o,result:s,loadedAt:Date.now()}),M(null)}catch(t){if(!r||m.signal.aborted)return;let e=null!==t&&"object"==typeof t&&"kind"in t&&"message"in t&&"string"==typeof t.message?t:{kind:"network",message:"Could not reach the hub. Try again."};l="rate-limited"===e.kind,["unauthorized","denied","missing"].includes(e.kind)&&x(null),M({key:y,error:e})}finally{s=!1,r&&w(null)}}},b=()=>{"visible"!==document.visibilityState||Date.now()-d<f||p()};p(t);let v=u?window.setInterval(b,f):null;return u&&document.addEventListener("visibilitychange",b),()=>{r=!1,m.abort(),null!==v&&window.clearInterval(v),document.removeEventListener("visibilitychange",b)}},[a,e,h,g,o,y,u,c]),{data:a&&b?.result.machineId===e&&b.range===o?b:null,error:a&&v?.key===y?v.error:null,loading:a&&k?.key===y,manualRefreshing:a&&k?.key===y&&k.manual}}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[939],{592:(e,t,r)=>{r.d(t,{U8:()=>n,Q_:()=>l,FZ:()=>T});let n=1024,i=Date.parse("2000-01-01T00:00:00Z"),s=Date.parse("2200-01-01T00:00:00Z"),a=["metrics","inventory","processes"],o=["cpu","memory","swap","gpus","disks","network"],u=["outbox-age","outbox-bytes","disk-budget","write-failure","rejected"];function l(e){let t=b(e,"collector message");switch(t.type){case"hello":{k(t,["type","collectorId","runId","bootId","hostname","capabilities","expectedIntervalMs"],"hello");let e=$(t.capabilities,"hello.capabilities",1,a.length).map(e=>A(e,a,"hello.capabilities"));if(new Set(e).size!==e.length||!e.includes("metrics"))throw Error("invalid hello: capabilities must be unique and include metrics");return{type:"hello",collectorId:E(t.collectorId,"collectorId"),runId:E(t.runId,"runId"),bootId:B(t.bootId,"bootId",0,128),hostname:B(t.hostname,"hostname",0,255),capabilities:e,expectedIntervalMs:P(t.expectedIntervalMs,"expectedIntervalMs",100,72e5)}}case"samples":{k(t,["type","mode","records"],"samples");let e=A(t.mode,["live","replay"],"samples.mode"),r=$(t.records,"samples.records",1,32).map((e,t)=>d(e,`records[${t}]`)),n=new Set;for(let e of r){let t=`${e.runId}\0${e.sequence}`;if(n.has(t))throw Error("invalid samples: duplicate record in batch");n.add(t)}return{type:"samples",mode:e,records:r}}case"inventory":return k(t,["type","capturedAt","inventory"],"inventory"),{type:"inventory",capturedAt:x(t.capturedAt,"capturedAt"),inventory:c(t.inventory)};case"status":return k(t,["type","capturedAt","delivery","failures"],"status"),{type:"status",capturedAt:x(t.capturedAt,"capturedAt"),delivery:function(e){let t=b(e,"delivery");if(k(t,["pendingRecords","pendingBytes","oldestPendingCapturedAt","inFlightRecords","droppedRecords","replaying","lastAckAt"],"delivery"),"boolean"!=typeof t.replaying)throw Error("invalid delivery: replaying");let r=(e,t)=>P(e,t,0,Number.MAX_SAFE_INTEGER);return{pendingRecords:r(t.pendingRecords,"pendingRecords"),pendingBytes:r(t.pendingBytes,"pendingBytes"),oldestPendingCapturedAt:v(t.oldestPendingCapturedAt,e=>x(e,"oldestPendingCapturedAt")),inFlightRecords:r(t.inFlightRecords,"inFlightRecords"),droppedRecords:r(t.droppedRecords,"droppedRecords"),replaying:t.replaying,lastAckAt:v(t.lastAckAt,e=>x(e,"lastAckAt"))}}(t.delivery),failures:$(t.failures,"failures",0,32).map(e=>{let t=b(e,"failure");return k(t,["metric","resourceId","reason"],"failure"),{metric:B(t.metric,"metric",1,64),resourceId:null===t.resourceId?null:I(t.resourceId),reason:B(t.reason,"reason",0,256)}})};case"detail.result":return k(t,["type","subscriptionId","capturedAt","snapshot"],"detail.result"),{type:"detail.result",subscriptionId:E(t.subscriptionId,"subscriptionId"),capturedAt:x(t.capturedAt,"capturedAt"),snapshot:function(e){let t=b(e,"process snapshot");if(k(t,["totalProcesses","truncated","inaccessible","processes"],"process snapshot"),"boolean"!=typeof t.truncated)throw Error("invalid process snapshot: truncated");let r=(e,t,r)=>v(e,e=>S(e,t,0,r));return{totalProcesses:P(t.totalProcesses,"totalProcesses",0,1e7),truncated:t.truncated,inaccessible:P(t.inaccessible,"inaccessible",0,1e7),processes:$(t.processes,"processes",0,6e3).map(e=>{let t=b(e,"process");k(t,["pid","ppid","startTicks","name","user","state","cpuPercent","memoryRssBytes","gpuMemoryBytes","ioReadBytesPerSec","ioWriteBytesPerSec","threads","unit"],"process",["command"]);let i={pid:P(t.pid,"pid",0,0x80000000),ppid:P(t.ppid,"ppid",0,0x80000000),startTicks:P(t.startTicks,"startTicks",0,Number.MAX_SAFE_INTEGER),name:B(t.name,"name",0,256),user:v(t.user,e=>B(e,"user",0,64)),state:B(t.state,"state",0,16),cpuPercent:r(t.cpuPercent,"cpuPercent",100*n),memoryRssBytes:v(t.memoryRssBytes,e=>P(e,"memoryRssBytes",0,Number.MAX_SAFE_INTEGER)),gpuMemoryBytes:v(t.gpuMemoryBytes,e=>P(e,"gpuMemoryBytes",0,Number.MAX_SAFE_INTEGER)),ioReadBytesPerSec:r(t.ioReadBytesPerSec,"ioReadBytesPerSec",1e13),ioWriteBytesPerSec:r(t.ioWriteBytesPerSec,"ioWriteBytesPerSec",1e13),threads:v(t.threads,e=>P(e,"threads",0,1e7)),unit:v(t.unit,e=>B(e,"unit",1,256))};return w(t,"command")&&(i.command=B(t.command,"command",0,4096)),i})}}(t.snapshot)};case"detail.ended":return k(t,["type","subscriptionId","reason"],"detail.ended"),{type:"detail.ended",subscriptionId:E(t.subscriptionId,"subscriptionId"),reason:A(t.reason,["expired","cancelled","withheld","unsupported","busy","failed"],"detail.ended.reason")};default:throw Error(`invalid collector message: unsupported type ${M(t.type)}`)}}function d(e,t="record"){let r=b(e,t);k(r,["collectorId","runId","bootId","sequence","capturedAt","kind","payload"],t);let i={collectorId:E(r.collectorId,"collectorId"),runId:E(r.runId,"runId"),bootId:B(r.bootId,"bootId",0,128),sequence:P(r.sequence,"sequence",0,Number.MAX_SAFE_INTEGER),capturedAt:x(r.capturedAt,"capturedAt")};if("metrics"===r.kind){let e;return{...i,kind:"metrics",payload:(k(e=b(r.payload,"metrics payload"),[...o],"metrics payload"),{cpu:y(e.cpu,"cpu",e=>{k(e,["status","usagePercent","perCore"],"cpu",["temperatureC","powerWatts","iowaitPercent","pressureSomePercent"]);let t={status:"ok",usagePercent:S(e.usagePercent,"usagePercent",0,100),perCore:$(e.perCore,"perCore",0,n).map(e=>null===e?null:S(e,"perCore",0,100))},r=g(e,"temperatureC",e=>S(e,"temperatureC",-50,200));void 0!==r&&(t.temperatureC=r);let i=g(e,"powerWatts",e=>S(e,"powerWatts",0,1e4));void 0!==i&&(t.powerWatts=i);let s=g(e,"iowaitPercent",e=>S(e,"iowaitPercent",0,100));void 0!==s&&(t.iowaitPercent=s);let a=g(e,"pressureSomePercent",e=>S(e,"pressureSomePercent",0,100));return void 0!==a&&(t.pressureSomePercent=a),t}),memory:y(e.memory,"memory",m),swap:y(e.swap,"swap",p),gpus:y(e.gpus,"gpus",e=>(k(e,["status","devices"],"gpus"),{status:"ok",devices:h($(e.devices,"gpus.devices",0,16).map(e=>f(e,"gpu",(e,t)=>{k(e,["id","status","utilizationPercent","memoryUsedBytes","memoryTotalBytes","temperatureC","powerWatts"],"gpu");let r=v(e.memoryUsedBytes,e=>P(e,"memoryUsedBytes",0,Number.MAX_SAFE_INTEGER)),n=v(e.memoryTotalBytes,e=>P(e,"memoryTotalBytes",0,Number.MAX_SAFE_INTEGER));if(null!==r&&null!==n&&r>n)throw Error("invalid gpu: memoryUsedBytes exceeds total");return{id:t,status:"ok",utilizationPercent:v(e.utilizationPercent,e=>S(e,"utilizationPercent",0,100)),memoryUsedBytes:r,memoryTotalBytes:n,temperatureC:v(e.temperatureC,e=>S(e,"temperatureC",-50,200)),powerWatts:v(e.powerWatts,e=>S(e,"powerWatts",0,1e4))}})))})),disks:y(e.disks,"disks",e=>{k(e,["status","filesystems","devices"],"disks",["pressureSomePercent","pressureFullPercent"]);let t={status:"ok",filesystems:h($(e.filesystems,"filesystems",0,64).map(e=>f(e,"filesystem",(e,t)=>{k(e,["id","status","usedBytes","totalBytes"],"filesystem",["inodesUsed","inodesTotal"]);let r=p({status:"ok",usedBytes:e.usedBytes,totalBytes:e.totalBytes}),n={id:t,status:"ok",usedBytes:r.usedBytes,totalBytes:r.totalBytes},i=g(e,"inodesUsed",e=>P(e,"inodesUsed",0,Number.MAX_SAFE_INTEGER));void 0!==i&&(n.inodesUsed=i);let s=g(e,"inodesTotal",e=>P(e,"inodesTotal",0,Number.MAX_SAFE_INTEGER));if(void 0!==s&&(n.inodesTotal=s),null!=i&&null!=s&&i>s)throw Error("invalid filesystem: inodesUsed exceeds inodesTotal");return n}))),devices:h($(e.devices,"disk devices",0,64).map(e=>f(e,"disk",(e,t)=>{k(e,["id","status","readBytesPerSec","writeBytesPerSec"],"disk",["readLatencyMs","writeLatencyMs","ioUtilizationPercent"]);let r={id:t,status:"ok",readBytesPerSec:S(e.readBytesPerSec,"readBytesPerSec",0,1e13),writeBytesPerSec:S(e.writeBytesPerSec,"writeBytesPerSec",0,1e13)},n=g(e,"readLatencyMs",e=>S(e,"readLatencyMs",0,864e5));void 0!==n&&(r.readLatencyMs=n);let i=g(e,"writeLatencyMs",e=>S(e,"writeLatencyMs",0,864e5));void 0!==i&&(r.writeLatencyMs=i);let s=g(e,"ioUtilizationPercent",e=>S(e,"ioUtilizationPercent",0,100));return void 0!==s&&(r.ioUtilizationPercent=s),r})))},r=g(e,"pressureSomePercent",e=>S(e,"pressureSomePercent",0,100));void 0!==r&&(t.pressureSomePercent=r);let n=g(e,"pressureFullPercent",e=>S(e,"pressureFullPercent",0,100));return void 0!==n&&(t.pressureFullPercent=n),t}),network:y(e.network,"network",e=>(k(e,["status","interfaces"],"network"),{status:"ok",interfaces:h($(e.interfaces,"interfaces",0,64).map(e=>f(e,"interface",(e,t)=>(k(e,["id","status","rxBytesPerSec","txBytesPerSec"],"interface"),{id:t,status:"ok",rxBytesPerSec:S(e.rxBytesPerSec,"rxBytesPerSec",0,1e13),txBytesPerSec:S(e.txBytesPerSec,"txBytesPerSec",0,1e13)}))))}))})}}if("gap"===r.kind){let e=b(r.payload,`${t}.payload`);k(e,["fromCapturedAt","toCapturedAt","droppedRecords","reason"],"gap payload");let n=x(e.fromCapturedAt,"fromCapturedAt"),s=x(e.toCapturedAt,"toCapturedAt");if(Date.parse(n)>Date.parse(s))throw Error("invalid gap: fromCapturedAt after toCapturedAt");return{...i,kind:"gap",payload:{fromCapturedAt:n,toCapturedAt:s,droppedRecords:P(e.droppedRecords,"droppedRecords",1,Number.MAX_SAFE_INTEGER),reason:A(e.reason,u,"gap.reason")}}}throw Error(`invalid ${t}: unsupported kind ${M(r.kind)}`)}function c(e){let t=b(e,"inventory");k(t,["os","cpu","memory","gpus","filesystems","disks","network","capabilities"],"inventory");let r=b(t.os,"inventory.os");k(r,["platform","release","distro","arch"],"inventory.os");let i=b(t.cpu,"inventory.cpu");k(i,["model","logicalCores"],"inventory.cpu");let s=b(t.memory,"inventory.memory");k(s,["totalBytes","swapTotalBytes"],"inventory.memory");let a=b(t.capabilities,"inventory.capabilities"),u=[...o,"processes"];k(a,[...u],"inventory.capabilities");let l={};for(let e of u){let t=b(a[e],`capability ${e}`);k(t,["status"],`capability ${e}`,["reason"]);let r={status:A(t.status,["supported","unsupported","withheld"],`capability ${e}`)};w(t,"reason")&&(r.reason=B(t.reason,"reason",0,256)),l[e]=r}let d=(e,t)=>v(e,e=>P(e,t,0,Number.MAX_SAFE_INTEGER));return{os:{platform:B(r.platform,"platform",0,64),release:B(r.release,"release",0,256),distro:v(r.distro,e=>B(e,"distro",0,256)),arch:B(r.arch,"arch",0,64)},cpu:{model:v(i.model,e=>B(e,"model",0,256)),logicalCores:P(i.logicalCores,"logicalCores",0,n)},memory:{totalBytes:d(s.totalBytes,"totalBytes"),swapTotalBytes:d(s.swapTotalBytes,"swapTotalBytes")},gpus:h($(t.gpus,"inventory.gpus",0,16).map(e=>{let t=b(e,"gpu inventory");k(t,["id","name","vendor","pciBusId","telemetry","memoryTotalBytes"],"gpu inventory",["reason"]);let r={id:I(t.id),name:B(t.name,"name",0,256),vendor:A(t.vendor,["nvidia","amd","intel","aspeed","other"],"vendor"),pciBusId:v(t.pciBusId,e=>B(e,"pciBusId",1,64)),telemetry:A(t.telemetry,["supported","unsupported"],"telemetry"),memoryTotalBytes:d(t.memoryTotalBytes,"memoryTotalBytes")};return w(t,"reason")&&(r.reason=B(t.reason,"reason",0,256)),r})),filesystems:h($(t.filesystems,"inventory.filesystems",0,64).map(e=>{let t=b(e,"filesystem inventory");return k(t,["id","mountPoint","device","fsType","totalBytes"],"filesystem inventory"),{id:I(t.id),mountPoint:B(t.mountPoint,"mountPoint",1,256),device:B(t.device,"device",0,256),fsType:B(t.fsType,"fsType",0,64),totalBytes:d(t.totalBytes,"totalBytes")}})),disks:h($(t.disks,"inventory.disks",0,64).map(e=>{let t=b(e,"disk inventory");if(k(t,["id","name","model","rotational","sizeBytes"],"disk inventory"),null!==t.rotational&&"boolean"!=typeof t.rotational)throw Error("invalid disk inventory: rotational");return{id:I(t.id),name:B(t.name,"name",1,64),model:v(t.model,e=>B(e,"model",0,256)),rotational:t.rotational,sizeBytes:d(t.sizeBytes,"sizeBytes")}})),network:h($(t.network,"inventory.network",0,64).map(e=>{let t=b(e,"interface inventory");if(k(t,["id","name","mac","addresses","virtual","state","speedMbps"],"interface inventory"),"boolean"!=typeof t.virtual)throw Error("invalid interface inventory: virtual");return{id:I(t.id),name:B(t.name,"name",1,64),mac:v(t.mac,e=>B(e,"mac",1,64)),addresses:$(t.addresses,"addresses",0,32).map(e=>{let t=b(e,"address");k(t,["family","address","prefix"],"address");let r=A(t.family,["ipv4","ipv6"],"family");return{family:r,address:B(t.address,"address",2,64),prefix:P(t.prefix,"prefix",0,"ipv4"===r?32:128)}}),virtual:t.virtual,state:A(t.state,["up","down","unknown"],"state"),speedMbps:v(t.speedMbps,e=>P(e,"speedMbps",0,1e7))}})),capabilities:l}}function p(e){k(e,["status","usedBytes","totalBytes"],"usage");let t=P(e.totalBytes,"totalBytes",0,Number.MAX_SAFE_INTEGER),r=P(e.usedBytes,"usedBytes",0,Number.MAX_SAFE_INTEGER);if(r>t)throw Error("invalid usage: usedBytes exceeds totalBytes");return{status:"ok",usedBytes:r,totalBytes:t}}function m(e){k(e,["status","usedBytes","totalBytes"],"memory",["pressureSomePercent","pressureFullPercent"]);let t=P(e.totalBytes,"totalBytes",0,Number.MAX_SAFE_INTEGER),r=P(e.usedBytes,"usedBytes",0,Number.MAX_SAFE_INTEGER);if(r>t)throw Error("invalid memory: usedBytes exceeds totalBytes");let n={status:"ok",usedBytes:r,totalBytes:t},i=g(e,"pressureSomePercent",e=>S(e,"pressureSomePercent",0,100));void 0!==i&&(n.pressureSomePercent=i);let s=g(e,"pressureFullPercent",e=>S(e,"pressureFullPercent",0,100));return void 0!==s&&(n.pressureFullPercent=s),n}function y(e,t,r){let n=b(e,t);if("ok"===n.status)return r(n);if("unavailable"===n.status)return k(n,["status","reason"],t),{status:"unavailable",reason:B(n.reason,"reason",0,256)};throw Error(`invalid ${t}: unsupported status ${M(n.status)}`)}function f(e,t,r){let n=b(e,t),i=I(n.id);if("ok"===n.status)return r(n,i);if("unavailable"===n.status)return k(n,["id","status","reason"],t),{id:i,status:"unavailable",reason:B(n.reason,"reason",0,256)};throw Error(`invalid ${t}: unsupported status ${M(n.status)}`)}function h(e){let t=new Set;for(let r of e){if(t.has(r.id))throw Error(`invalid resource list: duplicate id ${M(r.id)}`);t.add(r.id)}return e}function v(e,t){return null===e?null:t(e)}function g(e,t,r){if(w(e,t))return v(e[t],r)}function b(e,t){if(null===e||"object"!=typeof e||Array.isArray(e))throw Error(`invalid ${t}: expected object, got ${M(e)}`);return e}function k(e,t,r,n=[]){let i=new Set([...t,...n]);for(let t of Object.keys(e))if(!i.has(t))throw Error(`invalid ${r}: unexpected field "${t}"`);for(let n of t)if(void 0===e[n])throw Error(`invalid ${r}: missing field "${n}"`);for(let t of n)if(w(e,t)&&void 0===e[t])throw Error(`invalid ${r}: ${t} must not be undefined`)}function w(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function $(e,t,r,n){if(!Array.isArray(e))throw Error(`invalid ${t}: expected array`);if(e.length<r||e.length>n)throw Error(`invalid ${t}: length ${e.length} outside ${r}..${n}`);return e}function A(e,t,r){if("string"!=typeof e||!t.includes(e))throw Error(`invalid ${r}: unexpected value ${M(e)}`);return e}function B(e,t,r,n){if("string"!=typeof e)throw Error(`invalid ${t}: expected string, got ${M(e)}`);if(e.length<r||e.length>n)throw Error(`invalid ${t}: length ${e.length} outside ${r}..${n}`);return e}function E(e,t){return B(e,t,1,128)}function I(e){return B(e,"resource id",1,256)}function P(e,t,r,n){if("number"!=typeof e||!Number.isSafeInteger(e))throw Error(`invalid ${t}: expected safe integer, got ${M(e)}`);if(e<r||e>n)throw Error(`invalid ${t}: ${e} outside ${r}..${n}`);return e}function S(e,t,r,n){if("number"!=typeof e||!Number.isFinite(e))throw Error(`invalid ${t}: expected finite number, got ${M(e)}`);if(e<r||e>n)throw Error(`invalid ${t}: ${e} outside ${r}..${n}`);return e}function x(e,t){let r=B(e,t,1,64),n=Date.parse(r);if(!Number.isFinite(n)||n<i||n>s)throw Error(`invalid ${t}: not a parseable timestamp`);return r}function M(e){try{let t=JSON.stringify(e);if("string"==typeof t)return t.length<=80?t:`${t.slice(0,77)}...`}catch{}return String(e)}function T(e){let t=C(e,"hub snapshot");_(t,["hubRunId","machines"],"hub snapshot");let r=j(t.hubRunId,"hubRunId","hub snapshot");if(!Array.isArray(t.machines))throw Error("invalid snapshot machines");let n=new Set;return{hubRunId:r,machines:t.machines.map(e=>{let t=C(e,"machine");_(t,["machineId","collectorId","hostname","connected","lastReceivedAt"],"machine",["expectedIntervalMs","metrics","inventory","delivery","displayName","tags"]);let r=j(t.machineId,"machineId","machine");if(n.has(r))throw Error("duplicate snapshot machine");n.add(r);let i=j(t.collectorId,"collectorId","machine"),s=z(t.hostname,"hostname","machine",0,N);if("boolean"!=typeof t.connected)throw Error("invalid machine connection state");let a=null===t.lastReceivedAt?null:D(t.lastReceivedAt,"lastReceivedAt","machine"),o={},u=L(t,"expectedIntervalMs")?function(e,t,r){if(null===e)return null;if(void 0===e)throw Error(`invalid ${r}: ${t} must not be undefined`);var n=e,i=t,s=r;if("number"!=typeof n||!Number.isSafeInteger(n))throw Error(`invalid ${s}: ${i} must be a safe integer, got ${G(n)}`);if(n<100||n>72e5)throw Error(`invalid ${s}: ${i} ${n} outside ${100}..${72e5}`);return n}(t.expectedIntervalMs,"expectedIntervalMs","machine"):void 0;if(L(t,"metrics")){let{receivedAt:e,...r}=C(t.metrics,"received metrics"),n=d(r);if("metrics"!==n.kind||n.collectorId!==i)throw Error("conflicting machine metrics");if(o.metrics={...n,receivedAt:D(e,"receivedAt","metrics")},o.metrics.receivedAt!==a)throw Error("conflicting metrics receipt time")}if(L(t,"inventory")&&(o.inventory=c(t.inventory)),L(t,"delivery")){let e=l(t.delivery);if("status"!==e.type)throw Error("invalid delivery status");o.delivery=e}if(L(t,"displayName")&&(o.displayName=null===t.displayName?null:z(t.displayName,"displayName","machine",0,128)),L(t,"tags")){if(!Array.isArray(t.tags)||t.tags.length>32)throw Error("invalid machine tags");o.tags=t.tags.map(e=>z(e,"tag","machine",1,64))}return{machineId:r,collectorId:i,hostname:s,connected:t.connected,lastReceivedAt:a,...void 0===u?{}:{expectedIntervalMs:u},...o}})}}let N=255,R=Date.parse("2000-01-01T00:00:00Z"),F=Date.parse("2200-01-01T00:00:00Z");function C(e,t){if(null===e||"object"!=typeof e||Array.isArray(e))throw Error(`invalid ${t}: expected object, got ${G(e)}`);return e}function _(e,t,r,n=[]){let i=new Set([...t,...n]);for(let t of Object.keys(e))if(!i.has(t))throw Error(`invalid ${r}: unexpected field "${t}"`);for(let n of t)if(void 0===e[n])throw Error(`invalid ${r}: missing field "${n}"`);for(let t of n)if(L(e,t)&&void 0===e[t])throw Error(`invalid ${r}: ${t} must not be undefined`)}function L(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function j(e,t,r){return z(e,t,r,1,128)}function z(e,t,r,n,i){if("string"!=typeof e)throw Error(`invalid ${r}: ${t} must be a string, got ${G(e)}`);if(e.length<n||e.length>i)throw Error(`invalid ${r}: ${t} length ${e.length} outside ${n}..${i}`);return e}function D(e,t,r){let n=z(e,t,r,1,64),i=Date.parse(n);if(!Number.isFinite(i)||i<R||i>F)throw Error(`invalid ${r}: ${t} is not a parseable timestamp`);return n}function G(e){try{let t=JSON.stringify(e);if("string"==typeof t)return t.length<=80?t:`${t.slice(0,77)}...`}catch{}return String(e)}},4334:(e,t,r)=>{r.d(t,{K:()=>o,g:()=>s});var n=r(5887),i=r(7586);function s(e,t){let r=new Map;for(let s of t.machines){let a=s.metrics;if(!a)continue;let o=`${t.hubRunId}\0${a.collectorId}\0${a.runId}\0${a.sequence}`,u=e.get(s.machineId)??[],l=u.at(-1);if(l?.sampleId===o){r.set(s.machineId,u);continue}let d=o.slice(0,o.lastIndexOf("\0")+1),c=l?.sampleId.startsWith(d)?u:[],p=a.payload.memory;r.set(s.machineId,[...c,{sampleId:o,receivedAtLocal:Date.parse(a.receivedAt),cpuPercent:"ok"===a.payload.cpu.status?a.payload.cpu.usagePercent:null,memoryPercent:"ok"===p.status&&p.totalBytes>0?100*p.usedBytes/p.totalBytes:null,gapThresholdMs:(0,i.Cj)(s.expectedIntervalMs)}].slice(-n.yY))}return r}function a(e){return"number"==typeof e.gapThresholdMs&&Number.isFinite(e.gapThresholdMs)&&e.gapThresholdMs>0?e.gapThresholdMs:n.vz}function o(e,t=600,r=140){let i;if(e.length<2)return null;let s=e[0].receivedAtLocal,u=Math.max(1e3,e.at(-1).receivedAtLocal-s),l="";for(let o of e){if(null===o.cpuPercent){i=void 0;continue}let e=4+(o.receivedAtLocal-s)/u*(t-8),d=r-4-o.cpuPercent/100*(r-8),c=i?Math.min(a(i),a(o)):n.vz,p=i&&o.receivedAtLocal>=i.receivedAtLocal&&o.receivedAtLocal-i.receivedAtLocal<c;l+=`${p?"L":"M"}${e.toFixed(2)},${d.toFixed(2)} `,i=o}return l.trim()||null}},5887:(e,t,r)=>{r.d(t,{mq:()=>i,vz:()=>n,yY:()=>s});let n=15e3,i=9e4,s=180},7586:(e,t,r)=>{r.d(t,{$:()=>s,A4:()=>d,Cj:()=>i,F2:()=>m,L_:()=>p,fv:()=>c,l9:()=>u,nV:()=>l,vj:()=>a,z3:()=>o});var n=r(5887);function i(e){return null==e||"number"!=typeof e||!Number.isFinite(e)||e<=0?n.vz:Math.max(n.vz,3*e)}function s(e){if(null==e||!Number.isFinite(e)||e<0)return"—";if(e<6e4){let t=e/1e3;return Number.isInteger(t)?`${t} s`:`${t.toFixed(1)} s`}if(e<36e5){let t=e/6e4;return Number.isInteger(t)?`${t} min`:`${t.toFixed(1)} min`}let t=e/36e5;return Number.isInteger(t)?`${t} h`:`${t.toFixed(1)} h`}function a(e,t,r=i(e.expectedIntervalMs)){return function(e,t,r=n.vz){if(null===e)return"unknown";let i=Date.parse(e);return Number.isFinite(i)?t-i>=r?"stale":"live":"unknown"}(e.lastReceivedAt,t,r)}function o(e){if(null==e||!Number.isFinite(e)||e<0)return"—";let t=["B","KiB","MiB","GiB","TiB"],r=e,n=0;for(;r>=1024&&n<t.length-1;)r/=1024,n+=1;return 0===n?`${Math.round(r)} B`:`${r.toFixed(1)} ${t[n]}`}function u(e){return null!=e&&Number.isFinite(e)?`${e.toFixed(1)}%`:"—"}function l(e){if(null===e||!Number.isFinite(e))return"—";let t=Math.round(Math.max(0,e)/1e3);if(t<60)return`${t}s ago`;let r=Math.floor(t/60);if(r<60){let e=t%60;return 0===e?`${r}m ago`:`${r}m ${e}s ago`}let n=Math.floor(r/60);if(n<24){let e=r%60;return 0===e?`${n}h ago`:`${n}h ${e}m ago`}let i=Math.floor(n/24),s=n%24;return 0===s?`${i}d ago`:`${i}d ${s}h ago`}function d(e,t){if(null===e)return null;let r=Date.parse(e);return Number.isFinite(r)?t-r:null}function c(e){switch(e){case"ok":return"Live";case"degraded":return"Degraded";case"stale":return"Stale";case"disconnected":return"Disconnected";case"unseen":return"No sample yet"}}function p(e,t=n.mq){let r=e.metrics;if(!r)return{kind:"unknown"};let i=Date.parse(r.capturedAt),s=Date.parse(r.receivedAt);if(!Number.isFinite(i)||!Number.isFinite(s))return{kind:"unknown"};let a=i-s;return a>t?{kind:"ahead",skewMs:a}:a<-t?{kind:"behind",skewMs:-a}:{kind:"none"}}function m(e,t,r=i(e.expectedIntervalMs)){return{freshness:a(e,t,r),attention:function(e,t,r=i(e.expectedIntervalMs)){var n;let s=a(e,t,r);return e.metrics&&"unknown"!==s?"stale"===s?"stale":(n=e.metrics)&&("unavailable"===n.payload.cpu.status||"unavailable"===n.payload.memory.status)?"degraded":e.connected?"ok":"disconnected":"unseen"}(e,t,r),connection:e.connected?"connected":"disconnected",skew:p(e),thresholdMs:r}}},9939:(e,t,r)=>{r.d(t,{LiveProvider:()=>g,M:()=>v});var n=r(5155),i=r(2115);async function s(e){try{let t=await e.json();if(t&&"object"==typeof t&&"error"in t){let e=t.error;if("string"==typeof e)return e}}catch{}return e.statusText||null}function a(e){if(!e||"object"!=typeof e)return null;let t=e.username,r=e.csrfToken;if("string"!=typeof t||0===t.length||"string"!=typeof r||0===r.length)return null;let n=e.admin;return void 0!==n&&"boolean"!=typeof n?null:{username:t,csrfToken:r,...!0===n?{admin:!0}:{}}}async function o(){try{let e=await fetch("/api/auth/session",{cache:"no-store",signal:AbortSignal.timeout(5e3),headers:{Accept:"application/json"}});if(e.ok){try{let t=a(await e.json());if(t)return{kind:"signed-in",user:t}}catch{}return{kind:"error",detail:"unexpected session response"}}if(401===e.status)return{kind:"signed-out"};if(503===e.status)return{kind:"auth-unavailable",detail:await s(e)};return{kind:"error",detail:`unexpected status ${e.status}`}}catch{return{kind:"unreachable"}}}async function u(e,t){try{let r=await fetch("/api/auth/login",{method:"POST",cache:"no-store",signal:AbortSignal.timeout(5e3),headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({username:e,password:t})});if(r.ok){try{let e=a(await r.json());if(e)return{kind:"signed-in",user:e}}catch{}return{kind:"error",detail:"unexpected sign-in response"}}if(401===r.status)return{kind:"invalid-credentials",detail:await s(r)};if(429===r.status)return{kind:"error",detail:"too many attempts — wait a moment and try again"};if(503===r.status)return{kind:"auth-unavailable",detail:await s(r)};return{kind:"error",detail:`unexpected status ${r.status}`}}catch{return{kind:"unreachable"}}}async function l(e){try{let t=await fetch("/api/auth/logout",{method:"POST",cache:"no-store",signal:AbortSignal.timeout(5e3),headers:{"X-CSRF-Token":e,Accept:"application/json"}});if(t.ok||401===t.status)return"ok";return t.status,{kind:"error",detail:`unexpected status ${t.status}`}}catch{return"unreachable"}}async function d(e=5e3){let t=new AbortController,r=setTimeout(()=>t.abort(),e);try{let e=await fetch("/api/live",{cache:"no-store",signal:t.signal,headers:{Accept:"text/event-stream"}});if(200===e.status)return{kind:"ok"};if(401===e.status)return{kind:"unauthorized"};if(403===e.status)return{kind:"forbidden"};return{kind:"error",detail:`unexpected status ${e.status}`}}catch{return{kind:"unreachable"}}finally{clearTimeout(r);try{t.abort()}catch{}}}var c=r(592);let p=["snapshot","update","reset"];class m{source=null;lastId=null;get lastEventId(){return this.lastId}get isOpen(){return null!==this.source&&2!==this.source.readyState}start(e,t){this.close();let r=new EventSource(e);this.source=r;let n=e=>n=>{if(this.source!==r||null===this.source)return;let i=n.lastEventId;"string"==typeof i&&i.length>0&&(this.lastId=i);try{t.onSnapshot((0,c.FZ)(JSON.parse(n.data)),e,i??"")}catch{this.close(),t.onError()}};for(let e of p)r.addEventListener(e,n(e));r.onerror=()=>{this.source===r&&(this.close(),t.onError())}}close(){this.source?.close(),this.source=null}}var y=r(4334);let f=[1e3,2e3,4e3,8e3,15e3],h=(0,i.createContext)(null);function v(){let e=(0,i.useContext)(h);if(!e)throw Error("useLive must be used inside <LiveProvider>");return e}function g({children:e}){let[t,r]=(0,i.useState)({kind:"restoring"}),[s,a]=(0,i.useState)("idle"),[c,p]=(0,i.useState)(null),[v,b]=(0,i.useState)([]),[k,w]=(0,i.useState)(null),[$,A]=(0,i.useState)(null),[B,E]=(0,i.useState)(null),[I,P]=(0,i.useState)(null),[S,x]=(0,i.useState)(new Map),M=(0,i.useRef)(!0),T=(0,i.useRef)(0),N=(0,i.useRef)(null),R=(0,i.useRef)(null),F=(0,i.useRef)(0),C=(0,i.useRef)(t),_=(0,i.useRef)(0),L=(0,i.useRef)(!1),j=(0,i.useRef)(!1),z=e=>{C.current=e,r(e)},D=()=>{null!==R.current&&(clearTimeout(R.current),R.current=null)},G=()=>{_.current+=1,T.current+=1,N.current?.close(),N.current=null,D()},X=()=>{L.current=!1,b([]),x(new Map),p(null),A(null),E(null),w(null)},O=e=>{let t=C.current;("signed-in"!==t.kind||t.user.csrfToken!==e.csrfToken)&&X(),z({kind:"signed-in",user:e})},U=()=>{if("signed-in"!==C.current.kind)return;G(),a(L.current?"reconnecting":"connecting");let e=new m;N.current=e,e.start("/api/live",{onSnapshot:(t,r,n)=>{M.current&&N.current===e&&(F.current=0,L.current=!0,p(t.hubRunId),b(t.machines),w(Date.now()),A(n||null),E(r),x(e=>(0,y.g)(e,t)),a("live"))},onError:()=>{M.current&&N.current===e&&W()}})},W=async()=>{G();let e=_.current;a("reconnecting");let t=await o();if(!M.current||e!==_.current)return;if("signed-in"===t.kind)O(t.user);else if("signed-out"===t.kind){z({kind:"signed-out"}),X(),a("expired");return}else if("auth-unavailable"===t.kind){z({kind:"auth-unavailable",detail:t.detail}),X(),a("idle");return}let r=Math.min(F.current+1,f.length+1);if(F.current=r,r>f.length){a("disconnected"),Z();return}a("reconnecting"),R.current=setTimeout(()=>{q()},f[r-1])},q=async()=>{if(!M.current||j.current)return;G();let e=_.current,t=await d();if(M.current&&e===_.current){if("forbidden"===t.kind){X(),a("no-permission");return}if("unauthorized"===t.kind){let t=await o();if(!M.current||e!==_.current)return;if("signed-in"===t.kind){O(t.user),U();return}if("signed-out"===t.kind){z({kind:"signed-out"}),X(),a("expired");return}if("auth-unavailable"===t.kind){z({kind:"auth-unavailable",detail:t.detail}),X(),a("idle");return}}U()}},Z=()=>{D(),R.current=setTimeout(()=>{J()},3e4)},J=async()=>{if(!M.current||j.current)return;G();let e=_.current,t=await o();if(M.current&&e===_.current){if("signed-in"===t.kind){O(t.user),U();return}if("signed-out"===t.kind){z({kind:"signed-out"}),X(),a("expired");return}if("auth-unavailable"===t.kind){z({kind:"auth-unavailable",detail:t.detail}),X(),a("idle");return}Z()}},K=async e=>{let t=_.current,r=await o();if(M.current&&T.current===e&&t===_.current){if("signed-in"===r.kind){O(r.user),F.current=0,U();return}if("signed-out"===r.kind){z({kind:"signed-out"}),a("idle");return}if("auth-unavailable"===r.kind){z({kind:"auth-unavailable",detail:r.detail}),a("idle");return}z({kind:"restore-failed",detail:"error"===r.kind?r.detail:null}),a("idle")}},Y=async(e,t)=>{G();let r=_.current,n=await u(e,t);return M.current&&r===_.current?("signed-in"===n.kind&&M.current&&(O(n.user),P(null),F.current=0,U()),n):{kind:"error",detail:"Session request superseded. Try again."}},Q=async()=>{let e=C.current;if("signed-in"!==e.kind||j.current)return;j.current=!0,G();let t=_.current;X(),a("idle");let r=await l(e.user.csrfToken);if(j.current=!1,!M.current||t!==_.current)return;if("ok"===r){z({kind:"signed-out"}),X(),a("idle"),P("Signed out.");return}let n=await o();if(M.current&&t===_.current){if("signed-in"===n.kind){O(n.user),P("Sign out failed — try again."),U();return}if("signed-out"===n.kind){z({kind:"signed-out"}),X(),a("idle"),P(null);return}if("auth-unavailable"===n.kind){z({kind:"auth-unavailable",detail:n.detail}),a("idle");return}z({kind:"restore-failed",detail:"error"===n.kind?n.detail:null}),a("idle")}};return(0,i.useEffect)(()=>(M.current=!0,T.current+=1,K(T.current),()=>{M.current=!1,G()}),[]),(0,n.jsx)(h.Provider,{value:{session:t,phase:s,hubRunId:c,machines:v,lastReceivedLocalMs:k,lastEventId:$,lastEventKind:B,notice:I,history:S,login:Y,signOut:Q,retryConnection:()=>{if(M.current&&!j.current){if("signed-in"===C.current.kind){F.current=0,q();return}T.current+=1,K(T.current)}},dismissNotice:()=>P(null)},children:e})}}}]);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[429],{1:(e,t,s)=>{"use strict";s.d(t,{PE:()=>o,UR:()=>d,kg:()=>l,uW:()=>c});let r=/^[\u0009\u000a\u000d ]*[=+\-@]/,n=/^[\u0009\u000a\u000d]/;function i(e){if(null==e)return"";if("number"==typeof e)return Number.isFinite(e)?String(e):"";if("boolean"==typeof e)return e?"true":"false";let t=0===e.length?e:r.test(e)||n.test(e)?`'${e}`:e;return/[",\t\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function a(e){return e.map(i).join(",")}function l(e){return`${e.map(a).join("\r\n")}\r
|
|
2
|
+
`}function o(e,t,s){if("u"<typeof document)return;let r=new Blob([t],{type:s}),n=URL.createObjectURL(r),i=document.createElement("a");i.href=n,i.download=e,i.rel="noopener",i.style.display="none",document.body.append(i),i.click(),i.remove(),globalThis.setTimeout(()=>URL.revokeObjectURL(n),0)}let d="text/csv;charset=utf-8",c="application/json;charset=utf-8"},438:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(8698).A)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},2910:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(8698).A)("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]])},2939:(e,t,s)=>{"use strict";s.d(t,{HistoryView:()=>eI});var r=s(5155),n=s(8500),i=s.n(n),a=s(2115),l=s(7422),o=s(3896),d=s(1735),c=s(7029),u=s(828),m=s(4173),h=s(3440),p=s(940),x=s(802),g=s(6582),f=s(9939),b=s(8664),y=s(4567),j=s(592);let v=j.U8,N=/^core:(\d+)$/;function w(e){let t=N.exec(e);if(null===t)return null;let s=Number(t[1]);return!Number.isSafeInteger(s)||s<0||s>=j.U8?null:s}function k(e){return[...new Set(e)].sort((e,t)=>(w(e)??0)-(w(t)??0))}function M(e,t=[]){var s;let r=e?.metrics?.payload.cpu,n=new Set(!Number.isFinite(s=Math.max(e?.inventory?.cpu.logicalCores??0,r?.status==="ok"?r.perCore.length:0))?[]:Array.from({length:Math.min(j.U8,Math.max(0,Math.floor(s)))},(e,t)=>`core:${t}`));for(let e of t)"cpu.core"===e.metric&&null!==w(e.resourceId)&&n.add(e.resourceId);return k([...n])}function $(e,t){let s=new Set(t);if(null===e)return k(t).slice(0,v);let r=[];for(let t of e)if(s.has(t)&&null!==w(t)&&(r.push(t),r.length>=v))break;return k(r)}function A(e){let t=w(e);return null===t?e:`Core ${t}`}var I=s(7726);function C(e){if("string"!=typeof e||0===e.length)return null;let t=Date.parse(e);return Number.isFinite(t)?t:null}var S=s(5078),R=s(2910),P=s(9942),U=s(8698);let L=(0,U.A)("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),_=(0,U.A)("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);var B=s(6114);let T=Object.freeze([]),z=new Set(y.H9.map(e=>e.metric)),E=e=>"boolean"==typeof e?e:null,D=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e)?e.slice(0,1e3):null,F=e=>S.pI.some(t=>t.id===e)?e:null,O=e=>"string"==typeof e&&(""===e||e.split(",").every(e=>z.has(e)))?e:null,H=/^core:\d+$/,Z=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e&&H.test(e))?[...new Set(e)].slice(0,j.U8):null;function G(e,t){return(0,B.u)(`history.hidden.${t}.${e}`,T,D)}function q(e){return(0,B.u)(`history.cores.${e}`,null,Z)}let V=e=>"bytes"===e||"percent"===e?e:null;function W(e,t){return(0,B.u)(`history.units.${t}.${e}`,"bytes",V)}let K="peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:[outline-color:var(--focus)]";function Y({label:e,action:t}){return(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:e}),(0,r.jsx)("span",{"aria-hidden":!0,className:"h-px min-w-0 flex-1 bg-border"}),t]})}let J="inline-flex min-h-8 items-center gap-1.5 rounded-md border border-transparent px-2.5 text-xs transition-colors",Q=`${J} ${K} bg-selected text-foreground`,X=`${J} ${K} bg-card-strong text-muted-foreground hover:text-foreground`;function ee(e){let{machine:t,range:s,selectedMetrics:n,catalog:i,catalogError:a,gpuCards:l,hiddenCards:o,autoRefresh:d,loading:c,manualRefreshing:m,statusText:h,onRangeChange:p,onToggleMetric:x,onSetMetrics:g,onToggleCard:f,onToggleAutoRefresh:b,onRefresh:j}=e,[v,N]=(0,B.u)("history.controlsOpen",!1,E,"session"),w=new Set(n),k=y.H9.filter(({metric:e})=>(0,y.yv)(t,e).available&&(null===i||void 0!==i[e])).map(({metric:e})=>e),I=new Set(k),C=(e,t)=>{let s=new Set(n);for(let r of e)t&&I.has(r)?s.add(r):t||s.delete(r);g([...s])},U=n.some(e=>e.startsWith("gpu.")),T=w.has("cpu.core"),[z,D]=q(t?.machineId??""),F=T?M(t):[],O=$(z,F),H=new Set(O);return(0,r.jsxs)("section",{"aria-labelledby":"history-query-heading","aria-busy":c,className:"mb-5 min-w-0 rounded-xl border border-border bg-card",children:[(0,r.jsx)("h2",{id:"history-query-heading",className:"sr-only",children:"History query"}),(0,r.jsxs)("div",{className:"flex flex-wrap items-end gap-x-5 gap-y-4 p-4 md:p-5",children:[(0,r.jsxs)("fieldset",{className:"flex min-w-0 flex-col gap-1.5",children:[(0,r.jsx)("legend",{className:"mb-1.5 text-xs text-muted-foreground",children:"Time range"}),(0,r.jsx)("div",{className:"inline-flex flex-wrap rounded-lg border border-border bg-background p-0.5",children:S.pI.map(e=>{let t=s===e.id;return(0,r.jsxs)("label",{className:"cursor-pointer",children:[(0,r.jsx)("input",{type:"radio",name:"history-range",value:e.id,checked:t,onChange:()=>p(e.id),className:"peer sr-only"}),(0,r.jsxs)("span",{className:`inline-flex min-h-8 items-center rounded-md px-2.5 text-xs transition-colors ${K} ${t?"bg-selected font-medium text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[e.shortLabel,(0,r.jsxs)("span",{className:"sr-only",children:[" — ",e.label]})]})]},e.id)})})]}),(0,r.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 sm:ml-auto",children:[(0,r.jsx)("p",{className:"order-first w-full text-xs text-muted-foreground sm:order-none sm:w-auto",children:h}),(0,r.jsxs)("button",{type:"button",onClick:j,disabled:m,className:"inline-flex min-h-8 items-center gap-1.5 rounded-md border border-border bg-background px-2.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-60",children:[(0,r.jsx)(u.A,{className:`h-3.5 w-3.5 ${m?"animate-spin":""}`,"aria-hidden":!0}),"Refresh"]}),(0,r.jsxs)("button",{type:"button",onClick:b,"aria-pressed":d,className:`inline-flex min-h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs transition-colors ${d?"border-accent/40 bg-selected text-foreground":"border-border bg-background text-muted-foreground hover:bg-card-strong hover:text-foreground"}`,children:[d?(0,r.jsx)(R.A,{className:"h-3.5 w-3.5","aria-hidden":!0}):(0,r.jsx)(P.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),d?"Pause":"Resume"]})]})]}),(0,r.jsxs)("div",{className:"border-t border-border px-4 py-4 md:px-5",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsxs)("button",{type:"button","aria-expanded":v,"aria-controls":"history-metric-options",onClick:()=>N(!v),className:"inline-flex min-h-8 items-center gap-1.5 rounded-md text-sm font-medium",children:["Metrics ",(0,r.jsxs)("span",{className:"tnum text-xs font-normal text-muted-foreground",children:[w.size," selected"]}),(0,r.jsx)(L,{"aria-hidden":!0,className:`h-3.5 w-3.5 text-muted-foreground transition-transform ${v?"rotate-180":""}`})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:()=>C(k,!0),disabled:k.every(e=>w.has(e)),className:"inline-flex min-h-8 items-center rounded-md border border-border bg-background px-2.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Select all"}),(0,r.jsx)("button",{type:"button",onClick:()=>g([]),disabled:0===w.size,className:"inline-flex min-h-8 items-center rounded-md border border-border bg-background px-2.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Unselect all"})]})]}),(0,r.jsx)("div",{id:"history-metric-options",hidden:!v,children:(0,r.jsxs)("div",{className:"mt-4 min-w-0 md:col-span-2",children:[(0,r.jsx)("div",{className:"min-w-0",children:(0,r.jsx)("div",{className:"grid gap-x-6 gap-y-5 md:grid-cols-2 xl:grid-cols-3",children:y.P$.map(e=>(0,r.jsxs)("fieldset",{className:`min-w-0 ${"disk"===e.id?"xl:col-span-2":""}`,children:[(0,r.jsx)("legend",{className:"sr-only",children:e.label}),(0,r.jsx)(Y,{label:e.label,action:(0,r.jsxs)("div",{className:"flex shrink-0 gap-2",children:[(0,r.jsx)("button",{type:"button","aria-label":`Select all ${e.label} metrics`,onClick:()=>C(e.metrics,!0),disabled:e.metrics.filter(e=>I.has(e)).every(e=>w.has(e)),className:"min-h-6 rounded-sm text-xs text-muted-foreground hover:text-foreground hover:underline disabled:opacity-50",children:"All"}),(0,r.jsx)("button",{type:"button","aria-label":`Unselect all ${e.label} metrics`,onClick:()=>C(e.metrics,!1),disabled:!e.metrics.some(e=>w.has(e)),className:"min-h-6 rounded-sm text-xs text-muted-foreground hover:text-foreground hover:underline disabled:opacity-50",children:"None"})]})}),(0,r.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:e.metrics.map(e=>{var s;let n=(0,y.oB)(e);if(null===n)return null;let a=(0,y.yv)(t,e),l=null===i||void 0!==i[e],o=a.available&&l,d=w.has(e),c=(0,y.Lf)(n,0);return(0,r.jsxs)("label",{className:o?"cursor-pointer":"cursor-not-allowed",title:a.available?l?n.description:"This hub does not record this metric.":a.reason??void 0,children:[(0,r.jsx)("input",{type:"checkbox",checked:d,onChange:()=>x(e),disabled:!o&&!d,className:"peer sr-only","aria-label":n.label}),(0,r.jsxs)("span",{className:`${!o?d?`${J} ${K} bg-card-strong text-muted-foreground line-through`:`${J} text-muted-foreground opacity-50`:d?Q:X}`,children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border border-current",style:{color:c.color},children:d?(0,r.jsx)(_,{className:"h-3 w-3",strokeWidth:3}):null}),(s=n.label,({"cpu.usage":"Usage","cpu.core":"Per-core","cpu.iowait":"I/O wait","cpu.pressure":"Pressure","cpu.temperature":"Temperature","cpu.power":"Package power","memory.used":"Used bytes","memory.usage":"Usage %","swap.used":"Swap","memory.pressure.some":"Pressure (some)","memory.pressure.full":"Pressure (full)","gpu.utilization":"Utilization","gpu.memory.used":"VRAM","gpu.temperature":"Temperature","gpu.power":"Power","fs.used":"Space used","fs.usage":"Capacity %","fs.inodes.usage":"Inodes %","net.rx":"Received","net.tx":"Sent"})[e]??s)]})]},e)})}),"gpu"===e.id&&U&&l.length>0?(0,r.jsxs)("fieldset",{className:"mt-4 border-t border-border pt-3",children:[(0,r.jsx)("legend",{className:"sr-only",children:"GPU cards"}),(0,r.jsx)(Y,{label:"GPU cards"}),(0,r.jsx)("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:l.map((e,t)=>{let s=e.id,n=!o.has(s);return(0,r.jsxs)("label",{className:"cursor-pointer",children:[(0,r.jsx)("input",{type:"checkbox",checked:n,onChange:()=>f(s),className:"peer sr-only"}),(0,r.jsxs)("span",{className:n?Q:X,children:[(0,r.jsx)("span",{className:"tnum text-xs text-muted-foreground",children:t+1}),e.label]})]},e.id)})})]}):null,"cpu"===e.id&&T?(0,r.jsxs)("fieldset",{className:"mt-4 border-t border-border pt-3",children:[(0,r.jsx)("legend",{className:"sr-only",children:"CPU cores"}),(0,r.jsx)(Y,{label:`CPU cores \xb7 ${O.length} / ${F.length}`,action:(0,r.jsxs)("div",{className:"flex shrink-0 gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:()=>D(null),disabled:O.length===F.length,className:"min-h-6 rounded-sm text-xs text-muted-foreground hover:text-foreground disabled:opacity-50",children:"All cores"}),(0,r.jsx)("button",{type:"button",onClick:()=>D([]),disabled:0===O.length,"aria-label":"Unselect all CPU cores",className:"min-h-6 rounded-sm text-xs text-muted-foreground hover:text-foreground disabled:opacity-50",children:"None"})]})}),0===F.length?(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Core count unavailable."}):(0,r.jsxs)("details",{className:"mt-2",children:[(0,r.jsxs)("summary",{className:"inline-flex min-h-8 cursor-pointer items-center gap-1 rounded-md text-xs text-muted-foreground hover:text-foreground",children:["Choose cores ",(0,r.jsx)(L,{className:"h-3.5 w-3.5","aria-hidden":!0})]}),(0,r.jsx)("div",{className:"mt-2 grid max-h-48 grid-cols-3 gap-1.5 overflow-y-auto p-1",children:F.map(e=>{let t=H.has(e);return(0,r.jsxs)("label",{className:"min-w-0 cursor-pointer",children:[(0,r.jsx)("input",{type:"checkbox",checked:t,onChange:()=>{var s;return s=!t,void D(t=>{let r=$(t,F);return s?r.includes(e)?t:[...r,e]:r.filter(t=>t!==e)})},className:"peer sr-only"}),(0,r.jsxs)("span",{className:`${t?Q:X} w-full px-1.5`,children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border border-current",children:t?(0,r.jsx)(_,{className:"h-3 w-3"}):null}),A(e)]})]},e)})})]})]}):null]},e.id))})}),a?(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:a}):null]})})]})]})}var et=s(9429),es=s(7284),er=s(6304),en=s(4150);let ei="grid grid-cols-[3rem_minmax(0,1fr)_4.5rem] items-center gap-2 sm:grid-cols-[3.5rem_minmax(0,1fr)_4.5rem_3rem]";function ea({title:e,series:t,fromMs:s,toMs:n,stepMs:i,gaps:l,hiddenKeys:o,onToggleSeries:d}){let[c,u]=(0,a.useState)(!1),m=(0,a.useMemo)(()=>t.filter(e=>!o.has(e.key)),[t,o]),h=(0,en.Au)({series:m,fromMs:s,toMs:n,stepMs:i,gaps:l}),p=(0,a.useMemo)(()=>{let e=t.map(e=>{let t=Array(10).fill("");return(function(e,t,s,r=120){let n=Array(r).fill(null),i=Math.max(1,s-t);for(let a of e){if(a.t<t||a.t>s)continue;let e=a.max??a.avg;if(null===e||!Number.isFinite(e))continue;let l=Math.min(r-1,Math.floor((a.t-t)/i*r));n[l]=Math.max(n[l]??0,Math.min(100,Math.max(0,e)))}return n})(e.points,s,n,120).forEach((e,s)=>{if(null===e)return;let r=Math.min(9,Math.floor(e/10));t[r]+=`M${s},1h1v16h-1z`}),{...e,stats:(0,I.T6)(e.points),paths:t}});return c&&e.sort((e,t)=>(t.stats.max??-1)-(e.stats.max??-1)),e},[t,s,n,c]),x=p.filter(e=>!o.has(e.key)).reduce((e,t)=>null!==t.stats.max&&(e?.stats.max===null||null===e||t.stats.max>e.stats.max)?t:e,null),g=null===h.timeMs?null:(0,S.r6)(h.timeMs),f=Math.max(1,n-s),b=(0,I.$z)(l,s,n);return(0,r.jsxs)("figure",{className:"min-w-0 lg:col-span-full",onPointerLeave:h.clear,children:[(0,r.jsxs)("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsx)("h3",{className:"text-xs font-medium text-foreground",children:e}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-3 text-xs",children:[x?(0,r.jsxs)("span",{className:"tnum text-muted-foreground",children:["Peak \xb7 ",x.label," ",(0,r.jsx)("span",{className:"text-foreground",children:(0,S.dd)(x.stats.max,"percent")})]}):null,(0,r.jsx)("button",{type:"button","aria-pressed":c,onClick:()=>u(!c),className:`min-h-8 rounded-md border border-border px-2 ${c?"bg-selected text-foreground":"bg-background text-muted-foreground hover:text-foreground"}`,children:"Busiest first"})]})]}),(0,r.jsxs)("div",{className:`${ei} mb-1 min-h-4 whitespace-nowrap text-xs leading-4 text-muted-foreground`,"aria-hidden":!0,children:[(0,r.jsx)("span",{children:"Core"}),(0,r.jsx)("span",{className:"truncate",children:null!==g?(0,r.jsx)("span",{className:"tnum",children:g}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"sm:hidden",children:"History"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Peak usage over time"})]})}),(0,r.jsx)("span",{className:"hidden text-right sm:block",children:null!==g?"At cursor":"Last"}),(0,r.jsxs)("span",{className:"text-right",children:[(0,r.jsx)("span",{className:"hidden sm:inline",children:"Peak"}),(0,r.jsx)("span",{className:"sm:hidden",children:null!==g?"At cursor":"Peak"})]})]}),(0,r.jsx)("p",{id:`${h.id}-instructions`,className:"sr-only",children:"Focus a core chart and use Left and Right arrows to inspect recorded bucket peaks, Home or End to jump, and Escape to dismiss."}),(0,r.jsx)("div",{role:"region","aria-label":"Per-core history rows",tabIndex:0,className:"max-h-96 overflow-y-auto rounded-md",children:0===p.length?(0,r.jsx)("p",{className:"py-8 text-center text-xs text-muted-foreground",children:"No stored per-core readings."}):p.map(e=>{let t=!o.has(e.key),a=null===h.timeMs?null:(0,er.bO)(e.points,h.timeMs,i,l),c=a?.max??a?.avg??null;return(0,r.jsxs)("div",{className:`${ei} min-h-7 border-b border-border/40 text-xs`,children:[(0,r.jsxs)("label",{className:"inline-flex min-h-7 cursor-pointer items-center rounded-sm",children:[(0,r.jsx)("input",{type:"checkbox",checked:t,onChange:()=>d(e.key),className:"peer sr-only"}),(0,r.jsx)("span",{className:`${t?"text-foreground":"text-muted-foreground line-through"} rounded-sm peer-focus-visible:outline-2 peer-focus-visible:outline-accent`,children:e.label})]}),(0,r.jsxs)("svg",{viewBox:"0 0 120 18",preserveAspectRatio:"none",role:"img","aria-label":`${e.label}: ${null!==g?`${(0,S.dd)(c,"percent")} at ${g}`:`latest ${(0,S.dd)(e.stats.latest,"percent")}`}, peak ${(0,S.dd)(e.stats.max,"percent")}${t?"":", hidden"}`,"aria-describedby":`${h.id}-instructions`,tabIndex:t?0:void 0,onPointerMove:t?e=>{let t=e.currentTarget.getBoundingClientRect();h.inspect((0,er.yk)(e.clientX,t.left,t.width,s,n))}:void 0,onFocus:h.onFocus,onBlur:h.clear,onKeyDown:h.onKeyDown,className:`h-5 w-full cursor-crosshair rounded-sm focus-visible:outline-2 focus-visible:outline-accent ${t?"":"opacity-20"}`,children:[(0,r.jsx)("title",{children:`${e.label} \xb7 Last ${(0,S.dd)(e.stats.latest,"percent")} \xb7 Peak ${(0,S.dd)(e.stats.max,"percent")}`}),t?e.paths.map((e,t)=>e?(0,r.jsx)("path",{d:e,fill:t<5?"var(--cpu)":t<8?"var(--warn)":"var(--crit)",opacity:t<5?.15+.17*t:.65+t%5*.07},t):null):null,b.map(e=>(0,r.jsx)("rect",{x:(e.fromMs-s)/f*120,width:(e.toMs-e.fromMs)/f*120,y:0,height:18,fill:"var(--card)"},`${e.fromMs}-${e.toMs}`)),null!==h.timeMs?(0,r.jsx)("line",{"aria-hidden":!0,x1:(h.timeMs-s)/f*120,x2:(h.timeMs-s)/f*120,y1:0,y2:18,stroke:"var(--foreground)",strokeWidth:"1",vectorEffect:"non-scaling-stroke",pointerEvents:"none"}):null]}),(0,r.jsx)("span",{className:"tnum hidden text-right text-muted-foreground sm:block",children:t?(0,S.dd)(null!==h.timeMs?c:e.stats.latest,"percent"):"—"}),(0,r.jsxs)("span",{className:`tnum text-right ${t&&(e.stats.max??0)>=80?"text-crit":"text-muted-foreground"}`,children:[(0,r.jsx)("span",{className:"hidden sm:inline",children:t?(0,S.dd)(e.stats.max,"percent"):"—"}),(0,r.jsx)("span",{className:"sm:hidden",children:t?(0,S.dd)(null!==h.timeMs?c:e.stats.max,"percent"):"—"})]})]},e.key)})}),(0,r.jsxs)("div",{className:`${ei} mt-2 text-xs text-muted-foreground`,"aria-hidden":!0,children:[(0,r.jsx)("span",{}),(0,r.jsx)("div",{className:"flex justify-between gap-2 tnum",children:(0,I.Cf)(s,n,3).map((e,t)=>(0,r.jsx)("span",{className:1===t?"hidden sm:inline":"",children:(0,S.O5)(e,f)},e))}),(0,r.jsx)("span",{className:"hidden sm:block"}),(0,r.jsx)("span",{})]}),(0,r.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[[{label:"0–49%",color:"var(--cpu)"},{label:"50–79%",color:"var(--warn)"},{label:"80–100%",color:"var(--crit)"}].map(e=>(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"h-2 w-4 rounded-sm",style:{backgroundColor:e.color}}),e.label]},e.label)),(0,r.jsx)("span",{children:"No fill \xb7 no reading"})]})]})}function el(e,t){return`${e}\0${t}`}function eo(e,t,s,r,n){let i=(0,y.oB)(s);return null===i?[]:e.series.filter(e=>e.metric===s&&(void 0===r||e.resourceId===r)).map((e,r)=>{let a=(0,y.Lf)(i,r),l=n?.(e,i,r)??(0,y.bP)(t,s,e.resourceId);return{key:el(e.metric,e.resourceId),label:l,metric:e.metric,resourceId:e.resourceId,color:a.color,dash:a.dash,points:e.points}})}function ed(e){let{machine:t,result:s,selectedMetrics:n,hiddenCards:i,hiddenSeries:a,onToggleSeries:l}=e,[o]=q(t.machineId),d=$(o,M(t,s.series)),c=function(e){let{machine:t,result:s,selectedMetrics:r,hiddenCards:n,coreIds:i}=e,a=new Set(r),l=[];if(["cpu.usage","cpu.core","cpu.temperature","cpu.power","cpu.iowait","cpu.pressure"].filter(e=>a.has(e)).length>0){let e=[],r=["cpu.usage","cpu.iowait","cpu.pressure"].filter(e=>a.has(e));if(r.length>0&&e.push({key:"cpu.usage",title:r.length>1?"Usage & stalls":(0,y.oB)(r[0]).label,unit:"percent",series:r.flatMap(e=>eo(s,t,e,void 0,(t,s)=>"cpu.pressure"===e?"Pressure (some)":s.shortLabel)),emptyMessage:"No stored CPU readings in this range."}),a.has("cpu.core")){let r=(0,y.oB)("cpu.core"),n=M(t,s.series),a=i??$(null,n),l=function(e,t){let s=(0,y.oB)("cpu.core");if(null===s)return[];let r=new Map(e.series.filter(e=>"cpu.core"===e.metric).map(e=>[e.resourceId,e]));return t.flatMap((e,t)=>{let n=r.get(e),i=(0,y.Lf)(s,t);return[{key:el("cpu.core",e),label:A(e),metric:"cpu.core",resourceId:e,color:i.color,dash:i.dash,points:n?.points??[]}]})}(s,a),o=n.length>a.length;e.push({key:"cpu.core",title:o?`Per-core usage \xb7 ${a.length} of ${n.length}`:"Per-core usage",unit:r.unit,series:l,emptyMessage:0===n.length?"No stored per-core readings in this range.":0===a.length?"No CPU cores are selected. Choose cores under Metrics.":"No stored per-core readings for the selected cores in this range."})}if(a.has("cpu.temperature")){let r=(0,y.oB)("cpu.temperature");e.push({key:"cpu.temperature",title:"Temperature",unit:r.unit,series:eo(s,t,"cpu.temperature"),emptyMessage:"No stored CPU temperature readings in this range."})}if(a.has("cpu.power")){let r=(0,y.oB)("cpu.power");e.push({key:"cpu.power",title:"Package power",unit:r.unit,series:eo(s,t,"cpu.power"),emptyMessage:"No stored CPU package power readings in this range."})}l.push({key:"cpu",title:"CPU",charts:e})}if(["memory.used","memory.usage","memory.pressure.some","memory.pressure.full","swap.used"].filter(e=>a.has(e)).length>0){let e=[],r=["memory.used","memory.usage"].filter(e=>a.has(e));if(r.length>0){let n=r.map(e=>({unit:(0,y.oB)(e).unit,series:eo(s,t,e,void 0,()=>"RAM")}));e.push({key:"memory.capacity",title:"RAM",...n[0],unitGroup:"memory",views:n,emptyMessage:"No stored memory readings in this range."})}a.has("swap.used")&&e.push({key:"swap.used",title:"Swap",unit:"bytes",series:eo(s,t,"swap.used"),emptyMessage:"No stored swap readings in this range."});let n=["memory.pressure.some","memory.pressure.full"].filter(e=>a.has(e));if(n.length>0){let r=(0,y.oB)(n[0]),i=n.flatMap(e=>eo(s,t,e,void 0,(t,s)=>"memory.pressure.some"===e?"Some":"memory.pressure.full"===e?"Full":s.shortLabel));e.push({key:"memory.pressure",title:"Memory pressure",unit:r.unit,series:i,emptyMessage:"No stored memory pressure in this range."})}l.push({key:"memory",title:"Memory",charts:e})}let o=["gpu.utilization","gpu.memory.used","gpu.temperature","gpu.power"].filter(e=>a.has(e));if(o.length>0){let e=(0,y.ue)(t,s.series),r=e.filter(e=>!n.has(e.id));for(let n of(0===r.length&&l.push({key:"gpu-empty",title:"GPU",charts:[{key:"gpu-empty",title:"Per-card history",unit:"percent",series:[],emptyMessage:e.length>0?"All GPU cards are hidden. Re-enable a card under Metrics to see its panels.":"No supported GPU cards or stored GPU history in this range."}]}),r)){let e=o.map(e=>{let r=(0,y.oB)(e),i=function(e,t,s,r){return eo(e,t,s,r,(e,t)=>"gpu.utilization"===s?"Utilization":"gpu.memory.used"===s?"VRAM used":t.shortLabel).map(e=>({...e}))}(s,t,e,n.id),a="gpu.memory.used"===e&&null!==n.totalBytes?`of ${(0,S.dd)(n.totalBytes,"bytes")}`:void 0;return{key:`${n.id}-${e}`,title:r.shortLabel,unit:r.unit,series:i,emptyMessage:`No stored ${r.shortLabel.toLowerCase()} readings for this card in this range.`,note:a}});l.push({key:`gpu-${n.id}`,title:`GPU ${n.index+1}${n.label?` \xb7 ${n.label}`:""}`,charts:e})}}if(["fs.used","fs.usage","fs.inodes.usage"].filter(e=>a.has(e)).length>0){let e=[],r=["fs.used","fs.usage"].filter(e=>a.has(e));if(r.length>0){let n=r.map(e=>({unit:(0,y.oB)(e).unit,series:eo(s,t,e)}));e.push({key:"fs.capacity",title:"Capacity used",...n[0],unitGroup:"filesystem",views:n,emptyMessage:"No stored filesystem usage in this range."})}if(a.has("fs.inodes.usage")){let r=(0,y.oB)("fs.inodes.usage");e.push({key:"fs.inodes.usage",title:"Inodes used",unit:r.unit,series:eo(s,t,"fs.inodes.usage"),emptyMessage:"No stored inode usage in this range."})}l.push({key:"filesystems",title:"Filesystems",charts:e})}let d=["disk.read","disk.write"].filter(e=>a.has(e));if(d.length>0){let e=d.flatMap(e=>{let r=(0,y.oB)(e);return eo(s,t,e,void 0,s=>`${(0,y.bP)(t,e,s.resourceId)} ${r.shortLabel.toLowerCase()}`)});l.push({key:"disk",title:"Disk throughput",charts:[{key:"disk",title:"Read and write",unit:"bytes_per_second",series:e,emptyMessage:"No stored disk throughput in this range."}]})}let c=["disk.read.latency","disk.write.latency"].filter(e=>a.has(e)),u=["io.pressure.some","io.pressure.full"].filter(e=>a.has(e));if(c.length>0||u.length>0||a.has("disk.utilization")){let e=[];if(c.length>0){let r=c.flatMap(e=>{let r=(0,y.oB)(e);return eo(s,t,e,void 0,s=>`${(0,y.bP)(t,e,s.resourceId)} ${r.shortLabel.toLowerCase()}`)}),n=(0,y.oB)(c[0]);e.push({key:"disk.latency",title:"Latency",unit:n.unit,series:r,emptyMessage:"No stored disk latency in this range."})}if(a.has("disk.utilization")){let r=(0,y.oB)("disk.utilization");e.push({key:"disk.utilization",title:"Utilization",unit:r.unit,series:eo(s,t,"disk.utilization"),emptyMessage:"No stored disk utilization in this range."})}if(u.length>0){let r=(0,y.oB)(u[0]),n=u.flatMap(e=>eo(s,t,e,void 0,(t,s)=>"io.pressure.some"===e?"Some":"io.pressure.full"===e?"Full":s.shortLabel));e.push({key:"io.pressure",title:"I/O pressure",unit:r.unit,series:n,emptyMessage:"No stored I/O pressure in this range."})}l.push({key:"disk-health",title:"Disk health",charts:e})}let m=["net.rx","net.tx"].filter(e=>a.has(e));if(m.length>0){let e=m.flatMap(e=>{let r=(0,y.oB)(e);return eo(s,t,e,void 0,s=>`${(0,y.bP)(t,e,s.resourceId)} ${r.shortLabel.toLowerCase()}`)});l.push({key:"network",title:"Network throughput",charts:[{key:"network",title:"Received and sent",unit:"bytes_per_second",series:e,emptyMessage:"No stored network throughput in this range."}]})}return l}({machine:t,result:s,selectedMetrics:n,hiddenCards:i,coreIds:d});return(0,r.jsx)(en._C,{children:(0,r.jsx)("div",{className:"grid grid-cols-1 gap-5",children:c.map(n=>{let i=n.charts.find(e=>"cpu.core"===e.key&&e.series.length>4),o=i?[...n.charts.filter(e=>e!==i),i]:n.charts,d=i&&4===o.length?"grid gap-6 lg:grid-cols-2 xl:grid-cols-3":o.length>1&&!(i&&2===o.length)?"grid gap-6 lg:grid-cols-2":"flex flex-col gap-6";return(0,r.jsx)(h.Z,{title:n.title,children:(0,r.jsx)("div",{className:d,children:o.map((n,d)=>{let c=n.unitGroup,u=c?e.capacityUnits[c]:void 0,m=n.views?.find(e=>e.unit===u)??n.views?.[0]??n,h=n===i||!i&&o.length%2==1&&d===o.length-1;return"cpu.core"===n.key&&n.series.length>8?(0,r.jsx)(ea,{title:n.title,series:n.series,fromMs:s.fromMs,toMs:s.toMs,gaps:s.gaps,stepMs:(0,I.jl)(s.stepMs,s.tier,t.expectedIntervalMs),hiddenKeys:a,onToggleSeries:l},n.key):(0,r.jsx)(es.t,{title:n.title,unit:m.unit,series:m.series,fromMs:s.fromMs,toMs:s.toMs,stepMs:(0,I.jl)(s.stepMs,s.tier,t.expectedIntervalMs),gaps:s.gaps,hiddenKeys:a,onToggleSeries:l,emptyMessage:n.emptyMessage,note:n.note,action:c&&n.views&&n.views.length>1?(0,r.jsx)("div",{role:"group","aria-label":`${n.title} units`,className:"inline-flex rounded-md border border-border bg-background p-0.5",children:n.views.map(t=>(0,r.jsx)("button",{type:"button","aria-pressed":t.unit===m.unit,onClick:()=>e.onCapacityUnitChange(c,t.unit),className:`min-h-7 rounded px-2 text-xs transition-colors ${t.unit===m.unit?"bg-selected text-foreground":"text-muted-foreground hover:text-foreground"}`,children:"bytes"===t.unit?"Bytes":"%"},t.unit))}):void 0,maxDrawPoints:"cpu.core"===n.key?150:void 0,className:h?"lg:col-span-full":void 0},n.key)})})},n.key)})})},`${t.machineId}|${s.toMs-s.fromMs}`)}var ec=s(1),eu=s(7499);let em={raw:"raw samples","1m":"1-minute rollups","1h":"1-hour rollups"};function eh(e){return e.displayName?.trim()||e.hostname.trim()||e.machineId}function ep(e,t){return`${e}\0${t}`}function ex(e){let t=new Set(e.selectedMetrics),s=new Set((0,y.ue)(e.machine,e.result.series).filter(t=>!e.hiddenCards.has(t.id)).map(e=>e.id));return e.result.series.filter(r=>!(!t.has(r.metric)||e.hiddenSeries.has(ep(r.metric,r.resourceId))||"cpu.core"===r.metric&&void 0!==e.coreIds&&!e.coreIds.includes(r.resourceId)||r.metric.startsWith("gpu.")&&""!==r.resourceId&&!s.has(r.resourceId)))}function eg(e){return new Date(e).toISOString()}function ef(e){return(0,y.oB)(e)?.label??e}function eb(e){return ex(e).map(t=>({metric:t.metric,label:ef(t.metric),resourceId:t.resourceId,resourceLabel:(0,y.bP)(e.machine,t.metric,t.resourceId),unit:t.unit,unitLabel:(0,y.RL)(t.unit),stats:(0,I.T6)(t.points),points:t.points.map(t=>{let s=Math.min(e.result.toMs,t.t+e.result.stepMs),r=null!==t.min||null!==t.max||null!==t.avg;return{t:t.t,tIso:eg(t.t),bucketStartMs:t.t,bucketStartIso:eg(t.t),bucketEndMs:s,bucketEndIso:eg(s),min:t.min,max:t.max,avg:t.avg,state:r?"recorded":"unavailable"}})}))}function ey(e){return(0,I.$z)(e.result.gaps,e.result.fromMs,e.result.toMs).map(e=>({...e,fromIso:eg(e.fromMs),toIso:eg(e.toMs)}))}function ej(e){let t=new Set(e.result.series.map(e=>e.metric));return e.selectedMetrics.filter(e=>!t.has(e))}function ev(e){let t=new Set(e.selectedMetrics),s=new Set(ex(e).map(e=>ep(e.metric,e.resourceId)));return e.result.series.filter(e=>t.has(e.metric)&&!s.has(ep(e.metric,e.resourceId))).length}function eN(e,t){let s=e.result,r=["Only the visible series from the loaded History result are included; this export does not query more data."];"raw"!==s.tier&&r.push(`Values are ${em[s.tier]}, not individual raw samples.`),s.truncated&&r.push("The loaded result is partial: the hub limited or shortened this history query.");let n=ey(e);n.length>0&&r.push(`${n.length} recorded data gap${1===n.length?"":"s"} included.`),t.length>0&&r.push(`Selected metrics without stored data: ${t.join(", ")}.`);let i=ev(e);return i>0&&r.push(`${i} selected series hidden in this view were not exported.`),r}let ew=["record_type","metric","metric_label","resource_id","resource_label","unit","bucket_start_ms","bucket_start_iso","bucket_end_ms","bucket_end_iso","min","max","avg","value_state","gap_kind","gap_reason","gap_dropped_records"],ek="inline-flex min-h-7 items-center rounded-md border border-border bg-background px-2 text-xs text-foreground transition-colors hover:bg-card-strong disabled:cursor-not-allowed disabled:opacity-50";function eM(e){let[t,s]=(0,a.useState)(null),n=ex(e).length,i=t=>{let r=Date.now(),n={...e,exportedAt:r};try{let e,i,a,l,o,d,c,u,m=function(e,t,s=Date.now()){return(0,eu.Y8)("history",eh(e.machine),s,t)}(n,t,r),h="csv"===t?function(e){let t,s,r,n,i,a,l=e.exportedAt??Date.now(),o=(t=(0,S.ly)(e.range),s=e.result,r=ex(e),n=ej(e),i=ey(e),a=e.selectedMetrics.map(ef).join("; "),[["Rigscope History export"],["Scope","Visible series from the loaded History result"],["Machine",eh(e.machine)],["Machine ID",e.machine.machineId],["Query",a],["Range",`${t.label} (${eg(s.fromMs)} – ${eg(s.toMs)})`],["Resolution",`${em[s.tier]} \xb7 ${s.stepMs} ms buckets`],["Loaded at",eg(e.loadedAt)],["Exported at",eg(l)],["Partial",s.truncated?"true":"false"],["Gaps",String(i.length)],["Visible series",String(r.length)],["Selected without stored data",n.length>0?n.join(", "):"none"],["Note",eN(e,n).join(" ")],[]]);for(let t of(o.push([...ew]),eb(e)))for(let e of t.points)o.push(["bucket",t.metric,t.label,t.resourceId,t.resourceLabel,t.unit,e.bucketStartMs,e.bucketStartIso,e.bucketEndMs,e.bucketEndIso,e.min,e.max,e.avg,e.state,"","",""]);for(let t of ey(e))o.push(["gap","","","","","",t.fromMs,t.fromIso,t.toMs,t.toIso,"","","","gap",t.kind,t.reason??"",t.droppedRecords??""]);return(0,ec.kg)(o)}(n):(e=n.exportedAt??Date.now(),i=(0,S.ly)(n.range),a=n.result,l=eb(n),o=ej(n),d=ey(n),c=ev(n),u={app:"Rigscope",kind:"history",exportedAt:eg(e),scope:{description:"Visible series from the loaded History result",machine:{id:n.machine.machineId,name:eh(n.machine),hostname:n.machine.hostname,connected:n.machine.connected,lastReceivedAt:n.machine.lastReceivedAt},query:{range:{id:i.id,label:i.label,fromMs:a.fromMs,fromIso:eg(a.fromMs),toMs:a.toMs,toIso:eg(a.toMs)},selectedMetrics:[...n.selectedMetrics],visibleSeries:l.length,hiddenSeriesCount:c}},resolution:{tier:a.tier,label:em[a.tier],stepMs:a.stepMs,expectedIntervalMs:n.machine.expectedIntervalMs??null},loadedAt:eg(n.loadedAt),partial:a.truncated,gaps:d,series:l.map(e=>({metric:e.metric,label:e.label,resourceId:e.resourceId,resourceLabel:e.resourceLabel,unit:e.unit,unitLabel:e.unitLabel,summary:{points:e.stats.count,min:e.stats.min,max:e.stats.max,averageOfBucketAverages:e.stats.avg,latest:e.stats.latest,latestAt:null===e.stats.latestT?null:eg(e.stats.latestT),firstAt:null===e.stats.firstT?null:eg(e.stats.firstT),lastAt:null===e.stats.lastT?null:eg(e.stats.lastT)},points:e.points})),missingData:o.map(e=>({metric:e,label:ef(e),reason:"No stored series in the loaded result."})),notes:eN(n,o)},`${JSON.stringify(u,null,2)}
|
|
3
|
+
`);(0,ec.PE)(m,h,"csv"===t?ec.UR:ec.uW),s(null)}catch{s("The history export could not be created.")}};return(0,r.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Export visible",(0,r.jsx)("span",{className:"sr-only",children:` (${n} series from the loaded result)`})]}),(0,r.jsx)("button",{type:"button",onClick:()=>i("csv"),"aria-label":"Download visible history as CSV",title:"Download the visible series from this loaded result as CSV",className:ek,children:"CSV"}),(0,r.jsx)("button",{type:"button",onClick:()=>i("json"),"aria-label":"Download visible history as JSON",title:"Download the visible series from this loaded result as JSON",className:ek,children:"JSON"}),null!==t?(0,r.jsxs)("span",{role:"status",className:"inline-flex items-center gap-1 text-xs text-warn",children:[(0,r.jsx)(d.A,{className:"h-3 w-3","aria-hidden":!0}),t]}):null]})}function e$(e){return e.displayName?.trim()||e.hostname.trim()||e.machineId}function eA(){return(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-5 xl:grid-cols-2","aria-busy":"true",children:[(0,r.jsx)(h.Z,{title:"Loading stored history",children:(0,r.jsx)("div",{className:"h-40 animate-pulse rounded-lg bg-card-strong","aria-hidden":!0})}),(0,r.jsx)(h.Z,{title:"Preparing charts",children:(0,r.jsx)("div",{className:"h-40 animate-pulse rounded-lg bg-card-strong","aria-hidden":!0})})]})}function eI(){let e,t,s,n,{session:j,phase:v,machines:N,retryConnection:w}=(0,f.M)(),k=(0,g.x)(),{machine:A,machineId:R,requestedMachineId:P}=(0,b.JG)("history"),[U,L]=W(R,"memory"),[_,T]=W(R,"filesystem"),z={memory:U,filesystem:_},[D,H]=(0,B.u)("history.range","10m",F),[Z,V]=(0,B.u)(`history.metrics.${R}`,null,O),[K]=q(R),Y=M(A),J=$(K,Y),[Q,X]=G(R,"cards"),[es,er]=G(R,"series"),en=(0,a.useMemo)(()=>new Set(Q),[Q]),ei=(0,a.useMemo)(()=>new Set(es),[es]),[ea,el]=(0,B.u)("history.autoRefresh",!0,E,"session"),[eo,ec]=(0,a.useState)(null),[eu,em]=(0,a.useState)(null),[eh,ep]=(0,a.useState)(0),ex=(0,a.useRef)(null),[eg,ef]=(0,a.useState)(null),[eb,ey]=(0,a.useState)(Date.now);(0,a.useEffect)(()=>{if(void 0===A){ex.current=null,ef(null);return}let e=ex.current,t={connected:A.connected,lastReceivedAt:A.lastReceivedAt},s=e?.machineId===A.machineId?e.point:null;ef(e=>{let r=function(e,t,s,r){let n=e.findIndex(e=>null===e.toMs);if(!s.connected){if(n>=0)return e;let i=[...e,{fromMs:C(s.lastReceivedAt)??C(t?.lastReceivedAt??null)??r,toMs:null}];return i.length>64?i.slice(i.length-64):i}if(n<0||null===t||t.connected)return e;let i=e[n],a=C(s.lastReceivedAt),l=null!==a&&a>i.fromMs?a:Math.max(i.fromMs,r);return e.map((e,t)=>t===n?{fromMs:e.fromMs,toMs:l}:e)}(e?.machineId===A.machineId?e.outages:[],s,t,Date.now());return e?.machineId===A.machineId&&e.outages===r?e:{machineId:A.machineId,outages:r}}),t.connected&&s?.connected!==!1||ey(Date.now()),ex.current={machineId:A.machineId,point:t}},[A?.machineId,A?.connected,A?.lastReceivedAt]),(0,a.useEffect)(()=>{if(A?.connected!==!1||!ea)return;let e=window.setInterval(()=>{"visible"===document.visibilityState&&ey(Date.now())},1e3);return()=>window.clearInterval(e)},[A?.machineId,A?.connected,ea]);let ej=(0,a.useMemo)(()=>void 0===A?"":(0,y.er)(A).join(","),[A?.machineId,A?.inventory,A?.metrics?.payload.gpus]),ev=Z??ej,eN=""===ev?[]:ev.split(","),ew="signed-in"===j.kind&&void 0!==A&&""!==R&&""!==ev;(0,a.useEffect)(()=>{if(""===R){ec(null),em(null);return}let e=new AbortController;return ec(null),em(null),fetch(`/api/history/metrics?machineId=${encodeURIComponent(R)}`,{signal:e.signal,cache:"no-store",headers:{Accept:"application/json"}}).then(async t=>{if(!t.ok){if(401===t.status||403===t.status||404===t.status)return;throw Error(`catalog ${t.status}`)}let s=await t.json();if(null===s||"object"!=typeof s||!("metrics"in s))throw Error("catalog shape");let r=s.metrics;if(null===r||"object"!=typeof r)throw Error("catalog shape");let n=Object.create(null);for(let[e,t]of Object.entries(r))null!==t&&"object"==typeof t&&"string"==typeof t.unit&&(n[e]={unit:t.unit});e.signal.aborted||ec(n)}).catch(()=>{e.signal.aborted||em("The hub's metric catalog could not be loaded; standard metric names are shown.")}),()=>e.abort()},[R]);let{data:ek,error:eI,loading:eC,manualRefreshing:eS}=(0,et.n)({machineId:R,metricsKey:ev,coreIdsKey:eN.includes("cpu.core")&&J.length!==Y.length?J.join(","):void 0,range:D,enabled:ew,autoRefresh:ea,refreshNonce:eh});(0,a.useEffect)(()=>{eI?.kind==="rate-limited"&&el(!1)},[eI?.kind,el]);let eR=(0,a.useMemo)(()=>{if(!ek||eg?.machineId!==R||0===eg.outages.length)return ek;let e=ek.result,t=Math.max(e.toMs,...eg.outages.map(e=>e.toMs??eb)),s=e.fromMs+t-e.toMs;return{...ek,result:{...e,fromMs:s,toMs:t,gaps:(0,I.$z)([...e.gaps,...function(e,t,s){if(!Number.isFinite(t)||!Number.isFinite(s)||s<=t)return[];let r=[];for(let n of e){let e=Math.max(t,n.fromMs),i=Math.min(s,n.toMs??s);Number.isFinite(e)&&Number.isFinite(i)&&!(i<=e)&&r.push({fromMs:e,toMs:i,kind:"missing",reason:null===n.toMs?"collector disconnected":"collector outage"})}var n=r;let i=n.filter(e=>Number.isFinite(e.fromMs)&&Number.isFinite(e.toMs)&&e.toMs>e.fromMs).map(e=>({...e})).sort((e,t)=>e.fromMs-t.fromMs||e.toMs-t.toMs),a=[];for(let e of i){let t=a.at(-1);if(void 0!==t&&e.fromMs<=t.toMs){t.toMs=Math.max(t.toMs,e.toMs),"dropped"===e.kind&&(t.kind="dropped"),void 0===t.reason&&void 0!==e.reason&&(t.reason=e.reason),void 0===t.droppedRecords&&void 0!==e.droppedRecords&&(t.droppedRecords=e.droppedRecords);continue}a.push(e)}return a}(eg.outages,s,t)],s,t)}}},[ek,R,eg,eb]),eP=eR?.result??null,eU=void 0===A?[]:(0,y.ue)(A,eP?.series??[]),eL=(0,S.ly)(D),e_=null!==eI?null!==eR?`${"rate-limited"===eI.kind?"Refresh paused":"Refresh failed"} \xb7 ${(0,S.ei)(eR.loadedAt)}`:"History unavailable":null!==eR?`Updated ${(0,S.ei)(eR.loadedAt)}`:eC?"Loading…":"",eB=ew&&null===eR&&null===eI,eT=N.length,ez="disconnected"===v;return(0,r.jsx)(m.G,{title:"History",machineId:R,machineView:"history",headerRight:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(p.$E,{}),(0,r.jsx)(x.B,{})]}),children:k||(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{role:"status","aria-live":"polite",className:"sr-only",children:eI?.message??""}),(0,r.jsx)(ee,{machine:A,range:D,selectedMetrics:eN,catalog:eo,catalogError:eu,gpuCards:eU,hiddenCards:en,autoRefresh:ea,loading:eC,manualRefreshing:eS,statusText:e_,onRangeChange:H,onToggleMetric:e=>{let t=new Set(eN);t.has(e)?t.delete(e):t.add(e),V([...t].sort().join(","))},onSetMetrics:e=>V([...new Set(e)].sort().join(",")),onToggleCard:e=>{X(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),[...s]})},onToggleAutoRefresh:()=>el(e=>!e),onRefresh:()=>ep(e=>e+1)}),"reconnecting"===v||"disconnected"===v?(0,r.jsxs)("div",{role:"status",className:"mb-4 flex items-start gap-2 rounded-lg border border-border bg-card px-4 py-2.5 text-xs text-muted-foreground",children:[(0,r.jsx)(d.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-warn","aria-hidden":!0}),(0,r.jsxs)("span",{children:["Live feed ","disconnected"===v?"disconnected":"reconnecting"," \xb7 stored history available"]}),"disconnected"===v?(0,r.jsxs)("button",{type:"button",onClick:w,className:"ml-auto inline-flex min-h-8 shrink-0 items-center gap-1.5 rounded-md border border-border px-2.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:[(0,r.jsx)(u.A,{className:"h-3 w-3","aria-hidden":!0}),"Retry now"]}):null]}):null,void 0===A?ez?(0,r.jsxs)(h.Z,{title:"Hub disconnected",className:"mx-auto mt-3 max-w-xl",children:[(0,r.jsx)(h.p,{icon:c.A,note:"The hub is unreachable, so the authorized machine list is unavailable."}),(0,r.jsx)("div",{className:"mt-2 flex justify-center",children:(0,r.jsxs)("button",{type:"button",onClick:w,className:"inline-flex min-h-8 items-center gap-1.5 rounded-md border border-border px-3 text-xs text-foreground transition-colors hover:bg-card-strong",children:[(0,r.jsx)(u.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Check again"]})})]}):0!==eT||ez||"idle"!==v&&"connecting"!==v&&"reconnecting"!==v?0===eT?(0,r.jsx)(h.Z,{title:"No machines",className:"mx-auto mt-3 max-w-xl",children:(0,r.jsx)(h.p,{icon:o.A,note:"No machines are available in your authorized fleet."})}):(0,r.jsxs)(h.Z,{title:"Machine not found",className:"mx-auto mt-3 max-w-xl",children:[(0,r.jsx)(h.p,{icon:o.A,note:"This machine is unavailable or outside your access."}),P?(0,r.jsxs)("p",{className:"tnum mt-2 text-center text-xs text-muted-foreground",children:["Requested identifier: ",P]}):null,(0,r.jsx)("div",{className:"mt-2 flex justify-center",children:(0,r.jsx)(i(),{href:"/",className:"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:"Back to fleet"})})]}):(0,r.jsx)(h.Z,{title:"Waiting for machines",className:"mx-auto mt-3 max-w-xl",children:(0,r.jsx)(h.p,{icon:o.A,note:"Waiting for the hub to report your authorized machines…"})}):0===eN.length?(0,r.jsx)(h.Z,{title:"No metrics selected",className:"mx-auto mt-3 max-w-xl",children:(0,r.jsx)(h.p,{icon:o.A,note:""===ej?"No metric families are shared with this hub.":"Choose at least one metric above to draw history."})}):null!==eI&&null===eR?(t=(e=function(e){switch(e.kind){case"unauthorized":return{title:"Session ended",note:"Your session is no longer accepted, so stored history is hidden.",icon:l.A};case"denied":return{title:"History access denied",note:e.message,icon:l.A};case"missing":return{title:"Machine unavailable",note:e.message,icon:o.A};case"rate-limited":return{title:"History requests limited",note:e.message,icon:d.A};case"unavailable":return{title:"History unavailable",note:e.message,icon:c.A};case"network":return{title:"Hub unreachable",note:"The hub could not be reached for stored history.",icon:c.A};case"invalid":return{title:"Unexpected history response",note:e.message,icon:d.A}}}(eI)).icon,(0,r.jsxs)(h.Z,{title:e.title,className:"mx-auto mt-3 max-w-xl",children:[(0,r.jsx)(h.p,{icon:t,note:e.note}),(0,r.jsxs)("div",{className:"mt-2 flex flex-wrap justify-center gap-2",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>ep(e=>e+1),className:"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:[(0,r.jsx)(u.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Try again"]}),"unauthorized"===eI.kind?(0,r.jsx)(i(),{href:"/login",className:"inline-flex items-center rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors hover:bg-accent/90",children:"Sign in"}):null]})]})):(eC||eB)&&null===eR?(0,r.jsx)(eA,{}):null===eR?(0,r.jsx)(h.Z,{title:"History",className:"mx-auto mt-3 max-w-xl",children:(0,r.jsx)(h.p,{icon:o.A,note:"No stored history has arrived yet."})}):(n="raw"===(s=eR.result).tier?"raw samples":"1m"===s.tier?"1-minute rollups":"1-hour rollups",(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"mb-3 flex flex-wrap items-baseline gap-x-4 gap-y-1 text-xs text-muted-foreground",children:[(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-foreground",children:[(0,r.jsx)("span",{"aria-hidden":!0,className:`inline-block h-2 w-2 shrink-0 rounded-full ${A.connected?"bg-ok":"bg-crit"}`}),e$(A)]}),(0,r.jsxs)("span",{children:[(0,S.r6)(s.fromMs)," – ",(0,S.r6)(s.toMs)]}),(0,r.jsxs)("span",{className:"tnum",title:n,children:[(0,S.I_)(s.stepMs)," buckets"]}),(0,r.jsx)("div",{className:"ml-auto self-center",children:(0,r.jsx)(eM,{machine:A,result:s,range:D,selectedMetrics:(0,y.Cv)(eN,z),hiddenCards:en,hiddenSeries:ei,coreIds:J,loadedAt:eR.loadedAt})})]}),s.truncated?(0,r.jsxs)("div",{role:"status",className:"mb-4 flex items-start gap-2 rounded-lg bg-warn-soft px-4 py-2.5 text-xs text-foreground",children:[(0,r.jsx)(d.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-warn","aria-hidden":!0}),(0,r.jsx)("span",{children:"Partial history \xb7 narrow the range for more detail."})]}):null,s.gaps.length>0?(0,r.jsxs)("details",{className:"mb-4 max-w-3xl text-xs text-muted-foreground",children:[(0,r.jsxs)("summary",{className:"inline-flex min-h-8 cursor-pointer items-center gap-2 rounded-md text-warn",children:[(0,r.jsx)(d.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-warn","aria-hidden":!0}),(0,r.jsxs)("span",{children:[(0,r.jsx)("strong",{className:"font-medium",children:"Data gaps:"})," ",(0,S.fH)(s.gaps,s.fromMs,s.toMs)]})]}),(0,r.jsxs)("ul",{className:"mt-1.5 flex flex-col gap-1",children:[s.gaps.slice(0,20).map(e=>(0,r.jsxs)("li",{className:"tnum text-xs",children:[(0,S.r6)(e.fromMs)," – ",(0,S.r6)(e.toMs)," (",(0,S.I_)(e.toMs-e.fromMs),"):"," ","dropped"===e.kind?"dropped":"missed",e.reason?` \xb7 ${e.reason}`:"",void 0!==e.droppedRecords?` \xb7 ${e.droppedRecords} record${1===e.droppedRecords?"":"s"}`:""]},`${e.fromMs}-${e.toMs}-${e.kind}`)),s.gaps.length>20?(0,r.jsxs)("li",{className:"text-xs text-muted-foreground",children:["…and ",s.gaps.length-20," more."]}):null]})]}):null,0===s.series.length?(0,r.jsx)(h.Z,{title:"No stored points",className:"mx-auto max-w-xl",children:(0,r.jsx)(h.p,{icon:o.A,note:`No stored readings for ${void 0===A?"this machine":e$(A)} in ${eL.label.toLowerCase()}.`})}):(0,r.jsx)(ed,{machine:A,result:s,selectedMetrics:eN,hiddenCards:en,hiddenSeries:ei,onToggleSeries:e=>{er(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),[...s]})},capacityUnits:z,onCapacityUnitChange:(e,t)=>("memory"===e?L:T)(t)})]}))]})})}},6582:(e,t,s)=>{"use strict";s.d(t,{E:()=>f,x:()=>g});var r=s(5155),n=s(8500),i=s.n(n),a=s(828),l=s(6914),o=s(7029),d=s(438),c=s(7422),u=s(1735),m=s(3440),h=s(9939);function p(e){return(0,r.jsxs)("button",{type:"button",onClick:e.onClick,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:[(0,r.jsx)(a.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.children]})}function x(e){return(0,r.jsx)(i(),{href:e.href,className:e.primary?"inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors hover:bg-accent/90":"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:e.children})}function g(){let{session:e,phase:t,retryConnection:s}=(0,h.M)();switch(e.kind){case"restoring":return(0,r.jsx)(m.Z,{title:"Checking session",className:"mx-auto my-12 max-w-md",children:(0,r.jsx)(m.p,{icon:l.A,note:"Checking your session…"})});case"restore-failed":return(0,r.jsxs)(m.Z,{title:"Hub unreachable",className:"mx-auto my-12 max-w-md",children:[(0,r.jsx)(m.p,{icon:o.A,note:"The hub is unreachable right now."}),(0,r.jsx)("div",{className:"flex justify-center",children:(0,r.jsx)(p,{onClick:s,children:"Check again"})})]});case"signed-out":if("expired"===t)return(0,r.jsxs)(m.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,r.jsx)(m.p,{icon:d.A,note:"Your session ended."}),(0,r.jsx)("div",{className:"flex justify-center",children:(0,r.jsx)(x,{href:"/login",primary:!0,children:"Sign in"})})]});return(0,r.jsxs)(m.Z,{title:"Sign in required",className:"mx-auto my-12 max-w-md",children:[(0,r.jsx)(m.p,{icon:l.A,note:"Sign in required."}),(0,r.jsx)("div",{className:"flex justify-center",children:(0,r.jsx)(x,{href:"/login",primary:!0,children:"Sign in"})})]});case"auth-unavailable":return(0,r.jsx)(m.Z,{title:"Sign-in unavailable",className:"mx-auto my-12 max-w-md",children:(0,r.jsx)(m.p,{icon:c.A,note:"Browser sign-in is not configured on this hub."})})}return"expired"===t?(0,r.jsxs)(m.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,r.jsx)(m.p,{icon:d.A,note:"Your session ended."}),(0,r.jsx)("div",{className:"flex justify-center",children:(0,r.jsx)(x,{href:"/login",primary:!0,children:"Sign in"})})]}):"no-permission"===t?(0,r.jsxs)(m.Z,{title:"No permission",className:"mx-auto my-12 max-w-md",children:[(0,r.jsx)(m.p,{icon:c.A,note:`You are signed in as ${e.user.username}, but this hub grants no machine view to this account.`}),(0,r.jsx)("div",{className:"flex justify-center",children:(0,r.jsx)(p,{onClick:s,children:"Check again"})})]}):null}function f(){let{phase:e,retryConnection:t}=(0,h.M)();return"reconnecting"!==e&&"disconnected"!==e&&"connecting"!==e?null:"connecting"===e?(0,r.jsxs)("div",{role:"status",className:"mb-5 flex items-center gap-2 rounded-lg border border-border bg-card px-4 py-2.5 text-xs text-muted-foreground",children:[(0,r.jsx)(a.A,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),"Connecting to the live feed — waiting for the first snapshot."]}):(0,r.jsxs)("div",{role:"status",className:"mb-5 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border border-border bg-card px-4 py-2.5 text-xs text-muted-foreground",children:[(0,r.jsx)(u.A,{className:"h-3.5 w-3.5 shrink-0 text-warn","aria-hidden":!0}),(0,r.jsxs)("span",{children:["Connection lost — values below are ",(0,r.jsx)("strong",{className:"font-medium text-foreground",children:"last known"}),", not live measurements","reconnecting"===e?" — retrying with backoff…":" — retries stopped."]}),"disconnected"===e?(0,r.jsx)(p,{onClick:t,children:"Retry now"}):null]})}},7148:(e,t,s)=>{Promise.resolve().then(s.bind(s,2939)),Promise.resolve().then(s.bind(s,1721)),Promise.resolve().then(s.bind(s,2701)),Promise.resolve().then(s.bind(s,2394))},7499:(e,t,s)=>{"use strict";function r(e,t,s,r){return`rigscope-${e}-${function(e,t="machine"){let s=e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48).replace(/-+$/g,"");return s.length>0?s:t}(t)}-${!Number.isFinite(s)?"unknown-time":new Date(s).toISOString().replace(/[-:]/g,"").replace(/\.\d{3}Z$/,"Z")}.${r}`}s.d(t,{Y8:()=>r})},9942:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(8698).A)("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]])}},e=>{e.O(0,[157,939,103,408,441,794,358],()=>e(e.s=7148)),_N_E=e.O()}]);
|
package/.next/static/chunks/app/processes/{page-e471ed23a1d5632f.js → page-0e98a4a64e829c5f.js}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[952],{1:(e,t,r)=>{"use strict";r.d(t,{PE:()=>o,UR:()=>c,kg:()=>l,uW:()=>d});let s=/^[\u0009\u000a\u000d ]*[=+\-@]/,n=/^[\u0009\u000a\u000d]/;function a(e){if(null==e)return"";if("number"==typeof e)return Number.isFinite(e)?String(e):"";if("boolean"==typeof e)return e?"true":"false";let t=0===e.length?e:s.test(e)||n.test(e)?`'${e}`:e;return/[",\t\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function i(e){return e.map(a).join(",")}function l(e){return`${e.map(i).join("\r\n")}\r
|
|
2
|
-
`}function o(e,t,r){if("u"<typeof document)return;let s=new Blob([t],{type:r}),n=URL.createObjectURL(s),a=document.createElement("a");a.href=n,a.download=e,a.rel="noopener",a.style.display="none",document.body.append(a),a.click(),a.remove(),globalThis.setTimeout(()=>URL.revokeObjectURL(n),0)}let c="text/csv;charset=utf-8",d="application/json;charset=utf-8"},438:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},2910:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]])},3381:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("CloudOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]])},4268:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},6582:(e,t,r)=>{"use strict";r.d(t,{E:()=>x,x:()=>g});var s=r(5155),n=r(8500),a=r.n(n),i=r(828),l=r(6914),o=r(7029),c=r(438),d=r(7422),u=r(1735),p=r(3440),h=r(9939);function m(e){return(0,s.jsxs)("button",{type:"button",onClick:e.onClick,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:[(0,s.jsx)(i.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.children]})}function f(e){return(0,s.jsx)(a(),{href:e.href,className:e.primary?"inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors hover:bg-accent/90":"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:e.children})}function g(){let{session:e,phase:t,retryConnection:r}=(0,h.M)();switch(e.kind){case"restoring":return(0,s.jsx)(p.Z,{title:"Checking session",className:"mx-auto my-12 max-w-md",children:(0,s.jsx)(p.p,{icon:l.A,note:"Checking your session…"})});case"restore-failed":return(0,s.jsxs)(p.Z,{title:"Hub unreachable",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(p.p,{icon:o.A,note:"The hub is unreachable right now."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(m,{onClick:r,children:"Check again"})})]});case"signed-out":if("expired"===t)return(0,s.jsxs)(p.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(p.p,{icon:c.A,note:"Your session ended."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(f,{href:"/login",primary:!0,children:"Sign in"})})]});return(0,s.jsxs)(p.Z,{title:"Sign in required",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(p.p,{icon:l.A,note:"Sign in required."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(f,{href:"/login",primary:!0,children:"Sign in"})})]});case"auth-unavailable":return(0,s.jsx)(p.Z,{title:"Sign-in unavailable",className:"mx-auto my-12 max-w-md",children:(0,s.jsx)(p.p,{icon:d.A,note:"Browser sign-in is not configured on this hub."})})}return"expired"===t?(0,s.jsxs)(p.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(p.p,{icon:c.A,note:"Your session ended."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(f,{href:"/login",primary:!0,children:"Sign in"})})]}):"no-permission"===t?(0,s.jsxs)(p.Z,{title:"No permission",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(p.p,{icon:d.A,note:`You are signed in as ${e.user.username}, but this hub grants no machine view to this account.`}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(m,{onClick:r,children:"Check again"})})]}):null}function x(){let{phase:e,retryConnection:t}=(0,h.M)();return"reconnecting"!==e&&"disconnected"!==e&&"connecting"!==e?null:"connecting"===e?(0,s.jsxs)("div",{role:"status",className:"mb-5 flex items-center gap-2 rounded-lg border border-border bg-card px-4 py-2.5 text-xs text-muted-foreground",children:[(0,s.jsx)(i.A,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),"Connecting to the live feed — waiting for the first snapshot."]}):(0,s.jsxs)("div",{role:"status",className:"mb-5 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border border-border bg-card px-4 py-2.5 text-xs text-muted-foreground",children:[(0,s.jsx)(u.A,{className:"h-3.5 w-3.5 shrink-0 text-warn","aria-hidden":!0}),(0,s.jsxs)("span",{children:["Connection lost — values below are ",(0,s.jsx)("strong",{className:"font-medium text-foreground",children:"last known"}),", not live measurements","reconnecting"===e?" — retrying with backoff…":" — retries stopped."]}),"disconnected"===e?(0,s.jsx)(m,{onClick:t,children:"Retry now"}):null]})}},7339:(e,t,r)=>{"use strict";r.d(t,{ProcessesView:()=>eX});var s=r(5155),n=r(8500),a=r.n(n),i=r(9926),l=r(3381),o=r(8731),c=r(4173),d=r(3440),u=r(940),p=r(802),h=r(6582),m=r(9939),f=r(8664),g=r(2115),x=r(828),b=r(7422),y=r(7029),w=r(2910),v=r(1735),j=r(9764),k=r(9664),M=r(4268),N=r(9942);let A=new Set(["bash","zsh","fish","sh","dash","ksh","mksh","tcsh","csh","ash","busybox"]),P=new Set(["sshd","sshd-session","dropbear","tmux","screen","systemd"]),S=["cpuPercent","memoryRssBytes","gpuMemoryBytes","ioReadBytesPerSec","ioWriteBytesPerSec"];function $(e,t,r){return e.slice().sort((e,s)=>W(D(e,t),D(s,t),r))}function R(e){return null!==e&&!!("init.scope"===e||/^session-.+\.scope$/.test(e)||/^user@.+\.service$/.test(e))}function C(e){return null===e||!e.endsWith(".scope")&&!e.endsWith(".service")||R(e)?null:e}function B(e){let t=e.replace(/\.(scope|service)$/,"");return t.startsWith("app-gnome-")?t=t.slice(10):t.startsWith("app-")&&(t=t.slice(4)),(t=t.replace(/-\d+$/,"")).length>0?t:e}function T(e){return{key:`tree:${e.pid}:${e.startTicks}`,label:e.name,kind:"tree",leader:e}}function U(e,t){switch(t){case"cpu":return e.cpuPercent;case"memory":return e.memoryRssBytes;case"gpuMemory":return e.gpuMemoryBytes;case"ioRead":return e.ioReadBytesPerSec;case"ioWrite":return e.ioWriteBytesPerSec;case"name":return e.label;case"count":return e.count;case"pid":var r=e.members;let s=null;for(let e of r)(null===s||e.pid<s)&&(s=e.pid);return s;case"user":return e.users.length>0?e.users[0]:null}}function D(e,t){switch(t){case"cpu":return e.cpuPercent;case"memory":return e.memoryRssBytes;case"gpuMemory":return e.gpuMemoryBytes;case"ioRead":return e.ioReadBytesPerSec;case"ioWrite":return e.ioWriteBytesPerSec;case"name":return e.name;case"count":return 1;case"pid":return e.pid;case"user":return e.user}}function W(e,t,r){let s,n=null==e,a=null==t;if(n&&a)return 0;if(n)return 1;if(a)return -1;if("number"==typeof e&&"number"==typeof t)s=e-t;else{let r=String(e).toLowerCase(),n=String(t).toLowerCase();s=r<n?-1:+(r>n)}return"asc"===r?s:-s}var I=r(592),L=r(7586);let q={key:"cpu",dir:"desc"};function K(e,t,r){return null!==e&&t-e>=(!Number.isFinite(r)||r<=0?1e4:Math.max(1e4,3*r))}let _=[{value:"applications",label:"Applications"},{value:"processes",label:"Processes"},{value:"tree",label:"Tree"}];function E(e){return`${e.pid}:${e.startTicks}`}function F(e){if(void 0===e.command)return e;let{command:t,...r}=e;return r}function z(e){return null!=e&&Number.isFinite(e)?Math.round(e).toString().replace(/\B(?=(\d{3})+(?!\d))/g,","):"—"}function O(e){switch(e){case"idle":return{label:"Not connected",tone:"muted",description:"Select a machine to request process detail.",retryable:!1};case"acquiring":return{label:"Connecting",tone:"warn",description:"Requesting process detail…",retryable:!1};case"loading":return{label:"Waiting",tone:"warn",description:"Waiting for the collector's first process snapshot…",retryable:!1};case"ready":return{label:"Live",tone:"ok",description:"Process detail is live.",retryable:!1};case"paused":return{label:"Paused",tone:"muted",description:"Process updates are paused.",retryable:!1};case"stale":return{label:"Not refreshing",tone:"warn",description:"The last snapshot is retained, but new snapshots are not arriving.",retryable:!0};case"disconnected":return{label:"Disconnected",tone:"crit",description:"The collector is disconnected; the last snapshot is not live.",retryable:!0};case"withheld":return{label:"Withheld",tone:"warn",description:"Process detail is withheld for this hub.",retryable:!0};case"unsupported":return{label:"Unsupported",tone:"warn",description:"This collector cannot provide process detail.",retryable:!0};case"busy":return{label:"Busy",tone:"warn",description:"Too many process views are open for this hub.",retryable:!0};case"expired":return{label:"Expired",tone:"warn",description:"Process detail expired before a fresh snapshot arrived.",retryable:!0};case"failed":return{label:"Scan failed",tone:"crit",description:"The process scan failed repeatedly.",retryable:!0};case"cancelled":return{label:"Stopped",tone:"muted",description:"The process detail view was stopped.",retryable:!0};case"error":return{label:"Unavailable",tone:"crit",description:"Process detail is unavailable right now.",retryable:!0}}}function V(e){return"number"==typeof e&&Number.isFinite(e)&&e>0}var Z=r(7348);class G{maxAgeMs;limit;session=null;entries=new Map;constructor(e=3e5,t=32){this.maxAgeMs=e,this.limit=t}scope(e){(this.session!==e||null===e)&&this.entries.clear(),this.session=e}get(e,t,r=Date.now()){this.scope(t);let s=this.entries.get(e);return s&&r-s.lastReceivedMs>=this.maxAgeMs?void this.entries.delete(e):s}set(e,t,r){this.scope(t),this.entries.delete(e),this.entries.set(e,r),this.entries.size>this.limit&&this.entries.delete(this.entries.keys().next().value)}delete(e,t){this.scope(t),this.entries.delete(e)}}let Y=new G;function X(e,t){let r=Y.get(e??"",t);return void 0!==r?{phase:"stale",message:"Resuming process updates…",...r}:{phase:null===e?"idle":"acquiring",detail:null,message:null,intervalMs:1e3,leaseMs:15e3,lastReceivedMs:null}}async function J(e){try{let t=await e.json();if(t&&"object"==typeof t&&"error"in t){let e=t.error;if("string"==typeof e&&e.length>0)return e}}catch{}return e.statusText||null}var H=r(8698);let Q=(0,H.A)("ChevronsUpDown",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]),ee=(0,H.A)("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),et=(0,H.A)("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);var er=r(8528),es=r(6114);let en=[{id:"name",label:"Application",sortKey:"name",align:"left",width:300},{id:"count",label:"Procs",sortKey:"count",align:"right",width:76},{id:"cpu",label:"CPU / core",sortKey:"cpu",align:"right",width:104},{id:"memory",label:"RSS",sortKey:"memory",align:"right",width:96},{id:"gpuMemory",label:"VRAM",sortKey:"gpuMemory",align:"right",width:96},{id:"ioRead",label:"Read",sortKey:"ioRead",align:"right",width:104},{id:"ioWrite",label:"Write",sortKey:"ioWrite",align:"right",width:104},{id:"users",label:"Users",sortKey:"user",align:"left",width:160}],ea=[{id:"name",label:"Process",sortKey:"name",align:"left",width:300},{id:"pid",label:"PID",sortKey:"pid",align:"right",width:84},{id:"user",label:"User",sortKey:"user",align:"left",width:120},{id:"cpu",label:"CPU / core",sortKey:"cpu",align:"right",width:104},{id:"memory",label:"RSS",sortKey:"memory",align:"right",width:96},{id:"gpuMemory",label:"VRAM",sortKey:"gpuMemory",align:"right",width:96},{id:"ioRead",label:"Read",sortKey:"ioRead",align:"right",width:104},{id:"ioWrite",label:"Write",sortKey:"ioWrite",align:"right",width:104},{id:"threads",label:"Threads",align:"right",width:84}],ei=Object.freeze({}),el=Object.freeze([]),eo=new Set(["cpu","memory","gpuMemory","ioRead","ioWrite","name","count","pid","user"]);function ec(e){return Math.round(Math.min(1200,Math.max(56,e)))}function ed(e){return"applications"===e||"processes"===e||"tree"===e?e:null}function eu(e){if(null===e||"object"!=typeof e)return null;let{key:t,dir:r}=e;return"string"==typeof t&&eo.has(t)&&("asc"===r||"desc"===r)?{key:t,dir:r}:null}function ep(e){if(null===e||"object"!=typeof e||Array.isArray(e))return null;let t={};for(let[r,s]of Object.entries(e))"number"==typeof s&&Number.isFinite(s)&&(t[r]=ec(s));return t}function eh(e){return"string"==typeof e?e.slice(0,200):null}function em(e){return"boolean"==typeof e?e:null}function ef(e){return Array.isArray(e)&&e.every(e=>"string"==typeof e)?e.slice(0,500):null}let eg="overflow-hidden text-ellipsis whitespace-nowrap border-b border-border px-2 py-2 align-middle",ex=`${eg} tnum text-right text-xs`,eb="relative overflow-hidden whitespace-nowrap border-b border-border px-2 py-2 text-left text-xs font-normal text-muted-foreground";function ey(e,t){return t[e.id]??e.width}function ew({label:e,width:t,onChange:r,onReset:n}){let a=(0,g.useRef)(null);return(0,s.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e} column`,"aria-valuenow":t,"aria-valuemin":56,"aria-valuemax":1200,tabIndex:0,title:"Drag to resize \xb7 double-click to reset",onPointerDown:e=>{0===e.button&&(e.preventDefault(),e.stopPropagation(),e.currentTarget.setPointerCapture(e.pointerId),a.current={x:e.clientX,width:t})},onPointerMove:e=>{null!==a.current&&r(ec(a.current.width+e.clientX-a.current.x))},onPointerUp:e=>{null!==a.current&&r(ec(a.current.width+e.clientX-a.current.x)),a.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)},onPointerCancel:()=>{a.current=null},onLostPointerCapture:()=>{a.current=null},onClick:e=>e.stopPropagation(),onDoubleClick:e=>{e.stopPropagation(),n()},onKeyDown:e=>{"ArrowLeft"===e.key?(e.preventDefault(),r(ec(t-16))):"ArrowRight"===e.key&&(e.preventDefault(),r(ec(t+16)))},className:"group/handle absolute inset-y-0 right-0 z-10 flex w-2.5 cursor-col-resize touch-none select-none justify-end",children:(0,s.jsx)("span",{"aria-hidden":!0,className:"my-2 w-px bg-border transition-colors group-hover/handle:bg-accent group-focus-visible/handle:bg-accent"})})}function ev({column:e,sort:t,onSort:r,width:n,onResize:a,onReset:i}){let l="right"===e.align,o=e.sortKey,c=void 0!==o?t.key!==o?"none":"asc"===t.dir?"ascending":"descending":"none",d="none"!==c,u=d?"asc"===t.dir?ee:et:Q;return(0,s.jsxs)("th",{scope:"col","aria-sort":void 0!==o?c:void 0,className:l?`${eb} text-right`:eb,children:[void 0!==o?(0,s.jsxs)("button",{type:"button",onClick:()=>r(o),className:["inline-flex min-h-6 max-w-full items-center gap-1 rounded-sm transition-colors hover:text-foreground",l?"w-full justify-end pr-1":"",d?"text-foreground":""].filter(Boolean).join(" "),children:[(0,s.jsx)("span",{className:"truncate",children:e.label}),(0,s.jsx)(u,{className:d?"h-3 w-3 shrink-0":"h-3 w-3 shrink-0 opacity-40","aria-hidden":!0})]}):(0,s.jsx)("span",{className:l?"block truncate pr-1":"block truncate",children:e.label}),(0,s.jsx)(ew,{label:e.label,width:n,onChange:a,onReset:i})]})}function ej({table:e,columns:t,label:r,caption:n,sort:a,onSort:i,children:l}){let[o,c]=(0,es.u)(`processes.widths.${e}`,ei,ep),d=(0,g.useRef)(null),[u,p]=(0,g.useState)(0);(0,g.useEffect)(()=>{let e=d.current;if(!e)return;let t=new ResizeObserver(([e])=>p(e.contentRect.width));return t.observe(e),()=>t.disconnect()},[]);let h=e=>"name"===e.id?160:56,m=t.reduce((e,t)=>e+h(t),0),f=t.reduce((e,t)=>e+ey(t,o),0),x={},b=Math.max(u||f,m),y=[...t];for(;y.length>0;){let e=y.reduce((e,t)=>e+ey(t,o),0),t=y.filter(t=>b*ey(t,o)/e<h(t));if(0===t.length){for(let t of y)x[t.id]=b*ey(t,o)/e;break}for(let e of t)x[e.id]=h(e),b-=h(e);y=y.filter(e=>!t.includes(e))}return(0,s.jsx)("div",{ref:d,className:"relative min-h-0 w-full min-w-0 flex-1 overflow-auto overscroll-contain",tabIndex:0,role:"region","aria-label":r,children:(0,s.jsxs)("table",{className:"table-fixed border-separate border-spacing-0 text-left",style:{width:"100%",minWidth:m},children:[(0,s.jsx)("caption",{className:"sr-only",children:n}),(0,s.jsx)("colgroup",{children:t.map(e=>(0,s.jsx)("col",{style:{width:x[e.id]}},e.id))}),(0,s.jsx)("thead",{className:"sticky top-0 z-20 bg-card",children:(0,s.jsx)("tr",{children:t.map(e=>(0,s.jsx)(ev,{column:e,sort:a,onSort:i,width:x[e.id],onResize:r=>{let s,n,a;return s=t.indexOf(e),n=t[s+1]??t[s-1],a=Math.max(h(e)-x[e.id],Math.min(r-x[e.id],x[n.id]-h(n))),void c({...x,[e.id]:x[e.id]+a,[n.id]:x[n.id]-a})},onReset:()=>c(t=>{let{[e.id]:r,...s}=t;return s})},e.id))})}),(0,s.jsx)("tbody",{children:l})]})})}function ek({value:e,kind:t,partial:r=!1}){let n=function(e,t,r=!1){let s;if(null===e||!Number.isFinite(e)||e<0)return{text:"—",atLeast:!1,title:null};switch(t){case"percent":s=(0,L.l9)(e);break;case"bytes":s=(0,L.z3)(e);break;case"rate":s=`${(0,L.z3)(e)}/s`;break;case"count":s=z(e)}return{text:s,atLeast:r,title:r?`At least ${s}: some processes in this group did not report this metric.`:null}}(e,t,r);return(0,s.jsxs)("td",{className:"—"===n.text?`${ex} text-muted-foreground`:ex,title:n.title??void 0,children:[n.atLeast?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{"aria-hidden":!0,children:"≥ "}),(0,s.jsx)("span",{className:"sr-only",children:"at least "})]}):null,n.text]})}function eM(e){let t=e.name.length>0?e.name:"Unnamed process";return null!==e.unit?`${t} \xb7 ${e.unit}`:t}function eN({row:e,depth:t=0}){return(0,s.jsx)("th",{scope:"row",className:`${eg} text-left text-sm font-medium`,title:eM(e),children:(0,s.jsxs)("span",{style:t>0?{paddingLeft:`${14*t}px`}:void 0,children:[t>0?(0,s.jsx)("span",{className:"sr-only",children:`Nested level ${t+1}. `}):null,e.name.length>0?e.name:(0,s.jsx)("span",{className:"text-muted-foreground",children:"Unnamed process"})]})})}function eA({entries:e,sort:t,onSort:r,mode:n}){return(0,s.jsx)(ej,{table:"processes",columns:ea,label:"tree"===n?"Process tree":"Process list",caption:"tree"===n?"Process tree with nesting depth, PID, user, CPU per core, resident memory, GPU memory, read and write rates, and threads":"Processes with PID, user, CPU per core, resident memory, GPU memory, read and write rates, and threads",sort:t,onSort:r,children:e.map(({row:e,depth:t})=>(0,s.jsxs)("tr",{className:"transition-colors hover:bg-card-strong/60",children:[(0,s.jsx)(eN,{row:e,depth:t}),(0,s.jsx)("td",{className:ex,children:e.pid}),(0,s.jsx)("td",{className:`${eg} text-xs text-muted-foreground`,title:e.user??void 0,children:e.user??"—"}),(0,s.jsx)(ek,{value:e.cpuPercent,kind:"percent"}),(0,s.jsx)(ek,{value:e.memoryRssBytes,kind:"bytes"}),(0,s.jsx)(ek,{value:e.gpuMemoryBytes,kind:"bytes"}),(0,s.jsx)(ek,{value:e.ioReadBytesPerSec,kind:"rate"}),(0,s.jsx)(ek,{value:e.ioWriteBytesPerSec,kind:"rate"}),(0,s.jsx)("td",{className:ex,children:z(e.threads)})]},E(e)))})}function eP({group:e}){return(0,s.jsx)(s.Fragment,{children:e.members.map(e=>(0,s.jsxs)("tr",{className:"bg-card-strong/40 transition-colors hover:bg-card-strong/70",children:[(0,s.jsx)("th",{scope:"row",className:`${eg} text-left text-xs font-normal`,title:`${eM(e)} \xb7 PID ${e.pid}`,children:(0,s.jsxs)("span",{className:"pl-5",children:[e.name.length>0?e.name:"Unnamed process",(0,s.jsx)("span",{className:"tnum ml-2 text-muted-foreground",children:e.pid})]})}),(0,s.jsx)("td",{className:ex}),(0,s.jsx)(ek,{value:e.cpuPercent,kind:"percent"}),(0,s.jsx)(ek,{value:e.memoryRssBytes,kind:"bytes"}),(0,s.jsx)(ek,{value:e.gpuMemoryBytes,kind:"bytes"}),(0,s.jsx)(ek,{value:e.ioReadBytesPerSec,kind:"rate"}),(0,s.jsx)(ek,{value:e.ioWriteBytesPerSec,kind:"rate"}),(0,s.jsx)("td",{className:`${eg} text-xs text-muted-foreground`,title:e.user??void 0,children:e.user??"—"})]},E(e)))})}function eS({groups:e,sort:t,onSort:r,expanded:n,onToggleGroup:a}){return(0,s.jsx)(ej,{table:"applications",columns:en,label:"Applications",caption:"Applications grouped by systemd unit, process tree, or kernel, with process count, aggregate CPU per core, resident memory, GPU memory, read and write rates, and users",sort:t,onSort:r,children:e.map(e=>{var t;let r=n.has(e.key),i=e.label.length>0?e.label:"Unnamed application",l=e.users.length>0?e.users.join(", "):"—";return(0,s.jsxs)(g.Fragment,{children:[(0,s.jsxs)("tr",{className:"transition-colors hover:bg-card-strong/60",children:[(0,s.jsx)("th",{scope:"row",className:`${eg} text-left font-normal`,title:`${i} \xb7 ${"unit"===(t=e.kind)?"systemd unit":"kernel"===t?"kernel":"process tree"}`,children:(0,s.jsxs)("button",{type:"button","aria-expanded":r,onClick:()=>a(e.key),className:"inline-flex min-h-6 max-w-full items-center gap-1.5 rounded-sm text-left",children:[(0,s.jsx)(er.A,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform ${r?"rotate-90":""}`,"aria-hidden":!0}),(0,s.jsx)("span",{className:"truncate text-sm font-medium",children:i})]})}),(0,s.jsx)("td",{className:ex,children:z(e.count)}),(0,s.jsx)(ek,{value:e.cpuPercent,kind:"percent",partial:e.partial.cpuPercent}),(0,s.jsx)(ek,{value:e.memoryRssBytes,kind:"bytes",partial:e.partial.memoryRssBytes}),(0,s.jsx)(ek,{value:e.gpuMemoryBytes,kind:"bytes",partial:e.partial.gpuMemoryBytes}),(0,s.jsx)(ek,{value:e.ioReadBytesPerSec,kind:"rate",partial:e.partial.ioReadBytesPerSec}),(0,s.jsx)(ek,{value:e.ioWriteBytesPerSec,kind:"rate",partial:e.partial.ioWriteBytesPerSec}),(0,s.jsx)("td",{className:`${eg} text-xs text-muted-foreground`,title:l,children:l})]}),r?(0,s.jsx)(eP,{group:e}):null]},e.key)})})}function e$({mode:e,groups:t,rows:r,tree:n,sort:a,onSort:i,expanded:l,onToggleGroup:o}){if("applications"===e)return(0,s.jsx)(eS,{groups:t,sort:a,onSort:i,expanded:l,onToggleGroup:o});let c="tree"===e?n.map(e=>({row:e.row,depth:e.depth})):r.map(e=>({row:e,depth:0}));return(0,s.jsx)(eA,{entries:c,mode:e,sort:a,onSort:i})}var eR=r(1),eC=r(7499);let eB=[{key:"cpuPercent",label:"cpu"},{key:"memoryRssBytes",label:"memory"},{key:"gpuMemoryBytes",label:"vram"},{key:"ioReadBytesPerSec",label:"read"},{key:"ioWriteBytesPerSec",label:"write"},{key:"threads",label:"threads"}];function eT(e){return new Date(e).toISOString()}function eU(e){return e.displayName?.trim()||e.hostname.trim()||e.machineId}function eD(e){return"applications"===e.mode?e.groups.flatMap(t=>$([...t.members],e.sort.key,e.sort.dir).map(e=>({row:e,application:t.label,applicationKind:t.kind,depth:0}))):"tree"===e.mode?e.tree.map(e=>({row:e.row,application:null,applicationKind:null,depth:e.depth})):e.sortedRows.map(e=>({row:e,application:null,applicationKind:null,depth:0}))}function eW(e){let t=e.now??Date.now(),r=null===e.receivedAtMs?null:Math.max(0,t-e.receivedAtMs),s=null===r?"receipt time unknown":`${Math.round(r/1e3)}s old`;return null===e.receivedAtMs?{label:"unknown",ageMs:null,stale:!0,note:"No browser receipt time is available for this snapshot."}:"paused"===e.phase?{label:"paused",ageMs:r,stale:!1,note:`Paused \xb7 ${s}. Not live.`}:"disconnected"===e.phase?{label:"disconnected",ageMs:r,stale:!0,note:`Collector disconnected \xb7 last snapshot ${s}. Not live.`}:"withheld"===e.phase||"unsupported"===e.phase?{label:"not live",ageMs:r,stale:!0,note:`Process detail is ${e.phase} \xb7 last snapshot ${s}.`}:"failed"===e.phase||"expired"===e.phase||"busy"===e.phase||"cancelled"===e.phase||"error"===e.phase?{label:"not live",ageMs:r,stale:!0,note:`Refresh problem \xb7 last snapshot ${s}. Not live.`}:"acquiring"===e.phase||"loading"===e.phase||"idle"===e.phase?{label:"waiting",ageMs:r,stale:!0,note:`Waiting for a fresh snapshot \xb7 ${s}.`}:K(e.receivedAtMs,t,e.intervalMs)?{label:"stale",ageMs:r,stale:!0,note:`No new snapshot has arrived \xb7 ${s}. Not live.`}:{label:"live",ageMs:r,stale:!1,note:`Live \xb7 updated ${s}.`}}function eI(e){return eB.filter(({key:t})=>null===e[t]).map(({label:e})=>e).join(" ")}function eL(e,t){let r=eW({phase:e.phase,receivedAtMs:e.receivedAtMs,intervalMs:e.intervalMs,now:t}),s=null===e.receivedAtMs?"unknown":eT(e.receivedAtMs),n=e.query.trim();return[`Filtered process snapshot from the loaded view \xb7 ${r.note}`,`Search: ${n.length>0?n:"(none)"} \xb7 view: ${e.mode} \xb7 sort: ${e.sort.key} ${e.sort.dir}`,`Snapshot ${e.snapshot.processes.length} shown of ${e.snapshot.totalProcesses} processes \xb7 ${e.snapshot.inaccessible} unreadable${e.snapshot.truncated?" \xb7 collector kept the highest-CPU rows":""}`,`Captured ${e.capturedAt} \xb7 received ${s}`]}let eq=["name","pid","user","application","application_kind","tree_depth","cpu_percent","memory_rss_bytes","gpu_memory_bytes","io_read_bytes_per_sec","io_write_bytes_per_sec","threads","unavailable_metrics"],eK="inline-flex min-h-7 items-center rounded-md border border-border bg-background px-2 text-xs text-foreground transition-colors hover:bg-card-strong disabled:cursor-not-allowed disabled:opacity-50";function e_(e){let[t,r]=(0,g.useState)(null),n=null!==e.snapshot&&null!==e.capturedAt,a=n?"applications"===e.mode?e.filteredRows.length:"tree"===e.mode?e.tree.length:e.sortedRows.length:0,i=!n||0===a,l=t=>{if(null===e.snapshot||null===e.capturedAt)return;let s=Date.now(),n={...e,snapshot:e.snapshot,capturedAt:e.capturedAt,exportedAt:s};try{let e,i,l,o=function(e,t,r=Date.now()){let s=Date.parse(e.capturedAt);return(0,eC.Y8)("processes",eU(e.machine),Number.isFinite(s)?s:r,t)}(n,t,s),c="csv"===t?function(e){let t,r,s=e.exportedAt??Date.now(),n=(t=eD(e),r=eW({phase:e.phase,receivedAtMs:e.receivedAtMs,intervalMs:e.intervalMs,now:s}),[["Rigscope process snapshot"],["Scope",eL(e,s)[0]],["Machine",eU(e.machine)],["Machine ID",e.machine.machineId],["Snapshot captured",e.capturedAt],["Snapshot received",null===e.receivedAtMs?"unknown":eT(e.receivedAtMs)],["Freshness",`${r.label}${null===r.ageMs?"":` \xb7 ${Math.round(r.ageMs/1e3)}s old`}`],["Search",e.query.trim()||"(none)"],["View",e.mode],["Sort",`${e.sort.key} ${e.sort.dir}`],["Snapshot rows",`${e.snapshot.processes.length} shown of ${e.snapshot.totalProcesses}`],["Unreadable",String(e.snapshot.inaccessible)],["Collector truncated",e.snapshot.truncated?"true":"false"],["Exported rows",String(t.length)],["Note",eL(e,s).slice(1).join(" ")],[]]);for(let t of(n.push([...eq]),eD(e)))n.push(function(e){let{row:t}=e;return[t.name,t.pid,t.user,e.application,e.applicationKind,e.depth,t.cpuPercent,t.memoryRssBytes,t.gpuMemoryBytes,t.ioReadBytesPerSec,t.ioWriteBytesPerSec,t.threads,eI(t)]}(t));return(0,eR.kg)(n)}(n):(e=n.exportedAt??Date.now(),i=eW({phase:n.phase,receivedAtMs:n.receivedAtMs,intervalMs:n.intervalMs,now:e}),l={app:"Rigscope",kind:"processes",version:1,exportedAt:eT(e),scope:{description:"Filtered process snapshot from the loaded view",machine:{id:n.machine.machineId,name:eU(n.machine),hostname:n.machine.hostname,connected:n.machine.connected},query:n.query.trim(),view:n.mode,sort:n.sort},snapshot:{capturedAt:n.capturedAt,receivedAt:null===n.receivedAtMs?null:eT(n.receivedAtMs),ageMs:i.ageMs,freshness:i.label,live:!i.stale&&"live"===i.label,note:i.note,totalProcesses:n.snapshot.totalProcesses,shownProcesses:n.snapshot.processes.length,inaccessible:n.snapshot.inaccessible,truncated:n.snapshot.truncated},exportedRows:eD(n).length,notes:eL(n,e),processes:eD(n).map(e=>({name:e.row.name,pid:e.row.pid,user:e.row.user,application:e.application,applicationKind:e.applicationKind,treeDepth:e.depth,cpuPercent:e.row.cpuPercent,memoryRssBytes:e.row.memoryRssBytes,gpuMemoryBytes:e.row.gpuMemoryBytes,ioReadBytesPerSec:e.row.ioReadBytesPerSec,ioWriteBytesPerSec:e.row.ioWriteBytesPerSec,threads:e.row.threads,unavailableMetrics:eI(e.row).split(" ").filter(Boolean)}))},`${JSON.stringify(l,null,2)}
|
|
2
|
+
`}function o(e,t,r){if("u"<typeof document)return;let s=new Blob([t],{type:r}),n=URL.createObjectURL(s),a=document.createElement("a");a.href=n,a.download=e,a.rel="noopener",a.style.display="none",document.body.append(a),a.click(),a.remove(),globalThis.setTimeout(()=>URL.revokeObjectURL(n),0)}let c="text/csv;charset=utf-8",d="application/json;charset=utf-8"},438:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},2910:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]])},3381:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("CloudOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]])},4268:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},6582:(e,t,r)=>{"use strict";r.d(t,{E:()=>x,x:()=>g});var s=r(5155),n=r(8500),a=r.n(n),i=r(828),l=r(6914),o=r(7029),c=r(438),d=r(7422),u=r(1735),p=r(3440),h=r(9939);function m(e){return(0,s.jsxs)("button",{type:"button",onClick:e.onClick,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:[(0,s.jsx)(i.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.children]})}function f(e){return(0,s.jsx)(a(),{href:e.href,className:e.primary?"inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors hover:bg-accent/90":"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:e.children})}function g(){let{session:e,phase:t,retryConnection:r}=(0,h.M)();switch(e.kind){case"restoring":return(0,s.jsx)(p.Z,{title:"Checking session",className:"mx-auto my-12 max-w-md",children:(0,s.jsx)(p.p,{icon:l.A,note:"Checking your session…"})});case"restore-failed":return(0,s.jsxs)(p.Z,{title:"Hub unreachable",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(p.p,{icon:o.A,note:"The hub is unreachable right now."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(m,{onClick:r,children:"Check again"})})]});case"signed-out":if("expired"===t)return(0,s.jsxs)(p.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(p.p,{icon:c.A,note:"Your session ended."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(f,{href:"/login",primary:!0,children:"Sign in"})})]});return(0,s.jsxs)(p.Z,{title:"Sign in required",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(p.p,{icon:l.A,note:"Sign in required."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(f,{href:"/login",primary:!0,children:"Sign in"})})]});case"auth-unavailable":return(0,s.jsx)(p.Z,{title:"Sign-in unavailable",className:"mx-auto my-12 max-w-md",children:(0,s.jsx)(p.p,{icon:d.A,note:"Browser sign-in is not configured on this hub."})})}return"expired"===t?(0,s.jsxs)(p.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(p.p,{icon:c.A,note:"Your session ended."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(f,{href:"/login",primary:!0,children:"Sign in"})})]}):"no-permission"===t?(0,s.jsxs)(p.Z,{title:"No permission",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(p.p,{icon:d.A,note:`You are signed in as ${e.user.username}, but this hub grants no machine view to this account.`}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(m,{onClick:r,children:"Check again"})})]}):null}function x(){let{phase:e,retryConnection:t}=(0,h.M)();return"reconnecting"!==e&&"disconnected"!==e&&"connecting"!==e?null:"connecting"===e?(0,s.jsxs)("div",{role:"status",className:"mb-5 flex items-center gap-2 rounded-lg border border-border bg-card px-4 py-2.5 text-xs text-muted-foreground",children:[(0,s.jsx)(i.A,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),"Connecting to the live feed — waiting for the first snapshot."]}):(0,s.jsxs)("div",{role:"status",className:"mb-5 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border border-border bg-card px-4 py-2.5 text-xs text-muted-foreground",children:[(0,s.jsx)(u.A,{className:"h-3.5 w-3.5 shrink-0 text-warn","aria-hidden":!0}),(0,s.jsxs)("span",{children:["Connection lost — values below are ",(0,s.jsx)("strong",{className:"font-medium text-foreground",children:"last known"}),", not live measurements","reconnecting"===e?" — retrying with backoff…":" — retries stopped."]}),"disconnected"===e?(0,s.jsx)(m,{onClick:t,children:"Retry now"}):null]})}},7339:(e,t,r)=>{"use strict";r.d(t,{ProcessesView:()=>eX});var s=r(5155),n=r(8500),a=r.n(n),i=r(9926),l=r(3381),o=r(8731),c=r(4173),d=r(3440),u=r(940),p=r(802),h=r(6582),m=r(9939),f=r(8664),g=r(2115),x=r(828),b=r(7422),y=r(7029),w=r(2910),v=r(1735),j=r(9764),k=r(9664),M=r(4268),N=r(9942);let A=new Set(["bash","zsh","fish","sh","dash","ksh","mksh","tcsh","csh","ash","busybox"]),P=new Set(["sshd","sshd-session","dropbear","tmux","screen","systemd"]),S=["cpuPercent","memoryRssBytes","gpuMemoryBytes","ioReadBytesPerSec","ioWriteBytesPerSec"];function $(e,t,r){return e.slice().sort((e,s)=>W(D(e,t),D(s,t),r))}function R(e){return null!==e&&!!("init.scope"===e||/^session-.+\.scope$/.test(e)||/^user@.+\.service$/.test(e))}function C(e){return null===e||!e.endsWith(".scope")&&!e.endsWith(".service")||R(e)?null:e}function B(e){let t=e.replace(/\.(scope|service)$/,"");return t.startsWith("app-gnome-")?t=t.slice(10):t.startsWith("app-")&&(t=t.slice(4)),(t=t.replace(/-\d+$/,"")).length>0?t:e}function T(e){return{key:`tree:${e.pid}:${e.startTicks}`,label:e.name,kind:"tree",leader:e}}function U(e,t){switch(t){case"cpu":return e.cpuPercent;case"memory":return e.memoryRssBytes;case"gpuMemory":return e.gpuMemoryBytes;case"ioRead":return e.ioReadBytesPerSec;case"ioWrite":return e.ioWriteBytesPerSec;case"name":return e.label;case"count":return e.count;case"pid":var r=e.members;let s=null;for(let e of r)(null===s||e.pid<s)&&(s=e.pid);return s;case"user":return e.users.length>0?e.users[0]:null}}function D(e,t){switch(t){case"cpu":return e.cpuPercent;case"memory":return e.memoryRssBytes;case"gpuMemory":return e.gpuMemoryBytes;case"ioRead":return e.ioReadBytesPerSec;case"ioWrite":return e.ioWriteBytesPerSec;case"name":return e.name;case"count":return 1;case"pid":return e.pid;case"user":return e.user}}function W(e,t,r){let s,n=null==e,a=null==t;if(n&&a)return 0;if(n)return 1;if(a)return -1;if("number"==typeof e&&"number"==typeof t)s=e-t;else{let r=String(e).toLowerCase(),n=String(t).toLowerCase();s=r<n?-1:+(r>n)}return"asc"===r?s:-s}var I=r(592),L=r(7586);let q={key:"cpu",dir:"desc"};function K(e,t,r){return null!==e&&t-e>=(!Number.isFinite(r)||r<=0?1e4:Math.max(1e4,3*r))}let _=[{value:"applications",label:"Applications"},{value:"processes",label:"Processes"},{value:"tree",label:"Tree"}];function E(e){return`${e.pid}:${e.startTicks}`}function F(e){if(void 0===e.command)return e;let{command:t,...r}=e;return r}function z(e){return null!=e&&Number.isFinite(e)?Math.round(e).toString().replace(/\B(?=(\d{3})+(?!\d))/g,","):"—"}function O(e){switch(e){case"idle":return{label:"Not connected",tone:"muted",description:"Select a machine to request process detail.",retryable:!1};case"acquiring":return{label:"Connecting",tone:"warn",description:"Requesting process detail…",retryable:!1};case"loading":return{label:"Waiting",tone:"warn",description:"Waiting for the collector's first process snapshot…",retryable:!1};case"ready":return{label:"Live",tone:"ok",description:"Process detail is live.",retryable:!1};case"paused":return{label:"Paused",tone:"muted",description:"Process updates are paused.",retryable:!1};case"stale":return{label:"Not refreshing",tone:"warn",description:"The last snapshot is retained, but new snapshots are not arriving.",retryable:!0};case"disconnected":return{label:"Disconnected",tone:"crit",description:"The collector is disconnected; the last snapshot is not live.",retryable:!0};case"withheld":return{label:"Withheld",tone:"warn",description:"Process detail is withheld for this hub.",retryable:!0};case"unsupported":return{label:"Unsupported",tone:"warn",description:"This collector cannot provide process detail.",retryable:!0};case"busy":return{label:"Busy",tone:"warn",description:"Too many process views are open for this hub.",retryable:!0};case"expired":return{label:"Expired",tone:"warn",description:"Process detail expired before a fresh snapshot arrived.",retryable:!0};case"failed":return{label:"Scan failed",tone:"crit",description:"The process scan failed repeatedly.",retryable:!0};case"cancelled":return{label:"Stopped",tone:"muted",description:"The process detail view was stopped.",retryable:!0};case"error":return{label:"Unavailable",tone:"crit",description:"Process detail is unavailable right now.",retryable:!0}}}function V(e){return"number"==typeof e&&Number.isFinite(e)&&e>0}var Z=r(7348);class G{maxAgeMs;limit;session=null;entries=new Map;constructor(e=3e5,t=32){this.maxAgeMs=e,this.limit=t}scope(e){(this.session!==e||null===e)&&this.entries.clear(),this.session=e}get(e,t,r=Date.now()){this.scope(t);let s=this.entries.get(e);return s&&r-s.lastReceivedMs>=this.maxAgeMs?void this.entries.delete(e):s}set(e,t,r){this.scope(t),this.entries.delete(e),this.entries.set(e,r),this.entries.size>this.limit&&this.entries.delete(this.entries.keys().next().value)}delete(e,t){this.scope(t),this.entries.delete(e)}}let Y=new G;function X(e,t){let r=Y.get(e??"",t);return void 0!==r?{phase:"stale",message:"Resuming process updates…",...r}:{phase:null===e?"idle":"acquiring",detail:null,message:null,intervalMs:1e3,leaseMs:15e3,lastReceivedMs:null}}async function J(e){try{let t=await e.json();if(t&&"object"==typeof t&&"error"in t){let e=t.error;if("string"==typeof e&&e.length>0)return e}}catch{}return e.statusText||null}var H=r(8698);let Q=(0,H.A)("ChevronsUpDown",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]),ee=(0,H.A)("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),et=(0,H.A)("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);var er=r(8528),es=r(6114);let en=[{id:"name",label:"Application",sortKey:"name",align:"left",width:300},{id:"count",label:"Procs",sortKey:"count",align:"right",width:76},{id:"cpu",label:"CPU / core",sortKey:"cpu",align:"right",width:104},{id:"memory",label:"RSS",sortKey:"memory",align:"right",width:96},{id:"gpuMemory",label:"VRAM",sortKey:"gpuMemory",align:"right",width:96},{id:"ioRead",label:"Read",sortKey:"ioRead",align:"right",width:104},{id:"ioWrite",label:"Write",sortKey:"ioWrite",align:"right",width:104},{id:"users",label:"Users",sortKey:"user",align:"left",width:160}],ea=[{id:"name",label:"Process",sortKey:"name",align:"left",width:300},{id:"pid",label:"PID",sortKey:"pid",align:"right",width:84},{id:"user",label:"User",sortKey:"user",align:"left",width:120},{id:"cpu",label:"CPU / core",sortKey:"cpu",align:"right",width:104},{id:"memory",label:"RSS",sortKey:"memory",align:"right",width:96},{id:"gpuMemory",label:"VRAM",sortKey:"gpuMemory",align:"right",width:96},{id:"ioRead",label:"Read",sortKey:"ioRead",align:"right",width:104},{id:"ioWrite",label:"Write",sortKey:"ioWrite",align:"right",width:104},{id:"threads",label:"Threads",align:"right",width:84}],ei=Object.freeze({}),el=Object.freeze([]),eo=new Set(["cpu","memory","gpuMemory","ioRead","ioWrite","name","count","pid","user"]);function ec(e){return Math.round(Math.min(1200,Math.max(56,e)))}function ed(e){return"applications"===e||"processes"===e||"tree"===e?e:null}function eu(e){if(null===e||"object"!=typeof e)return null;let{key:t,dir:r}=e;return"string"==typeof t&&eo.has(t)&&("asc"===r||"desc"===r)?{key:t,dir:r}:null}function ep(e){if(null===e||"object"!=typeof e||Array.isArray(e))return null;let t={};for(let[r,s]of Object.entries(e))"number"==typeof s&&Number.isFinite(s)&&(t[r]=ec(s));return t}function eh(e){return"string"==typeof e?e.slice(0,200):null}function em(e){return"boolean"==typeof e?e:null}function ef(e){return Array.isArray(e)&&e.every(e=>"string"==typeof e)?e.slice(0,500):null}let eg="overflow-hidden text-ellipsis whitespace-nowrap border-b border-border px-2 py-2 align-middle",ex=`${eg} tnum text-right text-xs`,eb="relative overflow-hidden whitespace-nowrap border-b border-border px-2 py-2 text-left text-xs font-normal text-muted-foreground";function ey(e,t){return t[e.id]??e.width}function ew({label:e,width:t,onChange:r,onReset:n}){let a=(0,g.useRef)(null);return(0,s.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e} column`,"aria-valuenow":t,"aria-valuemin":56,"aria-valuemax":1200,tabIndex:0,title:"Drag to resize \xb7 double-click to reset",onPointerDown:e=>{0===e.button&&(e.preventDefault(),e.stopPropagation(),e.currentTarget.setPointerCapture(e.pointerId),a.current={x:e.clientX,width:t})},onPointerMove:e=>{null!==a.current&&r(ec(a.current.width+e.clientX-a.current.x))},onPointerUp:e=>{null!==a.current&&r(ec(a.current.width+e.clientX-a.current.x)),a.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)},onPointerCancel:()=>{a.current=null},onLostPointerCapture:()=>{a.current=null},onClick:e=>e.stopPropagation(),onDoubleClick:e=>{e.stopPropagation(),n()},onKeyDown:e=>{"ArrowLeft"===e.key?(e.preventDefault(),r(ec(t-16))):"ArrowRight"===e.key&&(e.preventDefault(),r(ec(t+16)))},className:"group/handle absolute inset-y-0 right-0 z-10 flex w-2.5 cursor-col-resize touch-none select-none justify-end",children:(0,s.jsx)("span",{"aria-hidden":!0,className:"my-2 w-px bg-border transition-colors group-hover/handle:bg-accent group-focus-visible/handle:bg-accent"})})}function ev({column:e,sort:t,onSort:r,width:n,onResize:a,onReset:i}){let l="right"===e.align,o=e.sortKey,c=void 0!==o?t.key!==o?"none":"asc"===t.dir?"ascending":"descending":"none",d="none"!==c,u=d?"asc"===t.dir?ee:et:Q;return(0,s.jsxs)("th",{scope:"col","aria-sort":void 0!==o?c:void 0,className:l?`${eb} text-right`:eb,children:[void 0!==o?(0,s.jsxs)("button",{type:"button",onClick:()=>r(o),className:["inline-flex min-h-6 max-w-full items-center gap-1 rounded-sm transition-colors hover:text-foreground",l?"w-full justify-end pr-1":"",d?"text-foreground":""].filter(Boolean).join(" "),children:[(0,s.jsx)("span",{className:"truncate",children:e.label}),(0,s.jsx)(u,{className:d?"h-3 w-3 shrink-0":"h-3 w-3 shrink-0 opacity-40","aria-hidden":!0})]}):(0,s.jsx)("span",{className:l?"block truncate pr-1":"block truncate",children:e.label}),(0,s.jsx)(ew,{label:e.label,width:n,onChange:a,onReset:i})]})}function ej({table:e,columns:t,label:r,caption:n,sort:a,onSort:i,children:l}){let[o,c]=(0,es.u)(`processes.widths.${e}`,ei,ep),d=(0,g.useRef)(null),[u,p]=(0,g.useState)(0);(0,g.useEffect)(()=>{let e=d.current;if(!e)return;let t=new ResizeObserver(([e])=>p(e.contentRect.width));return t.observe(e),()=>t.disconnect()},[]);let h=e=>"name"===e.id?160:56,m=t.reduce((e,t)=>e+h(t),0),f=t.reduce((e,t)=>e+ey(t,o),0),x={},b=Math.max(u||f,m),y=[...t];for(;y.length>0;){let e=y.reduce((e,t)=>e+ey(t,o),0),t=y.filter(t=>b*ey(t,o)/e<h(t));if(0===t.length){for(let t of y)x[t.id]=b*ey(t,o)/e;break}for(let e of t)x[e.id]=h(e),b-=h(e);y=y.filter(e=>!t.includes(e))}return(0,s.jsx)("div",{ref:d,className:"relative min-h-0 w-full min-w-0 flex-1 overflow-auto overscroll-contain",tabIndex:0,role:"region","aria-label":r,children:(0,s.jsxs)("table",{className:"table-fixed border-separate border-spacing-0 text-left",style:{width:"100%",minWidth:m},children:[(0,s.jsx)("caption",{className:"sr-only",children:n}),(0,s.jsx)("colgroup",{children:t.map(e=>(0,s.jsx)("col",{style:{width:x[e.id]}},e.id))}),(0,s.jsx)("thead",{className:"sticky top-0 z-20 bg-card",children:(0,s.jsx)("tr",{children:t.map(e=>(0,s.jsx)(ev,{column:e,sort:a,onSort:i,width:x[e.id],onResize:r=>{let s,n,a;return s=t.indexOf(e),n=t[s+1]??t[s-1],a=Math.max(h(e)-x[e.id],Math.min(r-x[e.id],x[n.id]-h(n))),void c({...x,[e.id]:x[e.id]+a,[n.id]:x[n.id]-a})},onReset:()=>c(t=>{let{[e.id]:r,...s}=t;return s})},e.id))})}),(0,s.jsx)("tbody",{children:l})]})})}function ek({value:e,kind:t,partial:r=!1}){let n=function(e,t,r=!1){let s;if(null===e||!Number.isFinite(e)||e<0)return{text:"—",atLeast:!1,title:null};switch(t){case"percent":s=(0,L.l9)(e);break;case"bytes":s=(0,L.z3)(e);break;case"rate":s=`${(0,L.z3)(e)}/s`;break;case"count":s=z(e)}return{text:s,atLeast:r,title:r?`At least ${s}: some processes in this group did not report this metric.`:null}}(e,t,r);return(0,s.jsxs)("td",{className:"—"===n.text?`${ex} text-muted-foreground`:ex,title:n.title??void 0,children:[n.atLeast?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{"aria-hidden":!0,children:"≥ "}),(0,s.jsx)("span",{className:"sr-only",children:"at least "})]}):null,n.text]})}function eM(e){let t=e.name.length>0?e.name:"Unnamed process";return null!==e.unit?`${t} \xb7 ${e.unit}`:t}function eN({row:e,depth:t=0}){return(0,s.jsx)("th",{scope:"row",className:`${eg} text-left text-sm font-medium`,title:eM(e),children:(0,s.jsxs)("span",{style:t>0?{paddingLeft:`${14*t}px`}:void 0,children:[t>0?(0,s.jsx)("span",{className:"sr-only",children:`Nested level ${t+1}. `}):null,e.name.length>0?e.name:(0,s.jsx)("span",{className:"text-muted-foreground",children:"Unnamed process"})]})})}function eA({entries:e,sort:t,onSort:r,mode:n}){return(0,s.jsx)(ej,{table:"processes",columns:ea,label:"tree"===n?"Process tree":"Process list",caption:"tree"===n?"Process tree with nesting depth, PID, user, CPU per core, resident memory, GPU memory, read and write rates, and threads":"Processes with PID, user, CPU per core, resident memory, GPU memory, read and write rates, and threads",sort:t,onSort:r,children:e.map(({row:e,depth:t})=>(0,s.jsxs)("tr",{className:"transition-colors hover:bg-card-strong/60",children:[(0,s.jsx)(eN,{row:e,depth:t}),(0,s.jsx)("td",{className:ex,children:e.pid}),(0,s.jsx)("td",{className:`${eg} text-xs text-muted-foreground`,title:e.user??void 0,children:e.user??"—"}),(0,s.jsx)(ek,{value:e.cpuPercent,kind:"percent"}),(0,s.jsx)(ek,{value:e.memoryRssBytes,kind:"bytes"}),(0,s.jsx)(ek,{value:e.gpuMemoryBytes,kind:"bytes"}),(0,s.jsx)(ek,{value:e.ioReadBytesPerSec,kind:"rate"}),(0,s.jsx)(ek,{value:e.ioWriteBytesPerSec,kind:"rate"}),(0,s.jsx)("td",{className:ex,children:z(e.threads)})]},E(e)))})}function eP({group:e}){return(0,s.jsx)(s.Fragment,{children:e.members.map(e=>(0,s.jsxs)("tr",{className:"bg-card-strong/40 transition-colors hover:bg-card-strong/70",children:[(0,s.jsx)("th",{scope:"row",className:`${eg} text-left text-xs font-normal`,title:`${eM(e)} \xb7 PID ${e.pid}`,children:(0,s.jsxs)("span",{className:"pl-5",children:[e.name.length>0?e.name:"Unnamed process",(0,s.jsx)("span",{className:"tnum ml-2 text-muted-foreground",children:e.pid})]})}),(0,s.jsx)("td",{className:ex}),(0,s.jsx)(ek,{value:e.cpuPercent,kind:"percent"}),(0,s.jsx)(ek,{value:e.memoryRssBytes,kind:"bytes"}),(0,s.jsx)(ek,{value:e.gpuMemoryBytes,kind:"bytes"}),(0,s.jsx)(ek,{value:e.ioReadBytesPerSec,kind:"rate"}),(0,s.jsx)(ek,{value:e.ioWriteBytesPerSec,kind:"rate"}),(0,s.jsx)("td",{className:`${eg} text-xs text-muted-foreground`,title:e.user??void 0,children:e.user??"—"})]},E(e)))})}function eS({groups:e,sort:t,onSort:r,expanded:n,onToggleGroup:a}){return(0,s.jsx)(ej,{table:"applications",columns:en,label:"Applications",caption:"Applications grouped by systemd unit, process tree, or kernel, with process count, aggregate CPU per core, resident memory, GPU memory, read and write rates, and users",sort:t,onSort:r,children:e.map(e=>{var t;let r=n.has(e.key),i=e.label.length>0?e.label:"Unnamed application",l=e.users.length>0?e.users.join(", "):"—";return(0,s.jsxs)(g.Fragment,{children:[(0,s.jsxs)("tr",{className:"transition-colors hover:bg-card-strong/60",children:[(0,s.jsx)("th",{scope:"row",className:`${eg} text-left font-normal`,title:`${i} \xb7 ${"unit"===(t=e.kind)?"systemd unit":"kernel"===t?"kernel":"process tree"}`,children:(0,s.jsxs)("button",{type:"button","aria-expanded":r,onClick:()=>a(e.key),className:"inline-flex min-h-6 max-w-full items-center gap-1.5 rounded-sm text-left",children:[(0,s.jsx)(er.A,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform ${r?"rotate-90":""}`,"aria-hidden":!0}),(0,s.jsx)("span",{className:"truncate text-sm font-medium",children:i})]})}),(0,s.jsx)("td",{className:ex,children:z(e.count)}),(0,s.jsx)(ek,{value:e.cpuPercent,kind:"percent",partial:e.partial.cpuPercent}),(0,s.jsx)(ek,{value:e.memoryRssBytes,kind:"bytes",partial:e.partial.memoryRssBytes}),(0,s.jsx)(ek,{value:e.gpuMemoryBytes,kind:"bytes",partial:e.partial.gpuMemoryBytes}),(0,s.jsx)(ek,{value:e.ioReadBytesPerSec,kind:"rate",partial:e.partial.ioReadBytesPerSec}),(0,s.jsx)(ek,{value:e.ioWriteBytesPerSec,kind:"rate",partial:e.partial.ioWriteBytesPerSec}),(0,s.jsx)("td",{className:`${eg} text-xs text-muted-foreground`,title:l,children:l})]}),r?(0,s.jsx)(eP,{group:e}):null]},e.key)})})}function e$({mode:e,groups:t,rows:r,tree:n,sort:a,onSort:i,expanded:l,onToggleGroup:o}){if("applications"===e)return(0,s.jsx)(eS,{groups:t,sort:a,onSort:i,expanded:l,onToggleGroup:o});let c="tree"===e?n.map(e=>({row:e.row,depth:e.depth})):r.map(e=>({row:e,depth:0}));return(0,s.jsx)(eA,{entries:c,mode:e,sort:a,onSort:i})}var eR=r(1),eC=r(7499);let eB=[{key:"cpuPercent",label:"cpu"},{key:"memoryRssBytes",label:"memory"},{key:"gpuMemoryBytes",label:"vram"},{key:"ioReadBytesPerSec",label:"read"},{key:"ioWriteBytesPerSec",label:"write"},{key:"threads",label:"threads"}];function eT(e){return new Date(e).toISOString()}function eU(e){return e.displayName?.trim()||e.hostname.trim()||e.machineId}function eD(e){return"applications"===e.mode?e.groups.flatMap(t=>$([...t.members],e.sort.key,e.sort.dir).map(e=>({row:e,application:t.label,applicationKind:t.kind,depth:0}))):"tree"===e.mode?e.tree.map(e=>({row:e.row,application:null,applicationKind:null,depth:e.depth})):e.sortedRows.map(e=>({row:e,application:null,applicationKind:null,depth:0}))}function eW(e){let t=e.now??Date.now(),r=null===e.receivedAtMs?null:Math.max(0,t-e.receivedAtMs),s=null===r?"receipt time unknown":`${Math.round(r/1e3)}s old`;return null===e.receivedAtMs?{label:"unknown",ageMs:null,stale:!0,note:"No browser receipt time is available for this snapshot."}:"paused"===e.phase?{label:"paused",ageMs:r,stale:!1,note:`Paused \xb7 ${s}. Not live.`}:"disconnected"===e.phase?{label:"disconnected",ageMs:r,stale:!0,note:`Collector disconnected \xb7 last snapshot ${s}. Not live.`}:"withheld"===e.phase||"unsupported"===e.phase?{label:"not live",ageMs:r,stale:!0,note:`Process detail is ${e.phase} \xb7 last snapshot ${s}.`}:"failed"===e.phase||"expired"===e.phase||"busy"===e.phase||"cancelled"===e.phase||"error"===e.phase?{label:"not live",ageMs:r,stale:!0,note:`Refresh problem \xb7 last snapshot ${s}. Not live.`}:"acquiring"===e.phase||"loading"===e.phase||"idle"===e.phase?{label:"waiting",ageMs:r,stale:!0,note:`Waiting for a fresh snapshot \xb7 ${s}.`}:K(e.receivedAtMs,t,e.intervalMs)?{label:"stale",ageMs:r,stale:!0,note:`No new snapshot has arrived \xb7 ${s}. Not live.`}:{label:"live",ageMs:r,stale:!1,note:`Live \xb7 updated ${s}.`}}function eI(e){return eB.filter(({key:t})=>null===e[t]).map(({label:e})=>e).join(" ")}function eL(e,t){let r=eW({phase:e.phase,receivedAtMs:e.receivedAtMs,intervalMs:e.intervalMs,now:t}),s=null===e.receivedAtMs?"unknown":eT(e.receivedAtMs),n=e.query.trim();return[`Filtered process snapshot from the loaded view \xb7 ${r.note}`,`Search: ${n.length>0?n:"(none)"} \xb7 view: ${e.mode} \xb7 sort: ${e.sort.key} ${e.sort.dir}`,`Snapshot ${e.snapshot.processes.length} shown of ${e.snapshot.totalProcesses} processes \xb7 ${e.snapshot.inaccessible} unreadable${e.snapshot.truncated?" \xb7 collector kept the highest-CPU rows":""}`,`Captured ${e.capturedAt} \xb7 received ${s}`]}let eq=["name","pid","user","application","application_kind","tree_depth","cpu_percent","memory_rss_bytes","gpu_memory_bytes","io_read_bytes_per_sec","io_write_bytes_per_sec","threads","unavailable_metrics"],eK="inline-flex min-h-7 items-center rounded-md border border-border bg-background px-2 text-xs text-foreground transition-colors hover:bg-card-strong disabled:cursor-not-allowed disabled:opacity-50";function e_(e){let[t,r]=(0,g.useState)(null),n=null!==e.snapshot&&null!==e.capturedAt,a=n?"applications"===e.mode?e.filteredRows.length:"tree"===e.mode?e.tree.length:e.sortedRows.length:0,i=!n||0===a,l=t=>{if(null===e.snapshot||null===e.capturedAt)return;let s=Date.now(),n={...e,snapshot:e.snapshot,capturedAt:e.capturedAt,exportedAt:s};try{let e,i,l,o=function(e,t,r=Date.now()){let s=Date.parse(e.capturedAt);return(0,eC.Y8)("processes",eU(e.machine),Number.isFinite(s)?s:r,t)}(n,t,s),c="csv"===t?function(e){let t,r,s=e.exportedAt??Date.now(),n=(t=eD(e),r=eW({phase:e.phase,receivedAtMs:e.receivedAtMs,intervalMs:e.intervalMs,now:s}),[["Rigscope process snapshot"],["Scope",eL(e,s)[0]],["Machine",eU(e.machine)],["Machine ID",e.machine.machineId],["Snapshot captured",e.capturedAt],["Snapshot received",null===e.receivedAtMs?"unknown":eT(e.receivedAtMs)],["Freshness",`${r.label}${null===r.ageMs?"":` \xb7 ${Math.round(r.ageMs/1e3)}s old`}`],["Search",e.query.trim()||"(none)"],["View",e.mode],["Sort",`${e.sort.key} ${e.sort.dir}`],["Snapshot rows",`${e.snapshot.processes.length} shown of ${e.snapshot.totalProcesses}`],["Unreadable",String(e.snapshot.inaccessible)],["Collector truncated",e.snapshot.truncated?"true":"false"],["Exported rows",String(t.length)],["Note",eL(e,s).slice(1).join(" ")],[]]);for(let t of(n.push([...eq]),eD(e)))n.push(function(e){let{row:t}=e;return[t.name,t.pid,t.user,e.application,e.applicationKind,e.depth,t.cpuPercent,t.memoryRssBytes,t.gpuMemoryBytes,t.ioReadBytesPerSec,t.ioWriteBytesPerSec,t.threads,eI(t)]}(t));return(0,eR.kg)(n)}(n):(e=n.exportedAt??Date.now(),i=eW({phase:n.phase,receivedAtMs:n.receivedAtMs,intervalMs:n.intervalMs,now:e}),l={app:"Rigscope",kind:"processes",exportedAt:eT(e),scope:{description:"Filtered process snapshot from the loaded view",machine:{id:n.machine.machineId,name:eU(n.machine),hostname:n.machine.hostname,connected:n.machine.connected},query:n.query.trim(),view:n.mode,sort:n.sort},snapshot:{capturedAt:n.capturedAt,receivedAt:null===n.receivedAtMs?null:eT(n.receivedAtMs),ageMs:i.ageMs,freshness:i.label,live:!i.stale&&"live"===i.label,note:i.note,totalProcesses:n.snapshot.totalProcesses,shownProcesses:n.snapshot.processes.length,inaccessible:n.snapshot.inaccessible,truncated:n.snapshot.truncated},exportedRows:eD(n).length,notes:eL(n,e),processes:eD(n).map(e=>({name:e.row.name,pid:e.row.pid,user:e.row.user,application:e.application,applicationKind:e.applicationKind,treeDepth:e.depth,cpuPercent:e.row.cpuPercent,memoryRssBytes:e.row.memoryRssBytes,gpuMemoryBytes:e.row.gpuMemoryBytes,ioReadBytesPerSec:e.row.ioReadBytesPerSec,ioWriteBytesPerSec:e.row.ioWriteBytesPerSec,threads:e.row.threads,unavailableMetrics:eI(e.row).split(" ").filter(Boolean)}))},`${JSON.stringify(l,null,2)}
|
|
3
3
|
`);(0,eR.PE)(o,c,"csv"===t?eR.UR:eR.uW),r(`${t.toUpperCase()} downloaded \xb7 ${a} ${1===a?"process":"processes"}`)}catch{r("The process export could not be created.")}},o=n?0===a?"No processes match the current search":void 0:"A process snapshot is not available yet";return(0,s.jsxs)("div",{className:"flex min-w-0 shrink-0 items-center gap-1.5",children:[(0,s.jsx)("span",{className:"hidden text-xs text-muted-foreground sm:inline",children:"Export"}),(0,s.jsx)("button",{type:"button",onClick:()=>l("csv"),disabled:i,"aria-label":"Download current process snapshot as CSV",title:o??"Download the filtered process snapshot as CSV",className:eK,children:"CSV"}),(0,s.jsx)("button",{type:"button",onClick:()=>l("json"),disabled:i,"aria-label":"Download current process snapshot as JSON",title:o??"Download the filtered process snapshot as JSON",className:eK,children:"JSON"}),(0,s.jsxs)("span",{role:"status",className:t?.includes("could not")?"inline-flex items-center gap-1 text-xs text-warn":"sr-only",children:[t?.includes("could not")?(0,s.jsx)(v.A,{className:"h-3 w-3","aria-hidden":!0}):null,t??""]})]})}let eE={ok:"bg-ok-soft text-ok",warn:"bg-warn-soft text-warn",crit:"bg-crit-soft text-crit",muted:"border border-border text-muted-foreground"};function eF({phase:e,message:t}){return(0,s.jsxs)("span",{title:t??e.description,className:`inline-flex h-6 w-32 shrink-0 items-center gap-1.5 rounded-full px-2 py-0.5 text-xs ${eE[e.tone]}`,children:[(0,s.jsx)("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-current","aria-hidden":!0}),e.label]})}function ez({onClick:e,label:t="Check again"}){return(0,s.jsxs)("button",{type:"button",onClick:e,className:"inline-flex min-h-5 items-center gap-1.5 rounded-md border border-border bg-card px-2 py-1 text-xs text-foreground transition-colors hover:bg-card-strong",children:[(0,s.jsx)(x.A,{className:"h-3 w-3","aria-hidden":!0}),t]})}function eO({phase:e,info:t,message:r,onRetry:n}){let a="withheld"===e||"unsupported"===e?b.A:"disconnected"===e||"error"===e?y.A:"paused"===e?w.A:"acquiring"===e||"loading"===e?i.A:"busy"===e||"expired"===e||"failed"===e||"stale"===e?v.A:j.A;return(0,s.jsxs)("div",{className:"flex flex-col items-center gap-2 break-words",children:[(0,s.jsx)(d.p,{icon:a,note:r??t.description,className:"min-h-64 w-full"}),"paused"!==e&&t.retryable?(0,s.jsx)(ez,{onClick:n,label:"Retry process detail"}):null]})}function eV({summary:e,lastReceivedMs:t,intervalMs:r,message:n,phase:a,hasSnapshot:i}){let l=(0,Z.c)(1e3),o="ready"===a&&K(t,l,r),c=o?"stale":a,d="paused"===c,u=O(c),p=null===t?null:(0,L.nV)(Math.max(0,l-t)),h=null===p?null:"ready"===c?`Updated ${p}`:`Last snapshot ${p}`,m=d?i?"Paused. This snapshot is not live.":"Paused. Use Resume to request a fresh snapshot.":`${u.label}${o?". No new snapshot has arrived.":""}${n?`. ${n}`:""}`;return d&&!i?(0,s.jsx)("p",{role:"status",className:"sr-only",children:m}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{role:"status",className:"sr-only",children:m}),(0,s.jsxs)("div",{className:"flex min-h-6 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[d?(0,s.jsx)("span",{children:"Paused — not live"}):(0,s.jsx)(eF,{phase:u,message:n}),i&&null!==h?(0,s.jsx)("span",{className:"tnum",children:h}):null,i&&e.truncated?(0,s.jsxs)("span",{className:"tnum",title:"The collector kept the highest-CPU rows",children:["top ",z(e.shown)," of ",z(e.total)]}):null,i&&e.inaccessible>0?(0,s.jsxs)("span",{className:"tnum text-warn",children:[z(e.inaccessible)," unreadable"]}):null]})]})}function eZ({machine:e,csrfToken:t,paused:r,onPausedChange:n}){var a;let[i,l]=(0,es.u)("processes.query","",eh,"session"),o=(0,g.useDeferredValue)(i),[c,u]=(0,es.u)("processes.mode","applications",ed),[p,h]=(a="applications"===c?"applications":"processes",(0,es.u)(`processes.sort.${a}`,q,eu)),[m,f]=(0,es.u)("processes.expanded",el,ef,"session"),x=(0,g.useMemo)(()=>new Set(m),[m]),{state:b,refresh:y}=function(e){let{machineId:t,csrfToken:r,paused:s}=e,[n,a]=(0,g.useState)(()=>"u">typeof document&&document.hidden),[i,l]=(0,g.useState)(0),[o,c]=(0,g.useState)(()=>X(t,r)),d=(0,g.useRef)(o),u=(0,g.useRef)({machineId:t,csrfToken:r}),p=(0,g.useRef)(0),h=(0,g.useCallback)(()=>{p.current+=1,l(p.current)},[]);return(0,g.useEffect)(()=>{if("u"<typeof document)return;let e=()=>a(document.hidden);return e(),document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[]),(0,g.useEffect)(()=>{let e;if(u.current.machineId!==t||u.current.csrfToken!==r){u.current={machineId:t,csrfToken:r};let e=X(t,r);d.current=e,c(e)}if(!(null!==t&&null!==r&&!s&&!n)){if(t&&r){let e={...d.current,phase:"paused",message:n?"This tab is hidden — process updates are stopped until it is visible again.":"Paused — process updates are stopped until you resume."};d.current=e,c(e)}else{let e=X(t,r);d.current=e,c(e)}return}let a=!1,i=new AbortController,l=(e=globalThis.crypto)&&"function"==typeof e.randomUUID?e.randomUUID():`viewer-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`,o=`/api/processes?machineId=${encodeURIComponent(t)}&viewerId=${encodeURIComponent(l)}`,p=d.current.intervalMs||1e3,h=d.current.leaseMs||15e3,m=null!==d.current.detail,f=!1,g=!1,x=!1,b=null,y=null,w=null,v=e=>{if(a)return;let s=d.current,n="function"==typeof e?e(s):e,i={...s,...n};d.current=i,null!==i.detail&&null!==i.lastReceivedMs&&Y.set(t,r,{detail:i.detail,intervalMs:i.intervalMs,leaseMs:i.leaseMs,lastReceivedMs:i.lastReceivedMs}),c(i)},j=()=>{null!==b&&(clearTimeout(b),b=null),null!==y&&(clearTimeout(y),y=null),w?.abort(),w=null},k=()=>{try{fetch(o,{method:"DELETE",cache:"no-store",keepalive:!0,headers:{"X-CSRF-Token":r,Accept:"application/json"}}).catch(()=>void 0)}catch{}},M=()=>{g=!1,null!==b&&(clearTimeout(b),b=null)},N=(e,s)=>{x=!0,j(),m=!1,Y.delete(t,r),v({phase:e,detail:null,message:s,lastReceivedMs:null}),k()},A=e=>{let t="u">typeof navigator&&!1===navigator.onLine;v({phase:m?t?"disconnected":"stale":"error",message:e})},P=async()=>{try{let e=await fetch(o,{method:"POST",cache:"no-store",signal:i.signal,headers:{"X-CSRF-Token":r,Accept:"application/json"}});if(a||i.signal.aborted)return!1;if(!e.ok){M();let t=await J(e);return 401===e.status?N("error","Your session ended. Sign in again to inspect processes."):403===e.status?N("withheld",t??"Processes are not available to this hub."):409===e.status?N("unsupported",t??"This collector requires an upgrade before Processes is available."):(429===e.status||503===e.status)&&/budget/i.test(t??"")?v({phase:"busy",message:t??"Too many process views are open for this hub."}):A(t??`Could not request process detail (HTTP ${e.status}).`),!1}g=!0;let t=null;try{t=await e.json()}catch{t=null}let s=function(e){if(null===e||"object"!=typeof e||Array.isArray(e))return null;let t=e.leaseMs,r=e.intervalMs;return V(t)&&V(r)?{leaseMs:Math.round(t),intervalMs:Math.round(r)}:null}(t);if(null===s)return M(),k(),A("The hub returned an unexpected response."),!1;if(a||i.signal.aborted)return!1;return p=s.intervalMs,h=s.leaseMs,v(e=>({intervalMs:s.intervalMs,leaseMs:s.leaseMs,phase:null===e.detail?"loading":e.phase,message:null})),!0}catch(e){if(a||i.signal.aborted)return!1;return M(),A(m?"Could not refresh process detail. Showing the last snapshot, which is not live.":"Could not reach the hub for process detail."),!1}},S=()=>{a||x||null!==y||(y=setTimeout(()=>{y=null,$()},Math.max(1e3,Math.min(5e3,Math.floor(h/3)))))},$=async()=>{a||x||(await P(),a||x||(g&&!f&&null===b&&R(),S()))},R=async()=>{if(a||x||f)return;f=!0;let e=new AbortController;w=e;let t=()=>e.abort();i.signal.addEventListener("abort",t,{once:!0});try{let t=await fetch(o,{cache:"no-store",signal:e.signal,headers:{Accept:"application/json"}});if(a||e.signal.aborted)return;if(410===t.status){v({phase:m?"stale":"loading",message:"Process detail expired. Renewing…"}),await P();return}if(!t.ok){let e=await J(t);401===t.status?N("error","Your session ended. Sign in again to inspect processes."):403===t.status?N("withheld",e??"Processes are not available to this machine."):A(e??`Could not refresh processes (HTTP ${t.status}).`);return}let r=null;try{r=await t.json()}catch{r=null}let s=function(e){if(null===e||"object"!=typeof e||Array.isArray(e))return null;let t=e.state;if("string"!=typeof t||0===t.length)return null;let r=e.result;if(null==r)return{state:t,result:null};try{let e=(0,I.Q_)(r);if("detail.result"!==e.type)return null;return{state:t,result:e}}catch{return null}}(r);if(a||e.signal.aborted)return;if(null===s)return void A(m?"Unable to read the process update. Showing the last snapshot.":"Unable to read the process update from the hub.");((e,t)=>{if(null!==t){m=!0;let e=d.current;if(null!==e.detail&&e.detail.subscriptionId===t.subscriptionId&&e.detail.capturedAt===t.capturedAt&&"ready"===e.phase&&null===e.message)return;v(e=>{let r=null!==e.detail&&e.detail.subscriptionId===t.subscriptionId&&e.detail.capturedAt===t.capturedAt;return{phase:"ready",detail:r?e.detail:t,message:null,lastReceivedMs:r?e.lastReceivedMs:Date.now()}});return}let r=function(e){switch(e){case"ready":return"ready";case"loading":return"loading";case"paused":return"paused";case"disconnected":return"disconnected";case"withheld":return"withheld";case"unsupported":return"unsupported";case"busy":return"busy";case"expired":return"expired";case"failed":return"failed";case"cancelled":return"cancelled";default:return"error"}}(e);switch(r){case"ready":case"loading":return v({phase:m?"stale":"loading",message:m?"Waiting for a fresh snapshot. The values shown are from the last received snapshot.":"Waiting for the collector to report processes…"});case"disconnected":return v({phase:"disconnected",message:m?"The collector is disconnected. Showing the last received snapshot; it is not live.":"The collector is disconnected."});case"withheld":case"unsupported":case"cancelled":return N(r,O(r).description);case"busy":case"expired":case"failed":return v({phase:r,message:m?`${O(r).description} Showing the last received snapshot.`:O(r).description});case"paused":return v({phase:"paused",message:"Process updates are paused."});default:v({phase:m?"stale":"error",message:"Unable to read the process status from the hub."})}})(s.state,s.result)}catch{if(a||e.signal.aborted)return;A(m?"Process refresh failed. Showing the last snapshot, which is not live.":"Could not reach the hub for process detail.")}finally{i.signal.removeEventListener("abort",t),w===e&&(w=null),f=!1,a||x||a||x||!g||null!==b||(b=setTimeout(()=>{b=null,R()},p))}};return v(e=>null===e.detail?{phase:"acquiring",message:null}:"ready"===e.phase&&null===e.message?{}:{phase:"stale",message:"Resuming process updates…"}),(async()=>{let e=await P();a||x||(S(),e&&R())})(),()=>{a=!0,x=!0,j(),k()}},[t,r,s,n,i]),{state:u.current.machineId===t&&u.current.csrfToken===r?o:X(t,r),hidden:n,refresh:h}}({machineId:e.machineId,csrfToken:t,paused:r}),v=(0,g.useMemo)(()=>b.detail?.snapshot.processes??[],[b.detail]),j=(0,g.useMemo)(()=>(function(e){if(null===e)return{total:0,shown:0,inaccessible:0,truncated:!1};let t=e.processes.length;return{total:e.totalProcesses,shown:t,inaccessible:e.inaccessible,truncated:e.truncated}})(b.detail?.snapshot??null),[b.detail]),D=(0,g.useMemo)(()=>{var e,t,r;let s;return e=v,t=o,r=e.map(F),0===(s=t.trim().toLowerCase()).length?r.slice():r.filter(e=>!!(e.name.toLowerCase().includes(s)||null!==e.user&&e.user.toLowerCase().includes(s)||String(e.pid).includes(s)||null!==e.unit&&e.unit.toLowerCase().includes(s)||void 0!==e.command&&e.command.toLowerCase().includes(s)))},[v,o]),L=(0,g.useMemo)(()=>$(D,p.key,p.dir),[D,p]),K=(0,g.useMemo)(()=>{var e,t,r;return"applications"===c?(e=function(e){let t=new Map;for(let r of e)t.has(r.pid)||t.set(r.pid,r);let r=new Map;for(let s of e){let e=function(e,t){if(function(e,t){if(2===e.pid||2===e.ppid)return!0;let r=e,s=new Set;for(;r&&!s.has(r.pid);){if(2===r.pid)return!0;s.add(r.pid),r=t.get(r.ppid)}return!1}(e,t))return{key:"kernel",label:"kernel",kind:"kernel",leader:e};let r=C(e.unit);if(null!==r)return{key:`unit:${r}`,label:B(r),kind:"unit",leader:e};let s=e,n=new Set;for(;;){if(n.has(s.pid)){let e=s;for(let r of n){let s=t.get(r);s&&(s.pid<e.pid||s.pid===e.pid&&s.startTicks<e.startTicks)&&(e=s)}return T(e)}n.add(s.pid);let e=t.get(s.ppid);if(!e||function(e,t){if(1===e.pid)return!0;let r=e.name.toLowerCase();if(A.has(r)||P.has(r)||r.startsWith("tmux:"))return!0;if(R(e.unit)){let r=t.get(e.ppid);return void 0===r||r.unit!==e.unit}return!1}(e,t))return T(s);let r=C(e.unit);if(null!==r)return{key:`unit:${r}`,label:B(r),kind:"unit",leader:e};s=e}}(s,t),n=r.get(e.key);n?n.members.push(s):r.set(e.key,{descriptor:e,members:[s]})}return[...r.values()].map(({descriptor:e,members:t})=>(function(e,t){let r={cpuPercent:{sum:0,known:0},memoryRssBytes:{sum:0,known:0},gpuMemoryBytes:{sum:0,known:0},ioReadBytesPerSec:{sum:0,known:0},ioWriteBytesPerSec:{sum:0,known:0}},s=new Set;for(let e of t)for(let t of(null!==e.user&&s.add(e.user),S)){let s=e[t];null!==s&&Number.isFinite(s)&&(r[t].sum+=s,r[t].known++)}let n=e=>0===r[e].known?null:r[e].sum,a={};for(let e of S)a[e]=r[e].known>0&&r[e].known<t.length;return{key:e.key,label:e.label,kind:e.kind,members:e.leader!==t[0]?[e.leader,...t.filter(t=>t!==e.leader)]:t,cpuPercent:n("cpuPercent"),memoryRssBytes:n("memoryRssBytes"),gpuMemoryBytes:n("gpuMemoryBytes"),ioReadBytesPerSec:n("ioReadBytesPerSec"),ioWriteBytesPerSec:n("ioWriteBytesPerSec"),count:t.length,users:[...s].sort(),partial:a}})(e,t))}(D),t=p.key,r=p.dir,e.slice().sort((e,s)=>W(U(e,t),U(s,t),r))):[]},[D,c,p]),E=(0,g.useMemo)(()=>"tree"===c?function(e){let t=e.length,r=new Map;for(let s=0;s<t;s++)r.has(e[s].pid)||r.set(e[s].pid,s);let s=e.map(e=>{let t=r.get(e.ppid);return void 0===t?null:t}),n=new Uint8Array(t);for(let e=0;e<t;e++){if(0!==n[e])continue;let t=[],r=e;for(;null!==r&&0===n[r];)n[r]=1,t.push(r),r=s[r];for(let e of(null!==r&&1===n[r]&&(s[t[t.length-1]]=null),t))n[e]=2}let a=Array.from({length:t},()=>[]),i=[];for(let e=0;e<t;e++){let t=s[e];null===t?i.push(e):a[t].push(e)}let l=[],o=[];for(let e=i.length-1;e>=0;e--)o.push({index:i[e],depth:0});for(;o.length>0;){let{index:t,depth:r}=o.pop();l.push({row:e[t],depth:r,children:a[t].length});let s=a[t];for(let e=s.length-1;e>=0;e--)o.push({index:s[e],depth:r+1})}return l}(L):[],[c,L]),z=O(b.phase),Z=null!==b.detail,G=!Z&&("acquiring"===b.phase||"loading"===b.phase),H=o.trim().slice(0,80),Q=(0,g.useMemo)(()=>{let e=D.length,t=o.trim().length>0,r=1!==e||t?"processes":"process";return"applications"===c?`${K.length} app${1===K.length?"":"s"} \xb7 ${e}${t?` of ${j.shown}`:""} ${r}`:`${e}${t?` of ${j.shown}`:""} ${r}`},[o,D.length,K.length,c,j.shown]);return(0,s.jsx)(d.Z,{title:"Process detail",action:Z?(0,s.jsx)("span",{className:"tnum hidden max-w-[18rem] truncate text-muted-foreground sm:block",children:Q}):void 0,className:"min-h-0 flex-1",children:(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:[(0,s.jsxs)("div",{className:"relative min-w-0 flex-1 basis-52",children:[(0,s.jsx)("label",{htmlFor:"process-search",className:"sr-only",children:"Search processes"}),(0,s.jsx)(k.A,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground","aria-hidden":!0}),(0,s.jsx)("input",{id:"process-search",type:"search",value:i,onChange:e=>l(e.target.value),placeholder:"Search name, user, PID, or unit",autoComplete:"off",spellCheck:!1,className:"h-9 w-full rounded-md border border-border bg-card-strong py-1.5 pl-8 pr-8 text-sm text-foreground placeholder:text-muted-foreground [&::-webkit-search-cancel-button]:hidden [&::-webkit-search-cancel-button]:[-webkit-appearance:none]"}),i.length>0?(0,s.jsx)("button",{type:"button",onClick:()=>l(""),"aria-label":"Clear search",className:"absolute right-0.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-card hover:text-foreground",children:(0,s.jsx)(M.A,{className:"h-3.5 w-3.5","aria-hidden":!0})}):null]}),(0,s.jsx)("div",{role:"group","aria-label":"Process view",className:"inline-flex shrink-0 rounded-md border border-border p-0.5",children:_.map(e=>{let t=c===e.value;return(0,s.jsx)("button",{type:"button","aria-pressed":t,onClick:()=>u(e.value),className:["rounded px-2.5 py-1 text-xs transition-colors",t?"bg-selected font-medium text-foreground":"text-muted-foreground hover:bg-card-strong hover:text-foreground"].join(" "),children:e.label},e.value)})}),(0,s.jsxs)("button",{type:"button",onClick:()=>n(!r),title:r?"Resume process updates":"Pause process updates",className:"inline-flex min-h-9 shrink-0 items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:[r?(0,s.jsx)(N.A,{className:"h-3.5 w-3.5","aria-hidden":!0}):(0,s.jsx)(w.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),r?"Resume":"Pause"]}),(0,s.jsx)(e_,{machine:e,snapshot:b.detail?.snapshot??null,capturedAt:b.detail?.capturedAt??null,receivedAtMs:b.lastReceivedMs,intervalMs:b.intervalMs,phase:b.phase,query:o,mode:c,sort:p,filteredRows:D,sortedRows:L,groups:K,tree:E})]}),(0,s.jsx)(eV,{summary:j,lastReceivedMs:b.lastReceivedMs,intervalMs:b.intervalMs,message:b.message,phase:b.phase,hasSnapshot:Z}),(0,s.jsx)("div",{"aria-busy":G||"acquiring"===b.phase,className:"flex min-h-0 flex-1 flex-col overflow-auto",children:Z?0===D.length?(0,s.jsxs)("div",{className:"flex flex-col items-center gap-2 break-words",children:[(0,s.jsx)(d.p,{icon:k.A,note:0===j.shown?"The collector reported no processes in this snapshot.":o.trim().length>0?`No processes match “${H}”.`:"No processes to show.",className:"min-h-64 w-full"}),o.trim().length>0?(0,s.jsxs)("button",{type:"button",onClick:()=>l(""),className:"inline-flex min-h-6 items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs text-foreground transition-colors hover:bg-card-strong",children:[(0,s.jsx)(M.A,{className:"h-3 w-3","aria-hidden":!0}),"Clear search"]}):null]}):(0,s.jsx)(e$,{mode:c,groups:K,rows:L,tree:E,sort:p,onSort:e=>h(t=>(function(e,t){return e.key===t?{key:t,dir:"asc"===e.dir?"desc":"asc"}:{key:t,dir:"name"===t||"user"===t||"pid"===t?"asc":"desc"}})(t,e)),expanded:x,onToggleGroup:e=>{f(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}}):(0,s.jsx)(eO,{phase:b.phase,info:z,message:b.message,onRetry:y})})]})})}function eG({waiting:e}){return(0,s.jsx)(d.Z,{title:e?"Waiting for machines":"No machines",className:"mt-2",children:(0,s.jsx)(d.p,{icon:e?i.A:l.A,note:e?"Waiting for the fleet snapshot…":"No machines are available in your authorized fleet."})})}function eY({requested:e}){return(0,s.jsxs)(d.Z,{title:"Machine not found",className:"mt-2",children:[(0,s.jsx)(d.p,{icon:o.A,note:"This machine is unavailable or outside your access."}),(0,s.jsxs)("p",{className:"tnum mt-2 break-all text-center text-xs text-muted-foreground",children:["Requested identifier: ",e]}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(a(),{href:"/",className:"mt-2 inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:"Back to fleet"})})]})}function eX(){let{session:e,phase:t,machines:r}=(0,m.M)(),n=(0,h.x)(),[a,i]=(0,es.u)("processes.paused",!1,em,"session"),{machine:l,navMachineId:o,requestedMachineId:d}=(0,f.JG)("processes"),g="signed-in"===e.kind?e.user.csrfToken:null,x=0===r.length&&("connecting"===t||"idle"===t);return(0,s.jsx)(c.G,{title:"Processes",machineId:o,machineView:"processes",workspace:!0,headerRight:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(u.$E,{}),(0,s.jsx)(p.B,{})]}),children:n||(0,s.jsx)(s.Fragment,{children:0===r.length?(0,s.jsx)(eG,{waiting:x}):l?(0,s.jsx)(eZ,{machine:l,csrfToken:g,paused:a,onPausedChange:i},`${l.machineId}:${g}`):(0,s.jsx)(eY,{requested:d??""})})})}},7348:(e,t,r)=>{"use strict";r.d(t,{c:()=>n});var s=r(2115);function n(e=1e3){let[t,r]=(0,s.useState)(()=>Date.now());return(0,s.useEffect)(()=>{r(Date.now());let t=setInterval(()=>r(Date.now()),e);return()=>clearInterval(t)},[e]),t}},7499:(e,t,r)=>{"use strict";function s(e,t,r,s){return`rigscope-${e}-${function(e,t="machine"){let r=e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48).replace(/-+$/g,"");return r.length>0?r:t}(t)}-${!Number.isFinite(r)?"unknown-time":new Date(r).toISOString().replace(/[-:]/g,"").replace(/\.\d{3}Z$/,"Z")}.${s}`}r.d(t,{Y8:()=>s})},8528:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]])},9031:(e,t,r)=>{Promise.resolve().then(r.bind(r,1721)),Promise.resolve().then(r.bind(r,7339)),Promise.resolve().then(r.bind(r,2701)),Promise.resolve().then(r.bind(r,2394))},9664:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]])},9926:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Hourglass",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]])},9942:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]])}},e=>{e.O(0,[157,939,103,441,794,358],()=>e(e.s=9031)),_N_E=e.O()}]);
|