import{a as o}from"./chunk-2F33MW3T.js";import{a as h}from"./chunk-PQ7NYIWJ.js";import{m as a}from"./chunk-A7R3CFJO.js";import{x as n}from"./chunk-OIJW4GMG.js";import{J as r,_ as c,ca as s,ia as p}from"./chunk-3FIHWXA5.js";var u=(()=>{class t{constructor(e){this._http=e}createPrice(e){return this._http.post("/api/price",e)}updatePrice(e,i){return this._http.put(`/api/price/${e}`,i)}deletePrice(e){return this._http.delete(`/api/price/${e}`)}getPrices(){return this._http.post("/api/price/all",{})}syncPrice(){return this._http.post("/api/price/sync",{})}static{this.\u0275fac=function(i){return new(i||t)(p(n))}}static{this.\u0275prov=s({token:t,factory:t.\u0275fac})}}return t})();var v=(()=>{class t{constructor(e,i){this._priceServiceApi=e,this._store=i}createPrice(e){return this._priceServiceApi.createPrice(this._toUpsertModel(e)).pipe(c(()=>this.getPrices().subscribe()),r(1))}updatePrice(e,i){return this._priceServiceApi.updatePrice(e,this._toUpsertModel(i)).pipe(c(()=>this.getPrices().subscribe()),r(1))}deletePrice(e){return this._priceServiceApi.deletePrice(e).pipe(c(()=>this.getPrices().subscribe()),r(1))}getPrices(){return this._priceServiceApi.getPrices().pipe(c(e=>this._store.dispatch(new h({prices:e}))),r(1))}synPrice(){return this._priceServiceApi.syncPrice().pipe(r(1))}_toUpsertModel(e){return{type:e.type,name:e.name,from:e.period?o(e.period[0]):null,to:e.period?o(e.period[1]):null}}static{this.\u0275fac=function(i){return new(i||t)(p(u),p(a))}}static{this.\u0275prov=s({token:t,factory:t.\u0275fac})}}return t})();export{u as a,v as b};
