!function(t,e){"function"==typeof define&&define.amd?define([],e(t)):"object"==typeof exports?module.exports=e(t):t.smoothScroll=e(t)}("undefined"!=typeof global?global:this.window||this.global,function(t){"use strict";var e,n,o,r,a={},u=!!t.document.querySelector&&!!t.addEventListener,c={speed:500,easing:"easeInOutCubic",offset:0,updateURL:!0,callback:function(){}},i=function(){var t={},e=!1,n=0,o=arguments.length;"[object Boolean]"===Object.prototype.toString.call(arguments[0])&&(e=arguments[0],n++);for(var r=function(n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=e&&"[object Object]"===Object.prototype.toString.call(n[o])?i(!0,t[o],n[o]):n[o])};o>n;n++){var a=arguments[n];r(a)}return t},s=function(t){return Math.max(t.scrollHeight,t.offsetHeight,t.clientHeight)},l=function(t,e){var n,o,r=e.charAt(0),a="classList"in document.documentElement;for("["===r&&(e=e.substr(1,e.length-2),n=e.split("="),n.length>1&&(o=!0,n[1]=n[1].replace(/"/g,"").replace(/'/g,"")));t&&t!==document;t=t.parentNode){if("."===r)if(a){if(t.classList.contains(e.substr(1)))return t}else if(new RegExp("(^|\\s)"+e.substr(1)+"(\\s|$)").test(t.className))return t;if("#"===r&&t.id===e.substr(1))return t;if("["===r&&t.hasAttribute(n[0])){if(!o)return t;if(t.getAttribute(n[0])===n[1])return t}if(t.tagName.toLowerCase()===e)return t}return null},f=function(t){for(var e,n=String(t),o=n.length,r=-1,a="",u=n.charCodeAt(0);++r=1&&31>=e||127==e||0===r&&e>=48&&57>=e||1===r&&e>=48&&57>=e&&45===u?"\\"+e.toString(16)+" ":e>=128||45===e||95===e||e>=48&&57>=e||e>=65&&90>=e||e>=97&&122>=e?n.charAt(r):"\\"+n.charAt(r)}return a},d=function(t,e){var n;return"easeInQuad"===t&&(n=e*e),"easeOutQuad"===t&&(n=e*(2-e)),"easeInOutQuad"===t&&(n=.5>e?2*e*e:-1+(4-2*e)*e),"easeInCubic"===t&&(n=e*e*e),"easeOutCubic"===t&&(n=--e*e*e+1),"easeInOutCubic"===t&&(n=.5>e?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1),"easeInQuart"===t&&(n=e*e*e*e),"easeOutQuart"===t&&(n=1- --e*e*e*e),"easeInOutQuart"===t&&(n=.5>e?8*e*e*e*e:1-8*--e*e*e*e),"easeInQuint"===t&&(n=e*e*e*e*e),"easeOutQuint"===t&&(n=1+--e*e*e*e*e),"easeInOutQuint"===t&&(n=.5>e?16*e*e*e*e*e:1+16*--e*e*e*e*e),n||e},h=function(t,e,n){var o=0;if(t.offsetParent)do o+=t.offsetTop,t=t.offsetParent;while(t);return o=o-e-n,o>=0?o:0},m=function(){return Math.max(t.document.body.scrollHeight,t.document.documentElement.scrollHeight,t.document.body.offsetHeight,t.document.documentElement.offsetHeight,t.document.body.clientHeight,t.document.documentElement.clientHeight)},p=function(t){return t&&"object"==typeof JSON&&"function"==typeof JSON.parse?JSON.parse(t):{}},g=function(e,n){t.history.pushState&&(n||"true"===n)&&t.history.pushState(null,null,[t.location.protocol,"//",t.location.host,t.location.pathname,t.location.search,e].join(""))},b=function(t){return null===t?0:s(t)+t.offsetTop};a.animateScroll=function(e,n,a){var u=p(e?e.getAttribute("data-options"):null),s=i(s||c,a||{},u);n="#"+f(n.substr(1));var l="#"===n?t.document.documentElement:t.document.querySelector(n),v=t.pageYOffset;o||(o=t.document.querySelector("[data-scroll-header]")),r||(r=b(o));var y,O,S,I=h(l,r,parseInt(s.offset,10)),E=I-v,L=m(),H=0;g(n,s.updateURL);var j=function(o,r,a){var u=t.pageYOffset;(o==r||u==r||t.innerHeight+u>=L)&&(clearInterval(a),l.focus(),s.callback(e,n))},w=function(){H+=16,O=H/parseInt(s.speed,10),O=O>1?1:O,S=v+E*d(s.easing,O),t.scrollTo(0,Math.floor(S)),j(S,I,y)},C=function(){y=setInterval(w,16)};0===t.pageYOffset&&t.scrollTo(0,0),C()};var v=function(t){var n=l(t.target,"[data-scroll]");n&&"a"===n.tagName.toLowerCase()&&(t.preventDefault(),a.animateScroll(n,n.hash,e))},y=function(t){n||(n=setTimeout(function(){n=null,r=b(o)},66))};return a.destroy=function(){e&&(t.document.removeEventListener("click",v,!1),t.removeEventListener("resize",y,!1),e=null,n=null,o=null,r=null)},a.init=function(n){u&&(a.destroy(),e=i(c,n||{}),o=t.document.querySelector("[data-scroll-header]"),r=b(o),t.document.addEventListener("click",v,!1),o&&t.addEventListener("resize",y,!1))},a});