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AmB,0CAAoD,EAAY,QAInJ,EAAa,SACX,EACA,EAAY,GAAG,SAAS,YACpB,QAAQ,EAAY,IACpB,EAAY,GAEpB,CACA,OAAO,EAAY,EAAY,EACjC,CAEA,OAAO,EAAgB,QAAQ,2BAA2B,CAAC,EAAK,IACnD,WAAP,EAAwB,EACrB,EAAQ,IAEnB,CAEA,OAAO,QAAU,UAA4B,MAAO,IAClD,MAAO,CACL,QAAS,CACP,kBAAmB,SAAU,EAAM,GACjC,MAAM,OAAE,EAAM,WAAE,GAAe,EAAK,KAC9B,EAAS,oBAAoB,EAAO,MAAO,EAAM,MACjD,EAAO,EAAM,KAAK,GAExB,IAAK,EAAM,OAEX,IAAK,EAAK,UAIR,YAHA,QAAQ,MACN,IAAI,0DAA0D,EAAO,SAKzE,MAAM,EACJ,qBAAqB,EAAO,MAAO,IAAI,OAAO,EAAQ,OAAS,GAEjE,IAAI,EAAa,GAEjB,MAAM,EAAiB,EAAW,QAC/B,GAAiC,oBAAnB,EAAU,OAErB,EAAgB,EAAW,QAC9B,GAAiC,oBAAnB,EAAU,OAGvB,EAAe,OAAS,GACtB,EAAc,OAAS,GACzB,EAAW,KACT,EAAE,kBAAkB,EAAgB,EAAE,cAAc,KAK1D,EAAc,SAAS,IACrB,MAAM,EAAa,EAAa,SAAS,KACnC,EAAgB,UAAU,EAAK,UAAW,EAAY,GAExD,GACF,EAAW,KACT,EAAE,kBACA,CAAC,GACD,EAAE,cAAc,IAGtB,IAGE,EAAW,OAAS,GACtB,EAAK,oBAAoB,EAE7B,GAGN","file":"/npm/@instructure/babel-plugin-transform-imports@10.26.4/lib/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@instructure/babel-plugin-transform-imports@10.26.4/lib/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 - present Instructure, Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nconst { dirname, relative } = require('path')\nconst globby = require('globby')\n\nconst transformName = 'babel-plugin-transform-imports'\n\nfunction getOptKeyFromSource(source, opts) {\n  if (opts[source]) {\n    return source\n  } else {\n    return Object.keys(opts).find((optKey) => new RegExp(optKey).test(source))\n  }\n}\n\nfunction getMatchesFromSource(source, regex) {\n  const matches = []\n  let match\n  let matcher = regex\n\n  matcher.lastIndex = 0\n  matcher = new RegExp(matcher.source, 'g')\n\n  while ((match = matcher.exec(source)) !== null) {\n    match.forEach((m) => {\n      matches.push(m)\n    })\n\n    if (matcher.lastIndex === match.index) {\n      matcher.lastIndex++\n    }\n  }\n  return matches\n}\n\nfunction transform(transformOption, importName, matches) {\n  const isFunction = typeof transformOption === 'function'\n  if (/\\.js$/i.test(transformOption) || isFunction) {\n    let transformFn\n    try {\n      transformFn = isFunction ? transformOption : require(transformOption)\n    } catch (error) {\n      throw {\n        err: `[${transformName}] failed to require transform file ${transformOption} ${error}`\n      }\n    }\n\n    if (typeof transformFn !== 'function') {\n      throw {\n        err: `[${transformName}] expected transform function to be exported from ${transformOption}`\n      }\n    }\n\n    let importPath = importName\n\n    // Sometimes the import is not located at root level of the src. Examine the source of the specified package and if the designated\n    // import is not at the root level, construct a relative path from the source root to it's location.\n    if (matches && matches[1]) {\n      const packageName = matches[1]\n      const sourceIndex = require.resolve(packageName)\n      const sourceRoot = dirname(sourceIndex)\n\n      const importPaths = globby.sync(\n        [\n          `${sourceRoot}/**/${importName}.js`,\n          `${sourceRoot}/**/${importName}/index.js`\n        ],\n        { cwd: sourceRoot }\n      )\n\n      if (!importPaths || importPaths.length === 0) {\n        // If there are no import paths found it is the same as if globby or the require.resolve failed, we cannot construct a relative import path\n        // so throw an error and just fall back to using the import name as the path.\n        console.error(\n          `[${transformName}] no modules match '${importName}' in '${packageName}'. Continuing with '${importName}' as the import path. If that is unexpected or incorrect, make sure '${importName}' exists in '${packageName}' and you have run 'npm install' to download the package source.`\n        )\n        return null\n      }\n\n      if (importPaths.length > 1) {\n        console.error(\n          `[${transformName}] multiple modules found with the name '${importName}' in '${packageName}'. Continuing using the first match: '${importPaths[0]}'.`\n        )\n      }\n\n      importPath = relative(\n        sourceRoot,\n        importPaths[0].endsWith('index.js')\n          ? dirname(importPaths[0])\n          : importPaths[0]\n      )\n    }\n    return transformFn(importPath, matches)\n  }\n\n  return transformOption.replace(/\\$\\{\\s?([\\w\\d]*)\\s?\\}/gi, (str, g1) => {\n    if (g1 === 'member') return importName\n    return matches[g1]\n  })\n}\n\nmodule.exports = function transformImports({ types: t }) {\n  return {\n    visitor: {\n      ImportDeclaration: function (path, state) {\n        const { source, specifiers } = path.node\n        const optKey = getOptKeyFromSource(source.value, state.opts)\n        const opts = state.opts[optKey]\n\n        if (!opts) return\n\n        if (!opts.transform) {\n          console.error(\n            `[${transformName}] transform option is required for module ${source.value}`\n          )\n          return\n        }\n\n        const matches =\n          getMatchesFromSource(source.value, new RegExp(optKey, 'g')) || []\n\n        let transforms = []\n\n        const defaultImports = specifiers.filter(\n          (specifier) => specifier.type !== 'ImportSpecifier'\n        )\n        const memberImports = specifiers.filter(\n          (specifier) => specifier.type === 'ImportSpecifier'\n        )\n\n        if (defaultImports.length > 0) {\n          if (memberImports.length > 0) {\n            transforms.push(\n              t.importDeclaration(defaultImports, t.stringLiteral(source))\n            )\n          }\n        }\n\n        memberImports.forEach((memberImport) => {\n          const importName = memberImport.imported.name\n          const newImportPath = transform(opts.transform, importName, matches)\n\n          if (newImportPath) {\n            transforms.push(\n              t.importDeclaration(\n                [memberImport],\n                t.stringLiteral(newImportPath)\n              )\n            )\n          }\n        })\n\n        if (transforms.length > 0) {\n          path.replaceWithMultiple(transforms)\n        }\n      }\n    }\n  }\n}\n"]}