(()=>{"use strict";!function(n){if("undefined"!=typeof rtsbCrParams&&rtsbCrParams.is_checkout){var e=window.RtsbFrontendHelpers||window.RTSB.helpers,t=function(){var n=(window.RTSB||{}).cache,e=(null==n?void 0:n.create("AbandonedCartRecovery"))||null;return{name:"AbandonedCartRecovery",version:"1.0.0",init:function(){return this.run(),e.set("initialized",!0),this},refresh:function(){this.run()},run:function(){var n=setInterval(function(){document.querySelector("#email,#billing_email")&&(clearInterval(n),i())},100)},destroy:function(){e.clear()}}},i=function(){var t=n(document).find("#email,#billing_email"),i=n(document).find("#billing-first_name,#billing_first_name"),o=n(document).find("#billing-last_name,#billing_last_name");if(t.length){var s=function(){return{email:(t.val()||"").trim(),first_name:(i.val()||"").trim(),last_name:(o.val()||"").trim()}},l=e.rtsbDebounce(function(){var n=s(),e=n.email,t=n.first_name,i=n.last_name;e&&a(e)&&r(e,t,i)},500);n(document).on("input validate change focusout",".input-text, input, select, input:checkbox",l);var c=s(),u=c.email,d=c.first_name,m=c.last_name;u&&a(u)&&r(u,d,m)}},a=function(n){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(n).toLowerCase())},r=function(e,t,i){e&&a(e)&&(console.log("email rtsbDebounce:",e),n.ajax({url:rtsbCrParams.ajax_url,method:"POST",dataType:"json",data:{action:"rtsb_abandoned_cart_recovery",email:e,first_name:t,last_name:i,sessionId:rtsbCrParams.session_id,__rtsb_wpnonce:rtsbCrParams.__rtsb_wpnonce},success:function(n){console.log(n.data.message)}}))};!function(){if(window.RTSB&&window.RTSB._initialized){var n;null===(n=RTSB.modules.register("AbandonedCartRecovery",t))||void 0===n||n.init()}else{var e=t();window.rtsbAbandonedCartRecovery=e.run,window.rtsbAbandonedCartRecovery()}}()}}(jQuery)})();