"use client";
const require_use_props = require("../../../core/MantineProvider/use-props/use-props.cjs");
const require_factory = require("../../../core/factory/factory.cjs");
let react = require("react");
let _mantine_hooks = require("@mantine/hooks");
let react_jsx_runtime = require("react/jsx-runtime");
//#region packages/@mantine/core/src/components/Chip/ChipGroup/ChipGroup.tsx
const ChipGroup = require_factory.genericFactory((props) => {
	const { value, defaultValue, onChange, multiple, children } = require_use_props.useProps("ChipGroup", null, props);
	const [_value, setValue] = (0, _mantine_hooks.useUncontrolled)({
		value,
		defaultValue,
		finalValue: multiple ? [] : null,
		onChange
	});
	const isChipSelected = (val) => Array.isArray(_value) ? _value.includes(val) : val === _value;
	const handleChange = (event) => {
		const val = event.currentTarget.value;
		if (Array.isArray(_value)) setValue(_value.includes(val) ? _value.filter((v) => v !== val) : [..._value, val]);
		else setValue(val);
	};
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChipGroupContext, {
		value: {
			isChipSelected,
			onChange: handleChange,
			multiple
		},
		children
	});
});
ChipGroup.displayName = "@mantine/core/ChipGroup";
const ChipGroupContext = (0, react.createContext)(null);
//#endregion
exports.ChipGroup = ChipGroup;
exports.ChipGroupContext = ChipGroupContext;

//# sourceMappingURL=ChipGroup.cjs.map