import {J,a6 as pi,a5 as fh,c as tS,a7 as si,bP as he,bE as ff,w as wo,wP as fo,j$ as zs,ac as Dr,bW as JT}from'./main-WUGO6e7n.js';var C,P=J(()=>{pi();fh();tS();si();C=(()=>{class n{constructor(e,t,r){this.templateRef=e,this.viewContainer=t,this.currentUserService=r,this.permissions=[],this.requireAll=!1,this.elseTemplateRef=null,this.hasView=!1,this.destroy$=new he;}set hasAdminPermission(e){this.permissions=e,this.updateView();}set hasAdminPermissionRequireAll(e){this.requireAll=e,this.updateView();}set hasAdminPermissionElse(e){this.elseTemplateRef=e,this.updateView();}ngOnInit(){this.currentUserService.permissionsChanged.pipe(ff(this.destroy$)).subscribe(()=>{this.updateView();}),this.updateView();}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete();}updateView(){let e=this.checkPermission();e&&!this.hasView?(this.viewContainer.clear(),this.viewContainer.createEmbeddedView(this.templateRef),this.hasView=!0):!e&&this.hasView&&(this.viewContainer.clear(),this.hasView=!1),!e&&this.elseTemplateRef&&this.viewContainer.length===0&&this.viewContainer.createEmbeddedView(this.elseTemplateRef);}checkPermission(){if(!this.permissions)return !1;let e=this.currentUserService.permissionsSnapshot;if(!e||!e.activePermissions)return !1;let t=new Date,r=i=>i.endDateUtc?new Date(i.endDateUtc)>=t:!0;if(!Array.isArray(this.permissions))return e.activePermissions.some(i=>i.permission===this.permissions&&r(i));let a=this.permissions;return a.length===0?!1:this.requireAll?a.every(i=>e.activePermissions.some(s=>s.permission===i&&r(s))):a.some(i=>e.activePermissions.some(s=>s.permission===i&&r(s)))}static{this.\u0275fac=function(t){return new(t||n)(wo(fo),wo(zs),wo(Dr))};}static{this.\u0275dir=JT({type:n,selectors:[["","hasAdminPermission",""]],inputs:{hasAdminPermission:"hasAdminPermission",hasAdminPermissionRequireAll:"hasAdminPermissionRequireAll",hasAdminPermissionElse:"hasAdminPermissionElse"}});}}return n})();});export{C,P};