!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t||self).LocomotiveScroll=e()}(this,function(){function t(){return t=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var i=0,s=new Array(e);i=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(){return s=Object.assign?Object.assign.bind():function(t){for(var e=1;e=1;const s=i?1:this.easing(e);this.value=this.from+(this.to-this.from)*s}var s;null==(e=this.onUpdate)||e.call(this,this.value,{completed:i}),i&&this.stop()}stop(){this.isRunning=!1}fromTo(t,e,{lerp:i=.1,duration:s=1,easing:n=(t=>t),onUpdate:r}){this.from=this.value=t,this.to=e,this.lerp=i,this.duration=s,this.easing=n,this.currentTime=0,this.isRunning=!0,this.onUpdate=r}}function o(t,e){let i;return function(){let s=arguments,n=this;clearTimeout(i),i=setTimeout(function(){t.apply(n,s)},e)}}class l{constructor(t,e){this.onWindowResize=()=>{this.width=window.innerWidth,this.height=window.innerHeight},this.onWrapperResize=()=>{this.width=this.wrapper.clientWidth,this.height=this.wrapper.clientHeight},this.onContentResize=()=>{const t=this.wrapper===window?document.documentElement:this.wrapper;this.scrollHeight=t.scrollHeight,this.scrollWidth=t.scrollWidth},this.wrapper=t,this.content=e,this.wrapper===window?(window.addEventListener("resize",this.onWindowResize,!1),this.onWindowResize()):(this.wrapperResizeObserver=new ResizeObserver(o(this.onWrapperResize,100)),this.wrapperResizeObserver.observe(this.wrapper),this.onWrapperResize()),this.contentResizeObserver=new ResizeObserver(o(this.onContentResize,100)),this.contentResizeObserver.observe(this.content),this.onContentResize()}destroy(){var t,e;window.removeEventListener("resize",this.onWindowResize,!1),null==(t=this.wrapperResizeObserver)||t.disconnect(),null==(e=this.contentResizeObserver)||e.disconnect()}get limit(){return{x:this.scrollWidth-this.width,y:this.scrollHeight-this.height}}}let a=()=>({events:{},emit(t,...e){let i=this.events[t]||[];for(let t=0,s=i.length;t{var i;this.events[t]=null==(i=this.events[t])?void 0:i.filter(t=>e!==t)}}});class h{constructor(t,{wheelMultiplier:e=1,touchMultiplier:i=2,normalizeWheel:s=!1}){this.onTouchStart=t=>{const{clientX:e,clientY:i}=t.targetTouches?t.targetTouches[0]:t;this.touchStart.x=e,this.touchStart.y=i,this.lastDelta={x:0,y:0}},this.onTouchMove=t=>{const{clientX:e,clientY:i}=t.targetTouches?t.targetTouches[0]:t,s=-(e-this.touchStart.x)*this.touchMultiplier,n=-(i-this.touchStart.y)*this.touchMultiplier;this.touchStart.x=e,this.touchStart.y=i,this.lastDelta={x:s,y:n},this.emitter.emit("scroll",{type:"touch",deltaX:s,deltaY:n,event:t})},this.onTouchEnd=t=>{this.emitter.emit("scroll",{type:"touch",inertia:!0,deltaX:this.lastDelta.x,deltaY:this.lastDelta.y,event:t})},this.onWheel=t=>{let{deltaX:e,deltaY:i}=t;this.normalizeWheel&&(e=n(-100,e,100),i=n(-100,i,100)),e*=this.wheelMultiplier,i*=this.wheelMultiplier,this.emitter.emit("scroll",{type:"wheel",deltaX:e,deltaY:i,event:t})},this.element=t,this.wheelMultiplier=e,this.touchMultiplier=i,this.normalizeWheel=s,this.touchStart={x:null,y:null},this.emitter=a(),this.element.addEventListener("wheel",this.onWheel,{passive:!1}),this.element.addEventListener("touchstart",this.onTouchStart,{passive:!1}),this.element.addEventListener("touchmove",this.onTouchMove,{passive:!1}),this.element.addEventListener("touchend",this.onTouchEnd,{passive:!1})}on(t,e){return this.emitter.on(t,e)}destroy(){this.emitter.events={},this.element.removeEventListener("wheel",this.onWheel,{passive:!1}),this.element.removeEventListener("touchstart",this.onTouchStart,{passive:!1}),this.element.removeEventListener("touchmove",this.onTouchMove,{passive:!1}),this.element.removeEventListener("touchend",this.onTouchEnd,{passive:!1})}}class c{constructor({direction:t,gestureDirection:e,mouseMultiplier:i,smooth:n,wrapper:o=window,content:c=document.documentElement,wheelEventsTarget:u=o,smoothWheel:d=null==n||n,smoothTouch:m=!1,syncTouch:v=!1,syncTouchLerp:p=.1,touchInertiaMultiplier:f=35,duration:g,easing:b=(t=>Math.min(1,1.001-Math.pow(2,-10*t))),lerp:S=(g?null:.1),infinite:w=!1,orientation:E=(null!=t?t:"vertical"),gestureOrientation:I=(null!=e?e:"vertical"),touchMultiplier:O=1,wheelMultiplier:y=(null!=i?i:1),normalizeWheel:R=!1}={}){this.onVirtualScroll=({type:t,inertia:e,deltaX:i,deltaY:n,event:r})=>{if(r.ctrlKey)return;const o="touch"===t,l="wheel"===t;if("vertical"===this.options.gestureOrientation&&0===n||"horizontal"===this.options.gestureOrientation&&0===i||o&&"vertical"===this.options.gestureOrientation&&0===this.scroll&&!this.options.infinite&&n<=0)return;if(r.composedPath().find(t=>null==t||null==t.hasAttribute?void 0:t.hasAttribute("data-lenis-prevent")))return;if(this.isStopped||this.isLocked)return void r.preventDefault();if(this.isSmooth=(this.options.smoothTouch||this.options.syncTouch)&&o||this.options.smoothWheel&&l,!this.isSmooth)return this.isScrolling=!1,void this.animate.stop();r.preventDefault();let a=n;"both"===this.options.gestureOrientation?a=Math.abs(n)>Math.abs(i)?n:i:"horizontal"===this.options.gestureOrientation&&(a=i);const h=o&&this.options.syncTouch,c=o&&e&&Math.abs(a)>1;c&&(a=this.velocity*this.options.touchInertiaMultiplier),this.scrollTo(this.targetScroll+a,s({programmatic:!1},h&&{lerp:c?this.syncTouchLerp:.4}))},this.onScroll=()=>{if(!this.isScrolling){const t=this.animatedScroll;this.animatedScroll=this.targetScroll=this.actualScroll,this.velocity=0,this.direction=Math.sign(this.animatedScroll-t),this.emit()}},t&&console.warn("Lenis: `direction` option is deprecated, use `orientation` instead"),e&&console.warn("Lenis: `gestureDirection` option is deprecated, use `gestureOrientation` instead"),i&&console.warn("Lenis: `mouseMultiplier` option is deprecated, use `wheelMultiplier` instead"),n&&console.warn("Lenis: `smooth` option is deprecated, use `smoothWheel` instead"),window.lenisVersion="1.0.11",o!==document.documentElement&&o!==document.body||(o=window),this.options={wrapper:o,content:c,wheelEventsTarget:u,smoothWheel:d,smoothTouch:m,syncTouch:v,syncTouchLerp:p,touchInertiaMultiplier:f,duration:g,easing:b,lerp:S,infinite:w,gestureOrientation:I,orientation:E,touchMultiplier:O,wheelMultiplier:y,normalizeWheel:R},this.dimensions=new l(o,c),this.rootElement.classList.add("lenis"),this.velocity=0,this.isStopped=!1,this.isSmooth=d||m,this.isScrolling=!1,this.targetScroll=this.animatedScroll=this.actualScroll,this.animate=new r,this.emitter=a(),this.options.wrapper.addEventListener("scroll",this.onScroll,{passive:!1}),this.virtualScroll=new h(u,{touchMultiplier:O,wheelMultiplier:y,normalizeWheel:R}),this.virtualScroll.on("scroll",this.onVirtualScroll)}destroy(){this.emitter.events={},this.options.wrapper.removeEventListener("scroll",this.onScroll,{passive:!1}),this.virtualScroll.destroy()}on(t,e){return this.emitter.on(t,e)}off(t,e){var i;this.emitter.events[t]=null==(i=this.emitter.events[t])?void 0:i.filter(t=>e!==t)}setScroll(t){this.isHorizontal?this.rootElement.scrollLeft=t:this.rootElement.scrollTop=t}emit(){this.emitter.emit("scroll",this)}reset(){this.isLocked=!1,this.isScrolling=!1,this.velocity=0,this.animate.stop()}start(){this.isStopped=!1,this.reset()}stop(){this.isStopped=!0,this.animate.stop(),this.reset()}raf(t){const e=t-(this.time||t);this.time=t,this.animate.advance(.001*e)}scrollTo(t,{offset:e=0,immediate:i=!1,lock:s=!1,duration:r=this.options.duration,easing:o=this.options.easing,lerp:l=!r&&this.options.lerp,onComplete:a=null,force:h=!1,programmatic:c=!0}={}){if(!this.isStopped||h){if(["top","left","start"].includes(t))t=0;else if(["bottom","right","end"].includes(t))t=this.limit;else{var u;let i;if("string"==typeof t?i=document.querySelector(t):null!=(u=t)&&u.nodeType&&(i=t),i){if(this.options.wrapper!==window){const t=this.options.wrapper.getBoundingClientRect();e-=this.isHorizontal?t.left:t.top}const s=i.getBoundingClientRect();t=(this.isHorizontal?s.left:s.top)+this.animatedScroll}}if("number"==typeof t){if(t+=e,t=Math.round(t),this.options.infinite?c&&(this.targetScroll=this.animatedScroll=this.scroll):t=n(0,t,this.limit),i)return this.animatedScroll=this.targetScroll=t,this.setScroll(this.scroll),this.reset(),this.emit(),void(null==a||a());if(!c){if(t===this.targetScroll)return;this.targetScroll=t}this.animate.fromTo(this.animatedScroll,t,{duration:r,easing:o,lerp:l,onUpdate:(t,{completed:e})=>{s&&(this.isLocked=!0),this.isScrolling=!0,this.velocity=t-this.animatedScroll,this.direction=Math.sign(this.velocity),this.animatedScroll=t,this.setScroll(this.scroll),c&&(this.targetScroll=t),e&&(s&&(this.isLocked=!1),requestAnimationFrame(()=>{this.isScrolling=!1}),this.velocity=0,null==a||a()),this.emit()}})}}}get rootElement(){return this.options.wrapper===window?this.options.content:this.options.wrapper}get limit(){return this.isHorizontal?this.dimensions.limit.x:this.dimensions.limit.y}get isHorizontal(){return"horizontal"===this.options.orientation}get actualScroll(){return this.isHorizontal?this.rootElement.scrollLeft:this.rootElement.scrollTop}get scroll(){return this.options.infinite?function(t,e){let i=t%e;return(e>0&&i<0||e<0&&i>0)&&(i+=e),i}(this.animatedScroll,this.limit):this.animatedScroll}get progress(){return 0===this.limit?1:this.scroll/this.limit}get isSmooth(){return this.__isSmooth}set isSmooth(t){this.__isSmooth!==t&&(this.rootElement.classList.toggle("lenis-smooth",t),this.__isSmooth=t)}get isScrolling(){return this.__isScrolling}set isScrolling(t){this.__isScrolling!==t&&(this.rootElement.classList.toggle("lenis-scrolling",t),this.__isScrolling=t)}get isStopped(){return this.__isStopped}set isStopped(t){this.__isStopped!==t&&(this.rootElement.classList.toggle("lenis-stopped",t),this.__isStopped=t)}}var u=/*#__PURE__*/function(){function t(t){var e=t.scrollElements,i=t.rootMargin,s=void 0===i?"-1px -1px -1px -1px":i,n=t.IORaf;this.scrollElements=void 0,this.rootMargin=void 0,this.IORaf=void 0,this.observer=void 0,this.scrollElements=e,this.rootMargin=s,this.IORaf=n,this._init()}var e=t.prototype;return e._init=function(){var t=this;this.observer=new IntersectionObserver(function(e){e.forEach(function(e){var i=t.scrollElements.find(function(t){return t.$el===e.target});e.isIntersecting?(i&&(i.isAlreadyIntersected=!0),t._setInview(e)):i&&i.isAlreadyIntersected&&t._setOutOfView(e)})},{rootMargin:this.rootMargin});for(var e,s=i(this.scrollElements);!(e=s()).done;)this.observe(e.value.$el)},e.destroy=function(){this.observer.disconnect()},e.observe=function(t){t&&this.observer.observe(t)},e.unobserve=function(t){t&&this.observer.unobserve(t)},e._setInview=function(t){var e=this.scrollElements.find(function(e){return e.$el===t.target});this.IORaf&&(null==e||e.setInteractivityOn()),!this.IORaf&&(null==e||e.setInview())},e._setOutOfView=function(t){var e=this.scrollElements.find(function(e){return e.$el===t.target});this.IORaf&&(null==e||e.setInteractivityOff()),!this.IORaf&&(null==e||e.setOutOfView()),null!=e&&e.attributes.scrollRepeat||this.IORaf||this.unobserve(t.target)},t}();function d(t,e,i,s,n){return i+((n-t)/(e-t)*(s-i)||0)}function m(t,e){return t.reduce(function(t,i){return Math.abs(i-e)1?1:e;if(this.progress=s,s!=this.lastProgress){if(this.lastProgress=s,this.attributes.scrollCssProgress&&this._setCssProgress(s),this.attributes.scrollEventProgress&&this._setCustomEventProgress(s),this.attributes.scrollModuleProgress)for(var n,r=i(this.progressModularModules);!(n=r()).done;){var o=n.value;this.modularInstance&&this.modularInstance.call("onScrollProgress",s,o.moduleName,o.moduleId)}s>0&&s<1&&this.setInview(),0===s&&this.setOutOfView(),1===s&&this.setOutOfView()}},e._setCssProgress=function(t){void 0===t&&(t=0),this.$el.style.setProperty("--progress",t.toString())},e._setCustomEventProgress=function(t){void 0===t&&(t=0);var e=this.attributes.scrollEventProgress;if(e){var i=new CustomEvent(e,{detail:{target:this.$el,progress:t}});window.dispatchEvent(i)}},e._getProgressModularModules=function(){if(this.modularInstance){var t=Object.keys(this.$el.dataset).filter(function(t){return t.includes("module")}),e=Object.entries(this.modularInstance.modules);if(t.length)for(var s,n=i(t);!(s=n()).done;){var r=this.$el.dataset[s.value];if(!r)return;for(var o,l=i(e);!(o=l()).done;){var a=o.value;r in a[1]&&this.progressModularModules.push({moduleName:a[0],moduleId:r})}}}},e._getScrollCallFrom=function(){var t=m([this.intersection.start,this.intersection.end],this.currentScroll);return this.intersection.start===t?"start":"end"},e._dispatchCall=function(t,e){var i,s,n=null==(i=this.attributes.scrollCall)?void 0:i.split(","),r=null==(s=this.attributes)?void 0:s.scrollCallSelf;if(n&&n.length>1){var o,l,a=n[0],h=n[1],c=n[2];l=r?this.$el.dataset["module"+h.trim()]:c,this.modularInstance&&this.modularInstance.call(a.trim(),{target:this.$el,way:t,from:e},h.trim(),null==(o=l)?void 0:o.trim())}else if(n){var u=new CustomEvent(n[0],{detail:{target:this.$el,way:t,from:e}});window.dispatchEvent(u)}},t}(),p=["scrollOffset","scrollPosition","scrollModuleProgress","scrollCssProgress","scrollEventProgress","scrollSpeed"],f=/*#__PURE__*/function(){function t(t){var e=t.$el,i=t.modularInstance,s=t.triggerRootMargin,n=t.rafRootMargin,r=t.scrollOrientation;this.$scrollContainer=void 0,this.modularInstance=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,e?(this.$scrollContainer=e,this.modularInstance=i,this.scrollOrientation=r,this.triggerRootMargin=null!=s?s:"-1px -1px -1px -1px",this.rafRootMargin=null!=n?n:"100% 100% 100% 100%",this.scrollElements=[],this.triggeredScrollElements=[],this.RAFScrollElements=[],this.scrollElementsToUpdate=[],this._init()):console.error("Please provide a DOM Element as scrollContainer")}var e=t.prototype;return e._init=function(){var t=this.$scrollContainer.querySelectorAll("[data-scroll]"),e=Array.from(t);this._subscribeScrollElements(e),this.IOTriggerInstance=new u({scrollElements:[].concat(this.triggeredScrollElements),rootMargin:this.triggerRootMargin,IORaf:!1}),this.IORafInstance=new u({scrollElements:[].concat(this.RAFScrollElements),rootMargin:this.rafRootMargin,IORaf:!0})},e.destroy=function(){this.IOTriggerInstance.destroy(),this.IORafInstance.destroy(),this._unsubscribeAllScrollElements()},e.onResize=function(t){for(var e,s=t.currentScroll,n=i(this.RAFScrollElements);!(e=n()).done;)e.value.onResize({currentScroll:s})},e.onRender=function(t){for(var e,s=t.currentScroll,n=t.smooth,r=i(this.scrollElementsToUpdate);!(e=r()).done;)e.value.onRender({currentScroll:s,smooth:n})},e.removeScrollElements=function(t){var e=this,i=t.querySelectorAll("[data-scroll]");if(i.length){for(var s=0;s-1&&(this.IOTriggerInstance.unobserve(n.$el),this.triggeredScrollElements.splice(s,1))}for(var r=0;r-1&&(this.IORafInstance.unobserve(o.$el),this.RAFScrollElements.splice(r,1))}i.forEach(function(t){var i=e.scrollElementsToUpdate.find(function(e){return e.$el===t}),s=e.scrollElements.find(function(e){return e.$el===t});i&&e._unsubscribeElementUpdate(i),s&&(e.scrollElements=e.scrollElements.filter(function(t){return t.id!=s.id}))})}},e.addScrollElements=function(t){var e=t.querySelectorAll("[data-scroll]"),i=[];this.scrollElements.forEach(function(t){i.push(t.id)});var s=Math.max.apply(Math,i)+1,n=Array.from(e);this._subscribeScrollElements(n,s,!0)},e._subscribeScrollElements=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=!1);for(var s=0;s