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 contentLeftCO(){
      return new DivComponent(this.contentCO).addPredicateClassContains('eui-list-item__content-left');
    }
    get contentLeftIconCO() {
      return new DivComponent(this.contentLeftCO).addPredicateClassContains('eui-list-item__content-icon');
    }
    async hasContentIcon() {
      return await (await this.contentLeftIconCO.element()).isExisting();
    }
    get itemIconCO(){
      return new CoEuiIcon(this.contentLeftIconCO);
    }
    get contentLeftIconSvgCO() {
      return new DivComponent(this.contentLeftCO).addPredicateClassContains('eui-list-item__content-icon-svg');
    }
    async hasContentLeftIconSvg() {
      return await (await this.contentLeftIconSvgCO.element()).isExisting();
    }
    get itemLeftIconSvgCO(){
      return new CoEuiIcon(this.contentLeftIconCO);
    }
    get contentLeftTextCO() {
      return new DivComponent(this.contentCO).addPredicateClassContains('eui-list-item__content-text');
    }
    async hasContentLeftText() {
      return await (await this.contentLeftTextCO.element()).isExisting();
    }
    get itemLabelCO() {
      return new CoEuiLabel(this.contentLeftTextCO);
    }
    get contentRightCO(){
      return new DivComponent(this.contentCO).addPredicateClassContains('eui-list-item__content-right');
    }
    get toggleCO() {
      return new CoEuiButton(this.contentRightCO).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');
    }
    async hasItems(){
      return await ( await this.subListCO.element()).isExisting();
    }
    get listCO() {
      return new CoEuiList(this.subListCO);
    }

}


