var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { ComponentBase, EJComponentDecorator, getProps, gh, isExecute } from '@syncfusion/ej2-vue-base';
import { isNullOrUndefined, getValue } from '@syncfusion/ej2-base';
import { FileManager } from '@syncfusion/ej2-filemanager';
import { Options } from 'vue-class-component';
export var properties = ['isLazyUpdate', 'plugins', 'ajaxSettings', 'allowDragAndDrop', 'allowMultiSelection', 'contextMenuSettings', 'cssClass', 'detailsViewSettings', 'enableHtmlSanitizer', 'enablePersistence', 'enableRtl', 'height', 'locale', 'navigationPaneSettings', 'path', 'popupTarget', 'rootAliasName', 'searchSettings', 'selectedItems', 'showFileExtension', 'showHiddenItems', 'showThumbnail', 'sortBy', 'sortOrder', 'toolbarSettings', 'uploadSettings', 'view', 'virtualizationSettings', 'width', 'beforeDownload', 'beforeImageLoad', 'beforePopupClose', 'beforePopupOpen', 'beforeSend', 'created', 'destroyed', 'failure', 'fileDragStart', 'fileDragStop', 'fileDragging', 'fileDropped', 'fileLoad', 'fileOpen', 'fileSelect', 'fileSelection', 'menuClick', 'menuOpen', 'popupClose', 'popupOpen', 'success', 'toolbarClick', 'toolbarCreate', 'uploadListCreate'];
export var modelProps = [];
export var testProp = getProps({ props: properties });
export var props = testProp[0];
export var watch = testProp[1];
export var emitProbs = Object.keys(watch);
emitProbs.push('modelchanged', 'update:modelValue');
for (var _i = 0, modelProps_1 = modelProps; _i < modelProps_1.length; _i++) {
    var props_1 = modelProps_1[_i];
    emitProbs.push('update:' + props_1);
}
/**
 * Represents the Essential JS 2 VueJS FileManager Component.
 * ```vue
 * <ejs-filemanager showThumbnail='false'></ejs-filemanager>
 * ```
 */
var FileManagerComponent = /** @class */ (function (_super) {
    __extends(FileManagerComponent, _super);
    function FileManagerComponent() {
        var _this = _super.call(this, arguments) || this;
        _this.propKeys = properties;
        _this.models = modelProps;
        _this.hasChildDirective = false;
        _this.hasInjectedModules = true;
        _this.tagMapper = {};
        _this.tagNameMapper = {};
        _this.isVue3 = !isExecute;
        _this.ej2Instances = new FileManager({});
        _this.bindProperties();
        _this.ej2Instances._setProperties = _this.ej2Instances.setProperties;
        _this.ej2Instances.setProperties = _this.setProperties;
        _this.ej2Instances.clearTemplate = _this.clearTemplate;
        _this.updated = _this.updated;
        return _this;
    }
    FileManagerComponent.prototype.clearTemplate = function (templateNames) {
        if (!templateNames) {
            templateNames = Object.keys(this.templateCollection || {});
        }
        if (templateNames.length && this.templateCollection) {
            for (var _i = 0, templateNames_1 = templateNames; _i < templateNames_1.length; _i++) {
                var tempName = templateNames_1[_i];
                var elementCollection = this.templateCollection[tempName];
                if (elementCollection && elementCollection.length) {
                    for (var _a = 0, elementCollection_1 = elementCollection; _a < elementCollection_1.length; _a++) {
                        var ele = elementCollection_1[_a];
                        var destroy = getValue('__vue__.$destroy', ele);
                        if (destroy) {
                            ele.__vue__.$destroy();
                        }
                        if (ele.innerHTML) {
                            ele.innerHTML = '';
                        }
                    }
                    delete this.templateCollection[tempName];
                }
            }
        }
    };
    FileManagerComponent.prototype.setProperties = function (prop, muteOnChange) {
        var _this = this;
        if (this.isVue3) {
            this.models = !this.models ? this.ej2Instances.referModels : this.models;
        }
        if (this.ej2Instances && this.ej2Instances._setProperties) {
            this.ej2Instances._setProperties(prop, muteOnChange);
        }
        if (prop && this.models && this.models.length) {
            Object.keys(prop).map(function (key) {
                _this.models.map(function (model) {
                    if ((key === model) && !(/datasource/i.test(key))) {
                        if (_this.isVue3) {
                            _this.ej2Instances.vueInstance.$emit('update:' + key, prop[key]);
                        }
                        else {
                            _this.$emit('update:' + key, prop[key]);
                            _this.$emit('modelchanged', prop[key]);
                        }
                    }
                });
            });
        }
    };
    FileManagerComponent.prototype.render = function (createElement) {
        var h = !isExecute ? gh : createElement;
        var slots = null;
        if (!isNullOrUndefined(this.$slots.default)) {
            slots = !isExecute ? this.$slots.default() : this.$slots.default;
        }
        return h('div', slots);
    };
    FileManagerComponent.prototype.custom = function () {
        this.updated();
    };
    FileManagerComponent.prototype.clearSelection = function () {
        return this.ej2Instances.clearSelection();
    };
    FileManagerComponent.prototype.createFolder = function (name) {
        return this.ej2Instances.createFolder(name);
    };
    FileManagerComponent.prototype.deleteFiles = function (ids) {
        return this.ej2Instances.deleteFiles(ids);
    };
    FileManagerComponent.prototype.disableMenuItems = function (items) {
        return this.ej2Instances.disableMenuItems(items);
    };
    FileManagerComponent.prototype.disableToolbarItems = function (items) {
        return this.ej2Instances.disableToolbarItems(items);
    };
    FileManagerComponent.prototype.downloadFiles = function (ids) {
        return this.ej2Instances.downloadFiles(ids);
    };
    FileManagerComponent.prototype.enableToolbarItems = function (items) {
        return this.ej2Instances.enableToolbarItems(items);
    };
    FileManagerComponent.prototype.filterFiles = function (filterData) {
        return this.ej2Instances.filterFiles(filterData);
    };
    FileManagerComponent.prototype.getMenuItemIndex = function (item) {
        return this.ej2Instances.getMenuItemIndex(item);
    };
    FileManagerComponent.prototype.getSelectedFiles = function () {
        return this.ej2Instances.getSelectedFiles();
    };
    FileManagerComponent.prototype.getToolbarItemIndex = function (item) {
        return this.ej2Instances.getToolbarItemIndex(item);
    };
    FileManagerComponent.prototype.openFile = function (id) {
        return this.ej2Instances.openFile(id);
    };
    FileManagerComponent.prototype.refreshFiles = function () {
        return this.ej2Instances.refreshFiles();
    };
    FileManagerComponent.prototype.refreshLayout = function () {
        return this.ej2Instances.refreshLayout();
    };
    FileManagerComponent.prototype.renameFile = function (id, name) {
        return this.ej2Instances.renameFile(id, name);
    };
    FileManagerComponent.prototype.selectAll = function () {
        return this.ej2Instances.selectAll();
    };
    FileManagerComponent.prototype.uploadFiles = function () {
        return this.ej2Instances.uploadFiles();
    };
    FileManagerComponent = __decorate([
        EJComponentDecorator({
            props: properties
        }, isExecute)
        ,Options({
            props: props,
            watch: watch,
            emits: emitProbs,
            provide: function provide() {
                return {
                    custom: this.custom
                };
            }
        })
    ], FileManagerComponent);
    return FileManagerComponent;
}(ComponentBase));
export { FileManagerComponent };
export var FileManagerPlugin = {
    name: 'ejs-filemanager',
    install: function (Vue) {
        Vue.component(FileManagerPlugin.name, FileManagerComponent);
    }
};
