import { Fragment, useMemo, createElement } from "react";
import { useHTMLProps } from "../html/use-props.js";
import { useSVGProps } from "../svg/use-props.js";
import { filterProps } from "./utils/filter-props.js";
import { isSVGComponent } from "./utils/is-svg-component.js";
import { isMotionValue } from "../../../../../motion-dom/dist/es/value/utils/is-motion-value.js";
function createUseRender(forwardMotionProps = false) {
  const useRender = (Component, props, ref, { latestValues }, isStatic) => {
    const useVisualProps = isSVGComponent(Component) ? useSVGProps : useHTMLProps;
    const visualProps = useVisualProps(props, latestValues, isStatic, Component);
    const filteredProps = filterProps(props, typeof Component === "string", forwardMotionProps);
    const elementProps = Component !== Fragment ? { ...filteredProps, ...visualProps, ref } : {};
    const { children } = props;
    const renderedChildren = useMemo(() => isMotionValue(children) ? children.get() : children, [children]);
    return createElement(Component, {
      ...elementProps,
      children: renderedChildren
    });
  };
  return useRender;
}
export {
  createUseRender
};
//# sourceMappingURL=use-render.js.map
