"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _react = _interopRequireWildcard(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var router = _interopRequireWildcard(require("react-router-dom"));

var _reactstrap = require("reactstrap");

var _react2 = require("@coreui/react");

var _pages = require("../../pages");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

var BackendFooter = _react.default.lazy(function () {
  return Promise.resolve().then(function () {
    return _interopRequireWildcard(require('./BackendFooter'));
  });
});

var BackendHeader = _react.default.lazy(function () {
  return Promise.resolve().then(function () {
    return _interopRequireWildcard(require('./BackendHeader'));
  });
});

function BackendTemplate(_ref) {
  var props = _extends({}, _ref);

  var loading = function loading() {
    return _react.default.createElement("div", {
      className: "animated fadeIn pt-1 text-center"
    }, "Loading...");
  };

  var parentProps = props;
  return _react.default.createElement("div", {
    className: "app"
  }, _react.default.createElement(_react2.AppHeader, {
    fixed: true
  }, _react.default.createElement(_react.Suspense, {
    fallback: loading()
  }, _react.default.createElement(BackendHeader, props))), _react.default.createElement("div", {
    className: "app-body"
  }, _react.default.createElement(_react2.AppSidebar, {
    fixed: true,
    display: "lg"
  }, _react.default.createElement(_react2.AppSidebarHeader, null), _react.default.createElement(_react2.AppSidebarForm, null), _react.default.createElement(_react.Suspense, null, _react.default.createElement(_react2.AppSidebarNav2, _extends({
    navConfig: props.navConfig
  }, props, {
    router: router
  }))), _react.default.createElement(_react2.AppSidebarFooter, null), _react.default.createElement(_react2.AppSidebarMinimizer, null)), _react.default.createElement("main", {
    className: "main"
  }, props.history.location.key && _react.default.createElement(_react2.AppBreadcrumb2, {
    appRoutes: props.routeConfig,
    router: router
  }), _react.default.createElement(_reactstrap.Container, {
    fluid: true
  }, _react.default.createElement(_react.Suspense, {
    fallback: loading()
  }, _react.default.createElement(router.Switch, null, props.routeConfig.map(function (route, idx) {
    return route.component ? _react.default.createElement(router.Route, {
      key: idx,
      path: route.path,
      exact: route.exact,
      name: route.name,
      render: function render(props) {
        return _react.default.createElement(route.component, _extends({}, props, parentProps));
      }
    }) : null;
  }), _react.default.createElement(router.Route, {
    render: function render() {
      return _react.default.createElement("div", {
        style: {
          display: 'flex',
          flex: 1,
          height: '88.5vh',
          justifyContent: 'center',
          alignItems: 'center'
        }
      }, _react.default.createElement(_pages.Page404, {
        includeTemplate: false
      }));
    }
  })))))), _react.default.createElement(_react2.AppFooter, null, _react.default.createElement(_react.Suspense, {
    fallback: loading()
  }, _react.default.createElement(BackendFooter, props))));
}

var _default = (0, router.withRouter)(BackendTemplate);

exports.default = _default;
BackendTemplate.propTypes = {
  routeConfig: _propTypes.default.oneOfType([_propTypes.default.array.isRequired, _propTypes.default.object.isRequired]),
  navConfig: _propTypes.default.oneOfType([_propTypes.default.array.isRequired, _propTypes.default.object.isRequired])
};
BackendTemplate.defualtProps = {
  routeConfig: [],
  navConfig: []
};