import Component from '../../component.js'
import { elementAttributeContains } from '../../../core/utils.js'
import CoUxAicon from './ux-a-icon.js'
import CoUxAlabel from './ux-a-label.js'
import CoUxAtag from './ux-a-tag.js'
import CoUxAmarker from './ux-a-marker.js'

export default class CoUxTabItem extends Component {
  constructor(parent) {
    let selector = 'div[contains(@class,"ux-tab-item") and not(contains(@class,"ux-tab-item_"))]';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/src/lib/ux-components/ux-tab/ux-tab.component.ts
  }
  async isActive() {
    return await elementAttributeContains(this.currentPath, 'class', 'ux-tab-item--active');
  }
  async isDisabled() {
    return await elementAttributeContains(this.currentPath, 'class', 'ux-tab-item--disabled');
  }
  async isSubTabs() {
    return await elementAttributeContains(this.currentPath, 'class', 'ux-tab-item--sub-tabs');
  }
  async hasValidationErrors() {
    return await elementAttributeContains(this.currentPath, 'class', 'ux-tab-item--invalid');
  }
  async isHidden() {
    return await elementAttributeContains(this.currentPath, 'class', 'ux-tab-item--hidden');
  }
  get iconCO() {
    return new CoUxAicon(this.currentPath);
  }
  get labelCO() {
    return new CoUxAlabel(this.currentPath);
  }
  get tagCO() {
    return new CoUxAtag(this.currentPath);
  }
  get markerCO(){
    return  new CoUxAmarker(this.currentPath);
  }
  async hasMarker(){
    return await (await $(this.markerCO.currentPath)).isExisting();
  }
  get closeIcon() {
    let path = '//span[contains(@class,"ux-tab-item__close-toggle")]';
    return this.currentPath + path;
  }
  async isClosable(){
    return await (await $(this.closeIcon)).isExisting();
  }

}

  
