!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():e.AutocJs=t()}(this,function(){"use strict";function n(e,t){for(var i=0;i=o)return r.scrollTop=o,i.stop(),!1;i.timer=setTimeout(e,30)}(),this}},{key:"stop",value:function(){return clearTimeout(this.timer),this.timer=null,this}},{key:"show",value:function(){var e=this.getElements(),t=p.Utils.DOM;return t.addClass(e.modal,"outline-outside-modal-opened"),t.removeClass(e.overlay,"outline-hidden"),this}},{key:"hide",value:function(){var e=this.getElements(),t=p.Utils.DOM;return t.removeClass(e.modal,"outline-outside-modal-opened"),t.addClass(e.overlay,"outline-hidden"),this}},{key:"toggle",value:function(){return p.Utils.DOM.hasClass(this.getElements().modal,"outline-outside-modal-opened")?this.hide():this.show(),this}},{key:"remove",value:function(){var e=this.getElements(),t=e.wrap;return this.removeListeners(),this.get("isGenerateHeadingAnchor")&&e.anchors.forEach(function(e){e.parentNode.removeChild(e)}),t.parentNode.removeChild(t),this}},{key:"destroy",value:function(){return this.remove(),this.attributes={},this.elements={article:null,wrap:null,modal:null,header:null,title:null,body:null,list:null,footer:null,switcher:null,top:null,overlay:null,anchors:[]},this.data={headings:[],chapters:[]},this.timer=null,this}},{key:"removeListeners",value:function(){var e=this.getElements(),t=e.article,i=e.wrap,n=p.Utils.Events.off,r=this.get("position").toLowerCase();return n(t,"mouseenter",this._handleArticleHeadingMouseEnter),n(t,"mouseleave",this._handleArticleHeadingMouseLeave),"outside"===r&&(n(i,"click",this._handleSwitcherClick),n(i,"click",this._handleTopClick),n(i,"click",this._handleOverlayClick)),n(i,"click",this._handleChapterClick),this.get("isGenerateHeadingAnchor")&&n(t,"click",this._handleHeadingAnchorClick),this}},{key:"addListeners",value:function(){var e=this.getElements(),t=e.article,i=e.wrap,n=p.Utils.Events.delegate,r=this.get("position").toLowerCase();return n(t,".outline-heading","mouseenter",this._handleArticleHeadingMouseEnter,this),n(t,".outline-heading","mouseleave",this._handleArticleHeadingMouseLeave,this),"outside"===r&&(n(i,".outline-outside-switcher","click",this._handleSwitcherClick,this),n(i,".outline-outside-top","click",this._handleTopClick,this),n(i,".outline-outside-overlay","click",this._handleOverlayClick,this)),n(i,".outline-link","click",this._handleChapterClick,this),this.get("isGenerateHeadingAnchor")&&n(t,".outline-heading-anchor","click",this._handleHeadingAnchorClick,this),this}},{key:"_handleArticleHeadingMouseEnter",value:function(e){var t=e.delegateTarget.querySelector(".outline-heading-anchor");return t&&p.Utils.DOM.removeClass(t,"outline-hidden"),this}},{key:"_handleArticleHeadingMouseLeave",value:function(e){var t=e.delegateTarget.querySelector(".outline-heading-anchor");return t&&p.Utils.DOM.addClass(t,"outline-hidden"),this}},{key:"_handleHeadingAnchorClick",value:function(e){var t=e.delegateTarget.getAttribute("rel"),i=document.querySelector("#"+t),n=p.Utils,r=n.DOM,a=n.Events,l=r.offset(i).top;return n.isEmpty(this.get("anchorURL"))&&(this.stop().scrollTo(l),a.stop(e)),this}},{key:"_handleChapterClick",value:function(e){var t=e.delegateTarget.getAttribute("rel"),i=document.querySelector("#"+t),n=p.Utils,r=n.DOM,a=n.Events,l=r.offset(i).top;return"outside"===this.get("position")&&this.hide(),this.stop().scrollTo(l),a.stop(e),this}},{key:"_handleSwitcherClick",value:function(){return this.toggle(),this}},{key:"_handleTopClick",value:function(e){var t=p.Utils.Events;return this.stop().scrollTo(0),t.stop(e),this}},{key:"_handleOverlayClick",value:function(){return this.hide(),this}}]),p);function p(e){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,p),this.attributes={},this.elements={article:null,wrap:null,modal:null,header:null,title:null,body:null,list:null,footer:null,switcher:null,top:null,overlay:null,anchors:[]},this.data={headings:[],chapters:[]},this.timer=null,this.initialize(e).render().addListeners(),this}return s.defaults={article:"#article",selector:"h1,h2,h3,h4,h5,h6",title:"文章导读",position:"outside",anchorURL:"",anchorAt:"front",isGenerateOutline:!0,isGenerateOutlineChapterCode:!0,isGenerateHeadingChapterCode:!1,isGenerateHeadingAnchor:!0},s.Utils={uuid:0,isObject:function(e){return"[object Object]"===Object.prototype.toString.apply(e)&&null!==e},isArray:function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.apply(e)},isElement:function(e){return e&&e.nodeName&&e.tagName&&1===e.nodeType},isEmpty:function(e){return"string"==typeof e&&""===e},guid:function(e){var t=s.Utils;return t.uuid+=1,e?e+"-"+t.uuid:"guid-"+t.uuid},trim:function(e){return e.replace(/^\s+/g,"").replace(/\s+$/g,"")},stripTags:function(e){return e.replace(/<\/?[^>]+(>|$)/g,"")},groupBy:function(e,i){var n={};return e.forEach(function(e){var t=JSON.stringify(function(e){return[e[i]]}(e));n[t]=n[t]||[],n[t].push(e)}),Object.keys(n).map(function(e){return n[e]})},easeInQuad:function(e){return e*e},extend:function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])}},s.Utils.DOM={createElement:function(e,t,i){var n=s.Utils,r=n.DOM,a=document.createElement(e);for(var l in t)t.hasOwnProperty(l)&&r.setAttribute(a,l,t[l]);return n.isArray(i)&&i.forEach(function(e){var t=n.isElement(e)?e:document.createTextNode(e);a.appendChild(t)}),a},setAttribute:function(e,t,i){var n=e.tagName.toLowerCase();switch(t){case"style":e.style.cssText=i;break;case"value":"input"===n||"textarea"===n?e.value=i:e.setAttribute(t,i);break;case"className":e.className=i;break;default:e.setAttribute(t,i)}},hasClass:function(e,t){var i=e.className;return!!i&&i.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))},addClass:function(e,t){var i=e.className;if(s.Utils.DOM.hasClass(e,t))return!1;i+=0