function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import { memo } from 'react';
import { ComponentID, ElementID, PageID } from '../../enums/enumUIKitID';
import { useAmityElement, useLeaveCommunity } from '../../hooks';
import { Button, BUTTON_SIZE } from '../../components/Button/Button';
import { check } from '../../../core/assets/icons';
const CommunityJoinedButton = ({
  pageId = PageID.WildCardPage,
  componentId = ComponentID.WildCardComponent,
  communityId,
  ...props
}) => {
  const {
    config,
    accessibilityId,
    isExcluded,
    themeStyles
  } = useAmityElement({
    pageId,
    componentId,
    elementId: ElementID.community_joined_button
  });
  const {
    leaveCommunity,
    isPending
  } = useLeaveCommunity();
  const handleLeaveCommunity = () => {
    if (!communityId) return;
    leaveCommunity(communityId);
  };
  if (isExcluded) return null;
  return /*#__PURE__*/React.createElement(Button, _extends({
    testID: accessibilityId,
    type: "secondary",
    icon: check(themeStyles.isDarkTheme ? themeStyles.colors.baseShade1 : undefined),
    onPress: handleLeaveCommunity,
    disabled: isPending,
    size: BUTTON_SIZE.SMALL
  }, props), (config === null || config === void 0 ? void 0 : config.text) || 'Joined');
};
export default /*#__PURE__*/memo(CommunityJoinedButton);
//# sourceMappingURL=CommunityJoinedButtonElement.js.map