"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var timestamp_1 = require("../timestamp");
var Renderables_1 = require("../Renderables");
var node_1 = require("../../support/node");
var Specification_1 = require("../../support/Specification");
/**
 * Implementation of the 'form' markup element.
 * A form HTML element is created and the class
 * lto-form is added to allow CSS manipulations.
 *
 * @see {@link IRenderable}
 * @see {@link IStackeable}
 * @see {@link Submit}
 */
var Form = /** @class */ (function () {
    function Form(message) {
        this.spec = message;
    }
    /**
     * @inheritDoc
     */
    Form.prototype.render = function (renderer, isNested) {
        var _this = this;
        var form = node_1.default("form");
        new Specification_1.Specification(this.spec).initNode(form, "lto-form");
        form.setAriaLabel(this.spec.ariaLabel);
        // this prevents a page reload when pressing "enter" and thus submitting the form
        form.unwrap().onsubmit = function () { return false; };
        form.unwrap().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 form.unwrap().appendChild(x); }); });
        isNested && form.addClasses('lto-nested');
        return form.unwrap();
    };
    return Form;
}());
exports.Form = Form;
Renderables_1.default.register("form", Form);
//# sourceMappingURL=index.js.map