import{l as e,lt as t}from"./runtime-core.esm-bundler-DbRZbT7v.js";import{a as n,d as r}from"./index-Mgun2LFs.js";import{t as i}from"./request-DG5cMCYw.js";function a(e){return i.post(`/auth/login`,e)}function o(){return i.post(`/auth/logout`)}function s(){return i.get(`/auth/me`)}var c=r({useUserStore:()=>l}),l=n(`user`,()=>{let n=t(localStorage.getItem(`token`)||``),r=t(null),i=t([]),c=t([]),l=e(()=>!!n.value),u=e(()=>r.value?.is_super===!0||r.value?.is_super===1);async function d(e){let t=await a(e),{token:r}=t.data;return n.value=r,localStorage.setItem(`token`,r),t}async function f(){let e=await s(),t=e.data;return r.value=t,i.value=t.permissions||[],c.value=t.menus||[],e}async function p(){try{await o()}catch{}finally{n.value=``,r.value=null,i.value=[],c.value=[],localStorage.removeItem(`token`),localStorage.removeItem(`userInfo`)}}function m(e){return u.value?!0:i.value.includes(e)}return{token:n,userInfo:r,permissions:i,menus:c,isLoggedIn:l,isSuper:u,login:d,getInfo:f,logout:p,hasPermission:m}});export{c as n,l as t};