/* @oracle/oraclejet-preact: undefined */
import { jsx, jsxs } from 'preact/jsx-runtime';
import { Fragment } from 'preact';
import { B as BaseButton } from './BaseButton-61f6baa8.js';
import { P as ProgressButtonLabelLayout } from './ProgressButtonLabelLayout-f1d097d6.js';
import { forwardRef } from 'preact/compat';
import { u as useTooltip } from './useTooltip-89ca3f3e.js';
import 'preact/hooks';
import { m as mergeProps } from './mergeProps-88ea8306.js';
import './logger-c92f309c.js';
import './LayerHost-e6402730.js';
import './TooltipContentStyles.styles.css';
import './hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentBaseTheme.styles.css';
import './hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentVariants.css.js';
import './tooltipUtils-768450a7.js';
import { p as processGlobals } from './buttonUtils-be059939.js';
import bundle from './resources/nls/en/bundle.js';

/**
 * A Progress button is a push button that can show progress.
 */
const ProgressButton = forwardRef(({ variant = 'outlined', isLoading = false, isDisabled = false, size = 'md', display = 'all', type: buttonType = 'button', startIcon, edge, testId, onAction, label = '', tooltip, 'aria-describedby': ariaDescribedBy, width, ...props }, ref) => {
    const { globalEventProps } = processGlobals(props);
    const isAdjustedLoading = isDisabled ? false : isLoading;
    const progressStatus = bundle.accButtonProgressStatus({
        label: label
    });
    const progressComplete = bundle.accButtonProgressComplete({
        label: label
    });
    const showTooltip = isAdjustedLoading && (display == 'label' || !startIcon);
    const tooltipLabel = showTooltip ? (tooltip ? tooltip : label) : tooltip;
    const { tooltipContent, tooltipProps } = useTooltip({
        text: tooltipLabel,
        isDisabled
    });
    const labelOnly = !startIcon || display === 'label';
    const elementDetails = {
        type: 'button',
        buttonType: buttonType
    };
    const content = (jsx(ProgressButtonLabelLayout, { display: display, isLoadingContrast: variant === 'callToAction', startIcon: startIcon, accessibleLoadedLabel: progressComplete, accessibleLoadingLabel: progressStatus, size: size, isLoading: isAdjustedLoading, children: label }));
    /* For a11y, we use ignore aria-label during loading time */
    const { 'aria-describedby': adb, ...ttProps } = tooltipProps;
    return (jsxs(Fragment, { children: [jsx(BaseButton, { ...mergeProps(ttProps, globalEventProps), ref: ref, elementDetails: elementDetails, isDisabled: isDisabled, isReadOnly: isAdjustedLoading, size: size, width: width, edge: edge, variant: variant, styling: labelOnly
                    ? isAdjustedLoading
                        ? ['default', 'hiddenLabel', 'noHoverActive']
                        : ['default']
                    : isAdjustedLoading
                        ? ['noHoverActive', 'min']
                        : ['min'], onAction: onAction, "aria-label": label, testId: testId, children: content }), tooltipContent] }));
});
ProgressButton.displayName = 'ProgressButton';

export { ProgressButton as P };
//# sourceMappingURL=ProgressButton-bb52347a.js.map
