"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FactoryManager = void 0;
var tslib_1 = require("tslib");
var common_1 = require("../common");
var defaultFactory = function (req) { return null; };
var FactoryManager = (function () {
    function FactoryManager(args) {
        this.grid = args.grid;
        this.factory = args.factory || defaultFactory;
    }
    FactoryManager.prototype.editor = function (args) {
        return this.render(tslib_1.__assign(tslib_1.__assign({}, args), { type: 'EDITOR' }));
    };
    FactoryManager.prototype.cell = function (args) {
        return this.render(tslib_1.__assign(tslib_1.__assign({}, args), { type: 'CELL' }));
    };
    FactoryManager.prototype.render = function (args) {
        var type = args.type, row = args.row, column = args.column;
        var key = common_1.coord.cell.toKey(column, row);
        var grid = this.grid;
        var props = common_1.util.toGridCellProps(args.cell ? args.cell.props : {});
        var data = tslib_1.__assign(tslib_1.__assign({}, args.cell), { props: props });
        var cell = { key: key, props: props, data: data };
        var view = props.view;
        var req = { type: type, grid: grid, cell: cell, view: view };
        return this.factory(req);
    };
    return FactoryManager;
}());
exports.FactoryManager = FactoryManager;
