import{L as T}from"./CircularLoading.cc5ea3b3.js";import{d as x,e as q,o as c,X as m,a as _,b as t,ec as s,u as a,eV as n,c as w,w as u,bK as b,eU as I,cy as L,aF as f,bS as p,cx as R,R as B,$ as A,eq as C,ed as D,f as K,dH as U}from"./vue-router.4a8a3251.js";import{L as E}from"./Logo.ba350f35.js";import{T as M}from"./router.306a90e5.js";import{a as h,E as S}from"./gateway.8fe65dcb.js";import{M as V}from"./member.4276e668.js";import"./tables.fc036ba1.js";import"./popupNotifcation.d430940c.js";import"./record.2a0e778d.js";import"./string.26e1c29c.js";(function(){try{var l=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},o=new Error().stack;o&&(l._sentryDebugIds=l._sentryDebugIds||{},l._sentryDebugIds[o]="93aa8720-fef1-49ac-bda4-dd09229d5385",l._sentryDebugIdIdentifier="sentry-dbid-93aa8720-fef1-49ac-bda4-dd09229d5385")}catch{}})();const $={class:"form"},F={class:"header"},N={class:"description"},O={class:"description"},j={class:"footer"},z={key:2,class:"loading"},H=x({__name:"Passwordless",emits:["done"],setup(l,{emit:o}){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");M.trackSession(),o("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",$,[_("div",F,[t(E,{"hide-text":"",size:"large"}),_("h2",null,s(a(n).translate("i18n_auth_validate_your_email_login")),1)]),e.value.stage==="collect-info"?(c(),w(a(R),{key:0,class:"section"},{default:u(()=>[_("div",N,s(a(n).translate("i18n_auth_info_description")),1),t(a(L),{"has-feedback":"","validate-status":e.value.invalid?"error":"",help:e.value.invalid?a(n).translate("i18n_auth_info_invalid_email"):""},{default:u(()=>[t(a(b),{value:e.value.info.email,"onUpdate:value":d[0]||(d[0]=g=>e.value.info.email=g),placeholder:"Work email address",onKeyup:I(r,["enter"])},null,8,["value","onKeyup"])]),_:1},8,["validate-status","help"]),t(a(p),{type:"primary",onClick:r},{default:u(()=>[f(s(a(n).translate("i18n_auth_info_send_code")),1)]),_:1})]),_:1})):e.value.stage==="collect-token"?(c(),w(a(R),{key:1,class:"section"},{default:u(()=>[_("div",O,s(a(n).translate("i18n_auth_token_label",null,e.value.info)),1),t(a(L),{"has-feedback":"","validate-status":e.value.invalid?"error":"",help:e.value.invalid?a(n).translate("i18n_auth_token_invalid"):""},{default:u(()=>[t(a(b),{value:e.value.token,"onUpdate:value":d[1]||(d[1]=g=>e.value.token=g),type:"text",placeholder:"Type your verification code",onKeyup:I(y,["enter"])},null,8,["value","onKeyup"])]),_:1},8,["validate-status","help"]),t(a(p),{type:"primary",onClick:y},{default:u(()=>[f(s(a(n).translate("i18n_auth_token_verify_email")),1)]),_:1}),t(a(p),{onClick:P},{default:u(()=>[f(s(a(n).translate("i18n_auth_edit_email")),1)]),_:1}),t(a(p),{disabled:!!e.value.secsToAllowResend,onClick:k},{default:u(()=>[f(s(a(n).translate("i18n_auth_token_resend_email"))+" ("+s(e.value.secsToAllowResend)+" s) ",1)]),_:1},8,["disabled"]),_("div",j,s(a(n).translate("i18n_auth_token_footer_alternative_email")),1)]),_:1})):e.value.stage==="loading"?(c(),m("div",z,[t(T)])):B("",!0)]))}});const W=A(H,[["__scopeId","data-v-0a23904b"]]),X=async()=>{const l=await V.onboarding(),o=h.getAuthor();if(l.shouldBeOnboarded&&o){const e=`${S.onboarding}/schedule`,i=new URLSearchParams({token:o.jwt}),r=e+"?"+i;window.location.replace(r)}},G={key:0,class:"login"},J={key:1,class:"loading"},Q=x({__name:"Login",setup(l){const o=C(),e=D();async function i(){await X(),e.query.redirect?await o.push({path:e.query.redirect,query:{...e.query,redirect:e.query["prev-redirect"],"prev-redirect":void 0}}):o.push({name:"home"})}const r=K(()=>!h.getAuthor());return U(()=>{r.value||i()}),(y,k)=>r.value?(c(),m("div",G,[t(W,{onDone:i})])):(c(),m("div",J,[t(T)]))}});const re=A(Q,[["__scopeId","data-v-e4e9b925"]]);export{re as default};
//# sourceMappingURL=Login.adecca68.js.map
