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Aa,cAAc,GAG5C,EAAM,OAAS,IACjB,EAAO,EAAM,OAEf,EAAO,EAAM,MACT,EAAM,OAAS,IACjB,EAAY,EAAM,KAAK,MAGzB,IAAI,EAAgB,CAAC,EAAc,GAC/B,GACF,EAAc,KAAK,GAErB,EAAc,KAAK,GAEnB,IAAI,EAAY,EAAO,KAAO,EAAc,KAAK,KAIjD,OAFA,QAAQ,IAAI,aAAc,GAEnB,CACT,CAwBkB,CAAoB,EAAc,EAAc,GAC5D,EAAmB,MAAQ,EAC3B,EAAY,KAAO,EAAO,QAAQ,MAAO,MAAM,QAAQ,KAAM,KAAO,KACpE,EAAe,uBAAyB,EAAY,YAAc,EAAmB,KACzF,EAAc,KAAK,GACnB,EAAY,KAAK,IAAM,EAAY,MAAQ,EAC7C,IACA,IAAI,EAAW,KAAK,KAAK,KAAK,WAAY,UACrC,GAAG,WAAW,IACjB,GAAG,UAAU,GAGf,IAAI,EAAW,EAAc,KAAK,MAAnB,iCACoB,EAAY,KAAK,KADrC,OAGf,GAAG,cAAc,KAAK,KAAK,KAAK,WAAY,SAAU,iBAAkB,EAAU,CAAE,SAAU,QAChG,EAEA,OAAO,QAAU","file":"/npm/@glimmer/resolution-map-builder@0.1.0/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@glimmer/resolution-map-builder@0.1.0/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","\"use strict\";\n\nconst Plugin = require('broccoli-plugin');\nconst fs = require('fs');\nconst path = require('path');\nconst walkSync = require('walk-sync');\nconst getModuleConfig = require('./lib/get-module-config');\n\nfunction ResolutionMapBuilder(src, config, options) {\n  options = options || {};\n  Plugin.call(this, [src, config], {\n    annotation: options.annotation\n  });\n  this.options = options;\n}\n\nResolutionMapBuilder.prototype = Object.create(Plugin.prototype);\n\nResolutionMapBuilder.prototype.constructor = ResolutionMapBuilder;\n\nResolutionMapBuilder.prototype.build = function() {\n  function specifierFromModule(modulePrefix, moduleConfig, modulePath) {\n    let path;\n    let collectionPath;\n\n    for (let i = 0, l = moduleConfig.collectionPaths.length; i < l; i++) {\n      path = moduleConfig.collectionPaths[i];\n      if (modulePath.indexOf(path) === 0) {\n        collectionPath = path;\n        break;\n      }\n    }\n\n    if (collectionPath) {\n      // trim group/collection from module path\n      modulePath = modulePath.substr(collectionPath.length);\n    } else {\n      collectionPath = 'main';\n    }\n    let parts = modulePath.split('/');\n\n    let collectionName = moduleConfig.collectionMap[collectionPath];\n\n    let name, type, namespace;\n    if (parts.length > 1) {\n      type = parts.pop();\n    }\n    name = parts.pop();\n    if (parts.length > 0) {\n      namespace = parts.join('/');\n    }\n\n    let specifierPath = [modulePrefix, collectionName];\n    if (namespace) {\n      specifierPath.push(namespace);\n    }\n    specifierPath.push(name);\n\n    let specifier = type + ':/' + specifierPath.join('/');\n\n    console.log('specifier:', specifier);\n\n    return specifier;\n  }\n\n  let configPath = path.join(this.inputPaths[1], this.options.configPath);\n  let configContents = fs.readFileSync(configPath, { encoding: 'utf8' });\n  let config = JSON.parse(configContents);\n\n  let modulePrefix = config.modulePrefix;\n  let moduleConfig = getModuleConfig(config);\n  let paths = walkSync(this.inputPaths[0]);\n  let modules = [];\n  let moduleImports = [];\n  let mapContents = [];\n\n  paths.forEach(function(entry) {\n    if (entry.indexOf('.') > -1) {\n      let module = entry.substring(0, entry.lastIndexOf('.'));\n\n      // filter out index module\n      if (module !== 'index' && module !== 'main') {\n        modules.push(module);\n      }\n    }\n  });\n  modules.forEach(function(module) {\n    let specifier = specifierFromModule(modulePrefix, moduleConfig, module);\n    let moduleImportPath = '../' + module;\n    let moduleVar = '__' + module.replace(/\\//g, '__').replace(/-/g, '_') + '__';\n    let moduleImport = \"import { default as \" + moduleVar + \" } from '\" + moduleImportPath + \"';\";\n    moduleImports.push(moduleImport);\n    mapContents.push(\"'\" + specifier + \"': \" + moduleVar);\n  });\n  let destPath = path.join(this.outputPath, 'config');\n  if (!fs.existsSync(destPath)) {\n    fs.mkdirSync(destPath);\n  }\n\n  let contents = moduleImports.join('\\n') + '\\n' +\n    \"export default moduleMap = {\" + mapContents.join(',') + \"};\" + '\\n';\n\n  fs.writeFileSync(path.join(this.outputPath, 'config', 'module-map.js'), contents, { encoding: 'utf8' });\n};\n\nmodule.exports = ResolutionMapBuilder;\n"]}