function r(e){return{product:e,item:e.variant||e,addingToCart:!1,get productName(){return this.product.name},get productUrl(){let t=`/products/${this.product.slug}`;return this.hasAnyVariant&&(t+=`?variant=${this.item.uid}`),t},get productPrice(){return this.item.formatted_price},get regularPrice(){return this.item.price.inCurrentCurrency.amount},get hasSpecialPrice(){return this.item.special_price!==null},get hasPercentageSpecialPrice(){return this.item.has_percentage_special_price},get specialPrice(){return this.item.selling_price.inCurrentCurrency.amount},get specialPricePercent(){return Math.round((this.regularPrice-this.specialPrice)/this.regularPrice*100)},get hasAnyVariant(){return this.product.variant!==null},get hasAnyOption(){return this.product.options_count>0},get hasNoOption(){return!this.hasAnyOption},get hasAnyMedia(){return this.item.media.length!==0},get hasBaseImage(){return this.hasAnyVariant?this.item.base_image.length!==0||this.product.base_image.length!==0:this.item.base_image.length!==0},get baseImage(){return this.hasBaseImage?this.item.base_image.path||this.product.base_image.path:`${window.FleetCart.baseUrl}/build/assets/image-placeholder.png`},get isInStock(){return this.item.is_in_stock},get isOutOfStock(){return this.item.is_out_of_stock},get doesManageStock(){return this.item.does_manage_stock},get isNew(){return!this.isOutOfStock&&this.product.is_new},syncWishlist(){this.$store.wishlist.syncWishlist(this.product.id)},syncCompareList(){this.$store.compare.syncCompareList(this.product.id)},addToCart(){if(this.addingToCart)return;this.addingToCart=!0;let t=`/cart/items?product_id=${this.product.id}&qty=1`;this.hasAnyVariant&&(t+=`&variant_id=${this.item.id}`),axios.post(t).then(i=>{this.$store.cart.updateCart(i.data),this.$store.layout.openSidebarCart()}).catch(i=>{notify(i.response.data.message)}).finally(()=>{this.addingToCart=!1})}}}export{r as P};
