1import{r as n,j as e}from"./react-core.DJiaDNPT.js";import{l as _,a8 as C,H as S,z as E}from"./vendors.D5VPZlu6.js";import{u as R,g as q,b as A,d as P,c as F,s as z,R as L}from"./index.CKQejW0v.js";import{u as T}from"./useUsers.ByvfHBVH.js";import{I as O}from"./IconInfoTriangle.g8T4r2Kv.js";import{O as U}from"./OAuthButtons.BICPTXKu.js";import{A as M}from"./AuthLayout.CYs27jbI.js";import{L as Z}from"./react-router.CDx91DFN.js";import"./react-query.BPQxxLgJ.js";const D=()=>{const{t:a}=_(),{createUser:u}=T(),{login:p}=R(),[i,h]=n.useState({name:"",email:"",password:""}),[s,l]=n.useState({email:"",password:""}),[m,w]=n.useState(!1),[x,j]=n.useState(""),[y,o]=n.useState(""),f=t=>{const{name:r,value:d}=t.target;h(c=>({...c,[r]:d}))},N=/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[^A-Za-z0-9]).{12,128}$/,v=async t=>{if(t.preventDefault(),o(""),!N.test(i.password)){o(a("password_requirements","Minimum 12 characters, uppercase, lowercase, number, and special character"));return}w(!0),await u(i).then(async()=>{const r=q();A({method:"email",signup_source:P(r),utm_source:r?.utm_source,utm_medium:r?.utm_medium,utm_campaign:r?.utm_campaign}),F(),await p({email:i.email,password:i.password})}).catch(r=>{const d=r,c=d?.response?.status,b=c===400?/"(\w+)"/.exec(d?.response?.data?.message??"")?.[1]:void 0;o(c===409?a("register_email_exists","A user with this email already exists."):b==="email"?a("register_email_invalid","Enter a valid email address."):b==="password"?a("password_requirements","Minimum 12 characters, uppercase, lowercase, number, and special character"):b==="name"?a("register_name_invalid","Enter your name."):a("register_error_generic","Registration failed. Please try again."))}).finally(()=>w(!1))},k=t=>{let r=a("weak");const d=new RegExp("^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[^A-Za-z0-9])(?=.{12,})"),c=new RegExp("^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.{10,})");d.test(t)?r=a("strong"):c.test(t)&&(r=a("medium")),j(r)},g="w-full rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800/50 px-4 py-3 text-sm text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-gray-500 outline-none transition-all focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20";return e.jsxs("form",{className:"space-y-4",onSubmit:v,children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"Name",className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5",children:a("name")}),e.jsx("input",{id:"Name",type:"text",name:"name",required:!0,"aria-required":"true",autoComplete:"name",placeholder:a("enter_name"),className:g,onChange:f})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"Email",className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5",children:a("email")}),e.jsx("input",{id:"Email",type:"email",name:"email",required:!0,"aria-required":"true",autoComplete:"email",placeholder:a("enter_email"),className:g,onChange:f})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"confirm_email",className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5",children:a("confirm_email")}),e.jsx("input",{id:"confirm_email",type:"email",name:"confirm_email",required:!0,"aria-required":"true","aria-invalid":!!s?.email,"aria-describedby":s?.email?"confirm-email-error":void 0,autoComplete:"email",placeholder:a("enter_email"),className:g,onChange:t=>{i.email===t.target.value?l(r=>({...r,email:""})):l(r=>({...r,email:a("email_not_match")}))}}),s?.email&&e.jsx("div",{id:"confirm-email-error",className:"text-red-500 text-sm mt-1",role:"alert",children:s.email})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"Password",className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5",children:a("password")}),e.jsx("input",{id:"Password",type:"password",name:"password",required:!0,"aria-required":"true",autoComplete:"new-password",placeholder:a("enter_password"),className:g,onChange:t=>{f(t),k(t.target.value)}}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 mt-1",children:a("password_requirements","Minimum 12 characters, uppercase, lowercase, number, and special character")}),x!==""&&e.jsxs("div",{className:"flex items-center mt-2 text-sm",children:[e.jsx(C,{content:a("security_password_content"),theme:"primary",children:e.jsx("div",{children:e.jsx(O,{className:"cursor-pointer text-gray-400 mr-1 w-4 h-4"})})}),e.jsxs("span",{className:"text-gray-500 mr-1",children:[a("strength_password"),":"]}),e.jsx("span",{className:`font-semibold capitalize ${x===a("weak")?"text-red-500":x===a("medium")?"text-yellow-500":"text-green-500"}`,children:x})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"confirm_password",className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5",children:a("confirm_password")}),e.jsx("input",{id:"confirm_password",type:"password",name:"confirm_password",required:!0,"aria-required":"true","aria-invalid":!!s?.password,"aria-describedby":s?.password?"confirm-password-error":void 0,autoComplete:"new-password",placeholder:a("enter_password"),className:g,onChange:t=>{i.password===t.target.value?l(r=>({...r,password:""})):l(r=>({...r,password:a("password_not_match")}))}}),s?.password&&e.jsx("div",{id:"confirm-password-error",className:"text-red-500 text-sm mt-1",role:"alert",children:s.password})]}),y&&e.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 p-3",children:e.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",role:"alert",children:y})}),e.jsx("button",{type:"submit",className:"w-full rounded-lg bg-brand-800 px-4 py-3 text-sm font-semibold text-white shadow-sm transition-all hover:bg-brand-900 focus:outline-none focus:ring-2 focus:ring-brand-500/50 focus:ring-offset-2 disabled:opacity-60 disabled:cursor-not-allowed",disabled:s.email!==""||s.password!==""||x===a("weak")||m,children:m?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),a("creating_account","Creating accountâ¦")]}):a("sign_up")})]})},K=()=>{const{t:a,i18n:u}=_(),p=S(),i=E(m=>m.themeConfig);n.useEffect(()=>{p(z(a("register_page_title","Register")))},[p,a]);const[h,s]=n.useState(u.language||i.locale);n.useEffect(()=>{s(u.language)},[u.language]);const l=m=>{s(m)};return e.jsxs(M,{currentLanguage:h,onLanguageChange:l,children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900 dark:text-white",children:a("auth_create_account","Create your account")}
1),e.jsx("p",{className:"mt-2 text-gray-500 dark:text-gray-400",children:a("enter_data_register")})]}),e.jsx("div",{className:"mb-6",children:e.jsx(U,{})}),e.jsxs("div",{className:"relative mb-6",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("div",{className:"w-full border-t border-gray-200 dark:border-gray-700"})}),e.jsx("div",{className:"relative flex justify-center text-sm",children:e.jsx("span",{className:"px-3 bg-gray-50 dark:bg-[#0e1726] text-gray-600 dark:text-gray-400",children:a("or_register_with_email","Or register with email")})})]}),e.jsx(D,{}),e.jsxs("p",{className:"mt-8 text-center text-sm text-gray-500 dark:text-gray-400",children:[a("already_account")," ",e.jsx(Z,{to:L.AUTH.LOGIN,className:"font-semibold text-brand-800 hover:text-brand-900 dark:text-brand-400 dark:hover:text-brand-300 transition-colors",children:a("sign_in")})]})]})};export{K 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.