window.Sticksy=function(){"use strict";var t="static",e="fixed";function i(t,e){if(!t)throw new Error("You have to specify the target element");if("string"!=typeof t&&!(t instanceof Element))throw new Error("Expected a string or element, but got: "+Object.prototype.toString.call(t));var i=n.findElement(t);if(!i)throw new Error("Cannot find target element: "+t);var o=i.parentNode;if(!o)throw new Error("Cannot find container of target element: "+t);e=e||{},this.t={containerEl:o,targetEl:i,topSpacing:e.topSpacing||0,enabled:e.enabled||!0,listen:e.listen||!1},this.onStateChanged=null,this.nodeRef=i,this.i()}i.instances=[],i.enabledInstances=[],i.prototype.i=function(){var e=this;this.state=t,this.o=[],this.h=[];for(var n=this.t.targetEl;n;){var o=n.cloneNode(!0);o.style.visibility="hidden",o.style.pointerEvents="none",o.className+=" sticksy-dummy-node",o.removeAttribute("id"),this.t.targetEl.parentNode.insertBefore(o,this.t.targetEl),this.o.push(n),this.h.push(o),n=n.nextElementSibling}this.u=0,this.l={top:0,bottom:0},this.v=!1,this.t.containerEl.style.position="relative",this.m=-1===getComputedStyle(this.t.containerEl).display.indexOf("flex"),this.t.listen&&(this.p=new MutationObserver(function(){e.hardRefresh()}),this.g()),i.instances.push(this),this.t.enabled&&i.enabledInstances.push(this),this.hardRefresh()},i.prototype.g=function(){this.t.listen&&!this.v&&(this.p.observe(this.t.containerEl,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),this.v=!0)},i.prototype.C=function(){this.t.listen&&this.v&&(this.p.disconnect(),this.v=!1)},i.prototype.M=function(i){return i=this.l.bottom?"stuck":e},i.prototype.S=function(){this.u=n.getComputedBox(this.o[this.o.length-1]).bottomWithMargin-n.getComputedBox(this.o[0]).topWithMargin},i.prototype.j=function(){var t=this.t.containerEl,e=this.o;t=n.getComputedBox(t),e=n.getComputedBox(e[0]);this.l={top:e.topWithMargin-this.t.topSpacing,bottom:t.bottom-t.paddingBottom-this.t.topSpacing-this.u}},i.prototype.B=function(i){i===t?(this.P(this.o),this.T(this.h)):(this.k(this.o),i===e?this.O(this.o):this.W(this.o),this.D(this.h))},i.prototype.refresh=function(){var t=this.M(window.pageYOffset,this.l);t!==this.state&&(this.state=t,this.C(),this.B(t),this.g(),"function"==typeof this.onStateChanged&&this.onStateChanged(t))},i.prototype.hardRefresh=function(){this.C();var e=this.state;this.state=t,this.B(this.state),this.k(this.o),this.S(),this.j(),this.state=this.M(window.pageYOffset,this.l),this.B(this.state),this.g(),"function"==typeof this.onStateChanged&&e!==this.state&&this.onStateChanged(this.state)},i.prototype.enable=function(){this.t.enabled=!0,i.enabledInstances.push(this),this.hardRefresh()},i.prototype.disable=function(){this.t.enabled=!1,this.state=t,this.B(this.state),i.enabledInstances.splice(i.enabledInstances.indexOf(this),1)},i.prototype.O=function(t){for(var e=0,i=this.t.topSpacing,o=0;o=992&&Sticksy.initializeAll(".sticksy",{listen:!0},!0)})}(jQuery);