import Component  from '../component.js'
import { elementAttributeContains } from '../../core/utils.js';
import CoUxAlabel from '../7x/ux-a-label.js';
import CoUxAtag from '../7x/ux-a-tag.js';

export default class CoUxListItem extends Component {
    constructor(parent) {
      let selector = 'ux-list-item';
      super(parent, selector);
      //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/core/src/lib/commons/ux-components/ux-list-item/ux-list-item.component.html?at=refs%2Fheads%2Fsupport%2F7.x
    }
    get itemWrapper() {
      return this.currentPath + '//div[contains(@class, "ux-list-item-wrapper")]';
    }
    get listItem() {
      return this.itemWrapper + '//div[contains(@class,"ux-list-item")]';
    }
    get customContentPlaceholder() {
      return this.listItem + '//uxListItemContent'
    }
    get listLabel() {
        return new CoUxAlabel(this.listItem);
    }
    get rightContent() {
      return this.itemWrapper + '//div[contains(@class,"ux-list-item__right-content")]';
    }
    get rightContentTag() {
      return new CoUxAtag(this.rightContent);
    }
    async isSmall(){
      return await elementAttributeContains(this.listItem, 'class', 'ux-list-item--small');
    }
    async isLarge(){
      return await elementAttributeContains(this.listItem, 'class', 'ux-list-item--large');
    }
    async isHovered(){
      return await elementAttributeContains(this.listItem, 'class', 'ux-list-item--hovered');
    }
    async isHoverable(){
      return !elementAttributeContains(this.listItem, 'class', 'ux-list-item--not-hoverable');
    }
    async hasBorder(){
      return await elementAttributeContains(this.listItem, 'class', 'ux-list-item--bordered');
    }
    async isCollapsed(){
      return await elementAttributeContains(this.listItem, 'class', 'ux-list-item--collapsed');
    }
    async isActive(){
      return await elementAttributeContains(this.listItem, 'class', 'ux-list-item--active');
    }
    async hasSeperator(){
      return await elementAttributeContains(this.listItem, 'class', 'ux-list-item--seperator');
    }
    async isDisabled(){
      return await elementAttributeContains(this.listItem, 'class', 'ux-list-item--disabled');
    }
    async typeClass() {
      return await (await $(this.currentPath)).getAttribute('typeclass');
    }
    // UX A LABEL
    async label() {
      return await (await $(new CoUxAlabel(this.listLabel).currentPath)).getAttribute('label');
    }
    async subLabel() {
      return await (await $(new CoUxAlabel(this.listLabel).currentPath)).getAttribute('subLabel');
    }
    async iconClass() {
      return await (await $(new CoUxAlabel(this.listLabel).currentPath)).getAttribute('iconClass');
    }
    async isIconRounded(){
      return await (await $(new CoUxAlabel(this.listLabel).currentPath)).getAttribute('isIconRounded');
    }
    async iconTypeClass(){
      return await (await $(new CoUxAlabel(this.listLabel).currentPath)).getAttribute('iconTypeClass');
    }
    async hasMarker(){
      return await (await $(new CoUxAlabel(this.listLabel).currentPath)).getAttribute('hasMarker');
    }
    async markerTypeClass() {
      return await (await $(new CoUxAlabel(this.listLabel).currentPath)).getAttribute('markerTypeClass');
    }
    async isDisabled(){
      return await (await $(new CoUxAlabel(this.listLabel).currentPath)).getAttribute('isDisabled');
    }
    // UX A TAG
    async tagLabel() {
      return await (await $(new CoUxAtag(this.rightContent).currentPath)).getAttribute('label');
    }
    async tagCount() {
      return await (await $(new CoUxAtag(this.rightContent).currentPath)).getAttribute('subLabel');
    }
    async tagTypeClass() {
      return await (await $(new CoUxAtag(this.rightContent).currentPath)).getAttribute('typeClass');
    }
    async isTagRounded(){
      return await elementAttributeContains(new CoUxAtag(this.rightContent).tagDataDiv, 'class', 'ux-a-tag--rounded');
    }
}


