"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Renderables_1 = require("../Renderables");
/**
 * Implementation of the 'link' markup element. An
 * a HTML element is created and the given attributes
 * for href and target are taken over from the markup. The
 * class lto-link is added to allow CSS manipulations.
 *
 * @see {@link IRenderable}
 */
var Link = /** @class */ (function () {
    function Link(spec) {
        this.spec = spec;
    }
    /**
     * @inheritDoc
     */
    Link.prototype.render = function (renderer, isNested) {
        var link = document.createElement('a');
        link.setAttribute('href', Link.decode(this.spec.value || ""));
        link.setAttribute('target', '_blank');
        link.classList.add('lto-link');
        if (this.spec.id !== undefined) {
            link.id = this.spec.id;
        }
        if (this.spec.class !== undefined) {
            this.spec.class.split(" ").forEach(function (e) { return link.classList.add(e); });
        }
        link.appendChild(document.createTextNode(this.spec.text || ""));
        return link;
    };
    Link.decode = function (input) {
        var txt = document.createElement("textarea");
        txt.innerHTML = input;
        return txt.value;
    };
    return Link;
}());
exports.Link = Link;
Renderables_1.default.register("link", Link);
//# sourceMappingURL=index.js.map