import{a6 as e,aU as a,aK as s,aW as l,aO as t,a as o,Q as n,T as r,g as i,bv as u,a1 as c,h as d,o as g,X as m,a3 as p,a4 as b,Y as f,$ as v,u as y}from"./index.9313841a.js";import{Q as S}from"./QPage.51e20052.js";import{u as h}from"./use-quasar.ca800b49.js";import{u as j,g as k}from"./common.356e5c35.js";import{a as w}from"./api.c096d0cb.js";import"./index.d11c4764.js";var x=e({name:"QInnerLoading",props:{...a,...s,showing:Boolean,color:String,size:{type:[String,Number],default:"42px"},label:String,labelClass:String,labelStyle:[String,Array,Object]},setup(e,{slots:a}){const s=i(),c=l(e,s.proxy.$q),{transitionProps:d,transitionStyle:g}=t(e),m=o((()=>"q-inner-loading q--avoid-card-border absolute-full column flex-center"+(!0===c.value?" q-inner-loading--dark":""))),p=o((()=>"q-inner-loading__label"+(void 0!==e.labelClass?` ${e.labelClass}`:"")));function b(){return!0===e.showing?n("div",{class:m.value,style:g.value},void 0!==a.default?a.default():function(){const a=[n(u,{size:e.size,color:e.color})];return void 0!==e.label&&a.push(n("div",{class:p.value,style:e.labelStyle},[e.label])),a}()):null}return()=>n(r,d.value,b)}});const _={key:1},q={__name:"LoginPage",setup(e){const a=c(),s=h(),l=d(null),t=d(!1);return g((()=>{new WebSocket({}.API_WS_URL).onmessage=({data:e})=>{var o;if("hello"===(e=JSON.parse(e)).type){l.value=e.cid;const a={}.API_URL+"/login?cid="+l.value;w.post("login",{json:{url:a}})}else if("token"===e.type){t.value=!0,j.value=e.user,localStorage.setItem("user",JSON.stringify(j.value)),w.post("user",{json:{token:e.token,id:e.user.id,name:e.user.name}}),s.cookies.set("token",e.token,{expires:360,sameSite:"Strict",secure:!0}),"OFFLINE"===(null==(o=k())?void 0:o.syncData)&&s.notify({message:"Offline mode enabled, data will not be synced, you can change that from settings.",color:"warning",timeout:0,actions:[{label:"Dismiss",color:"white",handler:()=>{}}]});const l=a.currentRoute.value.query.redirect||"/apps-library";a.replace({path:l})}}})),(e,a)=>(m(),p(S,{class:"flex items-center justify-center"},{default:b((()=>[t.value?(m(),f("div",_,"Logged in as "+v(y(j).name),1)):(m(),p(x,{key:0,showing:!0,label:"Waiting for the login in the browser window...","label-class":"text-teal","label-style":"font-size: 1.1em"}))])),_:1}))}};export{q as default};
