import { jsx, jsxs } from 'react/jsx-runtime';
import { Field, FieldLabel, FieldContent, FieldError, FieldDescription } from './primitives/Field.js';

function SelectFieldWrapper({
  id,
  label,
  error,
  helpText,
  errorId,
  helpTextId,
  isDisabled,
  required,
  testIdPrefix,
  labelProps,
  className,
  children
}) {
  const hasField = !!(label || error || helpText);
  if (!hasField) {
    return /* @__PURE__ */ jsx(
      "div",
      {
        className,
        ...testIdPrefix ? { "data-testid": `${testIdPrefix}-select-container-wrapper` } : {},
        children
      }
    );
  }
  return /* @__PURE__ */ jsxs(
    Field,
    {
      "data-disabled": isDisabled || void 0,
      "data-invalid": !!error || void 0,
      className,
      ...testIdPrefix ? { "data-testid": `${testIdPrefix}-select-container-wrapper` } : {},
      children: [
        label && /* @__PURE__ */ jsxs(
          FieldLabel,
          {
            htmlFor: id,
            ...labelProps,
            ...testIdPrefix ? { "data-testid": `${testIdPrefix}-input-label` } : {},
            children: [
              label,
              required && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "text-destructive", children: "*" })
            ]
          }
        ),
        /* @__PURE__ */ jsxs(FieldContent, { children: [
          children,
          !!error && /* @__PURE__ */ jsx(
            FieldError,
            {
              id: errorId,
              ...testIdPrefix ? { "data-testid": `${testIdPrefix}-select-error` } : {},
              children: error
            }
          ),
          helpText && /* @__PURE__ */ jsx(
            FieldDescription,
            {
              id: helpTextId,
              ...testIdPrefix ? { "data-testid": `${testIdPrefix}-select-help-text` } : {},
              children: helpText
            }
          )
        ] })
      ]
    }
  );
}

export { SelectFieldWrapper as S };
//# sourceMappingURL=SelectFieldWrapper-CiBARDsn.js.map
