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 __());
    };
})();
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { isFunction } from 'lodash';
import { filterKeyCodes } from '../../utils/functions';
import { Icon } from '../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 = 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.createElement(Icon, { className: "rc-breadcrumbs-item-icon", name: "chevron-right-small" });
        }
        if (isLast || !isFunction(onSelect)) {
            text = (React.createElement("span", { className: "rc-breadcrumbs-item-name", "data-test-automation-id": "breadcrumbLink", title: name }, name));
        }
        else {
            text = (React.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.createElement("div", { className: "rc-breadcrumbs-item", "data-test-automation-id": "breadcrumb" + index },
            arrowIcon,
            text));
    };
    BreadCrumb.propTypes = {
        id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
        name: PropTypes.string.isRequired,
        index: PropTypes.number.isRequired,
        isFirst: PropTypes.bool,
        isLast: PropTypes.bool,
        onSelect: PropTypes.func
    };
    BreadCrumb.defaultProps = {
        isFirst: false,
        isLast: false,
        onSelect: null
    };
    return BreadCrumb;
}(PureComponent));
export { BreadCrumb };
//# sourceMappingURL=BreadCrumb.js.map