import Component from '../../component.js'
import { elementAttributeContains } from '../../../core/utils.js'

export default class CoUxDashboardCard extends Component {
    constructor(parent) {
      let selector = 'ux-dashboard-card';
      super(parent, selector);
      //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/src/lib/ux-components/ux-dashboard-card/ux-dashboard-card.component.ts?at=support/10.x
    }
    get dataE2E() {
      return this.currentPath + '//div[@data-e2e = "ux-dashboard-card"]';
    }
    get cardContentWrapper() {
      let path = '//div[contains(@class, "ux-dashboard-card__content-wrapper")]';
      return this.dataE2E + path;
    }
    get cardContent() {
      let path = '//div[contains(@class, "ux-dashboard-card__content")]';
      return this.cardContentWrapper + path;
    }
    get contentLabel() {
      let path = '//div[contains(@class, "ux-dashboard-card__content-label")]';
      return this.cardContent + path;
    }
    get contentSublabel() {
      let path = '//div[contains(@class,"ux-dashboard-card__content-sub-label")]';
      return this.cardContent + path;
    }
    get contentLink() {
      let path = '//div[contains(@class,"ux-dashboard-card__content-link")]';
      return this.cardContent + path;
    }
    get buttonLinkLabel() {
      let path = '//a[contains(@class,"ux-button")]';
      return this.contentLink + path;
    }
    get cardIconContainer() {
      let path = '//div[contains(@class, "ux-dashboard-card__icon-container")]';
      return this.dataE2E + path;
    }
    async hasIconContainer() {
      return await (await $(this.cardIconContainer)).isExisting();
      }
    get iconWrapper() {
      let path = '//div[contains(@class, "ux-dashboard-card__icon-wrapper")]';
      return this.cardIconContainer + path;
    }
    get iconWrapperIcon() {
      let path = '//span[contains(@class, "ux-dashboard-card__icon-wrapper-icon")]';
      return this.iconWrapper + path;
    }
    get cardImageContainer() {
      let path = '//div[contains(@class, "ux-dashboard-card__image-container")]';
      return this.dataE2E + path;
    }
    async hasImageUrl() {
      return await (await $(this.cardImageContainer)).isExisting();
    }
    get imageWrapper() {
      let path = '//div[contains(@class, "ux-dashboard-card__image-wrapper")]';
      return this.cardImageContainer + path;
    }
    get imageWrapperImage() {
      let path = '//img';
      return this.imageWrapper + path;
    }
    async isClickable() {
      return await elementAttributeContains(this.dataE2E, 'class', 'ux-dashboard-card--clickable');
    }
    async isIconCompact() {
      return await elementAttributeContains(this.dataE2E, 'class', 'ux-dashboard-card--icon-compact');
    }
    async isHorizontalLayout() {
      return await elementAttributeContains(this.dataE2E, 'class', 'ux-dashboard-card--horizontal');
    }
    async isIconCompactAndHorizontalLayout() {
      return await elementAttributeContains(this.dataE2E, 'class', 'ux-dashboard-card--horizontal--icon-compact');
    }
    async hasIconClass() {
      return await elementAttributeContains(this.iconWrapperIcon, 'class', 'eui-icon-fw');
    }
    async maxLines(){
      return parseInt(await (await (await $(this.contentLabel)).getAttribute('class')).replace(/\D/g,''));
    }
    async maxSublines(){
      return parseInt(await ( await (await $(this.contentSublabel)).getAttribute('class')).replace(/\D/g,''));
    }
}


