"use strict";
/*
 * Copyright 2024 Palantir Technologies, Inc. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.CompoundTag = void 0;
var tslib_1 = require("tslib");
var classnames_1 = tslib_1.__importDefault(require("classnames"));
var React = tslib_1.__importStar(require("react"));
var common_1 = require("../../common");
var utils_1 = require("../../common/utils");
var icon_1 = require("../icon/icon");
var text_1 = require("../text/text");
var tagRemoveButton_1 = require("./tagRemoveButton");
/**
 * Compound tag component.
 *
 * @see https://blueprintjs.com/docs/#core/components/compound-tag
 */
exports.CompoundTag = React.forwardRef(function (props, ref) {
    var _a;
    var _b = props.active, active = _b === void 0 ? false : _b, children = props.children, className = props.className, _c = props.fill, fill = _c === void 0 ? false : _c, icon = props.icon, intent = props.intent, _d = props.interactive, interactive = _d === void 0 ? false : _d, leftContent = props.leftContent, _e = props.large, large = _e === void 0 ? false : _e, _f = props.minimal, minimal = _f === void 0 ? false : _f, onRemove = props.onRemove, rightIcon = props.rightIcon, _g = props.round, round = _g === void 0 ? false : _g, _h = props.tabIndex, tabIndex = _h === void 0 ? 0 : _h, htmlProps = tslib_1.__rest(props, ["active", "children", "className", "fill", "icon", "intent", "interactive", "leftContent", "large", "minimal", "onRemove", "rightIcon", "round", "tabIndex"]);
    var isRemovable = common_1.Utils.isFunction(onRemove);
    var tagClasses = (0, classnames_1.default)(common_1.Classes.TAG, common_1.Classes.COMPOUND_TAG, common_1.Classes.intentClass(intent), (_a = {},
        _a[common_1.Classes.ACTIVE] = active,
        _a[common_1.Classes.FILL] = fill,
        _a[common_1.Classes.INTERACTIVE] = interactive,
        _a[common_1.Classes.LARGE] = large,
        _a[common_1.Classes.MINIMAL] = minimal,
        _a[common_1.Classes.ROUND] = round,
        _a), className);
    return (React.createElement("span", tslib_1.__assign({}, htmlProps, { className: tagClasses, tabIndex: interactive ? tabIndex : undefined, ref: ref }),
        React.createElement("span", { className: common_1.Classes.COMPOUND_TAG_LEFT },
            React.createElement(icon_1.Icon, { icon: icon }),
            React.createElement(text_1.Text, { className: (0, classnames_1.default)(common_1.Classes.COMPOUND_TAG_LEFT_CONTENT, common_1.Classes.FILL), tagName: "span" }, leftContent)),
        React.createElement("span", { className: common_1.Classes.COMPOUND_TAG_RIGHT },
            !(0, utils_1.isReactNodeEmpty)(children) && (React.createElement(text_1.Text, { className: (0, classnames_1.default)(common_1.Classes.COMPOUND_TAG_RIGHT_CONTENT, common_1.Classes.FILL), tagName: "span" }, children)),
            React.createElement(icon_1.Icon, { icon: rightIcon }),
            isRemovable && React.createElement(tagRemoveButton_1.TagRemoveButton, tslib_1.__assign({}, props)))));
});
exports.CompoundTag.displayName = "".concat(common_1.DISPLAYNAME_PREFIX, ".CompoundTag");
//# sourceMappingURL=compoundTag.js.map