{"version":3,"names":["_babelPluginPolyfillCorejs","require","_babelPluginPolyfillCorejs2","_babelPluginPolyfillRegenerator","pluginCorejs2","_pluginCorejs2","default","pluginCorejs3","_pluginCorejs3","pluginRegenerator","_pluginRegenerator","pluginsCompat","createCorejsPlugin","plugin","options","regeneratorPlugin","api","_","filename","Object","assign","inherits","createRegeneratorPlugin","useRuntimeRegenerator","undefined","createBasePolyfillsPlugin","corejs","regenerator","runtimeVersion","absoluteImports","proposals","rawVersion","version","Boolean","corejsVersion","Number","includes","Error","JSON","stringify","polyfillOpts","method","useBabelRuntime","ext"],"sources":["../src/polyfills.ts"],"sourcesContent":["// TODO(Babel 8): Remove at least support for babel-plugin-polyfill-regenerator,\n// which isn't needed anymore, and babel-plugin-polyfill-corejs2, since core-js\n// 2 isn't maintained anymore.\n// Consider also removing babel-plugin-polyfill-corejs3 from here, and ask users\n// to explicitly enable it in their Babel configuration files.\n\nimport type { PluginAPI, PluginObject } from \"@babel/core\";\nimport _pluginCorejs2 from \"babel-plugin-polyfill-corejs2\";\nimport _pluginCorejs3 from \"babel-plugin-polyfill-corejs3\";\nimport _pluginRegenerator from \"babel-plugin-polyfill-regenerator\";\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\nconst pluginCorejs2 = (_pluginCorejs2.default ||\n _pluginCorejs2) as typeof _pluginCorejs2.default;\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\nconst pluginCorejs3 = (_pluginCorejs3.default ||\n _pluginCorejs3) as typeof _pluginCorejs3.default;\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\nconst pluginRegenerator = (_pluginRegenerator.default ||\n _pluginRegenerator) as typeof _pluginRegenerator.default;\n\nimport type { Options } from \"./index.ts\";\n\nconst pluginsCompat = \"#__secret_key__@babel/runtime__compatibility\";\n\ninterface CoreJS2PluginOptions {\n absoluteImports: boolean;\n method: \"usage-pure\";\n [pluginsCompat]: {\n runtimeVersion: string;\n useBabelRuntime: boolean;\n ext: string;\n };\n}\n\ninterface RegeneratorPluginOptions {\n absoluteImports: boolean;\n method: \"usage-pure\";\n [pluginsCompat]: {\n useBabelRuntime: boolean;\n };\n}\n\ninterface CoreJS3PluginOptions {\n absoluteImports: boolean;\n method: \"usage-pure\";\n proposals: boolean;\n version: number;\n [pluginsCompat]: {\n useBabelRuntime: boolean;\n ext: string;\n };\n}\n\nfunction createCorejsPlugin(\n plugin: (api: PluginAPI, options: Options, filename: string) => PluginObject,\n options: Options,\n regeneratorPlugin: (\n api: PluginAPI,\n options: RegeneratorPluginOptions,\n filename: string,\n ) => PluginObject,\n): (api: PluginAPI, options: {}, filename: string) => PluginObject {\n return (api: PluginAPI, _: {}, filename: string) => {\n return {\n ...plugin(api, options, filename),\n inherits: regeneratorPlugin,\n };\n };\n}\n\nfunction createRegeneratorPlugin(\n options: RegeneratorPluginOptions,\n useRuntimeRegenerator: boolean,\n): (\n api: PluginAPI,\n options: RegeneratorPluginOptions,\n filename: string,\n) => PluginObject {\n if (!useRuntimeRegenerator) return undefined;\n return (api, _, filename) => {\n return pluginRegenerator(api, options, filename);\n };\n}\n\nexport function createBasePolyfillsPlugin(\n { corejs, regenerator: useRuntimeRegenerator = true }: Options,\n runtimeVersion: string,\n absoluteImports: boolean,\n) {\n let proposals = false;\n let rawVersion;\n\n if (typeof corejs === \"object\" && corejs !== null) {\n rawVersion = corejs.version;\n proposals = Boolean(corejs.proposals);\n } else {\n rawVersion = corejs;\n }\n\n const corejsVersion = rawVersion ? Number(rawVersion) : false;\n\n if (![false, 2, 3].includes(corejsVersion)) {\n throw new Error(\n `The \\`core-js\\` version must be false, 2 or 3, but got ${JSON.stringify(\n rawVersion,\n )}.`,\n );\n }\n\n if (proposals && (!corejsVersion || corejsVersion < 3)) {\n throw new Error(\n \"The 'proposals' option is only supported when using 'corejs: 3'\",\n );\n }\n\n if (typeof useRuntimeRegenerator !== \"boolean\") {\n throw new Error(\n \"The 'regenerator' option must be undefined, or a boolean.\",\n );\n }\n\n const polyfillOpts = {\n method: \"usage-pure\",\n absoluteImports,\n [pluginsCompat]: { useBabelRuntime: true, runtimeVersion, ext: \"\" },\n } as const;\n\n return corejsVersion === 2\n ? createCorejsPlugin(\n pluginCorejs2,\n polyfillOpts,\n createRegeneratorPlugin(polyfillOpts, useRuntimeRegenerator),\n )\n : corejsVersion === 3\n ? createCorejsPlugin(\n pluginCorejs3,\n { version: 3, proposals, ...polyfillOpts },\n createRegeneratorPlugin(polyfillOpts, useRuntimeRegenerator),\n )\n : createRegeneratorPlugin(polyfillOpts, useRuntimeRegenerator);\n}\n"],"mappings":";;;;;;AAOA,IAAAA,0BAAA,GAAAC,OAAA;AACA,IAAAC,2BAAA,GAAAD,OAAA;AACA,IAAAE,+BAAA,GAAAF,OAAA;AAEA,MAAMG,aAAa,GAAIC,0BAAc,CAACC,OAAO,IAC3CD,0BAAgD;AAElD,MAAME,aAAa,GAAIC,2BAAc,CAACF,OAAO,IAC3CE,2BAAgD;AAElD,MAAMC,iBAAiB,GAAIC,+BAAkB,CAACJ,OAAO,IACnDI,+BAAwD;AAI1D,MAAMC,aAAa,GAAG,8CAA8C;AA+BpE,SAASC,kBAAkBA,CACzBC,MAA4E,EAC5EC,OAAgB,EAChBC,iBAIiB,EACgD;EACjE,OAAO,CAACC,GAAc,EAAEC,CAAK,EAAEC,QAAgB,KAAK;IAClD,OAAAC,MAAA,CAAAC,MAAA,KACKP,MAAM,CAACG,GAAG,EAAEF,OAAO,EAAEI,QAAQ,CAAC;MACjCG,QAAQ,EAAEN;IAAiB;EAE/B,CAAC;AACH;AAEA,SAASO,uBAAuBA,CAC9BR,OAAiC,EACjCS,qBAA8B,EAKd;EAChB,IAAI,CAACA,qBAAqB,EAAE,OAAOC,SAAS;EAC5C,OAAO,CAACR,GAAG,EAAEC,CAAC,EAAEC,QAAQ,KAAK;IAC3B,OAAOT,iBAAiB,CAACO,GAAG,EAAEF,OAAO,EAAEI,QAAQ,CAAC;EAClD,CAAC;AACH;AAEO,SAASO,yBAA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