"use strict";const e=require("vue"),m=["onClick"],u={class:"anchor-label"},p=e.defineComponent({name:"ClAnchorNav",__name:"Index",props:{className:{type:String,default:""},list:{type:Array,required:!0}},setup(s){const a=s,c=e.ref(""),i=e.ref(!1),d=l=>{const o=document.getElementById(l);o&&o.scrollIntoView({behavior:"smooth",block:"start"})},r=()=>{const l=window.scrollY,o=window.innerHeight;i.value=l>100;const t=a.list.map(n=>({id:n.id,element:document.getElementById(n.id)})).filter(n=>n.element!==null);for(let n=t.length-1;n>=0;n--)if(t[n].element.getBoundingClientRect().top<=o/2){c.value=t[n].id;break}};return e.onMounted(()=>{window.addEventListener("scroll",r),r()}),e.onUnmounted(()=>{window.removeEventListener("scroll",r)}),(l,o)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["anchor-nav",{"is-fixed":i.value}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.list,t=>(e.openBlock(),e.createElementBlock("div",{key:t.id,class:e.normalizeClass(["anchor-item",{active:c.value===t.id}]),onClick:n=>d(t.id)},[o[0]||(o[0]=e.createElementVNode("span",{class:"anchor-dot"},null,-1)),e.createElementVNode("span",u,e.toDisplayString(t.label),1)],10,m))),128))],2))}});module.exports=p;
//# sourceMappingURL=ClAnchorNav.cjs.map
