"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/index.ts var src_exports = {}; __export(src_exports, { browsersWithSupportForEcmaVersion: () => browsersWithSupportForEcmaVersion, browsersWithSupportForFeatures: () => browsersWithSupportForFeatures, browsersWithoutSupportForFeatures: () => browsersWithoutSupportForFeatures, browserslistSupportsEcmaVersion: () => browserslistSupportsEcmaVersion, browserslistSupportsFeatures: () => browserslistSupportsFeatures, generateBrowserslistFromUseragent: () => generateBrowserslistFromUseragent, getAppropriateEcmaVersionForBrowserslist: () => getAppropriateEcmaVersionForBrowserslist, getFeaturesForEcmaVersion: () => getFeaturesForEcmaVersion, getFirstVersionsWithFullSupport: () => getFirstVersionsWithFullSupport, matchBrowserslistOnUserAgent: () => matchBrowserslistOnUserAgent, normalizeBrowserslist: () => normalizeBrowserslist, userAgentSupportsFeatures: () => userAgentSupportsFeatures }); module.exports = __toCommonJS(src_exports); // src/browserslist-generator/browserslist-generator.ts var import_browserslist2 = __toESM(require("browserslist"), 1); var import_caniuse_lite = require("caniuse-lite"); var compatData = __toESM(require("@mdn/browser-compat-data"), 1); var import_object_path = __toESM(require("object-path"), 1); var import_semver5 = require("semver"); // src/browserslist-generator/browser-version.ts var import_browserslist = __toESM(require("browserslist"), 1); var import_semver2 = require("semver"); // src/browserslist-generator/ensure-semver.ts var import_semver = require("semver"); function ensureSemver(browser, version) { if ((browser === "op_mini" || browser === "android") && version === "all") { return (0, import_semver.coerce)("0.0.0"); } else if (browser === "safari" && version === "TP") { return SAFARI_TP_MAJOR_VERSION; } return (0, import_semver.coerce)(version, { loose: true }) ?? void 0; } function coerceToString(browser, version) { return ensureSemver(browser, version)?.toString() ?? ""; } // src/browserslist-generator/compare-versions.ts function compareVersions(a, b) { const normalizedA = isNaN(parseFloat(a)) ? a : parseFloat(a); const normalizedB = isNaN(parseFloat(b)) ? b : parseFloat(b); if (typeof normalizedA === "string" && typeof normalizedB !== "string") { return 1; } if (typeof normalizedB === "string" && typeof normalizedA !== "string") { return -1; } if (normalizedA < normalizedB) return -1; if (normalizedA > normalizedB) return 1; return 0; } // src/browserslist-generator/normalize-browser-version-regexp.ts var NORMALIZE_BROWSER_VERSION_REGEXP = /(?![\d.,]+-)-*(.*)/; // src/browserslist-generator/util.ts function assertNonEmptyArray(array, message = "Array is empty") { if (array.length === 0) { throw new Error(message); } return; } // src/browserslist-generator/browser-version.ts var SAFARI_TP_MAJOR_VERSION = (() => { const versions = getSortedBrowserVersions("safari"); const lastVersionBeforeTp = versions[versions.length - 2]; const coerced = (0, import_semver2.coerce)(lastVersionBeforeTp); if (coerced.minor === 9) { return (0, import_semver2.coerce)(coerced.major + 1); } else { return (0, import_semver2.coerce)(`${coerced.major}.${coerced.minor + 1}.0`); } })(); function normalizeBrowserVersion(browser, givenVersion, versions = getSortedBrowserVersions(browser), allowSmaller = false) { const givenVersionCoerced = ensureSemver(browser, givenVersion); const latestVersion = getLatestVersionOfBrowser(browser); const latestVersionCoerced = ensureSemver(browser, latestVersion); if (givenVersionCoerced == null || latestVersionCoerced == null) { throw new TypeError(`Could not detect the version of: '${givenVersion}' for browser: ${browser}`); } if (givenVersionCoerced.major > latestVersionCoerced.major || givenVersionCoerced.major === latestVersionCoerced.major && givenVersionCoerced.minor > latestVersionCoerced.minor || givenVersionCoerced.major === latestVersionCoerced.major && givenVersionCoerced.minor === latestVersionCoerced.minor && givenVersionCoerced.patch > latestVersionCoerced.patch) { return latestVersion; } const closestMatch = getClosestMatchingBrowserVersion(browser, givenVersion, versions); const semverClosestMatch = ensureSemver(browser, closestMatch); if (allowSmaller && semverClosestMatch != null && (0, import_semver2.lt)(givenVersionCoerced, semverClosestMatch, { loose: true })) { return givenVersion; } return closestMatch; } function getClosestMatchingBrowserVersion(browser, version, versions = getSortedBrowserVersions(browser)) { assertNonEmptyArray(versions, `Could not find any versions for browser: ${browser}`); const coerced = ensureSemver(browser, version); if (browser === "op_mini" && version === "all") return "all"; if (browser === "safari") { const browserMajorMinorSemver = coerced == null ? void 0 : ensureSemver(browser, `${coerced.major}.${coerced.minor}`); const browserLatestNonTpSemver = coerced == null ? void 0 : ensureSemver(browser, versions.slice(-2)[0]); if (version === "TP") { return "TP"; } else if (browserMajorMinorSemver != null && browserLatestNonTpSemver != null && (0, import_semver2.gt)(browserMajorMinorSemver, browserLatestNonTpSemver)) { return "TP"; } } let [candidate] = versions; versions.forEach((currentVersion) => { const currentCoerced = ensureSemver(browser, currentVersion); if (currentCoerced != null && coerced != null && (0, import_semver2.gte)(coerced, currentCoerced)) { candidate = currentVersion; } }); return candidate; } function getSortedBrowserVersionsWithLeadingVersion(browser, inputVersion) { const versions = getSortedBrowserVersions(browser); const [firstVersion] = versions; if (firstVersion != null && inputVersion != null) { const firstVersionSemver = ensureSemver(browser, firstVersion); let nextInputVersion = inputVersion; while (true) { const nextInputSemver = ensureSemver(browser, nextInputVersion); if (firstVersionSemver != null && nextInputSemver != null && (0, import_semver2.gt)(firstVersionSemver, nextInputSemver)) { versions.unshift(nextInputVersion); nextInputVersion = String(nextInputSemver.major + 1); } else { break; } } } return versions; } function getSortedBrowserVersions(browser) { const queryResult = (0, import_browserslist.default)([`>= 0%`, `unreleased versions`]); const versions = []; queryResult.forEach((part) => { const [currentBrowser, version] = part.split(" "); if (currentBrowser !== browser) return; const versionMatch = version.match(NORMALIZE_BROWSER_VERSION_REGEXP); const normalizedVersion = versionMatch == null ? version : versionMatch[1]; if (normalizedVersion != null) { versions.push(normalizedVersion); } }); return versions.sort(compareVersions); } function getLatestVersionOfBrowser(browser) { const versions = getSortedBrowserVersions(browser); assertNonEmptyArray(versions); return versions[versions.length - 1]; } function getOldestVersionOfBrowser(browser) { const versions = getSortedBrowserVersions(browser); assertNonEmptyArray(versions); return versions[0]; } function getPreviousVersionOfBrowser(browser, version) { const versions = getSortedBrowserVersions(browser); const indexOfVersion = versions.indexOf(normalizeBrowserVersion(browser, version, versions)); if (indexOfVersion <= 0) return void 0; return versions[indexOfVersion - 1]; } function getNextVersionOfBrowser(browser, version) { const versions = getSortedBrowserVersions(browser); const indexOfVersion = versions.indexOf(normalizeBrowserVersion(browser, version, versions)); if (indexOfVersion <= 0) return void 0; return versions[indexOfVersion + 1]; } // src/browserslist-generator/constant.ts var UNKNOWN_CANIUSE_BROWSER = { browser: "chrome", version: "80" }; // src/browserslist-generator/ecma-version.ts var ES5_FEATURES = [ "javascript.builtins.Object.create", "javascript.builtins.Object.getPrototypeOf", "javascript.builtins.Object.defineProperty", "javascript.builtins.Object.defineProperties", "javascript.builtins.Object.getOwnPropertyDescriptor", "javascript.builtins.Object.getOwnPropertyNames", "javascript.builtins.Object.keys", "javascript.builtins.Object.preventExtensions", "javascript.builtins.Object.isExtensible", "javascript.builtins.Object.seal", "javascript.builtins.Object.isSealed", "javascript.builtins.Object.freeze", "javascript.builtins.Object.isFrozen", "javascript.builtins.Function.bind", "javascript.builtins.String.trim", "javascript.builtins.Array.isArray", "javascript.builtins.Array.every", "javascript.builtins.Array.filter", "javascript.builtins.Array.forEach", "javascript.builtins.Array.indexOf", "javascript.builtins.Array.lastIndexOf", "javascript.builtins.Array.map", "javascript.builtins.Array.reduce", "javascript.builtins.Array.some", "javascript.builtins.JSON.parse", "javascript.builtins.JSON.stringify", "javascript.builtins.Date.now", "javascript.builtins.Date.toISOString" ]; var ES2015_FEATURES = [ ...ES5_FEATURES, "javascript.classes", "javascript.statements.const", "javascript.statements.let", "javascript.functions.arrow_functions", "javascript.functions.rest_parameters", "javascript.grammar.template_literals", "javascript.operators.destructuring", "javascript.operators.spread.spread_in_arrays", "javascript.functions.default_parameters", "javascript.builtins.RegExp.sticky", "javascript.operators.object_initializer.shorthand_property_names", "javascript.operators.object_initializer.computed_property_names", "javascript.operators.object_initializer.shorthand_method_names" ]; var ES2016_FEATURES = [...ES2015_FEATURES, "javascript.operators.exponentiation", "javascript.builtins.Array.includes"]; var ES2017_FEATURES = [ ...ES2016_FEATURES, "javascript.builtins.AsyncFunction", "javascript.builtins.Object.values", "javascript.builtins.Object.entries", "javascript.builtins.Object.getOwnPropertyDescriptors", "javascript.builtins.String.padStart", "javascript.builtins.String.padEnd" ]; var ES2018_FEATURES = [...ES2017_FEATURES, "javascript.operators.spread.spread_in_object_literals", "javascript.builtins.Promise.finally"]; var ES2019_FEATURES = [ ...ES2018_FEATURES, "javascript.builtins.Array.flat", "javascript.builtins.Array.flatMap", "javascript.builtins.Object.fromEntries", "javascript.builtins.String.trimStart", "javascript.builtins.String.trimEnd", "javascript.builtins.JSON.json_superset", "javascript.builtins.JSON.stringify.well_formed_stringify", "javascript.builtins.Symbol.description", "javascript.statements.try_catch.optional_catch_binding" ]; var ES2020_FEATURES = [...ES2019_FEATURES, "javascript.builtins.String.matchAll"]; var ES2021_FEATURES = [ ...ES2020_FEATURES, "javascript.operators.logical_or_assignment", "javascript.operators.nullish_coalescing_assignment", "javascript.operators.logical_and_assignment", "javascript.builtins.String.replaceAll", "javascript.grammar.numeric_separators", "javascript.builtins.Promise.any" ]; var ES2022_FEATURES = [ ...ES2021_FEATURES, "javascript.builtins.Array.at", "javascript.builtins.String.matchAll", "javascript.classes.public_class_fields", "javascript.classes.private_class_fields", "javascript.classes.private_class_fields_in", "javascript.classes.static_class_fields", "javascript.operators.await.top_level", "javascript.builtins.RegExp.hasIndices" ]; var ES2023_FEATURES = [ ...ES2022_FEATURES, "javascript.builtins.Array.findLast", "javascript.builtins.Array.findLastIndex", "javascript.grammar.hashbang_comments", "javascript.builtins.WeakMap.symbol_as_keys", "javascript.builtins.Array.toReversed", "javascript.builtins.Array.toSorted", "javascript.builtins.Array.toSpliced", "javascript.builtins.Array.with" ]; var ES2024_FEATURES = [ ...ES2023_FEATURES, "javascript.builtins.String.isWellFormed", "javascript.builtins.String.toWellFormed", "javascript.builtins.Atomics.waitAsync", "javascript.builtins.ArrayBuffer.resize", "javascript.builtins.Object.groupBy", "javascript.builtins.Map.groupBy", "javascript.builtins.Promise.withResolvers", "javascript.builtins.ArrayBuffer.transfer" ]; // src/browserslist-generator/range-correction.ts var import_semver3 = require("semver"); function rangeCorrection(browser, supportKind, start, end) { const versions = getSortedBrowserVersions(browser); const corrections = []; versions.forEach((version) => { let shouldSet = false; if (start == null && end == null) { shouldSet = true; } else if (start != null && end == null) { if (version === "TP") { shouldSet = true; } else if (version === "all") { shouldSet = true; } else { shouldSet = (0, import_semver3.gte)(coerceToString(browser, version), coerceToString(browser, start)); } } else if (start == null && end != null) { if (version === "TP") { shouldSet = end === "TP"; } else if (version === "all") { shouldSet = true; } else { shouldSet = (0, import_semver3.lte)(coerceToString(browser, version), coerceToString(browser, end)); } } else if (start != null && end != null) { if (version === "TP") { shouldSet = end === "TP"; } else if (version === "all") { shouldSet = true; } else { shouldSet = (0, import_semver3.gte)(coerceToString(browser, version), coerceToString(browser, start)) && (0, import_semver3.lte)(coerceToString(browser, version), coerceToString(browser, end)); } } if (shouldSet) { corrections.push({ kind: supportKind, version }); } }); return corrections; } // src/browserslist-generator/ua-parser-wrapper.ts var import_semver4 = require("semver"); var import_ua_parser_js = require("ua-parser-js"); var import_isbot = require("isbot"); var FIREFOX_MATCH = /Firefox\/([\d.]+)/i; var IOS_REGEX_1 = /(iPhone)|(iPad)/i; var IOS_REGEX_2 = /(iOS)\s*([\d._]+)/i; var UNDERSCORED_VERSION_REGEX = /\d+_/; var FBSV_IOS_VERSION_REGEX = /FBSV\/([\d.]+)/i; var IOS_14_5_UA_1 = /(CFNetwork\/1237\s+Darwin\/20.4)/i; var IOS_3_2_UA_1 = /(^Mobile\/7B334b)/i; var isbot = (0, import_isbot.createIsbotFromList)([...import_isbot.list, "bitdiscovery", "Dalvik/", "placid.app/v1", "WebsiteMetadataRetriever", "(compatible; aa/1.0)"]); var PARSER_EXTENSIONS = { engine: [[/(Chrome)\/([\d.]+)/i], ["blink", "version"]], browser: [ [/(MetaSr)\s*([\d.]+)/i], ["Sogou Explorer", "version"], [/(HeyTapBrowser)\/([\d.]+)/i], ["HeyTapBrowser", "version"], [/(SamsungBrowser)\/CrossApp/i], ["Samsung Browser"], [/(Nokia\d+\/[\d.]+.*Profile\/MIDP)/i], ["WAP"] ] }; var UaParserWrapper = class { constructor(userAgent) { this.userAgent = userAgent; this.parser = new import_ua_parser_js.UAParser(userAgent, PARSER_EXTENSIONS); } /** * An instanceof UAParser */ parser; /** * Gets the IUserAgentBrowser based on the UAParser */ getBrowser() { return this.extendGetBrowserResult(this.parser.getBrowser()); } /** * Gets the IUserAgentOS based on the UAParser */ getOS() { return this.extendGetOsResult(this.parser.getOS()); } /** * Gets the IUserAgentDevice based on the UAParser */ getDevice() { return this.parser.getDevice(); } /** * Gets the IEngine based on the UAParser */ getEngine() { return this.extendGetEngineResult(this.parser.getEngine()); } /** * Extends the result of calling 'getBrowser' on the UAParser and always takes bots into account */ extendGetBrowserResult(result) { if (result.name === "Edge") { const engine = this.parser.getEngine(); if (engine.name === "EdgeHTML") { result.version = engine.version; result.major = String((0, import_semver4.coerce)(engine.version)?.major ?? result.version); } } if (result.name !== "Chrome Headless" && Boolean(isbot(this.userAgent))) { if (this.userAgent.includes("http://www.google.com/bot.htm") || this.userAgent.includes("http://www.google.com/adsbot.htm")) { result.name = "Chrome"; result.version = "74"; result.major = "74"; } else { result.name = "IE"; result.version = "11"; result.major = "11"; } } if (result["Sogou Explorer"] != null) { result.name = "Sogou Explorer"; delete result["Sogou Explorer"]; } else if (result.HeyTapBrowser != null) { result.name = "HeyTapBrowser"; delete result.HeyTapBrowser; } else if (result["Samsung Browser"] != null) { result.name = "Samsung Browser"; delete result["Samsung Browser"]; } else if (result.WAP != null) { result.name = "IE"; result.version = "8"; delete result.WAP; } return result; } /** * Extends the result of calling 'getEngine' */ extendGetEngineResult(result) { if (result.blink != null) { result.name = "Blink"; delete result.blink; } if (result.name === "Goanna") { const ffMatch = this.userAgent.match(FIREFOX_MATCH); if (ffMatch != null) { result.name = "Gecko"; result.version = ffMatch[1]; } } return result; } /** * Extends the result of calling 'getOS' */ extendGetOsResult(result) { if (result.version != null && UNDERSCORED_VERSION_REGEX.test(result.version)) { result.version = result.version.replace(/_/g, "."); } if ((result.name == null || result.name === "iOS") && (IOS_REGEX_1.test(this.userAgent) || IOS_REGEX_2.test(this.userAgent))) { result.name = "iOS"; if (result.version == null) { const fbsvMatch = this.userAgent.match(FBSV_IOS_VERSION_REGEX); if (fbsvMatch != null) { result.version = fbsvMatch[1]?.replace(/_/g, "."); } else { const iosRegex2Match = this.userAgent.match(IOS_REGEX_2); if (iosRegex2Match != null) { result.version = iosRegex2Match[2]?.replace(/_/g, "."); } } } } if ((result.name == null || result.name === "iOS") && IOS_14_5_UA_1.test(this.userAgent)) { result.name = "iOS"; result.version = "14.5"; } if ((result.name == null || result.name === "iOS") && IOS_3_2_UA_1.test(this.userAgent)) { result.name = "iOS"; result.version = "3.2"; } return result; } }; // src/browserslist-generator/browserslist-generator.ts var userAgentToBrowserslistCache = /* @__PURE__ */ new Map(); var browserSupportForFeaturesCache = /* @__PURE__ */ new Map(); var featureToCaniuseStatsCache = /* @__PURE__ */ new Map(); var userAgentWithFeaturesToSupportCache = /* @__PURE__ */ new Map(); var CANIUSE_TO_MDN_FEATURE_MAP = { pointer: "api.PointerEvent.PointerEvent", shadowdomv1: "api.ShadowRoot", "custom-elementsv1": "api.CustomElementRegistry", template: "html.elements.template", fetch: "api.fetch", promises: "javascript.builtins.Promise", "object-values": "javascript.builtins.Object.values", mutationobserver: "api.MutationObserver", "focusin-focusout-events": "api.Element.focusin_event", "high-resolution-time": "api.Performance.now", url: "api.URL", urlsearchparams: "api.URLSearchParams", "object-fit": "css.properties.object-fit", "console-basic": "api.console.info", "console-time": "api.console.time", "atob-btoa": "api.atob", blobbuilder: "api.Blob.Blob", bloburls: "api.URL.createObjectURL", requestidlecallback: "api.Window.requestIdleCallback", requestanimationframe: "api.Window.requestAnimationFrame", proxy: "javascript.builtins.Proxy" }; var PARTIAL_SUPPORT_ALLOWANCES = /* @__PURE__ */ new Map([ ["shadowdomv1", "*"], ["custom-elementsv1", "*"], ["web-animation", "*"] ]); var TYPED_ARRAY_BASE_DATA_CORRECTIONS_INPUT = { /* eslint-disable @typescript-eslint/naming-convention */ android: rangeCorrection("android", "available", `4`), chrome: rangeCorrection("and_chr", "available", `7`), and_chr: rangeCorrection("and_chr", "available", `7`), edge: rangeCorrection("edge", "available", "12"), samsung: rangeCorrection("samsung", "available", `4`), opera: rangeCorrection("opera", "available", `12`), op_mob: rangeCorrection("op_mob", "available", `12`), firefox: rangeCorrection("firefox", "available", `4`), and_ff: rangeCorrection("and_ff", "available", `4`), safari: rangeCorrection("safari", "available", `6`), ios_saf: rangeCorrection("safari", "available", `5`), ie: rangeCorrection("ie", "available", `11`), op_mini: rangeCorrection("op_mini", "available", `all`), bb: rangeCorrection("bb", "available", `10`) /* eslint-enable @typescript-eslint/naming-convention */ }; var TYPED_ARRAY_ES2015_DATA_CORRECTIONS_INPUT = { /* eslint-disable @typescript-eslint/naming-convention */ android: rangeCorrection("android", "available", `45`), chrome: rangeCorrection("and_chr", "available", `45`), and_chr: rangeCorrection("and_chr", "available", `45`), edge: rangeCorrection("edge", "available", "12"), samsung: rangeCorrection("samsung", "available", `5`), opera: rangeCorrection("opera", "available", `32`), op_mob: rangeCorrection("op_mob", "available", `32`), firefox: rangeCorrection("firefox", "available", `38`), and_ff: rangeCorrection("and_ff", "available", `38`), safari: rangeCorrection("safari", "available", `10`), ios_saf: rangeCorrection("safari", "available", `10`), ie: rangeCorrection("ie", "available", `11`), ie_mob: rangeCorrection("ie", "available", `11`) /* eslint-enable @typescript-eslint/naming-convention */ }; var TYPED_ARRAY_ES2016_DATA_CORRECTIONS_INPUT = { /* eslint-disable @typescript-eslint/naming-convention */ android: rangeCorrection("android", "available", `47`), chrome: rangeCorrection("and_chr", "available", `47`), and_chr: rangeCorrection("and_chr", "available", `47`), edge: rangeCorrection("edge", "available", "14"), samsung: rangeCorrection("samsung", "available", `5`), opera: rangeCorrection("opera", "available", `34`), op_mob: rangeCorrection("op_mob", "available", `34`), firefox: rangeCorrection("firefox", "available", `43`), and_ff: rangeCorrection("and_ff", "available", `43`), safari: rangeCorrection("safari", "available", `10`), ios_saf: rangeCorrection("safari", "available", `10`) /* eslint-enable @typescript-eslint/naming-convention */ }; var TYPED_ARRAY_KEYS_VALUES_ENTRIES_ITERATOR_DATA_CORRECTIONS_INPUT = { /* eslint-disable @typescript-eslint/naming-convention */ android: rangeCorrection("android", "available", `38`), chrome: rangeCorrection("and_chr", "available", `38`), and_chr: rangeCorrection("and_chr", "available", `38`), edge: rangeCorrection("edge", "available", "12"), samsung: rangeCorrection("samsung", "available", `5`), opera: rangeCorrection("opera", "available", `26`), op_mob: rangeCorrection("op_mob", "available", `26`), firefox: rangeCorrection("firefox", "available", `37`), and_ff: rangeCorrection("and_ff", "available", `37`), safari: rangeCorrection("safari", "available", `10`), ios_saf: rangeCorrection("safari", "available", `10`) /* eslint-enable @typescript-eslint/naming-convention */ }; var TYPED_ARRAY_SPECIES_DATA_CORRECTIONS_INPUT = { /* eslint-disable @typescript-eslint/naming-convention */ android: rangeCorrection("android", "available", `51`), chrome: rangeCorrection("and_chr", "available", `51`), and_chr: rangeCorrection("and_chr", "available", `51`), edge: rangeCorrection("edge", "available", "13"), samsung: rangeCorrection("samsung", "available", `5`), opera: rangeCorrection("opera", "available", `38`), op_mob: rangeCorrection("op_mob", "available", `38`), firefox: rangeCorrection("firefox", "available", `48`), and_ff: rangeCorrection("and_ff", "available", `48`), safari: rangeCorrection("safari", "available", `10`), ios_saf: rangeCorrection("safari", "available", `10`) /* eslint-enable @typescript-eslint/naming-convention */ }; var FEATURE_TO_BROWSER_DATA_CORRECTIONS_INPUT = [ /* eslint-disable @typescript-eslint/naming-convention */ [ "xhr2", { ie: [ { // Caniuse reports that XMLHttpRequest support is partial in Internet Explorer 11, but it is in fact properly supported kind: "available", version: "11" } ] } ], [ // Caniuse reports that Safari 12.1 and iOS Safari 12.2 has partial support for Web Animations, // but they do not - They require enabling it as an experimental feature "web-animation", { safari: rangeCorrection("safari", "unavailable", `0`, "13.4"), ios_saf: rangeCorrection("ios_saf", "unavailable", `0`, "13.4") } ], [ "es6-class", { edge: [ { // Caniuse reports that Microsoft Edge has been supporting classes since v12, but it was prefixed until v13 kind: "prefixed", version: "12" } ], ios_saf: [ { // Caniuse reports that iOS Safari has been supporting classes since v9, but the implementation was only partial kind: "partial_support", version: "9" }, { // Caniuse reports that iOS Safari has been supporting classes since v9, but the implementation was only partial kind: "partial_support", version: "9.2" }, { // Caniuse reports that iOS Safari has been supporting classes since v9, but the implementation was only partial kind: "partial_support", version: "9.3" } ], safari: [ { // Caniuse reports that Safari has been supporting classes since v9, but the implementation was only partial kind: "partial_support", version: "9" }, { // Caniuse reports that Safari has been supporting classes since v9, but the implementation was only partial kind: "partial_support", version: "9.1" } ] } ], [ "api.Element.classList", { edge: [ { // Caniuse reports that Microsoft Edge v15 has only partial support for class-list since it doesn't support SVG elements, // but we don't want feature detections to return false for that browser kind: "available", version: "15" } ], ie: [ { // Caniuse reports that IE 10 has only partial support for class-list since it doesn't support SVG elements, // but we don't want feature detections to return false for that browser kind: "available", version: "10" }, { // Caniuse reports that IE 11 has only partial support for class-list since it doesn't support SVG elements, // but we don't want feature detections to return false for that browser kind: "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", "available", `38`), chrome: rangeCorrection("chrome", "available", `38`), and_chr: rangeCorrection("and_chr", "available", `38`), edge: rangeCorrection("edge", "available", `12`), opera: rangeCorrection("opera", "available", `25`), op_mob: rangeCorrection("op_mob", "available", `25`), firefox: rangeCorrection("firefox", "available", `36`), and_ff: rangeCorrection("and_ff", "available", `36`), safari: rangeCorrection("safari", "available", `9`), ios_saf: rangeCorrection("ios_saf", "available", `9`), samsung: rangeCorrection("samsung", "available", `3`) } ], [ "javascript.builtins.Symbol.asyncIterator", { android: rangeCorrection("android", "available", `63`), chrome: rangeCorrection("chrome", "available", `63`), and_chr: rangeCorrection("and_chr", "available", `63`), opera: rangeCorrection("opera", "available", `50`), op_mob: rangeCorrection("op_mob", "available", `50`), firefox: rangeCorrection("firefox", "available", `57`), and_ff: rangeCorrection("and_ff", "available", `57`), safari: rangeCorrection("safari", "available", `11.1`), ios_saf: rangeCorrection("ios_saf", "available", `11.1`) } ], [ "javascript.builtins.Array.@@species", { android: rangeCorrection("android", "available", `51`), // MDN reports that it doesn't support Array.@@species, but it does and has done since Chrome v51 chrome: rangeCorrection("chrome", "available", `51`), // MDN reports that it doesn't support Array.@@species, but it does and has done since Chrome for Android v51 and_chr: rangeCorrection("and_chr", "available", `51`), // MDN reports that it doesn't support Array.@@species, but it does and has done since Edge v14 edge: rangeCorrection("edge", "available", `14`), // MDN reports that it doesn't support Array.@@species, but it does and has done since Firefox v41 firefox: rangeCorrection("firefox", "available", `41`), // MDN reports that it doesn't support Array.@@species, but it does and has done since Firefox for Android v41 and_ff: rangeCorrection("and_ff", "available", `41`), // MDN reports that it doesn't support Array.@@species, but it does and has done since Opera v38 opera: rangeCorrection("opera", "available", `38`), // MDN reports that it doesn't support Array.@@species, but it does and has done since Opera for Android v38 op_mob: rangeCorrection("op_mob", "available", `38`), // MDN reports that it doesn't support Array.@@species, but it does and has done since Safari v10 safari: rangeCorrection("safari", "available", `10`), // MDN reports that it doesn't support Array.@@species, but it does and has done since Safari for iOS v10 ios_saf: rangeCorrection("ios_saf", "available", `10`) } ], [ "javascript.builtins.Date.@@toPrimitive", { android: rangeCorrection("android", "available", `48`), // MDN reports that it doesn't support Date.@@toPrimitive, but it does and has done since Chrome v48 chrome: rangeCorrection("chrome", "available", `48`), // MDN reports that it doesn't support Date.@@toPrimitive, but it does and has done since Chrome for Android v48 and_chr: rangeCorrection("and_chr", "available", `48`), // MDN reports that it doesn't support Date.@@toPrimitive, but it does and has done in all Edge versions edge: rangeCorrection("edge", "available"), // MDN reports that it doesn't support Date.@@toPrimitive, but it does and has done since Firefox v44 firefox: rangeCorrection("firefox", "available", `44`), // MDN reports that it doesn't support Date.@@toPrimitive, but it does and has done since Firefox for Android v44 and_ff: rangeCorrection("and_ff", "available", `44`), // MDN reports that it doesn't support Date.@@toPrimitive, but it does and has done since Opera v35 opera: rangeCorrection("opera", "available", `35`), // MDN reports that it doesn't support Date.@@toPrimitive, but it does and has done since Opera for Android v35 op_mob: rangeCorrection("op_mob", "available", `35`), // MDN reports that it doesn't support Date.@@toPrimitive, but it does and has done since Safari v10 safari: rangeCorrection("safari", "available", `10`), // MDN reports that it doesn't support Date.@@toPrimitive, but it does and has done since Safari for iOS v10 ios_saf: rangeCorrection("ios_saf", "available", `10`), // MDN reports that it doesn't support the Date.@@toPrimitive method, but it does and has done for all Samsung Internet versions samsung: rangeCorrection("samsung", "available") } ], [ "fetch", { edge: [ { // Caniuse reports that Microsoft Edge has been supporting fetch since v14, but the implementation was quite unstable until v15 kind: "unavailable", version: "14" } ] } ], [ "api.Window", { chrome: rangeCorrection("chrome", "unavailable", `0`, `18`), safari: rangeCorrection("safari", "unavailable", `0`, `5.1`), ie: rangeCorrection("ie", "unavailable", `0`, `7`), opera: rangeCorrection("safari", "unavailable", `0`, `11.1`) } ], [ "javascript.builtins.String.matchAll", { samsung: rangeCorrection("samsung", "unavailable", `0`, `9.4`) } ], [ "resizeobserver", { safari: rangeCorrection("safari", "unavailable", `0`) } ] /* eslint-enable @typescript-eslint/naming-convention */ ]; var FEATURE_TO_BROWSER_DATA_CORRECTIONS_MAP = new Map(FEATURE_TO_BROWSER_DATA_CORRECTIONS_INPUT); function extendQueryWith(query, extendWith) { const normalizedExtendWith = Array.isArray(extendWith) ? extendWith : [extendWith]; return [.../* @__PURE__ */ new Set([...query, ...normalizedExtendWith])]; } function normalizeBrowserslist(browserslist) { const result = (0, import_browserslist2.default)(browserslist); const inputBrowserslist = Array.isArray(browserslist) ? browserslist : [browserslist]; for (const browser of ["and_ff", "and_chr", "op_mini"]) { const versions = getSortedBrowserVersions(browser); for (const entry of inputBrowserslist) { if (!entry.startsWith(browser)) continue; const directMatch = entry.match(new RegExp(`${browser} (\\d+.*)`)); if (directMatch != null) { const candidate = `${browser} ${directMatch[1]}`; if (!result.includes(candidate)) { result.push(candidate); } } else { const greaterThanOrEqualsMatch = entry.match(new RegExp(`${browser} >= (\\d+)`)); if (greaterThanOrEqualsMatch != null) { let currentMajor = Number(greaterThanOrEqualsMatch[1]); while (true) { const candidate = `${browser} ${currentMajor}`; if (!result.includes(candidate)) { result.push(candidate); currentMajor++; if (Number(getClosestMatchingBrowserVersion(browser, String(currentMajor), versions)) <= currentMajor) break; } else { break; } } } } } } return result.sort(); } function extendQueryWithUnreleasedVersions(query, browsers) { return extendQueryWith( query, Array.from(browsers).map((browser) => `unreleased ${browser} versions`) ); } function browsersWithSupportForFeatures(...args) { const [firstArg] = args; const { features } = firstArg != null && typeof firstArg === "object" ? firstArg : { features: args }; const { query, browsers } = browserSupportForFeaturesCommon(">=", ...features); return extendQueryWithUnreleasedVersions(query, browsers); } function browserslistSupportsEcmaVersion(browserslist, version, options) { const features = getFeaturesForEcmaVersion(version, options); if (features.length === 0) return true; return browserslistSupportsFeatures(browserslist, ...features); } function getFeaturesForEcmaVersion(version, options) { const features = getFeaturesForEcmaVersionInner(version); const filteredFirstPass = Boolean(options?.syntaxOnly) ? features.filter((feature) => !feature.startsWith("javascript.builtins.")) : features; return typeof options?.featureFilter === "function" ? filteredFirstPass.filter(options.featureFilter) : filteredFirstPass; } function getFeaturesForEcmaVersionInner(version) { switch (version) { case "es3": return []; case "es5": return ES5_FEATURES; case "es2015": return ES2015_FEATURES; case "es2016": return ES2016_FEATURES; case "es2017": return ES2017_FEATURES; case "es2018": return ES2018_FEATURES; case "es2019": return ES2019_FEATURES; case "es2020": return ES2020_FEATURES; case "es2021": return ES2021_FEATURES; case "es2022": return ES2022_FEATURES; case "es2023": return ES2023_FEATURES; case "es2024": return ES2024_FEATURES; } } function getAppropriateEcmaVersionForBrowserslist(browserslist, options) { if (browserslistSupportsEcmaVersion(browserslist, "es2024", options)) return "es2024"; if (browserslistSupportsEcmaVersion(browserslist, "es2023", options)) return "es2023"; if (browserslistSupportsEcmaVersion(browserslist, "es2022", options)) return "es2022"; if (browserslistSupportsEcmaVersion(browserslist, "es2021", options)) return "es2021"; if (browserslistSupportsEcmaVersion(browserslist, "es2020", options)) return "es2020"; if (browserslistSupportsEcmaVersion(browserslist, "es2019", options)) return "es2019"; if (browserslistSupportsEcmaVersion(browserslist, "es2018", options)) return "es2018"; else if (browserslistSupportsEcmaVersion(browserslist, "es2017", options)) return "es2017"; else if (browserslistSupportsEcmaVersion(browserslist, "es2016", options)) return "es2016"; else if (browserslistSupportsEcmaVersion(browserslist, "es2015", options)) return "es2015"; else if (browserslistSupportsEcmaVersion(browserslist, "es5", options)) return "es5"; else return "es3"; } function browsersWithSupportForEcmaVersion(version, options) { switch (version) { case "es3": return browsersWithoutSupportForFeatures(...getFeaturesForEcmaVersion("es5", options)); default: return browsersWithSupportForFeatures(...getFeaturesForEcmaVersion(version, options)); } } function browserslistSupportsFeatures(browserslist, ...features) { const normalizedIdealBrowserslist = normalizeBrowserslist(browsersWithSupportForFeatures(...features)); const normalizedInputBrowserslist = normalizeBrowserslist(browserslist); return normalizedInputBrowserslist.every((option) => normalizedIdealBrowserslist.includes(option)); } function browsersWithoutSupportForFeatures(...args) { const [firstArg] = args; const { features } = firstArg != null && typeof firstArg === "object" ? firstArg : { features: args }; return browserSupportForFeaturesCommon("<", ...features).query; } function shouldIgnoreBrowser(browser, version) { return ( // The data for the QQ browser is severely lacking and unreliable browser === "and_qq" || // The data for the UC browser is severely lacking and unreliable browser === "and_uc" || // The data for the Baidu browser is severely lacking and unreliable browser === "baidu" || // The data for the KaiOS browser is severely lacking and unreliable browser === "kaios" || browser === "android" && (0, import_semver5.gt)(coerceToString(browser, version), coerceToString(browser, "4.4.4")) || browser === "op_mob" && (0, import_semver5.gt)(coerceToString(browser, version), coerceToString(browser, "12.1")) ); } function getCaniuseLiteFeatureNormalized(stats, featureName) { const featureCorrectionMatch = FEATURE_TO_BROWSER_DATA_CORRECTIONS_MAP.get(featureName); const keys = Object.keys(stats); keys.forEach((browser) => { const browserDict = stats[browser]; if (browserDict == null) return; Object.entries(browserDict).forEach(([version, support]) => { const versionMatch = version.match(NORMALIZE_BROWSER_VERSION_REGEXP); const normalizedVersion = versionMatch == null ? version : versionMatch[1] ?? version; let supportKind; if (support === "available" || support === "unavailable" || support === "partial_support" || support === "prefixed") { supportKind = support; } else if (support.startsWith("y")) { supportKind = "available"; } else if (support.startsWith("n")) { supportKind = "unavailable"; } else if (support.startsWith("a")) { supportKind = "partial_support"; } else { supportKind = "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; } function getCaniuseFeatureSupport(feature) { const packedFeature = import_caniuse_lite.features[feature]; if (packedFeature == null) { throw new TypeError(`The given feature: '${feature}' is unknown. It must be a valid Caniuse or MDN feature!`); } const rawStats = (0, import_caniuse_lite.feature)(packedFeature).stats; for (const browser of Object.keys(rawStats)) { const browserDict = rawStats[browser]; if (browserDict == null) continue; for (const version of Object.keys(browserDict)) { if (shouldIgnoreBrowser(browser, version)) { delete browserDict[version]; } } } return getCaniuseLiteFeatureNormalized(rawStats, feature); } function isCaniuseFeature(feature) { return import_caniuse_lite.features[feature] != null; } function isMdnFeature(feature) { return import_object_path.default.get(compatData, feature) != null; } 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!`); } } function normalizeFeature(feature) { if (feature in CANIUSE_TO_MDN_FEATURE_MAP) { return CANIUSE_TO_MDN_FEATURE_MAP[feature]; } return feature; } function getFeatureSupport(feature) { const normalizedFeature = normalizeFeature(feature); const cacheHit = featureToCaniuseStatsCache.get(normalizedFeature); if (cacheHit != null) return cacheHit; assertKnownFeature(normalizedFeature); const result = isMdnFeature(normalizedFeature) ? getMdnFeatureSupport(normalizedFeature) : getCaniuseFeatureSupport(normalizedFeature); featureToCaniuseStatsCache.set(normalizedFeature, result); return result; } function getMdnFeatureSupport(feature) { const match = import_object_path.default.get(compatData, feature); const supportMap = match.__compat.support; const formatBrowser = (mdnBrowser, caniuseBrowser) => { const versionMap = supportMap[mdnBrowser]; const versionAdded = versionMap == null ? false : Array.isArray(versionMap) ? ( // If there are multiple entries, take the one that hasn't been removed yet, if any (() => { const versionStillInBrowser = versionMap.find((element) => element.version_removed == null); return versionStillInBrowser?.version_added == null ? false : versionStillInBrowser.version_added; })() ) : versionMap.version_added; const dict = {}; const supportedSince = versionAdded === false ? null : versionAdded === true ? getOldestVersionOfBrowser(caniuseBrowser) : versionAdded; getSortedBrowserVersionsWithLeadingVersion(caniuseBrowser, typeof versionAdded === "string" ? versionAdded : void 0).forEach((version) => { if (supportedSince == null) { dict[version] = "unavailable"; } else { dict[version] = version === "TP" || version === "all" || (0, import_semver5.gte)(coerceToString(caniuseBrowser, version), coerceToString(caniuseBrowser, supportedSince)) ? "available" : "unavailable"; } }); return dict; }; const stats = { /* eslint-disable @typescript-eslint/naming-convention */ and_chr: formatBrowser("chrome_android", "and_chr"), chrome: formatBrowser("chrome", "chrome"), and_ff: formatBrowser("firefox_android", "and_ff"), android: formatBrowser("webview_android", "android"), bb: {}, and_qq: {}, and_uc: {}, kaios: {}, baidu: {}, 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") /* eslint-enable @typescript-eslint/naming-convention */ }; return getCaniuseLiteFeatureNormalized(stats, feature); } function getFirstVersionWithSupportKind(kind, stats) { const sortedKeys = Object.keys(stats).sort(compareVersions); for (const key of sortedKeys) { if (stats[key] === kind) { return key; } } return void 0; } function sortBrowserslist(a, b) { if (a.startsWith("not") && !b.startsWith("not")) return 1; if (!a.startsWith("not") && b.startsWith("not")) return -1; return 0; } function getFirstVersionsWithFullSupport(feature) { const normalizedFeature = normalizeFeature(feature); const support = getFeatureSupport(normalizedFeature); const browserMap = /* @__PURE__ */ new Map(); const entries = Object.entries(support); entries.forEach(([browser, stats]) => { const fullSupportVersion = getFirstVersionWithSupportKind("available", stats); if (fullSupportVersion != null) { browserMap.set(browser, fullSupportVersion); } }); return browserMap; } function getBrowserSupportForFeaturesCacheKey(comparisonOperator, features) { return `${comparisonOperator}.${features.sort().join(",")}`; } function browserSupportForFeaturesCommon(comparisonOperator, ...features) { const normalizedFeatures = features.map(normalizeFeature); const cacheKey = getBrowserSupportForFeaturesCacheKey(comparisonOperator, normalizedFeatures); const cacheHit = browserSupportForFeaturesCache.get(cacheKey); if (cacheHit != null) { return cacheHit; } const browserMaps = []; for (const normalizedFeature of normalizedFeatures) { const support = getFeatureSupport(normalizedFeature); const browserMap = /* @__PURE__ */ new Map(); const entries = Object.entries(support); entries.forEach(([browser, stats]) => { const fullSupportVersion = getFirstVersionWithSupportKind("available", stats); const partialSupportVersion = getFirstVersionWithSupportKind("partial_support", stats); let versionToSet; if (fullSupportVersion != null) { versionToSet = fullSupportVersion; } if (partialSupportVersion != null) { const partialSupportMatch = PARTIAL_SUPPORT_ALLOWANCES.get(normalizedFeature); 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 = /* @__PURE__ */ 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 = [].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; } 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(void 0, browser.version); if (semver != null && (0, import_semver5.lte)(semver, "5.0.0")) { return { browser: "firefox", version: "2" }; } else if (semver != null && (0, import_semver5.lte)(semver, "24.0.0")) { return { browser: "firefox", version: browser.version }; } else if (semver != null && (0, import_semver5.lt)(semver, "27.0.0")) { return { browser: "firefox", version: "24.0.0" }; } else if (semver != null && (0, import_semver5.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(void 0, browser.version); if (semver != null && (semver.major === 8 || semver.major === 9)) { return { browser: "chrome", version: "53" }; } } switch (browser.name) { case "Samsung Browser": case "Samsung Internet": 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(void 0, os.version); if (browserSemver != null && osSemver != null && (0, import_semver5.lte)(osSemver, "4.4.4") && (0, import_semver5.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 != null && 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(void 0, engine.version); if (semver != null && (0, import_semver5.lt)(semver, "412.0.0")) { return { browser: "safari", version: "1.0" }; } if (semver != null && (0, import_semver5.lt)(semver, "522.0.0")) { return { browser: "safari", version: "2.0" }; } if (semver != null && (0, import_semver5.lt)(semver, "526.0.0")) { return { browser: "safari", version: "3.0" }; } if (semver != null && (0, import_semver5.lt)(semver, "533.0.0")) { return { browser: "safari", version: "4.0" }; } if (semver != null && (0, import_semver5.lt)(semver, "536.0.0")) { return { browser: "safari", version: "5.0" }; } if (semver != null && (0, import_semver5.lt)(semver, "537.71.0")) { return { browser: "safari", version: "6.0" }; } if (semver != null && (0, import_semver5.lt)(semver, "600.0.0")) { return { browser: "safari", version: "7.0" }; } if (semver != null && (0, import_semver5.lt)(semver, "601.0.0")) { return { browser: "safari", version: "8.0" }; } if (semver != null && (0, import_semver5.lt)(semver, "602.0.0")) { return { browser: "safari", version: "9.0" }; } if (semver != null && (0, import_semver5.lt)(semver, "604.0.0")) { return { browser: "safari", version: "10.0" }; } if (semver != null && (0, import_semver5.lt)(semver, "606.0.0")) { return { browser: "safari", version: "11.0" }; } if (semver != null && (0, import_semver5.lt)(semver, "608.0.0")) { return { browser: "safari", version: "12.0" }; } if (semver != null && (0, import_semver5.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) { // If the Engine is Blink, it's Chrome 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 {}; } 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) => `${majorVersion}${minorVersion == null || minorVersion === 0 ? "" : `.${minorVersion}`}${patchVersion == null || patchVersion === 0 ? "" : `.${patchVersion}`}`; switch (browser) { case "chrome": if (useragentEngine.name === "Blink") { const semver = ensureSemver(browser, getClosestMatchingBrowserVersion(browser, useragentEngine.version ?? version)); return semver == null ? buildSemverVersion(major) : buildSemverVersion(semver.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(void 0, getClosestMatchingBrowserVersion(browser, useragentOs.version)); return osSemver == null ? buildSemverVersion(major) : 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": case "kaios": return buildSemverVersion(major, minor); default: return buildSemverVersion(major); } } 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(); const { 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}`); } const closestMatchingCaniuseBrowserVersionOrSmaller = normalizeBrowserVersion(caniuseBrowserName, caniuseBrowserVersion, void 0, true); const closestMatchingCaniuseBrowserVersion = normalizeBrowserVersion(caniuseBrowserName, caniuseBrowserVersion, void 0); const caniuseBrowser = { browser: caniuseBrowserName, version: closestMatchingCaniuseBrowserVersionOrSmaller }; const finalVersion = getCaniuseVersionForUseragentVersion(caniuseBrowser, browser, os, engine); const normalizedBrowserslist = normalizeBrowserslist([`${caniuseBrowserName} ${finalVersion}`]); const finalVersionCoerced = ensureSemver(caniuseBrowserName, finalVersion); const closestMatchingCaniuseBrowserVersionCoerced = ensureSemver(caniuseBrowserName, closestMatchingCaniuseBrowserVersion); if (finalVersionCoerced != null && closestMatchingCaniuseBrowserVersionCoerced != null && (0, import_semver5.lt)(finalVersionCoerced, closestMatchingCaniuseBrowserVersionCoerced, { loose: true }) && normalizedBrowserslist[0] === `${caniuseBrowserName} ${closestMatchingCaniuseBrowserVersion}`) { normalizedBrowserslist[0] = `${caniuseBrowserName} ${finalVersion}`; } userAgentToBrowserslistCache.set(useragent, normalizedBrowserslist); return normalizedBrowserslist; } function matchBrowserslistOnUserAgent(useragent, browserslist) { const useragentBrowserslist = generateBrowserslistFromUseragent(useragent); const normalizedInputBrowserslist = normalizeBrowserslist(browserslist); return useragentBrowserslist.every((option) => normalizedInputBrowserslist.includes(option)); } function userAgentWithFeaturesCacheKey(useragent, features) { return `${useragent}.${features.join(",")}`; } function userAgentSupportsFeatures(useragent, ...features) { const normalizedFeatures = features.map(normalizeFeature); const cacheKey = userAgentWithFeaturesCacheKey(useragent, normalizedFeatures); const cacheHit = userAgentWithFeaturesToSupportCache.get(cacheKey); if (cacheHit != null) return cacheHit; const useragentBrowserslist = generateBrowserslistFromUseragent(useragent); const supportedBrowserslist = normalizeBrowserslist(browsersWithSupportForFeatures(...normalizedFeatures)); const support = useragentBrowserslist.every((option) => supportedBrowserslist.includes(option)); userAgentWithFeaturesToSupportCache.set(cacheKey, support); return support; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { browsersWithSupportForEcmaVersion, browsersWithSupportForFeatures, browsersWithoutSupportForFeatures, browserslistSupportsEcmaVersion, browserslistSupportsFeatures, generateBrowserslistFromUseragent, getAppropriateEcmaVersionForBrowserslist, getFeaturesForEcmaVersion, getFirstVersionsWithFullSupport, matchBrowserslistOnUserAgent, normalizeBrowserslist, userAgentSupportsFeatures }); //# sourceMappingURL=index.cjs.map