import Component from '../../component.js'
import { elementAttributeContains } from '../../../core/utils.js'

export default class CoUxAlert extends Component {
    constructor(parent) {
      let selector = 'ux-alert';
      super(parent, selector);
      //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/src/lib/ux-components/ux-alert/ux-alert.component.html?at=support/10.x
    }
    get dataE2E(){
      let path = '//div[@data-e2e="ux-alert"]';
      return  this.currentPath + path;
    }
    async isVisible() {
      return await (await $(this.dataE2E)).isExisting();
    }
    async isMuted() {
      return await elementAttributeContains(this.dataE2E, 'class', 'ux-alert--muted');
    }
    get contentContainer() {
      let path = '//div[contains(@class,"ux-alert__content-container")]';
      return this.dataE2E + path;
    }
    get alertIcon() {
      let path = '//div[contains(@class,"ux-alert__icon")]';
      return this.contentContainer + path;
    }
    async hasIconClass() {
      return await (await $(this.alertIcon)).isExisting();
    }
    get roleAlert() {
      let path = '//div[contains(@role,"alert")]';
      return this.contentContainer + path;
    }
    get alertClose() {
      let path = '//div[contains(@class,"ux-alert__close")]';
      return this.contentContainer + path;
    }
    async isCloseable() {
      return await (await $(this.alertClose)).isExisting();
    }
    get toggableContent() {
      let path = '//div[@role="alert"]//div';
      return this.contentContainer + path;
    }
    getAlertLinkByText(text) {
      let path = '//a[contains(text(), "' + text + '")]';
      return this.contentContainer + path;
    }
}


