import{A as D,a3 as Z,o as ee,a0 as te,T as A,cC as ne,a1 as re,R as $,d as oe,u as se,E as ie,al as ae,p as R,d3 as le,am as C,cp as ce,G as de,q as ue,e as S,f as F,j as c,w as u,g as i,an as me,t as l,h as o,s as _e,aF as b,i as ge,k,aL as I,x as N,X as B,_ as pe,cl as fe,d4 as ze,d5 as ve,aM as we,M as O,c1 as P,ao as he,ap as x,m as ye}from"./index-B4gewkxT.js";import{I as be}from"./IllustrationAndContentColumns-CSHDHow3.js";import{a as E}from"./index-BBtxBH0G.js";(function(){try{var m=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new m.Error().stack;n&&(m._sentryDebugIds=m._sentryDebugIds||{},m._sentryDebugIds[n]="4cde4546-2e55-41a9-9657-27b6229f4888",m._sentryDebugIdIdentifier="sentry-dbid-4cde4546-2e55-41a9-9657-27b6229f4888")}catch{}})();function xe(){const m=D(),{navigate:n}=Z(),e=E("redirectUrl"),t=E("redirect"),z=E("context");return ee(()=>{var d,_;(Array.isArray(e.value)||(d=e.value)!=null&&d.match(/\/(register|login)/gim))&&(e.value=void 0),(Array.isArray(t.value)||(_=t.value)!=null&&_.match(/\/(register|login)/gim))&&(t.value=void 0)}),{redirect:d=>{var a,w;const v=e.value||t.value||void 0||(d==null?void 0:d.fallbackUrl),p=(w=(a=m.authentifiedUser)==null?void 0:a.business_lines)==null?void 0:w.some(f=>f===te.LECLUB);return v?v.replace(/\/$/,"")==="https://www.frenchfounders.com"&&p?n({name:A.HOME}):ne(v||"/"):z.value==="pro"?n({name:re.HOME}):n(p?{name:A.HOME}:{name:$.HOME})}}}const Ee={class:"login"},Re={href:"/",class:"login__logo-container"},Se={class:"title-3 m-0 mb-1r"},ke={class:"title-4 mb-10r font-normal"},Le={class:"login__mail-group"},Ce={class:"login__info-title"},Fe={class:"login__info-title"},Ie={class:"login__register-fields"},Ne={class:"login__info-title"},Be={class:"login__info-title"},Me={class:"login__info-title"},Ue={class:"login__info-title"},Ae={class:"login__via-group"},Oe={class:"login__via-text text-sm"},Pe={class:"login__layout-aside"},Te={class:"login__aside"},De={class:"login__aside-content"},$e={class:"title-3 mb-6r"},q=oe({__name:"LoginPage",emits:["error","pending","success"],setup(m){const{t:n}=se(),e=D(),{handleSubmit:t,meta:z,setFieldValue:M}=ie(),{toast:d}=ae(),_=E("force-email"),v=E("redirectUrl","",{transform:String}),{redirect:p}=xe(),a=R("default"),w=R(""),f=R(null),L=R(null),V=le(),{mutate:G,isPending:H}=C({mutationFn:r=>he.verifyEmail(r),onSuccess:r=>{a.value=r?"login":"register",O(()=>{var g;const s=(g=V.value)==null?void 0:g.querySelector(a.value==="login"?'[data-testid="password"]':'[data-testid="first-name"]');s==null||s.focus()})},onError:()=>{d({type:x.ERROR,title:n("error.generic.title"),text:n("error.generic.text")})}}),{mutate:W,isPending:Q}=C({mutationFn:r=>e.loginRoom({username:r.email,password:r.password}),onSuccess:({redirect:r})=>{p({fallbackUrl:r})},onError:r=>{var s;((s=r.response)==null?void 0:s.status)===401?d({type:x.ERROR,title:n("error.invalid_crendentials.title"),text:n("error.invalid_crendentials.text")}):(console.error(r),d({type:x.ERROR,title:n("error.generic.title"),text:n("error.generic.text")}))}}),{mutate:j,isPending:J}=C({mutationFn:r=>{const s={email:r.email,firstName:r.firstName,lastName:r.lastName,password:r.password,suw:"password",isBpi:v.value.includes("cfo-bpi")};return e.register(s)},onSuccess:({meta:r})=>{p({fallbackUrl:r.redirect}),d({type:x.SUCCESS,title:n("success.register.title"),text:n("success.register.text")})},onError:r=>{console.error(r),d({type:x.ERROR,title:n("error.generic.title"),text:n("error.generic.text")})}});ce(()=>{_.value&&(M("email",_.value),U())}),de(a,()=>{O(()=>{a.value==="login"?h(f.value,!0):a.value==="register"?h(L.value,!0):(h(L.value,!1),h(f.value,!1),h(f.value,!1))})});const h=(r,s)=>{if(!r)return null;const g={height:0,opacity:0,easing:"power2",duration:.5};s?P.fromTo(r,g,{height:"auto",opacity:1}):P.to(r,g)},X=t(r=>{if("firstName"in r)j(r);else throw new Error(`Wrong form values sent for "register": ${r}`)}),K=t(r=>{if("password"in r)W(r);else throw new Error(`Wrong form values sent for "login": ${r}`)}),Y=t(r=>{G(r)}),U=()=>{switch(a.value){case"default":return Y();case"login":return K();case"register":return X();default:throw new Error(`${a.value} action not supported`)}};return(r,s)=>{const g=ue("safe-html");return S(),F("div",Ee,[c(be,{reverse:""},{default:u(()=>[i("a",Re,[c(me,{class:"login__logo",dark:"",height:"30"})]),i("form",{class:"login__content",onSubmit:we(U,["prevent"])},[i("h1",Se,l(o(n)("hello")),1),_e(i("p",ke,null,512),[[g,o(n)("title")]]),i("div",Le,[c(b,{name:"email",rules:"required|email",class:"login__info-input","data-testid":"email",disabled:!!o(_),onInput:s[0]||(s[0]=y=>a.value="default")},{default:u(()=>[i("span",Ce,l(o(n)("mail")),1)]),_:1},8,["disabled"])]),a.value==="default"?(S(),ge(N,{key:0,class:"mt-4",type:o(I).SUBMIT,disabled:!o(z).valid,pending:o(H),"test-id":"login-or-register"},{default:u(()=>[k(l(o(n)("connect")),1)]),_:1},8,["type","disabled","pending"])):B("",!0),a.value==="login"?(S(),F("div",{key:1,ref_key:"loginFieldsEl",ref:f},[c(b,{modelValue:w.value,"onUpdate:modelValue":s[1]||(s[1]=y=>w.value=y),type:"password",name:"password","show-eye":"",rules:"required|min:6",class:"login__info-input","data-testid":"password"},{default:u(()=>[i("span",Fe,l(o(n)("password")),1)]),_:1},8,["modelValue"]),c(pe,{to:{name:o($).PASSWORD_FORGOT},class:"login__forgot-password text-xs"},{default:u(()=>[k(l(o(n)("forgot_password")),1)]),_:1},8,["to"]),c(N,{class:"login__action mt-4",disabled:!o(z).valid,pending:o(Q),type:o(I).SUBMIT,"test-id":"login"},{default:u(()=>[k(l(o(n)("login")),1)]),_:1},8,["disabled","pending","type"])],512)):B("",!0),a.value==="register"?(S(),F("div",{key:2,ref_key:"registerFieldsEl",ref:L},[i("div",Ie,[c(b,{name:"firstName",rules:"required","data-testid":"first-name"},{default:u(()=>[i("span",Ne,l(o(n)("first_name")),1)]),_:1}),c(b,{name:"lastName",rules:"required","data-testid":"last-name"},{default:u(()=>[i("span",Be,l(o(n)("last_name")),1)]),_:1}),c(fe,{name:"password","test-id":"password"},{default:u(()=>[i("span",Me,l(o(n)("create_password")),1)]),_:1}),c(b,{name:"passwordBis","show-eye":"",rules:"required|confirmed:@password",type:"password","data-testid":"confirm-password"},{default:u(()=>[i("span",Ue,l(o(n)("confirm_password")),1)]),_:1})]),c(N,{class:"login__action mt-8",disabled:!o(z).valid,pending:o(J),type:o(I).SUBMIT,"test-id":"register"},{default:u(()=>[k(l(o(n)("register")),1)]),_:1},8,["disabled","pending","type"])],512)):B("",!0),i("div",Ae,[i("div",Oe,l(o(n)("via")),1)]),c(ze,{type:"login",size:"large",onError:s[2]||(s[2]=y=>r.$emit("error",y)),onSuccess:s[3]||(s[3]=()=>o(p)()),onPending:s[4]||(s[4]=y=>r.$emit("pending"))}),c(ve,{type:"login",size:"large"})],32)]),illustration:u(()=>[i("div",Pe,[i("div",Te,[i("div",De,[i("h2",$e,l(o(n)("aside_title")),1),i("p",null,l(o(n)("aside_text")),1)])])])]),_:1})])}}});function T(m){const n=m;n.__i18n=n.__i18n||[],n.__i18n.push({locale:"",resource:{fr:{hello:e=>{const{normalize:t}=e;return t(["Bonjour,"])},title:e=>{const{normalize:t}=e;return t(["saisissez votre <span class='font-medium'>e-mail</span> pour vous connecter ou créer un compte"])},mail:e=>{const{normalize:t}=e;return t(["Adresse e-mail"])},login:e=>{const{normalize:t}=e;return t(["Connexion"])},first_name:e=>{const{normalize:t}=e;return t(["Prénom"])},last_name:e=>{const{normalize:t}=e;return t(["Nom"])},password:e=>{const{normalize:t}=e;return t(["Mot de passe"])},create_password:e=>{const{normalize:t}=e;return t(["Créez un mot de passe"])},confirm_password:e=>{const{normalize:t}=e;return t(["Confirmez le mot de passe"])},forgot_password:e=>{const{normalize:t}=e;return t(["Mot de passe oublié ?"])},register:e=>{const{normalize:t}=e;return t(["S'inscrire"])},connect:e=>{const{normalize:t}=e;return t(["Connexion / Inscription"])},google:e=>{const{normalize:t}=e;return t(["Se connecter avec Google"])},linkedin:e=>{const{normalize:t}=e;return t(["Se connecter avec Linkedin"])},via:e=>{const{normalize:t}=e;return t(["Ou via"])},new:e=>{const{normalize:t}=e;return t(["Nouveau ? Je m'inscris"])},aside_title:e=>{const{normalize:t}=e;return t(["Donnez de l’élan à vos projets professionnels ou entrepreneuriaux"])},aside_text:e=>{const{normalize:t}=e;return t(["Qu’il s’agisse de trouver votre futur défi, de participer à des événements de networking ou de faire grandir votre entreprise, accédez grâce à votre compte à l’ensemble des services Frenchfounders."])},error:{invalid_crendentials:{title:e=>{const{normalize:t}=e;return t(["Connexion impossible"])},text:e=>{const{normalize:t}=e;return t(["Impossible de se connecter avec ces identifiants"])}}},success:{register:{title:e=>{const{normalize:t}=e;return t(["Compte créé"])},text:e=>{const{normalize:t}=e;return t(["Bienvenue sur la plateforme Frenchfounders."])}}}},en:{hello:e=>{const{normalize:t}=e;return t(["Hello,"])},title:e=>{const{normalize:t}=e;return t(["type your <span class='font-medium'>e-mail</span> to log in or create an account"])},mail:e=>{const{normalize:t}=e;return t(["E-mail address"])},login:e=>{const{normalize:t}=e;return t(["Log in"])},first_name:e=>{const{normalize:t}=e;return t(["First name"])},last_name:e=>{const{normalize:t}=e;return t(["Last name"])},password:e=>{const{normalize:t}=e;return t(["Password"])},create_password:e=>{const{normalize:t}=e;return t(["Type a password"])},confirm_password:e=>{const{normalize:t}=e;return t(["Confirm the password"])},forgot_password:e=>{const{normalize:t}=e;return t(["Forgot password ?"])},register:e=>{const{normalize:t}=e;return t(["Register"])},connect:e=>{const{normalize:t}=e;return t(["Log in / Register"])},google:e=>{const{normalize:t}=e;return t(["Log in with Google"])},linkedin:e=>{const{normalize:t}=e;return t(["Log in with Linkedin"])},via:e=>{const{normalize:t}=e;return t(["Or with"])},new:e=>{const{normalize:t}=e;return t(["New? Register now"])},aside_title:e=>{const{normalize:t}=e;return t(["Give a boost to your professional or entrepreneurial projects"])},aside_text:e=>{const{normalize:t}=e;return t(["Whether it's finding your next challenge, taking part in networking events or growing your business, your account gives you access to all Frenchfounders services."])},error:{invalid_crendentials:{title:e=>{const{normalize:t}=e;return t(["Invalid crendentials"])},text:e=>{const{normalize:t}=e;return t(["Impossible to log in with theses credentials"])}}},success:{register:{title:e=>{const{normalize:t}=e;return t(["Account created"])},text:e=>{const{normalize:t}=e;return t(["Welcome to the Frenchfounders app."])}}}}}})}typeof T=="function"&&T(q);const He=ye(q,[["__scopeId","data-v-529a07ad"]]);export{He as default}; //# sourceMappingURL=LoginPage-IcB5F3dE.js.map