import Component  from '../component.js'
import CoEuiIcon from './eui-icon.js'
import CoEuiBadge from './eui-badge.js'
import CoEuiOverlay from './eui-overlay.js'
import CoEuiNotificationItem from './eui-notification-item.js'
import CoEuiButton from './eui-button.js'
import CoEuiIconSvg from './eui-icon-svg.js'

export default class CoEuiNotifications extends Component {
  constructor(parent) {
    let selector = 'eui-notifications';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/layout/eui-notifications/eui-notifications.component.html?at=refs%2Fheads%2Fsupport%2F13.x
  }
  get euiIconCO() {
    return new CoEuiIcon(this.currentPath);
  }
  get euiIconBadgeCO() {
    return new CoEuiBadge(this.euiIconCO);
  }
  async hasCount() {
    return await (await this.euiIconBadgeCO.element()).isExisting();
  }
  get euiOverlayCO() {
    return new CoEuiOverlay(this.currentPath);
  }
  get headerTitle() {
    let path = '//div[contains(@class,"eui-notifications__header-title")]';
    return this.euiOverlayCO.euiOverlayHeaderCO.currentPath + path;
  }
  get headerTitleLabel() {
    let path = '//div[contains(@class,"eui-notifications__header-title-label")]';
    return this.headerTitle + path;
  }
  get cursor() {
    let path = '//span[contains(@class,"eui-u-cursor-help")]';
    return this.headerTitleLabel + path;
  }
  get euiTitleBadgeCO() {
    return new CoEuiBadge(this.headerTitleLabel);
  }
  async hasItems() {
    return await (await $(this.cursor)).isExisting();
  }
  get headerActions() {
    let path = '//div[contains(@class,"eui-notifications__header-actions")]';
    return this.euiOverlayCO.euiOverlayHeaderCO.currentPath + path;
  }
  get headerActionsButtonCO() {
    return new CoEuiButton(this.headerActions);
  }
  get headerButtonIconCO() {
    return new CoEuiIconSvg(this.headerActionsButtonCO);
  }
  async isShowMarkAllAsReadButton() {
    return await (await $(this.headerButtonIconCO.currentPath)).isExisting();
  }
  get headerButtonSpanGear() {
    return this.headerActionsButtonCO.currentPath + '//span[contains(@class, "eui-icon-ecl-gear")]';
  }
  async isShowSettingsButton() {
    return await (await $(this.headerButtonSpanGear)).isExisting();
  }
  get headerButtonSpanRefresh() {
    return this.headerActionsButtonCO.currentPath + '//span[contains(@class, "eui-icon-refresh")]';
  }
  async isShowRefreshButton() {
    return await (await $(this.headerButtonSpanRefresh)).isExisting();
  }
  get notificationsItems() {
    let path = '//ul[contains(@class,"eui-notifications-items")]';
    return this.euiOverlayCO.euiOverlayBodyCO.currentPath + path;
  }
  async hasItems() {
    return await (await $(this.notificationsItems)).isExisting();
  }
  get euiNotificationItemCO() {
    return new CoEuiNotificationItem(this.notificationsItems);
  }
  get footerLabel() {
    let path = '//strong//a';
    return this.euiOverlayCO.euiOverlayFooterCO.currentPath + path;
  }
  get footerItemContent() {
    return this.euiOverlayCO.euiOverlayFooterCO.currentPath + '//div[contains(@class, "ux-notification__item-content")]';
  }
  get footerItemLink() {
    return this.footerItemContent + '//strong//a';
  }
  async hasNotificationLink() {
    return await (await $(this.footerItemLink)).isExisting();
  }
}


