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AAQ,IAAK,EAAM,GAAK,QAAQ,IAAK,EAAI,GAExE,CAEO,SAAS,UAAU,EAAc,GACtC,OAAO,yBAAA,EAAwB,sBAAA,WAAG,wBAAwB,GAAO,GACnE,CAEO,SAAS,SAAS,EAAc,GACrC,SAAO,sBAAA,UAAK,wBAAwB,GAAO,wBAAwB,GACrE,CAGA,IAAO,qBAAQ,CACb,gDACA,gDACA,kBACA,oBACA","file":"/npm/@tonaljs/abc-notation@4.9.1/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@tonaljs/abc-notation@4.9.1/dist/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","import { distance as dist, transpose as tr } from \"@tonaljs/pitch-distance\";\nimport { note } from \"@tonaljs/pitch-note\";\n\nconst fillStr = (character: string, times: number) =>\n  Array(times + 1).join(character);\n\nconst REGEX = /^(_{1,}|=|\\^{1,}|)([abcdefgABCDEFG])([,']*)$/;\n\ntype AbcTokens = [string, string, string];\n\nexport function tokenize(str: string): AbcTokens {\n  const m = REGEX.exec(str);\n  if (!m) {\n    return [\"\", \"\", \"\"];\n  }\n  return [m[1], m[2], m[3]];\n}\n\n/**\n * Convert a (string) note in ABC notation into a (string) note in scientific notation\n *\n * @example\n * abcToScientificNotation(\"c\") // => \"C5\"\n */\nexport function abcToScientificNotation(str: string): string {\n  const [acc, letter, oct] = tokenize(str);\n  if (letter === \"\") {\n    return \"\";\n  }\n  let o = 4;\n  for (let i = 0; i < oct.length; i++) {\n    o += oct.charAt(i) === \",\" ? -1 : 1;\n  }\n  const a =\n    acc[0] === \"_\"\n      ? acc.replace(/_/g, \"b\")\n      : acc[0] === \"^\"\n        ? acc.replace(/\\^/g, \"#\")\n        : \"\";\n  return letter.charCodeAt(0) > 96\n    ? letter.toUpperCase() + a + (o + 1)\n    : letter + a + o;\n}\n\n/**\n * Convert a (string) note in scientific notation into a (string) note in ABC notation\n *\n * @example\n * scientificToAbcNotation(\"C#4\") // => \"^C\"\n */\nexport function scientificToAbcNotation(str: string): string {\n  const n = note(str);\n  if (n.empty || (!n.oct && n.oct !== 0)) {\n    return \"\";\n  }\n  const { letter, acc, oct } = n;\n  const a = acc[0] === \"b\" ? acc.replace(/b/g, \"_\") : acc.replace(/#/g, \"^\");\n  const l = oct > 4 ? letter.toLowerCase() : letter;\n  const o =\n    oct === 5 ? \"\" : oct > 4 ? fillStr(\"'\", oct - 5) : fillStr(\",\", 4 - oct);\n  return a + l + o;\n}\n\nexport function transpose(note: string, interval: string): string {\n  return scientificToAbcNotation(tr(abcToScientificNotation(note), interval));\n}\n\nexport function distance(from: string, to: string): string {\n  return dist(abcToScientificNotation(from), abcToScientificNotation(to));\n}\n\n/** @deprecated */\nexport default {\n  abcToScientificNotation,\n  scientificToAbcNotation,\n  tokenize,\n  transpose,\n  distance,\n};\n"]}