/*
 * Copyright 2016 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 { useInteractiveAttributes } from "../../accessibility/useInteractiveAttributes";
import { Classes, DISPLAYNAME_PREFIX, removeNonHTMLProps, Utils, } from "../../common";
import { isReactNodeEmpty } from "../../common/utils";
import { Icon } from "../icon/icon";
import { Text } from "../text/text";
import { TagRemoveButton } from "./tagRemoveButton";
/**
 * Tag component.
 *
 * @see https://blueprintjs.com/docs/#core/components/tag
 */
export var Tag = React.forwardRef(function (props, ref) {
    var _a;
    var children = props.children, className = props.className, endIcon = props.endIcon, _b = props.fill, fill = _b === void 0 ? false : _b, icon = props.icon, intent = props.intent, interactive = props.interactive, 
    // eslint-disable-next-line @typescript-eslint/no-deprecated
    _c = props.large, 
    // eslint-disable-next-line @typescript-eslint/no-deprecated
    large = _c === void 0 ? false : _c, _d = props.minimal, minimal = _d === void 0 ? false : _d, multiline = props.multiline, onRemove = props.onRemove, 
    // eslint-disable-next-line @typescript-eslint/no-deprecated
    rightIcon = props.rightIcon, _e = props.round, round = _e === void 0 ? false : _e, _f = props.size, size = _f === void 0 ? "medium" : _f, _g = props.tabIndex, tabIndex = _g === void 0 ? 0 : _g, htmlTitle = props.htmlTitle, htmlProps = __rest(props, ["children", "className", "endIcon", "fill", "icon", "intent", "interactive", "large", "minimal", "multiline", "onRemove", "rightIcon", "round", "size", "tabIndex", "htmlTitle"]);
    var isRemovable = Utils.isFunction(onRemove);
    var isInteractive = interactive !== null && interactive !== void 0 ? interactive : htmlProps.onClick != null;
    var _h = useInteractiveAttributes(isInteractive, props, ref, {
        defaultTabIndex: 0,
        disabledTabIndex: undefined,
    }), active = _h[0], interactiveProps = _h[1];
    var tagClasses = classNames(Classes.TAG, Classes.intentClass(intent), Classes.sizeClass(size, { large: large }), (_a = {},
        _a[Classes.ACTIVE] = active,
        _a[Classes.FILL] = fill,
        _a[Classes.INTERACTIVE] = isInteractive,
        _a[Classes.MINIMAL] = minimal,
        _a[Classes.ROUND] = round,
        _a), className);
    return (React.createElement("span", __assign({}, removeNonHTMLProps(htmlProps), interactiveProps, { className: tagClasses }),
        React.createElement(Icon, { icon: icon }),
        !isReactNodeEmpty(children) && (React.createElement(Text, { className: Classes.FILL, ellipsize: !multiline, tagName: "span", title: htmlTitle }, children)),
        React.createElement(Icon, { icon: endIcon !== null && endIcon !== void 0 ? endIcon : rightIcon }),
        isRemovable && React.createElement(TagRemoveButton, __assign({}, props))));
});
Tag.displayName = "".concat(DISPLAYNAME_PREFIX, ".Tag");
//# sourceMappingURL=tag.js.map