"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const styles_1 = require("@material-ui/core/styles");
const react_1 = tslib_1.__importDefault(require("react"));
const core_1 = require("@bluebase/core");
const { createElement, forwardRef } = react_1.default;
// Docs: https://github.com/mui-org/material-ui/issues/7633#issuecomment-418211698
exports.withPropsStyles = (style) => {
    const withPropsStylesInternal = (component) => {
        return forwardRef((props, ref) => (react_1.default.createElement(core_1.ThemeConsumer, null, ({ theme: bluebaseTheme }) => {
            const proxy = (theme) => style(props, theme, bluebaseTheme);
            const hoc = styles_1.withStyles(proxy)(component);
            return createElement(hoc, Object.assign(Object.assign({}, props), { ref, bluebaseTheme }), props.children);
        })));
    };
    return withPropsStylesInternal;
};
