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

var jsxRuntime = require('preact/jsx-runtime');
var preact = require('preact');
var compat = require('preact/compat');
var hooks = require('preact/hooks');
var BaseButton = require('./BaseButton-590432e4.js');
var useToggleAction = require('./useToggleAction-e4f15550.js');
var useTooltip = require('./useTooltip-cf4a15f3.js');
var useId = require('./useId-6c0eeb27.js');
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 toggleButtonUtils = require('./toggleButtonUtils-245111a7.js');
var ToggleButtonLabel = require('./ToggleButtonLabel-6ff96ee4.js');

/**
 * A IconSwitchButton is an icon button that allows users to switch
 * between states when pressed.  It differs from a toggle button in not
 * providing any visual indication of the state; instead, switch the
 * icon to provide the state indication.
 */
const IconSwitchButton = compat.forwardRef(({ children, tooltip, size = 'md', isDisabled = false, accessibleLabel, isSelected = false, onToggle, testId, width, 'aria-describedby': ariaDescribedBy }, ref) => {
    const buttonRef = hooks.useRef(null);
    hooks.useImperativeHandle(ref, () => buttonRef.current, [buttonRef]);
    const { triggerProps } = useToggleAction.useToggleAction({
        isDisabled: isDisabled,
        onToggle: onToggle
    });
    const { tooltipContent, tooltipProps } = useTooltip.useTooltip({
        text: tooltip ?? accessibleLabel,
        isDisabled: isDisabled
    });
    const styling = toggleButtonUtils.toggleStyling('auto', isSelected, true, false, false, undefined, undefined, true);
    const ariaProps = { 'aria-describedby': ariaDescribedBy };
    return (jsxRuntime.jsxs(preact.Fragment, { children: [jsxRuntime.jsx(BaseButton.BaseButton, { ...mergeProps.mergeProps(tooltipProps, triggerProps, ariaProps), elementDetails: { type: 'button', isSwitch: true }, "aria-checked": isSelected, variant: "ghost", size: size, isDisabled: isDisabled, styling: styling, width: width, ref: buttonRef, "aria-label": accessibleLabel ?? tooltip, testId: testId, children: jsxRuntime.jsx(ToggleButtonLabel.ToggleButtonLabel, { isDisabled: isDisabled, label: accessibleLabel ?? tooltip, isToggle: true, inputName: useId.useId(), inputType: 'switch', onAction: () => onToggle?.({ value: isSelected }), isSelected: isSelected, display: 'icons', startIcon: children, size: size }) }), tooltipContent] }));
});
IconSwitchButton.displayName = 'IconSwitchButton';

exports.IconSwitchButton = IconSwitchButton;
//# sourceMappingURL=IconSwitchButton-2f946274.js.map
