$=jQuery,$(document).ready((function(){function bpr_update_postRating(t){void 0!==t&&(!function bpr_setCookie(t,a,o){let e="";if(o){let t=new Date;t.setTime(t.getTime()+24*o*60*60*1e3),e="; expires="+t.toUTCString()}document.cookie=t+"="+(a||"")+e+"; path=/"}(postratinglocalize.post_id+"_post_rating",t,365),$(".js-post-rating-star").removeClass("_hover"),$(".js-post-rating-star").removeClass("js-post-rating-star"),$(".post-rating").attr({"data-total-score":parseFloat($(".post-rating").attr("data-total-score"))+t,"data-total-votes":parseInt($(".post-rating").attr("data-total-votes"))+1}),bpr_set_postRating(),function bpr_update_postRating_ajax(t){$.ajax({type:"POST",url:postratinglocalize.ajaxurl,dataType:"json",data:{post_id:postratinglocalize.post_id,new_rating:t,action:"AjaxPostRating_update"},error:function(t,a,o){return console.log(o),!1}})}(t))}function bpr_set_postRating(){let t=$(".post-rating"),a=t.attr("data-total-score"),o=t.attr("data-total-votes");if(o&&"0"!=o){let e=a/o,s=Math.trunc(e),n=e-s;n>.5?(s++,e=s):n>0&&(e=s+.5);let r=o>1e3?Math.trunc(o/1e3)+"k":o;for(postRating of($(".post-rating__score").html(""+e+"/5"),$(".post-rating__votes").html("("+r+")"),t)){let t=$(postRating).find(".post-rating-star");t.removeClass("_active _hide-half"),t.addClass((function(t){return t0&&n<=.5?"_active _hide-half":""}))}}}$(document).one("scroll resize mousemove tochstart",(function(){$(".post-rating").length>0&&function bpr_get_postRating(){$.ajax({type:"POST",url:postratinglocalize.ajaxurl,dataType:"json",data:{post_id:postratinglocalize.post_id,action:"AjaxPostRating_get"},success:function(t,a,o){(function bpr_getPostRatingCookie(t){var a=document.cookie,o=t+"=",e=a.indexOf("; "+o);if(-1==e){if(0!=(e=a.indexOf(o)))return null}else{e+=2;var s=document.cookie.indexOf(";",e);-1==s&&(s=a.length)}return decodeURI(a.substring(e+o.length,s))})(postratinglocalize.post_id+"_post_rating")&&$(".js-post-rating-star").removeClass("js-post-rating-star"),$(".post-rating._preload").removeClass("_preload"),$(".post-rating").attr({"data-total-score":t.data.total_score,"data-total-votes":t.data.total_votes}),bpr_set_postRating()},error:function(t,a,o){return console.log(o),!1}})}()})),$(document).on("mouseover",".js-post-rating-star",(function(){let t=$(this),a=t.parent().find(".js-post-rating-star"),o=t.index();a.addClass((function(t){return t<=o?"_hover":""}))})),$(document).on("mouseleave",".js-post-rating-star",(function(){$(".js-post-rating-star").removeClass("_hover")})),$(document).on("click",".post-rating:not(._preload) .js-post-rating-star .post-rating-star__full",(function(){bpr_update_postRating($(this).parent().index()+.5)})),$(document).on("click",".post-rating:not(._preload) .js-post-rating-star .post-rating-star__half",(function(){bpr_update_postRating($(this).parent().index()+1)}))}));