"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 functions_1 = require("../../utils/functions");
var Icon_1 = require("../Icon");
var BreadCrumb = /** @class */ (function (_super) {
    __extends(BreadCrumb, _super);
    function BreadCrumb() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.handleSelect = function () {
            var _a = _this.props, id = _a.id, onSelect = _a.onSelect;
            onSelect(id);
        };
        _this.handleKeyDown = functions_1.filterKeyCodes(_this.handleSelect);
        return _this;
    }
    BreadCrumb.prototype.render = function () {
        var _a = this.props, name = _a.name, isFirst = _a.isFirst, isLast = _a.isLast, onSelect = _a.onSelect, index = _a.index;
        var arrowIcon = null;
        var text = null;
        if (!isFirst) {
            arrowIcon = react_1.default.createElement(Icon_1.Icon, { className: "rc-breadcrumbs-item-icon", name: "chevron-right-small" });
        }
        if (isLast || !lodash_1.isFunction(onSelect)) {
            text = (react_1.default.createElement("span", { className: "rc-breadcrumbs-item-name", "data-test-automation-id": "breadcrumbLink", title: name }, name));
        }
        else {
            text = (react_1.default.createElement("a", { className: "rc-breadcrumbs-item-name rc-breadcrumbs-item-link", tabIndex: 0, onClick: this.handleSelect, onKeyDown: this.handleKeyDown, "data-test-automation-id": "breadcrumbLink", title: name }, name));
        }
        return (react_1.default.createElement("div", { className: "rc-breadcrumbs-item", "data-test-automation-id": "breadcrumb" + index },
            arrowIcon,
            text));
    };
    BreadCrumb.propTypes = {
        id: prop_types_1.default.oneOfType([prop_types_1.default.number, prop_types_1.default.string]).isRequired,
        name: prop_types_1.default.string.isRequired,
        index: prop_types_1.default.number.isRequired,
        isFirst: prop_types_1.default.bool,
        isLast: prop_types_1.default.bool,
        onSelect: prop_types_1.default.func
    };
    BreadCrumb.defaultProps = {
        isFirst: false,
        isLast: false,
        onSelect: null
    };
    return BreadCrumb;
}(react_1.PureComponent));
exports.BreadCrumb = BreadCrumb;
//# sourceMappingURL=BreadCrumb.js.map