import { jsx as _jsx } from "react/jsx-runtime";
// (C) 2024-2025 GoodData Corporation
import { useIntl } from "react-intl";
import { isIInsightMenuSubmenu, } from "../../insightMenu/types.js";
import { useEditableInsightMenu } from "../../widget/InsightWidget/useEditableInsightMenu.js";
export const useVisualizationSwitcherEditableInsightMenu = (widget, insight, onVisualizationDeleted) => {
    const intl = useIntl();
    const { menuItems } = useEditableInsightMenu({
        widget,
        insight,
        closeMenu: () => { },
    });
    const modifiedMenuItems = menuItems.map((item) => {
        if (item.itemId === "ConfigurationPanelSubmenu" && isIInsightMenuSubmenu(item)) {
            return {
                ...item,
                SubmenuComponent: item.SubmenuComponent
                    ? (props) => {
                        const Component = item.SubmenuComponent;
                        return _jsx(Component, { ...props, enableTitleConfig: false });
                    }
                    : undefined,
            };
        }
        if (item.itemId === "InteractionPanelRemove") {
            return {
                ...item,
                itemName: intl.formatMessage({
                    id: "visualizationSwitcher.configurationPanel.remove.from.switcher",
                }),
                onClick: () => onVisualizationDeleted(widget.identifier),
            };
        }
        return item;
    });
    return { menuItems: modifiedMenuItems };
};
//# sourceMappingURL=useVisualizationSwitcherEditableInsightMenu.js.map