import Component  from '../component.js'
import { elementAttributeContains } from '../../core/utils.js'
import CoEuiIcon from './eui-icon.js'

export default class CoEuiTableSelectableHeader extends Component {
    constructor(parent) {
      let selector = 'th[contains(@class, "eui-table__cell-select")]';
      // 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=refs%2Fheads%2Fsupport/13.x
    }
    async isSelectableHeader(){
      return await (await $(this.currentPath)).isExisting();
    }
    get euiIconCO() {
      return new CoEuiIcon(this.currentPath);
    }

    async isCheckedIndeterminate(){
      return await (await $(this.euiIconCO.byAttributeContains('iconclass', 'eui-icon-checkbox-intermediate').currentPath)).isExisting();
    }

    async isChecked() {
      let cl = await (await $(this.euiIconCO.currentPath)).getAttribute('iconclass');
      if(await cl.includes('eui-icon-checkbox-outline')) {
        return false;
      } else {
        return true;
      }
    }
}


