"use client";
'use strict';

var React = require('react');
var useProps$1 = require('../html/use-props.js');
var useProps = require('../svg/use-props.js');
var filterProps = require('./utils/filter-props.js');
var isSvgComponent = require('./utils/is-svg-component.js');
var isMotionValue = require('../../../../../../../motion-dom@12.38.0/node_modules/motion-dom/dist/es/value/utils/is-motion-value.js');

function useRender(Component, props, ref, { latestValues, }, isStatic, forwardMotionProps = false, isSVG) {
    const useVisualProps = (isSVG ?? isSvgComponent.isSVGComponent(Component)) ? useProps.useSVGProps : useProps$1.useHTMLProps;
    const visualProps = useVisualProps(props, latestValues, isStatic, Component);
    const filteredProps = filterProps.filterProps(props, typeof Component === "string", forwardMotionProps);
    const elementProps = Component !== React.Fragment ? { ...filteredProps, ...visualProps, ref } : {};
    /**
     * If component has been handed a motion value as its child,
     * memoise its initial value and render that. Subsequent updates
     * will be handled by the onChange handler
     */
    const { children } = props;
    const renderedChildren = React.useMemo(() => (isMotionValue.isMotionValue(children) ? children.get() : children), [children]);
    return React.createElement(Component, {
        ...elementProps,
        children: renderedChildren,
    });
}

exports.useRender = useRender;
