import { Observable , debounceTime , distinctUntilChanged , fromEvent , map , merge , startWith } from "rxjs" ; import { getActiveElement } from "../_" ; param el returns export function watchElementFocus ( el ) { return merge ( fromEvent ( document . body , "focusin" ) , fromEvent ( document . body , "focusout" ) ) . pipe ( debounceTime ( 1 ) , map ( ( ) => { const active = getActiveElement ( ) ; return typeof active !== "undefined" ? el . contains ( active ) : false ; } ) , startWith ( el === getActiveElement ( ) ) , distinctUntilChanged ( ) ) ; }