import Component from '../../component.js'
import CoEuiButton from './eui-button.js'
import { elementAttributeContains } from '../../../core/utils.js'

export default class CoEuiAlert extends Component {
    constructor(parent) {
      let selector = '*[self::eui-alert or self::div[euiAlert]]';
      super(parent, selector);
      // https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components-next/src/lib/components/eui-alert/eui-alert.component.html?at=refs%2Fheads%2Fsupport%2F10.x
    }
    get contentContainer() {
      let path = '//div[contains(@class,"eui-alert__content-wrapper")]';
      return this.currentPath + path;
    }
    get roleAlert() {
      let path = '//div[contains(@role,"alert")]';
      return this.contentContainer + path;
    }
    get alertClose() {
      return new CoEuiButton(this.contentContainer).byAttributeContains('class', 'eui-alert__close').currentPath;
    }
    async isCloseable() {
      return await (await $(this.alertClose)).isExisting();
    }
    async isMuted() {
      return await elementAttributeContains(this.currentPath, 'class', 'eui-alert--muted');
    }
    async isHidden() {
      return await elementAttributeContains(this.currentPath, 'class', 'eui-alert--hidden');
    }
}


