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