import LabelComponent from '../../label.js'
import Component from '../../component.js'
import InputComponent from '../../input.js'

export default class MatSlideToggle extends Component {
  constructor(parent) {
      let selector = 'mat-slide-toggle';
      super(parent, selector);
      // https://github.com/angular/components/blob/master/src/material/slide-toggle/slide-toggle.html
  }

  get matMatSlideToggleLabelCO() {
    return new LabelComponent(this.currentPath).byAttributeContains('class', 'mat-slide-toggle-label');
  }

  get matMatSlideToggleBar() {
    return this.matMatSlideToggleLabelCO.currentPath + '//span[contains(@class,"mat-slide-toggle-bar")]';
  }

  get toggleInput() {
    return new InputComponent(this.matMatSlideToggleBar);
  }

  async isSelected() {
    return await this.toggleInput.isSelected();
  }

  get thumbContainer() {
    return this.matMatSlideToggleBar + '//span[contains(@class,"mat-slide-toggle-thumb-container")]';
  }

  async select() {
    await (await $(this.thumbContainer)).click();
  }

  get thumb() {
    return this.thumbContainer + '//span[contains(@class,"mat-slide-toggle-thumb")]';
  }

  get thumbRipple(){
    return this.thumbContainer + '//span[contains(@class,"mat-slide-toggle-ripple")]';
  }

  get content(){
    return this.matMatSlideToggleLabelCO.currentPath + '//span[contains(@class,"mat-slide-toggle-content")]';
  }

}
