function lazy(render) {
	// @ts-ignore-next
	return function (...args) {
		if (this._prom && this.state.ret === this._prom) {
			this._prom = null;
			return (this._ret = this.state.c);
		}
		const ret = render.call(this, ...args);
		if (ret && ret.then) {
			this._prom = ret;
			ret.then(c => this._prom === ret && this.setState({ ret, c }));
			if (this._ret) return this._ret;
			throw ret;
		}
		this._prom = null;
		this._ret = ret;
		return ret;
	};
}
@template {(...any) => any} T @type {(f: T) => (...args: Parameters<T>) => ReturnType<T> extends PromiseLike<infer U> ? U : T}