jQuery(document).ready((function(o){"use strict";if(o(document.body).hasClass("elementor-editor-active"))return!1;function e(o){for(var e=o+"=",t=document.cookie.split(";"),a=0;a0?"&":"?")+a),t}function a(e){if(void 0!==o.fn.block)if(Array.isArray(e))for(var t of e)a(t);else e.addClass("js-blocked").block({message:null,overlayCSS:{background:"#fff url("+yith_woocompare.loader+") no-repeat center",backgroundSize:"20px 20px",opacity:.6}})}function r(o){if(Array.isArray(o))for(var e of o)r(e);else o.hasClass("js-blocked")&&o.removeClass("js-blocked").unblock()}function i(e){var t=o(".yith-woocompare-widget-content"),a=o("#yith-woocompare:not(.fixed-compare-table)");return o.extend(e,{context:"frontend",lang:a.data("lang")||t.data("lang")})}function n(e){e?.table_html&&(o("#yith-woocompare:not(.fixed-compare-table)").replaceWith(e.table_html),o(document).trigger("yith_woocompare_table_updated")),e?.widget_html&&(o(".yith-woocompare-widget-content").replaceWith(e.widget_html),o(document).trigger("yith_woocompare_widget_updated"))}function c(){var t=o(".yith-woocompare-counter");if(t.length){var a=t.data("type"),r=t.data("text_o"),i=e(yith_woocompare.cookie_name),n=i?JSON.parse(i).length:0;r=r.replace("{{count}}",n),t.find(".yith-woocompare-count").html("text"===a?r:n)}o(document).trigger("yith_woocompare_counter_updated",n)}var d,p;d=o(".yith-woocompare-widget-content"),p=o("#yith-woocompare:not(.fixed-compare-table)"),(d.length||p.length)&&(a([d,p]),o.ajax({type:"post",url:yith_woocompare.ajaxurl.toString().replace("%%endpoint%%",yith_woocompare.actionreload),data:i({action:yith_woocompare.actionreload}),dataType:"json",cache:!1,error:function(o,e,t){console.log(o,e,t),r([d,p])},success:n})),c(),o(document).on("click","a.compare:not(.added)",(function(e){e.preventDefault();var t=o(this),d=t.closest(".yith-woocompare-related").length,p=t.data("product_id");a(t),o.ajax({type:"post",url:yith_woocompare.ajaxurl.toString().replace("%%endpoint%%",yith_woocompare.actionadd),data:i({action:yith_woocompare.actionadd,id:p}),cache:!1,dataType:"json",error:function(o,e,a){console.log(o,e,a),r(t)},success:function(e){d||(r(t),t.addClass("added").attr("href",e.table_url).text(yith_woocompare.added_label),"yes"!==yith_woocompare.auto_open||e.only_one||yith_woocompare.is_page||o("body").trigger("yith_woocompare_open_popup",{response:e.table_url,button:t})),n(e),c()}})})),yith_woocompare.is_page||o(document).on("click","a.compare.added",(function(e){e.preventDefault();var t=this.href;void 0!==t&&o("body").trigger("yith_woocompare_open_popup",{response:t,button:o(this)})})),o("body").on("yith_woocompare_open_popup",(function(e,t){var a=t.response;t.button;yith_woocompare.force_showing_popup||o(window).width()>=768?(o.colorbox({href:a,iframe:!0,width:"80%",height:"80%",fixed:!0,className:"yith_woocompare_colorbox",close:yith_woocompare.close_label,onClosed:function(){yith_woocompare.im_in_page?location.reload():(update_widget(!1),update_counter())},onComplete:function(){l(),o.dataTableFunction()}}),o(window).resize((function(){o.colorbox.resize({width:"90%",height:"90%"})}))):window.location=yith_woocompare.page_url})),o(document).on("click",".compare-list .remove a, a.yith_woocompare_clear",(function(e){e.preventDefault();var t=o(this),d=t.data("product_id");a(t),o.ajax({type:"post",url:yith_woocompare.ajaxurl.toString().replace("%%endpoint%%",yith_woocompare.actionremove),data:i({action:yith_woocompare.actionremove,id:d}),cache:!1,dataType:"json",error:function(o,e,a){console.log(o,e,a),r(t)},success:function(e){var a="all"===d?".compare.added":'.compare[data-product_id="'+d+'"]',r=yith_woocompare.custom_label_for_compare_button?t.closest("tbody").find("tr"+yith_woocompare.selector_for_custom_label_compare_button).find("td.product_"+d).text():yith_woocompare.button_text;o(a,window.parent.document).removeClass("added").html(r),n(e),c(),o(document).trigger("yith_woocompare_product_removed")}})})),o(".yith-woocompare-open a, a.yith-woocompare-open").on("click",(function(e){yith_woocompare.is_page||(e.preventDefault(),o("body").trigger("yith_woocompare_open_popup",{response:t("action",yith_woocompare.actionview)+"&iframe=1"}))})),o(".yith-woocompare-widget").on("click","a.compare-widget",(function(e){yith_woocompare.is_page||(e.preventDefault(),o("body").trigger("yith_woocompare_open_popup",{response:o(this).attr("href")}))})).on("click","li a.remove, a.clear-all",(function(e){e.preventDefault();var t=o(this),d=t.data("product_id"),p=t.closest(".yith-woocompare-widget-content");if(void 0===d){var l=t.attr("href").split("id=");d=l[1]}a(p),o.ajax({type:"post",url:yith_woocompare.ajaxurl.toString().replace("%%endpoint%%",yith_woocompare.actionremove),data:i({action:yith_woocompare.actionremove,id:d}),cache:!1,dataType:"json",error:function(o,e,t){console.log(o,e,t),r(p)},success:function(e){n(e),c(),"all"===d?o(".compare.added").removeClass("added").html(yith_woocompare.button_text):o('.compare[data-product_id="'+d+'"]').removeClass("added").html(yith_woocompare.button_text)}})})),o(document).on("click","#yith-woocompare-cat-nav li > a",(function(e){e.preventDefault();var t=o(this),n=t.closest("#yith-woocompare"),c=t.data("cat_id"),d=t.closest("#yith-woocompare-cat-nav > ul").data("product_ids");a(n),o.ajax({type:"post",url:yith_woocompare.ajaxurl.toString().replace("%%endpoint%%",yith_woocompare.actionfilter),data:i({action:yith_woocompare.actionfilter,yith_compare_cat:c,yith_compare_prod:d}),cache:!1,dataType:"html",error:function(o,e,t){console.log(o,e,t),r(n)},success:function(e){n.replaceWith(e),o(document).trigger("yith_woocompare_table_updated")}})}));var l=function(){if(void 0!==o.fn.owlCarousel){var e=o("#yith-woocompare-related"),t=e.find(".related-products"),a=e.find(".related-slider-nav");if(!e.length)return;t.owlCarousel({autoplay:yith_woocompare.autoplay_related,autoplayHoverPause:!0,loop:!0,margin:15,responsiveClass:!0,responsive:{0:{items:2},480:{items:3},768:{items:yith_woocompare.num_related}}}),a.length&&(a.find(".related-slider-nav-prev").click((function(){t.trigger("prev.owl.carousel")})),a.find(".related-slider-nav-next").click((function(){t.trigger("next.owl.carousel")})))}};l(),o(document).on("yith_woocompare_table_updated",l),o.dataTableFunction=function(e){var t,a=e&&e.length?e:o(document).find("#yith-woocompare table.compare-list"),r=o(window).outerWidth();a.length&&void 0!==o.fn.DataTable&&void 0!==o.fn.imagesLoaded&&(a.each((function(){var e=o(this);e.imagesLoaded((function(){t=e.DataTable({info:!1,scrollX:!0,scrollCollapse:!0,paging:!1,ordering:!1,searching:!1,autoWidth:!1,destroy:!0,fixedColumns:{leftColumns:yith_woocompare.fixedcolumns}})}))})),o(window).off("yith_woocompare_refresh_table").on("yith_woocompare_refresh_table",(function(){void 0!==t&&r!==o(window).outerWidth()&&(t.destroy(),o.dataTableFunction(!1))})))},o.dataTableFunction(!1),o(window).on("resize orientationchange",(function(){o(window).trigger("yith_woocompare_refresh_table")})),o(document).on("yith_woocompare_table_updated",(function(e,t){var a=!!t&&o(t).find("table.compare-list");o.dataTableFunction(a)})),o("body").on("added_to_cart",(function(e,t,a,r){o(r).closest("table.compare-list").length&&r.hide()}))}));