class AdvancedTabs{constructor(t){this.container=t,this.tabs=t.querySelectorAll(":scope > .dsm-advanced-tabs-wrapper > .dsm-tab"),this.tabsContent=t.querySelectorAll(":scope > .dsm-advanced-tabs-content-wrapper > .dsm-content-wrapper"),this.trigger=t.dataset.trigger,this.animationName=t.dataset.animation,this.innerAnimationName=t.dataset.inner_animation,this.deepLink="on"===t.dataset.deep_link,this.autoScrollMobile="on"===t.dataset.auto_scroll_mobile,this.anchorLink="on"===t.dataset.anchor_link,this.init()}init(){this.setupEventListeners(),this.handleInitialState()}setupEventListeners(){this.tabs.forEach(t=>{"click"===this.trigger?t.addEventListener("click",e=>this.handleEvent(e,t)):"hover"===this.trigger&&t.addEventListener("mouseover",e=>this.handleEvent(e,t)),t.addEventListener("keydown",e=>{"Enter"===e.key&&this.handleEvent(e,t)})})}handleInitialState(){let t=this.tabs[0];if(this.deepLink&&location.hash){let e=location.hash.substring(1),a=Array.from(this.tabs).find(t=>{let a=t.querySelector(".dsm-title");return a&&a.textContent.toLowerCase().replace(/\s+/g,"-")===e});a&&(t=a)}this.setActiveTab(t),this.anchorInitScroll()}handleEvent(t,e){t.stopPropagation(),this.setActiveTab(e),this.autoScrollOnMobile(e)}setActiveTab(t){let e=t.dataset.tabid.trim(),a=Array.from(this.tabsContent).find(t=>t.dataset.contentid.trim()===e);if(!a)return;this.tabs.forEach(t=>t.classList.remove("dsm-active",this.animationName)),this.tabsContent.forEach(t=>{t.classList.remove("dsm-active",this.animationName);let e=t.querySelector(".dsm-inner-content-wrapper");e&&e.classList.remove("animated",this.innerAnimationName)}),t.classList.add("dsm-active"),a.classList.add("dsm-active",this.animationName);let i=a.querySelector(".dsm-inner-content-wrapper");if(i&&i.classList.add("animated",this.innerAnimationName),this.deepLink){let n=t.querySelector(".dsm-title");if(n){let s=n.textContent.toLowerCase().replace(/\s+/g,"-");history.pushState(null,null,`#${s}`),this.container.classList.add("dsm-active-deep-link")}}}autoScrollOnMobile(t){let e=t.dataset.tabid.trim(),a=Array.from(this.tabsContent).find(t=>t.dataset.contentid.trim()===e);this.autoScrollMobile&&window.innerWidth<=768&&a.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})}anchorSmoothScroll(t){let e=t.replace(/-/g,""),a=document.querySelector(`.${e}`);this.anchorLink&&this.deepLink&&a&&a.scrollIntoView({behavior:"smooth",block:"start"})}findMatchingTab(t){let e=t.replace(/-/g,""),a=Array.from(this.tabs).find(t=>t.classList.contains(e));return a?(this.setActiveTab(a),a):null}anchorInitScroll(){let t=document.querySelectorAll("a");for(let e=0;e<t.length;e++){let a=t[e],i=a.getAttribute("href");i&&i.startsWith("#")&&i.length>=1&&a.addEventListener("click",t=>{let e=i.slice(1);this.anchorSmoothScroll(e),this.findMatchingTab(e)})}}}window.addEventListener("load",()=>{let t=e=>{new AdvancedTabs(e);let a=e.querySelectorAll(":scope .dsm-content-wrapper .dsm-advanced-tabs-container");a.forEach(e=>{t(e)})},e=document.querySelectorAll(".dsm-advanced-tabs-container:not(.dsm-content-wrapper .dsm-advanced-tabs-container)");e.forEach(e=>{t(e)}),jQuery(()=>{jQuery(".dsm-content p").each(function(){0===jQuery(this).html().replace(/\s|&nbsp;/g,"").length&&jQuery(this).remove()})})});