import{Tt as e}from"./vue-vendor-DMUmTARL.js";import{r as t}from"./admin-monitor-CH173huO.js";function n(n={}){let{onTrend:r}=n,i=e(null),a=e(null),o=e(!0),s=e(!1),c=e(null),l=e(null),u=e(!1),d=e(5),f=e(5),p=()=>t().then(e=>{i.value=e.data;let t=new Date;a.value=`${t.getHours().toString().padStart(2,`0`)}:${t.getMinutes().toString().padStart(2,`0`)}:${t.getSeconds().toString().padStart(2,`0`)}`,r?.(e.data?.trend||[]),s.value=!1}).catch(()=>{s.value=!0}).finally(()=>{o.value=!1}),m=()=>{f.value=d.value,l.value&&clearInterval(l.value),l.value=setInterval(()=>{!u.value&&f.value>0&&f.value--},1e3)},h=()=>{c.value&&clearInterval(c.value),c.value=setInterval(()=>{u.value||(p(),f.value=d.value)},d.value*1e3)};return{monitorData:i,lastUpdateTime:a,isLoading:o,isError:s,isPaused:u,refreshInterval:d,countdown:f,loadMonitorData:p,togglePause:()=>{u.value=!u.value,u.value?(c.value&&=(clearInterval(c.value),null),l.value&&=(clearInterval(l.value),null)):(h(),m())},changeInterval:e=>{let t=Math.max(1,Math.min(60,e));d.value=t,f.value=t,h()},start:()=>{p(),h(),m()},stop:()=>{c.value&&=(clearInterval(c.value),null),l.value&&=(clearInterval(l.value),null)}}}export{n as t};