(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["app/login/recovery-password"],{1095:(e,t,s)=>{"use strict";s.r(t);var n=s(148),r=s.n(n),i=s(155),a=s(154),o=s(261),l=s.n(o),c=s(144);class p extends a.Component{constructor(e){if(super(e),r()(this,"state",{recoveryLink:"",recoveryEmail:"",isActionInProgress:!1,isDialogOpen:!1,sendButtonState:"active"}),r()(this,"recoveryLinkContainer",(0,a.createRef)()),r()(this,"setLinkSelection",(()=>{setTimeout((()=>{try{const e=document.createRange();e.selectNode(this.recoveryLinkContainer.current);const t=window.getSelection();t.removeAllRanges(),t.addRange(e)}catch(e){}}),200)})),r()(this,"handleAction",(()=>{if(this.state.isActionInProgress)return;if(this.state.recoveryLink)return this.setState({isDialogOpen:!0}),void this.setLinkSelection();this.setState({isActionInProgress:!0});const{userType:e,userId:t}=this.props;c.api.post((0,c.prepareUrl)("".concat(this.endpoint,"/generate-secret")),{userType:e,userId:t}).then((e=>{"success"===e.status?(this.setState({recoveryLink:e.link,recoveryEmail:e.email,isActionInProgress:!1,isDialogOpen:!0}),this.setLinkSelection()):location.reload()}))})),r()(this,"handleSend",(()=>{if("active"!==this.state.sendButtonState)return;this.setState({sendButtonState:"loading"});const{messages:e}=this.props,{userType:t,userId:s}=this.props;c.api.post((0,c.prepareUrl)("".concat(this.endpoint,"/send-secret")),{userType:t,userId:s,secret:this.state.recoveryLink}).then((t=>{"success"===t.status?(this.setState({isDialogOpen:!1}),(0,c.clearStatusMessages)(),(0,c.addStatusMessage)("info",e.linkSendedMessage),this.setState({sendButtonState:"active",recoveryLink:null})):location.reload()}))})),r()(this,"handleClose",(()=>{this.setState({isDialogOpen:!1,recoveryLink:null})})),2===this.props.userType)this.endpoint="/admin/reseller";else if(4===this.props.userType)this.endpoint="/admin/customer";else if(8===this.props.userType)this.endpoint="/smb/user";else{if(32!==this.props.userType)throw new Error("Unexpected user type.");this.endpoint="/smb/email-address"}}render(){return(0,a.createElement)(a.Fragment,null,(0,a.createElement)(i.Action,{onClick:this.handleAction,progress:this.state.isActionInProgress},(0,a.createElement)(i.Translate,{content:"action"})),(0,a.createElement)(i.Dialog,{isOpen:this.state.isDialogOpen,buttons:[this.state.recoveryEmail?(0,a.createElement)(i.Button,{key:"sendButton",intent:"primary",onClick:this.handleSend,state:this.state.sendButtonState},(0,a.createElement)(i.Translate,{content:"sendButton"})):null],title:(0,a.createElement)(i.Translate,{content:"title"}),cancelTitle:(0,a.createElement)(i.Translate,{content:"closeButton"}),onClose:this.handleClose},this.state.recoveryEmail?(0,a.createElement)(i.Paragraph,null,(0,a.createElement)(i.Translate,{content:"text",params:{email:(0,a.createElement)(i.Text,{bold:!0},this.state.recoveryEmail)}})):null,(0,a.createElement)(i.Alert,null,(0,a.createElement)("span",{ref:this.recoveryLinkContainer},this.state.recoveryLink))))}}p.propTypes={messages:l().object.isRequired,userType:l().number.isRequired,userId:l().number.isRequired},t.default=p},1094:(e,t,s)=>{"use strict";s.r(t);var n=s(153),r=s.n(n),i=s(155),a=s(154),o=s(144),l=s(1095);t.default=({renderTo:e,...t})=>{const s=o.Locale.getSection("components.login.recovery-password").messages;(0,a.render)((0,a.createElement)(i.LocaleProvider,{messages:s},(0,a.createElement)(l.default,r()({messages:s},t))),document.getElementById(e))}}}]);
//# sourceMappingURL=recovery-password.js.map?8ad1abe052824494ea5d