"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AdminField = exports.AdminUI = exports.EntityMetadata = exports.AdminType = void 0;
var AdminType;
(function (AdminType) {
    AdminType[AdminType["Id"] = 1] = "Id";
    AdminType[AdminType["String"] = 2] = "String";
    AdminType[AdminType["Text"] = 3] = "Text";
    AdminType[AdminType["Selection"] = 4] = "Selection";
    AdminType[AdminType["RichText"] = 5] = "RichText";
    AdminType[AdminType["Checkbox"] = 6] = "Checkbox";
    AdminType[AdminType["Radio"] = 7] = "Radio";
    AdminType[AdminType["Number"] = 8] = "Number";
    AdminType[AdminType["Date"] = 9] = "Date";
    AdminType[AdminType["Table"] = 10] = "Table";
    AdminType[AdminType["Expanded"] = 11] = "Expanded";
    AdminType[AdminType["Time"] = 12] = "Time";
    AdminType[AdminType["Color"] = 13] = "Color";
    AdminType[AdminType["Media"] = 14] = "Media";
    AdminType[AdminType["AjaxSelection"] = 15] = "AjaxSelection";
    AdminType[AdminType["DateTime"] = 16] = "DateTime";
    AdminType[AdminType["ActionButton"] = 17] = "ActionButton";
    AdminType[AdminType["Currency"] = 18] = "Currency";
    AdminType[AdminType["ExpandedAndSelection"] = 19] = "ExpandedAndSelection";
    AdminType[AdminType["CustomInclude"] = 20] = "CustomInclude";
})(AdminType = exports.AdminType || (exports.AdminType = {}));
var EntityMetadata = /** @class */ (function () {
    function EntityMetadata() {
        this.classParameters = {};
        this.fields = {};
    }
    return EntityMetadata;
}());
exports.EntityMetadata = EntityMetadata;
var currentEntity = new EntityMetadata();
function AdminUI(name, params) {
    return function (target) {
        currentEntity.name = name;
        if (params) {
            currentEntity.classParameters = params;
        }
        target.adminUI = currentEntity;
        currentEntity = new EntityMetadata();
    };
}
exports.AdminUI = AdminUI;
function AdminField(params) {
    return function (target, key) {
        var type = Reflect.getMetadata('design:type', target, key);
        if (!params.selfType) {
            if (!type) {
                throw new Error("AdminUI: Unable to understand the current type. Please add the 'selfType' parameter for the '" +
                    key +
                    "' field.");
            }
            if (type.name == 'Promise') {
                throw new Error("AdminUI: Please specify the Promise type for the '" +
                    key +
                    "' field.");
            }
            if (type.name == 'Array') {
                throw new Error("AdminUI: Please specify the Arrays type for the '" +
                    key +
                    "' field.");
            }
            params.selfType = type.name;
        }
        currentEntity.fields[key] = params;
    };
}
exports.AdminField = AdminField;
