"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Container = /** @class */ (function () {
    function Container() {
        this._boundConstructors = {};
        this._instances = {};
    }
    Container.prototype.bind = function (token, constructor) {
        var args = [];
        for (var _i = 2; _i < arguments.length; _i++) {
            args[_i - 2] = arguments[_i];
        }
        if (this._boundConstructors.hasOwnProperty(token)) {
            delete this._boundConstructors[token];
        }
        if (this._instances.hasOwnProperty(token)) {
            delete this._instances[token];
        }
        this._boundConstructors[token] = {
            constructor: constructor,
            args: args
        };
    };
    Container.prototype.get = function (token) {
        if (!this._instances.hasOwnProperty(token)) {
            var data = this._boundConstructors[token];
            this._instances[token] = new ((_a = data.constructor).bind.apply(_a, [void 0, this].concat(data.args)))();
        }
        return this._instances[token];
        var _a;
    };
    Container.prototype.getConstructor = function (token) {
        if (!this._boundConstructors.hasOwnProperty(token)) {
            throw new Error("Constructor token " + token + " not bound.");
        }
        return this._boundConstructors[token].constructor;
    };
    return Container;
}());
exports.Container = Container;
//# sourceMappingURL=container.js.map