"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const Slate = require("slate");
const react = require("react");
const reactBinding = require("@contember/react-binding");
const useBlockElementPathRefs = ({ editor, blockList }) => {
  const [blockElementPathRefs] = react.useState(() => /* @__PURE__ */ new Map());
  const desugaredBlockList = reactBinding.useDesugaredRelativeEntityList(blockList);
  reactBinding.useEntityPersistSuccess(
    react.useCallback(
      (getEntity) => {
        for (const ref of blockElementPathRefs.values()) {
          ref.unref();
        }
        blockElementPathRefs.clear();
        const blocks = getEntity().getRelativeEntityList(desugaredBlockList);
        let blockIndex = 0;
        for (const topLevelBlock of blocks) {
          blockElementPathRefs.set(topLevelBlock.id, Slate.Editor.pathRef(editor, [blockIndex++], { affinity: "backward" }));
        }
      },
      [blockElementPathRefs, desugaredBlockList, editor]
    )
  );
  return blockElementPathRefs;
};
exports.useBlockElementPathRefs = useBlockElementPathRefs;
//# sourceMappingURL=useBlockElementPathRefs.cjs.map
