import Component from '../../component.js'
import { elementAttributeContains } from '../../../core/utils.js'
import CoUxButton from './ux-button.js'

export default class CoUxErrorGroupItem extends Component {

  constructor(parent) {
    let selector = 'ux-error-group-item';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/src/lib/ux-components/ux-error-group-output/ux-error-group-item/ux-error-group-item.component.html
  }
  get wrapper()  {
    let path = '//div[contains(@class, "ux-error-item-wrapper")]';
    return this.currentPath + path;
  }
  get headerContainer()  {
    let path = '//div[contains(@class, "ux-error-item__header-container")]';
    return this.wrapper + path;
  }
  get item()  {
    let path = '//div[contains(@class, "ux-error-item")]';
    return this.headerContainer + path;
  }
  async isMessageOverflowHidden() {
    return await elementAttributeContains(this.item, 'class', 'ux-error-item-hide-message-overflow');
  }
  get dangerIcon()  {
    let path = '//span[contains(@class, "ux-icon-times-circle") and contains(@class, "ux-u-color-danger")]';
    return this.item + path;
  }
  async hasSeverity(severity) {
    return await elementAttributeContains(this.item + '//span[contains(@class, "ux-u-color")]', 'class', severity);
  }
   get warningIcon()  {
    let path = '//span[contains(@class, "ux-icon-exclamation-triangle") and contains(@class, "ux-u-color-warning")]';
    return this.item + path;
  }
  get infoIcon()  {
    let path = '//span[contains(@class, "ux-icon-exclamation-circle") and contains(@class, "ux-u-color-grey")]';
    return this.item + path;
  }
  async hasSeverityInfo() {
    return await (await $(this.infoIcon)).isExisting();
  }
  get title()  {
    let path = '//span[contains(@class, "ux-error-item__title")]';
    return this.item + path;
  }
  get expandIconContainer()  {
    let path = '//div[contains(@class, "ux-error-item__expand-icon")]';
    return this.headerContainer + path;
  }
  async hasErrorDescription() {
    return await (await $(this.expandIconContainer)).isExisting();
  }
  get expandIcon()  {
    let path = '//span[contains(@class, "ux-icon")]';
    return this.expandIconContainer + path;
  }
  async isExpanded() {
    return await elementAttributeContains(this.expandIcon, 'class', 'ux-icon-angle-down');
  }
  get bodyContainer()  {
    let path = '//div[contains(@class, "ux-error-item__body-container")]';
    return this.wrapper + path;
  }
  get bodyContainerDescription()  {
    let path = '//div[contains(@class, "ux-error-item__body-container__description")]';
    return this.bodyContainer + path;
  }
  get descriptionFollowButtonCO() {
    return new CoUxButton(this.bodyContainerDescription);
  }
  async hasFollowButton() {
    return await (await $(this.descriptionFollowButtonCO.currentPath)).isExisting();
  }
  get bodyContainerDescriptionDiv()  {
    let path = '//div';
    return this.bodyContainerDescription + path;
  }
}


