import { useRef, useState } from 'react';
/**
 * @example const ref = useConsolidatedRefs(refs);
 * @param refs The ref or refs to consolidate.
 * @returns ref:: The consolidated ref.
 */
const useConsolidatedRef = (...refs) => {
    const targetRef = useRef(null);
    const [refProxy] = useState(() => Object.defineProperty({ current: null }, 'current', {
        configurable: true,
        enumerable: true,
        get: () => targetRef.current,
        set: value => {
            targetRef.current = value;
            refs.forEach(ref => {
                if (!ref)
                    return;
                if (typeof ref === 'function') {
                    ref(targetRef.current);
                }
                else {
                    ref.current = targetRef.current;
                }
            });
        }
    }));
    return refProxy;
};
export default useConsolidatedRef;
//# sourceMappingURL=useConsolidatedRef.js.map