// raw-loader!escape-loader
import babelStandaloneJs from 'raw-loader!../lib/escape-loader!@babel/standalone/babel.min';
import babelEnvStandaloneJs from 'raw-loader!@babel/preset-env-standalone/babel-preset-env.min.js';
var config = {
  presets: [['@babel/preset-env', {
    targets: {
      ie: 11
    },
    useBuiltIns: false
  }]],
  plugins: [['@babel/plugin-transform-runtime', {
    corejs: false,
    helpers: true,
    regenerator: true,
    useESModules: false
  }]]
};
var code = "\nfor (var key in Babel.availablePlugins) {\n  if (Babel.availablePlugins.hasOwnProperty(key)) {\n    Babel.availablePlugins['@babel/plugin-' + key] = Babel.availablePlugins[key];\n  }\n}\nfor (var key in Babel.availablePresets) {\n  if (Babel.availablePresets.hasOwnProperty(key)) {\n    Babel.availablePresets['@babel/preset-' + key] = Babel.availablePresets[key];\n  }\n}\nself.addEventListener(\"message\", function (event) {\n  try {\n    // Transpile the code\n    var options = Object.assign({}, event.data.options, ".concat(JSON.stringify(config), ");\n    var result = Babel.transform(event.data.code, options);\n    // Send result\n    self.postMessage({\n      id: event.data.id,\n      code: result ? result.code : event.data.code // match babelignore\n    });\n  } catch (error) {\n    // Throw babel error with processing\n    self.postMessage({\n      id: event.data.id,\n      error: {\n        code: error.code + '',\n        message: error.message + '',\n        stack: error.stack + '',\n        loc: error.loc && {\n          line: error.loc.line,\n          column: error.loc.column\n        },\n        missingPlugin: error.missingPlugin\n      }\n    });\n    // Show useful error info into console\n    console.warn(error);\n  }\n});\n");
export var getUrl = function getUrl() {
  return URL.createObjectURL(new Blob([babelStandaloneJs, babelEnvStandaloneJs, code], {
    type: 'text/javascript'
  }));
};
var url;
export default function BabelWorker() {
  url = url || getUrl();
  return new Worker(url);
}