1import{a0 as e,R as a,aa as s,O as t,r,o as i,c as o,b as n,u as l,e as d,V as u,F as c,i as m,w as p,d as f,b6 as g,Q as y,ag as _,ab as w,ac as x,D as h,bK as b,bc as v}from"./index-CcZ45_S5.js";import{F as k}from"./index.es-0vjt-INv.js";import{f as j}from"./index-BtVxpgnl.js";import{u as q}from"./useQueryClient-D_RWsVuD.js";import{u as E}from"./useMutation-Ca8CgNX9.js";import{T}from"./test-ids-C_9vcHPk.js";import{d as S}from"./queryKeys-DpAWY-q4.js";import{m as P}from"./annotate-Cm-iLXzC.js";import{_ as F}from"./_plugin-vue_export-helper-BCo6x5W8.js";const H={class:"pdap-flex-container mx-auto max-w-2xl pb-24"},L={key:0,class:"flex items-center justify-center h-full w-full"},Q=["data-test"],R=["data-test"],C={class:"flex flex-col items-start sm:flex-row sm:items-center sm:gap-4 w-full"},G=F({__name:"sign-in",setup(F){const G=e(),K=a(),Y=s(),A=q(),D=()=>A.invalidateQueries({queryKey:[S]}),I=[{name:"email",validators:{required:{value:!0},email:{message:"Please provide your email address",value:!0}}},{name:"password",validators:{required:{value:!0}}}],{isError:O,data:z,mutate:M,isLoading:V}=E({mutationFn:async function(){if(G.isAuthenticated())return Y.push(G.redirectTo??{path:"/profile"});try{const e=K.query.gh_access_token;if(e){if(await b(e))return Y.push(G.redirectTo??{path:"/profile"})}return null}catch(e){if(e.response.data.message.includes("already exists"))return G.setRedirectTo(G.redirectTo??{path:"/profile"}),{userExists:!0};throw e}},onSuccess:e=>{e&&!(null==e?void 0:e.userExists)&&(D(),Y.replace(G.redirectTo??{path:"/profile"}))}}),{mutate:B,isLoading:J}=E({mutationFn:e=>async function(e){const{email:a,password:s}=e;await v(a,s),P()}(e),onError:()=>{N.value="Error logging in. Please ensure your password is correct and try again."},onSuccess:()=>{D(),Y.replace(G.redirectTo??"/profile")}});t(()=>K.query.gh_access_token,(e,a)=>{e&&e!==a&&M()},{immediate:!0});const N=h(void 0);return(e,a)=>{var s,t,h,b;const v=r("RouterLink");return i(),o("main",H,[a[6]||(a[6]=n("h1",null,"Sign In",-1)),l(O)||(null==(s=l(z))?void 0:s.userExists)||!l(V)&&!l(K).query.gh_access_token?(i(),o(c,{key:1},[l(O)?(i(),o("p",{key:0,class:"error","data-test":l(T).error_message}," There was an error logging you in with GitHub. Please try again ",8,Q)):(i(),o(c,{key:1},[(null==(h=l(z))?void 0:h.userExists)?(i(),o("p",{key:0,class:"error","data-test":l(T).error_message}," You already have an account with this email address. Please sign in and link your existing account to GitHub from your profile. ",8,R)):m("",!0),d(l(y),{class:"border-2 border-neutral-950 border-solid [&>svg]:ml-0",intent:"tertiary","data-test":l(T).github_signin_button,disabled:null==(b=l(z))?void 0:b.userExists,onClick:a[0]||(a[0]=async()=>await l(g)())},{default:p(()=>[d(l(k),{icon:l(j)},null,8,["icon"]),a[1]||(a[1]=f(" Sign in with GitHub ",-1))]),_:1},8,["data-test","disabled"])],64)),a[5]||(a[5]=n("h2",null,"Or sign in with email",-1)),d(l(x),{id:"login",class:"flex flex-col gap-2","data-test":l(T).sign_in_form,name:"login",error:N.value,schema:I,onSubmit:l(B)},{default:p(()=>[d(l(_),{id:"email",autocomplete:"email","data-test":l(T).email_input,name:"email",label:"Email",type:"text",placeholder:"Your email address"},null,8,["data-test"]),d(l(w),{id:"password",autocomplete:"password","data-test":l(T).password_input,name:"password",label:"Password",type:"password",placeholder:"Your password"},null,8,["data-test"]),d(l(y),{class:"max-w-full mt-4",disabled:l(J),"is-loading":l(J),type:"submit","data-test":l(T).sign_in_submit},{default:p(()=>[...a[2]||(a[2]=[f(" Sign in ",-1)])]),_:1},8,["disabled","is-loading","data-test"])]),_:1},8,["data-test","error","onSubmit"]),n("div",C,[d(v,{class:"pdap-button-secondary flex-1 max-w-full",intent:"secondary","data-test":l(T).sign_up_link,to:"/sign-up"},{default:p(()=>[...a[3]||(a[3]=[f(" Create Account ",-1)])]),_:1},8,["data-test"]),d(v,{class:"pdap-button-secondary flex-1 max-w-full","data-test":l(T).forgot_password_link,to:"/request-reset-password"},{default:p(()=>[...a[4]||(a[4]=[f(" Reset Password ",-1)])]),_:1},8,["data-test"])])],64)):(i(),o("div",L,[d(l(u),{show:!(l(O)||(null==(t=l(z))?void 0:t.userExists))&&(l(V)||l(K).query.gh_access_token),text:"Logging in"},null,8,["show"])]))])}}},[["__scopeId","data-v-b3897a74"]]);export{G 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.