"use strict";if(void 0===woostifyEvent)var woostifyEvent={};var productMetaSku=document.querySelector(".elementor-widget-woostify-product-meta .sku");function productVariation(e,t){var o=document.querySelectorAll(e);if(o.length){var r=o[0],i=r.getAttribute("data-pid"),a=t||'form.variations_form[data-product_id="'+i+'"]';jQuery(document.body).on("found_variation",a,(function(t,o){var r=document.querySelectorAll(e);if(r.length&&document.querySelector(a)){var i=o.image.src,c=o.image.full_src,n=o.is_in_stock;o.image.src_h;i&&c&&r.forEach((function(e,t){var r=e.querySelector(woostify_product_images_slider_options.thumb.container);r&&r.children.length&&r.children[0].click();var a=null==r?e.querySelector(".image-item"):e.querySelector(".image-item.is-selected");if(null!=a){var u=!!a&&a.querySelector("img"),l=(u&&u.getAttribute("src"),u?u.getAttribute("srcset"):""),s=a.querySelector("a"),d=(s&&s.getAttribute("href"),e.querySelector(".thumbnail-item")),m=!!d&&d.querySelector("img");m&&m.getAttribute("src");o.max_qty&&(woostify_woocommerce_general.qty_max_warning=woostify_woocommerce_general.qty_max_warning_variation.replace("%s",o.max_qty)),document.querySelectorAll(".single_add_to_cart_button").forEach((e=>e.value=o.variation_id));var y=document.querySelectorAll(".elementor-widget-woostify-product-meta .sku"),_=document.querySelectorAll(".wpm_gtin_code_wrapper .wpm_pgw_code");if(y&&y.forEach((function(e){e.innerHTML=o.sku})),_&&(_.forEach((function(e){e.innerHTML=o.sku})),o.wpm_pgw_code&&(wpmGtinCodeWrapper.innerHTML=o.wpm_pgw_code)),s&&s.setAttribute("href",c),u&&i){a.classList.add("image-loading");var f=a.closest(".flickity-viewport"),g=new Image;g.onload=function(){a.classList.remove("image-loading"),setTimeout((function(){null!=f&&(f.style.height=u.height+"px")}),50)},g.src=i,u.setAttribute("src",i),l&&u.setAttribute("srcset",o.image.srcset)}m&&m.setAttribute("src",o.image.thumb_src),"function"==typeof easyZoomHandle&&easyZoomHandle();var p=!!e&&e.querySelector(".product-images"),w=!!p&&p.querySelector(".woostify-out-of-stock-label"),v=!!p&&p.querySelector(".woostify-tag-on-sale");if(n)o.max_qty&&"function"==typeof woostifyStockQuantityProgressBar&&setTimeout((function(){woostifyStockQuantityProgressBar()}),300),w&&w.remove(),v&&"undefined"!=typeof woostify_woocommerce_variable_product_data&&woostify_woocommerce_variable_product_data.sale_tag_percent&&o.display_price!=o.display_regular_price&&(v.innerHTML="-"+Math.round((o.display_regular_price-o.display_price)/o.display_regular_price*100)+"%");else if("undefined"!=typeof woostify_woocommerce_variable_product_data){var S='<span class="woostify-out-of-stock-label position-'+woostify_woocommerce_variable_product_data.out_of_stock_display+" "+woostify_woocommerce_variable_product_data.out_of_stock_square+'">'+woostify_woocommerce_variable_product_data.out_of_stock_text+"</span>";w||p.insertAdjacentHTML("beforeend",S)}}}))}})),jQuery(".single_variation_wrap").on("show_variation",(function(e,t){if(t){var o=document.querySelector(".reset_variations");o&&(o.style.visibility="visible")}}));var c="",n="";if(r){var u=r.querySelector(".thumbnail-item"),l=u&&0!=u.length?r.querySelector(".image-item"):r.querySelector(".image-item.is-selected");n=u&&0!=u.length?u.cloneNode(!0):null,c=l?l.cloneNode(!0):null}jQuery(".reset_variations").on("click",(function(e){if(woostifyEvent.productVariationReady){e.preventDefault(),woostify_woocommerce_general.qty_max_warning=woostify_woocommerce_general.qty_max_warning_default;var t=document.querySelectorAll(".elementor-widget-woostify-product-meta .sku"),o=document.querySelector(".wpm_gtin_code_wrapper .wpm_pgw_code");t&&t.forEach((function(e){e.innerHTML=woostifyEvent.productMetaSkuDefault})),o&&o.forEach((function(e){e.innerHTML=woostifyEvent.productMetaSkuDefault})),setTimeout((function(){var e=document.querySelector(".product-gallery"),t=e.querySelector(".thumbnail-item"),o=t&&0!=t.length?e.querySelector(".image-item"):e.querySelector(".image-item.is-selected"),r=!!o&&o.querySelector("img");if(null!=o){if(r){var i=!!c&&c.querySelector("img"),a=r?r.getAttribute("src"):"",u=r?r.getAttribute("srcset"):"";a=i?i.getAttribute("src"):a,u=i?i.getAttribute("srcset"):u,o.classList.add("image-loading");var l=new Image;l.onload=function(){o.classList.remove("image-loading")},l.src=a,r.setAttribute("src",a),u&&r.setAttribute("srcset",u)}var s=!!t&&t.querySelector("img"),d=s?s.getAttribute("src"):"",m=!!n&&n.querySelector("img");d=m?m.getAttribute("src"):d,s&&s.setAttribute("src",d);var y=o.querySelector("a"),_=y?y.getAttribute("href"):"",f=!!c&&c.querySelector("a");(_=f?f.getAttribute("href"):_)&&y.setAttribute("href",_),"function"==typeof easyZoomHandle&&easyZoomHandle(),"function"==typeof initPhotoSwipe&&initPhotoSwipe(".product-images-container");new WoostifyGallery(".product-gallery",woostify_product_images_slider_options);var g=document.querySelector(".woostify-variation-swatches");g&&g.querySelectorAll(".swatch").forEach((function(e,t){e.classList.remove("selected")}))}}),150)}})),woostifyEvent.productVariationReady=1}}woostifyEvent.productMetaSkuDefault=productMetaSku?productMetaSku.innerHTML:"",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")}))})))}));