license import { MDCRipplePoint } from './types' ; /**
 * Stores result from supportsCssVariables to avoid redundant processing to
 * detect CSS custom variable support.
 */ let supportsCssVariables_ ; export function supportsCssVariables ( windowObj , forceRefresh = false ) { const { CSS } = windowObj ; let supportsCssVars = supportsCssVariables_ ; if ( typeof supportsCssVariables_ === 'boolean' && ! forceRefresh ) { return supportsCssVariables_ ; } const supportsFunctionPresent = CSS && typeof CSS . supports === 'function' ; if ( ! supportsFunctionPresent ) { return false ; } const explicitlySupportsCssVars = CSS . supports ( '--css-vars' , 'yes' ) ; const weAreFeatureDetectingSafari10plus = ( CSS . supports ( '(--css-vars: yes)' ) && CSS . supports ( 'color' , '#00000000' ) ) ; supportsCssVars = explicitlySupportsCssVars || weAreFeatureDetectingSafari10plus ; if ( ! forceRefresh ) { supportsCssVariables_ = supportsCssVars ; } return supportsCssVars ; } export function getNormalizedEventCoords ( evt , pageOffset , clientRect ) { if ( ! evt ) { return { x : 0 , y : 0 } ; } const { x , y } = pageOffset ; const documentX = x + clientRect . left ; const documentY = y + clientRect . top ; let normalizedX ; let normalizedY ; if ( evt . type === 'touchstart' ) { const touchEvent = evt as TouchEvent ; normalizedX = touchEvent . changedTouches [ 0 ] . pageX - documentX ; normalizedY = touchEvent . changedTouches [ 0 ] . pageY - documentY ; } else { const mouseEvent = evt as MouseEvent ; normalizedX = mouseEvent . pageX - documentX ; normalizedY = mouseEvent . pageY - documentY ; } return { x : normalizedX , y : normalizedY } ; }