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,CAAU,GACN,MAAM,EAAM,EAAM,IAAI,GACtB,OAAI,EACO,CACH,GAAI,EACJ,UAAU,GAGX,IACX,EAER","file":"/npm/rollup-plugin-import-map@3.0.0/lib/plugin.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/rollup-plugin-import-map@3.0.0/lib/plugin.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import path from 'path';\nimport fs from 'fs';\n\nconst isBare = (str) => {\n    if (str.startsWith('/') || str.startsWith('./') || str.startsWith('../') || str.substr(0, 7) === 'http://' || str.substr(0, 8) === 'https://') {\n        return false;\n    }\n    return true;\n};\n\nconst isString = (str) => typeof str === 'string';\n\nconst validate = (map, options) => Object.keys(map.imports).map((key) => {\n    const value = map.imports[key];\n\n    if (isBare(value)) {\n        throw Error(`Import specifier can NOT be mapped to a bare import statement. Import specifier \"${key}\" is being wrongly mapped to \"${value}\"`);\n    }\n\n    if (typeof options.external === 'function') {\n        if (options.external(key)) throw Error('Import specifier must NOT be present in the Rollup external config. Please remove specifier from the Rollup external config.');\n    }\n\n    if (Array.isArray(options.external)) {\n        if (options.external.includes(key)) throw Error('Import specifier must NOT be present in the Rollup external config. Please remove specifier from the Rollup external config.');\n    }\n\n    return { key, value };\n});\n\nconst fileReader = (pathname = '', options = {}) => new Promise((resolve, reject) => {\n    const filepath = path.normalize(pathname);\n    fs.promises.readFile(filepath).then((file) => {\n        try {\n            const obj = JSON.parse(file);\n            resolve(validate(obj, options));\n        } catch (error) {\n            reject(error);\n        }\n    }).catch(reject);\n});\n\nexport function rollupImportMapPlugin(importMaps = []) {\n    const cache = new Map();\n    const maps = Array.isArray(importMaps) ? importMaps : [importMaps];\n\n    return {\n        name: 'rollup-plugin-import-map',\n\n        async buildStart(options) {\n            const mappings = maps.map((item) => {\n                if (isString(item)) {\n                    return fileReader(item, options);\n                }\n                return validate(item, options);\n            });\n\n            await Promise.all(mappings).then((items) => {\n                items.forEach((item) => {\n                    item.forEach((obj) => {\n                        cache.set(obj.key, obj.value);\n                    });\n                });\n            });\n        },\n\n        resolveId(importee) {\n            const url = cache.get(importee);\n            if (url) {\n                return {\n                    id: url,\n                    external: true,\n                };\n            }\n            return null;\n        },\n    };\n}\n"]}