"use strict";

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

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

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

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

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

var _context = require("../config-provider/context");

var _dropdown = _interopRequireDefault(require("../dropdown"));

var _icon = _interopRequireDefault(require("../icon"));

// import classNames from 'classnames';
var DownLine = _icon.default.DownLine;

var BreadcrumbItem = function BreadcrumbItem(_ref) {
  var _ref$separator = _ref.separator,
      separator = _ref$separator === void 0 ? '/' : _ref$separator,
      children = _ref.children,
      overlay = _ref.overlay,
      dropdownProps = _ref.dropdownProps,
      restProps = (0, _objectWithoutProperties2.default)(_ref, ["separator", "children", "overlay", "dropdownProps"]);

  var _useContext = (0, _react.useContext)(_context.ConfigContext),
      getPrefixClassName = _useContext.getPrefixClassName;

  var prefixCls = getPrefixClassName('bread-crumb');

  var renderBreadcrumbNode = function renderBreadcrumbNode(breadcrumbItem) {
    if (overlay) {
      return /*#__PURE__*/_react.default.createElement(_dropdown.default, Object.assign({
        overlay: overlay,
        placement: "bottomCenter"
      }, dropdownProps), /*#__PURE__*/_react.default.createElement("span", {
        className: "".concat(prefixCls, "-overlay-link")
      }, breadcrumbItem, /*#__PURE__*/_react.default.createElement(DownLine, {
        style: {
          marginLeft: 4
        }
      })));
    }

    return breadcrumbItem;
  };

  var link;

  if ('href' in restProps) {
    link = /*#__PURE__*/_react.default.createElement("a", Object.assign({
      className: "".concat(prefixCls, "-link")
    }, restProps), children);
  } else {
    link = /*#__PURE__*/_react.default.createElement("span", Object.assign({
      className: "".concat(prefixCls, "-link")
    }, restProps), children);
  } // wrap to dropDown


  link = renderBreadcrumbNode(link);

  if (children) {
    return /*#__PURE__*/_react.default.createElement("span", null, link, separator && separator !== '' && /*#__PURE__*/_react.default.createElement("span", {
      className: "".concat(prefixCls, "-separator")
    }, separator));
  }

  return null;
}; // BreadcrumbItem._klein_BREADCRUMB_ITEM = true;


var _default = BreadcrumbItem;
exports.default = _default;