import Component from '../component.js'
import CoEuiChipList from './eui-chip-list.js'
import CoEuiChipListAppendContent from './eui-chip-list-append-content.js'
import DivComponent from '../div.js';
import CoEuiAutocompleteControl from './eui-autocomplete-control.js';
import CoEuiAutocompletePortalContent from './eui-autocomplete-portal-content.js';

export default class CoEuiAutocomplete extends Component {
  constructor(parent) {
    let selector = '*[self::eui-autocomplete or input[@euiAutocomplete]]';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-autocomplete/eui-autocomplete.component.html
  }
  get wrapperCO() {
    return new DivComponent(this.currentPath).addPredicateClassContains('eui-autocomplete__wrapper');
  }
  get controlBottomCO() {
    return new CoEuiAutocompleteControl(this.wrapperCO);
  }
  async chipsPositionIsBottom() {
    return await (await this.controlBottomCO.element()).isExisting();
  }
  get chipListCO() {
    return new CoEuiChipList(this.wrapperCO);
  }
  async hasChips() {
    return await (await this.chipListCO.element()).isExisting();
  }
  get chipListAppendContentCO() {
    return new CoEuiChipListAppendContent(this.chipListCO);
  }
  get fieldWrapperInsideCO() {
    return new CoEuiAutocompleteControl(this.chipListAppendContentCO);
  }
  async chipsPositionIsInside() {
    return await (await this.fieldWrapperInsideCO.element()).isExisting();
  }
  get fieldWrapperTopCO() {
    return new CoEuiAutocompleteControl(this.wrapperCO);
  }
  get portalContentCO() {
    return new CoEuiAutocompletePortalContent(this.currentPath);
  }
  async chipsPositionIsTop() {
    return await (await this.fieldWrapperTopCO.element()).isExisting();
  }
  async isChipsDragAndDrop() {
    return await (await $(this.currentPath + '/self::*[@isChipsDragAndDrop]')).isExisting();
  }
  async isItemsSorted() {
    return await (await $(this.currentPath + '/self::*[@isItemsSorted]')).isExisting();
  }
  async isChipsSorted() {
    return await (await $(this.currentPath + '/self::*[@isChipsSorted]')).isExisting();
  }
  async isChipsRemovable() {
    return await (await $(this.currentPath + '/self::*[@isChipsRemovable]')).isExisting();
  }
  async isMaxVisibleChipsOpened() {
    return await (await $(this.currentPath + '/self::*[@isMaxVisibleChipsOpened]')).isExisting();
  }
  async addOnBlur() {
    return await (await $(this.currentPath + '/self::*[@addOnBlur]')).isExisting();
  }
  async isFreeValueAllowed() {
    return await (await $(this.currentPath + '/self::*[@isFreeValueAllowed]')).isExisting();
  }
  async isDuplicateValueAllowed() {
    return await (await $(this.currentPath + '/self::*[@isDuplicateValueAllowed]')).isExisting();
  }
}


