import{b as R}from"./chunk-SCIHINN2.js";import{b as v}from"./chunk-PM5FBLRE.js";import{d as y,f as l}from"./chunk-WQCTYPF6.js";import{a as f}from"./chunk-B7E4YH53.js";import{a as A}from"./chunk-NHAEOK7K.js";import{m as d}from"./chunk-A7R3CFJO.js";import{x as u}from"./chunk-OIJW4GMG.js";import{J as S,ca as a,ia as o,r as h}from"./chunk-3FIHWXA5.js";import{b as s,i as _}from"./chunk-QOJKCMZT.js";_();var t=function(e){return e[e.CompanyAndStores=1]="CompanyAndStores",e[e.Warehouses=2]="Warehouses",e[e.EmployeesAndRoles=3]="EmployeesAndRoles",e[e.Nomenclature=4]="Nomenclature",e[e.Accounts=5]="Accounts",e[e.Cashboxes=6]="Cashboxes",e[e.Remains=7]="Remains",e[e.AcceptanceDocuments=8]="AcceptanceDocuments",e[e.PostingDocuments=9]="PostingDocuments",e[e.WriteOffDocuments=10]="WriteOffDocuments",e[e.MovementDocuments=11]="MovementDocuments",e[e.RevisionDocuments=12]="RevisionDocuments",e[e.SellAndReturnDocuments=13]="SellAndReturnDocuments",e[e.Manufacture=16]="Manufacture",e[e.ReturnSupplier=17]="ReturnSupplier",e[e.Shifts=18]="Shifts",e}(t||{}),p={[t.CompanyAndStores]:"\u041A\u043E\u043C\u043F\u0430\u043D\u0438\u044F \u0438 \u0442\u043E\u0440\u0433\u043E\u0432\u0430\u044F \u0442\u043E\u0447\u043A\u0430",[t.Warehouses]:"\u0421\u043A\u043B\u0430\u0434\u044B",[t.EmployeesAndRoles]:"\u0421\u043E\u0442\u0440\u0443\u0434\u043D\u0438\u043A\u0438 \u0438 \u0440\u043E\u043B\u0438",[t.Nomenclature]:"\u041D\u043E\u043C\u0435\u043D\u043A\u043B\u0430\u0442\u0443\u0440\u0430",[t.Accounts]:"\u0421\u0447\u0435\u0442\u0430",[t.Cashboxes]:"\u041A\u0430\u0441\u0441\u044B",[t.Remains]:"\u041E\u0441\u0442\u0430\u0442\u043A\u0438",[t.AcceptanceDocuments]:"\u041F\u0440\u0438\u0435\u043C\u043A\u0438",[t.PostingDocuments]:"\u041E\u043F\u0440\u0438\u0445\u043E\u0434\u043E\u0432\u0430\u043D\u0438\u044F",[t.WriteOffDocuments]:"\u0421\u043F\u0438\u0441\u0430\u043D\u0438\u044F",[t.MovementDocuments]:"\u041F\u0435\u0440\u0435\u043C\u0435\u0449\u0435\u043D\u0438\u044F",[t.RevisionDocuments]:"\u0420\u0435\u0432\u0438\u0437\u0438\u0438",[t.SellAndReturnDocuments]:"\u041F\u0440\u043E\u0434\u0430\u0436\u0438 \u0438 \u0432\u043E\u0437\u0432\u0440\u0430\u0442\u044B",[t.Manufacture]:"\u0418\u0437\u0433\u043E\u0442\u043E\u0432\u043B\u0435\u043D\u0438\u0435",[t.ReturnSupplier]:"\u0412\u043E\u0437\u0432\u0440\u0430\u0442\u044B \u043F\u043E\u0441\u0442\u0430\u0432\u0449\u0438\u043A\u0443",[t.Shifts]:"\u0421\u043C\u0435\u043D\u044B"};var D=(()=>{class e{constructor(i){this._http=i}getPermission(){return this._http.get("/api/permission/all",{headers:A})}static{this.\u0275fac=function(n){return new(n||e)(o(u))}}static{this.\u0275prov=a({token:e,factory:e.\u0275fac})}}return e})();var r=class e{constructor(c,i,n,m){this._permissionsServiceApi=c,this._authService=i,this._employeeService=n,this._store=m}getPermissions(){return this._permissionsServiceApi.getPermission().pipe(S(1),h(c=>Object.keys(p).map(i=>({id:+i,name:p[+i],permissions:c.filter(n=>n.group===+i)}))))}hasPermissions(c){return this._permissions?this._permissions.includes(c):(this._employeeService.getEmployeeById(this._employeeId).subscribe(i=>(this._store.dispatch(new y(i)),this._permissions.includes(c))),!1)}filteredItems(c){return c.filter(i=>i.options.filter(n=>(n.visible=n.permissions.some(m=>this.hasPermissions(m))||n.permissions.length===0,n.visible)).length)}static{this.\u0275fac=function(i){return new(i||e)(o(D),o(v),o(R),o(d))}}static{this.\u0275prov=a({token:e,factory:e.\u0275fac})}};s([f(l.permissions)],r.prototype,"_permissions",void 0);s([f(l.employeeId)],r.prototype,"_employeeId",void 0);export{D as a,r as b};
