import { elementAttributeContains } from '../../core/utils.js';
import Component from '../component.js';
import DivComponent from '../div.js';
import CoEuiAlertTitle from './eui-alert-title.js';
import CoEuiIconButton from './eui-icon-button.js';
import CoEuiIconState from './eui-icon-state.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/eui-alert/eui-alert.component.html?at=refs%2Fheads%2Fmaster
  }
  get containerTitleCO() {
    return new DivComponent(this.currentPath).addPredicateClassContains("eui-alert-container");
  }
  async hasTitle() {
    return await (await this.containerTitleCO.element()).isExisting();
  }
  get contentWrapperCO() {
    return new DivComponent(this.containerTitleCO).addPredicateClassContains("eui-alert-title-wrapper");
  }
  get wrapperIconCO() {
    return new CoEuiIconState(this.contentWrapperCO);
  }
  async euiAlertMuted() {
    return !await (await this.wrapperIconCO.element()).isExisting();
  }
  get alertTitle() {
    return new CoEuiAlertTitle(this.contentWrapperCO);
  }
  get alertContentTitleCO() {
    return new DivComponent(this.containerTitleCO).addPredicateClassContains("eui-alert__content");
  }
  get alertIconCO() {
    return new CoEuiIconState(this.currentPath);
  }
  get alertContentCO() {
    return new DivComponent(this.currentPath).addPredicateClassContains("eui-alert__content");
  }
  get alertCloseIconCO() {
    return new CoEuiIconButton(this.currentPath).addPredicateClassContains('eui-alert-close');
  }
  async isCloseable() {
    return await (await this.alertCloseIconCO.element()).isExisting();
  }
  async isMuted() {
    return await elementAttributeContains(this.currentPath, 'class', 'eui-alert--muted');
  }
  async isHidden() {
    return await elementAttributeContains(this.currentPath, 'class', 'eui-alert--hidden');
  }
  async isFocusable() {
    return await elementAttributeContains(this.currentPath, 'class', 'eui-alert--focusable');
  }
}
