import Component from '../../component.js'
import CoUxBadge from './ux-badge.js'
import CoUxButton from './ux-button.js'
import CoUxNotificationItem from './ux-notification-item.js'

export default class CoUxNotificationsPanel extends Component {
    constructor(parent) {
      let selector = 'ux-notifications-panel';
      super(parent, selector);
      //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/src/lib/ux-components/ux-notifications/ux-notifications-panel.component.html
    }
    get dataE2E() {
      let path = '//div[@data-e2e="ux-notifications-panel"]';
      return this.currentPath + path;
    }
    get notificationsPanelHeader() {
      let path = '//div[@class = "ux-notifications-panel__header"]';
      return this.dataE2E + path;
    }
    get headerTitle() {
      let path = '//div[@class = "ux-notifications-panel__header-title"]';
      return this.notificationsPanelHeader + path;
    }
    get headerTitleLabel() {
      let path = '//div[@class = "ux-notifications-panel__header-title-label"]';
      return this.headerTitle + path;
    }
    get headerTitleNotificationUnreadLabel() {
      let path = '//span[contains(@class, "eui-u-cursor-help")]';
      return this.headerTitleLabel + path;
    }
    get notificationsQuantityBadge() {
      return new CoUxBadge(this.headerTitleLabel);
    }
    get headerActions() {
      let path = '//div[contains(@class, "ux-notifications-panel__header-actions")]';
      return this.notificationsPanelHeader + path;
    }
    get markAllAsReadButtonCO() {
      return new CoUxButton(this.headerActions).byAttributeContains('iconclass', 'eui-icon eui-icon-check');
    }
    get showSettingsButtonCO() {
      return new CoUxButton(this.headerActions).byAttributeContains('iconclass', 'eui-icon eui-icon-ecl-gear');
   }
   get showRefreshButtonCO() {
    return new CoUxButton(this.headerActions).byAttributeContains('iconclass', 'eui-icon-refresh');
   }
   async isShowMarkAllAsReadButton() {
      return await (await $(this.markAllAsReadButtonCO.button)).isExisting();
    }
    async isShowSettingsButton() {
      return await (await $(this.showSettingsButtonCO.button)).isExisting();
    }
    async isShowRefreshButton() {
      return await (await $(this.showRefreshButtonCO.button)).isExisting();
    }
    get notificationsPanelContent() {
      let path = '//div[@class = "ux-notifications-panel__content"]';
      return this.dataE2E + path;
    }
    get notificationItemCO() {
      return new CoUxNotificationItem(this.notificationsPanelContent);
    }
    get notificationsPanelFooter() {
      let path = '//div[@class = "ux-notifications-panel__footer"]';
      return this.dataE2E + path;
    }
    get notificationPanelFooterViewAllLink() {
      let path = '/strong/a';
      return this.notificationsPanelFooter + path;
    }
    get notificationsPanelFooterItem() {
      let path = '//div[contains(@class, "ux-notification__item-content")]';
      return this.notificationsPanelFooter + path;
    }
    get noNotificationFoundLabel() {
      let path = '/self::div[contains(text(), "No notification found")]';
      return this.notificationsPanelFooterItem + path;
    }
    get noNotificationFoundLink() {
      let path = '/strong/a';
      return this.notificationsPanelFooterItem + path;
    }
    async hasNotifications() {
      return !(await(await $(this.notificationsPanelFooterItem)).isExisting());
    }
}


