"use strict";
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ButtonGroup = exports.ButtonGroupBase = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const core_1 = require("../core");
const utils_1 = require("../utils");
const context_1 = require("./context");
const helpers_1 = require("./helpers");
exports.ButtonGroupBase = core_1.styled.divBox `
  display: flex;

  // Border color between Buttons
  > *:not(:last-of-type):not(:focus) {
    border-right-color: ${p => core_1.th.color(p.innerBorderColor)};
  }

  // First Button
  > *:first-of-type:not(:last-of-type) {
    border-right-width: 1px;
  }

  // Middle Buttons
  > *:not(:first-of-type):not(:last-of-type) {
    border-left-width: 0px;
    border-right-width: 1px;
  }

  // Last Button
  > *:not(:first-of-type):last-of-type {
    border-left-width: 0px;
    margin-right: 0;
  }

  // Border color
  > *,
  *:hover {
    border-color: ${p => core_1.th.color(p.innerBorderColor)};
  }

  //
  > .${utils_1.activeClassName}.vui-button-variant-secondaryDark {
    background-color: ${core_1.th.color('skyBlue.90')};
  }

  > .${utils_1.activeClassName}.vui-button-variant-buttonGroupRounded {
    background-color: ${core_1.th.color('seaBlue.main')};
    color: ${core_1.th.color('white')};
  }

  > .vui-button-variant-buttonGroupRounded {
    border-left-width: 1px !important;
  }

  > .${utils_1.activeClassName}.vui-button-variant-buttonGroupRounded:hover {
    background-color: ${core_1.th.color('seaBlue.20')};
  }

  > .${utils_1.activeClassName}.vui-button-variant-buttonGroupRounded:active {
    background-color: ${core_1.th.color('seaBlue.35')};
  }
`;
/**
 * Organizes layout and display of multiple buttons. Controls border visual around and between the buttons.
 * Exposes some props to the children via context.
 */
exports.ButtonGroup = (0, core_1.vui)((props, ref) => {
    const { className, disabled, innerBorderColor, size, variant = 'default' } = props, rest = __rest(props, ["className", "disabled", "innerBorderColor", "size", "variant"]);
    const context = (0, react_1.useMemo)(() => (0, utils_1.filterUndefined)({
        disabled,
        size,
        variant: variant === 'default' ? 'buttonGroupDefault' : 'buttonGroupRounded',
    }), [disabled, size, variant]);
    return ((0, jsx_runtime_1.jsx)(context_1.ButtonGroupProvider, { value: context, children: (0, jsx_runtime_1.jsx)(exports.ButtonGroupBase, Object.assign({ className: (0, utils_1.cs)('vui-buttonGroup', className, `vui-buttonGroup-variant-${variant}`), innerBorderColor: innerBorderColor ? innerBorderColor : (0, helpers_1.getInnerBorderColor)(props), ref }, rest)) }));
});
exports.ButtonGroup.displayName = 'ButtonGroup';
exports.default = exports.ButtonGroup;
//# sourceMappingURL=buttonGroup.js.map