import Component  from '../component.js';
import DivComponent from '../div.js';
import CoEuiButton from './eui-button.js';
import CoEuiIconSvg from './eui-icon-svg.js';
import CoEuiLabel from './eui-label.js';

export default class CoEuiFieldset extends Component {
    constructor(parent) {
        let selector = 'eui-fieldset';
        super(parent, selector);
        //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-fieldset/eui-fieldset.component.html?at=master
    }
    get containerCO() {
      return new DivComponent(this.currentPath).addPredicateClassContains('eui-fieldset__container');
    }
    get headerCO() {
      return new DivComponent(this.containerCO).addPredicateClassContains('eui-fieldset__header');
    }
    async hasLabel() {
        return await (await this.headerCO.element()).isExisting();
    }
    get headerLabelCO() {
        return new DivComponent(this.headerCO).addPredicateClassContains('eui-fieldset__header-label');
    }
    async isLarge() {
      return await (await $(this.headerLabelCO.currentPath + '/self::*[contains(@class,"eui-fieldset__header-label--large")]')).isExisting();
    }
    get iconClass() {
        return this.headerLabelCO.currentPath + '//div[contains(@class,"eui-fieldset__header-icon") and contains(@class, "eui-icon")]';
    }
    async hasIconClass() {
        return await (await $(this.iconClass)).isExisting();
    }
    get iconSvgName() {
        return this.headerLabelCO.currentPath + '//div[contains(@class,"eui-fieldset__header-icon")] and not(contains(@class, "eui-icon"))]';
    }
    get euiIconSvgCO() {
        return new CoEuiIconSvg(this.iconSvgName);
    }
    async hasIconSvgName() {
        return await (await $(this.iconSvgName)).isExisting();
    }
    get defaultIconCO(){
        return new DivComponent(this.headerLabelCO).byChildSelector('eui-icon-svg');
    }
    get euiIconSvgInfoCO(){
        return new CoEuiIconSvg(this.defaultIconCO).addPredicateIconContains('eui-info');
    }
    async isInfoIcon() {
      return await (await this.euiIconSvgInfoCO.element()).isExisting();
    }
    get euiIconSvgSuccessCO(){
        return new CoEuiIconSvg(this.defaultIconCO).addPredicateClassContains('eui-ecl-check-filled');
    }
    async isSuccessIcon() {
      return await (await this.euiIconSvgSuccessCO.element()).isExisting();
    }
    get euiIconSvgWarningCO(){
        return new CoEuiIconSvg(this.defaultIconCO).addPredicateClassContains('eui-ecl-warning');
    }
    async isWarningIcon() {
      return await (await this.euiIconSvgWarningCO.element()).isExisting();
    }
    get euiIconSvgDangerCO(){
        return new CoEuiIconSvg(this.defaultIconCO).addPredicateClassContains('eui-ecl-error');
    }
    async isDangerIcon() {
      return await (await this.euiIconSvgDangerCO.element()).isExisting();
    }
    get labelCO() {
      return new CoEuiLabel(this.headerLabelCO);
    }
    get euiFieldsetLabelExtraContent() {
      return this.headerLabelCO.currentPath + '//euiFieldsetLabelExtraContent';
    }
    get headerRightContentCO() {
      return new DivComponent(this.headerCO).addPredicateClassContains('eui-fieldset__header-right-content');
    }
    async hasCustomLabelRightContent() {
        return await (await this.euiFieldsetLabelRightContent.element()).isExisting();
    }
    get euiFieldsetLabelRightContent() {
      return this.headerRightContentCO.currentPath + '//euiFieldsetLabelRightContent';
    }
    get expandToggleButtonCO() {
        return new CoEuiButton(this.headerRightContentCO).addPredicateClassContains('eui-fieldset__header-expand-toggle');
    }
    async isExpandable() {
        return await (await this.expandToggleButtonCO.element()).isExisting();
    }
    get forwardIconSvgCO() {
        return new CoEuiIconSvg(this.expandToggleButtonCO).addPredicateClassContains('eui-chevron-forward');
    }
    get contentCO() {
      return new DivComponent(this.containerCO).addPredicateClassContains('eui-fieldset__content');
    }
    async isExpanded() {
        return await (await this.contentCO.element()).isExisting();
    }
}


