"use client";
import { getRefProp } from "../../../core/utils/get-ref-prop/get-ref-prop.mjs";
import { getSingleElementChild } from "../../../core/utils/get-single-element-child/get-single-element-child.mjs";
import { useProps } from "../../../core/MantineProvider/use-props/use-props.mjs";
import { factory } from "../../../core/factory/factory.mjs";
import { useComboboxContext } from "../Combobox.context.mjs";
import { useComboboxTargetProps } from "../use-combobox-target-props/use-combobox-target-props.mjs";
import { cloneElement } from "react";
import { useMergedRef } from "@mantine/hooks";
//#region packages/@mantine/core/src/components/Combobox/ComboboxEventsTarget/ComboboxEventsTarget.tsx
const defaultProps = {
	refProp: "ref",
	targetType: "input",
	withKeyboardNavigation: true,
	withAriaAttributes: true,
	withExpandedAttribute: false,
	autoComplete: "off"
};
const ComboboxEventsTarget = factory((props) => {
	const { children, refProp, withKeyboardNavigation, withAriaAttributes, withExpandedAttribute, targetType, autoComplete, ref, ...others } = useProps("ComboboxEventsTarget", defaultProps, props);
	const child = getSingleElementChild(children);
	if (!child) throw new Error("Combobox.EventsTarget component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported");
	const ctx = useComboboxContext();
	return cloneElement(child, {
		...useComboboxTargetProps({
			targetType,
			withAriaAttributes,
			withKeyboardNavigation,
			withExpandedAttribute,
			onKeyDown: child.props.onKeyDown,
			onClick: child.props.onClick,
			autoComplete
		}),
		...others,
		[refProp]: useMergedRef(ref, ctx.store.targetRef, getRefProp(child))
	});
});
ComboboxEventsTarget.displayName = "@mantine/core/ComboboxEventsTarget";
//#endregion
export { ComboboxEventsTarget };

//# sourceMappingURL=ComboboxEventsTarget.mjs.map