import{r as z,w as X,d as K,x as m,y as _,t as T,g as U,z as j,_ as q,b as F,A as E,u as G,C as I,D as M,E as f,f as u,i as s,G as P,H as g,J as h,K as J,L as x,M as b,N as V,O as k}from"./index-BPVK8l7-.js";import{D as B}from"./DocumentTitle-Dh4EzHth.js";const Q=(r,t,o)=>{const n=o(r,t);return z(()=>clearInterval(n))};function w(r){if(r===null||typeof r!="object")return!1;const t=Object.getPrototypeOf(r);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in r?!1:Symbol.toStringTag in r?Object.prototype.toString.call(r)==="[object Module]":!0}function C(r,t,o=".",n){if(!w(t))return C(r,{},o,n);const i=Object.assign({},t);for(const e in r){if(e==="__proto__"||e==="constructor")continue;const l=r[e];l!=null&&(n&&n(i,e,l,o)||(Array.isArray(l)&&Array.isArray(i[e])?i[e]=[...l,...i[e]]:w(l)&&w(i[e])?i[e]=C(l,i[e],(o?`${o}.`:"")+e.toString(),n):i[e]=l))}return i}function Y(r){return(...t)=>t.reduce((o,n)=>C(o,n,"",r),{})}const Z=Y();var tt=T("<div>"),et=r=>{let t,o;const n=X({height:"auto",width:"100%",series:[],type:"line"},r),i=async()=>{const e={chart:{type:n.type,height:n.height,width:n.width,events:{}},series:j(n.series)};for(const d in r)if(d.startsWith("on")){const v=d.charAt(2).toLowerCase()+d.slice(3);e.chart.events[v]=r[d]}const l=Z(j(n.options),e),y=(await q(async()=>{const{default:d}=await import("./apexcharts.esm-CVCxVBSD.js");return{default:d}},[],import.meta.url)).default;o=new y(t,l),r.ref?.(o),o.render()};return K(()=>{i()}),m(_(()=>n.series,e=>{o.updateSeries(e)},{defer:!0})),m(_(()=>n.options,e=>{o.updateOptions(e)},{defer:!0})),m(_(()=>[n.type,n.height,n.width],()=>{o.destroy(),i()},{defer:!0})),z(()=>{o.destroy()}),(()=>{var e=tt(),l=t;return typeof l=="function"?U(l,e):t=e,e})()},S=et,rt=T('<div class="stat flex-1 place-items-center"><div class="stat-title text-primary-content"></div><div class="stat-value w-full truncate text-center text-2xl text-primary-content lg:text-3xl">'),nt=T('<div class="flex flex-col gap-2 lg:h-full"><div class="stats w-full flex-shrink-0 stats-vertical grid-cols-2 bg-primary shadow lg:flex lg:stats-horizontal"></div><div class="flex flex-col gap-2 rounded-box bg-base-300 py-4 lg:flex-row"><div class=flex-1></div><div class=flex-1></div><div class=flex-1></div></div><footer class="mx-auto mt-4 footer block footer-horizontal rounded-box bg-neutral p-4 text-center text-lg font-bold text-neutral-content">');const p=r=>(()=>{var t=rt(),o=t.firstChild,n=o.nextSibling;return s(o,()=>r.label),s(n,()=>J(()=>r.children)()),t})(),at=()=>{const r=F();if(!E())return r("/setup",{replace:!0}),null;const[t]=G(),[o,n]=I([]),[i,e]=I([]);Q(()=>{V(()=>{n(a=>a.slice(-k)),e(a=>a.slice(-k))})},60*1e3,setInterval);const l=M("traffic");m(()=>{const a=l();a&&n(c=>[...c,a])});const y=f(()=>x.defaultsDeep({title:{text:t("traffic")}},b)),d=f(()=>[{name:t("down"),data:o().map(a=>a.down)},{name:t("up"),data:o().map(a=>a.up)}]),v=f(()=>x.defaultsDeep({title:{text:t("flow")},labels:[t("downloadTotal"),t("uploadTotal")],tooltip:{enabled:!0},chart:{animations:{enabled:!1}}},b)),L=f(()=>[h()?.downloadTotal||0,h()?.uploadTotal||0]),$=M("memory");m(()=>{const a=$()?.inuse;a&&e(c=>[...c,a])});const R=f(()=>x.defaultsDeep({title:{text:t("memory")}},b)),H=f(()=>[{name:t("memory"),data:i()}]);return[u(B,{get children(){return t("overview")}}),(()=>{var a=nt(),c=a.firstChild,O=c.nextSibling,A=O.firstChild,D=A.nextSibling,N=D.nextSibling,W=O.nextSibling;return s(c,u(p,{get label(){return t("upload")},get children(){return[P(()=>g(l()?.up||0).toString()),"/s"]}}),null),s(c,u(p,{get label(){return t("download")},get children(){return[P(()=>g(l()?.down||0).toString()),"/s"]}}),null),s(c,u(p,{get label(){return t("uploadTotal")},get children(){return g(h()?.uploadTotal||0).toString()}}),null),s(c,u(p,{get label(){return t("downloadTotal")},get children(){return g(h()?.downloadTotal||0).toString()}}),null),s(c,u(p,{get label(){return t("activeConnections")},get children(){return h()?.connections?.length||0}}),null),s(c,u(p,{get label(){return t("memoryUsage")},get children(){return g($()?.inuse||0).toString()}}),null),s(A,u(S,{type:"line",get options(){return y()},get series(){return d()}})),s(D,u(S,{type:"pie",get options(){return v()},get series(){return L()}})),s(N,u(S,{type:"line",get options(){return R()},get series(){return H()}})),s(W,()=>E()?.url),a})()]};export{at as default};
