1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4  value: true
5});
6exports.createLegacyPlugin = createLegacyPlugin;
7function _configPlugins() {
8  const data = require("@expo/config-plugins");
9  _configPlugins = function () {
10    return data;
11  };
12  return data;
13}
14const toCamelCase = s => s.replace(/-./g, x => x.toUpperCase()[1]);
15function isModuleExcluded(config, packageName) {
16  var _config$_internal;
17  // Skip using the versioned plugin when autolinking is enabled
18  // and doesn't link the native module.
19  return ((_config$_internal = config._internal) === null || _config$_internal === void 0 ? void 0 : _config$_internal.autolinkedModules) && !config._internal.autolinkedModules.includes(packageName);
20}
21function createLegacyPlugin({
22  packageName,
23  fallback
24}) {
25  let withFallback;
26  if (Array.isArray(fallback)) {
27    withFallback = config => (0, _configPlugins().withPlugins)(config, fallback);
28  } else {
29    withFallback = fallback;
30  }
31  const withUnknown = config => {
32    // Skip using the versioned plugin when autolinking is enabled
33    // and doesn't link the native module.
34    if (isModuleExcluded(config, packageName)) {
35      return (0, _configPlugins().createRunOncePlugin)(withFallback, packageName)(config);
36    }
37    return (0, _configPlugins().withStaticPlugin)(config, {
38      _isLegacyPlugin: true,
39      plugin: packageName,
40      // If the static plugin isn't found, use the unversioned one.
41      fallback: (0, _configPlugins().createRunOncePlugin)(withFallback, packageName)
42    });
43  };
44  const methodName = toCamelCase(`with-${packageName}`);
45  Object.defineProperty(withUnknown, 'name', {
46    value: methodName
47  });
48  return withUnknown;
49}
50//# sourceMappingURL=createLegacyPlugin.js.map