(()=>{const e="a[data-gb-prefetch][href]";function t(e){try{const t=new URL(e,window.location.href);return t.origin!==window.location.origin?"":t.href}catch(e){return""}}const n={};document.body.addEventListener("mouseenter",(function(r){const o=r.target.closest(e);if(o){var c;const e=t(o.href);if(!e)return;if(null!==(c=n[e])&&void 0!==c&&c)return;const r=document.createElement("link");r.rel="prefetch",r.href=e,document.head.appendChild(r),n[e]=!0}}),!0),document.addEventListener("click",(n=>{const r=n.target.closest(e);if(r&&r.href){const e=r.getAttribute("data-gb-router-target");if(!e)return;const o=t(r.href);if(!o)return;n.preventDefault(),function(e){return fetch(e).then((e=>{if(!e.ok)throw new Error("Network error");return e.text()})).catch((e=>{console.error("Error fetching prefetched page:",e)}))}(o).then((t=>{(function(e="",t=""){const n=document.querySelector(`[data-gb-router-region="${e}"]`);if(!n||!t)throw new Error("Missing container or prefetched content");const r=n.parentNode.querySelector(".gb-query-loop-pagination"),o=document.createElement("div");o.innerHTML=t;const c=o.querySelector(`[data-gb-router-region="${e}"]`),i=c.parentNode.querySelector(".gb-query-loop-pagination");c&&n?(n.innerHTML=c.innerHTML,function(e){const t=e.getBoundingClientRect();t.top>=0&&t.top<=(window.innerHeight||document.documentElement.clientHeight)||e.scrollIntoView({behavior:"smooth",block:"start"})}(n),r.innerHTML=i.innerHTML):console.error("Unable to update posts container: Missing elements")})(e,t),history.pushState(null,"",o)}))}}))})();