"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = function(exports1, definition) {
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
(()=>{
    __webpack_require__.r = function(exports1) {
        if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    CollectionPlugin: ()=>CollectionPlugin
});
const Plugin_js_namespaceObject = require("../application/Plugin.js");
const DataSource_js_namespaceObject = require("../data-source/data-source/DataSource.js");
const DataSourceManager_js_namespaceObject = require("../data-source/data-source/DataSourceManager.js");
const index_js_namespaceObject = require("./interfaces/index.js");
const InheritanceCollectionMixin_js_namespaceObject = require("./mixins/InheritanceCollectionMixin.js");
const external_templates_index_js_namespaceObject = require("./templates/index.js");
const xlsx_js_namespaceObject = require("./templates/xlsx.js");
class MainDataSource extends DataSource_js_namespaceObject.DataSource {
    async getDataSource() {
        var _service_data;
        const service = await this.app.apiClient.request({
            resource: 'collections',
            action: 'list',
            params: {
                paginate: false,
                appends: [
                    'fields',
                    'category'
                ],
                filter: {},
                sort: [
                    'sort'
                ]
            }
        });
        const collections = (null == service ? void 0 : null === (_service_data = service.data) || void 0 === _service_data ? void 0 : _service_data.data) || [];
        return {
            collections
        };
    }
}
class CollectionPlugin extends Plugin_js_namespaceObject.Plugin {
    async load() {
        this.dataSourceManager.addCollectionMixins([
            InheritanceCollectionMixin_js_namespaceObject.InheritanceCollectionMixin
        ]);
        this.addFieldInterfaces();
        this.addCollectionTemplates();
        this.addFieldInterfaces();
        this.addFieldInterfaceGroups();
        this.dataSourceManager.addDataSource(MainDataSource, {
            key: DataSourceManager_js_namespaceObject.DEFAULT_DATA_SOURCE_KEY,
            displayName: DataSourceManager_js_namespaceObject.DEFAULT_DATA_SOURCE_TITLE
        });
    }
    addFieldInterfaceGroups() {
        this.dataSourceManager.addFieldInterfaceGroups({
            basic: {
                label: '{{t("Basic")}}'
            },
            choices: {
                label: '{{t("Choices")}}'
            },
            media: {
                label: '{{t("Media")}}'
            },
            datetime: {
                label: '{{t("Date & Time")}}'
            },
            relation: {
                label: '{{t("Relation")}}'
            },
            advanced: {
                label: '{{t("Advanced type")}}'
            },
            systemInfo: {
                label: '{{t("System info")}}'
            },
            others: {
                label: '{{t("Others")}}'
            }
        });
    }
    addFieldInterfaces() {
        this.dataSourceManager.addFieldInterfaces([
            index_js_namespaceObject.CheckboxFieldInterface,
            index_js_namespaceObject.CheckboxGroupFieldInterface,
            index_js_namespaceObject.ChinaRegionFieldInterface,
            index_js_namespaceObject.CollectionSelectFieldInterface,
            index_js_namespaceObject.ColorFieldInterface,
            index_js_namespaceObject.CreatedAtFieldInterface,
            index_js_namespaceObject.CreatedByFieldInterface,
            index_js_namespaceObject.DatetimeFieldInterface,
            index_js_namespaceObject.EmailFieldInterface,
            index_js_namespaceObject.IconFieldInterface,
            index_js_namespaceObject.IdFieldInterface,
            index_js_namespaceObject.InputFieldInterface,
            index_js_namespaceObject.IntegerFieldInterface,
            index_js_namespaceObject.JsonFieldInterface,
            index_js_namespaceObject.LinkToFieldInterface,
            index_js_namespaceObject.M2MFieldInterface,
            index_js_namespaceObject.M2OFieldInterface,
            index_js_namespaceObject.MarkdownFieldInterface,
            index_js_namespaceObject.MultipleSelectFieldInterface,
            index_js_namespaceObject.NumberFieldInterface,
            index_js_namespaceObject.O2MFieldInterface,
            index_js_namespaceObject.O2OFieldInterface,
            index_js_namespaceObject.OHOFieldInterface,
            index_js_namespaceObject.OBOFieldInterface,
            index_js_namespaceObject.PasswordFieldInterface,
            index_js_namespaceObject.PercentFieldInterface,
            index_js_namespaceObject.PhoneFieldInterface,
            index_js_namespaceObject.RadioGroupFieldInterface,
            index_js_namespaceObject.RichTextFieldInterface,
            index_js_namespaceObject.SelectFieldInterface,
            index_js_namespaceObject.SubTableFieldInterface,
            index_js_namespaceObject.TableoidFieldInterface,
            index_js_namespaceObject.TextareaFieldInterface,
            index_js_namespaceObject.TimeFieldInterface,
            index_js_namespaceObject.UpdatedAtFieldInterface,
            index_js_namespaceObject.UpdatedByFieldInterface,
            index_js_namespaceObject.UrlFieldInterface,
            index_js_namespaceObject.SortFieldInterface,
            index_js_namespaceObject.UUIDFieldInterface,
            index_js_namespaceObject.NanoidFieldInterface,
            index_js_namespaceObject.UnixTimestampFieldInterface
        ]);
    }
    addCollectionTemplates() {
        this.dataSourceManager.addCollectionTemplates([
            external_templates_index_js_namespaceObject.GeneralCollectionTemplate,
            external_templates_index_js_namespaceObject.ExpressionCollectionTemplate,
            external_templates_index_js_namespaceObject.SqlCollectionTemplate,
            external_templates_index_js_namespaceObject.TreeCollectionTemplate,
            external_templates_index_js_namespaceObject.ViewCollectionTemplate,
            external_templates_index_js_namespaceObject.ImportCollectionTemplate,
            xlsx_js_namespaceObject.ImportXlsxTemplate
        ]);
    }
}
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
