import Plugin from 'src/plugin-system/plugin.class';

export default class BcAquaHeader extends Plugin {
    init() {
        this.registerEvents();
    }

    registerEvents() {
        const toggleBtn = this.el.querySelector('.header-actions-btn-toggle');
        const mainNav = this.el.querySelector('.main-navigation');

        if (toggleBtn && mainNav) {
            toggleBtn.addEventListener('click', () => {
                mainNav.classList.toggle('top-bar-is-open');
            });
        }
    }
}
// Get the target container
const bcMenuView = document.querySelector('.bc_menu_view');
 
document.querySelectorAll('.nav-item').forEach(item => {
  item.addEventListener('mouseenter', () => {
    const dropdown = item?.querySelector('.dropdown-menu');
    if (dropdown && bcMenuView) {
      // Make sure bc_menu_view is visible
      bcMenuView.style.display = '';
 
      // Move dropdown into bc_menu_view
      bcMenuView.appendChild(dropdown);
    }
  });
 
  item.addEventListener('mouseleave', () => {
    const dropdown = item?.querySelector('.dropdown-menu');
    if (dropdown && bcMenuView) {
      // Move dropdown back into original nav-item
      //item.appendChild(dropdown);
 
      // Empty the bc_menu_view
      bcMenuView.innerHTML = '';
 
      // Remove display:none (keep it visible)
      bcMenuView.style.display = '';
    }
  });
});
 

