document.addEventListener("DOMContentLoaded",(e=>{const t=document.querySelectorAll(".wp-block-wpseopress-table-of-contents");if(!t)return;const o=document.querySelectorAll("h1,h2,h3,h4,h5,h6");o&&t.forEach((e=>{const t=e.querySelectorAll("a"),n=[...t].map((e=>e.getAttribute("href")));let r=n[0],s=!1;const c=new IntersectionObserver(((o,c)=>{o.sort(((e,t)=>e.time-t.time)),o.forEach((e=>{const t=e.target,o=t.getAttribute("ID")||null;if(t&&o&&n.includes(`#${o}`))if(e.isIntersecting||e.boundingClientRect.y<e.rootBounds.top)r=n.find((e=>e===`#${o}`));else{if(!s)return;const e=n.findIndex((e=>e===r));if(-1===e)return;const t=Math.max(e-1,0);r=n[t]}})),s=!0,(o=>{const n=e.querySelector(`[href="${o}"] `);n&&(t.forEach((e=>e.closest("li").classList.remove("active"))),n.closest("li").classList.add("active"))})(r)}),{rootMargin:"0px 0px -80%",threshold:1});o.forEach((e=>{const t=e.getAttribute("ID")||null;t&&n.includes(`#${t}`)&&c.observe(e)}))}))}));