'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var React = require('react');
var index$1 = require('../../utils/index.js');
var base$1 = require('./variations/_size/base.js');
var base = require('./variations/_view/base.js');
var Breadcrumbs_styles = require('./Breadcrumbs.styles.js');
var index = require('./utils/index.js');
var getShortItems = require('./utils/getShortItems.js');

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

var React__default = /*#__PURE__*/_interopDefault(React);

var breadcrumbsRoot = function breadcrumbsRoot(Root) {
  return /*#__PURE__*/React.forwardRef(function (_ref, outerRootRef) {
    var view = _ref.view,
      size = _ref.size,
      separator = _ref.separator,
      items = _ref.items,
      _ref$showItems = _ref.showItems,
      showItems = _ref$showItems === void 0 ? items.length : _ref$showItems,
      className = _ref.className;
    var renderSeparator = separator !== null && separator !== void 0 ? separator : /*#__PURE__*/React__default.default.createElement(Breadcrumbs_styles.Separator, {
      color: "inherit",
      size: index.convertIconSize(size)
    });
    var renderItems = getShortItems.getRenderItems(items, renderSeparator, showItems);
    var itemsWithSeparator = index.addSeparator(renderItems, renderSeparator);
    return /*#__PURE__*/React__default.default.createElement(Root, {
      ref: outerRootRef,
      size: size,
      view: view,
      className: index$1.cx(className),
      items: items
    }, itemsWithSeparator.map(function (item, index) {
      return /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, {
        key: index
      }, item);
    }));
  });
};
var breadcrumbsConfig = {
  name: 'Breadcrumbs',
  tag: 'div',
  layout: breadcrumbsRoot,
  base: Breadcrumbs_styles.base,
  variations: {
    view: {
      css: base.base
    },
    size: {
      css: base$1.base
    }
  },
  defaults: {
    view: 'default',
    size: 'm'
  }
};

exports.breadcrumbsConfig = breadcrumbsConfig;
exports.breadcrumbsRoot = breadcrumbsRoot;
