import { Decorator } from "./types" ; const withAutoHeight = ( amp ) : Decorator => ( pym ) => { let cachedHeightString ; pym . onMessage ( "height" , ( heightString ) => { if ( heightString === cachedHeightString ) { return ; } cachedHeightString = heightString ; const height = parseInt ( heightString , 10 ) ; pym . iframe . style . height = `${ height }px` ; if ( ! amp ) { return ; } window . parent . postMessage ( { sentinel : "amp" , type : "embed-size" , height : height > 100 ? height : 100 , } , "*" ) ; } ) ; } ; export default withAutoHeight ;