"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LinkWrapper = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const LinkWrapper = ({ url, children, target }) => {
    const validUrl = url && buildValidUrl(url);
    return url ? ((0, jsx_runtime_1.jsx)("a", { href: validUrl, target: target, rel: "noreferrer", children: children })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children }));
};
exports.LinkWrapper = LinkWrapper;
function buildValidUrl(url) {
    const prefixes = [
        'http://',
        'https://',
        '/',
        'mailto:',
        'tel:',
        'file:',
        'ftp:',
        'javascript',
        '#'
    ];
    const protocolCheck = prefixes.some(prefix => url.startsWith(prefix));
    if (protocolCheck)
        return url;
    return `//${url}`;
}
