function _define_property(obj, key, value) {
    if (key in obj) Object.defineProperty(obj, key, {
        value: value,
        enumerable: true,
        configurable: true,
        writable: true
    });
    else obj[key] = value;
    return obj;
}
class CollectionFieldInterfaceManager {
    addFieldInterfaces() {
        let fieldInterfaceClasses = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [];
        const newCollectionFieldInterfaces = fieldInterfaceClasses.reduce((acc, Interface)=>{
            const instance = new Interface(this);
            acc[instance.name] = instance;
            return acc;
        }, {});
        Object.assign(this.collectionFieldInterfaceInstances, newCollectionFieldInterfaces);
    }
    getFieldInterface(name) {
        return this.collectionFieldInterfaceInstances[name];
    }
    getFieldInterfaces(dataSourceType) {
        return Object.values(this.collectionFieldInterfaceInstances).filter((item)=>{
            if (!dataSourceType) return true;
            if (!item.supportDataSourceType && !item.notSupportDataSourceType) return true;
            if (item.supportDataSourceType) {
                var _item_supportDataSourceType;
                return null === (_item_supportDataSourceType = item.supportDataSourceType) || void 0 === _item_supportDataSourceType ? void 0 : _item_supportDataSourceType.includes(dataSourceType);
            }
            if (item.notSupportDataSourceType) {
                var _item_notSupportDataSourceType;
                return !(null === (_item_notSupportDataSourceType = item.notSupportDataSourceType) || void 0 === _item_notSupportDataSourceType ? void 0 : _item_notSupportDataSourceType.includes(dataSourceType));
            }
            return true;
        });
    }
    addFieldInterfaceGroups(groups) {
        Object.assign(this.collectionFieldGroups, groups);
    }
    getFieldInterfaceGroups() {
        return this.collectionFieldGroups;
    }
    getFieldInterfaceGroup(name) {
        return this.collectionFieldGroups[name];
    }
    constructor(fieldInterfaceClasses, fieldInterfaceGroups, dataSourceManager){
        _define_property(this, "dataSourceManager", void 0);
        _define_property(this, "collectionFieldInterfaceInstances", void 0);
        _define_property(this, "collectionFieldGroups", void 0);
        this.dataSourceManager = dataSourceManager;
        this.collectionFieldInterfaceInstances = {};
        this.collectionFieldGroups = {};
        this.addFieldInterfaces(fieldInterfaceClasses);
        this.addFieldInterfaceGroups(fieldInterfaceGroups);
    }
}
export { CollectionFieldInterfaceManager };
