PageSourceSearch

https://trackstein.com/assets/Auth-BRie0Vu5.js

js trackstein.com collected 2026-10-09 22:05:34 UTC 37,017 bytes, 1 lines download raw bytes

1import{r as u,dC as _e,dD as D,gS as js,eM as ae,dR as ys,aO as vs,bK as ws,M as e,aS as Ns,cx as ue,b0 as we,c$ as Q,aU as ee,ef as q,aT as A,d0 as Ye,bZ as bs,b5 as Ve,b3 as Ke,cq as Ne,dl as Ze,dP as Je,fY as Ss,aK as We}from"./vendor-BNUVQ5NN.js";import{z as ks,s as b,C as Y,f as V,g as K,a3 as Z,h as J,B as E,I as M,M as Cs,N as As,O as be,Q as Se}from"./index-BryxCFMR.js";import{P as se}from"./password-input-CYtDnq6b.js";import{L as p}from"./label-C9Mg_OMf.js";import{A as P,a as R}from"./alert-CIJFoxOt.js";import{S as ke,a as Ce,b as Ae,c as Ee,d as t}from"./select-fU-0lmrN.js";import{P as Xe}from"./phone-input-Cru3WKBc.js";import"./export-excel-BaWk6VOU.js";import"./supabase-DE1vgkE3.js";import"./sentry-B8b0D934.js";import"./command-D5rn7qv4.js";const Re={attempts:0,firstAttempt:0,blockedUntil:0};function Es(m){try{const c=localStorage.getItem(`rateLimit_${m}`);if(c)return JSON.parse(c)}catch{}return{...Re}}function Pe(m,c){try{localStorage.setItem(`rateLimit_${m}`,JSON.stringify(c))}catch{}}const Ps=(m,c)=>{const[y,F]=u.useState(()=>Es(m)),B=u.useRef(c);B.current=c,u.useEffect(()=>{const _=Date.now(),T=y.firstAttempt>0&&_-y.firstAttempt>c.windowMs,$=y.blockedUntil>0&&y.blockedUntil<=_;if(T&&$){const N={...Re};F(N),Pe(m,N)}else if(T&&y.blockedUntil===0){const N={...Re};F(N),Pe(m,N)}},[y.firstAttempt,y.blockedUntil,c.windowMs,m]);const he=u.useCallback(()=>{F(_=>{const T=Date.now(),$=B.current,N=_.attempts+1,ne={attempts:N,firstAttempt:_.firstAttempt||T,blockedUntil:N>=$.maxAttempts?T+$.blockDurationMs:_.blockedUntil};return Pe(m,ne),ne})},[m]),te=Date.now(),re=y.blockedUntil>te,U=re||y.attempts>=c.maxAttempts,pe=Math.max(0,c.maxAttempts-y.attempts);return{isBlocked:U,attemptsRemaining:pe,getRemainingTime:()=>re?Math.ceil((y.blockedUntil-te)/1e3):0,recordAttempt:he}},Qe=D().min(12,"Password must be at least 12 characters long").regex(/[A-Z]/,"Password must contain at least one uppercase letter").regex(/[a-z]/,"Password must contain at least one lowercase letter").regex(/[0-9]/,"Password must contain at least one number").regex(/[^A-Za-z0-9]/,"Password must contain at least one special character").max(128,"Password must not exceed 128 characters"),Te=js(m=>typeof m=="string"?m.trim().toLowerCase():m,D().min(1,"Email is required").email("Please enter a valid email address").max(255,"Email must not exceed 255 characters")),es=D().trim().refine(m=>m===""||/^\+[1-9]\d{6,14}$/.test(m)?!0:/^\+?[1-9][\d\s\-().]{5,20}$/.test(m)?m.replace(/[\s\-().+]/g,"").length>=6:!1,"Please enter a valid phone number"),Rs=_e({email:Te,password:D().min(1,"Password is required")}),_s=_e({fullName:D().trim().min(2,"Full name must be at least 2 characters").max(100,"Full name must not exceed 100 characters"),email:Te,phone:es.optional(),password:Qe}),Ts=D().min(2,"Company name must be at least 2 characters").max(100,"Company name must not exceed 100 characters").regex(/^[a-zA-Z0-9\s\-&.,()]+$/,"Company name contains invalid characters").transform(m=>m.trim()),Is=ae(["construction","manufacturing","oil_gas","mining","healthcare","warehousing","transportation","utilities","chemical","agriculture","general"],{errorMap:()=>({message:"Please select an industry"})}),Fs=ae(["US","CA","GB","AU","NZ","IE","DE","FR","ES","IT","NL","BE","SE","NO","DK","FI","CH","AT","JP","SG","HK","IN","AE","SA","MX","BR","AR","CL","CO","PE","ZA","KE","NG","EG","MA","TN","GH","OTHER"],{errorMap:()=>({message:"Please select a country"})}),Bs=ae(["1-10","11-50","51-200","201-500","500+"]).optional(),Us=ae(["search","linkedin","conference","referral","other"]).optional(),Ls=[{value:"usa",label:"United States (OSHA, rates per 200,000 hours)"},{value:"canada",label:"Canada (rates per 200,000 hours)"},{value:"uk",label:"United Kingdom (RIDDOR)"},{value:"australia",label:"Australia (WHS)"},{value:"uae",label:"United Arab Emirates (OSHAD)"},{value:"eu",label:"European Union"},{value:"singapore",label:"Singapore"},{value:"international",label:"Other / International (rates per 1,000,000 hours)"}],Os=ae(["usa","canada","uk","australia","uae","eu","singapore","international"],{errorMap:()=>({message:"Please select your safety reporting region"})}),qs=_e({fullName:D().trim().min(2,"Full name must be at least 2 characters").max(100,"Full name must not exceed 100 characters"),email:Te,phone:es.refine(m=>m!=="","Phone number is required"),password:Qe,companyName:Ts,country:Fs,safetyRegion:Os,industry:Is,companySize:Bs,referralSource:Us}
1),Ms={fullName:"",email:"",phone:"",password:"",companyName:"",country:"",safetyRegion:"",industry:"general",companySize:void 0,referralSource:void 0};function Qs(){var qe,Me,De,$e,Ge,He;const[m]=ys(),c=m.get("invitation"),y=u.useRef(0),F=u.useCallback(a=>{const s=Date.now();if(!(s-y.current<200)){y.current=s;try{window.history.replaceState({},"",a)}catch{}}},[]),B=new URLSearchParams(window.location.hash.substring(1)),he=m.get("type")||B.get("type"),te=m.has("code")&&m.get("type")==="recovery",re=B.has("access_token")&&B.has("refresh_token"),U=he==="recovery"||te||re&&B.get("type")==="recovery",[pe,Ie]=u.useState(U),[_,T]=u.useState(c?"accept-invitation":"signin"),[$,N]=u.useState(!1),[ne,L]=u.useState(U),[ss,xe]=u.useState(!1),[W,G]=u.useState(null),[ie,le]=u.useState(""),[ce,Fe]=u.useState(""),[Be,Ue]=u.useState(""),[as,Le]=u.useState(!1),[S,O]=u.useState({fullName:"",email:"",phone:"",password:""}),[v,I]=u.useState(Ms),[i,o]=u.useState({}),[k,w]=u.useState(!1),[h,ts]=u.useState(null),[oe,ge]=u.useState(!!c),[de,H]=u.useState(null),{signIn:fe,user:f,resetPassword:rs,updatePassword:ns}=ks(),je=vs().state,ye=((qe=je==null?void 0:je.from)==null?void 0:qe.pathname)||sessionStorage.getItem("auth-redirect-path")||"/dashboard",is=ye.startsWith("/")&&!ye.startsWith("//")?ye:"/dashboard",r=Ps("auth_attempts",{maxAttempts:5,windowMs:15*60*1e3,blockDurationMs:15*60*1e3});u.useEffect(()=>{c&&ls()},[c]),u.useEffect(()=>{const{data:{subscription:a}}=b.auth.onAuthStateChange((d,l)=>{d==="PASSWORD_RECOVERY"?(Ie(!0),L(!0),xe(!0),G(null)):d==="SIGNED_IN"&&l&&U&&xe(!0)});let s=null;return U&&(s=setTimeout(async()=>{try{const{data:{session:d},error:l}=await b.auth.getSession();l?(G("Failed to verify recovery link. Please request a new one."),L(!1)):d?xe(!0):(G("Recovery link is invalid or has expired. Please request a new password reset."),L(!1))}catch{G("Could not connect to the server. Please try again."),L(!1)}},2500)),()=>{a.unsubscribe(),s&&clearTimeout(s)}},[U]);const ls=async()=>{if(c){ge(!0),H(null);try{const a="https://qabqjkhvgefvurbbbbkw.supabase.co",s="sb_publishable_uFk9ZbLFLevVmzxtyfGA8Q_oAIkX5JR",d=new AbortController,l=setTimeout(()=>d.abort(),15e3),x=await fetch(`${a}/rest/v1/rpc/validate_invitation_token`,{method:"POST",headers:{"Content-Type":"application/json",apikey:s,Authorization:`Bearer ${s}`},body:JSON.stringify({token_value:c}),signal:d.signal});clearTimeout(l);const n=await x.json();if(x.ok&&n){const g=typeof n=="string"?JSON.parse(n):n;ts({companies:{name:g.company_name},role:g.role,email:g.email}),O(z=>({...z,email:g.email})),ge(!1);return}const C=((n==null?void 0:n.message)||(n==null?void 0:n.error)||"").toLowerCase();C.includes("too many validation attempts")||C.includes("too many")?H("Too many validation attempts. Please try again later."):C.includes("invalid or expired")?H("This invitation link is invalid, expired, or has already been accepted. Please request a new invitation from your company administrator, or sign in if you already have an account."):H((n==null?void 0:n.message)||"Unable to validate this invitation link. It may be invalid or expired.")}catch(a){(a==null?void 0:a.name)==="AbortError"?H("The request timed out. Please check your internet connection and try again."):H("Failed to validate invitation. Please check your internet connection and try again.")}finally{ge(!1)}}},ve=ws(),[Oe,me]=u.useState(!1),cs=async()=>{var a,s,d;if(!(!c||!h||!f)){me(!0),o({});try{const{data:l,error:x}=await b.rpc("validate_invitation_token",{token_value:c});if(x||!l){o({email:"This invitation link is invalid, expired, or has already been accepted."}),me(!1);return}const n=typeof l=="string"?JSON.parse(l):l;if(n.email.toLowerCase()!==((a=f.email)==null?void 0:a.toLowerCase())){o({email:`This invitation was sent to ${n.email}. You are signed in as ${f.email}. Please sign in with the correct account.`}),me(!1);return}const{error:C}=await b.from("user_roles").upsert({user_id:f.id,role:n.role,company_id:n.company_id},{onConflict:"user_id, role, company_id"});if(C&&await b.from("user_roles").insert({user_id:f.id,role:n.role,company_id:n.company_id}),await b.from("company_invitations").update({accepted_at:new Date().toISOString()}).eq("id",n.id),await b.from("audit_logs").insert({actor_user_id:f.id,action:"invitation_accepted",entity_type:"company_invitation",entity_id:n.id,company_id:n.company_id,metadata:{role:n.role,is_existing_user:!0,email:f.email}}).then(()=>{}),["employee","maintenance","trainer","issuer"].includes(n.role)){const{data:z}=await b.from("crew").select("id").eq("user_id",f.id).eq("company_id",n.company_id).is("deleted_at",null).limit(1).maybeSingle();if(!z){const j=((s=f.user_metadata)==null?void 0:s.full_name)||f.email||"",X=j.trim().split(/\s+/),ps=X[0]||j,xs=X.length>1?X.slice(1).join(" "):null,{data:ze}=await b.from("crew").insert({user_id:f.id,company_id:n.company_id,first_name:ps,last_name:xs,email:(d=f.email)==null?void 0:d.toLowerCase(),status:"Active",hire_date:new Date().toISOString().split("T")[0],onboarding_status:"in_progress",onboarding_started_at:new Date().toISOString()}).select("id").single();if(ze){const gs=["Complete employment paperwork","Review company policies and handbook","Safety orientation and training","Issue PPE equipment","Set up email and system access","Assign to division and supervisor","Complete I-9 verification","Set up direct deposit","Complete emergency contact information","Review job description and responsibilities"];await b.from("crew_onboarding").insert(gs.map(fs=>({crew_id:ze.id,company_id:n.company_id,checklist_item:fs,completed:!1})))}}}We.success(`You've joined ${n.company_name} as ${n.role.replace(/_/g," ")}!`),ve(`/welcome?role=${encodeURIComponent(n.role)}`,{replace:!0})}catch(l){o({email:(l==null?void 0:l.message)||"Failed to accept invitation. Please try again."})}finally{me(!1)}}};if(f&&!pe&&!c)return e.jsx(Ns,{to:is,replace:!0});const os=async a=>{if(a.preventDefault(),o({}),r.isBlocked){o({email:`Too many attempts. Try again in ${r.getRemainingTime()} seconds.`});return}const s={email:S.email,password:S.password},d=Rs.safeParse(s);if(!d.success){const x={};
1d.error.errors.forEach(n=>{const C=n.path[0];x[C]=n.message}),o(x);return}w(!0),r.recordAttempt();const{error:l}=await fe(d.data.email,d.data.password);l&&o({form:l.message}),w(!1)},ds=async a=>{var d;if(a.preventDefault(),o({}),r.isBlocked){o({email:`Too many attempts. Try again in ${r.getRemainingTime()} seconds.`});return}const s=_s.safeParse(S);if(!s.success){const l={};s.error.errors.forEach(x=>{const n=x.path[0];l[n]=x.message}),o(l);return}if(!c){o({email:"Invitation required to create an account."});return}w(!0),r.recordAttempt();try{const l="https://qabqjkhvgefvurbbbbkw.supabase.co",x="sb_publishable_uFk9ZbLFLevVmzxtyfGA8Q_oAIkX5JR",n=new AbortController,C=setTimeout(()=>n.abort(),3e4);let g=null;try{const j=await fetch(`${l}/functions/v1/accept-invitation`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${x}`},body:JSON.stringify({token:c,email:s.data.email,password:s.data.password,fullName:s.data.fullName,phone:s.data.phone}),signal:n.signal});if(clearTimeout(C),g=await j.json(),!j.ok){const X=(g==null?void 0:g.error)||(g==null?void 0:g.message)||"Failed to accept invitation";o({email:X}),w(!1);return}}catch(j){clearTimeout(C),(j==null?void 0:j.name)==="AbortError"?o({email:"Request timed out. Please try again."}):o({email:(j==null?void 0:j.message)||"Failed to accept invitation"}),w(!1);return}if(g&&!g.success&&g.error){o({email:String(g.error)}),w(!1);return}const z=await fe(s.data.email,s.data.password);if(z.error)o({email:z.error.message||"Account created, but sign-in failed. Please try signing in."});else{const j=(h==null?void 0:h.role)||"employee";We.success(`Welcome! You've joined ${((d=h==null?void 0:h.companies)==null?void 0:d.name)||"the company"} as ${j.replace(/_/g," ")}.`),ve(`/welcome?role=${encodeURIComponent(j)}`,{replace:!0});return}}catch(l){o({email:(l==null?void 0:l.message)||"Failed to accept invitation"})}finally{w(!1)}},ms=async a=>{if(a.preventDefault(),o({}),r.isBlocked){o({email:`Too many attempts. Try again in ${r.getRemainingTime()} seconds.`});return}const s=qs.safeParse(v);if(!s.success){const d={};s.error.errors.forEach(l=>{const x=l.path[0];d[x]=l.message}),o(d);return}w(!0),r.recordAttempt();try{const{data:d,error:l}=await b.functions.invoke("self-signup",{body:{email:s.data.email,password:s.data.password,fullName:s.data.fullName,phone:s.data.phone,companyName:s.data.companyName,country:s.data.country,safetyRegion:s.data.safetyRegion,industry:s.data.industry,companySize:s.data.companySize,referralSource:s.data.referralSource}});if(l){o({email:l.message||"Failed to create account"}),w(!1);return}const x=await fe(s.data.email,s.data.password);x.error&&o({email:x.error.message||"Account created, but sign-in failed. Please try signing in."})}catch(d){o({email:(d==null?void 0:d.message)||"Failed to create account"})}finally{w(!1)}},us=async a=>{if(a.preventDefault(),o({}),!ie||!ie.includes("@")){o({resetEmail:"Please enter a valid email address"});return}w(!0);const{error:s}=await rs(ie);w(!1),s||Le(!0)},hs=async a=>{if(a.preventDefault(),o({}),!/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^a-zA-Z\d]).{12,}$/.test(ce)){o({newPassword:"Password must be at least 12 characters and include uppercase, lowercase, a number, and a special character"});return}if(ce!==Be){o({confirmPassword:"Passwords do not match"});return}w(!0);const{error:d}=await ns(ce);w(!1),d||(L(!1),Fe(""),Ue(""),F("/auth"))};return $?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsxs(ue,{to:"/home",className:"inline-block",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"p-3 bg-primary/10 rounded-full hover:bg-primary/20 transition-colors",children:e.jsx(we,{className:"h-8 w-8 text-primary"})})}),e.jsx("h1",{className:"text-xl sm:text-page-title tracking-tight hover:text-primary transition-colors",children:"TrackStein"})]}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"EHS Management Platform"})]}),e.jsxs(Y,{children:[e.jsxs(V,{children:[e.jsxs(K,{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"h-5 w-5"}),"Reset Password"]}),e.jsx(Z,{children:"Enter your email and we'll send you a reset link"})]}),e.jsx(J,{children:as?e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"p-4 bg-green-50 dark:bg-green-950 rounded-lg border border-green-200 dark:border-green-800",children:e.jsx("p",{className:"text-green-700 dark:text-green-300",children:"Check your email for a password reset link."})}),e.jsxs(E,{variant:"outline",className:"w-full",onClick:()=>{N(!1),Le(!1),le("")},children:[e.jsx(ee,{className:"h-4 w-4 mr-2"}),"Back to Sign In"]})]}):e.jsxs("form",{onSubmit:us,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(p,{htmlFor:"reset-email",className:"flex items-center gap-2",children:[e.jsx(Q,{className:"h-4 w-4"}),"Email"]}),e.jsx(M,{id:"reset-email",type:"email",placeholder:"Enter your email",value:ie,onChange:a=>le(a.target.value),required:!0}),i.resetEmail&&e.jsx("p",{className:"text-sm text-destructive",children:i.resetEmail})]}),e.jsx(E,{type:"submit",className:"w-full",disabled:k,children:k?"Sending...":"Send Reset Link"}),e.jsxs("button",{type:"button",onClick:()=>{N(!1),le(""),o({})},className:"w-full text-sm text-muted-foreground hover:text-foreground flex items-center justify-center gap-2",children:[e.jsx(ee,{className:"h-4 w-4"}),"Back to Sign In"]})]})})]})]})}):ne||W?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsxs(ue,{to:"/home",className:"inline-block",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"p-3 bg-primary/10 rounded-full hover:bg-primary/20 transition-colors",children:e.jsx(we,{className:"h-8 w-8 text-primary"})})}),e.jsx("h1",{className:"text-xl sm:text-page-title tracking-tight hover:text-primary transition-colors",children:"TrackStein"})]}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"EHS Management Platform"})]}),e.jsxs(Y,{children:[e.jsxs(V,{children:[e.jsxs(K,{className:"flex items-center gap-2",children:[e.jsx(q,{className:"h-5 w-5"}),W?"Link Expired":"Set New Password"]}),e.jsx(Z,{children:W?"Your password reset link has expired":"Enter your new password below"})]}),e.jsx(J,{children:W?e.jsxs("div",{className:"space-y-4",children:[e.jsxs(P,{variant:"destructive",children:[e.jsx(A,{className:"h-4 w-4"}),e.jsx(R,{children:W})]}),e.jsx(E,{variant:"outline",className:"w-full",onClick:()=>{G(null),L(!1),N(!0),F("/auth")},children:"Request New Reset Link"}),e.jsxs("button",{type:"button",onClick:()=>{G(null),L(!1),F("/auth")},className:"w-full text-sm text-muted-foreground hover:text-foreground flex items-center justify-center gap-2",children:[e.jsx(ee,{className:"h-4 w-4"}),"Back to Sign In"]})]}):ss?e.jsxs("form",{onSubmit:hs,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(p,{htmlFor:"new-password",className:"flex items-center gap-2",children:[e.jsx(q,{className:"h-4 w-4"}),"New Password"]}),e.jsx(se,{id:"new-password",placeholder:"Enter new password",value:ce,onChange:a=>Fe(a.target.value),required:!0}),i.newPassword&&e.jsx("p",{className:"text-sm text-destructive",children:i.newPassword}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsx("p",{children:"Password requirements:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 mt-1",children:[e.jsx("li",{children:"At least 12 characters long"}),e.jsx("li",{children:"Contains uppercase and lowercase letters"}),e.jsx("li",{children:"Contains at least one number"}),e.jsx("li",{children:"Contains at least one special character"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(p,{htmlFor:"confirm-password",className:"flex items-center gap-2",children:[e.jsx(q,{className:"h-4 w-4"}),"Confirm Password"]}),e.jsx(se,{id:"confirm-password",placeholder:"Confirm new password",value:
1Be,onChange:a=>Ue(a.target.value),required:!0}),i.confirmPassword&&e.jsx("p",{className:"text-sm text-destructive",children:i.confirmPassword})]}),e.jsx(E,{type:"submit",className:"w-full",disabled:k,children:k?"Updating...":"Update Password"})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 space-y-4",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"}),e.jsx("p",{className:"text-muted-foreground",children:"Verifying your reset link..."})]})})]})]})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsxs(ue,{to:"/home",className:"inline-block",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"p-3 bg-primary/10 rounded-full hover:bg-primary/20 transition-colors",children:e.jsx(we,{className:"h-8 w-8 text-primary"})})}),e.jsx("h1",{className:"text-xl sm:text-page-title tracking-tight hover:text-primary transition-colors",children:"TrackStein"})]}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"EHS Management Platform"}),h&&e.jsxs("div",{className:"mt-4 p-4 bg-blue-50 dark:bg-blue-950 rounded-lg border border-blue-200 dark:border-blue-800",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 text-blue-700 dark:text-blue-300 mb-2",children:[e.jsx(Ye,{className:"h-5 w-5"}),e.jsx("span",{className:"font-semibold",children:"Company Invitation"})]}),e.jsxs("p",{className:"text-sm text-blue-600 dark:text-blue-400",children:["You've been invited to join ",e.jsx("strong",{children:(Me=h==null?void 0:h.companies)==null?void 0:Me.name})]})]})]}),f&&c&&h&&e.jsxs(Y,{className:"mb-6",children:[e.jsxs(V,{children:[e.jsxs(K,{className:"flex items-center gap-2",children:[e.jsx(bs,{className:"h-5 w-5 text-green-500"}),"Accept Invitation"]}),e.jsxs(Z,{children:["You're signed in as ",e.jsx("strong",{children:f.email}),". Accept this invitation to join ",e.jsx("strong",{children:(De=h.companies)==null?void 0:De.name})," as ",e.jsx("strong",{children:($e=h.role)==null?void 0:$e.replace(/_/g," ")}),"."]})]}),e.jsxs(J,{className:"space-y-4",children:[i.email&&e.jsxs(P,{variant:"destructive",children:[e.jsx(A,{className:"h-4 w-4"}),e.jsx(R,{children:i.email})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(E,{className:"flex-1",onClick:cs,disabled:Oe,children:Oe?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"h-4 w-4 mr-2 animate-spin"})," Accepting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ye,{className:"h-4 w-4 mr-2"})," Accept & Join"]})}),e.jsx(E,{variant:"outline",onClick:()=>ve("/dashboard"),children:"Decline"})]})]})]}),!(f&&c&&h)&&e.jsxs(Cs,{value:_,onValueChange:T,className:"w-full",children:[e.jsxs(As,{className:`grid w-full ${c?"grid-cols-3":"grid-cols-2"}`,children:[e.jsx(be,{value:"signin",children:"Sign In"}),e.jsx(be,{value:"signup",children:"Sign Up"}),c&&e.jsx(be,{value:"accept-invitation",children:"Accept Invitation"})]}),e.jsx(Se,{value:"signin",children:e.jsxs(Y,{children:[e.jsxs(V,{children:[e.jsxs(K,{className:"flex items-center gap-2",children:[e.jsx(q,{className:"h-5 w-5"}),"Sign In"]}),e.jsx(Z,{children:"Enter your credentials to access your account"})]}),e.jsxs(J,{children:[r.isBlocked&&e.jsxs(P,{variant:"destructive",className:"mb-4",children:[e.jsx(A,{className:"h-4 w-4"}),e.jsxs(R,{children:["Too many failed attempts. Please wait ",r.getRemainingTime()," seconds before trying again."]})]}),e.jsxs("form",{onSubmit:os,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(p,{htmlFor:"signin-email",className:"flex items-center gap-2",children:[e.jsx(Q,{className:"h-4 w-4"}),"Email"]}),e.jsx(M,{id:"signin-email",type:"email",placeholder:"Enter your email",value:S.email,onChange:a=>O(s=>({...s,email:a.target.value})),required:!0,disabled:r.isBlocked,autoComplete:"email"}),i.email&&e.jsx("p",{className:"text-sm text-destructive",children:i.email})]}),i.form&&e.jsxs(P,{variant:"destructive",children:[e.jsx(A,{className:"h-4 w-4"}),e.jsx(R,{children:i.form})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(p,{htmlFor:"signin-password",className:"flex items-center gap-2",children:[e.jsx(q,{className:"h-4 w-4"}),"Password"]}),e.jsx(se,{id:"signin-password",placeholder:"Enter your password",value:S.password,onChange:a=>O(s=>({...s,password:a.target.value})),required:!0,disabled:r.isBlocked,autoComplete:"current-password"}),i.password&&e.jsx("p",{className:"text-sm text-destructive",children:i.password}),e.jsx("button",{type:"button",onClick:()=>{N(!0),le(S.email),o({})},className:"text-sm text-primary hover:underline",children:"Forgot password?"})]}),r.attemptsRemaining<=2&&r.attemptsRemaining>0&&e.jsxs(P,{children:[e.jsx(A,{className:"h-4 w-4"}),e.jsxs(R,{children:[r.attemptsRemaining," attempt(s) remaining before temporary lockout."]})]}),e.jsx(E,{type:"submit",className:"w-full",disabled:k||r.isBlocked,children:k?"Signing in...":"Sign In"})]})]})]})}),e.jsx(Se,{value:"signup",children:e.jsxs(Y,{children:[e.jsxs(V,{children:[e.jsxs(K,{className:"flex items-center gap-2",children:[e.jsx(Ke,{className:"h-5 w-5"}),"Create Your Company Account"]}),e.jsx(Z,{children:"Start with a free plan and upgrade anytime"})]}),e.jsxs(J,{children:[r.isBlocked&&e.jsxs(P,{variant:"destructive",className:"mb-4",children:[e.jsx(A,{className:"h-4 w-4"}),e.jsxs(R,{children:["Too many failed attempts. Please wait ",r.getRemainingTime()," seconds before trying again."]})]}),e.jsxs("form",{onSubmit:ms,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(p,{htmlFor:"self-signup-companyname",className:"flex items-center gap-2",children:[e.jsx(Ke,{className:"h-4 w-4"}),"Company Name"]}),e.jsx(M,{id:"self-signup-companyname",type:"text",placeholder:"Enter your company name",value:v.companyName,onChange:a=>I(s=>({...s,companyName:a.target.value})),required:!0,disabled:r.isBlocked}),i.companyName&&e.jsx("p",{className:"text-sm text-destructive",children:i.companyName})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(p,{htmlFor:"self-signup-fullname",className:"flex items-center gap-2",children:[e.jsx(Ne,{className:"h-4 w-4"}),"Full Name"]}),e.jsx(M,{id:"self-signup-fullname",type:"text",placeholder:"Enter your full name",value:v.fullName,onChange:a=>I(s=>({...s,fullName:a.target.value})),required:!0,disabled:r.isBlocked,autoComplete:"name"}),i.fullName&&e.jsx("p",{className:"text-sm text-destructive",children:i.fullName})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(p,{htmlFor:"self-signup-email",className:"flex items-center gap-2",children:[e.jsx(Q,{className:"h-4 w-4"}),"Email"]}),e.jsx(M,{id:"self-signup-email",type:"email",placeholder:"Enter your email",value:v.email,onChange:a=>I(s=>({...s,email:a.target.value})),required:!0,disabled:r.isBlocked,autoComplete:"email"}),i.email&&e.jsx("p",{className:"text-sm text-destructive",children:i.email})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(p,{htmlFor:"self-signup-phone",className:"flex items-center gap-2",children:[e.jsx(Ze,{className:"h-4 w-4"}),"Phone Number"]}),e.jsx(Xe,{id:"self-signup-phone",placeholder:"Enter your phone number",value:v.phone||"",onChange:a=>I(s=>({...s,phone:a||""})),defaultCountry:v.country&&v.country!=="OTHER"?v.country:void 0,disabled:r.isBlocked}),i.phone&&e.jsx("p",{className:"text-sm text-destructive",children:i.phone})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(p,{htmlFor:"self-signup-country",className:"flex items-center gap-2",children:[e.jsx(Je,{className:"h-4 w-4"}),"Country"]}),e.jsxs(ke,{value:v.country,onValueChange:a=>I(s=>({...s,country:a})),disabled:r.isBlocked,children:[e.jsx(Ce,{id:"self-signup-country",children:e.jsx(Ae,{placeholder:"Select country"})}),e.jsxs(Ee,{children:[e.jsx(t,{value:"US",children:"United States"}),e.jsx(t,{value:"CA",children:"Canada"}),e.jsx(t,{value:"GB",children:"United Kingdom"}),e.jsx(t,{value:"AU",children:"Australia"}),e.jsx(t,{value:"NZ",children:"New Zealand"}),e.jsx(t,{value:"IE",children:"Ireland"}),e.jsx(t,{value:"DE",children:"Germany"}),e.jsx(t,{value:"FR",children:"France"}),e.jsx(t,{value:"ES",children:"Spain"}),e.jsx(t,{value:"IT",children:"Italy"}),e.jsx(t,{value:"NL",children:"Netherlands"}),e.jsx(t,{value:"BE",children:"Belgium"}),e.jsx(t,{value:"SE",children:"Sweden"}),e.jsx(t,{value:"NO",children:"Norway"}),e.jsx(t,{value:"DK",children:"Denmark"}),e.jsx(t,{value:"FI",children:"Finland"}),e.jsx(t,{value:"CH",children:"Switzerland"}),e.jsx(t,{value:"AT",children:"Austria"}),e.jsx(t,{value:"JP",children:"Japan"}),e.jsx(t,{value:"SG",children:"Singapore"}),e.jsx(t,{value:"HK",children:"Hong Kong"}),e.jsx(t,{value:"IN",children:"India"}),e.jsx(t,{value:"AE",children:"United Arab Emirates"}),e.jsx(t,{value:"SA",children:"Saudi Arabia"}),e.jsx(t,{value:"MX",children:"Mexico"}),e.jsx(t,{value:"BR",children:"Brazil"}),e.jsx(t,{value:"AR",children:"Argentina"}),e.jsx(t,{value:"CL",children:"Chile"}),e.jsx(t,{value:"CO",children:"Colombia"}),e.jsx(t,{value:"PE",children:"Peru"}),e.jsx(t,{value:"ZA",children:"South Africa"}),e.jsx(t,{value:"KE",children:"Kenya"}),e.jsx(t,{value:"NG",children:"Nigeria"}),e.jsx(t,{value:"EG",children:"Egypt"}),e.jsx(t,{value:"MA",children:"Morocco"}),e.jsx(t,{value:"TN",children:"Tunisia"}),e.jsx(t,{value:"GH",children:"Ghana"}),e.jsx(t,{value:"OTHER",children:"Other"})]})]}),i.country&&e.jsx("p",{className:"text-sm text-destructive",children:i.country})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(p,{htmlFor:"self-signup-safety-region",className:"flex items-center gap-2",children:[e.jsx(Je,{className:"h-4 w-4"}),"Safety reporting region"]}),e.jsxs(ke,{value:v.safetyRegion,onValueChange:a=>I(s=>({...s,safetyRegion:a})),disabled:r.isBlocked,children:[e.jsx(Ce,{id:"self-signup-safety-region",children:e.jsx(Ae,{placeholder:"Select the regulations you report under"})}),e.jsx(Ee,{children:Ls.map(a=>e.jsx(t,{value:a.value,children:a.label},a.value))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Sets your compliance framework and how incident rates (TRIR, DART) are calculated. You can change it later in Admin Settings."}),i.safetyRegion&&e.jsx("p",{className:"text-sm text-destructive",children:i.safetyRegion})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(p,{htmlFor:"self-signup-industry",className:"flex items-center gap-2",children:[e.jsx(Ss,{className:"h-4 w-4"}),"Industry"]}),e.jsxs(ke,{value:v.industry,onValueChange:a=>I(s=>({...s,industry:a})),disabled:r.isBlocked,children:[e.jsx(Ce,{id:"self-signup-industry",children:e.jsx(Ae,{placeholder:"Select industry"})}),e.jsxs(Ee,{children:[e.jsx(t,{value:"construction",children:"Construction"}),e.jsx(t,{value:"manufacturing",children:"Manufacturing"}),e.jsx(t,{value:"oil_gas",children:"Oil & Gas"}),e.jsx(t,{value:"mining",children:"Mining"}),e.jsx(t,{value:"healthcare",children:"Healthcare"}),e.jsx(t,{value:"warehousing",children:"Warehousing & Logistics"}),e.jsx(t,{value:"transportation",children:"Transportation"}),e.jsx(t,{value:"utilities",children:"Utilities"}),e.jsx(t,{value:"chemical",children:"Chemical Processing"}),e.jsx(t,{value:"agriculture",children:"Agriculture"}),e.jsx(t,{value:"general",children:"General Industry"})]})]}),i.industry&&e.jsx("p",{className:"text-sm text-destructive",children:i.industry})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{className:"text-xs text-muted-foreground",children:"Email Domain (auto-detected)"}),e.jsx("div",{className:"text-sm px-3 py-2 bg-muted rounded-md",children:v.email?`@${v.email.split("@")[1]||"..."}`:"Enter email to see domain"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Team members with this email domain can be auto-assigned to your company"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(p,{htmlFor:"self-signup-password",className:"flex items-center gap-2",children:[e.jsx(q,{className:"h-4 w-4"}),"Password"]}),e.jsx(se,{id:"self-signup-password",placeholder:"Strong password (12+ chars, mixed case, numbers, symbols)",value:v.password,onChange:a=>I(s=>({...s,password:a.target.value})),required:!0,disabled:r.isBlocked,autoComplete:"new-password"}),i.password&&e.jsx("p",{className:"text-sm text-destructive",children:i.password}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsx("p",{children:"Password requirements:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 mt-1",children:[e.jsx("li",{children:"At least 12 characters long"}),e.jsx("li",{children:"Contains uppercase and lowercase letters"}),e.jsx("li",{children:"Contains at least one number"}),e.jsx("li",{children:"Contains at least one special character"})]})]})]}),r.attemptsRemaining<=2&&r.attemptsRemaining>0&&e.jsxs(P,{children:[e.jsx(A,{className:"h-4 w-4"}),e.jsxs(R,{children:[r.attemptsRemaining," attempt(s) remaining before temporary lockout."]})]}),e.jsx(E,{type:"submit",className:"w-full",disabled:k||r.isBlocked,children:k?"Creating account...":"Create Company Account"}),e.jsxs("div",{className:"text-center text-sm text-muted-foreground mt-4",children:[e.jsx("p",{children:"By 
1signing up, you'll start with a free plan."}),e.jsx("p",{children:"You can upgrade anytime from your dashboard."})]})]})]})]})}),c&&e.jsx(Se,{value:"accept-invitation",children:e.jsxs(Y,{children:[e.jsxs(V,{children:[e.jsxs(K,{className:"flex items-center gap-2",children:[e.jsx(Ne,{className:"h-5 w-5"}),"Accept Invitation"]}),e.jsx(Z,{children:oe?"Validating your invitation...":de?"There was a problem with your invitation":`Complete your account setup to join ${((Ge=h==null?void 0:h.companies)==null?void 0:Ge.name)||"your team"}`})]}),e.jsxs(J,{children:[oe&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 space-y-4",children:[e.jsx(Ve,{className:"h-8 w-8 animate-spin text-primary"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Verifying your invitation link..."})]}),!oe&&de&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(P,{variant:"destructive",children:[e.jsx(A,{className:"h-4 w-4"}),e.jsx(R,{children:de})]}),e.jsxs("div",{className:"text-center space-y-3 py-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"If you believe this is an error, please contact your company administrator to resend the invitation."}),e.jsxs(E,{variant:"outline",onClick:()=>T("signin"),className:"mt-2",children:[e.jsx(ee,{className:"h-4 w-4 mr-2"}),"Go to Sign In"]})]})]}),!oe&&!de&&e.jsxs(e.Fragment,{children:[r.isBlocked&&e.jsxs(P,{variant:"destructive",className:"mb-4",children:[e.jsx(A,{className:"h-4 w-4"}),e.jsxs(R,{children:["Too many failed attempts. Please wait ",r.getRemainingTime()," seconds before trying again."]})]}),e.jsxs("form",{onSubmit:ds,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(p,{htmlFor:"signup-fullname",className:"flex items-center gap-2",children:[e.jsx(Ne,{className:"h-4 w-4"}),"Full Name"]}),e.jsx(M,{id:"signup-fullname",type:"text",placeholder:"Enter your full name",value:S.fullName,onChange:a=>O(s=>({...s,fullName:a.target.value})),required:!0,disabled:r.isBlocked,autoComplete:"name"}),i.fullName&&e.jsx("p",{className:"text-sm text-destructive",children:i.fullName})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(p,{htmlFor:"signup-email",className:"flex items-center gap-2",children:[e.jsx(Q,{className:"h-4 w-4"}),"Email"]}),e.jsx(M,{id:"signup-email",type:"email",placeholder:"Enter your email",value:S.email,onChange:a=>O(s=>({...s,email:a.target.value})),required:!0,disabled:r.isBlocked||!!c,className:c?"bg-muted":"",autoComplete:"email"}),i.email&&e.jsx("p",{className:"text-sm text-destructive",children:i.email})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(p,{htmlFor:"signup-phone",className:"flex items-center gap-2",children:[e.jsx(Ze,{className:"h-4 w-4"}),"Phone Number"]}),e.jsx(Xe,{id:"signup-phone",placeholder:"Enter your phone number",value:S.phone||"",onChange:a=>O(s=>({...s,phone:a||""})),defaultCountry:"US",disabled:r.isBlocked}),i.phone&&e.jsx("p",{className:"text-sm text-destructive",children:i.phone})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(p,{htmlFor:"signup-password",className:"flex items-center gap-2",children:[e.jsx(q,{className:"h-4 w-4"}),"Password"]}),e.jsx(se,{id:"signup-password",placeholder:"Strong password (12+ chars, mixed case, numbers, symbols)",value:S.password,onChange:a=>O(s=>({...s,password:a.target.value})),required:!0,disabled:r.isBlocked,autoComplete:"new-password"}),i.password&&e.jsx("p",{className:"text-sm text-destructive",children:i.password}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsx("p",{children:"Password requirements:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 mt-1",children:[e.jsx("li",{children:"At least 12 characters long"}),e.jsx("li",{children:"Contains uppercase and lowercase letters"}),e.jsx("li",{children:"Contains at least one number"}),e.jsx("li",{children:"Contains at least one special character"})]})]})]}),r.attemptsRemaining<=2&&r.attemptsRemaining>0&&e.jsxs(P,{children:[e.jsx(A,{className:"h-4 w-4"}),e.jsxs(R,{children:[r.attemptsRemaining," attempt(s) remaining before temporary lockout."]})]}),e.jsx(E,{type:"submit",className:"w-full",disabled:k||r.isBlocked,children:k?"Accepting invitation...":"Accept Invitation & Create Account"}),e.jsx("div",{className:"text-center text-sm text-muted-foreground mt-4",children:e.jsxs("p",{children:["By creating your account, you'll automatically join ",e.jsx("strong",{children:(He=h==null?void 0:h.companies)==null?void 0:He.name})]})})]})]})]})]})})]}),e.jsx("div",{className:"mt-6 text-center",children:e.jsxs(ue,{to:"/home",className:"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(ee,{className:"h-4 w-4"}),"Back to Home"]})}),e.jsx("div",{className:"mt-4 text-center text-sm text-muted-foreground",children:e.jsx("p",{children:"Secure access to your EHS management platform"})})]})})}export{Qs 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.