var GlobalEventBus=GlobalEventBus||new Vue();(function($){Vue.filter('capitalize',(data)=>{capitalized=[];data.split(' ').forEach((word)=>{capitalized.push(word.charAt(0).toUpperCase()+word.slice(1).toLowerCase(),)});return capitalized.join(' ')});Vue.component('product-item',{template:'#vc-component-product-item',props:{hasHoverImage:{type:Boolean,default:!1,},index:{type:Number,default:0,},listName:{type:String,default:null,},product:{type:Object,required:!0,},sizes:{type:Boolean,default:!1,},swatches:{type:Number,default:10,}},data(){return{inWishlist:this.product.stylecolour.inwishlist,selectedSize:'',showAltImage:!1,wishlistPopupVisible:!1,}},computed:{styleColour(){return this.product.stylecolour},currency(){var currency=this.styleColour.variant.currency;var currencySymbol='';switch(currency){case 'GBP':currencySymbol='&pound;';break;default:currencySymbol='$';break}
return currency+' '+currencySymbol},lowestBaseUnitPrice(){return this.getLowestAmount(this.styleColour.variants,'baseunitprice')},lowestUnitPrice(){return this.getLowestAmount(this.styleColour.variants,'unitprice')},colourSwatches(){if(!this.styleColour.attributes||!this.styleColour.attributes.colourswatches)return[];return this.styleColour.attributes.colourswatches},maxColourSwatches(){var self=this;var currentSwatchIndex=0;if(!this.colourSwatches.length)return[];this.colourSwatches.forEach(function(swatch,index){if(swatch.stylecolourid===self.styleColour.stylecolourid){currentSwatchIndex=index}});var currentSwatch=this.colourSwatches.splice(currentSwatchIndex,1)[0];this.colourSwatches.unshift(currentSwatch);return this.colourSwatches.slice(0,this.swatches)},image(){return this.styleColour.primaryimage},imageAlt(){if(this.styleColour.images&&this.styleColour.images.length>1&&this.showAltImage){return this.styleColour.images.filter(function(image){return!image.primary})[0]}
return!1},imageWide(){return this.styleColour.imageswide},gaImpressionData(){var additionalData={};if(this.index){additionalData.position=this.index}
if(this.listName){additionalData.list=this.listName}
return{type:'impressions',data:$.extend(this.styleColour.variant.gadata,additionalData),}},upsell(){return this.styleColour.variant.upsell},releaseDate(){var releaseDate=this.styleColour.attributes.releasedate;var date;var dateFormatted;if(releaseDate!==null&&releaseDate!==undefined){date=(releaseDate.split(' ')[0]).split('-');dateFormatted=date[2]+'.'+date[1]+'.'+date[0]}
return dateFormatted}},mounted(){GlobalEventBus.$on('product-wishlist:success',this.wishlistSuccess)},methods:{addToCart(barcode,quantity){peppercheckout.globals.$eventbus.$emit('addproducttocart',{variantid:barcode,quantity:quantity})},getLowestAmount(variants,property){var lowest;for(var i=0;i<variants.length;i++){if(i==0){lowest=parseFloat(variants[i][property])}else{if(lowest>parseFloat(variants[i][property])){lowest=parseFloat(variants[i][property])}}}
return lowest.toFixed(2)},getSrcset(images){return Object.keys(images).reduce(function(srcset,width){srcset.push(images[width]+' '+width+'w');return srcset},[]).join(', ')},toggleAltImage(){if(this.hasHoverImage){this.showAltImage=!this.showAltImage}},toggleWishlist(){if(window.isCustomerLoggedIn===''){GlobalEventBus.$emit('show-login')}else{GlobalEventBus.$emit('product-wishlist:open',{styleColour:this.styleColour,inWishlist:this.inWishlist})}},wishlistSuccess(payload){var styleColourId=payload.styleColourId;if(this.styleColour.stylecolourid===styleColourId){this.inWishlist=payload.inWishlist}},trackClick(){$(document).trigger('psevent',['productClick',this.styleColour.variant.gadata])}},});Vue.component('popup-add-to-wishlist',{template:'#vc-component-popup-add-to-wishlist',props:{styleColour:{type:Object,required:!0,},},computed:{wishlistCtaLabel(){var wishlistCtaLabel='Add to';var wishlistId=this.fields.wishlistId
var wishlists=this.wishlists;var stylecolourid=this.styleColour.stylecolourid;if(wishlistId!==null&&wishlists.length>0){for(var i=0;i<wishlists.length;i++){var wishlist=wishlists[i];if(wishlist.customerwishlistid===wishlistId){var products=wishlist.product;if(products){products.forEach(function(product){if(product.stylecolour.stylecolourid===stylecolourid){wishlistCtaLabel='Remove from'}})}
break}}}
if(this.fields.label!==''){wishlistCtaLabel='Add to'}
return wishlistCtaLabel},},created(){this.getWishlists()},data(){return{fields:{wishlistLabel:'',wishlistId:null,label:'',},success:'',errors:{label:'',},wishlists:[]}},methods:{getWishlists(){var self=this;$.ajax({url:'/customerapi/getwishlistitems',type:'GET',dataType:'json',success:function(response){if(response.status){var items=response.data.items;var arr=[];for(var i=0;i<Object.keys(items).length;i++){arr.push(items[Object.keys(items)[i]])}
self.wishlists=arr;if(self.wishlists.length>0){self.fields.wishlistLabel=self.wishlists[0].label;self.fields.wishlistId=self.wishlists[0].customerwishlistid}}else{self.wishlistsMessage=response.data.message}},})},closePopup(){this.$emit('close-popup')},wishlistSuccess(){this.$emit('wishlist-success')},selectWishlist(value){this.fields.wishlistLabel=value.label;this.fields.wishlistId=value.customerwishlistid},toggleWishlist(){var self=this;peppercheckout.globals.$eventbus.$emit('togglewishlistitem',{stylecolourid:this.styleColour.stylecolourid,wishlistid:this.fields.wishlistId},function(response){if(response.status){self.inWishlist=!self.inWishlist;self.wishlistSuccess();self.success='Added To Wishlist'}else{GlobalEventBus.$emit('show-login')}})},submitForm(){var self=this;self.errors.label='';if(self.fields.label!==''){$.ajax({url:'/customerapi/createwishlistlist',type:'post',dataType:'json',data:{label:self.fields.label},success:function(response){if(response.status){self.fields.wishlistLabel=response.data.wishlist.label;self.fields.wishlistId=response.data.wishlist.customerwishlistid;self.$nextTick(function(){self.toggleWishlist({stylecolour:self.styleColour.stylecolourid,wishlistid:self.fields.wishlistId})})}else{self.errors.label=response.data.message}},})}else{self.toggleWishlist({stylecolour:self.styleColour.stylecolourid,wishlistid:self.fields.wishlistId})}},},});Vue.component('product-flag',{template:'#vc-component-product-flag',props:{flag:{type:Object,default(){return{}},},},computed:{flagClass(){if(!this.flag.text)return'';return's-flag--'+this.flag.text.replace(' ','-').toLowerCase()},style(){var styles={};if(this.flag.bgcolourcode){styles.backgroundColor=this.flag.bgcolourcode}
if(this.flag.colourcode){styles.color=this.flag.colourcode}
return styles}},});Vue.component('product-intro-offer',{template:'#vc-component-product-intro-offer',props:{isCategory:{type:Boolean,default:!1,},labelIntro:{type:String,default:'now',},labelAfter:{type:String,default:'after sale',},introPrice:{required:!0,},afterPrice:{required:!0,},},});Vue.component('site-breadcrumbs',{template:'#vc-component-site-breadcrumbs',props:{breadcrumbs:{type:Array,default(){return[]},},},});Vue.component('product-slider',{template:'#vc-component-product-slider',props:{label:{type:String,default:'',},items:{type:Array,default(){return[]},},},data(){return{options:{arrows:!1,centerMode:!0,centerPadding:'8px',infinite:!1,slidesToShow:1.5,slidesToScroll:1,mobileFirst:!0,responsive:[{breakpoint:ps.breakpoints.md,settings:{arrows:!0,centerMode:!1,infinite:!1,prevArrow:'<button type="button" class="s-slider-arrow s-slider-arrow--prev" aria-label="Previous"><span class="icon-arrow-left"></button>',nextArrow:'<button type="button" class="s-slider-arrow s-slider-arrow--next" aria-label="Next"><span class="icon-arrow-right"></button>',slidesToShow:3,slidesToScroll:3,},},{breakpoint:900,settings:{arrows:!0,centerMode:!1,infinite:!1,prevArrow:'<button type="button" class="s-slider-arrow s-slider-arrow--prev" aria-label="Previous"><span class="icon-arrow-left"></button>',nextArrow:'<button type="button" class="s-slider-arrow s-slider-arrow--next" aria-label="Next"><span class="icon-arrow-right"></button>',slidesToShow:5,slidesToScroll:5,},},],},}},});const siteCartSummary=Vue.component('cart-summary').extend({templateOverride:'#vc-component-cart-summary',});const siteCheckoutRewardsSummary=Vue.component('checkout-rewards-summary',{template:'#vc-component-checkout-rewards-summary',computed:{points(){return this.$store.state.customerdata.rewards.earnable},},});const siteCheckoutOrderRows=Vue.component('checkout-order-rows').extend({templateOverride:'#vc-component-checkout-order-rows',});const siteCheckoutBasketItem=Vue.component('checkout-basket-item').extend({templateOverride:'#vc-component-checkout-basket-item',methods:{isNumber(evt){evt=(evt)||window.event;const charCode=(evt.which)?evt.which:evt.keyCode;if((charCode>31&&(charCode<48||charCode>57))&&charCode!==46){evt.preventDefault()}else{return!0}},getStoreStatus(status){const statuses={instock:'In Stock',outofstock:'Not in Stock',lowstock:'Low Stock',notavailable:'Not Available',};return statuses[status]},},});Vue.component('checkout-rewards-summary',siteCheckoutRewardsSummary);Vue.component('checkout-cart-summary',siteCartSummary);Vue.component('checkout-order-rows',siteCheckoutOrderRows);Vue.component('checkout-basket-item',siteCheckoutBasketItem);new Vue({el:'#v-product-wishlist',name:'Product Wishlist',data(){return{wishlistPopupVisible:!1,styleColour:{},inWishlist:!1}},mounted(){GlobalEventBus.$on('product-wishlist:open',this.openProductWishlist)},methods:{openProductWishlist(payload){this.styleColour=payload.styleColour;this.inWishlist=payload.inWishlist;this.wishlistPopupVisible=!0},closePopup(){this.wishlistPopupVisible=!1},wishlistSuccess(){GlobalEventBus.$emit('product-wishlist:success',{styleColourId:this.styleColour.stylecolourid,inWishlist:!this.inWishlist})}},})}(jQuery))