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 } from "react";
import { cx } from "../../utils";
import { base as viewCSS } from "./variations/_view/base";
import { base as sizeCSS } from "./variations/_size/base";
import { base as gapCSS } from "./variations/_gap/base";
import { base as shapeCSS } from "./variations/_shape/base";
import { base as orientationCSS } from "./variations/_orientation/base";
import { base as stretchingCSS } from "./variations/_stretching/base";
import { base } from "./ButtonGroup.styles";
import { classes } from "./ButtonGroup.tokens";
export var buttonGroupRoot = function buttonGroupRoot(Root) {
    return /*#__PURE__*/ forwardRef(function(props, ref) {
        var children = props.children, view = props.view, size = props.size, className = props.className, _props_stretching = props.stretching, stretching = _props_stretching === void 0 ? 'auto' : _props_stretching, _props_gap = props.gap, gap = _props_gap === void 0 ? 'dense' : _props_gap, _props_orientation = props.orientation, orientation = _props_orientation === void 0 ? 'horizontal' : _props_orientation, _props_shape = props.shape, shape = _props_shape === void 0 ? 'default' : _props_shape, _props_isCommonButtonStyles = props.isCommonButtonStyles, isCommonButtonStyles = _props_isCommonButtonStyles === void 0 ? true : _props_isCommonButtonStyles, rest = _object_without_properties(props, [
            "children",
            "view",
            "size",
            "className",
            "stretching",
            "gap",
            "orientation",
            "shape",
            "isCommonButtonStyles"
        ]);
        var orientationClass = classes[orientation];
        var gapClass = classes[gap];
        var shapeClass = classes[shape];
        var stretchingClass = classes["".concat(stretching, "Stretching")];
        var overrideStylesClass = isCommonButtonStyles ? classes.buttonGroupOverrideStyles : undefined;
        return /*#__PURE__*/ React.createElement(Root, _object_spread({
            ref: ref,
            view: view,
            size: size,
            gap: gap,
            orientation: orientation,
            shape: shape,
            className: cx(overrideStylesClass, orientationClass, gapClass, shapeClass, stretchingClass, className)
        }, rest), children);
    });
};
export var buttonGroupConfig = {
    name: 'ButtonGroup',
    tag: 'div',
    layout: buttonGroupRoot,
    base: base,
    variations: {
        view: {
            css: viewCSS
        },
        size: {
            css: sizeCSS
        },
        gap: {
            css: gapCSS
        },
        orientation: {
            css: orientationCSS
        },
        shape: {
            css: shapeCSS
        },
        stretching: {
            css: stretchingCSS
        }
    },
    defaults: {
        view: 'primary',
        size: 'm',
        gap: 'dense',
        orientation: 'horizontal',
        shape: 'default',
        stretching: 'auto'
    }
};
