import{a as S}from"./chunk-CHJ4ZSZK.js";import{a as w}from"./chunk-NRBWRRAF.js";import{Ka as r,la as u,qa as d}from"./chunk-ISMRT7VU.js";import{a as h,b as n}from"./chunk-M5TX2NVG.js";var m=(()=>{class c{constructor(){this._showcaseServiceApi=d(S),this._localStorageService=d(w),this.loadingShowcase=r(!1),this.showcase=r(null),this.id=r(null),this.showcaseCart=r([]),this.openBottomSheet=r(!1),this.openDialog=r(!1)}saveShowcaseToLocalStorage(e){this._localStorageService.set(`showcase:${e}`,this.showcaseCart())}createShowcase(e){return this._showcaseServiceApi.create(e)}editShowcase(e,s){return this._showcaseServiceApi.edit(e,s)}currentShowcase(){return this._showcaseServiceApi.current()}getShowcase(e){return this._showcaseServiceApi.get(e)}suspendShowcase(e){return this._showcaseServiceApi.suspend(e)}activateShowcase(e){return this._showcaseServiceApi.activate(e)}productsShowcase(e,s){return this._showcaseServiceApi.products(e,s)}getProductsShowcase(e,s,a){let i={criteria:{search:e!==null?{name:e}:null},take:s,skip:0,orderBy:"Current",isAscending:!1};return this.productsShowcase(i,a)}addProductToCart(e){let a=this.showcaseCart()??[],i=a.findIndex(t=>t.id===e.id),o;i!==-1?o=a.map((t,l)=>l===i?n(h({},t),{quantity:t.quantity+1}):t):o=[...a,n(h({},e),{quantity:1})],this.showcaseCart.set(o),this.saveShowcaseToLocalStorage(this.id())}removeCartProduct(e){let s=this.showcaseCart();if(!s)return;let a=s??[],i=a.find(t=>t.id===e);if(!i)return;let o;i.quantity>1?o=a.map(t=>t.id===e?n(h({},t),{quantity:t.quantity-1}):t):o=a.filter(t=>t.id!==e),this.showcaseCart.set(o),this.saveShowcaseToLocalStorage(this.id())}clearCart(){this.showcaseCart.set([]),this.saveShowcaseToLocalStorage(this.id())}removeCartPosition(e){let a=this.showcaseCart().filter((i,o)=>o!==e);this.showcaseCart.set(a),this.saveShowcaseToLocalStorage(this.id())}static{this.\u0275fac=function(s){return new(s||c)}}static{this.\u0275prov=u({token:c,factory:c.\u0275fac})}}return c})();export{m as a};
//# sourceMappingURL=chunk-D2W6JP73.js.map
