import{a as h}from"./chunk-UHNHO2LZ.js";import{a as l}from"./chunk-YZQRUE7W.js";import{a as n}from"./chunk-JAY45DEO.js";import{a as u,b as m}from"./chunk-KXDO3JYP.js";import{K as c,fa as d,ka as a,q as o}from"./chunk-PVUKHE45.js";import{d as p,n as v}from"./chunk-VD6R3735.js";v();var i,A=(i=class{constructor(t,e){this._productionActServiceApi=t,this._remainsService=e}create(t){let e=this._migrateFormToRequestModel(t);return this._productionActServiceApi.create(e).pipe(c(1))}edit(t,e){let r=this._migrateFormToRequestModel(e);return this._productionActServiceApi.edit(t,{date:r.date,copies:r.copies,comment:r.comment}).pipe(c(1))}getById(t){return this._productionActServiceApi.getById(t).pipe(o(e=>(e.date=new Date(e.date),e)))}getAll(t){return this._productionActServiceApi.getAll(t).pipe(c(1))}calculateTotalCost(t,e){let r={warehouseId:e,positions:t};return this._remainsService.getCalculatedProductsCost(r).pipe(m(this),o(s=>s.positions.reduce((S,g)=>S+=g.totalCost,0)))}getProductRemains(t,e){let r={criteria:{search:null,filter:{nomenclatureIds:e,viewWithZeroQuantity:!0}},skip:0,take:e.length,orderBy:"id",isAscending:!1};return this._remainsService.getProductRemains(t,r).pipe(o(s=>s.data))}_migrateFormToRequestModel(t){return{prescriptId:t.prescriptId,date:t.date?n(t.date):n(new Date),copies:t.copies,resultsWarehouseId:t.resultsWarehouseId,componentsWarehouseId:t.componentsWarehouseId,comment:t.comment}}},i.\u0275fac=function(e){return new(e||i)(a(h),a(l))},i.\u0275prov=d({token:i,factory:i.\u0275fac}),i);A=p([u()],A);export{A as a};
//# sourceMappingURL=chunk-2ZDJSYEB.js.map
