import{V as d,W as A}from"./chunk-INYFUTXB.js";import{Db as c,Gb as o,Ib as l,Sd as v,Tb as p,g as m,ia as h,na as f,oa as w}from"./chunk-XJKQ67XR.js";import{e as u}from"./chunk-SZAW6ZBW.js";var C,P=u(()=>{f();w();v();A();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 m}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(h(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)(o(c),o(l),o(d))}}static{this.\u0275dir=p({type:n,selectors:[["","hasAdminPermission",""]],inputs:{hasAdminPermission:"hasAdminPermission",hasAdminPermissionRequireAll:"hasAdminPermissionRequireAll",hasAdminPermissionElse:"hasAdminPermissionElse"}})}}return n})()});export{C as a,P as b};
