text: (()=>{var m=class{galleryUID;items=[];constructor(t,i=1){if(window.PhotoSwipe==null||window.PhotoSwipeUI_Default==null){console.error("PhotoSwipe lib not loaded.");return}this.galleryUID=i,m.createGallery(t),this.loadItems(t),this.bindClick()}loadItems(t){this.items=[];let i=t.querySelectorAll("figure.gallery-image");for(let o of i){let r=o.querySelector("figcaption"),n=o.querySelector("img"),s={w:parseInt(n.getAttribute("width")),h:parseInt(n.getAttribute("height")),src:n.src,msrc:n.getAttribute("data-thumb")||n.src,el:o};r&&(s.title=r.innerHTML),this.items.push(s)}}static createGallery(t){let i=t.querySelectorAll("figure.gallery-image"),o=[];for(let r of i)o.length?r.previousElementSibling===o[o.length-1]?o.push(r):o.length&&(m.wrap(o),o=[r]):o=[r];o.length>0&&m.wrap(o)}static wrap(t){let i=document.createElement("div");i.className="gallery";let o=t[0].parentNode,r=t[0];o.insertBefore(i,r);for(let n of t)i.appendChild(n)}open(t){let i=document.querySelector(".pswp");new window.PhotoSwipe(i,window.PhotoSwipeUI_Default,this.items,{index:t,galleryUID:this.galleryUID,getThumbBoundsFn:r=>{let n=this.items[r].el.getElementsByTagName("img")[0],s=window.pageYOffset||document.documentElement.scrollTop,a=n.getBoundingClientRect();return{x:a.left,y:a.top+s,w:a.width}}}).init()}bindClick(){for(let[t,i]of this.items.entries())i.el.querySelector("a").addEventListener("click",r=>{r.preventDefault(),this.open(t)})}},y=m;var l={};if(localStorage.hasOwnProperty("StackColorsCache"))try{l=JSON.parse(localStorage.getItem("StackColorsCache"))}catch{l={}}async function g(e,t,i){if(!e)return await Vibrant.from(i).getPalette();if(!l.hasOwnProperty(e)||l[e].hash!==t){let o=await Vibrant.from(i).getPalette();l[e]={hash:t,Vibrant:{hex:o.Vibrant.hex,rgb:o.Vibrant.rgb,bodyTextColor:o.Vibrant.bodyTextColor},DarkMuted:{hex:o.DarkMuted.hex,rgb:o.DarkMuted.rgb,bodyTextColor:o.DarkMuted.bodyTextColor}},localStorage.setItem("StackColorsCache",JSON.stringify(l))}return l[e]}var k=(e,t=500)=>{e.classList.add("transiting"),e.style.transitionProperty="height, margin, padding",e.style.transitionDuration=t+"ms",e.style.height=e.offsetHeight+"px",e.offsetHeight,e.style.overflow="hidden",e.style.height="0",e.style.paddingTop="0",e.style.paddingBottom="0",e.style.marginTop="0",e.style.marginBottom="0",window.setTimeout(()=>{e.classList.remove("show"),e.style.removeProperty("height"),e.style.removeProperty("padding-top"),e.style.removeProperty("padding-bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom"),e.style.removeProperty("overflow"),e.style.removeProperty("transition-duration"),e.style.removeProperty("transition-property"),e.classList.remove("transiting")},t)},L=(e,t=500)=>{e.classList.add("transiting"),e.style.removeProperty("display"),e.classList.add("show");let i=e.offsetHeight;e.style.overflow="hidden",e.style.height="0",e.style.paddingTop="0",e.style.paddingBottom="0",e.style.marginTop="0",e.style.marginBottom="0",e.offsetHeight,e.style.transitionProperty="height, margin, padding",e.style.transitionDuration=t+"ms",e.style.height=i+"px",e.style.removeProperty("padding-top"),e.style.removeProperty("padding-bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom"),window.setTimeout(()=>{e.style.removeProperty("height"),e.style.removeProperty("overflow"),e.style.removeProperty("transition-duration"),e.style.removeProperty("transition-property"),e.classList.remove("transiting")},t)},x=(e,t=500)=>window.getComputedStyle(e).display==="none"?L(e,t):k(e,t);function f(){let e=document.getElementById("toggle-menu");e&&e.addEventListener("click",()=>{document.getElementById("main-menu").classList.contains("transiting")||(document.body.classList.toggle("show-menu"),x(document.getElementById("main-menu"),300),e.classList.toggle("is-active"))})}function M(e,t,i){var o=document.createElement(e);for(let r in t)if(r&&t.hasOwnProperty(r)){let n=t[r];r=="dangerouslySetInnerHTML"?o.innerHTML=n.__html:n===!0?o.setAttribute(r,r):n!==!1&&n!=null&&o.setAttribute(r,n.toString())}for(let r=2;r<arguments.length;r++){let n=arguments[r];n&&o.appendChild(n.nodeType==null?document.createTextNode(n.toString()):n)}return o}var S=M;var b=class{localStorageKey="StackColorScheme";currentScheme;systemPreferScheme;constructor(t){this.bindMatchMedia(),this.currentScheme=this.getSavedScheme(),this.dispatchEvent(document.documentElement.dataset.scheme),t&&this.bindClick(t),document.body.style.transition==""&&document.body.style.setProperty("transition","background-color .3s ease")}saveScheme(){localStorage.setItem(this.localStorageKey,this.currentScheme)}bindClick(t){t.addEventListener("click",i=>{this.isDark()?this.currentScheme="light":this.currentScheme="dark",this.setBodyClass(),this.currentScheme==this.systemPreferScheme&&(this.currentScheme="auto"),this.saveScheme()})}isDark(){return this.currentScheme=="dark"||this.currentScheme=="auto"&&this.systemPreferScheme=="dark"}dispatchEvent(t){let i=new CustomEvent("onColorSchemeChange",{detail:t});window.dispatchEvent(i)}setBodyClass(){this.isDark()?document.documentElement.dataset.scheme="dark":document.documentElement.dataset.scheme="light",this.dispatchEvent(document.documentElement.dataset.scheme)}getSavedScheme(){let t=localStorage.getItem(this.localStorageKey);return t=="light"||t=="dark"||t=="auto"?t:"auto"}bindMatchMedia(){window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",t=>{t.matches?this.systemPreferScheme="dark":this.systemPreferScheme="light",this.setBodyClass()})}},w=b;var v={init:()=>{f();let e=document.querySelector(".article-content");e&&new y(e);let t=document.querySelector(".article-list--tile");t&&new IntersectionObserver(async(s,a)=>{s.forEach(d=>{if(!d.isIntersecting)return;a.unobserve(d.target),d.target.querySelectorAll("article.has-image").forEach(async p=>{let u=p.querySelector("img"),E=u.src,T=u.getAttribute("data-key"),C=u.getAttribute("data-hash"),P=p.querySelector(".article-details"),c=await g(T,C,E);P.style.background=`
                          linear-gradient(0deg, 
                              rgba(${c.DarkMuted.rgb[0]}, ${c.DarkMuted.rgb[1]}, ${c.DarkMuted.rgb[2]}, 0.5) 0%, 
                              rgba(${c.Vibrant.rgb[0]}, ${c.Vibrant.rgb[1]}, ${c.Vibrant.rgb[2]}, 0.75) 100%)`})})}).observe(t);let i=document.querySelectorAll(".article-content .highlight"),o="Copy",r="Copied!";i.forEach(n=>{let s=document.createElement("button");s.innerHTML=o,s.classList.add("copyCodeButton"),n.appendChild(s);let d=n.getElementsByTagName("pre")[0].textContent;s.addEventListener("click",()=>{navigator.clipboard.writeText(d).then(()=>{s.textContent=r,setTimeout(()=>{s.textContent=o},1e3)}).catch(h=>{alert(h),console.log("Something went wrong",h)})})}),new w(document.getElementById("dark-mode-toggle"))}};window.addEventListener("load",()=>{setTimeout(function(){v.init()},0)});window.Stack=v;window.createElement=S;})();
  /*!
  *   Hugo Theme Stack
  *
  *   @author: Jimmy Cai
  *   @website: https://jimmycai.com
  *   @link: https://github.com/CaiJimmy/hugo-theme-stack
  */
  