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

export default class CoUxPopover extends Component {
    constructor(parent) {
      // ux-popover.component.ts has selector 'ux-popover'
      // but ux-popover.component.html is popoverContainer therefor I put following selector
      let selector = 'div[contains(@data-e2e,"ux-popover")]';
      super(parent, selector);
      //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/src/lib/ux-components/ux-popover/ux-popover.component.html
    }
    async isVisible() {
      return await elementAttributeContains(this.currentPath, 'class', 'ux-popover--visible');
    }
    get popoverArrow() {
      let path = '//div[contains(@class,"ux-popover__arrow")]';
      return this.currentPath + 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.currentPath + path;
    }
    async hasTitle() {
      return await (await $(this.popoverHeader)).isExisting();
    }
    get popoverHeaderTitle() {
      let path = '//div[contains(@class,"ux-popover__title")]';
      return this.popoverHeader + path;
    }
    get popoverClose() {
      let path = '//div[contains(@class,"ux-popover__close")]';
      return this.popoverHeader + path;
    }
    async isShownCloseIcon() {
      return await (await $(this.popoverCloseIcon)).isExisting();
    }
    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.currentPath + path;
    }
    async hasNoContentPadding() {
      return await elementAttributeContains(this.popoverContent, 'class', 'p-0');
    }
}


