jQuery(function(o){function e(e){var n=e.hasClass("xc-open");o(".xc-open").removeClass("xc-open"),n?e.removeClass("xc-open"):e.addClass("xc-open")}o(window).on("x_currency/change_site_currency",function(o){var e=o.detail.code;if("string"==typeof e){var n=new URLSearchParams(window.location.search);n.set("currency",e);var c=n.toString(),t=window.location.origin+window.location.pathname+"?"+c;window.location.href=t}}),o("body").on("click",".x-currency-shortcode-old .switch",function(n){n.preventDefault(),n.stopPropagation();var c=o(this).closest(".x-currency-shortcode-old");e(c),function(o){var e=o.find(".currency-wrap").get(0).getBoundingClientRect();innerHeight-(e.top+e.height/2)<15?(o.removeClass("open-bottom"),o.addClass("open-top")):(o.removeClass("open-top"),o.addClass("open-bottom"))}(c)}),o("body").on("click",".x-currency-shortcode-old .currency-wrap li",function(n){n.preventDefault(),n.stopPropagation();var c=o(this);c.siblings(".active").removeClass("active"),c.addClass("active"),e(c.closest(".x-currency-shortcode-old")),o(window).trigger({type:"x_currency/change_site_currency",detail:{code:c.data("code")}})}),o(document).on("click",function(){o(".xc-open").removeClass("xc-open")}),o(".x-currency-sticky-old .dropdown-ul li").on("click",function(e){e.preventDefault(),e.stopPropagation(),o(window).trigger({type:"x_currency/change_site_currency",detail:{code:o(this).data("code")}})})});