1import{u as C,r,s as V,j as e,A as F,C as J,a as K,b as Q,L as X,c as Z,B as x,d as $,e as ne,f as re,g as ie,h as le,i as oe,k as ce,l as de,m as _,n as P,I as A,M as me,o as ue,p as he}from"./index-DaQRcXJP.js?dpl=dpl_3Xoi9Qkh6ZkLDrXxRVzBv8pnT45F";import{F as xe}from"./index-BAZwQ60B.js?dpl=dpl_3Xoi9Qkh6ZkLDrXxRVzBv8pnT45F";import{p as W}from"./productLassoUrls-CgFNIVqm.js?dpl=dpl_3Xoi9Qkh6ZkLDrXxRVzBv8pnT45F";import{r as fe}from"./uiFailureReporting-B1Hp5Ap4.js?dpl=dpl_3Xoi9Qkh6ZkLDrXxRVzBv8pnT45F";import{E as ge}from"./eye-off-COpY9IJM.js?dpl=dpl_3Xoi9Qkh6ZkLDrXxRVzBv8pnT45F";import{E as pe}from"./eye-C_v5gfzV.js?dpl=dpl_3Xoi9Qkh6ZkLDrXxRVzBv8pnT45F";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};s.SENTRY_RELEASE={id:"4512fedfb5fc8e1dfdaaed8980acdaefd0f8d84c"};var c=new s.Error().stack;c&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[c]="bb5610e4-3c76-442b-b38a-1081854cd2fd",s._sentryDebugIdIdentifier="sentry-dbid-bb5610e4-3c76-442b-b38a-1081854cd2fd")}catch{}})();function je({userId:s,email:c,onSignOut:f,companyError:n,onRetry:v}){const{t:i}=C("invitation"),{t:S}=C("settings"),[d,p]=r.useState([]),[g,N]=r.useState(!0),[j,l]=r.useState(!1),[u,y]=r.useState(0);return r.useEffect(()=>{let o=!0;return N(!0),l(!1),Promise.resolve(V.rpc("get_my_pending_invitations")).then(({data:b,error:h})=>{o&&(l(!!h),p(h?[]:b??[]),N(!1))}).catch(()=>{o&&(l(!0),N(!1))}),()=>{o=!1}},[s,u]),e.jsxs("div",{className:"relative min-h-screen overflow-hidden",children:[e.jsx(F,{}),e.jsx("div",{className:"relative z-10 flex min-h-screen items-center justify-center p-4",children:e.jsxs(J,{className:"w-full max-w-md",children:[e.jsxs(K,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Q,{children:i("welcomeTitle")}),e.jsx(X,{})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:i("signedInAs",{email:c})})]}),e.jsxs(Z,{className:"space-y-4",children:[g?e.jsx("p",{role:"status",children:i("loading")}):j||n?e.jsxs("div",{role:"alert",className:"space-y-3",children:[e.jsx("p",{children:i("invitationsLoadFailed")}),e.jsx(x,{className:"shadow-none",onClick:()=>{y(o=>o+1),v()},children:i("retry")})]}):d.length?e.jsxs(e.Fragment,{children:[e.jsx("p",{children:i("pendingInvitations")}),d.map(o=>e.jsx(x,{asChild:!0,variant:"outline",className:"w-full shadow-none",children:e.jsx($,{to:`/invite/${encodeURIComponent(o.token)}`,children:i("joinCompany",{company:o.company_name})})},o.token))]}):e.jsx("p",{children:i("noCompany")}),e.jsx($,{className:"block text-sm underline",to:"/account/delete",children:S("lifecycle.accountTitle")}),e.jsx(x,{variant:"link",onClick:()=>{f().catch(()=>l(!0))},children:i("signOutTryAgain")})]})]})})]})}const ye="app.productlasso.com";function we(s){return s.trim().toLowerCase().replace(/\.$/,"")}function ve(s){return we(s)===ye}function Ne(s=window.location){return s.hostname}function be(s=window.location){return ve(Ne(s))}function Ce({userId:s,authLoading:c,companyInitialized:f,initializedForUserId:n,hasCompany:v}){return!!(s&&!c&&f&&n===s&&v)}const Se="product_extraction";function Y({href:s}){return e.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"absolute top-4 left-4 flex h-9 cursor-pointer items-center",children:e.jsx("img",{src:"/assets/logo_lasso_new.svg",alt:"Lasso",className:"h-7"})})}function Ae(){const{t:s,i18n:c}=C("auth"),{t:f}=C("common");ne("login");const{user:n,signIn:v,signInWithGoogle:i,resetPassword:S,loading:d,error:p,clearError:g,signOut:N}=re(),{hasCompany:j,initialized:l,initializedForUserId:u,error:y,refetch:o}=ie(),b=le(),[h,L]=r.useState(""),[T,R]=r.useState(""),[I,ee]=r.useState(!1),[m,w]=r.useState(!1),[k,D]=r.useState("signin"),[O,U]=r.useState(!1),z=be(),M=`${oe}/${ce(c.language)}`,B=j(),E=n?.id;r.useEffect(()=>{if(!E||d||!l||u!==E||B)return;let t=!0;return V.auth.getUser().then(async({error:a})=>{!t||!a||![401,403,404].includes(a.status??0)||(await de(),window.location.replace("/login"))}).catch(()=>{}),()=>{t=!1}},[E,d,l,u,B]),r.useEffect(()=>{!y&&Ce({userId:n?.id??null,authLoading:d,companyInitialized:l,initializedForUserId:u,hasCompany:j()})&&b("/",{replace:!0})},[n,d,l,u,j,b,y]);const G=t=>{const a=t.toLowerCase();return a.includes("invalid login credentials")||a.includes("invalid email or password")?s("errors.invalidCredentials"):a.includes("email not confirmed")?s("errors.emailN
1otConfirmed"):a.includes("too many requests")||a.includes("rate limit")?s("errors.tooManyRequests"):a.includes("already registered")||a.includes("user already registered")?s("errors.userAlreadyRegistered"):a.includes("failed to sign in with google")?s("errors.googleFailed"):a.includes("failed to sign in")?s("errors.signInFailed"):a.includes("failed to sign up")?s("errors.signUpFailed"):a.includes("failed to sign out")?s("errors.signOutFailed"):a.includes("failed to send reset link")?s("errors.resetFailed"):s("errors.generic")},se=async t=>{t.preventDefault(),w(!0),g();try{await v(h,T)}catch{}finally{w(!1)}},te=async t=>{t.preventDefault(),w(!0),g();try{await S(h),U(!0)}catch{}finally{w(!1)}},ae=async()=>{w(!0),g();try{await i()}catch(t){he(t)&&t.status&&t.status>=400&&t.status<500||fe("auth_google_start_failed")}finally{w(!1)}},H=()=>{L(""),R(""),U(!1),g()},q=()=>{H(),b(`/onboarding/${Se}`)};return n&&!d&&l&&u===n.id&&(!j()||y)?e.jsx(je,{userId:n.id,email:n.email,onSignOut:N,companyError:y,onRetry:o},n.id):d||n&&(!l||u!==n.id)?e.jsxs("div",{className:"relative min-h-screen overflow-hidden",children:[e.jsx(F,{}),e.jsxs("div",{className:"relative z-10 flex min-h-screen items-center justify-center",children:[z&&e.jsx(Y,{href:M}),e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(_,{className:"h-8 w-8 animate-spin"}),e.jsx("p",{className:"text-sm text-gray-600",children:f("loading")})]})]})]}):e.jsxs("div",{className:"relative min-h-screen overflow-hidden",children:[e.jsx(F,{}),e.jsxs("div",{className:"relative z-10 flex min-h-screen w-full items-center justify-center px-4",children:[z&&e.jsx(Y,{href:M}),e.jsx(x,{type:"button",variant:"outline",className:"absolute top-4 right-4 bg-white shadow-none hover:shadow-none",onClick:q,children:s("signUp")}),e.jsxs(J,{className:"w-full max-w-md",children:[e.jsxs(K,{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Q,{className:"text-2xl font-semibold",children:s(k==="signin"?"welcome":"forgotPasswordTitle")}),e.jsx(X,{})]}),k==="forgotPassword"&&!O&&e.jsx("p",{className:"text-sm text-gray-500",children:s("forgotPasswordDescription")})]}),e.jsx(Z,{children:k==="signin"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("form",{onSubmit:se,className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(P,{htmlFor:"email",children:s("email")}),e.jsx(A,{id:"email",name:"email",type:"email",placeholder:s("emailPlaceholder"),value:h,onChange:t=>L(t.target.value),required:!0,disabled:m,autoComplete:"email",className:"shadow-none"})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(P,{htmlFor:"password",children:s("password")}),e.jsxs("div",{className:"relative",children:[e.jsx(A,{id:"password",name:"password",type:I?"text":"password",placeholder:s("passwordPlaceholder"),value:T,onChange:t=>R(t.target.value),required:!0,disabled:m,autoComplete:"current-password",className:"shadow-none"}),e.jsx(x,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 shadow-none hover:bg-transparent hover:shadow-none",onClick:()=>ee(!I),disabled:m,children:I?e.jsx(ge,{className:"h-4 w-4"}):e.jsx(pe,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"flex justify-end -mt-1",children:e.jsx("button",{type:"button",onClick:()=>{g(),D("forgotPassword")},className:"text-sm text-gray-500 hover:text-gray-900 hover:underline",children:s("forgotPassword")})}),p&&e.jsx("div",{className:"text-sm text-red-600 bg-red-50 p-3 rounded-md",children:G(p)}),e.jsx(x,{type:"submit",className:"mb-0 w-full shadow-none hover:shadow-none",disabled:m,children:m?e.jsxs(e.Fragment,{children:[e.jsx(_,{className:"mr-2 h-4 w-4 animate-spin"}),s("signingIn")]}):s("signIn")}),e.jsxs("div",{className:"flex items-center my-4",children:[e.jsx("span",{className:"flex-1 h-px bg-gray-200"}),e.jsx("span",{className:"px-2 text-xs text-gray-400 uppercase",children:f("or")}),e.jsx("span",{className:"flex-1 h-px bg-gray-200"})]}),e.jsxs(x,{type:"button",variant:"outline",className:"flex w-full items-center justify-center gap-2 shadow-none hover:shadow-none",onClick:ae,disabled:m,children:[e.jsx(xe,{className:"h-5 w-5"}),s("continueWithGoogle")]})]}),e.jsxs("p",{className:"text-sm text-center text-gray-500",children:[s("noAccountYet")," ",e.jsx("button",{type:"button",onClick:q,className:"font-medium text-gray-900 hover:underline",children:s("getStarted")})]})]}):e.jsxs("div",{className:"space-y-4",children:[O?e.jsxs("div",{className:"flex flex-col items-center text-center py-4 space-y-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-green-50 flex items-center justify-center",children:e.jsx(me,{className:"h-6 w-6 text-green-600"})}),e.jsx("h3",{className:"font-semibold text-lg",children:s("resetLinkSent")}),e.jsx("p",{className:"text-sm text-gray-500",children:s("resetLinkSentDescription")})]}):e.jsxs("form",{onSubmit:te,className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(P,{htmlFor:"reset-email",children:s("email")}),e.jsx(A,{id:"reset-email",name:"email",type:"email",placeholder:s("emailPlaceholder"),value:h,onChange:t=>L(t.target.value),required:!0,disabled:m,autoComplete:"email",className:"shadow-none"})]}),p&&e.jsx("div",{className:"text-sm text-red-600 bg-red-50 p-3 rounded-md",children:G(p)}),e.jsx(x,{type:"submit",className:"w-full shadow-none hover:shadow-none",disabled:m||!h,children:m?e.jsxs(e.Fragment,{children:[e.jsx(_,{className:"mr-2 h-4 w-4 animate-spin"}),s("sendingResetLink")]}):s("sendResetLink")})]}),e.jsx("p",{className:"text-sm text-center text-gray-500",children:e.jsxs("button",{type:"button",onClick:()=>{H(),D("signin")},className:"font-medium text-gray-900 hover:underline inline-flex items-center gap-1",children:[e.jsx(ue,{className:"h-3 w-3"}),s("backToSignIn")]})})]})})]}),e.jsxs("p",{className:"absolute bottom-6 left-0 right-0 mx-auto max-w-md px-4 text-xs text-center text-gray-500/50",children:[s("termsNotice")," ",e.jsx("a",{href:W(c.language,"terms-of-service"),target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-gray-600/70",children:s("termsAndConditions")})," ",s("termsAnd")," ",e.jsx("a",{href:W(c.language,"privacy-policy"),target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-gray-600/70",children:s("privacyPolicy")})]})]})]})}export{Ae as LoginPage};
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.