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