import Component from '../../component.js'
import CoUxSidebarItemHeader from './ux-layout-sidebar-item-header.js'
import { elementAttributeContains } from '../../../core/utils.js'

export default class CoUxLayoutSidebarItem extends Component {
    constructor(parent) {
      let selector = 'ux-layout-sidebar-item';
      super(parent, selector);
      //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/src/lib/ux-components/layout/ux-layout-app-shell/components/ux-layout-sidebar/ux-layout-sidebar-item.component.ts
    }
    get dataE2E() {
      let path = '//div[@data-e2e="ux-layout-sidebar-item"]';
      return this.currentPath + path;
    }
    async isLarge() {
      return await elementAttributeContains(this.dataE2E, 'class', 'sidebar-item--large');
    }
    get url() {
      let path = '//a';
      return this.dataE2E + path;
    }
    async urlExternal() {
      return await (await $(this.dataE2E + '//a')).getAttribute('href');
    }
    get sidebarItemHeaderCO(){
      return new CoUxSidebarItemHeader(this.dataE2E);
    }
    get sidebarItemSub() {
      let path = '//div[contains(@class,"sidebar-item__sub")]';
      return this.dataE2E + path;
    }
    async isCollapsedWithIcon() {
      return await elementAttributeContains(this.sidebarItemSub, 'class', 'sidebar-item__sub--collapsed');
    }
    async isExpanded() {
      return await (await $(this.sidebarItemSub)).isExisting();
    }
    get separator() {
      let path = '//div[contains(@class,"sidebar-item-separator")]';
      return this.dataE2E + path;
    }
    async isSeparator() {
      return await (await $(this.separator)).isExisting();
    }
}


