// source --> https://store.mesinhl.com/wp-content/plugins/woocommerce/assets/js/frontend/checkout.min.js 
jQuery(function(e){if("undefined"==typeof wc_checkout_params)return!1;function t(){var t=wc.customPlaceOrderButton.__getForm();return{validate:function(){return new Promise(function(o){var r=!1,i=t.find('input[name="terms"]:visible');if(i.length&&i.closest(".form-row").removeClass("woocommerce-invalid"),t.find(".input-text, select, input:checkbox").trigger("validate"),t.find(".woocommerce-invalid").length>0&&(r=!0),t.find(".validate-required:visible").each(function(){var t=e(this),o=t.find("input.input-text, select, input:checkbox");0!==o.length&&((o.is(":checkbox")?!o.is(":checked"):""===o.val()||null===o.val())&&(r=!0,t.addClass("woocommerce-invalid woocommerce-invalid-required-field")))}),i.length&&!i.is(":checked")&&(r=!0,i.closest(".form-row").addClass("woocommerce-invalid")),r){var c=t.find(".woocommerce-invalid").first();c.length&&e("html, body").animate({scrollTop:c.offset().top-100},500)}o({hasError:r})})},submit:function(){t.trigger("submit")}}}e.blockUI.defaults.overlayCSS.cursor="default",e(document.body).on("update_checkout",function(){wc.customPlaceOrderButton.__cleanup()}),e(document.body).on("wc_custom_place_order_button_registered",function(e,o){wc.customPlaceOrderButton.__maybeShow(o,t())});var o={updateTimer:!1,dirtyInput:!1,selectedPaymentMethod:!1,xhr:!1,$order_review:e("#order_review"),$checkout_form:e("form.checkout"),init:function(){if(e(document.body).on("update_checkout",this.update_checkout),e(document.body).on("init_checkout",this.init_checkout),this.$checkout_form.on("click",'input[name="payment_method"]',this.payment_method_selected),e(document.body).hasClass("woocommerce-order-pay")){this.$order_review.on("click",'input[name="payment_method"]',this.payment_method_selected),this.$order_review.on("submit",this.submitOrder),this.$order_review.attr("novalidate","novalidate");var t=this.$order_review.find('input[name="payment_method"]:checked');t.length&&(wc.customPlaceOrderButton.__maybeHideDefaultButtonOnInit(t.val()),t.trigger("click"))}this.$checkout_form.attr("novalidate","novalidate"),this.$checkout_form.on("submit",this.submit),this.$checkout_form.on("input validate change focusout",".input-text, select, input:checkbox",this.validate_field),this.$checkout_form.on("update",this.trigger_update_checkout),this.$checkout_form.on("change",'select.shipping_method, input[name^="shipping_method"], #ship-to-different-address input, .update_totals_on_change select, .update_totals_on_change input[type="radio"], .update_totals_on_change input[type="checkbox"]',this.trigger_update_checkout),this.$checkout_form.on("change",".address-field select",this.input_changed),this.$checkout_form.on("change",".address-field input.input-text, .update_totals_on_change input.input-text",this.maybe_input_changed),this.$checkout_form.on("keydown",".address-field input.input-text, .update_totals_on_change input.input-text",this.queue_update_checkout),this.$checkout_form.on("blur","#billing_address_1, #shipping_address_1",this.address_field_blur),this.$checkout_form.on("change","#ship-to-different-address input",this.ship_to_different_address),this.$checkout_form.find("#ship-to-different-address input").trigger("change"),this.init_payment_methods(),"1"===wc_checkout_params.is_checkout&&e(document.body).trigger("init_checkout"),"yes"===wc_checkout_params.option_guest_checkout&&e("input#createaccount").on("change",this.toggle_create_account).trigger("change")},init_payment_methods:function(){var t=e(".woocommerce-checkout").find('input[name="payment_method"]');1===t.length&&t.eq(0).hide(),o.selectedPaymentMethod&&e("#"+o.selectedPaymentMethod).prop("checked",!0),0===t.filter(":checked").length&&t.eq(0).prop("checked",!0);var r=t.filter(":checked").eq(0).prop("id");t.length>1&&e('div.payment_box:not(".'+r+'")').filter(":visible").slideUp(0);var i=t.filter(":checked").eq(0);i.length&&wc.customPlaceOrderButton.__maybeHideDefaultButtonOnInit(i.val()),t.filter(":checked").eq(0).trigger("click")},get_payment_method:function(){return o.$checkout_form.find('input[name="payment_method"]:checked').val()},payment_method_selected:function(r){if(r.stopPropagation(),e(".payment_methods input.input-radio").length>1){var i=e("div.payment_box."+e(this).attr("ID")),c=e(this).is(":checked");c&&!i.is(":visible")&&(e("div.payment_box").filter(":visible").slideUp(230),c&&i.slideDown(230))}else e("div.payment_box").show();e(this).data("order_button_text")?e("#place_order").text(e(this).data("order_button_text")):e("#place_order").text(e("#place_order").data("value"));var n=e('.woocommerce-checkout input[name="payment_method"]:checked').attr("id");n!==o.selectedPaymentMethod&&e(document.body).trigger("payment_method_selected");var a=e(this).val();wc.customPlaceOrderButton.__maybeShow(a,t()),o.selectedPaymentMethod=n},toggle_create_account:function(){e("div.create-account").hide(),e(this).is(":checked")&&(e("#account_password").val("").trigger("change"),e("div.create-account").slideDown())},init_checkout:function(){e(document.body).trigger("update_checkout")},should_skip_address_update:function(e){var t=e.target||e.srcElement;if(t&&("billing_address_1"===t.id||"shipping_address_1"===t.id)){if("true"===t.getAttribute("data-autocomplete-manipulating"))return!0;var o=t.id.replace("_address_1","");if(window.wc&&window.wc.addressAutocomplete&&window.wc.addressAutocomplete.activeProvider&&window.wc.addressAutocomplete.activeProvider[o])return!0}return!1},should_trigger_address_blur_update:function(e){var t=e.target||e.srcElement;if(t&&("billing_address_1"===t.id||"shipping_address_1"===t.id)){if("true"===t.getAttribute("data-autocomplete-manipulating"))return!1;var o=t.id.replace("_address_1","");if(window.wc&&window.wc.addressAutocomplete&&window.wc.addressAutocomplete.activeProvider&&window.wc.addressAutocomplete.activeProvider[o])return!0}return!1},maybe_input_changed:function(e){o.should_skip_address_update(e)||o.dirtyInput&&o.input_changed(e)},input_changed:function(e){o.should_skip_address_update(e)||(o.dirtyInput=e.target,o.maybe_update_checkout())},address_field_blur:function(e){o.should_trigger_address_blur_update(e)&&(o.dirtyInput=e.target,o.maybe_update_checkout())},queue_update_checkout:function(e){if(9===(e.keyCode||e.which||0))return!0;var t=e.target||e.srcElement;if(t&&("billing_address_1"===t.id||"shipping_address_1"===t.id)){var r=t.id.replace("_address_1","");if(window.wc&&window.wc.addressAutocomplete&&window.wc.addressAutocomplete.activeProvider&&window.wc.addressAutocomplete.activeProvider[r])return!0}o.dirtyInput=this,o.reset_update_checkout_timer(),o.updateTimer=setTimeout(o.maybe_update_checkout,"1000")},trigger_update_checkout:function(t){o.reset_update_checkout_timer(),o.dirtyInput=!1,e(document.body).trigger("update_checkout",{current_target:t?t.currentTarget:null})},maybe_update_checkout:function(){var t=!0;if(e(o.dirtyInput).length){var r=e(o.dirtyInput).closest("div").find(".address-field.validate-required");r.length&&r.each(function(){""===e(this).find("input.input-text").val()&&(t=!1)})}t&&o.trigger_update_checkout()},ship_to_different_address:function(){e("div.shipping_address").hide(),e(this).is(":checked")&&e("div.shipping_address").slideDown()},reset_update_checkout_timer:function(){clearTimeout(o.updateTimer)},is_valid_json:function(e){try{var t=JSON.parse(e);return t&&"object"==typeof t}catch(o){return!1}},validate_field:function(t){var o=e(this),r=o.closest(".form-row"),i=!0,c=r.is(".validate-required"),n=r.is(".validate-email"),a=r.is(".validate-phone"),d="",s=t.type;"input"===s&&(o.removeAttr("aria-invalid").removeAttr("aria-describedby"),r.find(".checkout-inline-error-message").remove(),r.removeClass("woocommerce-invalid woocommerce-invalid-required-field woocommerce-invalid-email woocommerce-invalid-phone woocommerce-validated")),"validate"!==s&&"change"!==s&&"focusout"!==s||(c&&("checkbox"===o.attr("type")&&!o.is(":checked")||""===o.val())&&(o.attr("aria-invalid","true"),r.removeClass("woocommerce-validated").addClass("woocommerce-invalid woocommerce-invalid-required-field"),i=!1),n&&o.val()&&((d=new RegExp(/^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[0-9a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i)).test(o.val())||(o.attr("aria-invalid","true"),r.removeClass("woocommerce-validated").addClass("woocommerce-invalid woocommerce-invalid-email"),i=!1)),a&&(d=new RegExp(/[\s\#0-9_\-\+\/\(\)\.]/g),0<o.val().replace(d,"").length&&(o.attr("aria-invalid","true"),r.removeClass("woocommerce-validated").addClass("woocommerce-invalid woocommerce-invalid-phone"),i=!1)),i&&(o.removeAttr("aria-invalid").removeAttr("aria-describedby"),r.find(".checkout-inline-error-message").remove(),r.removeClass("woocommerce-invalid woocommerce-invalid-required-field woocommerce-invalid-email woocommerce-invalid-phone").addClass("woocommerce-validated")))},update_checkout:function(e,t){o.reset_update_checkout_timer(),o.updateTimer=setTimeout(o.update_checkout_action,"5",t)},update_checkout_action:function(t){if(o.xhr&&o.xhr.abort(),0!==e("form.checkout").length){t=void 0!==t?t:{update_shipping_method:!0};var r=e("#billing_country").val(),i=e("#billing_state").val(),c=e(":input#billing_postcode").val(),n=e("#billing_city").val(),a=e(":input#billing_address_1").val(),d=e(":input#billing_address_2").val(),s=r,u=i,l=c,m=n,p=a,_=d,h=e(o.$checkout_form).find(".address-field.validate-required:visible"),f=!0;h.length&&h.each(function(){""===e(this).find(":input").val()&&(f=!1)}),e("#ship-to-different-address").find("input").is(":checked")&&(s=e("#shipping_country").val(),u=e("#shipping_state").val(),l=e(":input#shipping_postcode").val(),m=e("#shipping_city").val(),p=e(":input#shipping_address_1").val(),_=e(":input#shipping_address_2").val());var v={security:wc_checkout_params.update_order_review_nonce,payment_method:o.get_payment_method(),country:r,state:i,postcode:c,city:n,address:a,address_2:d,s_country:s,s_state:u,s_postcode:l,s_city:m,s_address:p,s_address_2:_,has_full_address:f,post_data:e("form.checkout").serialize()};if(!1!==t.update_shipping_method){var g={};e('select.shipping_method, input[name^="shipping_method"][type="radio"]:checked, input[name^="shipping_method"][type="hidden"]').each(function(){g[e(this).data("index")]=e(this).val()}),v.shipping_method=g}e(".woocommerce-checkout-payment, .woocommerce-checkout-review-order-table").block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),o.xhr=e.ajax({type:"POST",url:wc_checkout_params.wc_ajax_url.toString().replace("%%endpoint%%","update_order_review"),data:v,success:function(r){if(r&&!0===r.reload)window.location.reload();else{e(".woocommerce-NoticeGroup-updateOrderReview").remove();var i=e("#terms").prop("checked"),c={};if(e(".payment_box :input").each(function(){var t=e(this).attr("id");t&&(-1!==e.inArray(e(this).attr("type"),["checkbox","radio"])?c[t]=e(this).prop("checked"):c[t]=e(this).val())}),r&&r.fragments&&(e.each(r.fragments,function(t,r){o.fragments&&o.fragments[t]===r||e(t).replaceWith(r),e(t).unblock()}),o.fragments=r.fragments),i&&e("#terms").prop("checked",!0),e.isEmptyObject(c)||e(".payment_box :input").each(function(){var t=e(this).attr("id");t&&(-1!==e.inArray(e(this).attr("type"),["checkbox","radio"])?e(this).prop("checked",c[t]).trigger("change"):-1!==e.inArray(e(this).attr("type"),["select"])?e(this).val(c[t]).trigger("change"):null!==e(this).val()&&0===e(this).val().length&&e(this).val(c[t]).trigger("change"))}),r&&"failure"===r.result){var n=e("form.checkout");e(".woocommerce-error, .woocommerce-message, .is-error, .is-success").remove(),r.messages?n.prepend('<div class="woocommerce-NoticeGroup woocommerce-NoticeGroup-updateOrderReview">'+r.messages+"</div>"):n.prepend(r),n.find(".input-text, select, input:checkbox").trigger("validate").trigger("blur"),o.scroll_to_notices()}o.init_payment_methods(),r&&"success"===r.result&&t.current_target&&-1!==t.current_target.id.indexOf("shipping_method")&&document.getElementById(t.current_target.id).focus(),e(document.body).trigger("updated_checkout",[r])}}})}},handleUnloadEvent:function(e){return-1===navigator.userAgent.indexOf("MSIE")&&!document.documentMode||(e.preventDefault(),undefined)},attachUnloadEventsOnSubmit:function(){e(window).on("beforeunload",this.handleUnloadEvent)},detachUnloadEventsOnSubmit:function(){e(window).off("beforeunload",this.handleUnloadEvent)},blockOnSubmit:function(e){1!==e.data("blockUI.isBlocked")&&e.block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},submitOrder:function(){o.blockOnSubmit(e(this))},submit:function(){o.reset_update_checkout_timer();var t=e(this);return!t.is(".processing")&&(!1!==t.triggerHandler("checkout_place_order",[o])&&!1!==t.triggerHandler("checkout_place_order_"+o.get_payment_method(),[o])&&(t.addClass("processing"),o.blockOnSubmit(t),o.attachUnloadEventsOnSubmit(),e.ajaxSetup({dataFilter:function(e,t){if("json"!==t)return e;if(o.is_valid_json(e))return e;var r=e.match(/{"result.*}/);return null===r?console.log("Unable to fix malformed JSON #1"):o.is_valid_json(r[0])?(console.log("Fixed malformed JSON. Original:"),console.log(e),e=r[0]):console.log("Unable to fix malformed JSON #2"),e}}),e.ajax({type:"POST",url:wc_checkout_params.checkout_url,data:t.serialize(),dataType:"json",success:function(r){o.detachUnloadEventsOnSubmit(),e(".checkout-inline-error-message").remove();try{if("success"!==r.result||!1===t.triggerHandler("checkout_place_order_success",[r,o]))throw"failure"===r.result?"Result failure":"Invalid response";-1===r.redirect.indexOf("https://")||-1===r.redirect.indexOf("http://")?window.location=r.redirect:window.location=decodeURI(r.redirect)}catch(a){if(!0===r.reload)return void window.location.reload();if(!0===r.refresh&&e(document.body).trigger("update_checkout"),r.messages){var i=e(r.messages).removeAttr("role").attr("tabindex","-1"),c=o.wrapMessagesInsideLink(i),n=e('<div role="alert"></div>').append(c);o.submit_error(n.prop("outerHTML")),o.show_inline_errors(i)}else o.submit_error('<div class="woocommerce-error">'+wc_checkout_params.i18n_checkout_error+"</div>")}},error:function(e,t,r){o.detachUnloadEventsOnSubmit();var i=r;"object"==typeof wc_checkout_params&&null!==wc_checkout_params&&wc_checkout_params.hasOwnProperty("i18n_checkout_error")&&"string"==typeof wc_checkout_params.i18n_checkout_error&&""!==wc_checkout_params.i18n_checkout_error.trim()&&(i=wc_checkout_params.i18n_checkout_error),o.submit_error('<div class="woocommerce-error">'+i+"</div>")}})),!1)},submit_error:function(t){e(".woocommerce-NoticeGroup-checkout, .woocommerce-error, .woocommerce-message, .is-error, .is-success").remove(),o.$checkout_form.prepend('<div class="woocommerce-NoticeGroup woocommerce-NoticeGroup-checkout">'+t+"</div>"),o.$checkout_form.removeClass("processing").unblock(),o.$checkout_form.find(".input-text, select, input:checkbox").trigger("validate").trigger("blur"),o.scroll_to_notices(),o.$checkout_form.find('.woocommerce-error[tabindex="-1"], .wc-block-components-notice-banner.is-error[tabindex="-1"]').focus(),e(document.body).trigger("checkout_error",[t])},wrapMessagesInsideLink:function(t){return t.find("li[data-id]").each(function(){const t=e(this),o=t.attr("data-id");if(o){const r=e("<a>",{href:"#"+o,html:t.html()});t.empty().append(r)}}),t},show_inline_errors:function(t){t.find("li[data-id]").each(function(){const t=e(this),o=t.attr("data-id"),r=e("#"+o);if(1===r.length){const e=o+"_description",i=t.text().trim(),c=r.closest(".form-row"),n=document.createElement("p");n.id=e,n.className="checkout-inline-error-message",n.textContent=i,c&&n.textContent.length>0&&c.append(n),r.attr("aria-describedby",e),r.attr("aria-invalid","true")}})},scroll_to_notices:function(){var t=e(".woocommerce-NoticeGroup-updateOrderReview, .woocommerce-NoticeGroup-checkout");t.length||(t=e("form.checkout")),e.scroll_to_notices(t)}},r={init:function(){e(document.body).on("click","a.showcoupon",this.show_coupon_form),e(document.body).on("click",".woocommerce-remove-coupon",this.remove_coupon),e(document.body).on("keydown",".woocommerce-remove-coupon",this.on_keydown_remove_coupon),e(document.body).on("change input","#coupon_code",this.remove_coupon_error),e("form.checkout_coupon").hide().on("submit",this.submit.bind(this))},show_coupon_form:function(){var t=e(this);return e(".checkout_coupon").slideToggle(400,function(){var o=e(this);o.is(":visible")?(t.attr("aria-expanded","true"),o.find(":input:eq(0)").trigger("focus")):t.attr("aria-expanded","false")}),!1},show_coupon_error:function(t,o){if(0!==o.length){this.remove_coupon_error();var r=e(e.parseHTML(t)).text().trim();""!==r&&(o.find("#coupon_code").focus().addClass("has-error").attr("aria-invalid","true").attr("aria-describedby","coupon-error-notice"),e("<span>",{"class":"coupon-error-notice",id:"coupon-error-notice",role:"alert",text:r}).appendTo(o))}},remove_coupon_error:function(){var t=e("#coupon_code");0!==t.length&&t.removeClass("has-error").removeAttr("aria-invalid").removeAttr("aria-describedby").next(".coupon-error-notice").remove()},clear_coupon_input:function(){e("#coupon_code").val("").removeClass("has-error").removeAttr("aria-invalid").removeAttr("aria-describedby").next(".coupon-error-notice").remove()},submit:function(t){var r=e(t.currentTarget),i=r.find("#coupon_code"),c=this;if(c.remove_coupon_error(),r.is(".processing"))return!1;r.addClass("processing").block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var n={security:wc_checkout_params.apply_coupon_nonce,coupon_code:r.find('input[name="coupon_code"]').val(),billing_email:o.$checkout_form.find('input[name="billing_email"]').val()};return e.ajax({type:"POST",url:wc_checkout_params.wc_ajax_url.toString().replace("%%endpoint%%","apply_coupon"),data:n,success:function(t){e(".woocommerce-error, .woocommerce-message, .is-error, .is-success, .checkout-inline-error-message").remove(),r.removeClass("processing").unblock(),t&&(-1===t.indexOf("woocommerce-error")&&-1===t.indexOf("is-error")?(r.slideUp(400,function(){e("a.showcoupon").attr("aria-expanded","false"),r.before(t)}),c.clear_coupon_input()):c.show_coupon_error(t,i.parent()),e(document.body).trigger("applied_coupon_in_checkout",[n.coupon_code]),e(document.body).trigger("update_checkout",{update_shipping_method:!1}))},dataType:"html"}),!1},remove_coupon:function(t){t.preventDefault();var o=e(this).parents(".woocommerce-checkout-review-order"),i=e(this).data("coupon");o.addClass("processing").block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var c={security:wc_checkout_params.remove_coupon_nonce,coupon:i};e.ajax({type:"POST",url:wc_checkout_params.wc_ajax_url.toString().replace("%%endpoint%%","remove_coupon"),data:c,success:function(t){e(".woocommerce-error, .woocommerce-message, .is-error, .is-success").remove(),o.removeClass("processing").unblock(),t&&(e("form.woocommerce-checkout").before(t),e(document.body).trigger("removed_coupon_in_checkout",[c.coupon]),e(document.body).trigger("update_checkout",{update_shipping_method:!1}),r.clear_coupon_input(),e("form.checkout_coupon").slideUp(400,function(){e("a.showcoupon").attr("aria-expanded","false")}))},error:function(e){wc_checkout_params.debug_mode&&console.log(e.responseText)},dataType:"html"})},on_keydown_remove_coupon:function(t){" "===t.key&&(t.preventDefault(),e(this).trigger("click"))}},i={init:function(){e(document.body).on("click","a.showlogin",this.show_login_form)},show_login_form:function(){var t=e("form.login, form.woocommerce-form--login");return t.is(":visible")?t.slideToggle({duration:400}):t.slideToggle({duration:400,complete:function(){t.is(":visible")&&e("html, body").animate({scrollTop:t.offset().top-50},300)}}),!1}},c={init:function(){e(document.body).on("click","a.woocommerce-terms-and-conditions-link",this.toggle_terms)},toggle_terms:function(){if(e(".woocommerce-terms-and-conditions").length)return e(".woocommerce-terms-and-conditions").slideToggle(function(){var t=e(".woocommerce-terms-and-conditions-link");e(".woocommerce-terms-and-conditions").is(":visible")?(t.addClass("woocommerce-terms-and-conditions-link--open"),t.removeClass("woocommerce-terms-and-conditions-link--closed")):(t.removeClass("woocommerce-terms-and-conditions-link--open"),t.addClass("woocommerce-terms-and-conditions-link--closed"))}),!1}};o.init(),r.init(),i.init(),c.init()});
// source --> https://store.mesinhl.com/wp-content/plugins/translatepress-multilingual/assets/js/trp-frontend-compatibility.js 
document.addEventListener("DOMContentLoaded", function(event) {
    function trpClearWooCartFragments(){

        // clear WooCommerce cart fragments when switching language
        var trp_language_switcher_urls = document.querySelectorAll(".trp-language-switcher-container a:not(.trp-ls-disabled-language), .trp-language-item:not(.trp-language-item__current)");

        for (i = 0; i < trp_language_switcher_urls.length; i++) {
            trp_language_switcher_urls[i].addEventListener("click", function(){
                if ( typeof wc_cart_fragments_params !== 'undefined' && typeof wc_cart_fragments_params.fragment_name !== 'undefined' ) {
                    window.sessionStorage.removeItem(wc_cart_fragments_params.fragment_name);
                }
            });
        }
    }

    trpClearWooCartFragments();
});
// source --> https://store.mesinhl.com/wp-content/plugins/translatepress-multilingual/assets/js/trp-frontend-language-switcher.js 
class BaseSwitcher {
    constructor(rootEl) {
        this.root = rootEl;
        this.list = rootEl?.querySelector('.trp-switcher-dropdown-list') || null;
        this.isOpen = false;
        this._pendingFocusOnOpen = false;
        if (!this.root || !this.list) return;

        if (!this.list.id) {
            this.list.id = `trp-list-${Math.random().toString(36).slice(2, 9)}`;
        }

        // Single transitionend handler to drop .is-transitioning and finalize hidden/inert
        this._onTe = (e) => {
            if (e.target !== this.list || e.propertyName !== 'max-height') return;

            this.root.classList.remove('is-transitioning');

            if (!this.isOpen) {
                this.list.hidden = true;
                this.list.setAttribute('inert', '');
            } else if (this._pendingFocusOnOpen) {
                this._pendingFocusOnOpen = false;
                const first = this.list.querySelector(
                    '[role="option"], a, button, [tabindex]:not([tabindex="-1"])'
                );
                first?.focus?.({ preventScroll: true });
            }
        };
        this.list.addEventListener('transitionend', this._onTe);

        this.collapse();
        this.setAutoWidth();
        this.bindKeyboard();
    }

    /**
     * Returns true if the list has a non-zero transition duration (for any property).
     * We use this to decide whether to rely on `transitionend` or fall back to sync behavior.
     */
    _hasAnimatedTransition() {
        if (!this.list) return false;

        const cs = getComputedStyle(this.list);
        const durationsRaw = cs.transitionDuration || '';

        if (!durationsRaw) return false;

        const durations = durationsRaw
            .split(',')
            .map(str => parseFloat(str) || 0);

        return durations.some(d => d > 0);
    }

    collapse() {
        this.list.hidden = true;
        this.list.setAttribute('inert', '');
        this.setExpanded(false);
        this.root.classList.remove('is-transitioning');
    }

    /**
     * If width is set to auto, fix it to the calculated width + 20px
     * We do this in order to avoid width shift on hover
     * */
    setAutoWidth() {
        const bonusWidth = 10;

        const cs = getComputedStyle(this.root);
        const declaredWidth = cs.getPropertyValue('--switcher-width').trim();

        if (declaredWidth === 'auto' && this.root.querySelector('.trp-language-item-name')) { // In case trp-language-item-name is not present, we are in flags only mode - so no auto width sizing is needed
            const initialWidth = this.root.getBoundingClientRect().width;

            this.root.style.setProperty('--switcher-width', (initialWidth + bonusWidth) + 'px');
        }
    }

    setExpanded(open) {
        const trigger = this.root.querySelector('.trp-language-item__current[role="button"]');
        const val = String( !!open );
        trigger?.setAttribute('aria-expanded', val);
        this.root.classList.toggle('is-open', !!open);
    }

    setOpen( open, { source = null } = {} ) {
        if ( !this.root || !this.list || open === this.isOpen ) return;

        const prefersReduced = window.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches;
        const hasTransition  = !prefersReduced && this._hasAnimatedTransition();

        this.isOpen = open;

        // No transitions (0s duration) OR reduced motion: do everything synchronously,
        if ( !hasTransition ) {
            if ( open ) {
                this.list.hidden = false;
                this.list.removeAttribute( 'inert' );
                this.setExpanded( true );

                this._pendingFocusOnOpen = ( source?.type === 'keydown' );
                if ( this._pendingFocusOnOpen ) {
                    this._pendingFocusOnOpen = false;
                    const first = this.list.querySelector(
                        '[role="option"], a, button, [tabindex]:not([tabindex="-1"])'
                    );
                    first?.focus?.({ preventScroll: true });
                }
            } else {
                this.setExpanded( false );
                this.list.hidden = true;
                this.list.setAttribute( 'inert', '' );
                this._pendingFocusOnOpen = false;
            }
            return;
        }

        // Animated path: rely on transitionend to remove .is-transitioning
        if ( open ) {
            // Must be visible for CSS transition to run
            this.list.hidden = false;
            this.list.removeAttribute( 'inert' );

            this._pendingFocusOnOpen = ( source?.type === 'keydown' );

            this.root.classList.add( 'is-transitioning' );
            // Next frame so browser registers pre-open (max-height: 0) state
            requestAnimationFrame( () => this.setExpanded( true ) );
        } else {
            this.root.classList.add( 'is-transitioning' );
            this.setExpanded( false );
        }
    }

    bindKeyboard() {
        const trigger = this.root.querySelector('.trp-language-item__current[role="button"]');
        if ( !trigger ) return;

        trigger.addEventListener('keydown', (e) => {
            const inList = !!e.target.closest?.('.trp-switcher-dropdown-list');

            if ( e.key === 'Enter' || e.key === ' ' ) {
                e.preventDefault();
                this.setOpen(!this.isOpen, { source: e });
                return;
            }

            if ( e.key === 'ArrowDown' && !this.isOpen ) {
                e.preventDefault();
                this.setOpen(true, { source: e });
            }

            if ( e.key === 'Escape' ) {
                this.setOpen(false, { source: e });
                trigger.focus?.();
            }
        });
    }
}

class ShortcodeSwitcher extends BaseSwitcher {
    constructor(wrapper) {
        const overlay =
                  wrapper.querySelector('.trp-language-switcher.trp-shortcode-overlay')
                  || [...wrapper.querySelectorAll('.trp-language-switcher')]
                      .find(el => el.classList.contains('trp-shortcode-overlay'));

        // Overlay must be interactable; ensure no accidental hidden/inert from server
        overlay.hidden = false;
        overlay.removeAttribute('hidden');
        overlay.removeAttribute('inert');
        if ('inert' in overlay) overlay.inert = false;

        super(overlay);

        if (!this.root || !this.list) return;

        const control = this.root.querySelector('.trp-language-item__current[role="button"]');
        if (control && this.list && !control.hasAttribute('aria-controls')) {
            control.setAttribute('aria-controls', this.list.id);
        }

        const isClickMode =
                  this.root.classList.contains('trp-open-on-click') ||
                  wrapper.dataset.openMode === 'click' ||
                  wrapper.classList.contains('trp-open-on-click');

        if (isClickMode) {
            // Click anywhere on overlay EXCEPT inside the list
            this.root.addEventListener('click', (e) => {
                const inList = e.target.closest('.trp-switcher-dropdown-list');
                if (!inList) {
                    e.preventDefault();
                    e.stopPropagation();
                    this.setOpen(!this.isOpen, { source: e });
                }
            }, true);

            // Outside click closes
            this.onDocClick = (evt) => {
                if (!wrapper.contains(evt.target)) this.setOpen(false, { source: evt });
            };
            document.addEventListener('click', this.onDocClick, true);

            // Focus leaving wrapper closes
            wrapper.addEventListener('focusout', () => {
                setTimeout(() => {
                    if (!wrapper.contains(document.activeElement)) {
                        this.setOpen(false, { source: 'keyboard' });
                    }
                }, 0);
            });
        } else {
            // Hover mode on overlay
            this.root.addEventListener('mouseenter', (e) => this.setOpen(true,  { source: e }));
            this.root.addEventListener('mouseleave', (e) => this.setOpen(false, { source: e }));
        }
    }
}

class FloaterSwitcher extends BaseSwitcher {
    constructor(el) {
        super(el);

        el.addEventListener('mouseenter', (e) => this.setOpen(true,  { source: e }));
        el.addEventListener('mouseleave', (e) => this.setOpen(false, { source: e }));

        this.onDocClick = (evt) => { if (!el.contains(evt.target)) this.setOpen(false, { source: evt }); };
        document.addEventListener('click', this.onDocClick, true);
    }
}

document.addEventListener('DOMContentLoaded', () => {
    // Front-end or classic admin
    initLanguageSwitchers(document);

    // If no wrapper and we are in Gutenberg, watch for async SSR insert
    if (
        inGutenberg() &&
        !getEditorDoc().querySelector(WRAPPER)
    ) {
        observeWrapperUntilFound();
    }

    if ( !inGutenberg() )
        observeShortcodeSwitcher();
});

/** For shortcode switcher
 *  Mark the shortcodes that were initialized
 * */
const TRP_BOUND = new WeakSet();
const mark = (el) => TRP_BOUND.add(el);
const isMarked = (el) => TRP_BOUND.has(el);

const WRAPPER = '.trp-shortcode-switcher__wrapper';
const OVERLAY = '.trp-language-switcher:not(.trp-opposite-button)';

// Helpers
function inGutenberg() {
    return document.body?.classList?.contains('block-editor-page')
        || !!(window.wp?.data?.select?.('core/block-editor'));
}

// If editor uses an iframe canvas, work inside it
function getEditorDoc() {
    const ifr = document.querySelector('iframe[name="editor-canvas"], .editor-canvas__iframe');

    return (ifr && ifr.contentDocument) ? ifr.contentDocument : document;
}

function initLanguageSwitchers(root = document) {
    const floater = root.querySelector(
        '.trp-language-switcher.trp-ls-dropdown:not(.trp-shortcode-switcher):not(.trp-opposite-language)'
    );

    if (floater)
        new FloaterSwitcher(floater);

    root.querySelectorAll(WRAPPER)
        .forEach(wrapper => {
            const overlay = wrapper.querySelector('.trp-language-switcher:not(.trp-opposite-button)');

            if (overlay && !isMarked(overlay)) {
                mark(overlay);
                new ShortcodeSwitcher(wrapper);
            }
        });
}

/**
 * Observes the document for dynamically inserted shortcode switchers and initializes them automatically when detected.
 */
function observeShortcodeSwitcher() {
    const initWrapper = ( wrapper ) => {
        if ( !wrapper )
            return;

        const overlay = wrapper.querySelector( OVERLAY );

        if ( !overlay || isMarked( overlay ) )
            return;

        mark( overlay );

        new ShortcodeSwitcher( wrapper );
    }

    const mo = new MutationObserver( ( mutations ) => {
        for ( const m of mutations ) {
            for ( const n of m.addedNodes ) {
                if ( n.nodeType !== 1 )
                    continue;

                if ( n.matches?.( WRAPPER ) )
                    initWrapper( n );

                n.querySelectorAll?.( WRAPPER ).forEach( initWrapper );
            }
        }
    });

    mo.observe( document, { childList: true, subtree: true } );
}

/**
 * Observe Gutenberg for the shortcode wrapper being inserted asynchronously.
 *
 * Supports both Blocks API v2 (no editor iframe; wrapper appears in the outer document)
 * and Blocks API v3 (editor content rendered inside an iframe canvas).
 *
 * Strategy:
 *  1) Check the current editor document for `.trp-shortcode-switcher__wrapper` and init immediately.
 *  2) If an editor canvas iframe exists, watch its document (and reattach on iframe load) for the wrapper.
 *  3) If no iframe yet, watch the outer document for either the iframe (v3) or the wrapper itself (v2).
 *
 * Initialization is performed once per context to avoid duplicate bindings.
 */
function observeWrapperUntilFound() {
    // If wrapper already exists in current editor doc, init
    const edDoc = getEditorDoc();
    const existing = edDoc.querySelector(WRAPPER);

    if ( existing ) {
        initLanguageSwitchers( edDoc );
        return;
    }

    // Helper to locate the editor canvas iframe in the OUTER document
    const findCanvasIframe = () => document.querySelector('iframe[name="editor-canvas"], .editor-canvas__iframe');

    // If iframe is already present in the outer doc, start watching inside it
    const iframeNow = findCanvasIframe();
    if ( iframeNow ) {
        watchIframe( iframeNow );
        return;
    }

    // Otherwise, observe the OUTER document until the iframe appears
    const outerMO = new MutationObserver( ( mutations ) => {
        for ( const m of mutations ) {
            for ( const n of m.addedNodes ) {
                if ( n.nodeType !== 1 ) continue;

                const iframe =
                          n.matches?.('iframe[name="editor-canvas"], .editor-canvas__iframe')
                              ? n
                              : n.querySelector?.('iframe[name="editor-canvas"], .editor-canvas__iframe');

                if ( iframe ) {
                    outerMO.disconnect();
                    watchIframe( iframe );
                    return;
                }

                // Also catch shortcode wrapper added directly to the outer document (API v2, no iframe)
                const wrapper =
                          n.matches?.(WRAPPER)
                              ? n
                              : n.querySelector?.(WRAPPER);

                if ( wrapper ) {
                    outerMO.disconnect();
                    initLanguageSwitchers( document );
                    return;
                }

            }
        }
    } );
    outerMO.observe( document, { childList: true, subtree: true } );

    function watchIframe( iframe ) {
        // Try immediately (some builds inject srcdoc synchronously)
        tryAttachInside();

        // Also on load/navigate (Gutenberg may reload the canvas)
        iframe.addEventListener( 'load', tryAttachInside );

        function tryAttachInside() {
            let doc;
            try {
                doc = iframe.contentDocument || iframe.contentWindow?.document;
            } catch (e) {
                console.warn('Cannot access iframe content due to cross-origin restrictions', e);
                return;
            }
            if ( !doc ) return;

            // If wrapper is already there, init once and stop.
            const hit = doc.querySelector(WRAPPER);
            if ( hit ) {
                initLanguageSwitchers( doc );
                return;
            }

            // Observe INSIDE the iframe until wrapper appears
            const innerMO = new MutationObserver( ( muts ) => {
                for ( const mm of muts ) {
                    for ( const nn of mm.addedNodes ) {
                        if ( nn.nodeType !== 1 ) continue;
                        if (
                            nn.matches?.(WRAPPER) ||
                            nn.querySelector?.(WRAPPER)
                        ) {
                            innerMO.disconnect();
                            initLanguageSwitchers( doc );
                            return;
                        }
                    }
                }
                if ( doc.querySelector(WRAPPER) ) {
                    innerMO.disconnect();
                    initLanguageSwitchers( doc );
                }
            } );

            innerMO.observe( doc, { childList: true, subtree: true } );
        }
    }
};