"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const useBlockElementCache = require("./useBlockElementCache.cjs");
const reactBinding = require("@contember/react-binding");
const useBlockElementPathRefs = require("./useBlockElementPathRefs.cjs");
const useBlockEditorOnChange = require("./useBlockEditorOnChange.cjs");
const react = require("react");
const useBlockEditorSlateNodes = require("../useBlockEditorSlateNodes.cjs");
const useRefreshBlocks = require("./useRefreshBlocks.cjs");
const useBlockEditorState = ({ editor, blockList, sortableBy, contentField, monolithicReferencesMode, referencesField }) => {
  const { entities: sortedBlocks } = reactBinding.useSortedEntities(reactBinding.useEntityList(blockList), sortableBy);
  const sortedBlocksRef = react.useRef(sortedBlocks);
  sortedBlocksRef.current = sortedBlocks;
  const blockElementCache = useBlockElementCache.useBlockElementCache({ editor, blockList, sortableBy, contentField });
  const blockElementPathRefs = useBlockElementPathRefs.useBlockElementPathRefs({ editor, blockList });
  const refreshBlocks = useRefreshBlocks.useRefreshBlocks({ editor, sortableBy, contentField, blockList, blockElementCache, blockElementPathRefs, referencesField, monolithicReferencesMode, sortedBlocksRef });
  const onChange = useBlockEditorOnChange.useBlockEditorOnChange({ editor, blockList, contentField, blockElementCache, sortedBlocksRef, refreshBlocks });
  const nodes = useBlockEditorSlateNodes.useBlockEditorSlateNodes({ editor, blockElementCache, blockElementPathRefs, blockContentField: contentField, topLevelBlocks: sortedBlocks });
  return { onChange, nodes, sortedBlocksRef, refreshBlocks };
};
exports.useBlockEditorState = useBlockEditorState;
//# sourceMappingURL=useBlockEditorState.cjs.map
