import{a as F,b as R,c as V}from"./chunk-NHPWD7XQ.js";import{C as S,G as E}from"./chunk-P5ZTPV5Q.js";import{b as A,d as T,h as k}from"./chunk-LZAJN7X2.js";import"./chunk-7GLTULNV.js";import{Ba as O}from"./chunk-JNANLRYG.js";import"./chunk-HQJI5M5I.js";import"./chunk-PTMJTNEU.js";import"./chunk-X6YHEMIY.js";import{Mb as u,Nb as f,Tb as s,Ub as m,V as l,Yd as P,ab as c,ac as _,ae as M,cc as v,ea as r,ec as p,f as b,ka as C,la as g,nb as y,qc as w,sc as d,uc as x}from"./chunk-PCDQIHDN.js";import"./chunk-2PV2FVC7.js";function B(t,a){if(t&1){let n=_();s(0,"button",6),v("click",function(){C(n);let e=p(2);return g(e.resendConfirmation())}),d(1," Resend confirmation email "),m()}}function L(t,a){if(t&1){let n=_();s(0,"button",7),v("click",function(){C(n);let e=p(2);return g(e.navigateToLogin())}),d(1," Login now "),m()}}function D(t,a){if(t&1&&(s(0,"div",0)(1,"mat-card",1)(2,"div",2),d(3),m(),s(4,"mat-card-content",3),d(5),m(),s(6,"mat-card-actions"),u(7,B,2,0,"button",4),u(8,L,2,0,"button",5),m()()()),t&2){let n=p();c(2),w("warning",n.confirmationState!==n.confirmationStates.Confirmed)("success",n.confirmationState===n.confirmationStates.Confirmed),c(),x(" ",n.cardTitle," "),c(2),x(" ",n.cardContent," "),c(2),f((n.confirmationState===n.confirmationStates.Pending||n.confirmationState===n.confirmationStates.Failed)&&n.canResendConfirmation?7:-1),c(),f(n.confirmationState===n.confirmationStates.Confirmed?8:-1)}}var i=(function(t){return t[t.Pending=0]="Pending",t[t.Busy=1]="Busy",t[t.Confirmed=2]="Confirmed",t[t.Failed=3]="Failed",t})(i||{}),W=(()=>{let a=class a{constructor(){this.translationService=r(P),this.activatedRoute=r(A),this.authService=r(k),this.viewService=r(E),this.router=r(T),this.confirmationStates=i,this.confirmationState=i.Busy,this.destroyed=new b}confirmUseraccount(){this.authService.confirmEmailAddress(this.email,this.token).pipe(l(this.destroyed)).subscribe(o=>this.confirmationState=o?i.Confirmed:i.Failed)}resendConfirmation(){this.authService.resendConfirmationEmail(this.email).pipe(l(this.destroyed)).subscribe(o=>{if(o)this.viewService.showToastNotification("Another confirmation email has been sent",S.Success);else{let e=this.translationService.translate("Failed to send email to address %1").replace("%1",this.email);this.viewService.showToastNotification(e,S.Error)}})}navigateToLogin(){this.router.navigate(["./login"])}get canResendConfirmation(){return!!this.email?.length}get cardTitle(){switch(this.confirmationState){case i.Failed:return"Account confirmation failed";case i.Confirmed:return"Account confirmed";case i.Pending:default:return"Account confirmation required"}}get cardContent(){switch(this.confirmationState){case i.Failed:return"AccountConfirmationFailed";case i.Confirmed:return"AccountConfirmationSucceeded";case i.Pending:default:return"AccountConfirmationPending"}}ngOnInit(){this.activatedRoute.queryParams.pipe(l(this.destroyed)).subscribe(o=>{this.email=o.email;let e=!!this.email?.length;this.token=o.token,!!this.token?.length?e&&this.confirmUseraccount():this.confirmationState=i.Pending})}ngOnDestroy(){this.destroyed.next(),this.destroyed.complete()}};a.\u0275fac=function(e){return new(e||a)},a.\u0275cmp=y({type:a,selectors:[["wv-account-confirmation"]],decls:1,vars:1,consts:[[1,"account-confirmation-container"],["appearance","outlined"],["translate","",1,"header-text"],["translate",""],["id","resend-button","mat-flat-button","","type","button","translate",""],["id","login-button","mat-raised-button","","color","primary","type","button","translate","","data-test","account.action.confirm"],["id","resend-button","mat-flat-button","","type","button","translate","",3,"click"],["id","login-button","mat-raised-button","","color","primary","type","button","translate","","data-test","account.action.confirm",3,"click"]],template:function(e,h){e&1&&u(0,D,9,8,"div",0),e&2&&f(h.confirmationState!==h.confirmationStates.Busy?0:-1)},dependencies:[F,M,R,V,O],styles:[".account-confirmation-container[_ngcontent-%COMP%]{min-width:400px;max-width:600px;position:absolute;top:50%;left:50%;transform:translateY(-50%) translate(-50%)}.account-confirmation-container[_ngcontent-%COMP%]   mat-card[_ngcontent-%COMP%]   .header-text[_ngcontent-%COMP%]{width:100%;font-size:1.5rem;text-align:center;padding:24px 0}.account-confirmation-container[_ngcontent-%COMP%]   mat-card[_ngcontent-%COMP%]   mat-card-content[_ngcontent-%COMP%]{margin:0 24px}.account-confirmation-container[_ngcontent-%COMP%]   mat-card[_ngcontent-%COMP%]   mat-card-actions[_ngcontent-%COMP%]{padding:24px 12px 12px;margin:0;display:flex;align-items:center;justify-content:center}"]});let t=a;return t})();export{W as AccountConfirmationComponent,i as ConfirmationState};
