import * as React from 'react' ; const widthRatio = 640 / ( 35 * 1.3 ) ; const heightRatio = 583 / ( 578 * 1.3 ) ; export const useSvgResize = ( containerHeight , containerWidth ) : { svgOffset : number ; svgHeight : number | undefined ; svgWidth : number | undefined ; } => { const [ svgHeight , setSvgHeight ] = React . useState < number > ( 0 ) ; const [ svgWidth , setSvgWidth ] = React . useState < number > ( 0 ) ; React . useEffect ( ( ) => { if ( typeof containerHeight === 'number' && ! Number . isNaN ( containerHeight ) ) { setSvgHeight ( containerHeight / heightRatio ) ; } } , [ containerHeight ] ) ; React . useEffect ( ( ) => { if ( typeof containerWidth === 'number' && ! Number . isNaN ( containerWidth ) ) { setSvgWidth ( containerWidth / widthRatio ) ; } } , [ containerWidth ] ) ; const svgOffset = containerHeight ? ( - 1 * Math . abs ( svgHeight - containerHeight ) ) / 2 : 0 ; return { svgOffset , svgHeight , svgWidth } ; } ;