/**
 * @license MIT
 * author: Cube Dev Team
 * @cube-dev/ui-kit v0.0.0-canary-032998c
 * Released under the MIT license.
 */

import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { forwardRef } from 'react';
import { extractStyles, OUTER_STYLES } from '../../../tasty/index.js';
import { mergeProps } from '../../../utils/react/index.js';
import { Gradation } from './Gradation.js';
import { SliderBase, } from './SliderBase.js';
import { SliderThumb } from './SliderThumb.js';
import { SliderTrack } from './SliderTrack.js';
function Slider(props, ref) {
    const { onChange, onChangeEnd, value, defaultValue, getValueLabel, isDisabled, styles, gradation, orientation, trackStyles, thumbStyles, thumbTokens, ...otherProps } = props;
    let baseProps = {
        ...otherProps,
        // Normalize `value: number[]` to `value: number`
        value: value != null ? [value] : undefined,
        defaultValue: defaultValue != null ? [defaultValue] : undefined,
        onChange: (v) => {
            onChange?.(v[0]);
        },
        onChangeEnd: (v) => {
            onChangeEnd?.(v[0]);
        },
        getValueLabel: getValueLabel ? ([v]) => getValueLabel(v) : undefined,
    };
    const extractedStyles = extractStyles(otherProps, OUTER_STYLES, styles);
    return (_jsx(SliderBase, { ...mergeProps(otherProps, baseProps), ref: ref, orientation: orientation, styles: extractedStyles, children: ({ trackRef, inputRef, state }) => {
            return (_jsxs(_Fragment, { children: [_jsx(Gradation, { state: state, ranges: [0, 1], values: gradation }), _jsx(SliderTrack, { state: state, isDisabled: isDisabled, orientation: orientation, styles: trackStyles }), _jsx(SliderThumb, { index: 0, state: state, inputRef: inputRef, trackRef: trackRef, isDisabled: isDisabled, styles: thumbStyles, tokens: thumbTokens })] }));
        } }));
}
const _Slider = forwardRef(Slider);
const __Slider = Object.assign(_Slider, {
    cubeInputType: 'Number',
    displayName: 'Slider',
});
export { __Slider as Slider };

        