import { dynamic } from "@solidjs/web";
import { omit } from "solid-js";
import { composeRefs, userRef } from "../../internals/compose-refs.jsx";
import { mergeRootProps } from "../../internals/merge-root-props.jsx";
import { resolveClassStyle } from "../../internals/resolve-class-style.jsx";
import { useSelectRootContext } from "../select-root-context.jsx";

// biome-ignore lint/complexity/noBannedTypes: public empty-state for consumer type references.

const EMPTY_STATE = {};

/**
 * `<Select.List>` — an inner container for `<Select.Item>`s that takes the
 * `listbox` role.
 */
export function SelectList(props) {
  const root = useSelectRootContext();
  const setListRef = el => {
    root.setListElement(el);
  };
  const internal = {
    get id() {
      return `${root.id() ?? ""}-list`;
    },
    role: "listbox",
    get "aria-multiselectable"() {
      return root.multiple() ? "true" : undefined;
    },
    // The list is the scroll container when present; keep the popup's
    // scroll-arrow visibility in sync with it.
    onScroll(event) {
      root.scrollHandlerRef.current(event.currentTarget);
    }
  };
  const userClassStyle = resolveClassStyle(props, () => EMPTY_STATE);
  const userProps = omit(props, "as", "class", "style", "attrs");
  let merged = mergeRootProps(internal, userClassStyle);
  merged = mergeRootProps(merged, userProps);
  const Tag = dynamic(() => props.as ?? "div");
  return <Tag {...merged} ref={composeRefs(setListRef, userRef(props))} />;
}
//# sourceMappingURL=select-list.jsx.map
