(function(n,t){if(typeof define=="function"&&define.amd)define(["exports"],t);else if(typeof exports!="undefined")t(exports);else{var i={exports:{}};t(i.exports);n.bodyScrollLock=i.exports}})(this,function(n){"use strict";function c(n){if(Array.isArray(n)){for(var t=0,i=Array(n.length);t<n.length;t++)i[t]=n[t];return i}return Array.from(n)}var r,o;Object.defineProperty(n,"__esModule",{value:!0});r=!1;typeof window!="undefined"&&(o={get passive(){return r=!0,undefined}},window.addEventListener("testPassive",null,o),window.removeEventListener("testPassive",null,o));var s=typeof window!="undefined"&&window.navigator&&window.navigator.platform&&/iP(ad|hone|od)/.test(window.navigator.platform),t=[],i=!1,h=-1,u=void 0,f=void 0,l=function(n){return t.some(function(t){return t.options.allowTouchMove&&t.options.allowTouchMove(n)?!0:!1})},e=function(n){var t=n||window.event;return l(t.target)?!0:t.touches.length>1?!0:(t.preventDefault&&t.preventDefault(),!1)},v=function(n){setTimeout(function(){if(f===undefined){var i=!!n&&n.reserveScrollBarGap===!0,t=window.innerWidth-document.documentElement.clientWidth;i&&t>0&&(f=document.body.style.paddingRight,document.body.style.paddingRight=t+"px")}u===undefined&&(u=document.body.style.overflow,document.body.style.overflow="hidden")})},a=function(){setTimeout(function(){f!==undefined&&(document.body.style.paddingRight=f,f=undefined);u!==undefined&&(document.body.style.overflow=u,u=undefined)})},y=function(n){return n?n.scrollHeight-n.scrollTop<=n.clientHeight:!1},p=function(n,t){var i=n.targetTouches[0].clientY-h;return l(n.target)?!1:t&&t.scrollTop===0&&i>0?e(n):y(t)&&i<0?e(n):(n.stopPropagation(),!0)},w=n.disableBodyScroll=function(n,u){var f,o;if(s){if(!n){console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.");return}n&&!t.some(function(t){return t.targetElement===n})&&(f={targetElement:n,options:u||{}},t=[].concat(c(t),[f]),n.ontouchstart=function(n){n.targetTouches.length===1&&(h=n.targetTouches[0].clientY)},n.ontouchmove=function(t){t.targetTouches.length===1&&p(t,n)},i||(document.addEventListener("touchmove",e,r?{passive:!1}:undefined),i=!0))}else v(u),o={targetElement:n,options:u||{}},t=[].concat(c(t),[o])},b=n.clearAllBodyScrollLocks=function(){s?(t.forEach(function(n){n.targetElement.ontouchstart=null;n.targetElement.ontouchmove=null}),i&&(document.removeEventListener("touchmove",e,r?{passive:!1}:undefined),i=!1),t=[],h=-1):(a(),t=[])},k=n.enableBodyScroll=function(n){if(s){if(!n){console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.");return}n.ontouchstart=null;n.ontouchmove=null;t=t.filter(function(t){return t.targetElement!==n});i&&t.length===0&&(document.removeEventListener("touchmove",e,r?{passive:!1}:undefined),i=!1)}else t.length===1&&t[0].targetElement===n?(a(),t=[]):t=t.filter(function(t){return t.targetElement!==n})}})