"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importDefault(require("react"));
const react_dom_1 = __importDefault(require("react-dom"));
class ReactVersionAdapter extends react_1.default.Component {
    refHold = null;
    async init(hydrate = false) {
        const { children, ...rest } = this.props;
        const renderMethod = hydrate ? react_dom_1.default.hydrate : react_dom_1.default.render;
        try {
            // eslint-disable-next-line @typescript-eslint/ban-ts-comment
            // @ts-ignore wrong react component definition
            renderMethod(react_1.default.createElement('div', rest, children), this.refHold);
        }
        catch (error) {
            this.props.onError?.(error instanceof Error ? error : new Error(String(error)));
        }
    }
    componentDidUpdate() {
        this.init(true);
    }
    componentDidMount() {
        this.init();
    }
    componentWillUnmount() {
        react_dom_1.default.unmountComponentAtNode(this.refHold);
    }
    render() {
        return react_1.default.createElement("div", { ref: (ref) => (this.refHold = ref) });
    }
}
exports.default = ReactVersionAdapter;
//# sourceMappingURL=ReactVersionAdapter.js.map