1import{r as c,j as e,b as X,e as Z,L as D,d as $}from"./chunk-LFPYN7LY-DEKZ4FNX.js";import{B as S}from"./button-ZjeYo-cb.js";import{C as Q,a as ee,b as te,d as ae,c as se}from"./card-1a5h9Imb.js";import{I as b}from"./input-BVcd8XqH.js";import{L as j}from"./label-Cg41PopF.js";import{s as _}from"./supabaseClient-DWlHRmQg.js";import{a as U}from"./api-BRqzXKpj.js";import{a as m,d as re}from"./marketing-events-Dp3l2wnn.js";import"./index-DzxQ7-vn.js";import"./index-DFtUjVon.js";import"./utils-XvSw8WNf.js";import"./index-COJuM6gq.js";import"./preload-helper-CLcXU_4U.js";import"./exports-CFihLitN.js";import"./telemetry-privacy-mim_uihv.js";const F="0x4AAAAAACKMaZ62BlYyGNpT";function ne({onVerify:r,onError:s,onExpire:a,onLoadFailure:g,theme:p="auto",size:f="flexible",className:C}){const y=c.useRef(null),x=c.useRef(null),n=c.useCallback(()=>{if(!(!y.current||!window.turnstile||!F)){if(x.current)try{window.turnstile.remove(x.current)}catch{}x.current=window.turnstile.render(y.current,{sitekey:F,callback:r,"error-callback":s,"expired-callback":a,theme:p,size:f})}},[r,s,a,p,f]);return c.useEffect(()=>{if(window.turnstile){n();return}const w=setInterval(()=>{window.turnstile&&(clearInterval(w),n())},100),u=setTimeout(()=>{clearInterval(w),g?.()},3e3);return()=>{if(clearInterval(w),clearTimeout(u),x.current)try{window.turnstile.remove(x.current)}catch{}}},[n,g]),e.jsx("div",{ref:y,className:C,"data-turnstile-sitekey":F})}const ie="seotakeoff_tenant_id",W="seotakeoff_lead_context";function E(){const r=window.location.origin;return r==="https://seotakeoff.com"?"https://www.seotakeoff.com/auth/callback":`${r}/auth/callback`}function k(r){return r.toLowerCase().trim().split("@")[1]||void 0}function h(){try{const r=localStorage.getItem(W);return r?JSON.parse(r):{}}catch{return{}}}function T(r,s){const a=h(),g={...a,email:s||r.get("email")?.toLowerCase().trim()||a.email,website_url:r.get("website_url")||a.website_url,source:r.get("source")||a.source,capture_id:r.get("capture_id")||a.capture_id,lead_magnet_id:r.get("lead_magnet_id")||a.lead_magnet_id,saved_at:new Date().toISOString()};try{localStorage.setItem(W,JSON.stringify(g))}catch{}return g}function be(){const r=X(),[s]=Z(),[a,g]=c.useState(""),[p,f]=c.useState(""),[C,y]=c.useState(""),x=s.get("mode")==="signup"?"signup":"login",[n,w]=c.useState(x==="signup"?"signup":"magic-link"),[u,i]=c.useState("idle"),[v,o]=c.useState(null),A=c.useRef(null),[V,H]=c.useState(0),[B,M]=c.useState(!1),[R,I]=c.useState(!1);c.useEffect(()=>{const t=s.get("email")?.toLowerCase().trim();t&&!a&&g(t),(s.get("website_url")||s.get("capture_id")||s.get("lead_magnet_id")||s.get("source")||t)&&T(s,t||a)},[a,s]);const P=c.useCallback(async t=>{const{tenant:l,has_completed_onboarding:d}=await U.getTenantByUserId(t);m("auth_redirect_decided",{destination:d&&l?"/strategy":"/onboarding",has_tenant:!!l,has_completed_onboarding:!!d,offer:s.get("offer")||void 0},{tenantId:l?.tenant_id,userId:t}),d&&l?(localStorage.setItem(ie,l.tenant_id),r("/strategy",{replace:!0})):r("/onboarding",{replace:!0})},[r,s]);c.useEffect(()=>{m("auth_page_loaded",{auth_mode:n,offer:s.get("offer")||void 0})},[n,s]),c.useEffect(()=>{(async()=>{const{data:{session:l}}=await _.auth.getSession();if(l)try{await P(l.user.id)}catch{r("/onboarding",{replace:!0})}})()},[r,P]);const q=t=>{A.current=t,I(!0),m("turnstile_loaded",{auth_mode:n})},N=()=>{A.current=null,I(!1),H(t=>t+1),m("turnstile_failed",{auth_mode:n})},K=async()=>{const t=A.current;if(!t)return B?!0:(o("Verification is loading â please wait a moment and try again."),N(),!1);try{return(await U.verifyTurnstile(t)).success?!0:(o("Verification failed. Please wait a moment and try again."),N(),!1)}catch{return console.warn("Backend Turnstile verification failed, proceeding anyway"),!0}},z=async t=>{t.preventDefault(),i("loading"),o(null),m("auth_method_selected",{auth_mode:n,signup_method:"magic_link",email_domain:k(a),offer:s.get("offer")||void 0,capture_id:s.get("capture_id")||h().capture_id,lead_magnet_id:s.get("lead_magnet_id")||h().lead_magnet_id,website_domain:(()=>{const d=s.get("website_url")||h().website_url;try{return d?new URL(d).hostname.replace(/^www\./i,""):void 0}catch{return}})()}),T(s,a);const{error:l}=await _.auth.signInWithOtp({email:a,options:{emailRedirectTo:E(),shouldCreateUser:!1}});if(l){const d=l.status===422&&/signups not allowed/i.test(l.message??"");o(d?"No account found for this email. New here? Use Sign up below.":l.message),i("error");return}i("success")},Y=async t=>{t.preventDefault(),i("loading"),o(null),m("auth_method_selected",{auth_mode:n,signup_method:"password",email_domain:k(a),offer:s.get("offer")||void 0});const{error:l}=await _.auth.signInWithPassword({email:a,password:p});if(l){o(l.message),i("error");return}try{const{data:{session:d}}=await _.auth.getSession();d&&await P(d.user.id)}catch{o("Signed in, but we couldn't load your account. Please try again."),i("error")}},G=async t=>{if(t.preventDefault(),i("loading"),o(null),m("auth_method_selected",{auth_mode:n,signup_method:"email_password",email_domain:k(a),offer:s.get("offer")||void 0,capture_id:s.get("capture_id")||h().capture_id,lead_magnet_id:s.get("lead_magnet_id")||h().lead_magnet_id}),T(s,a),p!==C){o("Passwords do not match"),i("error");return}if(p.length<8){o("Password must be at least 8 characters"),i("error");return}if(!await K()){i("error");return}m("signup_started",{signup_method:"email_password",email_domain:k(a)});const{data:d,error:L}=await _.auth.signUp({email:a,password:p,options:{emailRedirectTo:E()}});if(L){o(L.message),i("error");return}m("signup_completed",{signup_method:"email_password",email_domain:k(a)},{userId:d?.user?.id}),await re({email:a,method:"email_password"}),i("success")},O=n==="signup",J=n==="magic-link"||n==="password";return e.jsx(e.Fragment,{children:e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-muted/20 px-4",children:e.jsxs(Q,{className:"w-full max-w-md",children:[e.jsxs(ee,{children:[e.jsx(te,{children:O?"Create your account":"Welcome back"}
1),e.jsx(ae,{children:n==="signup"?"Sign up to start generating SEO content on autopilot.":n==="magic-link"?"Enter your email and we'll send you a secure login link. No password needed.":"Sign in with your email and password."})]}),e.jsxs(se,{children:[e.jsxs(S,{variant:"outline",className:"w-full mb-4",type:"button",disabled:u==="loading",onClick:async()=>{i("loading"),o(null),m("auth_method_selected",{auth_mode:n,signup_method:"google",offer:s.get("offer")||void 0,capture_id:s.get("capture_id")||h().capture_id,lead_magnet_id:s.get("lead_magnet_id")||h().lead_magnet_id}),T(s,a),m("signup_started",{signup_method:"google",auth_mode:n});const{error:t}=await _.auth.signInWithOAuth({provider:"google",options:{redirectTo:E()}});t&&(m("auth_callback_failed",{reason:"oauth_start_error",provider:"google",detail:t.message}),o(t.message),i("error"))},children:[e.jsxs("svg",{className:"mr-2 h-4 w-4",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z",fill:"#4285F4"}),e.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"}),e.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.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),e.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"})]}),"Continue with Google"]}),e.jsxs("div",{className:"relative mb-4",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"or"})})]}),n==="signup"?e.jsxs("form",{className:"space-y-4",onSubmit:G,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"signup-email",children:"Email address"}),e.jsx(b,{autoComplete:"email",id:"signup-email",onChange:t=>g(t.target.value),placeholder:"[email protected]",required:!0,type:"email",value:a})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"signup-password",children:"Password"}),e.jsx(b,{autoComplete:"new-password",id:"signup-password",onChange:t=>f(t.target.value),placeholder:"At least 8 characters",required:!0,type:"password",value:p})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"confirm-password",children:"Confirm password"}),e.jsx(b,{autoComplete:"new-password",id:"confirm-password",onChange:t=>y(t.target.value),placeholder:"Confirm your password",required:!0,type:"password",value:C})]}),e.jsx(ne,{onVerify:t=>{q(t),M(!1)},onExpire:N,onError:N,onLoadFailure:()=>{M(!0),I(!0)},size:"flexible"},V),!R&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsxs("svg",{className:"h-4 w-4 animate-spin",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"})]}),"Loading security verification..."]}),B&&e.jsx("p",{className:"text-sm text-amber-600",children:"Verification couldn't load â this is usually caused by an ad blocker. Try disabling it, or sign up with Google instead."}),e.jsx(S,{className:"w-full",disabled:u==="loading"||!R,type:"submit",children:u==="loading"?"Creating account...":"Create Account"}),u==="success"?e.jsxs("p",{className:"text-sm text-emerald-600",children:["Check your inbox! We sent a confirmation email to ",e.jsx("strong",{children:a})]}):null,v?e.jsx("p",{className:"text-sm text-destructive",children:v}):null]}):n==="magic-link"?e.jsxs("form",{className:"space-y-4",onSubmit:z,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"email",children:"Email address"}),e.jsx(b,{autoComplete:"email",id:"email",onChange:t=>g(t.target.value),placeholder:"[email protected]",required:!0,type:"email",value:a})]}),e.jsx(S,{className:"w-full",disabled:u==="loading",type:"submit",children:u==="loading"?"Sending login link...":"Continue with Email"}),u==="success"?e.jsxs("p",{className:"text-sm text-emerald-600",children:["Check your inbox! We sent a login link to ",e.jsx("strong",{children:a})]}):null,v?e.jsx("p",{className:"text-sm text-destructive",children:v}):null]}):e.jsxs("form",{className:"space-y-4",onSubmit:Y,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"email-password",children:"Email address"}),e.jsx(b,{autoComplete:"email",id:"email-password",onChange:t=>g(t.target.value),placeholder:"[email protected]",required:!0,type:"email",value:a})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"password",children:"Password"}),e.jsx(b,{autoComplete:"current-password",id:"password",onChange:t=>f(t.target.value),placeholder:"Enter your password",required:!0,type:"password",value:p})]}),e.jsx(S,{className:"w-full",disabled:u==="loading",type:"submit",children:u==="loading"?"Signing in...":"Sign In"}),v?e.jsx("p",{className:"text-sm text-destructive",children:v}):null,e.jsx("button",{type:"button",onClick:async()=>
1{if(!a){o("Enter your email address first, then click Forgot password.");return}i("loading"),o(null);const{error:t}=await _.auth.resetPasswordForEmail(a,{redirectTo:E()});t?(o(t.message),i("error")):(o(null),i("success"))},className:"text-sm text-muted-foreground hover:text-primary hover:underline",children:"Forgot password?"}),u==="success"?e.jsxs("p",{className:"text-sm text-emerald-600",children:["Check your inbox! We sent a password reset link to ",e.jsx("strong",{children:a})]}):null]}),J&&e.jsx("div",{className:"mt-4 text-center",children:e.jsx("button",{type:"button",onClick:()=>{w(n==="magic-link"?"password":"magic-link"),o(null),i("idle")},className:"text-sm text-muted-foreground hover:text-primary hover:underline",children:n==="magic-link"?"Sign in with password instead":"Sign in with magic link instead"})}),e.jsx("div",{className:"mt-4 pt-4 border-t text-center",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:O?e.jsxs(e.Fragment,{children:["Already have an account?"," ",e.jsx("button",{type:"button",onClick:()=>{w("magic-link"),o(null),i("idle"),f(""),y("")},className:"text-primary hover:underline font-medium",children:"Sign in"})]}):e.jsxs(e.Fragment,{children:["Don't have an account?"," ",e.jsx("button",{type:"button",onClick:()=>{w("signup"),o(null),i("idle"),f("")},className:"text-primary hover:underline font-medium",children:"Sign up"})]})})}),e.jsxs("p",{className:"mt-6 text-center text-xs text-muted-foreground",children:["By continuing, you agree to our"," ",e.jsx(D,{to:"/terms",className:"text-primary hover:underline",children:"Terms of Service"})," ","and"," ",e.jsx(D,{to:"/privacy",className:"text-primary hover:underline",children:"Privacy Policy"}),"."]})]})]})})})}const je=()=>[{title:"Log In | SEOTakeoff"},{name:"description",content:"Log in to your SEOTakeoff dashboard to manage your SEO content, track rankings, and publish articles."},{name:"robots",content:"noindex, nofollow"}];function ke(){return{}}const Ce=$(function(){return e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})});export{Ce as HydrateFallback,ke as clientLoader,be as default,je as meta};
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.