"use strict";if(void 0===woostifyEvent)var woostifyEvent={};function renderSlider(selector,options){var element=document.querySelectorAll(selector);if(element.length)for(var i=0,j=element.length;i',item+="',item+="",item+=""}function createThumbnails(src){var item='
';return item+='',item+="
"}function woostifyStickySummary(){if(woostify_woocommerce_general.enabled_sticky_product_summary){var gallery=document.querySelector(".has-gallery-list-layout .product-gallery.has-product-thumbnails"),summary=document.querySelector(".has-gallery-list-layout .product-summary");if(gallery&&summary&&!(window.innerWidth<992)&&!(gallery.offsetHeight<=summary.offsetHeight)){var sidebarStickCmnKy=new WSYSticky(".summary.entry-summary",{stickyContainer:".product-page-container",marginTop:parseInt(woostify_woocommerce_general.sticky_top_space),marginBottom:parseInt(woostify_woocommerce_general.sticky_bottom_space)});jQuery("form.variations_form").on("found_variation",(function(){sidebarStickCmnKy.update()}))}}}document.addEventListener("DOMContentLoaded",(function(){if(!woostifyEvent.productImagesReady){var gallery=document.querySelector(".product-gallery"),productThumbnails=document.getElementById("product-thumbnail-images"),noSliderLayout=!!gallery&&(gallery.classList.contains("column-style")||gallery.classList.contains("grid-style")),prevBtn=document.createElement("button"),nextBtn=document.createElement("button"),mobileSlider,imageCarousel,options=woostify_product_images_slider_options.main,firstImage=!!gallery&&gallery.querySelector(".image-item img"),firstImageHeight=firstImage?firstImage.offsetHeight:0,thumbCarousel,thumbOptions=woostify_product_images_slider_options.thumb;window.matchMedia("( min-width: 768px )").matches&&gallery&&gallery.classList.contains("vertical-style")&&(thumbOptions.draggable=!1),productThumbnails&&(options.on={ready:function(){changeImageCarouselButtonIcon(),window.matchMedia("( min-width: 768px )").matches&&gallery&&gallery.classList.contains("vertical-style")&&calculateVerticalSliderHeight()}},imageCarousel=new Flickity(options.container,options),calculateThumbnailTotalWidth(),gallery&&(window.matchMedia("( max-width: 767px )").matches?thumbCarousel=new Flickity(thumbOptions.container,thumbOptions):gallery.classList.contains("vertical-style")?(verticalThumbnailSliderAction(),addThumbButtons()):thumbCarousel=new Flickity(thumbOptions.container,thumbOptions))),window.addEventListener("resize",(function(){window.matchMedia("( min-width: 768px )").matches&&gallery&&gallery.classList.contains("vertical-style")&&productThumbnails&&(calculateVerticalSliderHeight(),verticalThumbnailSliderAction(),displayThumbButtons()),calculateThumbnailTotalWidth()})),carouselAction(),woostifyGalleryCarouselMobile(),window.addEventListener("load",(function(){woostifyStickySummary(),setTimeout((function(){window.dispatchEvent(new Event("resize"))}),200)})),"function"==typeof onElementorLoaded&&onElementorLoaded((function(){window.elementorFrontend.hooks.addAction("frontend/element_ready/global",(function(){document.getElementById("product-thumbnail-images")&&(renderSlider(options.container,options),window.matchMedia("( min-width: 768px )").matches&&gallery&&gallery.classList.contains("vertical-style")?calculateVerticalSliderHeight():renderSlider(thumbOptions.container,thumbOptions)),carouselAction()}))})),woostifyEvent.productImagesReady=1}function calculateVerticalSliderHeight(){var currFirstImage=!!gallery&&gallery.querySelector(".image-item img"),currFirstImageHeight=currFirstImage?currFirstImage.offsetHeight:0;currFirstImageHeight&&(productThumbnails.style.maxHeight=currFirstImageHeight+"px");var check=0,intv=0;function IsImageOk(img){return!!img.complete&&(void 0===img.naturalWidth||0!=img.naturalWidth)}intv=setInterval((function(){if(IsImageOk(currFirstImage)&&check<20){var currFirstImageHeight=currFirstImage?currFirstImage.offsetHeight:0;currFirstImageHeight&&(productThumbnails.style.maxHeight=currFirstImageHeight+"px"),clearInterval(intv)}check++}),200)}function calculateThumbnailTotalWidth(){if(productThumbnails&&gallery&&(gallery.classList.contains("horizontal-style")||window.matchMedia("( max-width: 767px )").matches)){var thumbEls=productThumbnails.querySelectorAll(".thumbnail-item"),totalWidth=0;thumbEls.length&&thumbEls.forEach((function(thumbEl){var thumbWidth=thumbEl.offsetWidth;thumbWidth+=parseInt(window.getComputedStyle(thumbEl).getPropertyValue("margin-left")),thumbWidth+=parseInt(window.getComputedStyle(thumbEl).getPropertyValue("margin-right")),totalWidth+=thumbWidth})),totalWidth>=productThumbnails.offsetWidth?(thumbOptions.groupCells="60%",thumbOptions.wrapAround=!0,thumbCarousel&&thumbCarousel.slider&&(thumbCarousel.destroy(),thumbCarousel=new Flickity(thumbOptions.container,thumbOptions))):(thumbOptions.groupCells="3",thumbOptions.wrapAround=!1,thumbCarousel&&thumbCarousel.slider&&(thumbCarousel.destroy(),thumbCarousel=new Flickity(thumbOptions.container,thumbOptions)))}}function changeImageCarouselButtonIcon(){var imageNextBtn=document.querySelector(".flickity-button.next"),imagePrevBtn=document.querySelector(".flickity-button.previous");imageNextBtn&&(imageNextBtn.innerHTML=woostify_product_images_slider_options.next_icon),imagePrevBtn&&(imagePrevBtn.innerHTML=woostify_product_images_slider_options.prev_icon)}function displayThumbButtons(){var thumbs=productThumbnails.querySelectorAll(".thumbnail-item"),totalThumbHeight=0;thumbs.length&&thumbs.forEach((function(thumb){var thumbHeight=thumb.offsetHeight;thumbHeight+=parseInt(window.getComputedStyle(thumb).getPropertyValue("margin-top")),thumbHeight+=parseInt(window.getComputedStyle(thumb).getPropertyValue("margin-bottom")),totalThumbHeight+=thumbHeight})),totalThumbHeight>productThumbnails.offsetHeight?(productThumbnails.classList.add("has-buttons"),nextBtn.style.display="block",prevBtn.style.display="block"):(productThumbnails.classList.remove("has-buttons"),nextBtn.style.display="none",prevBtn.style.display="none")}function addThumbButtons(){var productThumbnailsWrapper=productThumbnails.parentElement;prevBtn.classList.add("thumb-btn","thumb-prev-btn","prev"),prevBtn.innerHTML=woostify_product_images_slider_options.vertical_prev_icon,nextBtn.classList.add("thumb-btn","thumb-next-btn","next"),nextBtn.innerHTML=woostify_product_images_slider_options.vertical_next_icon,productThumbnailsWrapper.appendChild(prevBtn),productThumbnailsWrapper.appendChild(nextBtn),displayThumbButtons();var thumbButtons=document.querySelectorAll(".thumb-btn");thumbButtons.length&&thumbButtons.forEach((function(thumbBtn){thumbBtn.addEventListener("click",(function(){var currBtn=this;this.classList.contains("prev")?imageCarousel.previous():imageCarousel.next()}))}))}function woostifyGalleryCarouselMobile(){var mobileGallery;!document.querySelector(".has-gallery-list-layout .product-gallery.has-product-thumbnails")||window.innerWidth>991||(options.on={ready:function(){changeImageCarouselButtonIcon()}},mobileSlider=new Flickity("#product-images",options))}function verticalThumbnailSliderAction(){var thumbNav=productThumbnails,thumbNavImages=thumbNav.querySelectorAll(".thumbnail-item");thumbNavImages[0].classList.add("is-nav-selected"),thumbNavImages[0].classList.add("is-selected"),thumbNavImages.forEach((function(thumbNavImg,thumbIndex){thumbNavImg.addEventListener("click",(function(){imageCarousel.select(thumbIndex)}))}));var thumbImgHeight=0=data[i].length-1){thumbnails="";for(var x=1,y=data[i].length;x1||variation.variation_gallery_images.length&&variation.image&&variation.variation_gallery_images[0].full_src!=variation.image.full_src)updateGallery(variation.variation_gallery_images,!0,variation.variation_id),thumbs&&thumbs.classList.add("variation-gallery");else if("undefined"!=typeof woostify_default_gallery&&woostify_default_gallery.length){var images=[];variation.image?(images.push(variation.image),woostify_default_gallery.forEach((function(item,index,default_gallery){index&&images.push(item)}),images)):images=woostify_default_gallery,updateGallery(images,!0),thumbs&&thumbs.classList.remove("variation-gallery")}}})),woostifyEvent.carouselActionReady=1),jQuery(".reset_variations").on("click",(function(){"undefined"!=typeof woostify_default_gallery&&woostify_default_gallery.length&&(updateGallery(woostify_default_gallery,!0),document.querySelector(".product-thumbnail-images")&&document.querySelector(".product-thumbnail-images").classList.remove("variation-gallery")),resetCarousel(),setTimeout((function(){window.dispatchEvent(new Event("resize"))}),200),(document.body.classList.contains("elementor-editor-active")||document.body.classList.contains("elementor-editor-preview"))&&(document.getElementById("product-thumbnail-images")||document.querySelector(".product-gallery").classList.remove("has-product-thumbnails"))}))}}));