import Component  from '../component.js';
import CoEuiList from './eui-list.js';
import CoEuiButton from './eui-button.js';
import CoEuiIcon from './eui-icon.js';
import CoEuiLabel from './eui-label.js';
import CoEuiIconSvg from './eui-icon-svg.js';
import DivComponent from '../div.js';

export default class CoEuiListItem extends Component {
    constructor(parent) {
      let selector = '*[self::eui-list-item or @euilistitem]';
      super(parent, selector);
      //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-list/eui-list-item/eui-list-item.component.html?at=master
    }
    get containerCO() {
      return new DivComponent(this.currentPath).addPredicateClassContains('eui-list-item__container');
    }
    async hasSubmenu() {
      return await (await $(this.containerCO.currentPath + '/self::div[contains(@class, "eui-list-item--has-submenu")]')).isExisting();
    }
    //Content
    get contentCO() {
      return new DivComponent(this.containerCO).addPredicateClassContains('eui-list-item__content');
    }
    get contentIconCO() {
      return new DivComponent(this.contentCO).addPredicateClassContains('eui-list-item__content-icon');
    }
    async hasContentIcon() {
      return await (await this.contentIconCO.element()).isExisting();
    }
    get itemIconCO(){
      return new CoEuiIcon(this.contentIconCO);
    }
    get contentTextCO() {
      return new DivComponent(this.contentCO).addPredicateClassContains('eui-list-item__content-text');
    }
    async hasContentText() {
      return await (await this.contentTextCO.element()).isExisting();
    }
    get itemLabelCO() {
      return new CoEuiLabel(this.contentTextCO);
    }
    get toggleCO() {
      return new CoEuiButton(this.contentCO).addPredicateClassContains('eui-list-item__content-toggle');
    }
    async isCollapsible() {
      return await (await this.toggleCO.element()).isExisting();
    }
    async isCollapsed(){
      return !await (await $(this.toggleCO.currentPath + '/self::button[contains(@class, "eui-list-item__content-toggle--expanded")]')).isExisting();
    }
    get toggleIconCO(){
      return new CoEuiIconSvg(this.toggleCO);
    }
    get subListCO() {
      return new DivComponent(this.containerCO).addPredicateClassContains('eui-list-item__sub-list');
    }
    get listCO() {
      return new CoEuiList(this.subListCO);
    }

}


