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,KAAO,EAAI,QAAQ,KAAO,OAAO,QAAQ,sBAC7E,EAAY,IAAM,OAAO,QAAQ,wBAAwB,EAAI,QAAQ,WAAY,SAC3E,mBAAmB,EAAa,EACxC,CAEF,OAAO,CAAW,EAMpB,OAAO,QAAQ,4BAA8B,IACpC,CACL,YACA,OACA,MACA,MACA,SACA,aACA,aACA,YACA,WAOJ,OAAO,QAAQ,4BAA8B,KAC3C,MAAM,EAAgB,CACpB,OACA,kBACA,QAGF,IAAK,IAAI,EAAkB,EAAG,GAAmB,EAAG,IAClD,EAAc,KAAK,WAAW,KAGhC,OAAO,CAAa","file":"/npm/@pkgjs/support@0.0.6/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@pkgjs/support@0.0.6/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';\nconst path = require('path');\nconst fs = require('fs');\nconst normalizeUrl = require('normalize-url');\nconst Ajv = require('ajv');\nconst got = require('got');\nconst betterAjvErrors = require('better-ajv-errors');\nconst create = require('./lib/cli/create');\n\nlet ajv;\nlet compiledSchema;\nlet ajvElement;\nlet compiledSchemaElement;\n\nconst schema = module.exports.schema = require('./schema.json');\nconst supportElementSchema = module.exports.schema = require('./support-element-schema.json');\n\nmodule.exports.defaultPackageSupport = 'package-support.json';\nmodule.exports.create = create;\n\nfunction getBetterAjvErrorsOptions (cli) {\n  const options = { format: 'js' };\n  if (cli === true) {\n    options.format = 'cli';\n  }\n  return options;\n}\n\nmodule.exports.validateSupportElement = (obj, cli = false) => {\n  if (!ajvElement) {\n    ajvElement = new Ajv({ jsonPointers: true });\n    compiledSchemaElement = ajvElement.compile(supportElementSchema);\n  }\n\n  const validates = compiledSchemaElement(obj);\n  if (!validates) {\n    const err = new Error('Validation Failed');\n    err.validationErrors = compiledSchemaElement.errors;\n    err.prettyValidationErrors = betterAjvErrors(supportElementSchema, obj, compiledSchemaElement.errors, getBetterAjvErrorsOptions(cli));\n    err.validationSchema = compiledSchemaElement.schema;\n    throw err;\n  }\n  return true;\n};\n\nmodule.exports.validate = (obj, cli = false) => {\n  if (!ajv) {\n    ajv = new Ajv({ jsonPointers: true });\n    compiledSchema = ajv.compile(schema);\n  }\n\n  const validates = compiledSchema(obj);\n  if (!validates) {\n    const err = new Error('Validation Failed');\n    err.validationErrors = compiledSchema.errors;\n    err.prettyValidationErrors = betterAjvErrors(schema, obj, compiledSchema.errors, getBetterAjvErrorsOptions(cli));\n    err.validationSchema = compiledSchema.schema;\n    throw err;\n  }\n  return true;\n};\n\n// extract the URL for the support info from the pkg info\nmodule.exports.getRemoteSupportInfoUrl = (repository, supportPath) => {\n  const gitHubInitialPath = '/blob/HEAD/';\n\n  if (repository && (repository.type === 'git')) {\n    const directory = repository.directory || '';\n    let remoteURL = repository.url;\n    const trailerLocation = remoteURL.indexOf('.git');\n    if (trailerLocation >= 0) {\n      remoteURL = remoteURL.substring(0, trailerLocation) +\n                  gitHubInitialPath + '/' + directory +\n                  '/' + supportPath;\n    }\n    return normalizeUrl(remoteURL);\n  } else {\n    return 'unknown';\n  }\n};\n\n// the path should not try to escape the root as it\n// is specified to be a relative path\nmodule.exports.sanitizePath = (basePath, inputPath, basePathOverride) => {\n  const effectiveBasePath = path.normalize(basePathOverride || basePath);\n  const candidatePath = path.join(basePath, inputPath);\n  let ret = path.basename(inputPath);\n  if (candidatePath.indexOf(effectiveBasePath) === 0) {\n    // inputPath did not try to escape\n    ret = inputPath;\n  }\n  return ret;\n};\n\nasync function resolveSupportInfo (supportInfo, fetchCanonical) {\n  supportInfo.resolved = false;\n  if (fetchCanonical) {\n    const url = normalizeUrl(supportInfo.url\n      .replace('blob', '')\n      .replace('github.com', 'raw.githubusercontent.com'));\n    try {\n      const result = await got(url);\n      supportInfo.contents = result.body;\n      supportInfo.resolved = true;\n    } catch (e) {\n      supportInfo.error = e;\n    }\n  }\n}\n\nmodule.exports.getSupportData = async (pkg, pkgPath, preferCanonical, basePathOverride, fetchCanonical) => {\n  const supportInfo = { contents: 'unknown', url: '', resolved: true };\n  if (pkg.support) {\n    if ((pkg.support === true) || (typeof pkg.support === 'string')) {\n      const supportInfoName = (pkg.support === true)\n        ? module.exports.defaultPackageSupport : module.exports.sanitizePath(pkgPath, pkg.support, basePathOverride);\n      const localPath = path.join(pkgPath, supportInfoName);\n      if (!preferCanonical && fs.existsSync(localPath)) {\n        supportInfo.contents = fs.readFileSync(localPath);\n        supportInfo.resolved = true;\n      } else {\n        supportInfo.url = module.exports.getRemoteSupportInfoUrl(pkg.repository, supportInfoName);\n        await resolveSupportInfo(supportInfo, fetchCanonical);\n      }\n    } else if (typeof pkg.support === 'object') {\n      const supportInfoName = pkg.support.path ? pkg.support.path : module.exports.defaultPackageSupport;\n      supportInfo.url = module.exports.getRemoteSupportInfoUrl(pkg.support.repository, supportInfoName);\n      await resolveSupportInfo(supportInfo, fetchCanonical);\n    }\n  }\n  return supportInfo;\n};\n\n/**\n * Returns list of target Node.js versions for package-support.json file\n */\nmodule.exports.getNodeJsTargetVersionsList = () => {\n  return [\n    'abandoned',\n    'none',\n    'all',\n    'lts',\n    'active',\n    'lts_active',\n    'lts_latest',\n    'supported',\n    'current'\n  ];\n};\n\n/**\n * Returns list of response types for package-support.json file\n */\nmodule.exports.getSupportResponseTypesList = () => {\n  const schemaOptions = [\n    'none',\n    'time-permitting',\n    '24-7'\n  ];\n\n  for (let daysForResponse = 1; daysForResponse <= 7; daysForResponse++) {\n    schemaOptions.push(`regular-${daysForResponse}`);\n  }\n\n  return schemaOptions;\n};\n"]}