function wcpr_pagination_basic(e,o){e=jQuery(e),o=jQuery(o);let r=!1;jQuery(document).on("click",".woocommerce-pagination a",function(t){if(r)return!1;console.log("ajax_pagination_running"),t.preventDefault(),t.stopPropagation();let a="1"===woocommerce_photo_reviews_params.display?e.find(".wcpr-grid"):e.find(woocommerce_photo_reviews_params.container),n=parseInt(a.offset().top)-200;window.scrollTo({top:n,behavior:"smooth"}),r=!0;let i=jQuery(this).attr("href");a.find(".wcpr-grid-overlay").length||a.append('<div class="wcpr-grid-overlay wcpr-hidden"></div>');let c=a.find(".wcpr-grid-overlay");c.removeClass("wcpr-hidden"),jQuery.ajax({url:i,type:"get",success:function(e){if(e){let r=jQuery(e);"1"===woocommerce_photo_reviews_params.display?a.html(r.find(".wcpr-grid").html()):a.html(r.find(woocommerce_photo_reviews_params.container).html()),r.find(".woocommerce-pagination").length&&o.html(r.find(".woocommerce-pagination").html()),jQuery(document.body).trigger("wcpr_ajax_pagination_end")}c.addClass("wcpr-hidden"),r=!1},error:function(e){r=!1,c.addClass("wcpr-hidden")}})});let t=e.find(".wcpr-filter-container");if(!t.length)return!1;jQuery(".et_divi_theme").length?jQuery("a.wcpr-filter-button").on("click",function(a){a.preventDefault(),a.stopPropagation();let n=jQuery(this);if(r||0===parseInt(n.find(".wcpr-filter-button-count").html())&&!n.hasClass("wcpr-active"))return!1;r=!0,a.preventDefault();let i=jQuery(this).attr("href"),c="1"===woocommerce_photo_reviews_params.display?e.find(".wcpr-grid"):e.find(woocommerce_photo_reviews_params.container);if(0===c.length){if("1"===woocommerce_photo_reviews_params.display)e.append('<div class="'+woocommerce_photo_reviews_params.grid_class+'"><div class="wcpr-grid-overlay"></div></div>'),c=e.find(".wcpr-grid");else{"."===woocommerce_photo_reviews_params.container.substr(0,1)?e.append('<ol class="'+woocommerce_photo_reviews_params.container.substr(1)+'"></ol>'):e.append('<ol id="'+woocommerce_photo_reviews_params.container.substr(1)+'"></ol>'),c=e.find(woocommerce_photo_reviews_params.container)}e.find(".woocommerce-noreviews").hide()}c.find(".wcpr-grid-overlay").length||c.append('<div class="wcpr-grid-overlay wcpr-hidden"></div>');let l=c.find(".wcpr-grid-overlay");l.removeClass("wcpr-hidden"),t.addClass("wcpr-filter-loading"),jQuery.ajax({url:i,type:"get",data:{wcpr_is_ajax:1},success:function(r){if(r){let a,n;r=r.replace(/(\r\n\t|\n|\r\t)/gm,"");let i=jQuery(r);"1"===woocommerce_photo_reviews_params.display?c.html(i.find(".wcpr-grid").html()):c.html(i.find(woocommerce_photo_reviews_params.container).html()),i.find(".woocommerce-pagination").length?o&&o.length?o.html(i.find(".woocommerce-pagination").html()):(e.append('<nav class="woocommerce-pagination">'+i.find(".woocommerce-pagination").html()+"</nav>"),o=e.find(".woocommerce-pagination")):o&&o.length>0&&(o.remove(),o=null),null!=(n=(a=/<div class="wcpr-filter-container" style="display: none;">([^]+?)<\/div>/gm).exec(r))&&t.html(n[1]),jQuery(document.body).trigger("wcpr_ajax_pagination_end")}},error:function(e){console.log(e)},complete:function(){r=!1,l.addClass("wcpr-hidden"),t.removeClass("wcpr-filter-loading")}})}):jQuery(document).on("click","a.wcpr-filter-button",function(a){a.preventDefault(),a.stopPropagation();let n=jQuery(this);if(r||0===parseInt(n.find(".wcpr-filter-button-count").html())&&!n.hasClass("wcpr-active"))return!1;r=!0,a.preventDefault();let i=jQuery(this).attr("href"),c="1"===woocommerce_photo_reviews_params.display?e.find(".wcpr-grid"):e.find(woocommerce_photo_reviews_params.container);if(0===c.length){if("1"===woocommerce_photo_reviews_params.display)e.append('<div class="'+woocommerce_photo_reviews_params.grid_class+'"><div class="wcpr-grid-overlay"></div></div>'),c=e.find(".wcpr-grid");else{"."===woocommerce_photo_reviews_params.container.substr(0,1)?e.append('<ol class="'+woocommerce_photo_reviews_params.container.substr(1)+'"></ol>'):e.append('<ol id="'+woocommerce_photo_reviews_params.container.substr(1)+'"></ol>'),c=e.find(woocommerce_photo_reviews_params.container)}e.find(".woocommerce-noreviews").hide()}c.find(".wcpr-grid-overlay").length||c.append('<div class="wcpr-grid-overlay wcpr-hidden"></div>');let l=c.find(".wcpr-grid-overlay");l.removeClass("wcpr-hidden"),t.addClass("wcpr-filter-loading"),jQuery.ajax({url:i,type:"get",data:{wcpr_is_ajax:1},success:function(r){if(r){let a,n;r=r.replace(/(\r\n\t|\n|\r\t)/gm,"");let i=jQuery(r);"1"===woocommerce_photo_reviews_params.display?c.html(i.find(".wcpr-grid").html()):c.html(i.find(woocommerce_photo_reviews_params.container).html()),i.find(".woocommerce-pagination").length?o&&o.length?o.html(i.find(".woocommerce-pagination").html()):(e.append('<nav class="woocommerce-pagination">'+i.find(".woocommerce-pagination").html()+"</nav>"),o=e.find(".woocommerce-pagination")):o&&o.length>0&&(o.remove(),o=null),null!=(n=(a=/<div class="wcpr-filter-container" style="display: none;">([^]+?)<\/div>/gm).exec(r))&&t.html(n[1]),jQuery(document.body).trigger("wcpr_ajax_pagination_end")}},error:function(e){console.log(e)},complete:function(){r=!1,l.addClass("wcpr-hidden"),t.removeClass("wcpr-filter-loading")}})})}function wcpr_pagination_loadmore(e,o){e=jQuery(e),o=jQuery(o);let r=e.find(".wcpr-filter-container"),t=jQuery(".wcpr-load-more-reviews-cpage").val(),a=jQuery(".wcpr-load-more-reviews-product-id").val(),n=jQuery(".wcpr-load-more-reviews-rating").val(),i=jQuery(".wcpr-load-more-reviews-verified").val(),c=jQuery(".wcpr-load-more-reviews-image").val(),l=e.find(".woocommerce-noreviews"),s="1"===woocommerce_photo_reviews_params.display?e.find(".wcpr-grid"):e.find(woocommerce_photo_reviews_params.container);function p(){if(0===s.length){let o="1"===woocommerce_photo_reviews_params.display?".":woocommerce_photo_reviews_params.container.substr(0,1);s="."===o?"1"===woocommerce_photo_reviews_params.display?jQuery('<div class="'+woocommerce_photo_reviews_params.grid_class+'"></div>'):jQuery('<ol class="'+woocommerce_photo_reviews_params.container.substr(1)+'"></ol>'):jQuery('<ol id="'+woocommerce_photo_reviews_params.container.substr(1)+'"></ol>'),e.append(s)}}if(t&&a){if(t>1){let o=e.find(".wcpr-load-more-reviews-button");jQuery.ajax({url:woocommerce_photo_reviews_params.ajaxurl,data:{action:"wcpr_ajax_load_more_reviews",post_id:a,cpage:t,rating:n,verified:i,image:c,is_shortcode:"",frontend_style:woocommerce_photo_reviews_params.display},type:"POST",beforeSend:function(){o.addClass("wcpr-loading")},success:function(e){e.html&&(p(),s.html(e.html)),jQuery(document.body).trigger("wcpr_ajax_load_more_reviews_end")},complete:function(){o.removeClass("wcpr-loading")}})}jQuery(document).on("click",".wcpr-load-more-reviews-button:not(.shortcode-wcpr-load-more-reviews-button):not(.wcpr-loading)",function(){let e=jQuery(this);return 2==woocommerce_photo_reviews_params.sort?1==++t&&t++:1==--t&&t--,t>-1&&jQuery.ajax({url:woocommerce_photo_reviews_params.ajaxurl,data:{action:"wcpr_ajax_load_more_reviews",post_id:a,cpage:t,rating:n,verified:i,image:c,is_shortcode:"",frontend_style:woocommerce_photo_reviews_params.display},type:"POST",beforeSend:function(o){e.addClass("wcpr-loading")},success:function(o){o.html?(s.append(o.html),0==t&&e.parent().remove()):e.parent().remove(),jQuery(document.body).trigger("wcpr_ajax_load_more_reviews_end")},complete:function(){e.removeClass("wcpr-loading")}}),!1});let m=!1;if(r.length){let d=r.find(".wcpr-filter-button-ul");jQuery(document).on("click","a.wcpr-filter-button",function(w){let _=jQuery(this);if(m||0===parseInt(_.find(".wcpr-filter-button-count").html())&&!_.hasClass("wcpr-active"))return!1;t=0;let u=_.data("filter_type");switch(u){case"all":if(_.hasClass("wcpr-active"))return!1;n="";break;case"image":c=_.hasClass("wcpr-active")?"":1;break;case"verified":i=_.hasClass("wcpr-active")?"":1;break;default:if(_.hasClass("wcpr-active"))return!1;n=parseInt(u)}m=!0,w.preventDefault(),r.addClass("wcpr-filter-loading"),jQuery.ajax({url:woocommerce_photo_reviews_params.ajaxurl,type:"POST",data:{action:"wcpr_ajax_load_more_reviews",post_id:a,cpage:t,rating:n,verified:i,image:c,filter_type:u,is_shortcode:"",frontend_style:woocommerce_photo_reviews_params.display},success:function(a){2==woocommerce_photo_reviews_params.sort?t++:t--,a.html&&(l.hide(),p()),s.html(a.html),t=parseInt(a.cpage),0===o.length&&(e.append('<nav class="woocommerce-pagination"></nav>'),o=e.find(".woocommerce-pagination")),o.html(a.load_more_html);let n=a.update_count;if(n)for(let e in n)n.hasOwnProperty(e)&&r.find('.wcpr-filter-button[data-filter_type="'+e+'"]').find(".wcpr-filter-button-count").html(n[e]);switch(r.find(".wcpr-filter-rating-placeholder .wcpr-filter-button-count").html(n.all),u){case"all":d.find(".wcpr-filter-button").removeClass("wcpr-active"),_.addClass("wcpr-active"),r.find(".wcpr-filter-rating-placeholder").html(_.html());break;case"image":case"verified":_.hasClass("wcpr-active")?_.removeClass("wcpr-active"):_.addClass("wcpr-active");break;default:d.find(".wcpr-filter-button").removeClass("wcpr-active"),_.addClass("wcpr-active")}jQuery(document.body).trigger("wcpr_ajax_load_more_reviews_end")},error:function(e){console.log(e)},complete:function(){m=!1,r.removeClass("wcpr-filter-loading")}})})}}}function wcpr_helpful_button(){"use strict";jQuery(document).on("click",".wcpr-comment-helpful-button",function(e){e.stopPropagation();let o=jQuery(this),r=o.hasClass("wcpr-comment-helpful-button-up-vote")?"up":"down",t=o.closest(".wcpr-comment-helpful-button-container"),a=t.data("comment_id");"up"===r&&t.hasClass("wcpr-comment-helpful-button-voted-up")||"down"===r&&t.hasClass("wcpr-comment-helpful-button-voted-down")||t.hasClass("wcpr-comment-helpful-button-voting")||(t.addClass("wcpr-comment-helpful-button-voting"),jQuery.ajax({url:woocommerce_photo_reviews_params.ajaxurl,data:{action:"wcpr_helpful_button_handle",vote:r,comment_id:a},type:"POST",success:function(e){if("success"===e.status&&(t.find(".wcpr-comment-helpful-button-up-vote-count").html(parseInt(e.up)),t.find(".wcpr-comment-helpful-button-down-vote-count").html(parseInt(e.down)),"up"===r?t.removeClass("wcpr-comment-helpful-button-voted-down").addClass("wcpr-comment-helpful-button-voted-up"):t.removeClass("wcpr-comment-helpful-button-voted-up").addClass("wcpr-comment-helpful-button-voted-down"),t.parent().hasClass("reviews-content-right-meta")||t.parent().hasClass("shortcode-reviews-content-right-meta"))){let o=jQuery('.wcpr-comment-helpful-button-container[data-comment_id="'+a+'"]');o.find(".wcpr-comment-helpful-button-up-vote-count").html(parseInt(e.up)),o.find(".wcpr-comment-helpful-button-down-vote-count").html(parseInt(e.down)),"up"===r?o.removeClass("wcpr-comment-helpful-button-voted-down").addClass("wcpr-comment-helpful-button-voted-up"):o.removeClass("wcpr-comment-helpful-button-voted-up").addClass("wcpr-comment-helpful-button-voted-down")}},error:function(){},complete:function(){t.removeClass("wcpr-comment-helpful-button-voting")}}))})}function viSwipeDetect(e,o){var r,t,a,n,i,c,l=e,s=o||function(e){};l.addEventListener("touchstart",function(e){var o=e.changedTouches[0];r="none",t=o.pageX,a=o.pageY,c=(new Date).getTime()},!1),l.addEventListener("touchmove",function(e){e.preventDefault()},!1),l.addEventListener("touchend",function(e){var o=e.changedTouches[0];n=o.pageX-t,i=o.pageY-a,(new Date).getTime()-c<=300&&(Math.abs(n)>=150&&Math.abs(i)<=100?r=n<0?"left":"right":Math.abs(i)>=150&&Math.abs(n)<=100&&(r=i<0?"up":"down")),s(r)},!1)}jQuery(window).on("elementor/frontend/init",()=>{"use strict";elementorFrontend.hooks.addAction("frontend/element_ready/woocommerce-photo-reviews.default",function(e){window.elementor&&wcpr_helpful_button()})}),jQuery(document).ready(function(e){"use strict";let o=1==woocommerce_photo_reviews_params.image_caption_enable,r=woocommerce_photo_reviews_params.i18n_image_caption;function t(e,t){let a;return a=o?`<div class="wcpr-selected-image"><img title="${t}" src="${e}" class="wcpr-selected-image-preview"><div class="wcpr-selected-image-info"><div class="wcpr-selected-image-name" title="${t}">${t}</div><input class="wcpr-selected-image-caption" type="text" name="wcpr_image_caption[]" placeholder="${r}"></div></div>`:`<div class="wcpr-selected-image"><img title="${t}" src="${e}" class="wcpr-selected-image-preview"><div class="wcpr-selected-image-info"><div class="wcpr-selected-image-name" title="${t}">${t}</div></div></div>`}wcpr_helpful_button();let a=woocommerce_photo_reviews_params.max_files;e("#commentform").on("change",".wcpr_image_upload",function(o){if(e(this).parent().find(".wcpr-selected-image-container").html(""),this.files.length>a)return alert(woocommerce_photo_reviews_params.warning_max_files),e(this).val(""),!1;this.files.length>0&&function(o){for(let a=0;a<o.files.length;a++){var r=new FileReader;r.onload=function(r){e(o).parent().find(".wcpr-selected-image-container").append(t(r.target.result,o.files[a].name))},r.readAsDataURL(o.files[a])}}(this)}),e("#commentform").find('input[type="submit"]').on("click",function(o){let r=e(this).closest("form"),t=r.find('textarea[id="comment"]')||r.find('textarea[name="comment"]'),n=r.find('input[name="author"]'),i=r.find('input[name="email"]');if(t.length>0&&!t.val()&&1!=woocommerce_photo_reviews_params.allow_empty_comment)return alert(woocommerce_photo_reviews_params.i18n_required_comment_text),o.preventDefault(),t.focus(),!1;if("on"===woocommerce_photo_reviews_params.enable_photo){let e=r.find(".wcpr_image_upload");if(e.length>0){let r=parseInt(e.get(0).files.length);if("on"===woocommerce_photo_reviews_params.required_image&&0===r)return alert(woocommerce_photo_reviews_params.warning_required_image),o.preventDefault(),!1;if(r>a)return alert(woocommerce_photo_reviews_params.warning_max_files),o.preventDefault(),!1}else if("on"===woocommerce_photo_reviews_params.required_image)return alert(woocommerce_photo_reviews_params.warning_required_image),o.preventDefault(),!1}return n.length>0&&n.attr("required")&&!n.val()?(alert(woocommerce_photo_reviews_params.i18n_required_name_text),o.preventDefault(),n.focus(),!1):i.length>0&&i.attr("required")&&!i.val()?(alert(woocommerce_photo_reviews_params.i18n_required_email_text),o.preventDefault(),i.focus(),!1):!1===r.find('input[name="wcpr_gdpr_checkbox"]').prop("checked")?(alert(woocommerce_photo_reviews_params.warning_gdpr),o.preventDefault(),!1):void 0});let n=woocommerce_photo_reviews_params.hasOwnProperty("comments_container_id")?woocommerce_photo_reviews_params.comments_container_id:"comments",i=e("#"+n);if(i.prepend(e(".wcpr-filter-container")).prepend(e(".wcpr-overall-rating-and-rating-count")).prepend(e(".woocommerce-Reviews-title").eq(0)),woocommerce_photo_reviews_params.pagination_ajax&&i.length){let e=i.find(".woocommerce-pagination");woocommerce_photo_reviews_params.loadmore_button?(e.html(jQuery(".wcpr-load-more-reviews-button-modal").html()),wcpr_pagination_loadmore(i,i.find(".woocommerce-pagination"))):wcpr_pagination_basic(i,i.find(".woocommerce-pagination"))}else jQuery(".et_divi_theme").length&&jQuery("a.wcpr-filter-button").on("click",function(){location.href=jQuery(this).attr("href")});e(document).on("click",".reviews_tab",function(){i=e("#"+n),(e(".wcpr-filter-container").length>0&&0===i.find(".wcpr-filter-container").length||e(".wcpr-overall-rating-and-rating-count").length>0&&0===i.find(".wcpr-overall-rating-and-rating-count").length)&&i.prepend(e(".wcpr-filter-container")).prepend(e(".wcpr-overall-rating-and-rating-count")).prepend(e(".woocommerce-Reviews-title").eq(0))})});