import Component from '../../component.js'

export default class CoUxAiconToggle extends Component {
    constructor(parent) {
      let selector = 'ux-a-icon-toggle';
      super(parent, selector);
      //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/src/lib/ux-components/atomic/ux-a-icon-toggle/ux-a-icon-toggle.component.html?at=support/10.x
    }
    get iconToggle() {
      let path = '//div[@data-e2e="ux-a-icon-toggle"]';
      return this.currentPath + path;

    }
    get icon() {
      let path = '//span[contains(@class,"ux-a-icon__icon")]';
      return this.iconToggle + path;
    }
    async isChecked() {
      let at = await (await $(this.iconToggle)).getAttribute('aria-checked');
      if (at === 'true') {
         return true;
      } else if (at === 'false') {
         return false;
      }
    }
    async isReadOnly() {
      let cl = await (await $(this.icon)).getAttribute('class');
      if (!cl.includes('ux-u-cursor-pointer')) {
         return true;
      } else {
         return false;
      }
    }
}


