import merge from 'lodash.merge';
import { isEmptyObj } from '../../utils/isEmptyObj';
import { getStyleAndFilteredProps } from '../../theme/styled-system';
export const resolvePropsToStyle = (styledSystemProps, theme, platform, debug, currentBreakpoint, strictMode, getResponsiveStyles, INTERNAL_themeStyle, stateProps) => {
  let flattenInternalThemeProps = INTERNAL_themeStyle;
  let fontSize;

  if (Array.isArray(flattenInternalThemeProps)) {
    var _flattenInternalTheme;

    flattenInternalThemeProps = flattenInternalThemeProps.flat();
    fontSize = (_flattenInternalTheme = flattenInternalThemeProps[0]) === null || _flattenInternalTheme === void 0 ? void 0 : _flattenInternalTheme.fontSize;
  } else {
    var _flattenInternalTheme2;

    fontSize = (_flattenInternalTheme2 = flattenInternalThemeProps) === null || _flattenInternalTheme2 === void 0 ? void 0 : _flattenInternalTheme2.fontSize;
  }

  const modifiedStyledSytemProps = {
    fontSize,
    ...styledSystemProps
  };
  const {
    unResolvedProps,
    styleFromProps,
    restDefaultProps,
    dataSet
  } = getStyleAndFilteredProps({
    styledSystemProps: modifiedStyledSytemProps,
    theme,
    debug,
    currentBreakpoint,
    strictMode,
    getResponsiveStyles,
    platform
  });
  const {
    unResolvedProps: stateUnResolvedProps,
    styleFromProps: inlineStyleFromProps,
    restDefaultProps: stateRestDefaultProps,
    dataSet: stateDataSet
  } = getStyleAndFilteredProps({
    styledSystemProps: stateProps,
    theme,
    debug,
    currentBreakpoint,
    strictMode,
    getResponsiveStyles,
    platform
  });
  const mergedStyle = merge.apply({}, [merge.apply({}, INTERNAL_themeStyle), styleFromProps, merge.apply({}, stateProps === null || stateProps === void 0 ? void 0 : stateProps.INTERNAL_themeStyle), inlineStyleFromProps]);
  return {
    style: mergedStyle,
    styleFromProps,
    unResolvedProps: merge(unResolvedProps, stateUnResolvedProps),
    restDefaultProps: merge(restDefaultProps, stateRestDefaultProps),
    dataSet: !isEmptyObj(stateDataSet) ? stateDataSet : dataSet
  };
};
//# sourceMappingURL=resolvePropsToStyle.js.map