import{b as g}from"./chunk-YQRXO7LU.js";import{b as v,c as _}from"./chunk-4WBIDQ26.js";import{a as d}from"./chunk-VXSBHXCN.js";import{a as W}from"./chunk-Y4KZVCMP.js";import{c as n}from"./chunk-BYOG7O4N.js";import{a as m}from"./chunk-4QCIIFWS.js";import{n as u}from"./chunk-DC6G5OHZ.js";import{L as i,aa as h,ia as f,na as o,oa as l,q as S}from"./chunk-C2QKZJOP.js";import{d as a,n as y}from"./chunk-INB5GR2I.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-OAUPJA66.js.map
