// source --> http://mytoolbox.sakura.ne.jp/wp/wp-content/plugins/beliefmedia-abcjs/js/abcjs_basic_latest-min.js?ver=4.4.15 /*! abcjs v3.1.2 Copyright © 2009-2016 Paul Rosen and Gregory Dyke (http://abcjs.net) */ /*! midi.js Copyright © Michael Deal (http://mudcu.be) */ function calcHorizontalSpacing(isLastLine,stretchLast,targetWidth,lineWidth,spacing,spacingUnits,minSpace){if(isLastLine&&lineWidth/targetWidth<.66&&!stretchLast)return null;if(Math.abs(targetWidth-lineWidth)<2)return null;var relSpace=spacingUnits*spacing,constSpace=lineWidth-relSpace;return spacingUnits>0?(spacing=(targetWidth-constSpace)/spacingUnits,spacing*minSpace>50&&(spacing=50/minSpace),spacing):null}function centerWholeRests(voices){for(var i=0;i>8-idx%1*8)){if(charCode=input.charCodeAt(idx+=.75),charCode>255)throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");block=block<<8|charCode}return output}),object.atob||(object.atob=function(input){if(input=input.replace(/=+$/,""),input.length%4==1)throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.");for(var bs,buffer,bc=0,idx=0,output="";buffer=input.charAt(idx++);~buffer&&(bs=bc%4?64*bs+buffer:buffer,bc++%4)?output+=String.fromCharCode(255&bs>>(-2*bc&6)):0)buffer=chars.indexOf(buffer);return output})}(),window.AudioContext=window.AudioContext||window.webkitAudioContext||null,window.OfflineAudioContext=window.OfflineAudioContext||window.webkitOfflineAudioContext||null,function(Context){var proto,instance,sourceProto,isFunction=function(f){return"[object Function]"===Object.prototype.toString.call(f)||"[object AudioContextConstructor]"===Object.prototype.toString.call(f)},contextMethods=[["createGainNode","createGain"],["createDelayNode","createDelay"],["createJavaScriptNode","createScriptProcessor"]];isFunction(Context)&&(instance=new Context,instance.destination&&instance.sampleRate&&(proto=Context.prototype,sourceProto=Object.getPrototypeOf(instance.createBufferSource()),isFunction(sourceProto.start)||isFunction(sourceProto.noteOn)&&(sourceProto.start=function(when,offset,duration){switch(arguments.length){case 0:throw new Error("Not enough arguments.");case 1:this.noteOn(when);break;case 2:if(!this.buffer)throw new Error("Missing AudioBuffer");this.noteGrainOn(when,offset,this.buffer.duration-offset);break;case 3:this.noteGrainOn(when,offset,duration)}}),isFunction(sourceProto.noteOn)||(sourceProto.noteOn=sourceProto.start),isFunction(sourceProto.noteGrainOn)||(sourceProto.noteGrainOn=sourceProto.start),isFunction(sourceProto.stop)||(sourceProto.stop=sourceProto.noteOff),isFunction(sourceProto.noteOff)||(sourceProto.noteOff=sourceProto.stop),contextMethods.forEach(function(names){for(var name1,name2;names.length;)name1=names.pop(),isFunction(this[name1])?this[names.pop()]=this[name1]:(name2=names.pop(),this[name1]=this[name2])},proto)))}(window.AudioContext),function(global){"use strict";function Promise(){}function _JazzInstance(){this.inputInUse=!1,this.outputInUse=!1;var o1=document.createElement("object");o1.id="_Jazz"+Math.random()+"ie",o1.classid="CLSID:1ACE1618-1C7D-4561-AEE1-34842AA85E90",this.activeX=o1;var o2=document.createElement("object");o2.id="_Jazz"+Math.random(),o2.type="audio/x-jazz",o1.appendChild(o2),this.objRef=o2;var e=document.createElement("p");e.appendChild(document.createTextNode("This page requires the "));var a=document.createElement("a");a.appendChild(document.createTextNode("Jazz plugin")),a.href="http://jazz-soft.net/",e.appendChild(a),e.appendChild(document.createTextNode(".")),o2.appendChild(e);var insertionPoint=document.getElementById("MIDIPlugin");if(!insertionPoint){var insertionPoint=document.createElement("div");insertionPoint.id="MIDIPlugin",insertionPoint.style.position="absolute",insertionPoint.style.visibility="hidden",insertionPoint.style.left="-9999px",insertionPoint.style.top="-9999px",document.body.appendChild(insertionPoint)}insertionPoint.appendChild(o1),this.objRef.isJazz?this._Jazz=this.objRef:this.activeX.isJazz?this._Jazz=this.activeX:this._Jazz=null,this._Jazz&&(this._Jazz._jazzTimeZero=this._Jazz.Time(),this._Jazz._perfTimeZero=window.performance.now())}function _onNotReady(){this._promise&&this._promise.fail({code:1})}function _sendLater(){this.jazz.MidiOutLong(this.data)}var _requestMIDIAccess,MIDIAccess,_onReady,MIDIInput,MIDIOutput,_midiProc;Promise.prototype.then=function(accept,reject){this.accept=accept,this.reject=reject},Promise.prototype.succeed=function(access){this.accept&&this.accept(access)},Promise.prototype.fail=function(error){this.reject&&this.reject(error)},_requestMIDIAccess=function(){var access=new MIDIAccess;return access._promise},MIDIAccess=function(){this._jazzInstances=new Array,this._jazzInstances.push(new _JazzInstance),this._promise=new Promise,this._jazzInstances[0]._Jazz?(this._Jazz=this._jazzInstances[0]._Jazz,window.setTimeout(_onReady.bind(this),3)):window.setTimeout(_onNotReady.bind(this),3)},_onReady=function(){this._promise&&this._promise.succeed(this)},MIDIAccess.prototype.inputs=function(){if(!this._Jazz)return null;for(var list=this._Jazz.MidiInList(),inputs=new Array(list.length),i=0;i1){var sendObj=new Object;sendObj.jazz=this._jazzInstance,sendObj.data=data,window.setTimeout(_sendLater.bind(sendObj),delayBeforeSend)}else this._jazzInstance.MidiOutLong(data);return!0},window.navigator.requestMIDIAccess||(window.navigator.requestMIDIAccess=_requestMIDIAccess)}(window),function(exports){function findAlt(){for(var prefix=["moz","webkit","o","ms"],i=prefix.length,props={value:function(start){return function(){return Date.now()-start}}(Date.now())};i>=0;i--)if(prefix[i]+"Now"in exports.performance)return props.value=function(method){return function(){exports.performance[method]()}}(prefix[i]+"Now"),props;return"timing"in exports.performance&&"connectStart"in exports.performance.timing&&(props.value=function(start){return function(){Date.now()-start}}(exports.performance.timing.connectStart)),props}var props,perf={};"performance"in exports&&"now"in exports.performance||("performance"in exports||Object.defineProperty(exports,"performance",{get:function(){return perf}}),props=findAlt(),Object.defineProperty(exports.performance,"now",props))}(window),"undefined"==typeof dom)var dom={};!function(){"use strict";function globalExists(path,root){try{path=path.split('"').join("").split("'").join("").split("]").join("").split("[").join(".");for(var parts=path.split("."),length=parts.length,object=root||window,n=0;nyD)return 1}for(var cLoc=0,numS=Math.max(xN.length,yN.length);cLocoFyNcL)return 1}return 0},util.getItems=function(keys,onsuccess){var pending=keys.length,res={};util.each(keys,function(key){util.getItem(key,function(value){res[key]=value,--pending||onsuccess(res)})})},util.getItem=function(key,onsuccess){onsuccess=onsuccess||function(value){console.log(value)};var parse=function(value){if(value)try{value=JSON.parse(value)}catch(err){}onsuccess(value)};if(util.exists("chrome.storage.local"))chrome.storage.local.get(key,function(data){parse(data[key])});else{var prefix=root.feature&&root.feature.prefix||"",prefixed=prefix+"/"+key,data=localStorage.getItem(prefixed)||"";parse(data)}},util.setItem=function(key,value){if(util.exists("chrome.storage.local")){var obj={};obj[key]=value,chrome.storage.local.set(obj)}else{var prefix=root.feature&&root.feature.prefix||"",prefixed=prefix+"/"+key;localStorage.setItem(prefixed,value)}},util.Canvas=function(width,height,type){if("undefined"==typeof document){if(void 0===Canvas)return{ctx:{}};var canvas=new Canvas}else{var canvas=document.createElement("canvas");"function"==typeof FlashCanvas&&(canvas.onload=root.client.fn.detect)}return canvas.ctx=canvas.getContext(type||"2d"),isFinite(width)&&(canvas.width=width||1),isFinite(height)&&(canvas.height=height||1),canvas},util.Canvas.resize=function(canvas,width,height){width&&height?(canvas.width=width,canvas.height=height):canvas.width=canvas.width},util.Canvas.clear=function(canvas){canvas.ctx.clearRect(0,0,canvas.width,canvas.height)},util.Context3d=function(width,height){return util.Canvas(width,height,"webgl").ctx},util.Context2d=function(width,height){return util.Canvas(width,height,"2d").ctx},util.json={},util.json.pretty=function(data){return JSON.stringify(data,null,"\t")},util.json.stringify=function(data){return JSON.stringify(data,function(key,value){if("object"==typeof value){if(null===value)return;if(value.nodeName)return;if(value.tagName)return}return value})},util.timestamp=function(){if("object"==typeof window){var performance=window.performance;if(performance&&performance.now)return performance.now.bind(performance)}return Date.now}(),util.perf=function(fn,amount,title){if(!amount||!fn){var start=util.timestamp();return function(title,reset){var now=util.timestamp(),diff=Math.round(now-start);return title&&console.log(diff+"ms",title),reset&&(start=now),diff}}for(var perf=util.perf(),n=0;n=0)return!obj.length;for(var key in obj)return!1;return!0},util.isNotEmpty=function(obj){return!util.isEmpty(obj)},util.clamp=function(min,max,value){return valuemax?max:value},util.clampFinite=function(value){var INFINITY=util.INFINITY;return value>+INFINITY&&(value=+INFINITY),value<-INFINITY&&(value=-INFINITY),value},util.arrayEmpty=function(arr){arr.splice(0,arr.length)},util.arrayIntersects=function(haystack,arr){return arr.some(function(value){return haystack.indexOf(value)!==-1})},util.inArray=function(array,value){return array.indexOf(value)!==-1},util.isArray=function(obj){return Array.isArray(obj)||obj instanceof NodeList},util.each=function(obj,callback){if(util.isArray(obj))for(var idx=0;idx>0,minutes=(timestamp-3600*hours)/60>>0,seconds=timestamp-3600*hours-60*minutes>>0;return toString?(hours<10&&(hours="0"+hours),minutes<10&&(minutes="0"+minutes),seconds<10&&(seconds="0"+seconds),hours+":"+minutes+":"+seconds):{hours:hours,minutes:minutes,seconds:seconds}},util.require=function(opts){function addCSS(){var link=document.createElement("link");link.href=url,link.setAttribute("type","text/css"),link.setAttribute("rel","stylesheet"),document.head.appendChild(link)}"string"==typeof opts&&(opts={url:opts});var url=opts.url,type=opts.type||(url.indexOf(".css")!==-1?"css":"js"),async=opts.async||!1,onsuccess=opts.onsuccess;if("css"===type)async?setTimeout(addCSS,0):addCSS();else{var script=document.createElement("script");if(script.src=url,script.async=async,onsuccess){var loaded=!1;script.onload=script.onreadystatechange=function(){if(loaded===!1){var readyState=script.readyState;readyState&&!/loaded|complete/.test(readyState)||(loaded=!0,onsuccess(),script.onload=script.onreadystatechange=null)}}}document.head.appendChild(script)}},util.isEditingText=function(){var node=document.activeElement;if(!node)return!1;var nodeName=node.nodeName;return("INPUT"===nodeName||"TEXTAREA"===nodeName||"true"===node.contentEditable)&&!node.classList.contains("sk-canvas-dummy")},util.pending=function(length,onsuccess){var pending=length;return{add:function(amount){pending+=amount||1},next:function(){--pending||onsuccess()}}}},"undefined"!=typeof module&&module.exports){try{var Canvas=require("canvas")}catch(e){}module.exports=root.module.DOMMisc}else root.module.DOMMisc(galactic)}(galactic),function(){"use strict";function AudioSupports(){return detectAudio(),detectMIDI(),detectWebAudio(),detectAudioFormats().then(function(){return supports})}function detectAudio(){return supports.audio=!!self.Audio&&{}}function detectWebAudio(){return supports.audioapi=!!AudioContext&&{}}function detectMIDI(){if(navigator.requestMIDIAccess){var toString=Function.prototype.toString,isNative=toString.call(navigator.requestMIDIAccess).indexOf("[native code]")!==-1;if(isNative)return supports.midiapi={};for(var n=0;navigator.plugins.length>n;n++){var plugin=navigator.plugins[n];if(plugin.name.indexOf("Jazz-Plugin")>=0)return supports.midiapi={}}}return supports.midiapi=!1}function detectAudioFormats(){return new Promise(function(resolve,reject){return supports.audio?(setTimeout(resolve,5e3),void Promise.all([canPlayThrough(tests.mpeg_mp3),canPlayThrough(tests.ogg_opus),canPlayThrough(tests.ogg_vorbis)]).then(resolve)):resolve()})}function canPlayThrough(test){return new Promise(function(resolve,reject){function hasSupport(truthy){function record(_supports,format,codec,truthy){!supports[format]&&(supports[format]=truthy),!supports[codec]&&(supports[codec]=truthy),!_supports[format]&&(_supports[format]=truthy),_supports[codec]=truthy}return record(supports.audio,format,codec,truthy),supports.audioapi?void detectDecodeAudio(src).then(function(){record(supports.audioapi,format,codec,!0),resolve()},function(err){record(supports.audioapi,format,codec,!1),resolve()}):void resolve()}var format=test.format,codec=test.codec,base64=test.base64,mime="audio/"+format+'; codecs="'+codec+'"',src="data:"+mime+";base64,"+base64,audio=new Audio;return audio.canPlayType(mime).replace(/no/i,"")?(audio.id="audio",audio.controls=!1,audio.setAttribute("autobuffer",!0),audio.setAttribute("preload","auto"),audio.addEventListener("error",function onError(err){createObjectURL&&!audio.testedBlobURL?(audio.testedBlobURL=!0,audio.src=createObjectURL(base64ToBlob(src))):(audio.removeEventListener("error",onError),hasSupport(!1))}),audio.addEventListener("canplaythrough",function onCanPlayThrough(){audio.removeEventListener("canplaythrough",onCanPlayThrough),hasSupport(!0)}),audio.src=src,void audio.load()):void hasSupport(!1)})}function detectDecodeAudio(src){return new Promise(function(resolve,reject){audioContext=audioContext||new AudioContext,audioContext.decodeAudioData(base64ToBuffer(src),resolve,reject).catch(function(){}),setTimeout(reject,250)})}function base64Mime(uri){return uri=uri.split(","),uri[0].split(":")[1].split(";")[0]}function base64ToBuffer(uri){uri=uri.split(",");for(var binary=atob(uri[1]),buffer=new ArrayBuffer(binary.length),uint=new Uint8Array(buffer),n=0;n=0){var program=MIDI.getProgram(programId);program&&(programs[n]=program.nameId)}}return 0===programs.length&&(programs=["acoustic_grand_piano"]),programs}return args||(args={}),"object"==typeof args||(args={instrument:args}),args.instruments=instrumentList(),args.tech=args.tech||MIDI.adaptor.id,MIDI.adaptors._load(args)}}(MIDI),"undefined"==typeof MIDI&&(MIDI={}),function(MIDI){"use strict";function requestQueue(args){function sendRequest(programId,audioFormat,onprogress){return new Promise(function(resolve,reject){var soundfontPath=MIDI.PATH+programId+"-"+audioFormat+".js";MIDI.USE_XHR?galactic.request({url:soundfontPath,format:"text",onerror:reject,onprogress:onprogress,onsuccess:function(event,responseText){var script=document.createElement("script");script.language="javascript",script.type="text/javascript",script.text=responseText,document.body.appendChild(script),resolve()}}):dom.loadScript.add({url:soundfontPath,verify:'MIDI.Soundfont["'+programId+'"]',onerror:reject,onsuccess:resolve})})}return new Promise(function(resolve,reject){function emitProgress(progress,programId){emitProgress.progress!==progress&&(emitProgress.progress=progress,onprogress&&onprogress("load",progress,programId))}function waitForEnd(){--pending||(emitProgress(1),_adaptors[tech].connect(args).then(function(){programs.forEach(function(programId){for(var cb,request=_requests[programId];cb=request.queue.pop();)cb()})}).catch(reject))}for(var audioFormat=_adaptor.format.split("_").shift(),programs=args.instruments,onprogress=args.onprogress,tech=args.tech,length=programs.length,pending=length,i=0;i>0],1e3*(delay||0)),_active[channelId+"x"+noteId]={_channel:MIDI.channels[channelId],_volume:velocity},{cancel:function(){}}}function noteOff(channelId,noteId,delay){return _context.send([128+channelId,noteId,0],1e3*(delay||0)),delete _active[channelId+"x"+noteId],{cancel:function(){}}}function noteGroupOn(channelId,group,velocity,delay){for(var i=0;i>0,name=number2key[n%12]+octave;toNote[name]=n,toName[n]=name}MIDI.getNoteName=function(value){return value in toNote?value:value in toName?toName[value]:void 0},MIDI.getNoteNumber=function(value){return value in toName?value:value in toNote?toNote[value]:void 0}}()}(MIDI),"undefined"==typeof MIDI&&(MIDI={}),MIDI.player=new function(){"use strict";function requestEvents(startAt,seek){function handleMetaEvent(){switch(subtype){case"setTempo":}}function handleChannelEvent(){var channelId=event.channel,channel=MIDI.channels[channelId],delay=Math.max(0,(startAt+future)/1e3);switch(subtype){case"controller":MIDI.setController(channelId,event.controllerType,event.value,delay);break;case"programChange":var program=event.programNumber;programIsUsed(program)&&MIDI.programChange(channelId,program,delay);break;case"pitchBend":var pitch=event.value;MIDI.setPitchBend(channelId,pitch,delay);break;case"noteOn":var noteNumber=transpose(event.noteNumber);_midiQueue.push({promise:channel.noteOn(noteNumber,event.velocity/127,delay),timeout:wait(event,noteNumber,_midiEventTime,delay)}),requests++;break;case"noteOff":var noteNumber=transpose(event.noteNumber);_midiQueue.push({promise:channel.noteOff(noteNumber,delay),timeout:wait(event,noteNumber,_midiEventTime,delay)}),requests++}}function wait(event,noteNumber,currentTime,delay){return setTimeout(function(){var packet=galactic.util.copy(event);packet.noteNumber=noteNumber,player.emit("event",packet),_midiQueue.shift();var packetId=packet.channel+"x"+packet.noteNumber;switch(packet.subtype){case"noteOn":_midiState[packetId]=packet;break;case"noteOff":delete _midiState[packetId]}_midiQueue.length<=_scheduleMax&&requestEvents(_midiEventTime)},1e3*delay)}function programIsUsed(programNumber){var program=MIDI.getProgram(programNumber);return program&&player.instruments[program.nameId]}function seekPacket(seekTime){for(var time=0,length=_midiEvents.length,idx=0;idxplayer.duration)){if(seek){player.playing?cancelEvents():player.playing=!0;var packet=seekPacket(startAt),packetIndex=packet.idx,packetTime=_midiEventTime=packet.time}else var packetIndex=_midiEventIndex,packetTime=_midiEventTime;for(var future=startAt-player.currentTime,requests=0,length=_midiEvents.length;packetIndexmax?max:value}function readMidiFile(){function getLength(){for(var length=_midiEvents.length,totalTime=0,n=0;n=1e3&&delete cache[count.shift()],count.push(args),cache[args]=f[apply](scope,arg),postprocessor?postprocessor(cache[args]):cache[args])}return newf}function clrToString(){return this.hex}function catmullRom2bezier(crp,z){for(var d=[],i=0,iLen=crp.length;iLen-2*!z>i;i+=2){var p=[{x:+crp[i-2],y:+crp[i-1]},{x:+crp[i],y:+crp[i+1]},{x:+crp[i+2],y:+crp[i+3]},{x:+crp[i+4],y:+crp[i+5]}];z?i?iLen-4==i?p[3]={x:+crp[0],y:+crp[1]}:iLen-2==i&&(p[2]={x:+crp[0],y:+crp[1]},p[3]={x:+crp[2],y:+crp[3]}):p[0]={x:+crp[iLen-2],y:+crp[iLen-1]}:iLen-4==i?p[3]=p[2]:i||(p[0]={x:+crp[i],y:+crp[i+1]}),d.push(["C",(-p[0].x+6*p[1].x+p[2].x)/6,(-p[0].y+6*p[1].y+p[2].y)/6,(p[1].x+6*p[2].x-p[3].x)/6,(p[1].y+6*p[2].y-p[3].y)/6,p[2].x,p[2].y])}return d}function base3(t,p1,p2,p3,p4){var t1=-3*p1+9*p2-9*p3+3*p4,t2=t*t1+6*p1-12*p2+6*p3;return t*t2-3*p1+3*p2}function bezlen(x1,y1,x2,y2,x3,y3,x4,y4,z){null==z&&(z=1),z=z>1?1:z<0?0:z;for(var z2=z/2,n=12,Tvalues=[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],Cvalues=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472],sum=0,i=0;ie;)step/=2,t2+=(lmmax(x3,x4)||mmax(y1,y2)mmax(y3,y4))){var nx=(x1*y2-y1*x2)*(x3-x4)-(x1-x2)*(x3*y4-y3*x4),ny=(x1*y2-y1*x2)*(y3-y4)-(y1-y2)*(x3*y4-y3*x4),denominator=(x1-x2)*(y3-y4)-(y1-y2)*(x3-x4);if(denominator){var px=nx/denominator,py=ny/denominator,px2=+px.toFixed(2),py2=+py.toFixed(2);if(!(px2<+mmin(x1,x2).toFixed(2)||px2>+mmax(x1,x2).toFixed(2)||px2<+mmin(x3,x4).toFixed(2)||px2>+mmax(x3,x4).toFixed(2)||py2<+mmin(y1,y2).toFixed(2)||py2>+mmax(y1,y2).toFixed(2)||py2<+mmin(y3,y4).toFixed(2)||py2>+mmax(y3,y4).toFixed(2)))return{x:px,y:py}}}}function interHelper(bez1,bez2,justCount){var bbox1=R.bezierBBox(bez1),bbox2=R.bezierBBox(bez2);if(!R.isBBoxIntersect(bbox1,bbox2))return justCount?0:[];for(var l1=bezlen.apply(0,bez1),l2=bezlen.apply(0,bez2),n1=mmax(~~(l1/5),1),n2=mmax(~~(l2/5),1),dots1=[],dots2=[],xy={},res=justCount?0:[],i=0;i=0&&t1<=1.001&&t2>=0&&t2<=1.001&&(justCount?res++:res.push({x:is.x,y:is.y,t1:mmin(t1,1),t2:mmin(t2,1)}))}}return res}function interPathHelper(path1,path2,justCount){path1=R._path2curve(path1),path2=R._path2curve(path2);for(var x1,y1,x2,y2,x1m,y1m,x2m,y2m,bez1,bez2,res=justCount?0:[],i=0,ii=path1.length;it1)return t1;for(;t0x2?t0=t2:t1=t2,t2=(t1-t0)/2+t0}return t2}var cx=3*p1x,bx=3*(p2x-p1x)-cx,ax=1-cx-bx,cy=3*p1y,by=3*(p2y-p1y)-cy,ay=1-cy-by;return solve(t,1/(200*duration))}function Animation(anim,ms){var percents=[],newAnim={};if(this.ms=ms,this.times=1,anim){for(var attr in anim)anim[has](attr)&&(newAnim[toFloat(attr)]=anim[attr],percents.push(toFloat(attr)));percents.sort(sortByNumber)}this.anim=newAnim,this.top=percents[percents.length-1],this.percents=percents}function runAnimation(anim,element,percent,status,totalOrigin,times){percent=toFloat(percent);var params,isInAnim,isInAnimSet,next,prev,timestamp,ms=anim.ms,from={},to={},diff={};if(status)for(i=0,ii=animationElements.length;istatus*anim.top){percent=anim.percents[i],prev=anim.percents[i-1]||0,ms=ms/anim.top*(percent-prev),next=anim.percents[i+1],params=anim.anim[percent];break}status&&element.attr(anim.anim[anim.percents[i]])}if(params){if(isInAnim)isInAnim.initstatus=status,isInAnim.start=new Date-isInAnim.ms*status;else{for(var attr in params)if(params[has](attr)&&(availableAnimAttrs[has](attr)||element.paper.customAttributes[has](attr)))switch(from[attr]=element.attr(attr),null==from[attr]&&(from[attr]=availableAttrs[attr]),to[attr]=params[attr],availableAnimAttrs[attr]){case nu:diff[attr]=(to[attr]-from[attr])/ms;break;case"colour":from[attr]=R.getRGB(from[attr]);var toColour=R.getRGB(to[attr]);diff[attr]={r:(toColour.r-from[attr].r)/ms,g:(toColour.g-from[attr].g)/ms,b:(toColour.b-from[attr].b)/ms};break;case"path":var pathes=path2curve(from[attr],to[attr]),toPath=pathes[1];for(from[attr]=pathes[0],diff[attr]=[],i=0,ii=from[attr].length;i',b=d.firstChild,b.style.behavior="url(#default#VML)",!b||"object"!=typeof b.adj)return R.type=E;d=null}R.svg=!(R.vml="VML"==R.type),R._Paper=Paper,R.fn=paperproto=Paper.prototype=R.prototype,R._id=0,R._oid=0,R.is=function(o,type){return type=lowerCase.call(type),"finite"==type?!isnan[has](+o):"array"==type?o instanceof Array:"null"==type&&null===o||type==typeof o&&null!==o||"object"==type&&o===Object(o)||"array"==type&&Array.isArray&&Array.isArray(o)||objectToString.call(o).slice(8,-1).toLowerCase()==type},R.angle=function(x1,y1,x2,y2,x3,y3){if(null==x3){var x=x1-x2,y=y1-y2;return x||y?(180+180*math.atan2(-y,-x)/PI+360)%360:0}return R.angle(x1,y1,x3,y3)-R.angle(x2,y2,x3,y3)},R.rad=function(deg){return deg%360*PI/180},R.deg=function(rad){return 180*rad/PI%360},R.snapTo=function(values,value,tolerance){if(tolerance=R.is(tolerance,"finite")?tolerance:10,R.is(values,array)){for(var i=values.length;i--;)if(abs(values[i]-value)<=tolerance)return values[i]}else{values=+values;var rem=value%values;if(remvalues-tolerance)return value-rem+values}return value};R.createUUID=function(uuidRegEx,uuidReplacer){return function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(uuidRegEx,uuidReplacer).toUpperCase()}}(/[xy]/g,function(c){var r=16*math.random()|0,v="x"==c?r:3&r|8;return v.toString(16)});R.setWindow=function(newwin){eve("raphael.setWindow",R,g.win,newwin),g.win=newwin,g.doc=g.win.document,R._engine.initWin&&R._engine.initWin(g.win)};var toHex=function(color){if(R.vml){var bod,trim=/^\s+|\s+$/g;try{var docum=new ActiveXObject("htmlfile");docum.write(""),docum.close(),bod=docum.body}catch(e){bod=createPopup().document.body}var range=bod.createTextRange();toHex=cacher(function(color){try{bod.style.color=Str(color).replace(trim,E);var value=range.queryCommandValue("ForeColor");return value=(255&value)<<16|65280&value|(16711680&value)>>>16,"#"+("000000"+value.toString(16)).slice(-6)}catch(e){return"none"}})}else{var i=g.doc.createElement("i");i.title="Raphaël Colour Picker",i.style.display="none",g.doc.body.appendChild(i),toHex=cacher(function(color){return i.style.color=color,g.doc.defaultView.getComputedStyle(i,E).getPropertyValue("color")})}return toHex(color)},hsbtoString=function(){return"hsb("+[this.h,this.s,this.b]+")"},hsltoString=function(){return"hsl("+[this.h,this.s,this.l]+")"},rgbtoString=function(){return this.hex},prepareRGB=function(r,g,b){if(null==g&&R.is(r,"object")&&"r"in r&&"g"in r&&"b"in r&&(b=r.b,g=r.g,r=r.r),null==g&&R.is(r,string)){var clr=R.getRGB(r);r=clr.r,g=clr.g,b=clr.b}return(r>1||g>1||b>1)&&(r/=255,g/=255,b/=255),[r,g,b]},packageRGB=function(r,g,b,o){r*=255,g*=255,b*=255;var rgb={r:r,g:g,b:b,hex:R.rgb(r,g,b),toString:rgbtoString};return R.is(o,"finite")&&(rgb.opacity=o),rgb};R.color=function(clr){var rgb;return R.is(clr,"object")&&"h"in clr&&"s"in clr&&"b"in clr?(rgb=R.hsb2rgb(clr),clr.r=rgb.r,clr.g=rgb.g,clr.b=rgb.b,clr.hex=rgb.hex):R.is(clr,"object")&&"h"in clr&&"s"in clr&&"l"in clr?(rgb=R.hsl2rgb(clr),clr.r=rgb.r,clr.g=rgb.g,clr.b=rgb.b,clr.hex=rgb.hex):(R.is(clr,"string")&&(clr=R.getRGB(clr)),R.is(clr,"object")&&"r"in clr&&"g"in clr&&"b"in clr?(rgb=R.rgb2hsl(clr),clr.h=rgb.h,clr.s=rgb.s,clr.l=rgb.l,rgb=R.rgb2hsb(clr),clr.v=rgb.b):(clr={hex:"none"},clr.r=clr.g=clr.b=clr.h=clr.s=clr.v=clr.l=-1)),clr.toString=rgbtoString,clr},R.hsb2rgb=function(h,s,v,o){this.is(h,"object")&&"h"in h&&"s"in h&&"b"in h&&(v=h.b,s=h.s,h=h.h,o=h.o),h*=360;var R,G,B,X,C;return h=h%360/60,C=v*s,X=C*(1-abs(h%2-1)),R=G=B=v-C,h=~~h,R+=[C,X,0,0,X,C][h],G+=[X,C,C,X,0,0][h],B+=[0,0,X,C,C,X][h],packageRGB(R,G,B,o)},R.hsl2rgb=function(h,s,l,o){this.is(h,"object")&&"h"in h&&"s"in h&&"l"in h&&(l=h.l,s=h.s,h=h.h),(h>1||s>1||l>1)&&(h/=360,s/=100,l/=100),h*=360;var R,G,B,X,C;return h=h%360/60,C=2*s*(l<.5?l:1-l),X=C*(1-abs(h%2-1)),R=G=B=l-C/2,h=~~h,R+=[C,X,0,0,X,C][h],G+=[X,C,C,X,0,0][h],B+=[0,0,X,C,C,X][h],packageRGB(R,G,B,o)},R.rgb2hsb=function(r,g,b){b=prepareRGB(r,g,b),r=b[0],g=b[1],b=b[2];var H,S,V,C;return V=mmax(r,g,b),C=V-mmin(r,g,b),H=0==C?null:V==r?(g-b)/C:V==g?(b-r)/C+2:(r-g)/C+4,H=(H+360)%6*60/360,S=0==C?0:C/V,{h:H,s:S,b:V,toString:hsbtoString}},R.rgb2hsl=function(r,g,b){b=prepareRGB(r,g,b),r=b[0],g=b[1],b=b[2];var H,S,L,M,m,C;return M=mmax(r,g,b),m=mmin(r,g,b),C=M-m,H=0==C?null:M==r?(g-b)/C:M==g?(b-r)/C+2:(r-g)/C+4,H=(H+360)%6*60/360,L=(M+m)/2,S=0==C?0:L<.5?C/(2*L):C/(2-2*L),{h:H,s:S,l:L,toString:hsltoString}},R._path2string=function(){return this.join(",").replace(p2s,"$1")};R._preload=function(src,f){var img=g.doc.createElement("img");img.style.cssText="position:absolute;left:-9999em;top:-9999em",img.onload=function(){f.call(this),this.onload=null,g.doc.body.removeChild(this)},img.onerror=function(){g.doc.body.removeChild(this)},g.doc.body.appendChild(img),img.src=src};R.getRGB=cacher(function(colour){if(!colour||(colour=Str(colour)).indexOf("-")+1)return{r:-1,g:-1,b:-1,hex:"none",error:1,toString:clrToString};if("none"==colour)return{r:-1,g:-1,b:-1,hex:"none",toString:clrToString};!(hsrg[has](colour.toLowerCase().substring(0,2))||"#"==colour.charAt())&&(colour=toHex(colour));var red,green,blue,opacity,t,values,rgb=colour.match(colourRegExp);return rgb?(rgb[2]&&(blue=toInt(rgb[2].substring(5),16),green=toInt(rgb[2].substring(3,5),16),red=toInt(rgb[2].substring(1,3),16)),rgb[3]&&(blue=toInt((t=rgb[3].charAt(3))+t,16),green=toInt((t=rgb[3].charAt(2))+t,16),red=toInt((t=rgb[3].charAt(1))+t,16)),rgb[4]&&(values=rgb[4][split](commaSpaces),red=toFloat(values[0]),"%"==values[0].slice(-1)&&(red*=2.55),green=toFloat(values[1]),"%"==values[1].slice(-1)&&(green*=2.55),blue=toFloat(values[2]),"%"==values[2].slice(-1)&&(blue*=2.55),"rgba"==rgb[1].toLowerCase().slice(0,4)&&(opacity=toFloat(values[3])),values[3]&&"%"==values[3].slice(-1)&&(opacity/=100)),rgb[5]?(values=rgb[5][split](commaSpaces),red=toFloat(values[0]),"%"==values[0].slice(-1)&&(red*=2.55),green=toFloat(values[1]),"%"==values[1].slice(-1)&&(green*=2.55),blue=toFloat(values[2]),"%"==values[2].slice(-1)&&(blue*=2.55),("deg"==values[0].slice(-3)||"°"==values[0].slice(-1))&&(red/=360),"hsba"==rgb[1].toLowerCase().slice(0,4)&&(opacity=toFloat(values[3])),values[3]&&"%"==values[3].slice(-1)&&(opacity/=100),R.hsb2rgb(red,green,blue,opacity)):rgb[6]?(values=rgb[6][split](commaSpaces),red=toFloat(values[0]),"%"==values[0].slice(-1)&&(red*=2.55),green=toFloat(values[1]),"%"==values[1].slice(-1)&&(green*=2.55),blue=toFloat(values[2]),"%"==values[2].slice(-1)&&(blue*=2.55),("deg"==values[0].slice(-3)||"°"==values[0].slice(-1))&&(red/=360),"hsla"==rgb[1].toLowerCase().slice(0,4)&&(opacity=toFloat(values[3])),values[3]&&"%"==values[3].slice(-1)&&(opacity/=100),R.hsl2rgb(red,green,blue,opacity)):(rgb={r:red,g:green,b:blue,toString:clrToString},rgb.hex="#"+(16777216|blue|green<<8|red<<16).toString(16).slice(1),R.is(opacity,"finite")&&(rgb.opacity=opacity),rgb)):{r:-1,g:-1,b:-1,hex:"none",error:1,toString:clrToString}},R),R.hsb=cacher(function(h,s,b){return R.hsb2rgb(h,s,b).hex}),R.hsl=cacher(function(h,s,l){return R.hsl2rgb(h,s,l).hex}),R.rgb=cacher(function(r,g,b){return"#"+(16777216|b|g<<8|r<<16).toString(16).slice(1)}),R.getColor=function(value){var start=this.getColor.start=this.getColor.start||{h:0,s:1,b:value||.75},rgb=this.hsb2rgb(start.h,start.s,start.b);return start.h+=.075,start.h>1&&(start.h=0,start.s-=.2,start.s<=0&&(this.getColor.start={h:0,s:1,b:start.b})),rgb.hex},R.getColor.reset=function(){delete this.start},R.parsePathString=function(pathString){if(!pathString)return null;var pth=paths(pathString);if(pth.arr)return pathClone(pth.arr);var paramCounts={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0},data=[];return R.is(pathString,array)&&R.is(pathString[0],array)&&(data=pathClone(pathString)),data.length||Str(pathString).replace(pathCommand,function(a,b,c){var params=[],name=b.toLowerCase();if(c.replace(pathValues,function(a,b){b&¶ms.push(+b)}),"m"==name&¶ms.length>2&&(data.push([b][concat](params.splice(0,2))),name="l",b="m"==b?"l":"L"),"r"==name)data.push([b][concat](params));else for(;params.length>=paramCounts[name]&&(data.push([b][concat](params.splice(0,paramCounts[name]))),paramCounts[name]););}),data.toString=R._path2string,pth.arr=pathClone(data),data},R.parseTransformString=cacher(function(TString){if(!TString)return null;var data=[];return R.is(TString,array)&&R.is(TString[0],array)&&(data=pathClone(TString)),data.length||Str(TString).replace(tCommand,function(a,b,c){var params=[];lowerCase.call(b);c.replace(pathValues,function(a,b){b&¶ms.push(+b)}),data.push([b][concat](params))}),data.toString=R._path2string,data});var paths=function(ps){var p=paths.ps=paths.ps||{};return p[ps]?p[ps].sleep=1:p[ps]={sleep:1},setTimeout(function(){for(var key in p)p[has](key)&&key!=ps&&(p[key].sleep--,!p[key].sleep&&delete p[key])}),p[ps]};R.findDotsAtSegment=function(p1x,p1y,c1x,c1y,c2x,c2y,p2x,p2y,t){var t1=1-t,t13=pow(t1,3),t12=pow(t1,2),t2=t*t,t3=t2*t,x=t13*p1x+3*t12*t*c1x+3*t1*t*t*c2x+t3*p2x,y=t13*p1y+3*t12*t*c1y+3*t1*t*t*c2y+t3*p2y,mx=p1x+2*t*(c1x-p1x)+t2*(c2x-2*c1x+p1x),my=p1y+2*t*(c1y-p1y)+t2*(c2y-2*c1y+p1y),nx=c1x+2*t*(c2x-c1x)+t2*(p2x-2*c2x+c1x),ny=c1y+2*t*(c2y-c1y)+t2*(p2y-2*c2y+c1y),ax=t1*p1x+t*c1x,ay=t1*p1y+t*c1y,cx=t1*c2x+t*p2x,cy=t1*c2y+t*p2y,alpha=90-180*math.atan2(mx-nx,my-ny)/PI;return(mx>nx||my=bbox.x&&x<=bbox.x2&&y>=bbox.y&&y<=bbox.y2},R.isBBoxIntersect=function(bbox1,bbox2){var i=R.isPointInsideBBox;return i(bbox2,bbox1.x,bbox1.y)||i(bbox2,bbox1.x2,bbox1.y)||i(bbox2,bbox1.x,bbox1.y2)||i(bbox2,bbox1.x2,bbox1.y2)||i(bbox1,bbox2.x,bbox2.y)||i(bbox1,bbox2.x2,bbox2.y)||i(bbox1,bbox2.x,bbox2.y2)||i(bbox1,bbox2.x2,bbox2.y2)||(bbox1.xbbox2.x||bbox2.xbbox1.x)&&(bbox1.ybbox2.y||bbox2.ybbox1.y)},R.pathIntersection=function(path1,path2){return interPathHelper(path1,path2)},R.pathIntersectionNumber=function(path1,path2){return interPathHelper(path1,path2,1)},R.isPointInsidePath=function(path,x,y){var bbox=R.pathBBox(path);return R.isPointInsideBBox(bbox,x,y)&&interPathHelper(path,[["M",x,y],["H",bbox.x2+10]],1)%2==1},R._removedFactory=function(methodname){return function(){eve("raphael.log",null,"Raphaël: you are calling to method “"+methodname+"” of removed object",methodname)}};var pathDimensions=R.pathBBox=function(path){var pth=paths(path);if(pth.bbox)return clone(pth.bbox);if(!path)return{x:0,y:0,width:0,height:0,x2:0,y2:0};path=path2curve(path);for(var p,x=0,y=0,X=[],Y=[],i=0,ii=path.length;i1&&(h=math.sqrt(h),rx*=h,ry*=h);var rx2=rx*rx,ry2=ry*ry,k=(large_arc_flag==sweep_flag?-1:1)*math.sqrt(abs((rx2*ry2-rx2*y*y-ry2*x*x)/(rx2*y*y+ry2*x*x))),cx=k*rx*y/ry+(x1+x2)/2,cy=k*-ry*x/rx+(y1+y2)/2,f1=math.asin(((y1-cy)/ry).toFixed(9)),f2=math.asin(((y2-cy)/ry).toFixed(9));f1=x1f2&&(f1-=2*PI),!sweep_flag&&f2>f1&&(f2-=2*PI)}var df=f2-f1;if(abs(df)>_120){var f2old=f2,x2old=x2,y2old=y2;f2=f1+_120*(sweep_flag&&f2>f1?1:-1),x2=cx+rx*math.cos(f2),y2=cy+ry*math.sin(f2),res=a2c(x2,y2,rx,ry,angle,0,sweep_flag,x2old,y2old,[f2,f2old,cx,cy])}df=f2-f1;var c1=math.cos(f1),s1=math.sin(f1),c2=math.cos(f2),s2=math.sin(f2),t=math.tan(df/4),hx=4/3*rx*t,hy=4/3*ry*t,m1=[x1,y1],m2=[x1+hx*s1,y1-hy*c1],m3=[x2+hx*s2,y2-hy*c2],m4=[x2,y2];if(m2[0]=2*m1[0]-m2[0],m2[1]=2*m1[1]-m2[1],recursive)return[m2,m3,m4][concat](res);res=[m2,m3,m4][concat](res).join()[split](",");for(var newres=[],i=0,ii=res.length;i"1e12"&&(t1=.5),abs(t2)>"1e12"&&(t2=.5),t1>0&&t1<1&&(dot=findDotAtSegment(p1x,p1y,c1x,c1y,c2x,c2y,p2x,p2y,t1),x.push(dot.x),y.push(dot.y)),t2>0&&t2<1&&(dot=findDotAtSegment(p1x,p1y,c1x,c1y,c2x,c2y,p2x,p2y,t2),x.push(dot.x),y.push(dot.y)),a=c2y-2*c1y+p1y-(p2y-2*c2y+c1y),b=2*(c1y-p1y)-2*(c2y-c1y),c=p1y-c1y,t1=(-b+math.sqrt(b*b-4*a*c))/2/a,t2=(-b-math.sqrt(b*b-4*a*c))/2/a,abs(t1)>"1e12"&&(t1=.5),abs(t2)>"1e12"&&(t2=.5),t1>0&&t1<1&&(dot=findDotAtSegment(p1x,p1y,c1x,c1y,c2x,c2y,p2x,p2y,t1),x.push(dot.x),y.push(dot.y)),t2>0&&t2<1&&(dot=findDotAtSegment(p1x,p1y,c1x,c1y,c2x,c2y,p2x,p2y,t2),x.push(dot.x),y.push(dot.y)),{min:{x:mmin[apply](0,x),y:mmin[apply](0,y)},max:{x:mmax[apply](0,x),y:mmax[apply](0,y)}}}),path2curve=R._path2curve=cacher(function(path,path2){var pth=!path2&&paths(path);if(!path2&&pth.curve)return pathClone(pth.curve);for(var p=pathToAbsolute(path),p2=path2&&pathToAbsolute(path2),attrs={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},attrs2={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},processPath=(function(path,d,pcom){var nx,ny;if(!path)return["C",d.x,d.y,d.x,d.y,d.x,d.y];switch(!(path[0]in{T:1,Q:1})&&(d.qx=d.qy=null),path[0]){case"M":d.X=path[1],d.Y=path[2];break;case"A":path=["C"][concat](a2c[apply](0,[d.x,d.y][concat](path.slice(1))));break;case"S":"C"==pcom||"S"==pcom?(nx=2*d.x-d.bx,ny=2*d.y-d.by):(nx=d.x,ny=d.y),path=["C",nx,ny][concat](path.slice(1));break;case"T":"Q"==pcom||"T"==pcom?(d.qx=2*d.x-d.qx,d.qy=2*d.y-d.qy):(d.qx=d.x,d.qy=d.y),path=["C"][concat](q2c(d.x,d.y,d.qx,d.qy,path[1],path[2]));break;case"Q":d.qx=path[1],d.qy=path[2],path=["C"][concat](q2c(d.x,d.y,path[1],path[2],path[3],path[4]));break;case"L":path=["C"][concat](l2c(d.x,d.y,path[1],path[2]));break;case"H":path=["C"][concat](l2c(d.x,d.y,path[1],d.y));break;case"V":path=["C"][concat](l2c(d.x,d.y,d.x,path[1]));break;case"Z":path=["C"][concat](l2c(d.x,d.y,d.X,d.Y))}return path}),fixArc=function(pp,i){if(pp[i].length>7){pp[i].shift();for(var pi=pp[i];pi.length;)pp.splice(i++,0,["C"][concat](pi.splice(0,6)));pp.splice(i,1),ii=mmax(p.length,p2&&p2.length||0)}},fixM=function(path1,path2,a1,a2,i){path1&&path2&&"M"==path1[i][0]&&"M"!=path2[i][0]&&(path2.splice(i,0,["M",a2.x,a2.y]),a1.bx=0,a1.by=0,a1.x=path1[i][1],a1.y=path1[i][2],ii=mmax(p.length,p2&&p2.length||0))},i=0,ii=mmax(p.length,p2&&p2.length||0);ilength){if(subpath&&!subpaths.start){if(point=getPointAtSegmentLength(x,y,p[1],p[2],p[3],p[4],p[5],p[6],length-len),sp+=["C"+point.start.x,point.start.y,point.m.x,point.m.y,point.x,point.y],onlystart)return sp;subpaths.start=sp,sp=["M"+point.x,point.y+"C"+point.n.x,point.n.y,point.end.x,point.end.y,p[5],p[6]].join(),len+=l,x=+p[5],y=+p[6];continue}if(!istotal&&!subpath)return point=getPointAtSegmentLength(x,y,p[1],p[2],p[3],p[4],p[5],p[6],length-len),{x:point.x,y:point.y,alpha:point.alpha}}len+=l,x=+p[5],y=+p[6]}sp+=p.shift()+p}return subpaths.end=sp,point=istotal?len:subpath?subpaths:R.findDotsAtSegment(x,y,p[0],p[1],p[2],p[3],p[4],p[5],1),point.alpha&&(point={x:point.x,y:point.y,alpha:point.alpha}),point}},getTotalLength=getLengthFactory(1),getPointAtLength=getLengthFactory(),getSubpathsAtLength=getLengthFactory(0,1);R.getTotalLength=getTotalLength,R.getPointAtLength=getPointAtLength,R.getSubpath=function(path,from,to){if(this.getTotalLength(path)-to<1e-6)return getSubpathsAtLength(path,from).end;var a=getSubpathsAtLength(path,to,1);return from?getSubpathsAtLength(a,from).end:a},elproto.getTotalLength=function(){var path=this.getPath();if(path)return this.node.getTotalLength?this.node.getTotalLength():getTotalLength(path)},elproto.getPointAtLength=function(length){var path=this.getPath();if(path)return getPointAtLength(path,length)},elproto.getPath=function(){var path,getPath=R._getPath[this.type];if("text"!=this.type&&"set"!=this.type)return getPath&&(path=getPath(this)),path},elproto.getSubpath=function(from,to){var path=this.getPath();if(path)return R.getSubpath(path,from,to)};var ef=R.easing_formulas={linear:function(n){return n},"<":function(n){return pow(n,1.7)},">":function(n){return pow(n,.48)},"<>":function(n){var q=.48-n/1.04,Q=math.sqrt(.1734+q*q),x=Q-q,X=pow(abs(x),1/3)*(x<0?-1:1),y=-Q-q,Y=pow(abs(y),1/3)*(y<0?-1:1),t=X+Y+.5;return 3*(1-t)*t*t+t*t*t},backIn:function(n){var s=1.70158;return n*n*((s+1)*n-s)},backOut:function(n){n-=1;var s=1.70158;return n*n*((s+1)*n+s)+1},elastic:function(n){return n==!!n?n:pow(2,-10*n)*math.sin((n-.075)*(2*PI)/.3)+1},bounce:function(n){var l,s=7.5625,p=2.75;return n<1/p?l=s*n*n:n<2/p?(n-=1.5/p,l=s*n*n+.75):n<2.5/p?(n-=2.25/p,l=s*n*n+.9375):(n-=2.625/p,l=s*n*n+.984375),l}};ef.easeIn=ef["ease-in"]=ef["<"],ef.easeOut=ef["ease-out"]=ef[">"],ef.easeInOut=ef["ease-in-out"]=ef["<>"],ef["back-in"]=ef.backIn,ef["back-out"]=ef.backOut;var animationElements=[],requestAnimFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(callback){setTimeout(callback,16)},animation=function(){for(var Now=+new Date,l=0;l1&&!e.next){for(key in to)to[has](key)&&(init[key]=e.totalOrigin[key]);e.el.attr(init),runAnimation(e.anim,e.el,e.anim.percents[0],null,e.totalOrigin,e.repeat-1)}e.next&&!e.stop&&runAnimation(e.anim,e.el,e.next,null,e.totalOrigin,e.repeat)}}}R.svg&&that&&that.paper&&that.paper.safari(),animationElements.length&&requestAnimFrame(animation)},upto255=function(color){return color>255?255:color<0?0:color};elproto.animateWith=function(el,anim,params,ms,easing,callback){var element=this;if(element.removed)return callback&&callback.call(element),element;var a=params instanceof Animation?params:R.animation(params,ms,easing,callback);runAnimation(a,element,a.percents[0],null,element.attr());for(var i=0,ii=animationElements.length;i.5)-1;pow(fx-.5,2)+pow(fy-.5,2)>.25&&(fy=math.sqrt(.25-pow(fx-.5,2))*dir+.5)&&.5!=fy&&(fy=fy.toFixed(5)-1e-5*dir)}return E}),gradient=gradient.split(/\s*\-\s*/),"linear"==type){var angle=gradient.shift();if(angle=-toFloat(angle),isNaN(angle))return null;var vector=[0,0,math.cos(R.rad(angle)),math.sin(R.rad(angle))],max=1/(mmax(abs(vector[2]),abs(vector[3]))||1);vector[2]*=max,vector[3]*=max,vector[2]<0&&(vector[0]=-vector[2],vector[2]=0),vector[3]<0&&(vector[1]=-vector[3],vector[3]=0)}var dots=R._parseDots(gradient);if(!dots)return null;if(id=id.replace(/[\(\)\s,\xb0#]/g,"_"),element.gradient&&id!=element.gradient.id&&(SVG.defs.removeChild(element.gradient),delete element.gradient),!element.gradient){el=$(type+"Gradient",{id:id}),element.gradient=el,$(el,"radial"==type?{fx:fx,fy:fy}:{x1:vector[0],y1:vector[1],x2:vector[2],y2:vector[3],gradientTransform:element.matrix.invert()}),SVG.defs.appendChild(el);for(var i=0,ii=dots.length;i1?clr.opacity/100:clr.opacity});case"stroke":clr=R.getRGB(value),node.setAttribute(att,clr.hex),"stroke"==att&&clr[has]("opacity")&&$(node,{"stroke-opacity":clr.opacity>1?clr.opacity/100:clr.opacity}),"stroke"==att&&o._.arrows&&("startString"in o._.arrows&&addArrow(o,o._.arrows.startString),"endString"in o._.arrows&&addArrow(o,o._.arrows.endString,1));break;case"gradient":("circle"==o.type||"ellipse"==o.type||"r"!=Str(value).charAt())&&addGradientFill(o,value);break;case"opacity":attrs.gradient&&!attrs[has]("stroke-opacity")&&$(node,{"stroke-opacity":value>1?value/100:value});case"fill-opacity":if(attrs.gradient){gradient=R._g.doc.getElementById(node.getAttribute("fill").replace(/^url\(#|\)$/g,E)),gradient&&(stops=gradient.getElementsByTagName("stop"),$(stops[stops.length-1],{"stop-opacity":value}));break}default:"font-size"==att&&(value=toInt(value,10)+"px");var cssrule=att.replace(/(\-.)/g,function(w){return w.substring(1).toUpperCase()});node.style[cssrule]=value,o._.dirty=1,node.setAttribute(att,value)}}tuneText(o,params),node.style.visibility=vis},leading=1.2,tuneText=function(el,params){if("text"==el.type&&(params[has]("text")||params[has]("font")||params[has]("font-size")||params[has]("x")||params[has]("y"))){var a=el.attrs,node=el.node,fontSize=node.firstChild?toInt(R._g.doc.defaultView.getComputedStyle(node.firstChild,E).getPropertyValue("font-size"),10):10;if(params[has]("text")){for(a.text=params.text;node.firstChild;)node.removeChild(node.firstChild);for(var tspan,texts=Str(params.text).split("\n"),tspans=[],i=0,ii=texts.length;i"));var brect=span.getBoundingClientRect();res.W=a.w=(brect.right-brect.left)/m,res.H=a.h=(brect.bottom-brect.top)/m,res.X=a.x,res.Y=a.y+res.H/2,("x"in params||"y"in params)&&(res.path.v=R.format("m{0},{1}l{2},{1}",round(a.x*zoom),round(a.y*zoom),round(a.x*zoom)+1));for(var dirtyattrs=["x","y","text","font","font-family","font-weight","font-style","font-size"],d=0,dd=dirtyattrs.length;d.25&&(fy=math.sqrt(.25-pow(fx-.5,2))*(2*(fy>.5)-1)+.5),fxfy=fx+S+fy),E}),gradient=gradient.split(/\s*\-\s*/),"linear"==type){var angle=gradient.shift();if(angle=-toFloat(angle),isNaN(angle))return null}var dots=R._parseDots(gradient);if(!dots)return null;if(o=o.shape||o.node,dots.length){o.removeChild(fill),fill.on=!0,fill.method="none",fill.color=dots[0].color,fill.color2=dots[dots.length-1].color;for(var clrs=[],i=0,ii=dots.length;i')}}catch(e){createNode=function(tagName){return doc.createElement("<"+tagName+' xmlns="urn:schemas-microsoft.com:vml" class="rvml">')}}},R._engine.initWin(R._g.win),R._engine.create=function(){var con=R._getContainer.apply(0,arguments),container=con.container,height=con.height,width=con.width,x=con.x,y=con.y;if(!container)throw new Error("VML container not found.");var res=new R._Paper,c=res.canvas=R._g.doc.createElement("div"),cs=c.style;return x=x||0,y=y||0,width=width||512,height=height||342,res.width=width,res.height=height,width==+width&&(width+="px"),height==+height&&(height+="px"),res.coordsize=1e3*zoom+S+1e3*zoom,res.coordorigin="0 0",res.span=R._g.doc.createElement("span"),res.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;",c.appendChild(res.span),cs.cssText=R.format("top:0;left:0;width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden",width,height),1==container?(R._g.doc.body.appendChild(c),cs.left=x+"px",cs.top=y+"px",cs.position="absolute"):container.firstChild?container.insertBefore(c,container.firstChild):container.appendChild(c),res.renderfix=function(){},res},R.prototype.clear=function(){R.eve("raphael.clear",this),this.canvas.innerHTML=E,this.span=R._g.doc.createElement("span"),this.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;",this.canvas.appendChild(this.span),this.bottom=this.top=null},R.prototype.remove=function(){R.eve("raphael.remove",this),this.canvas.parentNode.removeChild(this.canvas);for(var i in this)this[i]="function"==typeof this[i]?R._removedFactory(i):null;return!0};var setproto=R.st;for(var method in elproto)elproto[has](method)&&!setproto[has](method)&&(setproto[method]=function(methodname){return function(){var arg=arguments;return this.forEach(function(el){el[methodname].apply(el,arg)})}}(method))}}(),oldRaphael.was?g.win.Raphael=R:Raphael=R,R}),window.ABCJS||(window.ABCJS={}),function(){"use strict";function hasClass(element,cls){var elClass=element.getAttribute("class"),rclass=/[\t\r\n\f]/g,className=" "+cls+" ";return 1===element.nodeType&&(" "+elClass+" ").replace(rclass," ").indexOf(className)>=0}function getAllElementsByClasses(startingEl,class1,class2){for(var els=startingEl.getElementsByClassName(class1),ret=[],i=0;iouter.offsetWidth-paper.scrollWidth&&(scrollTimer=setTimeout(scrolling,interval))}function nextMeasure(lineNum,measureNum){lineNum=parseInt(lineNum,10),measureNum=parseInt(measureNum,10),measureNum++;var els=getAllElementsByClasses(paper,"l"+lineNum,"m"+measureNum);return els.length>0?[lineNum,measureNum]:(lineNum++,measureNum=0,els=getAllElementsByClasses(paper,"l"+lineNum,"m"+measureNum),els.length>0?[lineNum,measureNum]:null)}function processMeasureHider(lineNum,measureNum){var els=getAllElementsByClasses(paper,"l"+lineNum,"m"+measureNum);if(els.length>0)for(var i=0;i=0;e--){var ev=timingEvents[e];"bar"===ev.type?(ev.top=lastEventTop,ev.nextTop=lastBarTop,lastBarTop=lastEventTop,ev.bottom=lastEventBottom,ev.nextBottom=lastBarBottom,lastBarBottom=lastEventBottom):"event"===ev.type&&(lastEventTop=ev.top,lastEventBottom=ev.top+ev.height)}}function makeSortedArray(hash){var arr=[];for(var k in hash)hash.hasOwnProperty(k)&&arr.push(hash[k]);return arr=arr.sort(function(a,b){var diff=a.time-b.time;return 0!==diff?diff:"bar"===a.type?-1:1})}function setupEvents(engraver){for(var eventHash={},time=0,isTiedState=!1,line=0;line0){var isTiedToNext=element.startTie;isTiedState?isTiedToNext||(isTiedState=!1):(eventHash["event"+voiceTime]?eventHash["event"+voiceTime].left=Math.min(eventHash["event"+voiceTime].left,element.x):eventHash["event"+voiceTime]={type:"event",time:voiceTime,top:top,height:height,left:element.x,width:element.w},isTiedToNext&&(isTiedState=!0)),voiceTime+=element.duration}if("bar"===element.type&&(0===timingEvents.length||"bar"!==timingEvents[timingEvents.length-1])&&element.elemset&&element.elemset.length>0&&element.elemset[0].attrs){for(var lineNum,measureNum,klass=element.elemset[0].attrs.class,arr=klass.split(" "),i=0;i0?timingEvents[0].time/beatLength:0}return options.scrollHint&&lastTop!==currentNote.top&&(lastTop=currentNote.top,setMargin(lastTop)),options.showCursor&&cursor.css({left:currentNote.left+"px",top:currentNote.top+"px",width:currentNote.width+"px",height:currentNote.height+"px"}),timingEvents.length>0?timingEvents[0].time/beatLength:(stopNextTime=!0,0)}function processNext(){if(stopNextTime)return void ABCJS.stopAnimation();var currentTime=(new Date).getTime();if(isPaused)return void(pausedDifference=currentTime-pausedTime);var nextTimeInBeats=processShowCursor(),nextTimeInMilliseconds=nextTimeInBeats/beatsPerMillisecond,interval=startTime+nextTimeInMilliseconds-currentTime;interval<=0?processNext():animateTimer=setTimeout(processNext,interval)}if(void 0===paper.getElementsByClassName)return void console.error("ABCJS.startAnimation: The first parameter must be a regular DOM element. (Did you pass a jQuery object or an ID?)");if(void 0===tune.getBeatLength)return void console.error("ABCJS.startAnimation: The second parameter must be a single tune. (Did you pass the entire array of tunes?)");if((options.scrollHorizontal||options.scrollVertical||options.scrollHint)&&(hasClass(paper,"abcjs-inner")||(paper.scrollTop=0,paper.style.overflow="hidden",paper=paper.children[0]),!hasClass(paper,"abcjs-inner")))return void console.error("ABCJS.startAnimation: When using scrollHorizontal/scrollVertical/scrollHint, the music must have been rendered using viewportHorizontal/viewportVertical.");ABCJS.stopAnimation(),animationTarget=paper,shouldResetOverflow=options.scrollVertical||options.scrollHint,options.showCursor&&(cursor=$('
'),$(paper).append(cursor),$(paper).css({position:"relative"})),stopNextTime=!1;var millisecondsPerHalfMeasure,beatsPerMinute=getBeatsPerMinute(tune,options),beatsPerMillisecond=beatsPerMinute/6e4,beatLength=tune.getBeatLength(),totalBeats=0;if(options.scrollVertical){var millisecondsPerBeat=1/beatsPerMillisecond,beatsPerMeasure=1/beatLength,millisecondsPerMeasure=millisecondsPerBeat*beatsPerMeasure;millisecondsPerHalfMeasure=millisecondsPerMeasure/2,cssRule=getCssRule(".abcjs-inner")}var startTime,pausedTime,pausedDifference,isPaused=!1,initialWait=2700,interval=11,distance=1,outer=paper.parentNode;options.scrollHorizontal&&(paper.style.marginLeft="0px",scrollTimer=setTimeout(scrolling,initialWait));var timingEvents=[];setupEvents(tune.engraver);var lastTop=-1;$(outer).find(".abcjs-inner");if(currentMargin=0,options.scrollVertical&&setMargin(0),startTime=new Date,startTime=startTime.getTime(),isPaused=!1,options.hideCurrentMeasure){var next=nextMeasure(0,-1);next&&processMeasureHider(next[0],next[1])}processNext(),ABCJS.pauseAnimation=function(pause){if(pause&&!isPaused)isPaused=!0,pausedTime=(new Date).getTime();else if(!pause&&isPaused){var nowTime=(new Date).getTime(),elapsedTimeWhenPaused=nowTime-pausedTime;startTime+=elapsedTimeWhenPaused,pausedTime=void 0,isPaused=!1,animateTimer=setTimeout(processNext,pausedDifference),pausedDifference=void 0}}},ABCJS.stopAnimation=function(){clearTimeout(animateTimer),clearTimeout(scrollTimer),cursor&&(cursor.remove(),cursor=null),shouldResetOverflow&&(animationTarget&&animationTarget.parentNode&&(animationTarget.parentNode.style.overflowY="auto"),setMargin(0))}}(),window.ABCJS||(window.ABCJS={}),function(){"use strict";function renderEngine(callback,output,abc,parserParams,renderParams){var ret=[],isArray=function(testObject){return testObject&&!testObject.propertyIsEnumerable("length")&&"object"==typeof testObject&&"number"==typeof testObject.length};if(void 0!==output&&void 0!==abc){isArray(output)||(output=[output]),void 0===parserParams&&(parserParams={}),void 0===renderParams&&(renderParams={});for(var currentTune=renderParams.startingTune?renderParams.startingTune:0,book=new ABCJS.TuneBook(abc),abcParser=new window.ABCJS.parse.Parse,i=0;i',renderParams.scrollHorizontal?(div.style.overflowX="auto",div.style.overflowY="hidden"):div.style.overflow="hidden",resizeDivs[div.id]=div,div=div.children[0]):renderParams.viewportVertical&&(div.innerHTML='
',div.style.overflowX="hidden",div.style.overflowY="auto",div=div.children[0]);var paper=Raphael(div,width,400);void 0===engraverParams&&(engraverParams={});var engraver_controller=new ABCJS.write.EngraverController(paper,engraverParams);if(engraver_controller.engraveABC(tune),tune.engraver=engraver_controller,renderParams.viewportVertical||renderParams.viewportHorizontal){var parent=div.parentNode;parent.style.width=div.style.width}}function renderEachLineSeparately(div,tune,renderParams,engraverParams){function initializeTuneLine(tune){return{formatting:tune.formatting,media:tune.media,version:tune.version,metaText:{},lines:[]}}for(var tuneLine,tunes=[],i=0;i1&&!window.ABCJS.parse.startsWith(This.tunes[0].abc,"X:")){var dir=This.tunes.shift(),arrDir=dir.abc.split("\n");window.ABCJS.parse.each(arrDir,function(line){window.ABCJS.parse.startsWith(line,"%%")&&(directives+=line+"\n")})}This.header=directives,window.ABCJS.parse.each(This.tunes,function(tune){var end=tune.abc.indexOf("\n\n");end>0&&(tune.abc=tune.abc.substring(0,end)),tune.pure=tune.abc,tune.abc=directives+tune.abc;var title=tune.pure.split("T:");title.length>1?(title=title[1].split("\n"),tune.title=title[0].replace(/^\s+|\s+$/g,"")):tune.title="";var id=tune.pure.substring(2,tune.pure.indexOf("\n"));tune.id=id.replace(/^\s+|\s+$/g,"")})},ABCJS.TuneBook.prototype.getTuneById=function(id){for(var i=0;i=0;e--){var ev=timingEvents[e];"bar"===ev.type?(ev.top=lastEventTop,ev.nextTop=lastBarTop,lastBarTop=lastEventTop,ev.bottom=lastEventBottom,ev.nextBottom=lastBarBottom,lastBarBottom=lastEventBottom):"event"===ev.type&&(lastEventTop=ev.top,lastEventBottom=ev.top+ev.height)}}function makeSortedArray(hash){var arr=[];for(var k in hash)hash.hasOwnProperty(k)&&arr.push(hash[k]);return arr=arr.sort(function(a,b){var diff=a.seconds-b.seconds;return 0!==diff?diff:"bar"===a.type?-1:1})}this.getBeatLength=function(){for(var i=0;i0){var num=parseInt(meter.value[0].num,10),den=parseInt(meter.value[0].den,10);return 6===num&&8===den?3/8:9===num&&8===den?3/8:12===num&&8===den?3/8:1/den}return null}return"cut_time"===meter.type?.5:.25}return null},this.reset=function(){this.version="1.0.1",this.media="screen",this.metaText={},this.formatting={},this.lines=[],this.staffNum=0,this.voiceNum=0,this.lineNum=0},this.cleanUp=function(defWidth,defLength,barsperstaff,staffnonote,currSlur){function cleanUpSlursInLine(line){for(var x,addEndSlur=function(obj,num,chordPos){if(void 0===currSlur[chordPos]){for(x=0;xcurrentLine;){if(lines[currentLine].staff)return lines[currentLine];currentLine++}return null}this.closeLine();var i,s,v,anyDeleted=!1;for(i=0;i=barsperstaff&&n0&&voice[voice.length-1].barNumber){var nextLine=getNextMusicLine(this.lines,this.lineNum);nextLine&&(nextLine.staff[0].barNumber=voice[voice.length-1].barNumber),delete voice[voice.length-1].barNumber}}}return this.formatting.pagewidth||(this.formatting.pagewidth=defWidth),this.formatting.pageheight||(this.formatting.pageheight=defLength),delete this.staffNum,delete this.voiceNum,delete this.lineNum,delete this.potentialStartBeam,delete this.potentialEndBeam,delete this.vskipPending,currSlur},this.reset(),this.getLastNote=function(){if(this.lines[this.lineNum]&&this.lines[this.lineNum].staff&&this.lines[this.lineNum].staff[this.staffNum]&&this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum])for(var i=this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum].length-1;i>=0;i--){var el=this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum][i];if("note"===el.el_type)return el}return null},this.addTieToLastNote=function(){var el=this.getLastNote();return!!(el&&el.pitches&&el.pitches.length>0)&&(el.pitches[0].startTie={},!0)},this.getDuration=function(el){return el.duration?el.duration:0},this.closeLine=function(){this.potentialStartBeam&&this.potentialEndBeam&&(this.potentialStartBeam.startBeam=!0,this.potentialEndBeam.endBeam=!0),delete this.potentialStartBeam,delete this.potentialEndBeam},this.appendElement=function(type,startChar,endChar,hashParams){var This=this,pushNote=function(hp){if(void 0!==hp.pitches){var mid=This.lines[This.lineNum].staff[This.staffNum].workingClef.verticalPos;window.ABCJS.parse.each(hp.pitches,function(p){p.verticalPos=p.pitch-mid})}if(void 0!==hp.gracenotes){var mid2=This.lines[This.lineNum].staff[This.staffNum].workingClef.verticalPos;window.ABCJS.parse.each(hp.gracenotes,function(p){p.verticalPos=p.pitch-mid2})}This.lines[This.lineNum].staff[This.staffNum].voices[This.voiceNum].push(hp)};hashParams.el_type=type,null!==startChar&&(hashParams.startChar=startChar),null!==endChar&&(hashParams.endChar=endChar);var endBeamHere=function(){This.potentialStartBeam.startBeam=!0,hashParams.endBeam=!0,delete This.potentialStartBeam,delete This.potentialEndBeam},endBeamLast=function(){void 0!==This.potentialStartBeam&&void 0!==This.potentialEndBeam&&(This.potentialStartBeam.startBeam=!0,This.potentialEndBeam.endBeam=!0),delete This.potentialStartBeam,delete This.potentialEndBeam};if("note"===type){var dur=This.getDuration(hashParams);dur>=.25?endBeamLast():hashParams.force_end_beam_last&&void 0!==This.potentialStartBeam?endBeamLast():hashParams.end_beam&&void 0!==This.potentialStartBeam?void 0===hashParams.rest?endBeamHere():endBeamLast():void 0===hashParams.rest&&(void 0===This.potentialStartBeam?hashParams.end_beam||(This.potentialStartBeam=hashParams,delete This.potentialEndBeam):This.potentialEndBeam=hashParams)}else endBeamLast();delete hashParams.end_beam,delete hashParams.force_end_beam_last,pushNote(hashParams)},this.appendStartingElement=function(type,startChar,endChar,hashParams2){this.closeLine();var impliedNaturals;"key"===type&&(impliedNaturals=hashParams2.impliedNaturals,delete hashParams2.impliedNaturals);var hashParams=window.ABCJS.parse.clone(hashParams2);if(this.lines[this.lineNum].staff){"clef"===type&&(this.lines[this.lineNum].staff[this.staffNum].workingClef=hashParams),this.lines[this.lineNum].staff.length<=this.staffNum&&(this.lines[this.lineNum].staff[this.staffNum]={},this.lines[this.lineNum].staff[this.staffNum].clef=window.ABCJS.parse.clone(this.lines[this.lineNum].staff[0].clef),this.lines[this.lineNum].staff[this.staffNum].key=window.ABCJS.parse.clone(this.lines[this.lineNum].staff[0].key),this.lines[this.lineNum].staff[0].meter&&(this.lines[this.lineNum].staff[this.staffNum].meter=window.ABCJS.parse.clone(this.lines[this.lineNum].staff[0].meter)),this.lines[this.lineNum].staff[this.staffNum].workingClef=window.ABCJS.parse.clone(this.lines[this.lineNum].staff[0].workingClef),this.lines[this.lineNum].staff[this.staffNum].voices=[[]]);for(var voice=this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum],i=0;i0){if(void 0!==This.lines[This.lineNum].staff[This.staffNum].voices[0]){for(var found=!1,i=0;i=0;i--)if(void 0!==this.lines[i].staff)return!1;return!0},this.getMeter=function(){for(var i=0;i0){var isTiedToNext=element.startTie;isTiedState?isTiedToNext||(isTiedState=!1):(eventHash["event"+voiceTime]?(eventHash["event"+voiceTime].left=Math.min(eventHash["event"+voiceTime].left,element.x),eventHash["event"+voiceTime].elements.push(element.elemset)):eventHash["event"+voiceTime]={type:"event",seconds:voiceTime,top:top,height:height,left:element.x,width:element.w,elements:[element.elemset]},isTiedToNext&&(isTiedState=!0)),voiceTime+=element.duration/timeDivider}}maxVoiceTime=Math.max(maxVoiceTime,voiceTime)}time=maxVoiceTime}return timingEvents=makeSortedArray(eventHash),addVerticalInfo(timingEvents),timingEvents},this.setTiming=function(bpm,measuresOfDelay){var meter=this.getMeter();this.barTimings=[];var measureLength,beatLength=this.getBeatLength(),beatsPerSecond=bpm/60;switch(meter.type){case"common_time":measureLength=1,this.meter={num:4,den:4};break;case"cut_time":measureLength=1,this.meter={num:2,den:2};break;default:measureLength=meter.value[0].num/meter.value[0].den,this.meter={num:meter.value[0].num,den:meter.value[0].den}}var startingDelay=measureLength/beatLength*measuresOfDelay/beatsPerSecond,timeDivider=beatLength*beatsPerSecond;this.noteTimings=this.setupEvents(startingDelay,timeDivider)}},window.ABCJS||(window.ABCJS={}),window.ABCJS.midi||(window.ABCJS.midi={}),function(){"use strict";function isFunction(functionToCheck){var getType={};return functionToCheck&&"[object Function]"===getType.toString.call(functionToCheck)}function preprocessLabel(label,title){return label.replace(/%T/g,title)}function hasClass(element,cls){return!!element&&(" "+element.className+" ").indexOf(" "+cls+" ")>-1}function addClass(element,cls){element&&(hasClass(element,cls)||(element.className=element.className+" "+cls))}function removeClass(element,cls){element&&(element.className=element.className.replace(cls,"").trim().replace(" "," "))}function toggleClass(element,cls){element&&(hasClass(element,cls)?removeClass(element,cls):addClass(element,cls))}function closest(element,cls){if(!element)return null;for(;element!==document.body;){if(hasClass(element,cls))return element;element=element.parentNode}return null}function find(element,cls){if(!element)return null;var els=element.getElementsByClassName(cls);return 0===els.length?null:els[0]}function addLoadEvent(func){var oldOnLoad=window.onload;"function"!=typeof window.onload?window.onload=func:window.onload=function(){oldOnLoad&&oldOnLoad(),func()}}function afterSetup(timeWarp,data,onSuccess){MIDI.player.currentTime=0,MIDI.player.warp=timeWarp,MIDI.player.load({events:data}),onSuccess()}function setCurrentMidiTune(timeWarp,data,onSuccess){midiJsInitialized?afterSetup(timeWarp,data,onSuccess):MIDI.setup({debug:!0,soundfontUrl:window.ABCJS.midi.soundfontUrl}).then(function(){midiJsInitialized=!0,afterSetup(timeWarp,data,onSuccess)})}function startCurrentlySelectedTune(){MIDI.player.start(MIDI.player.currentTime)}function stopCurrentlyPlayingTune(){MIDI.player.stop()}function pauseCurrentlyPlayingTune(){MIDI.player.pause()}function setMidiCallback(midiJsListener){MIDI.player.setAnimation(midiJsListener)}function jumpToMidiPosition(play,offset,width){var ratio=offset/width,endTime=MIDI.player.duration;play&&pauseCurrentlyPlayingTune(),MIDI.player.currentTime=endTime*ratio,play&&startCurrentlySelectedTune()}function setTimeWarp(percent){MIDI.player.warp=percent>0?100/percent:1}function loadMidi(target,onSuccess){var dataEl=find(target,"abcjs-data"),data=JSON.parse(dataEl.innerHTML),timeWarp=1,tempoEl=find(target,"abcjs-midi-tempo");if(tempoEl){var percent=parseInt(tempoEl.value,10);percent>0&&(timeWarp=100/percent)}setCurrentMidiTune(timeWarp,data,onSuccess)}function deselectMidiControl(){var otherMidi=find(document,"abcjs-midi-current");if(otherMidi){stopCurrentlyPlayingTune(),removeClass(otherMidi,"abcjs-midi-current");var otherMidiStart=find(otherMidi,"abcjs-midi-start");removeClass(otherMidiStart,"abcjs-pushed")}}function findElements(visualItems,currentTime,epsilon){for(var currentIndex,currentElement,minIndex=0,maxIndex=visualItems.length-1;minIndex<=maxIndex;)if(currentIndex=(minIndex+maxIndex)/2|0,currentElement=visualItems[currentIndex],currentElement.seconds-epsiloncurrentTime))return currentIndex;maxIndex=currentIndex-1}for(;visualItems[currentIndex].seconds-epsilon>=currentTime&¤tIndex>0;)currentIndex--;return 0===currentIndex&&visualItems[currentIndex].seconds-epsilon>=currentTime?-1:currentIndex}function midiJsListener(position){var midiControl;if(position.duration>0&&lastNow!==position.progress&&(lastNow=position.progress,midiControl=find(document,"abcjs-midi-current"))){var startButton=find(midiControl,"abcjs-midi-start");if(hasClass(startButton,"abcjs-pushed")){var progressBackground=find(midiControl,"abcjs-midi-progress-background"),totalWidth=progressBackground.offsetWidth,progressIndicator=find(midiControl,"abcjs-midi-progress-indicator"),scaled=totalWidth*lastNow;progressIndicator.style.left=scaled+"px";var clock=find(midiControl,"abcjs-midi-clock");if(clock){var seconds=Math.floor(position.currentTime),minutes=Math.floor(seconds/60);seconds%=60,seconds<10&&(seconds="0"+seconds),minutes<10&&(minutes=" "+minutes),clock.innerHTML=minutes+":"+seconds}var beatsPerSecond=parseInt(midiControl.abcjsQpm,10)/60,currentTime=position.currentTime;if(midiControl.abcjsListener){var thisBeat=Math.floor(currentTime/beatsPerSecond);position.newBeat=thisBeat!==midiControl.abcjsLastBeat,midiControl.abcjsLastBeat=thisBeat,midiControl.abcjsListener(midiControl,position)}if(midiControl.abcjsAnimate){var epsilon=beatsPerSecond/64,index=findElements(midiControl.abcjsTune.noteTimings,currentTime,epsilon);if(index!==midiControl.abcjsLastIndex){var last=midiControl.abcjsLastIndex>=0?midiControl.abcjsTune.noteTimings[midiControl.abcjsLastIndex]:null;midiControl.abcjsAnimate(last,midiControl.abcjsTune.noteTimings[index]),midiControl.abcjsLastIndex=index}}}}if(1===position.progress){midiControl=find(document,"abcjs-midi-current");var loopControl=find(midiControl,"abcjs-midi-loop"),finishedResetting=function(){loopControl&&hasClass(loopControl,"abcjs-pushed")&&onStart(find(midiControl,"abcjs-midi-start"))};setTimeout(function(){doReset(midiControl,finishedResetting),midiControl.abcjsAnimate&&midiControl.abcjsAnimate(midiControl.abcjsTune.noteTimings[midiControl.abcjsLastIndex],null)},1)}}function onStart(target){var parent=closest(target,"abcjs-inline-midi");if(hasClass(target,"abcjs-pushed"))pauseCurrentlyPlayingTune(),removeClass(target,"abcjs-pushed");else{if(hasClass(parent,"abcjs-midi-current"))startCurrentlySelectedTune();else{deselectMidiControl();var onSuccess=function(){startCurrentlySelectedTune(),addClass(parent,"abcjs-midi-current")};loadMidi(parent,onSuccess)}addClass(target,"abcjs-pushed")}parent.abcjsLastBeat=-1,parent.abcjsLastIndex=-1,setMidiCallback(midiJsListener)}function onSelection(target){toggleClass(target,"abcjs-pushed")}function onLoop(target){toggleClass(target,"abcjs-pushed")}function doReset(target,callback){function onSuccess(){addClass(parent,"abcjs-midi-current");var progressIndicator=find(parent,"abcjs-midi-progress-indicator");progressIndicator.style.left="0px";var clock=find(parent,"abcjs-midi-clock");clock.innerHTML=" 0:00",callback&&callback()}var parent=closest(target,"abcjs-inline-midi");deselectMidiControl(),parent&&loadMidi(parent,onSuccess)}function onReset(target){function keepPlaying(){play&&(startCurrentlySelectedTune(),addClass(playEl,"abcjs-pushed"))}var parent=closest(target,"abcjs-inline-midi"),playEl=find(parent,"abcjs-midi-start"),play=hasClass(playEl,"abcjs-pushed");hasClass(parent,"abcjs-midi-current")&&doReset(target,keepPlaying)}function relMouseX(target,event){var totalOffsetX=0;do totalOffsetX+=target.offsetLeft-target.scrollLeft,target=target.offsetParent;while(target);return event.pageX-totalOffsetX}function onProgress(target,event){var parent=closest(target,"abcjs-inline-midi");if(hasClass(parent,"abcjs-midi-current")){var play=find(parent,"abcjs-midi-start");play=hasClass(play,"abcjs-pushed");var width=target.offsetWidth,offset=relMouseX(target,event);jumpToMidiPosition(play,offset,width)}}function onTempo(el){for(var percent=parseInt(el.value,10),startTempo=parseInt(el.getAttribute("data-start-tempo"),10);el&&!hasClass(el,"abcjs-midi-current-tempo");)el=el.nextSibling;el.innerHTML=Math.floor(percent*startTempo/100),setTimeWarp(percent)}function addDelegates(){if(document.body.addEventListener("click",function(event){event=event||window.event;for(var target=event.target||event.srcElement;target&&target!==document.body;){if(hasClass(target,"abcjs-midi-start"))return void onStart(target,event);if(hasClass(target,"abcjs-midi-selection"))return void onSelection(target,event);if(hasClass(target,"abcjs-midi-loop"))return void onLoop(target,event);if(hasClass(target,"abcjs-midi-reset"))return void onReset(target,event);if(hasClass(target,"abcjs-midi-progress-background"))return void onProgress(target,event);target=target.parentNode}}),document.body.addEventListener("change",function(event){event=event||window.event;for(var target=event.target||event.srcElement;target!==document.body;)hasClass(target,"abcjs-midi-tempo")&&onTempo(target,event),target=target.parentNode}),void 0===window.MIDI){window.ABCJS.midi.midiInlineInitialized="not loaded";for(var els=document.getElementsByClassName("abcjs-inline-midi"),i=0;i';midiParams.preTextDownload&&(html+=midiParams.preTextDownload);var label,title=tune.metaText&&tune.metaText.title?tune.metaText.title:"Untitled";return label=midiParams.downloadLabel&&isFunction(midiParams.downloadLabel)?midiParams.downloadLabel(tune,index):midiParams.downloadLabel?midiParams.downloadLabel.replace(/%T/,title):'Download MIDI for "'+title+'"',title=title.toLowerCase().replace(/'/g,"").replace(/\W/g,"_").replace(/__/g,"_"),html+=''+label+"",midiParams.postTextDownload&&(html+=midiParams.postTextDownload),html+""},window.ABCJS.midi.generateMidiControls=function(tune,midiParams,midi,index){if("failed"===window.ABCJS.midi.midiInlineInitialized)return'
ERROR
'; if("not loaded"===window.ABCJS.midi.midiInlineInitialized)return'
MIDI NOT PRESENT
';var title=tune.metaText&&tune.metaText.title?tune.metaText.title:"Untitled",options=midiParams.inlineControls||{};void 0===options.standard&&(options.standard=!0),void 0===options.tooltipSelection&&(options.tooltipSelection="Click to toggle play selection/play all."),void 0===options.tooltipLoop&&(options.tooltipLoop="Click to toggle play once/repeat."),void 0===options.tooltipReset&&(options.tooltipReset="Click to go to beginning."),void 0===options.tooltipPlay&&(options.tooltipPlay="Click to play/pause."),void 0===options.tooltipProgress&&(options.tooltipProgress="Click to change the playback position."),void 0===options.tooltipTempo&&(options.tooltipTempo="Change the playback speed.");var style="";options.hide&&(style='style="display:none;"');var html='
";if(html+='",midiParams.preTextInline&&(html+=''+preprocessLabel(midiParams.preTextInline,title)+""),options.selectionToggle&&(html+=''),options.loopToggle&&(html+=''),options.standard&&(html+=' 0:00'),options.tempo){var startTempo=tune&&tune.metaText&&tune.metaText.tempo?tune.metaText.tempo.bpm:180;html+='% ('+startTempo+" BPM)"}return midiParams.postTextInline&&(html+=''+preprocessLabel(midiParams.postTextInline,title)+""),html+"
"},window.ABCJS.midi.soundfontUrl="/soundfont/";var lastNow,midiJsInitialized=!1;window.ABCJS.midi.startPlaying=function(target){onStart(target)},window.ABCJS.midi.stopPlaying=function(){stopCurrentlyPlayingTune()},addLoadEvent(addDelegates)}(),window.ABCJS||(window.ABCJS={}),window.ABCJS.midi||(window.ABCJS.midi={}),function(){"use strict";function convertPitch(pitch){return 60+pitch}var baseDuration=1920;window.ABCJS.midi.create=function(abcTune,options){void 0===options&&(options={});var sequence=window.ABCJS.midi.sequence(abcTune,options),commands=window.ABCJS.midi.flatten(sequence,options),midi=window.ABCJS.midi.rendererFactory(),midiJs=new window.ABCJS.midi.Preparer,title=abcTune.metaText?abcTune.metaText.title:void 0;title&&title.length>128&&(title=title.substring(0,124)+"..."),midi.setGlobalInfo(commands.tempo,title),midiJs.setGlobalInfo(commands.tempo,title),void 0!==commands.instrument&&(midi.setInstrument(commands.instrument),midiJs.setInstrument(commands.instrument)),void 0!==commands.channel&&(midi.setChannel(commands.channel),midiJs.setChannel(commands.channel));for(var i=0;i=0)return"break"}return null}function timeFromStart(){for(var distance=0,ct=0;ct0&&chordTrack.push({cmd:"move",duration:distance*tempoChangeFactor})}lastChord=c,currentChords.push({chord:lastChord,beat:barBeat})}}elem.startTriplet&&(multiplier=2===elem.startTriplet?1.5:(elem.startTriplet-1)/elem.startTriplet);var duration=elem.duration*multiplier;barBeat+=duration;var graces;if(elem.gracenotes){var stealFromCurrent=bagpipes||lastNoteDurationPosition<0||0===currentTrack.length,stealFromDuration=stealFromCurrent?duration:currentTrack[lastNoteDurationPosition].duration;graces=processGraceNotes(elem.gracenotes,stealFromDuration),bagpipes||(duration=writeGraceNotes(graces,stealFromCurrent,duration,null,velocity))}if(elem.pitches){graces&&bagpipes&&(duration=writeGraceNotes(graces,!0,duration,null,velocity));for(var pitches=[],i=0;icompanionDuration?companionDuration/(2*graceDuration):1;for(g=0;g.0078125){pattern=[];for(var beatsPresent=barBeat/beatLength,p=0;p0&&distance0&&(resolveChords(),currentChords=[]),barBeat=0,barAccidentals=[],0===i&&writeDrum();break;case"bagpipes":bagpipes=!0;break;case"instrument":instrument=element.program;break;case"channel":channel=element.channel;break;case"drum":drumDefinition=normalizeDrumDefinition(element.params);break;default:console.log("MIDI creation. Unknown el_type: "+element.el_type+"\n")}}tracks.push(currentTrack),chordTrack.length>0&&(chordTrackFinished=!0),drumTrack.length>0&&(drumTrackFinished=!0)}chordTrack.length>0&&tracks.push(chordTrack),drumTrack.length>0&&tracks.push(drumTrack);var num=parseInt(startingMeter.num,10),den=parseInt(startingMeter.den,10);return 2===den?startingTempo*=2:8===den?parseInt(num,10)%3===0?startingTempo*=1.5:startingTempo/=2:16===den&&(num%3===0?startingTempo*=.75:startingTempo/=4),{tempo:startingTempo,instrument:instrument,channel:channel,tracks:tracks}};var breakSynonyms=["break","(break)","no chord","n.c.","tacet"],scale=[0,2,4,5,7,9,11],graceDivider=8,basses={A:-27,B:-25,C:-24,D:-22,E:-20,F:-19,G:-17},chordIntervals={M:[0,4,7],6:[0,4,7,9],7:[0,4,7,10],"+7":[0,4,8,10],aug7:[0,4,8,10],maj7:[0,4,7,11],"∆7":[0,4,7,11],9:[0,4,7,10,14],11:[0,4,7,10,14,16],13:[0,4,7,10,14,18],"+":[0,4,8],"7#5":[0,4,8,10],"7+5":[0,4,8,10],"7b9":[0,4,7,10,13],"7b5":[0,4,6,10],"9#5":[0,4,8,10,14],"9+5":[0,4,8,10,14],m:[0,3,7],"-":[0,3,7],m6:[0,3,7,9],"-6":[0,3,7,9],m7:[0,3,7,10],"-7":[0,3,7,10],dim:[0,3,6],dim7:[0,3,6,9],"°7":[0,3,6,9],"ø7":[0,3,6,9],"7sus4":[0,5,7,10],m7sus4:[0,5,7,10],sus4:[0,5,7]},rhythmPatterns={"2/2":["boom","chick"],"2/4":["boom","chick"],"3/4":["boom","chick","chick"],"4/4":["boom","chick","boom2","chick"],"6/8":["boom","","chick","boom2","","chick"]}}(),window.ABCJS||(window.ABCJS={}),window.ABCJS.midi||(window.ABCJS.midi={}),function(){"use strict";function addAbsoluteTime(tracks){for(var i=0;ib.absTime?1:-1})}function adjustTime(output){for(var lastTime=0,i=0;i>=7;for(var i=a.length-1;i>=0;i--){res<<=8;var bits=a[i];0!==i&&(bits|=128),res|=bits}var padding=res.toString(16).length;return padding+=padding%2,toHex(res,padding)}Midi.prototype.setTempo=function(qpm){0===this.trackcount&&(this.startTrack(),this.track+="%00%FF%51%03"+toHex(Math.round(6e7/qpm),6),this.endTrack())},Midi.prototype.setGlobalInfo=function(qpm,name){if(0===this.trackcount){if(this.startTrack(),this.track+="%00%FF%51%03"+toHex(Math.round(6e7/qpm),6),name){this.track+="%00%FF%03"+toHex(name.length,2);for(var i=0;i1&&(channel=globals.program[1])),globals.transpose&&(transpose=globals.transpose[0]),globals.channel&&(channel=globals.channel[0]),globals.drum&&(drumPattern=globals.drum),globals.drumbars&&(drumBars=globals.drumbars[0]),globals.drumon&&(drumOn=!0)}abctune.metaText.tempo&&(qpm=interpretTempo(abctune.metaText.tempo)),options.qpm&&(qpm=parseInt(options.qpm,10));var startVoice=[];bagpipes&&startVoice.push({el_type:"bagpipes"}),startVoice.push({el_type:"instrument",program:program}),channel&&startVoice.push({el_type:"channel",channel:channel}),transpose&&startVoice.push({el_type:"transpose",transpose:transpose}),startVoice.push({el_type:"tempo",qpm:qpm});for(var voices=[],startRepeatPlaceholder=[],skipEndingPlaceholder=[],startingDrumSet=!1,i=0;i0&&voices[voiceNumber].push({el_type:"bar"}),noteEventsInBar=0;var endRepeat="bar_right_repeat"===elem.type||"bar_dbl_repeat"===elem.type,startEnding="1"===elem.startEnding,startRepeat="bar_left_repeat"===elem.type||"bar_dbl_repeat"===elem.type||"bar_thick_thin"===elem.type||"bar_thin_thick"===elem.type||"bar_thin_thin"===elem.type||"bar_right_repeat"===elem.type;if(endRepeat){var s=startRepeatPlaceholder[voiceNumber];s||(s=0);var e=skipEndingPlaceholder[voiceNumber];e||(e=voices[voiceNumber].length),voices[voiceNumber]=voices[voiceNumber].concat(voices[voiceNumber].slice(s,e)),skipEndingPlaceholder[voiceNumber]=void 0,startRepeatPlaceholder[voiceNumber]=void 0}startEnding&&(skipEndingPlaceholder[voiceNumber]=voices[voiceNumber].length),startRepeat&&(startRepeatPlaceholder[voiceNumber]=voices[voiceNumber].length);break;case"style":break;case"part":break;case"stem":case"scale":break;case"midi":var drumChange=!1;switch(elem.cmd){case"drumon":drumOn=!0,drumChange=!0;break;case"drumoff":drumOn=!1,drumChange=!0;break;case"drum":drumPattern=elem.params,drumChange=!0;break;case"drumbars":drumBars=elem.params[0],drumChange=!0}drumChange&&(voices[0].push({el_type:"drum",params:{pattern:drumPattern,bars:drumBars,intro:drumIntro,on:drumOn}}),startingDrumSet=!0);break;default:console.log("MIDI: element type "+elem.el_type+" not handled.")}}voiceNumber++}}if(drumIntro)for(var vv=0;vvinsertPoint;)insertPoint++;if(voices[vv].length>insertPoint)for(var w=0;w=0&&str.lastIndexOf(pattern)===d},window.ABCJS.parse.each=function(arr,iterator,context){for(var i=0,length=arr.length;i",">")},warn=function(str,line,col_num){line||(line=" ");var bad_char=line.charAt(col_num);" "===bad_char&&(bad_char="SPACE");var clean_line=encode(line.substring(0,col_num))+''+bad_char+""+encode(line.substring(col_num+1));addWarning("Music Line:"+tune.getNumLines()+":"+(col_num+1)+": "+str+": "+clean_line)},header=new window.ABCJS.parse.ParseHeader(tokenizer,warn,multilineVars,tune);this.getWarnings=function(){return multilineVars.warnings};var letter_to_chord=function(line,i){if('"'===line.charAt(i)){var chord=tokenizer.getBrackettedSubstring(line,i,5);if(chord[2]||warn("Missing the closing quote while parsing the chord symbol",line,i),chord[0]>0&&chord[1].length>0&&"^"===chord[1].charAt(0))chord[1]=chord[1].substring(1),chord[2]="above";else if(chord[0]>0&&chord[1].length>0&&"_"===chord[1].charAt(0))chord[1]=chord[1].substring(1),chord[2]="below";else if(chord[0]>0&&chord[1].length>0&&"<"===chord[1].charAt(0))chord[1]=chord[1].substring(1),chord[2]="left";else if(chord[0]>0&&chord[1].length>0&&">"===chord[1].charAt(0))chord[1]=chord[1].substring(1),chord[2]="right";else if(chord[0]>0&&chord[1].length>0&&"@"===chord[1].charAt(0)){chord[1]=chord[1].substring(1);var x=tokenizer.getFloat(chord[1]);0===x.digits&&warn("Missing first position in absolutely positioned annotation.",line,i),chord[1]=chord[1].substring(x.digits),","!==chord[1][0]&&warn("Missing comma absolutely positioned annotation.",line,i),chord[1]=chord[1].substring(1);var y=tokenizer.getFloat(chord[1]);0===y.digits&&warn("Missing second position in absolutely positioned annotation.",line,i),chord[1]=chord[1].substring(y.digits);var ws=tokenizer.skipWhiteSpace(chord[1]);chord[1]=chord[1].substring(ws),chord[2]=null,chord[3]={x:x.value,y:y.value}}else chord[1]=chord[1].replace(/([ABCDEFG])b/g,"$1♭"),chord[1]=chord[1].replace(/([ABCDEFG])#/g,"$1♯"),chord[2]="default";return chord}return[0,""]},legalAccents=["trill","lowermordent","uppermordent","mordent","pralltriller","accent","fermata","invertedfermata","tenuto","0","1","2","3","4","5","+","wedge","open","thumb","snap","turn","roll","breath","shortphrase","mediumphrase","longphrase","segno","coda","D.S.","D.C.","fine","slide","^","marcato","upbow","downbow","/","//","///","////","trem1","trem2","trem3","trem4","turnx","invertedturn","invertedturnx","trill(","trill)","arpeggio","xstem","mark","umarcato","style=normal","style=harmonic","style=rhythm","style=x"],volumeDecorations=["p","pp","f","ff","mf","mp","ppp","pppp","fff","ffff","sfz"],dynamicDecorations=["crescendo(","crescendo)","diminuendo(","diminuendo)"],accentPseudonyms=[["<","accent"],[">","accent"],["tr","trill"],["plus","+"],["emphasis","accent"],["^","umarcato"],["marcato","umarcato"]],accentDynamicPseudonyms=[["<(","crescendo("],["<)","crescendo)"],[">(","diminuendo("],[">)","diminuendo)"]],letter_to_accent=function(line,i){var macro=multilineVars.macros[line.charAt(i)];if(void 0!==macro)return"!"!==macro.charAt(0)&&"+"!==macro.charAt(0)||(macro=macro.substring(1)),"!"!==macro.charAt(macro.length-1)&&"+"!==macro.charAt(macro.length-1)||(macro=macro.substring(0,macro.length-1)),window.ABCJS.parse.detect(legalAccents,function(acc){return macro===acc})?[1,macro]:window.ABCJS.parse.detect(volumeDecorations,function(acc){return macro===acc})?("hidden"===multilineVars.volumePosition&&(macro=""),[1,macro]):window.ABCJS.parse.detect(dynamicDecorations,function(acc){return"hidden"===multilineVars.dynamicPosition&&(macro=""),macro===acc})?[1,macro]:(window.ABCJS.parse.detect(multilineVars.ignoredDecorations,function(dec){return macro===dec})||warn("Unknown macro: "+macro,line,i),[1,""]);switch(line.charAt(i)){case".":return[1,"staccato"];case"u":return[1,"upbow"];case"v":return[1,"downbow"];case"~":return[1,"irishroll"];case"!":case"+":var ret=tokenizer.getBrackettedSubstring(line,i,5);return ret[1].length>0&&("^"===ret[1].charAt(0)||"_"===ret[1].charAt(0))&&(ret[1]=ret[1].substring(1)),window.ABCJS.parse.detect(legalAccents,function(acc){return ret[1]===acc})?ret:window.ABCJS.parse.detect(volumeDecorations,function(acc){return ret[1]===acc})?("hidden"===multilineVars.volumePosition&&(ret[1]=""),ret):window.ABCJS.parse.detect(dynamicDecorations,function(acc){return ret[1]===acc})?("hidden"===multilineVars.dynamicPosition&&(ret[1]=""),ret):window.ABCJS.parse.detect(accentPseudonyms,function(acc){return ret[1]===acc[0]&&(ret[1]=acc[1],!0)})?ret:window.ABCJS.parse.detect(accentDynamicPseudonyms,function(acc){return ret[1]===acc[0]&&(ret[1]=acc[1],!0)})?("hidden"===multilineVars.dynamicPosition&&(ret[1]=""),ret):"!"!==line.charAt(i)||1!==ret[0]&&"!"===line.charAt(i+ret[0]-1)?(warn("Unknown decoration: "+ret[1],line,i),ret[1]="",ret):[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"]}return[0,0]},letter_to_spacer=function(line,i){for(var start=i;tokenizer.isWhiteSpace(line.charAt(i));)i++;return[i-start]},letter_to_bar=function(line,curr_pos){var ret=tokenizer.getBarLine(line,curr_pos);if(0===ret.len)return[0,""];if(ret.warn)return warn(ret.warn,line,curr_pos),[ret.len,""];for(var ws=0;ws="2"&&line.charAt(i+1)<="9"?(void 0!==ret.triplet?warn("Can't nest triplets",line,i):(ret.triplet=line.charAt(i+1)-"0",i+2="1"&&line.charAt(i+4)<="9"?(ret.num_notes=line.charAt(i+4)-"0",i+=3):warn("expected number after the two colons after the triplet to mark the duration",line,i):i+3="1"&&line.charAt(i+3)<="9"?i+4="1"&&line.charAt(i+5)<="9"&&(ret.num_notes=line.charAt(i+5)-"0",i+=4):(ret.num_notes=ret.triplet,i+=3):warn("expected number after the triplet to mark the duration",line,i))),i++):void 0===ret.startSlur?ret.startSlur=1:ret.startSlur++),i++;return ret.consumed=i-start,ret},addWords=function(line,words){if(!line)return void warn("Can't add words before the first line of music",line,0);words=window.ABCJS.parse.strip(words),"-"!==words.charAt(words.length-1)&&(words+=" ");for(var word_list=[],last_divider=0,replace=!1,addWord=function(i){var word=window.ABCJS.parse.strip(words.substring(last_divider,i));if(last_divider=i+1,word.length>0){replace&&(word=window.ABCJS.parse.gsub(word,"~"," "));var div=words.charAt(i);return"_"!==div&&"-"!==div&&(div=" "),word_list.push({syllable:tokenizer.translateString(word),divider:div}),replace=!1,!0}return!1},i=0;i0&&(window.ABCJS.parse.last(word_list).divider="-",word_list.push({skip:!0,to:"next"}));break;case"_":addWord(i),word_list.push({skip:!0,to:"slur"});break;case"*":addWord(i),word_list.push({skip:!0,to:"next"});break;case"|":addWord(i),word_list.push({skip:!0,to:"bar"});break;case"~":replace=!0}var inSlur=!1;window.ABCJS.parse.each(line,function(el){if(0!==word_list.length)if(word_list[0].skip)switch(word_list[0].to){case"next":"note"!==el.el_type||null===el.pitches||inSlur||word_list.shift();break;case"slur":"note"===el.el_type&&null!==el.pitches&&word_list.shift();break;case"bar":"bar"===el.el_type&&word_list.shift()}else if("note"===el.el_type&&void 0===el.rest&&!inSlur){var lyric=word_list.shift();void 0===el.lyric?el.lyric=[lyric]:el.lyric.push(lyric)}})},addSymbols=function(line,words){if(!line)return void warn("Can't add symbols before the first line of music",line,0);words=window.ABCJS.parse.strip(words),"-"!==words.charAt(words.length-1)&&(words+=" ");for(var word_list=[],last_divider=0,replace=!1,addWord=function(i){var word=window.ABCJS.parse.strip(words.substring(last_divider,i));if(last_divider=i+1,word.length>0){replace&&(word=window.ABCJS.parse.gsub(word,"~"," "));var div=words.charAt(i);return"_"!==div&&"-"!==div&&(div=" "),word_list.push({syllable:tokenizer.translateString(word),divider:div}),replace=!1,!0}return!1},i=0;i0&&(window.ABCJS.parse.last(word_list).divider="-",word_list.push({skip:!0,to:"next"}));break;case"_":addWord(i),word_list.push({skip:!0,to:"slur"});break;case"*":addWord(i),word_list.push({skip:!0,to:"next"});break;case"|":addWord(i),word_list.push({skip:!0,to:"bar"});break;case"~":replace=!0}var inSlur=!1;window.ABCJS.parse.each(line,function(el){if(0!==word_list.length)if(word_list[0].skip)switch(word_list[0].to){case"next":"note"!==el.el_type||null===el.pitches||inSlur||word_list.shift();break;case"slur":"note"===el.el_type&&null!==el.pitches&&word_list.shift();break;case"bar":"bar"===el.el_type&&word_list.shift()}else if("note"===el.el_type&&void 0===el.rest&&!inSlur){var lyric=word_list.shift();void 0===el.lyric?el.lyric=[lyric]:el.lyric.push(lyric)}})},getBrokenRhythm=function(line,index){switch(line.charAt(index)){case">":return index"===line.charAt(index+1)?[2,1.75,.25]:[1,1.5,.5];case"<":return index"!==line.charAt(index))return el;index--,state="broken_rhythm";break;case">":case"<":if(!isComplete(state))return null;if(!canHaveBrokenRhythm)return el.endChar=index,el;var br2=getBrokenRhythm(line,index);index+=br2[0]-1,multilineVars.next_note_duration=br2[2],el.duration=br2[1]*el.duration,state="end_slur";break;default:return isComplete(state)?(el.endChar=index,el):null}if(index++,index===line.length)return isComplete(state)?(el.endChar=index,el):null}return null},letter_to_grace=function(line,i){if("{"===line.charAt(i)){var gra=tokenizer.getBrackettedSubstring(line,i,1,"}");gra[2]||warn("Missing the closing '}' while parsing grace note",line,i),")"===line[i+gra[0]]&&(gra[0]++,gra[1]+=")");for(var gracenotes=[],ii=0,inTie=!1;ii0&&(gracenotes[gracenotes.length-1].end_beam=!0):warn("Unknown character '"+gra[1].charAt(ii)+"' while parsing grace note",line,i),ii++)}if(gracenotes.length)return[gra[0],gracenotes]}return[0]},nonDecorations="ABCDEFGabcdefgxyzZ[]|^_{",parseRegularMusicLine=function(line){header.resolveTempo(),multilineVars.is_in_header=!1;for(var i=0,startOfLine=multilineVars.iChar;tokenizer.isWhiteSpace(line.charAt(i))&&i0&&(i+=retHeader[0],"V"===retHeader[1]&&(delayStartNewLine=!0));for(var el={};i0)i+=retInlineHeader[0],"V"===retInlineHeader[1]&&(delayStartNewLine=!0);else{delayStartNewLine&&(startNewLine(),delayStartNewLine=!1);for(var ret;;)if(ret=tokenizer.eatWhiteSpace(line,i),ret>0&&(i+=ret),i>0&&""===line.charAt(i-1)&&(ret=header.letter_to_body_header(line,i),ret[0]>0&&("V"===ret[1]&&startNewLine(),i=ret[0],multilineVars.start_new_line=!1)),ret=letter_to_spacer(line,i),ret[0]>0&&(i+=ret[0]),ret=letter_to_chord(line,i),ret[0]>0){el.chord||(el.chord=[]);var chordName=tokenizer.translateString(ret[1]);chordName=chordName.replace(/;/g,"\n");for(var addedChord=!1,ci=0;ci0&&(el.force_end_beam_last=!0),i+=ii}else if(ret=nonDecorations.indexOf(line.charAt(i))===-1?letter_to_accent(line,i):[0],ret[0]>0)null===ret[1]?i+10&&(0===ret[1].indexOf("style=")?el.style=ret[1].substr(6):(void 0===el.decoration&&(el.decoration=[]),el.decoration.push(ret[1]))),i+=ret[0];else{if(ret=letter_to_grace(line,i),!(ret[0]>0))break;el.gracenotes=ret[1],i+=ret[0]}if(ret=letter_to_bar(line,i),ret[0]>0){void 0!==el.gracenotes&&(el.rest={type:"spacer"},el.duration=.125,multilineVars.addFormattingOptions(el,tune.formatting,"note"),tune.appendElement("note",startOfLine+i,startOfLine+i+ret[0],el),multilineVars.measureNotEmpty=!0,el={});var bar={type:ret[1]};if(0===bar.type.length)warn("Unknown bar type",line,i);else{if(multilineVars.inEnding&&"bar_thin"!==bar.type&&(bar.endEnding=!0,multilineVars.inEnding=!1),ret[2]&&(bar.startEnding=ret[2],multilineVars.inEnding&&(bar.endEnding=!0),multilineVars.inEnding=!0),void 0!==el.decoration&&(bar.decoration=el.decoration),void 0!==el.chord&&(bar.chord=el.chord),bar.startEnding&&void 0===multilineVars.barFirstEndingNum?multilineVars.barFirstEndingNum=multilineVars.currBarNumber:bar.startEnding&&bar.endEnding&&multilineVars.barFirstEndingNum?multilineVars.currBarNumber=multilineVars.barFirstEndingNum:bar.endEnding&&(multilineVars.barFirstEndingNum=void 0),"bar_invisible"!==bar.type&&multilineVars.measureNotEmpty){var isFirstVoice=void 0===multilineVars.currentVoice||0===multilineVars.currentVoice.staffNum&&0===multilineVars.currentVoice.index;isFirstVoice&&(multilineVars.currBarNumber++,multilineVars.barNumbers&&multilineVars.currBarNumber%multilineVars.barNumbers===0&&(bar.barNumber=multilineVars.currBarNumber))}multilineVars.addFormattingOptions(el,tune.formatting,"bar"),tune.appendElement("bar",startOfLine+i,startOfLine+i+ret[0],bar),multilineVars.measureNotEmpty=!1,el={}}i+=ret[0]}else if("&"===line[i])warn("Overlay not yet supported",line,i),i++;else{if(ret=letter_to_open_slurs_and_triplets(line,i),ret.consumed>0&&(void 0!==ret.startSlur&&(el.startSlur=ret.startSlur),void 0!==ret.triplet&&(tripletNotesLeft>0?warn("Can't nest triplets",line,i):(el.startTriplet=ret.triplet,tripletNotesLeft=void 0===ret.num_notes?ret.triplet:ret.num_notes)),i+=ret.consumed),"["===line.charAt(i)){var chordStartChar=i;i++;for(var chordDuration=null,done=!1;!done;){var chordNote=getCoreNote(line,i,{},!1);if(null!==chordNote)chordNote.end_beam&&(el.end_beam=!0,delete chordNote.end_beam),void 0===el.pitches?(el.duration=chordNote.duration,el.pitches=[chordNote]):el.pitches.push(chordNote),delete chordNote.duration,multilineVars.inTieChord[el.pitches.length]&&(chordNote.endTie=!0,multilineVars.inTieChord[el.pitches.length]=void 0),chordNote.startTie&&(multilineVars.inTieChord[el.pitches.length]=!0),i=chordNote.endChar,delete chordNote.endChar;else if(" "===line.charAt(i))warn("Spaces are not allowed in chords",line,i),i++;else{if(i0&&(tripletNotesLeft--,0===tripletNotesLeft&&(el.endTriplet=!0));for(var postChordDone=!1;i":case"<":var br2=getBrokenRhythm(line,i);i+=br2[0]-1,multilineVars.next_note_duration=br2[2],chordDuration?chordDuration*=br2[1]:chordDuration=br2[1];break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"/":var fraction=tokenizer.getFraction(line,i);chordDuration=fraction.value,i=fraction.index,"-"===line.charAt(i)||")"===line.charAt(i)||" "===line.charAt(i)||"<"===line.charAt(i)||">"===line.charAt(i)?i--:postChordDone=!0;break;default:postChordDone=!0}postChordDone||i++}}else warn("Expected ']' to end the chords",line,i);void 0!==el.pitches&&(null!==chordDuration&&(el.duration=el.duration*chordDuration),multilineVars.addFormattingOptions(el,tune.formatting,"note"),tune.appendElement("note",startOfLine+chordStartChar,startOfLine+i,el),multilineVars.measureNotEmpty=!0,el={}),done=!0}}}else{var el2={},core=getCoreNote(line,i,el2,!0);void 0!==el2.endTie&&(multilineVars.inTie=!0),null!==core&&(void 0!==core.pitch?(el.pitches=[{}],void 0!==core.accidental&&(el.pitches[0].accidental=core.accidental),el.pitches[0].pitch=core.pitch,void 0!==core.endSlur&&(el.pitches[0].endSlur=core.endSlur),void 0!==core.endTie&&(el.pitches[0].endTie=core.endTie),void 0!==core.startSlur&&(el.pitches[0].startSlur=core.startSlur),void 0!==el.startSlur&&(el.pitches[0].startSlur=el.startSlur),void 0!==core.startTie&&(el.pitches[0].startTie=core.startTie),void 0!==el.startTie&&(el.pitches[0].startTie=el.startTie)):(el.rest=core.rest,void 0!==core.endSlur&&(el.endSlur=core.endSlur),void 0!==core.endTie&&(el.rest.endTie=core.endTie),void 0!==core.startSlur&&(el.startSlur=core.startSlur),void 0!==core.startTie&&(el.rest.startTie=core.startTie),void 0!==el.startTie&&(el.rest.startTie=el.startTie)),void 0!==core.chord&&(el.chord=core.chord),void 0!==core.duration&&(el.duration=core.duration),void 0!==core.decoration&&(el.decoration=core.decoration),void 0!==core.graceNotes&&(el.graceNotes=core.graceNotes),delete el.startSlur,multilineVars.inTie&&(void 0!==el.pitches?(el.pitches[0].endTie=!0,multilineVars.inTie=!1):"spacer"!==el.rest.type&&(el.rest.endTie=!0,multilineVars.inTie=!1)),(core.startTie||el.startTie)&&(multilineVars.inTie=!0),i=core.endChar,tripletNotesLeft>0&&(tripletNotesLeft--,0===tripletNotesLeft&&(el.endTriplet=!0)),core.end_beam&&addEndBeam(el),el.rest&&"rest"===el.rest.type&&1===el.duration&&(el.rest.type="whole",el.duration=durationOfMeasure(multilineVars)),multilineVars.addFormattingOptions(el,tune.formatting,"note"),tune.appendElement("note",startOfLine+startI,startOfLine+i,el),multilineVars.measureNotEmpty=!0,el={})}i===startI&&(" "!==line.charAt(i)&&"`"!==line.charAt(i)&&warn("Unknown character ignored",line,i),i++)}}}}},parseLine=function(line){var ret=header.parseHeader(line);ret.regular&&parseRegularMusicLine(ret.str),ret.newline&&void 0===multilineVars.continueall&&startNewLine(),ret.words&&addWords(tune.getCurrentVoice(),line.substring(2)),ret.symbols&&addSymbols(tune.getCurrentVoice(),line.substring(2)),ret.recurse&&parseLine(ret.str)};this.parse=function(strTune,switches){switches||(switches={}),tune.reset(),switches.print&&(tune.media="print"),multilineVars.reset(),header.reset(tokenizer,warn,multilineVars,tune),strTune=window.ABCJS.parse.gsub(strTune,"\r\n","\n"),strTune=window.ABCJS.parse.gsub(strTune,"\r","\n"),strTune+="\n",strTune=strTune.replace(/\n\\.*\n/g,"\n");var continuationReplacement=function(all,backslash,comment){var spaces=" ",padding=comment?spaces.substring(0,comment.length):"";return backslash+" "+padding};strTune=strTune.replace(/\\([ \t]*)(%.*)*\n/g,continuationReplacement);var lines=strTune.split("\n");0===window.ABCJS.parse.last(lines).length&&lines.pop();try{switches.format&&window.ABCJS.parse.parseDirective.globalFormatting(switches.format),window.ABCJS.parse.each(lines,function(line){if(switches.header_only&&multilineVars.is_in_header===!1)throw"normal_abort";if(switches.stop_on_warning&&multilineVars.warnings)throw"normal_abort";multilineVars.is_in_history?":"===line.charAt(1)?(multilineVars.is_in_history=!1,parseLine(line)):tune.addMetaText("history",tokenizer.translateString(tokenizer.stripComment(line))):multilineVars.inTextBlock?window.ABCJS.parse.startsWith(line,"%%endtext")?(tune.addText(multilineVars.textBlock),multilineVars.inTextBlock=!1):window.ABCJS.parse.startsWith(line,"%%")?multilineVars.textBlock+=" "+line.substring(2):multilineVars.textBlock+=" "+line:multilineVars.inPsBlock?window.ABCJS.parse.startsWith(line,"%%endps")?multilineVars.inPsBlock=!1:multilineVars.textBlock+=" "+line:parseLine(line),multilineVars.iChar+=line.length+1});var ph=792,pl=612;switch(multilineVars.papersize){case"legal":ph=1008,pl=612;break;case"A4":ph=842.4,pl=597.6}if(multilineVars.landscape){var x=ph;ph=pl,pl=x}multilineVars.openSlurs=tune.cleanUp(pl,ph,multilineVars.barsperstaff,multilineVars.staffnonote,multilineVars.openSlurs)}catch(err){if("normal_abort"!==err)throw err}switches.hint_measures&&addHintMeasures()}},window.ABCJS||(window.ABCJS={}),window.ABCJS.parse||(window.ABCJS.parse={}),window.ABCJS.parse.parseDirective={},function(){"use strict";function initializeFonts(){multilineVars.annotationfont={face:"Helvetica",size:12,weight:"normal",style:"normal",decoration:"none"},multilineVars.gchordfont={face:"Helvetica",size:12,weight:"normal",style:"normal",decoration:"none"},multilineVars.historyfont={face:'"Times New Roman"',size:16,weight:"normal",style:"normal",decoration:"none"},multilineVars.infofont={face:'"Times New Roman"',size:14,weight:"normal",style:"italic",decoration:"none"},multilineVars.measurefont={face:'"Times New Roman"',size:14,weight:"normal",style:"italic",decoration:"none"},multilineVars.partsfont={face:'"Times New Roman"',size:15,weight:"normal",style:"normal",decoration:"none"},multilineVars.repeatfont={face:'"Times New Roman"',size:13,weight:"normal",style:"normal",decoration:"none"},multilineVars.textfont={face:'"Times New Roman"',size:16,weight:"normal",style:"normal",decoration:"none"},multilineVars.vocalfont={face:'"Times New Roman"',size:13,weight:"bold",style:"normal",decoration:"none"},multilineVars.wordsfont={face:'"Times New Roman"',size:16,weight:"normal",style:"normal",decoration:"none"},tune.formatting.composerfont={face:'"Times New Roman"',size:14,weight:"normal",style:"italic",decoration:"none"},tune.formatting.subtitlefont={face:'"Times New Roman"', size:16,weight:"normal",style:"normal",decoration:"none"},tune.formatting.tempofont={face:'"Times New Roman"',size:15,weight:"bold",style:"normal",decoration:"none"},tune.formatting.titlefont={face:'"Times New Roman"',size:20,weight:"normal",style:"normal",decoration:"none"},tune.formatting.footerfont={face:'"Times New Roman"',size:12,weight:"normal",style:"normal",decoration:"none"},tune.formatting.headerfont={face:'"Times New Roman"',size:12,weight:"normal",style:"normal",decoration:"none"},tune.formatting.voicefont={face:'"Times New Roman"',size:13,weight:"bold",style:"normal",decoration:"none"},tune.formatting.annotationfont=multilineVars.annotationfont,tune.formatting.gchordfont=multilineVars.gchordfont,tune.formatting.historyfont=multilineVars.historyfont,tune.formatting.infofont=multilineVars.infofont,tune.formatting.measurefont=multilineVars.measurefont,tune.formatting.partsfont=multilineVars.partsfont,tune.formatting.repeatfont=multilineVars.repeatfont,tune.formatting.textfont=multilineVars.textfont,tune.formatting.vocalfont=multilineVars.vocalfont,tune.formatting.wordsfont=multilineVars.wordsfont}var tokenizer,warn,multilineVars,tune;window.ABCJS.parse.parseDirective.initialize=function(tokenizer_,warn_,multilineVars_,tune_){tokenizer=tokenizer_,warn=warn_,multilineVars=multilineVars_,tune=tune_,initializeFonts()};var fontTypeCanHaveBox={gchordfont:!0,measurefont:!0,partsfont:!0},fontTranslation=function(fontFace){switch(fontFace){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}},getFontParameter=function(tokens,currentSetting,str,position,cmd){function processNumberOnly(){var size=parseInt(tokens[0].token);return tokens.shift(),currentSetting?0===tokens.length?{face:currentSetting.face,weight:currentSetting.weight,style:currentSetting.style,decoration:currentSetting.decoration,size:size}:1===tokens.length&&"box"===tokens[0].token&&fontTypeCanHaveBox[cmd]?{face:currentSetting.face,weight:currentSetting.weight,style:currentSetting.style,decoration:currentSetting.decoration,size:size,box:!0}:(warn("Extra parameters in font definition.",str,position),{face:currentSetting.face,weight:currentSetting.weight,style:currentSetting.style,decoration:currentSetting.decoration,size:size}):(warn("Can't set just the size of the font since there is no default value.",str,position),{face:'"Times New Roman"',weight:"normal",style:"normal",decoration:"none",size:size})}if("*"===tokens[0].token){if(tokens.shift(),"number"===tokens[0].type)return processNumberOnly();warn("Expected font size number after *.",str,position)}if("number"===tokens[0].type)return processNumberOnly();for(var size,face=[],weight="normal",style="normal",decoration="none",box=!1,state="face",hyphenLast=!1;tokens.length;){var currToken=tokens.shift(),word=currToken.token.toLowerCase();switch(state){case"face":hyphenLast||"utf"!==word&&"number"!==currToken.type&&"bold"!==word&&"italic"!==word&&"underline"!==word&&"box"!==word?face.length>0&&"-"===currToken.token?(hyphenLast=!0,face[face.length-1]=face[face.length-1]+currToken.token):hyphenLast?(hyphenLast=!1,face[face.length-1]=face[face.length-1]+currToken.token):face.push(currToken.token):"number"===currToken.type?(size?warn("Font size specified twice in font definition.",str,position):size=currToken.token,state="modifier"):"bold"===word?weight="bold":"italic"===word?style="italic":"underline"===word?decoration="underline":"box"===word?(fontTypeCanHaveBox[cmd]?box=!0:warn('This font style doesn\'t support "box"',str,position),state="finished"):"utf"===word?(currToken=tokens.shift(),state="size"):warn("Unknown parameter "+currToken.token+" in font definition.",str,position);break;case"size":"number"===currToken.type?size?warn("Font size specified twice in font definition.",str,position):size=currToken.token:warn("Expected font size in font definition.",str,position),state="modifier";break;case"modifier":"bold"===word?weight="bold":"italic"===word?style="italic":"underline"===word?decoration="underline":"box"===word?(fontTypeCanHaveBox[cmd]?box=!0:warn('This font style doesn\'t support "box"',str,position),state="finished"):warn("Unknown parameter "+currToken.token+" in font definition.",str,position);break;case"finished":warn('Extra characters found after "box" in font definition.',str,position)}}void 0===size?currentSetting?size=currentSetting.size:(warn("Must specify the size of the font since there is no default value.",str,position),size=12):size=parseFloat(size),face=face.join(" ");var psFont=fontTranslation(face),font={};return psFont?(font.face=psFont.face,font.weight=psFont.weight,font.style=psFont.style,font.decoration=psFont.decoration,font.size=size,box&&(font.box=!0),font):(font.face=face,font.weight=weight,font.style=style,font.decoration=decoration,font.size=size,box&&(font.box=!0),font)},getChangingFont=function(cmd,tokens,str){return 0===tokens.length?'Directive "'+cmd+'" requires a font as a parameter.':(multilineVars[cmd]=getFontParameter(tokens,multilineVars[cmd],str,0,cmd),multilineVars.is_in_header&&(tune.formatting[cmd]=multilineVars[cmd]),null)},getGlobalFont=function(cmd,tokens,str){return 0===tokens.length?'Directive "'+cmd+'" requires a font as a parameter.':(tune.formatting[cmd]=getFontParameter(tokens,tune.formatting[cmd],str,0,cmd),null)},setScale=function(cmd,tokens){var scratch="";window.ABCJS.parse.each(tokens,function(tok){scratch+=tok.token});var num=parseFloat(scratch);return isNaN(num)||0===num?'Directive "'+cmd+'" requires a number as a parameter.':void(tune.formatting.scale=num)},getRequiredMeasurement=function(cmd,tokens){var points=tokenizer.getMeasurement(tokens);return 0===points.used||0!==tokens.length?{error:'Directive "'+cmd+'" requires a measurement as a parameter.'}:points.value},oneParameterMeasurement=function(cmd,tokens){var points=tokenizer.getMeasurement(tokens);return 0===points.used||0!==tokens.length?'Directive "'+cmd+'" requires a measurement as a parameter.':(tune.formatting[cmd]=points.value,null)},addMultilineVar=function(key,cmd,tokens,min,max){if(1!==tokens.length||"number"!==tokens[0].type)return'Directive "'+cmd+'" requires a number as a parameter.';var i=tokens[0].intt;return void 0!==min&&imax?'Directive "'+cmd+'" requires a number less than or equal to '+max+" as a parameter.":(multilineVars[key]=i,null)},addMultilineVarBool=function(key,cmd,tokens){var str=addMultilineVar(key,cmd,tokens,0,1);return null!==str?str:(multilineVars[key]=1===multilineVars[key],null)},addMultilineVarOneParamChoice=function(key,cmd,tokens,choices){if(1!==tokens.length)return'Directive "'+cmd+'" requires one of [ '+choices.join(", ")+" ] as a parameter.";for(var choice=tokens[0].token,found=!1,i=0;!found&&i=0)0!==midi.length&&warn("Unexpected parameter in MIDI "+midi_cmd,restOfString,0);else if(midiCmdParam1String.indexOf(midi_cmd)>=0)1!==midi.length?warn("Expected one parameter in MIDI "+midi_cmd,restOfString,0):midi_params.push(midi[0].token);else if(midiCmdParam1Integer.indexOf(midi_cmd)>=0)1!==midi.length?warn("Expected one parameter in MIDI "+midi_cmd,restOfString,0):"number"!==midi[0].type?warn("Expected one integer parameter in MIDI "+midi_cmd,restOfString,0):midi_params.push(midi[0].intt);else if(midiCmdParam1Integer1OptionalInteger.indexOf(midi_cmd)>=0)1!==midi.length&&2!==midi.length?warn("Expected one or two parameters in MIDI "+midi_cmd,restOfString,0):"number"!==midi[0].type?warn("Expected integer parameter in MIDI "+midi_cmd,restOfString,0):2===midi.length&&"number"!==midi[1].type?warn("Expected integer parameter in MIDI "+midi_cmd,restOfString,0):(midi_params.push(midi[0].intt),2===midi.length&&midi_params.push(midi[1].intt));else if(midiCmdParam2Integer.indexOf(midi_cmd)>=0)2!==midi.length?warn("Expected two parameters in MIDI "+midi_cmd,restOfString,0):"number"!==midi[0].type||"number"!==midi[1].type?warn("Expected two integer parameters in MIDI "+midi_cmd,restOfString,0):(midi_params.push(midi[0].intt),midi_params.push(midi[1].intt));else if(midiCmdParam1String1Integer.indexOf(midi_cmd)>=0)2!==midi.length?warn("Expected two parameters in MIDI "+midi_cmd,restOfString,0):"alpha"!==midi[0].type||"number"!==midi[1].type?warn("Expected one string and one integer parameters in MIDI "+midi_cmd,restOfString,0):(midi_params.push(midi[0].token),midi_params.push(midi[1].intt));else if(midiCmdParamFraction.indexOf(midi_cmd)>=0)3!==midi.length?warn("Expected fraction parameter in MIDI "+midi_cmd,restOfString,0):"number"!==midi[0].type||"/"!==midi[1].token||"number"!==midi[2].type?warn("Expected fraction parameter in MIDI "+midi_cmd,restOfString,0):(midi_params.push(midi[0].intt),midi_params.push(midi[2].intt));else if(midiCmdParam4Integer.indexOf(midi_cmd)>=0)4!==midi.length?warn("Expected four parameters in MIDI "+midi_cmd,restOfString,0):"number"!==midi[0].type||"number"!==midi[1].type||"number"!==midi[2].type||"number"!==midi[3].type?warn("Expected four integer parameters in MIDI "+midi_cmd,restOfString,0):(midi_params.push(midi[0].intt),midi_params.push(midi[1].intt),midi_params.push(midi[2].intt),midi_params.push(midi[3].intt));else if(midiCmdParam5Integer.indexOf(midi_cmd)>=0)5!==midi.length?warn("Expected five parameters in MIDI "+midi_cmd,restOfString,0):"number"!==midi[0].type||"number"!==midi[1].type||"number"!==midi[2].type||"number"!==midi[3].type||"number"!==midi[4].type?warn("Expected five integer parameters in MIDI "+midi_cmd,restOfString,0):(midi_params.push(midi[0].intt),midi_params.push(midi[1].intt),midi_params.push(midi[2].intt),midi_params.push(midi[3].intt),midi_params.push(midi[4].intt));else if(midiCmdParam1Integer1OptionalInteger.indexOf(midi_cmd)>=0)1!==midi.length||4!==midi.length?warn("Expected one or two parameters in MIDI "+midi_cmd,restOfString,0):"number"!==midi[0].type?warn("Expected integer parameter in MIDI "+midi_cmd,restOfString,0):4===midi.length?("octave"!==midi[1].token&&warn("Expected octave parameter in MIDI "+midi_cmd,restOfString,0),"="!==midi[2].token&&warn("Expected octave parameter in MIDI "+midi_cmd,restOfString,0),"number"!==midi[3].type&&warn("Expected integer parameter for octave in MIDI "+midi_cmd,restOfString,0)):(midi_params.push(midi[0].intt),4===midi.length&&midi_params.push(midi[3].intt));else if(midiCmdParam1StringVariableIntegers.indexOf(midi_cmd)>=0)if(midi.length<2)warn("Expected string parameter and at least one integer parameter in MIDI "+midi_cmd,restOfString,0);else if("alpha"!==midi[0].type)warn("Expected string parameter and at least one integer parameter in MIDI "+midi_cmd,restOfString,0);else{var p=midi.shift();for(midi_params.push(p.token);midi.length>0;)p=midi.shift(),"number"!==p.type&&warn("Expected integer parameter in MIDI "+midi_cmd,restOfString,0),midi_params.push(p.intt)}tune.hasBeginMusic()?tune.appendElement("midi",-1,-1,{cmd:midi_cmd,params:midi_params}):(void 0===tune.formatting.midi&&(tune.formatting.midi={}),tune.formatting.midi[midi_cmd]=midi_params)};window.ABCJS.parse.parseDirective.parseFontChangeLine=function(textstr){var textParts=textstr.split("$");if(textParts.length>1&&multilineVars.setfont){for(var textarr=[{text:textParts[0]}],i=1;i1)return textarr}return textstr};var positionChoices=["auto","above","below","hidden"];window.ABCJS.parse.parseDirective.addDirective=function(str){var tokens=tokenizer.tokenize(str,0,str.length);if(0===tokens.length||"alpha"!==tokens[0].type)return null;var restOfString=str.substring(str.indexOf(tokens[0].token)+tokens[0].token.length);restOfString=tokenizer.stripComment(restOfString);var cmd=tokens.shift().token.toLowerCase(),scratch="";switch(cmd){case"bagpipes":tune.formatting.bagpipes=!0;break;case"landscape":multilineVars.landscape=!0;break;case"papersize":multilineVars.papersize=restOfString;break;case"slurgraces":tune.formatting.slurgraces=!0;break;case"stretchlast":tune.formatting.stretchlast=!0;break;case"titlecaps":multilineVars.titlecaps=!0;break;case"titleleft":tune.formatting.titleleft=!0;break;case"measurebox":tune.formatting.measurebox=!0;break;case"vocal":return addMultilineVarOneParamChoice("vocalPosition",cmd,tokens,positionChoices);case"dynamic":return addMultilineVarOneParamChoice("dynamicPosition",cmd,tokens,positionChoices);case"gchord":return addMultilineVarOneParamChoice("chordPosition",cmd,tokens,positionChoices);case"ornament":return addMultilineVarOneParamChoice("ornamentPosition",cmd,tokens,positionChoices);case"volume":return addMultilineVarOneParamChoice("volumePosition",cmd,tokens,positionChoices);case"botmargin":case"botspace":case"composerspace":case"indent":case"leftmargin":case"linesep":case"musicspace":case"partsspace":case"pageheight":case"pagewidth":case"rightmargin":case"staffsep":case"staffwidth":case"subtitlespace":case"sysstaffsep":case"systemsep":case"textspace":case"titlespace":case"topmargin":case"topspace":case"vocalspace":case"wordsspace":return oneParameterMeasurement(cmd,tokens);case"vskip":var vskip=getRequiredMeasurement(cmd,tokens);return vskip.error?vskip.error:(tune.addSpacing(vskip),null);case"scale":setScale(cmd,tokens);break;case"sep":if(0===tokens.length)tune.addSeparator();else{var points=tokenizer.getMeasurement(tokens);if(0===points.used)return'Directive "'+cmd+'" requires 3 numbers: space above, space below, length of line';var spaceAbove=points.value;if(points=tokenizer.getMeasurement(tokens),0===points.used)return'Directive "'+cmd+'" requires 3 numbers: space above, space below, length of line';var spaceBelow=points.value;if(points=tokenizer.getMeasurement(tokens),0===points.used||0!==tokens.length)return'Directive "'+cmd+'" requires 3 numbers: space above, space below, length of line';var lenLine=points.value;tune.addSeparator(spaceAbove,spaceBelow,lenLine)}break;case"barsperstaff":if(scratch=addMultilineVar("barsperstaff",cmd,tokens),null!==scratch)return scratch;break;case"staffnonote":if(scratch=addMultilineVarBool("staffnonote",cmd,tokens),null!==scratch)return scratch;break;case"printtempo":if(scratch=addMultilineVarBool("printTempo",cmd,tokens),null!==scratch)return scratch;break;case"partsbox":if(scratch=addMultilineVarBool("partsBox",cmd,tokens),null!==scratch)return scratch;break;case"measurenb":case"barnumbers":if(scratch=addMultilineVar("barNumbers",cmd,tokens),null!==scratch)return scratch;break;case"begintext":multilineVars.inTextBlock=!0;break;case"continueall":multilineVars.continueall=!0;break;case"beginps":multilineVars.inPsBlock=!0,warn("Postscript ignored",str,0);break;case"deco":restOfString.length>0&&multilineVars.ignoredDecorations.push(restOfString.substring(0,restOfString.indexOf(" "))),warn("Decoration redefinition ignored",str,0);break;case"text":var textstr=tokenizer.translateString(restOfString);tune.addText(window.ABCJS.parse.parseDirective.parseFontChangeLine(textstr));break;case"center":var centerstr=tokenizer.translateString(restOfString);tune.addCentered(window.ABCJS.parse.parseDirective.parseFontChangeLine(centerstr));break;case"font":break;case"setfont":var sfTokens=tokenizer.tokenize(restOfString,0,restOfString.length);if(sfTokens.length>=4&&"-"===sfTokens[0].token&&"number"===sfTokens[1].type){var sfNum=parseInt(sfTokens[1].token);sfNum>=1&&sfNum<=4&&(multilineVars.setfont||(multilineVars.setfont=[]),sfTokens.shift(),sfTokens.shift(),multilineVars.setfont[sfNum]=getFontParameter(sfTokens,multilineVars.setfont[sfNum],str,0,"setfont"))}break;case"gchordfont":case"partsfont":case"vocalfont":case"textfont":case"annotationfont":case"historyfont":case"infofont":case"measurefont":case"repeatfont":case"wordsfont":return getChangingFont(cmd,tokens,str);case"composerfont":case"subtitlefont":case"tempofont":case"titlefont":case"voicefont":case"footerfont":case"headerfont":return getGlobalFont(cmd,tokens,str);case"barlabelfont":case"barnumberfont":case"barnumfont":return getChangingFont("measurefont",tokens,str);case"staves":case"score":multilineVars.score_is_present=!0;for(var lastVoice,addVoice=function(id,newStaff,bracket,brace,continueBar){(newStaff||0===multilineVars.staves.length)&&multilineVars.staves.push({index:multilineVars.staves.length,numVoices:0});var staff=window.ABCJS.parse.last(multilineVars.staves);void 0!==bracket&&(staff.bracket=bracket),void 0!==brace&&(staff.brace=brace),continueBar&&(staff.connectBarLines="end"),void 0===multilineVars.voices[id]&&(multilineVars.voices[id]={staffNum:staff.index,index:staff.numVoices},staff.numVoices++)},openParen=!1,openBracket=!1,openBrace=!1,justOpenParen=!1,justOpenBracket=!1,justOpenBrace=!1,continueBar=!1,addContinueBar=function(){if(continueBar=!0,lastVoice){var ty="start";lastVoice.staffNum>0&&("start"!==multilineVars.staves[lastVoice.staffNum-1].connectBarLines&&"continue"!==multilineVars.staves[lastVoice.staffNum-1].connectBarLines||(ty="continue")),multilineVars.staves[lastVoice.staffNum].connectBarLines=ty}};tokens.length;){var t=tokens.shift();switch(t.token){case"(":openParen?warn("Can't nest parenthesis in %%score",str,t.start):(openParen=!0,justOpenParen=!0);break;case")":!openParen||justOpenParen?warn("Unexpected close parenthesis in %%score",str,t.start):openParen=!1;break;case"[":openBracket?warn("Can't nest brackets in %%score",str,t.start):(openBracket=!0,justOpenBracket=!0);break;case"]":!openBracket||justOpenBracket?warn("Unexpected close bracket in %%score",str,t.start):(openBracket=!1,multilineVars.staves[lastVoice.staffNum].bracket="end");break;case"{":openBrace?warn("Can't nest braces in %%score",str,t.start):(openBrace=!0,justOpenBrace=!0);break;case"}":!openBrace||justOpenBrace?warn("Unexpected close brace in %%score",str,t.start):(openBrace=!1,multilineVars.staves[lastVoice.staffNum].brace="end");break;case"|":addContinueBar();break;default:for(var vc="";("alpha"===t.type||"number"===t.type)&&(vc+=t.token,t.continueId);)t=tokens.shift();var newStaff=!openParen||justOpenParen,bracket=justOpenBracket?"start":openBracket?"continue":void 0,brace=justOpenBrace?"start":openBrace?"continue":void 0;addVoice(vc,newStaff,bracket,brace,continueBar),justOpenParen=!1,justOpenBracket=!1,justOpenBrace=!1,continueBar=!1,lastVoice=multilineVars.voices[vc],"staves"===cmd&&addContinueBar()}}break;case"newpage":var pgNum=tokenizer.getInt(restOfString);tune.addNewPage(0===pgNum.digits?-1:pgNum.value);break;case"abc":var arr=restOfString.split(" ");switch(arr[0]){case"-copyright":case"-creator":case"-edited-by":case"-version":case"-charset":var subCmd=arr.shift();tune.addMetaText(cmd+subCmd,arr.join(" "));break;default:return"Unknown directive: "+cmd+arr[0]}break;case"header":case"footer":var footerStr=tokenizer.getMeat(restOfString,0,restOfString.length);footerStr=restOfString.substring(footerStr.start,footerStr.end),'"'===footerStr.charAt(0)&&'"'===footerStr.charAt(footerStr.length-1)&&(footerStr=footerStr.substring(1,footerStr.length-1));var footerArr=footerStr.split("\t"),footer={};footer=1===footerArr.length?{left:"",center:footerArr[0],right:""}:2===footerArr.length?{left:footerArr[0],center:footerArr[1],right:""}:{left:footerArr[0],center:footerArr[1],right:footerArr[2]},footerArr.length>3&&warn("Too many tabs in "+cmd+": "+footerArr.length+" found.",restOfString,0),tune.addMetaTextObj(cmd,footer);break;case"midi":var midi=tokenizer.tokenize(restOfString,0,restOfString.length,!0);midi.length>0&&"="===midi[0].token&&midi.shift(),0===midi.length?warn("Expected midi command",restOfString,0):parseMidiCommand(midi,tune,restOfString);break;case"playtempo":case"auquality":case"continuous":case"nobarcheck":tune.formatting[cmd]=restOfString;break;default:return"Unknown directive: "+cmd}return null},window.ABCJS.parse.parseDirective.globalFormatting=function(formatHash){for(var cmd in formatHash)if(formatHash.hasOwnProperty(cmd)){var scratch,value=""+formatHash[cmd],tokens=tokenizer.tokenize(value,0,value.length);switch(cmd){case"titlefont":case"gchordfont":getChangingFont(cmd,tokens,value);break;case"scale":setScale(cmd,tokens);break;case"partsbox":scratch=addMultilineVarBool("partsBox",cmd,tokens),null!==scratch&&warn(scratch);break;default:warn("Formatting directive unrecognized: ",cmd,0)}}}}(),window.ABCJS||(window.ABCJS={}),window.ABCJS.parse||(window.ABCJS.parse={}),window.ABCJS.parse.ParseHeader=function(tokenizer,warn,multilineVars,tune){this.reset=function(tokenizer,warn,multilineVars,tune){window.ABCJS.parse.parseKeyVoice.initialize(tokenizer,warn,multilineVars,tune),window.ABCJS.parse.parseDirective.initialize(tokenizer,warn,multilineVars,tune)},this.reset(tokenizer,warn,multilineVars,tune),this.setTitle=function(title){if(multilineVars.hasMainTitle)tune.addSubtitle(tokenizer.translateString(tokenizer.stripComment(title)));else{var titleStr=tokenizer.translateString(tokenizer.theReverser(tokenizer.stripComment(title)));multilineVars.titlecaps&&(titleStr=titleStr.toUpperCase()),tune.addMetaText("title",titleStr),multilineVars.hasMainTitle=!0}},this.setMeter=function(line){if(line=tokenizer.stripComment(line),"C"===line)return multilineVars.havent_set_length===!0&&(multilineVars.default_length=.125,multilineVars.havent_set_length=!1),{type:"common_time"};if("C|"===line)return multilineVars.havent_set_length===!0&&(multilineVars.default_length=.125,multilineVars.havent_set_length=!1),{type:"cut_time"};if("o"===line)return multilineVars.havent_set_length===!0&&(multilineVars.default_length=.125,multilineVars.havent_set_length=!1),{type:"tempus_perfectum"};if("c"===line)return multilineVars.havent_set_length===!0&&(multilineVars.default_length=.125,multilineVars.havent_set_length=!1),{type:"tempus_imperfectum"};if("o."===line)return multilineVars.havent_set_length===!0&&(multilineVars.default_length=.125,multilineVars.havent_set_length=!1),{type:"tempus_perfectum_prolatio"};if("c."===line)return multilineVars.havent_set_length===!0&&(multilineVars.default_length=.125,multilineVars.havent_set_length=!1),{type:"tempus_imperfectum_prolatio"};if(0===line.length||"none"===line.toLowerCase())return multilineVars.havent_set_length===!0&&(multilineVars.default_length=.125,multilineVars.havent_set_length=!1),null;var tokens=tokenizer.tokenize(line,0,line.length);try{var parseNum=function(){var ret={value:0,num:""},tok=tokens.shift();for("("===tok.token&&(tok=tokens.shift());;){if("number"!==tok.type)throw"Expected top number of meter";if(ret.value+=parseInt(tok.token),ret.num+=tok.token,0===tokens.length||"/"===tokens[0].token)return ret;if(tok=tokens.shift(),")"===tok.token){if(0===tokens.length||"/"===tokens[0].token)return ret;throw"Unexpected paren in meter"}if("."!==tok.token&&"+"!==tok.token)throw"Expected top number of meter";if(ret.num+=tok.token,0===tokens.length)throw"Expected top number of meter";tok=tokens.shift()}return ret},parseFraction=function(){var ret=parseNum();if(0===tokens.length)return ret;var tok=tokens.shift();if("/"!==tok.token)throw"Expected slash in meter";if(tok=tokens.shift(),"number"!==tok.type)throw"Expected bottom number of meter";return ret.den=tok.token,ret.value=ret.value/parseInt(ret.den),ret};if(0===tokens.length)throw"Expected meter definition in M: line";for(var meter={type:"specified",value:[]},totalLength=0;;){var ret=parseFraction();totalLength+=ret.value;var mv={num:ret.num};if(void 0!==ret.den&&(mv.den=ret.den),meter.value.push(mv),0===tokens.length)break}return multilineVars.havent_set_length===!0&&(multilineVars.default_length=totalLength<.75?.0625:.125,multilineVars.havent_set_length=!1),meter}catch(e){warn(e,line,0)}return null},this.calcTempo=function(relTempo){var dur=.25;multilineVars.meter&&"specified"===multilineVars.meter.type?dur=1/parseInt(multilineVars.meter.value[0].den):multilineVars.origMeter&&"specified"===multilineVars.origMeter.type&&(dur=1/parseInt(multilineVars.origMeter.value[0].den));for(var i=0;i0&&(multilineVars.default_length=n/d,multilineVars.havent_set_length=!1)}else 1===len_arr.length&&"1"===len_arr[0]&&(multilineVars.default_length=1,multilineVars.havent_set_length=!1)},this.setTempo=function(line,start,end){try{var tokens=tokenizer.tokenize(line,start,end);if(0===tokens.length)throw"Missing parameter in Q: field";var tempo={},delaySet=!0,token=tokens.shift();if("quote"===token.type&&(tempo.preString=token.token,token=tokens.shift(),0===tokens.length))return{type:"immediate",tempo:tempo};if("alpha"===token.type&&"C"===token.token){if(0===tokens.length)throw"Missing tempo after C in Q: field";if(token=tokens.shift(),"punct"===token.type&&"="===token.token){if(0===tokens.length)throw"Missing tempo after = in Q: field";if(token=tokens.shift(),"number"!==token.type)throw"Expected number after = in Q: field";tempo.duration=[1],tempo.bpm=parseInt(token.token)}else{if("number"!==token.type)throw"Expected number or equal after C in Q: field";if(tempo.duration=[parseInt(token.token)],0===tokens.length)throw"Missing = after duration in Q: field";if(token=tokens.shift(),"punct"!==token.type||"="!==token.token)throw"Expected = after duration in Q: field";if(0===tokens.length)throw"Missing tempo after = in Q: field";if(token=tokens.shift(),"number"!==token.type)throw"Expected number after = in Q: field";tempo.bpm=parseInt(token.token)}}else{if("number"!==token.type)throw"Unknown value in Q: field";var num=parseInt(token.token);if(0===tokens.length||"quote"===tokens[0].type)tempo.duration=[1],tempo.bpm=num;else{if(delaySet=!1,token=tokens.shift(),"punct"!==token.type&&"/"!==token.token)throw"Expected fraction in Q: field"; if(token=tokens.shift(),"number"!==token.type)throw"Expected fraction in Q: field";var den=parseInt(token.token);for(tempo.duration=[num/den];tokens.length>0&&"="!==tokens[0].token&&"quote"!==tokens[0].type;){if(token=tokens.shift(),"number"!==token.type)throw"Expected fraction in Q: field";if(num=parseInt(token.token),token=tokens.shift(),"punct"!==token.type&&"/"!==token.token)throw"Expected fraction in Q: field";if(token=tokens.shift(),"number"!==token.type)throw"Expected fraction in Q: field";den=parseInt(token.token),tempo.duration.push(num/den)}if(token=tokens.shift(),"punct"!==token.type&&"="!==token.token)throw"Expected = in Q: field";if(token=tokens.shift(),"number"!==token.type)throw"Expected tempo in Q: field";tempo.bpm=parseInt(token.token)}}if(0!==tokens.length&&(token=tokens.shift(),"quote"===token.type&&(tempo.postString=token.token,token=tokens.shift()),0!==tokens.length))throw"Unexpected string at end of Q: field";return multilineVars.printTempo===!1&&(tempo.suppress=!0),{type:delaySet?"delaySet":"immediate",tempo:tempo}}catch(msg){return warn(msg,line,start),{type:"none"}}},this.letter_to_inline_header=function(line,i){var ws=tokenizer.eatWhiteSpace(line,i);if(i+=ws,line.length>=i+5&&"["===line.charAt(i)&&":"===line.charAt(i+2)){var e=line.indexOf("]",i);switch(line.substring(i,i+3)){case"[I:":var err=window.ABCJS.parse.parseDirective.addDirective(line.substring(i+3,e));return err&&warn(err,line,i),[e-i+1+ws];case"[M:":var meter=this.setMeter(line.substring(i+3,e));return tune.hasBeginMusic()&&meter?tune.appendStartingElement("meter",-1,-1,meter):multilineVars.meter=meter,[e-i+1+ws];case"[K:":var result=window.ABCJS.parse.parseKeyVoice.parseKey(line.substring(i+3,e));return result.foundClef&&tune.hasBeginMusic()&&tune.appendStartingElement("clef",-1,-1,multilineVars.clef),result.foundKey&&tune.hasBeginMusic()&&tune.appendStartingElement("key",-1,-1,window.ABCJS.parse.parseKeyVoice.fixKey(multilineVars.clef,multilineVars.key)),[e-i+1+ws];case"[P:":return tune.lines.length<=tune.lineNum?multilineVars.partForNextLine=line.substring(i+3,e):tune.appendElement("part",-1,-1,{title:line.substring(i+3,e)}),[e-i+1+ws];case"[L:":return this.setDefaultLength(line,i+3,e),[e-i+1+ws];case"[Q:":if(e>0){var tempo=this.setTempo(line,i+3,e);return"delaySet"===tempo.type?tune.appendElement("tempo",-1,-1,this.calcTempo(tempo.tempo)):"immediate"===tempo.type&&tune.appendElement("tempo",-1,-1,tempo.tempo),[e-i+1+ws,line.charAt(i+1),line.substring(i+3,e)]}break;case"[V:":if(e>0)return window.ABCJS.parse.parseKeyVoice.parseVoice(line,i+3,e),[e-i+1+ws,line.charAt(i+1),line.substring(i+3,e)]}}return[0]},this.letter_to_body_header=function(line,i){if(line.length>=i+3)switch(line.substring(i,i+2)){case"I:":var err=window.ABCJS.parse.parseDirective.addDirective(line.substring(i+2));return err&&warn(err,line,i),[line.length];case"M:":var meter=this.setMeter(line.substring(i+2));return tune.hasBeginMusic()&&meter&&tune.appendStartingElement("meter",-1,-1,meter),[line.length];case"K:":var result=window.ABCJS.parse.parseKeyVoice.parseKey(line.substring(i+2));return result.foundClef&&tune.hasBeginMusic()&&tune.appendStartingElement("clef",-1,-1,multilineVars.clef),result.foundKey&&tune.hasBeginMusic()&&tune.appendStartingElement("key",-1,-1,window.ABCJS.parse.parseKeyVoice.fixKey(multilineVars.clef,multilineVars.key)),[line.length];case"P:":return tune.hasBeginMusic()&&tune.appendElement("part",-1,-1,{title:line.substring(i+2)}),[line.length];case"L:":return this.setDefaultLength(line,i+2,line.length),[line.length];case"Q:":var e=line.indexOf("",i+2);e===-1&&(e=line.length);var tempo=this.setTempo(line,i+2,e);return"delaySet"===tempo.type?tune.appendElement("tempo",-1,-1,this.calcTempo(tempo.tempo)):"immediate"===tempo.type&&tune.appendElement("tempo",-1,-1,tempo.tempo),[e,line.charAt(i),window.ABCJS.parse.strip(line.substring(i+2))];case"V:":return window.ABCJS.parse.parseKeyVoice.parseVoice(line,2,line.length),[line.length,line.charAt(i),window.ABCJS.parse.strip(line.substring(i+2))]}return[0]};var metaTextHeaders={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(line){if(window.ABCJS.parse.startsWith(line,"%%")){var err=window.ABCJS.parse.parseDirective.addDirective(line.substring(2));return err&&warn(err,line,2),{}}var i=line.indexOf("%");if(i>=0&&(line=line.substring(0,i)),line=line.replace(/\s+$/,""),0===line.length)return{};if(line.length>=2&&":"===line.charAt(1)){var nextLine="";line.indexOf("")>=0&&"w"!==line.charAt(0)&&(nextLine=line.substring(line.indexOf("")+1),line=line.substring(0,line.indexOf("")));var field=metaTextHeaders[line.charAt(0)];if(void 0!==field)return"unalignedWords"===field?tune.addMetaTextArray(field,window.ABCJS.parse.parseDirective.parseFontChangeLine(tokenizer.translateString(tokenizer.stripComment(line.substring(2))))):tune.addMetaText(field,tokenizer.translateString(tokenizer.stripComment(line.substring(2)))),{};switch(line.charAt(0)){case"H":tune.addMetaText("history",tokenizer.translateString(tokenizer.stripComment(line.substring(2)))),multilineVars.is_in_history=!0;break;case"K":this.resolveTempo();var result=window.ABCJS.parse.parseKeyVoice.parseKey(line.substring(2));!multilineVars.is_in_header&&tune.hasBeginMusic()&&(result.foundClef&&tune.appendStartingElement("clef",-1,-1,multilineVars.clef),result.foundKey&&tune.appendStartingElement("key",-1,-1,window.ABCJS.parse.parseKeyVoice.fixKey(multilineVars.clef,multilineVars.key))),multilineVars.is_in_header=!1;break;case"L":this.setDefaultLength(line,2,line.length);break;case"M":multilineVars.origMeter=multilineVars.meter=this.setMeter(line.substring(2));break;case"P":multilineVars.is_in_header?tune.addMetaText("partOrder",tokenizer.translateString(tokenizer.stripComment(line.substring(2)))):multilineVars.partForNextLine=tokenizer.translateString(tokenizer.stripComment(line.substring(2)));break;case"Q":var tempo=this.setTempo(line,2,line.length);"delaySet"===tempo.type?multilineVars.tempo=tempo.tempo:"immediate"===tempo.type&&(tune.metaText.tempo=tempo.tempo);break;case"T":this.setTitle(line.substring(2));break;case"U":this.addUserDefinition(line,2,line.length);break;case"V":if(window.ABCJS.parse.parseKeyVoice.parseVoice(line,2,line.length),!multilineVars.is_in_header)return{newline:!0};break;case"s":return{symbols:!0};case"w":return{words:!0};case"X":break;case"E":case"m":warn("Ignored header",line,0);break;default:return nextLine.length&&(nextLine=""+nextLine),{regular:!0,str:line+nextLine}}return nextLine.length>0?{recurse:!0,str:nextLine}:{}}return{regular:!0,str:line}}},window.ABCJS||(window.ABCJS={}),window.ABCJS.parse||(window.ABCJS.parse={}),window.ABCJS.parse.parseKeyVoice={},function(){var tokenizer,warn,multilineVars,tune;window.ABCJS.parse.parseKeyVoice.initialize=function(tokenizer_,warn_,multilineVars_,tune_){tokenizer=tokenizer_,warn=warn_,multilineVars=multilineVars_,tune=tune_},window.ABCJS.parse.parseKeyVoice.standardKey=function(keyName){var key1sharp={acc:"sharp",note:"f"},key2sharp={acc:"sharp",note:"c"},key3sharp={acc:"sharp",note:"g"},key4sharp={acc:"sharp",note:"d"},key5sharp={acc:"sharp",note:"A"},key6sharp={acc:"sharp",note:"e"},key7sharp={acc:"sharp",note:"B"},key1flat={acc:"flat",note:"B"},key2flat={acc:"flat",note:"e"},key3flat={acc:"flat",note:"A"},key4flat={acc:"flat",note:"d"},key5flat={acc:"flat",note:"G"},key6flat={acc:"flat",note:"c"},key7flat={acc:"flat",note:"F"},keys={"C#":[key1sharp,key2sharp,key3sharp,key4sharp,key5sharp,key6sharp,key7sharp],"A#m":[key1sharp,key2sharp,key3sharp,key4sharp,key5sharp,key6sharp,key7sharp],"G#Mix":[key1sharp,key2sharp,key3sharp,key4sharp,key5sharp,key6sharp,key7sharp],"D#Dor":[key1sharp,key2sharp,key3sharp,key4sharp,key5sharp,key6sharp,key7sharp],"E#Phr":[key1sharp,key2sharp,key3sharp,key4sharp,key5sharp,key6sharp,key7sharp],"F#Lyd":[key1sharp,key2sharp,key3sharp,key4sharp,key5sharp,key6sharp,key7sharp],"B#Loc":[key1sharp,key2sharp,key3sharp,key4sharp,key5sharp,key6sharp,key7sharp],"F#":[key1sharp,key2sharp,key3sharp,key4sharp,key5sharp,key6sharp],"D#m":[key1sharp,key2sharp,key3sharp,key4sharp,key5sharp,key6sharp],"C#Mix":[key1sharp,key2sharp,key3sharp,key4sharp,key5sharp,key6sharp],"G#Dor":[key1sharp,key2sharp,key3sharp,key4sharp,key5sharp,key6sharp],"A#Phr":[key1sharp,key2sharp,key3sharp,key4sharp,key5sharp,key6sharp],BLyd:[key1sharp,key2sharp,key3sharp,key4sharp,key5sharp,key6sharp],"E#Loc":[key1sharp,key2sharp,key3sharp,key4sharp,key5sharp,key6sharp],B:[key1sharp,key2sharp,key3sharp,key4sharp,key5sharp],"G#m":[key1sharp,key2sharp,key3sharp,key4sharp,key5sharp],"F#Mix":[key1sharp,key2sharp,key3sharp,key4sharp,key5sharp],"C#Dor":[key1sharp,key2sharp,key3sharp,key4sharp,key5sharp],"D#Phr":[key1sharp,key2sharp,key3sharp,key4sharp,key5sharp],ELyd:[key1sharp,key2sharp,key3sharp,key4sharp,key5sharp],"A#Loc":[key1sharp,key2sharp,key3sharp,key4sharp,key5sharp],E:[key1sharp,key2sharp,key3sharp,key4sharp],"C#m":[key1sharp,key2sharp,key3sharp,key4sharp],BMix:[key1sharp,key2sharp,key3sharp,key4sharp],"F#Dor":[key1sharp,key2sharp,key3sharp,key4sharp],"G#Phr":[key1sharp,key2sharp,key3sharp,key4sharp],ALyd:[key1sharp,key2sharp,key3sharp,key4sharp],"D#Loc":[key1sharp,key2sharp,key3sharp,key4sharp],A:[key1sharp,key2sharp,key3sharp],"F#m":[key1sharp,key2sharp,key3sharp],EMix:[key1sharp,key2sharp,key3sharp],BDor:[key1sharp,key2sharp,key3sharp],"C#Phr":[key1sharp,key2sharp,key3sharp],DLyd:[key1sharp,key2sharp,key3sharp],"G#Loc":[key1sharp,key2sharp,key3sharp],D:[key1sharp,key2sharp],Bm:[key1sharp,key2sharp],AMix:[key1sharp,key2sharp],EDor:[key1sharp,key2sharp],"F#Phr":[key1sharp,key2sharp],GLyd:[key1sharp,key2sharp],"C#Loc":[key1sharp,key2sharp],G:[key1sharp],Em:[key1sharp],DMix:[key1sharp],ADor:[key1sharp],BPhr:[key1sharp],CLyd:[key1sharp],"F#Loc":[key1sharp],C:[],Am:[],GMix:[],DDor:[],EPhr:[],FLyd:[],BLoc:[],F:[key1flat],Dm:[key1flat],CMix:[key1flat],GDor:[key1flat],APhr:[key1flat],BbLyd:[key1flat],ELoc:[key1flat],Bb:[key1flat,key2flat],Gm:[key1flat,key2flat],FMix:[key1flat,key2flat],CDor:[key1flat,key2flat],DPhr:[key1flat,key2flat],EbLyd:[key1flat,key2flat],ALoc:[key1flat,key2flat],Eb:[key1flat,key2flat,key3flat],Cm:[key1flat,key2flat,key3flat],BbMix:[key1flat,key2flat,key3flat],FDor:[key1flat,key2flat,key3flat],GPhr:[key1flat,key2flat,key3flat],AbLyd:[key1flat,key2flat,key3flat],DLoc:[key1flat,key2flat,key3flat],Ab:[key1flat,key2flat,key3flat,key4flat],Fm:[key1flat,key2flat,key3flat,key4flat],EbMix:[key1flat,key2flat,key3flat,key4flat],BbDor:[key1flat,key2flat,key3flat,key4flat],CPhr:[key1flat,key2flat,key3flat,key4flat],DbLyd:[key1flat,key2flat,key3flat,key4flat],GLoc:[key1flat,key2flat,key3flat,key4flat],Db:[key1flat,key2flat,key3flat,key4flat,key5flat],Bbm:[key1flat,key2flat,key3flat,key4flat,key5flat],AbMix:[key1flat,key2flat,key3flat,key4flat,key5flat],EbDor:[key1flat,key2flat,key3flat,key4flat,key5flat],FPhr:[key1flat,key2flat,key3flat,key4flat,key5flat],GbLyd:[key1flat,key2flat,key3flat,key4flat,key5flat],CLoc:[key1flat,key2flat,key3flat,key4flat,key5flat],Gb:[key1flat,key2flat,key3flat,key4flat,key5flat,key6flat],Ebm:[key1flat,key2flat,key3flat,key4flat,key5flat,key6flat],DbMix:[key1flat,key2flat,key3flat,key4flat,key5flat,key6flat],AbDor:[key1flat,key2flat,key3flat,key4flat,key5flat,key6flat],BbPhr:[key1flat,key2flat,key3flat,key4flat,key5flat,key6flat],CbLyd:[key1flat,key2flat,key3flat,key4flat,key5flat,key6flat],FLoc:[key1flat,key2flat,key3flat,key4flat,key5flat,key6flat],Cb:[key1flat,key2flat,key3flat,key4flat,key5flat,key6flat,key7flat],Abm:[key1flat,key2flat,key3flat,key4flat,key5flat,key6flat,key7flat],GbMix:[key1flat,key2flat,key3flat,key4flat,key5flat,key6flat,key7flat],DbDor:[key1flat,key2flat,key3flat,key4flat,key5flat,key6flat,key7flat],EbPhr:[key1flat,key2flat,key3flat,key4flat,key5flat,key6flat,key7flat],FbLyd:[key1flat,key2flat,key3flat,key4flat,key5flat,key6flat,key7flat],BbLoc:[key1flat,key2flat,key3flat,key4flat,key5flat,key6flat,key7flat],"A#":[key1flat,key2flat],"B#":[],"D#":[key1flat,key2flat,key3flat],"E#":[key1flat],"G#":[key1flat,key2flat,key3flat,key4flat],Gbm:[key1sharp,key2sharp,key3sharp,key4sharp,key5sharp,key6sharp,key7sharp]};return keys[keyName]};var clefLines={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},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+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}},calcMiddle=function(clef,oct){var value=clefLines[clef],mid=value?value.mid:0;return mid+oct};window.ABCJS.parse.parseKeyVoice.fixClef=function(clef){var value=clefLines[clef.type];value&&(clef.clefPos=value.pitch,clef.type=value.clef)},window.ABCJS.parse.parseKeyVoice.deepCopyKey=function(key){var ret={accidentals:[],root:key.root,acc:key.acc,mode:key.mode};return window.ABCJS.parse.each(key.accidentals,function(k){ret.accidentals.push(window.ABCJS.parse.clone(k))}),ret};var 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};window.ABCJS.parse.parseKeyVoice.addPosToKey=function(clef,key){var mid=clef.verticalPos;window.ABCJS.parse.each(key.accidentals,function(acc){var pitch=pitches[acc.note];pitch-=mid,acc.verticalPos=pitch}),key.impliedNaturals&&window.ABCJS.parse.each(key.impliedNaturals,function(acc){var pitch=pitches[acc.note];pitch-=mid,acc.verticalPos=pitch}),mid<-10?(window.ABCJS.parse.each(key.accidentals,function(acc){acc.verticalPos-=7,(acc.verticalPos>=11||10===acc.verticalPos&&"flat"===acc.acc)&&(acc.verticalPos-=7),"A"===acc.note&&"sharp"===acc.acc&&(acc.verticalPos-=7),"G"!==acc.note&&"F"!==acc.note||"flat"!==acc.acc||(acc.verticalPos-=7)}),key.impliedNaturals&&window.ABCJS.parse.each(key.impliedNaturals,function(acc){acc.verticalPos-=7,(acc.verticalPos>=11||10===acc.verticalPos&&"flat"===acc.acc)&&(acc.verticalPos-=7),"A"===acc.note&&"sharp"===acc.acc&&(acc.verticalPos-=7),"G"!==acc.note&&"F"!==acc.note||"flat"!==acc.acc||(acc.verticalPos-=7)})):mid<-4?(window.ABCJS.parse.each(key.accidentals,function(acc){acc.verticalPos-=7,mid!==-8||"f"!==acc.note&&"g"!==acc.note||"sharp"!==acc.acc||(acc.verticalPos-=7)}),key.impliedNaturals&&window.ABCJS.parse.each(key.impliedNaturals,function(acc){acc.verticalPos-=7,mid!==-8||"f"!==acc.note&&"g"!==acc.note||"sharp"!==acc.acc||(acc.verticalPos-=7)})):mid>=7&&(window.ABCJS.parse.each(key.accidentals,function(acc){acc.verticalPos+=7}),key.impliedNaturals&&window.ABCJS.parse.each(key.impliedNaturals,function(acc){acc.verticalPos+=7}))},window.ABCJS.parse.parseKeyVoice.fixKey=function(clef,key){var fixedKey=window.ABCJS.parse.clone(key);return window.ABCJS.parse.parseKeyVoice.addPosToKey(clef,fixedKey),fixedKey};var parseMiddle=function(str){for(var mid=pitches[str.charAt(0)],i=1;i0){ret.foundKey=!0;var acc="",mode="";tokens[0].token.length>1?tokens[0].token=tokens[0].token.substring(1):tokens.shift();var key=retPitch.token;if(tokens.length>0){var retAcc=tokenizer.getSharpFlat(tokens[0].token);if(retAcc.len>0&&(tokens[0].token.length>1?tokens[0].token=tokens[0].token.substring(1):tokens.shift(),key+=retAcc.token,acc=retAcc.token),tokens.length>0){var retMode=tokenizer.getMode(tokens[0].token);retMode.len>0&&(tokens.shift(),key+=retMode.token,mode=retMode.token)}if(void 0===window.ABCJS.parse.parseKeyVoice.standardKey(key))return warn("Unsupported key signature: "+key,str,0),ret}var oldKey=window.ABCJS.parse.parseKeyVoice.deepCopyKey(multilineVars.key);if(multilineVars.key=window.ABCJS.parse.parseKeyVoice.deepCopyKey({accidentals:window.ABCJS.parse.parseKeyVoice.standardKey(key)}),multilineVars.key.root=retPitch.token,multilineVars.key.acc=acc,multilineVars.key.mode=mode,oldKey){for(var kk,k=0;k0;)switch(tokens[0].token){case"m":case"middle":if(tokens.shift(),0===tokens.length)return warn("Expected = after middle",str,0),ret;if(token=tokens.shift(),"="!==token.token){warn("Expected = after middle",str,token.start);break}if(0===tokens.length)return warn("Expected parameter after middle=",str,0),ret;var pitch=tokenizer.getPitchFromTokens(tokens);pitch.warn&&warn(pitch.warn,str,0),pitch.position&&(multilineVars.clef.verticalPos=pitch.position-6);break;case"transpose":if(tokens.shift(),0===tokens.length)return warn("Expected = after transpose",str,0),ret;if(token=tokens.shift(),"="!==token.token){warn("Expected = after transpose",str,token.start);break}if(0===tokens.length)return warn("Expected parameter after transpose=",str,0),ret;if("number"!==tokens[0].type){warn("Expected number after transpose",str,tokens[0].start);break}multilineVars.clef.transpose=tokens[0].intt,tokens.shift();break;case"stafflines":if(tokens.shift(),0===tokens.length)return warn("Expected = after stafflines",str,0),ret;if(token=tokens.shift(),"="!==token.token){warn("Expected = after stafflines",str,token.start);break}if(0===tokens.length)return warn("Expected parameter after stafflines=",str,0),ret;if("number"!==tokens[0].type){warn("Expected number after stafflines",str,tokens[0].start);break}multilineVars.clef.stafflines=tokens[0].intt,tokens.shift();break;case"staffscale":if(tokens.shift(),0===tokens.length)return warn("Expected = after staffscale",str,0),ret;if(token=tokens.shift(),"="!==token.token){warn("Expected = after staffscale",str,token.start);break}if(0===tokens.length)return warn("Expected parameter after staffscale=",str,0),ret;if("number"!==tokens[0].type){warn("Expected number after staffscale",str,tokens[0].start);break}multilineVars.clef.staffscale=tokens[0].floatt,tokens.shift();break;case"style":if(tokens.shift(),0===tokens.length)return warn("Expected = after style",str,0),ret;if(token=tokens.shift(),"="!==token.token){warn("Expected = after style",str,token.start);break}if(0===tokens.length)return warn("Expected parameter after style=",str,0),ret;switch(tokens[0].token){case"normal":case"harmonic":case"rhythm":case"x":multilineVars.style=tokens[0].token,tokens.shift();break;default:warn("error parsing style element: "+tokens[0].token,str,tokens[0].start)}break;case"clef":if(tokens.shift(),0===tokens.length)return warn("Expected = after clef",str,0),ret;if(token=tokens.shift(),"="!==token.token){warn("Expected = after clef",str,token.start);break}if(0===tokens.length)return warn("Expected parameter after clef=",str,0),ret;case"treble":case"bass":case"alto":case"tenor":case"perc":var clef=tokens.shift();switch(clef.token){case"treble":case"tenor":case"alto":case"bass":case"perc":case"none":break;case"C":clef.token="alto";break;case"F":clef.token="bass";break;case"G":clef.token="treble";break;case"c":clef.token="alto";break;case"f":clef.token="bass";break;case"g":clef.token="treble";break;default:warn("Expected clef name. Found "+clef.token,str,clef.start)}tokens.length>0&&"number"===tokens[0].type&&(clef.token+=tokens[0].token,tokens.shift()),tokens.length>1&&("-"===tokens[0].token||"+"===tokens[0].token)&&"8"===tokens[1].token&&(clef.token+=tokens[0].token+tokens[1].token,tokens.shift(),tokens.shift()),multilineVars.clef={type:clef.token,verticalPos:calcMiddle(clef.token,0)},multilineVars.currentVoice&&void 0!==multilineVars.currentVoice.transpose&&(multilineVars.clef.transpose=multilineVars.currentVoice.transpose),ret.foundClef=!0;break;default:warn("Unknown parameter: "+tokens[0].token,str,tokens[0].start),tokens.shift()}return ret};var setCurrentVoice=function(id){multilineVars.currentVoice=multilineVars.voices[id],tune.setCurrentVoice(multilineVars.currentVoice.staffNum,multilineVars.currentVoice.index)};window.ABCJS.parse.parseKeyVoice.parseVoice=function(line,i,e){var ret=tokenizer.getMeat(line,i,e),start=ret.start,end=ret.end,id=tokenizer.getToken(line,start,end);if(0===id.length)return void warn("Expected a voice id",line,start);var isNew=!1;void 0===multilineVars.voices[id]&&(multilineVars.voices[id]={},isNew=!0,multilineVars.score_is_present&&warn("Can't have an unknown V: id when the %score directive is present",line,start)),start+=id.length,start+=tokenizer.eatWhiteSpace(line,start);for(var staffInfo={startStaff:isNew},addNextTokenToStaffInfo=function(name){var attr=tokenizer.getVoiceToken(line,start,end);void 0!==attr.warn?warn("Expected value for "+name+" in voice: "+attr.warn,line,start):0===attr.token.length&&'"'!==line.charAt(start)?warn("Expected value for "+name+" in voice",line,start):staffInfo[name]=attr.token,start+=attr.len},addNextTokenToVoiceInfo=function(id,name,type){var attr=tokenizer.getVoiceToken(line,start,end);void 0!==attr.warn?warn("Expected value for "+name+" in voice: "+attr.warn,line,start):0===attr.token.length&&'"'!==line.charAt(start)?warn("Expected value for "+name+" in voice",line,start):("number"===type&&(attr.token=parseFloat(attr.token)),multilineVars.voices[id][name]=attr.token),start+=attr.len};start=str.length};this.eatWhiteSpace=function(line,index){for(var i=index;i="a"&&str.charAt(start)<="z"||str.charAt(start)>="A"&&str.charAt(start)<="Z");)start++;return start},i=this.skipWhiteSpace(str);if(finished(str,i))return{len:0};var firstThree=str.substring(i,i+3).toLowerCase();switch((firstThree.length>1&&" "===firstThree.charAt(1)||"^"===firstThree.charAt(1)||"_"===firstThree.charAt(1)||"="===firstThree.charAt(1))&&(firstThree=firstThree.charAt(0)),firstThree){case"mix":return{len:skipAlpha(str,i),token:"Mix"};case"dor":return{len:skipAlpha(str,i),token:"Dor"};case"phr":return{len:skipAlpha(str,i),token:"Phr"};case"lyd":return{len:skipAlpha(str,i),token:"Lyd"};case"loc":return{len:skipAlpha(str,i),token:"Loc"};case"aeo":return{len:skipAlpha(str,i),token:"m"};case"maj":return{len:skipAlpha(str,i),token:""};case"ion":return{len:skipAlpha(str,i),token:""};case"min":return{len:skipAlpha(str,i),token:"m"};case"m":return{len:skipAlpha(str,i),token:"m"}}return{len:0}},this.getClef=function(str,bExplicitOnly){var strOrig=str,i=this.skipWhiteSpace(str);if(finished(str,i))return{len:0};var needsClef=!1,strClef=str.substring(i);if(window.ABCJS.parse.startsWith(strClef,"clef=")&&(needsClef=!0,strClef=strClef.substring(5),i+=5),0===strClef.length&&needsClef)return{len:i+5,warn:"No clef specified: "+strOrig};var j=this.skipWhiteSpace(strClef);if(finished(strClef,j))return{len:0};j>0&&(i+=j,strClef=strClef.substring(j));var name=null;if(window.ABCJS.parse.startsWith(strClef,"treble"))name="treble";else if(window.ABCJS.parse.startsWith(strClef,"bass3"))name="bass3";else if(window.ABCJS.parse.startsWith(strClef,"bass"))name="bass";else if(window.ABCJS.parse.startsWith(strClef,"tenor"))name="tenor";else if(window.ABCJS.parse.startsWith(strClef,"alto2"))name="alto2";else if(window.ABCJS.parse.startsWith(strClef,"alto1"))name="alto1";else if(window.ABCJS.parse.startsWith(strClef,"alto"))name="alto";else if(!bExplicitOnly&&needsClef&&window.ABCJS.parse.startsWith(strClef,"none"))name="none";else if(window.ABCJS.parse.startsWith(strClef,"perc"))name="perc";else if(!bExplicitOnly&&needsClef&&window.ABCJS.parse.startsWith(strClef,"C"))name="tenor";else if(!bExplicitOnly&&needsClef&&window.ABCJS.parse.startsWith(strClef,"F"))name="bass";else{if(bExplicitOnly||!needsClef||!window.ABCJS.parse.startsWith(strClef,"G"))return{len:i+5,warn:"Unknown clef specified: "+strOrig};name="treble"}return strClef=strClef.substring(name.length),j=this.isMatch(strClef,"+8"),j>0?name+="+8":(j=this.isMatch(strClef,"-8"),j>0&&(name+="-8")),{len:i+name.length,token:name,explicit:needsClef}},this.getBarLine=function(line,i){switch(line.charAt(i)){case"]":switch(++i,line.charAt(i)){case"|":return{len:2,token:"bar_thick_thin"};case"[":return++i,line.charAt(i)>="1"&&line.charAt(i)<="9"||'"'===line.charAt(i)?{len:2,token:"bar_invisible"}:{len:1,warn:"Unknown bar symbol"};default:return{len:1,token:"bar_invisible"}}break;case":":switch(++i,line.charAt(i)){case":":return{len:2,token:"bar_dbl_repeat"};case"|":switch(++i,line.charAt(i)){case"]":switch(++i,line.charAt(i)){case"|":return++i,":"===line.charAt(i)?{len:5,token:"bar_dbl_repeat"}:{len:3,token:"bar_right_repeat"};default:return{len:3,token:"bar_right_repeat"}}break;case"|":return++i,":"===line.charAt(i)?{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(++i,"|"!==line.charAt(i))return line.charAt(i)>="1"&&line.charAt(i)<="9"||'"'===line.charAt(i)?{len:1,token:"bar_invisible"}:{len:0};switch(++i,line.charAt(i)){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(++i,line.charAt(i)){case"]":return{len:2,token:"bar_thin_thick"};case"|":return++i,":"===line.charAt(i)?{len:3,token:"bar_left_repeat"}:{len:2,token:"bar_thin_thin"};case":":for(var colons=0;":"===line.charAt(i+colons);)colons++;return{len:1+colons,token:"bar_left_repeat"};default:return{len:1,token:"bar_thin"}}}return{len:0}},this.getTokenOf=function(str,legalChars){for(var i=0;i0;){var acc;if("^"===tokens[0].token){if(acc="sharp",tokens.shift(),0===tokens.length)return{accs:accs,warn:"Expected note name after "+acc};switch(tokens[0].token){case"^":acc="dblsharp",tokens.shift();break;case"/":acc="quartersharp",tokens.shift()}}else if("="===tokens[0].token)acc="natural",tokens.shift();else{if("_"!==tokens[0].token)return{accs:accs};if(acc="flat",tokens.shift(),0===tokens.length)return{accs:accs,warn:"Expected note name after "+acc};switch(tokens[0].token){case"_":acc="dblflat",tokens.shift();break;case"/":acc="quarterflat",tokens.shift()}}if(0===tokens.length)return{accs:accs,warn:"Expected note name after "+acc};switch(tokens[0].token.charAt(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===accs&&(accs=[]),accs.push({acc:acc,note:tokens[0].token.charAt(0)}),1===tokens[0].token.length?tokens.shift():tokens[0].token=tokens[0].token.substring(1);break;default:return{accs:accs,warn:"Expected note name after "+acc+" Found: "+tokens[0].token}}}return{accs:accs}},this.getKeyAccidental=function(str){var accTranslation={"^":"sharp","^^":"dblsharp","=":"natural",_:"flat",__:"dblflat","_/":"quarterflat","^/":"quartersharp"},i=this.skipWhiteSpace(str);if(finished(str,i))return{len:0};var acc=null;switch(str.charAt(i)){case"^":case"_":case"=":acc=str.charAt(i);break;default:return{len:0}}if(i++,finished(str,i))return{len:1,warn:"Expected note name after accidental"};switch(str.charAt(i)){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:i+1,token:{acc:accTranslation[acc],note:str.charAt(i)}};case"^":case"_":case"/":if(acc+=str.charAt(i),i++,finished(str,i))return{len:2,warn:"Expected note name after accidental"};switch(str.charAt(i)){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:i+1,token:{acc:accTranslation[acc],note:str.charAt(i)}};default:return{len:2,warn:"Expected note name after accidental"}}break;default:return{len:1,warn:"Expected note name after accidental"}}},this.isWhiteSpace=function(ch){return" "===ch||"\t"===ch||""===ch},this.getMeat=function(line,start,end){var comment=line.indexOf("%",start);for(comment>=0&&comment="A"&&ch<="Z"||ch>="a"&&ch<="z"},isNumber=function(ch){return ch>="0"&&ch<="9"};this.tokenize=function(line,start,end,alphaUntilWhiteSpace){var ret=this.getMeat(line,start,end);start=ret.start,end=ret.end;for(var i,tokens=[];start=end?{len:1,err:"Missing close quote"}:{len:close-start+1,token:this.translateString(line.substring(i+1,close))}}for(var ii=i;ii=0?window.ABCJS.parse.strip(str.substring(0,i)):window.ABCJS.parse.strip(str)},this.getInt=function(str){var x=parseInt(str);if(isNaN(x))return{digits:0};var s=""+x,i=str.indexOf(s);return{value:x,digits:i+s.length}},this.getFloat=function(str){var x=parseFloat(str);if(isNaN(x))return{digits:0};var s=""+x,i=str.indexOf(s);return{value:x,digits:i+s.length}},this.getMeasurement=function(tokens){if(0===tokens.length)return{used:0};var used=1,num="";if("-"===tokens[0].token)tokens.shift(),num="-",used++;else if("number"!==tokens[0].type)return{used:0};if(num+=tokens.shift().token,0===tokens.length)return{used:1,value:parseInt(num)};var x=tokens.shift();if("."===x.token){if(used++,0===tokens.length)return{used:used,value:parseInt(num)};if("number"===tokens[0].type&&(x=tokens.shift(),num=num+"."+x.token,used++,0===tokens.length))return{used:used,value:parseFloat(num)};x=tokens.shift()}switch(x.token){case"pt":return{used:used+1,value:parseFloat(num)};case"cm":return{used:used+1,value:parseFloat(num)/2.54*72};case"in":return{used:used+1,value:72*parseFloat(num)};default:return tokens.unshift(x),{used:used,value:parseFloat(num)}}return{used:0}};var substInChord=function(str){for(;str.indexOf("\\n")!==-1;)str=str.replace("\\n","\n");return str};this.getBrackettedSubstring=function(line,i,maxErrorChars,_matchChar){for(var matchChar=_matchChar||line.charAt(i),pos=i+1;posline.length-1&&(pos=line.length-1),[pos-i+1,substInChord(line.substring(i+1,pos)),!1])}},window.ABCJS||(window.ABCJS={}),window.ABCJS.write||(window.ABCJS.write={}),ABCJS.write.AbsoluteElement=function(abcelem,duration,minspacing,type,tuneNumber){this.tuneNumber=tuneNumber,this.abcelem=abcelem,this.duration=duration,this.minspacing=minspacing||0,this.x=0,this.children=[],this.heads=[],this.extra=[],this.extraw=0,this.w=0,this.right=[],this.invisible=!1,this.bottom=void 0,this.top=void 0,this.type=type,this.specialY={tempoHeightAbove:0,partHeightAbove:0,volumeHeightAbove:0,dynamicHeightAbove:0,endingHeightAbove:0,chordHeightAbove:0,lyricHeightAbove:0,lyricHeightBelow:0,chordHeightBelow:0,volumeHeightBelow:0,dynamicHeightBelow:0}},ABCJS.write.AbsoluteElement.prototype.setUpperAndLowerElements=function(specialYResolved){for(var i=0;ithis.w&&(this.w=right.dx+right.w),this.right[this.right.length]=right,this.addChild(right)},ABCJS.write.AbsoluteElement.prototype.addCentered=function(elem){var half=elem.w/2;-halfthis.w&&(this.w=elem.dx+half),this.right[this.right.length]=elem,this.addChild(elem)},ABCJS.write.AbsoluteElement.prototype.setLimit=function(member,child){child[member]&&(this.specialY[member]?this.specialY[member]=Math.max(this.specialY[member],child[member]):this.specialY[member]=child[member])},ABCJS.write.AbsoluteElement.prototype.addChild=function(child){child.parent=this,this.children[this.children.length]=child,this.pushTop(child.top),this.pushBottom(child.bottom),this.setLimit("tempoHeightAbove",child),this.setLimit("partHeightAbove",child),this.setLimit("volumeHeightAbove",child),this.setLimit("dynamicHeightAbove",child),this.setLimit("endingHeightAbove",child),this.setLimit("chordHeightAbove",child),this.setLimit("lyricHeightAbove",child),this.setLimit("lyricHeightBelow",child),this.setLimit("chordHeightBelow",child),this.setLimit("volumeHeightBelow",child),this.setLimit("dynamicHeightBelow",child)},ABCJS.write.AbsoluteElement.prototype.pushTop=function(top){void 0!==top&&(void 0===this.top?this.top=top:this.top=Math.max(top,this.top))},ABCJS.write.AbsoluteElement.prototype.pushBottom=function(bottom){void 0!==bottom&&(void 0===this.bottom?this.bottom=bottom:this.bottom=Math.min(bottom,this.bottom))},ABCJS.write.AbsoluteElement.prototype.setX=function(x){this.x=x;for(var i=0;i0&&(kls.length>0&&" "!==kls.charAt(kls.length-1)&&(kls+=" "),kls+=addClass),this.elemset[i][0].setAttribute("class",kls)}},ABCJS.write.AbsoluteElement.prototype.highlight=function(klass,color){void 0===klass&&(klass="note_selected"),void 0===color&&(color="#ff0000"),this.setClass(klass,"",color)},ABCJS.write.AbsoluteElement.prototype.unhighlight=function(klass,color){void 0===klass&&(klass="note_selected"),void 0===color&&(color="#000000"),this.setClass("",klass,color)},window.ABCJS||(window.ABCJS={}),window.ABCJS.write||(window.ABCJS.write={}),function(){"use strict";ABCJS.write.getDuration=function(elem){var d=0;return elem.duration&&(d=elem.duration),d},ABCJS.write.getDurlog=function(duration){return void 0===duration?0:Math.floor(Math.log(duration)/Math.log(2))},ABCJS.write.AbstractEngraver=function(bagpipes,renderer,tuneNumber){this.decoration=new ABCJS.write.Decoration,this.renderer=renderer,this.tuneNumber=tuneNumber,this.isBagpipes=bagpipes,this.chartable={rest:{0:"rests.whole",1:"rests.half",2:"rests.quarter",3:"rests.8th",4:"rests.16th",5:"rests.32nd",6:"rests.64th",7:"rests.128th"},note:{"-1":"noteheads.dbl",0:"noteheads.whole",1:"noteheads.half",2:"noteheads.quarter",3:"noteheads.quarter",4:"noteheads.quarter",5:"noteheads.quarter",6:"noteheads.quarter",7:"noteheads.quarter",nostem:"noteheads.quarter"},rhythm:{"-1":"noteheads.slash.whole",0:"noteheads.slash.whole",1:"noteheads.slash.whole",2:"noteheads.slash.quarter",3:"noteheads.slash.quarter",4:"noteheads.slash.quarter",5:"noteheads.slash.quarter",6:"noteheads.slash.quarter",7:"noteheads.slash.quarter",nostem:"noteheads.slash.nostem"},x:{"-1":"noteheads.indeterminate",0:"noteheads.indeterminate",1:"noteheads.indeterminate",2:"noteheads.indeterminate",3:"noteheads.indeterminate",4:"noteheads.indeterminate",5:"noteheads.indeterminate",6:"noteheads.indeterminate",7:"noteheads.indeterminate",nostem:"noteheads.indeterminate"},harmonic:{"-1":"noteheads.harmonic.quarter",0:"noteheads.harmonic.quarter",1:"noteheads.harmonic.quarter",2:"noteheads.harmonic.quarter",3:"noteheads.harmonic.quarter",4:"noteheads.harmonic.quarter",5:"noteheads.harmonic.quarter",6:"noteheads.harmonic.quarter",7:"noteheads.harmonic.quarter",nostem:"noteheads.harmonic.quarter"},uflags:{3:"flags.u8th",4:"flags.u16th",5:"flags.u32nd",6:"flags.u64th"},dflags:{3:"flags.d8th",4:"flags.d16th",5:"flags.d32nd",6:"flags.d64th"}},this.reset()},ABCJS.write.AbstractEngraver.prototype.reset=function(){this.slurs={},this.ties=[],this.slursbyvoice={},this.tiesbyvoice={},this.endingsbyvoice={},this.s=0,this.v=0,this.tripletmultiplier=1,this.abcline=void 0,this.accidentalSlot=void 0,this.accidentalshiftx=void 0,this.dotshiftx=void 0,this.hasVocals=!1,this.minY=void 0,this.partstartelem=void 0,this.pos=void 0,this.roomtaken=void 0,this.roomtakenright=void 0,this.staffgroup=void 0,this.startlimitelem=void 0,this.stemdir=void 0,this.voice=void 0},ABCJS.write.AbstractEngraver.prototype.setStemHeight=function(heightInPixels){this.stemHeight=heightInPixels/ABCJS.write.spacing.STEP},ABCJS.write.AbstractEngraver.prototype.getCurrentVoiceId=function(){return"s"+this.s+"v"+this.v},ABCJS.write.AbstractEngraver.prototype.pushCrossLineElems=function(){this.slursbyvoice[this.getCurrentVoiceId()]=this.slurs,this.tiesbyvoice[this.getCurrentVoiceId()]=this.ties,this.endingsbyvoice[this.getCurrentVoiceId()]=this.partstartelem},ABCJS.write.AbstractEngraver.prototype.popCrossLineElems=function(){this.slurs=this.slursbyvoice[this.getCurrentVoiceId()]||{},this.ties=this.tiesbyvoice[this.getCurrentVoiceId()]||[],this.partstartelem=this.endingsbyvoice[this.getCurrentVoiceId()]},ABCJS.write.AbstractEngraver.prototype.getElem=function(){return this.abcline.length<=this.pos?null:this.abcline[this.pos]},ABCJS.write.AbstractEngraver.prototype.getNextElem=function(){return this.abcline.length<=this.pos+1?null:this.abcline[this.pos+1]},ABCJS.write.AbstractEngraver.prototype.containsLyrics=function(staves){for(var i=0;ielem.pitches[p+1].pitch){sorted=!1;var tmp=elem.pitches[p];elem.pitches[p]=elem.pitches[p+1],elem.pitches[p+1]=tmp}}while(!sorted)},ABCJS.write.ledgerLines=function(abselem,minPitch,maxPitch,isRest,c,additionalLedgers,dir,dx,scale){for(var i=maxPitch;i>11;i--)i%2!==0||isRest||abselem.addChild(new ABCJS.write.RelativeElement(null,dx,(ABCJS.write.glyphs.getSymbolWidth(c)+4)*scale,i,{type:"ledger"}));for(i=minPitch;i<1;i++)i%2!==0||isRest||abselem.addChild(new ABCJS.write.RelativeElement(null,dx,(ABCJS.write.glyphs.getSymbolWidth(c)+4)*scale,i,{type:"ledger"}));for(i=0;i=6?"down":"up";this.stemdir&&(dir=this.stemdir);var style=elem.style?elem.style:this.style;style&&"normal"!==style||(style="note");var noteSymbol;for(noteSymbol=zeroDuration?this.chartable[style].nostem:this.chartable[style][-durlog],noteSymbol||console.log("noteSymbol:",style,durlog,zeroDuration),p="down"===dir?elem.pitches.length-2:1;"down"===dir?p>=0:p11||curr.verticalPos<1)&&additionalLedgers.push(curr.verticalPos-curr.verticalPos%2),"down"===dir?this.roomtaken=ABCJS.write.glyphs.getSymbolWidth(noteSymbol)+2:dotshiftx=ABCJS.write.glyphs.getSymbolWidth(noteSymbol)+2)}for(this.accidentalSlot=[],p=0;p0&&(notehead.bottom=notehead.bottom-1),abselem.addHead(notehead)),this.roomtaken+=this.accidentalshiftx,this.roomtakenright=Math.max(this.roomtakenright,this.dotshiftx)}hasStem&&(p1="down"===dir?elem.minpitch-7:elem.minpitch+1/3,p1>6&&!this.stemdir&&(p1=6),p2="down"===dir?elem.maxpitch-1/3:elem.maxpitch+7,p2<6&&!this.stemdir&&(p2=6),dx="down"===dir||0===abselem.heads.length?0:abselem.heads[0].w,width="down"===dir?1:-1,"noteheads.slash.quarter"===notehead.c&&("down"===dir?p2-=1:p1+=1),abselem.addExtra(new ABCJS.write.RelativeElement(null,dx,0,p1,{type:"stem",pitch2:p2,linewidth:width})),this.minY=Math.min(p1,this.minY),this.minY=Math.min(p2,this.minY))}if(void 0!==elem.lyric){var lyricStr="";window.ABCJS.parse.each(elem.lyric,function(ly){lyricStr+=ly.syllable+ly.divider+"\n"});var lyricDim=this.renderer.getTextSize(lyricStr,"vocalfont","abc-lyric"),position=elem.positioning?elem.positioning.vocalPosition:"below";abselem.addCentered(new ABCJS.write.RelativeElement(lyricStr,0,lyricDim.width,void 0,{type:"lyric",position:position,height:lyricDim.height/ABCJS.write.spacing.STEP}))}if(!dontDraw&&void 0!==elem.gracenotes){var gracescale=.6,graceScaleStem=.7,gracebeam=null;elem.gracenotes.length>1&&(gracebeam=new ABCJS.write.BeamElem(this.stemHeight*graceScaleStem,"grace",this.isBagpipes),ABCJS.write.hint&&gracebeam.setHint(),gracebeam.mainNote=abselem);var graceoffsets=[];for(i=elem.gracenotes.length-1;i>=0;i--)this.roomtaken+=10,graceoffsets[i]=this.roomtaken,elem.gracenotes[i].accidental&&(this.roomtaken+=7);for(i=0;i6:pos<6)&&(pos=6);var xdelta="down"===dir?headx:headx+notehead.w-.6;abselem.addRight(new ABCJS.write.RelativeElement(flag,xdelta,ABCJS.write.glyphs.getSymbolWidth(flag)*scale,pos,{scalex:scale,scaley:scale}))}for(this.dotshiftx=notehead.w+dotshiftx-2+5*dot;dot>0;dot--){var dotadjusty=1-Math.abs(pitch)%2;abselem.addRight(new ABCJS.write.RelativeElement("dots.dot",notehead.w+dotshiftx-2+5*dot,ABCJS.write.glyphs.getSymbolWidth("dots.dot"),pitch+dotadjusty))}}if(notehead&&(notehead.highestVert=pitchelem.highestVert),pitchelem.accidental){var symb;switch(pitchelem.accidental){case"quartersharp":symb="accidentals.halfsharp";break;case"dblsharp":symb="accidentals.dblsharp";break;case"sharp":symb="accidentals.sharp";break;case"quarterflat":symb="accidentals.halfflat";break;case"flat":symb="accidentals.flat";break;case"dblflat":symb="accidentals.dblflat";break;case"natural":symb="accidentals.nat"}for(var accSlotFound=!1,accPlace=extrax,j=0;j=6){this.accidentalSlot[j][0]=pitch,accPlace=this.accidentalSlot[j][1],accSlotFound=!0;break}accSlotFound===!1&&(accPlace-=ABCJS.write.glyphs.getSymbolWidth(symb)*scale+2,this.accidentalSlot.push([pitch,accPlace]),this.accidentalshiftx=ABCJS.write.glyphs.getSymbolWidth(symb)*scale+2),abselem.addExtra(new ABCJS.write.RelativeElement(symb,accPlace,ABCJS.write.glyphs.getSymbolWidth(symb),pitch,{scalex:scale,scaley:scale}))}if(pitchelem.endTie&&this.ties[0]&&(this.ties[0].setEndAnchor(notehead),this.ties=this.ties.slice(1,this.ties.length)),pitchelem.startTie){var tie=new ABCJS.write.TieElem(notehead,null,("down"===this.stemdir||"down"===dir)&&"up"!==this.stemdir,"down"===this.stemdir||"up"===this.stemdir,!0);ABCJS.write.hint&&tie.setHint(),this.ties[this.ties.length]=tie,this.voice.addOther(tie),abselem.startTie=!0}if(pitchelem.endSlur)for(i=0;imaxSlant&&(slant=maxSlant),slant<-maxSlant&&(slant=-maxSlant),slant}function calcAverage(total,numElements){return numElements?total/numElements:0}function getBarYAt(startx,starty,endx,endy,x){return starty+(endy-starty)/(endx-startx)*(x-startx)}function calcDy(asc,isGrace){var dy=asc?ABCJS.write.spacing.STEP:-ABCJS.write.spacing.STEP;return isGrace&&(dy*=.4),dy}function drawBeam(renderer,startX,startY,endX,endY,dy,isHint){var klass="beam-elem";isHint&&(klass+=" abcjs-hint"),startY=renderer.calcY(startY),endY=renderer.calcY(endY);var pathString="M"+startX+" "+startY+" L"+endX+" "+endY+"L"+endX+" "+(endY+dy)+" L"+startX+" "+(startY+dy)+"z";renderer.printPath({path:pathString,stroke:"none",fill:"#000000",class:renderer.addClasses(klass)})}function calcXPos(asc,firstElement,lastElement){var starthead=firstElement.heads[asc?0:firstElement.heads.length-1],endhead=lastElement.heads[asc?0:lastElement.heads.length-1],startX=starthead.x;asc&&(startX+=starthead.w-.6);var endX=endhead.x;return asc&&(endX+=endhead.w),[startX,endX]}function calcYPos(total,numElements,stemHeight,asc,firstAveragePitch,lastAveragePitch,isFlat,minPitch,maxPitch,isGrace){var average=calcAverage(total,numElements),barpos=stemHeight-2,barminpos=stemHeight-2,pos=Math.round(asc?Math.max(average+barpos,maxPitch+barminpos):Math.min(average-barpos,minPitch-barminpos)),slant=calcSlant(firstAveragePitch,lastAveragePitch,numElements,isFlat),startY=pos+Math.floor(slant/2),endY=pos+Math.floor(-slant/2);return isGrace||(asc&&pos<6?(startY=6,endY=6):!asc&&pos>6&&(startY=6,endY=6)),[startY,endY]}function createStems(elems,asc,beam,dy,mainNote){for(var i=0;i=0;j--)if(i===elems.length-1||ABCJS.write.getDurlog(elems[i+1].abcelem.duration)>-j-4){var auxBeamEndX=x,auxBeamEndY=bary+sy*(j+1);auxBeams[j].single&&(auxBeamEndX=0===i?x+5:x-5,auxBeamEndY=getBarYAt(beam.startX,beam.startY,beam.endX,beam.endY,auxBeamEndX)+sy*(j+1)),beams.push({startX:auxBeams[j].x,endX:auxBeamEndX,startY:auxBeams[j].y,endY:auxBeamEndY,dy:dy}),auxBeams=auxBeams.slice(0,j)}}}return beams}ABCJS.write.BeamElem=function(stemHeight,type,flat){this.isflat=flat,this.isgrace=type&&"grace"===type,this.forceup=this.isgrace||type&&"up"===type,this.forcedown=type&&"down"===type,this.elems=[],this.total=0,this.allrests=!0,this.stemHeight=stemHeight,this.beams=[]},ABCJS.write.BeamElem.prototype.setHint=function(){this.hint=!0},ABCJS.write.BeamElem.prototype.add=function(abselem){var pitch=abselem.abcelem.averagepitch;void 0!==pitch&&(this.allrests=this.allrests&&abselem.abcelem.rest,abselem.beam=this,this.elems.push(abselem),this.total+=pitch,(!this.min||abselem.abcelem.minpitchthis.max)&&(this.max=abselem.abcelem.maxpitch))};var middleLine=6;ABCJS.write.BeamElem.prototype.calcDir=function(){if(this.forceup)return!0;if(this.forcedown)return!1;var average=calcAverage(this.total,this.elems.length);return average0?abselem.top+3:abselem.bottom-1,{scalex:scale,scaley:scale})),abselem.top+=2}return abselem}}(),window.ABCJS||(window.ABCJS={}),window.ABCJS.write||(window.ABCJS.write={}),function(){"use strict";ABCJS.write.createKeySignature=function(elem,tuneNumber){if(!elem.accidentals||0===elem.accidentals.length)return null;var abselem=new ABCJS.write.AbsoluteElement(elem,0,10,"staff-extra",tuneNumber),dx=0;return window.ABCJS.parse.each(elem.accidentals,function(acc){var symbol="sharp"===acc.acc?"accidentals.sharp":"natural"===acc.acc?"accidentals.nat":"accidentals.flat";abselem.addRight(new ABCJS.write.RelativeElement(symbol,dx,ABCJS.write.glyphs.getSymbolWidth(symbol),acc.verticalPos,{thickness:ABCJS.write.glyphs.symbolHeightInPitches(symbol)})),dx+=ABCJS.write.glyphs.getSymbolWidth(symbol)+2},this),abselem}}(),window.ABCJS||(window.ABCJS={}),window.ABCJS.write||(window.ABCJS.write={}),function(){"use strict";ABCJS.write.createTimeSignature=function(elem,tuneNumber){var abselem=new ABCJS.write.AbsoluteElement(elem,0,10,"staff-extra",tuneNumber);if("specified"===elem.type)for(var i=0;i9&&yPos++;var deltaX=width/2;"center"!==ABCJS.write.glyphs.getSymbolAlign(symbol)&&(deltaX-=ABCJS.write.glyphs.getSymbolWidth(symbol)/2),abselem.addChild(new ABCJS.write.RelativeElement(symbol,deltaX,ABCJS.write.glyphs.getSymbolWidth(symbol),yPos))}if("slide"===decoration[i]&&abselem.heads[0]){var yPos2=abselem.heads[0].pitch;yPos2-=2;var blank1=new ABCJS.write.RelativeElement("",-roomtaken-15,0,yPos2-1),blank2=new ABCJS.write.RelativeElement("",-roomtaken-5,0,yPos2+1);abselem.addChild(blank1),abselem.addChild(blank2),voice.addOther(new ABCJS.write.TieElem(blank1,blank2,!1,!1,!1))}}return void 0===yPos&&(yPos=pitch),{above:yPos,below:abselem.bottom}},volumeDecoration=function(voice,decoration,abselem,positioning){for(var i=0;iminBottom&&(y=minBottom)),y}function textDecoration(text,placement){var y=getPlacement(placement),textFudge=2,textHeight=5;abselem.addChild(new ABCJS.write.RelativeElement(text,width/2,0,y+textFudge,{type:"decoration",klass:"ornament",thickness:3})),incrementPlacement(placement,textHeight)}function symbolDecoration(symbol,placement){var deltaX=width/2;"center"!==ABCJS.write.glyphs.getSymbolAlign(symbol)&&(deltaX-=ABCJS.write.glyphs.getSymbolWidth(symbol)/2);var height=ABCJS.write.glyphs.symbolHeightInPitches(symbol)+1,y=getPlacement(placement);y="above"===placement?y+height/2:y-height/2,abselem.addChild(new ABCJS.write.RelativeElement(symbol,deltaX,ABCJS.write.glyphs.getSymbolWidth(symbol),y,{klass:"ornament",thickness:ABCJS.write.glyphs.symbolHeightInPitches(symbol)})),incrementPlacement(placement,height)}for(var symbolList={"+":"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",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"},hasOne=!1,i=0;i",positioning)),crescendo&&voice.addOther(new ABCJS.write.CrescendoElem(crescendo.start,crescendo.stop,"<",positioning))},ABCJS.write.Decoration.prototype.createDecoration=function(voice,decoration,pitch,width,abselem,roomtaken,dir,minPitch,positioning,hasVocals){positioning||(positioning={ornamentPosition:"above",volumePosition:hasVocals?"above":"below",dynamicPosition:hasVocals?"above":"below"}),volumeDecoration(voice,decoration,abselem,positioning.volumePosition),this.dynamicDecoration(voice,decoration,abselem,positioning.dynamicPosition),compoundDecoration(decoration,pitch,width,abselem,dir);var yPos=closeDecoration(voice,decoration,pitch,width,abselem,roomtaken,dir,minPitch);yPos.above=Math.max(yPos.above,this.minTop);stackedDecoration(decoration,width,abselem,yPos,positioning.ornamentPosition,this.minTop,this.minBottom)}}(),window.ABCJS||(window.ABCJS={}),window.ABCJS.write||(window.ABCJS.write={}),ABCJS.write.DynamicDecoration=function(anchor,dec,position){this.anchor=anchor,this.dec=dec,"below"===position?this.volumeHeightBelow=5:this.volumeHeightAbove=5,this.pitch=void 0},ABCJS.write.DynamicDecoration.prototype.setUpperAndLowerElements=function(positionY){this.volumeHeightAbove?this.pitch=positionY.volumeHeightAbove:this.pitch=positionY.volumeHeightBelow},ABCJS.write.DynamicDecoration.prototype.draw=function(renderer,linestartx,lineendx){void 0===this.pitch&&window.console.error("Dynamic Element y-coordinate not set.");var scalex=1,scaley=1;renderer.printSymbol(this.anchor.x,this.pitch,this.dec,scalex,scaley,renderer.addClasses("decoration"))},window.ABCJS||(window.ABCJS={}),window.ABCJS.write||(window.ABCJS.write={}),ABCJS.write.EndingElem=function(text,anchor1,anchor2){this.text=text,this.anchor1=anchor1,this.anchor2=anchor2,this.endingHeightAbove=5,this.pitch=void 0},ABCJS.write.EndingElem.prototype.setUpperAndLowerElements=function(positionY){this.pitch=positionY.endingHeightAbove},ABCJS.write.EndingElem.prototype.draw=function(renderer,linestartx,lineendx){void 0===this.pitch&&window.console.error("Ending Element y-coordinate not set.");var pathString,y=renderer.calcY(this.pitch),height=20;this.anchor1&&(linestartx=this.anchor1.x+this.anchor1.w,pathString=ABCJS.write.sprintf("M %f %f L %f %f",linestartx,y,linestartx,y+height), renderer.printPath({path:pathString,stroke:"#000000",fill:"#000000",class:renderer.addClasses("ending")}),renderer.renderText(linestartx+5,renderer.calcY(this.pitch-.5),this.text,"repeatfont","ending","start")),this.anchor2&&(lineendx=this.anchor2.x,pathString=ABCJS.write.sprintf("M %f %f L %f %f",lineendx,y,lineendx,y+height),renderer.printPath({path:pathString,stroke:"#000000",fill:"#000000",class:renderer.addClasses("ending")})),pathString=ABCJS.write.sprintf("M %f %f L %f %f",linestartx,y,lineendx,y),renderer.printPath({path:pathString,stroke:"#000000",fill:"#000000",class:renderer.addClasses("ending")})},window.ABCJS||(window.ABCJS={}),window.ABCJS.write||(window.ABCJS.write={}),ABCJS.write.spacing=function(){},ABCJS.write.spacing.FONTEM=360,ABCJS.write.spacing.FONTSIZE=30,ABCJS.write.spacing.STEP=93*ABCJS.write.spacing.FONTSIZE/720,ABCJS.write.spacing.SPACE=10,ABCJS.write.spacing.TOPNOTE=15,ABCJS.write.spacing.STAVEHEIGHT=100,ABCJS.write.spacing.INDENT=50,ABCJS.write.debugPlacement=!1,ABCJS.write.EngraverController=function(paper,params){params=params||{},this.space=3*ABCJS.write.spacing.SPACE,this.scale=params.scale||void 0,params.staffwidth?(this.staffwidthScreen=params.staffwidth,this.staffwidthPrint=params.staffwidth):(this.staffwidthScreen=740,this.staffwidthPrint=680),this.editable=params.editable||!1,this.listeners=[],params.listener&&this.addSelectListener(params.listener),this.usingSvg=!(!window.SVGAngle&&!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1")),this.usingSvg&¶ms.add_classes&&(Raphael._availableAttrs.class=""),Raphael._availableAttrs["text-decoration"]="",Raphael._availableAttrs["data-vertical"]="",this.renderer=new ABCJS.write.Renderer(paper,params.regression),this.renderer.setPaddingOverride(params),this.renderer.controller=this,this.reset()},ABCJS.write.EngraverController.prototype.reset=function(){this.selected=[],this.ingroup=!1,this.staffgroups=[],this.lastStaffGroupIndex=-1,this.engraver&&this.engraver.reset(),this.engraver=null,this.renderer.reset()},ABCJS.write.EngraverController.prototype.engraveABC=function(abctunes){void 0===abctunes[0]&&(abctunes=[abctunes]),this.reset();for(var i=0;imaxWidth&&(maxWidth=abcLine.staffGroup.w));for(i=0;i-1&&this.renderer.addStaffPadding(this.staffgroups[this.lastStaffGroupIndex],staffGroup),this.renderer.voiceNumber=null,staffGroup.draw(this.renderer);var height=staffGroup.height*ABCJS.write.spacing.STEP;this.staffgroups[this.staffgroups.length]=staffGroup,this.lastStaffGroupIndex=this.staffgroups.length-1,this.renderer.y+=height},ABCJS.write.EngraverController.prototype.notifySelect=function(abselem,tuneNumber){this.clearSelection(),abselem.highlight&&(this.selected=[abselem],abselem.highlight());for(var abcelem=abselem.abcelem||{},i=0;ielStart&&startthis.top&&(this.top=this.pitch2),this.bottom=pitch,void 0!==this.pitch2&&this.pitch20?this.top+=opt.stemHeight:this.bottom+=opt.stemHeight);var height=opt.height?opt.height:4;switch(this.centerVertically=!1,this.type){case"debug":this.chordHeightAbove=height;break;case"lyric":opt.position&&"below"===opt.position?this.lyricHeightBelow=height:this.lyricHeightAbove=height;break;case"chord":opt.position&&"below"===opt.position?this.chordHeightBelow=height:this.chordHeightAbove=height;break;case"text":void 0===this.pitch?opt.position&&"below"===opt.position?this.chordHeightBelow=height:this.chordHeightAbove=height:this.centerVertically=!0;break;case"part":this.partHeightAbove=height}},ABCJS.write.RelativeElement.prototype.setX=function(x){this.x=x+this.dx},ABCJS.write.RelativeElement.prototype.draw=function(renderer,bartop){void 0===this.pitch&&window.console.error(this.type+" Relative Element y-coordinate not set.");var y=renderer.calcY(this.pitch);switch(this.type){case"symbol":if(null===this.c)return null;var klass="symbol";this.klass&&(klass+=" "+this.klass),this.graphelem=renderer.printSymbol(this.x,this.pitch,this.c,this.scalex,this.scaley,renderer.addClasses(klass));break;case"debug":this.graphelem=renderer.renderText(this.x,renderer.calcY(15),""+this.c,"debugfont","debug-msg","start");break;case"barNumber":this.graphelem=renderer.renderText(this.x,y,""+this.c,"measurefont","bar-number","middle");break;case"lyric":this.graphelem=renderer.renderText(this.x,y,this.c,"vocalfont","abc-lyric","middle");break;case"chord":this.graphelem=renderer.renderText(this.x,y,this.c,"gchordfont","chord","middle");break;case"decoration":this.graphelem=renderer.renderText(this.x,y,this.c,"annotationfont","annotation","middle",!0);break;case"text":this.graphelem=renderer.renderText(this.x,y,this.c,"annotationfont","annotation","start",this.centerVertically);break;case"part":this.graphelem=renderer.renderText(this.x,y,this.c,"partsfont","part","start");break;case"bar":this.graphelem=renderer.printStem(this.x,this.linewidth,y,bartop?bartop:renderer.calcY(this.pitch2));break;case"stem":this.graphelem=renderer.printStem(this.x,this.linewidth,y,renderer.calcY(this.pitch2));break;case"ledger":this.graphelem=renderer.printStaveLine(this.x,this.x+this.w,this.pitch)}return 1!==this.scalex&&this.graphelem&&this.graphelem.scale(this.scalex,this.scaley,this.x,y),this.graphelem},window.ABCJS||(window.ABCJS={}),window.ABCJS.write||(window.ABCJS.write={}),ABCJS.write.Renderer=function(paper,doRegression){this.paper=paper,this.controller=null,this.space=3*ABCJS.write.spacing.SPACE,this.padding={},this.doRegression=doRegression,this.doRegression&&(this.regressionLines=[]),this.reset()},ABCJS.write.Renderer.prototype.reset=function(){this.paper.clear(),this.y=0,this.abctune=null,this.lastM=null,this.ingroup=!1,this.path=null,this.isPrint=!1,this.initVerticalSpace(),this.doRegression&&(this.regressionLines=[])},ABCJS.write.Renderer.prototype.setPrintMode=function(isPrint){this.isPrint=isPrint},ABCJS.write.Renderer.prototype.setPaperSize=function(maxwidth,scale){var w=(maxwidth+this.padding.right)*scale,h=(this.y+this.padding.bottom)*scale;this.isPrint&&(h=Math.max(h,1056)),this.doRegression&&this.regressionLines.push("PAPER SIZE: ("+w+","+h+")"),this.paper.setSize(w/scale,h/scale);var isIE=!1;isIE?(this.paper.canvas.parentNode.style.width=w+"px",this.paper.canvas.parentNode.style.height=""+h+"px"):this.paper.canvas.parentNode.setAttribute("style","width:"+w+"px"),1!==scale?(this.paper.canvas.style.transform="scale("+scale+","+scale+")",this.paper.canvas.style["-ms-transform"]="scale("+scale+","+scale+")",this.paper.canvas.style["-webkit-transform"]="scale("+scale+","+scale+")",this.paper.canvas.style["transform-origin"]="0 0",this.paper.canvas.style["-ms-transform-origin-x"]="0",this.paper.canvas.style["-ms-transform-origin-y"]="0",this.paper.canvas.style["-webkit-transform-origin-x"]="0",this.paper.canvas.style["-webkit-transform-origin-y"]="0"):(this.paper.canvas.style.transform="",this.paper.canvas.style["-ms-transform"]="",this.paper.canvas.style["-webkit-transform"]=""),this.paper.canvas.parentNode.style.overflow="hidden",this.paper.canvas.parentNode.style.height=""+h+"px"},ABCJS.write.Renderer.prototype.setPaddingOverride=function(params){this.paddingOverride={top:params.paddingtop,bottom:params.paddingbottom,right:params.paddingright,left:params.paddingleft}},ABCJS.write.Renderer.prototype.setPadding=function(abctune){function setPaddingVariable(self,paddingKey,formattingKey,printDefault,screenDefault){void 0!==abctune.formatting[formattingKey]?self.padding[paddingKey]=abctune.formatting[formattingKey]:void 0!==self.paddingOverride[paddingKey]?self.padding[paddingKey]=self.paddingOverride[paddingKey]:self.isPrint?self.padding[paddingKey]=printDefault:self.padding[paddingKey]=screenDefault}setPaddingVariable(this,"top","topmargin",38,15),setPaddingVariable(this,"bottom","botmargin",38,15),setPaddingVariable(this,"left","leftmargin",68,15),setPaddingVariable(this,"right","rightmargin",68,15)},ABCJS.write.Renderer.prototype.adjustNonScaledItems=function(scale){this.padding.top/=scale,this.padding.bottom/=scale,this.padding.left/=scale,this.padding.right/=scale,this.abctune.formatting.headerfont.size/=scale,this.abctune.formatting.footerfont.size/=scale},ABCJS.write.Renderer.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,stemHeight:36.67,subtitle:3.78,systemStaffSeparation:48,text:18.9,title:7.56,top:30.24,vocal:30.67,words:0}},ABCJS.write.Renderer.prototype.setVerticalSpace=function(formatting){void 0!==formatting.staffsep&&(this.spacing.staffSeparation=4*formatting.staffsep/3),void 0!==formatting.composerspace&&(this.spacing.composer=4*formatting.composerspace/3),void 0!==formatting.partsspace&&(this.spacing.parts=4*formatting.partsspace/3),void 0!==formatting.textspace&&(this.spacing.text=4*formatting.textspace/3),void 0!==formatting.musicspace&&(this.spacing.music=4*formatting.musicspace/3),void 0!==formatting.titlespace&&(this.spacing.title=4*formatting.titlespace/3),void 0!==formatting.sysstaffsep&&(this.spacing.systemStaffSeparation=4*formatting.sysstaffsep/3),void 0!==formatting.subtitlespace&&(this.spacing.subtitle=4*formatting.subtitlespace/3),void 0!==formatting.topspace&&(this.spacing.top=4*formatting.topspace/3),void 0!==formatting.vocalspace&&(this.spacing.vocal=4*formatting.vocalspace/3),void 0!==formatting.wordsspace&&(this.spacing.words=4*formatting.wordsspace/3)},ABCJS.write.Renderer.prototype.topMargin=function(abctune){this.moveY(this.padding.top)},ABCJS.write.Renderer.prototype.addMusicPadding=function(){this.moveY(this.spacing.music)},ABCJS.write.Renderer.prototype.addStaffPadding=function(lastStaffGroup,thisStaffGroup){var lastStaff=lastStaffGroup.staffs[lastStaffGroup.staffs.length-1],lastBottomLine=-(lastStaff.bottom-2),nextTopLine=thisStaffGroup.staffs[0].top-10,naturalSeparation=nextTopLine+lastBottomLine,separationInPixels=naturalSeparation*ABCJS.write.spacing.STEP;separationInPixels0){var space=this.outputTextIf(this.padding.left+width,composerLine,"composerfont","meta-top",0,null,"end");this.moveY(space[1])}else this.moveY(rSpace[1]);this.moveY(-6)}this.outputTextIf(this.padding.left+width,abctune.metaText.author,"composerfont","meta-top",0,0,"end"),this.outputTextIf(this.padding.left,abctune.metaText.partOrder,"partsfont","meta-bottom",0,0,"start")},ABCJS.write.Renderer.prototype.engraveExtraText=function(width,abctune){this.lineNumber=null,this.measureNumber=null,this.voiceNumber=null;var extraText;if(abctune.metaText.unalignedWords){extraText="";for(var j=0;j0&&symbol.indexOf(".")<0){for(var elemset=this.paper.set(),dx=0,i=0;i=0;i--)this.printStaveLine(startx,endx,2*(i+1),klass),klass=void 0},ABCJS.write.Renderer.prototype.addClasses=function(c){var ret=[];return c.length>0&&ret.push(c),null!==this.lineNumber&&ret.push("l"+this.lineNumber),null!==this.measureNumber&&ret.push("m"+this.measureNumber),null!==this.voiceNumber&&ret.push("v"+this.voiceNumber),ret.join(" ")},ABCJS.write.Renderer.prototype.getFontAndAttr=function(type,klass){var font=this.abctune.formatting[type];font=font?{face:font.face,size:4*font.size/3,decoration:font.decoration,style:font.style,weight:font.weight,box:font.box}:{face:"Arial",size:16,decoration:"underline",style:"normal",weight:"normal"};var attr={"font-size":font.size,"font-style":font.style,"font-family":font.face,"font-weight":font.weight,"text-decoration":font.decoration,class:this.addClasses(klass)};return attr.font="",{font:font,attr:attr}},ABCJS.write.Renderer.prototype.getTextSize=function(text,type,klass){var hash=this.getFontAndAttr(type,klass),el=this.paper.text(0,0,text).attr(hash.attr),size=el.getBBox();return isNaN(size.height)&&(size={width:0,height:0}),el.remove(),size},ABCJS.write.Renderer.prototype.renderText=function(x,y,text,type,klass,anchor,centerVertically){var hash=this.getFontAndAttr(type,klass);anchor&&(hash.attr["text-anchor"]=anchor),text=text.replace(/\n\n/g,"\n \n");var el=this.paper.text(x,y,text).attr(hash.attr);if(!centerVertically){var size=el.getBBox();isNaN(size.height)?el.attr({y:y}):(el.attr({y:y+size.height/2}),hash.font.box&&this.paper.rect(size.x-1,size.y+size.height/2-1,size.width+2,size.height+2).attr({stroke:"#888888"}))}return"debugfont"===type&&(console.log("Debug msg: "+text),el.attr({stroke:"#ff0000"})),this.doRegression&&this.addToRegression(el),el},ABCJS.write.Renderer.prototype.moveY=function(em,numLines){void 0===numLines&&(numLines=1),this.y+=em*numLines},ABCJS.write.Renderer.prototype.skipSpaceY=function(){this.y+=this.space},ABCJS.write.Renderer.prototype.outputTextIf=function(x,str,kind,klass,marginTop,marginBottom,alignment){if(str){marginTop&&this.moveY(marginTop);var el=this.renderText(x,this.y,str,kind,klass,alignment),bb=el.getBBox(),width=isNaN(bb.width)?0:bb.width,height=isNaN(bb.height)?0:bb.height;if(null!==marginBottom){var numLines=str.split("\n").length;isNaN(bb.height)||this.moveY(height/numLines,numLines+marginBottom)}return[width,height]}return[0,0]},ABCJS.write.Renderer.prototype.addInvisibleMarker=function(className){var dy=.35,fill="rgba(0,0,0,0)",y=this.y;y=Math.round(y);var x1=0,x2=100,pathString=ABCJS.write.sprintf("M %f %f L %f %f L %f %f L %f %f z",x1,y-dy,x1+x2,y-dy,x2,y+dy,x1,y+dy);this.paper.path().attr({path:pathString,stroke:"none",fill:fill,class:this.addClasses(className),"data-vertical":y}).toBack()},ABCJS.write.Renderer.prototype.printHorizontalLine=function(width,vertical,comment){var dy=.35,fill="rgba(0,0,255,.4)",y=this.y;vertical&&(y=vertical),y=Math.round(y),this.paper.text(10,y,""+Math.round(y)).attr({"text-anchor":"start","font-size":"18px",fill:fill,stroke:fill});var x1=50,x2=width,pathString=ABCJS.write.sprintf("M %f %f L %f %f L %f %f L %f %f z",x1,y-dy,x1+x2,y-dy,x2,y+dy,x1,y+dy);this.paper.path().attr({path:pathString,stroke:"none",fill:fill,class:this.addClasses("staff")}).toBack();for(var i=1;i0&&(staff.top+=addedSpace)}lastStaffBottom=2-staff.bottom}},ABCJS.write.StaffGroupElement.prototype.finished=function(){for(var i=0;iepsilon?othervoices.push(this.voices[i]):(currentvoices.push(this.voices[i]),debug&&console.log("in: voice ",i))}spacingunit=0;var spacingduration=0;for(i=0;ix&&(x=currentvoices[i].getNextX(),spacingunit=currentvoices[i].getSpacingUnits(),spacingduration=currentvoices[i].spacingduration);for(this.spacingunits+=spacingunit,this.minspace=Math.min(this.minspace,spacingunit),i=0;i0){x=voicechildx;for(var j=0;jx&&(x=this.voices[i].getNextX(),spacingunit=this.voices[i].getSpacingUnits());for(this.spacingunits+=spacingunit,this.w=x,i=0;i6&&(colorIndex=0)}}}renderer.addInvisibleMarker("abcjs-top-of-system");for(var startY=renderer.y,j=0;j1&&renderer.printStem(this.startx,.6,topLine,bottomLine),renderer.y=startY},window.ABCJS||(window.ABCJS={}),window.ABCJS.write||(window.ABCJS.write={}), function(){"use strict";var totalHeightInPitches=5;ABCJS.write.TempoElement=function(tempo,tuneNumber){this.tempo=tempo,this.tuneNumber=tuneNumber,this.tempoHeightAbove=totalHeightInPitches,this.pitch=void 0},ABCJS.write.TempoElement.prototype.setUpperAndLowerElements=function(positionY){this.pitch=positionY.tempoHeightAbove},ABCJS.write.TempoElement.prototype.setX=function(x){this.x=x},ABCJS.write.TempoElement.prototype.draw=function(renderer){var x=this.x;void 0===this.pitch&&window.console.error("Tempo Element y-coordinate not set.");var text,y=renderer.calcY(this.pitch);if(this.tempo.preString){text=renderer.renderText(x,y,this.tempo.preString,"tempofont","tempo","start");var preWidth=text.getBBox().width,charWidth=preWidth/this.tempo.preString.length;x+=preWidth+charWidth}if(this.tempo.duration){var dot,flag,note,temposcale=.75,tempopitch=this.pitch-totalHeightInPitches+1,duration=this.tempo.duration[0],abselem=new ABCJS.write.AbsoluteElement(this.tempo,duration,1,"tempo",this.tuneNumber);duration<=1/32?(note="noteheads.quarter",flag="flags.u32nd",dot=0):duration<=1/16?(note="noteheads.quarter",flag="flags.u16th",dot=0):duration<=3/32?(note="noteheads.quarter",flag="flags.u16nd",dot=1):duration<=1/8?(note="noteheads.quarter",flag="flags.u8th",dot=0):duration<=3/16?(note="noteheads.quarter",flag="flags.u8th",dot=1):duration<=.25?(note="noteheads.quarter",dot=0):duration<=3/8?(note="noteheads.quarter",dot=1):duration<=.5?(note="noteheads.half",dot=0):duration<=.75?(note="noteheads.half",dot=1):duration<=1?(note="noteheads.whole",dot=0):duration<=1.5?(note="noteheads.whole",dot=1):duration<=2?(note="noteheads.dbl",dot=0):(note="noteheads.dbl",dot=1);var temponote=renderer.engraver.createNoteHead(abselem,note,{verticalPos:tempopitch},"up",0,0,flag,dot,0,temposcale);abselem.addHead(temponote);var stem;if("noteheads.whole"!==note&&"noteheads.dbl"!==note){var p1=tempopitch+1/3*temposcale,p2=tempopitch+7*temposcale,dx=temponote.dx+temponote.w,width=-.6;stem=new ABCJS.write.RelativeElement(null,dx,0,p1,{type:"stem",pitch2:p2,linewidth:width}),stem.setX(x),abselem.addExtra(stem)}abselem.setX(x);for(var i=0;i=this.children.length},ABCJS.write.VoiceElement.prototype.getDurationIndex=function(){return this.durationindex-(this.children[this.i]&&this.children[this.i].duration>0?0:5e-7)},ABCJS.write.VoiceElement.prototype.getSpacingUnits=function(){return Math.sqrt(8*this.spacingduration)},ABCJS.write.VoiceElement.prototype.getNextX=function(){return Math.max(this.minx,this.nextx)},ABCJS.write.VoiceElement.prototype.beginLayout=function(startx){this.i=0,this.durationindex=0,this.startx=startx,this.minx=startx,this.nextx=startx,this.spacingduration=0},ABCJS.write.VoiceElement.prototype.layoutOneItem=function(x,spacing){var child=this.children[this.i];if(!child)return 0;var er=x-this.minx;return er0?"+"+a:a,c=m[3]?"0"==m[3]?"0":m[3].charAt(1):" ",x=m[5]-String(a).length,p=m[5]?str_repeat(c,x):"",o.push(m[4]?a+p:p+a)}f=f.substring(m[0].length)}return o.join("")}; // source --> http://mytoolbox.sakura.ne.jp/wp/wp-includes/js/jquery/jquery.js?ver=1.11.3 /*! jQuery v1.11.3 | (c) 2005, 2015 jQuery Foundation, Inc. | jquery.org/license */ !function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.3",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},m.extend=m.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||m.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(m.isPlainObject(c)||(b=m.isArray(c)))?(b?(b=!1,f=a&&m.isArray(a)?a:[]):f=a&&m.isPlainObject(a)?a:{},g[d]=m.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},m.extend({expando:"jQuery"+(l+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===m.type(a)},isArray:Array.isArray||function(a){return"array"===m.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!m.isArray(a)&&a-parseFloat(a)+1>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==m.type(a)||a.nodeType||m.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(k.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&m.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(o,"ms-").replace(p,q)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(n,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(r(Object(a))?m.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=r(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),m.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||m.guid++,e):void 0},now:function(){return+new Date},support:k}),m.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function r(a){var b="length"in a&&a.length,c=m.type(a);return"function"===c||m.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var s=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N=M.replace("w","w#"),O="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+N+"))|)"+L+"*\\]",P=":("+M+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+O+")*)|.*)\\)|)",Q=new RegExp(L+"+","g"),R=new RegExp("^"+L+"+|((?:^|[^\\\\])(?:\\\\.)*)"+L+"+$","g"),S=new RegExp("^"+L+"*,"+L+"*"),T=new RegExp("^"+L+"*([>+~]|"+L+")"+L+"*"),U=new RegExp("="+L+"*([^\\]'\"]*?)"+L+"*\\]","g"),V=new RegExp(P),W=new RegExp("^"+N+"$"),X={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),TAG:new RegExp("^("+M.replace("w","w*")+")"),ATTR:new RegExp("^"+O),PSEUDO:new RegExp("^"+P),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+L+"*(even|odd|(([+-]|)(\\d*)n|)"+L+"*(?:([+-]|)"+L+"*(\\d+)|))"+L+"*\\)|)","i"),bool:new RegExp("^(?:"+K+")$","i"),needsContext:new RegExp("^"+L+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+L+"*((?:-\\d)?\\d*)"+L+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,aa=/[+~]/,ba=/'|\\/g,ca=new RegExp("\\\\([\\da-f]{1,6}"+L+"?|("+L+")|.)","ig"),da=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},ea=function(){m()};try{H.apply(E=I.call(v.childNodes),v.childNodes),E[v.childNodes.length].nodeType}catch(fa){H={apply:E.length?function(a,b){G.apply(a,I.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function ga(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],k=b.nodeType,"string"!=typeof a||!a||1!==k&&9!==k&&11!==k)return d;if(!e&&p){if(11!==k&&(f=_.exec(a)))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return H.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName)return H.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=1!==k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(ba,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+ra(o[l]);w=aa.test(a)&&pa(b.parentNode)||b,x=o.join(",")}if(x)try{return H.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function ha(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ia(a){return a[u]=!0,a}function ja(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function ka(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function la(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||C)-(~a.sourceIndex||C);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function ma(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function na(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function oa(a){return ia(function(b){return b=+b,ia(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function pa(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=ga.support={},f=ga.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=ga.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=g.documentElement,e=g.defaultView,e&&e!==e.top&&(e.addEventListener?e.addEventListener("unload",ea,!1):e.attachEvent&&e.attachEvent("onunload",ea)),p=!f(g),c.attributes=ja(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ja(function(a){return a.appendChild(g.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(g.getElementsByClassName),c.getById=ja(function(a){return o.appendChild(a).id=u,!g.getElementsByName||!g.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(ca,da);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(ca,da);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(g.querySelectorAll))&&(ja(function(a){o.appendChild(a).innerHTML="",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+L+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+L+"*(?:value|"+K+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),ja(function(a){var b=g.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+L+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ja(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",P)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===g||a.ownerDocument===v&&t(v,a)?-1:b===g||b.ownerDocument===v&&t(v,b)?1:k?J(k,a)-J(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,h=[a],i=[b];if(!e||!f)return a===g?-1:b===g?1:e?-1:f?1:k?J(k,a)-J(k,b):0;if(e===f)return la(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?la(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},g):n},ga.matches=function(a,b){return ga(a,null,null,b)},ga.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return ga(b,n,null,[a]).length>0},ga.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},ga.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&D.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},ga.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},ga.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=ga.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=ga.selectors={cacheLength:50,createPseudo:ia,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ca,da),a[3]=(a[3]||a[4]||a[5]||"").replace(ca,da),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||ga.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&ga.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(ca,da).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+L+")"+a+"("+L+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=ga.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(Q," ")+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||ga.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ia(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=J(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ia(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?ia(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ia(function(a){return function(b){return ga(a,b).length>0}}),contains:ia(function(a){return a=a.replace(ca,da),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ia(function(a){return W.test(a||"")||ga.error("unsupported lang: "+a),a=a.replace(ca,da).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:oa(function(){return[0]}),last:oa(function(a,b){return[b-1]}),eq:oa(function(a,b,c){return[0>c?c+b:c]}),even:oa(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:oa(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:oa(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:oa(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function sa(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function ta(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function ua(a,b,c){for(var d=0,e=b.length;e>d;d++)ga(a,b[d],c);return c}function va(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function wa(a,b,c,d,e,f){return d&&!d[u]&&(d=wa(d)),e&&!e[u]&&(e=wa(e,f)),ia(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||ua(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:va(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=va(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?J(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=va(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):H.apply(g,r)})}function xa(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=sa(function(a){return a===b},h,!0),l=sa(function(a){return J(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];f>i;i++)if(c=d.relative[a[i].type])m=[sa(ta(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return wa(i>1&&ta(m),i>1&&ra(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&xa(a.slice(i,e)),f>e&&xa(a=a.slice(e)),f>e&&ra(a))}m.push(c)}return ta(m)}function ya(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=F.call(i));s=va(s)}H.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&ga.uniqueSort(i)}return k&&(w=v,j=t),r};return c?ia(f):f}return h=ga.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=xa(b[c]),f[u]?d.push(f):e.push(f);f=A(a,ya(e,d)),f.selector=a}return f},i=ga.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(ca,da),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(ca,da),aa.test(j[0].type)&&pa(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&ra(j),!a)return H.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,aa.test(a)&&pa(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ja(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ja(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||ka("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ja(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||ka("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ja(function(a){return null==a.getAttribute("disabled")})||ka(K,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),ga}(a);m.find=s,m.expr=s.selectors,m.expr[":"]=m.expr.pseudos,m.unique=s.uniqueSort,m.text=s.getText,m.isXMLDoc=s.isXML,m.contains=s.contains;var t=m.expr.match.needsContext,u=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,v=/^.[^:#\[\.,]*$/;function w(a,b,c){if(m.isFunction(b))return m.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return m.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(v.test(b))return m.filter(b,a,c);b=m.filter(b,a)}return m.grep(a,function(a){return m.inArray(a,b)>=0!==c})}m.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?m.find.matchesSelector(d,a)?[d]:[]:m.find.matches(a,m.grep(b,function(a){return 1===a.nodeType}))},m.fn.extend({find:function(a){var b,c=[],d=this,e=d.length;if("string"!=typeof a)return this.pushStack(m(a).filter(function(){for(b=0;e>b;b++)if(m.contains(d[b],this))return!0}));for(b=0;e>b;b++)m.find(a,d[b],c);return c=this.pushStack(e>1?m.unique(c):c),c.selector=this.selector?this.selector+" "+a:a,c},filter:function(a){return this.pushStack(w(this,a||[],!1))},not:function(a){return this.pushStack(w(this,a||[],!0))},is:function(a){return!!w(this,"string"==typeof a&&t.test(a)?m(a):a||[],!1).length}});var x,y=a.document,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=m.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||x).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof m?b[0]:b,m.merge(this,m.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:y,!0)),u.test(c[1])&&m.isPlainObject(b))for(c in b)m.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}if(d=y.getElementById(c[2]),d&&d.parentNode){if(d.id!==c[2])return x.find(a);this.length=1,this[0]=d}return this.context=y,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):m.isFunction(a)?"undefined"!=typeof x.ready?x.ready(a):a(m):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),m.makeArray(a,this))};A.prototype=m.fn,x=m(y);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};m.extend({dir:function(a,b,c){var d=[],e=a[b];while(e&&9!==e.nodeType&&(void 0===c||1!==e.nodeType||!m(e).is(c)))1===e.nodeType&&d.push(e),e=e[b];return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),m.fn.extend({has:function(a){var b,c=m(a,this),d=c.length;return this.filter(function(){for(b=0;d>b;b++)if(m.contains(this,c[b]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=t.test(a)||"string"!=typeof a?m(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&m.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?m.unique(f):f)},index:function(a){return a?"string"==typeof a?m.inArray(this[0],m(a)):m.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(m.unique(m.merge(this.get(),m(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}m.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return m.dir(a,"parentNode")},parentsUntil:function(a,b,c){return m.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return m.dir(a,"nextSibling")},prevAll:function(a){return m.dir(a,"previousSibling")},nextUntil:function(a,b,c){return m.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return m.dir(a,"previousSibling",c)},siblings:function(a){return m.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return m.sibling(a.firstChild)},contents:function(a){return m.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:m.merge([],a.childNodes)}},function(a,b){m.fn[a]=function(c,d){var e=m.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=m.filter(d,e)),this.length>1&&(C[a]||(e=m.unique(e)),B.test(a)&&(e=e.reverse())),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return m.each(a.match(E)||[],function(a,c){b[c]=!0}),b}m.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):m.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(c=a.memory&&l,d=!0,f=g||0,g=0,e=h.length,b=!0;h&&e>f;f++)if(h[f].apply(l[0],l[1])===!1&&a.stopOnFalse){c=!1;break}b=!1,h&&(i?i.length&&j(i.shift()):c?h=[]:k.disable())},k={add:function(){if(h){var d=h.length;!function f(b){m.each(b,function(b,c){var d=m.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&f(c)})}(arguments),b?e=h.length:c&&(g=d,j(c))}return this},remove:function(){return h&&m.each(arguments,function(a,c){var d;while((d=m.inArray(c,h,d))>-1)h.splice(d,1),b&&(e>=d&&e--,f>=d&&f--)}),this},has:function(a){return a?m.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],e=0,this},disable:function(){return h=i=c=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,c||k.disable(),this},locked:function(){return!i},fireWith:function(a,c){return!h||d&&!i||(c=c||[],c=[a,c.slice?c.slice():c],b?i.push(c):j(c)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!d}};return k},m.extend({Deferred:function(a){var b=[["resolve","done",m.Callbacks("once memory"),"resolved"],["reject","fail",m.Callbacks("once memory"),"rejected"],["notify","progress",m.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return m.Deferred(function(c){m.each(b,function(b,f){var g=m.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&m.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?m.extend(a,d):d}},e={};return d.pipe=d.then,m.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&m.isFunction(a.promise)?e:0,g=1===f?a:m.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&m.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;m.fn.ready=function(a){return m.ready.promise().done(a),this},m.extend({isReady:!1,readyWait:1,holdReady:function(a){a?m.readyWait++:m.ready(!0)},ready:function(a){if(a===!0?!--m.readyWait:!m.isReady){if(!y.body)return setTimeout(m.ready);m.isReady=!0,a!==!0&&--m.readyWait>0||(H.resolveWith(y,[m]),m.fn.triggerHandler&&(m(y).triggerHandler("ready"),m(y).off("ready")))}}});function I(){y.addEventListener?(y.removeEventListener("DOMContentLoaded",J,!1),a.removeEventListener("load",J,!1)):(y.detachEvent("onreadystatechange",J),a.detachEvent("onload",J))}function J(){(y.addEventListener||"load"===event.type||"complete"===y.readyState)&&(I(),m.ready())}m.ready.promise=function(b){if(!H)if(H=m.Deferred(),"complete"===y.readyState)setTimeout(m.ready);else if(y.addEventListener)y.addEventListener("DOMContentLoaded",J,!1),a.addEventListener("load",J,!1);else{y.attachEvent("onreadystatechange",J),a.attachEvent("onload",J);var c=!1;try{c=null==a.frameElement&&y.documentElement}catch(d){}c&&c.doScroll&&!function e(){if(!m.isReady){try{c.doScroll("left")}catch(a){return setTimeout(e,50)}I(),m.ready()}}()}return H.promise(b)};var K="undefined",L;for(L in m(k))break;k.ownLast="0"!==L,k.inlineBlockNeedsLayout=!1,m(function(){var a,b,c,d;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",k.inlineBlockNeedsLayout=a=3===b.offsetWidth,a&&(c.style.zoom=1)),c.removeChild(d))}),function(){var a=y.createElement("div");if(null==k.deleteExpando){k.deleteExpando=!0;try{delete a.test}catch(b){k.deleteExpando=!1}}a=null}(),m.acceptData=function(a){var b=m.noData[(a.nodeName+" ").toLowerCase()],c=+a.nodeType||1;return 1!==c&&9!==c?!1:!b||b!==!0&&a.getAttribute("classid")===b};var M=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,N=/([A-Z])/g;function O(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(N,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:M.test(c)?m.parseJSON(c):c}catch(e){}m.data(a,b,c)}else c=void 0}return c}function P(a){var b;for(b in a)if(("data"!==b||!m.isEmptyObject(a[b]))&&"toJSON"!==b)return!1; return!0}function Q(a,b,d,e){if(m.acceptData(a)){var f,g,h=m.expando,i=a.nodeType,j=i?m.cache:a,k=i?a[h]:a[h]&&h;if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!P(d):!m.isEmptyObject(d))return}(c||(delete g[h].data,P(g[h])))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},_data:function(a,b,c){return Q(a,b,c,!0)},_removeData:function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=m.data(f),1===f.nodeType&&!m._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=m.camelCase(d.slice(5)),O(f,d,e[d])));m._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){m.data(this,a)}):arguments.length>1?this.each(function(){m.data(this,a,b)}):f?O(f,a,m.data(f,a)):void 0},removeData:function(a){return this.each(function(){m.removeData(this,a)})}}),m.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=m._data(a,b),c&&(!d||m.isArray(c)?d=m._data(a,b,m.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=m.queue(a,b),d=c.length,e=c.shift(),f=m._queueHooks(a,b),g=function(){m.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return m._data(a,c)||m._data(a,c,{empty:m.Callbacks("once memory").add(function(){m._removeData(a,b+"queue"),m._removeData(a,c)})})}}),m.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthh;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},W=/^(?:checkbox|radio)$/i;!function(){var a=y.createElement("input"),b=y.createElement("div"),c=y.createDocumentFragment();if(b.innerHTML="
a",k.leadingWhitespace=3===b.firstChild.nodeType,k.tbody=!b.getElementsByTagName("tbody").length,k.htmlSerialize=!!b.getElementsByTagName("link").length,k.html5Clone="<:nav>"!==y.createElement("nav").cloneNode(!0).outerHTML,a.type="checkbox",a.checked=!0,c.appendChild(a),k.appendChecked=a.checked,b.innerHTML="",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,c.appendChild(b),b.innerHTML="",k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,k.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){k.noCloneEvent=!1}),b.cloneNode(!0).click()),null==k.deleteExpando){k.deleteExpando=!0;try{delete b.test}catch(d){k.deleteExpando=!1}}}(),function(){var b,c,d=y.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(k[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),k[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var X=/^(?:input|select|textarea)$/i,Y=/^key/,Z=/^(?:mouse|pointer|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=/^([^.]*)(?:\.(.+)|)$/;function aa(){return!0}function ba(){return!1}function ca(){try{return y.activeElement}catch(a){}}m.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=m.guid++),(g=r.events)||(g=r.events={}),(k=r.handle)||(k=r.handle=function(a){return typeof m===K||a&&m.event.triggered===a.type?void 0:m.event.dispatch.apply(k.elem,arguments)},k.elem=a),b=(b||"").match(E)||[""],h=b.length;while(h--)f=_.exec(b[h])||[],o=q=f[1],p=(f[2]||"").split(".").sort(),o&&(j=m.event.special[o]||{},o=(e?j.delegateType:j.bindType)||o,j=m.event.special[o]||{},l=m.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&m.expr.match.needsContext.test(e),namespace:p.join(".")},i),(n=g[o])||(n=g[o]=[],n.delegateCount=0,j.setup&&j.setup.call(a,d,p,k)!==!1||(a.addEventListener?a.addEventListener(o,k,!1):a.attachEvent&&a.attachEvent("on"+o,k))),j.add&&(j.add.call(a,l),l.handler.guid||(l.handler.guid=c.guid)),e?n.splice(n.delegateCount++,0,l):n.push(l),m.event.global[o]=!0);a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m.hasData(a)&&m._data(a);if(r&&(k=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=_.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=m.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,n=k[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=n.length;while(f--)g=n[f],!e&&q!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(n.splice(f,1),g.selector&&n.delegateCount--,l.remove&&l.remove.call(a,g));i&&!n.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||m.removeEvent(a,o,r.handle),delete k[o])}else for(o in k)m.event.remove(a,o+b[j],c,d,!0);m.isEmptyObject(k)&&(delete r.handle,m._removeData(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,n,o=[d||y],p=j.call(b,"type")?b.type:b,q=j.call(b,"namespace")?b.namespace.split("."):[];if(h=l=d=d||y,3!==d.nodeType&&8!==d.nodeType&&!$.test(p+m.event.triggered)&&(p.indexOf(".")>=0&&(q=p.split("."),p=q.shift(),q.sort()),g=p.indexOf(":")<0&&"on"+p,b=b[m.expando]?b:new m.Event(p,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=q.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:m.makeArray(c,[b]),k=m.event.special[p]||{},e||!k.trigger||k.trigger.apply(d,c)!==!1)){if(!e&&!k.noBubble&&!m.isWindow(d)){for(i=k.delegateType||p,$.test(i+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),l=h;l===(d.ownerDocument||y)&&o.push(l.defaultView||l.parentWindow||a)}n=0;while((h=o[n++])&&!b.isPropagationStopped())b.type=n>1?i:k.bindType||p,f=(m._data(h,"events")||{})[b.type]&&m._data(h,"handle"),f&&f.apply(h,c),f=g&&h[g],f&&f.apply&&m.acceptData(h)&&(b.result=f.apply(h,c),b.result===!1&&b.preventDefault());if(b.type=p,!e&&!b.isDefaultPrevented()&&(!k._default||k._default.apply(o.pop(),c)===!1)&&m.acceptData(d)&&g&&d[p]&&!m.isWindow(d)){l=d[g],l&&(d[g]=null),m.event.triggered=p;try{d[p]()}catch(r){}m.event.triggered=void 0,l&&(d[g]=l)}return b.result}},dispatch:function(a){a=m.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(m._data(this,"events")||{})[a.type]||[],k=m.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=m.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,g=0;while((e=f.handlers[g++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(e.namespace))&&(a.handleObj=e,a.data=e.data,c=((m.event.special[e.origType]||{}).handle||e.handler).apply(f.elem,i),void 0!==c&&(a.result=c)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!=this;i=i.parentNode||this)if(1===i.nodeType&&(i.disabled!==!0||"click"!==a.type)){for(e=[],f=0;h>f;f++)d=b[f],c=d.selector+" ",void 0===e[c]&&(e[c]=d.needsContext?m(c,this).index(i)>=0:m.find(c,this,null,[i]).length),e[c]&&e.push(d);e.length&&g.push({elem:i,handlers:e})}return h]","i"),ha=/^\s+/,ia=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,ja=/<([\w:]+)/,ka=/\s*$/g,ra={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],_default:k.htmlSerialize?[0,"",""]:[1,"X
","
"]},sa=da(y),ta=sa.appendChild(y.createElement("div"));ra.optgroup=ra.option,ra.tbody=ra.tfoot=ra.colgroup=ra.caption=ra.thead,ra.th=ra.td;function ua(a,b){var c,d,e=0,f=typeof a.getElementsByTagName!==K?a.getElementsByTagName(b||"*"):typeof a.querySelectorAll!==K?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||m.nodeName(d,b)?f.push(d):m.merge(f,ua(d,b));return void 0===b||b&&m.nodeName(a,b)?m.merge([a],f):f}function va(a){W.test(a.type)&&(a.defaultChecked=a.checked)}function wa(a,b){return m.nodeName(a,"table")&&m.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function xa(a){return a.type=(null!==m.find.attr(a,"type"))+"/"+a.type,a}function ya(a){var b=pa.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function za(a,b){for(var c,d=0;null!=(c=a[d]);d++)m._data(c,"globalEval",!b||m._data(b[d],"globalEval"))}function Aa(a,b){if(1===b.nodeType&&m.hasData(a)){var c,d,e,f=m._data(a),g=m._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)m.event.add(b,c,h[c][d])}g.data&&(g.data=m.extend({},g.data))}}function Ba(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!k.noCloneEvent&&b[m.expando]){e=m._data(b);for(d in e.events)m.removeEvent(b,d,e.handle);b.removeAttribute(m.expando)}"script"===c&&b.text!==a.text?(xa(b).text=a.text,ya(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),k.html5Clone&&a.innerHTML&&!m.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&W.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}m.extend({clone:function(a,b,c){var d,e,f,g,h,i=m.contains(a.ownerDocument,a);if(k.html5Clone||m.isXMLDoc(a)||!ga.test("<"+a.nodeName+">")?f=a.cloneNode(!0):(ta.innerHTML=a.outerHTML,ta.removeChild(f=ta.firstChild)),!(k.noCloneEvent&&k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||m.isXMLDoc(a)))for(d=ua(f),h=ua(a),g=0;null!=(e=h[g]);++g)d[g]&&Ba(e,d[g]);if(b)if(c)for(h=h||ua(a),d=d||ua(f),g=0;null!=(e=h[g]);g++)Aa(e,d[g]);else Aa(a,f);return d=ua(f,"script"),d.length>0&&za(d,!i&&ua(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,l,n=a.length,o=da(b),p=[],q=0;n>q;q++)if(f=a[q],f||0===f)if("object"===m.type(f))m.merge(p,f.nodeType?[f]:f);else if(la.test(f)){h=h||o.appendChild(b.createElement("div")),i=(ja.exec(f)||["",""])[1].toLowerCase(),l=ra[i]||ra._default,h.innerHTML=l[1]+f.replace(ia,"<$1>")+l[2],e=l[0];while(e--)h=h.lastChild;if(!k.leadingWhitespace&&ha.test(f)&&p.push(b.createTextNode(ha.exec(f)[0])),!k.tbody){f="table"!==i||ka.test(f)?""!==l[1]||ka.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;while(e--)m.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j)}m.merge(p,h.childNodes),h.textContent="";while(h.firstChild)h.removeChild(h.firstChild);h=o.lastChild}else p.push(b.createTextNode(f));h&&o.removeChild(h),k.appendChecked||m.grep(ua(p,"input"),va),q=0;while(f=p[q++])if((!d||-1===m.inArray(f,d))&&(g=m.contains(f.ownerDocument,f),h=ua(o.appendChild(f),"script"),g&&za(h),c)){e=0;while(f=h[e++])oa.test(f.type||"")&&c.push(f)}return h=null,o},cleanData:function(a,b){for(var d,e,f,g,h=0,i=m.expando,j=m.cache,l=k.deleteExpando,n=m.event.special;null!=(d=a[h]);h++)if((b||m.acceptData(d))&&(f=d[i],g=f&&j[f])){if(g.events)for(e in g.events)n[e]?m.event.remove(d,e):m.removeEvent(d,e,g.handle);j[f]&&(delete j[f],l?delete d[i]:typeof d.removeAttribute!==K?d.removeAttribute(i):d[i]=null,c.push(f))}}}),m.fn.extend({text:function(a){return V(this,function(a){return void 0===a?m.text(this):this.empty().append((this[0]&&this[0].ownerDocument||y).createTextNode(a))},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wa(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wa(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?m.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||m.cleanData(ua(c)),c.parentNode&&(b&&m.contains(c.ownerDocument,c)&&za(ua(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){1===a.nodeType&&m.cleanData(ua(a,!1));while(a.firstChild)a.removeChild(a.firstChild);a.options&&m.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return m.clone(this,a,b)})},html:function(a){return V(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a)return 1===b.nodeType?b.innerHTML.replace(fa,""):void 0;if(!("string"!=typeof a||ma.test(a)||!k.htmlSerialize&&ga.test(a)||!k.leadingWhitespace&&ha.test(a)||ra[(ja.exec(a)||["",""])[1].toLowerCase()])){a=a.replace(ia,"<$1>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(m.cleanData(ua(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,m.cleanData(ua(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,n=this,o=l-1,p=a[0],q=m.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&na.test(p))return this.each(function(c){var d=n.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(i=m.buildFragment(a,this[0].ownerDocument,!1,this),c=i.firstChild,1===i.childNodes.length&&(i=c),c)){for(g=m.map(ua(i,"script"),xa),f=g.length;l>j;j++)d=i,j!==o&&(d=m.clone(d,!0,!0),f&&m.merge(g,ua(d,"script"))),b.call(this[j],d,j);if(f)for(h=g[g.length-1].ownerDocument,m.map(g,ya),j=0;f>j;j++)d=g[j],oa.test(d.type||"")&&!m._data(d,"globalEval")&&m.contains(h,d)&&(d.src?m._evalUrl&&m._evalUrl(d.src):m.globalEval((d.text||d.textContent||d.innerHTML||"").replace(qa,"")));i=c=null}return this}}),m.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){m.fn[a]=function(a){for(var c,d=0,e=[],g=m(a),h=g.length-1;h>=d;d++)c=d===h?this:this.clone(!0),m(g[d])[b](c),f.apply(e,c.get());return this.pushStack(e)}});var Ca,Da={};function Ea(b,c){var d,e=m(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:m.css(e[0],"display");return e.detach(),f}function Fa(a){var b=y,c=Da[a];return c||(c=Ea(a,b),"none"!==c&&c||(Ca=(Ca||m("