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';
import DivComponent from '../div.js';
import CoEuiMenuItemEndContent from './eui-menu-item-end-content.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 contentCO() {
    return new LiComponent(this.currentPath).addPredicateClassContains('eui-menu-item__content');
  }
  async isDisabledItem() {
    return await elementAttributeContains(this.contentCO.currentPath, 'class', 'eui-menu-item--disabled');
  }
  async isLinkExpandedList() {
    return await elementAttributeContains(this.contentCO.currentPath, 'class', 'eui-menu-item--expanded');
  }
  get urlLinkCO() {
    return new AComponent(this.contentCO).addPredicateClassContains('eui-menu-item__link');
  }
  async isCategoryItem() {
    return await elementAttributeContains(this.urlLinkCO.currentPath, 'class', 'eui-menu-item__link-category');
  }
  async isUrlItem() {
    return await(await $(this.urlLinkCO.currentPath + '/self::*[@routerLink]')).isExisting();
  }
  async isLinkItem() {
    return await(await $(this.urlLinkCO.currentPath + '/self::*[@href]')).isExisting();
  }
  async hasSubItems() {
    return await elementAttributeContains(this.urlLinkCO.currentPath, 'class', 'eui-menu-item__link--has-sub');
  }
  async isLinkDisabled() {4
    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 startBlockCO(){
    return new DivComponent(this.urlLinkCO).addPredicateClassContains('eui-menu-item__link-start-block');
  }
  get categoryIconContentCO() {
    return new CoEuiMenuItemIconContent(this.startBlockCO);
  }
  get contentBlockCO(){
    return new DivComponent(this.urlLinkCO).addPredicateClassContains('eui-menu-item__link-content-block');
  }
  get labelContainerCO(){
    return new DivComponent(this.contentBlockCO).addPredicateClassContains('eui-menu-item__link-label-container');
  }
  get labelCategoryCO(){
    return new SpanComponent(this.labelContainerCO).addPredicateClassContains('eui-menu-item__link-label-category');
  }
  get endBlockCO(){
    return new DivComponent(this.urlLinkCO).addPredicateClassContains('eui-menu-item__link-end-block');
  }
  get itemEndContentCO() {
    return new CoEuiMenuItemEndContent(this.endBlockCO);
  }
  get linkContentCO() {
    return new CoEuiMenuItemLinkContent(this.urlLinkCO);
  }
}


