import AComponent from '../a.js';
import Component  from '../component.js';
import DivComponent from '../div.js';
import SpanComponent from '../span.js';
import CoEuiButton from './eui-button.js'
import CoEuiIcon from './eui-icon.js';
import CoEuiIconSvg from './eui-icon-svg.js';


export default class CoEuiFilePreview extends Component {
    constructor(parent) {
        let selector = 'eui-file-preview';
        super(parent, selector);
        //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-file-upload/file-preview/file-preview.component.html
    }

    get fileUploadPreviewDivCO() {
        return new DivComponent(this.currentPath).addPredicateAttributeContains('class', 'file-upload__preview');
    }
    // file-upload__preview__image
    get fileUploadPreviewImageDivCO() {
        return new DivComponent(this.fileUploadPreviewDivCO).addPredicateAttributeContains('class', 'file-upload__preview__image');
    }
    async hasPreviewAsImage() {
        return await (await this.fileUploadPreviewImageDivCO.element()).isExisting();
    }
    get image() {
        return this.fileUploadPreviewImageDivCO.currentPath + '//img';
    }
    async hasImage() {
        return await (await $(this.image)).isExisting();
    }
    get previewAsImageSpanCO() {
        return new SpanComponent(this.fileUploadPreviewImageDivCO).addPredicateAttributeContains('class', 'eui-icon-color');
    }
    async hasColorImage() {
        return await (await this.previewAsImageSpanCO.element()).isExisting();
    }
    get loadingCoatainerDivCO() {
        return new DivComponent(this.fileUploadPreviewImageDivCO).addPredicateAttributeContains('class', 'loading-coatainer');
    }
    async isLoading() {
        return await (await this.loadingCoatainerDivCO.element()).isExisting();
    }
    get spinnerEuiIconCO() {
        return new CoEuiIcon(this.loadingCoatainerDivCO).addPredicateAttributeContains('class', 'eui-icon-spinner');
    }

    // file-upload__preview__icon
    get fileUploadPreviewIconDivCO() {
        return new DivComponent(this.fileUploadPreviewDivCO).addPredicateAttributeContains('class', 'file-upload__preview__icon');
    }
    async hasPreviewAsIcon() {
        return await (await this.fileUploadPreviewIconDivCO.element()).isExisting();
    }
    get previewAsIconSpanCO() {
        return new SpanComponent(this.fileUploadPreviewIconDivCO).addPredicateAttributeContains('class', 'eui-icon-color');
    }

    // file-upload__preview__filename
    get fileUploadPreviewFilenameDivCO() {
        return new DivComponent(this.fileUploadPreviewDivCO).addPredicateAttributeContains('class', 'file-upload__preview__filename');
    }
    async isFilenameDisplayed() {
        return await (await this.fileUploadPreviewFilenameDivCO.element()).isExisting();
    }
    get previewFilenameACO() {
        return new AComponent(this.fileUploadPreviewFilenameDivCO);
    }
    async isItemsClickable() {
        return await (await this.previewFilenameACO.element()).isExisting();
    }

    // file-upload__preview__filesize
    get fileUploadPreviewFilesizeDivCO() {
        return new DivComponent(this.fileUploadPreviewDivCO).addPredicateAttributeContains('class', 'file-upload__preview__filesize');
    }
    async isFilesizeDisplayed() {
        return await (await this.fileUploadPreviewFilesizeDivCO.element()).isExisting();
    }

    // file-upload__preview__filetype
    get fileUploadPreviewFiletypeDivCO() {
        return new DivComponent(this.fileUploadPreviewDivCO).addPredicateAttributeContains('class', 'file-upload__preview__filetype');
    }
    async isFiletypeDisplayed() {
        return await (await this.fileUploadPreviewFiletypeDivCO.element()).isExisting();
    }

    // file-upload__preview__actions
    get fileUploadPreviewActionsDivCO() {
        return new DivComponent(this.fileUploadPreviewDivCO).addPredicateAttributeContains('class', 'file-upload__preview__actions');
    }
    // file-upload__preview__actions-container
    get fileUploadPreviewActionsContainerDivCO() {
        return new DivComponent(this.fileUploadPreviewActionsDivCO).addPredicateAttributeContains('class', 'file-upload__preview__actions-container');
    }
    get fileUploadRemoveBtnCO() {
        return new CoEuiButton(this.fileUploadPreviewActionsContainerDivCO);
    }
    get closeIconSvgCO() {
        return new CoEuiIconSvg(this.fileUploadRemoveBtnCO).addPredicateAttributeContains('icon', 'eui-close');
    }
}


