import Browserslist from "browserslist" ; import { feature as caniuseFeature , features as caniuseFeatures } from "caniuse-lite" ; import compatData from "@mdn/browser-compat-data" ; import { get } from "object-path" ; import { gt , gte , lt , lte } from "semver" ; import { getClosestMatchingBrowserVersion , getNextVersionOfBrowser , getOldestVersionOfBrowser , getPreviousVersionOfBrowser , getSortedBrowserVersionsWithLeadingVersion , normalizeBrowserVersion } from "./browser-version" ; import { UNKNOWN_CANIUSE_BROWSER } from "./constant" ; import { ensureSemver , coerceToString } from "./ensure-semver" ; import { compareVersions } from "./compare-versions" ; import { ComparisonOperator } from "./comparison-operator" ; import { EcmaVersion , ES2015_FEATURES , ES2016_FEATURES , ES2017_FEATURES , ES2018_FEATURES , ES2019_FEATURES , ES2020_FEATURES , ES2021_FEATURES , ES2022_FEATURES , ES5_FEATURES } from "./ecma-version" ; import { rangeCorrection } from "./range-correction" ; import { BrowserSupportForFeaturesCommonResult } from "./browser-support-for-features-common-result" ; import { CaniuseBrowser , CaniuseStats , CaniuseStatsNormalized , CaniuseSupportKind , CaniuseBrowserCorrection , CaniuseFeature , VersionedCaniuseBrowser } from "./i-caniuse" ; import { Mdn , MdnBrowserName } from "./mdn" ; import { NORMALIZE_BROWSER_VERSION_REGEXP } from "./normalize-browser-version-regexp" ; import { UaParserWrapper } from "./ua-parser-wrapper" ; import { UseragentBrowser , UseragentEngine , UseragentOs } from "./useragent/useragent-typed" ; /**
 * A Cache between user agent names and generated Browserslists
 */ const userAgentToBrowserslistCache = new Map ( ) ; type { Map < string , BrowserSupportForFeaturesCommonResult > } const browserSupportForFeaturesCache = new Map ( ) ; type { Map < string , CaniuseStatsNormalized > } const featureToCaniuseStatsCache = new Map ( ) ; type { Map < string , boolean > } const userAgentWithFeaturesToSupportCache = new Map ( ) ; type { Map < string , string [ ] > } const PARTIAL_SUPPORT_ALLOWANCES = new Map ( [ [ "shadowdomv1" , "*" ] , [ "custom-elementsv1" , "*" ] , [ "web-animation" , "*" ] ] ) as Map < string , CaniuseBrowser [ ] | "*" > ; type { Set < string > } const IGNORED_BROWSERS_INPUT = [ "and_chr" , "and_ff" , "and_uc" , "and_qq" , "baidu" , "op_mini" ] ; const IGNORED_BROWSERS = new Set ( IGNORED_BROWSERS_INPUT ) ; const TYPED_ARRAY_BASE_DATA_CORRECTIONS_INPUT = { android : rangeCorrection ( "android" , CaniuseSupportKind . AVAILABLE , `4` ) , chrome : rangeCorrection ( "and_chr" , CaniuseSupportKind . AVAILABLE , `7` ) , and_chr : rangeCorrection ( "and_chr" , CaniuseSupportKind . AVAILABLE , `7` ) , edge : rangeCorrection ( "edge" , CaniuseSupportKind . AVAILABLE , "12" ) , samsung : rangeCorrection ( "samsung" , CaniuseSupportKind . AVAILABLE , `4` ) , opera : rangeCorrection ( "opera" , CaniuseSupportKind . AVAILABLE , `12` ) , op_mob : rangeCorrection ( "op_mob" , CaniuseSupportKind . AVAILABLE , `12` ) , firefox : rangeCorrection ( "firefox" , CaniuseSupportKind . AVAILABLE , `4` ) , and_ff : rangeCorrection ( "and_ff" , CaniuseSupportKind . AVAILABLE , `4` ) , safari : rangeCorrection ( "safari" , CaniuseSupportKind . AVAILABLE , `6` ) , ios_saf : rangeCorrection ( "safari" , CaniuseSupportKind . AVAILABLE , `5` ) , ie : rangeCorrection ( "ie" , CaniuseSupportKind . AVAILABLE , `11` ) , op_mini : rangeCorrection ( "op_mini" , CaniuseSupportKind . AVAILABLE , `all` ) , bb : rangeCorrection ( "bb" , CaniuseSupportKind . AVAILABLE , `10` ) , and_uc : rangeCorrection ( "and_uc" , CaniuseSupportKind . AVAILABLE , `11.8` ) , and_qq : rangeCorrection ( "and_qq" , CaniuseSupportKind . AVAILABLE , `1.2` ) , baidu : rangeCorrection ( "baidu" , CaniuseSupportKind . AVAILABLE , `7.12` ) } ; const TYPED_ARRAY_ES2015_DATA_CORRECTIONS_INPUT = { android : rangeCorrection ( "android" , CaniuseSupportKind . AVAILABLE , `45` ) , chrome : rangeCorrection ( "and_chr" , CaniuseSupportKind . AVAILABLE , `45` ) , and_chr : rangeCorrection ( "and_chr" , CaniuseSupportKind . AVAILABLE , `45` ) , edge : rangeCorrection ( "edge" , CaniuseSupportKind . AVAILABLE , "12" ) , samsung : rangeCorrection ( "samsung" , CaniuseSupportKind . AVAILABLE , `5` ) , opera : rangeCorrection ( "opera" , CaniuseSupportKind . AVAILABLE , `32` ) , op_mob : rangeCorrection ( "op_mob" , CaniuseSupportKind . AVAILABLE , `32` ) , firefox : rangeCorrection ( "firefox" , CaniuseSupportKind . AVAILABLE , `38` ) , and_ff : rangeCorrection ( "and_ff" , CaniuseSupportKind . AVAILABLE , `38` ) , safari : rangeCorrection ( "safari" , CaniuseSupportKind . AVAILABLE , `10` ) , ios_saf : rangeCorrection ( "safari" , CaniuseSupportKind . AVAILABLE , `10` ) , ie : rangeCorrection ( "ie" , CaniuseSupportKind . AVAILABLE , `11` ) , ie_mob : rangeCorrection ( "ie" , CaniuseSupportKind . AVAILABLE , `11` ) } ; const TYPED_ARRAY_ES2016_DATA_CORRECTIONS_INPUT = { android : rangeCorrection ( "android" , CaniuseSupportKind . AVAILABLE , `47` ) , chrome : rangeCorrection ( "and_chr" , CaniuseSupportKind . AVAILABLE , `47` ) , and_chr : rangeCorrection ( "and_chr" , CaniuseSupportKind . AVAILABLE , `47` ) , edge : rangeCorrection ( "edge" , CaniuseSupportKind . AVAILABLE , "14" ) , samsung : rangeCorrection ( "samsung" , CaniuseSupportKind . AVAILABLE , `5` ) , opera : rangeCorrection ( "opera" , CaniuseSupportKind . AVAILABLE , `34` ) , op_mob : rangeCorrection ( "op_mob" , CaniuseSupportKind . AVAILABLE , `34` ) , firefox : rangeCorrection ( "firefox" , CaniuseSupportKind . AVAILABLE , `43` ) , and_ff : rangeCorrection ( "and_ff" , CaniuseSupportKind . AVAILABLE , `43` ) , safari : rangeCorrection ( "safari" , CaniuseSupportKind . AVAILABLE , `10` ) , ios_saf : rangeCorrection ( "safari" , CaniuseSupportKind . AVAILABLE , `10` ) } ; const TYPED_ARRAY_KEYS_VALUES_ENTRIES_ITERATOR_DATA_CORRECTIONS_INPUT = { android : rangeCorrection ( "android" , CaniuseSupportKind . AVAILABLE , `38` ) , chrome : rangeCorrection ( "and_chr" , CaniuseSupportKind . AVAILABLE , `38` ) , and_chr : rangeCorrection ( "and_chr" , CaniuseSupportKind . AVAILABLE , `38` ) , edge : rangeCorrection ( "edge" , CaniuseSupportKind . AVAILABLE , "12" ) , samsung : rangeCorrection ( "samsung" , CaniuseSupportKind . AVAILABLE , `5` ) , opera : rangeCorrection ( "opera" , CaniuseSupportKind . AVAILABLE , `26` ) , op_mob : rangeCorrection ( "op_mob" , CaniuseSupportKind . AVAILABLE , `26` ) , firefox : rangeCorrection ( "firefox" , CaniuseSupportKind . AVAILABLE , `37` ) , and_ff : rangeCorrection ( "and_ff" , CaniuseSupportKind . AVAILABLE , `37` ) , safari : rangeCorrection ( "safari" , CaniuseSupportKind . AVAILABLE , `10` ) , ios_saf : rangeCorrection ( "safari" , CaniuseSupportKind . AVAILABLE , `10` ) } ; const TYPED_ARRAY_SPECIES_DATA_CORRECTIONS_INPUT = { android : rangeCorrection ( "android" , CaniuseSupportKind . AVAILABLE , `51` ) , chrome : rangeCorrection ( "and_chr" , CaniuseSupportKind . AVAILABLE , `51` ) , and_chr : rangeCorrection ( "and_chr" , CaniuseSupportKind . AVAILABLE , `51` ) , edge : rangeCorrection ( "edge" , CaniuseSupportKind . AVAILABLE , "13" ) , samsung : rangeCorrection ( "samsung" , CaniuseSupportKind . AVAILABLE , `5` ) , opera : rangeCorrection ( "opera" , CaniuseSupportKind . AVAILABLE , `38` ) , op_mob : rangeCorrection ( "op_mob" , CaniuseSupportKind . AVAILABLE , `38` ) , firefox : rangeCorrection ( "firefox" , CaniuseSupportKind . AVAILABLE , `48` ) , and_ff : rangeCorrection ( "and_ff" , CaniuseSupportKind . AVAILABLE , `48` ) , safari : rangeCorrection ( "safari" , CaniuseSupportKind . AVAILABLE , `10` ) , ios_saf : rangeCorrection ( "safari" , CaniuseSupportKind . AVAILABLE , `10` ) } ; type { [ string , CaniuseBrowserCorrection ] [ ] } const FEATURE_TO_BROWSER_DATA_CORRECTIONS_INPUT = [ [ "xhr2" , { ie : [ { kind : CaniuseSupportKind . AVAILABLE , version : "11" } ] } ] , [ "web-animation" , { safari : rangeCorrection ( "safari" , CaniuseSupportKind . UNAVAILABLE , `0` , "13.4" ) , ios_saf : rangeCorrection ( "ios_saf" , CaniuseSupportKind . UNAVAILABLE , `0` , "13.4" ) } ] , [ "es6-class" , { edge : [ { kind : CaniuseSupportKind . PREFIXED , version : "12" } ] , ios_saf : [ { kind : CaniuseSupportKind . PARTIAL_SUPPORT , version : "9" } , { kind : CaniuseSupportKind . PARTIAL_SUPPORT , version : "9.2" } , { kind : CaniuseSupportKind . PARTIAL_SUPPORT , version : "9.3" } ] , safari : [ { kind : CaniuseSupportKind . PARTIAL_SUPPORT , version : "9" } , { kind : CaniuseSupportKind . PARTIAL_SUPPORT , version : "9.1" } ] } ] , [ "api.Element.classList" , { edge : [ { kind : CaniuseSupportKind . AVAILABLE , version : "15" } ] , ie : [ { kind : CaniuseSupportKind . AVAILABLE , version : "10" } , { kind : CaniuseSupportKind . AVAILABLE , version : "11" } ] } ] , [ "javascript.builtins.TypedArray.from" , TYPED_ARRAY_ES2015_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.of" , TYPED_ARRAY_ES2015_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.subarray" , TYPED_ARRAY_BASE_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.copyWithin" , TYPED_ARRAY_ES2015_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.every" , TYPED_ARRAY_ES2015_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.fill" , TYPED_ARRAY_ES2015_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.filter" , TYPED_ARRAY_ES2015_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.find" , TYPED_ARRAY_ES2015_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.findIndex" , TYPED_ARRAY_ES2015_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.forEach" , TYPED_ARRAY_ES2015_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.indexOf" , TYPED_ARRAY_ES2015_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.join" , TYPED_ARRAY_ES2015_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.lastIndexOf" , TYPED_ARRAY_ES2015_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.map" , TYPED_ARRAY_ES2015_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.reduce" , TYPED_ARRAY_ES2015_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.reduceRight" , TYPED_ARRAY_ES2015_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.reverse" , TYPED_ARRAY_ES2015_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.some" , TYPED_ARRAY_ES2015_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.sort" , TYPED_ARRAY_ES2015_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.toLocaleString" , TYPED_ARRAY_ES2015_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.toString" , TYPED_ARRAY_ES2015_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.slice" , TYPED_ARRAY_ES2015_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.includes" , TYPED_ARRAY_ES2016_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.keys" , TYPED_ARRAY_KEYS_VALUES_ENTRIES_ITERATOR_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.values" , TYPED_ARRAY_KEYS_VALUES_ENTRIES_ITERATOR_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.entries" , TYPED_ARRAY_KEYS_VALUES_ENTRIES_ITERATOR_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.@@iterator" , TYPED_ARRAY_KEYS_VALUES_ENTRIES_ITERATOR_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray.@@species" , TYPED_ARRAY_SPECIES_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.TypedArray" , TYPED_ARRAY_BASE_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.Int8Array" , TYPED_ARRAY_BASE_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.Int16Array" , TYPED_ARRAY_BASE_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.Int32Array" , TYPED_ARRAY_BASE_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.Float32Array" , TYPED_ARRAY_BASE_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.Float64Array" , TYPED_ARRAY_BASE_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.Uint8Array" , TYPED_ARRAY_BASE_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.Uint8ClampedArray" , TYPED_ARRAY_BASE_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.Uint16ClampedArray" , TYPED_ARRAY_BASE_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.Uint32ClampedArray" , TYPED_ARRAY_BASE_DATA_CORRECTIONS_INPUT ] , [ "javascript.builtins.String.@@iterator" , { android : rangeCorrection ( "chrome" , CaniuseSupportKind . AVAILABLE , `38` ) , chrome : rangeCorrection ( "chrome" , CaniuseSupportKind . AVAILABLE , `38` ) , and_chr : rangeCorrection ( "and_chr" , CaniuseSupportKind . AVAILABLE , `38` ) , edge : rangeCorrection ( "edge" , CaniuseSupportKind . AVAILABLE , `12` ) , opera : rangeCorrection ( "opera" , CaniuseSupportKind . AVAILABLE , `25` ) , op_mob : rangeCorrection ( "op_mob" , CaniuseSupportKind . AVAILABLE , `25` ) , firefox : rangeCorrection ( "firefox" , CaniuseSupportKind . AVAILABLE , `36` ) , and_ff : rangeCorrection ( "and_ff" , CaniuseSupportKind . AVAILABLE , `36` ) , safari : rangeCorrection ( "safari" , CaniuseSupportKind . AVAILABLE , `9` ) , ios_saf : rangeCorrection ( "ios_saf" , CaniuseSupportKind . AVAILABLE , `9` ) , samsung : rangeCorrection ( "samsung" , CaniuseSupportKind . AVAILABLE , `3` ) } ] , [ "javascript.builtins.Symbol.asyncIterator" , { android : rangeCorrection ( "android" , CaniuseSupportKind . AVAILABLE , `63` ) , chrome : rangeCorrection ( "chrome" , CaniuseSupportKind . AVAILABLE , `63` ) , and_chr : rangeCorrection ( "and_chr" , CaniuseSupportKind . AVAILABLE , `63` ) , opera : rangeCorrection ( "opera" , CaniuseSupportKind . AVAILABLE , `50` ) , op_mob : rangeCorrection ( "op_mob" , CaniuseSupportKind . AVAILABLE , `50` ) , firefox : rangeCorrection ( "firefox" , CaniuseSupportKind . AVAILABLE , `57` ) , and_ff : rangeCorrection ( "and_ff" , CaniuseSupportKind . AVAILABLE , `57` ) , safari : rangeCorrection ( "safari" , CaniuseSupportKind . AVAILABLE , `11.1` ) , ios_saf : rangeCorrection ( "ios_saf" , CaniuseSupportKind . AVAILABLE , `11.1` ) } ] , [ "javascript.builtins.Array.@@species" , { android : rangeCorrection ( "android" , CaniuseSupportKind . AVAILABLE , `51` ) , chrome : rangeCorrection ( "chrome" , CaniuseSupportKind . AVAILABLE , `51` ) , and_chr : rangeCorrection ( "and_chr" , CaniuseSupportKind . AVAILABLE , `51` ) , edge : rangeCorrection ( "edge" , CaniuseSupportKind . AVAILABLE , `14` ) , firefox : rangeCorrection ( "firefox" , CaniuseSupportKind . AVAILABLE , `41` ) , and_ff : rangeCorrection ( "and_ff" , CaniuseSupportKind . AVAILABLE , `41` ) , opera : rangeCorrection ( "opera" , CaniuseSupportKind . AVAILABLE , `38` ) , op_mob : rangeCorrection ( "op_mob" , CaniuseSupportKind . AVAILABLE , `38` ) , safari : rangeCorrection ( "safari" , CaniuseSupportKind . AVAILABLE , `10` ) , ios_saf : rangeCorrection ( "ios_saf" , CaniuseSupportKind . AVAILABLE , `10` ) } ] , [ "javascript.builtins.Date.@@toPrimitive" , { android : rangeCorrection ( "android" , CaniuseSupportKind . AVAILABLE , `48` ) , chrome : rangeCorrection ( "chrome" , CaniuseSupportKind . AVAILABLE , `48` ) , and_chr : rangeCorrection ( "and_chr" , CaniuseSupportKind . AVAILABLE , `48` ) , edge : rangeCorrection ( "edge" , CaniuseSupportKind . AVAILABLE ) , firefox : rangeCorrection ( "firefox" , CaniuseSupportKind . AVAILABLE , `44` ) , and_ff : rangeCorrection ( "and_ff" , CaniuseSupportKind . AVAILABLE , `44` ) , opera : rangeCorrection ( "opera" , CaniuseSupportKind . AVAILABLE , `35` ) , op_mob : rangeCorrection ( "op_mob" , CaniuseSupportKind . AVAILABLE , `35` ) , safari : rangeCorrection ( "safari" , CaniuseSupportKind . AVAILABLE , `10` ) , ios_saf : rangeCorrection ( "ios_saf" , CaniuseSupportKind . AVAILABLE , `10` ) , samsung : rangeCorrection ( "samsung" , CaniuseSupportKind . AVAILABLE ) } ] , [ "fetch" , { edge : [ { kind : CaniuseSupportKind . UNAVAILABLE , version : "14" } ] } ] , [ "api.Window" , { chrome : rangeCorrection ( "chrome" , CaniuseSupportKind . UNAVAILABLE , `0` , `18` ) , safari : rangeCorrection ( "safari" , CaniuseSupportKind . UNAVAILABLE , `0` , `5.1` ) , ie : rangeCorrection ( "ie" , CaniuseSupportKind . UNAVAILABLE , `0` , `7` ) , opera : rangeCorrection ( "safari" , CaniuseSupportKind . UNAVAILABLE , `0` , `11.1` ) } ] , [ "javascript.builtins.String.matchAll" , { samsung : rangeCorrection ( "samsung" , CaniuseSupportKind . UNAVAILABLE , `0` , `9.4` ) } ] , [ "resizeobserver" , { safari : rangeCorrection ( "safari" , CaniuseSupportKind . UNAVAILABLE , `0` ) } ] ] ; type { Map < string , CaniuseBrowserCorrection > } const FEATURE_TO_BROWSER_DATA_CORRECTIONS_MAP = new Map ( FEATURE_TO_BROWSER_DATA_CORRECTIONS_INPUT ) ; /**
 * Returns the input query, but extended with the given options
 */ function extendQueryWith ( query , extendWith ) { const normalizedExtendWith = Array . isArray ( extendWith ) ? extendWith : [ extendWith ] ; return [ ... new Set ( [ ... query , ... normalizedExtendWith ] ) ] ; } /**
 * Normalizes the given Browserslist
 */ export function normalizeBrowserslist ( browserslist ) { return Browserslist ( browserslist ) ; } param query param browsers returns function extendQueryWithUnreleasedVersions ( query , browsers ) { return extendQueryWith ( query , Array . from ( browsers ) . map ( browser => `unreleased ${ browser } versions` ) ) ; } param features returns export function browsersWithSupportForFeatures ( ... features ) { const { query , browsers } = browserSupportForFeaturesCommon ( ">=" , ... features ) ; return extendQueryWithUnreleasedVersions ( query , browsers ) ; } param browserslist param version export function browserslistSupportsEcmaVersion ( browserslist , version ) { switch ( version ) { case "es3" : return true ; case "es5" : return browserslistSupportsFeatures ( browserslist , ... ES5_FEATURES ) ; case "es2015" : return browserslistSupportsFeatures ( browserslist , ... ES2015_FEATURES ) ; case "es2016" : return browserslistSupportsFeatures ( browserslist , ... ES2016_FEATURES ) ; case "es2017" : return browserslistSupportsFeatures ( browserslist , ... ES2017_FEATURES ) ; case "es2018" : return browserslistSupportsFeatures ( browserslist , ... ES2018_FEATURES ) ; case "es2019" : return browserslistSupportsFeatures ( browserslist , ... ES2019_FEATURES ) ; case "es2020" : return browserslistSupportsFeatures ( browserslist , ... ES2020_FEATURES ) ; case "es2021" : return browserslistSupportsFeatures ( browserslist , ... ES2021_FEATURES ) ; case "es2022" : return browserslistSupportsFeatures ( browserslist , ... ES2022_FEATURES ) ; } } /**
 * Returns the appropriate Ecma version for the given Browserslist
 */ export function getAppropriateEcmaVersionForBrowserslist ( browserslist ) { if ( browserslistSupportsEcmaVersion ( browserslist , "es2022" ) ) return "es2022" ; if ( browserslistSupportsEcmaVersion ( browserslist , "es2021" ) ) return "es2021" ; if ( browserslistSupportsEcmaVersion ( browserslist , "es2020" ) ) return "es2020" ; if ( browserslistSupportsEcmaVersion ( browserslist , "es2019" ) ) return "es2019" ; if ( browserslistSupportsEcmaVersion ( browserslist , "es2018" ) ) return "es2018" ; else if ( browserslistSupportsEcmaVersion ( browserslist , "es2017" ) ) return "es2017" ; else if ( browserslistSupportsEcmaVersion ( browserslist , "es2016" ) ) return "es2016" ; else if ( browserslistSupportsEcmaVersion ( browserslist , "es2015" ) ) return "es2015" ; else if ( browserslistSupportsEcmaVersion ( browserslist , "es5" ) ) return "es5" ; else return "es3" ; } /**
 * Generates a Browserslist based on browser support for the given ECMA version
 */ export function browsersWithSupportForEcmaVersion ( version ) { switch ( version ) { case "es3" : return browsersWithoutSupportForFeatures ( ... ES5_FEATURES ) ; case "es5" : return browsersWithSupportForFeatures ( ... ES5_FEATURES ) ; case "es2015" : return browsersWithSupportForFeatures ( ... ES2015_FEATURES ) ; case "es2016" : return browsersWithSupportForFeatures ( ... ES2016_FEATURES ) ; case "es2017" : return browsersWithSupportForFeatures ( ... ES2017_FEATURES ) ; case "es2018" : return browsersWithSupportForFeatures ( ... ES2018_FEATURES ) ; case "es2019" : return browsersWithSupportForFeatures ( ... ES2019_FEATURES ) ; case "es2020" : return browsersWithSupportForFeatures ( ... ES2020_FEATURES ) ; case "es2021" : return browsersWithSupportForFeatures ( ... ES2021_FEATURES ) ; case "es2022" : return browsersWithSupportForFeatures ( ... ES2022_FEATURES ) ; } } param browserslist param features returns export function browserslistSupportsFeatures ( browserslist , ... features ) { const normalizedIdealBrowserslist = normalizeBrowserslist ( browsersWithSupportForFeatures ( ... features ) ) ; const normalizedInputBrowserslist = normalizeBrowserslist ( browserslist ) ; return normalizedInputBrowserslist . every ( option => normalizedIdealBrowserslist . includes ( option ) ) ; } param features returns export function browsersWithoutSupportForFeatures ( ... features ) { return browserSupportForFeaturesCommon ( "<" , ... features ) . query ; } param browser param version returns function shouldIgnoreBrowser ( browser , version ) { return ( ( browser === "android" && gt ( coerceToString ( browser , version ) , coerceToString ( browser , "4.4.4" ) ) ) || ( browser === "op_mob" && gt ( coerceToString ( browser , version ) , coerceToString ( browser , "12.1" ) ) ) || IGNORED_BROWSERS . has ( browser ) ) ; } param stats param featureName returns function getCaniuseLiteFeatureNormalized ( stats , featureName ) { const featureCorrectionMatch = FEATURE_TO_BROWSER_DATA_CORRECTIONS_MAP . get ( featureName ) ; const keys = Object . keys ( stats ) as ( keyof CaniuseStats & string ) [ ] ; keys . forEach ( browser => { const browserDict = stats [ browser ] ; Object . entries ( browserDict ) . forEach ( ( [ version , support ] ) => { const versionMatch = version . match ( NORMALIZE_BROWSER_VERSION_REGEXP ) ; const normalizedVersion = versionMatch == null ? version : versionMatch [ 1 ] ; let supportKind ; if ( support === CaniuseSupportKind . AVAILABLE || support === CaniuseSupportKind . UNAVAILABLE || support === CaniuseSupportKind . PARTIAL_SUPPORT || support === CaniuseSupportKind . PREFIXED ) { supportKind = support ; } else if ( support . startsWith ( "y" ) ) { supportKind = CaniuseSupportKind . AVAILABLE ; } else if ( support . startsWith ( "n" ) ) { supportKind = CaniuseSupportKind . UNAVAILABLE ; } else if ( support . startsWith ( "a" ) ) { supportKind = CaniuseSupportKind . PARTIAL_SUPPORT ; } else { supportKind = CaniuseSupportKind . PREFIXED ; } if ( version !== normalizedVersion ) { delete browserDict [ version ] ; } if ( support !== supportKind ) { browserDict [ normalizedVersion ] = supportKind ; } if ( featureCorrectionMatch != null ) { const browserMatch = featureCorrectionMatch [ browser ] ; if ( browserMatch != null ) { browserMatch . forEach ( correction => { browserDict [ correction . version ] = correction . kind ; } ) ; } } } ) ; } ) ; return stats as CaniuseStatsNormalized ; } param feature returns function getCaniuseFeatureSupport ( feature ) { const rawStats = ( caniuseFeature ( caniuseFeatures [ feature ] ) as CaniuseFeature ) . stats ; for ( const browser of Object . keys ( rawStats ) ) { const browserDict = rawStats [ browser as keyof CaniuseStatsNormalized ] ; for ( const version of Object . keys ( browserDict ) ) { if ( shouldIgnoreBrowser ( browser as keyof CaniuseStatsNormalized , version ) ) { delete browserDict [ version ] ; } } } return getCaniuseLiteFeatureNormalized ( rawStats , feature ) ; } param feature function isCaniuseFeature ( feature ) { return caniuseFeatures [ feature ] != null ; } param feature function isMdnFeature ( feature ) { return get ( compatData , feature ) != null ; } param feature function assertKnownFeature ( feature ) { if ( ! isCaniuseFeature ( feature ) && ! isMdnFeature ( feature ) ) { throw new TypeError ( `The given feature: '${ feature }' is unknown. It must be a valid Caniuse or MDN feature!` ) ; } } param feature returns function getFeatureSupport ( feature ) { const cacheHit = featureToCaniuseStatsCache . get ( feature ) ; if ( cacheHit != null ) return cacheHit ; assertKnownFeature ( feature ) ; const result = isMdnFeature ( feature ) ? getMdnFeatureSupport ( feature ) : getCaniuseFeatureSupport ( feature ) ; featureToCaniuseStatsCache . set ( feature , result ) ; return result ; } param feature returns function getMdnFeatureSupport ( feature ) { const match = get ( compatData , feature ) ; const supportMap = match . __compat . support ; const formatBrowser = ( mdnBrowser , caniuseBrowser ) : { [ key ] : CaniuseSupportKind ; } => { const versionMap = supportMap [ mdnBrowser ] ; const versionAdded = versionMap == null ? false : Array . isArray ( versionMap ) ? ( ( ) => { const versionStillInBrowser = versionMap . filter ( element => element . version_removed == null ) [ 0 ] ; return versionStillInBrowser == null || versionStillInBrowser . version_added == null ? false : ( versionStillInBrowser . version_added as string | boolean ) ; } ) ( ) : versionMap . version_added ; const dict = { } ; const supportedSince = versionAdded === false ? null : versionAdded === true ? getOldestVersionOfBrowser ( caniuseBrowser ) : versionAdded ; getSortedBrowserVersionsWithLeadingVersion ( caniuseBrowser , typeof versionAdded === "string" ? versionAdded : undefined ) . forEach ( version => { if ( supportedSince == null ) { dict [ version ] = CaniuseSupportKind . UNAVAILABLE ; } else { dict [ version ] = version === "TP" || version === "all" || gte ( coerceToString ( caniuseBrowser , version ) , coerceToString ( caniuseBrowser , supportedSince ) ) ? CaniuseSupportKind . AVAILABLE : CaniuseSupportKind . UNAVAILABLE ; } } ) ; return dict ; } ; const stats = { and_chr : formatBrowser ( "chrome_android" , "and_chr" ) , chrome : formatBrowser ( "chrome" , "chrome" ) , and_ff : formatBrowser ( "firefox_android" , "and_ff" ) , and_qq : { } , and_uc : { } , android : formatBrowser ( "webview_android" , "android" ) , baidu : { } , bb : { } , edge : formatBrowser ( "edge" , "edge" ) , samsung : formatBrowser ( "samsunginternet_android" , "samsung" ) , ie : formatBrowser ( "ie" , "ie" ) , ie_mob : formatBrowser ( "ie" , "ie_mob" ) , safari : formatBrowser ( "safari" , "safari" ) , ios_saf : formatBrowser ( "safari_ios" , "ios_saf" ) , opera : formatBrowser ( "opera" , "opera" ) , op_mini : { } , op_mob : { } , firefox : formatBrowser ( "firefox" , "firefox" ) } ; return getCaniuseLiteFeatureNormalized ( stats , feature ) ; } param kind param stats returns function getFirstVersionWithSupportKind ( kind , stats ) { const sortedKeys = Object . keys ( stats ) . sort ( compareVersions ) ; for ( const key of sortedKeys ) { if ( stats [ key ] === kind ) { return key ; } } return undefined ; } param a param b returns function sortBrowserslist ( a , b ) { if ( a . startsWith ( "not" ) && ! b . startsWith ( "not" ) ) return 1 ; if ( ! a . startsWith ( "not" ) && b . startsWith ( "not" ) ) return - 1 ; return 0 ; } param feature returns export function getFirstVersionsWithFullSupport ( feature ) { const support = getFeatureSupport ( feature ) ; const browserMap = new Map ( ) ; const entries = Object . entries ( support ) as [ CaniuseBrowser , Record < string , CaniuseSupportKind > ] [ ] ; entries . forEach ( ( [ browser , stats ] ) => { const fullSupportVersion = getFirstVersionWithSupportKind ( CaniuseSupportKind . AVAILABLE , stats ) ; if ( fullSupportVersion != null ) { browserMap . set ( browser , fullSupportVersion ) ; } } ) ; return browserMap ; } param comparisonOperator param features function getBrowserSupportForFeaturesCacheKey ( comparisonOperator , features ) { return `${ comparisonOperator }.${ features . sort ( ) . join ( "," ) }` ; } /**
 * Common logic for the functions that generate browserslists based on feature support
 */ function browserSupportForFeaturesCommon ( comparisonOperator , ... features ) { const cacheKey = getBrowserSupportForFeaturesCacheKey ( comparisonOperator , features ) ; const cacheHit = browserSupportForFeaturesCache . get ( cacheKey ) ; if ( cacheHit != null ) { return cacheHit ; } const browserMaps = [ ] ; for ( const feature of features ) { const support = getFeatureSupport ( feature ) ; const browserMap = new Map ( ) ; const entries = Object . entries ( support ) as [ CaniuseBrowser , Record < string , CaniuseSupportKind > ] [ ] ; entries . forEach ( ( [ browser , stats ] ) => { const fullSupportVersion = getFirstVersionWithSupportKind ( CaniuseSupportKind . AVAILABLE , stats ) ; const partialSupportVersion = getFirstVersionWithSupportKind ( CaniuseSupportKind . PARTIAL_SUPPORT , stats ) ; let versionToSet ; if ( fullSupportVersion != null ) { versionToSet = fullSupportVersion ; } if ( partialSupportVersion != null ) { const partialSupportMatch = PARTIAL_SUPPORT_ALLOWANCES . get ( feature ) ; if ( partialSupportMatch != null && ( partialSupportMatch === "*" || partialSupportMatch . includes ( browser ) ) && ( fullSupportVersion == null || compareVersions ( partialSupportVersion , fullSupportVersion ) < 0 ) ) { versionToSet = partialSupportVersion ; } } if ( versionToSet == null ) { switch ( comparisonOperator ) { case "<" : case "<=" : versionToSet = "-1" ; } } if ( versionToSet != null ) { browserMap . set ( browser , versionToSet ) ; } } ) ; browserMaps . push ( browserMap ) ; } for ( const browserMap of browserMaps ) { for ( const browser of browserMap . keys ( ) ) { if ( ! browserMaps . every ( map => map . has ( browser ) ) ) { browserMap . delete ( browser ) ; } } } const combinedBrowserMap = new Map ( ) ; for ( const browserMap of browserMaps ) { for ( const [ browser , version ] of browserMap . entries ( ) ) { const existingVersion = combinedBrowserMap . get ( browser ) ; const shouldSet = existingVersion !== "-1" && ( existingVersion == null || version === "-1" || compareVersions ( version , existingVersion ) >= 0 ) ; if ( shouldSet ) { combinedBrowserMap . set ( browser , version ) ; } } } const query = ( [ ] as string [ ] ) . concat . apply ( [ ] , Array . from ( combinedBrowserMap . entries ( ) ) . map ( ( [ browser , version ] ) => { if ( isNaN ( parseFloat ( version ) ) ) { switch ( comparisonOperator ) { case "<" : case "<=" : { const previousVersion = getPreviousVersionOfBrowser ( browser , version ) ; return [ `not ${ browser } ${ version }` , ... ( previousVersion == null ? [ ] : [ `${ browser } ${ comparisonOperator } ${ previousVersion }` ] ) ] ; } case ">" : case ">=" : { const nextVersion = getNextVersionOfBrowser ( browser , version ) ; return [ `${ browser } ${ version }` , ... ( nextVersion == null ? [ ] : [ `${ browser } ${ comparisonOperator } ${ nextVersion }` ] ) ] ; } } } return parseInt ( version ) === - 1 ? [ `${ comparisonOperator === ">" || comparisonOperator === ">=" ? "not " : "" }${ browser } ${ browser === "op_mini" ? "all" : "> 0" }` , `${ comparisonOperator === ">" || comparisonOperator === ">=" ? "not " : "" }unreleased ${ browser } versions` ] : [ `${ browser } ${ comparisonOperator } ${ version }` ] ; } ) ) . sort ( sortBrowserslist ) ; const returnObject = { query , browsers : new Set ( combinedBrowserMap . keys ( ) ) } ; browserSupportForFeaturesCache . set ( cacheKey , returnObject ) ; return returnObject ; } /**
 * Gets the matching CaniuseBrowser for the given UseragentBrowser. Not all are supported, so it may return undefined
 */ function getCaniuseBrowserForUseragentBrowser ( parser ) { const browser = parser . getBrowser ( ) ; const device = parser . getDevice ( ) ; const os = parser . getOS ( ) ; const engine = parser . getEngine ( ) ; if ( os . name === "iOS" ) { if ( browser . name === "Opera Mini" && engine . name === "Presto" ) { return { browser : "op_mini" , version : browser . version } ; } return { browser : "ios_saf" , version : os . version ?? browser . version } ; } if ( device . vendor === "BlackBerry" || os . name === "BlackBerry" ) { return { browser : "bb" , version : browser . version } ; } if ( browser . name === "HeyTapBrowser" && engine . name === "WebKit" ) { return { browser : "chrome" , version : "70" } ; } if ( browser . name === "PaleMoon" && engine . name === "Goanna" && browser . version != null ) { const semver = ensureSemver ( undefined , browser . version ) ; if ( lte ( semver , "5.0.0" ) ) { return { browser : "firefox" , version : "2" } ; } else if ( lte ( semver , "24.0.0" ) ) { return { browser : "firefox" , version : browser . version } ; } else if ( lt ( semver , "27.0.0" ) ) { return { browser : "firefox" , version : "24.0.0" } ; } else if ( lt ( semver , "29.0.0" ) ) { return { browser : "firefox" , version : "38" } ; } else { return { browser : "firefox" , version : "68" } ; } } if ( browser . name === "MIUI Browser" && browser . version != null && os . name === "Android" && engine . name == null ) { const semver = ensureSemver ( undefined , browser . version ) ; if ( semver . major === 8 || semver . major === 9 ) { return { browser : "chrome" , version : "53" } ; } } switch ( browser . name ) { case "Samsung Browser" : if ( browser . version != null ) { return { browser : "samsung" , version : browser . version } ; } else if ( engine . name === "Blink" && engine . version != null ) { return { browser : "chrome" , version : engine . version } ; } else { break ; } case "Android Browser" : { if ( device . vendor === "Samsung" ) { return { browser : "samsung" , version : browser . version } ; } return { browser : "android" , version : browser . version } ; } case "WebKit" : if ( device . type === "mobile" || device . type === "tablet" || device . type === "smarttv" || device . type === "wearable" || device . type === "embedded" ) { return { browser : "ios_saf" , version : os . version } ; } return { browser : "safari" , version : browser . version } ; case "Baidu" : return { browser : "baidu" , version : browser . version } ; case "Chrome Headless" : case "Chrome WebView" : return { browser : "chrome" , version : browser . version } ; case "Facebook" : return { browser : "chrome" , version : browser . version } ; case "Chrome" : { if ( os . name === "Android" ) { if ( os . version != null && browser . version != null ) { const browserSemver = ensureSemver ( "chrome" , browser . version ) ; const osSemver = ensureSemver ( undefined , os . version ) ; if ( lte ( osSemver , "4.4.4" ) && gte ( browserSemver , "400.0.0" ) ) { return { browser : "android" , version : os . version } ; } } return { browser : "chrome" , version : browser . version } ; } return { browser : "chrome" , version : browser . version } ; } case "Edge" : { if ( engine . name === "Blink" ) { if ( browser . version == null ) { return { browser : "chrome" , version : engine . version } ; } const semverVersion = ensureSemver ( "edge" , browser . version ) ; if ( semverVersion . major > 18 && semverVersion . major < 79 ) { return { browser : "chrome" , version : engine . version } ; } } return { browser : "edge" , version : browser . version } ; } case "Firefox" : if ( os . name === "Android" ) { return { browser : "and_ff" , version : browser . version } ; } return { browser : "firefox" , version : browser . version } ; case "IE" : return { browser : "ie" , version : browser . version } ; case "IE Mobile" : case "IEMobile" : return { browser : "ie_mob" , version : browser . version } ; case "Safari" : if ( browser . version == null && engine . name === "WebKit" && engine . version != null ) { const semver = ensureSemver ( undefined , engine . version ) ; if ( lt ( semver , "412.0.0" ) ) { return { browser : "safari" , version : "1.0" } ; } if ( lt ( semver , "522.0.0" ) ) { return { browser : "safari" , version : "2.0" } ; } if ( lt ( semver , "526.0.0" ) ) { return { browser : "safari" , version : "3.0" } ; } if ( lt ( semver , "533.0.0" ) ) { return { browser : "safari" , version : "4.0" } ; } if ( lt ( semver , "536.0.0" ) ) { return { browser : "safari" , version : "5.0" } ; } if ( lt ( semver , "537.71.0" ) ) { return { browser : "safari" , version : "6.0" } ; } if ( lt ( semver , "600.0.0" ) ) { return { browser : "safari" , version : "7.0" } ; } if ( lt ( semver , "601.0.0" ) ) { return { browser : "safari" , version : "8.0" } ; } if ( lt ( semver , "602.0.0" ) ) { return { browser : "safari" , version : "9.0" } ; } if ( lt ( semver , "604.0.0" ) ) { return { browser : "safari" , version : "10.0" } ; } if ( lt ( semver , "606.0.0" ) ) { return { browser : "safari" , version : "11.0" } ; } if ( lt ( semver , "608.0.0" ) ) { return { browser : "safari" , version : "12.0" } ; } if ( lt ( semver , "610.0.0" ) ) { return { browser : "safari" , version : "13.0" } ; } return { browser : "safari" , version : "14.0" } ; } return { browser : "safari" , version : browser . version } ; case "Mobile Safari" : case "MobileSafari" : case "Safari Mobile" : case "SafariMobile" : return { browser : "ios_saf" , version : os . version ?? browser . version } ; case "Opera" : return { browser : "opera" , version : browser . version } ; case "Opera Mini" : return { browser : "op_mini" , version : browser . version } ; case "Opera Mobi" : return { browser : "op_mob" , version : browser . version } ; case "QQBrowser" : return { browser : "and_qq" , version : browser . version } ; case "UCBrowser" : return { browser : "and_uc" , version : browser . version } ; default : switch ( engine . name ) { case "Blink" : return { browser : "chrome" , version : engine . version } ; case "WebKit" : return { browser : "safari" , version : browser . version } ; case "EdgeHTML" : return { browser : "edge" , version : browser . version } ; case "Gecko" : return { browser : "firefox" , version : engine . version } ; case "Presto" : return { browser : "opera" , version : browser . version } ; } } if ( browser . name == null && engine . name == null && device . type == null && os . name != null ) { return UNKNOWN_CANIUSE_BROWSER ; } return { } ; } /**
 * Normalizes the version of the browser such that it plays well with Caniuse
 */ function getCaniuseVersionForUseragentVersion ( { browser , version } , useragentBrowser , useragentOs , useragentEngine ) { if ( browser === "op_mini" ) { return "all" ; } else if ( browser === "safari" ) { const nextBrowserVersion = getNextVersionOfBrowser ( browser , version ) ; if ( nextBrowserVersion == null ) { return "TP" ; } } const coerced = ensureSemver ( browser , version ) ; if ( coerced == null ) throw new TypeError ( `Could not detect the version of: '${ version }' for browser: ${ browser }` ) ; const { major , minor , patch } = coerced ; const buildSemverVersion = ( majorVersion , minorVersion ? , patchVersion ? ) : string => `${ majorVersion }${ minorVersion == null || minorVersion === 0 ? "" : `.${ minorVersion }` }${ patchVersion == null || patchVersion === 0 ? "" : `.${ patchVersion }` }` ; switch ( browser ) { case "chrome" : if ( useragentEngine . name === "Blink" ) { return buildSemverVersion ( ensureSemver ( browser , getClosestMatchingBrowserVersion ( browser , useragentEngine . version ?? version ) ) . major ) ; } return buildSemverVersion ( major ) ; case "ie" : case "ie_mob" : case "edge" : case "bb" : case "and_chr" : case "and_ff" : return buildSemverVersion ( major ) ; case "opera" : case "op_mob" : if ( major === 10 || major === 11 || major === 12 ) { return buildSemverVersion ( major , minor ) ; } return buildSemverVersion ( major ) ; case "ios_saf" : { if ( useragentBrowser . name === "Safari" || useragentBrowser . name === "Mobile Safari" ) { return buildSemverVersion ( major , minor ) ; } else { if ( useragentOs . version == null ) throw new ReferenceError ( `Could not detect OS version of iOS for ${ useragentBrowser . name } on iOS` ) ; const osSemver = ensureSemver ( undefined , getClosestMatchingBrowserVersion ( browser , useragentOs . version ) ) ; return buildSemverVersion ( osSemver . major , osSemver . minor ) ; } } case "safari" : case "firefox" : { return buildSemverVersion ( major , minor ) ; } case "android" : if ( major < 4 ) { return buildSemverVersion ( major , minor ) ; } else if ( major === 4 ) { return buildSemverVersion ( major , minor , patch ) ; } else { return buildSemverVersion ( major ) ; } case "and_uc" : case "samsung" : case "and_qq" : case "baidu" : return buildSemverVersion ( major , minor ) ; default : return buildSemverVersion ( major ) ; } } /**
 * Generates a browserslist from the provided useragent string
 */ export function generateBrowserslistFromUseragent ( useragent ) { const cacheHit = userAgentToBrowserslistCache . get ( useragent ) ; if ( cacheHit != null ) return cacheHit ; const parser = new UaParserWrapper ( useragent ) ; const browser = parser . getBrowser ( ) ; const os = parser . getOS ( ) ; const engine = parser . getEngine ( ) ; let { browser : caniuseBrowserName , version : caniuseBrowserVersion } = getCaniuseBrowserForUseragentBrowser ( parser ) ; if ( caniuseBrowserName == null || caniuseBrowserVersion == null ) { throw new TypeError ( `No caniuse browser and/or version could be determined for User Agent: ${ useragent }` ) ; } caniuseBrowserVersion = normalizeBrowserVersion ( caniuseBrowserName , caniuseBrowserVersion ) ; const caniuseBrowser = { browser : caniuseBrowserName , version : caniuseBrowserVersion } ; caniuseBrowserVersion = getCaniuseVersionForUseragentVersion ( caniuseBrowser , browser , os , engine ) ; const normalizedBrowserslist = normalizeBrowserslist ( [ `${ caniuseBrowserName } ${ caniuseBrowserVersion }` ] ) ; userAgentToBrowserslistCache . set ( useragent , normalizedBrowserslist ) ; return normalizedBrowserslist ; } /**
 * Generates a browserslist from the provided useragent string and checks if it matches
 * the given browserslist
 */ export function matchBrowserslistOnUserAgent ( useragent , browserslist ) { const useragentBrowserslist = generateBrowserslistFromUseragent ( useragent ) ; const normalizedInputBrowserslist = normalizeBrowserslist ( browserslist ) ; return useragentBrowserslist . every ( option => normalizedInputBrowserslist . includes ( option ) ) ; } /**
 * Returns a key to use for the cache between user agents with feature names and whether or not the user agent supports them
 */ function userAgentWithFeaturesCacheKey ( useragent , features ) { return `${ useragent }.${ features . join ( "," ) }` ; } /**
 * Returns true if the given user agent supports the given features
 */ export function userAgentSupportsFeatures ( useragent , ... features ) { const cacheKey = userAgentWithFeaturesCacheKey ( useragent , features ) ; const cacheHit = userAgentWithFeaturesToSupportCache . get ( cacheKey ) ; if ( cacheHit != null ) return cacheHit ; const useragentBrowserslist = generateBrowserslistFromUseragent ( useragent ) ; const supportedBrowserslist = normalizeBrowserslist ( browsersWithSupportForFeatures ( ... features ) ) ; const support = useragentBrowserslist . every ( option => supportedBrowserslist . includes ( option ) ) ; userAgentWithFeaturesToSupportCache . set ( cacheKey , support ) ; return support ; }