import * as React from "react";
import * as PropTypes from "prop-types";
import Linkify from "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));
};
export default function RichText(props) {
    var lines = props.text.split("\n");
    return (React.createElement(Linkify, { 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))); }))));
}
RichText.propTypes = {
    text: PropTypes.string.isRequired,
};
