import { useShellStore } from "../stores/shellStore.mjs";
import { UdpPagesLazy } from "../udp/pages/UdpPagesLazy/index.mjs";
import { c } from "react-compiler-runtime";
import { useEffect } from "react";
//#region src/shell/useWidgetRegistry.js
/**
* Resolves the widget registry from either the new `widgets` prop or the
* deprecated `getWidget`/`isValidWidget` props and syncs it to the shell store.
*/
function useWidgetRegistry(t0) {
	const $ = c(14);
	const { widgets, getWidget, isValidWidget } = t0;
	const { setGetWidget, setIsValidWidget } = useShellStore();
	let t1;
	bb0: {
		if (!widgets) {
			t1 = null;
			break bb0;
		}
		let t2;
		if ($[0] !== widgets) {
			t2 = {
				...UdpPagesLazy,
				...widgets
			};
			$[0] = widgets;
			$[1] = t2;
		} else t2 = $[1];
		t1 = t2;
	}
	const mergedWidgetMap = t1;
	let t2;
	bb1: {
		if (mergedWidgetMap) {
			let t3;
			if ($[2] !== mergedWidgetMap) {
				t3 = (widgetType) => mergedWidgetMap[widgetType] ?? null;
				$[2] = mergedWidgetMap;
				$[3] = t3;
			} else t3 = $[3];
			t2 = t3;
			break bb1;
		}
		t2 = getWidget;
	}
	const resolvedGetWidget = t2;
	let t3;
	bb2: {
		if (mergedWidgetMap) {
			let t4;
			if ($[4] !== mergedWidgetMap) {
				t4 = (widgetType_0) => Object.prototype.hasOwnProperty.call(mergedWidgetMap, widgetType_0);
				$[4] = mergedWidgetMap;
				$[5] = t4;
			} else t4 = $[5];
			t3 = t4;
			break bb2;
		}
		t3 = isValidWidget;
	}
	const resolvedIsValidWidget = t3;
	let t4;
	let t5;
	if ($[6] !== resolvedGetWidget || $[7] !== setGetWidget) {
		t4 = () => {
			setGetWidget(resolvedGetWidget);
			return () => setGetWidget(null);
		};
		t5 = [resolvedGetWidget, setGetWidget];
		$[6] = resolvedGetWidget;
		$[7] = setGetWidget;
		$[8] = t4;
		$[9] = t5;
	} else {
		t4 = $[8];
		t5 = $[9];
	}
	useEffect(t4, t5);
	let t6;
	let t7;
	if ($[10] !== resolvedIsValidWidget || $[11] !== setIsValidWidget) {
		t6 = () => {
			setIsValidWidget(resolvedIsValidWidget);
			return () => setIsValidWidget(null);
		};
		t7 = [resolvedIsValidWidget, setIsValidWidget];
		$[10] = resolvedIsValidWidget;
		$[11] = setIsValidWidget;
		$[12] = t6;
		$[13] = t7;
	} else {
		t6 = $[12];
		t7 = $[13];
	}
	useEffect(t6, t7);
}
//#endregion
export { useWidgetRegistry };

//# sourceMappingURL=useWidgetRegistry.mjs.map