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 { Switch, View } from 'react-native';
import { Controller } from 'react-hook-form';
import { SafeAreaView } from 'react-native-safe-area-context';
import { Typography } from '../../../../core/components/Typography/Typography';
import Action from '../shared/elements/Action';
import Header from './components/Header';
import { useNotificationSetting } from './hooks/useNotificationSetting';
export function NotificationSetting({
  community
}) {
  const {
    styles,
    theme,
    control,
    accessibilityId,
    isEnabled,
    isPending,
    handleToggle,
    notificationActions
  } = useNotificationSetting({
    community
  });
  return /*#__PURE__*/React.createElement(SafeAreaView, {
    edges: ['top'],
    testID: accessibilityId,
    style: styles.container
  }, /*#__PURE__*/React.createElement(Header, null), /*#__PURE__*/React.createElement(View, {
    style: styles.switchContainer
  }, /*#__PURE__*/React.createElement(View, {
    style: styles.labelContainer
  }, /*#__PURE__*/React.createElement(Typography.BodyBold, {
    style: styles.colorBase
  }, "Allow notifications"), /*#__PURE__*/React.createElement(Typography.Caption, {
    style: styles.colorBaseShade1
  }, "Turn on to receive push notifications from this community.")), /*#__PURE__*/React.createElement(Controller, {
    name: "isEnabled",
    control: control,
    render: ({
      field: {
        value,
        onChange
      }
    }) => /*#__PURE__*/React.createElement(Switch, {
      value: value,
      onValueChange: val => {
        onChange(val);
        handleToggle(val);
      },
      disabled: isPending,
      thumbColor: theme.colors.background,
      ios_backgroundColor: theme.colors.baseShade3,
      trackColor: {
        true: theme.colors.primary,
        false: theme.colors.baseShade3
      }
    })
  })), isEnabled && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
    style: styles.divider
  }), notificationActions.map(item => /*#__PURE__*/React.createElement(Action, _extends({
    key: item.label
  }, item)))));
}
//# sourceMappingURL=NotificationSetting.js.map