"use strict";

function _typeof(e) {
  return (_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
    return typeof e
  } : function(e) {
    return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
  })(e)
}
Object.defineProperty(exports, "__esModule", {
  value: !0
}), exports.default = void 0;
var _amosTool = require("amos-tool"),
  _rayProgress = _interopRequireDefault(require("ray-progress")),
  endConf = _interopRequireWildcard(require("amos-processor/lib/config/endconf")),
  _calcRoutes = _interopRequireDefault(require("./calcRoutes")),
  _customRoutes = _interopRequireDefault(require("./customRoutes")),
  _view = _interopRequireWildcard(require("./view"));

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

function _interopRequireWildcard(e) {
  if (e && e.__esModule) return e;
  if (null === e || "object" !== _typeof(e) && "function" != typeof e) return {
    default: e
  };
  var r = _getRequireWildcardCache();
  if (r && r.has(e)) return r.get(e);
  var t, o, n = {},
    i = Object.defineProperty && Object.getOwnPropertyDescriptor;
  for (t in e) Object.prototype.hasOwnProperty.call(e, t) && ((o = i ? Object.getOwnPropertyDescriptor(e, t) : null) && (o.get || o.set) ? Object.defineProperty(n, t, o) : n[t] = e[t]);
  return n.default = e, r && r.set(e, n), n
}

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

function _toConsumableArray(e) {
  return _arrayWithoutHoles(e) || _iterableToArray(e) || _unsupportedIterableToArray(e) || _nonIterableSpread()
}

function _nonIterableSpread() {
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
}

function _unsupportedIterableToArray(e, r) {
  if (e) {
    if ("string" == typeof e) return _arrayLikeToArray(e, r);
    var t = Object.prototype.toString.call(e).slice(8, -1);
    return "Object" === t && e.constructor && (t = e.constructor.name), "Map" === t || "Set" === t ? Array.from(e) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(e, r) : void 0
  }
}

function _iterableToArray(e) {
  if ("undefined" != typeof Symbol && Symbol.iterator in Object(e)) return Array.from(e)
}

function _arrayWithoutHoles(e) {
  if (Array.isArray(e)) return _arrayLikeToArray(e)
}

function _arrayLikeToArray(e, r) {
  (null == r || r > e.length) && (r = e.length);
  for (var t = 0, o = new Array(r); t < r; t++) o[t] = e[t];
  return o
}
var AmosConfig = endConf.AmosConfig,
  loginURI = AmosConfig.httpURI.loginURI,
  injectRoutes = function(e) {
    e = (0, _customRoutes.default)((0, _calcRoutes.default)(e, _view.default));
    return [{
      path: "login",
      component: _view.Login
    }, {
      path: "region",
      component: _view.RegionList
    }, {
      path: "main",
      component: _view.RootView,
      childRoutes: _toConsumableArray(e)
    }]
  },
  progressStart = function() {
    _rayProgress.default.start()
  },
  rootRoutes = function(e) {
    return {
      path: "/",
      onChange: progressStart,
      indexRedirect: _view.Login,
      indexRoute: {
        onEnter: function() {
          window.location.href = loginURI
        }
      },
      childRoutes: injectRoutes(e)
    }
  },
  _default = rootRoutes;
exports.default = rootRoutes, module.exports = exports.default;
