import{Component}from"@theme/component";export class AnnouncementBar extends Component{#current=0;#interval=void 0;connectedCallback(){super.connectedCallback(),this.addEventListener("mouseenter",this.suspend),this.addEventListener("mouseleave",this.resume),document.addEventListener("visibilitychange",this.#handleVisibilityChange),this.play()}next(){this.current+=1}previous(){this.current-=1}play(interval=this.autoplayInterval){this.autoplay&&(this.paused=!1,this.#interval=setInterval(()=>{this.matches(":hover")||document.hidden||this.next()},interval))}pause(){this.paused=!0,this.suspend()}get paused(){return this.hasAttribute("paused")}set paused(paused){this.toggleAttribute("paused",paused)}suspend(){clearInterval(this.#interval),this.#interval=void 0}resume(){!this.autoplay||this.paused||(this.pause(),this.play())}get autoplay(){return!!this.autoplayInterval}get autoplayInterval(){const interval=this.getAttribute("autoplay"),value=parseInt(`${interval}`,10);if(!Number.isNaN(value))return value*1e3}get current(){return this.#current}set current(current){this.#current=current;let relativeIndex=current%(this.refs.slides??[]).length;relativeIndex<0&&(relativeIndex+=(this.refs.slides??[]).length),this.refs.slides?.forEach((slide,index)=>{slide.setAttribute("aria-hidden",`${index!==relativeIndex}`)})}#handleVisibilityChange=()=>document.hidden?this.pause():this.resume()}customElements.get("announcement-bar-component")||customElements.define("announcement-bar-component",AnnouncementBar);
//# sourceMappingURL=/s/files/1/0677/1399/0759/t/1/assets/announcement-bar.js.map?v=1783078800
