import Component  from '../component.js'

export default class CoUxModal extends Component {

    constructor(parent) {
      let selector = 'ux-modal';
      super(parent, selector);
    }
    /**
    * @type boolean
    */
    async isModalOpen() {
      let st =await (await this.element()).getAttribute('style');
      if (st.includes('display: block;')) {
         return true;
      } else if (st.includes('display: none;')) {
         return false;
      } else {
         throw new Error('ux-modal component object needs to be revised, root is missing style attribute or value doesn\'t correspond');
      }
    }
    /**
    * @type WebdriverIO.Element
    */
    get content() {
      let path = '//div[contains(@class,"ux-modal__content")]';
      return this.currentPath + path;
    }
    /**
    * @type WebdriverIO.Element
    */
    get header() {
      let path = '//div[contains(@class,"ux-modal__header")]';
      return this.content + path;
    }
    /**
    * @type WebdriverIO.Element
    */
    get headerTitle() {
      let path = '//div[contains(@class,"ux-modal__header-title")]';
      return this.header + path;
    }
    /**
    * @type WebdriverIO.Element
    */
    get closeBtn() {
      let path = '//button[contains(@class,"ux-modal__header-close")]';
      return this.header + path;
    }
    /**
    * @type WebdriverIO.Element
    */
    get body() {
      let path = '//div[contains(@class,"ux-modal__body")]';
      return this.content + path;
    }
    /**
    * @type WebdriverIO.Element
    */
    get bodyPlaceholder() {
      let path = '//uxmodalbody';
      return this.body + path;
    }
    /**
    * @type WebdriverIO.Element
    */
    async isFooterVisible() {
      return await (await $(this.footer)).isExisting();
    }
    /**
    * @type WebdriverIO.Element
    */
    get footer() {
      let path = '//div[contains(@class, "ux-modal__footer")]';
      return this.content + path;
    }
    /**
    * @type WebdriverIO.Element
    */
    get footerContentPlaceholder() {
      let path = '//uxmodalfooter';
      return this.content + path;
    }
    /**
    * @type WebdriverIO.Element
    */
    get dismissBtn() {
      let path = '//button[contains(@class, "btn-secondary")]';
      return this.footer + path;
    }
    /**
    * @type WebdriverIO.Element
    */
    get acceptBtn() {
      let path = '//button[contains(@class, "btn-primary")]';
      return this.footer + path;
    }
}


