"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importStar(require("react"));
var prop_types_1 = __importDefault(require("prop-types"));
var lodash_1 = require("lodash");
var classnames_1 = __importDefault(require("classnames"));
var Icon_1 = require("../Icon");
var BreadCrumb_1 = require("./BreadCrumb");
var BreadCrumbs = /** @class */ (function (_super) {
    __extends(BreadCrumbs, _super);
    function BreadCrumbs() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.renderCrumb = function (item, index) {
            if (index === void 0) { index = 0; }
            var _a = _this.props, items = _a.items, onSelect = _a.onSelect;
            var id = item.id, name = item.name;
            var isFirst = index <= 0;
            var isLast = index >= items.length - 1;
            return (react_1.default.createElement(BreadCrumb_1.BreadCrumb, { key: id, id: id, name: name, isFirst: isFirst, isLast: isLast, onSelect: onSelect, index: index }));
        };
        return _this;
    }
    BreadCrumbs.prototype.render = function () {
        var _a = this.props, iconName = _a.iconName, items = _a.items, style = _a.style, onSelect = _a.onSelect, testAutomationId = _a.testAutomationId;
        var className = classnames_1.default('rc-breadcrumbs', {
            'rc-breadcrumbs-no-handler': !lodash_1.isFunction(onSelect)
        });
        var icon = null;
        if (iconName) {
            icon = react_1.default.createElement(Icon_1.Icon, { name: iconName, className: "rc-breadcrumbs-icon" });
        }
        return (react_1.default.createElement("div", { style: style, className: className, "data-test-automation-id": testAutomationId },
            icon,
            items.map(this.renderCrumb)));
    };
    BreadCrumbs.propTypes = {
        iconName: prop_types_1.default.string,
        items: prop_types_1.default.arrayOf(prop_types_1.default.shape({
            id: prop_types_1.default.oneOfType([prop_types_1.default.number, prop_types_1.default.string]),
            name: prop_types_1.default.string
        })),
        onSelect: prop_types_1.default.func,
        testAutomationId: prop_types_1.default.string,
        style: prop_types_1.default.object
    };
    BreadCrumbs.defaultProps = {
        iconName: null,
        items: [],
        onSelect: null,
        testAutomationId: 'breadcrumbs',
        style: null,
        breadcrumbMaxWidth: 240
    };
    return BreadCrumbs;
}(react_1.Component));
exports.BreadCrumbs = BreadCrumbs;
//# sourceMappingURL=BreadCrumbs.js.map