'use strict';

var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var utils = require('./utils-CTr7wn5d.js');
var primitives_RadioGroup = require('./primitives/RadioGroup.js');
var primitives_Label = require('./primitives/Label.js');
var primitives_Field = require('./primitives/Field.js');

const RadioGroupItem = React.forwardRef(({ label, helpText, value, className, id: idProp, ...props }, ref) => {
    const generatedId = React.useId();
    const id = idProp ?? generatedId;
    const helpTextId = `helpText_${id}`;
    return (jsxRuntime.jsxs("div", { className: utils.cn("flex gap-2", helpText ? "items-start" : "items-center", className), children: [jsxRuntime.jsx(primitives_RadioGroup.RadioGroupItem, { ref: ref, id: id, value: value, "aria-describedby": helpText ? helpTextId : undefined, className: helpText ? "mt-0.5" : undefined, ...props }), (label || helpText) && (jsxRuntime.jsxs("div", { className: "flex flex-col gap-0.5", children: [label && (jsxRuntime.jsx(primitives_Label.Label, { htmlFor: id, className: "cursor-pointer font-normal", children: label })), helpText && (jsxRuntime.jsx(primitives_Field.FieldDescription, { id: helpTextId, children: helpText }))] }))] }));
});
RadioGroupItem.displayName = "RadioGroup.Item";
const RadioGroupRoot = React.forwardRef(({ label, error, helpText, orientation = "horizontal", className, disabled, required, children, ...props }, ref) => {
    const generatedId = React.useId();
    const errorId = `error_${generatedId}`;
    const helpTextId = `helpText_${generatedId}`;
    const hasField = !!(label || error || helpText);
    const radioGroup = (jsxRuntime.jsx(primitives_RadioGroup.RadioGroup, { ref: ref, disabled: disabled, required: required, "aria-invalid": !!error || undefined, "aria-describedby": [error ? errorId : null, helpText ? helpTextId : null]
            .filter(Boolean)
            .join(" ") || undefined, orientation: orientation, className: utils.cn("data-[orientation=vertical]:grid data-[orientation=vertical]:gap-2 data-[orientation=horizontal]:flex data-[orientation=horizontal]:flex-row data-[orientation=horizontal]:flex-wrap data-[orientation=horizontal]:items-center data-[orientation=horizontal]:gap-4", !hasField && className), ...props, children: children }));
    if (!hasField) {
        return radioGroup;
    }
    return (jsxRuntime.jsxs(primitives_Field.Field, { "data-disabled": disabled || undefined, "data-invalid": !!error || undefined, className: className, children: [(label || helpText) && (jsxRuntime.jsxs("div", { children: [label && (jsxRuntime.jsxs(primitives_Field.FieldLabel, { children: [label, required && (jsxRuntime.jsx("span", { "aria-hidden": "true", className: "text-destructive", children: "*" }))] })), helpText && (jsxRuntime.jsx(primitives_Field.FieldDescription, { id: helpTextId, children: helpText }))] })), jsxRuntime.jsxs(primitives_Field.FieldContent, { children: [radioGroup, !!error && jsxRuntime.jsx(primitives_Field.FieldError, { id: errorId, children: error })] })] }));
});
RadioGroupRoot.displayName = "RadioGroup";
const RadioGroup = Object.assign(RadioGroupRoot, {
    Item: RadioGroupItem,
});

exports.RadioGroup = RadioGroup;
//# sourceMappingURL=RadioGroup-1RAoe38m.js.map
