import _Menu from "antd/es/menu";
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
var _excluded = ["icon", "type"];
import React from 'react';
// import Icon from '@ant-design/icons/lib/components/Icon';
import * as icons from '@ant-design/icons';
var CustomNav = function CustomNav(props, ref) {
  var icon = props.icon,
    type = props.type,
    otherProps = _objectWithoutPropertiesLoose(props, _excluded);
  var data = [].concat(otherProps === null || otherProps === void 0 ? void 0 : otherProps.items);
  function processMenuItems(menuItems) {
    return menuItems === null || menuItems === void 0 ? void 0 : menuItems.map(function (item) {
      var menuItem = _extends({}, item);
      // 处理当前菜单项
      if (menuItem !== null && menuItem !== void 0 && menuItem.icon) {
        var IconComp = (icons || {})[menuItem === null || menuItem === void 0 ? void 0 : menuItem.icon];
        if (IconComp) {
          menuItem.icon = /*#__PURE__*/React.createElement(IconComp, icon);
        } else {
          menuItem.icon = '';
        }
      }
      // 处理子菜单项
      if (menuItem !== null && menuItem !== void 0 && menuItem.children) {
        menuItem.children = processMenuItems(menuItem.children);
      }
      return menuItem;
    });
  }
  var newdata = processMenuItems(data);
  otherProps.items = newdata;
  return /*#__PURE__*/React.createElement(_Menu, otherProps);
};
export default CustomNav;