"use strict";

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

var _jsxRuntime = require("react/jsx-runtime");

var _Icon = _interopRequireDefault(require("../Icon"));

var _Breadcrumb = _interopRequireDefault(require("./Breadcrumb"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

/**
 * Generates an array of at most `max` breadcrumbs
 *
 * @param {Number} index      Index of active breadcrumb
 * @param {Number} max        Maximum number of breadcrumbs to dispaly
 * @param {Function} onSelect Handler for selecting a breadcrumb
 * @returns {React.element[]} Array of breadcrumbs
 * @private
 */
var Breadcrumbs = function Breadcrumbs(id, index, max, onSelect) {
  var breadcrumbs = new Array(index < max ? index : max);
  var start = Math.max(index - max, 0);

  for (var i = start; i < index; i++) {
    breadcrumbs[index - i - 1] = /*#__PURE__*/(0, _jsxRuntime.jsx)(_Breadcrumb["default"], {
      onSelect: onSelect,
      id: "".concat(id, "_bc_").concat(i),
      index: i,
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon["default"], {
        children: "arrowlargeleft"
      })
    }, i);
  }

  return breadcrumbs;
};

exports.Breadcrumbs = Breadcrumbs;
var _default = Breadcrumbs;
exports["default"] = _default;