import Component  from '../component.js'
import CoEuiChipListAppendContent from './eui-chip-list-append-content.js'
import CoEuiChipListChipContainer from './eui-chip-list-chip-container.js'
import CoEuiChipListCustom from './eui-chip-list-custom.js'
import CoEuiChipListExpandButton from './eui-chip-list-expand-button.js'
import DivComponent from '../div.js';

export default class CoEuiChipList extends Component {
    constructor(parent) {
      let selector = '*[self::eui-chip-list or self::div[@euiChipList] or self::ul[@euiChipList]]';
      super(parent, selector);
      // https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-chip-list/eui-chip-list.component.html?at=master
    }
    get containerCO() {
      return new DivComponent(this.currentPath).addPredicateClassContains('eui-chip-list-container');
    }
    get wrapperCO() {
      return new DivComponent(this.containerCO).addPredicateClassContains('eui-chip-list-wrapper');
    }
    get chipListListCO() {
      return new DivComponent(this.wrapperCO).addPredicateClassContains('eui-chip-list__list');
    }
    get chipListContainerCO() {
      return new CoEuiChipListChipContainer(this.chipListListCO);
    }
    get euiChipListAppendContentCO() {
      return new CoEuiChipListAppendContent(this.chipListListCO);
    }
    get expandButtonWrapperCO() {
      return new CoEuiChipListExpandButton(this.containerCO);
    }
    get gridContainer(){
      let path = 'div[contains(@class,"eui-chip-list-container")]';
      return this.currentPath + '/descendant::div[contains(@class,"eui-chip-list__group")]/ancestor::' + path;  
    }
    async isGrid() {
      return await (await $(this.gridContainer)).isExisting();
    }
    get gridWrapperCO() {
      return new DivComponent(this.wrapperCO).addPredicateClassContains('eui-chip-list-wrapper');
    }
    get groupCO() {
      return new DivComponent(this.gridWrapperCO).addPredicateClassContains('eui-chip-list__group');
    }
    get euiChipListCustomCO() {
      return new CoEuiChipListCustom(this.groupCO);
    }
    get euiChipListAppendContentGroupCO() {
      return new CoEuiChipListAppendContent(this.groupCO);
    }
    get expandButtonWrapperGridCO() {
      return new CoEuiChipListExpandButton(this.gridContainer);
    }
    get euiChipListAppendContentCustomCO() {
      return new CoEuiChipListAppendContent(this.currentPath);
    }

}


