(self.webpackChunkcarbonio_login_ui=self.webpackChunkcarbonio_login_ui||[]).push([[283],{5283:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>te});var n=a(9713),r=a.n(n),o=a(3038),i=a.n(o),l=a(7294),s=a(9163),c=a(8249),u=a(6486),d=a(4478);const m=a.p+"assets/c201cd88dd8ac881fb5116d6e523f6c0.svg",g=a.p+"assets/4692c32b7a3da0c90b16af9b4c511dc5.svg",p=a.p+"assets/bf91cbb0a8890f791877c30804d22033.svg",f=a.p+"assets/af8f8b8de3c2c64dd9e0e26f9e326c76.svg",h=a.p+"assets/37914751a841e5bada7088f083ebe8f1.svg",b=a.p+"assets/38bfc573882a13cd65849d7c094d4ad3.svg",w=a.p+"assets/21fac676d4a152cb019e995ec686929c.svg",v=a.p+"assets/eeb6651c4b148221c44b8ec5a66a5906.jpg",E=a.p+"assets/634f498ae039e36b1ba83ec6c271d756.jpg",x=a.p+"assets/a26591c262737d3a125010c0f7531ce5.png";var y=a(8313),k=a(7757),C=a.n(k),_=a(8926),S=a.n(_);function P(e){var t=e.open,a=e.onClose,n=(0,d.$)(),r=i()(n,1)[0];return l.createElement(c.u_,{title:"Offline",open:t,onClose:a},l.createElement(c.nv,null,r("offline","You are currently offline, please check your internet connection")))}var I=s.default.svg.withConfig({displayName:"spinner__StyledSpinner",componentId:"sc-7h2tc3-0"})(["animation:rotate 2s linear infinite;margin:-25px 0 0 -25px;width:50px;height:50px;& .path{stroke:#0000FF;animation:dash 1.5s ease-in-out infinite;}@keyframes rotate{100%{transform:rotate(360deg);}}@keyframes dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0;}50%{stroke-dasharray:90,150;stroke-dashoffset:-35;}100%{stroke-dasharray:90,150;stroke-dashoffset:-124;}}"]);function O(){return l.createElement(I,{viewBox:"0 0 50 50"},l.createElement("circle",{className:"path",cx:"25",cy:"25",r:"20",fill:"none",strokeWidth:"4"}))}var U=a(1153),j=a(2211),A=a(5941),L=new URLSearchParams(window.location.search);function X(e){var t=e.authError,a=e.submitCredentials,n=e.configuration,r=e.disableInputs,o=e.loading,s=void 0!==o&&o,u=(0,d.$)(),m=i()(u,1)[0],g=(0,U.k6)(),p=(0,l.useState)(L.get("username")||""),f=i()(p,2),h=f[0],b=f[1],w=(0,l.useState)(""),v=i()(w,2),E=v[0],x=v[1],y=(0,l.useMemo)((function(){return[{label:"Classic",value:"classic"},{label:"Iris",value:"iris"}]}),[]),k=(0,l.useMemo)((function(){return y.find((function(e){return e.value===(L.get("ui")||j.HU)}))}),[]),C=(0,l.useCallback)((function(e){if(e.preventDefault(),h&&E){var t=h;L.has("virtualacctdomain")?t="".concat(t.replace("@","."),"@").concat(L.get("virtualacctdomain")):L.has("customerDomain")&&!h.includes("@")&&(t="".concat(t.trim(),"@").concat(L.get("customerDomain"))),a(t,E)}}),[h,E,a]),_=(0,l.useCallback)((function(){window.location.assign("/zx/auth/startSamlWorkflow?redirectUrl=".concat((0,A.BR)(n.destinationUrl,n.hasIris)))}),[n]),S=(0,l.useMemo)((function(){return n.authMethods.includes("saml")?l.createElement(c.zx,{type:"outlined",label:m("login_saml","Login SAML"),color:"primary",disabled:r,onClick:_}):l.createElement("div",{style:{minHeight:"20px"}})}),[n,r,_,m]),P=(0,l.useCallback)((function(e){return b(e.target.value)}),[b]),I=(0,l.useCallback)((function(e){return x(e.target.value)}),[x]);return l.createElement("form",{onSubmit:C,style:{width:"100%"}},l.createElement("input",{type:"submit",style:{display:"none"}}),l.createElement(c.X2,{padding:{bottom:"large"}},l.createElement(c.II,{defaultValue:h,disabled:r,onChange:P,hasError:!!t,autocomplete:"username",label:m("username","Username"),backgroundColor:"gray5"})),l.createElement(c.X2,{padding:{bottom:"small"}},l.createElement(c.WU,{defaultValue:E,disabled:r,onChange:I,hasError:!!t,autocomplete:"password",label:m("password","Password"),backgroundColor:"gray5"})),n.hasIris&&l.createElement(c.X2,{padding:{vertical:"small"}},l.createElement(c.Ph,{label:m("select_ui","Select UI"),items:y,onChange:function(e){var t=new URLSearchParams(g.location.search);t.set("ui",e),g.replace({search:t.toString()})},defaultSelection:k})),l.createElement(c.xv,{color:"error",size:"medium",overflow:"break-word"},t||l.createElement("br",null)),l.createElement(c.X2,{orientation:"vertical",crossAlignment:"flex-start",padding:{bottom:"large",top:"small"}},l.createElement(c.zx,{loading:s,onClick:C,disabled:r,label:m("login","Login"),size:"fill"})),l.createElement(c.X2,{mainAlignment:"flex-end",padding:{bottom:"extralarge"}},S))}function T(e){var t=e.configuration,a=e.disableInputs,n=(0,d.$)(),r=i()(n,1)[0],o=(0,l.useState)(!1),s=i()(o,2),u=s[0],m=s[1],g=(0,l.useState)("credentials"),p=i()(g,2),f=p[0],h=(p[1],(0,l.useState)()),b=i()(h,2),w=b[0],v=b[1],E=(0,l.useState)(!1),x=i()(E,2),y=x[0],k=x[1],_=(0,l.useState)(!1),I=i()(_,2),U=I[0],j=I[1],L=(0,l.useCallback)((function(e,a){return m(!0),function(e,t,a,n){return fetch("/zx/auth/v1/login",{method:"POST",headers:{"X-Device-Model":(0,A.fj)(),"X-Device-Id":(0,A.yx)(),"X-Service":"webUI","Content-Type":"application/json"},body:JSON.stringify({auth_method:"password",user:t,password:a})})}(0,e,a).then(function(){var n=S()(C().mark((function n(o){return C().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:n.t0=o.status,n.next=200===n.t0?3:401===n.t0?7:403===n.t0?10:13;break;case 3:return n.next=5,(0,A.Pg)(e,a);case 5:return window.location.assign((0,A.BR)(t.destinationUrl,t.hasIris)),n.abrupt("break",15);case 7:return v(r("credentials_not_valid","Credentials are not valid, please check data and try again")),m(!1),n.abrupt("break",15);case 10:return v(r("auth_not_valid","The authentication policy needs more steps: please contact your administrator for more information")),m(!1),n.abrupt("break",15);case 13:k(!0),m(!1);case 15:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}()).catch((function(){return m(!1)}))}),[t.destinationUrl]),T=(0,l.useCallback)((function(){return j(!1)}),[j]),z=(0,l.useCallback)((function(){return j(!0)}),[j]),D=(0,l.useCallback)((function(){return k(!1)}),[k]);return l.createElement(l.Fragment,null,"credentials"===f&&l.createElement(X,{configuration:t,disableInputs:a,authError:w,submitCredentials:L,loading:u}),"waiting"===f&&l.createElement(c.X2,{orientation:"vertical",crossAlignment:"center",padding:{vertical:"extralarge"}},l.createElement(O,null)),l.createElement(c.A9,{open:y,label:r("cant_login","Can not do the login now"),actionLabel:r("details","Details"),onActionClick:z,onClose:D,autoHideTimeout:1e4,type:"error"}),l.createElement(P,{open:U,onClose:T}))}const z=function(e){var t=e.isLoading,a=e.setIsLoading,n=e.username,r=e.configuration,o=(0,d.$)(),s=i()(o,1)[0],u=(0,l.useState)(""),m=i()(u,2),g=m[0],p=m[1],f=(0,l.useState)(""),h=i()(f,2),b=h[0],w=h[1],v=(0,l.useState)(""),E=i()(v,2),x=E[0],y=E[1],k=(0,l.useState)(!1),_=i()(k,2),P=_[0],I=_[1],O=(0,l.useState)(!1),U=i()(O,2),L=U[0],X=U[1],T=(0,l.useState)(""),z=i()(T,2),D=z[0],B=z[1],R=(0,l.useCallback)((function(e){return p(e.target.value)}),[p]),F=(0,l.useCallback)((function(e){return w(e.target.value)}),[w]),V=(0,l.useCallback)((function(e){return y(e.target.value)}),[y]);(0,l.useEffect)((function(){X(""),B("")}),[b,s]),(0,l.useEffect)((function(){B(b&&x!==b?s("changePassword_error_confirmPassword","Confirm password not valid"):"")}),[x,b,s]);var W=(0,l.useCallback)((function(e){e.preventDefault(),a(!0),b&&x===b&&!L&&function(e,t,a){return fetch("/service/soap/ChangePasswordRequest",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({Body:{ChangePasswordRequest:{_jsns:"urn:zimbraAccount",csrfTokenSecured:"1",persistAuthTokenCookie:"1",account:{by:"name",_content:e},oldPassword:{_content:t},password:{_content:a},prefs:[{pref:{name:"zimbraPrefMailPollingInterval"}}]}}})})}(n,g,b).then(function(){var e=S()(C().mark((function e(t){var o,i,l,c,u,d,m,g,p,f,h,w;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:m=e.sent,g=(0,A.BR)(r.destinationUrl,r.hasIris),200===t.status&&(p=m.Body.ChangePasswordResponse.authToken,(f=p&&p.length>0?p[0]._content:void 0)&&(0,A.d8)(j.uQ,f)),e.t0=t.status,e.next=200===e.t0?8:401===e.t0||500===e.t0?12:41;break;case 8:return e.next=10,(0,A.Pg)(n,b);case 10:return window.location.assign(g),e.abrupt("break",44);case 12:if((null===(o=m.Body.Fault)||void 0===o||null===(i=o.Detail)||void 0===i||null===(l=i.Error)||void 0===l?void 0:l.Code)!==j.oT){e.next=39;break}if(I(!1),h=m.Body.Fault.Detail.Error.a,!(w=h?h.find((function(e){return e.n===j.sD})):void 0)){e.next=19;break}return X(s("changePassword_error_maxLength",{defaultValue:"Maximum length is {{num}} characters",replace:{num:w._content}})),e.abrupt("break",44);case 19:if(!(w=h?h.find((function(e){return e.n===j.PB})):void 0)){e.next=23;break}return X(s("changePassword_error_minLength",{defaultValue:"Minimum length is {{num}} characters",replace:{num:w._content}})),e.abrupt("break",44);case 23:if(!(w=h?h.find((function(e){return e.n===j.M$})):void 0)){e.next=27;break}return X(s("changePassword_error_minLowerCaseChars",{defaultValue:"Expecting at least {{num}} lowercase characters",replace:{num:w._content}})),e.abrupt("break",44);case 27:if(!(w=h?h.find((function(e){return e.n===j.Wo})):void 0)){e.next=31;break}return X(s("changePassword_error_minNumericChars",{defaultValue:"Expecting at least {{num}} numeric characters",replace:{num:w._content}})),e.abrupt("break",44);case 31:if(!(w=h?h.find((function(e){return e.n===j.mF})):void 0)){e.next=35;break}return X(s("changePassword_error_minPunctuationChars",{defaultValue:"Expecting at least {{num}} punctuation characters",replace:{num:w._content}})),e.abrupt("break",44);case 35:(w=h?h.find((function(e){return e.n===j.i_})):void 0)&&X(s("changePassword_error_minUppercaseChars",{defaultValue:"Expecting at least {{num}} uppercase characters",replace:{num:w._content}})),e.next=40;break;case 39:(null===(c=m.Body.Fault)||void 0===c||null===(u=c.Detail)||void 0===u||null===(d=u.Error)||void 0===d?void 0:d.Code)===j.SX?(I(!1),X(s("changePassword_error_passwordRecentlyUsed",{defaultValue:"Password recently used"}))):(I(!0),X(""));case 40:return e.abrupt("break",44);case 41:I(!1),X(s("changePassword_error_minLowerCaseChars",{defaultValue:"Expecting at least {{num}} lowercase characters",replace:{num:6}})),a(!1);case 44:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).catch((function(e){a(!1),e.message.startsWith("authentication failed")&&(I(!0),X(""))})),a(!1)}),[a,b,x,L,n,g,r.destinationUrl,r.hasIris,s]);return l.createElement("form",{onSubmit:W,style:{width:"100%",height:"auto",maxHeight:"unset"}},l.createElement("input",{type:"submit",style:{display:"none"}}),l.createElement(c.X2,{padding:{bottom:"large"}},l.createElement(c.xv,{size:"large",color:"text",weight:"bold"},s("changePassword_title","Create a new password"))),l.createElement(c.X2,{padding:{top:"large"}},l.createElement(c.II,{defaultValue:n,disabled:!0,label:"Email"})),l.createElement(c.X2,{padding:{top:"large"}},l.createElement(c.WU,{defaultValue:g,hasError:P,onChange:R,label:s("changePassword_oldPassword","Old password"),backgroundColor:"gray5"})),P&&l.createElement(c.X2,{padding:{top:"extrasmall"},mainAlignment:"flex-start"},l.createElement(c.xv,{color:"error",size:"medium",overflow:"break-word"},s("wrong_password","Wrong password, please check data and try again"))),l.createElement(c.X2,{padding:{top:"large"}},l.createElement(c.WU,{defaultValue:b,hasError:L,onChange:F,label:s("changePassword_newPassword","New password"),backgroundColor:"gray5"})),L&&l.createElement(c.X2,{padding:{top:"extrasmall"},mainAlignment:"flex-start"},l.createElement(c.xv,{color:"error",size:"medium",overflow:"break-word"},L)),l.createElement(c.X2,{padding:{top:"large"}},l.createElement(c.WU,{defaultValue:x,hasError:D,onChange:V,label:s("changePassword_confirmNewPassword","Confirm new password"),backgroundColor:"gray5"})),D&&l.createElement(c.X2,{padding:{top:"extrasmall"},mainAlignment:"flex-start"},l.createElement(c.xv,{color:"error",size:"medium",overflow:"break-word"},D)),l.createElement(c.X2,{orientation:"vertical",crossAlignment:"flex-start",padding:{vertical:"medium"}},l.createElement(c.zx,{onClick:W,label:s("changePassword_confirm_label","Change password and login"),size:"fill",loading:t,disabled:!b||x!==b||L})))};var D="credentials",B="two-factor",R="change-password";function F(e){var t=e.configuration,a=e.disableInputs,n=(0,d.$)(),r=i()(n,1)[0],o=(0,l.useState)(!1),s=i()(o,2),m=s[0],g=s[1],p=(0,l.useState)(!1),f=i()(p,2),h=f[0],b=f[1],w=(0,l.useState)(D),v=i()(w,2),E=v[0],x=v[1],y=(0,l.useState)(!1),k=i()(y,2),_=k[0],I=k[1],U=(0,l.useState)(!1),j=i()(U,2),L=j[0],T=j[1],F=(0,l.useState)([]),V=i()(F,2),W=V[0],M=V[1],N=(0,l.useState)(""),Z=i()(N,2),$=Z[0],H=Z[1],q=(0,l.useState)(""),J=i()(q,2),Y=J[0],G=J[1],Q=(0,l.useCallback)((function(e){G(e.target.value)}),[G]),K=(0,l.useState)(!1),ee=i()(K,2),te=ee[0],ae=ee[1],ne=(0,l.useCallback)((function(){return ae((function(e){return!e}))}),[ae]),re=(0,l.useState)(""),oe=i()(re,2),ie=oe[0],le=oe[1],se=(0,l.useState)(!1),ce=i()(se,2),ue=ce[0],de=ce[1],me=(0,l.useState)(!1),ge=i()(me,2),pe=ge[0],fe=ge[1],he=(0,l.useState)(!1),be=i()(he,2),we=be[0],ve=be[1],Ee=(0,l.useCallback)((function(e,a){return g(!0),function(e,t,a,n){return fetch("/zx/auth/v2/login",{method:"POST",headers:{"X-Device-Model":(0,A.fj)(),"X-Device-Id":(0,A.yx)(),"X-Service":"WebUI","Content-Type":"application/json"},body:JSON.stringify({auth_method:"password",user:t,password:a})})}(0,e,a).then((function(n){switch(n.status){case 200:le(e),n.redirected?x(R):n.json().then(function(){var n=S()(C().mark((function n(r){var o,i,l;return C().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,(0,A.Pg)(e,a);case 2:!0===(null==r?void 0:r["2FA"])?(M((0,u.map)(null!==(o=null==r?void 0:r.otp)&&void 0!==o?o:[],(function(e){return{label:e.label,value:e.id}}))),H(null==r||null===(i=r.otp)||void 0===i?void 0:i[0].id),x(B),g(!1)):(l=(0,A.BR)(t.destinationUrl,t.hasIris),window.location.assign(l));case 3:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}());break;case 401:case 403:I(r("credentials_not_valid","Credentials are not valid, please check data and try again")),g(!1);break;default:fe(!0),g(!1)}})).catch((function(){return g(!1)}))}),[t.destinationUrl]),xe=(0,l.useCallback)((function(e){e.preventDefault(),b(!0),function(e,t,a){return fetch("/zx/auth/v2/otp/validate",{method:"POST",headers:{"X-Device-Model":(0,A.fj)(),"X-Device-Id":(0,A.yx)(),"X-Service":"WebUI","Content-Type":"application/json",version:"2"},body:JSON.stringify({id:e,code:t,unsecure_device:!a})})}($,Y,te).then((function(e){200===e.status?e.redirected?x(R):window.location.assign((0,A.BR)(t.destinationUrl,t.hasIris)):(b(!1),T(!0))})).catch((function(){return b(!1)}))}),[$,Y,te,t.destinationUrl]),ye=(0,l.useCallback)((function(){return ve(!1)}),[ve]),ke=(0,l.useCallback)((function(){return ve(!0)}),[ve]),Ce=(0,l.useCallback)((function(){return fe(!1)}),[fe]);return l.createElement(l.Fragment,null,E===D&&l.createElement(X,{configuration:t,disableInputs:a,authError:_,submitCredentials:Ee,loading:m}),"waiting"===E&&l.createElement(c.X2,{orientation:"vertical",crossAlignment:"center",padding:{vertical:"extralarge"}},l.createElement(O,null)),E===B&&l.createElement("form",{onSubmit:xe,style:{width:"100%"}},l.createElement("input",{type:"submit",style:{display:"none"}}),l.createElement(c.X2,{padding:{bottom:"large"}},l.createElement(c.xv,{size:"large",color:"text",weight:"bold"},r("two_step_authentication","Two-Step-Authentication"))),l.createElement(c.X2,{padding:{top:"large"}},l.createElement(c.Ph,{items:W,background:"gray5",label:r("choose_otp","Choose the OTP Method"),onChange:H,defaultSelection:W[0]})),l.createElement(c.X2,{padding:{top:"large"}},l.createElement(c.II,{defaultValue:Y,hasError:L,disabled:a,onChange:Q,label:r("type_otp","Type here One-Time-Password"),backgroundColor:"gray5"})),l.createElement(c.X2,{padding:{top:"extrasmall"},mainAlignment:"flex-start"},l.createElement(c.xv,{color:"error",size:"medium",overflow:"break-word"},L&&r("wrong_password","Wrong password, please check data and try again"),!L&&l.createElement("br",null))),l.createElement(c.X2,{orientation:"vertical",crossAlignment:"flex-start",padding:{vertical:"small"}},l.createElement(c.zx,{onClick:xe,disabled:a,label:r("login","Login"),size:"fill",loading:h})),l.createElement(c.X2,{mainAlignment:"flex-start"},l.createElement(c.XZ,{value:te,label:r("trust_device_and_ip","Trust this device and IP address"),onClick:ne}))),E===R&&l.createElement(z,{isLoading:ue,setIsLoading:de,configuration:t,username:ie}),l.createElement(c.A9,{open:pe,label:r("cant_login","Can not do the login now"),actionLabel:r("details","Details"),onActionClick:ke,onClose:Ce,autoHideTimeout:1e4,type:"error"}),l.createElement(P,{open:we,onClose:ye}))}function V(){var e=(0,d.$)(),t=i()(e,1)[0],a=(0,l.useState)(!0),n=i()(a,2),r=n[0],o=n[1],s=(0,l.useCallback)((function(){return o(!1)}),[]);return l.createElement(c.A9,{open:r,label:t("server_not_responding","The server is not responding. Please contact your server administrator"),onClose:s,autoHideTimeout:1e4,type:"error"})}var W=a(6227);function M(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function N(e){for(var t=1;t=2&&s.minApiVersion<=2?l.createElement(F,{configuration:s,disableInputs:h}):s.maxApiVersion>=1&&s.minApiVersion<=1?l.createElement(T,{configuration:s,disableInputs:h}):l.createElement(W.Z,null):l.createElement("div",null)}function $(e){var t=e.destinationUrl,a=e.hasIris,n=(0,d.$)().t,r=(0,l.useState)(),o=i()(r,2),s=o[0],c=o[1],u=(0,l.useState)(!1),m=i()(u,2),g=m[0],p=m[1],f=(0,l.useCallback)((function(e,r){return p(!0),function(e,t){return fetch("/service/soap/AuthRequest",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({Body:{AuthRequest:{_jsns:"urn:zimbraAccount",csrfTokenSecured:"1",persistAuthTokenCookie:"1",generateDeviceId:"1",account:{by:"name",_content:e},password:{_content:t},prefs:[{pref:{name:"zimbraPrefMailPollingInterval"}}]}}})})}(e,r).then(function(){var e=S()(C().mark((function e(r){var o;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.json();case 2:if(!(o=e.sent).Body.Fault){e.next=5;break}throw new Error(o.Body.Fault.Reason.Text);case 5:e.t0=r.status,e.next=200===e.t0?8:401===e.t0||500===e.t0?10:403===e.t0?13:16;break;case 8:return window.location.assign(t||(0,A.BR)(window.location.href,a)),e.abrupt("break",17);case 10:case 13:return c(n("credentials_not_valid","Credentials are not valid, please check data and try again")),p(!1),e.abrupt("break",17);case 16:p(!1);case 17:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).catch((function(e){p(!1),e.message.startsWith("authentication failed")?c(n("credentials_not_valid","Credentials are not valid, please check data and try again")):c(e.message)}))}),[a]);return l.createElement(X,{configuration:{destinationUrl:t,authMethods:["zimbra"],hasIris:a},disableInputs:!1,authError:s,submitCredentials:f,loading:g})}function H(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function q(e){for(var t=1;t