import { useBlockElementCache } from "./useBlockElementCache.js";
import { useSortedEntities, useEntityList } from "@contember/binding";
import { useBlockElementPathRefs } from "./useBlockElementPathRefs.js";
import { useBlockEditorOnChange } from "./useBlockEditorOnChange.js";
import { useRef } from "react";
import { useBlockEditorSlateNodes } from "../useBlockEditorSlateNodes.js";
import { useRefreshBlocks } from "./useRefreshBlocks.js";
const useBlockEditorState = ({ editor, blockList, sortableBy, contentField, monolithicReferencesMode, referencesField }) => {
  const { entities: sortedBlocks } = useSortedEntities(useEntityList(blockList), sortableBy);
  const sortedBlocksRef = useRef(sortedBlocks);
  sortedBlocksRef.current = sortedBlocks;
  const blockElementCache = useBlockElementCache({ editor, blockList, sortableBy, contentField });
  const blockElementPathRefs = useBlockElementPathRefs({ editor, blockList });
  const refreshBlocks = useRefreshBlocks({ editor, sortableBy, contentField, blockList, blockElementCache, blockElementPathRefs, referencesField, monolithicReferencesMode, sortedBlocksRef });
  const onChange = useBlockEditorOnChange({ editor, blockList, contentField, blockElementCache, sortedBlocksRef, refreshBlocks });
  const nodes = useBlockEditorSlateNodes({ editor, blockElementCache, blockElementPathRefs, blockContentField: contentField, topLevelBlocks: sortedBlocks });
  return { onChange, nodes, sortedBlocksRef, refreshBlocks };
};
export { useBlockEditorState };
//# sourceMappingURL=useBlockEditorState.js.map
