import{bt as e,en as t,ii as n,xt as r}from"./index-BKLG6eUi.js";function i(e){return e===`uncategorized`?`未分类`:e}function a(){let a=n([]),o=n(!1),s=n(0);async function c(n=!1){n||(o.value=!0);try{let{data:n}=await r(e.serverCategories,()=>t.get(`/servers/categories`)),o=n.categories||[];s.value=o.reduce((e,t)=>e+(t.count||0),0),a.value=o.map(e=>({name:e.name,label:i(e.name),count:e.count})).sort((e,t)=>e.name===`uncategorized`?1:t.name===`uncategorized`?-1:e.label.localeCompare(t.label,`zh`))}catch{a.value=[],s.value=0}finally{n||(o.value=!1)}}return{categories:a,loading:o,totalCount:s,loadCategories:c}}export{a as n,i as t};