"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.typeGenerator = exports.saveTypesData = exports.saveNewTypesData = exports.getTypesData = exports.getData = void 0;
const data = {};
const getData = () => {
    return data;
};
exports.getData = getData;
const getTypesData = (target) => {
    var _a;
    const values = data[(target === null || target === void 0 ? void 0 : target.name) || ((_a = target === null || target === void 0 ? void 0 : target.constructor) === null || _a === void 0 ? void 0 : _a.name)];
    if (!values)
        return {};
    return values;
};
exports.getTypesData = getTypesData;
const saveNewTypesData = (attributes, target) => {
    data[target.constructor.name] = attributes;
};
exports.saveNewTypesData = saveNewTypesData;
const saveTypesData = (target, propertyName, value) => {
    const types = (0, exports.getTypesData)(target);
    types[propertyName] = value;
    (0, exports.saveNewTypesData)(types, target);
};
exports.saveTypesData = saveTypesData;
const typeGenerator = (data) => (...options) => {
    return (target, propertyName, propertyDescriptor) => {
        if (target !== undefined) {
            const type = data(...options);
            (0, exports.saveTypesData)(target, propertyName, type);
            if (propertyDescriptor) {
                propertyDescriptor.value = type;
            }
        }
        else {
            return data(...options);
        }
    };
};
exports.typeGenerator = typeGenerator;
//# sourceMappingURL=typeGenerator.js.map