"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ReduxWrapper = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactRedux = require("react-redux");
var _reactNativeKeyboardController = require("react-native-keyboard-controller");
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
var _roomStore = require("../../roomStore");
var _xmppProvider = require("../../context/xmppProvider");
var _MessageNotificationContext = require("../../context/MessageNotificationContext");
var _ToastContext = require("../../context/ToastContext");
var _LoginWrapper = _interopRequireDefault(require("./LoginWrapper"));
require("../../helpers/storeConsole");
var _installPromiseRejectionTracker = require("../../utils/installPromiseRejectionTracker");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
// Mount-time, dev-only — wire a global unhandled-promise-rejection
// tracker so any future leak surfaces with a real stack trace in Metro
// logs (bug #4 follow-up). No-op in production.
(0, _installPromiseRejectionTracker.installPromiseRejectionTracker)();
const ReduxWrapper = exports.ReduxWrapper = /*#__PURE__*/_react.default.memo(({
  ...props
}) => {
  const memoizedConfig = (0, _react.useMemo)(() => {
    return props.config;
  }, [props.config]);

  // Host apps that own their keyboard handling (their own
  // KeyboardProvider + KeyboardAvoidingView around <Chat>) set
  // `disableKeyboardAvoidingView` — drop the built-in KeyboardProvider
  // here too so there aren't two nested providers (the second is part of
  // the Android keyboard flicker in bug #6; ChatRoom drops the matching
  // KeyboardAvoidingView under the same flag).
  const ownKeyboardHandling = !memoizedConfig?.disableKeyboardAvoidingView;
  const tree = /*#__PURE__*/(0, _jsxRuntime.jsx)(_xmppProvider.XmppProvider, {
    config: memoizedConfig,
    isVisible: props.isVisible,
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToastContext.ToastProvider, {
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_MessageNotificationContext.MessageNotificationProvider, {
        config: memoizedConfig,
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_LoginWrapper.default, {
          config: memoizedConfig,
          ...props
        })
      })
    })
  });
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRedux.Provider, {
    store: _roomStore.store,
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSafeAreaContext.SafeAreaProvider, {
      children: ownKeyboardHandling ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeKeyboardController.KeyboardProvider, {
        children: tree
      }) : tree
    })
  });
});
//# sourceMappingURL=ReduxWrapper.js.map