import{useState as e,useCallback as t,startTransition as r,useEffect as l}from"react";let useScrollPercentage=c=>{let[n,o]=e(0),i=t(e=>{if(c)return;let t=document.documentElement.scrollHeight-document.documentElement.clientHeight,l=e.currentTarget.scrollY;try{r(()=>{o(Math.ceil(l/t*100))})}catch{r(()=>{o(0)})}},[c]);return l(()=>(window.addEventListener("scroll",i),()=>{window.removeEventListener("scroll",i)}),[i]),n};export{useScrollPercentage};
