import Component  from '../component.js'
import CoEuiButton from './eui-button.js'
import ButtonComponent from '../button.js'
import CoEuiDropdownContent from './eui-dropdown-content.js'
import CdkOverlayContainer from '../cdk-overlay-container.js'
import MatMenu from '../material/mat-menu.js'

export default class CoEuiDropdown extends Component {
    overlayContainer;
    constructor(parent) {
      let selector = 'eui-dropdown';
      super(parent, selector);
      this.overlayContainer = new CdkOverlayContainer('//body');
      //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-dropdown/eui-dropdown.component.html?at=support/13.x
    }
    get matMenuTrigger() {
      return this.currentPath +  '//div[contains(@class, "mat-menu-trigger")]';
    }
    // not in html temlate eui button
    get euiButtonCO() {
      return new CoEuiButton(this.matMenuTrigger);
    }
    // Mat section
    get matMenuCO() {
      return new MatMenu(this.overlayContainer.overlayPane);
    }
    get matContentWrapper() {
      return this.matMenuCO.currentPath + '//div[contains(@class, "eui-dropdown-content-wrapper")]';
    }
    async euiEnabled() {
      return await (await $(this.matContentWrapper)).isExisting();
    }
    get euiDropdownContentCO() {
      return new CoEuiDropdownContent(this.matContentWrapper);
    }
    // not in html temlate
    matDropdownItemByLabel(label) {
    return new ButtonComponent(this.euiDropdownContentCO).byAttributeContainsAndTextContains('class', 'eui-list-item',label);
  }
}


