/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-f1f3d22 | Cube Dev Team */
import { tasty } from "../../../tasty/tasty.js";
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
import { _Overlay } from "./Overlay.js";
import { _Underlay } from "./Underlay.js";
import { OVERLAY_WRAPPER_STYLES } from "./Modal.js";
import { forwardRef } from "react";
import { jsx, jsxs } from "react/jsx-runtime";
import { useModal, useOverlay, usePreventScroll } from "react-aria";
import { useDOMRef } from "@react-spectrum/utils";

//#region src/components/overlays/Modal/Tray.tsx
const TrayWrapperElement = tasty({
	qa: "TrayWrapper",
	styles: {
		...OVERLAY_WRAPPER_STYLES,
		placeContent: "end center",
		placeItems: "end center"
	}
});
const TrayElement = tasty({ styles: {
	display: {
		"": "none",
		"entering | entered": "initial",
		exiting: "initial",
		exited: "none"
	},
	zIndex: 10,
	height: "max 90dvh",
	width: "$min-dialog-size 90vw",
	pointerEvents: "auto",
	transition: "transform .25s ease-in-out, opacity .25s linear, visibility 0ms linear",
	opacity: {
		"": 0,
		open: ".9999"
	}
} });
function Tray(props, ref) {
	let { qa, children, onClose, isFixedHeight, isNonModal, styles, ...otherProps } = props;
	let domRef = useDOMRef(ref);
	let { overlayProps, underlayProps } = useOverlay({
		...props,
		isDismissable: true
	}, domRef);
	return /* @__PURE__ */ jsxs(_Overlay, {
		...otherProps,
		children: [/* @__PURE__ */ jsx(_Underlay, { ...underlayProps }), /* @__PURE__ */ jsx(TrayWrapper, {
			ref: domRef,
			qa,
			overlayProps,
			isFixedHeight,
			isNonModal,
			styles,
			onClose,
			children
		})]
	});
}
let TrayWrapper = forwardRef(function TrayWrapper(props, ref) {
	let { qa, children, isOpen, styles, isFixedHeight, isNonModal, overlayProps, transitionState, ...otherProps } = props;
	usePreventScroll();
	let { modalProps } = useModal({ isDisabled: isNonModal });
	let domProps = mergeProps$1(otherProps, overlayProps);
	return /* @__PURE__ */ jsx(TrayWrapperElement, {
		mods: { open: isOpen },
		children: /* @__PURE__ */ jsx(TrayElement, {
			qa: qa || "Tray",
			styles,
			mods: {
				open: isOpen,
				entering: transitionState === "entering",
				exiting: transitionState === "exiting",
				exited: transitionState === "exited",
				entered: transitionState === "entered",
				"fixed-height": isFixedHeight
			},
			...domProps,
			...modalProps,
			ref,
			children
		})
	});
});
let _Tray = forwardRef(Tray);
_Tray.displayName = "Tray";

//#endregion
export { _Tray };
//# sourceMappingURL=Tray.js.map