'use strict';

var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var utils = require('./utils-CTr7wn5d.js');
var primitives_Checkbox = require('./primitives/Checkbox.js');
var primitives_Field = require('./primitives/Field.js');

const Checkbox = React.forwardRef(({ label, error, helpText, required = false, disabled = false, className, ...otherProps }, ref) => {
    const generatedId = React.useId();
    const id = otherProps.id ?? generatedId;
    const errorId = `error_${id}`;
    const helpTextId = `helpText_${id}`;
    const ariaDescribedBy = [error ? errorId : null, helpText ? helpTextId : null]
        .filter(Boolean)
        .join(" ") || undefined;
    const hasField = !!(label || error || helpText);
    if (!hasField) {
        return (jsxRuntime.jsx(primitives_Checkbox.Checkbox, { ref: ref, id: id, disabled: disabled, "aria-invalid": !!error || undefined, "aria-required": required || undefined, "aria-describedby": ariaDescribedBy, className: className, ...otherProps }));
    }
    return (jsxRuntime.jsxs("div", { className: utils.cn("flex flex-col gap-1", className), "data-disabled": disabled || undefined, "data-invalid": !!error || undefined, children: [jsxRuntime.jsxs(primitives_Field.Field, { orientation: "horizontal", children: [jsxRuntime.jsx(primitives_Checkbox.Checkbox, { ref: ref, id: id, disabled: disabled, "aria-invalid": !!error || undefined, "aria-required": required || undefined, "aria-describedby": ariaDescribedBy, ...otherProps }), jsxRuntime.jsxs(primitives_Field.FieldContent, { children: [label && (jsxRuntime.jsxs(primitives_Field.FieldLabel, { htmlFor: id, children: [label, required && (jsxRuntime.jsx("span", { "aria-hidden": "true", className: "text-destructive", children: "*" }))] })), helpText && (jsxRuntime.jsx(primitives_Field.FieldDescription, { id: helpTextId, children: helpText }))] })] }), error && jsxRuntime.jsx(primitives_Field.FieldError, { id: errorId, children: error })] }));
});
Checkbox.displayName = "Checkbox";

exports.Checkbox = Checkbox;
//# sourceMappingURL=Checkbox-DOlS2oCD.js.map
