import Component from '../../component.js'
import CoUxAtoolbarFilter from './ux-a-toolbar-filter.js'
import CoUxTreeNode from './ux-tree-node.js'
import { elementAttributeContains } from '../../../core/utils.js';

export default class CoUxTree extends Component {

  constructor(parent) {
    let selector = 'ux-tree';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/src/lib/ux-components/ux-tree/ux-tree.component.ts
  }
  get coUxAtoolbarFilter() {
    return new CoUxAtoolbarFilter(this.currentPath);
  }
  async hasSelectAll() {
    return await (await $(this.selectAllCheckbox)).isExisting();
  }
  get selectAllCheckbox()  {
    let path = '//span//input[contains(@class,"ux-input__checkbox")]';
    return this.currentPath + path;
  }
  get selectAllCheckboxLabel()  {
    let path = '//span//label[contains(@class,"ux-tree__node-checkbox-label")]';
    return this.currentPath + path;
  }
  async isIndeterminate() {
    return await elementAttributeContains(this.selectAllCheckboxLabel, 'class', 'checkbox-label-indeterminate');
  }
  get treeList() {
    let path = '/ul[@data-e2e="ux-tree"]'
    return this.currentPath + path;
  }
  get coUxTreeNode() {
    return new CoUxTreeNode(this.treeList);
  }
  async isHideLines() {
    return await elementAttributeContains(this.treeList, 'class', 'ux-tree--hidelines');
  }
  async isMultiselect() {
    return await elementAttributeContains(this.treeList, 'class', 'ux-tree--multiselect');
  }
  async hasOneLevel() {
    return await elementAttributeContains(this.treeList, 'class', 'ux-tree--onelevel');
  }
}


