"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NavigationItem = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const React = tslib_1.__importStar(require("react"));
const omit_1 = tslib_1.__importDefault(require("lodash/omit.js"));
const blockIdContext_1 = require("../../../../context/blockIdContext/index.js");
const models_1 = require("../../../../models/index.js");
const utils_1 = require("../../../../utils/index.js");
const useNavigationItemMap_1 = require("./hooks/useNavigationItemMap.js");
const b = (0, utils_1.block)('navigation-item');
const ANALYTICS_ID = 'navigation';
const nonComplexNavigationItemTypes = models_1.NavigationItemTypes.filter((type) => type !== models_1.NavigationItemType.Dropdown);
const NavigationItem = ({ data, className, menuLayout, ...props }) => {
    const { type = models_1.NavigationItemType.Link } = data;
    const navItemMap = (0, useNavigationItemMap_1.useNavigationItemMap)();
    const Component = navItemMap[type];
    const componentProps = React.useMemo(() => {
        const componentProperties = {
            ...data,
            ...props,
        };
        if (nonComplexNavigationItemTypes.includes(type)) {
            return (0, omit_1.default)(componentProperties, 'hidePopup', 'isActive');
        }
        return models_1.NavigationItemTypes.includes(type)
            ? componentProperties
            : { ...componentProperties, menuLayout };
    }, [data, props, type, menuLayout]);
    return (
    // TODO: fix any
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    (0, jsx_runtime_1.jsx)(blockIdContext_1.BlockIdContext.Provider, { value: ANALYTICS_ID, children: (0, jsx_runtime_1.jsx)("li", { className: b({ 'menu-layout': menuLayout }, className), children: (0, jsx_runtime_1.jsx)(Component, { ...componentProps, className: b('content', { type }) }) }) }));
};
exports.NavigationItem = NavigationItem;
exports.default = exports.NavigationItem;
//# sourceMappingURL=NavigationItem.js.map
