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 from 'react';
import PropTypes from 'prop-types';
import { filterKeyCodes } from '../../utils/functions';
import { CatalogItemIcon } from './CatalogItemIcon';
import { CatalogSimplePrice } from './CatalogSimplePrice';
var CatalogGridItem = /** @class */ (function (_super) {
    __extends(CatalogGridItem, _super);
    function CatalogGridItem() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.handleKeyDown = filterKeyCodes(_this.props.onClick);
        return _this;
    }
    CatalogGridItem.prototype.renderDescription = function () {
        var _a = this.props, description = _a.description, price = _a.price;
        if (!description && !price) {
            return null;
        }
        if (price) {
            var pricePurchase = price.pricePurchase, priceAnnual = price.priceAnnual, priceMonthly = price.priceMonthly, isPriceFrom = price.isPriceFrom;
            return (React.createElement(CatalogSimplePrice, { isCentered: true, pricePurchase: pricePurchase, priceAnnual: priceAnnual, priceMonthly: priceMonthly, isPriceFrom: isPriceFrom }));
        }
        return (React.createElement("div", { className: "rc-catalog-grid-item__desc", "data-test-automation-id": "description" }, description));
    };
    CatalogGridItem.prototype.renderIcon = function () {
        var _a = this.props, icon = _a.icon, color = _a.color;
        if (React.isValidElement(icon)) {
            return icon;
        }
        return React.createElement(CatalogItemIcon, { isRound: true, size: 90, iconName: icon, backgroundColor: color });
    };
    CatalogGridItem.prototype.render = function () {
        var _a = this.props, testAutomationId = _a.testAutomationId, name = _a.name, onClick = _a.onClick;
        return (React.createElement("div", { "data-test-automation-id": testAutomationId, className: "rc-catalog-grid-item__block", role: "button", onClick: onClick, onKeyDown: this.handleKeyDown, tabIndex: 0 },
            this.renderIcon(),
            React.createElement("div", { className: "rc-catalog-grid-item__name", "data-test-automation-id": "name" }, name),
            this.renderDescription()));
    };
    CatalogGridItem.propTypes = {
        testAutomationId: PropTypes.string,
        name: PropTypes.string.isRequired,
        description: PropTypes.string,
        icon: PropTypes.string,
        color: PropTypes.string,
        onClick: PropTypes.func,
        price: PropTypes.shape({
            pricePurchase: PropTypes.object,
            priceAnnual: PropTypes.object,
            priceMonthly: PropTypes.object,
            isPriceFrom: PropTypes.bool
        })
    };
    CatalogGridItem.defaultProps = {
        testAutomationId: 'catalogGridItem',
        description: null,
        icon: null,
        color: null,
        price: null,
        onClick: function () { }
    };
    return CatalogGridItem;
}(React.PureComponent));
export { CatalogGridItem };
//# sourceMappingURL=CatalogGridItem.js.map