1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5998],{36540:(e,r,t)=>{t.d(r,{A:()=>n});var o=t(12115);function n(){let e=(0,o.useRef)(!0);return(0,o.useEffect)(()=>(e.current=!0,()=>{e.current=!1}),[]),e}},45998:(e,r,t)=>{t.r(r),t.d(r,{default:()=>U});var o=t(95155),n=t(12115),i=t(4615),s=t(86627),l=t(27855),a=t(35346),d=t(65654),c=t(60193),u=t(12827),x=t(21844),h=t(80317),m=t(41574),p=t(41942),f=t(13664),b=t(41477),g=t(75265),j=t(35068),v=t(10128),A=t(52619),w=t.n(A),y=t(46222),S=t(90854),C=t(36540),W=t(92265),z=t(29310),I=t(97617),E=t(320),k=t(21363),D=t(76541),B=t(29999),F=t(40150),O=t(95125);let R="loginFlowState",H=()=>{try{let e=window.sessionStorage.getItem(R);return e?JSON.parse(e):null}catch(e){return null}},M=()=>{window.sessionStorage.removeItem(R)};function U(e){let{...r}=e,{login:t}=(0,S.A)(),A=(0,C.A)(),[U,P]=(0,n.useState)(()=>{var e,r;return null!=(r=null==(e=H())?void 0:e.step)?r:"email"}),[T,N]=(0,n.useState)(()=>{var e,r;return null!=(r=null==(e=H())?void 0:e.email)?r:""}
1),[Y,q]=(0,n.useState)(()=>{var e,r;return null!=(r=null==(e=H())?void 0:e.selectedTenantId)?r:""}),[V,_]=(0,n.useState)(()=>{var e,r;return null!=(r=null==(e=H())?void 0:e.tenants)?r:[]}),[J,L]=(0,n.useState)(!1);(0,n.useEffect)(()=>{if("email"===U&&!T)return void M();try{window.sessionStorage.setItem(R,JSON.stringify({email:T,step:U,selectedTenantId:Y,tenants:V}))}catch(e){}},[T,U,Y,V]);let K=()=>{L(!J)},X=async e=>{try{var r;return(null!=(r=(await O.A.get("".concat("https://api.maraspace.ai","/users/p?u=").concat(encodeURIComponent(e)))).data.tenants)?r:[]).map(e=>{var r,t,o;return{publicId:null!=(r=e.publicId)?r:"",name:null!=(t=e.name)?t:"",avatarUrl:null!=(o=e.avatarUrl)?o:null,role:e.role||"Admin",domain:e.domain||"".concat((e.name||"tenant").toLowerCase().replace(/\s+/g,""),".metricly.app")}})}catch(e){throw console.error("Error fetching tenants:",e),e}},G=async e=>{try{let r=e.trim(),t=await X(r);if(0===t.length)throw Error("No tenants found for this email");N(r),_(t),q(t[0].publicId),P(1===t.length?"password":"tenant-selection")}catch(e){throw console.error(e),e}},Q=async e=>{localStorage.setItem("tenantPublicId",Y),await (null==t?void 0:t(T,e)),M()},Z=()=>{P("email"),_([])},$=()=>(0,o.jsx)(v.l1,{initialValues:{email:T||"",submit:null},validationSchema:j.Ik().shape({email:j.Yj().email("Must be a valid email").max(255).required("Email is required")}),onSubmit:async(e,r)=>{let{setErrors:t,setStatus:o,setSubmitting:n}=r;try{await G(e.email),n(!1)}catch(e){A.current&&(o({success:!1}),t({submit:e.message||"An error occurred"}),n(!1))}},children:e=>{let{errors:t,handleBlur:n,handleChange:s,handleSubmit:c,isSubmitting:p,touched:f,values:b}=e;return(0,o.jsxs)("form",{noValidate:!0,onSubmit:c,...r,children:[(0,o.jsx)(h.A,{variant:"h1",sx:{fontWeight:700,color:"#2C1B10",fontSize:{xs:"2.5rem",sm:"3rem",md:"3.5rem"},lineHeight:1.1,mb:2},children:"Hi, Welcome Back!"}),(0,o.jsx)(h.A,{variant:"body1",sx:{color:"text.secondary",fontSize:{xs:"0.9375rem",md:"1.05rem"},lineHeight:1.6,maxWidth:450,mb:4},children:"Enter your email to continue. We'll show you the workspaces tied to your account."}),(0,o.jsx)(h.A,{sx:{fontSize:"0.875rem",fontWeight:600,mb:1,color:"#2C1B10"},children:"Email Address"}),(0,o.jsx)(x.A,{fullWidth:!0,type:"email",value:b.email,name:"email",onBlur:n,onChange:s,autoFocus:!0,placeholder:"[email protected]",startAdornment:(0,o.jsx)(u.A,{position:"start",children:(0,o.jsx)(I.A,{sx:{color:"text.secondary",fontSize:20}})}),sx:{borderRadius:3,bgcolor:"white","& .MuiOutlinedInput-notchedOutline":{borderColor:"#E0D8D0",borderWidth:1.5},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"#2C1B10"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"#2C1B10"}}}),f.email&&t.email&&(0,o.jsx)(d.A,{error:!0,sx:{mt:1},children:t.email}),(0,o.jsx)(a.A,{in:!!t.submit,children:(0,o.jsx)(i.A,{severity:"error",variant:"outlined",sx:{mt:2},children:t.submit})}),(0,o.jsx)(m.default,{sx:{mt:3},children:(0,o.jsx)(y.A,{children:(0,o.jsx)(l.A,{disabled:p,fullWidth:!0,size:"large",type:"submit",variant:"contained",endIcon:!p&&(0,o.jsx)(k.A,{}),sx:{bgcolor:"#2C2318",borderRadius:2,py:1.5,fontWeight:600,fontSize:"1rem",textTransform:"uppercase","&:hover":{bgcolor:"#1A1510"}},children:p?"Loading...":"Next"})})})]})}});return(0,o.jsxs)(o.Fragment,{children:["email"===U&&$(),"tenant-selection"===U&&(0,o.jsxs)(m.default,{children:[$(),(0,o.jsx)(g.A,{open:"tenant-selection"===U,onClose:()=>P("email"),fullWidth:!0,maxWidth:"xs",PaperProps:{sx:{borderRadius:4,p:1,boxShadow:"0 8px 32px rgba(0,0,0,0.12)"}},children:(0,o.jsxs)(m.default,{sx:{p:2,position:"relative"},children:[(0,o.jsx)(c.A,{onClick:()=>P("email"),sx:{position:"absolute",right:8,top:8,color:"text.secondary"},children:(0,o.jsx)(B.A,{fontSize:"small"})}),(0,o.jsx)(h.A,{variant:"h3",sx:{fontWeight:700,mb:1,color:"#2C1B10"},children:"Choose a workspace"}),(0,o.jsxs)(h.A,{variant:"body2",sx:{color:"text.secondary",mb:3},children:["You belong to"," ",(0,o.jsxs)(m.default,{component:"span",sx:{fontWeight:700,color:"text.primary"},children:[V.length," workspaces"]}),". Pick the one to sign in to."]}),(0,o.jsx)(m.default,{sx:{maxHeight:400,overflowY:"auto",pr:1,mr:-1,"&::-webkit-scrollbar":{width:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"#E0D8D0",borderRadius:3,"&:hover":{bgcolor:"#C8BDB0"}}},children:(0,o.jsx)(p.A,{spacing:1.5,children:V.map(e=>(0,o.jsxs)(m.default,{onClick:()=>{q(e.publicId),P("password")},sx:{p:2,borderRadius:3,border:"1.5px solid #F3EFE9",display:"flex",alignItems:"center",gap:2,cursor:"pointer",transition:"all 0.2s ease","&:hover":{borderColor:"#2C1B10",bgcolor:"#FAF8F6",transform:"translateX(4px)"}},children:[(0,o.jsx)(s.A,{src:e.avatarUrl||void 0,sx:{bgcolor:"#E0D8D0",color:"#2C1B10",fontWeight:700,fontSize:"0.875rem",borderRadius:2},children:!e.avatarUrl&&e.name.substring(0,2).toUpperCase()}),(0,o.jsxs)(m.default,{sx:{flex:1},children:[(0,o.jsx)(h.A,{sx:{fontWeight:700,fontSize:"0.95rem",color:"#2C1B10"},children:e.name}),(0,o.jsxs)(h.A,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:[e.role," \xb7 ",e.domain]})]}),(0,o.jsx)(F.A,{sx:{color:"#E0D8D0"}})]},e.publicId))})}),(0,o.jsx)(p.A,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mt:3,pt:2,borderTop:"1.5px solid #F3EFE9"},children:(0,o.jsxs)(h.A,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:["Signed in as"," ",(0,o.jsx)(m.default,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:T})]})})]})})]}),"password"===U&&(()=>{let e=V.find(e=>e.publicId===Y),t=T.split("@")[0];return(0,o.jsx)(v.l1,{initialValues:{password:"",submit:null},validationSchema:j.Ik().shape({password:j.Yj().required("Password is required")}),onSubmit:async(e,r)=>{let{setErrors:t,setStatus:o,setSubmitting:n}=r;try{await Q(e.password),o({success:!0}),n(!1)}catch(e){console.log(e),A.current&&(o({success:!1}),t({submit:"The password you entered is incorrect."}),n(!1))}},children:n=>{var g;let{errors:j,handleBlur:v,handleChange:A,handleSubmit:S,isSubmitting:C,touched:I,values:k}=n;return(0,o.jsxs)("form",{noValidate:!0,onSubmit:S,...r,children:[(0,o.jsxs)(p.A,{direction:"row",alignItems:"center",onClick:Z,sx:{mb:2,cursor:"pointer",color:"text.secondary",display:"inline-flex",gap:.5,"&:hover":{color:"text.primary"}},children:[(0,o.jsx)(D.A,{sx:{fontSize:14}}),(0,o.jsx)(h.A,{sx:{fontSize:"0.75rem",fontWeight:600},children:"Use a different email"})]}),(0,o.jsxs)(h.A,{variant:"h1",sx:{fontWeight:700,color:"#2C1B10",fontSize:{xs:"2.5rem",sm:"3rem",md:"3.5rem"},lineHeight:1.1,mb:2},children:["Welcome back, ",t.charAt(0).toUpperCase()+t.slice(1),"."]}),(0,o.jsxs)(h.A,{variant:"body1",sx:{color:"text.secondary",fontSize:{xs:"0.9375rem",md:"1.05rem"},lineHeight:1.6,maxWidth:450,mb:4},children:["Enter your password to sign in to"," ",(0,o.jsx)(m.default,{component:"span",sx:{fontWeight:700,color:"text.primary"},children:null!=(g=null==e?void 0:e.name)?g:"your workspace"}),"."]}),(0,o.jsxs)(m.default,{sx:{p:2,borderRadius:2,border:"1.5px solid #F3EFE9",display:"flex",alignItems:"center",gap:2,mb:3},children:[(0,o.jsx)(s.A,{src:(null==e?void 0:e.avatarUrl)||void 0,sx:{bgcolor:"#6C63FF",color:"white",fontWeight:700,fontSize:"0.75rem",width:32,height:32,borderRadius:1},children:!(null==e?void 0:e.avatarUrl)&&(null==e?void 0:e.name.substring(0,2).toUpperCase())}),(0,o.jsxs)(m.default,{sx:{flex:1},children:[(0,o.jsx)(h.A,{sx:{fontWeight:600,fontSize:"0.875rem"},children:T}),(0,o.jsxs)(h.A,{sx:{fontSize:"0.75rem",color:"text.secondary"},children:[null==e?void 0:e.name," \xb7 ",null==e?void 0:e.role]})]}),V.length>1&&(0,o.jsx)(l.A,{onClick:()=>P("tenant-selection"),size:"small",sx:{textTransform:"none",color:"#2C1B10",fontWeight:600,border:"1px solid #E0D8D0",borderRadius:1.5,px:1.5},children:"Switch"})]}),(0,o.jsxs)(p.A,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[(0,o.jsx)(h.A,{sx:{fontSize:"0.875rem",fontWeight:600,color:"#2C1B10"},children:"Password"}),(0,o.jsx)(h.A,{component:w(),href:"/forgot-password",onMouseDown:e=>e.preventDefault(),sx:{fontSize:"0.75rem",fontWeight:600,color:"text.primary",textDecoration:"none","&:hover":{textDecoration:"underline"}},children:"Forgot?"})]}),(0,o.jsx)(x.A,{fullWidth:!0,type:J?"text":"password",value:k.password,name:"password",onBlur:v,onChange:A,autoFocus:!0,placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢",startAdornment:(0,o.jsx)(u.A,{position:"start",children:(0,o.jsx)(E.A,{sx:{color:"text.secondary",fontSize:20}})}),endAdornment:(0,o.jsx)(u.A,{position:"end",children:(0,o.jsx)(c.A,{onClick:K,size:"small",edge:"end",children:J?(0,o.jsx)(W.A,{fontSize:"small"}):(0,o.jsx)(z.A,{fontSize:"small"})})}),sx:{borderRadius:3,bgcolor:"white","& .MuiOutlinedInput-notchedOutline":{borderColor:"#E0D8D0",borderWidth:1.5},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"#2C1B10"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"#2C1B10"}}}),I.password&&j.password&&(0,o.jsx)(d.A,{error:!0,sx:{mt:1},children:j.password}),(0,o.jsx)(p.A,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{mt:1.5},children:(0,o.jsx)(b.A,{control:(0,o.jsx)(f.A,{size:"small",sx:{color:"#E0D8D0","&.Mui-checked":{color:"#2C1B10"}}}),label:(0,o.jsx)(h.A,{sx:{fontSize:"0.85rem",fontWeight:500},children:"Keep me signed in"})})}),(0,o.jsx)(a.A,{in:!!j.submit,children:(0,o.jsx)(i.A,{severity:"error",variant:"outlined",sx:{mt:2},children:j.submit})}),(0,o.jsx)(m.default,{sx:{mt:3},children:(0,o.jsx)(y.A,{children:(0,o.jsx)(l.A,{disabled:C,fullWidth:!0,size:"large",type:"submit",variant:"contained",sx:{bgcolor:"#2C2318",borderRadius:2,py:1.5,fontWeight:600,fontSize:"1rem",textTransform:"uppercase","&:hover":{bgcolor:"#1A1510"}},children:C?"Signing in...":"Sign in"})})})]})}})})()]})}},46222:(e,r,t)=>{t.d(r,{A:()=>s});var o=t(95155),n=t(68775),i=t(65678);function s(e){let r,t,{children:s,type:l="scale",direction:a="right",offset:d=10,scale:c={hover:1,tap:.9}}=e;switch(a){case"up":case"left":r=d,t=0;break;default:r=0,t=d}let[u,x]=(0,n.Y)(r,t),[h,m]=(0,n.Y)(r,t);switch(l){case"rotate":return(0,o.jsx)(i.P.div,{animate:{rotate:360},transition:{repeat:1/0,repeatType:"loop",duration:2,repeatDelay:0},children:s});case"slide":if("up"===a||"down"===a)return(0,o.jsx)(i.P.div,{animate:{y:void 0!==h?h:""},onHoverEnd:()=>m(),onHoverStart:()=>m(),children:s});return(0,o.jsx)(i.P.div,{animate:{x:void 0!==u?u:""},onHoverEnd:()=>x(),onHoverStart:()=>x(),children:s});default:return"number"==typeof c&&(c={hover:c,tap:c}),(0,o.jsx)(i.P.div,{whileHover:{scale:null==c?void 0:c.hover},whileTap:{scale:null==c?void 0:c.tap},children:s})}}}}]);
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.