import Component from '../component.js'
import CoEuiChipList from './eui-chip-list.js'
import CoEuiChipListAppendContent from './eui-chip-list-append-content.js'
import CoEuiAutocompleteFieldWrapper from './eui-autocomplete-field-wrapper.js'
import DivComponent from '../div.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 containerCO() {
    return new DivComponent(this.currentPath).addPredicateClassContains('eui-autocomplete__container');
  }
  get wrapperCO() {
    return new DivComponent(this.containerCO).addPredicateClassContains('eui-autocomplete__wrapper');
  }
  get fieldWrapperBottomCO() {
    return new CoEuiAutocompleteFieldWrapper(this.wrapperCO);
  }
  async chipsPositionIsBottom() {
    return await (await this.fieldWrapperBottomCO.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 CoEuiAutocompleteFieldWrapper(this.chipListAppendContentCO);
  }
  async chipsPositionIsInside() {
    return await (await this.fieldWrapperInsideCO.element()).isExisting();
  }
  get fieldWrapperTopCO() {
    return new CoEuiAutocompleteFieldWrapper(this.wrapperCO);
  }
  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();
  }
}


