{"version":3,"sources":["jsdelivr-header.js","/npm/git-base-hash@0.3.0/lib/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,MAAM,WAAE,YAAe,QAAQ,sBAE/B,OAAO,QAAQ,eAAiB,CAAC,EAAK,KACpC,MAAM,EAAS,WAAW,eAAe,GACnC,EAAO,IAAI,WAAW,GAE5B,IAAI,EACJ,GAAI,EACF,EAAe,EAAK,uBAAuB,OACtC,CACL,MAAM,EAAO,EAAK,eAClB,GAAkB,WAAd,EAAK,KAAmB,MAAM,IAAI,MAAM,gCAC5C,EAAa,EAAK,OAAO,KACzB,EAAe,EAAK,OAAO,MAC7B,CAEA,MAAM,EAAU,EACb,mBACA,QAAO,GAAK,EAAE,OAAS,IACvB,KAAI,GAAK,EAAE,SAER,EAAW,CAAC,EAClB,EAAQ,SAAQ,GAAK,EAAS,EAAE,OAAQ,IAYxC,EAAQ,SAVR,SAAS,EAAY,GACnB,EAAS,EAAO,OAAQ,EACpB,EAAO,YACT,EAAO,aAAa,QAAO,IAAS,EAAS,KAAO,SAAQ,IAC1D,IACE,EAAY,EAAO,SAAS,GAC9B,CAAE,MAAO,GAAO,IAGtB,IAGA,IAAI,EAAW,GACX,EAAS,EAEb,OAAa,CACX,GAAI,EAAS,EAAO,MAAO,CACzB,EAAW,EAAO,KAClB,KACF,CACA,GAAI,EAAO,cAAe,CACxB,EAAW,EAAO,mBAAmB,GACrC,KACF,CACA,IAAK,EAAO,WACV,MAEF,EAAS,EAAO,UAClB,CAEA,OAAO,CAAQ","file":"/npm/git-base-hash@0.3.0/lib/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/git-base-hash@0.3.0/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","const { Repository } = require('tiny-commit-walker');\n\nmodule.exports.detectBaseHash = (dir, branchName) => {\n  const gitDir = Repository.findGitDirSync(dir);\n  const repo = new Repository(gitDir);\n\n  let targetCommit;\n  if (branchName) {\n    targetCommit = repo.readCommitByBranchSync(branchName);\n  } else {\n    const head = repo.readHeadSync();\n    if (head.type === 'commit') throw new Error('HEAD is not a ref to branch.');\n    branchName = head.branch.name;\n    targetCommit = head.branch.commit;\n  }\n\n  const commits = repo\n    .readBranchesSync()\n    .filter(b => b.name !== branchName)\n    .map(b => b.commit);\n\n  const hashDict = {};\n  commits.forEach(c => hashDict[c.hash] = true);\n\n  function setupHashes(commit) {\n    hashDict[commit.hash] = true;\n    if (commit.hasParents) {\n      commit.parentHashes.filter(hash => !hashDict[hash]).forEach(hash => {\n        try {\n          setupHashes(commit.walkSync(hash));\n        } catch (err) { }\n      });\n    }\n  }\n  commits.forEach(setupHashes);\n\n  let baseHash = \"\";\n  let commit = targetCommit;\n\n  while (true) {\n    if (hashDict[commit.hash]) {\n      baseHash = commit.hash;\n      break;\n    }\n    if (commit.isMergeCommit) {\n      baseHash = commit.mergedParentHashes[0];\n      break;\n    }\n    if (!commit.hasParents) {\n      break;\n    }\n    commit = commit.walkSync();\n  }\n\n  return baseHash;\n};"]}