import { ExportNs } from './export-ns' ; const { userAgent , vendor , platform } = window . navigator ; export const isTrident = /trident/i . test ( userAgent ) ; export const isIE = isTrident ; export const isEdgeHTML = /edg([ea]|ios)/i . test ( userAgent ) ; export const isBlinkEdge = /\sedg\//i . test ( userAgent ) ; export const isEdge = isEdgeHTML || isBlinkEdge ; export const isGecko = /gecko/i . test ( userAgent ) && ! /like gecko/i . test ( userAgent ) ; export const isFirefox = /firefox|iceweasel|fxios/i . test ( userAgent ) ; export const isOpera = /(?:^opera.+?version|opr)/ . test ( userAgent ) ; export const isChrome = ! isOpera && /google inc/ . test ( vendor ) ; export const isWebkit = /(apple)?webkit/i . test ( userAgent ) ; export const isSafari = isWebkit && /^((?!chrome|android).)*safari/i . test ( userAgent ) ; export const isBlink = isWebkit && ! isSafari ; export const isBot = /Chrome-Lighthouse|Google Page Speed Insights/i . test ( userAgent ) ; export const isAndroid = /Android/i . test ( userAgent ) ; export const isMobileIOS13 = ( platform === 'MacIntel' && window . navigator . maxTouchPoints > 1 ) ; export const isMobileIOS = /iPad|iPhone|iPod/ . test ( platform ) || isMobileIOS13 ; export const isLegacyMobile = /webOS|BlackBerry|IEMobile|Opera Mini/i . test ( navigator . userAgent ) ; export const isMobile = isMobileIOS || isAndroid || isLegacyMobile ; export const isMobileSafari = isMobileIOS && isWebkit && /CriOS/i . test ( userAgent ) ; export const isTouchDevice = ( ( ) : boolean => { const navApi = window . navigator ; if ( navApi . maxTouchPoints || navApi . msMaxTouchPoints ) return true ; return ( 'ontouchstart' in window ) || ( 'DocumentTouch' in window && document instanceof Touch ) ; } ) ( ) ; export const hasHover = ! matchMedia ( '(hover: none)' ) . matches ; type TouchEventsDefinition = { START : string ; MOVE : string ; END : string ; } ; deprecated export const TOUCH_EVENTS = ( ( ) : TouchEventsDefinition => { const isTouch = isTouchDevice ; return { START : isTouch ? 'touchstart' : 'pointerdown' , MOVE : isTouch ? 'touchmove' : 'pointermove' , END : isTouch ? 'touchend' : 'pointerup' } ; } ) ( ) ; readonly @ ExportNs ( 'DeviceDetector' ) export abstract class DeviceDetector { public static readonly isTrident = isTrident ; public static readonly isIE = isIE ; public static readonly isEdgeHTML = isEdgeHTML ; public static readonly isBlinkEdge = isBlinkEdge ; public static readonly isEdge = isEdge ; public static readonly isGecko = isGecko ; public static readonly isFirefox = isFirefox ; public static readonly isOpera = isOpera ; public static readonly isChrome = isChrome ; public static readonly isWebkit = isWebkit ; public static readonly isSafari = isSafari ; public static readonly isBlink = isBlink ; public static readonly isBot = isBot ; public static readonly isAndroid = isAndroid ; public static readonly isMobileIOS13 = isMobileIOS13 ; public static readonly isMobileIOS = isMobileIOS ; public static readonly isLegacyMobile = isLegacyMobile ; public static readonly isMobile = isMobile ; public static readonly isMobileSafari = isMobileSafari ; public static isTouchDevice = isTouchDevice ; public static hasHover = hasHover ; deprecated static TOUCH_EVENTS = TOUCH_EVENTS ; } declare global { export interface ESLLibrary { DeviceDetector : typeof DeviceDetector ; } }