jQuery(document).ready(function(e){"use strict";window.woo_multi_currency={init:function(){this.design(),this.checkPosition(),this.cacheCompatible(),this.ajaxComplete()},design:function(){jQuery(window).width()<=768?jQuery(".woo-multi-currency.wmc-sidebar").on("click",function(){jQuery(this).toggleClass("wmc-hover"),jQuery(this).hasClass("wmc-hover")?jQuery("html").css({overflow:"hidden"}):jQuery("html").css({overflow:"visible"})}):(jQuery(".woo-multi-currency.wmc-sidebar").on("mouseenter",function(){jQuery(this).addClass("wmc-hover")}),jQuery(".woo-multi-currency.wmc-sidebar").on("mouseleave",function(){jQuery(this).removeClass("wmc-hover")}))},checkPosition:function(){jQuery(".woo-multi-currency .wmc-currency-wrapper").on("mouseenter",function(){this.getBoundingClientRect().top/e(window).height()>.5?e(".woo-multi-currency .wmc-sub-currency").addClass("wmc-show-up"):e(".woo-multi-currency .wmc-sub-currency").removeClass("wmc-show-up")})},cacheCompatible(){if("1"===wooMultiCurrencyParams.enableCacheCompatible){if("undefined"!=typeof wc_checkout_params&&1===parseInt(wc_checkout_params.is_checkout))return;let c=[],r=e(".wmc-cache-pid");r.length&&r.each(function(r,t){c.push(e(t).data("wmc_product_id"))});let t=e(".variations_form");t.length&&t.each(function(r,t){let a=e(t).data("product_variations");a.length&&a.forEach(e=>{c.push(e.variation_id)})});let a=e(".woo-multi-currency.wmc-shortcode");c.length&&(c=[...new Set(c)]);let i=[];e(".wmc-cache-value").each(function(c,r){i.push({value:e(r).data("value"),currency:e(r).data("currency")})}),i=[...new Set(i.map(JSON.stringify))].map(JSON.parse),e.ajax({url:wooMultiCurrencyParams.ajaxUrl,type:"POST",data:{action:"wmc_get_products_price",pids:c,shortcode:a.data("layout"),flag_size:a.data("flag_size"),wmc_current_url:a.find(".wmc-current-url").val(),exchange:i},success(c){if(c.success){let r=c.data.prices||"",t=c.data.current_currency||"",i=c.data.exchange||"";if(a.replaceWith(c.data.shortcode),"1"!==wooMultiCurrencyParams.switchByJS&&e(".wmc-currency a").unbind(),t&&(e(".wmc-sidebar .wmc-currency").removeClass("wmc-active"),e(`.wmc-sidebar .wmc-currency[data-currency=${t}]`).addClass("wmc-active"),e(".wmc-price-switcher .wmc-current-currency i").removeClass().addClass("vi-flag-64 flag-"+c.data.current_country),e(`.wmc-price-switcher .wmc-currency[data-currency=${t}]`).hide(),e(`select.wmc-nav option[data-currency=${t}]`).prop("selected",!0)),"undefined"!=typeof woo_multi_currency_switcher&&woo_multi_currency_switcher.init(),r){for(let c in r)e(`.wmc-cache-pid[data-wmc_product_id=${c}]`).replaceWith(r[c]);e(".variations_form").each((c,t)=>{let a=e(t).data("product_variations");a.map(e=>{let c=e.variation_id;return e.price_html=r[c],e}),e(t).data("product_variations",a)})}if(i)for(let c in i)i[c].currency?e(`.wmc-cache-value[data-value=${i[c].value}][data-currency=${i[c].currency}]`).replaceWith(i[c].shortcode):e(`.wmc-cache-value[data-value=${i[c].value}][data-currency='']`).replaceWith(i[c].shortcode)}}})}},ajaxComplete(){e(document).on("append.infiniteScroll",()=>{this.cacheCompatible()})}},woo_multi_currency.init()});