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 CoEuiButtonsLocalMenu from './eui-buttons-local-menu.js'
import CoEuiList from './eui-list.js'
import CoEuiIconSvg from './eui-icon-svg.js'
import CoEuiButtonsActionsMenu from './eui-buttons-actions-content.js'
import DivComponent from '../div.js'
import SpanComponent from '../span.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
  }
  get wrapperCO() {
    return new DivComponent(this.currentPath).addPredicateClassContains('eui-buttons-wrapper');
  }
  async isMobileOrTablet() {
    return await elementAttributeContains(this.wrapperCO.currentPath, 'class', 'eui-buttons-wrapper--mobile');
  }
  get actionsContainerCO() {
    return new DivComponent(this.wrapperCO).addPredicateClassContains('eui-buttons__actions-container');
  }
  get euiButtonsActionsButtonsCO() {
    return new CoEuiButtonsActionsMenu(this.actionsContainerCO);
  }
  get bookmarkBtnCO() {
    return new CoEuiButton(this.actionsContainerCO).addSelectorPredicate('[@euiSecondary]');
  }
  async isBookmarkable() {
    return await (await this.bookmarkBtnCO.element()).isExisting();
  }
  get euiIconCO() {
    return new CoEuiIconSvg(this.bookmarkBtnCO).addPredicateIconContains('eui-bookmark');
  }
  async isNotBookmarked(){
    return await elementAttributeContains(this.euiIconCO.currentPath, 'icon', 'eui-bookmark-outline'); 
  }
  get bookmarkLabelCO() {
    return new SpanComponent(this.bookmarkBtnCO);
  }
  get localMenuCO() {
    return new DivComponent(this.actionsContainerCO).addPredicateClassContains('eui-buttons__local-menu');
  }
  async isLocalMenuMobile() {
    return await elementAttributeContains(this.localMenuCO.currentPath, 'class', 'eui-buttons__local-menu--mobile');
  }
  get euiDropdownCO() {
    return new CoEuiDropdown(this.localMenuCO);
  }
  get euiButtomCOinDropdown() {
    return new CoEuiButton(this.euiDropdownCO);
  }
  get euiLabelCO() {
    return new CoEuiLabel(this.euiButtomCOinDropdown);
  }
  async hasLocalMenuLabel() {
    return await (await this.euiLabelCO.element()).isExisting();
  }
  get euiIconMoreVerticalCO() {
    return new CoEuiIconSvg(this.euiButtomCOinDropdown).addPredicateIconContains('eui-ellipsis-vertical');
  }
  get euiDropdownContentCO() {
    return new CoEuiDropdownContent(this.euiDropdownCO);
  }
  get euiButtonsActionsButtonsCOinDropdownContentCO() {
    return new CoEuiButtonsActionsMenu(this.euiDropdownContentCO);
  }
  get euiButtonsLocalMenuCOinDropdownContentCO() {
    return new CoEuiButtonsLocalMenu(this.euiDropdownContentCO);
  }
  get euiListCO() {
    return new CoEuiList(this.euiDropdownContentCO).addPredicateClassContains('eui-buttons__local-menu-extras');
  }
  get listItemCO() {
    return this.euiListCO.euiListItemCO;
  }
  get euiIconSvgExtraMenuCO() {
    return new CoEuiIconSvg(this.listItemCO).addPredicateIconContains('eui-bookmark');
  }
  async isNotBookmarkedExtraMenu() {
    return await (await this.notBookmarkedCO.element()).isExisting();
  }
  get notBookmarkedCO() {
    return new CoEuiIconSvg(this.listItemCO).addPredicateIconContains('eui-bookmark');
  }
  get bookmarkLabelExtraMenuCO() {
    return new SpanComponent(this.listItemCO);
  }
}


