var $=jQuery.noConflict(),ST_WC_FRONT_SWATCH=ST_WC_FRONT_SWATCH||{},ST_WC_Chosen_attribute="",ST_WC_Show_selected_title=!1,ST_WC_Triggered_variations=[];!function(m){"use strict";ST_WC_FRONT_SWATCH.onSelect=function(){m("body").on("click","ul.st-swatch-preview:not(.et_linked-swatches) span.st-custom-attribute",function(){var t,e,a,s;m(this).parents().is(".swiper-entry, .products-loop, .etheme-product-grid-item, .etheme-product-list-item")||(t=m(this).closest("[data-attribute]").data("attribute"),t=m("select#"+t),e=m(this).data("value"),a=m(this).parent("li"),s=m(this).parents(".variations_form.cart").attr("data-product_variations"),null==e||t.find('option[value="'+e+'"]').length?(a.hasClass("selected")?(a.removeClass("selected"),t.val(" "),1==sten_wc_params.is_singular_product&&(sten_wc_params.is_customize_preview&&a.css({"border-color":a.data("border-color")}),ST_WC_Show_selected_title)&&a.parents("tr").find(" > th label").attr("data-swatch-name",null)):(a.addClass("selected").siblings().removeClass("selected"),t.val(e),1==sten_wc_params.is_singular_product&&(sten_wc_params.is_customize_preview&&(a.removeAttr("style"),a.siblings().css({"border-color":a.data("border-color")}),a.css({"border-color":a.data("active-border-color")})),ST_WC_Show_selected_title)&&a.parents("tr").find("> th label").attr("data-swatch-name",null).attr("data-swatch-name",m(this).attr("data-name")),ST_WC_Chosen_attribute=m(this).closest("[data-attribute]").data("attribute")),!sten_wc_params.stock_logic&&"false"===s&&etConfig.woocommerceSettings.primary_attribute&&"et_none"!=etConfig.woocommerceSettings.primary_attribute&&(m("footer").append(''),jQuery(document).on("found_variation",function(t,e){setTimeout(function(){m(".et-temp-style_single-product").remove()},50)})),t.trigger("change"),sten_wc_params.stock_logic&&m(".variations_form").find("ul.st-swatch-preview").each(function(t,e){ST_WC_FRONT_SWATCH.singleProductUpdateAttribute(e),a.removeClass("sten-li-disabled")})):(t.val(" ").trigger("change"),a.siblings().removeClass("selected"),window.alert(sten_wc_params.i18n_no_matching_variations_text)))}),m(document).on("click",".etheme-sticky-cart .st-custom-attribute",function(){var t=m(document).find(".et_product-block .woocommerce-variation-add-to-cart");(t.hasClass("disabled")||t.hasClass("woocommerce-variation-add-to-cart-disabled"))&&m(document).find(".etheme-sticky-cart .single_add_to_cart_button").addClass("disabled")})},ST_WC_FRONT_SWATCH.singleProductPrimaryAttribute=function(){m(document).find(".variations_form.cart").on("reset_data",function(){var s=m(this);etConfig.woocommerceSettings.primary_attribute&&"et_none"!=etConfig.woocommerceSettings.primary_attribute&&ST_WC_Chosen_attribute=="pa_"+etConfig.woocommerceSettings.primary_attribute&&(ST_WC_Chosen_attribute="",setTimeout(function(){var t,e=ST_WC_FRONT_SWATCH.productLoop.getChosenAttributes(s),a=e.data;(!sten_wc_params.stock_logic||e.count&&e.chosenCount&&e.count!=e.chosenCount)&&(e=m.parseJSON(s.attr("data-product_variations")),e=ST_WC_FRONT_SWATCH.productLoop.findMatchingVariations(e,a).shift(),a=m(".woocommerce-main-image").first(),t=m(".thumbnail-item a").first(),!sten_wc_params.stock_logic&&void 0===e||(a.find("img").attr("data-o_src")||a.find("img").attr("data-o_data-src")||(a.attr("data-o_href",a.attr("href")),a.find("img").attr({"data-o_src":a.find("img").attr("src"),"data-o_data-src":a.find("img").attr("src"),"data-o_data-large_image":a.find("img").attr("data-large_image")})),a.attr("href",e.image.full_src),a.find("img").attr({src:e.image.src,"data-src":e.image.src,"data-large_image":e.image.full_src,srcset:""}),sten_wc_params.stock_logic||m(".woocommerce-main-image.pswp-main-image").find("img").attr({src:e.image.full_src,srcset:""}),a.parent().find("img.zoomImg").attr("src",a.find("img").attr("data-large_image")),t.attr("href",e.image.full_src).attr("data-large",e.image.full_src).attr("data-small",e.image.gallery_thumbnail_src),t.find("img").attr("src",e.image.gallery_thumbnail_src).attr("srcset",e.image.gallery_thumbnail_src)))},50))})},ST_WC_FRONT_SWATCH.onSelectUpdateAttribute=function(){sten_wc_params.stock_logic||m(document).on("show_variation","form.variations_form",function(t,e){var a=m(".woocommerce-main-image.pswp-main-image img");a.attr("src",e.image.full_src),a.attr("srcset",e.image.full_src),a.attr("data-src",e.image.full_src),a.attr("data-srcset",e.image.full_src)}),m(document).on("woocommerce_update_variation_values","form.variations_form",function(){m(this).find("ul.st-swatch-preview").each(function(){var t=m(this).data("attribute"),t=document.getElementById(t),e=m(t).find("option"),a=m(t).find("option").eq(1),s=m(this).find("li"),i=m(t).find("option:selected"),r=[],o="";e.each(function(){""!==m(this).val()&&(r.push(m(this).val()),o=(i||a).val())}),s.each(function(){var t=this,e=m(t).find("span.st-custom-attribute").attr("data-value");m(t).removeClass("selected sten-li-disabled").addClass("sten-li-disabled"),-1!==r.indexOf(e.toString())&&(m(t).removeClass("sten-li-disabled"),e.toString()==o)&&(m(t).addClass("selected"),!sten_wc_params.stock_logic)&&ST_WC_Show_selected_title&&s.parents("tr").find(" > th label").attr("data-swatch-name",m(t).children().attr("data-name"))})})})},ST_WC_FRONT_SWATCH.singleProductUpdateAttribute=function(t){var e,a=m.parseJSON(m(t).parents(".variations_form").attr("data-product_variations")),s=ST_WC_FRONT_SWATCH.productLoop.getChosenAttributes(m(t).parents(".variations_form")).data,s=m.extend(!0,{},s),i=ST_WC_FRONT_SWATCH.productLoop.findMatchingVariations(a,s),r="attribute_"+m(t).data("attribute");for(e in i)if(void 0!==i[e]){var o,n,d=i[e].attributes;for(o in d)d.hasOwnProperty(o)&&(n=d[o],o!==r||i[e].is_in_stock||m(t).find('span.st-custom-attribute[data-value="'+n+'"]').parent().hasClass("sten-li-enabled")||m(t).find('span.st-custom-attribute[data-value="'+n+'"]').parent().addClass("sten-li-disabled"))}},ST_WC_FRONT_SWATCH.onClear=function(){m(document).on("click","form.variations_form a.reset_variations",function(){var t=m(this).parents("form.variations_form"),e=t.find("ul.st-swatch-preview li.selected");e.removeClass("selected"),1==sten_wc_params.is_singular_product&&(sten_wc_params.is_customize_preview&&e.css({"border-color":e.data("border-color")}),ST_WC_Show_selected_title&&t.find("label[data-swatch-name]").attr("data-swatch-name",null),sten_wc_params.stock_logic||m(document).find("a.reset_variations").css("visibility","hidden"))})},ST_WC_FRONT_SWATCH.productLoop={init:function(){ST_WC_FRONT_SWATCH.productLoop.itemSwatches(),ST_WC_FRONT_SWATCH.productLoop.addToCart(),ST_WC_FRONT_SWATCH.productLoop.showMoreAttr()},itemSwatches:function(){m("div.st-swatch-in-loop").each(function(){var i=m(this),t=i.find("span.st-custom-attribute:not(.sten-disabled)"),r=i.find("a.sten-reset-loop-variation, .et-delete"),o=i.closest(".product-type-variable, .product-type-variable-subscription"),n=m.parseJSON(i.attr("data-product_variations")),e=i.find("ul.has-default-attribute"),a=i.find(".et_st-select-holder");if(o.find("a.add_to_cart_button").addClass("et-st-disabled"),m(".st-swatch-btn-ready").removeClass("et-st-disabled"),ST_WC_FRONT_SWATCH.productLoop.updateAttributes(i,n),a.length){if(1==a.length)a.removeClass("hidden"),a.find("li.type-select").each(function(){var t=m(this).find(".st-attribute-price"),e=t.find(">span").clone();t.html(e)});else{let t=!1;a.each(function(){m(this).find("ul.has-default-attribute").length?(m(this).removeClass("hidden"),m(this).data("was-changed",!0).parent().find(".et_st-select-holder.hidden").first().removeClass("hidden"),t=!0):m(this).addClass("hidden")}),t||a.first().removeClass("hidden")}a.last().addClass("et_st-select-holder-last"),i.find(".et_st-default-holder:not(.et_st-select-holder)").length||(o.addClass("has-select-swatch-only"),i.find("a.sten-reset-loop-variation").addClass("hidden"),o.find("a.add_to_cart_button").text(sten_wc_params.add_to_cart_btn_text))}e.each(function(){var t=m(this).parent("div.st-swatch-in-loop").find("a.sten-reset-loop-variation"),e=(t.show(),ST_WC_FRONT_SWATCH.productLoop.getChosenAttributes(i)),a=e.data;e.count===e.chosenCount?(ST_WC_FRONT_SWATCH.productLoop.updateAttributes(i,n),(e=ST_WC_FRONT_SWATCH.productLoop.findMatchingVariations(n,a).shift())?ST_WC_FRONT_SWATCH.productLoop.foundVariation(o,i,e):t.trigger("click")):ST_WC_FRONT_SWATCH.productLoop.updateAttributes(i,n)}),t.on("click",function(){var t=m(this),e=t.parent("li"),a=e.parents(".et_st-select-holder"),s=!!a.length&&a.find(".et_st-swatch-select-title");if(t.hasClass("sten-disabled"))return!1;o.find("span.st-custom-attribute").removeClass("sten-disabled sten-enabled"),o.find("span.st-custom-attribute").parent("li").removeClass("sten-li-disabled sten-li-enabled"),e.hasClass("selected")&&sten_wc_params.is_customize_preview&&e.css({"border-color":e.data("border-color")}),e.hasClass("selected")||(e.addClass("selected").siblings().removeClass("selected"),s&&s.html(m(this).html()),a.length&&(a.data("was-changed")||a.data("was-changed",!0).parent().find(".et_st-select-holder.hidden").first().removeClass("hidden"),a.find(".et_st-swatch-select-list").addClass("hidden"),setTimeout(function(){a.find(".et_st-swatch-select-wrapper").removeClass("active"),a.find(".et_st-swatch-select-list").removeClass("hidden")},300)),sten_wc_params.is_customize_preview&&(e.removeAttr("style"),e.siblings().css({"border-color":e.data("border-color")}),e.css({"border-color":e.data("active-border-color")})),r.slideDown());var t=ST_WC_FRONT_SWATCH.productLoop.getChosenAttributes(i),s=t.data;t.count===t.chosenCount?(ST_WC_FRONT_SWATCH.productLoop.updateAttributes(i,n),(e=ST_WC_FRONT_SWATCH.productLoop.findMatchingVariations(n,s).shift())?ST_WC_FRONT_SWATCH.productLoop.foundVariation(o,i,e):r.trigger("click")):(etConfig.woocommerceSettings.primary_attribute&&"et_none"!=etConfig.woocommerceSettings.primary_attribute&&m(this).closest("[data-attribute]").data("attribute")=="pa_"+etConfig.woocommerceSettings.primary_attribute&&(t=ST_WC_FRONT_SWATCH.productLoop.findMatchingVariations(n,s).shift(),ST_WC_FRONT_SWATCH.productLoop.variationsImageUpdate(o,t)),ST_WC_FRONT_SWATCH.productLoop.updateAttributes(i,n))}),r.on("click",function(){i.removeAttr("data-variation_id"),sten_wc_params.is_customize_preview&&(t=i.find("ul.st-swatch-preview li.selected")).css({"border-color":t.data("border-color")}),i.find(".et_st-swatch-select-title").text(sten_wc_params.select_options_btn_text),sten_wc_params.show_select_type_price&&o.removeClass("hide-product-price"),i.find("ul.st-swatch-preview li").removeClass("selected sten-li-disabled sten-li-enabled"),i.find("ul.st-swatch-preview span").removeClass("sten-disabled sten-enabled");var t=o.find("a.add_to_cart_button");let e=t;o.is(".etheme-product-grid-item, .etheme-product-list-item")&&(e=o.find(".st-swatch-popup").length&&!o.find(".st-swatch-popup .quantity-wrapper").length?o.find(".st-swatch-in-loop a.add_to_cart_button"):o.find(".etheme-product-grid-button .button-text, .etheme-product-list-button .button-text")),t.addClass("et-st-disabled").removeClass("st-swatch-btn-ready st-swatch-btn-readmore st-swatch-btn-text-changed added loading").attr("aria-label",sten_wc_params.select_options_btn_text+" "+sten_wc_params.read_more_for_btn_text+' "'+t.attr("data-product_name")+'"'),e.text(sten_wc_params.select_options_btn_text),o.find("a.added_to_cart").remove();var t=o.find("span.price").not(".price-cloned"),a=o.find(".price-cloned");a.length&&(t.html(a.html()),a.remove()),etConfig.woocommerceSettings.wishlist_for_variations&&i.trigger("reset_data"),n=m.parseJSON(i.attr("data-product_variations")),ST_WC_FRONT_SWATCH.productLoop.updateAttributes(i,n),ST_WC_FRONT_SWATCH.productLoop.variationsImageUpdate(o,!1),ST_WC_FRONT_SWATCH.productLoop.variationsCountdownUpdate(o,!1),ST_WC_FRONT_SWATCH.productLoop.variationsLoopQty(o,!1),m(this).slideUp()})})},getChosenAttributes:function(t){var a={},s=0,i=0;return t.find("ul.st-swatch-preview").each(function(){var t="attribute_"+m(this).data("attribute"),e=m(this).find("li.selected span.st-custom-attribute").attr("data-value")||"";0<(e=e.toString()).length&&i++,s++,a[t]=e}),{count:s,chosenCount:i,data:a}},updateAttributes:function(t,l){var p,u=ST_WC_FRONT_SWATCH.productLoop.getChosenAttributes(t).data;t.find("ul.st-swatch-preview").each(function(t,e){var a,s=m(e),i="attribute_"+s.data("attribute"),e=s.find("li.selected span.st-custom-attribute").data("value"),r=!0,o=m.extend(!0,{},u),n=(o[i]="",ST_WC_FRONT_SWATCH.productLoop.findMatchingVariations(l,o));for(a in n)if(void 0!==n[a]){var d,c,_=n[a].attributes;for(d in _)_.hasOwnProperty(d)&&(c=_[d],d===i)&&(n[a].variation_is_active,n[a].is_in_stock)&&(c?s.find('span.st-custom-attribute[data-value="'+c+'"]'):s.find("span.st-custom-attribute")).addClass("sten-enabled")}p=s.find("span.st-custom-attribute.sten-enabled").length,!e||0!==p&&0!==s.find('span.st-custom-attribute.sten-enabled[data-value="'+ST_WC_FRONT_SWATCH.productLoop.addSlashes(e)+'"]').length||(r=!1),s.find("span.st-custom-attribute:not(.sten-enabled)").addClass("sten-disabled"),s.find("span.st-custom-attribute:not(.sten-enabled)").parent("li").addClass("sten-li-disabled"),e&&r||s.find("li.selected").removeClass("selected")})},findMatchingVariations:function(t,e){for(var a=[],s=0;s=e||""==e)?m(this).attr("disabled",null):i.val(i.find("option:not([disabled]):first").val())})}else i.attr("min",s.min_qty),i.attr("max",s.max_qty),s.max_qty