1import{c as e,r as a,j as t}from"./vendor-react-DbsVTsKS.js";import{_ as r,d as s,ab as l,ac as o}from"./index-Dirtnqiz.js";import{bH as i,q as d}from"./app-constants-D3ojol5R.js";import{u as n}from"./useGoogleAuth-BOl1r5uW.js";/* empty css */import{u as c}from"./vendor-i18n-DiTKF2NC.js";import"./vendor-ui-B_XW8Pya.js";import"./vendor-charts-CG7l663-.js";import"./vendor-otel-B3hnpEUX.js";import"./vendor-virtuoso-CT6D0QVj.js";import"./vendor-markdown-CiT-VfZw.js";const g=()=>{const g=e(),{t:m}=c(),{register:u,loginWithGoogle:h}=r(),{isDarkMode:p}=s(),[x,b]=a.useState(""),{openGoogleLogin:y,loading:v}=n({onSuccess:async e=>{const a=await h(e);a.success?g("/",{replace:!0}):b(a.error||m("auth.googleSignUpFailed"))},onError:e=>b(e||m("auth.googleSignUpFailed"))}),[f,N]=a.useState({email:"",firstName:"",lastName:"",password:"",confirmPassword:""}),[j,w]=a.useState(""),[S,P]=a.useState(null),[$,C]=a.useState(!1),[F,q]=a.useState(!1),[I,k]=a.useState(0),[A,E]=a.useState(null),[O,L]=a.useState({}),[B,M]=a.useState(!1),[R,H]=a.useState(!1),[G,U]=a.useState(!1),[T,z]=a.useState(!1),D=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;a.useEffect(()=>()=>{A&&clearInterval(A)},[A]);const V=e=>{const{name:a,value:t}=e.target;N(e=>({...e,[a]:t})),O[a]&&L(e=>({...e,[a]:""}))},_=async()=>{if(f.email?D.test(f.email)||(L(e=>({...e,email:m("auth.emailInvalid")})),0):(L(e=>({...e,email:m("auth.emailRequired")})),0)){H(!0),L(e=>({...e,otp:"",otpSuccess:"",email:""}));try{let a;try{a=await l.checkEmail(f.email)}catch(e){return L(e=>({...e,email:m("auth.emailCheckUnavailable")})),void H(!1)}if(a.exists)return L(e=>({...e,email:m("auth.emailAlreadyExists")})),void H(!1);const t=await o.generateOTP(f.email);t.success&&t.responseBody&&P(t.responseBody),C(!0),k(300),L(e=>({...e,otpSuccess:m("auth.otpSentSuccess",{email:f.email})})),A&&clearInterval(A);const r=setInterval(()=>{k(e=>e<=1?(clearInterval(r),E(null),0):e-1)},1e3);E(r),L(e=>({...e,otp:""}))}catch(a){L(e=>{var t,r;return{...e,otp:(null==(r=null==(t=a.response)?void 0:t.data)?void 0:r.httpMessage)||a.message||m("auth.otpSendFailed")}})}finally{H(!1)}}},W=e=>`${Math.floor(e/60)}:${(e%60).toString().padStart(2,"0")}`;return t.jsx("div",{className:"signup-form-container "+(p?"bg-gray-900":"bg-gray-50"),children:t.jsxs("div",{className:`signup-form-card ${p?"bg-gray-800 border-gray-700":"bg-white border-gray-200"} border rounded-lg shadow-lg`,children:[t.jsx("h1",{className:"signup-form-title "+(p?"text-gray-100":"text-gray-800"),children:m("auth.createAccount")}),t.jsx("p",{className:"signup-form-subtitle "+(p?"text-gray-300":"text-gray-600"),children:m("auth.signUpTagline")}),t.jsxs("form",{onSubmit:async e=>{if(e.preventDefault(),(()=>{const e={};return f.email?D.test(f.email)||(e.email=m("auth.emailInvalid")):e.email=m("auth.emailRequired"),F||(e.otp=m("auth.emailVerifyRequired")),f.firstName.trim()||(e.firstName=m("auth.firstNameRequired")),f.lastName.trim()||(e.lastName=m("auth.lastNameRequired")),f.password?f.password.length<8&&(e.password=m("auth.passwordTooShort")):e.password=m("auth.passwordRequired"),f.confirmPassword?f.password!==f.confirmPassword&&(e.confirmPassword=m("auth.passwordsMismatch")):e.confirmPassword=m("auth.confirmPasswordRequired"),L(e),0===Object.keys(e).length})()){M(!0),L({});try{const e=d(),a=await u({email:f.email,firstName:f.firstName,lastName:f.lastName,password:f.password,username:f.email,emailVerified:!0,guestUserId:e});a.success?g("/"):L({submit:a.error})}catch(a){L({submit:m("auth.registrationFailed")})}finally{M(!1)}}},className:"signup-form",children:[t.jsxs("div",{className:"form-group",children:[t.jsx("label",{htmlFor:"email",className:p?"text-gray-200":"text-gray-700",children:m("auth.emailAddressLabel")}),t.jsxs("div",{className:"email-verify-container",children:[t.jsx("input",{type:"email",id:"email",name:"email",value:f.email,onChange:V,className:`form-input ${O.email?"error":""} ${F?"verified":""} ${p?"bg-gray-700 border-gray-600 text-gray-100 placeholder-gray-400":"bg-white border-gray-300 text-gray-900"}`,placeholder:m("auth.emailPlaceholderSignup"),disabled:F,required:!0}),!F&&t.jsx("button",{type:"button",onClick:_,disabled:R||!f.email||I>0,className:"verify-btn "+(p?"bg-blue-600 hover:bg-blue-700 text-white disabled:bg-gray-700 disabled:text-gray-400":"bg-blue-600 hover:bg-blue-700 text-white"),children:R?m("auth.sendingOtp"):I>0?W(I):m("auth.verifyEmail")}),F&&t.jsx("span",{className:"verified-badge "+(p?"bg-green-900/20 text-green-400 border-green-600":"bg-green-50 text-green-600"),children:m("auth.verifiedBadge")})]}),O.email&&t.jsx("span",{className:"error-message "+(p?"text-red-400":"text-red-600"),children:O.email})]}),$&&!F&&t.jsxs("div",{className:"form-group",children:[O.otpSuccess&&t.jsx("div",{className:"success-message rounded "+(p?"bg-green-900/20 text-green-400 border border-green-600":"bg-green-50 text-green-700"),style:{marginBottom:"1rem",padding:"0.75rem"},children:O.otpSuccess}),t.jsx("label",{htmlFor:"otp",className:p?"text-gray-200":"text-gray-700",children:m("auth.enterOtpLabel")}),t.jsxs("div",{className:"otp-verify-container",children:[t.jsx("input",{type:"text",id:"otp",value:j,onChange:e=>w(e.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"").slice(0,6)),className:`form-input ${O.otp?"error":""} ${p?"bg-gray-700 border-gray-600 text-gray-100 placeholder-gray-400":"bg-white border-gray-300 text-gray-900"}`,placeholder:m("auth.enterOtpPlaceholder"),maxLength:6,required:!0}),t.jsx("button",{type:"button",onClick:async()=>{var e;if(j&&6===j.length)if(S&&j!==S)L(e=>({...e,otp:m("auth.otpInvalid")}));else{H(!0),L(e=>({...e,otp:""}));try{const a=await o.validateOTP(f.email,j);a.success&&"Valid"===(null==(e=a.responseBody)?void 0:e.Status)?(q(!0),L(e=>({...e,otp:""})),A&&(clearInterval(A),E(null))):L(e=>({...e,otp:m("auth.otpInvalidRetry")}))}catch(a){L(e=>{var t,r;return{...e,otp:(null==(r=null==(t=a.response)?void 0:t.data)?void 0:r.httpMessage)||a.message||m("auth.otpInvalidRetry")}})}finally{H(!1)}}else L(e=>({...e,otp:m("auth.otpEnterSixChar")}))},disabled:R||6!==j.length,className:"verify-otp-btn "+(p?"bg-blue-600 hover:bg-blue-700 text-white disabled:bg-gray-700 disabled:text-gray-400":"bg-blue-600 hover:bg-blue-700 text-white"),children:m(R?"auth.verifyingOtp":"auth.verifyOtp")})]}),O.otp&&t.jsx("span",{className:"error-message "+(p?"text-red-400":"text-red-600"),children:O.otp}),t.jsxs("div",{className:"otp-info-container",children:[t.jsxs("p",{className:"otp-info "+(p?"text-gray-300":"text-gray-600"),children:[m("auth.otpSentTo")," ",f.email,I>0&&t.jsxs("span",{className:"otp-timer "+(p?"text-gray-400":"text-gray-500"),children:[" ⢠",m("auth.otpExpiresIn")," ",W(I)]})]}),0===I&&t.jsxs("div",{className:"resend-otp-section",children:[t.jsxs("p",{className:"otp-expired-hint "+(p?"text-yellow-400":"text-yellow-700"),children:["â ï¸ ",m("auth.otpExpiredHint")]}),t.jsx("button",{type:"button",onClick:async()=>{w(""),await _()},disabled:R,className:"resend-otp-btn "+(p?"text-blue-400 hover:text-blue-300":"text-blue-600 hover:text-blue-700"),
1children:m("auth.resendOtp")})]})]})]}),F&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"form-group",children:[t.jsx("label",{htmlFor:"firstName",className:p?"text-gray-200":"text-gray-700",children:m("auth.firstNameLabel")}),t.jsx("input",{type:"text",id:"firstName",name:"firstName",value:f.firstName,onChange:V,className:`form-input ${O.firstName?"error":""} ${p?"bg-gray-700 border-gray-600 text-gray-100 placeholder-gray-400":"bg-white border-gray-300 text-gray-900"}`,placeholder:m("auth.firstNamePlaceholder"),required:!0}),O.firstName&&t.jsx("span",{className:"error-message "+(p?"text-red-400":"text-red-600"),children:O.firstName})]}),t.jsxs("div",{className:"form-group",children:[t.jsx("label",{htmlFor:"lastName",className:p?"text-gray-200":"text-gray-700",children:m("auth.lastNameLabel")}),t.jsx("input",{type:"text",id:"lastName",name:"lastName",value:f.lastName,onChange:V,className:`form-input ${O.lastName?"error":""} ${p?"bg-gray-700 border-gray-600 text-gray-100 placeholder-gray-400":"bg-white border-gray-300 text-gray-900"}`,placeholder:m("auth.lastNamePlaceholder"),required:!0}),O.lastName&&t.jsx("span",{className:"error-message "+(p?"text-red-400":"text-red-600"),children:O.lastName})]}),t.jsxs("div",{className:"form-group",children:[t.jsx("label",{htmlFor:"password",className:p?"text-gray-200":"text-gray-700",children:m("auth.passwordLabel")}),t.jsxs("div",{className:"password-input-container",children:[t.jsx("input",{type:G?"text":"password",id:"password",name:"password",value:f.password,onChange:V,className:`form-input ${O.password?"error":""} ${p?"bg-gray-700 border-gray-600 text-gray-100 placeholder-gray-400":"bg-white border-gray-300 text-gray-900"}`,placeholder:m("auth.passwordPlaceholderSignup"),required:!0}),t.jsx("button",{type:"button",className:"password-toggle "+(p?"text-gray-300 hover:text-gray-100":"text-gray-600 hover:text-gray-800"),onClick:()=>U(!G),children:G?"ðï¸":"ðï¸âð¨ï¸"})]}),O.password&&t.jsx("span",{className:"error-message "+(p?"text-red-400":"text-red-600"),children:O.password}),t.jsx("p",{className:"password-hint "+(p?"text-gray-400":"text-gray-500"),children:m("auth.passwordHint")})]}),t.jsxs("div",{className:"form-group",children:[t.jsx("label",{htmlFor:"confirmPassword",className:p?"text-gray-200":"text-gray-700",children:m("auth.confirmPasswordLabel")}),t.jsxs("div",{className:"password-input-container",children:[t.jsx("input",{type:T?"text":"password",id:"confirmPassword",name:"confirmPassword",value:f.confirmPassword,onChange:V,className:`form-input ${O.confirmPassword?"error":""} ${p?"bg-gray-700 border-gray-600 text-gray-100 placeholder-gray-400":"bg-white border-gray-300 text-gray-900"}`,placeholder:m("auth.confirmPasswordPlaceholder"),required:!0}),t.jsx("button",{type:"button",className:"password-toggle "+(p?"text-gray-300 hover:text-gray-100":"text-gray-600 hover:text-gray-800"),onClick:()=>z(!T),children:T?"ðï¸":"ðï¸âð¨ï¸"})]}),O.confirmPassword&&t.jsx("span",{className:"error-message "+(p?"text-red-400":"text-red-600"),children:O.confirmPassword})]})]}),O.submit&&t.jsx("div",{className:`submit-error ${p?"bg-red-900/20 text-red-400 border border-red-600":"bg-red-50 text-red-700"} rounded p-3`,children:O.submit}),t.jsx("button",{type:"submit",className:"submit-btn bg-blue-600 hover:bg-blue-700 text-white "+(B||!F?"opacity-50 cursor-not-allowed":""),disabled:B||!F,children:m(B?"auth.creatingAccount":"auth.createAccount")}),i.GOOGLE_AUTH_ENABLED&&t.jsxs(t.Fragment,{children:[x&&t.jsx("div",{className:`submit-error ${p?"bg-red-900/20 text-red-400 border border-red-600":"bg-red-50 text-red-700"} rounded p-3`,children:x}),t.jsx("div",{className:"google-auth-divider",children:t.jsx("span",{className:p?"text-gray-400":"text-gray-500",children:m("auth.orDivider")})}),t.jsxs("button",{type:"button",onClick:y,disabled:v||B,className:`google-auth-btn ${p?"bg-gray-700 border-gray-600 text-gray-100 hover:bg-gray-600":"bg-white border-gray-300 text-gray-700 hover:bg-gray-50"} ${v||B?"opacity-50 cursor-not-allowed":""}`,children:[t.jsxs("svg",{className:"google-auth-icon",viewBox:"0 0 24 24","aria-hidden":"true",children:[t.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z",fill:"#4285F4"}),t.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),t.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l3.66-2.84z",fill:"#FBBC05"}),t.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),m(v?"auth.signingInGoogle":"auth.continueWithGoogle")]})]}),t.jsxs("p",{className:"login-link "+(p?"text-gray-300":"text-gray-600"),children:[m("auth.alreadyHaveAccount")," ",t.jsx("a",{href:"/login",onClick:e=>{e.preventDefault(),g("/login")},className:p?"text-blue-400 hover:text-blue-300":"text-blue-600 hover:text-blue-700",children:m("auth.logIn")})]})]})]})})};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.