import Renderables from '../Renderables';
import { Timestamp } from '../timestamp';
/**
 * Implementation of the 'block' markup element. A div HTML element
 * is created and the and the classes lto-block is added to
 * allow CSS modifications.
 *
 * @see {@link IRenderable}
 * @see {@link IStackeable}
 */
var Block = /** @class */ (function () {
    function Block(message) {
        this.spec = message;
    }
    /**
     * @inheritDoc
     */
    Block.prototype.render = function (renderer, isNested) {
        var _this = this;
        var position = this.spec.position || 'left';
        var block = document.createElement('div');
        block.classList.add('lto-block', "lto-" + position);
        block.setAttribute("name", this.spec.name || "");
        if (this.spec.id !== undefined) {
            block.id = this.spec.id;
        }
        if (this.spec.class !== undefined) {
            this.spec.class.split(" ").forEach(function (e) { return block.classList.add(e); });
        }
        block.appendChild(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 block.appendChild(x); }); });
        if (isNested) {
            block.classList.add('lto-nested');
        }
        return block;
    };
    return Block;
}());
export { Block };
Renderables.register("block", Block);
//# sourceMappingURL=index.js.map