import classNames from "classnames";
import React, { forwardRef, useContext } from "react";
import ReactDOM from "react-dom";
import { StylesContext } from "./../../ricos-styles/index.js";
import { isSSR } from "./../../wix-rich-content-common/index.js";
const RicosPortalInner = forwardRef((props, ref) => {
  const { portalCssVars, stylePreset } = useContext(StylesContext);
  return /* @__PURE__ */ React.createElement(
    "div",
    {
      dir: props?.languageDir,
      ref,
      "data-hook": "ricos-portal",
      className: classNames(props?.className, stylePreset),
      style: {
        ...portalCssVars,
        ...props.environment === "wixel" ? { pointerEvents: "auto" } : {}
      }
    },
    props?.children
  );
});
const RicosPortal = forwardRef((props, ref) => {
  if (!isSSR()) {
    const container = props?.container ?? document?.body;
    return ReactDOM.createPortal(/* @__PURE__ */ React.createElement(RicosPortalInner, { ...props, ref }), container);
  }
  return /* @__PURE__ */ React.createElement(RicosPortalInner, { ...props, ref });
});
export {
  RicosPortal
};
//# sourceMappingURL=ricos-portal.js.map
