import Component from '../component.js'
import { elementAttributeContains } from '../../core/utils.js';
import DivComponent from '../div.js';
import CoEuiPageHeaderBody from './eui-page-header-body.js';
import CoEuiPageHeaderActionItems from './eui-page-header-action-items.js';
import CoEuiPageHeaderSubLabel from './eui-page-header-sub-label.js';
import ButtonComponent from '../button.js';
import SpanComponent from '../span.js';
import CoEuiIconSvg from './eui-icon-svg.js';

export default class CoEuiPageHeader extends Component {
  constructor(parent) {
    let selector = 'eui-page-header';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-page/components/eui-page-header/eui-page-header.component.html
  }
  get headerLabelCO() {
    return new DivComponent(this.currentPath).addPredicateClassContains('eui-common-header__label');
  }
  get headerLabelTextCO() {
    return new DivComponent(this.headerLabelCO).addPredicateClassContains('eui-common-header__label-text');
  }
  get headerActionCO() {
    return new DivComponent(this.headerLabelCO).addPredicateClassContains('"eui-common-header__actions');
  }
  get headerActionItemsCO() {
    return new CoEuiPageHeaderActionItems(this.headerActionCO);
  }
  get headerSubLabelDivCO() {
    return new DivComponent(this.currentPath).addPredicateClassContains('eui-common-header__sub-label');
  }
  get headerSubLabelTextCO() {
    return new DivComponent(this.headerSubLabelDivCO).addPredicateClassContains('eui-common-header__sub-label-text');
  }
  get commonHeaderSubLabelCO() {
    return new CoEuiPageHeaderSubLabel(this.currentPath);
  }
  async hasSubLabel() {
    return await (await this.headerSubLabelDivCO.element()).isExisting();
  }
  get headerBodyCO() {
    return new CoEuiPageHeaderBody(this.currentPath);
  }
  async isCollapsible() {
    return await (await this.headerBodyCO.element()).isExisting();
  }
  get expandTriggerCO() {
    return new DivComponent(this.currentPath).addPredicateClassContains('eui-button__expand-trigger');
  }
  async isCollapsed() {
    return await elementAttributeContains(this.expandTriggerCO.currentPath, 'class', 'eui-button__expand-trigger--collapsed');
  }
  get buttonCO() {
    return new ButtonComponent(this.expandTriggerCO).addPredicateClassContains('eui-button--expand-toggle');
  }
  get expandedLabelCO() {
    return new SpanComponent(this.buttonCO).addPredicateClassContains('eui-label');
  }
  get expandedIconCO() {
    return new CoEuiIconSvg(this.buttonCO);
  }
  async isExpanded() {
    return await elementAttributeContains(this.expandedIconCO.currentPath, 'icon', 'chevron-down');
  }
}


