1import{u as T,w as k,v as C,k as U,i as N,c as Y,j as F,_ as H}from"./adminAccess-CLSn5bX2.js";import{R as O,u as j}from"./useRegisterModal-BkvdjoZI.js";import{u as I,e as W}from"./mpa-BmZCX-Jj.js";import{p as z}from"./authRedirect-hUV00kbx.js";import{d as $,r as q,a as R,p as x,c as h,b as m,e as g,g as e,t as d,k as y,w as v,I as G,v as i,y as J}from"./core-DBmSqcqn.js";import{m as K}from"./helpers-Bj1NoKNb.js";import"./authService-9lAuG718.js";const Q="/assets/auth/login-hero.webp",X={class:"login-screen","aria-labelledby":"login-title"},Z={class:"login-panel"},ee={class:"login-panel-inner"},te={class:"login-intro"},se={id:"login-title"},oe={key:0,class:"status-banner",role:"status"},ie={class:"field"},ae={class:"field"},ne={class:"input-shell"},re=["type"],le=["aria-label"],de={class:"sr-only"},ue={key:0,class:"error"},ce=["disabled"],pe={class:"verification-copy"},me={class:"field"},ge={class:"checkbox-row"},fe={class:"otp-actions"},ve=["disabled"],he=["disabled"],ye={key:0,class:"error"},be=["disabled"],_e=$({__name:"LoginView",setup(ke){const s=T(),n=W(),u=I(),f=j(),r=q({email:u.query.email??"",password:""}),a=q({code:"",trustDevice:!0}),c=R(!1),p=R(u.query.notice);x(()=>u.query.email,o=>{r.email=o??""}),x(()=>u.query.notice,o=>{p.value=o});const b=h(()=>p.value==="email-verified"?"Your email has been verified. Sign in to continue.":p.value==="email-already-verified"?"That email address is already verified. Sign in to continue.":p.value==="reset-link-sent"?"We sent password reset instructions to your email.":p.value==="password-reset"?"Your password has been updated. You can sign in now.":p.value==="session-expired"?"Your session expired after inactivity. Sign in again to continue.":""),S=h(()=>f.isOpen.value),_=h(()=>!!s.loginChallenge);async function V(){try{const o=await s.login(r);if(o?.status==="two_factor_required"){a.code="",a.trustDevice=!0;return}if(o?.status==="email_verification_required"){n.replace({name:"email-confirmation",query:{email:o.email,notice:"verification-required",...typeof u.query.redirect=="string"?{redirect:u.query.redirect}:{}}});return}await w()}catch{}}async function M(){try{await s.verifyLoginChallenge({code:a.code,trust_device:a.trustDevice}),await w()}catch{}}async function D(){try{await s.resendLoginChallenge(),a.code=""}catch{}}function E(){a.code="",s.cancelLoginChallenge()}async function w(){if(!z(u.query.redirect,n)){if(Y(s.roles)){n.replace(F(s.roles));return}if(s.hasRole("author")){n.replace("/author/dashboard");return}if(s.hasRole("reader")){n.replace("/reader/dashboard");return}n.replace("/")}}function L(){n.push({name:"forgot-password",query:r.email?{email:r.email}:void 0})}function A(){f.open()}function B(){f.close()}function P(o){f.close(),n.push({name:"register",query:{type:o}})}return(o,t)=>(m(),g("section",X,[t[10]||(t[10]=e("aside",{class:"login-visual"},[e("img",{src:Q,alt:"",class:"login-visual-image"}),e("div",{class:"login-visual-overlay"},[e("div",{class:"login-visual-copy"},[e("h2",null,"Welcome Back!"),e("p",null,"Enjoy hussle free publishing with the largest self publishing platform in Africa")])])],-1)),e("main",Z,[e("div",ee,[e("div",te,[e("h1",se,d(_.value?"Check your email":"Log in to your account"),1)]),b.value?(m(),g("p",oe,d(b.value),1)):y("",!0),_.value?(m(),g("form",{key:2,class:"login-form",onSubmit:k(M,["prevent"])},[e("p",pe," Enter the 6-digit code sent to "+d(i(s).loginChallenge?.email)+" to finish signing in. ",1),e("label",me,[t[7]||(t[7]=e("span",null,"Verification code",-1)),v(e("input",{"onUpdate:modelValue":t[3]||(t[3]=l=>a.code=l),inputmode:"numeric",autocomplete:"one-time-code",maxlength:"6",minlength:"6",pattern:"[0-9]*",required:"",placeholder:"6-digit code","data-required-message":"Enter the 6-digit verification code."},null,512),[[C,a.code,void 0,{trim:!0}]])]),e("label",ge,[v(e("input",{"onUpdate:modelValue":t[4]||(t[4]=l=>a.trustDevice=l),type:"checkbox"},null,512),[[N,a.trustDevice]]),t[8]||(t[8]=e("span",null,"Trust this device for 30 days",-1))]),e("div",fe,[e("button",{type:"button",class:"text-link",disabled:i(s).status==="loading",onClick:D}," Resend code ",8,ve),e("button",{type:"button",class:"text-link",disabled:i(s).status==="loading",onClick:E}," Use a different account ",8,he)]),i(s).error?(m(),g("p",ye,d(i(s).error),1)):y("",!0),e("button",{type:"submit",class:"submit-button",disabled:i(s).status==="loading"},d(i(s).status==="loading"?"Verifyingâ¦":"Verify and continue"),9,be)],32)):(m(),g("form",{key:1,class:"login-form",onSubmit:k(V,["prevent"])},[e("label",ie,[t[5]||(t[5]=e("span",null,"Email",-1)),v(e("input",{"onUpdate:modelValue":t[0]||(t[0]=l=>r.email=l),type:"email",autocomplete:"email",required:"",placeholder:"Email address","data-required-message":"Enter your email address."},null,512),[[C,r.email,void 0,{trim:!0}]])]),e("label",ae,[t[6]||(t[6]=e("span",null,"Password",-1)),e("div",ne,[v(e("input",{"onUpdate:modelValue":t[1]||(t[1]=l=>r.password=l),type:c.value?"text":"password",autocomplete:"current-password",required:"",placeholder:"Password","data-required-message":"Enter your password."},null,8,re),[[U,r.password]]),e("button",{type:"button",class:"toggle-visibility","aria-label":c.value?"Hide password":"Show password",onClick:t[2]||(t[2]=l=>c.value=!c.value)},[e("i",{class:G(c.value?"fa-solid fa-eye-slash":"fa-solid fa-eye")},null,2),e("span",de,d(c.value?"Hide password":"Show password"),1)],8,le)])]),e("div",{class:"login-meta"},[e("button",{type:"button",class:"text-link",onClick:L},"Forgot password?")]),i(s).error?(m(),g("p",ue,d(i(s).error),1)):y("",!0),e("button",{type:"submit",class:"submit-button",disabled:i(s).status==="loading"},d(i(s).status==="loading"?"Signing inâ¦":"Log in"),9,ce)],32)),e("div",{class:"login-secondary"},[t[9]||(t[9]=e("span",null,"New to AfricaRead?",-1)),e("button",{type:"button",class:"text-link",onClick:A},"Create an account")])])]),J(O,{open:S.value,onClose:B,onSelect:P},null,8,["open"])]))}}),we=H(_e,[["__scopeId","data-v-e5386c00"]]);function De(){K(we)}export{De as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.