import type * as d from '../declarations' ; import { BUILD } from '@app-data' ; import { consoleDevWarn , plt } from '@platform' ; import { EVENT_FLAGS } from '@utils' ; import { getElement } from './element' ; export const createEvent = ( ref , name , flags ) => { const elm = getElement ( ref ) as HTMLElement ; return { emit : ( detail ) => { if ( BUILD . isDev && ! elm . isConnected ) { consoleDevWarn ( `The "${ name }" event was emitted, but the dispatcher node is no longer connected to the dom.` ) ; } return emitEvent ( elm , name , { bubbles : ! ! ( flags & EVENT_FLAGS . Bubbles ) , composed : ! ! ( flags & EVENT_FLAGS . Composed ) , cancelable : ! ! ( flags & EVENT_FLAGS . Cancellable ) , detail , } ) ; } , } ; } ; param elm param name param opts returns export const emitEvent = ( elm , name , opts ? ) => { const ev = plt . ce ( name , opts ) ; elm . dispatchEvent ( ev ) ; return ev ; } ;