import AComponent from '../a.js';
import Component from '../component.js';
import SpanComponent from '../span.js';
import UlComponent from '../ul.js';
import CoEuiIconSvg from './eui-icon-svg.js';
import CoEuiToolbarMenuItemSubChild from './eui-toolbar-menu-item-sub-child.js';

export default class CoEuiToolbarMenuItemChild extends Component {
  constructor(parent) {
    let selector = 'li[contains(@class, "child")]';
    super(parent, selector);
    //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 tabIndexLinkCO() {
    return new AComponent(this.currentPath).addSelectorPredicate('[not(@routerLink)]');
  }
  async tabIndexLinkIsDisabled() {
    return await elementAttributeContains(this.tabIndexLinkCO.currentPath, 'class', 'disabled');
  }
  get tabIndexLinkIconCO() {
    return new SpanComponent(this.tabIndexLinkCO).addSelectorPredicate('[contains(@class, "eui-toolbar-menu-item__icon")]');
  }
  async hasTabIndexLinkIcon() {
    return await (await this.tabIndexLinkIconCO.element()).isExisting();
  }
  get tabIndexLinkSvgIconCO() {
    return new CoEuiIconSvg(this.tabIndexLinkCO).addPredicateClassContains('eui-toolbar-menu-item__icon');
  }
  get tabIndexLinkLabelCO() {
    return new SpanComponent(this.tabIndexLinkCO).addPredicateClassContains('eui-toolbar-menu-item__label');
  }
  get routerLinkCO() {
    return new AComponent(this.currentPath).addSelectorPredicate('[@routerLink]');
  }
  async routerLinkIsDisabled() {
    return await elementAttributeContains(this.routerLinkCO.currentPath, 'class', 'disabled');
  }
  async hasSubLinkUrl() {
    return await (await this.routerLinkCO.element()).isExisting();
  }
  get routerLinkIconCO() {
    return new SpanComponent(this.routerLinkCO).addSelectorPredicate('[contains(@class, "eui-toolbar-menu-item__icon")]');
  }
  get routerLinkSvgIconCO() {
    return new CoEuiIconSvg(this.routerLinkCO).addPredicateClassContains('eui-toolbar-menu-item__icon');
  }
  get routerLinkLabelCO() {
    return new SpanComponent(this.routerLinkCO).addPredicateClassContains('eui-toolbar-menu-item__label');
  }
  get childrenUlShowCO() {
    return new UlComponent(this.currentPath).addPredicateClassContains('show');
  }
  get childrenCO() {
    return new CoEuiToolbarMenuItemSubChild(this.childrenUlShowCO);
  }
  async hasChildren() {
    return await (await this.childrenCO.element()).isExisting();
  }
}


