import _extends from '../../../../../@babel_runtime@7.24.8/node_modules/@babel/runtime/helpers/esm/extends.js';
import React__default from 'react';
import { createContextScope as $c512c27ab02ef895$export$50c7b4e9d9f19c1 } from '../../../../../@radix-ui_react-context@1.0.1_@types_react@18.2.12_react@18.2.0/node_modules/@radix-ui/react-context/dist/index.js';
import { Primitive as $8927f6f2acc4f386$export$250ffa63cdc0d034 } from '../../../../../@radix-ui_react-primitive@1.0.3_@types_react-dom@18.0.11_@types_react@18.2.12_react-dom@18.3._44pjkdrkjq3hxuh62jsxoggm4e/node_modules/@radix-ui/react-primitive/dist/index.js';
import { createRovingFocusGroupScope as $d7bdfb9eb0fdf311$export$c7109489551a4f4, Root as $d7bdfb9eb0fdf311$export$be92b6f5f03c0fe9, Item as $d7bdfb9eb0fdf311$export$6d08773d2e66f8f2 } from '../../../../../@radix-ui_react-roving-focus@1.0.4_@types_react-dom@18.0.11_@types_react@18.2.12_react-dom@18_753i7szl5dwsjermawvfyhbcfq/node_modules/@radix-ui/react-roving-focus/dist/index.js';
import { Toggle as $b3bbe2732c13b576$export$bea8ebba691c5813 } from '../../../../../@radix-ui_react-toggle@1.0.3_@types_react-dom@18.0.11_@types_react@18.2.12_react-dom@18.3.1_react@18.2.0__react@18.2.0/node_modules/@radix-ui/react-toggle/dist/index.js';
import { useControllableState as $71cd76cc60e0454e$export$6f32135080cb4c3 } from '../../../../../@radix-ui_react-use-controllable-state@1.0.1_@types_react@18.2.12_react@18.2.0/node_modules/@radix-ui/react-use-controllable-state/dist/index.js';
import { useDirection as $f631663db3294ace$export$b39126d51d94e6f3 } from '../../../../../@radix-ui_react-direction@1.0.1_@types_react@18.2.12_react@18.2.0/node_modules/@radix-ui/react-direction/dist/index.js';

/* -------------------------------------------------------------------------------------------------
 * ToggleGroup
 * -----------------------------------------------------------------------------------------------*/ const $6c1fd9e6a8969628$var$TOGGLE_GROUP_NAME = 'ToggleGroup';
const [$6c1fd9e6a8969628$var$createToggleGroupContext, $6c1fd9e6a8969628$export$d1c7c4bcd9f26dd4] = $c512c27ab02ef895$export$50c7b4e9d9f19c1($6c1fd9e6a8969628$var$TOGGLE_GROUP_NAME, [
    $d7bdfb9eb0fdf311$export$c7109489551a4f4
]);
const $6c1fd9e6a8969628$var$useRovingFocusGroupScope = $d7bdfb9eb0fdf311$export$c7109489551a4f4();
const $6c1fd9e6a8969628$export$af3ec21f6cfb5e30 = /*#__PURE__*/ React__default.forwardRef((props, forwardedRef)=>{
    const { type: type , ...toggleGroupProps } = props;
    if (type === 'single') {
        const singleProps = toggleGroupProps;
        return /*#__PURE__*/ React__default.createElement($6c1fd9e6a8969628$var$ToggleGroupImplSingle, _extends({}, singleProps, {
            ref: forwardedRef
        }));
    }
    if (type === 'multiple') {
        const multipleProps = toggleGroupProps;
        return /*#__PURE__*/ React__default.createElement($6c1fd9e6a8969628$var$ToggleGroupImplMultiple, _extends({}, multipleProps, {
            ref: forwardedRef
        }));
    }
    throw new Error(`Missing prop \`type\` expected on \`${$6c1fd9e6a8969628$var$TOGGLE_GROUP_NAME}\``);
});
/* -----------------------------------------------------------------------------------------------*/ const [$6c1fd9e6a8969628$var$ToggleGroupValueProvider, $6c1fd9e6a8969628$var$useToggleGroupValueContext] = $6c1fd9e6a8969628$var$createToggleGroupContext($6c1fd9e6a8969628$var$TOGGLE_GROUP_NAME);
const $6c1fd9e6a8969628$var$ToggleGroupImplSingle = /*#__PURE__*/ React__default.forwardRef((props, forwardedRef)=>{
    const { value: valueProp , defaultValue: defaultValue , onValueChange: onValueChange = ()=>{} , ...toggleGroupSingleProps } = props;
    const [value, setValue] = $71cd76cc60e0454e$export$6f32135080cb4c3({
        prop: valueProp,
        defaultProp: defaultValue,
        onChange: onValueChange
    });
    return /*#__PURE__*/ React__default.createElement($6c1fd9e6a8969628$var$ToggleGroupValueProvider, {
        scope: props.__scopeToggleGroup,
        type: "single",
        value: value ? [
            value
        ] : [],
        onItemActivate: setValue,
        onItemDeactivate: React__default.useCallback(()=>setValue('')
        , [
            setValue
        ])
    }, /*#__PURE__*/ React__default.createElement($6c1fd9e6a8969628$var$ToggleGroupImpl, _extends({}, toggleGroupSingleProps, {
        ref: forwardedRef
    })));
});
const $6c1fd9e6a8969628$var$ToggleGroupImplMultiple = /*#__PURE__*/ React__default.forwardRef((props, forwardedRef)=>{
    const { value: valueProp , defaultValue: defaultValue , onValueChange: onValueChange = ()=>{} , ...toggleGroupMultipleProps } = props;
    const [value1 = [], setValue] = $71cd76cc60e0454e$export$6f32135080cb4c3({
        prop: valueProp,
        defaultProp: defaultValue,
        onChange: onValueChange
    });
    const handleButtonActivate = React__default.useCallback((itemValue)=>setValue((prevValue = [])=>[
                ...prevValue,
                itemValue
            ]
        )
    , [
        setValue
    ]);
    const handleButtonDeactivate = React__default.useCallback((itemValue)=>setValue((prevValue = [])=>prevValue.filter((value)=>value !== itemValue
            )
        )
    , [
        setValue
    ]);
    return /*#__PURE__*/ React__default.createElement($6c1fd9e6a8969628$var$ToggleGroupValueProvider, {
        scope: props.__scopeToggleGroup,
        type: "multiple",
        value: value1,
        onItemActivate: handleButtonActivate,
        onItemDeactivate: handleButtonDeactivate
    }, /*#__PURE__*/ React__default.createElement($6c1fd9e6a8969628$var$ToggleGroupImpl, _extends({}, toggleGroupMultipleProps, {
        ref: forwardedRef
    })));
});
/* -----------------------------------------------------------------------------------------------*/ const [$6c1fd9e6a8969628$var$ToggleGroupContext, $6c1fd9e6a8969628$var$useToggleGroupContext] = $6c1fd9e6a8969628$var$createToggleGroupContext($6c1fd9e6a8969628$var$TOGGLE_GROUP_NAME);
const $6c1fd9e6a8969628$var$ToggleGroupImpl = /*#__PURE__*/ React__default.forwardRef((props, forwardedRef)=>{
    const { __scopeToggleGroup: __scopeToggleGroup , disabled: disabled = false , rovingFocus: rovingFocus = true , orientation: orientation , dir: dir , loop: loop = true , ...toggleGroupProps } = props;
    const rovingFocusGroupScope = $6c1fd9e6a8969628$var$useRovingFocusGroupScope(__scopeToggleGroup);
    const direction = $f631663db3294ace$export$b39126d51d94e6f3(dir);
    const commonProps = {
        role: 'group',
        dir: direction,
        ...toggleGroupProps
    };
    return /*#__PURE__*/ React__default.createElement($6c1fd9e6a8969628$var$ToggleGroupContext, {
        scope: __scopeToggleGroup,
        rovingFocus: rovingFocus,
        disabled: disabled
    }, rovingFocus ? /*#__PURE__*/ React__default.createElement($d7bdfb9eb0fdf311$export$be92b6f5f03c0fe9, _extends({
        asChild: true
    }, rovingFocusGroupScope, {
        orientation: orientation,
        dir: direction,
        loop: loop
    }), /*#__PURE__*/ React__default.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({}, commonProps, {
        ref: forwardedRef
    }))) : /*#__PURE__*/ React__default.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({}, commonProps, {
        ref: forwardedRef
    })));
});
/* -------------------------------------------------------------------------------------------------
 * ToggleGroupItem
 * -----------------------------------------------------------------------------------------------*/ const $6c1fd9e6a8969628$var$ITEM_NAME = 'ToggleGroupItem';
const $6c1fd9e6a8969628$export$b453109e13abe10b = /*#__PURE__*/ React__default.forwardRef((props, forwardedRef)=>{
    const valueContext = $6c1fd9e6a8969628$var$useToggleGroupValueContext($6c1fd9e6a8969628$var$ITEM_NAME, props.__scopeToggleGroup);
    const context = $6c1fd9e6a8969628$var$useToggleGroupContext($6c1fd9e6a8969628$var$ITEM_NAME, props.__scopeToggleGroup);
    const rovingFocusGroupScope = $6c1fd9e6a8969628$var$useRovingFocusGroupScope(props.__scopeToggleGroup);
    const pressed = valueContext.value.includes(props.value);
    const disabled = context.disabled || props.disabled;
    const commonProps = {
        ...props,
        pressed: pressed,
        disabled: disabled
    };
    const ref = React__default.useRef(null);
    return context.rovingFocus ? /*#__PURE__*/ React__default.createElement($d7bdfb9eb0fdf311$export$6d08773d2e66f8f2, _extends({
        asChild: true
    }, rovingFocusGroupScope, {
        focusable: !disabled,
        active: pressed,
        ref: ref
    }), /*#__PURE__*/ React__default.createElement($6c1fd9e6a8969628$var$ToggleGroupItemImpl, _extends({}, commonProps, {
        ref: forwardedRef
    }))) : /*#__PURE__*/ React__default.createElement($6c1fd9e6a8969628$var$ToggleGroupItemImpl, _extends({}, commonProps, {
        ref: forwardedRef
    }));
});
/* -----------------------------------------------------------------------------------------------*/ const $6c1fd9e6a8969628$var$ToggleGroupItemImpl = /*#__PURE__*/ React__default.forwardRef((props, forwardedRef)=>{
    const { __scopeToggleGroup: __scopeToggleGroup , value: value , ...itemProps } = props;
    const valueContext = $6c1fd9e6a8969628$var$useToggleGroupValueContext($6c1fd9e6a8969628$var$ITEM_NAME, __scopeToggleGroup);
    const singleProps = {
        role: 'radio',
        'aria-checked': props.pressed,
        'aria-pressed': undefined
    };
    const typeProps = valueContext.type === 'single' ? singleProps : undefined;
    return /*#__PURE__*/ React__default.createElement($b3bbe2732c13b576$export$bea8ebba691c5813, _extends({}, typeProps, itemProps, {
        ref: forwardedRef,
        onPressedChange: (pressed)=>{
            if (pressed) valueContext.onItemActivate(value);
            else valueContext.onItemDeactivate(value);
        }
    }));
});
/* -----------------------------------------------------------------------------------------------*/ const $6c1fd9e6a8969628$export$be92b6f5f03c0fe9 = $6c1fd9e6a8969628$export$af3ec21f6cfb5e30;
const $6c1fd9e6a8969628$export$6d08773d2e66f8f2 = $6c1fd9e6a8969628$export$b453109e13abe10b;

export { $6c1fd9e6a8969628$export$6d08773d2e66f8f2 as Item, $6c1fd9e6a8969628$export$be92b6f5f03c0fe9 as Root, $6c1fd9e6a8969628$export$af3ec21f6cfb5e30 as ToggleGroup, $6c1fd9e6a8969628$export$b453109e13abe10b as ToggleGroupItem, $6c1fd9e6a8969628$export$d1c7c4bcd9f26dd4 as createToggleGroupScope };
//# sourceMappingURL=index.js.map
