"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Group = void 0;
var react_1 = __importDefault(require("react"));
var ui_i18n_1 = __importDefault(require("ui-i18n"));
var react_select_1 = require("react-select");
var Add_1 = __importDefault(require("@mui/icons-material/Add"));
var styles_1 = require("./styles");
var ComponentsGroup = react_select_1.components.Group;
var Group = function (props) {
    var styles = (0, styles_1.useStyles)();
    var _a = props.selectProps, inputValue = _a.inputValue, onCreate = _a.onCreate, canCreateOption = _a.canCreateOption, data = props.data, children = props.children;
    return (react_1.default.createElement(ComponentsGroup, __assign({}, props),
        react_1.default.createElement("div", { className: styles.groupHeading },
            react_1.default.createElement("span", null, data.label),
            onCreate && canCreateOption(data.entityType) && (react_1.default.createElement("span", { onClick: function () { return onCreate(inputValue, data.entityType); }, className: styles.addLabel },
                react_1.default.createElement(Add_1.default, { className: styles.addIcon }),
                inputValue
                    ? ui_i18n_1.default.text('Create "${name}" as new ${entityTypeLabel}', {
                        name: inputValue,
                        entityTypeLabel: data.label
                    })
                    : ui_i18n_1.default.text('Create new ${entityTypeLabel}', { entityTypeLabel: data.label })))),
        children));
};
exports.Group = Group;
