"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var NinePatch_1 = require("./ninepatch/NinePatch");
var NinePatchPlugin = (function (_super) {
    tslib_1.__extends(NinePatchPlugin, _super);
    function NinePatchPlugin(pluginManager) {
        var _this = _super.call(this, pluginManager) || this;
        pluginManager.game.cache.addCustom("ninePatch");
        pluginManager.registerGameObject("ninePatch", _this.ninePatchFactory, _this.ninePatchCreator);
        return _this;
    }
    NinePatchPlugin.prototype.ninePatchFactory = function (x, y, width, height, key, frame, patchesConfig) {
        return this.scene.add.existing(new NinePatch_1.NinePatch(this.scene, x, y, width, height, key, frame, patchesConfig));
    };
    NinePatchPlugin.prototype.ninePatchCreator = function (config, addToScene) {
        if (config === undefined) {
            config = {};
        }
        var key = Phaser.Utils.Objects.GetAdvancedValue(config, "key", null);
        var frame = Phaser.Utils.Objects.GetAdvancedValue(config, "frame", null);
        var width = Phaser.Utils.Objects.GetAdvancedValue(config, "width", null);
        var height = Phaser.Utils.Objects.GetAdvancedValue(config, "height", null);
        var patchesConfig = Phaser.Utils.Objects.GetAdvancedValue(config, "patchesConfig", null);
        var ninePatch = new NinePatch_1.NinePatch(this.scene, 0, 0, width, height, key, frame, patchesConfig);
        if (addToScene !== undefined) {
            config.add = addToScene;
        }
        Phaser.GameObjects.BuildGameObject(this.scene, ninePatch, config);
        return ninePatch;
    };
    return NinePatchPlugin;
}(Phaser.Plugins.BasePlugin));
exports.NinePatchPlugin = NinePatchPlugin;
//# sourceMappingURL=NinePatchPlugin.js.map