function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

import React, { useMemo } from 'react';
import { theme } from '../theme';
import { useComponentThemePropsResolution } from '../hooks/useThemeProps';
import { makeStyledComponent } from '../utils/makeStyledComponent';
export default function Factory(Component, componentTheme) {
  return /*#__PURE__*/React.forwardRef(({ ...props
  }, ref) => {
    const StyledComponent = useMemo(() => makeStyledComponent(Component), []);
    const calculatedProps = useComponentThemePropsResolution(componentTheme !== null && componentTheme !== void 0 ? componentTheme : {}, props, theme);
    return /*#__PURE__*/React.createElement(StyledComponent, _extends({}, calculatedProps, {
      ref: ref
    }));
  }); // return React.forwardRef(
  //   ({ children, ...props }: P & FactoryComponentProps, ref: any) => {
  //     const StyledComponent = useMemo(() => makeStyledComponent(Component), []);
  //     const calculatedProps = usePropsResolutionWithComponentTheme(
  //       componentTheme ?? {},
  //       props,
  //       theme
  //     );
  //     return (
  //       <StyledComponent {...(calculatedProps as any)} ref={ref}>
  //         {children}
  //       </StyledComponent>
  //     );
  //   }
  // );
}
//# sourceMappingURL=component.js.map