text: "use strict";jQuery(document).ready(function(s){function c(e){s(".product-sync-field").each(function(){var o=s(this);s(this).hasClass("wc-enhanced-select")&&(o=s(this).next("span.select2-container")),e?o.css("pointer-events","all").css("opacity","1.0"):o.css("pointer-events","none").css("opacity","0.4")})}s(".woocommerce-help-tip").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200}),s("form.wc-facebook-settings").hasClass("disconnected")&&c(!1),s("input#wc_facebook_enable_product_sync").on("change",function(o){s("form.wc-facebook-settings").hasClass("disconnected")?s(this).css("pointer-events","none").css("opacity","0.4"):c(s(this).is(":checked"))}).trigger("change");var t=!1;function e(o){n(0<arguments.length&&void 0!==o?o:null),window.syncStatusInterval||(window.syncStatusInterval=setInterval(r,1e4))}function n(o){var e=0<arguments.length&&void 0!==o?o:null;c(!1),s('input#wc_facebook_enable_product_sync, input[name="save_product_sync_settings"]').css("pointer-events","none").css("opacity","0.4");o=facebook_for_woocommerce_settings_sync.i18n.sync_in_progress;e&&(o=(o+=1<e?facebook_for_woocommerce_settings_sync.i18n.sync_remaining_items_plural:facebook_for_woocommerce_settings_sync.i18n.sync_remaining_items_singular).replace("{count}",e)),s("#sync_progress").show().html(o).css("color","inherit"),facebook_for_woocommerce_settings_sync.sync_in_progress=!0}function _(o){o=0<arguments.length&&void 0!==o?o:"";facebook_for_woocommerce_settings_sync.sync_in_progress=!1,clearInterval(window.syncStatusInterval),c(!(window.syncStatusInterval=null)),s('input#wc_facebook_enable_product_sync, input[name="save_product_sync_settings"]').css("pointer-events","all").css("opacity","1"),o?s("#sync_progress").show().html(o).css("color","#DC3232"):s("#sync_progress").hide()}function r(){facebook_for_woocommerce_settings_sync.sync_in_progress&&s.post(facebook_for_woocommerce_settings_sync.ajax_url,{action:"wc_facebook_get_sync_status",nonce:facebook_for_woocommerce_settings_sync.sync_status_nonce},function(o){console.log(o),o.success&&(0<o.data?e(o.data):_())})}s('input[name="save_product_sync_settings"]').on("click",function(o){if(t)return!0;o.preventDefault();var e,c,n=s(this),o=(e=s("#wc_facebook_excluded_product_category_ids").val(),c=[],window.facebook_for_woocommerce_settings_sync&&window.facebook_for_woocommerce_settings_sync.excluded_category_ids&&(c=window.facebook_for_woocommerce_settings_sync.excluded_category_ids),s(e).not(c).get()),c=(e=s("#wc_facebook_excluded_product_tag_ids").val(),c=[],window.facebook_for_woocommerce_settings_sync&&window.facebook_for_woocommerce_settings_sync.excluded_tag_ids&&(c=window.facebook_for_woocommerce_settings_sync.excluded_tag_ids),s(e).not(c).get());0<o.length||0<c.length?s.post(facebook_for_woocommerce_settings_sync.ajax_url,{action:"facebook_for_woocommerce_set_excluded_terms_prompt",security:facebook_for_woocommerce_settings_sync.set_excluded_terms_prompt_nonce,categories:o,tags:c},function(o){o&&!o.success?(s("#wc-backbone-modal-dialog .modal-close").trigger("click"),new s.WCBackboneModal.View({target:"facebook-for-woocommerce-modal",string:o.data}),s(".facebook-for-woocommerce-confirm-settings-change").on("click",function(){blockModal(),t=!0,n.trigger("click")})):(t=!0,n.trigger("click"))}):(t=!0,n.trigger("click"))}),facebook_for_woocommerce_settings_sync.sync_in_progress&&e(),s("#woocommerce-facebook-settings-sync-products").click(function(o){var c;o.preventDefault(),confirm(facebook_for_woocommerce_settings_sync.i18n.confirm_sync)&&(n(),c=Date.now(),s.post(facebook_for_woocommerce_settings_sync.ajax_url,{action:"wc_facebook_sync_products",nonce:facebook_for_woocommerce_settings_sync.sync_products_nonce},function(o){var e;console.log(o),o.success?setTimeout(r,Math.max(0,1e4-(Date.now()-c))):(e=facebook_for_woocommerce_settings_sync.i18n.general_error,_(e=o.data&&0<o.data.length?o.data:e))}).fail(function(){_(facebook_for_woocommerce_settings_sync.i18n.general_error)}))})});