"use client";
const require_create_split_props = require("../../utils/create-split-props.cjs");
const require_tree_collection = require("../collection/tree-collection.cjs");
const require_tree_view_root = require("../tree-view/tree-view-root.cjs");
const require_get_branch_value = require("./get-branch-value.cjs");
const require_json_tree_view_props_context = require("./json-tree-view-props-context.cjs");
let react = require("react");
let react_jsx_runtime = require("react/jsx-runtime");
let _zag_js_json_tree_utils = require("@zag-js/json-tree-utils");
//#region src/components/json-tree-view/json-tree-view-root.tsx
var splitJsonTreeViewProps = require_create_split_props.createSplitProps();
var JsonTreeViewRoot = (0, react.forwardRef)((props, ref) => {
	const [jsonTreeProps, localProps] = splitJsonTreeViewProps(props, [
		"maxPreviewItems",
		"collapseStringsAfterLength",
		"quotesOnKeys",
		"groupArraysAfterLength",
		"showNonenumerable"
	]);
	const { data, defaultExpandedDepth, ...restProps } = localProps;
	const collection = (0, react.useMemo)(() => {
		return require_tree_collection.createTreeCollection({
			nodeToValue: _zag_js_json_tree_utils.nodeToValue,
			nodeToString: _zag_js_json_tree_utils.nodeToString,
			rootNode: (0, _zag_js_json_tree_utils.getRootNode)(data)
		});
	}, [data]);
	const defaultExpandedValue = (0, react.useMemo)(() => {
		return defaultExpandedDepth != null ? require_get_branch_value.getBranchValues(collection, defaultExpandedDepth) : void 0;
	}, [collection, defaultExpandedDepth]);
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_json_tree_view_props_context.JsonTreeViewPropsProvider, {
		value: jsonTreeProps,
		children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_tree_view_root.TreeViewRoot, {
			"data-scope": "json-tree-view",
			collection,
			defaultExpandedValue,
			...restProps,
			ref
		})
	});
});
JsonTreeViewRoot.displayName = "JsonTreeViewRoot";
//#endregion
exports.JsonTreeViewRoot = JsonTreeViewRoot;
