"use strict";

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

var _renderAuthorize = require("./renderAuthorize");

var filterPath = [{
  name: '404',
  path: '/404'
}, {
  name: '403',
  path: '/403'
}, {
  name: '500',
  path: '/500'
}];

var checkPermissions = function checkPermissions(authority, flatMenu, currentAuthority, target, Exception) {
  if (!authority) {
    return target;
  }

  if (Array.isArray(flatMenu)) {
    var data = flatMenu.concat(filterPath);
    var findIndex = data.findIndex(function (item) {
      return item.path === authority;
    });

    if (findIndex > -1) {
      return target;
    }

    return Exception;
  }

  throw new Error('unsupported parameters');
};

function check(authority, flatMenu, target, Exception) {
  debugger;
  return checkPermissions(authority, flatMenu, _renderAuthorize.CURRENT, target, Exception);
}

var _default = check;
exports["default"] = _default;