(function(m){"use strict";var _=Object.defineProperty,$=Object.defineProperties,P=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,G=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable,y=(t,e,r)=>e in t?_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,d=(t,e)=>{for(var r in e||(e={}))G.call(e,r)&&y(t,r,e[r]);if(p)for(var r of p(e))C.call(e,r)&&y(t,r,e[r]);return t},b=(t,e)=>$(t,P(e));const w=(t="always")=>({playMode:t,optimizeSeo:!0,createContainers:!0,hideOverflow:!1,timing:t==="always"?{duration:2*1e3,iterations:1/0}:{duration:250,iterations:1},glitchTimeSpan:t==="always"?{start:.5,end:.7}:{start:0,end:1},shake:{velocity:15,amplitudeX:.2,amplitudeY:.2},slice:t==="click"?{count:15,velocity:20,minHeight:.02,maxHeight:.15,hueRotate:!0,cssFilters:""}:{count:6,velocity:15,minHeight:.02,maxHeight:.15,hueRotate:!0,cssFilters:""},pulse:!1}),v=(t,e)=>{if(!t.glitchTimeSpan)return 1;const r=t.glitchTimeSpan.start,n=t.glitchTimeSpan.end;if(en)return 0;const a=r+(n-r)/2;return e(Math.random()-.5)*2*v(t,e),M=({minHeight:t,maxHeight:e,minWidth:r,maxWidth:n})=>{const a=Math.floor(Math.random()*((e-t)*100+1))+t*100,s=Math.floor(Math.random()*((n-r)*100+1))+r*100,i=Math.floor(Math.random()*(100-a)),l=Math.floor(Math.random()*(100-s)),h=`${l+s}% ${i}%`,c=`${l+s}% ${i+a}%`,o=`${l}% ${i+a}%`,f=`${l}% ${i}%`;return`polygon(${h},${c},${o},${f})`},A=t=>{const e=Math.floor(t.slice.velocity*t.timing.duration/1e3)+1,r=[];for(let n=0;nt.pulse?{steps:[{transform:"scale(1)",opacity:"1"},{transform:`scale(${t.pulse.scale})`,opacity:"0"}],timing:b(d({},t.timing),{delay:(t.glitchTimeSpan?t.glitchTimeSpan.start:0)*t.timing.duration,easing:"ease-in-out"})}:null,L=t=>{if(!t.shake)return{steps:[],timing:{}};const e=Math.floor(t.shake.velocity*t.timing.duration/1e3)+1,r=[];for(let n=0;n[L(t),O(t),...Array.from({length:t.slice.count}).map(()=>A(t))].filter(e=>e!==null),g=(...t)=>{const e=r=>r&&typeof r=="object";return t.reduce((r,n)=>(Object.keys(n).forEach(a=>{e(r[a])&&e(n[a])?r[a]=g(r[a],n[a]):n[a]!==void 0&&(r[a]=n[a])}),r),{})},H=(t,e)=>{var r,n;if(!e.createContainers)return{container:t,layersContainer:t,glitched:t.firstElementChild};if(!t.dataset.glitched){const i=document.createElement("div"),l=document.createElement("div");return getComputedStyle(t).getPropertyValue("display").match(/^inline/)&&(l.style.display="inline-block"),l.appendChild(i),(r=t.parentElement)==null||r.insertBefore(l,t),i.prepend(t),{container:l,layersContainer:i,glitched:t}}const a=t.parentElement,s=(n=t.parentElement)==null?void 0:n.parentElement;for(;a.children.length>1;)a.removeChild(a.children[1]);return a.firstElementChild.getAnimations().forEach(i=>i.cancel()),{container:s,layersContainer:a,glitched:t}},x=(t,e,r)=>{const{glitched:n,container:a,layersContainer:s}=H(t,r);s.style.display="grid",r.hideOverflow&&(a.style.overflow="hidden"),r.html&&(n.innerHTML=r.html),n.style.gridArea="1/1/-1/-1";const i=n.cloneNode(!0);i.dataset.islayer="true",i.style.gridArea="1/1/-1/-1",i.style.userSelect="none",i.style.pointerEvents="none",i.style.opacity="0";for(let c=0;c{e.forEach((c,o)=>{s.children[o].animate(c.steps,c.timing)})},h=()=>{e.forEach((c,o)=>{s.children[o].getAnimations().forEach(f=>{f.cancel()})})};switch(a.onmouseenter=null,a.onmouseleave=null,a.onclick=null,r.playMode){case"always":l();break;case"hover":a.onmouseenter=l,a.onmouseleave=h;break;case"click":a.onclick=()=>{h(),l()};break}return t.dataset.glitched="1",{container:a,startGlitch:l,stopGlitch:h}},R={glitch:(t=".powerglitch",e={})=>{const r=g(w(e.playMode),e);if(r.optimizeSeo&&/google|bing|baidu|yandex|slurp|bot/i.exec(navigator.userAgent))return{containers:[],startGlitch:()=>{console.warn("PowerGlitch disabled")},stopGlitch:()=>{console.warn("PowerGlitch disabled")}};let n=[];typeof t=="string"?n=Array.from(document.querySelectorAll(t)):t instanceof NodeList?n=Array.from(t):Array.isArray(t)?n=t:t instanceof HTMLElement&&(n=[t]);const a=E(r),s=n.filter(i=>!i.dataset.islayer).map(i=>x(i,a,r));return{containers:s.map(i=>i.container),startGlitch:()=>s.forEach(i=>i.startGlitch()),stopGlitch:()=>s.forEach(i=>i.stopGlitch())}},generateLayers:E,getDefaultOptions:w};m.PowerGlitch=R,m.mergeOptions=g})(this.window=this.window||{});