import Component from '../../component.js'
import CoEuiDropdown from './eui-dropdown.js';
import CoEuiLanguageSelectorMenuItem from './eui-language-selector-menu-item.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/layout/eui-language-selector/language-selector.component.html?at=master
  }
  get dropdownCO() {
    return new CoEuiDropdown(this.currentPath);
  }
  async languageSelectorLink() {
    let path = '//a[contains(@class, "eui-language-selector-link")]';
    if (await this.isShowDropDown()) {
      return this.dropdownCO.currentPath + path;
    } else {
      return this.currentPath + path;
    }
  }
  async languageSelectorLinkIcon() {
    let path = '//span[contains(@class, "eui-language-selector-link__icon")]';
    return await this.languageSelectorLink() + path;
  }
  async languageSelectorLinkCode() {
    let path = '//span[contains(@class, "eui-language-selector-link__language-code")]';
    return await this.languageSelectorLink() + path;
  }
  get languageSelectorMenu() {
    let path = '//div[contains(@class, "eui-language-selector-menu")]';
    return this.dropdownCO.euiDropdownContent.currentPath + path;
  }
  get languageSelectorItem() {
    return new CoEuiLanguageSelectorMenuItem(this.languageSelectorMenu);
  }
  async isShowDropDown() {
    return await (await this.dropdownCO.element()).isExisting();
  }
  async isShowModal() {
    return ! await (await this.dropdownCO.element()).isExisting();
  }
}


