/**
 * Copyright IBM Corp. 2020, 2026
 *
 * This source code is licensed under the Apache-2.0 license found in the
 * LICENSE file in the root directory of this source tree.
 */

const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_index = require("../../../node_modules/classnames/index.js");
const require_context = require("./context.js");
let react = require("react");
react = require_runtime.__toESM(react);
let prop_types = require("prop-types");
prop_types = require_runtime.__toESM(prop_types);
let _carbon_react = require("@carbon/react");
//#region src/components/AddSelect/next/AddSelectColumn.tsx
/**
* Copyright IBM Corp. 2026
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
var import_classnames = /* @__PURE__ */ require_runtime.__toESM(require_index.default);
const AddSelectColumn = (0, react.forwardRef)(({ children, title = "", searchLabel = "Search", searchPlaceholder = "Search", onSearch, actionsSlot, hideSearch = false, multi = false, showSelectAll = false, itemCount = 0, allSelected = false, allIndeterminate = false, onSelectAll, onNavigate, className, searchProps, tagProps, selectAllCheckboxProps, ...rest }, ref) => {
	const parentContext = react.default.useContext(require_context.AddSelectContext);
	const [searchTerm, setSearchTerm] = (0, react.useState)("");
	const handleSearch = (e) => {
		const value = e.target.value;
		setSearchTerm(value);
		onSearch?.(value);
	};
	const handleSelectAll = (_event, { checked }) => {
		onSelectAll?.(checked);
	};
	const columnClasses = (0, import_classnames.default)(`${require_context.blockClass}-column`, className);
	const columnContext = {
		...parentContext,
		multi,
		onNavigate
	};
	return /* @__PURE__ */ react.default.createElement(require_context.AddSelectContext.Provider, { value: columnContext }, /* @__PURE__ */ react.default.createElement("div", {
		className: columnClasses,
		ref,
		...rest
	}, (!hideSearch || actionsSlot) && /* @__PURE__ */ react.default.createElement("div", { className: (0, import_classnames.default)(`${require_context.blockClass}-column__search`, { [`${require_context.blockClass}-column__search--with-actions`]: actionsSlot }) }, !hideSearch && /* @__PURE__ */ react.default.createElement("div", { className: actionsSlot ? `${require_context.blockClass}-column__search-input` : "" }, /* @__PURE__ */ react.default.createElement(_carbon_react.Search, {
		labelText: searchLabel,
		placeholder: searchPlaceholder,
		size: "md",
		onChange: handleSearch,
		value: searchTerm,
		...searchProps
	})), actionsSlot && /* @__PURE__ */ react.default.createElement("div", { className: `${require_context.blockClass}-column__actions` }, actionsSlot)), (showSelectAll || title) && /* @__PURE__ */ react.default.createElement("div", { className: `${require_context.blockClass}-column__header` }, showSelectAll && multi ? /* @__PURE__ */ react.default.createElement(_carbon_react.Checkbox, {
		id: `select-all-${title}`,
		className: `${require_context.blockClass}-column__select-all`,
		checked: allSelected,
		indeterminate: allIndeterminate,
		onChange: handleSelectAll,
		labelText: /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("span", { className: `${require_context.blockClass}-column__title` }, title), itemCount > 0 && /* @__PURE__ */ react.default.createElement(_carbon_react.Tag, {
			type: "gray",
			size: "sm",
			...tagProps
		}, itemCount)),
		...selectAllCheckboxProps
	}) : /* @__PURE__ */ react.default.createElement("div", { className: `${require_context.blockClass}-column__title-wrapper` }, /* @__PURE__ */ react.default.createElement("span", { className: `${require_context.blockClass}-column__title` }, title), itemCount > 0 && /* @__PURE__ */ react.default.createElement(_carbon_react.Tag, {
		type: "gray",
		size: "sm",
		...tagProps
	}, itemCount))), /* @__PURE__ */ react.default.createElement("div", { className: `${require_context.blockClass}-column__rows` }, children)));
});
AddSelectColumn.propTypes = {
	actionsSlot: prop_types.default.node,
	allIndeterminate: prop_types.default.bool,
	allSelected: prop_types.default.bool,
	children: prop_types.default.node,
	className: prop_types.default.string,
	hideSearch: prop_types.default.bool,
	itemCount: prop_types.default.number,
	multi: prop_types.default.bool,
	/**@ts-ignore */
	onNavigate: prop_types.default.func,
	/**@ts-ignore */
	onSearch: prop_types.default.func,
	/**@ts-ignore */
	onSelectAll: prop_types.default.func,
	searchLabel: prop_types.default.string,
	searchPlaceholder: prop_types.default.string,
	/**@ts-ignore */
	searchProps: prop_types.default.object,
	/**@ts-ignore */
	selectAllCheckboxProps: prop_types.default.object,
	showSelectAll: prop_types.default.bool,
	/**@ts-ignore */
	tagProps: prop_types.default.object,
	title: prop_types.default.string
};
AddSelectColumn.displayName = "AddSelectColumn";
//#endregion
exports.default = AddSelectColumn;
