'use strict';

var jsxRuntime = require('../../node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.cjs');
var React = require('react');
var index = require('../../node_modules/.pnpm/@radix-ui_react-slider@1.2.2_@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-slider/dist/index.cjs');
var index$1 = require('../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.cjs');
var slider_module = require('./slider.module.css.cjs');
var thumb = require('./thumb.cjs');

function _interopNamespaceDefault(e) {
    var n = Object.create(null);
    if (e) {
        Object.keys(e).forEach(function (k) {
            if (k !== 'default') {
                var d = Object.getOwnPropertyDescriptor(e, k);
                Object.defineProperty(n, k, d.get ? d : {
                    enumerable: true,
                    get: function () { return e[k]; }
                });
            }
        });
    }
    n.default = e;
    return Object.freeze(n);
}

var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);

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__namespace.forwardRef(({ className, variant = 'single', value, defaultValue, min = 0, max = 100, step = 1, label, onChange, 'aria-label': ariaLabel, 'aria-valuetext': ariaValueText, ...props }, ref) => {
    const isRange = variant === 'range';
    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.jsxRuntimeExports.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.jsxRuntimeExports.jsx(index.Track, { className: slider_module.default.track, children: jsxRuntime.jsxRuntimeExports.jsx(index.Range, { className: slider_module.default.range }) }), defaultVal.map((_, i) => (jsxRuntime.jsxRuntimeExports.jsx(index.Thumb, { className: slider_module.default.thumb, asChild: true, "aria-label": getLabel(i) || `Thumb ${i + 1}`, "aria-valuetext": getAriaValueText(i), children: jsxRuntime.jsxRuntimeExports.jsxs("div", { children: [jsxRuntime.jsxRuntimeExports.jsx(thumb.ThumbIcon, {}), getLabel(i) && jsxRuntime.jsxRuntimeExports.jsx("div", { className: slider_module.default.label, children: getLabel(i) })] }) }, i)))] }));
});
Slider.displayName = 'Slider';

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