import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2025-2026 GoodData Corporation
import { memo, useCallback } from "react";
import { typedUiMenuContextStore } from "../../context.js";
import { e } from "../../menuBem.js";
import { DefaultUiMenuHeader } from "./DefaultUiMenuHeader.js";
/**
 * Container for rendering custom content in menu.
 * @internal
 */
export const DefaultUiMenuContent = memo(function DefaultUiMenuContent({ item, }) {
    const { useContextStore, createSelector } = typedUiMenuContextStore();
    const selector = createSelector((ctx) => ({
        onClose: ctx.onClose,
        setShownCustomContentItemId: ctx.setShownCustomContentItemId,
        setFocusedId: ctx.setFocusedId,
        shownCustomContentItemId: ctx.shownCustomContentItemId,
    }));
    const { onClose, setShownCustomContentItemId, setFocusedId, shownCustomContentItemId } = useContextStore(selector);
    const handleBack = useCallback(() => {
        setFocusedId(shownCustomContentItemId);
        setShownCustomContentItemId(undefined);
    }, [setShownCustomContentItemId, shownCustomContentItemId, setFocusedId]);
    const ContentComponent = item.Component;
    return (_jsxs(_Fragment, { children: [item.showComponentOnly ? null : _jsx(DefaultUiMenuHeader, {}), _jsx("div", { className: e("content-container"), children: _jsx(ContentComponent, { onBack: handleBack, onClose: onClose ?? (() => { }) }) })
        ] }));
});
