1import{az as U,j as e,P as I,C as L,d as H,ac as Y,am as T,Q as v,R as k,B as i,h as J,bn as V,bo as Z,N as ee,L as F,K as R,an as W,ao as K}from"./index-Byg2HWAE.js";import{d as se,r as a}from"./vendor-Qgthw7N1.js";import{t as Q}from"./teamService-D0yxWeK5.js";function ae(){const[s,u]=se("/accept-invite/:token"),t=u==null?void 0:u.token,[x,z]=a.useState(null),[c,C]=a.useState(null),[D,P]=a.useState(!0),[G,S]=a.useState(!1),[O,g]=a.useState(null),[B,p]=a.useState(!1),[j,f]=a.useState(""),[N,A]=a.useState(""),[d,M]=a.useState(""),[m,l]=a.useState(""),[w,q]=a.useState(!1),[n,$]=a.useState(!1),_=a.useCallback(async()=>{if(!t){g("Invalid invitation link"),P(!1);return}try{const o=await Q.getInvitationDetails(t);z(o);try{const h=await U("GET","/api/auth/user");if(h.ok){const r=await h.json();C(r)}}catch{C(null)}}catch(o){g(o.message||"Failed to load invitation details")}finally{P(!1)}},[t]);return a.useEffect(()=>{_()},[_]),{invitation:x,loading:D,accepting:G,error:O,success:B,user:c,firstName:j,setFirstName:f,lastName:N,setLastName:A,password:d,setPassword:M,confirmPassword:m,setConfirmPassword:l,showPassword:w,setShowPassword:q,showConfirmPassword:n,setShowConfirmPassword:$,handleAccept:async o=>{var h;if(o&&o.preventDefault(),!!t){S(!0);try{const r={};if(!c){if(!j||!N||!d)throw new Error("Please fill in all fields");
1if(d.length<6)throw new Error("Password must be at least 6 characters");if(d!==m)throw new Error("Passwords don't match");r.firstName=j,r.lastName=N,r.password=d}const y=await Q.acceptInvitation(t,r);p(!0);const E=(((h=y.user)==null?void 0:h.role)||"team_member")==="team_member"?"/member/time-entries":"/dashboard";setTimeout(()=>{window.location.href=E},2e3)}catch(r){let y="An error occurred";if(r instanceof Error)try{const b=JSON.parse(r.message.replace(/^\d+:\s*/,"")),E=[b.message];b.errors&&Array.isArray(b.errors)&&b.errors.forEach(X=>E.push(X.message)),y=E.join(". ")}catch{y=r.message}g(y||"Failed to accept invitation")}finally{S(!1)}}},handleLogout:async()=>{try{await U("POST","/api/logout"),window.location.reload()}catch(o){console.error("Logout failed",o)}},handleGoogleSignup:()=>{t&&(window.location.href=`/api/auth/google?return_url=/accept-invite/${t}`)}}}function oe(){const{invitation:s,loading:u,accepting:t,error:x,success:z,user:c,firstName:C,setFirstName:D,lastName:P,setLastName:G,password:S,setPassword:O,confirmPassword:g,setConfirmPassword:B,showPassword:p,setShowPassword:j,showConfirmPassword:f,setShowConfirmPassword:N,handleAccept:A,handleLogout:d,handleGoogleSignup:M}=ae();if(u)return e.jsx(I,{hideEmailIntake:!0,children:e.jsx("div",{className:"min-h-screen flex items-center justify-center p-4",style:{background:"transparent"},children:e.jsx(L,{className:"w-full max-w-md",children:e.jsxs(H,{className:"flex items-center justify-center p-8",children:[e.jsx(Y,{className:"h-8 w-8 animate-spin text-blue-500"}),e.jsx("span",{className:"ml-2 text-lg",children:"Loading invitation..."})]})})})});if(x&&!s)return e.jsx(I,{hideEmailIntake:!0,children:e.jsx("div",{className:"min-h-screen flex items-center justify-center p-4",style:{background:"transparent"},children:e.jsx(L,{className:"w-full max-w-md",children:e.jsxs(H,{className:"text-center p-8 space-y-4",children:[e.jsx(T,{className:"h-12 w-12 text-red-500 mx-auto"}),e.jsx("h2",{className:"text-xl font-semibold text-red-700 dark:text-red-400",children:"Invitation Error"}),e.jsx(v,{variant:"destructive",children:e.jsx(k,{children:x})}),e.jsx(i,{variant:"outline",onClick:()=>window.location.href="/",children:"Go to Home"})]})})})});if(z)return e.jsx(I,{hideEmailIntake:!0,children:e.jsx("div",{className:"min-h-screen flex items-center justify-center p-4",style:{background:"transparent"},children:e.jsx(L,{className:"w-full max-w-md",children:e.jsxs(H,{className:"text-center p-8 space-y-4",children:[e.jsx(J,{className:"h-12 w-12 text-green-500 mx-auto"}),e.jsx("h2",{className:"text-xl font-semibold text-green-700 dark:text-green-400",children:"Welcome to the Team!"}),e.jsxs("p",{className:"text-gray-600 dark:text-gray-300",children:["You have successfully joined"," ",(s==null?void 0:s.orgName)||"the team","."]}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-sm",children:"Redirecting to dashboard..."}),e.jsx(i,{onClick:()=>window.location.href="/dashboard",className:"w-full",children:"Go to Dashboard Now"})]})})})});const m=s&&new Date>new Date(s.expiresAt),l=(s==null?void 0:s.status)==="accepted",w=(s==null?void 0:s.status)==="cancelled",q=c&&s&&c.email.toLowerCase()!==s.email.toLowerCase();return e.jsx(I,{hideEmailIntake:!0,children:e.jsx("div",{className:"min-h-screen flex items-center justify-center p-4",style:{background:"transparent"},children:e.jsx(L,{className:"w-full max-w-5xl shadow-lg border border-gray-200",children:e.jsxs("div",{className:"grid md:grid-cols-2 min-h-[600px]",children:[e.jsx("div",{className:"flex flex-col items-center justify-center p-8 md:p-12 bg-gradient-to-br from-blue-50 to-indigo-50 dark:from-blue-950/30 dark:to-indigo-950/30",children:e.jsxs("div",{className:"text-center space-y-6 max-w-sm",children:[e.jsxs("div",{className:"mascot-container",children:[e.jsx("img",{src:"/repsshield-logo-full.png",alt:"REPSShield",className:"bouncing-mascot"}),e.jsx("div",{className:"mascot-shadow"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h1",{className:"text-2xl md:text-3xl font-bold text-gray-800 dark:text-white leading-tight",children:["You've been invited to join"," ",e.jsx("span",{className:"text-blue-600 dar
1k:text-blue-400",children:(s==null?void 0:s.orgName)||"a team"})]}),e.jsx("p",{className:"text-lg text-gray-700 dark:text-gray-200 font-medium",children:"Complete your registration to start collaborating"})]}),e.jsxs("div",{className:"bg-white/70 dark:bg-gray-800/50 rounded-lg p-4 space-y-3 text-sm border border-gray-100 dark:border-gray-700 text-left",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Role"}),e.jsx("span",{className:"font-medium capitalize bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 px-2 py-0.5 rounded text-xs",children:s==null?void 0:s.role})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Invited Email"}),e.jsx("span",{className:"font-medium text-gray-800 dark:text-gray-200",children:s==null?void 0:s.email})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Invited By"}),e.jsx("span",{className:"font-medium text-gray-800 dark:text-gray-200",children:(s==null?void 0:s.inviterName)||"Team Admin"})]})]}),e.jsx("div",{className:"pt-4",children:e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:["Already have an account?"," ",e.jsx("a",{href:"/login",className:"text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 font-medium underline",children:"Login first"})," ","then click the invite link again."]})})]})}),e.jsxs("div",{className:"p-8 md:p-12 flex flex-col justify-center",children:[(m||l||w)&&e.jsxs(v,{variant:l?"default":"destructive",className:"mb-6",children:[l?e.jsx(J,{className:"h-4 w-4"}):e.jsx(T,{className:"h-4 w-4"}),e.jsx(V,{children:l?"Accepted":"Invalid Invitation"}),e.jsx(k,{children:l?"This invitation has already been accepted.":m?"This invitation has expired.":"This invitation has been cancelled."})]}),x&&e.jsxs(v,{variant:"destructive",className:"mb-6",children:[e.jsx(T,{className:"h-4 w-4"}),e.jsx(k,{children:x})]}),!m&&!l&&!w&&e.jsx("div",{className:"space-y-6",children:c?q?e.jsxs(v,{variant:"destructive",className:"border-orange-200 bg-orange-50 dark:bg-orange-900/20 dark:border-orange-900/50",children:[e.jsx(T,{className:"h-4 w-4 text-orange-600 dark:text-orange-400"}),e.jsx(V,{className:"text-orange-800 dark:text-orange-300",children:"Wrong Account"}),e.jsxs(k,{className:"text-orange-700 dark:text-orange-400 mt-2",children:["You are logged in as"," ",e.jsx("strong",{children:c.email}),", but this invitation is for"," ",e.jsx("strong",{children:s==null?void 0:s.email}),".",e.jsx("div",{className:"mt-3",children:e.jsxs(i,{variant:"outline",size:"sm",onClick:()=>d(),className:"w-full border-orange-200 hover:bg-orange-100 hover:text-orange-900 dark:border-orange-800 dark:hover:bg-orange-900/50",children:[e.jsx(Z,{className:"h-4 w-4 mr-2"}),"Logout & Switch Account"]})})]})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs(v,{className:"bg-blue-50 border-blue-100 dark:bg-blue-900/20 dark:border-blue-800",children:[e.jsx(J,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"}),e.jsxs(k,{className:"text-blue-800 dark:text-blue-300",children:["You are logged in as"," ",e.jsx("strong",{children:c.email}),"."]})]}),e.jsx(i,{onClick:()=>A(),disabled:t,className:"w-full bg-yellow-400 hover:bg-yellow-500 text-black font-medium py-3",size:"lg",children:t?e.jsxs(e.Fragment,{children:[e.jsx(Y,{className:"w-4 h-4 mr-2 animate-spin"}),"Joining Team..."]}):"ACCEPT INVITATION"})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"space-y-3",children:e.jsxs(i,{variant:"outline",className:"w-full",onClick:M,disabled:t,children:[e.jsxs("svg",{className:"w-4 h-4 mr-2",viewBox:"0 0 24 24",children:[e.jsx("path",{fill:"#4285F4",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"}),e.jsx("path",{fill:"#34A853",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"}),e.jsx("path",{fill:"#FBBC05",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"}),e.jsx("path",{fill:"#EA4335",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"})]}),"Continue with Google"]})}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx(ee,{className:"w-full"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-white dark:bg-gray-950 px-2 text-gray-500",children:"Or create an account"})})]}),e.jsxs("form",{onSubmit:A,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(F,{htmlFor:"firstName",className:"text-sm font-medium text-gray-700 dark:text-gray-300 uppercase tracking-wide",children:"First Name"}),e.jsx(R,{id:"firstName",placeholder:"Enter your first name",value:C,onChange:n=>D(n.target.value),required:!0,className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(F,{htmlFor:"lastName",className:"text-sm font-medium text-gray-700 dark:text-gray-300 uppercase tracking-wide",children:"Last Name"}),e.jsx(R,{id:"lastName",placeholder:"Enter your last name",value:P,onChange:n=>G(n.target.value),required:!0,className:"mt-1"})]})]}),e.jsxs("div",{children:[e.jsx(F,{htmlFor:"password",className:"text-sm font-medium text-gray-700 dark:text-gray-300 uppercase tracking-wide",children:"Password"}),e.jsxs("div",{className:"relative mt-1",children:[e.jsx(R,{id:"password",type:p?"text":"password",placeholder:"Create a password",value:S,onChange:n=>O(n.target.value),required:!0,minLength:6}),e.jsx(i,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>j(!p),children:p?e.jsx(W,{className:"h-4 w-4"}):e.jsx(K,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{children:[e.jsx(F,{htmlFor:"confirmPassword",className:"text-sm font-medium text-gray-700 dark:text-gray-300 uppercase tracking-wide",children:"Confirm Password"}),e.jsxs("div",{className:"relative mt-1",children:[e.jsx(R,{id:"confirmPassword",type:f?"text":"password",placeholder:"Confirm your password",value:g,onChange:n=>B(n.target.value),required:!0,minLength:6}),e.jsx(i,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>N(!f),children:f?e.jsx(W,{className:"h-4 w-4"}):e.jsx(K,{className:"h-4 w-4"})})]})]}),e.jsx(i,{type:"submit",className:"w-full bg-yellow-400 hover:bg-yellow-500 text-black font-medium py-3 mt-6",disabled:t,children:t?e.jsxs(e.Fragment,{children:[e.jsx(Y,{className:"w-4 h-4 mr-2 animate-spin"}),"Creating Account..."]}):"CREATE ACCOUNT & JOIN"})]})]})}),(m||l||w)&&e.jsx("div",{className:"mt-4 text-center",children:e.jsx(i,{variant:"outline",onClick:()=>window.location.href="/",children:"Go to Home"})})]})]})})})})}export{oe 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.