import { Component as e, useEffect as t } from "react";
import { jsx as n } from "react/jsx-runtime";
import { disableThreeSceneForSession as r, threeSceneDefaultDisabledStorageKey as i, useThreeSceneAvailability as a } from "@ryuzaki13/react-foundation-lib/three-scene";
//#region src/three-scene/ThreeSceneErrorBoundary.tsx
var o = class extends e {
	state = { hasError: !1 };
	static getDerivedStateFromError() {
		return { hasError: !0 };
	}
	componentDidCatch(e, t) {
		this.props.onError?.(e, t);
	}
	render() {
		return this.state.hasError ? this.props.fallback : this.props.children;
	}
};
//#endregion
//#region src/three-scene/ThreeSceneGuard.tsx
function s({ children: e, fallback: s, disabledStorageKey: c = i, disableWhenReducedMotion: l, webGLVersion: u, onError: d, onAvailabilityChange: f }) {
	let p = a({
		disabledStorageKey: c,
		disableWhenReducedMotion: l,
		webGLVersion: u
	});
	return t(() => {
		f?.(p);
	}, [p, f]), p.status === "available" ? /* @__PURE__ */ n(o, {
		fallback: s,
		onError: (e, t) => {
			r(c), d?.(e, t);
		},
		children: e
	}) : s;
}
//#endregion
export { o as ThreeSceneErrorBoundary, s as ThreeSceneGuard };

//# sourceMappingURL=index.js.map