import { isCallable } from '../../common/utils';
import { Reblend } from '../../internal/Reblend';
//@ReblendComponent
function TryCatchError({ children = ((_error) => <>{''}</>), }) {
    //@ts-ignore
    this &&
        //@ts-ignore
        (this.renderingErrorHandler = (e) => {
            //@ts-ignore
            this.renderingError = e;
            //if (!this.stateEffectRunning && this.attached) {
            //Promise.resolve().then(() => {
            //@ts-ignore
            this?.onStateChange();
            //})
            //}
        });
    function view() {
        const arr = [];
        for (const child of children) {
            if (isCallable(child)) {
                //@ts-ignore
                arr.push(child(this.renderingError));
            }
            else {
                arr.push(child);
            }
        }
        //@ts-ignore
        this.renderingError = null;
        return arr;
    }
    return <div>{view()}</div>;
}
export { TryCatchError };
