/*
 * 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.
 */
import { __assign, __rest } from "tslib";
import classNames from "classnames";
import * as React from "react";
import { Classes, DISPLAYNAME_PREFIX, Utils } from "../../common";
import { isReactNodeEmpty } from "../../common/utils";
import { Icon } from "../icon/icon";
import { Text } from "../text/text";
import { TagRemoveButton } from "./tagRemoveButton";
/**
 * Compound tag component.
 *
 * @see https://blueprintjs.com/docs/#core/components/compound-tag
 */
export var CompoundTag = React.forwardRef(function (props, ref) {
    var _a;
    var active = props.active, children = props.children, className = props.className, fill = props.fill, icon = props.icon, intent = props.intent, interactive = props.interactive, leftContent = props.leftContent, large = props.large, minimal = props.minimal, onRemove = props.onRemove, rightIcon = props.rightIcon, round = props.round, _b = props.tabIndex, tabIndex = _b === void 0 ? 0 : _b, htmlProps = __rest(props, ["active", "children", "className", "fill", "icon", "intent", "interactive", "leftContent", "large", "minimal", "onRemove", "rightIcon", "round", "tabIndex"]);
    var isRemovable = Utils.isFunction(onRemove);
    var tagClasses = classNames(Classes.TAG, Classes.COMPOUND_TAG, Classes.intentClass(intent), (_a = {},
        _a[Classes.ACTIVE] = active,
        _a[Classes.FILL] = fill,
        _a[Classes.INTERACTIVE] = interactive,
        _a[Classes.LARGE] = large,
        _a[Classes.MINIMAL] = minimal,
        _a[Classes.ROUND] = round,
        _a), className);
    return (React.createElement("span", __assign({}, htmlProps, { className: tagClasses, tabIndex: interactive ? tabIndex : undefined, ref: ref }),
        React.createElement("span", { className: Classes.COMPOUND_TAG_LEFT },
            React.createElement(Icon, { icon: icon }),
            React.createElement(Text, { className: classNames(Classes.COMPOUND_TAG_LEFT_CONTENT, Classes.FILL), tagName: "span" }, leftContent)),
        React.createElement("span", { className: Classes.COMPOUND_TAG_RIGHT },
            !isReactNodeEmpty(children) && (React.createElement(Text, { className: classNames(Classes.COMPOUND_TAG_RIGHT_CONTENT, Classes.FILL), tagName: "span" }, children)),
            React.createElement(Icon, { icon: rightIcon }),
            isRemovable && React.createElement(TagRemoveButton, __assign({}, props)))));
});
CompoundTag.defaultProps = {
    active: false,
    fill: false,
    interactive: false,
    large: false,
    minimal: false,
    round: false,
};
CompoundTag.displayName = "".concat(DISPLAYNAME_PREFIX, ".CompoundTag");
//# sourceMappingURL=compoundTag.js.map