function _define_property(obj, key, value) {
    if (key in obj) {
        Object.defineProperty(obj, key, {
            value: value,
            enumerable: true,
            configurable: true,
            writable: true
        });
    } else {
        obj[key] = value;
    }
    return obj;
}
function _object_spread(target) {
    for(var i = 1; i < arguments.length; i++){
        var source = arguments[i] != null ? arguments[i] : {};
        var ownKeys = Object.keys(source);
        if (typeof Object.getOwnPropertySymbols === "function") {
            ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
                return Object.getOwnPropertyDescriptor(source, sym).enumerable;
            }));
        }
        ownKeys.forEach(function(key) {
            _define_property(target, key, source[key]);
        });
    }
    return target;
}
function _object_without_properties(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys, key, i;
    if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
        sourceKeys = Reflect.ownKeys(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
        return target;
    }
    target = _object_without_properties_loose(source, excluded);
    if (Object.getOwnPropertySymbols) {
        sourceKeys = Object.getOwnPropertySymbols(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
    }
    return target;
}
function _object_without_properties_loose(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
    for(i = 0; i < sourceKeys.length; i++){
        key = sourceKeys[i];
        if (excluded.indexOf(key) >= 0) continue;
        if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
        target[key] = source[key];
    }
    return target;
}
import React, { forwardRef, useRef, useContext } from "react";
import { useForkRef } from "../../../../../hooks";
import { cx } from "../../../../../utils";
import { TabsContext } from "../../..";
import { classes } from "../../../tokens";
import { useTabItem } from "../../../hooks/useTabItem";
import { base as viewCSS } from "./variations/_view/base";
import { base as sizeCSS } from "./variations/_size/base";
import { base as disabledCSS } from "./variations/_disabled/base";
import { ActionContent, StyledContent, base } from "./HorizontalIconTabItem.styles";
export var horizontalIconTabItemRoot = function horizontalIconTabItemRoot(Root) {
    return /*#__PURE__*/ forwardRef(function(props, outerRef) {
        var size = props.size, view = props.view, children = props.children, selected = props.selected, _props_disabled = props.disabled, disabled = _props_disabled === void 0 ? false : _props_disabled, actionContent = props.actionContent, itemIndex = props.itemIndex, tabIndex = props.tabIndex, className = props.className, onIndexChange = props.onIndexChange, onClick = props.onClick, isActive = props.isActive, _props_animated = props.animated, animated = _props_animated === void 0 ? true : _props_animated, rest = _object_without_properties(props, [
            "size",
            "view",
            "children",
            "selected",
            "disabled",
            "actionContent",
            "itemIndex",
            "tabIndex",
            "className",
            "onIndexChange",
            "onClick",
            "isActive",
            "animated"
        ]);
        var innerRef = useRef(null);
        var ref = useForkRef(outerRef, innerRef);
        var refs = useContext(TabsContext);
        var role = 'tab';
        var animatedClass = animated ? classes.tabItemAnimated : undefined;
        var selectedClass = isActive || selected ? classes.selectedTabsItem : undefined;
        var _useTabItem = useTabItem({
            refs: refs,
            innerRef: innerRef,
            itemIndex: itemIndex,
            selected: selected,
            disabled: disabled,
            onIndexChange: onIndexChange,
            onClick: onClick,
            orientation: rest.orientation
        }), hasKeyNavigation = _useTabItem.hasKeyNavigation, navigationTabIndex = _useTabItem.navigationTabIndex, onItemFocus = _useTabItem.onItemFocus, handleClick = _useTabItem.handleClick;
        return /*#__PURE__*/ React.createElement(Root, _object_spread({
            ref: ref,
            className: cx(selectedClass, animatedClass, className),
            disabled: disabled,
            role: role,
            view: view,
            size: size,
            tabIndex: hasKeyNavigation ? navigationTabIndex : tabIndex,
            onFocus: onItemFocus,
            onClick: handleClick
        }, rest), /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(StyledContent, {
            className: classes.tabContent
        }, children), actionContent && /*#__PURE__*/ React.createElement(ActionContent, null, actionContent)));
    });
};
export var horizontalIconTabItemConfig = {
    name: 'HorizontalIconTabItem',
    tag: 'button',
    layout: horizontalIconTabItemRoot,
    base: base,
    variations: {
        size: {
            css: sizeCSS
        },
        view: {
            css: viewCSS
        },
        disabled: {
            css: disabledCSS,
            attrs: true
        }
    },
    defaults: {
        view: 'default'
    }
};
