"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.withTheme = void 0;
const tslib_1 = require("tslib");
const core_1 = require("@bluebase/core");
const core_2 = require("@material-ui/core");
const styles_1 = require("@material-ui/core/styles");
const CssBaseline_1 = tslib_1.__importDefault(require("@material-ui/core/CssBaseline"));
const react_1 = tslib_1.__importDefault(require("react"));
core_2.MuiThemeProvider.displayName = 'MuiThemeProvider';
exports.withTheme = (Component) => {
    var _a;
    return _a = class ReactNativePaperProvider extends react_1.default.Component {
            render() {
                const { theme } = this.context;
                // Strip color from typography.
                const typography = {};
                Object.keys(theme.typography).map((key) => {
                    const _a = theme.typography[key], { color } = _a, values = tslib_1.__rest(_a, ["color"]);
                    typography[key] = values;
                });
                return (react_1.default.createElement(core_1.IntlConsumer, null, ({ rtl }) => {
                    const rnpTheme = styles_1.createTheme({
                        direction: rtl ? 'rtl' : 'ltr',
                        palette: Object.assign(Object.assign({}, theme.palette), { action: theme.palette.action, background: Object.assign(Object.assign({}, theme.palette.background), { paper: theme.palette.background.card }), type: theme.mode }),
                        shape: theme.shape,
                        spacing: theme.spacing.unit,
                        typography,
                    });
                    return (react_1.default.createElement(core_2.MuiThemeProvider, { theme: rnpTheme },
                        react_1.default.createElement(CssBaseline_1.default, null),
                        react_1.default.createElement(Component, Object.assign({}, this.props))));
                }));
            }
        },
        _a.contextType = core_1.ThemeContext,
        _a;
};
