import { r as reactExports, j as jsxRuntimeExports, M as Modal, t as twMerge, $ as mergeClassNameProps } from "./index-DEuI3Aoa.js";
const buttonStyles = "min-h-[48px] min-w-[142px] text-base font-semibold py-3 px-6 rounded-xl outline-none active:opacity-75 hover:scale-105 transform transition-all";
function ReadRequiredModal(props) {
  const { body, header, children, onOpenChange, onContinue, closeLabel, overlayProps, contentProps, bodyProps = {}, headerProps = {}, containerProps = {}, continueButtonProps = {}, buttonContainerProps = {}, ...restProps } = props;
  const [disableClose, setDisableClose] = reactExports.useState(true);
  const contentRef = reactExports.useRef(null);
  reactExports.useEffect(() => {
    const checkScroll = () => {
      const element = contentRef.current;
      if (element) {
        if (element.scrollHeight > element.clientHeight) {
          setDisableClose(true);
          element.addEventListener("scroll", handleScroll);
        } else {
          setDisableClose(false);
        }
      }
    };
    const handleScroll = () => {
      const element = contentRef.current;
      if (element && element.scrollHeight - Math.ceil(element.scrollTop) === element.clientHeight) {
        setDisableClose(false);
      }
    };
    requestAnimationFrame(checkScroll);
    return () => {
      const element = contentRef.current;
      if (element) {
        element.removeEventListener("scroll", handleScroll);
      }
    };
  }, []);
  return jsxRuntimeExports.jsx(Modal, { contentProps: {
    ...contentProps,
    className: twMerge("rounded-3xl outline-none", contentProps?.className)
  }, onOpenChange, overlayProps: {
    ...overlayProps,
    className: overlayProps?.className
  }, ...restProps, children: jsxRuntimeExports.jsxs("div", { ...mergeClassNameProps(containerProps, "w-[500px] p-6 text-slate-300"), children: [jsxRuntimeExports.jsx("div", { ...mergeClassNameProps(headerProps, "border-b border-slate-50 pb-2 text-2xl font-bold text-gray-800"), children: header }), jsxRuntimeExports.jsxs("div", { ref: contentRef, ...mergeClassNameProps(bodyProps, "my-6 max-h-[245px] overflow-scroll rounded-md bg-slate-50 p-4 text-center"), children: [body, children] }), jsxRuntimeExports.jsx("div", { ...mergeClassNameProps(buttonContainerProps, "mt-8 flex justify-between gap-3"), children: jsxRuntimeExports.jsx("button", { disabled: disableClose, onClick: onContinue, ...mergeClassNameProps(continueButtonProps, twMerge(buttonStyles, "flex-1 bg-gray-800 text-gray-50", disableClose && "cursor-not-allowed bg-gray-300 hover:scale-100")), children: closeLabel }) })] }) });
}
export {
  ReadRequiredModal as R
};
//# sourceMappingURL=read-required-modal-CXInGGU1.js.map
