import BasePage from '@eui/automation/pages/base.js'
import CoEuiApp from '@eui/automation/components/10x/eui/eui-app.js';
import CdkOverlayContainer from '@eui/automation/components/cdk-overlay-container.js';
import CoEuiDialog from '@eui/automation/components/10x/eui/eui-dialog.js';
import CoEuiButton from '@eui/automation/components/10x/eui/eui-button.js';
import CoEuiUserProfileMenu from '@eui/automation/components/10x/eui/eui-user-profile-menu.js';
import CoEuiToolbarItemUserProfile from '@eui/automation/components/10x/eui/eui-toolbar-item-user-profile.js';
import CoEuiUserProfileMenuItem from '@eui/automation/components/10x/eui/eui-user-profile-menu-item.js';
import CoEuiIcon from '@eui/automation/components/10x/eui/eui-icon.js';

export default class AppBasePage extends BasePage {

    constructor() {
        super();
    }
    get euiAppCO() {
        return new CoEuiApp(this.root);
    }
    get languageSelectorCO() {
        return this.euiAppCO.euiAppToolbarCO.euiLanguageSelectorCO;
    }
    async languageSelectorLink() {
        return await this.languageSelectorCO.languageSelectorLink();
    }
    async languageSelectedCode() {
        return await this.languageSelectorCO.languageSelectorLinkCode();
    }
    get euiDialogCO(){
        return new CoEuiDialog(new CdkOverlayContainer('//body'));
    }
    get modalSelector(){
        return this.euiDialogCO.currentPath + '//eui-modal-selector';
    }
    get selectLanguageButtonCO(){
        return new CoEuiButton(this.modalSelector);
    }
    get userProfileWelcomeName() {
        return this.userProfileCO.currentPath + '//div[contains(@class, "eui-user-profile__infos-welcome")]';
    }
    get userProfileAvatar() {
        return this.userProfileCO.avatar;
    }
    get userProfileMenuItemCO() {
        return new CoEuiUserProfileMenuItem(this.root);
    }
    get userProfileMenuCO() {
        return new CoEuiUserProfileMenu(this.root);
    }
    get userProfileCO() {
        return new CoEuiToolbarItemUserProfile(this.root).euiUserProfileCO;
    }
    get profileSignOutCO() {
        return new this.userProfileMenuItemCO.byTextContains('Sign out');
    }
    get logoutIconCO(){
        return new CoEuiIcon(this.userProfileMenuItemCO).byIndex(5).byAttributeContains('class', 'eui-icon-logout-thin');
    } 

    get genericLoaders() {
        return '//*[@class="ux-block-document-loading" ' +
                'or @class="c-page-loading__content" ' +
                'or @class="ux-loading-indicator" ' +
                'or @class="c-page-loading__message" ' +
                'or @class="loading" ' +
                'or (contains(@class,"eui-icon-spinner"))'+
                'or (contains(@class,"fa-spinner") and contains(@class, " fa-spin"))]';
    }
    get blockLoader() {
        return '//div[(contains(@class,"ux-c-block-content") and contains(@class,"ux-is-active")) ' +
        'or contains(@class,"eui-block-content__wrapper")]';
    }
    get pageLoaders() {
        return '//*[@class="eu-app-loader-wrapper"]';
    }
};
