import { SendOptions } from 'data-transport' ; export const isParentFronts = ( ) => ! ! window . name && /^fronts/ . test ( window . name ) ; const postMessageToFrames = ( message , targetOrigin ) => { Array . from ( document . getElementsByTagName ( 'iframe' ) ) . forEach ( ( frame ) => { const isFronts = ! ! frame . getAttribute ( 'data-fronts' ) ; if ( isFronts ) { frame . contentWindow ! . postMessage ( message , targetOrigin ) ; } } ) ; } ; export const broadcastMessage = ( message , targetOrigin ) => { if ( ! message ?. __DATA_TRANSPORT_UUID__ ) return ; if ( ! message . downward ) { if ( isParentFronts ( ) ) { window . parent . postMessage ( message , targetOrigin ) ; } else { message . downward = true ; postMessageToFrames ( message , targetOrigin ) ; } } else { postMessageToFrames ( message , targetOrigin ) ; } } ;