import Component  from '../component.js'
import CoUxChip from './ux-chip.js'

export default class CoEuiChipsList extends Component {
    constructor(parent) {
      let selector = 'eui-chip-list[@data-e2e = "eui-chip-list"]';
      super(parent, selector);
    }
    get chipListContainer() {
      let path = '//div[contains(@class, "eui-chip-list-container")]';
      return this.currentPath + path;
    }
    get euiChipListWrapper() {
      let path = '//div[contains(@class, "eui-chip-list-wrapper")]';
      return this.chipListContainer + path;
    }
    get chipList() {
      let path = '//mat-chip-list[contains(@class, "mat-chip-list")]';
      return this.euiChipListWrapper + path;
    }
    get matChipListWrapper() {
      let path = '//div[contains(@class, "mat-chip-list-wrapper")]';
      return this.euiChipListWrapper + path;
    }
    get chipCO() {
      return new CoUxChip(this.matChipListWrapper);
    }
    async chipCount() {
      let list = await (await this.chipCO.elementList());
      return await list.length;
    }
    get expandButtonWrapper() {
      let path = '//div[contains(@class, "eui-chip-list__expand-button-wrapper")]';
      return this.chipListContainer + path;
    }
    get expandButton() {
      return new CoEuiButton(this.expandButtonWrapper);
    }
    async isExpanded() {
      let cl = await (await $(this.expandButton.buttonIcon)).getAttribute('class');
      if (cl.includes('eui-icon-angle-right')) {
         return false;
      } else if (cl.includes('eui-icon-angle-left')) {
         return true;
      }
    }
    async isDragAndDrop() {
      let cl = await(await $(this.chipList)).getAttribute('class');
      if (cl.includes('cdk-drop-list-disabled')) {
         return false;
      } else {
         return true;
      }
    }
}


