!function(e,t){"use strict";const r="spb-marquee-styles";let i=!1,a=new Set,n=0;function s(e){return e?"string"==typeof e?Array.from(t.querySelectorAll(e)):e instanceof Element?[e]:"number"==typeof e.length?Array.from(e):[]:[]}function o(e,t){const r=parseInt(e,10);return Number.isFinite(r)&&r>0?r:t}function d(e,t){const r=parseFloat(e);return Number.isFinite(r)?r:t}function u(e){return{duplicates:o(e.getAttribute("data-duplicates"),2),pauseOnHover:"true"===e.getAttribute("data-pause-on-hover"),gap:d(e.getAttribute("data-gap"),0),direction:"right"===e.getAttribute("data-direction")?"right":"left",speed:d(e.getAttribute("data-speed"),50),isFullContainer:"true"===e.getAttribute("data-is-full-container"),fullContainerWidth:d(e.getAttribute("data-full-container-width"),100)}}function l(e,t){if(e&&1===e.nodeType&&(e.matches&&e.matches(".marquee[data-pause-on-hover]")&&t.add(e),e.querySelectorAll))for(const r of e.querySelectorAll(".marquee[data-pause-on-hover]"))t.add(r)}function c(){if(n=0,a.size){for(const e of a)p.initNode(e);a.clear()}}class p{constructor(e={}){this.element=e.element,this.duplicates=o(e.duplicates,2),this.gap=d(e.gap,0),this.direction="right"===e.direction?"right":"left",this.speed=d(e.speed,50),this.isFullContainer=!!e.isFullContainer,this.fullContainerWidth=d(e.fullContainerWidth,100),this.pauseOnHover=!!e.pauseOnHover,this.nodes=s(this.element),this.instances=[],this.boundResize=this.onResize.bind(this)}init(){if(this.nodes.length){!function(){if(t.getElementById(r))return;const e=t.createElement("style");e.id=r,e.type="text/css",e.textContent=[".marquee { display: inline-flex; overflow: hidden; max-width: 100%; }",'.marquee[data-pause-on-hover="true"]:hover .marquee-track { animation-play-state: paused; }',".marquee.marquee--full { display: block; }",".marquee-track { display: inline-flex; flex-wrap: nowrap; align-items: center; will-change: transform; animation-name: spb-marquee-scroll; animation-timing-function: linear; animation-iteration-count: infinite; animation-duration: var(--marquee-duration, 10s); animation-direction: var(--marquee-direction, normal); gap: var(--marquee-gap, 0px); }",".marquee-set { display: inline-flex; align-items: center; flex-wrap: nowrap; gap: var(--marquee-gap, 0px); }",".marquee__item { flex: 0 0 auto; white-space: nowrap; }","@keyframes spb-marquee-scroll { from { transform: translateX(0); } to { transform: translateX(calc(-1 * var(--marquee-shift, 0px))); } }"].join(""),t.head.appendChild(e)}();for(const e of this.nodes)this.setupNode(e);e.addEventListener("resize",this.boundResize)}}setupNode(e){if(!e||"true"===e.getAttribute("data-marquee-ready"))return;const r=Array.from(e.children);if(!r.length)return;e.classList.add("marquee"),e.setAttribute("data-pause-on-hover",this.pauseOnHover?"true":"false"),e.style.setProperty("--marquee-gap",`${this.gap}px`),e.style.setProperty("--marquee-direction","right"===this.direction?"reverse":"normal"),this.isFullContainer?(e.classList.add("marquee--full"),e.style.setProperty("display","block"),e.style.setProperty("width",`${this.fullContainerWidth}%`),e.style.setProperty("box-sizing","border-box")):(e.classList.remove("marquee--full"),e.style.removeProperty("width"),e.style.setProperty("display","inline-flex"));const i=t.createElement("span");i.className="marquee-track";const a=t.createElement("span");a.className="marquee-set";for(const e of r)a.appendChild(e);i.appendChild(a);for(let e=0;e<this.duplicates;e++){const e=a.cloneNode(!0);e.setAttribute("aria-hidden","true"),i.appendChild(e)}e.replaceChildren(i),e.setAttribute("data-marquee-ready","true");const n={container:e,baseSet:a};this.instances.push(n),this.applyMetrics(n)}applyMetrics(e){if(!e||!e.baseSet||!e.container)return;const t=e.baseSet.getBoundingClientRect().width;if(!t)return;const r=t+this.gap,i=r/Math.max(this.speed,1);e.container.style.setProperty("--marquee-shift",`${r}px`),e.container.style.setProperty("--marquee-duration",`${Math.max(i,1)}s`)}onResize(){for(const e of this.instances)this.applyMetrics(e)}static initNode(e){if(!e||"true"===e.getAttribute("data-marquee-ready"))return;if(!e.hasAttribute("data-pause-on-hover"))return;new p({element:e,...u(e)}).init()}static initNodes(e){for(const t of s(e))p.initNode(t)}static observeEditor(){if(i)return;i=!0;const r=()=>{if(!t.body)return;new MutationObserver((t=>{const r=new Set;for(const e of t)if(e.addedNodes&&e.addedNodes.length)for(const t of e.addedNodes)l(t,r);r.size&&function(t){let r=!1;for(const e of t)e&&!a.has(e)&&(a.add(e),r=!0);r&&!n&&(n=e.requestAnimationFrame(c))}(r)})).observe(t.body,{childList:!0,subtree:!0})};"loading"===t.readyState?t.addEventListener("DOMContentLoaded",r,{once:!0}):r()}}e.addEventListener("DOMContentLoaded",(function(){p.observeEditor()})),e.Marquee=p}(window,document);