abcjs
Version:
Renderer for abc music notation
3 lines • 425 kB
JavaScript
/*! abcjs_plugin v6.5.1 Copyright © 2009-2024 Paul Rosen and Gregory Dyke (https://abcjs.net) */
/*! For license information please see abcjs_plugin.LICENSE */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.abcjs=t():e.ABCJS=t()}(this,(function(){return e={7001:function(e,t,r){"use strict";var a=r(1592).TuneBook,i=r(8905),n=r(5253),s=new function(){var e=!1;try{e=abcjs_is_user_script}catch(e){}this.show_midi=!e,this.hide_abc=!1,this.render_before=!1,this.midi_options={},this.render_options={},this.render_classname="abcrendered",this.text_classname="abctext",this.auto_render_threshold=20,this.show_text="show score for: ",this.debug=!1};s.start=function(){var e=window.document.body;this.errors="";var t=this.getABCContainingElements(e);if(0!==t.length){if(this.debug)for(var r=0;r<t.length;r++){var a="Possible ABC found ("+(r+1)+" of "+t.length+"):\n\n"+t[r].innerText;alert(a)}var i=t.map(this.convertToDivs,this).reduce((function(e,t){return e.concat(t)}));this.auto_render=i.length<=this.auto_render_threshold,i.forEach((function(e){this.render(e,e.abctext_)}),this)}},s.getABCContainingElements=function(e){for(var t,r=[],a=!1,i=0,n=e.childNodes.length;i<n;++i)3!==(t=e.childNodes[i]).nodeType||a?1===t.nodeType&&"TEXTAREA"!==t.tagName&&(r=r.concat(this.getABCContainingElements(t))):t.nodeValue.match(/^\s*X:/m)&&"TEXTAREA"!==t.parentNode.tagName&&(r.push(e),a=!0);return r},s.convertToDivs=function(e){for(var t,r="",a=null,i=!1,n=[],s=Array.prototype.slice.call(e.childNodes),o=0,c=s.length;o<c;++o)if(3!==(t=s[o]).nodeType||t.nodeValue.match(/^\s*$/))i&&"BR"===t.tagName||i&&1===t.nodeType?(r+="\n",a.appendChild(t)):i&&(i=!1,r=r.replace(/\n+/,"\n"),a.abctext_=r,n.push(a));else{var l=t.nodeValue;l.match(/^\s*X:/m)&&(i=!0,r="",(a=document.createElement("DIV")).className=this.text_classname,t.parentElement.insertBefore(a,t),this.hide_abc&&(a.style.display="none")),i&&(r+=l.replace(/^\n+/,""),a.appendChild(t))}return i&&(r=r.replace(/\n+$/,"\n").replace(/^\n+/,"\n"),a.abctext_=r,n.push(a)),n},s.render=function(e,t){var r=document.createElement("DIV");r.className=this.render_classname,this.render_before?e.parentElement.insertBefore(r,e):e.nextSibling?e.parentElement.insertBefore(r,e.nextSibling):e.parentElement.appendChild(r);var s=this;try{this.debug&&alert("About to render:\n\n"+t);var o=new a(t),c=new i;c.parse(o.tunes[0].abc);var l=c.getTune(),h=function(){try{var t=new n(r,s.render_options);t.engraveABC(l)}catch(a){r.remove(),(r=document.createElement("DIV")).className=s.render_classname,(t=new n(r)).engraveABC(l),s.render_before?e.parentElement.insertBefore(r,e):e.nextSibling?e.parentElement.insertBefore(r,e.nextSibling):e.parentElement.appendChild(r)}},d=document.createElement("A");d.className="abcshow",d.href="#",d.innerHTML=this.show_text+(l.metaText.title||"untitled"),this.auto_render?h():(d.onclick=function(){return h(),d.remove(),!1},r.parentElement.insertBefore(d,r))}catch(e){this.errors+=e}};var o=!0;"undefined"!=typeof abcjs_plugin_autostart&&(o=abcjs_plugin_autostart),o&&"undefined"!=typeof window&&void 0!==window.document&&("loading"!==window.document.readyState?s.start():document.addEventListener("DOMContentLoaded",(function(){s.start()})));var c={plugin:s};e.exports=c},1592:function(e,t,r){function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}var i=r(8905),n=r(9565),s=r(2426),o={};!function(){"use strict";o.numberOfTunes=function(e){var t=e.split("\nX:").length;return 0===t&&(t=1),t};var e=o.TuneBook=function(e){var t=n(e);this.header=t.header,this.tunes=t.tunes};e.prototype.getTuneById=function(e){for(var t=0;t<this.tunes.length;t++)if(this.tunes[t].id===""+e)return this.tunes[t];return null},e.prototype.getTuneByTitle=function(e){for(var t=0;t<this.tunes.length;t++)if(this.tunes[t].title===e)return this.tunes[t];return null},o.parseOnly=function(e,t){for(var r=o.numberOfTunes(e),a=[],i=0;i<r;i++)a.push(1);return o.renderEngine((function(){}),a,e,t)},o.renderEngine=function(t,r,n,o){var c=[];if(void 0!==r&&void 0!==n){var l;(!(l=r)||l.propertyIsEnumerable("length")||"object"!==a(l)||"number"!=typeof l.length)&&(r=[r]),void 0===o&&(o={});for(var h=o.startingTune?parseInt(o.startingTune,10):0,d=new e(n),u=new i,f=0;f<r.length;f++){var p=r[f];if("*"===p||"string"==typeof p&&(p=document.getElementById(p)),p)if(h>=0&&h<d.tunes.length){u.parse(d.tunes[h].abc,o,d.tunes[h].startPos-d.header.length);var m=u.getTune();o.tablature&&(m.tablatures=s.preparePlugins(m,h,o));var g=u.getWarnings();g&&(m.warnings=g);var v=t(p,m,f,d.tunes[h].abc);c.push(v||m)}else p.innerHTML&&(p.innerHTML="");h++}return c}},o.extractMeasures=function(t){for(var r=[],a=new e(t),i=0;i<a.tunes.length;i++){for(var n=a.tunes[i],s=n.abc.split("K:"),c=s[1].split("\n"),l=s[0]+"K:"+c[0]+"\n",h=null,d=null,u=null,f=[],p=!1,m=o.parseOnly(n.abc)[0],g=m.getPickupLength()>0,v=0;v<m.lines.length;v++){var b=m.lines[v];if(b.staff)for(var y=0;y<1;y++)for(var x=b.staff[y],k=0;k<1;k++)for(var w=x.voices[k],T=0;T<w.length;T++){var C=w[T];if(null===u&&C.startChar>=0&&(u=C.startChar,d=void 0===C.chord?h:null),C.chord&&(h=C),"bar"===C.el_type){if(p){var S={abc:n.abc.substring(u,C.endChar)};(h=d&&d.chord&&d.chord.length>0?d.chord[0].name:null)&&(S.lastChord=h),C.startEnding&&(S.startEnding=C.startEnding),C.endEnding&&(S.endEnding=C.endEnding),f.push(S),u=null,p=!1}}else"note"===C.el_type&&(p=!0)}}r.push({header:l,measures:f,hasPickup:g})}return r}}(),e.exports=o},9447:function(e,t,r){var a=r(4914).relativeMajor,i={acc:"sharp",note:"f"},n={acc:"sharp",note:"c"},s={acc:"sharp",note:"g"},o={acc:"sharp",note:"d"},c={acc:"sharp",note:"A"},l={acc:"sharp",note:"e"},h={acc:"flat",note:"B"},d={acc:"flat",note:"e"},u={acc:"flat",note:"A"},f={acc:"flat",note:"d"},p={acc:"flat",note:"G"},m={acc:"flat",note:"c"},g={"C#":[i,n,s,o,c,l,{acc:"sharp",note:"B"}],"F#":[i,n,s,o,c,l],B:[i,n,s,o,c],E:[i,n,s,o],A:[i,n,s],D:[i,n],G:[i],C:[],F:[h],Bb:[h,d],Eb:[h,d,u],Cm:[h,d,u],Ab:[h,d,u,f],Db:[h,d,u,f,p],Gb:[h,d,u,f,p,m],Cb:[h,d,u,f,p,m,{acc:"flat",note:"F"}],"A#":[h,d],"B#":[],"D#":[h,d,u],"E#":[h],"G#":[h,d,u,f],none:[]};e.exports=function(e){var t=g[a(e)];return t?JSON.parse(JSON.stringify(t)):null}},4914:function(e){var t={C:{modes:["CMaj","Amin","Am","GMix","DDor","EPhr","FLyd","BLoc"],stepsFromC:0},Db:{modes:["DbMaj","Bbmin","Bbm","AbMix","EbDor","FPhr","GbLyd","CLoc"],stepsFromC:1},D:{modes:["DMaj","Bmin","Bm","AMix","EDor","F#Phr","GLyd","C#Loc"],stepsFromC:2},Eb:{modes:["EbMaj","Cmin","Cm","BbMix","FDor","GPhr","AbLyd","DLoc"],stepsFromC:3},E:{modes:["EMaj","C#min","C#m","BMix","F#Dor","G#Phr","ALyd","D#Loc"],stepsFromC:4},F:{modes:["FMaj","Dmin","Dm","CMix","GDor","APhr","BbLyd","ELoc"],stepsFromC:5},Gb:{modes:["GbMaj","Ebmin","Ebm","DbMix","AbDor","BbPhr","CbLyd","FLoc"],stepsFromC:6},G:{modes:["GMaj","Emin","Em","DMix","ADor","BPhr","CLyd","F#Loc"],stepsFromC:7},Ab:{modes:["AbMaj","Fmin","Fm","EbMix","BbDor","CPhr","DbLyd","GLoc"],stepsFromC:8},A:{modes:["AMaj","F#min","F#m","EMix","BDor","C#Phr","DLyd","G#Loc"],stepsFromC:9},Bb:{modes:["BbMaj","Gmin","Gm","FMix","CDor","DPhr","EbLyd","ALoc"],stepsFromC:10},B:{modes:["BMaj","G#min","G#m","F#Mix","C#Dor","D#Phr","ELyd","A#Loc"],stepsFromC:11},"C#":{modes:["C#Maj","A#min","A#m","G#Mix","D#Dor","E#Phr","F#Lyd","B#Loc"],stepsFromC:1},"F#":{modes:["F#Maj","D#min","D#m","C#Mix","G#Dor","A#Phr","BLyd","E#Loc"],stepsFromC:6},Cb:{modes:["CbMaj","Abmin","Abm","GbMix","DbDor","EbPhr","FbLyd","BbLoc"],stepsFromC:11}},r=null;e.exports={relativeMajor:function(e){r||function(){r={};for(var e=Object.keys(t),a=0;a<e.length;a++){var i=t[e[a]];r[e[a].toLowerCase()]=e[a];for(var n=0;n<i.modes.length;n++){var s=i.modes[n].toLowerCase();r[s]=e[a]}}}();var a=e.toLowerCase().match(/([a-g][b#]?)(maj|min|mix|dor|phr|lyd|loc|m)?/);if(!a||!a[2])return e;a=a[1]+a[2];var i=r[a];return i||e},relativeMode:function(e,r){var a=t[e];if(!a)return e;if(""===r)return e;var i=r.toLowerCase().match(/^(maj|min|mix|dor|phr|lyd|loc|m)/);if(!i)return e;for(var n=i[1],s=0;s<a.modes.length;s++){var o=a.modes[s],c=o.toLowerCase().indexOf(n);if(-1!==c&&c===o.length-n.length)return o.substring(0,o.length-n.length)}return e},transposeKey:function(e,r){var a=t[e];if(!a)return e;for(;r<0;)r+=12;for(var i=(a.stepsFromC+r)%12,n=0;n<Object.keys(t).length;n++){var s=Object.keys(t)[n];if(t[s].stepsFromC===i)return s}return e}}},6780:function(e,t,r){var a=r(5008),i=r(4331),n=r(1028),s=r(9716),o=r(351);e.exports=function(){function e(e,t,r,a){for(var i=0;i<a.length;i++)e[r][a[i]]=t[r][a[i]]}function t(e,t){for(;t<e.length&&null===e[t].left;)t++;return e[t]}this.reset=function(){this.version="1.1.0",this.media="screen",this.metaText={},this.metaTextInfo={},this.formatting={},this.lines=[],this.staffNum=0,this.voiceNum=0,this.lineNum=0,this.runningFonts={},delete this.visualTranspose},this.reset(),this.copyTopInfo=function(t){var r=["tempo","title","header","rhythm","origin","composer","author","partOrder"];e(this,t,"metaText",r),e(this,t,"metaTextInfo",r)},this.copyBottomInfo=function(t){var r=["unalignedWords","book","source","discography","notes","transcription","history","abc-copyright","abc-creator","abc-edited-by","footer"];e(this,t,"metaText",r),e(this,t,"metaTextInfo",r)},this.getBeatLength=function(){var e=this.getMeterFraction(),t=1;return(6===e.num||9===e.num||12===e.num||3===e.num&&8===e.den)&&(t=3),t/e.den},this.getPickupLength=function(){var e=this.getBarLength(),t=function(e,t){for(var r=0,a=0;a<e.length;a++)if(e[a].staff)for(var i=0;i<e[a].staff.length;i++)for(var n=0;n<e[a].staff[i].voices.length;n++)for(var s=e[a].staff[i].voices[n],o=1,c=0;c<s.length;c++){var l=s[c].rest&&"spacer"===s[c].rest.type;if(s[c].startTriplet&&(o=s[c].tripletMultiplier),s[c].duration&&!l&&"tempo"!==s[c].el_type&&(r+=s[c].duration*o),s[c].endTriplet&&(o=1),r>=t&&(r-=t),"bar"===s[c].el_type)return r}return r}(this.lines,e);return t<1e-8||e-t<1e-8?0:t},this.getBarLength=function(){var e=this.getMeterFraction();return e.num/e.den},this.getTotalTime=function(){return this.totalTime},this.getTotalBeats=function(){return this.totalBeats},this.millisecondsPerMeasure=function(e){var t;if(e)t=e;else{var r=this.metaText?this.metaText.tempo:null;t=this.getBpm(r)}return t<=0&&(t=1),this.getBeatsPerMeasure()/t*6e4},this.getBeatsPerMeasure=function(){var e=this.getBeatLength();return this.getBarLength()/e},this.getMeter=function(){for(var e=0;e<this.lines.length;e++){var t=this.lines[e];if(t.staff)for(var r=0;r<t.staff.length;r++){var a=t.staff[r].meter;if(a)return a}}return{type:"common_time"}},this.getMeterFraction=function(){var e=this.getMeter(),t=4,r=4;return e&&("specified"===e.type?(t=parseInt(e.value[0].num,10),r=parseInt(e.value[0].den,10)):"cut_time"===e.type?(t=2,r=2):"common_time"===e.type&&(t=4,r=4)),this.meter={num:t,den:r},this.meter},this.getKeySignature=function(){for(var e=0;e<this.lines.length;e++){var t=this.lines[e];if(t.staff)for(var r=0;r<t.staff.length;r++)if(t.staff[r].key)return t.staff[r].key}return{}},this.getElementFromChar=function(e){for(var t=0;t<this.lines.length;t++){var r=this.lines[t];if(r.staff)for(var a=0;a<r.staff.length;a++)for(var i=r.staff[a],n=0;n<i.voices.length;n++)for(var s=i.voices[n],o=0;o<s.length;o++){var c=s[o];if(c.startChar&&c.endChar&&c.startChar<=e&&c.endChar>e)return c}}return null},this.addElementToEvents=function(e,t,r,i,n,s,o,c,l,h){if(t.hint)return{isTiedState:void 0,duration:0};var d=t.durationClass?t.durationClass:t.duration;if(t.abcelem.rest&&"spacer"===t.abcelem.rest.type&&(d=0),d>0){for(var u=[],f=0;f<t.elemset.length;f++)null!==t.elemset[f]&&u.push(t.elemset[f]);var p=t.startTie;if(void 0!==l)e["event"+l].elements.push(u),h&&(e["event"+r]||(e["event"+r]={type:"event",milliseconds:r,line:s,measureNumber:o,top:i,height:n,left:null,width:0,elements:[],startChar:null,endChar:null,startCharArray:[],endCharArray:[]}),e["event"+r].measureStart=!0,h=!1),p||(l=void 0);else{if(e["event"+r]){if(e["event"+r].left?e["event"+r].left=Math.min(e["event"+r].left,t.x):e["event"+r].left=t.x,e["event"+r].elements.push(u),e["event"+r].startCharArray.push(t.abcelem.startChar),e["event"+r].endCharArray.push(t.abcelem.endChar),null===e["event"+r].startChar&&(e["event"+r].startChar=t.abcelem.startChar),null===e["event"+r].endChar&&(e["event"+r].endChar=t.abcelem.endChar),t.abcelem.midiPitches&&t.abcelem.midiPitches.length)for(e["event"+r].midiPitches||(e["event"+r].midiPitches=[]),f=0;f<t.abcelem.midiPitches.length;f++)e["event"+r].midiPitches.push(t.abcelem.midiPitches[f]);if(t.abcelem.midiGraceNotePitches&&t.abcelem.midiGraceNotePitches.length){e["event"+r].midiGraceNotePitches||(e["event"+r].midiGraceNotePitches=[]);for(var m=0;m<t.abcelem.midiGraceNotePitches.length;m++)e["event"+r].midiGraceNotePitches.push(t.abcelem.midiGraceNotePitches[m])}}else e["event"+r]={type:"event",milliseconds:r,line:s,measureNumber:o,top:i,height:n,left:t.x,width:t.w,elements:[u],startChar:t.abcelem.startChar,endChar:t.abcelem.endChar,startCharArray:[t.abcelem.startChar],endCharArray:[t.abcelem.endChar],midiPitches:t.abcelem.midiPitches?a.cloneArray(t.abcelem.midiPitches):[]},t.abcelem.midiGraceNotePitches&&(e["event"+r].midiGraceNotePitches=a.cloneArray(t.abcelem.midiGraceNotePitches));h&&(e["event"+r].measureStart=!0,h=!1)}}return{isTiedState:l,duration:d/c,nextIsBar:h||"bar"===t.type}},this.makeVoicesArray=function(){for(var e=[],t=[],r={},a=0;a<this.engraver.staffgroups.length;a++){var n=this.engraver.staffgroups[a];if(n&&n.staffs&&n.staffs.length>0)for(var s=n.staffs[0],o=s.absoluteY,c=o-s.top*i.STEP,l=n.staffs[n.staffs.length-1],h=(o=l.absoluteY)-l.bottom*i.STEP-c,d=n.voices,u=0;u<d.length;u++)if(!d[u].staff||!d[u].staff.isTabStaff){var f=!1;e[u]||(e[u]=[]),void 0===t[u]&&(t[u]=0);for(var p=d[u].children,m=0;m<p.length;m++)"tempo"===p[m].type&&(r[t[u]]=this.getBpm(p[m].abcelem)),e[u].push({top:c,height:h,line:n.line,measureNumber:t[u],elem:p[m]}),"bar"===p[m].type&&f&&t[u]++,"note"!==p[m].type&&"rest"!==p[m].type||(f=!0)}}return this.tempoLocations=r,e},this.setupEvents=function(e,r,a,i){i||(i=1);for(var n,s=[],o={},c=e,l=!0,h=this.makeVoicesArray(),d=0,u=0;u<h.length;u++){var f=c,p=Math.round(1e3*f),m=0,g=-1,v=h[u],b=a;r=this.getBeatLength()*b/60;for(var y=-1,x=0;x<v.length;x++){var k=v[x].measureNumber;y!==k&&this.tempoLocations[k]&&(b=this.tempoLocations[k],r=i*this.getBeatLength()*b/60,y=k);var w,T=v[x].elem,C=this.addElementToEvents(o,T,p,v[x].top,v[x].height,v[x].line,v[x].measureNumber,r,n,l);if(n=C.isTiedState,l=C.nextIsBar,f+=C.duration,T.duration>0&&o["event"+p]&&(w="event"+p),p=Math.round(1e3*f),"bar"===T.type){var S=T.abcelem.type,E="bar_right_repeat"===S||"bar_dbl_repeat"===S,M="1"===T.abcelem.startEnding,N="bar_left_repeat"===S||"bar_dbl_repeat"===S||"bar_right_repeat"===S;if(E){x>0&&(o[w].endX=T.x),-1===g&&(g=x);var _=0;y=-1;for(var A=m;A<g;A++){y!==(k=v[A].measureNumber)&&this.tempoLocations[k]&&(b=this.tempoLocations[k],r=i*this.getBeatLength()*b/60,y=k);var B=v[A].elem;n=(C=this.addElementToEvents(o,B,p,v[A].top,v[A].height,v[A].line,v[A].measureNumber,r,n,l)).isTiedState,l=C.nextIsBar,f+=C.duration,_=p,p=Math.round(1e3*f)}o["event"+_]&&(o["event"+_].endX=v[g].elem.x),l=!0,g=-1}M&&(g=x),N&&(m=x)}}d=Math.max(d,p)}return function(e){for(var t,r,a,i,n=e.length-1;n>=0;n--){var s=e[n];"bar"===s.type?(s.top=a,s.nextTop=t,t=a,s.bottom=i,s.nextBottom=r,r=i):"event"===s.type&&(a=s.top,i=s.top+s.height)}}(s=function(e){var t=[];for(var r in e)e.hasOwnProperty(r)&&t.push(e[r]);return t.sort((function(e,t){var r=e.milliseconds-t.milliseconds;return 0!==r?r:"bar"===e.type?-1:1}))}(o)),function(e,r){if(!(r.length<1)){for(var a=0;a<r.length-1;a++){var i=r[a],n=t(r,a+1);if(null!==i.left){var s=n&&i.top===n.top?n.left:e[i.line].staffGroup.w;void 0!==i.endX?s>i.left&&(i.endX=Math.min(i.endX,s)):i.endX=s}}var o=r[r.length-1];o.endX=e[o.line].staffGroup.w}}(this.lines,s),s.push({type:"end",milliseconds:d}),this.addUsefulCallbackInfo(s,b*i),s},this.addUsefulCallbackInfo=function(e,t){for(var r=this.millisecondsPerMeasure(t),a=0;a<e.length;a++)e[a].millisecondsPerMeasure=r},this.getBpm=function(e){var t;if(e||(e=this.metaText?this.metaText.tempo:null),e){t=e.bpm;var r=this.getBeatLength();t=t*(e.duration&&e.duration.length>0?e.duration[0]:r)/r}if(!t){t=180;var a=this.getMeterFraction();a&&3!==a.num&&a.num%3==0&&(t=120)}return t},this.setTiming=function(e,t){if(t=t||0,!this.engraver||!this.engraver.staffgroups)return console.log("setTiming cannot be called before the tune is drawn."),this.noteTimings=[],this.noteTimings;var r=this.metaText?this.metaText.tempo:null,a=this.getBpm(r),i=1;e?r&&(i=e/a):e=a;var n=this.getBeatLength(),s=e/60,o=this.getBarLength()/n*t/s;o&&(o-=this.getPickupLength()/n/s);var c=n*s;return this.noteTimings=this.setupEvents(o,c,e,i),this.noteTimings.length>0?(this.totalTime=this.noteTimings[this.noteTimings.length-1].milliseconds/1e3,this.totalBeats=this.totalTime*s):(this.totalTime=void 0,this.totalBeats=void 0),this.noteTimings},this.setUpAudio=function(e){e||(e={});var t=n(this,e);return s(t,e,this.formatting.percmap,this.formatting.midi)},this.deline=function(e){return o(this.lines,e)},this.findSelectableElement=function(e){return this.engraver&&this.engraver.selectables?this.engraver.findSelectableElement(e):null},this.getSelectableArray=function(){return this.engraver&&this.engraver.selectables?this.engraver.selectables:[]}}},351:function(e){function t(e,t){return"abselem"===e?"abselem":t}function r(e,t){e.el_type="meter",e.startChar=-1,e.endChar=-1;for(var r=0;r<t.length;r++)t[r].unshift(e)}function a(e,t){e.el_type="key",e.startChar=-1,e.endChar=-1;for(var r=0;r<t.length;r++)t[r].unshift(e)}function i(e,t){e.el_type="clef",e.startChar=-1,e.endChar=-1;for(var r=0;r<t.length;r++)t[r].unshift(e)}function n(e,t,r){e.el_type="font",e.type=r,e.startChar=-1,e.endChar=-1;for(var a=0;a<t.length;a++)t[a].unshift(e)}function s(e,r){return!e||JSON.stringify(e,t)===JSON.stringify(r,t)}function o(e){for(var t={},r=Object.keys(e),a=0;a<r.length;a++)if("staff"!==r[a])t[r[a]]=e[r[a]];else{t.staff=[];for(var i=0;i<e.staff.length;i++){for(var n={},s=Object.keys(e.staff[i]),o=0;o<s.length;o++)if("voices"!==s[o])n[s[o]]=e.staff[i][s[o]];else{n.voices=[];for(var c=0;c<e.staff[i].voices.length;c++)n.voices.push([].concat(e.staff[i].voices[c]))}t.staff.push(n)}}return t}e.exports=function(e,t){t||(t={});for(var c=!!t.lineBreaks,l=[],h=!1,d=[],u=[],f=[],p=[],m=[],g=[],v=[],b=0;b<e.length;b++){var y=e[b];if(y.staff){if(h&&!y.vskip)for(var x=l[l.length-1],k=0;k<x.staff.length;k++){var w=y.staff[k],T=x.staff[k];if(w&&(s(w.meter,d[k])||(r(w.meter,w.voices),d[k]=w.meter,delete w.meter),s(w.key,u[k])||(a(w.key,w.voices),u[k]=w.key,delete w.key),w.title&&(T.abbrevTitle=w.title),s(w.clef,f[k])||(i(w.clef,w.voices),f[k]=w.clef,delete w.clef),s(w.vocalfont,p[k])||(n(w.vocalfont,w.voices,"vocalfont"),p[k]=w.vocalfont,delete w.vocalfont),s(w.gchordfont,m[k])||(n(w.gchordfont,w.voices,"gchordfont"),m[k]=w.gchordfont,delete w.gchordfont),s(w.tripletfont,g[k])||(n(w.tripletfont,w.voices,"tripletfont"),g[k]=w.tripletfont,delete w.tripletfont),s(w.annotationfont,v[k])||(n(w.annotationfont,w.voices,"annotationfont"),v[k]=w.annotationfont,delete w.annotationfont)),w)for(var C=0;C<T.voices.length;C++){var S=T.voices[C],E=w.voices[C];c&&S.push({el_type:"break"}),E&&(T.voices[C]=S.concat(E))}}else{for(var M=0;M<y.staff.length;M++)u[M]=y.staff[M].key,d[M]=y.staff[M].meter,f[M]=y.staff[M].clef;l.push(o(y))}h=!0}else h=!1,l.push(y)}return l}},5008:function(e){var t={cloneArray:function(e){for(var t=[],r=0;r<e.length;r++)t.push(Object.assign({},e[r]));return t},cloneHashOfHash:function(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[r]=Object.assign({},e[r]));return t},cloneHashOfArrayOfHash:function(e){var r={};for(var a in e)e.hasOwnProperty(a)&&(r[a]=t.cloneArray(e[a]));return r},strip:function(e){return e.replace(/^\s+/,"").replace(/\s+$/,"")},startsWith:function(e,t){return 0===e.indexOf(t)},endsWith:function(e,t){var r=e.length-t.length;return r>=0&&e.lastIndexOf(t)===r},last:function(e){return 0===e.length?null:e[e.length-1]}};e.exports=t},8905:function(e,t,r){var a=r(5008),i=r(8360),n=r(9928),s=r(6476),o=r(1881),c=r(1756),l=r(6780),h=r(575);e.exports=function(){"use strict";var e,t=new l,r=new h(t),d="",u="";function f(e,t,r){e.positioning||(e.positioning={}),e.positioning[t]=r}function p(e,t,r){e.fonts||(e.fonts={}),e.fonts[t]=r}this.getTune=function(){var e={formatting:t.formatting,lines:t.lines,media:t.media,metaText:t.metaText,metaTextInfo:t.metaTextInfo,version:t.version,addElementToEvents:t.addElementToEvents,addUsefulCallbackInfo:t.addUsefulCallbackInfo,getTotalTime:t.getTotalTime,getTotalBeats:t.getTotalBeats,getBarLength:t.getBarLength,getBeatLength:t.getBeatLength,getBeatsPerMeasure:t.getBeatsPerMeasure,getBpm:t.getBpm,getMeter:t.getMeter,getMeterFraction:t.getMeterFraction,getPickupLength:t.getPickupLength,getKeySignature:t.getKeySignature,getElementFromChar:t.getElementFromChar,makeVoicesArray:t.makeVoicesArray,millisecondsPerMeasure:t.millisecondsPerMeasure,setupEvents:t.setupEvents,setTiming:t.setTiming,setUpAudio:t.setUpAudio,deline:t.deline,findSelectableElement:t.findSelectableElement,getSelectableArray:t.getSelectableArray};return t.lineBreaks&&(e.lineBreaks=t.lineBreaks),t.visualTranspose&&(e.visualTranspose=t.visualTranspose),e};var m,g,v={reset:function(){for(var e in this)this.hasOwnProperty(e)&&"function"!=typeof this[e]&&delete this[e];this.iChar=0,this.key={accidentals:[],root:"none",acc:"",mode:""},this.meter=null,this.origMeter=null,this.hasMainTitle=!1,this.default_length=.125,this.clef={type:"treble",verticalPos:0},this.octave=0,this.next_note_duration=0,this.start_new_line=!0,this.is_in_header=!0,this.partForNextLine={},this.tempoForNextLine=[],this.havent_set_length=!0,this.voices={},this.staves=[],this.macros={},this.currBarNumber=1,this.barCounter={},this.ignoredDecorations=[],this.score_is_present=!1,this.inEnding=!1,this.inTie=[],this.inTieChord={},this.vocalPosition="auto",this.dynamicPosition="auto",this.chordPosition="auto",this.ornamentPosition="auto",this.volumePosition="auto",this.openSlurs=[],this.freegchord=!1,this.endingHoldOver={}},differentFont:function(e,t){return this[e].decoration!==t[e].decoration||this[e].face!==t[e].face||this[e].size!==t[e].size||this[e].style!==t[e].style||this[e].weight!==t[e].weight},addFormattingOptions:function(e,t,r){"note"===r?("auto"!==this.vocalPosition&&f(e,"vocalPosition",this.vocalPosition),"auto"!==this.dynamicPosition&&f(e,"dynamicPosition",this.dynamicPosition),"auto"!==this.chordPosition&&f(e,"chordPosition",this.chordPosition),"auto"!==this.ornamentPosition&&f(e,"ornamentPosition",this.ornamentPosition),"auto"!==this.volumePosition&&f(e,"volumePosition",this.volumePosition),this.differentFont("annotationfont",t)&&p(e,"annotationfont",this.annotationfont),this.differentFont("gchordfont",t)&&p(e,"gchordfont",this.gchordfont),this.differentFont("vocalfont",t)&&p(e,"vocalfont",this.vocalfont),this.differentFont("tripletfont",t)&&p(e,"tripletfont",this.tripletfont)):"bar"===r&&("auto"!==this.dynamicPosition&&f(e,"dynamicPosition",this.dynamicPosition),"auto"!==this.chordPosition&&f(e,"chordPosition",this.chordPosition),"auto"!==this.ornamentPosition&&f(e,"ornamentPosition",this.ornamentPosition),"auto"!==this.volumePosition&&f(e,"volumePosition",this.volumePosition),this.differentFont("measurefont",t)&&p(e,"measurefont",this.measurefont),this.differentFont("repeatfont",t)&&p(e,"repeatfont",this.repeatfont))},duplicateStartEndingHoldOvers:function(){this.endingHoldOver={inTie:[],inTieChord:{}};for(var e=0;e<this.inTie.length;e++)if(this.endingHoldOver.inTie.push([]),this.inTie[e])for(var t=0;t<this.inTie[e].length;t++)this.endingHoldOver.inTie[e].push(this.inTie[e][t]);for(var r in this.inTieChord)this.inTieChord.hasOwnProperty(r)&&(this.endingHoldOver.inTieChord[r]=this.inTieChord[r])},restoreStartEndingHoldOvers:function(){if(this.endingHoldOver.inTie){this.inTie=[],this.inTieChord={};for(var e=0;e<this.endingHoldOver.inTie.length;e++){this.inTie.push([]);for(var t=0;t<this.endingHoldOver.inTie[e].length;t++)this.inTie[e].push(this.endingHoldOver.inTie[e][t])}for(var r in this.endingHoldOver.inTieChord)this.endingHoldOver.inTieChord.hasOwnProperty(r)&&(this.inTieChord[r]=this.endingHoldOver.inTieChord[r])}}},b=function(e){var t=e.replace(/\x12/g," ");return(t=(t=t.replace(/&/g,"&")).replace(/</g,"<")).replace(/>/g,">")},y=function(t,r,a){r||(r=" ");var i=r[a];" "!==i&&i||(i="SPACE");var n,s=b(r.substring(a-64,a))+'<span style="text-decoration:underline;font-size:1.3em;font-weight:bold;">'+i+"</span>"+b(r.substring(a+1).substring(0,64));!function(e){v.warnings||(v.warnings=[]),v.warnings.push(e)}("Music Line:"+e.lineIndex+":"+(a+1)+": "+t+": "+s),n={message:t,line:r,startChar:v.iChar+a,column:a},v.warningObjects||(v.warningObjects=[]),v.warningObjects.push(n)};this.getWarnings=function(){return v.warnings},this.getWarningObjects=function(){return v.warningObjects};var x=function(t,r){if(r.indexOf("")>=0)d+=r;else if(r=d+r,d="",t){"-"!==(r=a.strip(r))[r.length-1]&&(r+=" ");for(var i=[],n=0,s=!1,o=function(t){var o=a.strip(r.substring(n,t));if(o=o.replace(/\\([-_*|~])/g,"$1"),n=t+1,o.length>0){s&&(o=o.replace(/~/g," "));var c=r[t];return"_"!==c&&"-"!==c&&(c=" "),i.push({syllable:e.translateString(o),divider:c}),s=!1,!0}return!1},c=!1,l=0;l<r.length;l++){switch(r[l]){case" ":case"":o(l);break;case"-":!c&&!o(l)&&i.length>0&&(a.last(i).divider="-",i.push({skip:!0,to:"next"}));break;case"_":c||(o(l),i.push({skip:!0,to:"slur"}));break;case"*":c||(o(l),i.push({skip:!0,to:"next"}));break;case"|":c||(o(l),i.push({skip:!0,to:"bar"}));break;case"~":c||(s=!0)}c="\\"===r[l]}t.forEach((function(e){if(0!==i.length)if(i[0].skip){switch(i[0].to){case"next":case"slur":"note"===e.el_type&&null!==e.pitches&&i.shift();break;case"bar":"bar"===e.el_type&&i.shift()}"bar"!==e.el_type&&(void 0===e.lyric?e.lyric=[{syllable:"",divider:" "}]:e.lyric.push({syllable:"",divider:" "}))}else if("note"===e.el_type&&void 0===e.rest){var t=i.shift();t.syllable&&(t.syllable=t.syllable.replace(/ +/g," ")),void 0===e.lyric?e.lyric=[t]:e.lyric.push(t)}}))}else y("Can't add words before the first line of music",t,0)},k=function(t,r){if(r.indexOf("")>=0)u+=r;else if(r=u+r,u="",t){"-"!==(r=a.strip(r))[r.length-1]&&(r+=" ");for(var i=[],n=0,s=!1,o=function(t){var o=a.strip(r.substring(n,t));if(n=t+1,o.length>0){s&&(o=o.replace(/~/g," "));var c=r[t];return"_"!==c&&"-"!==c&&(c=" "),i.push({syllable:e.translateString(o),divider:c}),s=!1,!0}return!1},c=0;c<r.length;c++)switch(r[c]){case" ":case"":o(c);break;case"-":!o(c)&&i.length>0&&(a.last(i).divider="-",i.push({skip:!0,to:"next"}));break;case"_":o(c),i.push({skip:!0,to:"slur"});break;case"*":o(c),i.push({skip:!0,to:"next"});break;case"|":o(c),i.push({skip:!0,to:"bar"});break;case"~":s=!0}t.forEach((function(e){if(0!==i.length)if(i[0].skip)switch(i[0].to){case"next":case"slur":"note"===e.el_type&&null!==e.pitches&&i.shift();break;case"bar":"bar"===e.el_type&&i.shift()}else if("note"===e.el_type&&void 0===e.rest){var t=i.shift();void 0===e.lyric?e.lyric=[t]:e.lyric.push(t)}}))}else y("Can't add symbols before the first line of music",t,0)},w=function(e){if(a.startsWith(e,"%%")){var t=i.addDirective(e.substring(2));t&&y(t,e,2)}else{var n=e.indexOf("%");if(n>=0&&(e=e.substring(0,n)),0!==(e=e.replace(/\s+$/,"")).length)if(d)x(r.getCurrentVoice(),e.substring(2));else if(u)k(r.getCurrentVoice(),e.substring(2));else if(e.length<2||":"!==e[1]||g.lineContinuation)g.parseMusic(e);else{var s=m.parseHeader(e);s.regular&&g.parseMusic(e),s.newline&&g.startNewLine(),s.words&&x(r.getCurrentVoice(),e.substring(2)),s.symbols&&k(r.getCurrentVoice(),e.substring(2))}}};function T(e,t){e.push({el_type:"hint"});for(var r=0;r<t.length;r++){var a=t[r],i=Object.assign({},a);if(e.push(i),"bar"===a.el_type)return}}function C(e,t){for(var r=0;r<e.length;r++){var a=e[r],i=t[r];if(i)for(var n=0;n<i.voices.length;n++){var s=i.voices[n],o=a.voices[n];o&&T(o,s)}}}this.parse=function(l,h,f){h||(h={}),f||(f=0),t.reset();var p=(l=l.replace(/\r\n?/g,"\n")+"\n").split("\n\\");if(p.length>1){for(var b=1;b<p.length;b++)for(;p[b].length>0&&"\n"!==p[b][0];)p[b]=p[b].substr(1),p[b-1]+=" ";l=p.join(" ")}var T=(l=l.replace(/\\([ \t]*)(%.*)*\n/g,(function(e,t,r){return t+""+(r?Array(r.length+1).join(" "):"")+"\n"}))).split("\n");0===a.last(T).length&&T.pop(),e=new o(T,v),m=new n(e,y,v,t,r),g=new s(e,y,v,t,r,m),h.print&&(t.media="print"),v.reset(),v.iChar=f,h.visualTranspose?(v.globalTranspose=parseInt(h.visualTranspose),0===v.globalTranspose?v.globalTranspose=void 0:r.setVisualTranspose(h.visualTranspose)):v.globalTranspose=void 0,h.lineBreaks&&(v.lineBreaks=h.lineBreaks),m.reset(e,y,v,t);try{h.format&&i.globalFormatting(h.format);for(var S=e.nextLine();S;){if(h.header_only&&!1===v.is_in_header)throw"normal_abort";if(h.stop_on_warning&&v.warnings)throw"normal_abort";var E=v.is_in_header;w(S),E&&!v.is_in_header&&(r.setRunningFont("annotationfont",v.annotationfont),r.setRunningFont("gchordfont",v.gchordfont),r.setRunningFont("tripletfont",v.tripletfont),r.setRunningFont("vocalfont",v.vocalfont)),S=e.nextLine()}d&&x(r.getCurrentVoice(),""),u&&k(r.getCurrentVoice(),""),v.openSlurs=r.cleanUp(v.barsperstaff,v.staffnonote,v.openSlurs)}catch(e){if("normal_abort"!==e)throw e}var M=792,N=612;switch(v.papersize){case"legal":M=1008,N=612;break;case"A4":M=842.4,N=597.6}if(v.landscape){var _=M;M=N,N=_}t.formatting.pagewidth||(t.formatting.pagewidth=N),t.formatting.pageheight||(t.formatting.pageheight=M),h.hint_measures&&function(){for(var e=0;e<t.lines.length;e++){var r=t.lines[e].staff;if(r){for(var a=e+1;a<t.lines.length&&void 0===t.lines[a].staff;)a++;a<t.lines.length&&C(r,t.lines[a].staff)}}}(),c.wrapLines(t,v.lineBreaks,v.barNumbers)}}},9565:function(e,t,r){var a=r(5008);e.exports=function(e){"use strict";for(var t="",r=e.match(/(\s*)/),i=(e=a.strip(e)).split("\nX:"),n=1;n<i.length;n++)i[n]="X:"+i[n];var s=r?r[0].length:0,o=[];i.forEach((function(e){o.push({abc:e,startPos:s}),s+=e.length+1})),o.length>1&&!a.startsWith(o[0].abc,"X:")&&o.shift().abc.split("\n").forEach((function(e){a.startsWith(e,"%%")&&(t+=e+"\n")}));var c=t;return o.forEach((function(e){var r=e.abc.indexOf("\n\n");r>0&&(e.abc=e.abc.substring(0,r)),e.pure=e.abc,e.abc=t+e.abc,e.title="";var i=e.pure.split("T:");i.length>1&&(i=i[1].split("\n"),e.title=a.strip(i[0]));var n=e.pure.substring(2,e.pure.indexOf("\n"));e.id=a.strip(n)})),{header:c,tunes:o}}},8360:function(e,t,r){var a=r(5008),i={};!function(){"use strict";var e,t,r,n,s;i.initialize=function(a,i,o,c,l){e=a,t=i,n=c,s=l,(r=o).annotationfont={face:"Helvetica",size:12,weight:"normal",style:"normal",decoration:"none"},r.gchordfont={face:"Helvetica",size:12,weight:"normal",style:"normal",decoration:"none"},r.historyfont={face:'"Times New Roman"',size:16,weight:"normal",style:"normal",decoration:"none"},r.infofont={face:'"Times New Roman"',size:14,weight:"normal",style:"italic",decoration:"none"},r.measurefont={face:'"Times New Roman"',size:14,weight:"normal",style:"italic",decoration:"none"},r.partsfont={face:'"Times New Roman"',size:15,weight:"normal",style:"normal",decoration:"none"},r.repeatfont={face:'"Times New Roman"',size:13,weight:"normal",style:"normal",decoration:"none"},r.textfont={face:'"Times New Roman"',size:16,weight:"normal",style:"normal",decoration:"none"},r.tripletfont={face:"Times",size:11,weight:"normal",style:"italic",decoration:"none"},r.vocalfont={face:'"Times New Roman"',size:13,weight:"bold",style:"normal",decoration:"none"},r.wordsfont={face:'"Times New Roman"',size:16,weight:"normal",style:"normal",decoration:"none"},n.formatting.composerfont={face:'"Times New Roman"',size:14,weight:"normal",style:"italic",decoration:"none"},n.formatting.subtitlefont={face:'"Times New Roman"',size:16,weight:"normal",style:"normal",decoration:"none"},n.formatting.tempofont={face:'"Times New Roman"',size:15,weight:"bold",style:"normal",decoration:"none"},n.formatting.titlefont={face:'"Times New Roman"',size:20,weight:"normal",style:"normal",decoration:"none"},n.formatting.footerfont={face:'"Times New Roman"',size:12,weight:"normal",style:"normal",decoration:"none"},n.formatting.headerfont={face:'"Times New Roman"',size:12,weight:"normal",style:"normal",decoration:"none"},n.formatting.voicefont={face:'"Times New Roman"',size:13,weight:"bold",style:"normal",decoration:"none"},n.formatting.tablabelfont={face:'"Trebuchet MS"',size:16,weight:"normal",style:"normal",decoration:"none"},n.formatting.tabnumberfont={face:'"Arial"',size:11,weight:"normal",style:"normal",decoration:"none"},n.formatting.tabgracefont={face:'"Arial"',size:8,weight:"normal",style:"normal",decoration:"none"},n.formatting.annotationfont=r.annotationfont,n.formatting.gchordfont=r.gchordfont,n.formatting.historyfont=r.historyfont,n.formatting.infofont=r.infofont,n.formatting.measurefont=r.measurefont,n.formatting.partsfont=r.partsfont,n.formatting.repeatfont=r.repeatfont,n.formatting.textfont=r.textfont,n.formatting.tripletfont=r.tripletfont,n.formatting.vocalfont=r.vocalfont,n.formatting.wordsfont=r.wordsfont};var o={gchordfont:!0,measurefont:!0,partsfont:!0,annotationfont:!0,composerfont:!0,historyfont:!0,infofont:!0,subtitlefont:!0,textfont:!0,titlefont:!0,voicefont:!0},c=function(e,r,a,i,n){function s(){var s=parseInt(e[0].token);return e.shift(),r?0===e.length?{face:r.face,weight:r.weight,style:r.style,decoration:r.decoration,size:s}:1===e.length&&"box"===e[0].token&&o[n]?{face:r.face,weight:r.weight,style:r.style,decoration:r.decoration,size:s,box:!0}:(t("Extra parameters in font definition.",a,i),{face:r.face,weight:r.weight,style:r.style,decoration:r.decoration,size:s}):(t("Can't set just the size of the font since there is no default value.",a,i),{face:'"Times New Roman"',weight:"normal",style:"normal",decoration:"none",size:s})}if("*"===e[0].token){if(e.shift(),"number"===e[0].type)return s();t("Expected font size number after *.",a,i)}if("number"===e[0].type)return s();for(var c,l=[],h="normal",d="normal",u="none",f=!1,p="face",m=!1;e.length;){var g=e.shift(),v=g.token.toLowerCase();switch(p){case"face":m||"utf"!==v&&"number"!==g.type&&"bold"!==v&&"italic"!==v&&"underline"!==v&&"box"!==v?l.length>0&&"-"===g.token?(m=!0,l[l.length-1]=l[l.length-1]+g.token):m?(m=!1,l[l.length-1]=l[l.length-1]+g.token):l.push(g.token):"number"===g.type?(c?t("Font size specified twice in font definition.",a,i):c=g.token,p="modifier"):"bold"===v?h="bold":"italic"===v?d="italic":"underline"===v?u="underline":"box"===v?(o[n]?f=!0:t('This font style doesn\'t support "box"',a,i),p="finished"):"utf"===v?(g=e.shift(),p="size"):t("Unknown parameter "+g.token+" in font definition.",a,i);break;case"size":"number"===g.type?c?t("Font size specified twice in font definition.",a,i):c=g.token:t("Expected font size in font definition.",a,i),p="modifier";break;case"modifier":"bold"===v?h="bold":"italic"===v?d="italic":"underline"===v?u="underline":"box"===v?(o[n]?f=!0:t('This font style doesn\'t support "box"',a,i),p="finished"):t("Unknown parameter "+g.token+" in font definition.",a,i);break;case"finished":t('Extra characters found after "box" in font definition.',a,i)}}void 0===c?r?c=r.size:(t("Must specify the size of the font since there is no default value.",a,i),c=12):c=parseFloat(c),""===(l=l.join(" "))&&(r?l=r.face:(t("Must specify the name of the font since there is no default value.",a,i),l="sans-serif"));var b=function(e){switch(e){case"Arial-Italic":return{face:"Arial",weight:"normal",style:"italic",decoration:"none"};case"Arial-Bold":return{face:"Arial",weight:"bold",style:"normal",decoration:"none"};case"Bookman-Demi":return{face:"Bookman,serif",weight:"bold",style:"normal",decoration:"none"};case"Bookman-DemiItalic":return{face:"Bookman,serif",weight:"bold",style:"italic",decoration:"none"};case"Bookman-Light":return{face:"Bookman,serif",weight:"normal",style:"normal",decoration:"none"};case"Bookman-LightItalic":return{face:"Bookman,serif",weight:"normal",style:"italic",decoration:"none"};case"Courier":return{face:'"Courier New"',weight:"normal",style:"normal",decoration:"none"};case"Courier-Oblique":return{face:'"Courier New"',weight:"normal",style:"italic",decoration:"none"};case"Courier-Bold":return{face:'"Courier New"',weight:"bold",style:"normal",decoration:"none"};case"Courier-BoldOblique":return{face:'"Courier New"',weight:"bold",style:"italic",decoration:"none"};case"AvantGarde-Book":return{face:"AvantGarde,Arial",weight:"normal",style:"normal",decoration:"none"};case"AvantGarde-BookOblique":return{face:"AvantGarde,Arial",weight:"normal",style:"italic",decoration:"none"};case"AvantGarde-Demi":case"Avant-Garde-Demi":return{face:"AvantGarde,Arial",weight:"bold",style:"normal",decoration:"none"};case"AvantGarde-DemiOblique":return{face:"AvantGarde,Arial",weight:"bold",style:"italic",decoration:"none"};case"Helvetica-Oblique":return{face:"Helvetica",weight:"normal",style:"italic",decoration:"none"};case"Helvetica-Bold":return{face:"Helvetica",weight:"bold",style:"normal",decoration:"none"};case"Helvetica-BoldOblique":return{face:"Helvetica",weight:"bold",style:"italic",decoration:"none"};case"Helvetica-Narrow":return{face:'"Helvetica Narrow",Helvetica',weight:"normal",style:"normal",decoration:"none"};case"Helvetica-Narrow-Oblique":return{face:'"Helvetica Narrow",Helvetica',weight:"normal",style:"italic",decoration:"none"};case"Helvetica-Narrow-Bold":return{face:'"Helvetica Narrow",Helvetica',weight:"bold",style:"normal",decoration:"none"};case"Helvetica-Narrow-BoldOblique":return{face:'"Helvetica Narrow",Helvetica',weight:"bold",style:"italic",decoration:"none"};case"Palatino-Roman":return{face:"Palatino",weight:"normal",style:"normal",decoration:"none"};case"Palatino-Italic":return{face:"Palatino",weight:"normal",style:"italic",decoration:"none"};case"Palatino-Bold":return{face:"Palatino",weight:"bold",style:"normal",decoration:"none"};case"Palatino-BoldItalic":return{face:"Palatino",weight:"bold",style:"italic",decoration:"none"};case"NewCenturySchlbk-Roman":return{face:'"New Century",serif',weight:"normal",style:"normal",decoration:"none"};case"NewCenturySchlbk-Italic":return{face:'"New Century",serif',weight:"normal",style:"italic",decoration:"none"};case"NewCenturySchlbk-Bold":return{face:'"New Century",serif',weight:"bold",style:"normal",decoration:"none"};case"NewCenturySchlbk-BoldItalic":return{face:'"New Century",serif',weight:"bold",style:"italic",decoration:"none"};case"Times":case"Times-Roman":case"Times-Narrow":case"Times-Courier":case"Times-New-Roman":return{face:'"Times New Roman"',weight:"normal",style:"normal",decoration:"none"};case"Times-Italic":case"Times-Italics":return{face:'"Times New Roman"',weight:"normal",style:"italic",decoration:"none"};case"Times-Bold":return{face:'"Times New Roman"',weight:"bold",style:"normal",decoration:"none"};case"Times-BoldItalic":return{face:'"Times New Roman"',weight:"bold",style:"italic",decoration:"none"};case"ZapfChancery-MediumItalic":return{face:'"Zapf Chancery",cursive,serif',weight:"normal",style:"normal",decoration:"none"};default:return null}}(l),y={};return b?(y.face=b.face,y.weight=b.weight,y.style=b.style,y.decoration=b.decoration,y.size=c,f&&(y.box=!0),y):(y.face=l,y.weight=h,y.style=d,y.decoration=u,y.size=c,f&&(y.box=!0),y)},l=function(e,t,a){return 0===t.length?'Directive "'+e+'" requires a font as a parameter.':(r[e]=c(t,r[e],a,0,e),r.is_in_header&&(n.formatting[e]=r[e]),null)},h=function(e,t){var r="";t.forEach((function(e){r+=e.token}));var a=parseFloat(r);if(isNaN(a)||0===a)return'Directive "'+e+'" requires a number as a parameter.';n.formatting.scale=a},d=["acoustic-bass-drum","bass-drum-1","side-stick","acoustic-snare","hand-clap","electric-snare","low-floor-tom","closed-hi-hat","high-floor-tom","pedal-hi-hat","low-tom","open-hi-hat","low-mid-tom","hi-mid-tom","crash-cymbal-1","high-tom","ride-cymbal-1","chinese-cymbal","ride-bell","tambourine","splash-cymbal","cowbell","crash-cymbal-2","vibraslap","ride-cymbal-2","hi-bongo","low-bongo","mute-hi-conga","open-hi-conga","low-conga","high-timbale","low-timbale","high-agogo","low-agogo","cabasa","maracas","short-whistle","long-whistle","short-guiro","long-guiro","claves","hi-wood-block","low-wood-block","mute-cuica","open-cuica","mute-triangle","open-triangle"],u=function(e,t,a,i,n){if(1!==a.length||"number"!==a[0].type)return'Directive "'+t+'" requires a number as a parameter.';var s=a[0].intt;return void 0!==i&&s<i?'Directive "'+t+'" requires a number greater than or equal to '+i+" as a parameter.":void 0!==n&&s>n?'Directive "'+t+'" requires a number less than or equal to '+n+" as a parameter.":(r[e]=s,null)},f=function(e,t,a){if(1===a.length&&("true"===a[0].token||"false"===a[0].token))return r[e]="true"===a[0].token,null;var i=u(e,t,a,0,1);return null!==i?i:(r[e]=1===r[e],null)},p=function(e,t,a,i){if(1!==a.length)return'Directive "'+t+'" requires one of [ '+i.join(", ")+" ] as a parameter.";for(var n=a[0].token,s=!1,o=0;!s&&o<i.length;o++)i[o]===n&&(s=!0);return s?(r[e]=n,null):'Directive "'+t+'" requires one of [ '+i.join(", ")+" ] as a parameter."},m=["nobarlines","barlines","beataccents","nobeataccents","droneon","droneoff","drumon","drumoff","fermatafixed","fermataproportional","gchordon","gchordoff","controlcombo","temperamentnormal","noportamento"],g=["gchord","ptstress","beatstring"],v=["bassvol","chordvol","c","channel","beatmod","deltaloudness","drumbars","gracedivider","makechordchannels","randomchordattack","chordattack","stressmodel","transpose","rtranspose","vol","volinc","gchordbars"],b=["program"],y=["ratio","snt","bendvelocity","pitchbend","control","temperamentlinear"],x=["beat"],k=["drone"],w=["portamento"],T=["expand","grace","trim"],C=["drum","chordname"],S=["bassprog","chordprog"];i.parseFontChangeLine=function(e){var t=(e=e.replace(/\$\$/g,"")).split("$");if(t.length>1&&r.setfont){var a=[];""!==t[0]&&a.push({text:t[0]});for(var i=1;i<t.length;i++)if("0"===t[i][0])a.push({text:t[i].substring(1).replace(/\x03/g,"$$")});else{var n=parseInt(t[i][0],10);r.setfont[n]?a.push({font:r.setfont[n],text:t[i].substring(1).replace(/\x03/g,"$$")}):a[a.length-1].text+="$"+t[i].replace(/\x03/g,"$$")}return a}return e.replace(/\x03/g,"$$")};var E=["auto","above","below","hidden"];function M(e){if(0===e.length)return{value:1};if(1===e.length)if("number"===e[0].type){if(e[0].floatt>=0||e[0].floatt<=1)return{value:e[0].floatt}}else{if("false"===e[0].token)return{value:0};if("true"===e[0].token)return{value:1}}return{error:"Directive stretchlast requires zero or one parameter: false, true, or number between 0 and 1 (received "+e[0].token+")"}}i.addDirective=function(o){var N=e.tokenize(o,0,o.length);if(0===N.length||"alpha"!==N[0].type)return null;var _=o.substring(o.indexOf(N[0].token)+N[0].token.length);_=e.stripComment(_);var A,B=N.shift().token.toLowerCase(),P="";switch(B){case"bagpipes":n.formatting.bagpipes=!0;break;case"flatbeams":n.formatting.flatbeams=!0;break;case"jazzchords":n.formatting.jazzchords=!0;break;case"accentAbove":n.formatting.accentAbove=!0;break;case"germanAlphabet":n.formatting.germanAlphabet=!0;break;case"landscape":r.landscape=!0;break;case"papersize":r.papersize=_;break;case"graceslurs":if(1!==N.length)return"Directive graceslurs requires one parameter: 0 or 1";if("0"===N[0].token||"false"===N[0].token)n.formatting.graceSlurs=!1;else{if("1"!==N[0].token&&"true"!==N[0].token)return"Directive graceslurs requires one parameter: 0 or 1 (received "+N[0].token+")";n.formatting.graceSlurs=!0}break;case"lineThickness":var L=M(N);if(void 0!==L.value&&(n.formatting.lineThickness=L.value),L.error)return L.error;break;case"stretchlast":var z=M(N);if(void 0!==z.value&&(n.formatting.stretchlast=z.value),z.error)return z.error;break;case"titlecaps":r.titlecaps=!0;break;case"titleleft":n.formatting.titleleft=!0;break;case"measurebox":n.formatting.measurebox=!0;break;case"vocal":return p("vocalPosition",B,N,E);case"dynamic":return p("dynamicPosition",B,N,E);case"gchord":return p("chordPosition",B,N,E);case"ornament":return p("ornamentPosition",B,N,E);case"volume":return p("volumePosition",B,N,E);case"botmargin":case"botspace":case"composerspace":case"indent":case"leftmargin":case"linesep":case"musicspace":case"partsspace":case"pageheight":case"pagewidth":case"rightmargin":case"stafftopmargin":case"staffsep":case"staffwidth":case"subtitlespace":case"sysstaffsep":case"systemsep":case"textspace":case"titlespace":case"topmargin":case"topspace":case"vocalspace":case"wordsspace":return function(t,r){var a=e.getMeasurement(r);return 0===a.used||0!==r.length?'Directive "'+t+'" requires a measurement as a parameter.':(n.formatting[t]=a.value,null)}(B,N);case"voicescale":if(1!==N.length||"number"!==N[0].type)return"voicescale requires one float as a parameter";var O=N.shift();return r.currentVoice&&(r.currentVoice.scale=O.floatt,s.changeVoiceScale(r.currentVoice.scale)),null;case"voicecolor":if(1!==N.length)return"voicecolor requires one string as a parameter";var H=N.shift();return r.currentVoice&&(r.currentVoice.color=H.token,s.changeVoiceColor(r.currentVoice.color)),null;case"vskip":var D=Math.round(function(t,r){var a=e.getMeasurement(r);return 0===a.used||0!==r.length?{error:'Directive "'+t+'" requires a measurement as a parameter.'}:a.value}(B,N));return D.error?D.error:(s.addSpacing(D),null);case"scale":h(B,N);break;case"sep":if(0===N.length)s.addSeparator(14,14,85,{startChar:r.iChar,endChar:r.iChar+5});else{var I=e.getMeasurement(N);if(0===I.used)return'Directive "'+B+'" requires 3 numbers: space above, space below, length of line';var F=I.value;if(0===(I=e.getMeasurement(N)).used)return'Directive "'+B+'" requires 3 numbers: space above, space below, length of line';var V=I.value;if(0===(I=e.getMeasurement(N)).used||0!==N.length)return'Directive "'+B+'" requires 3 numbers: space above, space below, length of line';var Y=I.value;s.addSeparator(F,V,Y,{startChar:r.iChar,endChar:r.iChar+_.length})}break;case"barsperstaff":if(null!==(P=u("barsperstaff",B,N)))return P;break;case"staffnonote":if(1!==N.length)return"Directive staffnonote requires one parameter: 0 or 1";if("0"===N[0].token)r.staffnonote=!0;else{if("1"!==N[0].token)return"Directive staffnonote requires one parameter: 0 or 1 (received "+N[0].token+")";r.staffnonote=!1}break;case"printtempo":if(null!==(P=f("printTempo",B,N)))return P;break;case"partsbox":if(null!==(P=f("partsBox",B,N)))return P;r.partsfont.box=r.partsBox;break;case"freegchord":if(null!==(P=f("freegchord",B,N)))return P;break;case"measurenb":case"barnumbers":if(null!==(P=u("barNumbers",B,N)))return P;break;case"setbarnb":if(1!==N.length||"number"!==N[0].type)return"Directive setbarnb requires a number as a parameter.";r.currBarNumber=s.setBarNumberImmediate(N[0].intt);break;case"keywarn":if(1!==N.length||"number"!==N[0].type||1!==N[0].intt&&0!==N[0].intt)return"Directive "+B+" requires 0 or 1 as a parameter.";r[B]=1===N[0].intt;break;case"begintext":var j="";for(A=e.nextLine();A&&0!==A.indexOf("%%endtext");){if(a.startsWith(A,"%%")){var G=A.substring(2);j+=G=G.trim()+"\n"}else j+=A.trim()+"\n";A=e.nextLine()}s.addText(j,{startChar:r.iChar,endChar:r.iChar+j.length+7});break;case"continueall":r.continueall=!0;break;case"beginps":for(A=e.nextLine();A&&0!==A.indexOf("%%endps");)e.nextLine();t("Postscript ignored",o,0);break;case"deco":_.length>0&&r.ignoredDecorations.push(_.substring(0,_.indexOf(" "))),t("Decoration redefinition ignored",o,0);break;case"text":var W=e.translateString(_);s.addText(i.parseFontChangeLine(W),{startChar:r.iChar,endChar:r.iChar+_.length+7});break;case"center":var q=e.translateString(_);s.addCentered(i.parseFontChangeLine(q));break;case"font":break;case"setfont":var X=e.tokenize(_,0,_.length);if(X.length>=4&&"-"===X[0].token&&"number"===X[1].type){var R=parseInt(X[1].token);R>=1&&R<=9&&(r.setfont||(r.setfont=[]),X.shift(),X.shift(),r.setfont[R]=c(X,r.setfont[R],o,0,"setfont"))}break;case"gchordfont":case"partsfont":case"tripletfont":case"vocalfont":case"textfont":case"annotationfont":case"historyfont":case"infofont":case"measurefont":case"repeatfont":case"wordsfont":return l(B,N,o);case"composerfont":case"subtitlefont":case"tempofont":case"titlefont":case"voicefont":case"footerfont":case"headerfont":return function(e,t,r){return 0===t.length?'Directive "'+e+'" requires a font as a parameter.':(n.formatting[e]=c(t,n.formatting[e],r,0,e),null)}(B,N,o);case"barlabelfont":case"barnumberfont":case"barnumfont":return l("measurefont",N,o);case"staves":case"score":r.score_is_present=!0;for(var U,K=function(e,t,i,n,s){(t||0===r.staves.length)&&r.staves.push({index:r.staves.length,numVoices:0});var o=a.last(r.staves);void 0!==i&&void 0===o.bracket&&(o.bracket=i),void 0!==n&&void 0===o.brace&&(o.brace=n),s&&(o.connectBarLines="end"),void 0===r.voices[e]&&(r.voices[e]={staffNum:o.index,index:o.numVoices},o.numVoices++)},$=!1,Q=!1,J=!1,Z=!1,ee=!1,te=!1,re=!1,ae=function(){if(re=!0,U){var e="start";U.staffNum>0&&("start"!==r.staves[U.staffNum-1].connectBarLines&&"continue"!==r.staves[U.staffNum-1].connectBarLines||(e="continue")),r.staves[U.staffNum].connectBarLines=e}};N.length;){var ie=N.shift();switch(ie.token){case"(":$?t("Can't nest parenthesis in %%score",o,ie.start):($=!0,Z=!0);break;case")":!$||Z?t("Unexpected close parenthesis in %%score",o,ie.start):$=!1;break;case"[":Q?t("Can't nest brackets in %%score",o,ie.start):(Q=!0,ee=!0);break;case"]":!Q||ee?t("Unexpected close bracket in %%score",o,ie.start):(Q=!1,r.staves[U.staffNum].bracket="end");break;case"{":J?t("Can't nest braces in %%score",o,ie.start):(J=!0,te=!0);break;case"}":!J||te?t("Unexpected close brace in %%score",o,ie.start):(J=!1,r.staves[U.staffNum].brace