import Component from '../component.js'
import DivComponent from '../div.js'
import SpanComponent from '../span.js'
import CoEuiAutocompleteOptionGroup from './eui-autocomplete-option-group.js'
import CoEuiAutocompleteOption from './eui-autocomplete-option.js'
import CoEuiIconSvg from './eui-icon-svg.js'

export default class CoEuiAutocompletePortalContent extends Component {
  constructor(parent) {
    let selector = 'div[contains(@class, "eui-autocomplete__panel")]';
    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 cdkViewport() {
    return this.currentPath + '//cdk-virtual-scroll-viewport';
  }
  get optionGroupCO() {
    return new CoEuiAutocompleteOptionGroup(this.cdkViewport);
  }
  async isGroupBy() {
    return await (await this.optionGroupCO.element()).isExisting();
  }
  get optionGroupLabelCO() {
    return new DivComponent(this.optionGroupCO).addPredicateClassContains('eui-autocomplete-option-group__label');
  }
  get optionGroupOptionsCO() {
    return new DivComponent(this.optionGroupCO).addPredicateClassContains('eui-autocomplete-option-group__options');
  }
  get optionCO() {
    return new CoEuiAutocompleteOption(this.optionGroupOptionsCO);
  }
  get optionIconCO() {
    return new SpanComponent(this.optionCO);
  }
  get optionIconSvgCO() {
    return new CoEuiIconSvg(this.optionCO);
  }
  get optionNotGroupedCO() {
    return new CoEuiAutocompleteOption(this.cdkViewport);
  }
  get optionNotGroupedIconCO() {
    return new SpanComponent(this.optionNotGroupedCO);
  }
  get optionNotGroupedIconSvgCO() {
    return new CoEuiIconSvg(this.optionNotGroupedCO);
  }
}


