/*! For license information please see opensheetmusicdisplay.min.js.LICENSE.txt */ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.opensheetmusicdisplay=e():t.opensheetmusicdisplay=e()}(this,(()=>(()=>{var t={5733:(t,e,i)=>{t.exports=function t(e,i,s){function n(o,a){if(!i[o]){if(!e[o]){if(r)return r(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var h=i[o]={exports:{}};e[o][0].call(h.exports,(function(t){return n(e[o][1][t]||t)}),h,h.exports,t,e,i,s)}return i[o].exports}for(var r=void 0,o=0;o>2,a=(3&e)<<4|i>>4,l=1>6:64,h=2>4,i=(15&o)<<4|(a=r.indexOf(t.charAt(h++)))>>2,s=(3&a)<<6|(l=r.indexOf(t.charAt(h++))),d[c++]=e,64!==a&&(d[c++]=i),64!==l&&(d[c++]=s);return d}},{"./support":30,"./utils":32}],2:[function(t,e,i){"use strict";var s=t("./external"),n=t("./stream/DataWorker"),r=t("./stream/Crc32Probe"),o=t("./stream/DataLengthProbe");function a(t,e,i,s,n){this.compressedSize=t,this.uncompressedSize=e,this.crc32=i,this.compression=s,this.compressedContent=n}a.prototype={getContentWorker:function(){var t=new n(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new o("data_length")),e=this;return t.on("end",(function(){if(this.streamInfo.data_length!==e.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),t},getCompressedWorker:function(){return new n(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},a.createWorkerFrom=function(t,e,i){return t.pipe(new r).pipe(new o("uncompressedSize")).pipe(e.compressWorker(i)).pipe(new o("compressedSize")).withStreamInfo("compression",e)},e.exports=a},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,e,i){"use strict";var s=t("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},i.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,e,i){"use strict";var s=t("./utils"),n=function(){for(var t,e=[],i=0;i<256;i++){t=i;for(var s=0;s<8;s++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e}();e.exports=function(t,e){return void 0!==t&&t.length?"string"!==s.getTypeOf(t)?function(t,e,i,s){var r=n,o=0+i;t^=-1;for(var a=0;a>>8^r[255&(t^e[a])];return-1^t}(0|e,t,t.length):function(t,e,i,s){var r=n,o=0+i;t^=-1;for(var a=0;a>>8^r[255&(t^e.charCodeAt(a))];return-1^t}(0|e,t,t.length):0}},{"./utils":32}],5:[function(t,e,i){"use strict";i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(t,e,i){"use strict";var s;s="undefined"!=typeof Promise?Promise:t("lie"),e.exports={Promise:s}},{lie:37}],7:[function(t,e,i){"use strict";var s="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,n=t("pako"),r=t("./utils"),o=t("./stream/GenericWorker"),a=s?"uint8array":"array";function l(t,e){o.call(this,"FlateWorker/"+t),this._pako=null,this._pakoAction=t,this._pakoOptions=e,this.meta={}}i.magic="\b\0",r.inherits(l,o),l.prototype.processChunk=function(t){this.meta=t.meta,null===this._pako&&this._createPako(),this._pako.push(r.transformTo(a,t.data),!1)},l.prototype.flush=function(){o.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},l.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this._pako=null},l.prototype._createPako=function(){this._pako=new n[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var t=this;this._pako.onData=function(e){t.push({data:e,meta:t.meta})}},i.compressWorker=function(t){return new l("Deflate",t)},i.uncompressWorker=function(){return new l("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,e,i){"use strict";function s(t,e){var i,s="";for(i=0;i>>=8;return s}function n(t,e,i,n,o,c){var u,d,f=t.file,m=t.compression,p=c!==a.utf8encode,b=r.transformTo("string",c(f.name)),g=r.transformTo("string",a.utf8encode(f.name)),S=f.comment,y=r.transformTo("string",c(S)),E=r.transformTo("string",a.utf8encode(S)),v=g.length!==f.name.length,x=E.length!==S.length,_="",M="",w="",P=f.dir,T=f.date,L={crc32:0,compressedSize:0,uncompressedSize:0};e&&!i||(L.crc32=t.crc32,L.compressedSize=t.compressedSize,L.uncompressedSize=t.uncompressedSize);var A=0;e&&(A|=8),p||!v&&!x||(A|=2048);var C=0,I=0;P&&(C|=16),"UNIX"===o?(I=798,C|=function(t,e){var i=t;return t||(i=e?16893:33204),(65535&i)<<16}(f.unixPermissions,P)):(I=20,C|=function(t){return 63&(t||0)}(f.dosPermissions)),u=T.getUTCHours(),u<<=6,u|=T.getUTCMinutes(),u<<=5,u|=T.getUTCSeconds()/2,d=T.getUTCFullYear()-1980,d<<=4,d|=T.getUTCMonth()+1,d<<=5,d|=T.getUTCDate(),v&&(M=s(1,1)+s(l(b),4)+g,_+="up"+s(M.length,2)+M),x&&(w=s(1,1)+s(l(y),4)+E,_+="uc"+s(w.length,2)+w);var R="";return R+="\n\0",R+=s(A,2),R+=m.magic,R+=s(u,2),R+=s(d,2),R+=s(L.crc32,4),R+=s(L.compressedSize,4),R+=s(L.uncompressedSize,4),R+=s(b.length,2),R+=s(_.length,2),{fileRecord:h.LOCAL_FILE_HEADER+R+b+_,dirRecord:h.CENTRAL_FILE_HEADER+s(I,2)+R+s(y.length,2)+"\0\0\0\0"+s(C,4)+s(n,4)+b+_+y}}var r=t("../utils"),o=t("../stream/GenericWorker"),a=t("../utf8"),l=t("../crc32"),h=t("../signature");function c(t,e,i,s){o.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=e,this.zipPlatform=i,this.encodeFileName=s,this.streamFiles=t,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}r.inherits(c,o),c.prototype.push=function(t){var e=t.meta.percent||0,i=this.entriesCount,s=this._sources.length;this.accumulate?this.contentBuffer.push(t):(this.bytesWritten+=t.data.length,o.prototype.push.call(this,{data:t.data,meta:{currentFile:this.currentFile,percent:i?(e+100*(i-s-1))/i:100}}))},c.prototype.openedSource=function(t){this.currentSourceOffset=this.bytesWritten,this.currentFile=t.file.name;var e=this.streamFiles&&!t.file.dir;if(e){var i=n(t,e,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:i.fileRecord,meta:{percent:0}})}else this.accumulate=!0},c.prototype.closedSource=function(t){this.accumulate=!1;var e=this.streamFiles&&!t.file.dir,i=n(t,e,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(i.dirRecord),e)this.push({data:function(t){return h.DATA_DESCRIPTOR+s(t.crc32,4)+s(t.compressedSize,4)+s(t.uncompressedSize,4)}(t),meta:{percent:100}});else for(this.push({data:i.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},c.prototype.flush=function(){for(var t=this.bytesWritten,e=0;e=this.index;e--)i=(i<<8)+this.byteAt(e);return this.index+=t,i},readString:function(t){return s.transformTo("string",this.readData(t))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var t=this.readInt(4);return new Date(Date.UTC(1980+(t>>25&127),(t>>21&15)-1,t>>16&31,t>>11&31,t>>5&63,(31&t)<<1))}},e.exports=n},{"../utils":32}],19:[function(t,e,i){"use strict";var s=t("./Uint8ArrayReader");function n(t){s.call(this,t)}t("../utils").inherits(n,s),n.prototype.readData=function(t){this.checkOffset(t);var e=this.data.slice(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=n},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,e,i){"use strict";var s=t("./DataReader");function n(t){s.call(this,t)}t("../utils").inherits(n,s),n.prototype.byteAt=function(t){return this.data.charCodeAt(this.zero+t)},n.prototype.lastIndexOfSignature=function(t){return this.data.lastIndexOf(t)-this.zero},n.prototype.readAndCheckSignature=function(t){return t===this.readData(4)},n.prototype.readData=function(t){this.checkOffset(t);var e=this.data.slice(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=n},{"../utils":32,"./DataReader":18}],21:[function(t,e,i){"use strict";var s=t("./ArrayReader");function n(t){s.call(this,t)}t("../utils").inherits(n,s),n.prototype.readData=function(t){if(this.checkOffset(t),0===t)return new Uint8Array(0);var e=this.data.subarray(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=n},{"../utils":32,"./ArrayReader":17}],22:[function(t,e,i){"use strict";var s=t("../utils"),n=t("../support"),r=t("./ArrayReader"),o=t("./StringReader"),a=t("./NodeBufferReader"),l=t("./Uint8ArrayReader");e.exports=function(t){var e=s.getTypeOf(t);return s.checkSupport(e),"string"!==e||n.uint8array?"nodebuffer"===e?new a(t):n.uint8array?new l(s.transformTo("uint8array",t)):new r(s.transformTo("array",t)):new o(t)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,e,i){"use strict";i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\b"},{}],24:[function(t,e,i){"use strict";var s=t("./GenericWorker"),n=t("../utils");function r(t){s.call(this,"ConvertWorker to "+t),this.destType=t}n.inherits(r,s),r.prototype.processChunk=function(t){this.push({data:n.transformTo(this.destType,t.data),meta:t.meta})},e.exports=r},{"../utils":32,"./GenericWorker":28}],25:[function(t,e,i){"use strict";var s=t("./GenericWorker"),n=t("../crc32");function r(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(r,s),r.prototype.processChunk=function(t){this.streamInfo.crc32=n(t.data,this.streamInfo.crc32||0),this.push(t)},e.exports=r},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,e,i){"use strict";var s=t("../utils"),n=t("./GenericWorker");function r(t){n.call(this,"DataLengthProbe for "+t),this.propName=t,this.withStreamInfo(t,0)}s.inherits(r,n),r.prototype.processChunk=function(t){if(t){var e=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=e+t.data.length}n.prototype.processChunk.call(this,t)},e.exports=r},{"../utils":32,"./GenericWorker":28}],27:[function(t,e,i){"use strict";var s=t("../utils"),n=t("./GenericWorker");function r(t){n.call(this,"DataWorker");var e=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,t.then((function(t){e.dataIsReady=!0,e.data=t,e.max=t&&t.length||0,e.type=s.getTypeOf(t),e.isPaused||e._tickAndRepeat()}),(function(t){e.error(t)}))}s.inherits(r,n),r.prototype.cleanUp=function(){n.prototype.cleanUp.call(this),this.data=null},r.prototype.resume=function(){return!!n.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},r.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},r.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var t=null,e=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":t=this.data.substring(this.index,e);break;case"uint8array":t=this.data.subarray(this.index,e);break;case"array":case"nodebuffer":t=this.data.slice(this.index,e)}return this.index=e,this.push({data:t,meta:{percent:this.max?this.index/this.max*100:0}})},e.exports=r},{"../utils":32,"./GenericWorker":28}],28:[function(t,e,i){"use strict";function s(t){this.name=t||"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}s.prototype={push:function(t){this.emit("data",t)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(t){this.emit("error",t)}return!0},error:function(t){return!this.isFinished&&(this.isPaused?this.generatedError=t:(this.isFinished=!0,this.emit("error",t),this.previous&&this.previous.error(t),this.cleanUp()),!0)},on:function(t,e){return this._listeners[t].push(e),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(t,e){if(this._listeners[t])for(var i=0;i "+t:t}},e.exports=s},{}],29:[function(t,e,i){"use strict";var s=t("../utils"),n=t("./ConvertWorker"),r=t("./GenericWorker"),o=t("../base64"),a=t("../support"),l=t("../external"),h=null;if(a.nodestream)try{h=t("../nodejs/NodejsStreamOutputAdapter")}catch(t){}function c(t,e,i){var o=e;switch(e){case"blob":case"arraybuffer":o="uint8array";break;case"base64":o="string"}try{this._internalType=o,this._outputType=e,this._mimeType=i,s.checkSupport(o),this._worker=t.pipe(new n(o)),t.lock()}catch(t){this._worker=new r("error"),this._worker.error(t)}}c.prototype={accumulate:function(t){return function(t,e){return new l.Promise((function(i,n){var r=[],a=t._internalType,l=t._outputType,h=t._mimeType;t.on("data",(function(t,i){r.push(t),e&&e(i)})).on("error",(function(t){r=[],n(t)})).on("end",(function(){try{var t=function(t,e,i){switch(t){case"blob":return s.newBlob(s.transformTo("arraybuffer",e),i);case"base64":return o.encode(e);default:return s.transformTo(t,e)}}(l,function(t,e){var i,s=0,n=null,r=0;for(i=0;i>>6:(i<65536?e[o++]=224|i>>>12:(e[o++]=240|i>>>18,e[o++]=128|i>>>12&63),e[o++]=128|i>>>6&63),e[o++]=128|63&i);return e}(t)},i.utf8decode=function(t){return n.nodebuffer?s.transformTo("nodebuffer",t).toString("utf-8"):function(t){var e,i,n,r,o=t.length,l=new Array(2*o);for(e=i=0;e>10&1023,l[i++]=56320|1023&n)}return l.length!==i&&(l.subarray?l=l.subarray(0,i):l.length=i),s.applyFromCharCode(l)}(t=s.transformTo(n.uint8array?"uint8array":"array",t))},s.inherits(h,o),h.prototype.processChunk=function(t){var e=s.transformTo(n.uint8array?"uint8array":"array",t.data);if(this.leftOver&&this.leftOver.length){if(n.uint8array){var r=e;(e=new Uint8Array(r.length+this.leftOver.length)).set(this.leftOver,0),e.set(r,this.leftOver.length)}else e=this.leftOver.concat(e);this.leftOver=null}var o=function(t,e){var i;for((e=e||t.length)>t.length&&(e=t.length),i=e-1;0<=i&&128==(192&t[i]);)i--;return i<0||0===i?e:i+a[t[i]]>e?i:e}(e),l=e;o!==e.length&&(n.uint8array?(l=e.subarray(0,o),this.leftOver=e.subarray(o,e.length)):(l=e.slice(0,o),this.leftOver=e.slice(o,e.length))),this.push({data:i.utf8decode(l),meta:t.meta})},h.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=h,s.inherits(c,o),c.prototype.processChunk=function(t){this.push({data:i.utf8encode(t.data),meta:t.meta})},i.Utf8EncodeWorker=c},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,e,i){"use strict";var s=t("./support"),n=t("./base64"),r=t("./nodejsUtils"),o=t("./external");function a(t){return t}function l(t,e){for(var i=0;i>8;this.dir=!!(16&this.externalFileAttributes),0==t&&(this.dosPermissions=63&this.externalFileAttributes),3==t&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var t=s(this.extraFields[1].value);this.uncompressedSize===n.MAX_VALUE_32BITS&&(this.uncompressedSize=t.readInt(8)),this.compressedSize===n.MAX_VALUE_32BITS&&(this.compressedSize=t.readInt(8)),this.localHeaderOffset===n.MAX_VALUE_32BITS&&(this.localHeaderOffset=t.readInt(8)),this.diskNumberStart===n.MAX_VALUE_32BITS&&(this.diskNumberStart=t.readInt(4))}},readExtraFields:function(t){var e,i,s,n=t.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});t.index+4>>6:(i<65536?e[o++]=224|i>>>12:(e[o++]=240|i>>>18,e[o++]=128|i>>>12&63),e[o++]=128|i>>>6&63),e[o++]=128|63&i);return e},i.buf2binstring=function(t){return l(t,t.length)},i.binstring2buf=function(t){for(var e=new s.Buf8(t.length),i=0,n=e.length;i>10&1023,h[s++]=56320|1023&n)}return l(h,s)},i.utf8border=function(t,e){var i;for((e=e||t.length)>t.length&&(e=t.length),i=e-1;0<=i&&128==(192&t[i]);)i--;return i<0||0===i?e:i+o[t[i]]>e?i:e}},{"./common":41}],43:[function(t,e,i){"use strict";e.exports=function(t,e,i,s){for(var n=65535&t|0,r=t>>>16&65535|0,o=0;0!==i;){for(i-=o=2e3>>1:t>>>1;e[i]=t}return e}();e.exports=function(t,e,i,n){var r=s,o=n+i;t^=-1;for(var a=n;a>>8^r[255&(t^e[a])];return-1^t}},{}],46:[function(t,e,i){"use strict";var s,n=t("../utils/common"),r=t("./trees"),o=t("./adler32"),a=t("./crc32"),l=t("./messages"),h=-2,c=258,u=262,d=113;function f(t,e){return t.msg=l[e],e}function m(t){return(t<<1)-(4t.avail_out&&(i=t.avail_out),0!==i&&(n.arraySet(t.output,e.pending_buf,e.pending_out,i,t.next_out),t.next_out+=i,e.pending_out+=i,t.total_out+=i,t.avail_out-=i,e.pending-=i,0===e.pending&&(e.pending_out=0))}function g(t,e){r._tr_flush_block(t,0<=t.block_start?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,b(t.strm)}function S(t,e){t.pending_buf[t.pending++]=e}function y(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function E(t,e){var i,s,n=t.max_chain_length,r=t.strstart,o=t.prev_length,a=t.nice_match,l=t.strstart>t.w_size-u?t.strstart-(t.w_size-u):0,h=t.window,d=t.w_mask,f=t.prev,m=t.strstart+c,p=h[r+o-1],b=h[r+o];t.prev_length>=t.good_match&&(n>>=2),a>t.lookahead&&(a=t.lookahead);do{if(h[(i=e)+o]===b&&h[i+o-1]===p&&h[i]===h[r]&&h[++i]===h[r+1]){r+=2,i++;do{}while(h[++r]===h[++i]&&h[++r]===h[++i]&&h[++r]===h[++i]&&h[++r]===h[++i]&&h[++r]===h[++i]&&h[++r]===h[++i]&&h[++r]===h[++i]&&h[++r]===h[++i]&&rl&&0!=--n);return o<=t.lookahead?o:t.lookahead}function v(t){var e,i,s,r,l,h,c,d,f,m,p=t.w_size;do{if(r=t.window_size-t.lookahead-t.strstart,t.strstart>=p+(p-u)){for(n.arraySet(t.window,t.window,p,p,0),t.match_start-=p,t.strstart-=p,t.block_start-=p,e=i=t.hash_size;s=t.head[--e],t.head[e]=p<=s?s-p:0,--i;);for(e=i=p;s=t.prev[--e],t.prev[e]=p<=s?s-p:0,--i;);r+=p}if(0===t.strm.avail_in)break;if(h=t.strm,c=t.window,d=t.strstart+t.lookahead,m=void 0,(f=r)<(m=h.avail_in)&&(m=f),i=0===m?0:(h.avail_in-=m,n.arraySet(c,h.input,h.next_in,m,d),1===h.state.wrap?h.adler=o(h.adler,c,m,d):2===h.state.wrap&&(h.adler=a(h.adler,c,m,d)),h.next_in+=m,h.total_in+=m,m),t.lookahead+=i,t.lookahead+t.insert>=3)for(l=t.strstart-t.insert,t.ins_h=t.window[l],t.ins_h=(t.ins_h<=3&&(t.ins_h=(t.ins_h<=3)if(s=r._tr_tally(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){for(t.match_length--;t.strstart++,t.ins_h=(t.ins_h<=3&&(t.ins_h=(t.ins_h<=3&&t.match_length<=t.prev_length){for(n=t.strstart+t.lookahead-3,s=r._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;++t.strstart<=n&&(t.ins_h=(t.ins_h<t.pending_buf_size-5&&(i=t.pending_buf_size-5);;){if(t.lookahead<=1){if(v(t),0===t.lookahead&&0===e)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var s=t.block_start+i;if((0===t.strstart||t.strstart>=s)&&(t.lookahead=t.strstart-s,t.strstart=s,g(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-u&&(g(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(g(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(g(t,!1),t.strm.avail_out),1)})),new M(4,4,8,4,x),new M(4,5,16,8,x),new M(4,6,32,32,x),new M(4,4,16,16,_),new M(8,16,32,32,_),new M(8,16,128,128,_),new M(8,32,128,256,_),new M(32,128,258,1024,_),new M(32,258,258,4096,_)],i.deflateInit=function(t,e){return L(t,e,8,15,8,0)},i.deflateInit2=L,i.deflateReset=T,i.deflateResetKeep=P,i.deflateSetHeader=function(t,e){return t&&t.state?2!==t.state.wrap?h:(t.state.gzhead=e,0):h},i.deflate=function(t,e){var i,n,o,l;if(!t||!t.state||5>8&255),S(n,n.gzhead.time>>16&255),S(n,n.gzhead.time>>24&255),S(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),S(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(S(n,255&n.gzhead.extra.length),S(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=a(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(S(n,0),S(n,0),S(n,0),S(n,0),S(n,0),S(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),S(n,3),n.status=d);else{var u=8+(n.w_bits-8<<4)<<8;u|=(2<=n.strategy||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(u|=32),u+=31-u%31,n.status=d,y(n,u),0!==n.strstart&&(y(n,t.adler>>>16),y(n,65535&t.adler)),t.adler=1}if(69===n.status)if(n.gzhead.extra){for(o=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>o&&(t.adler=a(t.adler,n.pending_buf,n.pending-o,o)),b(t),o=n.pending,n.pending!==n.pending_buf_size));)S(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>o&&(t.adler=a(t.adler,n.pending_buf,n.pending-o,o)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){o=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>o&&(t.adler=a(t.adler,n.pending_buf,n.pending-o,o)),b(t),o=n.pending,n.pending===n.pending_buf_size)){l=1;break}l=n.gzindexo&&(t.adler=a(t.adler,n.pending_buf,n.pending-o,o)),0===l&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){o=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>o&&(t.adler=a(t.adler,n.pending_buf,n.pending-o,o)),b(t),o=n.pending,n.pending===n.pending_buf_size)){l=1;break}l=n.gzindexo&&(t.adler=a(t.adler,n.pending_buf,n.pending-o,o)),0===l&&(n.status=103)}else n.status=103;if(103===n.status&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&b(t),n.pending+2<=n.pending_buf_size&&(S(n,255&t.adler),S(n,t.adler>>8&255),t.adler=0,n.status=d)):n.status=d),0!==n.pending){if(b(t),0===t.avail_out)return n.last_flush=-1,0}else if(0===t.avail_in&&m(e)<=m(i)&&4!==e)return f(t,-5);if(666===n.status&&0!==t.avail_in)return f(t,-5);if(0!==t.avail_in||0!==n.lookahead||0!==e&&666!==n.status){var E=2===n.strategy?function(t,e){for(var i;;){if(0===t.lookahead&&(v(t),0===t.lookahead)){if(0===e)return 1;break}if(t.match_length=0,i=r._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,i&&(g(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(g(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(g(t,!1),0===t.strm.avail_out)?1:2}(n,e):3===n.strategy?function(t,e){for(var i,s,n,o,a=t.window;;){if(t.lookahead<=c){if(v(t),t.lookahead<=c&&0===e)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&0t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(i=r._tr_tally(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(i=r._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),i&&(g(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(g(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(g(t,!1),0===t.strm.avail_out)?1:2}(n,e):s[n.level].func(n,e);if(3!==E&&4!==E||(n.status=666),1===E||3===E)return 0===t.avail_out&&(n.last_flush=-1),0;if(2===E&&(1===e?r._tr_align(n):5!==e&&(r._tr_stored_block(n,0,0,!1),3===e&&(p(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),b(t),0===t.avail_out))return n.last_flush=-1,0}return 4!==e?0:n.wrap<=0?1:(2===n.wrap?(S(n,255&t.adler),S(n,t.adler>>8&255),S(n,t.adler>>16&255),S(n,t.adler>>24&255),S(n,255&t.total_in),S(n,t.total_in>>8&255),S(n,t.total_in>>16&255),S(n,t.total_in>>24&255)):(y(n,t.adler>>>16),y(n,65535&t.adler)),b(t),0=i.w_size&&(0===a&&(p(i.head),i.strstart=0,i.block_start=0,i.insert=0),d=new n.Buf8(i.w_size),n.arraySet(d,e,f-i.w_size,i.w_size,0),e=d,f=i.w_size),l=t.avail_in,c=t.next_in,u=t.input,t.avail_in=f,t.next_in=0,t.input=e,v(i);i.lookahead>=3;){for(s=i.strstart,r=i.lookahead-2;i.ins_h=(i.ins_h<>>=E=y>>>24,m-=E,0==(E=y>>>16&255))P[r++]=65535&y;else{if(!(16&E)){if(0==(64&E)){y=p[(65535&y)+(f&(1<>>=E,m-=E),m<15&&(f+=w[s++]<>>=E=y>>>24,m-=E,!(16&(E=y>>>16&255))){if(0==(64&E)){y=b[(65535&y)+(f&(1<>>=E,m-=E,(E=r-o)>3,f&=(1<<(m-=v<<3))-1,t.next_in=s,t.next_out=r,t.avail_in=s>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function c(){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 s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function u(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new s.Buf32(852),e.distcode=e.distdyn=new s.Buf32(592),e.sane=1,e.back=-1,0):l}function d(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,u(t)):l}function f(t,e){var i,s;return t&&t.state?(s=t.state,e<0?(i=0,e=-e):(i=1+(e>>4),e<48&&(e&=15)),e&&(e<8||15=o.wsize?(s.arraySet(o.window,e,i-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(n<(r=o.wsize-o.wnext)&&(r=n),s.arraySet(o.window,e,i-n,r,o.wnext),(n-=r)?(s.arraySet(o.window,e,i-n,n,0),o.wnext=n,o.whave=o.wsize):(o.wnext+=r,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,i.check=r(i.check,D,2,0),g=b=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&b)<<8)+(b>>8))%31){t.msg="incorrect header check",i.mode=30;break}if(8!=(15&b)){t.msg="unknown compression method",i.mode=30;break}if(g-=4,I=8+(15&(b>>>=4)),0===i.wbits)i.wbits=I;else if(I>i.wbits){t.msg="invalid window size",i.mode=30;break}i.dmax=1<>8&1),512&i.flags&&(D[0]=255&b,D[1]=b>>>8&255,i.check=r(i.check,D,2,0)),g=b=0,i.mode=3;case 3:for(;g<32;){if(0===m)break t;m--,b+=c[d++]<>>8&255,D[2]=b>>>16&255,D[3]=b>>>24&255,i.check=r(i.check,D,4,0)),g=b=0,i.mode=4;case 4:for(;g<16;){if(0===m)break t;m--,b+=c[d++]<>8),512&i.flags&&(D[0]=255&b,D[1]=b>>>8&255,i.check=r(i.check,D,2,0)),g=b=0,i.mode=5;case 5:if(1024&i.flags){for(;g<16;){if(0===m)break t;m--,b+=c[d++]<>>8&255,i.check=r(i.check,D,2,0)),g=b=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(m<(x=i.length)&&(x=m),x&&(i.head&&(I=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),s.arraySet(i.head.extra,c,d,x,I)),512&i.flags&&(i.check=r(i.check,c,x,d)),m-=x,d+=x,i.length-=x),i.length))break t;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===m)break t;for(x=0;I=c[d+x++],i.head&&I&&i.length<65536&&(i.head.name+=String.fromCharCode(I)),I&&x>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=12;break;case 10:for(;g<32;){if(0===m)break t;m--,b+=c[d++]<>>=7&g,g-=7&g,i.mode=27;break}for(;g<3;){if(0===m)break t;m--,b+=c[d++]<>>=1)){case 0:i.mode=14;break;case 1:if(S(i),i.mode=20,6!==e)break;b>>>=2,g-=2;break t;case 2:i.mode=17;break;case 3:t.msg="invalid block type",i.mode=30}b>>>=2,g-=2;break;case 14:for(b>>>=7&g,g-=7&g;g<32;){if(0===m)break t;m--,b+=c[d++]<>>16^65535)){t.msg="invalid stored block lengths",i.mode=30;break}if(i.length=65535&b,g=b=0,i.mode=15,6===e)break t;case 15:i.mode=16;case 16:if(x=i.length){if(m>>=5,g-=5,i.ndist=1+(31&b),b>>>=5,g-=5,i.ncode=4+(15&b),b>>>=4,g-=4,286>>=3,g-=3}for(;i.have<19;)i.lens[O[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,N={bits:i.lenbits},R=a(0,i.lens,0,19,i.lencode,0,i.work,N),i.lenbits=N.bits,R){t.msg="invalid code lengths set",i.mode=30;break}i.have=0,i.mode=19;case 19:for(;i.have>>16&255,T=65535&F,!((w=F>>>24)<=g);){if(0===m)break t;m--,b+=c[d++]<>>=w,g-=w,i.lens[i.have++]=T;else{if(16===T){for(B=w+2;g>>=w,g-=w,0===i.have){t.msg="invalid bit length repeat",i.mode=30;break}I=i.lens[i.have-1],x=3+(3&b),b>>>=2,g-=2}else if(17===T){for(B=w+3;g>>=w)),b>>>=3,g-=3}else{for(B=w+7;g>>=w)),b>>>=7,g-=7}if(i.have+x>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=30;break}for(;x--;)i.lens[i.have++]=I}}if(30===i.mode)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=30;break}if(i.lenbits=9,N={bits:i.lenbits},R=a(1,i.lens,0,i.nlen,i.lencode,0,i.work,N),i.lenbits=N.bits,R){t.msg="invalid literal/lengths set",i.mode=30;break}if(i.distbits=6,i.distcode=i.distdyn,N={bits:i.distbits},R=a(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,N),i.distbits=N.bits,R){t.msg="invalid distances set",i.mode=30;break}if(i.mode=20,6===e)break t;case 20:i.mode=21;case 21:if(6<=m&&258<=p){t.next_out=f,t.avail_out=p,t.next_in=d,t.avail_in=m,i.hold=b,i.bits=g,o(t,v),f=t.next_out,u=t.output,p=t.avail_out,d=t.next_in,c=t.input,m=t.avail_in,b=i.hold,g=i.bits,12===i.mode&&(i.back=-1);break}for(i.back=0;P=(F=i.lencode[b&(1<>>16&255,T=65535&F,!((w=F>>>24)<=g);){if(0===m)break t;m--,b+=c[d++]<>L)])>>>16&255,T=65535&F,!(L+(w=F>>>24)<=g);){if(0===m)break t;m--,b+=c[d++]<>>=L,g-=L,i.back+=L}if(b>>>=w,g-=w,i.back+=w,i.length=T,0===P){i.mode=26;break}if(32&P){i.back=-1,i.mode=12;break}if(64&P){t.msg="invalid literal/length code",i.mode=30;break}i.extra=15&P,i.mode=22;case 22:if(i.extra){for(B=i.extra;g>>=i.extra,g-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;P=(F=i.distcode[b&(1<>>16&255,T=65535&F,!((w=F>>>24)<=g);){if(0===m)break t;m--,b+=c[d++]<>L)])>>>16&255,T=65535&F,!(L+(w=F>>>24)<=g);){if(0===m)break t;m--,b+=c[d++]<>>=L,g-=L,i.back+=L}if(b>>>=w,g-=w,i.back+=w,64&P){t.msg="invalid distance code",i.mode=30;break}i.offset=T,i.extra=15&P,i.mode=24;case 24:if(i.extra){for(B=i.extra;g>>=i.extra,g-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=30;break}i.mode=25;case 25:if(0===p)break t;if(x=v-p,i.offset>x){if((x=i.offset-x)>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=30;break}_=x>i.wnext?(x-=i.wnext,i.wsize-x):i.wnext-x,x>i.length&&(x=i.length),M=i.window}else M=u,_=f-i.offset,x=i.length;for(pS?(E=O[k+u[M]],N[B+u[M]]):(E=96,0),f=1<<_-A,w=m=1<>A)+(m-=f)]=y<<24|E<<16|v|0,0!==m;);for(f=1<<_-1;R&f;)f>>=1;if(0!==f?(R&=f-1,R+=f):R=0,M++,0==--F[_]){if(_===P)break;_=e[i+u[M]]}if(T<_&&(R&b)!==p){for(0===A&&(A=T),g+=w,C=1<<(L=_-A);L+A>>7)]}function w(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function P(t,e,i){t.bi_valid>16-i?(t.bi_buf|=e<>16-t.bi_valid,t.bi_valid+=i-16):(t.bi_buf|=e<>>=1,i<<=1,0<--e;);return i>>>1}function A(t,e,i){var s,n,r=new Array(16),o=0;for(s=1;s<=l;s++)r[s]=o=o+i[s-1]<<1;for(n=0;n<=e;n++){var a=t[2*n+1];0!==a&&(t[2*n]=L(r[a]++,a))}}function C(t){var e;for(e=0;e>1;1<=i;i--)N(t,r,i);for(n=h;i=t.heap[1],t.heap[1]=t.heap[t.heap_len--],N(t,r,1),s=t.heap[1],t.heap[--t.heap_max]=i,t.heap[--t.heap_max]=s,r[2*n]=r[2*i]+r[2*s],t.depth[n]=(t.depth[i]>=t.depth[s]?t.depth[i]:t.depth[s])+1,r[2*i+1]=r[2*s+1]=n,t.heap[1]=n++,N(t,r,1),2<=t.heap_len;);t.heap[--t.heap_max]=t.heap[1],function(t,e){var i,s,n,r,o,a,h=e.dyn_tree,c=e.max_code,u=e.stat_desc.static_tree,d=e.stat_desc.has_stree,f=e.stat_desc.extra_bits,m=e.stat_desc.extra_base,p=e.stat_desc.max_length,b=0;for(r=0;r<=l;r++)t.bl_count[r]=0;for(h[2*t.heap[t.heap_max]+1]=0,i=t.heap_max+1;i<573;i++)p<(r=h[2*h[2*(s=t.heap[i])+1]+1]+1)&&(r=p,b++),h[2*s+1]=r,c>=7;s>>=1)if(1&i&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e>>3,(o=t.static_len+3+7>>>3)<=n&&(n=o)):n=o=i+5,i+4<=n&&-1!==e?V(t,e,i,s):4===t.strategy||o===n?(P(t,2+(s?1:0),3),B(t,f,m)):(P(t,4+(s?1:0),3),function(t,e,i,s){var n;for(P(t,e-257,5),P(t,i-1,5),P(t,s-4,4),n=0;n>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&i,t.last_lit++,0===e?t.dyn_ltree[2*i]++:(t.matches++,e--,t.dyn_ltree[2*(b[i]+r+1)]++,t.dyn_dtree[2*M(e)]++),t.last_lit===t.lit_bufsize-1},i._tr_align=function(t){P(t,2,3),T(t,256,f),function(t){16===t.bi_valid?(w(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):8<=t.bi_valid&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}},{"../utils/common":41}],53:[function(t,e,i){"use strict";e.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(t,e,s){(function(t){!function(t,e){"use strict";if(!t.setImmediate){var i,s,n,r,o=1,a={},l=!1,h=t.document,c=Object.getPrototypeOf&&Object.getPrototypeOf(t);c=c&&c.setTimeout?c:t,i="[object process]"==={}.toString.call(t.process)?function(t){process.nextTick((function(){d(t)}))}:function(){if(t.postMessage&&!t.importScripts){var e=!0,i=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=i,e}}()?(r="setImmediate$"+Math.random()+"$",t.addEventListener?t.addEventListener("message",f,!1):t.attachEvent("onmessage",f),function(e){t.postMessage(r+e,"*")}):t.MessageChannel?((n=new MessageChannel).port1.onmessage=function(t){d(t.data)},function(t){n.port2.postMessage(t)}):h&&"onreadystatechange"in h.createElement("script")?(s=h.documentElement,function(t){var e=h.createElement("script");e.onreadystatechange=function(){d(t),e.onreadystatechange=null,s.removeChild(e),e=null},s.appendChild(e)}):function(t){setTimeout(d,0,t)},c.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),s=0;s=0&&i<=o.levels.SILENT))throw"log.setLevel() called with invalid level: "+i;if(r=i,!1!==n&&function(t){var i=(s[t]||"silent").toUpperCase();if(typeof window!==e&&l){try{return void(window.localStorage[l]=i)}catch(t){}try{window.document.cookie=encodeURIComponent(l)+"="+i+";"}catch(t){}}}(i),a.call(o,i,t),typeof console===e&&i{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Fraction=void 0;class i{constructor(t=0,e=1,i=0,s=!0){this.numerator=0,this.denominator=1,this.wholeValue=0,this.numerator=t,this.denominator=e,this.wholeValue=i,s&&this.simplify(),this.setRealValue()}static max(t,e){return t.RealValue>e.RealValue?t:e}static Equal(t,e){return t.wholeValue===e.wholeValue&&t.Denominator===e.Denominator&&t.Numerator===e.Numerator}static createFromFraction(t){return new i(t.numerator,t.denominator,t.wholeValue,!1)}static plus(t,e){const i=t.clone();return i.Add(e),i}static minus(t,e){const i=t.clone();return i.Sub(e),i}static multiply(t,e){return new i((t.wholeValue*t.denominator+t.numerator)*(e.wholeValue*e.denominator+e.numerator),t.denominator*e.denominator)}static greatestCommonDenominator(t,e){if(0===t)return e;if(1===e)return 1;for(;Math.abs(e)>1e-8;)t>e?t-=e:e-=t;return Math.round(t)}toString(){let t=this.numerator+"/"+this.denominator;return 0!==this.wholeValue&&(t=this.wholeValue+" "+t),t}clone(){return new i(this.numerator,this.denominator,this.wholeValue,!1)}get Numerator(){return this.numerator}set Numerator(t){this.numerator!==t&&(this.numerator=t,this.simplify(),this.setRealValue())}get Denominator(){return this.denominator}set Denominator(t){this.denominator!==t&&(this.denominator=t,0!==this.numerator&&this.simplify(),this.setRealValue())}get WholeValue(){return this.wholeValue}set WholeValue(t){this.wholeValue!==t&&(this.wholeValue=t,this.setRealValue())}GetExpandedNumerator(){return this.wholeValue*this.denominator+this.numerator}calculateNumberOfNeededDots(){let t=1,e=2;const i=this.GetExpandedNumerator();for(;et;)e.Numerator++;if(this.numerator>this.denominator){const s=new i(this.numerator-1,this.denominator,this.wholeValue);for(;s.Denominator>t;)s.Numerator--;if(s.Denominatori.maximumAllowedNumber){const t=this.denominator/i.maximumAllowedNumber;this.numerator=Math.round(this.numerator/t),this.denominator=Math.round(this.denominator/t)}if(this.numerator>i.maximumAllowedNumber){const t=this.numerator/i.maximumAllowedNumber;this.numerator=Math.round(this.numerator/t),this.denominator=Math.round(this.denominator/t)}}isOnBeat(t){const e=this.distanceFromBeat(t);return Math.abs(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Matrix2D=void 0;const s=i(9086);class n{constructor(){this.matrix=[];for(let t=0;t<2;t++){this.matrix[t]=[];for(let e=0;e<2;e++)this.matrix[t][e]=0}}static getRotationMatrix(t){const e=new n,i=Math.cos(t),s=Math.sin(t);return e.matrix[0][0]=i,e.matrix[0][1]=-s,e.matrix[1][0]=s,e.matrix[1][1]=i,e}scalarMultiplication(t){for(let e=0;e<2;e++)for(let i=0;i<2;i++)this.matrix[e][i]*=t}getTransposeMatrix(){const t=new n;for(let e=0;e<2;e++)for(let i=0;i<2;i++)t.matrix[e][i]=this.matrix[i][e];return t}vectorMultiplication(t){const e=new s.PointF2D;return e.x=t.x*this.matrix[0][0]+t.y*this.matrix[0][1],e.y=t.x*this.matrix[1][0]+t.y*this.matrix[1][1],e}}e.Matrix2D=n},9651:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MusicSheetErrors=void 0,e.MusicSheetErrors=class{constructor(){this.measureErrors={},this.errors=[],this.tempErrors=[]}finalizeMeasure(t){let e=this.measureErrors[t];e||(e=[]),this.measureErrors[t]=e.concat(this.tempErrors),this.tempErrors=[]}pushMeasureError(t){this.tempErrors.push(t)}push(t){this.errors.push(t)}}},9855:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.OSMDColor=void 0;class i{constructor(t,e,i){this.alpha=255,this.red=t,this.green=e,this.blue=i}static get Black(){return new i(0,0,0)}static get DeepSkyBlue(){return new i(0,191,255)}static get Green(){return new i(20,160,20)}static get Magenta(){return new i(255,0,255)}static get Orange(){return new i(255,128,0)}static get Red(){return new i(240,20,20)}static get Disabled(){return new i(225,225,225)}static get DarkBlue(){return new i(0,0,140)}static get Debug1(){return new i(200,0,140)}static get Debug2(){return new i(100,100,200)}static get Debug3(){return new i(0,50,140)}toString(){return"rgb("+this.red+","+this.green+","+this.blue+","+this.alpha+")"}}e.OSMDColor=i},8640:(t,e)=>{"use strict";var i,s;Object.defineProperty(e,"__esModule",{value:!0}),e.Pitch=e.AccidentalEnum=e.NoteEnum=void 0,function(t){t[t.C=0]="C",t[t.D=2]="D",t[t.E=4]="E",t[t.F=5]="F",t[t.G=7]="G",t[t.A=9]="A",t[t.B=11]="B"}(i=e.NoteEnum||(e.NoteEnum={})),function(t){t[t.SHARP=0]="SHARP",t[t.FLAT=1]="FLAT",t[t.NONE=2]="NONE",t[t.NATURAL=3]="NATURAL",t[t.DOUBLESHARP=4]="DOUBLESHARP",t[t.DOUBLEFLAT=5]="DOUBLEFLAT",t[t.TRIPLESHARP=6]="TRIPLESHARP",t[t.TRIPLEFLAT=7]="TRIPLEFLAT",t[t.QUARTERTONESHARP=8]="QUARTERTONESHARP",t[t.QUARTERTONEFLAT=9]="QUARTERTONEFLAT",t[t.SLASHFLAT=10]="SLASHFLAT",t[t.THREEQUARTERSSHARP=11]="THREEQUARTERSSHARP",t[t.THREEQUARTERSFLAT=12]="THREEQUARTERSFLAT",t[t.SLASHQUARTERSHARP=13]="SLASHQUARTERSHARP",t[t.SLASHSHARP=14]="SLASHSHARP",t[t.DOUBLESLASHFLAT=15]="DOUBLESLASHFLAT",t[t.SORI=16]="SORI",t[t.KORON=17]="KORON"}(s=e.AccidentalEnum||(e.AccidentalEnum={}));class n{constructor(t,e,i,r,o=!1){this.accidental=s.NONE,this.fundamentalNote=t,this.octave=e,this.accidental=i,this.accidentalXml=r,this.halfTone=t+12*(e+n.octXmlDiff)+n.HalfTonesFromAccidental(i),o||(this.frequency=n.calcFrequency(this))}static getNoteEnumString(t){switch(t){case i.C:return"C";case i.D:return"D";case i.E:return"E";case i.F:return"F";case i.G:return"G";case i.A:return"A";case i.B:return"B";default:return""}}static lineShiftFromNoteEnum(t,e){if(0===e)return[t,0];const i=n.pitchEnumValues,s=i.indexOf(t);let r=0,o=(s+e)%i.length;return s+e>i.length-1&&(r=1),o<0&&(o=i.length+o,r=-1),[i[o],r]}static CalculateTransposedHalfTone(t,e){const i=t.fundamentalNote+t.AccidentalHalfTones+e;return n.WrapAroundCheck(i,12)}static WrapAroundCheck(t,e){let i=0;for(;t<0;)t+=e,i--;for(;t>=e;)t-=e,i++;return{overflow:i,halftone:t}}static calcFrequency(t){let e,s=0;if(t instanceof n){const n=t;s=n.octave-1,e=n.fundamentalNote-i.A+n.AccidentalHalfTones}else"number"==typeof t&&(e=t-57);return 440*Math.pow(2,s)*Math.pow(2,e/12)}static calcFractionalKey(t){return Math.log(t/440)/Math.LN10*n.halftoneFactor+57}static fromFrequency(t){const e=n.calcFractionalKey(t)+.5,i=Math.floor(e/12)-n.octXmlDiff,r=Math.floor(e)%12;let o=r,a=s.NONE;return-1===this.pitchEnumValues.indexOf(o)&&(o=r-1,a=s.SHARP),new n(o,i,a)}static fromHalftone(t){const e=Math.floor(t/12)-n.octXmlDiff,i=t%12;let r=i,o=s.NONE;return-1===this.pitchEnumValues.indexOf(r)&&(r=i-1,o=s.SHARP),new n(r,e,o)}static ceiling(t){let e=t%=12;return-1===this.pitchEnumValues.indexOf(e)&&(e=t+1),e}static floor(t){let e=t%=12;return-1===this.pitchEnumValues.indexOf(e)&&(e=t-1),e}static HalfTonesFromAccidental(t){switch(t){case s.NONE:return 0;case s.SHARP:return 1;case s.FLAT:return-1;case s.NATURAL:return 0;case s.DOUBLESHARP:return 2;case s.DOUBLEFLAT:return-2;case s.TRIPLESHARP:return 3;case s.TRIPLEFLAT:return-3;case s.QUARTERTONESHARP:return.5;case s.QUARTERTONEFLAT:return-.5;case s.SLASHFLAT:return-.51;case s.THREEQUARTERSSHARP:return 1.5;case s.THREEQUARTERSFLAT:return-1.5;case s.SLASHQUARTERSHARP:return.0013;case s.SLASHSHARP:return.0014;case s.DOUBLESLASHFLAT:return-.0015;case s.SORI:return.0016;case s.KORON:return.0017;default:throw new Error("Unhandled AccidentalEnum value")}}static AccidentalFromHalfTones(t){switch(t){case 0:return s.NONE;case 1:return s.SHARP;case-1:return s.FLAT;case 2:return s.DOUBLESHARP;case-2:return s.DOUBLEFLAT;case 3:return s.TRIPLESHARP;case-3:return s.TRIPLEFLAT;case.5:return s.QUARTERTONESHARP;case-.5:return s.QUARTERTONEFLAT;case 1.5:return s.THREEQUARTERSSHARP;case-1.5:return s.THREEQUARTERSFLAT;default:return t>0&&t<1?s.QUARTERTONESHARP:t<0&&t>-1?s.QUARTERTONEFLAT:s.QUARTERTONESHARP}}static accidentalVexflow(t){let e;switch(t){case s.NATURAL:e="n";break;case s.FLAT:e="b";break;case s.SHARP:e="#";break;case s.DOUBLESHARP:e="##";break;case s.TRIPLESHARP:e="###";break;case s.DOUBLEFLAT:e="bb";break;case s.TRIPLEFLAT:e="bbs";break;case s.QUARTERTONESHARP:e="+";break;case s.QUARTERTONEFLAT:e="d";break;case s.SLASHFLAT:e="bs";break;case s.THREEQUARTERSSHARP:e="++";break;case s.THREEQUARTERSFLAT:e="db";break;case s.SLASHQUARTERSHARP:e="+-";break;case s.SLASHSHARP:e="++-";break;case s.DOUBLESLASHFLAT:e="bss";break;case s.SORI:e="o";break;case s.KORON:e="k"}return e}get AccidentalHalfTones(){return n.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 n.octXmlDiff}getHalfTone(){return this.halfTone}getTransposedPitch(t){if(t>12)throw new Error("rewrite this method to handle bigger octave changes or don't use is with bigger octave changes!");return t>0?this.getHigherPitchByTransposeFactor(t):t<0?this.getLowerPitchByTransposeFactor(-t):this}DoEnharmonicChange(){switch(this.accidental){case s.FLAT:case s.DOUBLEFLAT:this.fundamentalNote=this.getPreviousFundamentalNote(this.fundamentalNote),this.accidental=n.AccidentalFromHalfTones(this.halfTone-(this.fundamentalNote+12*(this.octave+n.octXmlDiff)));break;case s.SHARP:case s.DOUBLESHARP:this.fundamentalNote=this.getNextFundamentalNote(this.fundamentalNote),this.accidental=n.AccidentalFromHalfTones(this.halfTone-(this.fundamentalNote+12*(this.octave+n.octXmlDiff)));break;default:return}}ToString(){let t=n.accidentalVexflow(this.accidental);return t||(t=""),"Key: "+n.getNoteEnumString(this.fundamentalNote)+t+", Note: "+this.fundamentalNote+", octave: "+this.octave.toString()}OperatorEquals(t){const e=this;return!(!e||!t)&&e.FundamentalNote===t.FundamentalNote&&e.Octave===t.Octave&&e.Accidental===t.Accidental}OperatorNotEqual(t){return!(this===t)}OperatorFundamentalGreaterThan(t){const e=this;return e.Octave===t.Octave?e.FundamentalNote>t.FundamentalNote:e.Octave>t.Octave}OperatorFundamentalLessThan(t){const e=this;return e.Octave===t.Octave?e.FundamentalNoten.pitchEnumValues.length-1?(i=n.pitchEnumValues[e+t-n.pitchEnumValues.length],r++):i=n.pitchEnumValues[e+t],new n(i,r,s.NONE)}getLowerPitchByTransposeFactor(t){const e=n.pitchEnumValues.indexOf(this.fundamentalNote);let i,r=this.octave;return e-t<0?(i=n.pitchEnumValues[n.pitchEnumValues.length+e-t],r--):i=n.pitchEnumValues[e-t],new n(i,r,s.NONE)}getNextFundamentalNote(t){let e=n.pitchEnumValues.indexOf(t);return e=(e+1)%n.pitchEnumValues.length,n.pitchEnumValues[e]}getPreviousFundamentalNote(t){const e=n.pitchEnumValues.indexOf(t);return e>0?n.pitchEnumValues[e-1]:n.pitchEnumValues[n.pitchEnumValues.length-1]}}e.Pitch=n,n.pitchEnumValues=[i.C,i.D,i.E,i.F,i.G,i.A,i.B],n.halftoneFactor=12/(Math.LN2/Math.LN10),n.octXmlDiff=3},9086:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PointF2D=void 0;class i{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}static get Empty(){return new i}static pointsAreEqual(t,e){return t.x===e.x&&t.y===e.y}ToString(){return"["+this.x+", "+this.y+"]"}}e.PointF2D=i},3278:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RectangleF2D=void 0;const s=i(739),n=i(9086);class r{constructor(t,e,i,s){this.x=0,this.y=0,this.width=0,this.height=0,this.x=t,this.y=e,this.width=i,this.height=s}static createFromLocationAndSize(t,e){return new r(t.x,t.y,e.width,e.height)}get Location(){return new n.PointF2D(this.x,this.y)}get Size(){return new s.SizeF2D(this.width,this.height)}}e.RectangleF2D=r},739:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SizeF2D=void 0,e.SizeF2D=class{constructor(t=0,e=0){this.width=t,this.height=e}}},8918:function(t,e,i){"use strict";var s=this&&this.__createBinding||(Object.create?function(t,e,i,s){void 0===s&&(s=i);var n=Object.getOwnPropertyDescriptor(e,i);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,s,n)}:function(t,e,i,s){void 0===s&&(s=i),t[s]=e[i]}),n=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||s(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(i(1797),e),n(i(8363),e),n(i(9651),e),n(i(9855),e),n(i(8640),e),n(i(9086),e),n(i(3278),e),n(i(739),e)},2562:(t,e)=>{"use strict";var i;Object.defineProperty(e,"__esModule",{value:!0}),e.FontStyles=void 0,(i=e.FontStyles||(e.FontStyles={}))[i.Regular=0]="Regular",i[i.Bold=1]="Bold",i[i.Italic=2]="Italic",i[i.BoldItalic=3]="BoldItalic",i[i.Underlined=4]="Underlined"},96:(t,e)=>{"use strict";var i;Object.defineProperty(e,"__esModule",{value:!0}),e.Fonts=void 0,(i=e.Fonts||(e.Fonts={}))[i.TimesNewRoman=0]="TimesNewRoman",i[i.Kokila=1]="Kokila"},1274:(t,e)=>{"use strict";var i;Object.defineProperty(e,"__esModule",{value:!0}),e.TextAlignment=e.TextAlignmentEnum=void 0,function(t){t[t.LeftTop=0]="LeftTop",t[t.LeftCenter=1]="LeftCenter",t[t.LeftBottom=2]="LeftBottom",t[t.CenterTop=3]="CenterTop",t[t.CenterCenter=4]="CenterCenter",t[t.CenterBottom=5]="CenterBottom",t[t.RightTop=6]="RightTop",t[t.RightCenter=7]="RightCenter",t[t.RightBottom=8]="RightBottom"}(i=e.TextAlignmentEnum||(e.TextAlignmentEnum={})),e.TextAlignment=class{static IsLeft(t){return t===i.LeftTop||t===i.LeftCenter||t===i.LeftBottom}static IsCenterAligned(t){return t===i.CenterTop||t===i.CenterCenter||t===i.CenterBottom}static IsRight(t){return t===i.RightTop||t===i.RightCenter||t===i.RightBottom}}},7119:(t,e)=>{"use strict";var i;Object.defineProperty(e,"__esModule",{value:!0}),e.TieTypes=void 0,(i=e.TieTypes||(e.TieTypes={})).SIMPLE="",i.HAMMERON="H",i.PULLOFF="P",i.SLIDE="S",i.TAPPING="T"},5544:function(t,e,i){"use strict";var s=this&&this.__createBinding||(Object.create?function(t,e,i,s){void 0===s&&(s=i);var n=Object.getOwnPropertyDescriptor(e,i);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,s,n)}:function(t,e,i,s){void 0===s&&(s=i),t[s]=e[i]}),n=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||s(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(i(2562),e),n(i(96),e),n(i(1274),e),n(i(7119),e)},7056:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.MXLHelper=void 0;const n=i(9228),r=s(i(5733)),o=s(i(2043));e.MXLHelper=class{static MXLtoIXmlElement(t){const e=new r.default;return e.loadAsync(t).then((t=>e.file("META-INF/container.xml").async("text")),(t=>{throw t})).then((t=>{const i=(new DOMParser).parseFromString(t,"text/xml").getElementsByTagName("rootfile")[0].getAttribute("full-path");return e.file(i).async("text")}),(t=>{throw t})).then((t=>{const e=(new DOMParser).parseFromString(t,"text/xml"),i=new n.IXmlElement(e.documentElement);return Promise.resolve(i)}),(t=>{throw t})).then((t=>t),(t=>{throw new Error("extractSheetFromMxl: "+t.message)}))}static MXLtoXMLstring(t){const e=new r.default;return e.loadAsync(t).then((t=>e.file("META-INF/container.xml").async("text")),(t=>{throw o.default.error(t),t})).then((t=>{const i=(new DOMParser).parseFromString(t,"text/xml").getElementsByTagName("rootfile")[0].getAttribute("full-path");return e.file(i).async("text")}),(t=>{throw t}))}}},9228:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.IXmlElement=void 0;class i{constructor(t){if(this.hasAttributes=!1,!t)throw new Error("IXmlElement: expected Element, got undefined");this.elem=t,this.name=t.nodeName.toLowerCase(),t.hasAttributes()&&(this.hasAttributes=!0,this.firstAttribute=t.attributes[0]),this.hasElements=t.hasChildNodes(),1===t.childNodes.length&&t.childNodes[0].nodeType===Node.TEXT_NODE?this.value=t.childNodes[0].nodeValue:this.value=""}attribute(t){return this.elem.attributes.getNamedItem(t)}attributes(){if(!this.attrs){const t=this.elem.attributes,e=[];for(let i=0;i0){let s;for(let i=0,n=e.length;i{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.StringUtil=void 0,e.StringUtil=class{static StringContainsSeparatedWord(t,e,i=!1){return new RegExp("( |^)"+e+"([ .]|$)",i?"i":void 0).test(t)}}},5205:function(t,e,i){"use strict";var s=this&&this.__createBinding||(Object.create?function(t,e,i,s){void 0===s&&(s=i);var n=Object.getOwnPropertyDescriptor(e,i);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,s,n)}:function(t,e,i,s){void 0===s&&(s=i),t[s]=e[i]}),n=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||s(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(i(8918),e),n(i(5544),e),n(i(9633),e)},1703:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InvalidEnumArgumentException=e.ArgumentOutOfRangeException=e.MusicSheetReadingException=void 0,e.MusicSheetReadingException=class{constructor(t,e){this.message=t,e&&(this.message+=" "+e.toString())}},e.ArgumentOutOfRangeException=class{constructor(t){this.message=t}},e.InvalidEnumArgumentException=class{constructor(t){this.message=t}}},6791:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AbstractGraphicalExpression=void 0;const s=i(4785),n=i(8911);class r extends s.GraphicalObject{constructor(t,e,i){super(),this.expression=e,this.parentMeasure=i,this.boundingBox=new n.BoundingBox(this,t.PositionAndShape),this.parentStaffLine=t,this.parentStaffLine.AbstractExpressions.push(this),this.rules=t.ParentMusicSystem.rules}get Label(){return this.label}get ParentStaffLine(){return this.parentStaffLine}get SourceExpression(){return this.expression}get Placement(){return this.expression.Placement}}e.AbstractGraphicalExpression=r},6055:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AbstractGraphicalInstruction=void 0;const s=i(4785);class n extends s.GraphicalObject{constructor(t){super(),this.parent=t}get Parent(){return this.parent}set Parent(t){this.parent=t}}e.AbstractGraphicalInstruction=n},1070:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AccidentalCalculator=void 0;const s=i(8640),n=i(8640),r=i(1649),o=i(4040);e.AccidentalCalculator=class{constructor(){this.keySignatureNoteAlterationsDict=new r.Dictionary,this.currentAlterationsComparedToKeyInstructionList=[],this.currentInMeasureNoteAlterationsDict=new r.Dictionary}get ActiveKeyInstruction(){return this.activeKeyInstruction}set ActiveKeyInstruction(t){this.activeKeyInstruction=t,this.reactOnKeyInstructionChange()}doCalculationsAtEndOfMeasure(){this.currentInMeasureNoteAlterationsDict.clear(),this.currentAlterationsComparedToKeyInstructionList.clear();for(const t of this.keySignatureNoteAlterationsDict.keys())this.currentInMeasureNoteAlterationsDict.setValue(t,this.keySignatureNoteAlterationsDict.getValue(t))}checkAccidental(t,e){if(!e)return;const i=e.FundamentalNote+12*e.Octave,r=this.currentAlterationsComparedToKeyInstructionList.indexOf(i)>=0;if(this.currentInMeasureNoteAlterationsDict.containsKey(i)){if(r&&this.currentAlterationsComparedToKeyInstructionList.splice(this.currentAlterationsComparedToKeyInstructionList.indexOf(i),1),this.currentInMeasureNoteAlterationsDict.getValue(i)!==e.AccidentalHalfTones){this.keySignatureNoteAlterationsDict.containsKey(i)&&this.keySignatureNoteAlterationsDict.getValue(i)!==e.AccidentalHalfTones?(this.currentAlterationsComparedToKeyInstructionList.push(i),this.currentInMeasureNoteAlterationsDict.setValue(i,e.AccidentalHalfTones)):e.Accidental!==s.AccidentalEnum.NONE&&this.currentInMeasureNoteAlterationsDict.remove(i);const r=this.currentInMeasureNoteAlterationsDict.getValue(i);if(e.Accidental===s.AccidentalEnum.NONE&&(e=.5===Math.abs(r)?new n.Pitch(e.FundamentalNote,e.Octave,s.AccidentalEnum.NONE):new n.Pitch(e.FundamentalNote,e.Octave,s.AccidentalEnum.NATURAL)),this.isAlterAmbiguousAccidental(e.Accidental)&&!e.AccidentalXml)return;o.MusicSheetCalculator.symbolFactory.addGraphicalAccidental(t,e)}}else if(e.Accidental!==s.AccidentalEnum.NONE){if(r||this.currentAlterationsComparedToKeyInstructionList.push(i),this.currentInMeasureNoteAlterationsDict.setValue(i,e.AccidentalHalfTones),this.isAlterAmbiguousAccidental(e.Accidental)&&!e.AccidentalXml)return;o.MusicSheetCalculator.symbolFactory.addGraphicalAccidental(t,e)}else r&&(e=new n.Pitch(e.FundamentalNote,e.Octave,s.AccidentalEnum.NATURAL),this.currentAlterationsComparedToKeyInstructionList.splice(this.currentAlterationsComparedToKeyInstructionList.indexOf(i),1),o.MusicSheetCalculator.symbolFactory.addGraphicalAccidental(t,e))}isAlterAmbiguousAccidental(t){return t===s.AccidentalEnum.SLASHFLAT||t===s.AccidentalEnum.QUARTERTONEFLAT}reactOnKeyInstructionChange(){const t=this.activeKeyInstruction.AlteratedNotes;let e;e=this.activeKeyInstruction.Key>0?s.AccidentalEnum.SHARP:s.AccidentalEnum.FLAT,this.keySignatureNoteAlterationsDict.clear(),this.currentAlterationsComparedToKeyInstructionList.length=0;for(let i=-9;i<9;i++)for(let s=0;sthis.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(t,1)}this.parent=t,this.parent.ChildElements.indexOf(this)>-1?n.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 o.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,e=this.ChildElements.length;t.001;break;case c.Up:case c.Down:s=this.relativePosition.y,t.calculateMarginPositionAlongDirection(this,e),n=Math.abs(s-this.relativePosition.y)>.001;break;default:throw new r.ArgumentOutOfRangeException("direction")}}while(n)}collisionDetection(t){const e=Math.min(this.AbsolutePosition.x+this.borderRight,t.absolutePosition.x+t.borderRight)-Math.max(this.AbsolutePosition.x+this.borderLeft,t.absolutePosition.x+t.borderLeft),i=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 e>0&&i>0}liesInsideBorders(t){const e=this.AbsolutePosition.x+this.borderLeft<=t.absolutePosition.x+t.borderLeft&&t.absolutePosition.x+t.borderLeft<=this.AbsolutePosition.x+this.borderRight,i=this.AbsolutePosition.x+this.borderLeft<=t.absolutePosition.x+t.borderRight&&t.absolutePosition.x+t.borderRight<=this.AbsolutePosition.x+this.borderRight;if(e&&i){const e=this.AbsolutePosition.y+this.borderTop<=t.absolutePosition.y+t.borderTop&&t.absolutePosition.y+t.borderTop<=this.AbsolutePosition.y+this.borderBottom,i=this.AbsolutePosition.y+this.borderTop<=t.absolutePosition.y+t.borderBottom&&t.absolutePosition.y+t.borderBottom<=this.AbsolutePosition.y+this.borderBottom;if(e&&i)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 e=Math.min(this.AbsolutePosition.x+this.borderMarginRight,t.absolutePosition.x+t.borderMarginRight)-Math.max(this.AbsolutePosition.x+this.borderMarginLeft,t.absolutePosition.x+t.borderMarginLeft),i=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 e>0&&i>0}liesInsideMargins(t){const e=this.AbsolutePosition.x+this.borderMarginLeft<=t.absolutePosition.x+t.borderMarginLeft&&t.absolutePosition.x+t.borderMarginLeft<=this.AbsolutePosition.x+this.borderMarginRight,i=this.AbsolutePosition.x+this.borderMarginLeft<=t.absolutePosition.x+t.borderMarginRight&&t.absolutePosition.x+t.borderMarginRight<=this.AbsolutePosition.x+this.borderMarginRight;if(e&&i){const e=this.AbsolutePosition.y+this.borderMarginTop<=t.absolutePosition.y+t.borderMarginTop&&t.absolutePosition.y+t.borderMarginTop<=this.AbsolutePosition.y+this.borderMarginBottom,i=this.AbsolutePosition.y+this.borderMarginTop<=t.absolutePosition.y+t.borderMarginBottom&&t.absolutePosition.y+t.borderMarginBottom<=this.AbsolutePosition.y+this.borderMarginBottom;if(e&&i)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,e,i){this.RelativePosition=new o.PointF2D(i.x,i.y),this.setAbsolutePositionFromParent();let s=0,n=!1;do{switch(e){case c.Left:case c.Right:s=this.relativePosition.x,t.calculatePositionAlongDirection(this,e),n=Math.abs(s-this.relativePosition.x)>1e-4;break;case c.Up:case c.Down:s=this.relativePosition.y,t.calculatePositionAlongDirection(this,e),n=Math.abs(s-this.relativePosition.y)>1e-4;break;default:throw new r.ArgumentOutOfRangeException("direction")}}while(n)}getClickedObjectOfType(t){const e=this.dataObject;if(this.pointLiesInsideBorders(t)&&e)return e;for(let e=0,i=this.childElements.length;e{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Clickable=void 0;const s=i(4785);class n extends s.GraphicalObject{}e.Clickable=n},8155:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AutoColorSet=e.NoteState=e.GraphicalLayers=e.StyleSets=e.OUTLINE_AND_FILL_STYLE_DICT=e.OutlineAndFillStyleEnum=void 0;const s=i(1649);var n,r,o,a,l;!function(t){t[t.BaseWritingColor=0]="BaseWritingColor",t[t.FollowingCursor=1]="FollowingCursor",t[t.AlternativeFollowingCursor=2]="AlternativeFollowingCursor",t[t.PlaybackCursor=3]="PlaybackCursor",t[t.Highlighted=4]="Highlighted",t[t.ErrorUnderlay=5]="ErrorUnderlay",t[t.Selected=6]="Selected",t[t.SelectionSymbol=7]="SelectionSymbol",t[t.DebugColor1=8]="DebugColor1",t[t.DebugColor2=9]="DebugColor2",t[t.DebugColor3=10]="DebugColor3",t[t.SplitScreenDivision=11]="SplitScreenDivision",t[t.GreyTransparentOverlay=12]="GreyTransparentOverlay",t[t.MarkedArea1=13]="MarkedArea1",t[t.MarkedArea2=14]="MarkedArea2",t[t.MarkedArea3=15]="MarkedArea3",t[t.MarkedArea4=16]="MarkedArea4",t[t.MarkedArea5=17]="MarkedArea5",t[t.MarkedArea6=18]="MarkedArea6",t[t.MarkedArea7=19]="MarkedArea7",t[t.MarkedArea8=20]="MarkedArea8",t[t.MarkedArea9=21]="MarkedArea9",t[t.MarkedArea10=22]="MarkedArea10",t[t.Comment1=23]="Comment1",t[t.Comment2=24]="Comment2",t[t.Comment3=25]="Comment3",t[t.Comment4=26]="Comment4",t[t.Comment5=27]="Comment5",t[t.Comment6=28]="Comment6",t[t.Comment7=29]="Comment7",t[t.Comment8=30]="Comment8",t[t.Comment9=31]="Comment9",t[t.Comment10=32]="Comment10"}(n=e.OutlineAndFillStyleEnum||(e.OutlineAndFillStyleEnum={})),e.OUTLINE_AND_FILL_STYLE_DICT=new s.Dictionary,e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.BaseWritingColor,"Thistle"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.FollowingCursor,"Aqua"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.AlternativeFollowingCursor,"Azure"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.PlaybackCursor,"Bisque"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.Highlighted,"CadetBlue"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.ErrorUnderlay,"DarkBlue"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.Selected,"DarkGoldenRod"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.SelectionSymbol,"BlanchedAlmond"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.DebugColor1,"Chartreuse"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.DebugColor2,"DarkGreen"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.DebugColor3,"DarkOrange"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.SplitScreenDivision,"FireBrick"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.GreyTransparentOverlay,"DarkSalmon"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.MarkedArea1,"DarkSeaGreen"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.MarkedArea2,"DarkOrchid"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.MarkedArea3,"Aquamarine"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.MarkedArea4,"DarkKhaki"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.MarkedArea5,"ForestGreen"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.MarkedArea6,"AliceBlue"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.MarkedArea7,"DeepPink"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.MarkedArea8,"Coral"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.MarkedArea9,"DarkOliveGreen"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.MarkedArea10,"Chocolate"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.Comment1,"DodgerBlue"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.Comment2,"Blue"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.Comment3,"Beige"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.Comment4,"Crimson"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.Comment5,"Fuchsia"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.Comment6,"Brown"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.Comment7,"BlanchedAlmond"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.Comment8,"CornflowerBlue"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.Comment9,"Cornsilk"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(n.Comment10,"DarkGrey"),(l=e.StyleSets||(e.StyleSets={}))[l.MarkedArea=0]="MarkedArea",l[l.Comment=1]="Comment",(a=e.GraphicalLayers||(e.GraphicalLayers={}))[a.Background=0]="Background",a[a.Highlight=1]="Highlight",a[a.MeasureError=2]="MeasureError",a[a.SelectionSymbol=3]="SelectionSymbol",a[a.Cursor=4]="Cursor",a[a.PSI_Debug=5]="PSI_Debug",a[a.Notes=6]="Notes",a[a.Comment=7]="Comment",a[a.Debug_above=8]="Debug_above",(o=e.NoteState||(e.NoteState={}))[o.Normal=0]="Normal",o[o.Selected=1]="Selected",o[o.Follow_Confirmed=2]="Follow_Confirmed",o[o.QFeedback_NotFound=3]="QFeedback_NotFound",o[o.QFeedback_OK=4]="QFeedback_OK",o[o.QFeedback_Perfect=5]="QFeedback_Perfect",o[o.Debug1=6]="Debug1",o[o.Debug2=7]="Debug2",o[o.Debug3=8]="Debug3",(r=e.AutoColorSet||(e.AutoColorSet={})).C="#d82c6b",r.D="#F89D15",r.E="#FFE21A",r.F="#4dbd5c",r.G="#009D96",r.A="#43469d",r.B="#76429c",r.Rest="#000000"},5074:(t,e)=>{"use strict";var i,s,n;Object.defineProperty(e,"__esModule",{value:!0}),e.PhonicScoreModes=e.MusicSymbolDrawingStyle=e.DrawingMode=void 0,(n=e.DrawingMode||(e.DrawingMode={}))[n.All=0]="All",n[n.NoOverlays=1]="NoOverlays",n[n.Leadsheet=2]="Leadsheet",(s=e.MusicSymbolDrawingStyle||(e.MusicSymbolDrawingStyle={}))[s.Normal=0]="Normal",s[s.Disabled=1]="Disabled",s[s.Selected=2]="Selected",s[s.Clickable=3]="Clickable",s[s.PlaybackSymbols=4]="PlaybackSymbols",s[s.FollowSymbols=5]="FollowSymbols",s[s.QFeedbackNotFound=6]="QFeedbackNotFound",s[s.QFeedbackOk=7]="QFeedbackOk",s[s.QFeedbackPerfect=8]="QFeedbackPerfect",s[s.Debug1=9]="Debug1",s[s.Debug2=10]="Debug2",s[s.Debug3=11]="Debug3",(i=e.PhonicScoreModes||(e.PhonicScoreModes={}))[i.Following=0]="Following",i[i.Midi=1]="Midi",i[i.Manual=2]="Manual"},7459:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DrawingParameters=e.DrawingParametersEnum=e.ColoringModes=void 0;const s=i(1405),n=i(3748);var r,o;(o=e.ColoringModes||(e.ColoringModes={}))[o.XML=0]="XML",o[o.AutoColoring=1]="AutoColoring",o[o.CustomColorSet=2]="CustomColorSet",function(t){t.allon="allon",t.compact="compact",t.compacttight="compacttight",t.default="default",t.leadsheet="leadsheet",t.preview="preview",t.thumbnail="thumbnail"}(r=e.DrawingParametersEnum||(e.DrawingParametersEnum={})),e.DrawingParameters=class{constructor(t=r.default,e){this.drawCursors=!0,this.drawTitle=!0,this.drawSubtitle=!0,this.drawLyricist=!0,this.drawComposer=!0,this.drawCopyright=!1,this.drawCredits=!0,this.drawPartNames=!0,this.fingeringPosition=n.PlacementEnum.Left,this.drawHiddenNotes=!1,this.rules=e,this.rules||(this.rules=new s.EngravingRules),this.DrawingParametersEnum=t}set DrawingParametersEnum(t){switch(this.drawingParametersEnum=t,t){case r.allon:this.setForAllOn();break;case r.thumbnail:this.setForThumbnail();break;case r.leadsheet:this.setForLeadsheet();break;case r.compact:this.setForCompactMode();break;case r.compacttight:this.setForCompactTightMode();break;case r.default:default:this.setForDefault()}}get DrawingParametersEnum(){return this.drawingParametersEnum}setForAllOn(){this.drawHighlights=!0,this.drawErrors=!0,this.drawSelectionStartSymbol=!0,this.drawSelectionEndSymbol=!0,this.drawCursors=!0,this.drawActivitySymbols=!0,this.drawScrollIndicator=!0,this.drawComments=!0,this.drawMarkedAreas=!0,this.DrawTitle=!0,this.DrawSubtitle=!0,this.DrawComposer=!0,this.DrawLyricist=!0,this.drawCredits=!0,this.DrawPartNames=!0,this.drawHiddenNotes=!0,this.rules.CompactMode=!1}setForDefault(){this.rules.loadDefaultValues(),this.setForAllOn(),this.drawHiddenNotes=!1}setForThumbnail(){this.drawHighlights=!1,this.drawErrors=!1,this.drawSelectionStartSymbol=!1,this.drawSelectionStartSymbol=!1,this.drawCursors=!1,this.drawActivitySymbols=!1,this.drawScrollIndicator=!1,this.drawComments=!0,this.drawMarkedAreas=!0,this.drawHiddenNotes=!1}setForCompactMode(){this.rules.CompactMode=!0,this.DrawCredits=!1,this.drawHiddenNotes=!1}setForCompactTightMode(){this.setForCompactMode(),this.DrawPartNames=!1,this.rules.VoiceSpacingMultiplierVexflow=.65,this.rules.VoiceSpacingAddendVexflow=2,this.rules.MinSkyBottomDistBetweenStaves=1,this.rules.MinSkyBottomDistBetweenSystems=1,this.rules.BetweenStaffDistance=2.5,this.rules.StaffDistance=3.5,this.rules.MinimumDistanceBetweenSystems=1,this.rules.PageBottomMargin=0,this.rules.PageLeftMargin=2,this.rules.PageRightMargin=2}setForLeadsheet(){this.drawHighlights=!1,this.drawErrors=!1,this.drawSelectionStartSymbol=!0,this.drawSelectionEndSymbol=!0,this.drawCursors=!0,this.drawActivitySymbols=!1,this.drawScrollIndicator=!0,this.drawComments=!0,this.drawMarkedAreas=!0}get DrawCredits(){return this.drawCredits}set DrawCredits(t){this.drawCredits=t,this.DrawComposer=t,this.DrawTitle=t,this.DrawSubtitle=t,this.DrawLyricist=t,this.DrawCopyright=t}get DrawTitle(){return this.drawTitle}set DrawTitle(t){this.drawTitle=t,this.rules.RenderTitle=t,t||(this.DrawSubtitle=!1)}get DrawSubtitle(){return this.drawSubtitle}set DrawSubtitle(t){this.drawSubtitle=t,this.rules.RenderSubtitle=t,t&&(this.DrawTitle=!0)}get DrawComposer(){return this.drawComposer}set DrawComposer(t){this.drawComposer=t,this.rules.RenderComposer=t}get DrawLyricist(){return this.drawLyricist}set DrawLyricist(t){this.drawLyricist=t,this.rules.RenderLyricist=t}get DrawCopyright(){return this.drawCopyright}set DrawCopyright(t){this.drawCopyright=t,this.rules.RenderCopyright=t}get DrawPartNames(){return this.drawPartNames}set DrawPartNames(t){this.drawPartNames=t,this.rules.RenderPartNames=t,this.rules.RenderPartNames||(this.rules.RenderPartAbbreviations=!1)}get FingeringPosition(){return this.fingeringPosition}set FingeringPosition(t){this.fingeringPosition=t,this.rules.FingeringPosition=t}get Rules(){return this.rules}set Rules(t){this.rules=t}}},1405:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.PageFormat=e.EngravingRules=void 0;const n=i(599),r=s(i(2043)),o=i(1274),a=i(3748),l=i(41),h=i(7459),c=i(1649),u=i(5544),d=i(8640),f=i(4123),m=i(3486);class p{constructor(){this.NoteDistances=[1,1,1.3,1.6,2,2.5,3,4],this.NoteDistancesScalingFactors=[1,2,4,8,16,32,64,128],this.DurationDistanceDict={},this.DurationScalingDistanceDict={},this.NoteToGraphicalNoteMapObjectCount=0,this.loadDefaultValues()}loadDefaultValues(){this.SamplingUnit=3*p.unit,this.SheetTitleHeight=4,this.SheetSubtitleHeight=2,this.SheetMinimumDistanceBetweenTitleAndSubtitle=1,this.SheetComposerHeight=2,this.SheetAuthorHeight=2,this.SheetCopyrightHeight=1.5,this.SheetCopyrightMargin=2,this.CompactMode=!1,this.PagePlacementEnum=n.PagePlacementEnum.Down,this.PageHeight=100001,this.PageTopMargin=5,this.PageTopMarginNarrow=0,this.PageBottomMargin=5,this.PageLeftMargin=5,this.PageRightMargin=5,this.TitleTopDistance=5,this.TitleBottomDistance=1,this.StaffDistance=7,this.BetweenStaffDistance=5,this.MinimumStaffLineDistance=4,this.MinSkyBottomDistBetweenStaves=1,this.StaffHeight=4,this.TabStaffInterlineHeight=1.1111,this.BetweenStaffLinesDistance=p.unit,this.SystemLeftMargin=0,this.SystemRightMargin=0,this.SystemLabelsRightMargin=2,this.SystemComposerDistance=2,this.InstrumentLabelTextHeight=2,this.MinimumDistanceBetweenSystems=7,this.MinSkyBottomDistBetweenSystems=5,this.LastSystemMaxScalingFactor=1.4,this.AutoBeamNotes=!1,this.AutoBeamOptions={beam_middle_rests_only:!1,beam_rests:!1,maintain_stem_directions:!1},this.AutoBeamTabs=!1,this.BeamWidth=p.unit/2,this.BeamSpaceWidth=p.unit/3,this.BeamForwardLength=1.25*p.unit,this.FlatBeams=!1,this.FlatBeamOffset=20,this.FlatBeamOffsetPerBeam=10,this.ClefLeftMargin=.5,this.ClefRightMargin=.75,this.PercussionOneLineCutoff=3,this.PercussionForceVoicesOneLineCutoff=1,this.PercussionUseXMLDisplayStep=!0,this.PercussionXMLDisplayStepNoteValueShift=0,this.PercussionOneLineXMLDisplayStepOctaveOffset=0,this.BetweenKeySymbolsDistance=.2,this.KeyRightMargin=.75,this.RhythmRightMargin=1.25,this.ShowRhythmAgainAfterPartEndOrFinalBarline=!0,this.NewPartAndSystemAfterFinalBarline=!1,this.InStaffClefScalingFactor=.8,this.DistanceBetweenNaturalAndSymbolWhenCancelling=.4,this.NoteHelperLinesOffset=.25,this.MeasureLeftMargin=.7,this.MeasureRightMargin=0,this.DistanceBetweenLastInstructionAndRepetitionBarline=1,this.ArpeggioDistance=.6,this.StaccatoShorteningFactor=2,this.IdealStemLength=3,this.StemNoteHeadBorderYOffset=.2,this.StemMargin=.2,this.StemMinLength=2.5,this.StemMaxLength=4.5,this.BeamSlopeMaxAngle=10,this.StemMinAllowedDistanceBetweenNoteHeadAndBeamLine=1,this.SetWantedStemDirectionByXml=!0,this.GraceNoteScalingFactor=.6,this.GraceNoteXOffset=.2,this.GraceNoteGroupXMargin=0,this.WedgeOpeningLength=1.2,this.WedgeMeasureEndOpeningLength=.75,this.WedgeMeasureBeginOpeningLength=.75,this.WedgePlacementAboveY=-1.5,this.WedgePlacementBelowY=1.5,this.WedgeHorizontalMargin=.6,this.WedgeVerticalMargin=.5,this.DistanceOffsetBetweenTwoHorizontallyCrossedWedges=.3,this.WedgeMinLength=2,this.WedgeEndDistanceBetweenTimestampsFactor=1.75,this.SoftAccentWedgePadding=.4,this.SoftAccentSizeFactor=.6,this.DistanceBetweenAdjacentDynamics=.75,this.TempoChangeMeasureValidity=4,this.TempoContinousFactor=.7,this.StaccatoScalingFactor=.8,this.BetweenDotsDistance=.8,this.OrnamentAccidentalScalingFactor=.65,this.ChordSymbolTextHeight=2,this.ChordSymbolTextAlignment=o.TextAlignmentEnum.LeftBottom,this.ChordSymbolRelativeXOffset=-1,this.ChordSymbolXSpacing=1,this.ChordOverlapAllowedIntoNextMeasure=0,this.ChordSymbolYOffset=.1,this.ChordSymbolYPadding=0,this.ChordSymbolYAlignment=!0,this.ChordSymbolYAlignmentScope="staffline",this.ChordAccidentalTexts=new c.Dictionary,this.resetChordAccidentalTexts(this.ChordAccidentalTexts,!1),this.ChordSymbolLabelTexts=new c.Dictionary,this.resetChordSymbolLabelTexts(this.ChordSymbolLabelTexts),this.CustomChords=[],this.resetChordNames(),this.RepetitionSymbolsYOffset=0,this.RepetitionEndInstructionXShiftAsPercentOfStaveWidth=.4,this.RehearsalMarkXOffsetDefault=10,this.RehearsalMarkXOffset=0,this.RehearsalMarkXOffsetSystemStartMeasure=-20,this.RehearsalMarkYOffsetDefault=-15,this.RehearsalMarkYOffset=0,this.RehearsalMarkFontSize=10,this.MeasureNumberLabelHeight=1.5*p.unit,this.MeasureNumberLabelOffset=2,this.MeasureNumberLabelXOffset=-.5,this.TupletsRatioed=!1,this.TupletsBracketed=!1,this.TripletsBracketed=!1,this.TupletNumberLabelHeight=1.5*p.unit,this.TupletNumberYOffset=.5,this.TupletNumberLimitConsecutiveRepetitions=!0,this.TupletNumberMaxConsecutiveRepetitions=2,this.TupletNumberAlwaysDisableAfterFirstMax=!0,this.LabelMarginBorderFactor=.1,this.TupletVerticalLineLength=.5,this.TupletNumbersInTabs=!1,this.SlurPlacementFromXML=!0,this.BezierCurveStepSize=1e3,this.calculateCurveParametersArrays(),this.TieGhostObjectWidth=.75,this.TieYPositionOffsetFactor=.3,this.MinimumNeededXspaceForTieGhostObject=1,this.TieHeightMinimum=.28,this.TieHeightMaximum=1.2,this.TieHeightInterpolationK=.0288,this.TieHeightInterpolationD=.136,this.SlurNoteHeadYOffset=.5,this.SlurEndArticulationYOffset=.8,this.SlurStartArticulationYOffsetOfArticulation=.5,this.SlurStemXOffset=.3,this.SlurSlopeMaxAngle=15,this.SlurTangentMinAngle=30,this.SlurTangentMaxAngle=80,this.SlurHeightFactor=1,this.SlurHeightFlattenLongSlursFactorByWidth=.24,this.SlurHeightFlattenLongSlursFactorByAngle=.36,this.SlurHeightFlattenLongSlursCutoffAngle=47,this.SlurHeightFlattenLongSlursCutoffWidth=16,this.SlursStartingAtSameStaffEntryYOffset=.8,this.SlurMaximumYControlPointDistance=void 0,this.GlissandoNoteOffset=.5,this.GlissandoStafflineStartMinimumWidth=1,this.GlissandoStafflineStartYDistanceToNote=.8,this.GlissandoStafflineEndOffset=1,this.GlissandoDefaultWidth=.1,this.RepetitionEndingLabelHeight=2,this.RepetitionEndingLabelXOffset=.5,this.RepetitionEndingLabelYOffset=.3,this.RepetitionEndingLineYLowerOffset=.5,this.RepetitionEndingLineYUpperOffset=.3,this.VoltaOffset=2.5,this.LyricsAlignmentStandard=o.TextAlignmentEnum.LeftBottom,this.LyricsHeight=2,this.LyricsYOffsetToStaffHeight=0,this.LyricsYMarginToBottomLine=.2,this.VerticalBetweenLyricsDistance=.5,this.HorizontalBetweenLyricsDistance=.2,this.BetweenSyllableMaximumDistance=10,this.BetweenSyllableMinimumDistance=.5,this.LyricOverlapAllowedIntoNextMeasure=3.4,this.MinimumDistanceBetweenDashes=10,this.MaximumLyricsElongationFactor=2.5,this.TempoYSpacing=.5,this.InstantaneousTempoTextHeight=2.3,this.ContinuousDynamicTextHeight=2.3,this.MoodTextHeight=2.3,this.UnknownTextHeight=2,this.ContinuousTempoTextHeight=2.3,this.DynamicExpressionMaxDistance=2,this.DynamicExpressionSpacer=.5,this.VexFlowDefaultNotationFontScale=39,this.VexFlowDefaultTabFontScale=39,this.TremoloStrokeScale=1,this.TremoloYSpacingScale=1,this.StemWidth=.15,this.StaffLineWidth=.1,this.StaffLineColor=void 0,this.LedgerLineWidth=1,this.LedgerLineStrokeStyle=void 0,this.LedgerLineColorDefault="#000000",this.WedgeLineWidth=.12,this.TupletLineWidth=.12,this.LyricUnderscoreLineWidth=.12,this.SystemThinLineWidth=.12,this.SystemBoldLineWidth=p.unit/2,this.SystemRepetitionEndingLineWidth=.12,this.SystemDotWidth=p.unit/2,this.DistanceBetweenVerticalSystemLines=.35,this.DistanceBetweenDotAndLine=.7,this.RepeatEndStartPadding=2,this.OctaveShiftLineWidth=.12,this.OctaveShiftVerticalLineLength=p.unit,this.GraceLineWidth=this.StaffLineWidth*this.GraceNoteScalingFactor,this.MultipleRestMeasureDefaultWidth=4,this.MultipleRestMeasureAddKeySignature=!0,this.FixedMeasureWidth=!1,this.FixedMeasureWidthFixedValue=void 0,this.MinimumCrossedBeamDifferenceMargin=1e-4,this.SheetMaximumWidth=32767,this.VoiceSpacingMultiplierVexflow=.85,this.VoiceSpacingAddendVexflow=3,this.PickupMeasureWidthMultiplier=1,this.PickupMeasureRepetitionSpacing=.8,this.PickupMeasureSpacingSingleNoteAddend=1.6,this.DisplacedNoteMargin=.1,this.MinNoteDistance=2,this.SubMeasureXSpacingThreshold=35,this.MeasureDynamicsMaxScalingFactor=2.5,this.WholeRestXShiftVexflow=-1.5,this.MetronomeMarksDrawn=!0,this.MetronomeMarkXShift=-6,this.MetronomeMarkYShift=-1,this.SoftmaxFactorVexFlow=15,this.StaggerSameWholeNotes=!0,this.AlignRests=l.AlignRestOption.Never,this.RestCollisionYPadding=0,this.FillEmptyMeasuresWithWholeRest=l.FillEmptyMeasuresWithWholeRests.No,this.ArpeggiosGoAcrossVoices=!1,this.RenderArpeggios=!0,this.RenderSlurs=!0,this.RenderGlissandi=!0,this.ColoringMode=h.ColoringModes.XML,this.ColoringEnabled=!0,this.ColorStemsLikeNoteheads=!1,this.ColorBeams=!0,this.ColorFlags=!0,this.applyDefaultColorMusic("#000000"),this.DefaultColorCursor="#33e02f",this.DefaultFontFamily="Times New Roman",this.DefaultFontStyle=u.FontStyles.Regular,this.DefaultVexFlowNoteFont="gonville",this.MaxMeasureToDrawIndex=Number.MAX_VALUE,this.MinMeasureToDrawIndex=0,this.MaxSystemToDrawNumber=Number.MAX_VALUE,this.MaxPageToDrawNumber=Number.MAX_VALUE,this.RenderComposer=!0,this.RenderTitle=!0,this.RenderSubtitle=!0,this.RenderLyricist=!0,this.RenderCopyright=!1,this.RenderPartNames=!0,this.RenderPartAbbreviations=!0,this.RenderFingerings=!0,this.RenderMeasureNumbers=!0,this.RenderMeasureNumbersOnlyAtSystemStart=!1,this.UseXMLMeasureNumbers=!0,this.RenderLyrics=!0,this.RenderChordSymbols=!0,this.RenderMultipleRestMeasures=!0,this.AutoGenerateMultipleRestMeasuresFromRestMeasures=!0,this.RenderRehearsalMarks=!0,this.RenderClefsAtBeginningOfStaffline=!0,this.RenderKeySignatures=!0,this.RenderTimeSignatures=!0,this.RenderPedals=!0,this.ArticulationPlacementFromXML=!0,this.BreathMarkDistance=.8,this.FingeringPosition=a.PlacementEnum.AboveOrBelow,this.FingeringPositionFromXML=!0,this.FingeringPositionGrace=a.PlacementEnum.Left,this.FingeringInsideStafflines=!1,this.FingeringLabelFontHeight=1.7,this.FingeringOffsetX=0,this.FingeringOffsetY=0,this.FingeringPaddingY=-.2,this.FingeringTextSize=1.5,this.RenderStringNumbersClassical=!0,this.StringNumberOffsetY=0,this.NewSystemAtXMLNewSystemAttribute=!1,this.NewPageAtXMLNewPageAttribute=!1,this.NewSystemAtXMLNewPageAttribute=!1,this.RestoreCursorAfterRerender=!0,this.StretchLastSystemLine=!1,this.IgnoreBracketsWords=!0,this.PageFormat=b.UndefinedPageFormat,this.PageBackgroundColor=void 0,this.RenderSingleHorizontalStaffline=!1,this.SpacingBetweenTextLines=0,this.NoteToGraphicalNoteMap=new c.Dictionary,this.NoteToGraphicalNoteMapObjectCount=0,this.SkyBottomLineBatchMinMeasures=5,this.SkyBottomLineWebGLMinMeasures=80,this.AlwaysSetPreferredSkyBottomLineBackendAutomatically=!0,this.DisableWebGLInFirefox=!0,this.DisableWebGLInSafariAndIOS=!0,this.setPreferredSkyBottomLineBackendAutomatically();try{this.MaxInstructionsConstValue=this.ClefLeftMargin+this.ClefRightMargin+this.KeyRightMargin+this.RhythmRightMargin+11}catch(t){r.default.info("EngravingRules()",t)}}setPreferredSkyBottomLineBackendAutomatically(t=-1){var e,i,s,n;let r="",o="";"object"==typeof globalThis&&(r=null!==(i=null===(e=globalThis.navigator)||void 0===e?void 0:e.vendor)&&void 0!==i?i:"",o=null!==(n=null===(s=globalThis.navigator)||void 0===s?void 0:s.userAgent)&&void 0!==n?n:"");let a=!1;(this.DisableWebGLInSafariAndIOS&&/apple/i.test(r)||this.DisableWebGLInFirefox&&o.includes("Firefox"))&&(a=!0),this.PreferredSkyBottomLineBatchCalculatorBackend=l.SkyBottomLineBatchCalculatorBackendType.Plain,a||t>=this.SkyBottomLineWebGLMinMeasures&&(this.PreferredSkyBottomLineBatchCalculatorBackend=l.SkyBottomLineBatchCalculatorBackendType.WebGL)}applyDefaultColorMusic(t){this.DefaultColorMusic=t,this.DefaultColorNotehead=t,this.DefaultColorRest=t,this.DefaultColorStem=t,this.DefaultColorLabel=t,this.DefaultColorLyrics=t,this.DefaultColorTitle=t,this.LedgerLineColorDefault=t}addGraphicalNoteToNoteMap(t,e){t.NoteToGraphicalNoteObjectId=this.NoteToGraphicalNoteMapObjectCount,this.NoteToGraphicalNoteMap.setValue(t.NoteToGraphicalNoteObjectId,e),this.NoteToGraphicalNoteMapObjectCount++}GNote(t){return m.GraphicalNote.FromNote(t,this)}clearMusicSheetObjects(){this.NoteToGraphicalNoteMap=new c.Dictionary,this.NoteToGraphicalNoteMapObjectCount=0}resetChordAccidentalTexts(t,e){t.setValue(d.AccidentalEnum.SHARP,e?"♯":"#"),t.setValue(d.AccidentalEnum.FLAT,e?"♭":"b"),t.setValue(d.AccidentalEnum.DOUBLEFLAT,e?"𝄫":"bb"),t.setValue(d.AccidentalEnum.DOUBLESHARP,e?"𝄪":"x")}setChordSymbolLabelText(t,e){this.ChordSymbolLabelTexts.setValue(t,e)}resetChordSymbolLabelTexts(t){return t.setValue(f.ChordSymbolEnum.minor,"m"),t.setValue(f.ChordSymbolEnum.augmented,"aug"),t.setValue(f.ChordSymbolEnum.diminished,"dim"),t.setValue(f.ChordSymbolEnum.dominant,"7"),t.setValue(f.ChordSymbolEnum.majorseventh,"maj7"),t.setValue(f.ChordSymbolEnum.minorseventh,"m7"),t.setValue(f.ChordSymbolEnum.diminishedseventh,"dim7"),t.setValue(f.ChordSymbolEnum.augmentedseventh,"aug7"),t.setValue(f.ChordSymbolEnum.halfdiminished,`m7${this.ChordAccidentalTexts.getValue(d.AccidentalEnum.FLAT)}5`),t.setValue(f.ChordSymbolEnum.majorminor,"m(maj7)"),t.setValue(f.ChordSymbolEnum.majorsixth,"maj6"),t.setValue(f.ChordSymbolEnum.minorsixth,"m6"),t.setValue(f.ChordSymbolEnum.dominantninth,"9"),t.setValue(f.ChordSymbolEnum.majorninth,"maj9"),t.setValue(f.ChordSymbolEnum.minorninth,"m9"),t.setValue(f.ChordSymbolEnum.dominant11th,"11"),t.setValue(f.ChordSymbolEnum.major11th,"maj11"),t.setValue(f.ChordSymbolEnum.minor11th,"m11"),t.setValue(f.ChordSymbolEnum.dominant13th,"13"),t.setValue(f.ChordSymbolEnum.major13th,"maj13"),t.setValue(f.ChordSymbolEnum.minor13th,"m13"),t.setValue(f.ChordSymbolEnum.suspendedsecond,"sus2"),t.setValue(f.ChordSymbolEnum.suspendedfourth,"sus4"),t.setValue(f.ChordSymbolEnum.power,"5"),t.setValue(f.ChordSymbolEnum.none,"N.C."),t}addChordName(t,e,i,s,n){if(void 0!==f.ChordSymbolEnum[e]){const r={adds:i,alts:s,subs:n};this.CustomChords.push(f.CustomChord.createCustomChord(t,f.ChordSymbolEnum[e],r))}}renameChord(t,e){f.CustomChord.renameCustomChord(t,e,this.CustomChords)}resetChordNames(){const t=this.ChordAccidentalTexts.getValue(d.AccidentalEnum.SHARP),e=this.ChordAccidentalTexts.getValue(d.AccidentalEnum.FLAT);this.addChordName("alt","major",[`${t}5`,`${e}9`,`${t}9`],[`${e}5`],[]),this.addChordName("7alt","dominant",[`${t}5`,`${e}9`,`${t}9`],[`${e}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${e}5`,"minorseventh",[],[`${e}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 t=0;t{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalChordSymbolContainer=void 0;const s=i(2255),n=i(9946),r=i(4123),o=i(8911),a=i(4785),l=i(9086);class h extends a.GraphicalObject{constructor(t,e,i,s,n,r){super(),this.chordSymbolContainer=t,this.boundingBox=new o.BoundingBox(this,e),this.rules=r,this.calculateLabel(i,n,s)}get GetChordSymbolContainer(){return this.chordSymbolContainer}get GraphicalLabel(){return this.graphicalLabel}calculateLabel(t,e,i){const o=r.ChordSymbolContainer.calculateChordText(this.chordSymbolContainer,e,i);this.graphicalLabel=new n.GraphicalLabel(new s.Label(o),t,this.rules.ChordSymbolTextAlignment,this.rules,this.boundingBox),this.graphicalLabel.PositionAndShape.RelativePosition=new l.PointF2D(this.rules.ChordSymbolRelativeXOffset,0),this.graphicalLabel.Label.colorDefault=this.rules.DefaultColorChordSymbol}}e.GraphicalChordSymbolContainer=h},3442:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalComment=void 0,e.GraphicalComment=class{constructor(t,e){this.label=t,this.settings=e}}},374:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalContinuousDynamicExpression=void 0;const n=i(6729),r=i(7839),o=i(9086),a=i(6791),l=i(3748),h=s(i(2043));class c extends a.AbstractGraphicalExpression{constructor(t,e,i){super(e,t,i),this.lines=[],this.isSplittedPart=!1,this.notToBeRemoved=!1}get StartMeasure(){return this.startMeasure}set StartMeasure(t){this.startMeasure=t}get EndMeasure(){return this.endMeasure}set EndMeasure(t){this.endMeasure=t}get EndStaffLine(){return this.endMeasure?this.endMeasure.ParentStaffLine:void 0}get IsSplittedPart(){return this.isSplittedPart}set IsSplittedPart(t){this.isSplittedPart=t}get IsVerbal(){return this.ContinuousDynamic.Label&&this.ContinuousDynamic.Label.length>0}get NotToBeRemoved(){return this.notToBeRemoved}set NotToBeRemoved(t){this.notToBeRemoved=t}get Lines(){return this.lines}get ContinuousDynamic(){return this.SourceExpression}updateSkyBottomLine(){var t;const e=this.parentStaffLine.SkyBottomLineCalculator,i=this.IsVerbal?this.label.PositionAndShape.RelativePosition.x+this.label.PositionAndShape.BorderMarginLeft:0,s=this.IsVerbal?this.label.PositionAndShape.RelativePosition.x+this.label.PositionAndShape.BorderMarginRight:0;switch(!this.IsSoftAccent&&!this.IsVerbal&&this.lines.length<2&&h.default.warn("Not enough lines for SkyBottomLine calculation"),this.IsVerbal||this.ContinuousDynamic.DynamicType!==r.ContDynamicEnum.crescendo&&this.ContinuousDynamic.DynamicType!==r.ContDynamicEnum.diminuendo&&h.default.warn("GraphicalContinuousDynamicExpression.updateSkyBottomLine(): unhandled continuous dynamic type. start measure: "+(null===(t=this.startMeasure)||void 0===t?void 0:t.MeasureNumber)),this.Placement){case l.PlacementEnum.Above:if(this.IsSoftAccent)e.updateSkyLineWithWedge(this.lines[0].Start,this.lines[0].End),e.updateSkyLineWithWedge(this.lines[2].End,this.lines[2].Start),e.updateSkyLineWithLine(this.lines[0].End,this.lines[2].End,this.lines[0].End.y);else if(this.IsVerbal){const t=this.label.PositionAndShape.BorderMarginTop+this.label.PositionAndShape.RelativePosition.y;e.updateSkyLineInRange(i,s,t)}else this.ContinuousDynamic.DynamicType===r.ContDynamicEnum.crescendo?e.updateSkyLineWithWedge(this.lines[0].Start,this.lines[0].End):this.ContinuousDynamic.DynamicType===r.ContDynamicEnum.diminuendo&&e.updateSkyLineWithWedge(this.lines[0].End,this.lines[0].Start);break;case l.PlacementEnum.Below:if(this.IsVerbal){const t=this.label.PositionAndShape.BorderMarginBottom+this.label.PositionAndShape.RelativePosition.y;e.updateBottomLineInRange(i,s,t)}else this.ContinuousDynamic.DynamicType===r.ContDynamicEnum.crescendo?e.updateBottomLineWithWedge(this.lines[1].Start,this.lines[1].End):this.ContinuousDynamic.DynamicType===r.ContDynamicEnum.diminuendo&&e.updateBottomLineWithWedge(this.lines[1].End,this.lines[1].Start);break;default:h.default.error("Placement for GraphicalContinuousDynamicExpression is unknown")}}createCrescendoLines(t,e,i,s=this.rules.WedgeOpeningLength,n=this.rules.WedgeLineWidth){const r=new o.PointF2D(t,i),a=new o.PointF2D(e,i-s/2),l=new o.PointF2D(e,i+s/2);this.addWedgeLines(r,a,l,n)}createFirstHalfCrescendoLines(t,e,i,s=this.rules.WedgeMeasureEndOpeningLength,n=this.rules.WedgeLineWidth){const r=new o.PointF2D(t,i),a=new o.PointF2D(e,i-s/2),l=new o.PointF2D(e,i+s/2);this.addWedgeLines(r,a,l,n)}createSecondHalfCrescendoLines(t,e,i,s=this.rules.WedgeMeasureBeginOpeningLength,n=this.rules.WedgeOpeningLength,r=this.rules.WedgeLineWidth){const a=new o.PointF2D(t,i-s/2),l=new o.PointF2D(t,i+s/2),h=new o.PointF2D(e,i-n/2),c=new o.PointF2D(e,i+n/2);this.addDoubleLines(a,h,l,c,r)}recalculateCrescendoLines(t,e,i){const s=Math.abs(this.lines[0].Start.y-this.lines[1].Start.y)>1e-4;this.lines.clear(),s?this.createSecondHalfCrescendoLines(t,e,i):this.isSplittedPart?this.createFirstHalfCrescendoLines(t,e,i):this.createCrescendoLines(t,e,i)}createDiminuendoLines(t,e,i,s=this.rules.WedgeOpeningLength,n=this.rules.WedgeLineWidth){const r=new o.PointF2D(t,i-s/2),a=new o.PointF2D(t,i+s/2),l=new o.PointF2D(e,i);this.addWedgeLines(l,r,a,n)}createFirstHalfDiminuendoLines(t,e,i,s=this.rules.WedgeOpeningLength,n=this.rules.WedgeMeasureEndOpeningLength,r=this.rules.WedgeLineWidth){const a=new o.PointF2D(t,i-s/2),l=new o.PointF2D(t,i+s/2),h=new o.PointF2D(e,i-n/2),c=new o.PointF2D(e,i+n/2);this.addDoubleLines(a,h,l,c,r)}createSecondHalfDiminuendoLines(t,e,i,s=this.rules.WedgeMeasureBeginOpeningLength,n=this.rules.WedgeLineWidth){const r=new o.PointF2D(t,i-s/2),a=new o.PointF2D(t,i+s/2),l=new o.PointF2D(e,i);this.addWedgeLines(l,r,a,n)}recalculateDiminuendoLines(t,e,i){const s=Math.abs(this.lines[0].End.y-this.lines[1].End.y)>1e-4;this.lines.clear(),s?this.createFirstHalfDiminuendoLines(t,e,i):this.isSplittedPart?this.createSecondHalfDiminuendoLines(t,e,i):this.createDiminuendoLines(t,e,i)}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===r.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(t){this.IsVerbal?(this.PositionAndShape.RelativePosition.y+=t,this.PositionAndShape.calculateBoundingBox()):(this.lines[0].Start.y+=t,this.lines[0].End.y+=t,this.lines[1].End.y+=t)}squeeze(t){this.IsVerbal||Math.abs(this.lines[0].End.x-this.lines[0].Start.x)0?this.lines[0].Start.x+=t:(this.lines[0].End.x+=t,this.lines[1].End.x+=t):t<0?this.lines[0].Start.x+=t:(this.lines[0].End.x+=t,this.lines[1].End.x+=t),this.calcPsi())}addWedgeLines(t,e,i,s){const r=new n.GraphicalLine(t,e,s),o=new n.GraphicalLine(t,i,s);this.rules.DefaultColorMusic&&(r.colorHex=this.rules.DefaultColorMusic,o.colorHex=this.rules.DefaultColorMusic),this.lines.push(r),this.lines.push(o)}addDoubleLines(t,e,i,s,r){const o=new n.GraphicalLine(t,e,r),a=new n.GraphicalLine(i,s,r);this.rules.DefaultColorMusic&&(o.colorHex=this.rules.DefaultColorMusic,a.colorHex=this.rules.DefaultColorMusic),this.lines.push(o),this.lines.push(a)}}e.GraphicalContinuousDynamicExpression=c},5330:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalCurve=void 0;const s=i(9086);class n{constructor(){n.tPow3=new Array(n.bezierCurveStepSize),n.oneMinusTPow3=new Array(n.bezierCurveStepSize),n.bezierFactorOne=new Array(n.bezierCurveStepSize),n.bezierFactorTwo=new Array(n.bezierCurveStepSize);for(let t=0;t=n.bezierCurveStepSize?new s.PointF2D:new s.PointF2D(n.oneMinusTPow3[e]*this.bezierStartPt.x+n.bezierFactorOne[e]*this.bezierStartControlPt.x+n.bezierFactorTwo[e]*this.bezierEndControlPt.x+n.tPow3[e]*this.bezierEndPt.x,n.oneMinusTPow3[e]*this.bezierStartPt.y+n.bezierFactorOne[e]*this.bezierStartControlPt.y+n.bezierFactorTwo[e]*this.bezierEndControlPt.y+n.tPow3[e]*this.bezierEndPt.y)}}e.GraphicalCurve=n,n.bezierCurveStepSize=1e3},1443:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalGlissando=void 0;const s=i(9086),n=i(8911),r=i(6729);e.GraphicalGlissando=class{constructor(t){this.Glissando=t,this.staffEntries=[]}calculateLine(t){const e=this.staffEntries[0],i=this.staffEntries[this.staffEntries.length-1],o=e.findGraphicalNoteFromNote(this.Glissando.StartNote),a=i.findGraphicalNoteFromNote(this.Glissando.EndNote);if(!o&&!a)return;const l=e.parentMeasure.ParentStaffLine;let h,c,u,d;if(o&&e.parentMeasure.ParentStaffLine===this.StaffLine)h=o.PositionAndShape.RelativePosition.x+o.parentVoiceEntry.parentStaffEntry.PositionAndShape.RelativePosition.x+o.parentVoiceEntry.parentStaffEntry.parentMeasure.PositionAndShape.RelativePosition.x+t.GlissandoNoteOffset,u=o.PositionAndShape.AbsolutePosition.y;else{h=i.parentMeasure.beginInstructionsWidth-.4;const e=this.Glissando.Direction===n.ColDirEnum.Down?-1:1;u=a.PositionAndShape.AbsolutePosition.y+e*t.GlissandoStafflineStartYDistanceToNote}if(a&&i.parentMeasure.ParentStaffLine===this.StaffLine)c=a.PositionAndShape.RelativePosition.x+a.parentVoiceEntry.parentStaffEntry.PositionAndShape.RelativePosition.x+a.parentVoiceEntry.parentStaffEntry.parentMeasure.PositionAndShape.RelativePosition.x-.5-t.GlissandoNoteOffset,h>c&&(h=c-t.GlissandoStafflineStartMinimumWidth),d=a.PositionAndShape.AbsolutePosition.y;else{if(l.Measures.last().parentSourceMeasure.HasEndLine)return;c=l.PositionAndShape.Size.width,c-h>t.GlissandoStafflineEndOffset&&(h=c-t.GlissandoStafflineEndOffset);const e=this.Glissando.Direction===n.ColDirEnum.Down?1:-1;d=o.PositionAndShape.AbsolutePosition.y+e*t.GlissandoStafflineStartYDistanceToNote}const f=new s.PointF2D(h,u),m=new s.PointF2D(c,d);void 0===this.Width&&(this.Width=t.GlissandoDefaultWidth),this.Line=new r.GraphicalLine(f,m,this.Width)}}},9428:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalInstantaneousDynamicExpression=void 0;const n=i(6791),r=i(3748),o=s(i(2043));class a extends n.AbstractGraphicalExpression{constructor(t,e,i){super(e,t,i.parentSourceMeasure),this.mInstantaneousDynamicExpression=t,this.mMeasure=i}updateSkyBottomLine(){const t=this.parentStaffLine.SkyBottomLineCalculator,e=this.PositionAndShape.RelativePosition.x+this.PositionAndShape.BorderMarginLeft,i=this.PositionAndShape.RelativePosition.x+this.PositionAndShape.BorderMarginRight;let s=0;switch(this.Placement){case r.PlacementEnum.Above:s=this.PositionAndShape.RelativePosition.y+this.PositionAndShape.BorderMarginTop,t.updateSkyLineInRange(e,i,s);break;case r.PlacementEnum.Below:s=this.PositionAndShape.RelativePosition.y+this.PositionAndShape.BorderMarginBottom,t.updateBottomLineInRange(e,i,s);break;default:o.default.error("Placement for GraphicalInstantaneousDynamicExpression is unknown")}}}e.GraphicalInstantaneousDynamicExpression=a},5277:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalInstantaneousTempoExpression=void 0;const s=i(6791);class n extends s.AbstractGraphicalExpression{constructor(t,e){super(e.PositionAndShape.Parent.DataObject,t,t.parentMeasure),this.label=e}get GraphicalLabel(){return this.label}updateSkyBottomLine(){}}e.GraphicalInstantaneousTempoExpression=n},9946:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalLabel=void 0;const s=i(1274),n=i(8911),r=i(4278),o=i(4040);class a extends r.Clickable{constructor(t,e,i,s,r){super(),this.label=t,this.boundingBox=new n.BoundingBox(this,r),this.label.fontHeight=e,this.label.textAlignment=i,this.rules=s}get Label(){return this.label}toString(){return`${this.label.text} (${this.boundingBox.RelativePosition.x},${this.boundingBox.RelativePosition.y})`}setLabelPositionAndShapeBorders(){var t,e;if(""===this.Label.text.trim())return;this.TextLines=[];const i=null!==(e=null===(t=this.rules)||void 0===t?void 0:t.LabelMarginBorderFactor)&&void 0!==e?e:.1,n=this.Label.text.split(/[\n\r]+/g),r=n.length;let a=0;for(let t=0;t0&&this.TextLines.length>1&&(l+=this.rules.SpacingBetweenTextLines*r/10);const h=this.PositionAndShape;switch(this.Label.textAlignment){case s.TextAlignmentEnum.CenterBottom:h.BorderTop=-l,h.BorderLeft=-a/2,h.BorderBottom=0,h.BorderRight=a/2;break;case s.TextAlignmentEnum.CenterCenter:h.BorderTop=-l/2,h.BorderLeft=-a/2,h.BorderBottom=l/2,h.BorderRight=a/2;break;case s.TextAlignmentEnum.CenterTop:h.BorderTop=0,h.BorderLeft=-a/2,h.BorderBottom=l,h.BorderRight=a/2;break;case s.TextAlignmentEnum.LeftBottom:h.BorderTop=-l,h.BorderLeft=0,h.BorderBottom=0,h.BorderRight=a;break;case s.TextAlignmentEnum.LeftCenter:h.BorderTop=-l/2,h.BorderLeft=0,h.BorderBottom=l/2,h.BorderRight=a;break;case s.TextAlignmentEnum.LeftTop:h.BorderTop=0,h.BorderLeft=0,h.BorderBottom=l,h.BorderRight=a;break;case s.TextAlignmentEnum.RightBottom:h.BorderTop=-l,h.BorderLeft=-a,h.BorderBottom=0,h.BorderRight=0;break;case s.TextAlignmentEnum.RightCenter:h.BorderTop=-l/2,h.BorderLeft=-a,h.BorderBottom=l/2,h.BorderRight=0;break;case s.TextAlignmentEnum.RightTop:h.BorderTop=0,h.BorderLeft=-a,h.BorderBottom=l,h.BorderRight=0}h.BorderMarginTop=h.BorderTop-l*i,h.BorderMarginLeft=h.BorderLeft-l*i,h.BorderMarginBottom=h.BorderBottom+l*i,h.BorderMarginRight=h.BorderRight+l*i}}e.GraphicalLabel=a},6729:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalLine=void 0;const s=i(8155);e.GraphicalLine=class{constructor(t,e,i=0,n=s.OutlineAndFillStyleEnum.BaseWritingColor,r){this.start=t,this.end=e,this.width=i,this.styleId=n,this.colorHex=r}get Start(){return this.start}set Start(t){this.start=t}get End(){return this.end}set End(t){this.end=t}get Width(){return this.width}set Width(t){this.width=t}}},5091:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalLyricEntry=void 0;const s=i(9946),n=i(2255),r=i(9086),o=i(1274);e.GraphicalLyricEntry=class{constructor(t,e,i,a){this.lyricsEntry=t,this.graphicalStaffEntry=e;const l=e.parentMeasure.parentSourceMeasure.Rules.LyricsAlignmentStandard;t.Text.length>=4&&t.Parent.Notes[0].Length.Denominator>4&&o.TextAlignmentEnum.LeftBottom;const h=new n.Label(t.Text),c=this.graphicalStaffEntry.parentMeasure.parentSourceMeasure.Rules;this.graphicalLabel=new s.GraphicalLabel(h,i,l,c,e.PositionAndShape),this.graphicalLabel.Label.colorDefault=c.DefaultColorLyrics,this.graphicalLabel.PositionAndShape.RelativePosition=new r.PointF2D(0,a),l===o.TextAlignmentEnum.LeftBottom&&(this.graphicalLabel.PositionAndShape.RelativePosition.x-=1)}get LyricsEntry(){return this.lyricsEntry}get ParentLyricWord(){return this.graphicalLyricWord}set ParentLyricWord(t){this.graphicalLyricWord=t}get GraphicalLabel(){return this.graphicalLabel}set GraphicalLabel(t){this.graphicalLabel=t}get StaffEntryParent(){return this.graphicalStaffEntry}set StaffEntryParent(t){this.graphicalStaffEntry=t}}},8720:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalLyricWord=void 0,e.GraphicalLyricWord=class{constructor(t){this.graphicalLyricsEntries=[],this.lyricWord=t,this.initialize()}get GetLyricWord(){return this.lyricWord}get GraphicalLyricsEntries(){return this.graphicalLyricsEntries}set GraphicalLyricsEntries(t){this.graphicalLyricsEntries=t}isFilled(){for(let t=0;t{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalMarkedArea=void 0,e.GraphicalMarkedArea=class{constructor(t,e,i,s){this.systemRectangle=t,this.labelRectangle=e,this.label=i,this.settings=s}}},1513:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalMeasure=void 0;const s=i(4785),n=i(1797),r=i(8911),o=i(9086);class a extends s.GraphicalObject{constructor(t,e,i){super(),this.hasOnlyRests=!1,this.measureNumber=-1,this.ShowTimeSignature=!0,this.ShowKeySignature=!0,this.parentStaff=t,this.parentSourceMeasure=e,this.parentStaffLine=i,i?(this.parentStaff=i.ParentStaff,this.PositionAndShape=new r.BoundingBox(this,i.PositionAndShape)):this.PositionAndShape=new r.BoundingBox(this),this.PositionAndShape.BorderBottom=4,this.parentSourceMeasure&&(this.measureNumber=this.parentSourceMeasure.MeasureNumber),this.staffEntries=[]}get ParentStaff(){return this.parentStaff}get ParentMusicSystem(){return this.parentMusicSystem}set ParentMusicSystem(t){this.parentMusicSystem=t}get MeasureNumber(){return this.measureNumber}get FirstInstructionStaffEntry(){return this.firstInstructionStaffEntry}set FirstInstructionStaffEntry(t){this.firstInstructionStaffEntry=t}get LastInstructionStaffEntry(){return this.lastInstructionStaffEntry}set LastInstructionStaffEntry(t){this.lastInstructionStaffEntry=t}get ParentStaffLine(){return this.parentStaffLine}set ParentStaffLine(t){this.parentStaffLine=t,this.parentStaffLine&&(this.PositionAndShape.Parent=this.parentStaffLine.PositionAndShape)}resetLayout(){throw new Error("not implemented")}getLineWidth(t){throw new Error("not implemented")}addClefAtBegin(t){throw new Error("not implemented")}addKeyAtBegin(t,e,i){throw new Error("not implemented")}addRhythmAtBegin(t){throw new Error("not implemented")}addClefAtEnd(t,e=!0){throw new Error("not implemented")}setPositionInStaffline(t){this.PositionAndShape.RelativePosition=new o.PointF2D(t,0)}setWidth(t){this.PositionAndShape.BorderRight=t}layoutSymbols(){throw new Error("not implemented")}findGraphicalStaffEntryFromTimestamp(t){var e;for(let i=0,s=this.staffEntries.length;i1}isVisible(){return this.ParentStaff.ParentInstrument.Visible}getGraphicalMeasureDurationFromStaffEntries(){let t=new n.Fraction(0,1);const e=[];for(let t=0,i=this.staffEntries.length;t0&&r.Add(e.notes[0].graphicalNoteLength);t.lt(r)&&(t=n.Fraction.createFromFraction(r))}return t}addGraphicalStaffEntry(t){this.staffEntries.push(t)}addGraphicalStaffEntryAtTimestamp(t){if(t)if(0===this.staffEntries.length||this.staffEntries[this.staffEntries.length-1].relInMeasureTimestamp.lt(t.relInMeasureTimestamp))this.staffEntries.push(t);else for(let e=this.staffEntries.length-1;e>=0;e--){if(this.staffEntries[e].relInMeasureTimestamp.lt(t.relInMeasureTimestamp)){this.staffEntries.splice(e+1,0,t);break}0===e&&this.staffEntries.splice(e,0,t)}}isPianoRightHand(){return this.isUpperStaffOfInstrument()}isPianoLeftHand(){return this.isLowerStaffOfInstrument()}isUpperStaffOfInstrument(){return 1===this.parentStaff.ParentInstrument.Staves.length||this.ParentStaff===this.parentStaff.ParentInstrument.Staves[0]}isLowerStaffOfInstrument(){return 1!==this.parentStaff.ParentInstrument.Staves.length&&this.ParentStaff===this.ParentStaff.ParentInstrument.Staves.last()}beginsWithLineRepetition(){const t=this.parentSourceMeasure;return!!t&&t.beginsWithLineRepetition()}endsWithLineRepetition(){const t=this.parentSourceMeasure;return!!t&&t.endsWithLineRepetition()}beginsWithWordRepetition(){const t=this.parentSourceMeasure;return!!t&&t.beginsWithWordRepetition()}endsWithWordRepetition(){const t=this.parentSourceMeasure;return!!t&&t.endsWithWordRepetition()}getTransposedHalftones(){return this.parentStaff.ParentInstrument.GetMusicSheet.Transpose+this.parentStaff.ParentInstrument.Transpose}}e.GraphicalMeasure=a},599:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PagePlacementEnum=e.GraphicalMusicPage=void 0;const s=i(8911),n=i(4785),r=i(9086);class o extends n.GraphicalObject{constructor(t){super(),this.musicSystems=[],this.labels=[],this.parent=t,this.boundingBox=new s.BoundingBox(this,void 0)}get MusicSystems(){return this.musicSystems}set MusicSystems(t){this.musicSystems=t}get Labels(){return this.labels}set Labels(t){this.labels=t}get Parent(){return this.parent}set Parent(t){this.parent=t}get PageNumber(){return this.pageNumber}set PageNumber(t){this.pageNumber=t}setMusicPageAbsolutePosition(t,e){return new r.PointF2D(0,0)}}var a;e.GraphicalMusicPage=o,(a=e.PagePlacementEnum||(e.PagePlacementEnum={}))[a.Down=0]="Down",a[a.Right=1]="Right",a[a.RightDown=2]="RightDown"},4324:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.SystemImageProperties=e.GraphicalMusicSheet=void 0;const n=i(525),r=i(6729),o=i(9086),a=i(289),l=i(5198),h=i(1797),c=i(8911),u=s(i(2043)),d=i(2337),f=i(5974),m=i(4785);e.GraphicalMusicSheet=class{constructor(t,e){this.musicPages=[],this.measureList=[],this.verticalGraphicalStaffEntryContainers=[],this.cursors=[],this.leadSheet=!1,this.musicSheet=t,this.numberOfStaves=this.musicSheet.Staves.length,this.calculator=e,this.calculator.initialize(this)}get ParentMusicSheet(){return this.musicSheet}get GetCalculator(){return this.calculator}get MusicPages(){return this.musicPages}set MusicPages(t){this.musicPages=t}get MeasureList(){return this.measureList}set MeasureList(t){this.measureList=t}get VerticalGraphicalStaffEntryContainers(){return this.verticalGraphicalStaffEntryContainers}set VerticalGraphicalStaffEntryContainers(t){this.verticalGraphicalStaffEntryContainers=t}get Title(){return this.title}set Title(t){this.title=t}get Subtitle(){return this.subtitle}set Subtitle(t){this.subtitle=t}get Composer(){return this.composer}set Composer(t){this.composer=t}get Lyricist(){return this.lyricist}set Lyricist(t){this.lyricist=t}get Copyright(){return this.copyright}set Copyright(t){this.copyright=t}get Cursors(){return this.cursors}get SelectionStartSymbol(){return this.selectionStartSymbol}get SelectionEndSymbol(){return this.selectionEndSymbol}get MinAllowedSystemWidth(){return this.minAllowedSystemWidth}set MinAllowedSystemWidth(t){this.minAllowedSystemWidth=t}get NumberOfStaves(){return this.numberOfStaves}get LeadSheet(){return this.leadSheet}set LeadSheet(t){this.leadSheet=t}static transformRelativeToAbsolutePosition(t){for(let e=0;e=0;i--){const t=this.measureList[i][e];if(t)return t}}findGraphicalStaffEntryFromMeasureList(t,e,i){for(let s=e;s0)return i.staffEntries[0]}}getFirstVisibleMeasuresListFromIndices(t,e){const i=[],s=this.measureList[0].length;for(let n=t;n<=e;n++)for(let t=0;t=0;e--){if(this.verticalGraphicalStaffEntryContainers[e].AbsoluteTimestamp.lt(t)){const i=new n.VerticalGraphicalStaffEntryContainer(this.numberOfStaves,t);return this.verticalGraphicalStaffEntryContainers.splice(e+1,0,i),i}if(this.verticalGraphicalStaffEntryContainers[e].AbsoluteTimestamp.Equals(t))return this.verticalGraphicalStaffEntryContainers[e]}}GetVerticalContainerFromTimestamp(t,e=0){const i=d.CollectionUtil.binarySearch(this.verticalGraphicalStaffEntryContainers,new n.VerticalGraphicalStaffEntryContainer(0,t),n.VerticalGraphicalStaffEntryContainer.compareByTimestamp,e);if(i>=0)return this.verticalGraphicalStaffEntryContainers[i]}GetInterpolatedIndexInVerticalContainers(t){const e=this.verticalGraphicalStaffEntryContainers;let i,s,n=0,r=e.length-1;if(t.lte(e[e.length-1].AbsoluteTimestamp)){for(;r-n>1;){const i=Math.floor((r+n)/2);if(e[n].AbsoluteTimestamp.Equals(t)){r=n;break}if(e[r].AbsoluteTimestamp.Equals(t)){n=r;break}if(e[i].AbsoluteTimestamp.Equals(t))return this.verticalGraphicalStaffEntryContainers.indexOf(e[i]);t.lt(e[i].AbsoluteTimestamp)?r=i:n=i}if(n===r)return this.verticalGraphicalStaffEntryContainers.indexOf(e[n]);i=e[n].AbsoluteTimestamp,s=e[r].AbsoluteTimestamp}else i=e[e.length-1].AbsoluteTimestamp,s=h.Fraction.plus(this.getLongestStaffEntryDuration(e.length-1),i),r=e.length;const o=s.RealValue-i.RealValue,a=r-(s.RealValue-t.RealValue)/o;return Math.min(a,this.verticalGraphicalStaffEntryContainers.length)}getVisibleStavesIndicesFromSourceMeasure(t){const e=[],i=[];for(let i=0,s=t.length;i{var e;return void 0!==(null===(e=t.parentStaffEntry)||void 0===e?void 0:e.relInMeasureTimestamp)}))}GetNearestNote(t,e){const i=this.GetNearestVoiceEntry(t);if(!i)return;let s,n=Number.MAX_SAFE_INTEGER;for(const e of i.notes){const i=e.PositionAndShape.AbsolutePosition.y,r=Math.abs(e.PositionAndShape.AbsolutePosition.x-t.x),o=Math.abs(i-t.y);r+os.PositionAndShape.RelativePosition.x&&(i=s):i=s)}}catch(t){u.default.info("GraphicalMusicSheet.getStaffEntry",t)}return i}GetPreviousVisibleContainerIndex(t){for(let e=t-1;e>=0;e--){const t=this.verticalGraphicalStaffEntryContainers[e].StaffEntries;for(let i=0,s=t.length;i=0;t--)if(i=this.getStaffEntry(t),i){if(!e)return i;if(i.sourceStaffEntry.ParentStaff.ParentInstrument.Visible)return i}}findClosestRightStaffEntry(t,e){let i;for(let s=Math.max(0,Math.ceil(t));s{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalNote=void 0;const s=i(8640),n=i(4785),r=i(4040),o=i(8911);class a extends n.GraphicalObject{constructor(t,e,i,n){super(),this.DrawnAccidental=s.AccidentalEnum.NONE,this.lineShift=0,this.sourceNote=t,this.parentVoiceEntry=e,this.PositionAndShape=new o.BoundingBox(this,e.PositionAndShape),this.graphicalNoteLength=n||t.Length,this.numberOfDots=this.calculateNumberOfNeededDots(this.graphicalNoteLength),this.rules=i,this.rules.addGraphicalNoteToNoteMap(t,this)}Transpose(t,e,i,s){let n=this.sourceNote.Pitch;return r.MusicSheetCalculator.transposeCalculator&&(n=r.MusicSheetCalculator.transposeCalculator.transposePitch(this.sourceNote.Pitch,t,i)),n}calculateNumberOfNeededDots(t){return this.sourceNote&&this.sourceNote.NoteTuplet?0:t.calculateNumberOfNeededDots()}get ParentMusicPage(){return this.parentVoiceEntry.parentStaffEntry.parentMeasure.ParentMusicSystem.Parent}static FromNote(t,e){return e.NoteToGraphicalNoteMap.getValue(t.NoteToGraphicalNoteObjectId)}}e.GraphicalNote=a},4785:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalObject=void 0;const s=i(1035);class n extends s.AClassHierarchyTrackable{get PositionAndShape(){return this.boundingBox}set PositionAndShape(t){this.boundingBox=t}}e.GraphicalObject=n},873:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalOctaveShift=void 0;const s=i(4785),n=i(5853),r=i(8911),o=i(158),a=i(1703);class l extends s.GraphicalObject{constructor(t,e){super(),this.getOctaveShift=t,this.setSymbol(),this.PositionAndShape=new r.BoundingBox(this,e)}setSymbol(){switch(this.getOctaveShift.Type){case n.OctaveEnum.VA8:this.octaveSymbol=o.MusicSymbol.VA8;break;case n.OctaveEnum.VB8:this.octaveSymbol=o.MusicSymbol.VB8;break;case n.OctaveEnum.MA15:this.octaveSymbol=o.MusicSymbol.MA15;break;case n.OctaveEnum.MB15:this.octaveSymbol=o.MusicSymbol.MB15;break;default:throw new a.ArgumentOutOfRangeException("")}}}e.GraphicalOctaveShift=l},4082:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalPedal=void 0;const s=i(4785),n=i(8911),r=i(158);class o extends s.GraphicalObject{constructor(t,e){super(),this.getPedal=t,this.setSymbol(),this.PositionAndShape=new n.BoundingBox(this,e)}setSymbol(){!this.getPedal.IsLine&&this.getPedal.IsSign?this.pedalSymbol=r.MusicSymbol.PEDAL_SYMBOL:this.getPedal.IsLine&&this.getPedal.IsSign?this.pedalSymbol=r.MusicSymbol.PEDAL_MIXED:this.pedalSymbol=r.MusicSymbol.PEDAL_BRACKET}}e.GraphicalPedal=o},3411:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalRectangle=void 0;const s=i(8911),n=i(4785);class r extends n.GraphicalObject{constructor(t,e,i,n){super(),this.boundingBox=new s.BoundingBox(this,i),this.boundingBox.RelativePosition=t,this.boundingBox.BorderRight=e.x-t.x,this.boundingBox.BorderBottom=e.y-t.y,this.style=n}}e.GraphicalRectangle=r},9876:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalSlur=void 0;const n=i(9086),r=i(5330),o=i(3748),a=i(8363),l=i(2947),h=i(1797),c=i(908);var u=s(i(6368)).default.Flow;class d extends r.GraphicalCurve{constructor(t,e){super(),this.staffEntries=[],this.slur=t,this.rules=e}static Compare(t,e){if(t.staffEntries.length<1)return-1;if(e.staffEntries.length<1)return 1;const i=h.Fraction.minus(t.staffEntries[t.staffEntries.length-1].getAbsoluteTimestamp(),t.staffEntries[0].getAbsoluteTimestamp()),s=h.Fraction.minus(e.staffEntries[e.staffEntries.length-1].getAbsoluteTimestamp(),e.staffEntries[0].getAbsoluteTimestamp());return i.RealValue>s.RealValue?1:s.RealValue>i.RealValue?-1:0}calculateCurve(t){const e=this.staffEntries[0],i=this.staffEntries[this.staffEntries.length-1];let s=e.findGraphicalNoteFromNote(this.slur.StartNote);!s&&this.graceStart&&(s=e.findGraphicalNoteFromGraceNote(this.slur.StartNote)),s||(s=e.findEndTieGraphicalNoteFromNoteWithStartingSlur(this.slur.StartNote,this.slur));let r=i.findGraphicalNoteFromNote(this.slur.EndNote);!r&&this.graceEnd&&(r=i.findGraphicalNoteFromGraceNote(this.slur.EndNote));const l=e.parentMeasure.ParentStaffLine,h=l.SkyBottomLineCalculator;this.calculatePlacement(h,l);const c=this.calculateStartAndEnd(s,r,l,t,h),u=c.startX,d=c.endX;let f=c.startY,m=c.endY;const p=t.SlurTangentMinAngle,b=t.SlurTangentMaxAngle;let g;if(this.placement===o.PlacementEnum.Above){f-=t.SlurNoteHeadYOffset,m-=t.SlurNoteHeadYOffset;const e=new n.PointF2D(this.staffEntries[0].parentMeasure.PositionAndShape.RelativePosition.x+this.staffEntries[0].PositionAndShape.RelativePosition.x,f);s?e.x+=this.staffEntries[0].PositionAndShape.BorderRight:e.x=this.staffEntries[0].parentMeasure.beginInstructionsWidth,this.graceStart&&(e.x+=i.PositionAndShape.RelativePosition.x);const o=new n.PointF2D(this.staffEntries[this.staffEntries.length-1].parentMeasure.PositionAndShape.RelativePosition.x+this.staffEntries[this.staffEntries.length-1].PositionAndShape.RelativePosition.x,m);if(r?o.x+=this.staffEntries[this.staffEntries.length-1].PositionAndShape.BorderLeft:o.x=this.staffEntries[this.staffEntries.length-1].parentMeasure.PositionAndShape.RelativePosition.x+this.staffEntries[this.staffEntries.length-1].parentMeasure.PositionAndShape.Size.width,this.graceEnd&&(o.x+=i.staffEntryParent.PositionAndShape.RelativePosition.x),g=this.calculateTopPoints(e,o,l,h),0===g.length){const t=new n.PointF2D((o.x-e.x)/2+e.x,(o.y-e.y)/2+e.y);g.push(t)}const c=Math.atan((m-f)/(d-u)),S=new n.PointF2D(0,0);let y=new n.PointF2D(d-u,-(m-f));const E=a.Matrix2D.getRotationMatrix(c),v=E.getTransposeMatrix();y=E.vectorMultiplication(y);const x=this.calculateTranslatedAndRotatedPointListAbove(g,u,f,E),_=this.calculateMaxLeftSlope(x,S,y),M=this.calculateMaxRightSlope(x,S,y),w=S.y-S.x*_,P=y.y-y.x*M,T=new n.PointF2D;let L=!1;Math.abs(Math.abs(_)-Math.abs(M))<1e-4?(T.x=y.x/2,T.y=0,L=!0):(T.x=(P-w)/(_-M),T.y=_*T.x+w);const A=this.calculateHeightWidthRatio(y.x,x),C=0,I=0;let R=p,N=-p;if(!L){const t=this.calculateAngles(p,_,M,b);R=t.startAngle,N=t.endAngle}const B=this.calculateControlPoints(y.x,R,N,x,A,f,m);let F=B.startControlPoint,D=B.endControlPoint;F=v.vectorMultiplication(F),F.x+=u,F.y=-F.y+f,D=v.vectorMultiplication(D),D.x+=u,D.y=-D.y+f,this.bezierStartPt=new n.PointF2D(u,f-C),this.bezierStartControlPt=new n.PointF2D(F.x,F.y-C),this.bezierEndControlPt=new n.PointF2D(D.x,D.y-I),this.bezierEndPt=new n.PointF2D(d,m-I);const O=l.SkyLine.length,k=h.getLeftIndexForPointX(this.bezierStartPt.x,O),V=h.getLeftIndexForPointX(this.bezierEndPt.x,O),G=this.bezierEndPt.x-this.bezierStartPt.x,W=h.SamplingUnit;for(let t=k;t=k&&(l.SkyLine[s]=Math.min(l.SkyLine[s],i.y)),s++,s=k&&(l.BottomLine[s]=Math.max(l.BottomLine[s],i.y)),s++,s0)return void(this.placement=o.PlacementEnum.Above);const i=this.staffEntries[0],s=this.staffEntries[this.staffEntries.length-1],n=i.graphicalVoiceEntries[0].parentVoiceEntry.StemDirection;if(n===s.graphicalVoiceEntries[0].parentVoiceEntry.StemDirection)this.placement=n===c.StemDirectionType.Up?o.PlacementEnum.Below:o.PlacementEnum.Above;else{let n=i.PositionAndShape.BorderLeft+i.PositionAndShape.RelativePosition.x+i.parentMeasure.PositionAndShape.RelativePosition.x,r=s.PositionAndShape.BorderRight+s.PositionAndShape.RelativePosition.x+s.parentMeasure.PositionAndShape.RelativePosition.x;this.graceStart&&(n+=s.PositionAndShape.RelativePosition.x),this.graceEnd&&(r+=s.staffEntryParent.PositionAndShape.RelativePosition.x);const a=-1*t.getSkyLineMinInRange(n,r),l=t.getBottomLineMaxInRange(n,r)-e.StaffHeight;this.placement=l>a?o.PlacementEnum.Above:o.PlacementEnum.Below}}calculateTopPoints(t,e,i,s){const r=[];let o=s.getRightIndexForPointX(t.x,i.SkyLine.length),a=s.getLeftIndexForPointX(e.x,i.SkyLine.length);o<0&&(o=0),a>=i.SkyLine.length&&(a=i.SkyLine.length-1);for(let t=o;t=i.BottomLine.length&&(a=i.BottomLine.length-1);for(let t=o;tc&&t>u&&(h+=t/70*this.rules.SlurHeightFlattenLongSlursFactorByWidth,h*=1+e/30*this.rules.SlurHeightFlattenLongSlursFactorByAngle,l/=h);const f=Math.min(.5,Math.max(.1,1.7*e/80*l*Math.pow(Math.max(r,.05),.4))),m=Math.min(.5,Math.max(.1,1.7*-i/80*l*Math.pow(Math.max(r,.05),.4))),p=new n.PointF2D;p.x=t*f*Math.cos(e*d.degreesToRadiansFactor),p.y=t*f*Math.sin(e*d.degreesToRadiansFactor);const b=new n.PointF2D;b.x=t-t*m*Math.cos(i*d.degreesToRadiansFactor),b.y=-t*m*Math.sin(i*d.degreesToRadiansFactor);let g=p.y-b.y;for(;this.rules.SlurMaximumYControlPointDistance&&Math.abs(g)>this.rules.SlurMaximumYControlPointDistance;)g<0?(p.y+=1,b.y-=1):(p.y-=1,b.y+=1),g=p.y-b.y;return{startControlPoint:p,endControlPoint:b}}calculateAngles(t,e,i,s){let n=Math.atan(e)/d.degreesToRadiansFactor;e>0?n+=20:n-=20;let r=Math.atan(i)/d.degreesToRadiansFactor;return i<0?r-=20:r+=20,{startAngle:Math.min(Math.max(t,n),s),endAngle:Math.max(Math.min(-t,r),-s)}}}e.GraphicalSlur=d,d.degreesToRadiansFactor=Math.PI/180},3023:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalStaffEntry=void 0;const s=i(8911),n=i(1797),r=i(4785),o=i(2337),a=i(4040);class l extends r.GraphicalObject{constructor(t,e,i){super(),this.graphicalChordContainers=[],this.tabStaffEntry=void 0,this.MaxAccidentals=0,this.graphicalInstructions=[],this.ties=[],this.graphicalTies=[],this.lyricsEntries=[],this.parentMeasure=t,this.graphicalVoiceEntries=[],this.sourceStaffEntry=e,i?(this.staffEntryParent=i,this.parentVerticalContainer=i.parentVerticalContainer,this.PositionAndShape=new s.BoundingBox(this,i.PositionAndShape)):this.PositionAndShape=new s.BoundingBox(this,t.PositionAndShape),e&&(this.relInMeasureTimestamp=e.Timestamp),this.FingeringEntries=[]}get GraphicalInstructions(){return this.graphicalInstructions}get GraphicalTies(){return this.graphicalTies}get LyricsEntries(){return this.lyricsEntries}set LyricsEntries(t){this.lyricsEntries=t}getAbsoluteTimestamp(){const t=this.parentMeasure.parentSourceMeasure.AbsoluteTimestamp.clone();return this.relInMeasureTimestamp&&t.Add(this.relInMeasureTimestamp),t}findTieGraphicalNoteFromNote(t){for(const e of this.graphicalVoiceEntries)for(const i of e.notes){const e=i.sourceNote;if(!e.isRest()&&e.Pitch.FundamentalNote===t.Pitch.FundamentalNote&&e.Pitch.Octave===t.Pitch.Octave&&e.getAbsoluteTimestamp().Equals(t.getAbsoluteTimestamp()))return i}}findEndTieGraphicalNoteFromNoteWithStartingSlur(t,e){if(t)for(const i of this.graphicalVoiceEntries)if(i.parentVoiceEntry===t.ParentVoiceEntry)for(const t of i.notes){const i=t.sourceNote;if(i.NoteTie&&-1!==i.NoteSlurs.indexOf(e))return t}}findGraphicalNoteFromGraceNote(t){if(t)for(const e of this.graphicalVoiceEntries)if(e.parentVoiceEntry===t.ParentVoiceEntry)for(const i of e.notes)if(i.sourceNote===t)return i}findGraphicalNoteFromNote(t){if(t)for(const e of this.graphicalVoiceEntries)if(e.parentVoiceEntry===t.ParentVoiceEntry)for(const i of e.notes)if(i.sourceNote===t&&this.getAbsoluteTimestamp().Equals(t.getAbsoluteTimestamp()))return i}getGraphicalNoteDurationFromVoice(t){for(const e of this.graphicalVoiceEntries)if(e.parentVoiceEntry.ParentVoice===t)return e.notes[0].graphicalNoteLength;return new n.Fraction(0,1)}findVoiceEntryGraphicalNotes(t){for(const e of this.graphicalVoiceEntries)if(e.parentVoiceEntry===t)return e.notes}isVoiceEntryPartOfLinkedVoiceEntry(t){if(this.sourceStaffEntry.Link)for(let e=0,i=this.sourceStaffEntry.Link.LinkStaffEntries.length;e0&&(t=e)}return t}findStaffEntryMaxNoteLength(){let t=new n.Fraction(0,1);for(const e of this.graphicalVoiceEntries)for(const i of e.notes){const e=i.graphicalNoteLength;t.lt(e)&&e.GetExpandedNumerator()>0&&(t=e)}return t}findOrCreateGraphicalVoiceEntry(t){for(const e of this.graphicalVoiceEntries)if(e.parentVoiceEntry===t)return e;const e=a.MusicSheetCalculator.symbolFactory.createVoiceEntry(t,this);return this.graphicalVoiceEntries.push(e),e}findOrCreateGraphicalVoiceEntryFromGraphicalNote(t){for(const e of this.graphicalVoiceEntries)if(e===t.parentVoiceEntry)return e;const e=a.MusicSheetCalculator.symbolFactory.createVoiceEntry(t.sourceNote.ParentVoiceEntry,this);return this.graphicalVoiceEntries.push(e),e}addGraphicalNoteToListAtCorrectYPosition(t,e){const i=t.notes;if(0===i.length||e.PositionAndShape.RelativePosition.y=0;t--){if(i[t].PositionAndShape.RelativePosition.y>e.PositionAndShape.RelativePosition.y){i.splice(t+1,0,e);break}if(0===t){i.splice(0,0,e);break}}}hasOnlyRests(){for(const t of this.graphicalVoiceEntries)for(const e of t.notes)if(!e.sourceNote.isRest())return!1;return!0}getSkylineMin(){var t;const e=null===(t=this.parentMeasure)||void 0===t?void 0:t.ParentStaffLine.SkyBottomLineCalculator;if(!e)return;const[i,s]=this.getAbsoluteStartAndEnd();return e.getSkyLineMinInRange(i,s)}getHighestYAtEntry(){return this.parentMeasure.ParentStaffLine.PositionAndShape.AbsolutePosition.y+this.getSkylineMin()}getLowestYAtEntry(){return this.parentMeasure.ParentStaffLine.PositionAndShape.AbsolutePosition.y+this.getBottomlineMax()}getBottomlineMax(){var t;const e=null===(t=this.parentMeasure)||void 0===t?void 0:t.ParentStaffLine.SkyBottomLineCalculator;if(!e)return;const[i,s]=this.getAbsoluteStartAndEnd();return e.getBottomLineMaxInRange(i,s)}getAbsoluteStartAndEnd(){let t=this.PositionAndShape.AbsolutePosition.x;return t-=this.parentMeasure.ParentStaffLine.PositionAndShape.AbsolutePosition.x,[t,t+this.PositionAndShape.Size.width]}}e.GraphicalStaffEntry=l},8898:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalStaffEntryLink=void 0,e.GraphicalStaffEntryLink=class{constructor(t){this.graphicalLinkedStaffEntries=[],this.staffEntryLink=t,this.initialize()}get GetStaffEntryLink(){return this.staffEntryLink}get GraphicalLinkedStaffEntries(){return this.graphicalLinkedStaffEntries}set GraphicalLinkedStaffEntries(t){this.graphicalLinkedStaffEntries=t}isFilled(){for(let t=0;t{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalTie=void 0,e.GraphicalTie=class{constructor(t,e,i){this.tie=t,this.startNote=e,this.endNote=i}get SVGElement(){return this.vfTie.getAttribute("el")}get GetTie(){return this.tie}get StartNote(){return this.startNote}get Tie(){return this.tie}set StartNote(t){this.startNote=t}get EndNote(){return this.endNote}set EndNote(t){this.endNote=t}}},4462:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalUnknownExpression=void 0;const n=i(6791),r=i(3748),o=s(i(2043));class a extends n.AbstractGraphicalExpression{constructor(t,e,i,s,n){super(t,new r.AbstractExpression(i),s),this.label=e,this.sourceMultiExpression=n}updateSkyBottomLine(){const t=this.parentStaffLine.SkyBottomLineCalculator,e=this.label.PositionAndShape.RelativePosition.x+this.label.PositionAndShape.BorderMarginLeft,i=this.label.PositionAndShape.RelativePosition.x+this.label.PositionAndShape.BorderMarginRight;switch(this.Placement){case r.PlacementEnum.Above:const s=this.label.PositionAndShape.BorderMarginTop+this.label.PositionAndShape.RelativePosition.y;t.updateSkyLineInRange(e,i,s);break;case r.PlacementEnum.Below:const n=this.label.PositionAndShape.BorderMarginBottom+this.label.PositionAndShape.RelativePosition.y;t.updateBottomLineInRange(e,i,n);break;default:o.default.error("Placement for GraphicalUnknownExpression is unknown")}}}e.GraphicalUnknownExpression=a},5974:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalVoiceEntry=void 0;const s=i(4785),n=i(8911),r=i(1405);class o extends s.GraphicalObject{constructor(t,e,i){super(),this.parentVoiceEntry=t,this.parentStaffEntry=e,this.PositionAndShape=new n.BoundingBox(this,e?e.PositionAndShape:void 0,!0),this.notes=[],this.rules=i||(e?e.parentMeasure.parentSourceMeasure.Rules:new r.EngravingRules)}sort(){return this.notes.sort(((t,e)=>{var i,s,n,r;return(null!==(s=null===(i=e.sourceNote.Pitch)||void 0===i?void 0:i.getHalfTone())&&void 0!==s?s:0)-(null!==(r=null===(n=t.sourceNote.Pitch)||void 0===n?void 0:n.getHalfTone())&&void 0!==r?r:0)})),this.notes}sortForVexflow(){return this.notes.sort(((t,e)=>{var i,s,n;return(null!==(s=null===(i=t.sourceNote.Pitch)||void 0===i?void 0:i.getHalfTone())&&void 0!==s?s:0)-(null!==(n=e.sourceNote.Pitch.getHalfTone())&&void 0!==n?n:0)})),this.notes}color(){}}e.GraphicalVoiceEntry=o},8823:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},4040:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.MusicSheetCalculator=void 0;const n=i(4324),r=i(1797),o=i(5253),a=i(289),l=i(5853),h=i(908),c=i(5623),u=i(9086),d=i(9050),f=i(9946),m=i(1274),p=i(5198),b=i(2947),g=i(8911),S=i(4574),y=i(1070),E=i(289),v=s(i(2043)),x=i(1649),_=i(6729),M=i(2255),w=i(141),P=i(3748),T=i(5277),L=i(9667),A=i(280),C=i(7839),I=i(374),R=i(41),N=i(4462),B=i(3884);class F{constructor(){this.staffEntriesWithGraphicalTies=[],this.staffEntriesWithOrnaments=[],this.staffEntriesWithChordSymbols=[],this.staffLinesWithLyricWords=[],this.graphicalLyricWords=[],this.abstractNotImplementedErrorMessage="abstract, not implemented",this.dynamicExpressionMap=new Map}static get TextMeasurer(){return F.textMeasurer}static set TextMeasurer(t){F.textMeasurer=t}get leadSheet(){return this.graphicalMusicSheet.LeadSheet}static setMeasuresMinStaffEntriesWidth(t,e){for(let i=0,s=t.length;i0&&this.rules.RenderMultipleRestMeasures){a.isReducedToMultiRest=!0,a.multipleRestMeasureNumber=1;const i=a.multipleRestMeasures-1;r+=i;for(let s=1;s<=i;s++){const i=t.SourceMeasures.indexOf(a)+s;if(i>=t.SourceMeasures.length)break;const n=t.SourceMeasures[i];n.multipleRestMeasureNumber=s+1,n.isReducedToMultiRest=!0,e.push([void 0])}}}if(this.rules.AutoGenerateMultipleRestMeasuresFromRestMeasures&&this.rules.RenderMultipleRestMeasures){let r,a=0;for(let l=0,h=t.SourceMeasures.length;l0){r.isReducedToMultiRest=!0,r.multipleRestMeasureNumber=1,a++,h.multipleRestMeasureNumber=a,h.isReducedToMultiRest=!0;for(let t=0;t1){r.multipleRestMeasures=a;const t=this.createGraphicalMeasuresForSourceMeasure(r,i,n,o,s);e[r.measureListIndex]=t,a=0,r=void 0}else a=0,r=void 0}if(a>1){r.multipleRestMeasures=a,r.isReducedToMultiRest=!0;const t=this.createGraphicalMeasuresForSourceMeasure(r,i,n,o,s);e[r.measureListIndex]=t,a=0,r=void 0}}const l=s.map((t=>t.ClefType===a.ClefEnum.percussion));this.handleStaffEntries(l),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(),n.GraphicalMusicSheet.transformRelativeToAbsolutePosition(this.graphicalMusicSheet)}calculateXLayout(t,e){if(this.graphicalMusicSheet.MeasureList.length>0){let t=this.graphicalMusicSheet.MeasureList[0],e=this.calculateMeasureXLayout(t);e=this.calculateMeasureWidthFromStaffEntries(t,e),F.setMeasuresMinStaffEntriesWidth(t,e);let i=0;for(let s=1;si&&(i=e),F.setMeasuresMinStaffEntriesWidth(t,e);if(this.rules.FixedMeasureWidth){let e=i;this.rules.FixedMeasureWidthFixedValue&&(e=this.rules.FixedMeasureWidthFixedValue);for(let i=1;i1;if(1===n&&e.Measures[0].parentSourceMeasure.ImplicitMeasure&&(o=!1),o)return;0!==r.MeasureNumber&&1!==r.MeasureNumber||(i=r.MeasureNumber),s=r!==e.Measures[0]&&this.rules.MeasureNumberLabelXOffset?this.rules.MeasureNumberLabelXOffset:0;const a=this.rules.UseXMLMeasureNumbers&&1===r.MeasureNumber&&1!==r.parentSourceMeasure.getPrintedMeasureNumber();((r.MeasureNumber===i||r.MeasureNumber>=i+this.rules.MeasureNumberLabelOffset)&&!r.parentSourceMeasure.ImplicitMeasure||a)&&((1!==r.MeasureNumber||1===r.MeasureNumber&&r!==e.Measures[0]||a)&&this.calculateSingleMeasureNumberPlacement(r,e,t,s),i=r.MeasureNumber)}}calculateSingleMeasureNumberPlacement(t,e,i,s=0){const n=t.parentSourceMeasure.getPrintedMeasureNumber().toString(),r=new M.Label(n),o=new f.GraphicalLabel(r,this.rules.MeasureNumberLabelHeight,m.TextAlignmentEnum.LeftBottom,this.rules),a=e.SkyBottomLineCalculator;o.setLabelPositionAndShapeBorders(),o.PositionAndShape.Parent=i.PositionAndShape;const l=e.PositionAndShape.RelativePosition.x+t.PositionAndShape.RelativePosition.x-o.PositionAndShape.BorderMarginLeft+s;let h,c=l,d=l-o.PositionAndShape.BorderLeft+o.PositionAndShape.BorderRight;c-=e.PositionAndShape.RelativePosition.x,d-=e.PositionAndShape.RelativePosition.x;const p=c+.5,b=d-.5,g=a.getSkyLineMinInRange(p,b);if(t===e.Measures[0]){let t=0;if(i.GroupBrackets.length>0)for(const e of i.GroupBrackets)t=Math.min(t,e.PositionAndShape.BorderTop);h=Math.min(g,t)}else h=g;h=Math.min(0,h),o.PositionAndShape.RelativePosition=new u.PointF2D(l,h),i.MeasureNumberLabels.push(o)}calculateMeasureNumberSkyline(t){const e=t.StaffLines[0];for(const i of t.MeasureNumberLabels){let t=i.PositionAndShape.RelativePosition.x,s=t-i.PositionAndShape.BorderLeft+i.PositionAndShape.BorderRight;t-=e.PositionAndShape.RelativePosition.x,s-=e.PositionAndShape.RelativePosition.x,e.SkyBottomLineCalculator.updateSkyLineInRange(t,s,i.PositionAndShape.RelativePosition.y+i.PositionAndShape.BorderMarginTop)}}layoutGraphicalTie(t,e,i){throw new Error(this.abstractNotImplementedErrorMessage)}calculateSingleStaffLineLyricsPosition(t,e){let i=0,s=this.rules.StaffHeight;const n=new Map,r=[],o=t.SkyBottomLineCalculator;let a=t.Measures.length;for(let e=0;e0){r.push(e),i=Math.max(i,e.LyricsEntries.length);const t=e.PositionAndShape.RelativePosition.x+l.x;let n=Number.MAX_VALUE,a=Number.MIN_VALUE;for(let i=0;i0){const e=t.PositionAndShape.Size.width;let i=r[0].PositionAndShape.RelativePosition.x+r[0].PositionAndShape.BorderMarginLeft+r[0].parentMeasure.PositionAndShape.RelativePosition.x;i=i>e?e:i,o.updateBottomLineInRange(i,e,l)}return r}calculateLyricsExtendsAndDashes(t){for(let e=0,i=t.length;e0||t.UnknownList.length>0){let e="";for(let i=0,s=t.EntriesList.length;it.length-1&&(v.default.debug("minimum measure to draw index out of range. resetting min measure index to limit."),this.rules.MinMeasureToDrawIndex=t.length-1);const e=[];for(let i=this.rules.MinMeasureToDrawIndex,s=t.length;i0)&&(i=t.getSkyLineMinInRange(a,l));let h=0;0===s?(h+=this.rules.ChordSymbolYOffset,h+=.1):h+=this.rules.ChordSymbolYPadding,h*=-1;const c=n.GraphicalLabel;c.PositionAndShape.RelativePosition.y=i+h,c.setLabelPositionAndShapeBorders(),c.PositionAndShape.calculateBoundingBox(),t.updateSkyLineInRange(a,l,i+c.PositionAndShape.BorderMarginTop)}}}}calculateAlignedChordSymbolsOffset(t,e){let i=Number.MAX_SAFE_INTEGER;for(const s of t)for(const t of s.graphicalChordContainers){const n=s.PositionAndShape,r=t.PositionAndShape,o=r.BorderMarginLeft+n.AbsolutePosition.x,a=r.BorderMarginRight+n.AbsolutePosition.x;i=Math.min(i,e.getSkyLineMinInRange(o,a))}return i}layoutMeasureWithWholeRest(t,e,i){}layoutBeams(t){}layoutArticulationMarks(t,e,i){}layoutOrnament(t,e,i){}calculateRestNotePlacementWithinGraphicalBeam(t,e,i,s,n){}calculateTupletNumbers(){if(!this.rules.TupletNumberLimitConsecutiveRepetitions)return;let t,e,i,s=-1,n=0;const r={};for(const o of this.graphicalMusicSheet.ParentMusicSheet.Instruments)for(const a of o.Voices){n=0,r[a.VoiceId]={};for(const o of a.VoiceEntries)if(o.Notes.length>0){const l=o.Notes[0];if(!l.NoteTuplet){s=-1,n=0,e=void 0,t=void 0;continue}if(l.NoteTuplet===i)continue;let h=l.TypeLength;if(h||(v.default.warn("note missing TypeLength"),h=l.NoteTuplet.Fractions[0]),l.NoteTuplet!==e&&r[a.VoiceId][l.NoteTuplet.TupletLabelNumber]&&r[a.VoiceId][l.NoteTuplet.TupletLabelNumber][h.RealValue]){l.NoteTuplet.RenderTupletNumber=!1,i=l.NoteTuplet;continue}l.NoteTuplet.TupletLabelNumber===s&&h.Equals(t)||(s=l.NoteTuplet.TupletLabelNumber,t=h,n=0),e=l.NoteTuplet,n++,n<=this.rules.TupletNumberMaxConsecutiveRepetitions&&(l.NoteTuplet.RenderTupletNumber=!0),n>this.rules.TupletNumberMaxConsecutiveRepetitions&&(l.NoteTuplet.RenderTupletNumber=!1,this.rules.TupletNumberAlwaysDisableAfterFirstMax&&(r[a.VoiceId][s]||(r[a.VoiceId][s]={}),r[a.VoiceId][s][h.RealValue]=!0)),i=e}}}calculateSlurs(){}calculateGlissandi(){}calculateDynamicExpressionsForMultiExpression(t,e,i){}calculateGraphicalVerbalContinuousDynamic(t,e){const i=t.Label,s=e.x+i.PositionAndShape.BorderMarginLeft,n=e.x+i.PositionAndShape.BorderMarginRight,r=t.ContinuousDynamic.Placement,o=t.ParentStaffLine.SkyBottomLineCalculator;let a;r===P.PlacementEnum.Below?(a=o.getBottomLineMaxInRange(s,n),i.PositionAndShape.RelativePosition=new u.PointF2D(e.x,a-i.PositionAndShape.BorderMarginTop)):(a=o.getSkyLineMinInRange(s,n),i.PositionAndShape.RelativePosition=new u.PointF2D(e.x,a-i.PositionAndShape.BorderMarginBottom))}calculateGraphicalContinuousDynamic(t,e){var i;const s=t.IsSoftAccent,n=t.ParentStaffLine.ParentStaff.idInMusicSheet,o=this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(t.ContinuousDynamic.EndMultiExpression.SourceMeasureParent,n);if(!o)return void v.default.warn("MusicSheetCalculator.calculateGraphicalContinuousDynamic: No endMeasure found");t.EndMeasure=o;const a=t.ParentStaffLine,l=o.ParentStaffLine,h=l&&a===l;let c=!1;l?c=null==l?void 0:l.isPartOfMultiStaffInstrument():a&&(c=null==a?void 0:a.isPartOfMultiStaffInstrument());const u=r.Fraction.createFromFraction(t.ContinuousDynamic.EndMultiExpression.AbsoluteTimestamp),d=this.graphicalMusicSheet.GetVerticalContainerFromTimestamp(u),f=d.getFirstNonNullStaffEntry().parentMeasure,m=f.PositionAndShape.AbsolutePosition.x+f.PositionAndShape.BorderRight;let p=new r.Fraction(0,0,0);for(const t of d.StaffEntries){const e=null===(i=null==t?void 0:t.sourceStaffEntry)||void 0===i?void 0:i.calculateMaxNoteLength();(null==e?void 0:e.gt(p))&&(p=e)}const b=this.getRelativePositionInStaffLineFromTimestamp(u,n,l,c,0),g=r.Fraction.plus(u,p),S=this.getRelativePositionInStaffLineFromTimestamp(g,n,l,c,0),y=this.rules.SoftAccentWedgePadding,E=d.getFirstNonNullStaffEntry().PositionAndShape.Size.width,x=this.rules.SoftAccentSizeFactor;s?(e.x-=E/2*x+y,b.x=e.x+E/2*x):S.x>b.x&&S.xw){const t=M.StaffLines[e].PositionAndShape.RelativePosition.y-a.PositionAndShape.RelativePosition.y-this.rules.StaffHeight;D=this.rules.StaffHeight+t/2}else D=this.rules.WedgePlacementBelowY;D-=this.rules.WedgeOpeningLength/2,h||(O=D);let i=T.getBottomLineMaxInRange(R,B);i>D&&(D=i);const s=!1;if(wthis.rules.StaffHeight?n-this.rules.WedgeVerticalMargin:this.rules.StaffHeight+this.rules.WedgeOpeningLength,t.NotToBeRemoved=!0}}h||(i=l.SkyBottomLineCalculator.getBottomLineMaxInRange(N,F),i>O&&(O=i),O+=this.rules.WedgeOpeningLength/2,O+=this.rules.WedgeVerticalMargin),s||(D+=this.rules.WedgeOpeningLength/2,D+=this.rules.WedgeVerticalMargin)}else if(L===P.PlacementEnum.Above){if(1===a.ParentStaff.ParentInstrument.Staves.length)D=this.rules.WedgePlacementAboveY;else{let t=0;w>0&&(t=w-1);const e=M.StaffLines[t];D=-(a.PositionAndShape.RelativePosition.y-e.PositionAndShape.RelativePosition.y-this.rules.StaffHeight)/2}D+=this.rules.WedgeOpeningLength/2,h||(O=D);let t=T.getSkyLineMinInRange(R,B);t1&&w>0){const t=a.findClosestStaffEntry(R),i=a.findClosestStaffEntry(B);if(t&&i){t.parentVerticalContainer;const i=w-1;if(e){const t=M.StaffLines[i],e=t.SkyBottomLineCalculator.getBottomLineMaxInRange(R,B);D=(a.PositionAndShape.RelativePosition.y-t.PositionAndShape.RelativePosition.y-e-this.rules.StaffHeight)/2+this.rules.StaffHeight}}}h||(t=l.SkyBottomLineCalculator.getSkyLineMinInRange(N,F),t-n/2?-n/2:i-t.PositionAndShape.BorderMarginBottom}else a=i-t.PositionAndShape.BorderMarginBottom;t.PositionAndShape.RelativePosition=new u.PointF2D(e.x,a)}else if(t.Placement===P.PlacementEnum.Below){const i=o.getBottomLineMaxInRange(n,r),l=s.ParentStaff.ParentInstrument.Staves[s.ParentStaff.ParentInstrument.Staves.length-1];if(s.isPartOfMultiStaffInstrument()&&s.ParentStaff!==l){const e=s.ParentMusicSystem.StaffLines[s.ParentMusicSystem.StaffLines.indexOf(s)+1].PositionAndShape.RelativePosition.y-s.PositionAndShape.RelativePosition.y-this.rules.StaffHeight;a=i+t.PositionAndShape.BorderMarginBottomt.PositionAndShape.Size.width&&(b=t.PositionAndShape.Size.width-this.rules.MeasureRightMargin,p=b-h.PositionAndShape.MarginSize.width,e.x=p-h.PositionAndShape.BorderMarginLeft);const g=t.SkyBottomLineCalculator;return d=n===P.PlacementEnum.Below?g.getBottomLineMaxInRange(p,b)+a:g.getSkyLineMinInRange(p,b)-a,h.PositionAndShape.RelativePosition=new u.PointF2D(e.x,d),n===P.PlacementEnum.Below?g.updateBottomLineInRange(p,b,h.PositionAndShape.BorderMarginBottom+d):g.updateSkyLineInRange(p,b,h.PositionAndShape.BorderMarginTop+d),h}calculateTempoExpressionsForMultiTempoExpression(t,e,i){const s=r.Fraction.plus(t.AbsoluteTimestamp,e.Timestamp),n=this.graphicalMusicSheet.MeasureList[i];let o=new u.PointF2D;if(e.ContinuousTempo||e.InstantaneousTempo){if(this.rules.MinMeasureToDrawIndex>0)return;if(!n[0])return;let t=n[0].ParentStaffLine,i=n[0].PositionAndShape.RelativePosition.x,r=0;for(let e=0;e0){t=n[e].ParentStaffLine,i=n[e].PositionAndShape.RelativePosition.x,r=e;break}if(o=this.getRelativePositionInStaffLineFromTimestamp(s,r,t,t.isPartOfMultiStaffInstrument(),i),e.EntriesList.length>0&&e.EntriesList[0].Expression instanceof L.InstantaneousTempoExpression&&(e.EntriesList[0].Expression.Placement=P.PlacementEnum.Above,t.Measures[0].staffEntries.length>0&&0===Math.abs(o.x-t.Measures[0].staffEntries[0].PositionAndShape.RelativePosition.x)&&t.ParentMusicSystem===this.musicSystems[0])){const e=t.Measures[0].FirstInstructionStaffEntry;if(e){const t=e.GraphicalInstructions.last();o.x=t.PositionAndShape.RelativePosition.x}this.rules.CompactMode&&(o.x=t.PositionAndShape.RelativePosition.x+t.Measures[0].PositionAndShape.RelativePosition.x)}for(const i of e.EntriesList){let s=m.TextAlignmentEnum.CenterBottom;this.rules.CompactMode&&(s=m.TextAlignmentEnum.LeftBottom);const n=this.calculateLabel(t,o,i.label,e.getFontstyleOfFirstEntry(),i.Expression.Placement,this.rules.UnknownTextHeight,s,this.rules.TempoYSpacing);if(i.Expression instanceof L.InstantaneousTempoExpression){for(const e of t.AbstractExpressions)e instanceof T.GraphicalInstantaneousTempoExpression&&(e.SourceExpression.Label,i.Expression.Label);if(new T.GraphicalInstantaneousTempoExpression(i.Expression,n).ParentStaffLine||v.default.warn("Adding staffline didn't work"),this.rules.MetronomeMarksDrawn&&i.Expression.Enum===L.TempoEnum.metronomeMark){this.createMetronomeMark(i.Expression);continue}}else i.Expression,A.ContinuousTempoExpression}}}createMetronomeMark(t){throw new Error(this.abstractNotImplementedErrorMessage)}graphicalMeasureCreatedCalculations(t){}clearSystemsAndMeasures(){for(let t=0,e=this.graphicalMusicSheet.MusicPages.length;t-1&&i.PositionAndShape.ChildElements.splice(t,1),i.FirstInstructionStaffEntry=void 0,i.beginInstructionsWidth=0}if(i.LastInstructionStaffEntry){const t=i.PositionAndShape.ChildElements.indexOf(i.LastInstructionStaffEntry.PositionAndShape);t>-1&&i.PositionAndShape.ChildElements.splice(t,1),i.LastInstructionStaffEntry=void 0,i.endInstructionsWidth=0}}e.Measures=[],e.PositionAndShape.ChildElements=[]}i.StaffLines.length=0,i.PositionAndShape.ChildElements=[]}e.MusicSystems=[],e.PositionAndShape.ChildElements=[]}this.graphicalMusicSheet.MusicPages=[]}handleVoiceEntry(t,e,i,s,n,r,o,a,l,c,u){t.StemDirectionXml!==h.StemDirectionType.Undefined&&this.rules.SetWantedStemDirectionByXml&&void 0!==t.StemDirectionXml?t.WantedStemDirection=t.StemDirectionXml:this.calculateStemDirectionFromVoices(t);const d=e.findOrCreateGraphicalVoiceEntry(t);d.octaveShiftValue=a;const f=e.tabStaffEntry;let m;f&&(m=f.findOrCreateGraphicalVoiceEntry(t));for(let s=0,l=t.Notes.length;s-1)continue;let h;if(t.IsGrace?h=F.symbolFactory.createGraceNote(l,d,n,this.rules,a):(h=F.symbolFactory.createNote(l,d,n,a,this.rules,void 0),F.stafflineNoteCalculator.trackNote(h)),l.Pitch&&this.checkNoteForAccidental(h,i,n,a),this.resetYPositionForLeadSheet(h.PositionAndShape),e.addGraphicalNoteToListAtCorrectYPosition(d,h),h.PositionAndShape.calculateBoundingBox(),this.leadSheet||(void 0!==l.NoteBeam&&l.PrintObject&&this.handleBeam(h,l.NoteBeam,o),void 0!==l.NoteTuplet&&l.PrintObject&&this.handleTuplet(h,l.NoteTuplet,r)),m){const t=F.symbolFactory.createNote(l,m,n,a,this.rules,void 0);f.addGraphicalNoteToListAtCorrectYPosition(m,t),t.PositionAndShape.calculateBoundingBox(),this.leadSheet||l.NoteTuplet&&this.handleTuplet(t,l.NoteTuplet,r)}}return t.Articulations.length>0&&this.handleVoiceEntryArticulations(t.Articulations,t,e),t.TechnicalInstructions.length>0&&this.handleVoiceEntryTechnicalInstructions(t.TechnicalInstructions,t,e),t.LyricsEntries.size()>0&&this.handleVoiceEntryLyrics(t,e,s),t.OrnamentContainer&&this.handleVoiceEntryOrnaments(t.OrnamentContainer,t,e),a}resetYPositionForLeadSheet(t){this.leadSheet&&(t.RelativePosition=new u.PointF2D(t.RelativePosition.x,0))}layoutVoiceEntries(t,e){if(t.PositionAndShape.RelativePosition=new u.PointF2D(0,0),!this.leadSheet)for(const e of t.graphicalVoiceEntries){const i=e.notes;if(0===i.length)continue;const s=i[0].sourceNote.ParentVoiceEntry,n=void 0!==i[0].sourceNote.Pitch;this.layoutVoiceEntry(s,i,t,n)}}maxInstrNameLabelLength(){var t;let e=0;for(const i of this.graphicalMusicSheet.ParentMusicSheet.Instruments)if((null===(t=i.NameLabel)||void 0===t?void 0:t.print)&&i.Voices.length>0&&i.Voices[0].Visible){let t=i.NameLabel;this.rules.RenderPartNames||(t=new M.Label("",t.textAlignment,t.font));const s=new f.GraphicalLabel(t,this.rules.InstrumentLabelTextHeight,m.TextAlignmentEnum.LeftCenter,this.rules);s.setLabelPositionAndShapeBorders(),e=Math.max(e,s.PositionAndShape.MarginSize.width)}return this.rules.RenderPartNames?e:0}calculateSheetLabelBoundingBoxes(){const t=this.graphicalMusicSheet.ParentMusicSheet,e=this.rules.DefaultColorTitle;if(void 0!==t.Title&&this.rules.RenderTitle){const i=new f.GraphicalLabel(t.Title,this.rules.SheetTitleHeight,m.TextAlignmentEnum.CenterBottom,this.rules);i.Label.IsCreditLabel=!0,i.Label.colorDefault=e,this.graphicalMusicSheet.Title=i,i.setLabelPositionAndShapeBorders()}else this.rules.RenderTitle||(this.graphicalMusicSheet.Title=void 0);if(void 0!==t.Subtitle&&this.rules.RenderSubtitle){const i=new f.GraphicalLabel(t.Subtitle,this.rules.SheetSubtitleHeight,m.TextAlignmentEnum.CenterCenter,this.rules);i.Label.IsCreditLabel=!0,i.Label.colorDefault=e,this.graphicalMusicSheet.Subtitle=i,i.setLabelPositionAndShapeBorders()}else this.rules.RenderSubtitle||(this.graphicalMusicSheet.Subtitle=void 0);if(void 0!==t.Composer&&this.rules.RenderComposer){const i=new f.GraphicalLabel(t.Composer,this.rules.SheetComposerHeight,m.TextAlignmentEnum.RightCenter,this.rules);i.Label.IsCreditLabel=!0,i.Label.colorDefault=e,this.graphicalMusicSheet.Composer=i,i.setLabelPositionAndShapeBorders()}else this.rules.RenderComposer||(this.graphicalMusicSheet.Composer=void 0);if(void 0!==t.Lyricist&&this.rules.RenderLyricist){const i=new f.GraphicalLabel(t.Lyricist,this.rules.SheetAuthorHeight,m.TextAlignmentEnum.LeftCenter,this.rules);i.Label.IsCreditLabel=!0,i.Label.colorDefault=e,this.graphicalMusicSheet.Lyricist=i,i.setLabelPositionAndShapeBorders()}else this.rules.RenderLyricist||(this.graphicalMusicSheet.Lyricist=void 0);if(void 0!==t.Copyright&&this.rules.RenderCopyright){const i=new f.GraphicalLabel(t.Copyright,this.rules.SheetCopyrightHeight,m.TextAlignmentEnum.CenterBottom,this.rules);i.Label.IsCreditLabel=!0,i.Label.colorDefault=e,this.graphicalMusicSheet.Copyright=i,i.setLabelPositionAndShapeBorders()}else this.rules.RenderCopyright||(this.graphicalMusicSheet.Copyright=void 0)}checkMeasuresForWholeRestNotes(){for(let t=0,e=this.musicSystems.length;t0&&1===t.graphicalVoiceEntries[0].notes.length){const i=t.graphicalVoiceEntries[0].notes[0];!i.sourceNote.Pitch&&new r.Fraction(1,2).lt(i.sourceNote.Length)&&this.layoutMeasureWithWholeRest(i,t,e)}}}}}}optimizeRestNotePlacement(t,e){if(0===t.graphicalVoiceEntries.length)return;const i=t.graphicalVoiceEntries[0].notes;if(0===i.length)return;const s=i[0],n=s.sourceNote.isRest();if(2===t.graphicalVoiceEntries.length){let e=!1;const i=t.graphicalVoiceEntries[1].notes;i.length>0&&(e=i[0].sourceNote.isRest()),n&&e?this.calculateTwoRestNotesPlacementWithCollisionDetection(t):(n||e)&&this.calculateRestNotePlacementWithCollisionDetectionFromGraphicalNote(t)}else if(n&&t!==e.staffEntries[0]&&t!==e.staffEntries[e.staffEntries.length-1]){const i=e.staffEntries.indexOf(t),n=e.staffEntries[i-1],r=e.staffEntries[i+1];if(1===n.graphicalVoiceEntries.length){const e=n.graphicalVoiceEntries[0].notes[0];if(void 0!==e.sourceNote.NoteBeam&&1===r.graphicalVoiceEntries.length){const i=r.graphicalVoiceEntries[0].notes[0];void 0!==i.sourceNote.NoteBeam&&e.sourceNote.NoteBeam===i.sourceNote.NoteBeam&&(this.calculateRestNotePlacementWithinGraphicalBeam(t,s,e,r,i),t.PositionAndShape.calculateBoundingBox())}}}}getRelativePositionInStaffLineFromTimestamp(t,e,i,s,n=0){let o,a,l=new u.PointF2D;const h=this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers.length,c=this.graphicalMusicSheet.GetInterpolatedIndexInVerticalContainers(t),d=Math.min(Math.floor(c),h-1),f=Math.min(Math.ceil(c),h-1);if(d<0||e<0)return l;if(o=this.getFirstLeftNotNullStaffEntryFromContainer(d,e,s),a=this.getFirstRightNotNullStaffEntryFromContainer(f,e,s),o&&a){let e=o.parentMeasure.PositionAndShape.RelativePosition.x;n>0&&(e=n);let s=o.PositionAndShape.RelativePosition.x+e,h=a.PositionAndShape.RelativePosition.x+a.parentMeasure.PositionAndShape.RelativePosition.x;n>0&&(h=a.PositionAndShape.RelativePosition.x+e);let c=0;if(o!==a){const e=o.getAbsoluteTimestamp(),i=a.getAbsoluteTimestamp();c=r.Fraction.minus(t,e).RealValue/r.Fraction.minus(i,e).RealValue}o.parentMeasure.ParentStaffLine!==a.parentMeasure.ParentStaffLine&&(o.parentMeasure.ParentStaffLine===i?h=i.PositionAndShape.Size.width:s=i.PositionAndShape.RelativePosition.x),l=new u.PointF2D(s+(h-s)*c,0)}return l}getRelativeXPositionFromTimestamp(t){const e=this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers.length,i=this.graphicalMusicSheet.GetInterpolatedIndexInVerticalContainers(t),s=Math.max(0,Math.min(Math.round(i),e-1)),n=this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[s].getFirstNonNullStaffEntry();return n.PositionAndShape.RelativePosition.x+n.parentMeasure.PositionAndShape.RelativePosition.x}calculatePageLabels(t){var e;this.rules.RenderSingleHorizontalStaffline&&(t.PositionAndShape.BorderRight=t.PositionAndShape.Size.width,t.PositionAndShape.calculateBoundingBox(),this.graphicalMusicSheet.ParentMusicSheet.pageWidth=t.PositionAndShape.Size.width);let i=10,s=-1;if(t.MusicSystems.length>0){const e=t.MusicSystems[0];i=e.PositionAndShape.RelativePosition.y+e.PositionAndShape.BorderTop;const n=t.MusicSystems[t.MusicSystems.length-1];s=n.PositionAndShape.RelativePosition.y+n.PositionAndShape.BorderBottom}if(this.graphicalMusicSheet.Title&&this.rules.RenderTitle){const e=this.graphicalMusicSheet.Title;e.PositionAndShape.Parent=t.PositionAndShape;const i=new u.PointF2D;i.x=this.graphicalMusicSheet.ParentMusicSheet.pageWidth/2,i.y=this.rules.TitleTopDistance+this.rules.SheetTitleHeight,e.PositionAndShape.RelativePosition=i,t.Labels.push(e)}if(this.graphicalMusicSheet.Subtitle&&this.rules.RenderTitle&&this.rules.RenderSubtitle){const e=this.graphicalMusicSheet.Subtitle;e.PositionAndShape.Parent=t.PositionAndShape;const i=new u.PointF2D;i.x=this.graphicalMusicSheet.ParentMusicSheet.pageWidth/2,i.y=this.rules.TitleTopDistance+this.rules.SheetTitleHeight+this.rules.SheetMinimumDistanceBetweenTitleAndSubtitle,e.PositionAndShape.RelativePosition=i,t.Labels.push(e)}const n=this.graphicalMusicSheet.Composer;let r;if(n&&this.rules.RenderComposer){n.PositionAndShape.Parent=t.PositionAndShape,n.setLabelPositionAndShapeBorders();const s=new u.PointF2D;s.x=this.graphicalMusicSheet.ParentMusicSheet.pageWidth-this.rules.PageRightMargin,s.y=i,s.y-=this.rules.SystemComposerDistance;const o=null===(e=n.TextLines)||void 0===e?void 0:e.length;o>1&&(s.y-=n.PositionAndShape.BorderBottom*(o-1)/o),r=s.y,n.PositionAndShape.RelativePosition=s,t.Labels.push(n)}const o=this.graphicalMusicSheet.Lyricist;if(o&&this.rules.RenderLyricist){o.PositionAndShape.Parent=t.PositionAndShape,o.setLabelPositionAndShapeBorders();const e=new u.PointF2D;e.x=this.rules.PageLeftMargin,e.y=i,e.y+=o.PositionAndShape.BorderBottom,e.y=Math.min(e.y,null!=r?r:Number.MAX_SAFE_INTEGER),o.PositionAndShape.RelativePosition=e,t.Labels.push(o)}const a=this.graphicalMusicSheet.Copyright;if(a&&this.rules.RenderCopyright){a.PositionAndShape.Parent=t.PositionAndShape,a.setLabelPositionAndShapeBorders();const e=new u.PointF2D;e.x=t.PositionAndShape.Size.width/2,e.y=s+this.rules.SheetCopyrightMargin,e.y-=a.PositionAndShape.BorderTop,a.PositionAndShape.RelativePosition=e,t.Labels.push(a)}}createGraphicalTies(){for(let t=0;t=0&&this.staffEntriesWithGraphicalTies.push(a)}a=r}}setTieDirections(t){if(!t)return;const e=t.ties;if(1===e.length){const t=e[0];if(t.TieDirection===P.PlacementEnum.NotYetDefined){const e=t.Notes[0].ParentVoiceEntry.ParentVoice.VoiceId;2!==e&&6!==e||(t.TieDirection=P.PlacementEnum.Below)}}if(e.length>1){let t;for(const i of e){const e=i.Notes[0];(!t||e.Pitch.getHalfTone()>t.Pitch.getHalfTone())&&(t=e)}for(const i of e)i.TieDirection===P.PlacementEnum.NotYetDefined&&(i.Notes[0]===t?i.TieDirection=P.PlacementEnum.Above:i.TieDirection=P.PlacementEnum.Below)}}createAccidentalCalculators(){const t=[],e=this.graphicalMusicSheet.ParentMusicSheet.getFirstSourceMeasure();if(e)for(let i=0;i1)return;_=F.symbolFactory.createGraphicalMeasure(t,x)}if(_.hasError=t.getErrorInMeasure(f),t.FirstInstructionsStaffEntries[f])for(let e=0,i=t.FirstInstructionsStaffEntries[f].Instructions.length;e0){const e=o.Instructions[0];F.symbolFactory.createInStaffClef(t,e)}this.rules.RenderChordSymbols&&(null===(v=o.ChordContainers)||void 0===v?void 0:v.length)>0&&(o.ParentStaff.ParentInstrument.HasChordSymbols=!0,F.symbolFactory.createChordSymbols(o,t,s.ActiveKeyInstruction,this.graphicalMusicSheet.ParentMusicSheet.Transpose))}}if(s.doCalculationsAtEndOfMeasure(),t.LastInstructionsStaffEntries[f]){const e=t.LastInstructionsStaffEntries[f];for(let t=0,i=e.Instructions.length;t=1&&0===_.staffEntries.length){const e=new d.SourceStaffEntry(new w.VerticalSourceStaffEntryContainer(_.parentSourceMeasure,_.parentSourceMeasure.AbsoluteTimestamp,_.parentSourceMeasure.CompleteNumberOfStaves),x);if(0===x.Voices.length){const t=new B.Voice(_.ParentStaff.ParentInstrument,-1);x.Voices.push(t)}const i=new h.VoiceEntry(new r.Fraction(0,1),x.Voices[0],e);let s=t.Duration;0===s.RealValue&&(s=t.ActiveTimeSignature.clone());const n=new o.Note(i,e,s,void 0,t,!0);n.IsWholeMeasureRest=!0,n.PrintObject=this.rules.FillEmptyMeasuresWithWholeRest===R.FillEmptyMeasuresWithWholeRests.YesVisible,i.Notes.push(n);const c=F.symbolFactory.createStaffEntry(e,_);_.addGraphicalStaffEntry(c),c.relInMeasureTimestamp=i.Timestamp;const u=F.symbolFactory.createVoiceEntry(i,c);c.graphicalVoiceEntries.push(u);const f=F.symbolFactory.createNote(n,u,new a.ClefInstruction,l.OctaveEnum.NONE,this.rules);F.stafflineNoteCalculator.trackNote(f),u.notes.push(f)}_.hasOnlyRests=!0;for(const t of _.staffEntries)if(_.hasOnlyRests=t.hasOnlyRests(),!_.hasOnlyRests)break;return _}checkNoteForAccidental(t,e,i,s){let n=t.sourceNote.Pitch;const r=t.parentVoiceEntry.parentStaffEntry.parentMeasure.getTransposedHalftones();0!==r&&t.sourceNote.ParentStaffEntry.ParentStaff.ParentInstrument.MidiInstrumentId!==E.MidiInstrument.Percussion&&(n=t.Transpose(e.ActiveKeyInstruction,i,r,s),t.sourceNote.TransposedPitch=n),t.sourceNote.halfTone=n.getHalfTone(),e.checkAccidental(t,n)}handleStaffEntries(t){for(let e=0,i=this.graphicalMusicSheet.MeasureList.length;e0&&t.graphicalVoiceEntries[0].notes.length>0&&(this.layoutVoiceEntries(t,e),this.layoutStaffEntry(t));this.graphicalMeasureCreatedCalculations(s)}}}}calculateSkyBottomLines(){}calculateExpressionAlignements(){}calculateStaffEntryArticulationMarks(){for(let t=0,e=this.musicSystems.length;t0&&this.layoutArticulationMarks(e.Articulations,e,i)}}}}}}calculateOrnaments(){for(let t=0,e=this.musicSystems.length;t0&&e.LyricVersesNumbers.sort()}for(let e=0,i=this.musicSystems.length;e=0&&(s=e.GraphicalLyricsEntries[i+1]),!s)return;const n=t.StaffEntryParent.parentMeasure.ParentStaffLine,r=s.StaffEntryParent.parentMeasure.ParentStaffLine,o=t.StaffEntryParent,a=s.StaffEntryParent;if(t.StaffEntryParent.parentMeasure.ParentStaffLine===s.StaffEntryParent.parentMeasure.ParentStaffLine){const e=o.parentMeasure.PositionAndShape.RelativePosition.x+o.PositionAndShape.RelativePosition.x+t.GraphicalLabel.PositionAndShape.RelativePosition.x+t.GraphicalLabel.PositionAndShape.BorderMarginRight,i=a.parentMeasure.PositionAndShape.RelativePosition.x+a.PositionAndShape.RelativePosition.x+t.GraphicalLabel.PositionAndShape.RelativePosition.x+s.GraphicalLabel.PositionAndShape.BorderMarginLeft,r=t.GraphicalLabel.PositionAndShape.RelativePosition.y;let l=1;i-e>3*this.rules.MinimumDistanceBetweenDashes&&(l=Math.floor((i-e)/this.rules.MinimumDistanceBetweenDashes)-1),1===l?this.calculateSingleDashForLyricWord(n,e,i,r):this.calculateDashes(n,e,i,r)}else{const e=o.parentMeasure.PositionAndShape.RelativePosition.x+o.PositionAndShape.RelativePosition.x+t.GraphicalLabel.PositionAndShape.BorderMarginRight,i=n.Measures[n.Measures.length-1],l=i.PositionAndShape.RelativePosition.x+i.PositionAndShape.Size.width;let h=t.GraphicalLabel.PositionAndShape.RelativePosition.y;if(this.calculateDashes(n,e,l,h),r&&r.Measures[0]&&a.parentMeasure.ParentStaffLine&&(a!==a.parentMeasure.staffEntries[0]||a.parentMeasure!==a.parentMeasure.ParentStaffLine.Measures[0])){const t=r.Measures[0].staffEntries[0].PositionAndShape.RelativePosition.x,e=a.parentMeasure.PositionAndShape.RelativePosition.x+a.PositionAndShape.RelativePosition.x+s.GraphicalLabel.PositionAndShape.BorderMarginLeft;h=s.GraphicalLabel.PositionAndShape.RelativePosition.y,this.calculateDashes(r,t,e,h)}}}calculateDashes(t,e,i,s){let n=i-e;if(n<3*this.rules.MinimumDistanceBetweenDashes)this.calculateSingleDashForLyricWord(t,e,i,s);else{const r=Math.floor(n/this.rules.MinimumDistanceBetweenDashes)-1,o=n/(r+1);let a=0;for(e+=o,i-=o;a<=Math.floor(r/2)&&i>e;)n=this.calculateRightAndLeftDashesForLyricWord(t,e,i,s),e+=o,i-=o,a++;n>2*o&&this.calculateSingleDashForLyricWord(t,e,i,s)}}calculateSingleDashForLyricWord(t,e,i,s){const n=new M.Label("-");n.colorDefault=this.rules.DefaultColorLyrics;const r=new f.GraphicalLabel(n,this.rules.LyricsHeight,m.TextAlignmentEnum.CenterBottom,this.rules);r.setLabelPositionAndShapeBorders(),t.LyricsDashes.push(r),-1===this.staffLinesWithLyricWords.indexOf(t)&&this.staffLinesWithLyricWords.push(t),r.PositionAndShape.Parent=t.PositionAndShape;const o=new u.PointF2D(e+(i-e)/2,s);r.PositionAndShape.RelativePosition=o}calculateLyricExtend(t){let e=t.GraphicalLabel.PositionAndShape.RelativePosition.y;const i=t.StaffEntryParent,s=i.parentMeasure.ParentStaffLine;let n,r;const o=i.parentMeasure.ParentStaff.idInMusicSheet;for(let t=i.parentVerticalContainer.Index+1;t0)break;n=e,r=n.parentMeasure.ParentStaffLine,r||(r=i.parentMeasure.ParentStaffLine)}}if(n&&r)if(s===r&&n.parentMeasure.ParentStaffLine){const r=i.parentMeasure.PositionAndShape.RelativePosition.x+i.PositionAndShape.RelativePosition.x+t.GraphicalLabel.PositionAndShape.BorderMarginRight,o=n.parentMeasure.PositionAndShape.RelativePosition.x+n.PositionAndShape.RelativePosition.x+n.PositionAndShape.BorderMarginRight;e-=t.GraphicalLabel.PositionAndShape.Size.height/4,this.calculateSingleLyricWordWithUnderscore(s,r,o,e)}else{const o=s.Measures[s.Measures.length-1].PositionAndShape,a=i.parentMeasure.PositionAndShape.RelativePosition.x+i.PositionAndShape.RelativePosition.x+t.GraphicalLabel.PositionAndShape.BorderMarginRight,l=o.RelativePosition.x+o.Size.width;if(e-=t.GraphicalLabel.PositionAndShape.Size.height/4,this.calculateSingleLyricWordWithUnderscore(s,a,l,e),!n)return;if(n.parentMeasure.ParentStaffLine&&n.parentMeasure.staffEntries&&(n!==n.parentMeasure.staffEntries[0]||n.parentMeasure!==n.parentMeasure.ParentStaffLine.Measures[0])){const t=r.Measures[0].staffEntries[0].PositionAndShape.RelativePosition.x,i=n.parentMeasure.PositionAndShape.RelativePosition.x+n.PositionAndShape.RelativePosition.x+n.PositionAndShape.BorderMarginRight;this.calculateSingleLyricWordWithUnderscore(r,t,i,e)}}}calculateSingleLyricWordWithUnderscore(t,e,i,s){const n=new u.PointF2D(e,s),r=new u.PointF2D(i,s),o=new _.GraphicalLine(n,r,this.rules.LyricUnderscoreLineWidth);o.colorHex=this.rules.DefaultColorLyrics,t.LyricLines.push(o),-1===this.staffLinesWithLyricWords.indexOf(t)&&this.staffLinesWithLyricWords.push(t)}calculateRightAndLeftDashesForLyricWord(t,e,i,s){const n=new M.Label("-");n.colorDefault=this.rules.DefaultColorLyrics;const r=new f.GraphicalLabel(n,this.rules.LyricsHeight,m.TextAlignmentEnum.CenterBottom,this.rules);r.setLabelPositionAndShapeBorders(),t.LyricsDashes.push(r),-1===this.staffLinesWithLyricWords.indexOf(t)&&this.staffLinesWithLyricWords.push(t),r.PositionAndShape.Parent=t.PositionAndShape;const o=new u.PointF2D(e,s);r.PositionAndShape.RelativePosition=o;const a=new M.Label("-"),l=new f.GraphicalLabel(a,this.rules.LyricsHeight,m.TextAlignmentEnum.CenterBottom,this.rules);l.setLabelPositionAndShapeBorders(),t.LyricsDashes.push(l),l.PositionAndShape.Parent=t.PositionAndShape;const h=new u.PointF2D(i,s);return l.PositionAndShape.RelativePosition=h,l.PositionAndShape.RelativePosition.x-r.PositionAndShape.RelativePosition.x}calculateDynamicExpressions(){const t=Math.min(this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length-1,this.rules.MaxMeasureToDrawIndex);for(let e=Math.min(this.rules.MinMeasureToDrawIndex,this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length);e<=t;e++){const t=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures[e];this.dynamicExpressionMap.clear();for(let i=0;i=0;i--)if(this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[i].StaffEntries[e])return this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[i].StaffEntries[e]}getFirstRightNotNullStaffEntryFromContainer(t,e,i){if(this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[t].StaffEntries[e])return this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[t].StaffEntries[e];for(let i=t+1;i0||e.StaffLinkedExpressions[i][s].UnknownList.length>0)&&this.calculateMoodAndUnknownExpression(e.StaffLinkedExpressions[i][s],t,i)}}calculateStemDirectionFromVoices(t){if(void 0!==t.ParentSourceStaffEntry.Link)return t===t.ParentSourceStaffEntry.VoiceEntries[0]?void(t.WantedStemDirection=h.StemDirectionType.Up):void(t.WantedStemDirection=h.StemDirectionType.Down);t.ParentVoice instanceof b.LinkedVoice?t.WantedStemDirection=h.StemDirectionType.Down:t.ParentSourceStaffEntry.VoiceEntries.length>1&&(t.WantedStemDirection=h.StemDirectionType.Up)}setBeamNotesWantedStemDirections(t){if(!(t.Notes.length>0))return;const e=t.Notes[0].NoteBeam;if(e)for(const i of e.Notes)if(i.ParentVoiceEntry.WantedStemDirection!==h.StemDirectionType.Undefined&&i.ParentVoiceEntry.ParentSourceStaffEntry.ParentStaff.Id===t.ParentSourceStaffEntry.ParentStaff.Id){t.WantedStemDirection=i.ParentVoiceEntry.WantedStemDirection;break}}}e.MusicSheetCalculator=F},1494:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MusicSheetDrawer=void 0;const s=i(8911),n=i(8155),r=i(6729),o=i(3278),a=i(9086),l=i(9946),h=i(2255),c=i(1274),u=i(1703),d=i(7771),f=i(158),m=i(5074),p=i(9839),b=i(4196);e.MusicSheetDrawer=class{constructor(t,e){this.drawableBoundingBoxElement="None",this.skyLineVisible=!1,this.bottomLineVisible=!1,this.phonicScoreMode=m.PhonicScoreModes.Manual,this.textMeasurer=t,this.splitScreenLineColor=-1,this.drawingParameters=e,this.rules=e.Rules}set Mode(t){this.phonicScoreMode=t}drawSheet(t){if(this.graphicalMusicSheet=t,this.rules=t.ParentMusicSheet.Rules,this.drawSplitScreenLine(),this.drawingParameters.drawCursors)for(const e of t.Cursors){if(!e)continue;const t=new s.BoundingBox(e);t.AbsolutePosition=e.Start,t.BorderBottom=e.End.y-e.Start.y,t.BorderRight=e.Width/2,t.BorderLeft=-e.Width/2,this.isVisible(t)&&this.drawLineAsVerticalRectangle(e,n.GraphicalLayers.Cursor)}this.drawingParameters.drawScrollIndicator&&this.drawScrollIndicator();const e=Math.min(this.graphicalMusicSheet.MusicPages.length,this.rules.MaxPageToDrawNumber);for(let t=0;t0&&this.drawDashes(e.LyricsDashes),e.LyricLines.length>0&&this.drawLyricLines(e.LyricLines,e));for(const e of t.SystemLines)this.drawSystemLineObject(e);if(t.Parent===t.Parent.Parent.MusicPages[0])for(const e of t.Labels)e.SVGNode=this.drawLabel(e,n.GraphicalLayers.Notes);const o=this.graphicalMusicSheet.ParentMusicSheet.Instruments,a=o.filter((t=>t.Visible)).length;for(const e of t.InstrumentBrackets)this.drawInstrumentBrace(e,t);if(o.length>0)if(a>1)for(const e of t.GroupBrackets)this.drawGroupBracket(e,t);else for(const e of t.GroupBrackets)e.Visible=!1;if(!this.leadSheet)for(const e of t.MeasureNumberLabels)e.SVGNode=this.drawLabel(e,n.GraphicalLayers.Notes);for(const e of t.StaffLines)this.drawStaffLineSymbols(e);this.drawingParameters.drawMarkedAreas&&this.drawMarkedAreas(t),this.drawingParameters.drawComments&&this.drawComment(t)}activateSystemRendering(t,e,i,s){return!0}drawSystemLineObject(t){}drawStaffLine(t){for(const e of t.Measures)this.drawMeasure(e);this.rules.RenderLyrics&&t.LyricsDashes.length>0&&this.drawDashes(t.LyricsDashes),this.drawOctaveShifts(t),this.drawPedals(t),this.drawExpressions(t),this.skyLineVisible&&this.drawSkyLine(t),this.bottomLineVisible&&this.drawBottomLine(t)}drawLyricLines(t,e){e.LyricLines.forEach((t=>{t.Start.y+=e.PositionAndShape.AbsolutePosition.y,t.End.y+=e.PositionAndShape.AbsolutePosition.y,t.Start.x+=e.PositionAndShape.AbsolutePosition.x,t.End.x+=e.PositionAndShape.AbsolutePosition.x,this.drawGraphicalLine(t,this.rules.LyricUnderscoreLineWidth,t.colorHex)}))}drawExpressions(t){}drawGraphicalLine(t,e,i="black"){return this.drawLine(t.Start,t.End,i,e)}drawLine(t,e,i="#FF0000FF",s){}drawDashes(t){t.forEach((t=>t.SVGNode=this.drawLabel(t,n.GraphicalLayers.Notes)))}drawOctaveShifts(t){}drawStaffLines(t){if(t.StaffLines){const e=t.PositionAndShape.AbsolutePosition;for(let i=0;i<5;i++)this.drawLineAsHorizontalRectangleWithOffset(t.StaffLines[i],e,n.GraphicalLayers.Notes)}}drawInstantaneousDynamic(t){throw new Error("not implemented")}drawContinuousDynamic(t){throw new Error("not implemented")}drawSymbol(t,e,i,s=1,r=n.GraphicalLayers.Notes){}get leadSheet(){return this.graphicalMusicSheet.LeadSheet}set leadSheet(t){this.graphicalMusicSheet.LeadSheet=t}drawPage(t){if(this.isVisible(t.PositionAndShape)){for(const e of t.MusicSystems)this.isVisible(e.PositionAndShape)&&this.drawMusicSystem(e);if(t===t.Parent.MusicPages[0])for(const e of t.Labels)e.SVGNode=this.drawLabel(e,n.GraphicalLayers.Notes);this.drawableBoundingBoxElement&&this.drawBoundingBoxes(t.PositionAndShape,0,this.drawableBoundingBoxElement)}}drawBoundingBoxes(t,e=0,i="all"){const s=t.DataObject.constructor.name;let n=!1;"all"===i?n=!0:"VexFlowStaffEntry"===i?n=t.DataObject instanceof p.VexFlowStaffEntry:"VexFlowMeasure"===i?n=t.DataObject instanceof p.VexFlowMeasure:"VexFlowGraphicalNote"===i?n=t.DataObject instanceof p.VexFlowGraphicalNote:"VexFlowVoiceEntry"===i?n=t.DataObject instanceof p.VexFlowVoiceEntry:"GraphicalLabel"===i?n=t.DataObject instanceof l.GraphicalLabel:"VexFlowStaffLine"===i?n=t.DataObject instanceof p.VexFlowStaffLine:"SystemLine"===i?n=t.DataObject instanceof d.SystemLine:"StaffLineActivitySymbol"===i?n=t.DataObject instanceof b.StaffLineActivitySymbol:"VexFlowContinuousDynamicExpression"===i&&(n=t.DataObject instanceof p.VexFlowContinuousDynamicExpression),(n||s===i)&&this.drawBoundingBox(t,void 0,!0,s,e),e++,t.ChildElements.forEach((t=>this.drawBoundingBoxes(t,e,i)))}drawBoundingBox(t,e,i=!1,s,u=0){let d=new o.RectangleF2D(t.AbsolutePosition.x+t.BorderMarginLeft,t.AbsolutePosition.y+t.BorderMarginTop,t.BorderMarginRight-t.BorderMarginLeft,t.BorderMarginBottom-t.BorderMarginTop);i&&(this.drawLineAsHorizontalRectangle(new r.GraphicalLine(new a.PointF2D(t.AbsolutePosition.x-1,t.AbsolutePosition.y),new a.PointF2D(t.AbsolutePosition.x+1,t.AbsolutePosition.y),.1,n.OutlineAndFillStyleEnum.BaseWritingColor,e),u-1),this.drawLineAsVerticalRectangle(new r.GraphicalLine(new a.PointF2D(t.AbsolutePosition.x,t.AbsolutePosition.y-1),new a.PointF2D(t.AbsolutePosition.x,t.AbsolutePosition.y+1),.1,n.OutlineAndFillStyleEnum.BaseWritingColor,e),u-1)),d=this.applyScreenTransformationForRect(d);const f=this.renderRectangle(d,n.GraphicalLayers.Background,u,e,.5);if(s){const t=new h.Label(s);this.renderLabel(new l.GraphicalLabel(t,.8,c.TextAlignmentEnum.CenterCenter,this.rules),u,d.width,d.height,d.height,new a.PointF2D(d.x,d.y+12))}return f}drawMarkedAreas(t){for(const e of t.GraphicalMarkedAreas)e&&(e.systemRectangle&&this.drawRectangle(e.systemRectangle,n.GraphicalLayers.Background),e.settings&&(e.settings.SVGNode=this.drawLabel(e.settings,n.GraphicalLayers.Comment)),e.labelRectangle&&this.drawRectangle(e.labelRectangle,n.GraphicalLayers.Background),e.label&&(e.label.SVGNode=this.drawLabel(e.label,n.GraphicalLayers.Comment)))}drawComment(t){for(const e of t.GraphicalComments)e&&(e.settings&&(e.settings.SVGNode=this.drawLabel(e.settings,n.GraphicalLayers.Comment)),e.label&&(e.label.SVGNode=this.drawLabel(e.label,n.GraphicalLayers.Comment)))}drawStaffLineSymbols(t){const e=t.ParentStaff.ParentInstrument,i=t.PositionAndShape.AbsolutePosition.x,s=t.PositionAndShape.AbsolutePosition.y+2,o=t.PositionAndShape.BorderRight;e.highlight&&this.drawingParameters.drawHighlights&&this.drawLineAsHorizontalRectangle(new r.GraphicalLine(new a.PointF2D(i,s),new a.PointF2D(i+o,s),4,n.OutlineAndFillStyleEnum.Highlighted),n.GraphicalLayers.Highlight);let l=m.MusicSymbolDrawingStyle.Disabled,h=f.MusicSymbol.PLAY,c=this.drawingParameters.drawActivitySymbols;switch(this.phonicScoreMode){case m.PhonicScoreModes.Midi:h=f.MusicSymbol.PLAY,this.midiPlaybackAvailable&&t.ParentStaff.audible&&(l=m.MusicSymbolDrawingStyle.PlaybackSymbols);break;case m.PhonicScoreModes.Following:h=f.MusicSymbol.MIC,t.ParentStaff.following&&(l=m.MusicSymbolDrawingStyle.FollowSymbols);break;default:c=!1}if(c){const t=new a.PointF2D(i+o+2,s);this.drawSymbol(h,l,t)}if(this.drawingParameters.drawErrors)for(const e of t.Measures){const t=e.PositionAndShape,i=t.AbsolutePosition.x,s=t.AbsolutePosition.y+2;e.hasError&&this.graphicalMusicSheet.ParentMusicSheet.DrawErroneousMeasures&&this.drawLineAsHorizontalRectangle(new r.GraphicalLine(new a.PointF2D(i,s),new a.PointF2D(i+t.BorderRight,s),4,n.OutlineAndFillStyleEnum.ErrorUnderlay),n.GraphicalLayers.MeasureError)}}}},158:(t,e)=>{"use strict";var i;Object.defineProperty(e,"__esModule",{value:!0}),e.MusicSymbol=void 0,(i=e.MusicSymbol||(e.MusicSymbol={}))[i.Unused_first_Symbol=0]="Unused_first_Symbol",i[i.BLACK_HEAD=1]="BLACK_HEAD",i[i.UPWARDS_TAIL=2]="UPWARDS_TAIL",i[i.DOWNWARDS_TAIL=3]="DOWNWARDS_TAIL",i[i.UPWARDS_DOUBLE_TAIL=4]="UPWARDS_DOUBLE_TAIL",i[i.DOWNWARDS_DOUBLE_TAIL=5]="DOWNWARDS_DOUBLE_TAIL",i[i.UPWARDS_TRIPLE_TAIL=6]="UPWARDS_TRIPLE_TAIL",i[i.DOWNWARDS_TRIPLE_TAIL=7]="DOWNWARDS_TRIPLE_TAIL",i[i.UPWARDS_QUAD_TAIL=8]="UPWARDS_QUAD_TAIL",i[i.DOWNWARDS_QUAD_TAIL=9]="DOWNWARDS_QUAD_TAIL",i[i.ROUND_HEAD=10]="ROUND_HEAD",i[i.WHITE_HEAD=11]="WHITE_HEAD",i[i.G_CLEF=12]="G_CLEF",i[i.F_CLEF=13]="F_CLEF",i[i.C_CLEF=14]="C_CLEF",i[i.BREVE=15]="BREVE",i[i.BREVE_REST=16]="BREVE_REST",i[i.COMMON_TIME=17]="COMMON_TIME",i[i.CUT_TIME=18]="CUT_TIME",i[i.WHOLE_REST=19]="WHOLE_REST",i[i.HALF_REST=20]="HALF_REST",i[i.QUARTER_REST=21]="QUARTER_REST",i[i.EIGHTH_REST=22]="EIGHTH_REST",i[i.SIXTEENTH_REST=23]="SIXTEENTH_REST",i[i.THIRTYSECOND_REST=24]="THIRTYSECOND_REST",i[i.SIXTYFOURTH_REST=25]="SIXTYFOURTH_REST",i[i.FLAT=26]="FLAT",i[i.SHARP=27]="SHARP",i[i.NATURAL=28]="NATURAL",i[i.DOUBLE_FLAT=29]="DOUBLE_FLAT",i[i.DOUBLE_SHARP=30]="DOUBLE_SHARP",i[i.ZERO=31]="ZERO",i[i.ONE=32]="ONE",i[i.TWO=33]="TWO",i[i.THREE=34]="THREE",i[i.FOUR=35]="FOUR",i[i.FIVE=36]="FIVE",i[i.SIX=37]="SIX",i[i.SEVEN=38]="SEVEN",i[i.EIGHT=39]="EIGHT",i[i.NINE=40]="NINE",i[i.DOT=41]="DOT",i[i.FERMATA=42]="FERMATA",i[i.INVERTED_FERMATA=43]="INVERTED_FERMATA",i[i.SPICCATO=44]="SPICCATO",i[i.TENUTO=45]="TENUTO",i[i.MARCATO=46]="MARCATO",i[i.MARCATISSIMO=47]="MARCATISSIMO",i[i.INVERTED_MARCATISSIMO=48]="INVERTED_MARCATISSIMO",i[i.P=49]="P",i[i.F=50]="F",i[i.S=51]="S",i[i.Z=52]="Z",i[i.M=53]="M",i[i.R=54]="R",i[i.SEGNO=55]="SEGNO",i[i.CODA=56]="CODA",i[i.DRUM_CLEF=57]="DRUM_CLEF",i[i.G_CLEF_SUB8=58]="G_CLEF_SUB8",i[i.G_CLEF_SUPER8=59]="G_CLEF_SUPER8",i[i.G_CLEF_SUB15=60]="G_CLEF_SUB15",i[i.G_CLEF_SUPER15=61]="G_CLEF_SUPER15",i[i.F_CLEF_SUB8=62]="F_CLEF_SUB8",i[i.F_CLEF_SUPER8=63]="F_CLEF_SUPER8",i[i.F_CLEF_SUB15=64]="F_CLEF_SUB15",i[i.F_CLEF_SUPER15=65]="F_CLEF_SUPER15",i[i.DOWN_BOW=66]="DOWN_BOW",i[i.MORDENT=67]="MORDENT",i[i.INVERTED_MORDENT=68]="INVERTED_MORDENT",i[i.TURN=69]="TURN",i[i.INVERTED_TURN=70]="INVERTED_TURN",i[i.LEFTHAND_PIZZICATO=71]="LEFTHAND_PIZZICATO",i[i.RELEASE_PED=72]="RELEASE_PED",i[i.ENGAGE_PED=73]="ENGAGE_PED",i[i.VA8=74]="VA8",i[i.VB8=75]="VB8",i[i.TRILL=76]="TRILL",i[i.MA15=77]="MA15",i[i.MB15=78]="MB15",i[i.HIGH=79]="HIGH",i[i.PLAY=80]="PLAY",i[i.MIC=81]="MIC",i[i.SNAP_PIZZICATO=82]="SNAP_PIZZICATO",i[i.NATURAL_HARMONIC=83]="NATURAL_HARMONIC",i[i.EditPen=84]="EditPen",i[i.PEDAL_BRACKET=85]="PEDAL_BRACKET",i[i.PEDAL_MIXED=86]="PEDAL_MIXED",i[i.PEDAL_SYMBOL=87]="PEDAL_SYMBOL"},7142:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MusicSystem=void 0;const s=i(6842),n=i(8911),r=i(1797),o=i(1274),a=i(9946),l=i(4785),h=i(9086),c=i(6894),u=i(1649),d=i(1225),f=i(2255);class m extends l.GraphicalObject{constructor(t){super(),this.needsToBeRedrawn=!0,this.staffLines=[],this.graphicalMeasures=[],this.labels=new u.Dictionary,this.measureNumberLabels=[],this.objectsToRedraw=[],this.instrumentBrackets=[],this.groupBrackets=[],this.graphicalMarkedAreas=[],this.graphicalComments=[],this.systemLines=[],this.breaksPage=!1,this.id=t,this.boundingBox=new n.BoundingBox(this),this.maxLabelLength=0}get Parent(){return this.parent}set Parent(t){if(this.parent){const t=this.parent.MusicSystems.indexOf(this,0);t>-1&&this.parent.MusicSystems.splice(t,1)}this.parent=t,this.boundingBox.Parent=t.PositionAndShape}get NextSystem(){const t=this.Parent.MusicSystems.indexOf(this);return t!==this.Parent.MusicSystems.length?this.Parent.MusicSystems[t+1]:void 0}get StaffLines(){return this.staffLines}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}createSystemLeftLine(t,e,i){let s=-t/2;i&&(s=this.maxLabelLength+e-t/2);const n=this.staffLines[0].Measures[0];let r;this.staffLines.length>1&&(r=this.staffLines[this.staffLines.length-1].Measures[0]);const o=this.createSystemLine(s,t,c.SystemLinesEnum.SingleThin,d.SystemLinePosition.MeasureBegin,this,n,r);this.SystemLines.push(o),o.PositionAndShape.RelativePosition=new h.PointF2D(s,0),o.PositionAndShape.BorderLeft=0,o.PositionAndShape.BorderRight=t,o.PositionAndShape.BorderTop=o.PositionAndShape.Parent.BorderTop,o.PositionAndShape.BorderBottom=o.PositionAndShape.Parent.BorderBottom,this.createLinesForSystemLine(o)}createVerticalLineForMeasure(t,e,i,s,n,r){const o=r.ParentStaffLine,a=new h.PointF2D(o.PositionAndShape.RelativePosition.x,o.PositionAndShape.RelativePosition.y),l=o.ParentStaff.ParentInstrument.Staves;if(o.ParentStaff===l[0]){let c;l.length>1&&(c=this.getBottomStaffLine(o).Measures[n]);const u=this.createSystemLine(t,e,i,s,this,r,c),d=a.x+t;u.PositionAndShape.RelativePosition=new h.PointF2D(d,0),u.PositionAndShape.BorderLeft=0,u.PositionAndShape.BorderRight=e,this.SystemLines.push(u)}}setYPositionsToVerticalLineObjectsAndCreateLines(t){}calculateBorders(t){}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(t){for(let e=0,i=t.length;e1){let t,e;for(let s=0,n=this.staffLines.length;sthis.maxLabelLength&&(this.maxLabelLength=i.PositionAndShape.Size.width,e=r)}this.updateMusicSystemStaffLineXPosition(e)}setMusicSystemLabelsYPosition(){this.labels.forEach(((t,e)=>{let i=0,s=0;for(let e=0;e0&&(e.PositionAndShape.RelativePosition=new h.PointF2D(0,i/s+2))}))}checkStaffEntriesForStaffEntryLink(){let t=!1,e=!1;for(let i=0;i=0;i--){if(e=t.InstrumentalGroups[i],!(e instanceof s.Instrument))return this.findLastVisibleInstrumentInInstrumentalGroup(e);if(!0===e.Visible)return e}}updateMusicSystemStaffLineXPosition(t){for(let e=0,i=this.StaffLines.length;e{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MeasureBuildParameters=e.SystemBuildParameters=e.MusicSystemBuilder=void 0;const s=i(599),n=i(3331),r=i(5198),o=i(289),a=i(9086),l=i(6729),h=i(6894),c=i(4040),u=i(289),d=i(2337),f=i(1225);e.MusicSystemBuilder=class{constructor(){this.musicSystems=[],this.globalSystemIndex=0,this.leadSheet=!1}initialize(t,e,i){this.leadSheet=t.LeadSheet,this.graphicalMusicSheet=t,this.rules=this.graphicalMusicSheet.ParentMusicSheet.Rules,this.measureList=e,this.numberOfVisibleStaffLines=i,this.activeRhythm=new Array(this.numberOfVisibleStaffLines),this.activeKeys=new Array(this.numberOfVisibleStaffLines),this.activeClefs=new Array(this.numberOfVisibleStaffLines),this.initializeActiveInstructions(this.measureList[0])}buildMusicSystems(){var t,e,i;const s=this.getFullPageSystemWidth();let n=!1;for(this.measureListIndex=0,this.currentSystemParams=new m,this.currentSystemParams.currentSystem=this.initMusicSystem();this.measureListIndex0){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 t of this.musicSystems)this.optimizeDistanceBetweenStaffLines(t);this.calculateMusicSystemsRelativePositions()}setMeasureWidth(t,e,i,s){for(let n=0,r=t.length;n0&&(r.beginInstructionsWidth=i),s>0&&(r.endInstructionsWidth=s)}}finalizeCurrentAndCreateNewSystem(t,e=!1,i=!0,s=!1){this.finalizeCurrentSystem(t,e,i,s),this.currentSystemParams=new m,void 0!==t&&this.measureListIndex=1){const e=this.currentSystemParams.currentSystem.GraphicalMeasures[this.currentSystemParams.currentSystem.GraphicalMeasures.length-1];let i=0;const s=t[t.length-1];s.endLine===h.SystemLinesEnum.DotsBoldBoldDots&&(s.endLine=h.SystemLinesEnum.DotsThinBold,i=e[0].getLineWidth(h.SystemLinesEnum.DotsBoldBoldDots)/2-e[0].getLineWidth(h.SystemLinesEnum.DotsThinBold)),this.currentSystemParams.currentSystemFixWidth-=i;for(let t=0,s=e.length;t1){r=!0;break}let o=0;for(let e=0;e=0&&this.measureList[i]){const e=null===(l=this.measureList[i][0])||void 0===l?void 0:l.parentSourceMeasure;(null==e?void 0:e.ImplicitMeasure)&&(null==e?void 0:e.RhythmPrinted)&&(t=!1)}t&&(e.addRhythmAtBegin(u),e.parentSourceMeasure.RhythmPrinted=u,p=!0)}return(f||m||p)&&(d+=e.beginInstructionsWidth,p&&(d+=this.rules.RhythmRightMargin)),d}addInstructionsAtMeasureEnd(t,e,i){if(!t||!t.Instructions||0===t.Instructions.length)return 0;for(let s=0,n=t.Instructions.length;s0&&(this.currentSystemParams.systemMeasures.push({beginLine:h.SystemLinesEnum.None,endLine:h.SystemLinesEnum.None}),this.currentSystemParams.currentWidth+=s,this.currentSystemParams.currentSystemFixWidth+=s)}addExtraInstructionMeasure(t,e,i){const s=this.currentSystemParams.currentSystem,n=c.MusicSheetCalculator.symbolFactory.createExtraGraphicalMeasure(s.StaffLines[t]);[].push(n),e&&n.addKeyAtBegin(e,this.activeKeys[t],this.activeClefs[t]),void 0!==i&&i.PrintObject&&n.addRhythmAtBegin(i),n.PositionAndShape.BorderLeft=0,n.PositionAndShape.BorderTop=0,n.PositionAndShape.BorderBottom=this.rules.StaffHeight;const r=this.rules.MeasureLeftMargin+n.beginInstructionsWidth+this.rules.MeasureRightMargin;return n.PositionAndShape.BorderRight=r,s.StaffLines[t].Measures.push(n),r}addStaveMeasuresToSystem(t){if(t[0]){const e=[];for(let i=0;i1){const e=Math.min(this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length-1,t.measureListIndex+t.multipleRestMeasures-1);t=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures[e]}}finally{}return this.nextMeasureBeginsLineRepetition()&&this.thisMeasureEndsLineRepetition()?h.SystemLinesEnum.DotsBoldBoldDots:this.thisMeasureEndsLineRepetition()?h.SystemLinesEnum.DotsThinBold:this.nextMeasureHasKeyInstructionChange()||this.thisMeasureEndsWordRepetition()||this.nextMeasureBeginsWordRepetition()?h.SystemLinesEnum.DoubleThin:t&&void 0!==t.endingBarStyleEnum?t.endingBarStyleEnum:h.SystemLinesEnum.SingleThin}getLineWidth(t,e,i){let s=t.getLineWidth(e);return e===h.SystemLinesEnum.DotsBoldBoldDots&&(s/=2),i&&e===h.SystemLinesEnum.BoldThinDots&&(s+=this.rules.DistanceBetweenLastInstructionAndRepetitionBarline),s}previousMeasureEndsLineRepetition(){if(0===this.measureListIndex)return!1;for(let t=0,e=this.measureList[this.measureListIndex-1].length;t=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length||!this.measureList[t])return!1;for(let e=0,i=this.measureList[t].length;e=n))break;e=s,n=s.multipleRestMeasureNumber}return e.endsWithLineRepetition()}}return!1}nextMeasureBeginsWordRepetition(){const t=this.measureListIndex+1;if(t>=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length||t>this.measureList.length-1)return!1;for(let e=0,i=this.measureList[t].length;ethis.rules.PageHeight-this.rules.PageBottomMargin&&(s++,s<=4&&console.log(`warning: could not fit a single system on page ${t.PageNumber} and measure number ${i.GraphicalMeasures[0][0].MeasureNumber}.\n The PageFormat may be too small for this sheet."\n Will not give further warnings for all pages, only total.`))}else{const s=this.musicSystems[n-1],r=s.StaffLines[s.StaffLines.length-1],o=r.PositionAndShape;let l=this.findRequiredDistanceWithSkyBottomLine(s,i);l+=this.rules.MinSkyBottomDistBetweenSystems,l=Math.max(l,this.rules.MinimumDistanceBetweenSystems+r.StaffHeight);const h=e+o.RelativePosition.y+l,c=h+i.PositionAndShape.BorderMarginBottom;if(this.rules.NewPageAtXMLNewPageAttribute&&s.breaksPage||!(c0&&console.log(`total amount of pages that couldn't fit a single music system: ${s} of ${t.PageNumber}`)}findRequiredDistanceWithSkyBottomLine(t,e){const i=t.StaffLines[t.StaffLines.length-1],s=e.StaffLines[0],n=i.BottomLine,r=s.SkyLine,o=i.PositionAndShape,a=s.PositionAndShape,l=1/this.rules.SamplingUnit;let h=0;for(let t=0;t=r.length)break;const s=Math.max(0,i-6),c=Math.min(r.length-1,i+6);let u=0;for(let t=s;t<=c;t++)u=Math.min(u,r[t]);const d=e-u;h=Math.max(d,h)}return 0===h&&(h=o.BorderBottom-a.BorderTop),h}};class m{constructor(){this.systemMeasures=[],this.systemMeasureIndex=0,this.currentWidth=0,this.currentSystemFixWidth=0,this.currentSystemVarWidth=0,this.maxLabelLength=0}IsSystemStartMeasure(){return 0===this.systemMeasureIndex}}e.SystemBuildParameters=m,e.MeasureBuildParameters=class{}},4574:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.OctaveShiftParams=void 0,e.OctaveShiftParams=class{constructor(t,e,i){this.getOpenOctaveShift=t,this.getAbsoluteStartTimestamp=e,this.getAbsoluteEndTimestamp=i}}},9059:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PlainSkyBottomLineBatchCalculatorBackend=void 0;const s=i(1378),n=i(9531);class r extends n.SkyBottomLineBatchCalculatorBackend{constructor(t,e){super(t,e)}getPreferredRenderingConfiguration(t,e){return{elementWidth:Math.ceil(t),numColumns:6,numRows:6}}onInitialize(t){}calculateFromCanvas(t,e,i,n,r){const o=t.width,a=e.getImageData(0,0,t.width,t.height),{elementWidth:l,elementHeight:h,numColumns:c}=r,u=[];for(let t=0;t0){g[t-f]=e-p;break}}S[t-f]=h;for(let e=b-1;e>=p;e--){const i=e*o*4+4*t;if(a.data[i+3]>0){S[t-f]=e-p;break}}}const y=Math.max(...g),E=Math.min(...S);for(let t=0;t{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SelectionEndSymbol=void 0;const s=i(4785),n=i(8155),r=i(9086),o=i(8911),a=i(6729),l=i(2337);class h extends s.GraphicalObject{constructor(t,e){super();const i=e,s=t.PositionAndShape.AbsolutePosition.y,h=l.CollectionUtil.last(t.StaffLines).PositionAndShape.RelativePosition.y+4;this.verticalLine=new a.GraphicalLine(new r.PointF2D(i,s),new r.PointF2D(i,s+h),.4,n.OutlineAndFillStyleEnum.SelectionSymbol);for(let e=0,n=t.StaffLines.length;e{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SelectionStartSymbol=void 0;const s=i(9086),n=i(8155),r=i(6729),o=i(4785),a=i(8911),l=i(2337);class h extends o.GraphicalObject{constructor(t,e){super();const i=e,o=t.PositionAndShape.AbsolutePosition.y,h=l.CollectionUtil.last(t.StaffLines).PositionAndShape.RelativePosition.y+4;this.verticalLine=new r.GraphicalLine(new s.PointF2D(i,o),new s.PointF2D(i,o+h),.4,n.OutlineAndFillStyleEnum.SelectionSymbol);for(let e=0,n=t.StaffLines.length;e{if(i.has(t))return i.get(t);{const e=[];return i.set(t,e),e}})().push({skyBottomLineCalculator:e.SkyBottomLineCalculator,measures:e.Measures})}this.batches=new Map;for(const[t,s]of i.entries()){const i=l.CollectionUtil.flat(s.map((t=>t.measures))),h=(()=>{if(e===n.SkyBottomLineBatchCalculatorBackendType.Plain)return new r.PlainSkyBottomLineBatchCalculatorBackend(t,i).initialize();try{return new o.WebGLSkyBottomLineBatchCalculatorBackend(t,i).initialize()}catch(e){return a.default.info("Couldn't create WebGLBackend for Skyline. Using fallback."),new r.PlainSkyBottomLineBatchCalculatorBackend(t,i).initialize()}})();h.initialize(),this.batches.set(t,{backend:h,entries:s})}}calculateLines(){for(const[,{backend:t,entries:e}]of this.batches){const i=t.calculateLines();let s=0;for(const{skyBottomLineCalculator:t,measures:n}of e){const e=s+n.length;t.updateLines(i.slice(s,e)),s=e}}}}},9531:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.SkyBottomLineBatchCalculatorBackend=void 0;const n=i(4028),r=s(i(2043));e.SkyBottomLineBatchCalculatorBackend=class{constructor(t,e){this.elementHeight=300,this.canvas=new n.CanvasVexFlowBackend(t),this.measures=e,this.maxWidth=Math.max(...this.measures.map((t=>{let e=t.getVFStave().getWidth();return e>0||t.IsExtraGraphicalMeasure||(r.default.warn("SkyBottomLineBatchCalculatorBackend: width not > 0 in measure "+t.MeasureNumber),e=50),e}))),this.samplingUnit=t.SamplingUnit}initialize(){if(this.tableConfiguration=Object.assign(Object.assign({},this.getPreferredRenderingConfiguration(this.maxWidth,this.elementHeight)),{elementHeight:this.elementHeight}),this.tableConfiguration.numRows<1||this.tableConfiguration.numColumns<1)throw r.default.warn("SkyBottomLineBatchCalculatorBackend: numRows or numColumns in tableConfiguration is 0"),new Error("numRows or numColumns in tableConfiguration is 0");this.tableConfiguration.elementWidth0||n.IsExtraGraphicalMeasure||(d=50),d=Math.floor(d),n.PositionAndShape.calculateAbsolutePositionsRecursive(0,0);const f=0;l.setX(f);const m=l.y+100;l.setY(m);const p=l.getWidth();l.setWidth(d),n.format(),l.setWidth(p);try{a.translate(h*i,u*s),n.draw(o),a.translate(-h*i,-u*s)}catch(t){r.default.warn("SkyBottomLineBatchCalculatorBackend.calculateLines.draw",t)}}const u=this.calculateFromCanvas(l,o,c,this.samplingUnit,this.tableConfiguration);h.push(...u)}return h}}},1378:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SkyBottomLineCalculationResult=void 0,e.SkyBottomLineCalculationResult=class{constructor(t,e){this.skyLine=t,this.bottomLine=e}}},6040:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.SkyBottomLineCalculator=void 0;i(9086);const n=i(5820),r=s(i(2043)),o=i(1378),a=i(4028);e.SkyBottomLineCalculator=class{constructor(t){this.mStaffLineParent=t,this.mRules=t.ParentMusicSystem.rules}updateLines(t){const e=this.StaffLineParent.Measures;if(t.length!==e.length)if(r.default.warn("SkyBottomLineCalculator: lengths of calculation result array and measure array do not match"),t.length(t-h)/n.unitInPixels+this.StaffLineParent.TopLineOffset));const c=Math.min(...this.mBottomLine);this.mBottomLine=this.mBottomLine.map((t=>(t-c)/n.unitInPixels+this.StaffLineParent.BottomLineOffset))}calculateLines(){const t=this.mRules.SamplingUnit,e=[],i=new a.CanvasVexFlowBackend(this.mRules);for(const s of this.StaffLineParent.Measures){s.PositionAndShape.calculateAbsolutePositionsRecursive(0,0);const n=s.getVFStave();let a=n.getWidth();a>0||s.IsExtraGraphicalMeasure||(r.default.warn("SkyBottomLineCalculator: width not > 0 in measure "+s.MeasureNumber),a=50),i.initializeHeadless(a);const l=i.getContext(),h=i.getCanvas();a=h.width;const c=h.height;n.setY(n.y+100);const u=n.getWidth();n.setWidth(a),s.format(),n.setWidth(u);try{s.draw(l)}catch(t){r.default.warn("SkyBottomLineCalculator.calculateLines.draw",t)}const d=l.getImageData(0,0,a,c),f=4,m=Math.max(Math.ceil(s.PositionAndShape.Size.width*t),1),p=new Array(m),b=new Array(m);for(let t=0;t0){p[t]=e;break}}for(let e=c;e>0;e--){const i=e*a*f+t*f;if(d.data[i+3]>0){b[t]=e;break}}}for(let t=0;t=this.BottomLine.length&&(i=this.BottomLine.length-1),s<0&&(s=0),s>=this.BottomLine.length&&(s=this.BottomLine.length),this.SkyLine[i]=t.y;for(let t=i+1;t=this.BottomLine.length&&(i=this.BottomLine.length-1),s<0&&(s=0),s>=this.BottomLine.length&&(s=this.BottomLine.length),this.BottomLine[i]=t.y;for(let t=i+1;tt))}setBottomLineWithValue(t){this.BottomLine.forEach((e=>t))}getLeftIndexForPointX(t,e){const i=Math.floor(t*this.SamplingUnit);return i<0?0:i>=e?e-1:i}getRightIndexForPointX(t,e){const i=Math.ceil(t*this.SamplingUnit);return i<0?0:i>=e?e-1:i}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((t=>!isNaN(t))))}getSkyLineMinAtPoint(t){const e=Math.round(t*this.SamplingUnit);return this.mSkyLine[e]}getSkyLineMinInRange(t,e){return this.getMinInRange(this.SkyLine,t,e)}getBottomLineMax(){return Math.max(...this.BottomLine.filter((t=>!isNaN(t))))}getBottomLineMaxAtPoint(t){const e=Math.round(t*this.SamplingUnit);return this.mBottomLine[e]}getBottomLineMaxInRange(t,e){return this.getMaxInRange(this.BottomLine,t,e)}getBottomLineMaxInBoundingBox(t){const e=Math.floor(t.AbsolutePosition.x+t.BorderLeft),i=Math.ceil(t.AbsolutePosition.x+t.BorderRight);return this.getMaxInRange(this.mBottomLine,e,i)}updateWithBoundingBoxRecursively(t){if(t.ChildElements&&t.ChildElements.length>0)this.updateWithBoundingBoxRecursively(t);else{const e=t.BorderTop+t.AbsolutePosition.y,i=t.BorderBottom+t.AbsolutePosition.y;if(e<0){const i=Math.floor(t.AbsolutePosition.x+t.BorderLeft),s=Math.ceil(t.AbsolutePosition.x+t.BorderRight);this.updateInRange(this.mSkyLine,i,s,e)}else if(i>this.StaffLineParent.StaffHeight){const e=Math.floor(t.AbsolutePosition.x+t.BorderLeft),s=Math.ceil(t.AbsolutePosition.x+t.BorderRight);this.updateInRange(this.mBottomLine,e,s,i)}}}findPreviousValidNumber(t,e){for(let i=t;i>=0;i--)if(!isNaN(e[i]))return e[i];return 0}findNextValidNumber(t,e){if(t>=e.length)return e[t-1];for(let i=t;it.length&&(i=t.length);for(let n=e;nMath.abs(t[n])?s:t[n]}setInRange(t,e=0,i=t.length,s=0){if(e=Math.floor(e*this.SamplingUnit),(i=Math.ceil(i*this.SamplingUnit))t.length&&(i=t.length);for(let n=e;n=t.length&&(e=t.length-1),i<0&&(i=0),i>=t.length&&(i=t.length),e>=0&&i<=t.length?Math.min(...t.slice(e,i+1)):void 0):Number.MAX_VALUE}getMaxInRange(t,e,i){return e=Math.floor(e*this.SamplingUnit),i=Math.ceil(i*this.SamplingUnit),t?(e<0&&(e=0),e>=t.length&&(e=t.length-1),i<0&&(i=0),i>=t.length&&(i=t.length),e>=0&&i<=t.length?Math.max(...t.slice(e,i+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}}},9953:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.StaffLine=void 0;const s=i(8911),n=i(4785),r=i(4196),o=i(9086),a=i(6040);class l extends n.GraphicalObject{constructor(t,e){super(),this.measures=[],this.staffLines=new Array(5),this.octaveShifts=[],this.lyricLines=[],this.lyricsDashes=[],this.abstractExpressions=[],this.graphicalSlurs=[],this.graphicalGlissandi=[],this.Pedals=[],this.parentMusicSystem=t,this.parentStaff=e,this.boundingBox=new s.BoundingBox(this,t.PositionAndShape),this.skyBottomLine=new a.SkyBottomLineCalculator(this),this.staffHeight=this.parentMusicSystem.rules.StaffHeight,this.topLineOffset=0,this.bottomLineOffset=4,this.calculateStaffLineOffsets()}calculateStaffLineOffsets(){if(this.ParentStaff.isTab)5===this.ParentStaff.StafflineCount?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(t){this.measures=t}get StaffLines(){return this.staffLines}set StaffLines(t){this.staffLines=t}get NextStaffLine(){const t=this.parentMusicSystem.StaffLines.indexOf(this);return t!==this.parentMusicSystem.StaffLines.length?this.parentMusicSystem.StaffLines[t+1]:void 0}get LyricLines(){return this.lyricLines}get AbstractExpressions(){return this.abstractExpressions}set AbstractExpressions(t){this.abstractExpressions=t}set LyricLines(t){this.lyricLines=t}get LyricsDashes(){return this.lyricsDashes}set LyricsDashes(t){this.lyricsDashes=t}get ParentMusicSystem(){return this.parentMusicSystem}set ParentMusicSystem(t){this.parentMusicSystem=t}get ParentStaff(){return this.parentStaff}set ParentStaff(t){this.parentStaff=t}get SkyBottomLineCalculator(){return this.skyBottomLine}get SkyLine(){return this.skyBottomLine.SkyLine}get BottomLine(){return this.skyBottomLine.BottomLine}get OctaveShifts(){return this.octaveShifts}set OctaveShifts(t){this.octaveShifts=t}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(t){this.graphicalSlurs.push(t)}addGlissandoToStaffline(t){this.graphicalGlissandi.push(t),t.StaffLine=this}addActivitySymbolClickArea(){const t=new r.StaffLineActivitySymbol(this),e=this.PositionAndShape;t.PositionAndShape.RelativePosition=new o.PointF2D(e.RelativePosition.x+e.BorderRight+.5,e.RelativePosition.y+.5),t.PositionAndShape.Parent=this.parentMusicSystem.PositionAndShape}isPartOfMultiStaffInstrument(){return this.parentStaff.ParentInstrument.Staves.length>1}findClosestStaffEntry(t){let e;for(let i=0,s=this.Measures.length;i{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.StaffLineActivitySymbol=void 0;const s=i(4785),n=i(8911);class r extends s.GraphicalObject{constructor(t){super(),this.parentStaffLine=t;const e=t.PositionAndShape;this.boundingBox=new n.BoundingBox(this,e),this.boundingBox.BorderRight=6,this.boundingBox.BorderBottom=4.5,this.boundingBox.BorderLeft=-1.5,this.boundingBox.BorderTop=-1.5}}e.StaffLineActivitySymbol=r},7771:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SystemLine=void 0;const s=i(6894),n=i(8911),r=i(4785);class o extends r.GraphicalObject{constructor(t,e,i,s,r){super(),this.lineType=t,this.linePosition=e,this.parentMusicSystem=i,this.topMeasure=s,this.bottomMeasure=r,this.parentTopStaffLine=null==s?void 0:s.ParentStaffLine,this.boundingBox=new n.BoundingBox(this,i.PositionAndShape)}static getObjectWidthForLineType(t,e){switch(e){case s.SystemLinesEnum.SingleThin:return t.SystemThinLineWidth;case s.SystemLinesEnum.DoubleThin:return 2*t.SystemThinLineWidth+t.DistanceBetweenVerticalSystemLines;case s.SystemLinesEnum.ThinBold:return t.SystemThinLineWidth+t.SystemBoldLineWidth+t.DistanceBetweenVerticalSystemLines;case s.SystemLinesEnum.BoldThinDots:case s.SystemLinesEnum.DotsThinBold:return t.SystemThinLineWidth+t.SystemBoldLineWidth+t.DistanceBetweenVerticalSystemLines+t.SystemDotWidth+t.DistanceBetweenDotAndLine;case s.SystemLinesEnum.DotsBoldBoldDots:return 2*t.SystemBoldLineWidth+2*t.SystemDotWidth+2*t.DistanceBetweenDotAndLine+t.DistanceBetweenVerticalSystemLines;default:return 0}}}e.SystemLine=o},1225:(t,e)=>{"use strict";var i;Object.defineProperty(e,"__esModule",{value:!0}),e.SystemLinePosition=void 0,(i=e.SystemLinePosition||(e.SystemLinePosition={}))[i.MeasureBegin=0]="MeasureBegin",i[i.MeasureEnd=1]="MeasureEnd"},6894:(t,e)=>{"use strict";var i;Object.defineProperty(e,"__esModule",{value:!0}),e.SystemLinesEnumHelper=e.SystemLinesEnum=void 0,function(t){t[t.SingleThin=0]="SingleThin",t[t.DoubleThin=1]="DoubleThin",t[t.ThinBold=2]="ThinBold",t[t.BoldThinDots=3]="BoldThinDots",t[t.DotsThinBold=4]="DotsThinBold",t[t.DotsBoldBoldDots=5]="DotsBoldBoldDots",t[t.None=6]="None",t[t.Dotted=7]="Dotted",t[t.Dashed=8]="Dashed",t[t.Bold=9]="Bold",t[t.BoldThin=10]="BoldThin",t[t.DoubleBold=11]="DoubleBold",t[t.Tick=12]="Tick",t[t.Short=13]="Short"}(i=e.SystemLinesEnum||(e.SystemLinesEnum={})),e.SystemLinesEnumHelper=class{static xmlBarlineStyleToSystemLinesEnum(t){return"regular"===t?i.SingleThin:"dotted"===t?i.Dotted:"dashed"===t?i.Dashed:"heavy"===t?i.Bold:"light-light"===t?i.DoubleThin:"light-heavy"===t?i.ThinBold:"heavy-light"===t?i.BoldThin:"heavy-heavy"===t?i.DoubleBold:"tick"===t?i.Tick:"short"===t?i.Short:"none"===t?i.None:i.SingleThin}}},525:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.VerticalGraphicalStaffEntryContainer=void 0,e.VerticalGraphicalStaffEntryContainer=class{constructor(t,e){this.staffEntries=[],this.absoluteTimestamp=e,this.staffEntries=new Array(t)}get Index(){return this.index}set Index(t){this.index=t}get AbsoluteTimestamp(){return this.absoluteTimestamp}get StaffEntries(){return this.staffEntries}set StaffEntries(t){this.staffEntries=t}static compareByTimestamp(t,e){const i=t.absoluteTimestamp.RealValue,s=e.absoluteTimestamp.RealValue;return is?1:0}getFirstNonNullStaffEntry(){for(let t=0,e=this.staffEntries.length;t{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AlignmentManager=void 0;const s=i(9344),n=i(9086);e.AlignmentManager=class{constructor(t){this.parentStaffline=t,this.rules=this.parentStaffline.ParentMusicSystem.rules}alignDynamicExpressions(){var t,e;const i=[];let n=new Array;for(let s=0;s0){const e=t.map((t=>t.PositionAndShape.Center.y)),i=Math.max(...e);for(let n=0;n0?t[n-1]:void 0;if(e){const t=this.getOverlap(r.PositionAndShape,e.PositionAndShape);r.squeeze(-(t.x+this.rules.DynamicExpressionSpacer))}if(i){const t=this.getOverlap(i.PositionAndShape,r.PositionAndShape);r.squeeze(t.x+this.rules.DynamicExpressionSpacer)}}}}}getDistance(t,e){const i=t.RelativePosition.x+t.BorderMarginRight,s=e.RelativePosition.x+e.BorderMarginLeft,r=t.RelativePosition.y+t.BorderMarginBottom,o=e.RelativePosition.y+e.BorderMarginTop;return new n.PointF2D(s-i,o-r)}getOverlap(t,e){return new n.PointF2D(t.RelativePosition.x+t.BorderMarginRight-(e.RelativePosition.x+e.BorderMarginLeft),t.RelativePosition.y+t.BorderMarginBottom-(e.RelativePosition.y+e.BorderMarginTop))}}},4028:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.CanvasVexFlowBackend=void 0;var n=s(i(6368)).default.Flow;const r=i(709),o=i(8129),a=i(41),l=i(599);class h extends r.VexFlowBackend{constructor(t){super(),this.rules=t}getVexflowBackendType(){return n.Renderer.Backends.CANVAS}getOSMDBackendType(){return a.BackendType.Canvas}getCanvasSize(){var t;return null===(t=document.getElementById("osmdCanvasPage"+this.graphicalMusicPage.PageNumber))||void 0===t?void 0:t.offsetHeight}initialize(t,e){this.zoom=e,this.canvas=document.createElement("canvas"),this.graphicalMusicPage||(this.graphicalMusicPage=new l.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 n.Renderer(this.canvas,this.getVexflowBackendType()),this.ctx=this.renderer.getContext()}initializeHeadless(t=300,e=300){this.graphicalMusicPage||(this.graphicalMusicPage=new l.GraphicalMusicPage(void 0),this.graphicalMusicPage.PageNumber=1),this.canvas=document.createElement("canvas"),this.canvas.width=t,this.canvas.height=e,this.renderer=new n.Renderer(this.canvas,this.getVexflowBackendType()),this.ctx=this.renderer.getContext()}getContext(){return this.ctx}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,e){this.CanvasRenderingCtx.translate(t,e)}renderText(t,e,i,s,n,r,a,l){const h=this.CanvasRenderingCtx.font;this.CanvasRenderingCtx.save(),this.CanvasRenderingCtx.font=o.VexFlowConverter.font(t,e,i,this.rules,l),this.CanvasRenderingCtx.fillStyle=a,this.CanvasRenderingCtx.strokeStyle=a,this.CanvasRenderingCtx.fillText(s,r.x,r.y+n),this.CanvasRenderingCtx.restore(),this.CanvasRenderingCtx.font=h}renderRectangle(t,e,i,s=1){const n=this.CanvasRenderingCtx.fillStyle;this.CanvasRenderingCtx.fillStyle=i||o.VexFlowConverter.style(e),this.CanvasRenderingCtx.globalAlpha=s,this.ctx.fillRect(t.x,t.y,t.width,t.height),this.CanvasRenderingCtx.fillStyle=n,this.CanvasRenderingCtx.globalAlpha=1}renderLine(t,e,i="#FF0000FF",s=2){const n=this.CanvasRenderingCtx.strokeStyle;this.CanvasRenderingCtx.strokeStyle=i,this.CanvasRenderingCtx.beginPath(),this.CanvasRenderingCtx.moveTo(t.x,t.y),this.CanvasRenderingCtx.lineTo(e.x,e.y),this.CanvasRenderingCtx.stroke(),this.CanvasRenderingCtx.strokeStyle=n}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()}get CanvasRenderingCtx(){return this.ctx.vexFlowCanvasContext}}e.CanvasVexFlowBackend=h},9505:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.SvgVexFlowBackend=void 0;var n=s(i(6368)).default.Flow;const r=i(709),o=i(8129),a=i(2562),l=i(41),h=s(i(2043));class c extends r.VexFlowBackend{constructor(t){super(),this.rules=t}getVexflowBackendType(){return n.Renderer.Backends.SVG}getOSMDBackendType(){return l.BackendType.SVG}getCanvasSize(){var t;return null===(t=document.getElementById("osmdCanvasPage"+this.graphicalMusicPage.PageNumber))||void 0===t?void 0:t.offsetHeight}initialize(t,e){this.zoom=e,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",t.appendChild(this.inner),this.renderer=new n.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(t){var e;const i=null===(e=this.ctx)||void 0===e?void 0:e.svg;if(!i)return!1;try{i.removeChild(t)}catch(t){return h.default.error(t),!1}return!0}clear(){if(!this.ctx)return;const t=this.ctx.svg;for(;t.lastChild;)t.removeChild(t.lastChild);this.rules.PageBackgroundColor&&(this.ctx.svg.style["background-color"]=this.rules.PageBackgroundColor)}scale(t){this.ctx.scale(t,t)}translate(t,e){}renderText(t,e,i,s,n,r,l,h){this.ctx.save();const c=this.ctx.openGroup("text");l&&(this.ctx.attributes.fill=l,this.ctx.attributes.stroke=l);let u=h;h&&"default"!==h||(u=this.rules.DefaultFontFamily),this.ctx.setFont(u,t,o.VexFlowConverter.fontStyle(e)),this.ctx.attributes["font-size"]=`${t}px`,this.ctx.state["font-size"]=`${t}px`;let d="normal",f="normal";switch(e){case a.FontStyles.Bold:d="bold";break;case a.FontStyles.Italic:f="italic";break;case a.FontStyles.BoldItalic:d="bold",f="italic";break;default:d="normal"}return this.ctx.attributes["font-weight"]=d,this.ctx.state["font-weight"]=d,this.ctx.attributes["font-style"]=f,this.ctx.state["font-style"]=f,this.ctx.fillText(s,r.x,r.y+n),this.ctx.closeGroup(),this.ctx.restore(),c}renderRectangle(t,e,i,s=1){this.ctx.save();const n=this.ctx.openGroup("rect");return this.ctx.attributes.fill=i||o.VexFlowConverter.style(e),this.ctx.attributes["fill-opacity"]=s,this.ctx.fillRect(t.x,t.y,t.width,t.height),this.ctx.restore(),this.ctx.attributes["fill-opacity"]=1,this.ctx.closeGroup(),n}renderLine(t,e,i="#FF0000FF",s=2){this.ctx.save();const n=this.ctx.openGroup("line");return this.ctx.beginPath(),this.ctx.moveTo(t.x,t.y),this.ctx.lineTo(e.x,e.y),this.ctx.attributes.stroke=i,this.ctx.lineWidth=s,this.ctx.stroke(),this.ctx.closeGroup(),this.ctx.restore(),n}renderCurve(t){const e=this.ctx.openGroup("curve");return 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(),this.ctx.closeGroup(),e}export(){const t=this.ctx.svg.cloneNode(!0),e=document.implementation.createDocumentType("svg","-//W3C//DTD SVG 1.1//EN","http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"),i=document.implementation.createDocument("http://www.w3.org/2000/svg","svg",e);i.replaceChild(t,i.documentElement);const s=(new XMLSerializer).serializeToString(i),n=document.createElement("a");n.href="data:image/svg+xml; charset=utf8, "+encodeURIComponent(s.replace(/>\n\r<")),n.download="opensheetmusicdisplay_download.svg",n.innerHTML=window.location.href+"/download",document.body.appendChild(n)}}e.SvgVexFlowBackend=c},709:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowBackend=e.VexFlowBackends=void 0;var n=s(i(6368)).default.Flow;e.VexFlowBackends=class{},e.VexFlowBackend=class{getInnerElement(){return this.inner}getCanvas(){return this.canvas}getRenderElement(){let t=this.canvas;return this.getVexflowBackendType()===n.Renderer.Backends.CANVAS&&(t=this.inner),t}getRenderer(){return this.renderer}removeAllChildrenFromContainer(t){for(;0!==t.children.length;)t.removeChild(t.children.item(0))}removeFromContainer(t){const e=this.getRenderElement();for(let i=0;i{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowContinuousDynamicExpression=void 0;const s=i(374),n=i(9946),r=i(2255),o=i(1274),a=i(2562);class l extends s.GraphicalContinuousDynamicExpression{constructor(t,e,i,s){if(super(t,e,i),this.IsVerbal){const e=new r.Label(t.Label);this.label=new n.GraphicalLabel(e,s||this.rules.ContinuousDynamicTextHeight,o.TextAlignmentEnum.LeftCenter,this.rules,this.PositionAndShape),this.label.Label.fontStyle=a.FontStyles.Italic,this.label.setLabelPositionAndShapeBorders(),this.PositionAndShape.calculateBoundingBox()}}}e.VexFlowContinuousDynamicExpression=l},8129:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowConverter=void 0;var n=s(i(6368)).default.Flow;const r=i(289),o=i(8640),a=i(1797),l=i(3331),h=i(5198),c=i(8640),u=i(8640),d=i(6894),f=i(2562),m=i(96),p=i(8155),b=s(i(2043)),g=i(908),S=i(1225),y=i(5922),E=i(766),v=i(5820),x=i(3029),_=i(3748);class M{static durations(t,e){const i=[],s=t.clone();for(;s.RealValue>0;){const t=s.RealValue;if(t>=2)i.push("1/2"),s.Sub(new a.Fraction(2,1));else if(t>=1)i.push("w"),s.Sub(new a.Fraction(1,1));else if(t<1&&t>=.5){if(e&&t>.5)return["w"];i.push("h"),s.Sub(new a.Fraction(1,2))}else if(t<.5&&t>=.25){if(e&&t>.25)return["h"];i.push("q"),s.Sub(new a.Fraction(1,4))}else if(t<.25&&t>=.125){if(e&&t>.125)return["q"];i.push("8"),s.Sub(new a.Fraction(1,8))}else if(t<.125&&t>=.0625){if(e&&t>.0625)return["8"];i.push("16"),s.Sub(new a.Fraction(1,16))}else if(t<.0625&&t>=.03125){if(e&&t>.03125)return["16"];i.push("32"),s.Sub(new a.Fraction(1,32))}else if(t<.03125&&t>=.015625){if(e&&t>.015625)return["32"];i.push("64"),s.Sub(new a.Fraction(1,64))}else{if(e)return["64"];i.push("128"),s.Sub(new a.Fraction(1,128))}}return i}static pitch(t,e,i,s,n){let a=n;void 0===n&&(a=3),e&&void 0===n&&(a=0,i.ClefType===r.ClefEnum.F&&(a=2),i.ClefType===r.ClefEnum.C&&(a=2));const l=u.NoteEnum[t.FundamentalNote].toLowerCase(),h=o.Pitch.accidentalVexflow(t.Accidental),c=t.Octave-i.OctaveOffset+a;let d="";return s&&(d=this.NoteHeadCode(s)),[l+"n/"+c+d,h,i]}static restToNotePitch(t,e){let i=t.Octave;switch(e){case r.ClefEnum.C:case r.ClefEnum.F:i+=2;case r.ClefEnum.G:}return new o.Pitch(t.FundamentalNote,i,c.AccidentalEnum.NONE)}static NoteHeadCode(t){const e=t.Filled?"2":"1";switch(t.Shape){case E.NoteHeadShape.NORMAL:return"";case E.NoteHeadShape.DIAMOND:return"/D"+e;case E.NoteHeadShape.TRIANGLE:return"/T"+e;case E.NoteHeadShape.X:return"/X"+e;case E.NoteHeadShape.CIRCLEX:return"/X3";case E.NoteHeadShape.RECTANGLE:return"/R"+e;case E.NoteHeadShape.SQUARE:return"/S"+e;case E.NoteHeadShape.SLASH:default:return""}}static GhostNotes(t){const e=[],i=M.durations(t,!1);for(const t of i)e.push(new n.GhostNote({duration:t}));return e}static StaveNote(t){var e,i,s,a,l,h,c,u,d,f;t.sortForVexflow();const m=t.notes,p=t.parentStaffEntry.parentMeasure.parentSourceMeasure.Rules,b=m[0];let S=[];const y=[],x=b.graphicalNoteLength,_=void 0!==b.sourceNote.NoteTuplet;let w,P=M.durations(x,_)[0];void 0!==b.sourceNote.TypeLength&&b.sourceNote.TypeLength!==x&&0!==b.sourceNote.TypeLength.RealValue&&(P=M.durations(b.sourceNote.TypeLength,_)[0],b.numberOfDots=b.sourceNote.DotsXml);let T,L,A=b.numberOfDots,C=!1,I=0,R=!1;for(const t of m){if(A=1&&e.length-1>=d+1&&(r=null===(l=null===(a=e[d-1])||void 0===a?void 0:a.graphicalVoiceEntries[0])||void 0===l?void 0:l.parentVoiceEntry,o=null===(c=null===(h=e[d+1])||void 0===h?void 0:h.graphicalVoiceEntries[0])||void 0===c?void 0:c.parentVoiceEntry,r&&o)){const e=r.Notes[0],i=o.Notes[0];if(null===(u=e.NoteBeam)||void 0===u?void 0:u.Notes.includes(i)){const e=r.Notes.last().Pitch,i=t.Clef();S=[M.pitch(M.restToNotePitch(e.getTransposedPitch(-2),i.ClefType),!1,i)[0]]}}}}if((t.sourceNote.IsWholeMeasureRest||x.RealValue===t.sourceNote.SourceMeasure.ActiveTimeSignature.RealValue)&&(S=["d/5"],P="w",A=0,C=!0,I=p.WholeRestXShiftVexflow*v.unitInPixels),t.sourceNote.ParentStaff.Voices.length>1){const e=t.parentVoiceEntry.parentStaffEntry.graphicalVoiceEntries,i=t.parentVoiceEntry.parentVoiceEntry.ParentVoice.VoiceId;let s,n;for(const r of e)for(const e of r.notes){if(e===t||e.sourceNote.isRest()||!e.sourceNote.PrintObject)continue;const r=e.parentVoiceEntry.parentVoiceEntry.WantedStemDirection,o=1===i||5===i,a=o?1:-1,l=e.sourceNote.Pitch.getHalfTone(),h=1===a&&l>s,c=-1===a&&l0){let e=3;const i=t.Clef();switch(i.ClefType){case r.ClefEnum.F:e=5;break;case r.ClefEnum.C:e=4}T=o.Pitch.fromHalftone(s),S=[M.pitch(T,!0,i,void 0,e)[0]]}}break}const n=t.vfpitch;S.push(n[0]),y.push(n[1]),w||(w=M.Clef(n[2]).type)}for(let t=0,e=A;t1)for(let t=0;tt.notes[i].staffLine=e)),(p.LedgerLineWidth||p.LedgerLineStrokeStyle)&&(L.ledgerLineStyle||(L.ledgerLineStyle={}),p.LedgerLineWidth&&(L.ledgerLineStyle.lineWidth=p.LedgerLineWidth),p.LedgerLineStrokeStyle&&(L.ledgerLineStyle.strokeStyle=p.LedgerLineStrokeStyle)),p.ColoringEnabled){const e=p.DefaultColorStem;let i=t.parentVoiceEntry.StemColor;!i&&e&&(i=e);const s={fillStyle:i,strokeStyle:i};i&&(L.setStemStyle(s),L.flag&&p.ColorFlags&&L.setFlagStyle(s))}if(L.x_shift=I,t.parentVoiceEntry.IsGrace&&t.notes[0].sourceNote.NoteBeam&&(t.parentVoiceEntry.WantedStemDirection=t.notes[0].sourceNote.NoteBeam.Notes[0].ParentVoiceEntry.WantedStemDirection),t.parentVoiceEntry)switch(t.parentVoiceEntry.WantedStemDirection){case g.StemDirectionType.Up:L.setStemDirection(n.Stem.UP),t.parentVoiceEntry.StemDirection=g.StemDirectionType.Up;break;case g.StemDirectionType.Down:L.setStemDirection(n.Stem.DOWN),t.parentVoiceEntry.StemDirection=g.StemDirectionType.Down}for(let t=0,e=m.length;t0){const i=new n.Tremolo(e);i.extra_stroke_scale=p.TremoloStrokeScale,i.y_spacing_scale=p.TremoloYSpacingScale,L.addModifier(t,i)}}if(.25===B.Length.RealValue&&B.Notehead&&!1===B.Notehead.Filled){const t=L.getKeyProps();for(let e=0;e");const t=e.sourceNote.NoteSlurs;for(const s of t)s.StartNote===e.sourceNote&&(s.PlacementXml===_.PlacementEnum.Above?r.setYShift(10*-i.SlurStartArticulationYOffsetOfArticulation):s.PlacementXml===_.PlacementEnum.Below&&r.setYShift(10*i.SlurStartArticulationYOffsetOfArticulation));break}case g.ArticulationEnum.breathmark:r=new n.Articulation("abr"),s.placement===_.PlacementEnum.Above&&(o=n.Modifier.Position.ABOVE),r.breathMarkDistance=i.BreathMarkDistance;break;case g.ArticulationEnum.downbow:r=new n.Articulation("am"),void 0===s.placement&&(o=n.Modifier.Position.ABOVE,s.placement=_.PlacementEnum.Above);break;case g.ArticulationEnum.fermata:r=new n.Articulation("a@a"),o=n.Modifier.Position.ABOVE,s.placement=_.PlacementEnum.Above;break;case g.ArticulationEnum.marcatodown:r=new n.Articulation("a|");break;case g.ArticulationEnum.marcatoup:r=new n.Articulation("a^"),o=n.Modifier.Position.ABOVE;break;case g.ArticulationEnum.invertedfermata:{const t=e.sourceNote.ParentVoiceEntry;if(t!==e.sourceNote.ParentVoiceEntry.ParentSourceStaffEntry.VoiceEntries.last()){t.Articulations=t.Articulations.slice(t.Articulations.indexOf(s)),t.ParentSourceStaffEntry.VoiceEntries.last().Articulations.push(s);continue}r=new n.Articulation("a@u"),o=n.Modifier.Position.BELOW,s.placement=_.PlacementEnum.Below;break}case g.ArticulationEnum.lefthandpizzicato:r=new n.Articulation("a+");break;case g.ArticulationEnum.naturalharmonic:r=new n.Articulation("ah");break;case g.ArticulationEnum.snappizzicato:r=new n.Articulation("ao");break;case g.ArticulationEnum.staccatissimo:r=new n.Articulation("av");break;case g.ArticulationEnum.staccato:r=new n.Articulation("a.");break;case g.ArticulationEnum.tenuto:r=new n.Articulation("a-");break;case g.ArticulationEnum.upbow:r=new n.Articulation("a|"),void 0===s.placement&&(o=n.Modifier.Position.ABOVE,s.placement=_.PlacementEnum.Above);break;case g.ArticulationEnum.strongaccent:r=new n.Articulation("a^")}r&&(r.setPosition(o),t.addModifier(0,r))}}static generateOrnaments(t,e){let i,s=n.Modifier.Position.ABOVE;switch(e.placement===_.PlacementEnum.Below&&(s=n.Modifier.Position.BELOW),e.GetOrnament){case y.OrnamentEnum.DelayedInvertedTurn:i=new n.Ornament("turn_inverted"),i.setDelayed(!0);break;case y.OrnamentEnum.DelayedTurn:i=new n.Ornament("turn"),i.setDelayed(!0);break;case y.OrnamentEnum.InvertedMordent:i=new n.Ornament("mordent"),i.setDelayed(!1);break;case y.OrnamentEnum.InvertedTurn:i=new n.Ornament("turn_inverted"),i.setDelayed(!1);break;case y.OrnamentEnum.Mordent:i=new n.Ornament("mordent_inverted"),i.setDelayed(!1);break;case y.OrnamentEnum.Trill:i=new n.Ornament("tr"),i.setDelayed(!1);break;case y.OrnamentEnum.Turn:i=new n.Ornament("turn"),i.setDelayed(!1);break;default:return void b.default.warn("unhandled OrnamentEnum type: "+e.GetOrnament)}i&&(e.AccidentalBelow!==c.AccidentalEnum.NONE&&i.setLowerAccidental(o.Pitch.accidentalVexflow(e.AccidentalBelow)),e.AccidentalAbove!==c.AccidentalEnum.NONE&&i.setUpperAccidental(o.Pitch.accidentalVexflow(e.AccidentalAbove)),i.setPosition(s),t.addModifier(0,i))}static StrokeTypeFromArpeggioType(t){switch(t){case x.ArpeggioType.ARPEGGIO_DIRECTIONLESS:return n.Stroke.Type.ARPEGGIO_DIRECTIONLESS;case x.ArpeggioType.BRUSH_DOWN:return n.Stroke.Type.BRUSH_UP;case x.ArpeggioType.BRUSH_UP:return n.Stroke.Type.BRUSH_DOWN;case x.ArpeggioType.RASQUEDO_DOWN:return n.Stroke.Type.RASQUEDO_UP;case x.ArpeggioType.RASQUEDO_UP:return n.Stroke.Type.RASQUEDO_DOWN;case x.ArpeggioType.ROLL_DOWN:return n.Stroke.Type.ROLL_UP;case x.ArpeggioType.ROLL_UP:return n.Stroke.Type.ROLL_DOWN;default:return n.Stroke.Type.ARPEGGIO_DIRECTIONLESS}}static CreateTabNote(t){const e=[],i=t.notes.reverse(),s=[],r=t.notes[0].graphicalNoteLength,o=void 0!==t.notes[0].sourceNote.NoteTuplet;let a=M.durations(r,o)[0],l=0,h=!1;for(const i of t.notes){const t=i.sourceNote,r={str:t.StringNumberTab,fret:t.FretNumber};e.push(r),t.BendArray&&t.BendArray.forEach((function(t){let e;const i=t.bendalter-r.fret;e=i>1?"Full":1===i?"1/2":"1/4","up"===t.direction?s.push({type:n.Bend.UP,text:e,width:10}):s.push({type:n.Bend.DOWN,text:e,width:10})})),t.VibratoStroke&&(h=!0),l{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowGlissando=void 0;const s=i(1443);class n extends s.GraphicalGlissando{}e.VexFlowGlissando=n},4679:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowGraphicalNote=void 0;const s=i(3486),n=i(8129),r=i(5853);class o extends s.GraphicalNote{constructor(t,e,i,s=r.OctaveEnum.NONE,o,a){if(super(t,e,o,a),this.clef=i,this.octaveShift=s,t.Pitch){const e=t.isRest()?t.Pitch:r.OctaveShift.getPitchFromOctaveShift(t.Pitch,s);this.vfpitch=n.VexFlowConverter.pitch(e,t.isRest(),this.clef,this.sourceNote.Notehead),this.vfpitch[1]=void 0}}setAccidental(t){const e=this.drawPitch(t);this.vfpitch=n.VexFlowConverter.pitch(e,this.sourceNote.isRest(),this.clef,this.sourceNote.Notehead),this.DrawnAccidental=e.Accidental}drawPitch(t){return r.OctaveShift.getPitchFromOctaveShift(t,this.octaveShift)}Transpose(t,e,i,s){const o=super.Transpose(t,e,i,s),a=r.OctaveShift.getPitchFromOctaveShift(o,this.octaveShift);return this.vfpitch=n.VexFlowConverter.pitch(a,this.sourceNote.isRest(),this.clef,this.sourceNote.Notehead),this.vfpitch[1]=void 0,a}setIndex(t,e){this.vfnote=[t,e],this.vfnoteIndex=e}notehead(t){let e=t;e||(e=this.vfnote[0]);const i=e.note_heads;return i&&i.length>this.vfnoteIndex&&i[this.vfnoteIndex]?e.note_heads[this.vfnoteIndex]:{line:0}}Clef(){return this.clef}getSVGId(){if(this.vfnote)return this.vfnote[0].getAttribute("id")}getSVGGElement(){if(this.vfnote)return this.vfnote[0].getAttribute("el")}getStemSVG(){return document.getElementById("vf-"+this.getSVGId()+"-stem")}getBeamSVGs(){const t=[];for(let e=0;;e++){const i=document.getElementById(`vf-${this.getSVGId()}-beam${e}`);if(!i)break;t.push(i)}return t}}e.VexFlowGraphicalNote=o},8144:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowGraphicalSymbolFactory=void 0;var n=s(i(6368)).default.Flow;const r=i(8494),o=i(7330),a=i(9252),l=i(5853),h=i(4679),c=i(4146),u=i(5460),d=i(8129),f=i(8790),m=i(4828),p=i(4405);e.VexFlowGraphicalSymbolFactory=class{createMusicSystem(t,e){return new r.VexFlowMusicSystem(t,e)}createStaffLine(t,e){return new m.VexFlowStaffLine(t,e)}createGraphicalMeasure(t,e,i=!1){return new o.VexFlowMeasure(e,t,void 0)}createMultiRestMeasure(t,e,i){return new p.VexFlowMultiRestMeasure(e,t,i)}createTabStaffMeasure(t,e){return new f.VexFlowTabMeasure(e,t)}createExtraGraphicalMeasure(t){const e=new o.VexFlowMeasure(t.ParentStaff,void 0,t);return e.IsExtraGraphicalMeasure=!0,e.ExtraGraphicalMeasurePreviousMeasure=t.Measures.last(),e}createStaffEntry(t,e){return new a.VexFlowStaffEntry(e,t,void 0)}createVoiceEntry(t,e){return new u.VexFlowVoiceEntry(t,e)}createNote(t,e,i,s=l.OctaveEnum.NONE,n,r){return new h.VexFlowGraphicalNote(t,e,i,s,n,r)}createGraceNote(t,e,i,s,n=l.OctaveEnum.NONE){return new h.VexFlowGraphicalNote(t,e,i,n,s)}addGraphicalAccidental(t,e){t.setAccidental(e)}addFermataAtTiedEndNote(t,e){}createInStaffClef(t,e){const i=t,s=d.VexFlowConverter.Clef(e,"small");i.vfClefBefore=new n.ClefNote(s.type,s.size,s.annotation)}createChordSymbols(t,e,i,s){const n=e.parentMeasure.parentSourceMeasure.Rules;let r=0;const o=n.ChordSymbolXSpacing;for(const a of t.ChordContainers){const t=new c.GraphicalChordSymbolContainer(a,e.PositionAndShape,n.ChordSymbolTextHeight,i,s,e.parentMeasure.parentSourceMeasure.Rules),l=t.GraphicalLabel;l.PositionAndShape.RelativePosition.y-=n.ChordSymbolYOffset,l.PositionAndShape.RelativePosition.x+=r,l.setLabelPositionAndShapeBorders(),t.PositionAndShape.calculateBoundingBox(),e.graphicalChordContainers.push(t),r+=l.PositionAndShape.Size.width+o}}createGraphicalTechnicalInstruction(t,e){}}},6351:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowInstantaneousDynamicExpression=void 0;const s=i(9428),n=i(9793),r=i(9946),o=i(2255),a=i(1274),l=i(2562);class h extends s.GraphicalInstantaneousDynamicExpression{constructor(t,e,i){super(t,e,i);const s=new o.Label(this.Expression);this.label=new r.GraphicalLabel(s,this.rules.ContinuousDynamicTextHeight,a.TextAlignmentEnum.CenterCenter,this.rules,this.PositionAndShape),this.label.Label.fontStyle=l.FontStyles.BoldItalic,this.label.setLabelPositionAndShapeBorders(),this.PositionAndShape.calculateBoundingBox()}get InstantaneousDynamic(){return this.mInstantaneousDynamicExpression}get Expression(){return n.DynamicEnum[this.mInstantaneousDynamicExpression.DynEnum]}}e.VexFlowInstantaneousDynamicExpression=h},8939:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowInstrumentBrace=void 0;var n=s(i(6368)).default.Flow;const r=i(5575);class o extends r.VexFlowInstrumentBracket{constructor(t,e,i=0){super(t,e,i),this.vexflowConnector.setType(n.StaveConnector.type.BRACE)}}e.VexFlowInstrumentBrace=o},5575:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowInstrumentBracket=void 0;var n=s(i(6368)).default.Flow;const r=i(4785),o=i(8911),a=i(5820);class l extends r.GraphicalObject{constructor(t,e,i=0){super(),this.Visible=!0,this.PositionAndShape=new o.BoundingBox(this,t.ParentMusicSystem.PositionAndShape);const s=t.Measures[0],r=e.Measures[0];this.addConnector(s.getVFStave(),r.getVFStave(),n.StaveConnector.type.BRACKET,i)}draw(t){this.Visible&&this.vexflowConnector.setContext(t).draw();const e=this.vexflowConnector,i=e.top_stave.getYForLine(0),s=e.bottom_stave.getYForLine(e.bottom_stave.getNumLines()-1)+e.thickness;this.PositionAndShape.AbsolutePosition.x=(e.top_stave.getX()-2+e.x_shift)/a.unitInPixels,this.PositionAndShape.AbsolutePosition.y=i/a.unitInPixels,this.PositionAndShape.Size.height=(s-i)/a.unitInPixels,this.PositionAndShape.Size.width=12/a.unitInPixels}addConnector(t,e,i,s){this.vexflowConnector=new n.StaveConnector(t,e).setType(i).setXShift(-5*s)}}e.VexFlowInstrumentBracket=l},7330:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.StavePositionEnum=e.VexFlowMeasure=void 0;var n=s(i(6368)).default.Flow;const r=i(1513),o=i(6894),a=i(289),l=i(8129);var h=n.NoteSubGroup;const c=s(i(2043)),u=i(5820),d=i(6189),f=i(1225),m=i(908),p=i(5460),b=i(1797),g=i(1405),S=i(3748),y=i(2478);class E extends r.GraphicalMeasure{constructor(t,e,i){super(t,e,i),this.isTabMeasure=!1,this.octaveOffset=3,this.vfVoices={},this.vfTies=[],this.vfRepetitionWords=[],this.connectors=[],this.beams={},this.autoVfBeams=[],this.autoTupletVfBeams=[],this.vfbeams={},this.tuplets={},this.vftuplets={},this.minimumStaffEntriesWidth=-1,this.rules=i?i.ParentMusicSystem.rules:e?e.Rules:new g.EngravingRules,this.resetLayout()}setAbsoluteCoordinates(t,e){this.stave.setX(t).setY(e)}resetLayout(){this.stave=new n.Stave(0,0,0,{fill_style:this.rules.StaffLineColor,space_above_staff_ln:0,space_below_staff_ln:0}),this.stave.MeasureNumber=this.MeasureNumber,this.ParentStaff&&this.setLineNumber(this.ParentStaff.StafflineCount),this.stave.setBegBarType(n.Barline.type.NONE),this.parentSourceMeasure&&this.parentSourceMeasure.endingBarStyleEnum===o.SystemLinesEnum.None&&this.stave.setEndBarType(n.Barline.type.NONE),this.updateInstructionWidth()}clean(){this.vfTies.length=0,this.connectors=[],this.resetLayout()}getLineWidth(t){switch(t){case o.SystemLinesEnum.BoldThinDots:case o.SystemLinesEnum.DotsThinBold:return 10/u.unitInPixels;case o.SystemLinesEnum.DotsBoldBoldDots:return 10/u.unitInPixels+this.rules.RepeatEndStartPadding;default:return 0}}addClefAtBegin(t){if(this.rules.RenderClefsAtBeginningOfStaffline){if(this.octaveOffset=t.OctaveOffset,t.ClefType===a.ClefEnum.TAB)this.stave.addClef("tab",void 0,void 0,void 0);else{const e=l.VexFlowConverter.Clef(t,"default");this.stave.addClef(e.type,e.size,e.annotation,n.StaveModifier.Position.BEGIN)}this.updateInstructionWidth()}}setLineNumber(t){5!==t&&(0===t?(this.stave.setNumLines(0),this.stave.getBottomLineY=function(){return this.getYForLine(this.options.num_lines)}):1===t?(this.stave.options.line_config=[{visible:!1},{visible:!1},{visible:!0},{visible:!1},{visible:!1}],this.stave.getBottomLineY=function(){return this.getYForLine(2)}):2===t?(this.stave.options.line_config=[{visible:!1},{visible:!1},{visible:!0},{visible:!0},{visible:!1}],this.stave.getBottomLineY=function(){return this.getYForLine(3)}):3===t?(this.stave.options.line_config=[{visible:!1},{visible:!0},{visible:!0},{visible:!0},{visible:!1}],this.stave.getBottomLineY=function(){return this.getYForLine(2)}):(this.stave.setNumLines(t),this.stave.getBottomLineY=function(){return this.getYForLine(this.options.num_lines)}))}addKeyAtBegin(t,e,i){var s;this.rules.RenderKeySignatures&&this.ShowKeySignature&&((null===(s=this.parentSourceMeasure)||void 0===s?void 0:s.isReducedToMultiRest)&&!this.rules.MultipleRestMeasureAddKeySignature||(this.stave.setKeySignature(l.VexFlowConverter.keySignature(t),l.VexFlowConverter.keySignature(e),void 0),this.updateInstructionWidth()))}addRhythmAtBegin(t){const e=l.VexFlowConverter.TimeSignature(t);this.stave.addModifier(e,n.StaveModifier.Position.BEGIN),this.ShowTimeSignature||e.setStyle({fillStyle:"#00000000"}),this.updateInstructionWidth()}addClefAtEnd(t,e=!0){const i=l.VexFlowConverter.Clef(t,"small");if(e||!this.stave.endClef){this.stave.setEndClef(i.type,i.size,i.annotation);for(const t of this.stave.getModifiers())if(e){const e=t.originalStrokeStyle,i=t.originalFillStyle;t.getStyle()&&(e&&i?(t.getStyle().strokeStyle=e,t.getStyle().fillStyle=i):(t.getStyle().strokeStyle=null,t.getStyle().fillStyle=null))}else if("clefs"===t.getCategory()&&t.getPosition()===n.StaveModifier.Position.END&&t.type===i.type){const e="#12345600",i=t.getStyle();i&&(t.originalStrokeStyle=i.strokeStyle,t.originalFillStyle=i.fillStyle),t.setStyle({strokeStyle:e,fillStyle:e})}return this.parentSourceMeasure.hasEndClef=!0,this.updateInstructionWidth()}}addMeasureLine(t,e,i=!0){switch(e){case f.SystemLinePosition.MeasureBegin:t===o.SystemLinesEnum.BoldThinDots&&(i||(this.stave.modifiers[0].draw=function(t){switch(t.checkContext(),this.setRendered(),this.type){case n.Barline.type.SINGLE:this.drawVerticalBar(t,this.x,!1);break;case n.Barline.type.DOUBLE:this.drawVerticalBar(t,this.x,!0);break;case n.Barline.type.END:this.drawVerticalEndBar(t,this.x);break;case n.Barline.type.REPEAT_BEGIN:this.drawRepeatBar(t,this.x,!0);break;case n.Barline.type.REPEAT_END:this.drawRepeatBar(t,this.x,!1);break;case n.Barline.type.REPEAT_BOTH:this.drawRepeatBar(t,this.x,!1),this.drawRepeatBar(t,this.x,!0)}}),this.stave.setBegBarType(n.Barline.type.REPEAT_BEGIN));break;case f.SystemLinePosition.MeasureEnd:switch(t){case o.SystemLinesEnum.DotsBoldBoldDots:this.stave.setEndBarType(n.Barline.type.REPEAT_BOTH);break;case o.SystemLinesEnum.DotsThinBold:this.stave.setEndBarType(n.Barline.type.REPEAT_END);break;case o.SystemLinesEnum.DoubleThin:this.stave.setEndBarType(n.Barline.type.DOUBLE);break;case o.SystemLinesEnum.ThinBold:this.stave.setEndBarType(n.Barline.type.END);break;case o.SystemLinesEnum.None:this.stave.setEndBarType(n.Barline.type.NONE)}}}addMeasureNumber(){const t=this.MeasureNumber.toString(),e=v.ABOVE;this.stave.setText(t,e,{justification:1,shift_x:0,shift_y:0})}addWordRepetition(t){let e,i=n.StaveModifier.Position.END;const s=this.beginInstructionsWidth;switch(t.type){case d.RepetitionInstructionEnum.Segno:e=n.Repetition.type.SEGNO_LEFT,i=n.StaveModifier.Position.LEFT;break;case d.RepetitionInstructionEnum.Coda:e=n.Repetition.type.CODA_LEFT,i=n.StaveModifier.Position.LEFT;break;case d.RepetitionInstructionEnum.DaCapo:e=n.Repetition.type.DC;break;case d.RepetitionInstructionEnum.DalSegno:e=n.Repetition.type.DS;break;case d.RepetitionInstructionEnum.Fine:e=n.Repetition.type.FINE;break;case d.RepetitionInstructionEnum.ToCoda:e=n.Repetition.type.TO_CODA;break;case d.RepetitionInstructionEnum.DaCapoAlFine:e=n.Repetition.type.DC_AL_FINE;break;case d.RepetitionInstructionEnum.DaCapoAlCoda:e=n.Repetition.type.DC_AL_CODA;break;case d.RepetitionInstructionEnum.DalSegnoAlFine:e=n.Repetition.type.DS_AL_FINE;break;case d.RepetitionInstructionEnum.DalSegnoAlCoda:e=n.Repetition.type.DS_AL_CODA}if(e){const t=new n.Repetition(e,s,-this.rules.RepetitionSymbolsYOffset);return t.xShiftAsPercentOfStaveWidth=this.rules.RepetitionEndInstructionXShiftAsPercentOfStaveWidth,void this.stave.addModifier(t,i)}this.addVolta(t)}addVolta(t){var e;let i=n.Volta.type.BEGIN;if(t.type===d.RepetitionInstructionEnum.Ending){switch(t.alignment){case d.AlignmentType.Begin:i=this.parentSourceMeasure.endsRepetitionEnding()?n.Volta.type.BEGIN_END:n.Volta.type.BEGIN;break;case d.AlignmentType.End:if(this.parentSourceMeasure.beginsRepetitionEnding())return;i=n.Volta.type.END}const s=this.ParentStaffLine.SkyBottomLineCalculator,r=this.PositionAndShape.AbsolutePosition.x+this.PositionAndShape.BorderMarginLeft+.4,o=Math.max(this.PositionAndShape.AbsolutePosition.x+this.PositionAndShape.BorderMarginRight,r+.4),a=s.getSkyLineMinInRange(r,o)-2;let l,h=-6.1+this.rules.VoltaOffset,c=this.rules.VoltaOffset;a0){c.default.trace(`Ghost Found in between (measure ${this.MeasureNumber})`);const e=this.createGhostGves(s);i.splice(t,0,...e),t+=e.length}}else{const e=b.Fraction.minus(n,this.parentSourceMeasure.AbsoluteTimestamp);if(e.RealValue>0){c.default.trace(`Ghost Found at start (measure ${this.MeasureNumber})`);const s=this.createGhostGves(e);i.splice(0,0,...s),t+=s.length}}e=r}const s=b.Fraction.plus(this.parentSourceMeasure.AbsoluteTimestamp,this.parentSourceMeasure.Duration),n=b.Fraction.minus(s,e);if(n.RealValue>0){c.default.trace(`Ghost Found at end (measure ${this.MeasureNumber})`);const t=this.createGhostGves(n);i=i.concat(t)}return i}createGhostGves(t){const e=l.VexFlowConverter.GhostNotes(t),i=[];for(const t of e){const e=new p.VexFlowVoiceEntry(void 0,void 0,this.rules);e.vfStaveNote=t,i.push(e)}return i}handleBeam(t,e){const i=t.sourceNote.ParentVoiceEntry.ParentVoice.VoiceId;let s,n=this.beams[i];n||(n=this.beams[i]=[]);for(const t of n)t[0]===e&&(s=t);s||(s=[e,[]],n.push(s));const r=t.parentVoiceEntry;s[1].indexOf(r)<0&&s[1].push(r)}handleTuplet(t,e){const i=t.sourceNote.ParentVoiceEntry.ParentVoice.VoiceId;e=t.sourceNote.NoteTuplet;let s,n=this.tuplets[i];n||(n=this.tuplets[i]=[]);for(const t of n)t[0]===e&&(s=t);s||(s=[e,[]],n.push(s));const r=t.parentVoiceEntry;s[1].indexOf(r)<0&&s[1].push(r)}finalizeBeams(){this.vfbeams={};const t=[];for(const e in this.beams)if(this.beams.hasOwnProperty(e)){let i=this.vfbeams[e];i||(i=this.vfbeams[e]=[]);for(const s of this.beams[e]){let e=!1;for(const t of s[0].Notes)if(t.Length.RealValue>=new b.Fraction(1,4).RealValue&&(!t.TypeLength||t.TypeLength.RealValue>.125)){e=!0;break}if(e){c.default.debug("Beam between note >= quarter, likely tremolo, currently unsupported. continuing.");continue}const r=[],o=s[0],a=s[1];let l=!0;for(const t of a)t.parentVoiceEntry.ParentVoice===o.Notes[0].ParentVoiceEntry.ParentVoice&&(l=t.parentVoiceEntry.WantedStemDirection===m.StemDirectionType.Undefined);let h,u=!1;const d=[];for(const e of a){const i=e.vfStaveNote;i&&(r.push(i),t.push(i)),e.parentVoiceEntry.IsGrace&&(u=!0),e.parentVoiceEntry.StemColor&&this.rules.ColoringEnabled&&d.push(e.parentVoiceEntry.StemColor)}if(r.length>1){const t=new n.Beam(r,l);if(u&&(t.render_options.beam_width=3,t.render_options.partial_beam_length=4),d.length>=2&&this.rules.ColorBeams){h=d[0];for(const t of d)if(t!==h){h=void 0;break}t.setStyle({fillStyle:h,strokeStyle:h})}this.rules.FlatBeams&&(t.render_options.flat_beams=!0,t.render_options.flat_beam_offset=this.rules.FlatBeamOffset,t.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),i.push(t)}else c.default.debug("Warning! Beam with no notes!")}}this.rules.AutoBeamNotes&&this.autoBeamNotes(t)}autoBeamNotes(t){if(!this.rules.AutoBeamTabs&&this.isTabMeasure)return;let e,i=[],s=[],r=[];this.autoTupletVfBeams=[];const o=[];this.autoVfBeams=[];let a=this.parentSourceMeasure.ActiveTimeSignature;a||(a=this.parentSourceMeasure.Duration);for(const l of this.staffEntries)for(const h of l.graphicalVoiceEntries){const c=h.vfStaveNote,u=h.notes[0],d=l.relInMeasureTimestamp.isOnBeat(a),f=s.length>=2,m=u.sourceNote.Length.RealValue-new b.Fraction(1,4).RealValue>-b.Fraction.FloatInaccuracyTolerance,p=h.parentVoiceEntry.IsGrace||m||t.contains(c);if(p||d){if(f){for(const t of s)i.push(t);o.push(i.slice()),i=[]}if(s=[],p)continue}const g=h.notes[0].sourceNote.NoteTuplet;if(g){let t=!1;for(const e of g.Notes){for(const i of e)if(i.NoteTypeXml>=y.NoteType.QUARTER||i.ParentVoiceEntry.IsGrace||i.isRest()&&!this.rules.AutoBeamOptions.beam_rests){t=!0;break}if(t)break}if(e){if(e!==g){if(r.length>1){const t=new n.Beam(r,!0);this.rules.FlatBeams&&(t.render_options.flat_beams=!0,t.render_options.flat_beam_offset=this.rules.FlatBeamOffset,t.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),this.autoTupletVfBeams.push(t)}r=[],e=g}}else e=g;t||r.push(c)}else e=void 0,s.push(c)}if(r.length>=2){const t=new n.Beam(r,!0);this.rules.FlatBeams&&(t.render_options.flat_beams=!0,t.render_options.flat_beam_offset=this.rules.FlatBeamOffset,t.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),this.autoTupletVfBeams.push(t)}if(s.length>=2){for(const t of s)i.push(t);o.push(i)}const l=this.rules.AutoBeamOptions,h={beam_middle_only:l.beam_middle_rests_only,beam_rests:l.beam_rests,maintain_stem_directions:l.maintain_stem_directions};if(l.groups&&l.groups.length){const t=[];for(const e of l.groups)t.push(new n.Fraction(e[0],e[1]));h.groups=t}for(const t of o){const e=n.Beam.generateBeams(t,h);for(const t of e)this.rules.FlatBeams&&(t.render_options.flat_beams=!0,t.render_options.flat_beam_offset=this.rules.FlatBeamOffset,t.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),this.autoVfBeams.push(t)}}finalizeTuplets(){this.vftuplets={};for(const t in this.tuplets)if(this.tuplets.hasOwnProperty(t)){let e=this.vftuplets[t];e||(e=this.vftuplets[t]=[]);for(const i of this.tuplets[t]){const t=[],s=i[1];for(const e of s)t.push(e.vfStaveNote);if(t.length>1){const s=i[0],r=s.Notes[0][0].NormalNotes,o=s.Bracket||3===s.TupletLabelNumber&&this.rules.TripletsBracketed||3!==s.TupletLabelNumber&&this.rules.TupletsBracketed;let a=n.Tuplet.LOCATION_TOP;s.tupletLabelNumberPlacement===S.PlacementEnum.Below&&(a=n.Tuplet.LOCATION_BOTTOM);const l=new n.Tuplet(t,{bracketed:o,location:a,notes_occupied:r,num_notes:s.TupletLabelNumber,ratioed:this.rules.TupletsRatioed});e.push(l)}else c.default.debug("Warning! Tuplet with no notes! Trying to ignore, but this is a serious problem.")}}}layoutStaffEntry(t){}graphicalMeasureCreatedCalculations(){let t,e=[];const i=[];for(const s of this.staffEntries){t=!1,e=[];for(const r of s.graphicalVoiceEntries)if(r.parentVoiceEntry.IsGrace)e.push(r),i.push(r),t||(t=r.parentVoiceEntry.GraceSlur);else if(r.vfStaveNote=l.VexFlowConverter.StaveNote(r),e.length>0){const i=[];for(let t=0;t0&&(s.GraceSlash=!1);const n=l.VexFlowConverter.StaveNote(s);s.vfStaveNote=n,i.push(n)}const s=new n.GraceNoteGroup(i,t);s.spacing=10*this.rules.GraceNoteGroupXMargin,r.vfStaveNote.addModifier(0,s),e=[]}}if(e.length>0)for(const t of e)t.vfStaveNote=l.VexFlowConverter.StaveNote(t),t.parentVoiceEntry.GraceAfterMainNote=!0;this.finalizeBeams(),this.finalizeTuplets();const s=this.getVoicesWithinMeasure();if(this.rules.RenderFingerings)for(const t of this.staffEntries)t.setModifierXOffsets();for(const t of s){if(!t)continue;this.vfVoices[t.VoiceId]=new n.Voice({beat_value:this.parentSourceMeasure.ActiveTimeSignature.Denominator,num_beats:this.parentSourceMeasure.ActiveTimeSignature.Numerator,resolution:n.RESOLUTION}).setMode(n.Voice.Mode.SOFT);const e=this.getRestFilledVexFlowStaveNotesPerVoice(t);for(const i of e){if(i.parentVoiceEntry&&i.parentVoiceEntry.IsGrace&&!i.parentVoiceEntry.GraceAfterMainNote)continue;const e=i;if(0===e.vfStaveNote.getTicks().denominator)continue;if(0===i.notes.length||!i.notes[0]||!i.notes[0].sourceNote.PrintObject){this.vfVoices[t.VoiceId].addTickable(e.vfStaveNote);continue}const s=e.parentStaffEntry;if(s&&s.vfClefBefore){const t=new h([s.vfClefBefore]);e.vfStaveNote.getCategory&&"stavenotes"===e.vfStaveNote.getCategory()&&e.vfStaveNote.addModifier(0,t)}i.parentVoiceEntry&&this.rules.RenderFingerings&&(this.rules.FingeringPosition!==S.PlacementEnum.Left&&this.rules.FingeringPosition!==S.PlacementEnum.Right||this.createFingerings(i),this.createStringNumber(i)),this.createArpeggio(i),this.vfVoices[t.VoiceId].addTickable(e.vfStaveNote)}}this.setStemDirectionFromVexFlow();for(const t of i)this.createFingerings(t),this.createStringNumber(t),this.createArpeggio(t);this.createArticulations(),this.createOrnaments()}createArpeggio(t){if(t.parentVoiceEntry&&t.parentVoiceEntry.Arpeggio){const e=t.parentVoiceEntry.Arpeggio;if(t.notes&&t.notes.length>1){const i=l.VexFlowConverter.StrokeTypeFromArpeggioType(e.type),s=new n.Stroke(i,{all_voices:this.rules.ArpeggiosGoAcrossVoices});this.rules.RenderArpeggios&&t.vfStaveNote.addStroke(0,s)}else c.default.debug(`[OSMD] arpeggio in measure ${this.MeasureNumber} could not be drawn.\n voice entry had less than two notes, arpeggio is likely between voice entries, not currently supported in Vexflow.`)}}setStemDirectionFromVexFlow(){for(const t of this.staffEntries)for(const e of t.graphicalVoiceEntries)for(const t of e.notes){const i=t.vfnote;if(i&&i[0])switch(i[0].getStemDirection()){case n.Stem.UP:e.parentVoiceEntry.StemDirection=m.StemDirectionType.Up;break;case n.Stem.DOWN:e.parentVoiceEntry.StemDirection=m.StemDirectionType.Down}}}createArticulations(){for(let t=0,e=this.staffEntries.length;t1||t.parentStaffEntry.graphicalVoiceEntries.length>1?l=n.StaveModifier.Position.LEFT:0===e.idInMusicSheet?(l=n.StaveModifier.Position.ABOVE,a=S.PlacementEnum.Above):(l=n.StaveModifier.Position.BELOW,a=S.PlacementEnum.Below)}const c=new n.FretHandFinger(o.value);if(c.setPosition(l),c.setOffsetX(h),a===S.PlacementEnum.Above||a===S.PlacementEnum.Below){const t=a===S.PlacementEnum.Above?-1:1,r=a===S.PlacementEnum.Above?s:i-1-s;if(this.rules.FingeringInsideStafflines&&i>1){const e=c.getWidth()/2,s=2.5*i;c.setOffsetY(t*(r+s)*e)}else if(!this.rules.FingeringInsideStafflines){const i=new n.StringNumber(o.value);i.radius=0,i.setPosition(l),i.setOffsetY(t*r*i.getWidth()*2/3),e.vfStaveNote.addModifier(s,i);continue}}e.vfStaveNote.addModifier(s,c)}}createStringNumber(t){if(!this.rules.RenderStringNumbersClassical)return;const e=t;t.notes.forEach(((i,s)=>{const r=i.sourceNote.StringInstruction;if(r){let o=r.value;switch(o){case"1":o="I";break;case"2":o="II";break;case"3":o="III";break;case"4":o="IV";break;case"5":o="V";break;case"6":o="VI"}const a=new n.StringNumber(o);a.radius=0;const l=-this.rules.StringNumberOffsetY;t.notes.length>1||t.parentStaffEntry.graphicalVoiceEntries.length>1?(a.setOffsetX(13*i.baseStringNumberXOffset),a.setPosition(n.Modifier.Position.RIGHT)):a.setPosition(n.Modifier.Position.ABOVE),a.setOffsetY(l),e.vfStaveNote.addModifier(s,a)}}))}lineTo(t,e){const i=new n.StaveConnector(t.getVFStave(),this.stave);i.setType(e),this.connectors.push(i)}getVFStave(){return this.stave}updateInstructionWidth(){let t=0,e=0;const i=this.stave.getModifiers();for(const s of i)s.getPosition()===v.BEGIN?t+=s.getWidth()+s.getPadding(void 0):s.getPosition()===v.END&&(e+=s.getWidth()+s.getPadding(void 0));this.beginInstructionsWidth=(null!=t?t:0)/u.unitInPixels,this.endInstructionsWidth=(null!=e?e:0)/u.unitInPixels}addStaveTie(t,e){this.vfTies.push(t),e.vfTie=t,e.Tie.TieDirection===S.PlacementEnum.Below&&t.setDirection(1)}}var v;e.VexFlowMeasure=E,function(t){t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT",t[t.ABOVE=3]="ABOVE",t[t.BELOW=4]="BELOW",t[t.BEGIN=5]="BEGIN",t[t.END=6]="END"}(v=e.StavePositionEnum||(e.StavePositionEnum={}))},4405:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowMultiRestMeasure=void 0;var n=s(i(6368)).default.Flow;const r=i(7330);class o extends r.VexFlowMeasure{constructor(t,e,i){super(t,e,i),this.minimumStaffEntriesWidth=-1,i?this.rules=i.ParentMusicSystem.rules:e&&(this.rules=e.Rules),this.resetLayout(),this.multiRestElement=new n.MultiMeasureRest(e.multipleRestMeasures,{})}draw(t){this.stave.setContext(t).draw(),this.multiRestElement.setStave(this.stave),this.multiRestElement.setContext(t),this.multiRestElement.draw();for(const e of this.connectors)e.setContext(t).draw()}format(){}getVoicesWithinMeasure(){return[]}getGraphicalVoiceEntriesPerVoice(t){return[]}getRestFilledVexFlowStaveNotesPerVoice(t){return[]}handleBeam(t,e){}handleTuplet(t,e){}finalizeBeams(){}finalizeTuplets(){}layoutStaffEntry(t){}graphicalMeasureCreatedCalculations(){}createArticulations(){}createOrnaments(){}createFingerings(t){}getVFStave(){return this.stave}}e.VexFlowMultiRestMeasure=o},8738:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowMusicSheetCalculator=void 0;const n=i(4040),r=i(8144),o=i(1659),a=i(5309),l=i(2942),h=s(i(6368));var c=h.default.Flow;const u=s(i(2043)),d=i(5820),f=i(5091),m=i(8720),p=i(9520),b=i(6351),g=i(1274),S=i(9876),y=i(9344),E=i(9667),v=i(41),x=i(7781),_=i(2478),M=i(8129),w=i(2343),P=i(6894),T=i(3010),L=i(158),A=i(2337),C=i(3602);class I extends n.MusicSheetCalculator{constructor(t){var e,i,s,o,a,c,u,d;super(),this.beamsNeedUpdate=!1,this.rules=t,n.MusicSheetCalculator.symbolFactory=new r.VexFlowGraphicalSymbolFactory,n.MusicSheetCalculator.TextMeasurer=new l.VexFlowTextMeasurer(this.rules),n.MusicSheetCalculator.stafflineNoteCalculator=new x.VexflowStafflineNoteCalculator(this.rules),"gonville"===(null===(e=this.rules.DefaultVexFlowNoteFont)||void 0===e?void 0:e.toLowerCase())?h.default.Flow.DEFAULT_FONT_STACK=[null===(i=h.default.Flow.Fonts)||void 0===i?void 0:i.Gonville,null===(s=h.default.Flow.Fonts)||void 0===s?void 0:s.Bravura,null===(o=h.default.Flow.Fonts)||void 0===o?void 0:o.Custom]:"petaluma"===(null===(a=this.rules.DefaultVexFlowNoteFont)||void 0===a?void 0:a.toLowerCase())&&(h.default.Flow.DEFAULT_FONT_STACK=[null===(c=h.default.Flow.Fonts)||void 0===c?void 0:c.Petaluma,null===(u=h.default.Flow.Fonts)||void 0===u?void 0:u.Gonville,null===(d=h.default.Flow.Fonts)||void 0===d?void 0:d.Bravura])}clearRecreatedObjects(){super.clearRecreatedObjects(),n.MusicSheetCalculator.stafflineNoteCalculator=new x.VexflowStafflineNoteCalculator(this.rules);for(const t of this.graphicalMusicSheet.MeasureList)for(const e of t)null==e||e.clean()}formatMeasures(){for(const t of this.graphicalMusicSheet.MeasureList)if(t&&t[0]){t.find((t=>null==t?void 0:t.isVisible())).format();for(const e of t){for(const t of e.staffEntries)t.calculateXPosition();e.finalizeBeams()}}this.beamsNeedUpdate=!1}calculateMeasureXLayout(t){const e=[];for(const i of t)i&&e.push(i);if(0===e.length)return 0;t=e;const i=[],s=new c.Formatter({softmaxFactor:this.rules.SoftmaxFactorVexFlow});let r=t[0].staffEntries.length,o=1;for(const e of t){if(!e)continue;let t=0;for(const i of e.staffEntries)t+=i.setMaxAccidentals();e.parentSourceMeasure.ImplicitMeasure&&(r=Math.max(e.staffEntries.length,r),o=Math.max(e.staffEntries.length+t,o));const n=e.vfVoices,a=[];for(const t in n)if(n.hasOwnProperty(t)){const s=n[t];e.hasOnlyRests&&!s.ticksUsed.equals(s.totalTicks)&&(s.ticksUsed=s.totalTicks),a.push(s),i.push(s)}0!==a.length?s.joinVoices(a):u.default.debug("Found a measure with no voices. Continuing anyway.",n)}let a=12;const l=t[0].parentSourceMeasure;if(i.length>0){if(a=s.preCalculateMinTotalWidth(i)/d.unitInPixels*this.rules.VoiceSpacingMultiplierVexflow+this.rules.VoiceSpacingAddendVexflow+.3*r,null==l?void 0:l.ImplicitMeasure){a=l.Duration.RealValue/l.ActiveTimeSignature.RealValue*a;let t=0;const e=l.measureListIndex;if(e>1)for(const i of this.graphicalMusicSheet.MeasureList[e-1]){const e=null==i?void 0:i.parentSourceMeasure.endingBarStyleEnum;if(e===P.SystemLinesEnum.ThinBold||e===P.SystemLinesEnum.DotsThinBold){t=this.rules.PickupMeasureRepetitionSpacing;break}}a+=t,r>1?a+=.3*o*1.5:e>1&&1===r&&(a+=this.rules.PickupMeasureSpacingSingleNoteAddend),a*=this.rules.PickupMeasureWidthMultiplier}n.MusicSheetCalculator.setMeasuresMinStaffEntriesWidth(t,a);const e=(t,e)=>{s.formatToStave(i,e.getVFStave())},h=(t,e)=>{s.formatToStave(i,e.getVFStave(),{align_rests:!0,context:void 0})};for(const i of t){if(this.rules.AlignRests===v.AlignRestOption.Never)i.formatVoices=e;else if(this.rules.AlignRests===v.AlignRestOption.Always)i.formatVoices=h;else if(this.rules.AlignRests===v.AlignRestOption.Auto){let t=!1;for(const e of i.staffEntries){let i=0,s=0;for(const n of e.graphicalVoiceEntries)if(n.parentVoiceEntry.IsGrace||n&&n.notes&&n.notes[0]&&n.notes[0].sourceNote&&n.notes[0].sourceNote.PrintObject&&i++,n&&n.notes&&n.notes[0]&&n.notes[0].sourceNote&&n.notes[0].sourceNote.isRest()&&n.notes[0].sourceNote.PrintObject&&s++,i>1&&s>=1){t=!0;break}if(t)break}i.formatVoices=t?h:e}if(i===t[0]){const t=i;t.formatVoices(a*d.unitInPixels,t)}}}for(const e of t)if(e)for(const t of e.staffEntries)t.calculateXPosition();for(const e of t){if(!e)continue;const t=e.vfVoices,i=[];for(const e in t)t.hasOwnProperty(e)&&i.push(t[e]);0!==i.length?s.joinVoices(i):u.default.debug("Found a measure with no voices. Continuing anyway.",t)}return a}calculateElongationFactor(t,e,i,s,n,r,o,a){let l=n,h=0;for(const c of t){const t=c.GraphicalLabel.Label.textAlignment;let u=o,d=a;if(c instanceof f.GraphicalLyricEntry&&c.ParentLyricWord){c.LyricsEntry.SyllableIndex>0&&(u=this.rules.BetweenSyllableMinimumDistance,g.TextAlignment.IsCenterAligned(t)&&(u+=1));const e=c.ParentLyricWord.GetLyricWord.Syllables;e.length>1&&c.LyricsEntry.SyllableIndex4&&(w*=1.1)}}else i[h]&&(w=S/y);_=Math.max(M,w),l=Math.max(l,_);let P=Math.max(S-y||0,0);i[h]&&(P+=i[h].cumulativeOverlap),i[h]={cumulativeOverlap:P,extend:c instanceof f.GraphicalLyricEntry&&c.LyricsEntry.extend,labelWidth:p,measureNumber:r,sourceNoteDuration:c instanceof f.GraphicalLyricEntry&&c.LyricsEntry&&c.LyricsEntry.Parent.Notes[0].Length,text:c instanceof f.GraphicalLyricEntry?c.LyricsEntry.Text:c.GraphicalLabel.Label.text,xPosition:b},h++}return l}calculateElongationFactorFromStaffEntries(t,e,i,s){let n=i;const r={},o={};for(const i of t)i.LyricsEntries.length>0&&(n=this.calculateElongationFactor(i.LyricsEntries,i,r,e,n,s,this.rules.HorizontalBetweenLyricsDistance,this.rules.LyricOverlapAllowedIntoNextMeasure)),i.graphicalChordContainers.length>0&&(n=this.calculateElongationFactor(i.graphicalChordContainers,i,o,e,n,s,this.rules.ChordSymbolXSpacing,this.rules.ChordOverlapAllowedIntoNextMeasure));return n}calculateMeasureWidthFromStaffEntries(t,e){let i=1;for(const s of t)s&&0!==s.staffEntries.length&&(i=this.calculateElongationFactorFromStaffEntries(s.staffEntries,e,i,s.MeasureNumber));return i=Math.min(i,this.rules.MaximumLyricsElongationFactor),e*i}createGraphicalTie(t,e,i,s,n){return new a.GraphicalTie(t,s,n)}updateStaffLineBorders(t){t.SkyBottomLineCalculator.updateStaffLineBorders()}graphicalMeasureCreatedCalculations(t){t.rules=this.rules,t.graphicalMeasureCreatedCalculations()}layoutVoiceEntry(t,e,i,s){for(let t=0;t=2&&(r=s.vfnote[0],a=s.vfnote[1]);let l=0;if(n&&n.vfnote&&n.vfnote.length>=2&&(o=n.vfnote[0],l=n.vfnote[1]),e){if(r){const e=new c.StaveTie({first_indices:[a],first_note:r});s.parentVoiceEntry.parentStaffEntry.parentMeasure.addStaveTie(e,t)}if(o){const e=new c.StaveTie({last_indices:[l],last_note:o});n.parentVoiceEntry.parentStaffEntry.parentMeasure.addStaveTie(e,t)}}else if(r||o){let e;if(i)if("S"===t.Tie.Type){const i=t.StartNote.sourceNote,s=t.EndNote.sourceNote;let n=1;i.FretNumber>s.FretNumber&&(n=-1),e=new c.TabSlide({first_indices:[a],first_note:r,last_indices:[l],last_note:o},n)}else e=new c.TabTie({first_indices:[a],first_note:r,last_indices:[l],last_note:o},t.Tie.Type);else{e=new c.StaveTie({first_indices:[a],first_note:r,last_indices:[l],last_note:o});const i=t.Tie.getTieDirection(s.sourceNote);i===w.PlacementEnum.Below?e.setDirection(1):i===w.PlacementEnum.Above&&e.setDirection(-1)}n.parentVoiceEntry.parentStaffEntry.parentMeasure.addStaveTie(e,t)}}calculateDynamicExpressionsForMultiExpression(t,e,i){if(ethis.rules.MaxMeasureToDrawIndex)return;const s=t.AbsoluteTimestamp,n=this.graphicalMusicSheet.MeasureList[e],r=n[i].ParentStaffLine,o=n[i],a=this.getRelativePositionInStaffLineFromTimestamp(s,i,r,null==r?void 0:r.isPartOfMultiStaffInstrument());if(a.x<=0&&(a.x=o.beginInstructionsWidth+this.rules.RhythmRightMargin),t.InstantaneousDynamic){const e=new b.VexFlowInstantaneousDynamicExpression(t.InstantaneousDynamic,r,o);this.calculateGraphicalInstantaneousDynamicExpression(e,a,s),this.dynamicExpressionMap.set(s.RealValue,e.PositionAndShape)}if(t.StartingContinuousDynamic){const e=t.StartingContinuousDynamic,i=new y.VexFlowContinuousDynamicExpression(t.StartingContinuousDynamic,r,o.parentSourceMeasure);if(i.StartMeasure=o,i.IsSoftAccent=t.StartingContinuousDynamic.IsStartOfSoftAccent,!i.IsVerbal&&e.EndMultiExpression)try{this.calculateGraphicalContinuousDynamic(i,a),i.updateSkyBottomLine()}catch(t){}else i.IsVerbal?this.calculateGraphicalVerbalContinuousDynamic(i,a):u.default.warn("This continuous dynamic is not covered. measure"+t.SourceMeasureParent.MeasureNumber)}}createMetronomeMark(t){var e,i;const s=Math.max(t.ParentMultiTempoExpression.SourceMeasureParent.MeasureNumber-1,0),n=Math.max(t.StaffNumber-1,0),r=0===s&&0===n,o=this.graphicalMusicSheet.MeasureList[s][n].getVFStave();let a="q";if(t.beatUnit){const e=_.NoteTypeHandler.getNoteDurationFromType(t.beatUnit);a=M.VexFlowConverter.durations(e,!1)[0]}let l=this.rules.MetronomeMarkYShift,h=!1;for(const i of t.parentMeasure.TempoExpressions){const t=(null===(e=i.InstantaneousTempo)||void 0===e?void 0:e.Enum)===E.TempoEnum.metronomeMark;if(i.getPlacementOfFirstEntry()===w.PlacementEnum.Above&&!t){h=!0;break}}h&&(l-=1.4);const c=null===(i=this.graphicalMusicSheet.MeasureList[0][0].ParentStaffLine)||void 0===i?void 0:i.SkyLine;o.setTempo({bpm:t.TempoInBpm,dots:t.dotted,duration:a},l*d.unitInPixels);const u=r?this.rules.MetronomeMarkXShift*d.unitInPixels:0;o.getModifiers()[o.getModifiers().length-1].setShiftX(u),c&&(c[0]=Math.min(c[0],-4.5+l))}calculateRehearsalMark(t){var e;const i=t.rehearsalExpression;if(!i)return;const s=this.graphicalMusicSheet.MeasureList[0][0].MeasureNumber,n=Math.max(t.MeasureNumber-s,0),r=null===(e=this.graphicalMusicSheet.MeasureList[n][0])||void 0===e?void 0:e.getVFStave();if(!r)return;const o=-this.rules.RehearsalMarkYOffsetDefault-this.rules.RehearsalMarkYOffset;let a=this.rules.RehearsalMarkXOffsetDefault+this.rules.RehearsalMarkXOffset;t.IsSystemStartMeasure&&(a+=this.rules.RehearsalMarkXOffsetSystemStartMeasure);const l=this.rules.RehearsalMarkFontSize;r.setSection(i.label,o,a,l)}calculateSingleOctaveShift(t,e,i,s){var n;const r=e.OctaveShiftStart,o=r.ParentStartMultiExpression.Timestamp,a=null===(n=r.ParentEndMultiExpression)||void 0===n?void 0:n.Timestamp,l=this.rules.MinMeasureToDrawIndex,h=this.rules.MaxMeasureToDrawIndex;let c,d,f=this.graphicalMusicSheet.MeasureList[i][s].ParentStaffLine;if(f||(f=this.graphicalMusicSheet.MeasureList[l][s].ParentStaffLine),c=r.ParentEndMultiExpression?this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(r.ParentEndMultiExpression.SourceMeasureParent,s):this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(s,!0),c.MeasureNumber>h+1&&(c=this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(s,!0)),d=r.ParentEndMultiExpression?this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(r.ParentStartMultiExpression.SourceMeasureParent,s):this.graphicalMusicSheet.MeasureList[l][s],d.MeasureNumberh+1||c.MeasureNumberh+1)return;let m=c.ParentStaffLine;if(m||(m=f),c&&f&&m){const t=new p.VexFlowOctaveShift(r,f.PositionAndShape);if(!t.startNote){let e;for(const t of d.staffEntries)if(t){e=t;break}if(!e)return;if(t.setStartNote(e),!t.startNote)return}if(!t.endNote){let e;for(let t=c.staffEntries.length-1;t>=0;t++)if(c.staffEntries[t]){e=c.staffEntries[t];break}if(t.setEndNote(e),!t.endNote)return}let e=d.findGraphicalStaffEntryFromTimestamp(o);e||(e=d.staffEntries[0]);let i=c.findGraphicalStaffEntryFromTimestamp(a);if(i||(i=c.staffEntries[c.staffEntries.length-1]),t.setStartNote(e),m!==f){t.endsOnDifferentStaffLine=!0;let n=this.findLastStafflineMeasure(f);void 0===n&&(n=c);const o=n.staffEntries[n.staffEntries.length-1];t.setEndNote(o),t.graphicalEndAtMeasureEnd=!0,t.endMeasure=n;const a=m.ParentMusicSystem.Id-f.ParentMusicSystem.Id;if(a>0)for(let t=f.ParentMusicSystem.Id;t=0;e--){const i=t.Measures[e];if(i.staffEntries.length>0)return i}}calculateSinglePedal(t,e,i,s){var n;const r=e.PedalStart,o=r.ParentStartMultiExpression.Timestamp,a=null===(n=r.ParentEndMultiExpression)||void 0===n?void 0:n.Timestamp,l=this.rules.MinMeasureToDrawIndex,h=this.rules.MaxMeasureToDrawIndex;let c,d,f=this.graphicalMusicSheet.MeasureList[i][s].ParentStaffLine;if(f||(f=this.graphicalMusicSheet.MeasureList[l][s].ParentStaffLine),c=r.ParentEndMultiExpression?this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(r.ParentEndMultiExpression.SourceMeasureParent,s):this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(s,!0),c.MeasureNumber>h+1&&(c=this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(s,!0)),r.ParentEndMultiExpression?d=this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(r.ParentStartMultiExpression.SourceMeasureParent,s):(d=this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(r.ParentStartMultiExpression.SourceMeasureParent,s),d||(d=this.graphicalMusicSheet.MeasureList[l][s])),d.MeasureNumberh||c.parentSourceMeasure.measureListIndexh)return;let m=c.ParentStaffLine;if(m||(m=f),c&&f&&m){let t=!1;f!==m&&(t=!0);const e=new T.VexFlowPedal(r,f.PositionAndShape,!1,t);e.setEndsStave(c,a);let i=d.findGraphicalStaffEntryFromTimestamp(o);i||(i=d.staffEntries[0]);let n=c.findGraphicalStaffEntryFromTimestamp(a);if(n||(n=c.staffEntries[c.staffEntries.length-1]),!e.setStartNote(i))return;if(e.setBeginsStave(e.startNote.isRest(),o),m!==f)if(e.pedalSymbol===L.MusicSymbol.PEDAL_SYMBOL){e.setEndNote(n),e.setEndMeasure(c),e.ReleaseText=" ",e.CalculateBoundingBox(),this.calculatePedalSkyBottomLine(e.startVfVoiceEntry,e.endVfVoiceEntry,e,f);const t=m.Measures[0],i=new T.VexFlowPedal(r,t.PositionAndShape);e.setEndsStave(c,a);const s=t.staffEntries[0];if(!i.setStartNote(s))return;i.setEndNote(n),e.setEndMeasure(c),m.Pedals.push(i),i.CalculateBoundingBox(),i.DepressText=" ",this.calculatePedalSkyBottomLine(i.startVfVoiceEntry,i.endVfVoiceEntry,i,m)}else{let t=this.findLastStafflineMeasure(f);void 0===t&&(t=c);const i=t.staffEntries[t.staffEntries.length-1];e.setEndNote(i),e.setEndMeasure(c),e.ChangeEnd=!1;const o=m.ParentMusicSystem.Id-f.ParentMusicSystem.Id;if(o>0){let t=1;for(let i=f.ParentMusicSystem.Id;im){const t=m;m=p,p=t}s.SkyBottomLineCalculator.updateBottomLineInRange(p,m,b+t)}for(const t of s.Pedals){const e=t,i=e.getPedalMarking();if(b>i.line+3+(s.StaffLines.length-1)){const t=i.render_options.text_margin_right/10;let n,l=e.startVfVoiceEntry.PositionAndShape.AbsolutePosition.x-t;e.setLine(b-3-(s.StaffLines.length-1));let h=null===(r=e.endVfVoiceEntry)||void 0===r?void 0:r.PositionAndShape;if(h||(h=e.endMeasure.PositionAndShape),e.EndSymbolPositionAndShape){const e=u.render_options.glyph_point_size/20;n=l+3.4;const i=h.AbsolutePosition.x-t,r=i+1.5;s.SkyBottomLineCalculator.updateBottomLineInRange(l,n,b+e),s.SkyBottomLineCalculator.updateBottomLineInRange(i,r,b+e)}else{const r=i.render_options.bracket_height/10;if(i.EndsStave)n=h.AbsolutePosition.x+h.Size.width-t;else switch(u.style){case c.BRACKET_OPEN_END:case c.BRACKET_OPEN_BOTH:case c.MIXED_OPEN_END:n=h.AbsolutePosition.x+h.BorderRight-t;break;default:n=h.AbsolutePosition.x+h.BorderLeft-t}const d=null===(a=null===(o=e.endVfVoiceEntry)||void 0===o?void 0:o.parentStaffEntry)||void 0===a?void 0:a.vfClefBefore;if(d&&(n+=d.getWidth()/10),l>n){const t=l;l=n,n=t}s.SkyBottomLineCalculator.updateBottomLineInRange(l,n,b+r)}}}}calculateOctaveShiftSkyBottomLine(t,e,i,s){if(!e)return void u.default.warn("octaveshift: no endStaffEntry");let n=e.PositionAndShape;i.graphicalEndAtMeasureEnd&&(n=e.parentMeasure.PositionAndShape);let r=t.PositionAndShape.Size.width,o=n.Size.width;t.hasOnlyRests()?r=-r:r/=2,i.graphicalEndAtMeasureEnd||(e.hasOnlyRests()?o*=2:o/=2,t===e&&(o*=2));let a=t.PositionAndShape.AbsolutePosition.x-r,l=n.AbsolutePosition.x+o;if(a>l){const t=a;a=l,l=t}i.PositionAndShape.Size.width=l-a;const h=i.getTextBracket(),d=h.font.size/10;if(h.position===c.TextBracket.Positions.TOP){const t=Math.ceil(s.SkyBottomLineCalculator.getSkyLineMinInRange(a,l));if(t===1/0)return;h.start.getStave().options.top_text_position=Math.abs(t),s.SkyBottomLineCalculator.updateSkyLineInRange(a,l,t-2*d)}else{const t=s.SkyBottomLineCalculator.getBottomLineMaxInRange(a,l);if(t===1/0)return;h.start.getStave().options.bottom_text_position=t,s.SkyBottomLineCalculator.updateBottomLineInRange(a,l,t+1.5*d)}}calculateWordRepetitionInstruction(t,e){let i;const s=this.graphicalMusicSheet.MeasureList[e];for(let t=0,e=s.length;tt.StaffLines)));let e=0;for(const i of t)for(const t of i.Measures)t&&e++;if(this.rules.AlwaysSetPreferredSkyBottomLineBackendAutomatically&&this.rules.setPreferredSkyBottomLineBackendAutomatically(e),e>=this.rules.SkyBottomLineBatchMinMeasures)new o.SkyBottomLineBatchCalculator(t,this.rules.PreferredSkyBottomLineBatchCalculatorBackend).calculateLines();else for(const e of t)e.SkyBottomLineCalculator.calculateLines()}calculateExpressionAlignements(){for(const t of this.musicSystems)for(const e of t.StaffLines)try{e.AlignmentManager.alignDynamicExpressions(),e.AbstractExpressions.forEach((t=>{t.updateSkyBottomLine()}))}catch(t){}}handleTiedGraphicalNote(t,e,i,s,n,r,o,a){}handleBeam(t,e,i){t.parentVoiceEntry.parentStaffEntry.parentMeasure.handleBeam(t,e)}handleVoiceEntryLyrics(t,e,i){t.LyricsEntries.forEach(((t,s)=>{const n=new f.GraphicalLyricEntry(s,e,this.rules.LyricsHeight,this.rules.StaffHeight);if(e.LyricsEntries.push(n),n.GraphicalLabel.setLabelPositionAndShapeBorders(),s.Word){const t=s.Word.Syllables.indexOf(s);let e=i.indexOf(s.Word);if(-1===e&&(i.push(s.Word),e=i.indexOf(s.Word)),0===this.graphicalLyricWords.length||e>this.graphicalLyricWords.length-1){const e=new m.GraphicalLyricWord(s.Word);n.ParentLyricWord=e,e.GraphicalLyricsEntries[t]=n,this.graphicalLyricWords.push(e)}else{const s=this.graphicalLyricWords[e];n.ParentLyricWord=s,s.GraphicalLyricsEntries[t]=n,s.isFilled()&&(i.splice(e,1),this.graphicalLyricWords.splice(this.graphicalLyricWords.indexOf(s),1))}}}))}handleVoiceEntryOrnaments(t,e,i){}handleVoiceEntryArticulations(t,e,i){}handleVoiceEntryTechnicalInstructions(t,e,i){}handleTuplet(t,e,i){t.parentVoiceEntry.parentStaffEntry.parentMeasure.handleTuplet(t,e)}findIndexGraphicalSlurFromSlur(t,e){for(let i=0;i=0){const t=e[i];-1===t.staffEntries.indexOf(s)&&t.staffEntries.push(s),e.splice(i,1)}}}for(const t of e)-1===t.staffEntries.indexOf(s)&&t.staffEntries.push(s)}}for(const t of this.musicSystems)for(const e of t.StaffLines){const t=e.GraphicalSlurs.sort(S.GraphicalSlur.Compare);for(const e of t)e.slur.isCrossed()||e.calculateCurve(this.rules)}}calculateGlissandi(){const t={};for(const e of this.graphicalMusicSheet.MeasureList[0])t[e.ParentStaff.idInMusicSheet]=[];for(const e of this.musicSystems)for(const i of e.StaffLines){const e=t[i.ParentStaff.idInMusicSheet];for(let t=0;t=0){const t=e[i];-1===t.staffEntries.indexOf(s)&&t.staffEntries.push(s),e.splice(i,1)}}}}for(const t of e)-1===t.staffEntries.indexOf(s)&&t.staffEntries.push(s)}}for(const t of this.musicSystems)for(const e of t.StaffLines)for(const t of e.GraphicalGlissandi)if(e.ParentStaff.isTab){const e=t.Glissando.StartNote,i=t.Glissando.EndNote,s=t.staffEntries[0].findGraphicalNoteFromNote(e),n=t.staffEntries.last().findGraphicalNoteFromNote(i);if(!s&&!n)return;let r,o,a,l,h=1;e.FretNumber>i.FretNumber&&(h=-1),s&&s.vfnote&&s.vfnote.length>=2&&(a=s.vfnote[0],r=[0]),n&&n.vfnote&&n.vfnote.length>=2&&(l=n.vfnote[0],o=[0]);const u=new c.TabSlide({first_indices:r,first_note:a,last_indices:o,last_note:l},h),d=null==s?void 0:s.parentVoiceEntry.parentStaffEntry.parentMeasure;d&&(d.vfTies.push(u),t.vfTie=u);const f=null==n?void 0:n.parentVoiceEntry.parentStaffEntry.parentMeasure;f&&(f.vfTies.push(u),t.vfTie=u)}}}e.VexFlowMusicSheetCalculator=I},5820:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowMusicSheetDrawer=e.unitInPixels=void 0;const n=s(i(6368)),r=i(1494),o=i(3278),a=i(9086),l=i(2942),h=i(8155),c=i(3748),u=i(5277),d=i(9428),f=s(i(2043)),m=i(374),p=i(7459),b=i(4462);e.unitInPixels=10;class g extends r.MusicSheetDrawer{constructor(t=new p.DrawingParameters){super(new l.VexFlowTextMeasurer(t.Rules),t),this.backends=[],this.zoom=1,this.pageIdx=0}get Backends(){return this.backends}drawSheet(t){var i,s,r;"gonville"===this.rules.DefaultVexFlowNoteFont&&(n.default.Flow.DEFAULT_FONT_STACK=[null===(i=n.default.Flow.Fonts)||void 0===i?void 0:i.Gonville,null===(s=n.default.Flow.Fonts)||void 0===s?void 0:s.Bravura,null===(r=n.default.Flow.Fonts)||void 0===r?void 0:r.Custom]),n.default.Flow.STAVE_LINE_THICKNESS=this.rules.StaffLineWidth*e.unitInPixels,n.default.Flow.STEM_WIDTH=this.rules.StemWidth*e.unitInPixels,n.default.Flow.DEFAULT_NOTATION_FONT_SCALE=this.rules.VexFlowDefaultNotationFontScale,n.default.Flow.DEFAULT_TAB_FONT_SCALE=this.rules.VexFlowDefaultTabFontScale,this.pageIdx=0;for(const e of t.MusicPages){if(e.PageNumber>this.rules.MaxPageToDrawNumber)break;const t=this.backends[this.pageIdx];t.graphicalMusicPage=e,t.scale(this.zoom),this.pageIdx+=1}this.pageIdx=0,this.backend=this.backends[0],super.drawSheet(t)}drawPage(t){t&&(this.backend=this.backends[t.PageNumber-1],super.drawPage(t),this.pageIdx+=1)}clear(){for(const t of this.backends)t.clear()}setZoom(t){this.zoom=t}calculatePixelDistance(t){return t*e.unitInPixels}drawStaffLine(t){super.drawStaffLine(t);const e=t.PositionAndShape.AbsolutePosition;this.rules.RenderSlurs&&this.drawSlurs(t,e),this.rules.RenderGlissandi&&this.drawGlissandi(t,e)}drawSlurs(t,e){for(const i of t.GraphicalSlurs)i.slur.isCrossed()||this.drawSlur(i,e)}drawGlissandi(t,e){for(const i of t.GraphicalGlissandi)this.drawGlissando(i,e)}drawGlissando(t,e){if(t.StaffLine.ParentStaff.isTab||t.calculateLine(this.rules),t.Line){const i=new a.PointF2D(t.Line.Start.x+e.x,t.Line.Start.y),s=new a.PointF2D(t.Line.End.x+e.x,t.Line.End.y);this.drawLine(i,s,t.Color,t.Width)}else{const e=t.vfTie;if(e){const t=this.backend.getContext();e.setContext(t),e.draw()}}}drawSlur(t,e){const i=[],s=new a.PointF2D(t.bezierStartPt.x+e.x,t.bezierStartPt.y+e.y),n=new a.PointF2D(t.bezierStartControlPt.x+e.x,t.bezierStartControlPt.y+e.y),r=new a.PointF2D(t.bezierEndControlPt.x+e.x,t.bezierEndControlPt.y+e.y),o=new a.PointF2D(t.bezierEndPt.x+e.x,t.bezierEndPt.y+e.y);i.push(this.applyScreenTransformation(s)),i.push(this.applyScreenTransformation(n)),i.push(this.applyScreenTransformation(r)),i.push(this.applyScreenTransformation(o)),t.placement===c.PlacementEnum.Above?(s.y-=.05,n.y-=.3,r.y-=.3,o.y-=.05):(s.y+=.05,n.y+=.3,r.y+=.3,o.y+=.05),i.push(this.applyScreenTransformation(s)),i.push(this.applyScreenTransformation(n)),i.push(this.applyScreenTransformation(r)),i.push(this.applyScreenTransformation(o)),t.SVGElement=this.backend.renderCurve(i)}drawMeasure(t){t.setAbsoluteCoordinates(t.PositionAndShape.AbsolutePosition.x*e.unitInPixels,t.PositionAndShape.AbsolutePosition.y*e.unitInPixels);try{t.draw(this.backend.getContext())}catch(t){f.default.warn("VexFlowMusicSheetDrawer.drawMeasure",t)}for(const e of t.staffEntries)this.drawStaffEntry(e)}drawLine(t,i,s="#000000FF",n=.2){return t=this.applyScreenTransformation(t),i=this.applyScreenTransformation(i),this.backend.renderLine(t,i,s,n*e.unitInPixels)}DrawOverlayLine(t,i,s,n="#FF0000FF",r=.2){if(!s.PageNumber||s.PageNumber>this.backends.length||s.PageNumber<1)return void console.log("VexFlowMusicSheetDrawer.drawOverlayLine: invalid page number / music page number doesn't correspond to an existing backend.");const o=s.PageNumber-1,a=this.backends[o];return t=this.applyScreenTransformation(t),i=this.applyScreenTransformation(i),a.renderLine(t,i,n,r*e.unitInPixels)}drawSkyLine(t){const e=t.PositionAndShape.AbsolutePosition,i=t.PositionAndShape.Size.width;this.drawSampledLine(t.SkyLine,e,i)}drawBottomLine(t){const e=new a.PointF2D(t.PositionAndShape.AbsolutePosition.x,t.PositionAndShape.AbsolutePosition.y),i=t.PositionAndShape.Size.width;this.drawSampledLine(t.BottomLine,e,i,"#0000FFFF")}drawSampledLine(t,e,i,s="#FF0000FF"){const n=[];let r=0;for(let e=0;e0){const e=this.rules.SamplingUnit;let r,l,h=new a.PointF2D(o.x,o.y),c=new a.PointF2D(n[0]/e+o.x,o.y);this.drawLine(h,c,s),t[0]>=0&&(r=new a.PointF2D(n[0]/e+o.x,o.y),l=new a.PointF2D(n[0]/e+o.x,o.y+t[n[0]]),this.drawLine(r,l,s));for(let i=1;i0)for(const e of t.FingeringEntries)e.SVGNode=this.drawLabel(e,h.GraphicalLayers.Notes);if(void 0!==t.graphicalChordContainers&&t.graphicalChordContainers.length>0)for(const e of t.graphicalChordContainers){const t=e.GraphicalLabel;t.SVGNode=this.drawLabel(t,h.GraphicalLayers.Notes)}this.rules.RenderLyrics&&t.LyricsEntries.length>0&&this.drawLyrics(t.LyricsEntries,h.GraphicalLayers.Notes)}drawLyrics(t,e){t.forEach((t=>{const i=t.GraphicalLabel;i.Label.colorDefault=this.rules.DefaultColorLyrics,i.SVGNode=this.drawLabel(i,e)}))}drawInstrumentBrace(t,e){t.draw(this.backend.getContext())}drawGroupBracket(t,e){t.draw(this.backend.getContext())}drawOctaveShifts(t){for(const e of t.OctaveShifts)if(e){const t=e,i=this.backend.getContext(),s=t.getTextBracket();this.rules.DefaultColorMusic&&(s.render_options.color=this.rules.DefaultColorMusic),s.setContext(i);try{s.draw()}catch(t){f.default.warn(t)}}}drawPedals(t){for(const e of t.Pedals)if(e){const t=e,i=this.backend.getContext(),s=t.getPedalMarking();s.render_options.color=this.rules.DefaultColorMusic,s.setContext(i),s.draw()}}drawExpressions(t){for(const e of t.AbstractExpressions)if(e instanceof d.GraphicalInstantaneousDynamicExpression)this.drawInstantaneousDynamic(e);else if(e instanceof u.GraphicalInstantaneousTempoExpression){const t=e.GraphicalLabel;t.SVGNode=this.drawLabel(t,h.GraphicalLayers.Notes)}else if(e instanceof m.GraphicalContinuousDynamicExpression)this.drawContinuousDynamic(e);else if(e instanceof b.GraphicalUnknownExpression){const t=e.Label;t.SVGNode=this.drawLabel(t,h.GraphicalLayers.Notes)}else f.default.warn("Unkown type of expression!")}drawInstantaneousDynamic(t){const e=t.Label;e.SVGNode=this.drawLabel(e,h.GraphicalLayers.Notes)}drawContinuousDynamic(t){var e;if(t.IsVerbal){const e=t.Label;e.SVGNode=this.drawLabel(e,h.GraphicalLayers.Notes)}else for(const i of t.Lines){const s=new a.PointF2D(t.ParentStaffLine.PositionAndShape.AbsolutePosition.x+i.Start.x,t.ParentStaffLine.PositionAndShape.AbsolutePosition.y+i.Start.y),n=new a.PointF2D(t.ParentStaffLine.PositionAndShape.AbsolutePosition.x+i.End.x,t.ParentStaffLine.PositionAndShape.AbsolutePosition.y+i.End.y);this.drawLine(s,n,null!==(e=i.colorHex)&&void 0!==e?e:"#000000",i.Width)}}renderLabel(t,i,s,n,r,o){var l;if(!t.Label.print)return;const h=t.Label.fontHeight*e.unitInPixels,{font:c}=t.Label;let u;this.rules.ColoringEnabled&&(u=t.Label.colorDefault,u||(u=this.rules.DefaultColorLabel));let d,{fontStyle:f,fontFamily:m}=t.Label;f||(f=this.rules.DefaultFontStyle),m||(m=this.rules.DefaultFontFamily);for(let e=0;e<(null===(l=t.TextLines)||void 0===l?void 0:l.length);e++){const i=t.TextLines[e],s=this.calculatePixelDistance(i.xOffset),n=new a.PointF2D(o.x+s,o.y),l=this.backend.renderText(h,f,c,i.text,r,n,u,t.Label.fontFamily);d?d.appendChild(l):d=l,o.y=o.y+r,t.TextLines.length>1&&(o.y+=this.rules.SpacingBetweenTextLines)}return d}renderRectangle(t,e,i,s,n){return this.backend.renderRectangle(t,i,s,n)}applyScreenTransformation(t){return new a.PointF2D(t.x*e.unitInPixels,t.y*e.unitInPixels)}applyScreenTransformationForRect(t){return new o.RectangleF2D(t.x*e.unitInPixels,t.y*e.unitInPixels,t.width*e.unitInPixels,t.height*e.unitInPixels)}}e.VexFlowMusicSheetDrawer=g},8494:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowMusicSystem=void 0;const s=i(7142),n=i(6894),r=i(7771),o=i(8129),a=i(5575),l=i(8939);class h extends s.MusicSystem{constructor(t,e){super(t),this.rules=e}calculateBorders(t){if(0===this.staffLines.length)return;const e=this.calcBracketsWidth();this.boundingBox.BorderLeft=-e,this.boundingBox.BorderMarginLeft=-e,this.boundingBox.XBordersHaveBeenSet=!0;const i=this.staffLines[0].SkyBottomLineCalculator.getSkyLineMin();this.boundingBox.BorderTop=i,this.boundingBox.BorderMarginTop=i;const s=this.staffLines[this.staffLines.length-1],n=s.SkyBottomLineCalculator.getBottomLineMax()+s.PositionAndShape.RelativePosition.y;this.boundingBox.BorderBottom=n,this.boundingBox.BorderMarginBottom=n,this.boundingBox.XBordersHaveBeenSet=!0,this.boundingBox.YBordersHaveBeenSet=!0}createSystemLine(t,e,i,s,a,l,h){const c=l;let u=!1;if(h&&(u=!0,h.lineTo(l,o.VexFlowConverter.line(i,s)),h.addMeasureLine(i,s),i===n.SystemLinesEnum.DotsBoldBoldDots)){const t=h.ParentStaffLine.Measures.indexOf(h)+1,e=h.ParentStaffLine.Measures[t],i=l.ParentStaffLine.Measures[t];e&&i&&(e.lineTo(i,o.VexFlowConverter.line(n.SystemLinesEnum.BoldThinDots,s)),e.addMeasureLine(n.SystemLinesEnum.BoldThinDots,s))}return c&&c.addMeasureLine(i,s,u),new r.SystemLine(i,s,this,l,h)}createInstrumentBracket(t,e){const i=t,s=e,n=new l.VexFlowInstrumentBrace(i,s);this.InstrumentBrackets.push(n)}createGroupBracket(t,e,i){const s=t,n=e;if(0===i){const t=new a.VexFlowInstrumentBracket(s,n,i);this.GroupBrackets.push(t)}else{const t=new l.VexFlowInstrumentBrace(s,n,i);this.GroupBrackets.push(t)}}}e.VexFlowMusicSystem=h},9520:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowOctaveShift=void 0;var n=s(i(6368)).default.Flow;const r=i(873),o=i(5853),a=s(i(2043));class l extends r.GraphicalOctaveShift{constructor(t,e){switch(super(t,e),t.Type){case o.OctaveEnum.VA8:this.position=n.TextBracket.Positions.TOP,this.supscript="va",this.text="8";break;case o.OctaveEnum.MA15:this.position=n.TextBracket.Positions.TOP,this.supscript="ma",this.text="15";break;case o.OctaveEnum.VB8:this.position=n.TextBracket.Positions.BOTTOM,this.supscript="vb",this.text="8";break;case o.OctaveEnum.MB15:this.position=n.TextBracket.Positions.BOTTOM,this.supscript="mb",this.text="15";break;default:a.default.error("Unknown or NONE octaveshift. This should not be called!")}}setStartNote(t){for(const e of t.graphicalVoiceEntries){const t=e;if(null==t?void 0:t.vfStaveNote)return this.startNote=t.vfStaveNote,!0}return!1}setEndNote(t){for(const e of t.graphicalVoiceEntries){const t=e;if(null==t?void 0:t.vfStaveNote)return this.endNote=t.vfStaveNote,!0}return!1}getTextBracket(){let t,e=this.endNote;const i=this;this.graphicalEndAtMeasureEnd&&(t={getAbsoluteX:()=>10*(i.endMeasure.PositionAndShape.AbsolutePosition.x+i.endMeasure.PositionAndShape.Size.width),getGlyph:()=>({getWidth:()=>0})}),t&&(e=t);const s=new n.TextBracket({position:this.position,start:this.startNote,stop:e,superscript:this.supscript,text:this.text});return this.endsOnDifferentStaffLine&&(s.render_options.show_bracket=!1),s}}e.VexFlowOctaveShift=l},3010:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowPedal=void 0;const n=s(i(6368)),r=i(8911),o=i(4082),a=i(158);class l extends o.GraphicalPedal{constructor(t,e,i=!1,s=!1){switch(super(t,e),this.vfStyle=n.default.Flow.PedalMarking.Styles.BRACKET,this.ChangeBegin=!1,this.ChangeEnd=!1,this.line=-3,this.EndSymbolPositionAndShape=void 0,this.ChangeBegin=t.ChangeBegin,this.ChangeEnd=t.ChangeEnd,this.pedalSymbol){case a.MusicSymbol.PEDAL_SYMBOL:this.vfStyle=n.default.Flow.PedalMarking.Styles.TEXT,this.EndSymbolPositionAndShape=new r.BoundingBox(this,e);break;case a.MusicSymbol.PEDAL_MIXED:this.vfStyle=i&&s?n.default.Flow.PedalMarking.Styles.BRACKET_OPEN_BOTH:i?n.default.Flow.PedalMarking.Styles.BRACKET_OPEN_BEGIN:s?n.default.Flow.PedalMarking.Styles.MIXED_OPEN_END:n.default.Flow.PedalMarking.Styles.MIXED;break;case a.MusicSymbol.PEDAL_BRACKET:default:this.vfStyle=i&&s?n.default.Flow.PedalMarking.Styles.BRACKET_OPEN_BOTH:i?n.default.Flow.PedalMarking.Styles.BRACKET_OPEN_BEGIN:s?n.default.Flow.PedalMarking.Styles.BRACKET_OPEN_END:n.default.Flow.PedalMarking.Styles.BRACKET}}setStartNote(t){if(!t)return!1;for(const e of t.graphicalVoiceEntries){const t=e;if(null==t?void 0:t.vfStaveNote)return this.startNote=t.vfStaveNote,this.startVfVoiceEntry=t,!0}return!1}setEndNote(t){if(!t)return!1;for(const e of t.graphicalVoiceEntries){const t=e;if(null==t?void 0:t.vfStaveNote)return this.endNote=t.vfStaveNote,this.endVfVoiceEntry=t,!0}return!1}setEndMeasure(t){this.endMeasure=t}CalculateBoundingBox(){}setLine(t){this.line=t}getPedalMarking(){const t=new n.default.Flow.PedalMarking([this.startNote,this.endNote]);return this.endMeasure&&t.setEndStave(this.endMeasure.getVFStave()),t.setStyle(this.vfStyle),t.setLine(this.line),t.setCustomText(this.DepressText,this.ReleaseText),this.endVfVoiceEntry&&!this.getPedal.EndsStave||(t.EndsStave=!0),this.getPedal.BeginsStave&&(t.BeginsStave=!0),t.ChangeBegin=this.ChangeBegin,t.ChangeEnd=this.ChangeEnd,t}setEndsStave(t,e){(null==e?void 0:e.gte(t.parentSourceMeasure.Duration))&&(this.getPedal.EndsStave=!0)}setBeginsStave(t,e){t&&0===e.RealValue&&(this.getPedal.BeginsStave=!0)}}e.VexFlowPedal=l},8041:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowSlur=e.CurvePositionEnum=void 0;var n,r=s(i(6368)).default.Flow;!function(t){t[t.NEAR_HEAD=1]="NEAR_HEAD",t[t.NEAR_TOP=2]="NEAR_TOP"}(n=e.CurvePositionEnum||(e.CurvePositionEnum={}));class o{constructor(t){this.vfStartNote=void 0,this.vfEndNote=void 0,this.parentSlur=t}static createFromVexflowSlur(t){return new o(t.parentSlur)}get vfSlur(){return this.parentSlur}curve_Options(){return{cps:[{x:0,y:10},{x:0,y:10}],invert:!1,position:n.NEAR_TOP,position_end:n.NEAR_TOP,spacing:2,thickness:2,x_shift:0,y_shift:10}}createVexFlowCurve(){this.vfCurve=new r.Curve(this.vfStartNote,this.vfEndNote,void 0)}}e.VexFlowSlur=o},9252:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowStaffEntry=void 0;const s=i(3023),n=i(5820),r=i(8640);class o extends s.GraphicalStaffEntry{constructor(t,e,i){super(t,e,i)}calculateXPosition(){const t=this.parentMeasure.getVFStave();let e=0;for(const i of this.graphicalVoiceEntries)if(i.vfStaveNote){if(i.vfStaveNote.setStave(t),!i.vfStaveNote.preFormatted)continue;i.applyBordersFromVexflow(),this.parentMeasure.ParentStaff.isTab?this.PositionAndShape.RelativePosition.x=(i.vfStaveNote.getAbsoluteX()+i.vfStaveNote.glyph.getWidth())/n.unitInPixels:this.PositionAndShape.RelativePosition.x=i.vfStaveNote.getBoundingBox().getX()/n.unitInPixels;const s=i.notes[0].sourceNote;s.isRest()&&s.Length.RealValue===this.parentMeasure.parentSourceMeasure.ActiveTimeSignature.RealValue&&(this.PositionAndShape.RelativePosition.x+=this.parentMeasure.parentSourceMeasure.Rules.WholeRestXShiftVexflow-.1,i.PositionAndShape.BorderLeft=-.7,i.PositionAndShape.BorderRight=.7),i.PositionAndShape.BorderLeftt.staffLine)),i=this.calculateModifierXOffsets(e,1),s=this.calculateModifierXOffsets(e,.5);t.forEach(((t,e)=>{t.baseFingeringXOffset=s[e],t.baseStringNumberXOffset=i[e]}))}calculateModifierXOffsets(t,e){const i=[];for(let s=0;s=0;o--){if(Math.abs(t[s]-t[o])<=e&&n===i[o]){n++,r=!0;break}r=!1}i.push(n)}return i}}e.VexFlowStaffEntry=o},4828:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowStaffLine=void 0;const s=i(9953),n=i(449);class r extends s.StaffLine{constructor(t,e){super(t,e),this.slursInVFStaffLine=[],this.alignmentManager=new n.AlignmentManager(this)}get SlursInVFStaffLine(){return this.slursInVFStaffLine}addVFSlurToVFStaffline(t){this.slursInVFStaffLine.push(t)}get AlignmentManager(){return this.alignmentManager}}e.VexFlowStaffLine=r},8790:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowTabMeasure=void 0;var n=s(i(6368)).default.Flow;const r=i(7330),o=i(8129),a=s(i(2043));class l extends r.VexFlowMeasure{constructor(t,e,i){super(t,e,i),this.isTabMeasure=!0}resetLayout(){var t;const e=null!==(t=this.ParentStaff.StafflineCount)&&void 0!==t?t:6;this.stave=new n.TabStave(0,0,0,{space_above_staff_ln:0,space_below_staff_ln:0,num_lines:e}),this.updateInstructionWidth()}graphicalMeasureCreatedCalculations(){for(let t=0,e=this.staffEntries.length;t1){const i=o.VexFlowConverter.StrokeTypeFromArpeggioType(e.type),s=new n.Stroke(i,{all_voices:this.rules.ArpeggiosGoAcrossVoices});this.rules.RenderArpeggios&&t.vfStaveNote.addStroke(0,s)}else a.default.debug(`[OSMD] arpeggio in measure ${this.MeasureNumber} could not be drawn.\n voice entry had less than two notes, arpeggio is likely between voice entries, not currently supported in Vexflow.`)}this.vfVoices[e.VoiceId].addTickable(t.vfStaveNote)}else this.vfVoices[e.VoiceId].addTickable(t.vfStaveNote)}}}}e.VexFlowTabMeasure=l},2942:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowTextMeasurer=void 0;const s=i(8129);e.VexFlowTextMeasurer=class{constructor(t){this.fontSize=20,this.fontSizeStandard=this.fontSize;const e=document.createElement("canvas");this.context=e.getContext("2d"),this.rules=t}computeTextWidthToHeightRatio(t,e,i,n,r=this.fontSize){return this.context.font=s.VexFlowConverter.font(r,i,e,this.rules,n),this.context.measureText(t).width/r}setFontSize(t=this.fontSizeStandard){return this.fontSize=t,t}}},5460:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowVoiceEntry=void 0;const s=i(5974),n=i(5820),r=i(7459);class o extends s.GraphicalVoiceEntry{constructor(t,e,i){super(t,e,i)}applyBordersFromVexflow(){const t=this.vfStaveNote;if(!t.getNoteHeadBeginX)return;const e=t.getBoundingBox(),i=t.getNoteHeadBeginX()-e.x;this.PositionAndShape.RelativePosition.y=e.y/n.unitInPixels,this.PositionAndShape.BorderTop=0,this.PositionAndShape.BorderBottom=e.h/n.unitInPixels,this.PositionAndShape.BorderLeft=-(i+t.width/2)/n.unitInPixels,this.PositionAndShape.BorderRight=(e.w-i)/n.unitInPixels}set vfStaveNote(t){this.mVexFlowStaveNote=t}get vfStaveNote(){return this.mVexFlowStaveNote}color(){var t;const e=this.rules.DefaultColorNotehead,i=this.rules.DefaultColorRest,s=this.rules.DefaultColorStem,n="#00000000";let o,a;const l=this.vfStaveNote;for(let s=0;s{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.VexflowStafflineNoteCalculator=void 0;const s=i(8640),n=i(4679),r=i(1649),o=i(289),a=i(908);class l{constructor(t){this.staffPitchListMapping=new r.Dictionary,this.baseLineNote=s.NoteEnum.B,this.baseLineOctave=1,this.rules=t}trackNote(t){if(!(t instanceof n.VexFlowGraphicalNote)||t.Clef().ClefType!==o.ClefEnum.percussion||t.sourceNote.isRest()||0===this.rules.PercussionOneLineCutoff||-1===this.rules.PercussionForceVoicesOneLineCutoff)return;const e=t.parentVoiceEntry.parentStaffEntry.sourceStaffEntry.ParentStaff.idInMusicSheet;let i;this.staffPitchListMapping.containsKey(e)||this.staffPitchListMapping.setValue(e,new Array),i=this.staffPitchListMapping.getValue(e);const s=t.sourceNote.Pitch;l.findOrInsert(i,s)}static PitchIndexOf(t,e,i=0){if(i>t.length-1)return-1;for(let s=i;sthis.rules.PercussionOneLineCutoff&&!r)return t;const o=t,h=t.sourceNote.Pitch;let c=this.baseLineNote,u=this.baseLineOctave;if(this.rules.PercussionUseXMLDisplayStep&&void 0!==t.sourceNote.displayStepUnpitched&&(c=t.sourceNote.displayStepUnpitched,u=t.sourceNote.displayOctaveUnpitched+this.rules.PercussionOneLineXMLDisplayStepOctaveOffset),i.length<=this.rules.PercussionForceVoicesOneLineCutoff)o.setAccidental(new s.Pitch(c,u,h.Accidental));else{const t=l.PitchIndexOf(i,h);if(t>-1){const e=Math.ceil(i.length/2);if(!this.rules.PercussionUseXMLDisplayStep)if(t>=e)switch(u=2,(t-e)%5){case 1:c=s.NoteEnum.E;break;case 2:c=s.NoteEnum.G;break;case 3:c=s.NoteEnum.B;break;case 4:c=s.NoteEnum.D,u=3;break;default:c=s.NoteEnum.C}else switch(t%5){case 1:c=s.NoteEnum.F;break;case 2:c=s.NoteEnum.D;break;case 3:c=s.NoteEnum.B,u=0;break;case 4:c=s.NoteEnum.G,u=0;break;default:c=s.NoteEnum.A}const n=new s.Pitch(c,u,h.Accidental);o.setAccidental(n);const r=o.parentVoiceEntry.parentVoiceEntry;!this.rules.SetWantedStemDirectionByXml&&r.Notes.length<2&&(n.Octave>this.baseLineOctave||n.FundamentalNote===this.baseLineNote&&n.Octave===this.baseLineOctave?o.parentVoiceEntry.parentVoiceEntry.WantedStemDirection=a.StemDirectionType.Up:o.parentVoiceEntry.parentVoiceEntry.WantedStemDirection=a.StemDirectionType.Down)}}return o}getStafflineUniquePositionCount(t){return this.staffPitchListMapping.containsKey(t)?this.staffPitchListMapping.getValue(t).length:0}}e.VexflowStafflineNoteCalculator=l},9839:function(t,e,i){"use strict";var s=this&&this.__createBinding||(Object.create?function(t,e,i,s){void 0===s&&(s=i);var n=Object.getOwnPropertyDescriptor(e,i);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,s,n)}:function(t,e,i,s){void 0===s&&(s=i),t[s]=e[i]}),n=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||s(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(i(449),e),n(i(4028),e),n(i(9505),e),n(i(709),e),n(i(9344),e),n(i(8129),e),n(i(3602),e),n(i(4679),e),n(i(8144),e),n(i(6351),e),n(i(8939),e),n(i(5575),e),n(i(7330),e),n(i(4405),e),n(i(8738),e),n(i(5820),e),n(i(8494),e),n(i(9520),e),n(i(8041),e),n(i(9252),e),n(i(4828),e),n(i(7781),e),n(i(8790),e),n(i(2942),e),n(i(5460),e)},7636:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLSkyBottomLineBatchCalculatorBackend=void 0;const n=i(1378),r=i(9531),o=s(i(6357)),a=s(i(6150)),l=s(i(2043)),h=i(2337);function c(t,e,i){const s=t.createShader(e);if(!s)throw l.default.warn("WebGLSkyBottomLineCalculatorBackend: Could not create a WebGL shader"),new Error("Could not create a WebGL shader");if(t.shaderSource(s,i),t.compileShader(s),!t.getShaderParameter(s,t.COMPILE_STATUS))throw l.default.warn("Shader compilation failed\n"+t.getShaderInfoLog(s)),t.deleteShader(s),new Error("WebGL shader compilation failed");return s}class u extends r.SkyBottomLineBatchCalculatorBackend{constructor(t,e){super(t,e)}getPreferredRenderingConfiguration(t,e){const i=Math.min(4096,function(){const t=document.createElement("canvas").getContext("webgl");return t.getParameter(t.MAX_TEXTURE_SIZE)}()),s=Math.ceil(t);return{elementWidth:s,numColumns:Math.min(5,Math.floor(i/s)),numRows:Math.min(5,Math.floor(i/e))}}onInitialize(t){const{elementWidth:e,elementHeight:i,numColumns:s,numRows:n}=t,r=document.createElement("canvas");r.width=e*s,r.height=n;const u=r.getContext("webgl");if(!u)throw l.default.warn("WebGLSkyBottomLineCalculatorBackend: No WebGL support"),new Error("No WebGL support");this.gl=u;const d=function(t,e,i){const s=t.createProgram();if(!s)throw l.default.warn("WebGLSkyBottomLineCalculatorBackend: Could not create a WebGL program"),new Error("Could not create a WebGL program");if(t.attachShader(s,e),t.attachShader(s,i),t.linkProgram(s),!t.getProgramParameter(s,t.LINK_STATUS))throw l.default.warn("WebGLSkyBottomLineCalculatorBackend: WebGL program link failed\n"+t.getProgramInfoLog(s)),t.deleteProgram(s),new Error("WebGL program link failed");return s}(u,c(u,u.VERTEX_SHADER,o.default),c(u,u.FRAGMENT_SHADER,function(t,e){let i=t;for(const[t,s]of Object.entries(e)){const e=new RegExp(`#define ${t} .*`);i=i.replace(e,`#define ${t} ${s}`)}return i}(a.default,{NUM_ROWS:n,ELEMENT_HEIGHT:i})));!function(t,e,i,s){const n=t.createBuffer();if(!n)throw l.default.warn("WebGLSkyBottomLineCalculatorBackend: WebGL buffer creation failed"),new Error("WebGL buffer creation failed");t.bindBuffer(t.ARRAY_BUFFER,n),t.bufferData(t.ARRAY_BUFFER,new Float32Array(h.CollectionUtil.flat([[-1,-1],[1,-1],[1,1],[-1,-1],[1,1],[-1,1]])),t.STATIC_DRAW),t.useProgram(e);const r=t.getAttribLocation(e,"a_position");t.enableVertexAttribArray(r),t.vertexAttribPointer(r,2,t.FLOAT,!1,0,0)}(u,d),this.texture=function(t,e,i,s){const n=t.createTexture();if(!n)throw l.default.warn("WebGLSkyBottomLineCalculatorBackend: WebGL texture creation failed"),new Error("WebGL texture creation failed");t.activeTexture(t.TEXTURE0+0),t.bindTexture(t.TEXTURE_2D,n),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST);const r=t.getUniformLocation(e,"u_image");if(!r)throw l.default.warn("WebGLSkyBottomLineCalculatorBackend: WebGL invalid uniform name"),new Error("WebGL invalid uniform name");return t.uniform1i(r,0),n}(u,d)}calculateFromCanvas(t,e,i,s,r){const o=this.gl,{elementWidth:a,elementHeight:l,numColumns:h}=r;o.viewport(0,0,o.canvas.width,o.canvas.height),o.bindTexture(o.TEXTURE_2D,this.texture),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,t),o.drawArrays(o.TRIANGLES,0,6);const c=new Uint8Array(o.canvas.width*o.canvas.height*4);o.readPixels(0,0,o.canvas.width,o.canvas.height,o.RGBA,o.UNSIGNED_BYTE,c);const u=[];for(let t=0;t{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Instrument=void 0;const s=i(884),n=i(2255),r=i(0);class o extends s.InstrumentalGroup{constructor(t,e,i,s){super(void 0,i,s),this.Transpose=0,this.voices=[],this.staves=[],this.hasLyrics=!1,this.hasChordSymbols=!1,this.lyricVersesNumbers=[],this.subInstruments=[],this.id=t,this.idString=e,this.nameLabel=new n.Label(e)}get Voices(){return this.voices}get Staves(){return this.staves}get NameLabel(){return this.nameLabel}get HasLyrics(){return this.hasLyrics}set HasLyrics(t){this.hasLyrics=t}get HasChordSymbols(){return this.hasChordSymbols}set HasChordSymbols(t){this.hasChordSymbols=t}get LyricVersesNumbers(){return this.lyricVersesNumbers}set LyricVersesNumbers(t){this.lyricVersesNumbers=t}get Name(){return this.nameLabel.text}set Name(t){this.nameLabel.text=t}get IdString(){return this.idString}get Id(){return this.id}get MidiInstrumentId(){return this.subInstruments[0].midiInstrumentID}set MidiInstrumentId(t){this.subInstruments[0].midiInstrumentID=t}get Volume(){return this.subInstruments[0].volume}set Volume(t){for(let e=0,i=this.subInstruments.length;e0&&this.Voices[0].Visible}set Visible(t){for(let e=0,i=this.Voices.length;e{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InstrumentalGroup=void 0,e.InstrumentalGroup=class{constructor(t,e,i){this.instrumentalGroups=[],this.name=t,this.musicSheet=e,this.parent=i}get InstrumentalGroups(){return this.instrumentalGroups}get Parent(){return this.parent}get Name(){return this.name}set Name(t){this.name=t}get GetMusicSheet(){return this.musicSheet}}},1035:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AClassHierarchyTrackable=void 0,e.AClassHierarchyTrackable=class{isInstanceOfClass(t){let e=this.constructor.prototype;for(;e;){if(t===e.constructor.name)return!0;e=e.__proto__}return!1}}},9603:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},7058:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},6287:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},4543:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},4207:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},6331:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ITextTranslation=void 0,e.ITextTranslation=class{static translateText(t,e){if(!this.defaultTextTranslation)return e}}},9984:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},4854:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},4143:function(t,e,i){"use strict";var s=this&&this.__createBinding||(Object.create?function(t,e,i,s){void 0===s&&(s=i);var n=Object.getOwnPropertyDescriptor(e,i);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,s,n)}:function(t,e,i,s){void 0===s&&(s=i),t[s]=e[i]}),n=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||s(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(i(9603),e),n(i(7058),e),n(i(6287),e),n(i(4207),e),n(i(6331),e),n(i(9984),e),n(i(4854),e),n(i(1035),e),n(i(4543),e)},2255:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Label=void 0;const s=i(1274);e.Label=class{constructor(t="",e=s.TextAlignmentEnum.CenterBottom,i,n=!0){this.IsCreditLabel=!1,this.text=t,this.print=n,this.textAlignment=e,this.font=i,this.fontFamily=void 0}ToString(){return this.text}}},5278:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TimestampTransform=e.MusicPartManager=void 0;const s=i(1797),n=i(301);e.MusicPartManager=class{constructor(t){this.musicSheet=t}reInit(){this.init()}init(){this.parts=this.musicSheet.Repetitions.slice(),this.sheetStart=this.musicSheet.SelectionStart=new s.Fraction(0,1),this.sheetEnd=this.musicSheet.SelectionEnd=this.musicSheet.SheetEndTimestamp,this.calcMapping()}getCurrentRepetitionTimestampTransform(t){let e;for(let i=this.timestamps.length-1;i>=0;i--)if(e=this.timestamps[i],t.gte(e.$from))return e;return this.timestamps[0]}absoluteEnrolledToSheetTimestamp(t){if(0===this.timestamps.length)return t;const e=this.getCurrentRepetitionTimestampTransform(t);return s.Fraction.plus(t,s.Fraction.minus(e.to,e.$from))}get Parts(){return this.parts}get MusicSheet(){return this.musicSheet}getIterator(t){return t?new n.MusicPartManagerIterator(this.musicSheet,t,void 0):new n.MusicPartManagerIterator(this.musicSheet,this.musicSheet.SelectionStart,this.musicSheet.SelectionEnd)}setSelectionStart(t){this.musicSheet.SelectionStart=t,this.musicSheet.SelectionEnd=void 0}setSelectionRange(t,e){this.musicSheet.SelectionStart=null!=t?t:this.sheetStart,this.musicSheet.SelectionEnd=null!=e?e:this.sheetEnd}calcMapping(){const t=[],e=this.getIterator();let i=e.CurrentRepetition,s=new r(e.CurrentEnrolledTimestamp.clone(),e.CurrentSourceTimestamp.clone(),void 0,0);for(t.push(s);!e.EndReached;){if(e.JumpOccurred||i!==e.CurrentRepetition){if(i=e.CurrentRepetition,e.backJumpOccurred){const i=e.JumpResponsibleRepetition;s.nextBackJump=e.CurrentEnrolledTimestamp,s.curRepetition=i,s.curRepetitionIteration=e.CurrentJumpResponsibleRepetitionIterationBeforeJump;for(let e=this.timestamps.length-2;e>=0&&!t[e].to.lt(i.AbsoluteTimestamp)&&!t[e].curRepetition;e--)t[e].nextBackJump=s.nextBackJump,t[e].curRepetition=i,t[e].curRepetitionIteration=s.curRepetitionIteration}s=new r(e.CurrentEnrolledTimestamp.clone(),e.CurrentSourceTimestamp.clone(),void 0,0),t.push(s)}e.moveToNext()}this.timestamps=t}};class r{constructor(t,e,i,s){this.$from=t,this.to=e,this.curRepetition=i,this.curRepetitionIteration=s,this.nextBackJump=void 0,this.nextForwardJump=void 0}}e.TimestampTransform=r},301:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.MusicPartManagerIterator=void 0;const n=i(1797),r=i(5356),o=i(3331),a=i(7839),l=s(i(2043));class h{constructor(t,e,i){this.currentMeasureIndex=0,this.currentPartIndex=0,this.currentVoiceEntryIndex=-1,this.currentDynamicEntryIndex=0,this.currentTempoEntryIndex=0,this.currentDynamicChangingExpressions=[],this.currentRepetition=void 0,this.endReached=!1,this.frontReached=!1,this.currentTimeStamp=new n.Fraction(0,1),this.currentEnrolledMeasureTimestamp=new n.Fraction(0,1),this.currentRelativeInMeasureTimestamp=new n.Fraction(0,1),this.currentVerticalContainerInMeasureTimestamp=new n.Fraction(0,1),this.jumpResponsibleRepetition=void 0,this.activeDynamicExpressions=[],this.SkipInvisibleNotes=!0;try{this.frontReached=!0,this.musicSheet=t,this.currentVoiceEntries=void 0,this.frontReached=!1;for(const t of this.musicSheet.Repetitions)this.setRepetitionIterationCount(t,1);if(this.activeDynamicExpressions=new Array(this.musicSheet.getCompleteNumberOfStaves()),this.currentMeasure=this.musicSheet.SourceMeasures[0],!e)return;do{this.moveToNext()}while((!this.currentVoiceEntries||this.currentTimeStamp.lt(e))&&!this.endReached);for(let t=0;t=this.JumpResponsibleRepetition.StartIndex&&i.EndIndex<=this.JumpResponsibleRepetition.EndIndex&&this.resetRepetitionIterationCount(i)}}handleRepetitionsAtMeasureEnd(){for(let t=0,e=this.currentMeasure.LastRepetitionInstructions.length;t-1&&this.getRepetitionIterationCount(i)=this.JumpResponsibleRepetition.StartIndex&&i.EndIndex<=this.JumpResponsibleRepetition.EndIndex&&this.resetRepetitionIterationCount(i);const t=i.getForwardJumpTargetForIteration(this.getRepetitionIterationCount(i));if(t>=0)return this.currentMeasureIndex=t,this.currentMeasure=this.musicSheet.SourceMeasures[this.currentMeasureIndex],this.currentVoiceEntryIndex=-1,this.jumpResponsibleRepetition=i,void(this.forwardJumpOccurred=!0);-2===t&&(this.endReached=!0)}}}this.currentMeasureIndex++,void 0!==this.JumpResponsibleRepetition&&this.currentMeasureIndex>this.JumpResponsibleRepetition.EndIndex&&(this.jumpResponsibleRepetition=void 0)}doBackJump(t){this.currentMeasureIndex=t.getBackwardJumpTarget(),this.currentMeasure=this.musicSheet.SourceMeasures[this.currentMeasureIndex],this.currentVoiceEntryIndex=-1,this.incrementRepetitionIterationCount(t),this.jumpResponsibleRepetition=t}activateCurrentRhythmInstructions(){if(void 0!==this.currentMeasure&&this.currentMeasure.FirstInstructionsStaffEntries.length>0&&void 0!==this.currentMeasure.FirstInstructionsStaffEntries[0]){const t=this.currentMeasure.FirstInstructionsStaffEntries[0].Instructions;for(let e=0,i=t.length;e0&&(this.currentDynamicEntryIndex>=t.length||this.CurrentSourceTimestamp.lte(t[this.currentDynamicEntryIndex].parMultiExpression().AbsoluteTimestamp));)this.currentDynamicEntryIndex--;for(;this.currentDynamicEntryIndex0&&(this.currentTempoEntryIndex>=e.length||this.CurrentSourceTimestamp.lte(e[this.currentTempoEntryIndex].AbsoluteTimestamp));)this.currentTempoEntryIndex--;for(;this.currentTempoEntryIndex0){this.currentVoiceEntryIndex--;const t=this.currentMeasure.VerticalSourceStaffEntryContainers[this.currentVoiceEntryIndex];this.currentVoiceEntries=this.getVoiceEntries(t),this.currentVerticalContainerInMeasureTimestamp=t.Timestamp,this.currentTimeStamp=n.Fraction.plus(this.currentMeasure.AbsoluteTimestamp,this.currentVerticalContainerInMeasureTimestamp),this.activateCurrentDynamicOrTempoInstructions();const e=this.musicSheet.SelectionEnd;return e&&this.currentTimeStamp.lt(e)&&(this.endReached=!1),void(this.currentMeasureIndex=this.musicSheet.SourceMeasures.indexOf(this.CurrentMeasure))}if(0!==this.currentVoiceEntryIndex||0===this.currentMeasureIndex)this.frontReached=!0,this.currentTimeStamp=new n.Fraction(-1,1);else{const t=this.musicSheet.SourceMeasures[this.currentMeasureIndex-1];this.currentMeasureIndex--,this.currentMeasure=this.musicSheet.SourceMeasures[this.currentMeasureIndex];const e=t.VerticalSourceStaffEntryContainers[t.VerticalSourceStaffEntryContainers.length-1];this.currentVoiceEntries=this.getVoiceEntries(e),this.currentVerticalContainerInMeasureTimestamp=e.Timestamp,this.currentVoiceEntryIndex=t.VerticalSourceStaffEntryContainers.length-1,this.currentTimeStamp=n.Fraction.plus(this.currentMeasure.AbsoluteTimestamp,e.Timestamp),this.activateCurrentDynamicOrTempoInstructions();const i=this.musicSheet.SelectionEnd;i&&this.currentTimeStamp.lt(i)&&(this.endReached=!1)}}recursiveMove(){if(this.currentVoiceEntryIndex++,0===this.currentVoiceEntryIndex&&(this.handleRepetitionsAtMeasureBegin(),this.activateCurrentRhythmInstructions()),this.currentVoiceEntryIndex>=0&&this.currentVoiceEntryIndex=0&&this.currentMeasureIndex0){if(!t)return!0;for(let t=0,i=e.length;t0){const t=this.TimestampSortedTempoExpressionsList[0];if(t.InstantaneousTempo)return t.InstantaneousTempo.TempoInBpm;if(t.ContinuousTempo)return t.ContinuousTempo.StartTempo}return this.userStartTempoInBPM}get Errors(){return this.musicSheetErrors.measureErrors}get FirstMeasureNumber(){try{return this.getFirstSourceMeasure().MeasureNumber}catch(t){return d.default.info("MusicSheet.FirstMeasureNumber: ",t),0}}get LastMeasureNumber(){try{return this.getLastSourceMeasure().MeasureNumber}catch(t){return d.default.info("MusicSheet.LastMeasureNumber: ",t),0}}get CurrentEnrolledPosition(){return this.currentEnrolledPosition.clone()}set CurrentEnrolledPosition(t){this.currentEnrolledPosition=t.clone()}get Transpose(){return this.transpose}set Transpose(t){this.transpose=t}get FullNameString(){return this.ComposerString+" "+this.TitleString}get IdString(){return this.idString}set IdString(t){this.idString=t}getEnrolledSelectionStartTimeStampWorkaround(){const t=this.MusicPartManager.getIterator(this.SelectionStart);return n.Fraction.createFromFraction(t.CurrentEnrolledTimestamp)}get SheetEndTimestamp(){const t=this.getLastSourceMeasure();return n.Fraction.plus(t.AbsoluteTimestamp,t.Duration)}getSourceMeasureFromTimeStamp(t){for(let e=0,i=this.sourceMeasures.length;e0&&i.Voices[0].Visible&&t.push(i)}return t}}e.MusicSheet=p,p.defaultTitle="defaultTitle"},6656:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MappingSourceMusicPart=void 0,e.MappingSourceMusicPart=class{constructor(t,e,i,s=-1,n=!1){this.repetitionRun=-1,this.sourceMusicPart=t,this.parentPartListEntry=i,this.startTimestamp=e.clone(),this.repetitionRun=s,this.parentRepetition=i,this.isEnding=n}get IsRepetition(){return void 0!==this.parentRepetition}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(t){return t?this.startTimestamp.CompareTo(t.startTimestamp):1}}},3766:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PartListEntry=void 0,e.PartListEntry=class{constructor(t){this.enrolledTimestamps=[],this.visible=!0,this.musicSheet=t}get Visible(){return this.visible}set Visible(t){this.visible=t}getFirstSourceMeasure(){return this.musicSheet.SourceMeasures[this.startIndex]}getLastSourceMeasure(){return this.musicSheet.SourceMeasures[this.endIndex]}}},1717:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.RepetitionEndingPart=e.Repetition=void 0;const n=i(8817),r=i(1797),o=i(3766),a=s(i(2043));class l extends o.PartListEntry{constructor(t,e){super(t),this.backwardJumpInstructions=[],this.endingParts=[],this.endingIndexDict={},this.userNumberOfRepetitions=0,this.visibles=[],this.fromWords=!1,this.repetitonIterationOrder=[],this.numberOfEndings=1,this.musicSheet2=t,this.virtualOverallRepetition=e}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 e=this.userNumberOfRepetitions-this.NumberOfEndings;for(let t=1;t<=this.userNumberOfRepetitions;t++)t<=e?this.repetitonIterationOrder.push(1):this.repetitonIterationOrder.push(t-e)}getForwardJumpTargetForIteration(t){const e=this.repetitonIterationOrder[t-1];return this.endingIndexDict[e]?this.endingIndexDict[e].part.StartIndex:-1}getBackwardJumpTarget(){return this.startMarker.measureIndex}SetEndingStartIndex(t,e){const i=new h(new n.SourceMusicPart(this.musicSheet2,e,e));this.endingParts.push(i);for(const e of t)try{this.endingIndexDict[e]=i,i.endingIndices.push(e),this.numberOfEndings{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SourceMusicPart=void 0;const s=i(3766),n=i(1797);class r extends s.PartListEntry{constructor(t,e,i){super(t),this.musicSheet=t,this.startIndex=e,this.endIndex=i}get MeasuresCount(){return this.endIndex-this.startIndex+1}get StartIndex(){return this.startIndex}get EndIndex(){return this.endIndex}get ParentRepetition(){return this.parentRepetition}set ParentRepetition(t){this.parentRepetition=t}get AbsoluteTimestamp(){return n.Fraction.createFromFraction(this.musicSheet.SourceMeasures[this.startIndex].AbsoluteTimestamp)}setStartIndex(t){this.startIndex=t}setEndIndex(t){this.endIndex=t}}e.SourceMusicPart=r},4990:function(t,e,i){"use strict";var s=this&&this.__createBinding||(Object.create?function(t,e,i,s){void 0===s&&(s=i);var n=Object.getOwnPropertyDescriptor(e,i);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,s,n)}:function(t,e,i,s){void 0===s&&(s=i),t[s]=e[i]}),n=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||s(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(i(6656),e),n(i(3766),e),n(i(1717),e),n(i(8817),e)},2393:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.InstrumentReader=void 0;const n=i(8109),r=i(9050),o=i(289),a=i(5198),l=i(3331),h=i(1797),c=i(6331),u=i(1703),d=i(289),f=i(3331),m=i(5198),p=s(i(2043)),b=i(289),g=i(2905),S=i(4671),y=i(3755),E=i(908),v=i(2478),x=i(6894);e.InstrumentReader=class{constructor(t,e,i,s){this.voiceGeneratorsDict={},this.staffMainVoiceGeneratorDict={},this.divisions=0,this.currentClefNumber=1,this.currentXmlMeasureIndex=0,this.activeKeyHasBeenInitialized=!1,this.abstractInstructions=[],this.repetitionInstructionReader=e,this.xmlMeasureList=i,this.musicSheet=s.GetMusicSheet,this.instrument=s,this.activeClefs=new Array(s.Staves.length),this.activeClefsHaveBeenInitialized=new Array(s.Staves.length);for(let t=0;t=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 o=new h.Fraction(0,1),a=new h.Fraction(0,1),l=!1;this.maxTieNoteFraction=new h.Fraction(0,1);let d=!1;try{const f=this.xmlMeasureList[this.currentXmlMeasureIndex],m=f.elements();if(t.Rules.UseXMLMeasureNumbers&&!Number.isInteger(t.MeasureNumberXML)){const e=parseInt(null===(s=f.attribute("number"))||void 0===s?void 0:s.value,10);Number.isInteger(e)&&(t.MeasureNumberXML=e)}let b;for(let s=0;s0&&(b=m[s-1]),"print"===f.name){const e=f.attribute("new-system");"yes"===(null==e?void 0:e.value)&&(t.printNewSystemXml=!0);const i=f.attribute("new-page");"yes"===(null==i?void 0:i.value)&&(t.printNewPageXml=!0)}else if("attributes"===f.name){const e=f.element("divisions");if(e&&(this.divisions=parseInt(e.value,10),isNaN(this.divisions))){const t=c.ITextTranslation.translateText("ReaderErrorMessages/DivisionError","Invalid divisions value at Instrument: ");if(p.default.debug("InstrumentReader.readNextXmlMeasure",t),this.divisions=this.readDivisionsFromNotes(),!(this.divisions>0))throw l=!0,new u.MusicSheetReadingException(t+this.instrument.Name);this.musicSheet.SheetErrors.push(t+this.instrument.Name)}if(!f.element("divisions")&&0===this.divisions&&0===this.currentXmlMeasureIndex){const t=c.ITextTranslation.translateText("ReaderErrorMessages/DivisionError","Invalid divisions value at Instrument: ");if(this.divisions=this.readDivisionsFromNotes(),!(this.divisions>0))throw l=!0,new u.MusicSheetReadingException(t+this.instrument.Name);this.musicSheet.SheetErrors.push(t+this.instrument.Name)}this.addAbstractInstruction(f,i,b,o.clone()),o.Equals(new h.Fraction(0,1))&&this.isAttributesNodeAtBeginOfMeasure(this.xmlMeasureList[this.currentXmlMeasureIndex],f)&&this.saveAbstractInstructionList(this.instrument.Staves.length,!0),this.isAttributesNodeAtEndOfMeasure(this.xmlMeasureList[this.currentXmlMeasureIndex],f,o)&&this.saveClefInstructionAtEndOfMeasure();const s=f.elements("staff-details");for(const t of s){const e=t.element("staff-lines");if(e){let i=1;const s=t.attribute("number");s&&(i=parseInt(s.value,10)),this.instrument.Staves[i-1].StafflineCount=parseInt(e.value,10)}}const n=f.element("measure-style");if(n){const e=n.element("multiple-rest");if(e){const i=e.value;let s=0;try{s=Number.parseInt(i,10),void 0!==t.multipleRestMeasures&&s!==t.multipleRestMeasures?t.multipleRestMeasures=0:(t.multipleRestMeasures=s,this.currentMultirestStartMeasure=t,this.followingMultirestMeasures=s+1)}catch(t){console.log("multirest parse error: "+t)}}}}else if("note"===f.name){let t=!0;"no"===(null===(n=f.attribute("print-object"))||void 0===n?void 0:n.value)&&(t=!1);const s=this.getNoteStaff(f);this.currentStaff=this.instrument.Staves[s-1];const r=void 0!==f.element("chord");if(f.element("voice")){const t=parseInt(f.element("voice").value,10);this.currentVoiceGenerator=this.getOrCreateVoiceGenerator(t,s-1)}else r&&this.currentVoiceGenerator||(this.currentVoiceGenerator=this.getOrCreateVoiceGenerator(1,s-1));let l,u=0,m=new h.Fraction(0,1),b=2,g=!1;if(f.element("duration")){if(u=parseInt(f.element("duration").value,10),isNaN(u)){const t=c.ITextTranslation.translateText("ReaderErrorMessages/NoteDurationError","Invalid Note Duration.");this.musicSheet.SheetErrors.pushMeasureError(t),p.default.debug("InstrumentReader.readNextXmlMeasure",t);continue}if(m=new h.Fraction(u,4*this.divisions),0===u?m=this.getNoteDurationFromTypeNode(f):l=this.getNoteDurationFromTypeNode(f),f.element("time-modification")){m=this.getNoteDurationForTuplet(f);const t=f.element("time-modification");(null==t?void 0:t.element("normal-notes"))&&(b=parseInt(t.element("normal-notes").value,10)),g=!0}}const S=void 0!==f.element("rest"),y=f.combinedElement("notations"),E=void 0!==f.element("grace")||0===u||r&&d;let v=!1,x=!1;if(E){const t=f.element("grace");t&&t.attributes()&&t.attribute("slash")&&"yes"===t.attribute("slash").value&&(v=!0),m=this.getNoteDurationFromTypeNode(f),y&&y.element("slur")&&(x=!0)}const[_,M]=this.getCueNoteAndNoteTypeXml(f),[w,P,T]=this.getStemDirectionAndColors(f);let L=0,A=!1;if(y){const t=y.element("ornaments");t&&(L=this.getTremoloStrokes(t),A=this.getVibratoStrokes(t))}const C=r?a.clone():o.clone();this.currentStaffEntry=this.currentMeasure.findOrCreateStaffEntry(C,this.inSourceMeasureInstrumentIndex+s-1,this.currentStaff).staffEntry,(!this.currentVoiceGenerator.hasVoiceEntry()||!r&&!E&&!d||E&&!d||E&&!r||!E&&d)&&this.currentVoiceGenerator.createVoiceEntry(C,this.currentStaffEntry,!S&&!E,E,v,x),E||r||(a=o.clone(),o.Add(m)),r&&void 0!==this.currentStaffEntry&&this.currentStaffEntry.ParentStaff!==this.currentStaff&&(this.currentStaffEntry=this.currentVoiceGenerator.checkForStaffEntryLink(this.inSourceMeasureInstrumentIndex+s-1,this.currentStaff,this.currentStaffEntry,this.currentMeasure));const I=void 0!==this.currentStaffEntry&&void 0!==this.currentStaffEntry.Timestamp&&this.currentStaffEntry.Timestamp.Equals(new h.Fraction(0,1))&&!this.currentStaffEntry.hasNotes();this.saveAbstractInstructionList(this.instrument.Staves.length,I),this.activeRhythm,g||E||(m=new h.Fraction(u,4*this.divisions));const R=f.elements("dot").length;if(this.currentVoiceGenerator.read(f,m,l,M,b,S,this.currentStaffEntry,this.currentMeasure,e,this.maxTieNoteFraction,r,i,t,_,E,w,L,P,T,A,R),void 0!==y&&y.element("dynamics")){const t=this.expressionReaders[this.readExpressionStaffNumber(f)-1];t&&(t.readExpressionParameters(f,this.instrument,this.divisions,o,a,this.currentMeasure.MeasureNumber,!1),t.read(f,this.currentMeasure,a))}d=E}else if("forward"===f.name){const t=parseInt(f.element("duration").value,10);o.Add(new h.Fraction(t,4*this.divisions))}else if("backup"===f.name){const t=parseInt(f.element("duration").value,10);o.Sub(new h.Fraction(t,4*this.divisions)),o.IsNegative()&&(o=new h.Fraction(0,1)),a.Sub(new h.Fraction(t,4*this.divisions)),a.IsNegative()&&(a=new h.Fraction(0,1))}else if("direction"===f.name){const t=f.element("direction-type");let e=Math.min(1,o.RealValue);void 0!==this.activeRhythm&&this.activeRhythm.Rhythm&&(e/=this.activeRhythm.Rhythm.RealValue);let i=!1;if(this.repetitionInstructionReader&&(i=this.repetitionInstructionReader.handleRepetitionInstructionsFromWordsOrSymbols(t,e)),!i){let e=this.expressionReaders[0];const i=this.readExpressionStaffNumber(f)-1;i0?this.musicSheet.SourceMeasures[0]:this.currentMeasure;const i=new o.ClefInstruction(d.ClefEnum.G,0,2);let s;e.FirstInstructionsStaffEntries[t]?(s=e.FirstInstructionsStaffEntries[t],s.removeFirstInstructionOfTypeClefInstruction()):(s=new r.SourceStaffEntry(void 0,void 0),e.FirstInstructionsStaffEntries[t]=s),i.Parent=s,s.Instructions.splice(0,0,i)}createDefaultKeyInstruction(){let t;t=this.musicSheet.SourceMeasures.length>0?this.musicSheet.SourceMeasures[0]:this.currentMeasure;const e=new a.KeyInstruction(void 0,0,m.KeyEnum.major);for(let i=this.inSourceMeasureInstrumentIndex;i0&&"backup"===i[s-1].name)return!0;let n=-1;for(let t=0;t0||n<0}isAttributesNodeAtEndOfMeasure(t,e,i){var s;if(i.Equals(null===(s=this.ActiveRhythm)||void 0===s?void 0:s.Rhythm))return!0;const n=t.elements().slice();let r=0;for(let t=0;to}getNoteDurationFromTypeNode(t){const e=t.element("type");if(e){const t=e.value;return v.NoteTypeHandler.getNoteDurationFromType(t)}return new h.Fraction(0,4*this.divisions)}addAbstractInstruction(t,e,i,s){if(t.element("divisions")&&1===t.elements().length)return;const n=t.element("transpose");if(n){const t=n.element("chromatic");t&&(this.instrument.PlaybackTranspose=parseInt(t.value,10))}const r=t.elements("clef");let u;if(r.length>0)for(let t=0,e=r.length;tthis.currentClefNumber&&(a=this.currentClefNumber),this.currentClefNumber=a+1}catch(t){u=c.ITextTranslation.translateText("ReaderErrorMessages/ClefError","Invalid clef. Using default."),this.musicSheet.SheetErrors.pushMeasureError(u),a=1,this.currentClefNumber=a+1}const b=new o.ClefInstruction(i,l,n);this.abstractInstructions.push([a,b,s])}if(void 0!==t.element("key")&&this.instrument.MidiInstrumentId!==b.MidiInstrument.Percussion){let e=0;const i=t.element("key").element("fifths");if(i)try{e=parseInt(i.value,10)}catch(t){u=c.ITextTranslation.translateText("ReaderErrorMessages/KeyError","Invalid key. Set to default."),this.musicSheet.SheetErrors.pushMeasureError(u),e=0,p.default.debug("InstrumentReader.addAbstractInstruction",u,t)}let n=m.KeyEnum.none,r=t.element("key");if(r&&(r=r.element("mode")),r)try{n=m.KeyEnum[r.value]}catch(t){u=c.ITextTranslation.translateText("ReaderErrorMessages/KeyError","Invalid key/mode. Set to default."),this.musicSheet.SheetErrors.pushMeasureError(u),n=m.KeyEnum.major,p.default.debug("InstrumentReader.addAbstractInstruction",u,t)}const o=new a.KeyInstruction(void 0,e,n);this.abstractInstructions.push([1,o,s])}if(t.element("time")){const e=t.element("time");let i=f.RhythmSymbolEnum.NONE,n=!0;if(void 0!==e&&e.hasAttributes){const t=e.attribute("symbol");t&&("common"===t.value?i=f.RhythmSymbolEnum.COMMON:"cut"===t.value&&(i=f.RhythmSymbolEnum.CUT));const s=e.attribute("print-object");s&&"no"===s.value&&(n=!1)}let r=0,o=0;const a=e&&void 0!==e.element("senza-misura"),d=t.elements("time"),m=[],b=[];for(let t=0,e=d.length;t0&&void 0!==b&&m.length===b.length){const t=m.length,e=new Array(t);let i=0;for(let s=0;s=0;i--){const s=this.abstractInstructions[i],n=s[0],h=s[1],c=s[2];if(h instanceof o.ClefInstruction){const t=h;if(0===this.currentXmlMeasureIndex||n<=this.activeClefs.length&&t!==this.activeClefs[n-1])if(e||void 0===this.currentStaffEntry||this.currentStaffEntry.hasNotes()||n-1!==this.instrument.Staves.indexOf(this.currentStaffEntry.ParentStaff))if(e){if(0!==c.RealValue)continue;let e;if(this.currentMeasure){const s=t,a=this.inSourceMeasureInstrumentIndex+n-1,l=this.currentMeasure.FirstInstructionsStaffEntries[a];if(0===this.currentXmlMeasureIndex)if(l)if(void 0===this.currentMeasure.FirstInstructionsStaffEntries[a]||l.Instructions[0]instanceof o.ClefInstruction){const t=new r.SourceStaffEntry(void 0,void 0);this.currentMeasure.LastInstructionsStaffEntries[a]=t,s.Parent=t,t.Instructions.push(s)}else e=l,s.Parent=e,e.removeFirstInstructionOfTypeClefInstruction(),e.Instructions.splice(0,0,s),this.activeClefsHaveBeenInitialized[n-1]=!0;else e=new r.SourceStaffEntry(void 0,void 0),this.currentMeasure.FirstInstructionsStaffEntries[a]=e,s.Parent=e,e.Instructions.push(s),this.activeClefsHaveBeenInitialized[n-1]=!0;else if(this.activeClefsHaveBeenInitialized[n-1]){let t=this.previousMeasure;this.followingMultirestMeasures>0&&this.currentMeasure.Rules.RenderMultipleRestMeasures&&(t=this.currentMultirestStartMeasure);const e=new r.SourceStaffEntry(void 0,void 0);t.LastInstructionsStaffEntries[a]=e,s.Parent=e,e.Instructions.push(s)}else{const t=this.musicSheet.SourceMeasures[0];t.FirstInstructionsStaffEntries[a]?(e=t.FirstInstructionsStaffEntries[a],e.removeFirstInstructionOfTypeClefInstruction()):e=new r.SourceStaffEntry(void 0,void 0),s.Parent=e,e.Instructions.splice(0,0,s),this.activeClefsHaveBeenInitialized[n-1]=!0}this.activeClefs[n-1]=t,this.abstractInstructions.splice(i,1)}}else{let e;const s=this.activeRhythm.Rhythm;s.RealValue>0&&c.RealValue/s.RealValue>.9&&(this.currentMeasure.LastInstructionsStaffEntries[n-1]||(this.currentMeasure.LastInstructionsStaffEntries[n-1]=new r.SourceStaffEntry(void 0,this.instrument.Staves[n-1])),e=this.currentMeasure.LastInstructionsStaffEntries[n-1]),e&&(t.Parent=e,e.Instructions.push(t),this.activeClefs[n-1]=t,this.abstractInstructions.splice(i,1))}else{const e=t,s=this.currentStaffEntry;if(c&&Math.abs(c.RealValue-s.Timestamp.RealValue)>.01)continue;e.Parent=s,s.removeFirstInstructionOfTypeClefInstruction(),s.Instructions.push(e),this.activeClefs[n-1]=t,this.abstractInstructions.splice(i,1)}else n<=this.activeClefs.length&&t===this.activeClefs[n-1]&&this.abstractInstructions.splice(i,1)}if(h instanceof a.KeyInstruction){const e=h;if(this.activeKey&&this.activeKey.Key===e.Key)this.abstractInstructions.splice(i,1);else{let s;if(this.activeKey=e,this.abstractInstructions.splice(i,1),this.activeKeyHasBeenInitialized?s=this.currentMeasure:(this.activeKeyHasBeenInitialized=!0,s=this.currentXmlMeasureIndex>0?this.musicSheet.SourceMeasures[0]:this.currentMeasure),s)for(let i=this.inSourceMeasureInstrumentIndex;i=0;t--){const e=this.abstractInstructions[t][0],i=this.abstractInstructions[t][1];if(i instanceof o.ClefInstruction){const s=i;if(!this.activeClefs[e-1]||s.ClefType!==this.activeClefs[e-1].ClefType||s.ClefType===this.activeClefs[e-1].ClefType&&s.Line!==this.activeClefs[e-1].Line){const i=new r.SourceStaffEntry(void 0,void 0);this.currentMeasure.LastInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex+e-1]=i;const n=s;n.Parent=i,i.Instructions.push(n),this.activeClefs[e-1]=s,this.abstractInstructions.splice(t,1)}}}}getNoteDurationForTuplet(t){let e=new h.Fraction(0,1);const i=this.getNoteDurationFromTypeNode(t);if(t.element("time-modification")){const s=t.element("time-modification");if(s&&void 0!==s.element("actual-notes")&&s.element("normal-notes")){const t=s.element("actual-notes"),n=s.element("normal-notes");if(void 0!==t&&n){const s=parseInt(t.value,10),r=parseInt(n.value,10);e=new h.Fraction(r*i.Numerator,s*i.Denominator)}}}return e}readExpressionStaffNumber(t){let e=1;if(t.element("staff")){const i=t.element("staff");if(i)try{e=parseInt(i.value,10)}catch(t){const i=c.ITextTranslation.translateText("ReaderErrorMessages/ExpressionStaffError","Invalid Expression staff number. Set to default.");this.musicSheet.SheetErrors.pushMeasureError(i),e=1,p.default.debug("InstrumentReader.readExpressionStaffNumber",i,t)}}return e}readDivisionsFromNotes(){let t=0,e=this.currentXmlMeasureIndex,i=!1;for(;!i;){const s=this.xmlMeasureList[e].elements();for(let e=0,n=s.length;e0){i=!0;break}}if(0===t&&(e++,e===this.xmlMeasureList.length)){const t=c.ITextTranslation.translateText("ReaderErrorMEssages/DivisionsError","Invalid divisions value at Instrument: ");throw new u.MusicSheetReadingException(t+this.instrument.Name)}}return t}getCueNoteAndNoteTypeXml(t){let e=!1;t.element("cue")&&(e=!0);const i=t.element("type");let s=v.NoteType.UNDEFINED;if(i){const t=i.attribute("size");"cue"===(null==t?void 0:t.value)&&(e=!0),s=v.NoteTypeHandler.StringToNoteType(i.value)}return[e,s]}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 e=t.element("notehead");if(e){const t=e.attribute("color");if(t)return this.parseXmlColor(t.value)}return null}getNoteColorXml(t){const e=t.attribute("color");return e?this.parseXmlColor(e.value):null}getTremoloStrokes(t){const e=t.element("tremolo");if(e){const t=e.attribute("type");if(t&&"single"===t.value){const t=parseInt(e.value,10);if(t>0)return t}}return 0}getVibratoStrokes(t){const e=t.element("wavy-line");if(void 0!==e){const t=e.attribute("type");if(t&&"start"===t.value)return!0}return!1}getNoteStaff(t){let e=1;return this.instrument.Staves.length>1&&t.element("staff")&&(e=parseInt(t.element("staff").value,10),isNaN(e)&&(p.default.debug("InstrumentReader.readNextXmlMeasure.get staff number"),e=1)),e}}},1372:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.MusicSheetReader=void 0;const n=i(7514),r=i(5942),o=i(1797),a=i(2393),l=i(6842),h=i(6331),c=i(1703),u=s(i(2043)),d=i(3331),f=i(3331),m=i(9050),p=i(884),b=i(5142),g=i(289),S=i(2255),y=i(8736),E=i(1405),v=i(2458),x=i(1274);class _{constructor(t,e=new E.EngravingRules){this.completeNumberOfStaves=0,this.pluginManager=new v.ReaderPluginManager,this.afterSheetReadingModules=t||[],this.repetitionInstructionReader=y.MusicSymbolModuleFactory.createRepetitionInstructionReader(),this.repetitionCalculator=y.MusicSymbolModuleFactory.createRepetitionCalculator(),this.rules=e}get PluginManager(){return this.pluginManager}get CompleteNumberOfStaves(){return this.completeNumberOfStaves}static doCalculationsAfterDurationHasBeenSet(t){for(const e of t)e.doCalculationsAfterDurationHasBeenSet()}createMusicSheet(t,e){try{return this._createMusicSheet(t,e)}catch(t){return void u.default.error("MusicSheetReader.CreateMusicSheet",t)}}_removeFromArray(t,e){const i=t.indexOf(e);-1!==i&&t.splice(i,1)}trimString(t){return t.replace(/^\s+|\s+$/g,"")}_lastElement(t){return t[t.length-1]}_createMusicSheet(t,e){const i=[];let s=0;if(this.musicSheet=new n.MusicSheet,this.musicSheet.Path=e,this.musicSheet.Rules=this.rules,!t)throw new c.MusicSheetReadingException("Undefined root element");this.pushSheetLabels(t,e);const a=t.element("part-list");if(!a)throw new c.MusicSheetReadingException("Undefined partListNode");const l=t.elements("part"),u=a.elements();this.initializeReading(u,l,i);let d=!0;this.currentFraction=new o.Fraction(0,1);let f=!1,m=t.element("identification");for(m&&(m=m.element("encoding")),m&&(m=m.element("software")),void 0!==m&&"Guitar Pro 5"===m.value&&(f=!0);d;){void 0!==this.currentMeasure&&this.currentMeasure.HasEndLine&&this.rules.NewPartAndSystemAfterFinalBarline&&(s=0),this.currentMeasure=new r.SourceMeasure(this.completeNumberOfStaves,this.musicSheet.Rules);for(const t of i)try{d=d&&t.readNextXmlMeasure(this.currentMeasure,this.currentFraction,f)}catch(t){const e=h.ITextTranslation.translateText("ReaderErrorMessages/InstrumentError","Error while reading instruments.");throw new c.MusicSheetReadingException(e,t)}d&&(this.musicSheet.addMeasure(this.currentMeasure),this.checkIfRhythmInstructionsAreSetAndEqual(i),this.checkSourceMeasureForNullEntries(),s=this.setSourceMeasureDuration(i,s),_.doCalculationsAfterDurationHasBeenSet(i),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 t=0,e=this.afterSheetReadingModules.length;ti){if(this.areRhythmInstructionsMixed(e)&&n.SymbolEnum!==f.RhythmSymbolEnum.NONE)continue;i=n.Rhythm.RealValue,s=e.indexOf(n)}}if(e.length>0&&e.lengtht.Denominator){const i=e.Denominator/t.Denominator;t.expand(i)}}checkIfMeasureIsImplicit(t,e){return!(this.previousMeasure||!t.lt(e))||!!this.previousMeasure&&o.Fraction.plus(this.previousMeasure.Duration,t).Equals(e)}allInstrumentsHaveSameDuration(t,e){let i=0;for(let s=0,n=t.length;s=0;t--)for(let e=this.currentMeasure.VerticalSourceStaffEntryContainers[t].StaffEntries.length-1;e>=0;e--){const i=this.currentMeasure.VerticalSourceStaffEntryContainers[t].StaffEntries[e];if(i)for(let t=i.VoiceEntries.length-1;t>=0;t--){const e=i.VoiceEntries[t];0===e.Notes.length&&(this._removeFromArray(e.ParentVoice.VoiceEntries,e),this._removeFromArray(i.VoiceEntries,e))}void 0!==i&&0===i.VoiceEntries.length&&(this.currentMeasure.VerticalSourceStaffEntryContainers[t].StaffEntries[e]=void 0)}for(let t=this.currentMeasure.VerticalSourceStaffEntryContainers.length-1;t>=0;t--){let e=0;for(let i=0,s=this.currentMeasure.VerticalSourceStaffEntryContainers[t].StaffEntries.length;i0){const t=e[0].elements("rights");if(t.length>0)for(let e=0,i=t.length;en){if(!this.musicSheet.Title){const e=null===(s=t.attribute("font-size"))||void 0===s?void 0:s.value;if(e){const i=parseFloat(e);l0&&n.MidiInstrumentId!==g.MidiInstrument.Percussion&&(t.midiInstrumentID=Math.max(0,parseInt(s.value,10)-1));else if("midi-unpitched"===s.name)t.fixedKey=Math.max(0,parseInt(s.value,10));else if("volume"===s.name)try{const e=parseFloat(s.value);t.volume=e/127}catch(t){u.default.debug("ExpressionReader.readExpressionParameters","read volume",t)}else if("pan"===s.name)try{const e=parseFloat(s.value);t.pan=e/64}catch(t){u.default.debug("ExpressionReader.readExpressionParameters","read pan",t)}}catch(t){u.default.info("MusicSheetReader.createInstrumentGroups midi settings: ",t)}}}}catch(t){u.default.info("MusicSheetReader.createInstrumentGroups: ",t)}}if(0===n.SubInstruments.length){const t=new b.SubInstrument(n);n.SubInstruments.push(t)}i[t]=n,s?(s.InstrumentalGroups.push(n),this.musicSheet.Instruments.push(n)):(this.musicSheet.InstrumentalGroups.push(n),this.musicSheet.Instruments.push(n))}else if("part-group"===r.name&&"start"===r.attribute("type").value){const t=new p.InstrumentalGroup("group",this.musicSheet,s);s?s.InstrumentalGroups.push(t):this.musicSheet.InstrumentalGroups.push(t),s=t}else if("part-group"===r.name&&"stop"===r.attribute("type").value&&s){if(1===s.InstrumentalGroups.length){const t=s.InstrumentalGroups[0];s.Parent?(s.Parent.InstrumentalGroups.push(t),this._removeFromArray(s.Parent.InstrumentalGroups,s)):(this.musicSheet.InstrumentalGroups.push(t),this._removeFromArray(this.musicSheet.InstrumentalGroups,s))}s=s.Parent}}}catch(t){const e=h.ITextTranslation.translateText("ReaderErrorMessages/InstrumentError","Error while reading Instruments");throw new c.MusicSheetReadingException(e,t)}for(let t=0,e=this.musicSheet.Instruments.length;t0){const i=t[0];if(i){let t=i.element("attributes");t&&(t=t.element("staves")),t?e+=parseInt(t.value,10):e++}}}if(isNaN(e)||e<=0){const t=h.ITextTranslation.translateText("ReaderErrorMessages/StaffError","Invalid number of staves.");throw new c.MusicSheetReadingException(t)}return e}getInstrumentNumberOfStavesFromXml(t){let e=0;const i=t.element("measure");if(i){const t=i.element("attributes");let s;t&&(s=t.element("staves")),e=t&&s?parseInt(s.value,10):1}if(isNaN(e)||e<=0){const t=h.ITextTranslation.translateText("ReaderErrorMessages/StaffError","Invalid number of Staves.");throw new c.MusicSheetReadingException(t)}return e}}e.MusicSheetReader=_},8736:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MusicSymbolModuleFactory=void 0;const s=i(9934),n=i(6789);e.MusicSymbolModuleFactory=class{static createRepetitionInstructionReader(){return new s.RepetitionInstructionReader}static createRepetitionCalculator(){return new n.RepetitionCalculator}}},7677:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.ArticulationReader=void 0;const n=i(908),r=s(i(2043)),o=i(1357),a=i(5922),l=i(3748),h=i(8640),c=i(1662),u=i(6943),d=i(8084);e.ArticulationReader=class{constructor(t){this.rules=t}getAccEnumFromString(t){switch(t){case"sharp":return h.AccidentalEnum.SHARP;case"flat":return h.AccidentalEnum.FLAT;case"natural":return h.AccidentalEnum.NATURAL;case"double-sharp":case"sharp-sharp":return h.AccidentalEnum.DOUBLESHARP;case"double-flat":case"flat-flat":return h.AccidentalEnum.DOUBLEFLAT;case"triple-sharp":return h.AccidentalEnum.TRIPLESHARP;case"triple-flat":return h.AccidentalEnum.TRIPLEFLAT;case"quarter-sharp":return h.AccidentalEnum.QUARTERTONESHARP;case"quarter-flat":return h.AccidentalEnum.QUARTERTONEFLAT;case"three-quarters-sharp":return h.AccidentalEnum.THREEQUARTERSSHARP;case"three-quarters-flat":return h.AccidentalEnum.THREEQUARTERSFLAT;case"slash-quarter-sharp":return h.AccidentalEnum.SLASHQUARTERSHARP;case"slash-sharp":return h.AccidentalEnum.SLASHSHARP;case"double-slash-flat":return h.AccidentalEnum.DOUBLESLASHFLAT;case"sori":return h.AccidentalEnum.SORI;case"koron":return h.AccidentalEnum.KORON;default:return h.AccidentalEnum.NONE}}addArticulationExpression(t,e){var i,s;if(void 0!==t&&t.elements().length>0){const o=t.elements();for(let t=0,a=o.length;t0&&e.Articulations[0].articulationEnum!==n.ArticulationEnum.staccato&&e.Articulations.splice(0,0,f);else if("breathmark"===h)r===l.PlacementEnum.NotYetDefined&&(f.placement=l.PlacementEnum.Above);else if("strongaccent"===h){const t=null===(s=null==a?void 0:a.attribute("type"))||void 0===s?void 0:s.value;"up"===t?f.articulationEnum=n.ArticulationEnum.marcatoup:"down"===t&&(f.articulationEnum=n.ArticulationEnum.marcatodown)}else if(t===n.ArticulationEnum.softaccent){const t=e.ParentSourceStaffEntry.ParentStaff.Id-1;r===l.PlacementEnum.NotYetDefined&&(r=l.PlacementEnum.Above,t>0&&(r=l.PlacementEnum.Below));const i=e.ParentSourceStaffEntry.VerticalContainerParent.ParentMeasure,s=new u.MultiExpression(i,e.Timestamp);s.StartingContinuousDynamic=new d.ContinuousDynamicExpression(d.ContDynamicEnum.crescendo,r,t,i,-1),s.StartingContinuousDynamic.IsStartOfSoftAccent=!0,s.StartingContinuousDynamic.StartMultiExpression=s,s.StartingContinuousDynamic.EndMultiExpression=s,s.EndingContinuousDynamic=new d.ContinuousDynamicExpression(d.ContDynamicEnum.diminuendo,r,t,i,-1),s.EndingContinuousDynamic.StartMultiExpression=s,s.EndingContinuousDynamic.EndMultiExpression=s,i.StaffLinkedExpressions[t].push(s)}e.hasArticulation(f)||e.Articulations.push(f)}}catch(t){const e="Invalid note articulation.";return void r.default.debug("addArticulationExpression",e,t)}}}}addFermata(t,e){var i;let s=n.ArticulationEnum.fermata;t.attributes().length>0&&t.attribute("type")&&"inverted"===t.attribute("type").value&&(s=n.ArticulationEnum.invertedfermata);let r=l.PlacementEnum.Above;"below"===(null===(i=t.attribute("placement"))||void 0===i?void 0:i.value)&&(r=l.PlacementEnum.Below),e.Articulations.push(new c.Articulation(s,r))}addTechnicalArticulations(t,e,i){var s,r;const a={bend:n.ArticulationEnum.bend,"down-bow":n.ArticulationEnum.downbow,"open-string":n.ArticulationEnum.naturalharmonic,"snap-pizzicato":n.ArticulationEnum.snappizzicato,stopped:n.ArticulationEnum.lefthandpizzicato,"up-bow":n.ArticulationEnum.upbow,harmonic:n.ArticulationEnum.naturalharmonic};for(const i in a){if(!a.hasOwnProperty(i))continue;const n=a[i],o=t.element(i);if(o){let t;"above"===(null===(s=o.attribute("placement"))||void 0===s?void 0:s.value)&&(t=l.PlacementEnum.Above),"below"===(null===(r=o.attribute("placement"))||void 0===r?void 0:r.value)&&(t=l.PlacementEnum.Below);const i=new c.Articulation(n,t);e.hasArticulation(i)||e.Articulations.push(i)}}const h=t.element("fingering");if(h){const t=this.createTechnicalInstruction(h,i);t.type=o.TechnicalInstructionType.Fingering,i.Fingering=t,e.TechnicalInstructions.push(t)}const u=t.element("string");if(u){const t=this.createTechnicalInstruction(u,i);t.type=o.TechnicalInstructionType.String,i.StringInstruction=t,e.TechnicalInstructions.push(t)}}createTechnicalInstruction(t,e){const i=new o.TechnicalInstruction;i.sourceNote=e,i.value=t.value;const s=t.attribute("placement");return this.rules.FingeringPositionFromXML&&(i.placement=this.getPlacement(s)),i}getPlacement(t,e=l.PlacementEnum.NotYetDefined){if(e!==l.PlacementEnum.NotYetDefined)return e;if(!t)return l.PlacementEnum.NotYetDefined;switch(t.value){case"above":return l.PlacementEnum.Above;case"below":return l.PlacementEnum.Below;case"left":return l.PlacementEnum.Left;case"right":return l.PlacementEnum.Right;default:return l.PlacementEnum.NotYetDefined}}addOrnament(t,e){if(t){let i;const s={"delayed-inverted-turn":a.OrnamentEnum.DelayedInvertedTurn,"delayed-turn":a.OrnamentEnum.DelayedTurn,"inverted-mordent":a.OrnamentEnum.InvertedMordent,"inverted-turn":a.OrnamentEnum.InvertedTurn,mordent:a.OrnamentEnum.Mordent,"trill-mark":a.OrnamentEnum.Trill,turn:a.OrnamentEnum.Turn};for(const e in s){if(!s.hasOwnProperty(e))continue;const n=t.element(e);if(n){i=new a.OrnamentContainer(s[e]);const t=n.attribute("placement");t&&"below"===t.value&&(i.placement=l.PlacementEnum.Below)}}if(i){const s=t.elements("accidental-mark");if(s){let t=l.PlacementEnum.Below,e=h.AccidentalEnum.NONE;const n=s;for(let s=0,r=n.length;s0?s.RealValue>0?(c=n.Fraction.multiply(n.Fraction.minus(s,r),c),this.directionTimestamp=n.Fraction.plus(c,s)):this.directionTimestamp=n.Fraction.createFromFraction(c):this.offsetDivisions<0&&(s.RealValue>0?(c=n.Fraction.multiply(n.Fraction.minus(s,r),c),this.directionTimestamp=n.Fraction.minus(s,c)):this.directionTimestamp=n.Fraction.createFromFraction(c));const u=t.element("direction-type");let d;if(u&&(d=u.element("wedge"),d)){const t=d.attribute("default-y");t&&(h=this.readPosition(t))}this.WedgeYPosXml=h;const f=t.attribute("placement");if(f)try{const t=f.value;"below"===t?this.placement=m.PlacementEnum.Below:"above"===t&&(this.placement=m.PlacementEnum.Above)}catch(t){const e=b.ITextTranslation.translateText("ReaderErrorMessages/ExpressionPlacementError","Invalid expression placement -> set to default.");g.default.debug("ExpressionReader.readExpressionParameters",e,t),this.musicSheet.SheetErrors.pushMeasureError(e),this.placement=m.PlacementEnum.Below}if(this.placement===m.PlacementEnum.NotYetDefined)try{if(u){const t=u.element("dynamics");if(t){const e=t.attribute("default-y");e&&this.readExpressionPlacement(e,"read dynamics y pos")}if(d){const t=d.attribute("default-y");t&&this.readExpressionPlacement(t,"read wedge y pos")}const e=u.element("words");if(e){const t=e.attribute("default-y");t&&this.readExpressionPlacement(t,"read words y pos")}const i=u.element("rehearsal");if(i){const t=i.attribute("default-y");t&&this.readExpressionPlacement(t,"read rehearsal pos")}}}catch(t){const e=b.ITextTranslation.translateText("ReaderErrorMessages/ExpressionPlacementError","Invalid expression placement. Set to default.");g.default.debug("ExpressionReader.readExpressionParameters",e,t),this.musicSheet.SheetErrors.pushMeasureError(e),this.placement=m.PlacementEnum.Below}this.placement===m.PlacementEnum.NotYetDefined&&(e.Staves.length>1?this.placement=m.PlacementEnum.Below:e.HasLyrics?this.placement=m.PlacementEnum.Above:this.placement=m.PlacementEnum.Below)}read(t,e,i,s){let r=!1,o=!1;const a=t.element("sound");if(a){const t=a.attribute("tempo"),i=a.attribute("dynamics");if(t){const i=t.value.match(/^(\d+)(\.\d+)?$/);(null==i?void 0:i.length)>0?this.soundTempo=Math.round(Number.parseFloat(t.value)):(g.default.info("invalid xml tempo: "+t.value),this.soundTempo=100),e.TempoInBPM=this.soundTempo,0===this.musicSheet.DefaultStartTempoInBpm&&(this.musicSheet.DefaultStartTempoInBpm=this.soundTempo),this.musicSheet.HasBPMInfo=!0,r=!0}if(i){const t=i.value.match(/\d+/);this.soundDynamic=void 0!==t?parseInt(t[0],10):100,o=!0}}const l=t.element("direction-type");if(!l)return;let h=l.element("metronome");if(h){const t=h.element("beat-unit"),s=void 0!==h.element("beat-unit-dot"),r=h.element("per-minute");if(void 0!==t&&r){h.hasAttributes&&void 0!==h.attribute("default-x")&&(this.directionTimestamp=n.Fraction.createFromFraction(i));const o=parseFloat(r.value);this.createNewTempoExpressionIfNeeded(e);const a=new u.InstantaneousTempoExpression(void 0,this.placement,this.staffNumber,o,this.currentMultiTempoExpression,!0);a.parentMeasure=e,this.soundTempo=o,e.TempoInBPM=this.soundTempo*(s?1.5:1),0===this.musicSheet.DefaultStartTempoInBpm&&(this.musicSheet.DefaultStartTempoInBpm=this.soundTempo),this.musicSheet.HasBPMInfo=!0,a.dotted=s,a.beatUnit=t.value,this.currentMultiTempoExpression.addExpression(a,""),this.currentMultiTempoExpression.CombinedExpressionsText="test"}}else if(h=l.element("dynamics"),h){const s=void 0!==t.element("notations");this.interpretInstantaneousDynamics(h,e,i,s)}else if(h=l.element("words"),h)if(r){this.createNewTempoExpressionIfNeeded(e),this.currentMultiTempoExpression.CombinedExpressionsText=h.value;const t=new u.InstantaneousTempoExpression(h.value,this.placement,this.staffNumber,this.soundTempo,this.currentMultiTempoExpression);this.currentMultiTempoExpression.addExpression(t,"")}else o||this.interpretWords(h,e,i);else h=l.element("wedge"),h?this.interpretWedge(h,e,s,e.MeasureNumber):(h=l.element("rehearsal"),h&&this.interpretRehearsalMark(h,e,i,e.MeasureNumber))}closeOpenExpressions(t,e){for(const i of this.openContinuousDynamicExpressions)this.createNewMultiExpressionIfNeeded(t,i.NumberXml,e),this.closeOpenContinuousDynamic(i,t,e);this.openContinuousTempoExpression&&this.closeOpenContinuousTempo(n.Fraction.plus(t.AbsoluteTimestamp,e))}addOctaveShift(t,e,i){var s;let n=1;const r=t.element("staff");if(r)try{n=parseInt(r.value,10)}catch(t){const e=b.ITextTranslation.translateText("ReaderErrorMessages/OctaveShiftStaffError","Invalid octave shift staff number. Set to default");this.musicSheet.SheetErrors.pushMeasureError(e),n=1,g.default.debug("ExpressionReader.addOctaveShift",e,t)}const o=t.element("direction-type");if(o){const r=o.element("octave-shift"),a=this.readPlacement(t);if(void 0!==r&&r.hasAttributes)try{const t=this.readNumber(r);if(r.attribute("size")){const o=parseInt(r.attribute("size").value,10);let l=0;8===o?l=1:15===o&&(l=2);let c=null===(s=r.attribute("type"))||void 0===s?void 0:s.value;if(c||(a===m.PlacementEnum.Above?c="down":a===m.PlacementEnum.Below&&(c="up")),"up"===c||"down"===c){const i=new h.OctaveShift(c,l);i.StaffNumber=n,this.getMultiExpression=this.createNewMultiExpressionIfNeeded(e,t),this.getMultiExpression.OctaveShiftStart=i,i.ParentStartMultiExpression=this.getMultiExpression,this.openOctaveShift=i}else"stop"===c?this.openOctaveShift&&(this.getMultiExpression=this.createNewMultiExpressionIfNeeded(e,this.openOctaveShift.numberXml,i),this.getMultiExpression.OctaveShiftEnd=this.openOctaveShift,this.openOctaveShift.ParentEndMultiExpression=this.getMultiExpression,this.openOctaveShift=void 0):c||g.default.debug("octave-shift missing type in xml")}}catch(t){const e=b.ITextTranslation.translateText("ReaderErrorMessages/OctaveShiftError","Error while reading octave shift.");this.musicSheet.SheetErrors.pushMeasureError(e),g.default.debug("ExpressionReader.addOctaveShift",e,t)}}}addPedalMarking(t,e,i){var s,n,r;const o=t.element("direction-type");if(o){const t=o.element("pedal");if(void 0!==t&&t.hasAttributes){let o=!1,a=!1;try{switch("yes"===(null===(s=t.attribute("line"))||void 0===s?void 0:s.value)?a=!0:"no"===(null===(n=t.attribute("line"))||void 0===n?void 0:n.value)?(a=!1,o=!0):"yes"===(null===(r=t.attribute("sign"))||void 0===r?void 0:r.value)?o=!0:(o=!1,a=!0),t.attribute("type").value){case"start":this.openPedal&&this.openPedal.IsLine&&this.endOpenPedal(e),this.createNewMultiExpressionIfNeeded(e,-1),this.openPedal=new E.Pedal(a,o),this.getMultiExpression.PedalStart=this.openPedal,this.openPedal.ParentStartMultiExpression=this.getMultiExpression;break;case"stop":this.openPedal&&this.endOpenPedal(e,i);break;case"change":this.openPedal&&this.openPedal.IsLine&&(this.openPedal.ChangeEnd=!0,this.createNewMultiExpressionIfNeeded(e,-1),this.getMultiExpression.PedalEnd=this.openPedal,this.openPedal.ParentEndMultiExpression=this.getMultiExpression,this.createNewMultiExpressionIfNeeded(e,-1),this.openPedal=new E.Pedal(a,o),this.openPedal.ChangeBegin=!0,this.getMultiExpression.PedalStart=this.openPedal,this.openPedal.ParentStartMultiExpression=this.getMultiExpression)}}catch(t){const e=b.ITextTranslation.translateText("ReaderErrorMessages/PedalError","Error while reading pedal.");this.musicSheet.SheetErrors.pushMeasureError(e),g.default.debug("ExpressionReader.addPedalMarking",e,t)}}}}endOpenPedal(t,e){this.createNewMultiExpressionIfNeeded(t,-1,e),this.getMultiExpression.PedalEnd=this.openPedal,this.openPedal.ParentEndMultiExpression=this.getMultiExpression,this.openPedal=void 0}initialize(){this.placement=m.PlacementEnum.NotYetDefined,this.soundTempo=0,this.soundDynamic=0,this.offsetDivisions=0}readPlacement(t){var e;const i=null===(e=t.attribute("placement"))||void 0===e?void 0:e.value;return"above"===i?m.PlacementEnum.Above:"below"===i?m.PlacementEnum.Below:m.PlacementEnum.NotYetDefined}readExpressionPlacement(t,e){try{const e=this.readPosition(t);e<0?this.placement=m.PlacementEnum.Below:e>0&&(this.placement=m.PlacementEnum.Above)}catch(t){g.default.debug("ExpressionReader.readExpressionParameters",e,t)}}readPosition(t){try{const e=parseInt(t.value,10);return e<0?this.placement=m.PlacementEnum.Below:e>0&&(this.placement=m.PlacementEnum.Above),e}catch(t){g.default.debug("ExpressionReader.readExpressionParameters",t)}}interpretInstantaneousDynamics(t,e,i,s){var r;if(t.hasElements){t.hasAttributes&&t.attribute("default-x")&&(this.directionTimestamp=n.Fraction.createFromFraction(i));const o=this.readNumber(t);let a=null===(r=t.elements()[0])||void 0===r?void 0:r.name;if("other-dynamics"===a&&(a=t.elements()[0].value),a){s?this.createNewMultiExpressionIfNeeded(e,o,n.Fraction.createFromFraction(i)):this.createNewMultiExpressionIfNeeded(e,o);const t=new l.InstantaneousDynamicExpression(a,this.soundDynamic,this.placement,this.staffNumber,e);t.InMeasureTimestamp=i.clone(),this.getMultiExpression.addExpression(t,""),this.initialize(),this.activeInstantaneousDynamic?this.activeInstantaneousDynamic.DynEnum=t.DynEnum:this.activeInstantaneousDynamic=new l.InstantaneousDynamicExpression(a,0,m.PlacementEnum.NotYetDefined,1,e)}}}interpretWords(t,e,i){const s=t.value;if(e.Rules.IgnoreBracketsWords&&(/^\(\s*\)$/.test(s)||/^\[\s*\]$/.test(s)))return;let r;const o=t.attribute("font-style");if(o&&"italic"===o.value&&(r=S.FontStyles.Italic),s.length>0){if(t.hasAttributes&&t.attribute("default-x")&&(this.directionTimestamp=n.Fraction.createFromFraction(i)),this.checkIfWordsNodeIsRepetitionInstruction(s))return;this.fillMultiOrTempoExpression(s,e,i,r),this.initialize()}}readNumber(t){var e;let i=1;const s=null===(e=t.attribute("number"))||void 0===e?void 0:e.value;return s&&(i=Number.parseInt(s,10)),i}interpretWedge(t,e,i,s){var r,a;void 0!==t&&t.hasAttributes&&t.attribute("default-x")&&(this.directionTimestamp=n.Fraction.createFromFraction(i));const l=this.readNumber(t),h=null===(a=null===(r=t.attribute("type"))||void 0===r?void 0:r.value)||void 0===a?void 0:a.toLowerCase();this.lastWedge&&this.lastWedge.parentMeasure.MeasureNumberXML===e.MeasureNumberXML&&this.lastWedge.StaffNumber===this.staffNumber&&this.placement===this.lastWedge.Placement&&void 0!==this.WedgeYPosXml&&this.lastWedge.YPosXml===this.WedgeYPosXml&&this.lastWedge.StartMultiExpression.Timestamp.Equals(this.directionTimestamp)&&this.lastWedge.DynamicType===o.ContDynamicEnum[h]||("stop"===h?this.createNewMultiExpressionIfNeeded(e,l,i):this.createNewMultiExpressionIfNeeded(e,l),this.addWedge(t,e,i),this.initialize())}interpretRehearsalMark(t,e,i,s){e.rehearsalExpression=new y.RehearsalExpression(t.value,this.placement)}createNewMultiExpressionIfNeeded(t,e,i){i||(i=this.directionTimestamp);let s=this.getMultiExpression;return(!s||s&&(s.SourceMeasureParent!==t||s.numberXml!==e||s.SourceMeasureParent===t&&s.Timestamp!==i))&&(this.getMultiExpression=s=new c.MultiExpression(t,n.Fraction.createFromFraction(i)),t.StaffLinkedExpressions[this.globalStaffIndex].push(s)),s}createNewTempoExpressionIfNeeded(t){this.currentMultiTempoExpression&&this.currentMultiTempoExpression.SourceMeasureParent===t&&this.currentMultiTempoExpression.Timestamp===this.directionTimestamp||(this.currentMultiTempoExpression=new r.MultiTempoExpression(t,n.Fraction.createFromFraction(this.directionTimestamp)),t.TempoExpressions.push(this.currentMultiTempoExpression))}addWedge(t,e,i){if(void 0!==t&&t.hasAttributes){const s=this.readNumber(t),n=t.attribute("type").value.toLowerCase();try{if("crescendo"===n||"diminuendo"===n){const t=new o.ContinuousDynamicExpression(o.ContDynamicEnum[n],this.placement,this.staffNumber,e,s);this.lastWedge=t,this.lastWedge.YPosXml=this.WedgeYPosXml,this.openContinuousDynamicExpressions.push(t);let i=this.getMultiExpression;i||(i=this.createNewMultiExpressionIfNeeded(e,s)),i.StartingContinuousDynamic=t,t.StartMultiExpression=i,void 0!==this.activeInstantaneousDynamic&&this.activeInstantaneousDynamic.StaffNumber===t.StaffNumber&&(this.activeInstantaneousDynamic=void 0)}else if("stop"===n)for(const t of this.openContinuousDynamicExpressions)t.NumberXml===s&&t.NumberXml===s&&this.closeOpenContinuousDynamic(t,e,i)}catch(t){const e="ReaderErrorMessages/WedgeError, Error while reading Crescendo / Diminuendo.";this.musicSheet.SheetErrors.pushMeasureError(e),g.default.debug("ExpressionReader.addWedge",e,t)}}}fillMultiOrTempoExpression(t,e,i,s){if(!t)return;const n=t.trim();this.createExpressionFromString("",n,e,i,t,s)}createExpressionFromString(t,e,i,s,n,r){if(u.InstantaneousTempoExpression.isInputStringInstantaneousTempo(e)||a.ContinuousTempoExpression.isInputStringContinuousTempo(e)){if(i.TempoExpressions.length>0)for(let t=0,s=i.TempoExpressions.length;t0)for(let t=0,s=i.TempoExpressions.length;t0&&!this.hasDigit(e)&&this.globalStaffIndex>0){if(s.EntriesList[0].label.indexOf(e)>=0)return!1;break}}let h=p.TextAlignmentEnum.CenterBottom;this.musicSheet.Rules.CompactMode&&(h=p.TextAlignmentEnum.LeftBottom);const c=new f.UnknownExpression(e,this.placement,h,this.staffNumber);return c.fontStyle=r,l.addExpression(c,t),!1}closeOpenContinuousDynamic(t,e,i){if(!t)return;const s=t.NumberXml;t.EndMultiExpression=this.createNewMultiExpressionIfNeeded(e,s,i),t.StartMultiExpression.EndingContinuousDynamic=t,this.openContinuousDynamicExpressions=this.openContinuousDynamicExpressions.filter((e=>e!==t))}closeOpenContinuousTempo(t){this.openContinuousTempoExpression.AbsoluteEndTimestamp=t,this.openContinuousTempoExpression=void 0}checkIfWordsNodeIsRepetitionInstruction(t){return"coda"===(t=t.trim().toLowerCase())||"tocoda"===t||"to coda"===t||"fine"===t||"d.c."===t||"dacapo"===t||"da capo"===t||"d.s."===t||"dalsegno"===t||"dal segno"===t||"d.c. al fine"===t||"d.s. al fine"===t||"d.c. al coda"===t||"d.s. al coda"===t}hasDigit(t){return/\d/.test(t)}}},2535:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.LyricsReader=void 0;const s=i(2672),n=i(7274),r=i(6331);e.LyricsReader=class{constructor(t){this.openLyricWords={},this.musicSheet=t}addLyricEntry(t,e){var i,o;if(t){const a=t;for(let t=0,l=a.length;t0)for(let t=n;t{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RepetitionCalculator=void 0;const s=i(6189),n=i(6189),r=i(1703);e.RepetitionCalculator=class{constructor(){this.repetitionInstructions=[]}calculateRepetitions(t,e){this.musicSheet=t,this.repetitionInstructions=e;const i=this.musicSheet.SourceMeasures;for(let t=0,e=this.repetitionInstructions.length;t1&&e.FirstRepetitionInstructions.sort(n.RepetitionInstructionComparer.Compare),e.LastRepetitionInstructions.length>1&&e.LastRepetitionInstructions.sort(n.RepetitionInstructionComparer.Compare)}}handleRepetitionInstructions(t){if(!this.currentMeasure)return!1;switch(t.type){case s.RepetitionInstructionEnum.StartLine:this.currentMeasure.FirstRepetitionInstructions.push(t);break;case s.RepetitionInstructionEnum.BackJumpLine:this.currentMeasure.LastRepetitionInstructions.push(t);break;case s.RepetitionInstructionEnum.Ending:if(t.alignment===s.AlignmentType.Begin)this.currentMeasure.FirstRepetitionInstructions.push(t);else for(let e=0,i=t.endingIndices.length;e{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RepetitionInstructionReader=void 0;const s=i(6189),n=i(6189),r=i(1211);e.RepetitionInstructionReader=class{set MusicSheet(t){this.musicSheet=t,this.xmlMeasureList=new Array(this.musicSheet.Instruments.length),this.repetitionInstructions=[]}prepareReadingMeasure(t,e){this.currentMeasureIndex=e}handleLineRepetitionInstructions(t){let e=!1;if(t.elements().length>0){let i="",n=!1,r="",o="",a="";const l=[],h=t.element("bar-style");h&&(a=h.value),i=t.attributes().length>0&&t.attribute("location")?t.attribute("location").value:"right";const c=t.elements();for(let t=0,e=c.length;t0)if("left"===i){if("start"===o){const t=new s.RepetitionInstruction(this.currentMeasureIndex,s.RepetitionInstructionEnum.Ending,s.AlignmentType.Begin,void 0,l);this.addInstruction(this.repetitionInstructions,t)}if("forward"===r){const t=new s.RepetitionInstruction(this.currentMeasureIndex,s.RepetitionInstructionEnum.StartLine);this.addInstruction(this.repetitionInstructions,t)}}else{if("stop"===o){const t=new s.RepetitionInstruction(this.currentMeasureIndex,s.RepetitionInstructionEnum.Ending,s.AlignmentType.End,void 0,l);this.addInstruction(this.repetitionInstructions,t)}if("backward"===r){const t=new s.RepetitionInstruction(this.currentMeasureIndex,s.RepetitionInstructionEnum.BackJumpLine);this.addInstruction(this.repetitionInstructions,t)}}}return e}handleRepetitionInstructionsFromWordsOrSymbols(t,e){const i=t.element("words"),n=this.currentMeasureIndex;if(i){const t="d\\s?\\.s\\.",e=i.value.trim().toLowerCase();if(r.StringUtil.StringContainsSeparatedWord(e,t+" al fine",!0)){const t=new s.RepetitionInstruction(n,s.RepetitionInstructionEnum.DalSegnoAlFine);return this.addInstruction(this.repetitionInstructions,t),!0}const o="d\\.\\s?c\\.";if(r.StringUtil.StringContainsSeparatedWord(e,o+" al coda",!0)){const t=new s.RepetitionInstruction(n,s.RepetitionInstructionEnum.DaCapoAlCoda);return this.addInstruction(this.repetitionInstructions,t),!0}if(r.StringUtil.StringContainsSeparatedWord(e,o+" al fine",!0)){const t=new s.RepetitionInstruction(n,s.RepetitionInstructionEnum.DaCapoAlFine);return this.addInstruction(this.repetitionInstructions,t),!0}if(r.StringUtil.StringContainsSeparatedWord(e,o+" al coda",!0)){const t=new s.RepetitionInstruction(n,s.RepetitionInstructionEnum.DaCapoAlCoda);return this.addInstruction(this.repetitionInstructions,t),!0}if(r.StringUtil.StringContainsSeparatedWord(e,o)||r.StringUtil.StringContainsSeparatedWord(e,"da\\s?capo",!0)){const t=new s.RepetitionInstruction(n,s.RepetitionInstructionEnum.DaCapo);return this.addInstruction(this.repetitionInstructions,t),!0}if(r.StringUtil.StringContainsSeparatedWord(e,t,!0)||r.StringUtil.StringContainsSeparatedWord(e,"dal\\s?segno",!0)){let t;return t=r.StringUtil.StringContainsSeparatedWord(e,"al\\s?coda",!0)?new s.RepetitionInstruction(n,s.RepetitionInstructionEnum.DalSegnoAlCoda):new s.RepetitionInstruction(n,s.RepetitionInstructionEnum.DalSegno),this.addInstruction(this.repetitionInstructions,t),!0}if(r.StringUtil.StringContainsSeparatedWord(e,"to\\s?coda",!0)||r.StringUtil.StringContainsSeparatedWord(e,"a (la )?coda",!0)){const t=new s.RepetitionInstruction(n,s.RepetitionInstructionEnum.ToCoda);return this.addInstruction(this.repetitionInstructions,t),!0}if(r.StringUtil.StringContainsSeparatedWord(e,"fine",!0)){const t=new s.RepetitionInstruction(n,s.RepetitionInstructionEnum.Fine);return this.addInstruction(this.repetitionInstructions,t),!0}if(r.StringUtil.StringContainsSeparatedWord(e,"coda",!0)){const t=new s.RepetitionInstruction(n,s.RepetitionInstructionEnum.Coda);return this.addInstruction(this.repetitionInstructions,t),!0}if(r.StringUtil.StringContainsSeparatedWord(e,"segno",!0)){const t=new s.RepetitionInstruction(n,s.RepetitionInstructionEnum.Segno);return this.addInstruction(this.repetitionInstructions,t),!0}}else{if(t.element("segno")){const t=new s.RepetitionInstruction(n,s.RepetitionInstructionEnum.Segno);return this.addInstruction(this.repetitionInstructions,t),!0}if(t.element("coda")){const t=new s.RepetitionInstruction(n,s.RepetitionInstructionEnum.Coda);return this.addInstruction(this.repetitionInstructions,t),!0}}return!1}removeRedundantInstructions(){let t=0,e=0,i=0,r=0;for(let n=0;n0&&this.findInstructionInPreviousMeasure(n,o.measureIndex,s.RepetitionInstructionEnum.ToCoda)&&(o.type=s.RepetitionInstructionEnum.None);break;case s.RepetitionInstructionEnum.Segno:if(t-r>0){let t=!1;for(let n=0,r=this.repetitionInstructions.length;n0?s.RepetitionInstructionEnum.DalSegnoAlCoda:s.RepetitionInstructionEnum.DalSegno,o.type=s.RepetitionInstructionEnum.None,t=!0;break;case s.RepetitionInstructionEnum.DalSegno:case s.RepetitionInstructionEnum.DalSegnoAlFine:case s.RepetitionInstructionEnum.DalSegnoAlCoda:o.type=s.RepetitionInstructionEnum.None,t=!0}if(t)break}if(t)break;o.type=i-e>0?s.RepetitionInstructionEnum.DalSegnoAlCoda:s.RepetitionInstructionEnum.DalSegno,o.alignment=s.AlignmentType.End,o.measureIndex--}}if(this.backwardSearchForPreviousIdenticalInstruction(n,o)||o.type===s.RepetitionInstructionEnum.None)this.repetitionInstructions.splice(n,1),n--;else switch(o.type){case s.RepetitionInstructionEnum.Fine:break;case s.RepetitionInstructionEnum.ToCoda:i++;break;case s.RepetitionInstructionEnum.Coda:e++;break;case s.RepetitionInstructionEnum.Segno:t++;break;case s.RepetitionInstructionEnum.DalSegnoAlFine:case s.RepetitionInstructionEnum.DalSegnoAlCoda:r++}}this.repetitionInstructions.sort(n.RepetitionInstructionComparer.Compare)}findInstructionInPreviousMeasure(t,e,i){for(let s=t-1;s>=0;s--){const t=this.repetitionInstructions[s];if(e-t.measureIndex==1&&t.type===i)return!0}return!1}backwardSearchForPreviousIdenticalInstruction(t,e){for(let i=t-1;i>=0;i--)if(this.repetitionInstructions[i].equals(e))return!0;return!1}addInstruction(t,e){let i=!0;for(let s=0,n=t.length;s0){const t=i.attribute("type").value;let s=1;try{i.attribute("number")&&(s=parseInt(i.attribute("number").value,10))}catch(t){r.default.debug("VoiceGenerator.addSlur number: ",t)}let o=a.PlacementEnum.NotYetDefined;const h=i.attribute("placement");h&&h.value&&("above"===h.value?o=a.PlacementEnum.Above:"below"===h.value&&(o=a.PlacementEnum.Below));const c=i.attribute("orientation");if(c&&c.value&&("over"===c.value?o=a.PlacementEnum.Above:"under"===c.value&&(o=a.PlacementEnum.Below)),"start"===t){let t=this.openSlurDict[s];t||(t=new n.Slur,this.openSlurDict[s]=t),t.StartNote=e,t.PlacementXml=o}else if("stop"===t){const t=this.openSlurDict[s];if(t){const n=i.name;if("slide"===n||"glissando"===n){const i=t.StartNote,n=new l.Glissando(i);n.AddNote(e),n.EndNote=e,e.NoteGlissando=n,delete this.openSlurDict[s]}else t.EndNote=e,e.isDuplicateSlur(t)||(e.NoteSlurs.push(t),t.StartNote.NoteSlurs.push(t)),delete this.openSlurDict[s]}}}}catch(t){const e=o.ITextTranslation.translateText("ReaderErrorMessages/SlurError","Error while reading slur.");this.musicSheet.SheetErrors.pushMeasureError(e)}}}},1651:function(t,e,i){"use strict";var s=this&&this.__createBinding||(Object.create?function(t,e,i,s){void 0===s&&(s=i);var n=Object.getOwnPropertyDescriptor(e,i);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,s,n)}:function(t,e,i,s){void 0===s&&(s=i),t[s]=e[i]}),n=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||s(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(i(7677),e),n(i(2905),e),n(i(4671),e),n(i(2535),e),n(i(6789),e),n(i(9934),e),n(i(3755),e)},2458:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.ReaderPluginManager=void 0;const n=s(i(2043));e.ReaderPluginManager=class{constructor(){this.voiceMeasureReadPlugins=[]}addVoiceMeasureReadPlugin(t){this.voiceMeasureReadPlugins.push(t)}processVoiceMeasureReadPlugins(t,e,i){for(const s of this.voiceMeasureReadPlugins)try{s.measureReadCalculations(t,e,i)}catch(t){n.default.info("VoiceGenerator.addSingleNote: ",t)}}}},8109:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.VoiceGenerator=void 0;const n=i(2947),r=i(3884),o=i(908),a=i(5253),l=i(9050),h=i(9224),c=i(4555),u=i(5544),d=i(8069),f=i(1797),m=i(6331),p=i(2535),b=i(1703),g=i(8640),S=i(8640),y=i(4447),E=s(i(2043)),v=i(8640),x=i(2337),_=i(7677),M=i(766),w=i(3029),P=i(2478),T=i(2953),L=i(3748);e.VoiceGenerator=class{constructor(t,e,i,s,o){this.openBeams=[],this.beamNumberOffset=0,this.currentOctaveShift=0,this.tupletDict={},this.openTupletNumber=0,this.staff=e,this.instrument=e.ParentInstrument,this.musicSheet=this.instrument.GetMusicSheet,this.slurReader=s,this.pluginManager=t,this.voice=o?new n.LinkedVoice(this.instrument,i,o):new r.Voice(this.instrument,i),this.instrument.Voices.push(this.voice),this.staff.Voices.push(this.voice),this.lyricsReader=new p.LyricsReader(this.musicSheet),this.articulationReader=new _.ArticulationReader(this.musicSheet.Rules)}get openTieDict(){return this.staff.openTieDict}get GetVoice(){return this.voice}get OctaveShift(){return this.currentOctaveShift}set OctaveShift(t){this.currentOctaveShift=t}createVoiceEntry(t,e,i,s=!1,n=!1,r=!1){this.currentVoiceEntry=new o.VoiceEntry(t.clone(),this.voice,e,s,n,r),i&&this.voice.VoiceEntries.push(this.currentVoiceEntry)}read(t,e,i,s,n,r,o,a,l,h,c,d,f,p,b,g,S,y,v,x,_){this.currentStaffEntry=o,this.currentMeasure=a;try{this.currentNote=r?this.addRestNote(t.element("rest"),e,s,i,n,f,p,v):this.addSingleNote(t,e,s,i,n,c,d,f,p,b,g,S,y,v,x),this.currentNote.DotsXml=_;const o=t.elements("lyric");void 0!==this.lyricsReader&&o&&(this.lyricsReader.addLyricEntry(o,this.currentVoiceEntry),this.voice.Parent.HasLyrics=!0);let a=!1;const m=t.element("notations");if(m){this.articulationReader&&this.readArticulations(m,this.currentVoiceEntry,this.currentNote);const e=m.elements("slur"),i=m.elements("slide"),s=m.elements("glissando");void 0!==this.slurReader&&(e.length>0||i.length>0)&&!this.currentNote.ParentVoiceEntry.IsGrace&&(this.slurReader.addSlur(e,this.currentNote),i.length>0&&this.slurReader.addSlur(i,this.currentNote),s.length>0&&this.slurReader.addSlur(s,this.currentNote));const n=m.elements("tuplet");n.length>0&&(this.openTupletNumber=this.addTuplet(t,n),a=!0);const r=m.element("arpeggiate");if(void 0!==r){let t;if(this.currentVoiceEntry.Arpeggio)t=this.currentVoiceEntry.Arpeggio;else{let e=!1;for(const i of this.currentStaffEntry.VoiceEntries)if(i.Arpeggio){e=!0,t=i.Arpeggio;break}if(!e){let e=w.ArpeggioType.ARPEGGIO_DIRECTIONLESS;const i=r.attribute("direction");if(i)switch(i.value){case"up":e=w.ArpeggioType.ROLL_UP;break;case"down":e=w.ArpeggioType.ROLL_DOWN;break;default:e=w.ArpeggioType.ARPEGGIO_DIRECTIONLESS}t=new w.Arpeggio(this.currentVoiceEntry,e),this.currentVoiceEntry.Arpeggio=t}}t.addNote(this.currentNote)}const o=m.elements("tied");o.length>0&&this.addTie(o,l,h,u.TieTypes.SIMPLE);const c=m.element("technical");if(c){const t=c.elements("hammer-on");t.length>0&&this.addTie(t,l,h,u.TieTypes.HAMMERON);const e=c.elements("pull-off");e.length>0&&this.addTie(e,l,h,u.TieTypes.PULLOFF)}}void 0===t.element("time-modification")||a||this.handleTimeModificationNode(t)}catch(t){E.default.warn(t);const e=m.ITextTranslation.translateText("ReaderErrorMessages/NoteError","Ignored erroneous Note.");this.musicSheet.SheetErrors.pushMeasureError(e),this.musicSheet.SheetErrors.pushMeasureError(t)}return this.currentNote}checkForStaffEntryLink(t,e,i,s){const n=new y.StaffEntryLink(this.currentVoiceEntry);n.LinkStaffEntries.push(i),i.Link=n;const r=this.currentVoiceEntry.Timestamp.clone(),o=s.getVerticalContainerByTimestamp(r);return(i=o.StaffEntries[t])||(i=new l.SourceStaffEntry(o,e),o.StaffEntries[t]=i),i.VoiceEntries.push(this.currentVoiceEntry),n.LinkStaffEntries.push(i),i.Link=n,i}checkForOpenBeam(){this.openBeams.length>0&&this.currentNote&&this.handleOpenBeam()}checkOpenTies(){const t=this.openTieDict;for(const e in t)if(t.hasOwnProperty(e)){const i=t[e];f.Fraction.plus(i.StartNote.ParentStaffEntry.Timestamp,i.Duration).lt(i.StartNote.SourceMeasure.Duration)&&delete t[e]}}hasVoiceEntry(){return void 0!==this.currentVoiceEntry}readArticulations(t,e,i){const s=t.element("articulations");s&&this.articulationReader.addArticulationExpression(s,e);const n=t.element("fermata");n&&this.articulationReader.addFermata(n,e);const r=t.element("technical");r&&this.articulationReader.addTechnicalArticulations(r,e,i);const o=t.element("ornaments");o&&this.articulationReader.addOrnament(o,e)}addSingleNote(t,e,i,s,n,r,l,h,c,u,d,p,y,x,_){let w,P,L,A,C=0,I=g.AccidentalEnum.NONE,R=S.NoteEnum.C,N=S.NoteEnum.C,B=0,F=0;const D=t.elements();for(let t=0,e=D.length;t0&&this.openBeams.last().ExtendedNoteList.push(b),b}addNoteInfo(t,e,i,s,n,r,o,a,l){t.NoteTypeXml=e,t.PrintObject=i,t.IsCueNote=s,t.NormalNotes=n,t.displayStepUnpitched=r,t.displayOctaveUnpitched=o,t.NoteheadColorXml=a,t.NoteheadColor=a}createBeam(t,e){var i;try{const s=t.element("beam");let n;if(void 0!==s&&s.hasAttributes&&(n=s.attribute("number")),n){let s=parseInt(n.value,10);const r=t.elements("beam"),o=r[0].value;r&&("begin"===o?(s===(null===(i=this.openBeams.last())||void 0===i?void 0:i.BeamNumber)?(this.beamNumberOffset++,s+=this.beamNumberOffset):this.openBeams.last()&&this.handleOpenBeam(),this.openBeams.push(new h.Beam(s,this.beamNumberOffset))):s+=this.beamNumberOffset);let a=!1;if(!(s>0&&s<=this.openBeams.length&&this.openBeams[s-1]))return void E.default.debug("[OSMD] invalid beamnumber");for(let t=0,e=this.openBeams[s-1].Notes.length;t1){let s=t.element("time-modification");s&&(s=s.element("actual-notes"));const n=e;for(let e=0,r=n.length;e1&&this.openTupletNumber--),this.tupletDict[e]=o;const l=[];l.push(this.currentNote),o.Notes.push(l),o.Fractions.push(this.getTupletNoteDurationFromType(t)),this.currentNote.NoteTuplet=o,this.openTupletNumber=e}else if("stop"===n.value){let e=1;r.attribute("number")&&(e=parseInt(r.attribute("number").value,10));const i=this.tupletDict[e];if(i){const s=r.attribute("placement");s&&("below"===s.value?i.tupletLabelNumberPlacement=L.PlacementEnum.Below:i.tupletLabelNumberPlacement=L.PlacementEnum.Above,i.PlacementFromXml=!0);const n=[];if(n.push(this.currentNote),i.Notes.push(n),!i.PlacementFromXml){let t=!1;for(const e of i.Notes){for(const s of e)if(!s.isRest()){s.StemDirectionXml===o.StemDirectionType.Down?i.tupletLabelNumberPlacement=L.PlacementEnum.Below:i.tupletLabelNumberPlacement=L.PlacementEnum.Above,t=!0;break}if(t)break}}i.Fractions.push(this.getTupletNoteDurationFromType(t)),this.currentNote.NoteTuplet=i,delete this.tupletDict[e],0===Object.keys(this.tupletDict).length?this.openTupletNumber=0:Object.keys(this.tupletDict).length>1&&this.openTupletNumber--}}}}}else if(e[0]){const s=e[0];if(s.hasAttributes){const e=s.attribute("type").value;let n=1;s.attribute("number")&&(n=parseInt(s.attribute("number").value,10));const r=isNaN(n),a=s.attribute("bracket");if(a&&"yes"===a.value&&(i=!0),"start"===e){let e=0,o=t.element("time-modification");if(o&&(o=o.element("actual-notes")),o&&(e=parseInt(o.value,10),isNaN(e))){const t=m.ITextTranslation.translateText("ReaderErrorMessages/TupletNoteDurationError","Invalid tuplet note duration.");throw this.musicSheet.SheetErrors.pushMeasureError(t),new b.MusicSheetReadingException(t)}r&&(this.openTupletNumber++,n=this.openTupletNumber);let a=this.tupletDict[n];a||(a=this.tupletDict[n]=new d.Tuplet(e,i),a.tupletLabelNumberPlacement=L.PlacementEnum.Above);const l=s.attribute("placement");l&&("below"===l.value?a.tupletLabelNumberPlacement=L.PlacementEnum.Below:a.tupletLabelNumberPlacement=L.PlacementEnum.Above,a.PlacementFromXml=!0);const h=[];h.push(this.currentNote),a.Notes.push(h),a.Fractions.push(this.getTupletNoteDurationFromType(t)),this.currentNote.NoteTuplet=a,this.openTupletNumber=n}else if("stop"===e){r&&(n=this.openTupletNumber);const e=this.tupletDict[this.openTupletNumber];if(e){const i=s.attribute("placement");i&&("below"===i.value?e.tupletLabelNumberPlacement=L.PlacementEnum.Below:e.tupletLabelNumberPlacement=L.PlacementEnum.Above,e.PlacementFromXml=!0);const r=[];if(r.push(this.currentNote),e.Notes.push(r),!e.PlacementFromXml){let t=!1;for(const i of e.Notes){for(const s of i)if(!s.isRest()){s.StemDirectionXml===o.StemDirectionType.Down?e.tupletLabelNumberPlacement=L.PlacementEnum.Below:e.tupletLabelNumberPlacement=L.PlacementEnum.Above,t=!0;break}if(t)break}}e.Fractions.push(this.getTupletNoteDurationFromType(t)),this.currentNote.NoteTuplet=e,0===Object.keys(this.tupletDict).length?this.openTupletNumber=0:Object.keys(this.tupletDict).length>1&&this.openTupletNumber--,delete this.tupletDict[n]}}}}return this.openTupletNumber}handleTimeModificationNode(t){if(this.tupletDict[this.openTupletNumber])try{const e=this.tupletDict[this.openTupletNumber],i=x.CollectionUtil.last(e.Notes);let s;i[0].ParentVoiceEntry.Timestamp.Equals(this.currentVoiceEntry.Timestamp)?s=i:(s=[],e.Notes.push(s),e.Fractions.push(this.getTupletNoteDurationFromType(t))),s.push(this.currentNote),this.currentNote.NoteTuplet=e}catch(t){const e=m.ITextTranslation.translateText("ReaderErrorMessages/TupletNumberError","Invalid tuplet number.");throw this.musicSheet.SheetErrors.pushMeasureError(e),t}else if(this.currentVoiceEntry.Notes.length>0){const t=this.currentVoiceEntry.Notes[0];if(t.NoteTuplet){const e=t.NoteTuplet;x.CollectionUtil.last(e.Notes).push(this.currentNote),this.currentNote.NoteTuplet=e}}}addTie(t,e,i,s){if(t)if(1===t.length){const e=t[0];if(void 0!==e&&e.attributes()){const t=this.getTieDirection(e),i=e.attribute("type").value;try{if("start"===i){const e=this.findCurrentNoteInTieDict(this.currentNote);e<0&&delete this.openTieDict[e];const i=this.getNextAvailableNumberForTie(),n=new c.Tie(this.currentNote,s);this.openTieDict[i]=n,n.TieNumber=i,n.TieDirection=t}else if("stop"===i){const t=this.findCurrentNoteInTieDict(this.currentNote),e=this.openTieDict[t];e&&(e.AddNote(this.currentNote),delete this.openTieDict[t])}}catch(t){const e=m.ITextTranslation.translateText("ReaderErrorMessages/TieError","Error while reading tie.");this.musicSheet.SheetErrors.pushMeasureError(e)}}}else if(2===t.length){const e=this.findCurrentNoteInTieDict(this.currentNote);if(e>=0){const i=this.openTieDict[e];i.AddNote(this.currentNote);for(const e of t)if("start"===e.attribute("type").value){const t=this.getTieDirection(e);i.NoteIndexToTieDirection[i.Notes.length-1]=t}}}}getTieDirection(t){let e=L.PlacementEnum.NotYetDefined;const i=t.attribute("placement");i&&("above"===i.value?e=L.PlacementEnum.Above:"below"===i.value&&(e=L.PlacementEnum.Below));const s=t.attribute("orientation");return s&&("over"===s.value?e=L.PlacementEnum.Above:"under"===s.value&&(e=L.PlacementEnum.Below)),e}getNextAvailableNumberForTie(){const t=Object.keys(this.openTieDict);if(0===t.length)return 1;t.sort(((t,e)=>+t-+e));for(let e=0;e{"use strict";var i;Object.defineProperty(e,"__esModule",{value:!0}),e.ArpeggioType=e.Arpeggio=void 0,e.Arpeggio=class{constructor(t,e=i.ARPEGGIO_DIRECTIONLESS){this.parentVoiceEntry=t,this.type=e,this.notes=[]}addNote(t){this.notes.push(t),t.Arpeggio=this}},function(t){t[t.BRUSH_DOWN=1]="BRUSH_DOWN",t[t.BRUSH_UP=2]="BRUSH_UP",t[t.ROLL_DOWN=3]="ROLL_DOWN",t[t.ROLL_UP=4]="ROLL_UP",t[t.RASQUEDO_DOWN=5]="RASQUEDO_DOWN",t[t.RASQUEDO_UP=6]="RASQUEDO_UP",t[t.ARPEGGIO_DIRECTIONLESS=7]="ARPEGGIO_DIRECTIONLESS"}(i=e.ArpeggioType||(e.ArpeggioType={}))},1662:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Articulation=void 0,e.Articulation=class{constructor(t,e){this.articulationEnum=t,this.placement=e}Equals(t){return t.articulationEnum===this.articulationEnum&&t.placement===this.placement}}},9224:(t,e)=>{"use strict";var i;Object.defineProperty(e,"__esModule",{value:!0}),e.BeamEnum=e.Beam=void 0,e.Beam=class{constructor(t=1,e=0){this.notes=[],this.extendedNoteList=[],this.BeamNumberOffsetToXML=0,this.BeamNumber=t,this.BeamNumberOffsetToXML=e}get Notes(){return this.notes}set Notes(t){this.notes=t}get ExtendedNoteList(){return this.extendedNoteList}set ExtendedNoteList(t){this.extendedNoteList=t}addNoteToBeam(t){t&&(t.NoteBeam=this,this.notes.push(t),this.extendedNoteList.push(t))}},(i=e.BeamEnum||(e.BeamEnum={}))[i.BeamNone=-1]="BeamNone",i[i.BeamBegin=0]="BeamBegin",i[i.BeamContinue=1]="BeamContinue",i[i.BeamEnd=2]="BeamEnd",i[i.BeamForward=3]="BeamForward",i[i.BeamBackward=4]="BeamBackward"},4123:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ChordSymbolEnum=e.ChordDegreeText=e.CustomChord=e.Degree=e.ChordSymbolContainer=void 0;const s=i(8640),n=i(4040),r=i(8640);e.ChordSymbolContainer=class{constructor(t,e,i,s,n){this.rootPitch=t,this.chordKind=e,this.bassPitch=i,this.degrees=s,this.rules=n}get RootPitch(){return this.rootPitch}get ChordKind(){return this.chordKind}get BassPitch(){return this.bassPitch}get ChordDegrees(){return this.degrees}static calculateChordText(t,e,i){let o=t.RootPitch;if(n.MusicSheetCalculator.transposeCalculator&&(o=n.MusicSheetCalculator.transposeCalculator.transposePitch(t.RootPitch,i,e)),t.ChordKind===l.none)return t.getTextFromChordKindEnum(t.ChordKind);let h=s.Pitch.getNoteEnumString(o.FundamentalNote);o.Accidental!==r.AccidentalEnum.NONE&&(h+=t.getTextForAccidental(o.Accidental));const c={adds:[],alts:[],subs:[]};for(const e of t.ChordDegrees)if(e){let i="";switch(e.alteration!==r.AccidentalEnum.NONE&&(i+=t.getTextForAccidental(e.alteration)),i+=e.value,e.text){case a.add:c.adds.push(i);break;case a.alter:c.alts.push(i);break;case a.subtract:c.subs.push(i)}}let u=t.getTextFromChordKindEnum(t.ChordKind);const d=["adds","alts","subs"],f=t.rules.CustomChords;for(const e of f){if(e.chordKind!==t.chordKind)continue;let i=!0;for(const t of d){for(const s of e.degrees[t]||[])if(c[t].indexOf(s)<0){i=!1;break}if(!i)break}if(i){for(const t of d)for(const i of e.degrees[t]||[])c[t].splice(c[t].indexOf(i),1);u=e.alternateName}}if(h+=u,c.adds.length>0&&(h+="("+c.adds.join(",")+")"),c.alts.length>0&&(h+="(alt "+c.alts.join(",")+")"),c.subs.length>0&&(h+="(omit "+c.subs.join(",")+")"),t.BassPitch){let r=t.BassPitch;n.MusicSheetCalculator.transposeCalculator&&(r=n.MusicSheetCalculator.transposeCalculator.transposePitch(t.BassPitch,i,e)),h+="/",h+=s.Pitch.getNoteEnumString(r.FundamentalNote),h+=t.getTextForAccidental(r.Accidental)}return h}getTextForAccidental(t){const e=this.rules.ChordAccidentalTexts.getValue(t);return void 0!==e?e:""}getTextFromChordKindEnum(t){var e;return null!==(e=this.rules.ChordSymbolLabelTexts.getValue(t))&&void 0!==e?e:""}},e.Degree=class{constructor(t,e,i){this.value=t,this.alteration=e,this.text=i}};class o{constructor(t,e,i){this.alternateName=t,this.chordKind=e,this.degrees=i}static createCustomChord(t,e,i){return new o(t,e,i)}static renameCustomChord(t,e,i){for(const s of i)s.alternateName===t&&(s.alternateName=e)}}var a,l;e.CustomChord=o,function(t){t[t.add=0]="add",t[t.alter=1]="alter",t[t.subtract=2]="subtract"}(a=e.ChordDegreeText||(e.ChordDegreeText={})),function(t){t[t.major=0]="major",t[t.minor=1]="minor",t[t.augmented=2]="augmented",t[t.diminished=3]="diminished",t[t.dominant=4]="dominant",t[t.majorseventh=5]="majorseventh",t[t.minorseventh=6]="minorseventh",t[t.diminishedseventh=7]="diminishedseventh",t[t.augmentedseventh=8]="augmentedseventh",t[t.halfdiminished=9]="halfdiminished",t[t.majorminor=10]="majorminor",t[t.majorsixth=11]="majorsixth",t[t.minorsixth=12]="minorsixth",t[t.dominantninth=13]="dominantninth",t[t.majorninth=14]="majorninth",t[t.minorninth=15]="minorninth",t[t.dominant11th=16]="dominant11th",t[t.major11th=17]="major11th",t[t.minor11th=18]="minor11th",t[t.dominant13th=19]="dominant13th",t[t.major13th=20]="major13th",t[t.minor13th=21]="minor13th",t[t.suspendedsecond=22]="suspendedsecond",t[t.suspendedfourth=23]="suspendedfourth",t[t.Neapolitan=24]="Neapolitan",t[t.Italian=25]="Italian",t[t.French=26]="French",t[t.German=27]="German",t[t.pedal=28]="pedal",t[t.power=29]="power",t[t.Tristan=30]="Tristan",t[t.none=31]="none"}(l=e.ChordSymbolEnum||(e.ChordSymbolEnum={}))},3748:(t,e)=>{"use strict";var i;Object.defineProperty(e,"__esModule",{value:!0}),e.PlacementEnum=e.AbstractExpression=void 0,e.AbstractExpression=class{constructor(t){this.placement=t}static isStringInStringList(t,e){for(let i=0,s=t.length;i{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AbstractTempoExpression=void 0;const s=i(3748);class n extends s.AbstractExpression{constructor(t,e,i,s){super(e),this.label=t,this.staffNumber=i,this.parentMultiTempoExpression=s}get Label(){return this.label}set Label(t){this.label=t}get Placement(){return this.placement}set Placement(t){this.placement=t}get StaffNumber(){return this.staffNumber}set StaffNumber(t){this.staffNumber=t}get ParentMultiTempoExpression(){return this.parentMultiTempoExpression}static isStringInStringList(t,e){for(const i of t)if(n.stringContainsSeparatedWord(e.toLowerCase().trim(),i.toLowerCase().trim()))return!0;return!1}static stringContainsSeparatedWord(t,e){return t===e||-1!==t.indexOf(" "+e)||-1!==t.indexOf(e+" ")}}e.AbstractTempoExpression=n},7839:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ContDynamicEnum=e.ContinuousDynamicExpression=void 0;const s=i(3748),n=i(1797);class r extends s.AbstractExpression{constructor(t,e,i,s,n,r=""){super(e),super.parentMeasure=s,this.NumberXml=n,this.dynamicType=t,this.label=r,this.staffNumber=i,this.startVolume=-1,this.endVolume=-1,""!==r&&this.setType()}get DynamicType(){return this.dynamicType}set DynamicType(t){this.dynamicType=t}get StartMultiExpression(){return this.startMultiExpression}set StartMultiExpression(t){this.startMultiExpression=t}get EndMultiExpression(){return this.endMultiExpression}set EndMultiExpression(t){this.endMultiExpression=t}get Placement(){return this.placement}set Placement(t){this.placement=t}get StartVolume(){return this.startVolume}set StartVolume(t){this.startVolume=t}get EndVolume(){return this.endVolume}set EndVolume(t){this.endVolume=t}get StaffNumber(){return this.staffNumber}set StaffNumber(t){this.staffNumber=t}get Label(){return this.label}set Label(t){this.label=t,this.setType()}static isInputStringContinuousDynamic(t){return!!t&&(r.isStringInStringList(r.listContinuousDynamicIncreasing,t)||r.isStringInStringList(r.listContinuousDynamicDecreasing,t))}getInterpolatedDynamic(t){const e=this.StartMultiExpression.AbsoluteTimestamp;let i;if(i=this.EndMultiExpression?this.EndMultiExpression.AbsoluteTimestamp:n.Fraction.plus(this.startMultiExpression.SourceMeasureParent.AbsoluteTimestamp,this.startMultiExpression.SourceMeasureParent.Duration),t.lt(e))return-1;if(i.lt(t))return-2;const s=n.Fraction.minus(t,e).RealValue/n.Fraction.minus(i,e).RealValue;return Math.max(0,Math.min(99.9,this.startVolume+(this.endVolume-this.startVolume)*s))}isWedge(){return!this.label}setType(){r.isStringInStringList(r.listContinuousDynamicIncreasing,this.label)?this.dynamicType=o.crescendo:r.isStringInStringList(r.listContinuousDynamicDecreasing,this.label)&&(this.dynamicType=o.diminuendo)}}var o;e.ContinuousDynamicExpression=r,r.listContinuousDynamicIncreasing=["crescendo","cresc","cresc.","cres."],r.listContinuousDynamicDecreasing=["decrescendo","decresc","decr.","diminuendo","dim.","dim"],function(t){t[t.crescendo=0]="crescendo",t[t.diminuendo=1]="diminuendo"}(o=e.ContDynamicEnum||(e.ContDynamicEnum={}))},280:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ContinuousTempoType=e.ContinuousTempoExpression=void 0;const s=i(1797),n=i(9775);class r extends n.AbstractTempoExpression{constructor(t,e,i,s){super(t,e,i,s),this.setTempoType()}static isInputStringContinuousTempo(t){return!!t&&(r.isStringInStringList(r.listContinuousTempoFaster,t)||r.isStringInStringList(r.listContinuousTempoSlower,t))}static isIncreasingTempo(t){return t<=o.piuMosso}static isDecreasingTempo(t){return t>=o.allargando&&t<=o.ritenuto}get TempoType(){return this.tempoType}set TempoType(t){this.tempoType=t}get StartTempo(){return this.startTempo}set StartTempo(t){this.startTempo=t}get EndTempo(){return this.endTempo}set EndTempo(t){this.endTempo=t}get AbsoluteEndTimestamp(){return this.absoluteEndTimestamp}set AbsoluteEndTimestamp(t){this.absoluteEndTimestamp=t}get AbsoluteTimestamp(){return this.ParentMultiTempoExpression.AbsoluteTimestamp}getAbsoluteFloatTimestamp(){return this.ParentMultiTempoExpression.AbsoluteTimestamp.RealValue}getInterpolatedTempo(t){const e=s.Fraction.plus(this.parentMultiTempoExpression.SourceMeasureParent.AbsoluteTimestamp,this.parentMultiTempoExpression.Timestamp);if(t.lt(e))return-1;if(this.absoluteEndTimestamp.lt(t))return-2;const i=s.Fraction.minus(t,e).RealValue/s.Fraction.minus(this.absoluteEndTimestamp,e).RealValue;return Math.max(0,Math.min(250,this.startTempo+(this.endTempo-this.startTempo)*i))}setTempoType(){r.isStringInStringList(r.listContinuousTempoFaster,this.label)?this.tempoType=o.accelerando:r.isStringInStringList(r.listContinuousTempoSlower,this.label)&&(this.tempoType=o.ritardando)}}var o;e.ContinuousTempoExpression=r,r.listContinuousTempoFaster=["accelerando","piu mosso","poco piu","stretto"],r.listContinuousTempoSlower=["poco meno","meno mosso","piu lento","calando","allargando","rallentando","ritardando","ritenuto","ritard.","ritard","rit.","rit","riten.","riten"],function(t){t[t.accelerando=0]="accelerando",t[t.stretto=1]="stretto",t[t.stringendo=2]="stringendo",t[t.mosso=3]="mosso",t[t.piuMosso=4]="piuMosso",t[t.allargando=5]="allargando",t[t.calando=6]="calando",t[t.menoMosso=7]="menoMosso",t[t.rallentando=8]="rallentando",t[t.ritardando=9]="ritardando",t[t.ritard=10]="ritard",t[t.rit=11]="rit",t[t.ritenuto=12]="ritenuto",t[t.rubato=13]="rubato",t[t.precipitando=14]="precipitando"}(o=e.ContinuousTempoType||(e.ContinuousTempoType={}))},5853:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.OctaveEnum=e.OctaveShift=void 0;const s=i(8640);var n;e.OctaveShift=class{constructor(t,e){this.numberXml=1,this.setOctaveShiftValue(t,e)}get Type(){return this.octaveValue}set Type(t){this.octaveValue=t}get StaffNumber(){return this.staffNumber}set StaffNumber(t){this.staffNumber=t}get ParentStartMultiExpression(){return this.startMultiExpression}set ParentStartMultiExpression(t){this.startMultiExpression=t}get ParentEndMultiExpression(){return this.endMultiExpression}set ParentEndMultiExpression(t){this.endMultiExpression=t}setOctaveShiftValue(t,e){this.octaveValue=1===e&&"down"===t?n.VA8:1===e&&"up"===t?n.VB8:2===e&&"down"===t?n.MA15:2===e&&"up"===t?n.MB15:n.NONE}static getPitchFromOctaveShift(t,e){if(!t)return;let i=t.Octave;switch(e){case n.VA8:i-=1;break;case n.VB8:i+=1;break;case n.MA15:i-=2;break;case n.MB15:i+=2;break;case n.NONE:default:i+=0}return new s.Pitch(t.FundamentalNote,i,t.Accidental)}},function(t){t[t.VA8=0]="VA8",t[t.VB8=1]="VB8",t[t.MA15=2]="MA15",t[t.MB15=3]="MB15",t[t.NONE=4]="NONE"}(n=e.OctaveEnum||(e.OctaveEnum={}))},308:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Pedal=void 0,e.Pedal=class{constructor(t=!1,e=!0){this.ChangeEnd=!1,this.ChangeBegin=!1,this.EndsStave=!1,this.BeginsStave=!1,this.line=t,this.sign=e}get IsLine(){return this.line}get IsSign(){return this.sign}}},1928:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Slur=void 0;const s=i(1797);e.Slur=class{constructor(){}get StartNote(){return this.startNote}set StartNote(t){this.startNote=t}get EndNote(){return this.endNote}set EndNote(t){this.endNote=t}startNoteHasMoreStartingSlurs(){if(!this.startNote)return!1;for(let t=0,e=this.startNote.NoteSlurs.length;t{"use strict";var i;Object.defineProperty(e,"__esModule",{value:!0}),e.DynamicExpressionSymbolEnum=void 0,(i=e.DynamicExpressionSymbolEnum||(e.DynamicExpressionSymbolEnum={}))[i.p=0]="p",i[i.f=1]="f",i[i.s=2]="s",i[i.z=3]="z",i[i.m=4]="m",i[i.r=5]="r"},9793:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.DynamicEnum=e.InstantaneousDynamicExpression=void 0;const n=i(3748),r=i(4802),o=i(1703),a=s(i(2043)),l=i(1649);class h extends n.AbstractExpression{constructor(t,e,i,s,n){super(i),super.parentMeasure=n,this.dynamicEnum=c[t.toLowerCase()],this.soundDynamic=e,this.staffNumber=s}static staticConstructor(){h.dynamicToRelativeVolumeDict.setValue(c.ffffff,1),h.dynamicToRelativeVolumeDict.setValue(c.fffff,126/127),h.dynamicToRelativeVolumeDict.setValue(c.ffff,125/127),h.dynamicToRelativeVolumeDict.setValue(c.fff,124/127),h.dynamicToRelativeVolumeDict.setValue(c.ff,122/127),h.dynamicToRelativeVolumeDict.setValue(c.f,108/127),h.dynamicToRelativeVolumeDict.setValue(c.mf,76/127),h.dynamicToRelativeVolumeDict.setValue(c.sf,.5),h.dynamicToRelativeVolumeDict.setValue(c.sfp,.5),h.dynamicToRelativeVolumeDict.setValue(c.sfpp,.5),h.dynamicToRelativeVolumeDict.setValue(c.fp,.5),h.dynamicToRelativeVolumeDict.setValue(c.rf,.5),h.dynamicToRelativeVolumeDict.setValue(c.rfz,.5),h.dynamicToRelativeVolumeDict.setValue(c.sfz,.5),h.dynamicToRelativeVolumeDict.setValue(c.sffz,.5),h.dynamicToRelativeVolumeDict.setValue(c.fz,.5),h.dynamicToRelativeVolumeDict.setValue(c.mp,60/127),h.dynamicToRelativeVolumeDict.setValue(c.p,28/127),h.dynamicToRelativeVolumeDict.setValue(c.pp,12/127),h.dynamicToRelativeVolumeDict.setValue(c.ppp,10/127),h.dynamicToRelativeVolumeDict.setValue(c.pppp,7/127),h.dynamicToRelativeVolumeDict.setValue(c.ppppp,5/127),h.dynamicToRelativeVolumeDict.setValue(c.pppppp,4/127)}get ParentMultiExpression(){return this.multiExpression}set ParentMultiExpression(t){this.multiExpression=t}get DynEnum(){return this.dynamicEnum}set DynEnum(t){this.dynamicEnum=t}get SoundDynamic(){return this.soundDynamic}set SoundDynamic(t){this.soundDynamic=t}get Placement(){return this.placement}set Placement(t){this.placement=t}get StaffNumber(){return this.staffNumber}set StaffNumber(t){this.staffNumber=t}get Length(){return Math.abs(this.length)<1e-4&&(this.length=this.calculateLength()),this.length}get MidiVolume(){return 127*this.Volume}get Volume(){return h.dynamicToRelativeVolumeDict.getValue(this.dynamicEnum)}static isInputStringInstantaneousDynamic(t){return!!t&&h.isStringInStringList(h.listInstantaneousDynamics,t)}getDynamicExpressionSymbol(t){switch(t){case"p":return r.DynamicExpressionSymbolEnum.p;case"f":return r.DynamicExpressionSymbolEnum.f;case"s":return r.DynamicExpressionSymbolEnum.s;case"z":return r.DynamicExpressionSymbolEnum.z;case"m":return r.DynamicExpressionSymbolEnum.m;case"r":return r.DynamicExpressionSymbolEnum.r;default:throw new o.InvalidEnumArgumentException("unknown DynamicExpressionSymbolEnum: "+t)}}calculateLength(){return a.default.debug("[Andrea] instantaneousDynamicExpression: not implemented: calculateLength!"),0}}var c;e.InstantaneousDynamicExpression=h,h.dynamicToRelativeVolumeDict=new l.Dictionary,h.listInstantaneousDynamics=["pppppp","ppppp","pppp","ppp","pp","p","ffffff","fffff","ffff","fff","ff","f","mf","mp","sf","sff","sp","spp","fp","rf","rfz","sfz","sffz","fz"],function(t){t[t.pppppp=0]="pppppp",t[t.ppppp=1]="ppppp",t[t.pppp=2]="pppp",t[t.ppp=3]="ppp",t[t.pp=4]="pp",t[t.p=5]="p",t[t.mp=6]="mp",t[t.mf=7]="mf",t[t.f=8]="f",t[t.ff=9]="ff",t[t.fff=10]="fff",t[t.ffff=11]="ffff",t[t.fffff=12]="fffff",t[t.ffffff=13]="ffffff",t[t.sf=14]="sf",t[t.sff=15]="sff",t[t.sfp=16]="sfp",t[t.sfpp=17]="sfpp",t[t.fp=18]="fp",t[t.rf=19]="rf",t[t.rfz=20]="rfz",t[t.sfz=21]="sfz",t[t.sffz=22]="sffz",t[t.fz=23]="fz",t[t.other=24]="other"}(c=e.DynamicEnum||(e.DynamicEnum={})),h.staticConstructor()},9667:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TempoEnum=e.InstantaneousTempoExpression=void 0;const s=i(9775),n=i(1703),r=i(1797);class o extends s.AbstractTempoExpression{constructor(t,e,i,s,n,r=!1){super(t,e,i,n),this.setTempoAndTempoType(s)}static getDefaultValueForTempoType(t){switch(t){case a.larghissimo:return 20;case a.grave:return 30;case a.lento:return 48;case a.largo:return 52;case a.larghetto:return 63;case a.adagio:return 70;case a.adagietto:return 75;case a.andanteModerato:return 88;case a.andante:return 92;case a.andantino:return 96;case a.moderato:return 106;case a.allegretto:return 112;case a.allegroModerato:return 118;case a.allegro:return 130;case a.vivace:return 140;case a.vivacissimo:return 155;case a.allegrissimo:return 170;case a.presto:return 184;case a.prestissimo:return 200;default:throw new n.ArgumentOutOfRangeException("tempoEnum")}}static isInputStringInstantaneousTempo(t){return!!t&&(o.isStringInStringList(o.listInstantaneousTempoLarghissimo,t)||o.isStringInStringList(o.listInstantaneousTempoGrave,t)||o.isStringInStringList(o.listInstantaneousTempoLento,t)||o.isStringInStringList(o.listInstantaneousTempoLargo,t)||o.isStringInStringList(o.listInstantaneousTempoLarghetto,t)||o.isStringInStringList(o.listInstantaneousTempoAdagio,t)||o.isStringInStringList(o.listInstantaneousTempoAdagietto,t)||o.isStringInStringList(o.listInstantaneousTempoAndanteModerato,t)||o.isStringInStringList(o.listInstantaneousTempoAndante,t)||o.isStringInStringList(o.listInstantaneousTempoAndantino,t)||o.isStringInStringList(o.listInstantaneousTempoModerato,t)||o.isStringInStringList(o.listInstantaneousTempoAllegretto,t)||o.isStringInStringList(o.listInstantaneousTempoAllegroModerato,t)||o.isStringInStringList(o.listInstantaneousTempoAllegro,t)||o.isStringInStringList(o.listInstantaneousTempoVivace,t)||o.isStringInStringList(o.listInstantaneousTempoVivacissimo,t)||o.isStringInStringList(o.listInstantaneousTempoAllegrissimo,t)||o.isStringInStringList(o.listInstantaneousTempoPresto,t)||o.isStringInStringList(o.listInstantaneousTempoPrestissimo,t)||o.isStringInStringList(o.listInstantaneousTempoChangesGeneral,t))}get Label(){return this.label}set Label(t){this.label=t}get Placement(){return this.placement}set Placement(t){this.placement=t}get StaffNumber(){return this.staffNumber}set StaffNumber(t){this.staffNumber=t}get Enum(){return this.tempoEnum}get TempoInBpm(){return this.tempoInBpm}set TempoInBpm(t){this.tempoInBpm=t}get ParentMultiTempoExpression(){return this.parentMultiTempoExpression}getAbsoluteTimestamp(){return r.Fraction.plus(this.ParentMultiTempoExpression.SourceMeasureParent.AbsoluteTimestamp,this.ParentMultiTempoExpression.Timestamp)}getAbsoluteFloatTimestamp(){return r.Fraction.plus(this.ParentMultiTempoExpression.SourceMeasureParent.AbsoluteTimestamp,this.ParentMultiTempoExpression.Timestamp).RealValue}setTempoAndTempoType(t){return this.label?o.isStringInStringList(o.listInstantaneousTempoLarghissimo,this.label)?(0===t&&(t=o.getDefaultValueForTempoType(a.larghissimo)),this.tempoInBpm=t,void(this.tempoEnum=a.larghissimo)):o.isStringInStringList(o.listInstantaneousTempoGrave,this.label)?(0===t&&(t=o.getDefaultValueForTempoType(a.grave)),this.tempoInBpm=t,void(this.tempoEnum=a.grave)):o.isStringInStringList(o.listInstantaneousTempoLento,this.label)?(0===t&&(t=o.getDefaultValueForTempoType(a.lento)),this.tempoInBpm=t,void(this.tempoEnum=a.lento)):o.isStringInStringList(o.listInstantaneousTempoLargo,this.label)?(0===t&&(t=o.getDefaultValueForTempoType(a.largo)),this.tempoInBpm=t,void(this.tempoEnum=a.largo)):o.isStringInStringList(o.listInstantaneousTempoLarghetto,this.label)?(0===t&&(t=o.getDefaultValueForTempoType(a.larghetto)),this.tempoInBpm=t,void(this.tempoEnum=a.larghetto)):o.isStringInStringList(o.listInstantaneousTempoAdagio,this.label)?(0===t&&(t=o.getDefaultValueForTempoType(a.adagio)),this.tempoInBpm=t,void(this.tempoEnum=a.adagio)):o.isStringInStringList(o.listInstantaneousTempoAdagietto,this.label)?(0===t&&(t=o.getDefaultValueForTempoType(a.adagietto)),this.tempoInBpm=t,void(this.tempoEnum=a.adagietto)):o.isStringInStringList(o.listInstantaneousTempoAndanteModerato,this.label)?(0===t&&(t=o.getDefaultValueForTempoType(a.andanteModerato)),this.tempoInBpm=t,void(this.tempoEnum=a.andanteModerato)):o.isStringInStringList(o.listInstantaneousTempoAndante,this.label)?(0===t&&(t=o.getDefaultValueForTempoType(a.andante)),this.tempoInBpm=t,void(this.tempoEnum=a.andante)):o.isStringInStringList(o.listInstantaneousTempoAndantino,this.label)?(0===t&&(t=o.getDefaultValueForTempoType(a.andantino)),this.tempoInBpm=t,void(this.tempoEnum=a.andantino)):o.isStringInStringList(o.listInstantaneousTempoModerato,this.label)?(0===t&&(t=o.getDefaultValueForTempoType(a.moderato)),this.tempoInBpm=t,void(this.tempoEnum=a.moderato)):o.isStringInStringList(o.listInstantaneousTempoAllegretto,this.label)?(0===t&&(t=o.getDefaultValueForTempoType(a.allegretto)),this.tempoInBpm=t,void(this.tempoEnum=a.allegretto)):o.isStringInStringList(o.listInstantaneousTempoAllegroModerato,this.label)?(0===t&&(t=o.getDefaultValueForTempoType(a.allegroModerato)),this.tempoInBpm=t,void(this.tempoEnum=a.allegroModerato)):o.isStringInStringList(o.listInstantaneousTempoAllegro,this.label)?(0===t&&(t=o.getDefaultValueForTempoType(a.allegro)),this.tempoInBpm=t,void(this.tempoEnum=a.allegro)):o.isStringInStringList(o.listInstantaneousTempoVivace,this.label)?(0===t&&(t=o.getDefaultValueForTempoType(a.vivace)),this.tempoInBpm=t,void(this.tempoEnum=a.vivace)):o.isStringInStringList(o.listInstantaneousTempoVivacissimo,this.label)?(0===t&&(t=o.getDefaultValueForTempoType(a.vivacissimo)),this.tempoInBpm=t,void(this.tempoEnum=a.vivacissimo)):o.isStringInStringList(o.listInstantaneousTempoAllegrissimo,this.label)?(0===t&&(t=o.getDefaultValueForTempoType(a.allegrissimo)),this.tempoInBpm=t,void(this.tempoEnum=a.allegrissimo)):o.isStringInStringList(o.listInstantaneousTempoPresto,this.label)?(0===t&&(t=o.getDefaultValueForTempoType(a.presto)),this.tempoInBpm=t,void(this.tempoEnum=a.presto)):o.isStringInStringList(o.listInstantaneousTempoPrestissimo,this.label)?(0===t&&(t=o.getDefaultValueForTempoType(a.prestissimo)),this.tempoInBpm=t,void(this.tempoEnum=a.prestissimo)):o.isStringInStringList(o.listInstantaneousTempoAddons,this.label)?(this.tempoInBpm=0,void(this.tempoEnum=a.addon)):o.isStringInStringList(o.listInstantaneousTempoChangesGeneral,this.label)?(this.tempoInBpm=0,void(this.tempoEnum=a.changes)):void 0:(this.tempoInBpm=t,void(this.tempoEnum=a.metronomeMark))}}var a;e.InstantaneousTempoExpression=o,o.listInstantaneousTempoLarghissimo=["Larghissimo","Sehr breit","very, very slow"],o.listInstantaneousTempoGrave=["Grave","Schwer","slow and solemn"],o.listInstantaneousTempoLento=["Lento","Lent","Langsam","slowly"],o.listInstantaneousTempoLargo=["Largo","Breit","broadly"],o.listInstantaneousTempoLarghetto=["Larghetto","Etwas breit","rather broadly"],o.listInstantaneousTempoAdagio=["Adagio","Langsam","Ruhig","slow and stately"],o.listInstantaneousTempoAdagietto=["Adagietto","Ziemlich ruhig","Ziemlich langsam","rather slow"],o.listInstantaneousTempoAndanteModerato=["Andante moderato"],o.listInstantaneousTempoAndante=["Andante","Gehend","Schreitend","at a walking pace"],o.listInstantaneousTempoAndantino=["Andantino"],o.listInstantaneousTempoModerato=["Moderato","Mäßig","Modéré","moderately"],o.listInstantaneousTempoAllegretto=["Allegretto","fast"],o.listInstantaneousTempoAllegroModerato=["Allegro moderato"],o.listInstantaneousTempoAllegro=["Allegro","Rapide","Vite","Rasch","Schnell","Fröhlich"],o.listInstantaneousTempoVivace=["Vivace","Lebhaft","Lebendig","lively and fast"],o.listInstantaneousTempoVivacissimo=["Vivacissimo","Sehr lebhaft","Sehr lebendig"],o.listInstantaneousTempoAllegrissimo=["Allegrissimo","very fast"],o.listInstantaneousTempoPresto=["Presto","Sehr schnell","Geschwind"],o.listInstantaneousTempoPrestissimo=["Prestissimo","äußerst schnell"],o.listInstantaneousTempoChangesGeneral=["tempo primo","a tempo","tempo i","rubato","doppio movimento","rallentando","ritardando","ritard.","rit.","ritard","rall...","accelerando","accel"],o.listInstantaneousTempoAddons=["assai","amoroso","cantabile","con brio","con dolore","con espressione","con fuoco","con moto","con spirito","spiritoso","espressivo","giocoso","giusto","grazioso","lesto","lugubre","maestoso","ma non troppo","marcato","molto","morendo","mosso","non tanto","piu","un poco","poco","quasi","risoluto","scherzando","sostenuto","teneramente","tempo giusto","tranquillo","sehr","lieblich","liebevoll","mit Leidenschaft","mit Liebe","amourös","gesanglich","mit Schwung","mit Feuer","mit Schmerz","mit Ausdruck","mit Bewegung","geistvoll","ausdrucksvoll","freudig","verspielt","angemessen","graziös","mit Grazie","flink","behände","traurig","klagend","majestätisch","aber nicht zu sehr","markant","gemäßigt","viel","sehr","ersterbend","bewegt","nicht zu sehr","mehr","ein wenig","gleichsam","entschlossen","zupackend","heiter","nachdrücklich","getragen","gewichtig","zart","zärtlich","im angemessenen Zeitmaß","ruhig","ein wenig","alla marcia","ad libitum","alla breve"],function(t){t[t.none=0]="none",t[t.larghissimo=1]="larghissimo",t[t.grave=2]="grave",t[t.lento=3]="lento",t[t.largo=4]="largo",t[t.larghetto=5]="larghetto",t[t.adagio=6]="adagio",t[t.adagietto=7]="adagietto",t[t.andanteModerato=8]="andanteModerato",t[t.andante=9]="andante",t[t.andantino=10]="andantino",t[t.moderato=11]="moderato",t[t.allegretto=12]="allegretto",t[t.allegroModerato=13]="allegroModerato",t[t.allegro=14]="allegro",t[t.vivace=15]="vivace",t[t.vivacissimo=16]="vivacissimo",t[t.allegrissimo=17]="allegrissimo",t[t.presto=18]="presto",t[t.prestissimo=19]="prestissimo",t[t.lastRealTempo=20]="lastRealTempo",t[t.addon=21]="addon",t[t.changes=22]="changes",t[t.metronomeMark=23]="metronomeMark"}(a=e.TempoEnum||(e.TempoEnum={}))},7527:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MoodEnum=e.MoodExpression=void 0;const s=i(3748);class n extends s.AbstractExpression{constructor(t,e,i){super(e),this.label=t,this.staffNumber=i,this.setMoodType()}static isInputStringMood(t){return!!t&&(n.isStringInStringList(n.listMoodAffettuoso,t)||n.isStringInStringList(n.listMoodAgitato,t)||n.isStringInStringList(n.listMoodAnimato,t)||n.isStringInStringList(n.listMoodAppassionato,t)||n.isStringInStringList(n.listMoodBrillante,t)||n.isStringInStringList(n.listMoodCantabile,t)||n.isStringInStringList(n.listMoodDolce,t)||n.isStringInStringList(n.listMoodEnergico,t)||n.isStringInStringList(n.listMoodEroico,t)||n.isStringInStringList(n.listMoodEspressivo,t)||n.isStringInStringList(n.listMoodFurioso,t)||n.isStringInStringList(n.listMoodGiocoso,t)||n.isStringInStringList(n.listMoodGioioso,t)||n.isStringInStringList(n.listMoodGrandioso,t)||n.isStringInStringList(n.listMoodGrazioso,t)||n.isStringInStringList(n.listMoodLacrimoso,t)||n.isStringInStringList(n.listMoodLeggiero,t)||n.isStringInStringList(n.listMoodMaestoso,t)||n.isStringInStringList(n.listMoodMalinconico,t)||n.isStringInStringList(n.listMoodMarcato,t)||n.isStringInStringList(n.listMoodMarziale,t)||n.isStringInStringList(n.listMoodMesto,t)||n.isStringInStringList(n.listMoodMorendo,t)||n.isStringInStringList(n.listMoodNobilmente,t)||n.isStringInStringList(n.listMoodPatetico,t)||n.isStringInStringList(n.listMoodPesante,t)||n.isStringInStringList(n.listMoodSaltando,t)||n.isStringInStringList(n.listMoodSautille,t)||n.isStringInStringList(n.listMoodScherzando,t)||n.isStringInStringList(n.listMoodSostenuto,t)||n.isStringInStringList(n.listMoodSpiccato,t)||n.isStringInStringList(n.listMoodTenerezza,t)||n.isStringInStringList(n.listMoodTranquillamente,t)||n.isStringInStringList(n.listMoodTrionfante,t))}get Label(){return this.label}set Label(t){this.label=t}get Mood(){return this.moodType}set Mood(t){this.moodType=t}get StaffNumber(){return this.staffNumber}set StaffNumber(t){this.staffNumber=t}get Placement(){return this.placement}set Placement(t){this.placement=t}setMoodType(){n.isStringInStringList(n.listMoodAffettuoso,this.label)?this.moodType=r.Affettuoso:n.isStringInStringList(n.listMoodAgitato,this.label)?this.moodType=r.Agitato:n.isStringInStringList(n.listMoodAnimato,this.label)?this.moodType=r.Animato:n.isStringInStringList(n.listMoodAppassionato,this.label)?this.moodType=r.Appassionato:n.isStringInStringList(n.listMoodBrillante,this.label)?this.moodType=r.Brillante:n.isStringInStringList(n.listMoodCantabile,this.label)?this.moodType=r.Cantabile:n.isStringInStringList(n.listMoodDolce,this.label)?this.moodType=r.Dolce:n.isStringInStringList(n.listMoodEnergico,this.label)?this.moodType=r.Energico:n.isStringInStringList(n.listMoodEroico,this.label)?this.moodType=r.Eroico:n.isStringInStringList(n.listMoodEspressivo,this.label)?this.moodType=r.Espressivo:n.isStringInStringList(n.listMoodFurioso,this.label)?this.moodType=r.Furioso:n.isStringInStringList(n.listMoodGiocoso,this.label)?this.moodType=r.Giocoso:n.isStringInStringList(n.listMoodGioioso,this.label)?this.moodType=r.Gioioso:n.isStringInStringList(n.listMoodGrandioso,this.label)?this.moodType=r.Grandioso:n.isStringInStringList(n.listMoodGrazioso,this.label)?this.moodType=r.Grazioso:n.isStringInStringList(n.listMoodLacrimoso,this.label)?this.moodType=r.Lacrimoso:n.isStringInStringList(n.listMoodLeggiero,this.label)?this.moodType=r.Leggiero:n.isStringInStringList(n.listMoodMaestoso,this.label)?this.moodType=r.Maestoso:n.isStringInStringList(n.listMoodMalinconico,this.label)?this.moodType=r.Malinconico:n.isStringInStringList(n.listMoodMarcato,this.label)?this.moodType=r.Marcato:n.isStringInStringList(n.listMoodMarziale,this.label)?this.moodType=r.Marziale:n.isStringInStringList(n.listMoodMesto,this.label)?this.moodType=r.Mesto:n.isStringInStringList(n.listMoodMorendo,this.label)?this.moodType=r.Morendo:n.isStringInStringList(n.listMoodNobilmente,this.label)?this.moodType=r.Nobilmente:n.isStringInStringList(n.listMoodPatetico,this.label)?this.moodType=r.Patetico:n.isStringInStringList(n.listMoodPesante,this.label)?this.moodType=r.Pesante:n.isStringInStringList(n.listMoodSaltando,this.label)?this.moodType=r.Saltando:n.isStringInStringList(n.listMoodSautille,this.label)?this.moodType=r.Sautille:n.isStringInStringList(n.listMoodScherzando,this.label)?this.moodType=r.Scherzando:n.isStringInStringList(n.listMoodSostenuto,this.label)?this.moodType=r.Sostenuto:n.isStringInStringList(n.listMoodSpiccato,this.label)?this.moodType=r.Spiccato:n.isStringInStringList(n.listMoodTenerezza,this.label)?this.moodType=r.Tenerezza:n.isStringInStringList(n.listMoodTranquillamente,this.label)?this.moodType=r.Tranquillamente:n.isStringInStringList(n.listMoodTrionfante,this.label)&&(this.moodType=r.Trionfante)}}var r;e.MoodExpression=n,n.listMoodAffettuoso=["affettuoso"],n.listMoodAgitato=["agitato"],n.listMoodAppassionato=["appassionato"],n.listMoodAnimato=["animato","lively"],n.listMoodBrillante=["brillante"],n.listMoodCantabile=["cantabile"],n.listMoodDolce=["dolce"],n.listMoodEnergico=["energico"],n.listMoodEroico=["eroico"],n.listMoodEspressivo=["espressivo"],n.listMoodFurioso=["furioso"],n.listMoodGiocoso=["giocoso"],n.listMoodGioioso=["gioioso"],n.listMoodLacrimoso=["lacrimoso"],n.listMoodGrandioso=["grandioso"],n.listMoodGrazioso=["grazioso"],n.listMoodLeggiero=["leggiero"],n.listMoodMaestoso=["maestoso"],n.listMoodMalinconico=["malinconico"],n.listMoodMarcato=["marcato"],n.listMoodMarziale=["marziale"],n.listMoodMesto=["mesto"],n.listMoodMorendo=["morendo"],n.listMoodNobilmente=["nobilmente"],n.listMoodPatetico=["patetico"],n.listMoodPesante=["pesante"],n.listMoodSautille=["sautille"],n.listMoodSaltando=["saltando"],n.listMoodScherzando=["scherzando"],n.listMoodSostenuto=["sostenuto"],n.listMoodSpiccato=["spiccato"],n.listMoodTenerezza=["tenerezza"],n.listMoodTranquillamente=["tranquillamente"],n.listMoodTrionfante=["trionfante"],function(t){t[t.Affettuoso=0]="Affettuoso",t[t.Agitato=1]="Agitato",t[t.Appassionato=2]="Appassionato",t[t.Animato=3]="Animato",t[t.Brillante=4]="Brillante",t[t.Cantabile=5]="Cantabile",t[t.Dolce=6]="Dolce",t[t.Energico=7]="Energico",t[t.Eroico=8]="Eroico",t[t.Espressivo=9]="Espressivo",t[t.Furioso=10]="Furioso",t[t.Giocoso=11]="Giocoso",t[t.Gioioso=12]="Gioioso",t[t.Lacrimoso=13]="Lacrimoso",t[t.Grandioso=14]="Grandioso",t[t.Grazioso=15]="Grazioso",t[t.Leggiero=16]="Leggiero",t[t.Maestoso=17]="Maestoso",t[t.Malinconico=18]="Malinconico",t[t.Marcato=19]="Marcato",t[t.Marziale=20]="Marziale",t[t.Mesto=21]="Mesto",t[t.Morendo=22]="Morendo",t[t.Nobilmente=23]="Nobilmente",t[t.Patetico=24]="Patetico",t[t.Pesante=25]="Pesante",t[t.Sautille=26]="Sautille",t[t.Saltando=27]="Saltando",t[t.Scherzando=28]="Scherzando",t[t.Sostenuto=29]="Sostenuto",t[t.Spiccato=30]="Spiccato",t[t.Tenerezza=31]="Tenerezza",t[t.Tranquillamente=32]="Tranquillamente",t[t.Trionfante=33]="Trionfante",t[t.Vivace=34]="Vivace"}(r=e.MoodEnum||(e.MoodEnum={}))},6943:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MultiExpressionEntry=e.MultiExpression=void 0;const s=i(1797),n=i(9793),r=i(7839),o=i(7527),a=i(1614),l=i(3748),h=i(2562);e.MultiExpression=class{constructor(t,e){this.unknownList=[],this.moodList=[],this.expressions=[],this.sourceMeasure=t,this.timestamp=e}get SourceMeasureParent(){return this.sourceMeasure}set SourceMeasureParent(t){this.sourceMeasure=t}get StaffNumber(){return this.staffNumber}set StaffNumber(t){this.staffNumber=t}get Timestamp(){return this.timestamp}set Timestamp(t){this.timestamp=t}get AbsoluteTimestamp(){return s.Fraction.plus(this.timestamp,this.sourceMeasure.AbsoluteTimestamp)}get InstantaneousDynamic(){return this.instantaneousDynamic}set InstantaneousDynamic(t){this.instantaneousDynamic=t}get EndingContinuousDynamic(){return this.endingContinuousDynamic}set EndingContinuousDynamic(t){this.endingContinuousDynamic=t}get StartingContinuousDynamic(){return this.startingContinuousDynamic}set StartingContinuousDynamic(t){this.startingContinuousDynamic=t}get MoodList(){return this.moodList}get UnknownList(){return this.unknownList}get EntriesList(){return this.expressions}get OctaveShiftStart(){return this.octaveShiftStart}set OctaveShiftStart(t){this.octaveShiftStart=t}get OctaveShiftEnd(){return this.octaveShiftEnd}set OctaveShiftEnd(t){this.octaveShiftEnd=t}get CombinedExpressionsText(){return this.combinedExpressionsText}set CombinedExpressionsText(t){this.combinedExpressionsText=t}getPlacementOfFirstEntry(){let t=l.PlacementEnum.Above;return this.expressions.length>0&&(this.expressions[0].expression instanceof n.InstantaneousDynamicExpression||this.expressions[0].expression instanceof r.ContinuousDynamicExpression||this.expressions[0].expression instanceof o.MoodExpression||this.expressions[0].expression instanceof a.UnknownExpression)&&(t=this.expressions[0].expression.Placement),t}getFontstyleOfFirstEntry(){var t;let e=h.FontStyles.Regular;return this.expressions.length>0&&(this.expressions[0].expression instanceof r.ContinuousDynamicExpression||this.expressions[0].expression instanceof o.MoodExpression?e=h.FontStyles.Italic:this.expressions[0].expression instanceof a.UnknownExpression&&(e=null!==(t=this.expressions[0].expression.fontStyle)&&void 0!==t?t:h.FontStyles.Regular)),e}addExpression(t,e){t instanceof n.InstantaneousDynamicExpression?(this.instantaneousDynamic&&this.removeExpressionFromEntryList(this.InstantaneousDynamic),this.instantaneousDynamic=t,this.instantaneousDynamic.ParentMultiExpression=this):t instanceof r.ContinuousDynamicExpression?this.startingContinuousDynamic=t:t instanceof o.MoodExpression?this.moodList.push(t):t instanceof a.UnknownExpression&&this.unknownList.push(t),this.addExpressionToEntryList(t,e)}CompareTo(t){return this.Timestamp.RealValue>t.Timestamp.RealValue?1:this.Timestamp.RealValue{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TempoExpressionEntry=e.MultiTempoExpression=void 0;const s=i(1797),n=i(9667),r=i(3748),o=i(2562),a=i(280);e.MultiTempoExpression=class{constructor(t,e){this.expressions=[],this.sourceMeasure=t,this.timestamp=e}get Timestamp(){return this.timestamp}get AbsoluteTimestamp(){return s.Fraction.plus(this.sourceMeasure.AbsoluteTimestamp,this.timestamp)}get SourceMeasureParent(){return this.sourceMeasure}set SourceMeasureParent(t){this.sourceMeasure=t}get InstantaneousTempo(){return this.instantaneousTempo}get ContinuousTempo(){return this.continuousTempo}get EntriesList(){return this.expressions}get CombinedExpressionsText(){return this.combinedExpressionsText}set CombinedExpressionsText(t){this.combinedExpressionsText=t}getPlacementOfFirstEntry(){let t=r.PlacementEnum.Above;return this.expressions.length>0&&(this.expressions[0].Expression instanceof n.InstantaneousTempoExpression||this.expressions[0].Expression instanceof a.ContinuousTempoExpression)&&(t=this.expressions[0].Expression.Placement),t}getFontstyleOfFirstEntry(){let t=o.FontStyles.Regular;return this.expressions[0].Expression instanceof n.InstantaneousTempoExpression?t=o.FontStyles.Bold:this.expressions[0].Expression instanceof a.ContinuousTempoExpression&&(t=o.FontStyles.Italic),t}addExpression(t,e){if(this.checkIfAlreadyExists(t))return;t instanceof n.InstantaneousTempoExpression?this.instantaneousTempo=t:t instanceof a.ContinuousTempoExpression&&(this.continuousTempo=t);const i=new l;i.prefix=e,i.Expression=t,i.label=t.Label,this.expressions.push(i)}CompareTo(t){return this.Timestamp.RealValue>t.Timestamp.RealValue?1:this.Timestamp.RealValue{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RehearsalExpression=void 0;const s=i(3748);class n extends s.AbstractExpression{constructor(t,e){super(e),this.label=t}}e.RehearsalExpression=n},1614:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UnknownExpression=void 0;const s=i(3748),n=i(1274);class r extends s.AbstractExpression{constructor(t,e,i,s){super(e),this.label=t,this.staffNumber=s,void 0===i&&(i=n.TextAlignmentEnum.LeftBottom),this.textAlignment=i}get Label(){return this.label}get Placement(){return this.placement}set Placement(t){this.placement=t}get StaffNumber(){return this.staffNumber}set StaffNumber(t){this.staffNumber=t}get TextAlignment(){return this.textAlignment}}e.UnknownExpression=r},2343:function(t,e,i){"use strict";var s=this&&this.__createBinding||(Object.create?function(t,e,i,s){void 0===s&&(s=i);var n=Object.getOwnPropertyDescriptor(e,i);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,s,n)}:function(t,e,i,s){void 0===s&&(s=i),t[s]=e[i]}),n=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||s(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(i(3748),e),n(i(9775),e),n(i(4802),e),n(i(9793),e),n(i(9667),e),n(i(7527),e),n(i(6943),e),n(i(6124),e),n(i(7513),e),n(i(1614),e)},7198:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Glissando=void 0;const s=i(1797),n=i(8911);e.Glissando=class{constructor(t){this.notes=[],this.XMLNumber=1,this.AddNote(t),this.StartNote=t,this.Direction=n.ColDirEnum.NotYetDefined}get Notes(){return this.notes}get Duration(){const t=new s.Fraction;for(const e of this.notes)t.Add(e.Length);return t}get Pitch(){return this.StartNote.Pitch}AddNote(t){this.notes.push(t),t.NoteGlissando=this,2===this.notes.length&&(this.notes[0].Pitch.getHalfTone(){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DynamicsContainer=void 0;const s=i(7839),n=i(9793);e.DynamicsContainer=class{constructor(t,e){t instanceof s.ContinuousDynamicExpression?this.continuousDynamicExpression=t:t instanceof n.InstantaneousDynamicExpression&&(this.instantaneousDynamicExpression=t),this.staffNumber=e}parMultiExpression(){return this.continuousDynamicExpression?this.continuousDynamicExpression.StartMultiExpression:this.instantaneousDynamicExpression?this.instantaneousDynamicExpression.ParentMultiExpression:void 0}CompareTo(t){return this.parMultiExpression().AbsoluteTimestamp.CompareTo(t.parMultiExpression().AbsoluteTimestamp)}}},1877:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AbstractNotationInstruction=void 0,e.AbstractNotationInstruction=class{constructor(t){this.printObject=!0,this.parent=t}get Parent(){return this.parent}set Parent(t){this.parent=t}get PrintObject(){return this.printObject}set PrintObject(t){this.printObject=t}}},289:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MidiInstrument=e.ClefEnum=e.ClefInstruction=void 0;const s=i(8640),n=i(1877),r=i(8640),o=i(8640),a=i(1703);class l extends n.AbstractNotationInstruction{constructor(t=h.G,e=0,i=2){super(void 0),this.clefType=h.G,this.line=2,this.octaveOffset=0,this.line=i,this.clefType=t,this.octaveOffset=e,this.calcParameters()}static getDefaultClefFromMidiInstrument(t){switch(t){case c.Acoustic_Grand_Piano:case c.Electric_Bass_finger:case c.Electric_Bass_pick:case c.Fretless_Bass:case c.Slap_Bass_1:case c.Slap_Bass_2:case c.Synth_Bass_1:case c.Synth_Bass_2:case c.Contrabass:return new l(h.F,0,4);default:return new l(h.G,0,2)}}static getAllPossibleClefs(){const t=[];for(let e=0;e<=2;e++){const i=new l(h.G,e,2);t.push(i)}for(let e=-2;e<=0;e++){const i=new l(h.F,e,4);t.push(i)}return t}static isSupportedClef(t){switch(t){case h.G:case h.F:case h.C:case h.percussion:case h.TAB:return!0;default:return!1}}get ClefType(){return this.clefType}set ClefType(t){this.clefType=t}get Line(){return this.line}set Line(t){this.line=t}get OctaveOffset(){return this.octaveOffset}set OctaveOffset(t){this.octaveOffset=t}get ClefPitch(){return this.clefPitch}set ClefPitch(t){this.clefPitch=t}get ReferenceCyPosition(){return this.referenceCyPosition}set ReferenceCyPosition(t){this.referenceCyPosition=t}Equals(t){return this===t||!(!this||!t)&&this.clefPitch===t.clefPitch&&this.Line===t.Line}NotEqual(t){return!this.Equals(t)}ToString(){return"ClefType: "+this.clefType}calcParameters(){switch(this.clefType){case h.G:this.clefPitch=new s.Pitch(r.NoteEnum.G,1+this.octaveOffset,o.AccidentalEnum.NONE),this.referenceCyPosition=5-this.line+2;break;case h.F:this.clefPitch=new s.Pitch(r.NoteEnum.F,0+this.octaveOffset,o.AccidentalEnum.NONE),this.referenceCyPosition=5-this.line+1.5;break;case h.C:this.clefPitch=new s.Pitch(r.NoteEnum.C,1+this.octaveOffset,o.AccidentalEnum.NONE),this.referenceCyPosition=5-this.line;break;case h.percussion:this.clefPitch=new s.Pitch(r.NoteEnum.C,2,o.AccidentalEnum.NONE),this.referenceCyPosition=2;break;case h.TAB:this.clefPitch=new s.Pitch(r.NoteEnum.G,0,o.AccidentalEnum.NONE),this.referenceCyPosition=0;break;default:throw new a.ArgumentOutOfRangeException("clefType")}}}var h,c;e.ClefInstruction=l,function(t){t[t.G=0]="G",t[t.F=1]="F",t[t.C=2]="C",t[t.percussion=3]="percussion",t[t.TAB=4]="TAB"}(h=e.ClefEnum||(e.ClefEnum={})),function(t){t[t.None=-1]="None",t[t.Acoustic_Grand_Piano=0]="Acoustic_Grand_Piano",t[t.Bright_Acoustic_Piano=1]="Bright_Acoustic_Piano",t[t.Electric_Grand_Piano=2]="Electric_Grand_Piano",t[t.Honky_tonk_Piano=3]="Honky_tonk_Piano",t[t.Electric_Piano_1=4]="Electric_Piano_1",t[t.Electric_Piano_2=5]="Electric_Piano_2",t[t.Harpsichord=6]="Harpsichord",t[t.Clavinet=7]="Clavinet",t[t.Celesta=8]="Celesta",t[t.Glockenspiel=9]="Glockenspiel",t[t.Music_Box=10]="Music_Box",t[t.Vibraphone=11]="Vibraphone",t[t.Marimba=12]="Marimba",t[t.Xylophone=13]="Xylophone",t[t.Tubular_Bells=14]="Tubular_Bells",t[t.Dulcimer=15]="Dulcimer",t[t.Drawbar_Organ=16]="Drawbar_Organ",t[t.Percussive_Organ=17]="Percussive_Organ",t[t.Rock_Organ=18]="Rock_Organ",t[t.Church_Organ=19]="Church_Organ",t[t.Reed_Organ=20]="Reed_Organ",t[t.Accordion=21]="Accordion",t[t.Harmonica=22]="Harmonica",t[t.Tango_Accordion=23]="Tango_Accordion",t[t.Acoustic_Guitar_nylon=24]="Acoustic_Guitar_nylon",t[t.Acoustic_Guitar_steel=25]="Acoustic_Guitar_steel",t[t.Electric_Guitar_jazz=26]="Electric_Guitar_jazz",t[t.Electric_Guitar_clean=27]="Electric_Guitar_clean",t[t.Electric_Guitar_muted=28]="Electric_Guitar_muted",t[t.Overdriven_Guitar=29]="Overdriven_Guitar",t[t.Distortion_Guitar=30]="Distortion_Guitar",t[t.Guitar_harmonics=31]="Guitar_harmonics",t[t.Acoustic_Bass=32]="Acoustic_Bass",t[t.Electric_Bass_finger=33]="Electric_Bass_finger",t[t.Electric_Bass_pick=34]="Electric_Bass_pick",t[t.Fretless_Bass=35]="Fretless_Bass",t[t.Slap_Bass_1=36]="Slap_Bass_1",t[t.Slap_Bass_2=37]="Slap_Bass_2",t[t.Synth_Bass_1=38]="Synth_Bass_1",t[t.Synth_Bass_2=39]="Synth_Bass_2",t[t.Violin=40]="Violin",t[t.Viola=41]="Viola",t[t.Cello=42]="Cello",t[t.Contrabass=43]="Contrabass",t[t.Tremolo_Strings=44]="Tremolo_Strings",t[t.Pizzicato_Strings=45]="Pizzicato_Strings",t[t.Orchestral_Harp=46]="Orchestral_Harp",t[t.Timpani=47]="Timpani",t[t.String_Ensemble_1=48]="String_Ensemble_1",t[t.String_Ensemble_2=49]="String_Ensemble_2",t[t.Synth_Strings_1=50]="Synth_Strings_1",t[t.Synth_Strings_2=51]="Synth_Strings_2",t[t.Choir_Aahs=52]="Choir_Aahs",t[t.Voice_Oohs=53]="Voice_Oohs",t[t.Synth_Voice=54]="Synth_Voice",t[t.Orchestra_Hit=55]="Orchestra_Hit",t[t.Trumpet=56]="Trumpet",t[t.Trombone=57]="Trombone",t[t.Tuba=58]="Tuba",t[t.Muted_Trumpet=59]="Muted_Trumpet",t[t.French_Horn=60]="French_Horn",t[t.Brass_Section=61]="Brass_Section",t[t.Synth_Brass_1=62]="Synth_Brass_1",t[t.Synth_Brass_2=63]="Synth_Brass_2",t[t.Soprano_Sax=64]="Soprano_Sax",t[t.Alto_Sax=65]="Alto_Sax",t[t.Tenor_Sax=66]="Tenor_Sax",t[t.Baritone_Sax=67]="Baritone_Sax",t[t.Oboe=68]="Oboe",t[t.English_Horn=69]="English_Horn",t[t.Bassoon=70]="Bassoon",t[t.Clarinet=71]="Clarinet",t[t.Piccolo=72]="Piccolo",t[t.Flute=73]="Flute",t[t.Recorder=74]="Recorder",t[t.Pan_Flute=75]="Pan_Flute",t[t.Blown_Bottle=76]="Blown_Bottle",t[t.Shakuhachi=77]="Shakuhachi",t[t.Whistle=78]="Whistle",t[t.Ocarina=79]="Ocarina",t[t.Lead_1_square=80]="Lead_1_square",t[t.Lead_2_sawtooth=81]="Lead_2_sawtooth",t[t.Lead_3_calliope=82]="Lead_3_calliope",t[t.Lead_4_chiff=83]="Lead_4_chiff",t[t.Lead_5_charang=84]="Lead_5_charang",t[t.Lead_6_voice=85]="Lead_6_voice",t[t.Lead_7_fifths=86]="Lead_7_fifths",t[t.Lead_8_bass_lead=87]="Lead_8_bass_lead",t[t.Pad_1_new_age=88]="Pad_1_new_age",t[t.Pad_2_warm=89]="Pad_2_warm",t[t.Pad_3_polysynth=90]="Pad_3_polysynth",t[t.Pad_4_choir=91]="Pad_4_choir",t[t.Pad_5_bowed=92]="Pad_5_bowed",t[t.Pad_6_metallic=93]="Pad_6_metallic",t[t.Pad_7_halo=94]="Pad_7_halo",t[t.Pad_8_sweep=95]="Pad_8_sweep",t[t.FX_1_rain=96]="FX_1_rain",t[t.FX_2_soundtrack=97]="FX_2_soundtrack",t[t.FX_3_crystal=98]="FX_3_crystal",t[t.FX_4_atmosphere=99]="FX_4_atmosphere",t[t.FX_5_brightness=100]="FX_5_brightness",t[t.FX_6_goblins=101]="FX_6_goblins",t[t.FX_7_echoes=102]="FX_7_echoes",t[t.FX_8_scifi=103]="FX_8_scifi",t[t.Sitar=104]="Sitar",t[t.Banjo=105]="Banjo",t[t.Shamisen=106]="Shamisen",t[t.Koto=107]="Koto",t[t.Kalimba=108]="Kalimba",t[t.Bag_pipe=109]="Bag_pipe",t[t.Fiddle=110]="Fiddle",t[t.Shanai=111]="Shanai",t[t.Tinkle_Bell=112]="Tinkle_Bell",t[t.Agogo=113]="Agogo",t[t.Steel_Drums=114]="Steel_Drums",t[t.Woodblock=115]="Woodblock",t[t.Taiko_Drum=116]="Taiko_Drum",t[t.Melodic_Tom=117]="Melodic_Tom",t[t.Synth_Drum=118]="Synth_Drum",t[t.Reverse_Cymbal=119]="Reverse_Cymbal",t[t.Guitar_Fret_Noise=120]="Guitar_Fret_Noise",t[t.Breath_Noise=121]="Breath_Noise",t[t.Seashore=122]="Seashore",t[t.Bird_Tweet=123]="Bird_Tweet",t[t.Telephone_Ring=124]="Telephone_Ring",t[t.Helicopter=125]="Helicopter",t[t.Applause=126]="Applause",t[t.Gunshot=127]="Gunshot",t[t.Percussion=128]="Percussion"}(c=e.MidiInstrument||(e.MidiInstrument={}))},5198:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.KeyEnum=e.NoteEnumToHalfToneLink=e.KeyInstruction=void 0;const s=i(1877),n=i(8640),r=i(8640);class o extends s.AbstractNotationInstruction{constructor(t,e=0,i=a.major){super(t),this.isTransposedBy=0,this.Key=e,this.keyTypeOriginal=e,this.mode=i,this.alteratedNotes=this.calcAlteratedNotes()}static copy(t){const e=new o(t.parent,t.Key,t.Mode);return e.keyTypeOriginal=t.keyTypeOriginal,e}static getAllPossibleMajorKeyInstructions(){const t=[];for(let e=-7;e<7;e++){const i=new o(void 0,e,a.major);t.push(i)}return t}get Key(){return this.keyType}set Key(t){this.keyType=t,this.alteratedNotes=this.calcAlteratedNotes()}get Mode(){return this.mode}set Mode(t){this.mode=t}get AlteratedNotes(){return this.alteratedNotes}calcAlteratedNotes(){const t=[];if(this.keyType>0)for(let e=0;e=0}getAlterationForPitch(t){return this.keyType>0&&this.alteratedNotes.indexOf(t.FundamentalNote)<=this.keyType?r.AccidentalEnum.SHARP:this.keyType<0&&this.alteratedNotes.indexOf(t.FundamentalNote)<=Math.abs(this.keyType)?r.AccidentalEnum.FLAT:r.AccidentalEnum.NONE}ToString(){return"Key: "+this.keyType+this.mode}OperatorEquals(t){const e=this;return e===t||!(!e||!t)&&e.Key===t.Key&&e.Mode===t.Mode}OperatorNotEqual(t){return!this.OperatorEquals(t)}}var a;e.KeyInstruction=o,o.sharpPositionList=[n.NoteEnum.F,n.NoteEnum.C,n.NoteEnum.G,n.NoteEnum.D,n.NoteEnum.A,n.NoteEnum.E,n.NoteEnum.B],o.flatPositionList=[n.NoteEnum.B,n.NoteEnum.E,n.NoteEnum.A,n.NoteEnum.D,n.NoteEnum.G,n.NoteEnum.C,n.NoteEnum.F],e.NoteEnumToHalfToneLink=class{constructor(t,e){this.note=t,this.halfTone=e}},function(t){t[t.major=0]="major",t[t.minor=1]="minor",t[t.none=2]="none",t[t.dorian=3]="dorian",t[t.phrygian=4]="phrygian",t[t.lydian=5]="lydian",t[t.mixolydian=6]="mixolydian",t[t.aeolian=7]="aeolian",t[t.ionian=8]="ionian",t[t.locrian=9]="locrian"}(a=e.KeyEnum||(e.KeyEnum={}))},6189:(t,e)=>{"use strict";var i,s;Object.defineProperty(e,"__esModule",{value:!0}),e.AlignmentType=e.RepetitionInstructionEnum=e.RepetitionInstruction=e.RepetitionInstructionComparer=void 0,e.RepetitionInstructionComparer=class{static Compare(t,e){if(void 0!==t.parentRepetition&&e.parentRepetition){if(t.alignment===s.End&&e.alignment===s.End){if(t.parentRepetition.StartIndexe.parentRepetition.StartIndex)return-1}if(t.alignment===s.Begin&&e.alignment===s.Begin){if(t.parentRepetition.EndIndexe.parentRepetition.EndIndex)return-1}}return 0}},e.RepetitionInstruction=class{constructor(t,e,i=s.End,n,r){this.endingIndices=void 0,this.measureIndex=t,r&&(this.endingIndices=r.slice()),this.type=e,this.alignment=i,this.parentRepetition=n}CompareTo(t){const e=t;if(this.measureIndex>e.measureIndex)return 1;if(this.measureIndex{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RhythmSymbolEnum=e.RhythmInstruction=void 0;const s=i(1877);class n extends s.AbstractNotationInstruction{constructor(t,e){super(void 0),this.rhythm=t,this.numerator=t.Numerator,this.denominator=t.Denominator,this.symbolEnum=e}get Rhythm(){return this.rhythm}set Rhythm(t){this.rhythm=t}get SymbolEnum(){return this.symbolEnum}set SymbolEnum(t){this.symbolEnum=t}clone(){return new n(this.rhythm.clone(),this.symbolEnum)}OperatorEquals(t){const e=this;return e===t||!(!e||!t)&&e.numerator===t.numerator&&e.denominator===t.denominator}OperatorNotEqual(t){return!(this===t)}ToString(){return"Rhythm: "+this.rhythm.toString()}}var r;e.RhythmInstruction=n,(r=e.RhythmSymbolEnum||(e.RhythmSymbolEnum={}))[r.NONE=0]="NONE",r[r.COMMON=1]="COMMON",r[r.CUT=2]="CUT"},1357:(t,e)=>{"use strict";var i;Object.defineProperty(e,"__esModule",{value:!0}),e.TechnicalInstruction=e.TechnicalInstructionType=void 0,(i=e.TechnicalInstructionType||(e.TechnicalInstructionType={}))[i.Fingering=0]="Fingering",i[i.String=1]="String",e.TechnicalInstruction=class{}},6065:function(t,e,i){"use strict";var s=this&&this.__createBinding||(Object.create?function(t,e,i,s){void 0===s&&(s=i);var n=Object.getOwnPropertyDescriptor(e,i);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,s,n)}:function(t,e,i,s){void 0===s&&(s=i),t[s]=e[i]}),n=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||s(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(i(1877),e),n(i(289),e),n(i(5198),e),n(i(6189),e),n(i(3331),e),n(i(1357),e)},2947:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.LinkedVoice=void 0;const s=i(3884);class n extends s.Voice{constructor(t,e,i){super(t,e),this.master=i}get Master(){return this.master}}e.LinkedVoice=n},7274:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.LyricsEntry=void 0;const s=i(2562);e.LyricsEntry=class{constructor(t,e,i,s,n=-1){this.text=t,this.word=i,this.parent=s,this.verseNumber=e,n>=0&&(this.syllableIndex=n)}get Text(){return this.text}set Text(t){this.text=t}get Word(){return this.word}get Parent(){return this.parent}set Parent(t){this.parent=t}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?s.FontStyles.Italic:s.FontStyles.Regular}}},2672:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.LyricWord=void 0,e.LyricWord=class{constructor(){this.syllables=[]}get Syllables(){return this.syllables}containsVoiceEntry(t){for(let e=0,i=this.Syllables.length;e{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Appearance=e.Note=void 0;const s=i(1797);var n;e.Note=class{constructor(t,e,i,s,n,r){this.slurs=[],this.playbackInstrumentId=void 0,this.notehead=void 0,this.printObject=!0,this.voiceEntry=t,this.parentStaffEntry=e,this.length=i,this.pitch=s,this.sourceMeasure=n,this.isRestFlag=null!=r&&r,this.halfTone=s?s.getHalfTone():0}get NoteAsString(){return this.pitch.toString()}get ParentVoiceEntry(){return this.voiceEntry}set ParentVoiceEntry(t){this.voiceEntry=t}get ParentStaffEntry(){return this.parentStaffEntry}get ParentStaff(){return this.parentStaffEntry.ParentStaff}get Length(){return this.length}set Length(t){this.length=t}get SourceMeasure(){return this.sourceMeasure}get TypeLength(){return this.typeLength}set TypeLength(t){this.typeLength=t}get NoteTypeXml(){return this.noteTypeXml}set NoteTypeXml(t){this.noteTypeXml=t}get NormalNotes(){return this.normalNotes}set NormalNotes(t){this.normalNotes=t}get Pitch(){return this.pitch}get NoteBeam(){return this.beam}set NoteBeam(t){this.beam=t}set Notehead(t){this.notehead=t}get Notehead(){return this.notehead}get NoteTuplet(){return this.tuplet}set NoteTuplet(t){this.tuplet=t}get NoteGlissando(){return this.glissando}set NoteGlissando(t){this.glissando=t}get NoteTie(){return this.tie}set NoteTie(t){this.tie=t}get NoteSlurs(){return this.slurs}set NoteSlurs(t){this.slurs=t}get PlaybackInstrumentId(){return this.playbackInstrumentId}set PlaybackInstrumentId(t){this.playbackInstrumentId=t}get PrintObject(){return this.printObject}set PrintObject(t){this.printObject=t}get Arpeggio(){return this.arpeggio}set Arpeggio(t){this.arpeggio=t}get IsCueNote(){return this.isCueNote}set IsCueNote(t){this.isCueNote=t}get StemDirectionXml(){return this.stemDirectionXml}set StemDirectionXml(t){this.stemDirectionXml=t}get TremoloStrokes(){return this.tremoloStrokes}set TremoloStrokes(t){this.tremoloStrokes=t}get StemColorXml(){return this.stemColorXml}set StemColorXml(t){this.stemColorXml=t}get NoteheadColorXml(){return this.noteheadColorXml}set NoteheadColorXml(t){this.noteheadColorXml=t}get NoteheadColor(){return this.noteheadColor}set NoteheadColor(t){this.noteheadColor=t}get NoteheadColorCurrentlyRendered(){return this.noteheadColorCurrentlyRendered}set NoteheadColorCurrentlyRendered(t){this.noteheadColorCurrentlyRendered=t}isRest(){return this.isRestFlag}isWholeRest(){return this.isRest()&&this.Length.RealValue===this.sourceMeasure.ActiveTimeSignature.RealValue}isWholeMeasureNote(){return this.Length.RealValue===this.sourceMeasure.ActiveTimeSignature.RealValue}ToString(){return this.pitch?this.Pitch.ToString()+", length: "+this.length.toString():"rest note, length: "+this.length.toString()}getAbsoluteTimestamp(){return s.Fraction.plus(this.voiceEntry.Timestamp,this.sourceMeasure.AbsoluteTimestamp)}isDuplicateSlur(t){for(let e=0,i=this.slurs.length;e{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.NoteTypeHandler=e.NoteType=void 0;const s=i(1797),n=i(6331),r=i(1703);var o;!function(t){t[t.UNDEFINED=0]="UNDEFINED",t[t._1024th=1]="_1024th",t[t._512th=2]="_512th",t[t._256th=3]="_256th",t[t._128th=4]="_128th",t[t._64th=5]="_64th",t[t._32nd=6]="_32nd",t[t._16th=7]="_16th",t[t.EIGTH=8]="EIGTH",t[t.QUARTER=9]="QUARTER",t[t.HALF=10]="HALF",t[t.WHOLE=11]="WHOLE",t[t.BREVE=12]="BREVE",t[t.LONG=13]="LONG",t[t.MAXIMA=14]="MAXIMA"}(o=e.NoteType||(e.NoteType={}));class a{static NoteTypeToString(t){return this.NoteTypeXmlValues[t]}static StringToNoteType(t){const e=this.NoteTypeXmlValues.indexOf(t);return-1!==e?e:o.UNDEFINED}static getNoteDurationFromType(t){switch(t){case"1024th":return new s.Fraction(1,1024);case"512th":return new s.Fraction(1,512);case"256th":return new s.Fraction(1,256);case"128th":return new s.Fraction(1,128);case"64th":return new s.Fraction(1,64);case"32th":case"32nd":return new s.Fraction(1,32);case"16th":return new s.Fraction(1,16);case"eighth":return new s.Fraction(1,8);case"quarter":return new s.Fraction(1,4);case"half":return new s.Fraction(1,2);case"whole":return new s.Fraction(1,1);case"breve":return new s.Fraction(2,1);case"long":return new s.Fraction(4,1);case"maxima":return new s.Fraction(8,1);default:{const t=n.ITextTranslation.translateText("ReaderErrorMessages/NoteDurationError","Invalid note duration.");throw new r.MusicSheetReadingException(t)}}}}e.NoteTypeHandler=a,a.NoteTypeXmlValues=["","1024th","512th","256th","128th","64th","32nd","16th","eigth","quarter","half","whole","breve","long","maxima"]},766:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.NoteHeadShape=e.Notehead=void 0;const n=s(i(2043));class r{constructor(t,e,i){this.sourceNote=t,this.setShapeFromXml(e,i)}setShapeFromXml(t,e){this.shape=r.ShapeTypeXmlToShape(t);let i=e;void 0===i&&(this.sourceNote?i=this.sourceNote.Length.Denominator>2:(n.default.warn("notehead: sourceNote and filledXmlAttribute undefined."),i=!0)),this.filled=i}get SourceNote(){return this.sourceNote}get Shape(){return this.shape}get Filled(){return this.filled}static ShapeTypeXmlToShape(t){switch(t.toLowerCase()){case"normal":return o.NORMAL;case"x":return o.X;case"slash":return o.SLASH;case"diamond":return o.DIAMOND;case"square":case"la":return o.SQUARE;case"do":case"triangle":return o.TRIANGLE;case"rectangle":return o.RECTANGLE;case"circle-x":return o.CIRCLEX;default:return n.default.info("unsupported/unhandled xml notehead '"+t+"'. Using normal notehead."),o.NORMAL}}}var o;e.Notehead=r,function(t){t[t.CIRCLEX=0]="CIRCLEX",t[t.DIAMOND=1]="DIAMOND",t[t.NORMAL=2]="NORMAL",t[t.RECTANGLE=3]="RECTANGLE",t[t.SLASH=4]="SLASH",t[t.SQUARE=5]="SQUARE",t[t.TRIANGLE=6]="TRIANGLE",t[t.X=7]="X"}(o=e.NoteHeadShape||(e.NoteHeadShape={}))},5922:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.OrnamentEnum=e.OrnamentContainer=void 0;const s=i(8640),n=i(3748);var r;e.OrnamentContainer=class{constructor(t){this.placement=n.PlacementEnum.Above,this.accidentalAbove=s.AccidentalEnum.NONE,this.accidentalBelow=s.AccidentalEnum.NONE,this.ornament=t}get GetOrnament(){return this.ornament}get AccidentalAbove(){return this.accidentalAbove}set AccidentalAbove(t){this.accidentalAbove=t}get AccidentalBelow(){return this.accidentalBelow}set AccidentalBelow(t){this.accidentalBelow=t}},(r=e.OrnamentEnum||(e.OrnamentEnum={}))[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"},5942:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SourceMeasure=void 0;const s=i(1797),n=i(141),r=i(9050),o=i(6189),a=i(908),l=i(289),h=i(5198),c=i(6894);e.SourceMeasure=class{constructor(t,e){this.printNewSystemXml=!1,this.printNewPageXml=!1,this.IsSystemStartMeasure=!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=c.SystemLinesEnum.SingleThin,this.firstInstructionsStaffEntries=new Array(t),this.lastInstructionsStaffEntries=new Array(t),this.rules=e,this.TempoInBPM=0;for(let e=0;e1)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,e,i){let s,o;for(const e of this.verticalSourceStaffEntryContainers)if(e.Timestamp.Equals(t)){o=e;break}if(o)return o.StaffEntries[e]?s=o.StaffEntries[e]:(s=new r.SourceStaffEntry(o,i),o.StaffEntries[e]=s),{createdNewContainer:!1,staffEntry:s};const a=this.verticalSourceStaffEntryContainers[this.verticalSourceStaffEntryContainers.length-1];if(0===this.verticalSourceStaffEntryContainers.length||a.Timestamp.lt(t)){const o=new n.VerticalSourceStaffEntryContainer(this,t.clone(),this.completeNumberOfStaves);this.verticalSourceStaffEntryContainers.push(o),s=new r.SourceStaffEntry(o,i),o.StaffEntries[e]=s}else for(let o=this.verticalSourceStaffEntryContainers.length-1;o>=0;o--){if(this.verticalSourceStaffEntryContainers[o].Timestamp.lt(t)){const a=new n.VerticalSourceStaffEntryContainer(this,t.clone(),this.completeNumberOfStaves);this.verticalSourceStaffEntryContainers.splice(o+1,0,a),s=new r.SourceStaffEntry(a,i),a.StaffEntries[e]=s;break}if(0===o){const a=new n.VerticalSourceStaffEntryContainer(this,t.clone(),this.completeNumberOfStaves);this.verticalSourceStaffEntryContainers.splice(o,0,a),s=new r.SourceStaffEntry(a,i),a.StaffEntries[e]=s;break}}return{createdNewContainer:!0,staffEntry:s}}findOrCreateVoiceEntry(t,e){let i,s=!1;for(const s of t.VoiceEntries)if(s.ParentVoice===e){i=s;break}return i||(i=new a.VoiceEntry(t.Timestamp,e,t),s=!0),{createdVoiceEntry:s,voiceEntry:i}}getPreviousSourceStaffEntryFromIndex(t,e){for(let i=e-1;i>=0;i--)if(this.verticalSourceStaffEntryContainers[i][t])return this.verticalSourceStaffEntryContainers[i][t]}getVerticalContainerIndexByTimestamp(t){for(let e=0,i=this.VerticalSourceStaffEntryContainers.length;e=0;e--){const t=this.verticalSourceStaffEntryContainers[e][r+n];if(void 0!==t&&t.hasTie()&&i.lt(s.Fraction.plus(t.Timestamp,t.calculateMaxNoteLength()))){i=s.Fraction.plus(t.Timestamp,t.calculateMaxNoteLength());break}}}n.push(i)}for(let t=0,e=n.length;t0)return!0}return!1}beginsWithLineRepetition(){for(let t=0,e=this.FirstRepetitionInstructions.length;t=0&&(e=this.verticalSourceStaffEntryContainers[i].StaffEntries[t],!e);i--);return e}canBeReducedToMultiRest(){var t,e;if(this.firstRepetitionInstructions.length>0||this.lastRepetitionInstructions.length>0)return!1;let i=!0,s=!1;for(const t of this.verticalSourceStaffEntryContainers)if(t)for(const e of t.StaffEntries)if(e&&e.ParentStaff.ParentInstrument.Visible){if(e.ChordContainers.length>0)return!1;e.ParentStaff.hasLyrics&&(s=!0);for(const t of e.VoiceEntries){for(const e of t.Notes)if(!e.isRest()){i=!1;break}if(!i)break}}if(!i||s||this.hasMoodExpressions||this.tempoExpressions.length>0)return!1;for(const t of this.staffLinkedExpressions)if(t.length>0)return!1;for(const t of this.lastInstructionsStaffEntries)for(let e=0,i=null==t?void 0:t.Instructions.length;e{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SourceStaffEntry=void 0;const s=i(1797),n=i(289),r=i(5198),o=i(3331);e.SourceStaffEntry=class{constructor(t,e){this.voiceEntries=[],this.instructions=[],this.chordSymbolContainers=[],this.verticalContainerParent=t,this.parentStaff=e}get ParentStaff(){return this.parentStaff}get VerticalContainerParent(){return this.verticalContainerParent}get Timestamp(){if(this.VerticalContainerParent)return this.VerticalContainerParent.Timestamp}get AbsoluteTimestamp(){if(this.VerticalContainerParent)return s.Fraction.plus(this.VerticalContainerParent.ParentMeasure.AbsoluteTimestamp,this.VerticalContainerParent.Timestamp)}get VoiceEntries(){return this.voiceEntries}set VoiceEntries(t){this.voiceEntries=t}get Link(){return this.staffEntryLink}set Link(t){this.staffEntryLink=t}get Instructions(){return this.instructions}set Instructions(t){this.instructions=t}get ChordContainers(){return this.chordSymbolContainers}set ChordContainers(t){this.chordSymbolContainers=t}removeAllInstructionsOfTypeClefInstruction(){let t=0,e=0;for(;t0)return!0;return!1}hasTie(){for(let t=0,e=this.VoiceEntries.length;t{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Staff=void 0,e.Staff=class{constructor(t,e){this.isTab=!1,this.voices=[],this.volume=1,this.stafflineCount=5,this.hasLyrics=!1,this.openTieDict={},this.parentInstrument=t,this.id=e,this.audible=!0,this.following=!0}get ParentInstrument(){return this.parentInstrument}set ParentInstrument(t){this.parentInstrument=t}get Voices(){return this.voices}get Id(){return this.id}get Volume(){return this.volume}set Volume(t){this.volume=t}get StafflineCount(){return this.stafflineCount}set StafflineCount(t){this.stafflineCount=t}}},4447:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.StaffEntryLink=void 0,e.StaffEntryLink=class{constructor(t){this.linkStaffEntries=[],this.voiceEntry=t}get GetVoiceEntry(){return this.voiceEntry}get LinkStaffEntries(){return this.linkStaffEntries}set LinkStaffEntries(t){this.linkStaffEntries=t}}},2953:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TabNote=void 0;const s=i(5253);class n extends s.Note{constructor(t,e,i,s,n,r,o,a,l){super(t,e,i,s,n),this.stringNumberTab=r,this.fretNumber=o,this.bendArray=a,this.vibratoStroke=l}get StringNumberTab(){return this.stringNumberTab}get FretNumber(){return this.fretNumber}get BendArray(){return this.bendArray}get VibratoStroke(){return this.vibratoStroke}}e.TabNote=n},4555:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Tie=void 0;const n=i(1797),r=i(3748),o=s(i(2043));e.Tie=class{constructor(t,e){this.notes=[],this.TieNumber=1,this.TieDirection=r.PlacementEnum.NotYetDefined,this.NoteIndexToTieDirection={},this.AddNote(t),this.type=e}getTieDirection(t){if(!t)return this.TieDirection;for(let e=0;e{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Tuplet=void 0,e.Tuplet=class{constructor(t,e=!1){this.PlacementFromXml=!1,this.RenderTupletNumber=!0,this.notes=[],this.fractions=[],this.tupletLabelNumber=t,this.bracket=e}get TupletLabelNumber(){return this.tupletLabelNumber}set TupletLabelNumber(t){this.tupletLabelNumber=t}get Notes(){return this.notes}set Notes(t){this.notes=t}get Fractions(){return this.fractions}set Fractions(t){this.fractions=t}get Bracket(){return this.bracket}set Bracket(t){this.bracket=t}getNoteIndex(t){for(let e=this.notes.length-1;e>=0;e--)for(let i=0;i{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.VerticalSourceStaffEntryContainer=void 0;const s=i(1797);e.VerticalSourceStaffEntryContainer=class{constructor(t,e,i){this.staffEntries=[],this.comments=[],this.timestamp=e,this.staffEntries=new Array(i),this.parentMeasure=t}$get$(t){return this.staffEntries[t]}$set$(t,e){this.staffEntries[t]=e}get Timestamp(){return this.timestamp}set Timestamp(t){this.timestamp=t}get StaffEntries(){return this.staffEntries}set StaffEntries(t){this.staffEntries=t}get Comments(){return this.comments}set Comments(t){this.comments=t}get ParentMeasure(){return this.parentMeasure}set ParentMeasure(t){this.parentMeasure=t}getAbsoluteTimestamp(){return s.Fraction.plus(this.timestamp,this.parentMeasure.AbsoluteTimestamp)}}},3884:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Voice=void 0,e.Voice=class{constructor(t,e){this.voiceEntries=[],this.volume=1,this.parent=t,this.visible=!0,this.audible=!0,this.following=!0,this.voiceId=e}get VoiceEntries(){return this.voiceEntries}get Parent(){return this.parent}get Visible(){return this.visible}set Visible(t){this.visible=t}get Audible(){return this.audible}set Audible(t){this.audible=t}get Following(){return this.following}set Following(t){this.following=t}get VoiceId(){return this.voiceId}get Volume(){return this.volume}set Volume(t){this.volume=t}}},908:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.StemDirectionType=e.ArticulationEnum=e.VoiceEntry=void 0;const s=i(1797),n=i(5253),r=i(8640),o=i(5922),a=i(8640),l=i(1649);class h{constructor(t,e,i,s=!1,n=!1,r=!1){if(this.notes=[],this.articulations=[],this.technicalInstructions=[],this.lyricsEntries=new l.Dictionary,this.wantedStemDirection=u.Undefined,this.stemDirectionXml=u.Undefined,this.stemDirection=u.Undefined,this.timestamp=t,this.parentVoice=e,this.parentSourceStaffEntry=i,this.isGrace=s,this.graceAfterMainNote=!1,this.graceNoteSlash=n,this.graceSlur=r,void 0!==i){const t=i.VoiceEntries;-1===t.indexOf(this)&&t.push(this)}}get ParentSourceStaffEntry(){return this.parentSourceStaffEntry}get ParentVoice(){return this.parentVoice}get Timestamp(){return this.timestamp}set Timestamp(t){this.timestamp=t}get Notes(){return this.notes}get IsGrace(){return this.isGrace}set IsGrace(t){this.isGrace=t}get GraceAfterMainNote(){return this.graceAfterMainNote}set GraceAfterMainNote(t){this.graceAfterMainNote=t}get GraceNoteSlash(){return this.graceNoteSlash}set GraceNoteSlash(t){this.graceNoteSlash=t}get GraceSlur(){return this.graceSlur}set GraceSlur(t){this.graceSlur=t}get Articulations(){return this.articulations}set Articulations(t){this.articulations=t}get TechnicalInstructions(){return this.technicalInstructions}get LyricsEntries(){return this.lyricsEntries}get Arpeggio(){return this.arpeggio}set Arpeggio(t){this.arpeggio=t}get OrnamentContainer(){return this.ornamentContainer}set OrnamentContainer(t){this.ornamentContainer=t}set WantedStemDirection(t){this.wantedStemDirection=t}get WantedStemDirection(){return this.wantedStemDirection}set StemDirectionXml(t){this.stemDirectionXml=t}get StemDirectionXml(){return this.stemDirectionXml}set StemDirection(t){this.stemDirection=t}get StemDirection(){return this.stemDirection}get StemColorXml(){return this.stemColorXml}set StemColorXml(t){this.stemColorXml=t}get StemColor(){return this.stemColor}set StemColor(t){this.stemColor=t}hasArticulation(t){for(const e of this.articulations)if(e.Equals(t))return!0;return!1}static isSupportedArticulation(t){switch(t){case c.accent:case c.strongaccent:case c.softaccent:case c.invertedstrongaccent:case c.staccato:case c.staccatissimo:case c.spiccato:case c.tenuto:case c.fermata:case c.invertedfermata:case c.breathmark:case c.caesura:case c.lefthandpizzicato:case c.naturalharmonic:case c.snappizzicato:case c.upbow:case c.downbow:case c.bend:return!0;default:return!1}}hasTie(){for(let t=0,e=this.Notes.length;t0)return!0;return!1}isStaccato(){for(const t of this.Articulations)if(t.articulationEnum===c.staccato)return!0;return!1}isAccent(){for(const t of this.Articulations)if(t.articulationEnum===c.accent||t.articulationEnum===c.strongaccent)return!0;return!1}getVerseNumberForLyricEntry(t){let e="1";return this.lyricsEntries.forEach(((i,s)=>{t===s&&(e=i)})),e}createVoiceEntriesForOrnament(t,e){t||(t=this);const i=[];if(!t.ornamentContainer)return;const n=this.notes[0],r=n.Length,l=t.ParentVoice,h=t.Timestamp;let c=s.Fraction.createFromFraction(h);switch(t.ornamentContainer.GetOrnament){case o.OrnamentEnum.Trill:{const o=new s.Fraction(r.Numerator,8*r.Denominator),u=n.Pitch.getTransposedPitch(1);let d=e.getAlterationForPitch(u);t.OrnamentContainer.AccidentalAbove!==a.AccidentalEnum.NONE&&(d=t.ornamentContainer.AccidentalAbove);for(let t=0;t<8;t++)c=s.Fraction.plus(h,new s.Fraction(t*o.Numerator,o.Denominator)),t%2==0?this.createBaseVoiceEntry(c,o,l,n,i):this.createAlteratedVoiceEntry(c,o,l,n.SourceMeasure,u,d,i);break}case o.OrnamentEnum.Turn:{const t=new s.Fraction(r.Numerator,4*r.Denominator),o=n.Pitch.getTransposedPitch(-1),a=e.getAlterationForPitch(o),h=n.Pitch.getTransposedPitch(1),u=e.getAlterationForPitch(h);this.createAlteratedVoiceEntry(c,t,l,n.SourceMeasure,h,u,i),c.Add(t),this.createBaseVoiceEntry(c,t,l,n,i),c.Add(t),this.createAlteratedVoiceEntry(c,t,l,n.SourceMeasure,o,a,i),c.Add(t),this.createBaseVoiceEntry(c,t,l,n,i);break}case o.OrnamentEnum.InvertedTurn:{const t=new s.Fraction(r.Numerator,4*r.Denominator),o=n.Pitch.getTransposedPitch(-1),a=e.getAlterationForPitch(o),h=n.Pitch.getTransposedPitch(1),u=e.getAlterationForPitch(h);this.createAlteratedVoiceEntry(c,t,l,n.SourceMeasure,o,a,i),c.Add(t),this.createBaseVoiceEntry(c,t,l,n,i),c.Add(t),this.createAlteratedVoiceEntry(c,t,l,n.SourceMeasure,h,u,i),c.Add(t),this.createBaseVoiceEntry(c,t,l,n,i);break}case o.OrnamentEnum.DelayedTurn:{const t=new s.Fraction(r.Numerator,2*r.Denominator),o=n.Pitch.getTransposedPitch(-1),a=e.getAlterationForPitch(o),u=n.Pitch.getTransposedPitch(1),d=e.getAlterationForPitch(u);this.createBaseVoiceEntry(c,t,l,n,i),c=s.Fraction.plus(h,t),t.Denominator=8*r.Denominator,this.createAlteratedVoiceEntry(c,t,l,n.SourceMeasure,u,d,i),c.Add(t),this.createBaseVoiceEntry(c,t,l,n,i),c.Add(t),this.createAlteratedVoiceEntry(c,t,l,n.SourceMeasure,o,a,i),c.Add(t),this.createBaseVoiceEntry(c,t,l,n,i);break}case o.OrnamentEnum.DelayedInvertedTurn:{const t=new s.Fraction(r.Numerator,2*r.Denominator),o=n.Pitch.getTransposedPitch(-1),a=e.getAlterationForPitch(o),u=n.Pitch.getTransposedPitch(1),d=e.getAlterationForPitch(u);this.createBaseVoiceEntry(c,t,l,n,i),c=s.Fraction.plus(h,t),t.Denominator=8*r.Denominator,this.createAlteratedVoiceEntry(c,t,l,n.SourceMeasure,o,a,i),c.Add(t),this.createBaseVoiceEntry(c,t,l,n,i),c.Add(t),this.createAlteratedVoiceEntry(c,t,l,n.SourceMeasure,u,d,i),c.Add(t),this.createBaseVoiceEntry(c,t,l,n,i);break}case o.OrnamentEnum.Mordent:{const t=new s.Fraction(r.Numerator,4*r.Denominator),o=n.Pitch.getTransposedPitch(1),a=e.getAlterationForPitch(o);this.createBaseVoiceEntry(c,t,l,n,i),c.Add(t),this.createAlteratedVoiceEntry(c,t,l,n.SourceMeasure,o,a,i),t.Denominator=2*r.Denominator,c=s.Fraction.plus(h,t),this.createBaseVoiceEntry(c,t,l,n,i);break}case o.OrnamentEnum.InvertedMordent:{const t=new s.Fraction(r.Numerator,4*r.Denominator),o=n.Pitch.getTransposedPitch(-1),a=e.getAlterationForPitch(o);this.createBaseVoiceEntry(c,t,l,n,i),c.Add(t),this.createAlteratedVoiceEntry(c,t,l,n.SourceMeasure,o,a,i),t.Denominator=2*r.Denominator,c=s.Fraction.plus(h,t),this.createBaseVoiceEntry(c,t,l,n,i);break}default:throw new RangeError}return i}createBaseVoiceEntry(t,e,i,s,o){const a=new h(t,i,s.ParentStaffEntry),l=new r.Pitch(s.Pitch.FundamentalNote,s.Pitch.Octave,s.Pitch.Accidental),c=new n.Note(a,void 0,e,l,s.SourceMeasure);a.Notes.push(c),o.push(a)}createAlteratedVoiceEntry(t,e,i,s,o,a,l){const c=new h(t,i,void 0),u=new r.Pitch(o.FundamentalNote,o.Octave,a),d=new n.Note(c,void 0,e,u,s);c.Notes.push(d),l.push(c)}}var c,u;e.VoiceEntry=h,function(t){t[t.accent=0]="accent",t[t.strongaccent=1]="strongaccent",t[t.softaccent=2]="softaccent",t[t.marcatoup=3]="marcatoup",t[t.marcatodown=4]="marcatodown",t[t.invertedstrongaccent=5]="invertedstrongaccent",t[t.staccato=6]="staccato",t[t.staccatissimo=7]="staccatissimo",t[t.spiccato=8]="spiccato",t[t.tenuto=9]="tenuto",t[t.fermata=10]="fermata",t[t.invertedfermata=11]="invertedfermata",t[t.breathmark=12]="breathmark",t[t.caesura=13]="caesura",t[t.lefthandpizzicato=14]="lefthandpizzicato",t[t.naturalharmonic=15]="naturalharmonic",t[t.snappizzicato=16]="snappizzicato",t[t.upbow=17]="upbow",t[t.downbow=18]="downbow",t[t.scoop=19]="scoop",t[t.plop=20]="plop",t[t.doit=21]="doit",t[t.falloff=22]="falloff",t[t.stress=23]="stress",t[t.unstress=24]="unstress",t[t.detachedlegato=25]="detachedlegato",t[t.otherarticulation=26]="otherarticulation",t[t.bend=27]="bend"}(c=e.ArticulationEnum||(e.ArticulationEnum={})),function(t){t[t.Undefined=-1]="Undefined",t[t.Up=0]="Up",t[t.Down=1]="Down",t[t.None=2]="None",t[t.Double=3]="Double"}(u=e.StemDirectionType||(e.StemDirectionType={}))},6550:function(t,e,i){"use strict";var s=this&&this.__createBinding||(Object.create?function(t,e,i,s){void 0===s&&(s=i);var n=Object.getOwnPropertyDescriptor(e,i);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,s,n)}:function(t,e,i,s){void 0===s&&(s=i),t[s]=e[i]}),n=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||s(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(i(3029),e),n(i(9224),e),n(i(4123),e),n(i(7198),e),n(i(2947),e),n(i(5253),e),n(i(766),e),n(i(2478),e),n(i(5922),e),n(i(5942),e),n(i(9050),e),n(i(0),e),n(i(4447),e),n(i(4555),e),n(i(8069),e),n(i(141),e),n(i(3884),e),n(i(908),e),n(i(6065),e),n(i(5253),e),n(i(2478),e),n(i(5942),e),n(i(9050),e),n(i(141),e),n(i(4555),e)},4761:function(t,e,i){"use strict";var s=this&&this.__createBinding||(Object.create?function(t,e,i,s){void 0===s&&(s=i);var n=Object.getOwnPropertyDescriptor(e,i);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,s,n)}:function(t,e,i,s){void 0===s&&(s=i),t[s]=e[i]}),n=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||s(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(i(1703),e),n(i(6842),e),n(i(884),e),n(i(2255),e),n(i(7514),e),n(i(5142),e),n(i(6550),e),n(i(4990),e),n(i(4257),e),n(i(9714),e),n(i(4759),e),n(i(4143),e)},3495:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AJAX=void 0,e.AJAX=class{static ajax(t,e=9e3){let i;const s=t.indexOf(".mxl")>-1?"text/plain; charset=x-user-defined":"application/xml";if(XMLHttpRequest)i=new XMLHttpRequest;else{if(!ActiveXObject)return Promise.reject(new Error("XMLHttp not supported."));i=new ActiveXObject("Microsoft.XMLHTTP")}return i.timeout=e,new Promise(((e,n)=>{i.onreadystatechange=()=>{i.readyState===XMLHttpRequest.DONE&&(200===i.status||0===i.status&&i.responseText?e(i.responseText):n(new Error("Could not retrieve requested URL "+i.status)))},i.ontimeout=t=>{n(new Error("Server request Timeout"))},i.overrideMimeType(s),i.open("GET",t,!0),i.send()}))}}},530:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Cursor=void 0;const s=i(1797);e.Cursor=class{constructor(t,e,i){this.hidden=!0,this.currentPageNumber=1,this.skipInvisibleNotes=!0,this.container=t,this.openSheetMusicDisplay=e,this.rules=this.openSheetMusicDisplay.EngravingRules,this.cursorOptions=i;let s=0;for(this.cursorElementId="cursorImg-0";document.getElementById(this.cursorElementId);)s++,this.cursorElementId=`cursorImg-${s}`;const n=document.createElement("img");n.id=this.cursorElementId,n.style.position="absolute",!0===this.cursorOptions.follow?(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 t;t=this.rules.PageBackgroundColor?"1":this.wantedZIndex,this.cursorElement.style.zIndex=t}init(t,e){this.manager=t,this.graphic=e,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 t=this.openSheetMusicDisplay.Sheet.SourceMeasures.length-1;let e=this.rules.MinMeasureToDrawIndex;e=Math.min(e,t);let i=this.rules.MaxMeasureToDrawIndex;if(i=Math.min(i,t),this.openSheetMusicDisplay.Sheet&&this.openSheetMusicDisplay.Sheet.SourceMeasures.length>e&&(this.openSheetMusicDisplay.Sheet.SelectionStart=this.openSheetMusicDisplay.Sheet.SourceMeasures[e].AbsoluteTimestamp),this.openSheetMusicDisplay.Sheet&&this.openSheetMusicDisplay.Sheet.SourceMeasures.length>i){const t=this.openSheetMusicDisplay.Sheet.SourceMeasures[i];this.openSheetMusicDisplay.Sheet.SelectionEnd=s.Fraction.plus(t.AbsoluteTimestamp,t.Duration)}this.iterator=this.manager.getIterator(),this.iterator.SkipInvisibleNotes=this.skipInvisibleNotes}getStaffEntryFromVoiceEntry(t){const e=t.ParentSourceStaffEntry.VerticalContainerParent.ParentMeasure.measureListIndex,i=t.ParentSourceStaffEntry.ParentStaff.idInMusicSheet;return this.graphic.findGraphicalStaffEntryFromMeasureList(i,e,t.ParentSourceStaffEntry)}update(){if(this.hidden||void 0===this.hidden||null===this.hidden)return;this.updateCurrentPage();const t=this.iterator;let e,i=t.CurrentVisibleVoiceEntries(),s=t.CurrentMeasureIndex,n=0,r=0,o=0;if(0!==i.length||t.FrontReached||t.EndReached||(t.moveToPrevious(),i=t.CurrentVisibleVoiceEntries(),t.moveToNext()),t.FrontReached&&0===i.length){t.moveToNext(),i=t.CurrentVisibleVoiceEntries();const s=this.findVisibleGraphicalMeasure(t.CurrentMeasureIndex);n=s.PositionAndShape.AbsolutePosition.x,e=s.ParentMusicSystem,t.moveToPrevious()}else if(t.EndReached||!t.CurrentVoiceEntries||0===i.length){t.moveToPrevious(),i=t.CurrentVisibleVoiceEntries(),s=t.CurrentMeasureIndex;const r=this.findVisibleGraphicalMeasure(t.CurrentMeasureIndex);n=r.PositionAndShape.AbsolutePosition.x+r.PositionAndShape.Size.width,e=r.ParentMusicSystem,t.moveToNext()}else if(t.CurrentMeasure.isReducedToMultiRest){const i=this.findVisibleGraphicalMeasure(t.CurrentMeasureIndex),s=i.parentSourceMeasure.multipleRestMeasures,r=t.CurrentMeasure.multipleRestMeasureNumber/(s+1),o=i.PositionAndShape.Size.width-i.beginInstructionsWidth;n=i.PositionAndShape.AbsolutePosition.x+i.beginInstructionsWidth+r*o,e=i.ParentMusicSystem}else{const t=i.map((t=>this.getStaffEntryFromVoiceEntry(t))).sort(((t,e)=>{var i,s,n,r;return(null===(s=null===(i=null==t?void 0:t.PositionAndShape)||void 0===i?void 0:i.AbsolutePosition)||void 0===s?void 0:s.x)<=(null===(r=null===(n=null==e?void 0:e.PositionAndShape)||void 0===n?void 0:n.AbsolutePosition)||void 0===r?void 0:r.x)?-1:1}))[0];t&&(n=t.PositionAndShape.AbsolutePosition.x,e=t.parentMeasure.ParentMusicSystem)}if(!e)return;r=e.PositionAndShape.AbsolutePosition.y+e.StaffLines[0].PositionAndShape.RelativePosition.y;let a=e.PositionAndShape.AbsolutePosition.y;const l=e.StaffLines[e.StaffLines.length-1];l&&(a+=l.PositionAndShape.RelativePosition.y+l.StaffHeight),o=a-r;const h=this.graphic.findGraphicalMeasure(s,0).PositionAndShape;if(this.updateWidthAndStyle(h,n,r,o),this.openSheetMusicDisplay.FollowCursor&&this.cursorOptions.follow)if(this.openSheetMusicDisplay.EngravingRules.RenderSingleHorizontalStaffline)this.cursorElement.scrollIntoView({behavior:"smooth",inline:"center"});else{const t=this.cursorElement.getBoundingClientRect().top;this.cursorElement.scrollIntoView({behavior:t<1e3?"smooth":"auto",block:"center"})}this.cursorElement.style.display=""}findVisibleGraphicalMeasure(t){for(let t=0;t{i.push.apply(i,t.Notes)})),i}GNotesUnderCursor(t){const e=this.VoicesUnderCursor(t),i=[];return e.forEach((t=>{i.push(...t.Notes.map((t=>this.rules.GNote(t))))})),i}updateCurrentPage(){let t=this.iterator.currentTimeStamp;t.RealValue<0&&(t=new s.Fraction(0,0));for(const e of this.graphic.MusicPages)if(e.MusicSystems.last().GetSystemsLastTimeStamp().gt(t)){const t=e.PageNumber;return t!==this.currentPageNumber&&(this.container.removeChild(this.cursorElement),this.container=document.getElementById("osmdCanvasPage"+t),this.container.appendChild(this.cursorElement)),this.currentPageNumber=t}return 1}get SkipInvisibleNotes(){return this.skipInvisibleNotes}set SkipInvisibleNotes(t){this.skipInvisibleNotes=t,this.iterator.SkipInvisibleNotes=t}get CursorOptions(){return this.cursorOptions}set CursorOptions(t){this.cursorOptions=t}}},41:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.OSMDOptions=e.SkyBottomLineBatchCalculatorBackendType=e.BackendType=e.FillEmptyMeasuresWithWholeRests=e.AlignRestOption=e.CursorType=void 0;const s=i(7459);var n,r,o,a,l;(l=e.CursorType||(e.CursorType={}))[l.Standard=0]="Standard",l[l.ThinLeft=1]="ThinLeft",l[l.ShortThinTopLeft=2]="ShortThinTopLeft",l[l.CurrentArea=3]="CurrentArea",l[l.CurrentAreaLeft=4]="CurrentAreaLeft",(a=e.AlignRestOption||(e.AlignRestOption={}))[a.Never=0]="Never",a[a.Always=1]="Always",a[a.Auto=2]="Auto",(o=e.FillEmptyMeasuresWithWholeRests||(e.FillEmptyMeasuresWithWholeRests={}))[o.No=0]="No",o[o.YesVisible=1]="YesVisible",o[o.YesInvisible=2]="YesInvisible",function(t){t[t.SVG=0]="SVG",t[t.Canvas=1]="Canvas"}(n=e.BackendType||(e.BackendType={})),(r=e.SkyBottomLineBatchCalculatorBackendType||(e.SkyBottomLineBatchCalculatorBackendType={}))[r.Plain=0]="Plain",r[r.WebGL=1]="WebGL",e.OSMDOptions=class{static OSMDOptionsStandard(){return{autoResize:!0,backend:"svg",drawingParameters:s.DrawingParametersEnum.default}}static BackendTypeFromString(t){return t&&"canvas"===t.toLowerCase()?n.Canvas:n.SVG}}},9629:function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.OpenSheetMusicDisplay=void 0;const n=i(9228),r=i(8738),o=i(1372),a=i(4324),l=i(4040),h=i(5820),c=i(9505),u=i(4028),d=i(530),f=i(7056),m=i(3495),p=s(i(2043)),b=i(7459),g=i(41),S=i(1405),y=i(3748),E=i(1649),v=i(8155),x=i(8640);class _{constructor(t,e=g.OSMDOptions.OSMDOptionsStandard()){if(this.version="1.7.6-release",this.cursorsOptions=[],this.cursors=[],this.zoom=1,this.zoomUpdated=!1,this.loadUrlTimeout=5e3,"string"==typeof t?this.container=document.getElementById(t):t&&"appendChild"in t&&(this.container=t),!this.container)throw new Error("Please pass a valid div container to OpenSheetMusicDisplay");void 0===e.autoResize&&(e.autoResize=!0),this.backendType=g.BackendType.SVG,this.setOptions(e)}get cursor(){return this.cursors[0]}load(t,e="Untitled Score"){if(this.reset(),"string"==typeof t){const e=t,i=this;if("PK"===e.substr(0,4))return p.default.debug("[OSMD] This is a zip file, unpack it first: "+e),f.MXLHelper.MXLtoXMLstring(e).then((t=>i.load(t)),(t=>{throw p.default.debug(t),new Error("OpenSheetMusicDisplay: Invalid MXL file")}));if(""===e.substr(0,3))return p.default.debug("[OSMD] UTF with BOM detected, truncate first three bytes and pass along: "+e),i.load(e.substr(3));let s=e;if(/^\s/.test(s)&&(s=s.trim()),s.substr(0,6).includes("i.load(t)),(t=>{throw t}));console.error("[OSMD] osmd.load(string): Could not process string. Did not find {t.init(this.sheet.MusicPartManager,this.graphic)}))}render(){var t;if(!this.graphic)throw new Error("OpenSheetMusicDisplay: Before rendering a music sheet, please load a MusicXML file");null===(t=this.drawer)||void 0===t||t.clear();let e=this.container.offsetWidth;this.rules.RenderSingleHorizontalStaffline&&(e=this.rules.SheetMaximumWidth),this.sheet.pageWidth=e/this.zoom/10,this.rules.PageFormat&&!this.rules.PageFormat.IsUndefined?(this.rules.PageHeight=this.sheet.pageWidth/this.rules.PageFormat.aspectRatio,p.default.debug("[OSMD] PageHeight: "+this.rules.PageHeight)):(p.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((t=>{t.update()})),this.zoomUpdated=!1}createOrRefreshRenderBackend(){this.drawer&&this.drawer.Backends&&(this.drawer.Backends[0]&&this.drawer.Backends[0].removeAllChildrenFromContainer(this.container),this.drawer.Backends.clear()),this.drawingParameters.Rules=this.rules,this.drawer=new h.VexFlowMusicSheetDrawer(this.drawingParameters),this.drawer.drawableBoundingBoxElement=this.DrawBoundingBox,this.drawer.bottomLineVisible=this.drawBottomLine,this.drawer.skyLineVisible=this.drawSkyLine;let t,e=this.container.offsetWidth;this.rules.RenderSingleHorizontalStaffline&&(e=10*(this.EngravingRules.PageLeftMargin+this.graphic.MusicPages[0].PositionAndShape.Size.width+this.EngravingRules.PageRightMargin)*this.zoom);const i=32767;for(const s of this.graphic.MusicPages){if(s.PageNumber>this.rules.MaxPageToDrawNumber)break;const n=this.createBackend(this.backendType,s),r=" exceeds CanvasBackend limit of 32767. Cutting off score.";n.getOSMDBackendType()===g.BackendType.Canvas&&e>i&&(p.default.warn("[OSMD] Warning: width of "+e+r),e=i),this.rules.PageFormat&&!this.rules.PageFormat.IsUndefined?t=e/this.rules.PageFormat.aspectRatio:(t=s.PositionAndShape.Size.height,t+=this.rules.PageBottomMargin,n.getOSMDBackendType()===g.BackendType.Canvas&&(t+=.1),t+=s.PositionAndShape.BorderTop,this.rules.RenderTitle&&(t+=this.rules.TitleTopDistance),t*=10*this.zoom),n.getOSMDBackendType()===g.BackendType.Canvas&&t>i&&(p.default.warn("[OSMD] Warning: height of "+t+r),t=Math.min(t,i)),n.resize(e,t),n.clear(),n.getContext().setFillStyle(this.rules.DefaultColorMusic),n.getContext().setStrokeStyle(this.rules.DefaultColorMusic),this.drawer.Backends.push(n),this.graphic.drawer=this.drawer}}exportSVG(){var t;for(const e of null===(t=this.drawer)||void 0===t?void 0:t.Backends)e instanceof c.SvgVexFlowBackend&&e.export()}IsReadyToRender(){return void 0!==this.graphic}clear(){this.drawer.clear(),this.reset()}setOptions(t){if(this.rules||(this.rules=new S.EngravingRules),this.drawingParameters||t.drawingParameters?t.drawingParameters&&(this.drawingParameters?this.drawingParameters.DrawingParametersEnum=b.DrawingParametersEnum[t.drawingParameters.toLowerCase()]:this.drawingParameters=new b.DrawingParameters(b.DrawingParametersEnum[t.drawingParameters],this.rules)):this.drawingParameters=new b.DrawingParameters(b.DrawingParametersEnum.default,this.rules),null==t)return void p.default.warn("warning: osmd.setOptions() called without an options parameter, has no effect.\nexample usage: osmd.setOptions({drawCredits: false, drawPartNames: false})");this.OnXMLRead=function(t){return t},t.onXMLRead&&(this.OnXMLRead=t.onXMLRead);let e=!this.drawer||!this.drawer.Backends||this.drawer.Backends.length<1;if(void 0!==t.backend){const i=g.OSMDOptions.BackendTypeFromString(t.backend);e=e||this.backendType!==i,this.backendType=i}this.needBackendUpdate=e,void 0!==t.autoBeam&&(this.rules.AutoBeamNotes=t.autoBeam);const i=t.autoBeamOptions;if(i&&(void 0===i.maintain_stem_directions&&(i.maintain_stem_directions=!1),this.rules.AutoBeamOptions=i,i.groups&&i.groups.length))for(const t of i.groups)if(2!==t.length)throw new Error("Each fraction in autoBeamOptions.groups must be of length 2, e.g. [3,4] for beaming three fourths");void 0!==t.percussionOneLineCutoff&&(this.rules.PercussionOneLineCutoff=t.percussionOneLineCutoff),0!==this.rules.PercussionOneLineCutoff&&void 0!==t.percussionForceVoicesOneLineCutoff&&(this.rules.PercussionForceVoicesOneLineCutoff=t.percussionForceVoicesOneLineCutoff),void 0!==t.alignRests&&(this.rules.AlignRests=t.alignRests),void 0!==t.coloringMode&&this.setColoringMode(t),void 0!==t.coloringEnabled&&(this.rules.ColoringEnabled=t.coloringEnabled),void 0!==t.colorStemsLikeNoteheads&&(this.rules.ColorStemsLikeNoteheads=t.colorStemsLikeNoteheads),t.disableCursor&&(this.drawingParameters.drawCursors=!1),t.drawHiddenNotes&&(this.drawingParameters.drawHiddenNotes=!0),void 0!==t.drawCredits&&(this.drawingParameters.DrawCredits=t.drawCredits),void 0!==t.drawComposer&&(this.drawingParameters.DrawComposer=t.drawComposer),void 0!==t.drawTitle&&(this.drawingParameters.DrawTitle=t.drawTitle),void 0!==t.drawSubtitle&&(this.drawingParameters.DrawSubtitle=t.drawSubtitle),void 0!==t.drawLyricist&&(this.drawingParameters.DrawLyricist=t.drawLyricist),void 0!==t.drawMetronomeMarks&&(this.rules.MetronomeMarksDrawn=t.drawMetronomeMarks),void 0!==t.drawPartNames&&(this.drawingParameters.DrawPartNames=t.drawPartNames,t.drawPartAbbreviations||(this.rules.RenderPartAbbreviations=t.drawPartNames)),void 0!==t.drawPartAbbreviations&&(this.rules.RenderPartAbbreviations=t.drawPartAbbreviations),!1===t.drawFingerings&&(this.rules.RenderFingerings=!1),void 0!==t.drawMeasureNumbers&&(this.rules.RenderMeasureNumbers=t.drawMeasureNumbers),t.drawMeasureNumbersOnlyAtSystemStart&&(this.rules.RenderMeasureNumbersOnlyAtSystemStart=t.drawMeasureNumbersOnlyAtSystemStart),void 0!==t.drawLyrics&&(this.rules.RenderLyrics=t.drawLyrics),void 0!==t.drawTimeSignatures&&(this.rules.RenderTimeSignatures=t.drawTimeSignatures),void 0!==t.drawSlurs&&(this.rules.RenderSlurs=t.drawSlurs),void 0!==t.measureNumberInterval&&(this.rules.MeasureNumberLabelOffset=t.measureNumberInterval),void 0!==t.useXMLMeasureNumbers&&(this.rules.UseXMLMeasureNumbers=t.useXMLMeasureNumbers),void 0!==t.fingeringPosition&&(this.rules.FingeringPosition=y.AbstractExpression.PlacementEnumFromString(t.fingeringPosition)),void 0!==t.fingeringInsideStafflines&&(this.rules.FingeringInsideStafflines=t.fingeringInsideStafflines),void 0!==t.newSystemFromXML&&(this.rules.NewSystemAtXMLNewSystemAttribute=t.newSystemFromXML),void 0!==t.newSystemFromNewPageInXML&&(this.rules.NewSystemAtXMLNewPageAttribute=t.newSystemFromNewPageInXML),void 0!==t.newPageFromXML&&(this.rules.NewPageAtXMLNewPageAttribute=t.newPageFromXML),void 0!==t.fillEmptyMeasuresWithWholeRest&&(this.rules.FillEmptyMeasuresWithWholeRest=t.fillEmptyMeasuresWithWholeRest),void 0!==t.followCursor&&(this.FollowCursor=t.followCursor),void 0!==t.setWantedStemDirectionByXml&&(this.rules.SetWantedStemDirectionByXml=t.setWantedStemDirectionByXml),t.darkMode?(this.rules.applyDefaultColorMusic("#FFFFFF"),this.rules.PageBackgroundColor="#000000"):!1===t.darkMode&&(this.rules.applyDefaultColorMusic("#000000"),this.rules.PageBackgroundColor=void 0),t.defaultColorMusic&&this.rules.applyDefaultColorMusic(t.defaultColorMusic),t.defaultColorNotehead&&(this.rules.DefaultColorNotehead=t.defaultColorNotehead),t.defaultColorRest&&(this.rules.DefaultColorRest=t.defaultColorRest),t.defaultColorStem&&(this.rules.DefaultColorStem=t.defaultColorStem),t.defaultColorLabel&&(this.rules.DefaultColorLabel=t.defaultColorLabel),t.defaultColorTitle&&(this.rules.DefaultColorTitle=t.defaultColorTitle),t.defaultFontFamily&&(this.rules.DefaultFontFamily=t.defaultFontFamily),t.defaultFontStyle&&(this.rules.DefaultFontStyle=t.defaultFontStyle),t.drawUpToMeasureNumber&&(this.rules.MaxMeasureToDrawIndex=t.drawUpToMeasureNumber-1),t.drawFromMeasureNumber&&(this.rules.MinMeasureToDrawIndex=t.drawFromMeasureNumber-1),t.drawUpToPageNumber&&(this.rules.MaxPageToDrawNumber=t.drawUpToPageNumber),t.drawUpToSystemNumber&&(this.rules.MaxSystemToDrawNumber=t.drawUpToSystemNumber),t.tupletsRatioed&&(this.rules.TupletsRatioed=!0),t.tupletsBracketed&&(this.rules.TupletsBracketed=!0),t.tripletsBracketed&&(this.rules.TripletsBracketed=!0),t.autoResize?(this.resizeHandlerAttached||this.autoResize(),this.autoResizeEnabled=!0):!1===t.autoResize&&(this.autoResizeEnabled=!1),void 0!==t.pageFormat&&this.setPageFormat(t.pageFormat),void 0!==t.pageBackgroundColor&&(this.rules.PageBackgroundColor=t.pageBackgroundColor),void 0!==t.renderSingleHorizontalStaffline&&(this.rules.RenderSingleHorizontalStaffline=t.renderSingleHorizontalStaffline),void 0!==t.spacingFactorSoftmax&&(this.rules.SoftmaxFactorVexFlow=t.spacingFactorSoftmax),void 0!==t.spacingBetweenTextLines&&(this.rules.SpacingBetweenTextLines=t.spacingBetweenTextLines),void 0!==t.stretchLastSystemLine&&(this.rules.StretchLastSystemLine=t.stretchLastSystemLine),void 0!==t.autoGenerateMultipleRestMeasuresFromRestMeasures&&(this.rules.AutoGenerateMultipleRestMeasuresFromRestMeasures=t.autoGenerateMultipleRestMeasuresFromRestMeasures),void 0!==t.cursorsOptions?this.cursorsOptions=t.cursorsOptions:this.cursorsOptions=[{type:0,color:this.EngravingRules.DefaultColorCursor,alpha:.5,follow:!0}],void 0!==t.preferredSkyBottomLineBatchCalculatorBackend&&(this.rules.PreferredSkyBottomLineBatchCalculatorBackend=t.preferredSkyBottomLineBatchCalculatorBackend),void 0!==t.skyBottomLineBatchMinMeasures&&(this.rules.SkyBottomLineBatchMinMeasures=t.skyBottomLineBatchMinMeasures)}setColoringMode(t){if(t.coloringMode===b.ColoringModes.XML)return void(this.rules.ColoringMode=b.ColoringModes.XML);const e=[x.NoteEnum.C,x.NoteEnum.D,x.NoteEnum.E,x.NoteEnum.F,x.NoteEnum.G,x.NoteEnum.A,x.NoteEnum.B];let i;if(t.coloringMode===b.ColoringModes.CustomColorSet){if(!t.coloringSetCustom||8!==t.coloringSetCustom.length)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 e of t.coloringSetCustom)if(!/^\#[0-9a-fA-F]{6}$/.test(e))throw new Error("One of the color strings in options.coloringSetCustom was not a valid HTML Hex color:\n"+e);i=t.coloringSetCustom}else if(t.coloringMode===b.ColoringModes.AutoColoring){i=[];const t=Object.keys(v.AutoColorSet);for(let e=0;e{t.hide()})),this.sheet=void 0,this.graphic=void 0,this.zoom=1}autoResize(){const t=this;this.handleResize((()=>{}),(()=>{var e;(null===(e=this.graphic)||void 0===e?void 0:e.GetCalculator)instanceof r.VexFlowMusicSheetCalculator&&(this.graphic.GetCalculator.beamsNeedUpdate=!0),t.IsReadyToRender()&&t.render()}))}handleResize(t,e){let i,s;const n=this;function r(){n.AutoResizeEnabled&&(i=(new Date).getTime(),s||(t(),i=(new Date).getTime(),s=window.setTimeout(o,200)))}function o(){s=void 0,window.clearTimeout(s),(new Date).getTime()-i<200?s=window.setTimeout(o,200):e()}window.attachEvent?window.attachEvent("onresize",r):window.addEventListener("resize",r),this.resizeHandlerAttached=!0,window.setTimeout(t,0),window.setTimeout(e,1)}enableOrDisableCursors(t){var e,i,s,n;if(this.drawingParameters.drawCursors=t,t)for(let t=0;t{t.hide()}))}createBackend(t,e){let i;return i=void 0===t||t===g.BackendType.SVG?new c.SvgVexFlowBackend(this.rules):new u.CanvasVexFlowBackend(this.rules),i.graphicalMusicPage=e,i.initialize(this.container,this.zoom),i}static StringToPageFormat(t){let e=S.PageFormat.UndefinedPageFormat;if(t.match("^[0-9]+x[0-9]+$")){const i=t.split("x"),s=Number.parseInt(i[0],10),n=Number.parseInt(i[1],10);s>0&&s<32768&&n>0&&n<32768&&(e=new S.PageFormat(s,n,`customPageFormat${t}`))}return t=(t=(t=t.replace(" ","_")).replace("Landscape","L")).replace("Portrait","P"),_.PageFormatStandards.hasOwnProperty(t)?(e=_.PageFormatStandards[t],e):e}setPageFormat(t){const e=_.StringToPageFormat(t);this.needBackendUpdate=!e.Equals(this.rules.PageFormat),this.rules.PageFormat=e}setCustomPageFormat(t,e){if(t>0&&e>0){const i=new S.PageFormat(t,e);this.rules.PageFormat=i}}set DrawSkyLine(t){this.drawSkyLine=t,this.drawer&&(this.drawer.skyLineVisible=t)}get DrawSkyLine(){return this.drawer.skyLineVisible}set DrawBottomLine(t){this.drawBottomLine=t,this.drawer&&(this.drawer.bottomLineVisible=t)}get DrawBottomLine(){return this.drawer.bottomLineVisible}set DrawBoundingBox(t){this.setDrawBoundingBox(t,!0)}get DrawBoundingBox(){return this.drawBoundingBox}setDrawBoundingBox(t,e=!1){this.drawBoundingBox=t,this.drawer&&(this.drawer.drawableBoundingBoxElement=t),e&&this.render()}get AutoResizeEnabled(){return this.autoResizeEnabled}set AutoResizeEnabled(t){this.autoResizeEnabled=t}get Zoom(){return this.zoom}set Zoom(t){var e;this.zoom=t,this.zoomUpdated=!0,(null===(e=this.graphic)||void 0===e?void 0:e.GetCalculator)instanceof r.VexFlowMusicSheetCalculator&&(this.graphic.GetCalculator.beamsNeedUpdate=this.zoomUpdated)}set FollowCursor(t){this.followCursor=t}get FollowCursor(){return this.followCursor}set TransposeCalculator(t){l.MusicSheetCalculator.transposeCalculator=t}get TransposeCalculator(){return l.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}}e.OpenSheetMusicDisplay=_,_.PageFormatStandards={A3_L:new S.PageFormat(420,297,"A3_L"),A3_P:new S.PageFormat(297,420,"A3_P"),A4_L:new S.PageFormat(297,210,"A4_L"),A4_P:new S.PageFormat(210,297,"A4_P"),A5_L:new S.PageFormat(210,148,"A5_L"),A5_P:new S.PageFormat(148,210,"A5_P"),A6_L:new S.PageFormat(148,105,"A6_L"),A6_P:new S.PageFormat(105,148,"A6_P"),Endless:S.PageFormat.UndefinedPageFormat,Letter_L:new S.PageFormat(279.4,215.9,"Letter_L"),Letter_P:new S.PageFormat(215.9,279.4,"Letter_P")}},2861:function(t,e,i){"use strict";var s=this&&this.__createBinding||(Object.create?function(t,e,i,s){void 0===s&&(s=i);var n=Object.getOwnPropertyDescriptor(e,i);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,s,n)}:function(t,e,i,s){void 0===s&&(s=i),t[s]=e[i]}),n=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||s(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(i(3495),e),n(i(530),e),n(i(41),e),n(i(9629),e)},8265:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TransposeCalculator=void 0;const s=i(8918);class n{transposePitch(t,e,i){let r=s.NoteEnum.C,o=0,a=s.AccidentalEnum.NONE;const l=s.Pitch.CalculateTransposedHalfTone(t,i);let h=l.halftone,c=l.overflow;for(let e=0;eh)break}for(let i=0;ih){let l=i;const u=s.Pitch.HalfTonesFromAccidental(t.Accidental);for((u>0||0===u&&e.Key>=0)&&l--;l<0;)l+=7,h+=12,c--;for(;l>=7;)l-=7,h-=12,c++;r=n.noteEnums[l],a=s.Pitch.AccidentalFromHalfTones(h-r),o=t.Octave+c;break}return new s.Pitch(r,o,a)}transposeKey(t,e){let i=0,s=0;for(;i=12;)r-=12;for(;r<0;)r+=12;t.Key=n.keyMapping[r],t.isTransposedBy=e}}e.TransposeCalculator=n,n.keyMapping=[0,-5,2,-3,4,-1,6,1,-4,3,-2,5],n.noteEnums=[s.NoteEnum.C,s.NoteEnum.D,s.NoteEnum.E,s.NoteEnum.F,s.NoteEnum.G,s.NoteEnum.A,s.NoteEnum.B]},5742:function(t,e,i){"use strict";var s=this&&this.__createBinding||(Object.create?function(t,e,i,s){void 0===s&&(s=i);var n=Object.getOwnPropertyDescriptor(e,i);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,s,n)}:function(t,e,i,s){void 0===s&&(s=i),t[s]=e[i]}),n=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||s(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(i(8265),e)},8447:function(t,e,i){"use strict";var s=this&&this.__createBinding||(Object.create?function(t,e,i,s){void 0===s&&(s=i);var n=Object.getOwnPropertyDescriptor(e,i);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,s,n)}:function(t,e,i,s){void 0===s&&(s=i),t[s]=e[i]}),n=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||s(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(i(5742),e)},2337:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.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(t){return-1!==this.indexOf(t)}}),e.CollectionUtil=class{static contains2(t,e){for(let i=0;i{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PSMath=void 0;class i{static log(t,e){return Math.log(e)/Math.log(t)}static log10(t){return i.log(10,t)}static meanSimple(t){let e=0;for(let i=0;i{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var s=i(9205),n=i(278),r=function(){function t(t){this.root=null,this.compare=t||s.defaultCompare,this.nElements=0}return t.prototype.add=function(t){return!s.isUndefined(t)&&null!==this.insertNode(this.createNode(t))&&(this.nElements++,!0)},t.prototype.clear=function(){this.root=null,this.nElements=0},t.prototype.isEmpty=function(){return 0===this.nElements},t.prototype.size=function(){return this.nElements},t.prototype.contains=function(t){return!s.isUndefined(t)&&null!==this.searchNode(this.root,t)},t.prototype.search=function(t){var e=this.searchNode(this.root,t);if(null!==e)return e.element},t.prototype.remove=function(t){var e=this.searchNode(this.root,t);return null!==e&&(this.removeNode(e),this.nElements--,!0)},t.prototype.inorderTraversal=function(t){this.inorderTraversalAux(this.root,t,{stop:!1})},t.prototype.preorderTraversal=function(t){this.preorderTraversalAux(this.root,t,{stop:!1})},t.prototype.postorderTraversal=function(t){this.postorderTraversalAux(this.root,t,{stop:!1})},t.prototype.levelTraversal=function(t){this.levelTraversalAux(this.root,t)},t.prototype.minimum=function(){if(!this.isEmpty()&&null!==this.root)return this.minimumAux(this.root).element},t.prototype.maximum=function(){if(!this.isEmpty()&&null!==this.root)return this.maximumAux(this.root).element},t.prototype.forEach=function(t){this.inorderTraversal(t)},t.prototype.toArray=function(){var t=[];return this.inorderTraversal((function(e){return t.push(e),!0})),t},t.prototype.height=function(){return this.heightAux(this.root)},t.prototype.searchNode=function(t,e){for(var i=1;null!==t&&0!==i;)(i=this.compare(e,t.element))<0?t=t.leftCh:i>0&&(t=t.rightCh);return t},t.prototype.transplant=function(t,e){null===t.parent?this.root=e:t===t.parent.leftCh?t.parent.leftCh=e:t.parent.rightCh=e,null!==e&&(e.parent=t.parent)},t.prototype.removeNode=function(t){if(null===t.leftCh)this.transplant(t,t.rightCh);else if(null===t.rightCh)this.transplant(t,t.leftCh);else{var e=this.minimumAux(t.rightCh);e.parent!==t&&(this.transplant(e,e.rightCh),e.rightCh=t.rightCh,e.rightCh.parent=e),this.transplant(t,e),e.leftCh=t.leftCh,e.leftCh.parent=e}},t.prototype.inorderTraversalAux=function(t,e,i){null===t||i.stop||(this.inorderTraversalAux(t.leftCh,e,i),i.stop||(i.stop=!1===e(t.element),i.stop||this.inorderTraversalAux(t.rightCh,e,i)))},t.prototype.levelTraversalAux=function(t,e){var i=new n.default;for(null!==t&&i.enqueue(t),t=i.dequeue()||null;null!=t;){if(!1===e(t.element))return;null!==t.leftCh&&i.enqueue(t.leftCh),null!==t.rightCh&&i.enqueue(t.rightCh),t=i.dequeue()||null}},t.prototype.preorderTraversalAux=function(t,e,i){null===t||i.stop||(i.stop=!1===e(t.element),i.stop||(this.preorderTraversalAux(t.leftCh,e,i),i.stop||this.preorderTraversalAux(t.rightCh,e,i)))},t.prototype.postorderTraversalAux=function(t,e,i){null===t||i.stop||(this.postorderTraversalAux(t.leftCh,e,i),i.stop||(this.postorderTraversalAux(t.rightCh,e,i),i.stop||(i.stop=!1===e(t.element))))},t.prototype.minimumAux=function(t){for(;null!=t&&null!==t.leftCh;)t=t.leftCh;return t},t.prototype.maximumAux=function(t){for(;null!=t&&null!==t.rightCh;)t=t.rightCh;return t},t.prototype.heightAux=function(t){return null===t?-1:Math.max(this.heightAux(t.leftCh),this.heightAux(t.rightCh))+1},t.prototype.insertNode=function(t){for(var e=null,i=this.root;null!==i;){var s=this.compare(t.element,i.element);if(0===s)return null;s<0?(e=i,i=i.leftCh):(e=i,i=i.rightCh)}return t.parent=e,null===e?this.root=t:this.compare(t.element,e.element)<0?e.leftCh=t:e.rightCh=t,t},t.prototype.createNode=function(t){return{element:t,leftCh:null,rightCh:null,parent:null}},t}();e.default=r},2070:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var s=i(9205),n=i(8805),r=i(7818),o=function(){function t(t){this.toStrF=t||s.defaultToString,this.dictionary=new n.default(this.toStrF),this.nElements=0}return t.prototype.add=function(t,e){if(void 0===e&&(e=1),s.isUndefined(t)||e<=0)return!1;if(this.contains(t))this.dictionary.getValue(t).copies+=e;else{var i={value:t,copies:e};this.dictionary.setValue(t,i)}return this.nElements+=e,!0},t.prototype.count=function(t){return this.contains(t)?this.dictionary.getValue(t).copies:0},t.prototype.contains=function(t){return this.dictionary.containsKey(t)},t.prototype.remove=function(t,e){if(void 0===e&&(e=1),s.isUndefined(t)||e<=0)return!1;if(this.contains(t)){var i=this.dictionary.getValue(t);return e>i.copies?this.nElements-=i.copies:this.nElements-=e,i.copies-=e,i.copies<=0&&this.dictionary.remove(t),!0}return!1},t.prototype.toArray=function(){for(var t=[],e=0,i=this.dictionary.values();e{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var s=i(9205),n=function(){function t(t){this.table={},this.nElements=0,this.toStr=t||s.defaultToString}return t.prototype.getValue=function(t){var e=this.table["$"+this.toStr(t)];if(!s.isUndefined(e))return e.value},t.prototype.setValue=function(t,e){if(!s.isUndefined(t)&&!s.isUndefined(e)){var i,n="$"+this.toStr(t),r=this.table[n];return s.isUndefined(r)?(this.nElements++,i=void 0):i=r.value,this.table[n]={key:t,value:e},i}},t.prototype.remove=function(t){var e="$"+this.toStr(t),i=this.table[e];if(!s.isUndefined(i))return delete this.table[e],this.nElements--,i.value},t.prototype.keys=function(){var t=[];for(var e in this.table)if(s.has(this.table,e)){var i=this.table[e];t.push(i.key)}return t},t.prototype.values=function(){var t=[];for(var e in this.table)if(s.has(this.table,e)){var i=this.table[e];t.push(i.value)}return t},t.prototype.forEach=function(t){for(var e in this.table)if(s.has(this.table,e)){var i=this.table[e];if(!1===t(i.key,i.value))return}},t.prototype.containsKey=function(t){return!s.isUndefined(this.getValue(t))},t.prototype.clear=function(){this.table={},this.nElements=0},t.prototype.size=function(){return this.nElements},t.prototype.isEmpty=function(){return this.nElements<=0},t.prototype.toString=function(){var t="{";return this.forEach((function(e,i){t+="\n\t"+e+" : "+i})),t+"\n}"},t}();e.default=n},2734:function(t,e,i){"use strict";var s,n=this&&this.__extends||(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])},function(t,e){function i(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var r=i(8805),o=i(9205),a=function(t){function e(e,i){var s=t.call(this,i)||this;return s.defaultFactoryFunction=e,s}return n(e,t),e.prototype.setDefault=function(e,i){var s=t.prototype.getValue.call(this,e);return o.isUndefined(s)?(this.setValue(e,i),i):s},e.prototype.getValue=function(t){return this.setDefault(t,this.defaultFactoryFunction())},e}(r.default);e.default=a},2422:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var s=i(9205),n=i(1229),r=function(){function t(t){this.data=[],this.compare=t||s.defaultCompare}return t.prototype.leftChildIndex=function(t){return 2*t+1},t.prototype.rightChildIndex=function(t){return 2*t+2},t.prototype.parentIndex=function(t){return Math.floor((t-1)/2)},t.prototype.minIndex=function(t,e){return e>=this.data.length?t>=this.data.length?-1:t:this.compare(this.data[t],this.data[e])<=0?t:e},t.prototype.siftUp=function(t){for(var e=this.parentIndex(t);t>0&&this.compare(this.data[e],this.data[t])>0;)n.swap(this.data,e,t),t=e,e=this.parentIndex(t)},t.prototype.siftDown=function(t){for(var e=this.minIndex(this.leftChildIndex(t),this.rightChildIndex(t));e>=0&&this.compare(this.data[t],this.data[e])>0;)n.swap(this.data,e,t),t=e,e=this.minIndex(this.leftChildIndex(t),this.rightChildIndex(t))},t.prototype.peek=function(){return this.data.length>0?this.data[0]:void 0},t.prototype.add=function(t){return!s.isUndefined(t)&&(this.data.push(t),this.siftUp(this.data.length-1),!0)},t.prototype.removeRoot=function(){if(this.data.length>0){var t=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),t}},t.prototype.contains=function(t){var e=s.compareToEquals(this.compare);return n.contains(this.data,t,e)},t.prototype.size=function(){return this.data.length},t.prototype.isEmpty=function(){return this.data.length<=0},t.prototype.clear=function(){this.data.length=0},t.prototype.forEach=function(t){n.forEach(this.data,t)},t}();e.default=r},3272:function(t,e,i){"use strict";var s,n=this&&this.__extends||(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])},function(t,e){function i(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var r=i(8805),o=i(9205),a=function(){function t(t,e){this.key=t,this.value=e}return t.prototype.unlink=function(){this.prev.next=this.next,this.next.prev=this.prev},t}(),l=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}(),h=function(t){function e(e){var i=t.call(this,e)||this;return i.head=new l,i.tail=new l,i.head.next=i.tail,i.tail.prev=i.head,i}return n(e,t),e.prototype.appendToTail=function(t){var e=this.tail.prev;e.next=t,t.prev=e,t.next=this.tail,this.tail.prev=t},e.prototype.getLinkedDictionaryPair=function(t){if(!o.isUndefined(t)){var e="$"+this.toStr(t);return this.table[e]}},e.prototype.getValue=function(t){var e=this.getLinkedDictionaryPair(t);if(!o.isUndefined(e))return e.value},e.prototype.remove=function(e){var i=this.getLinkedDictionaryPair(e);if(!o.isUndefined(i))return t.prototype.remove.call(this,e),i.unlink(),i.value},e.prototype.clear=function(){t.prototype.clear.call(this),this.head.next=this.tail,this.tail.prev=this.head},e.prototype.replace=function(t,e){var i="$"+this.toStr(e.key);e.next=t.next,e.prev=t.prev,this.remove(t.key),e.prev.next=e,e.next.prev=e,this.table[i]=e,++this.nElements},e.prototype.setValue=function(t,e){if(!o.isUndefined(t)&&!o.isUndefined(e)){var i=this.getLinkedDictionaryPair(t),s=new a(t,e),n="$"+this.toStr(t);return o.isUndefined(i)?(this.appendToTail(s),this.table[n]=s,void++this.nElements):(this.replace(i,s),i.value)}},e.prototype.keys=function(){var t=[];return this.forEach((function(e,i){t.push(e)})),t},e.prototype.values=function(){var t=[];return this.forEach((function(e,i){t.push(i)})),t},e.prototype.forEach=function(t){for(var e=this.head.next;e.next;){if(!1===t(e.key,e.value))return;e=e.next}},e}(r.default);e.default=h},5456:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var s=i(9205),n=i(1229),r=function(){function t(){this.firstNode=null,this.lastNode=null,this.nElements=0}return t.prototype.add=function(t,e){if(s.isUndefined(e)&&(e=this.nElements),e<0||e>this.nElements||s.isUndefined(t))return!1;var i=this.createNode(t);if(0===this.nElements||null===this.lastNode)this.firstNode=i,this.lastNode=i;else if(e===this.nElements)this.lastNode.next=i,this.lastNode=i;else if(0===e)i.next=this.firstNode,this.firstNode=i;else{var n=this.nodeAtIndex(e-1);if(null===n)return!1;i.next=n.next,n.next=i}return this.nElements++,!0},t.prototype.first=function(){if(null!==this.firstNode)return this.firstNode.element},t.prototype.last=function(){if(null!==this.lastNode)return this.lastNode.element},t.prototype.elementAtIndex=function(t){var e=this.nodeAtIndex(t);if(null!==e)return e.element},t.prototype.indexOf=function(t,e){var i=e||s.defaultEquals;if(s.isUndefined(t))return-1;for(var n=this.firstNode,r=0;null!==n;){if(i(n.element,t))return r;r++,n=n.next}return-1},t.prototype.contains=function(t,e){return this.indexOf(t,e)>=0},t.prototype.remove=function(t,e){var i=e||s.defaultEquals;if(this.nElements<1||s.isUndefined(t))return!1;for(var n=null,r=this.firstNode;null!==r;){if(i(r.element,t))return null===n?(this.firstNode=r.next,r===this.lastNode&&(this.lastNode=null)):r===this.lastNode?(this.lastNode=n,n.next=r.next,r.next=null):(n.next=r.next,r.next=null),this.nElements--,!0;n=r,r=r.next}return!1},t.prototype.clear=function(){this.firstNode=null,this.lastNode=null,this.nElements=0},t.prototype.equals=function(e,i){var n=i||s.defaultEquals;return e instanceof t&&this.size()===e.size()&&this.equalsAux(this.firstNode,e.firstNode,n)},t.prototype.equalsAux=function(t,e,i){for(;null!==t&&null!==e;){if(!i(t.element,e.element))return!1;t=t.next,e=e.next}return!0},t.prototype.removeElementAtIndex=function(t){if(!(t<0||t>=this.nElements||null===this.firstNode||null===this.lastNode)){var e;if(1===this.nElements)e=this.firstNode.element,this.firstNode=null,this.lastNode=null;else{var i=this.nodeAtIndex(t-1);null===i?(e=this.firstNode.element,this.firstNode=this.firstNode.next):i.next===this.lastNode&&(e=this.lastNode.element,this.lastNode=i),null!==i&&null!==i.next&&(e=i.next.element,i.next=i.next.next)}return this.nElements--,e}},t.prototype.forEach=function(t){for(var e=this.firstNode;null!==e&&!1!==t(e.element);)e=e.next},t.prototype.reverse=function(){for(var t=null,e=this.firstNode,i=null;null!==e;)i=e.next,e.next=t,t=e,e=i;i=this.firstNode,this.firstNode=this.lastNode,this.lastNode=i},t.prototype.toArray=function(){for(var t=[],e=this.firstNode;null!==e;)t.push(e.element),e=e.next;return t},t.prototype.size=function(){return this.nElements},t.prototype.isEmpty=function(){return this.nElements<=0},t.prototype.toString=function(){return n.toString(this.toArray())},t.prototype.nodeAtIndex=function(t){if(t<0||t>=this.nElements)return null;if(t===this.nElements-1)return this.lastNode;for(var e=this.firstNode,i=0;i{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var s=i(9205),n=i(8805),r=i(1229),o=function(){function t(t,e,i){void 0===i&&(i=!1),this.dict=new n.default(t),this.equalsF=e||s.defaultEquals,this.allowDuplicate=i}return t.prototype.getValue=function(t){var e=this.dict.getValue(t);return s.isUndefined(e)?[]:r.copy(e)},t.prototype.setValue=function(t,e){if(s.isUndefined(t)||s.isUndefined(e))return!1;var i=this.dict.getValue(t);return s.isUndefined(i)?(this.dict.setValue(t,[e]),!0):!(!this.allowDuplicate&&r.contains(i,e,this.equalsF)||(i.push(e),0))},t.prototype.remove=function(t,e){if(s.isUndefined(e)){var i=this.dict.remove(t);return!s.isUndefined(i)}var n=this.dict.getValue(t);return!(s.isUndefined(n)||!r.remove(n,e,this.equalsF)||(0===n.length&&this.dict.remove(t),0))},t.prototype.keys=function(){return this.dict.keys()},t.prototype.values=function(){for(var t=[],e=0,i=this.dict.values();e{"use strict";var i;Object.defineProperty(e,"__esModule",{value:!0}),function(t){t[t.BEFORE=0]="BEFORE",t[t.AFTER=1]="AFTER",t[t.INSIDE_AT_END=2]="INSIDE_AT_END",t[t.INSIDE_AT_START=3]="INSIDE_AT_START"}(i||(i={}));var s=function(){function t(t,e){void 0===t&&(t=[]),void 0===e&&(e={}),this.rootIds=t,this.nodes=e,this.initRootIds(),this.initNodes()}return t.prototype.initRootIds=function(){for(var t=0,e=this.rootIds;t-1&&this.insertIdIntoRoot(e,i),this.nodes)if(this.nodes.hasOwnProperty(s)){var n=this.findNodeId(s,t);n>-1&&this.insertIdIntoNode(s,e,n)}},t.prototype.insertIdAfterId=function(t,e){var i=this.findRootId(t);for(var s in i>-1&&this.insertIdIntoRoot(e,i+1),this.nodes)if(this.nodes.hasOwnProperty(s)){var n=this.findNodeId(s,t);n>-1&&this.insertIdIntoNode(s,e,n+1)}},t.prototype.insertIdIntoId=function(t,e){this.nodeInsertAtEnd(t,e),this.nodes[e]=[]},t.prototype.insertIdIntoRoot=function(t,e){if(void 0===e)this.rootInsertAtEnd(t);else if(e<0){var i=this.rootIds.length;this.rootIds.splice(e+i+1,0,t)}else this.rootIds.splice(e,0,t);this.nodes[t]=this.nodes[t]||[]},t.prototype.insertIdIntoNode=function(t,e,i){if(this.nodes[t]=this.nodes[t]||[],this.nodes[e]=this.nodes[e]||[],void 0===i)this.nodeInsertAtEnd(t,e);else if(i<0){var s=this.nodes[t].length;this.nodes[t].splice(i+s+1,0,e)}else this.nodes[t].splice(i,0,e)},t.prototype.moveId=function(t,e,s){var n=t,r=this.findRootId(n);for(var o in this.nodes[e],this.nodes)if(this.nodes.hasOwnProperty(o)){this.findNodeId(o,e);break}var a=e,l=this.findRootId(a);for(var o in this.nodes[e],this.nodes)if(this.nodes.hasOwnProperty(o)){this.findNodeId(o,e);break}if(r>-1){if(l>-1)switch(this.rootDelete(r),l>r&&l--,s){case i.BEFORE:this.insertIdIntoRoot(n,l);break;case i.AFTER:this.insertIdIntoRoot(n,l+1);break;case i.INSIDE_AT_START:this.nodeInsertAtStart(a,n);break;case i.INSIDE_AT_END:this.nodeInsertAtEnd(a,n)}else for(var o in this.rootDelete(r),this.nodes)if(this.nodes.hasOwnProperty(o)&&(h=this.findNodeId(o,a))>-1){switch(s){case i.BEFORE:this.insertIdIntoNode(o,n,h);break;case i.AFTER:this.insertIdIntoNode(o,n,h+1);break;case i.INSIDE_AT_START:this.nodeInsertAtStart(a,n);break;case i.INSIDE_AT_END:this.nodeInsertAtEnd(a,n)}break}}else if(l>-1){for(var o in this.nodes)if(this.nodes.hasOwnProperty(o)&&(h=this.findNodeId(o,n))>-1){this.nodeDeleteAtIndex(o,h);break}switch(s){case i.BEFORE:this.insertIdIntoRoot(n,l);break;case i.AFTER:this.insertIdIntoRoot(n,l+1);break;case i.INSIDE_AT_START:this.nodeInsertAtStart(a,n);break;case i.INSIDE_AT_END:this.nodeInsertAtEnd(a,n)}}else{for(var o in this.nodes)if(this.nodes.hasOwnProperty(o)&&(h=this.findNodeId(o,n))>-1){this.nodeDeleteAtIndex(o,h);break}for(var o in this.nodes){var h;if(this.nodes.hasOwnProperty(o)&&(h=this.findNodeId(o,a))>-1){switch(s){case i.BEFORE:this.insertIdIntoNode(o,n,h);break;case i.AFTER:this.insertIdIntoNode(o,n,h+1);break;case i.INSIDE_AT_START:this.nodeInsertAtStart(a,n);break;case i.INSIDE_AT_END:this.nodeInsertAtEnd(a,n)}break}}}},t.prototype.swapArrayElements=function(t,e,i){var s=t[e];return t[e]=t[i],t[i]=s,t},t.prototype.rootDeleteId=function(t){var e=this.findRootId(t);e>-1&&this.rootDelete(e)},t.prototype.nodeAndSubNodesDelete=function(t){for(var e=[],i=0;i{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var s=i(9205),n=i(2422),r=function(){function t(t){this.heap=new n.default(s.reverseCompareFunction(t))}return t.prototype.enqueue=function(t){return this.heap.add(t)},t.prototype.add=function(t){return this.heap.add(t)},t.prototype.dequeue=function(){if(0!==this.heap.size()){var t=this.heap.peek();return this.heap.removeRoot(),t}},t.prototype.peek=function(){return this.heap.peek()},t.prototype.contains=function(t){return this.heap.contains(t)},t.prototype.isEmpty=function(){return this.heap.isEmpty()},t.prototype.size=function(){return this.heap.size()},t.prototype.clear=function(){this.heap.clear()},t.prototype.forEach=function(t){this.heap.forEach(t)},t}();e.default=r},278:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var s=i(5456),n=function(){function t(){this.list=new s.default}return t.prototype.enqueue=function(t){return this.list.add(t)},t.prototype.add=function(t){return this.list.add(t)},t.prototype.dequeue=function(){if(0!==this.list.size()){var t=this.list.first();return this.list.removeElementAtIndex(0),t}},t.prototype.peek=function(){if(0!==this.list.size())return this.list.first()},t.prototype.size=function(){return this.list.size()},t.prototype.contains=function(t,e){return this.list.contains(t,e)},t.prototype.isEmpty=function(){return this.list.size()<=0},t.prototype.clear=function(){this.list.clear()},t.prototype.forEach=function(t){this.list.forEach(t)},t}();e.default=n},7818:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var s=i(9205),n=i(1229),r=i(8805),o=function(){function t(t){this.dictionary=new r.default(t)}return t.prototype.contains=function(t){return this.dictionary.containsKey(t)},t.prototype.add=function(t){return!this.contains(t)&&!s.isUndefined(t)&&(this.dictionary.setValue(t,t),!0)},t.prototype.intersection=function(t){var e=this;this.forEach((function(i){return t.contains(i)||e.remove(i),!0}))},t.prototype.union=function(t){var e=this;t.forEach((function(t){return e.add(t),!0}))},t.prototype.difference=function(t){var e=this;t.forEach((function(t){return e.remove(t),!0}))},t.prototype.isSubsetOf=function(t){if(this.size()>t.size())return!1;var e=!0;return this.forEach((function(i){return!!t.contains(i)||(e=!1,!1)})),e},t.prototype.remove=function(t){return!!this.contains(t)&&(this.dictionary.remove(t),!0)},t.prototype.forEach=function(t){this.dictionary.forEach((function(e,i){return t(i)}))},t.prototype.toArray=function(){return this.dictionary.values()},t.prototype.isEmpty=function(){return this.dictionary.isEmpty()},t.prototype.size=function(){return this.dictionary.size()},t.prototype.clear=function(){this.dictionary.clear()},t.prototype.toString=function(){return n.toString(this.toArray())},t}();e.default=o},5669:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var s=i(5456),n=function(){function t(){this.list=new s.default}return t.prototype.push=function(t){return this.list.add(t,0)},t.prototype.add=function(t){return this.list.add(t,0)},t.prototype.pop=function(){return this.list.removeElementAtIndex(0)},t.prototype.peek=function(){return this.list.first()},t.prototype.size=function(){return this.list.size()},t.prototype.contains=function(t,e){return this.list.contains(t,e)},t.prototype.isEmpty=function(){return this.list.isEmpty()},t.prototype.clear=function(){this.list.clear()},t.prototype.forEach=function(t){this.list.forEach(t)},t}();e.default=n},1229:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var s=i(9205);function n(t,e,i){for(var n=i||s.defaultEquals,r=t.length,o=0;o=0;r--)if(n(t[r],e))return r;return-1},e.contains=function(t,e,i){return n(t,e,i)>=0},e.remove=function(t,e,i){var s=n(t,e,i);return!(s<0||(t.splice(s,1),0))},e.frequency=function(t,e,i){for(var n=i||s.defaultEquals,r=t.length,o=0,a=0;a=t.length||i<0||i>=t.length)return!1;var s=t[e];return t[e]=t[i],t[i]=s,!0},e.toString=function(t){return"["+t.toString()+"]"},e.forEach=function(t,e){for(var i=0,s=t;i{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var s=i(1229);e.arrays=s;var n=i(2070);e.Bag=n.default;var r=i(8071);e.BSTree=r.default;var o=i(3176);e.BSTreeKV=o.default;var a=i(8805);e.Dictionary=a.default;var l=i(2422);e.Heap=l.default;var h=i(3272);e.LinkedDictionary=h.default;var c=i(5456);e.LinkedList=c.default;var u=i(6072);e.MultiDictionary=u.default;var d=i(2734);e.FactoryDictionary=d.default;var f=i(2734);e.DefaultDictionary=f.default;var m=i(278);e.Queue=m.default;var p=i(5994);e.PriorityQueue=p.default;var b=i(7818);e.Set=b.default;var g=i(5669);e.Stack=g.default;var S=i(1489);e.MultiRootTree=S.default;var y=i(9205);e.util=y},9205:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=Object.prototype.hasOwnProperty;function s(t){return"function"==typeof t}function n(t){return void 0===t}function r(t){return"[object String]"===Object.prototype.toString.call(t)}e.has=function(t,e){return i.call(t,e)},e.defaultCompare=function(t,e){return t{"use strict";i.r(e),i.d(e,{default:()=>ue});const s=()=>{};s.L=(t,e)=>{if(!e)return;const i=Array.prototype.slice.call(e).join(" ");window.console.log(t+": "+i)},s.MakeException=t=>class extends Error{constructor(e,i){super(e),this.name=t,this.message=e,this.data=i}},s.RERR=s.RuntimeError=class{constructor(t,e){this.code=t,this.message=e}toString(){return"[RuntimeError] "+this.code+":"+this.message}},s.Merge=(t,e)=>{for(const i in e)t[i]=e[i];return t},s.Min=Math.min,s.Max=Math.max,s.forEach=(t,e)=>{for(let i=0;it%e>=e/2?parseInt(t/e,10)*e+e:parseInt(t/e,10)*e,s.MidLine=(t,e)=>{let i=e+(t-e)/2;return i%2>0&&(i=s.RoundN(10*i,5)/10),i},s.SortAndUnique=(t,e,i)=>{if(t.length>1){const s=[];let n;t.sort(e);for(let e=0;e{let i=t.length;for(;i--;)if(t[i]===e)return!0;return!1},s.getCanvasContext=t=>{if(!t)throw new s.RERR("BadArgument","Invalid canvas selector: "+t);const e=document.getElementById(t);if(!e||!e.getContext)throw new s.RERR("UnsupportedBrowserError","This browser does not support HTML5 Canvas");return e.getContext("2d")},s.drawDot=(t,e,i,s="#55")=>{t.save(),t.setFillStyle(s),t.beginPath(),t.arc(e,i,3,0,2*Math.PI,!0),t.closePath(),t.fill(),t.restore()},s.BM=(t,e)=>{const i=(new Date).getTime();e();const n=(new Date).getTime()-i;s.L(t+n+"ms")},s.StackTrace=()=>(new Error).stack,s.W=(...t)=>{const e=t.join(" ");window.console.log("Warning: ",e,s.StackTrace())},(s.Prefix=t=>s.Prefix.prefix+t).prefix="vf-";class n{static GCD(t,e){if("number"!=typeof t||"number"!=typeof e)throw new s.RERR("BadArgument",`Invalid numbers: ${t}, ${e}`);let i;for(;0!==e;)i=e,e=t%e,t=i;return t}static LCM(t,e){return t*e/n.GCD(t,e)}static LCMM(t){if(0===t.length)return 0;if(1===t.length)return t[0];if(2===t.length)return n.LCM(t[0],t[1]);{const e=t[0];return t.shift(),n.LCM(e,n.LCMM(t))}}constructor(t,e){this.set(t,e)}set(t,e){return this.numerator=void 0===t?1:t,this.denominator=void 0===e?1:e,this}value(){return this.numerator/this.denominator}simplify(){let t=this.numerator,e=this.denominator;const i=n.GCD(t,e);return t/=i,e/=i,e<0&&(e=-e,t=-t),this.set(t,e)}add(t,e){let i,s;t instanceof n?(i=t.numerator,s=t.denominator):(i=void 0!==t?t:0,s=void 0!==e?e:1);const r=n.LCM(this.denominator,s),o=r/this.denominator,a=r/s,l=this.numerator*o+i*a;return this.set(l,r)}subtract(t,e){let i,s;t instanceof n?(i=t.numerator,s=t.denominator):(i=void 0!==t?t:0,s=void 0!==e?e:1);const r=n.LCM(this.denominator,s),o=r/this.denominator,a=r/s,l=this.numerator*o-i*a;return this.set(l,r)}multiply(t,e){let i,s;return t instanceof n?(i=t.numerator,s=t.denominator):(i=void 0!==t?t:1,s=void 0!==e?e:1),this.set(this.numerator*i,this.denominator*s)}divide(t,e){let i,s;return t instanceof n?(i=t.numerator,s=t.denominator):(i=void 0!==t?t:1,s=void 0!==e?e:1),this.set(this.numerator*s,this.denominator*i)}equals(t){const e=n.__compareA.copy(t).simplify(),i=n.__compareB.copy(this).simplify();return e.numerator===i.numerator&&e.denominator===i.denominator}greaterThan(t){const e=n.__compareB.copy(this);return e.subtract(t),e.numerator>0}greaterThanEquals(t){const e=n.__compareB.copy(this);return e.subtract(t),e.numerator>=0}lessThan(t){return!this.greaterThanEquals(t)}lessThanEquals(t){return!this.greaterThan(t)}clone(){return new n(this.numerator,this.denominator)}copy(t){return"number"==typeof t?this.set(t||0,1):this.set(t.numerator,t.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 n.__tmp.copy(this).simplify().toString()}toMixedString(){let t="";const e=this.quotient(),i=n.__tmp.copy(this);return e<0?i.abs().fraction():i.fraction(),0!==e?(t+=e,0!==i.numerator&&(t+=" "+i.toSimplifiedString())):t=0===i.numerator?"0":i.toSimplifiedString(),t}parse(t){const e=t.split("/"),i=parseInt(e[0],10),s=e[1]?parseInt(e[1],10):1;return this.set(i,s)}}n.__compareA=new n,n.__compareB=new n,n.__tmp=new n;const r=s.MakeException("RegistryError");function o(t,e,i,s,n){t[e][i]||(t[e][i]={}),t[e][i][s]=n}class a{static get INDEXES(){return["type"]}constructor(){this.clear()}static enableDefaultRegistry(t){a.defaultRegistry=t}static getDefaultRegistry(){return a.defaultRegistry}static disableDefaultRegistry(){a.defaultRegistry=null}clear(){return this.index={id:{},type:{},class:{}},this}updateIndex({id:t,name:e,value:i,oldValue:s}){const n=this.getElementById(t);null!==s&&this.index[e][s]&&delete this.index[e][s][t],null!==i&&o(this.index,e,i,n.getAttribute("id"),n)}register(t,e){if(!(e=e||t.getAttribute("id")))throw new r("Can't add element without `id` attribute to registry",t);return t.setAttribute("id",e),o(this.index,"id",e,e,t),a.INDEXES.forEach((i=>{this.updateIndex({id:e,name:i,value:t.getAttribute(i),oldValue:null})})),t.onRegister(this),this}getElementById(t){return this.index.id[t]?this.index.id[t][t]:null}getElementsByAttribute(t,e){const i=this.index[t];return i&&i[e]?Object.keys(i[e]).map((t=>i[e][t])):[]}getElementsByType(t){return this.getElementsByAttribute("type",t)}getElementsByClass(t){return this.getElementsByAttribute("class",t)}onUpdate({id:t,name:e,value:i,oldValue:s}){return function(t,e){return t.filter((t=>t===e)).length>0}(a.INDEXES.concat(["id","class"]),e)?(this.updateIndex({id:t,name:e,value:i,oldValue:s}),this):this}}a.defaultRegistry=null;class l{static newID(){return"auto"+l.ID++}constructor({type:t}={}){this.attrs={id:l.newID(),el:null,type:t||"Base",classes:{}},this.boundingBox=null,this.context=null,this.rendered=!1,a.getDefaultRegistry()&&a.getDefaultRegistry().register(this)}setStyle(t){return this.style=t,this}getStyle(){return this.style}applyStyle(t=this.context,e=this.getStyle()){return e?(t.save(),e.shadowColor&&t.setShadowColor(e.shadowColor),e.shadowBlur&&t.setShadowBlur(e.shadowBlur),e.fillStyle&&t.setFillStyle(e.fillStyle),e.strokeStyle&&t.setStrokeStyle(e.strokeStyle),e.lineWidth&&t.setLineWidth(e.lineWidth),this):this}restoreStyle(t=this.context,e=this.getStyle()){return e?(t.restore(),this):this}drawWithStyle(){this.checkContext(),this.applyStyle(),this.draw(),this.restoreStyle()}hasClass(t){return!0===this.attrs.classes[t]}addClass(t){return this.attrs.classes[t]=!0,this.registry&&this.registry.onUpdate({id:this.getAttribute("id"),name:"class",value:t,oldValue:null}),this}removeClass(t){return delete this.attrs.classes[t],this.registry&&this.registry.onUpdate({id:this.getAttribute("id"),name:"class",value:null,oldValue:t}),this}onRegister(t){return this.registry=t,this}isRendered(){return this.rendered}setRendered(t=!0){return this.rendered=t,this}getAttributes(){return this.attrs}getAttribute(t){return this.attrs[t]}setAttribute(t,e){const i=this.attrs.id,s=this.attrs[t];return this.attrs[t]=e,this.registry&&this.registry.onUpdate({id:i,name:t,value:e,oldValue:s}),this}getContext(){return this.context}setContext(t){return this.context=t,this}getBoundingBox(){return this.boundingBox}checkContext(){if(!this.context)throw new s.RERR("NoContext","No rendering context attached to instance");return this.context}}l.ID=1e3;class h{constructor(t,e,i,s){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN,this.addPoint(t,e),this.addPoint(i,s)}width(){return this.x2-this.x1}height(){return this.y2-this.y1}addPoint(t,e){null!=t&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=t,this.x2=t),tthis.x2&&(this.x2=t)),null!=e&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),ethis.y2&&(this.y2=e))}addX(t){this.addPoint(t,null)}addY(t){this.addPoint(null,t)}addQuadraticCurve(t,e,i,s,n,r){const o=t+2/3*(i-t),a=e+2/3*(s-e),l=o+1/3*(n-t),h=a+1/3*(r-e);this.addBezierCurve(t,e,o,a,l,h,n,r)}addBezierCurve(t,e,i,s,n,r,o,a){const l=[t,e],h=[i,s],c=[n,r],u=[o,a];let d;this.addPoint(l[0],l[1]),this.addPoint(u[0],u[1]);const f=(t,e)=>Math.pow(1-t,3)*l[e]+3*Math.pow(1-t,2)*t*h[e]+3*(1-t)*Math.pow(t,2)*c[e]+Math.pow(t,3)*u[e];for(d=0;d<=1;d++){const t=6*l[d]-12*h[d]+6*c[d],e=-3*l[d]+9*h[d]-9*c[d]+3*u[d],i=3*h[d]-3*l[d];if(0===e){if(0===t)continue;const e=-i/t;0{if(!t)throw new s.RERR("BadArgument","Invalid clef: "+t);const e=m.clefProperties.values[t];if(!e)throw new s.RERR("BadArgument","Invalid clef: "+t);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=(t,e,i)=>{void 0===e&&(e="treble");const n={octave_shift:0};"object"==typeof i&&s.Merge(n,i);const r=t.split("/");if(r.length<2)throw new s.RERR("BadArguments",`Key must have note + octave and an optional glyph: ${t}`);const o=r[0].toUpperCase(),a=m.keyProperties.note_values[o];if(!a)throw new s.RERR("BadArguments","Invalid key name: "+o);a.octave&&(r[1]=a.octave);let l=parseInt(r[1],10);l+=-1*n.octave_shift;let h=(7*l-28+a.index)/2;h+=m.clefProperties(e).line_shift;let c=0;h<=0&&2*h%2==0&&(c=1),h>=6&&2*h%2==0&&(c=-1);const u=void 0!==a.int_val?12*l+a.int_val:null,d=a.code,f=a.shift_right;let p={};if(r.length>2&&r[2]){const t=r[2].toUpperCase();p=m.keyProperties.customNoteHeads[t]||{}}return{key:o,octave:l,line:h,int_value:u,accidental:a.accidental,code:d,stroke:c,shift_right:f,displaced:!1,...p}},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},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}},m.integerToNote=t=>{if(void 0===t)throw new s.RERR("BadArguments","Undefined integer for integerToNote");if(t<-2)throw new s.RERR("BadArguments",`integerToNote requires integer > -2: ${t}`);const e=m.integerToNote.table[t];if(!e)throw new s.RERR("BadArguments",`Unknown note value for integer: ${t}`);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=(t,e=1)=>{let i=null,s=0,n=0;if("X"===t.toString().toUpperCase()){const t=new f("v7f",m.DEFAULT_TABLATURE_FONT_SCALE).getMetrics();i="v7f",s=t.width,n=-t.height/2}else s=m.textWidth(t.toString());return{text:t,code:i,getWidth:()=>s*e,shift_y:n}},m.textWidth=t=>7*t.toString().length,m.articulationCodes=t=>m.articulationCodes.articulations[t],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=t=>m.accidentalCodes.accidentals[t],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=t=>m.ornamentCodes.ornaments[t],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=t=>{const e=m.keySignature.keySpecs[t];if(!e)throw new s.RERR("BadKeySignature",`Bad key signature spec: '${t}'`);if(!e.acc)return[];const i=m.keySignature.accidentalList(e.acc),n=[];for(let t=0;t({b:[2,.5,2.5,1,3,1.5,3.5],"#":[0,1.5,-.5,1,2.5,.5,2]}[t]),m.parseNoteDurationString=t=>{if("string"!=typeof t)return null;const e=/(\d*\/?\d+|[a-z])(d*)([nrhms]|$)/.exec(t);if(!e)return null;const i=e[1],s=e[2].length;let n=e[3];return 0===n.length&&(n="n"),{duration:i,dots:s,type:n}},m.parseNoteStruct=t=>{const e=t.duration,i=m.parseNoteDurationString(e);if(!i)return null;let s=m.durationToTicks(i.duration);if(null==s)return null;let n=t.type;const r=[];if(n){if(!m.getGlyphProps.validTypes[n])return null}else n=i.type||"n",void 0!==t.keys&&t.keys.forEach(((t,e)=>{const i=t.split("/");i&&3===i.length&&(r[e]=i[2])}));const o=t.dots?t.dots:i.dots;if("number"!=typeof o)return null;let a=s;for(let t=0;t{const e=m.durationAliases[t];if(void 0!==e&&(t=e),void 0===m.durationToTicks.durations[t])throw new s.RERR("BadArguments",`The provided duration is not valid: ${t}`);return t},m.durationToFraction=t=>(new n).parse(m.sanitizeDuration(t)),m.durationToNumber=t=>m.durationToFraction(t).value(),m.durationToTicks=t=>{t=m.sanitizeDuration(t);const e=m.durationToTicks.durations[t];return void 0===e?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=(t,e)=>{t=m.sanitizeDuration(t);const i=m.getGlyphProps.duration_codes[t];if(void 0===i)return null;e||(e="n");let s=i.type[e];if(void 0===s){const t=m.keyProperties.customNoteHeads[e.toUpperCase()];if(void 0===t)return null;s={code_head:t.code,...t}}return{...i.common,...s}},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(t=m.DEFAULT_NOTATION_FONT_SCALE){return new f(this.code_head||"v53",t).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(t=m.DEFAULT_NOTATION_FONT_SCALE){return new f(this.code_head||"v1d",t).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(t=m.DEFAULT_NOTATION_FONT_SCALE){return new f(this.code_head||"v81",t).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(t=m.DEFAULT_NOTATION_FONT_SCALE){return new f(this.code_head||"vb",t).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(t=m.DEFAULT_NOTATION_FONT_SCALE){return new f(this.code_head||"vb",t).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(t=m.DEFAULT_NOTATION_FONT_SCALE){return new f(this.code_head||"vb",t).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(t=m.DEFAULT_NOTATION_FONT_SCALE){return new f(this.code_head||"vb",t).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(t=m.DEFAULT_NOTATION_FONT_SCALE){return new f(this.code_head||"vb",t).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(t=m.DEFAULT_NOTATION_FONT_SCALE){return new f(this.code_head||"vb",t).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 p{static get WIDTH(){return 600}static get HEIGHT(){return 400}static get CANVAS_BROWSER_SIZE_LIMIT(){return 32767}static SanitizeCanvasDims(t,e){return Math.max(t,e)>this.CANVAS_BROWSER_SIZE_LIMIT&&(s.W("Canvas dimensions exceed browser limit. Cropping to "+this.CANVAS_BROWSER_SIZE_LIMIT),t>this.CANVAS_BROWSER_SIZE_LIMIT&&(t=this.CANVAS_BROWSER_SIZE_LIMIT),e>this.CANVAS_BROWSER_SIZE_LIMIT&&(e=this.CANVAS_BROWSER_SIZE_LIMIT)),[t,e]}constructor(t){this.vexFlowCanvasContext=t,t.canvas?this.canvas=t.canvas:this.canvas={width:p.WIDTH,height:p.HEIGHT}}clear(){this.vexFlowCanvasContext.clearRect(0,0,this.canvas.width,this.canvas.height)}openGroup(){}closeGroup(){}add(){}setFont(t,e,i){return this.vexFlowCanvasContext.font=(i||"")+" "+e+"pt "+t,this}setRawFont(t){return this.vexFlowCanvasContext.font=t,this}setFillStyle(t){return this.vexFlowCanvasContext.fillStyle=t,this}setBackgroundFillStyle(t){return this.background_fillStyle=t,this}setStrokeStyle(t){return this.vexFlowCanvasContext.strokeStyle=t,this}setShadowColor(t){return this.vexFlowCanvasContext.shadowColor=t,this}setShadowBlur(t){return this.vexFlowCanvasContext.shadowBlur=t,this}setLineWidth(t){return this.vexFlowCanvasContext.lineWidth=t,this}setLineCap(t){return this.vexFlowCanvasContext.lineCap=t,this}setLineDash(t){return this.vexFlowCanvasContext.lineDash=t,this}scale(t,e){return this.vexFlowCanvasContext.scale(parseFloat(t),parseFloat(e))}resize(t,e){return[t,e]=this.SanitizeCanvasDims(parseInt(t,10),parseInt(e,10)),this.vexFlowCanvasContext.resize(t,e)}rect(t,e,i,s){return this.vexFlowCanvasContext.rect(t,e,i,s)}fillRect(t,e,i,s){return this.vexFlowCanvasContext.fillRect(t,e,i,s)}clearRect(t,e,i,s){return this.vexFlowCanvasContext.clearRect(t,e,i,s)}beginPath(){return this.vexFlowCanvasContext.beginPath()}moveTo(t,e){return this.vexFlowCanvasContext.moveTo(t,e)}lineTo(t,e){return this.vexFlowCanvasContext.lineTo(t,e)}bezierCurveTo(t,e,i,s,n,r){return this.vexFlowCanvasContext.bezierCurveTo(t,e,i,s,n,r)}quadraticCurveTo(t,e,i,s){return this.vexFlowCanvasContext.quadraticCurveTo(t,e,i,s)}arc(t,e,i,s,n,r){return this.vexFlowCanvasContext.arc(t,e,i,s,n,r)}glow(){return this.vexFlowCanvasContext.glow()}fill(){return this.vexFlowCanvasContext.fill()}stroke(){return this.vexFlowCanvasContext.stroke()}closePath(){return this.vexFlowCanvasContext.closePath()}measureText(t){return this.vexFlowCanvasContext.measureText(t)}fillText(t,e,i){return this.vexFlowCanvasContext.fillText(t,e,i)}save(){return this.vexFlowCanvasContext.save()}restore(){return this.vexFlowCanvasContext.restore()}}class b{constructor(t){this.element=t,this.paper=Raphael(t),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(t,e,i){return this.state.font_family=t,this.state.font_size=e,this.state.font_weight=i,this.attributes.font=(this.state.font_weight||"")+" "+this.state.font_size*this.state.scale.x+"pt "+this.state.font_family,this}setRawFont(t){return this.attributes.font=t,this}setFillStyle(t){return this.attributes.fill=t,this}setBackgroundFillStyle(t){return this.background_attributes.fill=t,this.background_attributes.stroke=t,this}setStrokeStyle(t){return this.attributes.stroke=t,this}setShadowColor(t){return this.shadow_attributes.color=t,this}setShadowBlur(t){return this.shadow_attributes.width=t,this}setLineWidth(t){this.attributes["stroke-width"]=t,this.lineWidth=t}setLineDash(){return this}setLineCap(){return this}scale(t,e){return this.state.scale={x:t,y:e},this.attributes.transform="S"+t+","+e+",0,0",this.attributes.scale=t+","+e+",0,0",this.attributes.font=this.state.font_size*this.state.scale.x+"pt "+this.state.font_family,this.background_attributes.transform="S"+t+","+e+",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(t,e){return this.element.style.width=t,this.paper.setSize(t,e),this}setViewBox(t){this.paper.canvas.setAttribute("viewBox",t)}rect(t,e,i,s){return s<0&&(e+=s,s=-s),this.paper.rect(t,e,i-.5,s-.5).attr(this.attributes).attr("fill","none").attr("stroke-width",this.lineWidth),this}fillRect(t,e,i,s){return s<0&&(e+=s,s=-s),this.paper.rect(t,e,i-.5,s-.5).attr(this.attributes),this}clearRect(t,e,i,s){return s<0&&(e+=s,s=-s),this.paper.rect(t,e,i-.5,s-.5).attr(this.background_attributes),this}beginPath(){return this.path="",this.pen.x=0,this.pen.y=0,this}moveTo(t,e){return this.path+="M"+t+","+e,this.pen.x=t,this.pen.y=e,this}lineTo(t,e){return this.path+="L"+t+","+e,this.pen.x=t,this.pen.y=e,this}bezierCurveTo(t,e,i,s,n,r){return this.path+="C"+t+","+e+","+i+","+s+","+n+","+r,this.pen.x=n,this.pen.y=r,this}quadraticCurveTo(t,e,i,s){return this.path+="Q"+t+","+e+","+i+","+s,this.pen.x=i,this.pen.y=s,this}arc(t,e,i,s,n,r){function o(t){for(;t<0;)t+=2*Math.PI;for(;t>2*Math.PI;)t-=2*Math.PI;return t}if((s=o(s))>(n=o(n))){const t=s;s=n,n=t,r=!r}const a=n-s;return a>Math.PI?(this.arcHelper(t,e,i,s,s+a/2,r),this.arcHelper(t,e,i,s+a/2,n,r)):this.arcHelper(t,e,i,s,n,r),this}arcHelper(t,e,i,s,n,r){const o=t+i*Math.cos(s),a=e+i*Math.sin(s),l=t+i*Math.cos(n),h=e+i*Math.sin(n);let c=0,u=0;r?(u=1,n-sMath.PI&&(c=1),this.path+="M"+o+","+a+",A"+i+","+i+",0,"+c+","+u+","+l+","+h+"M"+this.pen.x+","+this.pen.y}glow(){const t=this.paper.set();if(this.shadow_attributes.width>0){const e=this.shadow_attributes,i=e.width/2;for(let s=1;s<=i;s++)t.push(this.paper.path(this.path).attr({stroke:e.color,"stroke-linejoin":"round","stroke-linecap":"round","stroke-width":+(e.width/i*s).toFixed(3),opacity:+((e.opacity||.3)/i).toFixed(3),transform:this.attributes.transform,scale:this.attributes.scale}))}return t}fill(){const t=this.paper.path(this.path).attr(this.attributes).attr("stroke-width",0);return this.glow(t),this}stroke(){const t=this.lineWidth*(this.state.scale.x+this.state.scale.y)/2,e=this.paper.path(this.path).attr(this.attributes).attr("fill","none").attr("stroke-width",t);return this.glow(e),this}closePath(){return this.path+="Z",this}measureText(t){const e=this.paper.text(0,0,t).attr(this.attributes).attr("fill","none").attr("stroke","none"),i=e.getBBox();return e.remove(),{width:i.width,height:i.height}}fillText(t,e,i){return this.paper.text(e+this.measureText(t).width/2,i-this.state.font_size/(2.25*this.state.scale.y),t).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 t=this.state_stack.pop();return this.state.font_family=t.state.font_family,this.attributes.font=t.attributes.font,this.attributes.fill=t.attributes.fill,this.attributes.stroke=t.attributes.stroke,this.attributes["stroke-width"]=t.attributes["stroke-width"],this.shadow_attributes.width=t.shadow_attributes.width,this.shadow_attributes.color=t.shadow_attributes.color,this}}const g={path:{x:!0,y:!0,width:!0,height:!0},rect:{},text:{width:!0,height:!0}};{const t={"font-family":!0,"font-weight":!0,"font-style":!0,"font-size":!0};s.Merge(g.rect,t),s.Merge(g.path,t)}class S{constructor(t){this.element=t,this.svgNS="http://www.w3.org/2000/svg";const e=this.create("svg");this.element.appendChild(e),this.svg=e,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(t){return document.createElementNS(this.svgNS,t)}openGroup(t,e,i){const n=this.create("g");return this.groups.push(n),this.parent.appendChild(n),this.parent=n,t&&n.setAttribute("class",s.Prefix(t)),e&&n.setAttribute("id",s.Prefix(e)),i&&i.pointerBBox&&n.setAttribute("pointer-events","bounding-box"),n}closeGroup(){this.groups.pop(),this.parent=this.groups[this.groups.length-1]}add(t){this.parent.appendChild(t)}iePolyfill(){"undefined"!=typeof navigator&&(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(t,e,i){let n=!1,r=!1,o="normal";"string"==typeof i&&(-1!==i.indexOf("italic")&&(i=i.replace(/italic/g,""),r=!0),-1!==i.indexOf("bold")&&(i=i.replace(/bold/g,""),n=!0),i=i.replace(/ /g,"")),o=r?"italic":o;const a={"font-family":t,"font-size":e+"pt","font-weight":i=void 0===(i=n?"bold":i)||""===i?"normal":i,"font-style":o};return this.fontSize=Number(e),s.Merge(this.attributes,a),s.Merge(this.state,a),this}setRawFont(t){const e=(t=t.trim()).split(" ");return this.attributes["font-family"]=e[1],this.state["font-family"]=e[1],this.attributes["font-size"]=e[0],this.state["font-size"]=e[0],this.fontSize=Number(e[0].match(/\d+/)),this}setFillStyle(t){return this.attributes.fill=t,this}setBackgroundFillStyle(t){return this.background_attributes.fill=t,this.background_attributes.stroke=t,this}setStrokeStyle(t){return this.attributes.stroke=t,this}setShadowColor(t){return this.shadow_attributes.color=t,this}setShadowBlur(t){return this.shadow_attributes.width=t,this}setLineWidth(t){this.attributes["stroke-width"]=t,this.lineWidth=t}setLineDash(t){if("[object Array]"===Object.prototype.toString.call(t))return t=t.join(", "),this.attributes["stroke-dasharray"]=t,this;throw new s.RERR("ArgumentError","lineDash must be an array of integers.")}setLineCap(t){return this.attributes["stroke-linecap"]=t,this}resize(t,e){this.width=t,this.height=e,this.element.style.width=t;const i={width:t,height:e};return this.applyAttributes(this.svg,i),this.scale(this.state.scale.x,this.state.scale.y),this}scale(t,e){this.state.scale={x:t,y:e};const i=this.width/t,s=this.height/e;return this.setViewBox(0,0,i,s),this}setViewBox(...t){if(1===t.length){const[e]=t;this.svg.setAttribute("viewBox",e)}else{const[e,i,s,n]=t,r=e+" "+i+" "+s+" "+n;this.svg.setAttribute("viewBox",r)}}applyAttributes(t,e){const i=g[t.nodeName];return Object.keys(e).forEach((s=>{i&&i[s]||t.setAttributeNS(null,s,e[s])})),t}clear(){for(;this.svg.lastChild;)this.svg.removeChild(this.svg.lastChild);this.scale(this.state.scale.x,this.state.scale.y)}rect(t,e,i,n,r){n<0&&(e+=n,n*=-1);const o=this.create("rect");return void 0===r&&(r={fill:"none","stroke-width":this.lineWidth,stroke:this.attributes.stroke}),s.Merge(r,{x:t,y:e,width:i,height:n}),this.applyAttributes(o,r),this.add(o),this}fillRect(t,e,i,s){return s<0&&(e+=s,s*=-1),this.rect(t,e,i,s,this.attributes),this}clearRect(t,e,i,s){return this.rect(t,e,i,s,this.background_attributes),this}beginPath(){return this.path="",this.pen.x=NaN,this.pen.y=NaN,this}moveTo(t,e){return this.path+="M"+t+" "+e,this.pen.x=t,this.pen.y=e,this}lineTo(t,e){return this.path+="L"+t+" "+e,this.pen.x=t,this.pen.y=e,this}bezierCurveTo(t,e,i,s,n,r){return this.path+="C"+t+" "+e+","+i+" "+s+","+n+" "+r,this.pen.x=n,this.pen.y=r,this}quadraticCurveTo(t,e,i,s){return this.path+="Q"+t+" "+e+","+i+" "+s,this.pen.x=i,this.pen.y=s,this}arc(t,e,i,s,n,r){function o(t){for(;t<0;)t+=2*Math.PI;for(;t>2*Math.PI;)t-=2*Math.PI;return t}if((s=o(s))>(n=o(n))){const t=s;s=n,n=t,r=!r}const a=n-s;return a>Math.PI?(this.arcHelper(t,e,i,s,s+a/2,r),this.arcHelper(t,e,i,s+a/2,n,r)):this.arcHelper(t,e,i,s,n,r),this}arcHelper(t,e,i,s,n,r){const o=t+i*Math.cos(s),a=e+i*Math.sin(s),l=t+i*Math.cos(n),h=e+i*Math.sin(n);let c=0,u=0;r?(u=1,n-sMath.PI&&(c=1),this.path+="M"+o+" "+a+" A"+i+" "+i+" 0 "+c+" "+u+" "+l+" "+h,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 t=this.shadow_attributes,e=t.width/2;for(let i=1;i<=e;i++){const s={stroke:t.color,"stroke-linejoin":"round","stroke-linecap":"round","stroke-width":+(.4*t.width/e*i).toFixed(3),opacity:+((t.opacity||.3)/e).toFixed(3)},n=this.create("path");s.d=this.path,this.applyAttributes(n,s),this.add(n)}}return this}fill(t){this.glow();const e=this.create("path");let i=t;return void 0===t?(s.Merge(t={},this.attributes),t.stroke="none",i=t):(i=t,s.Merge(i,this.attributes),t.class&&(i.class=t.class),t.id&&(i.id=t.id)),t.d=this.path,this.applyAttributes(e,t),this.add(e),this}stroke(t){this.glow();const e=this.create("path"),i={};return s.Merge(i,this.attributes),t&&s.Merge(i,t),i.fill="none",i["stroke-width"]=this.lineWidth,i.d=this.path,this.applyAttributes(e,i),this.add(e),this}measureText(t){const e=this.create("text");if("function"!=typeof e.getBBox)return{x:0,y:0,width:0,height:0};e.textContent=t,this.applyAttributes(e,this.attributes),this.svg.appendChild(e);let i=e.getBBox();return this.ie&&""!==t&&"italic"===this.attributes["font-style"]&&(i=this.ieMeasureTextFix(i,t)),this.svg.removeChild(e),i}ieMeasureTextFix(t){const e=1.196*Number(this.fontSize)+1.9598,i=t.width-e,s=t.height-1.5;return{x:t.x,y:t.y,width:i,height:s}}fillText(t,e,i){if(!t||t.length<=0)return;const n={};s.Merge(n,this.attributes),n.stroke="none",n.x=e,n.y=i;const r=this.create("text");r.textContent=t,this.applyAttributes(r,n),this.add(r)}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 t=this.state_stack.pop();return this.state["font-family"]=t.state["font-family"],this.state["font-weight"]=t.state["font-weight"],this.state["font-style"]=t.state["font-style"],this.state["font-size"]=t.state["font-size"],this.state.scale=t.state.scale,this.attributes["font-family"]=t.attributes["font-family"],this.attributes["font-weight"]=t.attributes["font-weight"],this.attributes["font-style"]=t.attributes["font-style"],this.attributes["font-size"]=t.attributes["font-size"],this.attributes.fill=t.attributes.fill,this.attributes.stroke=t.attributes.stroke,this.attributes["stroke-width"]=t.attributes["stroke-width"],this.attributes["stroke-dasharray"]=t.attributes["stroke-dasharray"],this.shadow_attributes.width=t.shadow_attributes.width,this.shadow_attributes.color=t.shadow_attributes.color,this.lineWidth=t.lineWidth,this}}let y=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 y}static set lastContext(t){y=t}static buildContext(t,e,i,s,n){const r=new E(t,e);i&&s&&r.resize(i,s),n||(n="#FFF");const o=r.getContext();return o.setBackgroundFillStyle(n),E.lastContext=o,o}static getCanvasContext(t,e,i,s){return E.buildContext(t,E.Backends.CANVAS,e,i,s)}static getRaphaelContext(t,e,i,s){return E.buildContext(t,E.Backends.RAPHAEL,e,i,s)}static getSVGContext(t,e,i,s){return E.buildContext(t,E.Backends.SVG,e,i,s)}static bolsterCanvasContext(t){return E.USE_CANVAS_PROXY?new p(t):(t.vexFlowCanvasContext=t,["clear","setFont","setRawFont","setFillStyle","setBackgroundFillStyle","setStrokeStyle","setShadowColor","setShadowBlur","setLineWidth","setLineCap","setLineDash","openGroup","closeGroup","getGroup"].forEach((e=>{t[e]=t[e]||p.prototype[e]})),t)}static drawDashedLine(t,e,i,s,n,r){t.beginPath();const o=s-e,a=n-i,l=Math.atan2(a,o);let h=e,c=i;t.moveTo(e,i);let u=0,d=!0;for(;!(o<0?h<=s:h>=s)||!(a<0?c<=n:c>=n);){const e=r[u++%r.length],i=h+Math.cos(l)*e;h=o<0?Math.max(s,i):Math.min(s,i);const f=c+Math.sin(l)*e;c=a<0?Math.max(n,f):Math.min(n,f),d?t.lineTo(h,c):t.moveTo(h,c),d=!d}t.closePath(),t.stroke()}constructor(t,e){if(this.elementId=t,!this.elementId)throw new s.RERR("BadArgument","Invalid id for renderer.");if(this.element=document.getElementById(t),this.element||(this.element=t),this.ctx=null,this.paper=null,this.backend=e,this.backend===E.Backends.CANVAS){if(!this.element.getContext)throw new s.RERR("BadElement",`Can't get canvas context from element: ${t}`);this.ctx=E.bolsterCanvasContext(this.element.getContext("2d",{willReadFrequently:!0}))}else if(this.backend===E.Backends.RAPHAEL)this.ctx=new b(this.element);else{if(this.backend!==E.Backends.SVG)throw new s.RERR("InvalidBackend",`No support for backend: ${this.backend}`);this.ctx=new S(this.element)}}resize(t,e){if(this.backend===E.Backends.CANVAS){if(!this.element.getContext)throw new s.RERR("BadElement",`Can't get canvas context from element: ${this.elementId}`);[t,e]=p.SanitizeCanvasDims(t,e);const i=window.devicePixelRatio||1;this.element.width=t*i,this.element.height=e*i,this.element.style.width=t+"px",this.element.style.height=e+"px",this.ctx=E.bolsterCanvasContext(this.element.getContext("2d",{willReadFrequently:!0})),this.ctx.scale(i,i)}else this.ctx.resize(t,e);return this}getContext(){return this.ctx}}class v extends l{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(t={}){super(),this.setAttribute("type","Stem"),this.x_begin=t.x_begin||0,this.x_end=t.x_end||0,this.y_top=t.y_top||0,this.y_bottom=t.y_bottom||0,this.stem_extension=t.stem_extension||0,this.stem_direction=t.stem_direction||0,this.hide=t.hide||!1,this.isStemlet=t.isStemlet||!1,this.stemletHeight=t.stemletHeight||0,this.renderHeightAdjustment=0,this.setOptions(t)}setOptions(t){this.stem_up_y_offset=t.stem_up_y_offset||0,this.stem_down_y_offset=t.stem_down_y_offset||0}setNoteHeadXBounds(t,e){return this.x_begin=t,this.x_end=e,this}setDirection(t){this.stem_direction=t}setExtension(t){this.stem_extension=t}getExtension(){return this.stem_extension}setYBounds(t,e){this.y_top=t,this.y_bottom=e}getCategory(){return v.CATEGORY}getHeight(){const t=this.stem_direction===v.UP?this.stem_up_y_offset:this.stem_down_y_offset;return(this.y_bottom-this.y_top)*this.stem_direction+(v.HEIGHT-t+this.stem_extension)*this.stem_direction}getBoundingBox(){throw new s.RERR("NotImplemented","getBoundingBox() not implemented.")}getExtents(){const t=this.stem_direction===v.UP,e=[this.y_top,this.y_bottom],i=v.HEIGHT+this.stem_extension,s=(t?Math.min:Math.max)(...e),n=(t?Math.max:Math.min)(...e);return{topY:s+i*-this.stem_direction,baseY:n}}setVisibility(t){return this.hide=!t,this}setStemlet(t,e){return this.isStemlet=t,this.stemletHeight=e,this}draw(){if(this.setRendered(),this.hide)return;const t=this.checkContext();let e,i;const n=this.stem_direction;n===v.DOWN?(e=this.x_begin,i=this.y_top+this.stem_down_y_offset):(e=this.x_end,i=this.y_bottom-this.stem_up_y_offset);const r=this.getHeight();!function(...t){v.DEBUG&&s.L("Vex.Flow.Stem",t)}("Rendering stem - ","Top Y: ",this.y_top,"Bottom Y: ",this.y_bottom);const o=this.isStemlet?r-this.stemletHeight*this.stem_direction:0;if(t.save(),this.applyStyle(t),t.beginPath(),t.setLineWidth(v.WIDTH),t.moveTo(e,i-o),t.lineTo(e,i-r-this.renderHeightAdjustment*n),t.svg){const e={class:s.Prefix("stem")};this.id&&(e.id=this.id),t.stroke(e)}else t.stroke();this.restoreStyle(t),t.restore()}}class x extends l{static get LOCATION_TOP(){return 1}static get LOCATION_BOTTOM(){return-1}static get NESTING_OFFSET(){return 15}constructor(t,e){if(super(),this.setAttribute("type","Tuplet"),!t||!t.length)throw new s.RuntimeError("BadArguments","No notes provided for tuplet.");this.options=s.Merge({},e),this.notes=t,this.num_notes="num_notes"in this.options?this.options.num_notes:t.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=t.some((t=>null===t.beam)),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||x.LOCATION_TOP,ut.AlignRestsToNotes(t,!0,!0),this.resolveGlyphs(),this.attach()}attach(){for(let t=0;t=1;)this.numerator_glyphs.unshift(new f("v"+t%10,this.point)),t=parseInt(t/10,10);for(this.denom_glyphs=[],t=this.notes_occupied;t>=1;)this.denom_glyphs.unshift(new f("v"+t%10,this.point)),t=parseInt(t/10,10)}getNestedTupletCount(){const t=this.location,e=this.notes[0];let i=n(e,t),s=n(e,t);function n(t,e){return t.tupletStack.filter((t=>t.location===e)).length}return this.notes.forEach((e=>{const r=n(e,t);i=r>i?r:i,s=rs&&(s=e)}}return s+t+e}draw(){this.checkContext(),this.setRendered();const t=this.notes[0],e=this.notes[this.notes.length-1];this.bracketed?(this.x_pos=t.getTieLeftX()-5,this.width=e.getTieRightX()-this.x_pos+5):(this.x_pos=t.getStemX(),this.width=e.getStemX()-this.x_pos),this.y_pos=this.getYPosition();const i=(t,e)=>t+e.getMetrics().width;let s=this.numerator_glyphs.reduce(i,0);this.ratioed&&(s=this.denom_glyphs.reduce(i,s),s+=.32*this.point);const n=this.x_pos+this.width/2-s/2;if(this.bracketed){const t=this.width/2-s/2-5;t>0&&(this.context.fillRect(this.x_pos,this.y_pos,t,1),this.context.fillRect(this.x_pos+this.width/2+s/2+5,this.y_pos,t,1),this.context.fillRect(this.x_pos,this.y_pos+(this.location===x.LOCATION_BOTTOM),1,10*this.location),this.context.fillRect(this.x_pos+this.width,this.y_pos+(this.location===x.LOCATION_BOTTOM),1,10*this.location))}if(!1!==this.RenderTupletNumber){let t=0;this.numerator_glyphs.forEach((e=>{e.render(this.context,n+t,this.y_pos+this.point/3-2),t+=e.getMetrics().width}))}if(this.ratioed){const t=n+x_offset+.16*this.point,e=.06*this.point;this.context.beginPath(),this.context.arc(t,this.y_pos-.08*this.point,e,0,2*Math.PI,!0),this.context.closePath(),this.context.fill(),this.context.beginPath(),this.context.arc(t,this.y_pos+.12*this.point,e,0,2*Math.PI,!0),this.context.closePath(),this.context.fill(),x_offset+=.32*this.point,this.denom_glyphs.forEach((t=>{t.render(this.context,n+x_offset,this.y_pos+this.point/3-2),x_offset+=t.getMetrics().width}))}}}function _(t){let e=0;return t.forEach((t=>{t.keyProps&&t.keyProps.forEach((t=>{e+=t.line-3}))})),e>=0?v.DOWN:v.UP}const M="L",w="B";class P extends l{static getDefaultBeamGroups(t){t&&"c"!==t||(t="4/4");const e={"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"]}[t];if(void 0!==e)return e.map((t=>(new n).parse(t)));{const e=parseInt(t.split("/")[0],10),i=parseInt(t.split("/")[1],10);if(e%3==0)return[new n(3,i)];if(i>4)return[new n(2,i)];if(i<=4)return[new n(1,i)]}return[new n(1,4)]}static applyAndGetBeams(t,e,i){return P.generateBeams(t.getTickables(),{groups:i,stem_direction:e})}static generateBeams(t,e){e||(e={}),e.groups&&e.groups.length||(e.groups=[new n(2,8)]);const i=e.groups.map((t=>{if(!t.multiply)throw new s.RuntimeError("InvalidBeamGroups","The beam groups must be an array of Vex.Flow.Fractions");return t.clone().multiply(m.RESOLUTION,1)})),r=t;let o=0,a=[],l=[];function h(){i.length-1>o?o+=1:o=0}!function(){let t=[];r.forEach((e=>{if(t=[],e.shouldIgnoreTicks())return a.push(l),void(l=t);l.push(e);const s=i[o].clone(),r=l.reduce(((t,e)=>e.getTicks().clone().add(t)),new n(0,1)),c=m.durationToNumber(e.duration)<8;c&&e.tuplet&&(s.numerator*=2),r.greaterThan(s)?(c||t.push(l.pop()),a.push(l),l=t,h()):r.equals(s)&&(a.push(l),l=t,h())})),l.length>0&&a.push(l)}(),function(){const t=[];a.forEach((i=>{let s=[];i.forEach(((i,n,r)=>{const o=0===n||n===r.length-1,a=r[n-1],l=!e.beam_rests&&i.isRest(),h=e.beam_rests&&e.beam_middle_only&&i.isRest()&&o;let c=!1;if(e.maintain_stem_directions&&a&&!i.isRest()&&!a.isRest()){const t=a.getStemDirection();c=i.getStemDirection()!==t}const u=parseInt(i.duration,10)<8;l||h||c||u?(s.length>0&&t.push(s),s=c?[i]:[]):s.push(i)})),s.length>0&&t.push(s)})),a=t}(),a.forEach((t=>{let i;if(e.maintain_stem_directions){const e=function(t){for(let e=0;e{t.setStemDirection(e)}))}(t,i)}));const c=a.filter((t=>{if(t.length>1){let e=!0;return t.forEach((t=>{t.getIntrinsicTicks()>=m.durationToTicks("4")&&(e=!1)})),e}return!1})),u=function(){const t=[];return a.forEach((e=>{let i=null;e.forEach((e=>{e.tuplet&&i!==e.tuplet&&(i=e.tuplet,t.push(i))}))})),t}(),d=[];return c.forEach((t=>{const i=new P(t);e.show_stemlets&&(i.render_options.show_stemlets=!0),e.secondary_breaks&&(i.render_options.secondary_break_ticks=m.durationToTicks(e.secondary_breaks)),!0===e.flat_beams&&(i.render_options.flat_beams=!0,i.render_options.flat_beam_offset=e.flat_beam_offset),d.push(i)})),u.forEach((t=>{const e=t.notes[0].stem_direction===v.DOWN?x.LOCATION_BOTTOM:x.LOCATION_TOP;t.setTupletLocation(e);let i=!1;for(let e=0;e=m.durationToTicks("4"))throw new s.RuntimeError("BadArguments","Beams can only be applied to notes shorter than a quarter note.");let i,n;for(this.stem_direction=v.UP,i=0;it+e.stem_direction),0);r=e>-1?v.UP:v.DOWN}for(i=0;it.getGlyph().beam_count)).reduce(((t,e)=>e>t?e:t))}breakSecondaryAt(t){return this.break_on_indices=t,this}getSlopeY(t,e,i,s){return i+(t-e)*s}calculateSlope(){const{notes:t,stem_direction:e,render_options:{max_slope:i,min_slope:s,slope_iterations:n,slope_cost:r}}=this,o=t[0],a=((t,e)=>{const i=t.getStemExtents().topY,s=t.getStemX();return(e.getStemExtents().topY-i)/(e.getStemX()-s)})(o,t[t.length-1]),l=(i-s)/n;let h=Number.MAX_VALUE,c=0,u=0;for(let n=s;n<=i;n+=l){let i=0,s=0;for(let r=1;rn)&&(l=n,o=Math.min(...s.getYs()),a=s.getBeamCount())}let h=r/t.length;const c=s+a*(1.5*i),u=o+c*-e;e===v.DOWN&&hu&&(h=o-c),n+this.render_options.flat_beam_offset_per_beam>0?(e===v.DOWN&&h>n&&!this.render_options.flat_beams||e===v.UP&&h0){let e=this.render_options.flat_beam_offset;this.render_options.flat_beam_offset_per_beam&&(e+=this.render_options.flat_beam_offset_per_beam*this.getBeamCount());let i=this.notes[0].note_heads[0].y;const s=this.stem_direction>0?Math.min:Math.max;for(const t of this.notes)for(const e of t.note_heads)i=s(i,e.y);t=i+e*-this.stem_direction}return t}applyStemExtensions(){const{notes:t,slope:e,y_shift:i,stem_direction:s,beam_count:n,render_options:{show_stemlets:r,stemlet_extension:o,beam_width:a}}=this,l=t[0],h=this.getBeamYToDraw(),c=l.getStemX();for(let l=0;l=8&&(c=-1!==this.break_on_indices.indexOf(l),this.render_options.secondary_break_ticks&&a>=this.render_options.secondary_break_ticks&&(a=0,c=!0));const u=h.getIntrinsicTicks(){t.getStem()&&(this.context.openGroup("stem",t.getAttribute("id")+"-stem"),t.getStem().setContext(this.context).draw(),this.context.closeGroup())}),this)}drawBeamLines(){this.checkContext();const t=["4","8","16","32","64"],e=this.notes[0];let i=this.getBeamYToDraw();const s=e.getStemX(),n=this.render_options.beam_width*this.stem_direction,r={};for(const t of this.notes)r[t.getAttribute("id")]=0;for(let e=0;e{t.getStave()||t.setStave(this.stave)})),this.preFormatted=!0),this}draw(t=this.context,e=this.stave){this.setRendered();let i=null;for(let n=0;n0&&i){const t=r.getBoundingBox();t&&i.mergeWith(t)}r.setContext(t),r.drawWithStyle()}this.boundingBox=i}}function L(t,e,i,n,r){if(e!==A.type.BOLD_DOUBLE_LEFT&&e!==A.type.BOLD_DOUBLE_RIGHT)throw new s.RERR("InvalidConnector","A REPEAT_BEGIN or REPEAT_END type must be provided.");let o=3,a=3.5;e===A.type.BOLD_DOUBLE_RIGHT&&(o=-5,a=3),t.fillRect(i+o,n,1,r-n),t.fillRect(i-2,n,a,r-n)}class A extends l{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:A.type.SINGLE_RIGHT,singleLeft:A.type.SINGLE_LEFT,single:A.type.SINGLE,double:A.type.DOUBLE,brace:A.type.BRACE,bracket:A.type.BRACKET,boldDoubleLeft:A.type.BOLD_DOUBLE_LEFT,boldDoubleRight:A.type.BOLD_DOUBLE_RIGHT,thinDouble:A.type.THIN_DOUBLE,none:A.type.NONE}}constructor(t,e){super(),this.setAttribute("type","StaveConnector"),this.thickness=m.STAVE_LINE_THICKNESS,this.width=3,this.top_stave=t,this.bottom_stave=e,this.type=A.type.DOUBLE,this.font={family:"times",size:16,weight:"normal"},this.x_shift=0,this.texts=[]}setType(t){return(t="string"==typeof t?A.typeString[t]:t)>=A.type.SINGLE_RIGHT&&t<=A.type.NONE&&(this.type=t),this}setText(t,e){return this.texts.push({content:t,options:s.Merge({shift_x:0,shift_y:0},e)}),this}setFont(t){s.Merge(this.font,t)}setXShift(t){if("number"!=typeof t)throw s.RERR("InvalidType","x_shift must be a Number");return this.x_shift=t,this}draw(){const t=this.checkContext();this.setRendered();let e=this.top_stave.getYForLine(0),i=this.bottom_stave.getYForLine(this.bottom_stave.getNumLines()-1)+this.thickness,n=this.width,r=this.top_stave.getX();(this.type===A.type.SINGLE_RIGHT||this.type===A.type.BOLD_DOUBLE_RIGHT||this.type===A.type.THIN_DOUBLE)&&(r=this.top_stave.getX()+this.top_stave.width);let o=i-e;switch(this.type){case A.type.SINGLE:case A.type.SINGLE_LEFT:case A.type.SINGLE_RIGHT:n=1;break;case A.type.DOUBLE:r-=this.width+2;break;case A.type.BRACE:{n=12;const s=this.top_stave.getX()-2+this.x_shift,r=e,a=s,l=i,h=s-n,c=r+o/2,u=h-.9*n,d=r+.2*o,f=s+1.1*n,m=c-.135*o,p=f,b=c+.135*o,g=u,S=l-.2*o,y=h-n,E=S,v=s+.4*n,x=c+.135*o,_=v,M=c-.135*o,w=y,P=d;t.beginPath(),t.moveTo(s,r),t.bezierCurveTo(u,d,f,m,h,c),t.bezierCurveTo(p,b,g,S,a,l),t.bezierCurveTo(y,E,v,x,h,c),t.bezierCurveTo(_,M,w,P,s,r),t.fill(),t.stroke();break}case A.type.BRACKET:e-=4,i+=4,o=i-e,f.renderGlyph(t,r-5,e-3,40,"v1b",!0),f.renderGlyph(t,r-5,i+3,40,"v10",!0),r-=this.width+2;break;case A.type.BOLD_DOUBLE_LEFT:L(t,this.type,r+this.x_shift,e,i);break;case A.type.BOLD_DOUBLE_RIGHT:L(t,this.type,r,e,i);break;case A.type.THIN_DOUBLE:n=1;break;case A.type.NONE:break;default:throw new s.RERR("InvalidType",`The provided StaveConnector.type (${this.type}) is invalid`)}this.type!==A.type.BRACE&&this.type!==A.type.BOLD_DOUBLE_LEFT&&this.type!==A.type.BOLD_DOUBLE_RIGHT&&this.type!==A.type.NONE&&t.fillRect(r,e,n,o),this.type===A.type.THIN_DOUBLE&&t.fillRect(r-3,e,n,o),t.save(),t.lineWidth=2,t.setFont(this.font.family,this.font.size,this.font.weight);for(let e=0;e0){const s=p.space.deviation,n=s>=0?"+":"";t.setFillStyle("red"),t.fillText(n+Math.round(s),a+e.getXShift(),i-10)}t.restore()}constructor(t){if(super(),this.setAttribute("type","Note"),!t)throw new s.RuntimeError("BadArguments","Note must have valid initialization data to identify duration and type.");const e=m.parseNoteStruct(t);if(!e)throw new s.RuntimeError("BadArguments",`Invalid note initialization object: ${JSON.stringify(t)}`);if(this.duration=e.duration,this.dots=e.dots,this.noteType=e.type,this.customTypes=e.customTypes,t.duration_override?this.setDuration(t.duration_override):this.setIntrinsicTicks(e.ticks),this.modifiers=[],this.glyph=m.getGlyphProps(this.duration,this.noteType),this.customGlyphs=this.customTypes.map((t=>m.getGlyphProps(this.duration,t))),this.positions&&("object"!=typeof this.positions||!this.positions.length))throw new s.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=[],t.align_center&&this.setCenterAlignment(t.align_center),this.stave=null,this.render_options={annotation_spacing:5,stave_padding:I.STAVEPADDING}}getPlayNote(){return this.playNote}setPlayNote(t){return this.playNote=t,this}isRest(){return!1}addStroke(t,e){return e.setNote(this),e.setIndex(t),this.modifiers.push(e),this.setPreFormatted(!1),this}getStave(){return this.stave}setStave(t){return this.stave=t,this.setYs([t.getYForLine(0)]),this.context=this.stave.context,this}getCategory(){return I.CATEGORY}setContext(t){return this.context=t,this}getExtraLeftPx(){return this.extraLeftPx}getExtraRightPx(){return this.extraRightPx}setExtraLeftPx(t){return this.extraLeftPx=t,this}setExtraRightPx(t){return this.extraRightPx=t,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(t){return this.ys=t,this}getYs(){if(0===this.ys.length)throw new s.RERR("NoYValues","No Y-values calculated for this note.");return this.ys}getYForTopText(t){if(!this.stave)throw new s.RERR("NoStave","No stave attached to this note.");return this.stave.getYForTopText(t)}getBoundingBox(){return null}getVoice(){if(!this.voice)throw new s.RERR("NoVoice","Note has no voice.");return this.voice}setVoice(t){return this.voice=t,this.preFormatted=!1,this}getTickContext(){return this.tickContext}setTickContext(t){return this.tickContext=t,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(t){return this.modifierContext=t,this}addModifier(t,e=0){return t.setNote(this),t.setIndex(e),this.modifiers.push(t),this.setPreFormatted(!1),this}getModifierStartXY(){if(!this.preFormatted)throw new s.RERR("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");return{x:this.getAbsoluteX(),y:this.ys[0]}}getMetrics(){if(!this.preFormatted)throw new s.RERR("UnformattedNote","Can't call getMetrics on an unformatted note.");let t=0,e=0;null!=this.modifierContext&&(t=this.modifierContext.state.left_shift,e=this.modifierContext.state.right_shift);const i=this.getWidth();return{width:i,noteWidth:i-t-e-this.extraLeftPx-this.extraRightPx,left_shift:this.x_shift,modLeftPx:t,modRightPx:e,extraLeftPx:this.extraLeftPx,extraRightPx:this.extraRightPx}}setWidth(t){this.width=t}getWidth(){if(!this.preFormatted)throw new s.RERR("UnformattedNote","Can't call GetWidth on an unformatted note.");return this.width+(this.modifierContext?this.modifierContext.getWidth():0)}setXShift(t){return this.x_shift=t,this}getXShift(){return this.x_shift}getX(){if(!this.tickContext)throw new s.RERR("NoTickContext","Note needs a TickContext assigned for an X-Value");return this.tickContext.getX()+this.x_shift}getAbsoluteX(){if(!this.tickContext)throw new s.RERR("NoTickContext","Note needs a TickContext assigned for an X-Value");let t=this.tickContext.getX();return this.stave&&(t+=this.stave.getNoteStartX()+this.render_options.stave_padding),this.isCenterAligned()&&(t+=this.getCenterXShift()),t}setPreFormatted(t){if(this.preFormatted=t,this.preFormatted){const t=this.tickContext.getExtraPx();this.left_modPx=Math.max(this.left_modPx,t.left),this.right_modPx=Math.max(this.right_modPx,t.right)}}}class R extends I{static get CATEGORY(){return"notehead"}constructor(t){if(super(t),this.setAttribute("type","NoteHead"),this.index=t.index,this.x=t.x||0,this.y=t.y||0,this.note_type=t.note_type,this.duration=t.duration,this.displaced=t.displaced||!1,this.stem_direction=t.stem_direction||O.STEM_UP,this.line=t.line,this.glyph=m.getGlyphProps(this.duration,this.note_type),!this.glyph)throw new s.RuntimeError("BadArguments",`No glyph found for duration '${this.duration}' and type '${this.note_type}'`);this.glyph_code=this.glyph.code_head,this.x_shift=t.x_shift||0,t.custom_glyph_code&&(this.custom_glyph=!0,this.glyph_code=t.custom_glyph_code,this.stem_up_x_offset=t.stem_up_x_offset||0,this.stem_down_x_offset=t.stem_down_x_offset||0),this.style=t.style,this.slashed=t.slashed,s.Merge(this.render_options,{glyph_font_scale:t.glyph_font_scale||m.DEFAULT_NOTATION_FONT_SCALE,stroke_px:3}),this.setWidth(this.glyph.getWidth(this.render_options.glyph_font_scale))}getCategory(){return R.CATEGORY}getWidth(){return this.width}isDisplaced(){return!0===this.displaced}getGlyph(){return this.glyph}setX(t){return this.x=t,this}getY(){return this.y}setY(t){return this.y=t,this}getLine(){return this.line}setLine(t){return this.line=t,this}getAbsoluteX(){const t=this.preFormatted?super.getAbsoluteX():this.x,e=v.WIDTH/2;return t+(this.displaced?(this.width-e)*this.stem_direction:0)}getBoundingBox(){if(!this.preFormatted)throw new s.RERR("UnformattedNote","Can't call getBoundingBox on an unformatted note.");const t=this.stave.getSpacingBetweenLines(),e=t/2,i=this.y-e;return new m.BoundingBox(this.getAbsoluteX(),i,this.width,t)}setStave(t){const e=this.getLine();return this.stave=t,this.setY(t.getYForNote(e)),this.context=this.stave.context,this}preFormat(){if(this.preFormatted)return this;const t=this.getWidth()+this.extraLeftPx+this.extraRightPx;return this.setWidth(t),this.setPreFormatted(!0),this}draw(){this.checkContext(),this.setRendered();const t=this.context;let e=this.getAbsoluteX();this.custom_glyph&&(e+=this.stem_direction===v.UP?this.stem_up_x_offset:this.stem_down_x_offset);const i=this.y;!function(...t){R.DEBUG&&s.L("Vex.Flow.NoteHead",t)}("Drawing note head '",this.note_type,this.duration,"' at",e,i);const n=this.stem_direction,r=this.render_options.glyph_font_scale;if(this.style&&this.applyStyle(t),"s"===this.note_type){const s=this.stave.getSpacingBetweenLines();!function(t,e,i,s,n,r){const o=m.SLASH_NOTEHEAD_WIDTH;t.save(),t.setLineWidth(m.STEM_WIDTH);let a=!1;if(m.durationToNumber(e)>2&&(a=!0),a||(i-=m.STEM_WIDTH/2*n),t.beginPath(),t.moveTo(i,s+r),t.lineTo(i,s+1),t.lineTo(i+o,s-r),t.lineTo(i+o,s),t.lineTo(i,s+r),t.closePath(),a?t.fill():t.stroke(),m.durationToFraction(e).equals(.5)){const e=[-3,-1,o+1,o+3];for(let n=0;n{const i=t.getTickContext();t.setStave(e.stave),i.setXOffset(n)}))}}class F extends B{static get CATEGORY(){return"dots"}static format(t,e){const i=e.right_shift;if(!t||0===t.length)return!1;const s=[],n={};for(let e=0;ee.line-t.line));let r=i,o=0,a=null,l=null,h=null,c=0;for(let t=0;to?r:o,a=d,l=i}return e.right_shift+=o,!0}constructor(){super(),this.setAttribute("type","Dot"),this.note=null,this.index=null,this.position=B.Position.RIGHT,this.radius=2,this.setWidth(5),this.dot_shiftY=0}getCategory(){return F.CATEGORY}setNote(t){this.note=t,"gracenotes"===this.note.getCategory()&&(this.radius*=.5,this.setWidth(3))}setDotShiftY(t){return this.dot_shiftY=t,this}draw(){if(this.checkContext(),this.setRendered(),!this.note||null===this.index)throw new s.RERR("NoAttachedNote","Can't draw dot without a note and index.");const t=this.note.stave.options.spacing_between_lines_px,e=this.note.getModifierStartXY(this.position,this.index,{forceFlagRight:!0});"tabnotes"===this.note.getCategory()&&(e.y=this.note.getStemExtents().baseY);const i=e.x+this.x_shift+this.width-this.radius,n=e.y+this.y_shift+this.dot_shiftY*t,r=this.context;r.beginPath(),r.arc(i,n,this.radius,0,2*Math.PI,!1),r.fill()}}function D(t,e,i){const s=(e.isrest?0:1)*i;t.line+=s,t.maxLine+=s,t.minLine+=s,t.note.setKeyLine(0,t.note.getKeyLine(0)+s)}class O extends N{static get CATEGORY(){return"stavenotes"}static get STEM_UP(){return v.UP}static get STEM_DOWN(){return v.DOWN}static get DEFAULT_LEDGER_LINE_OFFSET(){return 3}static format(t,e){if(!t||t.length<2)return!1;const i=[],n=t[0].stagger_same_whole_notes;for(let e=0;e2?i[1]:null;let l=r>2?i[2]:i[1];2===r&&-1===o.stemDirection&&1===l.stemDirection&&(o=i[1],l=i[0]);const h=Math.max(o.voice_shift,l.voice_shift);let c,u=0;if(2===r){const t=o.stemDirection===l.stemDirection?0:.5;if(o.stemDirection===l.stemDirection&&o.minLine<=l.maxLine&&(o.isrest||(c=Math.abs(o.line-(l.maxLine+.5)),c=Math.max(c,o.stemMin),o.minLine=o.line-c,o.note.setStemLength(10*c))),o.minLine<=l.maxLine+t)if(o.isrest)D(o,l,1);else if(l.isrest)D(l,o,-1);else{u=h;const t=Math.abs(o.line-l.line);let e=0,i=0;"h"===o.note.duration?e++:"w"===o.note.duration&&i++,"h"===l.note.duration?e++:"w"===l.note.duration&&i++;let s=1===e||1===i||o.note.dots!==l.note.dots;if(n&&(s=s||2===i),0===t&&s){if(l.note.setXShift(u),o.note.dots>0){let t=0;for(const e of o.note.modifiers)if(e instanceof F&&(t++,e.setYShift(-10*(l.maxLine-o.line+1)),t===o.note.dots))break}}else t<1&&t>0?l.note.setXShift(u):o.note.voice!==l.note.voice&&o.stemDirection===l.stemDirection&&(o.line>l.line?1===o.stemDirection?l.note.renderFlag=!1:o.note.renderFlag=!1:l.line>o.line?1===l.stemDirection?o.note.renderFlag=!1:l.note.renderFlag=!1:1===l.stemDirection&&(l.stemDirection=-1,l.note.setStemDirection(-1)))}return!0}return null!==a&&a.minLinet.postFormat())),!0)}constructor(t){if(super(t),this.setAttribute("type","StaveNote"),this.keys=t.keys,this.clef=t.clef,this.octave_shift=t.octave_shift,this.beam=null,this.glyph=m.getGlyphProps(this.duration,this.noteType),!this.glyph)throw new s.RuntimeError("BadArguments",`Invalid note initialization data (No glyph found): ${JSON.stringify(t)}`);this.displaced=!1,this.dot_shiftY=0,this.addDotsCount=0,this.keyProps=[],this.use_default_head_x=!1,this.note_heads=[],this.modifiers=[],s.Merge(this.render_options,{glyph_font_scale:t.glyph_font_scale||m.DEFAULT_NOTATION_FONT_SCALE,stroke_px:t.stroke_px||O.DEFAULT_LEDGER_LINE_OFFSET}),this.calculateKeyProps(),this.buildStem(),t.auto_stem?this.autoStem():this.setStemDirection(t.stem_direction),this.reset(),this.buildFlag()}reset(){super.reset();const t=this.note_heads.map((t=>t.getStyle())),e=[];this.note_heads.forEach((t=>e.push(t.note_type))),this.buildNoteHeads(),this.note_heads.forEach(((i,s)=>{i.setStyle(t[s]),e[s]&&(i.note_type=e[s])})),this.stave&&this.note_heads.forEach((t=>t.setStave(this.stave))),this.calcExtraPx()}setBeam(t){return this.beam=t,this.calcExtraPx(),this}getCategory(){return O.CATEGORY}buildStem(){this.setStem(new v({hide:!!this.isRest()})),this.stem.id=s.Prefix(`${this.getAttribute("id")}-stem`)}buildNoteHeads(){this.note_heads=[];const t=this.getStemDirection(),e=this.getKeys();let i,s,n,r=null,o=null,a=!1;t===v.UP?(i=0,s=e.length,n=1):t===v.DOWN&&(i=e.length-1,s=-1,n=-1);for(let e=i;e!==s;e+=n){const i=this.keyProps[e],s=i.line;null===r?r=s:(o=Math.abs(r-s),0===o||.5===o?a=!a:(a=!1,this.use_default_head_x=!0)),r=s;const n=new R({duration:this.duration,note_type:this.noteType,displaced:a,stem_direction:t,custom_glyph_code:i.code,glyph_font_scale:this.render_options.glyph_font_scale,x_shift:i.shift_right,stem_up_x_offset:i.stem_up_x_offset,stem_down_x_offset:i.stem_down_x_offset,line:i.line});this.note_heads[e]=n}}autoStem(){this.minLine=this.keyProps[0].line,this.maxLine=this.keyProps[this.keyProps.length-1].line;const t=(this.minLine+this.maxLine)/2<3?v.UP:v.DOWN;this.setStemDirection(t)}calculateKeyProps(){let t=null;for(let e=0;e0&&(this.keyProps[e-1].displaced=!0)),t=o,this.keyProps.push(r)}t=-1/0,this.keyProps.forEach((e=>{e.linet.line-e.line))}getBoundingBox(){if(!this.preFormatted)throw new s.RERR("UnformattedNote","Can't call getBoundingBox on an unformatted note.");const{width:t,modLeftPx:e,extraLeftPx:i}=this.getMetrics(),n=this.getAbsoluteX()-e-i;let r=0,o=0;const a=this.getStave().getSpacingBetweenLines()/2,l=2*a;if(this.isRest()){const t=this.ys[0],e=m.durationToFraction(this.duration);e.equals(1)||e.equals(2)?(r=t-a,o=t+a):(r=t-this.glyph.line_above*l,o=t+this.glyph.line_below*l)}else if(this.glyph.stem){const t=this.getStemExtents();t.baseY+=a*this.stem_direction,r=Math.min(t.topY,t.baseY),o=Math.max(t.topY,t.baseY)}else{r=null,o=null;for(let t=0;te&&(e=s):s1}hasStem(){return this.glyph.stem}hasFlag(){return super.hasFlag()&&!this.isRest()&&this.renderFlag}getStemX(){return"r"===this.noteType?this.getCenterGlyphX():super.getStemX()+v.WIDTH/(2*-this.getStemDirection())}getYForTopText(t){const e=this.getStemExtents();return Math.min(this.stave.getYForTopText(t),e.topY-this.render_options.annotation_spacing*(t+1))}getYForBottomText(t){const e=this.getStemExtents();return Math.max(this.stave.getYForTopText(t),e.baseY+this.render_options.annotation_spacing*t)}setStave(t){super.setStave(t);const e=this.note_heads.map((e=>(e.setStave(t),e.getY())));if(this.setYs(e),this.stem){const{y_top:t,y_bottom:e}=this.getNoteHeadBounds();this.stem.setYBounds(t,e)}return this}getKeys(){return this.keys}getKeyProps(){return this.keyProps}isDisplaced(){return this.displaced}setNoteDisplaced(t){return this.displaced=t,this}getTieRightX(){let t=this.getAbsoluteX();return t+=this.getGlyphWidth()+this.x_shift+this.extraRightPx,this.modifierContext&&(t+=this.modifierContext.getExtraRightPx()),t}getTieLeftX(){let t=this.getAbsoluteX();return t+=this.x_shift-this.extraLeftPx,t}getLineForRest(){let t=this.keyProps[0].line;if(this.keyProps.length>1){const e=this.keyProps[this.keyProps.length-1].line,i=Math.max(t,e),n=Math.min(t,e);t=s.MidLine(i,n)}return t}getModifierStartXY(t,e,i){if(i=i||{},!this.preFormatted)throw new s.RERR("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");if(0===this.ys.length)throw new s.RERR("NoYValues","No Y-Values calculated for this note.");const{ABOVE:n,BELOW:r,LEFT:o,RIGHT:a}=B.Position;let l=0;return t===o?l=-2:t===a?(l=this.getGlyphWidth()+this.x_shift+2,this.stem_direction===v.UP&&this.hasFlag()&&(i.forceFlagRight||((t,e)=>e===(t.getStemDirection()===v.UP?t.keyProps.length-1:0))(this,e))&&(l+=this.flag.getMetrics().width)):t!==r&&t!==n||(l=this.getGlyphWidth()/2),{x:this.getAbsoluteX()+l,y:this.ys[e]}}setStyle(t){super.setStyle(t),this.note_heads.forEach((e=>e.setStyle(t))),this.stem&&this.stem.setStyle(t)}setStemStyle(t){this.stem&&this.getStem().setStyle(t)}getStemStyle(){return this.stem.getStyle()}setLedgerLineStyle(t){this.ledgerLineStyle=t}getLedgerLineStyle(){return this.ledgerLineStyle}setFlagStyle(t){this.flagStyle=t}getFlagStyle(){return this.flagStyle}setKeyStyle(t,e){return this.note_heads[t].setStyle(e),this}setKeyLine(t,e){return this.keyProps[t].line=e,this.reset(),this}getKeyLine(t){return this.keyProps[t].line}addToModifierContext(t){this.setModifierContext(t);for(let t=0;t{const u=c.getLine(),d=c.getY();(null===t||de)&&(e=d),null===s&&c.isDisplaced()&&(s=c.getAbsoluteX()),null!==i||c.isDisplaced()||(i=c.getAbsoluteX()),n=u>n?u:n,r=u{let a;a=s&&e?p-i:e?m-i:f-i;const l=e&&s?o:r;n.beginPath(),n.moveTo(a,t),n.lineTo(a+l,t),n.stroke()},g={...t.getStyle()||{},...this.getLedgerLineStyle()||{}};this.applyStyle(n,g);for(let e=6;e<=a;++e){const i=null!==m&&e<=c,s=null!==f&&e<=h;b(t.getYForNote(e),i,s)}for(let e=0;e>=l;--e){const i=null!==m&&e>=d,s=null!==f&&e>=u;b(t.getYForNote(e),i,s)}this.restoreStyle(n,g)}drawModifiers(){if(!this.context)throw new s.RERR("NoCanvasContext","Can't draw without a canvas context.");const t=this.context;t.openGroup("modifiers");for(let e=0;e{this.context.openGroup("notehead",null,{pointerBBox:!0}),t.setContext(this.context).draw(),this.context.closeGroup()}))}drawStem(t){if(!this.context)throw new s.RERR("NoCanvasContext","Can't draw without a canvas context.");t&&this.setStem(new v(t)),this.stem.id=s.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 s.RERR("NoCanvasContext","Can't draw without a canvas context.");if(!this.stave)throw new s.RERR("NoStave","Can't draw without a stave.");if(0===this.ys.length)throw new s.RERR("NoYValues","Can't draw note without Y values.");const t=this.getNoteHeadBeginX(),e=this.hasStem()&&!this.beam;if(this.note_heads.forEach((e=>e.setX(t))),this.stem){const t=this.getStemX();this.stem.setNoteHeadXBounds(t,t)}!function(...t){O.DEBUG&&s.L("Vex.Flow.StaveNote",t)}("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}),e&&this.drawStem(),this.drawNoteHeads(),this.drawFlag(),this.context.closeGroup(),this.drawModifiers(),this.context.closeGroup(),this.restoreStyle(),this.setRendered()}}class k extends B{static get CATEGORY(){return"frethandfinger"}static format(t,e){const{left_shift:i,right_shift:s}=e;if(!t||0===t.length)return!1;const n=[];let r=null,o=0,a=0;for(let e=0;ee.line-t.line));let l=0,h=0,c=0,u=0,d=null,f=null;for(let t=0;tc?e:c):o===B.Position.RIGHT&&(m.setXShift(h),e=a+S,u=e>u?e:u),d=p,f=r}return e.left_shift+=c,e.right_shift+=u,!0}constructor(t){super(),this.setAttribute("type","FretHandFinger"),this.note=null,this.index=null,this.finger=t,this.width=7,this.position=B.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 k.CATEGORY}setFretHandFinger(t){return this.finger=t,this}setOffsetX(t){return this.x_offset=t,this}setOffsetY(t){return this.y_offset=t,this}draw(){if(this.checkContext(),!this.note||null==this.index)throw new s.RERR("NoAttachedNote","Can't draw string number without a note and index.");this.setRendered();const t=this.context,e=this.note.getModifierStartXY(this.position,this.index);let i=e.x+this.x_shift+this.x_offset,n=e.y+this.y_shift+this.y_offset+5;switch(this.position){case B.Position.ABOVE:i-=4,n-=12;break;case B.Position.BELOW:i-=2,n+=10;break;case B.Position.LEFT:i-=this.width;break;case B.Position.RIGHT:i+=1;break;default:throw new s.RERR("InvalidPostion",`The position ${this.position} does not exist`)}t.save(),t.setFont(this.font.family,this.font.size,this.font.weight),t.fillText(""+this.finger,i,n),t.restore()}}class V{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:V.scales.major,m:V.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(t){return!(null==t||t<0||t>=V.NUM_TONES)}isValidIntervalValue(t){return this.isValidNoteValue(t)}getNoteParts(t){if(!t||t.length<1)throw new s.RERR("BadArguments","Invalid note name: "+t);if(t.length>3)throw new s.RERR("BadArguments","Invalid note name: "+t);const e=t.toLowerCase(),i=/^([cdefgab])(b|bb|n|#|##)?$/.exec(e);if(null!=i)return{root:i[1],accidental:i[2]};throw new s.RERR("BadArguments","Invalid note name: "+t)}getKeyParts(t){if(!t||t.length<1)throw new s.RERR("BadArguments","Invalid key: "+t);const e=t.toLowerCase(),i=/^([cdefgab])(b|#)?(mel|harm|m|M)?$/.exec(e);if(null!=i){const t=i[1],e=i[2];let s=i[3];return s||(s="M"),{root:t,accidental:e,type:s}}throw new s.RERR("BadArguments",`Invalid key: ${t}`)}getNoteValue(t){const e=V.noteValues[t];if(null==e)throw new s.RERR("BadArguments",`Invalid note name: ${t}`);return e.int_val}getIntervalValue(t){const e=V.intervals[t];if(null==e)throw new s.RERR("BadArguments",`Invalid interval name: ${t}`);return e}getCanonicalNoteName(t){if(!this.isValidNoteValue(t))throw new s.RERR("BadArguments",`Invalid note value: ${t}`);return V.canonical_notes[t]}getCanonicalIntervalName(t){if(!this.isValidIntervalValue(t))throw new s.RERR("BadArguments",`Invalid interval value: ${t}`);return V.diatonic_intervals[t]}getRelativeNoteValue(t,e,i){if(null==i&&(i=1),1!==i&&-1!==i)throw new s.RERR("BadArguments",`Invalid direction: ${i}`);let n=(t+i*e)%V.NUM_TONES;return n<0&&(n+=V.NUM_TONES),n}getRelativeNoteName(t,e){const i=this.getNoteParts(t),n=this.getNoteValue(i.root);let r=e-n;if(Math.abs(r)>V.NUM_TONES-3){let i=1;r>0&&(i=-1);const o=(e+1+(n+1))%V.NUM_TONES*i;if(Math.abs(o)>2)throw new s.RERR("BadArguments",`Notes not related: ${t}, ${e})`);r=o}if(Math.abs(r)>2)throw new s.RERR("BadArguments",`Notes not related: ${t}, ${e})`);let o=i.root;if(r>0)for(let t=1;t<=r;++t)o+="#";else if(r<0)for(let t=-1;t>=r;--t)o+="b";return o}getScaleTones(t,e){const i=[t];let s=t;for(let n=0;nt.getMetrics().width;class U extends B{static get CATEGORY(){return"accidentals"}static format(t,e){const i=e.left_shift+1;if(!t||0===t.length)return;const s=[];let n,r=null,o=0;for(let e=0;ee.line-t.line));const a=[];let l=0,h=null;for(let t=0;tl?e.shift:l,h=e.line}let c=0;for(let t=0;ta[i+t],r=t=>t.map(n),o=(t,e)=>{const[i,s]=r([t,e]).map((t=>t.line));return i-s},l=(...t)=>t.map(r).every((t=>!this.checkCollision(...t))),h=s-i+1;let u,d,f=this.checkCollision(a[i],a[s])?"a":"b";switch(h){case 3:"a"===f&&.5===o(1,2)&&.5!==o(0,1)&&(f="second_on_bottom");break;case 4:l([0,2],[1,3])&&(f="spaced_out_tetrachord");break;case 5:"b"===f&&l([1,3])&&(f="spaced_out_pentachord",l([0,2],[2,4])&&(f="very_spaced_out_pentachord"));break;case 6:l([0,3],[1,4],[2,5])&&(f="spaced_out_hexachord"),l([0,2],[2,4],[1,3],[3,5])&&(f="very_spaced_out_hexachord")}if(h>=7){let e=2,i=!0;for(;!0===i;){i=!1;for(let t=0;t+ed?c:d}else for(u=t;u<=s;u++)d=m.accidentalColumnsTable[h][f][u-t],a[u].column=d,c=c>d?c:d;t=s}const u=[],d=[];for(let t=0;t<=c;t++)u[t]=0,d[t]=0;u[0]=l+i,d[0]=l+i,a.forEach((t=>{t.width>u[t.column]&&(u[t.column]=t.width)}));for(let t=1;t{let e=0;const i=p+t.numAcc;for(;p0?(s=e.flatLine||e.dblSharpLine?2.5:3,t.dblSharpLine&&(i-=.5)):(s=t.flatLine||t.dblSharpLine?2.5:3,e.dblSharpLine&&(i-=.5));const n=Math.abs(i){const e=new n(0,1);t.getTickables().forEach((t=>{if(t.shouldIgnoreTicks())return;const n=s[e.value()];n?n.push(t):(i.push(e.value()),s[e.value()]=[t]),e.add(t.getTicks())}))}));const r=new V;e||(e="C");const o=r.createScaleMap(e);i.forEach((t=>{const e=s[t],i=[],n=t=>{t.isRest()||t.shouldIgnoreTicks()||(t.keys.forEach(((e,s)=>{const n=r.getNoteParts(e.split("/")[0]),a=n.accidental||"n",l=n.root+a,h=o[n.root]===l,c=i.indexOf(l)>-1;if(!h||h&&c){o[n.root]=l;const e=new U(a);t.addAccidental(s,e),i.push(l)}})),t.getModifiers().forEach((t=>{"gracenotegroups"===t.getCategory()&&t.getGraceNotes().forEach(n)})))};e.forEach(n)}))}constructor(t=null){if(super(),this.setAttribute("type","Accidental"),G("New accidental: ",t),this.note=null,this.index=null,this.type=t,this.position=B.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 s.RERR("ArgumentError",`Unknown accidental type: ${t}`);this.cautionary=!1,this.parenLeft=null,this.parenRight=null,this.reset()}reset(){const t=this.render_options.font_scale;this.glyph=new f(this.accidental.code,t),this.glyph.setOriginX(1),this.cautionary&&(this.parenLeft=new f(m.accidentalCodes("{").code,t),this.parenRight=new f(m.accidentalCodes("}").code,t),this.parenLeft.setOriginX(1),this.parenRight.setOriginX(1))}getCategory(){return U.CATEGORY}getWidth(){const t=this.cautionary?W(this.parenLeft)+W(this.parenRight)+this.render_options.parenLeftPadding+this.render_options.parenRightPadding:0;return W(this.glyph)+t}setNote(t){if(!t)throw new s.RERR("ArgumentError",`Bad note value: ${t}`);this.note=t,"gracenotes"===this.note.getCategory()&&(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:t,type:e,position:i,note:n,index:r,cautionary:o,x_shift:a,y_shift:l,glyph:h,parenLeft:c,parenRight:u,render_options:{parenLeftPadding:d,parenRightPadding:f}}=this;if(this.checkContext(),!n||null==r)throw new s.RERR("NoAttachedNote","Can't draw accidental without a note and index.");const m=n.getModifierStartXY(i,r);let p=m.x+a;const b=m.y+l;G("Rendering: ",e,p,b),o?(u.render(t,p,b),p-=W(u),p-=f,p-=this.accidental.parenRightPaddingAdjustment,h.render(t,p,b),p-=W(h),p-=d,c.render(t,p,b)):h.render(t,p,b),this.setRendered()}}class z extends B{static get CATEGORY(){return"notesubgroup"}static format(t,e){if(!t||0===t.length)return!1;let i=0;for(let e=0;e{t.ignore_ticks=!1})),this.width=0,this.preFormatted=!1,this.formatter=new ut,this.voice=new T({num_beats:4,beat_value:4,resolution:m.RESOLUTION}).setStrict(!1),this.voice.addTickables(this.subNotes),this}getCategory(){return z.CATEGORY}preFormat(){this.preFormatted||(this.formatter.joinVoices([this.voice]).format([this.voice],0),this.setWidth(this.formatter.getMinTotalWidth()),this.preFormatted=!0)}setNote(t){this.note=t}setWidth(t){this.width=t}getWidth(){return this.width}draw(){this.checkContext();const t=this.getNote();if(!t||null===this.index)throw new s.RuntimeError("NoAttachedNote","Can't draw notes without a parent note and parent note index.");this.setRendered(),this.alignSubNotesWithNote(this.subNotes,t),this.subNotes.forEach((t=>t.setContext(this.context).drawWithStyle()))}}class H extends l{constructor(t,e){super(),this.setAttribute("type","StaveTie"),this.notes=t,this.context=null,this.text=e,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(t)}setFont(t){return this.font=t,this}setDirection(t){return this.direction=t,this}setNotes(t){if(!t.first_note&&!t.last_note)throw new s.RuntimeError("BadArguments","Tie needs to have either first_note or last_note set.");if(t.first_indices||(t.first_indices=[0]),t.last_indices||(t.last_indices=[0]),t.first_indices.length!==t.last_indices.length)throw new s.RuntimeError("BadArguments","Tied notes must have similar index sizes");return this.first_note=t.first_note,this.first_indices=t.first_indices,this.last_note=t.last_note,this.last_indices=t.last_indices,this}isPartial(){return!this.first_note||!this.last_note}renderTie(t){if(0===t.first_ys.length||0===t.last_ys.length)throw new s.RERR("BadArguments","No Y-values to render");const e=this.context;let i=this.render_options.cp1,n=this.render_options.cp2;Math.abs(t.last_x_px-t.first_x_px)<10&&(i=2,n=8);const r=this.render_options.first_x_shift,o=this.render_options.last_x_shift,a=this.render_options.y_shift*t.direction;for(let l=0;l1){const e=new P(t);e.render_options.beam_width=3,e.render_options.partial_beam_length=4,this.beams.push(e)}return this}setNote(t){this.note=t}setWidth(t){this.width=t}getWidth(){return this.width}getGraceNotes(){return this.grace_notes}draw(){this.checkContext();const t=this.getNote();if(function(...t){j.DEBUG&&s.L("Vex.Flow.GraceNoteGroup",t)}("Drawing grace note group for:",t),!t||null===this.index)throw new s.RuntimeError("NoAttachedNote","Can't draw grace note without a parent note and parent note index.");if(this.setRendered(),this.alignSubNotesWithNote(this.getGraceNotes(),t),this.grace_notes.forEach((t=>{t.setContext(this.context).draw()})),this.beams.forEach((t=>{t.setContext(this.context).draw()})),this.show_slur){const e=this.getNote().getCategory()===O.CATEGORY,i=e?H:X;this.slur=new i({last_note:this.grace_notes[0],first_note:t,first_indices:[0],last_indices:[0]}),this.slur.render_options.cp2=12,this.slur.render_options.y_shift=(e?7:5)+this.render_options.slur_y_shift,this.slur.setContext(this.context).draw()}}}class Y extends B{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(t,e){const i=e.left_shift;if(!t||0===t.length)return this;const s=t.map((t=>{const e=t.getNote();if(e instanceof O){const{line:i,displaced:s}=e.getKeyProps()[t.getIndex()];return{line:i,shift:s?e.getExtraLeftPx():0,stroke:t}}{const{str:i}=e.getPositions()[t.getIndex()];return{line:i,shift:0,stroke:t}}})),n=i,r=s.reduce(((t,{stroke:e,shift:i})=>(e.setXShift(n+i),Math.max(e.getWidth()+0,t))),0);return e.left_shift+=r,!0}constructor(t,e){super(),this.setAttribute("type","Stroke"),this.note=null,this.options=s.Merge({},e),this.all_voices=!("all_voices"in this.options)||this.options.all_voices,this.note_end=null,this.index=null,this.type=t,this.position=B.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 Y.CATEGORY}getPosition(){return this.position}addEndNote(t){return this.note_end=t,this}draw(){if(this.checkContext(),this.setRendered(),!this.note||null==this.index)throw new s.RERR("NoAttachedNote","Can't draw stroke without a note and index.");const t=this.note.getModifierStartXY(this.position,this.index);let e=this.note.getYs(),i=t.y,n=t.y;const r=t.x-5,o=this.note.stave.options.spacing_between_lines_px,a=this.getModifierContext().getModifiers(this.note.getCategory());for(let t=0;te.line-t.line));let f=0,m=0,p=0,b=0,g=null,S=null;for(r=0;rp?t:p):l===B.Position.RIGHT&&(o.setXShift(m),t+=d,b=t>b?t:b),g=e,S=a}return e.left_shift+=p,e.right_shift+=b,!0}constructor(t){super(),this.setAttribute("type","StringNumber"),this.note=null,this.last_note=null,this.index=null,this.string_number=t,this.setWidth(20),this.position=B.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(t){return this.note=t,this}getIndex(){return this.index}setIndex(t){return this.index=t,this}setLineEndType(t){return t>=E.LineEndType.NONE&&t<=E.LineEndType.DOWN&&(this.leg=t),this}setStringNumber(t){return this.string_number=t,this}setOffsetX(t){return this.x_offset=t,this}setOffsetY(t){return this.y_offset=t,this}setLastNote(t){return this.last_note=t,this}setDashed(t){return this.dashed=t,this}draw(){const t=this.checkContext();if(!this.note||null==this.index)throw new s.RERR("NoAttachedNote","Can't draw string number without a note and index.");this.setRendered();const e=this.note.stave.options.spacing_between_lines_px,i=this.note.getModifierStartXY(this.position,this.index);let n=i.x+this.x_shift+this.x_offset,r=i.y+this.y_shift+this.y_offset;switch(this.position){case B.Position.ABOVE:case B.Position.BELOW:{const t=this.note.getStemExtents();let s=t.topY,n=t.baseY+2;this.note.stem_direction===O.STEM_DOWN&&(s=t.baseY,n=t.topY-2),r=this.position===B.Position.ABOVE?this.note.hasStem()?s-1.75*e:i.y-1.75*e:this.note.hasStem()?n+1.5*e:i.y+1.75*e,r+=this.y_shift+this.y_offset;break}case B.Position.LEFT:n-=this.radius/2+5;break;case B.Position.RIGHT:n+=this.radius/2+6;break;default:throw new s.RERR("InvalidPosition",`The position ${this.position} is invalid`)}t.save(),t.beginPath(),t.arc(n,r,this.radius,0,2*Math.PI,!1),t.lineWidth=1.5,t.stroke(),t.setFont(this.font.family,this.font.size,this.font.weight);const o=n-t.measureText(this.string_number).width/2;if(t.fillText(""+this.string_number,o,r+4.5),null!=this.last_note){const e=this.last_note.getStemX()-this.note.getX()+5;let i,s;switch(t.strokeStyle="#000000",t.lineCap="round",t.lineWidth=.6,this.dashed?E.drawDashedLine(t,n+10,r,n+e,r,[3,3]):E.drawDashedLine(t,n+10,r,n+e,r,[3,0]),this.leg){case E.LineEndType.UP:i=-10,s=this.dashed?[3,3]:[3,0],E.drawDashedLine(t,n+e,r,n+e,r+i,s);break;case E.LineEndType.DOWN:i=10,s=this.dashed?[3,3]:[3,0],E.drawDashedLine(t,n+e,r,n+e,r+i,s)}}t.restore()}}class q extends C{static getNextContext(t){const e=t.tContexts,i=e.indexOf(t);return e[i+1]}constructor(){super(),this.setAttribute("type","TickContext"),this.currentTick=new n(0,1),this.maxTicks=new n(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(t){return this.x=t,this.xBase=t,this.xOffset=0,this}getXBase(){return this.xBase}setXBase(t){this.xBase=t,this.x=t+this.xOffset}getXOffset(){return this.xOffset}setXOffset(t){this.xOffset=t,this.x=this.xBase+t}getWidth(){return this.width+2*this.padding}setPadding(t){return this.padding=t,this}getMaxTicks(){return this.maxTicks}getMinTicks(){return this.minTicks}getTickables(){return this.tickables}getCenterAlignedTickables(){return this.tickables.filter((t=>t.isCenterAligned()))}getMetrics(){const{width:t,notePx:e,extraLeftPx:i,extraRightPx:s}=this;return{width:t,notePx:e,extraLeftPx:i,extraRightPx:s}}getCurrentTick(){return this.currentTick}setCurrentTick(t){this.currentTick=t,this.preFormatted=!1}getExtraPx(){let t=0,e=0,i=0,s=0;for(let n=0;n.5*t(e/.5),Q=(t,e)=>e===$?t<=5:t>=1,tt=(t,e)=>Q(t,e)?e===$?Math.ceil:Math.floor:Math.round,et=t=>{const e=t.getCategory();return"stavenotes"===e||"gracenotes"===e};class it extends B{static get CATEGORY(){return"articulations"}static get INITIAL_OFFSET(){return-.5}static format(t,e){if(!t||0===t.length)return!1;const i=(t,e,i)=>Z(tt(e,i),t.glyph.getMetrics().height/10+.5);t.filter((t=>t.getPosition()===$)).forEach((t=>{t.setTextLine(e.top_text_line),e.top_text_line+=i(t,e.top_text_line,$)})),t.filter((t=>t.getPosition()===J)).forEach((t=>{t.setTextLine(e.text_line),e.text_line+=i(t,e.text_line,J)}));const s=t.map((t=>t.getWidth())).reduce(((t,e)=>Math.max(e,t)));return e.left_shift+=s/2,e.right_shift+=s/2,!0}static easyScoreHook({articulations:t},e,i){if(!t)return;const s={staccato:"a.",tenuto:"a-"};t.split(",").map((t=>t.trim().split("."))).map((([t,e])=>{const n={type:s[t]};return e&&(n.position=B.PositionString[e]),i.getFactory().Articulation(n)})).map((t=>e.addModifier(0,t)))}constructor(t){if(super(),this.setAttribute("type","Articulation"),this.note=null,this.index=null,this.type=t,this.position=J,this.render_options={font_scale:38},this.breathMarkDistance=.8,this.articulation=m.articulationCodes(this.type),"abr"===this.type&&(this.articulation={code:"v6c",between_lines:!1}),!this.articulation)throw new s.RERR("ArgumentError",`Articulation not found: ${this.type}`);this.glyph=new f(this.articulation.code,this.render_options.font_scale),this.setWidth(this.glyph.getMetrics().width)}getCategory(){return it.CATEGORY}draw(){const{note:t,index:e,position:i,glyph:n,articulation:{between_lines:r},text_line:o,context:a}=this;if(this.checkContext(),!t||null==e)throw new s.RERR("NoAttachedNote","Can't draw Articulation without a note and index.");this.setRendered();const l=t.getStave(),h=l.getSpacingBetweenLines(),c="tabnotes"===t.getCategory();let{x:u}=t.getModifierStartXY(i,e);if("abr"===this.type){let e=0;const i=t.getTickContext(),s=q.getNextContext(i),n=t.getTickContext().getX();if(s)e=(s.getX()-n)*this.breathMarkDistance;else{const i=t.getStave();e=(i.getX()+i.getWidth()-n)*this.breathMarkDistance}u+=e}const d=this.getXShift();d&&(u+=d);const f=!r||c,m=((t,e)=>{const i=e===$&&t.getStemDirection()===v.UP||e===J&&t.getStemDirection()===v.DOWN;return et(t)?t.hasStem()&&i?.5:1:t.hasStem()&&i?1:0})(t,i);let p={[$]:()=>{n.setOrigin(.5,1);const e=((t,e)=>{const i=t.getStave(),n=t.getStemDirection(),{topY:r,baseY:o}=t.getStemExtents();if(et(t))return t.hasStem()?n===v.UP?r:o:Math.min(...t.getYs());if("tabnotes"===t.getCategory())return t.hasStem()&&n===v.UP?r:i.getYForTopText(e);throw new s.RERR("UnknownCategory","Only can get the top and bottom ys of stavenotes and tabnotes")})(t,o)-(o+m)*h;return f?Math.min(l.getYForTopText(it.INITIAL_OFFSET),e):e},[J]:()=>{n.setOrigin(.5,0);const e=((t,e)=>{const i=t.getStave(),n=t.getStemDirection(),{topY:r,baseY:o}=t.getStemExtents();if(et(t))return t.hasStem()?n===v.UP?o:r:Math.max(...t.getYs());if("tabnotes"===t.getCategory())return t.hasStem()?n===v.UP?i.getYForBottomText(e):r:i.getYForBottomText(e);throw new s.RERR("UnknownCategory","Only can get the top and bottom ys of stavenotes and tabnotes")})(t,o)+(o+m)*h;return f?Math.max(l.getYForBottomText(it.INITIAL_OFFSET),e):e}}[i]();if(this.y_shift&&(p+=this.y_shift),!c){const s=i===$?-1:1,o=c?t.positions[e].str:t.getKeyProps()[e].line,a=(t.getYs()[e]-p)/h+o,l=((t,e,i,s)=>{const n=Z(tt(e,i),e);return t&&Q(n,i)&&n%1==0?n+.5*-s:n})(r,a,i,s);Q(l,i)&&n.setOrigin(.5,.5),p+=Math.abs(l-a)*h*s}!function(...t){it.DEBUG&&s.L("Vex.Flow.Articulation",t)}(`Rendering articulation at (x: ${u}, y: ${p})`),n.render(a,u,p)}}class st extends B{static get CATEGORY(){return"ornaments"}static format(t,e){if(!t||0===t.length)return!1;let i=0;for(let s=0;s0&&s--;for(let e=0;e{at("Preformatting ModifierContext: ",t.CATEGORY),t.format(this.getModifiers(t.CATEGORY),this.state,this)})),this.width=this.state.left_shift+this.state.right_shift,this.preFormatted=!0)}postFormat(){this.postFormatted||this.POSTFORMAT.forEach((t=>{at("Postformatting ModifierContext: ",t.CATEGORY),t.postFormat(this.getModifiers(t.CATEGORY),this)}))}}function ht(t,e,i,n){let r=e;for(i+=1;i{if(e.getMode()===T.Mode.STRICT&&!e.isComplete())throw new s.RERR("IncompleteVoice","Voice does not have enough notes.");return Math.max(t,n.LCM(t,e.getResolutionMultiplier()))}),1),o={},a=[],l=[];return t.forEach((t=>{const s=new n(0,r);t.getTickables().forEach((t=>{const n=s.numerator;if(!o[n]){const t=new e;l.push(t),o[n]=t}i(t,o[n]),a.push(n),s.add(t.getTicks())}))})),{map:o,array:l,list:s.SortAndUnique(a,((t,e)=>t-e),((t,e)=>t===e)),resolutionMultiplier:r}}class ut{static SimpleFormat(t,e=0,{paddingBetween:i=10}={}){t.reduce(((t,e)=>{e.addToModifierContext(new lt);const s=(new q).addTickable(e).preFormat(),n=s.getExtraPx();return s.setX(t+n.left),t+s.getWidth()+n.right+i}),e)}static plotDebugging(t,e,i,s,n){const r=i+I.STAVEPADDING,o=e.contextGaps;t.save(),t.setFont("Arial",8,""),o.gaps.forEach((e=>{var i,o,a;i=r+e.x1,o=r+e.x2,a="#aaa",t.beginPath(),t.setStrokeStyle(a),t.setFillStyle(a),t.setLineWidth(1),t.fillRect(i,s,o-i,n-s),t.fillText(Math.round(e.x2-e.x1),r+e.x1,n+12)})),t.fillText(Math.round(o.total)+"px",r-20,n+12),t.setFillStyle("red"),t.fillText("Loss: "+e.lossHistory.map((t=>Math.round(t))),r-20,n+22),t.restore()}static FormatAndDraw(t,e,i,n){const r={auto_beam:!1,align_rests:!1};"object"==typeof n?s.Merge(r,n):"boolean"==typeof n&&(r.auto_beam=n);const o=new T(m.TIME4_4).setMode(T.Mode.SOFT).addTickables(i),a=r.auto_beam?P.applyAndGetBeams(o):[];return(new ut).joinVoices([o],{align_rests:r.align_rests}).formatToStave([o],e,{align_rests:r.align_rests,stave:e}),o.setStave(e).draw(t,e),a.forEach((e=>e.setContext(t).draw())),o.getBoundingBox()}static FormatAndDrawTab(t,e,i,n,r,o,a){const l={auto_beam:o,align_rests:!1};"object"==typeof a?s.Merge(l,a):"boolean"==typeof a&&(l.auto_beam=a);const h=new T(m.TIME4_4).setMode(T.Mode.SOFT).addTickables(r),c=new T(m.TIME4_4).setMode(T.Mode.SOFT).addTickables(n),u=l.auto_beam?P.applyAndGetBeams(h):[];(new ut).joinVoices([h],{align_rests:l.align_rests}).joinVoices([c]).formatToStave([h,c],i,{align_rests:l.align_rests}),h.draw(t,i),c.draw(t,e),u.forEach((e=>e.setContext(t).draw())),new A(i,e).setContext(t).draw()}static AlignRestsToNotes(t,e,i){return t.forEach(((s,n)=>{if(s instanceof O&&s.isRest()){if(s.tuplet&&!i)return;const r=s.getGlyph().position.toUpperCase();if("R/4"!==r&&"B/4"!==r)return;if(e||null!=s.beam){const e=s.getKeyProps()[0];if(0===n)e.line=ht(t,e.line,n,!1),s.setKeyLine(0,e.line);else if(n>0&&nut.AlignRestsToNotes(t.getTickables(),e)))}preCalculateMinTotalWidth(t){if(this.hasMinTotalWidth)return this.minTotalWidth;if(!this.tickContexts){if(!t)throw new s.RERR("BadArgument","'voices' required to run preCalculateMinTotalWidth");this.createTickContexts(t)}const{list:e,map:i}=this.tickContexts;return this.minTotalWidth=e.map((t=>{const e=i[t];return e.preFormat(),e.getWidth()})).reduce(((t,e)=>t+e),0),this.hasMinTotalWidth=!0,this.minTotalWidth}getMinTotalWidth(){if(!this.hasMinTotalWidth)throw new s.RERR("NoMinTotalWidth","Call 'preCalculateMinTotalWidth' or 'preFormat' before calling 'getMinTotalWidth'");return this.minTotalWidth}createModifierContexts(t){const e=ct(t,lt,((t,e)=>t.addToModifierContext(e)));return this.modiferContexts=e,e}createTickContexts(t){const e=ct(t,q,((t,e)=>e.addTickable(t)));return e.array.forEach((t=>{t.tContexts=e.array})),this.totalTicks=t[0].getTicksUsed().clone(),this.tickContexts=e,e}preFormat(t=0,e,i,s){const n=this.tickContexts,{list:r,map:o,resolutionMultiplier:a}=n;i&&s&&i.forEach((t=>t.setStave(s).preFormat()));let l=0,h=0;const c=t/2;if(this.minTotalWidth=0,r.forEach((t=>{const i=o[t];e&&i.setContext(e),i.preFormat();const s=i.getWidth();this.minTotalWidth+=s;const n=i.getMetrics();l=l+h+n.extraLeftPx,i.setX(l),h=s-n.extraLeftPx})),this.minTotalWidth=l+h,this.hasMinTotalWidth=!0,t<=0)return;const u=(t-this.minTotalWidth)/(this.totalTicks.value()*a);let d=0;r.forEach(((t,e)=>{const i=r[e-1]||0,s=o[t];d+=(t-i)*u,s.setX(s.getX()+d),s.getCenterAlignedTickables().forEach((t=>{t.center_x_shift=c-s.getX()}))})),1!==r.length&&(this.justifyWidth=t,this.lossHistory=[],this.evaluate())}evaluate(){const t=this.justifyWidth;this.contextGaps={total:0,gaps:[]},this.tickContexts.list.forEach(((t,e)=>{if(0===e)return;const i=this.tickContexts.list[e-1],s=this.tickContexts.map[i],n=this.tickContexts.map[t],r=s.getMetrics(),o=s.getX()+r.width,a=n.getX(),l=a-o;this.contextGaps.total+=l,this.contextGaps.gaps.push({x1:o,x2:a}),n.getFormatterMetrics().freedom.left=l,s.getFormatterMetrics().freedom.right=l}));const e=this.durationStats={};this.voices.forEach((i=>{i.getTickables().forEach(((i,s,n)=>{const r=i.getTicks().clone().simplify().toString(),o=i.getMetrics(),a=i.getFormatterMetrics(),l=i.getX()+o.noteWidth+o.modRightPx+o.extraRightPx;let h=0;if(s{t.getTickables().forEach((t=>{const s=t.getTicks().clone().simplify().toString(),n=t.getFormatterMetrics();n.iterations+=1,n.space.deviation=n.space.used-e[s].mean,n.duration=s,n.space.mean=e[s].mean,i+=Math.pow(e[s].mean,2)}))})),this.totalCost=Math.sqrt(i),this.lossHistory.push(this.totalCost),this}tune(){let t=0;return this.tickContexts.list.forEach(((e,i,s)=>{const n=this.tickContexts.map[e],r=i>0?this.tickContexts.map[s[i-1]]:null,o=it.getFormatterMetrics().space.deviation)).reduce(((t,e)=>t+e));a>0?t=-Math.min(n.getFormatterMetrics().freedom.right,Math.abs(a)):a<0&&(t=o?Math.min(o.getFormatterMetrics().freedom.right,Math.abs(a)):0);const l=Math.min(5,Math.abs(t));t=t>0?l:-l})),this.evaluate()}postFormat(){const t=t=>t.list.forEach((e=>t.map[e].postFormat()));return t(this.modiferContexts),t(this.tickContexts),this}joinVoices(t){return this.createModifierContexts(t),this.hasMinTotalWidth=!1,this}format(t,e,i){const n={align_rests:!1,context:null,stave:null};return s.Merge(n,i),this.voices=t,this.alignRests(t,n.align_rests),this.createTickContexts(t),this.preFormat(e,n.context,t,n.stave),n.stave&&this.postFormat(),this}formatToStave(t,e,i){const n=e.getNoteEndX()-e.getNoteStartX()-10;!function(...t){ut.DEBUG&&s.L("Vex.Flow.Formatter",t)}("Formatting voices to width: ",n);const r={context:e.getContext()};return s.Merge(r,i),this.format(t,n,r)}}class dt extends l{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=dt.Position.ABOVE,this.layoutMetrics=null}getPosition(){return this.position}setPosition(t){return this.position=t,this}getStave(){return this.stave}setStave(t){return this.stave=t,this}getWidth(){return this.width}setWidth(t){return this.width=t,this}getX(){return this.x}setX(t){return this.x=t,this}getCategory(){return""}makeSpacer(t){return{getContext:()=>!0,setStave(){},renderToStave(){},getMetrics:()=>({width:t})}}placeGlyphOnLine(t,e,i){t.setYShift(e.getYForLine(i)-e.getYForGlyphs())}getPadding(t){return void 0!==t&&t<2?0:this.padding}setPadding(t){return this.padding=t,this}setLayoutMetrics(t){return this.layoutMetrics=t,this}getLayoutMetrics(){return this.layoutMetrics}}class ft extends dt{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}}static get typeString(){return{single:ft.type.SINGLE,double:ft.type.DOUBLE,end:ft.type.END,repeatBegin:ft.type.REPEAT_BEGIN,repeatEnd:ft.type.REPEAT_END,repeatBoth:ft.type.REPEAT_BOTH,none:ft.type.NONE}}constructor(t){super(),this.setAttribute("type","Barline"),this.thickness=m.STAVE_LINE_THICKNESS;const e=ft.type;this.widths={},this.widths[e.SINGLE]=5,this.widths[e.DOUBLE]=5,this.widths[e.END]=5,this.widths[e.REPEAT_BEGIN]=5,this.widths[e.REPEAT_END]=5,this.widths[e.REPEAT_BOTH]=5,this.widths[e.NONE]=5,this.paddings={},this.paddings[e.SINGLE]=0,this.paddings[e.DOUBLE]=0,this.paddings[e.END]=0,this.paddings[e.REPEAT_BEGIN]=15,this.paddings[e.REPEAT_END]=15,this.paddings[e.REPEAT_BOTH]=15,this.paddings[e.NONE]=0,this.layoutMetricsMap={},this.layoutMetricsMap[e.SINGLE]={xMin:0,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[e.DOUBLE]={xMin:-3,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[e.END]={xMin:-5,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[e.REPEAT_END]={xMin:-10,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[e.REPEAT_BEGIN]={xMin:-2,xMax:10,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[e.REPEAT_BOTH]={xMin:-10,xMax:10,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[e.NONE]={xMin:0,xMax:0,paddingLeft:5,paddingRight:5},this.setPosition(dt.Position.BEGIN),this.setType(t)}getCategory(){return ft.CATEGORY}getType(){return this.type}setType(t){return this.type="string"==typeof t?ft.typeString[t]:t,this.setWidth(this.widths[this.type]),this.setPadding(this.paddings[this.type]),this.setLayoutMetrics(this.layoutMetricsMap[this.type]),this}draw(t){switch(t.checkContext(),this.setRendered(),this.type){case ft.type.SINGLE:this.drawVerticalBar(t,this.x,!1);break;case ft.type.DOUBLE:this.drawVerticalBar(t,this.x,!0);break;case ft.type.END:this.drawVerticalEndBar(t,this.x);break;case ft.type.REPEAT_BEGIN:this.drawRepeatBar(t,this.x,!0),t.getX()!==this.x&&this.drawVerticalBar(t,t.getX());break;case ft.type.REPEAT_END:this.drawRepeatBar(t,this.x,!1);break;case ft.type.REPEAT_BOTH:this.drawRepeatBar(t,this.x,!1),this.drawRepeatBar(t,this.x,!0)}}drawVerticalBar(t,e,i){t.checkContext();const s=t.getTopLineTopY(),n=t.getBottomLineBottomY();i&&t.context.fillRect(e-3,s,1,n-s),t.context.fillRect(e,s,1,n-s)}drawVerticalEndBar(t,e){t.checkContext();const i=t.getTopLineTopY(),s=t.getBottomLineBottomY();t.context.fillRect(e-5,i,1,s-i),t.context.fillRect(e-2,i,3,s-i)}drawRepeatBar(t,e,i){t.checkContext();const s=t.getTopLineTopY(),n=t.getBottomLineBottomY();let r=3;i||(r=-5),t.context.fillRect(e+r,s,1,n-s),t.context.fillRect(e-2,s,3,n-s),i?r+=4:r-=4;const o=e+r+1;let a=(t.getNumLines()-1)*t.getSpacingBetweenLines();a=a/2-t.getSpacingBetweenLines()/2;let l=s+a+1;t.context.beginPath(),t.context.arc(o,l,2,0,2*Math.PI,!1),t.context.fill(),l+=t.getSpacingBetweenLines(),t.context.beginPath(),t.context.arc(o,l,2,0,2*Math.PI,!1),t.context.fill()}}class mt extends dt{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(t,e,i){super(),this.setAttribute("type","Repetition"),this.symbol_type=t,this.x=e,this.x_shift=0,this.y_shift=i,this.font={family:"times",size:12,weight:"bold italic"}}getCategory(){return mt.CATEGORY}setShiftX(t){return this.x_shift=t,this}setShiftY(t){return this.y_shift=t,this}setX(t){return this.x=t,this}draw(t,e){switch(this.setRendered(),this.symbol_type){case mt.type.CODA_RIGHT:this.drawCodaFixed(t,e+t.width);break;case mt.type.CODA_LEFT:this.drawSymbolText(t,e,"Coda",!0);break;case mt.type.SEGNO_LEFT:this.drawSignoFixed(t,e);break;case mt.type.SEGNO_RIGHT:this.drawSignoFixed(t,e+t.width);break;case mt.type.DC:this.drawSymbolText(t,e,"D.C.",!1);break;case mt.type.DC_AL_CODA:this.drawSymbolText(t,e,"D.C. al",!0);break;case mt.type.DC_AL_FINE:this.drawSymbolText(t,e,"D.C. al Fine",!1);break;case mt.type.DS:this.drawSymbolText(t,e,"D.S.",!1);break;case mt.type.DS_AL_CODA:this.drawSymbolText(t,e,"D.S. al",!0);break;case mt.type.DS_AL_FINE:this.drawSymbolText(t,e,"D.S. al Fine",!1);break;case mt.type.FINE:this.drawSymbolText(t,e,"Fine",!1);break;case mt.type.TO_CODA:this.drawSymbolText(t,e,"To",!0)}return this}drawCodaFixed(t,e){const i=t.getYForTopText(t.options.num_lines)+this.y_shift;return f.renderGlyph(t.context,this.x+e+this.x_shift,i+25,40,"v4d",!0),this}drawSignoFixed(t,e){const i=t.getYForTopText(t.options.num_lines)+this.y_shift;return f.renderGlyph(t.context,this.x+e+this.x_shift,i+25,30,"v8c",!0),this}drawSymbolText(t,e,i,s){const n=t.checkContext();n.save(),n.setFont(this.font.family,this.font.size,this.font.weight);let r=0+this.x_shift,o=e+this.x_shift;if(this.symbol_type===mt.type.CODA_LEFT?(r=this.x+this.x_shift,o=r+n.measureText(i).width+12):(this.x_shift=-(r+n.measureText(i).width+12+t.options.vertical_bar_width+12),r=this.x+this.x_shift+t.options.vertical_bar_width,o=r+n.measureText(i).width+12),this.xShiftAsPercentOfStaveWidth){const e=t.width*this.xShiftAsPercentOfStaveWidth;this.symbol_type!==mt.type.DC_AL_FINE&&this.symbol_type!==mt.type.FINE&&this.symbol_type!==mt.type.DC&&this.symbol_type!==mt.type.DS_AL_FINE&&this.symbol_type!==mt.type.DS&&this.symbol_type!==mt.type.FINE||(r+=e)}const a=t.getYForTopText(t.options.num_lines)+this.y_shift+25;return s&&f.renderGlyph(n,o,a,40,"v4d",!0),n.fillText(i,r,a+5),n.restore(),this}}class pt extends dt{static get CATEGORY(){return"stavesection"}constructor(t,e,i){super(),this.setAttribute("type","StaveSection"),this.setWidth(16),this.section=t,this.x=e,this.shift_x=0,this.shift_y=i,this.font={family:"sans-serif",size:12,weight:"bold"}}getCategory(){return pt.CATEGORY}setStaveSection(t){return this.section=t,this}setShiftX(t){return this.shift_x=t,this}setShiftY(t){return this.shift_y=t,this}draw(t,e){const i=t.checkContext();this.setRendered(),i.save(),i.lineWidth=2,i.setFont(this.font.family,this.font.size,this.font.weight);const s=i.measureText(""+this.section),n=s.width;let r=s.height;!r&&s.emHeightAscent>=0&&(r=s.emHeightAscent+2),r||(r=s.fontBoundingBoxAscent+3);let o=n+6;o<18&&(o=18);const a=r+this.font.size/10,l=t.getYForTopText(3)+19-1.15*a+this.shift_y;let h=this.x+e;return i.beginPath(),i.lineWidth=2,i.rect(h,l+r/4,o,a),i.stroke(),h+=(o-n)/2,i.fillText(""+this.section,h,l+a),i.restore(),this}}class bt extends dt{static get CATEGORY(){return"stavetempo"}constructor(t,e,i){super(),this.setAttribute("type","StaveTempo"),this.tempo=t,this.position=B.Position.ABOVE,this.x=e,this.shift_x=10,this.shift_y=i,this.font={family:"times",size:14,weight:"bold"},this.render_options={glyph_font_scale:30}}getCategory(){return bt.CATEGORY}setTempo(t){return this.tempo=t,this}setShiftX(t){return this.shift_x=t,this}setShiftY(t){return this.shift_y=t,this}draw(t,e){const i=t.checkContext();this.setRendered();const s=this.render_options,n=s.glyph_font_scale/38,r=this.tempo.name,o=this.tempo.duration,a=this.tempo.dots,l=this.tempo.bpm,h=this.font;let c=this.x+this.shift_x+e;const u=t.getYForTopText(1)+this.shift_y;if(i.save(),r&&(i.setFont(h.family,h.size,h.weight),i.fillText(r,c,u),c+=i.measureText(r).width),o&&l){i.setFont(h.family,h.size,"normal"),r&&(c+=i.measureText(" ").width,i.fillText("(",c,u),c+=i.measureText("(").width);const t=m.getGlyphProps(o);if(c+=3*n,f.renderGlyph(i,c,u,s.glyph_font_scale,t.code_head),c+=t.getWidth()*n,t.stem){let e=30;t.beam_count&&(e+=3*(t.beam_count-1)),e*=n;const r=u-e;i.fillRect(c-n,r,n,e),t.flag&&(f.renderGlyph(i,c,r,s.glyph_font_scale,t.code_flag_upstem),a||(c+=6*n))}for(let t=0;t=t.line?i.above:i.below)}this.placeGlyphOnLine(s,this.stave,t.line),this.glyphs.push(s);const r=this.xPositions[this.xPositions.length-1],o=s.getMetrics().width+n;this.xPositions.push(r+o),this.width+=o}cancelKey(t){return this.formatted=!1,this.cancelKeySpec=t,this}convertToCancelAccList(t){const e=m.keySignature(t),i=this.accList.length>0&&e.length>0&&e[0].type!==this.accList[0].type,s=i?e.length:e.length-this.accList.length;if(s<1)return;const n=[];for(let t=0;t0?t[0].type:null;let i;if(this.cancelKeySpec&&(i=this.convertToCancelAccList(this.cancelKeySpec)),this.alterKeySpec&&this.convertToAlterAccList(this.alterKeySpec),this.accList.length>0){const s=(this.position===dt.Position.END?this.stave.endClef:this.stave.clef)||this.stave.clef;i&&this.convertAccLines(s,i.type,i.accList),this.convertAccLines(s,e,t);for(let t=0;t0){this.stave.context.openGroup("keysignature");for(let t=0;t{const e=t.split("/").filter((t=>""!==t));if(2!==e.length)throw new s.RERR("BadTimeSignature",`Invalid time spec: ${t}. Must be in the form "/"`);e.forEach((e=>{if(isNaN(Number(e)))throw new s.RERR("BadTimeSignature",`Invalid time spec: ${t}. Must contain two valid numbers.`)}))})(t);const[e,i]=t.split("/").map((t=>t.split("")));return{num:!0,glyph:this.makeTimeSignatureGlyph(e,i)}}makeTimeSignatureGlyph(t,e){const i=new f("v0",this.point);i.topGlyphs=[],i.botGlyphs=[];let s=0;for(let e=0;en?s:n,o=i.getMetrics().x_min;i.getMetrics=()=>({x_min:o,x_max:o+r,width:r});const a=(r-s)/2,l=(r-n)/2,h=this;return i.renderToStave=function(t){let e=t+a;for(let t=0;ti.getWidth()&&(e-=i.getWidth()),e}setRepetitionTypeLeft(t,e){return this.modifiers.push(new mt(t,this.x,e)),this}setRepetitionTypeRight(t,e){return this.modifiers.push(new mt(t,this.x,e)),this}setVoltaType(t,e,i){return this.modifiers.push(new xt(t,e,this.x,i)),this}setSection(t,e,i=0,s=12){const n=new pt(t,this.x+i,e);return n.font.size=s,this.modifiers.push(n),this}setTempo(t,e){return this.modifiers.push(new bt(t,this.x,e)),this}setText(t,e,i){return this.modifiers.push(new St(t,e,i)),this}getHeight(){return this.height}getSpacingBetweenLines(){return this.options.spacing_between_lines_px}getBoundingBox(){return new c(this.x,this.y,this.width,this.getBottomY()-this.y)}getBottomY(){const t=this.options,e=t.spacing_between_lines_px;return this.getYForLine(t.num_lines)+t.space_below_staff_ln*e}getBottomLineY(){return this.getYForLine(this.options.num_lines)}getYForLine(t){const e=this.options,i=e.spacing_between_lines_px,s=e.space_above_staff_ln;return this.y+t*i+s*i}getLineForY(t){const e=this.options,i=e.spacing_between_lines_px,s=e.space_above_staff_ln;return(t-this.y)/i-s}getYForTopText(t){const e=t||0;return this.getYForLine(-e-this.options.top_text_position)}getYForBottomText(t){const e=t||0;return this.getYForLine(this.options.bottom_text_position+e)}getYForNote(t){const e=this.options,i=e.spacing_between_lines_px,s=e.space_above_staff_ln;return this.y+s*i+5*i-t*i}getYForGlyphs(){return this.getYForLine(3)}addModifier(t,e){return void 0!==e&&t.setPosition(e),t.setStave(this),this.formatted=!1,this.modifiers.push(t),this}addEndModifier(t){return this.addModifier(t,dt.Position.END),this}setBegBarType(t){const{SINGLE:e,REPEAT_BEGIN:i,NONE:s}=ft.type;return t!==e&&t!==i&&t!==s||(this.modifiers[0].setType(t),this.formatted=!1),this}setEndBarType(t){return t!==ft.type.REPEAT_BEGIN&&(this.modifiers[1].setType(t),this.formatted=!1),this}setClef(t,e,i,s){void 0===s&&(s=dt.Position.BEGIN),s===dt.Position.END?this.endClef=t:this.clef=t;const n=this.getModifiers(s,yt.CATEGORY);return 0===n.length?this.addClef(t,e,i,s):n[0].setType(t,e,i),this}setEndClef(t,e,i){return this.setClef(t,e,i,dt.Position.END),this}setKeySignature(t,e,i){void 0===i&&(i=dt.Position.BEGIN);const s=this.getModifiers(i,Et.CATEGORY);return 0===s.length?this.addKeySignature(t,e,i):s[0].setKeySig(t,e),this}setEndKeySignature(t,e){return this.setKeySignature(t,e,dt.Position.END),this}setTimeSignature(t,e,i){void 0===i&&(i=dt.Position.BEGIN);const s=this.getModifiers(i,vt.CATEGORY);return 0===s.length?this.addTimeSignature(t,e,i):s[0].setTimeSig(t),this}setEndTimeSignature(t,e){return this.setTimeSignature(t,e,dt.Position.END),this}addKeySignature(t,e,i){return void 0===i&&(i=dt.Position.BEGIN),this.addModifier(new Et(t,e).setPosition(i),i),this}addClef(t,e,i,s){return void 0===s||s===dt.Position.BEGIN?this.clef=t:s===dt.Position.END&&(this.endClef=t),this.addModifier(new yt(t,e,i),s),this}addEndClef(t,e,i){return this.addClef(t,e,i,dt.Position.END),this}addTimeSignature(t,e,i){return this.addModifier(new vt(t,e),i),this}addEndTimeSignature(t,e){return this.addTimeSignature(t,e,dt.Position.END),this}addTrebleGlyph(){return this.addClef("treble"),this}getModifiers(t,e){return void 0===t&&void 0===e?this.modifiers:this.modifiers.filter((i=>!(void 0!==t&&t!==i.getPosition()||void 0!==e&&e!==i.getCategory())))}sortByCategory(t,e){for(let i=t.length-1;i>=0;i--)for(let s=0;se[t[s+1].getCategory()]){const e=t[s];t[s]=t[s+1],t[s+1]=e}}format(){const t=this.modifiers[0],e=this.modifiers[1],i=this.getModifiers(dt.Position.BEGIN),s=this.getModifiers(dt.Position.END);let n,r,o;this.sortByCategory(i,{barlines:0,clefs:1,keysignatures:2,timesignatures:3}),this.sortByCategory(s,{timesignatures:0,keysignatures:1,barlines:2,clefs:3}),i.length>1&&t.getType()===ft.type.REPEAT_BEGIN&&(i.push(i.splice(0,1)[0]),i.splice(0,0,new ft(ft.type.SINGLE))),s.indexOf(e)>0&&s.splice(0,0,new ft(ft.type.NONE));let a=0,l=this.x;for(let t=0;t0){this.context.save(),this.context.setFont(this.font.family,this.font.size,this.font.weight);const t=this.context.measureText(""+this.measure).width;s=this.getYForTopText(0)+3,this.context.fillText(""+this.measure,this.x-t/2,s),this.context.restore()}return this}drawVertical(t,e){this.drawVerticalFixed(this.x+t,e)}drawVerticalFixed(t,e){this.checkContext();const i=this.getYForLine(0),s=this.getYForLine(this.options.num_lines-1);e&&this.context.fillRect(t-3,i,1,s-i+1),this.context.fillRect(t,i,1,s-i+1)}drawVerticalBar(t){this.drawVerticalBarFixed(this.x+t,!1)}drawVerticalBarFixed(t){this.checkContext();const e=this.getYForLine(0),i=this.getYForLine(this.options.num_lines-1);this.context.fillRect(t,e,1,i-e+1)}getConfigForLines(){return this.options.line_config}setConfigForLine(t,e){if(t>=this.options.num_lines||t<0)throw new s.RERR("StaveConfigError","The line number must be within the range of the number of lines in the Stave.");if(void 0===e.visible)throw new s.RERR("StaveConfigError","The line configuration object is missing the 'visible' property.");if("boolean"!=typeof e.visible)throw new s.RERR("StaveConfigError","The line configuration objects 'visible' property must be true or false.");return this.options.line_config[t]=e,this}setConfigForLines(t){if(t.length!==this.options.num_lines)throw new s.RERR("StaveConfigError","The length of the lines configuration array must match the number of lines in the Stave");for(const e in t)t[e]||(t[e]=this.options.line_config[e]),s.Merge(this.options.line_config[e],t[e]);return this.options.line_config=t,this}}class Mt extends _t{constructor(t,e,i,n){const r={spacing_between_lines_px:13,num_lines:6,top_text_position:1};s.Merge(r,n),super(t,e,i,r),this.setAttribute("type","TabStave")}getYForGlyphs(){return this.getYForLine(2.5)}addTabGlyph(){return this.addClef("tab"),this}}class wt extends N{static get CATEGORY(){return"tabnotes"}constructor(t,e){if(super(t),this.setAttribute("type","TabNote"),this.ghost=!1,this.positions=t.positions,s.Merge(this.render_options,{glyph_font_scale:m.DEFAULT_TABLATURE_FONT_SCALE,draw_stem:e,draw_dots:e,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 s.RuntimeError("BadArguments",`Invalid note initialization data (No glyph found): ${JSON.stringify(t)}`);this.buildStem(),t.stem_direction?this.setStemDirection(t.stem_direction):this.setStemDirection(v.UP),this.ghost=!1,this.updateWidth()}reset(){this.stave&&this.setStave(this.stave)}getCategory(){return wt.CATEGORY}setGhost(t){return this.ghost=t,this.updateWidth(),this}hasStem(){return this.render_options.draw_stem}getStemExtension(){const t=this.getGlyph();return null!=this.stem_extension_override?this.stem_extension_override:t?1===this.getStemDirection()?t.tabnote_stem_up_extension:t.tabnote_stem_down_extension:0}addDot(){const t=new F;return this.dots+=1,this.addModifier(t,0)}updateWidth(){this.glyphs=[],this.width=0;for(let t=0;tthis.width}setStave(t){let e;if(super.setStave(t),this.context=t.context,this.context){const t=this.context;for(this.width=0,e=0;ei.width),this.width=Math.max(i.getWidth(),this.width)}this.glyph.getWidth=()=>this.width}const i=this.positions.map((({str:e})=>t.getYForLine(e-1)));return this.setYs(i),this.stem&&this.stem.setYBounds(this.getStemY(),this.getStemY()),this}getPositions(){return this.positions}addToModifierContext(t){this.setModifierContext(t);for(let t=0;t{("dots"!==t.getCategory()||this.render_options.draw_dots)&&(t.setContext(this.context),t.drawWithStyle())}))}drawStemThrough(){const t=this.getStemX(),e=this.getStemY(),i=this.context,s=this.render_options.draw_stem_through_stave;if(this.render_options.draw_stem&&s){const s=function(t,e){const i=[];let s=[];for(let n=1;n<=t;n++)e.indexOf(n)>-1?(i.push(s),s=[]):s.push(n);return s.length>0&&i.push(s),i}(this.stave.getNumLines(),this.positions.map((t=>t.str))),n=function(t,e,i,s){const n=1!==s,r=-1!==s,o=i.getSpacingBetweenLines(),a=i.getNumLines(),l=[];return e.forEach((e=>{const h=e.indexOf(a)>-1,c=e.indexOf(1)>-1;if(n&&c||r&&h)return;1===e.length&&e.push(e[0]);const u=[];e.forEach(((e,n,r)=>{const l=1===e,h=e===a;let c=i.getYForLine(e-1);0!==n||l?n!==r.length-1||h||(c+=o/2-1):c-=o/2-1,u.push(c),1===s&&l?u.push(t-2):-1===s&&h&&u.push(t+2)})),l.push(u.sort(((t,e)=>t-e)))})),l}(e,s,this.getStave(),this.getStemDirection());i.save(),i.setLineWidth(v.WIDTH),n.forEach((e=>{0!==e.length&&(i.beginPath(),i.moveTo(t,e[0]),i.lineTo(t,e[e.length-1]),i.stroke(),i.closePath())})),i.restore()}}drawPositions(){const t=this.context,e=this.getAbsoluteX(),i=this.ys;for(let s=0;sparseInt(s,10)?Nt.SLIDE_DOWN:Nt.SLIDE_UP}this.slide_direction=e,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(t)}renderTie(t){if(0===t.first_ys.length||0===t.last_ys.length)throw new s.RERR("BadArguments","No Y-values to render");const e=this.context,i=t.first_x_px,n=t.first_ys,r=t.last_x_px,o=this.slide_direction;if(o!==Nt.SLIDE_UP&&o!==Nt.SLIDE_DOWN)throw new s.RERR("BadSlide","Invalid slide direction");for(let t=0;tthis.numStrings)throw new s.RERR("BadArguments",`String number must be between 1 and ${this.numStrings}:${t}`);return this.tuningValues[e-1]}getValueForFret(t,e){const i=this.getValueForString(e),n=parseInt(t,10);if(n<0)throw new s.RERR("BadArguments","Fret number must be 0 or higher: "+t);return i+n}getNoteForFret(t,e){const i=this.getValueForFret(t,e),s=Math.floor(i/12),n=i%12;return m.integerToNote(n)+"/"+s}}class Ot extends l{static get type(){return{CRESC:1,DECRESC:2}}static FormatByTicksAndDraw(t,e,i,n,r,o){const a=e.pixelsPerTick;if(null==a)throw new s.RuntimeError("BadArguments","A valid Formatter must be provide to draw offsets by ticks.");const l=a*o.left_shift_ticks,h=a*o.right_shift_ticks,c={height:o.height,y_shift:o.y_shift,left_shift_px:l,right_shift_px:h};new Ot({first_note:i.first_note,last_note:i.last_note},n).setContext(t).setRenderOptions(c).setPosition(r).draw()}constructor(t,e){super(),this.setAttribute("type","StaveHairpin"),this.notes=t,this.hairpin=e,this.position=B.Position.BELOW,this.render_options={height:10,y_shift:0,left_shift_px:0,right_shift_px:0},this.setNotes(t)}setPosition(t){return t!==B.Position.ABOVE&&t!==B.Position.BELOW||(this.position=t),this}setRenderOptions(t){return null!=t.height&&null!=t.y_shift&&null!=t.left_shift_px&&null!=t.right_shift_px&&(this.render_options=t),this}setNotes(t){if(!t.first_note&&!t.last_note)throw new s.RuntimeError("BadArguments","Hairpin needs to have either first_note or last_note set.");return this.first_note=t.first_note,this.last_note=t.last_note,this}renderHairpin(t){const e=this.checkContext();let i=this.render_options.y_shift+20,s=t.first_y;this.position===B.Position.ABOVE&&(i=30-i,s=t.first_y-t.staff_height);const n=this.render_options.left_shift_px,r=this.render_options.right_shift_px;switch(e.beginPath(),this.hairpin){case Ot.type.CRESC:e.moveTo(t.last_x+r,s+i),e.lineTo(t.first_x+n,s+this.render_options.height/2+i),e.lineTo(t.last_x+r,s+this.render_options.height+i);break;case Ot.type.DECRESC:e.moveTo(t.first_x+n,s+i),e.lineTo(t.last_x+r,s+this.render_options.height/2+i),e.lineTo(t.first_x+n,s+this.render_options.height+i)}e.stroke(),e.closePath()}draw(){this.checkContext(),this.setRendered();const t=this.first_note,e=this.last_note,i=t.getModifierStartXY(this.position,0),s=e.getModifierStartXY(this.position,0);return this.renderHairpin({first_x:i.x,last_x:s.x,first_y:t.getStave().y+t.getStave().height,last_y:e.getStave().y+e.getStave().height,staff_height:t.getStave().height}),!0}}class kt extends l{static get Position(){return{NEAR_HEAD:1,NEAR_TOP:2}}static get PositionString(){return{nearHead:kt.Position.NEAR_HEAD,nearTop:kt.Position.NEAR_TOP}}constructor(t,e,i){super(),this.setAttribute("type","Curve"),this.render_options={spacing:2,thickness:2,x_shift:0,y_shift:10,position:kt.Position.NEAR_HEAD,position_end:kt.Position.NEAR_HEAD,invert:!1,cps:[{x:0,y:10},{x:0,y:10}]},s.Merge(this.render_options,i),this.setNotes(t,e)}setNotes(t,e){if(!t&&!e)throw new s.RuntimeError("BadArguments","Curve needs to have either first_note or last_note set.");return this.from=t,this.to=e,this}isPartial(){return!this.from||!this.to}renderCurve(t){const e=this.context,i=this.render_options.cps,s=this.render_options.x_shift,n=this.render_options.y_shift*t.direction,r=t.first_x+s,o=t.first_y+n,a=t.last_x-s,l=t.last_y+n,h=this.render_options.thickness,c=(a-r)/(i.length+2);e.beginPath(),e.moveTo(r,o),e.bezierCurveTo(r+c+i[0].x,o+i[0].y*t.direction,a-c+i[1].x,l+i[1].y*t.direction,a,l),e.bezierCurveTo(a-c+i[1].x,l+(i[1].y+h)*t.direction,r+c+i[0].x,o+(i[0].y+h)*t.direction,r,o),e.stroke(),e.closePath(),e.fill()}draw(){this.checkContext(),this.setRendered();const t=this.from,e=this.to;let i,s,n,r,o,a="baseY",l="baseY";function h(t){return"string"==typeof t?kt.PositionString[t]:t}const c=h(this.render_options.position),u=h(this.render_options.position_end);return c===kt.Position.NEAR_TOP&&(a="topY",l="topY"),u===kt.Position.NEAR_HEAD?l="baseY":u===kt.Position.NEAR_TOP&&(l="topY"),t?(i=t.getTieRightX(),o=t.getStemDirection(),n=t.getStemExtents()[a]):(i=e.getStave().getTieStartX(),n=e.getStemExtents()[a]),e?(s=e.getTieLeftX(),o=e.getStemDirection(),r=e.getStemExtents()[l]):(s=t.getStave().getTieEndX(),r=t.getStemExtents()[l]),this.renderCurve({first_x:i,last_x:s,first_y:n,last_y:r,direction:o*(!0===this.render_options.invert?-1:1)}),!0}}function Vt(...t){Gt.DEBUG&&s.L("Vex.Flow.TextDynamics",t)}class Gt extends I{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(t){super(t),this.setAttribute("type","TextDynamics"),this.sequence=t.text.toLowerCase(),this.line=t.line||0,this.glyphs=[],s.Merge(this.render_options,{glyph_font_size:40}),Vt("New Dynamics Text: ",this.sequence)}setLine(t){return this.line=t,this}preFormat(){let t=0;return this.sequence.split("").forEach((e=>{const i=Gt.GLYPHS[e];if(!i)throw new s.RERR("Invalid dynamics character: "+e);const n=this.render_options.glyph_font_size,r=new f(i.code,n);this.glyphs.push(r),t+=i.width})),this.setWidth(t),this.preFormatted=!0,this}draw(){this.setRendered();const t=this.getAbsoluteX(),e=this.stave.getYForLine(this.line+-3);Vt("Rendering Dynamics: ",this.sequence);let i=t;this.glyphs.forEach(((t,s)=>{const n=this.sequence[s];t.render(this.context,i,e),i+=Gt.GLYPHS[n].width}))}}function Wt(t,e,i,s,n,r,o){t.beginPath(),t.moveTo(e,i),t.lineTo(s,n),t.lineTo(r,o),t.lineTo(e,i),t.closePath(),t.fill()}class Ut extends l{static get TextVerticalPosition(){return{TOP:1,BOTTOM:2}}static get TextJustification(){return{LEFT:1,CENTER:2,RIGHT:3}}constructor(t){super(),this.setAttribute("type","StaveLine"),this.notes=t,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:Ut.TextVerticalPosition.TOP,text_justification:Ut.TextJustification.CENTER},this.setNotes(t)}setFont(t){return this.font=t,this}setText(t){return this.text=t,this}setNotes(t){if(!t.first_note&&!t.last_note)throw new s.RuntimeError("BadArguments","Notes needs to have either first_note or last_note set.");if(t.first_indices||(t.first_indices=[0]),t.last_indices||(t.last_indices=[0]),t.first_indices.length!==t.last_indices.length)throw new s.RuntimeError("BadArguments","Connected notes must have similar index sizes");return this.first_note=t.first_note,this.first_indices=t.first_indices,this.last_note=t.last_note,this.last_indices=t.last_indices,this}applyLineStyle(){const t=this.checkContext(),e=this.render_options;e.line_dash&&t.setLineDash(e.line_dash),e.line_width&&t.setLineWidth(e.line_width),e.rounded_end?t.setLineCap("round"):t.setLineCap("square")}applyFontStyle(){const t=this.checkContext();this.font&&t.setFont(this.font.family,this.font.size,this.font.weight),this.render_options.color&&(t.setStrokeStyle(this.render_options.color),t.setFillStyle(this.render_options.color))}draw(){const t=this.checkContext();this.setRendered();const e=this.first_note,i=this.last_note,s=this.render_options;let n,r;t.save(),this.applyLineStyle(),this.first_indices.forEach(((o,a)=>{const l=this.last_indices[a];n=e.getModifierStartXY(2,o),r=i.getModifierStartXY(1,l);const h=n.y>r.y;n.x+=e.getMetrics().modRightPx+s.padding_left,r.x-=i.getMetrics().modLeftPx+s.padding_right;const c=e.getGlyph().getWidth();e.getKeyProps()[o].displaced&&1===e.getStemDirection()&&(n.x+=c+s.padding_left),i.getKeyProps()[l].displaced&&-1===i.getStemDirection()&&(r.x-=c+s.padding_right),n.y+=h?-3:1,r.y+=h?2:0,function(t,e,i,s){const n=s.draw_start_arrow&&s.draw_end_arrow,r=e.x,o=e.y,a=i.x,l=i.y,h=Math.sqrt((a-r)*(a-r)+(l-o)*(l-o)),c=(h-s.arrowhead_length/3)/h;let u,d,f,m;s.draw_end_arrow||n?(u=Math.round(r+(a-r)*c),d=Math.round(o+(l-o)*c)):(u=a,d=l),s.draw_start_arrow||n?(f=r+(a-r)*(1-c),m=o+(l-o)*(1-c)):(f=r,m=o),s.color&&(t.setStrokeStyle(s.color),t.setFillStyle(s.color)),t.beginPath(),t.moveTo(f,m),t.lineTo(u,d),t.stroke(),t.closePath();const p=Math.atan2(l-o,a-r),b=Math.abs(s.arrowhead_length/Math.cos(s.arrowhead_angle));let g,S,y,E,v,x;(s.draw_end_arrow||n)&&(g=p+Math.PI+s.arrowhead_angle,y=a+Math.cos(g)*b,E=l+Math.sin(g)*b,S=p+Math.PI-s.arrowhead_angle,v=a+Math.cos(S)*b,x=l+Math.sin(S)*b,Wt(t,y,E,a,l,v,x)),(s.draw_start_arrow||n)&&(g=p+s.arrowhead_angle,y=r+Math.cos(g)*b,E=o+Math.sin(g)*b,S=p-s.arrowhead_angle,v=r+Math.cos(S)*b,x=o+Math.sin(S)*b,Wt(t,y,E,r,o,v,x))}(t,n,r,this.render_options)})),t.restore();const o=t.measureText(this.text).width,a=s.text_justification;let l,h=0;a===Ut.TextJustification.LEFT?h=n.x:a===Ut.TextJustification.CENTER?h=(r.x-n.x)/2+n.x-o/2:a===Ut.TextJustification.RIGHT&&(h=r.x-o);const c=s.text_position_vertical;return c===Ut.TextVerticalPosition.TOP?l=e.getStave().getYForTopText():c===Ut.TextVerticalPosition.BOTTOM&&(l=e.getStave().getYForBottomText(m.TEXT_HEIGHT_OFFSET_HACK)),t.save(),this.applyFontStyle(),t.fillText(this.text,h,l),t.restore(),this}}function zt(t,e,i,s,n){const r=Ht.GLYPHS[t];new f(r.code,n).render(e,i+r.x_shift,s+r.y_shift)}class Ht extends l{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:Ht.Styles.TEXT,bracket:Ht.Styles.BRACKET,mixed:Ht.Styles.MIXED,mixed_open_end:Ht.Styles.MIXED_OPEN_END,bracket_open_begin:Ht.Styles.BRACKET_OPEN_BEGIN,bracket_open_end:Ht.Styles.BRACKET_OPEN_END,bracket_open_both:Ht.Styles.BRACKET_OPEN_BOTH}}static createSustain(t){return new Ht(t)}static createSostenuto(t){const e=new Ht(t);return e.setStyle(Ht.Styles.MIXED),e.setCustomText("Sost. Ped."),e}static createUnaCorda(t){const e=new Ht(t);return e.setStyle(Ht.Styles.TEXT),e.setCustomText("una corda","tre corda"),e}constructor(t){super(),this.setAttribute("type","PedalMarking"),this.EndsStave=!1,this.ChangeBegin=!1,this.ChangeEnd=!1,this.notes=t,this.style=Ht.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(t){if(this.endStave=t,this.endStaveAddedWidth=0,this.startMargin=0,this.endMargin=0,Array.isArray(this.endStave.modifiers))for(let t=0;t3)throw new s.RERR("InvalidParameter","The style must be one found in PedalMarking.Styles");return this.style=t,this}setLine(t){return this.line=t,this}drawBracketed(){const t=this.context;let e,i,s=!1;const n=this;this.notes.forEach(((r,o,a)=>{s=!s;let l=0;if(r?(l=r.getNoteHeadBeginX(),this.BeginsStave&&(l=r.getStave().getNoteStartX())):l=this.endStave.end_x+this.endStaveAddedWidth,this.EndsStave)s?this.ChangeBegin&&(l=r.getAbsoluteX()):(l=r?this.ChangeEnd?r.getAbsoluteX():r.getStave().end_x+this.endStaveAddedWidth-n.render_options.text_margin_right:this.endStave.end_x+this.endStaveAddedWidth-n.render_options.text_margin_right,this.endMargin=-n.render_options.text_margin_right);else if(r)if(s)this.ChangeBegin&&(l=r.getAbsoluteX());else switch(n.style){case Ht.Styles.BRACKET_OPEN_END:case Ht.Styles.BRACKET_OPEN_BOTH:case Ht.Styles.MIXED_OPEN_END:l=r.getNoteHeadEndX();break;default:this.ChangeEnd?l=r.getAbsoluteX():(l=r.getNoteHeadBeginX()-n.render_options.text_margin_right,this.startMargin=-n.render_options.text_margin_right)}let h=this.endStave;r&&(h=r.getStave());let c=h.getYForBottomText(n.line+3);i&&i>c&&(c=i);const u=a[o+1]===r,d=a[o-1]===r;let f=0;if(s)if(f=d?5:0,n.style!==Ht.Styles.MIXED&&n.style!==Ht.Styles.MIXED_OPEN_END||d)t.beginPath(),n.style===Ht.Styles.BRACKET_OPEN_BEGIN||n.style===Ht.Styles.BRACKET_OPEN_BOTH?t.moveTo(l+f,c):(this.ChangeBegin&&(l+=5),t.moveTo(l,c-n.render_options.bracket_height),this.ChangeBegin&&(l+=5),t.lineTo(l+f,c)),t.stroke(),t.closePath();else if(n.custom_depress_text){const e=t.measureText(n.custom_depress_text).width;t.fillText(n.custom_depress_text,l-e/2,c),f=e/2+n.render_options.text_margin_right}else zt("pedal_depress",t,l,c,n.render_options.glyph_point_size),f=20+n.render_options.text_margin_right;else f=u&&!this.EndsStave?-5:0,t.beginPath(),t.moveTo(e,i),t.lineTo(l+f,c),n.style!==Ht.Styles.BRACKET_OPEN_END&&n.style!==Ht.Styles.MIXED_OPEN_END&&n.style!==Ht.Styles.BRACKET_OPEN_BOTH&&(this.ChangeEnd&&(l+=5),t.lineTo(l,c-n.render_options.bracket_height)),t.stroke(),t.closePath();e=l+f,i=c}))}drawText(){const t=this.context;let e=!1;const i=this,s=i.render_options.glyph_point_size;this.notes.forEach((n=>{e=!e;const r=n.getStave(),o=n.getAbsoluteX(),a=r.getYForBottomText(i.line+3);let l=0;e?i.custom_depress_text?(l=t.measureText(i.custom_depress_text).width,t.fillText(i.custom_depress_text,o-l/2,a)):zt("pedal_depress",t,o,a,s):i.custom_release_text?(l=t.measureText(i.custom_release_text).width,t.fillText(i.custom_release_text,o-l/2,a)):zt("pedal_release",t,o,a,s)}))}draw(){const t=this.checkContext();this.setRendered(),t.save(),t.setStrokeStyle(this.render_options.color),t.setFillStyle(this.render_options.color),t.setFont(this.font.family,this.font.size,this.font.weight),Ht.DEBUG&&s.L("Vex.Flow.PedalMarking",["Rendering Pedal Marking"]),this.style===Ht.Styles.BRACKET||this.style===Ht.Styles.MIXED||this.style===Ht.Styles.MIXED_OPEN_END||this.style===Ht.Styles.BRACKET_OPEN_BEGIN||this.style===Ht.Styles.BRACKET_OPEN_END||this.style===Ht.Styles.BRACKET_OPEN_BOTH?(t.setLineWidth(this.render_options.bracket_line_width),this.drawBracketed()):this.style===Ht.Styles.TEXT&&this.drawText(),t.restore()}}class Xt extends l{static get Positions(){return{TOP:1,BOTTOM:-1}}static get PositionString(){return{top:Xt.Positions.TOP,bottom:Xt.Positions.BOTTOM}}constructor({start:t,stop:e,text:i="",superscript:s="",position:n=Xt.Positions.TOP}){super(),this.setAttribute("type","TextBracket"),this.start=t,this.stop=e,this.text=i,this.superscript=s,this.position="string"==typeof n?Xt.PositionString[n]:n,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(t){return t.setFont(this.font.family,this.font.size,this.font.weight),t.setStrokeStyle(this.render_options.color),t.setFillStyle(this.render_options.color),t.setLineWidth(this.render_options.line_width),this}setDashed(t,e){return this.render_options.dashed=t,e&&(this.render_options.dash=e),this}setFont(t){return this.font={...this.font,...t},this}setLine(t){return this.line=t,this}draw(){const t=this.context;this.setRendered();let e=0;switch(this.position){case Xt.Positions.TOP:e=this.start.getStave().getYForTopText(this.line);break;case Xt.Positions.BOTTOM:e=this.start.getStave().getYForBottomText(this.line+m.TEXT_HEIGHT_OFFSET_HACK);break;default:throw new s.RERR("InvalidPosition",`The position ${this.position} is invalid`)}const i={x:this.start.getAbsoluteX(),y:e},n={x:this.stop.getAbsoluteX(),y:e};!function(...t){Xt.DEBUG&&s.L("Vex.Flow.TextBracket",t)}("Rendering TextBracket: start:",i,"stop:",n,"y:",e);const r=this.render_options.bracket_height*this.position;t.save(),this.applyStyle(t),t.fillText(this.text,i.x,i.y);const o=t.measureText(this.text).width,a=t.measureText("M").width,l=i.y-a/2.5;t.setFont(this.font.family,this.font.size/1.4,this.font.weight),t.fillText(this.superscript,i.x+o+1,l);const h=t.measureText(this.superscript).width,c=t.measureText("M").width;let u=i.x,d=l;const f=n.x+this.stop.getGlyph().getWidth();this.position===Xt.Positions.TOP?(u+=o+h+5,d-=c/2.7):this.position===Xt.Positions.BOTTOM&&(d+=c/2.7,u+=o+2,this.render_options.underline_superscript||(u+=h)),this.render_options.dashed?(E.drawDashedLine(t,u,d,f,d,this.render_options.dash),this.render_options.show_bracket&&E.drawDashedLine(t,f,d+1*this.position,f,d+r,this.render_options.dash)):(t.beginPath(),t.moveTo(u,d),t.lineTo(f,d),this.render_options.show_bracket&&t.lineTo(f,d+r),t.stroke(),t.closePath()),t.restore()}}class jt extends I{constructor(t=ft.type.SINGLE){super({duration:"b"}),this.setAttribute("type","BarNote"),this.metrics={widths:{}};const e=ft.type;this.metrics.widths={[e.SINGLE]:8,[e.DOUBLE]:12,[e.END]:15,[e.REPEAT_BEGIN]:14,[e.REPEAT_END]:14,[e.REPEAT_BOTH]:18,[e.NONE]:0},this.ignore_ticks=!0,this.setType(t)}getType(){return this.type}setType(t){return this.type="string"==typeof t?ft.typeString[t]:t,this.setWidth(this.metrics.widths[this.type]),this}getBoundingBox(){return super.getBoundingBox()}addToModifierContext(){return this}preFormat(){return this.setPreFormatted(!0),this}draw(){if(this.checkContext(),!this.stave)throw new s.RERR("NoStave","Can't draw without a stave.");!function(...t){jt.DEBUG&&s.L("Vex.Flow.BarNote",t)}("Rendering bar line at: ",this.getAbsoluteX());const t=new ft(this.type);t.setX(this.getAbsoluteX()),t.draw(this.stave),this.setRendered()}}class Yt extends N{constructor(t){if(!t)throw new s.RuntimeError("BadArguments","Ghost note must have valid initialization data to identify duration.");let e;if("string"==typeof t)e={duration:t};else{if("object"!=typeof t)throw new s.RuntimeError("BadArguments","Ghost note must have valid initialization data to identify duration.");e=t}super(e),this.setAttribute("type","GhostNote"),this.setWidth(0)}isRest(){return!0}setStave(t){super.setStave(t)}addToModifierContext(){return this}preFormat(){return this.setPreFormatted(!0),this}draw(){if(!this.stave)throw new s.RERR("NoStave","Can't draw without a stave.");this.setRendered();for(let t=0;t0||!0===e;return!e||n>0||(this.pos=s),o?this.matchSuccess():this.matchFail(s),{success:o,results:i,numMatches:n}}expectZeroOrMore(t){return this.expectOneOrMore(t,!0)}expect(t){let e;if(function(...t){Zt.DEBUG&&s.L("Vex.Flow.Parser",t)}("Evaluating rules:",t),!t)throw new $t("Invalid Rule: "+t,t);const i=t.bind(this.grammar)();if(i.token)e=this.matchToken(i.token,!0===i.noSpace),e.success&&(this.pos+=e.incrementPos);else{if(!i.expect)throw new $t("Bad grammar! No `token` or `expect` property",i);e=i.oneOrMore?this.expectOneOrMore(i):i.zeroOrMore?this.expectZeroOrMore(i):this.expectOne(i)}return e.matches=[],e.results&&e.results.forEach((t=>e.matches.push(Jt(t)))),i.run&&e.success&&i.run(e),e}}function Qt(...t){re.DEBUG&&s.L("Vex.Flow.EasyScore",t)}const te=s.MakeException("EasyScoreError");class ee{constructor(t){this.builder=t}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:t=>this.builder.addChord(t.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:t=>this.builder.addSingleNote(t.matches[0],t.matches[1],t.matches[2])}}ACCIDENTAL(){return{expect:[this.ACCIDENTALS],maybe:!0}}DOTS(){return{expect:[this.DOT],zeroOrMore:!0,run:t=>this.builder.setNoteDots(t.matches[0])}}TYPE(){return{expect:[this.SLASH,this.MAYBESLASH,this.TYPES],maybe:!0,run:t=>this.builder.setNoteType(t.matches[2])}}DURATION(){return{expect:[this.SLASH,this.DURATIONS],maybe:!0,run:t=>this.builder.setNoteDuration(t.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:t=>this.builder.addNoteOption(t.matches[0],t.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 ie{constructor(t){this.factory=t,this.commitHooks=[],this.reset()}reset(t={}){this.options={stem:"auto",clef:"treble"},this.elements={notes:[],accidentals:[]},this.rollingDuration="8",this.resetPiece(),Object.assign(this.options,t)}getFactory(){return this.factory}getElements(){return this.elements}addCommitHook(t){this.commitHooks.push(t)}resetPiece(){Qt("resetPiece"),this.piece={chord:[],duration:this.rollingDuration,dots:0,type:void 0,options:{}}}setNoteDots(t){Qt("setNoteDots:",t),t&&(this.piece.dots=t.length)}setNoteDuration(t){Qt("setNoteDuration:",t),this.rollingDuration=this.piece.duration=t||this.rollingDuration}setNoteType(t){Qt("setNoteType:",t),t&&(this.piece.type=t)}addNoteOption(t,e){Qt("addNoteOption: key:",t,"value:",e),this.piece.options[t]=e}addNote(t,e,i){Qt("addNote:",t,e,i),this.piece.chord.push({key:t,accid:e,octave:i})}addSingleNote(t,e,i){Qt("addSingleNote:",t,e,i),this.addNote(t,e,i)}addChord(t){Qt("startChord"),"object"!=typeof t[0]?this.addSingleNote(t[0]):t.forEach((t=>{t&&this.addNote(...t)})),Qt("endChord")}commitPiece(){Qt("commitPiece");const{factory:t}=this;if(!t)return;const e={...this.options,...this.piece.options},{stem:i,clef:s}=e,n="auto"===i.toLowerCase(),r=n||"up"!==i.toLowerCase()?O.STEM_DOWN:O.STEM_UP,{chord:o,duration:a,dots:l,type:h}=this.piece,c=o.map((t=>t.key+"/"+t.octave)),u=t.StaveNote({keys:c,duration:a,dots:l,type:h,clef:s,auto_stem:n});n||u.setStemDirection(r);const d=o.map((t=>t.accid||null));d.forEach(((e,i)=>{e&&u.addAccidental(i,t.Accidental({type:e}))}));for(let t=0;tt(e,u,this))),this.elements.notes.push(u),this.elements.accidentals.concat(d),this.resetPiece()}}function se({id:t},e){void 0!==t&&e.setAttribute("id",t)}function ne(t,e){t.class&&t.class.split(/\s*,\s*/).forEach((t=>e.addClass(t)))}class re{constructor(t={}){this.setOptions(t),this.defaults={clef:"treble",time:"4/4",stem:"auto"}}set(t){return Object.assign(this.defaults,t),this}setOptions(t){return this.options={factory:null,builder:null,commitHooks:[se,ne,it.easyScoreHook],throwOnError:!1,...t},this.factory=this.options.factory,this.builder=this.options.builder||new ie(this.factory),this.grammar=new ee(this.builder),this.parser=new Zt(this.grammar),this.options.commitHooks.forEach((t=>this.addCommitHook(t))),this}setContext(t){return this.factory&&this.factory.setContext(t),this}parse(t,e={}){this.builder.reset(e);const i=this.parser.parse(t);if(!i.success&&this.options.throwOnError)throw new te("Error parsing line: "+t,i);return i}beam(t,e={}){return this.factory.Beam({notes:t,options:e}),t}tuplet(t,e={}){return this.factory.Tuplet({notes:t,options:e}),t}notes(t,e={}){return e={clef:this.defaults.clef,stem:this.defaults.stem,...e},this.parse(t,e),this.builder.getElements().notes}voice(t,e){return e={time:this.defaults.time,...e},this.factory.Voice(e).addTickables(t)}addCommitHook(t){return this.builder.addCommitHook(t)}}const oe=s.MakeException("FactoryError");function ae(t={},e){const i=e.options;return(t=Object.assign(e,t)).options=Object.assign(i,t.options),t}class le{constructor(t){!function(...t){le.DEBUG&&s.L("Vex.Flow.Factory",t)}("New factory: ",t);const e={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=e,this.setOptions(t)}static newFromElementId(t,e=500,i=200){return new le({renderer:{elementId:t,width:e,height:i}})}reset(){this.renderQ=[],this.systems=[],this.staves=[],this.voices=[],this.stave=null}getOptions(){return this.options}setOptions(t){for(const e of["stave","renderer","font"])Object.assign(this.options[e],t[e]);(null!==this.options.renderer.elementId||this.options.renderer.context)&&this.initRenderer(),this.reset()}initRenderer(){const{elementId:t,backend:e,width:i,height:s,background:n}=this.options.renderer;if(""===t)throw new oe("HTML DOM element not set in Factory");this.context=E.buildContext(t,e,i,s,n)}getContext(){return this.context}setContext(t){return this.context=t,this}getStave(){return this.stave}getVoices(){return this.voices}space(t){return this.options.stave.space*t}Stave(t){t=ae(t,{x:0,y:0,width:this.options.renderer.width-this.space(1),options:{spacing_between_lines_px:this.options.stave.space}});const e=new _t(t.x,t.y,t.width,t.options);return this.staves.push(e),e.setContext(this.context),this.stave=e,e}TabStave(t){t=ae(t,{x:0,y:0,width:this.options.renderer.width-this.space(1),options:{spacing_between_lines_px:1.3*this.options.stave.space}});const e=new Mt(t.x,t.y,t.width,t.options);return this.staves.push(e),e.setContext(this.context),this.stave=e,e}StaveNote(t){const e=new O(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}GhostNote(t){const e=new Yt(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}TextNote(t){const e=new gt(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}BarNote(t){t=ae(t,{type:"single",options:{}});const e=new jt(t.type);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}ClefNote(t){t=ae(t,{type:"treble",options:{size:"default"}});const e=new Ct(t.type,t.options.size,t.options.annotation);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}TimeSigNote(t){t=ae(t,{time:"4/4",options:{}});const e=new Rt(t.time);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}KeySigNote(t){const e=new It(t.key,t.cancelKey,t.alterKey);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}TabNote(t){const e=new wt(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}GraceNote(t){const e=new Bt(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),e}GraceNoteGroup(t){const e=new j(t.notes,t.slur);return e.setContext(this.context),e}Accidental(t){t=ae(t,{type:null,options:{}});const e=new U(t.type);return e.setContext(this.context),e}Annotation(t){t=ae(t,{text:"p",vJustify:"below",hJustify:"center",fontFamily:"Times",fontSize:14,fontWeight:"bold italic",options:{}});const e=new nt(t.text);return e.setJustification(t.hJustify),e.setVerticalJustification(t.vJustify),e.setFont(t.fontFamily,t.fontSize,t.fontWeight),e.setContext(this.context),e}Articulation(t){t=ae(t,{type:"a.",position:"above",options:{}});const e=new it(t.type);return e.setPosition(t.position),e.setContext(this.context),e}TextDynamics(t){t=ae(t,{text:"p",duration:"q",dots:0,line:0,options:{}});const e=new Gt({text:t.text,line:t.line,duration:t.duration,dots:t.dots});return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}Fingering(t){t=ae(t,{number:"0",position:"left",options:{}});const e=new k(t.number);return e.setPosition(t.position),e.setContext(this.context),e}StringNumber(t){t=ae(t,{number:"0",position:"left",options:{}});const e=new K(t.number);return e.setPosition(t.position),e.setContext(this.context),e}TickContext(){return(new q).setContext(this.context)}ModifierContext(){return new lt}MultiMeasureRest(t){const e=new At(t.number_of_measures,t);return e.setContext(this.context),this.renderQ.push(e),e}Voice(t){t=ae(t,{time:"4/4",options:{}});const e=new T(t.time);return this.voices.push(e),e}StaveConnector(t){t=ae(t,{top_stave:null,bottom_stave:null,type:"double",options:{}});const e=new A(t.top_stave,t.bottom_stave);return e.setType(t.type).setContext(this.context),this.renderQ.push(e),e}Formatter(){return new ut}Tuplet(t){t=ae(t,{notes:[],options:{}});const e=new x(t.notes,t.options).setContext(this.context);return this.renderQ.push(e),e}Beam(t){t=ae(t,{notes:[],options:{autoStem:!1,secondaryBeamBreaks:[]}});const e=new P(t.notes,t.options.autoStem).setContext(this.context);return e.breakSecondaryAt(t.options.secondaryBeamBreaks),this.renderQ.push(e),e}Curve(t){t=ae(t,{from:null,to:null,options:{}});const e=new kt(t.from,t.to,t.options).setContext(this.context);return this.renderQ.push(e),e}StaveTie(t){t=ae(t,{from:null,to:null,first_indices:[0],last_indices:[0],text:null,options:{direction:void 0}});const e=new H({first_note:t.from,last_note:t.to,first_indices:t.first_indices,last_indices:t.last_indices},t.text);return t.options.direction&&e.setDirection(t.options.direction),e.setContext(this.context),this.renderQ.push(e),e}StaveLine(t){t=ae(t,{from:null,to:null,first_indices:[0],last_indices:[0],options:{}});const e=new Ut({first_note:t.from,last_note:t.to,first_indices:t.first_indices,last_indices:t.last_indices});return t.options.text&&e.setText(t.options.text),t.options.font&&e.setFont(t.options.font),e.setContext(this.context),this.renderQ.push(e),e}VibratoBracket(t){t=ae(t,{from:null,to:null,options:{harsh:!1}});const e=new Pt({start:t.from,stop:t.to});return t.options.line&&e.setLine(t.options.line),t.options.harsh&&e.setHarsh(t.options.harsh),e.setContext(this.context),this.renderQ.push(e),e}TextBracket(t){t=ae(t,{from:null,to:null,text:"",options:{superscript:"",position:1}});const e=new Xt({start:t.from,stop:t.to,text:t.text,superscript:t.options.superscript,position:t.options.position});return t.options.line&&e.setLine(t.options.line),t.options.font&&e.setFont(t.options.font),e.setContext(this.context),this.renderQ.push(e),e}System(t={}){t.factory=this;const e=new ce(t).setContext(this.context);return this.systems.push(e),e}EasyScore(t={}){return t.factory=this,new re(t)}PedalMarking(t={}){t=ae(t,{notes:[],options:{style:"mixed"}});const e=new Ht(t.notes);return e.setStyle(Ht.StylesString[t.options.style]),e.setContext(this.context),this.renderQ.push(e),e}NoteSubGroup(t={}){t=ae(t,{notes:[],options:{}});const e=new z(t.notes);return e.setContext(this.context),e}draw(){this.systems.forEach((t=>t.setContext(this.context).format())),this.staves.forEach((t=>t.setContext(this.context).draw())),this.voices.forEach((t=>t.setContext(this.context).draw())),this.renderQ.forEach((t=>{t.isRendered()||t.setContext(this.context).draw()})),this.systems.forEach((t=>t.setContext(this.context).draw())),this.reset()}}function he(t,e){const i=e.options;return(t=Object.assign(e,t)).options=Object.assign(i,t.options),t}class ce extends l{constructor(t={}){super(),this.setAttribute("type","System"),this.setOptions(t),this.parts=[]}setOptions(t={}){this.options=he(t,{x:10,y:10,width:500,connector:null,spaceBetweenStaves:12,factory:null,debugFormatter:!1,formatIterations:0,options:{}}),this.factory=this.options.factory||new le({renderer:{el:null}})}setContext(t){return super.setContext(t),this.factory.setContext(t),this}addConnector(t="double"){return this.connector=this.factory.StaveConnector({top_stave:this.parts[0].stave,bottom_stave:this.parts[this.parts.length-1].stave,type:t}),this.connector}addStave(t){return(t=he(t,{stave:null,voices:[],spaceAbove:0,spaceBelow:0,debugNoteMetrics:!1,options:{left_bar:!1}})).stave||(t.stave=this.factory.Stave({x:this.options.x,y:this.options.y,width:this.options.width,options:t.options})),t.voices.forEach((e=>e.setContext(this.context).setStave(t.stave).getTickables().forEach((e=>e.setStave(t.stave))))),this.parts.push(t),t.stave}format(){const t=new ut;this.formatter=t;let e=this.options.y,i=0,s=[];const n=[];this.parts.forEach((r=>{e+=r.stave.space(r.spaceAbove),r.stave.setY(e),t.joinVoices(r.voices),e+=r.stave.space(r.spaceBelow),e+=r.stave.space(this.options.spaceBetweenStaves),r.debugNoteMetrics&&(n.push({y:e,voice:r.voices[0]}),e+=15),s=s.concat(r.voices),i=Math.max(i,r.stave.getNoteStartX())})),this.parts.forEach((t=>t.stave.setNoteStartX(i)));const r=this.options.width-(i-this.options.x)-I.STAVEPADDING;t.format(s,r);for(let e=0;e{e.voice.getTickables().forEach((i=>I.plotMetrics(t,i,e.y)))}))}}(s.Flow=m).Element=l,s.Flow.Fraction=n,s.Flow.Renderer=E,s.Flow.Formatter=ut,s.Flow.Music=V,s.Flow.Glyph=f,s.Flow.Stave=_t,s.Flow.StaveNote=O,s.Flow.StaveModifier=dt,s.Flow.StaveTempo=bt,s.Flow.Voice=T,s.Flow.Accidental=U,s.Flow.Beam=P,s.Flow.StaveTie=H,s.Flow.TabStave=Mt,s.Flow.TabNote=wt,s.Flow.Bend=rt,s.Flow.Vibrato=ot,s.Flow.VibratoBracket=Pt,s.Flow.Note=I,s.Flow.ModifierContext=lt,s.Flow.MultiMeasureRest=At,s.Flow.TickContext=q,s.Flow.Articulation=it,s.Flow.Annotation=nt,s.Flow.Barline=ft,s.Flow.NoteHead=R,s.Flow.StaveConnector=A,s.Flow.ClefNote=Ct,s.Flow.KeySignature=Et,s.Flow.KeySigNote=It,s.Flow.TimeSignature=vt,s.Flow.TimeSigNote=Rt,s.Flow.Stem=v,s.Flow.TabTie=X,s.Flow.Clef=yt,s.Flow.Dot=F,s.Flow.Modifier=B,s.Flow.TabSlide=Nt,s.Flow.Tuplet=x,s.Flow.GraceNote=Bt,s.Flow.GraceTabNote=Ft,s.Flow.Tuning=Dt,s.Flow.KeyManager=class{constructor(t){this.music=new V,this.setKey(t)}setKey(t){return this.key=t,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),!V.scaleTypes[this.keyParts.type])throw new s.RERR("BadArguments",`Unsupported key type: ${this.key}`);this.scale=this.music.getScaleTones(this.music.getNoteValue(this.keyString),V.scaleTypes[this.keyParts.type]),this.scaleMap={},this.scaleMapByValue={},this.originalScaleMapByValue={};const t=V.root_indices[this.keyParts.root];for(let e=0;e{"use strict";t.exports="precision mediump float;\nuniform sampler2D u_image;\nvarying vec4 v_position;\n\n#define NUM_ROWS 5\n#define ELEMENT_HEIGHT 300\n\nvoid main() {\n const float halfPixel = 1.0 / float(ELEMENT_HEIGHT * 2);\n\n vec2 absolutePosition = (v_position.xy + vec2(1.0)) / vec2(2.0);\n float absX = absolutePosition.x;\n float absY = absolutePosition.y;\n\n int skyLine = 0;\n for (int i = 0; i < ELEMENT_HEIGHT; ++i) {\n float ratioY = float(i) / float(ELEMENT_HEIGHT);\n float relY = (ratioY - 0.5 + halfPixel) / float(NUM_ROWS);\n float x = absX;\n float y = absY + relY;\n\n float currentAlpha = texture2D(u_image, vec2(x, y)).a;\n if (currentAlpha > 0.0) {\n skyLine = i;\n break;\n }\n }\n\n int bottomLine = ELEMENT_HEIGHT;\n for (int i = ELEMENT_HEIGHT - 1; i >= 0; --i) {\n float ratioY = float(i) / float(ELEMENT_HEIGHT);\n float relY = (ratioY - 0.5 + halfPixel) / float(NUM_ROWS);\n float x = absX;\n float y = absY + relY;\n\n float currentAlpha = texture2D(u_image, vec2(x, y)).a;\n if (currentAlpha > 0.0) {\n bottomLine = i;\n break;\n }\n }\n\n int r = skyLine;\n if (r > 256) {\n r -= 256;\n }\n int g = bottomLine;\n if (g > 256) {\n g -= 256;\n }\n int b = (skyLine / 256 * 16) + (bottomLine / 256);\n\n gl_FragColor = vec4(float(r) / 255.0, float(g) / 255.0, float(b) / 255.0, 1.0);\n}\n"},6357:t=>{"use strict";t.exports="attribute vec4 a_position;\nvarying vec4 v_position;\n\nvoid main() {\n gl_Position = a_position;\n v_position = a_position;\n}\n"}},e={};function i(s){var n=e[s];if(void 0!==n)return n.exports;var r=e[s]={exports:{}};return t[s].call(r.exports,r,r.exports,i),r.exports}return i.d=(t,e)=>{for(var s in e)i.o(e,s)&&!i.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i(3607)})())); //# sourceMappingURL=opensheetmusicdisplay.min.js.map