UNPKG

axentax-compiler

Version:

Compile Axentax syntax in JavaScript and generate MIDI output for guitar phrasing.

973 lines 263 kB
var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); function e(e3) { var t2, n2, i2, r2 = e3.length - 1, o2 = "", s2 = e3[0]; if (r2 > 0) { for (o2 += s2, t2 = 1; r2 > t2; t2++) (n2 = Mn - (i2 = e3[t2] + "").length) && (o2 += f(n2)), o2 += i2; (n2 = Mn - (i2 = (s2 = e3[t2]) + "").length) && (o2 += f(n2)); } else if (0 === s2) return "0"; for (; s2 % 10 == 0; ) s2 /= 10; return o2 + s2; } function t(e3, t2, n2) { if (e3 !== ~~e3 || t2 > e3 || e3 > n2) throw Error(an + e3); } function n(e3, t2, n2, i2) { var r2, o2, s2, c2; for (o2 = e3[0]; o2 >= 10; o2 /= 10) --t2; return 0 > --t2 ? (t2 += Mn, r2 = 0) : (r2 = Math.ceil((t2 + 1) / Mn), t2 %= Mn), o2 = mn(10, Mn - t2), c2 = e3[r2] % o2 | 0, null == i2 ? 3 > t2 ? (0 == t2 ? c2 = c2 / 100 | 0 : 1 == t2 && (c2 = c2 / 10 | 0), s2 = 4 > n2 && 99999 == c2 || n2 > 3 && 49999 == c2 || 5e4 == c2 || 0 == c2) : s2 = (4 > n2 && c2 + 1 == o2 || n2 > 3 && c2 + 1 == o2 / 2) && (e3[r2 + 1] / o2 / 100 | 0) == mn(10, t2 - 2) - 1 || (c2 == o2 / 2 || 0 == c2) && !(e3[r2 + 1] / o2 / 100 | 0) : 4 > t2 ? (0 == t2 ? c2 = c2 / 1e3 | 0 : 1 == t2 ? c2 = c2 / 100 | 0 : 2 == t2 && (c2 = c2 / 10 | 0), s2 = (i2 || 4 > n2) && 9999 == c2 || !i2 && n2 > 3 && 4999 == c2) : s2 = ((i2 || 4 > n2) && c2 + 1 == o2 || !i2 && n2 > 3 && c2 + 1 == o2 / 2) && (e3[r2 + 1] / o2 / 1e3 | 0) == mn(10, t2 - 3) - 1, s2; } function i(e3, t2, n2) { for (var i2, r2, o2 = [0], s2 = 0, c2 = e3.length; c2 > s2; ) { for (r2 = o2.length; r2--; ) o2[r2] *= t2; for (o2[0] += Zt.indexOf(e3.charAt(s2++)), i2 = 0; o2.length > i2; i2++) o2[i2] > n2 - 1 && (void 0 === o2[i2 + 1] && (o2[i2 + 1] = 0), o2[i2 + 1] += o2[i2] / n2 | 0, o2[i2] %= n2); } return o2.reverse(); } function r(e3, t2, n2, i2) { var r2, o2, s2, c2, a2, u2, f2, l2, d2, m2 = e3.constructor; e: if (null != t2) { if (!(l2 = e3.d)) return e3; for (r2 = 1, c2 = l2[0]; c2 >= 10; c2 /= 10) r2++; if (0 > (o2 = t2 - r2)) o2 += Mn, a2 = (f2 = l2[d2 = 0]) / mn(10, r2 - (s2 = t2) - 1) % 10 | 0; else if ((c2 = l2.length) > (d2 = Math.ceil((o2 + 1) / Mn))) { for (f2 = c2 = l2[d2], r2 = 1; c2 >= 10; c2 /= 10) r2++; a2 = 0 > (s2 = (o2 %= Mn) - Mn + r2) ? 0 : f2 / mn(10, r2 - s2 - 1) % 10 | 0; } else { if (!i2) break e; for (; c2++ <= d2; ) l2.push(0); f2 = a2 = 0, r2 = 1, s2 = (o2 %= Mn) - Mn + 1; } if (i2 = i2 || 0 > t2 || void 0 !== l2[d2 + 1] || (0 > s2 ? f2 : f2 % mn(10, r2 - s2 - 1)), u2 = 4 > n2 ? (a2 || i2) && (0 == n2 || n2 == (0 > e3.s ? 3 : 2)) : a2 > 5 || 5 == a2 && (4 == n2 || i2 || 6 == n2 && (o2 > 0 ? s2 > 0 ? f2 / mn(10, r2 - s2) : 0 : l2[d2 - 1]) % 10 & 1 || n2 == (0 > e3.s ? 8 : 7)), 1 > t2 || !l2[0]) return l2.length = 0, u2 ? (l2[0] = mn(10, (Mn - (t2 -= e3.e + 1) % Mn) % Mn), e3.e = -t2 || 0) : l2[0] = e3.e = 0, e3; if (0 == o2 ? (l2.length = d2, c2 = 1, d2--) : (l2.length = d2 + 1, c2 = mn(10, Mn - o2), l2[d2] = s2 > 0 ? (f2 / mn(10, r2 - s2) % mn(10, s2) | 0) * c2 : 0), u2) for (; ; ) { if (0 == d2) { for (o2 = 1, s2 = l2[0]; s2 >= 10; s2 /= 10) o2++; for (s2 = l2[0] += c2, c2 = 1; s2 >= 10; s2 /= 10) c2++; o2 != c2 && (e3.e++, l2[0] == yn && (l2[0] = 1)); break; } if (l2[d2] += c2, l2[d2] != yn) break; l2[d2--] = 0, c2 = 1; } for (o2 = l2.length; 0 === l2[--o2]; ) l2.pop(); } return sn && (e3.e > m2.maxE ? (e3.d = null, e3.e = NaN) : m2.minE > e3.e && (e3.e = 0, e3.d = [0])), e3; } function o(t2, n2, i2) { if (!t2.isFinite()) return b(t2); var r2, o2 = t2.e, s2 = e(t2.d), c2 = s2.length; return n2 ? (i2 && (r2 = i2 - c2) > 0 ? s2 = s2.charAt(0) + "." + s2.slice(1) + f(r2) : c2 > 1 && (s2 = s2.charAt(0) + "." + s2.slice(1)), s2 = s2 + (0 > t2.e ? "e" : "e+") + t2.e) : 0 > o2 ? (s2 = "0." + f(-o2 - 1) + s2, i2 && (r2 = i2 - c2) > 0 && (s2 += f(r2))) : c2 > o2 ? ((r2 = o2 + 1) < c2 && (s2 = s2.slice(0, r2) + "." + s2.slice(r2)), i2 && (r2 = i2 - c2) > 0 && (o2 + 1 === c2 && (s2 += "."), s2 += f(r2))) : (s2 += f(o2 + 1 - c2), i2 && (r2 = i2 - o2 - 1) > 0 && (s2 = s2 + "." + f(r2))), s2; } function s(e3, t2) { var n2 = e3[0]; for (t2 *= Mn; n2 >= 10; n2 /= 10) t2++; return t2; } function c(e3, t2, n2) { if (t2 > wn) throw sn = 1, n2 && (e3.precision = n2), Error(un); return r(new e3(en), t2, 1, 1); } function a(e3, t2, n2) { if (t2 > kn) throw Error(un); return r(new e3(tn), t2, n2, 1); } function u(e3) { var t2 = e3.length - 1, n2 = t2 * Mn + 1; if (t2 = e3[t2]) { for (; t2 % 10 == 0; t2 /= 10) n2--; for (t2 = e3[0]; t2 >= 10; t2 /= 10) n2++; } return n2; } function f(e3) { for (var t2 = ""; e3--; ) t2 += "0"; return t2; } function l(e3, t2, n2, i2) { var r2, o2 = new e3(1), s2 = Math.ceil(i2 / Mn + 4); for (sn = 0; ; ) { if (n2 % 2 && g((o2 = o2.times(t2)).d, s2) && (r2 = 1), 0 === (n2 = dn(n2 / 2))) { n2 = o2.d.length - 1, r2 && 0 === o2.d[n2] && ++o2.d[n2]; break; } g((t2 = t2.times(t2)).d, s2); } return sn = 1, o2; } function d(e3) { return 1 & e3.d[e3.d.length - 1]; } function m(e3, t2, n2) { for (var i2, r2 = new e3(t2[0]), o2 = 0; ++o2 < t2.length; ) { if (!(i2 = new e3(t2[o2])).s) { r2 = i2; break; } r2[n2](i2) && (r2 = i2); } return r2; } function h(t2, i2) { var o2, s2, c2, a2, u2, f2, l2, d2 = 0, m2 = 0, h2 = 0, v2 = t2.constructor, b2 = v2.rounding, p2 = v2.precision; if (!t2.d || !t2.d[0] || t2.e > 17) return new v2(t2.d ? t2.d[0] ? 0 > t2.s ? 0 : 1 / 0 : 1 : t2.s ? 0 > t2.s ? 0 : t2 : NaN); for (null == i2 ? (sn = 0, l2 = p2) : l2 = i2, f2 = new v2(0.03125); t2.e > -2; ) t2 = t2.times(f2), h2 += 5; for (l2 += s2 = Math.log(mn(2, h2)) / Math.LN10 * 2 + 5 | 0, o2 = a2 = u2 = new v2(1), v2.precision = l2; ; ) { if (a2 = r(a2.times(t2), l2, 1), o2 = o2.times(++m2), e((f2 = u2.plus(gn(a2, o2, l2, 1))).d).slice(0, l2) === e(u2.d).slice(0, l2)) { for (c2 = h2; c2--; ) u2 = r(u2.times(u2), l2, 1); if (null != i2) return v2.precision = p2, u2; if (d2 >= 3 || !n(u2.d, l2 - s2, b2, d2)) return r(u2, v2.precision = p2, b2, sn = 1); v2.precision = l2 += 10, o2 = a2 = f2 = new v2(1), m2 = 0, d2++; } u2 = f2; } } function v(t2, i2) { var o2, s2, a2, u2, f2, l2, d2, m2, h2, b2, p2, y2 = 1, M2 = t2, w2 = M2.d, k2 = M2.constructor, P2 = k2.rounding, g2 = k2.precision; if (0 > M2.s || !w2 || !w2[0] || !M2.e && 1 == w2[0] && 1 == w2.length) return new k2(w2 && !w2[0] ? -1 / 0 : 1 != M2.s ? NaN : w2 ? 0 : M2); if (null == i2 ? (sn = 0, h2 = g2) : h2 = i2, k2.precision = h2 += 10, s2 = (o2 = e(w2)).charAt(0), Math.abs(u2 = M2.e) >= 15e14) return m2 = c(k2, h2 + 2, g2).times(u2 + ""), M2 = v(new k2(s2 + "." + o2.slice(1)), h2 - 10).plus(m2), k2.precision = g2, null == i2 ? r(M2, g2, P2, sn = 1) : M2; for (; 7 > s2 && 1 != s2 || 1 == s2 && o2.charAt(1) > 3; ) s2 = (o2 = e((M2 = M2.times(t2)).d)).charAt(0), y2++; for (u2 = M2.e, s2 > 1 ? (M2 = new k2("0." + o2), u2++) : M2 = new k2(s2 + "." + o2.slice(1)), b2 = M2, d2 = f2 = M2 = gn(M2.minus(1), M2.plus(1), h2, 1), p2 = r(M2.times(M2), h2, 1), a2 = 3; ; ) { if (f2 = r(f2.times(p2), h2, 1), e((m2 = d2.plus(gn(f2, new k2(a2), h2, 1))).d).slice(0, h2) === e(d2.d).slice(0, h2)) { if (d2 = d2.times(2), 0 !== u2 && (d2 = d2.plus(c(k2, h2 + 2, g2).times(u2 + ""))), d2 = gn(d2, new k2(y2), h2, 1), null != i2) return k2.precision = g2, d2; if (!n(d2.d, h2 - 10, P2, l2)) return r(d2, k2.precision = g2, P2, sn = 1); k2.precision = h2 += 10, m2 = f2 = M2 = gn(b2.minus(1), b2.plus(1), h2, 1), p2 = r(M2.times(M2), h2, 1), a2 = l2 = 1; } d2 = m2, a2 += 2; } } function b(e3) { return e3.s * e3.s / 0 + ""; } function p(e3, t2) { var n2, i2, r2; for ((n2 = t2.indexOf(".")) > -1 && (t2 = t2.replace(".", "")), (i2 = t2.search(/e/i)) > 0 ? (0 > n2 && (n2 = i2), n2 += +t2.slice(i2 + 1), t2 = t2.substring(0, i2)) : 0 > n2 && (n2 = t2.length), i2 = 0; 48 === t2.charCodeAt(i2); i2++) ; for (r2 = t2.length; 48 === t2.charCodeAt(r2 - 1); --r2) ; if (t2 = t2.slice(i2, r2)) { if (r2 -= i2, e3.e = n2 = n2 - i2 - 1, e3.d = [], i2 = (n2 + 1) % Mn, 0 > n2 && (i2 += Mn), r2 > i2) { for (i2 && e3.d.push(+t2.slice(0, i2)), r2 -= Mn; r2 > i2; ) e3.d.push(+t2.slice(i2, i2 += Mn)); t2 = t2.slice(i2), i2 = Mn - t2.length; } else i2 -= r2; for (; i2--; ) t2 += "0"; e3.d.push(+t2), sn && (e3.e > e3.constructor.maxE ? (e3.d = null, e3.e = NaN) : e3.constructor.minE > e3.e && (e3.e = 0, e3.d = [0])); } else e3.e = 0, e3.d = [0]; return e3; } function y(e3, t2) { var n2, r2, o2, c2, a2, u2, f2, d2, m2; if (t2.indexOf("_") > -1) { if (t2 = t2.replace(/(\d)_(?=\d)/g, "$1"), pn.test(t2)) return p(e3, t2); } else if ("Infinity" === t2 || "NaN" === t2) return +t2 || (e3.s = NaN), e3.e = NaN, e3.d = null, e3; if (vn.test(t2)) n2 = 16, t2 = t2.toLowerCase(); else if (hn.test(t2)) n2 = 2; else { if (!bn.test(t2)) throw Error(an + t2); n2 = 8; } for ((c2 = t2.search(/p/i)) > 0 ? (f2 = +t2.slice(c2 + 1), t2 = t2.substring(2, c2)) : t2 = t2.slice(2), c2 = t2.indexOf("."), r2 = e3.constructor, (a2 = c2 >= 0) && (c2 = (u2 = (t2 = t2.replace(".", "")).length) - c2, o2 = l(r2, new r2(n2), c2, 2 * c2)), c2 = m2 = (d2 = i(t2, n2, yn)).length - 1; 0 === d2[c2]; --c2) d2.pop(); return 0 > c2 ? new r2(0 * e3.s) : (e3.e = s(d2, m2), e3.d = d2, sn = 0, a2 && (e3 = gn(e3, o2, 4 * u2)), f2 && (e3 = e3.times(54 > Math.abs(f2) ? mn(2, f2) : $n.pow(2, f2))), sn = 1, e3); } function M(e3, t2, n2, i2, r2) { var o2, s2, c2, a2, u2 = e3.precision, f2 = Math.ceil(u2 / Mn); for (sn = 0, a2 = n2.times(n2), c2 = new e3(i2); ; ) { if (s2 = gn(c2.times(a2), new e3(t2++ * t2++), u2, 1), c2 = r2 ? i2.plus(s2) : i2.minus(s2), i2 = gn(s2.times(a2), new e3(t2++ * t2++), u2, 1), void 0 !== (s2 = c2.plus(i2)).d[f2]) { for (o2 = f2; s2.d[o2] === c2.d[o2] && o2--; ) ; if (-1 == o2) break; } o2 = c2, c2 = i2, i2 = s2, s2 = o2; } return sn = 1, s2.d.length = f2 + 1, s2; } function w(e3, t2) { for (var n2 = e3; --t2; ) n2 *= e3; return n2; } function k(e3, t2) { var n2, i2 = 0 > t2.s, r2 = a(e3, e3.precision, 1), o2 = r2.times(0.5); if ((t2 = t2.abs()).lte(o2)) return on = i2 ? 4 : 1, t2; if ((n2 = t2.divToInt(r2)).isZero()) on = i2 ? 3 : 2; else { if ((t2 = t2.minus(n2.times(r2))).lte(o2)) return on = d(n2) ? i2 ? 2 : 3 : i2 ? 4 : 1, t2; on = d(n2) ? i2 ? 1 : 4 : i2 ? 3 : 2; } return t2.minus(r2).abs(); } function P(e3, n2, r2, s2) { var c2, a2, u2, f2, l2, d2, m2, h2, v2, p2 = e3.constructor, y2 = void 0 !== r2; if (y2 ? (t(r2, 1, Qt), void 0 === s2 ? s2 = p2.rounding : t(s2, 0, 8)) : (r2 = p2.precision, s2 = p2.rounding), e3.isFinite()) { for (y2 ? (c2 = 2, 16 == n2 ? r2 = 4 * r2 - 3 : 8 == n2 && (r2 = 3 * r2 - 2)) : c2 = n2, 0 > (u2 = (m2 = o(e3)).indexOf(".")) || (m2 = m2.replace(".", ""), (v2 = new p2(1)).e = m2.length - u2, v2.d = i(o(v2), 10, c2), v2.e = v2.d.length), a2 = l2 = (h2 = i(m2, 10, c2)).length; 0 == h2[--l2]; ) h2.pop(); if (h2[0]) { if (0 > u2 ? a2-- : ((e3 = new p2(e3)).d = h2, e3.e = a2, h2 = (e3 = gn(e3, v2, r2, s2, 0, c2)).d, a2 = e3.e, d2 = rn), u2 = h2[r2], f2 = c2 / 2, d2 = d2 || void 0 !== h2[r2 + 1], d2 = 4 > s2 ? (void 0 !== u2 || d2) && (0 === s2 || s2 === (0 > e3.s ? 3 : 2)) : u2 > f2 || u2 === f2 && (4 === s2 || d2 || 6 === s2 && 1 & h2[r2 - 1] || s2 === (0 > e3.s ? 8 : 7)), h2.length = r2, d2) for (; ++h2[--r2] > c2 - 1; ) h2[r2] = 0, r2 || (++a2, h2.unshift(1)); for (l2 = h2.length; !h2[l2 - 1]; --l2) ; for (u2 = 0, m2 = ""; l2 > u2; u2++) m2 += Zt.charAt(h2[u2]); if (y2) { if (l2 > 1) if (16 == n2 || 8 == n2) { for (u2 = 16 == n2 ? 4 : 3, --l2; l2 % u2; l2++) m2 += "0"; for (l2 = (h2 = i(m2, c2, n2)).length; !h2[l2 - 1]; --l2) ; for (u2 = 1, m2 = "1."; l2 > u2; u2++) m2 += Zt.charAt(h2[u2]); } else m2 = m2.charAt(0) + "." + m2.slice(1); m2 = m2 + (0 > a2 ? "p" : "p+") + a2; } else if (0 > a2) { for (; ++a2; ) m2 = "0" + m2; m2 = "0." + m2; } else if (++a2 > l2) for (a2 -= l2; a2--; ) m2 += "0"; else l2 > a2 && (m2 = m2.slice(0, a2) + "." + m2.slice(a2)); } else m2 = y2 ? "0p+0" : "0"; m2 = (16 == n2 ? "0x" : 2 == n2 ? "0b" : 8 == n2 ? "0o" : "") + m2; } else m2 = b(e3); return 0 > e3.s ? "-" + m2 : m2; } function g(e3, t2) { if (e3.length > t2) return e3.length = t2, 1; } function $(e3) { return new this(e3).abs(); } function N(e3) { return new this(e3).acos(); } function A(e3) { return new this(e3).acosh(); } function S(e3, t2) { return new this(e3).plus(t2); } function x(e3) { return new this(e3).asin(); } function I(e3) { return new this(e3).asinh(); } function T(e3) { return new this(e3).atan(); } function C(e3) { return new this(e3).atanh(); } function j(e3, t2) { e3 = new this(e3), t2 = new this(t2); var n2, i2 = this.precision, r2 = this.rounding, o2 = i2 + 4; return e3.s && t2.s ? e3.d || t2.d ? !t2.d || e3.isZero() ? (n2 = 0 > t2.s ? a(this, i2, r2) : new this(0)).s = e3.s : !e3.d || t2.isZero() ? (n2 = a(this, o2, 1).times(0.5)).s = e3.s : 0 > t2.s ? (this.precision = o2, this.rounding = 1, n2 = this.atan(gn(e3, t2, o2, 1)), t2 = a(this, o2, 1), this.precision = i2, this.rounding = r2, n2 = 0 > e3.s ? n2.minus(t2) : n2.plus(t2)) : n2 = this.atan(gn(e3, t2, o2, 1)) : (n2 = a(this, o2, 1).times(t2.s > 0 ? 0.25 : 0.75)).s = e3.s : n2 = new this(NaN), n2; } function O(e3) { return new this(e3).cbrt(); } function E(e3) { return r(e3 = new this(e3), e3.e + 1, 2); } function D(e3, t2, n2) { return new this(e3).clamp(t2, n2); } function B(e3) { if (!e3 || "object" != typeof e3) throw Error(cn + "Object expected"); var t2, n2, i2, r2 = 1 == e3.defaults, o2 = ["precision", 1, Qt, "rounding", 0, 8, "toExpNeg", -Yt, 0, "toExpPos", 0, Yt, "maxE", 0, Yt, "minE", -Yt, 0, "modulo", 0, 9]; for (t2 = 0; o2.length > t2; t2 += 3) if (n2 = o2[t2], r2 && (this[n2] = nn[n2]), void 0 !== (i2 = e3[n2])) { if (dn(i2) !== i2 || o2[t2 + 1] > i2 || i2 > o2[t2 + 2]) throw Error(an + n2 + ": " + i2); this[n2] = i2; } if (n2 = "crypto", r2 && (this[n2] = nn[n2]), void 0 !== (i2 = e3[n2])) { if (1 != i2 && 0 != i2 && 0 !== i2 && 1 !== i2) throw Error(an + n2 + ": " + i2); if (i2) { if ("undefined" == typeof crypto || !crypto || !crypto.getRandomValues && !crypto.randomBytes) throw Error(fn); this[n2] = 1; } else this[n2] = 0; } return this; } function F(e3) { return new this(e3).cos(); } function L(e3) { return new this(e3).cosh(); } function G(e3, t2) { return new this(e3).div(t2); } function _(e3) { return new this(e3).exp(); } function U(e3) { return r(e3 = new this(e3), e3.e + 1, 3); } function R() { var e3, t2, n2 = new this(0); for (sn = 0, e3 = 0; arguments.length > e3; ) if ((t2 = new this(arguments[e3++])).d) n2.d && (n2 = n2.plus(t2.times(t2))); else { if (t2.s) return sn = 1, new this(1 / 0); n2 = t2; } return sn = 1, n2.sqrt(); } function K(e3) { return e3 instanceof $n || e3 && e3.toStringTag === ln || 0; } function q(e3) { return new this(e3).ln(); } function z(e3, t2) { return new this(e3).log(t2); } function W(e3) { return new this(e3).log(2); } function X(e3) { return new this(e3).log(10); } function J() { return m(this, arguments, "lt"); } function V() { return m(this, arguments, "gt"); } function H(e3, t2) { return new this(e3).mod(t2); } function Y(e3, t2) { return new this(e3).mul(t2); } function Q(e3, t2) { return new this(e3).pow(t2); } function Z(e3) { var n2, i2, r2, o2, s2 = 0, c2 = new this(1), a2 = []; if (void 0 === e3 ? e3 = this.precision : t(e3, 1, Qt), r2 = Math.ceil(e3 / Mn), this.crypto) if (crypto.getRandomValues) for (n2 = crypto.getRandomValues(new Uint32Array(r2)); r2 > s2; ) 429e7 > (o2 = n2[s2]) ? a2[s2++] = o2 % 1e7 : n2[s2] = crypto.getRandomValues(new Uint32Array(1))[0]; else { if (!crypto.randomBytes) throw Error(fn); for (n2 = crypto.randomBytes(r2 *= 4); r2 > s2; ) 214e7 > (o2 = n2[s2] + (n2[s2 + 1] << 8) + (n2[s2 + 2] << 16) + ((127 & n2[s2 + 3]) << 24)) ? (a2.push(o2 % 1e7), s2 += 4) : crypto.randomBytes(4).copy(n2, s2); s2 = r2 / 4; } else for (; r2 > s2; ) a2[s2++] = 1e7 * Math.random() | 0; for (r2 = a2[--s2], e3 %= Mn, r2 && e3 && (o2 = mn(10, Mn - e3), a2[s2] = (r2 / o2 | 0) * o2); 0 === a2[s2]; s2--) a2.pop(); if (0 > s2) i2 = 0, a2 = [0]; else { for (i2 = -1; 0 === a2[0]; i2 -= Mn) a2.shift(); for (r2 = 1, o2 = a2[0]; o2 >= 10; o2 /= 10) r2++; Mn > r2 && (i2 -= Mn - r2); } return c2.e = i2, c2.d = a2, c2; } function ee(e3) { return r(e3 = new this(e3), e3.e + 1, this.rounding); } function te(e3) { return (e3 = new this(e3)).d ? e3.d[0] ? e3.s : 0 * e3.s : e3.s || NaN; } function ne(e3) { return new this(e3).sin(); } function ie(e3) { return new this(e3).sinh(); } function re(e3) { return new this(e3).sqrt(); } function oe(e3, t2) { return new this(e3).sub(t2); } function se() { var e3 = 0, t2 = arguments, n2 = new this(t2[e3]); for (sn = 0; n2.s && ++e3 < t2.length; ) n2 = n2.plus(t2[e3]); return sn = 1, r(n2, this.precision, this.rounding); } function ce(e3) { return new this(e3).tan(); } function ae(e3) { return new this(e3).tanh(); } function ue(e3) { return r(e3 = new this(e3), e3.e + 1, 1); } function fe(e3, t2) { return new $n(e3).add(new $n(t2)).toNumber(); } function le(e3) { return e3.replace(/\s+\)/g, ")").replace(/\(\s+/g, "(").replace(/\s*,\s*/g, ",").replace(/\s+/g, " "); } function de(e3) { switch (e3) { case "Cb": return "B"; case "Db": return "C#"; case "Eb": return "D#"; case "E#": return "F"; case "Fb": return "E"; case "Gb": return "F#"; case "Ab": return "G#"; case "Bb": return "A#"; case "B#": return "C"; default: return e3; } } function me(e3) { if (3 === e3.length) { const t2 = e3.replace(/^([CDEFGAB])(b#|#b)$/, "$1"); if (t2 !== e3) return t2; { const t3 = e3.match(/^([CDEFGAB]#)#$/); if (t3) return he(t3[1]); { const t4 = e3.match(/^([CDEFGAB])bb$/); if (t4) return ve(t4[1], 2); } } } return de(e3); } function he(e3) { const t2 = Zi.iKey, n2 = t2.indexOf(e3) + 1; return t2[n2 % 12]; } function ve(e3, t2 = 1) { const n2 = Zi.iKey, i2 = n2.indexOf(e3) - t2; return n2[(12 + i2) % 12]; } function be(e3) { const t2 = [{ sym: "E", note: 64 }, { sym: "B", note: 59 }, { sym: "G", note: 55 }, { sym: "D", note: 50 }, { sym: "A", note: 45 }, { sym: "E", note: 40 }, { sym: "B", note: 35 }, { sym: "F#", note: 30 }, { sym: "C#", note: 25 }], n2 = []; for (let i2 = 0; e3.length > i2; i2++) { const r2 = e3.length - i2 - 1, o2 = kr[e3[i2]].indexOf(t2[r2].sym); n2.unshift(t2[r2].note - o2); } return n2; } function pe(e3, t2) { return Array.from({ length: t2 - e3 + 1 }, (t3, n2) => e3 + n2); } function ye(e3, t2) { return e3.length > (t2 = Math.abs(t2) % (2 * (e3.length - 1))) || (t2 = 2 * (e3.length - 1) - t2), t2; } function Me(e3, t2) { const n2 = e3.slice(0, t2); return e3.slice(t2, e3.length + 1).concat(n2); } function we(e3, t2) { const n2 = e3.indexOf(t2), i2 = e3.slice(0, n2); return e3.slice(n2, e3.length + 1).concat(i2); } function ke(e3, t2, n2, i2 = []) { const r2 = []; let o2 = "", s2 = e3, c2 = t2, a2 = e3, u2 = t2, f2 = 0; for (const t3 of n2) "\n" === t3 ? (s2++, c2 = 1, f2 ? o2 += t3 : (/\S/.test(o2) && r2.push({ token: o2.trim(), line: a2, pos: u2 }), a2 = s2, u2 = c2, o2 = "")) : i2.includes(t3) ? f2 ? o2 += t3 : (/\S/.test(o2) && r2.push({ token: o2.trim(), line: a2, pos: u2 }), a2 = s2, u2 = c2 + (e3 === a2 ? 1 : 0), o2 = "") : "(" === t3 ? f2++ : ")" === t3 ? f2-- : /\s/.test(t3) ? /\S/.test(o2) ? o2 += t3 : u2++ : o2 += t3, c2++; return /\S/.test(o2) && r2.push({ token: o2.trim(), line: a2, pos: u2 }), r2; } function Pe(e3, t2, n2, i2) { const r2 = {}; let o2 = ""; if (/!/.test(e3)) { const i3 = e3.split("!"), s3 = parseInt(i3[1]); if (1 > s3 || s3 > Qi.maxApproachPercent) return new sr(t2, n2, e3, `Invalid shift order '${s3}'. Approach speed must be an integer with a value between 1 and ${Qi.maxApproachPercent}.`); r2.percentOfSpeed = s3, o2 = i3[0]; } else o2 = e3; const s2 = o2.split("|"), c2 = i2.map((e4, t3) => { const n3 = parseInt(s2[i2.length - 1 - t3]); return n3 > Qi.maxTopFret ? -2 : isNaN(n3) ? void 0 : n3; }); return s2.length > i2.length ? new sr(t2, n2, e3, `Invalid velocity value '${o2}'. You cannot specify more than the number of strings. Please set the number of strings using "set.turning".`) : c2.includes(-2) ? new sr(t2, n2, e3, `Invalid token '${o2}'. Up to ${Qi.maxTopFret} frets can be used`) : (r2.bowWithFret = c2, new nr(r2)); } function ge(e3, t2, n2) { const i2 = [], r2 = ke(t2, n2 + 3, e3, [","]); let o2 = 0, s2 = -1, c2 = 0; for (const t3 of r2) { const a2 = { row: t3.token, line: t3.line, linePos: t3.pos }; let u2 = t3.pos, f2 = t3.token, l2 = 0; const d2 = t3.token.split(/\s+/).length; for (let e4 = 0; d2 > e4; e4++) { const e5 = f2.match(/^((?:[^\s]+)(?:\s+|$))/); f2 = f2.replace(/^[^\s]+\s+/, ""); const n3 = e5 ? e5[1] : ""; let i3 = n3.trimEnd(); if (/^(\d+)?\.\./.test(i3)) { let e6 = i3.match(/^(\d+)?\.\.(\d+)?(\/\d+)?$/); if (!e6) return new sr(t3.line, u2, i3, `Invalid bend token '${i3}'. e.g. 0..2/4`); if (!e6[3] && o2 > 0 && (i3 = i3 + "/" + o2, e6 = i3.match(/^(\d+)?\.\.(\d+)?(\/\d+)?$/)), !e6) return new sr(t3.line, u2, i3, `Invalid bend token after processing '${i3}'. e.g. 0..2/4`); if (e6 && e6[3]) { const n4 = parseInt(e6[3].replace(/\//, "")); if (o2 && o2 !== n4) return new sr(t3.line, u2, t3.token, `Different denominators cannot be set. '/${n4}'`); if (o2 = parseInt(e6[3].replace(/\//, "")), o2 > Qi.bendMaxFixedUntilDenom) return new sr(t3.line, u2, t3.token, `The division denominator for Bend is ${Qi.bendMaxFixedUntilDenom}, but the setting value is ${o2}.`); } else 0 === o2 && (o2 = 16); a2.untilRange = [/^\d+$/.test(e6[1]) ? parseInt(e6[1]) : 0, /^\d+$/.test(e6[2]) ? parseInt(e6[2]) : -1, o2]; } else if ("reset" === i3) if (0 === c2) a2.untilRange = [0, 0, 1], a2.pitch = 0; else { if (c2 !== r2.length - 1) return new sr(t3.line, u2, t3.token, "Bend 'reset' can only be specified at the beginning or end."); a2.untilRange = [-2, -2, 1], a2.pitch = 0; } else if (/^(-|\+)?(\d+)(\.\d+)?$/.test(i3)) { const e6 = parseFloat(i3); if (-2 > e6 || e6 > 2) return new sr(t3.line, u2, t3.token, `Invalid bend pitch '${e6}'. Pitch can be set from -2 to 2.`); a2.pitch = e6; } else if (/^(ast|tri)$/.test(i3)) a2.curve = "tri" === i3 ? Xi.tri : Xi.ast; else if ("vib" === i3) l2 = 1, a2.method = Wi.vib; else { if (/^tpl::/.test(i3)) return new sr(t3.line, u2, t3.token, `Bend templates are not yet implemented. Template '${i3}' is recognized but cannot be applied due to technical complexity in scaling templates to variable note lengths. This feature is planned for future implementation.`); if ("cho" !== i3) return new sr(t3.line, u2, t3.token, `Wrong way to bend property '${i3}'`); } u2 += n3.length; } if (a2.template) { if (a2.untilRange || a2.curve || a2.cycle || a2.pitch || i2.length > 0) return new sr(t3.line, n2, e3, "Bend templates cannot overlap with other settings."); } else a2.untilRange || (0 === o2 && (o2 = 8), a2.untilRange = a2.method === Wi.vib ? [0 > s2 ? 0 : s2, -1, o2] : [0, -1, o2]); if (void 0 === a2.method && void 0 === a2.pitch && (a2.pitch = 1), 0 !== c2 && -2 !== a2.untilRange[0]) { if (-1 === s2) return new sr(t3.line, u2, t3.token, `The previous specification has already specified the end. '${t3.token}'`); s2 > a2.untilRange[0] && (a2.untilRange[0] = s2); } s2 = a2.untilRange[1], i2.push(a2), c2++; } return new nr(i2); } function $e(e3, t2, n2, i2) { let r2 = e3.trim(); const o2 = { line: n2, linePos: i2, row: r2 }; if (!/\D/.test(r2)) { const t3 = Ne(e3, n2, i2); return t3.fail() ? t3 : (o2.type = 1, o2.beforeBPM = t3.res, new nr(o2)); } if (/^(-|\+)\d+$/.test(r2)) return new sr(n2, i2, e3, `Invalid bpm token '${e3}'. If you use +- signs, start with '..'. e.g. bpm(120..-10)`); const s2 = r2.match(/\s*(\.\.)\s*?([+-])?(\d+)$/); s2 && (o2.type = s2[1] ? 2 : 1, s2[2] && (o2.afterSign = "+" === s2[2] ? 1 : -1), o2.afterBPM = parseInt(s2[3]), r2 = r2.replace(/\s*(\.\.)\s*?[+-]?\d+$/, "")); const c2 = r2.match(/^(\+|-)?(\d+)$/); return c2 && (o2.type = 3, c2[1] && (o2.beforeSign = "+" === c2[1] ? 1 : -1), o2.beforeBPM = parseInt(c2[2]), r2 = r2.replace(/^(\+|-)?(\d+)$/, "")), 2 !== o2.type && 3 !== o2.type || t2 === Nn.closingCurlyBrace ? "" !== r2 ? new sr(n2, i2, r2, `Invalid BPM format '${r2}'. e.g. bpm(100..200) or bpm(-20..+20) or bpm(140) etc..`) : new nr(o2) : new sr(n2, i2, e3, `Invalid set position transition bpm '${e3}'. Transition BPM cannot be specified for a single note.`); } function Ne(e3, t2, n2) { if (e3 = e3.trim(), /[^\d]/.test(e3)) return new sr(t2, -1, null, `Invalid BPM '${e3}', The entered value is outside the accepted range of ${Qi.minBPM}-${Qi.maxBPM}. Please enter a value within this range.`); const i2 = parseInt(e3); return Qi.minBPM > i2 || i2 > Qi.maxBPM || isNaN(i2) ? new sr(t2, n2, e3, `Invalid BPM '${e3}', The entered value is outside the accepted range of ${Qi.minBPM}-${Qi.maxBPM}. Please enter a value within this range.`) : new nr(i2); } function Ae(e3, t2, n2) { const i2 = {}; if ("" === e3) return new sr(t2, n2, e3, "'delay' properties need to be set."); if (!/^\d+\/\d+$/.test(e3)) return new sr(t2, n2, e3, `Invalid delay property '${e3}'.`); { const r2 = Te(e3, t2, n2); if (r2.fail()) return r2; i2.startUntil = r2.res; } return 0 === i2.startUntil[0] ? new sr(t2, n2, e3, `Invalid delay property '${e3}'. Molecule cannot be specified as 0.`) : i2.startUntil[0] > i2.startUntil[1] ? new sr(t2, n2, e3, `Invalid delay property '${e3}'. Make the numerator smaller than the denominator because it exceeds the range.`) : new nr(i2); } function Se(e3, t2, n2) { const i2 = {}, r2 = function(e4, t3, n3) { const i3 = []; let r3 = "", o3 = t3, s3 = 0, c3 = 0; const a3 = () => { i3.push({ token: r3, line: s3 + e4, pos: o3 }), o3 += r3.length; }; let u3 = 0; const f3 = n3.length; for (; f3 > u3; ) { const e5 = n3[u3]; switch (e5) { case " ": c3 ? r3 += e5 : r3.length && (a3(), r3 = ""), o3++; break; case "\n": c3 ? r3 += e5 : (r3.length && (a3(), r3 = ""), s3++, o3 = 0), o3++; break; case "(": c3++, r3 += e5; break; case ")": c3--, r3 += e5; break; default: r3 += e5; } u3++; } return r3.length && a3(), i3; }(t2, n2 + 4, e3); let o2 = ""; for (const e4 of r2) { const r3 = e4.token, s3 = e4.line, c3 = e4.pos, a3 = r3.match(/^([CDEFGAB](?:#|b)?)(m|M)?$/); if (a3) a3[1] && (i2.tonic = de(a3[1])), "m" === a3[2] ? i2.tonal = Sn.minor : "M" === a3[2] && (i2.tonal = Sn.major); else { if (/^[CDEFGAB](#|b)?:[01]+$/.test(r3)) return new fr(t2, n2, r3, `CustomScale Not Allowed. '${r3}'`); if (/^\d+th$/.test(r3)) { const e5 = parseInt(r3.replace(/th$/, "")); if (o2 === Sn.major || o2 === Sn.minor || o2 === An.harmonic || o2 === An.melodic) { if (7 !== e5 && 6 !== e5) return new sr(s3, c3, r3, `Invalid shift order '${r3}'. Set numerical values with 'th' for tonality to 6 or 7; however, note that some sequences are not supported. e.g. minor 6th`); i2.tonalShift = e5; } else { if ("mode" !== o2) return new sr(s3, c3, r3, `Invalid token '${r3}'. Set numerical values with 'th' after 'major', 'minor', 'mode'. e.g. harmonic minor 7th mode 5th`); if (1 > e5 || e5 > 7) return new sr(s3, c3, r3, `Invalid shift order '${r3}'. Must be an integer with a value between 1 and 7.`); i2.modalShift = e5; } } else switch (r3) { case "mode": o2 = r3; break; case An.harmonic: case An.melodic: i2.scale = r3; break; case Sn.major: case Sn.minor: i2.tonal = r3; break; default: return new sr(s3, c3, r3, `'${r3}' is an invalid token that cannot be set as a key. e.g. C# melodic minor 7th mode 3th`); } } o2 = r3; } if (i2.scale && !i2.tonal) return new sr(t2, n2, i2.scale, `Invalid order '${i2.scale}. 'minor' or 'major' is required after '${i2.scale}'. e.g. harmonic minor 7th mode 5th`); i2.tonic || (i2.tonic = br.C), i2.scale || (i2.scale = An.normal), i2.tonal || (i2.tonal = Sn.major); const s2 = `${i2.scale} ${i2.tonal} ${c2 = i2.tonalShift, c2 ? c2 + "th" : ""}`.trim(); var c2; const a2 = yr(s2); if (!a2) return new sr(t2, n2, s2, `Invalid scale combination '${s2}'.`); i2.modalShift && (a2.evolvedCodePrefix = Me(a2.evolvedCodePrefix, i2.modalShift - 1), a2.bin = Me(a2.bin, function(e4, t3) { const n3 = e4.map((e5, t4) => 1 === e5 ? t4 : -1).filter((e5) => -1 !== e5); return t3 > n3.length ? -1 : n3[t3 - 1]; }(a2.bin, i2.modalShift))), i2.diatonicEvolverValue = a2; const u2 = we(Zi.iKey, i2.tonic), f2 = u2.map((e4, t3) => 1 === a2.bin[t3] ? e4 : null).filter((e4) => null !== e4); return i2.sys = { shiftedKeyArray: u2, note7array: f2 }, new nr(i2); } function xe(e3, t2, n2) { const i2 = []; if (!/\S/.test(e3)) return new sr(t2, n2, "map", "Invalid map syntax. Symbol must be specified for map."); const r2 = ke(t2, n2, e3, [","]); for (let t3 = 0; r2.length > t3; t3++) { const n3 = r2[t3], o2 = []; let s2 = 0; const c2 = n3.token.match(/((?:-|\+)?\d+)\.\.((?:-|\+)?\d+)(?:\s*step\s*(\d+))?\s*/); c2 && (n3.token = n3.token.replace(c2[0], "")); const a2 = n3.token.match(/((?:-|\+)?\d+)\s*step\s*((?:-|\+)?\d+)\s*\*\s*((?:-|\+)?\d+)\s*/); a2 && (n3.token = n3.token.replace(a2[0], "")); const u2 = n3.token.match(/^(\d+)?\s*\*\s*(\d+)$/); if (u2 && (n3.token = n3.token.replace(u2[0], "")), "" !== n3.token) { const t4 = n3.token.split(/\s+/); for (let i3 = 0; t4.length > i3; i3++) { const r3 = t4[i3]; if (Yi.includes(r3)) o2.push(Hi[r3]); else { if (!/^(\+|-)?\d+$/.test(r3)) return new sr(n3.line, n3.pos, e3, `Invalid Mapping token '${r3}'. e.g. 3 ss, -2..+2 rev etc..`); s2 = parseInt(r3); } } } if (u2) { const e4 = void 0 === u2[1] ? 0 : parseInt(u2[1]), t4 = parseInt(u2[2]); if (t4 > Qi.maxMappedStepOrder) return new sr(n3.line, n3.pos, u2[0], `Invalid map prop '${u2[0]}'. The coefficient limit for this specification is ${Qi.maxMappedStepOrder}.`); for (let r3 = 0; t4 > r3; r3++) i2.push({ shift: e4, options: o2, location: { row: n3.token, line: n3.line, linePos: n3.pos } }); } else if (a2) { const e4 = parseInt(a2[1]), t4 = parseInt(a2[2]), r3 = parseInt(a2[3]); if (1 > r3) return new sr(n3.line, n3.pos, a2[0], `Invalid Mapping token '${a2[0]}'. Coefficient cannot be less than or equal to zero. e.g. map(1 step 2 * 3)`); if (r3 > Qi.maxMappedStepOrder) return new sr(n3.line, n3.pos, a2[0], `Invalid map order '${a2[0]}'. The coefficient limit for this specification is ${Qi.maxMappedStepOrder}.`); let s3 = e4; for (let e5 = 0; r3 > e5; e5++) { const e6 = { shift: s3, options: o2, location: { row: n3.token, line: n3.line, linePos: n3.pos } }; s3 += t4, i2.push(e6); } } else if (c2) { const e4 = parseInt(c2[1]), t4 = parseInt(c2[2]); let r3 = void 0 !== c2[3] && /^[1-9]/.test(c2[3]) ? parseInt(c2[3]) : 1; if (r3 = e4 > t4 ? -Math.abs(r3) : Math.abs(r3), Math.abs(e4 - t4) >= Qi.maxMappedStepOrder) return new sr(n3.line, n3.pos, c2[0], `Invalid map order '${c2[0]}'. Step count range is up to ${Qi.maxMappedStepOrder}.`); for (let s3 = e4; r3 > 0 ? t4 >= s3 : s3 >= t4; s3 += r3) i2.push({ shift: s3, options: o2, location: { row: n3.token, line: n3.line, linePos: n3.pos } }); } else i2.push({ shift: s2, options: o2, location: { row: n3.token, line: n3.line, linePos: n3.pos } }); } return new nr(i2); } function Ie(e3, t2, n2) { const i2 = e3.split("|"), r2 = i2.find((e4) => "" === e4 || !/^[CDEFGAB](#|b)?$/.test(e4)); if (r2 || "" === r2) return new sr(t2, n2, e3, `Invalid tuning '${r2}', tuning supports only ${Zi.iKey.map((e4) => `'${e4}'`)}.` + (/^\||\|$/.test(e3) ? "\nPlease set without '|' on both sides." : "") + "\ne.g. D|A|D|G|A|D or C#|A|D|G|B|E or C#|F#|B|E|A|D|G|B|E"); if (6 > i2.length || i2.length > Qi.maxBows) return new sr(t2, n2, e3, `Invalid tuning '${i2.join("|")}'. The number of strings that can be set ranges from 6 to ${Qi.maxBows}.`); const o2 = i2.map((e4) => me(e4)), s2 = be(o2); for (let i3 = 1; s2.length > i3; i3++) if (s2[i3] > s2[i3 - 1]) return new sr(t2, n2, e3, `Invalid tuning ${e3}. The treble strings cannot be lower than the bass strings. e.g. C#|F#|B|E|A|D|G|B|E`); return new nr(o2); } function Te(e3, t2, n2) { if (!/^\d+\/\d+$/.test(e3)) return new sr(t2, n2, e3, `Invalid token '${e3}'. specify A as a fraction. e.g. 1/4`); const i2 = e3.split("/").map((e4) => parseInt(e4.trim())); return i2[0] > Qi.maxUntilNext0 ? new sr(t2, n2, e3, `Invalid token '${i2.join("/")}', numerator value '${i2[0]}' exceeds the allowed maximum of ${Qi.maxUntilNext0}.`) : i2[1] > Qi.maxUntilNext1 || 1 > i2[1] ? new sr(t2, n2, e3, `Invalid token '${i2.join("/")}', The entered value is outside the accepted range of 1-${Qi.maxUntilNext1}. Please enter a value within this range.`) : new nr(i2); } function Ce(e3, t2, n2) { const i2 = {}; if ("" === e3) return new sr(t2, n2, e3, "staccato requires property"); if (!/^\d+\/\d+$/.test(e3)) return new sr(t2, n2, e3, `Invalid staccato property '${e3}'.`); { const r2 = Te(e3, t2, n2); if (r2.fail()) return r2; i2.cutUntil = r2.res; } return 0 === i2.cutUntil[0] ? new sr(t2, n2, e3, `Invalid staccato property '${e3}'. Molecule cannot be specified as 0.`) : i2.cutUntil[0] > i2.cutUntil[1] ? new sr(t2, n2, e3, `Invalid staccato property '${e3}'. Make the numerator smaller than the denominator because it exceeds the range.`) : new nr(i2); } function je(e3, t2, n2, i2, r2, o2) { if (!/\S/.test(i2)) return new sr(r2, n2, t2, "Invalid step syntax. Symbol must be specified for step."); const s2 = function(e4, t3, n3, i3) { let r3 = n3, o3 = i3 - 1, s3 = n3, c3 = i3 - 1; const a3 = []; let u3 = 0, f2 = "", l2 = ""; for (const n4 of t3) if ("\n" !== n4) if (c3++, /\s/.test(n4)) l2 += " "; else { if (!/[.MmnDdUuf123456789rRN~^=()]/.test(n4)) return new sr(s3, c3, n4, `Invalid step symbol '${n4}'. Only '.MmnDdUuf123456789rR' can be used with step.`); if (/\d/.test(n4) && parseInt(n4) > e4.length) return new sr(s3, c3, n4, `Invalid pos value '${n4}'. The string specification exceeds the number of strings specified in tuning ${e4.length} strings.`); if ("(" !== n4) if (")" !== n4) "" === f2 ? (r3 = s3, o3 = c3, f2 += n4, l2 += n4) : u3 || /m|M|n|N|~|=|\^|\./.test(n4) ? (f2 += n4, l2 += n4) : (a3.push({ sym: f2, startLine: r3, startPos: o3, endPos: o3 + l2.trim().length }), f2 = n4, l2 = n4, r3 = s3, o3 = c3); else { if ("" === f2) return new sr(s3, c3, n4, `Invalid step symbol '${n4}'. Parentheses must specify a symbol.`); if (/^(~|=|\^|\.)/.test(f2) || !/^\d+/.test(f2)) return new sr(s3, c3, n4, `Invalid step symbol '${f2}'.. Instrument specification cannot be at the beginning.`); u3 = 0, a3.push({ sym: f2, startLine: r3, startPos: o3, endPos: o3 + l2.trim().length }), f2 = "", l2 = ""; } else { if (u3) return new sr(s3, c3, n4, `Invalid pos value '${n4}'. Parentheses can only be one level deep.`); "" !== f2 && (a3.push({ sym: f2, startLine: r3, startPos: o3, endPos: o3 + l2.trim().length }), f2 = "", l2 = ""), u3 = 1; } } else u3 || "" === f2 || (a3.push({ sym: f2, startLine: r3, startPos: o3, endPos: o3 + l2.trim().length }), f2 = "", l2 = ""), s3++, c3 = 0; return "" !== f2 && a3.push({ sym: f2, startLine: r3, startPos: o3, endPos: o3 + l2.trim().length }), new nr(a3); }(e3, i2, r2, o2); if (s2.fail()) return s2; const c2 = { parsedStep: [] }, a2 = [], u2 = Array.from({ length: e3.length }, (e4, t3) => t3); for (let e4 = 0; s2.res.length > e4; e4++) { const t3 = s2.res[e4].sym, n3 = { line: s2.res[e4].startLine, startPos: s2.res[e4].startPos, endPos: s2.res[e4].endPos }, f2 = t3.match(/\d/g); if (/f|D|d|U|u/.test(t3)) n3.stringIndexes = u2; else if (/R|rn/.test(t3)) n3.stringIndexes = void 0, n3.inst = zi.restNoise; else if (/r/.test(t3)) n3.stringIndexes = void 0, n3.inst = zi.rest; else { if (!f2) return new sr(r2, o2, i2, `Invalid step symbol '${i2}'. Specification violation.`); n3.stringIndexes = f2.map((e5) => parseInt(e5) - 1); } const l2 = t3.replace(/rn/, "").match(/[nmMDdUuN]/g); if (l2) { if (l2.length > 1) return new sr(r2, o2, i2, `Invalid step symbol '${l2.join("")}'. Multiple inst specifications cannot be specified for one string.`); n3.inst = { n: zi.normal, m: zi.mute, M: zi.muteContinue, D: zi.brushing_D, d: zi.brushing_d, U: zi.brushing_U, u: zi.brushing_u, N: zi.normalUnContinueForStep }[l2[0]]; } const d2 = t3.replace(/[fnmMDdUu]/g, "").replace(/\./g, "~").match(/[~^=]+/g); d2 && (n3.suffix = d2[0]), a2.push(t3), n3.stepSym = [...a2], c2.parsedStep.push(n3); } return new nr(c2); } function Oe(e3, t2, n2, i2) { const r2 = {}; if ("" !== t2) { const e4 = t2.split(","); for (const o2 of e4) if (/\D/.test(o2)) { if (!/^\d+\/\d+$/.test(o2)) return new sr(n2, i2, t2, `Invalid strum property '${o2}'.`); { const e5 = Te(o2, n2, i2); if (e5.fail()) return e5; r2.startUntil = e5.res; } } else { const e5 = parseInt(o2); if (0 > e5 || e5 > Qi.maxStrumWidthMSec) return new sr(n2, i2, t2, `Invalid strum msec '${o2}'. Strum must be between 0 and ${Qi.maxStrumWidthMSec}.`); r2.strumWidthMSec = e5; } } return r2.startUntil && 0 === r2.startUntil[0] ? new sr(n2, i2, t2, `Invalid strum property '${t2}'. Molecule cannot be specified as 0.`) : r2.startUntil && r2.startUntil[0] > r2.startUntil[1] ? new sr(n2, i2, t2, `Invalid strum property '${t2}'. Make the numerator smaller than the denominator because it exceeds the range.`) : (r2.startUntil || (r2.startUntil = [0, 1]), r2.strumWidthMSec || (r2.strumWidthMSec = e3.settings.play.strum.defaultStrumWidthMSec), new nr(r2)); } function Ee(e3, t2, n2) { const i2 = {}, r2 = ke(t2, n2 + 3, e3, ["!", ",", "."]); for (const e4 of r2) if (/^\d+\/\d+$/.test(e4.token)) { const t3 = Te(e4.token, e4.line, e4.pos); if (t3.fail()) return t3; i2.until = t3.res; } else if ("off" === e4.token) i2.off = 1; else { if ("up" !== e4.token) return new sr(e4.line, e4.pos, e4.token, `The stroke property '${e4.token}' is invalid. e.g. ## stroke(1/8) or stroke(1/8.up) or stroke(off) etc..`); i2.up = 1; } return new nr(i2); } function De(e3, t2, n2) { const i2 = {}, r2 = ke(t2, n2, e3, [",", " "]); for (let t3 = 0; r2.length > t3; t3++) { const n3 = r2[t3]; if (/^[CDEFGAB](#|b)?$/.test(n3.token)) i2.key = me(n3.token); else if (Mr.includes(n3.token)) i2.scale = Mr.indexOf(n3.token), i2.bin = wr[i2.scale].bin; else { if (!/^\d+$/.test(n3.token)) return new sr(n3.line, n3.pos, e3, `Invalid scale token '${n3.token}'. e.g. E dorian`); if (!/^[01]+$/.test(n3.token)) return new sr(n3.line, n3.pos, e3, `Invalid scale token '${n3.token}'. Customize scale to shape "1" and "0". e.g. E 101101011010`); if (12 !== n3.token.length) return new sr(n3.line, n3.pos, e3, `Invalid scale token '${n3.token}'. Customize the scale to 12 digits. e.g. E 101101011010`); i2.scale = n3.token, i2.bin = n3.token.split("").map((e4) => "1" === e4 ? 1 : 0); } } return i2.key ? void 0 === i2.scale ? new sr(t2, n2, e3, `Invalid scale token '${e3}'. Scales need scale name. e.g. E minor`) : new nr(i2) : new sr(t2, n2, e3, `Invalid scale token '${e3}'. Scales need keys. e.g. E minor`); } function Be(e3, t2, n2, i2) { const r2 = {}, o2 = ke(t2, n2 - 2, e3, ["!", ","]); for (const e4 of o2) { if (/^\d+\/\d+$/.test(e4.token)) { const t4 = Te(e4.token, e4.line, e4.pos); if (t4.fail()) return t4; r2.startUntil = t4.res; continue; } const t3 = e4.token.match(/^(fast|mid|slow)(?:\.?(\d+))?$/); if (t3) { r2.inSpeed = t3[1], t3[2] && (r2.inSpeedLevel = parseInt(t3[2])); continue; } const n3 = e4.token.match(/^(hi|low)(?:\.?(\d+))?$/); if (n3) r2.type = "release", r2.arrow = "hi" === n3[1] ? 1 : -1, n3[2] && (r2.releaseWidth = parseInt(n3[2])); else if ("continue" !== e4.token) { if ("auto" !== e4.token) return new sr(e4.line, e4.pos, e4.token, `The slide property '${e4.token}' is invalid because it is an unknown word.`); r2.auto = 1; } else r2.continue = 1; } return r2.type || (r2.type = "to"), r2.startUntil || (r2.startUntil = r2.arrow ? [6, 8] : [1, 2], "to" === r2.type && (r2.auto = 1)), r2.inSpeedLevel || (r2.inSpeedLevel = 48), i2 && (r2.continue = 1), r2.continue && "release" === r2.type && (r2.continue = void 0), new nr(r2); } function Fe(e3, t2, n2, i2, r2) { const o2 = t2.split(/[|,]/).map((t3, n3) => { const i3 = t3.trim(); return "" === i3 ? e3.settings.play.velocities[n3] : /^\d+$/.test(i3) ? parseInt(i3) : NaN; }).reverse(); return o2.some((e4) => void 0 !== e4 && (e4 > 100 || 0 > e4 || isNaN(e4))) ? new sr(i2, r2, t2, `Invalid velocities value '${t2}'. Must be an integer with a value between 0 and 100.`) : o2.length > n2.length ? new sr(i2, r2, t2, `Invalid velocity value '${t2}'. You cannot specify more than the number of strings. Please set the number of strings using "set.turning". e.g. for 7 strings it is "set.turning: D|E|A|D|G|B|E"`) : new nr(o2); } function Le(e3, t2, n2) { const i2 = parseInt(e3.replace(/^\s/g, "")); return i2 > 100 || !/^s*\d+\s*$/.test(e3) ? new sr(t2, n2, e3, `Invalid velocity value '${e3}'. Must be an integer with a value between 0 and 100.`) : new nr(i2 || 1); } function Ge(e3) { const t2 = e3.token; if (/^([./!']+)?([|\dr]+(!\d+)?>>)/.test(e3.token)) { const t3 = e3.token.match(/^([./!']+)?([|\dr]+)(!\d+)?>>/); if (t3) { if (/r/.test(t3[2])) return new sr(e3.line, e3.linePos, e3.token, "The rest 'r' cannot be specified for the approach."); e3.styles.push(`approach(${t3[2] + (t3[3] ? t3[3] : "")})`), e3.linesOfStyle.push(e3.line), e3.linePosOfStyle.push(e3.linePos + (t3[1] ? t3[1].length : 0)), e3.token = e3.token.replace(/^([./!']+)?[|\dr]+(!\d+)?>>/, "$1"); } } if (/^([/!']+)?\.\./.test(e3.token) && (e3.styles.push("continue"), e3.linesOfStyle.push(e3.line), e3.linePosOfStyle.push(e3.linePos), e3.token = e3.token.replace(/^([/!']+)?\.\./, "$1")), /^'*?\//.test(e3.token) && (e3.styles.push("strum"), e3.linesOfStyle.push(e3.line), e3.linePosOfStyle.push(e3.linePos), e3.token = e3.token.replace(/^('*?)\//, "$1")), /^!?('+)/.test(e3.token) || /^!('+)?/.test(e3.token)) { const t3 = e3.token.match(/^(!)?('*)/); if (t3) { const n2 = t3[2].split("").length; if (n2 > 8) return new sr(e3.line, e3.linePos, e3.token, "The prefix >>'<< that specifies stroke cannot exceed 8."); const i2 = [16, 12, 8, 6, 4, 3, 2, 1][n2 - 1]; e3.styles.push(`stroke(${i2 ? "1/" + i2 : ""}${t3[1] ? ".up" : ""})`), e3.linesOfStyle.push(e3.line), e3.linePosOfStyle.push(e3.linePos), e3.token = e3.token.replace(/^!?'*/, ""); } } return /^[.!/>]/.test(e3.token) ? />/.test(e3.token) ? new sr(e3.line, e3.linePos, e3.token, `Invalid approach prefix ${t2}. e.g. ||||2|2>>||||5|5 or ||||2|2!200>>||||5|5 etc..`) : /\.\.\./.test(t2) || /\./.test(e3.token) ? new sr(e3.line, e3.linePos, e3.token, `Invalid continue prefix '${t2}'. Continue dots are only valid for 2 connections. e.g. ..|3|2|3|2`) : new sr(e3.line, e3.linePos, t2, `Invalid token prefix '${t2}'. e.g. ..C or ''C or ..''|||2|2| or /|||2|2| or ||||2|2>>||||5|5 or ||||2|2!200>>||||5|5 etc..`) : (e3.prefixLength = t2.length - e3.token.length, rr()); } function _e(e3, t2, n2, i2, r2) { const o2 = e3.marks.styleMappedGroupList, s2 = o2.findIndex((e4) => e4 > 0); let c2 = -1; if (o2[s2] > 0 ? (c2 = o2[s2] + 1, o2.splice(s2, 0, c2)) : (c2 = 1, o2.splice(1, 0, c2)), i2.decidedProp.noteStr.match(/\/$/)) return new sr(i2.line, i2.linePos, i2.decidedProp.noteStr, `Not found fret token. ${i2.decidedProp.noteStr} e.g. 6/1-2-3`); const a2 = i2.decidedProp.noteStr.replace(/:.*?$/, "").match(/^(.*?)\d\/[^/]+$/); let u2 = 0; a2 && (u2 = a2[1].length); let f2 = 0, l2 = i2.linePos + u2; const [d2, m2] = i2.token.split("/"), h2 = parseInt(d2); if (1 > h2 || h2 > t2.length) return new sr(i2.line, l2, "" + h2, `Not Found strings '${h2}'. Only the tuning string can be specified.`); const v2 = t2.length - h2; l2 += d2.length + 1; const b2 = Object.keys(i2.decidedProp.styles), p2 = m2.replace(/-+$/, "").split("-"); for (let e4 = 0; p2.length > e4; e4++) { const t3 = p2[e4]; if ("" === t3) { l2++; continue; } const o3 = t3.match(/^(\d+|r|R)([nmMDdUu])?([~^=]+)?$/); if (!o3) return new sr(i2.line, l2, t3, `Invalid fret token option '${t3}'. Permitted frets include n,m,M,D,d,U,u,R,r, etc.. e.g. 2/4m-5-7-r-5-7`); const s3 = o3[1], a3 = "R" === s3 ? "R" : o3[2], u3 = o3[3], d3 = {}; b2.forEach((t4) => { if (void 0 !== i2.decidedProp.styles[t4]) { switch (t4) { case "bd": case "bpm": case "until": case "degree": case "legato": case "scaleX": case "staccato": case "velocity": case "velocityPerBows": case "turn": d3[t4] = i2.decidedProp.styles[t4]; break; case "mapped": d3[t4] = structuredClone(i2.decidedProp.styles[t4]), d3[t4].forEach((e5) => { -1 === e5.group && (e5.group = c2); }); } if (0 === e4) switch (t4) { case "approach": case "continue": case "delay": case "strum": d3[t4] = i2.decidedProp.styles[t4]; } e4 === p2.length - 1 && "slide" === t4 && (d3[t4] = i2.decidedProp.styles[t4]); } }); const m3 = { n: zi.normal, m: zi.mute, M: zi.muteContinue, R: zi.restNoise, D: zi.brushing_D, d: zi.brushing_d, U: zi.brushing_U, u: zi.brushing_u }[a3]; m3 === zi.restNoise && (d3.restNoise = 1), d3.inst = void 0 !== m3 ? m3 : void 0 !== i2.decidedProp.styles.inst ? i2.decidedProp.styles.inst : zi.normal, 0 === e4 || !i2.decidedProp.styles.continue || f2 || d3.inst !== zi.normal && d3.inst !== zi.muteContinue ? 0 !== e4 && (f2 = 1) : d3.continue = 1; const h3 = "|".repeat(v2) + ("R" === s3 ? "r" : s3) + (0 === v2 ? "|" : "") + (u3 || ""), y2 = structuredClone(i2.decidedProp.extensionViewProp) || {}; y2.bullet = { row: t3, index: e4 }; const M2 = { curlyLevel: i2.curlyLevel, type: Nn.note, typesStyle: [], line: i2.line, linePos: l2, linesOfStyle: [], linePosOfStyle: [], endLine: i2.line, endPos: l2 + t3.length, token: h3, styles: [], decidedProp: { noteStr: i2.decidedProp.noteStr, extensionViewProp: y2, list: void 0, tick: structuredClone(i2.decidedProp.tick), styles: d3, fingering: void 0, chordDicRef: i2.decidedProp.chordDicRef, isBullet: r2.num }, regionRegionForDualConnection: i2.regionRegionForDualConnection, locationInfoRefStackUpList: i2.locationInfoRefStackUpList }; l2 += t3.length + 1, n2.push(M2); } return rr(); } function Ue(e3, t2) { return t2 * (60 / e3) * (1 / Qi.PPS); } function Re(e3, t2) { return Qi.PPS * e3 / 60 * (t2 / 1e3); } function Ke(e3) { return Qi.PPS / e3[1] * e3[0]; } function qe(e3) { const t2 = function(e4, t3) { for (; 0 !== t3; ) { const n2 = e4; e4 = t3, t3 = n2 % t3; } return e4; }(e3[0], e3[1]); return [e3[0] / t2, e3[1] / t2]; } function ze(e3, t2, n2, i2) { let r2 = 0; const o2 = t2.match(/[\^=~]+$/); if (o2) { if (o2[0].length > Qi.maxSuffixExtensionLength) return new sr(n2, i2, t2, `Invalid suffix extension token '${t2}'. Up to ${Qi.maxSuffixExtensionLength} suffix extensions can be used.`); const s2 = o2[0].match(/=/g); s2 && (e3[1] = 3 * e3[1] * s2.length); const c2 = o2[0].match(/~/g); c2 && (e3[0] = e3[0] * (c2.length + 1)); const a2 = o2[0].match(/\^/g); a2 && (e3[1] = 2 * e3[1] * a2.length), [e3[0], e3[1]] = qe(e3), r2 = 1; } return new nr(r2); } function We(e3, t2) { for (let n2 = 0; t2.length > n2; n2++) { const i2 = t2[n2]; if (i2.type !== Nn.regionStart && (i2.type === Nn.degreeName || i2.type === Nn.note)) { const t3 = i2.decidedProp.styles; i2.decidedProp.tick = { untilNext: (t3 == null ? void 0 : t3.until) ? structuredClone(t3.until) : structuredClone(e3.regionList[i2.regionRegionForDualConnection].untilNext) }; const n3 = ze(i2.decidedProp.tick.untilNext, i2.token, i2.line, i2.linePos); if (n3.fail()) return n3; n3.res && (i2.token = i2.token.replace(/[