'use strict';

var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var utils = require('./utils-BhM0B89p.js');
var primitives_Dialog = require('./primitives/Dialog.js');

const SIZE_CLASS_MAP = {
  small: "sm:max-w-sm",
  medium: "sm:max-w-md",
  large: "sm:max-w-lg",
  fullScreen: "h-screen w-screen max-w-none rounded-none sm:max-w-none"
};

const DialogHeader = React.forwardRef(({ children, className, description, dataTestid, ...otherProps }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
  primitives_Dialog.DialogHeader,
  {
    ref,
    className: utils.cn(className),
    "data-testid": dataTestid ?? "dialog-header",
    ...otherProps,
    children: [
      children,
      description && /* @__PURE__ */ jsxRuntime.jsx(primitives_Dialog.DialogDescription, { children: description })
    ]
  }
));
DialogHeader.displayName = "Dialog.Header";
const DialogBody = React.forwardRef(
  ({ children, className, dataTestid, ...otherProps }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
    "div",
    {
      ref,
      "data-slot": "dialog-body",
      "data-testid": dataTestid ?? "dialog-body",
      className: utils.cn("text-sm text-foreground", className),
      ...otherProps,
      children
    }
  )
);
DialogBody.displayName = "Dialog.Body";
const DialogFooter = React.forwardRef(
  ({ children, className, dataTestid, ...otherProps }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
    primitives_Dialog.DialogFooter,
    {
      ref,
      className: utils.cn(className),
      "data-testid": dataTestid ?? "dialog-footer",
      ...otherProps,
      children
    }
  )
);
DialogFooter.displayName = "Dialog.Footer";
const DialogTitle = React.forwardRef(({ children, className, ...otherProps }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
  primitives_Dialog.DialogTitle,
  {
    ref,
    className: utils.cn("text-2xl font-semibold", className),
    ...otherProps,
    children
  }
));
DialogTitle.displayName = "Dialog.Title";
const Dialog = React.forwardRef(
  ({
    size = "medium",
    isOpen = false,
    onClose = () => {
    },
    children,
    className,
    closeOnEsc = true,
    closeButton = true,
    backdropClassName,
    closeOnOutsideClick = true,
    initialFocusRef,
    finalFocusRef,
    blockScrollOnMount = true,
    forceRender = false,
    modal: modalProp,
    defaultOpen,
    // Radix content handlers — intercept and merge
    onOpenAutoFocus: onOpenAutoFocusProp,
    onCloseAutoFocus: onCloseAutoFocusProp,
    ...otherContentProps
  }, ref) => {
    const handleOpenChange = (open) => {
      if (!open) onClose();
    };
    const handleInteractOutside = (e) => {
      if (!closeOnOutsideClick) e.preventDefault();
    };
    const handleEscapeKeyDown = (e) => {
      if (!closeOnEsc) e.preventDefault();
    };
    const handleOpenAutoFocus = (e) => {
      if (initialFocusRef?.current) {
        e.preventDefault();
        initialFocusRef.current.focus();
      }
      onOpenAutoFocusProp?.(e);
    };
    const handleCloseAutoFocus = (e) => {
      if (finalFocusRef?.current) {
        e.preventDefault();
        finalFocusRef.current.focus();
      }
      onCloseAutoFocusProp?.(e);
    };
    const resolvedModal = modalProp ?? blockScrollOnMount;
    return /* @__PURE__ */ jsxRuntime.jsx(
      primitives_Dialog.Dialog,
      {
        open: isOpen,
        onOpenChange: handleOpenChange,
        modal: resolvedModal,
        defaultOpen,
        children: /* @__PURE__ */ jsxRuntime.jsx(
          primitives_Dialog.DialogContent,
          {
            ref,
            "aria-modal": true,
            showCloseButton: closeButton,
            forceMount: forceRender || void 0,
            overlayClassName: backdropClassName,
            onInteractOutside: handleInteractOutside,
            onEscapeKeyDown: handleEscapeKeyDown,
            onOpenAutoFocus: handleOpenAutoFocus,
            onCloseAutoFocus: handleCloseAutoFocus,
            className: utils.cn(SIZE_CLASS_MAP[size], className),
            "data-testid": "dialog-wrapper",
            ...otherContentProps,
            children
          }
        )
      }
    );
  }
);
Dialog.displayName = "Dialog";
Dialog.Header = DialogHeader;
Dialog.Body = DialogBody;
Dialog.Footer = DialogFooter;
Dialog.Title = DialogTitle;

exports.Dialog = Dialog;
//# sourceMappingURL=Dialog-CBSuKeu_.js.map
