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

export default class CoEuiDialogContainer extends Component {
  constructor(parent) {
    let selector = 'eui-dialog-container';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-dialog/container/eui-dialog-container.component.html?at=master
  }
  get containerCO() {
    return new DivComponent(this.currentPath).addPredicateClassContains('eui-dialog');
  }
  async isDraggable() {
    return await (await $(this.containerCO.currentPath + '/self::div[contains(@class, "eui-dialog--draggable")]')).isExisting();
  }
  async isMessageBox() {
    return await (await $(this.containerCO.currentPath + '/self::div[contains(@class, "eui-dialog--message-box")]')).isExisting();
  }
  async hasNoBodyPadding() {
    return await (await $(this.containerCO.currentPath + '/self::div[contains(@class, "eui-dialog--no-padding")]')).isExisting();
  }
  async hasMobileCustomSize() {
    return await (await $(this.containerCO.currentPath + '/self::div[contains(@class, "eui-dialog--custom-size")]')).isExisting();
  }
  get contentCO() {
    return new DivComponent(this.containerCO).addPredicateClassContains('eui-dialog__content');
  }
  get headerCO() {
    return new DivComponent(this.contentCO).addPredicateClassContains('eui-dialog__header');
  }
  get iconStateCO() {
    return new CoEuiIconState(this.headerCO);
  }
  async isMessageBox() {
    return await (await this.iconStateCO.element()).isExisting();
  }
  get headerTitle() {
    return this.headerCO.currentPath + '//h5[contains(@class, "eui-dialog__header-title")]';
  }
  async hasHeaderTilte() {
    return await (await $(this.headerTitle)).isExisting();
  }
  get closeContainerCO() {
    return new DivComponent(this.headerCO).addPredicateClassContains('eui-dialog__header-close-container');
  }
  get closeButtonCO() {
    return new CoEuiButton(this.closeContainerCO);
  }
  async hasCloseButton() {
    return await (await $(this.closeButtonCO.currentPath)).isExisting();
  }
  get closeIconCO() {
    return new CoEuiIconSvg(this.closeButtonCO).addPredicateIconContains('close');
  }
  async isHeaderTemplatePortal() {
    return await (await $(this.headerCO.currentPath + '//*[@cdkPortalOutlet="dialogContainerConfig.header"]')).isExisting();
  }
  async isHeaderComponentPortal() {
    return await (await $(this.headerCO.currentPath + '//*[@cdkPortalOutlet="headerComponentPortal"]')).isExisting();
  }
  get bodyCO() {
    return new DivComponent(this.contentCO).addPredicateClassContains('eui-dialog__body');
  }
  get bodyContentCO() {
    return new DivComponent(this.bodyCO).addPredicateAttributeContains('id', 'containerConfigId');
  }
  get bodyContenTemplateCO() {
    return new DivComponent(this.bodyCO).addPredicateAttributeContains('id', 'bodyTemplatePortalId');
  }
  get bodyComponentPortalCO() {
    return new DivComponent(this.bodyCO).addPredicateAttributeContains('id', 'bodyComponentPortalId');
  }
  async isBodyTemplatePortal() {
    return await (await this.bodyContenTemplateCO.element()).isExisting();
  }
  async isBodyTemplatePortal() {
    return await (await this.bodyComponentPortalCO.element()).isExisting();
  }
  get footerCO() {
    return new DivComponent(this.contentCO).addPredicateClassContains('eui-dialog__footer');
  }
  async hasFooter() {
    return await (await this.footerCO.element()).isExisting();
  }
  get footerContentCO() {
    return new DivComponent(this.footerCO).addPredicateClassContains('eui-dialog__footer-content');
  }
  async isFooterTemplatePortal() {
    return !(await (await this.footerContentCO.element()).isExisting());
  }
  get dismissButtonCO() {
    return new CoEuiButton(this.footerContentCO).addPredicateClassContains('eui-dialog__footer-dismiss-button');
  }
  async hasDismissButton() {
    return await (await this.dismissButtonCO.element()).isExisting();
  }
  get acceptButtonCO() {
    return new CoEuiButton(this.footerContentCO).addPredicateClassContains('eui-dialog__footer-accept-button');
  }
  async hasAcceptButton() {
    return await (await this.acceptButtonCO.element()).isExisting();
  }
}


