function wcwl_apply_event_on_page_update(){var e=".wcwl_elements";jQuery(".wcwl_frontend_wrap").length&&(e=".wcwl_frontend_wrap"),jQuery(".wcwl_nojs").toggleClass("wcwl_nojs",!1),jQuery(e+":not(.bound)").addClass("bound").on("click","a.wcwl_control",function(e){e.preventDefault(),wcwl_reset_waitlist_elements(jQuery(this)),wcwl_process_waitlist_request(jQuery(this))}),jQuery(".woocommerce.quick-view.single-product .wcwl_elements:not(.bound)").addClass("bound").on("click","a.wcwl_control",function(e){e.preventDefault(),jQuery(".wcwl_notice").hide(),wcwl_process_waitlist_request(jQuery(this))}),jQuery(".wcwl_toggle").on("click","button",function(){var e=jQuery(this).closest(".wcwl_frontend_wrap");wcwl_toggle_archive_fields(e),e.find(".wcwl_intro, .wcwl_optin, .wcwl_email_elements").show()}),jQuery(".wcwl_notice").on("click",".wcwl_notice_dismiss",function(){var e;jQuery(this).closest(".wcwl_notice").hide(),jQuery(".wcwl_frontend_wrap").length?(wcwl_toggle_archive_fields(e=jQuery(this).closest(".wcwl_frontend_wrap")),e.find(".spinner").hide(),e.find(".wcwl_toggle").show(),e.find(".wcwl_elements").hide()):((e=jQuery(this).closest(".wcwl_elements")).find(".spinner").hide(),e.find(".wcwl_intro, .wcwl_optin, .wcwl_email_elements, .wcwl_control, .wcwl_control button").show())}),wcwl_hide_waitlist_notice_if_empty(),wcwl_add_keyboard_button_events(),null!=jQuery(e).css("display")&&(waitlist_display_class=null!=jQuery(e).css("display"))}function wcwl_toggle_archive_fields(e){jQuery(".wcwl_elements, .wcwl_notice").hide(),jQuery(".wcwl_toggle, .woocommerce_waitlist, .wcwl_frontend_wrap > .wcwl_control").show(),e.find(".wcwl_toggle").hide(),e.find(".wcwl_elements, .wcwl_email_elements, .wcwl_control, .wcwl_optin").show()}function wcwl_reset_waitlist_elements(e){jQuery(".wcwl_frontend_wrap").length?wcwl_toggle_archive_fields(e.closest(".wcwl_frontend_wrap")):(jQuery(".wcwl_elements, .wcwl_email_elements, .wcwl_control, .wcwl_optin, .wcwl_intro").show(),jQuery(".wcwl_notice").hide(),e.closest(".wcwl_elements").find(".wcwl_intro").hide()),jQuery(".wcwl_email, .wcwl_optin").removeClass("wcwl_error_highlight")}function wcwl_process_waitlist_request(e){var t=e.closest(".wcwl_frontend_wrap"),l=[],i=(t=t.length?t:e.closest(".wcwl_elements")).find('input[name="wcwl_email"]'),w=(wcwl_check_email_field(i)||l.push("email"),t.find(".wcwl_optin input"));wcwl_check_optin_field(w)||l.push("optin"),jQuery("div.product-type-grouped").length&&0==wcwl_data.user_id&&!jQuery("input.wcwl_checkbox:checked").length&&l.push("grouped_no_checked"),0==l.length?(e.find("button").hide(),t.find(".wcwl_email_elements, .wcwl_optin").hide(),e.find(".spinner").show(),wcwl_add_screenreader_message(t.find(".wcwl_control"),wcwl_data.loading_message),wcwl_process_ajax_request(t,e,i.val())):(t.find(".wcwl_notice").hide(),t.find(".wcwl_intro, .wcwl_optin").show(),"email"===l[0]?i.focus():"optin"===l[0]?w.focus():"grouped_no_checked"===l[0]&&(t.find(".wcwl_notice p").text(wcwl_data.no_checkboxes_message),t.find(".wcwl_notice").show()))}function wcwl_process_ajax_request(l,e,t){var i=e.data("context"),w=wcwl_get_grouped_products(),_=e.data("product-id"),c=e.data("wpml-lang"),n={action:"wcwl_process_user_waitlist_request",nonce:e.data("nonce"),product_id:_,language:c,products:w,email:t,context:i,archive:l.hasClass("wcwl_frontend_wrap")?"true":"false"};jQuery(document.body).trigger("wcwl_before_waitlist_request",n),jQuery.post(wcwl_data.ajax_url,n).done(function(e){var t;void 0!==e?.data?.redirectUrl?(t=""!==e.data.redirectUrl?e.data.redirectUrl:document.location,document.location=t):(t=l,e.success&&(t=(t=e.data.html.replace("\x3c!-- wcwl_elements --\x3e","")).replace("\x3c!-- wcwl_frontend_wrap --\x3e",""),l.replaceWith(t)),l.hasClass("wcwl_frontend_wrap")?wcwl_process_dom_changes_on_archive_page(_,i,e):(jQuery(".single_variation_wrap").length&&wcwl_update_availability_html_on_variation_form(t,_),(t=jQuery('.wcwl_control[data-product-id="'+_+'"]').closest(".wcwl_elements")).length&&(t.find(".wcwl_intro").hide(),e.success||t.find(".wcwl_notice p").text(e.data),t.find(".wcwl_notice").show(),t.css("display",waitlist_display_class),"none"!==waitlist_display_class&&void 0!==waitlist_display_class||t.show())),jQuery(".woocommerce.quick-view.single-product .product-type-simple").length&&jQuery(".wcwl_frontend_wrap .wcwl_notice").hide(),wcwl_apply_event_on_page_update(),jQuery(document.body).trigger("wcwl_after_waitlist_request",[e,n]))})}function wcwl_update_availability_html_on_variation_form(i,w){var _=jQuery("form.variations_form").data("product_variations");jQuery.each(_,function(e,t){var l;t.variation_id===w&&(i=i.replace("\x3c!-- wcwl_elements --\x3e",""),l=t.availability_html.substring(t.availability_html.lastIndexOf('
'),t.availability_html.lastIndexOf("
\x3c!-- wcwl_elements --\x3e")),t.availability_html=t.availability_html.replace(l,i),_[e]=t)}),jQuery("form.variations_form").data("product_variations",_)}function wcwl_process_dom_changes_on_archive_page(e,t,l){e=jQuery('a[data-product-id="'+e+'"]').closest(".wcwl_frontend_wrap");e.find(".wcwl_elements").css("display",waitlist_display_class),l.success||e.find(".wcwl_notice p").text(l.data),e.find(".wcwl_elements, .wcwl_notice").show(),e.find(".wcwl_notice").next("a button").hide(),e.find(".wcwl_intro, .wcwl_optin, .wcwl_email_elements, .wcwl_control").hide(),"leave"===t?e.find(".woocommerce_waitlist").text(e.find('input[name="wcwl_join_button_text"]').val()):0!=wcwl_data.user_id&&e.find("a.wcwl_control").show(),e.find(".wcwl_toggle").insertAfter(e.find(".wcwl_elements"))}function wcwl_hook_up_variation_events(){jQuery("form.variations_form").on("show_variation",function(){wcwl_apply_event_on_page_update()})}function wcwl_maybe_show_for_bundle(){jQuery(".bundle_wrap .wcwl_elements").remove(),(jQuery(".bundle_availability").is(":visible")&&jQuery(".bundle_availability .stock.out-of-stock").length||wcwl_bundle_data.backorder_allowed&&jQuery(".bundle_availability").is(":visible")&&jQuery(".bundle_availability .stock.available-on-backorder").length)&&jQuery(wcwl_bundle_data.waitlist_html).insertAfter(".bundle_availability"),wcwl_apply_event_on_page_update()}var wcwl_ticket_form,wcwl_tickets,requires_waitlist;function wcwl_get_grouped_products(){var l={};return jQuery(".wcwl_checkbox").length&&jQuery(".wcwl_checkbox").each(function(){var e=jQuery(this).data("product-id"),t=jQuery(this).data("wpml-lang");l[e]={checked:this.checked,lang:t}}),l}function wcwl_add_keyboard_button_events(){jQuery(".wcwl_email_elements").on("keyup keypress","input.wcwl_email",function(e){13===(e.keyCode||e.which)&&(jQuery(this).closest(".wcwl_frontend_wrap").length?jQuery(this).closest(".wcwl_frontend_wrap"):jQuery(this).closest(".wcwl_elements")).find(".woocommerce_waitlist").trigger("click")})}function wcwl_check_optin_field(e){return e.length&&!e.is(":checked")?(e.closest(".wcwl_optin").addClass("wcwl_error_highlight"),!1):(e.closest(".wcwl_optin").removeClass("wcwl_error_highlight"),!0)}function wcwl_check_email_field(e){return!e.length||e.val()&&wcwl_validate_email(e.val())?(e.removeClass("wcwl_error_highlight"),!0):(e.addClass("wcwl_error_highlight"),!1)}function wcwl_validate_email(e){return/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e)}function wcwl_add_screenreader_message(e,t){e=e.find('div[aria-live="polite"]');e.empty(),e.append("

"+t+"

")}function wcwl_hide_waitlist_notice_if_empty(){jQuery(".wcwl_notice:empty").hide()}jQuery(document).ready(function(e){wcwl_apply_event_on_page_update(),wcwl_hook_up_variation_events(),e("body").on("quick-view-displayed",function(){wcwl_hook_up_variation_events()})}),"undefined"!=typeof wcwl_bundle_data&&jQuery(".bundle_availability").length&&jQuery(".bundle_form .bundle_data").on("woocommerce-product-bundle-initialized, woocommerce-product-bundle-updated",function(){setTimeout(function(){wcwl_maybe_show_for_bundle()},300)}),"undefined"!=typeof wcwl_event_data&&jQuery("#tribe-events").length?0<(wcwl_tickets=jQuery(".woocommerce.tribe-tickets-form-row")).length?(requires_waitlist=!1,jQuery.each(wcwl_tickets,function(e,t){var l=jQuery(t).data("product-id"),l=wcwl_event_data.tickets[l];l&&(requires_waitlist=!0,jQuery(l).insertAfter(jQuery(t).find(".tickets_nostock")))}),requires_waitlist&&(jQuery(wcwl_event_data.button).insertAfter(jQuery(".tribe-events-tickets")),wcwl_apply_event_on_page_update())):0<(wcwl_tickets=jQuery('input[value="Tribe__Tickets_Plus__Commerce__WooCommerce__Main"').nextAll("div.product.type-product")).length&&(requires_waitlist=!1,jQuery.each(wcwl_tickets,function(e,t){var l=jQuery(t).data("ticket-id"),l=wcwl_event_data.tickets[l];l&&(requires_waitlist=!0,jQuery(l).insertAfter(jQuery(t)))}),requires_waitlist)&&(jQuery(wcwl_event_data.button).insertAfter(jQuery("form#tribe-tickets")),wcwl_apply_event_on_page_update()):(wcwl_ticket_form=jQuery('form[data-provider-id="woo"]'),"undefined"!=typeof wcwl_event_data&&jQuery(wcwl_ticket_form).length&&0<(wcwl_tickets=0==(wcwl_tickets=wcwl_ticket_form.find(".tribe-tickets__item")).length?wcwl_ticket_form.find(".tribe-tickets__tickets-item"):wcwl_tickets).length&&(requires_waitlist=!1,jQuery.each(wcwl_tickets,function(e,t){var l=jQuery(t).data("ticket-id"),l=wcwl_event_data.tickets[l];l&&(requires_waitlist=!0,jQuery('
'+l+"
").insertAfter(jQuery(t)))}),requires_waitlist)&&(jQuery(wcwl_event_data.button).insertAfter(wcwl_ticket_form),wcwl_apply_event_on_page_update())),jQuery("body").on("quick-view-displayed",function(){wcwl_apply_event_on_page_update()}),jQuery(window).on("wcpf_after_ajax_filtering",function(){wcwl_apply_event_on_page_update()}),jQuery(document).on("ixProductFilterRequestProcessed",function(){wcwl_apply_event_on_page_update()});