import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useMainActions, } from '../../../components/ActionGroup';
import { MenuItem } from '../../../components/MenuItem';
import { DotsVOutlineMd } from '../../../icons/DotsVOutlineMd';
import { StyledButton, StyledDropdownButton, StyledIconDropDownButton, } from './styles';
export const FormMobileActions = ({ actions, }) => {
    const mainActions = useMainActions({
        actions: actions?.main || [],
    });
    if (!actions) {
        return null;
    }
    const { secondaryVisible = [], secondary = [] } = actions;
    const secondaryActions = [...secondaryVisible, ...secondary];
    return (_jsxs(StyledIconDropDownButton, { title: "\u0414\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044F", variant: "text", icon: _jsx(DotsVOutlineMd, {}), children: [mainActions.map(({ isNested, buttonProps, nestedActions }, index) => {
                const { name, disabled } = buttonProps;
                if (isNested) {
                    return (_jsx(MenuItem
                    // biome-ignore lint/suspicious/noArrayIndexKey: Используется вместе с name
                    , { disabled: disabled, children: _jsx(StyledDropdownButton, { ...buttonProps, variant: "text", children: nestedActions.map(({ key, text, ...nestedProps }) => (_jsx(MenuItem, { ...nestedProps, children: text }, key))) }) }, `${name}:${index}`));
                }
                return (
                // biome-ignore lint/suspicious/noArrayIndexKey: Используется вместе с name
                _jsx(MenuItem, { disabled: disabled, children: _jsx(StyledButton, { ...buttonProps, variant: "text" }) }, `${name}:${index}`));
            }), secondaryActions?.map((action, index) => {
                const label = 'name' in action ? action.name : action.text;
                const { disabled, onClick } = action;
                return (_jsx(MenuItem
                // biome-ignore lint/suspicious/noArrayIndexKey: Используется вместе с label
                , { disabled: disabled, onClick: onClick, children: label }, `${label}:${index}`));
            })] }));
};
