1import{h as _,V as q,W as J,ag as X,r as m,X as v,j as e,Y as $,M as k,H as G,_ as K,b as j,A as Q,L as A}from"./index-BxANg2aK.js";import{I as f}from"./input-BqbQr4nY.js";import{L as g}from"./label-suKr8x3S.js";import{C as Z,a as ee,b as se,d as ae,c as te}from"./card-CUg6U1K8.js";import{L}from"./loader-circle-DaA_FtT6.js";import{E as R}from"./eye-uEPgs6e6.js";import{o as N,s as c}from"./types-3c7sL9OC.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const F=_("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),re=N({email:c().email("Please enter a valid email"),password:c().min(6,"Password must be at least 6 characters"),fullName:c().min(2,"Please enter your name"),companyName:c().optional()}),ie=N({email:c().email("Please enter a valid email"),password:c().min(1,"Password is required")}),oe=N({email:c().email("Please enter a valid email")}),ne=N({password:c().min(6,"Password must be at least 6 characters"),confirmPassword:c().min(6,"Password must be at least 6 characters")}).refine(y=>y.password===y.confirmPassword,{message:"Passwords don't match",path:["confirmPassword"]});function we(){const{user:y,isLoading:b,signIn:I,signUp:T}=q(),{toast:n}=J(),U=X(),[a,p]=m.useState("signin"),[P,d]=m.useState(!1),[D,S]=m.useState(!1),[t,M]=m.useState({email:"",password:"",confirmPassword:"",fullName:"",companyName:""}),[o,h]=m.useState({}),[C,z]=m.useState(!1),[E,W]=m.useState(!1);if(m.useEffect(()=>{const{data:{subscription:s}}=v.auth.onAuthStateChange((r,i)=>{console.log("Auth event:",r),r==="PASSWORD_RECOVERY"&&(S(!0),p("update-password"))});return()=>s.unsubscribe()},[]),y&&!b&&!D)return e.jsx($,{to:"/embed",replace:!0});const w=(s,r)=>{M(i=>({...i,[s]:r})),h(i=>({...i,[s]:""}))},Y=async()=>{const s=t.email.trim().toLowerCase();if(!oe.safeParse({email:s}).success){h({email:"Please enter a valid email"});return}d(!0);const{error:i}=await v.auth.resetPasswordForEmail(s,{redirectTo:`${window.location.origin}/auth`});i?n({title:"Error",description:i.message,variant:"destructive"}):(n({title:"Check your email",description:"We've sent you a password reset link."}),p("signin")),d(!1)},O=async()=>{const s=ne.safeParse({password:t.password,confirmPassword:t.confirmPassword});if(!s.success){const i={};s.error.errors.forEach(l=>{l.path[0]&&(i[l.path[0]]=l.message)}),h(i);return}d(!0);const{error:r}=await v.auth.updateUser({password:t.password});r?n({title:"Error",description:r.message,variant:"destructive"}):(n({title:"Password updated!",description:"Your password has been successfully changed."}),S(!1),U("/embed")),d(!1)},B=async s=>{if(s.preventDefault(),a==="reset"){await Y();return}if(a==="update-password"){await O();return}d(!0),h({});try{if(a==="signup"){const r=re.safeParse(t);if(!r.success){const x={};r.error.errors.forEach(u=>{u.path[0]&&(x[u.path[0]]=u.message)}),h(x),d(!1);return}const i=t.email.trim().toLowerCase(),{error:l}=await T({email:i,password:t.password,fullName:t.fullName,companyName:t.companyName});l?l.message.includes("already registered")?(n({title:"Account exists",description:"This email is already registered. Please sign in instead.",variant:"destructive"}),p("signin")):n({title:"Sign up failed",description:l.message,variant:"destructive"}):n({title:"Account created!",description:"You can now create embed widgets."})}else{const r=t.email.trim().toLowerCase(),i=ie.safeParse({email:r,password:t.password});if(!i.success){const x={};i.error.errors.forEach(u=>{u.path[0]&&(x[u.path[0]]=u.message)}),h(x),d(!1);return}const{error:l}=await I(r,t.password);l&&n({title:"Sign in failed",description:"Invalid email or password. Check caps/spacing, verify your email if new, or use Forgot password.",variant:"destructive"})}}catch{n({title:"Error",description:"Something went wrong. Please try again.",variant:"destructive"})}d(!1)};if(b)return e.jsx(k,{children:e.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:e.jsx(L,{className:"h-8 w-8 animate-spin text-primary"})})});const H=()=>{switch(a){case"signup":return"Create Your Account";case"reset":return"Reset Password";case"update-password":return"Set New Password";default:return"Welcome Back"}},V=()=>
6{switch(a){case"signup":return"Sign up to create embeddable calculator widgets for your website";case"reset":return"Enter your email and we'll send you a reset link";case"update-password":return"Enter your new password below";default:return"Sign in to access your widget builder"}};return e.jsxs(k,{children:[e.jsx(G,{children:e.jsx("meta",{name:"robots",content:"noindex, nofollow"})}),e.jsx("div",{className:"container py-12 md:py-20",children:e.jsxs("div",{className:"max-w-md mx-auto",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"inline-flex items-center justify-center p-3 bg-primary/10 rounded-2xl mb-4",children:e.jsx(K,{className:"h-8 w-8 text-primary"})}),e.jsx("h1",{className:"text-2xl md:text-3xl font-bold text-foreground",children:H()}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:V()})]}),e.jsxs(Z,{children:[e.jsxs(ee,{className:"pb-4",children:[e.jsx(se,{className:"text-lg",children:a==="signup"?"Sign Up":a==="reset"?"Reset Password":a==="update-password"?"Set New Password":"Sign In"}),e.jsx(ae,{children:a==="signup"?"Create a free account to get started":a==="reset"?"We'll email you a link to reset your password":a==="update-password"?"Choose a strong password for your account":"Enter your credentials to continue"})]}),e.jsxs(te,{children:[e.jsxs("form",{onSubmit:B,className:"space-y-4",children:[a==="signup"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"fullName",children:"Full Name *"}),e.jsx(f,{id:"fullName",type:"text",value:t.fullName,onChange:s=>w("fullName",s.target.value),placeholder:"John Smith",className:o.fullName?"border-destructive":""}),o.fullName&&e.jsx("p",{className:"text-xs text-destructive",children:o.fullName})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"companyName",children:"Company Name (optional)"}),e.jsx(f,{id:"companyName",type:"text",value:t.companyName,onChange:s=>w("companyName",s.target.value),placeholder:"Acme Inc."})]})]}),a!=="update-password"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"email",children:"Email *"}),e.jsx(f,{id:"email",type:"email",value:t.email,onChange:s=>w("email",s.target.value),placeholder:"[email protected]",className:o.email?"border-destructive":""}),o.email&&e.jsx("p",{className:"text-xs text-destructive",children:o.email})]}),a!=="reset"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"password",children:a==="update-password"?"New Password *":"Password *"}),e.jsxs("div",{className:"relative",children:[e.jsx(f,{id:"password",type:C?"text":"password",value:t.password,onChange:s=>w("password",s.target.value),placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",className:o.password?"border-destructive pr-12":"pr-12"}),e.jsx(j,{type:"button",variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 -translate-y-1/2 h-7 px-2",onClick:()=>z(s=>!s),children:C?e.jsx(F,{className:"h-4 w-4"}):e.jsx(R,{className:"h-4 w-4"})})]}),o.password&&e.jsx("p",{className:"text-xs text-destructive",children:o.password})]}),a==="update-password"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"confirmPassword",children:"Confirm Password *"}),e.jsxs("div",{className:"relative",children:[e.jsx(f,{id:"confirmPassword",type:E?"text":"password",value:t.confirmPassword,onChange:s=>w("confirmPassword",s.target.value),placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",className:o.confirmPassword?"border-destructive pr-12":"pr-12"}),e.jsx(j,{type:"button",variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 -translate-y-1/2 h-7 px-2",onClick:()=>W(s=>!s),children:E?e.jsx(F,{className:"h-4 w-4"}):e.jsx(R,{className:"h-4 w-4"})})]}),o.confirmPassword&&e.jsx("p",{className:"text-xs text-destructive",children:o.confirmPassword})]}),a==="signin"&&e.jsx("div",{className:"text-right",children:e.jsx("button",{type:"button",onClick:()=>p("reset"),className:"text-sm text-primary hover:underline",children:"Forgot password?"})}),e.jsxs(j,{type:"submit",className:"w-full",disabled:P,children:[P&&e.jsx(L,{className:"h-4 w-4 mr-2 animate-spin"}),a==="signup"?"Create Account":a==="reset"?"Send Reset Link":a==="update-password"?"Update Password":"Sign In",e.jsx(Q,{className:"h-4 w-4 ml-2"})]})]}),a!=="update-password"&&e.jsx("div",{className:"mt-6 pt-6 border-t border-border text-center",children:a==="reset"?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Remember your password?"," ",e.jsx("button",{type:"button",onClick:()=>p("signin"),className:"text-primary hover:underline font-medium",children:"Sign in"})]}):e.jsxs("p",{className:"text-sm text-muted-foreground",children:[a==="signup"?"Already have an account?":"Don't have an account?"," ",e.jsx("button",{type:"button",onClick:()=>p(a==="signup"?"signin":"signup"),className:"text-primary hover:underline font-medium",children:a==="signup"?"
6Sign in":"Sign up"})]})})]})]}),e.jsxs("p",{className:"mt-6 text-center text-xs text-muted-foreground",children:["By signing up, you agree to our"," ",e.jsx(A,{to:"/terms",className:"text-primary hover:underline",children:"Terms of Use"})," ","and"," ",e.jsx(A,{to:"/privacy",className:"text-primary hover:underline",children:"Privacy Policy"})]})]})})]})}export{we 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.