import Component from '../../component.js'
import { elementAttributeContains } from '../../../core/utils.js'
import CoEuiDropdown from './eui-dropdown.js'
import CoEuiDropdownContent from './eui-dropdown-content.js'

export default class CoEuiUserProfile extends Component {
    constructor(parent) {
      let selector = 'eui-user-profile';
      super(parent, selector);
      //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components-next/src/lib/layout/eui-user-profile/user-profile.component.html?at=refs%2Fheads%2Fsupport%2Fdevelop-10.x
    }
    get euiDropdownCO() {
      return new CoEuiDropdown(this.currentPath);
    }
    get content() {
      let path = '//div[contains(@class,"eui-user-profile-content")]';
      return this.euiDropdownCO.currentPath + path;
    }
    get infos() {
      let path = '//div[contains(@class,"eui-user-profile__infos")]';
      return this.content + path;
    }
    async hasNoSubinfos() {
      return await elementAttributeContains(this.infos, 'class', 'eui-user-profile__infos--no-subinfos');
    }
    get infosContainer() {
      let path = '//div[contains(@class,"eui-user-profile__infos-container")]';
      return this.infos + path;
    }
    get infosWelcome() {
      let path = '//div[contains(@class,"eui-user-profile__infos-welcome")]';
      return this.infosContainer + path;
    }
    get infosWelcomeLabel() {
      let path = '//span[not contains(@class,"eui-user-profile__infos-name")]';
      return this.infosWelcome + path;
    }
    async hasWelcomeLabel() {
      return await (await $(this.infosWelcomeLabel)).isExisting();
    }
    get infosWelcomeName() {
      let path = '//span[contains(@class,"eui-user-profile__infos-name")]';
      return this.infos + path;
    }
    get infosSubinfos() {
      let path = '//div[contains(@class,"eui-user-profile__infos-subinfos")]';
      return this.infos + path;
    }
    async hasSubinfos() {
      return await (await $(this.infosSubinfos)).isExisting();
    }
    get infosWelcomeStrong() {
      let path = '//strong';
      return this.infosWelcome + path;
    }
    async hasImpersonatedUserInfos() {
      return await (await $(this.infosWelcomeStrong)).isExisting();
    }
    get avatarShadow() {
      let path = '//span[contains(@class,"eui-user-profile__avatar-shadow")]';
      return this.content + path;
    }
    get defaultAvatar() {
      let path = '//span[contains(@class,"eui-u-svg--default-avatar")]';
      return this.avatarShadow + path;
    }
    get avatar() {
      let path = '//div[contains(@class,"eui-user-profile__avatar")]';
      return this.content + path;
    }
    async avatarOnline() {
      return await elementAttributeContains(this.avatar, 'class', 'eui-user-profile__avatar--online');
    }
    async isOnline() {
      return this.avatarOnline();
    }
    async avatarOffline() {
      return await elementAttributeContains(this.avatar, 'class', 'eui-user-profile__avatar--offline');
    }
    get avatarUrl() {
      let path = '//span[contains(@class,"eui-user-profile__avatar") and contains(@class,"eui-u-svg")]';
      return this.content + path;
    }
    async hasAvatarUrl() {
      return await (await $(this.avatarUrl)).isExisting();
    }
    get avatarImage() {
      let path = '//img';
      return this.avatarUrl + path;
    }
    async hasEuiUserProfileSizeS() {
      return await elementAttributeContains(this.euiDropdownCO.currentPath, 'class', 'eui-user-profile--size-s');
    }
    get euiDropdownContentCO() {
      return new CoEuiDropdownContent(this.euiDropdownCO.currentPath);
    }

}


