"use strict"; var get_bot_type=cwginstock.get_bot_type, recaptcha_enabled=cwginstock.enable_recaptcha, is_v3_recaptcha=cwginstock.is_v3_recaptcha, recaptcha_site_key=cwginstock.recaptcha_site_key, turnstile_enabled=cwginstock.enable_turnstile, turnstile_site_key=cwginstock.turnstile_site_key, gtoken=""; "undefined"!=typeof wc_bulk_variations_params&&document.addEventListener("click", function (t){ if(t.target.matches(".cwg_popup_submit")){ console.log(t.target.dataset.product_id), console.log("Captured click before stopPropagation!"); var e=t.target; jQuery.blockUI({ message: null });var a=e.dataset.product_id, i=e.dataset.variation_id, c=e.dataset.quantity, r=e.dataset.security; return "recaptcha"==get_bot_type&&"1"==recaptcha_enabled&&"yes"==is_v3_recaptcha ? popup_notifier.popup_generate_v3_response(this):popup_notifier.perform_ajax({ action: "cwg_trigger_popup_ajax", product_id: a, variation_id: i, quantity: c, security: r }), !1 }}, !0); var popup_notifier={ init: function (){ jQuery(document).on("click", ".cwg_popup_submit", function (){ jQuery.blockUI({ message: null });var t=jQuery(this), e=t.attr("data-product_id"), a=t.attr("data-variation_id"), i=t.attr("data-quantity"), c=t.attr("data-security"); return "recaptcha"==get_bot_type&&"1"==recaptcha_enabled&&"yes"==is_v3_recaptcha ? popup_notifier.popup_generate_v3_response(this):popup_notifier.perform_ajax({ action: "cwg_trigger_popup_ajax", product_id: e, variation_id: a, quantity: i, security: c }), !1 }) }, popup_generate_v3_response: function (t){ "recaptcha"==get_bot_type&&"1"==recaptcha_enabled&&"yes"==is_v3_recaptcha&&grecaptcha.ready(function (){ grecaptcha.execute(recaptcha_site_key, { action: "popup_form" }).then(function (e){ console.log(e); var a=jQuery(t), i=a.attr("data-product_id"), c=a.attr("data-variation_id"), r=a.attr("data-quantity"); popup_notifier.perform_ajax({ action: "cwg_trigger_popup_ajax", product_id: i, variation_id: c, quantity: r, security: e }), gtoken=e }) }) }, perform_ajax: function (t){ jQuery.ajax({ type: "post", url: cwginstock.default_ajax_url, data: t, success: function (t){ jQuery.unblockUI(), Swal.fire({ html: t, showCloseButton: !0, showConfirmButton: !1, willOpen: function (){ "recaptcha"==get_bot_type ? "1"==recaptcha_enabled&&(jQuery(".g-recaptcha").before('<div id="cwg-google-recaptcha"></div>'), jQuery(".g-recaptcha").remove()):"1"==turnstile_enabled&&turnstile.render(".cf-turnstile", { sitekey: turnstile_site_key, theme: "light", callback: function (t){ cwginstock_turnstile_callback(t) }}) }, didOpen: function (){ jQuery(document).trigger("cwginstock_popup_open_callback") }, willClose: function (){ jQuery(document).trigger("cwginstock_popup_close_callback") }}) }, error: function (t, e, a){ jQuery.unblockUI() }}) }}; popup_notifier.init(), jQuery(document).on("cwginstock_popup_open_callback", function (){ instock_notifier.onloadcallback(), instock_notifier.initialize_phone() }), jQuery(document).on("cwginstock_popup_close_callback", function (){ instock_notifier.resetcallback() });