!function(){"use strict";(0,window.ctFrontend.registerDynamicChunk)("blocksy_ext_woo_extra_advanced_reviews_sync_cache",{mount:function(t){const e=t.querySelectorAll(".ct-review-vote");if(!e.length)return;const n=[...new Set(Array.from(e).map(function(t){return+t.dataset.commentId}))];fetch(`${ct_localizations.ajax_url}?action=ct_sync_votes`,{method:"POST",body:JSON.stringify({comments_ids:n}),headers:{Accept:"application/json","Content-Type":"application/json"}}).then(function(t){return t.json()}).then(function({votes:t,user:e}){Object.entries(t).forEach(function([t,n]){if(!n)return;const o=document.querySelector(`.ct-review-vote[data-comment-id="${t}"][data-vote="up"]`),c=document.querySelector(`.ct-review-vote[data-comment-id="${t}"][data-vote="down"]`);if(!o||!c)return;const{up:r=[],down:a=[]}=n;r.includes(e)&&(o.dataset.buttonState="active",c.dataset.buttonState=""),a.includes(e)&&(o.dataset.buttonState="",c.dataset.buttonState="active");const i=o.closest(".ct-review-votes"),u=i.querySelector(".ct-review-total-count"),s=i.querySelector(".ct-review-upvote-count");i.querySelector(".ct-review-vote-count").dataset.count=r.length,u.innerHTML=r.length+a.length,s.innerHTML=r.length})})}})}();