/*! abcjs_plugin v6.6.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,n=r(8905),i=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=0&&h0,v=0;v=0&&(f=C.startChar,d=void 0===C.chord?h:null),C.chord&&(h=C),"bar"===C.el_type){if(p){var S={abc:i.abc.substring(f,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),u.push(S),f=null,p=!1}}else"note"===C.el_type&&(p=!0)}}r.push({header:l,measures:u,hasPickup:g})}return r}}(),e.exports=o},9447:function(e,t,r){var a=r(4914).relativeMajor,n={acc:"sharp",note:"f"},i={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"},f={acc:"flat",note:"A"},u={acc:"flat",note:"d"},p={acc:"flat",note:"G"},m={acc:"flat",note:"c"},g={"C#":[n,i,s,o,c,l,{acc:"sharp",note:"B"}],"F#":[n,i,s,o,c,l],B:[n,i,s,o,c],E:[n,i,s,o],A:[n,i,s],D:[n,i],G:[n],C:[],F:[h],Bb:[h,d],Eb:[h,d,f],Cm:[h,d,f],Ab:[h,d,f,u],Db:[h,d,f,u,p],Gb:[h,d,f,u,p,m],Cb:[h,d,f,u,p,m,{acc:"flat",note:"F"}],"A#":[h,d],"B#":[],"D#":[h,d,f],"E#":[h],"G#":[h,d,f,u],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","CIon","Amin","AAeo","Am","GMix","DDor","EPhr","FLyd","BLoc"],stepsFromC:0},Db:{modes:["DbMaj","DbIon","Bbmin","BbAeo","Bbm","AbMix","EbDor","FPhr","GbLyd","CLoc"],stepsFromC:1},D:{modes:["DMaj","DIon","Bmin","BAeo","Bm","AMix","EDor","F#Phr","GLyd","C#Loc"],stepsFromC:2},Eb:{modes:["EbMaj","EbIon","Cmin","CAeo","Cm","BbMix","FDor","GPhr","AbLyd","DLoc"],stepsFromC:3},E:{modes:["EMaj","EIon","C#min","C#Aeo","C#m","BMix","F#Dor","G#Phr","ALyd","D#Loc"],stepsFromC:4},F:{modes:["FMaj","FIon","Dmin","DAeo","Dm","CMix","GDor","APhr","BbLyd","ELoc"],stepsFromC:5},Gb:{modes:["GbMaj","GbIon","Ebmin","EbAeo","Ebm","DbMix","AbDor","BbPhr","CbLyd","FLoc"],stepsFromC:6},G:{modes:["GMaj","GIon","Emin","EAeo","Em","DMix","ADor","BPhr","CLyd","F#Loc"],stepsFromC:7},Ab:{modes:["AbMaj","AbIon","Fmin","FAeo","Fm","EbMix","BbDor","CPhr","DbLyd","GLoc"],stepsFromC:8},A:{modes:["AMaj","AIon","F#min","F#Aeo","F#m","EMix","BDor","C#Phr","DLyd","G#Loc"],stepsFromC:9},Bb:{modes:["BbMaj","BbIon","Gmin","GAeo","Gm","FMix","CDor","DPhr","EbLyd","ALoc"],stepsFromC:10},B:{modes:["BMaj","BIon","G#min","G#Aeo","G#m","F#Mix","C#Dor","D#Phr","ELyd","A#Loc"],stepsFromC:11},"C#":{modes:["C#Maj","C#Ion","A#min","A#Aeo","A#m","G#Mix","D#Dor","E#Phr","F#Lyd","B#Loc"],stepsFromC:1},"F#":{modes:["F#Maj","F#Ion","D#min","D#Aeo","D#m","C#Mix","G#Dor","A#Phr","BLyd","E#Loc"],stepsFromC:6},Cb:{modes:["CbMaj","CbIon","Abmin","AbAeo","Abm","GbMix","DbDor","EbPhr","FbLyd","BbLoc"],stepsFromC:11}},r=["maj","ion","min","aeo","m","mix","dor","phr","lyd","loc"],a=null;e.exports={relativeMajor:function(e){a||function(){a={};for(var e=Object.keys(t),r=0;r=0}}},6780:function(e,t,r){var a=r(5008),n=r(4331),i=r(1028),s=r(9716),o=r(351);e.exports=function(){function e(e,t,r,a){for(var n=0;n=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;e0&&e.value[0].num.indexOf("+")>0){var a=e.value[0].num.split("+");t=0;for(var n=0;ne)return c}}return null},this.addElementToEvents=function(e,t,r,n,i,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 f=[],u=0;u0)for(var s=i.staffs[0],o=s.absoluteY,c=o-s.top*n.STEP,l=i.staffs[i.staffs.length-1],h=(o=l.absoluteY)-l.bottom*n.STEP-c,d=i.voices,f=0;f0&&o["event"+p]&&(w="event"+p),p=Math.round(1e3*u),"bar"===T.type){var S=T.abcelem.type,E="bar_right_repeat"===S||"bar_dbl_repeat"===S,_="1"===T.abcelem.startEnding,M="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 N=0;y=-1;for(var A=m;A=0;i--){var s=e[i];"bar"===s.type?(s.top=a,s.nextTop=t,t=a,s.bottom=n,s.nextBottom=r,r=n):"event"===s.type&&(a=s.top,n=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;an.left&&(n.endX=Math.min(n.endX,s)):n.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*n),s},this.addUsefulCallbackInfo=function(e,t){for(var r=this.millisecondsPerMeasure(t),a=0;a0?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),n=1;e?r&&(n=e/a):e=a;var i=this.getBeatLength(),s=e/60,o=this.getBarLength()/i*t/s;o&&(o-=this.getPickupLength()/i/s);var c=i*s;return this.noteTimings=this.setupEvents(o,c,e,n),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=i(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=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),n=r(8360),i=r(9928),s=r(6476),o=r(1881),c=r(1756),l=r(6225),h=r(6780),d=r(575);e.exports=function(){"use strict";var e,t=new h,r=new d(t),f="",u="";function p(e,t,r){e.positioning||(e.positioning={}),e.positioning[t]=r}function m(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),t.chordGrid&&(e.chordGrid=t.chordGrid),e};var g,v,b={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&&p(e,"vocalPosition",this.vocalPosition),"auto"!==this.dynamicPosition&&p(e,"dynamicPosition",this.dynamicPosition),"auto"!==this.chordPosition&&p(e,"chordPosition",this.chordPosition),"auto"!==this.ornamentPosition&&p(e,"ornamentPosition",this.ornamentPosition),"auto"!==this.volumePosition&&p(e,"volumePosition",this.volumePosition),this.differentFont("annotationfont",t)&&m(e,"annotationfont",this.annotationfont),this.differentFont("gchordfont",t)&&m(e,"gchordfont",this.gchordfont),this.differentFont("vocalfont",t)&&m(e,"vocalfont",this.vocalfont),this.differentFont("tripletfont",t)&&m(e,"tripletfont",this.tripletfont)):"bar"===r&&("auto"!==this.dynamicPosition&&p(e,"dynamicPosition",this.dynamicPosition),"auto"!==this.chordPosition&&p(e,"chordPosition",this.chordPosition),"auto"!==this.ornamentPosition&&p(e,"ornamentPosition",this.ornamentPosition),"auto"!==this.volumePosition&&p(e,"volumePosition",this.volumePosition),this.differentFont("measurefont",t)&&m(e,"measurefont",this.measurefont),this.differentFont("repeatfont",t)&&m(e,"repeatfont",this.repeatfont))},duplicateStartEndingHoldOvers:function(){this.endingHoldOver={inTie:[],inTieChord:{}};for(var e=0;e/g,">")},x=function(t,r,a){r||(r=" ");var n=r[a];" "!==n&&n||(n="SPACE");var i,s=y(r.substring(a-64,a))+''+n+""+y(r.substring(a+1).substring(0,64));!function(e){b.warnings||(b.warnings=[]),b.warnings.push(e)}("Music Line:"+e.lineIndex+":"+(a+1)+": "+t+": "+s),i={message:t,line:r,startChar:b.iChar+a,column:a},b.warningObjects||(b.warningObjects=[]),b.warningObjects.push(i)};this.getWarnings=function(){return b.warnings},this.getWarningObjects=function(){return b.warningObjects};var k=function(t,r){if(r.indexOf("")>=0)f+=r;else if(r=f+r,f="",t){"-"!==(r=a.strip(r))[r.length-1]&&(r+=" ");for(var n=[],i=0,s=!1,o=function(t){var o=a.strip(r.substring(i,t));if(o=o.replace(/\\([-_*|~])/g,"$1"),i=t+1,o.length>0){s&&(o=o.replace(/~/g," "));var c=r[t];return"_"!==c&&"-"!==c&&(c=" "),n.push({syllable:e.translateString(o),divider:c}),s=!1,!0}return!1},c=!1,l=0;l0&&(a.last(n).divider="-",n.push({skip:!0,to:"next"}));break;case"_":c||(o(l),n.push({skip:!0,to:"slur"}));break;case"*":c||(o(l),n.push({skip:!0,to:"next"}));break;case"|":c||(o(l),n.push({skip:!0,to:"bar"}));break;case"~":c||(s=!0)}c="\\"===r[l]}t.forEach((function(e){if(0!==n.length)if(n[0].skip){switch(n[0].to){case"next":case"slur":"note"===e.el_type&&null!==e.pitches&&n.shift();break;case"bar":"bar"===e.el_type&&n.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=n.shift();t.syllable&&(t.syllable=t.syllable.replace(/ +/g," ")),void 0===e.lyric?e.lyric=[t]:e.lyric.push(t)}}))}else x("Can't add words before the first line of music",t,0)},w=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 n=[],i=0,s=!1,o=function(t){var o=a.strip(r.substring(i,t));if(i=t+1,o.length>0){s&&(o=o.replace(/~/g," "));var c=r[t];return"_"!==c&&"-"!==c&&(c=" "),n.push({syllable:e.translateString(o),divider:c}),s=!1,!0}return!1},c=0;c0&&(a.last(n).divider="-",n.push({skip:!0,to:"next"}));break;case"_":o(c),n.push({skip:!0,to:"slur"});break;case"*":o(c),n.push({skip:!0,to:"next"});break;case"|":o(c),n.push({skip:!0,to:"bar"});break;case"~":s=!0}t.forEach((function(e){if(0!==n.length)if(n[0].skip)switch(n[0].to){case"next":case"slur":"note"===e.el_type&&null!==e.pitches&&n.shift();break;case"bar":"bar"===e.el_type&&n.shift()}else if("note"===e.el_type&&void 0===e.rest){var t=n.shift();void 0===e.lyric?e.lyric=[t]:e.lyric.push(t)}}))}else x("Can't add symbols before the first line of music",t,0)},T=function(e){if(a.startsWith(e,"%%")){var t=n.addDirective(e.substring(2));t&&x(t,e,2)}else{var i=e.indexOf("%");if(i>=0&&(e=e.substring(0,i)),0!==(e=e.replace(/\s+$/,"")).length)if(f)k(r.getCurrentVoice(),e.substring(2));else if(u)w(r.getCurrentVoice(),e.substring(2));else if(e.length<2||":"!==e[1]||v.lineContinuation)v.parseMusic(e);else{var s=g.parseHeader(e);s.regular&&v.parseMusic(e),s.newline&&v.startNewLine(),s.words&&k(r.getCurrentVoice(),e.substring(2)),s.symbols&&w(r.getCurrentVoice(),e.substring(2))}}};function C(e,t){e.push({el_type:"hint"});for(var r=0;r1){for(var y=1;y0&&"\n"!==m[y][0];)m[y]=m[y].substr(1),m[y-1]+=" ";h=m.join(" ")}var C=(h=h.replace(/\\([ \t]*)(%.*)*\n/g,(function(e,t,r){return t+""+(r?Array(r.length+1).join(" "):"")+"\n"}))).split("\n");0===a.last(C).length&&C.pop(),e=new o(C,b),g=new i(e,x,b,t,r),v=new s(e,x,b,t,r,g),d.print&&(t.media="print"),b.reset(),b.iChar=p,d.visualTranspose?(b.globalTranspose=parseInt(d.visualTranspose),0===b.globalTranspose?b.globalTranspose=void 0:r.setVisualTranspose(d.visualTranspose)):b.globalTranspose=void 0,d.lineBreaks&&(b.lineBreaks=d.lineBreaks),g.reset(e,x,b,t);try{d.format&&n.globalFormatting(d.format);for(var E=e.nextLine();E;){if(d.header_only&&!1===b.is_in_header)throw"normal_abort";if(d.stop_on_warning&&b.warnings)throw"normal_abort";var _=b.is_in_header;T(E),_&&!b.is_in_header&&(r.setRunningFont("annotationfont",b.annotationfont),r.setRunningFont("gchordfont",b.gchordfont),r.setRunningFont("tripletfont",b.tripletfont),r.setRunningFont("vocalfont",b.vocalfont)),E=e.nextLine()}f&&k(r.getCurrentVoice(),""),u&&w(r.getCurrentVoice(),""),b.openSlurs=r.cleanUp(b.barsperstaff,b.staffnonote,b.openSlurs)}catch(e){if("normal_abort"!==e)throw e}var M=792,N=612;switch(b.papersize){case"legal":M=1008,N=612;break;case"A4":M=842.4,N=597.6}if(b.landscape){var A=M;M=N,N=A}if(t.formatting.pagewidth||(t.formatting.pagewidth=N),t.formatting.pageheight||(t.formatting.pageheight=M),d.hint_measures&&function(){for(var e=0;e1&&!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 n=e.pure.split("T:");n.length>1&&(n=n[1].split("\n"),e.title=a.strip(n[0]));var i=e.pure.substring(2,e.pure.indexOf("\n"));e.id=a.strip(i)})),{header:c,tunes:o}}},8360:function(e,t,r){var a=r(5008),n={};!function(){"use strict";var e,t,r,i,s;n.initialize=function(a,n,o,c,l){e=a,t=n,i=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"},i.formatting.composerfont={face:'"Times New Roman"',size:14,weight:"normal",style:"italic",decoration:"none"},i.formatting.subtitlefont={face:'"Times New Roman"',size:16,weight:"normal",style:"normal",decoration:"none"},i.formatting.tempofont={face:'"Times New Roman"',size:15,weight:"bold",style:"normal",decoration:"none"},i.formatting.titlefont={face:'"Times New Roman"',size:20,weight:"normal",style:"normal",decoration:"none"},i.formatting.footerfont={face:'"Times New Roman"',size:12,weight:"normal",style:"normal",decoration:"none"},i.formatting.headerfont={face:'"Times New Roman"',size:12,weight:"normal",style:"normal",decoration:"none"},i.formatting.voicefont={face:'"Times New Roman"',size:13,weight:"bold",style:"normal",decoration:"none"},i.formatting.tablabelfont={face:'"Trebuchet MS"',size:16,weight:"normal",style:"normal",decoration:"none"},i.formatting.tabnumberfont={face:'"Arial"',size:11,weight:"normal",style:"normal",decoration:"none"},i.formatting.tabgracefont={face:'"Arial"',size:8,weight:"normal",style:"normal",decoration:"none"},i.formatting.annotationfont=r.annotationfont,i.formatting.gchordfont=r.gchordfont,i.formatting.historyfont=r.historyfont,i.formatting.infofont=r.infofont,i.formatting.measurefont=r.measurefont,i.formatting.partsfont=r.partsfont,i.formatting.repeatfont=r.repeatfont,i.formatting.textfont=r.textfont,i.formatting.tripletfont=r.tripletfont,i.formatting.vocalfont=r.vocalfont,i.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,n,i){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[i]?{face:r.face,weight:r.weight,style:r.style,decoration:r.decoration,size:s,box:!0}:(t("Extra parameters in font definition.",a,n),{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,n),{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,n)}if("number"===e[0].type)return s();for(var c,l=[],h="normal",d="normal",f="none",u=!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,n):c=g.token,p="modifier"):"bold"===v?h="bold":"italic"===v?d="italic":"underline"===v?f="underline":"box"===v?(o[i]?u=!0:t('This font style doesn\'t support "box"',a,n),p="finished"):"utf"===v?(g=e.shift(),p="size"):t("Unknown parameter "+g.token+" in font definition.",a,n);break;case"size":"number"===g.type?c?t("Font size specified twice in font definition.",a,n):c=g.token:t("Expected font size in font definition.",a,n),p="modifier";break;case"modifier":"bold"===v?h="bold":"italic"===v?d="italic":"underline"===v?f="underline":"box"===v?(o[i]?u=!0:t('This font style doesn\'t support "box"',a,n),p="finished"):t("Unknown parameter "+g.token+" in font definition.",a,n);break;case"finished":t('Extra characters found after "box" in font definition.',a,n)}}void 0===c?r?c=r.size:(t("Must specify the size of the font since there is no default value.",a,n),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,n),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,u&&(y.box=!0),y):(y.face=l,y.weight=h,y.style=d,y.decoration=f,y.size=c,u&&(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&&(i.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.';i.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"],f=function(e,t,a,n,i){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!==n&&si?'Directive "'+t+'" requires a number less than or equal to '+i+" as a parameter.":(r[e]=s,null)},u=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 n=f(e,t,a,0,1);return null!==n?n:(r[e]=1===r[e],null)},p=function(e,t,a,n){if(1!==a.length)return'Directive "'+t+'" requires one of [ '+n.join(", ")+" ] as a parameter.";for(var i=a[0].token,s=!1,o=0;!s&&o1&&r.setfont){var a=[];""!==t[0]&&a.push({text:t[0]});for(var n=1;n=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+")"}}n.addDirective=function(o){var M=e.tokenize(o,0,o.length);if(0===M.length||"alpha"!==M[0].type)return null;var N=o.substring(o.indexOf(M[0].token)+M[0].token.length);N=e.stripComment(N);var A,B=M.shift().token.toLowerCase(),P="";switch(B){case"bagpipes":i.formatting.bagpipes=!0;break;case"flatbeams":i.formatting.flatbeams=!0;break;case"jazzchords":i.formatting.jazzchords=!0;break;case"accentAbove":i.formatting.accentAbove=!0;break;case"germanAlphabet":i.formatting.germanAlphabet=!0;break;case"landscape":r.landscape=!0;break;case"papersize":r.papersize=N;break;case"graceslurs":if(1!==M.length)return"Directive graceslurs requires one parameter: 0 or 1";if("0"===M[0].token||"false"===M[0].token)i.formatting.graceSlurs=!1;else{if("1"!==M[0].token&&"true"!==M[0].token)return"Directive graceslurs requires one parameter: 0 or 1 (received "+M[0].token+")";i.formatting.graceSlurs=!0}break;case"lineThickness":var L=_(M);if(void 0!==L.value&&(i.formatting.lineThickness=L.value),L.error)return L.error;break;case"stretchlast":var z=_(M);if(void 0!==z.value&&(i.formatting.stretchlast=z.value),z.error)return z.error;break;case"titlecaps":r.titlecaps=!0;break;case"titleleft":i.formatting.titleleft=!0;break;case"measurebox":i.formatting.measurebox=!0;break;case"vocal":return p("vocalPosition",B,M,E);case"dynamic":return p("dynamicPosition",B,M,E);case"gchord":return p("chordPosition",B,M,E);case"ornament":return p("ornamentPosition",B,M,E);case"volume":return p("volumePosition",B,M,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.':(i.formatting[t]=a.value,null)}(B,M);case"voicescale":if(1!==M.length||"number"!==M[0].type)return"voicescale requires one float as a parameter";var O=M.shift();return r.currentVoice&&(r.currentVoice.scale=O.floatt,s.changeVoiceScale(r.currentVoice.scale)),null;case"voicecolor":if(1!==M.length)return"voicecolor requires one string as a parameter";var H=M.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,M));return D.error?D.error:(s.addSpacing(D),null);case"scale":h(B,M);break;case"sep":if(0===M.length)s.addSeparator(14,14,85,{startChar:r.iChar,endChar:r.iChar+5});else{var I=e.getMeasurement(M);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(M)).used)return'Directive "'+B+'" requires 3 numbers: space above, space below, length of line';var V=I.value;if(0===(I=e.getMeasurement(M)).used||0!==M.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+N.length})}break;case"barsperstaff":if(null!==(P=f("barsperstaff",B,M)))return P;break;case"staffnonote":if(1!==M.length)return"Directive staffnonote requires one parameter: 0 or 1";if("0"===M[0].token)r.staffnonote=!0;else{if("1"!==M[0].token)return"Directive staffnonote requires one parameter: 0 or 1 (received "+M[0].token+")";r.staffnonote=!1}break;case"printtempo":if(null!==(P=u("printTempo",B,M)))return P;break;case"partsbox":if(null!==(P=u("partsBox",B,M)))return P;r.partsfont.box=r.partsBox;break;case"freegchord":if(null!==(P=u("freegchord",B,M)))return P;break;case"measurenb":case"barnumbers":if(null!==(P=f("barNumbers",B,M)))return P;break;case"setbarnb":if(1!==M.length||"number"!==M[0].type)return"Directive setbarnb requires a number as a parameter.";r.currBarNumber=s.setBarNumberImmediate(M[0].intt);break;case"keywarn":if(1!==M.length||"number"!==M[0].type||1!==M[0].intt&&0!==M[0].intt)return"Directive "+B+" requires 0 or 1 as a parameter.";r[B]=1===M[0].intt;break;case"begintext":var G="";for(A=e.nextLine();A&&0!==A.indexOf("%%endtext");){if(a.startsWith(A,"%%")){var j=A.substring(2);G+=j=j.trim()+"\n"}else G+=A.trim()+"\n";A=e.nextLine()}s.addText(G,{startChar:r.iChar,endChar:r.iChar+G.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":N.length>0&&r.ignoredDecorations.push(N.substring(0,N.indexOf(" "))),t("Decoration redefinition ignored",o,0);break;case"text":var W=e.translateString(N);s.addText(n.parseFontChangeLine(W),{startChar:r.iChar,endChar:r.iChar+N.length+7});break;case"center":var q=e.translateString(N);s.addCentered(n.parseFontChangeLine(q));break;case"font":break;case"setfont":var X=e.tokenize(N,0,N.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,M,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.':(i.formatting[e]=c(t,i.formatting[e],r,0,e),null)}(B,M,o);case"barlabelfont":case"barnumberfont":case"barnumfont":return l("measurefont",M,o);case"staves":case"score":r.score_is_present=!0;for(var U,K=function(e,t,n,i,s){(t||0===r.staves.length)&&r.staves.push({index:r.staves.length,numVoices:0});var o=a.last(r.staves);void 0!==n&&void 0===o.bracket&&(o.bracket=n),void 0!==i&&void 0===o.brace&&(o.brace=i),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}};M.length;){var ne=M.shift();switch(ne.token){case"(":$?t("Can't nest parenthesis in %%score",o,ne.start):($=!0,Z=!0);break;case")":!$||Z?t("Unexpected close parenthesis in %%score",o,ne.start):$=!1;break;case"[":Q?t("Can't nest brackets in %%score",o,ne.start):(Q=!0,ee=!0);break;case"]":!Q||ee?t("Unexpected close bracket in %%score",o,ne.start):(Q=!1,r.staves[U.staffNum].bracket="end");break;case"{":J?t("Can't nest braces in %%score",o,ne.start):(J=!0,te=!0);break;case"}":!J||te?t("Unexpected close brace in %%score",o,ne.start):(J=!1,r.staves[U.staffNum].brace="end");break;case"|":ae();break;default:for(var ie="";("alpha"===ne.type||"number"===ne.type)&&(ie+=ne.token,ne.continueId);)ne=M.shift();K(ie,!$||Z,ee?"start":Q?"continue":void 0,te?"start":J?"continue":void 0,re),Z=!1,ee=!1,te=!1,re=!1,U=r.voices[ie],"staves"===B&&ae()}}break;case"maxstaves":var se=e.getInt(N);0===se.digits?t("Expected number of staves in maxstaves"):se.value>0&&(i.formatting.maxStaves=se.value);break;case"newpage":var oe=e.getInt(N);s.addNewPage(0===oe.digits?-1:oe.value);break;case"abc":var ce=N.split(" ");switch(ce[0]){case"-copyright":case"-creator":case"-edited-by":case"-version":case"-charset":var le=ce.shift();s.addMetaText(B+le,ce.join(" "),{startChar:r.iChar,endChar:r.iChar+N.length+5});break;default:return"Unknown directive: "+B+ce[0]}break;case"header":case"footer":var he=e.getMeat(N,0,N.length);'"'===(he=N.substring(he.start,he.end))[0]&&'"'===he[he.length-1]&&(he=he.substring(1,he.length-1));var de=he.split("\t"),fe={};fe=1===de.length?{left:"",center:de[0],right:""}:2===de.length?{left:de[0],center:de[1],right:""}:{left:de[0],center:de[1],right:de[2]},de.length>3&&t("Too many tabs in "+B+": "+de.length+" found.",N,0),s.addMetaTextObj(B,fe,{startChar:r.iChar,endChar:r.iChar+o.length});break;case"midi":var ue=e.tokenize(N,0,N.length,!0);ue.length>0&&"="===ue[0].token&&ue.shift(),0===ue.length?t("Expected midi command",N,0):function(e,r,a){var n=e.shift().token,i=[];if(m.indexOf(n)>=0)0!==e.length&&t("Unexpected parameter in MIDI "+n,a,0);else if(g.indexOf(n)>=0)1!==e.length?t("Expected one parameter in MIDI "+n,a,0):i.push(e[0].token);else if(v.indexOf(n)>=0)1!==e.length?t("Expected one parameter in MIDI "+n,a,0):"number"!==e[0].type?t("Expected one integer parameter in MIDI "+n,a,0):i.push(e[0].intt);else if(b.indexOf(n)>=0)1!==e.length&&2!==e.length?t("Expected one or two parameters in MIDI "+n,a,0):"number"!==e[0].type||2===e.length&&"number"!==e[1].type?t("Expected integer parameter in MIDI "+n,a,0):(i.push(e[0].intt),2===e.length&&i.push(e[1].intt));else if(y.indexOf(n)>=0)2!==e.length?t("Expected two parameters in MIDI "+n,a,0):"number"!==e[0].type||"number"!==e[1].type?t("Expected two integer parameters in MIDI "+n,a,0):(i.push(e[0].intt),i.push(e[1].intt));else if(w.indexOf(n)>=0)2!==e.length?t("Expected two parameters in MIDI "+n,a,0):"alpha"!==e[0].type||"number"!==e[1].type?t("Expected one string and one integer parameters in MIDI "+n,a,0):(i.push(e[0].token),i.push(e[1].intt));else if("drummap"===n)2===e.length&&"alpha"===e[0].type&&"number"===e[1].type?(r.formatting||(r.formatting={}),r.formatting.midi||(r.formatting.midi={}),r.formatting.midi.drummap||(r.formatting.midi.drummap={}),r.formatting.midi.drummap[e[0].token]=e[1].intt,i=r.formatting.midi.drummap):3===e.length&&"punct"===e[0].type&&"alpha"===e[1].type&&"number"===e[2].type?(r.formatting||(r.formatting={}),r.formatting.midi||(r.formatting.midi={}),r.formatting.midi.drummap||(r.formatting.midi.drummap={}),r.formatting.midi.drummap[e[0].token+e[1].token]=e[2].intt,i=r.formatting.midi.drummap):t("Expected one note name and one integer parameter in MIDI "+n,a,0);else if(T.indexOf(n)>=0)3!==e.length||"number"!==e[0].type||"/"!==e[1].token||"number"!==e[2].type?t("Expected fraction parameter in MIDI "+n,a,0):(i.push(e[0].intt),i.push(e[2].intt));else if(x.indexOf(n)>=0)4!==e.length?t("Expected four parameters in MIDI "+n,a,0):"number"!==e[0].type||"number"!==e[1].type||"number"!==e[2].type||"number"!==e[3].type?t("Expected four integer parameters in MIDI "+n,a,0):(i.push(e[0].intt),i.push(e[1].intt),i.push(e[2].intt),i.push(e[3].intt));else if(k.indexOf(n)>=0)5!==e.length?t("Expected five parameters in MIDI "+n,a,0):"number"!==e[0].type||"number"!==e[1].type||"number"!==e[2].type||"number"!==e[3].type||"number"!==e[4].type?t("Expected five integer parameters in MIDI "+n,a,0):(i.push(e[0].intt),i.push(e[1].intt),i.push(e[2].intt),i.push(e[3].intt),i.push(e[4].intt));else if(b.indexOf(n)>=0)1!==e.length||4!==e.length?t("Expected one or two parameters in MIDI "+n,a,0):"number"!==e[0].type?t("Expected integer parameter in MIDI "+n,a,0):4===e.length?("octave"!==e[1].token&&t("Expected octave parameter in MIDI "+n,a,0),"="!==e[2].token&&t("Expected octave parameter in MIDI "+n,a,0),"number"!==e[3].type&&t("Expected integer parameter for octave in MIDI "+n,a,0)):(i.push(e[0].intt),4===e.length&&i.push(e[3].intt));else if(C.indexOf(n)>=0)if(e.length<2)t("Expected string parameter and at least one integer parameter in MIDI "+n,a,0);else if("alpha"!==e[0].type)t("Expected string parameter and at least one integer parameter in MIDI "+n,a,0);else{var o=e.shift();for(i.push(o.token);e.length>0;)"number"!==(o=e.shift()).type&&t("Expected integer parameter in MIDI "+n,a,0),i.push(o.intt)}else if(S.indexOf(n)>=0)if(1!==e.length&&2!==e.length)t("Expected one or two parameters in MIDI "+n,a,0);else if("number"!==e[0].type)t("Expected integer parameter in MIDI "+n,a,0);else if(2===e.length&&"alpha"!==e[1].type)t("Expected alpha parameter in MIDI "+n,a,0);else if(i.push(e[0].intt),2===e.length){var c=e[1].token;-1!=c.indexOf("octave=")?(c=c.replace("octave=",""),c=parseInt(c),isNaN(c)?t("Expected octave value in MIDI"+n):(c<-1&&(t("Expected octave= in MIDI "+n+" to be >= -1 (recv:"+c+")"),c=-1),c>3&&(t("Expected octave= in MIDI "+n+" to be <= 3 (recv:"+c+")"),c=3),i.push(c))):t("Expected octave= in MIDI"+n)}s.hasBeginMusic()?s.appendElement("midi",-1,-1,{cmd:n,params:i}):(void 0===r.formatting.midi&&(r.formatting.midi={}),r.formatting.midi[n]=i)}(ue,i,N);break;case"percmap":var pe=function(e){var t=e.split(/\s+/);if(2!==t.length&&3!==t.length)return{error:'Expected parameters "abc-note", "drum-sound", and optionally "note-head"'};var r=t[0],a=parseInt(t[1],10);if((isNaN(a)||a<35||a>81)&&t[1]&&(a=d.indexOf(t[1].toLowerCase())+35),isNaN(a)||a<35||a>81)return{error:'Expected drum name, received "'+t[1]+'"'};var n={sound:a};return 3===t.length&&(n.noteHead=t[2]),{key:r,value:n}}(N);pe.error?t(pe.error,o,8):(i.formatting.percmap||(i.formatting.percmap={}),i.formatting.percmap[pe.key]=pe.value);break;case"visualtranspose":var me=e.getInt(N);0===me.digits?t("Expected number of half steps in visualTranspose"):r.globalTranspose=me.value;break;case"map":case"playtempo":case"auquality":case"continuous":case"nobarcheck":i.formatting[B]=N;break;default:return"Unknown directive: "+B}return null},n.globalFormatting=function(a){for(var n in a)if(a.hasOwnProperty(n)){var s,o=""+a[n],c=e.tokenize(o,0,o.length);switch(n){case"titlefont":case"gchordfont":case"composerfont":case"footerfont":case"headerfont":case"historyfont":case"infofont":case"measurefont":case"partsfont":case"repeatfont":case"subtitlefont":case"tempofont":case"textfont":case"voicefont":case"tripletfont":case"vocalfont":case"wordsfont":case"annotationfont":case"tablabelfont":case"tabnumberfont":case"tabgracefont":l(n,c,o);break;case"scale":h(n,c);break;case"partsbox":null!==(s=u("partsBox",n,c))&&t(s),r.partsfont.box=r.partsBox;break;case"freegchord":null!==(s=u("freegchord",n,c))&&t(s);break;case"fontboxpadding":1===c.length&&"number"===c[0].type||t('Directive "'+n+'" requires a number as a parameter.'),i.formatting.fontboxpadding=c[0].floatt;break;case"stafftopmargin":1===c.length&&"number"===c[0].type||t('Directive "'+n+'" requires a number as a parameter.'),i.formatting.stafftopmargin=c[0].floatt;break;case"stretchlast":var d=_(c);if(void 0!==d.value&&(i.formatting.stretchlast=d.value),d.error)return d.error;break;default:t("Formatting directive unrecognized: ",n,0)}}}}(),e.exports=n},9928:function(e,t,r){var a=r(5008),n=r(8360),i=r(9708);e.exports=function(e,t,r,s,o){this.reset=function(e,t,r,a){i.initialize(e,t,r,a,o),n.initialize(e,t,r,a,o)},this.reset(e,t,r,s),this.setTitle=function(e,t){r.hasMainTitle?o.addSubtitle(e,{startChar:r.iChar,endChar:r.iChar+t+2}):(o.addMetaText("title",e,{startChar:r.iChar,endChar:r.iChar+t+2}),r.hasMainTitle=!0)},this.setMeter=function(a){if("C"===(a=e.stripComment(a)))return!0===r.havent_set_length&&(r.default_length=.125,r.havent_set_length=!1),{type:"common_time"};if("C|"===a)return!0===r.havent_set_length&&(r.default_length=.125,r.havent_set_length=!1),{type:"cut_time"};if("o"===a)return!0===r.havent_set_length&&(r.default_length=.125,r.havent_set_length=!1),{type:"tempus_perfectum"};if("c"===a)return!0===r.havent_set_length&&(r.default_length=.125,r.havent_set_length=!1),{type:"tempus_imperfectum"};if("o."===a)return!0===r.havent_set_length&&(r.default_length=.125,r.havent_set_length=!1),{type:"tempus_perfectum_prolatio"};if("c."===a)return!0===r.havent_set_length&&(r.default_length=.125,r.havent_set_length=!1),{type:"tempus_imperfectum_prolatio"};if(0===a.length||"none"===a.toLowerCase())return!0===r.havent_set_length&&(r.default_length=.125,r.havent_set_length=!1),null;var n=e.tokenize(a,0,a.length);try{var i=function(){var e=function(){var e={value:0,num:""},t=n.shift();for("("===t.token&&(t=n.shift());;){if("number"!==t.type)throw"Expected top number of meter";if(e.value+=parseInt(t.token),e.num+=t.token,0===n.length||"/"===n[0].token)return e;if(")"===(t=n.shift()).token){if(0===n.length||"/"===n[0].token)return e;throw"Unexpected paren in meter"}if("."!==t.token&&"+"!==t.token)throw"Expected top number of meter";if(e.num+=t.token,0===n.length)throw"Expected top number of meter";t=n.shift()}return e}();if(0===n.length)return e;var t=n.shift();if("/"!==t.token)throw"Expected slash in meter";if("number"!==(t=n.shift()).type)throw"Expected bottom number of meter";return e.den=t.token,e.value=e.value/parseInt(e.den),e};if(0===n.length)throw"Expected meter definition in M: line";for(var s={type:"specified",value:[]},o=0;;){var c=i();o+=c.value;var l={num:c.num};if(void 0!==c.den&&(l.den=c.den),s.value.push(l),0===n.length)break}return!0===r.havent_set_length&&(r.default_length=o<.75?.0625:.125,r.havent_set_length=!1),s}catch(e){t(e,a,0)}return null},this.calcTempo=function(e){var t=1/4;r.meter&&"specified"===r.meter.type?t=1/parseInt(r.meter.value[0].den):r.origMeter&&"specified"===r.origMeter.type&&(t=1/parseInt(r.origMeter.value[0].den));for(var a=0;a0&&(r.default_length=i/s,r.havent_set_length=!1)}else 1===n.length&&"1"===n[0]&&(r.default_length=1,r.havent_set_length=!1)};var c={larghissimo:20,adagissimo:24,sostenuto:28,grave:32,largo:40,lento:50,larghetto:60,adagio:68,adagietto:74,andante:80,andantino:88,"marcia moderato":84,"andante moderato":100,moderato:112,allegretto:116,"allegro moderato":120,allegro:126,animato:132,agitato:140,veloce:148,"mosso vivo":156,vivace:164,vivacissimo:172,allegrissimo:176,presto:184,prestissimo:210};this.setTempo=function(a,n,i,s){try{var o=e.tokenize(a,n,i);if(0===o.length)throw"Missing parameter in Q: field";var l={startChar:s+n-2,endChar:s+i},h=!0,d=o.shift();if("quote"===d.type&&(l.preString=d.token,d=o.shift(),0===o.length))return c[l.preString.toLowerCase()]&&(l.bpm=c[l.preString.toLowerCase()],l.suppressBpm=!0),{type:"immediate",tempo:l};if("alpha"===d.type&&"C"===d.token){if(0===o.length)throw"Missing tempo after C in Q: field";if("punct"===(d=o.shift()).type&&"="===d.token){if(0===o.length)throw"Missing tempo after = in Q: field";if("number"!==(d=o.shift()).type)throw"Expected number after = in Q: field";l.duration=[1],l.bpm=parseInt(d.token)}else{if("number"!==d.type)throw"Expected number or equal after C in Q: field";if(l.duration=[parseInt(d.token)],0===o.length)throw"Missing = after duration in Q: field";if("punct"!==(d=o.shift()).type||"="!==d.token)throw"Expected = after duration in Q: field";if(0===o.length)throw"Missing tempo after = in Q: field";if("number"!==(d=o.shift()).type)throw"Expected number after = in Q: field";l.bpm=parseInt(d.token)}}else{if("number"!==d.type)throw"Unknown value in Q: field";var f=parseInt(d.token);if(0===o.length||"quote"===o[0].type)l.duration=[1],l.bpm=f;else{if(h=!1,"punct"!==(d=o.shift()).type&&"/"!==d.token)throw"Expected fraction in Q: field";if("number"!==(d=o.shift()).type)throw"Expected fraction in Q: field";var u=parseInt(d.token);for(l.duration=[f/u];o.length>0&&"="!==o[0].token&&"quote"!==o[0].type;){if("number"!==(d=o.shift()).type)throw"Expected fraction in Q: field";if(f=parseInt(d.token),"punct"!==(d=o.shift()).type&&"/"!==d.token)throw"Expected fraction in Q: field";if("number"!==(d=o.shift()).type)throw"Expected fraction in Q: field";u=parseInt(d.token),l.duration.push(f/u)}if("punct"!==(d=o.shift()).type&&"="!==d.token)throw"Expected = in Q: field";if("number"!==(d=o.shift()).type)throw"Expected tempo in Q: field";l.bpm=parseInt(d.token)}}if(0!==o.length&&("quote"===(d=o.shift()).type&&(l.postString=d.token,d=o.shift()),0!==o.length))throw"Unexpected string at end of Q: field";return!1===r.printTempo&&(l.suppress=!0),{type:h?"delaySet":"immediate",tempo:l}}catch(e){return t(e,a,n),{type:"none"}}},this.letter_to_inline_header=function(a,c,l){var h=!1,d=e.eatWhiteSpace(a,c);if(c+=d,a.length>=c+5&&"["===a[c]&&":"===a[c+2]){var f=a.indexOf("]",c),u=r.iChar+c,p=r.iChar+f+1;switch(a.substring(c,c+3)){case"[I:":var m=n.addDirective(a.substring(c+3,f));return m&&t(m,a,c),[f-c+1+d];case"[M:":var g=this.setMeter(a.substring(c+3,f));return o.hasBeginMusic()&&g?o.appendStartingElement("meter",u,p,g):r.meter=g,[f-c+1+d];case"[K:":var v=i.parseKey(a.substring(c+3,f),!0);return v.foundClef&&o.hasBeginMusic()&&o.appendStartingElement("clef",u,p,r.clef),v.foundKey&&o.hasBeginMusic()&&o.appendStartingElement("key",u,p,i.fixKey(r.clef,r.key)),[f-c+1+d];case"[P:":var b=n.parseFontChangeLine(a.substring(c+3,f));return l||s.lines.length<=s.lineNum?r.partForNextLine={title:b,startChar:u,endChar:p}:o.appendElement("part",u,p,{title:b}),[f-c+1+d];case"[L:":return this.setDefaultLength(a,c+3,f),[f-c+1+d];case"[Q:":if(f>0){var y=this.setTempo(a,c+3,f,r.iChar);return"delaySet"===y.type?o.hasBeginMusic()?o.appendElement("tempo",u,p,this.calcTempo(y.tempo)):r.tempoForNextLine=["tempo",u,p,this.calcTempo(y.tempo)]:"immediate"===y.type&&(!l&&o.hasBeginMusic()?o.appendElement("tempo",u,p,y.tempo):r.tempoForNextLine=["tempo",u,p,y.tempo]),[f-c+1+d,a[c+1],a.substring(c+3,f)]}break;case"[V:":if(f>0)return h=i.parseVoice(a,c+3,f),[f-c+1+d,a[c+1],a.substring(c+3,f),h];break;case"[r:":return[f-c+1+d]}}return[0]},this.letter_to_body_header=function(e,s){var c=!1;if(e.length>=s+3)switch(e.substring(s,s+2)){case"I:":var l=n.addDirective(e.substring(s+2));return l&&t(l,e,s),[e.length];case"M:":var h=this.setMeter(e.substring(s+2));return o.hasBeginMusic()&&h&&o.appendStartingElement("meter",r.iChar+s,r.iChar+e.length,h),[e.length];case"K:":var d=i.parseKey(e.substring(s+2),o.hasBeginMusic());return d.foundClef&&o.hasBeginMusic()&&!1!==r.keywarn&&o.appendStartingElement("clef",r.iChar+s,r.iChar+e.length,r.clef),d.foundKey&&o.hasBeginMusic()&&!1!==r.keywarn&&o.appendStartingElement("key",r.iChar+s,r.iChar+e.length,i.fixKey(r.clef,r.key)),[e.length];case"P:":return o.hasBeginMusic()&&o.appendElement("part",r.iChar+s,r.iChar+e.length,{title:e.substring(s+2)}),[e.length];case"L:":return this.setDefaultLength(e,s+2,e.length),[e.length];case"Q:":var f=e.indexOf("",s+2);-1===f&&(f=e.length);var u=this.setTempo(e,s+2,f,r.iChar);return"delaySet"===u.type?o.appendElement("tempo",r.iChar+s,r.iChar+e.length,this.calcTempo(u.tempo)):"immediate"===u.type&&o.appendElement("tempo",r.iChar+s,r.iChar+e.length,u.tempo),[f,e[s],a.strip(e.substring(s+2))];case"V:":return c=i.parseVoice(e,s+2,e.length),[e.length,e[s],a.strip(e.substring(s+2)),c]}return[0]};var l={A:"author",B:"book",C:"composer",D:"discography",F:"url",G:"group",I:"instruction",N:"notes",O:"origin",R:"rhythm",S:"source",W:"unalignedWords",Z:"transcription"};this.parseHeader=function(a){var c=l[a[0]],h=a.length-2,d=e.translateString(e.stripComment(a.substring(2)));if("unalignedWords"===c||"notes"===c)o.addMetaTextArray(c,n.parseFontChangeLine(d),{startChar:r.iChar,endChar:r.iChar+a.length});else if(void 0!==c)o.addMetaText(c,n.parseFontChangeLine(d),{startChar:r.iChar,endChar:r.iChar+a.length});else{var f=r.iChar,u=f+a.length;switch(a[0]){case"H":for(o.addMetaTextArray("history",n.parseFontChangeLine(d),{startChar:r.iChar,endChar:r.iChar+a.length}),a=e.peekLine();a&&":"!==a[1];)e.nextLine(),o.addMetaTextArray("history",n.parseFontChangeLine(e.translateString(e.stripComment(a))),{startChar:r.iChar,endChar:r.iChar+a.length}),a=e.peekLine();break;case"K":this.resolveTempo();var p=i.parseKey(a.substring(2),!1);!r.is_in_header&&o.hasBeginMusic()&&!1!==r.keywarn&&(p.foundClef&&o.appendStartingElement("clef",f,u,r.clef),p.foundKey&&o.appendStartingElement("key",f,u,i.fixKey(r.clef,r.key))),r.is_in_header=!1;break;case"L":this.setDefaultLength(a,2,a.length);break;case"M":r.origMeter=r.meter=this.setMeter(a.substring(2));break;case"P":r.is_in_header?o.addMetaText("partOrder",n.parseFontChangeLine(d),{startChar:r.iChar,endChar:r.iChar+a.length}):r.partForNextLine={title:d,startChar:f,endChar:u};break;case"Q":var m=this.setTempo(a,2,a.length,r.iChar);"delaySet"===m.type?r.tempo=m.tempo:"immediate"===m.type&&(s.metaText.tempo?r.tempoForNextLine=["tempo",f,u,m.tempo]:s.metaText.tempo=m.tempo);break;case"T":r.titlecaps&&(d=d.toUpperCase()),this.setTitle(n.parseFontChangeLine(e.theReverser(d)),h);break;case"U":this.addUserDefinition(a,2,a.length);break;case"V":if(i.parseVoice(a,2,a.length),!r.is_in_header)return{newline:!0};break;case"s":return{symbols:!0};case"w":return{words:!0};case"X":break;case"E":case"m":t("Ignored header",a,0);break;default:return{regular:!0}}}return{}}}},9708:function(e,t,r){var a=r(8360),n=r(2821),i={};!function(){var e,t,r,s;i.initialize=function(a,n,i,o,c){e=a,t=n,r=i,s=c},i.standardKey=function(e,t,a,i){return n.keySignature(r,e,t,a,i)};var o={treble:{clef:"treble",pitch:4,mid:0},"treble+8":{clef:"treble+8",pitch:4,mid:0},"treble-8":{clef:"treble-8",pitch:4,mid:0},"treble^8":{clef:"treble+8",pitch:4,mid:0},treble_8:{clef:"treble-8",pitch:4,mid:0},treble1:{clef:"treble",pitch:2,mid:2},treble2:{clef:"treble",pitch:4,mid:0},treble3:{clef:"treble",pitch:6,mid:-2},treble4:{clef:"treble",pitch:8,mid:-4},treble5:{clef:"treble",pitch:10,mid:-6},perc:{clef:"perc",pitch:6,mid:0},none:{clef:"none",mid:0},bass:{clef:"bass",pitch:8,mid:-12},"bass+8":{clef:"bass+8",pitch:8,mid:-12},"bass-8":{clef:"bass-8",pitch:8,mid:-12},"bass^8":{clef:"bass+8",pitch:8,mid:-12},bass_8:{clef:"bass-8",pitch:8,mid:-12},"bass+16":{clef:"bass",pitch:8,mid:-12},"bass-16":{clef:"bass",pitch:8,mid:-12},"bass^16":{clef:"bass",pitch:8,mid:-12},bass_16:{clef:"bass",pitch:8,mid:-12},bass1:{clef:"bass",pitch:2,mid:-6},bass2:{clef:"bass",pitch:4,mid:-8},bass3:{clef:"bass",pitch:6,mid:-10},bass4:{clef:"bass",pitch:8,mid:-12},bass5:{clef:"bass",pitch:10,mid:-14},tenor:{clef:"alto",pitch:8,mid:-8},tenor1:{clef:"alto",pitch:2,mid:-2},tenor2:{clef:"alto",pitch:4,mid:-4},tenor3:{clef:"alto",pitch:6,mid:-6},tenor4:{clef:"alto",pitch:8,mid:-8},tenor5:{clef:"alto",pitch:10,mid:-10},alto:{clef:"alto",pitch:6,mid:-6},alto1:{clef:"alto",pitch:2,mid:-2},alto2:{clef:"alto",pitch:4,mid:-4},alto3:{clef:"alto",pitch:6,mid:-6},alto4:{clef:"alto",pitch:8,mid:-8},alto5:{clef:"alto",pitch:10,mid:-10},"alto+8":{clef:"alto+8",pitch:6,mid:-6},"alto-8":{clef:"alto-8",pitch:6,mid:-6},"alto^8":{clef:"alto+8",pitch:6,mid:-6},alto_8:{clef:"alto-8",pitch:6,mid:-6}},c=function(e,t){var r=o[e];return(r?r.mid:0)+t};i.fixClef=function(e){var t=o[e.type];t&&(e.clefPos=t.pitch,e.type=t.clef)},i.deepCopyKey=function(e){var t={accidentals:[],root:e.root,acc:e.acc,mode:e.mode};return e.accidentals.forEach((function(e){t.accidentals.push(Object.assign({},e))})),t};var l={A:5,B:6,C:0,D:1,E:2,F:3,G:4,a:12,b:13,c:7,d:8,e:9,f:10,g:11};i.addPosToKey=function(e,t){var r=e.verticalPos;t.accidentals.forEach((function(e){var t=l[e.note];t-=r,e.verticalPos=t})),t.impliedNaturals&&t.impliedNaturals.forEach((function(e){var t=l[e.note];t-=r,e.verticalPos=t})),r<-10?(t.accidentals.forEach((function(e){e.verticalPos-=7,(e.verticalPos>=11||10===e.verticalPos&&"flat"===e.acc)&&(e.verticalPos-=7),"A"===e.note&&"sharp"===e.acc&&(e.verticalPos-=7),"G"!==e.note&&"F"!==e.note||"flat"!==e.acc||(e.verticalPos-=7)})),t.impliedNaturals&&t.impliedNaturals.forEach((function(e){e.verticalPos-=7,(e.verticalPos>=11||10===e.verticalPos&&"flat"===e.acc)&&(e.verticalPos-=7),"A"===e.note&&"sharp"===e.acc&&(e.verticalPos-=7),"G"!==e.note&&"F"!==e.note||"flat"!==e.acc||(e.verticalPos-=7)}))):r<-4?(t.accidentals.forEach((function(e){e.verticalPos-=7,-8!==r||"f"!==e.note&&"g"!==e.note||"sharp"!==e.acc||(e.verticalPos-=7)})),t.impliedNaturals&&t.impliedNaturals.forEach((function(e){e.verticalPos-=7,-8!==r||"f"!==e.note&&"g"!==e.note||"sharp"!==e.acc||(e.verticalPos-=7)}))):r>=7&&(t.accidentals.forEach((function(e){e.verticalPos+=7})),t.impliedNaturals&&t.impliedNaturals.forEach((function(e){e.verticalPos+=7})))},i.fixKey=function(e,t){var r=Object.assign({},t);return i.addPosToKey(e,r),r};var h=function(e){var t=0,r=e[t++];"^"!==r&&"_"!==r||(r=e[t++]);var a=l[r];for(void 0===a&&(a=6);t0){l.foundKey=!0;var d="",f="";o[0].token.length>1?o[0].token=o[0].token.substring(1):o.shift();var u=h.token;if(o.length>0){var p=e.getSharpFlat(o[0].token);if(p.len>0&&(o[0].token.length>1?o[0].token=o[0].token.substring(1):o.shift(),u+=p.token,d=p.token),o.length>0){var m=e.getMode(o[0].token);m.len>0&&(o.shift(),u+=m.token,f=m.token)}if(void 0===i.standardKey(u,h.token,d,0))return t("Unsupported key signature: "+u,n,0),l}var g,v=i.deepCopyKey(r.key),b=!s&&r.globalTranspose?-r.globalTranspose:0;if(s&&(g=r.globalTransposeOrigKeySig),r.key=i.deepCopyKey(i.standardKey(u,h.token,d,b)),s&&(r.globalTransposeOrigKeySig=g),r.key.mode=f,v&&!1!==r.keywarn){for(var y,x=0;x0;)switch(o[0].token){case"m":case"middle":if(o.shift(),0===o.length)return t("Expected = after middle",n,0),l;if("="!==(k=o.shift()).token){t("Expected = after middle",n,k.start);break}if(0===o.length)return t("Expected parameter after middle=",n,0),l;var _=e.getPitchFromTokens(o);_.warn&&t(_.warn,n,0),_.position&&(r.clef.verticalPos=_.position-6);break;case"transpose":if(o.shift(),0===o.length)return t("Expected = after transpose",n,0),l;if("="!==(k=o.shift()).token){t("Expected = after transpose",n,k.start);break}if(0===o.length)return t("Expected parameter after transpose=",n,0),l;if("number"!==o[0].type){t("Expected number after transpose",n,o[0].start);break}r.clef.transpose=o[0].intt,o.shift();break;case"stafflines":if(o.shift(),0===o.length)return t("Expected = after stafflines",n,0),l;if("="!==(k=o.shift()).token){t("Expected = after stafflines",n,k.start);break}if(0===o.length)return t("Expected parameter after stafflines=",n,0),l;if("number"!==o[0].type){t("Expected number after stafflines",n,o[0].start);break}r.clef.stafflines=o[0].intt,o.shift();break;case"staffscale":if(o.shift(),0===o.length)return t("Expected = after staffscale",n,0),l;if("="!==(k=o.shift()).token){t("Expected = after staffscale",n,k.start);break}if(0===o.length)return t("Expected parameter after staffscale=",n,0),l;if("number"!==o[0].type){t("Expected number after staffscale",n,o[0].start);break}r.clef.staffscale=o[0].floatt,o.shift();break;case"octave":if(o.shift(),0===o.length)return t("Expected = after octave",n,0),l;if("="!==(k=o.shift()).token){t("Expected = after octave",n,k.start);break}if(0===o.length)return t("Expected parameter after octave=",n,0),l;if("number"!==o[0].type){t("Expected number after octave",n,o[0].start);break}r.octave=o[0].intt,o.shift();break;case"style":if(o.shift(),0===o.length)return t("Expected = after style",n,0),l;if("="!==(k=o.shift()).token){t("Expected = after style",n,k.start);break}if(0===o.length)return t("Expected parameter after style=",n,0),l;switch(o[0].token){case"normal":case"harmonic":case"rhythm":case"x":case"triangle":r.style=o[0].token,o.shift();break;default:t("error parsing style element: "+o[0].token,n,o[0].start)}break;case"clef":if(o.shift(),0===o.length)return t("Expected = after clef",n,0),l;if("="!==(k=o.shift()).token){t("Expected = after clef",n,k.start);break}if(0===o.length)return t("Expected parameter after clef=",n,0),l;case"treble":case"bass":case"alto":case"tenor":case"perc":case"none":var M=o.shift();switch(M.token){case"treble":case"tenor":case"alto":case"bass":case"perc":case"none":break;case"C":case"c":M.token="alto";break;case"F":case"f":M.token="bass";break;case"G":case"g":M.token="treble";break;default:t("Expected clef name. Found "+M.token,n,M.start)}o.length>0&&"number"===o[0].type&&(M.token+=o[0].token,o.shift()),o.length>1&&("-"===o[0].token||"+"===o[0].token||"^"===o[0].token||"_"===o[0].token)&&"8"===o[1].token&&(M.token+=o[0].token+o[1].token,o.shift(),o.shift()),r.clef={type:M.token,verticalPos:c(M.token,0)},r.currentVoice&&void 0!==r.currentVoice.transpose&&(r.clef.transpose=r.currentVoice.transpose),l.foundClef=!0;break;default:t("Unknown parameter: "+o[0].token,n,o[0].start),o.shift()}return l},i.parseVoice=function(a,n,i){var o=e.getMeat(a,n,i),l=o.start,d=o.end,f=e.getToken(a,l,d);if(0!==f.length){var u=!1;void 0===r.voices[f]&&(r.voices[f]={},u=!0,r.score_is_present&&t("Can't have an unknown V: id when the %score directive is present",a,l)),l+=f.length,l+=e.eatWhiteSpace(a,l);for(var p={startStaff:u},m=function(r){var n=e.getVoiceToken(a,l,d);void 0!==n.warn?t("Expected value for "+r+" in voice: "+n.warn,a,l):void 0!==n.err?t("Expected value for "+r+" in voice: "+n.err,a,l):0===n.token.length&&'"'!==a[l]?t("Expected value for "+r+" in voice",a,l):p[r]=n.token,l+=n.len},g=function(n,i,s){var o=e.getVoiceToken(a,l,d);void 0!==o.warn?t("Expected value for "+i+" in voice: "+o.warn,a,l):void 0!==o.err?t("Expected value for "+i+" in voice: "+o.err,a,l):0===o.token.length&&'"'!==a[l]?t("Expected value for "+i+" in voice",a,l):("number"===s&&(o.token=parseFloat(o.token)),r.voices[n][i]=o.token),l+=o.len},v=function(r,n){var i=e.getVoiceToken(a,l,d);if(void 0!==i.warn)t("Expected value for "+r+" in voice: "+i.warn,a,l);else if(void 0!==i.err)t("Expected value for "+r+" in voice: "+i.err,a,l);else{if(0!==i.token.length||'"'===a[l])return"number"===n&&(i.token=parseFloat(i.token)),i.token;t("Expected value for "+r+" in voice",a,l)}l+=i.len},b=function(n,i){var s=e.getVoiceToken(a,l,d);if(void 0!==s.warn)t("Expected one of (_B, _E, _b, _e) for "+i+" in voice: "+s.warn,a,l);else if(0===s.token.length&&'"'!==a[l])t("Expected one of (_B, _E, _b, _e) for "+i+" in voice",a,l);else{var o={_B:2,_E:9,_b:-10,_e:-3}[s.token];o?r.voices[n][i]=o:t("Expected one of (_B, _E, _b, _e) for "+i+" in voice",a,l)}l+=s.len};l0&&(t+=d[0],"V"===d[1]&&this.startNewLine());for(var f=0;t0)t+=p[0],"V"===p[1]&&(l=!0);else{var m;for((!o.hasBeginMusic()||l&&!this.lineContinuation)&&(this.startNewLine(),l=!1);;)if((m=a.eatWhiteSpace(e,t))>0&&(t+=m),t>0&&""===e[t-1]&&(m=c.letter_to_body_header(e,t))[0]>0&&("V"===m[1]&&this.startNewLine(),t=m[0],i.start_new_line=!1),(m=P(e,t))[0]>0&&(t+=m[0]),(m=_(e,t))[0]>0){S.chord||(S.chord=[]);var g=a.translateString(m[1]);g=g.replace(/;/g,"\n");for(var y=!1,x=0;x0&&(S.force_end_beam_last=!0),t+=k}else if((m=-1===v.indexOf(e[t])?B(e,t):[0])[0]>0)null===m[1]?t+10&&(0===m[1].indexOf("style=")?S.style=m[1].substr(6):(void 0===S.decoration&&(S.decoration=[]),"beambr1"===m[1]?S.beambr=1:"beambr2"===m[1]?S.beambr=2:S.decoration.push(m[1]))),t+=m[0];else{if(!((m=M(e,t))[0]>0))break;S.gracenotes=m[1],t+=m[0]}if((m=L(e,t))[0]>0){f=0,void 0!==S.gracenotes&&(S.rest={type:"spacer"},S.duration=.125,i.addFormattingOptions(S,s.formatting,"note"),o.appendElement("note",r+t,r+t+m[0],S),i.measureNotEmpty=!0,S={});var w={type:m[1]};0===w.type.length?n("Unknown bar type",e,t):(i.inEnding&&"bar_thin"!==w.type&&(w.endEnding=!0,i.inEnding=!1),m[2]&&(w.startEnding=m[2],i.inEnding&&(w.endEnding=!0),i.inEnding=!0,"bar_right_repeat"===m[1]?i.restoreStartEndingHoldOvers():i.duplicateStartEndingHoldOvers()),void 0!==S.decoration&&(w.decoration=S.decoration),void 0!==S.chord&&(w.chord=S.chord),w.startEnding&&void 0===i.barFirstEndingNum?i.barFirstEndingNum=i.currBarNumber:w.startEnding&&w.endEnding&&i.barFirstEndingNum?i.currBarNumber=i.barFirstEndingNum:w.endEnding&&(i.barFirstEndingNum=void 0),"bar_invisible"!==w.type&&i.measureNotEmpty&&I()&&(i.currBarNumber++,i.barNumbers&&i.currBarNumber%i.barNumbers==0&&(w.barNumber=i.currBarNumber)),i.addFormattingOptions(S,s.formatting,"bar"),o.appendElement("bar",r+u,r+t+m[0],w),i.measureNotEmpty=!1,S={}),t+=m[0]}else if("&"===e[t])(m=N(e,t))[0]>0&&(o.appendElement("overlay",r,r+1,{}),t+=1,f++);else{if((m=z(e,t)).consumed>0&&(void 0!==m.startSlur&&(S.startSlur=m.startSlur),m.dottedSlur&&(S.dottedSlur=!0),void 0!==m.triplet&&(h>0?n("Can't nest triplets",e,t):(S.startTriplet=m.triplet,S.tripletMultiplier=m.tripletQ/m.triplet,S.tripletR=m.num_notes,h=void 0===m.num_notes?m.triplet:m.num_notes)),t+=m.consumed),"["===e[t]){t++;for(var T=null,F=!1,V=!1;!V;){var Y=B(e,t);Y[0]>0&&(t+=Y[0]);var G=H(e,t,{},!1);if(null!==G&&void 0!==G.pitch)Y[0]>0&&0!==Y[1].indexOf("style=")&&(void 0===S.decoration&&(S.decoration=[]),S.decoration.push(Y[1])),G.end_beam&&(S.end_beam=!0,delete G.end_beam),void 0===S.pitches?(S.duration=G.duration,S.pitches=[G]):S.pitches.push(G),delete G.duration,Y[0]>0&&0===Y[1].indexOf("style=")&&(S.pitches[S.pitches.length-1].style=Y[1].substr(6)),i.inTieChord[S.pitches.length]&&(G.endTie=!0,i.inTieChord[S.pitches.length]=void 0),G.startTie&&(i.inTieChord[S.pitches.length]=!0),t=G.endChar,delete G.endChar;else if(" "===e[t])n("Spaces are not allowed in chords",e,t),t++;else{if(t0&&(!S.rest||"spacer"!==S.rest.type)&&0==--h&&(S.endTriplet=!0);for(var j=!1;t":case"<":var W=D(e,t);t+=W[0]-1,i.next_note_duration=W[2],T?T*=W[1]:T=W[1];break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"/":var q=a.getFraction(e,t);T=q.value;var X=e[t=q.index];" "===X&&(F=!0),"-"===X||")"===X||" "===X||"<"===X||">"===X?t--:j=!0;break;case"0":T=0;break;default:j=!0}j||t++}}else n("Expected ']' to end the chords",e,t);void 0!==S.pitches&&(null!==T&&(S.duration=S.duration*T,F&&O(S)),i.addFormattingOptions(S,s.formatting,"note"),o.appendElement("note",r+u,r+t,S),i.measureNotEmpty=!0,S={}),V=!0}}}else{var R={},U=H(e,t,R,!0);void 0!==R.endTie&&E(i,f,!0),null!==U&&(void 0!==U.pitch?(S.pitches=[{}],void 0!==U.accidental&&(S.pitches[0].accidental=U.accidental),S.pitches[0].pitch=U.pitch,S.pitches[0].name=U.name,(U.midipitch||0===U.midipitch)&&(S.pitches[0].midipitch=U.midipitch),void 0!==U.endSlur&&(S.pitches[0].endSlur=U.endSlur),void 0!==U.endTie&&(S.pitches[0].endTie=U.endTie),void 0!==U.startSlur&&(S.pitches[0].startSlur=U.startSlur),void 0!==S.startSlur&&(S.pitches[0].startSlur=S.startSlur),void 0!==S.dottedSlur&&(S.pitches[0].dottedSlur=!0),void 0!==U.startTie&&(S.pitches[0].startTie=U.startTie),void 0!==S.startTie&&(S.pitches[0].startTie=S.startTie)):(S.rest=U.rest,"multimeasure"===U.rest.type&&I()&&(i.currBarNumber+=U.rest.text-1),void 0!==U.endSlur&&(S.endSlur=U.endSlur),void 0!==U.endTie&&(S.rest.endTie=U.endTie),void 0!==U.startSlur&&(S.startSlur=U.startSlur),void 0!==U.startTie&&(S.rest.startTie=U.startTie),void 0!==S.startTie&&(S.rest.startTie=S.startTie)),void 0!==U.chord&&(S.chord=U.chord),void 0!==U.duration&&(S.duration=U.duration),void 0!==U.decoration&&(S.decoration=U.decoration),void 0!==U.graceNotes&&(S.graceNotes=U.graceNotes),delete S.startSlur,delete S.dottedSlur,C(i,f,S)&&(void 0!==S.pitches?S.pitches[0].endTie=!0:"spacer"!==S.rest.type&&(S.rest.endTie=!0),E(i,f,!1)),(U.startTie||S.startTie)&&E(i,f,!0),t=U.endChar,h>0&&(!U.rest||"spacer"!==U.rest.type)&&0==--h&&(S.endTriplet=!0),U.end_beam&&O(S),S.rest&&"rest"===S.rest.type&&1===S.duration&&A(i)<=1&&(S.rest.type="whole",S.duration=A(i)),S.duration<1&&-1===b.indexOf(S.duration)&&0!==S.duration&&(S.rest&&"spacer"===S.rest.type||n("Duration not representable: "+e.substring(u,t),e,t)),i.addFormattingOptions(S,s.formatting,"note"),o.appendElement("note",r+u,r+t,S)||(this.startNewLine(),o.appendElement("note",r+u,r+t,S)),i.measureNotEmpty=!0,S={})}t===u&&(" "!==e[t]&&"`"!==e[t]&&n("Unknown character ignored",e,t),t++)}}}this.lineContinuation=e.indexOf("")>=0||d[0]>0,this.lineContinuation||(S={})}};var E=function(e,t,r){var a=e.currentVoice?100*e.currentVoice.staffNum+e.currentVoice.index:0;void 0===e.inTie[t]&&(e.inTie[t]=[]),e.inTie[t][a]=r},_=function(e,t){if('"'===e[t]){var r=a.getBrackettedSubstring(e,t,5);if(r[2]||n("Missing the closing quote while parsing the chord symbol",e,t),r[0]>0&&r[1].length>0&&"^"===r[1][0])r[1]=r[1].substring(1),r[2]="above";else if(r[0]>0&&r[1].length>0&&"_"===r[1][0])r[1]=r[1].substring(1),r[2]="below";else if(r[0]>0&&r[1].length>0&&"<"===r[1][0])r[1]=r[1].substring(1),r[2]="left";else if(r[0]>0&&r[1].length>0&&">"===r[1][0])r[1]=r[1].substring(1),r[2]="right";else if(r[0]>0&&r[1].length>0&&"@"===r[1][0]){r[1]=r[1].substring(1);var s=a.getFloat(r[1]);if(0===s.digits)return n("Missing first position in absolutely positioned annotation.",e,t),r[1]=r[1].replace("@",""),r[2]="above",r;if(r[1]=r[1].substring(s.digits),","!==r[1][0])return n("Missing comma absolutely positioned annotation.",e,t),r[1]=r[1].replace("@",""),r[2]="above",r;r[1]=r[1].substring(1);var o=a.getFloat(r[1]);if(0===o.digits)return n("Missing second position in absolutely positioned annotation.",e,t),r[1]=r[1].replace("@",""),r[2]="above",r;r[1]=r[1].substring(o.digits);var c=a.skipWhiteSpace(r[1]);r[1]=r[1].substring(c),r[2]=null,r[3]={x:s.value,y:o.value}}else!0!==i.freegchord&&(r[1]=r[1].replace(/([ABCDEFG0-9])b/g,"$1♭"),r[1]=r[1].replace(/([ABCDEFG0-9])#/g,"$1♯"),r[1]=r[1].replace(/^([ABCDEFG])([♯♭]?)o([^A-Za-z])/g,"$1$2°$3"),r[1]=r[1].replace(/^([ABCDEFG])([♯♭]?)o$/g,"$1$2°"),r[1]=r[1].replace(/^([ABCDEFG])([♯♭]?)0([^A-Za-z])/g,"$1$2ø$3"),r[1]=r[1].replace(/^([ABCDEFG])([♯♭]?)\^([^A-Za-z])/g,"$1$2∆$3")),r[2]="default",r[1]=h.chordName(i,r[1]);return r}return[0,""]},M=function(e,t){if("{"===e[t]){var r=a.getBrackettedSubstring(e,t,1,"}");r[2]||n("Missing the closing '}' while parsing grace note",e,t),")"===e[t+r[0]]&&(r[0]++,r[1]+=")");for(var s=[],o=0,c=!1;o0&&(s[s.length-1].endBeam=!0):n("Unknown character '"+r[1][o]+"' while parsing grace note",e,t),o++)}if(s.length)return[r[0],s]}return[0]};function N(e,t){if("&"===e[t]){for(var r=t;e[t]&&":"!==e[t]&&"|"!==e[t];)t++;return[t-r,e.substring(r+1,t)]}return[0]}function A(e){var t=e.origMeter;return t&&"specified"===t.type&&t.value&&0!==t.value.length?parseInt(t.value[0].num,10)/parseInt(t.value[0].den,10):1}var B=function(e,t){var r=i.macros[e[t]];if(void 0!==r)return"!"!==r[0]&&"+"!==r[0]||(r=r.substring(1)),"!"!==r[r.length-1]&&"+"!==r[r.length-1]||(r=r.substring(0,r.length-1)),f.includes(r)?[1,r]:u.includes(r)?("hidden"===i.volumePosition&&(r=""),[1,r]):p.includes(r)?("hidden"===i.dynamicPosition&&(r=""),[1,r]):(i.ignoredDecorations.includes(r)||n("Unknown macro: "+r,e,t),[1,""]);switch(e[t]){case".":if("("===e[t+1]||"-"===e[t+1])break;return[1,"staccato"];case"u":return[1,"upbow"];case"v":return[1,"downbow"];case"~":return[1,"irishroll"];case"!":case"+":var s=a.getBrackettedSubstring(e,t,5);if(s[1].length>1&&("^"===s[1][0]||"_"===s[1][0])&&(s[1]=s[1].substring(1)),f.includes(s[1]))return s;if(u.includes(s[1]))return"hidden"===i.volumePosition&&(s[1]=""),s;if(p.includes(s[1]))return"hidden"===i.dynamicPosition&&(s[1]=""),s;var o=m.findIndex((function(e){return s[1]===e[0]}));return o>=0?(s[1]=m[o][1],s):(o=g.findIndex((function(e){return s[1]===e[0]})))>=0?(s[1]=g[o][1],"hidden"===i.dynamicPosition&&(s[1]=""),s):"!"!==e[t]||1!==s[0]&&"!"===e[t+s[0]-1]?(n("Unknown decoration: "+s[1],e,t),s[1]="",s):[1,null];case"H":return[1,"fermata"];case"J":return[1,"slide"];case"L":return[1,"accent"];case"M":return[1,"mordent"];case"O":return[1,"coda"];case"P":return[1,"pralltriller"];case"R":return[1,"roll"];case"S":return[1,"segno"];case"T":return[1,"trill"];case"t":return[1,"trillh"]}return[0,0]},P=function(e,t){for(var r=t;a.isWhiteSpace(e[t]);)t++;return[t-r]},L=function(e,t){var r=a.getBarLine(e,t);if(0===r.len)return[0,""];if(r.warn)return n(r.warn,e,t),[r.len,""];for(var i=0;i="2"&&e[t+1]<="9"?(void 0!==r.triplet?n("Can't nest triplets",e,t):(r.triplet=e[t+1]-"0",r.tripletQ=w[r.triplet],r.num_notes=r.triplet,t+2="1"&&e[t+4]<="9"?(r.num_notes=e[t+4]-"0",t+=3):n("expected number after the two colons after the triplet to mark the duration",e,t):t+3="1"&&e[t+3]<="9"?(r.tripletQ=e[t+3]-"0",t+4="1"&&e[t+5]<="9"&&(r.num_notes=e[t+5]-"0",t+=4):t+=2):n("expected number after the triplet to mark the duration",e,t))),t++):void 0===r.startSlur?r.startSlur=1:r.startSlur++),t++;return r.consumed=t-i,r};T.prototype.startNewLine=function(){var e={startChar:-1,endChar:-1};i.partForNextLine.title&&(e.part=i.partForNextLine),e.clef=i.currentVoice&&void 0!==i.staves[i.currentVoice.staffNum].clef?Object.assign({},i.staves[i.currentVoice.staffNum].clef):Object.assign({},i.clef);var t=i.currentVoice?i.currentVoice.scoreTranspose:0;if(e.key=l.standardKey(i.key.root+i.key.acc+i.key.mode,i.key.root,i.key.acc,t),e.key.mode=i.key.mode,i.key.impliedNaturals&&(e.key.impliedNaturals=i.key.impliedNaturals),i.key.explicitAccidentals)for(var r=0;r=0?(r.duration=s.getBarLength(),r.rest.text=1,d="Zduration"):(n&&0!==i.next_note_duration?(r.duration=i.default_length*i.next_note_duration,i.next_note_duration=0,f=!0):r.duration=i.default_length,d="duration");break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"0":case"/":if("octave"===d||"duration"===d){var p=a.getFraction(e,t);for(r.duration=r.duration*p.value,r.endChar=p.index;p.index"!==e[t])return r;t--,d="broken_rhythm";break;case">":case"<":if(!l(d))return null;if(!n)return r.endChar=t,r;var g=D(e,t);t+=g[0]-1,i.next_note_duration=g[2],r.duration=g[1]*r.duration,d="end_slur";break;default:return l(d)?(r.endChar=t,r):null}if(++t===e.length)return l(d)?(r.endChar=t,r):null}return null},D=function(e,t){switch(e[t]){case">":return t"===e[t+1]&&">"===e[t+2]?[3,1.875,.125]:t"===e[t+1]?[2,1.75,.25]:[1,1.5,.5];case"<":return t","accent"],["tr","trill"],["plus","+"],["emphasis","accent"],["^","umarcato"],["marcato","umarcato"]],e.exports.accentDynamicPseudonyms=[["<(","crescendo("],["<)","crescendo)"],[">(","diminuendo("],[">)","diminuendo)"]],e.exports.nonDecorations="ABCDEFGabcdefgxyzZ[]|^_{",e.exports.durations=[.5,.75,.875,.9375,.96875,.984375,.25,.375,.4375,.46875,.484375,.4921875,.125,.1875,.21875,.234375,.2421875,.24609375,.0625,.09375,.109375,.1171875,.12109375,.123046875,.03125,.046875,.0546875,.05859375,.060546875,.0615234375,.015625,.0234375,.02734375,.029296875,.0302734375,.03076171875],e.exports.pitches={A:5,B:6,C:0,D:1,E:2,F:3,G:4,a:12,b:13,c:7,d:8,e:9,f:10,g:11},e.exports.rests={x:"invisible",X:"invisible-multimeasure",y:"spacer",z:"rest",Z:"multimeasure"},e.exports.accMap={dblflat:"__",flat:"_",natural:"=",sharp:"^",dblsharp:"^^",quarterflat:"_/",quartersharp:"^/"},e.exports.tripletQ={2:3,3:2,4:3,5:2,6:2,7:2,8:3,9:2}},1881:function(e,t,r){var a=r(5008),n=function(e,t){this.lineIndex=0,this.lines=e,this.multilineVars=t,this.skipWhiteSpace=function(e){for(var t=0;t=e.length};this.eatWhiteSpace=function(e,t){for(var r=t;r="a"&&e[t]<="z"||e[t]>="A"&&e[t]<="Z");)t++;return t},a=this.skipWhiteSpace(e);if(r(e,a))return{len:0};var n=e.substring(a,a+3).toLowerCase();switch((n.length>1&&" "===n[1]||"^"===n[1]||"_"===n[1]||"="===n[1])&&(n=n[0]),n){case"mix":return{len:t(e,a),token:"Mix"};case"dor":return{len:t(e,a),token:"Dor"};case"phr":return{len:t(e,a),token:"Phr"};case"lyd":return{len:t(e,a),token:"Lyd"};case"loc":return{len:t(e,a),token:"Loc"};case"aeo":case"min":case"m":return{len:t(e,a),token:"m"};case"maj":case"ion":return{len:t(e,a),token:""}}return{len:0}},this.getClef=function(e,t){var n=e,i=this.skipWhiteSpace(e);if(r(e,i))return{len:0};var s=!1,o=e.substring(i);if(a.startsWith(o,"clef=")&&(s=!0,o=o.substring(5),i+=5),0===o.length&&s)return{len:i+5,warn:"No clef specified: "+n};var c=this.skipWhiteSpace(o);if(r(o,c))return{len:0};c>0&&(i+=c,o=o.substring(c));var l=null;if(a.startsWith(o,"treble"))l="treble";else if(a.startsWith(o,"bass3"))l="bass3";else if(a.startsWith(o,"bass"))l="bass";else if(a.startsWith(o,"tenor"))l="tenor";else if(a.startsWith(o,"alto2"))l="alto2";else if(a.startsWith(o,"alto1"))l="alto1";else if(a.startsWith(o,"alto"))l="alto";else if(!t&&s&&a.startsWith(o,"none"))l="none";else if(a.startsWith(o,"perc"))l="perc";else if(!t&&s&&a.startsWith(o,"C"))l="tenor";else if(!t&&s&&a.startsWith(o,"F"))l="bass";else{if(t||!s||!a.startsWith(o,"G"))return{len:i+5,warn:"Unknown clef specified: "+n};l="treble"}return o=o.substring(l.length),(c=this.isMatch(o,"+8"))>0?l+="+8":(c=this.isMatch(o,"-8"))>0&&(l+="-8"),{len:i+l.length,token:l,explicit:s}},this.getBarLine=function(e,t){switch(e[t]){case"]":switch(e[++t]){case"|":return{len:2,token:"bar_thick_thin"};case"[":return e[++t]>="1"&&e[t]<="9"||'"'===e[t]?{len:2,token:"bar_invisible"}:{len:1,warn:"Unknown bar symbol"};default:return{len:1,token:"bar_invisible"}}break;case":":switch(e[++t]){case":":return{len:2,token:"bar_dbl_repeat"};case"|":switch(e[++t]){case"]":return"|"===e[++t]&&":"===e[++t]?{len:5,token:"bar_dbl_repeat"}:{len:3,token:"bar_right_repeat"};case"|":return":"===e[++t]?{len:4,token:"bar_dbl_repeat"}:{len:3,token:"bar_right_repeat"};default:return{len:2,token:"bar_right_repeat"}}break;default:return{len:1,warn:"Unknown bar symbol"}}break;case"[":if("|"!==e[++t])return e[t]>="1"&&e[t]<="9"||'"'===e[t]?{len:1,token:"bar_invisible"}:{len:0};switch(e[++t]){case":":return{len:3,token:"bar_left_repeat"};case"]":return{len:3,token:"bar_invisible"};default:return{len:2,token:"bar_thick_thin"}}break;case"|":switch(e[++t]){case"]":return{len:2,token:"bar_thin_thick"};case"|":return":"===e[++t]?{len:3,token:"bar_left_repeat"}:{len:2,token:"bar_thin_thin"};case":":for(var r=0;":"===e[t+r];)r++;return{len:1+r,token:"bar_left_repeat"};default:return{len:1,token:"bar_thin"}}}return{len:0}},this.getTokenOf=function(e,t){for(var r=0;r0;){var r;if("^"===e[0].token){if(r="sharp",e.shift(),0===e.length)return{accs:t,warn:"Expected note name after "+r};switch(e[0].token){case"^":r="dblsharp",e.shift();break;case"/":r="quartersharp",e.shift()}}else if("="===e[0].token)r="natural",e.shift();else{if("_"!==e[0].token)return{accs:t};if(r="flat",e.shift(),0===e.length)return{accs:t,warn:"Expected note name after "+r};switch(e[0].token){case"_":r="dblflat",e.shift();break;case"/":r="quarterflat",e.shift()}}if(0===e.length)return{accs:t,warn:"Expected note name after "+r};switch(e[0].token[0]){case"a":case"b":case"c":case"d":case"e":case"f":case"g":case"A":case"B":case"C":case"D":case"E":case"F":case"G":void 0===t&&(t=[]),t.push({acc:r,note:e[0].token[0]}),1===e[0].token.length?e.shift():e[0].token=e[0].token.substring(1);break;default:return{accs:t,warn:"Expected note name after "+r+" Found: "+e[0].token}}}return{accs:t}},this.getKeyAccidental=function(e){var t={"^":"sharp","^^":"dblsharp","=":"natural",_:"flat",__:"dblflat","_/":"quarterflat","^/":"quartersharp"},a=this.skipWhiteSpace(e);if(r(e,a))return{len:0};var n=null;switch(e[a]){case"^":case"_":case"=":n=e[a];break;default:return{len:0}}if(a++,r(e,a))return{len:1,warn:"Expected note name after accidental"};switch(e[a]){case"a":case"b":case"c":case"d":case"e":case"f":case"g":case"A":case"B":case"C":case"D":case"E":case"F":case"G":return{len:a+1,token:{acc:t[n],note:e[a]}};case"^":case"_":case"/":if(n+=e[a],a++,r(e,a))return{len:2,warn:"Expected note name after accidental"};switch(e[a]){case"a":case"b":case"c":case"d":case"e":case"f":case"g":case"A":case"B":case"C":case"D":case"E":case"F":case"G":return{len:a+1,token:{acc:t[n],note:e[a]}};default:return{len:2,warn:"Expected note name after accidental"}}break;default:return{len:1,warn:"Expected note name after accidental"}}},this.isWhiteSpace=function(e){return" "===e||"\t"===e||""===e},this.getMeat=function(e,t,r){var a=e.indexOf("%",t);for(a>=0&&a="A"&&e<="Z"||e>="a"&&e<="z"},i=function(e){return e>="0"&&e<="9"};this.tokenize=function(e,t,r,a){var s=this.getMeat(e,t,r);t=s.start,r=s.end;for(var o,c=[];t=r?{len:1,err:"Missing close quote"}:{len:n-t+1,token:this.translateString(e.substring(a+1,n))}}for(var i=a;i=0?a.strip(e.substring(0,t)):a.strip(e)},this.getInt=function(e){var t=parseInt(e);if(isNaN(t))return{digits:0};var r=""+t;return{value:t,digits:e.indexOf(r)+r.length}},this.getFloat=function(e){var t=parseFloat(e);if(isNaN(t))return{digits:0};var r=""+t;return{value:t,digits:e.indexOf(r)+r.length}},this.getMeasurement=function(e){if(0===e.length)return{used:0};var t=1,r="";if("-"===e[0].token)e.shift(),r="-",t++;else if("number"!==e[0].type)return{used:0};if(r+=e.shift().token,0===e.length)return{used:1,value:parseInt(r)};var a=e.shift();if("."===a.token){if(t++,0===e.length)return{used:t,value:parseInt(r)};if("number"===e[0].type&&(r=r+"."+(a=e.shift()).token,t++,0===e.length))return{used:t,value:parseFloat(r)};a=e.shift()}switch(a.token){case"pt":case"px":return{used:t+1,value:parseFloat(r)};case"cm":return{used:t+1,value:parseFloat(r)/2.54*72};case"in":return{used:t+1,value:72*parseFloat(r)};default:return e.unshift(a),{used:t,value:parseFloat(r)}}};var d=function(e){return e=(e=e.replace(/\\n/g,"\n")).replace(/\\"/g,'"')};this.getBrackettedSubstring=function(e,t,r,a){for(var n=a||e[t],i=t+1,s=!1;ie.length-1&&(i=e.length-1),[i-t+1,d(e.substring(t+1,i)),!1])}};n.prototype.peekLine=function(){return this.lines[this.lineIndex]},n.prototype.nextLine=function(){if(this.lineIndex>0&&(this.multilineVars.iChar+=this.lines[this.lineIndex-1].length+1),this.lineIndex11&&(u%=12);var p="m"===t[0]?l[u]:c[u],m=p+t,g=i(m);0!==g.length&&"flat"!==g[0].acc||(e.localTransposePreferFlats=!0);var v=m.charCodeAt(0)-h.charCodeAt(0);return e.localTranspose>0?v<0?v+=7:0===v&&("#"!==h[1]&&"b"!==m[1]||(v+=7)):e.localTranspose<0&&(v>0?v-=7:0===v&&("b"!==h[1]&&"#"!==m[1]||(v-=7))),e.localTranspose>0?e.localTransposeVerticalMovement=v+7*Math.floor(e.localTranspose/12):e.localTransposeVerticalMovement=v+7*Math.ceil(e.localTranspose/12),f?{accidentals:g,root:p[0],acc:p.length>1?p[1]:""}:{accidentals:[],root:r,acc:a}},s.chordName=function(e,t){return n(t,e.localTranspose,e.localTransposePreferFlats,e.freegchord)};var h=["c","d","e","f","g","a","b"],d={dblflat:-2,flat:-1,natural:0,sharp:1,dblsharp:2},f={"-2":"dblflat","-1":"flat",0:"natural",1:"sharp",2:"dblsharp"},u={"-2":"__","-1":"_",0:"=",1:"^",2:"^^"};s.note=function(e,t){if(e.localTranspose&&"perc"!==e.clef.type){var r=t.pitch;if(e.localTransposeVerticalMovement&&(t.pitch=t.pitch+e.localTransposeVerticalMovement,t.name)){var n=t.accidental?t.name.substring(1):t.name,i=t.accidental?t.name[0]:"",s=a.pitchIndex(n);t.name=i+a.noteName(s+e.localTransposeVerticalMovement)}if(t.accidental){var o=function(e,t,r,a,n){for(var i=h[(e+49)%7],s=0,o=0;o2&&(t++,p-="b"===l||"e"===l?1:2),[t,p]}(r,t.pitch,t.accidental,e.globalTransposeOrigKeySig,e.targetKey);t.pitch=o[0],t.accidental=f[o[1]],t.name&&(t.name=u[o[1]]+t.name.replace(/[_^=]/g,""))}}},e.exports=s},867:function(e){var t={},r=["C,,,","D,,,","E,,,","F,,,","G,,,","A,,,","B,,,","C,,","D,,","E,,","F,,","G,,","A,,","B,,","C,","D,","E,","F,","G,","A,","B,","C","D","E","F","G","A","B","c","d","e","f","g","a","b","c'","d'","e'","f'","g'","a'","b'","c''","d''","e''","f''","g''","a''","b''","c'''","d'''","e'''","f'''","g'''","a'''","b'''"];t.pitchIndex=function(e){return r.indexOf(e)},t.noteName=function(e){return r[e]},e.exports=t},6225:function(e){var t=["break","(break)","no chord","n.c.","tacet"];function r(e,t){if(e.decoration)for(var r=0;r0&&0===l&&0===h&&(a.push({type:"part",name:n,lines:[i]}),i=[]),n=e.title;else if("note"===e.el_type){r(e,s);var u=Math.floor(d);if(e.chord&&e.chord.length>0){var p=e.chord[0],m="default"===p.position||t.indexOf(p.name.toLowerCase())>=0?p.name:"";m&&(u>0&&!s.chord[0]&&(s.chord[0]=o),o=m,s.chord[u]?u<4&&!s.chord[u+1]&&(s.chord[u+1]=m):s.chord[u]=m),e.chord.forEach((function(e){"default"!==e.position&&t.indexOf(p.name.toLowerCase())<0&&(s.annotations||(s.annotations=[]),s.annotations.push(e.name))}))}if(!e.rest||"spacer"!==e.rest.type){var g=0!==e.duration||e.rest?e.duration:.25,v=Math.floor(4*g);if(v>4)f+=Math.floor(v/4),d=0;else{var b=4*g;e.tripletMultiplier&&(b*=e.tripletMultiplier),d+=b}}}else if("bar"===e.el_type){if(c&&(s.ending=c,c=""),r(e,s),e.chord&&e.chord.forEach((function(e){"default"!==e.position&&(s.annotations||(s.annotations=[]),s.annotations.push(e.name))})),"bar_dbl_repeat"!==e.type&&"bar_left_repeat"!==e.type||(s.hasStartRepeat=!0),"bar_dbl_repeat"!==e.type&&"bar_right_repeat"!==e.type||(s.hasEndRepeat=!0),e.startEnding&&(c=e.startEnding),d>=4){if(""===s.chord[0]&&(s.chord[1]||s.chord[2]||s.chord[3])&&(s.chord[0]=function(e){for(var t=e.length-1;t>=0;t--)for(var r=e[t].chord.length-1;r>=0;r--)if(e[t].chord[r])return e[t].chord[r]}(i)),0===l&&0===h)i.push(s);else{for(var y=f,x=0;y>=a[x].lines[0].length&&xr&&!!e.ending}));if(r>=0&&a>=0&&a-r==t.length-a){for(var n=!0,i=0;i=0?Math.min(n+1,r.length):r.length)&&(a=!0);for(var i=a?4:8,s=0;s=0&&c11&&(i%=12);var c=e.match(/^([A-G][b#♭♯]?)([^\/]+)?\/?([A-G][b#♭♯]?)?(.+)?/);if(!c)return e;var l=c[1],h=c[2],d=c[3],f=c[4];if((u=t.indexOf(l))<0&&(u=r.indexOf(l)),u<0&&(u=a.indexOf(l)),u<0&&(u=n.indexOf(l)),u<0)return e;u+=i,u%=12,e=s?o?n[u]:r[u]:o?a[u]:t[u];var u,p=h&&(h.indexOf("dim")>=0||h.indexOf("°")>=0);return p&&"A#"===e&&(e="Bb"),p&&"D#"===e&&(e="Eb"),p&&"A♯"===e&&(e="B♭"),p&&"D♯"===e&&(e="E♭"),h&&(e+=h),d&&((u=t.indexOf(d))<0&&(u=r.indexOf(d)),u<0&&(u=a.indexOf(d)),u<0&&(u=n.indexOf(d)),e+="/",u>=0?(u+=i,u%=12,e+=s?o?n[u]:r[u]:o?a[u]:t[u]):e+=d),f&&(e+=f),e}},575:function(e,t,r){var a=r(9708);function n(e){if(!e)return!1;if("string"==typeof e)return!1;for(var t=0;t0&&o[c].voice.push({el_type:"note",duration:h,rest:{type:"invisible"},startChar:p.startChar,endChar:p.endChar}),o[c].voice.push(p)),h=0):"note"===p.el_type?d?o[c].voice.push(p):p.rest&&"spacer"===p.rest.type||(h+=p.duration):"scale"!==p.el_type&&"stem"!==p.el_type&&"overlay"!==p.el_type&&"style"!==p.el_type&&"transpose"!==p.el_type&&"color"!==p.el_type||o[c].voice.push(p);else{t=!0,d=!0,f=u,o[c].hasOverlay=!0;for(var m=0;m=e.voices.length&&e.voices.forEach((function(t){var r=[];t.forEach((function(e){"bar"===e.el_type?r.push(e):"note"===e.el_type&&r.push({el_type:"note",duration:e.duration,rest:{type:"invisible"},startChar:e.startChar,endChar:e.endChar})})),e.voices.push(r)}))}))}}o[c].hasOverlay&&0===o[c].snip.length&&o[c].snip.push({start:f,len:l.length-f})}for(c=0;c=0;v--){var b=g.snip[v];i.voices[c].splice(b.start,b.len),i.voices[c].splice(b.start+1,0,{el_type:"stem",direction:"auto"});var y=s(i.voices[c],b.start);i.voices[c].splice(y,0,{el_type:"stem",direction:"up"})}for(v=0;v0&&"bar"!==e[r].el_type;r--);return r}function o(e,t,r,a){var n;a[t]||(a[t]=[]),a[t][r]||(a[t][r]=[]);for(var i=function(e,i,s){if(void 0===a[t][r][s]){for(n=0;n=t&&ct;){if(e[t].staff)return e[t];t++}return null}function h(e){e.potentialStartBeam&&e.potentialEndBeam&&(e.potentialStartBeam.startBeam=!0,e.potentialEndBeam.endBeam=!0),delete e.potentialStartBeam,delete e.potentialEndBeam}function d(e){for(var t=0;t0){if(void 0!==a.voices[0]){for(var n=!1,i=0;i0&&S[S.length-1].barNumber){var _=l(e.lines,T);_&&(_.staff[0].barNumber=S[S.length-1].barNumber),delete S[S.length-1].barNumber}}}return delete e.staffNum,delete e.voiceNum,delete e.lineNum,delete e.potentialStartBeam,delete e.potentialEndBeam,delete e.vskipPending,s},this.addTieToLastNote=function(t){var r=function(e){if(!e.lines[e.lineNum])return null;if(!e.lines[e.lineNum].staff)return null;if(!e.lines[e.lineNum].staff[e.staffNum])return null;var t=e.lines[e.lineNum].staff[e.staffNum].voices[e.voiceNum];if(!t)return null;for(var r=t.length-1;r>=0;r--){var a=t[r];if("note"===a.el_type)return a}return null}(e);return!!(r&&r.pitches&&r.pitches.length>0)&&(r.pitches[0].startTie={},t&&(r.pitches[0].startTie.style="dotted"),!0)},this.appendElement=function(a,n,i,o){var c;return o.el_type=a,null!==n&&(o.startChar=n),null!==i&&(o.endChar=i),"note"===a?((c=o).duration?c.duration:0)>=.25||o.force_end_beam_last&&void 0!==e.potentialStartBeam?p(e):o.end_beam&&void 0!==e.potentialStartBeam?void 0===o.rest?function(e,t){t.potentialStartBeam.startBeam=!0,e.endBeam=!0,delete t.potentialStartBeam,delete t.potentialEndBeam}(o,e):p(e):void 0===o.rest&&(void 0===e.potentialStartBeam?o.end_beam||(e.potentialStartBeam=o,delete e.potentialEndBeam):e.potentialEndBeam=o):p(e),delete o.end_beam,delete o.force_end_beam_last,o.rest&&"invisible"===o.rest.type&&delete o.decoration,!(e.lines.length<=e.lineNum||e.lines[e.lineNum].staff.length<=e.staffNum||(function(e,t,r,a,n){var i=t.lines[t.lineNum].staff[t.staffNum];if(void 0!==r.pitches){var s=i.workingClef.verticalPos;r.pitches.forEach((function(e){e.verticalPos=e.pitch-s}))}if(void 0!==r.gracenotes){var o=i.workingClef.verticalPos;r.gracenotes.forEach((function(e){e.verticalPos=e.pitch-o}))}i.voices.length<=t.voiceNum&&(a[n]||(a[n]={}),g(e,t,a[n])),i.voices[t.voiceNum].push(r)}(t,e,o,r,s),0))},this.appendStartingElement=function(t,r,a,n){var i;h(e),"key"===t&&(i=n.impliedNaturals,delete n.impliedNaturals,delete n.explicitAccidentals);var s=Object.assign({},n);if(e.lines[e.lineNum]){var o=e.lines[e.lineNum].staff;if(o){o.length<=e.staffNum&&(o[e.staffNum]={},o[e.staffNum].clef=Object.assign({},o[0].clef),o[e.staffNum].key=Object.assign({},o[0].key),o[0].meter&&(o[e.staffNum].meter=Object.assign({},o[0].meter)),o[e.staffNum].workingClef=Object.assign({},o[0].workingClef),o[e.staffNum].voices=[[]]),"clef"===t&&(o[e.staffNum].workingClef=s);for(var c=o[e.staffNum].voices[e.voiceNum],l=0;l0){var r=t[t.length-1];if("bar"!==r.el_type)return e-1;void 0!==r.barNumber&&(r.barNumber=e)}return e},this.hasBeginMusic=function(){for(var t=0;t=0;r--)if(void 0!==e.lines[r].staff)return!1;return!0},this.getCurrentVoice=function(){var t=function(e,t){if(e.length<=t)return null;for(;t>=0;){if(e[t].staff)return e[t];t--}return null}(e.lines,e.lineNum);if(!t)return null;var r=t.staff[e.staffNum];return r&&void 0!==r.voices[e.voiceNum]?r.voices[e.voiceNum]:null},this.setCurrentVoice=function(t,r,a){e.staffNum=t,e.voiceNum=r,s=a;for(var n=0;n0?(r.push(i-1),a.push(Math.round(n-s)),n=s):is&&fs?(l.push(f-1),c++,o=Math.max(o,s),s=Math.abs(a-t[c]),i.push(n-u),n=u):s=p}i.push(n)}function n(e,t,r,n){for(var i=Math.ceil(e.total/t),s=Math.floor(e.total/i),o=[],c=0;ct&&(s=!0),o%r==r-1&&(o!==e.length-1&&a.push(o),n.push(Math.round(i)),i=0);return{failed:s,totals:n,lineBreaks:a}}e.exports={wrapLines:function(e,t,r){if(t&&0!==e.lines.length){var a=e.deline({lineBreaks:!1}),n=function(e,t){for(var r=[],a=0,n=0,i=0,s=0;s0&&(a[c.line].staff[c.staff].barNumber=s);for(var h=Object.keys(l),d=0;d=0;p--)if("key"===u[p].el_type){n[c.staff]={root:u[p].root,acc:u[p].acc,mode:u[p].mode,accidentals:u[p].accidentals.filter((function(e){return"natural"!==e.acc}))};break}for(p=u.length-1;p>=0;p--)if("stem"===u[p].el_type){i[10*c.staff+c.voice]={direction:u[p].direction};break}if(void 0!==r&&0===c.staff&&0===c.voice)for(p=0;p0&&p.measureWidths.length<25&&(k=n(p,g,0,b),b.attempts.push({type:"Optimize",failed:k.failed,reason:k.reason,lineBreaks:k.lineBreaks,totals:k.totals}),k.failed||(y=k.lineBreaks))}d.push(y),f.push(b)}var w=function(e,t,r){var a={lineBreaks:e,staffwidth:t};for(var n in r)r.hasOwnProperty(n)&&"wrap"!==n&&"staffwidth"!==n&&(a[n]=r[n]);return{revisedParams:a}}(d,a.staffwidth,a);return w.explanation=f,w.reParse=!0,w}}},9716:function(e,t,r){var a,n=r(7207),i=r(5058);!function(){"use strict";var e,t,r,s,o,c,l,h,d,f,u,p,m,g,v,b,y,x,k=1,w={num:4,den:4},T=128,C=!0,S=105,E=95,_=85,M=[[S,E,_]],N=.25,A=0,B={},P=0;function L(e){for(var t=d.length-1;t>=0;t--)if("program"===d[t].cmd)return void(d[t].channel=e)}function z(e){return e/1e6}function O(e){return Math.round(e*k*1e6)/1e6}function H(e){switch(parseInt(e.den,10)){case 2:return.5;case 4:return.25;case 8:return e.num%3==0?.375:.125;case 16:return.125}return.25}function D(e,t,r){if(t)return 0;var a,n,i,s=S,o=E,c=_;if(void 0!==r&&M.length>=r+1&&(s=M[r][0],o=M[r][1],c=M[r][2]),void 0!==g)a=g,g=void 0;else if(C)if(P>e)a=c;else{var l=(n=m,i=H(w),(e-n)/i);a=0===l?s:parseInt(l,10)===l?o:c}else a=o;return v&&(a+=v,v=void 0),a<0&&(a=0),a>127&&(a=127),t?0:a}function I(e,t){var r=t.start,a=t.duration,n=O(1/32);switch(e){case"trill":for(var i=2;a>0;)d.push({cmd:"note",pitch:t.pitch+i,volume:t.volume,start:r,duration:n,gap:0,instrument:h,style:"decoration"}),i=2===i?0:2,a-=n,r+=n;break;case"trillh":for(i=1;a>0;)d.push({cmd:"note",pitch:t.pitch+i,volume:t.volume,start:r,duration:n,gap:0,instrument:h,style:"decoration"}),i=1===i?0:1,a-=n,r+=n;break;case"pralltriller":d.push({cmd:"note",pitch:t.pitch,volume:t.volume,start:r,duration:n,gap:0,instrument:h,style:"decoration"}),a-=n,r+=n,d.push({cmd:"note",pitch:t.pitch+2,volume:t.volume,start:r,duration:n,gap:0,instrument:h,style:"decoration"}),a-=n,r+=n,d.push({cmd:"note",pitch:t.pitch,volume:t.volume,start:r,duration:a,gap:0,instrument:h});break;case"mordent":case"lowermordent":d.push({cmd:"note",pitch:t.pitch,volume:t.volume,start:r,duration:n,gap:0,instrument:h,style:"decoration"}),a-=n,r+=n,d.push({cmd:"note",pitch:t.pitch-2,volume:t.volume,start:r,duration:n,gap:0,instrument:h,style:"decoration"}),a-=n,r+=n,d.push({cmd:"note",pitch:t.pitch,volume:t.volume,start:r,duration:a,gap:0,instrument:h});break;case"turn":n=t.duration/4,d.push({cmd:"note",pitch:t.pitch+2,volume:t.volume,start:r,duration:n,gap:0,instrument:h,style:"decoration"}),d.push({cmd:"note",pitch:t.pitch,volume:t.volume,start:r+n,duration:n,gap:0,instrument:h,style:"decoration"}),d.push({cmd:"note",pitch:t.pitch-1,volume:t.volume,start:r+2*n,duration:n,gap:0,instrument:h,style:"decoration"}),d.push({cmd:"note",pitch:t.pitch,volume:t.volume,start:r+3*n,duration:n,gap:0,instrument:h,style:"decoration"});break;case"roll":for(;a>0;)d.push({cmd:"note",pitch:t.pitch,volume:t.volume,start:r,duration:n,gap:0,instrument:h,style:"decoration"}),a-=2*n,r+=2*n}}function F(e,t){var r,a=D(z(e.time),t);if(p.processChord(e),e.gracenotes&&e.pitches&&e.pitches.length>0&&e.pitches[0]&&(r=function(e,t){for(var r,a=0,n=[],s=0;sv&&(b=D(z(e.time),t,v));var y=g[v];if(y){y.startSlur&&(A+=y.startSlur.length),y.endSlur&&(A-=y.endSlur.length);var k=y.actualPitch?y.actualPitch:Y(y);if(h===T&&x){var w=i(y);w&&x[w]&&(k=x[w].sound)}var C={cmd:"note",pitch:k,volume:b,start:z(e.time),duration:O(y.duration),instrument:h,startChar:e.elem.startChar,endChar:e.elem.endChar};if(C=j(C),e.gracenotes&&(C.duration=C.duration/2,C.start=C.start+C.duration),e.elem&&e.elem.midiPitches.push(C),m.noteModification)I(m.noteModification,C);else{switch(A>0?C.endType="tenuto":f&&(C.endType=f),C.endType){case"tenuto":C.gap=-.001;break;case"staccato":var S=.4*C.duration;C.gap=o/60*S;break;default:C.gap=0}d.push(C)}}}d.length}var E=function(e){return e.pitches&&e.pitches.length>0&&e.pitches[0]?e.pitches[0].duration:e.elem?e.elem.duration:e.duration}(e);u=Math.max(u,z(e.time)+O(E))}a=function(a,i,T,O){i||(i={}),O||(O={}),e=[],t=[0,0,0,0,0,0,0],s=[],o=i.qpm,c=void 0,k=1,l=void 0,h=void 0,d=void 0,f=void 0,u=0,x=T,w={num:4,den:4},C=!0,S=105,E=95,_=85,M=[],N=.25,g=void 0,v=void 0,A=0,b=[],B={},y=1,a.length>0&&a[0].length>0&&(P=a[0][0].pickupLength),void 0===i.bassprog||O.bassprog||(O.bassprog=[i.bassprog]),void 0===i.bassvol||O.bassvol||(O.bassvol=[i.bassvol]),void 0===i.chordprog||O.chordprog||(O.chordprog=[i.chordprog]),void 0===i.chordvol||O.chordvol||(O.chordvol=[i.chordvol]),void 0===i.gchord||O.gchord||(O.gchord=[i.gchord]),p=new n(a.length,i.chordsOff,O,w),function(e,t){for(var r=0;r=0)&&(V=!0);for(var Y=0;Y0&&"program"===d[d.length-1].cmd)d[d.length-1].instrument=j.program;else{var W;for(W=d.length-1;W>=0&&"program"!==d[W].cmd;W--);(W<0||d[W].instrument!==j.program)&&d.push({cmd:"program",channel:0,instrument:j.program})}break;case"channel":L(j.channel);break;case"drum":B=q(j.params),X();break;case"gchordOn":p.gChordOn(j);break;case"beat":S=j.beats[0],E=j.beats[1],_=j.beats[2],M=j.volumesPerNotePitch?j.volumesPerNotePitch:[];break;case"vol":g=j.volume;break;case"volinc":v=j.volume;break;case"beataccents":C=j.value;break;case"gchord":case"bassprog":case"chordprog":case"bassvol":case"chordvol":case"gchordbars":p.paramChange(j);break;default:console.log("MIDI creation. Unknown el_type: "+j.el_type+"\n")}}void 0===d[0].instrument&&(d[0].instrument=l||0),f&&d.unshift(f),s.push(d),p.finish(),b.length}return i.detuneOctave&&function(e,t){for(var r={},a=0;a1){var c=(o=o.sort((function(e,t){return e.pitch-t.pitch})))[o.length-1],l=c.pitch%12,h=!1;for(n=0;!h&&n0&&s.push(b),{tempo:o,instrument:l,tracks:s,totalDuration:u}};var V=[0,2,4,5,7,9,11];function Y(a){if(void 0!==a.midipitch)return a.midipitch;var n=a.pitch;if(a.accidental)switch(a.accidental){case"sharp":e[n]=1;break;case"flat":e[n]=-1;break;case"natural":e[n]=0;break;case"dblsharp":e[n]=2;break;case"dblflat":e[n]=-2;break;case"quartersharp":e[n]=.25;break;case"quarterflat":e[n]=-.25}var i=12*function(e){return Math.floor(e/7)}(n)+V[W(n)]+60;return void 0!==e[n]?i+=e[n]:i+=t[W(n)],i+=r}function G(e){var t=[0,0,0,0,0,0,0];if(!e.accidentals)return t;for(var r=0;r=0?(e.pitch=Math.round(e.pitch),e.cents=-50):t.indexOf(".25")>=0&&(e.pitch=Math.round(e.pitch),e.cents=50),e}function W(e){return(e%=7)<0&&(e+=7),e}function q(e){if(0===e.pattern.length||!1===e.on)return{on:!1};for(var t=e.pattern[0],r=[],a="",n=0,i=0;i=0)return a;return a}function s(e,t,r){for(var a=Math.min(e.length,t+3),n=t;n=0)return e[n].decoration[i];return null}function o(e){for(var t=0;t=0&&"bar"!==r[a].el_type;)r[a].noChordVoice=!0,a--}function c(e,t){if(e&&!(e.length<=t)&&e[t].title)return e[t].title.join(" ")}function l(e,t){var r=1/4;e.duration&&(r=e.duration[0]);var a=60;return e.bpm&&(a=e.bpm),r*a/t}function h(t){var r;switch(t.type){case"common_time":r={el_type:"meter",num:4,den:4},e=1;break;case"cut_time":r={el_type:"meter",num:2,den:2},e=1;break;case"specified":var a=0;if(t.value&&t.value.length>0&&t.value[0].num.indexOf("+")>0)for(var n=t.value[0].num.split("+"),i=0;i=0;r--)if(e[r].el_type===t.el_type)return void(JSON.stringify(e[r])!==JSON.stringify(t)&&e.push(t));e.push(t)}a=function(a,d){var m,g=(d=d||{}).program||0,v=d.midiTranspose||0;a.visualTranspose&&(v-=a.visualTranspose);var b=d.channel||0,y=!1,x=d.drum||"",k=d.drumBars||1,w=d.drumIntro||0,T=""!==x,C=!!d.drumOff,S=[];g=parseInt(g,10),v=parseInt(v,10),10===(b=parseInt(b,10))&&(g=t),x=x.split(" "),k=parseInt(k,10),w=parseInt(w,10);var E=a.formatting.bagpipes;E&&(g=71);var _=[];if(a.formatting.midi){var M=a.formatting.midi;M.program&&M.program.length>0&&(g=M.program[0],M.program.length>1&&(g=M.program[1],b=M.program[0]),y=!0),M.transpose&&(v=M.transpose[0]),M.channel&&(b=M.channel[0],y=!0),M.drum&&(x=M.drum),M.drumbars&&(k=M.drumbars[0]),M.drumon&&(T=!0),10===b&&(g=t),M.beat&&_.push({el_type:"beat",beats:M.beat}),M.nobeataccents&&_.push({el_type:"beataccents",value:!1})}m=d.qpm?parseInt(d.qpm,10):a.metaText.tempo?l(a.metaText.tempo,a.getBeatLength()):d.defaultQpm?d.defaultQpm:180;var N=[];E&&N.push({el_type:"bagpipes"}),N.push({el_type:"instrument",program:g}),b&&N.push({el_type:"channel",channel:b}),v&&N.push({el_type:"transpose",transpose:v}),N.push({el_type:"tempo",qpm:m});for(var A=0;A<_.length;A++)N.push(_[A]);var B,P=[],L=[],z=[],O=[],H=[0],D={};D[0]={el_type:"tempo",qpm:m,timing:0};for(var I=[],F=!1,V=a.lines,Y=0;Y=0?t="pppp":e.decoration.indexOf("ppp")>=0?t="ppp":e.decoration.indexOf("pp")>=0?t="pp":e.decoration.indexOf("p")>=0?t="p":e.decoration.indexOf("mp")>=0?t="mp":e.decoration.indexOf("mf")>=0?t="mf":e.decoration.indexOf("f")>=0?t="f":e.decoration.indexOf("ff")>=0?t="ff":e.decoration.indexOf("fff")>=0?t="fff":e.decoration.indexOf("ffff")>=0&&(t="ffff"),t){var n=[B=a[t].slice(0)];Array.isArray(e.decoration)&&(n=[],e.decoration.forEach((function(e){e in a&&n.push(a[e].slice(0))}))),P[q].push({el_type:"beat",beats:B.slice(0),volumesPerNotePitch:n}),z[U]=!1,O[U]=!1}if(e.decoration.indexOf("crescendo(")>=0){var i=r(K,re,"crescendo)"),o=Math.min(127,B[0]+50),c=s(K,re+i+1,Object.keys(a));c&&(o=a[c][0]),z[U]=i>0&&Math.floor((o-B[0])/i),O[U]=!1}else if(e.decoration.indexOf("crescendo)")>=0)z[U]=!1;else if(e.decoration.indexOf("diminuendo(")>=0){var l=r(K,re,"diminuendo)"),h=Math.max(15,B[0]-50),d=s(K,re+l+1,Object.keys(a));d&&(h=a[d][0]),z[U]=!1,O[U]=l>0&&Math.floor((h-B[0])/l)}else e.decoration.indexOf("diminuendo)")>=0&&(O[U]=!1)}},W=G.staff,q=0,X=0;X=0?(P[q].push({el_type:"transpose",transpose:-12}),L[q]=!0):R.clef.type.indexOf("+8")>=0?(P[q].push({el_type:"transpose",transpose:12}),L[q]=!0):L[q]&&(P[q].push({el_type:"transpose",transpose:0}),L[q]=!1)),a.formatting.midi&&a.formatting.midi.drumoff&&(P[q].push({el_type:"bar"}),P[q].push({el_type:"drum",params:{pattern:"",on:!1}}));var J=0,Z=0,ee=0,te=0;B=[105,95,85,1];for(var re=0;re=0?P[q].push({el_type:"transpose",transpose:-12}):ae.type.indexOf("+8")>=0&&P[q].push({el_type:"transpose",transpose:12}));break;case"tempo":m=l(ae,a.getBeatLength()),P[q].push({el_type:"tempo",qpm:m,timing:H[q]}),D[""+H[q]]={el_type:"tempo",qpm:m,timing:H[q]};break;case"bar":J>0&&P[q].push({el_type:"bar"}),j(ae),J=0,I[q].addBar(ae,q);break;case"style":S[q]=ae.head;break;case"timeSignature":P[q].push(h(ae));break;case"part":case"stem":case"scale":case"break":case"font":break;case"midi":var oe=!1;switch(ae.cmd){case"drumon":T=!0,oe=!0;break;case"drumoff":T=!1,oe=!0;break;case"drum":x=ae.params,oe=!0;break;case"drumbars":k=ae.params[0],oe=!0;break;case"drummap":break;case"channel":10===ae.params[0]&&P[q].push({el_type:"instrument",program:t});break;case"program":p(P[q],{el_type:"instrument",program:ae.params[0]}),y=!0;break;case"transpose":P[q].push({el_type:"transpose",transpose:ae.params[0]});break;case"gchordoff":P[q].push({el_type:"gchordOn",tacet:!0});break;case"gchordon":P[q].push({el_type:"gchordOn",tacet:!1});break;case"beat":P[q].push({el_type:"beat",beats:ae.params});break;case"nobeataccents":P[q].push({el_type:"beataccents",value:!1});break;case"beataccents":P[q].push({el_type:"beataccents",value:!0});break;case"vol":case"volinc":P[q].push({el_type:ae.cmd,volume:ae.params[0]});break;case"swing":case"gchord":case"bassvol":case"chordvol":case"gchordbars":P[q].push({el_type:ae.cmd,param:ae.params[0]});break;case"bassprog":case"chordprog":P[q].push({el_type:ae.cmd,value:ae.params[0],octaveShift:ae.params[1]});break;default:console.log("MIDI seq: midi cmd not handled: ",ae.cmd,ae)}oe&&(P[0].push({el_type:"drum",params:{pattern:x,bars:k,intro:w,on:T}}),F=!0);break;default:console.log("MIDI: element type "+ae.el_type+" not handled.")}}H[++q]||(H[q]=0)}}}for(var ce=0;ce=0&&i!==t[""+o.timing].qpm&&(i=t[""+o.timing].qpm,"tempo"===o.el_type?(o.qpm=t[""+o.timing].qpm,s++):(e[a].splice(s,0,{el_type:"tempo",qpm:t[""+o.timing].qpm,timing:o.timing}),s+=2))}}(P,D),w)for(var le=a.getPickupLength(),he=0;hede;)de++;if(P[he].length>de){for(se=0;se0&&P[0].length>0&&(P[0][0].pickupLength=a.getPickupLength()),P}}(),e.exports=a},7207:function(e){var t=function(e,t,r,a){this.chordTrack=[],this.chordTrackFinished=!1,this.chordChannel=e,this.currentChords=[],this.lastChord,this.chordLastBar,this.chordsOff=!!t,this.gChordTacet=this.chordsOff,this.hasRhythmHead=!1,this.transpose=0,this.lastBarTime=0,this.meter=a,this.tempoChangeFactor=1,this.bassInstrument=r.bassprog&&r.bassprog.length>=1?r.bassprog[0]:0,this.chordInstrument=r.chordprog&&r.chordprog.length>=1?r.chordprog[0]:0,this.bassOctaveShift=r.bassprog&&2===r.bassprog.length?r.bassprog[1]:0,this.chordOctaveShift=r.chordprog&&2===r.chordprog.length?r.chordprog[1]:0,this.boomVolume=r.bassvol&&1===r.bassvol.length?r.bassvol[0]:64,this.chickVolume=r.chordvol&&1===r.chordvol.length?r.chordvol[0]:48,r.gchord&&r.gchord.length>0?this.overridePattern=n(r.gchord[0]):this.overridePattern=void 0};function r(e,t,r,n){var i=[];if(!e)return i;t.indexOf("boom")>=0?i.push(r?e.boom:e.boom2):n&&i.push(e.boom);var s=e.chick.length;if(t.indexOf("chick")>=0)for(var o=0;o0&&!this.chordTrackFinished&&(this.resolveChords(this.lastBarTime,i(e.time)),this.currentChords=[]),this.chordLastBar=this.lastChord},t.prototype.gChordOn=function(e){this.chordsOff||(this.gChordTacet=e.tacet)},t.prototype.paramChange=function(e){switch(e.el_type){case"gchord":e.param&&e.param.length>0?this.overridePattern=n(e.param):this.overridePattern=void 0;break;case"bassprog":this.bassInstrument=e.value,null!=e.octaveShift&&null!=e.octaveShift?this.bassOctaveShift=e.octaveShift:this.bassOctaveShift=0;break;case"chordprog":this.chordInstrument=e.value,null!=e.octaveShift&&null!=e.octaveShift?this.chordOctaveShift=e.octaveShift:this.chordOctaveShift=0;break;case"bassvol":this.boomVolume=e.param;break;case"chordvol":this.chickVolume=e.param;break;default:console.log("unhandled midi param",e)}},t.prototype.finish=function(){this.chordTrackEmpty()||(this.chordTrackFinished=!0)},t.prototype.addTrack=function(e){this.chordTrackEmpty()||e.push(this.chordTrack)},t.prototype.findChord=function(e){if(this.gChordTacet)return"break";if(this.chordTrackFinished||!e.chord||0===e.chord.length)return null;for(var t=0;t=0)return"break"}return null},t.prototype.interpretChord=function(e){if(0!==e.length){if("break"===e)return{chick:[]};var t=e.substring(0,1);if("("===t){if(0===(e=e.substring(1,e.length-1)).length)return;t=e.substring(0,1)}var r=this.basses[t];if(r){for(var a=this.transpose;a<-8;)a+=12;for(;a>8;)a-=12;(r+=a)<33?r+=12:r>44&&(r-=12);var n,i=r,s=(r+=12*this.bassOctaveShift)-5;1===e.length&&(n=this.chordNotes(r,""));var o=e.substring(1),c=o.substring(0,1);"b"===c||"♭"===c?(i--,r--,s--,o=o.substring(1)):"#"!==c&&"♯"!==c||(i++,r++,s++,o=o.substring(1));var l=o.split("/");if((n=this.chordNotes(i,l[0])).length>=3&&(s=s+(n[2]-n[0])-7),2===l.length&&this.basses[l[1].substring(0,1)]){var h={"#":1,"♯":1,b:-1,"♭":-1}[l[1].substring(1)]||0;r=this.basses[l[1].substring(0,1)]+h+a,s=r+=12*this.bassOctaveShift}return{boom:r,boom2:s,chick:n}}}},t.prototype.chordNotes=function(e,t){var r=this.chordIntervals[t];r||(r="ma"===t.slice(0,2).toLowerCase()||"M"===t[0]?this.chordIntervals.M:"m"===t[0]||"-"===t[0]?this.chordIntervals.m:this.chordIntervals.M),e+=12,e+=12*this.chordOctaveShift;for(var a=[],n=0;n0&&c[d-1]&&c[d]&&c[d-1].boom!==c[d].boom&&(f=!0);var p=l[d],m=p.indexOf("boom")>=0,g=!m&&0!==d&&l[0].indexOf("boom")>=0&&(!c[d-1]||c[d-1].boom!==c[d].boom),v=r(c[d],p,f,g);m&&(f=!1);for(var b=0;b4)for(n=n.toLowerCase(),t-=5;t>0;)n+="'",t--;else for(;t<4;)n+=",",t++;return n}}},5058:function(e){var t={f0:"_C",n0:"=C",s0:"^C",x0:"C",f1:"_D",n1:"=D",s1:"^D",x1:"D",f2:"_E",n2:"=E",s2:"^E",x2:"E",f3:"_F",n3:"=F",s3:"^F",x3:"F",f4:"_G",n4:"=G",s4:"^G",x4:"G",f5:"_A",n5:"=A",s5:"^A",x5:"A",f6:"_B",n6:"=B",s6:"^B",x6:"B",f7:"_c",n7:"=c",s7:"^c",x7:"c",f8:"_d",n8:"=d",s8:"^d",x8:"d",f9:"_e",n9:"=e",s9:"^e",x9:"e",f10:"_f",n10:"=f",s10:"^f",x10:"f",f11:"_g",n11:"=g",s11:"^g",x11:"g",f12:"_a",n12:"=a",s12:"^a",x12:"a",f13:"_b",n13:"=b",s13:"^b",x13:"b",f14:"_c'",n14:"=c'",s14:"^c'",x14:"c'",f15:"_d'",n15:"=d'",s15:"^d'",x15:"d'",f16:"_e'",n16:"=e'",s16:"^e'",x16:"e'"};e.exports=function(e){var r=(e.accidental?e.accidental[0]:"x")+e.verticalPos;return t[r]}},7021:function(e,t,r){var a=r(5008);function n(e,t,r,n){r<0&&(r=0),t.length>0&&"bar"===e[r].el_type&&"bar"===t[t.length-1].el_type&&r++;for(var i=r;i<=n;i++){var s,o=!1;if("key"===e[i].el_type||"meter"===e[i].el_type||"tempo"===e[i].el_type||"instrument"===e[i].el_type){for(s=t.length-1;s>=0&&t[s].el_type!==e[i].el_type;)s--;s>=0&&("key"===e[i].el_type&&(h=e[i],d=t[s],h.accidentals&&d.accidentals&&JSON.stringify(h.accidentals)===JSON.stringify(d.accidentals))||"meter"===e[i].el_type&&e[i].num===t[s].num&&e[i].den===t[s].den||"instrument"===e[i].el_type&&e[i].program===t[s].program||"tempo"===e[i].el_type&&e[i].qpm===t[s].qpm)&&(o=!0)}o||t.push((c=e[i],l=void 0,(l=Object.assign({},c)).pitches&&(l.pitches=a.cloneArray(l.pitches)),l))}var c,l,h,d}e.exports=function(e){this.sections=[{type:"startRepeat",index:-1}],this.addBar=function(t){var r=e.length-1,a="bar_left_repeat"===t.type||"bar_dbl_repeat"===t.type,n="bar_right_repeat"===t.type||"bar_dbl_repeat"===t.type,i=t.startEnding?function(e){var t,r,a,n=[];if(e.indexOf(",")>0)for(r=e.split(","),a=0;a0&&n.push(t);else if(e.indexOf("-")>0){r=e.split("-");var i=parseInt(r[0],10),s=parseInt(r[1],10);for(a=i;a<=s;a++)n.push(a)}else(t=parseInt(e,10))>0&&n.push(t);return n}(t.startEnding):void 0;n&&(this.sections.length>0&&"endRepeat"===this.sections[this.sections.length-1].type&&this.sections.push({type:"startRepeat",index:this.sections[this.sections.length-1].index}),this.sections.push({type:"endRepeat",index:r})),a&&this.sections.push({type:"startRepeat",index:r}),i&&this.sections.push({type:"startEnding",index:r,endings:i})},this.resolveRepeats=function(){var t,r=this.sections[this.sections.length-1],a=e.length-1;if("startRepeat"===r.type?r.end=a:r.index+10)for(t=0;t0&&n(e,h,p.start,p.end),d=Math.max(d,p.end))}else n(e,h,u.common.start,u.common.end)}return h}}},2426:function(e,t,r){var a=r(6074),n={violin:{name:"StringTab",defaultTuning:["G,","D","A","e"],isTabBig:!1,tabSymbolOffset:0},fiddle:{name:"StringTab",defaultTuning:["G,","D","A","e"],isTabBig:!1,tabSymbolOffset:0},mandolin:{name:"StringTab",defaultTuning:["G,","D","A","e"],isTabBig:!1,tabSymbolOffset:0},guitar:{name:"StringTab",defaultTuning:["E,","A,","D","G","B","e"],isTabBig:!0,tabSymbolOffset:0},fiveString:{name:"StringTab",defaultTuning:["C,","G,","D","A","e"],isTabBig:!1,tabSymbolOffset:-.95}},i={inited:!1,plugins:{},register:function(e){var t=e.name,r=e.tablature;this.plugins[t]=r},setError:function(e,t){e.warnings?e.warning.push(t):e.warnings=[t]},preparePlugins:function(e,t,r){this.inited||(this.register(new a),this.inited=!0);var i=null;if(r.tablature){var s=r.tablature;i=[];for(var o=0;o0)for(var n=r.length,i=0;i1&&r&&r.length>0)for(n=r.length,i=0;i=0;a--)if(t.pitch+t.pitchAltered>=e.stringPitches[a]){var n=t.pitch+t.pitchAltered-e.stringPitches[a];return"^"===t.quarter?n-=.5:"v"===t.quarter&&(n+=.5),{num:Math.round(n),str:e.stringPitches.length-1-a,note:t}}return{num:"?",str:e.stringPitches.length-1,note:t}}function l(e,t){var r={num:"?",str:0,note:t};e.push(r),e.error=t.emit()+": unexpected note for instrument"}function h(e){var t=e.tuning,r=e.capo,s=e.params.highestNote;this.linePitch=e.linePitch,this.highestNote="a'",s&&(this.highestNote=s),this.measureAccidentals={},this.capo=0,r&&(this.capo=parseInt(r,10)),this.transpose=e.transpose?e.transpose:0,this.tuning=t,this.stringPitches=[];for(var o=0;o0&&(this.capoTuning=function(e){var t=null,r=e.tuning;if(e.capo>0){t=[];for(var a=0;a0&&(r=e.capoTuning);for(var a=r.length-1,n=0;n1?(o=s(this,e)).error&&(i=o.error):e[0].endTie||((r=new n(e[0].name,this.clefTranspose)).checkKeyAccidentals(this.accidentals,this.measureAccidentals),(a=c(this,r))?o.push(a):(l(o,r),i=o.error))),i)return o;var h=null;if(t){h=[];for(var d=0;d0&&(r+=" capo:"+e.capo),t=t.replace("%T",r)),t}return""},h.prototype.suppress=function(e){return!!e.params.suppress},e.exports=h},8918:function(e){function t(e,t){this.numLines=e,this.lineSpace=t,this.verticalSize=this.numLines*this.lineSpace,this.bar={pitch:3,pitch2:t*e,height:5}}t.prototype.bypass=function(e){var t=e.staffGroup.voices;return!!(t.length>0&&t[0].isPercussion)},t.prototype.setRelative=function(e,t,r){switch(e.type){case"bar":t.pitch=this.bar.pitch,t.pitch2=this.bar.pitch2,t.height=this.height;break;case"symbol":var a=this.bar.pitch2/2;if("dots.dot"==e.name)return r?(t.pitch=a,!1):(t.pitch=a+this.lineSpace,!0)}return r},e.exports=t},6776:function(e,t,r){var a=r(2842),n=a.noteToMidi,i=a.midiToNote;function s(e,t){var r=n(e);t&&(r+=t);var a,s=i(r),o=!1,c=!1,l=null,h=null,d=!1,f=0;e.startsWith("_")?(o=!0,f=-1,"/"==e[1]?(o=!1,h="v",f=0):"_"==e[1]&&(d=!0,f-=1)):e.startsWith("^")?(c=!0,f=1,"/"==e[1]?(c=!1,h="^",f=0):"^"==e[1]&&(d=!0,f+=1)):e.startsWith("=")&&(l=!0,f=0),((a=o||c||null!=h)||l)&&(s=null!=h||d?e.slice(2):e.slice(1));var u=(s.match(/,/g)||[]).length,p=(s.match(/'/g)||[]).length;this.pitch=r,this.pitchAltered=0,this.name=s,this.acc=f,this.isSharp=c,this.isKeySharp=!1,this.isDouble=d,this.isAltered=a,this.isFlat=o,this.isKeyFlat=!1,this.natural=l,this.quarter=h,this.isLower=this.name==this.name.toLowerCase(),this.name=this.name[0].toUpperCase(),this.hasComma=u,this.isQuoted=p}s.prototype.sameNoteAs=function(e){return e.pitch===this.pitch},s.prototype.isLowerThan=function(e){return e.pitch>this.pitch},s.prototype.checkKeyAccidentals=function(e,t){if(!this.isAltered&&!this.natural)if(t[this.name.toUpperCase()])switch(t[this.name.toUpperCase()]){case"__":return this.acc=-2,void(this.pitchAltered=-2);case"_":return this.acc=-1,void(this.pitchAltered=-1);case"=":return this.acc=0,void(this.pitchAltered=0);case"^":return this.acc=1,void(this.pitchAltered=1);case"^^":return this.acc=2,void(this.pitchAltered=2)}else if(e)for(var r=this.name,a=0;a=0){if(r===t)return e.extra[a].x+e.extra[a].w/2;r++}return-1}function u(e){if(e.abcelem){var t=e.abcelem;if(t.rest)return t.gracenotes}return null}function p(e,t,r){var a=e.semantics.notesToNumber(t,r);if(a.error)return e.setError(a.error),a;if(a.graces&&a.notes){var n=a.notes.length-1;a.notes[n].graces=a.graces}return a}function m(e,t,r,a,n){for(var i=0;i=0&&(e.semantics.clefTranspose=-12),k.abcelem.type.indexOf("+8")>=0&&(e.semantics.clefTranspose=12)),k.type){case"staff-extra key-signature":this.accidentals=k.abcelem.accidentals,e.semantics.accidentals=this.accidentals;break;case"bar":e.semantics.measureAccidentals={};var C=!1;x===g.children.length-1&&(C=!0);var S=o(k,e);if(S.abcelem.barNumber){delete S.abcelem.barNumber;for(var E=0;E0&&(y.abselem=M,r.push(y),v.children.push(M))}}},e.exports=h},4785:function(e,t,r){var a=r(3197),n=r(4240),i=r(4331);function s(e,t,r){var a=e.semantics,n=t.controller.getTextSize,i=a.tabInfos(e),s=!0;if(a.suppress(e)&&(s=!1),s){var o=n.calc(i,"tablabelfont","text instrumentname");return r.tabNameInfos={textSize:{height:o.height,width:o.width},name:i},o.height}return 0}function o(e,t){return!(!t[e].isTabStaff||e!==t.length-1&&t[e+1].isTabStaff)}function c(e,t){for(var r=t;r>=0;r--)if(!e[r].isTabStaff)return r;return-1}function l(e,t){return"clef"===e[t].children[0].abcelem.el_type?null:0==t?"none":e[t-1].children[0]}e.exports=function(e,t,r,h){var d=new n,f={clef:{type:"TAB"}},u=e.linePitch*e.nbLines,p=r.staff;if(p){var m=p[0];if(m&&m.clef&&0==m.clef.stafflines)return void e.setError("No tablatures when stafflines=0");p.splice(p.length,0,f)}var g=r.staffGroup,v=g.voices,b=function(e){for(var t=0,r=0;rt&&(t=a.specialY.lyricHeightBelow)}return t}(v[0]),y=h,x=g.staffs[y],k=u+3-x.bottom-b;x.isTabStaff&&(k=x.top);var w={bottom:-1,isTabStaff:!0,specialY:{tempoHeightAbove:0,partHeightAbove:0,volumeHeightAbove:0,dynamicHeightAbove:0,endingHeightAbove:0,chordHeightAbove:0,lyricHeightAbove:0,lyricHeightBelow:0,chordHeightBelow:0,volumeHeightBelow:0,dynamicHeightBelow:0},lines:e.nbLines,linePitch:e.linePitch,dy:.15,top:k},T=function(e,t){for(var r=0,a=0,n=0;;){if(!t[r])return-1;if(t[r].isTabStaff||(n=t[r].voices.length),t[r].isTabStaff){if(a++,o(r,t)&&a=e){if(r+1==t.length)return r+1;if(!t[r+1].isTabStaff)return r+1}if(++r>t.length)return-1}}(h,g.staffs);if(-1!==T){w.parentIndex=T-1,g.staffs.splice(T,0,w),g.height+=u+3;var C=function(e,t){for(var r=t;r>=0;r--)if(!e[r].isTabStaff)return e[r];return null}(g.staffs,T),S=1;(function(e,t){return 1===function(e){for(var t=0,r=0;r1})(g.staffs,C)&&(S=C.voices.length),f.voices=[];for(var E=0;E0&&(_.duplicate=!0);var M=s(e,t,_)/i.STEP;M=Math.max(M,1),g.staffs[h].top+=1,g.height+=M,_.staff=w;var N=v.length;v.splice(v.length,0,_);var A=l(v,E+h);f.voices[E]=[],d.build(e,v,f.voices[E],E,h,A,N)}!function(e){for(var t=0;t0&&(i[0].invisible=!0);break;case"meter":i[0]=l(n,this.tuneNumber),this.startlimitelem=i[0],r.duplicate&&i.length>0&&(i[0].invisible=!0);break;case"clef":if(i[0]=s(n,this.tuneNumber),!i[0])return null;r.duplicate&&i.length>0&&(i[0].invisible=!0);break;case"key":var h=o(n,this.tuneNumber);h&&(i[0]=h,this.startlimitelem=i[0]),r.duplicate&&i.length>0&&(i[0].invisible=!0);break;case"stem":this.stemdir="auto"===n.direction?void 0:n.direction;break;case"part":var d=new a(n,0,0,"part",this.tuneNumber),f=this.getTextSize.calc(n.title,"partsfont","part");d.addFixedX(new u(n.title,0,0,void 0,{type:"part",height:f.height/p.STEP})),i[0]=d;break;case"tempo":var m=new a(n,0,0,"tempo",this.tuneNumber);n.suppress||m.addFixedX(new g(n,this.tuneNumber,c)),i[0]=m;break;case"style":"normal"===n.head?delete this.style:this.style=n.head;break;case"hint":C=!0,this.saveState();break;case"midi":break;case"scale":this.voiceScale=n.size;break;case"color":this.voiceColor=n.color,r.color=this.voiceColor;break;default:var v=new a(n,0,0,"unsupported",this.tuneNumber);v.addFixed(new u("element type "+n.el_type,0,0,void 0,{type:"debug"})),i[0]=v}return i},E.prototype.createBeam=function(e,t,r){var a=[],i=new n(this.stemHeight*this.voiceScale,this.stemdir,this.flatBeams,r[0]);C&&i.setHint();for(var s=0;se.pitches[r+1].pitch){t=!1;var a=e.pitches[r];e.pitches[r]=e.pitches[r+1],e.pitches[r+1]=a}}while(!t)},A=function(e,t,r,a,n,i,s,o,c){for(var l=r;l>11;l--)l%2!=0||a||e.addFixed(new u(null,o,(n+4)*c,l,{type:"ledger"}));for(l=t;l<1;l++)l%2!=0||a||e.addFixed(new u(null,o,(n+4)*c,l,{type:"ledger"}));for(l=0;l1&&(p=new n(i,"grace",s),C&&p.setHint(),p.mainNote=r);var m=[];for(d=e.gracenotes.length-1;d>=0;d--)o+=10,m[d]=o,e.gracenotes[d].accidental&&(o+=7);for(d=0;d=6?"down":"up";for(a&&(E=a),(n=t.style?t.style:n)&&"normal"!==n||(n="note"),(m=i?S[n].nostem:S[n][-s])||console.log("noteSymbol:",n,s,i),g="down"===E?t.pitches.length-2:1;"down"===E?g>=0:g11||M.verticalPos<1)&&x.push(M.verticalPos-M.verticalPos%2),"down"===E?b=f.getSymbolWidth(m)+2:v=f.getSymbolWidth(m)+2)}var A=t.pitches.length;for(g=0;g0&&(h.bottom=h.bottom-1),e.addHead(h)),b+=H.accidentalshiftx,y=Math.max(y,H.dotshiftx)}if(O){var D=Math.round(70*this.voiceScale)/10,I="down"===E?t.minpitch-D:t.minpitch+1/3;I>6&&!a&&(I=6);var F="down"===E?t.maxpitch-1/3:t.maxpitch+D;F<6&&!a&&(F=6);var V="down"===E||0===e.heads.length?0:e.heads[0].w,Y="down"===E?1:-1;h&&"noteheads.slash.quarter"===h.c&&("down"===E?F-=1:I+=1),h&&"noteheads.triangle.quarter"===h.c&&("down"===E?F-=.7:I-=1.2),e.addRight(new u(null,V,0,I,{type:"stem",pitch2:F,linewidth:Y,bottom:I-1})),d=Math.min(I,F)}return{noteHead:h,roomTaken:b,roomTakenRight:y,min:d,additionalLedgers:x,dir:E,symbolWidth:C}},E.prototype.addLyric=function(e,t){var r="";t.lyric.forEach((function(e){var t=" "===e.divider?"":e.divider;r+=e.syllable+t+"\n"}));var a=this.getTextSize.calc(r,"vocalfont","lyric"),n=t.positioning?t.positioning.vocalPosition:"below";e.addCentered(new u(r,0,a.width,void 0,{type:"lyric",position:n,height:a.height/p.STEP,dim:this.getTextSize.attr("vocalfont","lyric")}))},E.prototype.createNote=function(e,t,r,n){var i,s=null,o=0,l=0,h=0,d=[],p=T(e),m=!1;0===p&&(m=!0,p=.25,t=!0);for(var g=Math.floor(Math.log(p)/Math.log(2)),v=0,y=Math.pow(2,g),k=y/2;y1,this.stemdir,r,g,this.voiceScale);s=M.noteHead,o=M.roomTaken,l=M.roomTakenRight}else{var N=this.addNoteToAbcElement(_,e,v,this.stemdir,this.style,m,g,t,n);void 0!==N.min&&(this.minY=Math.min(N.min,this.minY)),s=N.noteHead,o=N.roomTaken,l=N.roomTakenRight,d=N.additionalLedgers,i=N.dir,h=N.symbolWidth}if(void 0!==e.lyric&&this.addLyric(_,e),void 0!==e.gracenotes&&(o+=this.addGraceNotes(e,n,_,s,this.stemHeight*this.voiceScale,this.isBagpipes,o)),e.decoration){var B=t&&"up"!==i?Math.min(-3,_.bottom-6):_.bottom;this.decoration.createDecoration(n,e.decoration,_.top,s?s.w:0,_,o,i,B,e.positioning,this.hasVocals,this.accentAbove)}if(e.barNumber&&_.addFixed(new u(e.barNumber,-10,0,0,{type:"barNumber"})),A(_,e.minpitch,e.maxpitch,e.rest,h,d,i,-2,1),void 0!==e.chord){var P=x(this.getTextSize,_,e,o,l,h,this.jazzchords,this.germanAlphabet);o=P.roomTaken,l=P.roomTakenRight}return e.startTriplet&&(this.triplet=new b(e.startTriplet,s,{flatBeams:this.flatBeams})),e.endTriplet&&this.triplet&&this.triplet.setCloseAnchor(s),!this.triplet||e.startTriplet||e.endTriplet||e.rest&&"spacer"===e.rest.type||this.triplet.middleNote(s),_},E.prototype.addSlursAndTies=function(e,t,r,a,n,i){if(t.endTie&&this.ties.length>0){for(var s=!1,o=0;o10&&"treble"===t.abcelem.type?13.5:11;t.addFixed(new u(e,a,r.width,n+r.height/p.STEP,{type:"barNumber",dim:this.getTextSize.attr("measurefont","bar-number")}))},E.prototype.createBarLine=function(e,t,r){var n=new a(t,0,10,"bar",this.tuneNumber),i=null,s=0;t.barNumber&&this.addMeasureNumber(t.barNumber,n);var o="bar_right_repeat"===t.type||"bar_dbl_repeat"===t.type,c="bar_left_repeat"!==t.type&&"bar_thick_thin"!==t.type&&"bar_invisible"!==t.type,l="bar_right_repeat"===t.type||"bar_dbl_repeat"===t.type||"bar_left_repeat"===t.type||"bar_thin_thick"===t.type||"bar_thick_thin"===t.type,h="bar_left_repeat"===t.type||"bar_thick_thin"===t.type||"bar_thin_thin"===t.type||"bar_dbl_repeat"===t.type,f="bar_left_repeat"===t.type||"bar_dbl_repeat"===t.type;if(o||f){for(var p in this.slurs)this.slurs.hasOwnProperty(p)&&this.slurs[p].setEndX(n);this.startlimitelem=n}if(o&&(n.addRight(new u("dots.dot",s,1,7)),n.addRight(new u("dots.dot",s,1,5)),s+=6),c&&(i=new u(null,s,1,2,{type:"bar",pitch2:10,linewidth:.6}),n.addRight(i)),"bar_invisible"===t.type&&(i=new u(null,s,1,2,{type:"none",pitch2:10,linewidth:.6}),n.addRight(i)),t.decoration&&this.decoration.createDecoration(e,t.decoration,12,l?3:1,n,0,"down",2,t.positioning,this.hasVocals,this.accentAbove),l&&(i=new u(null,s+=4,4,2,{type:"bar",pitch2:10,linewidth:4}),n.addRight(i),s+=5),this.partstartelem&&t.endEnding&&(this.partstartelem.anchor2=i,this.partstartelem=null),h&&(i=new u(null,s+=3,1,2,{type:"bar",pitch2:10,linewidth:.6}),n.addRight(i)),f&&(s+=3,n.addRight(new u("dots.dot",s,1,7)),n.addRight(new u("dots.dot",s,1,5))),t.startEnding&&r&&0===e.voicenumber){var m=this.getTextSize.calc(t.startEnding,"repeatfont","").width;n.minspacing+=m+10,this.partstartelem=new d(t.startEnding,i,null),e.addOther(this.partstartelem)}return n.extraw-=5,void 0!==t.chord&&x(this.getTextSize,n,t,0,0,0,!1,this.germanAlphabet),n},e.exports=E},2652:function(e,t,r){var a=r(6658),n=r(4331),i=r(5810);function s(e,t,r,s,o,c,l,h,d,f,u,p,m,g,v){for(var b=e.split("\n"),y=b.length-1;y>=0;y--){var x,k=b[y],w=0;s||(k=i(k,g,v));var T=h.calc(k,o,c),C=T.width,S=T.height/n.STEP;switch(t){case"left":w=-(u+=C+7),x=f.averagepitch,d.addExtra(new a(k,w,C+4,x,{type:"text",height:S,dim:l,position:"left"}));break;case"right":w=p+=4,x=f.averagepitch,d.addRight(new a(k,w,C+4,x,{type:"text",height:S,dim:l,position:"right"}));break;case"below":d.addRight(new a(k,0,0,void 0,{type:"text",position:"below",height:S,dim:l,realWidth:C}));break;case"above":d.addRight(new a(k,0,0,void 0,{type:"text",position:"above",height:S,dim:l,realWidth:C}));break;default:if(r){var E=r.y+3*n.STEP;d.addRight(new a(k,w+r.x,0,f.minpitch+E/n.STEP,{position:"relative",type:"text",height:S,dim:l}))}else{var _="above";f.positioning&&f.positioning.chordPosition&&(_=f.positioning.chordPosition),"hidden"!==_&&d.addCentered(new a(k,m/2,C,void 0,{type:"chord",position:_,height:S,dim:l,realWidth:C}))}}}return{roomTaken:u,roomTakenRight:p}}e.exports=function(e,t,r,a,n,i,o,c){for(var l=0;l0?o.top+3:o.bottom-1,u=s>0?o.top+3:o.bottom-3,p=u-2;"bass-8"===e.type&&(f=3,d=0),o.addRight(new i("8",5+d,n.getSymbolWidth("8")*h,f,{scalex:h,scaley:h,top:u,bottom:p}))}}return o}},3923:function(e,t,r){var a=r(1409),n=r(6020),i=r(6658);e.exports=function(e,t){if(e.el_type="keySignature",!e.accidentals||0===e.accidentals.length)return null;var r=new a(e,0,10,"staff-extra key-signature",t);r.isKeySig=!0;var s=0;return e.accidentals.forEach((function(e){var t,a=0;switch(e.acc){case"sharp":t="accidentals.sharp",a=-3;break;case"natural":t="accidentals.nat";break;case"flat":t="accidentals.flat",a=-1.2;break;case"quartersharp":t="accidentals.halfsharp",a=-2.5;break;case"quarterflat":t="accidentals.halfflat",a=-1.2;break;default:t="accidentals.flat"}r.addRight(new i(t,s,n.getSymbolWidth(t),e.verticalPos,{thickness:n.symbolHeightInPitches(t),top:e.verticalPos+n.symbolHeightInPitches(t)+a,bottom:e.verticalPos+a})),s+=n.getSymbolWidth(t)+2}),this),r}},2143:function(e,t,r){var a=r(6020),n=r(6658);e.exports=function(e,t,r,i){i||(i={});var s,o=void 0!==i.dir?i.dir:null,c=void 0!==i.headx?i.headx:0,l=void 0!==i.extrax?i.extrax:0,h=void 0!==i.flag?i.flag:null,d=void 0!==i.dot?i.dot:0,f=void 0!==i.dotshiftx?i.dotshiftx:0,u=void 0!==i.scale?i.scale:1,p=void 0!==i.accidentalSlot?i.accidentalSlot:[],m=void 0!==i.shouldExtendStem&&i.shouldExtendStem,g=void 0===i.printAccidentals||i.printAccidentals,v=r.verticalPos,b=0,y=0,x=0;if(void 0===t)e.addFixed(new n("pitch is undefined",0,0,0,{type:"debug"}));else if(""===t)s=new n(null,0,0,v);else{var k=c;if(r.printer_shift){var w="same"===r.printer_shift?1:0;k="down"===o?-a.getSymbolWidth(t)*u+w:a.getSymbolWidth(t)*u-w}var T={scalex:u,scaley:u,thickness:a.symbolHeightInPitches(t)*u,name:r.name};if((s=new n(t,k,a.getSymbolWidth(t)*u,v,T)).stemDir=o,h){var C=v+("down"===o?-7:7)*u;m&&("down"===o&&C>6&&(C=6),"up"===o&&C<6&&(C=6));var S="down"===o?c:c+s.w-.6;e.addRight(new n(h,S,a.getSymbolWidth(h)*u,C,{scalex:u,scaley:u}))}for(y=s.w+f-2+5*d;d>0;d--){var E=1-Math.abs(v)%2;e.addRight(new n("dots.dot",s.w+f-2+5*d,a.getSymbolWidth("dots.dot"),v+E))}}if(s&&(s.highestVert=r.highestVert),g&&r.accidental){var _;switch(r.accidental){case"quartersharp":_="accidentals.halfsharp";break;case"dblsharp":_="accidentals.dblsharp";break;case"sharp":_="accidentals.sharp";break;case"quarterflat":_="accidentals.halfflat";break;case"flat":_="accidentals.flat";break;case"dblflat":_="accidentals.dblflat";break;case"natural":_="accidentals.nat"}for(var M=!1,N=l,A=0;A=6){p[A][0]=v,N=p[A][1],M=!0;break}!1===M&&(N-=a.getSymbolWidth(_)*u+2,p.push([v,N]),b=a.getSymbolWidth(_)*u+2);var B=a.symbolHeightInPitches(_);e.addExtra(new n(_,N,a.getSymbolWidth(_),v,{scalex:u,scaley:u,top:v+B/2,bottom:v-B/2})),x=a.getSymbolWidth(_)/2}return{notehead:s,accidentalshiftx:b,dotshiftx:y,extraLeft:x}}},2525:function(e,t,r){var a=r(1409),n=r(6020),i=r(6658);e.exports=function(e,t){e.el_type="timeSignature";var r=new a(e,0,10,"staff-extra time-signature",t);if("specified"===e.type)for(var s=0,o=0;o",this.dynamicPositioning)),this.startDiminuendoX=void 0),this.startCrescendoX&&(e.addOther(new n(this.startCrescendoX,f(e.children),"<",this.dynamicPositioning)),this.startCrescendoX=void 0)},l.prototype.dynamicDecoration=function(e,t,r,a){for(var s,o,c,l=0;l",a)),o&&e.addOther(new n(o.start,o.stop,"<",a)),c&&e.addOther(new i(c.start,c.stop))},l.prototype.createDecoration=function(e,t,r,n,i,l,d,f,u,p,m){u||(u={ornamentPosition:"above",volumePosition:p?"above":"below",dynamicPosition:p?"above":"below"}),function(e,t,r,n){for(var i=0;i9&&f++;var m=a/2;"center"!==s.getSymbolAlign(p)&&(m-=s.getSymbolWidth(p)/2),n.addFixedX(new o(p,m,s.getSymbolWidth(p),f))}if("slide"===t[u]&&n.heads[0]){var g=n.heads[0].pitch,v=new o("",-i-15,0,(g-=2)-1),b=new o("",-i-5,0,g+1);n.addFixedX(v),n.addFixedX(b),e.addOther(new c({anchor1:v,anchor2:b,fixedY:!0}))}}return void 0===f&&(f=r),{above:f,below:n.bottom}}(e,t,r,n,i,l,d,f,m);g.above=Math.max(g.above,this.minTop),g.below=Math.min(g.below,f),function(e,t,r,a,n,i,c,l){function h(e,t){"above"===e?a.above+=t:a.below-=t}function d(e){var t;return"above"===e?(t=a.above)c&&(t=c),t}function f(e,a,n){var i=d(a);r.addFixedX(new o(e,t/2,0,i+2,{type:"decoration",klass:"ornament",thickness:3,anchor:n})),h(a,5)}function u(e,a){var n=t/2;"center"!==s.getSymbolAlign(e)&&(n-=s.getSymbolWidth(e)/2);var i=s.symbolHeightInPitches(e)+1,c=d(a);c="above"===a?c+i/2:c-i/2,r.addFixedX(new o(e,n,s.getSymbolWidth(e),c,{klass:"ornament",thickness:s.symbolHeightInPitches(e),position:a})),h(a,i)}for(var p={"+":"scripts.stopped",open:"scripts.open",snap:"scripts.snap",wedge:"scripts.wedge",thumb:"scripts.thumb",shortphrase:"scripts.shortphrase",mediumphrase:"scripts.mediumphrase",longphrase:"scripts.longphrase",trill:"scripts.trill",trillh:"scripts.trill",roll:"scripts.roll",irishroll:"scripts.roll",marcato:"scripts.umarcato",dmarcato:"scripts.dmarcato",umarcato:"scripts.umarcato",turn:"scripts.turn",uppermordent:"scripts.prall",pralltriller:"scripts.prall",mordent:"scripts.mordent",lowermordent:"scripts.mordent",downbow:"scripts.downbow",upbow:"scripts.upbow",fermata:"scripts.ufermata",invertedfermata:"scripts.dfermata",breath:",",coda:"scripts.coda",segno:"scripts.segno"},m=0;mthis.w&&(this.w=e.dx+e.w),this.right[this.right.length]=e,this._addChild(e)},i.prototype.addFixed=function(e){this._addChild(e)},i.prototype.addFixedX=function(e){this._addChild(e)},i.prototype.addCentered=function(e){var t=e.w/2;-tthis.w&&(this.w=e.dx+t),this.right[this.right.length]=e,this._addChild(e)},i.prototype.setLimit=function(e,t){t[e]&&(this.specialY[e]?this.specialY[e]=Math.max(this.specialY[e],t[e]):this.specialY[e]=t[e])},i.prototype._addChild=function(e){var t=!0;"clef"==this.abcelem.el_type&&"barNumber"==e.type&&(t=!1),e.parent=this,this.children[this.children.length]=e,t&&this.pushTop(e.top),this.pushBottom(e.bottom),this.setLimit("tempoHeightAbove",e),this.setLimit("partHeightAbove",e),this.setLimit("volumeHeightAbove",e),this.setLimit("dynamicHeightAbove",e),this.setLimit("endingHeightAbove",e),this.setLimit("chordHeightAbove",e),this.setLimit("lyricHeightAbove",e),this.setLimit("lyricHeightBelow",e),this.setLimit("chordHeightBelow",e),this.setLimit("volumeHeightBelow",e),this.setLimit("dynamicHeightBelow",e)},i.prototype.pushTop=function(e){void 0!==e&&(void 0===this.top?this.top=e:this.top=Math.max(e,this.top))},i.prototype.pushBottom=function(e){void 0!==e&&(void 0===this.bottom?this.bottom=e:this.bottom=Math.min(e,this.bottom))},i.prototype.setX=function(e){this.x=e;for(var t=0;tthis.max)&&(this.max=e.abcelem.maxpitch))},t.prototype.addBeam=function(e){this.beams.push(e)},t.prototype.setStemDirection=function(){this.average=r(this.total,this.count),this.forceup?this.stemsUp=!0:this.forcedown?this.stemsUp=!1:this.stemsUp=this.average<6,delete this.count,this.total=0},t.prototype.calcDir=function(){this.average=r(this.total,this.elems.length),this.forceup?this.stemsUp=!0:this.forcedown?this.stemsUp=!1:this.stemsUp=this.average<6;for(var e=this.stemsUp?"up":"down",t=0;t0&&this.unalignedWords(e.unalignedWords,a,n,i,s),this.extraText(e,a,n,i,s),e.footer&&r&&this.footer(e.footer,t,a,s)}function s(e,t,r,a,i,s,o){r&&(t&&(r="string"==typeof r?t+r:[{text:t}].concat(r)),n(e,r,"historyfont",i=s?"abcjs-extra-text "+i:"","description",a,{absElemType:"extraText",anchor:"start"},o))}function o(e,t,r,i,s,o,c,l,h,d,f,u){if(r){l=f?"abcjs-extra-text "+l:"";var p=u.calc("A",s,l);if("string"==typeof r)t&&(r=t+"\n"+r),a(e,{marginLeft:i,text:r,font:s,absElemType:"extraText",name:h,"dominant-baseline":"middle",klass:l},u);else{e.push({startGroup:c,klass:l,name:h}),e.push({move:d.info}),t&&(a(e,{marginLeft:i,text:t,font:s,absElemType:"extraText",name:h,"dominant-baseline":"middle"},u),e.push({move:3*p.height/4}));for(var m=0;m0&&this.startVoice.staff.voices[0]===e)},e.exports=t},6891:function(e){e.exports=function(e,t,r,a){this.type="CrescendoElem",this.anchor1=e,this.anchor2=t,this.dir=r,"above"===a?this.dynamicHeightAbove=6:this.dynamicHeightBelow=6,this.pitch=void 0}},3185:function(e){e.exports=function(e,t,r){this.type="DynamicDecoration",this.anchor=e,this.dec=t,"below"===r?this.volumeHeightBelow=6:this.volumeHeightAbove=6,this.pitch=void 0}},8256:function(e){e.exports=function(e,t,r){this.type="EndingElem",this.text=e,this.anchor1=t,this.anchor2=r,this.endingHeightAbove=5,this.pitch=void 0}},3736:function(e){e.exports=function(e,t,r,a,n,i){var s,o=e.text;this.rows=[],t&&this.rows.push({move:t});var c=r.calc("textfont","defined-text");if(""===o)this.rows.push({move:2*c.attr["font-size"]});else if("string"==typeof o){this.rows.push({move:c.attr["font-size"]/2}),this.rows.push({left:a,text:o,font:"textfont",klass:"defined-text",anchor:"start",startChar:e.startChar,endChar:e.endChar,absElemType:"freeText",name:"free-text"});var l=o.replace(/^[ \t]*\n/gm,"X\n");s=i.calc(l,"textfont","defined-text"),this.rows.push({move:s.height})}else if(o){for(var h=0,d=a,f="textfont",u=0;uthis.top&&(this.top=this.pitch2),this.bottom=a,void 0!==this.pitch2&&this.pitch20?this.top+=n.stemHeight:this.bottom+=n.stemHeight),n.dim&&(this.dim=n.dim),n.position&&(this.position=n.position),this.height=n.height?n.height:4,n.top&&(this.top=n.top),n.bottom&&(this.bottom=n.bottom),n.name?this.name=n.name:this.c?this.name=this.c:this.name=this.type,n.realWidth?this.realWidth=n.realWidth:this.realWidth=this.w,this.centerVertically=!1,this.type){case"debug":this.chordHeightAbove=this.height;break;case"lyric":n.position&&"below"===n.position?this.lyricHeightBelow=this.height:this.lyricHeightAbove=this.height;break;case"chord":n.position&&"below"===n.position?this.chordHeightBelow=this.height:this.chordHeightAbove=this.height;break;case"text":void 0===this.pitch?n.position&&"below"===n.position?this.chordHeightBelow=this.height:this.chordHeightAbove=this.height:this.centerVertically=!0;break;case"part":this.partHeightAbove=this.height}};t.prototype.getChordDim=function(){if("debug"===this.type)return null;if(!this.chordHeightAbove&&!this.chordHeightBelow)return null;var e="chord"===this.type?this.realWidth/2:0,t=this.x-e-0;return{left:t,right:t+this.realWidth+0}},t.prototype.invertLane=function(e){void 0===this.lane&&(this.lane=0),this.lane=e-this.lane-1},t.prototype.putChordInLane=function(e){this.lane=e,this.chordHeightAbove?this.chordHeightAbove=1.25*this.height*this.lane:this.chordHeightBelow=1.25*this.height*this.lane},t.prototype.getLane=function(){return void 0===this.lane?0:this.lane},t.prototype.setX=function(e){this.x=e+this.dx},e.exports=t},6994:function(e,t,r){var a=r(1716);e.exports=function(e,t,r,n,i,s,o,c){var l=c.calc("i",r,n);if(""===t)e.push({move:l.height});else{if("string"==typeof t)return void a(e,{marginLeft:s,text:t,font:r,klass:n,marginTop:o.marginTop,anchor:o.anchor,absElemType:o.absElemType,info:o.info,name:i},c);o.marginTop&&e.push({move:o.marginTop});var h=0,d={left:s,anchor:o.anchor,phrases:[]};n&&(d.klass=n),e.push(d);for(var f=0;f0)this.above=!1;else{var e;e=this.anchor1?this.anchor1.pitch:this.anchor2?this.anchor2.pitch:14,this.anchor1&&"down"===this.anchor1.stemDir&&this.anchor2&&"down"===this.anchor2.stemDir?this.above=!0:this.anchor1&&"up"===this.anchor1.stemDir&&this.anchor2&&"up"===this.anchor2.stemDir?this.above=!1:this.anchor1&&this.anchor2?this.above=e>=6:this.anchor1?this.above="down"===this.anchor1.stemDir:this.anchor2?this.above="down"===this.anchor2.stemDir:this.above=e>=6}},t.prototype.calcSlurDirection=function(){if(this.isGrace)this.above=!1;else if(0===this.voiceNumber)this.above=!0;else if(this.voiceNumber>0)this.above=!1;else{var e=!1;this.anchor1&&"down"===this.anchor1.stemDir&&(e=!0),this.anchor2&&"down"===this.anchor2.stemDir&&(e=!0);for(var t=0;te&&(e=this.internalNotes[t].highestVert);e>this.startY&&e>this.endY&&(this.startY=this.endY=e-1)}},t.prototype.getYBounds=function(){var e,t;return this.isTie?(this.calcTieDirection(),this.calcX(10,1e3),this.calcTieY()):(this.calcSlurDirection(),this.calcX(10,1e3),this.calcSlurY()),this.above?e=(t=Math.min(this.startY,this.endY))+3:t=(e=Math.min(this.startY,this.endY))-3,[e,t]},e.exports=t},1134:function(e,t,r){var a=r(1716),n=r(6994);e.exports=function(e,t,r,i,s,o,c,l,h,d){if(this.rows=[],e.header&&o){var f=d.calc("X","headerfont","abcjs-header abcjs-meta-top").height;a(this.rows,{marginLeft:c,text:e.header.left,font:"headerfont",klass:"header meta-top",marginTop:-f,info:t.header,name:"header"},d),a(this.rows,{marginLeft:c+s/2,text:e.header.center,font:"headerfont",klass:"header meta-top",marginTop:-f,anchor:"middle",info:t.header,name:"header"},d),a(this.rows,{marginLeft:c+s,text:e.header.right,font:"headerfont",klass:"header meta-top",marginTop:-f,anchor:"end",info:t.header,name:"header"},d)}o&&this.rows.push({move:l.top});var u=r.titleleft?"start":"middle",p=r.titleleft?c:c+s/2;if(e.title){var m=h?"abcjs-title":"";n(this.rows,e.title,"titlefont",m,"title",p,{marginTop:l.title,anchor:u,absElemType:"title",info:t.title},d)}if(i.length)for(var g=0;g0){var v=!(!e.composer&&!e.origin);m=h?"abcjs-rhythm":"",a(this.rows,{marginLeft:c,text:e.rhythm,font:"infofont",klass:m,absElemType:"rhythm",noMove:v,info:t.rhythm,name:"rhythm"},d)}e.composer&&e.composer,e.origin&&e.origin;var b=e.composer?e.composer:"";e.origin&&("string"==typeof b&&"string"==typeof e.origin?b+=" ("+e.origin+")":"string"==typeof b&&"string"!=typeof e.origin?((b=[{text:b}]).push({text:" ("}),(b=b.concat(e.origin)).push({text:")"})):(b.push({text:" ("}),(b=b.concat(e.origin)).push({text:")"}))),b&&(m=h?"abcjs-composer":"",n(this.rows,b,"composerfont",m,"composer",c+s,{anchor:"end",absElemType:"composer",info:t.composer,ingroup:!0},d))}e.author&&e.author.length>0&&(m=h?"abcjs-author":"",n(this.rows,e.author,"composerfont",m,"author",c+s,{anchor:"end",absElemType:"author",info:t.author},d)),e.partOrder&&e.partOrder.length>0&&(m=h?"abcjs-part-order":"",n(this.rows,e.partOrder,"partsfont",m,"part-order",c,{absElemType:"partOrder",info:t.partOrder,anchor:"start"},d))}},2096:function(e){var t=function(e,t,r){this.type="TripletElem",this.anchor1=t,this.number=e,this.durationClass=("d"+Math.round(1e3*t.parent.durationClass)/1e3).replace(/\./,"-"),this.middleElems=[],this.flatBeams=r.flatBeams};t.prototype.isClosed=function(){return!!this.anchor2},t.prototype.middleNote=function(e){this.middleElems.push(e)},t.prototype.setCloseAnchor=function(e){this.anchor2=e,this.anchor1.parent.beam&&"up"!==this.anchor1.stemDir||(this.endingHeightAbove=4)},e.exports=t},3197:function(e){var t=function(e,t){this.children=[],this.beams=[],this.otherchildren=[],this.w=0,this.duplicate=!1,this.voicenumber=e,this.voicetotal=t,this.bottom=7,this.top=7,this.specialY={tempoHeightAbove:0,partHeightAbove:0,volumeHeightAbove:0,dynamicHeightAbove:0,endingHeightAbove:0,chordHeightAbove:0,lyricHeightAbove:0,lyricHeightBelow:0,chordHeightBelow:0,volumeHeightBelow:0,dynamicHeightBelow:0}};t.prototype.addChild=function(e){if("bar"===e.type){for(var t=!0,r=0;t&&r0&&"TempoElement"===t.children[0].type;t.elemset=[],o.beginGroup(e.paper,e.controller);for(var d=0;d=0&&u.setAttribute("class","abcjs-notehead")}}var p=t.type;if(("note"===t.type||"rest"===t.type)&&(t.counters=e.controller.classes.getCurrent(),p=(p+=" d"+Math.round(1e3*t.durationClass)/1e3).replace(/\./g,"-"),t.abcelem.pitches))for(var m=0;m0?g.classList[0]+" ":"";g.setAttribute("class",v+t.overrideClasses)}if(h)t.startChar=t.abcelem.startChar,t.endChar=t.abcelem.endChar,c.add(t,g,!1,l);else{t.elemset.push(g);var b=!1;"note"!==t.type&&"tabNumber"!==t.type||(b=!0),c.add(t,g,b,l)}}else t.elemset.length>0&&c.add(t,t.elemset[0],"note"===t.type,l);if(t.klass&&s(t.elemset,"mark","","#00ff00"),t.hint&&s(t.elemset,"abcjs-hint","",null),t.abcelem.abselem=t,t.heads&&t.heads.length>0){t.notePositions=[];for(var y=0;ys&&l>=14;)l-=2,o.setAttribute("font-size",l),c=o.getBBox()}var c=20,l=-3;function h(e){return"No Chord"===e?"N.C.":e}function d(e,t,r,a,n,i,s,o,c){var l={x:r,y:a,stroke:"none","font-size":n,"font-style":i.style,"font-family":i.face,"font-weight":i.weight,"text-decoration":i.decoration};return s&&(l["data-name"]=s),o&&(l.class=o),l["text-anchor"]=c?"middle":"start",e.paper.text(t,l,null,{"alignment-baseline":"middle"})}e.exports=function(e,t,r,n,f){var u=f.gchordfont,p=(f.partsfont,f.annotationfont),m=f.repeatfont,g=f.textfont,v=f.subtitlefont,b=50;e.paper.openGroup({klass:"abcjs-chord-grid"}),t.forEach((function(t){switch(t.type){case"text":d(e,t.text,r,e.y,16,g,null,null,!1),e.moveY(16);break;case"subtitle":d(e,t.subtitle,r,e.y+10,20,v,null,"abcjs-subtitle",!1),e.moveY(20);break;case"part":if(t.lines.length>0){d(e,t.name,r,e.y+10,20,v,t.name,"abcjs-part",!1),e.moveY(20);var f=t.lines[0].length,y=n/f;t.lines.forEach((function(t,n){var f=!1,g=!1;t.forEach((function(e){e.ending&&(f=!0),e.annotations&&e.annotations.length>0&&(g=!0)}));var v=g?14:f?10:0;t.forEach((function(t,n){if(!t.noBorder){e.paper.rect({x:r+n*y,y:e.y,width:y,height:v+b}),e.paper.rect({x:r+n*y+1,y:e.y+1,width:y-2,height:v+b-2});var f=0,g=0,x=e.y,k=r+y*n;t.hasStartRepeat&&(i(e,k,x,x+b+v,!0,v),f=12),t.hasEndRepeat&&(i(e,k+y,x,x+b+v,!1,v),g=12);var w=0;t.ending&&(w=d(e,t.ending,r+n*y+4,x+10,12,m,null,null,!1).getBBox().width+4),!function(e,t,r,n,i,s,d,f,u,p,m){var g=r+n*s;d[1]||d[2]||d[3]?d[1]||d[3]?function(e,t,r,a,n,i,s,d){var f=3;e.paper.lineToBack({x1:t+f,x2:t+a-f,y1:r+n/2+d,y2:r+n/2+d}),e.paper.lineToBack({x1:t+a/2,x2:t+a/2,y1:r+f+d,y2:r+n-f+d}),i[0]&&o(e,t+a/4,r+n/4+2+d+l,c,h(i[0]),s,a/2),i[1]&&o(e,t+3*a/4,r+n/4+2+d+l,c,h(i[1]),s,a/2),i[2]&&o(e,t+a/4,r+3*n/4+d+l,c,h(i[2]),s,a/2),i[3]&&o(e,t+3*a/4,r+3*n/4+d+l,c,h(i[3]),s,a/2)}(e,g,t,n-u,p,d,f,m):function(e,t,r,a,n,i,s,c,h){e.paper.lineToBack({x1:t,x2:t+a,y1:r+n+h,y2:r+2}),o(e,t+a/4,r+n/4+5+h+l,26,i,c,a/2),o(e,t+3*a/4,r+3*n/4+h+l,26,s,c,a/2)}(e,g,t,n-u,p,d[0],d[2],f,m):function(e,t,r,n,i,s,c,h){"%"===s?function(e,t,r,n){var i=t-10,s=t+10,o=r+10,c=r-10,l=t-10,h=2-e.yToPitch(n),d=t+6.5,f=-e.yToPitch(n)-2.3;e.paper.lineToBack({x1:i,x2:s,y1:o,y2:c,"stroke-width":"3px","stroke-linecap":"round"}),a(e,l,h,"dots.dot",{scalex:1,scaley:1,klass:"",name:"dot"}),a(e,d,f,"dots.dot",{scalex:1,scaley:1,klass:"",name:"dot"})}(e,t+n/2,r+i/2,h+i/2):o(e,t+n/2,r+i/2+l,34,s,c,n)}(e,g,t+m,n-u,p,d[0],f,m)}(e,x,r+f,y,0,n,t.chord,u,f+g,b,v),t.annotations&&t.annotations.length>0&&function(e,t,r,n,i){r+=3;for(var o=0;or.formatting.maxStaves)break;t.shouldAddClasses&&(b.klass="abcjs-staff-wrapper abcjs-l"+t.lineNumber),e.paper.openGroup(b),T.vskip&&e.moveY(T.vskip),x.length>=1&&h(e,e.spacing.staffSeparation,x[x.length-1],T.staffGroup);var C=l(e,T.staffGroup,v,w);C.line=m+w,x.push(C),e.paper.closeGroup()}else T.nonMusic&&(t.shouldAddClasses&&(b.klass="abcjs-non-music"),e.paper.openGroup(b),i(e,T.nonMusic,v),e.paper.closeGroup())}return t.reset(),y||r.bottomText&&r.bottomText.rows&&r.bottomText.rows.length>0&&(t.shouldAddClasses&&(b.klass="abcjs-meta-bottom"),e.paper.openGroup(b),e.moveY(24),i(e,r.bottomText,v),e.paper.closeGroup()),n(e,s,f,d),{staffgroups:x,selectables:v.getElements()}}},9879:function(e,t,r){var a=r(4777);e.exports=function(e,t,r){void 0===t.pitch&&window.console.error("Dynamic Element y-coordinate not set.");var n=a(e,t.anchor.x,t.pitch,t.dec,{scalex:1,scaley:1,klass:e.controller.classes.generate("decoration dynamics"),fill:e.foregroundColor,stroke:"none",name:"dynamics"});return r.wrapSvgEl({el_type:"dynamicDecoration",startChar:-1,endChar:-1,decoration:t.dec},n),[n]}},5947:function(e,t,r){var a=r(6764),n=r(5759),i=r(6454),s=r(7199);e.exports=function(e,t,r,o,c){void 0===t.pitch&&window.console.error("Ending Element y-coordinate not set.");var l=s(e.calcY(t.pitch)),h="";t.anchor1&&(r=s(t.anchor1.x+t.anchor1.w),h+=a("M %f %f L %f %f ",r,l,r,s(l+20))),t.anchor2&&(o=s(t.anchor2.x),h+=a("M %f %f L %f %f ",o,l,o,s(l+20))),h+=a("M %f %f L %f %f ",r,l,o,l),e.paper.openGroup({klass:e.controller.classes.generate("ending"),fill:e.foregroundColor,"data-name":"ending"}),i(e,{path:h,stroke:e.foregroundColor,fill:e.foregroundColor,"data-name":"line"}),t.anchor1&&n(e,{x:s(r+5),y:s(e.calcY(t.pitch-.5)),text:t.text,type:"repeatfont",klass:"ending",anchor:"start",noClass:!0,name:t.text});var d=e.paper.closeGroup();return c.wrapSvgEl({el_type:"ending",startChar:-1,endChar:-1},d),[d]}},9045:function(e,t,r){var a=r(6764),n=r(6454),i=r(7199);function s(e,t,r){return i(e+r*t)}var o=[[3.5,-4.8]],c=[[1.5,-1],[.3,-.3],[-3.5,3.8]],l=[[-1.5,2]],h=[[3,4],[3,-4]],d=[[-3,4],[-3,-4]];function f(e,t){for(var r="",a=0;a1&&s.indexOf(".")<0){var p=i.isInGroup()?"":o.klass;e.paper.openGroup({"data-name":o.name,klass:p});for(var m=0,g=0;g0?t.linewidth+e.lineThickness:t.linewidth-e.lineThickness;t.graphelem=n(e,t.x,d,o,e.calcY(t.pitch2),"abcjs-stem","stem");break;case"ledger":t.graphelem=i(e,t.x,t.x+t.w,t.pitch,"abcjs-ledger","ledger",.35+e.lineThickness)}return 1!==t.scalex&&t.graphelem&&function(e,t,r,a,n,i){e.setAttributeOnElement(t,{style:"transform:scale("+r+","+a+");transform-origin:"+n+"px "+i+"px;"})}(e.paper,t.graphelem,t.scalex,t.scaley,t.x,o),t.graphelem}},7199:function(e){e.exports=function(e){return parseFloat(e.toFixed(2))}},3524:function(e,t,r){var a=r(5741),n=r(5829);function i(e,t,r){this.elements=[],this.paper=e,this.tuneNumber=r,this.selectTypes=t}i.prototype.getElements=function(){return this.elements},i.prototype.add=function(e,t,r,a){if(this.canSelect(e)){var n;n=void 0===this.selectTypes?{selectable:!1,"data-index":this.elements.length}:{selectable:!0,tabindex:0,"data-index":this.elements.length},this.paper.setAttributeOnElement(t,n);var i={absEl:e,svgEl:t,isDraggable:r};void 0!==a&&(i.staffPos=a),this.elements.push(i)}},i.prototype.canSelect=function(e){return!(!1===this.selectTypes||!e||!e.abcelem||!0!==this.selectTypes&&!(void 0===this.selectTypes?"note"===e.abcelem.el_type||"tabNumber"===e.abcelem.el_type:this.selectTypes.indexOf(e.abcelem.el_type)>=0))},i.prototype.wrapSvgEl=function(e,t){var r={tuneNumber:this.tuneNumber,abcelem:e,elemset:[t],highlight:a,unhighlight:n};this.add(r,t,!1)},e.exports=i},4169:function(e){e.exports=function(e,t){var r=Math.round(e.y),a=(e.controller.width-t)/2,n=a+t,i="M "+a+" "+r+" L "+n+" "+r+" L "+n+" "+(r+1)+" L "+a+" "+(r+1)+" L "+a+" "+r+" z";e.paper.pathToBack({path:i,stroke:"rgba(0,0,0,0)",fill:"rgba(0,0,0,255)",class:e.controller.classes.generate("defined-text")})}},7611:function(e){e.exports=function(e,t,r,a){var n=(t+e.padding.left+e.padding.right)*r,i=(e.y+e.padding.bottom)*r;if(e.isPrint&&(i=Math.max(i,1056)),""!==e.ariaLabel){var s="Sheet Music";e.abctune&&e.abctune.metaText&&e.abctune.metaText.title&&(s+=' for "'+e.abctune.metaText.title+'"'),e.paper.setTitle(s);var o=e.ariaLabel?e.ariaLabel:s;e.paper.setAttribute("aria-label",o)}e.paper.insertStyles(".abcjs-dragging-in-progress text, .abcjs-dragging-in-progress tspan {"+["-webkit-touch-callout: none;","-webkit-user-select: none;","-khtml-user-select: none;","-moz-user-select: none;","-ms-user-select: none;","user-select: none;"].join(" ")+"}");var c={overflow:"hidden"};"resize"===a?e.paper.setResponsiveWidth(n,i):(c.width="",c.height=i+"px",r<1?(c.width=n+"px",e.paper.setSize(n/r,i/r)):e.paper.setSize(n,i)),e.paper.setScale(r),e.paper.setParentStyles(c)}},6764:function(e){function t(e){return t="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},t(e)}e.exports=function(){for(var e,r,a,n,i,s=0,o=arguments[s++],c=[];o;){if(r=/^[^\x25]+/.exec(o))c.push(r[0]);else if(r=/^\x25{2}/.exec(o))c.push("%");else{if(!(r=/^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(o)))throw"Huh ?!";if(null==(e=arguments[r[1]||s++])||null==e)throw"Too few arguments.";if(/[^s]/.test(r[7])&&"number"!=typeof e)throw"Expecting number but found "+t(e);switch(r[7]){case"b":e=e.toString(2);break;case"c":e=String.fromCharCode(e);break;case"d":e=parseInt(e);break;case"e":e=r[6]?e.toExponential(r[6]):e.toExponential();break;case"f":e=r[6]?parseFloat(e).toFixed(r[6]):parseFloat(e);break;case"o":e=e.toString(8);break;case"s":e=(e=String(e))&&r[6]?e.substring(0,r[6]):e;break;case"u":e=Math.abs(e);break;case"x":e=e.toString(16);break;case"X":e=e.toString(16).toUpperCase()}e=/[def]/.test(r[7])&&r[2]&&e>0?"+"+e:e,n=r[3]?"0"==r[3]?"0":r[3][1]:" ",i=r[5]-String(e).length,a=r[5]?str_repeat(n,i):"",c.push(r[4]?e+a:a+e)}o=o.substring(r[0].length)}return c.join("")}},5537:function(e,t,r){var a=r(4331),n=r(129),i=r(3145),s=r(7641),o=r(1547),c=r(3624),l=r(5668);function h(e,t,r,i,s){if(r)for(var o=0;o=0&&v.voices&&d(e,t.voices,v.voices),e.showDebug.indexOf("grid")>=0&&(e.paper.dottedLine({x1:e.padding.left,x2:e.padding.left+e.controller.width,y1:m,y2:m,stroke:"#0000ff"}),o(e,{x:e.padding.left,y:e.calcY(v.originalTop),width:e.controller.width,height:e.calcY(v.originalBottom)-e.calcY(v.originalTop),fill:e.foregroundColor,stroke:e.foregroundColor,"fill-opacity":.1,"stroke-opacity":.1}),f=0,_(v,"chordHeightAbove"),_(v,"chordHeightBelow"),_(v,"dynamicHeightAbove"),_(v,"dynamicHeightBelow"),_(v,"endingHeightAbove"),_(v,"lyricHeightAbove"),_(v,"lyricHeightBelow"),_(v,"partHeightAbove"),_(v,"tempoHeightAbove"),_(v,"volumeHeightAbove"),_(v,"volumeHeightBelow"))),e.moveY(a.STEP,-v.bottom),e.showDebug&&e.showDebug.indexOf("grid")>=0&&e.paper.dottedLine({x1:e.padding.left,x2:e.padding.left+e.controller.width,y1:e.y,y2:e.y,stroke:"#0000aa"})}for(var b=2,y=0,x=0;x6&&(f=0)}}E>1&&(u=t.staffs[0].topLine,p=t.staffs[E-1].bottomLine,c(e,t.startx,.6,u,p,null)),e.y=m}},7865:function(e,t,r){var a=r(6637);e.exports=function(e,t,r,n,i,s,o){var c=e.calcY(n);return a(e,t,r,c,i,s,o)}},7641:function(e,t,r){var a=r(7865);e.exports=function(e,t,r,n,i,s){var o="abcjs-top-line",c=2;i&&(c=i),e.paper.openGroup({prepend:!0,klass:e.controller.classes.generate("abcjs-staff")});var l=0,h=0;if(1===n)a(e,t,r,6,o,null,s+e.lineThickness),l=e.calcY(10),h=e.calcY(2);else for(var d=n-1;d>=0;d--){var f=(d+1)*c;h=e.calcY(f),0===l&&(l=h),a(e,t,r,f,o,null,s+e.lineThickness),o=void 0}return e.paper.closeGroup(),[l,h]}},3987:function(e,t,r){var a=r(2435),n=r(5759);e.exports=function(e,t){var r=t.x;void 0===t.pitch&&window.console.error("Tempo Element y-coordinate not set."),t.tempo.el_type="tempo";var i,s=e.calcY(t.pitch)+2;if(t.tempo.preString){i=n(e,{x:r,y:s,text:t.tempo.preString,type:"tempofont",klass:"abcjs-tempo",anchor:"start",noClass:!0,name:"pre"},!0);var o=e.controller.getTextSize.calc(t.tempo.preString,"tempofont","tempo",i).width;r+=o+o/t.tempo.preString.length}if(t.note){t.note.setX(r);for(var c=0;c.1||(this.scale=void 0),t.staffwidth?(this.staffwidthScreen=t.staffwidth,this.staffwidthPrint=t.staffwidth):(this.staffwidthScreen=740,this.staffwidthPrint=680),this.listeners=[],t.clickListener&&this.addSelectListener(t.clickListener),this.renderer=new i(e),this.renderer.setPaddingOverride(t),t.showDebug&&(this.renderer.showDebug=t.showDebug),t.jazzchords&&(this.jazzchords=t.jazzchords),t.accentAbove&&(this.accentAbove=t.accentAbove),t.germanAlphabet&&(this.germanAlphabet=t.germanAlphabet),t.lineThickness&&(this.lineThickness=t.lineThickness),t.chordGrid&&(this.chordGrid=t.chordGrid),this.renderer.controller=this,this.renderer.foregroundColor=t.foregroundColor?t.foregroundColor:"currentColor",void 0!==t.ariaLabel&&(this.renderer.ariaLabel=t.ariaLabel),this.renderer.minPadding=t.minPadding?t.minPadding:0,this.reset()};function x(e){for(var t=document.createElementNS("http://www.w3.org/2000/svg","svg"),r=0;r0)for(var o=s.staffGroup.voices[0],c=!1,l=0,h=0;hthis.width+1&&(e.topText=new l(e.metaText,e.metaTextInfo,e.formatting,e.lines,i,this.renderer.isPrint,this.renderer.padding.left,this.renderer.spacing,this.classes.shouldAddClasses,this.getTextSize),e.lines&&e.lines.length>0))for(var s=e.lines.length,o=0;o0)for(var h=c.nonMusic.rows.length,u=0;u0&&c.text[0].center)&&(p.left=i/2+this.renderer.padding.left)}}e.tablatures&&v.layoutTablatures(this.renderer,e);var m=g(this.renderer,this.classes,e,this.width,i,this.responsive,n,this.selectTypes,t,r,this.chordGrid);if(this.staffgroups=m.staffgroups,this.selectables=m.selectables,this.oneSvgPerLine){var b=this.renderer.paper.svg.parentNode;this.svgs=function(e,t,r,a,n){r||(r="Untitled");var i=t.querySelector("svg");"resize"===a&&(t.style.paddingBottom="");for(var s=i.querySelector("style"),o="resize"===a?i.viewBox.baseVal.width:i.getAttribute("width"),c=t.querySelectorAll("svg > g"),l=0,h=[],d=0;d0&&t.push(e),"abcjs-tab-number"===e)return t.join(" ");if("text instrument-name"===e)return"abcjs-text abcjs-instrument-name";if(null!==this.lineNumber&&t.push("l"+this.lineNumber),null!==this.measureNumber&&t.push("m"+this.measureNumber),null!==this.measureNumber&&t.push("mm"+this.measureTotal()),null!==this.voiceNumber&&t.push("v"+this.voiceNumber),e&&(e.indexOf("note")>=0||e.indexOf("rest")>=0||e.indexOf("lyric")>=0)&&null!==this.noteNumber&&t.push("n"+this.noteNumber),t.length>0){t=(t=t.join(" ")).split(" ");for(var r=0;r0&&(t[r]="abcjs-"+t[r])}return t.join(" ")},e.exports=t},1328:function(e){var t=function(e,t){this.formatting=e,this.classes=t};t.prototype.updateFonts=function(e){e.gchordfont&&(this.formatting.gchordfont=e.gchordfont),e.tripletfont&&(this.formatting.tripletfont=e.tripletfont),e.annotationfont&&(this.formatting.annotationfont=e.annotationfont),e.vocalfont&&(this.formatting.vocalfont=e.vocalfont)},t.prototype.getFamily=function(e){return'"'===e[0]&&'"'===e[e.length-1]?e.substring(1,e.length-1):e},t.prototype.calc=function(e,t){var r;r="string"==typeof e?(r=this.formatting[e])?{face:r.face,size:Math.round(4*r.size/3),decoration:r.decoration,style:r.style,weight:r.weight,box:r.box}:{face:"Arial",size:Math.round(16),decoration:"underline",style:"normal",weight:"normal"}:{face:e.face,size:Math.round(4*e.size/3),decoration:e.decoration,style:e.style,weight:e.weight,box:e.box};var a=this.formatting.fontboxpadding?this.formatting.fontboxpadding:.1;return r.padding=r.size*a,{font:r,attr:{"font-size":r.size,"font-style":r.style,"font-family":this.getFamily(r.face),"font-weight":r.weight,"text-decoration":r.decoration,class:this.classes.generate(t)}}},e.exports=t},9799:function(e){var t=function(e,t){this.getFontAndAttr=e,this.svg=t};t.prototype.updateFonts=function(e){this.getFontAndAttr.updateFonts(e)},t.prototype.attr=function(e,t){return this.getFontAndAttr.calc(e,t)},t.prototype.getFamily=function(e){return'"'===e[0]&&'"'===e[e.length-1]?e.substring(1,e.length-1):e},t.prototype.calc=function(e,t,r,a){var n;n="string"==typeof t?this.attr(t,r):{font:{face:t.face,size:t.size,decoration:t.decoration,style:t.style,weight:t.weight},attr:{"font-size":t.size,"font-style":t.style,"font-family":this.getFamily(t.face),"font-weight":t.weight,"text-decoration":t.decoration,class:this.getFontAndAttr.classes.generate(r)}};var i=this.svg.getTextSize(e,n.attr,a);return n.font.box?{height:i.height+4*n.font.padding,width:i.width+4*n.font.padding}:i},t.prototype.baselineToCenter=function(e,t,r,a,n){return.5*this.calc(e,t,r).height+(n-a-2)*this.attr(t,r).font.size},e.exports=t},2187:function(e){e.exports=function(e,t,r,a){if(e)for(var n=0;n0&&(o.length>0&&" "!==o[o.length-1]&&(o+=" "),o+=t),i.setAttribute("class",o)}}},4331:function(e){var t={FONTEM:360,FONTSIZE:30};t.STEP=93*t.FONTSIZE/720,t.SPACE=10,t.TOPNOTE=15,t.STAVEHEIGHT=100,t.INDENT=50,e.exports=t},8123:function(e){function t(e,t,r,a){if(0===e.indexOf(t)){var n=e.replace(t,""),i=parseInt(n,10);""+i===n&&(r[a]=i)}}e.exports=function(e,r){var a=[];if(e.absEl.elemset){for(var n={},i=0;i=0&&r=0?(n=function(e,t,r){return e.x<=t.offsetX&&e.x+e.width>=t.offsetX&&e.y<=t.offsetY&&e.y+e.height>=t.offsetY||Math.abs(t.layerY/r-t.offsetY)<3?[t.offsetX,t.offsetY]:[t.layerX,t.layerY]}(e.selectables[i].svgEl.getBBox(),t,e.scale),r=n[0],a=n[1]):(n=function(e){var t,r,a=1,n=1,i=e.target.closest("svg"),s=0;return i&&i.viewBox&&i.viewBox.baseVal&&(0!==i.viewBox.baseVal.width&&(a=i.viewBox.baseVal.width/i.clientWidth),0!==i.viewBox.baseVal.height&&(n=i.viewBox.baseVal.height/i.clientHeight),s=i.viewBox.baseVal.y),e.target&&"svg"===e.target.tagName?(t=e.offsetX,r=e.offsetY):(t=e.layerX,r=e.layerY),[t*=a,(r*=n)+s]}(t),i=function(e,t,r){for(var a=9999999,n=-1,i=0;i0;i++){var s=e.selectables[i];if(e.getDim(s),s.dim.leftt&&s.dim.topr)n=i,a=0;else if(s.dim.topr){var o=Math.min(Math.abs(s.dim.left-t),Math.abs(s.dim.right-t));ot){var c=Math.min(Math.abs(s.dim.top-r),Math.abs(s.dim.bottom-r));cMath.abs(t-s.dim.right)?Math.abs(t-s.dim.right):Math.abs(t-s.dim.left),h=Math.abs(r-s.dim.top)>Math.abs(r-s.dim.bottom)?Math.abs(r-s.dim.bottom):Math.abs(r-s.dim.top),d=Math.sqrt(l*l+h*h);d=0&&a<=12?n:-1}(e,r=n[0],a=n[1])),{x:r,y:a,clickedOn:i}}function l(e){if(e&&e.target&&e.touches&&!(e.touches.length<1)){var t=e.target.getBoundingClientRect(),r=e.touches[0].pageX-t.left,a=e.touches[0].pageY-t.top;e.touches[0].offsetX=r,e.touches[0].offsetY=a,e.touches[0].layerX=e.touches[0].pageX,e.touches[0].layerY=e.touches[0].pageY}}function h(e){var t=e;"touchstart"===e.type&&(l(e),e.touches.length>0&&(t=e.touches[0]));var r=c(this,t);r.clickedOn>=0&&("touchstart"===e.type||0===e.button)&&this.selectables[r.clickedOn]&&(this.dragTarget=this.selectables[r.clickedOn],this.dragIndex=r.clickedOn,this.dragMechanism="mouse",this.dragMouseStart={x:r.x,y:r.y},this.dragging&&this.dragTarget.isDraggable&&(function(e,t){if(e){var r=v(e.svg);r[t]=!0,b(e.svg,r)}}(this.renderer.paper,"abcjs-dragging-in-progress"),this.dragTarget.absEl.highlight(void 0,this.dragColor)))}function d(e){var t=e;if("touchmove"===e.type&&(l(e),e.touches.length>0&&(t=e.touches[0])),this.lastTouchMove=e,this.dragTarget&&this.dragging&&this.dragTarget.isDraggable&&"mouse"===this.dragMechanism&&this.dragMouseStart){var r=c(this,t),n=Math.round((r.y-this.dragMouseStart.y)/a.STEP);n!==this.dragYStep&&(this.dragYStep=n,this.dragTarget.svgEl.setAttribute("transform","translate(0,"+n*a.STEP+")"))}}function f(e){var t=e;"touchend"===e.type&&this.lastTouchMove&&(l(this.lastTouchMove),this.lastTouchMove&&this.lastTouchMove.touches&&this.lastTouchMove.touches.length>0&&(t=this.lastTouchMove.touches[0])),this.dragTarget&&(m.bind(this)(),this.dragTarget.absEl&&this.dragTarget.absEl.highlight&&(this.selected=[this.dragTarget.absEl],this.dragTarget.absEl.highlight(void 0,this.selectionColor)),p.bind(this)(this.dragTarget,this.dragYStep,this.selectables.length,this.dragIndex,t),this.dragTarget.svgEl&&this.dragTarget.svgEl.focus&&(this.dragTarget.svgEl.focus(),this.dragTarget=null,this.dragIndex=-1),function(e,t){if(e){var r=v(e.svg);delete r[t],b(e.svg,r)}}(this.renderer.svg,"abcjs-dragging-in-progress"))}function u(e){e>=0&&eo&&ei&&(n=i),n<-i&&(n=-i),n}(x,k,v,w),A=M+Math.floor(N/2),B=M+Math.floor(-N/2),S||(y&&M<6||!y&&M>6)&&(A=6,B=6),[A,B]),u=c(e.stemsUp,r,l);e.addBeam({startX:u[0],endX:u[1],startY:f[0],endY:f[1],dy:t});for(var p=function(e,t,r,a,n){for(var o=[],l=[],h=0;h0&&d.abcelem.beambr&&d.abcelem.beambr<=b+1){l[b].split||(l[b].split=[l[b].x]);var y=c(t,e[h-1],d);l[b].split[l[b].split.length-1]>=y[0]&&(y[0]+=d.w),l[b].split.push(y[0]),l[b].split.push(y[1])}}for(var x=l.length-1;x>=0;x--)if(h===e.length-1||s(e[h+1].abcelem.duration)>-x-4){var k=u,w=p+m*(x+1);l[x].single&&(k=0===h?u+5:h===e.length-1?u-5:e[h-1].duration===e[h+1].duration?h%2==0?u+5:u-5:e[h-1].duration>e[h+1].duration?u+5:u-5,w=i(r.startX,r.startY,r.endX,r.endY,k)+m*(x+1));var T={startX:l[x].x,endX:k,startY:l[x].y,endY:w,dy:n};if(void 0!==l[x].split){var C=l[x].split;T.endX<=C[C.length-1]&&(C[C.length-1]-=d.w),C.push(T.endX),T.split=l[x].split}o.push(T),l=l.slice(0,x)}}}return o}(e.elems,e.stemsUp,e.beams[0],e.isgrace,t),m=0;m0?((n=(r-(a-i*n))/i)*s>50&&(n=50/s),n):null}e.exports=function(e,t,r,i,s,l){var h,d,f=r;for(h=0;hMath.round(f)&&(f=u,s&&(h=-1)))}for(h=0;h=0&&(c.originalTop=c.top,c.originalBottom=c.bottom),i(c,l,"lyricHeightAbove"),i(c,l,"chordHeightAbove",c.specialY.chordLines.above),c.specialY.endingHeightAbove&&(c.specialY.chordHeightAbove?c.top+=2:c.top+=c.specialY.endingHeightAbove+n,l.endingHeightAbove=c.top),c.specialY.dynamicHeightAbove&&c.specialY.volumeHeightAbove?(c.top+=Math.max(c.specialY.dynamicHeightAbove,c.specialY.volumeHeightAbove)+n,l.dynamicHeightAbove=c.top,l.volumeHeightAbove=c.top):(i(c,l,"dynamicHeightAbove"),i(c,l,"volumeHeightAbove")),i(c,l,"partHeightAbove"),i(c,l,"tempoHeightAbove"),c.specialY.lyricHeightBelow&&(c.specialY.lyricHeightBelow+=e.spacing.vocal/a.STEP,l.lyricHeightBelow=c.bottom,c.bottom-=c.specialY.lyricHeightBelow+n),c.specialY.chordHeightBelow){l.chordHeightBelow=c.bottom;var h=c.specialY.chordHeightBelow;c.specialY.chordLines.below&&(h*=c.specialY.chordLines.below),c.bottom-=h+n}c.specialY.volumeHeightBelow&&c.specialY.dynamicHeightBelow?(l.volumeHeightBelow=c.bottom,l.dynamicHeightBelow=c.bottom,c.bottom-=Math.max(c.specialY.volumeHeightBelow,c.specialY.dynamicHeightBelow)+n):c.specialY.volumeHeightBelow?(l.volumeHeightBelow=c.bottom,c.bottom-=c.specialY.volumeHeightBelow+n):c.specialY.dynamicHeightBelow&&(l.dynamicHeightBelow=c.bottom,c.bottom-=c.specialY.dynamicHeightBelow+n),e.showDebug&&e.showDebug.indexOf("box")>=0&&(c.positionY=l);for(var d=0;d0&&(c.top+=u)}c.top+=e.spacing.staffTopMargin/a.STEP,r=2-c.bottom}}},735:function(e,t,r){var a=r(937);function n(e){for(var t=0;t0?0:5e-7)}e.exports=function(e,t,r,s,o){var c,l=0,h=1e3,d=o;s.startx=d;var f,u,p=0;for(r&&console.log("init layout",e),c=0;c1e-7?v.push(s.voices[c]):g.push(s.voices[c]);m=0;var b=0;for(c=0;cd&&(d=a.getNextX(g[c]),m=a.getSpacingUnits(g[c]),b=g[c].spacingduration);l+=m,h=Math.min(h,m),r&&console.log("currentduration: ",p,l,h);var y=void 0;for(c=0;c0){d=w;for(var C=0;Cd&&(d=a.getNextX(s.voices[c]),m=a.getSpacingUnits(s.voices[c]));return function(e){for(var t=0,r=0;r0){var n=a.children.length-1,i=a.children[n];if("bar"===i.abcelem.el_type){var s=i.children[0].x;s>t?t=s:i.children[0].x=t}}}}(s.voices),l+=m,s.setWidth(d),{spacingUnits:l,minSpace:h}}},3294:function(e,t,r){var a=r(3721);function n(e){return e.stemsUp}e.exports=function(e){if(e.anchor1&&e.anchor2){e.hasBeam=!!e.anchor1.parent.beam&&e.anchor1.parent.beam===e.anchor2.parent.beam;var t=e.anchor1.parent.beam;if(!e.hasBeam||t.elems[0]===e.anchor1.parent&&t.elems[t.elems.length-1]===e.anchor2.parent||(e.hasBeam=!1),e.hasBeam){var r=n(t)?e.anchor1.x+e.anchor1.w:e.anchor1.x;e.yTextPos=function(e,t,r){if(0===r.beams.length)return 0;r=r.beams[0];var n=e+(t-e)/2;return a(r.startX,r.startY,r.endX,r.endY,n)}(r,e.anchor2.x,t),e.yTextPos+=n(t)?3:-2,e.xTextPos=(o=r,c=e.anchor2.x,o+(c-o)/2),e.top=e.yTextPos+1,e.bottom=e.yTextPos-2,n(t)&&(e.endingHeightAbove=4)}else{e.startNote=Math.max(e.anchor1.parent.top,9)+4,e.endNote=Math.max(e.anchor2.parent.top,9)+4,"rest"===e.anchor1.parent.type&&"rest"!==e.anchor2.parent.type?e.startNote=e.endNote:"rest"===e.anchor2.parent.type&&"rest"!==e.anchor1.parent.type&&(e.endNote=e.startNote);for(var i=0,s=0;se.startNote||i>e.endNote)&&(e.startNote=i,e.endNote=i),e.flatBeams&&(e.startNote=Math.max(e.startNote,e.endNote),e.endNote=Math.max(e.startNote,e.endNote)),e.yTextPos=e.startNote+(e.endNote-e.startNote)/2,e.xTextPos=e.anchor1.x+(e.anchor2.x+e.anchor2.w-e.anchor1.x)/2,e.top=e.yTextPos+1}}var o,c;delete e.middleElems,delete e.flatBeams}},937:function(e){var t=function(){};t.beginLayout=function(e,t){t.i=0,t.durationindex=0,t.startx=e,t.minx=e,t.nextx=e,t.spacingduration=0},t.layoutEnded=function(e){return e.i>=e.children.length},t.getNextX=function(e){return Math.max(e.minx,e.nextx)},t.getSpacingUnits=function(e){return Math.sqrt(8*e.spacingduration)},t.layoutOneItem=function(e,t,r,a,n){var i=r.children[r.i];if(!i)return 0;var s=e-r.minx,o=r.durationindex+i.duration>0?a:0;if("note"===i.abcelem.el_type&&!i.abcelem.rest&&0!==r.voicenumber&&n){var c=n.children[n.i],l=c&&(i.abcelem.maxpitch<=c.abcelem.maxpitch+1&&i.abcelem.maxpitch>=c.abcelem.minpitch-1||i.abcelem.minpitch<=c.abcelem.maxpitch+1&&i.abcelem.minpitch>=c.abcelem.minpitch-1);if(l&&i.abcelem.minpitch===c.abcelem.minpitch&&i.abcelem.maxpitch===c.abcelem.maxpitch&&c.heads&&c.heads.length>0&&i.heads&&i.heads.length>0&&c.heads[0].c===i.heads[0].c&&(l=!1),l){var h=c.heads&&c.heads.length>0?c.heads[0].realWidth:c.fixed.w;i.adjustedWidth||(i.adjustedWidth=h+i.w),i.w=i.adjustedWidth;for(var d=0;d0&&t.putChordInLane(a),void(e[a]=r.right);e.push(r.right),t.putChordInLane(e.length-1)}}function c(e){for(var t=0,r=0;r=0;r--)(a=e[t].children[r]).chordHeightBelow&&o(i,a)}return(n.length>1||i.length>1)&&function(e,t,r){for(var a=0;a=0};i.prototype.reset=function(){this.paper.clear(),this.y=0,this.abctune=null,this.path=null,this.isPrint=!1,this.lineThickness=0,this.initVerticalSpace()},i.prototype.newTune=function(e){this.abctune=e,this.setVerticalSpace(e.formatting),this.isPrint="print"===e.media,this.setPadding(e)},i.prototype.setLineThickness=function(e){this.lineThickness=e},i.prototype.setPaddingOverride=function(e){this.paddingOverride={top:e.paddingtop,bottom:e.paddingbottom,right:e.paddingright,left:e.paddingleft}},i.prototype.setPadding=function(e){function t(t,r,a,n,i){void 0!==e.formatting[a]?t.padding[r]=e.formatting[a]:void 0!==t.paddingOverride[r]?t.padding[r]=t.paddingOverride[r]:t.isPrint?t.padding[r]=n:t.padding[r]=i}t(this,"top","topmargin",38,15),t(this,"bottom","botmargin",38,15),t(this,"left","leftmargin",68,15),t(this,"right","rightmargin",68,15)},i.prototype.adjustNonScaledItems=function(e){this.padding.top/=e,this.padding.bottom/=e,this.padding.left/=e,this.padding.right/=e,this.abctune.formatting.headerfont.size/=e,this.abctune.formatting.footerfont.size/=e},i.prototype.initVerticalSpace=function(){this.spacing={composer:7.56,graceBefore:8.67,graceInside:10.67,graceAfter:16,info:0,lineSkipFactor:1.1,music:7.56,paragraphSkipFactor:.4,parts:11.33,slurHeight:1,staffSeparation:61.33,staffTopMargin:0,stemHeight:36.67,subtitle:3.78,systemStaffSeparation:48,text:18.9,title:7.56,top:30.24,vocal:0,words:0}},i.prototype.setVerticalSpace=function(e){void 0!==e.staffsep&&(this.spacing.staffSeparation=4*e.staffsep/3),void 0!==e.composerspace&&(this.spacing.composer=4*e.composerspace/3),void 0!==e.partsspace&&(this.spacing.parts=4*e.partsspace/3),void 0!==e.textspace&&(this.spacing.text=4*e.textspace/3),void 0!==e.musicspace&&(this.spacing.music=4*e.musicspace/3),void 0!==e.titlespace&&(this.spacing.title=4*e.titlespace/3),void 0!==e.sysstaffsep&&(this.spacing.systemStaffSeparation=4*e.sysstaffsep/3),void 0!==e.stafftopmargin&&(this.spacing.staffTopMargin=4*e.stafftopmargin/3),void 0!==e.subtitlespace&&(this.spacing.subtitle=4*e.subtitlespace/3),void 0!==e.topspace&&(this.spacing.top=4*e.topspace/3),void 0!==e.vocalspace&&(this.spacing.vocal=4*e.vocalspace/3),void 0!==e.wordsspace&&(this.spacing.words=4*e.wordsspace/3)},i.prototype.calcY=function(e){return this.y-e*a.STEP},i.prototype.yToPitch=function(e){return e/a.STEP},i.prototype.moveY=function(e,t){void 0===t&&(t=1),this.y+=e*t},i.prototype.absolutemoveY=function(e){this.y=e},e.exports=i},4101:function(e){var t="http://www.w3.org/2000/svg";function r(e){this.svg=s(),this.currentGroup=[],e.appendChild(this.svg)}function a(e,t,r){var a=r-e;return"M "+e+" "+t+" l "+a+" 0 l 0 1 l "+-a+" 0 z "}function n(e,t,r){var a=r-t;return"M "+e+" "+t+" l 0 "+a+" l 1 0 l 0 "+-a+" z "}r.prototype.clear=function(){if(this.svg){var e=this.svg.parentNode;this.svg=s(),this.currentGroup=[],e&&(e.innerHTML="",e.appendChild(this.svg))}},r.prototype.setTitle=function(e){var t=document.createElement("title"),r=document.createTextNode(e);t.appendChild(r),this.svg.insertBefore(t,this.svg.firstChild)},r.prototype.setResponsiveWidth=function(e,t){if(this.svg.setAttribute("viewBox","0 0 "+e+" "+t),this.svg.setAttribute("preserveAspectRatio","xMinYMin meet"),this.svg.removeAttribute("height"),this.svg.removeAttribute("width"),this.svg.style.display="inline-block",this.svg.style.position="absolute",this.svg.style.top="0",this.svg.style.left="0",this.svg.parentNode){var r=this.svg.parentNode.getAttribute("class");r?r.indexOf("abcjs-container")<0&&this.svg.parentNode.setAttribute("class",r+" abcjs-container"):this.svg.parentNode.setAttribute("class","abcjs-container"),this.svg.parentNode.style.display="inline-block",this.svg.parentNode.style.position="relative",this.svg.parentNode.style.width="100%";var a=t/e*100;this.svg.parentNode.style["padding-bottom"]=a+"%",this.svg.parentNode.style["vertical-align"]="middle",this.svg.parentNode.style.overflow="hidden"}},r.prototype.setSize=function(e,t){this.svg.setAttribute("width",e),this.svg.setAttribute("height",t)},r.prototype.setAttribute=function(e,t){this.svg.setAttribute(e,t)},r.prototype.setScale=function(e){1!==e?(this.svg.style.transform="scale("+e+","+e+")",this.svg.style["-ms-transform"]="scale("+e+","+e+")",this.svg.style["-webkit-transform"]="scale("+e+","+e+")",this.svg.style["transform-origin"]="0 0",this.svg.style["-ms-transform-origin-x"]="0",this.svg.style["-ms-transform-origin-y"]="0",this.svg.style["-webkit-transform-origin-x"]="0",this.svg.style["-webkit-transform-origin-y"]="0"):(this.svg.style.transform="",this.svg.style["-ms-transform"]="",this.svg.style["-webkit-transform"]="")},r.prototype.insertStyles=function(e){var r=document.createElementNS(t,"style");r.textContent=e,this.svg.insertBefore(r,this.svg.firstChild)},r.prototype.setParentStyles=function(e){for(var t in e)e.hasOwnProperty(t)&&this.svg.parentNode&&(this.svg.parentNode.style[t]=e[t]);this.dummySvg&&(document.querySelector("body").removeChild(this.dummySvg),this.dummySvg=null)},r.prototype.rect=function(e){var t=[],r=e.x,i=e.y,s=e.x+e.width,o=e.y+e.height;return t.push(a(r,i,s)),t.push(a(r,o,s)),t.push(n(s,i,o)),t.push(n(r,o,i)),this.path({path:t.join(" "),stroke:"none","data-name":e["data-name"]})},r.prototype.dottedLine=function(e){var r=document.createElementNS(t,"line");r.setAttribute("x1",e.x1),r.setAttribute("x2",e.x2),r.setAttribute("y1",e.y1),r.setAttribute("y2",e.y2),r.setAttribute("stroke",e.stroke),r.setAttribute("stroke-dasharray","5,5"),this.svg.insertBefore(r,this.svg.firstChild)},r.prototype.rectBeneath=function(e){var r=document.createElementNS(t,"rect");r.setAttribute("x",e.x),r.setAttribute("width",e.width),r.setAttribute("y",e.y),r.setAttribute("height",e.height),e.stroke&&r.setAttribute("stroke",e.stroke),e["stroke-opacity"]&&r.setAttribute("stroke-opacity",e["stroke-opacity"]),e.fill&&r.setAttribute("fill",e.fill),e["fill-opacity"]&&r.setAttribute("fill-opacity",e["fill-opacity"]),this.svg.insertBefore(r,this.svg.firstChild)},r.prototype.text=function(e,r,a,n){var i=document.createElementNS(t,"text");for(var s in i.setAttribute("stroke","none"),r)r.hasOwnProperty(s)&&i.setAttribute(s,r[s]);for(var o="free-text"==r["data-name"],c=(""+e).split("\n"),l=0;l0?this.currentGroup[0].removeChild(r):this.svg.removeChild(r)),a&&(i[a]=n),n},r.prototype.openGroup=function(e){e=e||{};var r=document.createElementNS(t,"g");return e.klass&&r.setAttribute("class",e.klass),e.fill&&r.setAttribute("fill",e.fill),e.stroke&&r.setAttribute("stroke",e.stroke),e["data-name"]&&r.setAttribute("data-name",e["data-name"]),e.prepend?this.prepend(r):this.append(r),this.currentGroup.unshift(r),r},r.prototype.closeGroup=function(){var e=this.currentGroup.shift();return e&&0===e.children.length?(e.parentElement.removeChild(e),null):e},r.prototype.path=function(e){var r=document.createElementNS(t,"path");for(var a in e)e.hasOwnProperty(a)&&("path"===a?r.setAttributeNS(null,"d",e.path):"klass"===a?r.setAttributeNS(null,"class",e[a]):void 0!==e[a]&&r.setAttributeNS(null,a,e[a]));return this.append(r),r},r.prototype.pathToBack=function(e){var r=document.createElementNS(t,"path");for(var a in e)e.hasOwnProperty(a)&&("path"===a?r.setAttributeNS(null,"d",e.path):"klass"===a?r.setAttributeNS(null,"class",e[a]):r.setAttributeNS(null,a,e[a]));return this.prepend(r),r},r.prototype.lineToBack=function(e){for(var r=document.createElementNS(t,"line"),a=Object.keys(e),n=0;n0?this.currentGroup[0].appendChild(e):this.svg.appendChild(e)},r.prototype.prepend=function(e){this.currentGroup.length>0?this.currentGroup[0].appendChild(e):this.svg.insertBefore(e,this.svg.firstChild)},r.prototype.setAttributeOnElement=function(e,t){for(var r in t)t.hasOwnProperty(r)&&e.setAttributeNS(null,r,t[r])},r.prototype.moveElementToChild=function(e,t){e.appendChild(t)},e.exports=r}},t={},r=function r(a){var n=t[a];if(void 0!==n)return n.exports;var i=t[a]={exports:{}};return e[a](i,i.exports,r),i.exports}(7001),r;var e,t,r}));