"use strict";if(void 0===woostifyEvent)var woostifyEvent={};function productVariation(selector,form){var gallery=document.querySelector(selector);if(gallery){var currProductID=gallery.getAttribute("data-pid"),variationsForm=form||'form.variations_form[data-product_id="'+currProductID+'"]';if(jQuery(variationsForm).length){var imageWrapper=gallery.querySelector(".image-item");if(null!=imageWrapper){var image=!!imageWrapper&&imageWrapper.querySelector("img"),imageSrc=image?image.getAttribute("src"):"",imageSrcset=image?image.getAttribute("srcset"):"",photoSwipe=imageWrapper.querySelector("a"),photoSwipeSrc=photoSwipe?photoSwipe.getAttribute("href"):"",thumb=gallery.querySelector(".thumbnail-item"),thumbImg=!!thumb&&thumb.querySelector("img"),thumbSrc=thumbImg?thumbImg.getAttribute("src"):"";if(jQuery(variationsForm).length){var productMetaSku=document.querySelector(".elementor-widget-woostify-product-meta .sku"),productMetaSkuDefault=productMetaSku?productMetaSku.innerHTML:"",wpmGtinCodeWrapper=document.querySelector(".wpm_gtin_code_wrapper .wpm_pgw_code");wpmGtinCodeWrapper&&(wpmGtinCodeWrapper.innerHTML=productMetaSkuDefault),jQuery(document.body).on("found_variation",variationsForm,(function(event,variation){var buttons;variation.max_qty&&(woostify_woocommerce_general.qty_max_warning=woostify_woocommerce_general.qty_max_warning_variation.replace("%s",variation.max_qty)),document.querySelectorAll(".single_add_to_cart_button").forEach(elm=>elm.value=variation.variation_id);var imgSrc=variation.image.src,fullSrc=variation.image.full_src,inStock=variation.is_in_stock;if(imgSrc&&fullSrc){if(productMetaSku&&(productMetaSku.innerHTML=variation.sku),wpmGtinCodeWrapper&&variation.wpm_pgw_code&&(wpmGtinCodeWrapper.innerHTML=variation.wpm_pgw_code),photoSwipe&&photoSwipe.setAttribute("href",fullSrc),image&&imgSrc){imageWrapper.classList.add("image-loading");var img=new Image;img.onload=function(){imageWrapper.classList.remove("image-loading")},img.src=imgSrc,image.setAttribute("src",imgSrc),imageSrcset&&image.setAttribute("srcset",variation.image.srcset)}thumbImg&&thumbImg.setAttribute("src",variation.image.thumb_src),"function"==typeof easyZoomHandle&&easyZoomHandle();var jsSelector=document.querySelector(selector),productImages=!!jsSelector&&jsSelector.querySelector(".product-images"),outStockLabel=!!productImages&&productImages.querySelector(".woostify-out-of-stock-label"),onSaleLabel=!!productImages&&productImages.querySelector(".woostify-tag-on-sale");if(inStock)variation.max_qty&&"function"==typeof woostifyStockQuantityProgressBar&&setTimeout((function(){woostifyStockQuantityProgressBar()}),200),outStockLabel&&outStockLabel.remove(),onSaleLabel&&woostify_woocommerce_variable_product_data.sale_tag_percent&&variation.display_price!=variation.display_regular_price&&(onSaleLabel.innerHTML="-"+Math.round((variation.display_regular_price-variation.display_price)/variation.display_regular_price*100)+"%");else if("undefined"!=typeof woostify_woocommerce_variable_product_data){var outStockLabelHtml=''+woostify_woocommerce_variable_product_data.out_of_stock_text+"";outStockLabel||productImages.insertAdjacentHTML("beforeend",outStockLabelHtml)}}})),jQuery(".reset_variations").off("click").on("click",(function(e){if(e.preventDefault(),woostify_woocommerce_general.qty_max_warning=woostify_woocommerce_general.qty_max_warning_default,productMetaSkuDefault&&(productMetaSku.innerHTML=productMetaSkuDefault),wpmGtinCodeWrapper&&(wpmGtinCodeWrapper.innerHTML=productMetaSkuDefault),image){imageWrapper.classList.add("image-loading");var resetImg=new Image;resetImg.onload=function(){imageWrapper.classList.remove("image-loading")},resetImg.src=imageSrc,image.setAttribute("src",imageSrc),imageSrcset&&image.setAttribute("srcset",imageSrcset)}thumbSrc&&thumbImg.setAttribute("src",thumbSrc),photoSwipeSrc&&photoSwipe.setAttribute("href",photoSwipeSrc),"function"==typeof easyZoomHandle&&easyZoomHandle()})),woostifyEvent.productVariationReady=1}}}}}document.addEventListener("DOMContentLoaded",(function(){woostifyEvent.productVariationReady||(productVariation(".product-gallery"),"function"==typeof onElementorLoaded&&onElementorLoaded((function(){woostifyEvent.productVariationReady||window.elementorFrontend.hooks.addAction("frontend/element_ready/global",(function(){productVariation(".product-gallery")}))})))}));