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 SchemaInitializerManager {
    add() {
        for(var _len = arguments.length, schemaInitializerList = new Array(_len), _key = 0; _key < _len; _key++)schemaInitializerList[_key] = arguments[_key];
        schemaInitializerList.forEach((schemaInitializer)=>{
            this.schemaInitializers[schemaInitializer.name] = schemaInitializer;
            if (Array.isArray(this.actionList[schemaInitializer.name])) {
                this.actionList[schemaInitializer.name].forEach((item)=>{
                    schemaInitializer[item.type](item.itemName, item.data);
                });
                this.actionList[schemaInitializer.name] = void 0;
            }
        });
    }
    addItem(schemaInitializerName, itemName, data) {
        const schemaInitializer = this.get(schemaInitializerName);
        if (schemaInitializer) schemaInitializer.add(itemName, data);
        else {
            if (!this.actionList[schemaInitializerName]) this.actionList[schemaInitializerName] = [];
            this.actionList[schemaInitializerName].push({
                type: 'add',
                itemName: itemName,
                data
            });
        }
    }
    get(name) {
        return this.schemaInitializers[name];
    }
    getAll() {
        return this.schemaInitializers;
    }
    has(name) {
        return !!this.get(name);
    }
    remove(name) {
        delete this.schemaInitializers[name];
    }
    removeItem(schemaInitializerName, itemName) {
        const schemaInitializer = this.get(schemaInitializerName);
        if (schemaInitializer) schemaInitializer.remove(itemName);
        else {
            if (!this.actionList[schemaInitializerName]) this.actionList[schemaInitializerName] = [];
            this.actionList[schemaInitializerName].push({
                type: 'remove',
                itemName: itemName
            });
        }
    }
    constructor(_schemaInitializers = [], app){
        _define_property(this, "_schemaInitializers", void 0);
        _define_property(this, "app", void 0);
        _define_property(this, "schemaInitializers", void 0);
        _define_property(this, "actionList", void 0);
        this._schemaInitializers = _schemaInitializers;
        this.app = app;
        this.schemaInitializers = {};
        this.actionList = {};
        this.app = app;
        this.add(..._schemaInitializers);
    }
}
export { SchemaInitializerManager };
