1import{c as le,r as c,m as oe,s as ce,j as e,L as F,b as w,n as Y}from"./index-DdU35jPJ.js";import{B as S}from"./button-BfxMpK8P.js";import{I as P}from"./input-cpzcpc5y.js";import{L as E}from"./label-Bnj3FxlL.js";import{P as de}from"./PortalGridBg-BVDn-q4y.js";import{L as N}from"./loader-circle-B5Ydjp3O.js";import{A as I}from"./arrow-left-CoQakR5q.js";import{M as H}from"./mail-DvcgW5d2.js";import{c as me}from"./createLucideIcon-DMxicyrC.js";import{L as X}from"./lock-keyhole-BI7D1evS.js";import{S as he}from"./shield-check-CvVcm_Fy.js";import{C as xe}from"./circle-check-DIcqODlT.js";import{E as ue}from"./eye-off-CxGSfo5A.js";import{E as pe}from"./eye-BQotKVtf.js";import"./index-gN4drEn4.js";import"./index-Dp3B9jqt.js";import"./clsx-B-dksMZM.js";import"./utils-DCmAa5as.js";import"./bundle-mjs-BTmSotT-.js";import"./index-9bdZCgcr.js";/** 2 * @license lucide-react v0.475.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 fe=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],J=me("KeyRound",fe),ge="https://qtrypzzcjebvfcihiynt.supabase.co/storage/v1/object/public/base44-prod/public/692b9868f16b6d5a3a0d7f0a/c10174898_THlogowhite.png",Q=new Set(["login","register","verify","forgot","reset"]),D="truckhaters:last-successful-login-email",we=()=>{var s;try{return((s=window.localStorage.getItem(D))==null?void 0:s.trim().toLowerCase())||""}catch{return""}},be=(s,x)=>{try{x?window.localStorage.setItem(D,s):window.localStorage.removeItem(D)}catch{}},C=(s,x)=>{var f,d;const n=((f=s==null?void 0:s.response)==null?void 0:f.status)??(s==null?void 0:s.status)??(s==null?void 0:s.statusCode),l=((d=s==null?void 0:s.response)==null?void 0:d.data)??(s==null?void 0:s.data),p=(l==null?void 0:l.message)||(l==null?void 0:l.detail)||(l==null?void 0:l.error)||(s==null?void 0:s.message);return n===401?"The email or password is incorrect.":n===403?"Verify your email before signing in.":n===409?"An account already exists for this email. Sign in or reset your password.":n===422?typeof p=="string"?p:"Please check the information and try again.":n===429?"Too many attempts. Please wait a few minutes and try again.":typeof p=="string"&&p.trim()?p:x},je=s=>{var n;const x=(s==null?void 0:s.access_token)??((n=s==null?void 0:s.data)==null?void 0:n.access_token);x&&w.auth.setToken(x,!0)},L=({id:s,name:x,label:n,value:l,onChange:p,autoComplete:f,visible:d,onToggle:T})=>e.jsxs("div",{children:[e.jsx(E,{htmlFor:s,className:"text-sm font-semibold text-white",children:n}),e.jsxs("div",{className:"relative mt-1.5",children:[e.jsx(X,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-500"}),e.jsx(P,{id:s,name:x,type:d?"text":"password",autoComplete:f,value:l,onChange:p,className:"h-12 rounded-lg border-[rgba(148,163,184,0.15)] bg-[#0b0e14] pl-10 pr-11 text-base text-white placeholder:text-slate-600 focus:border-[#3b82f6] focus:ring-[#3b82f6]/20",required:!0}),e.jsx("button",{type:"button",onClick:T,className:"absolute right-2 top-1/2 flex h-9 w-9 -translate-y-1/2 items-center justify-center rounded-lg text-slate-500 hover:bg-white/5 hover:text-slate-300","aria-label":d?"Hide password":"Show password",children:d?e.jsx(ue,{className:"h-4 w-4"}):e.jsx(pe,{className:"h-4 w-4"})})]})]});function De(){const{isAuthenticated:s,isLoadingAuth:x}=le(),n=c.useMemo(()=>new URLSearchParams(window.location.search),[]),l=c.useMemo(()=>oe(window.location),[]),p=l?"reset":Q.has(n.get("mode"))?n.get("mode"):"login",f=c.useMemo(()=>ce(n.get("returnTo"),p==="register"?"/Registration":"/"),[p,n]),[d,T]=c.useState(p),[m,M]=c.useState(()=>n.get("email")||we()),[O,Z]=c.useState(!0),[h,A]=c.useState(""),[R,B]=c.useState(""),[W,ee]=c.useState(""),[V,q]=c.useState(!1),[U,$]=c.useState(!1),[o,u]=c.useState(!1),[g,r]=c.useState(""),[j,b]=c.useState(n.get("reset")==="success"?"Password changed successfully. Return to the Truck Haters app and sign in with your new password.":"");c.useEffect(()=>{d!=="reset"&&!x&&s&&window.location.replace(f)}
6,[s,x,d,f]);const y=t=>{const a=Q.has(t)?t:"login";T(a),r(""),b("");const i=new URLSearchParams;i.set("returnTo",f),a!=="login"&&i.set("mode",a),m.trim()&&i.set("email",m.trim()),window.history.replaceState({},"",`/Login?${i.toString()}`)},K=async(t,a=m)=>{je(t),await w.auth.me(),await Y("sign_in",{once:!0,onceScope:"authenticated"});const i=a.trim().toLowerCase();i&&be(i,O),window.location.replace(f)},te=async t=>{if(t.preventDefault(),o)return;r(""),b("");const a=m.trim().toLowerCase();if(!a||!h){r("Enter your email and password.");return}u(!0);try{const i=await w.auth.loginViaEmailPassword(a,h);await K(i,a)}catch(i){r(C(i,"Sign in failed. Please try again."))}finally{u(!1)}},se=async t=>{if(t.preventDefault(),o)return;r(""),b("");const a=m.trim().toLowerCase();if(!a||!/^\S+@\S+\.\S+$/.test(a)){r("Enter a valid email address.");return}if(h.length<8){r("Create a password with at least 8 characters.");return}if(h!==R){r("The passwords do not match.");return}u(!0);try{await w.auth.register({email:a,password:h,referral_code:new URLSearchParams(f.split("?")[1]||"").get("ref")||void 0}),Y("registration_started",{once:!0,onceScope:"auth-register"}),T("verify"),b(`We sent a verification code to ${a}.`);const i=new URLSearchParams({returnTo:f,mode:"verify",email:a});window.history.replaceState({},"",`/Login?${i.toString()}`)}catch(i){r(C(i,"We could not create the account. Please try again."))}finally{u(!1)}},ae=async t=>{if(t.preventDefault(),o)return;r("");const a=m.trim().toLowerCase(),i=W.replace(/\D/g,"");if(!a||i.length<4){r("Enter the verification code from your email.");return}if(!h){r("Your password is missing. Return to account creation and try again.");return}u(!0);try{await w.auth.verifyOtp({email:a,otpCode:i});const _=await w.auth.loginViaEmailPassword(a,h);await K(_,a)}catch(_){r(C(_,"The verification code is invalid or expired."))}finally{u(!1)}},re=async()=>{if(!(o||!m.trim())){u(!0),r(""),b("");try{await w.auth.resendOtp(m.trim().toLowerCase()),b("A new verification code was sent.")}catch(t){r(C(t,"We could not resend the code. Please try again."))}finally{u(!1)}}},ie=async t=>{if(t.preventDefault(),!o){if(r(""),b(""),!l){r("This password-reset link is invalid or expired. Request a new link.");return}if(h.length<8){r("Create a new password with at least 8 characters.");return}if(h!==R){r("The passwords do not match.");return}u(!0);try{await w.auth.resetPassword({resetToken:l,newPassword:h}),w.auth.logout(`${window.location.origin}/Login?reset=success`)}catch(a){r(C(a,"This password-reset link is invalid or expired. Request a new link.")),u(!1)}}},ne=async t=>{if(t.preventDefault(),o)return;r(""),b("");const a=m.trim().toLowerCase();if(!a||!/^\S+@\S+\.\S+$/.test(a)){r("Enter the email address used for your account.");return}u(!0);try{await w.auth.resetPasswordRequest(a),b("Reset instructions sent.")}catch(i){r(C(i,"We could not send reset instructions. Please try again."))}finally{u(!1)}};if(!x&&s)return e.jsx("div",{className:"flex min-h-[100dvh] items-center justify-center bg-[#0b0e14]",children:e.jsx(N,{className:"h-7 w-7 animate-spin text-[#3b82f6]"})});const z="h-12 rounded-lg border-[rgba(148,163,184,0.15)] bg-[#0b0e14] pl-10 text-base text-white placeholder:text-slate-600 focus:border-[#3b82f6] focus:ring-[#3b82f6]/20",k="h-12 w-full rounded-lg bg-[#3b82f6] text-base font-bold text-white hover:bg-[#2563eb]",v="rounded-lg border border-red-500/20 bg-red-500/10 px-3 py-2.5 text-sm font-medium text-red-300",G="rounded-lg border border-emerald-500/20 bg-emerald-500/10 px-3 py-2.5 text-sm font-medium text-emerald-300";return e.jsxs("div",{className:"relative min-h-[100dvh] overflow-hidden bg-[#0b0e14] px-4 pb-[calc(env(safe-area-inset-bottom)+1.5rem)] pt-[calc(env(safe-area-inset-top)+1.5rem)] text-white sm:pb-[calc(env(safe-area-inset-bottom)+2.5rem)] sm:pt-[calc(env(safe-area-inset-top)+2.5rem)]",children:[e.jsx(de,{}),e.jsxs("div",{className:"relative z-10 mx-auto flex max-w-md flex-col justify-start sm:min-h-[calc(100dvh-5rem)] sm:justify-center",children:[e.jsx("div",{className:"mb-5",children:e.jsxs(F,{to:"/Home",className:"inline-flex items-center gap-1.5 text-sm font-medium text-slate-400 transition-colors hover:text-white",children:[e.jsx(I,{className:"h-4 w-4"})," Back to home"]})}),e.jsxs("div",{className:"overflow-hidden rounded-xl border border-[rgba(148,163,184,0.14)] bg-[#11161f] shadow-2xl shadow-black/40",children:[e.jsxs("div",{className:"border-b border-[rgba(148,163,184,0.1)] bg-[#0d1119] px-6 py-6 text-center",children:[e.jsx("img",{src:ge,alt:"Truck Haters",className:"mx-auto h-11 w-auto object-contain"}),e.jsx("p",{className:"mt-2 text-[11px] font-semibold uppercase tracking-[0.18em] text-slate-500",children:"Secure Customer & Staff Portal"})]}),e.jsxs("div",{className:"p-6 sm:p-8",children:[d==="login"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-2xl font-extrabold tracking-tight text-white",children:"Welcome back"}),e.jsx("p",{className:"mt-1 text-sm text-slate-400",children:"Sign in with your Truck Haters email and password."})]}),e.jsxs("form",{onSubmit:te,className:"space-y-4",autoComplete:"on",noValidate:!0,children:[e.jsxs("div",{children:[e.jsx(E,{htmlFor:"login-email",className:"text-sm font-semibold text-white",children:"Email address"}),e.jsxs("div",{className:"relative mt-1.5",children:[e.jsx(H,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-500"}),e.jsx(P,{id:"login-email",name:"username",type:"email",inputMode:"email",autoComplete:"username",autoCapitalize:"none",spellCheck:!1,value:m,onChange:t=>M(t.target.value),className:z,required:!0})]})]}),e.jsx(L,{id:"login-password",name:"password",label:"Password",value:h,onChange:t=>A(t.target.value),autoComplete:"current-password",visible:V,onToggle:()=>q(t=>!t)}),e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("label",{className:"flex cursor-pointer items-start gap-2 text-sm text-slate-400",children:[e.jsx("input",{type:"checkbox",name:"remember-email",checked:O,onChange:t=>
6Z(t.target.checked),className:"mt-0.5 h-4 w-4 rounded border-slate-600 bg-[#0b0e14] text-[#3b82f6] focus:ring-[#3b82f6]"}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-semibold text-slate-200",children:"Remember email"}),e.jsx("span",{className:"mt-0.5 block text-xs leading-4 text-slate-500",children:"Password stays in your device's secure password manager."})]})]}),e.jsx("button",{type:"button",onClick:()=>y("forgot"),className:"shrink-0 text-sm font-semibold text-[#3b82f6] hover:underline",children:"Forgot password?"})]}),e.jsxs("div",{"aria-live":"polite",children:[g&&e.jsx("p",{className:v,children:g}),j&&e.jsx("p",{className:G,children:j})]}),e.jsx(S,{type:"submit",disabled:o,className:k,children:o?e.jsxs(e.Fragment,{children:[e.jsx(N,{className:"mr-2 h-5 w-5 animate-spin"})," Signing inâ¦"]}):"Sign In"})]}),e.jsxs("p",{className:"mt-6 text-center text-sm text-slate-400",children:["New to Truck Haters?"," ",e.jsx("button",{type:"button",onClick:()=>y("register"),className:"font-bold text-[#3b82f6] hover:underline",children:"Create account"})]})]}),d==="register"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-2xl font-extrabold tracking-tight text-white",children:"Create your secure login"}),e.jsx("p",{className:"mt-1 text-sm text-slate-400",children:"After email verification, you'll finish your business profile."})]}),e.jsxs("form",{onSubmit:se,className:"space-y-4",autoComplete:"on",noValidate:!0,children:[e.jsxs("div",{children:[e.jsx(E,{htmlFor:"register-email",className:"text-sm font-semibold text-white",children:"Email address"}),e.jsxs("div",{className:"relative mt-1.5",children:[e.jsx(H,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-500"}),e.jsx(P,{id:"register-email",name:"email",type:"email",inputMode:"email",autoComplete:"email",autoCapitalize:"none",spellCheck:!1,value:m,onChange:t=>M(t.target.value),className:z,required:!0})]})]}),e.jsx(L,{id:"new-password",name:"new-password",label:"Password",value:h,onChange:t=>A(t.target.value),autoComplete:"new-password",visible:V,onToggle:()=>q(t=>!t)}),e.jsx(L,{id:"confirm-password",name:"new-password-confirmation",label:"Confirm password",value:R,onChange:t=>B(t.target.value),autoComplete:"new-password",visible:U,onToggle:()=>$(t=>!t)}),e.jsx("p",{className:"text-xs text-slate-500",children:"Use at least 8 characters. Additional password strength may be required."}),e.jsx("div",{"aria-live":"polite",children:g&&e.jsx("p",{className:v,children:g})}),e.jsx(S,{type:"submit",disabled:o,className:k,children:o?e.jsxs(e.Fragment,{children:[e.jsx(N,{className:"mr-2 h-5 w-5 animate-spin"})," Creating loginâ¦"]}):"Continue"})]}),e.jsxs("p",{className:"mt-6 text-center text-sm text-slate-400",children:["Already have an account?"," ",e.jsx("button",{type:"button",onClick:()=>y("login"),className:"font-bold text-[#3b82f6] hover:underline",children:"Sign in"})]})]}),d==="verify"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg border border-[rgba(59,130,246,0.2)] bg-[rgba(59,130,246,0.06)]",children:e.jsx(J,{className:"h-6 w-6 text-[#3b82f6]"})}),e.jsx("h1",{className:"text-2xl font-extrabold tracking-tight text-white",children:"Verify your email"}),e.jsxs("p",{className:"mt-1 text-sm text-slate-400",children:["Enter the code sent to ",m||"your email","."]})]}),e.jsxs("form",{onSubmit:ae,className:"space-y-4",noValidate:!0,children:[e.jsxs("div",{children:[e.jsx(E,{htmlFor:"otp-code",className:"text-sm font-semibold text-white",children:"Verification code"}),e.jsx(P,{id:"otp-code",type:"text",inputMode:"numeric",autoComplete:"one-time-code",maxLength:8,value:W,onChange:t=>ee(t.target.value.replace(/\D/g,"")),className:"mt-1.5 h-13 rounded-lg border-[rgba(148,163,184,0.15)] bg-[#0b0e14] text-center text-xl font-bold tracking-[0.35em] text-white focus:border-[#3b82f6] focus:ring-[#3b82f6]/20",required:!0})]}),e.jsxs("div",{"aria-live":"polite",children:[g&&e.jsx("p",{className:v,children:g}),j&&e.jsx("p",{className:G,children:j})]}),e.jsx(S,{type:"submit",disabled:o,className:k,children:o?e.jsxs(e.Fragment,{children:[e.jsx(N,{className:"mr-2 h-5 w-5 animate-spin"})," Verifyingâ¦"]}):"Verify and Continue"})]}),e.jsxs("div",{className:"mt-5 flex items-center justify-center gap-3 text-sm",children:[e.jsx("button",{type:"button",disabled:o,onClick:re,className:"font-semibold text-[#3b82f6] hover:underline disabled:opacity-50",children:"Resend code"}),e.jsx("span",{className:"text-slate-600",children:"â¢"}),e.jsx("button",{type:"button",onClick:()=>y("register"),className:"font-semibold text-slate-400 hover:text-white",children:"Change email"}),e.jsx("span",{className:"text-slate-600",children:"â¢"}),e.jsx(F,{to:"/Home",className:"font-semibold text-slate-400 hover:text-white",children:"Back to home"})]})]}),d==="reset"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg border border-[rgba(59,130,246,0.2)] bg-[rgba(59,130,246,0.06)]",children:e.jsx(J,{className:"h-6 w-6 text-[#3b82f6]"})}),e.jsx("h1",{className:"text-2xl font-extrabold tracking-tight text-white",children:"Choose a new password"}),e.jsx("p",{className:"mt-1 text-sm text-slate-400",children:"Set your new password securely in this browser."})]}),e.jsxs("form",{onSubmit:ie,className:"space-y-4",autoComplete:"on",noValidate:!0,children:[e.jsx(L,{id:"reset-new-password",name:"new-password",label:"New password",value:h,onChange:t=>A(t.target.value),autoComplete:"new-password",visible:V,onToggle:()=>q(t=>!t)}),e.jsx(L,{id:"reset-confirm-password",name:"new-password-confirmation",label:"Confirm new password",value:R,onChange:t=>B(t.target.value),autoComplete:"new-password",visible:U,onToggle:()=>$(t=>!t)}),e.jsx("p",{className:"text-xs text-slate-500",children:"Use at least 8 characters."}),e.jsxs("div",{"aria-live":"polite",children:[!l&&e.jsx("p",{className:v,children:"This reset link is invali
6d or expired. Request a new link."}),g&&e.jsx("p",{className:v,children:g})]}),e.jsx(S,{type:"submit",disabled:o||!l,className:k,children:o?e.jsxs(e.Fragment,{children:[e.jsx(N,{className:"mr-2 h-5 w-5 animate-spin"})," Savingâ¦"]}):"Save New Password"})]}),e.jsxs("button",{type:"button",onClick:()=>y("forgot"),className:"mt-6 flex w-full items-center justify-center gap-2 text-sm font-bold text-[#3b82f6] hover:underline",children:[e.jsx(I,{className:"h-4 w-4"})," Request another reset link"]})]}),d==="forgot"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg border border-[rgba(59,130,246,0.2)] bg-[rgba(59,130,246,0.06)]",children:e.jsx(X,{className:"h-6 w-6 text-[#3b82f6]"})}),e.jsx("h1",{className:"text-2xl font-extrabold tracking-tight text-white",children:"Reset your password"}),e.jsx("p",{className:"mt-1 text-sm text-slate-400",children:"We'll email a secure link that opens in your browser."})]}),e.jsxs("form",{onSubmit:ne,className:"space-y-4",autoComplete:"on",noValidate:!0,children:[e.jsxs("div",{children:[e.jsx(E,{htmlFor:"reset-email",className:"text-sm font-semibold text-white",children:"Email address"}),e.jsxs("div",{className:"relative mt-1.5",children:[e.jsx(H,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-500"}),e.jsx(P,{id:"reset-email",name:"email",type:"email",inputMode:"email",autoComplete:"email",autoCapitalize:"none",spellCheck:!1,value:m,onChange:t=>M(t.target.value),className:z,required:!0})]})]}),e.jsxs("div",{"aria-live":"polite",children:[g&&e.jsx("p",{className:v,children:g}),j&&e.jsxs("div",{className:"rounded-lg border border-emerald-500/20 bg-emerald-500/10 px-4 py-3 text-sm text-emerald-200",children:[e.jsx("p",{className:"font-bold",children:"Reset instructions sent"}),e.jsxs("ol",{className:"mt-2 space-y-1.5 text-emerald-300/90",children:[e.jsxs("li",{children:[e.jsx("span",{className:"font-bold",children:"1."})," Open the email from Truck Haters."]}),e.jsxs("li",{children:[e.jsx("span",{className:"font-bold",children:"2."})," Tap the reset link and choose a new password in your browser."]}),e.jsxs("li",{children:[e.jsx("span",{className:"font-bold",children:"3."})," Return to the Truck Haters app and sign in with the new password."]})]})]})]}),e.jsx(S,{type:"submit",disabled:o,className:k,children:o?e.jsxs(e.Fragment,{children:[e.jsx(N,{className:"mr-2 h-5 w-5 animate-spin"})," Sendingâ¦"]}):j?"Send Again":"Send Reset Instructions"})]}),e.jsxs("button",{type:"button",onClick:()=>y("login"),className:"mt-6 flex w-full items-center justify-center gap-2 text-sm font-bold text-[#3b82f6] hover:underline",children:[e.jsx(I,{className:"h-4 w-4"})," Back to sign in"]})]}),e.jsxs("div",{className:"mt-7 flex items-center justify-center gap-2 border-t border-[rgba(148,163,184,0.1)] pt-5 text-xs text-slate-500",children:[e.jsx(he,{className:"h-4 w-4 text-emerald-500/80"}),e.jsx("span",{children:"Your connection and account are protected."})]})]})]}),e.jsxs("div",{className:"mt-5 flex items-center justify-center gap-4 text-xs text-slate-500",children:[e.jsx(F,{to:"/Privacy",className:"hover:text-[#3b82f6]",children:"Privacy"}),e.jsx(F,{to:"/Terms",className:"hover:text-[#3b82f6]",children:"Terms"}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-500/80",children:[e.jsx(xe,{className:"h-3.5 w-3.5"})," Secure login"]})]})]})]})}export{De 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.