import Component from '../../component.js'
import CoUxAlabel from '../../10x/ux/ux-a-label.js'
import { elementAttributeContains } from '../../../core/utils.js';
import CoEuiButton from '../eui-button.js';
import CoEuiIconSvg from '../eui-icon-svg.js';

export default class CoUxTreeListItem extends Component {
    constructor(parent) {
      let selector = 'ux-tree-list-item';
      super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/legacy/ux-tree-list/ux-tree-list-item.component.html
    }
    get dataE2E() {
      let path = '//div[@data-e2e="ux-tree-list-item"]';
      return this.currentPath + path;
    }
    async isActive() {
      return await elementAttributeContains(this.dataE2E, 'class', 'ux-tree-list-item--active');
    }
    async isHidden() {
      return await (await $(this.dataE2E + '/self::div[@hidden]')).isExisting();
    }
    get header() {
      let path = '//div[contains(@class,"ux-tree-list-item-header")]';
      return this.dataE2E + path;
    }
    get headerContent() {
      let path = '//div[contains(@class, "ux-tree-list-item-header__content")]';
      return this.header + path;
    }
    get customContentPlaceholder() {
      let path = '//uxTreeListItemCustomContent';
      return this.header + path;
    }
    async hasCustomContent() {
      return await (await $(this.customContentPlaceholder)).isExisting();
    }
    get headerContentRightContent() {
      let path = '//div[contains(@class, "ux-tree-list-item-header__content-right-content")]';
      return this.headerContent + path;
    }
    get rightContentPlaceholder() {
      let path = '//div[contains(@class, "ux-tree-list-item-header__content-right-content-sub")]';
      return this.headerContentRightContent + path;
    }
    get headerContentExpandToggleWrapper() {
      let path = '//div[contains(@class, "ux-tree-list-item-header__content-expand-toggle-wrapper")]';
      return this.headerContentRightContent + path;
    }
    get expandCollapseButtonCO(){
      return new CoEuiButton(this.headerContentExpandToggleWrapper);
    }
    get collapseIconCO(){
      return new CoEuiIconSvg(this.expandCollapseButtonCO).byAttributeContains('icon', 'eui-chevron-up');
    }
    async isExpanded(){
      return await (await this.collapseIconCO.element()).isExisting();
    }
    get expandIconCO(){
      return new CoEuiIconSvg(this.expandCollapseButtonCO).byAttributeContains('icon', 'eui-chevron-forward');
    }
    async isNotExpanded(){
      return await (await this.expandIconCO.element()).isExisting();
    }
    get alabelCO() {
      return new CoUxAlabel(this.headerContent);
    }
    get customSubLabelPlaceholder() {
      return this.alabelCO.customSubLabelPlaceholder;
    }
    get uxTreeListItemSubLabelPlaceholder() {
      let path = '//uxTreeListItemSubLabel';
      return this.alabelCO.customSubLabelPlaceholder + path;
    }
    async hasCustomSubLabel() {
      return await (await $(this.uxTreeListItemSubLabelPlaceholder)).isExisting();
    }
    get headerContentRightContentNotCustom() {
      let path = 'div[contains(@class, "ux-tree-list-item-header__content-right-content")]';
      return this.alabelCO.currentPath + '/following-sibling::' + path;
    }
    get rightContentPlaceholderNotCustom() {
      let path = '//div[contains(@class, "ux-tree-list-item-header__content-right-content-sub")]';
      return this.headerContentRightContentNotCustom + path;
    }
    get headerContentExpandToggleWrapperNotCustom() {
      let path = '//div[contains(@class, "ux-tree-list-item-header__content-expand-toggle-wrapper")]';
      return this.headerContentRightContentNotCustom + path;
    }
    get expandCollapseButtonNotCustomCO(){
      return new CoEuiButton(this.headerContentExpandToggleWrapperNotCustom);
    }
    get collapseIconNotCustomCO(){
      return new CoEuiIconSvg(this.expandCollapseButtonNotCustomCO).byAttributeContains('icon', 'eui-chevron-up');
    }
    async isExpandedNotCustom(){
      return await (await this.collapseIconNotCustomCO.element()).isExisting();
    }
    get expandIconNotCustomCO(){
      return new CoEuiIconSvg(this.expandCollapseButtonNotCustomCO).byAttributeContains('icon', 'eui-chevron-forward');
    }
    get customDetailContent() {
      let path = '//div[contains(@class, "ux-tree-list-item-header__details-content")]';
      return this.header + path;
    }
    async hasCustomDetailContent() {
      return await (await $(this.customDetailContentPlaceholder)).isExisting();
    }
    get customDetailContentPlaceholder() {
      let path = '//uxtreelistitemdetailscontent';
      return this.header + path;
    }
    get customSubContainerContentPlaceholder() {
      let path = '//uxtreelistitemsubcontainercontent';
      return this.header + path;
    }
    async hasCustomSubContainerContentPlaceholder() {
      return await (await $(this.customSubContainerContentPlaceholder)).isExisting();
    }
    async isExpanded() {
      return await elementAttributeContains(this.headerContent, 'aria-expanded', 'true');
    }
}
