import{b as v,c as _}from"./chunk-Z6SX4HYB.js";import{a as d}from"./chunk-KXDO3JYP.js";import{d as g}from"./chunk-MKNMLS2N.js";import{a as W}from"./chunk-Y4KZVCMP.js";import{c as n}from"./chunk-UU4K5RCK.js";import{a as m}from"./chunk-F24KRXZV.js";import{p as u}from"./chunk-JBWPPKX4.js";import{$ as h,K as i,fa as f,ka as o,la as l,q as S}from"./chunk-PVUKHE45.js";import{d as a,n as y}from"./chunk-VD6R3735.js";y();var t,c=(t=class{get warehouseOptions(){let e=this._stores.find(r=>r.id===this._storeId);return e?e.warehouses:[]}constructor(e,r,s,p){this._warehouseServiceApi=e,this._permissionService=r,this._retailStoreService=s,this._store=p,this._store$=l(u).select(n.selectedStoreId)}getWarehouses(e=!1){return this._warehouseServiceApi.getWarehouses(e).pipe(h(r=>this._store.dispatch(new W(r))),i(1))}getWarehouseAll(){return this._warehouseServiceApi.getWarehouseAll().pipe(i(1))}createWarehouse(e){return this._warehouseServiceApi.createWarehouse(e).pipe(h(()=>this.getWarehouses().subscribe()),i(1))}editWarehouse(e,r){return this._warehouseServiceApi.editWarehouse(e,r).pipe(h(()=>{this.getWarehouses().subscribe(),this._retailStoreService.getStores().subscribe()}),i(1))}syncWarehouse(){return this._warehouseServiceApi.syncWarehouse().pipe(i(1))}getWarehouseRemains(e,r,s=!1){let p={criteria:{filter:{nomenclatureIds:r,viewArchived:!0},search:null},take:r.length??100,skip:0,isAscending:!0,orderBy:"id"};return this._warehouseServiceApi.getWarehouseRemains(e,p,s).pipe(S(w=>w.data),i(1))}getWarehouseOptionByPermission(e){let r=[];return this._store$.pipe(i(1)).subscribe(s=>{r=this.filterWarehousesByPermission(this.getStoreById(s).warehouses,e)}),r}getStoresWarehouses(e){return e?e.warehouses:[]}filterWarehousesByPermission(e,r){return r?e.filter(()=>this._permissionService.hasPermissions(r)):e}getStoreById(e){return this._stores.find(r=>r.id===e)}},t.\u0275fac=function(r){return new(r||t)(o(v),o(g),o(_),o(u))},t.\u0275prov=f({token:t,factory:t.\u0275fac}),t);a([m(n.stores)],c.prototype,"_stores",void 0);a([m(n.selectedStoreId)],c.prototype,"_storeId",void 0);c=a([d()],c);export{c as a};
//# sourceMappingURL=chunk-NPOUEQYN.js.map
