import{Component}from"@theme/component";import{isMobileBreakpoint}from"@theme/utilities";class ShowMoreComponent extends Component{requiredRefs=["showMoreButton","showMoreItems","showMoreContent"];#expanded=!1;#disableOnDesktop=!1;#collapsedHeight=0;#disabledClass="hidden";get#currentBreakpoint(){return isMobileBreakpoint()?"MOBILE":"DESKTOP"}#animation;#animationSpeed=300;connectedCallback(){super.connectedCallback(),this.#updateBreakpointState()}#updateBreakpointState=()=>{this.#disableOnDesktop=this.dataset.disableOnDesktop==="true",this.#disabledClass=this.#disableOnDesktop?"mobile:hidden":"hidden"};#expand=()=>{const{showMoreItems,showMoreContent}=this.refs;this.#collapsedHeight=showMoreContent.offsetHeight;const startHeight=this.#collapsedHeight;return showMoreItems?.forEach(item=>item.classList.remove(this.#disabledClass)),{startHeight,endHeight:showMoreContent.scrollHeight}};#collapse=()=>{const{showMoreContent}=this.refs,startHeight=showMoreContent.offsetHeight,endHeight=this.#collapsedHeight;return{startHeight,endHeight}};#animateHeight=(startHeight,endHeight)=>{const{showMoreContent}=this.refs;showMoreContent.style.overflow="hidden",this.#animation?.cancel(),this.#animation=showMoreContent.animate({height:[`${startHeight}px`,`${endHeight}px`]},{duration:this.#animationSpeed,easing:"ease-in-out"}),this.#animation.onfinish=()=>this.#onAnimationFinish()};#onAnimationFinish(){const{showMoreContent,showMoreItems}=this.refs;this.#expanded&&showMoreItems.forEach(item=>item.classList.add(this.#disabledClass)),showMoreContent.style.removeProperty("height"),showMoreContent.style.overflow="",this.#expanded=!this.#expanded}toggle=event=>{if(event.preventDefault(),this.#updateBreakpointState(),this.#currentBreakpoint==="DESKTOP"&&this.#disableOnDesktop)return;const{startHeight,endHeight}=this.#expanded?this.#collapse():this.#expand();this.dataset.expanded=this.#expanded?"false":"true",this.refs.showMoreButton.setAttribute("aria-expanded",this.dataset.expanded),this.#animateHeight(startHeight,endHeight)}}customElements.get("show-more-component")||customElements.define("show-more-component",ShowMoreComponent);
//# sourceMappingURL=/s/files/1/0677/1399/0759/t/1/assets/show-more.js.map?v=1783078800
