jQuery(function(a){var t=function(){var t=this;this.updateFragments=this.updateFragments.bind(this);this.getProductIds=this.getProductIds.bind(this);a(document.body).on("products_compare_fragments_refresh products_compare_list_updated",{productsCompareFragments:t},t.refreshFragments).on("added_to_compare removed_from_compare",{productsCompareFragments:t},t.updateFragmentsOnChanges);a(window).on("pageshow",function(t){if(t.originalEvent.persisted){a(document.body).trigger("products_compare_fragments_refresh",[true])}});if("yes"===wcboost_products_compare_fragments_params.refresh_on_load){a(document.body).trigger("products_compare_fragments_refresh")}};t.prototype.refreshFragments=function(t,e){var r=t.data.productsCompareFragments;var o={time:(new Date).getTime()};if("yes"===wcboost_products_compare_fragments_params.refresh_on_load||e){o.product_button_ids=r.getProductIds()}a.post({url:woocommerce_params.wc_ajax_url.toString().replace("%%endpoint%%","get_compare_fragments"),data:o,dataType:"json",timeout:wcboost_products_compare_fragments_params.request_timeout,success:function(t){if(!t.success){a(document.body).trigger("products_compare_fragments_failed");return}r.updateFragments(t.data.fragments);a(document.body).trigger("products_compare_fragments_refreshed")},error:function(){a(document.body).trigger("products_compare_fragments_ajax_error")}})};t.prototype.getProductIds=function(){var r=[];a(".wcboost-products-compare-button").each(function(t,e){r.push(e.dataset.product_id)});return r};t.prototype.updateFragmentsOnChanges=function(t,e,r){var o=t.data.productsCompareFragments;o.updateFragments(r)};t.prototype.updateFragments=function(t){a.each(t,function(t,e){a(t).replaceWith(e)});a(document.body).trigger("products_compare_fragments_loaded")};new t});