/**
 * @license MIT
 * author: Cube Dev Team
 * @cube-dev/ui-kit v0.98.7
 * Released under the MIT license.
 */

import { jsx as _jsx } from "react/jsx-runtime";
import React, { isValidElement, memo } from 'react';
import flatten from 'react-keyed-flatten-children';
import { tasty } from '../../../../tasty';
import { ButtonGroup } from '../../../actions';
const FooterArea = tasty(ButtonGroup, {
    styles: {
        gridArea: 'footer',
        gap: '1x 2x',
        flow: 'row wrap',
        margin: {
            '': '0.5x top',
            'has-description': '1x top',
            ':empty': '0',
        },
    },
});
/**
 * @internal This component is unstable and must not be used outside of `NotificationView`.
 */
export const NotificationFooter = memo(function NotificationFooter(props) {
    const { actions, onClose, onDismiss, hasDescription } = props;
    return (_jsx(FooterArea, { mods: { 'has-description': hasDescription }, children: flatten(typeof actions === 'function'
            ? actions({ onClose, onDismiss })
            : actions)
            .filter((action) => isValidElement(action))
            .map((action, index) => {
            const { props } = action;
            const defaultType = index === 0 ? 'primary' : 'secondary';
            return React.cloneElement(action, {
                ...props,
                type: props.type ?? defaultType,
            }, props.children);
        }) }));
});

        