"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var jsx_runtime_1 = require("react/jsx-runtime");
var link_1 = __importDefault(require("next/link"));
var base_path_1 = __importDefault(require("lib/base-path"));
var path_1 = require("path");
function A(props) {
    var href = props.href;
    if (href == null) {
        return (0, jsx_runtime_1.jsx)("a", __assign({}, copyWithout(props, new Set(["external"]))));
    }
    if (href.includes("://") || href.startsWith("mailto:")) {
        return ((0, jsx_runtime_1.jsx)("a", __assign({}, copyWithout(props, new Set(["external"])), { target: "_blank", rel: "noopener" })));
    }
    if (props.external) {
        var props2 = copyWithout(props, new Set(["external"]));
        if (!href.startsWith(base_path_1.default)) {
            // @ts-ignore
            props2.href = (0, path_1.join)(base_path_1.default, href);
        }
        return (0, jsx_runtime_1.jsx)("a", __assign({}, props2, { target: "_blank", rel: "noopener" }));
    }
    return ((0, jsx_runtime_1.jsx)(link_1.default, __assign({ href: href }, { children: (0, jsx_runtime_1.jsx)("a", __assign({}, copyWithout(props, new Set(["external", "href"])))) })));
}
exports.default = A;
function copyWithout(props, without) {
    var props2 = {};
    for (var key in props) {
        if (!without.has(key)) {
            props2[key] = props[key];
        }
    }
    return props2;
}
//# sourceMappingURL=A.js.map