import{L as A}from"./CircularLoading.7699468a.js";import{d as T,e as q,o as c,X as m,a as _,b as o,ec as s,u as a,eV as t,c as b,w as u,bK as w,eU as I,cy as R,aF as f,bS as p,cx as x,R as B,$ as L,eq as C,ed as D,f as K,dH as U}from"./vue-router.2a09679a.js";import{_ as $}from"./AbstraLogo.vue_vue_type_script_setup_true_lang.7c2a202d.js";import{T as E}from"./router.c5972afe.js";import{a as h,E as M}from"./gateway.b08a6336.js";import{M as N}from"./member.53ae5da8.js";import"./tables.adb160d4.js";import"./Logo.4bfdee2e.js";import"./popupNotifcation.ed0bf79d.js";import"./record.1f9cddba.js";import"./string.6792602f.js";(function(){try{var l=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(l._sentryDebugIds=l._sentryDebugIds||{},l._sentryDebugIds[n]="3ea4b398-dab0-493e-93a9-3d11753d3973",l._sentryDebugIdIdentifier="sentry-dbid-3ea4b398-dab0-493e-93a9-3d11753d3973")}catch{}})();const S={class:"form"},V={class:"header"},F={class:"description"},O={class:"description"},j={class:"footer"},z={key:2,class:"loading"},H=T({__name:"Passwordless",emits:["done"],setup(l,{emit:n}){const e=q({stage:"collect-info",info:{email:""},token:"",invalid:!1,secsToAllowResend:0});let i;const r=async()=>{e.value.stage="loading";try{await h.authenticate(e.value.info.email),e.value.stage="collect-token",e.value.secsToAllowResend=120,clearInterval(i),i=setInterval(()=>{e.value.secsToAllowResend-=1,e.value.secsToAllowResend<=0&&clearInterval(i)},1e3)}catch{e.value.invalid=!0,e.value.stage="collect-info"}},y=async()=>{var v;if(!!((v=e.value.info)!=null&&v.email)){e.value.stage="loading";try{const d=await h.verify(e.value.info.email,e.value.token);if(!d)throw new Error("[Passwordless] Login did not return an user");E.trackSession(),n("done",d),e.value.stage="done"}catch{e.value.invalid=!0,e.value.stage="collect-token"}}},k=()=>{e.value.info&&r()},P=()=>{e.value.stage="collect-info",e.value.info={email:""},e.value.token="",e.value.invalid=!1};return(v,d)=>(c(),m("div",S,[_("div",V,[o($,{"hide-text":"",size:"large"}),_("h2",null,s(a(t).translate("i18n_auth_validate_your_email_login",null,{brandName:"Abstra"})),1)]),e.value.stage==="collect-info"?(c(),b(a(x),{key:0,class:"section"},{default:u(()=>[_("div",F,s(a(t).translate("i18n_auth_info_description")),1),o(a(R),{"has-feedback":"","validate-status":e.value.invalid?"error":"",help:e.value.invalid?a(t).translate("i18n_auth_info_invalid_email"):""},{default:u(()=>[o(a(w),{value:e.value.info.email,"onUpdate:value":d[0]||(d[0]=g=>e.value.info.email=g),placeholder:a(t).translate("i18n_auth_enter_your_work_email"),onKeyup:I(r,["enter"])},null,8,["value","placeholder","onKeyup"])]),_:1},8,["validate-status","help"]),o(a(p),{type:"primary",onClick:r},{default:u(()=>[f(s(a(t).translate("i18n_auth_info_send_code")),1)]),_:1})]),_:1})):e.value.stage==="collect-token"?(c(),b(a(x),{key:1,class:"section"},{default:u(()=>[_("div",O,s(a(t).translate("i18n_auth_token_label",null,e.value.info)),1),o(a(R),{"has-feedback":"","validate-status":e.value.invalid?"error":"",help:e.value.invalid?a(t).translate("i18n_auth_token_invalid"):""},{default:u(()=>[o(a(w),{value:e.value.token,"onUpdate:value":d[1]||(d[1]=g=>e.value.token=g),type:"text",placeholder:a(t).translate("i18n_auth_enter_your_token"),onKeyup:I(y,["enter"])},null,8,["value","placeholder","onKeyup"])]),_:1},8,["validate-status","help"]),o(a(p),{type:"primary",onClick:y},{default:u(()=>[f(s(a(t).translate("i18n_auth_token_verify_email")),1)]),_:1}),o(a(p),{onClick:P},{default:u(()=>[f(s(a(t).translate("i18n_auth_edit_email")),1)]),_:1}),o(a(p),{disabled:!!e.value.secsToAllowResend,onClick:k},{default:u(()=>[f(s(a(t).translate("i18n_auth_token_resend_email"))+" ("+s(e.value.secsToAllowResend)+" s) ",1)]),_:1},8,["disabled"]),_("div",j,s(a(t).translate("i18n_auth_token_footer_alternative_email")),1)]),_:1})):e.value.stage==="loading"?(c(),m("div",z,[o(A)])):B("",!0)]))}});const X=L(H,[["__scopeId","data-v-6748830b"]]),G=async()=>{const l=await N.onboarding(),n=h.getAuthor();if(l.shouldBeOnboarded&&n){const e=`${M.onboarding}/schedule`,i=new URLSearchParams({token:n.jwt}),r=e+"?"+i;window.location.replace(r)}},J={key:0,class:"login"},Q={key:1,class:"loading"},W=T({__name:"Login",setup(l){const n=C(),e=D();async function i(){await G(),e.query.redirect?await n.push({path:e.query.redirect,query:{...e.query,redirect:e.query["prev-redirect"],"prev-redirect":void 0}}):n.push({name:"home"})}const r=K(()=>!h.getAuthor());return U(()=>{r.value||i()}),(y,k)=>r.value?(c(),m("div",J,[o(X,{onDone:i})])):(c(),m("div",Q,[o(A)]))}});const de=L(W,[["__scopeId","data-v-e4e9b925"]]);export{de as default};
//# sourceMappingURL=Login.bcf7a381.js.map
