import{a as ai,b as li,i as hi}from"./lit-element-BUNo9pnf.js";import{t as ui}from"./custom-element-BhZVzxrc.js";import{n as Zt}from"./property-MreHcJY-.js";import{e as ci}from"./query-BApjzB0v.js";import{c as di}from"./_commonjsHelpers-Cpj98o6Y.js";var Qt={exports:{}};/*! For license information please see opensheetmusicdisplay.min.js.LICENSE.txt */(function(rt,gt){(function(bt,pt){rt.exports=pt()})(di,()=>(()=>{var bt={1710(de,g,c){de.exports=function l(s,u,r){function i(h,t){if(!u[h]){if(!s[h]){if(o)return o(h,!0);var f=new Error("Cannot find module '"+h+"'");throw f.code="MODULE_NOT_FOUND",f}var p=u[h]={exports:{}};s[h][0].call(p.exports,function(m){return i(s[h][1][m]||m)},p,p.exports,l,s,u,r)}return u[h].exports}for(var o=void 0,n=0;n>2,m=(3&h)<<4|t>>4,x=1>6:64,y=2>4,t=(15&p)<<4|(m=o.indexOf(n.charAt(y++)))>>2,f=(3&m)<<6|(x=o.indexOf(n.charAt(y++))),M[d++]=h,m!==64&&(M[d++]=t),x!==64&&(M[d++]=f);return M}},{"./support":30,"./utils":32}],2:[function(l,s,u){var r=l("./external"),i=l("./stream/DataWorker"),o=l("./stream/Crc32Probe"),n=l("./stream/DataLengthProbe");function h(t,f,p,m,x){this.compressedSize=t,this.uncompressedSize=f,this.crc32=p,this.compression=m,this.compressedContent=x}h.prototype={getContentWorker:function(){var t=new i(r.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new n("data_length")),f=this;return t.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),t},getCompressedWorker:function(){return new i(r.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},h.createWorkerFrom=function(t,f,p){return t.pipe(new o).pipe(new n("uncompressedSize")).pipe(f.compressWorker(p)).pipe(new n("compressedSize")).withStreamInfo("compression",f)},s.exports=h},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(l,s,u){var r=l("./stream/GenericWorker");u.STORE={magic:"\0\0",compressWorker:function(){return new r("STORE compression")},uncompressWorker:function(){return new r("STORE decompression")}},u.DEFLATE=l("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(l,s,u){var r=l("./utils"),i=function(){for(var o,n=[],h=0;h<256;h++){o=h;for(var t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;n[h]=o}return n}();s.exports=function(o,n){return o!==void 0&&o.length?r.getTypeOf(o)!=="string"?function(h,t,f){var p=i,m=0+f;h^=-1;for(var x=0;x>>8^p[255&(h^t[x])];return-1^h}(0|n,o,o.length):function(h,t,f){var p=i,m=0+f;h^=-1;for(var x=0;x>>8^p[255&(h^t.charCodeAt(x))];return-1^h}(0|n,o,o.length):0}},{"./utils":32}],5:[function(l,s,u){u.base64=!1,u.binary=!1,u.dir=!1,u.createFolders=!0,u.date=null,u.compression=null,u.compressionOptions=null,u.comment=null,u.unixPermissions=null,u.dosPermissions=null},{}],6:[function(l,s,u){var r;r=typeof Promise<"u"?Promise:l("lie"),s.exports={Promise:r}},{lie:37}],7:[function(l,s,u){var r=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",i=l("pako"),o=l("./utils"),n=l("./stream/GenericWorker"),h=r?"uint8array":"array";function t(f,p){n.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=p,this.meta={}}u.magic="\b\0",o.inherits(t,n),t.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(h,f.data),!1)},t.prototype.flush=function(){n.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},t.prototype.cleanUp=function(){n.prototype.cleanUp.call(this),this._pako=null},t.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(p){f.push({data:p,meta:f.meta})}},u.compressWorker=function(f){return new t("Deflate",f)},u.uncompressWorker=function(){return new t("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(l,s,u){function r(m,x){var y,d="";for(y=0;y>>=8;return d}function i(m,x,y,d,S,M){var E,L,I=m.file,T=m.compression,A=M!==h.utf8encode,v=o.transformTo("string",M(I.name)),B=o.transformTo("string",h.utf8encode(I.name)),D=I.comment,_=o.transformTo("string",M(D)),F=o.transformTo("string",h.utf8encode(D)),k=B.length!==I.name.length,j=F.length!==D.length,P="",G="",Y="",X=I.dir,ie=I.date,oe={crc32:0,compressedSize:0,uncompressedSize:0};x&&!y||(oe.crc32=m.crc32,oe.compressedSize=m.compressedSize,oe.uncompressedSize=m.uncompressedSize);var $=0;x&&($|=8),A||!k&&!j||($|=2048);var Q=0,ne=0;X&&(Q|=16),S==="UNIX"?(ne=798,Q|=function(N,R){var O=N;return N||(O=R?16893:33204),(65535&O)<<16}(I.unixPermissions,X)):(ne=20,Q|=function(N){return 63&(N||0)}(I.dosPermissions)),E=ie.getUTCHours(),E<<=6,E|=ie.getUTCMinutes(),E<<=5,E|=ie.getUTCSeconds()/2,L=ie.getUTCFullYear()-1980,L<<=4,L|=ie.getUTCMonth()+1,L<<=5,L|=ie.getUTCDate(),k&&(G=r(1,1)+r(t(v),4)+B,P+="up"+r(G.length,2)+G),j&&(Y=r(1,1)+r(t(_),4)+F,P+="uc"+r(Y.length,2)+Y);var ee="";return ee+=` \0`,ee+=r($,2),ee+=T.magic,ee+=r(E,2),ee+=r(L,2),ee+=r(oe.crc32,4),ee+=r(oe.compressedSize,4),ee+=r(oe.uncompressedSize,4),ee+=r(v.length,2),ee+=r(P.length,2),{fileRecord:f.LOCAL_FILE_HEADER+ee+v+P,dirRecord:f.CENTRAL_FILE_HEADER+r(ne,2)+ee+r(_.length,2)+"\0\0\0\0"+r(Q,4)+r(d,4)+v+P+_}}var o=l("../utils"),n=l("../stream/GenericWorker"),h=l("../utf8"),t=l("../crc32"),f=l("../signature");function p(m,x,y,d){n.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=x,this.zipPlatform=y,this.encodeFileName=d,this.streamFiles=m,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(p,n),p.prototype.push=function(m){var x=m.meta.percent||0,y=this.entriesCount,d=this._sources.length;this.accumulate?this.contentBuffer.push(m):(this.bytesWritten+=m.data.length,n.prototype.push.call(this,{data:m.data,meta:{currentFile:this.currentFile,percent:y?(x+100*(y-d-1))/y:100}}))},p.prototype.openedSource=function(m){this.currentSourceOffset=this.bytesWritten,this.currentFile=m.file.name;var x=this.streamFiles&&!m.file.dir;if(x){var y=i(m,x,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:y.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(m){this.accumulate=!1;var x=this.streamFiles&&!m.file.dir,y=i(m,x,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(y.dirRecord),x)this.push({data:function(d){return f.DATA_DESCRIPTOR+r(d.crc32,4)+r(d.compressedSize,4)+r(d.uncompressedSize,4)}(m),meta:{percent:100}});else for(this.push({data:y.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var m=this.bytesWritten,x=0;x=this.index;n--)h=(h<<8)+this.byteAt(n);return this.index+=o,h},readString:function(o){return r.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},s.exports=i},{"../utils":32}],19:[function(l,s,u){var r=l("./Uint8ArrayReader");function i(o){r.call(this,o)}l("../utils").inherits(i,r),i.prototype.readData=function(o){this.checkOffset(o);var n=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,n},s.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(l,s,u){var r=l("./DataReader");function i(o){r.call(this,o)}l("../utils").inherits(i,r),i.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},i.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},i.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},i.prototype.readData=function(o){this.checkOffset(o);var n=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,n},s.exports=i},{"../utils":32,"./DataReader":18}],21:[function(l,s,u){var r=l("./ArrayReader");function i(o){r.call(this,o)}l("../utils").inherits(i,r),i.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var n=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,n},s.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(l,s,u){var r=l("../utils"),i=l("../support"),o=l("./ArrayReader"),n=l("./StringReader"),h=l("./NodeBufferReader"),t=l("./Uint8ArrayReader");s.exports=function(f){var p=r.getTypeOf(f);return r.checkSupport(p),p!=="string"||i.uint8array?p==="nodebuffer"?new h(f):i.uint8array?new t(r.transformTo("uint8array",f)):new o(r.transformTo("array",f)):new n(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(l,s,u){u.LOCAL_FILE_HEADER="PK",u.CENTRAL_FILE_HEADER="PK",u.CENTRAL_DIRECTORY_END="PK",u.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",u.ZIP64_CENTRAL_DIRECTORY_END="PK",u.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(l,s,u){var r=l("./GenericWorker"),i=l("../utils");function o(n){r.call(this,"ConvertWorker to "+n),this.destType=n}i.inherits(o,r),o.prototype.processChunk=function(n){this.push({data:i.transformTo(this.destType,n.data),meta:n.meta})},s.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(l,s,u){var r=l("./GenericWorker"),i=l("../crc32");function o(){r.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}l("../utils").inherits(o,r),o.prototype.processChunk=function(n){this.streamInfo.crc32=i(n.data,this.streamInfo.crc32||0),this.push(n)},s.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(l,s,u){var r=l("../utils"),i=l("./GenericWorker");function o(n){i.call(this,"DataLengthProbe for "+n),this.propName=n,this.withStreamInfo(n,0)}r.inherits(o,i),o.prototype.processChunk=function(n){if(n){var h=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=h+n.data.length}i.prototype.processChunk.call(this,n)},s.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(l,s,u){var r=l("../utils"),i=l("./GenericWorker");function o(n){i.call(this,"DataWorker");var h=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,n.then(function(t){h.dataIsReady=!0,h.data=t,h.max=t&&t.length||0,h.type=r.getTypeOf(t),h.isPaused||h._tickAndRepeat()},function(t){h.error(t)})}r.inherits(o,i),o.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,r.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(r.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var n=null,h=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":n=this.data.substring(this.index,h);break;case"uint8array":n=this.data.subarray(this.index,h);break;case"array":case"nodebuffer":n=this.data.slice(this.index,h)}return this.index=h,this.push({data:n,meta:{percent:this.max?this.index/this.max*100:0}})},s.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(l,s,u){function r(i){this.name=i||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}r.prototype={push:function(i){this.emit("data",i)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(i){this.emit("error",i)}return!0},error:function(i){return!this.isFinished&&(this.isPaused?this.generatedError=i:(this.isFinished=!0,this.emit("error",i),this.previous&&this.previous.error(i),this.cleanUp()),!0)},on:function(i,o){return this._listeners[i].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(i,o){if(this._listeners[i])for(var n=0;n "+i:i}},s.exports=r},{}],29:[function(l,s,u){var r=l("../utils"),i=l("./ConvertWorker"),o=l("./GenericWorker"),n=l("../base64"),h=l("../support"),t=l("../external"),f=null;if(h.nodestream)try{f=l("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(m,x,y){var d=x;switch(x){case"blob":case"arraybuffer":d="uint8array";break;case"base64":d="string"}try{this._internalType=d,this._outputType=x,this._mimeType=y,r.checkSupport(d),this._worker=m.pipe(new i(d)),m.lock()}catch(S){this._worker=new o("error"),this._worker.error(S)}}p.prototype={accumulate:function(m){return function(x,y){return new t.Promise(function(d,S){var M=[],E=x._internalType,L=x._outputType,I=x._mimeType;x.on("data",function(T,A){M.push(T),y&&y(A)}).on("error",function(T){M=[],S(T)}).on("end",function(){try{var T=function(A,v,B){switch(A){case"blob":return r.newBlob(r.transformTo("arraybuffer",v),B);case"base64":return n.encode(v);default:return r.transformTo(A,v)}}(L,function(A,v){var B,D=0,_=null,F=0;for(B=0;B"u")u.blob=!1;else{var r=new ArrayBuffer(0);try{u.blob=new Blob([r],{type:"application/zip"}).size===0}catch{try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(r),u.blob=i.getBlob("application/zip").size===0}catch{u.blob=!1}}}try{u.nodestream=!!l("readable-stream").Readable}catch{u.nodestream=!1}},{"readable-stream":16}],31:[function(l,s,u){for(var r=l("./utils"),i=l("./support"),o=l("./nodejsUtils"),n=l("./stream/GenericWorker"),h=new Array(256),t=0;t<256;t++)h[t]=252<=t?6:248<=t?5:240<=t?4:224<=t?3:192<=t?2:1;function f(){n.call(this,"utf-8 decode"),this.leftOver=null}function p(){n.call(this,"utf-8 encode")}h[254]=h[254]=1,u.utf8encode=function(m){return i.nodebuffer?o.newBufferFrom(m,"utf-8"):function(x){var y,d,S,M,E,L=x.length,I=0;for(M=0;M>>6:(d<65536?y[E++]=224|d>>>12:(y[E++]=240|d>>>18,y[E++]=128|d>>>12&63),y[E++]=128|d>>>6&63),y[E++]=128|63&d);return y}(m)},u.utf8decode=function(m){return i.nodebuffer?r.transformTo("nodebuffer",m).toString("utf-8"):function(x){var y,d,S,M,E=x.length,L=new Array(2*E);for(y=d=0;y>10&1023,L[d++]=56320|1023&S)}return L.length!==d&&(L.subarray?L=L.subarray(0,d):L.length=d),r.applyFromCharCode(L)}(m=r.transformTo(i.uint8array?"uint8array":"array",m))},r.inherits(f,n),f.prototype.processChunk=function(m){var x=r.transformTo(i.uint8array?"uint8array":"array",m.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var y=x;(x=new Uint8Array(y.length+this.leftOver.length)).set(this.leftOver,0),x.set(y,this.leftOver.length)}else x=this.leftOver.concat(x);this.leftOver=null}var d=function(M,E){var L;for((E=E||M.length)>M.length&&(E=M.length),L=E-1;0<=L&&(192&M[L])==128;)L--;return L<0||L===0?E:L+h[M[L]]>E?L:E}(x),S=x;d!==x.length&&(i.uint8array?(S=x.subarray(0,d),this.leftOver=x.subarray(d,x.length)):(S=x.slice(0,d),this.leftOver=x.slice(d,x.length))),this.push({data:u.utf8decode(S),meta:m.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:u.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},u.Utf8DecodeWorker=f,r.inherits(p,n),p.prototype.processChunk=function(m){this.push({data:u.utf8encode(m.data),meta:m.meta})},u.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(l,s,u){var r=l("./support"),i=l("./base64"),o=l("./nodejsUtils"),n=l("./external");function h(y){return y}function t(y,d){for(var S=0;S>8;this.dir=!!(16&this.externalFileAttributes),m==0&&(this.dosPermissions=63&this.externalFileAttributes),m==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var m=r(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=m.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=m.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=m.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=m.readInt(4))}},readExtraFields:function(m){var x,y,d,S=m.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});m.index+4>>6:(m<65536?p[d++]=224|m>>>12:(p[d++]=240|m>>>18,p[d++]=128|m>>>12&63),p[d++]=128|m>>>6&63),p[d++]=128|63&m);return p},u.buf2binstring=function(f){return t(f,f.length)},u.binstring2buf=function(f){for(var p=new r.Buf8(f.length),m=0,x=p.length;m>10&1023,M[x++]=56320|1023&y)}return t(M,x)},u.utf8border=function(f,p){var m;for((p=p||f.length)>f.length&&(p=f.length),m=p-1;0<=m&&(192&f[m])==128;)m--;return m<0||m===0?p:m+n[f[m]]>p?m:p}},{"./common":41}],43:[function(l,s,u){s.exports=function(r,i,o,n){for(var h=65535&r,t=r>>>16&65535,f=0;o!==0;){for(o-=f=2e3>>1:i>>>1;o[n]=i}return o}();s.exports=function(i,o,n,h){var t=r,f=h+n;i^=-1;for(var p=h;p>>8^t[255&(i^o[p])];return-1^i}},{}],46:[function(l,s,u){var r,i=l("../utils/common"),o=l("./trees"),n=l("./adler32"),h=l("./crc32"),t=l("./messages"),f=-2,p=258,m=262,x=113;function y(P,G){return P.msg=t[G],G}function d(P){return(P<<1)-(4P.avail_out&&(Y=P.avail_out),Y!==0&&(i.arraySet(P.output,G.pending_buf,G.pending_out,Y,P.next_out),P.next_out+=Y,G.pending_out+=Y,P.total_out+=Y,P.avail_out-=Y,G.pending-=Y,G.pending===0&&(G.pending_out=0))}function E(P,G){o._tr_flush_block(P,0<=P.block_start?P.block_start:-1,P.strstart-P.block_start,G),P.block_start=P.strstart,M(P.strm)}function L(P,G){P.pending_buf[P.pending++]=G}function I(P,G){P.pending_buf[P.pending++]=G>>>8&255,P.pending_buf[P.pending++]=255&G}function T(P,G){var Y,X,ie=P.max_chain_length,oe=P.strstart,$=P.prev_length,Q=P.nice_match,ne=P.strstart>P.w_size-m?P.strstart-(P.w_size-m):0,ee=P.window,N=P.w_mask,R=P.prev,O=P.strstart+p,U=ee[oe+$-1],H=ee[oe+$];P.prev_length>=P.good_match&&(ie>>=2),Q>P.lookahead&&(Q=P.lookahead);do if(ee[(Y=G)+$]===H&&ee[Y+$-1]===U&&ee[Y]===ee[oe]&&ee[++Y]===ee[oe+1]){oe+=2,Y++;do;while(ee[++oe]===ee[++Y]&&ee[++oe]===ee[++Y]&&ee[++oe]===ee[++Y]&&ee[++oe]===ee[++Y]&&ee[++oe]===ee[++Y]&&ee[++oe]===ee[++Y]&&ee[++oe]===ee[++Y]&&ee[++oe]===ee[++Y]&&oene&&--ie!=0);return $<=P.lookahead?$:P.lookahead}function A(P){var G,Y,X,ie,oe,$,Q,ne,ee,N,R=P.w_size;do{if(ie=P.window_size-P.lookahead-P.strstart,P.strstart>=R+(R-m)){for(i.arraySet(P.window,P.window,R,R,0),P.match_start-=R,P.strstart-=R,P.block_start-=R,G=Y=P.hash_size;X=P.head[--G],P.head[G]=R<=X?X-R:0,--Y;);for(G=Y=R;X=P.prev[--G],P.prev[G]=R<=X?X-R:0,--Y;);ie+=R}if(P.strm.avail_in===0)break;if($=P.strm,Q=P.window,ne=P.strstart+P.lookahead,N=void 0,(ee=ie)<(N=$.avail_in)&&(N=ee),Y=N===0?0:($.avail_in-=N,i.arraySet(Q,$.input,$.next_in,N,ne),$.state.wrap===1?$.adler=n($.adler,Q,N,ne):$.state.wrap===2&&($.adler=h($.adler,Q,N,ne)),$.next_in+=N,$.total_in+=N,N),P.lookahead+=Y,P.lookahead+P.insert>=3)for(oe=P.strstart-P.insert,P.ins_h=P.window[oe],P.ins_h=(P.ins_h<=3&&(P.ins_h=(P.ins_h<=3)if(X=o._tr_tally(P,P.strstart-P.match_start,P.match_length-3),P.lookahead-=P.match_length,P.match_length<=P.max_lazy_match&&P.lookahead>=3){for(P.match_length--;P.strstart++,P.ins_h=(P.ins_h<=3&&(P.ins_h=(P.ins_h<=3&&P.match_length<=P.prev_length){for(ie=P.strstart+P.lookahead-3,X=o._tr_tally(P,P.strstart-1-P.prev_match,P.prev_length-3),P.lookahead-=P.prev_length-1,P.prev_length-=2;++P.strstart<=ie&&(P.ins_h=(P.ins_h<P.pending_buf_size-5&&(Y=P.pending_buf_size-5);;){if(P.lookahead<=1){if(A(P),P.lookahead===0&&G===0)return 1;if(P.lookahead===0)break}P.strstart+=P.lookahead,P.lookahead=0;var X=P.block_start+Y;if((P.strstart===0||P.strstart>=X)&&(P.lookahead=P.strstart-X,P.strstart=X,E(P,!1),P.strm.avail_out===0)||P.strstart-P.block_start>=P.w_size-m&&(E(P,!1),P.strm.avail_out===0))return 1}return P.insert=0,G===4?(E(P,!0),P.strm.avail_out===0?3:4):(P.strstart>P.block_start&&(E(P,!1),P.strm.avail_out),1)}),new D(4,4,8,4,v),new D(4,5,16,8,v),new D(4,6,32,32,v),new D(4,4,16,16,B),new D(8,16,32,32,B),new D(8,16,128,128,B),new D(8,32,128,256,B),new D(32,128,258,1024,B),new D(32,258,258,4096,B)],u.deflateInit=function(P,G){return j(P,G,8,15,8,0)},u.deflateInit2=j,u.deflateReset=k,u.deflateResetKeep=F,u.deflateSetHeader=function(P,G){return P&&P.state?P.state.wrap!==2?f:(P.state.gzhead=G,0):f},u.deflate=function(P,G){var Y,X,ie,oe;if(!P||!P.state||5>8&255),L(X,X.gzhead.time>>16&255),L(X,X.gzhead.time>>24&255),L(X,X.level===9?2:2<=X.strategy||X.level<2?4:0),L(X,255&X.gzhead.os),X.gzhead.extra&&X.gzhead.extra.length&&(L(X,255&X.gzhead.extra.length),L(X,X.gzhead.extra.length>>8&255)),X.gzhead.hcrc&&(P.adler=h(P.adler,X.pending_buf,X.pending,0)),X.gzindex=0,X.status=69):(L(X,0),L(X,0),L(X,0),L(X,0),L(X,0),L(X,X.level===9?2:2<=X.strategy||X.level<2?4:0),L(X,3),X.status=x);else{var $=8+(X.w_bits-8<<4)<<8;$|=(2<=X.strategy||X.level<2?0:X.level<6?1:X.level===6?2:3)<<6,X.strstart!==0&&($|=32),$+=31-$%31,X.status=x,I(X,$),X.strstart!==0&&(I(X,P.adler>>>16),I(X,65535&P.adler)),P.adler=1}if(X.status===69)if(X.gzhead.extra){for(ie=X.pending;X.gzindex<(65535&X.gzhead.extra.length)&&(X.pending!==X.pending_buf_size||(X.gzhead.hcrc&&X.pending>ie&&(P.adler=h(P.adler,X.pending_buf,X.pending-ie,ie)),M(P),ie=X.pending,X.pending!==X.pending_buf_size));)L(X,255&X.gzhead.extra[X.gzindex]),X.gzindex++;X.gzhead.hcrc&&X.pending>ie&&(P.adler=h(P.adler,X.pending_buf,X.pending-ie,ie)),X.gzindex===X.gzhead.extra.length&&(X.gzindex=0,X.status=73)}else X.status=73;if(X.status===73)if(X.gzhead.name){ie=X.pending;do{if(X.pending===X.pending_buf_size&&(X.gzhead.hcrc&&X.pending>ie&&(P.adler=h(P.adler,X.pending_buf,X.pending-ie,ie)),M(P),ie=X.pending,X.pending===X.pending_buf_size)){oe=1;break}oe=X.gzindexie&&(P.adler=h(P.adler,X.pending_buf,X.pending-ie,ie)),oe===0&&(X.gzindex=0,X.status=91)}else X.status=91;if(X.status===91)if(X.gzhead.comment){ie=X.pending;do{if(X.pending===X.pending_buf_size&&(X.gzhead.hcrc&&X.pending>ie&&(P.adler=h(P.adler,X.pending_buf,X.pending-ie,ie)),M(P),ie=X.pending,X.pending===X.pending_buf_size)){oe=1;break}oe=X.gzindexie&&(P.adler=h(P.adler,X.pending_buf,X.pending-ie,ie)),oe===0&&(X.status=103)}else X.status=103;if(X.status===103&&(X.gzhead.hcrc?(X.pending+2>X.pending_buf_size&&M(P),X.pending+2<=X.pending_buf_size&&(L(X,255&P.adler),L(X,P.adler>>8&255),P.adler=0,X.status=x)):X.status=x),X.pending!==0){if(M(P),P.avail_out===0)return X.last_flush=-1,0}else if(P.avail_in===0&&d(G)<=d(Y)&&G!==4)return y(P,-5);if(X.status===666&&P.avail_in!==0)return y(P,-5);if(P.avail_in!==0||X.lookahead!==0||G!==0&&X.status!==666){var Q=X.strategy===2?function(ne,ee){for(var N;;){if(ne.lookahead===0&&(A(ne),ne.lookahead===0)){if(ee===0)return 1;break}if(ne.match_length=0,N=o._tr_tally(ne,0,ne.window[ne.strstart]),ne.lookahead--,ne.strstart++,N&&(E(ne,!1),ne.strm.avail_out===0))return 1}return ne.insert=0,ee===4?(E(ne,!0),ne.strm.avail_out===0?3:4):ne.last_lit&&(E(ne,!1),ne.strm.avail_out===0)?1:2}(X,G):X.strategy===3?function(ne,ee){for(var N,R,O,U,H=ne.window;;){if(ne.lookahead<=p){if(A(ne),ne.lookahead<=p&&ee===0)return 1;if(ne.lookahead===0)break}if(ne.match_length=0,ne.lookahead>=3&&0ne.lookahead&&(ne.match_length=ne.lookahead)}if(ne.match_length>=3?(N=o._tr_tally(ne,1,ne.match_length-3),ne.lookahead-=ne.match_length,ne.strstart+=ne.match_length,ne.match_length=0):(N=o._tr_tally(ne,0,ne.window[ne.strstart]),ne.lookahead--,ne.strstart++),N&&(E(ne,!1),ne.strm.avail_out===0))return 1}return ne.insert=0,ee===4?(E(ne,!0),ne.strm.avail_out===0?3:4):ne.last_lit&&(E(ne,!1),ne.strm.avail_out===0)?1:2}(X,G):r[X.level].func(X,G);if(Q!==3&&Q!==4||(X.status=666),Q===1||Q===3)return P.avail_out===0&&(X.last_flush=-1),0;if(Q===2&&(G===1?o._tr_align(X):G!==5&&(o._tr_stored_block(X,0,0,!1),G===3&&(S(X.head),X.lookahead===0&&(X.strstart=0,X.block_start=0,X.insert=0))),M(P),P.avail_out===0))return X.last_flush=-1,0}return G!==4?0:X.wrap<=0?1:(X.wrap===2?(L(X,255&P.adler),L(X,P.adler>>8&255),L(X,P.adler>>16&255),L(X,P.adler>>24&255),L(X,255&P.total_in),L(X,P.total_in>>8&255),L(X,P.total_in>>16&255),L(X,P.total_in>>24&255)):(I(X,P.adler>>>16),I(X,65535&P.adler)),M(P),0=Y.w_size&&(oe===0&&(S(Y.head),Y.strstart=0,Y.block_start=0,Y.insert=0),ee=new i.Buf8(Y.w_size),i.arraySet(ee,G,N-Y.w_size,Y.w_size,0),G=ee,N=Y.w_size),$=P.avail_in,Q=P.next_in,ne=P.input,P.avail_in=N,P.next_in=0,P.input=G,A(Y);Y.lookahead>=3;){for(X=Y.strstart,ie=Y.lookahead-2;Y.ins_h=(Y.ins_h<>>=B=v>>>24,E-=B,(B=v>>>16&255)==0)P[t++]=65535&v;else{if(!(16&B)){if(!(64&B)){v=L[(65535&v)+(M&(1<>>=B,E-=B),E<15&&(M+=j[n++]<>>=B=v>>>24,E-=B,!(16&(B=v>>>16&255))){if(!(64&B)){v=I[(65535&v)+(M&(1<>>=B,E-=B,(B=t-f)<_){if(y<(B=_-B)&&o.sane){r.msg="invalid distance too far back",o.mode=30;break e}if(k=S,(F=0)===d){if(F+=x-B,B>3,M&=(1<<(E-=D<<3))-1,r.next_in=n,r.next_out=t,r.avail_in=n>>24&255)+(T>>>8&65280)+((65280&T)<<8)+((255&T)<<24)}function p(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function m(T){var A;return T&&T.state?(A=T.state,T.total_in=T.total_out=A.total=0,T.msg="",A.wrap&&(T.adler=1&A.wrap),A.mode=1,A.last=0,A.havedict=0,A.dmax=32768,A.head=null,A.hold=0,A.bits=0,A.lencode=A.lendyn=new r.Buf32(852),A.distcode=A.distdyn=new r.Buf32(592),A.sane=1,A.back=-1,0):t}function x(T){var A;return T&&T.state?((A=T.state).wsize=0,A.whave=0,A.wnext=0,m(T)):t}function y(T,A){var v,B;return T&&T.state?(B=T.state,A<0?(v=0,A=-A):(v=1+(A>>4),A<48&&(A&=15)),A&&(A<8||15=_.wsize?(r.arraySet(_.window,A,v-_.wsize,_.wsize,0),_.wnext=0,_.whave=_.wsize):(B<(D=_.wsize-_.wnext)&&(D=B),r.arraySet(_.window,A,v-B,D,_.wnext),(B-=D)?(r.arraySet(_.window,A,v-B,B,0),_.wnext=B,_.whave=_.wsize):(_.wnext+=D,_.wnext===_.wsize&&(_.wnext=0),_.whave<_.wsize&&(_.whave+=D))),0}u.inflateReset=x,u.inflateReset2=y,u.inflateResetKeep=m,u.inflateInit=function(T){return d(T,15)},u.inflateInit2=d,u.inflate=function(T,A){var v,B,D,_,F,k,j,P,G,Y,X,ie,oe,$,Q,ne,ee,N,R,O,U,H,W,K,q=0,te=new r.Buf8(4),se=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!T||!T.state||!T.output||!T.input&&T.avail_in!==0)return t;(v=T.state).mode===12&&(v.mode=13),F=T.next_out,D=T.output,j=T.avail_out,_=T.next_in,B=T.input,k=T.avail_in,P=v.hold,G=v.bits,Y=k,X=j,H=0;e:for(;;)switch(v.mode){case 1:if(v.wrap===0){v.mode=13;break}for(;G<16;){if(k===0)break e;k--,P+=B[_++]<>>8&255,v.check=o(v.check,te,2,0),G=P=0,v.mode=2;break}if(v.flags=0,v.head&&(v.head.done=!1),!(1&v.wrap)||(((255&P)<<8)+(P>>8))%31){T.msg="incorrect header check",v.mode=30;break}if((15&P)!=8){T.msg="unknown compression method",v.mode=30;break}if(G-=4,U=8+(15&(P>>>=4)),v.wbits===0)v.wbits=U;else if(U>v.wbits){T.msg="invalid window size",v.mode=30;break}v.dmax=1<>8&1),512&v.flags&&(te[0]=255&P,te[1]=P>>>8&255,v.check=o(v.check,te,2,0)),G=P=0,v.mode=3;case 3:for(;G<32;){if(k===0)break e;k--,P+=B[_++]<>>8&255,te[2]=P>>>16&255,te[3]=P>>>24&255,v.check=o(v.check,te,4,0)),G=P=0,v.mode=4;case 4:for(;G<16;){if(k===0)break e;k--,P+=B[_++]<>8),512&v.flags&&(te[0]=255&P,te[1]=P>>>8&255,v.check=o(v.check,te,2,0)),G=P=0,v.mode=5;case 5:if(1024&v.flags){for(;G<16;){if(k===0)break e;k--,P+=B[_++]<>>8&255,v.check=o(v.check,te,2,0)),G=P=0}else v.head&&(v.head.extra=null);v.mode=6;case 6:if(1024&v.flags&&(k<(ie=v.length)&&(ie=k),ie&&(v.head&&(U=v.head.extra_len-v.length,v.head.extra||(v.head.extra=new Array(v.head.extra_len)),r.arraySet(v.head.extra,B,_,ie,U)),512&v.flags&&(v.check=o(v.check,B,ie,_)),k-=ie,_+=ie,v.length-=ie),v.length))break e;v.length=0,v.mode=7;case 7:if(2048&v.flags){if(k===0)break e;for(ie=0;U=B[_+ie++],v.head&&U&&v.length<65536&&(v.head.name+=String.fromCharCode(U)),U&&ie>9&1,v.head.done=!0),T.adler=v.check=0,v.mode=12;break;case 10:for(;G<32;){if(k===0)break e;k--,P+=B[_++]<>>=7&G,G-=7&G,v.mode=27;break}for(;G<3;){if(k===0)break e;k--,P+=B[_++]<>>=1)){case 0:v.mode=14;break;case 1:if(L(v),v.mode=20,A!==6)break;P>>>=2,G-=2;break e;case 2:v.mode=17;break;case 3:T.msg="invalid block type",v.mode=30}P>>>=2,G-=2;break;case 14:for(P>>>=7&G,G-=7&G;G<32;){if(k===0)break e;k--,P+=B[_++]<>>16^65535)){T.msg="invalid stored block lengths",v.mode=30;break}if(v.length=65535&P,G=P=0,v.mode=15,A===6)break e;case 15:v.mode=16;case 16:if(ie=v.length){if(k>>=5,G-=5,v.ndist=1+(31&P),P>>>=5,G-=5,v.ncode=4+(15&P),P>>>=4,G-=4,286>>=3,G-=3}for(;v.have<19;)v.lens[se[v.have++]]=0;if(v.lencode=v.lendyn,v.lenbits=7,W={bits:v.lenbits},H=h(0,v.lens,0,19,v.lencode,0,v.work,W),v.lenbits=W.bits,H){T.msg="invalid code lengths set",v.mode=30;break}v.have=0,v.mode=19;case 19:for(;v.have>>16&255,ee=65535&q,!((Q=q>>>24)<=G);){if(k===0)break e;k--,P+=B[_++]<>>=Q,G-=Q,v.lens[v.have++]=ee;else{if(ee===16){for(K=Q+2;G>>=Q,G-=Q,v.have===0){T.msg="invalid bit length repeat",v.mode=30;break}U=v.lens[v.have-1],ie=3+(3&P),P>>>=2,G-=2}else if(ee===17){for(K=Q+3;G>>=Q)),P>>>=3,G-=3}else{for(K=Q+7;G>>=Q)),P>>>=7,G-=7}if(v.have+ie>v.nlen+v.ndist){T.msg="invalid bit length repeat",v.mode=30;break}for(;ie--;)v.lens[v.have++]=U}}if(v.mode===30)break;if(v.lens[256]===0){T.msg="invalid code -- missing end-of-block",v.mode=30;break}if(v.lenbits=9,W={bits:v.lenbits},H=h(1,v.lens,0,v.nlen,v.lencode,0,v.work,W),v.lenbits=W.bits,H){T.msg="invalid literal/lengths set",v.mode=30;break}if(v.distbits=6,v.distcode=v.distdyn,W={bits:v.distbits},H=h(2,v.lens,v.nlen,v.ndist,v.distcode,0,v.work,W),v.distbits=W.bits,H){T.msg="invalid distances set",v.mode=30;break}if(v.mode=20,A===6)break e;case 20:v.mode=21;case 21:if(6<=k&&258<=j){T.next_out=F,T.avail_out=j,T.next_in=_,T.avail_in=k,v.hold=P,v.bits=G,n(T,X),F=T.next_out,D=T.output,j=T.avail_out,_=T.next_in,B=T.input,k=T.avail_in,P=v.hold,G=v.bits,v.mode===12&&(v.back=-1);break}for(v.back=0;ne=(q=v.lencode[P&(1<>>16&255,ee=65535&q,!((Q=q>>>24)<=G);){if(k===0)break e;k--,P+=B[_++]<>N)])>>>16&255,ee=65535&q,!(N+(Q=q>>>24)<=G);){if(k===0)break e;k--,P+=B[_++]<>>=N,G-=N,v.back+=N}if(P>>>=Q,G-=Q,v.back+=Q,v.length=ee,ne===0){v.mode=26;break}if(32&ne){v.back=-1,v.mode=12;break}if(64&ne){T.msg="invalid literal/length code",v.mode=30;break}v.extra=15&ne,v.mode=22;case 22:if(v.extra){for(K=v.extra;G>>=v.extra,G-=v.extra,v.back+=v.extra}v.was=v.length,v.mode=23;case 23:for(;ne=(q=v.distcode[P&(1<>>16&255,ee=65535&q,!((Q=q>>>24)<=G);){if(k===0)break e;k--,P+=B[_++]<>N)])>>>16&255,ee=65535&q,!(N+(Q=q>>>24)<=G);){if(k===0)break e;k--,P+=B[_++]<>>=N,G-=N,v.back+=N}if(P>>>=Q,G-=Q,v.back+=Q,64&ne){T.msg="invalid distance code",v.mode=30;break}v.offset=ee,v.extra=15&ne,v.mode=24;case 24:if(v.extra){for(K=v.extra;G>>=v.extra,G-=v.extra,v.back+=v.extra}if(v.offset>v.dmax){T.msg="invalid distance too far back",v.mode=30;break}v.mode=25;case 25:if(j===0)break e;if(ie=X-j,v.offset>ie){if((ie=v.offset-ie)>v.whave&&v.sane){T.msg="invalid distance too far back",v.mode=30;break}oe=ie>v.wnext?(ie-=v.wnext,v.wsize-ie):v.wnext-ie,ie>v.length&&(ie=v.length),$=v.window}else $=D,oe=F-v.offset,ie=v.length;for(jA?(B=R[O+d[k]],Q[ne+d[k]]):(B=96,0),M=1<>X)+(E-=M)]=v<<24|B<<16|D,E!==0;);for(M=1<>=1;if(M!==0?($&=M-1,$+=M):$=0,k++,--ee[F]==0){if(F===P)break;F=f[p+d[k]]}if(G>>7)]}function _(R,O){R.pending_buf[R.pending++]=255&O,R.pending_buf[R.pending++]=O>>>8&255}function F(R,O,U){R.bi_valid>16-U?(R.bi_buf|=O<>16-R.bi_valid,R.bi_valid+=U-16):(R.bi_buf|=O<>>=1,U<<=1,0<--O;);return U>>>1}function P(R,O,U){var H,W,K=new Array(16),q=0;for(H=1;H<=t;H++)K[H]=q=q+U[H-1]<<1;for(W=0;W<=O;W++){var te=R[2*W+1];te!==0&&(R[2*W]=j(K[te]++,te))}}function G(R){var O;for(O=0;O>1;1<=U;U--)ie(R,K,U);for(W=se;U=R.heap[1],R.heap[1]=R.heap[R.heap_len--],ie(R,K,1),H=R.heap[1],R.heap[--R.heap_max]=U,R.heap[--R.heap_max]=H,K[2*W]=K[2*U]+K[2*H],R.depth[W]=(R.depth[U]>=R.depth[H]?R.depth[U]:R.depth[H])+1,K[2*U+1]=K[2*H+1]=W,R.heap[1]=W++,ie(R,K,1),2<=R.heap_len;);R.heap[--R.heap_max]=R.heap[1],function(fe,xe){var ve,Se,ye,be,Me,_e,Te=xe.dyn_tree,Le=xe.max_code,Pe=xe.stat_desc.static_tree,Ae=xe.stat_desc.has_stree,Ce=xe.stat_desc.extra_bits,Be=xe.stat_desc.extra_base,Ie=xe.stat_desc.max_length,Fe=0;for(be=0;be<=t;be++)fe.bl_count[be]=0;for(Te[2*fe.heap[fe.heap_max]+1]=0,ve=fe.heap_max+1;ve<573;ve++)Ie<(be=Te[2*Te[2*(Se=fe.heap[ve])+1]+1]+1)&&(be=Ie,Fe++),Te[2*Se+1]=be,Le>=7;W>>=1)if(1&ue&&te.dyn_ltree[2*se]!==0)return 0;if(te.dyn_ltree[18]!==0||te.dyn_ltree[20]!==0||te.dyn_ltree[26]!==0)return 1;for(se=32;se>>3,(K=R.static_len+3+7>>>3)<=W&&(W=K)):W=K=U+5,U+4<=W&&O!==-1?N(R,O,U,H):R.strategy===4||K===W?(F(R,2+(H?1:0),3),oe(R,y,d)):(F(R,4+(H?1:0),3),function(te,se,ue,fe){var xe;for(F(te,se-257,5),F(te,ue-1,5),F(te,fe-4,4),xe=0;xe>>8&255,R.pending_buf[R.d_buf+2*R.last_lit+1]=255&O,R.pending_buf[R.l_buf+R.last_lit]=255&U,R.last_lit++,O===0?R.dyn_ltree[2*U]++:(R.matches++,O--,R.dyn_ltree[2*(M[U]+o+1)]++,R.dyn_dtree[2*D(O)]++),R.last_lit===R.lit_bufsize-1},u._tr_align=function(R){F(R,2,3),k(R,256,y),function(O){O.bi_valid===16?(_(O,O.bi_buf),O.bi_buf=0,O.bi_valid=0):8<=O.bi_valid&&(O.pending_buf[O.pending++]=255&O.bi_buf,O.bi_buf>>=8,O.bi_valid-=8)}(R)}},{"../utils/common":41}],53:[function(l,s,u){s.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(l,s,u){(function(r){(function(i){if(!i.setImmediate){var o,n,h,t,f=1,p={},m=!1,x=i.document,y=Object.getPrototypeOf&&Object.getPrototypeOf(i);y=y&&y.setTimeout?y:i,o={}.toString.call(i.process)==="[object process]"?function(E){process.nextTick(function(){S(E)})}:function(){if(i.postMessage&&!i.importScripts){var E=!0,L=i.onmessage;return i.onmessage=function(){E=!1},i.postMessage("","*"),i.onmessage=L,E}}()?(t="setImmediate$"+Math.random()+"$",i.addEventListener?i.addEventListener("message",M,!1):i.attachEvent("onmessage",M),function(E){i.postMessage(t+E,"*")}):i.MessageChannel?((h=new MessageChannel).port1.onmessage=function(E){S(E.data)},function(E){h.port2.postMessage(E)}):x&&"onreadystatechange"in x.createElement("script")?(n=x.documentElement,function(E){var L=x.createElement("script");L.onreadystatechange=function(){S(E),L.onreadystatechange=null,n.removeChild(L),L=null},n.appendChild(L)}):function(E){setTimeout(S,0,E)},y.setImmediate=function(E){typeof E!="function"&&(E=new Function(""+E));for(var L=new Array(arguments.length-1),I=0;I"u"?r===void 0?this:r:self)}).call(this,c.g!==void 0?c.g:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)},3065(de,g,c){var l,s;(function(){l=function(){var u=function(){},r="undefined",i=typeof window!==r&&typeof window.navigator!==r&&/Trident\/|MSIE /.test(window.navigator.userAgent),o=["trace","debug","info","warn","error"],n={},h=null;function t(S,M){var E=S[M];if(typeof E.bind=="function")return E.bind(S);try{return Function.prototype.bind.call(E,S)}catch{return function(){return Function.prototype.apply.apply(E,[S,arguments])}}}function f(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function p(){for(var S=this.getLevel(),M=0;M=0&&F<=T.levels.SILENT)return F;throw new TypeError("log.setLevel() called with invalid level: "+_)}typeof S=="string"?A+=":"+S:typeof S=="symbol"&&(A=void 0),T.name=S,T.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},T.methodFactory=M||x,T.getLevel=function(){return I??L??E},T.setLevel=function(_,F){return I=B(_),F!==!1&&function(k){var j=(o[k]||"silent").toUpperCase();if(typeof window!==r&&A){try{return void(window.localStorage[A]=j)}catch{}try{window.document.cookie=encodeURIComponent(A)+"="+j+";"}catch{}}}(I),p.call(T)},T.setDefaultLevel=function(_){L=B(_),v()||T.setLevel(_,!1)},T.resetLevel=function(){I=null,function(){if(typeof window!==r&&A){try{window.localStorage.removeItem(A)}catch{}try{window.document.cookie=encodeURIComponent(A)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}(),p.call(T)},T.enableAll=function(_){T.setLevel(T.levels.TRACE,_)},T.disableAll=function(_){T.setLevel(T.levels.SILENT,_)},T.rebuild=function(){if(h!==T&&(E=B(h.getLevel())),p.call(T),h===T)for(var _ in n)n[_].rebuild()},E=B(h?h.getLevel():"WARN");var D=v();D!=null&&(I=B(D)),p.call(T)}(h=new y).getLogger=function(S){if(typeof S!="symbol"&&typeof S!="string"||S==="")throw new TypeError("You must supply a name when creating a logger.");var M=n[S];return M||(M=n[S]=new y(S,h.methodFactory)),M};var d=typeof window!==r?window.log:void 0;return h.noConflict=function(){return typeof window!==r&&window.log===h&&(window.log=d),h},h.getLoggers=function(){return n},h.default=h,h},(s=l.call(g,c,g,de))===void 0||(de.exports=s)})()},2561(de,g){Object.defineProperty(g,"__esModule",{value:!0}),g.Fraction=void 0;class c{static max(s,u){return s.RealValue>u.RealValue?s:u}static Equal(s,u){return s.wholeValue===u.wholeValue&&s.Denominator===u.Denominator&&s.Numerator===u.Numerator}static createFromFraction(s){return new c(s.numerator,s.denominator,s.wholeValue,!1)}static plus(s,u){const r=s.clone();return r.Add(u),r}static minus(s,u){const r=s.clone();return r.Sub(u),r}static multiply(s,u){return new c((s.wholeValue*s.denominator+s.numerator)*(u.wholeValue*u.denominator+u.numerator),s.denominator*u.denominator)}static greatestCommonDenominator(s,u){if(s===0)return u;if(u===1)return 1;for(;Math.abs(u)>=1&&Math.abs(s)>=1;)s>u?s-=u:u-=s;const r=Math.round(s);return Math.max(r,1)}constructor(s=0,u=1,r=0,i=!0){this.numerator=0,this.denominator=1,this.wholeValue=0,this.numerator=s,this.denominator=u,this.wholeValue=r,i&&this.simplify(),this.setRealValue()}toString(){let s=this.numerator+"/"+this.denominator;return this.wholeValue!==0&&(s=this.wholeValue+" "+s),s}clone(){return new c(this.numerator,this.denominator,this.wholeValue,!1)}get Numerator(){return this.numerator}set Numerator(s){this.numerator!==s&&(this.numerator=s,this.simplify(),this.setRealValue())}get Denominator(){return this.denominator}set Denominator(s){this.denominator!==s&&(this.denominator=s,this.numerator!==0&&this.simplify(),this.setRealValue())}get WholeValue(){return this.wholeValue}set WholeValue(s){this.wholeValue!==s&&(this.wholeValue=s,this.setRealValue())}GetExpandedNumerator(){return this.wholeValue*this.denominator+this.numerator}calculateNumberOfNeededDots(){let s=1,u=2;const r=this.GetExpandedNumerator();for(;us;)u.Numerator++;if(this.numerator>this.denominator){const r=new c(this.numerator-1,this.denominator,this.wholeValue);for(;r.Denominator>s;)r.Numerator--;if(r.Denominatorc.maximumAllowedNumber){const r=this.denominator/c.maximumAllowedNumber;this.numerator=Math.round(this.numerator/r),this.denominator=Math.round(this.denominator/r)}if(this.numerator>c.maximumAllowedNumber){const r=this.numerator/c.maximumAllowedNumber;this.numerator=Math.round(this.numerator/r),this.denominator=Math.round(this.denominator/r)}}isOnBeat(s){const u=this.distanceFromBeat(s);return Math.abs(u)o.length-1&&(h=1),t<0&&(t=o.length+t,h=-1),[o[t],h]}static CalculateTransposedHalfTone(r,i){const o=r.fundamentalNote+r.AccidentalHalfTones+i;return s.WrapAroundCheck(o,12)}static WrapAroundCheck(r,i){let o=0;for(;r<0;)r+=i,o--;for(;r>=i;)r-=i,o++;return{overflow:o,halftone:r}}static calcFrequency(r){let i,o=0;if(r instanceof s){const n=r;o=n.octave-1,i=n.fundamentalNote-c.A+n.AccidentalHalfTones}else typeof r=="number"&&(i=r-57);return 440*Math.pow(2,o)*Math.pow(2,i/12)}static calcFractionalKey(r){return Math.log(r/440)/Math.LN10*s.halftoneFactor+57}static fromFrequency(r){const i=s.calcFractionalKey(r)+.5,o=Math.floor(i/12)-s.octXmlDiff,n=Math.floor(i)%12;let h=n,t=l.NONE;return this.pitchEnumValues.indexOf(h)===-1&&(h=n-1,t=l.SHARP),new s(h,o,t)}static fromHalftone(r){const i=Math.floor(r/12)-s.octXmlDiff,o=r%12;let n=o,h=l.NONE;return this.pitchEnumValues.indexOf(n)===-1&&(n=o-1,h=l.SHARP),new s(n,i,h)}static ceiling(r){let i=r%=12;return this.pitchEnumValues.indexOf(i)===-1&&(i=r+1),i}static floor(r){let i=r%=12;return this.pitchEnumValues.indexOf(i)===-1&&(i=r-1),i}constructor(r,i,o,n=void 0,h=!1,t=void 0){this.accidental=l.NONE,this.fundamentalNote=r,this.octave=i,this.accidental=o,this.accidentalXml=n,this.halfTone=r+12*(i+s.octXmlDiff)+s.HalfTonesFromAccidental(o),h||(this.frequency=s.calcFrequency(this)),this.OctaveShiftApplied=t}static HalfTonesFromAccidental(r){switch(r){case l.NONE:return 0;case l.SHARP:return 1;case l.FLAT:return-1;case l.NATURAL:return 0;case l.DOUBLESHARP:return 2;case l.DOUBLEFLAT:return-2;case l.TRIPLESHARP:return 3;case l.TRIPLEFLAT:return-3;case l.QUARTERTONESHARP:return .5;case l.QUARTERTONEFLAT:return-.5;case l.SLASHFLAT:return-.51;case l.THREEQUARTERSSHARP:return 1.5;case l.THREEQUARTERSFLAT:return-1.5;case l.SLASHQUARTERSHARP:return .0013;case l.SLASHSHARP:return .0014;case l.DOUBLESLASHFLAT:return-.0015;case l.SORI:return .0016;case l.KORON:return .0017;default:throw new Error("Unhandled AccidentalEnum value")}}static AccidentalFromHalfTones(r){switch(r){case 0:return l.NONE;case 1:return l.SHARP;case-1:return l.FLAT;case 2:return l.DOUBLESHARP;case-2:return l.DOUBLEFLAT;case 3:return l.TRIPLESHARP;case-3:return l.TRIPLEFLAT;case .5:return l.QUARTERTONESHARP;case-.5:return l.QUARTERTONEFLAT;case 1.5:return l.THREEQUARTERSSHARP;case-1.5:return l.THREEQUARTERSFLAT;default:return r>0&&r<1?l.QUARTERTONESHARP:r<0&&r>-1?l.QUARTERTONEFLAT:l.QUARTERTONESHARP}}static accidentalVexflow(r){let i;switch(r){case l.NATURAL:i="n";break;case l.FLAT:i="b";break;case l.SHARP:i="#";break;case l.DOUBLESHARP:i="##";break;case l.TRIPLESHARP:i="###";break;case l.DOUBLEFLAT:i="bb";break;case l.TRIPLEFLAT:i="bbs";break;case l.QUARTERTONESHARP:i="+";break;case l.QUARTERTONEFLAT:i="d";break;case l.SLASHFLAT:i="bs";break;case l.THREEQUARTERSSHARP:i="++";break;case l.THREEQUARTERSFLAT:i="db";break;case l.SLASHQUARTERSHARP:i="+-";break;case l.SLASHSHARP:i="++-";break;case l.DOUBLESLASHFLAT:i="bss";break;case l.SORI:i="o";break;case l.KORON:i="k"}return i}get AccidentalHalfTones(){return s.HalfTonesFromAccidental(this.accidental)}get Octave(){return this.octave}get FundamentalNote(){return this.fundamentalNote}get Accidental(){return this.accidental}get AccidentalXml(){return this.accidentalXml}get Frequency(){return this.frequency}static get OctaveXmlDifference(){return s.octXmlDiff}getHalfTone(){return this.halfTone}getTransposedPitch(r){if(r>12)throw new Error("rewrite this method to handle bigger octave changes or don't use is with bigger octave changes!");return r>0?this.getHigherPitchByTransposeFactor(r):r<0?this.getLowerPitchByTransposeFactor(-r):this}DoEnharmonicChange(){switch(this.accidental){case l.FLAT:case l.DOUBLEFLAT:this.fundamentalNote=this.getPreviousFundamentalNote(this.fundamentalNote),this.accidental=s.AccidentalFromHalfTones(this.halfTone-(this.fundamentalNote+12*(this.octave+s.octXmlDiff)));break;case l.SHARP:case l.DOUBLESHARP:this.fundamentalNote=this.getNextFundamentalNote(this.fundamentalNote),this.accidental=s.AccidentalFromHalfTones(this.halfTone-(this.fundamentalNote+12*(this.octave+s.octXmlDiff)));break;default:return}}ToString(){let r=s.accidentalVexflow(this.accidental);return r||(r=""),"Key: "+s.getNoteEnumString(this.fundamentalNote)+r+", Note: "+this.fundamentalNote+", octave: "+this.octave.toString()}ToStringShort(r=0){let i=s.accidentalVexflow(this.accidental);i||(i="");const o=this.octave+r;return s.getNoteEnumString(this.fundamentalNote)+i+o}get ToStringShortGet(){return this.ToStringShort(0)}OperatorEquals(r){const i=this;return!(!i||!r)&&i.FundamentalNote===r.FundamentalNote&&i.Octave===r.Octave&&i.Accidental===r.Accidental}OperatorNotEqual(r){return this!==r}OperatorFundamentalGreaterThan(r){const i=this;return i.Octave===r.Octave?i.FundamentalNote>r.FundamentalNote:i.Octave>r.Octave}OperatorFundamentalLessThan(r){const i=this;return i.Octave===r.Octave?i.FundamentalNotes.pitchEnumValues.length-1?(o=s.pitchEnumValues[i+r-s.pitchEnumValues.length],n++):o=s.pitchEnumValues[i+r],new s(o,n,l.NONE)}getLowerPitchByTransposeFactor(r){const i=s.pitchEnumValues.indexOf(this.fundamentalNote);let o,n=this.octave;return i-r<0?(o=s.pitchEnumValues[s.pitchEnumValues.length+i-r],n--):o=s.pitchEnumValues[i-r],new s(o,n,l.NONE)}getNextFundamentalNote(r){let i=s.pitchEnumValues.indexOf(r);return i=(i+1)%s.pitchEnumValues.length,s.pitchEnumValues[i]}getPreviousFundamentalNote(r){const i=s.pitchEnumValues.indexOf(r);return i>0?s.pitchEnumValues[i-1]:s.pitchEnumValues[s.pitchEnumValues.length-1]}}g.Pitch=s,s.pitchEnumValues=[c.C,c.D,c.E,c.F,c.G,c.A,c.B],s.halftoneFactor=12/(Math.LN2/Math.LN10),s.octXmlDiff=3},283(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.PlaybackSettings=void 0;const l=c(2561);class s{constructor(r=new l.Fraction,i=100){this.rhythm=r,this.beatsPerMinute=i,this.beatLengthInMilliseconds=6e4/i,this.beatRealValue=.25}static createFrom(r){return new s(r.Rhythm,r.BeatsPerMinute)}get BeatsPerMinute(){return this.beatsPerMinute}set BeatsPerMinute(r){this.beatsPerMinute=r,this.beatLengthInMilliseconds=6e4/this.beatsPerMinute}get Rhythm(){return this.rhythm}set Rhythm(r){this.rhythm=r}get BeatRealValue(){return this.beatRealValue}get BeatLengthInMilliseconds(){return this.beatLengthInMilliseconds}getDurationInMilliseconds(r){return(typeof r=="number"?r:r.RealValue)*this.BeatLengthInMilliseconds/this.beatRealValue}getDurationAsNoteDuration(r,i=1024){const o=r/this.BeatLengthInMilliseconds;let n=Math.floor(o);const h=new l.Fraction(n,4),t=o-n;return n=Math.round(t/(1/i)/4),t!==0&&n===0&&r>0&&(n=1),h.Add(new l.Fraction(n,i)),h}}g.PlaybackSettings=s},9409(de,g){Object.defineProperty(g,"__esModule",{value:!0}),g.PointF2D=void 0;class c{constructor(s=0,u=0){this.x=0,this.y=0,this.x=s,this.y=u}static get Empty(){return new c}static pointsAreEqual(s,u){return s.x===u.x&&s.y===u.y}ToString(){return"["+this.x+", "+this.y+"]"}}g.PointF2D=c},200(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.RectangleF2D=void 0;const l=c(6864),s=c(9409);class u{constructor(i,o,n,h){this.x=0,this.y=0,this.width=0,this.height=0,this.x=i,this.y=o,this.width=n,this.height=h}static createFromLocationAndSize(i,o){return new u(i.x,i.y,o.width,o.height)}get Location(){return new s.PointF2D(this.x,this.y)}get Size(){return new l.SizeF2D(this.width,this.height)}}g.RectangleF2D=u},6864(de,g){Object.defineProperty(g,"__esModule",{value:!0}),g.SizeF2D=void 0,g.SizeF2D=class{constructor(c=0,l=0){this.width=c,this.height=l}}},9735(de,g,c){var l=this&&this.__createBinding||(Object.create?function(u,r,i,o){o===void 0&&(o=i);var n=Object.getOwnPropertyDescriptor(r,i);n&&!("get"in n?!r.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return r[i]}}),Object.defineProperty(u,o,n)}:function(u,r,i,o){o===void 0&&(o=i),u[o]=r[i]}),s=this&&this.__exportStar||function(u,r){for(var i in u)i==="default"||Object.prototype.hasOwnProperty.call(r,i)||l(r,u,i)};Object.defineProperty(g,"__esModule",{value:!0}),s(c(2561),g),s(c(6904),g),s(c(8786),g),s(c(8705),g),s(c(8233),g),s(c(9409),g),s(c(200),g),s(c(6864),g)},4434(de,g){var c;Object.defineProperty(g,"__esModule",{value:!0}),g.ColoringModes=void 0,function(l){l[l.XML=0]="XML",l[l.AutoColoring=1]="AutoColoring",l[l.CustomColorSet=2]="CustomColorSet"}(c||(g.ColoringModes=c={}))},4146(de,g){var c;Object.defineProperty(g,"__esModule",{value:!0}),g.DrawingParametersEnum=void 0,function(l){l.allon="allon",l.compact="compact",l.compacttight="compacttight",l.default="default",l.leadsheet="leadsheet",l.preview="preview",l.thumbnail="thumbnail"}(c||(g.DrawingParametersEnum=c={}))},2570(de,g){var c;Object.defineProperty(g,"__esModule",{value:!0}),g.FontStyles=void 0,function(l){l[l.Regular=0]="Regular",l[l.Bold=1]="Bold",l[l.Italic=2]="Italic",l[l.BoldItalic=3]="BoldItalic",l[l.Underlined=4]="Underlined"}(c||(g.FontStyles=c={}))},5951(de,g){var c;Object.defineProperty(g,"__esModule",{value:!0}),g.Fonts=void 0,function(l){l[l.TimesNewRoman=0]="TimesNewRoman",l[l.Kokila=1]="Kokila"}(c||(g.Fonts=c={}))},7533(de,g){var c;Object.defineProperty(g,"__esModule",{value:!0}),g.TextAlignment=g.TextAlignmentEnum=void 0,function(l){l[l.LeftTop=0]="LeftTop",l[l.LeftCenter=1]="LeftCenter",l[l.LeftBottom=2]="LeftBottom",l[l.CenterTop=3]="CenterTop",l[l.CenterCenter=4]="CenterCenter",l[l.CenterBottom=5]="CenterBottom",l[l.RightTop=6]="RightTop",l[l.RightCenter=7]="RightCenter",l[l.RightBottom=8]="RightBottom"}(c||(g.TextAlignmentEnum=c={})),g.TextAlignment=class{static IsLeft(l){return l===c.LeftTop||l===c.LeftCenter||l===c.LeftBottom}static IsCenterAligned(l){return l===c.CenterTop||l===c.CenterCenter||l===c.CenterBottom}static IsRight(l){return l===c.RightTop||l===c.RightCenter||l===c.RightBottom}}},2514(de,g){var c;Object.defineProperty(g,"__esModule",{value:!0}),g.TieTypes=void 0,function(l){l.SIMPLE="",l.HAMMERON="H",l.PULLOFF="P",l.SLIDE="S",l.TAPPING="T"}(c||(g.TieTypes=c={}))},2257(de,g,c){var l=this&&this.__createBinding||(Object.create?function(u,r,i,o){o===void 0&&(o=i);var n=Object.getOwnPropertyDescriptor(r,i);n&&!("get"in n?!r.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return r[i]}}),Object.defineProperty(u,o,n)}:function(u,r,i,o){o===void 0&&(o=i),u[o]=r[i]}),s=this&&this.__exportStar||function(u,r){for(var i in u)i==="default"||Object.prototype.hasOwnProperty.call(r,i)||l(r,u,i)};Object.defineProperty(g,"__esModule",{value:!0}),s(c(4434),g),s(c(4146),g),s(c(2570),g),s(c(5951),g),s(c(7533),g),s(c(2514),g)},6888(de,g,c){var l=this&&this.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(g,"__esModule",{value:!0}),g.MXLHelper=g.MXLFile=void 0;const s=c(3902),u=l(c(1710)),r=l(c(3065));g.MXLFile=class{constructor(o){this.unzipSuccessful=!1,this.blob=o}async tryUnzip(){this.zipFile=new u.default;try{return this.unzipSuccessful=!0,await this.zipFile.loadAsync(this.blob),!0}catch{return this.unzipSuccessful=!1,!1}}getXmlString(){return i.jszipToXMLstring(this.zipFile)}};class i{static MXLtoIXmlElement(n){return this.MXLtoXMLstring(n).then(h=>{const t=new DOMParser().parseFromString(h,"text/xml"),f=new s.IXmlElement(t.documentElement);return Promise.resolve(f)},h=>{throw new Error("extractSheetFromMxl: "+h.message)})}static async jszipToXMLstring(n){let h=await n.file("META-INF/container.xml").async("text");if(!h.startsWith("<")){const p=await n.file("META-INF/container.xml").async("uint8array");h=new TextDecoder("utf-8").decode(p)}if(!h.startsWith("<")){const p=await n.file("META-INF/container.xml").async("uint8array");h=new TextDecoder("utf-16").decode(p)}const t=new DOMParser().parseFromString(h,"text/xml").getElementsByTagName("rootfile")[0].getAttribute("full-path"),f=await n.file(t).async("text");if(!f.substring(0,1).startsWith("<")){const p=await n.file(t).async("uint8array");return new TextDecoder("utf-16").decode(p)}return f}static MXLtoXMLstring(n){const h=new u.default;return h.loadAsync(n).then(async t=>this.jszipToXMLstring(h),t=>{throw r.default.error(t),t})}}g.MXLHelper=i},3902(de,g){Object.defineProperty(g,"__esModule",{value:!0}),g.IXmlElement=void 0;class c{constructor(s){if(this.hasAttributes=!1,!s)throw new Error("IXmlElement: expected Element, got undefined");this.elem=s,this.name=s.nodeName.toLowerCase(),s.hasAttributes()&&(this.hasAttributes=!0,this.firstAttribute=s.attributes[0]),this.hasElements=s.hasChildNodes(),s.childNodes.length===1&&s.childNodes[0].nodeType===Node.TEXT_NODE?this.value=s.childNodes[0].nodeValue:this.value=""}attribute(s){return this.elem.attributes.getNamedItem(s)}attributes(){if(!this.attrs){const s=this.elem.attributes,u=[];for(let r=0;r0){let r;for(let i=0,o=u.length;i=0;if(this.currentInMeasureNoteAlterationsDict.containsKey(n))if(t&&this.currentAlterationsComparedToKeyInstructionList.splice(this.currentAlterationsComparedToKeyInstructionList.indexOf(n),1),this.currentInMeasureNoteAlterationsDict.getValue(n)!==o.AccidentalHalfTones){this.keySignatureNoteAlterationsDict.containsKey(n)&&this.keySignatureNoteAlterationsDict.getValue(n)!==o.AccidentalHalfTones?(this.currentAlterationsComparedToKeyInstructionList.push(n),this.currentInMeasureNoteAlterationsDict.setValue(n,o.AccidentalHalfTones)):o.Accidental!==l.AccidentalEnum.NONE?this.keySignatureNoteAlterationsDict.containsKey(n)?this.currentInMeasureNoteAlterationsDict.setValue(n,this.keySignatureNoteAlterationsDict.getValue(n)):this.currentInMeasureNoteAlterationsDict.remove(n):this.currentInMeasureNoteAlterationsDict.setValue(n,o.AccidentalHalfTones);const f=this.currentInMeasureNoteAlterationsDict.getValue(n);if(o.Accidental===l.AccidentalEnum.NONE&&(o=Math.abs(f)===.5?new s.Pitch(o.FundamentalNote,o.Octave,l.AccidentalEnum.NONE,void 0,!1,o.OctaveShiftApplied):new s.Pitch(o.FundamentalNote,o.Octave,l.AccidentalEnum.NATURAL,void 0,!1,o.OctaveShiftApplied)),this.isAlterAmbiguousAccidental(o.Accidental)&&!o.AccidentalXml)return;r.MusicSheetCalculator.symbolFactory.addGraphicalAccidental(i,o)}else o.AccidentalXml&&this.Transpose===0&&!t&&r.MusicSheetCalculator.symbolFactory.addGraphicalAccidental(i,o);else if(o.Accidental!==l.AccidentalEnum.NONE){if(t||this.currentAlterationsComparedToKeyInstructionList.push(n),this.currentInMeasureNoteAlterationsDict.setValue(n,o.AccidentalHalfTones),this.isAlterAmbiguousAccidental(o.Accidental)&&!o.AccidentalXml)return;r.MusicSheetCalculator.symbolFactory.addGraphicalAccidental(i,o)}else t&&(o=new s.Pitch(o.FundamentalNote,o.Octave,l.AccidentalEnum.NATURAL,void 0,!1,o.OctaveShiftApplied),this.currentAlterationsComparedToKeyInstructionList.splice(this.currentAlterationsComparedToKeyInstructionList.indexOf(n),1),r.MusicSheetCalculator.symbolFactory.addGraphicalAccidental(i,o))}isAlterAmbiguousAccidental(i){return i===l.AccidentalEnum.SLASHFLAT||i===l.AccidentalEnum.QUARTERTONEFLAT}reactOnKeyInstructionChange(){const i=this.activeKeyInstruction.AlteratedNotes;let o;o=this.activeKeyInstruction.Key>0?l.AccidentalEnum.SHARP:l.AccidentalEnum.FLAT,this.keySignatureNoteAlterationsDict.clear(),this.currentAlterationsComparedToKeyInstructionList.length=0;for(let n=-9;n<9;n++)for(let h=0;hthis.borderLeft?this.borderLeft:this.borderMarginLeft}set BorderMarginLeft(t){this.borderMarginLeft=t,this.calculateMarginRectangle()}get BorderMarginRight(){return this.borderMarginRightthis.borderTop?this.borderTop:this.borderMarginTop}set BorderMarginTop(t){this.borderMarginTop=t,this.calculateMarginRectangle()}get BorderMarginBottom(){return this.borderMarginBottom-1&&this.parent.ChildElements.splice(f,1)}this.parent=t,this.parent.ChildElements.indexOf(this)>-1?s.default.error("BoundingBox of "+this.dataObject.constructor.name+" already in children list of "+this.parent.dataObject.constructor.name+"'s BoundingBox"):this.parent.ChildElements.push(this)}get DataObject(){return this.dataObject}get Center(){return new r.PointF2D(this.RelativePosition.x+(this.BorderMarginRight+this.BorderMarginLeft),this.RelativePosition.y+(this.BorderMarginBottom+this.BorderMarginTop))}setAbsolutePositionFromParent(){this.parent?(this.absolutePosition.x=this.parent.AbsolutePosition.x+this.relativePosition.x,this.absolutePosition.y=this.parent.AbsolutePosition.y+this.relativePosition.y):this.absolutePosition=this.relativePosition}calculateAbsolutePosition(){this.absolutePosition.x=this.relativePosition.x,this.absolutePosition.y=this.relativePosition.y;let t=this.parent;for(;t;)this.absolutePosition.x+=t.relativePosition.x,this.absolutePosition.y+=t.relativePosition.y,t=t.parent}calculateAbsolutePositionsRecursiveWithoutTopelement(){this.absolutePosition.x=0,this.absolutePosition.y=0;for(let t=0,f=this.ChildElements.length;t.001;break;case h.Up:case h.Down:m=this.relativePosition.y,t.calculateMarginPositionAlongDirection(this,f),x=Math.abs(m-this.relativePosition.y)>.001;break;default:throw new u.ArgumentOutOfRangeException("direction")}while(x)}collisionDetection(t){const f=Math.min(this.AbsolutePosition.x+this.borderRight,t.absolutePosition.x+t.borderRight)-Math.max(this.AbsolutePosition.x+this.borderLeft,t.absolutePosition.x+t.borderLeft),p=Math.min(this.AbsolutePosition.y+this.borderBottom,t.absolutePosition.y+t.borderBottom)-Math.max(this.AbsolutePosition.y+this.borderTop,t.absolutePosition.y+t.borderTop);return f>=0&&p>=0}liesInsideBorders(t){const f=this.AbsolutePosition.x+this.borderLeft<=t.absolutePosition.x+t.borderLeft&&t.absolutePosition.x+t.borderLeft<=this.AbsolutePosition.x+this.borderRight,p=this.AbsolutePosition.x+this.borderLeft<=t.absolutePosition.x+t.borderRight&&t.absolutePosition.x+t.borderRight<=this.AbsolutePosition.x+this.borderRight;if(f&&p){const m=this.AbsolutePosition.y+this.borderTop<=t.absolutePosition.y+t.borderTop&&t.absolutePosition.y+t.borderTop<=this.AbsolutePosition.y+this.borderBottom,x=this.AbsolutePosition.y+this.borderTop<=t.absolutePosition.y+t.borderBottom&&t.absolutePosition.y+t.borderBottom<=this.AbsolutePosition.y+this.borderBottom;if(m&&x)return!0}return!1}pointLiesInsideBorders(t){return this.AbsolutePosition.x+this.borderLeft<=t.x&&t.x<=this.AbsolutePosition.x+this.borderRight&&this.AbsolutePosition.y+this.borderTop<=t.y&&t.y<=this.AbsolutePosition.y+this.borderBottom}marginCollisionDetection(t){const f=Math.min(this.AbsolutePosition.x+this.borderMarginRight,t.absolutePosition.x+t.borderMarginRight)-Math.max(this.AbsolutePosition.x+this.borderMarginLeft,t.absolutePosition.x+t.borderMarginLeft),p=Math.min(this.AbsolutePosition.y+this.borderMarginBottom,t.absolutePosition.y+t.borderMarginBottom)-Math.max(this.AbsolutePosition.y+this.borderMarginTop,t.absolutePosition.y+t.borderMarginTop);return f>0&&p>0}liesInsideMargins(t){const f=this.AbsolutePosition.x+this.borderMarginLeft<=t.absolutePosition.x+t.borderMarginLeft&&t.absolutePosition.x+t.borderMarginLeft<=this.AbsolutePosition.x+this.borderMarginRight,p=this.AbsolutePosition.x+this.borderMarginLeft<=t.absolutePosition.x+t.borderMarginRight&&t.absolutePosition.x+t.borderMarginRight<=this.AbsolutePosition.x+this.borderMarginRight;if(f&&p){const m=this.AbsolutePosition.y+this.borderMarginTop<=t.absolutePosition.y+t.borderMarginTop&&t.absolutePosition.y+t.borderMarginTop<=this.AbsolutePosition.y+this.borderMarginBottom,x=this.AbsolutePosition.y+this.borderMarginTop<=t.absolutePosition.y+t.borderMarginBottom&&t.absolutePosition.y+t.borderMarginBottom<=this.AbsolutePosition.y+this.borderMarginBottom;if(m&&x)return!0}return!1}pointLiesInsideMargins(t){return this.AbsolutePosition.x+this.borderMarginLeft<=t.x&&t.x<=this.AbsolutePosition.x+this.borderMarginRight&&this.AbsolutePosition.y+this.borderMarginTop<=t.y&&t.y<=this.AbsolutePosition.y+this.borderMarginBottom}computeNonOverlappingPosition(t,f,p){this.RelativePosition=new r.PointF2D(p.x,p.y),this.setAbsolutePositionFromParent();let m=0,x=!1;do switch(f){case h.Left:case h.Right:m=this.relativePosition.x,t.calculatePositionAlongDirection(this,f),x=Math.abs(m-this.relativePosition.x)>1e-4;break;case h.Up:case h.Down:m=this.relativePosition.y,t.calculatePositionAlongDirection(this,f),x=Math.abs(m-this.relativePosition.y)>1e-4;break;default:throw new u.ArgumentOutOfRangeException("direction")}while(x)}getClickedObjectOfType(t){const f=this.dataObject;if(this.pointLiesInsideBorders(t)&&f)return f;for(let p=0,m=this.childElements.length;p=this.SkyBottomLineWebGLMinMeasures&&(this.PreferredSkyBottomLineBatchCalculatorBackend=o.SkyBottomLineBatchCalculatorBackendType.WebGL)}applyDefaultColorMusic(S){this.DefaultColorMusic=S,this.DefaultColorNotehead=S,this.DefaultColorRest=S,this.DefaultColorStem=S,this.DefaultColorLabel=S,this.DefaultColorLyrics=S,this.DefaultColorTitle=S,this.LedgerLineColorDefault=S}addGraphicalNoteToNoteMap(S,M){S.NoteToGraphicalNoteObjectId=this.NoteToGraphicalNoteMapObjectCount,this.NoteToGraphicalNoteMap.setValue(S.NoteToGraphicalNoteObjectId,M),this.NoteToGraphicalNoteMapObjectCount++}GNote(S){return m.GraphicalNote.FromNote(S,this)}clearMusicSheetObjects(){this.NoteToGraphicalNoteMap=new h.Dictionary,this.NoteToGraphicalNoteMapObjectCount=0}resetChordAccidentalTexts(S,M){S.setValue(f.AccidentalEnum.SHARP,M?"♯":"#"),S.setValue(f.AccidentalEnum.FLAT,M?"♭":"b"),S.setValue(f.AccidentalEnum.DOUBLEFLAT,M?"𝄫":"bb"),S.setValue(f.AccidentalEnum.DOUBLESHARP,M?"𝄪":"x")}setChordSymbolLabelText(S,M){this.ChordSymbolLabelTexts.setValue(S,M)}resetChordSymbolLabelTexts(S){return S.setValue(p.ChordSymbolEnum.minor,"m"),S.setValue(p.ChordSymbolEnum.augmented,"aug"),S.setValue(p.ChordSymbolEnum.diminished,"dim"),S.setValue(p.ChordSymbolEnum.dominant,"7"),S.setValue(p.ChordSymbolEnum.majorseventh,"maj7"),S.setValue(p.ChordSymbolEnum.minorseventh,"m7"),S.setValue(p.ChordSymbolEnum.diminishedseventh,"dim7"),S.setValue(p.ChordSymbolEnum.augmentedseventh,"aug7"),S.setValue(p.ChordSymbolEnum.halfdiminished,`m7${this.ChordAccidentalTexts.getValue(f.AccidentalEnum.FLAT)}5`),S.setValue(p.ChordSymbolEnum.majorminor,"m(maj7)"),S.setValue(p.ChordSymbolEnum.majorsixth,"maj6"),S.setValue(p.ChordSymbolEnum.minorsixth,"m6"),S.setValue(p.ChordSymbolEnum.dominantninth,"9"),S.setValue(p.ChordSymbolEnum.majorninth,"maj9"),S.setValue(p.ChordSymbolEnum.minorninth,"m9"),S.setValue(p.ChordSymbolEnum.dominant11th,"11"),S.setValue(p.ChordSymbolEnum.major11th,"maj11"),S.setValue(p.ChordSymbolEnum.minor11th,"m11"),S.setValue(p.ChordSymbolEnum.dominant13th,"13"),S.setValue(p.ChordSymbolEnum.major13th,"maj13"),S.setValue(p.ChordSymbolEnum.minor13th,"m13"),S.setValue(p.ChordSymbolEnum.suspendedsecond,"sus2"),S.setValue(p.ChordSymbolEnum.suspendedfourth,"sus4"),S.setValue(p.ChordSymbolEnum.power,"5"),S.setValue(p.ChordSymbolEnum.none,"N.C."),S}addChordName(S,M,E,L,I){if(p.ChordSymbolEnum[M]!==void 0){const T={adds:E,alts:L,subs:I};this.CustomChords.push(p.CustomChord.createCustomChord(S,p.ChordSymbolEnum[M],T))}}renameChord(S,M){p.CustomChord.renameCustomChord(S,M,this.CustomChords)}resetChordNames(){const S=this.ChordAccidentalTexts.getValue(f.AccidentalEnum.SHARP),M=this.ChordAccidentalTexts.getValue(f.AccidentalEnum.FLAT);this.addChordName("alt","major",[`${S}5`,`${M}9`,`${S}9`],[`${M}5`],[]),this.addChordName("7alt","dominant",[`${S}5`,`${M}9`,`${S}9`],[`${M}5`],[]),this.addChordName("7sus4","dominant",["4"],[],["3"]),this.addChordName("7sus4","suspendedfourth",["7"],[],[]),this.addChordName("9sus4","dominantninth",["4"],[],["3"]),this.addChordName("9sus4","suspendedfourth",["9"],[],[]),this.addChordName("11sus4","dominant11th",["4"],[],["3"]),this.addChordName("11sus4","suspendedfourth",["11"],[],[]),this.addChordName("13sus4","dominant13th",["4"],[],["3"]),this.addChordName("13sus4","suspendedfourth",["13"],[],[]),this.addChordName("7sus2","dominant",["2"],[],["3"]),this.addChordName("7sus2","suspendedsecond",["7"],[],[]),this.addChordName(`m7${M}5`,"minorseventh",[],[`${M}5`],[]),this.addChordName("9sus2","dominantninth",["2"],[],["3"]),this.addChordName("9sus2","suspendedsecond",["9"],[],[]),this.addChordName("11sus2","dominant11th",["2"],[],["3"]),this.addChordName("11sus2","suspendedsecond",["11"],[],[]),this.addChordName("13sus2","dominant13th",["2"],[],["3"]),this.addChordName("13sus2","suspendedsecond",["13"],[],[]),this.addChordName("m(maj9)","majorminor",["9"],[],[]),this.addChordName("m(maj11)","majorminor",["11"],[],[]),this.addChordName("m(maj13)","majorminor",["13"],[],[]),this.addChordName("69","majorsixth",["9"],[],[]),this.addChordName("mi69","minorsixth",["9"],[],[])}calculateCurveParametersArrays(){this.TPower3=new Array(this.BezierCurveStepSize),this.OneMinusTPower3=new Array(this.BezierCurveStepSize),this.FactorOne=new Array(this.BezierCurveStepSize),this.FactorTwo=new Array(this.BezierCurveStepSize);for(let S=0;S0}get NotToBeRemoved(){return this.notToBeRemoved}set NotToBeRemoved(f){this.notToBeRemoved=f}get Lines(){return this.lines}get ContinuousDynamic(){return this.SourceExpression}updateSkyBottomLine(){var x;const f=this.parentStaffLine.SkyBottomLineCalculator,p=this.IsVerbal?this.label.PositionAndShape.RelativePosition.x+this.label.PositionAndShape.BorderMarginLeft:0,m=this.IsVerbal?this.label.PositionAndShape.RelativePosition.x+this.label.PositionAndShape.BorderMarginRight:0;switch(!this.IsSoftAccent&&!this.IsVerbal&&this.lines.length<2&&n.default.warn("Not enough lines for SkyBottomLine calculation"),this.IsVerbal||this.ContinuousDynamic.DynamicType!==u.ContDynamicEnum.crescendo&&this.ContinuousDynamic.DynamicType!==u.ContDynamicEnum.diminuendo&&n.default.warn("GraphicalContinuousDynamicExpression.updateSkyBottomLine(): unhandled continuous dynamic type. start measure: "+((x=this.startMeasure)==null?void 0:x.MeasureNumber)),this.Placement){case o.PlacementEnum.Above:if(this.IsSoftAccent)f.updateSkyLineWithWedge(this.lines[0].Start,this.lines[0].End),f.updateSkyLineWithWedge(this.lines[2].End,this.lines[2].Start),f.updateSkyLineWithLine(this.lines[0].End,this.lines[2].End,this.lines[0].End.y);else if(this.IsVerbal){const y=this.label.PositionAndShape.BorderMarginTop+this.label.PositionAndShape.RelativePosition.y;f.updateSkyLineInRange(p,m,y)}else this.ContinuousDynamic.DynamicType===u.ContDynamicEnum.crescendo?f.updateSkyLineWithWedge(this.lines[0].Start,this.lines[0].End):this.ContinuousDynamic.DynamicType===u.ContDynamicEnum.diminuendo&&f.updateSkyLineWithWedge(this.lines[0].End,this.lines[0].Start);break;case o.PlacementEnum.Below:if(this.IsVerbal){const y=this.label.PositionAndShape.BorderMarginBottom+this.label.PositionAndShape.RelativePosition.y;f.updateBottomLineInRange(p,m,y)}else this.ContinuousDynamic.DynamicType===u.ContDynamicEnum.crescendo?f.updateBottomLineWithWedge(this.lines[1].Start,this.lines[1].End):this.ContinuousDynamic.DynamicType===u.ContDynamicEnum.diminuendo&&f.updateBottomLineWithWedge(this.lines[1].End,this.lines[1].Start);break;default:n.default.error("Placement for GraphicalContinuousDynamicExpression is unknown")}}createCrescendoLines(f,p,m,x=this.rules.WedgeOpeningLength,y=this.rules.WedgeLineWidth){const d=new r.PointF2D(f,m),S=new r.PointF2D(p,m-x/2),M=new r.PointF2D(p,m+x/2);this.addWedgeLines(d,S,M,y)}createFirstHalfCrescendoLines(f,p,m,x=this.rules.WedgeMeasureEndOpeningLength,y=this.rules.WedgeLineWidth){const d=new r.PointF2D(f,m),S=new r.PointF2D(p,m-x/2),M=new r.PointF2D(p,m+x/2);this.addWedgeLines(d,S,M,y)}createSecondHalfCrescendoLines(f,p,m,x=this.rules.WedgeMeasureBeginOpeningLength,y=this.rules.WedgeOpeningLength,d=this.rules.WedgeLineWidth){const S=new r.PointF2D(f,m-x/2),M=new r.PointF2D(f,m+x/2),E=new r.PointF2D(p,m-y/2),L=new r.PointF2D(p,m+y/2);this.addDoubleLines(S,E,M,L,d)}recalculateCrescendoLines(f,p,m){const x=Math.abs(this.lines[0].Start.y-this.lines[1].Start.y)>1e-4;this.lines.clear(),x?this.createSecondHalfCrescendoLines(f,p,m):this.isSplittedPart?this.createFirstHalfCrescendoLines(f,p,m):this.createCrescendoLines(f,p,m)}createDiminuendoLines(f,p,m,x=this.rules.WedgeOpeningLength,y=this.rules.WedgeLineWidth){const d=new r.PointF2D(f,m-x/2),S=new r.PointF2D(f,m+x/2),M=new r.PointF2D(p,m);this.addWedgeLines(M,d,S,y)}createFirstHalfDiminuendoLines(f,p,m,x=this.rules.WedgeOpeningLength,y=this.rules.WedgeMeasureEndOpeningLength,d=this.rules.WedgeLineWidth){const S=new r.PointF2D(f,m-x/2),M=new r.PointF2D(f,m+x/2),E=new r.PointF2D(p,m-y/2),L=new r.PointF2D(p,m+y/2);this.addDoubleLines(S,E,M,L,d)}createSecondHalfDiminuendoLines(f,p,m,x=this.rules.WedgeMeasureBeginOpeningLength,y=this.rules.WedgeLineWidth){const d=new r.PointF2D(f,m-x/2),S=new r.PointF2D(f,m+x/2),M=new r.PointF2D(p,m);this.addWedgeLines(M,d,S,y)}recalculateDiminuendoLines(f,p,m){const x=Math.abs(this.lines[0].End.y-this.lines[1].End.y)>1e-4;this.lines.clear(),x?this.createFirstHalfDiminuendoLines(f,p,m):this.isSplittedPart?this.createSecondHalfDiminuendoLines(f,p,m):this.createDiminuendoLines(f,p,m)}createFirstHalfLines(f,p,m,x=this.rules.WedgeOpeningLength,y=this.rules.WedgeMeasureEndOpeningLength,d=this.rules.WedgeLineWidth){this.ContinuousDynamic.DynamicType===u.ContDynamicEnum.crescendo?this.createFirstHalfCrescendoLines(f,p,m,y,d):this.ContinuousDynamic.DynamicType===u.ContDynamicEnum.diminuendo&&this.createFirstHalfDiminuendoLines(f,p,m,x,y,d)}createSecondHalfLines(f,p,m,x=this.rules.WedgeMeasureBeginOpeningLength,y=this.rules.WedgeOpeningLength,d=this.rules.WedgeLineWidth){this.ContinuousDynamic.DynamicType===u.ContDynamicEnum.crescendo?this.createSecondHalfCrescendoLines(f,p,m,x,y,d):this.ContinuousDynamic.DynamicType===u.ContDynamicEnum.diminuendo&&this.createSecondHalfDiminuendoLines(f,p,m,x,d)}createLines(f,p,m,x=this.rules.WedgeOpeningLength,y=this.rules.WedgeLineWidth){this.ContinuousDynamic.DynamicType===u.ContDynamicEnum.crescendo?this.createCrescendoLines(f,p,m,x,y):this.ContinuousDynamic.DynamicType===u.ContDynamicEnum.diminuendo&&this.createDiminuendoLines(f,p,m,x,y)}calcPsi(){this.IsVerbal?this.PositionAndShape.calculateBoundingBox():(this.PositionAndShape.RelativePosition=this.lines[0].Start,this.PositionAndShape.BorderMarginTop=this.lines[0].End.y-this.lines[0].Start.y,this.PositionAndShape.BorderMarginBottom=this.lines[1].End.y-this.lines[1].Start.y,this.PositionAndShape.Center.y=(this.PositionAndShape.BorderMarginTop+this.PositionAndShape.BorderMarginBottom)/2,this.IsSoftAccent?(this.PositionAndShape.BorderMarginLeft=0,this.PositionAndShape.BorderMarginRight=this.lines[3].Start.x-this.lines[0].Start.x):this.ContinuousDynamic.DynamicType===u.ContDynamicEnum.crescendo?(this.PositionAndShape.BorderMarginLeft=0,this.PositionAndShape.BorderMarginRight=this.lines[0].End.x-this.lines[0].Start.x):(this.PositionAndShape.BorderMarginLeft=this.lines[0].End.x-this.lines[0].Start.x,this.PositionAndShape.BorderMarginRight=0))}cleanUp(){this.lines.clear()}shiftYPosition(f){this.IsVerbal?(this.PositionAndShape.RelativePosition.y+=f,this.PositionAndShape.calculateBoundingBox()):(this.lines[0].Start.y+=f,this.lines[0].End.y+=f,this.lines[1].End.y+=f)}squeeze(f){this.IsVerbal||Math.abs(this.lines[0].End.x-this.lines[0].Start.x)0?this.lines[0].Start.x+=f:(this.lines[0].End.x+=f,this.lines[1].End.x+=f):f<0?this.lines[0].Start.x+=f:(this.lines[0].End.x+=f,this.lines[1].End.x+=f),this.calcPsi())}addWedgeLines(f,p,m,x){const y=new s.GraphicalLine(f,p,x),d=new s.GraphicalLine(f,m,x);this.rules.DefaultColorMusic&&(y.colorHex=this.rules.DefaultColorMusic,d.colorHex=this.rules.DefaultColorMusic),this.lines.push(y),this.lines.push(d)}addDoubleLines(f,p,m,x,y){const d=new s.GraphicalLine(f,p,y),S=new s.GraphicalLine(m,x,y);this.rules.DefaultColorMusic&&(d.colorHex=this.rules.DefaultColorMusic,S.colorHex=this.rules.DefaultColorMusic),this.lines.push(d),this.lines.push(S)}}g.GraphicalContinuousDynamicExpression=h},6711(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.GraphicalCurve=void 0;const l=c(9409);class s{constructor(){s.tPow3=new Array(s.bezierCurveStepSize),s.oneMinusTPow3=new Array(s.bezierCurveStepSize),s.bezierFactorOne=new Array(s.bezierCurveStepSize),s.bezierFactorTwo=new Array(s.bezierCurveStepSize);for(let r=0;r=s.bezierCurveStepSize?new l.PointF2D:new l.PointF2D(s.oneMinusTPow3[i]*this.bezierStartPt.x+s.bezierFactorOne[i]*this.bezierStartControlPt.x+s.bezierFactorTwo[i]*this.bezierEndControlPt.x+s.tPow3[i]*this.bezierEndPt.x,s.oneMinusTPow3[i]*this.bezierStartPt.y+s.bezierFactorOne[i]*this.bezierStartControlPt.y+s.bezierFactorTwo[i]*this.bezierEndControlPt.y+s.tPow3[i]*this.bezierEndPt.y)}}g.GraphicalCurve=s,s.bezierCurveStepSize=1e3},98(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.GraphicalGlissando=void 0;const l=c(9409),s=c(6438),u=c(6452);g.GraphicalGlissando=class{constructor(r){this.Glissando=r,this.staffEntries=[]}calculateLine(r){const i=this.staffEntries[0],o=this.staffEntries[this.staffEntries.length-1],n=i.findGraphicalNoteFromNote(this.Glissando.StartNote),h=o.findGraphicalNoteFromNote(this.Glissando.EndNote);if(!n&&!h)return;const t=i.parentMeasure.ParentStaffLine;let f,p,m,x;if(n&&i.parentMeasure.ParentStaffLine===this.StaffLine)f=n.PositionAndShape.RelativePosition.x+n.parentVoiceEntry.parentStaffEntry.PositionAndShape.RelativePosition.x+n.parentVoiceEntry.parentStaffEntry.parentMeasure.PositionAndShape.RelativePosition.x+r.GlissandoNoteOffset,m=n.PositionAndShape.AbsolutePosition.y;else{f=o.parentMeasure.beginInstructionsWidth-.4;const S=this.Glissando.Direction===s.ColDirEnum.Down?-1:1;m=h.PositionAndShape.AbsolutePosition.y+S*r.GlissandoStafflineStartYDistanceToNote}if(h&&o.parentMeasure.ParentStaffLine===this.StaffLine)p=h.PositionAndShape.RelativePosition.x+h.parentVoiceEntry.parentStaffEntry.PositionAndShape.RelativePosition.x+h.parentVoiceEntry.parentStaffEntry.parentMeasure.PositionAndShape.RelativePosition.x-.5-r.GlissandoNoteOffset,f>p&&(f=p-r.GlissandoStafflineStartMinimumWidth),x=h.PositionAndShape.AbsolutePosition.y;else{if(t.Measures.last().parentSourceMeasure.HasEndLine)return;p=t.PositionAndShape.Size.width,p-f>r.GlissandoStafflineEndOffset&&(f=p-r.GlissandoStafflineEndOffset);const S=this.Glissando.Direction===s.ColDirEnum.Down?1:-1;x=n.PositionAndShape.AbsolutePosition.y+S*r.GlissandoStafflineStartYDistanceToNote}const y=new l.PointF2D(f,m),d=new l.PointF2D(p,x);this.Width===void 0&&(this.Width=r.GlissandoDefaultWidth),this.Line=new u.GraphicalLine(y,d,this.Width)}}},5023(de,g,c){var l=this&&this.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(g,"__esModule",{value:!0}),g.GraphicalInstantaneousDynamicExpression=void 0;const s=c(9490),u=c(6362),r=l(c(3065));class i extends s.AbstractGraphicalExpression{constructor(n,h,t){super(h,n,t.parentSourceMeasure),this.mInstantaneousDynamicExpression=n,this.mMeasure=t}updateSkyBottomLine(){const n=this.parentStaffLine.SkyBottomLineCalculator,h=this.PositionAndShape.RelativePosition.x+this.PositionAndShape.BorderMarginLeft,t=this.PositionAndShape.RelativePosition.x+this.PositionAndShape.BorderMarginRight;let f=0;switch(this.Placement){case u.PlacementEnum.Above:f=this.PositionAndShape.RelativePosition.y+this.PositionAndShape.BorderMarginTop,n.updateSkyLineInRange(h,t,f);break;case u.PlacementEnum.Below:f=this.PositionAndShape.RelativePosition.y+this.PositionAndShape.BorderMarginBottom,n.updateBottomLineInRange(h,t,f);break;default:r.default.error("Placement for GraphicalInstantaneousDynamicExpression is unknown")}}}g.GraphicalInstantaneousDynamicExpression=i},3361(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.GraphicalInstantaneousTempoExpression=void 0;const l=c(9490);class s extends l.AbstractGraphicalExpression{constructor(r,i){super(i.PositionAndShape.Parent.DataObject,r,r.parentMeasure),this.label=i}get GraphicalLabel(){return this.label}updateSkyBottomLine(){}}g.GraphicalInstantaneousTempoExpression=s},8254(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.GraphicalLabel=void 0;const l=c(7533),s=c(6438),u=c(995),r=c(7921);class i extends u.Clickable{constructor(n,h,t,f,p=void 0){super(),this.CenteringXShift=0,this.label=n,this.boundingBox=new s.BoundingBox(this,p),this.label.fontHeight=h,this.label.textAlignment=t,this.rules=f}get Label(){return this.label}toString(){return`${this.label.text} (${this.boundingBox.RelativePosition.x},${this.boundingBox.RelativePosition.y})`}setLabelPositionAndShapeBorders(){var x;if(this.Label.text.trim()==="")return;this.TextLines=[];const n=((x=this.rules)==null?void 0:x.LabelMarginBorderFactor)??.1,h=this.Label.text.split(/[\n\r]+/g),t=h.length;let f=0;for(let y=0;y0&&this.TextLines.length>1&&(p+=this.rules.SpacingBetweenTextLines*t/10);const m=this.PositionAndShape;switch(this.Label.textAlignment){case l.TextAlignmentEnum.CenterBottom:m.BorderTop=-p,m.BorderLeft=-f/2,m.BorderBottom=0,m.BorderRight=f/2;break;case l.TextAlignmentEnum.CenterCenter:m.BorderTop=-p/2,m.BorderLeft=-f/2,m.BorderBottom=p/2,m.BorderRight=f/2;break;case l.TextAlignmentEnum.CenterTop:m.BorderTop=0,m.BorderLeft=-f/2,m.BorderBottom=p,m.BorderRight=f/2;break;case l.TextAlignmentEnum.LeftBottom:m.BorderTop=-p,m.BorderLeft=0,m.BorderBottom=0,m.BorderRight=f;break;case l.TextAlignmentEnum.LeftCenter:m.BorderTop=-p/2,m.BorderLeft=0,m.BorderBottom=p/2,m.BorderRight=f;break;case l.TextAlignmentEnum.LeftTop:m.BorderTop=0,m.BorderLeft=0,m.BorderBottom=p,m.BorderRight=f;break;case l.TextAlignmentEnum.RightBottom:m.BorderTop=-p,m.BorderLeft=-f,m.BorderBottom=0,m.BorderRight=0;break;case l.TextAlignmentEnum.RightCenter:m.BorderTop=-p/2,m.BorderLeft=-f,m.BorderBottom=p/2,m.BorderRight=0;break;case l.TextAlignmentEnum.RightTop:m.BorderTop=0,m.BorderLeft=-f,m.BorderBottom=p,m.BorderRight=0}m.BorderMarginTop=m.BorderTop-p*n,m.BorderMarginLeft=m.BorderLeft-p*n,m.BorderMarginBottom=m.BorderBottom+p*n,m.BorderMarginRight=m.BorderRight+p*n}}g.GraphicalLabel=i},6452(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.GraphicalLine=void 0;const l=c(2683);g.GraphicalLine=class{constructor(s,u,r=0,i=l.OutlineAndFillStyleEnum.BaseWritingColor,o=void 0){this.start=s,this.end=u,this.width=r,this.styleId=i,this.colorHex=o}get Start(){return this.start}set Start(s){this.start=s}get End(){return this.end}set End(s){this.end=s}get Width(){return this.width}set Width(s){this.width=s}}},2395(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.GraphicalLyricEntry=void 0;const l=c(8254),s=c(7435),u=c(9409),r=c(7533);g.GraphicalLyricEntry=class{constructor(i,o,n,h){this.lyricsEntry=i,this.graphicalStaffEntry=o;const t=o.parentMeasure.parentSourceMeasure.Rules.LyricsAlignmentStandard;i.Text.length>=4&&i.Parent.Notes[0].Length.Denominator>4&&r.TextAlignmentEnum.LeftBottom;const f=new s.Label(i.Text),p=this.graphicalStaffEntry.parentMeasure.parentSourceMeasure.Rules;this.graphicalLabel=new l.GraphicalLabel(f,n,t,p,o.PositionAndShape),this.graphicalLabel.Label.colorDefault=p.DefaultColorLyrics,this.graphicalLabel.PositionAndShape.RelativePosition=new u.PointF2D(0,h),this.graphicalLabel.setLabelPositionAndShapeBorders(),this.graphicalLabel.PositionAndShape.Size.width1&&i1}isVisible(){return this.ParentStaff.isVisible()}isMultiRestMeasure(){return this.multiRestElement!==void 0}getGraphicalMeasureDurationFromStaffEntries(){let n=new s.Fraction(0,1);const h=[];for(let t=0,f=this.staffEntries.length;t0&&m.Add(y.notes[0].graphicalNoteLength);n.lt(m)&&(n=s.Fraction.createFromFraction(m))}return n}addGraphicalStaffEntry(n){this.staffEntries.push(n)}addGraphicalStaffEntryAtTimestamp(n){if(n)if(this.staffEntries.length===0||this.staffEntries[this.staffEntries.length-1].relInMeasureTimestamp.lt(n.relInMeasureTimestamp))this.staffEntries.push(n);else for(let h=this.staffEntries.length-1;h>=0;h--){if(this.staffEntries[h].relInMeasureTimestamp.lt(n.relInMeasureTimestamp)){this.staffEntries.splice(h+1,0,n);break}h===0&&this.staffEntries.splice(h,0,n)}}isPianoRightHand(){return this.isUpperStaffOfInstrument()}isPianoLeftHand(){return this.isLowerStaffOfInstrument()}isUpperStaffOfInstrument(){return this.parentStaff.ParentInstrument.Staves.length===1||this.ParentStaff===this.parentStaff.ParentInstrument.Staves[0]}isLowerStaffOfInstrument(){return this.parentStaff.ParentInstrument.Staves.length!==1&&this.ParentStaff===this.ParentStaff.ParentInstrument.Staves.last()}beginsWithLineRepetition(){const n=this.parentSourceMeasure;return!!n&&n.beginsWithLineRepetition()}endsWithLineRepetition(){const n=this.parentSourceMeasure;return!!n&&n.endsWithLineRepetition()}beginsWithWordRepetition(){const n=this.parentSourceMeasure;return!!n&&n.beginsWithWordRepetition()}endsWithWordRepetition(){const n=this.parentSourceMeasure;return!!n&&n.endsWithWordRepetition()}getTransposedHalftones(){return this.parentStaff.ParentInstrument.GetMusicSheet.Transpose+this.parentStaff.ParentInstrument.Transpose}}g.GraphicalMeasure=i},1888(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.PagePlacementEnum=g.GraphicalMusicPage=void 0;const l=c(6438),s=c(7741),u=c(9409);class r extends s.GraphicalObject{constructor(n){super(),this.musicSystems=[],this.labels=[],this.parent=n,this.boundingBox=new l.BoundingBox(this,void 0)}get MusicSystems(){return this.musicSystems}set MusicSystems(n){this.musicSystems=n}get Labels(){return this.labels}set Labels(n){this.labels=n}get Parent(){return this.parent}set Parent(n){this.parent=n}get PageNumber(){return this.pageNumber}set PageNumber(n){this.pageNumber=n}setMusicPageAbsolutePosition(n,h){return new u.PointF2D(0,0)}}var i;g.GraphicalMusicPage=r,function(o){o[o.Down=0]="Down",o[o.Right=1]="Right",o[o.RightDown=2]="RightDown"}(i||(g.PagePlacementEnum=i={}))},8724(de,g,c){var l=this&&this.__importDefault||function(y){return y&&y.__esModule?y:{default:y}};Object.defineProperty(g,"__esModule",{value:!0}),g.SystemImageProperties=g.GraphicalMusicSheet=void 0;const s=c(6723),u=c(6452),r=c(348),i=c(9409),o=c(164),n=c(4543),h=c(2561),t=c(6438),f=l(c(3065)),p=c(813),m=c(4548),x=c(7741);g.GraphicalMusicSheet=class{constructor(y,d){this.musicPages=[],this.measureList=[],this.verticalGraphicalStaffEntryContainers=[],this.cursors=[],this.leadSheet=!1,this.musicSheet=y,this.numberOfStaves=this.musicSheet.Staves.length,this.calculator=d,this.calculator.initialize(this)}get ParentMusicSheet(){return this.musicSheet}get GetCalculator(){return this.calculator}get MusicPages(){return this.musicPages}set MusicPages(y){this.musicPages=y}get MeasureList(){return this.measureList}set MeasureList(y){this.measureList=y}get VerticalGraphicalStaffEntryContainers(){return this.verticalGraphicalStaffEntryContainers}set VerticalGraphicalStaffEntryContainers(y){this.verticalGraphicalStaffEntryContainers=y}get Title(){return this.title}set Title(y){this.title=y}get Subtitle(){return this.subtitle}set Subtitle(y){this.subtitle=y}get Composer(){return this.composer}set Composer(y){this.composer=y}get Lyricist(){return this.lyricist}set Lyricist(y){this.lyricist=y}get Copyright(){return this.copyright}set Copyright(y){this.copyright=y}get Cursors(){return this.cursors}get SelectionStartSymbol(){return this.selectionStartSymbol}get SelectionEndSymbol(){return this.selectionEndSymbol}get MinAllowedSystemWidth(){return this.minAllowedSystemWidth}set MinAllowedSystemWidth(y){this.minAllowedSystemWidth=y}get NumberOfStaves(){return this.numberOfStaves}get LeadSheet(){return this.leadSheet}set LeadSheet(y){this.leadSheet=y}static transformRelativeToAbsolutePosition(y){for(let d=0;d=0;M--){const E=(S=this.measureList[M])==null?void 0:S[d];if(E)return E}}findGraphicalMeasureByMeasureNumber(y,d){for(let S=y;S>=0;S--)if(this.MeasureList[S]){const M=this.MeasureList[S][d];if((M==null?void 0:M.MeasureNumber)===y)return M}}findGraphicalStaffEntryFromMeasureList(y,d,S){for(let M=d;M0)return L.staffEntries[0]}}getFirstVisibleMeasuresListFromIndices(y,d){const S=[],M=this.measureList[0].length;for(let E=y;E<=d;E++)for(let L=0;L=0;d--){if(this.verticalGraphicalStaffEntryContainers[d].AbsoluteTimestamp.lt(y)){const S=new s.VerticalGraphicalStaffEntryContainer(this.numberOfStaves,y);return this.verticalGraphicalStaffEntryContainers.splice(d+1,0,S),S}if(this.verticalGraphicalStaffEntryContainers[d].AbsoluteTimestamp.Equals(y))return this.verticalGraphicalStaffEntryContainers[d]}}GetVerticalContainerFromTimestamp(y,d=0){const S=p.CollectionUtil.binarySearch(this.verticalGraphicalStaffEntryContainers,new s.VerticalGraphicalStaffEntryContainer(0,y),s.VerticalGraphicalStaffEntryContainer.compareByTimestamp,d);if(S>=0)return this.verticalGraphicalStaffEntryContainers[S]}GetInterpolatedIndexInVerticalContainers(y){const d=this.verticalGraphicalStaffEntryContainers;if(d.length===1)return 0;let S,M,E=0,L=d.length-1;if(y.lte(d[d.length-1].AbsoluteTimestamp)){for(;L-E>1;){const A=Math.floor((L+E)/2);if(d[E].AbsoluteTimestamp.Equals(y)){L=E;break}if(d[L].AbsoluteTimestamp.Equals(y)){E=L;break}if(d[A].AbsoluteTimestamp.Equals(y))return this.verticalGraphicalStaffEntryContainers.indexOf(d[A]);y.lt(d[A].AbsoluteTimestamp)?L=A:E=A}if(E===L)return this.verticalGraphicalStaffEntryContainers.indexOf(d[E]);S=d[E].AbsoluteTimestamp,M=d[L].AbsoluteTimestamp}else S=d[d.length-1].AbsoluteTimestamp,M=h.Fraction.plus(this.getLongestStaffEntryDuration(d.length-1),S),L=d.length;const I=M.RealValue-S.RealValue,T=L-(M.RealValue-y.RealValue)/I;return Math.min(T,this.verticalGraphicalStaffEntryContainers.length-1)}getVisibleStavesIndicesFromSourceMeasure(y){const d=[],S=[];for(let M=0,E=y.length;M=0;)M=this.measureList[--S][y];return this.measureList[S][y]}getMeasureIndex(y,d,S){for(d=0;d{var S;return((S=d.parentStaffEntry)==null?void 0:S.relInMeasureTimestamp)!==void 0})}GetNearestNote(y,d){const S=this.GetNearestVoiceEntry(y);if(!S)return;let M,E=Number.MAX_SAFE_INTEGER;for(const L of S.notes){const I=L.PositionAndShape.AbsolutePosition.y,T=Math.abs(L.PositionAndShape.AbsolutePosition.x-y.x),A=Math.abs(I-y.y);T+AL.PositionAndShape.RelativePosition.x&&(S=L):S=L)}}catch(M){f.default.info("GraphicalMusicSheet.getStaffEntry",M)}return S}GetPreviousVisibleContainerIndex(y){for(let d=y-1;d>=0;d--){const S=this.verticalGraphicalStaffEntryContainers[d].StaffEntries;for(let M=0,E=S.length;M=0;E--)if(S=this.getStaffEntry(E),S&&(!d||S.sourceStaffEntry.ParentStaff.isVisible()))return S}findClosestRightStaffEntry(y,d){let S;for(let M=Math.max(0,Math.ceil(y));Md.RealValue?1:d.RealValue>y.RealValue?-1:0}calculateCurve(m){const x=this.staffEntries[0],y=this.staffEntries[this.staffEntries.length-1];let d=x.findGraphicalNoteFromNote(this.slur.StartNote);!d&&this.graceStart&&(d=x.findGraphicalNoteFromGraceNote(this.slur.StartNote)),d||(d=x.findEndTieGraphicalNoteFromNoteWithStartingSlur(this.slur.StartNote,this.slur));let S=y.findGraphicalNoteFromNote(this.slur.EndNote);!S&&this.graceEnd&&(S=y.findGraphicalNoteFromGraceNote(this.slur.EndNote));const M=x.parentMeasure.ParentStaffLine,E=M.SkyBottomLineCalculator;this.calculatePlacement(E,M);const L=this.calculateStartAndEnd(d,S,M,m,E),I=L.startX,T=L.endX;let A=L.startY,v=L.endY;const B=m.SlurTangentMinAngle,D=m.SlurTangentMaxAngle;let _;if(this.placement===r.PlacementEnum.Above){A-=m.SlurNoteHeadYOffset,v-=m.SlurNoteHeadYOffset;const F=new s.PointF2D(this.staffEntries[0].parentMeasure.PositionAndShape.RelativePosition.x+this.staffEntries[0].PositionAndShape.RelativePosition.x,A);d?F.x+=this.staffEntries[0].PositionAndShape.BorderRight:F.x=this.staffEntries[0].parentMeasure.beginInstructionsWidth,this.graceStart&&(F.x+=y.PositionAndShape.RelativePosition.x);const k=new s.PointF2D(this.staffEntries[this.staffEntries.length-1].parentMeasure.PositionAndShape.RelativePosition.x+this.staffEntries[this.staffEntries.length-1].PositionAndShape.RelativePosition.x,v);if(S?k.x+=this.staffEntries[this.staffEntries.length-1].PositionAndShape.BorderLeft:k.x=this.staffEntries[this.staffEntries.length-1].parentMeasure.PositionAndShape.RelativePosition.x+this.staffEntries[this.staffEntries.length-1].parentMeasure.PositionAndShape.Size.width,this.graceEnd&&(k.x+=y.staffEntryParent.PositionAndShape.RelativePosition.x),_=this.calculateTopPoints(F,k,M,E),_.length===0){const Se=new s.PointF2D((k.x-F.x)/2+F.x,(k.y-F.y)/2+F.y);_.push(Se)}const j=Math.atan((v-A)/(T-I)),P=new s.PointF2D(0,0);let G=new s.PointF2D(T-I,-(v-A));const Y=i.Matrix2D.getRotationMatrix(j),X=Y.getTransposeMatrix();G=Y.vectorMultiplication(G);const ie=this.calculateTranslatedAndRotatedPointListAbove(_,I,A,Y),oe=this.calculateMaxLeftSlope(ie,P,G),$=this.calculateMaxRightSlope(ie,P,G),Q=P.y-P.x*oe,ne=G.y-G.x*$,ee=new s.PointF2D;let N=!1;Math.abs(Math.abs(oe)-Math.abs($))<1e-4?(ee.x=G.x/2,ee.y=0,N=!0):(ee.x=(ne-Q)/(oe-$),ee.y=oe*ee.x+Q);const R=this.calculateHeightWidthRatio(G.x,ie),O=0,U=0;let H=B,W=-B;if(!N){const Se=this.calculateAngles(B,oe,$,D);H=Se.startAngle,W=Se.endAngle}const K=this.calculateControlPoints(G.x,H,W,ie,R,A,v);let q=K.startControlPoint,te=K.endControlPoint;q=X.vectorMultiplication(q),q.x+=I,q.y=-q.y+A,te=X.vectorMultiplication(te),te.x+=I,te.y=-te.y+A,this.bezierStartPt=new s.PointF2D(I,A-O),this.bezierStartControlPt=new s.PointF2D(q.x,q.y-O),this.bezierEndControlPt=new s.PointF2D(te.x,te.y-U),this.bezierEndPt=new s.PointF2D(T,v-U);const se=M.SkyLine.length,ue=E.getLeftIndexForPointX(this.bezierStartPt.x,se),fe=E.getLeftIndexForPointX(this.bezierEndPt.x,se),xe=this.bezierEndPt.x-this.bezierStartPt.x,ve=E.SamplingUnit;for(let Se=ue;Se=ue&&(M.SkyLine[Me]=Math.min(M.SkyLine[Me],be.y)),Me++,Me=ue&&(M.BottomLine[Me]=Math.max(M.BottomLine[Me],be.y)),Me++,Me0)return void(this.placement=r.PlacementEnum.Above);const y=this.staffEntries[0],d=this.staffEntries[this.staffEntries.length-1],S=y.graphicalVoiceEntries[0].parentVoiceEntry.StemDirection;if(S===d.graphicalVoiceEntries[0].parentVoiceEntry.StemDirection)this.placement=S===h.StemDirectionType.Up?r.PlacementEnum.Below:r.PlacementEnum.Above,this.rules.SlurPlacementAtStems&&(this.placement=S===h.StemDirectionType.Up?r.PlacementEnum.Above:r.PlacementEnum.Below);else{let M=y.PositionAndShape.BorderLeft+y.PositionAndShape.RelativePosition.x+y.parentMeasure.PositionAndShape.RelativePosition.x,E=d.PositionAndShape.BorderRight+d.PositionAndShape.RelativePosition.x+d.parentMeasure.PositionAndShape.RelativePosition.x;this.graceStart&&(M+=d.PositionAndShape.RelativePosition.x),this.graceEnd&&(E+=d.staffEntryParent.PositionAndShape.RelativePosition.x);const L=-1*m.getSkyLineMinInRange(M,E),I=m.getBottomLineMaxInRange(M,E)-x.StaffHeight;this.placement=I>L?r.PlacementEnum.Above:r.PlacementEnum.Below}}calculateTopPoints(m,x,y,d){const S=[];let M=d.getRightIndexForPointX(m.x,y.SkyLine.length),E=d.getLeftIndexForPointX(x.x,y.SkyLine.length);M<0&&(M=0),E>=y.SkyLine.length&&(E=y.SkyLine.length-1);for(let L=M;L=y.BottomLine.length&&(E=y.BottomLine.length-1);for(let L=M;LT&&m>A&&(I+=m/70*this.rules.SlurHeightFlattenLongSlursFactorByWidth,I*=1+x/30*this.rules.SlurHeightFlattenLongSlursFactorByAngle,L/=I);const v=Math.min(.5,Math.max(.1,1.7*x/80*L*Math.pow(Math.max(S,.05),.4))),B=Math.min(.5,Math.max(.1,1.7*-y/80*L*Math.pow(Math.max(S,.05),.4))),D=new s.PointF2D;D.x=m*v*Math.cos(x*f.degreesToRadiansFactor),D.y=m*v*Math.sin(x*f.degreesToRadiansFactor);const _=new s.PointF2D;_.x=m-m*B*Math.cos(y*f.degreesToRadiansFactor),_.y=-m*B*Math.sin(y*f.degreesToRadiansFactor);let F=D.y-_.y;for(;this.rules.SlurMaximumYControlPointDistance&&Math.abs(F)>this.rules.SlurMaximumYControlPointDistance;)F<0?(D.y+=1,_.y-=1):(D.y-=1,_.y+=1),F=D.y-_.y;return{startControlPoint:D,endControlPoint:_}}calculateAngles(m,x,y,d){let S=Math.atan(x)/f.degreesToRadiansFactor;x>0?S+=20:S-=20;let M=Math.atan(y)/f.degreesToRadiansFactor;return y<0?M-=20:M+=20,{startAngle:Math.min(Math.max(m,S),d),endAngle:Math.max(Math.min(-m,M),-d)}}}g.GraphicalSlur=f,f.degreesToRadiansFactor=Math.PI/180},348(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.GraphicalStaffEntry=void 0;const l=c(6438),s=c(2561),u=c(7741),r=c(813),i=c(7921);class o extends u.GraphicalObject{constructor(h,t=void 0,f=void 0){super(),this.graphicalChordContainers=[],this.tabStaffEntry=void 0,this.MaxAccidentals=0,this.graphicalInstructions=[],this.ties=[],this.graphicalTies=[],this.lyricsEntries=[],this.parentMeasure=h,this.graphicalVoiceEntries=[],this.sourceStaffEntry=t,f?(this.staffEntryParent=f,this.parentVerticalContainer=f.parentVerticalContainer,this.PositionAndShape=new l.BoundingBox(this,f.PositionAndShape)):this.PositionAndShape=new l.BoundingBox(this,h.PositionAndShape),t&&(this.relInMeasureTimestamp=t.Timestamp),this.FingeringEntries=[]}get GraphicalInstructions(){return this.graphicalInstructions}get GraphicalTies(){return this.graphicalTies}get LyricsEntries(){return this.lyricsEntries}set LyricsEntries(h){this.lyricsEntries=h}getAbsoluteTimestamp(){const h=this.parentMeasure.parentSourceMeasure.AbsoluteTimestamp.clone();return this.relInMeasureTimestamp&&h.Add(this.relInMeasureTimestamp),h}findTieGraphicalNoteFromNote(h){for(const t of this.graphicalVoiceEntries)for(const f of t.notes){const p=f.sourceNote;if(!p.isRest()&&p.Pitch.FundamentalNote===h.Pitch.FundamentalNote&&p.Pitch.Octave===h.Pitch.Octave&&p.getAbsoluteTimestamp().Equals(h.getAbsoluteTimestamp()))return f}}findEndTieGraphicalNoteFromNoteWithStartingSlur(h,t){if(h){for(const f of this.graphicalVoiceEntries)if(f.parentVoiceEntry===h.ParentVoiceEntry)for(const p of f.notes){const m=p.sourceNote;if(m.NoteTie&&m.NoteSlurs.indexOf(t)!==-1)return p}}}findGraphicalNoteFromGraceNote(h){if(h){for(const t of this.graphicalVoiceEntries)if(t.parentVoiceEntry===h.ParentVoiceEntry){for(const f of t.notes)if(f.sourceNote===h)return f}}}findGraphicalNoteFromNote(h){if(h){for(const t of this.graphicalVoiceEntries)if(t.parentVoiceEntry===h.ParentVoiceEntry){for(const f of t.notes)if(f.sourceNote===h&&this.getAbsoluteTimestamp().Equals(h.getAbsoluteTimestamp()))return f}}}getGraphicalNoteDurationFromVoice(h){for(const t of this.graphicalVoiceEntries)if(t.parentVoiceEntry.ParentVoice===h)return t.notes[0].graphicalNoteLength;return new s.Fraction(0,1)}findVoiceEntryGraphicalNotes(h){for(const t of this.graphicalVoiceEntries)if(t.parentVoiceEntry===h)return t.notes}isVoiceEntryPartOfLinkedVoiceEntry(h){if(this.sourceStaffEntry.Link)for(let t=0,f=this.sourceStaffEntry.Link.LinkStaffEntries.length;t0&&(h=p)}return h}findStaffEntryMaxNoteLength(){let h=new s.Fraction(0,1);for(const t of this.graphicalVoiceEntries)for(const f of t.notes){const p=f.graphicalNoteLength;h.lt(p)&&p.GetExpandedNumerator()>0&&(h=p)}return h}findOrCreateGraphicalVoiceEntry(h){for(const f of this.graphicalVoiceEntries)if(f.parentVoiceEntry===h)return f;const t=i.MusicSheetCalculator.symbolFactory.createVoiceEntry(h,this);return this.graphicalVoiceEntries.push(t),t}findOrCreateGraphicalVoiceEntryFromGraphicalNote(h){for(const f of this.graphicalVoiceEntries)if(f===h.parentVoiceEntry)return f;const t=i.MusicSheetCalculator.symbolFactory.createVoiceEntry(h.sourceNote.ParentVoiceEntry,this);return this.graphicalVoiceEntries.push(t),t}addGraphicalNoteToListAtCorrectYPosition(h,t){const f=h.notes;if(f.length===0||t.PositionAndShape.RelativePosition.y=0;p--){if(f[p].PositionAndShape.RelativePosition.y>t.PositionAndShape.RelativePosition.y){f.splice(p+1,0,t);break}if(p===0){f.splice(0,0,t);break}}}hasOnlyRests(){return this.sourceStaffEntry.hasOnlyRests}getSkylineMin(){var p;const h=(p=this.parentMeasure)==null?void 0:p.ParentStaffLine.SkyBottomLineCalculator;if(!h)return;const[t,f]=this.getAbsoluteStartAndEnd();return h.getSkyLineMinInRange(t,f)}getHighestYAtEntry(){return this.parentMeasure.ParentStaffLine.PositionAndShape.AbsolutePosition.y+this.getSkylineMin()}getLowestYAtEntry(){return this.parentMeasure.ParentStaffLine.PositionAndShape.AbsolutePosition.y+this.getBottomlineMax()}getBottomlineMax(){var p;const h=(p=this.parentMeasure)==null?void 0:p.ParentStaffLine.SkyBottomLineCalculator;if(!h)return;const[t,f]=this.getAbsoluteStartAndEnd();return h.getBottomLineMaxInRange(t,f)}getAbsoluteStartAndEnd(){let h=this.PositionAndShape.AbsolutePosition.x;return h-=this.parentMeasure.ParentStaffLine.PositionAndShape.AbsolutePosition.x,[h,h+this.PositionAndShape.Size.width]}}g.GraphicalStaffEntry=o},9760(de,g){Object.defineProperty(g,"__esModule",{value:!0}),g.GraphicalStaffEntryLink=void 0,g.GraphicalStaffEntryLink=class{constructor(c){this.graphicalLinkedStaffEntries=[],this.staffEntryLink=c,this.initialize()}get GetStaffEntryLink(){return this.staffEntryLink}get GraphicalLinkedStaffEntries(){return this.graphicalLinkedStaffEntries}set GraphicalLinkedStaffEntries(c){this.graphicalLinkedStaffEntries=c}isFilled(){for(let c=0;c{var h,t;return(((h=n.sourceNote.Pitch)==null?void 0:h.getHalfTone())??0)-(((t=o.sourceNote.Pitch)==null?void 0:t.getHalfTone())??0)}),this.notes}sortForVexflow(){return this.notes.sort((o,n)=>{var h;return(((h=o.sourceNote.Pitch)==null?void 0:h.getHalfTone())??0)-(n.sourceNote.Pitch.getHalfTone()??0)}),this.notes}applyCustomNoteheads(){}color(){}}g.GraphicalVoiceEntry=r},7753(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.GraphicalWavyLine=void 0;const l=c(6438),s=c(7741);class u extends s.GraphicalObject{constructor(i,o){super(),this.getWavyLine=i,this.PositionAndShape=new l.BoundingBox(this,o)}}g.GraphicalWavyLine=u},7225(de,g){Object.defineProperty(g,"__esModule",{value:!0})},7921(de,g,c){var l=this&&this.__importDefault||function(ee){return ee&&ee.__esModule?ee:{default:ee}};Object.defineProperty(g,"__esModule",{value:!0}),g.MusicSheetCalculator=void 0;const s=c(8724),u=c(2561),r=c(1850),i=c(5748),o=c(164),n=c(437),h=c(1336),t=c(1645),f=c(7066),p=c(9409),m=c(2369),x=c(8254),y=c(7533),d=c(4543),S=c(3123),M=c(4249),E=c(6438),L=c(8033),I=c(8927),T=c(164),A=c(4064),v=l(c(3065)),B=c(3263),D=c(6452),_=c(7435),F=c(3236),k=c(6362),j=c(3361),P=c(9161),G=c(2221),Y=c(5875),X=c(1066),ie=c(624),oe=c(5824),$=c(5534),Q=c(9647);class ne{constructor(){this.staffEntriesWithGraphicalTies=[],this.staffEntriesWithOrnaments=[],this.staffEntriesWithChordSymbols=[],this.staffLinesWithLyricWords=[],this.graphicalLyricWords=[],this.abstractNotImplementedErrorMessage="abstract, not implemented",this.dynamicExpressionMap=new Map}static get TextMeasurer(){return ne.textMeasurer}static set TextMeasurer(N){ne.textMeasurer=N}get leadSheet(){return this.graphicalMusicSheet.LeadSheet}static setMeasuresMinStaffEntriesWidth(N,R){for(let O=0,U=N.length;O0&&this.rules.RenderMultipleRestMeasures){ue.isReducedToMultiRest=!0,ue.multipleRestMeasureNumber=1;const xe=ue.multipleRestMeasures-1;te+=xe;for(let ve=1;ve<=xe;ve++){const Se=N.SourceMeasures.indexOf(ue)+ve;if(Se>=N.SourceMeasures.length)break;const ye=N.SourceMeasures[Se];ye.multipleRestMeasureNumber=ve+1,ye.isReducedToMultiRest=!0,R.push([void 0])}}}if(this.rules.AutoGenerateMultipleRestMeasuresFromRestMeasures&&this.rules.RenderMultipleRestMeasures){let te,se=0;for(let ue=0,fe=N.SourceMeasures.length;ue0){te.isReducedToMultiRest=!0,te.multipleRestMeasureNumber=1,se++,xe.multipleRestMeasureNumber=se,xe.isReducedToMultiRest=!0;for(let ve=0;ve1){te.multipleRestMeasures=se;const ve=this.createGraphicalMeasuresForSourceMeasure(te,O,H,K,U);R[te.measureListIndex]=ve,se=0,te=void 0}else se=0,te=void 0}if(se>1){te.multipleRestMeasures=se,te.isReducedToMultiRest=!0;const ue=this.createGraphicalMeasuresForSourceMeasure(te,O,H,K,U);R[te.measureListIndex]=ue,se=0,te=void 0}}const q=U.map(te=>te.ClefType===o.ClefEnum.percussion);this.handleStaffEntries(q),this.calculateVerticalContainersList(),this.setIndicesToVerticalGraphicalContainers()}calculate(){this.musicSystems=[],this.clearSystemsAndMeasures(),this.clearRecreatedObjects(),this.createGraphicalTies(),this.calculateSheetLabelBoundingBoxes(),this.calculateXLayout(this.graphicalMusicSheet,this.maxInstrNameLabelLength()),this.graphicalMusicSheet.MusicPages.length=0,this.calculateMusicSystems(),s.GraphicalMusicSheet.transformRelativeToAbsolutePosition(this.graphicalMusicSheet)}calculateXLayout(N,R){var O;if(this.graphicalMusicSheet.MeasureList.length>0){let U,H=0,W=1;for(let K=0;KH&&(H=q);const te=this.graphicalMusicSheet.ParentMusicSheet.MeasureWidthFactor;for(const se of U)if(se!=null&&se.parentSourceMeasure.WidthFactor){W=se.parentSourceMeasure.WidthFactor;break}q*=te*W,ne.setMeasuresMinStaffEntriesWidth(U,q)}if(this.rules.FixedMeasureWidth){let K=H;this.rules.FixedMeasureWidthFixedValue&&(K=this.rules.FixedMeasureWidthFixedValue);for(let q=0;q1;if(H===1&&R.Measures[0].parentSourceMeasure.ImplicitMeasure&&(K=!1),K)return;W.MeasureNumber!==0&&W.MeasureNumber!==1||(O=W.MeasureNumber),U=W!==R.Measures[0]&&this.rules.MeasureNumberLabelXOffset?this.rules.MeasureNumberLabelXOffset:0;const q=this.rules.UseXMLMeasureNumbers&&W.MeasureNumber===1&&W.parentSourceMeasure.getPrintedMeasureNumber()!==1;((W.MeasureNumber===O||W.MeasureNumber>=O+this.rules.MeasureNumberLabelOffset)&&!W.parentSourceMeasure.ImplicitMeasure||q)&&((W.MeasureNumber!==1||W.MeasureNumber===1&&W!==R.Measures[0]||q)&&this.calculateSingleMeasureNumberPlacement(W,R,N,U),O=W.MeasureNumber)}}calculateSingleMeasureNumberPlacement(N,R,O,U=0){const H=N.parentSourceMeasure.getPrintedMeasureNumber().toString(),W=new _.Label(H),K=new x.GraphicalLabel(W,this.rules.MeasureNumberLabelHeight,y.TextAlignmentEnum.LeftBottom,this.rules),q=R.SkyBottomLineCalculator;K.setLabelPositionAndShapeBorders(),K.PositionAndShape.Parent=O.PositionAndShape;const te=R.PositionAndShape.RelativePosition.x+N.PositionAndShape.RelativePosition.x-K.PositionAndShape.BorderMarginLeft+U;let se,ue=te,fe=te-K.PositionAndShape.BorderLeft+K.PositionAndShape.BorderRight;ue-=R.PositionAndShape.RelativePosition.x,fe-=R.PositionAndShape.RelativePosition.x;const xe=ue+.5,ve=fe-.5,Se=q.getSkyLineMinInRange(xe,ve);if(N===R.Measures[0]){let ye=0;if(O.GroupBrackets.length>0)for(const be of O.GroupBrackets)ye=Math.min(ye,be.PositionAndShape.BorderTop);else N.ParentStaff.ParentInstrument.Parent&&(ye=-1);se=Math.min(Se,ye)}else se=Se;se=Math.min(0,se),K.PositionAndShape.RelativePosition=new p.PointF2D(te,se),O.MeasureNumberLabels.push(K)}calculateMeasureNumberSkyline(N){const R=N.StaffLines[0];for(const O of N.MeasureNumberLabels){let U=O.PositionAndShape.RelativePosition.x,H=U-O.PositionAndShape.BorderLeft+O.PositionAndShape.BorderRight;U-=R.PositionAndShape.RelativePosition.x,H-=R.PositionAndShape.RelativePosition.x,R.SkyBottomLineCalculator.updateSkyLineInRange(U,H,O.PositionAndShape.RelativePosition.y+O.PositionAndShape.BorderMarginTop)}}layoutGraphicalTie(N,R,O){throw new Error(this.abstractNotImplementedErrorMessage)}calculateSingleStaffLineLyricsPosition(N,R){let O=0,U=this.rules.StaffHeight;const H=new Map,W=[],K=N.SkyBottomLineCalculator;let q=N.Measures.length;for(let se=0;se0){W.push(Se),O=Math.max(O,Se.LyricsEntries.length);const be=Se.PositionAndShape.RelativePosition.x+fe.x;let Me=Number.MAX_VALUE,_e=Number.MIN_VALUE;for(let Le=0;Le0){const se=N.PositionAndShape.Size.width;let ue=W[0].PositionAndShape.RelativePosition.x+W[0].PositionAndShape.BorderMarginLeft+W[0].parentMeasure.PositionAndShape.RelativePosition.x;ue=ue>se?se:ue,K.updateBottomLineInRange(ue,se,te)}return W}calculateLyricsExtendsAndDashes(N){for(let R=0,O=N.length;R0||N.UnknownList.length>0){let se="";for(let be=0,Me=N.EntriesList.length;be-50){let be=K/10;be+=this.rules.PlaceWordsInsideStafflineYOffset,ve.PositionAndShape.RelativePosition.y=be}const ye=new oe.GraphicalUnknownExpression(ue,ve,xe,(te=H[O])==null?void 0:te.parentSourceMeasure,N);ue.AbstractExpressions.push(ye)}}clearRecreatedObjects(){for(let N=0,R=this.staffEntriesWithGraphicalTies.length;NN.length-1&&(v.default.debug("minimum measure to draw index out of range. resetting min measure index to limit."),this.rules.MinMeasureToDrawIndex=N.length-1);const R=[];for(let H=this.rules.MinMeasureToDrawIndex,W=N.length;H0){let _e=0;K.staffEntries[0].relInMeasureTimestamp.RealValue===0&&(_e=K.staffEntries[0].PositionAndShape.RelativePosition.x,K.MeasureNumber===1&&(_e+=this.rules.ChordSymbolWholeMeasureRestXOffsetMeasure1));let Te=_e+(K.PositionAndShape.Size.width-K.endInstructionsWidth-_e)*(te.relInMeasureTimestamp.RealValue/K.parentSourceMeasure.Duration.RealValue)+ue.PositionAndShape.BorderMarginLeft;q&&(Te=Math.max(Te,q.PositionAndShape.RelativePosition.x+q.GraphicalLabel.PositionAndShape.Size.width+this.rules.ChordSymbolXSpacing)),ue.PositionAndShape.RelativePosition.x=Te,ue.PositionAndShape.Parent=K.staffEntries[0].PositionAndShape.Parent}const fe=ue.PositionAndShape,xe=fe.Parent;if(xe.DataObject instanceof i.GraphicalMeasure&&te.relInMeasureTimestamp.RealValue===0&&(fe.RelativePosition.x=Math.max(K.beginInstructionsWidth,fe.RelativePosition.x),K.MeasureNumber===1&&fe.RelativePosition.x>3&&(fe.RelativePosition.x+=this.rules.ChordSymbolWholeMeasureRestXOffsetMeasure1)),te.PositionAndShape.RelativePosition.x===0){const _e=N.GraphicalMeasures[W];for(const Te of _e){let Le=!1;for(const Pe of Te.staffEntries)if(Pe.relInMeasureTimestamp===te.relInMeasureTimestamp&&Pe.PositionAndShape.RelativePosition.x!==0){fe.RelativePosition.x=Pe.PositionAndShape.RelativePosition.x,Le=!0;break}if(Le)break}}const ve=fe.BorderMarginLeft+xe.AbsolutePosition.x+fe.RelativePosition.x,Se=fe.BorderMarginRight+xe.AbsolutePosition.x+fe.RelativePosition.x,ye=ue.GetChordSymbolContainer.Placement;ye===k.PlacementEnum.Below?(!this.rules.ChordSymbolYAlignment||H<0)&&(H=O.getBottomLineMaxInRange(ve,Se)):ye===k.PlacementEnum.Above&&(!this.rules.ChordSymbolYAlignment||U>0)&&(U=O.getSkyLineMinInRange(ve,Se));let be=0;se===0?(be+=this.rules.ChordSymbolYOffset,be+=.1):be+=this.rules.ChordSymbolYPadding,ye!==k.PlacementEnum.Below&&(be*=-1);const Me=ue.GraphicalLabel;ye===k.PlacementEnum.Below?(Me.PositionAndShape.RelativePosition.y=H+be,Me.setLabelPositionAndShapeBorders(),Me.PositionAndShape.calculateBoundingBox(),O.updateBottomLineInRange(ve,Se,H+Me.PositionAndShape.BorderMarginBottom+this.rules.ChordSymbolBottomMargin)):(Me.PositionAndShape.RelativePosition.y=U+be,Me.setLabelPositionAndShapeBorders(),Me.PositionAndShape.calculateBoundingBox(),O.updateSkyLineInRange(ve,Se,U+Me.PositionAndShape.BorderMarginTop)),q=ue}}}}calculateAlignedChordSymbolsOffset(N,R){let O=Number.MAX_SAFE_INTEGER,U=Number.MIN_SAFE_INTEGER;for(const H of N)for(const W of H.graphicalChordContainers){const K=W.PositionAndShape,q=K.Parent;let te=K.BorderMarginLeft+q.AbsolutePosition.x,se=K.BorderMarginRight+q.AbsolutePosition.x;q.DataObject instanceof i.GraphicalMeasure&&(te+=q.DataObject.beginInstructionsWidth,se+=q.DataObject.beginInstructionsWidth);const ue=W.GetChordSymbolContainer.Placement;ue===k.PlacementEnum.Above?O=Math.min(O,R.getSkyLineMinInRange(te,se)):ue===k.PlacementEnum.Below&&(U=Math.max(U,R.getBottomLineMaxInRange(te,se)))}return{minOffset:O,maxOffset:U}}layoutMeasureWithWholeRest(N,R,O){}layoutBeams(N){}layoutArticulationMarks(N,R,O){}layoutOrnament(N,R,O){}calculateRestNotePlacementWithinGraphicalBeam(N,R,O,U,H){}calculateTupletNumbers(){if(!this.rules.TupletNumberLimitConsecutiveRepetitions)return;let N,R,O,U=-1,H=0;const W={};for(const K of this.graphicalMusicSheet.ParentMusicSheet.Instruments)for(const q of K.Voices){H=0,W[q.VoiceId]={};for(const te of q.VoiceEntries)if(te.Notes.length>0){const se=te.Notes[0];if(!se.NoteTuplet||se.NoteTuplet.shouldBeBracketed(this.rules.TupletsBracketedUseXMLValue,this.rules.TupletsBracketed,this.rules.TripletsBracketed)){U=-1,H=0,R=void 0,N=void 0;continue}if(se.NoteTuplet===O)continue;let ue=se.TypeLength;if(ue||(v.default.warn("note missing TypeLength"),ue=se.NoteTuplet.Fractions[0]),se.NoteTuplet!==R&&W[q.VoiceId][se.NoteTuplet.TupletLabelNumber]&&W[q.VoiceId][se.NoteTuplet.TupletLabelNumber][ue.RealValue]){se.NoteTuplet.RenderTupletNumber=!1,O=se.NoteTuplet;continue}se.NoteTuplet.TupletLabelNumber===U&&ue.Equals(N)&&!se.NoteTuplet.Bracket||(U=se.NoteTuplet.TupletLabelNumber,N=ue,H=0),R=se.NoteTuplet,H++,H<=this.rules.TupletNumberMaxConsecutiveRepetitions&&(se.NoteTuplet.RenderTupletNumber=!0),H>this.rules.TupletNumberMaxConsecutiveRepetitions&&(se.NoteTuplet.RenderTupletNumber=!1,this.rules.TupletNumberAlwaysDisableAfterFirstMax&&(W[q.VoiceId][U]||(W[q.VoiceId][U]={}),W[q.VoiceId][U][ue.RealValue]=!0)),O=R}}}calculateSlurs(){}calculateGlissandi(){}calculateDynamicExpressionsForMultiExpression(N,R,O){}calculateGraphicalVerbalContinuousDynamic(N,R){const O=N.Label,U=R.x+O.PositionAndShape.BorderMarginLeft,H=R.x+O.PositionAndShape.BorderMarginRight,W=N.ContinuousDynamic.Placement,K=N.ParentStaffLine.SkyBottomLineCalculator;let q;W===k.PlacementEnum.Below?(q=K.getBottomLineMaxInRange(U,H),O.PositionAndShape.RelativePosition=new p.PointF2D(R.x,q-O.PositionAndShape.BorderMarginTop)):(q=K.getSkyLineMinInRange(U,H),O.PositionAndShape.RelativePosition=new p.PointF2D(R.x,q-O.PositionAndShape.BorderMarginBottom))}calculateGraphicalContinuousDynamic(N,R){var ot;const O=N.IsSoftAccent,U=N.ParentStaffLine.ParentStaff.idInMusicSheet,H=this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(N.ContinuousDynamic.EndMultiExpression.SourceMeasureParent,U);if(!H)return void v.default.warn("MusicSheetCalculator.calculateGraphicalContinuousDynamic: No endMeasure found");N.EndMeasure=H;const W=N.ParentStaffLine,K=H.ParentStaffLine,q=K&&W===K;let te=!1;K?te=K==null?void 0:K.isPartOfMultiStaffInstrument():W&&(te=W==null?void 0:W.isPartOfMultiStaffInstrument());const se=u.Fraction.createFromFraction(N.ContinuousDynamic.EndMultiExpression.AbsoluteTimestamp),ue=this.graphicalMusicSheet.GetVerticalContainerFromTimestamp(se),fe=ue.getFirstNonNullStaffEntry().parentMeasure,xe=fe.PositionAndShape.AbsolutePosition.x+fe.PositionAndShape.BorderRight;let ve=new u.Fraction(0,0,0);for(const ze of ue.StaffEntries){if((ze==null?void 0:ze.sourceStaffEntry.ParentStaff)!==W.ParentStaff)continue;const He=(ot=ze==null?void 0:ze.sourceStaffEntry)==null?void 0:ot.calculateMaxNoteLength(!1);He!=null&&He.gt(ve)&&(ve=He)}const Se=!O&&N.ContinuousDynamic.DynamicType===Y.ContDynamicEnum.diminuendo,ye=this.getRelativePositionInStaffLineFromTimestamp(se,U,K,te,0,Se),be=u.Fraction.plus(se,ve).clone();N.ContinuousDynamic.EndMultiExpression.EndOffsetFraction&&this.rules.UseEndOffsetForExpressions&&be.Add(N.ContinuousDynamic.EndMultiExpression.EndOffsetFraction);const Me=this.getRelativePositionInStaffLineFromTimestamp(be,U,K,te,0,N.ContinuousDynamic.DynamicType===Y.ContDynamicEnum.diminuendo),_e=this.rules.SoftAccentWedgePadding,Te=ue.getFirstNonNullStaffEntry().PositionAndShape.Size.width,Le=this.rules.SoftAccentSizeFactor;O?(R.x-=Te/2*Le+_e,ye.x=R.x+Te/2*Le):Me.x>ye.x&&Me.xCe){const qe=Ae.StaffLines[ze].PositionAndShape.RelativePosition.y-W.PositionAndShape.RelativePosition.y-this.rules.StaffHeight;We=this.rules.StaffHeight+qe/2}else We=this.rules.WedgePlacementBelowY;We-=this.rules.WedgeOpeningLength/2,q||(Xe=We);let He=Be.getBottomLineMaxInRange(Ke,je);He>We&&(We=He);const Je=!1;if(CeXe&&(Xe=He),Xe+=this.rules.WedgeOpeningLength/2,Xe+=this.rules.WedgeVerticalMargin),We+=this.rules.WedgeOpeningLength/2,We+=this.rules.WedgeVerticalMargin}else if(Ie===k.PlacementEnum.Above){if(W.ParentStaff.ParentInstrument.Staves.length===1)We=this.rules.WedgePlacementAboveY;else{let He=0;Ce>0&&(He=Ce-1);const Je=Ae.StaffLines[He];We=-(W.PositionAndShape.RelativePosition.y-Je.PositionAndShape.RelativePosition.y-this.rules.StaffHeight)/2}We+=this.rules.WedgeOpeningLength/2,q||(Xe=We);let ze=Be.getSkyLineMinInRange(Ke,je);if(ze1&&Ce>0){const He=W.findClosestStaffEntry(Ke),Je=W.findClosestStaffEntry(je);He&&Je&&He.parentVerticalContainer}q||(ze=K.SkyBottomLineCalculator.getSkyLineMinInRange(st,at),zeqe&&(qe=tt),qe+=this.rules.WedgeOpeningLength/2,qe+=this.rules.WedgeVerticalMargin}else if(Ie===k.PlacementEnum.Above){const tt=Je.SkyBottomLineCalculator.getSkyLineMinInRange(st,at);tt-ue/2?-ue/2:te-N.PositionAndShape.BorderMarginBottom}}else q=te-N.PositionAndShape.BorderMarginBottom;N.PositionAndShape.RelativePosition=new p.PointF2D(R.x,q)}else if(N.Placement===k.PlacementEnum.Below){const te=K.getBottomLineMaxInRange(H,W),se=U.ParentStaff.ParentInstrument.Staves[U.ParentStaff.ParentInstrument.Staves.length-1];if(U.isPartOfMultiStaffInstrument()&&U.ParentStaff!==se){const ue=U.ParentMusicSystem.StaffLines[U.ParentMusicSystem.StaffLines.indexOf(U)+1];if(ue){const fe=ue.PositionAndShape.RelativePosition.y-U.PositionAndShape.RelativePosition.y-this.rules.StaffHeight;q=te+N.PositionAndShape.BorderMarginBottomN.PositionAndShape.Size.width&&(ve=N.PositionAndShape.Size.width-this.rules.MeasureRightMargin,xe=ve-se.PositionAndShape.MarginSize.width,R.x=xe-se.PositionAndShape.BorderMarginLeft),xe0||!H[0])return;let K=H[0].ParentStaffLine,q=H[0].PositionAndShape.RelativePosition.x,te=0;for(let se=0;se0){K=H[se].ParentStaffLine,q=H[se].PositionAndShape.RelativePosition.x,te=se;break}if(W=this.getRelativePositionInStaffLineFromTimestamp(U,te,K,K.isPartOfMultiStaffInstrument(),q),R.EntriesList.length>0&&R.EntriesList[0].Expression instanceof P.InstantaneousTempoExpression&&(R.EntriesList[0].Expression.Placement=k.PlacementEnum.Above,K.Measures[0].staffEntries.length>0&&Math.abs(W.x-K.Measures[0].staffEntries[0].PositionAndShape.RelativePosition.x)===0&&K.ParentMusicSystem===this.musicSystems[0])){const se=K.Measures[0].FirstInstructionStaffEntry;if(se){const ue=se.GraphicalInstructions.last();W.x=ue.PositionAndShape.RelativePosition.x}this.rules.CompactMode&&(W.x=K.PositionAndShape.RelativePosition.x+K.Measures[0].PositionAndShape.RelativePosition.x)}for(const se of R.EntriesList){let ue=this.rules.TempoExpressionTextAlignment;this.rules.CompactMode&&(ue=y.TextAlignmentEnum.LeftBottom);const fe=this.calculateLabel(K,W,se.label,R.getFontstyleOfFirstEntry(),se.Expression.Placement,this.rules.UnknownTextHeight,ue,this.rules.TempoYSpacing);if(se.Expression.ColorXML&&this.rules.ExpressionsUseXMLColor&&(fe.ColorXML=se.Expression.ColorXML),se.Expression instanceof P.InstantaneousTempoExpression){for(const xe of K.AbstractExpressions)xe instanceof j.GraphicalInstantaneousTempoExpression&&(xe.SourceExpression.Label,se.Expression.Label);if(new j.GraphicalInstantaneousTempoExpression(se.Expression,fe).ParentStaffLine||v.default.warn("Adding staffline didn't work"),this.rules.MetronomeMarksDrawn&&se.Expression.TempoType===P.TempoType.metronomeMark){this.createMetronomeMark(se.Expression);continue}}else if(se.Expression instanceof G.ContinuousTempoExpression){for(const xe of K.AbstractExpressions)xe instanceof j.GraphicalInstantaneousTempoExpression&&(xe.SourceExpression.Label,se.Expression.Label);K.AbstractExpressions.push(new j.GraphicalInstantaneousTempoExpression(se.Expression,fe))}}}}createMetronomeMark(N){throw new Error(this.abstractNotImplementedErrorMessage)}graphicalMeasureCreatedCalculations(N){}clearSystemsAndMeasures(){for(let N=0,R=this.graphicalMusicSheet.MusicPages.length;N-1&&fe.PositionAndShape.ChildElements.splice(xe,1),fe.FirstInstructionStaffEntry=void 0,fe.beginInstructionsWidth=0}if(fe.LastInstructionStaffEntry){const xe=fe.PositionAndShape.ChildElements.indexOf(fe.LastInstructionStaffEntry.PositionAndShape);xe>-1&&fe.PositionAndShape.ChildElements.splice(xe,1),fe.LastInstructionStaffEntry=void 0,fe.endInstructionsWidth=0}}te.Measures=[],te.PositionAndShape.ChildElements=[]}W.StaffLines.length=0,W.PositionAndShape.ChildElements=[]}O.MusicSystems=[],O.PositionAndShape.ChildElements=[]}this.graphicalMusicSheet.MusicPages=[]}handleVoiceEntry(N,R,O,U,H,W,K,q,te,se=void 0,ue=void 0){N.StemDirectionXml!==h.StemDirectionType.Undefined&&this.rules.SetWantedStemDirectionByXml&&N.StemDirectionXml!==void 0?N.WantedStemDirection=N.StemDirectionXml:this.calculateStemDirectionFromVoices(N);const fe=R.findOrCreateGraphicalVoiceEntry(N);fe.octaveShiftValue=q;const xe=R.tabStaffEntry;let ve;xe&&(ve=xe.findOrCreateGraphicalVoiceEntry(N));for(let Se=0,ye=N.Notes.length;Se-1)continue;let Me;if(N.IsGrace?Me=ne.symbolFactory.createGraceNote(be,fe,H,this.rules,q):(Me=ne.symbolFactory.createNote(be,fe,H,q,this.rules,void 0),ne.stafflineNoteCalculator.trackNote(Me)),be.Pitch&&this.checkNoteForAccidental(Me,O,H,q),this.resetYPositionForLeadSheet(Me.PositionAndShape),R.addGraphicalNoteToListAtCorrectYPosition(fe,Me),Me.PositionAndShape.calculateBoundingBox(),this.leadSheet||(be.NoteBeam!==void 0&&be.PrintObject&&(be instanceof Q.TabNote&&!this.rules.TabBeamsRendered||this.handleBeam(Me,be.NoteBeam,K)),be.NoteTuplet!==void 0&&be.PrintObject&&this.handleTuplet(Me,be.NoteTuplet,W)),ve){const _e=ne.symbolFactory.createNote(be,ve,H,q,this.rules,void 0);xe.addGraphicalNoteToListAtCorrectYPosition(ve,_e),_e.PositionAndShape.calculateBoundingBox(),this.leadSheet||be.NoteTuplet&&this.handleTuplet(_e,be.NoteTuplet,W)}}return N.Articulations.length>0&&this.handleVoiceEntryArticulations(N.Articulations,N,R),N.TechnicalInstructions.length>0&&this.handleVoiceEntryTechnicalInstructions(N.TechnicalInstructions,N,R),N.LyricsEntries.size()>0&&this.handleVoiceEntryLyrics(N,R,U),N.OrnamentContainer&&this.handleVoiceEntryOrnaments(N.OrnamentContainer,N,R),q}resetYPositionForLeadSheet(N){this.leadSheet&&(N.RelativePosition=new p.PointF2D(N.RelativePosition.x,0))}layoutVoiceEntries(N,R){if(N.PositionAndShape.RelativePosition=new p.PointF2D(0,0),!this.leadSheet)for(const O of N.graphicalVoiceEntries){const U=O.notes;if(U.length===0)continue;const H=U[0].sourceNote.ParentVoiceEntry,W=U[0].sourceNote.Pitch!==void 0;this.layoutVoiceEntry(H,U,N,W)}}maxInstrNameLabelLength(){var R;let N=0;for(const O of this.graphicalMusicSheet.ParentMusicSheet.Instruments)if((R=O.NameLabel)!=null&&R.print&&O.Voices.length>0&&O.Voices[0].Visible){let U=O.NameLabel;this.rules.RenderPartNames||(U=new _.Label("",U.textAlignment,U.font));const H=new x.GraphicalLabel(U,this.rules.InstrumentLabelTextHeight,y.TextAlignmentEnum.LeftCenter,this.rules);H.setLabelPositionAndShapeBorders(),N=Math.max(N,H.PositionAndShape.MarginSize.width)}return this.rules.RenderPartNames?N:0}calculateSheetLabelBoundingBoxes(){const N=this.graphicalMusicSheet.ParentMusicSheet,R=this.rules.DefaultColorTitle;if(N.Title!==void 0&&this.rules.RenderTitle){const O=new x.GraphicalLabel(N.Title,this.rules.SheetTitleHeight,y.TextAlignmentEnum.CenterBottom,this.rules);O.Label.IsCreditLabel=!0,O.Label.colorDefault=R,this.graphicalMusicSheet.Title=O,O.setLabelPositionAndShapeBorders()}else this.rules.RenderTitle||(this.graphicalMusicSheet.Title=void 0);if(N.Subtitle!==void 0&&this.rules.RenderSubtitle){const O=new x.GraphicalLabel(N.Subtitle,this.rules.SheetSubtitleHeight,y.TextAlignmentEnum.CenterCenter,this.rules);O.Label.IsCreditLabel=!0,O.Label.colorDefault=R,this.graphicalMusicSheet.Subtitle=O,O.setLabelPositionAndShapeBorders()}else this.rules.RenderSubtitle||(this.graphicalMusicSheet.Subtitle=void 0);if(N.Composer!==void 0&&this.rules.RenderComposer){const O=new x.GraphicalLabel(N.Composer,this.rules.SheetComposerHeight,y.TextAlignmentEnum.RightCenter,this.rules);O.Label.IsCreditLabel=!0,O.Label.colorDefault=R,this.graphicalMusicSheet.Composer=O,O.setLabelPositionAndShapeBorders()}else this.rules.RenderComposer||(this.graphicalMusicSheet.Composer=void 0);if(N.Lyricist!==void 0&&this.rules.RenderLyricist){const O=new x.GraphicalLabel(N.Lyricist,this.rules.SheetAuthorHeight,y.TextAlignmentEnum.LeftCenter,this.rules);O.Label.IsCreditLabel=!0,O.Label.colorDefault=R,this.graphicalMusicSheet.Lyricist=O,O.setLabelPositionAndShapeBorders()}else this.rules.RenderLyricist||(this.graphicalMusicSheet.Lyricist=void 0);if(N.Copyright!==void 0&&this.rules.RenderCopyright){const O=new x.GraphicalLabel(N.Copyright,this.rules.SheetCopyrightHeight,y.TextAlignmentEnum.CenterBottom,this.rules);O.Label.IsCreditLabel=!0,O.Label.colorDefault=R,this.graphicalMusicSheet.Copyright=O,O.setLabelPositionAndShapeBorders()}else this.rules.RenderCopyright||(this.graphicalMusicSheet.Copyright=void 0)}checkMeasuresForWholeRestNotes(){for(let N=0,R=this.musicSystems.length;N0&&se.graphicalVoiceEntries[0].notes.length===1){const ue=se.graphicalVoiceEntries[0].notes[0];!ue.sourceNote.Pitch&&new u.Fraction(1,2).lt(ue.sourceNote.Length)&&this.layoutMeasureWithWholeRest(ue,se,te)}}}}}}optimizeRestNotePlacement(N,R){if(N.graphicalVoiceEntries.length===0)return;const O=N.graphicalVoiceEntries[0].notes;if(O.length===0)return;const U=O[0],H=U.sourceNote.isRest();if(N.graphicalVoiceEntries.length===2){let W=!1;const K=N.graphicalVoiceEntries[1].notes;K.length>0&&(W=K[0].sourceNote.isRest()),H&&W?this.calculateTwoRestNotesPlacementWithCollisionDetection(N):(H||W)&&this.calculateRestNotePlacementWithCollisionDetectionFromGraphicalNote(N)}else if(H&&N!==R.staffEntries[0]&&N!==R.staffEntries[R.staffEntries.length-1]){const W=R.staffEntries.indexOf(N),K=R.staffEntries[W-1],q=R.staffEntries[W+1];if(K.graphicalVoiceEntries.length===1){const te=K.graphicalVoiceEntries[0].notes[0];if(te.sourceNote.NoteBeam!==void 0&&q.graphicalVoiceEntries.length===1){const se=q.graphicalVoiceEntries[0].notes[0];se.sourceNote.NoteBeam!==void 0&&te.sourceNote.NoteBeam===se.sourceNote.NoteBeam&&(this.calculateRestNotePlacementWithinGraphicalBeam(N,U,te,q,se),N.PositionAndShape.calculateBoundingBox())}}}}getRelativePositionInStaffLineFromTimestamp(N,R,O,U,H=0,W=!1){let K,q,te=new p.PointF2D;const se=this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers.length,ue=this.graphicalMusicSheet.GetInterpolatedIndexInVerticalContainers(N),fe=Math.min(Math.floor(ue),se-1),xe=Math.min(Math.ceil(ue),se-1);if(fe<0||R<0)return te;if(K=this.getFirstLeftNotNullStaffEntryFromContainer(fe,R,U),q=this.getFirstRightNotNullStaffEntryFromContainer(xe,R,U),K&&q){let ve=K.parentMeasure.PositionAndShape.RelativePosition.x;H>0&&(ve=H);let Se=K.PositionAndShape.RelativePosition.x+ve,ye=q.PositionAndShape.RelativePosition.x+q.parentMeasure.PositionAndShape.RelativePosition.x;const be=N.RealValue>q.getAbsoluteTimestamp().RealValue;H>0?ye=q.PositionAndShape.RelativePosition.x+ve:W&&(K.getAbsoluteTimestamp().RealValue===N.RealValue||be)&&(Se=K.PositionAndShape.RelativePosition.x+K.PositionAndShape.BorderLeft+ve,ye=Se);let Me=0;if(K!==q){const _e=K.getAbsoluteTimestamp(),Te=q.getAbsoluteTimestamp();Me=u.Fraction.minus(N,_e).RealValue/u.Fraction.minus(Te,_e).RealValue}K.parentMeasure.ParentStaffLine!==q.parentMeasure.ParentStaffLine&&(K.parentMeasure.ParentStaffLine===O?ye=O.PositionAndShape.Size.width:Se=O.PositionAndShape.RelativePosition.x),te=new p.PointF2D(Se+(ye-Se)*Me,0)}return te}getRelativeXPositionFromTimestamp(N){const R=this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers.length,O=this.graphicalMusicSheet.GetInterpolatedIndexInVerticalContainers(N),U=Math.max(0,Math.min(Math.round(O),R-1)),H=this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[U].getFirstNonNullStaffEntry();return H.PositionAndShape.RelativePosition.x+H.parentMeasure.PositionAndShape.RelativePosition.x}calculatePageLabels(N){var te,se;this.rules.RenderSingleHorizontalStaffline&&(N.PositionAndShape.calculateBoundingBox([i.GraphicalMeasure.name]),this.graphicalMusicSheet.ParentMusicSheet.pageWidth=N.PositionAndShape.Size.width);let R=10,O=-1;if(N.MusicSystems.length>0){const ue=N.MusicSystems[0];R=ue.PositionAndShape.RelativePosition.y+ue.PositionAndShape.BorderTop;const fe=N.MusicSystems[N.MusicSystems.length-1];O=fe.PositionAndShape.RelativePosition.y+fe.PositionAndShape.BorderBottom}const U=this.graphicalMusicSheet.Title;if(U&&this.rules.RenderTitle){U.PositionAndShape.Parent=N.PositionAndShape;const ue=new p.PointF2D;ue.x=this.graphicalMusicSheet.ParentMusicSheet.pageWidth/2,this.rules.RenderSingleHorizontalStaffline&&(ue.x=Math.max(ue.x,U.PositionAndShape.Size.width)),ue.y=this.rules.TitleTopDistance+this.rules.SheetTitleHeight,U.PositionAndShape.RelativePosition=ue,N.Labels.push(U)}if(this.graphicalMusicSheet.Subtitle&&this.rules.RenderTitle&&this.rules.RenderSubtitle){const ue=this.graphicalMusicSheet.Subtitle;ue.PositionAndShape.Parent=N.PositionAndShape;const fe=new p.PointF2D;fe.x=this.graphicalMusicSheet.ParentMusicSheet.pageWidth/2,this.rules.RenderSingleHorizontalStaffline&&(fe.x=U.PositionAndShape.RelativePosition.x),fe.y=this.rules.TitleTopDistance+this.rules.SheetTitleHeight+this.rules.SheetMinimumDistanceBetweenTitleAndSubtitle;const xe=(te=ue.TextLines)==null?void 0:te.length;xe>1&&(fe.y+=ue.PositionAndShape.BorderBottom*(xe-1)/xe),ue.PositionAndShape.RelativePosition=fe,N.Labels.push(ue)}const H=this.graphicalMusicSheet.Composer;let W;if(H&&this.rules.RenderComposer){H.PositionAndShape.Parent=N.PositionAndShape,H.setLabelPositionAndShapeBorders();const ue=new p.PointF2D;ue.x=this.graphicalMusicSheet.ParentMusicSheet.pageWidth-this.rules.PageRightMargin,ue.y=R,ue.y-=this.rules.SystemComposerDistance;const fe=(se=H.TextLines)==null?void 0:se.length;fe>1&&(ue.y-=H.PositionAndShape.BorderBottom*(fe-1)/fe),W=ue.y,H.PositionAndShape.RelativePosition=ue,N.Labels.push(H)}const K=this.graphicalMusicSheet.Lyricist;if(K&&this.rules.RenderLyricist){K.PositionAndShape.Parent=N.PositionAndShape,K.setLabelPositionAndShapeBorders();const ue=new p.PointF2D;ue.x=this.rules.PageLeftMargin,ue.y=R,ue.y-=this.rules.SystemLyricistDistance,ue.y+=K.PositionAndShape.BorderBottom,ue.y=Math.min(ue.y,W??Number.MAX_SAFE_INTEGER),K.PositionAndShape.RelativePosition=ue,N.Labels.push(K)}const q=this.graphicalMusicSheet.Copyright;if(q&&this.rules.RenderCopyright){q.PositionAndShape.Parent=N.PositionAndShape,q.setLabelPositionAndShapeBorders();const ue=new p.PointF2D;ue.x=N.PositionAndShape.Size.width/2,ue.y=O+this.rules.SheetCopyrightMargin,ue.y-=q.PositionAndShape.BorderTop,q.PositionAndShape.RelativePosition=ue,N.Labels.push(q)}this.rules.RenderSingleHorizontalStaffline&&(N.PositionAndShape.calculateBoundingBox([i.GraphicalMeasure.name]),this.graphicalMusicSheet.ParentMusicSheet.pageWidth=N.PositionAndShape.Size.width)}createGraphicalTies(){for(let N=0;N=0&&this.staffEntriesWithGraphicalTies.push(q)}q=W}}setTieDirections(N){if(!N)return;const R=N.ties;if(R.length===1){const O=R[0];if(O.TieDirection===k.PlacementEnum.NotYetDefined){const U=O.Notes[0].ParentVoiceEntry.ParentVoice.VoiceId;U!==2&&U!==6||(O.TieDirection=k.PlacementEnum.Below)}}if(R.length>1){let O;for(const U of R){const H=U.Notes[0];(!O||H.Pitch.getHalfTone()>O.Pitch.getHalfTone())&&(O=H)}for(const U of R)U.TieDirection===k.PlacementEnum.NotYetDefined&&(U.Notes[0]===O?U.TieDirection=k.PlacementEnum.Above:U.TieDirection=k.PlacementEnum.Below)}}createAccidentalCalculators(){var O;const N=[],R=this.graphicalMusicSheet.ParentMusicSheet.getFirstSourceMeasure();if(R){const U=this.graphicalMusicSheet.ParentMusicSheet.Transpose;for(let H=0;H1)return;ue=ne.symbolFactory.createGraphicalMeasure(N,se)}if(ue.hasError=N.getErrorInMeasure(q),N.FirstInstructionsStaffEntries[q])for(let Te=0,Le=N.FirstInstructionsStaffEntries[q].Instructions.length;Te0&&((be=Ce.ParentEndMultiExpression)!=null&&be.AbsoluteTimestamp.Equals(Le.AbsoluteTimestamp))&&Ie>=Ce.endVoiceEntryIndex&&(Be=n.OctaveEnum.NONE,Ce=void 0),Be=this.handleVoiceEntry(Ke,Pe,U,K,H[q],R,O,Be,q,Ae,Le)}for(const Ie of Le.Instructions)if(Ie instanceof o.ClefInstruction){ne.symbolFactory.createInStaffClef(Pe,Ie);break}this.rules.RenderChordSymbols&&((Me=Le.ChordContainers)==null?void 0:Me.length)>0&&(Le.ParentStaff.ParentInstrument.HasChordSymbols=!0,ne.symbolFactory.createChordSymbols(Le,Pe,U.ActiveKeyInstruction,this.graphicalMusicSheet.ParentMusicSheet.Transpose))}}if(U.doCalculationsAtEndOfMeasure(),N.LastInstructionsStaffEntries[q]){const Te=N.LastInstructionsStaffEntries[q];for(let Le=0,Pe=Te.Instructions.length;Le=1&&ue.staffEntries.length===0){const Te=new m.SourceStaffEntry(new F.VerticalSourceStaffEntryContainer(ue.parentSourceMeasure,ue.parentSourceMeasure.AbsoluteTimestamp,ue.parentSourceMeasure.CompleteNumberOfStaves),se);if(se.Voices.length===0){const Fe=new $.Voice(ue.ParentStaff.ParentInstrument,-1);se.Voices.push(Fe)}const Le=new h.VoiceEntry(new u.Fraction(0,1),se.Voices[0],Te);let Pe=N.Duration;Pe.RealValue===0&&(Pe=N.ActiveTimeSignature.clone());const Ae=new r.Note(Le,Te,Pe,void 0,N,!0);Ae.IsWholeMeasureRest=!0,Ae.PrintObject=this.rules.FillEmptyMeasuresWithWholeRest===ie.FillEmptyMeasuresWithWholeRests.YesVisible,Le.Notes.push(Ae);const Ce=ne.symbolFactory.createStaffEntry(Te,ue);ue.addGraphicalStaffEntry(Ce),Ce.relInMeasureTimestamp=Le.Timestamp;const Be=ne.symbolFactory.createVoiceEntry(Le,Ce);Ce.graphicalVoiceEntries.push(Be);const Ie=ne.symbolFactory.createNote(Ae,Be,new o.ClefInstruction,n.OctaveEnum.NONE,this.rules);ne.stafflineNoteCalculator.trackNote(Ie),Be.notes.push(Ie)}ue.hasOnlyRests=!0;for(const Te of ue.staffEntries)if(ue.hasOnlyRests=Te.hasOnlyRests(),!ue.hasOnlyRests)break;return ue}checkNoteForAccidental(N,R,O,U){let H=N.sourceNote.Pitch;const W=N.parentVoiceEntry.parentStaffEntry.parentMeasure.getTransposedHalftones();W!==0&&N.sourceNote.ParentStaffEntry.ParentStaff.ParentInstrument.MidiInstrumentId!==T.MidiInstrument.Percussion?(H=N.Transpose(R.ActiveKeyInstruction,O,W,U),N.sourceNote.TransposedPitch=H):N.sourceNote.TransposedPitch=void 0,N.sourceNote.halfTone=H.getHalfTone(),R.checkAccidental(N,H)}handleStaffEntries(N){for(let R=0,O=this.graphicalMusicSheet.MeasureList.length;R0&&!this.rules.PercussionUseCajon2NoteSystem&&N[H]&&(this.rules.PercussionOneLineCutoff===-1||ne.stafflineNoteCalculator.getStafflineUniquePositionCount(H)0&&q.graphicalVoiceEntries[0].notes.length>0&&(this.layoutVoiceEntries(q,H),this.layoutStaffEntry(q));this.graphicalMeasureCreatedCalculations(K)}}}}calculateSkyBottomLines(){}calculateExpressionAlignements(){}calculateStaffEntryArticulationMarks(){for(let N=0,R=this.musicSystems.length;N0&&this.layoutArticulationMarks(Se.Articulations,Se,fe)}}}}}}calculateOrnaments(){for(let N=0,R=this.musicSystems.length;N0){let ue;W===k.PlacementEnum.Below&&se.reverse();for(const fe of K.graphicalVoiceEntries)for(const xe of fe.notes)(!ue||((N=xe.sourceNote.Pitch)==null?void 0:N.getHalfTone())>((R=ue.Pitch)==null?void 0:R.getHalfTone()))&&(ue=xe.sourceNote);se[0].sourceNote===ue&&W===k.PlacementEnum.Above&&se.reverse()}for(let ue=0;ue0&&U.LyricVersesNumbers.sort()}for(let R=0,O=this.musicSystems.length;R=0&&(U=R.GraphicalLyricsEntries[O+1]),!U)return;const H=N.StaffEntryParent.parentMeasure.ParentStaffLine,W=U.StaffEntryParent.parentMeasure.ParentStaffLine,K=N.StaffEntryParent,q=U.StaffEntryParent;if(N.StaffEntryParent.parentMeasure.ParentStaffLine===U.StaffEntryParent.parentMeasure.ParentStaffLine){const te=K.parentMeasure.PositionAndShape.RelativePosition.x+K.PositionAndShape.RelativePosition.x+N.GraphicalLabel.PositionAndShape.RelativePosition.x+N.GraphicalLabel.PositionAndShape.BorderMarginRight-N.GraphicalLabel.CenteringXShift,se=q.parentMeasure.PositionAndShape.RelativePosition.x+q.PositionAndShape.RelativePosition.x+N.GraphicalLabel.PositionAndShape.RelativePosition.x+U.GraphicalLabel.PositionAndShape.BorderMarginLeft,ue=N.GraphicalLabel.PositionAndShape.RelativePosition.y;let fe=1;se-te>3*this.rules.MinimumDistanceBetweenDashes&&(fe=Math.floor((se-te)/this.rules.MinimumDistanceBetweenDashes)-1),fe===1?this.calculateSingleDashForLyricWord(H,te,se,ue):this.calculateDashes(H,te,se,ue)}else{const te=K.parentMeasure.PositionAndShape.RelativePosition.x+K.PositionAndShape.RelativePosition.x+N.GraphicalLabel.PositionAndShape.BorderMarginRight,se=H.Measures[H.Measures.length-1],ue=se.PositionAndShape.RelativePosition.x+se.PositionAndShape.Size.width;let fe=N.GraphicalLabel.PositionAndShape.RelativePosition.y;if(this.calculateDashes(H,te,ue,fe),W&&W.Measures[0]&&q.parentMeasure.ParentStaffLine&&(q!==q.parentMeasure.staffEntries[0]||q.parentMeasure!==q.parentMeasure.ParentStaffLine.Measures[0])){const xe=W.Measures[0].staffEntries[0].PositionAndShape.RelativePosition.x,ve=q.parentMeasure.PositionAndShape.RelativePosition.x+q.PositionAndShape.RelativePosition.x+U.GraphicalLabel.PositionAndShape.BorderMarginLeft;fe=U.GraphicalLabel.PositionAndShape.RelativePosition.y,this.calculateDashes(W,xe,ve,fe)}}}calculateDashes(N,R,O,U){let H=O-R;if(H<3*this.rules.MinimumDistanceBetweenDashes)this.calculateSingleDashForLyricWord(N,R,O,U);else{const W=Math.floor(H/this.rules.MinimumDistanceBetweenDashes)-1,K=H/(W+1);let q=0;for(R+=K,O-=K;q<=Math.floor(W/2)&&O>R;)H=this.calculateRightAndLeftDashesForLyricWord(N,R,O,U),R+=K,O-=K,q++;H>2*K&&this.calculateSingleDashForLyricWord(N,R,O,U)}}calculateSingleDashForLyricWord(N,R,O,U){const H=new _.Label("-");H.colorDefault=this.rules.DefaultColorLyrics;let W=this.rules.LyricsHeight;O-R<.8&&(W*=.8,U-=.1*W);const K=new x.GraphicalLabel(H,W,y.TextAlignmentEnum.CenterBottom,this.rules);K.setLabelPositionAndShapeBorders(),N.LyricsDashes.push(K),this.staffLinesWithLyricWords.indexOf(N)===-1&&this.staffLinesWithLyricWords.push(N),K.PositionAndShape.Parent=N.PositionAndShape;const q=new p.PointF2D(R+(O-R)/2,U);K.PositionAndShape.RelativePosition=q}calculateLyricExtend(N){let R=N.GraphicalLabel.PositionAndShape.RelativePosition.y;const O=N.StaffEntryParent,U=O.parentMeasure.ParentStaffLine;let H,W;const K=O.parentMeasure.ParentStaff.idInMusicSheet;if(O.parentVerticalContainer){for(let q=O.parentVerticalContainer.Index+1;q0)break;H=te,W=H.parentMeasure.ParentStaffLine,W||(W=O.parentMeasure.ParentStaffLine)}}if(H&&W)if(U===W&&H.parentMeasure.ParentStaffLine){const q=O.parentMeasure.PositionAndShape.RelativePosition.x+O.PositionAndShape.RelativePosition.x+N.GraphicalLabel.PositionAndShape.BorderMarginRight,te=H.parentMeasure.PositionAndShape.RelativePosition.x+H.PositionAndShape.RelativePosition.x+H.PositionAndShape.BorderMarginRight;R-=N.GraphicalLabel.PositionAndShape.Size.height/4,this.calculateSingleLyricWordWithUnderscore(U,q,te,R)}else{const q=U.Measures[U.Measures.length-1].PositionAndShape,te=O.parentMeasure.PositionAndShape.RelativePosition.x+O.PositionAndShape.RelativePosition.x+N.GraphicalLabel.PositionAndShape.BorderMarginRight,se=q.RelativePosition.x+q.Size.width;if(R-=N.GraphicalLabel.PositionAndShape.Size.height/4,this.calculateSingleLyricWordWithUnderscore(U,te,se,R),!H)return;if(H.parentMeasure.ParentStaffLine&&H.parentMeasure.staffEntries&&(H!==H.parentMeasure.staffEntries[0]||H.parentMeasure!==H.parentMeasure.ParentStaffLine.Measures[0])){const ue=W.Measures[0].staffEntries[0].PositionAndShape.RelativePosition.x,fe=H.parentMeasure.PositionAndShape.RelativePosition.x+H.PositionAndShape.RelativePosition.x+H.PositionAndShape.BorderMarginRight;this.calculateSingleLyricWordWithUnderscore(W,ue,fe,R)}}}}calculateSingleLyricWordWithUnderscore(N,R,O,U){const H=new p.PointF2D(R,U),W=new p.PointF2D(O,U),K=new D.GraphicalLine(H,W,this.rules.LyricUnderscoreLineWidth);K.colorHex=this.rules.DefaultColorLyrics,N.LyricLines.push(K),this.staffLinesWithLyricWords.indexOf(N)===-1&&this.staffLinesWithLyricWords.push(N)}calculateRightAndLeftDashesForLyricWord(N,R,O,U){const H=new _.Label("-");H.colorDefault=this.rules.DefaultColorLyrics;const W=new x.GraphicalLabel(H,this.rules.LyricsHeight,y.TextAlignmentEnum.CenterBottom,this.rules);W.setLabelPositionAndShapeBorders(),N.LyricsDashes.push(W),this.staffLinesWithLyricWords.indexOf(N)===-1&&this.staffLinesWithLyricWords.push(N),W.PositionAndShape.Parent=N.PositionAndShape;const K=new p.PointF2D(R,U);W.PositionAndShape.RelativePosition=K;const q=new _.Label("-"),te=new x.GraphicalLabel(q,this.rules.LyricsHeight,y.TextAlignmentEnum.CenterBottom,this.rules);te.setLabelPositionAndShapeBorders(),N.LyricsDashes.push(te),te.PositionAndShape.Parent=N.PositionAndShape;const se=new p.PointF2D(O,U);return te.PositionAndShape.RelativePosition=se,te.PositionAndShape.RelativePosition.x-W.PositionAndShape.RelativePosition.x}calculateDynamicExpressions(){const N=Math.min(this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length-1,this.rules.MaxMeasureToDrawIndex);for(let R=Math.min(this.rules.MinMeasureToDrawIndex,this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length);R<=N;R++){const O=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures[R];this.dynamicExpressionMap.clear();for(let U=0;U=0;U--)if(this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[U].StaffEntries[R])return this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[U].StaffEntries[R]}getFirstRightNotNullStaffEntryFromContainer(N,R,O){if(this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[N].StaffEntries[R])return this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[N].StaffEntries[R];for(let U=N+1;U0){const K=N[N.length-1];if(R>K.startMeasure){const q=new t.RepetitionInstruction(R,t.RepetitionInstructionEnum.Ending,t.AlignmentType.Mid,void 0,K.endingIndices);this.calculateWordRepetitionInstruction(q,R)}}W&&N.length>0&&N.pop()}}calculateRepetitionEndings(){const N=this.graphicalMusicSheet.ParentMusicSheet;for(let R=0,O=N.Repetitions.length;R0||O.StaffLinkedExpressions[U][W].UnknownList.length>0)&&this.calculateMoodAndUnknownExpression(O.StaffLinkedExpressions[U][W],R,H)}}}calculateStemDirectionFromVoices(N){if(N.ParentSourceStaffEntry.Link!==void 0)return N===N.ParentSourceStaffEntry.VoiceEntries[0]?void(N.WantedStemDirection=h.StemDirectionType.Up):void(N.WantedStemDirection=h.StemDirectionType.Down);N.ParentVoice instanceof M.LinkedVoice?N.WantedStemDirection=h.StemDirectionType.Down:N.ParentSourceStaffEntry.VoiceEntries.length>1&&(N.WantedStemDirection=h.StemDirectionType.Up)}setBeamNotesWantedStemDirections(N){var O;if(!(N.Notes.length>0))return;const R=N.Notes[0].NoteBeam;if(R){for(const U of R.Notes)if(((O=U.Notehead)==null?void 0:O.Shape)!==A.NoteHeadShape.NONE&&U.ParentVoiceEntry.WantedStemDirection!==h.StemDirectionType.Undefined&&U.ParentVoiceEntry.ParentSourceStaffEntry.ParentStaff.Id===N.ParentSourceStaffEntry.ParentStaff.Id){N.WantedStemDirection=U.ParentVoiceEntry.WantedStemDirection;break}}}}g.MusicSheetCalculator=ne},1932(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.MusicSheetDrawer=void 0;const l=c(6438),s=c(2683),u=c(6452),r=c(200),i=c(9409),o=c(8254),n=c(7435),h=c(7533),t=c(7307),f=c(4284),p=c(512),m=c(242),x=c(7499),y=c(298);g.MusicSheetDrawer=class{constructor(d,S){this.drawableBoundingBoxElement="None",this.skyLineVisible=!1,this.bottomLineVisible=!1,this.phonicScoreMode=m.PhonicScoreModes.Manual,this.textMeasurer=d,this.splitScreenLineColor=-1,this.drawingParameters=S,this.rules=S.Rules}set Mode(d){this.phonicScoreMode=d}drawSheet(d){if(this.graphicalMusicSheet=d,this.rules=d.ParentMusicSheet.Rules,this.drawSplitScreenLine(),this.drawingParameters.drawCursors)for(const M of d.Cursors){if(!M)continue;const E=new l.BoundingBox(M);E.AbsolutePosition=M.Start,E.BorderBottom=M.End.y-M.Start.y,E.BorderRight=M.Width/2,E.BorderLeft=-M.Width/2,this.isVisible(E)&&this.drawLineAsVerticalRectangle(M,s.GraphicalLayers.Cursor)}this.drawingParameters.drawScrollIndicator&&this.drawScrollIndicator();const S=Math.min(this.graphicalMusicSheet.MusicPages.length,this.rules.MaxPageToDrawNumber);for(let M=0;M0&&this.drawDashes(B.LyricsDashes),B.LyricLines.length>0&&this.drawLyricLines(B.LyricLines,B));for(const B of d.SystemLines)this.drawSystemLineObject(B);if(this.rules.RenderSystemLabelsAfterFirstPage||d.Parent===d.Parent.Parent.MusicPages[0])for(const B of d.Labels)B.SVGNode=this.drawLabel(B,s.GraphicalLayers.Notes);const I=this.graphicalMusicSheet.ParentMusicSheet.Instruments,T=I.filter(B=>B.isVisible()).length;for(const B of d.InstrumentBrackets)this.drawInstrumentBrace(B,d);if(I.length>0)if(T>1)for(const B of d.GroupBrackets)this.drawGroupBracket(B,d);else for(const B of d.GroupBrackets)B.Visible=!1;if(!this.leadSheet)for(const B of d.MeasureNumberLabels)B.SVGNode=this.drawLabel(B,s.GraphicalLayers.Notes),(v=(A=B.SVGNode)==null?void 0:A.classList)==null||v.add("measure-number");for(const B of d.StaffLines)this.drawStaffLineSymbols(B);this.drawingParameters.drawMarkedAreas&&this.drawMarkedAreas(d),this.drawingParameters.drawComments&&this.drawComment(d)}activateSystemRendering(d,S,M,E){return!0}drawSystemLineObject(d){}drawStaffLine(d){for(const S of d.Measures)this.drawMeasure(S);this.rules.RenderLyrics&&d.LyricsDashes.length>0&&this.drawDashes(d.LyricsDashes),this.drawOctaveShifts(d),this.drawPedals(d),this.drawWavyLines(d),this.drawExpressions(d),this.skyLineVisible&&this.drawSkyLine(d),this.bottomLineVisible&&this.drawBottomLine(d)}drawLyricLines(d,S){S.LyricLines.forEach(M=>{M.Start.y+=S.PositionAndShape.AbsolutePosition.y,M.End.y+=S.PositionAndShape.AbsolutePosition.y,M.Start.x+=S.PositionAndShape.AbsolutePosition.x,M.End.x+=S.PositionAndShape.AbsolutePosition.x,this.drawGraphicalLine(M,this.rules.LyricUnderscoreLineWidth,M.colorHex)})}drawExpressions(d){}drawGraphicalLine(d,S,M="black"){return this.drawLine(d.Start,d.End,M,S)}drawLine(d,S,M="#FF0000FF",E){}drawDashes(d){d.forEach(S=>{var M;S.SVGNode=this.drawLabel(S,s.GraphicalLayers.Notes),(M=S.SVGNode)==null||M.classList.add("dash")})}drawOctaveShifts(d){}drawStaffLines(d){if(d.StaffLines){const S=d.PositionAndShape.AbsolutePosition;for(let M=0;M<5;M++)this.drawLineAsHorizontalRectangleWithOffset(d.StaffLines[M],S,s.GraphicalLayers.Notes)}}drawInstantaneousDynamic(d){throw new Error("not implemented")}drawContinuousDynamic(d){throw new Error("not implemented")}drawSymbol(d,S,M,E=1,L=s.GraphicalLayers.Notes){}get leadSheet(){return this.graphicalMusicSheet.LeadSheet}set leadSheet(d){this.graphicalMusicSheet.LeadSheet=d}drawPage(d){if(this.isVisible(d.PositionAndShape)){for(const S of d.MusicSystems)this.isVisible(S.PositionAndShape)&&this.drawMusicSystem(S);if(d===d.Parent.MusicPages[0])for(const S of d.Labels)S.SVGNode=this.drawLabel(S,s.GraphicalLayers.Notes);this.drawableBoundingBoxElement&&this.drawBoundingBoxes(d.PositionAndShape,0,this.drawableBoundingBoxElement)}}drawBoundingBoxes(d,S=0,M="all",E=!1){const L=d.DataObject.constructor.name;let I=!1;if(M==="all"?I=!0:M==="VexFlowStaffEntry"?I=d.DataObject instanceof x.VexFlowStaffEntry:M==="VexFlowMeasure"?I=d.DataObject instanceof x.VexFlowMeasure:M==="VexFlowGraphicalNote"?I=d.DataObject instanceof x.VexFlowGraphicalNote:M==="VexFlowVoiceEntry"?I=d.DataObject instanceof x.VexFlowVoiceEntry:M==="GraphicalLabel"?I=d.DataObject instanceof o.GraphicalLabel:M==="VexFlowStaffLine"?I=d.DataObject instanceof x.VexFlowStaffLine:M==="SystemLine"?I=d.DataObject instanceof f.SystemLine:M==="StaffLineActivitySymbol"?I=d.DataObject instanceof y.StaffLineActivitySymbol:M==="VexFlowContinuousDynamicExpression"&&(I=d.DataObject instanceof x.VexFlowContinuousDynamicExpression),I||L===M){let T;E&&(T=L),this.drawBoundingBox(d,void 0,!0,T,S)}S++,d.ChildElements.forEach(T=>this.drawBoundingBoxes(T,S,M))}drawBoundingBox(d,S=void 0,M=!1,E=void 0,L=0){let I=new r.RectangleF2D(d.AbsolutePosition.x+d.BorderMarginLeft,d.AbsolutePosition.y+d.BorderMarginTop,d.BorderMarginRight-d.BorderMarginLeft,d.BorderMarginBottom-d.BorderMarginTop);M&&(this.drawLineAsHorizontalRectangle(new u.GraphicalLine(new i.PointF2D(d.AbsolutePosition.x-1,d.AbsolutePosition.y),new i.PointF2D(d.AbsolutePosition.x+1,d.AbsolutePosition.y),.1,s.OutlineAndFillStyleEnum.BaseWritingColor,S),L-1),this.drawLineAsVerticalRectangle(new u.GraphicalLine(new i.PointF2D(d.AbsolutePosition.x,d.AbsolutePosition.y-1),new i.PointF2D(d.AbsolutePosition.x,d.AbsolutePosition.y+1),.1,s.OutlineAndFillStyleEnum.BaseWritingColor,S),L-1)),I=this.applyScreenTransformationForRect(I);const T=this.renderRectangle(I,s.GraphicalLayers.Background,L,S,.5);if(E){const A=new n.Label(E),v=new o.GraphicalLabel(A,.8,h.TextAlignmentEnum.CenterCenter,this.rules);v.setLabelPositionAndShapeBorders(),this.renderLabel(v,L,I.width,I.height,I.height,new i.PointF2D(I.x,I.y+12))}return T}drawMarkedAreas(d){for(const S of d.GraphicalMarkedAreas)S&&(S.systemRectangle&&this.drawRectangle(S.systemRectangle,s.GraphicalLayers.Background),S.settings&&(S.settings.SVGNode=this.drawLabel(S.settings,s.GraphicalLayers.Comment)),S.labelRectangle&&this.drawRectangle(S.labelRectangle,s.GraphicalLayers.Background),S.label&&(S.label.SVGNode=this.drawLabel(S.label,s.GraphicalLayers.Comment)))}drawComment(d){for(const S of d.GraphicalComments)S&&(S.settings&&(S.settings.SVGNode=this.drawLabel(S.settings,s.GraphicalLayers.Comment)),S.label&&(S.label.SVGNode=this.drawLabel(S.label,s.GraphicalLayers.Comment)))}drawStaffLineSymbols(d){const S=d.ParentStaff.ParentInstrument,M=d.PositionAndShape.AbsolutePosition.x,E=d.PositionAndShape.AbsolutePosition.y+2,L=d.PositionAndShape.BorderRight;S.highlight&&this.drawingParameters.drawHighlights&&this.drawLineAsHorizontalRectangle(new u.GraphicalLine(new i.PointF2D(M,E),new i.PointF2D(M+L,E),4,s.OutlineAndFillStyleEnum.Highlighted),s.GraphicalLayers.Highlight);let I=m.MusicSymbolDrawingStyle.Disabled,T=p.MusicSymbol.PLAY,A=this.drawingParameters.drawActivitySymbols;switch(this.phonicScoreMode){case m.PhonicScoreModes.Midi:T=p.MusicSymbol.PLAY,this.midiPlaybackAvailable&&d.ParentStaff.audible&&(I=m.MusicSymbolDrawingStyle.PlaybackSymbols);break;case m.PhonicScoreModes.Following:T=p.MusicSymbol.MIC,d.ParentStaff.following&&(I=m.MusicSymbolDrawingStyle.FollowSymbols);break;default:A=!1}if(A){const v=new i.PointF2D(M+L+2,E);this.drawSymbol(T,I,v)}if(this.drawingParameters.drawErrors)for(const v of d.Measures){const B=v.PositionAndShape,D=B.AbsolutePosition.x,_=B.AbsolutePosition.y+2;v.hasError&&this.graphicalMusicSheet.ParentMusicSheet.DrawErroneousMeasures&&this.drawLineAsHorizontalRectangle(new u.GraphicalLine(new i.PointF2D(D,_),new i.PointF2D(D+B.BorderRight,_),4,s.OutlineAndFillStyleEnum.ErrorUnderlay),s.GraphicalLayers.MeasureError)}}}},512(de,g){var c;Object.defineProperty(g,"__esModule",{value:!0}),g.MusicSymbol=void 0,function(l){l[l.Unused_first_Symbol=0]="Unused_first_Symbol",l[l.BLACK_HEAD=1]="BLACK_HEAD",l[l.UPWARDS_TAIL=2]="UPWARDS_TAIL",l[l.DOWNWARDS_TAIL=3]="DOWNWARDS_TAIL",l[l.UPWARDS_DOUBLE_TAIL=4]="UPWARDS_DOUBLE_TAIL",l[l.DOWNWARDS_DOUBLE_TAIL=5]="DOWNWARDS_DOUBLE_TAIL",l[l.UPWARDS_TRIPLE_TAIL=6]="UPWARDS_TRIPLE_TAIL",l[l.DOWNWARDS_TRIPLE_TAIL=7]="DOWNWARDS_TRIPLE_TAIL",l[l.UPWARDS_QUAD_TAIL=8]="UPWARDS_QUAD_TAIL",l[l.DOWNWARDS_QUAD_TAIL=9]="DOWNWARDS_QUAD_TAIL",l[l.ROUND_HEAD=10]="ROUND_HEAD",l[l.WHITE_HEAD=11]="WHITE_HEAD",l[l.G_CLEF=12]="G_CLEF",l[l.F_CLEF=13]="F_CLEF",l[l.C_CLEF=14]="C_CLEF",l[l.BREVE=15]="BREVE",l[l.BREVE_REST=16]="BREVE_REST",l[l.COMMON_TIME=17]="COMMON_TIME",l[l.CUT_TIME=18]="CUT_TIME",l[l.WHOLE_REST=19]="WHOLE_REST",l[l.HALF_REST=20]="HALF_REST",l[l.QUARTER_REST=21]="QUARTER_REST",l[l.EIGHTH_REST=22]="EIGHTH_REST",l[l.SIXTEENTH_REST=23]="SIXTEENTH_REST",l[l.THIRTYSECOND_REST=24]="THIRTYSECOND_REST",l[l.SIXTYFOURTH_REST=25]="SIXTYFOURTH_REST",l[l.FLAT=26]="FLAT",l[l.SHARP=27]="SHARP",l[l.NATURAL=28]="NATURAL",l[l.DOUBLE_FLAT=29]="DOUBLE_FLAT",l[l.DOUBLE_SHARP=30]="DOUBLE_SHARP",l[l.ZERO=31]="ZERO",l[l.ONE=32]="ONE",l[l.TWO=33]="TWO",l[l.THREE=34]="THREE",l[l.FOUR=35]="FOUR",l[l.FIVE=36]="FIVE",l[l.SIX=37]="SIX",l[l.SEVEN=38]="SEVEN",l[l.EIGHT=39]="EIGHT",l[l.NINE=40]="NINE",l[l.DOT=41]="DOT",l[l.FERMATA=42]="FERMATA",l[l.INVERTED_FERMATA=43]="INVERTED_FERMATA",l[l.SPICCATO=44]="SPICCATO",l[l.TENUTO=45]="TENUTO",l[l.MARCATO=46]="MARCATO",l[l.MARCATISSIMO=47]="MARCATISSIMO",l[l.INVERTED_MARCATISSIMO=48]="INVERTED_MARCATISSIMO",l[l.P=49]="P",l[l.F=50]="F",l[l.S=51]="S",l[l.Z=52]="Z",l[l.M=53]="M",l[l.R=54]="R",l[l.SEGNO=55]="SEGNO",l[l.CODA=56]="CODA",l[l.DRUM_CLEF=57]="DRUM_CLEF",l[l.G_CLEF_SUB8=58]="G_CLEF_SUB8",l[l.G_CLEF_SUPER8=59]="G_CLEF_SUPER8",l[l.G_CLEF_SUB15=60]="G_CLEF_SUB15",l[l.G_CLEF_SUPER15=61]="G_CLEF_SUPER15",l[l.F_CLEF_SUB8=62]="F_CLEF_SUB8",l[l.F_CLEF_SUPER8=63]="F_CLEF_SUPER8",l[l.F_CLEF_SUB15=64]="F_CLEF_SUB15",l[l.F_CLEF_SUPER15=65]="F_CLEF_SUPER15",l[l.DOWN_BOW=66]="DOWN_BOW",l[l.MORDENT=67]="MORDENT",l[l.INVERTED_MORDENT=68]="INVERTED_MORDENT",l[l.TURN=69]="TURN",l[l.INVERTED_TURN=70]="INVERTED_TURN",l[l.LEFTHAND_PIZZICATO=71]="LEFTHAND_PIZZICATO",l[l.RELEASE_PED=72]="RELEASE_PED",l[l.ENGAGE_PED=73]="ENGAGE_PED",l[l.VA8=74]="VA8",l[l.VB8=75]="VB8",l[l.TRILL=76]="TRILL",l[l.MA15=77]="MA15",l[l.MB15=78]="MB15",l[l.HIGH=79]="HIGH",l[l.PLAY=80]="PLAY",l[l.MIC=81]="MIC",l[l.SNAP_PIZZICATO=82]="SNAP_PIZZICATO",l[l.NATURAL_HARMONIC=83]="NATURAL_HARMONIC",l[l.EditPen=84]="EditPen",l[l.PEDAL_BRACKET=85]="PEDAL_BRACKET",l[l.PEDAL_MIXED=86]="PEDAL_MIXED",l[l.PEDAL_SYMBOL=87]="PEDAL_SYMBOL"}(c||(g.MusicSymbol=c={}))},5221(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.MusicSystem=void 0;const l=c(9252),s=c(6438),u=c(2561),r=c(7533),i=c(8254),o=c(7741),n=c(9409),h=c(6954),t=c(3263),f=c(67),p=c(7435);class m extends o.GraphicalObject{constructor(y){super(),this.needsToBeRedrawn=!0,this.staffLines=[],this.graphicalMeasures=[],this.labels=new t.Dictionary,this.measureNumberLabels=[],this.objectsToRedraw=[],this.instrumentBrackets=[],this.groupBrackets=[],this.graphicalMarkedAreas=[],this.graphicalComments=[],this.systemLines=[],this.breaksPage=!1,this.id=y,this.boundingBox=new s.BoundingBox(this),this.maxLabelLength=0}get Parent(){return this.parent}set Parent(y){if(this.parent){const d=this.parent.MusicSystems.indexOf(this,0);d>-1&&this.parent.MusicSystems.splice(d,1)}this.parent=y,this.boundingBox.Parent=y.PositionAndShape}get NextSystem(){const y=this.Parent.MusicSystems.indexOf(this);return y!==this.Parent.MusicSystems.length?this.Parent.MusicSystems[y+1]:void 0}get StaffLines(){return this.staffLines}set StaffLines(y){this.staffLines=y}get GraphicalMeasures(){return this.graphicalMeasures}get MeasureNumberLabels(){return this.measureNumberLabels}get Labels(){return this.labels.values()}get ObjectsToRedraw(){return this.objectsToRedraw}get InstrumentBrackets(){return this.instrumentBrackets}get GroupBrackets(){return this.groupBrackets}get GraphicalMarkedAreas(){return this.graphicalMarkedAreas}get GraphicalComments(){return this.graphicalComments}get SystemLines(){return this.systemLines}get Id(){return this.id}get MaxLabelLength(){return this.maxLabelLength}createSystemLeftLine(y,d,S){let M=-y/2;S&&(M=this.maxLabelLength+d-y/2);const E=this.staffLines[0].Measures[0];let L;this.staffLines.length>1&&(L=this.staffLines[this.staffLines.length-1].Measures[0]);const I=this.createSystemLine(M,y,h.SystemLinesEnum.SingleThin,f.SystemLinePosition.MeasureBegin,this,E,L);this.SystemLines.push(I),I.PositionAndShape.RelativePosition=new n.PointF2D(M,0),I.PositionAndShape.BorderLeft=0,I.PositionAndShape.BorderRight=y,I.PositionAndShape.BorderTop=I.PositionAndShape.Parent.BorderTop,I.PositionAndShape.BorderBottom=I.PositionAndShape.Parent.BorderBottom,this.createLinesForSystemLine(I)}createVerticalLineForMeasure(y,d,S,M,E,L){const I=L.ParentStaffLine,T=new n.PointF2D(I.PositionAndShape.RelativePosition.x,I.PositionAndShape.RelativePosition.y),A=I.ParentStaff.ParentInstrument.Staves;if(I.ParentStaff===A[0]){let v;A.length>1&&(v=this.getBottomStaffLine(I).Measures[E]);const B=this.createSystemLine(y,d,S,M,this,L,v),D=T.x+y;B.PositionAndShape.RelativePosition=new n.PointF2D(D,0),B.PositionAndShape.BorderLeft=0,B.PositionAndShape.BorderRight=d,this.SystemLines.push(B)}}setYPositionsToVerticalLineObjectsAndCreateLines(y){}calculateBorders(y){}alignBeginInstructions(){}GetLeftBorderAbsoluteXPosition(){return this.StaffLines[0].PositionAndShape.AbsolutePosition.x+this.StaffLines[0].Measures[0].beginInstructionsWidth}GetRightBorderAbsoluteXPosition(){return this.StaffLines[0].PositionAndShape.AbsolutePosition.x+this.StaffLines[0].StaffLines[0].End.x}AddGraphicalMeasures(y){for(let d=0,S=y.length;d1){let L,I;for(let T=0,A=this.staffLines.length;Tthis.maxLabelLength&&(this.maxLabelLength=v.PositionAndShape.Size.width,d=E)}this.updateMusicSystemStaffLineXPosition(d)}setMusicSystemLabelsYPosition(){this.labels.forEach((y,d)=>{let S=0,M=0;for(let E=0;E0&&(d.PositionAndShape.RelativePosition=new n.PointF2D(0,S/M+2))})}checkStaffEntriesForStaffEntryLink(){let y=!1,d=!1;for(let S=0;S=0;E--)if((M=d[E])!=null&&M.Visible){S=d[E];break}for(const E of y.ParentMusicSystem.staffLines)if(E.ParentStaff===S)return E}createSystemLine(y,d,S,M,E,L,I=void 0){throw new Error("not implemented")}createLinesForSystemLine(y){}calcBracketsWidth(){let y=0;for(let d=0,S=this.GroupBrackets.length;d=0;S--){if(d=y.InstrumentalGroups[S],!(d instanceof l.Instrument))return this.findLastVisibleInstrumentInInstrumentalGroup(d);if(d.isVisible())return d}}updateMusicSystemStaffLineXPosition(y){for(let d=0,S=this.StaffLines.length;d0?this.currentSystemParams.maxLabelLength+this.rules.SystemLabelsRightMargin:0,ie=this.currentSystemParams.currentWidth+G+P+X0;if(A||ie&&!$){if(this.addMeasureToSystem(E,_,k,G,B,F,D),this.updateActiveClefs(L,E),this.measureListIndex++,T){if(this.rules.MaxSystemToDrawNumber===this.musicSystems.length)return this.finalizeCurrentSystem(E,!this.rules.StretchLastSystemLine,!1),this.musicSystems;this.finalizeCurrentAndCreateNewSystem(E,!this.rules.StretchLastSystemLine,!1)}y=I}else{if(this.rules.MaxSystemToDrawNumber===this.musicSystems.length)return this.finalizeCurrentSystem(E,!1,!0,oe),this.musicSystems;this.finalizeCurrentAndCreateNewSystem(E,!1,!0,oe)}}if(this.currentSystemParams.systemMeasures.length>0){if(this.rules.MaxSystemToDrawNumber===this.musicSystems.length)return this.finalizeCurrentSystem(this.measureList[this.measureList.length-1],!this.rules.StretchLastSystemLine,!1),this.musicSystems;this.finalizeCurrentAndCreateNewSystem(this.measureList[this.measureList.length-1],!this.rules.StretchLastSystemLine,!1)}return this.musicSystems}calculateSystemYLayout(){for(const x of this.musicSystems)this.optimizeDistanceBetweenStaffLines(x);this.calculateMusicSystemsRelativePositions()}setMeasureWidth(x,y,d,S){for(let M=0,E=x.length;M0&&(L.beginInstructionsWidth=d),S>0&&(L.endInstructionsWidth=S)}}finalizeCurrentAndCreateNewSystem(x,y=!1,d=!0,S=!1){this.finalizeCurrentSystem(x,y,d,S),this.currentSystemParams=new m,x!==void 0&&this.measureListIndex=1){const y=this.currentSystemParams.currentSystem.GraphicalMeasures[this.currentSystemParams.currentSystem.GraphicalMeasures.length-1];let d=0;const S=x[x.length-1];S.endLine===n.SystemLinesEnum.DotsBoldBoldDots&&(S.endLine=n.SystemLinesEnum.DotsThinBold,d=y[0].getLineWidth(n.SystemLinesEnum.DotsBoldBoldDots)/2-y[0].getLineWidth(n.SystemLinesEnum.DotsThinBold)),this.currentSystemParams.currentSystemFixWidth-=d;for(let M=0,E=y.length;M1){E=!0;break}}let L=0;for(let I=0;I=0&&this.measureList[F]){const k=this.measureList[F],j=(D=k[0])==null?void 0:D.parentSourceMeasure;j!=null&&j.ImplicitMeasure&&(j!=null&&j.RhythmPrinted)&&(_=!1)}_&&(y.addRhythmAtBegin(I),y.parentSourceMeasure.RhythmPrinted=I,B=!0)}return(A||v||B)&&(T+=y.beginInstructionsWidth,B&&(T+=this.rules.RhythmRightMargin)),T}addInstructionsAtMeasureEnd(x,y,d){if(!x||!x.Instructions||x.Instructions.length===0)return 0;for(let S=0,M=x.Instructions.length;S0&&(this.currentSystemParams.systemMeasures.push({beginLine:n.SystemLinesEnum.None,endLine:n.SystemLinesEnum.None}),this.currentSystemParams.currentWidth+=S,this.currentSystemParams.currentSystemFixWidth+=S)}addExtraInstructionMeasure(x,y,d){const S=this.currentSystemParams.currentSystem,M=h.MusicSheetCalculator.symbolFactory.createExtraGraphicalMeasure(S.StaffLines[x]);y&&M.addKeyAtBegin(y,this.activeKeys[x],this.activeClefs[x]),d!==void 0&&d.PrintObject&&M.addRhythmAtBegin(d),M.PositionAndShape.BorderLeft=0,M.PositionAndShape.BorderTop=0,M.PositionAndShape.BorderBottom=this.rules.StaffHeight;const E=this.rules.MeasureLeftMargin+M.beginInstructionsWidth+this.rules.MeasureRightMargin;return M.PositionAndShape.BorderRight=E,S.StaffLines[x].Measures.push(M),E}addStaveMeasuresToSystem(x){if(x[0]){const y=[];for(let S=0;S1){const y=Math.min(this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length-1,x.measureListIndex+x.multipleRestMeasures-1);x=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures[y]}}finally{}return this.nextMeasureBeginsLineRepetition()&&this.thisMeasureEndsLineRepetition()?n.SystemLinesEnum.DotsBoldBoldDots:this.thisMeasureEndsLineRepetition()?n.SystemLinesEnum.DotsThinBold:this.nextMeasureHasKeyInstructionChange()?n.SystemLinesEnum.DoubleThin:x&&x.endingBarStyleEnum!==void 0?x.endingBarStyleEnum:n.SystemLinesEnum.SingleThin}getLineWidth(x,y,d){let S=x.getLineWidth(y);return y===n.SystemLinesEnum.DotsBoldBoldDots&&(S/=2),d&&y===n.SystemLinesEnum.BoldThinDots&&(S+=this.rules.DistanceBetweenLastInstructionAndRepetitionBarline),S}previousMeasureEndsLineRepetition(){if(this.measureListIndex===0)return!1;for(let x=0,y=this.measureList[this.measureListIndex-1].length;x=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length||!this.measureList[x])return!1;for(let y=0,d=this.measureList[x].length;y=I))break;E=A,I=A.multipleRestMeasureNumber}return E.endsWithLineRepetition()}}return!1}nextMeasureBeginsWordRepetition(){const x=this.measureListIndex+1;if(x>=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length||x>this.measureList.length-1)return!1;for(let y=0,d=this.measureList[x].length;ythis.rules.PageHeight-this.rules.PageBottomMargin&&(S++,S<=4&&console.log(`warning: could not fit a single system on page ${x.PageNumber} and measure number ${d.GraphicalMeasures[0][0].MeasureNumber}. The PageFormat may be too small for this sheet." Will not give further warnings for all pages, only total.`))}else{const E=this.musicSystems[M-1],L=E.StaffLines[E.StaffLines.length-1],I=L.PositionAndShape;let T=this.findRequiredDistanceWithSkyBottomLine(E,d);T+=this.rules.MinSkyBottomDistBetweenSystems,T=Math.max(T,this.rules.MinimumDistanceBetweenSystems+L.StaffHeight);const A=y+I.RelativePosition.y+T,v=A+d.PositionAndShape.BorderMarginBottom;if(this.rules.NewPageAtXMLNewPageAttribute&&E.breaksPage||!(v0&&console.log(`total amount of pages that couldn't fit a single music system: ${S} of ${x.PageNumber}`)}findRequiredDistanceWithSkyBottomLine(x,y){const d=x.StaffLines[x.StaffLines.length-1],S=y.StaffLines[0],M=d.BottomLine,E=S.SkyLine,L=d.PositionAndShape,I=S.PositionAndShape,T=1/this.rules.SamplingUnit;let A=0;for(let v=0;v=E.length)break;const _=Math.max(0,D-6),F=Math.min(E.length-1,D+6);let k=0;for(let P=_;P<=F;P++)k=Math.min(k,E[P]);const j=B-k;A=Math.max(j,A)}return A===0&&(A=L.BorderBottom-I.BorderTop),A}};class m{constructor(){this.systemMeasures=[],this.systemMeasureIndex=0,this.currentWidth=0,this.currentSystemFixWidth=0,this.currentSystemVarWidth=0,this.maxLabelLength=0}IsSystemStartMeasure(){return this.systemMeasureIndex===0}}g.SystemBuildParameters=m,g.MeasureBuildParameters=class{}},8033(de,g){Object.defineProperty(g,"__esModule",{value:!0}),g.OctaveShiftParams=void 0,g.OctaveShiftParams=class{constructor(c,l,s){this.getOpenOctaveShift=c,this.getAbsoluteStartTimestamp=l,this.getAbsoluteEndTimestamp=s}}},735(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.PlainSkyBottomLineBatchCalculatorBackend=void 0;const l=c(5479),s=c(3667);class u extends s.SkyBottomLineBatchCalculatorBackend{constructor(i,o){super(i,o)}getPreferredRenderingConfiguration(i,o){return{elementWidth:Math.ceil(i),numColumns:6,numRows:6}}onInitialize(i){}calculateFromCanvas(i,o,n,h,t){const f=i.width,p=o.getImageData(0,0,i.width,i.height),{elementWidth:m,elementHeight:x,numColumns:y}=t,d=[];for(let S=0;S0){B[k-I]=j-A;break}}D[k-I]=x;for(let j=v-1;j>=A;j--){const P=j*f*4+4*k;if(p.data[P+3]>0){D[k-I]=j-A;break}}}const _=Math.max(...B),F=Math.min(...D);for(let k=0;k{if(t.has(p))return t.get(p);{const m=[];return t.set(p,m),m}})().push({skyBottomLineCalculator:f.SkyBottomLineCalculator,measures:f.Measures})}this.batches=new Map;for(const[f,p]of t.entries()){const m=o.CollectionUtil.flat(p.map(y=>y.measures)),x=(()=>{if(h===s.SkyBottomLineBatchCalculatorBackendType.Plain)return new u.PlainSkyBottomLineBatchCalculatorBackend(f,m).initialize();try{return new r.WebGLSkyBottomLineBatchCalculatorBackend(f,m).initialize()}catch{return i.default.info("Couldn't create WebGLBackend for Skyline. Using fallback."),new u.PlainSkyBottomLineBatchCalculatorBackend(f,m).initialize()}})();x.initialize(),this.batches.set(f,{backend:x,entries:p})}}calculateLines(){for(const[,{backend:n,entries:h}]of this.batches){const t=n.calculateLines();let f=0;for(const{skyBottomLineCalculator:p,measures:m}of h){const x=f+m.length;p.updateLines(t.slice(f,x)),f=x}}}}},3667(de,g,c){var l=this&&this.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(g,"__esModule",{value:!0}),g.SkyBottomLineBatchCalculatorBackend=void 0;const s=c(9834),u=l(c(3065));g.SkyBottomLineBatchCalculatorBackend=class{constructor(r,i){this.elementHeight=300,this.canvas=new s.CanvasVexFlowBackend(r),this.measures=i,this.maxWidth=Math.max(...this.measures.map(o=>{let n=o.getVFStave().getWidth();return n>0||o.IsExtraGraphicalMeasure||(u.default.warn("SkyBottomLineBatchCalculatorBackend: width not > 0 in measure "+o.MeasureNumber),n=50),n})),this.samplingUnit=r.SamplingUnit}initialize(){if(this.tableConfiguration={...this.getPreferredRenderingConfiguration(this.maxWidth,this.elementHeight),elementHeight:this.elementHeight},this.tableConfiguration.numRows<1||this.tableConfiguration.numColumns<1)throw u.default.warn("SkyBottomLineBatchCalculatorBackend: numRows or numColumns in tableConfiguration is 0"),new Error("numRows or numColumns in tableConfiguration is 0");this.tableConfiguration.elementWidth0||M.IsExtraGraphicalMeasure||(T=50),T=Math.floor(T),M.PositionAndShape.calculateAbsolutePositionsRecursive(0,0),E.setX(0);const v=E.y+100;E.setY(v);const B=E.getWidth();E.setWidth(T),M.format(),E.setWidth(B);try{f.translate(L*o,I*n),M.draw(t),f.translate(-L*o,-I*n)}catch(D){u.default.warn("SkyBottomLineBatchCalculatorBackend.calculateLines.draw",D)}}const d=this.calculateFromCanvas(p,t,y,this.samplingUnit,this.tableConfiguration);m.push(...d)}return m}}},5479(de,g){Object.defineProperty(g,"__esModule",{value:!0}),g.SkyBottomLineCalculationResult=void 0,g.SkyBottomLineCalculationResult=class{constructor(c,l){this.skyLine=c,this.bottomLine=l}}},2779(de,g,c){var l=this&&this.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(g,"__esModule",{value:!0}),g.SkyBottomLineCalculator=void 0,c(9409);const s=c(9479),u=l(c(3065)),r=c(5479),i=c(9834);g.SkyBottomLineCalculator=class{constructor(o){this.mStaffLineParent=o,this.mRules=o.ParentMusicSystem.rules}updateLines(o){const n=this.StaffLineParent.Measures;if(o.length!==n.length)if(u.default.warn("SkyBottomLineCalculator: lengths of calculation result array and measure array do not match"),o.length(y-m)/s.unitInPixels+this.StaffLineParent.TopLineOffset);const x=Math.min(...this.mBottomLine);this.mBottomLine=this.mBottomLine.map(y=>(y-x)/s.unitInPixels+this.StaffLineParent.BottomLineOffset)}calculateLines(){const o=this.mRules.SamplingUnit,n=[],h=new i.CanvasVexFlowBackend(this.mRules);for(const t of this.StaffLineParent.Measures){t.PositionAndShape.calculateAbsolutePositionsRecursive(0,0);const f=t.getVFStave();let p=f.getWidth();p>0||t.IsExtraGraphicalMeasure||(u.default.warn("SkyBottomLineCalculator: width not > 0 in measure "+t.MeasureNumber),p=50),h.initializeHeadless(p);const m=h.getContext(),x=h.getCanvas();p=x.width;const y=x.height;f.setY(f.y+100);const d=f.getWidth();f.setWidth(p),t.format(),f.setWidth(d);try{t.draw(m)}catch(T){u.default.warn("SkyBottomLineCalculator.calculateLines.draw",T)}const S=m.getImageData(0,0,p,y),M=4,E=Math.max(Math.ceil(t.PositionAndShape.Size.width*o),1),L=new Array(E),I=new Array(E);for(let T=0;T0){L[T]=A;break}}for(let A=y;A>0;A--){const v=A*p*M+T*M;if(S.data[v+3]>0){I[T]=A;break}}}for(let T=0;T=this.BottomLine.length&&(h=this.BottomLine.length-1),t<0&&(t=0),t>=this.BottomLine.length&&(t=this.BottomLine.length),this.SkyLine[h]=o.y;for(let p=h+1;p=this.BottomLine.length&&(h=this.BottomLine.length-1),t<0&&(t=0),t>=this.BottomLine.length&&(t=this.BottomLine.length),this.BottomLine[h]=o.y;for(let p=h+1;po)}setBottomLineWithValue(o){this.BottomLine.forEach(n=>o)}getLeftIndexForPointX(o,n){const h=Math.floor(o*this.SamplingUnit);return h<0?0:h>=n?n-1:h}getRightIndexForPointX(o,n){const h=Math.ceil(o*this.SamplingUnit);return h<0?0:h>=n?n-1:h}updateStaffLineBorders(){this.mStaffLineParent.PositionAndShape.BorderTop=this.getSkyLineMin(),this.mStaffLineParent.PositionAndShape.BorderMarginTop=this.getSkyLineMin(),this.mStaffLineParent.PositionAndShape.BorderBottom=this.getBottomLineMax(),this.mStaffLineParent.PositionAndShape.BorderMarginBottom=this.getBottomLineMax()}getSkyLineMin(){return Math.min(...this.SkyLine.filter(o=>!isNaN(o)))}getSkyLineMinAtPoint(o){const n=Math.round(o*this.SamplingUnit);return this.mSkyLine[n]}getSkyLineMinInRange(o,n){return this.getMinInRange(this.SkyLine,o,n)}getBottomLineMax(){return Math.max(...this.BottomLine.filter(o=>!isNaN(o)))}getBottomLineMaxAtPoint(o){const n=Math.round(o*this.SamplingUnit);return this.mBottomLine[n]}getBottomLineMaxInRange(o,n){return this.getMaxInRange(this.BottomLine,o,n)}getBottomLineMaxInBoundingBox(o){const n=Math.floor(o.AbsolutePosition.x+o.BorderLeft),h=Math.ceil(o.AbsolutePosition.x+o.BorderRight);return this.getMaxInRange(this.mBottomLine,n,h)}updateWithBoundingBoxRecursively(o){if(o.ChildElements&&o.ChildElements.length>0)this.updateWithBoundingBoxRecursively(o);else{const n=o.BorderTop+o.AbsolutePosition.y,h=o.BorderBottom+o.AbsolutePosition.y;if(n<0){const t=Math.floor(o.AbsolutePosition.x+o.BorderLeft),f=Math.ceil(o.AbsolutePosition.x+o.BorderRight);this.updateInRange(this.mSkyLine,t,f,n)}else if(h>this.StaffLineParent.StaffHeight){const t=Math.floor(o.AbsolutePosition.x+o.BorderLeft),f=Math.ceil(o.AbsolutePosition.x+o.BorderRight);this.updateInRange(this.mBottomLine,t,f,h)}}}findPreviousValidNumber(o,n){for(let h=o;h>=0;h--)if(!isNaN(n[h]))return n[h];return 0}findNextValidNumber(o,n){if(o>=n.length)return n[o-1];for(let h=o;ho.length&&(h=o.length);for(let f=n;fMath.abs(o[f])?t:o[f]}setInRange(o,n=0,h=o.length,t=0){if(n=Math.floor(n*this.SamplingUnit),(h=Math.ceil(h*this.SamplingUnit))o.length&&(h=o.length);for(let f=n;f=o.length&&(n=o.length-1),h<0&&(h=0),h>=o.length&&(h=o.length),n>=0&&h<=o.length?Math.min(...o.slice(n,h+1)):void 0):Number.MAX_VALUE}getMaxInRange(o,n,h){return n=Math.floor(n*this.SamplingUnit),h=Math.ceil(h*this.SamplingUnit),o?(n<0&&(n=0),n>=o.length&&(n=o.length-1),h<0&&(h=0),h>=o.length&&(h=o.length),n>=0&&h<=o.length?Math.max(...o.slice(n,h+1)):void 0):Number.MIN_VALUE}get SamplingUnit(){return this.mRules.SamplingUnit}get StaffLineParent(){return this.mStaffLineParent}get SkyLine(){return this.mSkyLine}get BottomLine(){return this.mBottomLine}}},2919(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.StaffLine=void 0;const l=c(6438),s=c(7741),u=c(298),r=c(9409),i=c(2779);class o extends s.GraphicalObject{constructor(h,t){super(),this.measures=[],this.staffLines=new Array(5),this.octaveShifts=[],this.lyricLines=[],this.lyricsDashes=[],this.abstractExpressions=[],this.graphicalSlurs=[],this.graphicalGlissandi=[],this.Pedals=[],this.WavyLines=[],this.parentMusicSystem=h,this.parentStaff=t,this.boundingBox=new l.BoundingBox(this,h.PositionAndShape),this.skyBottomLine=new i.SkyBottomLineCalculator(this),this.staffHeight=this.parentMusicSystem.rules.StaffHeight,this.topLineOffset=0,this.bottomLineOffset=4,this.calculateStaffLineOffsets()}calculateStaffLineOffsets(){if(this.ParentStaff.isTab)this.ParentStaff.StafflineCount===5?this.staffHeight=this.bottomLineOffset=6*this.ParentStaff.ParentInstrument.GetMusicSheet.Rules.TabStaffInterlineHeight:this.staffHeight=this.bottomLineOffset=this.ParentStaff.ParentInstrument.GetMusicSheet.Rules.TabStaffInterlineHeight*this.ParentStaff.StafflineCount;else switch(this.ParentStaff.StafflineCount){case 4:this.bottomLineOffset=1;break;case 3:this.topLineOffset=1,this.bottomLineOffset=1;break;case 2:this.topLineOffset=2,this.bottomLineOffset=1;break;case 1:this.topLineOffset=2,this.bottomLineOffset=2}}get Measures(){return this.measures}set Measures(h){this.measures=h}get StaffLines(){return this.staffLines}set StaffLines(h){this.staffLines=h}get NextStaffLine(){const h=this.parentMusicSystem.StaffLines.indexOf(this);return h!==this.parentMusicSystem.StaffLines.length?this.parentMusicSystem.StaffLines[h+1]:void 0}get LyricLines(){return this.lyricLines}get AbstractExpressions(){return this.abstractExpressions}set AbstractExpressions(h){this.abstractExpressions=h}set LyricLines(h){this.lyricLines=h}get LyricsDashes(){return this.lyricsDashes}set LyricsDashes(h){this.lyricsDashes=h}get ParentMusicSystem(){return this.parentMusicSystem}set ParentMusicSystem(h){this.parentMusicSystem=h}get ParentStaff(){return this.parentStaff}set ParentStaff(h){this.parentStaff=h}get SkyBottomLineCalculator(){return this.skyBottomLine}get SkyLine(){return this.skyBottomLine.SkyLine}get BottomLine(){return this.skyBottomLine.BottomLine}get OctaveShifts(){return this.octaveShifts}set OctaveShifts(h){this.octaveShifts=h}get StaffHeight(){return this.staffHeight}get TopLineOffset(){return this.topLineOffset}get BottomLineOffset(){return this.bottomLineOffset}get GraphicalSlurs(){return this.graphicalSlurs}get GraphicalGlissandi(){return this.graphicalGlissandi}addSlurToStaffline(h){this.graphicalSlurs.push(h)}addGlissandoToStaffline(h){this.graphicalGlissandi.push(h),h.StaffLine=this}addActivitySymbolClickArea(){const h=new u.StaffLineActivitySymbol(this),t=this.PositionAndShape;h.PositionAndShape.RelativePosition=new r.PointF2D(t.RelativePosition.x+t.BorderRight+.5,t.RelativePosition.y+.5),h.PositionAndShape.Parent=this.parentMusicSystem.PositionAndShape}isPartOfMultiStaffInstrument(){return this.parentStaff.ParentInstrument.Staves.length>1}findClosestStaffEntry(h){let t;for(let f=0,p=this.Measures.length;fu?1:0}getFirstNonNullStaffEntry(){for(let c=0,l=this.staffEntries.length;c0){const h=n.map(f=>f.PositionAndShape.Center.y),t=Math.max(...h);for(let f=0;f0?n[f-1]:void 0;if(x){const d=this.getOverlap(p.PositionAndShape,x.PositionAndShape);p.squeeze(-(d.x+this.rules.DynamicExpressionSpacer))}if(y){const d=this.getOverlap(y.PositionAndShape,p.PositionAndShape);p.squeeze(d.x+this.rules.DynamicExpressionSpacer)}}}}}getDistance(u,r){const i=u.RelativePosition.x+u.BorderMarginRight,o=r.RelativePosition.x+r.BorderMarginLeft,n=u.RelativePosition.y+u.BorderMarginBottom,h=r.RelativePosition.y+r.BorderMarginTop;return new s.PointF2D(o-i,h-n)}getOverlap(u,r){return new s.PointF2D(u.RelativePosition.x+u.BorderMarginRight-(r.RelativePosition.x+r.BorderMarginLeft),u.RelativePosition.y+u.BorderMarginBottom-(r.RelativePosition.y+r.BorderMarginTop))}}},9834(de,g,c){var l=this&&this.__importDefault||function(h){return h&&h.__esModule?h:{default:h}};Object.defineProperty(g,"__esModule",{value:!0}),g.CanvasVexFlowBackend=void 0;var s=l(c(3206)).default.Flow;const u=c(1902),r=c(6014),i=c(624),o=c(1888);class n extends u.VexFlowBackend{constructor(t){super(),this.rules=t}getVexflowBackendType(){return s.Renderer.Backends.CANVAS}getOSMDBackendType(){return i.BackendType.Canvas}getCanvasSize(){var t;return(t=document.getElementById("osmdCanvasPage"+this.graphicalMusicPage.PageNumber))==null?void 0:t.offsetHeight}initialize(t,f){this.zoom=f,this.canvas=document.createElement("canvas"),this.graphicalMusicPage||(this.graphicalMusicPage=new o.GraphicalMusicPage(void 0),this.graphicalMusicPage.PageNumber=1),this.canvas.id="osmdCanvasVexFlowBackendCanvas"+this.graphicalMusicPage.PageNumber,this.inner=document.createElement("div"),this.inner.id="osmdCanvasPage"+this.graphicalMusicPage.PageNumber,this.inner.style.position="relative",this.canvas.style.zIndex="0",this.inner.appendChild(this.canvas),t.appendChild(this.inner),this.renderer=new s.Renderer(this.canvas,this.getVexflowBackendType()),this.ctx=this.renderer.getContext()}initializeHeadless(t=300,f=300){this.graphicalMusicPage||(this.graphicalMusicPage=new o.GraphicalMusicPage(void 0),this.graphicalMusicPage.PageNumber=1),this.canvas=document.createElement("canvas"),this.canvas.width=t,this.canvas.height=f,this.renderer=new s.Renderer(this.canvas,this.getVexflowBackendType()),this.ctx=this.renderer.getContext()}getContext(){return this.ctx}free(){this.canvas&&(this.canvas.width=0,this.canvas.height=0,this.canvas.remove(),delete this.canvas,this.canvas=null)}clear(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.rules.PageBackgroundColor&&(this.ctx.save(),this.ctx.setFillStyle(this.rules.PageBackgroundColor),this.zoom=1,this.ctx.fillRect(0,0,this.canvas.width/this.zoom,this.canvas.height/this.zoom),this.ctx.restore())}scale(t){this.ctx.scale(t,t)}translate(t,f){this.CanvasRenderingCtx.translate(t,f)}renderText(t,f,p,m,x,y,d=void 0,S=void 0){const M=this.CanvasRenderingCtx.font;this.CanvasRenderingCtx.save(),this.CanvasRenderingCtx.font=r.VexFlowConverter.font(t,f,p,this.rules,S),this.CanvasRenderingCtx.fillStyle=d,this.CanvasRenderingCtx.strokeStyle=d,this.CanvasRenderingCtx.fillText(m,y.x,y.y+x),this.CanvasRenderingCtx.restore(),this.CanvasRenderingCtx.font=M}renderRectangle(t,f,p,m=1){const x=this.CanvasRenderingCtx.fillStyle;this.CanvasRenderingCtx.fillStyle=p||r.VexFlowConverter.style(f),this.CanvasRenderingCtx.globalAlpha=m,this.ctx.fillRect(t.x,t.y,t.width,t.height),this.CanvasRenderingCtx.fillStyle=x,this.CanvasRenderingCtx.globalAlpha=1}renderLine(t,f,p="#FF0000FF",m=2,x){const y=this.CanvasRenderingCtx.strokeStyle;this.CanvasRenderingCtx.strokeStyle=p,this.CanvasRenderingCtx.beginPath(),this.CanvasRenderingCtx.moveTo(t.x,t.y),this.CanvasRenderingCtx.lineTo(f.x,f.y),this.CanvasRenderingCtx.stroke(),this.CanvasRenderingCtx.strokeStyle=y}renderCurve(t){this.ctx.beginPath(),this.ctx.moveTo(t[0].x,t[0].y),this.ctx.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y),this.ctx.lineTo(t[7].x,t[7].y),this.ctx.bezierCurveTo(t[6].x,t[6].y,t[5].x,t[5].y,t[4].x,t[4].y),this.ctx.lineTo(t[0].x,t[0].y),this.ctx.closePath(),this.ctx.fill()}renderPath(t,f=!0,p){let m;this.ctx.beginPath();for(const x of t)m?this.ctx.lineTo(x.x,x.y):(this.ctx.moveTo(x.x,x.y),m=x);this.ctx.closePath(),f?this.ctx.fill():this.ctx.stroke()}get CanvasRenderingCtx(){return this.ctx.vexFlowCanvasContext}}g.CanvasVexFlowBackend=n},9436(de,g,c){var l=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(g,"__esModule",{value:!0}),g.SvgVexFlowBackend=void 0;var s=l(c(3206)).default.Flow;const u=c(1902),r=c(6014),i=c(2570),o=c(624),n=l(c(3065));class h extends u.VexFlowBackend{constructor(f){super(),this.rules=f}getVexflowBackendType(){return s.Renderer.Backends.SVG}getOSMDBackendType(){return o.BackendType.SVG}getCanvasSize(){var f;return(f=document.getElementById("osmdCanvasPage"+this.graphicalMusicPage.PageNumber))==null?void 0:f.offsetHeight}initialize(f,p){this.zoom=p,this.canvas=document.createElement("div"),this.canvas.id="osmdCanvasPage"+this.graphicalMusicPage.PageNumber,this.inner=this.canvas,this.inner.style.position="relative",this.canvas.style.zIndex="0",f.appendChild(this.inner),this.renderer=new s.Renderer(this.canvas,this.getVexflowBackendType()),this.ctx=this.renderer.getContext(),this.ctx.svg.id="osmdSvgPage"+this.graphicalMusicPage.PageNumber}getContext(){return this.ctx}getSvgElement(){return this.ctx.svg}removeNode(f){var m;const p=(m=this.ctx)==null?void 0:m.svg;if(!p)return!1;try{p.removeChild(f)}catch(x){return n.default.error(x),!1}return!0}free(){const f=this.ctx.svg;for(;f.lastChild;)f.removeChild(f.lastChild)}clear(){this.ctx&&(this.free(),this.rules.PageBackgroundColor&&(this.ctx.svg.style["background-color"]=this.rules.PageBackgroundColor))}scale(f){this.ctx.scale(f,f)}translate(f,p){}renderText(f,p,m,x,y,d,S=void 0,M=void 0){this.ctx.save();const E=this.ctx.openGroup("text");S&&(this.ctx.attributes.fill=S,this.ctx.attributes.stroke=S);let L=M;M&&M!=="default"||(L=this.rules.DefaultFontFamily),this.ctx.setFont(L,f,r.VexFlowConverter.fontStyle(p)),this.ctx.attributes["font-size"]=`${f}px`,this.ctx.state["font-size"]=`${f}px`;let I="normal",T="normal";switch(p){case i.FontStyles.Bold:I="bold";break;case i.FontStyles.Italic:T="italic";break;case i.FontStyles.BoldItalic:I="bold",T="italic";break;default:I="normal"}return this.ctx.attributes["font-weight"]=I,this.ctx.state["font-weight"]=I,this.ctx.attributes["font-style"]=T,this.ctx.state["font-style"]=T,this.ctx.fillText(x,d.x,d.y+y),this.ctx.closeGroup(),this.ctx.restore(),E}renderRectangle(f,p,m,x=1){this.ctx.save();const y=this.ctx.openGroup("rect");return this.ctx.attributes.fill=m||r.VexFlowConverter.style(p),this.ctx.attributes["fill-opacity"]=x,this.ctx.fillRect(f.x,f.y,f.width,f.height),this.ctx.restore(),this.ctx.attributes["fill-opacity"]=1,this.ctx.closeGroup(),y}renderLine(f,p,m="#FF0000FF",x=2,y){this.ctx.save();const d=this.ctx.openGroup("line",y);return this.ctx.beginPath(),this.ctx.moveTo(f.x,f.y),this.ctx.lineTo(p.x,p.y),this.ctx.attributes.stroke=m,this.ctx.lineWidth=x,this.ctx.stroke(),this.ctx.closeGroup(),this.ctx.restore(),d}renderCurve(f,p,m){let x;p&&m&&(x=`${m.getSVGId()}-slur`);const y=this.ctx.openGroup("curve",x);return this.ctx.beginPath(),this.ctx.moveTo(f[0].x,f[0].y),this.ctx.bezierCurveTo(f[1].x,f[1].y,f[2].x,f[2].y,f[3].x,f[3].y),this.ctx.lineTo(f[7].x,f[7].y),this.ctx.bezierCurveTo(f[6].x,f[6].y,f[5].x,f[5].y,f[4].x,f[4].y),this.ctx.lineTo(f[0].x,f[0].y),this.ctx.closePath(),this.ctx.fill(),this.ctx.closeGroup(),y}renderPath(f,p=!0,m){const x=this.ctx.openGroup("path",m);let y;this.ctx.beginPath();for(const d of f)y?this.ctx.lineTo(d.x,d.y):(this.ctx.moveTo(d.x,d.y),y=d);return this.ctx.closePath(),p?this.ctx.fill():this.ctx.stroke(),this.ctx.stroke(),this.ctx.closeGroup(),x}export(){const f=this.ctx.svg.cloneNode(!0),p=document.implementation.createDocumentType("svg","-//W3C//DTD SVG 1.1//EN","http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"),m=document.implementation.createDocument("http://www.w3.org/2000/svg","svg",p);m.replaceChild(f,m.documentElement);const x=new XMLSerializer().serializeToString(m),y=document.createElement("a");y.href="data:image/svg+xml; charset=utf8, "+encodeURIComponent(x.replace(/> \r<`)),y.download="opensheetmusicdisplay_download.svg",y.innerHTML=window.location.href+"/download",document.body.appendChild(y)}}g.SvgVexFlowBackend=h},1902(de,g,c){var l=this&&this.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(g,"__esModule",{value:!0}),g.VexFlowBackend=g.VexFlowBackends=void 0;var s=l(c(3206)).default.Flow;g.VexFlowBackends=class{},g.VexFlowBackend=class{getInnerElement(){return this.inner}getCanvas(){return this.canvas}getRenderElement(){let u=this.canvas;return this.getVexflowBackendType()===s.Renderer.Backends.CANVAS&&(u=this.inner),u}getRenderer(){return this.renderer}removeAllChildrenFromContainer(u){for(;u.children.length!==0;)u.removeChild(u.children.item(0))}removeFromContainer(u){const r=this.getRenderElement();for(let i=0;i1e-4;){const j=k.RealValue;if(j>=2)F.push("1/2"),k.Sub(new i.Fraction(2,1));else if(j>=1)F.push("w"),k.Sub(new i.Fraction(1,1));else if(j<1&&j>=.5){if(_&&j>.5)return["w"];F.push("h"),k.Sub(new i.Fraction(1,2))}else if(j<.5&&j>=.25){if(_&&j>.25)return["h"];F.push("q"),k.Sub(new i.Fraction(1,4))}else if(j<.25&&j>=.125){if(_&&j>.125)return["q"];F.push("8"),k.Sub(new i.Fraction(1,8))}else if(j<.125&&j>=.0625){if(_&&j>.0625)return["8"];F.push("16"),k.Sub(new i.Fraction(1,16))}else if(j<.0625&&j>=.03125){if(_&&j>.03125)return["16"];F.push("32"),k.Sub(new i.Fraction(1,32))}else if(j<.03125&&j>=.015625){if(_&&j>.015625)return["32"];F.push("64"),k.Sub(new i.Fraction(1,64))}else{if(_)return["64"];F.push("128"),k.Sub(new i.Fraction(1,128))}}return F}static pitch(D,_,F,k=void 0,j=void 0){let P=j;j===void 0&&(P=3),_&&j===void 0&&(P=0,F.ClefType===u.ClefEnum.F&&(P=2),F.ClefType===u.ClefEnum.C&&(P=2));const G=t.NoteEnum[D.FundamentalNote].toLowerCase(),Y=r.Pitch.accidentalVexflow(D.Accidental),X=D.Octave-F.OctaveOffset+P;let ie="";return k&&(ie=this.NoteHeadCode(k)),[G+"n/"+X+ie,Y,F]}static restToNotePitch(D,_){let F=D.Octave;switch(_){case u.ClefEnum.C:case u.ClefEnum.F:F+=2;case u.ClefEnum.G:}return new r.Pitch(D.FundamentalNote,F,h.AccidentalEnum.NONE)}static NoteHeadCode(D){const _=D.Filled?"2":"1";switch(D.Shape){case E.NoteHeadShape.NORMAL:case E.NoteHeadShape.NONE:return"";case E.NoteHeadShape.DIAMOND:return"/D"+_;case E.NoteHeadShape.TRIANGLE:return"/T"+_;case E.NoteHeadShape.TRIANGLE_INVERTED:return"/TI";case E.NoteHeadShape.X:return"/X"+_;case E.NoteHeadShape.CIRCLEX:return"/X3";case E.NoteHeadShape.RECTANGLE:return"/R"+_;case E.NoteHeadShape.SQUARE:return"/S"+_;case E.NoteHeadShape.SLASH:default:return""}}static GhostNotes(D){const _=[],F=v.durations(D,!1);for(const k of F)_.push(new s.GhostNote({duration:k}));return _}static StaveNote(D){var H,W,K,q,te,se,ue,fe,xe,ve,Se;D.sortForVexflow();const _=D.notes,F=D.parentStaffEntry.parentMeasure.parentSourceMeasure.Rules,k=_[0];let j=[];const P=[],G=k.graphicalNoteLength,Y=k.sourceNote.NoteTuplet!==void 0;let X,ie=v.durations(G,Y)[0];k.sourceNote.TypeLength!==void 0&&k.sourceNote.TypeLength!==G&&k.sourceNote.TypeLength.RealValue!==0&&(ie=v.durations(k.sourceNote.TypeLength,Y)[0],k.numberOfDots=k.sourceNote.DotsXml);let oe,$,Q=k.numberOfDots,ne=!1,ee=0,N=!1;for(const ye of _){if(Q=1&&_e.length-1>=Pe+1&&(Te=(se=(te=_e[Pe-1])==null?void 0:te.graphicalVoiceEntries[0])==null?void 0:se.parentVoiceEntry,Le=(fe=(ue=_e[Pe+1])==null?void 0:ue.graphicalVoiceEntries[0])==null?void 0:fe.parentVoiceEntry,Te&&Le)){const Ae=Te.Notes[0],Ce=Le.Notes[0];if((xe=Ae.NoteBeam)!=null&&xe.Notes.includes(Ce)){const Be=Te.Notes.last().Pitch,Ie=ye.Clef();j=[v.pitch(v.restToNotePitch(Be.getTransposedPitch(-2),Ie.ClefType),!1,Ie)[0]]}}}}if((ye.sourceNote.IsWholeMeasureRest||G.RealValue===ye.sourceNote.SourceMeasure.ActiveTimeSignature.RealValue)&&(j=["d/5"],D.parentStaffEntry.parentMeasure.ParentStaff.StafflineCount===1&&(j=["b/4"]),ie="w",Q=0,ne=!0,ee=F.WholeRestXShiftVexflow*L.unitInPixels),ye.sourceNote.ParentStaff.Voices.length>1){const Me=ye.parentVoiceEntry.parentStaffEntry.graphicalVoiceEntries,_e=ye.parentVoiceEntry.parentVoiceEntry.ParentVoice.VoiceId;let Te,Le;for(const Pe of Me)for(const Ae of Pe.notes){if(Ae===ye||Ae.sourceNote.isRest()||!Ae.sourceNote.PrintObject)continue;const Ce=Ae.parentVoiceEntry.parentVoiceEntry.WantedStemDirection,Be=_e===1||_e===5,Ie=Be?1:-1,Fe=Ae.sourceNote.Pitch.getHalfTone();(!Te||Ie===1&&Fe>Te||Ie===-1&&Fe0){let Pe=3;const Ae=ye.Clef();switch(Ae.ClefType){case u.ClefEnum.F:Pe=5;break;case u.ClefEnum.C:Pe=4}oe=r.Pitch.fromHalftone(Te),j=[v.pitch(oe,!0,Ae,void 0,Pe)[0]]}}break}const be=ye.vfpitch;j.push(be[0]),P.push(be[1]),X||(X=v.Clef(be[2]).type)}for(let ye=0,be=Q;ye0&&F.RenderLyrics&&F.LyricsUseXPaddingForLongLyrics){const _e=D.parentStaffEntry.parentMeasure,Te=[];for(let Ae=_e.staffEntries.indexOf(D.parentStaffEntry)+1;Ae<_e.staffEntries.length;Ae++){const Ce=_e.staffEntries[Ae];Ce.graphicalVoiceEntries[0]&&Te.push(Ce)}let Le,Pe=D.parentStaffEntry.relInMeasureTimestamp.clone();for(const Ae of Te){const Ce=Ae.relInMeasureTimestamp.clone();if(Le=i.Fraction.minus(Ce,D.parentVoiceEntry.Timestamp),Le.RealValue>.25){be=!1;break}if(Ae.LyricsEntries.length>0)break;Me+=32*i.Fraction.minus(Ce,Pe).RealValue,Pe=Ce}}if(F.RenderLyrics&&F.LyricsUseXPaddingForLongLyrics&&ye.length>0&&be){let _e=!1,Te=0;for(const Pe of _)if(Pe.sourceNote.Length.RealValue<=.125){_e=!0;break}let Le=!1;for(const Pe of ye){const Ae=F.LyricsXPaddingWidthThreshold;let Ce=Pe.GraphicalLabel.PositionAndShape.Size.width;if(Pe.hasDashFromLyricWord()&&(Ce+=.5),Ce>Ae){Te+=Ce-Ae;const Be=D.parentStaffEntry,Ie=Be.parentMeasure.staffEntries,Fe=Ie.indexOf(Be)===Ie.length-1,Ke=Fe&&Pe.hasDashFromLyricWord();Fe&&(Me+=Ke?F.LyricsXPaddingReductionForLastNoteInMeasureCrossMeasureMidWord:F.LyricsXPaddingReductionForLastNoteInMeasure),_e||(Me+=F.LyricsXPaddingReductionForLongNotes),!F.LyricsXPaddingForLastNoteInMeasure&&Fe||Ce>Ae+Me&&(Le=!0,Te-=Me);break}}Le&&($.paddingRight=10*F.LyricsXPaddingFactorForLongLyrics*Te)}}const U=D.notes[0].lineShift;if(U!==0&&($.getKeyProps()[0].line+=U),_.length>1)for(let ye=0;ye<_.length;ye++)((Se=_[ye].sourceNote.Notehead)==null?void 0:Se.Shape)===E.NoteHeadShape.SLASH&&($.note_heads[ye].note_type="s");if($.getKeyProps().forEach(({line:ye},be)=>D.notes[be].staffLine=ye),(F.LedgerLineWidth||F.LedgerLineStrokeStyle)&&($.ledgerLineStyle||($.ledgerLineStyle={}),F.LedgerLineWidth&&($.ledgerLineStyle.lineWidth=F.LedgerLineWidth),F.LedgerLineStrokeStyle&&($.ledgerLineStyle.strokeStyle=F.LedgerLineStrokeStyle)),F.ColoringEnabled){const ye=F.DefaultColorStem;let be=D.parentVoiceEntry.StemColor;!be&&ye&&(be=ye);const Me={fillStyle:be,strokeStyle:be};be&&($.setStemStyle(Me),$.flag&&F.ColorFlags&&$.setFlagStyle(Me))}if($.x_shift=ee,D.parentVoiceEntry.IsGrace&&D.notes[0].sourceNote.NoteBeam&&(D.parentVoiceEntry.WantedStemDirection=D.notes[0].sourceNote.NoteBeam.Notes[0].ParentVoiceEntry.WantedStemDirection),D.parentVoiceEntry)switch(D.parentVoiceEntry.WantedStemDirection){case d.StemDirectionType.Up:$.setStemDirection(s.Stem.UP),D.parentVoiceEntry.StemDirection=d.StemDirectionType.Up;break;case d.StemDirectionType.Down:$.setStemDirection(s.Stem.DOWN),D.parentVoiceEntry.StemDirection=d.StemDirectionType.Down}for(let ye=0,be=_.length;ye0){const _e=new s.Tremolo(Me);_e.extra_stroke_scale=F.TremoloStrokeScale,_e.y_spacing_scale=F.TremoloYSpacingScale,$.addModifier(ye,_e)}}if(O.Length.RealValue===.25&&O.Notehead&&O.Notehead.Filled===!1){const ye=$.getKeyProps();for(let be=0;be");const Y=_.sourceNote.NoteSlurs;for(const X of Y)X.StartNote===_.sourceNote&&(X.PlacementXml===A.PlacementEnum.Above?j.setYShift(10*-F.SlurStartArticulationYOffsetOfArticulation):X.PlacementXml===A.PlacementEnum.Below&&j.setYShift(10*F.SlurStartArticulationYOffsetOfArticulation));j.render_options={...j.render_options,extra_left_px:0,extra_right_px:0},j.getWidth&&(j.getWidth=function(){return 0});break}case d.ArticulationEnum.breathmark:j=new s.Articulation("abr"),k.placement===A.PlacementEnum.Above&&(P=s.Modifier.Position.ABOVE),j.breathMarkDistance=F.BreathMarkDistance;break;case d.ArticulationEnum.downbow:j=new s.Articulation("am"),k.placement===void 0&&(P=s.Modifier.Position.ABOVE,k.placement=A.PlacementEnum.Above);break;case d.ArticulationEnum.fermata:j=new s.Articulation("a@a"),P=s.Modifier.Position.ABOVE,k.placement=A.PlacementEnum.Above;break;case d.ArticulationEnum.marcatodown:j=new s.Articulation("a|");break;case d.ArticulationEnum.marcatoup:j=new s.Articulation("a^"),P=s.Modifier.Position.ABOVE;break;case d.ArticulationEnum.invertedfermata:{const Y=_.sourceNote.ParentVoiceEntry;if(Y!==_.sourceNote.ParentVoiceEntry.ParentSourceStaffEntry.VoiceEntries.last()){Y.Articulations=Y.Articulations.slice(Y.Articulations.indexOf(k)),Y.ParentSourceStaffEntry.VoiceEntries.last().Articulations.push(k);continue}j=new s.Articulation("a@u"),P=s.Modifier.Position.BELOW,k.placement=A.PlacementEnum.Below;break}case d.ArticulationEnum.lefthandpizzicato:j=new s.Articulation("a+");break;case d.ArticulationEnum.naturalharmonic:j=new s.Articulation("ah");break;case d.ArticulationEnum.snappizzicato:j=new s.Articulation("ao");break;case d.ArticulationEnum.staccatissimo:j=new s.Articulation("av");break;case d.ArticulationEnum.staccato:j=new s.Articulation("a.");break;case d.ArticulationEnum.tenuto:j=new s.Articulation("a-");break;case d.ArticulationEnum.upbow:j=new s.Articulation("a|"),k.placement===void 0&&(P=s.Modifier.Position.ABOVE,k.placement=A.PlacementEnum.Above);break;case d.ArticulationEnum.strongaccent:j=new s.Articulation("a^")}j&&(j.setPosition(P),D.addModifier(0,j))}}static generateOrnaments(D,_){let F,k=s.Modifier.Position.ABOVE;switch(_.placement===A.PlacementEnum.Below&&(k=s.Modifier.Position.BELOW),_.GetOrnament){case M.OrnamentEnum.DelayedInvertedTurn:F=new s.Ornament("turn_inverted"),F.setDelayed(!0);break;case M.OrnamentEnum.DelayedTurn:F=new s.Ornament("turn"),F.setDelayed(!0);break;case M.OrnamentEnum.InvertedMordent:F=new s.Ornament("mordent"),F.setDelayed(!1);break;case M.OrnamentEnum.InvertedTurn:F=new s.Ornament("turn_inverted"),F.setDelayed(!1);break;case M.OrnamentEnum.Mordent:F=new s.Ornament("mordent_inverted"),F.setDelayed(!1);break;case M.OrnamentEnum.Trill:F=new s.Ornament("tr"),F.setDelayed(!1);break;case M.OrnamentEnum.Turn:F=new s.Ornament("turn"),F.setDelayed(!1);break;default:return void y.default.warn("unhandled OrnamentEnum type: "+_.GetOrnament)}F&&(_.AccidentalBelow!==h.AccidentalEnum.NONE&&F.setLowerAccidental(r.Pitch.accidentalVexflow(_.AccidentalBelow)),_.AccidentalAbove!==h.AccidentalEnum.NONE&&F.setUpperAccidental(r.Pitch.accidentalVexflow(_.AccidentalAbove)),F.setPosition(k),D.addModifier(0,F))}static StrokeTypeFromArpeggioType(D){switch(D){case I.ArpeggioType.ARPEGGIO_DIRECTIONLESS:return s.Stroke.Type.ARPEGGIO_DIRECTIONLESS;case I.ArpeggioType.BRUSH_DOWN:return s.Stroke.Type.BRUSH_UP;case I.ArpeggioType.BRUSH_UP:return s.Stroke.Type.BRUSH_DOWN;case I.ArpeggioType.RASQUEDO_DOWN:return s.Stroke.Type.RASQUEDO_UP;case I.ArpeggioType.RASQUEDO_UP:return s.Stroke.Type.RASQUEDO_DOWN;case I.ArpeggioType.ROLL_DOWN:return s.Stroke.Type.ROLL_UP;case I.ArpeggioType.ROLL_UP:return s.Stroke.Type.ROLL_DOWN;default:return s.Stroke.Type.ARPEGGIO_DIRECTIONLESS}}static CreateTabNote(D){var $;const _=[],F=D.notes.reverse(),k=[],j=D.notes[0].graphicalNoteLength,P=D.notes[0].sourceNote.NoteTuplet!==void 0;let G=v.durations(j,P)[0],Y=0;const X=D.parentStaffEntry.parentMeasure.parentSourceMeasure.Rules;let ie=!1;for(const Q of D.notes){const ne=Q.sourceNote;let ee={str:ne.StringNumberTab,fret:ne.FretNumber};Q.sourceNote instanceof T.TabNote||(y.default.info(`invalid tab note: ${Q.sourceNote.Pitch.ToString()} in measure ${D.parentStaffEntry.parentMeasure.MeasureNumber}, likely missing XML string+fret number.`),ee={str:1,fret:0}),X.TabUseXNoteheadShapeForTabNote&&(($=Q.sourceNote.Notehead)==null?void 0:$.Shape)===E.NoteHeadShape.X&&(ee.fret="x",ie=!0),_.push(ee),ne.BendArray&&ne.BendArray.forEach(function(N){let R;const O=N.bendalter-ee.fret;R=O>1?"Full":O===1?"1/2":"1/4",N.direction==="up"?k.push({type:s.Bend.UP,text:R,width:10}):k.push({type:s.Bend.DOWN,text:R,width:10})}),Ythis.vfnoteIndex&&t[this.vfnoteIndex]?h.note_heads[this.vfnoteIndex]:{line:0}}Clef(){return this.clef}getSVGId(){if(this.vfnote)return this.vfnote[0].getAttribute("id")}setVisible(n,h={}){var M,E;const t=h.applyToBeams??!0,f=h.applyToLedgerLines??!0,p=h.applyToNotehead??!0,m=h.applyToSlurs??!0,x=h.applyToStem??!0,y=h.applyToTies??!0,d="visibility",S=n?"visible":"hidden";if(p&&((M=this.getSVGGElement())==null||M.setAttribute(d,S)),x&&((E=this.getStemSVG())==null||E.setAttribute(d,S)),t)for(const L of this.getBeamSVGs())L==null||L.setAttribute(d,S);if(f)for(const L of this.getLedgerLineSVGs())L==null||L.setAttribute(d,S);if(y)for(const L of this.getTieSVGs())L==null||L.setAttribute(d,S);if(m)for(const L of this.getSlurSVGs())L==null||L.setAttribute(d,S)}getSVGGElement(){if(this.vfnote)return this.vfnote[0].getAttribute("el")}getStemSVG(){const n=document.getElementById("vf-"+this.getSVGId()+"-stem");return(n==null?void 0:n.children.length)>0?n.children[0]:n}getBeamSVGs(){const n=[];for(let h=0;;h++){const t=document.getElementById(`vf-${this.getSVGId()}-beam${h}`);if(!t)break;n.push(t)}return n}getLedgerLineSVGs(){const n=[],h=`vf-${this.getSVGId()}ledgers`,t=document.getElementById(h);if(!t)return[];for(const f of t.childNodes)n.push(f);return n}getTieSVGs(){const n=[],h=document.querySelectorAll(`[id='vf-${this.getSVGId()}-tie']`);for(const t of h)n.push(t);return n}getSlurSVGs(){const n=[],h=document.querySelectorAll(`[id='vf-${this.getSVGId()}-slur']`);for(const t of h)n.push(t);return n}getNoteheadSVGs(){var t;const n=this.getVFNoteSVG(),h=[];if((t=n==null?void 0:n.children)!=null&&t.length)for(const f of n.children)f.classList.contains("vf-notehead")&&h.push(f);return h}getFlagSVG(){var h;const n=this.getVFNoteSVG();if((h=n==null?void 0:n.children)!=null&&h.length){for(const t of n.children)if(t.classList.contains("vf-flag"))return t}}getVFNoteSVG(){if(this.parentVoiceEntry.parentStaffEntry.parentMeasure.isMultiRestMeasure())return this.parentVoiceEntry.parentStaffEntry.parentMeasure.multiRestElement;const n=this.getSVGGElement();if(n){for(const h of n.children)if(h.classList.contains("vf-note"))return h}}getModifierSVGs(){const n=this.getSVGGElement(),h=[];if(!(n!=null&&n.children))return h;if(n.children.length)for(const t of n.children)t.classList.contains("vf-modifiers")&&h.push(t);return h}setColor(n,h={}){var T,A;const t=h.applyToBeams??!1,f=h.applyToFlag??!0,p=h.applyToLedgerLines??!1,m=h.applyToLyrics??!1,x=h.applyToModifiers??!0,y=h.applyToNoteheads??!0,d=h.applyToSlurs??!1,S=h.applyToStem??!0,M=h.applyToTies??!1,E=h.applyToMultiRestMeasure??!0,L=h.applyToMultiRestMeasureNumber??!0,I=h.applyToMultiRestMeasureRestBar??!0;if(t){const v=this.getBeamSVGs();for(const B of v)for(const D of B.children)D.setAttribute("fill",n)}if(f){const v=this.getFlagSVG();if(v)for(const B of v.children)B.setAttribute("fill",n)}if(p){const v=this.getLedgerLineSVGs();for(const B of v)B.setAttribute("stroke",n)}if(m){const v=this.getLyricsSVGs();for(const B of v)for(const D of B.children)D.setAttribute("stroke",n),D.setAttribute("fill",n)}if(E&&this.parentVoiceEntry.parentStaffEntry.parentMeasure instanceof r.VexFlowMultiRestMeasure){const v=this.parentVoiceEntry.parentStaffEntry.parentMeasure.multiRestElementSVG;if((T=v==null?void 0:v.children)!=null&&T.length)for(const B of v.children)if((A=B.children)!=null&&A.length){if(L)for(const D of B.children)D.setAttribute("fill",n)}else I&&B.setAttribute("fill",n)}if(x){const v=this.getModifierSVGs();for(const B of v)for(const D of B.children)D.setAttribute("fill",n)}if(y){const v=this.getNoteheadSVGs();for(const B of v)for(const D of B.children)D.setAttribute("fill",n)}if(d){const v=this.getSlurSVGs();for(const B of v)for(const D of B.children)D.setAttribute("fill",n)}if(S){const v=this.getStemSVG();v&&v.setAttribute("stroke",n)}if(M){const v=this.getTieSVGs();for(const B of v)for(const D of B.children)D.setAttribute("fill",n)}}}g.VexFlowGraphicalNote=i},3753(de,g,c){var l=this&&this.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(g,"__esModule",{value:!0}),g.VexFlowGraphicalSymbolFactory=void 0;var s=l(c(3206)).default.Flow;const u=c(4332),r=c(5246),i=c(6670),o=c(437),n=c(9635),h=c(6659),t=c(4134),f=c(6014),p=c(6173),m=c(5866),x=c(3849),y=c(6362);g.VexFlowGraphicalSymbolFactory=class{createMusicSystem(d,S){return new u.VexFlowMusicSystem(d,S)}createStaffLine(d,S){return new m.VexFlowStaffLine(d,S)}createGraphicalMeasure(d,S,M=!1){return new r.VexFlowMeasure(S,d,void 0)}createMultiRestMeasure(d,S,M){return new x.VexFlowMultiRestMeasure(S,d,M)}createTabStaffMeasure(d,S){return new p.VexFlowTabMeasure(S,d)}createExtraGraphicalMeasure(d){const S=new r.VexFlowMeasure(d.ParentStaff,void 0,d);return S.IsExtraGraphicalMeasure=!0,S.ExtraGraphicalMeasurePreviousMeasure=d.Measures.last(),S}createStaffEntry(d,S){return new i.VexFlowStaffEntry(S,d,void 0)}createVoiceEntry(d,S){return new t.VexFlowVoiceEntry(d,S)}createNote(d,S,M,E=o.OctaveEnum.NONE,L,I=void 0){return new n.VexFlowGraphicalNote(d,S,M,E,L,I)}createGraceNote(d,S,M,E,L=o.OctaveEnum.NONE){return new n.VexFlowGraphicalNote(d,S,M,L,E)}addGraphicalAccidental(d,S){d.setAccidental(S)}addFermataAtTiedEndNote(d,S){}createInStaffClef(d,S){const M=d,E=f.VexFlowConverter.Clef(S,"small");M.vfClefBefore=new s.ClefNote(E.type,E.size,E.annotation)}createChordSymbols(d,S,M,E){const L=S.parentMeasure.parentSourceMeasure.Rules;let I=0;const T=L.ChordSymbolXSpacing;for(const A of d.ChordContainers){if(!A)continue;let v=S.PositionAndShape;S.graphicalVoiceEntries.length===1&&S.graphicalVoiceEntries[0].notes.length===1&&S.graphicalVoiceEntries[0].notes[0].sourceNote.isWholeRest()&&(v=S.parentMeasure.PositionAndShape,I+=S.parentMeasure.beginInstructionsWidth,I+=L.ChordSymbolWholeMeasureRestXOffset);const B=new h.GraphicalChordSymbolContainer(A,v,L.ChordSymbolTextHeight,M,E,L),D=B.GetChordSymbolContainer.Placement,_=B.GraphicalLabel;D===y.PlacementEnum.Below?_.PositionAndShape.RelativePosition.y=L.StaffHeight+L.ChordSymbolYOffset:_.PositionAndShape.RelativePosition.y-=L.ChordSymbolYOffset,_.setLabelPositionAndShapeBorders();let F=0;_.PositionAndShape.Size.width=0&&(F.parentVoiceEntry.PositionAndShape.RelativePosition.y=(_.StringNumberTab-1)*this.rules.TabStaffInterlineHeightForBboxes)}else for(const v of this.getVoicesWithinMeasure())for(const B of v.VoiceEntries)for(const D of B.Notes){if(D.isRest())continue;const _=this.rules.GNote(D);if(!(_!=null&&_.vfnote))return;const F=_.vfnote[0];let k=0;_.parentVoiceEntry.parentVoiceEntry.StemDirection===x.StemDirectionType.Up&&_.vfnote[0].getDuration()!=="w"?k+=3.5:k+=.5,k+=-_.notehead(F).line+_.parentVoiceEntry.notes.last().notehead().line,_.PositionAndShape.RelativePosition.y=k}}getVoicesWithinMeasure(){const v=[];for(const B of this.staffEntries)for(const D of B.graphicalVoiceEntries)v.indexOf(D.parentVoiceEntry.ParentVoice)===-1&&v.push(D.parentVoiceEntry.ParentVoice);return v}getGraphicalVoiceEntriesPerVoice(v){const B=[];for(const D of this.staffEntries)for(const _ of D.graphicalVoiceEntries)_.parentVoiceEntry.ParentVoice===v&&B.push(_);return B}getRestFilledVexFlowStaveNotesPerVoice(v){let B,D=this.getGraphicalVoiceEntriesPerVoice(v);for(let k=0;k0){t.default.trace(`Ghost Found in between (measure ${this.MeasureNumber})`);const X=this.createGhostGves(Y);D.splice(k,0,...X),k+=X.length}}else{const Y=d.Fraction.minus(P,this.parentSourceMeasure.AbsoluteTimestamp);if(Y.RealValue>0){t.default.trace(`Ghost Found at start (measure ${this.MeasureNumber})`);const X=this.createGhostGves(Y);D.splice(0,0,...X),k+=X.length}}B=G}const _=d.Fraction.plus(this.parentSourceMeasure.AbsoluteTimestamp,this.parentSourceMeasure.Duration),F=d.Fraction.minus(_,B);if(F.RealValue>0){t.default.trace(`Ghost Found at end (measure ${this.MeasureNumber})`);const k=this.createGhostGves(F);D=D.concat(k)}return D}createGhostGves(v){const B=o.VexFlowConverter.GhostNotes(v),D=[];for(const _ of B){const F=new y.VexFlowVoiceEntry(void 0,void 0,this.rules);F.vfStaveNote=_,D.push(F)}return D}handleBeam(v,B){const D=v.sourceNote.ParentVoiceEntry.ParentVoice.VoiceId;let _,F=this.beams[D];F||(F=this.beams[D]=[]);for(const j of F)j[0]===B&&(_=j);_||(_=[B,[]],F.push(_));const k=v.parentVoiceEntry;_[1].indexOf(k)<0&&_[1].push(k)}handleTuplet(v,B){const D=v.sourceNote.ParentVoiceEntry.ParentVoice.VoiceId;B=v.sourceNote.NoteTuplet;let _,F=this.tuplets[D];F||(F=this.tuplets[D]=[]);for(const j of F)j[0]===B&&(_=j);_||(_=[B,[]],F.push(_));const k=v.parentVoiceEntry;_[1].indexOf(k)<0&&_[1].push(k)}finalizeBeams(){var B;if(this.vfbeams={},this.isTabMeasure&&!this.rules.TabBeamsRendered)return;const v=[];for(const D in this.beams)if(this.beams.hasOwnProperty(D)){let _=this.vfbeams[D];_||(_=this.vfbeams[D]=[]);for(const F of this.beams[D]){let k=!1;for(const $ of F[0].Notes)if($.Length.RealValue>=new d.Fraction(1,4).RealValue&&(!$.TypeLength||$.TypeLength.RealValue>.125)){k=!0;break}if(k){t.default.debug("Beam between note >= quarter, likely tremolo, currently unsupported. continuing.");continue}const j=[],P=F[0],G=F[1];let Y=!0;for(const $ of G)$.parentVoiceEntry.ParentVoice===P.Notes[0].ParentVoiceEntry.ParentVoice&&(Y=$.parentVoiceEntry.WantedStemDirection===x.StemDirectionType.Undefined);let X,ie=!1;const oe=[];for(const $ of G){const Q=$.vfStaveNote;Q&&(j.push(Q),v.push(Q)),$.parentVoiceEntry.IsGrace&&(ie=!0),$.parentVoiceEntry.StemColor&&this.rules.ColoringEnabled&&oe.push($.parentVoiceEntry.StemColor)}if(j.length>1){const $=new s.Beam(j,Y);if(((B=P.SecondaryBreakIndices)==null?void 0:B.length)>0&&$.breakSecondaryAt(P.SecondaryBreakIndices),ie&&($.render_options.beam_width=3,$.render_options.partial_beam_length=4),oe.length>=2&&this.rules.ColorBeams){X=oe[0];for(const Q of oe)if(Q!==X){X=void 0;break}$.setStyle({fillStyle:X,strokeStyle:X})}this.rules.FlatBeams&&($.render_options.flat_beams=!0,$.render_options.flat_beam_offset=this.rules.FlatBeamOffset,$.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),_.push($)}else t.default.debug("Warning! Beam with no notes!")}}this.rules.AutoBeamNotes&&this.autoBeamNotes(v)}autoBeamNotes(v){if(!this.rules.AutoBeamTabs&&this.isTabMeasure)return;let B,D=60,_=[],F=[],k=[];this.autoTupletVfBeams=[];const j=[];this.autoVfBeams=[];let P=this.parentSourceMeasure.ActiveTimeSignature;P||(P=this.parentSourceMeasure.Duration);for(const X of this.staffEntries)for(const ie of X.graphicalVoiceEntries){const oe=ie.vfStaveNote,$=ie.notes[0],Q={vfStaveNote:oe,sourceNote:$.sourceNote},ne=X.relInMeasureTimestamp.isOnBeat(P),ee=F.length>=2,N=$.sourceNote.Length.RealValue-new d.Fraction(1,4).RealValue>-d.Fraction.FloatInaccuracyTolerance,R=ie.parentVoiceEntry.IsGrace||N||v.contains(oe);if(R||ne){if(ee){for(const U of F)_.push(U);j.push(_.slice()),_=[]}if(F=[],R)continue}const O=ie.notes[0].sourceNote.NoteTuplet;if(O){let U=!1;for(const H of O.Notes){for(const W of H)if(W.NoteTypeXml>=L.NoteType.QUARTER||W.ParentVoiceEntry.IsGrace||W.isRest()&&!this.rules.AutoBeamOptions.beam_rests){U=!0;break}if(U)break}if(B){if(B!==O){if(k.length>1){const H=[];for(const q of k)H.push(q.vfStaveNote);const W=new s.Beam(H,!0);this.rules.FlatBeams&&(W.render_options.flat_beams=!0,W.render_options.flat_beam_offset=this.rules.FlatBeamOffset,W.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),this.autoTupletVfBeams.push(W);const K=new n.Beam(D++);K.AutoGenerated=!0;for(const q of k)K.addNoteToBeam(q.sourceNote)}k=[],B=O}}else B=O;U||k.push(Q);continue}B=void 0,F.push(Q)}if(k.length>=2){const X=[];for(const $ of k)X.push($.vfStaveNote);const ie=new s.Beam(X,!0);this.rules.FlatBeams&&(ie.render_options.flat_beams=!0,ie.render_options.flat_beam_offset=this.rules.FlatBeamOffset,ie.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),this.autoTupletVfBeams.push(ie);const oe=new n.Beam(D++);oe.AutoGenerated=!0;for(const $ of k)oe.addNoteToBeam($.sourceNote)}if(F.length>=2){for(const X of F)_.push(X);j.push(_)}const G=this.rules.AutoBeamOptions,Y={beam_middle_only:G.beam_middle_rests_only,beam_rests:G.beam_rests,maintain_stem_directions:G.maintain_stem_directions};if(G.groups&&G.groups.length){const X=[];for(const ie of G.groups)X.push(new s.Fraction(ie[0],ie[1]));Y.groups=X}for(const X of j){const ie=[];for(const $ of X)ie.push($.vfStaveNote);const oe=s.Beam.generateBeams(ie,Y);for(const $ of oe)this.rules.FlatBeams&&($.render_options.flat_beams=!0,$.render_options.flat_beam_offset=this.rules.FlatBeamOffset,$.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),this.autoVfBeams.push($)}}finalizeTuplets(){this.vftuplets={};for(const v in this.tuplets)if(this.tuplets.hasOwnProperty(v)){let B=this.vftuplets[v];B||(B=this.vftuplets[v]=[]);for(const D of this.tuplets[v]){const _=[],F=D[1];for(const k of F)_.push(k.vfStaveNote);if(_.length>1){const k=D[0],j=k.Notes[0][0].NormalNotes,P=k.shouldBeBracketed(this.rules.TupletsBracketedUseXMLValue,this.rules.TupletsBracketed,this.rules.TripletsBracketed,this.isTabMeasure,this.rules.TabTupletsBracketed);let G=s.Tuplet.LOCATION_TOP;k.tupletLabelNumberPlacement===E.PlacementEnum.Below&&(G=s.Tuplet.LOCATION_BOTTOM);let Y=0;if(this.isTabMeasure&&(Y=10*this.rules.TabTupletYOffsetBottom,G===s.Tuplet.LOCATION_TOP)){Y=-10*this.rules.TabTupletYOffsetTop;const ie=k.Notes[0][0];ie!=null&&ie.hasTabEffects()&&(Y-=10*this.rules.TabTupletYOffsetEffects)}const X=new s.Tuplet(_,{bracketed:P,location:G,notes_occupied:j,num_notes:k.TupletLabelNumber,ratioed:k.Ratioed,y_offset:Y});B.push(X)}else t.default.debug("Warning! Tuplet with no notes! Trying to ignore, but this is a serious problem.")}}}layoutStaffEntry(v){}graphicalMeasureCreatedCalculations(){let v,B=[];const D=[];for(const F of this.staffEntries){v=!1,B=[];for(const k of F.graphicalVoiceEntries)if(k.parentVoiceEntry.IsGrace)B.push(k),D.push(k),v||(v=k.parentVoiceEntry.GraceSlur);else if(k.vfStaveNote=o.VexFlowConverter.StaveNote(k),B.length>0){const j=[];for(let Y=0;Y0&&(X.GraceSlash=!1);const ie=o.VexFlowConverter.StaveNote(X);X.vfStaveNote=ie,j.push(ie)}const P=new s.GraceNoteGroup(j,v);let G=this.rules.GraceNoteGroupXMargin;j.length>1&&(G/=3),P.spacing=10*G,k.vfStaveNote.addModifier(0,P),B=[]}}if(B.length>0)for(const F of B)F.vfStaveNote=o.VexFlowConverter.StaveNote(F),F.parentVoiceEntry.GraceAfterMainNote=!0;this.finalizeBeams(),this.finalizeTuplets();const _=this.getVoicesWithinMeasure();if(this.rules.RenderFingerings)for(const F of this.staffEntries)F.setModifierXOffsets();for(const F of _){if(!F)continue;this.vfVoices[F.VoiceId]=new s.Voice({beat_value:this.parentSourceMeasure.ActiveTimeSignature.Denominator,num_beats:this.parentSourceMeasure.ActiveTimeSignature.Numerator,resolution:s.RESOLUTION}).setMode(s.Voice.Mode.SOFT);const k=this.getRestFilledVexFlowStaveNotesPerVoice(F);for(const j of k){if(j.parentVoiceEntry&&j.parentVoiceEntry.IsGrace&&!j.parentVoiceEntry.GraceAfterMainNote)continue;const P=j;if(P.vfStaveNote.getTicks().denominator===0&&(P.vfStaveNote.getTicks().denominator=1),j.notes.length>0&&j.notes[0].sourceNote&&j.notes[0].sourceNote.NoteTuplet){const Y=j.notes[0].graphicalNoteLength,X=P.vfStaveNote.getTicks();X.numerator=Y.Numerator*s.RESOLUTION,X.denominator=Y.Denominator,X.simplify()}const G=P.parentStaffEntry;if(G&&G.vfClefBefore){if(j.notes[0]&&!j.notes[0].sourceNote.PrintObject){const ie=this.rules.DefaultColorMusic||"#000000";G.vfClefBefore.setStyle({fillStyle:ie,strokeStyle:ie})}const Y=new h([G.vfClefBefore]),X=P.vfStaveNote;X&&typeof X.addModifier=="function"&&X.addModifier(0,Y)}j.notes.length!==0&&j.notes[0]&&j.notes[0].sourceNote.PrintObject?(j.parentVoiceEntry&&this.rules.RenderFingerings&&(this.rules.FingeringPosition!==E.PlacementEnum.Left&&this.rules.FingeringPosition!==E.PlacementEnum.Right||this.createFingerings(j),this.createStringNumber(j)),this.createArpeggio(j),this.vfVoices[F.VoiceId].addTickable(P.vfStaveNote)):this.vfVoices[F.VoiceId].addTickable(P.vfStaveNote)}}this.setStemDirectionFromVexFlow();for(const F of D)this.createFingerings(F),this.createStringNumber(F),this.createArpeggio(F);this.createArticulations(),this.createOrnaments()}createArpeggio(v){if(v.parentVoiceEntry&&v.parentVoiceEntry.Arpeggio){const B=v.parentVoiceEntry.Arpeggio;if(v.notes&&v.notes.length>1){const D=o.VexFlowConverter.StrokeTypeFromArpeggioType(B.type),_=new s.Stroke(D,{all_voices:this.rules.ArpeggiosGoAcrossVoices});this.rules.RenderArpeggios&&v.vfStaveNote.addStroke(0,_)}else t.default.debug(`[OSMD] arpeggio in measure ${this.MeasureNumber} could not be drawn. voice entry had less than two notes, arpeggio is likely between voice entries, not currently supported in Vexflow.`)}}setStemDirectionFromVexFlow(){for(const v of this.staffEntries)for(const B of v.graphicalVoiceEntries)for(const D of B.notes){const _=D.vfnote;if(_&&_[0])switch(_[0].getStemDirection()){case s.Stem.UP:B.parentVoiceEntry.StemDirection=x.StemDirectionType.Up;break;case s.Stem.DOWN:B.parentVoiceEntry.StemDirection=x.StemDirectionType.Down}}}createArticulations(){for(let v=0,B=this.staffEntries.length;vD){let k=0;for(const j of v.notes)if(j.sourceNote.Fingering)k++;else{if(k>_.length-1)break;j.sourceNote.Fingering=_[k],k++}}let F=-1;for(const k of v.notes){const j=k.sourceNote.Fingering;if(!j){F++;continue}F++;let P=this.rules.FingeringPosition;this.rules.FingeringPositionGrace===E.PlacementEnum.AboveOrBelow&&(this.isUpperStaffOfInstrument()?P=E.PlacementEnum.Above:this.isLowerStaffOfInstrument()&&(P=E.PlacementEnum.Below)),j.placement!==E.PlacementEnum.NotYetDefined&&(P=j.placement);let G,Y=this.rules.FingeringOffsetX;switch(P){default:case E.PlacementEnum.Left:G=s.StaveModifier.Position.LEFT,Y-=k.baseFingeringXOffset*f.unitInPixels;break;case E.PlacementEnum.Right:G=s.StaveModifier.Position.RIGHT,Y+=k.baseFingeringXOffset*f.unitInPixels;break;case E.PlacementEnum.Above:G=s.StaveModifier.Position.ABOVE;break;case E.PlacementEnum.Below:G=s.StaveModifier.Position.BELOW;break;case E.PlacementEnum.NotYetDefined:const ie=v.parentStaffEntry.sourceStaffEntry.ParentStaff;v.notes.length>1||v.parentStaffEntry.graphicalVoiceEntries.length>1?G=s.StaveModifier.Position.LEFT:ie.idInMusicSheet===0?(G=s.StaveModifier.Position.ABOVE,P=E.PlacementEnum.Above):(G=s.StaveModifier.Position.BELOW,P=E.PlacementEnum.Below)}const X=new s.FretHandFinger(j.value);if(X.setPosition(G),X.setOffsetX(Y),P===E.PlacementEnum.Above||P===E.PlacementEnum.Below){const ie=P===E.PlacementEnum.Above?-1:1,oe=P===E.PlacementEnum.Above?F:D-1-F;if(this.rules.FingeringInsideStafflines&&D>1){const $=X.getWidth()/2,Q=2.5*D;X.setOffsetY(ie*(oe+Q)*$)}else if(!this.rules.FingeringInsideStafflines){const $=new s.StringNumber(j.value);$.radius=0,$.setPosition(G),$.setOffsetY(ie*oe*$.getWidth()*2/3),B.vfStaveNote.addModifier(F,$);continue}}B.vfStaveNote.addModifier(F,X)}}createStringNumber(v){if(!this.rules.RenderStringNumbersClassical)return;const B=v;v.notes.forEach((D,_)=>{const F=D.sourceNote.StringInstruction;if(F){let k=F.value;switch(k){case"1":k="I";break;case"2":k="II";break;case"3":k="III";break;case"4":k="IV";break;case"5":k="V";break;case"6":k="VI"}const j=new s.StringNumber(k);j.radius=0;const P=-this.rules.StringNumberOffsetY;v.notes.length>1||v.parentStaffEntry.graphicalVoiceEntries.length>1?(j.setOffsetX(13*D.baseStringNumberXOffset),j.setPosition(s.Modifier.Position.RIGHT)):j.setPosition(s.Modifier.Position.ABOVE),j.setOffsetY(P),B.vfStaveNote.addModifier(_,j)}})}lineTo(v,B,D=0){const _=new s.StaveConnector(v.getVFStave(),this.stave);_.setType(B),D!==0&&_.setXShift(D),this.connectors.push(_)}getVFStave(){return this.stave}updateInstructionWidth(){let v=0,B=0;const D=this.stave.getModifiers();for(const _ of D)_.getPosition()===T.BEGIN?v+=_.getWidth()+_.getPadding(void 0):_.getPosition()===T.END&&(B+=_.getWidth()+_.getPadding(void 0));this.beginInstructionsWidth=(v??0)/f.unitInPixels,this.endInstructionsWidth=(B??0)/f.unitInPixels}addStaveTie(v,B){this.vfTies.push(v),B.vfTie=v,B.Tie.TieDirection===E.PlacementEnum.Below&&v.setDirection(1)}}var T;g.VexFlowMeasure=I,function(A){A[A.LEFT=1]="LEFT",A[A.RIGHT=2]="RIGHT",A[A.ABOVE=3]="ABOVE",A[A.BELOW=4]="BELOW",A[A.BEGIN=5]="BEGIN",A[A.END=6]="END"}(T||(g.StavePositionEnum=T={}))},3849(de,g,c){var l=this&&this.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(g,"__esModule",{value:!0}),g.VexFlowMultiRestMeasure=void 0;var s=l(c(3206)).default.Flow;const u=c(5246);class r extends u.VexFlowMeasure{constructor(o,n=void 0,h=void 0){super(o,n,h),this.minimumStaffEntriesWidth=-1,h?this.rules=h.ParentMusicSystem.rules:n&&(this.rules=n.Rules),this.resetLayout(),this.multiRestElement=new s.MultiMeasureRest(n.multipleRestMeasures,{})}draw(o){var h,t;const n=o.openGroup();n&&((h=n.classList)==null||h.add("vf-measure"),(t=n.classList)==null||t.add("multi"),n.id=`${this.MeasureNumber}`),this.stave.setContext(o).draw(),this.multiRestElementSVG=o.openGroup("multirest"),this.multiRestElement.setStave(this.stave),this.multiRestElement.setContext(o),this.multiRestElement.draw(),this.multiRestElement.id=`vf-multi${this.MeasureNumber}`,o.closeGroup(),o.closeGroup();for(const f of this.connectors)f.setContext(o).draw()}format(){var o,n;for(const h of this.staffEntries){const t=this.PositionAndShape.Size.width-this.beginInstructionsWidth;h.PositionAndShape.RelativePosition.x=this.PositionAndShape.Size.width/2+this.beginInstructionsWidth/3,h.PositionAndShape.RelativePosition.y=0;const f=(n=(o=h.graphicalVoiceEntries[0])==null?void 0:o.notes[0])==null?void 0:n.PositionAndShape;f.BorderLeft=-t/3,f.BorderRight=t/3,f.BorderTop=1,f.BorderBottom=3,h.PositionAndShape.calculateBoundingBox()}}getVoicesWithinMeasure(){return[]}getGraphicalVoiceEntriesPerVoice(o){return[]}getRestFilledVexFlowStaveNotesPerVoice(o){return[]}handleBeam(o,n){}handleTuplet(o,n){}finalizeBeams(){}finalizeTuplets(){}layoutStaffEntry(o){}graphicalMeasureCreatedCalculations(){}createArticulations(){}createOrnaments(){}createFingerings(o){}getVFStave(){return this.stave}}g.VexFlowMultiRestMeasure=r},806(de,g,c){var l=this&&this.__importDefault||function(oe){return oe&&oe.__esModule?oe:{default:oe}};Object.defineProperty(g,"__esModule",{value:!0}),g.VexFlowMusicSheetCalculator=void 0;const s=c(7921),u=c(3753),r=c(5748),i=c(1327),o=c(5054),n=c(2561),h=c(8215),t=c(7785),f=l(c(3206));var p=f.default.Flow;const m=l(c(3065)),x=c(9479),y=c(2395),d=c(7751),S=c(9310),M=c(7809),E=c(7533),L=c(4022),I=c(2400),T=c(9161),A=c(624),v=c(7506),B=c(5282),D=c(6014),_=c(4980),F=c(6659),k=c(6954),j=c(7109),P=c(512),G=c(813),Y=c(1216),X=c(2907);class ie extends s.MusicSheetCalculator{constructor($){var Q,ne,ee,N,R,O,U,H;super(),this.beamsNeedUpdate=!1,this.previousLyricOverflowsByStaff=new Map,this.previousChordOverflowsByStaff=new Map,this.rules=$,s.MusicSheetCalculator.symbolFactory=new u.VexFlowGraphicalSymbolFactory,s.MusicSheetCalculator.TextMeasurer=new t.VexFlowTextMeasurer(this.rules),s.MusicSheetCalculator.stafflineNoteCalculator=new v.VexflowStafflineNoteCalculator(this.rules),((Q=this.rules.DefaultVexFlowNoteFont)==null?void 0:Q.toLowerCase())==="gonville"?f.default.Flow.DEFAULT_FONT_STACK=[(ne=f.default.Flow.Fonts)==null?void 0:ne.Gonville,(ee=f.default.Flow.Fonts)==null?void 0:ee.Bravura,(N=f.default.Flow.Fonts)==null?void 0:N.Custom]:((R=this.rules.DefaultVexFlowNoteFont)==null?void 0:R.toLowerCase())==="petaluma"&&(f.default.Flow.DEFAULT_FONT_STACK=[(O=f.default.Flow.Fonts)==null?void 0:O.Petaluma,(U=f.default.Flow.Fonts)==null?void 0:U.Gonville,(H=f.default.Flow.Fonts)==null?void 0:H.Bravura])}clearRecreatedObjects(){super.clearRecreatedObjects(),s.MusicSheetCalculator.stafflineNoteCalculator=new v.VexflowStafflineNoteCalculator(this.rules);for(const $ of this.graphicalMusicSheet.MeasureList)for(const Q of $)Q==null||Q.clean()}formatMeasures(){for(const $ of this.graphicalMusicSheet.MeasureList)if($&&$[0]){$.find(Q=>Q==null?void 0:Q.isVisible()).format();for(const Q of $){for(const ne of Q.staffEntries)ne.calculateXPosition();Q.finalizeBeams()}}this.beamsNeedUpdate=!1}calculateMeasureXLayout($){const Q=[];for(const H of $)H!=null&&H.isVisible()&&Q.push(H);if(Q.length===0)return 0;$=Q;const ne=[],ee=new p.Formatter({softmaxFactor:this.rules.SoftmaxFactorVexFlow});let N=$[0].staffEntries.length,R=1;for(const H of $){if(!H)continue;let W=0;for(const te of H.staffEntries)W+=te.setMaxAccidentals();H.parentSourceMeasure.ImplicitMeasure&&(N=Math.max(H.staffEntries.length,N),R=Math.max(H.staffEntries.length+W,R));const K=H.vfVoices,q=[];for(const te in K)if(K.hasOwnProperty(te)){const se=K[te];H.hasOnlyRests&&!se.ticksUsed.equals(se.totalTicks)&&(se.ticksUsed=se.totalTicks),q.push(se),ne.push(se)}q.length!==0?ee.joinVoices(q):m.default.debug("Found a measure with no voices. Continuing anyway.",K)}let O=12;const U=$[0].parentSourceMeasure;if(ne.length>0){if(O=ee.preCalculateMinTotalWidth(ne)/x.unitInPixels*this.rules.VoiceSpacingMultiplierVexflow+this.rules.VoiceSpacingAddendVexflow+.3*N,U==null?void 0:U.ImplicitMeasure){O=U.Duration.RealValue/U.ActiveTimeSignature.RealValue*O;let K=0;const q=U.measureListIndex;if(q>1)for(const te of this.graphicalMusicSheet.MeasureList[q-1]){const se=te==null?void 0:te.parentSourceMeasure.endingBarStyleEnum;if(se===k.SystemLinesEnum.ThinBold||se===k.SystemLinesEnum.DotsThinBold){K=this.rules.PickupMeasureRepetitionSpacing;break}}O+=K,N>1?O+=.3*R*1.5:q>1&&N===1&&(O+=this.rules.PickupMeasureSpacingSingleNoteAddend),O*=this.rules.PickupMeasureWidthMultiplier}s.MusicSheetCalculator.setMeasuresMinStaffEntriesWidth($,O);const H=(K,q)=>{ee.formatToStave(ne,q.getVFStave())},W=(K,q)=>{ee.formatToStave(ne,q.getVFStave(),{align_rests:!0,context:void 0})};for(const K of $){if(this.rules.AlignRests===A.AlignRestOption.Never)K.formatVoices=H;else if(this.rules.AlignRests===A.AlignRestOption.Always)K.formatVoices=W;else if(this.rules.AlignRests===A.AlignRestOption.Auto){let q=!1;for(const te of K.staffEntries){let se=0,ue=0;for(const fe of te.graphicalVoiceEntries)if(fe.parentVoiceEntry.IsGrace||fe&&fe.notes&&fe.notes[0]&&fe.notes[0].sourceNote&&fe.notes[0].sourceNote.PrintObject&&se++,fe&&fe.notes&&fe.notes[0]&&fe.notes[0].sourceNote&&fe.notes[0].sourceNote.isRest()&&fe.notes[0].sourceNote.PrintObject&&ue++,se>1&&ue>=1){q=!0;break}if(q)break}K.formatVoices=q?W:H}if(K===$[0]){const q=K;q.formatVoices(O*x.unitInPixels,q)}}}for(const H of $)if(H)for(const W of H.staffEntries)W.calculateXPosition();for(const H of $){if(!H)continue;const W=H.vfVoices,K=[];for(const q in W)W.hasOwnProperty(q)&&K.push(W[q]);K.length!==0?ee.joinVoices(K):m.default.debug("Found a measure with no voices. Continuing anyway.",W)}return O}calculateElongationFactor($,Q,ne,ee,N,R,O,U){let H=N,W=0,K=!1;for(const q of $){const te=q.GraphicalLabel.Label.textAlignment;let se=O,ue=U;if(K=!1,q instanceof y.GraphicalLyricEntry&&q.ParentLyricWord){q.LyricsEntry.SyllableIndex>0&&(se=this.rules.BetweenSyllableMinimumDistance,E.TextAlignment.IsCenterAligned(te)&&(se+=1));const Ce=q.ParentLyricWord.GetLyricWord.Syllables;Ce.length>1&&q.LyricsEntry.SyllableIndex0?be/ye:(Me+be)/ee;let Pe=1;q instanceof y.GraphicalLyricEntry&&q.LyricsEntry?ne[W]&&(Pe=ve/Se,ne[W].sourceNoteDuration.Denominator>4&&(Pe*=1.1)):ne[W]&&(Pe=ve/Se),Le=Math.max(Te,Pe),H=Math.max(H,Le);let Ae=Math.max(ve-Se||0,0);ne[W]&&(Ae+=ne[W].cumulativeOverlap),ne[W]={cumulativeOverlap:Ae,extend:q instanceof y.GraphicalLyricEntry&&q.LyricsEntry.extend,labelWidth:xe,measureNumber:R,needsDashSpaceAtEnd:K,sourceNoteDuration:q instanceof y.GraphicalLyricEntry&&q.LyricsEntry&&q.LyricsEntry.Parent.Notes[0].Length,text:q instanceof y.GraphicalLyricEntry?q.LyricsEntry.Text:q.GraphicalLabel.Label.text,xPosition:Me},W++}return H}calculateElongationFactorFromStaffEntries($,Q,ne,ee,N,R){let O=ne;const U={},H={};if(N)for(let W=0;W0&&(U[W]={cumulativeOverlap:0,extend:!1,labelWidth:K,measureNumber:ee-1,sourceNoteDuration:new n.Fraction(1,4),text:"",xPosition:0})}if(R)for(let W=0;W0&&(H[W]={cumulativeOverlap:0,extend:!1,labelWidth:K,measureNumber:ee-1,sourceNoteDuration:new n.Fraction(1,4),text:"",xPosition:0})}for(const W of $)W.LyricsEntries.length>0&&this.rules.RenderLyrics&&(O=this.calculateElongationFactor(W.LyricsEntries,W,U,Q,O,ee,this.rules.HorizontalBetweenLyricsDistance,this.rules.LyricOverlapAllowedIntoNextMeasure)),W.graphicalChordContainers.length>0&&this.rules.RenderChordSymbols&&(O=this.calculateElongationFactor(W.graphicalChordContainers,W,H,Q,O,ee,this.rules.ChordSymbolXSpacing,this.rules.ChordOverlapAllowedIntoNextMeasure));return{factor:O,lastLyricEntryDict:U,lastChordEntryDict:H}}calculateMeasureWidthFromStaffEntries($,Q){let ne=1;const ee=[],N=new Set;for(const O of $){if(!O||O.staffEntries.length===0||!O.isVisible())continue;const U=O.ParentStaff;N.add(U);const H=this.previousLyricOverflowsByStaff.get(U),W=this.previousChordOverflowsByStaff.get(U),K=this.calculateElongationFactorFromStaffEntries(O.staffEntries,Q,ne,O.MeasureNumber,H,W);ne=K.factor,ee.push({staff:U,lastLyricEntryDict:K.lastLyricEntryDict,lastChordEntryDict:K.lastChordEntryDict})}ne=Math.min(ne,this.rules.MaximumLyricsElongationFactor);const R=Q*ne;for(const O of ee){const U=this.computeContainerOverflows(O.lastLyricEntryDict,R),H=this.computeContainerOverflows(O.lastChordEntryDict,R);this.previousLyricOverflowsByStaff.set(O.staff,U),this.previousChordOverflowsByStaff.set(O.staff,H)}for(const O of Array.from(this.previousLyricOverflowsByStaff.keys()))N.has(O)||this.previousLyricOverflowsByStaff.delete(O);for(const O of Array.from(this.previousChordOverflowsByStaff.keys()))N.has(O)||this.previousChordOverflowsByStaff.delete(O);return R}computeContainerOverflows($,Q){const ne=[];for(const ee of Object.keys($)){const N=Number(ee),R=$[N];if(!R)continue;const O=R.xPosition+R.labelWidth;let U=Math.max(0,O-Q);R.needsDashSpaceAtEnd&&this.dashSpace!==void 0&&(U+=this.dashSpace),ne[N]=U}return ne}createGraphicalTie($,Q,ne,ee,N){return new o.GraphicalTie($,ee,N)}updateStaffLineBorders($){$.SkyBottomLineCalculator.updateStaffLineBorders()}graphicalMeasureCreatedCalculations($){$.rules=this.rules,$.graphicalMeasureCreatedCalculations()}layoutVoiceEntry($,Q,ne,ee){for(let N=0;N=2&&(R=ee.vfnote[0],U=ee.vfnote[1]);let H=0;if(N&&N.vfnote&&N.vfnote.length>=2&&(O=N.vfnote[0],H=N.vfnote[1]),Q){if(R){const W=new p.StaveTie({first_indices:[U],first_note:R});ee.parentVoiceEntry.parentStaffEntry.parentMeasure.addStaveTie(W,$)}if(O){const W=new p.StaveTie({last_indices:[H],last_note:O});N.parentVoiceEntry.parentStaffEntry.parentMeasure.addStaveTie(W,$)}}else if(R||O){let W;if(ne)if($.Tie.Type==="S"){const K=$.StartNote.sourceNote,q=$.EndNote.sourceNote;let te=1;K.FretNumber>q.FretNumber&&(te=-1),W=new p.TabSlide({first_indices:[U],first_note:R,last_indices:[H],last_note:O},te)}else W=new p.TabTie({first_indices:[U],first_note:R,last_indices:[H],last_note:O},$.Tie.Type);else{W=new p.StaveTie({first_indices:[U],first_note:R,last_indices:[H],last_note:O});const K=$.Tie.getTieDirection(ee.sourceNote);K===_.PlacementEnum.Below?W.setDirection(1):K===_.PlacementEnum.Above&&W.setDirection(-1)}N.parentVoiceEntry.parentStaffEntry.parentMeasure.addStaveTie(W,$)}}calculateDynamicExpressionsForMultiExpression($,Q,ne){if(Qthis.rules.MaxMeasureToDrawIndex)return;const ee=$.AbsoluteTimestamp,N=this.graphicalMusicSheet.MeasureList[Q],R=N[ne].ParentStaffLine,O=N[ne],U=$.StartingContinuousDynamic,H=U!==void 0&&!U.IsStartOfSoftAccent,W=this.getRelativePositionInStaffLineFromTimestamp(ee,ne,R,R==null?void 0:R.isPartOfMultiStaffInstrument(),void 0,H);if(W.x<=0&&(W.x=O.beginInstructionsWidth+this.rules.RhythmRightMargin),$.InstantaneousDynamic){const K=new M.VexFlowInstantaneousDynamicExpression($.InstantaneousDynamic,R,O);this.calculateGraphicalInstantaneousDynamicExpression(K,W,ee),this.dynamicExpressionMap.set(ee.RealValue,K.PositionAndShape)}if(U){const K=new I.VexFlowContinuousDynamicExpression(U,R,O.parentSourceMeasure);if(K.StartMeasure=O,K.IsSoftAccent=$.StartingContinuousDynamic.IsStartOfSoftAccent,!K.IsVerbal&&U.EndMultiExpression)try{this.calculateGraphicalContinuousDynamic(K,W),K.updateSkyBottomLine()}catch{}else K.IsVerbal?this.calculateGraphicalVerbalContinuousDynamic(K,W):m.default.warn("This continuous dynamic is not covered. measure"+$.SourceMeasureParent.MeasureNumber)}}createMetronomeMark($){var K,q;const Q=$.ParentMultiTempoExpression.SourceMeasureParent.MeasureNumber,ne=Math.max($.StaffNumber-1,0),ee=this.graphicalMusicSheet.findGraphicalMeasureByMeasureNumber(Q,ne),N=ee===this.graphicalMusicSheet.MeasureList[0][0];if(ee.hasMetronomeMark)return;const R=ee.getVFStave();let O=this.rules.MetronomeMarkYShift,U=!1;for(const te of $.parentMeasure.TempoExpressions){const se=((K=te.InstantaneousTempo)==null?void 0:K.TempoType)===T.TempoType.metronomeMark;if(te.getPlacementOfFirstEntry()===_.PlacementEnum.Above&&!se){U=!0;break}}U&&(O-=1.4);const H=(q=this.graphicalMusicSheet.MeasureList[0][0].ParentStaffLine)==null?void 0:q.SkyLine;if($.metronomeNoteGroupLeft&&$.metronomeNoteGroupRight){const te=this.buildNoteEquationForVexFlow($.metronomeNoteGroupLeft,$.metronomeNoteGroupRight);R.setTempo({noteEquation:te},O*x.unitInPixels)}else{let te="q";if($.beatUnit){const se=B.NoteTypeHandler.getNoteDurationFromType($.beatUnit);te=D.VexFlowConverter.durations(se,!1)[0]}R.setTempo({bpm:$.TempoInBpm,dots:$.dotted,duration:te},O*x.unitInPixels)}const W=N?this.rules.MetronomeMarkXShift*x.unitInPixels:0;R.getModifiers()[R.getModifiers().length-1].setShiftX(W),ee.hasMetronomeMark=!0,H&&(H[0]=Math.min(H[0],-4.5+O))}buildNoteEquationForVexFlow($,Q){const ne=ee=>{const N={notes:ee.notes.map(R=>{const O=B.NoteTypeHandler.getNoteDurationFromType(R.type);return{duration:D.VexFlowConverter.durations(O,!1)[0],dots:R.dots,beam:R.beam}})};return ee.tuplet&&(N.tuplet={actualNotes:ee.tuplet.actualNotes,normalNotes:ee.tuplet.normalNotes,bracket:ee.tuplet.bracket,showNumber:ee.tuplet.showNumber}),N};return{left:ne($),right:ne(Q)}}calculateRehearsalMark($){const Q=$.rehearsalExpression;if(!Q)return;const ne=this.graphicalMusicSheet.MeasureList[0][0].MeasureNumber,ee=Math.max($.MeasureNumber-ne,0);for(const N of this.graphicalMusicSheet.MeasureList[ee]){const R=N==null?void 0:N.getVFStave();if(!R||!N.isVisible())continue;let O=-this.rules.RehearsalMarkYOffsetDefault-this.rules.RehearsalMarkYOffset;N.parentSourceMeasure.isReducedToMultiRest&&(O+=this.rules.RehearsalMarkYOffsetAddedForRehearsalMarks);let U=this.rules.RehearsalMarkXOffsetDefault+this.rules.RehearsalMarkXOffset;$.IsSystemStartMeasure&&(U+=this.rules.RehearsalMarkXOffsetSystemStartMeasure);const H=this.rules.RehearsalMarkFontSize;return void R.setSection(Q.label,O,U,H)}}calculateSingleOctaveShift($,Q,ne,ee){var se,ue;const N=Q.OctaveShiftStart,R=N.ParentStartMultiExpression.Timestamp,O=(se=N.ParentEndMultiExpression)==null?void 0:se.Timestamp,U=this.rules.MinMeasureToDrawIndex,H=this.rules.MaxMeasureToDrawIndex;let W,K,q=this.graphicalMusicSheet.MeasureList[ne][ee].ParentStaffLine;if(q||(q=this.graphicalMusicSheet.MeasureList[U][ee].ParentStaffLine),W=N.ParentEndMultiExpression?this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(N.ParentEndMultiExpression.SourceMeasureParent,ee):this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(ee,!0),W.MeasureNumber>H+1&&(W=this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(ee,!0)),K=N.ParentStartMultiExpression?this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(N.ParentStartMultiExpression.SourceMeasureParent,ee):this.graphicalMusicSheet.MeasureList[U][ee],K.MeasureNumberH||W.parentSourceMeasure.measureListIndexH)return;let te=W.ParentStaffLine;if(te||(te=q),W&&q&&te){const fe=new S.VexFlowOctaveShift(N,q.PositionAndShape);if(!fe.startNote){let Se;for(const ye of K.staffEntries)if(ye){Se=ye;break}if(!Se||(fe.setStartNote(Se),!fe.startNote))return}if(!fe.endNote){let Se;for(let ye=W.staffEntries.length-1;ye>=0;ye++)if(W.staffEntries[ye]){Se=W.staffEntries[ye];break}if(!Se)return void(fe.graphicalEndAtMeasureEnd=!0);if(fe.setEndNote(Se),!fe.endNote)return}let xe=K.findGraphicalStaffEntryFromTimestamp(R);xe||(xe=K.staffEntries[0]);let ve=W.findGraphicalStaffEntryFromTimestamp(O);if(!ve)for(let Se=W.staffEntries.length-1;Se>=0;Se--){const ye=W.staffEntries[Se];if((ue=ye.relInMeasureTimestamp)!=null&&ue.lte(O)){ve=ye;break}}if(ve||(ve=W.staffEntries[W.staffEntries.length-1]),fe.setStartNote(xe),te!==q){fe.endsOnDifferentStaffLine=!0;let Se=this.findLastStafflineMeasure(q);Se===void 0&&(Se=W);const ye=Se.staffEntries[Se.staffEntries.length-1];if(fe.setEndNote(ye),fe.graphicalEndAtMeasureEnd=!0,fe.endMeasure=Se,te.ParentMusicSystem.Id-q.ParentMusicSystem.Id>0)for(let be=q.ParentMusicSystem.Id;be0?N.endVoiceEntryIndex:-1;Pe.setEndNote(Be,Fe),Te.OctaveShifts.push(Pe),this.calculateOctaveShiftSkyBottomLine(Ce,Be,Pe,Te)}this.calculateOctaveShiftSkyBottomLine(xe,ye,fe,q)}else fe.setEndNote(ve,N.endVoiceEntryIndex>0?N.endVoiceEntryIndex:-1),this.calculateOctaveShiftSkyBottomLine(xe,ve,fe,q);q.OctaveShifts.push(fe)}else m.default.warn("End measure or staffLines for octave shift are undefined! This should not happen!")}findLastStafflineMeasure($){for(let Q=$.Measures.length-1;Q>=0;Q--){const ne=$.Measures[Q];if(ne.staffEntries.length>0)return ne}}calculateSinglePedal($,Q,ne,ee){var se;const N=Q.PedalStart,R=N.ParentStartMultiExpression.Timestamp,O=(se=N.ParentEndMultiExpression)==null?void 0:se.Timestamp,U=this.rules.MinMeasureToDrawIndex,H=this.rules.MaxMeasureToDrawIndex;let W,K,q=this.graphicalMusicSheet.MeasureList[ne][ee].ParentStaffLine;if(q||(q=this.graphicalMusicSheet.MeasureList[U][ee].ParentStaffLine),W=N.ParentEndMultiExpression?this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(N.ParentEndMultiExpression.SourceMeasureParent,ee):this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(ee,!0),W.MeasureNumber>H+1&&(W=this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(ee,!0)),N.ParentEndMultiExpression?K=this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(N.ParentStartMultiExpression.SourceMeasureParent,ee):(K=this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(N.ParentStartMultiExpression.SourceMeasureParent,ee),K||(K=this.graphicalMusicSheet.MeasureList[U][ee])),K.MeasureNumberH||W.parentSourceMeasure.measureListIndexH)return;let te=W.ParentStaffLine;if(te||(te=q),W&&q&&te){let ue=!1;q!==te&&(ue=!0);const fe=new j.VexFlowPedal(N,q.PositionAndShape,!1,ue);fe.setEndsStave(W,O);let xe=K.findGraphicalStaffEntryFromTimestamp(R);xe||(xe=K.staffEntries[0]);let ve=W.findGraphicalStaffEntryFromTimestamp(O);if(ve||(ve=W.staffEntries[W.staffEntries.length-1]),!fe.setStartNote(xe))return;if(fe.setBeginsStave(fe.startNote.isRest(),R),te!==q)if(fe.pedalSymbol===P.MusicSymbol.PEDAL_SYMBOL){fe.setEndNote(ve),fe.setEndMeasure(W),fe.ReleaseText=" ",fe.CalculateBoundingBox(),this.calculatePedalSkyBottomLine(fe.startVfVoiceEntry,fe.endVfVoiceEntry,fe,q);const Se=te.Measures[0],ye=new j.VexFlowPedal(N,Se.PositionAndShape);fe.setEndsStave(W,O);const be=Se.staffEntries[0];if(!ye.setStartNote(be))return;ye.setEndNote(ve),ye.setEndMeasure(W),fe.setEndMeasure(W),te.Pedals.push(ye),ye.CalculateBoundingBox(),ye.DepressText=" ",this.calculatePedalSkyBottomLine(ye.startVfVoiceEntry,ye.endVfVoiceEntry,ye,te)}else{let Se=this.findLastStafflineMeasure(q);Se===void 0&&(Se=W);const ye=Se.staffEntries[Se.staffEntries.length-1];fe.setEndNote(ye),fe.setEndMeasure(W),fe.ChangeEnd=!1;const be=te.ParentMusicSystem.Id-q.ParentMusicSystem.Id;if(be>0){let Me=1;for(let _e=q.ParentMusicSystem.Id;_eH+1&&(W=this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(ee,!0)),K=N.ParentEndMultiExpression?this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(N.ParentStartMultiExpression.SourceMeasureParent,ee):this.graphicalMusicSheet.MeasureList[U][ee],K.MeasureNumberH||W.parentSourceMeasure.measureListIndexH)return;let te=W.ParentStaffLine;if(te||(te=q),W&&q&&te){const ue=new X.VexFlowVibratoBracket(N,q.PositionAndShape,K.ParentStaff.isTab);let fe=K.findGraphicalStaffEntryFromTimestamp(R);fe||(fe=K.staffEntries[0]);let xe=W.findGraphicalStaffEntryFromTimestamp(O);if(xe||(xe=W.staffEntries[W.staffEntries.length-1]),ue.setStartNote(fe),te!==q){let ve=q.Measures[q.Measures.length-1];ve===void 0&&(ve=W);const Se=ve.staffEntries[ve.staffEntries.length-1];if(Se&&ue.setEndNote(Se),te.ParentMusicSystem.Id-q.ParentMusicSystem.Id>0)for(let ye=q.ParentMusicSystem.Id;yeW){const Se=W;W=K,K=Se}ee.SkyBottomLineCalculator.updateBottomLineInRange(K,W,q+xe)}for(const xe of ee.Pedals){const ve=xe,Se=ve.getPedalMarking();if(q>Se.line+3+(ee.StaffLines.length-1)){const ye=Se.render_options.text_margin_right/10;let be,Me=ve.startVfVoiceEntry.PositionAndShape.AbsolutePosition.x-ye;ve.setLine(q-3-(ee.StaffLines.length-1));let _e=(se=ve.endVfVoiceEntry)==null?void 0:se.PositionAndShape;if(_e||(_e=ve.endMeasure.PositionAndShape),ve.EndSymbolPositionAndShape){const Te=O.render_options.glyph_point_size/20;be=Me+3.4;const Le=_e.AbsolutePosition.x-ye,Pe=Le+1.5;ee.SkyBottomLineCalculator.updateBottomLineInRange(Me,be,q+Te),ee.SkyBottomLineCalculator.updateBottomLineInRange(Le,Pe,q+Te)}else{const Te=Se.render_options.bracket_height/10;if(Se.EndsStave)be=_e.AbsolutePosition.x+_e.Size.width-ye;else switch(O.style){case R.BRACKET_OPEN_END:case R.BRACKET_OPEN_BOTH:case R.MIXED_OPEN_END:be=_e.AbsolutePosition.x+_e.BorderRight-ye;break;default:be=_e.AbsolutePosition.x+_e.BorderLeft-ye}const Le=(fe=(ue=ve.endVfVoiceEntry)==null?void 0:ue.parentStaffEntry)==null?void 0:fe.vfClefBefore;if(Le&&(be+=Le.getWidth()/10),Me>be){const Pe=Me;Me=be,be=Pe}ee.SkyBottomLineCalculator.updateBottomLineInRange(Me,be,q+Te)}}}}calculateOctaveShiftSkyBottomLine($,Q,ne,ee){if(!Q)return void m.default.warn("octaveshift: no endStaffEntry");let N=Q.PositionAndShape;ne.graphicalEndAtMeasureEnd&&(N=Q.parentMeasure.PositionAndShape);let R=$.PositionAndShape.Size.width,O=N.Size.width;$.hasOnlyRests()?R=-R:R/=2,ne.graphicalEndAtMeasureEnd||(Q.hasOnlyRests()?O*=2:O/=2,$===Q&&(O*=2));let U=$.PositionAndShape.AbsolutePosition.x-R,H=N.AbsolutePosition.x+O;if(U>H){const q=U;U=H,H=q}ne.PositionAndShape.Size.width=H-U;const W=ne.getTextBracket(),K=W.font.size/10;if(W.position===p.TextBracket.Positions.TOP){const q=Math.ceil(ee.SkyBottomLineCalculator.getSkyLineMinInRange(U,H));if(q===1/0)return;W.start.getStave().options.top_text_position=Math.abs(q),ee.SkyBottomLineCalculator.updateSkyLineInRange(U,H,q-2*K)}else{const q=ee.SkyBottomLineCalculator.getBottomLineMaxInRange(U,H);if(q===1/0)return;W.start.getStave().options.bottom_text_position=q,ee.SkyBottomLineCalculator.updateBottomLineInRange(U,H,q+1.5*K)}}calculateWordRepetitionInstruction($,Q){let ne;const ee=this.graphicalMusicSheet.MeasureList[Q];for(let N=0,R=ee.length;Nne.StaffLines));let Q=0;for(const ne of $)for(const ee of ne.Measures)ee&&Q++;if(this.rules.AlwaysSetPreferredSkyBottomLineBackendAutomatically&&this.rules.setPreferredSkyBottomLineBackendAutomatically(Q),Q>=this.rules.SkyBottomLineBatchMinMeasures)new i.SkyBottomLineBatchCalculator($,this.rules.PreferredSkyBottomLineBatchCalculatorBackend).calculateLines();else for(const ne of $)ne.SkyBottomLineCalculator.calculateLines()}calculateExpressionAlignements(){for(const $ of this.musicSystems)for(const Q of $.StaffLines)try{Q.AlignmentManager.alignDynamicExpressions(),Q.AbstractExpressions.forEach(ne=>{ne.updateSkyBottomLine()})}catch{}}handleTiedGraphicalNote($,Q,ne,ee,N,R,O,U){}handleBeam($,Q,ne){$.parentVoiceEntry.parentStaffEntry.parentMeasure.handleBeam($,Q)}handleVoiceEntryLyrics($,Q,ne){$.LyricsEntries.forEach((ee,N)=>{const R=new y.GraphicalLyricEntry(N,Q,this.rules.LyricsHeight,this.rules.StaffHeight);if(Q.LyricsEntries.push(R),R.GraphicalLabel.setLabelPositionAndShapeBorders(),N.Word){const O=N.Word.Syllables.indexOf(N);let U=ne.indexOf(N.Word);if(U===-1&&(ne.push(N.Word),U=ne.indexOf(N.Word)),this.graphicalLyricWords.length===0||U>this.graphicalLyricWords.length-1){const H=new d.GraphicalLyricWord(N.Word);R.ParentLyricWord=H,H.GraphicalLyricsEntries[O]=R,this.graphicalLyricWords.push(H)}else{const H=this.graphicalLyricWords[U];R.ParentLyricWord=H,H.GraphicalLyricsEntries[O]=R,H.isFilled()&&(ne.splice(U,1),this.graphicalLyricWords.splice(this.graphicalLyricWords.indexOf(H),1))}}})}handleVoiceEntryOrnaments($,Q,ne){}handleVoiceEntryArticulations($,Q,ne){}handleVoiceEntryTechnicalInstructions($,Q,ne){}handleTuplet($,Q,ne){$.parentVoiceEntry.parentStaffEntry.parentMeasure.handleTuplet($,Q)}findIndexGraphicalSlurFromSlur($,Q){for(let ne=0;ne<$.length;ne++)if($[ne].slur===Q)return ne;return-1}indexOfGraphicalGlissFromGliss($,Q){for(let ne=0;ne<$.length;ne++)if($[ne].Glissando===Q)return ne;return-1}calculateSlurs(){const $={};for(const Q of this.graphicalMusicSheet.MeasureList[0])$[Q.ParentStaff.idInMusicSheet]=[];for(const Q of this.musicSystems)for(const ne of Q.StaffLines){const ee=$[ne.ParentStaff.idInMusicSheet];for(let N=0;N=0){const K=ee[W];K.staffEntries.indexOf(R)===-1&&K.staffEntries.push(R),ee.splice(W,1)}}}for(const O of ee)O.staffEntries.indexOf(R)===-1&&O.staffEntries.push(R)}}for(const Q of this.musicSystems)for(const ne of Q.StaffLines){const ee=ne.GraphicalSlurs.sort(L.GraphicalSlur.Compare);for(const N of ee)N.slur.isCrossed()||N.calculateCurve(this.rules)}}calculateGlissandi(){const $={};for(const Q of this.graphicalMusicSheet.MeasureList[0])$[Q.ParentStaff.idInMusicSheet]=[];for(const Q of this.musicSystems)for(const ne of Q.StaffLines){const ee=$[ne.ParentStaff.idInMusicSheet];for(let N=0;N=0){const K=ee[W];K.staffEntries.indexOf(R)===-1&&K.staffEntries.push(R),ee.splice(W,1)}}}}for(const O of ee)O.staffEntries.indexOf(R)===-1&&O.staffEntries.push(R)}}for(const Q of this.musicSystems)for(const ne of Q.StaffLines)for(const ee of ne.GraphicalGlissandi)if(ne.ParentStaff.isTab){const N=ee.Glissando.StartNote,R=ee.Glissando.EndNote,O=ee.staffEntries[0].findGraphicalNoteFromNote(N),U=ee.staffEntries.last().findGraphicalNoteFromNote(R);if(!O&&!U)return;let H,W,K,q,te=1;N.FretNumber>R.FretNumber&&(te=-1),O&&O.vfnote&&O.vfnote.length>=2&&(K=O.vfnote[0],H=[0]),U&&U.vfnote&&U.vfnote.length>=2&&(q=U.vfnote[0],W=[0]);const se=new p.TabSlide({first_indices:H,first_note:K,last_indices:W,last_note:q},te),ue=O==null?void 0:O.parentVoiceEntry.parentStaffEntry.parentMeasure;ue&&(ue.vfTies.push(se),ee.vfTie=se);const fe=U==null?void 0:U.parentVoiceEntry.parentStaffEntry.parentMeasure;fe&&(fe.vfTies.push(se),ee.vfTie=se)}}}g.VexFlowMusicSheetCalculator=ie},9479(de,g,c){var l=this&&this.__importDefault||function(M){return M&&M.__esModule?M:{default:M}};Object.defineProperty(g,"__esModule",{value:!0}),g.VexFlowMusicSheetDrawer=g.unitInPixels=void 0;const s=l(c(3206)),u=c(1932),r=c(200),i=c(9409),o=c(7785),n=c(2683),h=c(6362),t=c(3361),f=c(5023),p=l(c(3065)),m=c(1066),x=c(3661),y=c(5824),d=c(9436);g.unitInPixels=10;class S extends u.MusicSheetDrawer{constructor(E=new x.DrawingParameters){super(new o.VexFlowTextMeasurer(E.Rules),E),this.backends=[],this.zoom=1,this.pageIdx=0}get Backends(){return this.backends}drawSheet(E){var L,I,T;this.rules.DefaultVexFlowNoteFont==="gonville"&&(s.default.Flow.DEFAULT_FONT_STACK=[(L=s.default.Flow.Fonts)==null?void 0:L.Gonville,(I=s.default.Flow.Fonts)==null?void 0:I.Bravura,(T=s.default.Flow.Fonts)==null?void 0:T.Custom]),s.default.Flow.STAVE_LINE_THICKNESS=this.rules.StaffLineWidth*g.unitInPixels,s.default.Flow.STEM_WIDTH=this.rules.StemWidth*g.unitInPixels,s.default.Flow.DEFAULT_NOTATION_FONT_SCALE=this.rules.VexFlowDefaultNotationFontScale,s.default.Flow.DEFAULT_TAB_FONT_SCALE=this.rules.VexFlowDefaultTabFontScale,this.pageIdx=0;for(const A of E.MusicPages){if(A.PageNumber>this.rules.MaxPageToDrawNumber)break;const v=this.backends[this.pageIdx];v.graphicalMusicPage=A,v.scale(this.zoom),this.pageIdx+=1}this.pageIdx=0,this.backend=this.backends[0],super.drawSheet(E)}drawPage(E){E&&(this.backend=this.backends[E.PageNumber-1],super.drawPage(E),this.pageIdx+=1)}clear(){for(const E of this.backends)E.clear()}setZoom(E){this.zoom=E}calculatePixelDistance(E){return E*g.unitInPixels}drawStaffLine(E){var A,v,B;const L=this.backend.getContext(),I=L.openGroup();I&&(I.classList.add("staffline"),E.ParentStaff&&(I.id=`${(A=E.ParentStaff.ParentInstrument)==null?void 0:A.Name}${(v=E.ParentStaff.ParentInstrument)==null?void 0:v.Id}-${(B=E.ParentStaff)==null?void 0:B.Id}`)),super.drawStaffLine(E);const T=E.PositionAndShape.AbsolutePosition;this.rules.RenderSlurs&&this.drawSlurs(E,T),this.rules.RenderGlissandi&&this.drawGlissandi(E,T),L.closeGroup()}drawSlurs(E,L){for(const I of E.GraphicalSlurs)I.slur.isCrossed()||this.drawSlur(I,L)}drawGlissandi(E,L){for(const I of E.GraphicalGlissandi)this.drawGlissando(I,L)}drawGlissando(E,L){if(E.StaffLine.ParentStaff.isTab||E.calculateLine(this.rules),E.Line){const I=new i.PointF2D(E.Line.Start.x+L.x,E.Line.Start.y),T=new i.PointF2D(E.Line.End.x+L.x,E.Line.End.y);E.Line.SVGElement=this.drawLine(I,T,E.Color,E.Width)}else{const I=E.vfTie;if(I){const T=this.backend.getContext();I.setContext(T),I.draw()}}}drawSlur(E,L){const I=[],T=new i.PointF2D(E.bezierStartPt.x+L.x,E.bezierStartPt.y+L.y),A=new i.PointF2D(E.bezierStartControlPt.x+L.x,E.bezierStartControlPt.y+L.y),v=new i.PointF2D(E.bezierEndControlPt.x+L.x,E.bezierEndControlPt.y+L.y),B=new i.PointF2D(E.bezierEndPt.x+L.x,E.bezierEndPt.y+L.y);I.push(this.applyScreenTransformation(T)),I.push(this.applyScreenTransformation(A)),I.push(this.applyScreenTransformation(v)),I.push(this.applyScreenTransformation(B)),E.placement===h.PlacementEnum.Above?(T.y-=.05,A.y-=.3,v.y-=.3,B.y-=.05):(T.y+=.05,A.y+=.3,v.y+=.3,B.y+=.05),I.push(this.applyScreenTransformation(T)),I.push(this.applyScreenTransformation(A)),I.push(this.applyScreenTransformation(v)),I.push(this.applyScreenTransformation(B));const D=this.rules.GNote(E.slur.StartNote);E.SVGElement=this.backend.renderCurve(I,!0,D)}drawMeasure(E){E.setAbsoluteCoordinates(E.PositionAndShape.AbsolutePosition.x*g.unitInPixels,E.PositionAndShape.AbsolutePosition.y*g.unitInPixels);try{E.draw(this.backend.getContext())}catch(I){p.default.warn("VexFlowMusicSheetDrawer.drawMeasure",I)}let L=0;for(const I of E.staffEntries)this.drawStaffEntry(I),L=this.drawBuzzRolls(I,L)}drawBuzzRolls(E,L){var I;for(const T of E.graphicalVoiceEntries)for(const A of T.notes)if((I=A.sourceNote.TremoloInfo)!=null&&I.tremoloUnmeasured){const v=this.rules.TremoloBuzzRollThickness,B=.9,D=.5,_=A;let F,k;const j=_.vfnote[0].getStemDirection();let P;if(this.backend instanceof d.SvgVexFlowBackend&&(P=_.getStemSVG()),(P==null?void 0:P.getBbox)!==void 0){const Q=P.getBBox();F=new i.PointF2D(Q.x/10,Q.y/10),k=Q.height/10}else k=_.vfnote[0].getStemLength()/10,F=new i.PointF2D(_.vfnote[0].getStem().x_begin/10,_.vfnote[0].getStem().y_top/10),j===1&&(F.y-=k);let G=F.y+k/3;_.vfnote[0].getBeamCount()>1&&(G=F.y+k/2,j===-1&&(G-=D+.2));const Y=F.x-.5,X=G,ie=[],oe=[new i.PointF2D(0,-v),new i.PointF2D(B-v,0),new i.PointF2D(-B+v,-D),new i.PointF2D(0,-v),new i.PointF2D(B,0),new i.PointF2D(0,v),new i.PointF2D(-B+v,0),new i.PointF2D(B-v,D),new i.PointF2D(0,v),new i.PointF2D(-B,0)];let $=new i.PointF2D(Y,X);ie.push($);for(const Q of oe)$=ie.last(),ie.push(new i.PointF2D($.x+Q.x,$.y-Q.y));this.DrawPath(ie,_.ParentMusicPage,!0,`buzzRoll${L}`),L++}return L}drawLine(E,L,I="#000000FF",T=.2){return E=this.applyScreenTransformation(E),L=this.applyScreenTransformation(L),this.backend.renderLine(E,L,I,T*g.unitInPixels)}DrawOverlayLine(E,L,I,T="#FF0000FF",A=.2,v){if(!I.PageNumber||I.PageNumber>this.backends.length||I.PageNumber<1)return void console.log("VexFlowMusicSheetDrawer.drawOverlayLine: invalid page number / music page number doesn't correspond to an existing backend.");const B=I.PageNumber-1,D=this.backends[B];return E=this.applyScreenTransformation(E),L=this.applyScreenTransformation(L),v||(v=`overlayLine ${E.x}/${E.y}`),D.renderLine(E,L,T,A*g.unitInPixels,v)}DrawPath(E,L,I=!0,T){const A=L.PageNumber-1,v=this.backends[A],B=[];for(const D of E)B.push(this.applyScreenTransformation(D));return v.renderPath(B,I,T)}drawSkyLine(E){const L=E.PositionAndShape.AbsolutePosition,I=E.PositionAndShape.Size.width;this.drawSampledLine(E.SkyLine,L,I)}drawBottomLine(E){const L=new i.PointF2D(E.PositionAndShape.AbsolutePosition.x,E.PositionAndShape.AbsolutePosition.y),I=E.PositionAndShape.Size.width;this.drawSampledLine(E.BottomLine,L,I,"#0000FFFF")}drawSampledLine(E,L,I,T="#FF0000FF"){const A=[];let v=0;for(let D=0;D0){const D=this.rules.SamplingUnit;let _,F,k=new i.PointF2D(B.x,B.y),j=new i.PointF2D(A[0]/D+B.x,B.y);this.drawLine(k,j,T),E[0]>=0&&(_=new i.PointF2D(A[0]/D+B.x,B.y),F=new i.PointF2D(A[0]/D+B.x,B.y+E[A[0]]),this.drawLine(_,F,T));for(let P=1;P0)for(const L of E.FingeringEntries)L.SVGNode=this.drawLabel(L,n.GraphicalLayers.Notes);if(E.graphicalChordContainers!==void 0&&E.graphicalChordContainers.length>0)for(const L of E.graphicalChordContainers){const I=L.GraphicalLabel;I.SVGNode=this.drawLabel(I,n.GraphicalLayers.Notes)}this.rules.RenderLyrics&&E.LyricsEntries.length>0&&this.drawLyrics(E.LyricsEntries,n.GraphicalLayers.Notes)}drawLyrics(E,L){E.forEach(I=>{var A;const T=I.GraphicalLabel;T.Label.colorDefault=this.rules.DefaultColorLyrics,T.SVGNode=this.drawLabel(T,L),(A=T.SVGNode)==null||A.classList.add("lyrics")})}drawInstrumentBrace(E,L){const I=this.backend.getContext();I.openGroup("brace"),E.draw(I),I.closeGroup()}drawGroupBracket(E,L){const I=this.backend.getContext();I.openGroup("bracket"),E.draw(I),I.closeGroup()}drawOctaveShifts(E){for(const L of E.OctaveShifts)if(L){const I=L,T=this.backend.getContext(),A=I.getTextBracket();this.rules.DefaultColorMusic&&(A.render_options.color=this.rules.DefaultColorMusic),A.setContext(T);try{A.draw()}catch(v){p.default.warn(v)}}}drawPedals(E){for(const L of E.Pedals)if(L){const I=L,T=this.backend.getContext(),A=I.getPedalMarking();A.render_options.color=this.rules.DefaultColorMusic,A.setContext(T),A.draw()}}drawWavyLines(E){for(const L of E.WavyLines)if(L){const I=L,T=this.backend.getContext(),A=I.getVibratoBracket();A.setContext(T),A.draw()}}drawExpressions(E){var L;for(const I of E.AbstractExpressions)if(I instanceof f.GraphicalInstantaneousDynamicExpression)this.drawInstantaneousDynamic(I);else if(I instanceof t.GraphicalInstantaneousTempoExpression){if(((L=I.SourceExpression.parentMeasure)==null?void 0:L.MeasureNumber)<=1&&!this.rules.RenderFirstTempoExpression)continue;const T=I.GraphicalLabel;T.SVGNode=this.drawLabel(T,n.GraphicalLayers.Notes)}else if(I instanceof m.GraphicalContinuousDynamicExpression)this.drawContinuousDynamic(I);else if(I instanceof y.GraphicalUnknownExpression){const T=I.Label;T.SVGNode=this.drawLabel(T,n.GraphicalLayers.Notes)}else p.default.warn("Unkown type of expression!")}drawInstantaneousDynamic(E){const L=E.Label;L.SVGNode=this.drawLabel(L,n.GraphicalLayers.Notes)}drawContinuousDynamic(E){if(E.IsVerbal){const L=E.Label;L.SVGNode=this.drawLabel(L,n.GraphicalLayers.Notes)}else for(const L of E.Lines){const I=new i.PointF2D(E.ParentStaffLine.PositionAndShape.AbsolutePosition.x+L.Start.x,E.ParentStaffLine.PositionAndShape.AbsolutePosition.y+L.Start.y),T=new i.PointF2D(E.ParentStaffLine.PositionAndShape.AbsolutePosition.x+L.End.x,E.ParentStaffLine.PositionAndShape.AbsolutePosition.y+L.End.y);L.SVGElement=this.drawLine(I,T,L.colorHex??"#000000",L.Width)}}renderLabel(E,L,I,T,A,v){var P;if(!E.Label.print)return;const B=E.Label.fontHeight*g.unitInPixels,{font:D}=E.Label;let _;this.rules.ColoringEnabled&&(_=E.Label.colorDefault,E.ColorXML&&(_=E.ColorXML),_||(_=this.rules.DefaultColorLabel));let F,{fontStyle:k,fontFamily:j}=E.Label;k||(k=this.rules.DefaultFontStyle),j||(j=this.rules.DefaultFontFamily);for(let G=0;G<((P=E.TextLines)==null?void 0:P.length);G++){const Y=E.TextLines[G],X=this.calculatePixelDistance(Y.xOffset),ie=new i.PointF2D(v.x+X,v.y),oe=this.backend.renderText(B,k,D,Y.text,A,ie,_,E.Label.fontFamily);F?F.appendChild(oe):F=oe,v.y=v.y+A,E.TextLines.length>1&&(v.y+=this.rules.SpacingBetweenTextLines)}return F}renderRectangle(E,L,I,T,A){return this.backend.renderRectangle(E,I,T,A)}applyScreenTransformation(E){return new i.PointF2D(E.x*g.unitInPixels,E.y*g.unitInPixels)}applyScreenTransformationForRect(E){return new r.RectangleF2D(E.x*g.unitInPixels,E.y*g.unitInPixels,E.width*g.unitInPixels,E.height*g.unitInPixels)}}g.VexFlowMusicSheetDrawer=S},4332(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.VexFlowMusicSystem=void 0;const l=c(5221),s=c(6954),u=c(67),r=c(4284),i=c(6014),o=c(3109),n=c(7098);class h extends l.MusicSystem{constructor(f,p){super(f),this.rules=p}calculateBorders(f){if(this.staffLines.length===0)return;const p=this.calcBracketsWidth();this.boundingBox.BorderLeft=-p,this.boundingBox.BorderMarginLeft=-p,this.boundingBox.XBordersHaveBeenSet=!0;const m=this.staffLines[0].SkyBottomLineCalculator.getSkyLineMin();this.boundingBox.BorderTop=m,this.boundingBox.BorderMarginTop=m;const x=this.staffLines[this.staffLines.length-1],y=x.SkyBottomLineCalculator.getBottomLineMax()+x.PositionAndShape.RelativePosition.y;this.boundingBox.BorderBottom=y,this.boundingBox.BorderMarginBottom=y,this.boundingBox.XBordersHaveBeenSet=!0,this.boundingBox.YBordersHaveBeenSet=!0}createSystemLine(f,p,m,x,y,d,S=void 0){const M=d;let E=!1;if(S){E=!0,S.addMeasureLine(m,x),M&&M.addMeasureLine(m,x,E);let L=0;if(m===s.SystemLinesEnum.BoldThinDots&&x===u.SystemLinePosition.MeasureBegin&&d.beginInstructionsWidth>0&&(L=M.getVFStave().getModifierXShift(0)),S.lineTo(d,i.VexFlowConverter.line(m,x),L),m===s.SystemLinesEnum.DotsBoldBoldDots){const I=S.ParentStaffLine.Measures.indexOf(S)+1,T=S.ParentStaffLine.Measures[I],A=d.ParentStaffLine.Measures[I];T&&A&&(T.lineTo(A,i.VexFlowConverter.line(s.SystemLinesEnum.BoldThinDots,x)),T.addMeasureLine(s.SystemLinesEnum.BoldThinDots,x))}}else M&&M.addMeasureLine(m,x,E);return new r.SystemLine(m,x,this,d,S)}createInstrumentBracket(f,p){const m=f,x=p,y=new n.VexFlowInstrumentBrace(m,x);this.InstrumentBrackets.push(y)}createGroupBracket(f,p,m){const x=f,y=p;if(m===0){const d=new o.VexFlowInstrumentBracket(x,y,m);this.GroupBrackets.push(d)}else{const d=new n.VexFlowInstrumentBrace(x,y,m);this.GroupBrackets.push(d)}}}g.VexFlowMusicSystem=h},9310(de,g,c){var l=this&&this.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(g,"__esModule",{value:!0}),g.VexFlowOctaveShift=void 0;var s=l(c(3206)).default.Flow;const u=c(2768),r=c(437),i=l(c(3065));class o extends u.GraphicalOctaveShift{constructor(h,t){switch(super(h,t),h.Type){case r.OctaveEnum.VA8:this.position=s.TextBracket.Positions.TOP,this.supscript="va",this.text="8";break;case r.OctaveEnum.MA15:this.position=s.TextBracket.Positions.TOP,this.supscript="ma",this.text="15";break;case r.OctaveEnum.VB8:this.position=s.TextBracket.Positions.BOTTOM,this.supscript="vb",this.text="8";break;case r.OctaveEnum.MB15:this.position=s.TextBracket.Positions.BOTTOM,this.supscript="mb",this.text="15";break;default:i.default.error("Unknown or NONE octaveshift. This should not be called!")}}setStartNote(h){for(const t of h.graphicalVoiceEntries){const f=t;if(f!=null&&f.vfStaveNote)return this.startNote=f.vfStaveNote,!0}return!1}setEndNote(h,t=-1){var p;const f=h.graphicalVoiceEntries;for(let m=(t>=0?Math.min(t,f.length):f.length)-1;m>=0;m--){const x=f[m];if(x!=null&&x.vfStaveNote)return this.endNote=x.vfStaveNote,this.endMeasure=h.parentMeasure,(p=this.endMeasure)!=null&&p.parentSourceMeasure.Rules.OctaveShiftOnWholeMeasureNoteUntilEndOfMeasure&&x.notes[0].sourceNote.isWholeMeasureNote()&&(this.graphicalEndAtMeasureEnd=!0),!0}return!1}getTextBracket(){let h,t=this.endNote;const f=this;this.graphicalEndAtMeasureEnd&&(h={getAbsoluteX:()=>10*(f.endMeasure.PositionAndShape.AbsolutePosition.x+f.endMeasure.PositionAndShape.Size.width),getGlyph:()=>({getWidth:()=>0})}),h&&(t=h);const p=new s.TextBracket({position:this.position,start:this.startNote,stop:t,superscript:this.supscript,text:this.text});return this.endsOnDifferentStaffLine&&(p.render_options.show_bracket=!1),p}}g.VexFlowOctaveShift=o},7109(de,g,c){var l=this&&this.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(g,"__esModule",{value:!0}),g.VexFlowPedal=void 0;const s=l(c(3206)),u=c(6438),r=c(7824),i=c(512);class o extends r.GraphicalPedal{constructor(h,t,f=!1,p=!1){switch(super(h,t),this.vfStyle=s.default.Flow.PedalMarking.Styles.BRACKET,this.ChangeBegin=!1,this.ChangeEnd=!1,this.line=-3,this.EndSymbolPositionAndShape=void 0,this.ChangeBegin=h.ChangeBegin,this.ChangeEnd=h.ChangeEnd,this.pedalSymbol){case i.MusicSymbol.PEDAL_SYMBOL:this.vfStyle=s.default.Flow.PedalMarking.Styles.TEXT,this.EndSymbolPositionAndShape=new u.BoundingBox(this,t);break;case i.MusicSymbol.PEDAL_MIXED:this.vfStyle=f&&p?s.default.Flow.PedalMarking.Styles.BRACKET_OPEN_BOTH:f?s.default.Flow.PedalMarking.Styles.BRACKET_OPEN_BEGIN:p?s.default.Flow.PedalMarking.Styles.MIXED_OPEN_END:s.default.Flow.PedalMarking.Styles.MIXED;break;case i.MusicSymbol.PEDAL_BRACKET:default:this.vfStyle=f&&p?s.default.Flow.PedalMarking.Styles.BRACKET_OPEN_BOTH:f?s.default.Flow.PedalMarking.Styles.BRACKET_OPEN_BEGIN:p?s.default.Flow.PedalMarking.Styles.BRACKET_OPEN_END:s.default.Flow.PedalMarking.Styles.BRACKET}}setStartNote(h){if(!h)return!1;for(const t of h.graphicalVoiceEntries){const f=t;if(f!=null&&f.vfStaveNote)return this.startNote=f.vfStaveNote,this.startVfVoiceEntry=f,!0}return!1}setEndNote(h){if(!h)return!1;for(const t of h.graphicalVoiceEntries){const f=t;if(f!=null&&f.vfStaveNote)return this.endNote=f.vfStaveNote,this.endVfVoiceEntry=f,!0}return!1}setEndMeasure(h){this.endMeasure=h}CalculateBoundingBox(){}setLine(h){this.line=h}getPedalMarking(){const h=new s.default.Flow.PedalMarking([this.startNote,this.endNote]);return this.endMeasure&&h.setEndStave(this.endMeasure.getVFStave()),h.setStyle(this.vfStyle),h.setLine(this.line),h.setCustomText(this.DepressText,this.ReleaseText),this.endVfVoiceEntry&&!this.getPedal.EndsStave||(h.EndsStave=!0),this.getPedal.BeginsStave&&(h.BeginsStave=!0),h.ChangeBegin=this.ChangeBegin,h.ChangeEnd=this.ChangeEnd,h}setEndsStave(h,t){t!=null&&t.gte(h.parentSourceMeasure.Duration)&&(this.getPedal.EndsStave=!0)}setBeginsStave(h,t){h&&t.RealValue===0&&(this.getPedal.BeginsStave=!0)}}g.VexFlowPedal=o},5468(de,g,c){var l=this&&this.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(g,"__esModule",{value:!0}),g.VexFlowSlur=g.CurvePositionEnum=void 0;var s,u=l(c(3206)).default.Flow;(function(i){i[i.NEAR_HEAD=1]="NEAR_HEAD",i[i.NEAR_TOP=2]="NEAR_TOP"})(s||(g.CurvePositionEnum=s={}));class r{constructor(o){this.vfStartNote=void 0,this.vfEndNote=void 0,this.parentSlur=o}static createFromVexflowSlur(o){return new r(o.parentSlur)}get vfSlur(){return this.parentSlur}curve_Options(){return{cps:[{x:0,y:10},{x:0,y:10}],invert:!1,position:s.NEAR_TOP,position_end:s.NEAR_TOP,spacing:2,thickness:2,x_shift:0,y_shift:10}}createVexFlowCurve(){this.vfCurve=new u.Curve(this.vfStartNote,this.vfEndNote,void 0)}}g.VexFlowSlur=r},6670(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.VexFlowStaffEntry=void 0;const l=c(348),s=c(9479),u=c(8233);class r extends l.GraphicalStaffEntry{constructor(o,n,h){super(o,n,h)}calculateXPosition(){const o=this.parentMeasure.getVFStave();let n=0;for(const h of this.graphicalVoiceEntries)if(h.vfStaveNote){if(h.vfStaveNote.setStave(o),!h.vfStaveNote.preFormatted)continue;h.applyBordersFromVexflow();let t=!1,f=this.PositionAndShape;h.notes[0].sourceNote.isWholeRest()&&!this.hasOnlyRests()&&(t=!0,f=h.PositionAndShape),this.parentMeasure.ParentStaff.isTab?f.RelativePosition.x=(h.vfStaveNote.getAbsoluteX()+h.vfStaveNote.glyph.getWidth())/s.unitInPixels:(f.RelativePosition.x=h.vfStaveNote.getBoundingBox().getX()/s.unitInPixels,t&&(f.RelativePosition.x-=o.getNoteStartX()/s.unitInPixels,f.RelativePosition.x-=1.3));const p=h.notes[0].sourceNote;p.isRest()&&p.Length.RealValue===this.parentMeasure.parentSourceMeasure.ActiveTimeSignature.RealValue&&(f.RelativePosition.x+=this.parentMeasure.parentSourceMeasure.Rules.WholeRestXShiftVexflow-.1,h.PositionAndShape.BorderLeft=-.7,h.PositionAndShape.BorderRight=.7),h.PositionAndShape.BorderLeftf.staffLine),h=this.calculateModifierXOffsets(n,.5),t=this.calculateModifierXOffsets(n,1);o.forEach((f,p)=>{f.baseFingeringXOffset=h[p],f.baseStringNumberXOffset=t[p]})}calculateModifierXOffsets(o,n){const h=[];for(let t=0;t=0;m--){if(Math.abs(o[t]-o[m])<=n&&f===h[m]){f++,p=!0;break}p=!1}h.push(f)}return h}}g.VexFlowStaffEntry=r},5866(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.VexFlowStaffLine=void 0;const l=c(2919),s=c(1083);class u extends l.StaffLine{constructor(i,o){super(i,o),this.slursInVFStaffLine=[],this.alignmentManager=new s.AlignmentManager(this)}get SlursInVFStaffLine(){return this.slursInVFStaffLine}addVFSlurToVFStaffline(i){this.slursInVFStaffLine.push(i)}get AlignmentManager(){return this.alignmentManager}}g.VexFlowStaffLine=u},6173(de,g,c){var l=this&&this.__importDefault||function(h){return h&&h.__esModule?h:{default:h}};Object.defineProperty(g,"__esModule",{value:!0}),g.VexFlowTabMeasure=void 0;var s=l(c(3206)).default.Flow;const u=c(5246),r=c(6014),i=l(c(3065)),o=c(164);class n extends u.VexFlowMeasure{constructor(t,f=void 0,p=void 0){super(t,f,p),this.isTabMeasure=!0}resetLayout(){const t=this.ParentStaff.StafflineCount??6;this.stave=new s.TabStave(0,0,0,{space_above_staff_ln:0,space_below_staff_ln:0,num_lines:t}),this.updateInstructionWidth()}graphicalMeasureCreatedCalculations(){for(let f=0,p=this.staffEntries.length;f1){const d=r.VexFlowConverter.StrokeTypeFromArpeggioType(y.type),S=new s.Stroke(d,{all_voices:this.rules.ArpeggiosGoAcrossVoices});this.rules.RenderArpeggios&&x.vfStaveNote.addStroke(0,S)}else i.default.debug(`[OSMD] arpeggio in measure ${this.MeasureNumber} could not be drawn. voice entry had less than two notes, arpeggio is likely between voice entries, not currently supported in Vexflow.`)}if(x.vfGhostNotes)for(const y of x.vfGhostNotes)this.vfVoices[f.VoiceId].addTickable(y);else this.vfVoices[f.VoiceId].addTickable(x.vfStaveNote)}else if(x.vfGhostNotes)for(const y of x.vfGhostNotes)this.vfVoices[f.VoiceId].addTickable(y);else this.vfVoices[f.VoiceId].addTickable(x.vfStaveNote)}}}addClefAtBegin(t){t.ClefType===o.ClefEnum.TAB&&super.addClefAtBegin(t)}draw(t){super.draw(t);const f=this.parentSourceMeasure;f.multipleRestMeasures&&this.rules.RenderMultipleRestMeasures&&(this.multiRestElement=new s.MultiMeasureRest(f.multipleRestMeasures,{}),this.multiRestElement.setStave(this.stave),this.multiRestElement.setContext(t),this.multiRestElement.draw())}}g.VexFlowTabMeasure=n},7785(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.VexFlowTextMeasurer=void 0;const l=c(6014);g.VexFlowTextMeasurer=class{constructor(s){this.fontSize=20,this.fontSizeStandard=this.fontSize;const u=document.createElement("canvas");this.context=u.getContext("2d"),this.rules=s}computeTextWidthToHeightRatio(s,u,r,i=void 0,o=this.fontSize){return this.context.font=l.VexFlowConverter.font(o,r,u,this.rules,i),this.context.measureText(s).width/o}setFontSize(s=this.fontSizeStandard){return this.fontSize=s,s}}},2907(de,g,c){var l=this&&this.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(g,"__esModule",{value:!0}),g.VexFlowVibratoBracket=void 0;const s=c(7753),u=l(c(3206));class r extends s.GraphicalWavyLine{get ToEndOfStopStave(){return this.toEndOfStopStave}constructor(o,n,h=!1){super(o,n),this.line=1,this.isVibrato=!1,this.toEndOfStopStave=!1,this.isVibrato=h}setStartNote(o){for(const n of o.graphicalVoiceEntries){const h=n;if(h!=null&&h.vfStaveNote)return this.startNote=h.vfStaveNote,this.startVfVoiceEntry=h,!0}return!1}setEndNote(o){for(const n of o.graphicalVoiceEntries){const h=n;if(h!=null&&h.vfStaveNote){this.endNote=h.vfStaveNote,this.endVfVoiceEntry=h;const t=this.endVfVoiceEntry.parentStaffEntry.parentMeasure.staffEntries,f=t[t.length-1];return this.toEndOfStopStave=f===this.endVfVoiceEntry.parentStaffEntry,!0}}return!1}CalculateBoundingBox(){const o=this.getVibratoBracket();this.boundingBox.Size.height=.2*o.render_options.wave_height}getVibratoBracket(){const o=new u.default.Flow.VibratoBracket({start:this.startNote,stop:this.endNote,toEndOfStopStave:this.toEndOfStopStave});return o.setLine(this.line),this.isVibrato?o.render_options.vibrato_width=20:o.render_options.wave_girth=4,o}}g.VexFlowVibratoBracket=r},4134(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.VexFlowVoiceEntry=void 0;const l=c(4548),s=c(9479),u=c(4434),r=c(4064);class i extends l.GraphicalVoiceEntry{constructor(n,h,t){super(n,h,t)}applyBordersFromVexflow(){const n=this.vfStaveNote;if(!n.getNoteHeadBeginX)return;const h=n.getBoundingBox(),t=n.getNoteHeadBeginX()-h.x;this.PositionAndShape.RelativePosition.y=h.y/s.unitInPixels,this.PositionAndShape.BorderTop=0,this.PositionAndShape.BorderBottom=h.h/s.unitInPixels;const f=(n.width-(n.paddingRight??0))/2;this.PositionAndShape.BorderLeft=-(t+f)/s.unitInPixels,this.PositionAndShape.BorderRight=(h.w-t)/s.unitInPixels}set vfStaveNote(n){this.mVexFlowStaveNote=n}get vfStaveNote(){return this.mVexFlowStaveNote}applyCustomNoteheads(){const n=this.vfStaveNote;if(n)for(let h=0;hh.length-1)return-1;for(let p=f;pthis.rules.PercussionOneLineCutoff&&!p&&!this.rules.PercussionUseCajon2NoteSystem)return h;const m=h,x=h.sourceNote.Pitch;let y=this.baseLineNote,d=this.baseLineOctave;if(this.rules.PercussionUseCajon2NoteSystem?x.FundamentalNote===l.NoteEnum.C&&(y=l.NoteEnum.G,d=1):this.rules.PercussionUseXMLDisplayStep&&h.sourceNote.displayStepUnpitched!==void 0&&(y=h.sourceNote.displayStepUnpitched,d=h.sourceNote.displayOctaveUnpitched+this.rules.PercussionOneLineXMLDisplayStepOctaveOffset),f.length<=this.rules.PercussionForceVoicesOneLineCutoff)m.setAccidental(new l.Pitch(y,d,x.Accidental));else{const S=o.PitchIndexOf(f,x);if(S>-1){const M=Math.ceil(f.length/2);if(!this.rules.PercussionUseXMLDisplayStep)if(S>=M)switch(d=2,(S-M)%5){case 1:y=l.NoteEnum.E;break;case 2:y=l.NoteEnum.G;break;case 3:y=l.NoteEnum.B;break;case 4:y=l.NoteEnum.D,d=3;break;default:y=l.NoteEnum.C}else switch(S%5){case 1:y=l.NoteEnum.F;break;case 2:y=l.NoteEnum.D;break;case 3:y=l.NoteEnum.B,d=0;break;case 4:y=l.NoteEnum.G,d=0;break;default:y=l.NoteEnum.A}const E=new l.Pitch(y,d,x.Accidental);m.setAccidental(E);const L=m.parentVoiceEntry.parentVoiceEntry;!this.rules.SetWantedStemDirectionByXml&&L.Notes.length<2&&(E.Octave>this.baseLineOctave||E.FundamentalNote===this.baseLineNote&&E.Octave===this.baseLineOctave?m.parentVoiceEntry.parentVoiceEntry.WantedStemDirection=i.StemDirectionType.Up:m.parentVoiceEntry.parentVoiceEntry.WantedStemDirection=i.StemDirectionType.Down)}}return m}getStafflineUniquePositionCount(h){return this.staffPitchListMapping.containsKey(h)?this.staffPitchListMapping.getValue(h).length:0}}g.VexflowStafflineNoteCalculator=o},7499(de,g,c){var l=this&&this.__createBinding||(Object.create?function(u,r,i,o){o===void 0&&(o=i);var n=Object.getOwnPropertyDescriptor(r,i);n&&!("get"in n?!r.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return r[i]}}),Object.defineProperty(u,o,n)}:function(u,r,i,o){o===void 0&&(o=i),u[o]=r[i]}),s=this&&this.__exportStar||function(u,r){for(var i in u)i==="default"||Object.prototype.hasOwnProperty.call(r,i)||l(r,u,i)};Object.defineProperty(g,"__esModule",{value:!0}),s(c(1083),g),s(c(9834),g),s(c(9436),g),s(c(1902),g),s(c(2400),g),s(c(6014),g),s(c(1216),g),s(c(9635),g),s(c(3753),g),s(c(7809),g),s(c(7098),g),s(c(3109),g),s(c(5246),g),s(c(3849),g),s(c(806),g),s(c(9479),g),s(c(4332),g),s(c(9310),g),s(c(5468),g),s(c(6670),g),s(c(5866),g),s(c(7506),g),s(c(6173),g),s(c(7785),g),s(c(4134),g)},3508(de,g,c){var l=this&&this.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(g,"__esModule",{value:!0}),g.WebGLSkyBottomLineBatchCalculatorBackend=void 0;const s=c(5479),u=c(3667),r=l(c(5340)),i=l(c(5166)),o=l(c(3065)),n=c(813);function h(f,p,m){const x=f.createShader(p);if(!x)throw o.default.warn("WebGLSkyBottomLineCalculatorBackend: Could not create a WebGL shader"),new Error("Could not create a WebGL shader");if(f.shaderSource(x,m),f.compileShader(x),!f.getShaderParameter(x,f.COMPILE_STATUS))throw o.default.warn(`Shader compilation failed `+f.getShaderInfoLog(x)),f.deleteShader(x),new Error("WebGL shader compilation failed");return x}class t extends u.SkyBottomLineBatchCalculatorBackend{constructor(p,m){super(p,m)}getPreferredRenderingConfiguration(p,m){const x=Math.min(4096,function(){const d=document.createElement("canvas").getContext("webgl");return d.getParameter(d.MAX_TEXTURE_SIZE)}()),y=Math.ceil(p);return{elementWidth:y,numColumns:Math.min(5,Math.floor(x/y)),numRows:Math.min(5,Math.floor(x/m))}}onInitialize(p){const{elementWidth:m,elementHeight:x,numColumns:y,numRows:d}=p,S=document.createElement("canvas");S.width=m*y,S.height=d;const M=S.getContext("webgl");if(!M)throw o.default.warn("WebGLSkyBottomLineCalculatorBackend: No WebGL support"),new Error("No WebGL support");this.gl=M;const E=function(L,I,T){const A=L.createProgram();if(!A)throw o.default.warn("WebGLSkyBottomLineCalculatorBackend: Could not create a WebGL program"),new Error("Could not create a WebGL program");if(L.attachShader(A,I),L.attachShader(A,T),L.linkProgram(A),!L.getProgramParameter(A,L.LINK_STATUS))throw o.default.warn(`WebGLSkyBottomLineCalculatorBackend: WebGL program link failed `+L.getProgramInfoLog(A)),L.deleteProgram(A),new Error("WebGL program link failed");return A}(M,h(M,M.VERTEX_SHADER,r.default),h(M,M.FRAGMENT_SHADER,function(L,I){let T=L;for(const[A,v]of Object.entries(I)){const B=new RegExp(`#define ${A} .*`);T=T.replace(B,`#define ${A} ${v}`)}return T}(i.default,{NUM_ROWS:d,ELEMENT_HEIGHT:x})));(function(L,I){const T=L.createBuffer();if(!T)throw o.default.warn("WebGLSkyBottomLineCalculatorBackend: WebGL buffer creation failed"),new Error("WebGL buffer creation failed");L.bindBuffer(L.ARRAY_BUFFER,T),L.bufferData(L.ARRAY_BUFFER,new Float32Array(n.CollectionUtil.flat([[-1,-1],[1,-1],[1,1],[-1,-1],[1,1],[-1,1]])),L.STATIC_DRAW),L.useProgram(I);const A=L.getAttribLocation(I,"a_position");L.enableVertexAttribArray(A),L.vertexAttribPointer(A,2,L.FLOAT,!1,0,0)})(M,E),this.texture=function(L,I){const T=L.createTexture();if(!T)throw o.default.warn("WebGLSkyBottomLineCalculatorBackend: WebGL texture creation failed"),new Error("WebGL texture creation failed");L.activeTexture(L.TEXTURE0+0),L.bindTexture(L.TEXTURE_2D,T),L.texParameteri(L.TEXTURE_2D,L.TEXTURE_WRAP_S,L.CLAMP_TO_EDGE),L.texParameteri(L.TEXTURE_2D,L.TEXTURE_WRAP_T,L.CLAMP_TO_EDGE),L.texParameteri(L.TEXTURE_2D,L.TEXTURE_MIN_FILTER,L.NEAREST),L.texParameteri(L.TEXTURE_2D,L.TEXTURE_MAG_FILTER,L.NEAREST);const A=L.getUniformLocation(I,"u_image");if(!A)throw o.default.warn("WebGLSkyBottomLineCalculatorBackend: WebGL invalid uniform name"),new Error("WebGL invalid uniform name");return L.uniform1i(A,0),T}(M,E)}calculateFromCanvas(p,m,x,y,d){const S=this.gl,{elementWidth:M,elementHeight:E,numColumns:L}=d;S.viewport(0,0,S.canvas.width,S.canvas.height),S.bindTexture(S.TEXTURE_2D,this.texture),S.texImage2D(S.TEXTURE_2D,0,S.RGBA,S.RGBA,S.UNSIGNED_BYTE,p),S.drawArrays(S.TRIANGLES,0,6);const I=new Uint8Array(S.canvas.width*S.canvas.height*4);S.readPixels(0,0,S.canvas.width,S.canvas.height,S.RGBA,S.UNSIGNED_BYTE,I);const T=[];for(let A=0;A0&&this.Voices[0].Visible}isVisible(){if(!this.Visible)return!1;for(const o of this.Staves)if(o.Visible)return!0;return!1}set Visible(o){for(let n=0,h=this.Voices.length;n=0;o--)if(i=this.timestamps[o],r.gte(i.$from))return i;return this.timestamps[0]}absoluteEnrolledToSheetTimestamp(r){if(this.timestamps.length===0)return r;const i=this.getCurrentRepetitionTimestampTransform(r);return l.Fraction.plus(r,l.Fraction.minus(i.to,i.$from))}get Parts(){return this.parts}get MusicSheet(){return this.musicSheet}getIterator(r){return r?new s.MusicPartManagerIterator(this.musicSheet,r,void 0):new s.MusicPartManagerIterator(this.musicSheet,this.musicSheet.SelectionStart,this.musicSheet.SelectionEnd)}setSelectionStart(r){this.musicSheet.SelectionStart=r,this.musicSheet.SelectionEnd=void 0}setSelectionRange(r,i){this.musicSheet.SelectionStart=r??this.sheetStart,this.musicSheet.SelectionEnd=i??this.sheetEnd}calcMapping(){const r=[],i=this.getIterator();let o=i.CurrentRepetition,n=new u(i.CurrentEnrolledTimestamp.clone(),i.CurrentSourceTimestamp.clone(),void 0,0);for(r.push(n);!i.EndReached;){if(i.JumpOccurred||o!==i.CurrentRepetition){if(o=i.CurrentRepetition,i.backJumpOccurred){const h=i.JumpResponsibleRepetition;n.nextBackJump=i.CurrentEnrolledTimestamp,n.curRepetition=h,n.curRepetitionIteration=i.CurrentJumpResponsibleRepetitionIterationBeforeJump;for(let t=this.timestamps.length-2;t>=0&&!r[t].to.lt(h.AbsoluteTimestamp)&&!r[t].curRepetition;t--)r[t].nextBackJump=n.nextBackJump,r[t].curRepetition=h,r[t].curRepetitionIteration=n.curRepetitionIteration}n=new u(i.CurrentEnrolledTimestamp.clone(),i.CurrentSourceTimestamp.clone(),void 0,0),r.push(n)}i.moveToNext()}this.timestamps=r}};class u{constructor(i,o,n,h){this.$from=i,this.to=o,this.curRepetition=n,this.curRepetitionIteration=h,this.nextBackJump=void 0,this.nextForwardJump=void 0}}g.TimestampTransform=u},474(de,g,c){var l=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(g,"__esModule",{value:!0}),g.MusicPartManagerIterator=void 0;const s=c(2561),u=c(1110),r=c(9288),i=c(5875),o=l(c(3065)),n=c(4064);class h{constructor(f,p,m){this.currentMeasureIndex=0,this.currentPartIndex=0,this.currentVoiceEntryIndex=-1,this.currentDynamicEntryIndex=0,this.currentTempoEntryIndex=0,this.currentDynamicChangingExpressions=[],this.repetitionIterationCountDictKeys=[],this.repetitionIterationCountDictValues=[],this.currentRepetition=void 0,this.endReached=!1,this.frontReached=!1,this.currentTimeStamp=new s.Fraction(0,1),this.currentEnrolledMeasureTimestamp=new s.Fraction(0,1),this.currentRelativeInMeasureTimestamp=new s.Fraction(0,1),this.currentVerticalContainerInMeasureTimestamp=new s.Fraction(0,1),this.jumpResponsibleRepetition=void 0,this.activeDynamicExpressions=[],this.SkipInvisibleNotes=!0;try{this.frontReached=!0,this.musicSheet=f,this.currentBpm=f.userStartTempoInBPM,this.currentVoiceEntries=void 0,this.frontReached=!1;for(const x of this.musicSheet.Repetitions)this.setRepetitionIterationCount(x,1);for(let x=0;x0&&(this.currentBpm=p)}else this.musicSheet.IgnoreTempoInstructions||(f=this.CurrentTempoChangingExpression.InstantaneousTempo)!=null&&f.TempoInBpm&&(this.currentBpm=this.CurrentTempoChangingExpression.InstantaneousTempo.TempoInBpm)}moveToNextVisibleVoiceEntry(f){for(;!this.endReached;)if(this.moveToNext(),this.checkEntries(f))return}resetRepetitionIterationCount(f){return this.setRepetitionIterationCount(f,1),1}incrementRepetitionIterationCount(f){return this.repetitionIterationCountDictKeys.indexOf(f)===-1?this.setRepetitionIterationCount(f,1):this.setRepetitionIterationCount(f,this.getRepetitionIterationCount(f)+1)}setRepetitionIterationCount(f,p){const m=this.repetitionIterationCountDictKeys.indexOf(f);return m===-1?(this.repetitionIterationCountDictKeys.push(f),this.repetitionIterationCountDictValues.push(p)):this.repetitionIterationCountDictValues[m]=p,p}getRepetitionIterationCount(f){const p=this.repetitionIterationCountDictKeys.indexOf(f);if(p!==-1)return this.repetitionIterationCountDictValues[p]}handleRepetitionsAtMeasureBegin(){for(let f=0,p=this.currentMeasure.FirstRepetitionInstructions.length;f=this.JumpResponsibleRepetition.StartIndex&&x.EndIndex<=this.JumpResponsibleRepetition.EndIndex&&this.resetRepetitionIterationCount(x)}}handleRepetitionsAtMeasureEnd(){for(let f=0,p=this.currentMeasure.LastRepetitionInstructions.length;f-1&&this.getRepetitionIterationCount(x)=this.JumpResponsibleRepetition.StartIndex&&x.EndIndex<=this.JumpResponsibleRepetition.EndIndex&&this.resetRepetitionIterationCount(x),this.repetitionIterationCountDictKeys.contains(x))){const y=x.getForwardJumpTargetForIteration(this.getRepetitionIterationCount(x));if(y>=0)return this.currentMeasureIndex=y,this.currentMeasure=this.musicSheet.SourceMeasures[this.currentMeasureIndex],this.currentVoiceEntryIndex=-1,this.jumpResponsibleRepetition=x,void(this.forwardJumpOccurred=!0);y===-2&&(this.endReached=!0)}}}this.currentMeasureIndex++,this.JumpResponsibleRepetition!==void 0&&this.currentMeasureIndex>this.JumpResponsibleRepetition.EndIndex&&(this.jumpResponsibleRepetition=void 0)}doBackJump(f){f.SkipRepetition||this.musicSheet.Rules.CursorIgnoreRepetitions||(this.currentMeasureIndex=f.getBackwardJumpTarget(),this.currentMeasure=this.musicSheet.SourceMeasures[this.currentMeasureIndex],this.currentVoiceEntryIndex=-1,this.incrementRepetitionIterationCount(f),this.jumpResponsibleRepetition=f,this.backJumpOccurred=!0)}activateCurrentRhythmInstructions(){if(this.currentMeasure!==void 0&&this.currentMeasure.FirstInstructionsStaffEntries.length>0&&this.currentMeasure.FirstInstructionsStaffEntries[0]!==void 0){const f=this.currentMeasure.FirstInstructionsStaffEntries[0].Instructions;for(let p=0,m=f.length;p0&&(this.currentDynamicEntryIndex>=f.length||f[this.currentDynamicEntryIndex].parMultiExpression().AbsoluteTimestamp.gte(this.CurrentSourceTimestamp));)this.currentDynamicEntryIndex--;for(;this.currentDynamicEntryIndex0&&(this.currentTempoEntryIndex>=p.length||p[this.currentTempoEntryIndex].AbsoluteTimestamp.gte(this.CurrentSourceTimestamp));)this.currentTempoEntryIndex--;for(;this.currentTempoEntryIndex0){this.currentVoiceEntryIndex--;const f=this.currentMeasure.VerticalSourceStaffEntryContainers[this.currentVoiceEntryIndex];this.currentVoiceEntries=this.getVoiceEntries(f),this.currentVerticalContainerInMeasureTimestamp=f.Timestamp,this.currentRelativeInMeasureTimestamp=this.currentVerticalContainerInMeasureTimestamp,this.currentTimeStamp=s.Fraction.plus(this.currentMeasure.AbsoluteTimestamp,this.currentVerticalContainerInMeasureTimestamp),this.activateCurrentDynamicOrTempoInstructions();const p=this.musicSheet.SelectionEnd;return p&&this.currentTimeStamp.lt(p)&&(this.endReached=!1),void(this.currentMeasureIndex=this.musicSheet.SourceMeasures.indexOf(this.CurrentMeasure))}if(this.currentVoiceEntryIndex===0&&this.currentMeasureIndex!==0){const f=this.musicSheet.SourceMeasures[this.currentMeasureIndex-1];this.currentMeasureIndex--,this.currentMeasure=this.musicSheet.SourceMeasures[this.currentMeasureIndex];const p=f.VerticalSourceStaffEntryContainers[f.VerticalSourceStaffEntryContainers.length-1];this.currentVoiceEntries=this.getVoiceEntries(p),this.currentVerticalContainerInMeasureTimestamp=p.Timestamp,this.currentVoiceEntryIndex=f.VerticalSourceStaffEntryContainers.length-1,this.currentRelativeInMeasureTimestamp=this.currentVerticalContainerInMeasureTimestamp,this.currentTimeStamp=s.Fraction.plus(this.currentMeasure.AbsoluteTimestamp,p.Timestamp),this.activateCurrentDynamicOrTempoInstructions();const m=this.musicSheet.SelectionEnd;return void(m&&this.currentTimeStamp.lt(m)&&(this.endReached=!1))}this.frontReached=!0,this.currentTimeStamp=new s.Fraction(-1,1)}recursiveMove(){if(this.currentVoiceEntryIndex++,this.currentVoiceEntryIndex===0&&(this.handleRepetitionsAtMeasureBegin(),this.activateCurrentRhythmInstructions()),this.currentVoiceEntryIndex>=0&&this.currentVoiceEntryIndex=0&&this.currentMeasureIndex0){if(!f)return!0;for(let m=0,x=p.length;m0){const d=this.TimestampSortedTempoExpressionsList[0];if(d.InstantaneousTempo)return d.InstantaneousTempo.TempoInBpm;if(d.ContinuousTempo)return d.ContinuousTempo.StartTempo}return this.userStartTempoInBPM}get Errors(){return this.musicSheetErrors.measureErrors}get FirstMeasureNumber(){try{return this.getFirstSourceMeasure().MeasureNumber}catch(d){return f.default.info("MusicSheet.FirstMeasureNumber: ",d),0}}get LastMeasureNumber(){try{return this.getLastSourceMeasure().MeasureNumber}catch(d){return f.default.info("MusicSheet.LastMeasureNumber: ",d),0}}get CurrentEnrolledPosition(){return this.currentEnrolledPosition.clone()}set CurrentEnrolledPosition(d){this.currentEnrolledPosition=d.clone()}get Transpose(){return this.transpose}set Transpose(d){this.transpose=d}get FullNameString(){return this.ComposerString+" "+this.TitleString}get IdString(){return this.idString}set IdString(d){this.idString=d}getEnrolledSelectionStartTimeStampWorkaround(){const d=this.MusicPartManager.getIterator(this.SelectionStart);return s.Fraction.createFromFraction(d.CurrentEnrolledTimestamp)}get SheetEndTimestamp(){const d=this.getLastSourceMeasure();return s.Fraction.plus(d.AbsoluteTimestamp,d.Duration)}getSourceMeasureFromTimeStamp(d){for(let S=0,M=this.sourceMeasures.length;S0&&E.Voices[0].Visible&&d.push(E)}return d}}g.MusicSheet=x,x.defaultTitle="defaultTitle"},1325(de,g){Object.defineProperty(g,"__esModule",{value:!0}),g.MappingSourceMusicPart=void 0,g.MappingSourceMusicPart=class{constructor(c,l,s,u=-1,r=!1){this.repetitionRun=-1,this.sourceMusicPart=c,this.parentPartListEntry=s,this.startTimestamp=l.clone(),this.repetitionRun=u,this.parentRepetition=s,this.isEnding=r}get IsRepetition(){return this.parentRepetition!==void 0}get IsEnding(){return this.isEnding}get IsLastRepetitionRun(){return this.IsRepetition&&this.repetitionRun+1===this.parentRepetition.UserNumberOfRepetitions}get RepetitionRun(){return this.repetitionRun}get ParentPartListEntry(){return this.parentPartListEntry}get SourceMusicPart(){return this.sourceMusicPart}get StartTimestamp(){return this.startTimestamp}CompareTo(c){return c?this.startTimestamp.CompareTo(c.startTimestamp):1}}},7551(de,g){Object.defineProperty(g,"__esModule",{value:!0}),g.PartListEntry=void 0,g.PartListEntry=class{constructor(c){this.enrolledTimestamps=[],this.visible=!0,this.musicSheet=c}get Visible(){return this.visible}set Visible(c){this.visible=c}getFirstSourceMeasure(){return this.musicSheet.SourceMeasures[this.startIndex]}getLastSourceMeasure(){return this.musicSheet.SourceMeasures[this.endIndex]}}},6001(de,g,c){var l=this&&this.__importDefault||function(h){return h&&h.__esModule?h:{default:h}};Object.defineProperty(g,"__esModule",{value:!0}),g.RepetitionEndingPart=g.Repetition=void 0;const s=c(3457),u=c(2561),r=c(7551),i=l(c(3065));class o extends r.PartListEntry{constructor(t,f=!1){super(t),this.SkipRepetition=!1,this.userNumberOfRepetitions=0,this.backwardJumpInstructions=[],this.endingParts=[],this.endingIndexDict={},this.visibles=[],this.fromWords=!1,this.repetitonIterationOrder=[],this.numberOfEndings=1,this.musicSheet2=t,this.virtualOverallRepetition=f}get BackwardJumpInstructions(){return this.backwardJumpInstructions}get EndingIndexDict(){return this.endingIndexDict}get EndingParts(){return this.endingParts}get Visibles(){return this.visibles}set Visibles(t){this.visibles=t}get DefaultNumberOfRepetitions(){let t=2;return this.virtualOverallRepetition&&(t=1),Math.max(t,Object.keys(this.endingIndexDict).length,this.checkRepetitionForMultipleLyricVerses())}get UserNumberOfRepetitions(){return this.userNumberOfRepetitions}set UserNumberOfRepetitions(t){this.userNumberOfRepetitions=t,this.repetitonIterationOrder=[];const f=this.userNumberOfRepetitions-this.NumberOfEndings;for(let p=1;p<=this.userNumberOfRepetitions;p++)p<=f?this.repetitonIterationOrder.push(1):this.repetitonIterationOrder.push(p-f)}getForwardJumpTargetForIteration(t){const f=this.repetitonIterationOrder[t-1];return this.endingIndexDict[f]?this.endingIndexDict[f].part.StartIndex:-1}getBackwardJumpTarget(){return this.startMarker.measureIndex}setEndingsStartIndex(t,f){const p=new n(new s.SourceMusicPart(this.musicSheet2,f,f));this.endingParts.push(p);for(const m of t)try{this.endingIndexDict[m]=p,p.endingIndices.push(m),this.numberOfEndings=this.xmlMeasureList.length)return!1;this.currentMeasure=T,this.followingMultirestMeasures=Math.max(this.followingMultirestMeasures-1,0),this.inSourceMeasureInstrumentIndex=this.musicSheet.getGlobalStaffIndexOfFirstStaff(this.instrument),this.repetitionInstructionReader&&this.repetitionInstructionReader.prepareReadingMeasure(T,this.currentXmlMeasureIndex);let B=new n.Fraction(0,1),D=new n.Fraction(0,1),_=!1;this.maxTieNoteFraction=new n.Fraction(0,1);let F=!1;try{const ie=this.xmlMeasureList[this.currentXmlMeasureIndex],oe=ie.elements();let $;T.Rules.UseXMLMeasureNumbers&&!Number.isInteger(T.MeasureNumberXML)&&($=parseInt((k=ie.attribute("number"))==null?void 0:k.value,10),Number.isInteger($)&&(T.MeasureNumberXML=$));const Q=ie.attribute("osmdWidthFactor");if(Q){const ee=Number.parseFloat(Q.value);typeof ee!="number"||isNaN(ee)?x.default.info(`xml parse: osmdWidthFactor invalid for measure ${$}`):T.WidthFactor=ee}let ne;for(let ee=0;ee0&&(ne=oe[ee-1]),N.name==="print"){const R=N.attribute("new-system");(R==null?void 0:R.value)==="yes"&&(T.printNewSystemXml=!0);const O=N.attribute("new-page");(O==null?void 0:O.value)==="yes"&&(T.printNewPageXml=!0)}else if(N.name==="attributes"){const R=N.element("divisions");if(R&&(this.divisions=parseInt(R.value,10),isNaN(this.divisions))){const H=h.ITextTranslation.translateText("ReaderErrorMessages/DivisionError","Invalid divisions value at Instrument: ");if(x.default.debug("InstrumentReader.readNextXmlMeasure",H),this.divisions=this.readDivisionsFromNotes(),!(this.divisions>0))throw _=!0,new t.MusicSheetReadingException(H+this.instrument.Name);this.musicSheet.SheetErrors.push(H+this.instrument.Name)}if(!N.element("divisions")&&this.divisions===0&&this.currentXmlMeasureIndex===0){const H=h.ITextTranslation.translateText("ReaderErrorMessages/DivisionError","Invalid divisions value at Instrument: ");if(this.divisions=this.readDivisionsFromNotes(),!(this.divisions>0))throw _=!0,new t.MusicSheetReadingException(H+this.instrument.Name);this.musicSheet.SheetErrors.push(H+this.instrument.Name)}this.addAbstractInstruction(N,v,ne,B.clone()),B.Equals(new n.Fraction(0,1))&&this.isAttributesNodeAtBeginOfMeasure(this.xmlMeasureList[this.currentXmlMeasureIndex],N)&&this.saveAbstractInstructionList(this.instrument.Staves.length,!0),this.isAttributesNodeAtEndOfMeasure(this.xmlMeasureList[this.currentXmlMeasureIndex],N,B)&&this.saveClefInstructionAtEndOfMeasure();const O=N.elements("staff-details");for(const H of O){const W=H.element("staff-lines");if(W){let K=1;const q=H.attribute("number");q&&(K=parseInt(q.value,10)),this.instrument.Staves[K-1].StafflineCount=parseInt(W.value,10)}}const U=N.element("measure-style");if(U){const H=U.element("multiple-rest");if(H){const W=H.value;let K=0;try{K=Number.parseInt(W,10),T.multipleRestMeasures!==void 0&&K!==T.multipleRestMeasures?T.multipleRestMeasures=0:(T.multipleRestMeasures=K,this.currentMultirestStartMeasure=T,this.followingMultirestMeasures=K+1)}catch(q){console.log("multirest parse error: "+q)}}}}else if(N.name==="note"){let R=!0;((j=N.attribute("print-object"))==null?void 0:j.value)==="no"&&(R=!1);const O=this.getNoteStaff(N);this.currentStaff=this.instrument.Staves[O-1];const U=N.element("chord")!==void 0;if(N.element("voice")){const Ae=parseInt(N.element("voice").value,10);this.currentVoiceGenerator=this.getOrCreateVoiceGenerator(Ae,O-1)}else U&&this.currentVoiceGenerator||(this.currentVoiceGenerator=this.getOrCreateVoiceGenerator(1,O-1));let H,W=0,K=new n.Fraction(0,1),q=2;const te=N.element("rest")!==void 0;if(N.element("duration")){if(this.divisions===0&&this.currentXmlMeasureIndex===0){if(this.divisions=this.readDivisionsFromNotes(),this.divisions===0){const Ae=h.ITextTranslation.translateText("ReaderErrorMessages/DivisionError","Invalid divisions value at Instrument: ");throw _=!0,new t.MusicSheetReadingException(Ae+this.instrument.Name)}this.musicSheet.SheetErrors.push(h.ITextTranslation.translateText("ReaderErrorMessages/DivisionError","Invalid divisions value at Instrument: ")+this.instrument.Name)}if(W=parseInt(N.element("duration").value,10),isNaN(W)){const Ae=h.ITextTranslation.translateText("ReaderErrorMessages/NoteDurationError","Invalid Note Duration.");this.musicSheet.SheetErrors.pushMeasureError(Ae),x.default.debug("InstrumentReader.readNextXmlMeasure",Ae);continue}if(K=new n.Fraction(W,4*this.divisions),te&&K.RealValue>((P=this.ActiveRhythm)==null?void 0:P.Rhythm.RealValue)&&(K=this.ActiveRhythm.Rhythm.clone()),W===0?K=this.getNoteDurationFromTypeNode(N):H=this.getNoteDurationFromTypeNode(N),N.element("time-modification")){K=this.getNoteDurationForTuplet(N);const Ae=N.element("time-modification");Ae!=null&&Ae.element("normal-notes")&&(q=parseInt(Ae.element("normal-notes").value,10))}}const se=N.combinedElement("notations"),ue=N.element("grace")!==void 0||W===0||U&&F;let fe=!1,xe=!1;if(ue){const Ae=N.element("grace");Ae&&Ae.attributes()&&Ae.attribute("slash")&&Ae.attribute("slash").value==="yes"&&(fe=!0),K=this.getNoteDurationFromTypeNode(N),se&&se.element("slur")&&(xe=!0)}const[ve,Se]=this.getCueNoteAndNoteTypeXml(N),[ye,be,Me]=this.getStemDirectionAndColors(N);let _e;if(se){const Ae=se.element("ornaments");Ae&&(_e=this.getTremoloInfo(Ae),this.getWavyLines(Ae,N,B,D))}const Te=U?D.clone():B.clone();this.currentStaffEntry=this.currentMeasure.findOrCreateStaffEntry(Te,this.inSourceMeasureInstrumentIndex+O-1,this.currentStaff).staffEntry,(!this.currentVoiceGenerator.hasVoiceEntry()||!U&&!ue&&!F||ue&&!F||ue&&!U||!ue&&F)&&this.currentVoiceGenerator.createVoiceEntry(Te,this.currentStaffEntry,!ue,ue,fe,xe),ue||U||(D=B.clone(),B.Add(K)),U&&this.currentStaffEntry!==void 0&&this.currentStaffEntry.ParentStaff!==this.currentStaff&&(this.currentStaffEntry=this.currentVoiceGenerator.checkForStaffEntryLink(this.inSourceMeasureInstrumentIndex+O-1,this.currentStaff,this.currentStaffEntry,this.currentMeasure));const Le=this.currentStaffEntry!==void 0&&this.currentStaffEntry.Timestamp!==void 0&&this.currentStaffEntry.Timestamp.Equals(new n.Fraction(0,1))&&!this.currentStaffEntry.hasNotes();this.saveAbstractInstructionList(this.instrument.Staves.length,Le),this.activeRhythm;const Pe=N.elements("dot").length;if(this.currentVoiceGenerator.read(N,K,H,Se,q,te,this.currentStaffEntry,this.currentMeasure,A,this.maxTieNoteFraction,U,v,R,ve,ue,ye,_e,be,Me,Pe),se!==void 0&&se.element("dynamics")){const Ae=this.expressionReaders[this.readExpressionStaffNumber(N)-1];Ae&&(Ae.readExpressionParameters(N,this.instrument,this.divisions,B,D,this.currentMeasure.MeasureNumber,!1),Ae.read(N,this.currentMeasure,D))}F=ue}else if(N.name==="forward"){const R=parseInt(N.element("duration").value,10);B.Add(new n.Fraction(R,4*this.divisions))}else if(N.name==="backup"){const R=parseInt(N.element("duration").value,10);B.Sub(new n.Fraction(R,4*this.divisions)),B.IsNegative()&&(B=new n.Fraction(0,1)),D.Sub(new n.Fraction(R,4*this.divisions)),D.IsNegative()&&(D=new n.Fraction(0,1))}else if(N.name==="direction"){const R=N.elements("direction-type"),O=R[0];let U=Math.min(1,B.RealValue);this.activeRhythm!==void 0&&this.activeRhythm.Rhythm&&(U/=this.activeRhythm.Rhythm.RealValue);let H=!1;if(this.repetitionInstructionReader&&(H=this.repetitionInstructionReader.handleRepetitionInstructionsFromWordsOrSymbols(O,U)),!H){let W=this.expressionReaders[0];const K=this.readExpressionStaffNumber(N)-1;if(Kq.element("octave-shift"))){W.readExpressionParameters(N,this.instrument,this.divisions,B,D,this.currentMeasure.MeasureNumber,!0);let q,te=0;(Y=(G=this.currentStaffEntry)==null?void 0:G.Timestamp)!=null&&Y.Equals(B)?(te=this.currentStaffEntry.VoiceEntries.length,q=B.clone()):q=D.clone(),W.addOctaveShift(N,this.currentMeasure,q,te)}R.some(q=>q.element("pedal"))&&(W.readExpressionParameters(N,this.instrument,this.divisions,B,D,this.currentMeasure.MeasureNumber,!0),W.addPedalMarking(N,this.currentMeasure,B.clone())),W.readExpressionParameters(N,this.instrument,this.divisions,B,D,this.currentMeasure.MeasureNumber,!1),W.read(N,this.currentMeasure,B,D.clone())}}}else if(N.name==="barline"){this.repetitionInstructionReader&&this.repetitionInstructionReader.handleLineRepetitionInstructions(N)&&(this.currentMeasure.HasEndLine=!0);const R=N.attribute("location"),O=(R==null?void 0:R.value)??"right";if(ee===oe.length-1||O==="right"){const U=(X=N.element("bar-style"))==null?void 0:X.value;U&&(this.currentMeasure.endingBarStyleXml=U,this.currentMeasure.endingBarStyleEnum=I.SystemLinesEnumHelper.xmlBarlineStyleToSystemLinesEnum(U))}}else if(N.name==="sound")try{if(N.attribute("tempo")){const R=parseFloat(N.attribute("tempo").value);this.currentXmlMeasureIndex===0&&(this.musicSheet.DefaultStartTempoInBpm=R,this.musicSheet.HasBPMInfo=!0)}}catch(R){x.default.debug("InstrumentReader.readTempoInstruction",R)}else if(N.name==="harmony"){const R=this.getNoteStaff(N);this.currentStaff=this.instrument.Staves[R-1];const O=B.clone();this.currentStaffEntry=this.currentMeasure.findOrCreateStaffEntry(O,this.inSourceMeasureInstrumentIndex+R-1,this.currentStaff).staffEntry,this.currentStaffEntry.ChordContainers.push(d.ChordSymbolReader.readChordSymbol(N,this.musicSheet,this.activeKey))}}for(const ee in this.voiceGeneratorsDict)this.voiceGeneratorsDict.hasOwnProperty(ee)&&this.voiceGeneratorsDict[ee].checkForOpenBeam();if(this.currentXmlMeasureIndex===this.xmlMeasureList.length-1){for(let ee=0;ee0?this.musicSheet.SourceMeasures[0]:this.currentMeasure;const v=new r.ClefInstruction(f.ClefEnum.G,0,2);let B;A.FirstInstructionsStaffEntries[T]?(B=A.FirstInstructionsStaffEntries[T],B.removeFirstInstructionOfTypeClefInstruction()):(B=new u.SourceStaffEntry(void 0,void 0),A.FirstInstructionsStaffEntries[T]=B),v.Parent=B,B.Instructions.splice(0,0,v)}createDefaultKeyInstruction(){let T;T=this.musicSheet.SourceMeasures.length>0?this.musicSheet.SourceMeasures[0]:this.currentMeasure;const A=new i.KeyInstruction(void 0,0,m.KeyEnum.major);for(let v=this.inSourceMeasureInstrumentIndex;v0&&v[B-1].name==="backup")return!0;let D=-1;for(let _=0;_0||D<0}isAttributesNodeAtEndOfMeasure(T,A,v){var F;if(v.Equals((F=this.ActiveRhythm)==null?void 0:F.Rhythm))return!0;const B=T.elements().slice();let D=0;for(let k=0;k_}getNoteDurationFromTypeNode(T){const A=T.element("type");if(A){const v=A.value;return L.NoteTypeHandler.getNoteDurationFromType(v)}return new n.Fraction(0,4*this.divisions)}addAbstractInstruction(T,A,v,B){if(T.element("divisions")&&T.elements().length===1)return;const D=T.element("transpose");if(D){const k=D.element("chromatic");k&&(this.instrument.PlaybackTranspose=parseInt(k.value,10))}const _=T.elements("clef");let F;if(_.length>0)for(let k=0,j=_.length;kthis.currentClefNumber&&(X=this.currentClefNumber),this.currentClefNumber=X+1}catch{F=h.ITextTranslation.translateText("ReaderErrorMessages/ClefError","Invalid clef. Using default."),this.musicSheet.SheetErrors.pushMeasureError(F),X=1,this.currentClefNumber=X+1}const ne=new r.ClefInstruction(G,ie,Y);this.abstractInstructions.push([X,ne,B])}if(T.element("key")!==void 0&&this.instrument.MidiInstrumentId!==y.MidiInstrument.Percussion){let k=0;const j=T.element("key").element("fifths");if(j)try{k=parseInt(j.value,10)}catch(X){F=h.ITextTranslation.translateText("ReaderErrorMessages/KeyError","Invalid key. Set to default."),this.musicSheet.SheetErrors.pushMeasureError(F),k=0,x.default.debug("InstrumentReader.addAbstractInstruction",F,X)}let P=m.KeyEnum.none,G=T.element("key");if(G&&(G=G.element("mode")),G)try{P=m.KeyEnum[G.value]}catch(X){F=h.ITextTranslation.translateText("ReaderErrorMessages/KeyError","Invalid key/mode. Set to default."),this.musicSheet.SheetErrors.pushMeasureError(F),P=m.KeyEnum.major,x.default.debug("InstrumentReader.addAbstractInstruction",F,X)}const Y=new i.KeyInstruction(void 0,k,P);this.abstractInstructions.push([1,Y,B])}if(T.element("time")){const k=T.element("time");let j=p.RhythmSymbolEnum.NONE,P=!0;if(k!==void 0&&k.hasAttributes){const Q=k.attribute("symbol");Q&&(Q.value==="common"?j=p.RhythmSymbolEnum.COMMON:Q.value==="cut"&&(j=p.RhythmSymbolEnum.CUT));const ne=k.attribute("print-object");ne&&ne.value==="no"&&(P=!1)}let G=0,Y=0;const X=k&&k.element("senza-misura")!==void 0,ie=T.elements("time"),oe=[],$=[];for(let Q=0,ne=ie.length;Q0&&$!==void 0&&oe.length===$.length){const ne=oe.length,ee=new Array(ne);let N=0;for(let R=0;R=0;v--){const B=this.abstractInstructions[v],D=B[0],_=B[1],F=B[2];if(_ instanceof r.ClefInstruction){const k=_;if(this.currentXmlMeasureIndex===0||D<=this.activeClefs.length&&k!==this.activeClefs[D-1])if(A||this.currentStaffEntry===void 0||this.currentStaffEntry.hasNotes()||D-1!==this.instrument.Staves.indexOf(this.currentStaffEntry.ParentStaff))if(A){if(F.RealValue!==0)continue;let j;if(this.currentMeasure){const P=k,G=this.inSourceMeasureInstrumentIndex+D-1,Y=this.currentMeasure.FirstInstructionsStaffEntries[G];if(this.currentXmlMeasureIndex===0)if(Y)if(this.currentMeasure.FirstInstructionsStaffEntries[G]===void 0||Y.Instructions[0]instanceof r.ClefInstruction){const X=new u.SourceStaffEntry(void 0,void 0);this.currentMeasure.LastInstructionsStaffEntries[G]=X,P.Parent=X,X.Instructions.push(P)}else j=Y,P.Parent=j,j.removeFirstInstructionOfTypeClefInstruction(),j.Instructions.splice(0,0,P),this.activeClefsHaveBeenInitialized[D-1]=!0;else j=new u.SourceStaffEntry(void 0,void 0),this.currentMeasure.FirstInstructionsStaffEntries[G]=j,P.Parent=j,j.Instructions.push(P),this.activeClefsHaveBeenInitialized[D-1]=!0;else if(this.activeClefsHaveBeenInitialized[D-1]){let X=this.previousMeasure;this.followingMultirestMeasures>0&&this.currentMeasure.Rules.RenderMultipleRestMeasures&&(X=this.currentMultirestStartMeasure);const ie=new u.SourceStaffEntry(void 0,void 0);X.LastInstructionsStaffEntries[G]=ie,P.Parent=ie,ie.Instructions.push(P)}else{const X=this.musicSheet.SourceMeasures[0];X.FirstInstructionsStaffEntries[G]?(j=X.FirstInstructionsStaffEntries[G],j.removeFirstInstructionOfTypeClefInstruction()):j=new u.SourceStaffEntry(void 0,void 0),P.Parent=j,j.Instructions.splice(0,0,P),this.activeClefsHaveBeenInitialized[D-1]=!0}this.activeClefs[D-1]=k,this.abstractInstructions.splice(v,1)}}else{let j;const P=this.activeRhythm.Rhythm;P.RealValue>0&&F.RealValue/P.RealValue>.9&&P.RealValue!==F.RealValue&&(this.currentMeasure.LastInstructionsStaffEntries[D-1]||(this.currentMeasure.LastInstructionsStaffEntries[D-1]=new u.SourceStaffEntry(void 0,this.instrument.Staves[D-1])),j=this.currentMeasure.LastInstructionsStaffEntries[D-1]),j&&(k.Parent=j,j.Instructions.push(k),this.activeClefs[D-1]=k,this.abstractInstructions.splice(v,1))}else{const j=k,P=this.currentStaffEntry;if(F&&Math.abs(F.RealValue-P.Timestamp.RealValue)>.01)continue;j.Parent=P,P.removeFirstInstructionOfTypeClefInstruction(),P.Instructions.push(j),this.activeClefs[D-1]=k,this.abstractInstructions.splice(v,1)}else D<=this.activeClefs.length&&k===this.activeClefs[D-1]&&this.abstractInstructions.splice(v,1)}if(_ instanceof i.KeyInstruction){const k=_;if(this.activeKey&&this.activeKey.Key===k.Key)this.abstractInstructions.splice(v,1);else{let j;if(this.activeKey=k,this.abstractInstructions.splice(v,1),this.activeKeyHasBeenInitialized?j=this.currentMeasure:(this.activeKeyHasBeenInitialized=!0,j=this.currentXmlMeasureIndex>0?this.musicSheet.SourceMeasures[0]:this.currentMeasure),j)for(let P=this.inSourceMeasureInstrumentIndex;P=0;T--){const A=this.abstractInstructions[T][0],v=this.abstractInstructions[T][1];if(v instanceof r.ClefInstruction){const B=v;if(!this.activeClefs[A-1]||B.ClefType!==this.activeClefs[A-1].ClefType||B.ClefType===this.activeClefs[A-1].ClefType&&B.Line!==this.activeClefs[A-1].Line){const D=new u.SourceStaffEntry(void 0,void 0);this.currentMeasure.LastInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex+A-1]=D;const _=B;_.Parent=D,D.Instructions.push(_),this.activeClefs[A-1]=B,this.abstractInstructions.splice(T,1)}}}}getNoteDurationForTuplet(T){const A=T.element("duration"),v=Number.parseInt(A.value,10);return new n.Fraction(v,4*this.divisions)}readExpressionStaffNumber(T){let A=1;if(T.element("staff")){const v=T.element("staff");if(v)try{A=parseInt(v.value,10)}catch(B){const D=h.ITextTranslation.translateText("ReaderErrorMessages/ExpressionStaffError","Invalid Expression staff number. Set to default.");this.musicSheet.SheetErrors.pushMeasureError(D),A=1,x.default.debug("InstrumentReader.readExpressionStaffNumber",D,B)}}return A}readDivisionsFromNotes(){let T=0,A=this.currentXmlMeasureIndex,v=!1;for(;!v;){const B=this.xmlMeasureList[A].elements();for(let D=0,_=B.length;D<_;++D){const F=B[D];if(F.name==="note"&&!F.element("time-modification")){const k=F.element("duration"),j=F.element("type");if(k!==void 0&&j){const P=j.value;let G=0;try{G=parseInt(k.value,10)}catch(Y){x.default.debug("InstrumentReader.readDivisionsFromNotes",Y);continue}switch(P){case"1024th":T=G/4*1024;break;case"512th":T=G/4*512;break;case"256th":T=G/4*256;break;case"128th":T=G/4*128;break;case"64th":T=G/4*64;break;case"32nd":T=G/4*32;break;case"16th":T=G/4*16;break;case"eighth":T=G/4*8;break;case"quarter":T=G/4*4;break;case"half":T=G/4*2;break;case"whole":T=G/4;break;case"breve":T=G/4/2;break;case"long":T=G/4/4;break;case"maxima":T=G/4/8}}}if(T>0){v=!0;break}}if(T===0&&(A++,A===this.xmlMeasureList.length)){const D=h.ITextTranslation.translateText("ReaderErrorMEssages/DivisionsError","Invalid divisions value at Instrument: ");throw new t.MusicSheetReadingException(D+this.instrument.Name)}}return T}getCueNoteAndNoteTypeXml(T){let A=!1;T.element("cue")&&(A=!0);const v=T.element("type");let B=L.NoteType.UNDEFINED;if(v){const D=v.attribute("size");(D==null?void 0:D.value)==="cue"&&(A=!0),B=L.NoteTypeHandler.StringToNoteType(v.value)}return[A,B]}getStemDirectionType(T){switch(T.value){case"down":return E.StemDirectionType.Down;case"up":return E.StemDirectionType.Up;case"double":return E.StemDirectionType.Double;case"none":return E.StemDirectionType.None;default:return E.StemDirectionType.Undefined}}getNoteHeadColorXml(T){const A=T.element("notehead");if(A){const v=A.attribute("color");if(v)return this.parseXmlColor(v.value)}return null}getNoteColorXml(T){const A=T.attribute("color");return A?this.parseXmlColor(A.value):null}getTremoloInfo(T){let A,v;const B=T.element("tremolo");if(B){const D=B.attribute("type");if(D){if(D.value==="single"){const _=parseInt(B.value,10);_>0&&(A=_)}else A=0;D.value==="unmeasured"&&(v=!0)}}return{tremoloStrokes:A,tremoloUnmeasured:v}}getWavyLines(T,A,v,B){const D=T.elements("wavy-line");if(D)for(const _ of D){const F=this.expressionReaders[this.readExpressionStaffNumber(A)-1];F&&(F.readExpressionParameters(_,this.instrument,this.divisions,v,B,this.currentMeasure.MeasureNumber,!1),F.addWavyLine(_,this.currentMeasure,v,B))}}getNoteStaff(T){let A=1;return this.instrument.Staves.length>1&&T.element("staff")&&(A=parseInt(T.element("staff").value,10),isNaN(A)&&(x.default.debug("InstrumentReader.readNextXmlMeasure.get staff number"),A=1)),A}}},9099(de,g,c){var l=this&&this.__importDefault||function(T){return T&&T.__esModule?T:{default:T}};Object.defineProperty(g,"__esModule",{value:!0}),g.MusicSheetReader=void 0;const s=c(427),u=c(4387),r=c(2561),i=c(1272),o=c(9252),n=c(9767),h=c(7307),t=l(c(3065)),f=c(9288),p=c(9288),m=c(2369),x=c(7586),y=c(5294),d=c(164),S=c(7435),M=c(5749),E=c(9713),L=c(7503),I=c(7533);g.MusicSheetReader=class{constructor(T=void 0,A=new E.EngravingRules){this.completeNumberOfStaves=0,this.pluginManager=new L.ReaderPluginManager,this.afterSheetReadingModules=T||[],this.repetitionInstructionReader=M.MusicSymbolModuleFactory.createRepetitionInstructionReader(),this.repetitionCalculator=M.MusicSymbolModuleFactory.createRepetitionCalculator(),this.rules=A}get PluginManager(){return this.pluginManager}get CompleteNumberOfStaves(){return this.completeNumberOfStaves}static doCalculationsAfterDurationHasBeenSet(T){for(const A of T)A.doCalculationsAfterDurationHasBeenSet()}createMusicSheet(T,A){try{return this._createMusicSheet(T,A)}catch(v){return void t.default.error("MusicSheetReader.CreateMusicSheet",v)}}_removeFromArray(T,A){const v=T.indexOf(A);v!==-1&&T.splice(v,1)}trimString(T){return T.replace(/^\s+|\s+$/g,"")}_lastElement(T){return T[T.length-1]}_createMusicSheet(T,A){const v=[];let B=0;this.musicSheet=new s.MusicSheet,this.musicSheet.Path=A,this.musicSheet.Rules=this.rules;const D=T.attribute("osmdMeasureWidthFactor");if(D){const Y=Number.parseFloat(D.value);typeof Y!="number"||isNaN(Y)?t.default.info("xml parse: osmdMeasureWidthFactor invalid"):this.musicSheet.MeasureWidthFactor=Y}if(!T)throw new h.MusicSheetReadingException("Undefined root element");this.pushSheetLabels(T,A);const _=T.element("part-list");if(!_)throw new h.MusicSheetReadingException("Undefined partListNode");const F=T.elements("part"),k=_.elements();this.initializeReading(k,F,v);let j=!0;this.currentFraction=new r.Fraction(0,1);let P=!1,G=T.element("identification");for(G&&(G=G.element("encoding")),G&&(G=G.element("software")),G!==void 0&&G.value==="Guitar Pro 5"&&(P=!0);j;){this.currentMeasure!==void 0&&this.currentMeasure.HasEndLine&&this.rules.NewPartAndSystemAfterFinalBarline&&(B=0),this.currentMeasure=new u.SourceMeasure(this.completeNumberOfStaves,this.musicSheet.Rules);for(const Y of v)try{j=j&&Y.readNextXmlMeasure(this.currentMeasure,this.currentFraction,P)}catch(X){const ie=n.ITextTranslation.translateText("ReaderErrorMessages/InstrumentError","Error while reading instruments.");throw new h.MusicSheetReadingException(ie,X)}j&&(this.musicSheet.addMeasure(this.currentMeasure),this.checkIfRhythmInstructionsAreSetAndEqual(v),this.checkSourceMeasureForNullEntries(),B=this.setSourceMeasureDuration(v,B),this.currentMeasure.AbsoluteTimestamp=this.currentFraction.clone(),this.musicSheet.SheetErrors.finalizeMeasure(this.currentMeasure.MeasureNumber),this.currentFraction.Add(this.currentMeasure.Duration),this.previousMeasure=this.currentMeasure)}this.repetitionInstructionReader&&(this.repetitionInstructionReader.removeRedundantInstructions(),this.repetitionCalculator&&this.repetitionCalculator.calculateRepetitions(this.musicSheet,this.repetitionInstructionReader.repetitionInstructions)),this.musicSheet.checkForInstrumentWithNoVoice(),this.musicSheet.fillStaffList();for(let Y=0,X=this.afterSheetReadingModules.length;Yv){if(this.areRhythmInstructionsMixed(A)&&F.SymbolEnum!==p.RhythmSymbolEnum.NONE)continue;v=F.Rhythm.RealValue,B=A.indexOf(F)}}if(A.length>0&&A.length0)&&A++,this.currentMeasure.Duration=_,this.currentMeasure.ActiveTimeSignature=v,this.currentMeasure.MeasureNumber=A;for(let F=0;FT.Denominator){const v=A.Denominator/T.Denominator;T.expand(v)}}checkIfMeasureIsImplicit(T,A){return!(this.previousMeasure||!T.lt(A))||!!this.previousMeasure&&r.Fraction.plus(this.previousMeasure.Duration,T).Equals(A)}allInstrumentsHaveSameDuration(T,A){let v=0;for(let B=0,D=T.length;B=0;T--)for(let A=this.currentMeasure.VerticalSourceStaffEntryContainers[T].StaffEntries.length-1;A>=0;A--){const v=this.currentMeasure.VerticalSourceStaffEntryContainers[T].StaffEntries[A];if(v)for(let B=v.VoiceEntries.length-1;B>=0;B--){const D=v.VoiceEntries[B];D.Notes.length===0&&(this._removeFromArray(D.ParentVoice.VoiceEntries,D),this._removeFromArray(v.VoiceEntries,D))}v!==void 0&&v.VoiceEntries.length===0&&v.ChordContainers.length===0&&(this.currentMeasure.VerticalSourceStaffEntryContainers[T].StaffEntries[A]=void 0)}for(let T=this.currentMeasure.VerticalSourceStaffEntryContainers.length-1;T>=0;T--){let A=0;for(let v=0,B=this.currentMeasure.VerticalSourceStaffEntryContainers[T].StaffEntries.length;v0){const v=A[0].elements("rights");if(v.length>0)for(let B=0,D=v.length;BA||Q)if(v||Q){if(oe||N==="right")D?D+=` `+ee:D=ee;else if(ie||N!=="right"&&N!=="left")B?B+=` `+ee:B=ee;else if(N==="left"){this.musicSheet.Lyricist||(this.musicSheet.Lyricist=new S.Label(ee));break}}else v=ee}}}}if(!this.musicSheet.Title&&v&&(this.musicSheet.Title=new S.Label(this.trimString(v))),!this.musicSheet.Subtitle&&B&&(this.musicSheet.Subtitle=new S.Label(this.trimString(B))),D){let P=!1;this.musicSheet.Composer?(D.match(` `)??[]).length+1>=(this.musicSheet.Composer.text.match(` `)??[]).length+1&&(P=!0):P=!0,P&&(this.musicSheet.Composer=new S.Label(this.trimString(D)))}}readTitleAndComposerFromCreditsLegacy(T){var j,P,G;const A=this.computeSystemYCoordinates(T);if(A===0)return;let v,B,D,_=1,F=0;const k=T.elements("credit");for(let Y=0,X=k.length;YA||N){if(!this.musicSheet.Title&&!N){const O=(G=oe.attribute("font-size"))==null?void 0:G.value;if(O){const U=parseFloat(O);_0&&P.MidiInstrumentId!==d.MidiInstrument.Percussion&&(oe.midiInstrumentID=Math.max(0,parseInt(ee.value,10)-1));else if(ee.name==="midi-unpitched")oe.fixedKey=Math.max(0,parseInt(ee.value,10));else if(ee.name==="volume")try{const N=parseFloat(ee.value);oe.volume=N/127}catch(N){t.default.debug("ExpressionReader.readExpressionParameters","read volume",N)}else if(ee.name==="pan")try{const N=parseFloat(ee.value);oe.pan=N/64}catch(N){t.default.debug("ExpressionReader.readExpressionParameters","read pan",N)}}catch(N){t.default.info("MusicSheetReader.createInstrumentGroups midi settings: ",N)}}}}catch(oe){t.default.info("MusicSheetReader.createInstrumentGroups: ",oe)}}if(P.SubInstruments.length===0){const Y=new y.SubInstrument(P);P.SubInstruments.push(Y)}v[j]=P,B?(B.InstrumentalGroups.push(P),this.musicSheet.Instruments.push(P)):(this.musicSheet.InstrumentalGroups.push(P),this.musicSheet.Instruments.push(P))}else if(k.name==="part-group"&&k.attribute("type").value==="start"){const j=new x.InstrumentalGroup("group",this.musicSheet,B);B?B.InstrumentalGroups.push(j):this.musicSheet.InstrumentalGroups.push(j),B=j}else if(k.name==="part-group"&&k.attribute("type").value==="stop"&&B){if(B.InstrumentalGroups.length===1){const j=B.InstrumentalGroups[0];B.Parent?(B.Parent.InstrumentalGroups.push(j),this._removeFromArray(B.Parent.InstrumentalGroups,B)):(this.musicSheet.InstrumentalGroups.push(j),this._removeFromArray(this.musicSheet.InstrumentalGroups,B))}B=B.Parent}}}catch(D){const _=n.ITextTranslation.translateText("ReaderErrorMessages/InstrumentError","Error while reading Instruments");throw new h.MusicSheetReadingException(_,D)}for(let D=0,_=this.musicSheet.Instruments.length;D<_;++D){const F=this.musicSheet.Instruments[D];F.Name||(F.Name="Instr. "+F.IdString)}return v}getCompleteNumberOfStavesFromXml(T){let A=0;for(const v of T){const B=v.elements("measure");if(B.length>0){const D=B[0];if(D){let _=D.element("attributes");_&&(_=_.element("staves")),_?A+=parseInt(_.value,10):A++}}}if(isNaN(A)||A<=0){const v=n.ITextTranslation.translateText("ReaderErrorMessages/StaffError","Invalid number of staves.");throw new h.MusicSheetReadingException(v)}return A}getInstrumentNumberOfStavesFromXml(T){let A=0;const v=T.element("measure");if(v){const B=v.element("attributes");let D;B&&(D=B.element("staves")),A=B&&D?parseInt(D.value,10):1}if(isNaN(A)||A<=0){const B=n.ITextTranslation.translateText("ReaderErrorMessages/StaffError","Invalid number of Staves.");throw new h.MusicSheetReadingException(B)}return A}}},5749(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.MusicSymbolModuleFactory=void 0;const l=c(7631),s=c(6302);g.MusicSymbolModuleFactory=class{static createRepetitionInstructionReader(){return new l.RepetitionInstructionReader}static createRepetitionCalculator(){return new s.RepetitionCalculator}}},4127(de,g,c){var l=this&&this.__importDefault||function(p){return p&&p.__esModule?p:{default:p}};Object.defineProperty(g,"__esModule",{value:!0}),g.ArticulationReader=void 0;const s=c(1336),u=l(c(3065)),r=c(3123),i=c(8215),o=c(6362),n=c(8233),h=c(9003),t=c(9019),f=c(8045);g.ArticulationReader=class{constructor(p){this.rules=p}getAccEnumFromString(p){switch(p){case"sharp":return n.AccidentalEnum.SHARP;case"flat":return n.AccidentalEnum.FLAT;case"natural":return n.AccidentalEnum.NATURAL;case"double-sharp":case"sharp-sharp":return n.AccidentalEnum.DOUBLESHARP;case"double-flat":case"flat-flat":return n.AccidentalEnum.DOUBLEFLAT;case"triple-sharp":return n.AccidentalEnum.TRIPLESHARP;case"triple-flat":return n.AccidentalEnum.TRIPLEFLAT;case"quarter-sharp":return n.AccidentalEnum.QUARTERTONESHARP;case"quarter-flat":return n.AccidentalEnum.QUARTERTONEFLAT;case"three-quarters-sharp":return n.AccidentalEnum.THREEQUARTERSSHARP;case"three-quarters-flat":return n.AccidentalEnum.THREEQUARTERSFLAT;case"slash-quarter-sharp":return n.AccidentalEnum.SLASHQUARTERSHARP;case"slash-sharp":return n.AccidentalEnum.SLASHSHARP;case"double-slash-flat":return n.AccidentalEnum.DOUBLESLASHFLAT;case"sori":return n.AccidentalEnum.SORI;case"koron":return n.AccidentalEnum.KORON;default:return n.AccidentalEnum.NONE}}addArticulationExpression(p,m){var x,y;if(p!==void 0&&p.elements().length>0){const d=p.elements();for(let S=0,M=d.length;S0&&m.Articulations[0].articulationEnum!==s.ArticulationEnum.staccato&&m.Articulations.splice(0,0,v);else if(L==="breathmark")T===o.PlacementEnum.NotYetDefined&&(v.placement=o.PlacementEnum.Above);else if(L==="strongaccent"){const B=(y=E==null?void 0:E.attribute("type"))==null?void 0:y.value;B==="up"?v.articulationEnum=s.ArticulationEnum.marcatoup:B==="down"&&(v.articulationEnum=s.ArticulationEnum.marcatodown)}else if(I===s.ArticulationEnum.softaccent){const B=m.ParentSourceStaffEntry.ParentStaff.Id-1;T===o.PlacementEnum.NotYetDefined&&(T=o.PlacementEnum.Above,B>0&&(T=o.PlacementEnum.Below));const D=m.ParentSourceStaffEntry.VerticalContainerParent.ParentMeasure,_=new t.MultiExpression(D,m.Timestamp);_.StartingContinuousDynamic=new f.ContinuousDynamicExpression(f.ContDynamicEnum.crescendo,T,B,D,-1),_.StartingContinuousDynamic.IsStartOfSoftAccent=!0,_.StartingContinuousDynamic.StartMultiExpression=_,_.StartingContinuousDynamic.EndMultiExpression=_,_.EndingContinuousDynamic=new f.ContinuousDynamicExpression(f.ContDynamicEnum.diminuendo,T,B,D,-1),_.EndingContinuousDynamic.StartMultiExpression=_,_.EndingContinuousDynamic.EndMultiExpression=_,D.StaffLinkedExpressions[B].push(_)}m.hasArticulation(v)||m.Articulations.push(v)}}catch(I){return void u.default.debug("addArticulationExpression","Invalid note articulation.",I)}}}}addFermata(p,m){var d;let x=s.ArticulationEnum.fermata;p.attributes().length>0&&p.attribute("type")&&p.attribute("type").value==="inverted"&&(x=s.ArticulationEnum.invertedfermata);let y=o.PlacementEnum.Above;((d=p.attribute("placement"))==null?void 0:d.value)==="below"&&(y=o.PlacementEnum.Below),m.Articulations.push(new h.Articulation(x,y))}addTechnicalArticulations(p,m,x){var M,E;const y={bend:s.ArticulationEnum.bend,"down-bow":s.ArticulationEnum.downbow,"open-string":s.ArticulationEnum.naturalharmonic,"snap-pizzicato":s.ArticulationEnum.snappizzicato,stopped:s.ArticulationEnum.lefthandpizzicato,"up-bow":s.ArticulationEnum.upbow,harmonic:s.ArticulationEnum.naturalharmonic};for(const L in y){if(!y.hasOwnProperty(L))continue;const I=y[L],T=p.element(L);if(T){let A;((M=T.attribute("placement"))==null?void 0:M.value)==="above"&&(A=o.PlacementEnum.Above),((E=T.attribute("placement"))==null?void 0:E.value)==="below"&&(A=o.PlacementEnum.Below);const v=new h.Articulation(I,A);m.hasArticulation(v)||m.Articulations.push(v)}}const d=p.elements("fingering");for(const L of d){const I=this.createTechnicalInstruction(L,x);I.type=r.TechnicalInstructionType.Fingering,x.Fingering||(x.Fingering=I),m.TechnicalInstructions.push(I)}const S=p.element("string");if(S){const L=this.createTechnicalInstruction(S,x);L.type=r.TechnicalInstructionType.String,x.StringInstruction=L,m.TechnicalInstructions.push(L)}}createTechnicalInstruction(p,m){const x=new r.TechnicalInstruction;x.sourceNote=m,x.value=p.value;const y=p.attribute("placement");return this.rules.FingeringPositionFromXML&&(x.placement=this.getPlacement(y)),x}getPlacement(p,m=o.PlacementEnum.NotYetDefined){if(m!==o.PlacementEnum.NotYetDefined)return m;if(!p)return o.PlacementEnum.NotYetDefined;switch(p.value){case"above":return o.PlacementEnum.Above;case"below":return o.PlacementEnum.Below;case"left":return o.PlacementEnum.Left;case"right":return o.PlacementEnum.Right;default:return o.PlacementEnum.NotYetDefined}}addOrnament(p,m){if(p){let x;const y={"delayed-inverted-turn":i.OrnamentEnum.DelayedInvertedTurn,"delayed-turn":i.OrnamentEnum.DelayedTurn,"inverted-mordent":i.OrnamentEnum.InvertedMordent,"inverted-turn":i.OrnamentEnum.InvertedTurn,mordent:i.OrnamentEnum.Mordent,"trill-mark":i.OrnamentEnum.Trill,turn:i.OrnamentEnum.Turn};for(const d in y){if(!y.hasOwnProperty(d))continue;const S=p.element(d);if(S){x=new i.OrnamentContainer(y[d]);const M=S.attribute("placement");M&&M.value==="below"&&(x.placement=o.PlacementEnum.Below)}}if(x){const d=p.elements("accidental-mark");if(d){let S=o.PlacementEnum.Below,M=n.AccidentalEnum.NONE;const E=d;for(let L=0,I=E.length;L0?v.RealValue>0?(k=s.Fraction.multiply(s.Fraction.minus(v,B),k),this.directionTimestamp=s.Fraction.plus(k,v)):this.directionTimestamp=s.Fraction.createFromFraction(k):this.offsetDivisions<0&&(v.RealValue>0?(k=s.Fraction.multiply(s.Fraction.minus(v,B),k),this.directionTimestamp=s.Fraction.minus(v,k)):this.directionTimestamp=s.Fraction.createFromFraction(k));const j=I.elements("direction-type"),P=I.attribute("placement");if(P)try{const G=P.value;G==="below"?this.placement=m.PlacementEnum.Below:G==="above"&&(this.placement=m.PlacementEnum.Above)}catch(G){const Y=y.ITextTranslation.translateText("ReaderErrorMessages/ExpressionPlacementError","Invalid expression placement -> set to default.");d.default.debug("ExpressionReader.readExpressionParameters",Y,G),this.musicSheet.SheetErrors.pushMeasureError(Y),this.placement=m.PlacementEnum.Below}try{for(const G of j){const Y=G.element("wedge");if(Y){const X=Y.attribute("default-y");X&&(this.WedgeYPosXml=parseInt(X.value,10),this.placement===m.PlacementEnum.NotYetDefined&&this.readExpressionPlacement(X,"read wedge y pos"))}if(this.placement===m.PlacementEnum.NotYetDefined){const X=G.element("dynamics");if(X){const $=X.attribute("default-y");$&&this.readExpressionPlacement($,"read dynamics y pos")}const ie=G.element("words");if(ie){const $=ie.attribute("default-y");$&&this.readExpressionPlacement($,"read words y pos")}const oe=G.element("rehearsal");if(oe){const $=oe.attribute("default-y");$&&this.readExpressionPlacement($,"read rehearsal pos")}}}}catch(G){const Y=y.ITextTranslation.translateText("ReaderErrorMessages/ExpressionPlacementError","Invalid expression placement. Set to default.");d.default.debug("ExpressionReader.readExpressionParameters",Y,G),this.musicSheet.SheetErrors.pushMeasureError(Y),this.placement=m.PlacementEnum.Below}this.placement===m.PlacementEnum.NotYetDefined&&(T.Staves.length>1?this.placement=m.PlacementEnum.Below:T.HasLyrics?this.placement=m.PlacementEnum.Above:this.placement=m.PlacementEnum.Below)}read(I,T,A,v=void 0){let B=!1,D=!1;const _=A.clone(),F=I.element("offset");if(F!=null&&F.value){const P=Number.parseInt(F.value,10);_.Add(new s.Fraction(P,4*this.divisions))}const k=I.element("sound");if(k){const P=k.attribute("tempo"),G=k.attribute("dynamics");if(P){const Y=P.value.match(/^(\d+)(\.\d+)?$/);(Y==null?void 0:Y.length)>0?this.soundTempo=Math.round(Number.parseFloat(P.value)):(d.default.info("invalid xml tempo: "+P.value),this.soundTempo=100),T.TempoInBPM=this.soundTempo,this.musicSheet.DefaultStartTempoInBpm===0&&(this.musicSheet.DefaultStartTempoInBpm=this.soundTempo),this.musicSheet.HasBPMInfo=!0,B=!0}if(G){const Y=G.value.match(/\d+/);this.soundDynamic=Y!==void 0?parseInt(Y[0],10):100,D=!0}}const j=I.elements("direction-type");for(const P of j){let G=P.element("metronome");if(G){const Y=G.elements("metronome-note"),X=G.element("metronome-relation");if(Y.length>0&&X)this.parseComplexMetronomeMark(G,Y,X,T,_);else{const ie=G.element("beat-unit"),oe=G.element("beat-unit-dot")!==void 0,$=G.element("per-minute");if(ie!==void 0&&$){G.hasAttributes&&G.attribute("default-x")!==void 0&&(this.directionTimestamp=s.Fraction.createFromFraction(_));const Q=$.value.match(/(\d+\.?\d*)/),ne=Q?parseFloat(Q[1]):NaN;this.createNewTempoExpressionIfNeeded(T);const ee=new t.InstantaneousTempoExpression(void 0,this.placement,this.staffNumber,ne,this.currentMultiTempoExpression,!0);ee.parentMeasure=T,this.soundTempo=ne,T.TempoInBPM=this.soundTempo*(oe?1.5:1),this.musicSheet.DefaultStartTempoInBpm===0&&(this.musicSheet.DefaultStartTempoInBpm=this.soundTempo),this.musicSheet.HasBPMInfo=!0,ee.dotted=oe,ee.beatUnit=ie.value,this.currentMultiTempoExpression.addExpression(ee,""),this.currentMultiTempoExpression.CombinedExpressionsText="test"}}continue}if(G=P.element("dynamics"),G){const Y=I.element("notations")!==void 0;this.interpretInstantaneousDynamics(G,T,_,Y);continue}if(G=P.element("words"),G)if(B){this.createNewTempoExpressionIfNeeded(T),this.currentMultiTempoExpression.CombinedExpressionsText=G.value;const Y=new t.InstantaneousTempoExpression(G.value,this.placement,this.staffNumber,this.soundTempo,this.currentMultiTempoExpression);this.currentMultiTempoExpression.addExpression(Y,"")}else D||this.interpretWords(G,T,_);else G=P.element("wedge"),G?this.interpretWedge(I,G,T,v,T.MeasureNumber):(G=P.element("rehearsal"),G&&this.interpretRehearsalMark(G,T,A,T.MeasureNumber))}}closeOpenExpressions(I,T){for(const A of this.openContinuousDynamicExpressions)this.createNewMultiExpressionIfNeeded(I,A.NumberXml,T),this.closeOpenContinuousDynamic(A,I,T);this.openContinuousTempoExpression&&this.closeOpenContinuousTempo(s.Fraction.plus(I.AbsoluteTimestamp,T))}addOctaveShift(I,T,A,v=0){var k;let B=1;const D=I.element("staff");if(D)try{B=parseInt(D.value,10)}catch(j){const P=y.ITextTranslation.translateText("ReaderErrorMessages/OctaveShiftStaffError","Invalid octave shift staff number. Set to default");this.musicSheet.SheetErrors.pushMeasureError(P),B=1,d.default.debug("ExpressionReader.addOctaveShift",P,j)}const _=I.elements("direction-type"),F=this.readPlacement(I);for(const j of _){const P=j.element("octave-shift");if(P!==void 0&&P.hasAttributes)try{const G=this.readNumber(P);if(P.attribute("size")){const Y=parseInt(P.attribute("size").value,10);let X=0;Y===8?X=1:Y===15&&(X=2);let ie=(k=P.attribute("type"))==null?void 0:k.value;if(ie||(F===m.PlacementEnum.Above?ie="down":F===m.PlacementEnum.Below&&(ie="up")),ie==="up"||ie==="down"){const oe=new n.OctaveShift(ie,X);oe.StaffNumber=B,oe.numberXml=G,this.getMultiExpression=this.createNewMultiExpressionIfNeeded(T,G),this.getMultiExpression.OctaveShiftStart=oe,oe.ParentStartMultiExpression=this.getMultiExpression,this.openOctaveShifts.set(G,oe);const $=this.pendingOctaveShiftStops.get(G);$&&(this.pendingOctaveShiftStops.delete(G),this.getMultiExpression=this.createNewMultiExpressionIfNeeded($.measure,G,$.endTimestamp),this.getMultiExpression.OctaveShiftEnd=oe,oe.ParentEndMultiExpression=this.getMultiExpression,this.openOctaveShifts.delete(G))}else if(ie==="stop"){const oe=this.openOctaveShifts.get(G);if(oe)oe.endVoiceEntryIndex=v,this.getMultiExpression=this.createNewMultiExpressionIfNeeded(T,oe.numberXml,A),this.getMultiExpression.OctaveShiftEnd=oe,oe.ParentEndMultiExpression=this.getMultiExpression,this.openOctaveShifts.delete(G);else{const $=s.Fraction.minus(this.directionTimestamp,new s.Fraction(1,4*this.divisions));this.pendingOctaveShiftStops.set(G,{measure:T,endTimestamp:$})}}else ie||d.default.debug("octave-shift missing type in xml")}}catch(G){const Y=y.ITextTranslation.translateText("ReaderErrorMessages/OctaveShiftError","Error while reading octave shift.");this.musicSheet.SheetErrors.pushMeasureError(Y),d.default.debug("ExpressionReader.addOctaveShift",Y,G)}}}addPedalMarking(I,T,A){var B,D,_;const v=I.elements("direction-type");for(const F of v){const k=F.element("pedal");if(k&&k.hasAttributes){let j=!1,P=!1;try{switch(((B=k.attribute("line"))==null?void 0:B.value)==="yes"?P=!0:((D=k.attribute("line"))==null?void 0:D.value)==="no"?(P=!1,j=!0):((_=k.attribute("sign"))==null?void 0:_.value)==="yes"?j=!0:(j=!1,P=!0),k.attribute("type").value){case"start":this.openPedal&&this.openPedal.IsLine&&this.endOpenPedal(T),this.createNewMultiExpressionIfNeeded(T,-1),this.openPedal=new E.Pedal(P,j),this.getMultiExpression.PedalStart=this.openPedal,this.openPedal.ParentStartMultiExpression=this.getMultiExpression;break;case"stop":this.openPedal&&this.endOpenPedal(T,A);break;case"change":this.openPedal&&this.openPedal.IsLine&&(this.openPedal.ChangeEnd=!0,this.createNewMultiExpressionIfNeeded(T,-1),this.getMultiExpression.PedalEnd=this.openPedal,this.openPedal.ParentEndMultiExpression=this.getMultiExpression,this.createNewMultiExpressionIfNeeded(T,-1),this.openPedal=new E.Pedal(P,j),this.openPedal.ChangeBegin=!0,this.getMultiExpression.PedalStart=this.openPedal,this.openPedal.ParentStartMultiExpression=this.getMultiExpression)}}catch(G){const Y=y.ITextTranslation.translateText("ReaderErrorMessages/PedalError","Error while reading pedal.");this.musicSheet.SheetErrors.pushMeasureError(Y),d.default.debug("ExpressionReader.addPedalMarking",Y,G)}}}}endOpenPedal(I,T){this.createNewMultiExpressionIfNeeded(I,-1,T),this.getMultiExpression.PedalEnd=this.openPedal,this.openPedal.ParentEndMultiExpression=this.getMultiExpression,this.openPedal=void 0}addWavyLine(I,T,A,v){if(I&&I.hasAttributes)try{switch(I.attribute("type").value){case"start":this.createNewMultiExpressionIfNeeded(T,-1),this.openWavyLine=new L.WavyLine(this.placement),this.getMultiExpression.WavyLineStart=this.openWavyLine,this.openWavyLine.ParentStartMultiExpression=this.getMultiExpression;break;case"stop":this.openWavyLine&&(this.createNewMultiExpressionIfNeeded(T,-1,A),this.getMultiExpression.WavyLineEnd=this.openWavyLine,this.openWavyLine.ParentEndMultiExpression=this.getMultiExpression,this.openWavyLine=void 0)}}catch(B){const D=y.ITextTranslation.translateText("ReaderErrorMessages/WavyLineError","Error while reading wavy-line.");this.musicSheet.SheetErrors.pushMeasureError(D),d.default.debug("ExpressionReader.addWavyLine",D,B)}}initialize(){this.placement=m.PlacementEnum.NotYetDefined,this.soundTempo=0,this.soundDynamic=0,this.offsetDivisions=0}readPlacement(I){var A;const T=(A=I.attribute("placement"))==null?void 0:A.value;return T==="above"?m.PlacementEnum.Above:T==="below"?m.PlacementEnum.Below:m.PlacementEnum.NotYetDefined}readExpressionPlacement(I,T){try{const A=this.readPosition(I);A<0?this.placement=m.PlacementEnum.Below:A>0&&(this.placement=m.PlacementEnum.Above)}catch(A){d.default.debug("ExpressionReader.readExpressionParameters",T,A)}}readPosition(I){try{const T=parseInt(I.value,10);return T<0?this.placement=m.PlacementEnum.Below:T>0&&(this.placement=m.PlacementEnum.Above),T}catch(T){d.default.debug("ExpressionReader.readExpressionParameters",T)}}parseComplexMetronomeMark(I,T,A,v,B){var X;I.hasAttributes&&I.attribute("default-x")!==void 0&&(this.directionTimestamp=s.Fraction.createFromFraction(B));const D=I.elements(),_=[],F=[];let k,j=!1;for(const ie of D){if(ie.name==="metronome-relation"){j=!0;continue}if(ie.name!=="metronome-note")continue;const oe=ie.element("metronome-type");if(!oe)continue;const $={type:oe.value,dots:ie.elements("metronome-dot").length},Q=ie.element("metronome-beam");Q&&($.beam=Q.value);const ne=ie.element("metronome-tuplet");if(ne&&(ne.hasAttributes?(X=ne.attribute("type"))==null?void 0:X.value:void 0)==="start"){const ee=ne.element("actual-notes"),N=ne.element("normal-notes"),R=ne.attribute("bracket"),O=ne.attribute("show-number");k={actualNotes:ee?parseInt(ee.value,10):3,normalNotes:N?parseInt(N.value,10):2,bracket:!R||R.value==="yes",showNumber:O?O.value:"actual"}}j?F.push($):_.push($)}const P={notes:_},G={notes:F,tuplet:k};this.createNewTempoExpressionIfNeeded(v);const Y=new t.InstantaneousTempoExpression(void 0,this.placement,this.staffNumber,this.soundTempo,this.currentMultiTempoExpression,!0);Y.parentMeasure=v,Y.metronomeNoteGroupLeft=P,Y.metronomeNoteGroupRight=G,Y.metronomeRelation=A.value,this.musicSheet.DefaultStartTempoInBpm===0&&(this.musicSheet.DefaultStartTempoInBpm=this.soundTempo),this.musicSheet.HasBPMInfo=!0,this.currentMultiTempoExpression.addExpression(Y,""),this.currentMultiTempoExpression.CombinedExpressionsText="test"}interpretInstantaneousDynamics(I,T,A,v){var B,D,_;if(I.hasElements){I.hasAttributes&&I.attribute("default-x")&&(this.directionTimestamp=s.Fraction.createFromFraction(A));const F=this.readNumber(I);let k=(B=I.elements()[0])==null?void 0:B.name;if(k==="other-dynamics"&&(k=I.elements()[0].value),k){if((D=T.Rules)!=null&&D.IgnoreRepeatedDynamics){let P;try{P=o.DynamicEnum[k]}catch{const Y=y.ITextTranslation.translateText("ReaderErrorMessages/DynamicError","Error while reading dynamic.");return void this.musicSheet.SheetErrors.pushMeasureError(Y)}if(((_=this.activeInstantaneousDynamic)==null?void 0:_.DynEnum)===P)return}v?this.createNewMultiExpressionIfNeeded(T,F,s.Fraction.createFromFraction(A)):this.createNewMultiExpressionIfNeeded(T,F);const j=new o.InstantaneousDynamicExpression(k,this.soundDynamic,this.placement,this.staffNumber,T);j.InMeasureTimestamp=A.clone(),this.getMultiExpression.addExpression(j,""),this.activeInstantaneousDynamic?this.activeInstantaneousDynamic.DynEnum=j.DynEnum:this.activeInstantaneousDynamic=new o.InstantaneousDynamicExpression(k,0,m.PlacementEnum.NotYetDefined,1,T)}}}interpretWords(I,T,A){var Y;const v=I.value;if(T.Rules.IgnoreBracketsWords&&(/^\(\s*\)$/.test(v)||/^\[\s*\]$/.test(v)))return;let B;const D=I.attribute("font-style");let _,F,k;D&&(_=D.value,_==="italic"&&(B=S.FontStyles.Italic));const j=I.attribute("font-weight");j&&(F=j.value,F==="bold"&&(B=S.FontStyles.Bold,_==="italic"&&(B=S.FontStyles.BoldItalic)));const P=I.attribute("color");let G;if(P&&(k=P.value),T.Rules.PlaceWordsInsideStafflineFromXml){const X=(Y=I.attribute("default-y"))==null?void 0:Y.value;(X==null?void 0:X.length)>0&&(G=Number.parseInt(X,10))}if(v.length>0){if(I.hasAttributes&&I.attribute("default-x")&&(this.directionTimestamp=s.Fraction.createFromFraction(A)),this.checkIfWordsNodeIsRepetitionInstruction(v))return;this.fillMultiOrTempoExpression(v,T,A,B,k,G),this.initialize()}}readNumber(I){var v;let T=1;const A=(v=I.attribute("number"))==null?void 0:v.value;return A&&(T=Number.parseInt(A,10)),T}interpretWedge(I,T,A,v,B){var F,k;T!==void 0&&T.hasAttributes&&T.attribute("default-x")&&(this.directionTimestamp=s.Fraction.createFromFraction(v));const D=this.readNumber(T),_=(k=(F=T.attribute("type"))==null?void 0:F.value)==null?void 0:k.toLowerCase();this.lastWedge&&this.lastWedge.parentMeasure.MeasureNumberXML===A.MeasureNumberXML&&this.lastWedge.StaffNumber===this.staffNumber&&this.placement===this.lastWedge.Placement&&this.WedgeYPosXml!==void 0&&this.lastWedge.YPosXml===this.WedgeYPosXml&&this.lastWedge.StartMultiExpression.Timestamp.Equals(this.directionTimestamp)&&this.lastWedge.DynamicType===r.ContDynamicEnum[_]||(_==="stop"?(this.createNewMultiExpressionIfNeeded(A,D,v),this.getMultiExpression.EndOffsetFraction=new s.Fraction(this.offsetDivisions,4*this.divisions)):this.createNewMultiExpressionIfNeeded(A,D),this.addWedge(T,A,v),this.initialize())}interpretRehearsalMark(I,T,A,v){T.rehearsalExpression=new M.RehearsalExpression(I.value,this.placement)}createNewMultiExpressionIfNeeded(I,T,A=void 0){A||(A=this.directionTimestamp);let v=this.getMultiExpression;return(!v||v&&(v.SourceMeasureParent!==I||v.numberXml!==T||v.SourceMeasureParent===I&&!v.Timestamp.Equals(A)))&&(this.getMultiExpression=v=new h.MultiExpression(I,s.Fraction.createFromFraction(A)),this.getMultiExpression.numberXml=T,I.StaffLinkedExpressions[this.globalStaffIndex].push(v)),v}createNewTempoExpressionIfNeeded(I){this.currentMultiTempoExpression&&this.currentMultiTempoExpression.SourceMeasureParent===I&&this.currentMultiTempoExpression.Timestamp===this.directionTimestamp||(this.currentMultiTempoExpression=new u.MultiTempoExpression(I,s.Fraction.createFromFraction(this.directionTimestamp)),I.TempoExpressions.push(this.currentMultiTempoExpression))}addWedge(I,T,A){if(I!==void 0&&I.hasAttributes){const v=this.readNumber(I),B=I.attribute("type").value.toLowerCase();try{if(B==="crescendo"||B==="diminuendo"){const D=new r.ContinuousDynamicExpression(r.ContDynamicEnum[B],this.placement,this.staffNumber,T,v);this.lastWedge=D,this.lastWedge.YPosXml=this.WedgeYPosXml,this.openContinuousDynamicExpressions.push(D);let _=this.getMultiExpression;_||(_=this.createNewMultiExpressionIfNeeded(T,v)),_.StartingContinuousDynamic=D,D.StartMultiExpression=_,this.activeInstantaneousDynamic!==void 0&&this.activeInstantaneousDynamic.StaffNumber===D.StaffNumber&&(this.activeInstantaneousDynamic=void 0)}else if(B==="stop")for(const D of this.openContinuousDynamicExpressions)D.NumberXml===v&&this.closeOpenContinuousDynamic(D,T,A)}catch(D){const _="ReaderErrorMessages/WedgeError, Error while reading Crescendo / Diminuendo.";this.musicSheet.SheetErrors.pushMeasureError(_),d.default.debug("ExpressionReader.addWedge",_,D)}}}fillMultiOrTempoExpression(I,T,A,v,B,D=void 0){if(!I)return;const _=I.trim();this.createExpressionFromString("",_,T,A,I,v,B,D)}createExpressionFromString(I,T,A,v,B,D,_,F=void 0){const k=t.InstantaneousTempoExpression.isInputStringInstantaneousTempo(T),j=i.ContinuousTempoExpression.isInputStringContinuousTempo(T);if(k||j){if(A.TempoExpressions.length>0)for(let X=0,ie=A.TempoExpressions.length;X0)for(let X=0,ie=A.TempoExpressions.length;X0&&!this.hasDigit(T)&&this.globalStaffIndex>0){if(oe.EntriesList[0].label.indexOf(T)>=0)return!1;break}}let G=this.musicSheet.Rules.UnknownExpressionTextAlignment;this.musicSheet.Rules.CompactMode&&(G=x.TextAlignmentEnum.LeftBottom);const Y=new p.UnknownExpression(T,this.placement,G,this.staffNumber);return Y.fontStyle=D,Y.ColorXML=_,Y.defaultYXml=F,Y.parentMeasure=A,P.addExpression(Y,I),!1}closeOpenContinuousDynamic(I,T,A){if(!I)return;const v=I.NumberXml;I.EndMultiExpression=this.createNewMultiExpressionIfNeeded(T,v,A),I.StartMultiExpression.EndingContinuousDynamic=I,this.openContinuousDynamicExpressions=this.openContinuousDynamicExpressions.filter(B=>B!==I)}closeOpenContinuousTempo(I){this.openContinuousTempoExpression.AbsoluteEndTimestamp=I,this.openContinuousTempoExpression=void 0}checkIfWordsNodeIsRepetitionInstruction(I){return(I=I.trim().toLowerCase())==="coda"||I==="tocoda"||I==="to coda"||I==="fine"||I==="d.c."||I==="dacapo"||I==="da capo"||I==="d.s."||I==="dalsegno"||I==="dal segno"||I==="d.c. al fine"||I==="d.s. al fine"||I==="d.c. al coda"||I==="d.s. al coda"}hasDigit(I){return/\d/.test(I)}}},6030(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.LyricsReader=void 0;const l=c(649),s=c(2317),u=c(9767);g.LyricsReader=class{constructor(r){this.openLyricWords={},this.musicSheet=r}addLyricEntry(r,i){var o,n;if(r){const h=r;for(let t=0,f=h.length;t0)for(let A=T;A1&&p.add(d)}let m=0;for(const d of this.repetitionInstructions){if(this.currentMeasureIndex=d.measureIndex,this.currentMeasureIndex>m){for(const S of p)if(S>m&&S<=this.currentMeasureIndex){for(;this.openRepetitions.length>0;)this.finalizeRepetition(this.openRepetitions.last());this.lastRepetitionCommonPartStartIndex=S;break}}m=this.currentMeasureIndex;try{this.currentMeasure=f[this.currentMeasureIndex],this.handleRepetitionInstructions(d)}catch(S){o.default.error("RepetitionCalculator: calculateRepetitions",S)}}for(;this.openRepetitions.length>0;)try{const d=this.openRepetitions.last();if(d.RepetitonUnderConstruction.FromWords){if(d.WaitingForCoda){let S=d.RepetitonUnderConstruction.BackwardJumpInstructions.last().measureIndex+1;S>=this.musicSheet.SourceMeasures.length&&(S=-1),d.RepetitonUnderConstruction.setEndingStartIndex(2,S)}else if(d.RepetitonUnderConstruction.BackwardJumpInstructions.length===0){this.openRepetitions.splice(this.openRepetitions.length-1,1);continue}}else if(d.RepetitonUnderConstruction.BackwardJumpInstructions.length===0){const S=f.length-1,M=new s.RepetitionInstruction(S,s.RepetitionInstructionEnum.BackJumpLine,s.AlignmentType.End,d.RepetitonUnderConstruction);d.RepetitonUnderConstruction.BackwardJumpInstructions.push(M),f[S].LastRepetitionInstructions.push(M)}this.finalizeRepetition(this.openRepetitions.last())}catch{try{const S=this.openRepetitions.last().RepetitonUnderConstruction;for(const M of this.repetitionInstructions)M.parentRepetition===S&&(M.parentRepetition=void 0);this.openRepetitions.splice(this.openRepetitions.length-1,1)}catch(S){o.default.error("RepetitionCalculator: calculateRepetitions2",S)}}let x=!1;const y=this.musicSheet.SourceMeasures.length-1;for(const d of this.musicSheet.Repetitions)if(d.StartIndex===0&&d.EndIndex===y){x=!0;break}if(!x){const d=new i.Repetition(this.musicSheet,!0);d.FromWords=!0,d.startMarker=new s.RepetitionInstruction(0,s.RepetitionInstructionEnum.StartLine),d.startMarker.parentRepetition=d,this.musicSheet.SourceMeasures[0].FirstRepetitionInstructions.push(d.startMarker),d.endMarker=new s.RepetitionInstruction(y,s.RepetitionInstructionEnum.BackJumpLine),d.endMarker.parentRepetition=d,d.BackwardJumpInstructions.push(d.endMarker),d.UserNumberOfRepetitions=d.DefaultNumberOfRepetitions,this.musicSheet.Repetitions.push(d)}for(let d=0,S=this.musicSheet.SourceMeasures.length;d1&&M.FirstRepetitionInstructions.sort(u.RepetitionInstructionComparer.Compare),M.LastRepetitionInstructions.length>1&&M.LastRepetitionInstructions.sort(u.RepetitionInstructionComparer.Compare)}}handleRepetitionInstructions(h){let t;switch(h.type){case s.RepetitionInstructionEnum.StartLine:t=this.createNewRepetition(this.currentMeasureIndex),h.parentRepetition=t.RepetitonUnderConstruction,t.RepetitonUnderConstruction.FromWords=!1,t.RepetitonUnderConstruction.startMarker=h,this.currentMeasure.FirstRepetitionInstructions.push(h);break;case s.RepetitionInstructionEnum.BackJumpLine:t=this.getOrCreateCurrentRepetition2(!1),h.parentRepetition=t.RepetitonUnderConstruction,t.RepetitonUnderConstruction.BackwardJumpInstructions.push(h),this.currentMeasure.LastRepetitionInstructions.push(h),t.RepetitonUnderConstruction.EndingParts.length===0&&this.finalizeRepetition(t);break;case s.RepetitionInstructionEnum.Ending:if(t=this.getOrCreateCurrentRepetition(),h.parentRepetition=t.RepetitonUnderConstruction,h.endingIndices.contains(1)&&h.alignment===s.AlignmentType.Begin){if(t.RepetitonUnderConstruction.BackwardJumpInstructions.length>0||t.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)){t=void 0;for(let f=this.openRepetitions.length-1;f>=0;f--){const p=this.openRepetitions[f];if(p.RepetitonUnderConstruction.BackwardJumpInstructions.length===0)for(t=p;this.openRepetitions.length-1>f;){const m=this.openRepetitions.last();this.finalizeRepetition(m)}}t===void 0&&(t=this.createNewRepetition(0),t.RepetitonUnderConstruction.startMarker=new s.RepetitionInstruction(0,s.RepetitionInstructionEnum.None))}t.RepetitonUnderConstruction.forwardJumpInstruction===void 0&&(t.RepetitonUnderConstruction.forwardJumpInstruction=new s.RepetitionInstruction(this.currentMeasureIndex-1,s.RepetitionInstructionEnum.ForwardJump,s.AlignmentType.End,t.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[this.currentMeasureIndex-1].LastRepetitionInstructions.push(t.RepetitonUnderConstruction.forwardJumpInstruction))}if(h.alignment===s.AlignmentType.Begin)t.RepetitonUnderConstruction.setEndingsStartIndex(h.endingIndices,this.currentMeasureIndex),this.currentMeasure.FirstRepetitionInstructions.push(h);else for(let f=0,p=h.endingIndices.length;f0&&Math.abs(t.RepetitonUnderConstruction.BackwardJumpInstructions.last().measureIndex-this.currentMeasureIndex)<=1)break;t=this.createNewRepetition(this.currentMeasureIndex),h.parentRepetition=t.RepetitonUnderConstruction,t.RepetitonUnderConstruction.FromWords=!0,t.SegnoFound=!0,t.RepetitonUnderConstruction.startMarker=h,this.currentMeasure.FirstRepetitionInstructions.push(h);break;case s.RepetitionInstructionEnum.Fine:if(this.openRepetitions.length===0||(t=this.getCurrentRepetition(!0),t===void 0))break;h.parentRepetition=t.RepetitonUnderConstruction,t.RepetitonUnderConstruction.FromWords=!0,t.RepetitonUnderConstruction.forwardJumpInstruction===void 0?(t.FineFound=!0,t.RepetitonUnderConstruction.forwardJumpInstruction=h,t.RepetitonUnderConstruction.setEndingStartIndex(2,-2),this.currentMeasure.LastRepetitionInstructions.push(h)):this.currentMeasure.LastRepetitionInstructions.push(new s.RepetitionInstruction(this.currentMeasureIndex,s.RepetitionInstructionEnum.Fine,s.AlignmentType.End,void 0));break;case s.RepetitionInstructionEnum.ToCoda:if(this.openRepetitions.length===0||(t=this.getCurrentRepetition(!0),t===void 0))break;t.RepetitonUnderConstruction.forwardJumpInstruction===void 0&&(h.parentRepetition=t.RepetitonUnderConstruction,t.RepetitonUnderConstruction.FromWords=!0,t.ToCodaFound=!0,t.RepetitonUnderConstruction.forwardJumpInstruction=h,this.currentMeasure.LastRepetitionInstructions.push(h));break;case s.RepetitionInstructionEnum.Coda:if(this.openRepetitions.length===0)break;t=this.getOrCreateCurrentRepetition2(!0),h.parentRepetition=t.RepetitonUnderConstruction,t.WaitingForCoda?(t.CodaFound=!0,t.RepetitonUnderConstruction.setEndingStartIndex(2,this.currentMeasureIndex),this.currentMeasure.LastRepetitionInstructions.push(h),this.finalizeRepetition(t),this.currentMeasureIndex>0&&(this.musicSheet.SourceMeasures[this.currentMeasureIndex-1].printNewSystemXml=!0)):t.ToCodaFound||(t.RepetitonUnderConstruction.BackwardJumpInstructions.length===0?(t.ToCodaFound=!0,t.RepetitonUnderConstruction.forwardJumpInstruction=new s.RepetitionInstruction(this.currentMeasureIndex,s.RepetitionInstructionEnum.ToCoda,s.AlignmentType.End,t.RepetitonUnderConstruction),this.currentMeasure.LastRepetitionInstructions.push(t.RepetitonUnderConstruction.forwardJumpInstruction)):this.currentMeasure.LastRepetitionInstructions.push(new s.RepetitionInstruction(this.currentMeasureIndex,s.RepetitionInstructionEnum.Coda,s.AlignmentType.Begin,void 0)));break;case s.RepetitionInstructionEnum.DaCapo:t=this.getOrCreateCurrentRepetition(),t.RepetitonUnderConstruction.BackwardJumpInstructions.length>0&&this.finalizeRepetition(t),t.RepetitonUnderConstruction.StartIndex!==0&&(t=this.createNewRepetition(0)),h.parentRepetition=t.RepetitonUnderConstruction,t.RepetitonUnderConstruction.FromWords=!0,t.RepetitonUnderConstruction.startMarker=new s.RepetitionInstruction(0,s.RepetitionInstructionEnum.None,s.AlignmentType.Begin,t.RepetitonUnderConstruction),t.RepetitonUnderConstruction.BackwardJumpInstructions.push(h),this.currentMeasure.LastRepetitionInstructions.push(h),t.RepetitonUnderConstruction.EndingParts.length===0&&this.finalizeRepetition(t);break;case s.RepetitionInstructionEnum.DalSegno:if(t=this.getOrCreateCurrentRepetition2(!0),t.RepetitonUnderConstruction.BackwardJumpInstructions.length>0&&(this.finalizeRepetition(t),t=this.createNewRepetition(0),t.RepetitonUnderConstruction.FromWords=!0,t.RepetitonUnderConstruction.startMarker=new s.RepetitionInstruction(0,s.RepetitionInstructionEnum.None,s.AlignmentType.Begin,t.RepetitonUnderConstruction)),h.parentRepetition=t.RepetitonUnderConstruction,!t.SegnoFound){const f=this.findInstructionInMainListBackwards(s.RepetitionInstructionEnum.Segno,h.measureIndex);f>=0&&(t.SegnoFound=!0,t.RepetitonUnderConstruction.startMarker=new s.RepetitionInstruction(f,s.RepetitionInstructionEnum.Segno,s.AlignmentType.Begin,t.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[f].FirstRepetitionInstructions.splice(0,0,t.RepetitonUnderConstruction.startMarker))}t.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)&&t.RepetitonUnderConstruction.setEndingEndIndex(1,this.currentMeasureIndex),t.RepetitonUnderConstruction.BackwardJumpInstructions.push(h),this.currentMeasure.LastRepetitionInstructions.push(h);break;case s.RepetitionInstructionEnum.DalSegnoAlFine:if(this.openRepetitions.length===0)break;if(t=this.getOrCreateCurrentRepetition2(!0),h.parentRepetition=t.RepetitonUnderConstruction,!t.SegnoFound){const f=this.findInstructionInMainListBackwards(s.RepetitionInstructionEnum.Segno,h.measureIndex);f>=0&&(t.SegnoFound=!0,t.RepetitonUnderConstruction.startMarker=new s.RepetitionInstruction(f,s.RepetitionInstructionEnum.Segno,s.AlignmentType.Begin,t.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[f].FirstRepetitionInstructions.splice(0,0,t.RepetitonUnderConstruction.startMarker))}if(!t.FineFound){const f=this.findInstructionInMainListBackwards(s.RepetitionInstructionEnum.Fine,h.measureIndex);f>=0&&(t.FineFound=!0,t.RepetitonUnderConstruction.forwardJumpInstruction=new s.RepetitionInstruction(f,s.RepetitionInstructionEnum.Fine,s.AlignmentType.Begin,t.RepetitonUnderConstruction),t.RepetitonUnderConstruction.setEndingStartIndex(2,-2),this.musicSheet.SourceMeasures[f].LastRepetitionInstructions.splice(0,0,t.RepetitonUnderConstruction.forwardJumpInstruction))}t.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)||t.RepetitonUnderConstruction.setEndingEndIndex(1,this.currentMeasureIndex),t.RepetitonUnderConstruction.BackwardJumpInstructions.push(h),this.currentMeasure.LastRepetitionInstructions.push(h);break;case s.RepetitionInstructionEnum.DaCapoAlFine:if(t=this.getOrCreateCurrentRepetition(),t.RepetitonUnderConstruction.BackwardJumpInstructions.length>0&&(this.finalizeRepetition(t),t=this.createNewRepetition(0)),t.RepetitonUnderConstruction.startMarker!==void 0&&t.RepetitonUnderConstruction.StartIndex!==0&&(t=this.createNewRepetition(0)),t.RepetitonUnderConstruction.startMarker=new s.RepetitionInstruction(0,s.RepetitionInstructionEnum.None,s.AlignmentType.Begin,t.RepetitonUnderConstruction),t.RepetitonUnderConstruction.FromWords=!0,h.parentRepetition=t.RepetitonUnderConstruction,!t.FineFound){const f=this.findInstructionInMainListBackwards(s.RepetitionInstructionEnum.Fine,h.measureIndex);f>=0&&(t.FineFound=!0,t.RepetitonUnderConstruction.forwardJumpInstruction=new s.RepetitionInstruction(f,s.RepetitionInstructionEnum.Fine,s.AlignmentType.Begin,t.RepetitonUnderConstruction),t.RepetitonUnderConstruction.setEndingStartIndex(2,-2),this.musicSheet.SourceMeasures[f].LastRepetitionInstructions.splice(0,0,t.RepetitonUnderConstruction.forwardJumpInstruction))}t.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)||t.RepetitonUnderConstruction.setEndingEndIndex(1,this.currentMeasureIndex),t.RepetitonUnderConstruction.BackwardJumpInstructions.push(h),this.currentMeasure.LastRepetitionInstructions.push(h);break;case s.RepetitionInstructionEnum.DalSegnoAlCoda:if(this.openRepetitions.length===0)break;if(t=this.getOrCreateCurrentRepetition2(!0),h.parentRepetition=t.RepetitonUnderConstruction,!t.SegnoFound){const f=this.findInstructionInMainListBackwards(s.RepetitionInstructionEnum.Segno,h.measureIndex);f>=0&&(t.SegnoFound=!0,t.RepetitonUnderConstruction.startMarker=new s.RepetitionInstruction(f,s.RepetitionInstructionEnum.Segno,s.AlignmentType.Begin,t.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[f].FirstRepetitionInstructions.splice(0,0,t.RepetitonUnderConstruction.startMarker))}if(!t.ToCodaFound){const f=this.findInstructionInMainListBackwards(s.RepetitionInstructionEnum.ToCoda,h.measureIndex);if(f>=0)t.RepetitonUnderConstruction.forwardJumpInstruction=new s.RepetitionInstruction(f,s.RepetitionInstructionEnum.ToCoda,s.AlignmentType.Begin,t.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[f].LastRepetitionInstructions.splice(0,0,t.RepetitonUnderConstruction.forwardJumpInstruction),t.ToCodaFound=!0;else{const p=this.findInstructionInMainListBackwards(s.RepetitionInstructionEnum.Coda,h.measureIndex);p>=0&&(t.RepetitonUnderConstruction.forwardJumpInstruction=new s.RepetitionInstruction(p,s.RepetitionInstructionEnum.ToCoda,s.AlignmentType.Begin,t.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[p].LastRepetitionInstructions.splice(0,0,t.RepetitonUnderConstruction.forwardJumpInstruction),t.ToCodaFound=!0)}}t.ToCodaFound&&(t.WaitingForCoda=!0),t.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)||t.RepetitonUnderConstruction.setEndingEndIndex(1,this.currentMeasureIndex),t.RepetitonUnderConstruction.BackwardJumpInstructions.push(h),this.currentMeasure.LastRepetitionInstructions.push(h);break;case s.RepetitionInstructionEnum.DaCapoAlCoda:if(t=this.getOrCreateCurrentRepetition(),t.RepetitonUnderConstruction.BackwardJumpInstructions.length>0?(this.finalizeRepetition(t),t=this.createNewRepetition(0)):t.RepetitonUnderConstruction.EndingParts.length===0&&(t=this.createNewRepetition(0)),t.RepetitonUnderConstruction.startMarker!==void 0&&t.RepetitonUnderConstruction.StartIndex!==0&&(t=this.createNewRepetition(0)),t.RepetitonUnderConstruction.startMarker=new s.RepetitionInstruction(0,s.RepetitionInstructionEnum.None,s.AlignmentType.Begin,t.RepetitonUnderConstruction),t.RepetitonUnderConstruction.FromWords=!0,h.parentRepetition=t.RepetitonUnderConstruction,!t.ToCodaFound){const f=this.findInstructionInMainListBackwards(s.RepetitionInstructionEnum.ToCoda,h.measureIndex);if(f>=0)t.RepetitonUnderConstruction.forwardJumpInstruction=new s.RepetitionInstruction(f,s.RepetitionInstructionEnum.ToCoda,s.AlignmentType.Begin,t.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[f].LastRepetitionInstructions.splice(0,0,t.RepetitonUnderConstruction.forwardJumpInstruction),t.ToCodaFound=!0;else{const p=this.findInstructionInMainListBackwards(s.RepetitionInstructionEnum.Coda,h.measureIndex);p>=0&&(t.RepetitonUnderConstruction.forwardJumpInstruction=new s.RepetitionInstruction(p,s.RepetitionInstructionEnum.ToCoda,s.AlignmentType.Begin,t.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[p].LastRepetitionInstructions.splice(0,0,t.RepetitonUnderConstruction.forwardJumpInstruction),t.ToCodaFound=!0)}}t.ToCodaFound&&(t.WaitingForCoda=!0),t.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)||t.RepetitonUnderConstruction.setEndingEndIndex(1,this.currentMeasureIndex),t.RepetitonUnderConstruction.BackwardJumpInstructions.push(h),this.currentMeasure.LastRepetitionInstructions.push(h);break;case s.RepetitionInstructionEnum.None:break;default:throw new r.ArgumentOutOfRangeException("currentRepetitionInstruction")}return!0}findInstructionInMainListBackwards(h,t){for(let f=this.repetitionInstructions.length-1;f>=0;f--){const p=this.repetitionInstructions[f];if(p.measureIndex<=t&&p.type===h)return p.measureIndex}return-1}finalizeRepetition(h){const t=h.RepetitonUnderConstruction;if(t.BackwardJumpInstructions.length>0){let f=!0;const p=this.getLastFinalizedRepetition();if(p!==void 0&&t.coversIdenticalMeasures(p)){if(t.NumberOfEndings>p.NumberOfEndings){const m=this.musicSheet.Repetitions.indexOf(p,0);m>-1&&this.musicSheet.Repetitions.splice(m,1),p.removeFromRepetitionInstructions(),this.musicSheet.Repetitions.push(t)}f=!1,t.removeFromRepetitionInstructions()}else this.musicSheet.Repetitions.push(t);if(f){t.startMarker.type===s.RepetitionInstructionEnum.None&&this.musicSheet.SourceMeasures[t.StartIndex].FirstRepetitionInstructions.push(t.startMarker);let m=t.DefaultNumberOfRepetitions;t.BackwardJumpInstructions.length===1&&t.BackwardJumpInstructions[0].Times>0&&(m=t.BackwardJumpInstructions[0].Times),t.UserNumberOfRepetitions=m}}this.openRepetitions.splice(this.openRepetitions.length-1,1)}getCurrentRepetition(h){let t;for(let f=this.openRepetitions.length-1;f>=0;f--)if(this.openRepetitions[f].RepetitonUnderConstruction.FromWords===h){for(t=this.openRepetitions[f];f0)return this.openRepetitions.last();const h=this.createNewRepetition(0);return h.RepetitonUnderConstruction.startMarker=new s.RepetitionInstruction(0,s.RepetitionInstructionEnum.None,s.AlignmentType.Begin,h.RepetitonUnderConstruction),h}getOrCreateCurrentRepetition2(h){let t;for(let f=this.openRepetitions.length-1;f>=0;f--)if(t=this.openRepetitions[f],t.RepetitonUnderConstruction.FromWords===h){for(;f0){const f=this.openRepetitions.last(),p=f.RepetitonUnderConstruction;if(p.BackwardJumpInstructions.length>0){const m=Object.keys(p.EndingIndexDict);(m.length===0||p.EndingIndexDict[m[m.length-1]].part.EndIndex>=0)&&this.finalizeRepetition(f)}}const t=new n(this.musicSheet);return this.lastRepetitionCommonPartStartIndex=h,this.openRepetitions.push(t),t}getLastFinalizedRepetition(){if(this.musicSheet.Repetitions.length>0)return this.musicSheet.Repetitions.last()}};class n{constructor(t){this.RepetitonUnderConstruction=new i.Repetition(t)}}g.RepetitionBuildingContainer=n},7631(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.RepetitionInstructionReader=void 0;const l=c(1645),s=c(1645),u=c(4356);g.RepetitionInstructionReader=class{set MusicSheet(r){this.musicSheet=r,this.xmlMeasureList=new Array(this.musicSheet.Instruments.length),this.repetitionInstructions=[]}prepareReadingMeasure(r,i){this.currentMeasureIndex=i}handleLineRepetitionInstructions(r){var o;let i=!1;if(r.elements().length>0){let n="",h=!1,t="",f="",p="";const m=[],x=r.element("bar-style");x&&(p=x.value),n=r.attributes().length>0&&r.attribute("location")?r.attribute("location").value:"right";const y=r.elements();for(let d=0,S=y.length;d0)if(n==="left"){if(f==="start"){const d=new l.RepetitionInstruction(this.currentMeasureIndex,l.RepetitionInstructionEnum.Ending,l.AlignmentType.Begin,void 0,m);this.addInstruction(this.repetitionInstructions,d)}if(t==="forward"){const d=new l.RepetitionInstruction(this.currentMeasureIndex,l.RepetitionInstructionEnum.StartLine);this.addInstruction(this.repetitionInstructions,d)}}else{if(f==="stop"){const d=new l.RepetitionInstruction(this.currentMeasureIndex,l.RepetitionInstructionEnum.Ending,l.AlignmentType.End,void 0,m);this.addInstruction(this.repetitionInstructions,d)}else if(f==="discontinue"){const d=new l.RepetitionInstruction(this.currentMeasureIndex,l.RepetitionInstructionEnum.Ending,l.AlignmentType.Discontinue,void 0,m);this.addInstruction(this.repetitionInstructions,d)}if(t==="backward"){const d=new l.RepetitionInstruction(this.currentMeasureIndex,l.RepetitionInstructionEnum.BackJumpLine);this.addInstruction(this.repetitionInstructions,d)}}}return i}handleRepetitionInstructionsFromWordsOrSymbols(r,i){const o=r.element("words"),n=this.currentMeasureIndex;if(o){const h="d\\s?\\.s\\.",t=o.value.trim().toLowerCase();if(u.StringUtil.StringContainsSeparatedWord(t,h+" al fine",!0)){const p=new l.RepetitionInstruction(n,l.RepetitionInstructionEnum.DalSegnoAlFine);return this.addInstruction(this.repetitionInstructions,p),!0}const f="d\\.\\s?c\\.";if(u.StringUtil.StringContainsSeparatedWord(t,f+" al coda",!0)){const p=new l.RepetitionInstruction(n,l.RepetitionInstructionEnum.DaCapoAlCoda);return this.addInstruction(this.repetitionInstructions,p),!0}if(u.StringUtil.StringContainsSeparatedWord(t,f+" al fine",!0)){const p=new l.RepetitionInstruction(n,l.RepetitionInstructionEnum.DaCapoAlFine);return this.addInstruction(this.repetitionInstructions,p),!0}if(u.StringUtil.StringContainsSeparatedWord(t,f+" al coda",!0)){const p=new l.RepetitionInstruction(n,l.RepetitionInstructionEnum.DaCapoAlCoda);return this.addInstruction(this.repetitionInstructions,p),!0}if(u.StringUtil.StringContainsSeparatedWord(t,f)||u.StringUtil.StringContainsSeparatedWord(t,"da\\s?capo",!0)){const p=new l.RepetitionInstruction(n,l.RepetitionInstructionEnum.DaCapo);return this.addInstruction(this.repetitionInstructions,p),!0}if(u.StringUtil.StringContainsSeparatedWord(t,h,!0)||u.StringUtil.StringContainsSeparatedWord(t,"dal\\s?segno",!0)){let p;return p=u.StringUtil.StringContainsSeparatedWord(t,"al\\s?coda",!0)?new l.RepetitionInstruction(n,l.RepetitionInstructionEnum.DalSegnoAlCoda):new l.RepetitionInstruction(n,l.RepetitionInstructionEnum.DalSegno),this.addInstruction(this.repetitionInstructions,p),!0}if(u.StringUtil.StringContainsSeparatedWord(t,"to\\s?coda",!0)||u.StringUtil.StringContainsSeparatedWord(t,"a (la )?coda",!0)){const p=new l.RepetitionInstruction(n,l.RepetitionInstructionEnum.ToCoda);return this.addInstruction(this.repetitionInstructions,p),!0}if(u.StringUtil.StringContainsSeparatedWord(t,"fine",!0)){const p=new l.RepetitionInstruction(n,l.RepetitionInstructionEnum.Fine);return this.addInstruction(this.repetitionInstructions,p),!0}if(u.StringUtil.StringContainsSeparatedWord(t,"coda",!0)){const p=new l.RepetitionInstruction(n,l.RepetitionInstructionEnum.Coda);return this.addInstruction(this.repetitionInstructions,p),!0}if(u.StringUtil.StringContainsSeparatedWord(t,"segno",!0)){const p=new l.RepetitionInstruction(n,l.RepetitionInstructionEnum.Segno);return this.addInstruction(this.repetitionInstructions,p),!0}}else{if(r.element("segno")){const h=new l.RepetitionInstruction(n,l.RepetitionInstructionEnum.Segno);return this.addInstruction(this.repetitionInstructions,h),!0}if(r.element("coda")){const h=new l.RepetitionInstruction(n,l.RepetitionInstructionEnum.Coda);return this.addInstruction(this.repetitionInstructions,h),!0}}return!1}removeRedundantInstructions(){let r=0,i=0,o=0,n=0;for(let h=0;h0&&this.findInstructionInPreviousMeasure(h,t.measureIndex,l.RepetitionInstructionEnum.ToCoda)&&(t.type=l.RepetitionInstructionEnum.None);break;case l.RepetitionInstructionEnum.Segno:if(r-n>0){let f=!1;for(let p=0,m=this.repetitionInstructions.length;p0?l.RepetitionInstructionEnum.DalSegnoAlCoda:l.RepetitionInstructionEnum.DalSegno,t.type=l.RepetitionInstructionEnum.None,f=!0;break;case l.RepetitionInstructionEnum.DalSegno:case l.RepetitionInstructionEnum.DalSegnoAlFine:case l.RepetitionInstructionEnum.DalSegnoAlCoda:t.type=l.RepetitionInstructionEnum.None,f=!0}if(f)break}if(f)break;t.type=o-i>0?l.RepetitionInstructionEnum.DalSegnoAlCoda:l.RepetitionInstructionEnum.DalSegno,t.alignment=l.AlignmentType.End,t.measureIndex--}}if(this.backwardSearchForPreviousIdenticalInstruction(h,t)||t.type===l.RepetitionInstructionEnum.None)this.repetitionInstructions.splice(h,1),h--;else switch(t.type){case l.RepetitionInstructionEnum.Fine:break;case l.RepetitionInstructionEnum.ToCoda:o++;break;case l.RepetitionInstructionEnum.Coda:i++;break;case l.RepetitionInstructionEnum.Segno:r++;break;case l.RepetitionInstructionEnum.DalSegnoAlFine:case l.RepetitionInstructionEnum.DalSegnoAlCoda:n++}}this.repetitionInstructions.sort(s.RepetitionInstructionComparer.Compare)}findInstructionInPreviousMeasure(r,i,o){for(let n=r-1;n>=0;n--){const h=this.repetitionInstructions[n];if(i-h.measureIndex===1&&h.type===o)return!0}return!1}backwardSearchForPreviousIdenticalInstruction(r,i){for(let o=r-1;o>=0;o--)if(this.repetitionInstructions[o].equals(i))return!0;return!1}addInstruction(r,i){let o=!0;for(let n=0,h=r.length;n0){const f=t.attribute("type").value;let p=1;try{t.attribute("number")&&(p=parseInt(t.attribute("number").value,10))}catch(d){u.default.debug("VoiceGenerator.addSlur number: ",d)}let m=i.PlacementEnum.NotYetDefined;const x=t.attribute("placement");x&&x.value&&(x.value==="above"?m=i.PlacementEnum.Above:x.value==="below"&&(m=i.PlacementEnum.Below));const y=t.attribute("orientation");if(y&&y.value&&(y.value==="over"?m=i.PlacementEnum.Above:y.value==="under"&&(m=i.PlacementEnum.Below)),f==="start"){let d=this.openSlurDict[p];d||(d=new s.Slur,this.openSlurDict[p]=d),d.StartNote=h,d.PlacementXml=m}else if(f==="stop"){const d=this.openSlurDict[p];if(d){const S=t.name;if(S==="slide"||S==="glissando"){const M=d.StartNote,E=new o.Glissando(M);E.AddNote(h),E.EndNote=h,h.NoteGlissando=E,delete this.openSlurDict[p]}else d.EndNote=h,h.isDuplicateSlur(d)||(h.NoteSlurs.push(d),d.StartNote.NoteSlurs.push(d)),delete this.openSlurDict[p]}}}}}catch{const f=r.ITextTranslation.translateText("ReaderErrorMessages/SlurError","Error while reading slur.");this.musicSheet.SheetErrors.pushMeasureError(f)}}}},1538(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.TempoSorter=g.TemposCalculator=void 0;const l=c(2561),s=c(899),u=c(6362),r=c(9161),i=c(5332);class o{calculate(t){o.processTempoExpressions(t)}static processTempoExpressions(t){var d;const f=[];for(let S=0,M=t.SourceMeasures;S=0&&E.SourceMeasureParent.TempoExpressions.splice(L,1)}else m.push(E),x=E}y=p;for(let S=0;SL&&_.beginsWithRepetition()){I--;break}I++}const A=t.SourceMeasures[I];let v,B=l.Fraction.plus(A.AbsoluteTimestamp,l.Fraction.minus(A.Duration,new l.Fraction(1,64)));S0&&(p.TempoInBpm=t.DefaultStartTempoInBpm),p.TempoInBpm===0&&(p.TempoInBpm=r.InstantaneousTempoExpression.getDefaultValueForInstTempo[r.InstTempo.moderato])),p.TempoInBpm}}g.TemposCalculator=o;class n{static Compare(t,f){let p=0;if(p=n.CompareNumber(t.AbsoluteTimestamp.RealValue,f.AbsoluteTimestamp.RealValue),p!==0)return p;const m=n.calcSortPriority(t),x=n.calcSortPriority(f);return p=n.CompareNumber(m,x),p}static calcSortPriority(t){if(t.InstantaneousTempo!=null){switch(t.InstantaneousTempo.TempoType){case r.TempoType.metronomeMark:return 1;case r.TempoType.inst:return 2;case r.TempoType.change:switch(t.InstantaneousTempo.ChangeSubType){case r.ChangeSubType.atempo:case r.ChangeSubType.doppioMovimento:return 3;case r.ChangeSubType.tempoprimo:return 4}}return 5}return 9}static CompareNumber(t,f){return t0||fe.length>0)&&!this.currentNote.ParentVoiceEntry.IsGrace&&(this.slurReader.addSlur(ue,this.currentNote),fe.length>0&&this.slurReader.addSlur(fe,this.currentNote),xe.length>0&&this.slurReader.addSlur(xe,this.currentNote));const ve=se.elements("tuplet");ve.length>0&&(this.openTupletNumber=this.addTuplet(F,ve),te=!0);const Se=se.element("arpeggiate");if(Se!==void 0){let Me;if(this.currentVoiceEntry.Arpeggio)Me=this.currentVoiceEntry.Arpeggio;else{let _e=!1;for(const Te of this.currentStaffEntry.VoiceEntries)if(Te.Arpeggio){_e=!0,Me=Te.Arpeggio;break}if(!_e){let Te=v.ArpeggioType.ARPEGGIO_DIRECTIONLESS;const Le=Se.attribute("direction");if(Le)switch(Le.value){case"up":Te=v.ArpeggioType.ROLL_UP;break;case"down":Te=v.ArpeggioType.ROLL_DOWN;break;default:Te=v.ArpeggioType.ARPEGGIO_DIRECTIONLESS}Me=new v.Arpeggio(this.currentVoiceEntry,Te),this.currentVoiceEntry.Arpeggio=Me}}Me.addNote(this.currentNote)}const ye=se.elements("tied");ye.length>0&&this.addTie(ye,oe,$,t.TieTypes.SIMPLE);const be=se.element("technical");if(be){const Me=be.elements("hammer-on");Me.length>0&&this.addTie(Me,oe,$,t.TieTypes.HAMMERON);const _e=be.elements("pull-off");_e.length>0&&this.addTie(_e,oe,$,t.TieTypes.PULLOFF)}}F.element("time-modification")===void 0||te||this.handleTimeModificationNode(F)}catch(q){E.default.warn(q);const te=m.ITextTranslation.translateText("ReaderErrorMessages/NoteError","Ignored erroneous Note.");this.musicSheet.SheetErrors.pushMeasureError(te),this.musicSheet.SheetErrors.pushMeasureError(q)}return this.currentNote}checkForStaffEntryLink(F,k,j,P){const G=new M.StaffEntryLink(this.currentVoiceEntry);G.LinkStaffEntries.push(j),j.Link=G;const Y=this.currentVoiceEntry.Timestamp.clone(),X=P.getVerticalContainerByTimestamp(Y);return(j=X.StaffEntries[F])||(j=new o.SourceStaffEntry(X,k),X.StaffEntries[F]=j),j.VoiceEntries.push(this.currentVoiceEntry),G.LinkStaffEntries.push(j),j.Link=G,j}checkForOpenBeam(){this.openBeams.length>0&&this.currentNote&&this.handleOpenBeam()}checkOpenTies(){const F=this.openTieDict;for(const k in F)if(F.hasOwnProperty(k)){const j=F[k];p.Fraction.plus(j.StartNote.ParentStaffEntry.Timestamp,j.Duration).lt(j.StartNote.SourceMeasure.Duration)&&delete F[k]}}hasVoiceEntry(){return this.currentVoiceEntry!==void 0}readArticulations(F,k,j){const P=F.element("articulations");P&&this.articulationReader.addArticulationExpression(P,k);const G=F.element("fermata");G&&this.articulationReader.addFermata(G,k);const Y=F.element("technical");Y&&this.articulationReader.addTechnicalArticulations(Y,k,j);const X=F.element("ornaments");X&&this.articulationReader.addOrnament(X,k)}addSingleNote(F,k,j,P,G,Y,X,ie,oe,$,Q,ne,ee,N){let R,O,U,H,W=0,K=d.AccidentalEnum.NONE,q=S.NoteEnum.C,te=S.NoteEnum.C,se=0,ue=0;const fe=F.elements();for(let Te=0,Le=fe.length;Te0&&this.openBeams.last().ExtendedNoteList.push(R),R}addNoteInfo(F,k,j,P,G,Y,X,ie,oe){F.NoteTypeXml=k,F.PrintObject=j,F.IsCueNote=P,F.NormalNotes=G,F.displayStepUnpitched=Y,F.displayOctaveUnpitched=X,F.NoteheadColorXml=ie,F.NoteheadColor=ie}createBeam(F,k){var j;try{const P=F.element("beam");let G;if(P!==void 0&&P.hasAttributes&&(G=P.attribute("number")),G){let Y=parseInt(G.value,10);const X=F.elements("beam"),ie=X[0].value;X&&(ie==="begin"?(Y===((j=this.openBeams.last())==null?void 0:j.BeamNumber)?(this.beamNumberOffset++,Y+=this.beamNumberOffset):this.openBeams.last()&&this.handleOpenBeam(),this.openBeams.push(new n.Beam(Y,this.beamNumberOffset))):Y+=this.beamNumberOffset);let oe=!1;if(!(Y>0&&Y<=this.openBeams.length&&this.openBeams[Y-1]))return void E.default.debug("[OSMD] invalid beamnumber");for(let $=0,Q=this.openBeams[Y-1].Notes.length;$1){for(let Q=1;Q0&&$.SecondaryBreakIndices.push(ne);break}}ie==="end"&&this.endBeam()}}}catch(P){const G=m.ITextTranslation.translateText("ReaderErrorMessages/BeamError","Error while reading beam.");throw this.musicSheet.SheetErrors.pushMeasureError(G),new y.MusicSheetReadingException("",P)}}endBeam(){this.openBeams.pop(),this.beamNumberOffset=Math.max(0,this.beamNumberOffset-1)}handleOpenBeam(){const F=this.openBeams.last();if(F.Notes.length!==0){if(F.Notes.length===1)return F.Notes[0].NoteBeam=void 0,void this.endBeam();if(this.currentNote===I.CollectionUtil.last(F.Notes))this.endBeam();else{const k=I.CollectionUtil.last(F.Notes).ParentStaffEntry,j=this.currentMeasure.getVerticalContainerIndexByTimestamp(k.Timestamp),P=k.VerticalContainerParent.StaffEntries.indexOf(k);if(j1){let G=F.element("time-modification");G&&(G=G.element("actual-notes"));const Y=k;for(let X=0,ie=Y.length;X1&&this.openTupletNumber--),this.tupletDict[R]=U;const W=[];W.push(this.currentNote),U.Notes.push(W),U.Fractions.push(this.getTupletNoteDurationFromType(F)),this.currentNote.NoteTuplet=U,this.openTupletNumber=R}else if(N.value==="stop"){let R=1;oe.attribute("number")&&(R=parseInt(oe.attribute("number").value,10));const O=this.tupletDict[R];if(O){const U=oe.attribute("placement");U&&(U.value==="below"?O.tupletLabelNumberPlacement=_.PlacementEnum.Below:O.tupletLabelNumberPlacement=_.PlacementEnum.Above,O.PlacementFromXml=!0);const H=[];if(H.push(this.currentNote),O.Notes.push(H),!O.PlacementFromXml){let W=!1;for(const K of O.Notes){for(const q of K)if(!q.isRest()){q.StemDirectionXml===r.StemDirectionType.Down?O.tupletLabelNumberPlacement=_.PlacementEnum.Below:O.tupletLabelNumberPlacement=_.PlacementEnum.Above,W=!0;break}if(W)break}}O.Fractions.push(this.getTupletNoteDurationFromType(F)),this.currentNote.NoteTuplet=O,delete this.tupletDict[R],Object.keys(this.tupletDict).length===0?this.openTupletNumber=0:Object.keys(this.tupletDict).length>1&&this.openTupletNumber--}}}}}else if(k[0]){const G=k[0];if(G.hasAttributes){const Y=G.attribute("type").value;let X=1;G.attribute("number")&&(X=parseInt(G.attribute("number").value,10));const ie=isNaN(X),oe=this.readShowNumberNoneGiven(G),$=G.attribute("bracket");$&&$.value==="yes"?(P=!0,j=!0):$&&$.value==="no"&&(j=!1);let Q=this.musicSheet.Rules.TupletsRatioed;const ne=G.attribute("show-number");if(ne&&ne.value==="both"&&this.musicSheet.Rules.TupletsRatioedUseXMLValue&&(Q=!0),Y==="start"){let ee=0,N=F.element("time-modification");if(N&&(N=N.element("actual-notes")),N&&(ee=parseInt(N.value,10),isNaN(ee))){const H=m.ITextTranslation.translateText("ReaderErrorMessages/TupletNoteDurationError","Invalid tuplet note duration.");throw this.musicSheet.SheetErrors.pushMeasureError(H),new y.MusicSheetReadingException(H)}ie&&(this.openTupletNumber++,X=this.openTupletNumber);let R=this.tupletDict[X];R||(R=this.tupletDict[X]=new f.Tuplet(ee,P),R.Ratioed=Q,R.BracketedXmlValue=j,R.ShowNumberNoneGivenInXml=oe,R.tupletLabelNumberPlacement=_.PlacementEnum.Above);const O=G.attribute("placement");O&&(O.value==="below"?R.tupletLabelNumberPlacement=_.PlacementEnum.Below:R.tupletLabelNumberPlacement=_.PlacementEnum.Above,R.PlacementFromXml=!0);const U=[];U.push(this.currentNote),R.Notes.push(U),R.Fractions.push(this.getTupletNoteDurationFromType(F)),this.currentNote.NoteTuplet=R,this.openTupletNumber=X}else if(Y==="stop"){ie&&(X=this.openTupletNumber);const ee=this.tupletDict[this.openTupletNumber];if(ee){const N=G.attribute("placement");N&&(N.value==="below"?ee.tupletLabelNumberPlacement=_.PlacementEnum.Below:ee.tupletLabelNumberPlacement=_.PlacementEnum.Above,ee.PlacementFromXml=!0);const R=[];if(R.push(this.currentNote),ee.Notes.push(R),!ee.PlacementFromXml){let O=!1;for(const U of ee.Notes){for(const H of U)if(!H.isRest()){H.StemDirectionXml===r.StemDirectionType.Down?ee.tupletLabelNumberPlacement=_.PlacementEnum.Below:ee.tupletLabelNumberPlacement=_.PlacementEnum.Above,O=!0;break}if(O)break}}ee.Fractions.push(this.getTupletNoteDurationFromType(F)),this.currentNote.NoteTuplet=ee,Object.keys(this.tupletDict).length===0?this.openTupletNumber=0:Object.keys(this.tupletDict).length>1&&this.openTupletNumber--,delete this.tupletDict[X]}}}}return this.openTupletNumber}readShowNumberNoneGiven(F){const k=F.attribute("show-number");return!(!(k!=null&&k.value)||k.value!=="none")}handleTimeModificationNode(F){if(this.tupletDict[this.openTupletNumber])try{const k=this.tupletDict[this.openTupletNumber],j=I.CollectionUtil.last(k.Notes);let P;j[0].ParentVoiceEntry.Timestamp.Equals(this.currentVoiceEntry.Timestamp)?P=j:(P=[],k.Notes.push(P),k.Fractions.push(this.getTupletNoteDurationFromType(F))),P.push(this.currentNote),this.currentNote.NoteTuplet=k}catch(k){const j=m.ITextTranslation.translateText("ReaderErrorMessages/TupletNumberError","Invalid tuplet number.");throw this.musicSheet.SheetErrors.pushMeasureError(j),k}else if(this.currentVoiceEntry.Notes.length>0){const k=this.currentVoiceEntry.Notes[0];if(k.NoteTuplet){const j=k.NoteTuplet;I.CollectionUtil.last(j.Notes).push(this.currentNote),this.currentNote.NoteTuplet=j}}}addTie(F,k,j,P){if(F){if(F.length===1){const G=F[0];if(G!==void 0&&G.attributes()){const Y=this.getTieDirection(G),X=G.attribute("type").value;try{if(X==="start"){const ie=this.findCurrentNoteInTieDict(this.currentNote);ie<0&&delete this.openTieDict[ie];const oe=this.getNextAvailableNumberForTie(),$=new h.Tie(this.currentNote,P);this.openTieDict[oe]=$,$.TieNumber=oe,$.TieDirection=Y}else if(X==="stop"){const ie=this.findCurrentNoteInTieDict(this.currentNote),oe=this.openTieDict[ie];oe&&(oe.AddNote(this.currentNote),delete this.openTieDict[ie])}}catch{const oe=m.ITextTranslation.translateText("ReaderErrorMessages/TieError","Error while reading tie.");this.musicSheet.SheetErrors.pushMeasureError(oe)}}}else if(F.length===2){const G=this.findCurrentNoteInTieDict(this.currentNote);if(G>=0){const Y=this.openTieDict[G];Y.AddNote(this.currentNote);for(const X of F)if(X.attribute("type").value==="start"){const ie=this.getTieDirection(X);Y.NoteIndexToTieDirection[Y.Notes.length-1]=ie}}}}}getTieDirection(F){let k=_.PlacementEnum.NotYetDefined;const j=F.attribute("placement");j&&(j.value==="above"?k=_.PlacementEnum.Above:j.value==="below"&&(k=_.PlacementEnum.Below));const P=F.attribute("orientation");return P&&(P.value==="over"?k=_.PlacementEnum.Above:P.value==="under"&&(k=_.PlacementEnum.Below)),k}getNextAvailableNumberForTie(){const F=Object.keys(this.openTieDict);if(F.length===0)return 1;F.sort((k,j)=>+k-+j);for(let k=0;k0&&(m+="("+x.adds.join(",")+")"),x.alts.length>0&&(m+="(alt "+x.alts.join(",")+")"),x.subs.length>0&&(m+="(omit "+x.subs.join(",")+")"),h.BassPitch){let M=h.BassPitch;s.MusicSheetCalculator.transposeCalculator&&(M=s.MusicSheetCalculator.transposeCalculator.transposePitch(h.BassPitch,f,t)),m+="/",m+=l.Pitch.getNoteEnumString(M.FundamentalNote),m+=h.getTextForAccidental(M.Accidental)}return m}getTextForAccidental(h){const t=this.rules.ChordAccidentalTexts.getValue(h);return t!==void 0?t:""}getTextFromChordKindEnum(h){return this.rules.ChordSymbolLabelTexts.getValue(h)??""}},g.Degree=class{constructor(h,t,f){this.value=h,this.alteration=t,this.text=f}};class i{constructor(t,f,p){this.alternateName=t,this.chordKind=f,this.degrees=p}static createCustomChord(t,f,p){return new i(t,f,p)}static renameCustomChord(t,f,p){for(const m of p)m.alternateName===t&&(m.alternateName=f)}}var o,n;g.CustomChord=i,function(h){h[h.add=0]="add",h[h.alter=1]="alter",h[h.subtract=2]="subtract"}(o||(g.ChordDegreeText=o={})),function(h){h[h.major=0]="major",h[h.minor=1]="minor",h[h.augmented=2]="augmented",h[h.diminished=3]="diminished",h[h.dominant=4]="dominant",h[h.majorseventh=5]="majorseventh",h[h.minorseventh=6]="minorseventh",h[h.diminishedseventh=7]="diminishedseventh",h[h.augmentedseventh=8]="augmentedseventh",h[h.halfdiminished=9]="halfdiminished",h[h.majorminor=10]="majorminor",h[h.majorsixth=11]="majorsixth",h[h.minorsixth=12]="minorsixth",h[h.dominantninth=13]="dominantninth",h[h.majorninth=14]="majorninth",h[h.minorninth=15]="minorninth",h[h.dominant11th=16]="dominant11th",h[h.major11th=17]="major11th",h[h.minor11th=18]="minor11th",h[h.dominant13th=19]="dominant13th",h[h.major13th=20]="major13th",h[h.minor13th=21]="minor13th",h[h.suspendedsecond=22]="suspendedsecond",h[h.suspendedfourth=23]="suspendedfourth",h[h.Neapolitan=24]="Neapolitan",h[h.Italian=25]="Italian",h[h.French=26]="French",h[h.German=27]="German",h[h.pedal=28]="pedal",h[h.power=29]="power",h[h.Tristan=30]="Tristan",h[h.none=31]="none"}(n||(g.ChordSymbolEnum=n={}))},6362(de,g){var c;Object.defineProperty(g,"__esModule",{value:!0}),g.PlacementEnum=g.AbstractExpression=void 0,g.AbstractExpression=class{constructor(l){this.placement=l}static isStringInStringList(l,s){for(let u=0,r=l.length;u=r.allargando&&o<=r.ritenuto}get TempoType(){return this.tempoType}set TempoType(o){this.tempoType=o}get StartTempo(){return this.startTempo}set StartTempo(o){this.startTempo=o}get EndTempo(){return this.endTempo}set EndTempo(o){this.endTempo=o}get AbsoluteStartTimestamp(){return l.Fraction.plus(this.parentMultiTempoExpression.SourceMeasureParent.AbsoluteTimestamp,this.parentMultiTempoExpression.Timestamp)}get AbsoluteEndTimestamp(){return this.absoluteEndTimestamp}set AbsoluteEndTimestamp(o){this.absoluteEndTimestamp=o,this.AbsoluteTimeSpan=l.Fraction.minus(this.AbsoluteEndTimestamp,this.AbsoluteStartTimestamp).RealValue}get AbsoluteTimestamp(){return this.ParentMultiTempoExpression.AbsoluteTimestamp}getAbsoluteFloatTimestamp(){return this.ParentMultiTempoExpression.AbsoluteTimestamp.RealValue}getInterpolatedTempo(o){const n=l.Fraction.plus(this.parentMultiTempoExpression.SourceMeasureParent.AbsoluteTimestamp,this.parentMultiTempoExpression.Timestamp);if(o.lt(n))return-1;if(this.absoluteEndTimestamp.lt(o))return-2;const h=l.Fraction.minus(o,n).RealValue/l.Fraction.minus(this.absoluteEndTimestamp,n).RealValue;return Math.max(0,Math.min(250,this.startTempo+(this.endTempo-this.startTempo)*h))}setTempoType(){u.isStringInStringList(u.listContinuousTempoFaster,this.label)?this.tempoType=r.accelerando:u.isStringInStringList(u.listContinuousTempoSlower,this.label)&&(this.tempoType=r.ritardando)}getTempoFactor(o=this.Label){return 1}}var r;g.ContinuousTempoExpression=u,u.listContinuousTempoFaster=["accelerando","accel","piu mosso","poco piu","stretto"],u.listContinuousTempoSlower=["poco meno","meno mosso","piu lento","calando","allargando","rallentando","ritardando","ritenuto","ritard.","ritard","rit.","rit","riten.","riten"],function(i){i[i.accelerando=0]="accelerando",i[i.stretto=1]="stretto",i[i.stringendo=2]="stringendo",i[i.mosso=3]="mosso",i[i.piuMosso=4]="piuMosso",i[i.allargando=5]="allargando",i[i.calando=6]="calando",i[i.menoMosso=7]="menoMosso",i[i.rallentando=8]="rallentando",i[i.ritardando=9]="ritardando",i[i.ritard=10]="ritard",i[i.rit=11]="rit",i[i.ritenuto=12]="ritenuto",i[i.rubato=13]="rubato",i[i.precipitando=14]="precipitando"}(r||(g.ContinuousTempoType=r={}))},437(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.OctaveEnum=g.OctaveShift=void 0;const l=c(8233);var s;g.OctaveShift=class{constructor(u,r){this.numberXml=1,this.endVoiceEntryIndex=0,this.setOctaveShiftValue(u,r)}get Type(){return this.octaveValue}set Type(u){this.octaveValue=u}get StaffNumber(){return this.staffNumber}set StaffNumber(u){this.staffNumber=u}get ParentStartMultiExpression(){return this.startMultiExpression}set ParentStartMultiExpression(u){this.startMultiExpression=u}get ParentEndMultiExpression(){return this.endMultiExpression}set ParentEndMultiExpression(u){this.endMultiExpression=u}setOctaveShiftValue(u,r){this.octaveValue=r===1&&u==="down"?s.VA8:r===1&&u==="up"?s.VB8:r===2&&u==="down"?s.MA15:r===2&&u==="up"?s.MB15:s.NONE}static getPitchFromOctaveShift(u,r){if(!u)return;if(u.OctaveShiftApplied)return u;let i=u.Octave;switch(r){case s.VA8:i-=1;break;case s.VB8:i+=1;break;case s.MA15:i-=2;break;case s.MB15:i+=2;break;case s.NONE:default:i+=0}const o=new l.Pitch(u.FundamentalNote,i,u.Accidental);return o.OctaveShiftApplied=!0,o}},function(u){u[u.VA8=0]="VA8",u[u.VB8=1]="VB8",u[u.MA15=2]="MA15",u[u.MB15=3]="MB15",u[u.NONE=4]="NONE"}(s||(g.OctaveEnum=s={}))},3253(de,g){Object.defineProperty(g,"__esModule",{value:!0}),g.Pedal=void 0,g.Pedal=class{constructor(c=!1,l=!0){this.ChangeEnd=!1,this.ChangeBegin=!1,this.EndsStave=!1,this.BeginsStave=!1,this.line=c,this.sign=l}get IsLine(){return this.line}get IsSign(){return this.sign}}},6229(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.Slur=void 0;const l=c(2561);g.Slur=class{constructor(){}get StartNote(){return this.startNote}set StartNote(s){this.startNote=s}get EndNote(){return this.endNote}set EndNote(s){this.endNote=s}startNoteHasMoreStartingSlurs(){if(!this.startNote)return!1;for(let s=0,u=this.startNote.NoteSlurs.length;s0&&(this.expressions[0].expression instanceof s.InstantaneousDynamicExpression||this.expressions[0].expression instanceof u.ContinuousDynamicExpression||this.expressions[0].expression instanceof r.MoodExpression||this.expressions[0].expression instanceof i.UnknownExpression)&&(t=this.expressions[0].expression.Placement),t}getFontstyleOfFirstEntry(){let t=n.FontStyles.Regular;return this.expressions.length>0&&(this.expressions[0].expression instanceof u.ContinuousDynamicExpression||this.expressions[0].expression instanceof r.MoodExpression?t=n.FontStyles.Italic:this.expressions[0].expression instanceof i.UnknownExpression&&(t=this.expressions[0].expression.fontStyle??n.FontStyles.Regular)),t}getColorXMLOfFirstEntry(){let t;return this.expressions.length>=1&&(t=this.expressions[0].expression.ColorXML),t}addExpression(t,f){t instanceof s.InstantaneousDynamicExpression?(this.instantaneousDynamic&&this.removeExpressionFromEntryList(this.InstantaneousDynamic),this.instantaneousDynamic=t,this.instantaneousDynamic.ParentMultiExpression=this):t instanceof u.ContinuousDynamicExpression?this.startingContinuousDynamic=t:t instanceof r.MoodExpression?this.moodList.push(t):t instanceof i.UnknownExpression&&this.unknownList.push(t),this.addExpressionToEntryList(t,f)}CompareTo(t){return this.Timestamp.RealValue>t.Timestamp.RealValue?1:this.Timestamp.RealValue0&&(this.expressions[0].Expression instanceof s.InstantaneousTempoExpression||this.expressions[0].Expression instanceof i.ContinuousTempoExpression)&&(n=this.expressions[0].Expression.Placement),n}getFontstyleOfFirstEntry(){let n=r.FontStyles.Regular;return this.expressions[0].Expression instanceof s.InstantaneousTempoExpression?n=r.FontStyles.Bold:this.expressions[0].Expression instanceof i.ContinuousTempoExpression&&(n=r.FontStyles.Italic),n}addExpression(n,h){if(this.checkIfAlreadyExists(n))return;n instanceof s.InstantaneousTempoExpression?this.instantaneousTempo=n:n instanceof i.ContinuousTempoExpression&&(this.continuousTempo=n);const t=new o;t.prefix=h,t.Expression=n,t.label=n.Label,this.expressions.push(t)}CompareTo(n){return this.Timestamp.RealValue>n.Timestamp.RealValue?1:this.Timestamp.RealValue0)for(let h=0;h=0}getAlterationForPitch(n){return this.keyType>0&&this.alteratedNotes.indexOf(n.FundamentalNote)<=this.keyType?u.AccidentalEnum.SHARP:this.keyType<0&&this.alteratedNotes.indexOf(n.FundamentalNote)<=Math.abs(this.keyType)?u.AccidentalEnum.FLAT:u.AccidentalEnum.NONE}ToString(){return"Key: "+this.keyType+this.mode}OperatorEquals(n){const h=this;return h===n||!(!h||!n)&&h.Key===n.Key&&h.Mode===n.Mode}OperatorNotEqual(n){return!this.OperatorEquals(n)}}var i;g.KeyInstruction=r,r.sharpPositionList=[s.NoteEnum.F,s.NoteEnum.C,s.NoteEnum.G,s.NoteEnum.D,s.NoteEnum.A,s.NoteEnum.E,s.NoteEnum.B],r.flatPositionList=[s.NoteEnum.B,s.NoteEnum.E,s.NoteEnum.A,s.NoteEnum.D,s.NoteEnum.G,s.NoteEnum.C,s.NoteEnum.F],g.NoteEnumToHalfToneLink=class{constructor(o,n){this.note=o,this.halfTone=n}},function(o){o[o.major=0]="major",o[o.minor=1]="minor",o[o.none=2]="none",o[o.dorian=3]="dorian",o[o.phrygian=4]="phrygian",o[o.lydian=5]="lydian",o[o.mixolydian=6]="mixolydian",o[o.aeolian=7]="aeolian",o[o.ionian=8]="ionian",o[o.locrian=9]="locrian"}(i||(g.KeyEnum=i={}))},1645(de,g){var c,l;Object.defineProperty(g,"__esModule",{value:!0}),g.AlignmentType=g.RepetitionInstructionEnum=g.RepetitionInstruction=g.RepetitionInstructionComparer=void 0,g.RepetitionInstructionComparer=class{static Compare(s,u){if(s.parentRepetition!==void 0&&u.parentRepetition){if(s.alignment===l.End&&u.alignment===l.End){if(s.parentRepetition.StartIndexu.parentRepetition.StartIndex)return-1}if(s.alignment===l.Begin&&u.alignment===l.Begin){if(s.parentRepetition.EndIndexu.parentRepetition.EndIndex)return-1}}return 0}},g.RepetitionInstruction=class{constructor(s,u,r=l.End,i=void 0,o=void 0){this.endingIndices=void 0,this.measureIndex=s,o&&(this.endingIndices=o.slice()),this.type=u,this.alignment=r,this.parentRepetition=i}CompareTo(s){const u=s;if(this.measureIndex>u.measureIndex)return 1;if(this.measureIndex=0&&(this.syllableIndex=o)}get Text(){return this.text}set Text(s){this.text=s}get Word(){return this.word}get Parent(){return this.parent}set Parent(s){this.parent=s}get VerseNumber(){return this.verseNumber}get SyllableIndex(){return this.syllableIndex}get IsTranslation(){return this.VerseNumber.endsWith("translation")}get IsChorus(){return this.VerseNumber.startsWith("chorus")}get FontStyle(){return this.IsChorus||this.IsTranslation?l.FontStyles.Italic:l.FontStyles.Regular}}},649(de,g){Object.defineProperty(g,"__esModule",{value:!0}),g.LyricWord=void 0,g.LyricWord=class{constructor(){this.syllables=[]}get Syllables(){return this.syllables}containsVoiceEntry(c){for(let l=0,s=this.Syllables.length;l2:(s.default.warn("notehead: sourceNote and filledXmlAttribute undefined."),h=!0)),this.filled=h}get SourceNote(){return this.sourceNote}get Shape(){return this.shape}get Filled(){return this.filled}static ShapeTypeXmlToShape(o){switch(o.toLowerCase()){case"normal":return r.NORMAL;case"none":return r.NONE;case"x":return r.X;case"slash":return r.SLASH;case"diamond":return r.DIAMOND;case"square":case"la":return r.SQUARE;case"do":case"triangle":return r.TRIANGLE;case"inverted triangle":return r.TRIANGLE_INVERTED;case"rectangle":return r.RECTANGLE;case"circle-x":return r.CIRCLEX;default:return s.default.info("unsupported/unhandled xml notehead '"+o+"'. Using normal notehead."),r.NORMAL}}}var r;g.Notehead=u,function(i){i[i.CIRCLEX=0]="CIRCLEX",i[i.DIAMOND=1]="DIAMOND",i[i.NORMAL=2]="NORMAL",i[i.NONE=3]="NONE",i[i.RECTANGLE=4]="RECTANGLE",i[i.SLASH=5]="SLASH",i[i.SQUARE=6]="SQUARE",i[i.TRIANGLE=7]="TRIANGLE",i[i.TRIANGLE_INVERTED=8]="TRIANGLE_INVERTED",i[i.X=9]="X"}(r||(g.NoteHeadShape=r={}))},8215(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.OrnamentEnum=g.OrnamentContainer=void 0;const l=c(8233),s=c(6362);var u;g.OrnamentContainer=class{constructor(r){this.placement=s.PlacementEnum.Above,this.accidentalAbove=l.AccidentalEnum.NONE,this.accidentalBelow=l.AccidentalEnum.NONE,this.ornament=r}get GetOrnament(){return this.ornament}get AccidentalAbove(){return this.accidentalAbove}set AccidentalAbove(r){this.accidentalAbove=r}get AccidentalBelow(){return this.accidentalBelow}set AccidentalBelow(r){this.accidentalBelow=r}},function(r){r[r.Trill=0]="Trill",r[r.Turn=1]="Turn",r[r.InvertedTurn=2]="InvertedTurn",r[r.DelayedTurn=3]="DelayedTurn",r[r.DelayedInvertedTurn=4]="DelayedInvertedTurn",r[r.Mordent=5]="Mordent",r[r.InvertedMordent=6]="InvertedMordent"}(u||(g.OrnamentEnum=u={}))},4387(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.SourceMeasure=void 0;const l=c(2561),s=c(3236),u=c(2369),r=c(1645),i=c(1336),o=c(164),n=c(4543),h=c(6954);g.SourceMeasure=class{constructor(t,f){this.printNewSystemXml=!1,this.printNewPageXml=!1,this.IsSystemStartMeasure=!1,this.WidthFactor=1,this.hasLyrics=!1,this.hasMoodExpressions=!1,this.allRests=!1,this.isReducedToMultiRest=!1,this.multipleRestMeasureNumber=0,this.staffLinkedExpressions=[],this.tempoExpressions=[],this.verticalSourceStaffEntryContainers=[],this.graphicalMeasureErrors=[],this.firstRepetitionInstructions=[],this.lastRepetitionInstructions=[],this.completeNumberOfStaves=t,this.implicitMeasure=!1,this.hasEndLine=!1,this.endingBarStyleXml="",this.endingBarStyleEnum=h.SystemLinesEnum.SingleThin,this.firstInstructionsStaffEntries=new Array(t),this.lastInstructionsStaffEntries=new Array(t),this.rules=f,this.TempoInBPM=0;for(let p=0;p1)return t[this.measureListIndex-1]}get Rules(){return this.rules}get VerticalMeasureList(){return this.verticalMeasureList}set VerticalMeasureList(t){this.verticalMeasureList=t}get TempoInBPM(){return this.tempoInBPM}set TempoInBPM(t){this.tempoInBPM=t}findOrCreateStaffEntry(t,f,p){let m,x;for(const d of this.verticalSourceStaffEntryContainers)if(d.Timestamp.Equals(t)){x=d;break}if(x)return x.StaffEntries[f]?m=x.StaffEntries[f]:(m=new u.SourceStaffEntry(x,p),x.StaffEntries[f]=m),{createdNewContainer:!1,staffEntry:m};const y=this.verticalSourceStaffEntryContainers[this.verticalSourceStaffEntryContainers.length-1];if(this.verticalSourceStaffEntryContainers.length===0||y.Timestamp.lt(t)){const d=new s.VerticalSourceStaffEntryContainer(this,t.clone(),this.completeNumberOfStaves);this.verticalSourceStaffEntryContainers.push(d),m=new u.SourceStaffEntry(d,p),d.StaffEntries[f]=m}else for(let d=this.verticalSourceStaffEntryContainers.length-1;d>=0;d--){if(this.verticalSourceStaffEntryContainers[d].Timestamp.lt(t)){const S=new s.VerticalSourceStaffEntryContainer(this,t.clone(),this.completeNumberOfStaves);this.verticalSourceStaffEntryContainers.splice(d+1,0,S),m=new u.SourceStaffEntry(S,p),S.StaffEntries[f]=m;break}if(d===0){const S=new s.VerticalSourceStaffEntryContainer(this,t.clone(),this.completeNumberOfStaves);this.verticalSourceStaffEntryContainers.splice(d,0,S),m=new u.SourceStaffEntry(S,p),S.StaffEntries[f]=m;break}}return{createdNewContainer:!0,staffEntry:m}}findOrCreateVoiceEntry(t,f){let p,m=!1;for(const x of t.VoiceEntries)if(x.ParentVoice===f){p=x;break}return p||(p=new i.VoiceEntry(t.Timestamp,f,t),m=!0),{createdVoiceEntry:m,voiceEntry:p}}getPreviousSourceStaffEntryFromIndex(t,f){for(let p=f-1;p>=0;p--)if(this.verticalSourceStaffEntryContainers[p][t])return this.verticalSourceStaffEntryContainers[p][t]}getVerticalContainerIndexByTimestamp(t){for(let f=0,p=this.VerticalSourceStaffEntryContainers.length;f=0;E--){const L=this.verticalSourceStaffEntryContainers[E][d+S];if(L!==void 0&&L.hasTie()&&y.lt(l.Fraction.plus(L.Timestamp,L.calculateMaxNoteLength()))){y=l.Fraction.plus(L.Timestamp,L.calculateMaxNoteLength());break}}}m.push(y)}for(let x=0,y=m.length;x0)return!0}return!1}beginsWithRepetition(){return this.beginsWithLineRepetition()||this.beginsWithWordRepetition()}beginsWithLineRepetition(){for(let t=0,f=this.FirstRepetitionInstructions.length;t=0;m--)if(p=this.verticalSourceStaffEntryContainers[m].StaffEntries[t],p&&(!f||p.VoiceEntries.length>0))return p}canBeReducedToMultiRest(){var p,m;if(this.firstRepetitionInstructions.length>0||this.lastRepetitionInstructions.length>0)return!1;let t=!0,f=!1;for(const x of this.verticalSourceStaffEntryContainers)if(x){for(const y of x.StaffEntries)if(y&&y.ParentStaff.isVisible()){if(y.ChordContainers.length>0)return!1;y.ParentStaff.hasLyrics&&(f=!0);for(const d of y.VoiceEntries){for(const S of d.Notes)if(!S.isRest()){t=!1;break}if(!t)break}}}if(!t||f||this.hasMoodExpressions||this.tempoExpressions.length>0)return!1;for(const x of this.staffLinkedExpressions)if(x.length>0)return!1;for(const x of this.lastInstructionsStaffEntries)for(let y=0,d=x==null?void 0:x.Instructions.length;y0)return!0;return!1}hasTie(){for(let i=0,o=this.VoiceEntries.length;i0}}g.TabNote=s},5274(de,g,c){var l=this&&this.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(g,"__esModule",{value:!0}),g.Tie=void 0;const s=c(2561),u=c(6362),r=l(c(3065));g.Tie=class{constructor(i,o){this.notes=[],this.TieNumber=1,this.TieDirection=u.PlacementEnum.NotYetDefined,this.NoteIndexToTieDirection={},this.AddNote(i),this.type=o}getTieDirection(i){if(!i)return this.TieDirection;for(let o=0;o=0;l--)for(let s=0;s0)return!0;return!1}isStaccato(){for(const p of this.Articulations)if(p.articulationEnum===h.staccato)return!0;return!1}isAccent(){for(const p of this.Articulations)if(p.articulationEnum===h.accent||p.articulationEnum===h.strongaccent)return!0;return!1}getVerseNumberForLyricEntry(p){let m="1";return this.lyricsEntries.forEach((x,y)=>{p===y&&(m=x)}),m}createVoiceEntriesForOrnament(p,m){p||(p=this);const x=[];if(!p.ornamentContainer)return;const y=this.notes[0],d=y.Length,S=p.ParentVoice,M=p.Timestamp;let E=l.Fraction.createFromFraction(M);switch(p.ornamentContainer.GetOrnament){case r.OrnamentEnum.Trill:{const L=new l.Fraction(d.Numerator,8*d.Denominator),I=y.Pitch.getTransposedPitch(1);let T=m.getAlterationForPitch(I);p.OrnamentContainer.AccidentalAbove!==i.AccidentalEnum.NONE&&(T=p.ornamentContainer.AccidentalAbove);for(let A=0;A<8;A++)E=l.Fraction.plus(M,new l.Fraction(A*L.Numerator,L.Denominator)),A%2==0?this.createBaseVoiceEntry(E,L,S,y,x):this.createAlteratedVoiceEntry(E,L,S,y.SourceMeasure,I,T,x);break}case r.OrnamentEnum.Turn:{const L=new l.Fraction(d.Numerator,4*d.Denominator),I=y.Pitch.getTransposedPitch(-1),T=m.getAlterationForPitch(I),A=y.Pitch.getTransposedPitch(1),v=m.getAlterationForPitch(A);this.createAlteratedVoiceEntry(E,L,S,y.SourceMeasure,A,v,x),E.Add(L),this.createBaseVoiceEntry(E,L,S,y,x),E.Add(L),this.createAlteratedVoiceEntry(E,L,S,y.SourceMeasure,I,T,x),E.Add(L),this.createBaseVoiceEntry(E,L,S,y,x);break}case r.OrnamentEnum.InvertedTurn:{const L=new l.Fraction(d.Numerator,4*d.Denominator),I=y.Pitch.getTransposedPitch(-1),T=m.getAlterationForPitch(I),A=y.Pitch.getTransposedPitch(1),v=m.getAlterationForPitch(A);this.createAlteratedVoiceEntry(E,L,S,y.SourceMeasure,I,T,x),E.Add(L),this.createBaseVoiceEntry(E,L,S,y,x),E.Add(L),this.createAlteratedVoiceEntry(E,L,S,y.SourceMeasure,A,v,x),E.Add(L),this.createBaseVoiceEntry(E,L,S,y,x);break}case r.OrnamentEnum.DelayedTurn:{const L=new l.Fraction(d.Numerator,2*d.Denominator),I=y.Pitch.getTransposedPitch(-1),T=m.getAlterationForPitch(I),A=y.Pitch.getTransposedPitch(1),v=m.getAlterationForPitch(A);this.createBaseVoiceEntry(E,L,S,y,x),E=l.Fraction.plus(M,L),L.Denominator=8*d.Denominator,this.createAlteratedVoiceEntry(E,L,S,y.SourceMeasure,A,v,x),E.Add(L),this.createBaseVoiceEntry(E,L,S,y,x),E.Add(L),this.createAlteratedVoiceEntry(E,L,S,y.SourceMeasure,I,T,x),E.Add(L),this.createBaseVoiceEntry(E,L,S,y,x);break}case r.OrnamentEnum.DelayedInvertedTurn:{const L=new l.Fraction(d.Numerator,2*d.Denominator),I=y.Pitch.getTransposedPitch(-1),T=m.getAlterationForPitch(I),A=y.Pitch.getTransposedPitch(1),v=m.getAlterationForPitch(A);this.createBaseVoiceEntry(E,L,S,y,x),E=l.Fraction.plus(M,L),L.Denominator=8*d.Denominator,this.createAlteratedVoiceEntry(E,L,S,y.SourceMeasure,I,T,x),E.Add(L),this.createBaseVoiceEntry(E,L,S,y,x),E.Add(L),this.createAlteratedVoiceEntry(E,L,S,y.SourceMeasure,A,v,x),E.Add(L),this.createBaseVoiceEntry(E,L,S,y,x);break}case r.OrnamentEnum.Mordent:{const L=new l.Fraction(d.Numerator,4*d.Denominator),I=y.Pitch.getTransposedPitch(1),T=m.getAlterationForPitch(I);this.createBaseVoiceEntry(E,L,S,y,x),E.Add(L),this.createAlteratedVoiceEntry(E,L,S,y.SourceMeasure,I,T,x),L.Denominator=2*d.Denominator,E=l.Fraction.plus(M,L),this.createBaseVoiceEntry(E,L,S,y,x);break}case r.OrnamentEnum.InvertedMordent:{const L=new l.Fraction(d.Numerator,4*d.Denominator),I=y.Pitch.getTransposedPitch(-1),T=m.getAlterationForPitch(I);this.createBaseVoiceEntry(E,L,S,y,x),E.Add(L),this.createAlteratedVoiceEntry(E,L,S,y.SourceMeasure,I,T,x),L.Denominator=2*d.Denominator,E=l.Fraction.plus(M,L),this.createBaseVoiceEntry(E,L,S,y,x);break}default:throw new RangeError}return x}createBaseVoiceEntry(p,m,x,y,d){const S=new n(p,x,y.ParentStaffEntry),M=new u.Pitch(y.Pitch.FundamentalNote,y.Pitch.Octave,y.Pitch.Accidental),E=new s.Note(S,void 0,m,M,y.SourceMeasure);S.Notes.push(E),d.push(S)}createAlteratedVoiceEntry(p,m,x,y,d,S,M){const E=new n(p,x,void 0),L=new u.Pitch(d.FundamentalNote,d.Octave,S),I=new s.Note(E,void 0,m,L,y);E.Notes.push(I),M.push(E)}}var h,t;g.VoiceEntry=n,function(f){f[f.accent=0]="accent",f[f.strongaccent=1]="strongaccent",f[f.softaccent=2]="softaccent",f[f.marcatoup=3]="marcatoup",f[f.marcatodown=4]="marcatodown",f[f.invertedstrongaccent=5]="invertedstrongaccent",f[f.staccato=6]="staccato",f[f.staccatissimo=7]="staccatissimo",f[f.spiccato=8]="spiccato",f[f.tenuto=9]="tenuto",f[f.fermata=10]="fermata",f[f.invertedfermata=11]="invertedfermata",f[f.breathmark=12]="breathmark",f[f.caesura=13]="caesura",f[f.lefthandpizzicato=14]="lefthandpizzicato",f[f.naturalharmonic=15]="naturalharmonic",f[f.snappizzicato=16]="snappizzicato",f[f.upbow=17]="upbow",f[f.downbow=18]="downbow",f[f.scoop=19]="scoop",f[f.plop=20]="plop",f[f.doit=21]="doit",f[f.falloff=22]="falloff",f[f.stress=23]="stress",f[f.unstress=24]="unstress",f[f.detachedlegato=25]="detachedlegato",f[f.otherarticulation=26]="otherarticulation",f[f.bend=27]="bend"}(h||(g.ArticulationEnum=h={})),function(f){f[f.Undefined=-1]="Undefined",f[f.Up=0]="Up",f[f.Down=1]="Down",f[f.None=2]="None",f[f.Double=3]="Double"}(t||(g.StemDirectionType=t={}))},7456(de,g,c){var l=this&&this.__createBinding||(Object.create?function(u,r,i,o){o===void 0&&(o=i);var n=Object.getOwnPropertyDescriptor(r,i);n&&!("get"in n?!r.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return r[i]}}),Object.defineProperty(u,o,n)}:function(u,r,i,o){o===void 0&&(o=i),u[o]=r[i]}),s=this&&this.__exportStar||function(u,r){for(var i in u)i==="default"||Object.prototype.hasOwnProperty.call(r,i)||l(r,u,i)};Object.defineProperty(g,"__esModule",{value:!0}),s(c(4236),g),s(c(8365),g),s(c(9719),g),s(c(7718),g),s(c(4249),g),s(c(1850),g),s(c(4064),g),s(c(5282),g),s(c(8215),g),s(c(4387),g),s(c(2369),g),s(c(1910),g),s(c(6644),g),s(c(5274),g),s(c(4268),g),s(c(3236),g),s(c(5534),g),s(c(1336),g),s(c(9184),g),s(c(1850),g),s(c(5282),g),s(c(4387),g),s(c(2369),g),s(c(3236),g),s(c(5274),g)},1745(de,g,c){var l=this&&this.__createBinding||(Object.create?function(u,r,i,o){o===void 0&&(o=i);var n=Object.getOwnPropertyDescriptor(r,i);n&&!("get"in n?!r.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return r[i]}}),Object.defineProperty(u,o,n)}:function(u,r,i,o){o===void 0&&(o=i),u[o]=r[i]}),s=this&&this.__exportStar||function(u,r){for(var i in u)i==="default"||Object.prototype.hasOwnProperty.call(r,i)||l(r,u,i)};Object.defineProperty(g,"__esModule",{value:!0}),s(c(7307),g),s(c(9252),g),s(c(7586),g),s(c(7435),g),s(c(427),g),s(c(5294),g),s(c(7456),g),s(c(4076),g),s(c(1121),g),s(c(6352),g),s(c(899),g),s(c(2870),g)},3173(de,g){Object.defineProperty(g,"__esModule",{value:!0}),g.AJAX=void 0,g.AJAX=class{static ajax(c,l=9e3){let s;const u=c.indexOf(".mxl")>-1?"text/plain; charset=x-user-defined":"application/xml";if(XMLHttpRequest)s=new XMLHttpRequest;else{if(!ActiveXObject)return Promise.reject(new Error("XMLHttp not supported."));s=new ActiveXObject("Microsoft.XMLHTTP")}return s.timeout=l,new Promise((r,i)=>{s.onreadystatechange=()=>{s.readyState===XMLHttpRequest.DONE&&(s.status===200||s.status===0&&s.responseText?r(s.responseText):i(new Error("Could not retrieve requested URL "+s.status)))},s.ontimeout=o=>{i(new Error("Server request Timeout"))},s.overrideMimeType(u),s.open("GET",c,!0),s.send()})}}},6597(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.Cursor=void 0;const l=c(2561),s=c(624);g.Cursor=class{constructor(u,r,i){this.hidden=!0,this.currentPageNumber=1,this.skipInvisibleNotes=!0,this.container=u,this.openSheetMusicDisplay=r,this.rules=this.openSheetMusicDisplay.EngravingRules,this.cursorOptions=i;let o=0;for(this.cursorElementId="cursorImg-0";document.getElementById(this.cursorElementId);)o++,this.cursorElementId=`cursorImg-${o}`;const n=document.createElement("img");n.id=this.cursorElementId,n.style.position="absolute",this.cursorOptions.follow===!0?(this.wantedZIndex="-1",n.style.zIndex=this.wantedZIndex):(this.wantedZIndex="-2",n.style.zIndex=this.wantedZIndex),this.cursorElement=n,this.container.appendChild(n)}adjustToBackgroundColor(){let u;u=this.rules.PageBackgroundColor?"1":this.wantedZIndex,this.cursorElement.style.zIndex=u}init(u,r){this.manager=u,this.graphic=r,this.reset(),this.hidden=!0,this.hide()}show(){this.hidden=!1,this.update(),this.adjustToBackgroundColor()}resetIterator(){if(!this.openSheetMusicDisplay.Sheet||!this.openSheetMusicDisplay.Sheet.SourceMeasures)return void console.log("OSMD.Cursor.resetIterator(): sheet or measures were null/undefined.");const u=this.openSheetMusicDisplay.Sheet.SourceMeasures.length-1;let r=this.rules.MinMeasureToDrawIndex;r=Math.min(r,u);let i=this.rules.MaxMeasureToDrawIndex;if(i=Math.min(i,u),this.openSheetMusicDisplay.Sheet&&this.openSheetMusicDisplay.Sheet.SourceMeasures.length>r&&(this.openSheetMusicDisplay.Sheet.SelectionStart=this.openSheetMusicDisplay.Sheet.SourceMeasures[r].AbsoluteTimestamp),this.openSheetMusicDisplay.Sheet&&this.openSheetMusicDisplay.Sheet.SourceMeasures.length>i){const o=this.openSheetMusicDisplay.Sheet.SourceMeasures[i];this.openSheetMusicDisplay.Sheet.SelectionEnd=l.Fraction.plus(o.AbsoluteTimestamp,o.Duration)}this.iterator=this.manager.getIterator(),this.iterator.SkipInvisibleNotes=this.skipInvisibleNotes}getStaffEntryFromVoiceEntry(u){const r=u.ParentSourceStaffEntry.VerticalContainerParent.ParentMeasure.measureListIndex,i=u.ParentSourceStaffEntry.ParentStaff.idInMusicSheet;return this.graphic.findGraphicalStaffEntryFromMeasureList(i,r,u.ParentSourceStaffEntry)}update(){if(this.hidden||this.hidden===void 0||this.hidden===null)return;this.updateCurrentPage();const u=this.iterator;let r,i=u.CurrentVisibleVoiceEntries(),o=u.CurrentMeasureIndex,n=0,h=0,t=0;if(i.length!==0||u.FrontReached||u.EndReached||(u.moveToPrevious(),i=u.CurrentVisibleVoiceEntries(),u.moveToNext()),u.FrontReached&&i.length===0){u.moveToNext(),i=u.CurrentVisibleVoiceEntries();const y=this.findVisibleGraphicalMeasure(u.CurrentMeasureIndex);n=y.PositionAndShape.AbsolutePosition.x,r=y.ParentMusicSystem,u.moveToPrevious()}else if(u.EndReached||!u.CurrentVoiceEntries||i.length===0){u.moveToPrevious(),i=u.CurrentVisibleVoiceEntries(),o=u.CurrentMeasureIndex;const y=this.findVisibleGraphicalMeasure(u.CurrentMeasureIndex);n=y.PositionAndShape.AbsolutePosition.x+y.PositionAndShape.Size.width,r=y.ParentMusicSystem,u.moveToNext()}else if(u.CurrentMeasure.isReducedToMultiRest){const y=this.findVisibleGraphicalMeasure(u.CurrentMeasureIndex),d=y.parentSourceMeasure.multipleRestMeasures,S=u.CurrentMeasure.multipleRestMeasureNumber/(d+1),M=y.PositionAndShape.Size.width-y.beginInstructionsWidth;n=y.PositionAndShape.AbsolutePosition.x+y.beginInstructionsWidth+S*M,r=y.ParentMusicSystem}else{const y=i.map(d=>this.getStaffEntryFromVoiceEntry(d)).sort((d,S)=>{var M,E,L,I;return((E=(M=d==null?void 0:d.PositionAndShape)==null?void 0:M.AbsolutePosition)==null?void 0:E.x)<=((I=(L=S==null?void 0:S.PositionAndShape)==null?void 0:L.AbsolutePosition)==null?void 0:I.x)?-1:1})[0];y&&(n=y.PositionAndShape.AbsolutePosition.x,r=y.parentMeasure.ParentMusicSystem)}if(!(r!=null&&r.StaffLines[0]))return;h=r.PositionAndShape.AbsolutePosition.y+r.StaffLines[0].PositionAndShape.RelativePosition.y;let f=r.PositionAndShape.AbsolutePosition.y;const p=r.StaffLines[r.StaffLines.length-1];p&&(f+=p.PositionAndShape.RelativePosition.y+p.StaffHeight),t=f-h;const m=this.findVisibleGraphicalMeasure(o);if(!m)return;const x=m.PositionAndShape;if(this.updateWidthAndStyle(x,n,h,t),this.openSheetMusicDisplay.FollowCursor&&this.cursorOptions.follow)if(this.openSheetMusicDisplay.EngravingRules.RenderSingleHorizontalStaffline)this.cursorElement.scrollIntoView({behavior:"smooth",inline:"center"});else{const y=this.cursorElement.getBoundingClientRect().top;this.cursorElement.scrollIntoView({behavior:y<1e3?"smooth":"auto",block:"center"})}this.cursorElement.style.display=""}findVisibleGraphicalMeasure(u){for(let r=0;r{i.push(...o.Notes)}),i}GNotesUnderCursor(u){const r=this.VoicesUnderCursor(u),i=[];return r.forEach(o=>{i.push(...o.Notes.map(n=>this.rules.GNote(n)))}),i}updateCurrentPage(){let u=this.iterator.currentTimeStamp;u.RealValue<0&&(u=new l.Fraction(0,0));for(const r of this.graphic.MusicPages)if(r.MusicSystems.last().GetSystemsLastTimeStamp().gt(u)){const i=r.PageNumber;return i!==this.currentPageNumber&&(this.container.removeChild(this.cursorElement),this.container=document.getElementById("osmdCanvasPage"+i),this.container.appendChild(this.cursorElement)),this.currentPageNumber=i}return 1}get SkipInvisibleNotes(){return this.skipInvisibleNotes}set SkipInvisibleNotes(u){this.skipInvisibleNotes=u,this.iterator.SkipInvisibleNotes=u}get CursorOptions(){return this.cursorOptions}set CursorOptions(u){this.cursorOptions=u}Dispose(){this.hide(),this.container.removeChild(this.cursorElement),this.rules=void 0,this.openSheetMusicDisplay=void 0,this.cursorOptions=void 0}nextMeasure(){const u=this.Iterator.CurrentMeasure;let r=this.Iterator.currentTimeStamp.RealValue;this.next();let i=0;for(;this.Iterator.CurrentMeasure===u&&this.Iterator.currentTimeStamp.RealValue!==r&&i<999;)r=this.Iterator.currentTimeStamp.RealValue,this.next(),i++}previousMeasure(){const u=this.Iterator.CurrentMeasure;let r=this.Iterator.currentTimeStamp.RealValue;this.previous();let i=0;for(;this.Iterator.CurrentMeasure===u&&this.Iterator.currentTimeStamp.RealValue!==r&&i<999;)r=this.Iterator.currentTimeStamp.RealValue,this.previous(),i++;for(i=0;this.Iterator.CurrentRelativeInMeasureTimestamp.RealValue!==0&&i<999;)this.previous(),i++}}},624(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.OSMDOptions=g.SkyBottomLineBatchCalculatorBackendType=g.BackendType=g.FillEmptyMeasuresWithWholeRests=g.AlignRestOption=g.CursorType=void 0;const l=c(4146);var s,u,r,i,o;(function(n){n[n.Standard=0]="Standard",n[n.ThinLeft=1]="ThinLeft",n[n.ShortThinTopLeft=2]="ShortThinTopLeft",n[n.CurrentArea=3]="CurrentArea",n[n.CurrentAreaLeft=4]="CurrentAreaLeft"})(s||(g.CursorType=s={})),function(n){n[n.Never=0]="Never",n[n.Always=1]="Always",n[n.Auto=2]="Auto"}(u||(g.AlignRestOption=u={})),function(n){n[n.No=0]="No",n[n.YesVisible=1]="YesVisible",n[n.YesInvisible=2]="YesInvisible"}(r||(g.FillEmptyMeasuresWithWholeRests=r={})),function(n){n[n.SVG=0]="SVG",n[n.Canvas=1]="Canvas"}(i||(g.BackendType=i={})),function(n){n[n.Plain=0]="Plain",n[n.WebGL=1]="WebGL"}(o||(g.SkyBottomLineBatchCalculatorBackendType=o={})),g.OSMDOptions=class{static OSMDOptionsStandard(){return{autoResize:!0,backend:"svg",drawingParameters:l.DrawingParametersEnum.default}}static BackendTypeFromString(n){return n&&n.toLowerCase()==="canvas"?i.Canvas:i.SVG}}},7103(de,g,c){var l=this&&this.__importDefault||function(D){return D&&D.__esModule?D:{default:D}};Object.defineProperty(g,"__esModule",{value:!0}),g.OpenSheetMusicDisplay=void 0;const s=c(3902),u=c(806),r=c(9099),i=c(8724),o=c(7921),n=c(9479),h=c(9436),t=c(9834),f=c(6597),p=c(6888),m=c(3173),x=l(c(3065)),y=c(3661),d=c(4146),S=c(4434),M=c(624),E=c(9713),L=c(6362),I=c(3263),T=c(2683),A=c(8233),v=c(1538);class B{constructor(_,F=M.OSMDOptions.OSMDOptionsStandard()){if(this.version="1.9.9-release",this.cursorsOptions=[],this.cursors=[],this.zoom=1,this.zoomUpdated=!1,this.loadUrlTimeout=5e3,typeof _=="string"?this.container=document.getElementById(_):_&&"appendChild"in _&&(this.container=_),!this.container)throw new Error("Please pass a valid div container to OpenSheetMusicDisplay");F.autoResize===void 0&&(F.autoResize=!0),this.backendType=M.BackendType.SVG,this.setOptions(F)}get cursor(){return this.cursors[0]}get Cursor(){return this.cursor}load(_,F="Untitled Score"){this.reset();const k=this;if(_ instanceof Blob){const oe=new p.MXLFile(_);return oe.tryUnzip().then(()=>oe.unzipSuccessful?oe.getXmlString().then($=>k.load($)):_ instanceof Blob?_.text().then($=>k.load($)):void 0)}if(typeof _=="string"){const oe=_;if(oe.startsWith("PK"))return x.default.debug("[OSMD] This is a zip file, unpack it first: "+oe),p.MXLHelper.MXLtoXMLstring(oe).then(Q=>k.load(Q),Q=>{throw x.default.debug(Q),new Error("OpenSheetMusicDisplay: Invalid MXL file")});if(oe.startsWith(""))return x.default.debug("[OSMD] UTF with BOM detected, truncate first 3 bytes and pass along: "+oe),k.load(oe.substring(3));let $=oe;if(/^\s/.test($)&&($=$.trim()),$.startsWith("k.load(Q),Q=>{throw Q});console.error("[OSMD] osmd.load(string): Could not process string. Did not find {F.init(this.sheet.MusicPartManager,this.graphic)}),this.drawingParameters.DrawingParametersEnum===d.DrawingParametersEnum.leadsheet&&(this.graphic.LeadSheet=!0)}render(){var F;if(!this.graphic)throw new Error("OSMD: load() needs to be called before render()");(F=this.drawer)==null||F.clear(),this.Sheet.SourceMeasures[0].ImplicitMeasure&&(this.rules.MinMeasureToDrawNumber>1&&(this.rules.MinMeasureToDrawIndex=this.rules.MinMeasureToDrawNumber),this.rules.MaxMeasureToDrawNumber>0&&(this.rules.MaxMeasureToDrawIndex=this.rules.MaxMeasureToDrawNumber));let _=this.container.offsetWidth;this.rules.RenderSingleHorizontalStaffline&&(_=this.rules.SheetMaximumWidth),this.sheet.pageWidth=_/this.zoom/10,this.rules.PageFormat&&!this.rules.PageFormat.IsUndefined?(this.rules.PageHeight=this.sheet.pageWidth/this.rules.PageFormat.aspectRatio,x.default.debug("[OSMD] PageHeight: "+this.rules.PageHeight)):(x.default.debug("[OSMD] endless/undefined pageformat, id: "+this.rules.PageFormat.idString),this.rules.PageHeight=100001),this.graphic.reCalculate(),this.drawingParameters.drawCursors&&(this.graphic.Cursors.length=0),this.createOrRefreshRenderBackend(),this.needBackendUpdate=!1,this.drawer.setZoom(this.zoom),this.drawer.drawSheet(this.graphic),this.enableOrDisableCursors(this.drawingParameters.drawCursors),this.drawingParameters.drawCursors&&this.cursors.forEach(k=>{k.update()}),this.zoomUpdated=!1,this.rules.RenderCount++}createOrRefreshRenderBackend(){if(this.drawer&&this.drawer.Backends){this.drawer.Backends[0]&&this.drawer.Backends[0].removeAllChildrenFromContainer(this.container);for(const j of this.drawer.Backends)j.free();this.drawer.Backends.clear()}this.drawingParameters.Rules=this.rules,this.drawer=new n.VexFlowMusicSheetDrawer(this.drawingParameters),this.drawer.drawableBoundingBoxElement=this.DrawBoundingBox,this.drawer.bottomLineVisible=this.drawBottomLine,this.drawer.skyLineVisible=this.drawSkyLine;let _,F=this.container.offsetWidth;this.rules.RenderSingleHorizontalStaffline&&(F=10*(this.EngravingRules.PageLeftMargin+this.graphic.MusicPages[0].PositionAndShape.Size.width+this.EngravingRules.PageRightMargin)*this.zoom);const k=32767;for(const j of this.graphic.MusicPages){if(j.PageNumber>this.rules.MaxPageToDrawNumber)break;const P=this.createBackend(this.backendType,j),G=" exceeds CanvasBackend limit of 32767. Cutting off score.";P.getOSMDBackendType()===M.BackendType.Canvas&&F>k&&(x.default.warn("[OSMD] Warning: width of "+F+G),F=k),this.rules.PageFormat&&!this.rules.PageFormat.IsUndefined?_=F/this.rules.PageFormat.aspectRatio:(_=j.PositionAndShape.Size.height,_+=this.rules.PageBottomMargin,P.getOSMDBackendType()===M.BackendType.Canvas&&(_+=.1),_+=j.PositionAndShape.BorderTop,this.rules.RenderTitle&&(_+=this.rules.TitleTopDistance),_*=10*this.zoom),P.getOSMDBackendType()===M.BackendType.Canvas&&_>k&&(x.default.warn("[OSMD] Warning: height of "+_+G),_=Math.min(_,k)),P.resize(F,_),P.clear(),P.getContext().setFillStyle(this.rules.DefaultColorMusic),P.getContext().setStrokeStyle(this.rules.DefaultColorMusic),this.drawer.Backends.push(P),this.graphic.drawer=this.drawer}}exportSVG(){if(this.drawer)for(const _ of this.drawer.Backends)_ instanceof h.SvgVexFlowBackend&&_.export()}IsReadyToRender(){return this.graphic!==void 0}clear(){var _;(_=this.drawer)==null||_.clear(),this.reset()}setOptions(_){if(this.rules||(this.rules=new E.EngravingRules),this.drawingParameters||_.drawingParameters?_.drawingParameters&&(this.drawingParameters?this.drawingParameters.DrawingParametersEnum=d.DrawingParametersEnum[_.drawingParameters.toLowerCase()]:this.drawingParameters=new y.DrawingParameters(d.DrawingParametersEnum[_.drawingParameters],this.rules)):this.drawingParameters=new y.DrawingParameters(d.DrawingParametersEnum.default,this.rules),_==null)return void x.default.warn(`warning: osmd.setOptions() called without an options parameter, has no effect. example usage: osmd.setOptions({drawCredits: false, drawPartNames: false})`);this.OnXMLRead=function(j){return j},_.onXMLRead&&(this.OnXMLRead=_.onXMLRead);let F=!this.drawer||!this.drawer.Backends||this.drawer.Backends.length<1;if(_.backend!==void 0){const j=M.OSMDOptions.BackendTypeFromString(_.backend);F=F||this.backendType!==j,this.backendType=j}this.needBackendUpdate=F,_.autoBeam!==void 0&&(this.rules.AutoBeamNotes=_.autoBeam);const k=_.autoBeamOptions;if(k&&(k.maintain_stem_directions===void 0&&(k.maintain_stem_directions=!1),this.rules.AutoBeamOptions=k,k.groups&&k.groups.length)){for(const j of k.groups)if(j.length!==2)throw new Error("Each fraction in autoBeamOptions.groups must be of length 2, e.g. [3,4] for beaming three fourths")}_.percussionOneLineCutoff!==void 0&&(this.rules.PercussionOneLineCutoff=_.percussionOneLineCutoff),this.rules.PercussionOneLineCutoff!==0&&_.percussionForceVoicesOneLineCutoff!==void 0&&(this.rules.PercussionForceVoicesOneLineCutoff=_.percussionForceVoicesOneLineCutoff),_.alignRests!==void 0&&(this.rules.AlignRests=_.alignRests),_.coloringMode!==void 0&&this.setColoringMode(_),_.coloringEnabled!==void 0&&(this.rules.ColoringEnabled=_.coloringEnabled),_.colorStemsLikeNoteheads!==void 0&&(this.rules.ColorStemsLikeNoteheads=_.colorStemsLikeNoteheads),_.disableCursor&&(this.drawingParameters.drawCursors=!1),_.drawHiddenNotes&&(this.drawingParameters.drawHiddenNotes=!0),_.drawCredits!==void 0&&(this.drawingParameters.DrawCredits=_.drawCredits),_.drawComposer!==void 0&&(this.drawingParameters.DrawComposer=_.drawComposer),_.drawTitle!==void 0&&(this.drawingParameters.DrawTitle=_.drawTitle),_.drawSubtitle!==void 0&&(this.drawingParameters.DrawSubtitle=_.drawSubtitle),_.drawLyricist!==void 0&&(this.drawingParameters.DrawLyricist=_.drawLyricist),_.drawMetronomeMarks!==void 0&&(this.rules.MetronomeMarksDrawn=_.drawMetronomeMarks),_.drawPartNames!==void 0&&(this.drawingParameters.DrawPartNames=_.drawPartNames,_.drawPartAbbreviations||(this.rules.RenderPartAbbreviations=_.drawPartNames)),_.drawPartAbbreviations!==void 0&&(this.rules.RenderPartAbbreviations=_.drawPartAbbreviations),_.drawFingerings===!1&&(this.rules.RenderFingerings=!1),_.drawMeasureNumbers!==void 0&&(this.rules.RenderMeasureNumbers=_.drawMeasureNumbers),_.drawMeasureNumbersOnlyAtSystemStart&&(this.rules.RenderMeasureNumbersOnlyAtSystemStart=_.drawMeasureNumbersOnlyAtSystemStart),_.drawLyrics!==void 0&&(this.rules.RenderLyrics=_.drawLyrics),_.drawTimeSignatures!==void 0&&(this.rules.RenderTimeSignatures=_.drawTimeSignatures),_.drawSlurs!==void 0&&(this.rules.RenderSlurs=_.drawSlurs),_.measureNumberInterval!==void 0&&(this.rules.MeasureNumberLabelOffset=_.measureNumberInterval),_.useXMLMeasureNumbers!==void 0&&(this.rules.UseXMLMeasureNumbers=_.useXMLMeasureNumbers),_.fingeringPosition!==void 0&&(this.rules.FingeringPosition=L.AbstractExpression.PlacementEnumFromString(_.fingeringPosition)),_.fingeringInsideStafflines!==void 0&&(this.rules.FingeringInsideStafflines=_.fingeringInsideStafflines),_.newSystemFromXML!==void 0&&(this.rules.NewSystemAtXMLNewSystemAttribute=_.newSystemFromXML),_.newSystemFromNewPageInXML!==void 0&&(this.rules.NewSystemAtXMLNewPageAttribute=_.newSystemFromNewPageInXML),_.newPageFromXML!==void 0&&(this.rules.NewPageAtXMLNewPageAttribute=_.newPageFromXML),_.fillEmptyMeasuresWithWholeRest!==void 0&&(this.rules.FillEmptyMeasuresWithWholeRest=_.fillEmptyMeasuresWithWholeRest),_.followCursor!==void 0&&(this.FollowCursor=_.followCursor),_.setWantedStemDirectionByXml!==void 0&&(this.rules.SetWantedStemDirectionByXml=_.setWantedStemDirectionByXml),_.darkMode?(this.rules.applyDefaultColorMusic("#FFFFFF"),this.rules.PageBackgroundColor="#000000",this.rules.DarkModeEnabled=!0):_.darkMode===!1&&(this.rules.applyDefaultColorMusic("#000000"),this.rules.PageBackgroundColor=void 0,this.rules.DarkModeEnabled=!1),_.defaultColorMusic&&this.rules.applyDefaultColorMusic(_.defaultColorMusic),_.defaultColorNotehead&&(this.rules.DefaultColorNotehead=_.defaultColorNotehead),_.defaultColorRest&&(this.rules.DefaultColorRest=_.defaultColorRest),_.defaultColorStem&&(this.rules.DefaultColorStem=_.defaultColorStem),_.defaultColorLabel&&(this.rules.DefaultColorLabel=_.defaultColorLabel),_.defaultColorTitle&&(this.rules.DefaultColorTitle=_.defaultColorTitle),_.defaultFontFamily&&(this.rules.DefaultFontFamily=_.defaultFontFamily),_.defaultFontStyle&&(this.rules.DefaultFontStyle=_.defaultFontStyle),_.drawUpToMeasureNumber>=0&&(this.rules.MaxMeasureToDrawIndex=Math.max(_.drawUpToMeasureNumber-1,0),this.rules.MaxMeasureToDrawNumber=_.drawUpToMeasureNumber),_.drawFromMeasureNumber>=0&&(this.rules.MinMeasureToDrawIndex=Math.max(_.drawFromMeasureNumber-1,0),this.rules.MinMeasureToDrawNumber=_.drawFromMeasureNumber),_.drawUpToPageNumber&&(this.rules.MaxPageToDrawNumber=_.drawUpToPageNumber),_.drawUpToSystemNumber&&(this.rules.MaxSystemToDrawNumber=_.drawUpToSystemNumber),_.tupletsRatioed&&(this.rules.TupletsRatioed=!0),_.tupletsBracketed&&(this.rules.TupletsBracketed=!0),_.tripletsBracketed&&(this.rules.TripletsBracketed=!0),_.autoResize?(this.resizeHandlerAttached||this.autoResize(),this.autoResizeEnabled=!0):_.autoResize===!1&&(this.autoResizeEnabled=!1),_.pageFormat!==void 0&&this.setPageFormat(_.pageFormat),_.pageBackgroundColor!==void 0&&(this.rules.PageBackgroundColor=_.pageBackgroundColor),_.renderSingleHorizontalStaffline!==void 0&&(this.rules.RenderSingleHorizontalStaffline=_.renderSingleHorizontalStaffline),_.spacingFactorSoftmax!==void 0&&(this.rules.SoftmaxFactorVexFlow=_.spacingFactorSoftmax),_.spacingBetweenTextLines!==void 0&&(this.rules.SpacingBetweenTextLines=_.spacingBetweenTextLines),_.stretchLastSystemLine!==void 0&&(this.rules.StretchLastSystemLine=_.stretchLastSystemLine),_.autoGenerateMultipleRestMeasuresFromRestMeasures!==void 0&&(this.rules.AutoGenerateMultipleRestMeasuresFromRestMeasures=_.autoGenerateMultipleRestMeasuresFromRestMeasures),_.cursorsOptions!==void 0?this.cursorsOptions=_.cursorsOptions:this.cursorsOptions=[{type:M.CursorType.Standard,color:this.EngravingRules.DefaultColorCursor,alpha:.5,follow:!0}],_.preferredSkyBottomLineBatchCalculatorBackend!==void 0&&(this.rules.PreferredSkyBottomLineBatchCalculatorBackend=_.preferredSkyBottomLineBatchCalculatorBackend),_.skyBottomLineBatchMinMeasures!==void 0&&(this.rules.SkyBottomLineBatchMinMeasures=_.skyBottomLineBatchMinMeasures)}setColoringMode(_){if(_.coloringMode===S.ColoringModes.XML)return void(this.rules.ColoringMode=S.ColoringModes.XML);const F=[A.NoteEnum.C,A.NoteEnum.D,A.NoteEnum.E,A.NoteEnum.F,A.NoteEnum.G,A.NoteEnum.A,A.NoteEnum.B];let k;if(_.coloringMode===S.ColoringModes.CustomColorSet){if(!_.coloringSetCustom||_.coloringSetCustom.length!==8)throw new Error("Invalid amount of colors: With coloringModes.customColorSet, you have to provide a coloringSetCustom parameter (array) with 8 strings (C to B, rest note).");for(const P of _.coloringSetCustom)if(!/^#[0-9a-fA-F]{6}$/.test(P))throw new Error(`One of the color strings in options.coloringSetCustom was not a valid HTML Hex color: `+P);k=_.coloringSetCustom}else if(_.coloringMode===S.ColoringModes.AutoColoring){k=[];const P=Object.keys(T.AutoColorSet);for(let G=0;G{_.hide()}),this.sheet=void 0,this.graphic=void 0,this.zoom=1,this.rules.RenderCount=0}autoResize(){const _=this;this.handleResize(()=>{},()=>{var F;((F=this.graphic)==null?void 0:F.GetCalculator)instanceof u.VexFlowMusicSheetCalculator&&(this.graphic.GetCalculator.beamsNeedUpdate=!0),_.IsReadyToRender()&&_.renderAndScrollBack()})}renderAndScrollBack(){const _=window.scrollY/document.body.scrollHeight;this.render();const F=document.body.scrollHeight*_;window.scrollTo({top:F,behavior:"instant"})}handleResize(_,F){let k,j;const P=this;function G(){P.AutoResizeEnabled&&(k=new Date().getTime(),j||(_(),k=new Date().getTime(),j=window.setTimeout(Y,200)))}function Y(){j=void 0,window.clearTimeout(j),new Date().getTime()-k<200?j=window.setTimeout(Y,200):F()}window.attachEvent?window.attachEvent("onresize",G):window.addEventListener("resize",G),this.resizeHandlerAttached=!0,window.setTimeout(_,0),window.setTimeout(F,1)}enableOrDisableCursors(_){var F,k,j,P;if(this.drawingParameters.drawCursors=_,_)for(let G=0;G{G.hide()})}createBackend(_,F){let k;return k=_===void 0||_===M.BackendType.SVG?new h.SvgVexFlowBackend(this.rules):new t.CanvasVexFlowBackend(this.rules),k.graphicalMusicPage=F,k.initialize(this.container,this.zoom),k}static StringToPageFormat(_){let F=E.PageFormat.UndefinedPageFormat;if(_.match("^[0-9]+x[0-9]+$")){const k=_.split("x"),j=Number.parseInt(k[0],10),P=Number.parseInt(k[1],10);j>0&&j<32768&&P>0&&P<32768&&(F=new E.PageFormat(j,P,`customPageFormat${_}`))}return _=(_=(_=_.replace(" ","_")).replace("Landscape","L")).replace("Portrait","P"),B.PageFormatStandards.hasOwnProperty(_)&&(F=B.PageFormatStandards[_]),F}setPageFormat(_){const F=B.StringToPageFormat(_);this.needBackendUpdate=!F.Equals(this.rules.PageFormat),this.rules.PageFormat=F}setCustomPageFormat(_,F){if(_>0&&F>0){const k=new E.PageFormat(_,F);this.rules.PageFormat=k}}set DrawSkyLine(_){this.drawSkyLine=_,this.drawer&&(this.drawer.skyLineVisible=_)}get DrawSkyLine(){return this.drawer.skyLineVisible}set DrawBottomLine(_){this.drawBottomLine=_,this.drawer&&(this.drawer.bottomLineVisible=_)}get DrawBottomLine(){return this.drawer.bottomLineVisible}set DrawBoundingBox(_){this.setDrawBoundingBox(_,!0)}get DrawBoundingBox(){return this.drawBoundingBox}setDrawBoundingBox(_,F=!1){this.drawBoundingBox=_,this.drawer&&(this.drawer.drawableBoundingBoxElement=_),F&&this.renderAndScrollBack()}get AutoResizeEnabled(){return this.autoResizeEnabled}set AutoResizeEnabled(_){this.autoResizeEnabled=_}get Zoom(){return this.zoom}set Zoom(_){var F;this.zoom=_,this.zoomUpdated=!0,((F=this.graphic)==null?void 0:F.GetCalculator)instanceof u.VexFlowMusicSheetCalculator&&(this.graphic.GetCalculator.beamsNeedUpdate=this.zoomUpdated)}set FollowCursor(_){this.followCursor=_}get FollowCursor(){return this.followCursor}set TransposeCalculator(_){o.MusicSheetCalculator.transposeCalculator=_}get TransposeCalculator(){return o.MusicSheetCalculator.transposeCalculator}get Sheet(){return this.sheet}get Drawer(){return this.drawer}get GraphicSheet(){return this.graphic}get DrawingParameters(){return this.drawingParameters}get EngravingRules(){return this.rules}get Version(){return this.version}}g.OpenSheetMusicDisplay=B,B.PageFormatStandards={A3_L:new E.PageFormat(420,297,"A3_L"),A3_P:new E.PageFormat(297,420,"A3_P"),A4_L:new E.PageFormat(297,210,"A4_L"),A4_P:new E.PageFormat(210,297,"A4_P"),A5_L:new E.PageFormat(210,148,"A5_L"),A5_P:new E.PageFormat(148,210,"A5_P"),A6_L:new E.PageFormat(148,105,"A6_L"),A6_P:new E.PageFormat(105,148,"A6_P"),Endless:E.PageFormat.UndefinedPageFormat,Letter_L:new E.PageFormat(279.4,215.9,"Letter_L"),Letter_P:new E.PageFormat(215.9,279.4,"Letter_P")}},5955(de,g,c){var l=this&&this.__createBinding||(Object.create?function(u,r,i,o){o===void 0&&(o=i);var n=Object.getOwnPropertyDescriptor(r,i);n&&!("get"in n?!r.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return r[i]}}),Object.defineProperty(u,o,n)}:function(u,r,i,o){o===void 0&&(o=i),u[o]=r[i]}),s=this&&this.__exportStar||function(u,r){for(var i in u)i==="default"||Object.prototype.hasOwnProperty.call(r,i)||l(r,u,i)};Object.defineProperty(g,"__esModule",{value:!0}),s(c(3173),g),s(c(6597),g),s(c(624),g),s(c(7103),g)},8628(de,g,c){Object.defineProperty(g,"__esModule",{value:!0}),g.TransposeCalculator=void 0;const l=c(9735);class s{transposePitch(r,i,o){if(o===0)return r;let n=l.NoteEnum.C,h=0,t=l.AccidentalEnum.NONE;const f=l.Pitch.CalculateTransposedHalfTone(r,o);let p=f.halftone,m=f.overflow;for(let x=0;xp)break}for(let x=0;xp){let y=x;const d=l.Pitch.HalfTonesFromAccidental(r.Accidental),S=d>0,M=d<0,E=i.Key>0,L=i.Key<0;let I=!0;for(E?I=!0:L?I=!1:(S||M)&&(I=S),I&&y--;y<0;)y+=7,p+=12,m--;for(;y>=7;)y-=7,p-=12,m++;n=s.noteEnums[y],t=l.Pitch.AccidentalFromHalfTones(p-n),h=r.Octave+m;break}return new l.Pitch(n,h,t)}transposeKey(r,i){let o=0,n=0,h=r.keyTypeOriginal;if(i%12==0)return r.Key=r.keyTypeOriginal,void(r.isTransposedBy=i);for(h>6?h-=12:h<-6&&(h+=12);o=12;)t-=12;for(;t<0;)t+=12;r.Key=s.keyMapping[t],r.isTransposedBy=i}}g.TransposeCalculator=s,s.keyMapping=[0,-5,2,-3,4,-1,6,1,-4,3,-2,5],s.noteEnums=[l.NoteEnum.C,l.NoteEnum.D,l.NoteEnum.E,l.NoteEnum.F,l.NoteEnum.G,l.NoteEnum.A,l.NoteEnum.B]},8659(de,g,c){var l=this&&this.__createBinding||(Object.create?function(u,r,i,o){o===void 0&&(o=i);var n=Object.getOwnPropertyDescriptor(r,i);n&&!("get"in n?!r.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return r[i]}}),Object.defineProperty(u,o,n)}:function(u,r,i,o){o===void 0&&(o=i),u[o]=r[i]}),s=this&&this.__exportStar||function(u,r){for(var i in u)i==="default"||Object.prototype.hasOwnProperty.call(r,i)||l(r,u,i)};Object.defineProperty(g,"__esModule",{value:!0}),s(c(8628),g)},363(de,g,c){var l=this&&this.__createBinding||(Object.create?function(u,r,i,o){o===void 0&&(o=i);var n=Object.getOwnPropertyDescriptor(r,i);n&&!("get"in n?!r.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return r[i]}}),Object.defineProperty(u,o,n)}:function(u,r,i,o){o===void 0&&(o=i),u[o]=r[i]}),s=this&&this.__exportStar||function(u,r){for(var i in u)i==="default"||Object.prototype.hasOwnProperty.call(r,i)||l(r,u,i)};Object.defineProperty(g,"__esModule",{value:!0}),s(c(8659),g)},813(de,g){Object.defineProperty(g,"__esModule",{value:!0}),g.CollectionUtil=void 0,Array.prototype.last||Object.defineProperty(Array.prototype,"last",{enumerable:!1,writable:!0,value:function(){return this[this.length-1]}}),Array.prototype.clear||Object.defineProperty(Array.prototype,"clear",{enumerable:!1,writable:!0,value:function(){this.length=0}}),Array.prototype.contains||Object.defineProperty(Array.prototype,"contains",{enumerable:!1,writable:!0,value:function(c){return this.indexOf(c)!==-1}}),g.CollectionUtil=class{static contains2(c,l){for(let s=0;s0&&(i=i.rightCh);return i},r.prototype.transplant=function(i,o){i.parent===null?this.root=o:i===i.parent.leftCh?i.parent.leftCh=o:i.parent.rightCh=o,o!==null&&(o.parent=i.parent)},r.prototype.removeNode=function(i){if(i.leftCh===null)this.transplant(i,i.rightCh);else if(i.rightCh===null)this.transplant(i,i.leftCh);else{var o=this.minimumAux(i.rightCh);o.parent!==i&&(this.transplant(o,o.rightCh),o.rightCh=i.rightCh,o.rightCh.parent=o),this.transplant(i,o),o.leftCh=i.leftCh,o.leftCh.parent=o}},r.prototype.inorderTraversalAux=function(i,o,n){i===null||n.stop||(this.inorderTraversalAux(i.leftCh,o,n),n.stop||(n.stop=o(i.element)===!1,n.stop||this.inorderTraversalAux(i.rightCh,o,n)))},r.prototype.levelTraversalAux=function(i,o){var n=new s.default;for(i!==null&&n.enqueue(i),i=n.dequeue()||null;i!=null;){if(o(i.element)===!1)return;i.leftCh!==null&&n.enqueue(i.leftCh),i.rightCh!==null&&n.enqueue(i.rightCh),i=n.dequeue()||null}},r.prototype.preorderTraversalAux=function(i,o,n){i===null||n.stop||(n.stop=o(i.element)===!1,n.stop||(this.preorderTraversalAux(i.leftCh,o,n),n.stop||this.preorderTraversalAux(i.rightCh,o,n)))},r.prototype.postorderTraversalAux=function(i,o,n){i===null||n.stop||(this.postorderTraversalAux(i.leftCh,o,n),n.stop||(this.postorderTraversalAux(i.rightCh,o,n),n.stop||(n.stop=o(i.element)===!1)))},r.prototype.minimumAux=function(i){for(;i!=null&&i.leftCh!==null;)i=i.leftCh;return i},r.prototype.maximumAux=function(i){for(;i!=null&&i.rightCh!==null;)i=i.rightCh;return i},r.prototype.heightAux=function(i){return i===null?-1:Math.max(this.heightAux(i.leftCh),this.heightAux(i.rightCh))+1},r.prototype.insertNode=function(i){for(var o=null,n=this.root;n!==null;){var h=this.compare(i.element,n.element);if(h===0)return null;h<0?(o=n,n=n.leftCh):(o=n,n=n.rightCh)}return i.parent=o,o===null?this.root=i:this.compare(i.element,o.element)<0?o.leftCh=i:o.rightCh=i,i},r.prototype.createNode=function(i){return{element:i,leftCh:null,rightCh:null,parent:null}},r}();g.default=u},2909(de,g,c){Object.defineProperty(g,"__esModule",{value:!0});var l=c(4831),s=c(6119),u=c(2091),r=function(){function i(o){this.toStrF=o||l.defaultToString,this.dictionary=new s.default(this.toStrF),this.nElements=0}return i.prototype.add=function(o,n){if(n===void 0&&(n=1),l.isUndefined(o)||n<=0)return!1;if(this.contains(o))this.dictionary.getValue(o).copies+=n;else{var h={value:o,copies:n};this.dictionary.setValue(o,h)}return this.nElements+=n,!0},i.prototype.count=function(o){return this.contains(o)?this.dictionary.getValue(o).copies:0},i.prototype.contains=function(o){return this.dictionary.containsKey(o)},i.prototype.remove=function(o,n){if(n===void 0&&(n=1),l.isUndefined(o)||n<=0)return!1;if(this.contains(o)){var h=this.dictionary.getValue(o);return n>h.copies?this.nElements-=h.copies:this.nElements-=n,h.copies-=n,h.copies<=0&&this.dictionary.remove(o),!0}return!1},i.prototype.toArray=function(){for(var o=[],n=0,h=this.dictionary.values();n=this.data.length?i>=this.data.length?-1:i:this.compare(this.data[i],this.data[o])<=0?i:o},r.prototype.siftUp=function(i){for(var o=this.parentIndex(i);i>0&&this.compare(this.data[o],this.data[i])>0;)s.swap(this.data,o,i),i=o,o=this.parentIndex(i)},r.prototype.siftDown=function(i){for(var o=this.minIndex(this.leftChildIndex(i),this.rightChildIndex(i));o>=0&&this.compare(this.data[i],this.data[o])>0;)s.swap(this.data,o,i),i=o,o=this.minIndex(this.leftChildIndex(i),this.rightChildIndex(i))},r.prototype.peek=function(){return this.data.length>0?this.data[0]:void 0},r.prototype.add=function(i){return!l.isUndefined(i)&&(this.data.push(i),this.siftUp(this.data.length-1),!0)},r.prototype.removeRoot=function(){if(this.data.length>0){var i=this.data[0];return this.data[0]=this.data[this.data.length-1],this.data.splice(this.data.length-1,1),this.data.length>0&&this.siftDown(0),i}},r.prototype.contains=function(i){var o=l.compareToEquals(this.compare);return s.contains(this.data,i,o)},r.prototype.size=function(){return this.data.length},r.prototype.isEmpty=function(){return this.data.length<=0},r.prototype.clear=function(){this.data.length=0},r.prototype.forEach=function(i){s.forEach(this.data,i)},r}();g.default=u},1846(de,g,c){var l,s=this&&this.__extends||(l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,f){t.__proto__=f}||function(t,f){for(var p in f)f.hasOwnProperty(p)&&(t[p]=f[p])},function(t,f){function p(){this.constructor=t}l(t,f),t.prototype=f===null?Object.create(f):(p.prototype=f.prototype,new p)});Object.defineProperty(g,"__esModule",{value:!0});var u=c(6119),r=c(4831),i=function(){function t(f,p){this.key=f,this.value=p}return t.prototype.unlink=function(){this.prev.next=this.next,this.next.prev=this.prev},t}(),o=function(){function t(){this.key=null,this.value=null}return t.prototype.unlink=function(){this.prev.next=this.next,this.next.prev=this.prev},t}();function n(t){return!t.next}var h=function(t){function f(p){var m=t.call(this,p)||this;return m.head=new o,m.tail=new o,m.head.next=m.tail,m.tail.prev=m.head,m}return s(f,t),f.prototype.appendToTail=function(p){var m=this.tail.prev;m.next=p,p.prev=m,p.next=this.tail,this.tail.prev=p},f.prototype.getLinkedDictionaryPair=function(p){if(!r.isUndefined(p)){var m="$"+this.toStr(p);return this.table[m]}},f.prototype.getValue=function(p){var m=this.getLinkedDictionaryPair(p);if(!r.isUndefined(m))return m.value},f.prototype.remove=function(p){var m=this.getLinkedDictionaryPair(p);if(!r.isUndefined(m))return t.prototype.remove.call(this,p),m.unlink(),m.value},f.prototype.clear=function(){t.prototype.clear.call(this),this.head.next=this.tail,this.tail.prev=this.head},f.prototype.replace=function(p,m){var x="$"+this.toStr(m.key);m.next=p.next,m.prev=p.prev,this.remove(p.key),m.prev.next=m,m.next.prev=m,this.table[x]=m,++this.nElements},f.prototype.setValue=function(p,m){if(!r.isUndefined(p)&&!r.isUndefined(m)){var x=this.getLinkedDictionaryPair(p),y=new i(p,m),d="$"+this.toStr(p);return r.isUndefined(x)?(this.appendToTail(y),this.table[d]=y,void++this.nElements):(this.replace(x,y),x.value)}},f.prototype.keys=function(){var p=[];return this.forEach(function(m,x){p.push(m)}),p},f.prototype.values=function(){var p=[];return this.forEach(function(m,x){p.push(x)}),p},f.prototype.forEach=function(p){for(var m=this.head.next;!n(m);){if(p(m.key,m.value)===!1)return;m=m.next}},f}(u.default);g.default=h},4538(de,g,c){Object.defineProperty(g,"__esModule",{value:!0});var l=c(4831),s=c(4713),u=function(){function r(){this.firstNode=null,this.lastNode=null,this.nElements=0}return r.prototype.add=function(i,o){if(l.isUndefined(o)&&(o=this.nElements),o<0||o>this.nElements||l.isUndefined(i))return!1;var n=this.createNode(i);if(this.nElements===0||this.lastNode===null)this.firstNode=n,this.lastNode=n;else if(o===this.nElements)this.lastNode.next=n,this.lastNode=n;else if(o===0)n.next=this.firstNode,this.firstNode=n;else{var h=this.nodeAtIndex(o-1);if(h===null)return!1;n.next=h.next,h.next=n}return this.nElements++,!0},r.prototype.first=function(){if(this.firstNode!==null)return this.firstNode.element},r.prototype.last=function(){if(this.lastNode!==null)return this.lastNode.element},r.prototype.elementAtIndex=function(i){var o=this.nodeAtIndex(i);if(o!==null)return o.element},r.prototype.indexOf=function(i,o){var n=o||l.defaultEquals;if(l.isUndefined(i))return-1;for(var h=this.firstNode,t=0;h!==null;){if(n(h.element,i))return t;t++,h=h.next}return-1},r.prototype.contains=function(i,o){return this.indexOf(i,o)>=0},r.prototype.remove=function(i,o){var n=o||l.defaultEquals;if(this.nElements<1||l.isUndefined(i))return!1;for(var h=null,t=this.firstNode;t!==null;){if(n(t.element,i))return h===null?(this.firstNode=t.next,t===this.lastNode&&(this.lastNode=null)):t===this.lastNode?(this.lastNode=h,h.next=t.next,t.next=null):(h.next=t.next,t.next=null),this.nElements--,!0;h=t,t=t.next}return!1},r.prototype.clear=function(){this.firstNode=null,this.lastNode=null,this.nElements=0},r.prototype.equals=function(i,o){var n=o||l.defaultEquals;return i instanceof r&&this.size()===i.size()&&this.equalsAux(this.firstNode,i.firstNode,n)},r.prototype.equalsAux=function(i,o,n){for(;i!==null&&o!==null;){if(!n(i.element,o.element))return!1;i=i.next,o=o.next}return!0},r.prototype.removeElementAtIndex=function(i){if(!(i<0||i>=this.nElements||this.firstNode===null||this.lastNode===null)){var o;if(this.nElements===1)o=this.firstNode.element,this.firstNode=null,this.lastNode=null;else{var n=this.nodeAtIndex(i-1);n===null?(o=this.firstNode.element,this.firstNode=this.firstNode.next):n.next===this.lastNode&&(o=this.lastNode.element,this.lastNode=n),n!==null&&n.next!==null&&(o=n.next.element,n.next=n.next.next)}return this.nElements--,o}},r.prototype.forEach=function(i){for(var o=this.firstNode;o!==null&&i(o.element)!==!1;)o=o.next},r.prototype.reverse=function(){for(var i=null,o=this.firstNode,n=null;o!==null;)n=o.next,o.next=i,i=o,o=n;n=this.firstNode,this.firstNode=this.lastNode,this.lastNode=n},r.prototype.toArray=function(){for(var i=[],o=this.firstNode;o!==null;)i.push(o.element),o=o.next;return i},r.prototype.size=function(){return this.nElements},r.prototype.isEmpty=function(){return this.nElements<=0},r.prototype.toString=function(){return s.toString(this.toArray())},r.prototype.nodeAtIndex=function(i){if(i<0||i>=this.nElements)return null;if(i===this.nElements-1)return this.lastNode;for(var o=this.firstNode,n=0;n-1&&this.insertIdIntoRoot(r,i),this.nodes)if(this.nodes.hasOwnProperty(o)){var n=this.findNodeId(o,u);n>-1&&this.insertIdIntoNode(o,r,n)}},s.prototype.insertIdAfterId=function(u,r){var i=this.findRootId(u);for(var o in i>-1&&this.insertIdIntoRoot(r,i+1),this.nodes)if(this.nodes.hasOwnProperty(o)){var n=this.findNodeId(o,u);n>-1&&this.insertIdIntoNode(o,r,n+1)}},s.prototype.insertIdIntoId=function(u,r){this.nodeInsertAtEnd(u,r),this.nodes[r]=[]},s.prototype.insertIdIntoRoot=function(u,r){if(r===void 0)this.rootInsertAtEnd(u);else if(r<0){var i=this.rootIds.length;this.rootIds.splice(r+i+1,0,u)}else this.rootIds.splice(r,0,u);this.nodes[u]=this.nodes[u]||[]},s.prototype.insertIdIntoNode=function(u,r,i){if(this.nodes[u]=this.nodes[u]||[],this.nodes[r]=this.nodes[r]||[],i===void 0)this.nodeInsertAtEnd(u,r);else if(i<0){var o=this.nodes[u].length;this.nodes[u].splice(i+o+1,0,r)}else this.nodes[u].splice(i,0,r)},s.prototype.moveId=function(u,r,i){var o=u,n=this.findRootId(o);for(var h in this.nodes[r],this.nodes)if(this.nodes.hasOwnProperty(h)){this.findNodeId(h,r);break}var t=r,f=this.findRootId(t);for(var h in this.nodes[r],this.nodes)if(this.nodes.hasOwnProperty(h)){this.findNodeId(h,r);break}if(n>-1){if(f>-1)switch(this.rootDelete(n),f>n&&f--,i){case c.BEFORE:this.insertIdIntoRoot(o,f);break;case c.AFTER:this.insertIdIntoRoot(o,f+1);break;case c.INSIDE_AT_START:this.nodeInsertAtStart(t,o);break;case c.INSIDE_AT_END:this.nodeInsertAtEnd(t,o)}else for(var h in this.rootDelete(n),this.nodes)if(this.nodes.hasOwnProperty(h)&&(p=this.findNodeId(h,t))>-1){switch(i){case c.BEFORE:this.insertIdIntoNode(h,o,p);break;case c.AFTER:this.insertIdIntoNode(h,o,p+1);break;case c.INSIDE_AT_START:this.nodeInsertAtStart(t,o);break;case c.INSIDE_AT_END:this.nodeInsertAtEnd(t,o)}break}}else if(f>-1){for(var h in this.nodes)if(this.nodes.hasOwnProperty(h)&&(p=this.findNodeId(h,o))>-1){this.nodeDeleteAtIndex(h,p);break}switch(i){case c.BEFORE:this.insertIdIntoRoot(o,f);break;case c.AFTER:this.insertIdIntoRoot(o,f+1);break;case c.INSIDE_AT_START:this.nodeInsertAtStart(t,o);break;case c.INSIDE_AT_END:this.nodeInsertAtEnd(t,o)}}else{for(var h in this.nodes)if(this.nodes.hasOwnProperty(h)&&(p=this.findNodeId(h,o))>-1){this.nodeDeleteAtIndex(h,p);break}for(var h in this.nodes){var p;if(this.nodes.hasOwnProperty(h)&&(p=this.findNodeId(h,t))>-1){switch(i){case c.BEFORE:this.insertIdIntoNode(h,o,p);break;case c.AFTER:this.insertIdIntoNode(h,o,p+1);break;case c.INSIDE_AT_START:this.nodeInsertAtStart(t,o);break;case c.INSIDE_AT_END:this.nodeInsertAtEnd(t,o)}break}}}},s.prototype.swapArrayElements=function(u,r,i){var o=u[r];return u[r]=u[i],u[i]=o,u},s.prototype.rootDeleteId=function(u){var r=this.findRootId(u);r>-1&&this.rootDelete(r)},s.prototype.nodeAndSubNodesDelete=function(u){for(var r=[],i=0;io.size())return!1;var n=!0;return this.forEach(function(h){return!!o.contains(h)||(n=!1,!1)}),n},i.prototype.remove=function(o){return!!this.contains(o)&&(this.dictionary.remove(o),!0)},i.prototype.forEach=function(o){this.dictionary.forEach(function(n,h){return o(h)})},i.prototype.toArray=function(){return this.dictionary.values()},i.prototype.isEmpty=function(){return this.dictionary.isEmpty()},i.prototype.size=function(){return this.dictionary.size()},i.prototype.clear=function(){this.dictionary.clear()},i.prototype.toString=function(){return s.toString(this.toArray())},i}();g.default=r},2083(de,g,c){Object.defineProperty(g,"__esModule",{value:!0});var l=c(4538),s=function(){function u(){this.list=new l.default}return u.prototype.push=function(r){return this.list.add(r,0)},u.prototype.add=function(r){return this.list.add(r,0)},u.prototype.pop=function(){return this.list.removeElementAtIndex(0)},u.prototype.peek=function(){return this.list.first()},u.prototype.size=function(){return this.list.size()},u.prototype.contains=function(r,i){return this.list.contains(r,i)},u.prototype.isEmpty=function(){return this.list.isEmpty()},u.prototype.clear=function(){this.list.clear()},u.prototype.forEach=function(r){this.list.forEach(r)},u}();g.default=s},4713(de,g,c){Object.defineProperty(g,"__esModule",{value:!0});var l=c(4831);function s(u,r,i){for(var o=i||l.defaultEquals,n=u.length,h=0;h=0;n--)if(o(u[n],r))return n;return-1},g.contains=function(u,r,i){return s(u,r,i)>=0},g.remove=function(u,r,i){var o=s(u,r,i);return!(o<0||(u.splice(o,1),0))},g.frequency=function(u,r,i){for(var o=i||l.defaultEquals,n=u.length,h=0,t=0;t=u.length||i<0||i>=u.length)return!1;var o=u[r];return u[r]=u[i],u[i]=o,!0},g.toString=function(u){return"["+u.toString()+"]"},g.forEach=function(u,r){for(var i=0,o=u;ioi});const l=()=>{};l.L=(ce,e)=>{if(!e)return;const a=Array.prototype.slice.call(e).join(" ");window.console.log(ce+": "+a)},l.MakeException=ce=>class extends Error{constructor(e,a){super(e),this.name=ce,this.message=e,this.data=a}},l.RERR=l.RuntimeError=class{constructor(ce,e){this.code=ce,this.message=e}toString(){return"[RuntimeError] "+this.code+":"+this.message}},l.Merge=(ce,e)=>{for(const a in e)ce[a]=e[a];return ce},l.Min=Math.min,l.Max=Math.max,l.forEach=(ce,e)=>{for(let a=0;ace%e>=e/2?parseInt(ce/e,10)*e+e:parseInt(ce/e,10)*e,l.MidLine=(ce,e)=>{let a=e+(ce-e)/2;return a%2>0&&(a=l.RoundN(10*a,5)/10),a},l.SortAndUnique=(ce,e,a)=>{if(ce.length>1){const b=[];let w;ce.sort(e);for(let C=0;C{let a=ce.length;for(;a--;)if(ce[a]===e)return!0;return!1},l.getCanvasContext=ce=>{if(!ce)throw new l.RERR("BadArgument","Invalid canvas selector: "+ce);const e=document.getElementById(ce);if(!e||!e.getContext)throw new l.RERR("UnsupportedBrowserError","This browser does not support HTML5 Canvas");return e.getContext("2d")},l.drawDot=(ce,e,a,b="#55")=>{ce.save(),ce.setFillStyle(b),ce.beginPath(),ce.arc(e,a,3,0,2*Math.PI,!0),ce.closePath(),ce.fill(),ce.restore()},l.BM=(ce,e)=>{const a=new Date().getTime();e();const b=new Date().getTime()-a;l.L(ce+b+"ms")},l.StackTrace=()=>new Error().stack,l.W=(...ce)=>{const e=ce.join(" ");window.console.log("Warning: ",e,l.StackTrace())},(l.Prefix=ce=>l.Prefix.prefix+ce).prefix="vf-";class s{static GCD(e,a){if(typeof e!="number"||typeof a!="number")throw new l.RERR("BadArgument",`Invalid numbers: ${e}, ${a}`);let b;for(;a!==0;)b=a,a=e%a,e=b;return e}static LCM(e,a){return e*a/s.GCD(e,a)}static LCMM(e){if(e.length===0)return 0;if(e.length===1)return e[0];if(e.length===2)return s.LCM(e[0],e[1]);{const a=e[0];return e.shift(),s.LCM(a,s.LCMM(e))}}constructor(e,a){this.set(e,a)}set(e,a){return this.numerator=e===void 0?1:e,this.denominator=a===void 0?1:a,this}value(){return this.numerator/this.denominator}simplify(){let e=this.numerator,a=this.denominator;const b=s.GCD(e,a);return e/=b,a/=b,a<0&&(a=-a,e=-e),this.set(e,a)}add(e,a){let b,w;e instanceof s?(b=e.numerator,w=e.denominator):(b=e!==void 0?e:0,w=a!==void 0?a:1);const C=s.LCM(this.denominator,w),V=C/this.denominator,z=C/w,J=this.numerator*V+b*z;return this.set(J,C)}subtract(e,a){let b,w;e instanceof s?(b=e.numerator,w=e.denominator):(b=e!==void 0?e:0,w=a!==void 0?a:1);const C=s.LCM(this.denominator,w),V=C/this.denominator,z=C/w,J=this.numerator*V-b*z;return this.set(J,C)}multiply(e,a){let b,w;return e instanceof s?(b=e.numerator,w=e.denominator):(b=e!==void 0?e:1,w=a!==void 0?a:1),this.set(this.numerator*b,this.denominator*w)}divide(e,a){let b,w;return e instanceof s?(b=e.numerator,w=e.denominator):(b=e!==void 0?e:1,w=a!==void 0?a:1),this.set(this.numerator*w,this.denominator*b)}equals(e){const a=s.__compareA.copy(e).simplify(),b=s.__compareB.copy(this).simplify();return a.numerator===b.numerator&&a.denominator===b.denominator}greaterThan(e){const a=s.__compareB.copy(this);return a.subtract(e),a.numerator>0}greaterThanEquals(e){const a=s.__compareB.copy(this);return a.subtract(e),a.numerator>=0}lessThan(e){return!this.greaterThanEquals(e)}lessThanEquals(e){return!this.greaterThan(e)}clone(){return new s(this.numerator,this.denominator)}copy(e){return typeof e=="number"?this.set(e||0,1):this.set(e.numerator,e.denominator)}quotient(){return Math.floor(this.numerator/this.denominator)}fraction(){return this.numerator%this.denominator}abs(){return this.denominator=Math.abs(this.denominator),this.numerator=Math.abs(this.numerator),this}toString(){return this.numerator+"/"+this.denominator}toSimplifiedString(){return s.__tmp.copy(this).simplify().toString()}toMixedString(){let e="";const a=this.quotient(),b=s.__tmp.copy(this);return a<0?b.abs().fraction():b.fraction(),a!==0?(e+=a,b.numerator!==0&&(e+=" "+b.toSimplifiedString())):e=b.numerator===0?"0":b.toSimplifiedString(),e}parse(e){const a=e.split("/"),b=parseInt(a[0],10),w=a[1]?parseInt(a[1],10):1;return this.set(b,w)}}s.__compareA=new s,s.__compareB=new s,s.__tmp=new s;const u=l.MakeException("RegistryError");function r(ce,e,a,b,w){ce[e][a]||(ce[e][a]={}),ce[e][a][b]=w}class i{static get INDEXES(){return["type"]}constructor(){this.clear()}static enableDefaultRegistry(e){i.defaultRegistry=e}static getDefaultRegistry(){return i.defaultRegistry}static disableDefaultRegistry(){i.defaultRegistry=null}clear(){return this.index={id:{},type:{},class:{}},this}updateIndex({id:e,name:a,value:b,oldValue:w}){const C=this.getElementById(e);w!==null&&this.index[a][w]&&delete this.index[a][w][e],b!==null&&r(this.index,a,b,C.getAttribute("id"),C)}register(e,a){if(!(a=a||e.getAttribute("id")))throw new u("Can't add element without `id` attribute to registry",e);return e.setAttribute("id",a),r(this.index,"id",a,a,e),i.INDEXES.forEach(b=>{this.updateIndex({id:a,name:b,value:e.getAttribute(b),oldValue:null})}),e.onRegister(this),this}getElementById(e){return this.index.id[e]?this.index.id[e][e]:null}getElementsByAttribute(e,a){const b=this.index[e];return b&&b[a]?Object.keys(b[a]).map(w=>b[a][w]):[]}getElementsByType(e){return this.getElementsByAttribute("type",e)}getElementsByClass(e){return this.getElementsByAttribute("class",e)}onUpdate({id:e,name:a,value:b,oldValue:w}){return function(C,V){return C.filter(z=>z===V).length>0}(i.INDEXES.concat(["id","class"]),a)?(this.updateIndex({id:e,name:a,value:b,oldValue:w}),this):this}}i.defaultRegistry=null;class o{static newID(){return"auto"+o.ID++}constructor({type:e}={}){this.attrs={id:o.newID(),el:null,type:e||"Base",classes:{}},this.boundingBox=null,this.context=null,this.rendered=!1,i.getDefaultRegistry()&&i.getDefaultRegistry().register(this)}setStyle(e){return this.style=e,this}getStyle(){return this.style}applyStyle(e=this.context,a=this.getStyle()){return a?(e.save(),a.shadowColor&&e.setShadowColor(a.shadowColor),a.shadowBlur&&e.setShadowBlur(a.shadowBlur),a.fillStyle&&e.setFillStyle(a.fillStyle),a.strokeStyle&&e.setStrokeStyle(a.strokeStyle),a.lineWidth&&e.setLineWidth(a.lineWidth),this):this}restoreStyle(e=this.context,a=this.getStyle()){return a?(e.restore(),this):this}drawWithStyle(){this.checkContext(),this.applyStyle(),this.draw(),this.restoreStyle()}hasClass(e){return this.attrs.classes[e]===!0}addClass(e){return this.attrs.classes[e]=!0,this.registry&&this.registry.onUpdate({id:this.getAttribute("id"),name:"class",value:e,oldValue:null}),this}removeClass(e){return delete this.attrs.classes[e],this.registry&&this.registry.onUpdate({id:this.getAttribute("id"),name:"class",value:null,oldValue:e}),this}onRegister(e){return this.registry=e,this}isRendered(){return this.rendered}setRendered(e=!0){return this.rendered=e,this}getAttributes(){return this.attrs}getAttribute(e){return this.attrs[e]}setAttribute(e,a){const b=this.attrs.id,w=this.attrs[e];return this.attrs[e]=a,this.registry&&this.registry.onUpdate({id:b,name:e,value:a,oldValue:w}),this}getContext(){return this.context}setContext(e){return this.context=e,this}getBoundingBox(){return this.boundingBox}checkContext(){if(!this.context)throw new l.RERR("NoContext","No rendering context attached to instance");return this.context}}o.ID=1e3;class n{constructor(e,a,b,w){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN,this.addPoint(e,a),this.addPoint(b,w)}width(){return this.x2-this.x1}height(){return this.y2-this.y1}addPoint(e,a){e!=null&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=e,this.x2=e),ethis.x2&&(this.x2=e)),a!=null&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=a,this.y2=a),athis.y2&&(this.y2=a))}addX(e){this.addPoint(e,null)}addY(e){this.addPoint(null,e)}addQuadraticCurve(e,a,b,w,C,V){const z=e+.6666666666666666*(b-e),J=a+2/3*(w-a),Z=z+1/3*(C-e),re=J+1/3*(V-a);this.addBezierCurve(e,a,z,J,Z,re,C,V)}addBezierCurve(e,a,b,w,C,V,z,J){const Z=[e,a],re=[b,w],ae=[C,V],le=[z,J];let he;this.addPoint(Z[0],Z[1]),this.addPoint(le[0],le[1]);const pe=(ge,me)=>Math.pow(1-ge,3)*Z[me]+3*Math.pow(1-ge,2)*ge*re[me]+3*(1-ge)*Math.pow(ge,2)*ae[me]+Math.pow(ge,3)*le[me];for(he=0;he<=1;he++){const ge=6*Z[he]-12*re[he]+6*ae[he],me=-3*Z[he]+9*re[he]-9*ae[he]+3*le[he],Ee=3*re[he]-3*Z[he];if(me===0){if(ge===0)continue;const De=-Ee/ge;0{if(!ce)throw new l.RERR("BadArgument","Invalid clef: "+ce);const e=m.clefProperties.values[ce];if(!e)throw new l.RERR("BadArgument","Invalid clef: "+ce);return e}};m.clefProperties.values={treble:{line_shift:0},bass:{line_shift:6},tenor:{line_shift:4},alto:{line_shift:3},soprano:{line_shift:1},percussion:{line_shift:0},"mezzo-soprano":{line_shift:2},"baritone-c":{line_shift:5},"baritone-f":{line_shift:5},subbass:{line_shift:7},french:{line_shift:-1}},m.keyProperties=(ce,e,a)=>{e===void 0&&(e="treble");const b={octave_shift:0};typeof a=="object"&&l.Merge(b,a);const w=ce.split("/");if(w.length<2)throw new l.RERR("BadArguments",`Key must have note + octave and an optional glyph: ${ce}`);const C=w[0].toUpperCase(),V=m.keyProperties.note_values[C];if(!V)throw new l.RERR("BadArguments","Invalid key name: "+C);V.octave&&(w[1]=V.octave);let z=parseInt(w[1],10);z-=b.octave_shift;let J=(7*z-28+V.index)/2;J+=m.clefProperties(e).line_shift;let Z=0;J<=0&&2*J%2==0&&(Z=1),J>=6&&2*J%2==0&&(Z=-1);const re=V.int_val!==void 0?12*z+V.int_val:null,ae=V.code,le=V.shift_right;let he={};if(w.length>2&&w[2]){const pe=w[2].toUpperCase();he=m.keyProperties.customNoteHeads[pe]||{}}return{key:C,octave:z,line:J,int_value:re,accidental:V.accidental,code:ae,stroke:Z,shift_right:le,displaced:!1,...he}},m.keyProperties.note_values={C:{index:0,int_val:0,accidental:null},CN:{index:0,int_val:0,accidental:"n"},"C#":{index:0,int_val:1,accidental:"#"},"C##":{index:0,int_val:2,accidental:"##"},CB:{index:0,int_val:-1,accidental:"b"},CBB:{index:0,int_val:-2,accidental:"bb"},D:{index:1,int_val:2,accidental:null},DN:{index:1,int_val:2,accidental:"n"},"D#":{index:1,int_val:3,accidental:"#"},"D##":{index:1,int_val:4,accidental:"##"},DB:{index:1,int_val:1,accidental:"b"},DBB:{index:1,int_val:0,accidental:"bb"},E:{index:2,int_val:4,accidental:null},EN:{index:2,int_val:4,accidental:"n"},"E#":{index:2,int_val:5,accidental:"#"},"E##":{index:2,int_val:6,accidental:"##"},EB:{index:2,int_val:3,accidental:"b"},EBB:{index:2,int_val:2,accidental:"bb"},F:{index:3,int_val:5,accidental:null},FN:{index:3,int_val:5,accidental:"n"},"F#":{index:3,int_val:6,accidental:"#"},"F##":{index:3,int_val:7,accidental:"##"},FB:{index:3,int_val:4,accidental:"b"},FBB:{index:3,int_val:3,accidental:"bb"},G:{index:4,int_val:7,accidental:null},GN:{index:4,int_val:7,accidental:"n"},"G#":{index:4,int_val:8,accidental:"#"},"G##":{index:4,int_val:9,accidental:"##"},GB:{index:4,int_val:6,accidental:"b"},GBB:{index:4,int_val:5,accidental:"bb"},A:{index:5,int_val:9,accidental:null},AN:{index:5,int_val:9,accidental:"n"},"A#":{index:5,int_val:10,accidental:"#"},"A##":{index:5,int_val:11,accidental:"##"},AB:{index:5,int_val:8,accidental:"b"},ABB:{index:5,int_val:7,accidental:"bb"},B:{index:6,int_val:11,accidental:null},BN:{index:6,int_val:11,accidental:"n"},"B#":{index:6,int_val:12,accidental:"#"},"B##":{index:6,int_val:13,accidental:"##"},BB:{index:6,int_val:10,accidental:"b"},BBB:{index:6,int_val:9,accidental:"bb"},R:{index:6,int_val:9,rest:!0},X:{index:6,accidental:"",octave:4,code:"v3e",shift_right:5.5}},m.keyProperties.customNoteHeads={D0:{code:"v27",shift_right:0,stem_up_x_offset:0,stem_down_x_offset:0,stem_up_y_offset:-1,stem_down_y_offset:0},D1:{code:"v2d",shift_right:-.5},D2:{code:"v22",shift_right:-.5},D3:{code:"v70",shift_right:-.5},T0:{code:"v49",shift_right:-2,stem_up_y_offset:-4,stem_down_y_offset:4},T1:{code:"v93",shift_right:.5,stem_up_y_offset:-4,stem_down_y_offset:4},T2:{code:"v40",shift_right:.5,stem_up_y_offset:-4,stem_down_y_offset:4},T3:{code:"v7d",shift_right:.5,stem_up_y_offset:-4,stem_down_y_offset:4},TI:{code:"v11",shift_right:0,stem_up_y_shift:5,stem_down_y_shift:5,stem_up_x_offset:6,stem_down_x_offset:4},X0:{code:"v92",stem_up_x_offset:-2,stem_down_x_offset:0,stem_up_y_offset:4,stem_down_y_offset:4},X1:{code:"v95",shift_right:-.5,stem_up_y_offset:4,stem_down_y_offset:4},X2:{code:"v3e",shift_right:.5,stem_up_y_offset:4,stem_down_y_offset:4},X3:{code:"v3b",shift_right:0,stem_up_x_offset:-1.2,stem_down_x_offset:0,stem_up_y_offset:-1,stem_down_y_offset:2},S1:{code:"vd3",shift_right:0},S2:{code:"vd2",shift_right:0},R1:{code:"vd5",shift_right:0},R2:{code:"vd4",shift_right:0},rwl:{code:"rwl",shift_right:0},rhl:{code:"rhl",shift_right:0}},m.integerToNote=ce=>{if(ce===void 0)throw new l.RERR("BadArguments","Undefined integer for integerToNote");if(ce<-2)throw new l.RERR("BadArguments",`integerToNote requires integer > -2: ${ce}`);const e=m.integerToNote.table[ce];if(!e)throw new l.RERR("BadArguments",`Unknown note value for integer: ${ce}`);return e},m.integerToNote.table={0:"C",1:"C#",2:"D",3:"D#",4:"E",5:"F",6:"F#",7:"G",8:"G#",9:"A",10:"A#",11:"B"},m.tabToGlyph=(ce,e=1,a=!1)=>{let b=null,w=0,C=0;if(ce.toString().toUpperCase()==="X"){b="v7f",a&&(b="v3e");const V=new p(b,m.DEFAULT_TABLATURE_FONT_SCALE*e).getMetrics();w=V.width,C=-V.height/2}else w=m.textWidth(ce.toString());return{text:ce,code:b,getWidth:()=>w*e,shift_y:C}},m.textWidth=ce=>7*ce.toString().length,m.articulationCodes=ce=>m.articulationCodes.articulations[ce],m.articulationCodes.articulations={"a.":{code:"v23",between_lines:!0},av:{code:"v28",between_lines:!0},"a>":{code:"v42",between_lines:!0},"a-":{code:"v25",between_lines:!0},"a^":{code:"va",between_lines:!1},"a+":{code:"v8b",between_lines:!1},ao:{code:"v94",between_lines:!1},ah:{code:"vb9",between_lines:!1},"a@a":{code:"v43",between_lines:!1},"a@u":{code:"v5b",between_lines:!1},"a|":{code:"v75",between_lines:!1},am:{code:"v97",between_lines:!1},"a,":{code:"vb3",between_lines:!1}},m.accidentalCodes=ce=>m.accidentalCodes.accidentals[ce],m.accidentalCodes.accidentals={"#":{code:"v18",parenRightPaddingAdjustment:-1},"##":{code:"v7f",parenRightPaddingAdjustment:-1},b:{code:"v44",parenRightPaddingAdjustment:-2},bb:{code:"v26",parenRightPaddingAdjustment:-2},n:{code:"v4e",parenRightPaddingAdjustment:-1},"{":{code:"v9c",parenRightPaddingAdjustment:-1},"}":{code:"v84",parenRightPaddingAdjustment:-1},db:{code:"v9e",parenRightPaddingAdjustment:-1},d:{code:"vab",parenRightPaddingAdjustment:0},bbs:{code:"v90",parenRightPaddingAdjustment:-1},"++":{code:"v51",parenRightPaddingAdjustment:-1},"+":{code:"v78",parenRightPaddingAdjustment:-1},"+-":{code:"v8d",parenRightPaddingAdjustment:-1},"++-":{code:"v7a",parenRightPaddingAdjustment:-1},bs:{code:"vb7",parenRightPaddingAdjustment:-1},bss:{code:"v39",parenRightPaddingAdjustment:-1},o:{code:"vd0",parenRightPaddingAdjustment:-1},k:{code:"vd1",parenRightPaddingAdjustment:-1},ashs:{code:"vd6",parenRightPaddingAdjustment:-1},afhf:{code:"vd7",parenRightPaddingAdjustment:-1}},m.accidentalColumnsTable={1:{a:[1],b:[1]},2:{a:[1,2]},3:{a:[1,3,2],b:[1,2,1],second_on_bottom:[1,2,3]},4:{a:[1,3,4,2],b:[1,2,3,1],spaced_out_tetrachord:[1,2,1,2]},5:{a:[1,3,5,4,2],b:[1,2,4,3,1],spaced_out_pentachord:[1,2,3,2,1],very_spaced_out_pentachord:[1,2,1,2,1]},6:{a:[1,3,5,6,4,2],b:[1,2,4,5,3,1],spaced_out_hexachord:[1,3,2,1,3,2],very_spaced_out_hexachord:[1,2,1,2,1,2]}},m.ornamentCodes=ce=>m.ornamentCodes.ornaments[ce],m.ornamentCodes.ornaments={mordent:{code:"v1e"},mordent_inverted:{code:"v45"},turn:{code:"v72"},turn_inverted:{code:"v33"},tr:{code:"v1f"},upprall:{code:"v60"},downprall:{code:"vb4"},prallup:{code:"v6d"},pralldown:{code:"v2c"},upmordent:{code:"v29"},downmordent:{code:"v68"},lineprall:{code:"v20"},prallprall:{code:"v86"}},m.keySignature=ce=>{const e=m.keySignature.keySpecs[ce];if(!e)throw new l.RERR("BadKeySignature",`Bad key signature spec: '${ce}'`);if(!e.acc)return[];const a=m.keySignature.accidentalList(e.acc),b=[];for(let w=0;w({b:[2,.5,2.5,1,3,1.5,3.5],"#":[0,1.5,-.5,1,2.5,.5,2]})[ce],m.parseNoteDurationString=ce=>{if(typeof ce!="string")return null;const e=/(\d*\/?\d+|[a-z])(d*)([nrhms]|$)/.exec(ce);if(!e)return null;const a=e[1],b=e[2].length;let w=e[3];return w.length===0&&(w="n"),{duration:a,dots:b,type:w}},m.parseNoteStruct=ce=>{const e=ce.duration,a=m.parseNoteDurationString(e);if(!a)return null;let b=m.durationToTicks(a.duration);if(b==null)return null;let w=ce.type;const C=[];if(w){if(!m.getGlyphProps.validTypes[w])return null}else w=a.type||"n",ce.keys!==void 0&&ce.keys.forEach((J,Z)=>{const re=J.split("/");re&&re.length===3&&(C[Z]=re[2])});const V=ce.dots?ce.dots:a.dots;if(typeof V!="number")return null;let z=b;for(let J=0;J{const e=m.durationAliases[ce];if(e!==void 0&&(ce=e),m.durationToTicks.durations[ce]===void 0)throw new l.RERR("BadArguments",`The provided duration is not valid: ${ce}`);return ce},m.durationToFraction=ce=>new s().parse(m.sanitizeDuration(ce)),m.durationToNumber=ce=>m.durationToFraction(ce).value(),m.durationToTicks=ce=>{ce=m.sanitizeDuration(ce);const e=m.durationToTicks.durations[ce];return e===void 0?null:e},m.durationToTicks.durations={"1/2":2*m.RESOLUTION,1:m.RESOLUTION/1,2:m.RESOLUTION/2,4:m.RESOLUTION/4,8:m.RESOLUTION/8,16:m.RESOLUTION/16,32:m.RESOLUTION/32,64:m.RESOLUTION/64,128:m.RESOLUTION/128,256:m.RESOLUTION/256},m.durationAliases={w:"1",h:"2",q:"4",b:"256"},m.getGlyphProps=(ce,e)=>{ce=m.sanitizeDuration(ce);const a=m.getGlyphProps.duration_codes[ce];if(a===void 0)return null;e||(e="n");let b=a.type[e];if(b===void 0){const w=m.keyProperties.customNoteHeads[e.toUpperCase()];if(w===void 0)return null;b={code_head:w.code,...w}}return{...a.common,...b}},m.getGlyphProps.validTypes={n:{name:"note"},r:{name:"rest"},h:{name:"harmonic"},m:{name:"muted"},s:{name:"slash"}},m.getGlyphProps.duration_codes={"1/2":{common:{getWidth(ce=m.DEFAULT_NOTATION_FONT_SCALE){return new p(this.code_head||"v53",ce).getMetrics().width},stem:!1,stem_offset:0,flag:!1,stem_up_extension:-m.STEM_HEIGHT,stem_down_extension:-m.STEM_HEIGHT,tabnote_stem_up_extension:-m.STEM_HEIGHT,tabnote_stem_down_extension:-m.STEM_HEIGHT,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"v53"},h:{code_head:"v59"},m:{code_head:"vf",stem_offset:0},r:{code_head:"v31",rest:!0,position:"B/5",dot_shiftY:.5},s:{getWidth:()=>m.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},1:{common:{getWidth(ce=m.DEFAULT_NOTATION_FONT_SCALE){return new p(this.code_head||"v1d",ce).getMetrics().width},stem:!1,stem_offset:0,flag:!1,stem_up_extension:-m.STEM_HEIGHT,stem_down_extension:-m.STEM_HEIGHT,tabnote_stem_up_extension:-m.STEM_HEIGHT,tabnote_stem_down_extension:-m.STEM_HEIGHT,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"v1d"},h:{code_head:"v46"},m:{code_head:"v92",stem_offset:-3},r:{code_head:"v5c",rest:!0,position:"D/5",dot_shiftY:.5},s:{getWidth:()=>m.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},2:{common:{getWidth(ce=m.DEFAULT_NOTATION_FONT_SCALE){return new p(this.code_head||"v81",ce).getMetrics().width},stem:!0,stem_offset:0,flag:!1,stem_up_extension:0,stem_down_extension:0,tabnote_stem_up_extension:0,tabnote_stem_down_extension:0,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"v81"},h:{code_head:"v2d"},m:{code_head:"v95",stem_offset:-3},r:{code_head:"vc",stem:!1,rest:!0,position:"B/4",dot_shiftY:-.5},s:{getWidth:()=>m.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},4:{common:{getWidth(ce=m.DEFAULT_NOTATION_FONT_SCALE){return new p(this.code_head||"vb",ce).getMetrics().width},stem:!0,stem_offset:0,flag:!1,stem_up_extension:0,stem_down_extension:0,tabnote_stem_up_extension:0,tabnote_stem_down_extension:0,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"vb"},h:{code_head:"v22"},m:{code_head:"v3e",stem_offset:-3},r:{code_head:"v7c",stem:!1,rest:!0,position:"B/4",dot_shiftY:-.5,line_above:1.5,line_below:1.5},s:{getWidth:()=>m.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},8:{common:{getWidth(ce=m.DEFAULT_NOTATION_FONT_SCALE){return new p(this.code_head||"vb",ce).getMetrics().width},stem:!0,stem_offset:0,flag:!0,beam_count:1,code_flag_upstem:"v54",code_flag_downstem:"v9a",stem_up_extension:0,stem_down_extension:0,tabnote_stem_up_extension:0,tabnote_stem_down_extension:0,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"vb"},h:{code_head:"v22"},m:{code_head:"v3e"},r:{code_head:"va5",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-.5,line_above:1,line_below:1},s:{getWidth:()=>m.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},16:{common:{beam_count:2,getWidth(ce=m.DEFAULT_NOTATION_FONT_SCALE){return new p(this.code_head||"vb",ce).getMetrics().width},stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"v3f",code_flag_downstem:"v8f",stem_up_extension:0,stem_down_extension:0,tabnote_stem_up_extension:0,tabnote_stem_down_extension:0,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"vb"},h:{code_head:"v22"},m:{code_head:"v3e"},r:{code_head:"v3c",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-.5,line_above:1,line_below:2},s:{getWidth:()=>m.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},32:{common:{beam_count:3,getWidth(ce=m.DEFAULT_NOTATION_FONT_SCALE){return new p(this.code_head||"vb",ce).getMetrics().width},stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"v47",code_flag_downstem:"v2a",stem_up_extension:9,stem_down_extension:9,tabnote_stem_up_extension:8,tabnote_stem_down_extension:5,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"vb"},h:{code_head:"v22"},m:{code_head:"v3e"},r:{code_head:"v55",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-1.5,line_above:2,line_below:2},s:{getWidth:()=>m.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},64:{common:{beam_count:4,getWidth(ce=m.DEFAULT_NOTATION_FONT_SCALE){return new p(this.code_head||"vb",ce).getMetrics().width},stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"va9",code_flag_downstem:"v58",stem_up_extension:13,stem_down_extension:13,tabnote_stem_up_extension:12,tabnote_stem_down_extension:9,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"vb"},h:{code_head:"v22"},m:{code_head:"v3e"},r:{code_head:"v38",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-1.5,line_above:2,line_below:3},s:{getWidth:()=>m.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},128:{common:{beam_count:5,getWidth(ce=m.DEFAULT_NOTATION_FONT_SCALE){return new p(this.code_head||"vb",ce).getMetrics().width},stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"v9b",code_flag_downstem:"v30",stem_up_extension:22,stem_down_extension:22,tabnote_stem_up_extension:21,tabnote_stem_down_extension:18,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"vb"},h:{code_head:"v22"},m:{code_head:"v3e"},r:{code_head:"vaa",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:1.5,line_above:3,line_below:3},s:{getWidth:()=>m.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}}},m.smufl={},m.smufl.to_code_points={bracketTop:"v1b",bracketBottom:"v10",barlineTick:"v6f",segno:"v8c",coda:"v4d",gClef:"v83",cClef:"vad",fClef:"v79",unpitchedPercussionClef1:"v59","6stringTabClef":"v2f",timeSig0:"v0",timeSig1:"v1",timeSig2:"v2",timeSig3:"v3",timeSig4:"v4",timeSig5:"v5",timeSig6:"v6",timeSig7:"v7",timeSig8:"v8",timeSig9:"v9",timeSigCommon:"v41",timeSigCutCommon:"vb6",noteheadDoubleWhole:"v53",noteheadWhole:"v1d",noteheadHalf:"v81",noteheadBlack:"vb",noteheadXWhole:"v92",noteheadXHalf:"v95",noteheadXBlack:"v3e",noteheadCircleX:"v3b",noteheadTriangleUpWhole:"v49",noteheadTriangleUpHalf:"v93",noteheadTriangleUpBlack:"v40",noteheadDiamondWhole:"v46",noteheadDiamondHalf:"v2d",noteheadDiamondBlack:"v22",augmentationDot:"v23",tremolo1:"v74",flag8thUp:"v54",flag8thDown:"v9a",flag16thUp:"v3f",flag16thDown:"v8f",flag32ndUp:"v47",flag32ndDown:"v2a",flag64thUp:"va9",flag64thDown:"v58",flag128thUp:"v9b",flag128thDown:"v30",accidentalFlat:"v44",accidentalNatural:"v4e",accidentalSharp:"v18",accidentalDoubleSharp:"v7f",accidentalDoubleFlat:"v26",accidentalParensLeft:"v9c",accidentalParensRight:"v84",accidentalQuarterToneFlatStein:"vab",accidentalThreeQuarterTonesFlatZimmermann:"v9e",accidentalQuarterToneSharpStein:"v78",accidentalThreeQuarterTonesSharpStein:"v51",accidentalBuyukMucennebFlat:"v39",accidentalBakiyeFlat:"vb7",accidentalKomaSharp:"v51",accidentalKucukMucennebSharp:"v8d",accidentalKoron:"vd1",accidentalSori:"vd0",articAccentAbove:"v42",articAccentBelow:"v42",articTenutoAbove:"v25",articTenutoBelow:"v25",articStaccatoAbove:"v23",articStaccatoBelow:"v23",articStaccatissimoAbove:"v28",articMarcatoAbove:"va",fermataAbove:"v43",fermataBelow:"v5b",breathMarkComma:"v6c",breathMarkUpbow:"v8a",caesura:"v34",caesuraCurved:"v4b",restMaxima:"v59",restDoubleWhole:"v31",restWhole:"v5c",restHalf:"vc",restQuarter:"v7c",rest8th:"va5",rest16th:"v3c",rest32nd:"v55",rest64th:"v38",rest128th:"vaa",dynamicPiano:"vbf",dynamicMezzo:"v62",dynamicForte:"vba",dynamicRinforzando:"vba",dynamicSforzando:"v4a",dynamicZ:"v80",ornamentTrill:"v1f",ornamentTurn:"v72",ornamentTurnSlash:"v33",ornamentMordent:"v45",ornamentMordentInverted:"v1e",ornamentTremblement:"v86",ornamentPrecompAppoggTrill:"v20",ornamentPrecompSlideTrillDAnglebert:"v60",ornamentPrecompSlideTrillBach:"v29",ornamentPrecompTrillSuffixDandrieu:"v6d",ornamentPrecompDoubleCadenceUpperPrefix:"vb4",ornamentPrecompDoubleCadenceUpperPrefixTurn:"v68",ornamentPrecompTrillLowerSuffix:"v2c",stringsDownBow:"v94",stringsUpBow:"v75",stringsHarmonic:"vb9",pluckedSnapPizzicatoAbove:"v94",pluckedLeftHandPizzicato:"v8b",keyboardPedalPed:"v36",keyboardPedalUp:"v5d",pictChokeCymbal:"vb3",wiggleArpeggiatoUp:"va3",arrowheadBlackUp:"vc3",arrowheadBlackDown:"v52"},m.TIME4_4={num_beats:4,beat_value:4,resolution:m.RESOLUTION};class x{static get WIDTH(){return 600}static get HEIGHT(){return 400}static get CANVAS_BROWSER_SIZE_LIMIT(){return 32767}static SanitizeCanvasDims(e,a){return Math.max(e,a)>this.CANVAS_BROWSER_SIZE_LIMIT&&(l.W("Canvas dimensions exceed browser limit. Cropping to "+this.CANVAS_BROWSER_SIZE_LIMIT),e>this.CANVAS_BROWSER_SIZE_LIMIT&&(e=this.CANVAS_BROWSER_SIZE_LIMIT),a>this.CANVAS_BROWSER_SIZE_LIMIT&&(a=this.CANVAS_BROWSER_SIZE_LIMIT)),[e,a]}constructor(e){this.vexFlowCanvasContext=e,e.canvas?this.canvas=e.canvas:this.canvas={width:x.WIDTH,height:x.HEIGHT}}clear(){this.vexFlowCanvasContext.clearRect(0,0,this.canvas.width,this.canvas.height)}openGroup(){}closeGroup(){}add(){}setFont(e,a,b){return this.vexFlowCanvasContext.font=(b||"")+" "+a+"pt "+e,this}setRawFont(e){return this.vexFlowCanvasContext.font=e,this}setFillStyle(e){return this.vexFlowCanvasContext.fillStyle=e,this}setBackgroundFillStyle(e){return this.background_fillStyle=e,this}setStrokeStyle(e){return this.vexFlowCanvasContext.strokeStyle=e,this}setShadowColor(e){return this.vexFlowCanvasContext.shadowColor=e,this}setShadowBlur(e){return this.vexFlowCanvasContext.shadowBlur=e,this}setLineWidth(e){return this.vexFlowCanvasContext.lineWidth=e,this}setLineCap(e){return this.vexFlowCanvasContext.lineCap=e,this}setLineDash(e){return this.vexFlowCanvasContext.lineDash=e,this}scale(e,a){return this.vexFlowCanvasContext.scale(parseFloat(e),parseFloat(a))}resize(e,a){return[e,a]=this.SanitizeCanvasDims(parseInt(e,10),parseInt(a,10)),this.vexFlowCanvasContext.resize(e,a)}rect(e,a,b,w){return this.vexFlowCanvasContext.rect(e,a,b,w)}fillRect(e,a,b,w){return this.vexFlowCanvasContext.fillRect(e,a,b,w)}clearRect(e,a,b,w){return this.vexFlowCanvasContext.clearRect(e,a,b,w)}beginPath(){return this.vexFlowCanvasContext.beginPath()}moveTo(e,a){return this.vexFlowCanvasContext.moveTo(e,a)}lineTo(e,a){return this.vexFlowCanvasContext.lineTo(e,a)}bezierCurveTo(e,a,b,w,C,V){return this.vexFlowCanvasContext.bezierCurveTo(e,a,b,w,C,V)}quadraticCurveTo(e,a,b,w){return this.vexFlowCanvasContext.quadraticCurveTo(e,a,b,w)}arc(e,a,b,w,C,V){return this.vexFlowCanvasContext.arc(e,a,b,w,C,V)}glow(){return this.vexFlowCanvasContext.glow()}fill(){return this.vexFlowCanvasContext.fill()}stroke(){return this.vexFlowCanvasContext.stroke()}closePath(){return this.vexFlowCanvasContext.closePath()}measureText(e){return this.vexFlowCanvasContext.measureText(e)}fillText(e,a,b){return this.vexFlowCanvasContext.fillText(e,a,b)}save(){return this.vexFlowCanvasContext.save()}restore(){return this.vexFlowCanvasContext.restore()}}class y{constructor(e){this.element=e,this.paper=Raphael(e),this.path="",this.pen={x:0,y:0},this.lineWidth=1,this.state={scale:{x:1,y:1},font_family:"Arial",font_size:8,font_weight:800},this.attributes={"stroke-width":.3,fill:"black",stroke:"black",font:"10pt Arial"},this.background_attributes={"stroke-width":0,fill:"white",stroke:"white",font:"10pt Arial"},this.shadow_attributes={width:0,color:"black"},this.state_stack=[]}openGroup(){}closeGroup(){}add(){}setFont(e,a,b){return this.state.font_family=e,this.state.font_size=a,this.state.font_weight=b,this.attributes.font=(this.state.font_weight||"")+" "+this.state.font_size*this.state.scale.x+"pt "+this.state.font_family,this}setRawFont(e){return this.attributes.font=e,this}setFillStyle(e){return this.attributes.fill=e,this}setBackgroundFillStyle(e){return this.background_attributes.fill=e,this.background_attributes.stroke=e,this}setStrokeStyle(e){return this.attributes.stroke=e,this}setShadowColor(e){return this.shadow_attributes.color=e,this}setShadowBlur(e){return this.shadow_attributes.width=e,this}setLineWidth(e){this.attributes["stroke-width"]=e,this.lineWidth=e}setLineDash(){return this}setLineCap(){return this}scale(e,a){return this.state.scale={x:e,y:a},this.attributes.transform="S"+e+","+a+",0,0",this.attributes.scale=e+","+a+",0,0",this.attributes.font=this.state.font_size*this.state.scale.x+"pt "+this.state.font_family,this.background_attributes.transform="S"+e+","+a+",0,0",this.background_attributes.font=this.state.font_size*this.state.scale.x+"pt "+this.state.font_family,this}clear(){this.paper.clear()}resize(e,a){return this.element.style.width=e,this.paper.setSize(e,a),this}setViewBox(e){this.paper.canvas.setAttribute("viewBox",e)}rect(e,a,b,w){return w<0&&(a+=w,w=-w),this.paper.rect(e,a,b-.5,w-.5).attr(this.attributes).attr("fill","none").attr("stroke-width",this.lineWidth),this}fillRect(e,a,b,w){return w<0&&(a+=w,w=-w),this.paper.rect(e,a,b-.5,w-.5).attr(this.attributes),this}clearRect(e,a,b,w){return w<0&&(a+=w,w=-w),this.paper.rect(e,a,b-.5,w-.5).attr(this.background_attributes),this}beginPath(){return this.path="",this.pen.x=0,this.pen.y=0,this}moveTo(e,a){return this.path+="M"+e+","+a,this.pen.x=e,this.pen.y=a,this}lineTo(e,a){return this.path+="L"+e+","+a,this.pen.x=e,this.pen.y=a,this}bezierCurveTo(e,a,b,w,C,V){return this.path+="C"+e+","+a+","+b+","+w+","+C+","+V,this.pen.x=C,this.pen.y=V,this}quadraticCurveTo(e,a,b,w){return this.path+="Q"+e+","+a+","+b+","+w,this.pen.x=b,this.pen.y=w,this}arc(e,a,b,w,C,V){function z(Z){for(;Z<0;)Z+=2*Math.PI;for(;Z>2*Math.PI;)Z-=2*Math.PI;return Z}if((w=z(w))>(C=z(C))){const Z=w;w=C,C=Z,V=!V}const J=C-w;return J>Math.PI?(this.arcHelper(e,a,b,w,w+J/2,V),this.arcHelper(e,a,b,w+J/2,C,V)):this.arcHelper(e,a,b,w,C,V),this}arcHelper(e,a,b,w,C,V){const z=e+b*Math.cos(w),J=a+b*Math.sin(w),Z=e+b*Math.cos(C),re=a+b*Math.sin(C);let ae=0,le=0;V?(le=1,C-wMath.PI&&(ae=1),this.path+="M"+z+","+J+",A"+b+","+b+",0,"+ae+","+le+","+Z+","+re+"M"+this.pen.x+","+this.pen.y}glow(){const e=this.paper.set();if(this.shadow_attributes.width>0){const a=this.shadow_attributes,b=a.width/2;for(let w=1;w<=b;w++)e.push(this.paper.path(this.path).attr({stroke:a.color,"stroke-linejoin":"round","stroke-linecap":"round","stroke-width":+(a.width/b*w).toFixed(3),opacity:+((a.opacity||.3)/b).toFixed(3),transform:this.attributes.transform,scale:this.attributes.scale}))}return e}fill(){const e=this.paper.path(this.path).attr(this.attributes).attr("stroke-width",0);return this.glow(e),this}stroke(){const e=this.lineWidth*(this.state.scale.x+this.state.scale.y)/2,a=this.paper.path(this.path).attr(this.attributes).attr("fill","none").attr("stroke-width",e);return this.glow(a),this}closePath(){return this.path+="Z",this}measureText(e){const a=this.paper.text(0,0,e).attr(this.attributes).attr("fill","none").attr("stroke","none"),b=a.getBBox();return a.remove(),{width:b.width,height:b.height}}fillText(e,a,b){return this.paper.text(a+this.measureText(e).width/2,b-this.state.font_size/(2.25*this.state.scale.y),e).attr(this.attributes),this}save(){return this.state_stack.push({state:{font_family:this.state.font_family},attributes:{font:this.attributes.font,fill:this.attributes.fill,stroke:this.attributes.stroke,"stroke-width":this.attributes["stroke-width"]},shadow_attributes:{width:this.shadow_attributes.width,color:this.shadow_attributes.color}}),this}restore(){const e=this.state_stack.pop();return this.state.font_family=e.state.font_family,this.attributes.font=e.attributes.font,this.attributes.fill=e.attributes.fill,this.attributes.stroke=e.attributes.stroke,this.attributes["stroke-width"]=e.attributes["stroke-width"],this.shadow_attributes.width=e.shadow_attributes.width,this.shadow_attributes.color=e.shadow_attributes.color,this}}const d={path:{x:!0,y:!0,width:!0,height:!0},rect:{},text:{width:!0,height:!0}};{const ce={"font-family":!0,"font-weight":!0,"font-style":!0,"font-size":!0};l.Merge(d.rect,ce),l.Merge(d.path,ce)}class S{constructor(e){this.element=e,this.svgNS="http://www.w3.org/2000/svg";const a=this.create("svg");this.element.appendChild(a),this.svg=a,this.groups=[this.svg],this.parent=this.svg,this.path="",this.pen={x:NaN,y:NaN},this.lineWidth=1,this.state={scale:{x:1,y:1},"font-family":"Arial","font-size":"8pt","font-weight":"normal"},this.attributes={"stroke-width":.3,fill:"black",stroke:"black","stroke-dasharray":"none","font-family":"Arial","font-size":"10pt","font-weight":"normal","font-style":"normal"},this.background_attributes={"stroke-width":0,fill:"white",stroke:"white","stroke-dasharray":"none","font-family":"Arial","font-size":"10pt","font-weight":"normal","font-style":"normal"},this.shadow_attributes={width:0,color:"black"},this.state_stack=[],this.iePolyfill()}create(e){return document.createElementNS(this.svgNS,e)}openGroup(e,a,b){const w=this.create("g");return this.groups.push(w),this.parent.appendChild(w),this.parent=w,e&&w.setAttribute("class",l.Prefix(e)),a&&w.setAttribute("id",l.Prefix(a)),b&&b.pointerBBox&&w.setAttribute("pointer-events","bounding-box"),w}closeGroup(){this.groups.pop(),this.parent=this.groups[this.groups.length-1]}add(e){this.parent.appendChild(e)}iePolyfill(){typeof navigator<"u"&&(this.ie=/MSIE 9/i.test(navigator.userAgent)||/MSIE 10/i.test(navigator.userAgent)||/rv:11\.0/i.test(navigator.userAgent)||/Trident/i.test(navigator.userAgent))}setFont(e,a,b){let w=!1,C=!1,V="normal";typeof b=="string"&&(b.indexOf("italic")!==-1&&(b=b.replace(/italic/g,""),C=!0),b.indexOf("bold")!==-1&&(b=b.replace(/bold/g,""),w=!0),b=b.replace(/ /g,"")),V=C?"italic":V;const z={"font-family":e,"font-size":a+"pt","font-weight":b=(b=w?"bold":b)===void 0||b===""?"normal":b,"font-style":V};return this.fontSize=Number(a),l.Merge(this.attributes,z),l.Merge(this.state,z),this}setRawFont(e){const a=(e=e.trim()).split(" ");return this.attributes["font-family"]=a[1],this.state["font-family"]=a[1],this.attributes["font-size"]=a[0],this.state["font-size"]=a[0],this.fontSize=Number(a[0].match(/\d+/)),this}setFillStyle(e){return this.attributes.fill=e,this}setBackgroundFillStyle(e){return this.background_attributes.fill=e,this.background_attributes.stroke=e,this}setStrokeStyle(e){return this.attributes.stroke=e,this}setShadowColor(e){return this.shadow_attributes.color=e,this}setShadowBlur(e){return this.shadow_attributes.width=e,this}setLineWidth(e){this.attributes["stroke-width"]=e,this.lineWidth=e}setLineDash(e){if(Object.prototype.toString.call(e)==="[object Array]")return e=e.join(", "),this.attributes["stroke-dasharray"]=e,this;throw new l.RERR("ArgumentError","lineDash must be an array of integers.")}setLineCap(e){return this.attributes["stroke-linecap"]=e,this}resize(e,a){this.width=e,this.height=a,this.element.style.width=e;const b={width:e,height:a};return this.applyAttributes(this.svg,b),this.scale(this.state.scale.x,this.state.scale.y),this}scale(e,a){this.state.scale={x:e,y:a};const b=this.width/e,w=this.height/a;return this.setViewBox(0,0,b,w),this}setViewBox(...e){if(e.length===1){const[a]=e;this.svg.setAttribute("viewBox",a)}else{const[a,b,w,C]=e,V=a+" "+b+" "+w+" "+C;this.svg.setAttribute("viewBox",V)}}applyAttributes(e,a){const b=d[e.nodeName];return Object.keys(a).forEach(w=>{b&&b[w]||e.setAttributeNS(null,w,a[w])}),e}clear(){for(;this.svg.lastChild;)this.svg.removeChild(this.svg.lastChild);this.scale(this.state.scale.x,this.state.scale.y)}rect(e,a,b,w,C){w<0&&(a+=w,w*=-1);const V=this.create("rect");return C===void 0&&(C={fill:"none","stroke-width":this.lineWidth,stroke:this.attributes.stroke}),l.Merge(C,{x:e,y:a,width:b,height:w}),this.applyAttributes(V,C),this.add(V),this}fillRect(e,a,b,w){return w<0&&(a+=w,w*=-1),this.rect(e,a,b,w,this.attributes),this}clearRect(e,a,b,w){return this.rect(e,a,b,w,this.background_attributes),this}beginPath(){return this.path="",this.pen.x=NaN,this.pen.y=NaN,this}moveTo(e,a){return this.path+="M"+e+" "+a,this.pen.x=e,this.pen.y=a,this}lineTo(e,a){return this.path+="L"+e+" "+a,this.pen.x=e,this.pen.y=a,this}bezierCurveTo(e,a,b,w,C,V){return this.path+="C"+e+" "+a+","+b+" "+w+","+C+" "+V,this.pen.x=C,this.pen.y=V,this}quadraticCurveTo(e,a,b,w){return this.path+="Q"+e+" "+a+","+b+" "+w,this.pen.x=b,this.pen.y=w,this}arc(e,a,b,w,C,V){function z(Z){for(;Z<0;)Z+=2*Math.PI;for(;Z>2*Math.PI;)Z-=2*Math.PI;return Z}if((w=z(w))>(C=z(C))){const Z=w;w=C,C=Z,V=!V}const J=C-w;return J>Math.PI?(this.arcHelper(e,a,b,w,w+J/2,V),this.arcHelper(e,a,b,w+J/2,C,V)):this.arcHelper(e,a,b,w,C,V),this}arcHelper(e,a,b,w,C,V){const z=e+b*Math.cos(w),J=a+b*Math.sin(w),Z=e+b*Math.cos(C),re=a+b*Math.sin(C);let ae=0,le=0;V?(le=1,C-wMath.PI&&(ae=1),this.path+="M"+z+" "+J+" A"+b+" "+b+" 0 "+ae+" "+le+" "+Z+" "+re,isNaN(this.pen.x)||isNaN(this.pen.y)||(this.peth+="M"+this.pen.x+" "+this.pen.y)}closePath(){return this.path+="Z",this}glow(){if(this.shadow_attributes.width>0){const e=this.shadow_attributes,a=e.width/2;for(let b=1;b<=a;b++){const w={stroke:e.color,"stroke-linejoin":"round","stroke-linecap":"round","stroke-width":+(.4*e.width/a*b).toFixed(3),opacity:+((e.opacity||.3)/a).toFixed(3)},C=this.create("path");w.d=this.path,this.applyAttributes(C,w),this.add(C)}}return this}fill(e){this.glow();const a=this.create("path");let b=e;return e===void 0?(l.Merge(e={},this.attributes),e.stroke="none",b=e):(b=e,l.Merge(b,this.attributes),e.class&&(b.class=e.class),e.id&&(b.id=e.id)),e.d=this.path,this.applyAttributes(a,e),this.add(a),this}stroke(e=void 0){this.glow();const a=this.create("path"),b={};return l.Merge(b,this.attributes),e&&l.Merge(b,e),b.fill="none",b["stroke-width"]=this.lineWidth,b.d=this.path,this.applyAttributes(a,b),this.add(a),this}measureText(e){const a=this.create("text");if(typeof a.getBBox!="function")return{x:0,y:0,width:0,height:0};a.textContent=e,this.applyAttributes(a,this.attributes),this.svg.appendChild(a);let b=a.getBBox();return this.ie&&e!==""&&this.attributes["font-style"]==="italic"&&(b=this.ieMeasureTextFix(b,e)),this.svg.removeChild(a),b}ieMeasureTextFix(e){const a=1.196*Number(this.fontSize)+1.9598,b=e.width-a,w=e.height-1.5;return{x:e.x,y:e.y,width:b,height:w}}fillText(e,a,b){if(!e||e.length<=0)return;const w={};l.Merge(w,this.attributes),w.stroke="none",w.x=a,w.y=b;const C=this.create("text");C.textContent=e,this.applyAttributes(C,w),this.add(C)}save(){return this.state_stack.push({state:{"font-family":this.state["font-family"],"font-weight":this.state["font-weight"],"font-style":this.state["font-style"],"font-size":this.state["font-size"],scale:this.state.scale},attributes:{"font-family":this.attributes["font-family"],"font-weight":this.attributes["font-weight"],"font-style":this.attributes["font-style"],"font-size":this.attributes["font-size"],fill:this.attributes.fill,stroke:this.attributes.stroke,"stroke-width":this.attributes["stroke-width"],"stroke-dasharray":this.attributes["stroke-dasharray"]},shadow_attributes:{width:this.shadow_attributes.width,color:this.shadow_attributes.color},lineWidth:this.lineWidth}),this}restore(){const e=this.state_stack.pop();return this.state["font-family"]=e.state["font-family"],this.state["font-weight"]=e.state["font-weight"],this.state["font-style"]=e.state["font-style"],this.state["font-size"]=e.state["font-size"],this.state.scale=e.state.scale,this.attributes["font-family"]=e.attributes["font-family"],this.attributes["font-weight"]=e.attributes["font-weight"],this.attributes["font-style"]=e.attributes["font-style"],this.attributes["font-size"]=e.attributes["font-size"],this.attributes.fill=e.attributes.fill,this.attributes.stroke=e.attributes.stroke,this.attributes["stroke-width"]=e.attributes["stroke-width"],this.attributes["stroke-dasharray"]=e.attributes["stroke-dasharray"],this.shadow_attributes.width=e.shadow_attributes.width,this.shadow_attributes.color=e.shadow_attributes.color,this.lineWidth=e.lineWidth,this}}let M=null;class E{static get Backends(){return{CANVAS:1,RAPHAEL:2,SVG:3,VML:4}}static get LineEndType(){return{NONE:1,UP:2,DOWN:3}}static get USE_CANVAS_PROXY(){return!1}static get lastContext(){return M}static set lastContext(e){M=e}static buildContext(e,a,b,w,C){const V=new E(e,a);b&&w&&V.resize(b,w),C||(C="#FFF");const z=V.getContext();return z.setBackgroundFillStyle(C),E.lastContext=z,z}static getCanvasContext(e,a,b,w){return E.buildContext(e,E.Backends.CANVAS,a,b,w)}static getRaphaelContext(e,a,b,w){return E.buildContext(e,E.Backends.RAPHAEL,a,b,w)}static getSVGContext(e,a,b,w){return E.buildContext(e,E.Backends.SVG,a,b,w)}static bolsterCanvasContext(e){return E.USE_CANVAS_PROXY?new x(e):(e.vexFlowCanvasContext=e,["clear","setFont","setRawFont","setFillStyle","setBackgroundFillStyle","setStrokeStyle","setShadowColor","setShadowBlur","setLineWidth","setLineCap","setLineDash","openGroup","closeGroup","getGroup"].forEach(a=>{e[a]=e[a]||x.prototype[a]}),e)}static drawDashedLine(e,a,b,w,C,V){e.beginPath();const z=w-a,J=C-b,Z=Math.atan2(J,z);let re=a,ae=b;e.moveTo(a,b);let le=0,he=!0;for(;!(z<0?re<=w:re>=w)||!(J<0?ae<=C:ae>=C);){const pe=V[le++%V.length],ge=re+Math.cos(Z)*pe;re=z<0?Math.max(w,ge):Math.min(w,ge);const me=ae+Math.sin(Z)*pe;ae=J<0?Math.max(C,me):Math.min(C,me),he?e.lineTo(re,ae):e.moveTo(re,ae),he=!he}e.closePath(),e.stroke()}constructor(e,a){if(this.elementId=e,!this.elementId)throw new l.RERR("BadArgument","Invalid id for renderer.");if(this.element=document.getElementById(e),this.element||(this.element=e),this.ctx=null,this.paper=null,this.backend=a,this.backend===E.Backends.CANVAS){if(!this.element.getContext)throw new l.RERR("BadElement",`Can't get canvas context from element: ${e}`);this.ctx=E.bolsterCanvasContext(this.element.getContext("2d",{willReadFrequently:!0}))}else if(this.backend===E.Backends.RAPHAEL)this.ctx=new y(this.element);else{if(this.backend!==E.Backends.SVG)throw new l.RERR("InvalidBackend",`No support for backend: ${this.backend}`);this.ctx=new S(this.element)}}resize(e,a){if(this.backend===E.Backends.CANVAS){if(!this.element.getContext)throw new l.RERR("BadElement",`Can't get canvas context from element: ${this.elementId}`);[e,a]=x.SanitizeCanvasDims(e,a);const b=window.devicePixelRatio||1;this.element.width=e*b,this.element.height=a*b,this.element.style.width=e+"px",this.element.style.height=a+"px",this.ctx=E.bolsterCanvasContext(this.element.getContext("2d",{willReadFrequently:!0})),this.ctx.scale(b,b)}else this.ctx.resize(e,a);return this}getContext(){return this.ctx}}class L extends o{static get CATEGORY(){return"stem"}static get UP(){return 1}static get DOWN(){return-1}static get WIDTH(){return m.STEM_WIDTH}static get HEIGHT(){return m.STEM_HEIGHT}constructor(e={}){super(),this.setAttribute("type","Stem"),this.x_begin=e.x_begin||0,this.x_end=e.x_end||0,this.y_top=e.y_top||0,this.y_bottom=e.y_bottom||0,this.stem_extension=e.stem_extension||0,this.stem_direction=e.stem_direction||0,this.hide=e.hide||!1,this.isStemlet=e.isStemlet||!1,this.stemletHeight=e.stemletHeight||0,this.renderHeightAdjustment=0,this.setOptions(e)}setOptions(e){this.stem_up_y_offset=e.stem_up_y_offset||0,this.stem_down_y_offset=e.stem_down_y_offset||0}setNoteHeadXBounds(e,a){return this.x_begin=e,this.x_end=a,this}setDirection(e){this.stem_direction=e}setExtension(e){this.stem_extension=e}getExtension(){return this.stem_extension}setYBounds(e,a){this.y_top=e,this.y_bottom=a}getCategory(){return L.CATEGORY}getHeight(){const e=this.stem_direction===L.UP?this.stem_up_y_offset:this.stem_down_y_offset;return(this.y_bottom-this.y_top)*this.stem_direction+(L.HEIGHT-e+this.stem_extension)*this.stem_direction}getBoundingBox(){throw new l.RERR("NotImplemented","getBoundingBox() not implemented.")}getExtents(){const e=this.stem_direction===L.UP,a=[this.y_top,this.y_bottom],b=L.HEIGHT+this.stem_extension,w=(e?Math.min:Math.max)(...a),C=(e?Math.max:Math.min)(...a);return{topY:w+b*-this.stem_direction,baseY:C}}setVisibility(e){return this.hide=!e,this}setStemlet(e,a){return this.isStemlet=e,this.stemletHeight=a,this}draw(){if(this.setRendered(),this.hide)return;const e=this.checkContext();let a,b;const w=this.stem_direction;w===L.DOWN?(a=this.x_begin,b=this.y_top+this.stem_down_y_offset):(a=this.x_end,b=this.y_bottom-this.stem_up_y_offset);const C=this.getHeight();(function(...z){L.DEBUG&&l.L("Vex.Flow.Stem",z)})("Rendering stem - ","Top Y: ",this.y_top,"Bottom Y: ",this.y_bottom);const V=this.isStemlet?C-this.stemletHeight*this.stem_direction:0;if(e.save(),this.applyStyle(e),e.beginPath(),e.setLineWidth(L.WIDTH),e.moveTo(a,b-V),e.lineTo(a,b-C-this.renderHeightAdjustment*w),e.svg){const z={class:l.Prefix("stem")};this.id&&(z.id=this.id),e.stroke(z)}else e.stroke();this.restoreStyle(e),e.restore()}}class I extends o{static get LOCATION_TOP(){return 1}static get LOCATION_BOTTOM(){return-1}static get NESTING_OFFSET(){return 15}constructor(e,a){if(super(),this.setAttribute("type","Tuplet"),!e||!e.length)throw new l.RuntimeError("BadArguments","No notes provided for tuplet.");this.options=l.Merge({},a),this.notes=e,this.num_notes="num_notes"in this.options?this.options.num_notes:e.length,this.options.beats_occupied&&this.beatsOccupiedDeprecationWarning(),this.notes_occupied=this.options.notes_occupied||this.options.beats_occupied||2,"bracketed"in this.options?this.bracketed=this.options.bracketed:this.bracketed=e.some(b=>b.beam===null),this.ratioed="ratioed"in this.options?this.options.ratioed:Math.abs(this.notes_occupied-this.num_notes)>1,this.point=28,this.y_pos=16,this.x_pos=100,this.width=200,this.location=this.options.location||I.LOCATION_TOP,Ce.AlignRestsToNotes(e,!0,!0),this.resolveGlyphs(),this.attach()}attach(){for(let e=0;e=1;)this.numerator_glyphs.unshift(new p("v"+e%10,this.point)),e=parseInt(e/10,10);for(this.denom_glyphs=[],e=this.notes_occupied;e>=1;)this.denom_glyphs.unshift(new p("v"+e%10,this.point)),e=parseInt(e/10,10)}getNestedTupletCount(){const e=this.location,a=this.notes[0];let b=C(a,e),w=C(a,e);function C(V,z){return V.tupletStack.filter(J=>J.location===z).length}return this.notes.forEach(V=>{const z=C(V,e);b=z>b?z:b,w=zw&&(w=V)}}return w+e+a}draw(){this.checkContext(),this.setRendered();const e=this.notes[0],a=this.notes[this.notes.length-1];this.bracketed?(this.x_pos=e.getTieLeftX()-5,this.width=a.getTieRightX()-this.x_pos+5):(this.x_pos=e.getStemX(),this.width=a.getStemX()-this.x_pos),this.y_pos=this.getYPosition();const b=(z,J)=>z+J.getMetrics().width;let w=this.numerator_glyphs.reduce(b,0);this.ratioed&&(w=this.denom_glyphs.reduce(b,w),w+=.32*this.point);const C=this.x_pos+this.width/2-w/2;if(this.bracketed){const z=this.width/2-w/2-5;z>0&&(this.context.fillRect(this.x_pos,this.y_pos,z,1),this.context.fillRect(this.x_pos+this.width/2+w/2+5,this.y_pos,z,1),this.context.fillRect(this.x_pos,this.y_pos+(this.location===I.LOCATION_BOTTOM),1,10*this.location),this.context.fillRect(this.x_pos+this.width,this.y_pos+(this.location===I.LOCATION_BOTTOM),1,10*this.location))}let V=0;if(this.RenderTupletNumber!==!1&&this.numerator_glyphs.forEach(z=>{z.render(this.context,C+V,this.y_pos+this.point/3-2),V+=z.getMetrics().width}),this.ratioed){const z=C+V+.16*this.point,J=.06*this.point;this.context.beginPath(),this.context.arc(z,this.y_pos-.08*this.point,J,0,2*Math.PI,!0),this.context.closePath(),this.context.fill(),this.context.beginPath(),this.context.arc(z,this.y_pos+.12*this.point,J,0,2*Math.PI,!0),this.context.closePath(),this.context.fill(),V+=.32*this.point,this.denom_glyphs.forEach(Z=>{Z.render(this.context,C+V,this.y_pos+this.point/3-2),V+=Z.getMetrics().width})}}}function T(ce){let e=0;return ce.forEach(a=>{a.keyProps&&a.keyProps.forEach(b=>{e+=b.line-3})}),e>=0?L.DOWN:L.UP}const A="L",v="B";class B extends o{static getDefaultBeamGroups(e){e&&e!=="c"||(e="4/4");const a={"1/2":["1/2"],"2/2":["1/2"],"3/2":["1/2"],"4/2":["1/2"],"1/4":["1/4"],"2/4":["1/4"],"3/4":["1/4"],"4/4":["1/4"],"1/8":["1/8"],"2/8":["2/8"],"3/8":["3/8"],"4/8":["2/8"],"1/16":["1/16"],"2/16":["2/16"],"3/16":["3/16"],"4/16":["2/16"]}[e];if(a!==void 0)return a.map(b=>new s().parse(b));{const b=parseInt(e.split("/")[0],10),w=parseInt(e.split("/")[1],10);if(b%3==0)return[new s(3,w)];if(w>4)return[new s(2,w)];if(w<=4)return[new s(1,w)]}return[new s(1,4)]}static applyAndGetBeams(e,a,b){return B.generateBeams(e.getTickables(),{groups:b,stem_direction:a})}static generateBeams(e,a){a||(a={}),a.groups&&a.groups.length||(a.groups=[new s(2,8)]);const b=a.groups.map(le=>{if(!le.multiply)throw new l.RuntimeError("InvalidBeamGroups","The beam groups must be an array of Vex.Flow.Fractions");return le.clone().multiply(m.RESOLUTION,1)}),w=e;let C=0,V=[],z=[];function J(){b.length-1>C?C+=1:C=0}(function(){let le=[];w.forEach(he=>{if(le=[],he.shouldIgnoreTicks())return V.push(z),void(z=le);z.push(he);const pe=b[C].clone(),ge=z.reduce((Ee,Re)=>Re.getTicks().clone().add(Ee),new s(0,1)),me=m.durationToNumber(he.duration)<8;me&&he.tuplet&&(pe.numerator*=2),ge.greaterThan(pe)?(me||le.push(z.pop()),V.push(z),z=le,J()):ge.equals(pe)&&(V.push(z),z=le,J())}),z.length>0&&V.push(z)})(),function(){const le=[];V.forEach(he=>{let pe=[];he.forEach((ge,me,Ee)=>{const Re=me===0||me===Ee.length-1,we=Ee[me-1],Ne=!a.beam_rests&&ge.isRest(),De=a.beam_rests&&a.beam_middle_only&&ge.isRest()&ℜlet Oe=!1;if(a.maintain_stem_directions&&we&&!ge.isRest()&&!we.isRest()){const Ue=we.getStemDirection();Oe=ge.getStemDirection()!==Ue}const ke=parseInt(ge.duration,10)<8;Ne||De||Oe||ke?(pe.length>0&&le.push(pe),pe=Oe?[ge]:[]):pe.push(ge)}),pe.length>0&&le.push(pe)}),V=le}(),V.forEach(le=>{let he;if(a.maintain_stem_directions){const pe=function(ge){for(let me=0;me{me.setStemDirection(ge)})})(le,he)});const Z=V.filter(le=>{if(le.length>1){let he=!0;return le.forEach(pe=>{pe.getIntrinsicTicks()>=m.durationToTicks("4")&&(he=!1)}),he}return!1}),re=function(){const le=[];return V.forEach(he=>{let pe=null;he.forEach(ge=>{ge.tuplet&&pe!==ge.tuplet&&(pe=ge.tuplet,le.push(pe))})}),le}(),ae=[];return Z.forEach(le=>{const he=new B(le);a.show_stemlets&&(he.render_options.show_stemlets=!0),a.secondary_breaks&&(he.render_options.secondary_break_ticks=m.durationToTicks(a.secondary_breaks)),a.flat_beams===!0&&(he.render_options.flat_beams=!0,he.render_options.flat_beam_offset=a.flat_beam_offset),ae.push(he)}),re.forEach(le=>{const he=le.notes[0].stem_direction===L.DOWN?I.LOCATION_BOTTOM:I.LOCATION_TOP;le.setTupletLocation(he);let pe=!1;for(let ge=0;ge=m.durationToTicks("4"))throw new l.RuntimeError("BadArguments","Beams can only be applied to notes shorter than a quarter note.");let b,w;for(this.stem_direction=L.UP,b=0;bz+J.stem_direction,0)>-1?L.UP:L.DOWN),b=0;be.getGlyph().beam_count).reduce((e,a)=>a>e?a:e)}breakSecondaryAt(e){return this.break_on_indices=e,this}getSlopeY(e,a,b,w){return b+(e-a)*w}calculateSlope(){const{notes:e,stem_direction:a,render_options:{max_slope:b,min_slope:w,slope_iterations:C,slope_cost:V}}=this,z=e[0],J=((he,pe)=>{const ge=he.getStemExtents().topY,me=he.getStemX();return(pe.getStemExtents().topY-ge)/(pe.getStemX()-me)})(z,e[e.length-1]),Z=(b-w)/C;let re=Number.MAX_VALUE,ae=0,le=0;for(let he=w;he<=b;he+=Z){let pe=0,ge=0;for(let Re=1;Rege)&&(Z=ge,z=Math.min(...pe.getYs()),J=pe.getBeamCount())}let re=V/e.length;const ae=w+J*(1.5*b),le=z+ae*-a;a===L.DOWN&&rele&&(re=z-ae),C+this.render_options.flat_beam_offset_per_beam>0?(a===L.DOWN&&re>C&&!this.render_options.flat_beams||a===L.UP&&re0){let a=this.render_options.flat_beam_offset;this.render_options.flat_beam_offset_per_beam&&(a+=this.render_options.flat_beam_offset_per_beam*this.getBeamCount());let b=this.notes[0].note_heads[0].y;const w=this.stem_direction>0?Math.min:Math.max;for(const C of this.notes)for(const V of C.note_heads)b=w(b,V.y);e=b+a*-this.stem_direction}return e}applyStemExtensions(){const{notes:e,slope:a,y_shift:b,stem_direction:w,beam_count:C,render_options:{show_stemlets:V,stemlet_extension:z,beam_width:J}}=this,Z=e[0],re=this.getBeamYToDraw(),ae=Z.getStemX();for(let le=0;le=8&&(le=this.break_on_indices.indexOf(re)!==-1,this.render_options.secondary_break_ticks&&J>=this.render_options.secondary_break_ticks&&(J=0,le=!0));const he=ae.getIntrinsicTicks(){e.getStem()&&(this.context.openGroup("stem",e.getAttribute("id")+"-stem"),e.getStem().setContext(this.context).draw(),this.context.closeGroup())},this)}drawBeamLines(){this.checkContext();const e=["4","8","16","32","64"],a=this.notes[0];let b=this.getBeamYToDraw();const w=a.getStemX(),C=this.render_options.beam_width*this.stem_direction,V={};for(const z of this.notes)V[z.getAttribute("id")]=0;for(let z=0;z{e.getStave()||e.setStave(this.stave)}),this.preFormatted=!0),this}draw(e=this.context,a=this.stave){this.setRendered();let b=null;for(let w=0;w0&&b){const V=C.getBoundingBox();V&&b.mergeWith(V)}C.setContext(e),C.drawWithStyle()}this.boundingBox=b}}function _(ce,e,a,b,w){if(e!==F.type.BOLD_DOUBLE_LEFT&&e!==F.type.BOLD_DOUBLE_RIGHT)throw new l.RERR("InvalidConnector","A REPEAT_BEGIN or REPEAT_END type must be provided.");let C=3,V=3.5;e===F.type.BOLD_DOUBLE_RIGHT&&(C=-5,V=3),ce.fillRect(a+C,b,1,w-b),ce.fillRect(a-2,b,V,w-b)}class F extends o{static get type(){return{SINGLE_RIGHT:0,SINGLE_LEFT:1,SINGLE:1,DOUBLE:2,BRACE:3,BRACKET:4,BOLD_DOUBLE_LEFT:5,BOLD_DOUBLE_RIGHT:6,THIN_DOUBLE:7,NONE:8}}static get typeString(){return{singleRight:F.type.SINGLE_RIGHT,singleLeft:F.type.SINGLE_LEFT,single:F.type.SINGLE,double:F.type.DOUBLE,brace:F.type.BRACE,bracket:F.type.BRACKET,boldDoubleLeft:F.type.BOLD_DOUBLE_LEFT,boldDoubleRight:F.type.BOLD_DOUBLE_RIGHT,thinDouble:F.type.THIN_DOUBLE,none:F.type.NONE}}constructor(e,a){super(),this.setAttribute("type","StaveConnector"),this.thickness=m.STAVE_LINE_THICKNESS,this.width=3,this.top_stave=e,this.bottom_stave=a,this.type=F.type.DOUBLE,this.font={family:"times",size:16,weight:"normal"},this.x_shift=0,this.texts=[]}setType(e){return(e=typeof e=="string"?F.typeString[e]:e)>=F.type.SINGLE_RIGHT&&e<=F.type.NONE&&(this.type=e),this}setText(e,a){return this.texts.push({content:e,options:l.Merge({shift_x:0,shift_y:0},a)}),this}setFont(e){l.Merge(this.font,e)}setXShift(e){if(typeof e!="number")throw l.RERR("InvalidType","x_shift must be a Number");return this.x_shift=e,this}draw(){const e=this.checkContext();this.setRendered();let a=this.top_stave.getYForLine(0),b=this.bottom_stave.getYForLine(this.bottom_stave.getNumLines()-1)+this.thickness,w=this.width,C=this.top_stave.getX();(this.type===F.type.SINGLE_RIGHT||this.type===F.type.BOLD_DOUBLE_RIGHT||this.type===F.type.THIN_DOUBLE)&&(C=this.top_stave.getX()+this.top_stave.width);let V=b-a;switch(this.type){case F.type.SINGLE:case F.type.SINGLE_LEFT:case F.type.SINGLE_RIGHT:w=1;break;case F.type.DOUBLE:C-=this.width+2;break;case F.type.BRACE:{w=12;const z=this.top_stave.getX()-2+this.x_shift,J=a,Z=z,re=b,ae=z-w,le=J+V/2,he=ae-.9*w,pe=J+.2*V,ge=z+1.1*w,me=le-.135*V,Ee=ge,Re=le+.135*V,we=he,Ne=re-.2*V,De=ae-w,Oe=Ne,ke=z+.4*w,Ue=le+.135*V,Ge=ke,nt=le-.135*V,Qe=De,$e=pe;e.beginPath(),e.moveTo(z,J),e.bezierCurveTo(he,pe,ge,me,ae,le),e.bezierCurveTo(Ee,Re,we,Ne,Z,re),e.bezierCurveTo(De,Oe,ke,Ue,ae,le),e.bezierCurveTo(Ge,nt,Qe,$e,z,J),e.fill(),e.stroke();break}case F.type.BRACKET:a-=4,b+=4,V=b-a,p.renderGlyph(e,C-5,a-3,40,"v1b",!0),p.renderGlyph(e,C-5,b+3,40,"v10",!0),C-=this.width+2;break;case F.type.BOLD_DOUBLE_LEFT:_(e,this.type,C+this.x_shift,a,b);break;case F.type.BOLD_DOUBLE_RIGHT:_(e,this.type,C,a,b);break;case F.type.THIN_DOUBLE:w=1;break;case F.type.NONE:break;default:throw new l.RERR("InvalidType",`The provided StaveConnector.type (${this.type}) is invalid`)}this.type!==F.type.BRACE&&this.type!==F.type.BOLD_DOUBLE_LEFT&&this.type!==F.type.BOLD_DOUBLE_RIGHT&&this.type!==F.type.NONE&&e.fillRect(C,a,w,V),this.type===F.type.THIN_DOUBLE&&e.fillRect(C-3,a,w,V),e.save(),e.lineWidth=2,e.setFont(this.font.family,this.font.size,this.font.weight);for(let z=0;z0){const me=ge.space.deviation,Ee=me>=0?"+":"";e.setFillStyle("red"),e.fillText(Ee+Math.round(me),z+a.getXShift(),b-10)}e.restore()}constructor(e){if(super(),this.setAttribute("type","Note"),!e)throw new l.RuntimeError("BadArguments","Note must have valid initialization data to identify duration and type.");const a=m.parseNoteStruct(e);if(!a)throw new l.RuntimeError("BadArguments",`Invalid note initialization object: ${JSON.stringify(e)}`);if(this.duration=a.duration,this.dots=a.dots,this.noteType=a.type,this.customTypes=a.customTypes,e.duration_override?this.setDuration(e.duration_override):this.setIntrinsicTicks(a.ticks),this.modifiers=[],this.glyph=m.getGlyphProps(this.duration,this.noteType),this.customGlyphs=this.customTypes.map(b=>m.getGlyphProps(this.duration,b)),this.positions&&(typeof this.positions!="object"||!this.positions.length))throw new l.RuntimeError("BadArguments","Note keys must be array type.");this.playNote=null,this.tickContext=null,this.modifierContext=null,this.ignore_ticks=!1,this.width=0,this.extraLeftPx=0,this.extraRightPx=0,this.x_shift=0,this.left_modPx=0,this.right_modPx=0,this.voice=null,this.preFormatted=!1,this.ys=[],e.align_center&&this.setCenterAlignment(e.align_center),this.stave=null,this.render_options={annotation_spacing:5,stave_padding:j.STAVEPADDING}}getPlayNote(){return this.playNote}setPlayNote(e){return this.playNote=e,this}isRest(){return!1}addStroke(e,a){return a.setNote(this),a.setIndex(e),this.modifiers.push(a),this.setPreFormatted(!1),this}getStave(){return this.stave}setStave(e){return this.stave=e,this.setYs([e.getYForLine(0)]),this.context=this.stave.context,this}getCategory(){return j.CATEGORY}setContext(e){return this.context=e,this}getExtraLeftPx(){return this.extraLeftPx}getExtraRightPx(){return this.extraRightPx}setExtraLeftPx(e){return this.extraLeftPx=e,this}setExtraRightPx(e){return this.extraRightPx=e,this}shouldIgnoreTicks(){return this.ignore_ticks}getLineNumber(){return 0}getLineForRest(){return 0}getGlyph(){return this.glyph}getGlyphWidth(){return this.glyph.getWidth(this.render_options.glyph_font_scale)}setYs(e){return this.ys=e,this}getYs(){if(this.ys.length===0)throw new l.RERR("NoYValues","No Y-values calculated for this note.");return this.ys}getYForTopText(e){if(!this.stave)throw new l.RERR("NoStave","No stave attached to this note.");return this.stave.getYForTopText(e)}getBoundingBox(){return null}getVoice(){if(!this.voice)throw new l.RERR("NoVoice","Note has no voice.");return this.voice}setVoice(e){return this.voice=e,this.preFormatted=!1,this}getTickContext(){return this.tickContext}setTickContext(e){return this.tickContext=e,this.preFormatted=!1,this}getDuration(){return this.duration}isDotted(){return this.dots>0}hasStem(){return!1}getDots(){return this.dots}getNoteType(){return this.noteType}setBeam(){return this}setModifierContext(e){return this.modifierContext=e,this}addModifier(e,a=0){return e.setNote(this),e.setIndex(a),this.modifiers.push(e),this.setPreFormatted(!1),this}getModifierStartXY(){if(!this.preFormatted)throw new l.RERR("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");return{x:this.getAbsoluteX(),y:this.ys[0]}}getMetrics(){if(!this.preFormatted)throw new l.RERR("UnformattedNote","Can't call getMetrics on an unformatted note.");let e=0,a=0;this.modifierContext!=null&&(e=this.modifierContext.state.left_shift,a=this.modifierContext.state.right_shift);const b=this.getWidth();return{width:b,noteWidth:b-e-a-this.extraLeftPx-this.extraRightPx,left_shift:this.x_shift,modLeftPx:e,modRightPx:a,extraLeftPx:this.extraLeftPx,extraRightPx:this.extraRightPx}}setWidth(e){this.width=e}getWidth(){if(!this.preFormatted)throw new l.RERR("UnformattedNote","Can't call GetWidth on an unformatted note.");return this.width+(this.modifierContext?this.modifierContext.getWidth():0)}setXShift(e){return this.x_shift=e,this}getXShift(){return this.x_shift}getX(){if(!this.tickContext)throw new l.RERR("NoTickContext","Note needs a TickContext assigned for an X-Value");return this.tickContext.getX()+this.x_shift}getAbsoluteX(){if(!this.tickContext)throw new l.RERR("NoTickContext","Note needs a TickContext assigned for an X-Value");let e=this.tickContext.getX();return this.stave&&(e+=this.stave.getNoteStartX()+this.render_options.stave_padding),this.isCenterAligned()&&(e+=this.getCenterXShift()),e}setPreFormatted(e){if(this.preFormatted=e,this.preFormatted){const a=this.tickContext.getExtraPx();this.left_modPx=Math.max(this.left_modPx,a.left),this.right_modPx=Math.max(this.right_modPx,a.right)}}}class P extends j{static get CATEGORY(){return"notehead"}constructor(e){if(super(e),this.setAttribute("type","NoteHead"),this.index=e.index,this.x_shift=e.x_shift||0,this.x=(e.x||0)+this.x_shift,this.y=e.y||0,this.note_type=e.note_type,this.duration=e.duration,this.displaced=e.displaced||!1,this.stem_direction=e.stem_direction||oe.STEM_UP,this.line=e.line,this.glyph=m.getGlyphProps(this.duration,this.note_type),!this.glyph)throw new l.RuntimeError("BadArguments",`No glyph found for duration '${this.duration}' and type '${this.note_type}'`);this.glyph_code=this.glyph.code_head,this.x_shift_ledger_rest=0,this.y_shift_ledger_rest=0,this.x_shift=e.x_shift||0,this.glyph.rest&&(this.line>5||this.line<0)&&(this.isLedgerLinedRest=!0,this.duration==="h"?(e.custom_glyph_code="rhl",this.x_shift_ledger_rest-=4):this.duration==="w"&&(e.custom_glyph_code="rwl",this.x_shift_ledger_rest-=4,this.y_shift_ledger_rest=-5)),e.custom_glyph_code&&(this.custom_glyph=!0,this.glyph_code=e.custom_glyph_code,this.stem_up_x_offset=e.stem_up_x_offset||0,this.stem_down_x_offset=e.stem_down_x_offset||0,this.stem_up_y_shift=e.stem_up_y_shift||0,this.stem_down_y_shift=e.stem_down_y_shift||0),this.style=e.style,this.slashed=e.slashed,l.Merge(this.render_options,{glyph_font_scale:e.glyph_font_scale||m.DEFAULT_NOTATION_FONT_SCALE,stroke_px:3}),this.setWidth(this.glyph.getWidth(this.render_options.glyph_font_scale))}getCategory(){return P.CATEGORY}getWidth(){return this.width}isDisplaced(){return this.displaced===!0}getGlyph(){return this.glyph}setX(e){return this.x=e,this}getY(){return this.y}setY(e){return this.y=e,this}getLine(){return this.line}setLine(e){return this.line=e,this}getAbsoluteX(){const e=this.preFormatted?super.getAbsoluteX():this.x,a=L.WIDTH/2;return e+(this.displaced?(this.width-a)*this.stem_direction:0)}getBoundingBox(){if(!this.preFormatted)throw new l.RERR("UnformattedNote","Can't call getBoundingBox on an unformatted note.");const e=this.stave.getSpacingBetweenLines(),a=e/2,b=this.y-a;return new m.BoundingBox(this.getAbsoluteX(),b,this.width,e)}setStave(e){const a=this.getLine();return this.stave=e,this.setY(e.getYForNote(a)),this.context=this.stave.context,this}preFormat(){if(this.preFormatted)return this;const e=this.getWidth()+this.extraLeftPx+this.extraRightPx;return this.setWidth(e),this.setPreFormatted(!0),this}draw(){this.checkContext(),this.setRendered();const e=this.context;let a=this.getAbsoluteX(),b=this.y;this.custom_glyph&&(a+=this.x_shift_ledger_rest,this.stem_direction===L.UP?(a+=this.stem_up_x_offset,b+=this.stem_up_y_shift||0):this.stem_direction===L.DOWN&&(a+=this.stem_down_x_offset,b+=this.stem_down_y_shift||0),b+=this.y_shift_ledger_rest),function(...V){P.DEBUG&&l.L("Vex.Flow.NoteHead",V)}("Drawing note head '",this.note_type,this.duration,"' at",a,b);const w=this.stem_direction,C=this.render_options.glyph_font_scale;if(this.style&&this.applyStyle(e),this.note_type==="s"){const V=this.stave.getSpacingBetweenLines();(function(z,J,Z,re,ae,le){const he=m.SLASH_NOTEHEAD_WIDTH;z.save(),z.setLineWidth(m.STEM_WIDTH);let pe=!1;if(m.durationToNumber(J)>2&&(pe=!0),pe||(Z-=m.STEM_WIDTH/2*ae),z.beginPath(),z.moveTo(Z,re+le),z.lineTo(Z,re+1),z.lineTo(Z+he,re-le),z.lineTo(Z+he,re),z.lineTo(Z,re+le),z.closePath(),pe?z.fill():z.stroke(),m.durationToFraction(J).equals(.5)){const ge=[-3,-1,he+1,he+3];for(let me=0;me{const z=V.getTickContext();V.setStave(a.stave),z.setXOffset(C)})}}class X extends Y{static get CATEGORY(){return"dots"}static format(e,a){const b=a.right_shift;if(!e||e.length===0)return!1;const w=[],C={};for(let le=0;lehe.line-le.line);let V=b,z=0,J=null,Z=null,re=null,ae=0;for(let le=0;lez?V:z,J=me,Z=pe}return a.right_shift+=z,!0}constructor(){super(),this.setAttribute("type","Dot"),this.note=null,this.index=null,this.position=Y.Position.RIGHT,this.radius=2,this.setWidth(5),this.dot_shiftY=0}getCategory(){return X.CATEGORY}setNote(e){this.note=e,this.note.getCategory()==="gracenotes"&&(this.radius*=.5,this.setWidth(3))}setDotShiftY(e){return this.dot_shiftY=e,this}draw(){if(this.checkContext(),this.setRendered(),!this.note||this.index===null)throw new l.RERR("NoAttachedNote","Can't draw dot without a note and index.");const e=this.note.stave.options.spacing_between_lines_px,a=this.note.getModifierStartXY(this.position,this.index,{forceFlagRight:!0});this.note.getCategory()==="tabnotes"&&(a.y=this.note.getStemExtents().baseY);const b=a.x+this.x_shift+this.width-this.radius,w=a.y+this.y_shift+this.dot_shiftY*e,C=this.context;C.beginPath(),C.arc(b,w,this.radius,0,2*Math.PI,!1),C.fill()}}function ie(ce,e,a){if(ce.note.shiftRestVerticalDisabled)return;const b=(e.isrest?0:1)*a;ce.line+=b,ce.maxLine+=b,ce.minLine+=b,ce.note.setKeyLine(0,ce.note.getKeyLine(0)+b)}class oe extends G{static get CATEGORY(){return"stavenotes"}static get STEM_UP(){return L.UP}static get STEM_DOWN(){return L.DOWN}static get DEFAULT_LEDGER_LINE_OFFSET(){return 3}static format(e,a){if(!e||e.length<2)return!1;const b=[],w=e[0].stagger_same_whole_notes;for(let le=0;le2?b[1]:null;let J=C>2?b[2]:b[1];C!==2||V.stemDirection!==-1||J.stemDirection!==1||V.isrest||J.isRest||(V=b[1],J=b[0]);const Z=Math.max(V.voice_shift,J.voice_shift);let re,ae=0;if(C===2){const le=V.stemDirection===J.stemDirection?0:.5;if(V.stemDirection===J.stemDirection&&V.minLine<=J.maxLine&&(V.isrest||(re=Math.abs(V.line-(J.maxLine+.5)),re=Math.max(re,V.stemMin),V.minLine=V.line-re,V.note.setStemLength(10*re))),V.minLine<=J.maxLine+le)if(V.isrest)ie(V,J,1),V.note.hasLedgerLinedRest&&(V.note.shiftRestVerticalDisabled=!0);else if(J.isrest)ie(J,V,-1),J.note.hasLedgerLinedRest&&(J.note.shiftRestVerticalDisabled=!0);else{ae=Z;const he=Math.abs(V.line-J.line);let pe=0,ge=0;V.note.duration==="h"?pe++:V.note.duration==="w"&&ge++,J.note.duration==="h"?pe++:J.note.duration==="w"&&ge++;let me=pe===1||ge===1||V.note.dots!==J.note.dots;if(w&&(me||(me=ge===2)),he===0&&me){if(J.note.setXShift(ae),V.note.dots>0){let Ee=0;for(const Re of V.note.modifiers)if(Re instanceof X&&(Ee++,Re.setYShift(-10*(J.maxLine-V.line+1)),Ee===V.note.dots))break}}else he<1&&he>0?J.note.setXShift(ae):V.note.voice!==J.note.voice&&V.stemDirection===J.stemDirection&&(V.line>J.line?V.stemDirection===1?J.note.renderFlag=!1:V.note.renderFlag=!1:J.line>V.line?J.stemDirection===1?V.note.renderFlag=!1:J.note.renderFlag=!1:J.stemDirection===1&&(J.stemDirection=-1,J.note.setStemDirection(-1)))}return!0}return z!==null&&z.minLinea.postFormat()),!0)}constructor(e){if(super(e),this.setAttribute("type","StaveNote"),this.keys=e.keys,this.clef=e.clef,this.octave_shift=e.octave_shift,this.beam=null,this.glyph=m.getGlyphProps(this.duration,this.noteType),!this.glyph)throw new l.RuntimeError("BadArguments",`Invalid note initialization data (No glyph found): ${JSON.stringify(e)}`);this.displaced=!1,this.dot_shiftY=0,this.addDotsCount=0,this.keyProps=[],this.use_default_head_x=!1,this.paddingRight=0,this.note_heads=[],this.modifiers=[],l.Merge(this.render_options,{glyph_font_scale:e.glyph_font_scale||m.DEFAULT_NOTATION_FONT_SCALE,stroke_px:e.stroke_px||oe.DEFAULT_LEDGER_LINE_OFFSET}),this.calculateKeyProps(),this.buildStem(),e.auto_stem?this.autoStem():this.setStemDirection(e.stem_direction),this.reset(),this.buildFlag()}reset(){super.reset();const e=this.note_heads.map(b=>b.getStyle()),a=[];this.note_heads.forEach(b=>a.push(b.note_type)),this.buildNoteHeads(),this.note_heads.forEach((b,w)=>{b.setStyle(e[w]),a[w]&&(b.note_type=a[w])}),this.stave&&this.note_heads.forEach(b=>b.setStave(this.stave)),this.calcExtraPx()}setBeam(e){return this.beam=e,this.calcExtraPx(),this}getCategory(){return oe.CATEGORY}buildStem(){this.setStem(new L({hide:!!this.isRest()})),this.stem.id=l.Prefix(`${this.getAttribute("id")}-stem`)}buildNoteHeads(){this.note_heads=[];const e=this.getStemDirection(),a=this.getKeys();let b,w,C,V=null,z=null,J=!1;e===L.UP?(b=0,w=a.length,C=1):e===L.DOWN&&(b=a.length-1,w=-1,C=-1);for(let Z=b;Z!==w;Z+=C){const re=this.keyProps[Z],ae=re.line;V===null?V=ae:(z=Math.abs(V-ae),z===0||z===.5?J=!J:(J=!1,this.use_default_head_x=!0)),V=ae;const le=new P({duration:this.duration,note_type:this.noteType,displaced:J,stem_direction:e,custom_glyph_code:re.code,glyph_font_scale:this.render_options.glyph_font_scale,x_shift:re.shift_right,stem_up_x_offset:re.stem_up_x_offset,stem_down_x_offset:re.stem_down_x_offset,stem_up_y_shift:re.stem_up_y_shift,stem_down_y_shift:re.stem_down_y_shift,line:re.line});le.isLedgerLinedRest&&(this.hasLedgerLinedRest=!0),le.id=this.stem.id=l.Prefix(`${this.getAttribute("id")}-stem${Z}`),this.note_heads[Z]=le}}autoStem(){this.minLine=this.keyProps[0].line,this.maxLine=this.keyProps[this.keyProps.length-1].line;const e=(this.minLine+this.maxLine)/2<3?L.UP:L.DOWN;this.setStemDirection(e)}calculateKeyProps(){let e=null;for(let a=0;a0&&(this.keyProps[a-1].displaced=!0)),e=V,this.keyProps.push(C)}e=-1/0,this.keyProps.forEach(a=>{a.linea.line-b.line)}getBoundingBox(){if(!this.preFormatted)throw new l.RERR("UnformattedNote","Can't call getBoundingBox on an unformatted note.");const{width:e,modLeftPx:a,extraLeftPx:b}=this.getMetrics(),w=this.getAbsoluteX()-a-b-this.paddingRight;let C=0,V=0;const z=this.getStave().getSpacingBetweenLines()/2,J=2*z;if(this.isRest()){const Z=this.ys[0],re=m.durationToFraction(this.duration);re.equals(1)||re.equals(2)?(C=Z-z,V=Z+z):(C=Z-this.glyph.line_above*J,V=Z+this.glyph.line_below*J)}else if(this.glyph.stem){const Z=this.getStemExtents();Z.baseY+=z*this.stem_direction,C=Math.min(Z.topY,Z.baseY),V=Math.max(Z.topY,Z.baseY)}else{C=null,V=null;for(let Z=0;Za&&(a=w):w1}hasStem(){return this.glyph.stem}hasFlag(){return super.hasFlag()&&!this.isRest()&&this.renderFlag}getStemX(){return this.noteType==="r"?this.getCenterGlyphX():super.getStemX()+L.WIDTH/(2*-this.getStemDirection())}getYForTopText(e){const a=this.getStemExtents();return Math.min(this.stave.getYForTopText(e),a.topY-this.render_options.annotation_spacing*(e+1))}getYForBottomText(e){const a=this.getStemExtents();return Math.max(this.stave.getYForTopText(e),a.baseY+this.render_options.annotation_spacing*e)}setStave(e){super.setStave(e);const a=this.note_heads.map(b=>(b.setStave(e),b.getY()));if(this.setYs(a),this.stem){const{y_top:b,y_bottom:w}=this.getNoteHeadBounds();this.stem.setYBounds(b,w)}return this}getKeys(){return this.keys}getKeyProps(){return this.keyProps}isDisplaced(){return this.displaced}setNoteDisplaced(e){return this.displaced=e,this}getTieRightX(){let e=this.getAbsoluteX();return e+=this.getGlyphWidth()+this.x_shift+this.extraRightPx,this.modifierContext&&(e+=this.modifierContext.getExtraRightPx()),e}getTieLeftX(){let e=this.getAbsoluteX();return e+=this.x_shift-this.extraLeftPx,e}getLineForRest(){let e=this.keyProps[0].line;if(this.keyProps.length>1){const a=this.keyProps[this.keyProps.length-1].line,b=Math.max(e,a),w=Math.min(e,a);e=l.MidLine(b,w)}return e}getModifierStartXY(e,a,b){if(b=b||{},!this.preFormatted)throw new l.RERR("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");if(this.ys.length===0)throw new l.RERR("NoYValues","No Y-Values calculated for this note.");const{ABOVE:w,BELOW:C,LEFT:V,RIGHT:z}=Y.Position;let J=0;return e===V?J=-2:e===z?(J=this.getGlyphWidth()+this.x_shift+2,this.stem_direction===L.UP&&this.hasFlag()&&(b.forceFlagRight||((Z,re)=>re===(Z.getStemDirection()===L.UP?Z.keyProps.length-1:0))(this,a))&&(J+=this.flag.getMetrics().width)):e!==C&&e!==w||(J=this.getGlyphWidth()/2),{x:this.getAbsoluteX()+J,y:this.ys[a]}}setStyle(e){super.setStyle(e),this.note_heads.forEach(a=>a.setStyle(e)),this.stem&&this.stem.setStyle(e)}setStemStyle(e){this.stem&&this.getStem().setStyle(e)}getStemStyle(){return this.stem.getStyle()}setLedgerLineStyle(e){this.ledgerLineStyle=e}getLedgerLineStyle(){return this.ledgerLineStyle}setFlagStyle(e){this.flagStyle=e}getFlagStyle(){return this.flagStyle}setKeyStyle(e,a){return this.note_heads[e].setStyle(a),this}setKeyLine(e,a){return this.keyProps[e].line=a,this.reset(),this}getKeyLine(e){return this.keyProps[e].line}addToModifierContext(e){this.setModifierContext(e);for(let a=0;a{const le=ae.getLine(),he=ae.getY();(e===null||hea)&&(a=he),w===null&&ae.isDisplaced()&&(w=ae.getAbsoluteX()),b!==null||ae.isDisplaced()||(b=ae.getAbsoluteX()),C=le>C?le:C,V=le{let Oe;Oe=De&&Ne?ge-b:Ne?pe-b:he-b;const ke=Ne&&De?V:C;w.beginPath(),w.moveTo(Oe,we),w.lineTo(Oe+ke,we),w.stroke()},Ee={...e.getStyle()||{},...this.getLedgerLineStyle()||{}};this.applyStyle(w,Ee);const Re=z>=6||J<=0;Re&&w.openGroup("ledgers",this.getAttribute("id")+"ledgers");for(let we=6;we<=z;++we){const Ne=pe!==null&&we<=re,De=he!==null&&we<=Z;me(e.getYForNote(we),Ne,De)}for(let we=0;we>=J;--we){const Ne=pe!==null&&we>=le,De=he!==null&&we>=ae;me(e.getYForNote(we),Ne,De)}Re&&w.closeGroup(),this.restoreStyle(w,Ee)}drawModifiers(){if(!this.context)throw new l.RERR("NoCanvasContext","Can't draw without a canvas context.");const e=this.context;e.openGroup("modifiers");for(let a=0;a{this.context.openGroup("notehead",null,{pointerBBox:!0}),e.setContext(this.context).draw(),this.context.closeGroup()})}drawStem(e){if(!this.context)throw new l.RERR("NoCanvasContext","Can't draw without a canvas context.");e&&this.setStem(new L(e)),this.stem.id=l.Prefix(`${this.getAttribute("id")}-stem`),this.stem&&(this.context.openGroup("stem",null,{pointerBBox:!0}),this.stem.setContext(this.context).draw(),this.context.closeGroup())}draw(){if(!this.context)throw new l.RERR("NoCanvasContext","Can't draw without a canvas context.");if(!this.stave)throw new l.RERR("NoStave","Can't draw without a stave.");if(this.ys.length===0)throw new l.RERR("NoYValues","Can't draw note without Y values.");const e=this.getNoteHeadBeginX(),a=this.hasStem()&&!this.beam;if(this.note_heads.forEach(b=>b.setX(e)),this.stem){const b=this.getStemX();this.stem.setNoteHeadXBounds(b,b)}(function(...b){oe.DEBUG&&l.L("Vex.Flow.StaveNote",b)})("Rendering ",this.isChord()?"chord :":"note :",this.keys),this.drawLedgerLines(),this.applyStyle(),this.setAttribute("el",this.context.openGroup("stavenote",this.getAttribute("id"))),this.context.openGroup("note",null,{pointerBBox:!0}),a&&this.drawStem(),this.drawNoteHeads(),this.drawFlag(),this.context.closeGroup(),this.drawModifiers(),this.context.closeGroup(),this.restoreStyle(),this.setRendered()}}class $ extends Y{static get CATEGORY(){return"frethandfinger"}static format(e,a){const{left_shift:b,right_shift:w}=a;if(!e||e.length===0)return!1;const C=[];let V=null,z=0,J=0;for(let ge=0;geme.line-ge.line);let Z=0,re=0,ae=0,le=0,he=null,pe=null;for(let ge=0;geae?me:ae):Re===Y.Position.RIGHT&&(we.setXShift(re),me=J+ke,le=me>le?me:le),he=Ne,pe=Ee}return a.left_shift+=ae,a.right_shift+=le,!0}constructor(e){super(),this.setAttribute("type","FretHandFinger"),this.note=null,this.index=null,this.finger=e,this.width=7,this.position=Y.Position.LEFT,this.x_shift=0,this.y_shift=0,this.x_offset=0,this.y_offset=0,this.font={family:"sans-serif",size:9,weight:"bold"}}getCategory(){return $.CATEGORY}setFretHandFinger(e){return this.finger=e,this}setOffsetX(e){return this.x_offset=e,this}setOffsetY(e){return this.y_offset=e,this}draw(){if(this.checkContext(),!this.note||this.index==null)throw new l.RERR("NoAttachedNote","Can't draw string number without a note and index.");this.setRendered();const e=this.context,a=this.note.getModifierStartXY(this.position,this.index);let b=a.x+this.x_shift+this.x_offset,w=a.y+this.y_shift+this.y_offset+5;switch(this.position){case Y.Position.ABOVE:b-=4,w-=12;break;case Y.Position.BELOW:b-=2,w+=10;break;case Y.Position.LEFT:b-=this.width;break;case Y.Position.RIGHT:b+=1;break;default:throw new l.RERR("InvalidPostion",`The position ${this.position} does not exist`)}e.save(),e.setFont(this.font.family,this.font.size,this.font.weight),e.fillText(""+this.finger,b,w),e.restore()}}class Q{static get NUM_TONES(){return 12}static get roots(){return["c","d","e","f","g","a","b"]}static get root_values(){return[0,2,4,5,7,9,11]}static get root_indices(){return{c:0,d:1,e:2,f:3,g:4,a:5,b:6}}static get canonical_notes(){return["c","c#","d","d#","e","f","f#","g","g#","a","a#","b"]}static get diatonic_intervals(){return["unison","m2","M2","m3","M3","p4","dim5","p5","m6","M6","b7","M7","octave"]}static get diatonic_accidentals(){return{unison:{note:0,accidental:0},m2:{note:1,accidental:-1},M2:{note:1,accidental:0},m3:{note:2,accidental:-1},M3:{note:2,accidental:0},p4:{note:3,accidental:0},dim5:{note:4,accidental:-1},p5:{note:4,accidental:0},m6:{note:5,accidental:-1},M6:{note:5,accidental:0},b7:{note:6,accidental:-1},M7:{note:6,accidental:0},octave:{note:7,accidental:0}}}static get intervals(){return{u:0,unison:0,m2:1,b2:1,min2:1,S:1,H:1,2:2,M2:2,maj2:2,T:2,W:2,m3:3,b3:3,min3:3,M3:4,3:4,maj3:4,4:5,p4:5,"#4":6,b5:6,aug4:6,dim5:6,5:7,p5:7,"#5":8,b6:8,aug5:8,6:9,M6:9,maj6:9,b7:10,m7:10,min7:10,dom7:10,M7:11,maj7:11,8:12,octave:12}}static get scales(){return{major:[2,2,1,2,2,2,1],dorian:[2,1,2,2,2,1,2],mixolydian:[2,2,1,2,2,1,2],minor:[2,1,2,2,1,2,2]}}static get scaleTypes(){return{M:Q.scales.major,m:Q.scales.minor}}static get accidentals(){return["bb","b","n","#","##"]}static get noteValues(){return{c:{root_index:0,int_val:0},cn:{root_index:0,int_val:0},"c#":{root_index:0,int_val:1},"c##":{root_index:0,int_val:2},cb:{root_index:0,int_val:11},cbb:{root_index:0,int_val:10},d:{root_index:1,int_val:2},dn:{root_index:1,int_val:2},"d#":{root_index:1,int_val:3},"d##":{root_index:1,int_val:4},db:{root_index:1,int_val:1},dbb:{root_index:1,int_val:0},e:{root_index:2,int_val:4},en:{root_index:2,int_val:4},"e#":{root_index:2,int_val:5},"e##":{root_index:2,int_val:6},eb:{root_index:2,int_val:3},ebb:{root_index:2,int_val:2},f:{root_index:3,int_val:5},fn:{root_index:3,int_val:5},"f#":{root_index:3,int_val:6},"f##":{root_index:3,int_val:7},fb:{root_index:3,int_val:4},fbb:{root_index:3,int_val:3},g:{root_index:4,int_val:7},gn:{root_index:4,int_val:7},"g#":{root_index:4,int_val:8},"g##":{root_index:4,int_val:9},gb:{root_index:4,int_val:6},gbb:{root_index:4,int_val:5},a:{root_index:5,int_val:9},an:{root_index:5,int_val:9},"a#":{root_index:5,int_val:10},"a##":{root_index:5,int_val:11},ab:{root_index:5,int_val:8},abb:{root_index:5,int_val:7},b:{root_index:6,int_val:11},bn:{root_index:6,int_val:11},"b#":{root_index:6,int_val:0},"b##":{root_index:6,int_val:1},bb:{root_index:6,int_val:10},bbb:{root_index:6,int_val:9}}}isValidNoteValue(e){return!(e==null||e<0||e>=Q.NUM_TONES)}isValidIntervalValue(e){return this.isValidNoteValue(e)}getNoteParts(e){if(!e||e.length<1)throw new l.RERR("BadArguments","Invalid note name: "+e);if(e.length>3)throw new l.RERR("BadArguments","Invalid note name: "+e);const a=e.toLowerCase(),b=/^([cdefgab])(b|bb|n|#|##)?$/.exec(a);if(b!=null)return{root:b[1],accidental:b[2]};throw new l.RERR("BadArguments","Invalid note name: "+e)}getKeyParts(e){if(!e||e.length<1)throw new l.RERR("BadArguments","Invalid key: "+e);const a=e.toLowerCase(),b=/^([cdefgab])(b|#)?(mel|harm|m|M)?$/.exec(a);if(b!=null){const w=b[1],C=b[2];let V=b[3];return V||(V="M"),{root:w,accidental:C,type:V}}throw new l.RERR("BadArguments",`Invalid key: ${e}`)}getNoteValue(e){const a=Q.noteValues[e];if(a==null)throw new l.RERR("BadArguments",`Invalid note name: ${e}`);return a.int_val}getIntervalValue(e){const a=Q.intervals[e];if(a==null)throw new l.RERR("BadArguments",`Invalid interval name: ${e}`);return a}getCanonicalNoteName(e){if(!this.isValidNoteValue(e))throw new l.RERR("BadArguments",`Invalid note value: ${e}`);return Q.canonical_notes[e]}getCanonicalIntervalName(e){if(!this.isValidIntervalValue(e))throw new l.RERR("BadArguments",`Invalid interval value: ${e}`);return Q.diatonic_intervals[e]}getRelativeNoteValue(e,a,b){if(b==null&&(b=1),b!==1&&b!==-1)throw new l.RERR("BadArguments",`Invalid direction: ${b}`);let w=(e+b*a)%Q.NUM_TONES;return w<0&&(w+=Q.NUM_TONES),w}getRelativeNoteName(e,a){const b=this.getNoteParts(e),w=this.getNoteValue(b.root);let C=a-w;if(Math.abs(C)>Q.NUM_TONES-3){let z=1;C>0&&(z=-1);const J=(a+1+(w+1))%Q.NUM_TONES*z;if(Math.abs(J)>2)throw new l.RERR("BadArguments",`Notes not related: ${e}, ${a})`);C=J}if(Math.abs(C)>2)throw new l.RERR("BadArguments",`Notes not related: ${e}, ${a})`);let V=b.root;if(C>0)for(let z=1;z<=C;++z)V+="#";else if(C<0)for(let z=-1;z>=C;--z)V+="b";return V}getScaleTones(e,a){const b=[e];let w=e;for(let C=0;Cce.getMetrics().width;class N extends Y{static get CATEGORY(){return"accidentals"}static format(e,a){const b=a.left_shift+1;if(!e||e.length===0)return;const w=[];let C,V=null,z=0;for(let me=0;meEe.line-me.line);const J=[];let Z=0,re=null;for(let me=0;meZ?Ee.shift:Z,re=Ee.line}let ae=0;for(let me=0;meJ[Re+$e],De=$e=>$e.map(Ne),Oe=($e,ht)=>{const[ft,Rt]=De([$e,ht]).map(vt=>vt.line);return ft-Rt},ke=(...$e)=>$e.map(De).every(ht=>!this.checkCollision(...ht)),Ue=we-Re+1;let Ge,nt,Qe=this.checkCollision(J[Re],J[we])?"a":"b";switch(Ue){case 3:Qe==="a"&&Oe(1,2)===.5&&Oe(0,1)!==.5&&(Qe="second_on_bottom");break;case 4:ke([0,2],[1,3])&&(Qe="spaced_out_tetrachord");break;case 5:Qe==="b"&&ke([1,3])&&(Qe="spaced_out_pentachord",ke([0,2],[2,4])&&(Qe="very_spaced_out_pentachord"));break;case 6:ke([0,3],[1,4],[2,5])&&(Qe="spaced_out_hexachord"),ke([0,2],[2,4],[1,3],[3,5])&&(Qe="very_spaced_out_hexachord")}if(Ue>=7){let $e=2,ht=!0;for(;ht===!0;){ht=!1;for(let ft=0;ft+$ent?ae:nt}else for(Ge=me;Ge<=we;Ge++)nt=m.accidentalColumnsTable[Ue][Qe][Ge-me],J[Ge].column=nt,ae=ae>nt?ae:nt;me=we}const le=[],he=[];for(let me=0;me<=ae;me++)le[me]=0,he[me]=0;le[0]=Z+b,he[0]=Z+b,J.forEach(me=>{me.width>le[me.column]&&(le[me.column]=me.width)});for(let me=1;me{let Ee=0;const Re=ge+me.numAcc;for(;ge0?(w=a.flatLine||a.dblSharpLine?2.5:3,e.dblSharpLine&&(b-=.5)):(w=e.flatLine||e.dblSharpLine?2.5:3,a.dblSharpLine&&(b-=.5));const C=Math.abs(b){const J=new s(0,1);z.getTickables().forEach(Z=>{if(Z.shouldIgnoreTicks())return;const re=w[J.value()];re?re.push(Z):(b.push(J.value()),w[J.value()]=[Z]),J.add(Z.getTicks())})});const C=new Q;a||(a="C");const V=C.createScaleMap(a);b.forEach(z=>{const J=w[z],Z=[],re=ae=>{ae.isRest()||ae.shouldIgnoreTicks()||(ae.keys.forEach((le,he)=>{const pe=C.getNoteParts(le.split("/")[0]),ge=pe.accidental||"n",me=pe.root+ge,Ee=V[pe.root]===me,Re=Z.indexOf(me)>-1;if(!Ee||Ee&&Re){V[pe.root]=me;const we=new N(ge);ae.addAccidental(he,we),Z.push(me)}}),ae.getModifiers().forEach(le=>{le.getCategory()==="gracenotegroups"&&le.getGraceNotes().forEach(re)}))};J.forEach(re)})}constructor(e=null){if(super(),this.setAttribute("type","Accidental"),ne("New accidental: ",e),this.note=null,this.index=null,this.type=e,this.position=Y.Position.LEFT,this.render_options={font_scale:38,stroke_px:3,parenLeftPadding:2,parenRightPadding:2},this.accidental=m.accidentalCodes(this.type),!this.accidental)throw new l.RERR("ArgumentError",`Unknown accidental type: ${e}`);this.cautionary=!1,this.parenLeft=null,this.parenRight=null,this.reset()}reset(){const e=this.render_options.font_scale;this.glyph=new p(this.accidental.code,e),this.glyph.setOriginX(1),this.cautionary&&(this.parenLeft=new p(m.accidentalCodes("{").code,e),this.parenRight=new p(m.accidentalCodes("}").code,e),this.parenLeft.setOriginX(1),this.parenRight.setOriginX(1))}getCategory(){return N.CATEGORY}getWidth(){const e=this.cautionary?ee(this.parenLeft)+ee(this.parenRight)+this.render_options.parenLeftPadding+this.render_options.parenRightPadding:0;return ee(this.glyph)+e}setNote(e){if(!e)throw new l.RERR("ArgumentError",`Bad note value: ${e}`);this.note=e,this.note.getCategory()==="gracenotes"&&(this.render_options.font_scale=25,this.reset())}setAsCautionary(){return this.cautionary=!0,this.render_options.font_scale=28,this.reset(),this}draw(){const{context:e,type:a,position:b,note:w,index:C,cautionary:V,x_shift:z,y_shift:J,glyph:Z,parenLeft:re,parenRight:ae,render_options:{parenLeftPadding:le,parenRightPadding:he}}=this;if(this.checkContext(),!w||C==null)throw new l.RERR("NoAttachedNote","Can't draw accidental without a note and index.");const pe=w.getModifierStartXY(b,C);let ge=pe.x+z;const me=pe.y+J;ne("Rendering: ",a,ge,me),V?(ae.render(e,ge,me),ge-=ee(ae),ge-=he,ge-=this.accidental.parenRightPaddingAdjustment,Z.render(e,ge,me),ge-=ee(Z),ge-=le,re.render(e,ge,me)):Z.render(e,ge,me),this.setRendered()}}class R extends Y{static get CATEGORY(){return"notesubgroup"}static format(e,a){if(!e||e.length===0)return!1;let b=0;for(let w=0;w{a.ignore_ticks=!1}),this.width=0,this.preFormatted=!1,this.formatter=new Ce,this.voice=new D({num_beats:4,beat_value:4,resolution:m.RESOLUTION}).setStrict(!1),this.voice.addTickables(this.subNotes),this}getCategory(){return R.CATEGORY}preFormat(){this.preFormatted||(this.formatter.joinVoices([this.voice]).format([this.voice],0),this.setWidth(this.formatter.getMinTotalWidth()),this.preFormatted=!0)}setNote(e){this.note=e}setWidth(e){this.width=e}getWidth(){return this.width}draw(){this.checkContext();const e=this.getNote();if(!e||this.index===null)throw new l.RuntimeError("NoAttachedNote","Can't draw notes without a parent note and parent note index.");this.setRendered(),this.alignSubNotesWithNote(this.subNotes,e),this.subNotes.forEach(a=>a.setContext(this.context).drawWithStyle())}}class O extends o{constructor(e,a){super(),this.setAttribute("type","StaveTie"),this.notes=e,this.context=null,this.text=a,this.direction=null,this.render_options={cp1:8,cp2:12,text_shift_x:0,first_x_shift:0,last_x_shift:0,y_shift:7,tie_spacing:0,font:{family:"Arial",size:10,style:""}},this.font=this.render_options.font,this.setNotes(e)}setFont(e){return this.font=e,this}setDirection(e){return this.direction=e,this}setNotes(e){if(!e.first_note&&!e.last_note)throw new l.RuntimeError("BadArguments","Tie needs to have either first_note or last_note set.");if(e.first_indices||(e.first_indices=[0]),e.last_indices||(e.last_indices=[0]),e.first_indices.length!==e.last_indices.length)throw new l.RuntimeError("BadArguments","Tied notes must have similar index sizes");return this.first_note=e.first_note,this.first_indices=e.first_indices,this.last_note=e.last_note,this.last_indices=e.last_indices,this}isPartial(){return!this.first_note||!this.last_note}renderTie(e){var J;if(e.first_ys.length===0||e.last_ys.length===0)throw new l.RERR("BadArguments","No Y-values to render");const a=this.context;let b=this.render_options.cp1,w=this.render_options.cp2;Math.abs(e.last_x_px-e.first_x_px)<10&&(b=2,w=8);const C=this.render_options.first_x_shift,V=this.render_options.last_x_shift,z=this.render_options.y_shift*e.direction;for(let Z=0;Z1){const a=new B(e);a.render_options.beam_width=3,a.render_options.partial_beam_length=4,this.beams.push(a)}return this}setNote(e){this.note=e}setWidth(e){this.width=e}getWidth(){return this.width}getGraceNotes(){return this.grace_notes}draw(){this.checkContext();const e=this.getNote();if(function(...a){H.DEBUG&&l.L("Vex.Flow.GraceNoteGroup",a)}("Drawing grace note group for:",e),!e||this.index===null)throw new l.RuntimeError("NoAttachedNote","Can't draw grace note without a parent note and parent note index.");if(this.setRendered(),this.alignSubNotesWithNote(this.getGraceNotes(),e),this.grace_notes.forEach(a=>{a.setContext(this.context).draw()}),this.beams.forEach(a=>{a.setContext(this.context).draw()}),this.show_slur){const a=this.getNote().getCategory()===oe.CATEGORY,b=a?O:U;this.slur=new b({last_note:this.grace_notes[0],first_note:e,first_indices:[0],last_indices:[0]}),this.slur.render_options.cp2=12,this.slur.render_options.y_shift=(a?7:5)+this.render_options.slur_y_shift,this.slur.setContext(this.context).draw()}}}class W extends Y{static get CATEGORY(){return"strokes"}static get Type(){return{BRUSH_DOWN:1,BRUSH_UP:2,ROLL_DOWN:3,ROLL_UP:4,RASQUEDO_DOWN:5,RASQUEDO_UP:6,ARPEGGIO_DIRECTIONLESS:7}}static format(e,a){const b=a.left_shift;if(!e||e.length===0)return this;const w=e.map(z=>{const J=z.getNote();if(J instanceof oe){const{line:Z,displaced:re}=J.getKeyProps()[z.getIndex()];return{line:Z,shift:re?J.getExtraLeftPx():0,stroke:z}}{const{str:Z}=J.getPositions()[z.getIndex()];return{line:Z,shift:0,stroke:z}}}),C=b,V=w.reduce((z,{stroke:J,shift:Z})=>(J.setXShift(C+Z),Math.max(J.getWidth()+0,z)),0);return a.left_shift+=V,!0}constructor(e,a){super(),this.setAttribute("type","Stroke"),this.note=null,this.options=l.Merge({},a),this.all_voices=!("all_voices"in this.options)||this.options.all_voices,this.note_end=null,this.index=null,this.type=e,this.position=Y.Position.LEFT,this.render_options={font_scale:38,stroke_px:3,stroke_spacing:10},this.font={family:"serif",size:10,weight:"bold italic"},this.setXShift(0),this.setWidth(10)}getCategory(){return W.CATEGORY}getPosition(){return this.position}addEndNote(e){return this.note_end=e,this}draw(){if(this.checkContext(),this.setRendered(),!this.note||this.index==null)throw new l.RERR("NoAttachedNote","Can't draw stroke without a note and index.");const e=this.note.getModifierStartXY(this.position,this.index);let a=this.note.getYs(),b=e.y,w=e.y;const C=e.x-5,V=this.note.stave.options.spacing_between_lines_px,z=this.getModifierContext().getModifiers(this.note.getCategory());for(let he=0;heNe.line-we.line);let pe=0,ge=0,me=0,Ee=null,Re=null;for(V=0;Vge?we:ge):Z===Y.Position.RIGHT&&(z.setXShift(pe),we+=Oe,me=we>me?we:me),Ee=Ne,Re=J}return a.left_shift+=ge,a.right_shift+=me,!0}constructor(e){super(),this.setAttribute("type","StringNumber"),this.note=null,this.last_note=null,this.index=null,this.string_number=e,this.setWidth(20),this.position=Y.Position.ABOVE,this.x_shift=0,this.y_shift=0,this.x_offset=0,this.y_offset=0,this.dashed=!0,this.leg=E.LineEndType.NONE,this.radius=8,this.font={family:"sans-serif",size:10,weight:"bold"}}getCategory(){return K.CATEGORY}getNote(){return this.note}setNote(e){return this.note=e,this}getIndex(){return this.index}setIndex(e){return this.index=e,this}setLineEndType(e){return e>=E.LineEndType.NONE&&e<=E.LineEndType.DOWN&&(this.leg=e),this}setStringNumber(e){return this.string_number=e,this}setOffsetX(e){return this.x_offset=e,this}setOffsetY(e){return this.y_offset=e,this}setLastNote(e){return this.last_note=e,this}setDashed(e){return this.dashed=e,this}draw(){const e=this.checkContext();if(!this.note||this.index==null)throw new l.RERR("NoAttachedNote","Can't draw string number without a note and index.");this.setRendered();const a=this.note.stave.options.spacing_between_lines_px,b=this.note.getModifierStartXY(this.position,this.index);let w=b.x+this.x_shift+this.x_offset,C=b.y+this.y_shift+this.y_offset;switch(this.position){case Y.Position.ABOVE:case Y.Position.BELOW:{const z=this.note.getStemExtents();let J=z.topY,Z=z.baseY+2;this.note.stem_direction===oe.STEM_DOWN&&(J=z.baseY,Z=z.topY-2),C=this.position===Y.Position.ABOVE?this.note.hasStem()?J-1.75*a:b.y-1.75*a:this.note.hasStem()?Z+1.5*a:b.y+1.75*a,C+=this.y_shift+this.y_offset;break}case Y.Position.LEFT:w-=this.radius/2+5;break;case Y.Position.RIGHT:w+=this.radius/2+6;break;default:throw new l.RERR("InvalidPosition",`The position ${this.position} is invalid`)}e.save(),e.beginPath(),e.arc(w,C,this.radius,0,2*Math.PI,!1),e.lineWidth=1.5,e.stroke(),e.setFont(this.font.family,this.font.size,this.font.weight);const V=w-e.measureText(this.string_number).width/2;if(e.fillText(""+this.string_number,V,C+4.5),this.last_note!=null){const z=this.last_note.getStemX()-this.note.getX()+5;let J,Z;switch(e.strokeStyle="#000000",e.lineCap="round",e.lineWidth=.6,this.dashed?E.drawDashedLine(e,w+10,C,w+z,C,[3,3]):E.drawDashedLine(e,w+10,C,w+z,C,[3,0]),this.leg){case E.LineEndType.UP:J=-10,Z=this.dashed?[3,3]:[3,0],E.drawDashedLine(e,w+z,C,w+z,C+J,Z);break;case E.LineEndType.DOWN:J=10,Z=this.dashed?[3,3]:[3,0],E.drawDashedLine(e,w+z,C,w+z,C+J,Z)}}e.restore()}}class q extends k{static getNextContext(e){const a=e.tContexts,b=a.indexOf(e);return a[b+1]}constructor(){super(),this.setAttribute("type","TickContext"),this.currentTick=new s(0,1),this.maxTicks=new s(0,1),this.minTicks=null,this.padding=3,this.x=0,this.xBase=0,this.xOffset=0,this.tickables=[],this.notePx=0,this.extraLeftPx=0,this.extraRightPx=0,this.tContexts=[]}getX(){return this.x}setX(e){return this.x=e,this.xBase=e,this.xOffset=0,this}getXBase(){return this.xBase}setXBase(e){this.xBase=e,this.x=e+this.xOffset}getXOffset(){return this.xOffset}setXOffset(e){this.xOffset=e,this.x=this.xBase+e}getWidth(){return this.width+2*this.padding}setPadding(e){return this.padding=e,this}getMaxTicks(){return this.maxTicks}getMinTicks(){return this.minTicks}getTickables(){return this.tickables}getCenterAlignedTickables(){return this.tickables.filter(e=>e.isCenterAligned())}getMetrics(){const{width:e,notePx:a,extraLeftPx:b,extraRightPx:w}=this;return{width:e,notePx:a,extraLeftPx:b,extraRightPx:w}}getCurrentTick(){return this.currentTick}setCurrentTick(e){this.currentTick=e,this.preFormatted=!1}getExtraPx(){let e=0,a=0,b=0,w=0;for(let C=0;C.5*ce(e/.5),fe=(ce,e)=>e===te?ce<=5:ce>=1,xe=(ce,e)=>fe(ce,e)?e===te?Math.ceil:Math.floor:Math.round,ve=ce=>{const e=ce.getCategory();return e==="stavenotes"||e==="gracenotes"};class Se extends Y{static get CATEGORY(){return"articulations"}static get INITIAL_OFFSET(){return-.5}static format(e,a){if(!e||e.length===0)return!1;const b=(C,V,z)=>ue(xe(V,z),C.glyph.getMetrics().height/10+.5);e.filter(C=>C.getPosition()===te).forEach(C=>{C.setTextLine(a.top_text_line),a.top_text_line+=b(C,a.top_text_line,te)}),e.filter(C=>C.getPosition()===se).forEach(C=>{C.setTextLine(a.text_line),a.text_line+=b(C,a.text_line,se)});const w=e.map(C=>C.getWidth()).reduce((C,V)=>Math.max(V,C));return a.left_shift+=w/2,a.right_shift+=w/2,!0}static easyScoreHook({articulations:e},a,b){if(!e)return;const w={staccato:"a.",tenuto:"a-"};e.split(",").map(C=>C.trim().split(".")).map(([C,V])=>{const z={type:w[C]};return V&&(z.position=Y.PositionString[V]),b.getFactory().Articulation(z)}).map(C=>a.addModifier(0,C))}constructor(e){if(super(),this.setAttribute("type","Articulation"),this.note=null,this.index=null,this.type=e,this.position=se,this.render_options={font_scale:38},this.breathMarkDistance=.8,this.articulation=m.articulationCodes(this.type),this.type==="abr"&&(this.articulation={code:"v6c",between_lines:!1}),!this.articulation)throw new l.RERR("ArgumentError",`Articulation not found: ${this.type}`);this.glyph=new p(this.articulation.code,this.render_options.font_scale),this.setWidth(this.glyph.getMetrics().width)}getCategory(){return Se.CATEGORY}draw(){const{note:e,index:a,position:b,glyph:w,articulation:{between_lines:C},text_line:V,context:z}=this;if(this.checkContext(),!e||a==null)throw new l.RERR("NoAttachedNote","Can't draw Articulation without a note and index.");this.setRendered();const J=e.getStave(),Z=J.getSpacingBetweenLines(),re=e.getCategory()==="tabnotes";let{x:ae}=e.getModifierStartXY(b,a);if(this.type==="abr"){let me=0;const Ee=e.getTickContext(),Re=q.getNextContext(Ee),we=Ee.getX();if(Re&&Re.x>Ee.x)me=(Re.getX()-we)*this.breathMarkDistance;else{const Ne=e.getStave();me=(Ne.getX()+Ne.getWidth()-we+Ne.start_x)*this.breathMarkDistance}if(ae+=me,ae>J.end_x){const Ne=J.start_x+we;ae=Ne+(J.end_x-Ne)*this.breathMarkDistance}}const le=this.getXShift();le&&(ae+=le);const he=!C||re,pe=((me,Ee)=>{const Re=Ee===te&&me.getStemDirection()===L.UP||Ee===se&&me.getStemDirection()===L.DOWN;return ve(me)?me.hasStem()&&Re?.5:1:me.hasStem()&&Re?1:0})(e,b);let ge={[te]:()=>{w.setOrigin(.5,1);const me=((Ee,Re)=>{const we=Ee.getStave(),Ne=Ee.getStemDirection(),{topY:De,baseY:Oe}=Ee.getStemExtents();if(ve(Ee))return Ee.hasStem()?Ne===L.UP?De:Oe:Math.min(...Ee.getYs());if(Ee.getCategory()==="tabnotes")return Ee.hasStem()&&Ne===L.UP?De:we.getYForTopText(Re);throw new l.RERR("UnknownCategory","Only can get the top and bottom ys of stavenotes and tabnotes")})(e,V)-(V+pe)*Z;return he?Math.min(J.getYForTopText(Se.INITIAL_OFFSET),me):me},[se]:()=>{w.setOrigin(.5,0);const me=((Ee,Re)=>{const we=Ee.getStave(),Ne=Ee.getStemDirection(),{topY:De,baseY:Oe}=Ee.getStemExtents();if(ve(Ee))return Ee.hasStem()?Ne===L.UP?Oe:De:Math.max(...Ee.getYs());if(Ee.getCategory()==="tabnotes")return Ee.hasStem()?Ne===L.UP?we.getYForBottomText(Re):De:we.getYForBottomText(Re);throw new l.RERR("UnknownCategory","Only can get the top and bottom ys of stavenotes and tabnotes")})(e,V)+(V+pe)*Z;return he?Math.max(J.getYForBottomText(Se.INITIAL_OFFSET),me):me}}[b]();if(this.y_shift&&(ge+=this.y_shift),!re){const me=b===te?-1:1,Ee=re?e.positions[a].str:e.getKeyProps()[a].line,Re=(e.getYs()[a]-ge)/Z+Ee,we=((Ne,De,Oe,ke)=>{const Ue=ue(xe(De,Oe),De);return Ne&&fe(Ue,Oe)&&Ue%1==0?Ue+.5*-ke:Ue})(C,Re,b,me);fe(we,b)&&w.setOrigin(.5,.5),ge+=Math.abs(we-Re)*Z*me}(function(...me){Se.DEBUG&&l.L("Vex.Flow.Articulation",me)})(`Rendering articulation at (x: ${ae}, y: ${ge})`),w.render(z,ae,ge)}}class ye extends Y{static get CATEGORY(){return"ornaments"}static format(e,a){if(!e||e.length===0)return!1;let b=0;for(let w=0;w0&&w--;for(let J=0;J{Te("Preformatting ModifierContext: ",e.CATEGORY),e.format(this.getModifiers(e.CATEGORY),this.state,this)}),this.width=this.state.left_shift+this.state.right_shift,this.preFormatted=!0)}postFormat(){this.postFormatted||this.POSTFORMAT.forEach(e=>{Te("Postformatting ModifierContext: ",e.CATEGORY),e.postFormat(this.getModifiers(e.CATEGORY),this)})}}function Pe(ce,e,a,b){let w=e;for(a+=1;a{if(J.getMode()===D.Mode.STRICT&&!J.isComplete())throw new l.RERR("IncompleteVoice","Voice does not have enough notes.");return Math.max(z,s.LCM(z,J.getResolutionMultiplier()))},1),w={},C=[],V=[];return ce.forEach(z=>{const J=new s(0,b);z.getTickables().forEach(Z=>{const re=J.numerator;if(!w[re]){const ae=new e;V.push(ae),w[re]=ae}a(Z,w[re]),C.push(re),J.add(Z.getTicks())})}),{map:w,array:V,list:l.SortAndUnique(C,(z,J)=>z-J,(z,J)=>z===J),resolutionMultiplier:b}}class Ce{static SimpleFormat(e,a=0,{paddingBetween:b=10}={}){e.reduce((w,C)=>{C.addToModifierContext(new Le);const V=new q().addTickable(C).preFormat(),z=V.getExtraPx();return V.setX(w+z.left),w+V.getWidth()+z.right+b},a)}static plotDebugging(e,a,b,w,C){const V=b+j.STAVEPADDING,z=a.contextGaps;e.save(),e.setFont("Arial",8,""),z.gaps.forEach(J=>{var Z,re,ae;Z=V+J.x1,re=V+J.x2,ae="#aaa",e.beginPath(),e.setStrokeStyle(ae),e.setFillStyle(ae),e.setLineWidth(1),e.fillRect(Z,w,re-Z,C-w),e.fillText(Math.round(J.x2-J.x1),V+J.x1,C+12)}),e.fillText(Math.round(z.total)+"px",V-20,C+12),e.setFillStyle("red"),e.fillText("Loss: "+a.lossHistory.map(J=>Math.round(J)),V-20,C+22),e.restore()}static FormatAndDraw(e,a,b,w){const C={auto_beam:!1,align_rests:!1};typeof w=="object"?l.Merge(C,w):typeof w=="boolean"&&(C.auto_beam=w);const V=new D(m.TIME4_4).setMode(D.Mode.SOFT).addTickables(b),z=C.auto_beam?B.applyAndGetBeams(V):[];return new Ce().joinVoices([V],{align_rests:C.align_rests}).formatToStave([V],a,{align_rests:C.align_rests,stave:a}),V.setStave(a).draw(e,a),z.forEach(J=>J.setContext(e).draw()),V.getBoundingBox()}static FormatAndDrawTab(e,a,b,w,C,V,z){const J={auto_beam:V,align_rests:!1};typeof z=="object"?l.Merge(J,z):typeof z=="boolean"&&(J.auto_beam=z);const Z=new D(m.TIME4_4).setMode(D.Mode.SOFT).addTickables(C),re=new D(m.TIME4_4).setMode(D.Mode.SOFT).addTickables(w),ae=J.auto_beam?B.applyAndGetBeams(Z):[];new Ce().joinVoices([Z],{align_rests:J.align_rests}).joinVoices([re]).formatToStave([Z,re],b,{align_rests:J.align_rests}),Z.draw(e,b),re.draw(e,a),ae.forEach(le=>le.setContext(e).draw()),new F(b,a).setContext(e).draw()}static AlignRestsToNotes(e,a,b){return e.forEach((w,C)=>{if(w instanceof oe&&w.isRest()){if(w.tuplet&&!b)return;const V=w.getGlyph().position.toUpperCase();if(V!=="R/4"&&V!=="B/4")return;if(a||w.beam!=null){const z=w.getKeyProps()[0];if(C===0)z.line=Pe(e,z.line,C,!1),w.setKeyLine(0,z.line);else if(C>0&&CCe.AlignRestsToNotes(b.getTickables(),a))}preCalculateMinTotalWidth(e){if(this.hasMinTotalWidth)return this.minTotalWidth;if(!this.tickContexts){if(!e)throw new l.RERR("BadArgument","'voices' required to run preCalculateMinTotalWidth");this.createTickContexts(e)}const{list:a,map:b}=this.tickContexts;return this.minTotalWidth=a.map(w=>{const C=b[w];return C.preFormat(),C.getWidth()}).reduce((w,C)=>w+C,0),this.hasMinTotalWidth=!0,this.minTotalWidth}getMinTotalWidth(){if(!this.hasMinTotalWidth)throw new l.RERR("NoMinTotalWidth","Call 'preCalculateMinTotalWidth' or 'preFormat' before calling 'getMinTotalWidth'");return this.minTotalWidth}createModifierContexts(e){const a=Ae(e,Le,(b,w)=>b.addToModifierContext(w));return this.modiferContexts=a,a}createTickContexts(e){const a=Ae(e,q,(b,w)=>w.addTickable(b));return a.array.forEach(b=>{b.tContexts=a.array}),this.totalTicks=e[0].getTicksUsed().clone(),this.tickContexts=a,a}preFormat(e=0,a,b,w){const C=this.tickContexts,{list:V,map:z,resolutionMultiplier:J}=C;b&&w&&b.forEach(me=>me.setStave(w).preFormat());let Z=0,re=0;const ae=e/2;if(this.minTotalWidth=0,V.forEach(me=>{const Ee=z[me];a&&Ee.setContext(a),Ee.preFormat();const Re=Ee.getWidth();this.minTotalWidth+=Re;const we=Ee.getMetrics();Z=Z+re+we.extraLeftPx,Ee.setX(Z),re=Re-we.extraLeftPx}),this.minTotalWidth=Z+re,this.hasMinTotalWidth=!0,e<=0)return;const le=e-this.minTotalWidth;let he=this.totalTicks.value();he===0&&(he=1);const pe=le/(he*J);let ge=0;V.forEach((me,Ee)=>{const Re=V[Ee-1]||0,we=z[me];ge+=(me-Re)*pe,we.setX(we.getX()+ge),we.getCenterAlignedTickables().forEach(Ne=>{Ne.center_x_shift=ae-we.getX()})}),V.length!==1&&(this.justifyWidth=e,this.lossHistory=[],this.evaluate())}evaluate(){const e=this.justifyWidth;this.contextGaps={total:0,gaps:[]},this.tickContexts.list.forEach((w,C)=>{if(C===0)return;const V=this.tickContexts.list[C-1],z=this.tickContexts.map[V],J=this.tickContexts.map[w],Z=z.getMetrics(),re=z.getX()+Z.width,ae=J.getX(),le=ae-re;this.contextGaps.total+=le,this.contextGaps.gaps.push({x1:re,x2:ae}),J.getFormatterMetrics().freedom.left=le,z.getFormatterMetrics().freedom.right=le});const a=this.durationStats={};this.voices.forEach(w=>{w.getTickables().forEach((C,V,z)=>{const J=C.getTicks().clone().simplify().toString(),Z=C.getMetrics(),re=C.getFormatterMetrics(),ae=C.getX()+Z.noteWidth+Z.modRightPx+Z.extraRightPx;let le=0;if(V{w.getTickables().forEach(C=>{const V=C.getTicks().clone().simplify().toString(),z=C.getFormatterMetrics();z.iterations+=1,z.space.deviation=z.space.used-a[V].mean,z.duration=V,z.space.mean=a[V].mean,b+=Math.pow(a[V].mean,2)})}),this.totalCost=Math.sqrt(b),this.lossHistory.push(this.totalCost),this}tune(){let e=0;return this.tickContexts.list.forEach((a,b,w)=>{const C=this.tickContexts.map[a],V=b>0?this.tickContexts.map[w[b-1]]:null,z=bre.getFormatterMetrics().space.deviation).reduce((re,ae)=>re+ae);J>0?e=-Math.min(C.getFormatterMetrics().freedom.right,Math.abs(J)):J<0&&(e=z?Math.min(z.getFormatterMetrics().freedom.right,Math.abs(J)):0);const Z=Math.min(5,Math.abs(e));e=e>0?Z:-Z}),this.evaluate()}postFormat(){const e=a=>a.list.forEach(b=>a.map[b].postFormat());return e(this.modiferContexts),e(this.tickContexts),this}joinVoices(e){return this.createModifierContexts(e),this.hasMinTotalWidth=!1,this}format(e,a,b){const w={align_rests:!1,context:null,stave:null};return l.Merge(w,b),this.voices=e,this.alignRests(e,w.align_rests),this.createTickContexts(e),this.preFormat(a,w.context,e,w.stave),w.stave&&this.postFormat(),this}formatToStave(e,a,b){const w=a.getNoteEndX()-a.getNoteStartX()-10;(function(...V){Ce.DEBUG&&l.L("Vex.Flow.Formatter",V)})("Formatting voices to width: ",w);const C={context:a.getContext()};return l.Merge(C,b),this.format(e,w,C)}}class Be extends o{static get Position(){return{LEFT:1,RIGHT:2,ABOVE:3,BELOW:4,BEGIN:5,END:6}}constructor(){super(),this.setAttribute("type","StaveModifier"),this.padding=10,this.position=Be.Position.ABOVE,this.layoutMetrics=null}getPosition(){return this.position}setPosition(e){return this.position=e,this}getStave(){return this.stave}setStave(e){return this.stave=e,this}getWidth(){return this.width}setWidth(e){return this.width=e,this}getX(){return this.x}setX(e){return this.x=e,this}getCategory(){return""}makeSpacer(e){return{getContext:()=>!0,setStave(){},renderToStave(){},getMetrics:()=>({width:e})}}placeGlyphOnLine(e,a,b){e.setYShift(a.getYForLine(b)-a.getYForGlyphs())}getPadding(e){return e!==void 0&&e<2?0:this.padding}setPadding(e){return this.padding=e,this}setLayoutMetrics(e){return this.layoutMetrics=e,this}getLayoutMetrics(){return this.layoutMetrics}}class Ie extends Be{static get CATEGORY(){return"barlines"}static get type(){return{SINGLE:1,DOUBLE:2,END:3,REPEAT_BEGIN:4,REPEAT_END:5,REPEAT_BOTH:6,NONE:7,DOUBLE_HEAVY:8}}static get typeString(){return{single:Ie.type.SINGLE,double:Ie.type.DOUBLE,doubleheavy:Ie.type.DOUBLE_HEAVY,end:Ie.type.END,repeatBegin:Ie.type.REPEAT_BEGIN,repeatEnd:Ie.type.REPEAT_END,repeatBoth:Ie.type.REPEAT_BOTH,none:Ie.type.NONE}}constructor(e){super(),this.setAttribute("type","Barline"),this.thickness=m.STAVE_LINE_THICKNESS;const a=Ie.type;this.widths={},this.widths[a.SINGLE]=5,this.widths[a.DOUBLE]=5,this.widths[a.DOUBLE_HEAVY]=5,this.widths[a.END]=5,this.widths[a.REPEAT_BEGIN]=5,this.widths[a.REPEAT_END]=5,this.widths[a.REPEAT_BOTH]=5,this.widths[a.NONE]=5,this.paddings={},this.paddings[a.SINGLE]=0,this.paddings[a.DOUBLE]=0,this.paddings[a.DOUBLE_HEAVY]=0,this.paddings[a.END]=5,this.paddings[a.REPEAT_BEGIN]=10,this.paddings[a.REPEAT_END]=10,this.paddings[a.REPEAT_BOTH]=15,this.paddings[a.NONE]=0,this.layoutMetricsMap={},this.layoutMetricsMap[a.SINGLE]={xMin:0,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[a.DOUBLE]={xMin:-3,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[a.DOUBLE_HEAVY]={xMin:-5,xMax:4,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[a.END]={xMin:-5,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[a.REPEAT_END]={xMin:-10,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[a.REPEAT_BEGIN]={xMin:-2,xMax:10,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[a.REPEAT_BOTH]={xMin:-10,xMax:10,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[a.NONE]={xMin:0,xMax:0,paddingLeft:5,paddingRight:5},this.setPosition(Be.Position.BEGIN),this.setType(e)}getCategory(){return Ie.CATEGORY}getType(){return this.type}setType(e){return this.type=typeof e=="string"?Ie.typeString[e]:e,this.setWidth(this.widths[this.type]),this.setPadding(this.paddings[this.type]),this.setLayoutMetrics(this.layoutMetricsMap[this.type]),this}draw(e){switch(e.checkContext(),this.setRendered(),this.type){case Ie.type.SINGLE:this.drawVerticalBar(e,this.x,!1);break;case Ie.type.DOUBLE:this.drawVerticalBar(e,this.x,!0);break;case Ie.type.DOUBLE_HEAVY:this.drawVerticalBar(e,this.x,!0,!0);break;case Ie.type.END:this.drawVerticalEndBar(e,this.x);break;case Ie.type.REPEAT_BEGIN:this.drawRepeatBar(e,this.x,!0),e.getX()!==this.x&&this.drawVerticalBar(e,e.getX());break;case Ie.type.REPEAT_END:this.drawRepeatBar(e,this.x,!1);break;case Ie.type.REPEAT_BOTH:this.drawRepeatBar(e,this.x,!1),this.drawRepeatBar(e,this.x,!0)}}drawVerticalBar(e,a,b,w){e.checkContext();const C=e.getTopLineTopY(),V=e.getBottomLineBottomY();let z=1,J=1,Z=a-3,re=a;w&&(z=3,J=3,Z=a-5,re=a),b&&e.context.fillRect(Z,C,z,V-C),e.context.fillRect(re,C,J,V-C)}drawVerticalEndBar(e,a){e.checkContext();const b=e.getTopLineTopY(),w=e.getBottomLineBottomY();e.context.fillRect(a-5,b,1,w-b),e.context.fillRect(a-2,b,3,w-b)}drawRepeatBar(e,a,b){e.checkContext();const w=e.getTopLineTopY(),C=e.getBottomLineBottomY();let V=3;b||(V=-5),e.context.fillRect(a+V,w,1,C-w),e.context.fillRect(a-2,w,3,C-w),b?V+=4:V-=4;const z=a+V+1;let J=(e.getNumLines()-1)*e.getSpacingBetweenLines();J=J/2-e.getSpacingBetweenLines()/2;let Z=w+J+1;e.context.beginPath(),e.context.arc(z,Z,2,0,2*Math.PI,!1),e.context.fill(),Z+=e.getSpacingBetweenLines(),e.context.beginPath(),e.context.arc(z,Z,2,0,2*Math.PI,!1),e.context.fill()}}class Fe extends Be{static get CATEGORY(){return"repetitions"}static get type(){return{NONE:1,CODA_LEFT:2,CODA_RIGHT:3,SEGNO_LEFT:4,SEGNO_RIGHT:5,DC:6,DC_AL_CODA:7,DC_AL_FINE:8,DS:9,DS_AL_CODA:10,DS_AL_FINE:11,FINE:12,TO_CODA:13}}constructor(e,a,b){super(),this.setAttribute("type","Repetition"),this.symbol_type=e,this.x=a,this.x_shift=0,this.y_shift=b,this.font={family:"times",size:12,weight:"bold italic"}}getCategory(){return Fe.CATEGORY}setShiftX(e){return this.x_shift=e,this}setShiftY(e){return this.y_shift=e,this}setX(e){return this.x=e,this}draw(e,a){switch(this.setRendered(),this.symbol_type){case Fe.type.CODA_RIGHT:this.drawCodaFixed(e,a+e.width);break;case Fe.type.CODA_LEFT:this.drawSymbolText(e,a,"Coda",!0);break;case Fe.type.SEGNO_LEFT:this.drawSignoFixed(e,a);break;case Fe.type.SEGNO_RIGHT:this.drawSignoFixed(e,a+e.width);break;case Fe.type.DC:this.drawSymbolText(e,a,"D.C.",!1);break;case Fe.type.DC_AL_CODA:this.drawSymbolText(e,a,"D.C. al",!0);break;case Fe.type.DC_AL_FINE:this.drawSymbolText(e,a,"D.C. al Fine",!1);break;case Fe.type.DS:this.drawSymbolText(e,a,"D.S.",!1);break;case Fe.type.DS_AL_CODA:this.drawSymbolText(e,a,"D.S. al",!0);break;case Fe.type.DS_AL_FINE:this.drawSymbolText(e,a,"D.S. al Fine",!1);break;case Fe.type.FINE:this.drawSymbolText(e,a,"Fine",!1);break;case Fe.type.TO_CODA:this.drawSymbolText(e,a,"To",!0)}return this}drawCodaFixed(e,a){const b=e.getYForTopText(e.options.num_lines)+this.y_shift;return p.renderGlyph(e.context,this.x+a+this.x_shift,b+25,40,"v4d",!0),this}drawSignoFixed(e,a){const b=e.getYForTopText(e.options.num_lines)+this.y_shift;return p.renderGlyph(e.context,this.x+a+this.x_shift,b+25,30,"v8c",!0),this}drawSymbolText(e,a,b,w){const C=e.checkContext();C.save(),C.setFont(this.font.family,this.font.size,this.font.weight);let V=0+this.x_shift,z=a+this.x_shift;if(this.symbol_type===Fe.type.CODA_LEFT?(V=this.x+this.x_shift,z=V+C.measureText(b).width+12):(this.x_shift=-(V+C.measureText(b).width+12+e.options.vertical_bar_width+12),V=this.x+this.x_shift+e.options.vertical_bar_width,z=V+C.measureText(b).width+12),this.xShiftAsPercentOfStaveWidth){const Z=e.width*this.xShiftAsPercentOfStaveWidth;this.symbol_type!==Fe.type.DC_AL_FINE&&this.symbol_type!==Fe.type.FINE&&this.symbol_type!==Fe.type.DC&&this.symbol_type!==Fe.type.DS_AL_FINE&&this.symbol_type!==Fe.type.DS&&this.symbol_type!==Fe.type.FINE||(V+=Z)}const J=e.getYForTopText(e.options.num_lines)+this.y_shift+25;return w&&p.renderGlyph(C,z,J,40,"v4d",!0),C.fillText(b,V,J+5),C.restore(),this}}class Ke extends Be{static get CATEGORY(){return"stavesection"}constructor(e,a,b){super(),this.setAttribute("type","StaveSection"),this.setWidth(16),this.section=e,this.x=a,this.shift_x=0,this.shift_y=b,this.font={family:"sans-serif",size:12,weight:"bold"}}getCategory(){return Ke.CATEGORY}setStaveSection(e){return this.section=e,this}setShiftX(e){return this.shift_x=e,this}setShiftY(e){return this.shift_y=e,this}draw(e,a){const b=e.checkContext();this.setRendered(),b.save(),b.lineWidth=2,b.setFont(this.font.family,this.font.size,this.font.weight);const w=b.measureText(""+this.section),C=w.width;let V=w.height;!V&&w.emHeightAscent>=0&&(V=w.emHeightAscent+2),V||(V=w.fontBoundingBoxAscent+3);let z=C+6;z<18&&(z=18);const J=V+this.font.size/10,Z=e.getYForTopText(3)+19-1.15*J+this.shift_y;let re=this.x+a;return b.beginPath(),b.lineWidth=2,b.rect(re,Z+V/4,z,J),b.stroke(),re+=(z-C)/2,b.fillText(""+this.section,re,Z+J),b.restore(),this}}class st extends Be{static get CATEGORY(){return"stavetempo"}constructor(e,a,b){super(),this.setAttribute("type","StaveTempo"),this.tempo=e,this.position=Y.Position.ABOVE,this.x=a,this.shift_x=10,this.shift_y=b,this.font={family:"times",size:14,weight:"bold"},this.render_options={glyph_font_scale:30}}getCategory(){return st.CATEGORY}setTempo(e){return this.tempo=e,this}setShiftX(e){return this.shift_x=e,this}setShiftY(e){return this.shift_y=e,this}draw(e,a){const b=e.checkContext();this.setRendered(),b.openGroup("stavetempo");const w=this.render_options,C=w.glyph_font_scale/38,V=this.tempo.name,z=this.tempo.duration,J=this.tempo.dots,Z=this.tempo.bpm,re=this.tempo.noteEquation,ae=this.font;let le=this.x+this.shift_x+a;const he=e.getYForTopText(1)+this.shift_y;if(b.save(),V&&(b.setFont(ae.family,ae.size,ae.weight),b.fillText(V,le,he),le+=b.measureText(V).width),re)le=this.drawNoteEquation(b,le,he,C,re);else if(z&&Z){b.setFont(ae.family,ae.size,"normal"),V&&(le+=b.measureText(" ").width,b.fillText("(",le,he),le+=b.measureText("(").width);const pe=m.getGlyphProps(z);if(le+=3*C,p.renderGlyph(b,le,he,w.glyph_font_scale,pe.code_head),le+=pe.getWidth()*C,pe.stem){let ge=30;pe.beam_count&&(ge+=3*(pe.beam_count-1)),ge*=C;const me=he-ge;b.fillRect(le-C,me,C,ge),pe.flag&&(p.renderGlyph(b,le,me,w.glyph_font_scale,pe.code_flag_upstem),J||(le+=6*C))}for(let ge=0;ge0){const pe=re[0],ge=re[re.length-1];let me=pe.y_top;for(const De of re)me=Math.min(me,De.y_top);const Ee=1.25*C,Re=me-1.5*C,we=pe.x-.5*C,Ne=ge.stemX+Ee;if(Z.bracket){const De=C;e.beginPath(),e.moveTo(we,Re+De),e.lineTo(we,Re);const Oe=(we+Ne)/2,ke=Z.showNumber==="both"?`${Z.actualNotes}:${Z.normalNotes}`:`${Z.actualNotes}`;e.setFont(this.font.family,this.font.size-3,"bold");const Ue=e.measureText(ke).width,Ge=Ue/2+2*w;e.lineTo(Oe-Ge,Re),e.stroke(),e.beginPath(),e.moveTo(Oe+Ge,Re),e.lineTo(Ne,Re),e.lineTo(Ne,Re+De),e.stroke(),e.fillText(ke,Oe-Ue/2,Re-1*w)}else if(Z.showNumber!=="none"){const De=(we+Ne)/2,Oe=Z.showNumber==="both"?`${Z.actualNotes}:${Z.normalNotes}`:`${Z.actualNotes}`;e.setFont(this.font.family,this.font.size-3,"bold");const ke=e.measureText(Oe).width;e.fillText(Oe,De-ke/2,Re-1*w)}}return a}}class je extends j{static get Justification(){return{LEFT:1,CENTER:2,RIGHT:3}}static get GLYPHS(){return{segno:{code:"v8c",point:40,x_shift:0,y_shift:-10},tr:{code:"v1f",point:40,x_shift:0,y_shift:0},mordent_upper:{code:"v1e",point:40,x_shift:0,y_shift:0},mordent_lower:{code:"v45",point:40,x_shift:0,y_shift:0},f:{code:"vba",point:40,x_shift:0,y_shift:0},p:{code:"vbf",point:40,x_shift:0,y_shift:0},m:{code:"v62",point:40,x_shift:0,y_shift:0},s:{code:"v4a",point:40,x_shift:0,y_shift:0},z:{code:"v80",point:40,x_shift:0,y_shift:0},coda:{code:"v4d",point:40,x_shift:0,y_shift:-8},pedal_open:{code:"v36",point:40,x_shift:0,y_shift:0},pedal_close:{code:"v5d",point:40,x_shift:0,y_shift:3},caesura_straight:{code:"v34",point:40,x_shift:0,y_shift:2},caesura_curved:{code:"v4b",point:40,x_shift:0,y_shift:2},breath:{code:"v6c",point:40,x_shift:0,y_shift:0},tick:{code:"v6f",point:50,x_shift:0,y_shift:0},turn:{code:"v72",point:40,x_shift:0,y_shift:0},turn_inverted:{code:"v33",point:40,x_shift:0,y_shift:0},mordent:{code:"v1e",point:40,x_shift:0,y_shift:0}}}constructor(e){if(super(e),this.setAttribute("type","TextNote"),this.text=e.text,this.superscript=e.superscript,this.subscript=e.subscript,this.glyph_type=e.glyph,this.glyph=null,this.font={family:"Arial",size:12,weight:""},e.font&&(this.font=e.font),this.glyph_type){const a=je.GLYPHS[this.glyph_type];if(!a)throw new l.RERR("Invalid glyph type: "+this.glyph_type);this.glyph=new p(a.code,a.point,{cache:!1}),a.width?this.setWidth(a.width):this.setWidth(this.glyph.getMetrics().width),this.glyph_struct=a}else this.setWidth(m.textWidth(this.text));this.line=e.line||0,this.smooth=e.smooth||!1,this.ignore_ticks=e.ignore_ticks||!1,this.justification=je.Justification.LEFT}setJustification(e){return this.justification=e,this}setLine(e){return this.line=e,this}preFormat(){this.checkContext(),this.preFormatted||(this.smooth?this.setWidth(0):this.glyph||this.setWidth(this.context.measureText(this.text).width),this.justification===je.Justification.CENTER?this.extraLeftPx=this.width/2:this.justification===je.Justification.RIGHT&&(this.extraLeftPx=this.width),this.setPreFormatted(!0))}draw(){if(this.checkContext(),!this.stave)throw new l.RERR("NoStave","Can't draw without a stave.");this.setRendered();const e=this.context;let a,b=this.getAbsoluteX();if(this.justification===je.Justification.CENTER?b-=this.getWidth()/2:this.justification===je.Justification.RIGHT&&(b-=this.getWidth()),this.glyph)a=this.stave.getYForLine(this.line+-3),this.glyph.render(this.context,b+this.glyph_struct.x_shift,a+this.glyph_struct.y_shift);else{a=this.stave.getYForLine(this.line+-3),this.applyStyle(e),e.setFont(this.font.family,this.font.size,this.font.weight),e.fillText(this.text,b,a);const w=e.measureText("M").width,C=e.measureText(this.text).width;this.superscript&&(e.setFont(this.font.family,this.font.size/1.3,this.font.weight),e.fillText(this.superscript,b+C+2,a-w/2.2)),this.subscript&&(e.setFont(this.font.family,this.font.size/1.3,this.font.weight),e.fillText(this.subscript,b+C+2,a+w/2.2-1)),this.restoreStyle(e)}}}class at extends Be{static get CATEGORY(){return"stavetext"}constructor(e,a,b){super(),this.setAttribute("type","StaveText"),this.setWidth(16),this.text=e,this.position=a,this.options={shift_x:0,shift_y:0,justification:je.Justification.CENTER},l.Merge(this.options,b),this.font={family:"times",size:16,weight:"normal"}}getCategory(){return at.CATEGORY}setStaveText(e){return this.text=e,this}setShiftX(e){return this.shift_x=e,this}setShiftY(e){return this.shift_y=e,this}setFont(e){l.Merge(this.font,e)}setText(e){this.text=e}draw(e){const a=e.checkContext();this.setRendered(),a.save(),a.lineWidth=2,a.setFont(this.font.family,this.font.size,this.font.weight);const b=a.measureText(""+this.text).width;let w,C;const V=Be.Position,z=je.Justification;switch(this.position){case V.LEFT:case V.RIGHT:C=(e.getYForLine(0)+e.getBottomLineY())/2+this.options.shift_y,w=this.position===V.LEFT?e.getX()-b-24+this.options.shift_x:e.getX()+e.getWidth()+24+this.options.shift_x;break;case V.ABOVE:case V.BELOW:w=e.getX()+this.options.shift_x,this.options.justification===z.CENTER?w+=e.getWidth()/2-b/2:this.options.justification===z.RIGHT&&(w+=e.getWidth()-b),C=this.position===V.ABOVE?e.getYForTopText(2)+this.options.shift_y:e.getYForBottomText(2)+this.options.shift_y;break;default:throw new l.RERR("InvalidPosition","Value Must be in Modifier.Position.")}return a.fillText(""+this.text,w,C+4),a.restore(),this}}class et extends Be{static get CATEGORY(){return"clefs"}static get types(){return{treble:{code:"v83",line:3},bass:{code:"v79",line:1},alto:{code:"vad",line:2},tenor:{code:"vad",line:1},percussion:{code:"v59",line:2},soprano:{code:"vad",line:4},"mezzo-soprano":{code:"vad",line:3},"baritone-c":{code:"vad",line:0},"baritone-f":{code:"v79",line:2},subbass:{code:"v79",line:0},french:{code:"v83",line:4},tab:{code:"v2f"}}}static get sizes(){return{default:{point:40,width:26},small:{point:32,width:20}}}static get annotations(){return{"8va":{code:"v8",sizes:{default:{point:20,attachments:{treble:{line:-1.2,x_shift:11}}},small:{point:18,attachments:{treble:{line:-.4,x_shift:8}}}}},"8vb":{code:"v8",sizes:{default:{point:20,attachments:{treble:{line:6.3,x_shift:10},bass:{line:4,x_shift:1}}},small:{point:18,attachments:{treble:{line:5.8,x_shift:6},bass:{line:3.5,x_shift:.5}}}}}}}constructor(e,a,b){super(),this.setAttribute("type","Clef"),this.setPosition(Be.Position.BEGIN),this.setType(e,a,b),this.setWidth(et.sizes[this.size].width),function(...w){et.DEBUG&&l.L("Vex.Flow.Clef",w)}("Creating clef:",e)}getCategory(){return et.CATEGORY}setType(e,a,b){if(this.type=e,this.clef=et.types[e],this.size=a===void 0?"default":a,this.clef.point=et.sizes[this.size].point,this.glyph=new p(this.clef.code,this.clef.point),b!==void 0){const w=et.annotations[b];this.annotation={code:w.code,point:w.sizes[this.size].point,line:w.sizes[this.size].attachments[this.type].line,x_shift:w.sizes[this.size].attachments[this.type].x_shift},this.attachment=new p(this.annotation.code,this.annotation.point),this.attachment.metrics.x_max=0,this.attachment.setXShift(this.annotation.x_shift)}else this.annotation=void 0;return this}getWidth(){if(this.type==="tab"&&!this.stave)throw new l.RERR("ClefError","Can't get width without stave.");return this.width}setStave(e){if(this.stave=e,this.type!=="tab")return this;let a,b;const w=this.stave.getOptions().num_lines;switch(w){case 8:a=55,b=14;break;case 7:a=47,b=8;break;case 6:a=40,b=1;break;case 5:a=30,b=-6;break;case 4:a=23,b=-12;break;case 3:a=16,b=-18;break;default:throw new l.RERR("ClefError",`Invalid number of lines: ${w}`)}return this.glyph.setPoint(a),this.glyph.setYShift(b),this}draw(){if(!this.x)throw new l.RERR("ClefError","Can't draw clef without x.");if(!this.stave)throw new l.RERR("ClefError","Can't draw clef without stave.");this.setRendered(),this.glyph.setStave(this.stave),this.glyph.setContext(this.stave.context),this.clef.line!==void 0&&this.placeGlyphOnLine(this.glyph,this.stave,this.clef.line),this.stave.context.openGroup("clef"),this.glyph.renderToStave(this.x),this.annotation!==void 0&&(this.placeGlyphOnLine(this.attachment,this.stave,this.annotation.line),this.attachment.setStave(this.stave),this.attachment.setContext(this.stave.context),this.attachment.renderToStave(this.x)),this.stave.context.closeGroup()}}class We extends Be{static get CATEGORY(){return"keysignatures"}static get accidentalSpacing(){return{"#":{above:6,below:4},b:{above:4,below:7},n:{above:4,below:1},"##":{above:6,below:4},bb:{above:4,below:7},db:{above:4,below:7},d:{above:4,below:7},bbs:{above:4,below:7},"++":{above:6,below:4},"+":{above:6,below:4},"+-":{above:6,below:4},"++-":{above:6,below:4},bs:{above:4,below:10},bss:{above:4,below:10}}}constructor(e,a,b){super(),this.setAttribute("type","KeySignature"),this.setKeySig(e,a,b),this.setPosition(Be.Position.BEGIN),this.glyphFontScale=38,this.glyphs=[],this.xPositions=[],this.paddingForced=!1}getCategory(){return We.CATEGORY}convertToGlyph(e,a){const b=m.accidentalCodes(e.type),w=new p(b.code,this.glyphFontScale);let C=1;if(e.type==="n"&&a){const J=We.accidentalSpacing[a.type];J&&(C=a.line>=e.line?J.above:J.below)}this.placeGlyphOnLine(w,this.stave,e.line),this.glyphs.push(w);const V=this.xPositions[this.xPositions.length-1],z=w.getMetrics().width+C;this.xPositions.push(V+z),this.width+=z}cancelKey(e){return this.formatted=!1,this.cancelKeySpec=e,this}convertToCancelAccList(e){const a=m.keySignature(e),b=this.accList.length>0&&a.length>0&&a[0].type!==this.accList[0].type,w=b?a.length:a.length-this.accList.length;if(w<1)return;const C=[];for(let V=0;V0?e[0].type:null;let b;if(this.cancelKeySpec&&(b=this.convertToCancelAccList(this.cancelKeySpec)),this.alterKeySpec&&this.convertToAlterAccList(this.alterKeySpec),this.accList.length>0){const w=(this.position===Be.Position.END?this.stave.endClef:this.stave.clef)||this.stave.clef;b&&this.convertAccLines(w,b.type,b.accList),this.convertAccLines(w,a,e);for(let C=0;C0){const e=this.stave.context.openGroup("keysignature");for(let a=0;a{const C=w.split("/").filter(V=>V!=="");if(C.length!==2)throw new l.RERR("BadTimeSignature",`Invalid time spec: ${w}. Must be in the form "/"`);C.forEach(V=>{if(isNaN(Number(V)))throw new l.RERR("BadTimeSignature",`Invalid time spec: ${w}. Must contain two valid numbers.`)})})(e);const[a,b]=e.split("/").map(w=>w.split(""));return{num:!0,glyph:this.makeTimeSignatureGlyph(a,b)}}makeTimeSignatureGlyph(e,a){const b=new p("v0",this.point);b.topGlyphs=[],b.botGlyphs=[];let w=0;for(let ae=0;aeC?w:C,z=b.getMetrics().x_min;b.getMetrics=()=>({x_min:z,x_max:z+V,width:V});const J=(V-w)/2,Z=(V-C)/2,re=this;return b.renderToStave=function(ae){let le=ae+J;for(let he=0;he{b.getNoteStartX()>a&&(a=b.getNoteStartX())}),e.forEach(b=>{b.setNoteStartX(a)}),a=0,e.forEach(b=>{b.getModifiers(Be.Position.BEGIN,Ie.CATEGORY).forEach(w=>{w.getType()==Ie.type.REPEAT_BEGIN&&w.getX()>a&&(a=w.getX())})}),e.forEach(b=>{b.getModifiers(Be.Position.BEGIN,Ie.CATEGORY).forEach(w=>{w.getType()==Ie.type.REPEAT_BEGIN&&w.setX(a)})}),a=0,e.forEach(b=>{b.getModifiers(Be.Position.BEGIN,Xe.CATEGORY).forEach(w=>{w.getX()>a&&(a=w.getX())})}),e.forEach(b=>{b.getModifiers(Be.Position.BEGIN,Xe.CATEGORY).forEach(w=>{w.setX(a)})})}getOptions(){return this.options}setNoteStartX(e){return this.formatted||this.format(),this.setStartX(e),this}setStartX(e){this.start_x=e}getNoteStartX(){return this.formatted||this.format(),this.start_x}getNoteEndX(){return this.formatted||this.format(),this.end_x}getTieStartX(){return this.start_x}getTieEndX(){return this.x+this.width}getX(){return this.x}getNumLines(){return this.options.num_lines}setNumLines(e){return this.options.num_lines=parseInt(e,10),this.resetLines(),this}setY(e){return this.y=e,this}getTopLineTopY(){return this.getYForLine(0)-m.STAVE_LINE_THICKNESS/2}getBottomLineBottomY(){return this.getYForLine(this.getNumLines()-1)+m.STAVE_LINE_THICKNESS/2}setX(e){const a=e-this.x;this.formatted=!1,this.x=e,this.start_x+=a,this.end_x+=a;for(let b=0;bb.getWidth()&&(a-=b.getWidth()),a}setRepetitionTypeLeft(e,a){return this.modifiers.push(new Fe(e,this.x,a)),this}setRepetitionTypeRight(e,a){return this.modifiers.push(new Fe(e,this.x,a)),this}setVoltaType(e,a,b){return this.modifiers.push(new ot(e,a,this.x,b)),this}setSection(e,a,b=0,w=12){const C=new Ke(e,this.x+b,a);return C.font.size=w,this.modifiers.push(C),this}setTempo(e,a){return this.modifiers.push(new st(e,this.x,a)),this}setText(e,a,b){return this.modifiers.push(new at(e,a,b)),this}getHeight(){return this.height}getSpacingBetweenLines(){return this.options.spacing_between_lines_px}getBoundingBox(){return new h(this.x,this.y,this.width,this.getBottomY()-this.y)}getBottomY(){const e=this.options,a=e.spacing_between_lines_px;return this.getYForLine(e.num_lines)+e.space_below_staff_ln*a}getBottomLineY(){return this.getYForLine(this.options.num_lines)}getYForLine(e){const a=this.options,b=a.spacing_between_lines_px,w=a.space_above_staff_ln;return this.y+e*b+w*b}getLineForY(e){const a=this.options,b=a.spacing_between_lines_px,w=a.space_above_staff_ln;return(e-this.y)/b-w}getYForTopText(e){const a=e||0;return this.getYForLine(-a-this.options.top_text_position)}getYForBottomText(e){const a=e||0;return this.getYForLine(this.options.bottom_text_position+a)}getYForNote(e){const a=this.options,b=a.spacing_between_lines_px,w=a.space_above_staff_ln;return this.y+w*b+5*b-e*b}getYForGlyphs(){return this.getYForLine(3)}addModifier(e,a){return a!==void 0&&e.setPosition(a),e.setStave(this),this.formatted=!1,this.modifiers.push(e),this}addEndModifier(e){return this.addModifier(e,Be.Position.END),this}setBegBarType(e){const{SINGLE:a,REPEAT_BEGIN:b,NONE:w}=Ie.type;return e!==a&&e!==b&&e!==w||(this.modifiers[0].setType(e),this.formatted=!1),this}setEndBarType(e){return e!==Ie.type.REPEAT_BEGIN&&(this.modifiers[1].setType(e),this.formatted=!1),this}setClef(e,a,b,w){w===void 0&&(w=Be.Position.BEGIN),w===Be.Position.END?this.endClef=e:this.clef=e;const C=this.getModifiers(w,et.CATEGORY);return C.length===0?this.addClef(e,a,b,w):C[0].setType(e,a,b),this}setEndClef(e,a,b){return this.setClef(e,a,b,Be.Position.END),this}setKeySignature(e,a,b){b===void 0&&(b=Be.Position.BEGIN);const w=this.getModifiers(b,We.CATEGORY);return w.length===0?this.addKeySignature(e,a,b):w[0].setKeySig(e,a),this}setEndKeySignature(e,a){return this.setKeySignature(e,a,Be.Position.END),this}setTimeSignature(e,a,b){b===void 0&&(b=Be.Position.BEGIN);const w=this.getModifiers(b,Xe.CATEGORY);return w.length===0?this.addTimeSignature(e,a,b):w[0].setTimeSig(e),this}setEndTimeSignature(e,a){return this.setTimeSignature(e,a,Be.Position.END),this}addKeySignature(e,a,b){return b===void 0&&(b=Be.Position.BEGIN),this.addModifier(new We(e,a).setPosition(b),b),this}addClef(e,a,b,w){return w===void 0||w===Be.Position.BEGIN?this.clef=e:w===Be.Position.END&&(this.endClef=e),this.addModifier(new et(e,a,b),w),this}addEndClef(e,a,b){return this.addClef(e,a,b,Be.Position.END),this}addTimeSignature(e,a,b){return this.addModifier(new Xe(e,a),b),this}addEndTimeSignature(e,a){return this.addTimeSignature(e,a,Be.Position.END),this}addTrebleGlyph(){return this.addClef("treble"),this}getModifiers(e,a){return e===void 0&&a===void 0?this.modifiers:this.modifiers.filter(b=>!(e!==void 0&&e!==b.getPosition()||a!==void 0&&a!==b.getCategory()))}sortByCategory(e,a){for(let b=e.length-1;b>=0;b--)for(let w=0;wa[e[w+1].getCategory()]){const C=e[w];e[w]=e[w+1],e[w+1]=C}}format(){const e=this.modifiers[0],a=this.modifiers[1],b=this.getModifiers(Be.Position.BEGIN),w=this.getModifiers(Be.Position.END);let C,V,z;this.sortByCategory(b,{barlines:0,clefs:1,keysignatures:2,timesignatures:3}),this.sortByCategory(w,{timesignatures:0,keysignatures:1,barlines:2,clefs:3}),b.length>1&&e.getType()===Ie.type.REPEAT_BEGIN&&(b.push(b.splice(0,1)[0]),b.splice(0,0,new Ie(Ie.type.SINGLE))),w.indexOf(a)>0&&w.splice(0,0,new Ie(Ie.type.NONE));let J=0,Z=this.x;for(let le=0;leZ?Z=he:z.setX(Z),Z+=C,V+C===0&&J--}Z>this.start_x&&this.setStartX(Z),Z=this.x+this.width;const re={left:0,right:0,paddingRight:0,paddingLeft:0};let ae=0;for(let le=0;le0){this.context.save(),this.context.setFont(this.font.family,this.font.size,this.font.weight);const C=this.context.measureText(""+this.measure).width;w=this.getYForTopText(0)+3,this.context.fillText(""+this.measure,this.x-C/2,w),this.context.restore()}return this}drawVertical(e,a){this.drawVerticalFixed(this.x+e,a)}drawVerticalFixed(e,a){this.checkContext();const b=this.getYForLine(0),w=this.getYForLine(this.options.num_lines-1);a&&this.context.fillRect(e-3,b,1,w-b+1),this.context.fillRect(e,b,1,w-b+1)}drawVerticalBar(e){this.drawVerticalBarFixed(this.x+e,!1)}drawVerticalBarFixed(e){this.checkContext();const a=this.getYForLine(0),b=this.getYForLine(this.options.num_lines-1);this.context.fillRect(e,a,1,b-a+1)}getConfigForLines(){return this.options.line_config}setConfigForLine(e,a){if(e>=this.options.num_lines||e<0)throw new l.RERR("StaveConfigError","The line number must be within the range of the number of lines in the Stave.");if(a.visible===void 0)throw new l.RERR("StaveConfigError","The line configuration object is missing the 'visible' property.");if(typeof a.visible!="boolean")throw new l.RERR("StaveConfigError","The line configuration objects 'visible' property must be true or false.");return this.options.line_config[e]=a,this}setConfigForLines(e){if(e.length!==this.options.num_lines)throw new l.RERR("StaveConfigError","The length of the lines configuration array must match the number of lines in the Stave");for(const a in e)e[a]||(e[a]=this.options.line_config[a]),l.Merge(this.options.line_config[a],e[a]);return this.options.line_config=e,this}}class He extends ze{constructor(e,a,b,w){const C={spacing_between_lines_px:13,num_lines:6,top_text_position:1};l.Merge(C,w),super(e,a,b,C),this.setAttribute("type","TabStave")}getYForGlyphs(){return this.getYForLine(2.5)}addTabGlyph(){return this.addClef("tab"),this}}class Je extends G{static get CATEGORY(){return"tabnotes"}constructor(e,a){if(super(e),this.setAttribute("type","TabNote"),this.ghost=!1,this.positions=e.positions,l.Merge(this.render_options,{glyph_font_scale:m.DEFAULT_TABLATURE_FONT_SCALE,draw_stem:a,draw_dots:a,draw_stem_through_stave:!1,y_shift:0,scale:1,font:"10pt Arial"}),this.glyph=m.getGlyphProps(this.duration,this.noteType),!this.glyph)throw new l.RuntimeError("BadArguments",`Invalid note initialization data (No glyph found): ${JSON.stringify(e)}`);this.buildStem(),e.stem_direction?this.setStemDirection(e.stem_direction):this.setStemDirection(L.UP),this.ghost=!1,this.updateWidth()}reset(){this.stave&&this.setStave(this.stave)}getCategory(){return Je.CATEGORY}setGhost(e){return this.ghost=e,this.updateWidth(),this}hasStem(){return this.render_options.draw_stem}getStemExtension(){const e=this.getGlyph();return this.stem_extension_override!=null?this.stem_extension_override:e?this.getStemDirection()===1?e.tabnote_stem_up_extension:e.tabnote_stem_down_extension:0}addDot(){const e=new X;return this.dots+=1,this.addModifier(e,0)}updateWidth(){this.glyphs=[],this.width=0;for(let e=0;ethis.width}setStave(e){let a;if(super.setStave(e),this.context=e.context,this.context){const w=this.context;for(this.width=0,a=0;aC.width),this.width=Math.max(C.getWidth(),this.width)}this.glyph.getWidth=()=>this.width}const b=this.positions.map(({str:w})=>e.getYForLine(w-1));return this.setYs(b),this.stem&&this.stem.setYBounds(this.getStemY(),this.getStemY()),this}getPositions(){return this.positions}addToModifierContext(e){this.setModifierContext(e);for(let a=0;a{(e.getCategory()!=="dots"||this.render_options.draw_dots)&&(e.setContext(this.context),e.drawWithStyle())})}drawStemThrough(){const e=this.getStemX(),a=this.getStemY(),b=this.context,w=this.render_options.draw_stem_through_stave;if(this.render_options.draw_stem&&w){const C=function(z,J){const Z=[];let re=[];for(let ae=1;ae<=z;ae++)J.indexOf(ae)>-1?(Z.push(re),re=[]):re.push(ae);return re.length>0&&Z.push(re),Z}(this.stave.getNumLines(),this.positions.map(z=>z.str)),V=function(z,J,Z,re){const ae=re!==1,le=re!==-1,he=Z.getSpacingBetweenLines(),pe=Z.getNumLines(),ge=[];return J.forEach(me=>{const Ee=me.indexOf(pe)>-1,Re=me.indexOf(1)>-1;if(ae&&Re||le&&Ee)return;me.length===1&&me.push(me[0]);const we=[];me.forEach((Ne,De,Oe)=>{const ke=Ne===1,Ue=Ne===pe;let Ge=Z.getYForLine(Ne-1);De!==0||ke?De!==Oe.length-1||Ue||(Ge+=he/2-1):Ge-=he/2-1,we.push(Ge),re===1&&ke?we.push(z-2):re===-1&&Ue&&we.push(z+2)}),ge.push(we.sort((Ne,De)=>Ne-De))}),ge}(a,C,this.getStave(),this.getStemDirection());b.save(),b.setLineWidth(L.WIDTH),V.forEach(z=>{z.length!==0&&(b.beginPath(),b.moveTo(e,z[0]),b.lineTo(e,z[z.length-1]),b.stroke(),b.closePath())}),b.restore()}}drawPositions(){var w,C;const e=this.context,a=this.getAbsoluteX(),b=this.ys;for(let V=0;V=1&&z[0].getCategory()==="barlines"&&(C-=z[0].getPadding()),isNaN(this.render_options.padding_left)||(w=a.getX()+this.render_options.padding_left),isNaN(this.render_options.padding_right)||(C=a.getX()+a.getWidth()-this.render_options.padding_right),this.xs.left=w,this.xs.right=C,this.render_options.use_symbols?this.drawSymbols(e,w,C,b):this.drawLine(e,w,C,b),this.render_options.show_number){const J="/"+this.number_of_measures,Z=new Xe(null,void 0,!1);Z.point=this.render_options.number_glyph_point,Z.setTimeSig(J),Z.setStave(a),Z.x=w+.5*(C-w)-.5*Z.timeSig.glyph.getMetrics().width,Z.bottomLine=this.render_options.number_line,Z.setContext(e).draw()}}}class mt extends j{static get CATEGORY(){return"clefnote"}constructor(e,a,b){super({duration:"b"}),this.setAttribute("type","ClefNote"),this.setType(e,a,b),this.ignore_ticks=!0}setType(e,a,b){return this.type=e,this.clef_obj=new et(e,a,b),this.clef=this.clef_obj.clef,this.glyph=new p(this.clef.code,this.clef.point),this.setWidth(this.glyph.getMetrics().width),this}getClef(){return this.clef}setContext(e){return this.context=e,this.glyph.setContext(this.context),this}getBoundingBox(){return super.getBoundingBox()}addToModifierContext(){return this}getCategory(){return mt.CATEGORY}preFormat(){return this.setPreFormatted(!0),this}draw(){if(!this.stave)throw new l.RERR("NoStave","Can't draw without a stave.");this.glyph.getContext()||this.glyph.setContext(this.context),this.setRendered();const e=this.getAbsoluteX();if(this.glyph.setStave(this.stave),this.glyph.setYShift(this.stave.getYForLine(this.clef.line)-this.stave.getYForGlyphs()),this.glyph.renderToStave(e),this.clef_obj.annotation!==void 0){const a=new p(this.clef_obj.annotation.code,this.clef_obj.annotation.point);a.getContext()||a.setContext(this.context),a.setStave(this.stave),a.setYShift(this.stave.getYForLine(this.clef_obj.annotation.line)-this.stave.getYForGlyphs()),a.setXShift(this.clef_obj.annotation.x_shift),a.renderToStave(e)}}}class _t extends j{constructor(e,a,b){super({duration:"b"}),this.setAttribute("type","KeySigNote"),this.keySignature=new We(e,a,b),this.ignore_ticks=!0}getBoundingBox(){return super.getBoundingBox()}addToModifierContext(){return this}preFormat(){return this.setPreFormatted(!0),this.keySignature.setStave(this.stave),this.keySignature.format(),this.setWidth(this.keySignature.width),this}draw(){this.stave.checkContext(),this.setRendered(),this.keySignature.x=this.getAbsoluteX(),this.keySignature.setContext(this.context),this.keySignature.draw()}}class Xt extends j{constructor(e,a){super({duration:"b"}),this.setAttribute("type","TimeSigNote");const b=new Xe(e,a);this.timeSig=b.getTimeSig(),this.setWidth(this.timeSig.glyph.getMetrics().width),this.ignore_ticks=!0}getBoundingBox(){return super.getBoundingBox()}addToModifierContext(){return this}preFormat(){return this.setPreFormatted(!0),this}draw(){this.stave.checkContext(),this.setRendered(),this.timeSig.glyph.getContext()||this.timeSig.glyph.setContext(this.context),this.timeSig.glyph.setStave(this.stave),this.timeSig.glyph.setYShift(this.stave.getYForLine(this.timeSig.line)-this.stave.getYForGlyphs()),this.timeSig.glyph.renderToStave(this.getAbsoluteX())}}class ut extends U{static get SLIDE_UP(){return 1}static get SLIDE_DOWN(){return-1}static createSlideUp(e){return new ut(e,ut.SLIDE_UP)}static createSlideDown(e){return new ut(e,ut.SLIDE_DOWN)}constructor(e,a){if(super(e,"sl."),this.setAttribute("type","TabSlide"),!a){const b=e.first_note.getPositions()[0].fret,w=e.last_note.getPositions()[0].fret;a=parseInt(b,10)>parseInt(w,10)?ut.SLIDE_DOWN:ut.SLIDE_UP}this.slide_direction=a,this.render_options.cp1=11,this.render_options.cp2=14,this.render_options.y_shift=.5,this.setFont({font:"Times",size:10,style:"bold italic"}),this.setNotes(e)}renderTie(e){if(e.first_ys.length===0||e.last_ys.length===0)throw new l.RERR("BadArguments","No Y-values to render");const a=this.context,b=e.first_x_px,w=e.first_ys,C=e.last_x_px,V=this.slide_direction;if(V!==ut.SLIDE_UP&&V!==ut.SLIDE_DOWN)throw new l.RERR("BadSlide","Invalid slide direction");for(let z=0;zthis.numStrings)throw new l.RERR("BadArguments",`String number must be between 1 and ${this.numStrings}:${e}`);return this.tuningValues[a-1]}getValueForFret(e,a){const b=this.getValueForString(a),w=parseInt(e,10);if(w<0)throw new l.RERR("BadArguments","Fret number must be 0 or higher: "+e);return b+w}getNoteForFret(e,a){const b=this.getValueForFret(e,a),w=Math.floor(b/12),C=b%12;return m.integerToNote(C)+"/"+w}}class Lt extends o{static get type(){return{CRESC:1,DECRESC:2}}static FormatByTicksAndDraw(e,a,b,w,C,V){const z=a.pixelsPerTick;if(z==null)throw new l.RuntimeError("BadArguments","A valid Formatter must be provide to draw offsets by ticks.");const J=z*V.left_shift_ticks,Z=z*V.right_shift_ticks,re={height:V.height,y_shift:V.y_shift,left_shift_px:J,right_shift_px:Z};new Lt({first_note:b.first_note,last_note:b.last_note},w).setContext(e).setRenderOptions(re).setPosition(C).draw()}constructor(e,a){super(),this.setAttribute("type","StaveHairpin"),this.notes=e,this.hairpin=a,this.position=Y.Position.BELOW,this.render_options={height:10,y_shift:0,left_shift_px:0,right_shift_px:0},this.setNotes(e)}setPosition(e){return e!==Y.Position.ABOVE&&e!==Y.Position.BELOW||(this.position=e),this}setRenderOptions(e){return e.height!=null&&e.y_shift!=null&&e.left_shift_px!=null&&e.right_shift_px!=null&&(this.render_options=e),this}setNotes(e){if(!e.first_note&&!e.last_note)throw new l.RuntimeError("BadArguments","Hairpin needs to have either first_note or last_note set.");return this.first_note=e.first_note,this.last_note=e.last_note,this}renderHairpin(e){const a=this.checkContext();let b=this.render_options.y_shift+20,w=e.first_y;this.position===Y.Position.ABOVE&&(b=30-b,w=e.first_y-e.staff_height);const C=this.render_options.left_shift_px,V=this.render_options.right_shift_px;switch(a.beginPath(),this.hairpin){case Lt.type.CRESC:a.moveTo(e.last_x+V,w+b),a.lineTo(e.first_x+C,w+this.render_options.height/2+b),a.lineTo(e.last_x+V,w+this.render_options.height+b);break;case Lt.type.DECRESC:a.moveTo(e.first_x+C,w+b),a.lineTo(e.last_x+V,w+this.render_options.height/2+b),a.lineTo(e.first_x+C,w+this.render_options.height+b)}a.stroke(),a.closePath()}draw(){this.checkContext(),this.setRendered();const e=this.first_note,a=this.last_note,b=e.getModifierStartXY(this.position,0),w=a.getModifierStartXY(this.position,0);return this.renderHairpin({first_x:b.x,last_x:w.x,first_y:e.getStave().y+e.getStave().height,last_y:a.getStave().y+a.getStave().height,staff_height:e.getStave().height}),!0}}class lt extends o{static get Position(){return{NEAR_HEAD:1,NEAR_TOP:2}}static get PositionString(){return{nearHead:lt.Position.NEAR_HEAD,nearTop:lt.Position.NEAR_TOP}}constructor(e,a,b){super(),this.setAttribute("type","Curve"),this.render_options={spacing:2,thickness:2,x_shift:0,y_shift:10,position:lt.Position.NEAR_HEAD,position_end:lt.Position.NEAR_HEAD,invert:!1,cps:[{x:0,y:10},{x:0,y:10}]},l.Merge(this.render_options,b),this.setNotes(e,a)}setNotes(e,a){if(!e&&!a)throw new l.RuntimeError("BadArguments","Curve needs to have either first_note or last_note set.");return this.from=e,this.to=a,this}isPartial(){return!this.from||!this.to}renderCurve(e){const a=this.context,b=this.render_options.cps,w=this.render_options.x_shift,C=this.render_options.y_shift*e.direction,V=e.first_x+w,z=e.first_y+C,J=e.last_x-w,Z=e.last_y+C,re=this.render_options.thickness,ae=(J-V)/(b.length+2);a.beginPath(),a.moveTo(V,z),a.bezierCurveTo(V+ae+b[0].x,z+b[0].y*e.direction,J-ae+b[1].x,Z+b[1].y*e.direction,J,Z),a.bezierCurveTo(J-ae+b[1].x,Z+(b[1].y+re)*e.direction,V+ae+b[0].x,z+(b[0].y+re)*e.direction,V,z),a.stroke(),a.closePath(),a.fill()}draw(){this.checkContext(),this.setRendered();const e=this.from,a=this.to;let b,w,C,V,z,J="baseY",Z="baseY";function re(he){return typeof he=="string"?lt.PositionString[he]:he}const ae=re(this.render_options.position),le=re(this.render_options.position_end);return ae===lt.Position.NEAR_TOP&&(J="topY",Z="topY"),le===lt.Position.NEAR_HEAD?Z="baseY":le===lt.Position.NEAR_TOP&&(Z="topY"),e?(b=e.getTieRightX(),z=e.getStemDirection(),C=e.getStemExtents()[J]):(b=a.getStave().getTieStartX(),C=a.getStemExtents()[J]),a?(w=a.getTieLeftX(),z=a.getStemDirection(),V=a.getStemExtents()[Z]):(w=e.getStave().getTieEndX(),V=e.getStemExtents()[Z]),this.renderCurve({first_x:b,last_x:w,first_y:C,last_y:V,direction:z*(this.render_options.invert===!0?-1:1)}),!0}}function jt(...ce){xt.DEBUG&&l.L("Vex.Flow.TextDynamics",ce)}class xt extends j{static get GLYPHS(){return{f:{code:"vba",width:12},p:{code:"vbf",width:14},m:{code:"v62",width:17},s:{code:"v4a",width:10},z:{code:"v80",width:12},r:{code:"vb1",width:12}}}constructor(e){super(e),this.setAttribute("type","TextDynamics"),this.sequence=e.text.toLowerCase(),this.line=e.line||0,this.glyphs=[],l.Merge(this.render_options,{glyph_font_size:40}),jt("New Dynamics Text: ",this.sequence)}setLine(e){return this.line=e,this}preFormat(){let e=0;return this.sequence.split("").forEach(a=>{const b=xt.GLYPHS[a];if(!b)throw new l.RERR("Invalid dynamics character: "+a);const w=this.render_options.glyph_font_size,C=new p(b.code,w);this.glyphs.push(C),e+=b.width}),this.setWidth(e),this.preFormatted=!0,this}draw(){this.setRendered();const e=this.getAbsoluteX(),a=this.stave.getYForLine(this.line+-3);jt("Rendering Dynamics: ",this.sequence);let b=e;this.glyphs.forEach((w,C)=>{const V=this.sequence[C];w.render(this.context,b,a),b+=xt.GLYPHS[V].width})}}function Yt(ce,e,a,b,w,C,V){ce.beginPath(),ce.moveTo(e,a),ce.lineTo(b,w),ce.lineTo(C,V),ce.lineTo(e,a),ce.closePath(),ce.fill()}class ct extends o{static get TextVerticalPosition(){return{TOP:1,BOTTOM:2}}static get TextJustification(){return{LEFT:1,CENTER:2,RIGHT:3}}constructor(e){super(),this.setAttribute("type","StaveLine"),this.notes=e,this.text="",this.font={family:"Arial",size:10,weight:""},this.render_options={padding_left:4,padding_right:3,line_width:1,line_dash:null,rounded_end:!0,color:null,draw_start_arrow:!1,draw_end_arrow:!1,arrowhead_length:10,arrowhead_angle:Math.PI/8,text_position_vertical:ct.TextVerticalPosition.TOP,text_justification:ct.TextJustification.CENTER},this.setNotes(e)}setFont(e){return this.font=e,this}setText(e){return this.text=e,this}setNotes(e){if(!e.first_note&&!e.last_note)throw new l.RuntimeError("BadArguments","Notes needs to have either first_note or last_note set.");if(e.first_indices||(e.first_indices=[0]),e.last_indices||(e.last_indices=[0]),e.first_indices.length!==e.last_indices.length)throw new l.RuntimeError("BadArguments","Connected notes must have similar index sizes");return this.first_note=e.first_note,this.first_indices=e.first_indices,this.last_note=e.last_note,this.last_indices=e.last_indices,this}applyLineStyle(){const e=this.checkContext(),a=this.render_options;a.line_dash&&e.setLineDash(a.line_dash),a.line_width&&e.setLineWidth(a.line_width),a.rounded_end?e.setLineCap("round"):e.setLineCap("square")}applyFontStyle(){const e=this.checkContext();this.font&&e.setFont(this.font.family,this.font.size,this.font.weight),this.render_options.color&&(e.setStrokeStyle(this.render_options.color),e.setFillStyle(this.render_options.color))}draw(){const e=this.checkContext();this.setRendered();const a=this.first_note,b=this.last_note,w=this.render_options;let C,V;e.save(),this.applyLineStyle(),this.first_indices.forEach((le,he)=>{const pe=this.last_indices[he];C=a.getModifierStartXY(2,le),V=b.getModifierStartXY(1,pe);const ge=C.y>V.y;C.x+=a.getMetrics().modRightPx+w.padding_left,V.x-=b.getMetrics().modLeftPx+w.padding_right;const me=a.getGlyph().getWidth();a.getKeyProps()[le].displaced&&a.getStemDirection()===1&&(C.x+=me+w.padding_left),b.getKeyProps()[pe].displaced&&b.getStemDirection()===-1&&(V.x-=me+w.padding_right),C.y+=ge?-3:1,V.y+=ge?2:0,function(Ee,Re,we,Ne){const De=Ne.draw_start_arrow&&Ne.draw_end_arrow,Oe=Re.x,ke=Re.y,Ue=we.x,Ge=we.y,nt=Math.sqrt((Ue-Oe)*(Ue-Oe)+(Ge-ke)*(Ge-ke)),Qe=(nt-Ne.arrowhead_length/3)/nt;let $e,ht,ft,Rt;Ne.draw_end_arrow||De?($e=Math.round(Oe+(Ue-Oe)*Qe),ht=Math.round(ke+(Ge-ke)*Qe)):($e=Ue,ht=Ge),Ne.draw_start_arrow||De?(ft=Oe+(Ue-Oe)*(1-Qe),Rt=ke+(Ge-ke)*(1-Qe)):(ft=Oe,Rt=ke),Ne.color&&(Ee.setStrokeStyle(Ne.color),Ee.setFillStyle(Ne.color)),Ee.beginPath(),Ee.moveTo(ft,Rt),Ee.lineTo($e,ht),Ee.stroke(),Ee.closePath();const vt=Math.atan2(Ge-ke,Ue-Oe),St=Math.abs(Ne.arrowhead_length/Math.cos(Ne.arrowhead_angle));let Mt,Tt,Ft,Dt,Ot,kt;(Ne.draw_end_arrow||De)&&(Mt=vt+Math.PI+Ne.arrowhead_angle,Ft=Ue+Math.cos(Mt)*St,Dt=Ge+Math.sin(Mt)*St,Tt=vt+Math.PI-Ne.arrowhead_angle,Ot=Ue+Math.cos(Tt)*St,kt=Ge+Math.sin(Tt)*St,Yt(Ee,Ft,Dt,Ue,Ge,Ot,kt)),(Ne.draw_start_arrow||De)&&(Mt=vt+Ne.arrowhead_angle,Ft=Oe+Math.cos(Mt)*St,Dt=ke+Math.sin(Mt)*St,Tt=vt-Ne.arrowhead_angle,Ot=Oe+Math.cos(Tt)*St,kt=ke+Math.sin(Tt)*St,Yt(Ee,Ft,Dt,Oe,ke,Ot,kt))}(e,C,V,this.render_options)}),e.restore();const z=e.measureText(this.text).width,J=w.text_justification;let Z,re=0;J===ct.TextJustification.LEFT?re=C.x:J===ct.TextJustification.CENTER?re=(V.x-C.x)/2+C.x-z/2:J===ct.TextJustification.RIGHT&&(re=V.x-z);const ae=w.text_position_vertical;return ae===ct.TextVerticalPosition.TOP?Z=a.getStave().getYForTopText():ae===ct.TextVerticalPosition.BOTTOM&&(Z=a.getStave().getYForBottomText(m.TEXT_HEIGHT_OFFSET_HACK)),e.save(),this.applyFontStyle(),e.fillText(this.text,re,Z),e.restore(),this}}function Ut(ce,e,a,b,w){const C=Ve.GLYPHS[ce];new p(C.code,w).render(e,a+C.x_shift,b+C.y_shift)}class Ve extends o{static get GLYPHS(){return{pedal_depress:{code:"v36",x_shift:-10,y_shift:0},pedal_release:{code:"v5d",x_shift:-2,y_shift:3}}}static get Styles(){return{TEXT:1,BRACKET:2,MIXED:3,MIXED_OPEN_END:4,BRACKET_OPEN_BEGIN:5,BRACKET_OPEN_END:6,BRACKET_OPEN_BOTH:7}}static get StylesString(){return{text:Ve.Styles.TEXT,bracket:Ve.Styles.BRACKET,mixed:Ve.Styles.MIXED,mixed_open_end:Ve.Styles.MIXED_OPEN_END,bracket_open_begin:Ve.Styles.BRACKET_OPEN_BEGIN,bracket_open_end:Ve.Styles.BRACKET_OPEN_END,bracket_open_both:Ve.Styles.BRACKET_OPEN_BOTH}}static createSustain(e){return new Ve(e)}static createSostenuto(e){const a=new Ve(e);return a.setStyle(Ve.Styles.MIXED),a.setCustomText("Sost. Ped."),a}static createUnaCorda(e){const a=new Ve(e);return a.setStyle(Ve.Styles.TEXT),a.setCustomText("una corda","tre corda"),a}constructor(e){super(),this.setAttribute("type","PedalMarking"),this.EndsStave=!1,this.ChangeBegin=!1,this.ChangeEnd=!1,this.notes=e,this.style=Ve.TEXT,this.line=0,this.custom_depress_text="",this.custom_release_text="",this.font={family:"Times New Roman",size:12,weight:"italic bold"},this.render_options={bracket_height:10,text_margin_right:6,bracket_line_width:1,glyph_point_size:40,color:"black"}}setEndStave(e){if(this.endStave=e,this.endStaveAddedWidth=0,this.startMargin=0,this.endMargin=0,Array.isArray(this.endStave.modifiers))for(let a=0;a3)throw new l.RERR("InvalidParameter","The style must be one found in PedalMarking.Styles");return this.style=e,this}setLine(e){return this.line=e,this}drawBracketed(){const e=this.context;let a,b,w=!1;const C=this;this.notes.forEach((V,z,J)=>{w=!w;let Z=0;if(V?(Z=V.getNoteHeadBeginX(),this.BeginsStave&&(Z=V.getStave().getNoteStartX())):Z=this.endStave.end_x+this.endStaveAddedWidth,this.EndsStave)w?this.ChangeBegin&&(Z=V.getAbsoluteX()):(Z=V?this.ChangeEnd?V.getAbsoluteX():V.getStave().end_x+this.endStaveAddedWidth-C.render_options.text_margin_right:this.endStave.end_x+this.endStaveAddedWidth-C.render_options.text_margin_right,this.endMargin=-C.render_options.text_margin_right);else if(V)if(w)this.ChangeBegin&&(Z=V.getAbsoluteX());else switch(C.style){case Ve.Styles.BRACKET_OPEN_END:case Ve.Styles.BRACKET_OPEN_BOTH:case Ve.Styles.MIXED_OPEN_END:Z=V.getNoteHeadEndX();break;default:this.ChangeEnd?Z=V.getAbsoluteX():(Z=V.getNoteHeadBeginX()-C.render_options.text_margin_right,this.startMargin=-C.render_options.text_margin_right)}let re=this.endStave;V&&(re=V.getStave());let ae=re.getYForBottomText(C.line+3);b&&b>ae&&(ae=b);const le=J[z+1]===V,he=J[z-1]===V;let pe=0;if(w)if(pe=he?5:0,C.style!==Ve.Styles.MIXED&&C.style!==Ve.Styles.MIXED_OPEN_END||he)e.beginPath(),C.style===Ve.Styles.BRACKET_OPEN_BEGIN||C.style===Ve.Styles.BRACKET_OPEN_BOTH?e.moveTo(Z+pe,ae):(this.ChangeBegin&&(Z+=5),e.moveTo(Z,ae-C.render_options.bracket_height),this.ChangeBegin&&(Z+=5),e.lineTo(Z+pe,ae)),e.stroke(),e.closePath();else if(C.custom_depress_text){const ge=e.measureText(C.custom_depress_text).width;e.fillText(C.custom_depress_text,Z-ge/2,ae),pe=ge/2+C.render_options.text_margin_right}else Ut("pedal_depress",e,Z,ae,C.render_options.glyph_point_size),pe=20+C.render_options.text_margin_right;else pe=le&&!this.EndsStave?-5:0,e.beginPath(),e.moveTo(a,b),e.lineTo(Z+pe,ae),C.style!==Ve.Styles.BRACKET_OPEN_END&&C.style!==Ve.Styles.MIXED_OPEN_END&&C.style!==Ve.Styles.BRACKET_OPEN_BOTH&&(this.ChangeEnd&&(Z+=5),e.lineTo(Z,ae-C.render_options.bracket_height)),e.stroke(),e.closePath();a=Z+pe,b=ae})}drawText(){const e=this.context;let a=!1;const b=this,w=b.render_options.glyph_point_size;this.notes.forEach(C=>{if(!C)return;a=!a;const V=C.getStave(),z=C.getAbsoluteX(),J=V.getYForBottomText(b.line+3);let Z=0;a?b.custom_depress_text?(Z=e.measureText(b.custom_depress_text).width,e.fillText(b.custom_depress_text,z-Z/2,J)):Ut("pedal_depress",e,z,J,w):b.custom_release_text?(Z=e.measureText(b.custom_release_text).width,e.fillText(b.custom_release_text,z-Z/2,J)):Ut("pedal_release",e,z,J,w)})}draw(){const e=this.checkContext();this.setRendered(),e.save(),e.setStrokeStyle(this.render_options.color),e.setFillStyle(this.render_options.color),e.setFont(this.font.family,this.font.size,this.font.weight),Ve.DEBUG&&l.L("Vex.Flow.PedalMarking",["Rendering Pedal Marking"]),this.style===Ve.Styles.BRACKET||this.style===Ve.Styles.MIXED||this.style===Ve.Styles.MIXED_OPEN_END||this.style===Ve.Styles.BRACKET_OPEN_BEGIN||this.style===Ve.Styles.BRACKET_OPEN_END||this.style===Ve.Styles.BRACKET_OPEN_BOTH?(e.setLineWidth(this.render_options.bracket_line_width),this.drawBracketed()):this.style===Ve.Styles.TEXT&&this.drawText(),e.restore()}}class it extends o{static get Positions(){return{TOP:1,BOTTOM:-1}}static get PositionString(){return{top:it.Positions.TOP,bottom:it.Positions.BOTTOM}}constructor({start:e,stop:a,text:b="",superscript:w="",position:C=it.Positions.TOP}){super(),this.setAttribute("type","TextBracket"),this.start=e,this.stop=a,this.text=b,this.superscript=w,this.position=typeof C=="string"?it.PositionString[C]:C,this.line=1,this.font={family:"Serif",size:15,weight:"italic"},this.render_options={dashed:!0,dash:[5],color:"black",line_width:1,show_bracket:!0,bracket_height:8,underline_superscript:!0}}applyStyle(e){return e.setFont(this.font.family,this.font.size,this.font.weight),e.setStrokeStyle(this.render_options.color),e.setFillStyle(this.render_options.color),e.setLineWidth(this.render_options.line_width),this}setDashed(e,a){return this.render_options.dashed=e,a&&(this.render_options.dash=a),this}setFont(e){return this.font={...this.font,...e},this}setLine(e){return this.line=e,this}draw(){const e=this.context;this.setRendered();let a=0;switch(this.position){case it.Positions.TOP:a=this.start.getStave().getYForTopText(this.line);break;case it.Positions.BOTTOM:a=this.start.getStave().getYForBottomText(this.line+m.TEXT_HEIGHT_OFFSET_HACK);break;default:throw new l.RERR("InvalidPosition",`The position ${this.position} is invalid`)}const b={x:this.start.getAbsoluteX(),y:a},w={x:this.stop.getAbsoluteX(),y:a};(function(...pe){it.DEBUG&&l.L("Vex.Flow.TextBracket",pe)})("Rendering TextBracket: start:",b,"stop:",w,"y:",a);const C=this.render_options.bracket_height*this.position;e.save(),this.applyStyle(e),e.fillText(this.text,b.x,b.y);let V=e.measureText(this.text).width;V>0||(V=10*this.text.length);let z=e.measureText("M").width;z>0||(z=20);const J=b.y-z/2.5;e.setFont(this.font.family,this.font.size/1.4,this.font.weight),e.fillText(this.superscript,b.x+V+1,J);let Z=e.measureText(this.superscript).width;Z>0||(Z=12,this.superscript.includes("m")&&(Z+=5));let re=e.measureText("M").width;re>0||(re=10);let ae=b.x,le=J,he=w.x+this.stop.getGlyph().getWidth();this.position===it.Positions.TOP?(ae+=V+Z+5,le-=re/2.7):this.position===it.Positions.BOTTOM&&(le+=re/2.7,ae+=V+2,this.render_options.underline_superscript||(ae+=Z)),this.render_options.dashed?(he0||a===!0;return!a||C>0||(this.pos=w),z?this.matchSuccess():this.matchFail(w),{success:z,results:b,numMatches:C}}expectZeroOrMore(e){return this.expectOneOrMore(e,!0)}expect(e){let a;if(function(...w){Bt.DEBUG&&l.L("Vex.Flow.Parser",w)}("Evaluating rules:",e),!e)throw new qt("Invalid Rule: "+e,e);const b=e.bind(this.grammar)();if(b.token)a=this.matchToken(b.token,b.noSpace===!0),a.success&&(this.pos+=a.incrementPos);else{if(!b.expect)throw new qt("Bad grammar! No `token` or `expect` property",b);a=b.oneOrMore?this.expectOneOrMore(b):b.zeroOrMore?this.expectZeroOrMore(b):this.expectOne(b)}return a.matches=[],a.results&&a.results.forEach(w=>a.matches.push(Nt(w))),b.run&&a.success&&b.run(a),a}}function dt(...ce){Ht.DEBUG&&l.L("Vex.Flow.EasyScore",ce)}const ei=l.MakeException("EasyScoreError");class ti{constructor(e){this.builder=e}begin(){return this.LINE}LINE(){return{expect:[this.PIECE,this.PIECES,this.EOL]}}PIECE(){return{expect:[this.CHORDORNOTE,this.PARAMS],run:()=>this.builder.commitPiece()}}PIECES(){return{expect:[this.COMMA,this.PIECE],zeroOrMore:!0}}PARAMS(){return{expect:[this.DURATION,this.TYPE,this.DOTS,this.OPTS]}}CHORDORNOTE(){return{expect:[this.CHORD,this.SINGLENOTE],or:!0}}CHORD(){return{expect:[this.LPAREN,this.NOTES,this.RPAREN],run:e=>this.builder.addChord(e.matches[1])}}NOTES(){return{expect:[this.NOTE],oneOrMore:!0}}NOTE(){return{expect:[this.NOTENAME,this.ACCIDENTAL,this.OCTAVE]}}SINGLENOTE(){return{expect:[this.NOTENAME,this.ACCIDENTAL,this.OCTAVE],run:e=>this.builder.addSingleNote(e.matches[0],e.matches[1],e.matches[2])}}ACCIDENTAL(){return{expect:[this.ACCIDENTALS],maybe:!0}}DOTS(){return{expect:[this.DOT],zeroOrMore:!0,run:e=>this.builder.setNoteDots(e.matches[0])}}TYPE(){return{expect:[this.SLASH,this.MAYBESLASH,this.TYPES],maybe:!0,run:e=>this.builder.setNoteType(e.matches[2])}}DURATION(){return{expect:[this.SLASH,this.DURATIONS],maybe:!0,run:e=>this.builder.setNoteDuration(e.matches[1])}}OPTS(){return{expect:[this.LBRACKET,this.KEYVAL,this.KEYVALS,this.RBRACKET],maybe:!0}}KEYVALS(){return{expect:[this.COMMA,this.KEYVAL],zeroOrMore:!0}}KEYVAL(){return{expect:[this.KEY,this.EQUALS,this.VAL],run:e=>this.builder.addNoteOption(e.matches[0],e.matches[2].slice(1,-1))}}VAL(){return{expect:[this.SVAL,this.DVAL],or:!0}}KEY(){return{token:"[a-zA-Z][a-zA-Z0-9]*"}}DVAL(){return{token:'["][^"]*["]'}}SVAL(){return{token:"['][^']*[']"}}NOTENAME(){return{token:"[a-gA-G]"}}OCTAVE(){return{token:"[0-9]+"}}ACCIDENTALS(){return{token:"bbs|bb|bss|bs|b|db|d|##|#|n|\\+\\+-|\\+-|\\+\\+|\\+|k|o"}}DURATIONS(){return{token:"[0-9whq]+"}}TYPES(){return{token:"[rRsSxX]"}}LPAREN(){return{token:"[(]"}}RPAREN(){return{token:"[)]"}}COMMA(){return{token:"[,]"}}DOT(){return{token:"[.]"}}SLASH(){return{token:"[/]"}}MAYBESLASH(){return{token:"[/]?"}}EQUALS(){return{token:"[=]"}}LBRACKET(){return{token:"\\["}}RBRACKET(){return{token:"\\]"}}EOL(){return{token:"$"}}}class ii{constructor(e){this.factory=e,this.commitHooks=[],this.reset()}reset(e={}){this.options={stem:"auto",clef:"treble"},this.elements={notes:[],accidentals:[]},this.rollingDuration="8",this.resetPiece(),Object.assign(this.options,e)}getFactory(){return this.factory}getElements(){return this.elements}addCommitHook(e){this.commitHooks.push(e)}resetPiece(){dt("resetPiece"),this.piece={chord:[],duration:this.rollingDuration,dots:0,type:void 0,options:{}}}setNoteDots(e){dt("setNoteDots:",e),e&&(this.piece.dots=e.length)}setNoteDuration(e){dt("setNoteDuration:",e),this.rollingDuration=this.piece.duration=e||this.rollingDuration}setNoteType(e){dt("setNoteType:",e),e&&(this.piece.type=e)}addNoteOption(e,a){dt("addNoteOption: key:",e,"value:",a),this.piece.options[e]=a}addNote(e,a,b){dt("addNote:",e,a,b),this.piece.chord.push({key:e,accid:a,octave:b})}addSingleNote(e,a,b){dt("addSingleNote:",e,a,b),this.addNote(e,a,b)}addChord(e){dt("startChord"),typeof e[0]!="object"?this.addSingleNote(e[0]):e.forEach(a=>{a&&this.addNote(...a)}),dt("endChord")}commitPiece(){dt("commitPiece");const{factory:e}=this;if(!e)return;const a={...this.options,...this.piece.options},{stem:b,clef:w}=a,C=b.toLowerCase()==="auto",V=C||b.toLowerCase()!=="up"?oe.STEM_DOWN:oe.STEM_UP,{chord:z,duration:J,dots:Z,type:re}=this.piece,ae=z.map(pe=>pe.key+"/"+pe.octave),le=e.StaveNote({keys:ae,duration:J,dots:Z,type:re,clef:w,auto_stem:C});C||le.setStemDirection(V);const he=z.map(pe=>pe.accid||null);he.forEach((pe,ge)=>{pe&&le.addAccidental(ge,e.Accidental({type:pe}))});for(let pe=0;pepe(a,le,this)),this.elements.notes.push(le),this.elements.accidentals.concat(he),this.resetPiece()}}function si({id:ce},e){ce!==void 0&&e.setAttribute("id",ce)}function ni(ce,e){ce.class&&ce.class.split(/\s*,\s*/).forEach(a=>e.addClass(a))}class Ht{constructor(e={}){this.setOptions(e),this.defaults={clef:"treble",time:"4/4",stem:"auto"}}set(e){return Object.assign(this.defaults,e),this}setOptions(e){return this.options={factory:null,builder:null,commitHooks:[si,ni,Se.easyScoreHook],throwOnError:!1,...e},this.factory=this.options.factory,this.builder=this.options.builder||new ii(this.factory),this.grammar=new ti(this.builder),this.parser=new Bt(this.grammar),this.options.commitHooks.forEach(a=>this.addCommitHook(a)),this}setContext(e){return this.factory&&this.factory.setContext(e),this}parse(e,a={}){this.builder.reset(a);const b=this.parser.parse(e);if(!b.success&&this.options.throwOnError)throw new ei("Error parsing line: "+e,b);return b}beam(e,a={}){return this.factory.Beam({notes:e,options:a}),e}tuplet(e,a={}){return this.factory.Tuplet({notes:e,options:a}),e}notes(e,a={}){return a={clef:this.defaults.clef,stem:this.defaults.stem,...a},this.parse(e,a),this.builder.getElements().notes}voice(e,a){return a={time:this.defaults.time,...a},this.factory.Voice(a).addTickables(e)}addCommitHook(e){return this.builder.addCommitHook(e)}}const ri=l.MakeException("FactoryError");function Ye(ce={},e){const a=e.options;return(ce=Object.assign(e,ce)).options=Object.assign(a,ce.options),ce}class At{constructor(e){(function(...b){At.DEBUG&&l.L("Vex.Flow.Factory",b)})("New factory: ",e);const a={stave:{space:10},renderer:{context:null,elementId:"",backend:E.Backends.SVG,width:500,height:200,background:"#FFF"},font:{face:"Arial",point:10,style:""}};this.options=a,this.setOptions(e)}static newFromElementId(e,a=500,b=200){return new At({renderer:{elementId:e,width:a,height:b}})}reset(){this.renderQ=[],this.systems=[],this.staves=[],this.voices=[],this.stave=null}getOptions(){return this.options}setOptions(e){for(const a of["stave","renderer","font"])Object.assign(this.options[a],e[a]);(this.options.renderer.elementId!==null||this.options.renderer.context)&&this.initRenderer(),this.reset()}initRenderer(){const{elementId:e,backend:a,width:b,height:w,background:C}=this.options.renderer;if(e==="")throw new ri("HTML DOM element not set in Factory");this.context=E.buildContext(e,a,b,w,C)}getContext(){return this.context}setContext(e){return this.context=e,this}getStave(){return this.stave}getVoices(){return this.voices}space(e){return this.options.stave.space*e}Stave(e){e=Ye(e,{x:0,y:0,width:this.options.renderer.width-this.space(1),options:{spacing_between_lines_px:this.options.stave.space}});const a=new ze(e.x,e.y,e.width,e.options);return this.staves.push(a),a.setContext(this.context),this.stave=a,a}TabStave(e){e=Ye(e,{x:0,y:0,width:this.options.renderer.width-this.space(1),options:{spacing_between_lines_px:1.3*this.options.stave.space}});const a=new He(e.x,e.y,e.width,e.options);return this.staves.push(a),a.setContext(this.context),this.stave=a,a}StaveNote(e){const a=new oe(e);return this.stave&&a.setStave(this.stave),a.setContext(this.context),this.renderQ.push(a),a}GhostNote(e){const a=new Kt(e);return this.stave&&a.setStave(this.stave),a.setContext(this.context),this.renderQ.push(a),a}TextNote(e){const a=new je(e);return this.stave&&a.setStave(this.stave),a.setContext(this.context),this.renderQ.push(a),a}BarNote(e){e=Ye(e,{type:"single",options:{}});const a=new Ct(e.type);return this.stave&&a.setStave(this.stave),a.setContext(this.context),this.renderQ.push(a),a}ClefNote(e){e=Ye(e,{type:"treble",options:{size:"default"}});const a=new mt(e.type,e.options.size,e.options.annotation);return this.stave&&a.setStave(this.stave),a.setContext(this.context),this.renderQ.push(a),a}TimeSigNote(e){e=Ye(e,{time:"4/4",options:{}});const a=new Xt(e.time);return this.stave&&a.setStave(this.stave),a.setContext(this.context),this.renderQ.push(a),a}KeySigNote(e){const a=new _t(e.key,e.cancelKey,e.alterKey);return this.stave&&a.setStave(this.stave),a.setContext(this.context),this.renderQ.push(a),a}TabNote(e){const a=new Je(e);return this.stave&&a.setStave(this.stave),a.setContext(this.context),this.renderQ.push(a),a}GraceNote(e){const a=new yt(e);return this.stave&&a.setStave(this.stave),a.setContext(this.context),a}GraceNoteGroup(e){const a=new H(e.notes,e.slur);return a.setContext(this.context),a}Accidental(e){e=Ye(e,{type:null,options:{}});const a=new N(e.type);return a.setContext(this.context),a}Annotation(e){e=Ye(e,{text:"p",vJustify:"below",hJustify:"center",fontFamily:"Times",fontSize:14,fontWeight:"bold italic",options:{}});const a=new be(e.text);return a.setJustification(e.hJustify),a.setVerticalJustification(e.vJustify),a.setFont(e.fontFamily,e.fontSize,e.fontWeight),a.setContext(this.context),a}Articulation(e){e=Ye(e,{type:"a.",position:"above",options:{}});const a=new Se(e.type);return a.setPosition(e.position),a.setContext(this.context),a}TextDynamics(e){e=Ye(e,{text:"p",duration:"q",dots:0,line:0,options:{}});const a=new xt({text:e.text,line:e.line,duration:e.duration,dots:e.dots});return this.stave&&a.setStave(this.stave),a.setContext(this.context),this.renderQ.push(a),a}Fingering(e){e=Ye(e,{number:"0",position:"left",options:{}});const a=new $(e.number);return a.setPosition(e.position),a.setContext(this.context),a}StringNumber(e){e=Ye(e,{number:"0",position:"left",options:{}});const a=new K(e.number);return a.setPosition(e.position),a.setContext(this.context),a}TickContext(){return new q().setContext(this.context)}ModifierContext(){return new Le}MultiMeasureRest(e){const a=new Pt(e.number_of_measures,e);return a.setContext(this.context),this.renderQ.push(a),a}Voice(e){e=Ye(e,{time:"4/4",options:{}});const a=new D(e.time);return this.voices.push(a),a}StaveConnector(e){e=Ye(e,{top_stave:null,bottom_stave:null,type:"double",options:{}});const a=new F(e.top_stave,e.bottom_stave);return a.setType(e.type).setContext(this.context),this.renderQ.push(a),a}Formatter(){return new Ce}Tuplet(e){e=Ye(e,{notes:[],options:{}});const a=new I(e.notes,e.options).setContext(this.context);return this.renderQ.push(a),a}Beam(e){e=Ye(e,{notes:[],options:{autoStem:!1,secondaryBeamBreaks:[]}});const a=new B(e.notes,e.options.autoStem).setContext(this.context);return a.breakSecondaryAt(e.options.secondaryBeamBreaks),this.renderQ.push(a),a}Curve(e){e=Ye(e,{from:null,to:null,options:{}});const a=new lt(e.from,e.to,e.options).setContext(this.context);return this.renderQ.push(a),a}StaveTie(e){e=Ye(e,{from:null,to:null,first_indices:[0],last_indices:[0],text:null,options:{direction:void 0}});const a=new O({first_note:e.from,last_note:e.to,first_indices:e.first_indices,last_indices:e.last_indices},e.text);return e.options.direction&&a.setDirection(e.options.direction),a.setContext(this.context),this.renderQ.push(a),a}StaveLine(e){e=Ye(e,{from:null,to:null,first_indices:[0],last_indices:[0],options:{}});const a=new ct({first_note:e.from,last_note:e.to,first_indices:e.first_indices,last_indices:e.last_indices});return e.options.text&&a.setText(e.options.text),e.options.font&&a.setFont(e.options.font),a.setContext(this.context),this.renderQ.push(a),a}VibratoBracket(e){e=Ye(e,{from:null,to:null,options:{harsh:!1}});const a=new qe({start:e.from,stop:e.to});return e.options.line&&a.setLine(e.options.line),e.options.harsh&&a.setHarsh(e.options.harsh),a.setContext(this.context),this.renderQ.push(a),a}TextBracket(e){e=Ye(e,{from:null,to:null,text:"",options:{superscript:"",position:1}});const a=new it({start:e.from,stop:e.to,text:e.text,superscript:e.options.superscript,position:e.options.position});return e.options.line&&a.setLine(e.options.line),e.options.font&&a.setFont(e.options.font),a.setContext(this.context),this.renderQ.push(a),a}System(e={}){e.factory=this;const a=new $t(e).setContext(this.context);return this.systems.push(a),a}EasyScore(e={}){return e.factory=this,new Ht(e)}PedalMarking(e={}){e=Ye(e,{notes:[],options:{style:"mixed"}});const a=new Ve(e.notes);return a.setStyle(Ve.StylesString[e.options.style]),a.setContext(this.context),this.renderQ.push(a),a}NoteSubGroup(e={}){e=Ye(e,{notes:[],options:{}});const a=new R(e.notes);return a.setContext(this.context),a}draw(){this.systems.forEach(e=>e.setContext(this.context).format()),this.staves.forEach(e=>e.setContext(this.context).draw()),this.voices.forEach(e=>e.setContext(this.context).draw()),this.renderQ.forEach(e=>{e.isRendered()||e.setContext(this.context).draw()}),this.systems.forEach(e=>e.setContext(this.context).draw()),this.reset()}}function Jt(ce,e){const a=e.options;return(ce=Object.assign(e,ce)).options=Object.assign(a,ce.options),ce}class $t extends o{constructor(e={}){super(),this.setAttribute("type","System"),this.setOptions(e),this.parts=[]}setOptions(e={}){this.options=Jt(e,{x:10,y:10,width:500,connector:null,spaceBetweenStaves:12,factory:null,debugFormatter:!1,formatIterations:0,options:{}}),this.factory=this.options.factory||new At({renderer:{el:null}})}setContext(e){return super.setContext(e),this.factory.setContext(e),this}addConnector(e="double"){return this.connector=this.factory.StaveConnector({top_stave:this.parts[0].stave,bottom_stave:this.parts[this.parts.length-1].stave,type:e}),this.connector}addStave(e){return(e=Jt(e,{stave:null,voices:[],spaceAbove:0,spaceBelow:0,debugNoteMetrics:!1,options:{left_bar:!1}})).stave||(e.stave=this.factory.Stave({x:this.options.x,y:this.options.y,width:this.options.width,options:e.options})),e.voices.forEach(a=>a.setContext(this.context).setStave(e.stave).getTickables().forEach(b=>b.setStave(e.stave))),this.parts.push(e),e.stave}format(){const e=new Ce;this.formatter=e;let a=this.options.y,b=0,w=[];const C=[];this.parts.forEach(z=>{a+=z.stave.space(z.spaceAbove),z.stave.setY(a),e.joinVoices(z.voices),a+=z.stave.space(z.spaceBelow),a+=z.stave.space(this.options.spaceBetweenStaves),z.debugNoteMetrics&&(C.push({y:a,voice:z.voices[0]}),a+=15),w=w.concat(z.voices),b=Math.max(b,z.stave.getNoteStartX())}),this.parts.forEach(z=>z.stave.setNoteStartX(b));const V=this.options.width-(b-this.options.x)-j.STAVEPADDING;e.format(w,V);for(let z=0;z{a.voice.getTickables().forEach(b=>j.plotMetrics(e,b,a.y))})}}(l.Flow=m).Element=o,l.Flow.Fraction=s,l.Flow.Renderer=E,l.Flow.Formatter=Ce,l.Flow.Music=Q,l.Flow.Glyph=p,l.Flow.Stave=ze,l.Flow.StaveNote=oe,l.Flow.StaveModifier=Be,l.Flow.StaveTempo=st,l.Flow.Voice=D,l.Flow.Accidental=N,l.Flow.Beam=B,l.Flow.StaveTie=O,l.Flow.TabStave=He,l.Flow.TabNote=Je,l.Flow.Bend=Me,l.Flow.Vibrato=_e,l.Flow.VibratoBracket=qe,l.Flow.Note=j,l.Flow.ModifierContext=Le,l.Flow.MultiMeasureRest=Pt,l.Flow.TickContext=q,l.Flow.Articulation=Se,l.Flow.Annotation=be,l.Flow.Barline=Ie,l.Flow.NoteHead=P,l.Flow.StaveConnector=F,l.Flow.ClefNote=mt,l.Flow.KeySignature=We,l.Flow.KeySigNote=_t,l.Flow.TimeSignature=Xe,l.Flow.TimeSigNote=Xt,l.Flow.Stem=L,l.Flow.TabTie=U,l.Flow.Clef=et,l.Flow.Dot=X,l.Flow.Modifier=Y,l.Flow.TabSlide=ut,l.Flow.Tuplet=I,l.Flow.GraceNote=yt,l.Flow.GraceTabNote=Wt,l.Flow.Tuning=It,l.Flow.KeyManager=class{constructor(ce){this.music=new Q,this.setKey(ce)}setKey(ce){return this.key=ce,this.reset(),this}getKey(){return this.key}reset(){if(this.keyParts=this.music.getKeyParts(this.key),this.keyString=this.keyParts.root,this.keyParts.accidental&&(this.keyString+=this.keyParts.accidental),!Q.scaleTypes[this.keyParts.type])throw new l.RERR("BadArguments",`Unsupported key type: ${this.key}`);this.scale=this.music.getScaleTones(this.music.getNoteValue(this.keyString),Q.scaleTypes[this.keyParts.type]),this.scaleMap={},this.scaleMapByValue={},this.originalScaleMapByValue={};const ce=Q.root_indices[this.keyParts.root];for(let e=0;e 0.0) { skyLine = i; break; } } int bottomLine = ELEMENT_HEIGHT; for (int i = ELEMENT_HEIGHT - 1; i >= 0; --i) { float ratioY = float(i) / float(ELEMENT_HEIGHT); float relY = (ratioY - 0.5 + halfPixel) / float(NUM_ROWS); float x = absX; float y = absY + relY; float currentAlpha = texture2D(u_image, vec2(x, y)).a; if (currentAlpha > 0.0) { bottomLine = i; break; } } int r = skyLine; if (r > 256) { r -= 256; } int g = bottomLine; if (g > 256) { g -= 256; } int b = (skyLine / 256 * 16) + (bottomLine / 256); gl_FragColor = vec4(float(r) / 255.0, float(g) / 255.0, float(b) / 255.0, 1.0); } `},5340(de){de.exports=`attribute vec4 a_position; varying vec4 v_position; void main() { gl_Position = a_position; v_position = a_position; } `}},pt={};function Ze(de){var g=pt[de];if(g!==void 0)return g.exports;var c=pt[de]={exports:{}};return bt[de].call(c.exports,c,c.exports,Ze),c.exports}return Ze.d=(de,g)=>{for(var c in g)Ze.o(g,c)&&!Ze.o(de,c)&&Object.defineProperty(de,c,{enumerable:!0,get:g[c]})},Ze.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),Ze.o=(de,g)=>Object.prototype.hasOwnProperty.call(de,g),Ze.r=de=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(de,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(de,"__esModule",{value:!0})},Ze(8156)})())})(Qt);var fi=Qt.exports,pi=Object.defineProperty,mi=Object.getOwnPropertyDescriptor,Vt=(rt,gt,bt,pt)=>{for(var Ze=pt>1?void 0:pt?mi(gt,bt):gt,de=rt.length-1,g;de>=0;de--)(g=rt[de])&&(Ze=(pt?g(gt,bt,Ze):g(Ze))||Ze);return pt&&Ze&&pi(gt,bt,Ze),Ze};let wt=class extends ai{constructor(){super(...arguments),this._zoom=1,this.allowDrop=!1,this.src="",this.options={autoResize:!0,backend:"canvas",drawingParameters:"default"}}render(){return li`
`}async renderMusic(rt){this.controller&&(await this.controller.load(rt),this.controller.zoom=this._zoom,this.controller.render(),this.requestUpdate())}async getMusic(){var gt;if(this.src.length>0)return fetch(this.src).then(bt=>bt.text());const rt=(gt=this.parentElement)==null?void 0:gt.querySelector('script[type="text/xml"]');return rt?rt.innerHTML:""}async firstUpdated(){this.controller=new fi.OpenSheetMusicDisplay(this.canvas,this.options),this.requestUpdate();const rt=await this.getMusic();rt&&this.renderMusic(rt)}};wt.styles=hi` main { overflow-x: auto; } `;Vt([Zt({type:Boolean})],wt.prototype,"allowDrop",2);Vt([Zt()],wt.prototype,"src",2);Vt([ci("main")],wt.prototype,"canvas",2);wt=Vt([ui("sheet-music")],wt);export{wt as SheetMusic};