import Component  from '../component.js'

export default class CoUxFieldset extends Component {
    constructor(parent) {
      let selector = 'ux-fieldset';
      super(parent, selector);
    }
    /**
    * @type WebdriverIO.Element
    */
    get header() {
      let path = '//div[contains(@class,"ux-fieldset__header")]';
      return this.currentPath + path;
    }
    /**
    * @type boolean
    */
    async isExpandable() {
      if (await (await $(this.currentPath + '//div[contains(@class,"ux-fieldset__header")]')).isExisting()) {
         let cl = this.header.getAttribute('class');
         if (cl.includes('ux-fieldset__header--expandable')) {
            return true;
         } else {
            return false;
         }
      }
      return false;
    }
    /**
    * @type WebdriverIO.Element
    */
    get headerLabel() {
      let path = '//div[contains(@class,"ux-fieldset__header-label")]';
      return this.header + path;
    }
    /**
    * @type string
    */
    get iconType() {
      let cl = this.headerLabel.getAttribute('class');
      if (cl.includes('ux-u-color-info')) {
         return 'info';
      } else if (cl.includes('ux-u-color-success')) {
         return 'success';
      } else if (cl.includes('ux-u-color-warning')) {
         return 'warning';
      } else if (cl.includes('ux-u-color-danger')) {
         return 'danger';
      } else if (cl.includes('ux-u-color-default')) {
         return 'default';
      }
    }
    /**
    * @type WebdriverIO.Element
    */
    get headerRightContent() {
      let path = '//div[contains(@class,"ux-fieldset__header-right-content")]';
      return this.header + path;
    }
    /**
    * @type WebdriverIO.Element
    */
    get headerExpandToggle() {
      let path = '//span[contains(@class,"ux-fieldset__header-expand-toggle")]';
      return this.headerRightContent + path;
    }
    /**
    * @type WebdriverIO.Element
    */
    get content() {
      let path = '//div[contains(@class,"ux-fieldset__content")]';
      return this.currentPath + path;
    }
    /**
    * @type boolean
    */
    async isExpanded() {
      let content = await (await $(this.content)).isExisting();
      if (content) {
         return true;
      } else if (!content) {
         return false;
      }
    }
}


