import CoEuiIconSvg from './eui-icon-svg.js';
import Component from '../component.js';
import CoEuiDropdown from './eui-dropdown.js';
import CoEuiLanguageSelectorMenuItem from './eui-language-selector-menu-item.js';
import SpanComponent from '../span.js';
import DivComponent from '../div.js';
import CoEuiButton from './eui-button.js';

export default class CoEuiLanguageSelector extends Component {
  constructor(parent) {
    let selector = 'eui-language-selector';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-language-selector/language-selector.component.html
  }
  get buttonCO() {
    return new CoEuiButton(this.currentPath).addPredicateClassContains('eui-language-selector__button');
  }
  get iconCO() {
    return new CoEuiIconSvg(this.buttonCO).addPredicateIconContains('eui-ecl-global');
  }
  get languageCodeCO() {
    return new SpanComponent(this.buttonCO).addPredicateClassContains('eui-language-selector__code');
  }

  get dropdownCO() {
    return new CoEuiDropdown(this.currentPath);
  }
  get dropdownButtonCO() {
    return new CoEuiButton(this.dropdownCO).addPredicateClassContains('eui-language-selector__button');
  }
  async hasLanguageSelector() {
    return await (await this.dropdownCO.element()).isExisting();
  }
  get dropdownButtonIconCO() {
    return new CoEuiIconSvg(this.dropdownButtonCO).addPredicateIconContains('eui-ecl-global');
  }
  get dropdownButtonLanguageCodeCO() {
    return new SpanComponent(this.dropdownButtonCO).addPredicateClassContains('eui-language-selector__code');
  }
  get dropdownContentCO() {
    return this.dropdownCO.dropdownContentCO;
  }
  get languageSelectorMenuCO() {
    return new DivComponent(this.dropdownContentCO).addPredicateClassContains('eui-language-selector-menu');
  }
  get languageSelectorItemCO() {
    return new CoEuiLanguageSelectorMenuItem(this.languageSelectorMenuCO);
  }
  async isShowDropDown() {
    return ! await (await this.dropdownCO.element()).isExisting();
  }
  get modalButtonCO(){
    return new CoEuiButton(this.currentPath).addPredicateClassContains('eui-language-selector__button');
  }
  async isShowModal(){
    return await (await this.modalButtonCO.element()).isExisting();
  }
  get iconModalCO() {
    return new CoEuiIconSvg( this.buttonModalCO).addPredicateIconContains('eui-ecl-global');
  }
  get languageCodeModalCO() {
    return new SpanComponent(this.buttonModalCO).addPredicateClassContains('eui-language-selector-button__language-code');
  }
}