(window.webpackJsonp=window.webpackJsonp||[]).push([[7],{1436:function(e,t,a){"use strict";a.r(t),a.d(t,"default",(function(){return b}));var n=a(1),r=a.n(n),s=a(0),c=a.n(s),i=a(3),o=a(7),u=a(2),l=a(268),p=a(38),h=a(33),d=a(59),k=function(e){return e.BackingUp="backing_up",e.Done="done",e}(k||{});class b extends c.a.PureComponent{constructor(e){super(e),r()(this,"createBackup",(async()=>{let e;this.setState({error:void 0});const t=o.a.safeGet();try{await Object(l.b)((async()=>{e=await t.prepareKeyBackupVersion(null,{secureSecretStorage:!0}),e=await t.createKeyBackupVersion(e)})),await t.scheduleAllGroupSessionsForBackup(),this.setState({phase:k.Done})}catch(n){var a;i.a.error("Error creating key backup",n),null!==(a=e)&&void 0!==a&&a.version&&t.deleteKeyBackupVersion(e.version),this.setState({error:!0})}})),r()(this,"onCancel",(()=>{this.props.onFinished(!1)})),r()(this,"onDone",(()=>{this.props.onFinished(!0)})),this.state={phase:k.BackingUp,passPhrase:"",passPhraseValid:!1,passPhraseConfirm:"",copied:!1,downloaded:!1}}componentDidMount(){this.createBackup()}renderBusyPhase(){return c.a.createElement("div",null,c.a.createElement(p.a,null))}renderPhaseDone(){return c.a.createElement("div",null,c.a.createElement("p",null,Object(u.b)("Your keys are being backed up (the first backup could take a few minutes).")),c.a.createElement(d.a,{primaryButton:Object(u.b)("OK"),onPrimaryButtonClick:this.onDone,hasCancel:!1}))}titleForPhase(e){switch(e){case k.BackingUp:return Object(u.b)("Starting backup…");case k.Done:return Object(u.b)("Success!");default:return Object(u.b)("Create key backup")}}render(){let e;if(this.state.error)e=c.a.createElement("div",null,c.a.createElement("p",null,Object(u.b)("Unable to create key backup")),c.a.createElement(d.a,{primaryButton:Object(u.b)("Retry"),onPrimaryButtonClick:this.createBackup,hasCancel:!0,onCancel:this.onCancel}));else switch(this.state.phase){case k.BackingUp:e=this.renderBusyPhase();break;case k.Done:e=this.renderPhaseDone()}return c.a.createElement(h.a,{className:"mx_CreateKeyBackupDialog",onFinished:this.props.onFinished,title:this.titleForPhase(this.state.phase),hasCancel:[k.Done].includes(this.state.phase)},c.a.createElement("div",null,e))}}}}]);
//# sourceMappingURL=7.js.map