import{Lt as e,lr as t,xr as n}from"./index-D1zydkDr.js";function r(){let r=n([]),i=n(!1),a=n(1),o=n(20),s=n(0),c=n(``);async function l(){i.value=!0;try{let t=await e.get(`/servers/`,{page:a.value,per_page:o.value,search:c.value||void 0});r.value=t.items||[],s.value=t.total||0}catch(e){throw r.value=[],s.value=0,e}finally{i.value=!1}}let u;t(()=>clearTimeout(u));function d(){clearTimeout(u),u=setTimeout(()=>{a.value=1,l()},300)}function f(e){a.value=e,l()}function p(e){o.value=e,a.value=1,l()}return{servers:r,loading:i,page:a,itemsPerPage:o,total:s,search:c,loadServers:l,onSearch:d,onPageChange:f,onItemsPerPageChange:p}}function i(e){switch(e){case`online`:return`success`;case`offline`:return`error`;default:return`warning`}}function a(e){switch(e){case`online`:return`在线`;case`offline`:return`离线`;default:return`未知`}}function o(e){if(!e)return`—`;let t=new Date(e);if(isNaN(t.getTime()))return`—`;let n=Date.now()-t.getTime();return n<6e4?`刚刚`:n<36e5?`${Math.floor(n/6e4)} 分钟前`:n<864e5?`${Math.floor(n/36e5)} 小时前`:`${Math.floor(n/864e5)} 天前`}export{r as i,i as n,a as r,o as t};