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

export default class CoUxDynamicPopover extends Component {
    constructor(parent) {
      let selector = 'ux-dynamic-popover';
      super(parent, selector);
      //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/src/lib/ux-components/ux-dynamic-popover/ux-dynamic-popover.component.html
    }
    get dataE2E() {
      let path = '//div[contains(@data-e2e,"ux-dynamic-popover")]';
      return this.currentPath + path;
    }
    async isVisible() {
      return await elementAttributeContains(this.dataE2E, 'class', 'ux-popover--visible');
    }
    get popoverArrow() {
      let path = '//div[contains(@class,"ux-popover__arrow")]';
      return this.dataE2E + path;
    }
    get popoverArrowInner() {
      let path = '//div[contains(@class,"ux-popover__arrow-inner")]';
      return this.popoverArrow + path;
    }
    get popoverHeader() {
      let path = '//div[contains(@class,"ux-popover__header")]';
      return this.dataE2E + path;
    }
    get popoverHeaderTitle() {
      let path = '//div[contains(@class,"ux-popover__title")]';
      return this.popoverHeader + path;
    }
    async isShownCloseIcon() {
      return await (await $(this.popoverCloseIcon)).isExisting();
    }
    get popoverClose() {
      let path = '//div[contains(@class,"ux-popover__close")]';
      return this.popoverHeader + path;
    }
    get popoverCloseIcon() {
      let path = '//i[contains(@class,"eui-icon-ecl-close")]';
      return this.popoverClose + path;
    }
    get popoverContent() {
      let path = '//div[contains(@class,"ux-popover__content")]';
      return this.dataE2E + path;
    }
    async hasNoContentPadding() {
      return await elementAttributeContains(this.popoverContent, 'class', 'p-0');
    }
    get popoverContentSpan() {
      let path = '//span';
      return this.popoverContent + path;
    }
    async hasContent() {
      return await (await $(this.popoverContentSpan)).isExisting();
    }
}


