"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var icon_1 = require("../icon");
var timestamp_1 = require("../timestamp");
var Renderables_1 = require("../Renderables");
/**
 * Implementation of the 'table' markup element.
 * A table HTML element is created and the class
 * lto-table is added to allow CSS manipulations.
 *
 * @see {@link IRenderable}
 * @see {@link IStackeable}
 * @see {@link Col}
 * @see {@link Row}
 */
var Table = /** @class */ (function () {
    function Table(spec) {
        this.spec = spec;
    }
    /**
     * @inheritDoc
     */
    Table.prototype.render = function (renderer, isNested) {
        var _this = this;
        var table = document.createElement('table');
        var position = this.spec.position || 'left';
        if (this.spec.id !== undefined) {
            table.id = this.spec.id;
        }
        if (this.spec.class !== undefined) {
            this.spec.class.split(" ").forEach(function (e) { return table.classList.add(e); });
        }
        table.classList.add('lto-table', "lto-" + position);
        if (!isNested) {
            table.appendChild(timestamp_1.Timestamp.render());
            var elements = (this.spec.elements || []).map(function (e) { return renderer.render(e, _this); });
            elements.forEach(function (e) { return e.forEach(function (x) { return table.appendChild(x); }); });
            table.appendChild(new icon_1.Icon(position).render());
        }
        else {
            table.classList.add("lto-nested");
            var elements = (this.spec.elements || []).map(function (e) { return renderer.render(e, _this); });
            elements.forEach(function (e) { return e.forEach(function (x) { return table.appendChild(x); }); });
        }
        return table;
    };
    return Table;
}());
exports.Table = Table;
Renderables_1.default.register("table", Table);
//# sourceMappingURL=index.js.map