"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _reactI18next = require("react-i18next");
var _reactNative = require("react-native");
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
var _Button = _interopRequireWildcard(require("../components/buttons/Button"));
var _PushNotificationsContent = _interopRequireDefault(require("../components/views/PushNotificationsContent"));
var _containerApi = require("../container-api");
var _store = require("../contexts/reducers/store");
var _store2 = require("../contexts/store");
var _testable = require("../utils/testable");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
// Screen to show during onboarding that prompts
// for push notification permissions
const PushNotifications = () => {
  const {
    t
  } = (0, _reactI18next.useTranslation)();
  const [, dispatch] = (0, _store2.useStore)();
  const [{
    enablePushNotifications
  }] = (0, _containerApi.useServices)([_containerApi.TOKENS.CONFIG]);
  if (!enablePushNotifications) {
    throw new Error('Push notification configuration not found');
  }
  const styles = _reactNative.StyleSheet.create({
    screenContainer: {
      flex: 1,
      padding: 30
    },
    controlsContainer: {
      marginTop: 'auto'
    }
  });
  const activatePushNotifications = async () => {
    const state = await enablePushNotifications.setup();
    dispatch({
      type: _store.DispatchAction.USE_PUSH_NOTIFICATIONS,
      payload: [state === 'granted']
    });
  };
  return /*#__PURE__*/_react.default.createElement(_reactNativeSafeAreaContext.SafeAreaView, {
    style: {
      flex: 1
    },
    edges: ['left', 'right', 'bottom']
  }, /*#__PURE__*/_react.default.createElement(_reactNative.ScrollView, {
    contentContainerStyle: {
      flexGrow: 1
    }
  }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: styles.screenContainer
  }, /*#__PURE__*/_react.default.createElement(_PushNotificationsContent.default, null), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: styles.controlsContainer
  }, /*#__PURE__*/_react.default.createElement(_Button.default, {
    buttonType: _Button.ButtonType.Primary,
    title: t('Global.Continue'),
    accessibilityLabel: t('Global.Continue'),
    testID: (0, _testable.testIdWithKey)('PushNotificationContinue'),
    onPress: activatePushNotifications
  })))));
};
var _default = exports.default = PushNotifications;
//# sourceMappingURL=PushNotifications.js.map