"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var app_root_exports = {};
__export(app_root_exports, {
  AppRoot: () => AppRoot
});
module.exports = __toCommonJS(app_root_exports);
var import_jsx_runtime = require("react/jsx-runtime");
var import_react = require("react");
var import_react_redux = require("react-redux");
var import_styled_components = require("styled-components");
var import_pui_theme = require("@elliemae/pui-theme");
var import_app_router = require("../app-router.js");
var import_micro_frontend = require("../../utils/micro-frontend/index.js");
var import_error_boundary = require("../error-boundary/index.js");
var import_stand_alone_app = require("./stand-alone-app.js");
var import_hosted_app = require("./hosted-app.js");
const AppToRender = (props) => {
  const isParent = (0, import_micro_frontend.isStandAloneGuest)() || (0, import_micro_frontend.isHost)();
  return isParent ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stand_alone_app.StandAloneApp, { ...props }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_hosted_app.HostedApp, { ...props });
};
const AppRoot = ({
  store,
  history,
  basename,
  theme = (0, import_pui_theme.getDefaultTheme)(),
  manageSession = false,
  WaitMessage,
  errorTemplate,
  children,
  strictMode = true
}) => {
  const ParentEle = strictMode ? import_react.StrictMode : import_react.Fragment;
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ParentEle, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_error_boundary.ErrorBoundary, { errorTemplate, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_redux.Provider, { store, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_app_router.AppRouter, { history, basename, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled_components.ThemeProvider, { theme, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
    AppToRender,
    {
      manageSession,
      WaitMessage,
      children
    }
  ) }) }) }) }) });
};
