"use strict";(self.webpackChunk_bitwarden_web_vault=self.webpackChunk_bitwarden_web_vault||[]).push([[505],{31505:(e,t,i)=>{i.r(t),i.d(t,{MigrateFromLegacyEncryptionComponent:()=>M});var r=i(51757),n=i(72245),o=i(7861),s=i(83516),c=i(39488),a=i(22848),u=i(25065),l=i(62600),d=i(77186),y=i(56111),p=i(35500),h=i(50700),m=i(56962),b=i(69855),f=i(21274),w=i(49519),v=i(41103),g=i(26657),S=i(45154),k=i(56898),U=i(44432),F=i(86226),E=i(97553),T=i(43759),I=i(76356),R=i(69896),x=i(36288),G=i(58806),X=i(88016),B=function(e,t,i,r){return new(i||(i=Promise))((function(n,o){function s(e){try{a(r.next(e))}catch(t){o(t)}}function c(e){try{a(r.throw(e))}catch(t){o(t)}}function a(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))};class M{constructor(e,t,i,s,c,a,u,l,d,y){this.accountService=e,this.keyRotationService=t,this.i18nService=i,this.keyService=s,this.messagingService=c,this.logService=a,this.syncService=u,this.toastService=l,this.dialogService=d,this.folderApiService=y,this.formGroup=new r.gE({masterPassword:new r.MJ("",[r.k0.required])}),this.submit=()=>B(this,void 0,void 0,(function*(){if(this.formGroup.markAsTouched(),this.formGroup.invalid)return;const e=yield(0,n._)(this.accountService.activeAccount$);if(null==e)throw new Error("No active user.");if(yield this.keyService.hasUserKey(e.id))throw this.messagingService.send("logout"),new Error("User key already exists, cannot migrate legacy encryption.");const t=this.formGroup.value.masterPassword;try{yield this.syncService.fullSync(!1,!0),yield this.keyRotationService.rotateUserKeyAndEncryptedDataLegacy(t,e),this.toastService.showToast({variant:"success",title:this.i18nService.t("keyUpdated"),message:this.i18nService.t("logBackInOthersToo"),timeout:15e3}),this.messagingService.send("logout")}catch(i){if(i instanceof o._&&"All existing folders must be included in the rotation."===i.message){if(yield this.dialogService.openSimpleDialog({type:"warning",title:{key:"encryptionKeyUpdateCannotProceed"},content:{key:"keyUpdateFoldersFailed"},acceptButtonText:{key:"ok"},cancelButtonText:{key:"cancel"}}))return yield this.folderApiService.deleteAll(e.id),yield this.syncService.fullSync(!0,!0),void(yield this.submit())}throw this.logService.error(i),i}}))}}M.ɵfac=function(e){return new(e||M)(y.rXU(p.Di),y.rXU(d.y),y.rXU(h.W),y.rXU(a.Lu),y.rXU(s.U),y.rXU(m.K),y.rXU(c.H),y.rXU(b.f),y.rXU(f.o),y.rXU(v.w))},M.ɵcmp=y.VBU({type:M,selectors:[["ng-component"]],standalone:!0,features:[y.aNF],decls:25,vars:20,consts:[[3,"formGroup","bitSubmit"],[1,"tw-mt-12","tw-flex","tw-justify-center"],[1,"tw-max-w-xl"],["bitTypography","h1",1,"tw-mb-4","tw-text-center"],[1,"tw-block","tw-rounded","tw-border","tw-border-solid","tw-border-secondary-300","tw-bg-background","tw-p-8"],["href","https://bitwarden.com/help/account-encryption-key/#rotate-your-encryption-key","target","_blank","rel","noreferrer"],["type","warning"],["id","masterPassword","bitInput","","type","password","formControlName","masterPassword","appAutofocus",""],["type","button","bitIconButton","","bitSuffix","","bitPasswordInputToggle",""],["type","submit","bitButton","","bitFormButton","","buttonType","primary","block",""]],template:function(e,t){1&e&&(y.j41(0,"form",0)(1,"div",1)(2,"div",2)(3,"h1",3),y.EFF(4),y.nI1(5,"i18n"),y.k0s(),y.j41(6,"div",4)(7,"p"),y.EFF(8),y.nI1(9,"i18n"),y.j41(10,"a",5),y.EFF(11),y.nI1(12,"i18n"),y.k0s()(),y.j41(13,"bit-callout",6),y.EFF(14),y.nI1(15,"i18n"),y.k0s(),y.j41(16,"bit-form-field")(17,"bit-label"),y.EFF(18),y.nI1(19,"i18n"),y.k0s(),y.nrm(20,"input",7)(21,"button",8),y.k0s(),y.j41(22,"button",9),y.EFF(23),y.nI1(24,"i18n"),y.k0s()()()()()),2&e&&(y.Y8G("formGroup",t.formGroup)("bitSubmit",t.submit),y.R7$(4),y.JRh(y.bMT(5,8,"updateEncryptionKey")),y.R7$(4),y.SpI(" ",y.bMT(9,10,"updateEncryptionSchemeDesc")," "),y.R7$(3),y.JRh(y.bMT(12,12,"learnMore")),y.R7$(3),y.JRh(y.bMT(15,14,"updateEncryptionKeyWarning")),y.R7$(4),y.JRh(y.bMT(19,16,"masterPass")),y.R7$(5),y.SpI(" ",y.bMT(24,18,"updateEncryptionKey")," "))},dependencies:[u.G,r.qT,r.me,r.BC,r.cb,r.j4,r.JD,w.B,g.$,S.L,k.Q,U.G,F.m,E.J,T.h,I.e,R.a,x.s,G.r,X.$,l.H],encapsulation:2})}}]);
//# sourceMappingURL=505.a842c8c15f988abfb6c2.js.map