import CoEuiInputCheckbox from './eui-input-checkbox.js';
import Component from '../component.js';
import DivComponent from '../div.js';
import ThComponent from '../th.js';

export default class CoEuiTableSelectableHeader extends Component {
    constructor(parent) {
      let selector = 'tr[@isSelectableHeader]';
      super(parent, selector);
      //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-table/selectable-header/eui-table-selectable-header.component.html?at=master
    }
    get cellSelectCO(){
      return new ThComponent(this.currentPath).byClassContains('eui-table__cell-select');
    }
    async isSelectableHeader(){
      return await (await this.cellSelectCO.element()).isExisting();
    }
    get checkboxContainerCO(){
      return new DivComponent(this.cellSelectCO).addPredicateClassContains('eui-table__cell-select-checkbox-container');
    }
    get uncheckedCheckboxCO(){
      return new CoEuiInputCheckbox(this.checkboxContainerCO).byAttributeContains('aria-label', 'Unchecked');
    }
    async isUnchecked(){
      return await (await this.uncheckedCheckboxCO.element()).isExisting();
    }
    get indeterminateCheckboxCO(){
      return new CoEuiInputCheckbox(this.checkboxContainerCO).byAttributeContains('aria-label', 'Indeterminate');
    }
    async isCheckedIndeterminate(){
      return await (await this.indeterminateCheckboxCO.element()).isExisting();
    }
    get checkedCheckboxCO(){
      return new CoEuiInputCheckbox(this.checkboxContainerCO).byAttributeEquals('aria-label', 'Checked');
    }
    async isCheckedAndNotCheckedIndeterminate(){
      return await (await this.checkedCheckboxCO.element()).isExisting();
    }
}