import { Timestamp } from '../timestamp';
import Renderables from '../Renderables';
/**
 * 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 position = this.spec.position || 'left';
        var form = document.createElement('form');
        form.setAttribute("name", this.spec.name || "");
        form.classList.add('lto-form', "lto-" + position);
        if (this.spec.id !== undefined) {
            form.id = this.spec.id;
        }
        if (this.spec.class !== undefined) {
            this.spec.class.split(" ").forEach(function (e) { return form.classList.add(e); });
        }
        form.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 form.appendChild(x); }); });
        if (isNested) {
            form.classList.add('lto-nested');
        }
        return form;
    };
    return Form;
}());
export { Form };
Renderables.register("form", Form);
//# sourceMappingURL=index.js.map