import Component  from '../component.js';
import InputComponent from '../input.js';
import DivComponent from '../div.js';
import CoEuiIconSvg from './eui-icon-svg.js';

export default class CoEuiSlideToggle extends Component {

  constructor(parent) {
    let selector = 'eui-slide-toggle';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-slide-toggle/eui-slide-toggle.component.html?at=master
  }
  get containerCO() {
    return new DivComponent(this.currentPath).addPredicateClassContains('eui-slide-toggle__container');
  }
  async isContainerDisabled() {
    return await (await $(this.containerCO.currentPath + '/self::*[contains(@class,"eui-slide-toggle__container--disabled")]')).isExisting();
  }
  get inputCO() {
    return new InputComponent(this.containerCO).addPredicateClassContains('eui-u-display-hidden');
  }
  async isInputChecked() {
    return await (await $(this.inputCO.currentPath + '[@checked="true"]')).isExisting();
  }
  get toggleTrackCO() {
    return new DivComponent(this.containerCO).addPredicateClassContains('eui-slide-toggle__track');
  }
  async isToggleTrackChecked() {
    return await (await $(this.toggleTrackCO.currentPath + '/self::*[contains(@class,"eui-slide-toggle__track--on")]')).isExisting();
  }
  get toggleHandlerCO() {
    return new DivComponent(this.containerCO).addPredicateClassContains('eui-slide-toggle__handler');
  }
  async isToggleHandlerChecked() {
    return await (await $(this.toggleHandlerCO.currentPath + '/self::*[contains(@class,"eui-slide-toggle__handler--on")]')).isExisting();
  }
  get iconToggleHandlerCO() {
    return new CoEuiIconSvg(this.toggleHandlerCO);
  }
}


