/*! For license information please see jpcrm-mailpoet-hub-page.min.js.LICENSE.txt */
(()=>{var t={586:t=>{function jpcrm_mailpoet_initiate_sync(){jQuery("#jpcrm_failed_ajax").hide(),jQuery("#jpcrm_firing_ajax").addClass("active"),jpcrm_mailpoet_fire_sync(function(t){jQuery("#jpcrm_failed_ajax").hide();let e=1e3,a=-1,n=-1;if(void 0!==t.status){switch(t.total_crm_contacts_from_mailpoet&&(document.getElementById("jpcrm-mailpoet-stat-contacts-synced").innerHTML=t.total_crm_contacts_from_mailpoet,t.total_crm_contacts_from_mailpoet>0&&jQuery("#jpcrm-mailpoet-recap-link-to-contacts").removeClass("hidden")),t.status){case"job_in_progress":void 0===window.jpcrm_mailpoet_sync_blocked_runs&&(window.jpcrm_mailpoet_sync_blocked_runs=0),window.jpcrm_mailpoet_sync_blocked_runs++,e=1e4;break;case"sync_part_complete":document.getElementById("jpcrm-mailpoet-status-short-text").textContent=t.status_short_text+" ("+Math.round(t.percentage_completed)+"%)";break;case"sync_completed":return jQuery("#jpcrm_firing_ajax").removeClass("active"),document.getElementById("jpcrm-mailpoet-status-icon").className="icon thumbs up green",document.getElementById("jpcrm-mailpoet-status-short-text").textContent=t.status_short_text,void(document.getElementById("jpcrm-mailpoet-status-long-text").textContent=t.status_long_text);case"not_in_ready_mode":case"error":return jQuery("#jpcrm_firing_ajax").removeClass("active"),jQuery("#jpcrm_failed_ajax").show(),document.getElementById("jpcrm-mailpoet-status-icon").className="icon settings orange",document.getElementById("jpcrm-mailpoet-status-short-text").textContent=t.status_short_text,document.getElementById("jpcrm-mailpoet-status-short-text").className="status orange",void(document.getElementById("jpcrm-mailpoet-status-long-text").textContent=t.status_long_text)}void 0!==t.remaining_pages&&(a=parseInt(t.remaining_pages)),void 0!==t.percentage_completed&&(n=t.percentage_completed);let o="";if(a>0&&(o=jpcrm_mailpoet_language_label("pages_remain","{0} pages remain").format(a)),n>0&&(o+=" ("+Math.round(n)+"%)"),""!==o&&jQuery("#jpcrm_firing_ajax").attr("title",o),void 0===window.jpcrm_mailpoet_sync_blocked_runs||window.jpcrm_mailpoet_sync_blocked_runs<10)jpcrm_sleep(e).then(()=>{jpcrm_mailpoet_initiate_sync()});else{const t="caught_mid_job",e=jpcrm_mailpoet_language_label(t,"Import job is running in the back end. If this message is still shown after some time, please contact support.");jQuery("#jpcrm_firing_ajax").removeClass("active"),document.getElementById("jpcrm-mailpoet-status-short-text").textContent=t,document.getElementById("jpcrm-mailpoet-status-long-text").textContent=e}}},function(t){let e="",a="";if("timeout"==t.statusText)e="caught_mid_job",a=jpcrm_mailpoet_language_label(e,"Import job is running in the back end. If this message is still shown after some time, please contact support.");else{if(0==t.status&&"error"==t.statusText)return;e="server_error",a=jpcrm_mailpoet_language_label(e,"There was a general server error.")+" ("+t.status+")",document.getElementById("jpcrm-mailpoet-status-icon").className="icon thumbs down red",document.getElementById("jpcrm-mailpoet-status-short-text").className="status red";jpcrm_sleep(2e4).then(()=>{jpcrm_mailpoet_initiate_sync()})}jQuery("#jpcrm_firing_ajax").removeClass("active"),document.getElementById("jpcrm-mailpoet-status-short-text").textContent=e,document.getElementById("jpcrm-mailpoet-status-long-text").textContent=a})}function jpcrm_mailpoet_fire_sync(t,e){if(!window.jpcrm_mailpoet_firing_sync){window.jpcrm_mailpoet_firing_sync=!0;const a={action:"jpcrm_mailpoet_fire_sync_job",sec:window.jpcrm_mailpoet_nonce};jQuery.ajax({type:"POST",url:ajaxurl,data:a,dataType:"json",timeout:2e4,success:function(e){window.jpcrm_mailpoet_firing_sync=!1,"function"==typeof t&&t(e)},error:function(t){window.jpcrm_mailpoet_firing_sync=!1,"function"==typeof e&&e(t)}})}}function jpcrm_mailpoet_language_label(t,e){return void 0!==window.jpcrm_mailpoet_language_labels&&void 0!==window.jpcrm_mailpoet_language_labels[t]?window.jpcrm_mailpoet_language_labels[t]:void 0===e?"":e}jQuery(function(){if(window.jpcrm_mailpoet_initiate_ajax_sync){jpcrm_mailpoet_initiate_sync();const t=new URL(location);t.searchParams.delete("definitely_restart_sync"),history.replaceState(null,null,t)}jQuery(".jpcrm-clickable").on("click",function(){const t=jQuery(this).attr("data-href");t&&window.open(t,"_blank").trigger("focus")})}),String.prototype.format||(String.prototype.format=function(){const t=arguments;return this.replace(/{(\d+)}/g,function(e,a){return void 0!==t[a]?t[a]:e})}),t.exports={jpcrm_mailpoet_initiate_sync,jpcrm_mailpoet_fire_sync,jpcrm_mailpoet_language_label}}},e={};var a=function __webpack_require__(a){var n=e[a];if(void 0!==n)return n.exports;var o=e[a]={exports:{}};return t[a](o,o.exports,__webpack_require__),o.exports}(586),n=window="undefined"==typeof window?{}:window;for(var o in a)n[o]=a[o];a.__esModule&&Object.defineProperty(n,"__esModule",{value:!0})})();