(function($){Vue.component('product-flag',{template:'#vc-component-product-flag',props:{flag:{type:Object,default:function(){return{}}}},computed:{flagName:function(){return this.flag.text.replace(' ','-').toLowerCase()}}});Vue.component('product-timer',{template:'#vc-component-product-timer',props:{timer:{type:String},isProduct:{type:Boolean}},computed:{},data:function(){return{intervalId:"",days:'',hours:'',minutes:'',daysInterger:0,isMobile:!1,}},methods:{addToCart:function(barcode,quantity){peppercheckout.globals.$eventbus.$emit('addproducttocart',{variantid:barcode,quantity:quantity})},countdownTimer:function(endDate,targetid){var days,hours,minutes;if(isNaN(endDate)){return}
var self=this;self.calculate(endDate);this.intervalId=window.setInterval(function(){self.calculate(endDate)},60000)},calculate:function(endDate){var startDate=new Date();startDate=startDate.getTime();var timeRemaining=parseInt((endDate-startDate)/1000);if(timeRemaining>=0){days=parseInt(timeRemaining/86400);timeRemaining=(timeRemaining%86400);hours=parseInt(timeRemaining/3600);timeRemaining=(timeRemaining%3600);minutes=parseInt(timeRemaining/60);timeRemaining=(timeRemaining%60);this.daysInterger=days
this.days=('0'+days).slice(-2);this.hours=('0'+hours).slice(-2);this.minutes=('0'+minutes).slice(-2)}else{this.$emit('no-time-remaining');clearInterval(this.intervalId)}},setMobile:function(){this.isMobile=!0},unsetMobile:function(){this.isMobile=!1},},mounted:function(){this.countdownTimer(parseInt(this.timer)*1000);enquire.register('(max-width: '+ps.breakpoints.md+'px)',{match:this.setMobile,unmatch:this.unsetMobile,})},});Vue.component('star-rating',{template:'#vc-component-star-rating',props:{rating:{type:Number,required:!0},max:{type:Number,default:5}},computed:{ratingArray:function(){return this.rating.toString().split('.')},fullStars:function(){return parseInt(this.ratingArray[0],10)},halfStars:function(){return this.ratingArray[1]?1:0},emptyStars:function(){return this.max-this.fullStars-this.halfStars}},});Vue.component('product-item',{template:'#vc-component-product-item',props:{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:function(){return{selectedSize:'',categorySliderOptions:{arrows:!0,dots:!1,infinite:!1,mobileFirst:!0,prevArrow:'<button type="button" class="s-slider-arrow s-slider-arrow--prev" aria-label="Previous"><span class="icon-arrow-left s-slider-arrow__icon"></span></button>',nextArrow:'<button type="button" class="s-slider-arrow s-slider-arrow--next" aria-label="Next"><span class="icon-arrow-right s-slider-arrow__icon"></span></button>',},timeLeft:!0,}},computed:{styleColour:function(){return this.product.stylecolour},productsInStock:function(){return this.styleColour.variants.filter(function(variant){return variant.status!=='backinstock'})},currencyType:function(){var variants=Object.values(this.styleColour.variants);return variants[0].currency},lowestBaseUnitPrice:function(){return this.getLowestAmount(Object.values(this.styleColour.variants),'baseunitprice')},lowestUnitPrice:function(){return this.getLowestAmount(Object.values(this.styleColour.variants),'unitprice')},colourSwatches:function(){if(!this.styleColour.attributes||!this.styleColour.attributes.colourswatches)return[];return this.styleColour.attributes.colourswatches},maxColourSwatches:function(){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:function(){return this.styleColour.primaryimage},imageWide:function(){return this.styleColour.imageswide},gaImpressionData:function(){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:function(){for(key in this.styleColour.variants){if(this.styleColour.variants[key].upsell){return this.styleColour.variants[key].upsell}}
return!1},friendlySizing:function(){return this.styleColour.variant.sizeraw.replace(/[\(\)\d+']+/g,'')}},methods:{addToCart:function(barcode,quantity){peppercheckout.globals.$eventbus.$emit('addproducttocart',{variantid:barcode,quantity:quantity})},getLowestAmount:function(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:function(images){var srcset=[];for(width in images){srcset.push(images[width]+' '+width+'w')}
return srcset.join(', ')},toggleWishlist:function(){var self=this;$.ajax({url:'/customerapi/togglewishlistitem',type:'post',dataType:'json',data:{stylecolour:self.styleColour.stylecolourid,b:self.styleColour.variant.barcode},success:function(response){if(response.status){var gaData={eventCategory:'Category Page',eventAction:'Wishlists',eventLabel:response.data.message};$(document).trigger('psevent',['categoryPageClickWishlist',gaData]);self.$store.dispatch('setWishlistStatus',self.styleColour.stylecolourid)}},error:function(){$.slideIn.open({url:'/slide-in-login',class:'slide-in-login',data:{error:'Please login or register to add this item to your wishlist'}})}})},trackClick:function(){$(document).trigger('psevent',['productClick',this.styleColour.variant.gadata])}}});Vue.component('ps-radio-group',{template:'#vc-component-radio-group',props:{id:{type:String,required:!0},group:{type:String,required:!0},label:{type:String,default:''},options:{type:[Array,Object],required:!0},trackBy:{type:String,default:''},type:{type:String,required:!0},value:{type:String,required:!0}},methods:{isSelected:function(option){if(!this.trackBy){return option===this.value}
return option[this.trackBy]===this.value},select:function(value,index){this.$emit('select',{value:value,index:index})}}});Vue.component('site-breadcrumbs',{template:'#vc-component-site-breadcrumbs',props:{breadcrumbs:{type:Array,required:!0}}});Vue.component('size-guide',{template:'#vc-component-size-guide',props:{sizes:{type:Object,default:function(){return{}}}},mounted:function(){$(window).on('resize',function(){var guideContainer=$('.size-guide-container');guideContainer.each(function(){var $this=$(this);var guideContainerWidth=$this.width();var guideWidth=$this.find('.size-guide').width();if(guideWidth>guideContainerWidth){$this.addClass('is-overflow')}else{$this.removeClass('is-overflow')}})}).trigger('resize')}})}(jQuery));var vcCombobox={template:'#vc-component-combobox',props:{error:{type:String,default:''},id:{type:String,required:!0},label:{type:String,default:''},options:{type:Array,default:function(){return[]}},value:{type:String,default:''}},data:function(){return{pointer:-1,term:'',timeoutId:null}},methods:{handleInput:function(){var self=this;clearInterval(self.timeoutId);self.timeoutId=setTimeout(function(){self.$emit('input',self.term)},500)},hideOptions:function(){this.$emit('reset')},selectPrevOption:function(){this.pointer--;if(this.pointer<0){this.pointer=this.options.length-1}},selectNextOption:function(){this.pointer++;if(this.pointer>this.options.length-1){this.pointer=0}
if(document.activeElement!==this.$refs.options){this.$refs.options.focus()}},selectOptionOnEnter:function(){this.selectOption(this.options[this.pointer]);this.$refs.input.focus()},selectOption:function(option){this.$emit('select',option);this.hideOptions()},},watch:{options:function(newVal,oldVal){if(newVal!==oldVal){this.pointer=0}},value:{handler:function(newVal,oldVal){if(newVal!==oldVal){this.term=newVal}},immediate:!0}}};var globalMixin={methods:{getSrcset:function(images){var srcset=[];for(width in images){srcset.push(images[width]+' '+width+'w')}
return srcset.join(', ')},}};var vcProductDropdownColour={template:'#vc-component-dropdown-colour',components:{'ps-dropdown':vcDropdown},props:{options:{type:Array,required:!0},styleColour:{type:Object,required:!0}},computed:{locale:function(){return this.$store.state.product.locale||'NZ'},availableColours:function(){let colourString=this.options.length>1?' colours':' colour';if(this.locale=='US'){colourString=this.options.length>1?' colors':' color'}
return'('+this.options.length+colourString+')'}},methods:{select:function(option){this.$emit('select',option.value)}}};var vcDropdown={template:'#vc-component-dropdown',props:{active:{type:Boolean,default:!1},id:{type:String,required:!0},label:{type:String,default:''},labelBy:{type:String,default:''},options:{type:[Array,Object],required:!0},type:{type:String,required:!0},trackBy:{type:String,default:''},value:{type:String,required:!0}},data:function(){return{isActive:!1,pointer:-1}},computed:{currentHighlightedOption:function(){return Object.keys(this.options)[this.pointer]},selectedOption:function(){var self=this;if(self.trackBy){return self.options.filter(function(option){return option[self.trackBy]===self.value})[0]||self.value}
return self.value}},methods:{close:function(e){if(!this.$el.contains(e.target)){this.hideOptions()}},isSelected:function(option){if(!this.trackBy){return option===this.value}
return option[this.trackBy]===this.value},toggleOptions:function(){this.isActive?this.hideOptions():this.showOptions()},showOptions:function(){var self=this;this.isActive=!0;this.$nextTick(function(){self.$refs.options.focus()})},hideOptions:function(){this.isActive=!1},selectPrevOption:function(){this.pointer--;if(this.pointer<0){this.pointer=Object.keys(this.options).length-1}},selectNextOption:function(){this.pointer++;if(this.pointer>Object.keys(this.options).length-1){this.pointer=0}},selectOptionOnEnter:function(){var highlightedOption=this.options[this.currentHighlightedOption];if(highlightedOption.disabled){this.hideOptions();return}
this.selectOption(this.options[this.currentHighlightedOption],this.currentHighlightedOption,this.pointer);this.$refs.button.focus()},selectOption:function(value,key,index){this.pointer=index||key;this.$emit('select',{value:value,index:key});this.hideOptions()}},watch:{active:function(active){this.isActive=active},isActive:function(isActive){if(isActive){document.addEventListener('click',this.close)}else{document.removeEventListener('click',this.close)}}}};var vcProductDropdownSize={template:'#vc-component-dropdown-size',components:{'ps-dropdown':vcDropdown},props:{link:{type:String,default:'/size-guide'},options:{type:Array,required:!0},variant:{type:Object,required:!0},},methods:{select:function(option){this.$emit('select',option.value)}}};var vcSlick={template:'#vc-component-slick',props:{options:{type:Object,default:function(){return{}},},defer:{type:Boolean,default:!1}},methods:{create:function(){var $slick=$(this.$el);$slick.on('afterChange',this.onAfterChange);$slick.on('beforeChange',this.onBeforeChange);$slick.on('breakpoint',this.onBreakpoint);$slick.on('destroy',this.onDestroy);$slick.on('edge',this.onEdge);$slick.on('init',this.onInit);$slick.on('reInit',this.onReInit);$slick.on('setPosition',this.onSetPosition);$slick.on('swipe',this.onSwipe);$slick.on('lazyLoaded',this.onLazyLoaded);$slick.on('lazyLoadError',this.onLazyLoadError);$slick.slick(this.options)},destroy:function(){var $slick=$(this.$el);$slick.off('afterChange',this.onAfterChange);$slick.off('beforeChange',this.onBeforeChange);$slick.off('breakpoint',this.onBreakpoint);$slick.off('destroy',this.onDestroy);$slick.off('edge',this.onEdge);$slick.off('init',this.onInit);$slick.off('reInit',this.onReInit);$slick.off('setPosition',this.onSetPosition);$slick.off('swipe',this.onSwipe);$slick.off('lazyLoaded',this.onLazyLoaded);$slick.off('lazyLoadError',this.onLazyLoadError);$(this.$el).slick('unslick')},reSlick:function(){this.destroy();this.create()},next:function(){$(this.$el).slick('slickNext')},prev:function(){$(this.$el).slick('slickPrev')},pause:function(){$(this.$el).slick('slickPause')},play:function(){$(this.$el).slick('slickPlay')},goTo:function(index,dontAnimate){$(this.$el).slick('slickGoTo',index,dontAnimate)},currentSlide:function(){return $(this.$el).slick('slickCurrentSlide')},add:function(element,index,addBefore){$(this.$el).slick('slickAdd',element,index,addBefore)},remove:function(index,removeBefore){$(this.$el).slick('slickRemove',index,removeBefore)},filter:function(filterData){$(this.$el).slick('slickFilter',filterData)},unfilter:function(){$(this.$el).slick('slickUnfilter')},getOption:function(option){$(this.$el).slick('slickGetOption',option)},setOption:function(option,value,refresh){$(this.$el).slick('slickSetOption',option,value,refresh)},setPosition:function(){$(this.$el).slick('setPosition')},onAfterChange:function(event,slick,currentSlide){this.$emit('afterChange',event,slick,currentSlide)},onBeforeChange:function(event,slick,currentSlide,nextSlide){this.$emit('beforeChange',event,slick,currentSlide,nextSlide)},onBreakpoint:function(event,slick,breakpoint){this.$emit('breakpoint',event,slick,breakpoint)},onDestroy:function(event,slick){this.$emit('destroy',event,slick)},onEdge:function(event,slick,direction){this.$emit('edge',event,slick,direction)},onInit:function(event,slick){this.$emit('init',event,slick)},onReInit:function(event,slick){this.$emit('reInit',event,slick)},onSetPosition:function(event,slick){this.$emit('setPosition',event,slick)},onSwipe:function(event,slick,direction){this.$emit('swipe',event,slick,direction)},onLazyLoaded:function(event,slick,image,imageSource){this.$emit('lazyLoaded',event,slick,image,imageSource)},onLazyLoadError:function(event,slick,image,imageSource){this.$emit('lazyLoadError',event,slick,image,imageSource)},},mounted:function(){if(!this.defer){this.create()}},destroyed:function(){if(this.$el.classList.contains('slick-initialized')){$(this.$el).slick('unslick')}}}