(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[11],{3213:function(e,r,i){Promise.resolve().then(i.bind(i,9988))},9988:function(e,r,i){"use strict";i.r(r);var a=i(7821),l=i(9164),t=i(3153),s=i(6712),n=i(1736),o=i(615),c=i(8140),u=i(7558),m=i(5231),d=i(1853),x=i(4089),p=i(8504),f=i(8078),h=i(746),v=i(9912);let g=()=>{var e;let{projectName:r,emailPlaceholder:i,studentEmailRegex:g,staffEmailRegex:b,formerStudentEmailRegex:j}=(0,f.useContext)(o.c),y=(0,p.useRouter)(),[C,z]=(0,f.useState)(!1),N=(0,p.useSearchParams)(),_=(null===(e=N.get("external"))||void 0===e?void 0:e.toLocaleLowerCase())==="true",k=N.get("email"),w=v.z.string({required_error:"Veuillez renseigner votre adresse email"}).email({message:"Veuillez renseigner une adresse email valide"});_||(w=w.regex(new RegExp("(".concat([g,b,j].filter(e=>null!==e&&""!==e).join("|"),")")),{message:"Veuillez utiliser une adresse email li\xe9e \xe0 l'\xe9tablissement"}));let E=v.z.object({email:w}),S=(0,h.cI)({resolver:(0,x.F)(E),defaultValues:{email:null!=k?k:""}});async function V(e){try{z(!0);let r=await (0,l.ZiC)({body:{email:e.email,accept_external:_}});if(z(!1),r.response.status<300){y.push("/register/success");return}(0,d.Am)({title:"Erreur",description:r.error.detail,variant:"destructive"})}catch(e){z(!1),(0,d.Am)({title:"Erreur",description:"".concat(e),variant:"destructive"})}}return(0,a.jsxs)(t.G,{title:"Cr\xe9er un compte ".concat(r),description:"Vous n'avez besoin que de votre email pour commencer",children:[(0,a.jsxs)("div",{className:"flex flex-row mb-4 text-center",children:[(0,a.jsxs)(c.z,{variant:"outline",className:"mr-2 flex-1 ".concat(_?"":"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground"),onClick:()=>y.push("?external=false"),children:["J'ai un email",(0,a.jsx)("br",{})," en ",i.split("@")[1]]}),(0,a.jsxs)(c.z,{variant:"outline",className:"mr-2 flex-1 ".concat(_?"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground":""),onClick:()=>y.push("?external=true"),children:["J'utilise un",(0,a.jsx)("br",{})," email perso"]})]}),(0,a.jsx)(u.l0,{...S,children:(0,a.jsx)("form",{onSubmit:S.handleSubmit(V),children:(0,a.jsxs)("div",{className:"grid gap-4",children:[(0,a.jsx)(s.T,{form:S,name:"email",label:"Email",render:e=>(0,a.jsx)(m.I,{type:"email",autoFocus:!0,placeholder:_?"mail@example.com":i,...e})}),(0,a.jsx)(n.f,{className:"mt-2 w-full",type:"submit",label:"Commencer \xe0 cr\xe9er le compte",isLoading:C})]})})})]})};r.default=()=>(0,a.jsx)(f.Suspense,{fallback:(0,a.jsx)("div",{children:"Loading..."}),children:(0,a.jsx)(g,{})})}},function(e){e.O(0,[322,390,305,340,517,295,115,364,744],function(){return e(e.s=3213)}),_N_E=e.O()}]);