import { jsx } from 'react/jsx-runtime';
import { forwardRef } from 'react';
import { c as cn } from './utils-BJnb9o5c.js';
import { SheetHeader as SheetHeader$1, SheetFooter as SheetFooter$1, SheetTitle as SheetTitle$1, SheetDescription as SheetDescription$1, Sheet as Sheet$1, SheetContent } from './primitives/Sheet.js';

const SIZE_CLASS_MAP = {
  small: "data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm",
  large: "data-[side=left]:sm:max-w-lg data-[side=right]:sm:max-w-lg",
  extraLarge: "data-[side=left]:sm:max-w-2xl data-[side=right]:sm:max-w-2xl"
};

const SheetHeader = forwardRef(
  ({ children, className, ...otherProps }, ref) => /* @__PURE__ */ jsx(
    SheetHeader$1,
    {
      ref,
      className: cn(className),
      "data-testid": "sheet-header",
      ...otherProps,
      children
    }
  )
);
SheetHeader.displayName = "Sheet.Header";
const SheetBody = forwardRef(({ children, className, hasFooter = true, ...otherProps }, ref) => /* @__PURE__ */ jsx(
  "div",
  {
    ref,
    "data-slot": "sheet-body",
    "data-testid": "sheet-body",
    className: cn(
      "flex flex-1 flex-col items-start justify-start overflow-y-auto px-6",
      hasFooter && "pb-0",
      className
    ),
    ...otherProps,
    children
  }
));
SheetBody.displayName = "Sheet.Body";
const SheetFooter = forwardRef(
  ({ children, className, ...otherProps }, ref) => /* @__PURE__ */ jsx(
    SheetFooter$1,
    {
      ref,
      className: cn(
        "flex flex-row items-center justify-start gap-2",
        className
      ),
      "data-testid": "sheet-footer",
      ...otherProps,
      children
    }
  )
);
SheetFooter.displayName = "Sheet.Footer";
const SheetTitle = forwardRef(({ children, className, ...otherProps }, ref) => /* @__PURE__ */ jsx(
  SheetTitle$1,
  {
    ref,
    className: cn("text-2xl font-semibold", className),
    ...otherProps,
    children
  }
));
SheetTitle.displayName = "Sheet.Title";
const SheetDescription = forwardRef(({ children, className, ...otherProps }, ref) => /* @__PURE__ */ jsx(
  SheetDescription$1,
  {
    ref,
    className: cn(className),
    ...otherProps,
    children
  }
));
SheetDescription.displayName = "Sheet.Description";
const Sheet = forwardRef(
  ({
    size = "small",
    isOpen = false,
    onClose = () => {
    },
    children,
    className,
    closeOnEsc = true,
    closeButton = true,
    backdropClassName,
    closeOnOutsideClick = true,
    initialFocusRef,
    finalFocusRef,
    side = "right",
    modal,
    defaultOpen,
    // Radix content handlers — intercept and merge
    onOpenAutoFocus: onOpenAutoFocusProp,
    onCloseAutoFocus: onCloseAutoFocusProp,
    ...otherProps
  }, 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) {
        e.preventDefault();
        if (initialFocusRef.current) {
          initialFocusRef.current.focus();
        } else {
          requestAnimationFrame(() => initialFocusRef.current?.focus());
        }
      }
      onOpenAutoFocusProp?.(e);
    };
    const handleCloseAutoFocus = (e) => {
      if (finalFocusRef?.current) {
        e.preventDefault();
        finalFocusRef.current.focus();
      }
      onCloseAutoFocusProp?.(e);
    };
    return /* @__PURE__ */ jsx(
      Sheet$1,
      {
        open: isOpen,
        onOpenChange: handleOpenChange,
        modal,
        defaultOpen,
        children: /* @__PURE__ */ jsx(
          SheetContent,
          {
            ref,
            side,
            showCloseButton: closeButton,
            overlayClassName: backdropClassName,
            onInteractOutside: handleInteractOutside,
            onEscapeKeyDown: handleEscapeKeyDown,
            onOpenAutoFocus: handleOpenAutoFocus,
            onCloseAutoFocus: handleCloseAutoFocus,
            className: cn(SIZE_CLASS_MAP[size], className),
            "data-testid": "sheet-wrapper",
            ...otherProps,
            children
          }
        )
      }
    );
  }
);
Sheet.displayName = "Sheet";
Sheet.Header = SheetHeader;
Sheet.Body = SheetBody;
Sheet.Footer = SheetFooter;
Sheet.Title = SheetTitle;
Sheet.Description = SheetDescription;

export { Sheet as S };
//# sourceMappingURL=Sheet-Bw8GVQPS.js.map
