import{r as R,j as z}from"./index.0b22cc41.js";import{a as j,u as N,c as v,m as _}from"./0f7d6b42.js";const F=(e,t,n)=>Math.min(Math.max(n,e),t),O=e=>typeof e=="number",X=e=>Array.isArray(e)&&!O(e[0]),Y=(e,t,n)=>{const r=t-e;return((n-e)%r+r)%r+e};function V(e,t){return X(e)?e[Y(0,e.length,t)]:e}const P=(e,t,n)=>-n*e+n*t+e,k=e=>e,x=(e,t,n)=>t-e===0?1:(n-e)/(t-e);function T(e,t){const n=e[e.length-1];for(let r=1;r<=t;r++){const s=x(0,t,r);e.push(P(n,1,s))}}function I(e){const t=[0];return T(t,e-1),t}function q(e,t=I(e.length),n=k){const r=e.length,s=r-t.length;return s>0&&T(t,s),o=>{let i=0;for(;i<r-2&&!(o<t[i+1]);i++);let c=F(0,1,x(t[i],t[i+1],o));return c=V(n,i)(c),P(e[i],e[i+1],c)}}const M=e=>typeof e=="function",B=e=>typeof e=="string";function D(e,t){return t?e*(1e3/t):0}function G(e,t){var n;return typeof e=="string"?t?((n=t[e])!==null&&n!==void 0||(t[e]=document.querySelectorAll(e)),e=t[e]):e=document.querySelectorAll(e):e instanceof Element&&(e=[e]),Array.from(e||[])}function $(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]]);return n}const y=new WeakMap;let d;function C(e,t){if(t){const{inlineSize:n,blockSize:r}=t[0];return{width:n,height:r}}else return e instanceof SVGElement&&"getBBox"in e?e.getBBox():{width:e.offsetWidth,height:e.offsetHeight}}function J({target:e,contentRect:t,borderBoxSize:n}){var r;(r=y.get(e))===null||r===void 0||r.forEach(s=>{s({target:e,contentSize:t,get size(){return C(e,n)}})})}function K(e){e.forEach(J)}function Q(){typeof ResizeObserver!="undefined"&&(d=new ResizeObserver(K))}function U(e,t){d||Q();const n=G(e);return n.forEach(r=>{let s=y.get(r);s||(s=new Set,y.set(r,s)),s.add(t),d==null||d.observe(r)}),()=>{n.forEach(r=>{const s=y.get(r);s==null||s.delete(t),s!=null&&s.size||d==null||d.unobserve(r)})}}const w=new Set;let p;function Z(){p=()=>{const e={width:window.innerWidth,height:window.innerHeight},t={target:window,size:e,contentSize:e};w.forEach(n=>n(t))},window.addEventListener("resize",p)}function ee(e){return w.add(e),p||Z(),()=>{w.delete(e),!w.size&&p&&(p=void 0)}}function te(e,t){return M(e)?ee(e):U(e,t)}const ne=50,b=()=>({current:0,offset:[],progress:0,scrollLength:0,targetOffset:0,targetLength:0,containerLength:0,velocity:0}),re=()=>({time:0,x:b(),y:b()}),se={x:{length:"Width",position:"Left"},y:{length:"Height",position:"Top"}};function S(e,t,n,r){const s=n[t],{length:o,position:i}=se[t],c=s.current,h=n.time;s.current=e["scroll"+i],s.scrollLength=e["scroll"+o]-e["client"+o],s.offset.length=0,s.offset[0]=0,s.offset[1]=s.scrollLength,s.progress=x(0,s.scrollLength,s.current);const l=r-h;s.velocity=l>ne?0:D(s.current-c,l)}function oe(e,t,n){S(e,"x",t,n),S(e,"y",t,n),t.time=n}function ie(e,t){let n={x:0,y:0},r=e;for(;r&&r!==t;)if(r instanceof HTMLElement)n.x+=r.offsetLeft,n.y+=r.offsetTop,r=r.offsetParent;else if(r instanceof SVGGraphicsElement&&"getBBox"in r){const{top:s,left:o}=r.getBBox();for(n.x+=o,n.y+=s;r&&r.tagName!=="svg";)r=r.parentNode}return n}const le={Enter:[[0,1],[1,1]],Exit:[[0,0],[1,0]],Any:[[1,0],[0,1]],All:[[0,0],[1,1]]},E={start:0,center:.5,end:1};function H(e,t,n=0){let r=0;if(E[e]!==void 0&&(e=E[e]),B(e)){const s=parseFloat(e);e.endsWith("px")?r=s:e.endsWith("%")?e=s/100:e.endsWith("vw")?r=s/100*document.documentElement.clientWidth:e.endsWith("vh")?r=s/100*document.documentElement.clientHeight:e=s}return O(e)&&(r=t*e),n+r}const ce=[0,0];function fe(e,t,n,r){let s=Array.isArray(e)?e:ce,o=0,i=0;return O(e)?s=[e,e]:B(e)&&(e=e.trim(),e.includes(" ")?s=e.split(" "):s=[e,E[e]?e:"0"]),o=H(s[0],n,r),i=H(s[1],t),o-i}const ae={x:0,y:0};function ue(e,t,n){let{offset:r=le.All}=n;const{target:s=e,axis:o="y"}=n,i=o==="y"?"height":"width",c=s!==e?ie(s,e):ae,h=s===e?{width:e.scrollWidth,height:e.scrollHeight}:{width:s.clientWidth,height:s.clientHeight},l={width:e.clientWidth,height:e.clientHeight};t[o].offset.length=0;let a=!t[o].interpolate;const u=r.length;for(let f=0;f<u;f++){const L=fe(r[f],l[i],h[i],c[o]);!a&&L!==t[o].interpolatorOffsets[f]&&(a=!0),t[o].offset[f]=L}a&&(t[o].interpolate=q(I(u),t[o].offset),t[o].interpolatorOffsets=[...t[o].offset]),t[o].progress=t[o].interpolate(t[o].current)}function de(e,t=e,n){if(n.x.targetOffset=0,n.y.targetOffset=0,t!==e){let r=t;for(;r&&r!=e;)n.x.targetOffset+=r.offsetLeft,n.y.targetOffset+=r.offsetTop,r=r.offsetParent}n.x.targetLength=t===e?t.scrollWidth:t.clientWidth,n.y.targetLength=t===e?t.scrollHeight:t.clientHeight,n.x.containerLength=e.clientWidth,n.y.containerLength=e.clientHeight}function he(e,t,n,r={}){const s=r.axis||"y";return{measure:()=>de(e,r.target,n),update:o=>{oe(e,n,o),(r.offset||r.target)&&ue(e,n,r)},notify:M(t)?()=>t(n):ge(t,n[s])}}function ge(e,t){return e.pause(),e.forEachNative((n,{easing:r})=>{var s,o;if(n.updateDuration)r||(n.easing=k),n.updateDuration(1);else{const i={duration:1e3};r||(i.easing="linear"),(o=(s=n.effect)===null||s===void 0?void 0:s.updateTiming)===null||o===void 0||o.call(s,i)}}),()=>{e.currentTime=t.progress}}const g=new WeakMap,W=new WeakMap,m=new WeakMap,A=e=>e===document.documentElement?window:e;function pe(e,t={}){var{container:n=document.documentElement}=t,r=$(t,["container"]);let s=m.get(n);s||(s=new Set,m.set(n,s));const o=re(),i=he(n,e,o,r);if(s.add(i),!g.has(n)){const l=()=>{const u=performance.now();for(const f of s)f.measure();for(const f of s)f.update(u);for(const f of s)f.notify()};g.set(n,l);const a=A(n);window.addEventListener("resize",l,{passive:!0}),n!==document.documentElement&&W.set(n,te(n,l)),a.addEventListener("scroll",l,{passive:!0})}const c=g.get(n),h=requestAnimationFrame(c);return()=>{var l;typeof e!="function"&&e.stop(),cancelAnimationFrame(h);const a=m.get(n);if(!a||(a.delete(i),a.size))return;const u=g.get(n);g.delete(n),u&&(A(n).removeEventListener("scroll",u),(l=W.get(n))===null||l===void 0||l(),window.removeEventListener("resize",u))}}const ve=()=>({scrollX:v(0),scrollY:v(0),scrollXProgress:v(0),scrollYProgress:v(0)});function ye({container:e,target:t,layoutEffect:n=!0,...r}={}){const s=j(ve);return(n?N:R.exports.useEffect)(()=>pe(({x:i,y:c})=>{s.scrollX.set(i.current),s.scrollXProgress.set(i.progress),s.scrollY.set(c.current),s.scrollYProgress.set(c.progress)},{...r,container:(e==null?void 0:e.current)||void 0,target:(t==null?void 0:t.current)||void 0}),[]),s}function Ee(){const{scrollYProgress:e}=ye();return z("div",{className:"sticky z-30 top-12 md:top-20 left-0 w-full",children:z(_.div,{className:"bg-black dark:bg-white",style:{scaleX:e,transformOrigin:"left",height:"5px"}})})}export{Ee as ScrollTracker};
//# sourceMappingURL=d3340342.js.map