import { EventEmitter } from '@stencil/core' ; export const hasShadowDom = ( el ) => { return ! ! el . shadowRoot && ! ! ( el as any ) . attachShadow ; } ; export const renderHiddenInput = ( always , container , name , value , disabled ) => { if ( always || hasShadowDom ( container ) ) { let input = container . querySelector ( 'input.aux-input' ) as HTMLInputElement | null ; if ( ! input ) { input = container . ownerDocument . createElement ( 'input' ) ; input . type = 'hidden' ; input . classList . add ( 'aux-input' ) ; container . appendChild ( input ) ; } input . disabled = disabled ; input . name = name ; input . value = value || '' ; } } ; export const debounce = ( func , wait = 0 ) => { let timer ; return ( ... args ) : any => { clearTimeout ( timer ) ; timer = setTimeout ( func , wait , ... args ) ; } ; } ; export const debounceEvent = ( event , wait ) : EventEmitter => { const original = ( event as any ) . _original || event ; return { _original : event , emit : debounce ( original . emit . bind ( original ) , wait ) } as EventEmitter ; } ; export const deferEvent = ( event ) : EventEmitter => { return debounceEvent ( event , 0 ) ; } ;