"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SettingsMenuToggle = exports.useSettingsToggle = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const React = tslib_1.__importStar(require("react"));
const utils_1 = require("./utils");
const components_react_1 = require("@livekit/components-react");
/**
 * The `useSettingsToggle` hook provides state and functions for toggling the settings menu.
 */
function useSettingsToggle({ props }) {
    const { dispatch, state } = (0, components_react_1.useLayoutContext)().widget;
    const className = 'lk-button lk-settings-toggle';
    const mergedProps = React.useMemo(() => {
        return (0, utils_1.mergePropsReactAria)(props, {
            className,
            onClick: () => {
                if (dispatch)
                    dispatch({ msg: 'toggle_settings' });
            },
            'aria-pressed': (state === null || state === void 0 ? void 0 : state.showSettings) ? 'true' : 'false'
        });
    }, [props, className, dispatch, state]);
    return { mergedProps };
}
exports.useSettingsToggle = useSettingsToggle;
/**
 * The `SettingsMenuToggle` component is a button that toggles the visibility of the `SettingsMenu` component.
 */
exports.SettingsMenuToggle = 
/* @__PURE__ */ React.forwardRef(function SettingsMenuToggle(props, ref) {
    const { mergedProps } = useSettingsToggle({ props });
    return ((0, jsx_runtime_1.jsx)("button", Object.assign({ ref: ref }, mergedProps, { children: props.children })));
});
