import{a as o}from"./chunk-I4OLXHWD.js";import{a as u}from"./chunk-PQ7NYIWJ.js";import{m as n}from"./chunk-3VQS547U.js";import{a as h}from"./chunk-YO44C22F.js";import{f as a}from"./chunk-6VC7H3CZ.js";import{$ as c,K as r,da as s,ja as p}from"./chunk-QMYHTLAJ.js";var l=(()=>{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(e=!1){return e?this._http.post("/api/price/sync",{},{headers:h}):this._http.post("/api/price/sync",{})}static{this.\u0275fac=function(i){return new(i||t)(p(a))}}static{this.\u0275prov=s({token:t,factory:t.\u0275fac})}}return t})();var S=(()=>{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 u({prices:e}))),r(1))}synPrice(e=!1){return this._priceServiceApi.syncPrice(e).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(l),p(n))}}static{this.\u0275prov=s({token:t,factory:t.\u0275fac})}}return t})();export{l as a,S as b};
