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

export default class CoEuiAppSidebarHeaderUserProfile extends Component {
  constructor(parent) {
    let selector = 'eui-app-sidebar-header-user-profile';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/layout/eui-app/eui-app-sidebar/sidebar-header-user-profile/sidebar-header-user-profile.component.html?at=support%2F13.x
  }
  get content() {
    let path = '//div[contains(@class,"eui-app-sidebar-header-user-profile-content")]';
    return this.currentPath + path;
  }
  get avatar() {
    let path = '//span[contains(@class,"eui-user-profile__avatar")]';
    return this.content + path;
  }
  async isOnline() {
    return await elementAttributeContains(this.avatar, 'class', 'eui-user-profile__avatar--online');
  }
  get infos() {
    let path = '//div[contains(@class,"eui-user-profile__infos")]';
    return this.content + path;
  }
  get infosWrapper() {
    let path = '//div[contains(@class,"eui-user-profile__infos-wrapper")]';
    return this.infos + path;
  }
  get infosWelcomeLabel() {
    let path = '//div[contains(@class,"eui-user-profile__infos-welcome")]';
    return this.infosWrapper + path;
  }
  async hasWelcomeLabel() {
    return await (await $(this.infosWelcomeLabel)).isExisting();
  }
  get infosContainer() {
    let path = '//div[contains(@class,"eui-user-profile__infos-welcome")]/following-sibling::div[contains(@class,"eui-user-profile__infos-container")]';
    return this.infosWrapper + path;
  }
  get userInfos() {
    let path = '//span[contains(@class,"eui-user-profile__infos-name")]';
    return this.infosContainer + path;
  }
  async hasImpersonatedUserInfos() {
    return await (await $(this.userInfosUserImpersonated)).isExisting();
  }
  get infosContainerImpersonationWelcome() {
    let path = '//span[contains(@class,"eui-user-profile__infos-welcome"]//ancestor::div[contains(@class,"eui-user-profile__infos-container")]';
    return this.infosWrapper + path;
  }
  get welcomeLabelUserImpersonated() {
    let path = '//span[contains(@class,"eui-user-profile__infos-welcome")]';
    return this.infosContainerImpersonationWelcome + path;
  }
  async hasWelcomeLabelUserImpersonated() {
    return await (await $(this.welcomeLabelUserImpersonated)).isExisting();
  }
  get userInfosUserImpersonated() {
    let path = '//strong/ancestor::span[contains(@class,"eui-user-profile__infos-welcome")]';
    return this.infosContainerImpersonationWelcome + path;
  }
  get infosContainerImpersonate() {
    let path = '//div[contains(@class,"eui-user-profile__infos-container")]/following-sibling::div[contains(@class,"eui-user-profile__infos-container")]/';
    return this.infosWrapper + path;
  }
  get impersonatedLabel() {
    let path = '//span[contains(@class,"eui-user-profile__infos-impersonating")]';
    return this.infosContainerImpersonate + path;
  }
  get impersonatedUserInfos() {
    let path = '//span[contains(@class,"eui-user-profile__infos-name")]';
    return this.infosContainerImpersonate + path;
  }
  get infosSubinfos() {
    let path = '//div[contains(@class,"eui-user-profile__infos-subinfos")]';
    return this.infos + path;
  }
  async hasUserSubInfos() {
    return await (await $(this.infosSubinfos)).isExisting();
  }
  get euiButtonToggleCO() {
    return new CoEuiButton(this.content).byAttributeContains('class', 'eui-user-profile__toggle');
  }
  get toggleIcon() {
    return this.euiButtonToggleCO.currentPath + '//div[contains(@class,"eui-icon")]';
  }
  async hasIconAngleUp() {
    return await elementAttributeContains(this.toggleIcon, 'class', 'eui-icon-angle-up');
  }
  async hasIconAngleDown() {
    return await elementAttributeContains(this.toggleIcon, 'class', 'eui-icon-angle-down');
  }
}


