/* @oracle/oraclejet-preact: undefined */
import { jsxs, jsx } from 'preact/jsx-runtime';
import { Fragment } from 'preact';
import { forwardRef } from 'preact/compat';
import { useRef, useImperativeHandle } from 'preact/hooks';
import { B as BaseButton } from './BaseButton-61f6baa8.js';
import { u as useToggleAction } from './useToggleAction-fc0f5399.js';
import { u as useTooltip } from './useTooltip-89ca3f3e.js';
import { u as useId } from './useId-03dbfdf0.js';
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 { a as toggleStyling } from './toggleButtonUtils-75e3d781.js';
import { T as ToggleButtonLabel } from './ToggleButtonLabel-bd186454.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 = forwardRef(({ children, tooltip, size = 'md', isDisabled = false, accessibleLabel, isSelected = false, onToggle, testId, width, 'aria-describedby': ariaDescribedBy }, ref) => {
    const buttonRef = useRef(null);
    useImperativeHandle(ref, () => buttonRef.current, [buttonRef]);
    const { triggerProps } = useToggleAction({
        isDisabled: isDisabled,
        onToggle: onToggle
    });
    const { tooltipContent, tooltipProps } = useTooltip({
        text: tooltip ?? accessibleLabel,
        isDisabled: isDisabled
    });
    const styling = toggleStyling('auto', isSelected, true, false, false, undefined, undefined, true);
    const ariaProps = { 'aria-describedby': ariaDescribedBy };
    return (jsxs(Fragment, { children: [jsx(BaseButton, { ...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: jsx(ToggleButtonLabel, { isDisabled: isDisabled, label: accessibleLabel ?? tooltip, isToggle: true, inputName: useId(), inputType: 'switch', onAction: () => onToggle?.({ value: isSelected }), isSelected: isSelected, display: 'icons', startIcon: children, size: size }) }), tooltipContent] }));
});
IconSwitchButton.displayName = 'IconSwitchButton';

export { IconSwitchButton as I };
//# sourceMappingURL=IconSwitchButton-dcafa86c.js.map
