import{l as x,u as S,af as C,i as p,A as B,az as f,c as w,D as U,x as o,G as V,a as l,b as i,w as y,ag as b,o as d,av as h,s as $}from"./entry-28ede74.js";import{b as F,a as L,u as N,g,_ as z,c as A,k as D}from"./passwordModalStore-28ede74.js";const E=""+new URL("locked_bar-28ede74.png",import.meta.url).href,P={class:"w-full min-h-[calc(100vh-2rem)] flex flex-col items-center justify-center gap-6"},I=x({__name:"login",setup(T){S({title:"🔒 BUSY Bar Virtual LAN",meta:[{name:"description",content:"[Locked] Control your BUSY Bar in the browser"}]});const t=F(),u=L(),c=N(),v=C(),m=p(!0),a=p(!1);async function k(){if(!a.value){a.value=!0;try{c.apiKey=t.passwordModel.current,await u.fetchSystemStatus(!0),await f("/")}catch(s){const e=r=>typeof r=="object"&&r!==null&&"data"in r;e(s)&&s.data?.error==="Forbidden"?(c.apiKey=null,t.passwordModel.current="",t.passwordModel.currentWrong=!0):(console.error("Error fetching system status:",s),v.add({id:"system-status-error",title:"Failed to fetch system status",description:e(s)?s.data?.error||g:g,icon:"i-ri-alert-line",color:"error",duration:1e4}))}a.value=!1}}return B(async()=>{try{await u.fetchSystemStatus(),await f("/")}catch{}setTimeout(()=>{m.value=!1},500)}),(s,e)=>{const r=b,_=A,M=z;return d(),w("div",P,[o(m)?U("",!0):(d(),w(V,{key:0},[e[4]||(e[4]=l("div",{class:"text-xl font-medium"},"Virtual LAN is locked",-1)),e[5]||(e[5]=l("img",{src:E,class:"w-[300px] my-4"},null,-1)),e[6]||(e[6]=l("div",null,"Enter your password to unlock",-1)),i(M,{class:"w-full",error:o(t).currentPasswordValidation},{default:y(()=>[h((d(),$(_,{modelValue:o(t).passwordModel.current,"onUpdate:modelValue":[e[1]||(e[1]=n=>o(t).passwordModel.current=n),e[2]||(e[2]=n=>o(t).passwordModel.currentWrong=!1)],size:"xl",variant:"soft",type:o(t).passwordModel.showCurrent?"text":"password",placeholder:"Password"},{trailing:y(()=>[i(r,{icon:o(t).passwordModel.showCurrent?"i-ri-eye-close-line":"i-ri-eye-line",variant:"ghost",color:"neutral",square:"",class:"rounded-full",ui:{leadingIcon:"size-6 text-muted"},onClick:e[0]||(e[0]=n=>o(t).passwordModel.showCurrent=!o(t).passwordModel.showCurrent)},null,8,["icon"])]),_:1},8,["modelValue","type"])),[[o(D),"##########"]])]),_:1},8,["error"]),i(r,{label:"Unlock",color:"primary",size:"lg",class:"h-10",block:"",loading:o(a),onClick:e[3]||(e[3]=n=>k())},null,8,["loading"])],64))])}}});export{I as default};
