import { MutableRefObject } from 'react' ; export type BasicTarget < T = HTMLElement > = ( ( ) => T | null ) | T | null | MutableRefObject < T | null | undefined > ; type TargetElement = HTMLElement | Element | Document | Window ; export function getTargetElement ( target ? , defaultElement ? ) { if ( ! target ) { return defaultElement ; } let targetElement ; if ( typeof target === 'function' ) { targetElement = target ( ) ; } else if ( 'current' in target ) { targetElement = target . current ; } else { targetElement = target ; } return targetElement ; }