import{b as g}from"./chunk-BYMBPIQC.js";import{b as W,c as _}from"./chunk-UBWF5ENA.js";import{a as d}from"./chunk-LJIIRAVZ.js";import{a as v}from"./chunk-65ZGL2UQ.js";import{c as u}from"./chunk-6GCD7JC6.js";import{a as m}from"./chunk-B7E4YH53.js";import{m as h}from"./chunk-A7R3CFJO.js";import{J as t,_ as a,ca as f,ia as s,ja as l,r as S}from"./chunk-3FIHWXA5.js";import{b as o,i as w}from"./chunk-QOJKCMZT.js";w();var n=class c{get warehouseOptions(){let e=this._stores.find(r=>r.id===this._storeId);return e?e.warehouses:[]}constructor(e,r,i,p){this._warehouseServiceApi=e,this._permissionService=r,this._retailStoreService=i,this._store=p,this._store$=l(h).select(u.selectedStoreId)}getWarehouses(e=!1){return this._warehouseServiceApi.getWarehouses(e).pipe(a(r=>this._store.dispatch(new v(r))),t(1))}getWarehouseAll(){return this._warehouseServiceApi.getWarehouseAll().pipe(t(1))}createWarehouse(e){return this._warehouseServiceApi.createWarehouse(e).pipe(a(()=>this.getWarehouses().subscribe()),t(1))}editWarehouse(e,r){return this._warehouseServiceApi.editWarehouse(e,r).pipe(a(()=>{this.getWarehouses().subscribe(),this._retailStoreService.getStores().subscribe()}),t(1))}getWarehouseRemains(e,r){let i={criteria:{filter:{nomenclatureIds:r,viewArchived:!0},search:null},take:r.length??100,skip:0,isAscending:!0,orderBy:"id"};return this._warehouseServiceApi.getWarehouseRemains(e,i).pipe(S(p=>p.data),t(1))}getWarehouseOptionByPermission(e){let r=[];return this._store$.pipe(t(1)).subscribe(i=>{r=this.filterWarehousesByPermission(this.getStoreById(i).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)}static{this.\u0275fac=function(r){return new(r||c)(s(W),s(g),s(_),s(h))}}static{this.\u0275prov=f({token:c,factory:c.\u0275fac})}};o([m(u.stores)],n.prototype,"_stores",void 0);o([m(u.selectedStoreId)],n.prototype,"_storeId",void 0);n=o([d()],n);export{n as a};
