import"./chunk-rrt78xph.js";var m="1.3.17";function T(q,B,F){return Math.max(q,Math.min(B,F))}function v(q,B,F){return(1-F)*q+F*B}function p(q,B,F,J){return v(q,B,1-Math.exp(-F*J))}function g(q,B){return(q%B+B)%B}var d=class{isRunning=!1;value=0;from=0;to=0;currentTime=0;lerp;duration;easing;onUpdate;advance(q){if(!this.isRunning)return;let B=!1;if(this.duration&&this.easing){this.currentTime+=q;let F=T(0,this.currentTime/this.duration,1);B=F>=1;let J=B?1:this.easing(F);this.value=this.from+(this.to-this.from)*J}else if(this.lerp){if(this.value=p(this.value,this.to,this.lerp*60,q),Math.round(this.value)===this.to)this.value=this.to,B=!0}else this.value=this.to,B=!0;if(B)this.stop();this.onUpdate?.(this.value,B)}stop(){this.isRunning=!1}fromTo(q,B,{lerp:F,duration:J,easing:K,onStart:$,onUpdate:Z}){this.from=this.value=q,this.to=B,this.lerp=F,this.duration=J,this.easing=K,this.currentTime=0,this.isRunning=!0,$?.(),this.onUpdate=Z}};function c(q,B){let F;return function(...J){let K=this;clearTimeout(F),F=setTimeout(()=>{F=void 0,q.apply(K,J)},B)}}var i=class{constructor(q,B,{autoResize:F=!0,debounce:J=250}={}){if(this.wrapper=q,this.content=B,F){if(this.debouncedResize=c(this.resize,J),this.wrapper instanceof Window)window.addEventListener("resize",this.debouncedResize,!1);else this.wrapperResizeObserver=new ResizeObserver(this.debouncedResize),this.wrapperResizeObserver.observe(this.wrapper);this.contentResizeObserver=new ResizeObserver(this.debouncedResize),this.contentResizeObserver.observe(this.content)}this.resize()}width=0;height=0;scrollHeight=0;scrollWidth=0;debouncedResize;wrapperResizeObserver;contentResizeObserver;destroy(){if(this.wrapperResizeObserver?.disconnect(),this.contentResizeObserver?.disconnect(),this.wrapper===window&&this.debouncedResize)window.removeEventListener("resize",this.debouncedResize,!1)}resize=()=>{this.onWrapperResize(),this.onContentResize()};onWrapperResize=()=>{if(this.wrapper instanceof Window)this.width=window.innerWidth,this.height=window.innerHeight;else this.width=this.wrapper.clientWidth,this.height=this.wrapper.clientHeight};onContentResize=()=>{if(this.wrapper instanceof Window)this.scrollHeight=this.content.scrollHeight,this.scrollWidth=this.content.scrollWidth;else this.scrollHeight=this.wrapper.scrollHeight,this.scrollWidth=this.wrapper.scrollWidth};get limit(){return{x:this.scrollWidth-this.width,y:this.scrollHeight-this.height}}},X=class{events={};emit(q,...B){let F=this.events[q]||[];for(let J=0,K=F.length;J{this.events[q]=this.events[q]?.filter((F)=>B!==F)}}off(q,B){this.events[q]=this.events[q]?.filter((F)=>B!==F)}destroy(){this.events={}}},y=16.666666666666668,I={passive:!1},o=class{constructor(q,B={wheelMultiplier:1,touchMultiplier:1}){this.element=q,this.options=B,window.addEventListener("resize",this.onWindowResize,!1),this.onWindowResize(),this.element.addEventListener("wheel",this.onWheel,I),this.element.addEventListener("touchstart",this.onTouchStart,I),this.element.addEventListener("touchmove",this.onTouchMove,I),this.element.addEventListener("touchend",this.onTouchEnd,I)}touchStart={x:0,y:0};lastDelta={x:0,y:0};window={width:0,height:0};emitter=new X;on(q,B){return this.emitter.on(q,B)}destroy(){this.emitter.destroy(),window.removeEventListener("resize",this.onWindowResize,!1),this.element.removeEventListener("wheel",this.onWheel,I),this.element.removeEventListener("touchstart",this.onTouchStart,I),this.element.removeEventListener("touchmove",this.onTouchMove,I),this.element.removeEventListener("touchend",this.onTouchEnd,I)}onTouchStart=(q)=>{let{clientX:B,clientY:F}=q.targetTouches?q.targetTouches[0]:q;this.touchStart.x=B,this.touchStart.y=F,this.lastDelta={x:0,y:0},this.emitter.emit("scroll",{deltaX:0,deltaY:0,event:q})};onTouchMove=(q)=>{let{clientX:B,clientY:F}=q.targetTouches?q.targetTouches[0]:q,J=-(B-this.touchStart.x)*this.options.touchMultiplier,K=-(F-this.touchStart.y)*this.options.touchMultiplier;this.touchStart.x=B,this.touchStart.y=F,this.lastDelta={x:J,y:K},this.emitter.emit("scroll",{deltaX:J,deltaY:K,event:q})};onTouchEnd=(q)=>{this.emitter.emit("scroll",{deltaX:this.lastDelta.x,deltaY:this.lastDelta.y,event:q})};onWheel=(q)=>{let{deltaX:B,deltaY:F,deltaMode:J}=q,K=J===1?y:J===2?this.window.width:1,$=J===1?y:J===2?this.window.height:1;B*=K,F*=$,B*=this.options.wheelMultiplier,F*=this.options.wheelMultiplier,this.emitter.emit("scroll",{deltaX:B,deltaY:F,event:q})};onWindowResize=()=>{this.window={width:window.innerWidth,height:window.innerHeight}}},k=(q)=>Math.min(1,1.001-Math.pow(2,-10*q)),Y=class{_isScrolling=!1;_isStopped=!1;_isLocked=!1;_preventNextNativeScrollEvent=!1;_resetVelocityTimeout=null;_rafId=null;isTouching;time=0;userData={};lastVelocity=0;velocity=0;direction=0;options;targetScroll;animatedScroll;animate=new d;emitter=new X;dimensions;virtualScroll;constructor({wrapper:q=window,content:B=document.documentElement,eventsTarget:F=q,smoothWheel:J=!0,syncTouch:K=!1,syncTouchLerp:$=0.075,touchInertiaExponent:Z=1.7,duration:U,easing:G,lerp:V=0.1,infinite:z=!1,orientation:D="vertical",gestureOrientation:Q=D==="horizontal"?"both":"vertical",touchMultiplier:A=1,wheelMultiplier:j=1,autoResize:L=!0,prevent:P,virtualScroll:C,overscroll:_=!0,autoRaf:E=!1,anchors:W=!1,autoToggle:N=!1,allowNestedScroll:R=!1,__experimental__naiveDimensions:x=!1,naiveDimensions:u=x,stopInertiaOnNavigate:h=!1}={}){if(window.lenisVersion=m,!q||q===document.documentElement)q=window;if(typeof U==="number"&&typeof G!=="function")G=k;else if(typeof G==="function"&&typeof U!=="number")U=1;if(this.options={wrapper:q,content:B,eventsTarget:F,smoothWheel:J,syncTouch:K,syncTouchLerp:$,touchInertiaExponent:Z,duration:U,easing:G,lerp:V,infinite:z,gestureOrientation:Q,orientation:D,touchMultiplier:A,wheelMultiplier:j,autoResize:L,prevent:P,virtualScroll:C,overscroll:_,autoRaf:E,anchors:W,autoToggle:N,allowNestedScroll:R,naiveDimensions:u,stopInertiaOnNavigate:h},this.dimensions=new i(q,B,{autoResize:L}),this.updateClassName(),this.targetScroll=this.animatedScroll=this.actualScroll,this.options.wrapper.addEventListener("scroll",this.onNativeScroll,!1),this.options.wrapper.addEventListener("scrollend",this.onScrollEnd,{capture:!0}),this.options.anchors||this.options.stopInertiaOnNavigate)this.options.wrapper.addEventListener("click",this.onClick,!1);if(this.options.wrapper.addEventListener("pointerdown",this.onPointerDown,!1),this.virtualScroll=new o(F,{touchMultiplier:A,wheelMultiplier:j}),this.virtualScroll.on("scroll",this.onVirtualScroll),this.options.autoToggle)this.checkOverflow(),this.rootElement.addEventListener("transitionend",this.onTransitionEnd,{passive:!0});if(this.options.autoRaf)this._rafId=requestAnimationFrame(this.raf)}destroy(){if(this.emitter.destroy(),this.options.wrapper.removeEventListener("scroll",this.onNativeScroll,!1),this.options.wrapper.removeEventListener("scrollend",this.onScrollEnd,{capture:!0}),this.options.wrapper.removeEventListener("pointerdown",this.onPointerDown,!1),this.options.anchors||this.options.stopInertiaOnNavigate)this.options.wrapper.removeEventListener("click",this.onClick,!1);if(this.virtualScroll.destroy(),this.dimensions.destroy(),this.cleanUpClassName(),this._rafId)cancelAnimationFrame(this._rafId)}on(q,B){return this.emitter.on(q,B)}off(q,B){return this.emitter.off(q,B)}onScrollEnd=(q)=>{if(!(q instanceof CustomEvent)){if(this.isScrolling==="smooth"||this.isScrolling===!1)q.stopPropagation()}};dispatchScrollendEvent=()=>{this.options.wrapper.dispatchEvent(new CustomEvent("scrollend",{bubbles:this.options.wrapper===window,detail:{lenisScrollEnd:!0}}))};get overflow(){let q=this.isHorizontal?"overflow-x":"overflow-y";return getComputedStyle(this.rootElement)[q]}checkOverflow(){if(["hidden","clip"].includes(this.overflow))this.internalStop();else this.internalStart()}onTransitionEnd=(q)=>{if(q.propertyName.includes("overflow"))this.checkOverflow()};setScroll(q){if(this.isHorizontal)this.options.wrapper.scrollTo({left:q,behavior:"instant"});else this.options.wrapper.scrollTo({top:q,behavior:"instant"})}onClick=(q)=>{let F=q.composedPath().filter((J)=>J instanceof HTMLAnchorElement&&J.getAttribute("href"));if(this.options.anchors){let J=F.find((K)=>K.getAttribute("href")?.includes("#"));if(J){let K=J.getAttribute("href");if(K){let $=typeof this.options.anchors==="object"&&this.options.anchors?this.options.anchors:void 0,Z=`#${K.split("#")[1]}`;this.scrollTo(Z,$)}}}if(this.options.stopInertiaOnNavigate){if(F.find((K)=>K.host===window.location.host))this.reset()}};onPointerDown=(q)=>{if(q.button===1)this.reset()};onVirtualScroll=(q)=>{if(typeof this.options.virtualScroll==="function"&&this.options.virtualScroll(q)===!1)return;let{deltaX:B,deltaY:F,event:J}=q;if(this.emitter.emit("virtual-scroll",{deltaX:B,deltaY:F,event:J}),J.ctrlKey)return;if(J.lenisStopPropagation)return;let K=J.type.includes("touch"),$=J.type.includes("wheel");this.isTouching=J.type==="touchstart"||J.type==="touchmove";let Z=B===0&&F===0;if(this.options.syncTouch&&K&&J.type==="touchstart"&&Z&&!this.isStopped&&!this.isLocked){this.reset();return}let G=this.options.gestureOrientation==="vertical"&&F===0||this.options.gestureOrientation==="horizontal"&&B===0;if(Z||G)return;let V=J.composedPath();V=V.slice(0,V.indexOf(this.rootElement));let z=this.options.prevent;if(V.find((P)=>P instanceof HTMLElement&&(typeof z==="function"&&z?.(P)||P.hasAttribute?.("data-lenis-prevent")||K&&P.hasAttribute?.("data-lenis-prevent-touch")||$&&P.hasAttribute?.("data-lenis-prevent-wheel")||this.options.allowNestedScroll&&this.checkNestedScroll(P,{deltaX:B,deltaY:F}))))return;if(this.isStopped||this.isLocked){if(J.cancelable)J.preventDefault();return}if(!(this.options.syncTouch&&K||this.options.smoothWheel&&$)){this.isScrolling="native",this.animate.stop(),J.lenisStopPropagation=!0;return}let Q=F;if(this.options.gestureOrientation==="both")Q=Math.abs(F)>Math.abs(B)?F:B;else if(this.options.gestureOrientation==="horizontal")Q=B;if(!this.options.overscroll||this.options.infinite||this.options.wrapper!==window&&this.limit>0&&(this.animatedScroll>0&&this.animatedScroll0||this.animatedScroll===this.limit&&F<0))J.lenisStopPropagation=!0;if(J.cancelable)J.preventDefault();let A=K&&this.options.syncTouch,L=K&&J.type==="touchend";if(L)Q=Math.sign(this.velocity)*Math.pow(Math.abs(this.velocity),this.options.touchInertiaExponent);this.scrollTo(this.targetScroll+Q,{programmatic:!1,...A?{lerp:L?this.options.syncTouchLerp:1}:{lerp:this.options.lerp,duration:this.options.duration,easing:this.options.easing}})};resize(){this.dimensions.resize(),this.animatedScroll=this.targetScroll=this.actualScroll,this.emit()}emit(){this.emitter.emit("scroll",this)}onNativeScroll=()=>{if(this._resetVelocityTimeout!==null)clearTimeout(this._resetVelocityTimeout),this._resetVelocityTimeout=null;if(this._preventNextNativeScrollEvent){this._preventNextNativeScrollEvent=!1;return}if(this.isScrolling===!1||this.isScrolling==="native"){let q=this.animatedScroll;if(this.animatedScroll=this.targetScroll=this.actualScroll,this.lastVelocity=this.velocity,this.velocity=this.animatedScroll-q,this.direction=Math.sign(this.animatedScroll-q),!this.isStopped)this.isScrolling="native";if(this.emit(),this.velocity!==0)this._resetVelocityTimeout=setTimeout(()=>{this.lastVelocity=this.velocity,this.velocity=0,this.isScrolling=!1,this.emit()},400)}};reset(){this.isLocked=!1,this.isScrolling=!1,this.animatedScroll=this.targetScroll=this.actualScroll,this.lastVelocity=this.velocity=0,this.animate.stop()}start(){if(!this.isStopped)return;if(this.options.autoToggle){this.rootElement.style.removeProperty("overflow");return}this.internalStart()}internalStart(){if(!this.isStopped)return;this.reset(),this.isStopped=!1,this.emit()}stop(){if(this.isStopped)return;if(this.options.autoToggle){this.rootElement.style.setProperty("overflow","clip");return}this.internalStop()}internalStop(){if(this.isStopped)return;this.reset(),this.isStopped=!0,this.emit()}raf=(q)=>{let B=q-(this.time||q);if(this.time=q,this.animate.advance(B*0.001),this.options.autoRaf)this._rafId=requestAnimationFrame(this.raf)};scrollTo(q,{offset:B=0,immediate:F=!1,lock:J=!1,programmatic:K=!0,lerp:$=K?this.options.lerp:void 0,duration:Z=K?this.options.duration:void 0,easing:U=K?this.options.easing:void 0,onStart:G,onComplete:V,force:z=!1,userData:D}={}){if((this.isStopped||this.isLocked)&&!z)return;if(typeof q==="string"&&["top","left","start","#"].includes(q))q=0;else if(typeof q==="string"&&["bottom","right","end"].includes(q))q=this.limit;else{let Q;if(typeof q==="string"){if(Q=document.querySelector(q),!Q)if(q==="#top")q=0;else console.warn("Lenis: Target not found",q)}else if(q instanceof HTMLElement&&q?.nodeType)Q=q;if(Q){if(this.options.wrapper!==window){let j=this.rootElement.getBoundingClientRect();B-=this.isHorizontal?j.left:j.top}let A=Q.getBoundingClientRect();q=(this.isHorizontal?A.left:A.top)+this.animatedScroll}}if(typeof q!=="number")return;if(q+=B,q=Math.round(q),this.options.infinite){if(K){this.targetScroll=this.animatedScroll=this.scroll;let Q=q-this.animatedScroll;if(Q>this.limit/2)q=q-this.limit;else if(Q<-this.limit/2)q=q+this.limit}}else q=T(0,q,this.limit);if(q===this.targetScroll){G?.(this),V?.(this);return}if(this.userData=D??{},F){this.animatedScroll=this.targetScroll=q,this.setScroll(this.scroll),this.reset(),this.preventNextNativeScrollEvent(),this.emit(),V?.(this),this.userData={},requestAnimationFrame(()=>{this.dispatchScrollendEvent()});return}if(!K)this.targetScroll=q;if(typeof Z==="number"&&typeof U!=="function")U=k;else if(typeof U==="function"&&typeof Z!=="number")Z=1;this.animate.fromTo(this.animatedScroll,q,{duration:Z,easing:U,lerp:$,onStart:()=>{if(J)this.isLocked=!0;this.isScrolling="smooth",G?.(this)},onUpdate:(Q,A)=>{if(this.isScrolling="smooth",this.lastVelocity=this.velocity,this.velocity=Q-this.animatedScroll,this.direction=Math.sign(this.velocity),this.animatedScroll=Q,this.setScroll(this.scroll),K)this.targetScroll=Q;if(!A)this.emit();if(A)this.reset(),this.emit(),V?.(this),this.userData={},requestAnimationFrame(()=>{this.dispatchScrollendEvent()}),this.preventNextNativeScrollEvent()}})}preventNextNativeScrollEvent(){this._preventNextNativeScrollEvent=!0,requestAnimationFrame(()=>{this._preventNextNativeScrollEvent=!1})}checkNestedScroll(q,{deltaX:B,deltaY:F}){let J=Date.now(),K=q._lenis??={},$,Z,U,G,V,z,D,Q,A=this.options.gestureOrientation;if(J-(K.time??0)>2000){K.time=Date.now();let N=window.getComputedStyle(q);K.computedStyle=N;let{overflowX:R,overflowY:x}=N;if($=["auto","overlay","scroll"].includes(R),Z=["auto","overlay","scroll"].includes(x),K.hasOverflowX=$,K.hasOverflowY=Z,!$&&!Z)return!1;if(A==="vertical"&&!Z)return!1;if(A==="horizontal"&&!$)return!1;V=q.scrollWidth,z=q.scrollHeight,D=q.clientWidth,Q=q.clientHeight,U=V>D,G=z>Q,K.isScrollableX=U,K.isScrollableY=G,K.scrollWidth=V,K.scrollHeight=z,K.clientWidth=D,K.clientHeight=Q}else U=K.isScrollableX,G=K.isScrollableY,$=K.hasOverflowX,Z=K.hasOverflowY,V=K.scrollWidth,z=K.scrollHeight,D=K.clientWidth,Q=K.clientHeight;if(!$&&!Z||!U&&!G)return!1;if(A==="vertical"&&(!Z||!G))return!1;if(A==="horizontal"&&(!$||!U))return!1;let j;if(A==="horizontal")j="x";else if(A==="vertical")j="y";else{let N=B!==0,R=F!==0;if(N&&$&&U)j="x";if(R&&Z&&G)j="y"}if(!j)return!1;let L,P,C,_,E;if(j==="x")L=q.scrollLeft,P=V-D,C=B,_=$,E=U;else if(j==="y")L=q.scrollTop,P=z-Q,C=F,_=Z,E=G;else return!1;return(C>0?L0)&&_&&E}get rootElement(){return this.options.wrapper===window?document.documentElement:this.options.wrapper}get limit(){if(this.options.naiveDimensions)if(this.isHorizontal)return this.rootElement.scrollWidth-this.rootElement.clientWidth;else return this.rootElement.scrollHeight-this.rootElement.clientHeight;else return this.dimensions.limit[this.isHorizontal?"x":"y"]}get isHorizontal(){return this.options.orientation==="horizontal"}get actualScroll(){let q=this.options.wrapper;return this.isHorizontal?q.scrollX??q.scrollLeft:q.scrollY??q.scrollTop}get scroll(){return this.options.infinite?g(this.animatedScroll,this.limit):this.animatedScroll}get progress(){return this.limit===0?1:this.scroll/this.limit}get isScrolling(){return this._isScrolling}set isScrolling(q){if(this._isScrolling!==q)this._isScrolling=q,this.updateClassName()}get isStopped(){return this._isStopped}set isStopped(q){if(this._isStopped!==q)this._isStopped=q,this.updateClassName()}get isLocked(){return this._isLocked}set isLocked(q){if(this._isLocked!==q)this._isLocked=q,this.updateClassName()}get isSmooth(){return this.isScrolling==="smooth"}get className(){let q="lenis";if(this.options.autoToggle)q+=" lenis-autoToggle";if(this.isStopped)q+=" lenis-stopped";if(this.isLocked)q+=" lenis-locked";if(this.isScrolling)q+=" lenis-scrolling";if(this.isScrolling==="smooth")q+=" lenis-smooth";return q}updateClassName(){this.cleanUpClassName(),this.rootElement.className=`${this.rootElement.className} ${this.className}`.trim()}cleanUpClassName(){this.rootElement.className=this.rootElement.className.replace(/lenis(-\w+)?/g,"").trim()}};function H(){return H=Object.assign?Object.assign.bind():function(q){for(var B=1;B{q.forEach((B)=>{let F=this.scrollElements.find((J)=>J.$el===B.target);B.isIntersecting?(F&&(F.isAlreadyIntersected=!0),this._setInview(B)):F&&F.isAlreadyIntersected&&this._setOutOfView(B)})},{root:this.root,rootMargin:this.rootMargin});for(let q of this.scrollElements)this.observe(q.$el)}destroy(){this.observer.disconnect()}observe(q){q&&this.observer.observe(q)}unobserve(q){q&&this.observer.unobserve(q)}_setInview(q){let B=this.scrollElements.find((F)=>F.$el===q.target);this.IORaf&&(B==null||B.setInteractivityOn()),!this.IORaf&&(B==null||B.setInview())}_setOutOfView(q){let B=this.scrollElements.find((F)=>F.$el===q.target);this.IORaf&&(B==null||B.setInteractivityOff()),!this.IORaf&&(B==null||B.setOutOfView()),B!=null&&B.attributes.scrollRepeat||this.IORaf||this.unobserve(q.target)}}function O(q,B,F,J,K){return F+((K-q)/(B-q)*(J-F)||0)}function S(q,B){return q.reduce((F,J)=>Math.abs(J-B)Q-A+j,middle:(Q,A,j,L)=>Q-A+j+0.5*L,end:(Q,A,j,L)=>Q-A+j+L,fold:()=>0},this.endPositionHandlers={start:(Q,A)=>Q-A,middle:(Q,A,j)=>Q-A+0.5*j,end:(Q,A,j)=>Q-A+j},this.$el=q,this.id=B,this.needRaf=K,this.scrollOrientation=$,this.lenisInstance=Z,this.subscribeElementUpdateFn=F,this.unsubscribeElementUpdateFn=J,this.attributes={scrollClass:(U=this.$el.dataset.scrollClass)!=null?U:"is-inview",scrollOffset:(G=this.$el.dataset.scrollOffset)!=null?G:"0,0",scrollPosition:(V=this.$el.dataset.scrollPosition)!=null?V:"start,end",scrollCssProgress:this.$el.dataset.scrollCssProgress!==void 0,scrollEventProgress:(z=this.$el.dataset.scrollEventProgress)!=null?z:null,scrollSpeed:this.$el.dataset.scrollSpeed!==void 0?parseFloat(this.$el.dataset.scrollSpeed):null,scrollRepeat:this.$el.dataset.scrollRepeat!==void 0,scrollCall:(D=this.$el.dataset.scrollCall)!=null?D:null,scrollIgnoreFold:this.$el.dataset.scrollIgnoreFold!==void 0,scrollEnableTouchSpeed:this.$el.dataset.scrollEnableTouchSpeed!==void 0},this.intersection={start:0,end:0},this.metrics={offsetStart:0,offsetEnd:0,bcr:{}},this.currentScroll=this.lenisInstance.scroll,this.translateValue=0,this.progress=0,this.lastProgress=null,this.isInview=!1,this.isInteractive=!1,this.isAlreadyIntersected=!1,this.isInFold=!1,this.isFirstResize=!0,this.getWindowSize=this.scrollOrientation==="vertical"?()=>this.lenisInstance.dimensions.height:()=>this.lenisInstance.dimensions.width,this.getMetricsStart=this.scrollOrientation==="vertical"?(Q)=>Q.top:(Q)=>Q.left,this.getMetricsSize=this.scrollOrientation==="vertical"?(Q)=>Q.height:(Q)=>Q.width,this._init()}_init(){this.needRaf&&this._resize()}onResize({currentScroll:q}){this.currentScroll=q,this._resize()}onRender({currentScroll:q,smooth:B}){let F=this.getWindowSize();if(this.currentScroll=q,this._computeProgress(),this.attributes.scrollSpeed&&!isNaN(this.attributes.scrollSpeed))if(this.attributes.scrollEnableTouchSpeed||B){if(this.isInFold){let J=Math.max(0,this.progress);this.translateValue=J*F*this.attributes.scrollSpeed*-1}else{let J=O(0,1,-1,1,this.progress);this.translateValue=J*F*this.attributes.scrollSpeed*-1}this.$el.style.transform=this.scrollOrientation==="vertical"?`translate3d(0, ${this.translateValue}px, 0)`:`translate3d(${this.translateValue}px, 0, 0)`}else this.translateValue&&(this.$el.style.transform="translate3d(0, 0, 0)"),this.translateValue=0}setInview(){if(this.isInview)return;this.isInview=!0,this.$el.classList.add(this.attributes.scrollClass);let q=this._getScrollCallFrom();this.attributes.scrollCall&&this._dispatchCall("enter",q)}setOutOfView(){if(!this.isInview||!this.attributes.scrollRepeat)return;this.isInview=!1,this.$el.classList.remove(this.attributes.scrollClass);let q=this._getScrollCallFrom();this.attributes.scrollCall&&this._dispatchCall("leave",q)}setInteractivityOn(){this.isInteractive||(this.isInteractive=!0,this.subscribeElementUpdateFn(this))}setInteractivityOff(){this.isInteractive&&(this.isInteractive=!1,this.unsubscribeElementUpdateFn(this),this.lastProgress!==null&&this._computeProgress(S([0,1],this.lastProgress)))}_resize(){this.metrics.bcr=this.$el.getBoundingClientRect(),this._computeMetrics(),this._computeIntersection(),this.isFirstResize&&(this.isFirstResize=!1,this.isInFold&&this.setInview())}_computeMetrics(){let q=this.getWindowSize(),B=this.getMetricsStart(this.metrics.bcr),F=this.getMetricsSize(this.metrics.bcr);this.metrics.offsetStart=this.currentScroll+B-this.translateValue,this.metrics.offsetEnd=this.metrics.offsetStart+F,this.isInFold=this.metrics.offsetStart1?1:F;var F;this.progress=B,B!==this.lastProgress&&(this.lastProgress=B,this.attributes.scrollCssProgress&&this._setCssProgress(B),this.attributes.scrollEventProgress&&this._setCustomEventProgress(B),B>0&&B<1&&this.setInview(),B===0&&this.setOutOfView(),B===1&&this.setOutOfView())}_setCssProgress(q=0){this.$el.style.setProperty(b,q.toString())}_setCustomEventProgress(q=0){let B=this.attributes.scrollEventProgress;if(!B)return;let F=new CustomEvent(B,{detail:{target:this.$el,progress:q}});window.dispatchEvent(F)}_getScrollCallFrom(){let q=S([this.intersection.start,this.intersection.end],this.currentScroll);return this.intersection.start===q?"start":"end"}destroy(){this.attributes.scrollCssProgress&&this.$el.style.removeProperty(b),this.attributes.scrollSpeed&&this.$el.style.removeProperty("transform"),this.isInview&&this.attributes.scrollClass&&this.$el.classList.remove(this.attributes.scrollClass)}_dispatchCall(q,B){let F=this.attributes.scrollCall;if(!F)return;let J=new CustomEvent(F,{detail:{target:this.$el,way:q,from:B}});window.dispatchEvent(J)}}var n=["scrollOffset","scrollPosition","scrollCssProgress","scrollEventProgress","scrollSpeed"];class w{constructor({$el:q,triggerRootMargin:B,rafRootMargin:F,scrollOrientation:J,lenisInstance:K}){this.$scrollContainer=void 0,this.triggerRootMargin=void 0,this.rafRootMargin=void 0,this.scrollElements=void 0,this.triggeredScrollElements=void 0,this.RAFScrollElements=void 0,this.scrollElementsToUpdate=void 0,this.IOTriggerInstance=void 0,this.IORafInstance=void 0,this.scrollOrientation=void 0,this.lenisInstance=void 0,q?(this.$scrollContainer=q,this.lenisInstance=K,this.scrollOrientation=J,this.triggerRootMargin=B!=null?B:"-1px -1px -1px -1px",this.rafRootMargin=F!=null?F:"100% 100% 100% 100%",this.scrollElements=[],this.triggeredScrollElements=[],this.RAFScrollElements=[],this.scrollElementsToUpdate=[],this._init()):console.error("Please provide a DOM Element as scrollContainer")}_init(){let q=this.$scrollContainer.querySelectorAll("[data-scroll]"),B=this.toElementArray(q);this._subscribeScrollElements(B);let F=this.lenisInstance.options.wrapper===window?null:this.lenisInstance.options.wrapper;this.IOTriggerInstance=new M({scrollElements:[...this.triggeredScrollElements],root:F,rootMargin:this.triggerRootMargin,IORaf:!1}),this.IORafInstance=new M({scrollElements:[...this.RAFScrollElements],root:F,rootMargin:this.rafRootMargin,IORaf:!0})}destroy(){this.IOTriggerInstance.destroy(),this.IORafInstance.destroy(),this._unsubscribeAllScrollElements()}onResize({currentScroll:q}){for(let B of this.RAFScrollElements)B.onResize({currentScroll:q})}onRender({currentScroll:q,smooth:B}){for(let F of this.scrollElementsToUpdate)F.onRender({currentScroll:q,smooth:B})}removeScrollElements(q){let B=q.querySelectorAll("[data-scroll]");if(!B.length)return;let F=new Set(Array.from(B));for(let J=0;J{let K=this.scrollElementsToUpdate.find((Z)=>Z.$el===J),$=this.scrollElements.find((Z)=>Z.$el===J);K&&this._unsubscribeElementUpdate(K),$&&(this.scrollElements=this.scrollElements.filter((Z)=>Z.id!=$.id))})}addScrollElements(q){let B=q.querySelectorAll("[data-scroll]"),F=[];this.scrollElements.forEach(($)=>{F.push($.id)});let J=Math.max(...F,0)+1,K=this.toElementArray(B);this._subscribeScrollElements(K,J,!0)}_subscribeScrollElements(q,B=0,F=!1){for(let J=0;JB.id!=q.id)}toElementArray(q){return Array.from(q)}_checkRafNeeded(q){let B=[...n],F=(J)=>{B=B.filter((K)=>K!==J)};if(q.dataset.scrollOffset){if(q.dataset.scrollOffset.split(",").map((J)=>J.replace("%","").trim()).join(",")!=="0,0")return!0;F("scrollOffset")}else F("scrollOffset");if(q.dataset.scrollPosition){if(q.dataset.scrollPosition.trim()!=="top,bottom")return!0;F("scrollPosition")}else F("scrollPosition");if(q.dataset.scrollSpeed&&!isNaN(parseFloat(q.dataset.scrollSpeed)))return!0;F("scrollSpeed");for(let J of B)if(J in q.dataset)return!0;return!1}}class s{constructor({lenisOptions:q={},triggerRootMargin:B,rafRootMargin:F,autoStart:J=!0,scrollCallback:K=()=>{},initCustomTicker:$,destroyCustomTicker:Z}={}){this.rafPlaying=void 0,this.lenisInstance=null,this.coreInstance=null,this.lenisOptions=void 0,this.triggerRootMargin=void 0,this.rafRootMargin=void 0,this.rafInstance=void 0,this.autoStart=void 0,this.isTouchDevice=void 0,this.initCustomTicker=void 0,this.destroyCustomTicker=void 0,this._onRenderBind=void 0,this._onResizeBind=void 0,this._onScrollToBind=void 0,this._originalOnContentResize=void 0,this._originalOnWrapperResize=void 0,window.locomotiveScrollVersion="5.0.0",Object.assign(this,{lenisOptions:q,triggerRootMargin:B,rafRootMargin:F,autoStart:J,scrollCallback:K,initCustomTicker:$,destroyCustomTicker:Z}),this._onRenderBind=this._onRender.bind(this),this._onScrollToBind=this._onScrollTo.bind(this),this._onResizeBind=this._onResize.bind(this),this.rafPlaying=!1,this.isTouchDevice="ontouchstart"in window||navigator.maxTouchPoints>0,this._init()}_init(){this.lenisInstance=new Y(H({},this.lenisOptions)),this.scrollCallback&&this.lenisInstance.on("scroll",this.scrollCallback),document.documentElement.setAttribute("data-scroll-orientation",this.lenisInstance.options.orientation),requestAnimationFrame(()=>{this.coreInstance=new w({$el:this.lenisInstance.rootElement,triggerRootMargin:this.triggerRootMargin,rafRootMargin:this.rafRootMargin,scrollOrientation:this.lenisInstance.options.orientation,lenisInstance:this.lenisInstance}),this._bindEvents(),this.initCustomTicker&&!this.destroyCustomTicker?console.warn("initCustomTicker callback is declared, but destroyCustomTicker is not. Please pay attention. It could cause trouble."):!this.initCustomTicker&&this.destroyCustomTicker&&console.warn("destroyCustomTicker callback is declared, but initCustomTicker is not. Please pay attention. It could cause trouble."),this.autoStart&&this.start()})}destroy(){var q;this.stop(),this._unbindEvents(),(q=this.lenisInstance)==null||q.destroy(),requestAnimationFrame(()=>{var B;(B=this.coreInstance)==null||B.destroy()})}_bindEvents(){this._bindScrollToEvents(),this.lenisInstance&&(this._originalOnContentResize=this.lenisInstance.dimensions.onContentResize.bind(this.lenisInstance.dimensions),this._originalOnWrapperResize=this.lenisInstance.dimensions.onWrapperResize.bind(this.lenisInstance.dimensions),this.lenisInstance.dimensions.onContentResize=()=>{var q;(q=this._originalOnContentResize)==null||q.call(this),this._onResizeBind()},this.lenisInstance.dimensions.onWrapperResize=()=>{var q;(q=this._originalOnWrapperResize)==null||q.call(this),this._onResizeBind()})}_unbindEvents(){this._unbindScrollToEvents(),this.lenisInstance&&(this._originalOnContentResize&&(this.lenisInstance.dimensions.onContentResize=this._originalOnContentResize),this._originalOnWrapperResize&&(this.lenisInstance.dimensions.onWrapperResize=this._originalOnWrapperResize))}_bindScrollToEvents(q){var B;let F=q||((B=this.lenisInstance)==null?void 0:B.rootElement),J=F==null?void 0:F.querySelectorAll("[data-scroll-to]");(J==null?void 0:J.length)&&J.forEach((K)=>{K.addEventListener("click",this._onScrollToBind,!1)})}_unbindScrollToEvents(q){var B;let F=q||((B=this.lenisInstance)==null?void 0:B.rootElement),J=F==null?void 0:F.querySelectorAll("[data-scroll-to]");(J==null?void 0:J.length)&&J.forEach((K)=>{K.removeEventListener("click",this._onScrollToBind,!1)})}_onResize(){var q,B,F;(q=this.coreInstance)==null||q.onResize({currentScroll:(B=(F=this.lenisInstance)==null?void 0:F.scroll)!=null?B:0,smooth:!this.isTouchDevice})}_onRender(){var q,B,F,J;(q=this.lenisInstance)==null||q.raf(Date.now()),(B=this.coreInstance)==null||B.onRender({currentScroll:(F=(J=this.lenisInstance)==null?void 0:J.scroll)!=null?F:0,smooth:!this.isTouchDevice})}_onScrollTo(q){var B,F;q.preventDefault();let J=(B=q.currentTarget)!=null?B:null;if(!J)return;let K=J.getAttribute("data-scroll-to-href")||J.getAttribute("href"),$=J.getAttribute("data-scroll-to-offset")||0,Z=J.getAttribute("data-scroll-to-duration")||((F=this.lenisInstance)==null?void 0:F.options.duration);K&&this.scrollTo(K,{offset:typeof $=="string"?parseInt($):$,duration:typeof Z=="string"?parseInt(Z):Z})}start(){var q;this.rafPlaying||((q=this.lenisInstance)==null||q.start(),this.rafPlaying=!0,this.initCustomTicker?this.initCustomTicker(this._onRenderBind):this._raf())}stop(){var q;this.rafPlaying&&((q=this.lenisInstance)==null||q.stop(),this.rafPlaying=!1,this.destroyCustomTicker?this.destroyCustomTicker(this._onRenderBind):this.rafInstance&&cancelAnimationFrame(this.rafInstance))}removeScrollElements(q){var B;q?(this._unbindScrollToEvents(q),(B=this.coreInstance)==null||B.removeScrollElements(q)):console.error("Please provide a DOM Element as $oldContainer")}addScrollElements(q){var B;q?((B=this.coreInstance)==null||B.addScrollElements(q),requestAnimationFrame(()=>{this._bindScrollToEvents(q)})):console.error("Please provide a DOM Element as $newContainer")}resize(){this._onResizeBind()}scrollTo(q,B){var F;(F=this.lenisInstance)==null||F.scrollTo(q,{offset:B==null?void 0:B.offset,lerp:B==null?void 0:B.lerp,duration:B==null?void 0:B.duration,immediate:B==null?void 0:B.immediate,lock:B==null?void 0:B.lock,force:B==null?void 0:B.force,easing:B==null?void 0:B.easing,onComplete:B==null?void 0:B.onComplete})}_raf(){this._onRenderBind(),this.rafInstance=requestAnimationFrame(()=>this._raf())}}export{s as default};