import Component  from '../component.js'
import CoEuiIcon from './eui-icon.js'
import { elementAttributeContains } from '../../core/utils.js'

export default class CoEuiButton extends Component {
    constructor(parent) {
      let selector = '*[self::a[@euibutton] or self::button[@euibutton]]';
      super(parent, selector);
      //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-button/eui-button.component.html
    }
    get container() {
      let path = '//span[contains(@class, "eui-button__container")]';
      return this.currentPath + path;
    }
    get loadingIcon() {
      let path = '//span[contains(@class, "eui-button__loading-icon")]';
      return this.container + path;
    }
    async isLoading() {
      return await (await $(this.loadingIcon)).isExisting();
    }
    get euiIconCO() {
      return new CoEuiIcon(this.loadingIcon);
    }
    async isBasic() {
      return await elementAttributeContains(this.currentPath, 'class', 'eui-button--basic');
    }
    async isBlock() {
      return await elementAttributeContains(this.currentPath, 'class', 'eui-button--block');
    }
    async isRaised() {
      return await elementAttributeContains(this.currentPath, 'class', 'eui-button--loading');
    }
    async isIconOnly() {
      return await elementAttributeContains(this.currentPath, 'class', 'eui-button--icon-only');
    }
    async isLineWrap() {
      return await elementAttributeContains(this.currentPath, 'class', 'eui-button--line-wrap');
    }
}


