{"version":3,"sources":["jsdelivr-header.js","/npm/module-definition@6.0.1/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,aAEA,MAAM,GAAK,QAAQ,MACb,OAAS,QAAQ,oBACjB,MAAQ,QAAQ,oBAQtB,SAAS,WAAW,GAClB,QAAe,IAAX,EAAsB,MAAM,IAAI,MAAM,uBAE1C,MAAM,EAAS,IAAI,OACnB,IAAI,EAAO,OACP,GAAY,EACZ,GAAwB,EACxB,GAAa,EACb,GAAa,EACb,GAAe,EACf,GAAe,EA8BnB,OA1BA,EAAO,KAAK,GAAQ,IACd,MAAM,YAAY,KAAO,GAAY,GACrC,MAAM,UAAU,KAAO,GAAa,GACpC,MAAM,UAAU,KAAO,GAAa,GACpC,MAAM,yBAAyB,KAAO,GAAwB,GAC9D,MAAM,YAAY,KAAO,GAAe,GACxC,MAAM,YAAY,KAAO,GAAe,GAExC,GAAgB,GAClB,EAAO,WACP,EAAO,eAIL,GAAa,GACf,EAAO,WACP,EAAO,qBAIL,GAAe,IAAe,KAChC,EAAO,WACP,EAAO,mBAIJ,CACT,CASA,SAAS,KAAK,EAAU,EAAU,CAAC,GACjC,IAAK,EAAU,MAAM,IAAI,MAAM,oBAK/B,OAAO,YAHY,EAAQ,YAAc,IACjB,aAAa,EAAU,QAGjD,CASA,OAAO,QAAU,SAAS,EAAU,EAAU,EAAU,CAAC,GACvD,IAAK,EAAU,MAAM,IAAI,MAAM,oBAC/B,IAAK,EAAU,MAAM,IAAI,MAAM,qBAEZ,EAAQ,YAAc,IAG9B,SAAS,EAAU,QAAQ,CAAC,EAAO,KAC5C,GAAI,EAAO,OAAO,EAAS,GAE3B,IAAI,EAEJ,IACE,EAAO,WAAW,EACpB,CAAE,MAAO,GACP,OAAO,EAAS,EAClB,CAEA,EAAS,KAAM,EAAK,GAExB,EAEA,OAAO,QAAQ,KAAO,KACtB,OAAO,QAAQ,WAAa","file":"/npm/module-definition@6.0.1/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/module-definition@6.0.1/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 fs = require('fs');\nconst Walker = require('node-source-walk');\nconst types = require('ast-module-types');\n\n/**\n * Determines the type of the module from the supplied source code or AST\n *\n * @param  {String|Object} source - The string content or AST of a file\n * @return {String}\n */\nfunction fromSource(source) {\n  if (source === undefined) throw new Error('source not supplied');\n\n  const walker = new Walker();\n  let type = 'none';\n  let hasDefine = false;\n  let hasAMDTopLevelRequire = false;\n  let hasRequire = false;\n  let hasExports = false;\n  let hasES6Import = false;\n  let hasES6Export = false;\n  const hasDynamicImport = false;\n\n  // Walker accepts as AST to avoid reparsing\n  walker.walk(source, node => {\n    if (types.isDefineAMD(node)) hasDefine = true;\n    if (types.isRequire(node)) hasRequire = true;\n    if (types.isExports(node)) hasExports = true;\n    if (types.isAMDDriverScriptRequire(node)) hasAMDTopLevelRequire = true;\n    if (types.isES6Import(node)) hasES6Import = true;\n    if (types.isES6Export(node)) hasES6Export = true;\n\n    if (hasES6Import || hasES6Export || hasDynamicImport) {\n      type = 'es6';\n      walker.stopWalking();\n      return;\n    }\n\n    if (hasDefine || hasAMDTopLevelRequire) {\n      type = 'amd';\n      walker.stopWalking();\n      return;\n    }\n\n    if (hasExports || (hasRequire && !hasDefine)) {\n      type = 'commonjs';\n      walker.stopWalking();\n    }\n  });\n\n  return type;\n}\n\n/**\n * Synchronously determine the module type for the contents of the passed filepath\n *\n * @param  {String} filepath\n * @param  {Object} options\n * @return {String}\n */\nfunction sync(filepath, options = {}) {\n  if (!filepath) throw new Error('filename missing');\n\n  const fileSystem = options.fileSystem ?? fs;\n  const data = fileSystem.readFileSync(filepath, 'utf8');\n\n  return fromSource(data);\n}\n\n/**\n * Asynchronously determines the module type for the contents of the given filepath\n *\n * @param  {String}   filepath\n * @param  {Function} callback - Executed with (error, type)\n * @param  {Object}   options\n */\nmodule.exports = function(filepath, callback, options = {}) {\n  if (!filepath) throw new Error('filename missing');\n  if (!callback) throw new Error('callback missing');\n\n  const fileSystem = options.fileSystem ?? fs;\n\n  // eslint-disable-next-line n/prefer-promises/fs\n  fileSystem.readFile(filepath, 'utf8', (error, data) => {\n    if (error) return callback(error);\n\n    let type;\n\n    try {\n      type = fromSource(data);\n    } catch (error) {\n      return callback(error);\n    }\n\n    callback(null, type);\n  });\n};\n\nmodule.exports.sync = sync;\nmodule.exports.fromSource = fromSource;\n"]}