import * as _ from "react";
import { CompositeList as j } from "../list/CompositeList.js";
import { useCompositeRoot as z } from "./useCompositeRoot.js";
import { CompositeRootContext as B } from "./CompositeRootContext.js";
import { useRenderElement as D } from "../../utils/useRenderElement.js";
import { useDirection as F } from "../../direction-provider/DirectionContext.js";
import { jsx as d } from "react/jsx-runtime";
import { EMPTY_ARRAY as h, EMPTY_OBJECT as J } from "../../../../../../../@base-ui_utils@0.2.4_@types_react@18.3.27_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/empty.js";
function Q(o) {
  const {
    render: L,
    className: N,
    refs: m = h,
    props: a = h,
    state: p = J,
    stateAttributesMapping: g,
    highlightedIndex: l,
    onHighlightedIndexChange: f,
    orientation: c,
    dense: C,
    itemSizes: u,
    loopFocus: x,
    cols: I,
    enableHomeAndEndKeys: R,
    onMapChange: e,
    stopEventPropagation: E = !0,
    rootRef: v,
    disabledIndices: H,
    modifierKeys: M,
    highlightItemOnHover: t = !1,
    tag: P = "div",
    ...b
  } = o, y = F(), {
    props: A,
    highlightedIndex: n,
    onHighlightedIndexChange: i,
    elementsRef: K,
    onMapChange: T,
    relayKeyboardEvent: r
  } = z({
    itemSizes: u,
    cols: I,
    loopFocus: x,
    dense: C,
    orientation: c,
    highlightedIndex: l,
    onHighlightedIndexChange: f,
    rootRef: v,
    stopEventPropagation: E,
    enableHomeAndEndKeys: R,
    direction: y,
    disabledIndices: H,
    modifierKeys: M
  }), Y = D(P, o, {
    state: p,
    ref: m,
    props: [A, ...a, b],
    stateAttributesMapping: g
  }), O = _.useMemo(() => ({
    highlightedIndex: n,
    onHighlightedIndexChange: i,
    highlightItemOnHover: t,
    relayKeyboardEvent: r
  }), [n, i, t, r]);
  return /* @__PURE__ */ d(B.Provider, {
    value: O,
    children: /* @__PURE__ */ d(j, {
      elementsRef: K,
      onMapChange: (s) => {
        e == null || e(s), T(s);
      },
      children: Y
    })
  });
}
export {
  Q as CompositeRoot
};
