import Component  from '../component.js'
import CoEuiButton from './eui-button.js'
import CoEuiDropdown from './eui-dropdown.js'
import CoEuiDropdownContent from './eui-dropdown-content.js'
import CoEuiLabel from './eui-label.js'
import { elementAttributeContains } from '../../core/utils.js'
import CoEuiButtonsActionsButtons from './eui-buttons-actions-buttons.js'
import CoEuiButtonsLocalMenu from './eui-buttons-local-menu.js'
import CoEuiList from './eui-list.js'
import CoEuiIcon from './eui-icon.js'

export default class CoEuiButtons extends Component {
  constructor(parent) {
    let selector = 'eui-buttons';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-buttons/eui-buttons.component.html?at=refs%2Fheads%2Fsupport%2F13.x
  }
  get wrapper() {
    return this.currentPath + '//div[contains(@class, "eui-buttons-wrapper")]';
  }
  async isMobileOrTablet() {
    return await elementAttributeContains(this.wrapper, 'class', 'eui-buttons-wrapper--mobile');
  }
  get actionsContainer() {
    return this.wrapper + '//div[contains(@class, "eui-buttons__actions-container")]';
  }
  get euiButtonsActionsButtonsCO() {
    return new CoEuiButtonsActionsButtons(this.actionsContainer);
  }
  get euiButtonCO() {
    return new CoEuiButton(this.actionsContainer);
  }
  async isNotBookmarked() {
    return await elementAttributeContains(this.euiIconCO.currentPath, 'class', 'eui-icon-bookmark-o');
  }
  get euiIconCO() {
    return new CoEuiIcon(this.euiButtonCO);
  }
  get bookmarkSpan() {
    return this.euiButtonCO.currentPath + '/self::*[not(@euiIcon)]';;
  }
  get localMenu() {
    return this.actionsContainer + '//div[contains(@class, "eui-buttons__local-menu")]';
  }
  async isLocalMenuMobile() {
    return await elementAttributeContains(this.localMenu, 'class', 'eui-buttons__local-menu--mobile');
  }
  get euiDropdownCO() {
    return new CoEuiDropdown(this.localMenu);
  }
  get euiButtomCOinDropdown() {
    return new CoEuiButton(this.euiDropdownCO.currentPath);
  }
  get euiLabelCO() {
    return new CoEuiLabel(this.euiButtomCOinDropdown.currentPath);
  }
  get euiIconMoreVerticalCO() {
    return new CoEuiIcon(this.euiButtomCOinDropdown.currentPath).byAttributeContains('iconClass', 'eui-icon-more-vertical');
  }
  get euiDropdownContentCO() {
    return new CoEuiDropdownContent(this.euiDropdownCO.currentPath);
  }
  get euiButtonsActionsButtonsCOinDropdownContent() {
    return new CoEuiButtonsActionsButtons(this.euiDropdownContentCO.currentPath);
  }
  get euiButtonsLocalMenuCOinDropdownContent() {
    return new CoEuiButtonsLocalMenu(this.euiDropdownContentCO.currentPath);
  }
  get euiListCO() {
    return new CoEuiList(this.euiDropdownContentCO.currentPath).byAttributeContains('class', 'eui-buttons__local-menu-extras');
  }
  get listItemCO() {
    return this.euiListCO.euiListItemCO;
  }
  get colorInfoIconCO() {
    return new CoEuiIcon(this.listItemCO.currentPath).byAttributeContains('class', 'eui-u-color-info');
  }
  async isNotBookmarkedMenuItem() {
    return await elementAttributeContains(this.listItemCO.currentPath, 'class', 'eui-icon-bookmark-o');
  }
  get iconPrintCO() {
    return new CoEuiIcon(this.listItemCO.currentPath).byAttributeContains('class', 'eui-icon-print');
  }
  async isPrintable() {
    return await (await $(this.iconPrintCO.currentPath)).isExisting();
  }
  get euiLabelCOPrint() {
    return new CoEuiLabel(this.listItemCO.currentPath).byAttributeContains('class', 'eui-u-color-info');
  }
}


