!function(e,t){"function"==typeof define&&define.amd?define([],function(){return t(e)}):"object"==typeof exports?module.exports=t(e):e.Gumshoe=t(e)}("undefined"!=typeof global?global:"undefined"!=typeof window?window:this,function(u){"use strict";function f(e,t,n){var o;n.settings.events&&(o=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n}),t.dispatchEvent(o))}function n(e){var t=0;if(e.offsetParent)for(;e;)t+=e.offsetTop,e=e.offsetParent;return 0<=t?t:0}function d(e){e&&e.sort(function(e,t){return n(e.content)<n(t.content)?-1:1})}function r(e,t,n){var o,s=e.getBoundingClientRect(),c="function"==typeof(o=t).offset?parseFloat(o.offset()):parseFloat(o.offset);return n?parseInt(s.bottom,10)<(u.innerHeight||document.documentElement.clientHeight):parseInt(s.top,10)<=c}function i(){return Math.ceil(u.innerHeight+u.pageYOffset)>=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight,document.body.clientHeight,document.documentElement.clientHeight)}function v(e,t){var n,o,s=e[e.length-1];if(n=s,o=t,!(!i()||!r(n.content,o,!0)))return s;for(var c=e.length-1;0<=c;c--)if(r(e[c].content,t))return e[c]}function m(e,t){var n;!e||(n=e.nav.closest("li"))&&(n.classList.remove(t.navClass),e.content.classList.remove(t.contentClass),o(n,t),f("gumshoeDeactivate",n,{link:e.nav,content:e.content,settings:t}))}var h={navClass:"active",contentClass:"active",nested:!1,nestedClass:"active",offset:0,reflow:!1,events:!0},o=function(e,t){var n;t.nested&&e.parentNode&&((n=e.parentNode.closest("li"))&&(n.classList.remove(t.nestedClass),o(n,t)))},p=function(e,t){var n;!t.nested||(n=e.parentNode.closest("li"))&&(n.classList.add(t.nestedClass),p(n,t))};return function(e,t){var n,s,c,o,r,i={setup:function(){n=document.querySelectorAll(e),s=[],Array.prototype.forEach.call(n,function(e){var t=document.getElementById(decodeURIComponent(e.hash.substr(1)));t&&s.push({nav:e,content:t})}),d(s)}};i.detect=function(){var e,t,n,o=v(s,r);o?c&&o.content===c.content||(m(c,r),t=r,!(e=o)||(n=e.nav.closest("li"))&&(n.classList.add(t.navClass),e.content.classList.add(t.contentClass),p(n,t),f("gumshoeActivate",n,{link:e.nav,content:e.content,settings:t})),c=o):c&&(m(c,r),c=null)};function l(e){o&&u.cancelAnimationFrame(o),o=u.requestAnimationFrame(i.detect)}function a(e){o&&u.cancelAnimationFrame(o),o=u.requestAnimationFrame(function(){d(s),i.detect()})}i.destroy=function(){c&&m(c,r),u.removeEventListener("scroll",l,!1),r.reflow&&u.removeEventListener("resize",a,!1),r=o=c=n=s=null};return r=function(){var n={};return Array.prototype.forEach.call(arguments,function(e){for(var t in e){if(!e.hasOwnProperty(t))return;n[t]=e[t]}}),n}(h,t||{}),i.setup(),i.detect(),u.addEventListener("scroll",l,!1),r.reflow&&u.addEventListener("resize",a,!1),i}}),function(o,s){var c=null,r=null;function e(){var t,n=!1;o.addEventListener("scroll",function(e){t=o.scrollY,n||(o.requestAnimationFrame(function(){var e;e=t,0==c.getBoundingClientRect().top?c.classList.add("scrolled"):c.classList.remove("scrolled"),null!==r&&(0==e?r.scrollTo(0,0):Math.ceil(o.innerHeight+e)>=s.body.offsetHeight&&r.scrollTo(0,r.scrollHeight)),n=!1}),n=!0)}),o.scroll()}s.addEventListener("DOMContentLoaded",function(){s.body.parentNode.classList.remove("no-js"),c=s.querySelector("header"),r=s.querySelector(".toc-scroll"),e(),null!==r&&new Gumshoe(".toc-tree a",{reflow:!0,recursive:!0,navClass:"scroll-current"})})}(window,document);