"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.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 core_1 = require("@chakra-ui/core");
var react_router_dom_1 = require("react-router-dom");
var react_router_dom_2 = require("react-router-dom");
var react_1 = __importStar(require("react"));
exports.ComponentLink = react_1["default"].memo(react_1.forwardRef(function (_a, ref) {
    var href = _a.href, props = __rest(_a, ["href"]);
    var colorMode = core_1.useColorMode().colorMode;
    var hoverColor = { light: 'gray.900', dark: 'whiteAlpha.900' };
    var activeColor = { light: 'gray.800', dark: 'gray.200' };
    var activeBg = { light: 'gray.100', dark: 'gray.700' };
    return (react_1["default"].createElement(NavLink, { href: href }, function (isActive) { return (react_1["default"].createElement(exports.SideNavLink, __assign({ ref: ref, href: href, "aria-current": isActive ? 'page' : undefined, _hover: {
            color: hoverColor[colorMode],
            transform: 'translateX(4px)'
        } }, (isActive && {
        bg: activeBg[colorMode],
        rounded: 'sm',
        color: activeColor[colorMode],
        _hover: {}
    }), props))); }));
}));
exports.SideNavLink = react_1.forwardRef(function (_a, ref) {
    var children = _a.children, icon = _a.icon, props = __rest(_a, ["children", "icon"]);
    var colorMode = core_1.useColorMode().colorMode;
    var color = { light: 'gray.700', dark: 'whiteAlpha.700' };
    return (react_1["default"].createElement(core_1.PseudoBox, __assign({ ref: ref, 
        // mx={-2}
        display: 'flex', cursor: 'pointer', alignItems: 'center', 
        // px='2'
        py: '1', transition: 'all 0.2s', 
        // fontWeight='medium'
        outline: 'none', _focus: { shadow: 'outline' }, 
        // color={color[colorMode]}
        _notFirst: { mt: 1 } }, props),
        icon && react_1.cloneElement(icon, { mr: 3 }),
        react_1["default"].createElement(core_1.Box, null, children)));
});
var NavLink = function (_a) {
    var children = _a.children, href = _a.href, props = __rest(_a, ["children", "href"]);
    // const router = useRouter()
    var _b = react_router_dom_2.useLocation().pathname, pathname = _b === void 0 ? '' : _b;
    var isActive = false;
    if ((pathname === null || pathname === void 0 ? void 0 : pathname.replace(/\/$/, '').replace(/\bindex$/, '')) ===
        href.replace(/\/$/, '')) {
        isActive = true;
    }
    if (process.env.USE_HREF) {
        return typeof children === 'function' ? children(isActive) : children;
    }
    return (react_1["default"].createElement(react_router_dom_1.Link, __assign({ to: href }, props), typeof children === 'function' ? children(isActive) : children));
};
exports.stringToUrl = function (str, path) {
    if (path === void 0) { path = '/'; }
    return "" + path + str.toLowerCase().split(' ').join('-');
};
//# sourceMappingURL=NavLink.js.map