import Component  from '../component.js'
import { elementAttributeContains } from '../../core/utils.js'
import ButtonComponent from '../button.js'

export default class CoEuiExpandContent extends Component {
  constructor(parent) {
    let selector = 'eui-expand-content';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/shared/eui-expand-content/eui-expand-content.component.html?at=support%2F13.x
  }
  get body() {
    return this.currentPath + '//div[contains(@class,"eui-expand-content__body")]';
  }
  get expandTriggerButton() {
    return this.currentPath + '//div[contains(@class,"eui-button__expand-trigger")]';
  }
  async isCollapsed() {
    return await elementAttributeContains(this.expandTriggerButton, 'class', 'eui-button__expand-trigger--collapsed');
  }
  get expandButtonCo() {
    return new ButtonComponent(this.expandTriggerButton).byAttributeEquals('aria-label', 'Expand');
  }
  get expandLabel() {
    return this.expandButtonCo.currentPath + '//span[contains(@class, "eui-label") and contains(@class, "eui-u-color-grey-dark")]';
  }
  async hasExpandLabel() {
    return await (await $(this.expandLabel)).isExisting();
  }
  get expandIcon() {
    return this.expandButtonCo.currentPath + '//span[contains(@class, "eui-icon-angle-down")]';
  }
  get collapseButtonCo() {
    return new ButtonComponent(this.expandTriggerButton).byAttributeEquals('aria-label', 'Collapse');
  }
  get collapseLabel() {
    return this.collapseButtonCo.currentPath + '//span[contains(@class, "eui-label") and contains(@class, "eui-u-color-grey-dark")]';
  }
  async hasCollapseLabel() {
    return await (await $(this.collapseLabel)).isExisting();
  }
  get collapseIcon() {
    return this.collapseButtonCo.currentPath + '//span[contains(@class, "eui-icon-angle-up")]';
  }
}


