import Component from '../component.js'
import { elementAttributeContains } from '../../core/utils.js'
import LiComponent from '../li.js';
import CoEuiMenuItemIconContent from './eui-menu-item-icon-content.js';
import CoEuiMenuItemLinkContent from './eui-menu-item-link-content.js';
import SpanComponent from '../span.js';
import AComponent from '../a.js';

export default class CoEuiMenuItem extends Component {
  constructor(parent) {
    let selector = 'eui-menu-item';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-menu/eui-menu-item.component.html
  }
  get categoryItemCO() {
    return new LiComponent(this.currentPath).addPredicateClassContains('eui-menu-item__category');
  }
  async iscategoryItem() {
    return await (await this.categoryItemCO.element()).isExisting();
  }
  async isDisabledCategoryItem() {
    return await elementAttributeContains(this.categoryItemCO.currentPath, 'class', 'eui-menu-item--disabled');
  }
  get categoryIconContentCO() {
    return new CoEuiMenuItemIconContent(this.categoryItemCO);
  }
  get categoryLabelCO() {
    return new SpanComponent(this.categoryItemCO).addPredicateClassContains('eui-menu-item__category-label');
  }
  get categoryItemLabelCO() {
    return new SpanComponent(this.categoryLabelCO).addPredicateClassContains('eui-menu-item__label');
  }
  get urlListItemCO() {
    return new LiComponent(this.currentPath).byChildSelector('a[@routerLink]');
  }
  async isUrlItem() {
    return await (await this.urlListItemCO.element()).isExisting();
  }
  async isUrlExpandedList() {
    return await elementAttributeContains(this.urlListItemCO.currentPath, 'class', 'eui-menu-item--expanded');
  }
  get urlLinkCO() {
    return new AComponent(this.urlListItemCO).addPredicateClassContains('eui-menu-item__link');
  }
  async isLinkDisabled() {
    return await elementAttributeContains(this.urlLinkCO.currentPath, 'class', 'eui-menu-item--disabled');
  }
  async isLinkActive() {
    return await elementAttributeContains(this.urlLinkCO.currentPath, 'class', 'eui-menu-item__link--active');
  }
  get urlLinkContentCO() {
    return new CoEuiMenuItemLinkContent(this.urlLinkCO);
  }
  get linkListItemCO() {
    return new LiComponent(this.currentPath).byChildSelector('a[@href]');
  }
  async isLinkItem() {
    return await (await this.linkListItemCO.element()).isExisting();
  }
  async isLinkExpandedList() {
    return await elementAttributeContains(this.linkListItemCO.currentPath, 'class', 'eui-menu-item--expanded');
  }
  get linkCO() {
    return new AComponent(this.linkListItemCO).addPredicateClassContains('eui-menu-item__link');
  }
  get linkContentCO() {
    return new CoEuiMenuItemLinkContent(this.linkCO);
  }
}


