import Component  from '../component.js'
import CoEuiIcon from './eui-icon.js'
import CoEuiButton from './eui-button.js'
import CoEuiOverlay from './eui-overlay.js';
import InputComponent from '../input.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?at=support%2F13.x
  }
  get euiIconSearchCO() {
    return new CoEuiIcon(this.currentPath).byAttributeContains('iconClass', 'eui-icon-search-m');
  }
  get euiOverlayCO() {
    return new CoEuiOverlay(this.currentPath);
  }
  async isOverlayActive() {
    return await (await $(this.euiOverlayCO.currentPath + '/self::*[@isActive="isActive"]')).isExisting();
  }
  get inputAddon() {
    let path = '//div[contains(@class,"eui-u-input-addon")]';
    return this.euiOverlayCO.euiOverlayHeaderCO.currentPath + path;
  }
  get euiButtonAddonItemCO() {
    return new CoEuiButton(this.inputAddon).byAttributeContains('styleClass', 'eui-u-input-addon__item');
  }
  get euiIconArrowLeftCO() {
    return new CoEuiIcon(this.euiButtonAddonItemCO.currentPath).byAttributeContains('iconClass', 'eui-icon-arrow-left');
  }
  get searchInputCO() {
    return new InputComponent(this.inputAddon).byAttributeContains('class', 'eui-u-input-addon__input');
  }
  get euiButtonOutlineCO() {
    return new CoEuiButton(this.inputAddon + '/self::button[@euiOutline]');
  }
  get euiIconSearchAddonCO() {
    return new CoEuiIcon(this.euiButtonOutlineCO).byAttributeContains('iconClass', 'eui-icon-search-m');
  }
  get lipsum() {
    let path = '//div[@id="lipsum"]';
    return this.euiOverlayCO.euiOverlayBodyCO.currentPath + path;
  }
}


