"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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
exports.__esModule = true;
exports.stringToUrl = exports.SideNavLink = exports.ComponentLink = void 0;
var react_1 = require("@chakra-ui/react");
var react_2 = __importStar(require("react"));
var history_1 = require("../history");
exports.ComponentLink = react_2["default"].memo(react_2.forwardRef(function (_a, ref) {
    var href = _a.href, props = __rest(_a, ["href"]);
    var colorMode = react_1.useColorMode().colorMode;
    var hoverColor = { light: 'gray.900', dark: 'whiteAlpha.900' };
    var activeColor = { light: 'gray.800', dark: 'gray.200' };
    // const activeBg = { light: 'yellow.100', dark: 'gray.700' }
    return (react_2["default"].createElement(NavLink, { href: href }, function (isActive) { return (react_2["default"].createElement(exports.SideNavLink, __assign({ ref: ref, href: href, "aria-current": isActive ? 'page' : undefined, _hover: {
            color: hoverColor[colorMode],
            transform: 'translateX(4px)'
        } }, (isActive && {
        textDecoration: 'underline',
        // bg: activeBg[colorMode],
        rounded: 'sm',
        fontWeight: 600,
        color: activeColor[colorMode]
    }), props))); }));
}));
exports.SideNavLink = react_2.forwardRef(function (_a, ref) {
    var children = _a.children, icon = _a.icon, bg = _a.bg, props = __rest(_a, ["children", "icon", "bg"]);
    var colorMode = react_1.useColorMode().colorMode;
    var color = { light: 'gray.700', dark: 'whiteAlpha.700' };
    return (react_2["default"].createElement(react_1.Box, __assign({ ref: ref, display: 'flex', cursor: 'pointer', alignItems: 'center', transition: 'all 0.2s', outline: 'none', _focus: { shadow: 'outline' }, _notFirst: { mt: 1 }, py: '1' }, props),
        icon && react_2.cloneElement(icon, { mr: 3 }),
        react_2["default"].createElement(react_1.Box, { bg: bg }, children)));
});
var NavLink = function (_a) {
    var children = _a.children, href = _a.href, props = __rest(_a, ["children", "href"]);
    // const router = useRouter()
    var fileParam = history_1.getFileParam(window.location.href);
    var hrefFileParam = history_1.getFileParam(href);
    var isActive = fileParam === hrefFileParam;
    return (react_2["default"].createElement("a", __assign({ onClick: function (e) {
            if (!e.ctrlKey && !e.altKey && !e.metaKey && !e.shiftKey) {
                e.preventDefault();
                history_1.history.push(href);
            }
        }, href: href }, props), typeof children === 'function' ? children(isActive) : children));
};
var stringToUrl = function (str, path) {
    if (path === void 0) { path = '/'; }
    return "" + path + str
        .toLowerCase()
        .split(' ')
        .join('-');
};
exports.stringToUrl = stringToUrl;
//# sourceMappingURL=NavLink.js.map