/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-e694c50 | Cube Dev Team */
import { extractStyles } from "../../../utils/styles.js";
import { mergeProps } from "../../../utils/react/mergeProps.js";
import { Gradation } from "./Gradation.js";
import { _SliderBase } from "./SliderBase.js";
import { SliderThumb } from "./SliderThumb.js";
import { SliderTrack } from "./SliderTrack.js";
import { OUTER_STYLES } from "@tenphi/tasty";
import { forwardRef } from "react";
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";

//#region src/components/fields/Slider/Slider.tsx
function Slider(props, ref) {
	const { onChange, onChangeEnd, value, defaultValue, getValueLabel, isDisabled, styles, gradation, orientation, trackStyles, thumbStyles, thumbTokens, ...otherProps } = props;
	let baseProps = {
		...otherProps,
		value: value != null ? [value] : void 0,
		defaultValue: defaultValue != null ? [defaultValue] : void 0,
		onChange: (v) => {
			onChange?.(v[0]);
		},
		onChangeEnd: (v) => {
			onChangeEnd?.(v[0]);
		},
		getValueLabel: getValueLabel ? ([v]) => getValueLabel(v) : void 0
	};
	const extractedStyles = extractStyles(otherProps, OUTER_STYLES, styles);
	return /* @__PURE__ */ jsx(_SliderBase, {
		...mergeProps(otherProps, baseProps),
		ref,
		orientation,
		styles: extractedStyles,
		children: ({ trackRef, inputRef, state }) => {
			return /* @__PURE__ */ jsxs(Fragment$1, { children: [
				/* @__PURE__ */ jsx(Gradation, {
					state,
					ranges: [0, 1],
					values: gradation
				}),
				/* @__PURE__ */ jsx(SliderTrack, {
					state,
					isDisabled,
					orientation,
					styles: trackStyles
				}),
				/* @__PURE__ */ jsx(SliderThumb, {
					index: 0,
					state,
					inputRef,
					trackRef,
					isDisabled,
					styles: thumbStyles,
					tokens: thumbTokens
				})
			] });
		}
	});
}
const _Slider = forwardRef(Slider);
const __Slider = Object.assign(_Slider, {
	cubeInputType: "Number",
	displayName: "Slider"
});

//#endregion
export { __Slider };
//# sourceMappingURL=Slider.js.map