import { _objectSpread2 } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import { _objectWithoutProperties } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js";
import { useChildComponentPropsContext } from "../provider/ChildComponentProps.js";
import { useHandleActionProvider } from "../provider/HandleActions.js";
import { useRefManagerProvider } from "../provider/RefManager.js";
import { useCallback, useMemo } from "react";
//#region src/components/pisellDataSourceContainer/hooks/useContainerContext.ts
const _excluded = ["form"];
const useContainerContext = (displayName) => {
	const handleActionsValue = useHandleActionProvider();
	const refManager = useRefManagerProvider();
	const childComponentProps = useChildComponentPropsContext();
	const onValuesChange = useCallback((changedValues, _allValues) => {
		try {
			handleActionsValue.list.onSearch(changedValues);
		} catch (error) {
			console.error("[useContainerContext] onValuesChange 执行失败:", error);
		}
	}, [handleActionsValue.list]);
	return useMemo(() => {
		const { form } = childComponentProps, childProps = _objectWithoutProperties(childComponentProps, _excluded);
		let contextValue = {
			serverActions: handleActionsValue,
			refManager,
			form,
			onValuesChange
		};
		if (displayName && childProps) {
			const specificProps = childProps[displayName];
			if (specificProps !== void 0) contextValue = _objectSpread2(_objectSpread2({}, contextValue), specificProps);
		}
		return contextValue;
	}, [
		displayName,
		onValuesChange,
		handleActionsValue,
		refManager,
		childComponentProps
	]);
};
//#endregion
export { useContainerContext as default };
