const e=(e,t,n)=>n>t?t:n"object"==typeof e&&null!==e;const r=e=>e,o=(e,t,n)=>{const r=t-e;return r?(n-e)/r:1},s={delta:0,timestamp:0,isProcessing:!1},i=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function c(e,n,r={delta:0,timestamp:0,isProcessing:!1}){let o=!1,s=!0;const c=()=>o=!0,l=i.reduce((e,t)=>(e[t]=function(e){let t=new Set,n=new Set,r=!1,o=!1;const s=new Set;let i={delta:0,timestamp:0,isProcessing:!1};function c(t){s.has(t)&&(n.add(t),e()),t(i)}const l={schedule:(e,o=!1,i=!1)=>{const c=i&&r?t:n;return o&&s.add(e),c.add(e),e},cancel:e=>{n.delete(e),s.delete(e)},process:e=>{if(i=e,r)return void(o=!0);r=!0;const s=t;t=n,n=s,t.forEach(c),t.clear(),r=!1,o&&(o=!1,l.process(e))}};return l}(c),e),{}),{setup:f,read:a,resolveKeyframes:u,preUpdate:g,update:d,preRender:h,render:p,postRender:m}=l,w=()=>{const i=t.useManualTiming,c=i?r.timestamp:performance.now();o=!1,i||(r.delta=s?1e3/60:Math.max(Math.min(c-r.timestamp,40),1)),r.timestamp=c,r.isProcessing=!0,f.process(r),a.process(r),u.process(r),g.process(r),d.process(r),h.process(r),p.process(r),m.process(r),r.isProcessing=!1,o&&n&&(s=!1,e(w))};return{schedule:i.reduce((t,n)=>{const i=l[n];return t[n]=(t,n=!1,c=!1)=>(o||(o=!0,s=!0,r.isProcessing||e(w)),i.schedule(t,n,c)),t},{}),cancel:e=>{for(let t=0;t(void 0===t&&(t=e()),t)}(e);return()=>a[t]??n()}const g=u(()=>void 0!==window.ScrollTimeline,"scrollTimeline"),d=u(()=>void 0!==window.ViewTimeline,"viewTimeline");function h(e){return n(e)&&"offsetHeight"in e&&!("ownerSVGElement"in e)}const p=new WeakMap;let m;const w=(e,t,r)=>(o,s)=>{return s&&s[0]?s[0][e+"Size"]:n(i=o)&&"ownerSVGElement"in i&&"getBBox"in o?o.getBBox()[t]:o[r];var i},y=w("inline","width","offsetWidth"),v=w("block","height","offsetHeight");function x({target:e,borderBoxSize:t}){p.get(e)?.forEach(n=>{n(e,{get width(){return y(e,t)},get height(){return v(e,t)}})})}function L(e){e.forEach(x)}function E(e,t){m||"undefined"!=typeof ResizeObserver&&(m=new ResizeObserver(L));const n=function(e){if(null==e)return[];if(e instanceof EventTarget)return[e];if("string"==typeof e){const t=document.querySelectorAll(e);return t?Array.from(t):[]}return Array.from(e).filter(e=>null!=e)}(e);return n.forEach(e=>{let n=p.get(e);n||(n=new Set,p.set(e,n)),n.add(t),m?.observe(e)}),()=>{n.forEach(e=>{const n=p.get(e);n?.delete(t),n?.size||m?.unobserve(e)})}}const W=new Set;let S;function b(e){return W.add(e),S||(S=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};W.forEach(t=>t(e))},window.addEventListener("resize",S)),()=>{W.delete(e),W.size||"function"!=typeof S||(window.removeEventListener("resize",S),S=void 0)}}function B(e,t){return"function"==typeof e?b(e):E(e,t)}const M={x:{length:"Width",position:"Left"},y:{length:"Height",position:"Top"}},T=new WeakMap;function z(t,n,r,s){const i=r[n],{length:c,position:l}=M[n],f=i.current,a=r.time,u=t[`scroll${l}`];i.current=function(e,t){const n=e===document.scrollingElement,r=n&&document.body||e;let o=T.get(r);o||T.set(r,o=getComputedStyle(r));const{writingMode:s,flexDirection:i}=o,c="x"===t!==/^[vs]/.test(s);return(c?"rtl"===o.direction!=("sideways-lr"===s):s.endsWith("rl"))!==(!n&&o.display.includes("flex")&&(c!==("c"===i[0])?i:o.flexWrap).endsWith("reverse"))}(t,n)?-u||0:u,i.containerLength=t[`client${c}`],i.targetLength=t[`scroll${c}`],i.scrollLength=i.targetLength-i.containerLength,i.offset.length=0,i.offset[0]=0,i.offset[1]=i.scrollLength,i.progress=e(0,1,o(0,i.scrollLength,i.current));const g=s-a;var d,h;i.velocity=g>50?0:(d=i.current-f,(h=g)?d*(1e3/h):0)}const A={start:0,center:.5,end:1};function O(e,t,n=0){let r=0;if(e in A&&(e=A[e]),"string"==typeof e){const t=parseFloat(e);e.endsWith("px")?r=t:e.endsWith("%")?e=t/100:e.endsWith("vw")?r=t/100*document.documentElement.clientWidth:e.endsWith("vh")?r=t/100*document.documentElement.clientHeight:e=t}return"number"==typeof e&&(r=t*e),n+r}const k=[0,0];function H(e,t,n,r){let o=Array.isArray(e)?e:k,s=0,i=0;return"number"==typeof e?o=[e,e]:"string"==typeof e&&(o=(e=e.trim()).includes(" ")?e.split(" "):[e,A[e]?e:"0"]),s=O(o[0],n,r),i=O(o[1],t),s-i}const R={All:[[0,0],[1,1]]};function P(t,n){const{offset:r=R.All,axis:s="y"}=n,i=t[s];i.offset.length=0;const c=r.length;for(let e=0;ee[n],s=t=>e[r?n-t:t];if(e[0]===e[1]&&t=s(i+1);)i++;const c=(i+o(s(i),s(i+1),t))/n;return r?1-c:c}(i.offset,i.current))}function N(e,t,n,r={}){const{target:o}=r,s=o||r.offset;return{measure:t=>{if(s){n.time=t.time;for(const e in M){const r=e,{offset:o}=n[r];Object.assign(n[r],t[r]),n[r].offset=o}if(o&&o!==e){const t=function(e,t){const n={x:0,y:0};let r=e;for(;r&&r!==t;)if(h(r))n.x+=r.offsetLeft,n.y+=r.offsetTop,r=r.offsetParent;else if("svg"===r.tagName){const e=r.getBoundingClientRect();r=r.parentElement;const t=r.getBoundingClientRect();n.x+=e.left-t.left,n.y+=e.top-t.top}else{if(!(r instanceof SVGGraphicsElement))break;{const{x:e,y:t}=r.getBBox();n.x+=e,n.y+=t;let o=null,s=r.parentNode;for(;!o;)"svg"===s.tagName&&(o=s),s=r.parentNode;r=o}}return n}(o,e),r=function(e){return"getBBox"in e&&"svg"!==e.tagName?e.getBBox():{width:e.clientWidth,height:e.clientHeight}}(o);n.x.targetOffset=t.x,n.y.targetOffset=t.y,n.x.targetLength=r.width,n.y.targetLength=r.height}P(n,r)}},notify:e=>t(s?n:e)}}const V=new WeakMap,$=new WeakMap,j=new WeakMap,C=new WeakMap,G=e=>e===document.scrollingElement?window:e;function q(e,{container:t=document.scrollingElement,trackContentSize:n=!1,...o}={}){if(!t)return r;let i=j.get(t);i||(i=new Set,j.set(t,i));const c=N(t,e,{time:0,x:{current:0,offset:[],progress:0,scrollLength:0,targetOffset:0,targetLength:0,containerLength:0,velocity:0},y:{current:0,offset:[],progress:0,scrollLength:0,targetOffset:0,targetLength:0,containerLength:0,velocity:0}},o);if(i.add(c),!V.has(t)){const e={time:0,x:{current:0,offset:[],progress:0,scrollLength:0,targetOffset:0,targetLength:0,containerLength:0,velocity:0},y:{current:0,offset:[],progress:0,scrollLength:0,targetOffset:0,targetLength:0,containerLength:0,velocity:0}},n=()=>{!function(e,t,n){for(const r in M)z(e,r,t,n);t.time=n}(t,e,s.timestamp);for(const t of i)t.measure(e);l.preUpdate(r)},r=()=>{for(const t of i)t.notify(e)},o=()=>l.read(n);V.set(t,o);const c=G(t);window.addEventListener("resize",o),t!==document.documentElement&&$.set(t,B(t,o)),c.addEventListener("scroll",o),o()}if(n&&!C.has(t)){const e=V.get(t),n={width:t.scrollWidth,height:t.scrollHeight},r=()=>{const r=t.scrollWidth,o=t.scrollHeight;n.width===r&&n.height===o||(e(),n.width=r,n.height=o)},o=l.read(r,!0);C.set(t,o)}const a=V.get(t);return l.read(a,!1,!0),()=>{f(a);const e=j.get(t);if(!e)return;if(e.delete(c),e.size)return;j.delete(t);const n=V.get(t);V.delete(t),n&&(G(t).removeEventListener("scroll",n),$.get(t)?.(),window.removeEventListener("resize",n));const r=C.get(t);r&&(f(r),C.delete(t))}}const F=new Map;const U=e=>{if(/v/u.test(e))return[];const t=H(e,0,0,0);return[H(e,0,1,0)-t,t-H(e,1,0,0),t]},D=([e,t,n])=>!n&&(0===t||1===t)&&`${t?"entry":"exit"}-crossing ${100*e}%`;function K(e,t){const{target:n,container:r,axis:o}=t,s=n&&function(e=R.All){if(2!==e.length)return;const[t,n]=e.map(U),r=[D(t),D(n)],o=n[0]-t[0],s=t[1]-n[1];return r[0]&&r[1]&&(o||s)?{points:r,a:o,b:s,cover:!t[0]&&1===o&&1===s}:void 0}(t.offset),i=function(e){return"undefined"!=typeof window&&(e?d():g())}(n)&&(n?!!s:!t.offset),c=new Map,l=new Set;let f,a=!1;const u=(e,t)=>{const[n,r]=s.points;t.effect.updateTiming({direction:a?"normal"===e?"reverse":"alternate-reverse":e}),Object.assign(t,{rangeStart:a?r:n,rangeEnd:a?n:r}),t.play()},h=[e.attachTimeline({get timeline(){return i?function({container:e,target:t,axis:n}){let r=F.get(e);r||(r=new Map,F.set(e,r));const o=t??"self";let s=r.get(o);return s||(s={},r.set(o,s)),s[n]||(s[n]=t?new ViewTimeline({subject:t,axis:n}):new ScrollTimeline({source:e,axis:n}))}(t):void 0},onAttach:s&&(e=>{const t=e.effect.getTiming().direction;c.set(e,t),u(t,e)}),observe:e=>(e.pause(),l.add(e),f||(f=q(e=>{l.forEach(t=>{t.time=t.iterationDuration*e[o].progress})},t)),()=>l.delete(e))})];if(i&&s){const{a:e,b:t}=s,i="y"===o?"clientHeight":"clientWidth",l=()=>{a!==(a=e*n[i]+t*r[i]<0)&&c.forEach(u)};l(),e*t<0&&h.push(B(l),B([n,r],l))}return()=>{h.forEach(e=>e()),f?.()}}function I(e,{axis:t="y",source:n,container:o=document.scrollingElement,...s}={}){if(!o)return r;const i={axis:t,container:n||o,...s};return"function"==typeof e?q(n=>e(n[t].progress,n),i):K(e,i)}export{I as scroll}; //# sourceMappingURL=size-rollup-scroll.js.map