import Component from '../component.js'
import CoEuiButton from './eui-button.js'
import CoEuiOverlay from './eui-overlay.js';
import CoEuiIconSvg from './eui-icon-svg.js';
import CoEuiInputGroup from './eui-input-group.js';
import CoEuiInputText from './eui-input-text.js';
import DivComponent from '../div.js';

export default class CoEuiSearch extends Component {
  constructor(parent) {
    let selector = 'eui-search';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/layout/eui-search/search.component.html
  }
  get euiIconSearchCO() {
    return new CoEuiIconSvg(this.currentPath).byAttributeContains('icon', 'eui-search');
  }
  get euiOverlayCO() {
    return new CoEuiOverlay(this.currentPath);
  }
  async isOverlayActive() {
    return await (await $(this.euiOverlayCO.currentPath + '/self::*[@isActive="isActive"]')).isExisting();
  }
  get euiInputGroupCO() {
    return new CoEuiInputGroup(this.euiOverlayCO.euiOverlayHeaderCO);
  }
  get inputAddonCO() {
    return new DivComponent(this.euiInputGroupCO).addPredicateClassContains('eui-input-group-addon');
  }
  get euiButtonAddonItemCO() {
    return new CoEuiButton(this.inputAddonCO).byChildSelector('eui-icon-svg[contains(@icon, "eui-arrow-left")]');
  }
  get euiIconArrowLeftCO() {
    return new CoEuiIconSvg(this.euiButtonAddonItemCO).addPredicateIconContains('eui-arrow-left');
  }
  get searchInputCO() {
    return new CoEuiInputText(this.inputAddonCO);
  }
  get euiButtonSearchCO() {
    return new CoEuiButton(this.inputAddonCO).byChildSelector('eui-icon-svg[contains(@icon, "eui-search")]');;
  }
  get euiIconSearchAddonCO() {
    return new CoEuiIconSvg(this.euiButtonSearchCO).addPredicateIconContains('eui-search');
  }
  get euiOverlayBodyCO() {
    return this.euiOverlayCO.euiOverlayBodyCO;
  }
}


