"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["app/login/recovery-password"],{2612:(e,t,s)=>{s.r(t),s.d(t,{default:()=>u});var n=s(93),i=s(271),o=s(270),r=s(272),a=s.n(r),l=s(89),c=s(1055),d=s(548);class p extends o.Component{constructor(e){if(super(e),(0,n.default)(this,"state",{recoveryLink:"",recoveryEmail:"",isActionInProgress:!1,isDialogOpen:!1,sendButtonState:"active"}),(0,n.default)(this,"handleAction",(()=>{if(this.state.isActionInProgress)return;if(this.state.recoveryLink)return void this.setState({isDialogOpen:!0});this.setState({isActionInProgress:!0});const{userType:e,userId:t}=this.props;l.api.post((0,l.prepareUrl)(`${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}):location.reload()}))})),(0,n.default)(this,"handleSend",(()=>{if("active"!==this.state.sendButtonState)return;this.setState({sendButtonState:"loading"});const{messages:e}=this.props,{userType:t,userId:s}=this.props;l.api.post((0,l.prepareUrl)(`${this.endpoint}/send-secret`),{userType:t,userId:s,secret:this.state.recoveryLink}).then((t=>{"success"===t.status?(this.setState({isDialogOpen:!1}),(0,l.clearStatusMessages)(),(0,l.addStatusMessage)("info",e.linkSendedMessage),this.setState({sendButtonState:"active",recoveryLink:null})):location.reload()}))})),(0,n.default)(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,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.Action,{onClick:this.handleAction,progress:this.state.isActionInProgress,children:(0,o.jsx)(i.Translate,{content:"action"})}),(0,o.jsxs)(i.Dialog,{isOpen:this.state.isDialogOpen,buttons:[this.state.recoveryEmail?(0,o.jsx)(i.Button,{intent:"primary",onClick:this.handleSend,state:this.state.sendButtonState,children:(0,o.jsx)(i.Translate,{content:"sendButton"})},"sendButton"):null],title:(0,o.jsx)(i.Translate,{content:"title"}),cancelTitle:(0,o.jsx)(i.Translate,{content:"closeButton"}),onClose:this.handleClose,children:[this.state.recoveryEmail?(0,o.jsx)(i.Paragraph,{children:(0,o.jsx)(i.Translate,{content:"text",params:{email:(0,o.jsx)(i.Text,{bold:!0,children:this.state.recoveryEmail})}})}):null,(0,o.jsx)(i.Alert,{children:(0,o.jsxs)(i.Columns,{children:[(0,o.jsx)(i.Column,{fill:!0,children:this.state.recoveryLink}),(0,o.jsx)(i.Column,{children:(0,o.jsx)(c.default,{content:this.state.recoveryLink||"",onCopy:()=>(0,d.addToast)({intent:"success",message:l.Locale.getSection("components.buttons").lmsg("copied")})})})]})})]})]})}}p.propTypes={messages:a().object.isRequired,userType:a().number.isRequired,userId:a().number.isRequired};const u=p},2611:(e,t,s)=>{s.r(t),s.d(t,{default:()=>a});var n=s(271),i=s(270),o=s(89),r=s(2612);const a=({renderTo:e,...t})=>{const s=o.Locale.getSection("components.login.recovery-password").messages;(0,i.render)((0,i.jsx)(n.LocaleProvider,{messages:s,children:(0,i.jsx)(r.default,{messages:s,...t})}),document.getElementById(e))}},1055:(e,t,s)=>{s.r(t),s.d(t,{default:()=>d});var n=s(271),i=s(89),o=s(272),r=s.n(o),a=s(270);const l=i.Locale.getSection("components.buttons"),c=({id:e,content:t,icon:s="copy",className:i,tooltip:o=l.lmsg("copyToClipboard"),onCopy:r=()=>{},children:c})=>(0,a.jsx)(n.Button,{className:i,ghost:!0,icon:s,tooltip:o,onClick:()=>{(0,n.copyToClipboard)(t),r()},"data-action":"copy-to-clipboard"+(e?`-${e}`:""),children:c});c.propTypes={id:r().string,content:r().string.isRequired,className:r().string,icon:r().oneOfType([r().node,r().string,r().object]),tooltip:r().oneOfType([r().string,r().node]),onCopy:r().func,children:r().node};const d=c}}]);
//# sourceMappingURL=recovery-password.js.map?5038fea7407fd9545004