import{b as R}from"./chunk-SGKLF7ZH.js";import{b as v}from"./chunk-S7CZAL6E.js";import{f as s}from"./chunk-XLWPOSF4.js";import{b as A}from"./chunk-V2PLMOVJ.js";import{a as f}from"./chunk-MKXPJTAW.js";import{m as u}from"./chunk-3VQS547U.js";import{a as y}from"./chunk-YO44C22F.js";import{f as d}from"./chunk-6VC7H3CZ.js";import{K as S,da as a,ja as o,r as h}from"./chunk-QMYHTLAJ.js";import{d as l,n as _}from"./chunk-HE7HQ6LI.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[e.Audit=20]="Audit",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",[t.Audit]:"\u0410\u0443\u0434\u0438\u0442"};var D=(()=>{class e{constructor(i){this._http=i}getPermission(){return this._http.get("/api/permission/all",{headers:y})}static{this.\u0275fac=function(n){return new(n||e)(o(d))}}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 A(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(u))}}static{this.\u0275prov=a({token:e,factory:e.\u0275fac})}};l([f(s.permissions)],r.prototype,"_permissions",void 0);l([f(s.employeeId)],r.prototype,"_employeeId",void 0);export{D as a,r as b};
