1import{G as s}from"./GeneralHelper-3cfd9cf0.js";class h{constructor(t){this.elem=t,this.button=this.elem.matches("button")?this.elem:this.elem.querySelector("button"),this.visibleClass="back-to-top--visible",this.disabled=!1;const e=this.elem.getAttribute("data-threshold"),o=Number.parseFloat(e);this.threshold=Number.isFinite(o)?o:.05;const i=(this.elem.getAttribute("data-scroll-behavior")||"").toLowerCase();this.scrollBehavior=i==="auto"?"auto":"smooth",this.onScrollThrottled=s.throttle(this.onScroll.bind(this),100),this.onClick=this.onClick.bind(this),this.onKeyDown=this.onKeyDown.bind(this)}init(){this.button&&(this.button.type=this.button.type||"button",this.button.getAttribute("aria-label")||this.button.setAttribute("aria-label","Back to top"),this.button.addEventListener("click",this.onClick),this.button.matches("button")||(this.button.setAttribute("role","button"),this.button.setAttribute("tabindex","0"),this.button.addEventListener("keydown",this.onKeyDown)),window.addEventListener("scroll",this.onScrollThrottled,{passive:!0}),window.addEventListener("resize",this.onScrollThrottled,{passive:!0}),this.onScroll())}destroy(){this.button&&(this.button.removeEventListener("click",this.onClick),this.button.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("scroll",this.onScrollThrottled),window.removeEventListener("resize",this.onScrollThrottled))}onKeyDown(t){(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.onClick())}onScroll(){if(this.disabled)return;const t=document.documentElement,e=window.scrollY||t.scrollTop||0,o=Math.max(0,t.scrollHeight-window.innerHeight);(o>0?e/o:0)>=this.threshold?(this.elem.classList.add(this.visibleClass),this.button.removeAttribute("tabindex"),this.button.removeAttribute("aria-hidden")):(this.elem.classList.remove(this.visibleClass),this.button.setAttribute("tabindex","-1"),this.button.setAttribute("aria-hidden","true"))}onClick(){if(this.disabled)return;const e=window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches?"auto":this.scrollBehavior;window.scrollTo({top:0,left:0,behavior:e}),this.button.focus({preventScroll:!0})}}export{h as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.