import Component from '../../component.js'
import MatChipList from '../../material/mat-chip-list.js'
import EuiChipListChip from './eui-chip-list-chip.js'
import ButtonComponent from '../../button.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-next/src/lib/components/eui-chip-list/eui-chip-list.component.html?at=refs%2Fheads%2Fsupport%2Fdevelop-10.x
    }
    get container() {
      let path = '//div[contains(@class,"eui-chip-list-container")]';
      return this.currentPath + path;
    }
    get wrapper() {
      let path = '//div[contains(@class,"eui-chip-list-wrapper")]';
      return this.container + path;
    }
    get matChipListCO() {
      return new MatChipList(this.wrapper);
    }
    get euiChipListChipCO() {
      return new EuiChipListChip(this.matChipListCO);
    }
    get euiChipListAppendContent() {
      let path = '//euiChipListAppendContent';
      return this.matChipListCO.currentPath + path;
    }
    get expandButtonwrapper() {
      let path = '//div[contains(@class,"eui-chip-list__expand-button-wrapper")]';
      return this.container + path;
    }
    async hasExpandButton() {
      return await (await $(this.expandButtonwrapper)).isExisting();
    }
    get expandButton() {
      return new ButtonComponent(this.expandButtonwrapper).byAttributeContains('class','eui-chip-list__expand-button').currentPath;
    }
    get angelLeftIcon() {
      let path = '//span[contains(@iconClass,"eui-icon-angle-left")]';
      return this.expandButton + path;
    }
    get euiLabel() {
      let path = '//span[@euiLabel]';
      return this.expandButton + path;
    }
    async isMaxVisibleChipsOpened() {
      return await (await $(this.angelLeftIcon)).isExisting();
    }
    async hasLessLabel() {
      return await this.isMaxVisibleChipsOpened();
    }
    get angelRightIcon() {
      let path = '//span[contains(@iconClass,"eui-icon-angle-right")]';
      return this.expandButton + path;
    }
    async hasMoreLabel() {
      return !( await this.isMaxVisibleChipsOpened());
    }

}

