"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var PropTypes = require("prop-types");
var react_linkify_1 = require("react-linkify");
// Customized to open links in new tabs
// Based on https://github.com/tasti/react-linkify/blob/master/src/decorators/defaultComponentDecorator.jsx
var componentDecorator = function (decoratedHref, decoratedText, key) {
    return (React.createElement("a", { href: decoratedHref, key: key, target: "_blank", rel: "noopener noreferrer" }, decoratedText));
};
function RichText(props) {
    var lines = props.text.split("\n");
    return (React.createElement(react_linkify_1.default, { componentDecorator: componentDecorator },
        React.createElement("span", null, lines.map(function (item, index) { return (React.createElement("span", { key: index },
            item,
            index < lines.length - 1 && React.createElement("br", null))); }))));
}
exports.default = RichText;
RichText.propTypes = {
    text: PropTypes.string.isRequired,
};
