import { jsx } from "react/jsx-runtime";
import { useRef, useState, useEffect } from "react";
/* empty css                       */
import FormHelperText from "../../../node_modules/@mui/material/FormHelperText/FormHelperText.js";
function HelperText({ helper, error = false, className = "", minWidth }) {
  const textRef = useRef(null);
  const [isTruncated, setIsTruncated] = useState(false);
  useEffect(() => {
    const el = textRef.current;
    if (el) {
      setIsTruncated(el.scrollWidth > el.clientWidth);
    }
  }, [helper]);
  if (helper == null || helper === "") return null;
  const textElement = /* @__PURE__ */ jsx(
    FormHelperText,
    {
      ref: textRef,
      className: `ia-select-helper-text ${className} ${error ? "Mui-error" : ""}`.trim(),
      error,
      style: { width: minWidth ?? "240px" },
      children: helper
    }
  );
  if (isTruncated && typeof helper === "string") {
    return /* @__PURE__ */ jsx("span", { style: { display: "inline-block" }, title: helper, children: textElement });
  }
  return textElement;
}
HelperText.displayName = "HelperText";
export {
  HelperText
};
