/* @oracle/oraclejet-preact: undefined */
'use strict';

var jsxRuntime = require('preact/jsx-runtime');
var preact = require('preact');
var BaseButton = require('./BaseButton-590432e4.js');
var ProgressButtonLabelLayout = require('./ProgressButtonLabelLayout-b47ca0c8.js');
var compat = require('preact/compat');
var useTooltip = require('./useTooltip-cf4a15f3.js');
require('preact/hooks');
var mergeProps = require('./mergeProps-e3da7237.js');
require('./logger-2b636482.js');
require('./LayerHost-8ec73638.js');


require('./hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentVariants.css.js');
require('./tooltipUtils-d461919d.js');
var buttonUtils = require('./buttonUtils-1f339a8e.js');
var resources_nls_en_bundle = require('./resources/nls/en/bundle.js');

/**
 * A Progress button is a push button that can show progress.
 */
const ProgressButton = compat.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 } = buttonUtils.processGlobals(props);
    const isAdjustedLoading = isDisabled ? false : isLoading;
    const progressStatus = resources_nls_en_bundle["default"].accButtonProgressStatus({
        label: label
    });
    const progressComplete = resources_nls_en_bundle["default"].accButtonProgressComplete({
        label: label
    });
    const showTooltip = isAdjustedLoading && (display == 'label' || !startIcon);
    const tooltipLabel = showTooltip ? (tooltip ? tooltip : label) : tooltip;
    const { tooltipContent, tooltipProps } = useTooltip.useTooltip({
        text: tooltipLabel,
        isDisabled
    });
    const labelOnly = !startIcon || display === 'label';
    const elementDetails = {
        type: 'button',
        buttonType: buttonType
    };
    const content = (jsxRuntime.jsx(ProgressButtonLabelLayout.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 (jsxRuntime.jsxs(preact.Fragment, { children: [jsxRuntime.jsx(BaseButton.BaseButton, { ...mergeProps.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';

exports.ProgressButton = ProgressButton;
//# sourceMappingURL=ProgressButton-81474622.js.map
