import { n as AnalyticsId } from "./constants2.js";
import React from "react";
import { createPortal } from "react-dom";
function Portal({ children, parent, className, testId }) {
	const el = React.useMemo(() => document.createElement("div"), []);
	el.setAttribute("data-analyticsid", AnalyticsId.Portal);
	if (testId) el.setAttribute("data-testid", testId);
	React.useEffect(() => {
		const target = parent && !!parent.appendChild ? parent : document.body;
		const classList = ["portal-container"];
		if (className) className.split(" ").forEach((item) => classList.push(item));
		classList.forEach((item) => el.classList.add(item));
		target.appendChild(el);
		return () => {
			target.removeChild(el);
		};
	}, [
		el,
		parent,
		className
	]);
	return createPortal(children, el);
}
export { Portal as t };

//# sourceMappingURL=Portal.js.map