import Component from '../../component.js'
import CoUxOverlay from './ux-overlay.js';

export default class CoUxFieldset extends Component {
    constructor(parent) {
      let selector = 'ux-fieldset';
      super(parent, selector);
      // https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/src/lib/ux-components/ux-fieldset/ux-fieldset.component.ts
    }
    get dataE2E() {
      let path = '//div[@data-e2e = "ux-fieldset"]';
      return this.currentPath + path;
    }
    async isHighlighted() {
      return await (await $(this.dataE2E + '/self::div[contains(@class,"ux-fieldset--highlighted")]')).isExisting();
    }
    get header() {
      let path = '//div[contains(@class,"ux-fieldset__header")]';
      return this.dataE2E + path;
    }
    async isExpandable() {
      return await (await $(this.header + '/self::div[contains(@class,"ux-fieldset__header--expandable")]')).isExisting();
    }
    get headerLabel() {
      let path = '//div[contains(@class,"ux-fieldset__header-label")]';
      return this.header + path;
    }
    get headerIcon() {
      let path = '//span[contains(@class,"ux-fieldset__header-icon")]';
      return this.headerLabel + path;
    }
    async typeclass() {
      let array = await (await (await $(this.headerLabel)).getAttribute('class')).split(/\s*[\s,]\s*/);
      let type = array.filter(el => (el.startsWith("ux-u-color-") === true));
      let result = type.toString().replace('ux-u-color-','');
      return result;
    }
    get headerRightContent() {
      let path = '//div[contains(@class,"ux-fieldset__header-right-content")]';
      return this.header + path;
    }
    get headerExpandToggle() {
      let path = '//span[contains(@class,"ux-fieldset__header-expand-toggle")]';
      return this.headerRightContent + path;
    }
    get content() {
      let path = '//div[contains(@class,"ux-fieldset__content")]';
      return this.dataE2E + path;
    }
    async isExpanded() {
      return await (await $(this.dataE2E + '//div[contains(@class,"ux-fieldset__content")]')).isExisting();
    }
    async isLarge() {
      return await (await $(this.dataE2E + '/self::div[contains(@class,"ux-fieldset--large")]')).isExisting();
    }
    async isFirst() {
      return await (await $(this.dataE2E + '/self::div[contains(@class,"ux-fieldset--first")]')).isExisting();
    }
    get overlayCO() {
      return new CoUxOverlay(this.currentPath);
    }
}


