export { useThemeProps } from './useProps';
export { usePropsResolution } from './usePropsResolution';
import { mergeFinalResolvedProps, usePropsResolutionWithComponentTheme } from './usePropsResolution';
import merge from 'lodash.merge';
import { getStyledObject } from '../../utils/getStyledComponentAndObjects';
import { Platform } from 'react-native';
import { omitUndefined } from '../../theme/tools';
import { useColorMode } from '../../core';
import { useNativeBaseConfig } from '../../core/NativeBaseContext';

const useResolvedFactoryProps = (styleObj, incomingProps, colorMode, theme, componentTheme, incomingInternalThemeProps, incomingStateProps) => {
  const providerId = useNativeBaseConfig('NativeBase').providerId;
  const resolvedPropsWithStateProps = usePropsResolutionWithComponentTheme(componentTheme, incomingProps, theme, {});
  resolvedPropsWithStateProps.stateProps = merge({}, resolvedPropsWithStateProps === null || resolvedPropsWithStateProps === void 0 ? void 0 : resolvedPropsWithStateProps.stateProps, incomingStateProps);
  styleObj.styleFromProps = merge({}, styleObj.styleFromProps, incomingInternalThemeProps);
  const stateStyleFromProps = omitUndefined(styleObj === null || styleObj === void 0 ? void 0 : styleObj.stateStyleFromProps);
  const resolvedProps = mergeFinalResolvedProps(componentTheme, styleObj, incomingProps, '', stateStyleFromProps, resolvedPropsWithStateProps, {
    component: '',
    theme,
    providerId,
    colorMode,
    ignoredProps: {},
    stateProps: {},
    notResolveThemeProps: false
  });
  return resolvedProps;
};

const getModiefiedIncomingProps = incomingProps => {
  const incomingInternalThemeProps = merge.apply({}, incomingProps === null || incomingProps === void 0 ? void 0 : incomingProps.INTERNAL_themeStyle);
  const incomingStateProps = incomingProps === null || incomingProps === void 0 ? void 0 : incomingProps.stateProps;
  const modifiedIncomingProps = incomingProps;
  modifiedIncomingProps === null || modifiedIncomingProps === void 0 ? true : delete modifiedIncomingProps.INTERNAL_themeStyle;
  modifiedIncomingProps === null || modifiedIncomingProps === void 0 ? true : delete modifiedIncomingProps.stateProps;
  return {
    modifiedIncomingProps,
    incomingInternalThemeProps,
    incomingStateProps
  };
};

export const useComponentThemePropsResolution = (componentTheme, incomingProps, theme) => {
  const {
    colorMode
  } = useColorMode();
  const {
    modifiedIncomingProps,
    incomingInternalThemeProps,
    incomingStateProps
  } = getModiefiedIncomingProps(incomingProps);
  const styleObj = getStyledObject(theme, '', componentTheme, {
    platform: Platform.OS,
    colorMode: colorMode
  }, merge({}, modifiedIncomingProps), true);
  const resolvedProps = useResolvedFactoryProps(styleObj, merge({}, styleObj === null || styleObj === void 0 ? void 0 : styleObj.unResolvedProps, styleObj === null || styleObj === void 0 ? void 0 : styleObj.restDefaultProps, modifiedIncomingProps), colorMode, theme, componentTheme, incomingInternalThemeProps, incomingStateProps);
  return resolvedProps;
};
//# sourceMappingURL=index.js.map