import { useRef } from 'react';
import { useRerender } from '../useRerender/index.js';
const proto = Map.prototype;
export function useMap(entries) {
    const mapRef = useRef();
    const rerender = useRerender();
    if (!mapRef.current) {
        const map = new Map(entries);
        mapRef.current = map;
        map.set = (...args) => {
            proto.set.apply(map, args);
            rerender();
            return map;
        };
        map.clear = (...args) => {
            proto.clear.apply(map, args);
            rerender();
        };
        map.delete = (...args) => {
            const res = proto.delete.apply(map, args);
            rerender();
            return res;
        };
    }
    return mapRef.current;
}
