"use client";
'use strict';

var jsxRuntime = require('react/jsx-runtime');
var index$1 = require('../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.cjs');
var React = require('react');
var text = require('../text/text.cjs');
var slider_module = require('./slider.module.css.cjs');
var thumb = require('./thumb.cjs');
var index = require('../../node_modules/.pnpm/@radix-ui_react-slider@1.3.5_@types_react-dom@19.1.7_@types_react@19.1.9__@types_react@19.1.9_p32zwhugtqgn4tfikzqx3cas2u/node_modules/@radix-ui/react-slider/dist/index.cjs');

const slider = index$1.cva(slider_module.default.slider, {
    variants: {
        variant: {
            single: slider_module.default['slider-variant-single'],
            range: slider_module.default['slider-variant-range']
        }
    },
    defaultVariants: {
        variant: 'single'
    }
});
const Slider = React.forwardRef(({ className, variant = 'single', value, defaultValue, min = 0, max = 100, step = 1, label, onChange, 'aria-label': ariaLabel, 'aria-valuetext': ariaValueText, thumbSize = 'large', ...props }, ref) => {
    const isRange = variant === 'range';
    const isThumbSmall = thumbSize === 'small';
    const defaultVal = isRange
        ? defaultValue || [min, max]
        : [defaultValue || min];
    const currentValue = value
        ? isRange
            ? value
            : [value]
        : defaultVal;
    const getLabel = (index) => {
        if (!label)
            return undefined;
        if (typeof label === 'string')
            return label;
        return label[index];
    };
    const getAriaValueText = (index) => {
        if (ariaValueText)
            return ariaValueText;
        const labelText = getLabel(index);
        const val = currentValue[index];
        return labelText ? `${labelText}: ${val}` : `${val}`;
    };
    return (jsxRuntime.jsxs(index.Root, { ref: ref, className: `${slider({ variant })} ${className || ''}`, value: value ? currentValue : undefined, defaultValue: defaultVal, min: min, max: max, step: step, onValueChange: val => onChange?.(isRange ? val : val[0]), "aria-label": ariaLabel || (isRange ? 'Range slider' : 'Slider'), ...props, children: [jsxRuntime.jsx(index.Track, { className: slider_module.default.track, children: jsxRuntime.jsx(index.Range, { className: slider_module.default.range }) }), defaultVal.map((_, i) => (jsxRuntime.jsx(index.Thumb, { className: index$1.cx(slider_module.default.thumb), asChild: true, "aria-label": getLabel(i) || `Thumb ${i + 1}`, "aria-valuetext": getAriaValueText(i), "data-size": thumbSize, children: jsxRuntime.jsxs("div", { children: [isThumbSmall ? (jsxRuntime.jsx("div", { className: slider_module.default.thumbSmall })) : (jsxRuntime.jsx(thumb.ThumbIcon, {})), getLabel(i) && (jsxRuntime.jsx(text.Text, { className: slider_module.default.label, size: isThumbSmall ? 'micro' : 'mini', weight: 'medium', children: getLabel(i) }))] }) }, i)))] }));
});
Slider.displayName = 'Slider';

exports.Slider = Slider;
//# sourceMappingURL=slider.cjs.map
