!function(e){"use strict";const t="stacked"===flatsomeVars.options.swatches_layout,s=': ',a="ontouchstart"in window;e.fn.flatsomeSwatches=function(){return this.each((function(){var a=e(this);function o(){setTimeout((function(){a.find("tbody tr").each((function(){var t=e(this),s=t.find("select").find("option"),a=s.filter(":selected"),o=[];s.each((function(t,s){""!==s.value&&!0!==e(s).prop("disabled")&&o.push(s.value)})),t.find(".ux-swatch").each((function(){var t=e(this),s=t.attr("data-value");-1!==o.indexOf(s)?t.removeClass("disabled"):(t.addClass("disabled"),a.length&&s===a.val()&&t.removeClass("selected"))}))}))}),100)}function n(e,a){t&&(a=a?s+a:"",e.parents("tr").find(".ux-swatch-selected-value").html()!==a&&e.parents("tr").find(".ux-swatch-selected-value").html(a))}function c(){t&&a.find(".ux-swatch.selected").each((function(){const t=e(this).attr("data-name");e(this).parents("tr").find(".ux-swatch-selected-value").html(s+t)}))}a.hasClass("ux-swatches-js-attached")||(t&&a.find(".variations .label").append(''),a.on("click",".ux-swatch",(function(t){t.preventDefault();var s=e(this),a=s.closest(".value").find("select"),o=s.data("value"),c=s.data("name");s.hasClass("disabled")||(s.hasClass("selected")?(a.val(""),s.removeClass("selected"),n(s,"")):(s.addClass("selected").siblings(".selected").removeClass("selected"),a.val(o),n(s,c)),a.change())})),a.on("mouseenter mouseleave",".ux-swatch",(function(t){const s=e(this);"mouseenter"===t.type&&n(s,s.attr("data-name")),"mouseleave"===t.type&&n(s,s.closest(".ux-swatches").find(".ux-swatch.selected").attr("data-name"))})),a.on("click",".reset_variations",(function(){a.find(".ux-swatch.selected").removeClass("selected"),a.find(".ux-swatch.disabled").removeClass("disabled"),t&&a.find(".ux-swatch-selected-value").html("")})),o(),a.on("woocommerce_update_variation_values",(function(){o()})),c(),a.on("show_variation",(function(){c()})),a.addClass("ux-swatches-js-attached"))}))};const o=!flatsomeVars.options.swatches_box_behavior_selected,n=Boolean(flatsomeVars.options.swatches_box_update_urls),c="click"===flatsomeVars.options.swatches_box_select_event?"click":"hover",i=Boolean(flatsomeVars.options.swatches_box_reset),l=Boolean(flatsomeVars.options.swatches_box_reset_limited),d=flatsomeVars.options.swatches_box_reset_extent,r=parseInt(flatsomeVars.options.swatches_box_reset_time);e.fn.flatsomeSwatchesLoop=function(){return this.each((function(){var t=e(this);if(t.hasClass("ux-swatches-in-loop-js-attached"))return;var s,u,f,h,m,p=t.closest(".product-small"),w=p.find(".box-image a").first().attr("href"),v=[],_=!1;let x;if("hover"===c&&t.on("mouseenter",".ux-swatch",(function(t){if(!a){var s=e(this);b(),C(s)}})),t.on("click",".ux-swatch",(function(t){t.preventDefault();var s=e(this);if(s.hasClass("selected")){if(o)return void(window.location=m||w);s.removeClass("selected"),p.removeClass("ux-swatch-active"),g(),n&&S(v)}else b(),C(s)})),t.on("click",".ux-swatches__limiter",(function(t){const s=e(this);s.parent().find(".ux-swatch--limited.hidden").removeClass("hidden").fadeOut(0).fadeIn(500),s.hide(),e(document).trigger("flatsome-equalize-box")})),i){const s="product-box"===d?"":".ux-swatch";("product-box"===d?p:t).on("mouseenter mouseleave",s,(function(s){if("mouseleave"===s.type){const s=t.find(".selected");x=setTimeout((function(){s.removeClass("selected"),p.removeClass("ux-swatch-active"),l&&(t.find(".ux-swatch--limited").fadeOut(500).addClass("hidden"),t.find(".ux-swatches__limiter").fadeIn(500),e(document).trigger("flatsome-equalize-box")),g(),n&&S(v)}),r)}else clearTimeout(x)}))}function b(){_||(h=p.find(".box-image picture:not(.back-image) source"),s=p.find(".box-image img:not(.back-image)").first(),u=s.attr("src"),f=s.attr("srcset"),v.push(p.find(".box-image a").first()),v.push(p.find(".woocommerce-loop-product__link")),v.push(p.find(".product_type_variable.add_to_cart_button")),_=!0)}function C(e){e.hasClass("selected")||(t.find(".selected").removeClass("selected"),e.addClass("selected"),p.addClass("ux-swatch-active"),function(e){s.attr("src",e.data("image-src")),e.data("image-srcset")&&(s.attr("srcset",e.data("image-srcset")),h&&h.attr("srcset",e.data("image-srcset")))}(e),n&&function(e,t,s){var a=(t.indexOf("?")>-1?"&":"?")+e.data("attribute_name")+"="+e.data("value");s.forEach((function(e){e.attr("href",t+a)})),m=t+a}(e,w,v))}function g(){s&&s.attr("src",u),f&&(s.attr("srcset",f),h&&h.attr("srcset",f))}function S(e){e.forEach((function(e){e.attr("href",w)}))}t.addClass("ux-swatches-in-loop-js-attached")}))},e((function(){const t=".variations_form",s=".ux-swatches-in-loop:not(.js-ux-swatches)";e(t).flatsomeSwatches(),e(s).flatsomeSwatchesLoop(),e(document).on("wc_variation_form",(function(){e(t).flatsomeSwatches()})),e(document.body).on("wc-composite-initializing",".composite_data",(function(t,s){s.actions.add_action("component_options_state_changed",(function(t){e(t.$component_content).find(".variations_form").removeClass("ux-swatches-js-attached")}))})),e(document).on("flatsome-infiniteScroll-append",(function(t,a,o,n){e(s,n).flatsomeSwatchesLoop()})),e(document).on("facetwp-loaded",(function(){e(s).flatsomeSwatchesLoop()})),"undefined"!=typeof wp&&wp.customize&&wp.customize.selectiveRefresh&&wp.customize.selectiveRefresh.bind("partial-content-rendered",(function(t){e(s,t.container).flatsomeSwatchesLoop()})),e(document).ajaxComplete((function(){setTimeout((()=>{e(t).flatsomeSwatches(),e(s).flatsomeSwatchesLoop()}),100)})),e(document.body).on("updated_wc_div",(function(){setTimeout((()=>{e(t).flatsomeSwatches(),e(s).flatsomeSwatchesLoop()}),100)}))}))}(jQuery);