import React, { useMemo } from "react";
import PropTypes from "prop-types";
import { ThemeProvider, StylesProvider } from "@material-ui/styles";
import { createTheme } from "@material-ui/core/styles";
import themeConfig from "./themeConfig";
import GlobalStyles from "./GlobalStyles";
import StyleComponentsProvider from "./StyleComponentsProvider";

var Provider = function Provider(_ref) {
  var children = _ref.children,
      _theme = _ref.theme,
      reset = _ref.reset;
  var theme = useMemo(function () {
    return themeConfig(_theme);
  }, [_theme]);
  var themeBuilder = createTheme(theme);
  return /*#__PURE__*/React.createElement(StylesProvider, {
    injectFirst: true
  }, /*#__PURE__*/React.createElement(ThemeProvider, {
    theme: themeBuilder
  }, /*#__PURE__*/React.createElement(StyleComponentsProvider, {
    theme: theme.cleverUI
  }, /*#__PURE__*/React.createElement(GlobalStyles, {
    reset: reset
  }), children)));
};

Provider.propTypes = {
  theme: PropTypes.instanceOf(Object),
  reset: PropTypes.bool
};
Provider.defaultProps = {
  theme: {},
  reset: false
};
export default Provider;