import { elementAttributeContains } from '../../core/utils.js';
import LiComponent from '../li.js';
import UlComponent from '../ul.js';
import CoEuiToolbarMenuItemChild from './eui-toolbar-menu-item-child.js';

export default class CoEuiToolbarMenuItem extends LiComponent {
  constructor(parent) {
    super(parent);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/layout/eui-toolbar/toolbar-menu/toolbar-menu.component.html
  }
  get tabIndexLink() {
    return this.currentPath + '//a[@tabindex]';
  }
  async tabIndexLinkIsDisabled() {
    return await elementAttributeContains(this.tabIndexLink, 'class', 'disabled');
  }
  get tabIndexLinkIcon() {
    return this.tabIndexLink + '//span[contains(@class, "eui-icon")]';
  }
  async noLinkUrl() {
    return await (await $(this.tabIndexLink)).isExisting();
  }
  get routerLink() {
    return this.currentPath + '//a[@routerLink]';
  }
  async routerLinkIsDisabled() {
    return await elementAttributeContains(this.routerLink, 'class', 'disabled');
  }
  get routerLinkIcon() {
    return this.routerLink + '//span[contains(@class, "eui-icon")]';
  }
  async hasLinkUrl() {
    return await (await $(this.routerLink)).isExisting();
  }
  get childrenUlShowCO() {
    return new UlComponent(this.currentPath).byAttributeContains("class", "show");
  }
  get children() {
    return new CoEuiToolbarMenuItemChild(this.childrenUlShowCO);
  }
  async hasChildren() {
    return await (await this.children.element()).isExisting();
  }
  async isSelected() {
    return await(await $(this.currentPath + '[contains(@routerLinkActive, "selected")]')).isExisting();
  }
}


