import { __rest } from "tslib";
import { jsx as _jsx } from "react/jsx-runtime";
import React, { useContext } from 'react';
import { styled } from '@mui/material/styles';
import { SCPreferences, SCPreferencesContext } from '@selfcommunity/react-core';
import { Box } from '@mui/material';
import FollowUserButton from '../FollowUserButton';
import FriendshipUserButton from '../FriendshipUserButton';
import { useThemeProps } from '@mui/system';
const PREFIX = 'SCConnectionUserButton';
const classes = {
    root: `${PREFIX}-root`
};
const Root = styled(Box, {
    name: PREFIX,
    slot: 'Root',
    overridesResolver: (props, styles) => styles.root
})(({ theme }) => ({}));
/**
 * > API documentation for the Community-JS Connection User Button component. Learn about the available props and the CSS API.
 *
 *

 #### Import
 ```jsx
 import {ConnectionUserButton} from '@selfcommunity/react-ui';
 ```
 #### Component Name
 The name `SCConnectionUserButton` can be used when providing style overrides in the theme.

 #### CSS

 |Rule Name|Global class|Description|
 |---|---|---|
 |root|.SCConnectionUserButton-root|Styles applied to the root element.|

 * @param inProps
 */
export default function ConnectionUserButton(inProps) {
    // PROPS
    const props = useThemeProps({
        props: inProps,
        name: PREFIX
    });
    const { user = null, followConnectUserButtonProps = {} } = props, rest = __rest(props, ["user", "followConnectUserButtonProps"]);
    // CONTEXT
    const scPreferencesContext = useContext(SCPreferencesContext);
    const followEnabled = SCPreferences.CONFIGURATIONS_FOLLOW_ENABLED in scPreferencesContext.preferences &&
        scPreferencesContext.preferences[SCPreferences.CONFIGURATIONS_FOLLOW_ENABLED].value;
    return (_jsx(React.Fragment, { children: followEnabled ? (_jsx(FollowUserButton, Object.assign({ user: user }, followConnectUserButtonProps, rest))) : (_jsx(FriendshipUserButton, Object.assign({ user: user }, followConnectUserButtonProps, rest))) }));
}
