import Component from '../../component.js'
import CoUxDynamicModal from './ux-dynamic-modal.js'
import { elementAttributeContains } from '../../../core/utils.js'

export default class CoUxDynamicMessageBox extends Component {
    constructor(parent) {
      let selector = 'ux-dynamic-message-box';
      super(parent, selector);
      //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/src/lib/ux-components/ux-dynamic-message-box/ux-dynamic-message-box.component.ts
    }
    get dataE2E() {
      let path = '//div[@data-e2e="ux-dynamic-message-box"]';
      return this.currentPath + path;
    }
    get uxDynamicModalCo() {
      return new CoUxDynamicModal(this.dataE2E);
    }
    // BODY
    get body() {
      return this.uxDynamicModalCo.modalBody + '//div[contains(@class, "ux-message-box__body")]';
    }
    get bodyIcon() {
      return this.uxDynamicModalCo.modalContent + '//div[contains(@class, "ux-message-box__body-icon")]';
    }
    async hasBodyIcon() {
      return await (await $(this.bodyIcon)).isExisting();
    }
    get bodyContent() {
      return this.uxDynamicModalCo.modalContent + '//div[contains(@class, "ux-message-box__body-content")]';
    }
    async isBodyHidden() {
      return await (await $(this.bodyContent)).isExisting();
    }
    // FOOTER
    async dismissBtn() {
      return await (await $(this.uxDynamicModalCo.footerSecondaryButtonCO.currentPath));
    }
    async acceptBtn() {
      return await (await $(this.uxDynamicModalCo.footerPrimaryButtonCO.currentPath));
    }
    get dynamicMessageBoxFooter() {
      return this.uxDynamicModalCo.modalFooter + '//uxdynamicmessageboxfooter';
    }
    get dynamicMBoxFooterHorizontalLeft() {
      return this.dynamicMessageBoxFooter + '//uxlayouthorizontalleft';
    }
    async hasCustomFooterContent() {
      return await this.uxDynamicModalCo.hasCustomFooterContent();
    }
    // types
    async isTypeDanger() {
      return await elementAttributeContains(this.uxDynamicModalCo.dataE2E, 'class', 'ux-message-box--danger');
    }
    async isTypeSuccess() {
      return await elementAttributeContains(this.uxDynamicModalCo.dataE2E, 'class', 'ux-message-box--success');
    }
    async isTypeInfo() {
      return await elementAttributeContains(this.uxDynamicModalCo.dataE2E, 'class', 'ux-message-box--info');
    }
    async isTypeQuestion() {
      return await elementAttributeContains(this.uxDynamicModalCo.dataE2E, 'class', 'ux-message-box--question');
    }
    async isTypeWarning() {
      return await elementAttributeContains(this.uxDynamicModalCo.dataE2E, 'class', 'ux-message-box--warning');
    }
}


