import{a as h}from"./chunk-5VIN4FSX.js";import{a as l}from"./chunk-M3BIGFZJ.js";import{a as n}from"./chunk-QV4S7KFO.js";import{a as u,b as m}from"./chunk-XVWHZ5TH.js";import{L as o,ea as d,ka as a,r}from"./chunk-LEOKSAW2.js";import{d as p,n as g}from"./chunk-HE7HQ6LI.js";g();var A=class c{constructor(t,e){this._productionActServiceApi=t,this._remainsService=e}create(t){let e=this._migrateFormToRequestModel(t);return this._productionActServiceApi.create(e).pipe(o(1))}edit(t,e){let i=this._migrateFormToRequestModel(e);return this._productionActServiceApi.edit(t,{date:i.date,copies:i.copies,comment:i.comment}).pipe(o(1))}getById(t){return this._productionActServiceApi.getById(t).pipe(r(e=>(e.date=new Date(e.date),e)))}getAll(t){return this._productionActServiceApi.getAll(t).pipe(o(1))}calculateTotalCost(t,e){let i={warehouseId:e,positions:t};return this._remainsService.getCalculatedProductsCost(i).pipe(m(this),r(s=>s.positions.reduce((S,v)=>S+=v.totalCost,0)))}getProductRemains(t,e){let i={criteria:{search:null,filter:{nomenclatureIds:e,viewWithZeroQuantity:!0}},skip:0,take:e.length,orderBy:"id",isAscending:!1};return this._remainsService.getProductRemains(t,i).pipe(r(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}}static{this.\u0275fac=function(e){return new(e||c)(a(h),a(l))}}static{this.\u0275prov=d({token:c,factory:c.\u0275fac})}};A=p([u()],A);export{A as a};
