import{d as q,dg as B,d7 as A,r as l,p as J,j as e,q as Y,c as F,N as E,dh as te,di as se,dj as re,dk as ne,c9 as ae,B as oe,dl as le,dm as G}from"./index-BOwCLZTK.js";import{C as P,P as ce,a as ie,B as de}from"./PageLayout-QKntxcnp.js";import{T as me}from"./triangle-alert-SO3tIa8w.js";import{a as ue,A as xe}from"./arrow-up-BqsZCBBC.js";import{N as fe}from"./network-D0Fgg1y-.js";import{A as L}from"./activity-D5uH2SFx.js";import{R as pe}from"./refresh-cw-C9txhqc9.js";import{C as he}from"./cpu-D7sbzQ8o.js";import{R as H,C as $}from"./Grid-eFMUBxsw.js";/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ge=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],ye=q("hard-drive",ge);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const je=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],we=q("thermometer",je),k=[{pos:0,color:B(A.purple)},{pos:.25,color:B(A.indigo)},{pos:.5,color:B(A.cyan)},{pos:.75,color:B(A.amber)},{pos:1,color:B(A.red)}];function be(t,s,o){const n=.45454545454545453,r=Math.pow(t.r/255,2.2),i=Math.pow(t.g/255,2.2),x=Math.pow(t.b/255,2.2),d=Math.pow(s.r/255,2.2),m=Math.pow(s.g/255,2.2),c=Math.pow(s.b/255,2.2);return{r:Math.round(Math.pow(r+o*(d-r),n)*255),g:Math.round(Math.pow(i+o*(m-i),n)*255),b:Math.round(Math.pow(x+o*(c-x),n)*255)}}function Q(t){const s=Math.max(0,Math.min(1,t));let o=k[0],a=k[k.length-1];for(let i=0;i<k.length-1;i++)if(s>=k[i].pos&&s<=k[i+1].pos){o=k[i],a=k[i+1];break}const n=a.pos-o.pos,r=n>0?(s-o.pos)/n:0;return be(o.color,a.color,r)}const W=Y.hero,Ne=36;function V(){const t=getComputedStyle(document.documentElement);return{fontFamily:t.getPropertyValue("--font-data").trim()||'"JetBrains Mono", ui-monospace, monospace',textPrimary:t.getPropertyValue("--text-primary").trim()||"#FFFFFF",textMuted:t.getPropertyValue("--text-muted").trim()||"#727272",gridColor:t.getPropertyValue("--chart-grid").trim()||"rgba(255, 255, 255, 0.06)"}}function ve(t){const s=[],o=Math.max(0,W-t.length);for(let n=0;n<o;n++)s.push({timestamp:n,time:"",cpu:null,memory:null});const a=t.slice(-W);for(let n=0;n<a.length;n++){const r=a[n];s.push({timestamp:o+n,time:r.time.slice(0,5),cpu:r.cpu,memory:r.memory})}return s}function Me(t,s,o,a,n){if(s.length===0)return;const r=t.ctx,{left:i,top:x,width:d,height:m}=t.bbox,c=window.devicePixelRatio||1;if(d<=0||m<=0)return;const h=s.length;if(h===0)return;const v=d/h,w=u=>i+(u+.5)*v,f=u=>{const y=Math.min(Math.max(u/100,0),1);return x+m*(1-y)};r.save(),r.strokeStyle=n.textPrimary,r.globalAlpha=.1,r.lineWidth=1*c,r.setLineDash([4*c,4*c]);for(const u of[25,50,75]){const y=Math.round(f(u))+.5;r.beginPath(),r.moveTo(Math.round(i),y),r.lineTo(Math.round(i+d),y),r.stroke()}r.restore(),r.save(),r.font=`bold ${10*c}px ${n.fontFamily}`,r.fillStyle=n.textMuted,r.textBaseline="middle",r.textAlign="left";const g=8*c;for(const u of[0,25,50,75,100]){const y=f(u),j=Math.max(x+g,Math.min(x+m-g,y));r.fillText(`${u}%`,4*c,j)}r.restore(),r.save();for(let u=0;u<h;u++){const y=s[u];if(!y||y.cpu===null)continue;const N=w(u)-v/2,S=f(y.cpu),_=x+m-S,T=Math.pow(y.cpu/100,.7),O=Q(T);r.fillStyle=`rgba(${O.r}, ${O.g}, ${O.b}, 0.85)`,r.fillRect(N,S,v,_)}r.restore(),r.save(),r.lineWidth=2.5*c,r.lineCap="round",r.lineJoin="round",r.strokeStyle=a;let p=!1,b=0;for(let u=0;u<h;u++){const y=s[u];if(!y||y.memory===null){p&&(r.stroke(),r.beginPath(),p=!1);continue}const j=w(u),N=f(y.memory);p?(r.lineTo(j,b),r.lineTo(j,N)):(r.beginPath(),r.moveTo(j,N),p=!0),b=N}p&&r.stroke(),r.restore(),r.save(),r.font=`${10*c}px ${n.fontFamily}`,r.fillStyle=n.textMuted,r.textBaseline="top",r.textAlign="center";const M=x+m+6*c,R=Math.max(1,Math.floor(h/4));for(let u=0;u<h;u+=R){const y=s[u];!y||!y.time||r.fillText(y.time,w(u),M)}if(h>0){const u=s[h-1];u!=null&&u.time&&(r.textAlign="right",r.fillText(u.time,w(h-1),M))}r.restore()}function Re({data:t,cpuColor:s,memoryColor:o}){const a=l.useRef(null),n=l.useRef(null),r=l.useRef([]),i=l.useRef(s),x=l.useRef(o),d=l.useRef(null),m=l.useRef(t.length);l.useLayoutEffect(()=>{i.current=s,x.current=o}),l.useEffect(()=>{d.current=V()},[]);const c=l.useMemo(()=>ve(t),[t]);l.useLayoutEffect(()=>{r.current=c},[c]);const h=l.useMemo(()=>{const f=c.map(p=>p.timestamp),g=new Array(c.length).fill(1);return[f,g]},[c]),v=l.useMemo(()=>({hooks:{draw:f=>{const g=d.current||V();Me(f,r.current,i.current,x.current,g)}}}),[]),w=l.useMemo(()=>({width:400,height:240,padding:[4,8,4,Ne],cursor:{show:!1,x:!1,y:!1,drag:{x:!1,y:!1},points:{show:!1}},scales:{x:{time:!1},y:{range:[0,100]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],plugins:[v]}),[v]);return l.useEffect(()=>{const f=a.current;if(!f||c.length===0)return;const g=m.current,p=t.length,b=Math.abs(p-g);if(!(!n.current||b>50||g>0&&b/g>.2)&&n.current){n.current.setData(h),m.current=p;return}n.current&&n.current.destroy();const R=f.getBoundingClientRect(),u=Math.floor(R.width)||400,y=Math.floor(R.height)||240,j=new J({...w,width:u,height:y},h,f);return n.current=j,m.current=p,()=>{j.destroy(),n.current=null}},[w,h,c.length,t.length]),l.useEffect(()=>{const f=a.current;if(!f)return;const g=new ResizeObserver(p=>{const b=p[0];if(!b||!n.current)return;const{width:M,height:R}=b.contentRect;M>0&&R>0&&n.current.setSize({width:Math.floor(M),height:Math.floor(R)})});return g.observe(f),()=>{g.disconnect()}},[]),l.useEffect(()=>{n.current&&n.current.redraw()},[s,o,c]),t.length===0?e.jsx("div",{className:"flex-1 min-h-[180px] flex items-center justify-center text-fg-muted",children:"Collecting data..."}):e.jsx("div",{className:"relative flex-1 min-h-[180px]",children:e.jsx("div",{ref:a,className:"absolute inset-0 radius-inner overflow-hidden"})})}const Ce=l.memo(Re),Se=1024*1024;function _e(t,s,o,a,n){const r=t.ctx,{left:i,top:x,width:d,height:m}=t.bbox;if(d<=0||m<=0)return;const c=[...Array(Math.max(0,n-s.length)).fill(0),...s.slice(-n)],h=Math.max(...c,1),v=c.length,w=d/v,f=m*.03;r.save();for(let g=0;g<v;g++){const p=c[g],b=i+g*w;if(p<=0)continue;const M=Math.min(p/h,1),R=Math.max(M*m,f),u=Math.min(p/Se,1),y=Math.pow(u,.7),j=Q(y);r.fillStyle=`rgb(${j.r}, ${j.g}, ${j.b})`,a?r.fillRect(b,x,w,R):r.fillRect(b,x+m-R,w,R)}r.restore()}function ke({data:t,color:s,flipped:o=!1,fixedSlots:a}){const n=l.useRef(null),r=l.useRef(null),i=l.useRef(t),x=l.useRef(s),d=l.useRef(o),m=l.useRef(a);l.useLayoutEffect(()=>{i.current=t,x.current=s,d.current=o,m.current=a});const c=l.useMemo(()=>{const w=Array.from({length:a},(g,p)=>p),f=new Array(a).fill(1);return[w,f]},[a]),h=l.useMemo(()=>({hooks:{draw:w=>{_e(w,i.current,x.current,d.current,m.current)}}}),[]),v=l.useMemo(()=>({width:400,height:40,padding:[0,0,0,0],legend:{show:!1},cursor:{show:!1,x:!1,y:!1,drag:{x:!1,y:!1},points:{show:!1}},scales:{x:{time:!1},y:{range:[0,1]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1,label:""}],plugins:[h]}),[h]);return l.useEffect(()=>{const w=n.current;if(!w)return;r.current&&r.current.destroy();const f=w.getBoundingClientRect(),g=Math.floor(f.width)||400,p=Math.floor(f.height)||40,b=new J({...v,width:g,height:p},c,w);return r.current=b,()=>{b.destroy(),r.current=null}},[v,c]),l.useEffect(()=>{const w=n.current;if(!w)return;const f=new ResizeObserver(g=>{const p=g[0];if(!p||!r.current)return;const{width:b,height:M}=p.contentRect;b>0&&M>0&&r.current.setSize({width:Math.floor(b),height:Math.floor(M)})});return f.observe(w),()=>{f.disconnect()}},[]),l.useEffect(()=>{r.current&&r.current.redraw()},[t,s,o]),e.jsx("div",{ref:n,className:"w-full h-full"})}const X=l.memo(ke),C={cold:30,normal:50,warm:65,hot:80},I={cpu:{warning:80,danger:95},memory:{warning:85,danger:95},temp:{warning:70,danger:85}},Te=[{threshold:C.cold,color:"var(--sys-cyan)"},{threshold:C.normal,color:"var(--sys-blue)"},{threshold:C.warm,color:"var(--sys-indigo)"},{threshold:C.hot,color:"var(--signal-poor)"}];function Pe(t){return t<C.cold?{text:"Cool",color:"text-sys-cyan"}:t<C.normal?{text:"Normal",color:"text-sys-blue"}:t<C.warm?{text:"Warm",color:"text-sys-indigo"}:t<C.hot?{text:"Hot",color:"text-signal-poor"}:{text:"Danger",color:"text-sys-red"}}function Ee(t,s,o){const a=o-s,n={cold:(C.cold-s)/a*100,normal:(C.normal-s)/a*100,warm:(C.warm-s)/a*100,hot:(C.hot-s)/a*100};return`linear-gradient(to right, ${[{pos:0,color:"var(--sys-cyan)"},{pos:n.cold,color:"var(--sys-cyan)"},{pos:n.cold,color:"var(--sys-blue)"},{pos:n.normal,color:"var(--sys-blue)"},{pos:n.normal,color:"var(--sys-indigo)"},{pos:n.warm,color:"var(--sys-indigo)"},{pos:n.warm,color:"var(--signal-poor)"},{pos:n.hot,color:"var(--signal-poor)"},{pos:n.hot,color:"var(--sys-red)"},{pos:100,color:"var(--sys-red)"}].map(x=>{const d=t>0?x.pos/t*100:0;return`${x.color} ${Math.min(d,100)}%`}).join(", ")})`}function U(t,s){return t>=s.danger?"danger":t>=s.warning?"warning":"none"}function Be(t){let s="none";for(const o of Object.values(t)){const a=U(o,I.temp);if(a==="danger")return"danger";a==="warning"&&(s="warning")}return s}function K(t){let s,o;t>=1024*1024*1024?(s=t/(1024*1024*1024),o="GB/s"):t>=1024*1024?(s=t/(1024*1024),o="MB/s"):t>=1024?(s=t/1024,o="KB/s"):(s=t,o="B/s");let a;return s>=100?a=s.toFixed(0):(s>=10,a=s.toFixed(1)),`${a} ${o}`}function D(t){return t>=1024*1024*1024?{value:(t/(1024*1024*1024)).toFixed(1),unit:"GiB"}:t>=1024*1024?{value:(t/(1024*1024)).toFixed(1),unit:"MiB"}:t>=1024?{value:(t/1024).toFixed(1),unit:"KiB"}:{value:String(t),unit:"B"}}const z=l.memo(function({level:s}){return s==="none"?null:e.jsxs("span",{className:F("inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium",s==="danger"&&"bg-sys-red/20 text-sys-red",s==="warning"&&"bg-sys-indigo/20 text-sys-indigo"),children:[e.jsx(me,{className:"w-3 h-3"}),s==="danger"?"High":"Warn"]})}),ee=l.memo(function({value:s,max:o=100,width:a=10,color:n="primary"}){const r=Math.min(s/o,1),i=Math.round(r*a),x=a-i,d="■".repeat(i),m="·".repeat(x),c={primary:"text-sys-blue",secondary:"text-sys-indigo",success:"text-sys-green",danger:"text-sys-red"}[n];return e.jsxs("span",{className:"font-mono text-[10px] tracking-tight",children:[e.jsx("span",{className:c,children:d}),e.jsx("span",{className:"text-fg-muted/40",children:m})]})}),Ae=l.memo(function({index:s,usage:o}){const a=o>90?"danger":o>70?"secondary":"primary";return e.jsxs("div",{className:"flex items-center gap-1 type-data-xs",children:[e.jsxs("span",{className:"text-fg-muted w-5",children:["C",s]}),e.jsx(ee,{value:o,width:8,color:a}),e.jsxs("span",{className:F("w-7 text-right tabular-nums",o>90?"text-sys-red":o>70?"text-sys-indigo":"text-sys-green"),children:[o.toFixed(0),"%"]})]})}),Fe=l.memo(function({pid:s,name:o,cpu:a,mem:n,isTopCpu:r=!1,isTopMem:i=!1}){return e.jsxs("div",{className:"flex items-center gap-2 py-1 type-data-sm hover:bg-subtle-fill -mx-1 px-1 rounded",children:[e.jsx("span",{className:"text-fg-muted w-10 sm:w-14 tabular-nums",children:s}),e.jsx("span",{className:"flex-1 truncate text-fg-primary",children:o}),e.jsx("span",{className:"hidden sm:inline-flex",children:e.jsx(ee,{value:a,max:100,width:6,color:a>50?"danger":a>20?"secondary":"success"})}),e.jsx("span",{className:F("w-10 sm:w-12 text-right tabular-nums",r?"text-fg-primary":a>50?"text-sys-red":a>20?"text-sys-indigo":"text-fg-muted"),children:a.toFixed(1)}),e.jsx("span",{className:F("w-10 sm:w-12 text-right tabular-nums",i?"text-fg-primary":n>50?"text-sys-red":n>20?"text-sys-indigo":"text-fg-muted"),children:n.toFixed(1)})]})}),Z=l.memo(function({value:s,label:o,min:a=20,max:n=100}){const r=Math.min(Math.max((s-a)/(n-a)*100,0),100),i=Pe(s),x=n-a;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"type-data-sm text-fg-muted",children:o}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"type-data-sm text-fg-muted",children:i.text}),e.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded type-data-sm",children:[e.jsx("span",{className:i.color,children:s.toFixed(1)}),e.jsx("span",{className:"text-fg-primary",children:"°C"})]})]})]}),e.jsxs("div",{className:"relative h-3 rounded-full bg-subtle-fill/80 depth-stroke-inset overflow-hidden",children:[e.jsx("div",{className:"absolute inset-y-0 left-0 rounded-full transition-all duration-300 ease-out",style:{background:Ee(r,a,n),width:`${r}%`}}),e.jsx("div",{className:"absolute inset-0 flex items-center pointer-events-none",children:Te.map(({threshold:d,color:m})=>{const c=(d-a)/x*100;return c<0||c>100?null:e.jsx("div",{className:"absolute w-px h-full",style:{left:`${c}%`,backgroundColor:m}},d)})})]})]})});l.memo(function({data:s,color:o,flipped:a=!1,fixedSlots:n}){const r=[...Array(Math.max(0,n-s.length)).fill(0),...s.slice(-n)],i=Math.max(...r,1),x=r.map(d=>d===0?0:Math.max(d/i*100,3));return e.jsx("div",{className:"w-full h-full flex items-end",style:{transform:a?"scaleY(-1)":void 0},children:x.map((d,m)=>e.jsx("div",{className:"flex-1 min-w-0",style:{height:d>0?`${d}%`:"0%",backgroundColor:d>0?o:"transparent"}},m))})});function He({networkHistory:t,txRate:s,rxRate:o,totalBytesSent:a,totalBytesRecv:n,cpuColor:r,memoryColor:i,networkSlots:x}){return e.jsxs(P,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(E,{icon:e.jsx(fe,{}),title:"Network",actions:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ue,{className:"w-3.5 h-3.5",style:{color:i}}),e.jsx("span",{className:"type-data-xs",style:{color:i},children:"TX"}),e.jsx("span",{className:"px-2 py-1 bg-subtle-fill-strong rounded type-data-sm text-fg-primary",children:K(s)})]})}),e.jsxs("div",{className:"flex flex-col h-[120px]",children:[e.jsx("div",{className:"h-[60px]",children:e.jsx(X,{data:t.map((d,m,c)=>{if(m===0)return 0;const h=(d.timestamp-c[m-1].timestamp)/1e3;return h>0?(d.bytesSent-c[m-1].bytesSent)/h:0}),color:i,fixedSlots:x})}),e.jsx("div",{className:"h-[60px]",children:e.jsx(X,{data:t.map((d,m,c)=>{if(m===0)return 0;const h=(d.timestamp-c[m-1].timestamp)/1e3;return h>0?(d.bytesRecv-c[m-1].bytesRecv)/h:0}),color:r,flipped:!0,fixedSlots:x})})]}),e.jsxs("div",{className:"pt-2 flex flex-wrap justify-between items-center gap-2 type-data-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsx("span",{className:"text-fg-muted",children:"Total"}),e.jsxs("span",{className:"px-1.5 sm:px-2 py-1 bg-subtle-fill-strong rounded tabular-nums",children:[e.jsx("span",{style:{color:i},children:D(a).value})," ",e.jsx("span",{className:"text-fg-muted",children:D(a).unit})]}),e.jsxs("span",{className:"px-1.5 sm:px-2 py-1 bg-subtle-fill-strong rounded tabular-nums",children:[e.jsx("span",{style:{color:r},children:D(n).value})," ",e.jsx("span",{className:"text-fg-muted",children:D(n).unit})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(xe,{className:"w-3.5 h-3.5",style:{color:r}}),e.jsx("span",{className:"type-data-xs",style:{color:r},children:"RX"}),e.jsx("span",{className:"px-1.5 sm:px-2 py-1 bg-subtle-fill-strong rounded tabular-nums text-fg-primary",children:K(o)})]})]})]})}const $e=l.memo(He);function De({temperatures:t}){return e.jsxs(P,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(E,{icon:e.jsx(we,{}),title:"Temperature",actions:t&&e.jsx(z,{level:Be(t)})}),e.jsx("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:t&&Object.keys(t).length>0?e.jsxs("div",{className:"space-y-3",children:[t.cpu_thermal!==void 0&&e.jsx(Z,{value:t.cpu_thermal,label:"CPU",min:20,max:100}),Object.entries(t).filter(([s])=>s!=="cpu_thermal").slice(0,2).map(([s,o])=>e.jsx(Z,{value:o,label:s.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase()),min:20,max:100},s))]}):e.jsxs("div",{className:"flex items-center justify-center text-fg-muted text-sm",children:[e.jsx(L,{className:"w-4 h-4 mr-2"}),"No sensors"]})})]})}const Le=l.memo(De);function Oe({usagePercent:t,used:s,available:o,memoryColor:a}){return e.jsxs(P,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(E,{icon:e.jsx(L,{}),title:"Memory",actions:e.jsxs("span",{className:"px-2 py-0.5 bg-subtle-fill-strong rounded type-data",style:{color:a},children:[t.toFixed(0),"%"]})}),e.jsxs("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:[e.jsxs("div",{className:"flex gap-1 h-12 radius-inner bg-subtle-fill/80 depth-stroke-inset overflow-hidden",children:[e.jsx("div",{className:"h-full transition-all duration-300 bg-sys-blue",style:{width:`${t}%`}}),e.jsx("div",{className:"h-full transition-all duration-300 bg-subtle-fill/80",style:{width:`${100-t}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between type-data-xs pt-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-sys-blue"}),e.jsx("span",{className:"text-fg-muted",children:"Used"}),e.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-fg-primary",children:[(s/(1024*1024)).toFixed(0)," MB"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-subtle-fill-strong depth-stroke-raised"}),e.jsx("span",{className:"text-fg-muted",children:"Avail"}),e.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-fg-muted",children:[(o/(1024*1024)).toFixed(0)," MB"]})]})]})]})]})}const Ie=l.memo(Oe);function Ue({usagePercent:t,used:s,free:o,cpuColor:a}){return e.jsxs(P,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(E,{icon:e.jsx(ye,{}),title:"Disk",actions:e.jsxs("span",{className:"px-2 py-0.5 bg-subtle-fill-strong rounded type-data",style:{color:a},children:[t.toFixed(0),"%"]})}),e.jsxs("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:[e.jsxs("div",{className:"flex gap-1 h-12 radius-inner bg-subtle-fill/80 depth-stroke-inset overflow-hidden",children:[e.jsx("div",{className:"h-full transition-all duration-300 bg-sys-blue",style:{width:`${t}%`}}),e.jsx("div",{className:"h-full transition-all duration-300 bg-subtle-fill/80",style:{width:`${100-t}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between type-data-xs pt-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-sys-blue"}),e.jsx("span",{className:"text-fg-muted",children:"Used"}),e.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-fg-primary",children:[(s/(1024*1024*1024)).toFixed(1)," GB"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-subtle-fill-strong depth-stroke-raised"}),e.jsx("span",{className:"text-fg-muted",children:"Free"}),e.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-fg-muted",children:[(o/(1024*1024*1024)).toFixed(1)," GB"]})]})]})]})]})}const ze=l.memo(Ue);function Ye({processes:t}){if(t.length===0)return null;const s=t.slice(0,10),o=Math.max(...s.map(n=>n.cpu_percent)),a=Math.max(...s.map(n=>n.memory_percent));return e.jsx(P,{neomorphic:!0,noPadding:!0,children:e.jsxs("div",{className:"px-4 py-3",children:[e.jsx(E,{icon:e.jsx(L,{}),title:"Processes"}),e.jsxs("div",{className:"flex items-center gap-2 py-1.5 type-data-sm text-fg-muted",children:[e.jsx("span",{className:"w-10 sm:w-14",children:"PID"}),e.jsx("span",{className:"flex-1",children:"Program"}),e.jsx("span",{className:"hidden sm:block w-[52px]"}),e.jsx("span",{className:"w-10 sm:w-12 text-right",children:"CPU%"}),e.jsx("span",{className:"w-10 sm:w-12 text-right",children:"MEM%"})]}),s.map(n=>e.jsx(Fe,{pid:n.pid,name:n.name,cpu:n.cpu_percent,mem:n.memory_percent,isTopCpu:n.cpu_percent===o&&o>0,isTopMem:n.memory_percent===a&&a>0},n.pid))]})})}const Ge=l.memo(Ye),We=Y.hero;function Ve(){const[t,s]=l.useState(typeof window<"u"?window.matchMedia("(max-width: 767px)").matches:!1);return l.useEffect(()=>{const o=window.matchMedia("(max-width: 767px)");s(o.matches);const a=n=>s(n.matches);return o.addEventListener("change",a),()=>o.removeEventListener("change",a)},[]),t?Y.hero:40}function rt(){var y;const t=te(),s=se(),o=re(),a=ne(),[n,r]=l.useState([]),[i,x]=l.useState(!1),[d,m]=l.useState([]),[c,h]=l.useState(0),[v,w]=l.useState(0),f=l.useRef(null),g=ae(),p=g.blue,b=g.amber,M=Ve();l.useEffect(()=>{if(!t)return;const j=Date.now(),N={timestamp:j,bytesRecv:t.network.bytes_recv,bytesSent:t.network.bytes_sent};if(f.current){const S=(j-f.current.timestamp)/1e3;if(S>0){const _=(N.bytesRecv-f.current.bytesRecv)/S,T=(N.bytesSent-f.current.bytesSent)/S;_>=0&&T>=0&&(h(_),w(T))}}f.current=N,m(S=>[...S,N].slice(-We))},[t]);const R=5e3;l.useEffect(()=>{let j=!0;const N=async()=>{var T;const _=await G();j&&_.success&&((T=_.data)!=null&&T.processes)&&r(_.data.processes)};N();const S=setInterval(N,R);return()=>{j=!1,clearInterval(S)}},[]);const u=async()=>{var N;x(!0),await o();const j=await G();j.success&&((N=j.data)!=null&&N.processes)&&r(j.data.processes),x(!1)};return e.jsxs(ce,{children:[e.jsx(ie,{title:"System Stats",icon:e.jsx(he,{}),controls:e.jsxs(oe,{color:"muted",onClick:u,disabled:i,children:[e.jsx(pe,{"data-slot":"icon",className:F(i&&"animate-spin")}),"Refresh"]})}),e.jsxs(de,{ready:!!t,children:[s&&e.jsx(P,{className:"border border-sys-red/50 bg-sys-red/10",children:e.jsx("p",{className:"text-sys-red",children:s})}),e.jsx(H,{template:"hero",children:e.jsxs(P,{neomorphic:!0,className:"pb-2 sm:pb-3",children:[e.jsx(E,{icon:e.jsx(L,{}),title:"System Resources",stackActionsOnMobile:!0,actions:t&&e.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-wrap",children:[((y=t.system)==null?void 0:y.uptime)&&e.jsx("span",{className:"px-2 py-0.5 bg-subtle-fill rounded type-data-sm text-fg-primary",children:le(t.system.uptime)}),e.jsx(z,{level:U(t.cpu.usage_percent,I.cpu)}),e.jsx(z,{level:U(t.memory.usage_percent,I.memory)}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsx("span",{className:"type-data-sm text-fg-muted",children:"CPU"}),e.jsxs("span",{className:"text-sm sm:text-base font-mono font-semibold tabular-nums",style:{color:p},children:[t.cpu.usage_percent.toFixed(0),"%"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsx("span",{className:"type-data-sm text-fg-muted",children:"MEM"}),e.jsxs("span",{className:"text-sm sm:text-base font-mono font-semibold tabular-nums",style:{color:b},children:[t.memory.usage_percent.toFixed(0),"%"]})]})]})}),t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:e.jsx(Ce,{data:a,cpuColor:p,memoryColor:b})}),t.cpu.per_core_percent&&t.cpu.per_core_percent.length>0&&e.jsx("div",{className:"mt-3 pt-3 border-t border-edge-subtle",children:e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-8 gap-x-3 gap-y-0.5",children:t.cpu.per_core_percent.map((j,N)=>e.jsx(Ae,{index:N,usage:j},N))})})]})]})}),t&&e.jsxs(e.Fragment,{children:[e.jsxs(H,{template:"compact",children:[e.jsx($,{span:12,md:6,children:e.jsx($e,{networkHistory:d,txRate:v,rxRate:c,totalBytesSent:t.network.bytes_sent,totalBytesRecv:t.network.bytes_recv,cpuColor:p,memoryColor:b,networkSlots:M})}),e.jsx($,{span:12,md:6,children:e.jsx(Le,{temperatures:t.temperatures})})]}),e.jsxs(H,{template:"compact",children:[e.jsx($,{span:12,sm:6,children:e.jsx(Ie,{usagePercent:t.memory.usage_percent,used:t.memory.used,available:t.memory.available,memoryColor:b})}),e.jsx($,{span:12,sm:6,children:e.jsx(ze,{usagePercent:t.disk.usage_percent,used:t.disk.used,free:t.disk.free,cpuColor:p})})]}),e.jsx(H,{template:"auto",children:e.jsx(Ge,{processes:n})})]})]})]})}export{rt as default};
