1import{r as u,u as i,j as e,n as q,I as N,F as L,o as A,p as F,B as S,b6 as P}from"./elements-DVh2jUIM.js";import{u as T}from"./index.esm-BsOhZrKM.js";import{C as D,F as R}from"./ForgotLoginForm-DXqkLFtb.js";import{C as V}from"./CustomContent-qUKl3gpM.js";import{x as B,j as b,o as H,F as y,u as O,$ as W,y as _,k as z,ad as Q,a9 as $,L as d}from"./index-DeQvL4I7.js";import{u as G}from"./useAuthorization-D7B2eQha.js";import{u as U}from"./useBanner-CJNHVgHN.js";import{u as J}from"./useCustomContent-BqBLnYCa.js";import{u as K}from"./useLayoutContext-IVuJXBSD.js";import{u as M}from"./useRedesign-DVyq07A4.js";import"./useMutation-CfDMVIpo.js";import"./index-DWdRGcKw.js";import"./grids-DXrfAsUA.js";import"./startOfDay-AazlW55I.js";const he={title:"Welcome, Neighbor!",showPropertySelector:!1,showAi:!0};function pe(){var c;const t=B(),{setDropdown:s,setPageTitle:l}=K(),h=U(),{user:p,isLoggedIn:n}=G(),w=b(a=>a.settingsLoading),j=J("Login","Home_v2"),m=M(),[g,x]=u.useState(null),o=(c=H().state)==null?void 0:c.view,{t:r}=i();return u.useEffect(()=>{m&&t("/public")},[m,t]),u.useEffect(()=>{n&&t("/dashboard")},[n,t]),u.useEffect(()=>{const a="Welcome, Neighbor!";return s(!1),l(a),()=>{s(!1),l("")}},[p,n,s,l]),n?null:e.jsxs("div",{className:"px-horizontal-layout flex flex-wrap-reverse xl:flex-nowrap justify-center gap-10 py-8 bg-base-fill rounded-xl",children:[e.jsxs("div",{className:"flex flex-col w-full xl:max-w-[50%] gap-6",children:[!y&&e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"font-bold text-2xl lg:mb-[1vw] mb-6",children:r("auth.login.logInAccount")}),e.jsx(I,{}),e.jsx(C,{})]}),y&&e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"font-bold text-2xl lg:mb-[1vw] mb-6",children:r("auth.login.logInAccount")}),o!=null&&e.jsx(Y,{}),o==null&&e.jsx(Z,{setEmail:x}),o==="otpCodeInput"&&e.jsx(D,{email:g??"",shouldResetPassword:!1}),o!=="loginViaCredentials"&&e.jsx(te,{}),e.jsx(X,{loginViaCredentials:o==="loginViaCredentials"}),e.jsx(C,{})]}),e.jsx("div",{className:"lg:mb-[2vw] mb-12 w-full mt-6",children:e.jsx(V,{content:j})})]}),e.jsx(ee,{bannerUrl:h,settingsLoading:w})]})}function C(){const{t}=i();return e.jsxs("p",{className:"text-center",children:[t("auth.login.dontHaveAcc")," ",e.jsx(d,{to:"/create-account",className:"text-base-link",children:t("auth.login.signUp")})]})}function X({loginViaCredentials:t}){const{t:s}=i();return t?e.jsx("div",{"data-qa":"log-in-display",children:e.jsx(I,{})}):e.jsx("div",{className:"flex justify-center",children:e.jsx(d,{to:"/login",state:{view:"loginViaCredentials"},children:e.jsx(S,{"data-qa":"log-in-display",variant:"primaryOutline",children:s("auth.login.logInWithPassword")})})})}function Y(){const{t}=i();return e.jsxs(d,{to:"/login",state:{view:null},className:"flex items-center gap-2 text-base-link","data-qa":"forgot-login-back-to-login",children:[e.jsx(L,{icon:P}),e.jsx("p",{children:t("auth.login.backToLogin")})]})}function Z({setEmail:t}){const{t:s}=i();return e.jsxs("div",{className:"flex flex-col",children:[e.jsx(R,{setEmail:t,shouldResetPassword:!1}),e.jsxs("p",{className:"text-center",children:[s("auth.login.alreadyHave")," ",e.jsx(d,{to:"/login",state:{view:"otpCodeInput"},className:"text-base-link hover:underline","data-qa":"otp-email-input-continue",children:s("auth.login.continue")})]})]})}function ee({bannerUrl:t,settingsLoading:s}){return!t&&!s?null:e.jsx("div",{className:"hidden flex-col md:flex",children:s?e.jsx("div",{className:"min-h-[548px] max-h-[548px] w-[30vw] max-w-[600px] mb-20 rounded-xl"}):e.jsx("img",{src:t??"",width:548,className:"rounded-xl max-w-full max-h-[548px]",alt:"banner"})})}function I(){var r,c;const{t}=i(),s=O(),{clientId:l}=W(),h=b(a=>a.setToken),p=b(a=>a.setLastLoginDate),[n,w]=u.useState(!1),j=_(a=>a.clearStore),{handleSubmit:m,formState:{errors:g},register:x}=T(),v=()=>w(a=>!a),o=m(async({email:a,password:k})=>{try{await s.invalidateQueries();const{token:f,lastLoginDate:E}=await z.login({username:a,password:k,source:"vantacaHome",company:l??Q});if(!f)throw new Error("Invalid login");await h(f),p(E??void 0),j(),window.location.assign($("/dashboard"))}catch(f){q({message:t("auth.login.invalidLogin"),type:"error",title:t("auth.login.noAccount").toString()}),console.error(f)}});return e.jsxs("form",{id:"login-form",noValidate:!0,onSubmit:o,className:"flex flex-col gap-6",children:[e.jsx(N,{...x("email",{required:!0,pattern:/^[^@ ]+@[^@ ]+\.[^@ .]{2,}$/}),type:"text",errorSpacing:!1,label:t("auth.login.email"),className:"lg:w-11/12",placeholder:"[email protected]",error:g.email&&t("auth.login.invalidEmail").toString(),qaAttribute:"credential-email"}),e.jsx(N,{...x("password",{required:t("auth.login.passRequired").toString()}),type:n?"text":"password",label:t("auth.login.password"),className:"lg:w-11/12",errorSpacing:!0,endIcon:e.jsx(L,{icon:n?A:F,className:"text-base-header opacity-70",onClick:v}),error:(c=(r=g.password)==null?void 0:r.message)==null?void 0:c.toString(),qaAttribute:"credential-password"}),e.jsx("div",{className:"flex justify-between lg:w-11/12",children:e.jsx(d,{to:"/forgot-login",className:"text-base-link self-end text-right whitespace-nowrap","data-qa":"forgot-login-link",children:t("auth.login.forgotLogin")})}),e.jsx("div",{className:"self-center flex flex-col mt-4",children:e.jsx(S,{type:"submit",className:"mb-5 w-32 self-center","data-qa":"credential-login-button",children:t("auth.login.logIn")})})]})}function te(){return e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("div",{className:"h-[2px] bg-base-border w-full"})})}export{pe as Component,he as handle};
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.