'use strict';

var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var primitives_Switch = require('./primitives/Switch.js');
var primitives_Label = require('./primitives/Label.js');
var utils = require('./utils-CTr7wn5d.js');

const Switch = React.forwardRef(({ label, error, helpText, required = false, className, size = "default", disabled, id: idProp, ...otherProps }, ref) => {
    const generatedId = React.useId();
    const id = idProp ?? generatedId;
    const errorId = `error_${id}`;
    const helpTextId = `helpText_${id}`;
    const ariaDescribedBy = [error ? errorId : null, helpText ? helpTextId : null]
        .filter(Boolean)
        .join(" ") || undefined;
    return (jsxRuntime.jsxs("div", { className: utils.cn("inline-flex flex-col gap-1.5", className), "data-disabled": disabled || undefined, "data-invalid": !!error || undefined, children: [jsxRuntime.jsxs("div", { className: utils.cn("inline-flex gap-2", helpText ? "items-start" : "items-center"), children: [jsxRuntime.jsx(primitives_Switch.Switch, { ref: ref, id: id, size: size, disabled: disabled, "aria-invalid": !!error || undefined, "aria-describedby": ariaDescribedBy, "aria-required": required || undefined, className: helpText ? "mt-0.5" : undefined, ...otherProps }), (label || helpText) && (jsxRuntime.jsxs("div", { className: "flex flex-col gap-0.5", children: [label && (jsxRuntime.jsxs(primitives_Label.Label, { htmlFor: id, className: utils.cn("cursor-pointer", disabled && "cursor-not-allowed opacity-50"), children: [label, required && (jsxRuntime.jsx("span", { "aria-hidden": "true", className: "text-destructive", children: "*" }))] })), helpText && (jsxRuntime.jsx("p", { id: helpTextId, className: "text-sm text-muted-foreground", children: helpText }))] }))] }), error && (jsxRuntime.jsx("p", { id: errorId, role: "alert", className: "text-xs text-destructive", children: error }))] }));
});
Switch.displayName = "Switch";

exports.Switch = Switch;
//# sourceMappingURL=Switch-CFf8DtB_.js.map
