const throttle=(e,t)=>{let n=null;return()=>{n==null&&(n=setTimeout(()=>{e(),n=null},t))}},listen=(e,t,n)=>{document.querySelector(e)!==null&&document.querySelector(e).addEventListener(t,n)};let header=document.getElementById("site-header"),lastScrollPosition=window.pageYOffset;const autoHideHeader=()=>{let e=Math.max(window.pageYOffset,0);e>lastScrollPosition?(header.classList.remove("slideInUp"),header.classList.add("slideOutDown")):(header.classList.remove("slideOutDown"),header.classList.add("slideInUp")),lastScrollPosition=e};let mobileMenuVisible=!1;const toggleMobileMenu=()=>{let e=document.getElementById("mobile-menu");mobileMenuVisible==!1?(e.style.animationName="bounceInRight",e.style.webkitAnimationName="bounceInRight",e.style.display="block",mobileMenuVisible=!0):(e.style.animationName="bounceOutRight",e.style.webkitAnimationName="bounceOutRight",e.style.display="none",mobileMenuVisible=!1)};let shareMenuVisible=!1;const shareMobileMenu=()=>{let e=document.getElementById("share-links");shareMenuVisible==!1?(e.style.animationName="bounceInRight",e.style.webkitAnimationName="bounceInRight",e.style.display="block",shareMenuVisible=!0):(e.style.animationName="bounceOutRight",e.style.webkitAnimationName="bounceOutRight",e.style.display="none",shareMenuVisible=!1)},showImg=()=>{document.querySelector(".bg-img").classList.add("show-bg-img")},hideImg=()=>{document.querySelector(".bg-img").classList.remove("show-bg-img")},toggleToc=()=>{document.getElementById("toc").classList.toggle("show-toc")};header!==null&&(listen("#menu-btn","click",toggleMobileMenu),listen("#share-btn","click",shareMobileMenu),listen("#toc-btn","click",toggleToc),listen("#img-btn","click",showImg),listen(".bg-img","click",hideImg),document.querySelectorAll(".post-year").forEach(e=>{e.addEventListener("click",()=>{window.location.hash="#"+e.id})}),window.addEventListener("scroll",throttle(()=>{autoHideHeader(),mobileMenuVisible==!0&&toggleMobileMenu(),shareMenuVisible==!0&&shareMobileMenu()},250))),function(){"use strict";if(!document.queryCommandSupported("copy"))return;function e(e,t){e.textContent=t,setTimeout(function(){e.textContent="Copy"},1e3)}function t(e){var t=window.getSelection(),n=document.createRange();return n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n),t}function n(n){var o,s=document.createElement("button");s.className="highlight-copy-btn",s.textContent="Copy",o=n.firstElementChild,s.addEventListener("click",function(){try{if(o.firstElementChild instanceof HTMLTableElement)var n=t(o.firstElementChild.firstElementChild.firstElementChild.lastElementChild);else n=t(o);document.execCommand("copy"),n.removeAllRanges(),e(s,"Copied!")}catch(t){console&&console.log(t),e(s,"Failed :'(")}}),n.appendChild(s)}var s=document.getElementsByClassName("highlight");Array.prototype.forEach.call(s,n)}()