"use client";
//#region packages/@mantine/core/src/components/TreeSelect/flatten-tree-select-data.ts
function flattenTo(acc, data, expandedState, parent, level, parentGuides) {
	for (let i = 0; i < data.length; i++) {
		const node = data[i];
		const isLast = i === data.length - 1;
		const hasLoadedChildren = Array.isArray(node.children);
		const hasAsyncChildren = !!node.hasChildren && !hasLoadedChildren;
		const hasChildren = hasLoadedChildren || hasAsyncChildren;
		const expanded = expandedState[node.value] || false;
		acc.push({
			node,
			level,
			parent,
			hasChildren,
			expanded,
			isLastChild: isLast,
			lineGuides: parentGuides
		});
		if (expanded && hasLoadedChildren) {
			const childGuides = level >= 2 ? [...parentGuides, !isLast] : [];
			flattenTo(acc, node.children, expandedState, node.value, level + 1, childGuides);
		}
	}
}
function flattenTreeSelectData(data, expandedState) {
	const result = [];
	flattenTo(result, data, expandedState, null, 1, []);
	return result;
}
//#endregion
exports.flattenTreeSelectData = flattenTreeSelectData;

//# sourceMappingURL=flatten-tree-select-data.cjs.map