!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t||self).lenis=e()}(this,function(){function t(t,e){for(var i=0;i=1)?1:this.easing(l);this.value=this.from+(this.to-this.from)*h}null==(e=this.onupdate)||e.call(this,this.value,r),r&&this.stop()}},e.stop=function(){this.isrunning=!1},e.fromto=function(t,e,i){var o=i.lerp,n=void 0===o?.1:o,s=i.duration,r=void 0===s?1:s,l=i.easing,h=void 0===l?function(t){return t}:l,a=i.onstart,c=i.onupdate;this.from=this.value=t,this.to=e,this.lerp=n,this.duration=r,this.easing=h,this.currenttime=0,this.isrunning=!0,null==a||a(),this.onupdate=c},t}(),s=/*#__pure__*/function(){function t(t){var e,i,o=this,n=void 0===t?{}:t,s=n.wrapper,r=n.content,l=n.autoresize,h=void 0===l||l;if(this.resize=function(){o.onwrapperresize(),o.oncontentresize()},this.onwrapperresize=function(){o.wrapper===window?(o.width=window.innerwidth,o.height=window.innerheight):(o.width=o.wrapper.clientwidth,o.height=o.wrapper.clientheight)},this.oncontentresize=function(){o.scrollheight=o.content.scrollheight,o.scrollwidth=o.content.scrollwidth},this.wrapper=s,this.content=r,h){var a=(e=this.resize,function(){var t=arguments,o=this;cleartimeout(i),i=settimeout(function(){e.apply(o,t)},250)});this.wrapper!==window&&(this.wrapperresizeobserver=new resizeobserver(a),this.wrapperresizeobserver.observe(this.wrapper)),this.contentresizeobserver=new resizeobserver(a),this.contentresizeobserver.observe(this.content)}this.resize()}return t.prototype.destroy=function(){var t,e;null==(t=this.wrapperresizeobserver)||t.disconnect(),null==(e=this.contentresizeobserver)||e.disconnect()},e(t,[{key:"limit",get:function(){return{x:this.scrollwidth-this.width,y:this.scrollheight-this.height}}}]),t}(),r=/*#__pure__*/function(){function t(){this.events={}}var e=t.prototype;return e.emit=function(t){for(var e=this.events[t]||[],i=0,o=e.length;imath.abs(o)?n:o:"horizontal"===e.options.gestureorientation&&(a=o);var c=r&&e.options.synctouch,u=r&&"touchend"===s.type&&math.abs(a)>1;u&&(a=e.velocity*e.options.touchinertiamultiplier),e.scrollto(e.targetscroll+a,i({programmatic:!1},c&&{lerp:u?e.synctouchlerp:e.options.__iosnoinertiasynctouchlerp}))}}}},this.onnativescroll=function(){if(!e.__preventnextscrollevent&&!e.isscrolling){var t=e.animatedscroll;e.animatedscroll=e.targetscroll=e.actualscroll,e.velocity=0,e.direction=math.sign(e.animatedscroll-t),e.emit()}},window.lenisversion="1.0.29",a!==document.documentelement&&a!==document.body||(a=window),this.options={wrapper:a,content:u,wheeleventstarget:d,eventstarget:f,smoothwheel:g,smoothtouch:y,synctouch:t,synctouchlerp:z,__iosnoinertiasynctouchlerp:m,touchinertiamultiplier:e,duration:k,easing:r,lerp:x,infinite:h,gestureorientation:x,orientation:j,touchmultiplier:d,wheelmultiplier:p,normalizewheel:v,autoresize:b},this.animate=new n,this.emitter=new r,this.dimensions=new s({wrapper:a,content:u,autoresize:b}),this.toggleclass("lenis",!0),this.velocity=0,this.islocked=!1,this.isstopped=!1,this.issmooth=t||g||y,this.isscrolling=!1,this.targetscroll=this.animatedscroll=this.actualscroll,this.options.wrapper.addeventlistener("scroll",this.onnativescroll,{passive:!1}),this.virtualscroll=new l(f,{touchmultiplier:d,wheelmultiplier:p,normalizewheel:v}),this.virtualscroll.on("scroll",this.onvirtualscroll)}var h=t.prototype;return h.destroy=function(){this.emitter.destroy(),this.options.wrapper.removeeventlistener("scroll",this.onnativescroll,{passive:!1}),this.virtualscroll.destroy(),this.dimensions.destroy(),this.toggleclass("lenis",!1),this.toggleclass("lenis-smooth",!1),this.toggleclass("lenis-scrolling",!1),this.toggleclass("lenis-stopped",!1),this.toggleclass("lenis-locked",!1)},h.on=function(t,e){return this.emitter.on(t,e)},h.off=function(t,e){return this.emitter.off(t,e)},h.setscroll=function(t){this.ishorizontal?this.rootelement.scrollleft=t:this.rootelement.scrolltop=t},h.resize=function(){this.dimensions.resize()},h.emit=function(){this.emitter.emit("scroll",this)},h.reset=function(){this.islocked=!1,this.isscrolling=!1,this.animatedscroll=this.targetscroll=this.actualscroll,this.velocity=0,this.animate.stop()},h.start=function(){this.isstopped=!1,this.reset()},h.stop=function(){this.isstopped=!0,this.animate.stop(),this.reset()},h.raf=function(t){var e=t-(this.time||t);this.time=t,this.animate.advance(.001*e)},h.scrollto=function(t,e){var i=this,n=void 0===e?{}:e,s=n.offset,r=void 0===s?0:s,l=n.immediate,h=void 0!==l&&l,a=n.lock,c=void 0!==a&&a,u=n.duration,p=void 0===u?this.options.duration:u,d=n.easing,v=void 0===d?this.options.easing:d,f=n.lerp,m=void 0===f?!p&&this.options.lerp:f,g=n.oncomplete,s=void 0===g?null:g,y=n.force,w=n.programmatic,t=void 0===w||w;if(!this.isstopped&&!this.islocked||void 0!==y&&y){if(["top","left","start"].includes(t))t=0;else if(["bottom","right","end"].includes(t))t=this.limit;else{var b,z;if("string"==typeof t?z=document.queryselector(t):null!=(b=t)&&b.nodetype&&(z=t),z){if(this.options.wrapper!==window){var _=this.options.wrapper.getboundingclientrect();r-=this.ishorizontal?_.left:_.top}var m=z.getboundingclientrect();t=(this.ishorizontal?m.left:m.top)+this.animatedscroll}}if("number"==typeof t){if(t+=r,t=math.round(t),this.options.infinite?t&&(this.targetscroll=this.animatedscroll=this.scroll):t=o(0,t,this.limit),h)return this.animatedscroll=this.targetscroll=t,this.setscroll(this.scroll),this.reset(),void(null==s||s(this));if(!t){if(t===this.targetscroll)return;this.targetscroll=t}this.animate.fromto(this.animatedscroll,t,{duration:p,easing:v,lerp:m,onstart:function(){c&&(i.islocked=!0),i.isscrolling=!0},onupdate:function(t,e){i.isscrolling=!0,i.velocity=t-i.animatedscroll,i.direction=math.sign(i.velocity),i.animatedscroll=t,i.setscroll(i.scroll),t&&(i.targetscroll=t),e||i.emit(),e&&(i.reset(),i.emit(),null==s||s(i),i.__preventnextscrollevent=!0,requestanimationframe(function(){delete i.__preventnextscrollevent}))}})}}},h.toggleclass=function(t,e){this.rootelement.classlist.toggle(t,e),this.emitter.emit("classname change",this)},e(t,[{key:"rootelement",get:function(){return this.options.wrapper===window?document.documentelement:this.options.wrapper}},{key:"limit",get:function(){return this.dimensions.limit[this.ishorizontal?"x":"y"]}},{key:"ishorizontal",get:function(){return"horizontal"===this.options.orientation}},{key:"actualscroll",get:function(){return this.ishorizontal?this.rootelement.scrollleft:this.rootelement.scrolltop}},{key:"scroll",get:function(){return this.options.infinite?(this.animatedscroll%(t=this.limit)+t)%t:this.animatedscroll;var t}},{key:"progress",get:function(){return 0===this.limit?1:this.scroll/this.limit}},{key:"issmooth",get:function(){return this.__issmooth},set:function(t){this.__issmooth!==t&&(this.__issmooth=t,this.toggleclass("lenis-smooth",t))}},{key:"isscrolling",get:function(){return this.__isscrolling},set:function(t){this.__isscrolling!==t&&(this.__isscrolling=t,this.toggleclass("lenis-scrolling",t))}},{key:"isstopped",get:function(){return this.__isstopped},set:function(t){this.__isstopped!==t&&(this.__isstopped=t,this.toggleclass("lenis-stopped",t))}},{key:"islocked",get:function(){return this.__islocked},set:function(t){this.__islocked!==t&&(this.__islocked=t,this.toggleclass("lenis-locked",t))}},{key:"classname",get:function(){var t="lenis";return this.isstopped&&(t+=" lenis-stopped"),this.islocked&&(t+=" lenis-locked"),this.isscrolling&&(t+=" lenis-scrolling"),this.issmooth&&(t+=" lenis-smooth"),t}}]),t}()});