import { Theme } from '@fluentui/react' ; private export const isDarkThemed = ( theme ) : boolean => { const themeBlackBrightness = getPerceptualBrightnessOfHexColor ( theme . palette . black ) ; const themeWhiteBrightness = getPerceptualBrightnessOfHexColor ( theme . palette . white ) ; if ( Number . isNaN ( themeBlackBrightness ) || Number . isNaN ( themeWhiteBrightness ) ) { return false ; } return themeBlackBrightness > themeWhiteBrightness ; } ; const getPerceptualBrightnessOfHexColor = ( hexColor ) : number => { if ( ! /^#[0-9A-Fa-f]{6}$/i . test ( hexColor ) ) { return NaN ; } const r = parseInt ( hexColor . substring ( 1 , 3 ) , 16 ) ; const g = parseInt ( hexColor . substring ( 3 , 5 ) , 16 ) ; const b = parseInt ( hexColor . substring ( 5 , 7 ) , 16 ) ; return ( r + g + b ) / 3 ; } ;