import 'core-js/es6/reflect' ; import 'core-js/es7/reflect' ; import 'zone.js/dist/zone' ; import 'zone.js/dist/zone-patch-electron' ; ( < any > Symbol ) . asyncIterator = Symbol . asyncIterator || Symbol . for ( 'Symbol.asyncIterator' ) ; /**
 * Focus visible polyfill.
 * Source from: https://github.com/WICG/focus-visible
 */ let elementToBePointerFocused = null ; let forceNoFocusVisible = false ; let hadFocusVisibleRecently = false ; let hadFocusVisibleRecentlyTimeout = null ; const inputTypesWhiteList = { text : true , search : true , url : true , tel : true , email : true , password : true , number : true , date : true , month : true , week : true , time : true , datetime : true , 'datetime-local' : true , } ; const focusTriggersKeyboardModality = ( el ) : boolean => { const type = ( < HTMLInputElement > el ) . type ; const tagName = el . tagName ; if ( tagName === 'INPUT' && inputTypesWhiteList [ type ] && ! ( < HTMLInputElement > el ) . readOnly ) { return true ; } if ( tagName === 'TEXTAREA' && ! ( < HTMLTextAreaElement > el ) . readOnly ) { return true ; } if ( el . contentEditable == 'true' ) { return true ; } return false ; } ; const addFocusVisibleClass = ( el ) : void => { if ( el . classList . contains ( 'focus-visible' ) ) { return ; } el . classList . add ( 'focus-visible' ) ; el . setAttribute ( 'data-focus-visible-added' , '' ) ; } ; const removeFocusVisibleClass = ( el ) : void => { if ( ! el . classList . contains ( 'focus-visible' ) ) { return ; } el . classList . remove ( 'focus-visible' ) ; el . removeAttribute ( 'data-focus-visible-added' ) ; } ; const onKeyDown = ( ) : void => { forceNoFocusVisible = false ; } ; const onPointerDown = ( event ) : void => { forceNoFocusVisible = false ; elementToBePointerFocused = event . target ; if ( elementToBePointerFocused . nodeName == 'OPTION' ) { elementToBePointerFocused = elementToBePointerFocused . parentElement ; } } ; const onFocus = ( event ) : void => { if ( event . target === document || ( < any > event . target ) . nodeName === 'HTML' ) { return ; } if ( forceNoFocusVisible ) { return ; } if ( ! elementToBePointerFocused ) { addFocusVisibleClass ( event . target as HTMLElement ) ; return ; } if ( elementToBePointerFocused ) { if ( focusTriggersKeyboardModality ( event . target as HTMLElement ) || elementToBePointerFocused !== event . target ) { addFocusVisibleClass ( event . target as HTMLElement ) ; } elementToBePointerFocused = null ; } } ; const onBlur = ( event ) : void => { if ( event . target === document || ( < any > event . target ) . nodeName === 'HTML' ) { return ; } if ( ( < HTMLElement > event . target ) . classList . contains ( 'focus-visible' ) ) { hadFocusVisibleRecently = true ; window . clearTimeout ( hadFocusVisibleRecentlyTimeout ) ; hadFocusVisibleRecentlyTimeout = window . setTimeout ( ( ) => { hadFocusVisibleRecently = false ; window . clearTimeout ( hadFocusVisibleRecentlyTimeout ) ; } , 100 ) ; removeFocusVisibleClass ( event . target as HTMLElement ) ; } } ; const onVisibilityChange = ( ) : void => { if ( document . visibilityState == 'hidden' ) { if ( ! hadFocusVisibleRecently ) { forceNoFocusVisible = true ; return ; } } } ; document . addEventListener ( 'DOMContentLoaded' , ( ) => { document . addEventListener ( 'keydown' , onKeyDown , true ) ; document . addEventListener ( 'mousedown' , onPointerDown , true ) ; document . addEventListener ( 'touchstart' , onPointerDown , true ) ; document . addEventListener ( 'pointerdown' , onPointerDown , true ) ; document . addEventListener ( 'focus' , onFocus , true ) ; document . addEventListener ( 'blur' , onBlur , true ) ; document . addEventListener ( 'visibilitychange' , onVisibilityChange , true ) ; } ) ;