"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"), _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

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

var _class, _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")), _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")), _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")), _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")), _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")), _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")), _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")), _react = _interopRequireWildcard(require("react")), _propTypes = _interopRequireDefault(require("prop-types")), _amosReactRouter = require("amos-react-router"), _amosIcon = _interopRequireDefault(require("amos-icon")), _amosFramework = require("amos-framework"), _connectMenu = _interopRequireDefault(require("./connectMenu"));

function _createSuper(e) {
    var r = _isNativeReflectConstruct();
    return function() {
        var t, a = (0, _getPrototypeOf2.default)(e);
        if (r) {
            var i = (0, _getPrototypeOf2.default)(this).constructor;
            t = Reflect.construct(a, arguments, i);
        } else t = a.apply(this, arguments);
        return (0, _possibleConstructorReturn2.default)(this, t);
    };
}

function _isNativeReflectConstruct() {
    if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
    if (Reflect.construct.sham) return !1;
    if ("function" == typeof Proxy) return !0;
    try {
        return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function() {}))), 
        !0;
    } catch (e) {
        return !1;
    }
}

var LevelMenu = (0, _connectMenu.default)(_class = function(e) {
    (0, _inherits2.default)(t, e);
    var r = _createSuper(t);
    function t() {
        var e;
        (0, _classCallCheck2.default)(this, t);
        for (var a = arguments.length, i = new Array(a), n = 0; n < a; n++) i[n] = arguments[n];
        return e = r.call.apply(r, [ this ].concat(i)), (0, _defineProperty2.default)((0, 
        _assertThisInitialized2.default)(e), "renderItemLink", (function(r) {
            var t = e.props.iconPrefix, a = r.icon, i = (r.label, r.isBlank), n = r.path, u = r.permissionName, l = a && _react.default.createElement(_amosIcon.default, {
                icon: a,
                prefix: t,
                className: "menu-item-icon"
            });
            return i ? _react.default.createElement("a", {
                href: n,
                target: "_blank",
                rel: "noopener noreferrer",
                className: "menu-item-link"
            }, l, u) : _react.default.createElement(_amosReactRouter.Link, {
                to: n,
                className: "menu-item-link"
            }, l, u);
        })), e;
    }
    return (0, _createClass2.default)(t, [ {
        key: "render",
        value: function() {
            var e = this.props, r = e.className, t = e.onClick, a = e.nonChild, i = e.children;
            return _react.default.createElement("li", {
                className: r,
                onClick: t
            }, this.renderItemLink(this.props), !a && _react.default.createElement(_amosFramework.Icon, {
                icon: "right",
                className: "menu-subitem-icon"
            }), !a && i);
        }
    } ]), t;
}(_react.Component)) || _class;

exports.default = LevelMenu, LevelMenu.propTypes = {
    nonChild: _propTypes.default.bool,
    className: _propTypes.default.string,
    iconPrefix: _propTypes.default.string,
    onClick: _propTypes.default.func,
    children: _propTypes.default.node
};