!function(){"use strict";const t={},e=function(e={}){if(!(e={el:null,action:null,...e}).el)return;if(!e.action)return;if(e.el.classList.contains("ct-loading"))return;let n=parseInt(e.el.dataset.page,10);if("prev"===e.action&&1===n)return;if(e.el.querySelectorAll(".ct-trending-block-item").length<4&&1===n)return;if(e.el.dataset.page.indexOf("last")>-1&&"next"===e.action)return;e.el.querySelectorAll(".ct-trending-block-item").forEach(function(t,e){t.style.opacity=0,t.style.transform="translateY(3px)",t.style.transitionDelay=(e?.15*e-.05:0)+"s"});let i="prev"===e.action?n-1:n+1;var o;Promise.all([new Promise(function(t){requestAnimationFrame(function(){setTimeout(function(){return t()},650)})}),(o=`${ct_localizations.ajax_url}?action=blocksy_get_trending_posts&page=${i}`,t[o]?new Promise(function(e){e(t[o]),window.ct_customizer_localizations||(t[o]=t[o].clone())}):new Promise(function(e){return fetch(o).then(function(n){e(n),window.ct_customizer_localizations||(t[o]=n.clone())})})).then(function(t){return t.json()})]).then(function([t,{success:n,data:o}]){if(!n)return;let{posts:{is_last_page:r,posts:c}}=o;e.el.dataset.page=`${i}${r?":last":""}`,[...e.el.querySelectorAll(".ct-trending-block-item")].map(function(t){return t.remove()}),c.map(function(t,n){return e.el.insertAdjacentHTML("beforeend",`<div class="ct-trending-block-item" style="opacity: 0; transform: translateY(3px); transition-delay: ${n?.15*n-.05:0}s;">\n\t\t\t\t\t${t.image}\n\n\t\t\t\t\t<div class="ct-trending-block-item-content">\n\t\t\t\t\t\t${t.taxonomy}\n\t\t\t\t\t\t<a href="${t.url}" class="ct-post-title">\n\t\t\t\t\t\t\t${t.title}\n\t\t\t\t\t\t</a>\n\t\t\t\t\t\t${t.price}\n\t\t\t\t\t</div>\n\t\t\t\t</a>`)}),setTimeout(function(){e.el.querySelectorAll(".ct-trending-block-item").forEach(function(t,e){t.style.opacity=1,t.style.transform="translateY(0)",t.style.transitionDelay=(e?.15*e-.05:0)+"s"}),requestAnimationFrame(function(){setTimeout(function(){e.el.querySelectorAll(".ct-trending-block-item").forEach(function(t){t.removeAttribute("style")})},650)})},50)})};(0,window.ctFrontend.registerDynamicChunk)("blocksy_ext_trending",{mount:function(t,{event:n}){const i=t.closest("[data-page]");t.classList.contains("ct-arrow-prev")&&e({el:i,action:"prev"}),t.classList.contains("ct-arrow-next")&&e({el:i,action:"next"})}})}();