System.register([],(function(t,e){"use strict";return{execute:function(){t({a:function(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t},g:i});var e=t("c","undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{});function i(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var i=function t(){if(this instanceof t){var i=[null];return i.push.apply(i,arguments),new(Function.bind.apply(e,i))}return e.apply(this,arguments)};i.prototype=e.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var s=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(i,e,s.get?s:{enumerable:!0,get:function(){return t[e]}})})),i}var s=t("l",{});!function(t){var i,s;i=e,s=function(){var t=function(){},e="undefined",i=typeof window!==e&&typeof window.navigator!==e&&/Trident\/|MSIE /.test(window.navigator.userAgent),s=["trace","debug","info","warn","error"];function n(t,e){var i=t[e];if("function"==typeof i.bind)return i.bind(t);try{return Function.prototype.bind.call(i,t)}catch(s){return function(){return Function.prototype.apply.apply(i,[t,arguments])}}}function r(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function o(e,i){for(var n=0;n=0&&i<=a.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(n){}try{window.document.cookie=encodeURIComponent(l)+"="+i+";"}catch(n){}}}(i),o.call(a,i,t),typeof console===e&&i=0;n--)if(s(t[n],e))return n;return-1},r.contains=function(t,e,i){return h(t,e,i)>=0},r.remove=function(t,e,i){var s=h(t,e,i);return!(s<0||(t.splice(s,1),0))},r.frequency=function(t,e,i){for(var s=i||a.defaultEquals,n=t.length,r=0,o=0;o=t.length||i<0||i>=t.length)return!1;var s=t[e];return t[e]=t[i],t[i]=s,!0},r.toString=function(t){return"["+t.toString()+"]"},r.forEach=function(t,e){for(var i=0,s=t;it.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 b.toString(this.toArray())},t}();p.default=m,Object.defineProperty(l,"__esModule",{value:!0});var _=o,y=c,x=p,v=function(){function t(t){this.toStrF=t||_.defaultToString,this.dictionary=new y.default(this.toStrF),this.nElements=0}return t.prototype.add=function(t,e){if(void 0===e&&(e=1),_.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),_.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();ethis.nElements||k.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 s=this.nodeAtIndex(e-1);if(null===s)return!1;i.next=s.next,s.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||k.defaultEquals;if(k.isUndefined(t))return-1;for(var s=this.firstNode,n=0;null!==s;){if(i(s.element,t))return n;n++,s=s.next}return-1},t.prototype.contains=function(t,e){return this.indexOf(t,e)>=0},t.prototype.remove=function(t,e){var i=e||k.defaultEquals;if(this.nElements<1||k.isUndefined(t))return!1;for(var s=null,n=this.firstNode;null!==n;){if(i(n.element,t))return null===s?(this.firstNode=n.next,n===this.lastNode&&(this.lastNode=null)):n===this.lastNode?(this.lastNode=s,s.next=n.next,n.next=null):(s.next=n.next,n.next=null),this.nElements--,!0;s=n,n=n.next}return!1},t.prototype.clear=function(){this.firstNode=null,this.lastNode=null,this.nElements=0},t.prototype.equals=function(e,i){var s=i||k.defaultEquals;return e instanceof t&&this.size()===e.size()&&this.equalsAux(this.firstNode,e.firstNode,s)},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 C.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;i0&&(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 O.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}();S.default=L;var M,I=e&&e.__extends||(M=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}M(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(w,"__esModule",{value:!0});var B=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return I(e,t),e}(S.default);w.default=B;var F={};Object.defineProperty(F,"__esModule",{value:!0});var D=o,G=r,U=function(){function t(t){this.data=[],this.compare=t||D.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;)G.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;)G.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!D.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=D.compareToEquals(this.compare);return G.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){G.forEach(this.data,t)},t}();F.default=U;var W={},z=e&&e.__extends||function(){var t=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])};return function(e,i){function s(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(s.prototype=i.prototype,new s)}}();Object.defineProperty(W,"__esModule",{value:!0});var Y=c,H=o,X=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}(),V=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}(),j=function(t){function e(e){var i=t.call(this,e)||this;return i.head=new V,i.tail=new V,i.head.next=i.tail,i.tail.prev=i.head,i}return z(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(!H.isUndefined(t)){var e="$"+this.toStr(t);return this.table[e]}},e.prototype.getValue=function(t){var e=this.getLinkedDictionaryPair(t);if(!H.isUndefined(e))return e.value},e.prototype.remove=function(e){var i=this.getLinkedDictionaryPair(e);if(!H.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(!H.isUndefined(t)&&!H.isUndefined(e)){var i=this.getLinkedDictionaryPair(t),s=new X(t,e),n="$"+this.toStr(t);return H.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}(Y.default);W.default=j;var K={};Object.defineProperty(K,"__esModule",{value:!0});var $=o,q=c,Z=r,J=function(){function t(t,e,i){void 0===i&&(i=!1),this.dict=new q.default(t),this.equalsF=e||$.defaultEquals,this.allowDuplicate=i}return t.prototype.getValue=function(t){var e=this.dict.getValue(t);return $.isUndefined(e)?[]:Z.copy(e)},t.prototype.setValue=function(t,e){if($.isUndefined(t)||$.isUndefined(e))return!1;var i=this.dict.getValue(t);return $.isUndefined(i)?(this.dict.setValue(t,[e]),!0):!(!this.allowDuplicate&&Z.contains(i,e,this.equalsF)||(i.push(e),0))},t.prototype.remove=function(t,e){if($.isUndefined(e)){var i=this.dict.remove(t);return!$.isUndefined(i)}var s=this.dict.getValue(t);return!($.isUndefined(s)||!Z.remove(s,e,this.equalsF)||(0===s.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-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,i){var s=t,n=this.findRootId(s);for(var r in this.nodes[e],this.nodes)if(this.nodes.hasOwnProperty(r)){this.findNodeId(r,e);break}var o=e,a=this.findRootId(o);for(var r in this.nodes[e],this.nodes)if(this.nodes.hasOwnProperty(r)){this.findNodeId(r,e);break}if(n>-1){if(a>-1)switch(this.rootDelete(n),a>n&&a--,i){case ct.BEFORE:this.insertIdIntoRoot(s,a);break;case ct.AFTER:this.insertIdIntoRoot(s,a+1);break;case ct.INSIDE_AT_START:this.nodeInsertAtStart(o,s);break;case ct.INSIDE_AT_END:this.nodeInsertAtEnd(o,s)}else for(var r in this.rootDelete(n),this.nodes)if(this.nodes.hasOwnProperty(r)&&(h=this.findNodeId(r,o))>-1){switch(i){case ct.BEFORE:this.insertIdIntoNode(r,s,h);break;case ct.AFTER:this.insertIdIntoNode(r,s,h+1);break;case ct.INSIDE_AT_START:this.nodeInsertAtStart(o,s);break;case ct.INSIDE_AT_END:this.nodeInsertAtEnd(o,s)}break}}else if(a>-1){for(var r in this.nodes)if(this.nodes.hasOwnProperty(r)&&(h=this.findNodeId(r,s))>-1){this.nodeDeleteAtIndex(r,h);break}switch(i){case ct.BEFORE:this.insertIdIntoRoot(s,a);break;case ct.AFTER:this.insertIdIntoRoot(s,a+1);break;case ct.INSIDE_AT_START:this.nodeInsertAtStart(o,s);break;case ct.INSIDE_AT_END:this.nodeInsertAtEnd(o,s)}}else{for(var r in this.nodes)if(this.nodes.hasOwnProperty(r)&&(h=this.findNodeId(r,s))>-1){this.nodeDeleteAtIndex(r,h);break}for(var r in this.nodes){var h;if(this.nodes.hasOwnProperty(r)&&(h=this.findNodeId(r,o))>-1){switch(i){case ct.BEFORE:this.insertIdIntoNode(r,s,h);break;case ct.AFTER:this.insertIdIntoNode(r,s,h+1);break;case ct.INSIDE_AT_START:this.nodeInsertAtStart(o,s);break;case ct.INSIDE_AT_END:this.nodeInsertAtEnd(o,s)}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{}));Nt.L=(t,e)=>{if(!e)return;const i=Array.prototype.slice.call(e).join(" ");window.console.log(t+": "+i)},Nt.MakeException=t=>class extends Error{constructor(e,i){super(e),this.name=t,this.message=e,this.data=i}},Nt.RuntimeError=class{constructor(t,e){this.code=t,this.message=e}toString(){return"[RuntimeError] "+this.code+":"+this.message}},Nt.RERR=Nt.RuntimeError,Nt.Merge=(t,e)=>{for(const i in e)t[i]=e[i];return t},Nt.Min=Math.min,Nt.Max=Math.max,Nt.forEach=(t,e)=>{for(let i=0;it%e>=e/2?parseInt(t/e,10)*e+e:parseInt(t/e,10)*e,Nt.MidLine=(t,e)=>{let i=e+(t-e)/2;return i%2>0&&(i=Nt.RoundN(10*i,5)/10),i},Nt.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},Nt.getCanvasContext=t=>{if(!t)throw new Nt.RERR("BadArgument","Invalid canvas selector: "+t);const e=document.getElementById(t);if(!e||!e.getContext)throw new Nt.RERR("UnsupportedBrowserError","This browser does not support HTML5 Canvas");return e.getContext("2d")},Nt.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()},Nt.BM=(t,e)=>{const i=(new Date).getTime();e();const s=(new Date).getTime()-i;Nt.L(t+s+"ms")},Nt.StackTrace=()=>(new Error).stack,Nt.W=(...t)=>{const e=t.join(" ");window.console.log("Warning: ",e,Nt.StackTrace())},Nt.Prefix=t=>Nt.Prefix.prefix+t,Nt.Prefix.prefix="vf-";class Pt{static GCD(t,e){if("number"!=typeof t||"number"!=typeof e)throw new Nt.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/Pt.GCD(t,e)}static LCMM(t){if(0===t.length)return 0;if(1===t.length)return t[0];if(2===t.length)return Pt.LCM(t[0],t[1]);{const e=t[0];return t.shift(),Pt.LCM(e,Pt.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=Pt.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 Pt?(i=t.numerator,s=t.denominator):(i=void 0!==t?t:0,s=void 0!==e?e:1);const n=Pt.LCM(this.denominator,s),r=n/this.denominator,o=n/s,a=this.numerator*r+i*o;return this.set(a,n)}subtract(t,e){let i,s;t instanceof Pt?(i=t.numerator,s=t.denominator):(i=void 0!==t?t:0,s=void 0!==e?e:1);const n=Pt.LCM(this.denominator,s),r=n/this.denominator,o=n/s,a=this.numerator*r-i*o;return this.set(a,n)}multiply(t,e){let i,s;return t instanceof Pt?(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 Pt?(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=Pt.__compareA.copy(t).simplify(),i=Pt.__compareB.copy(this).simplify();return e.numerator===i.numerator&&e.denominator===i.denominator}greaterThan(t){const e=Pt.__compareB.copy(this);return e.subtract(t),e.numerator>0}greaterThanEquals(t){const e=Pt.__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 Pt(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 Pt.__tmp.copy(this).simplify().toString()}toMixedString(){let t="";const e=this.quotient(),i=Pt.__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)}}Pt.__compareA=new Pt,Pt.__compareB=new Pt,Pt.__tmp=new Pt;const Ot=Nt.MakeException("RegistryError");function Lt(t,e,i,s,n){t[e][i]||(t[e][i]={}),t[e][i][s]=n}class Mt{static get INDEXES(){return["type"]}constructor(){this.clear()}static enableDefaultRegistry(t){Mt.defaultRegistry=t}static getDefaultRegistry(){return Mt.defaultRegistry}static disableDefaultRegistry(){Mt.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&&Lt(this.index,e,i,n.getAttribute("id"),n)}register(t,e){if(!(e=e||t.getAttribute("id")))throw new Ot("Can't add element without `id` attribute to registry",t);return t.setAttribute("id",e),Lt(this.index,"id",e,e,t),Mt.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}(Mt.INDEXES.concat(["id","class"]),e)?(this.updateIndex({id:t,name:e,value:i,oldValue:s}),this):this}}Mt.defaultRegistry=null;class It{static newID(){return"auto"+It.ID++}constructor({type:t}={}){this.attrs={id:It.newID(),el:null,type:t||"Base",classes:{}},this.boundingBox=null,this.context=null,this.rendered=!1,Mt.getDefaultRegistry()&&Mt.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 Nt.RERR("NoContext","No rendering context attached to instance");return this.context}}It.ID=1e3;class Bt{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),h=o+1/3*(n-t),l=a+1/3*(r-e);this.addBezierCurve(t,e,o,a,h,l,n,r)}addBezierCurve(t,e,i,s,n,r,o,a){const h=[t,e],l=[i,s],c=[n,r],u=[o,a];let d;this.addPoint(h[0],h[1]),this.addPoint(u[0],u[1]);const p=(t,e)=>Math.pow(1-t,3)*h[e]+3*Math.pow(1-t,2)*t*l[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*h[d]-12*l[d]+6*c[d],e=-3*h[d]+9*l[d]-9*c[d]+3*u[d],i=3*l[d]-3*h[d];if(0===e){if(0===t)continue;const e=-i/t;0{if(!t)throw new Nt.RERR("BadArgument","Invalid clef: "+t);const e=Wt.clefProperties.values[t];if(!e)throw new Nt.RERR("BadArgument","Invalid clef: "+t);return e}};Wt.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}},Wt.keyProperties=(t,e,i)=>{void 0===e&&(e="treble");const s={octave_shift:0};"object"==typeof i&&Nt.Merge(s,i);const n=t.split("/");if(n.length<2)throw new Nt.RERR("BadArguments",`Key must have note + octave and an optional glyph: ${t}`);const r=n[0].toUpperCase(),o=Wt.keyProperties.note_values[r];if(!o)throw new Nt.RERR("BadArguments","Invalid key name: "+r);o.octave&&(n[1]=o.octave);let a=parseInt(n[1],10);a-=s.octave_shift;let h=(7*a-28+o.index)/2;h+=Wt.clefProperties(e).line_shift;let l=0;h<=0&&2*h%2==0&&(l=1),h>=6&&2*h%2==0&&(l=-1);const c=void 0!==o.int_val?12*a+o.int_val:null,u=o.code,d=o.shift_right;let p={};if(n.length>2&&n[2]){const t=n[2].toUpperCase();p=Wt.keyProperties.customNoteHeads[t]||{}}return{key:r,octave:a,line:h,int_value:c,accidental:o.accidental,code:u,stroke:l,shift_right:d,displaced:!1,...p}},Wt.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}},Wt.keyProperties.customNoteHeads={D0:{code:"v27",shift_right:0,stem_up_x_offset:0,stem_down_x_offset:0,stem_up_y_offset:-1,stem_down_y_offset:0},D1:{code:"v2d",shift_right:-.5},D2:{code:"v22",shift_right:-.5},D3:{code:"v70",shift_right:-.5},T0:{code:"v49",shift_right:-2,stem_up_y_offset:-4,stem_down_y_offset:4},T1:{code:"v93",shift_right:.5,stem_up_y_offset:-4,stem_down_y_offset:4},T2:{code:"v40",shift_right:.5,stem_up_y_offset:-4,stem_down_y_offset:4},T3:{code:"v7d",shift_right:.5,stem_up_y_offset:-4,stem_down_y_offset:4},TI:{code:"v11",shift_right:0,stem_up_y_shift:5,stem_down_y_shift:5,stem_up_x_offset:6,stem_down_x_offset:4},X0:{code:"v92",stem_up_x_offset:-2,stem_down_x_offset:0,stem_up_y_offset:4,stem_down_y_offset:4},X1:{code:"v95",shift_right:-.5,stem_up_y_offset:4,stem_down_y_offset:4},X2:{code:"v3e",shift_right:.5,stem_up_y_offset:4,stem_down_y_offset:4},X3:{code:"v3b",shift_right:0,stem_up_x_offset:-1.2,stem_down_x_offset:0,stem_up_y_offset:-1,stem_down_y_offset:2},S1:{code:"vd3",shift_right:0},S2:{code:"vd2",shift_right:0},R1:{code:"vd5",shift_right:0},R2:{code:"vd4",shift_right:0},rwl:{code:"rwl",shift_right:0},rhl:{code:"rhl",shift_right:0}},Wt.integerToNote=t=>{if(void 0===t)throw new Nt.RERR("BadArguments","Undefined integer for integerToNote");if(t<-2)throw new Nt.RERR("BadArguments",`integerToNote requires integer > -2: ${t}`);const e=Wt.integerToNote.table[t];if(!e)throw new Nt.RERR("BadArguments",`Unknown note value for integer: ${t}`);return e},Wt.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"},Wt.tabToGlyph=(t,e=1)=>{let i=null,s=0,n=0;if("X"===t.toString().toUpperCase()){const t=new Ut("v7f",Wt.DEFAULT_TABLATURE_FONT_SCALE).getMetrics();i="v7f",s=t.width,n=-t.height/2}else s=Wt.textWidth(t.toString());return{text:t,code:i,getWidth:()=>s*e,shift_y:n}},Wt.textWidth=t=>7*t.toString().length,Wt.articulationCodes=t=>Wt.articulationCodes.articulations[t],Wt.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}},Wt.accidentalCodes=t=>Wt.accidentalCodes.accidentals[t],Wt.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}},Wt.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]}},Wt.ornamentCodes=t=>Wt.ornamentCodes.ornaments[t],Wt.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"}},Wt.keySignature=t=>{const e=Wt.keySignature.keySpecs[t];if(!e)throw new Nt.RERR("BadKeySignature",`Bad key signature spec: '${t}'`);if(!e.acc)return[];const i=Wt.keySignature.accidentalList(e.acc),s=[];for(let n=0;n({b:[2,.5,2.5,1,3,1.5,3.5],"#":[0,1.5,-.5,1,2.5,.5,2]}[t]),Wt.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}},Wt.parseNoteStruct=t=>{const e=t.duration,i=Wt.parseNoteDurationString(e);if(!i)return null;let s=Wt.durationToTicks(i.duration);if(null==s)return null;let n=t.type;const r=[];if(n){if(!Wt.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 h=0;h{const e=Wt.durationAliases[t];if(void 0!==e&&(t=e),void 0===Wt.durationToTicks.durations[t])throw new Nt.RERR("BadArguments",`The provided duration is not valid: ${t}`);return t},Wt.durationToFraction=t=>(new Pt).parse(Wt.sanitizeDuration(t)),Wt.durationToNumber=t=>Wt.durationToFraction(t).value(),Wt.durationToTicks=t=>{t=Wt.sanitizeDuration(t);const e=Wt.durationToTicks.durations[t];return void 0===e?null:e},Wt.durationToTicks.durations={"1/2":2*Wt.RESOLUTION,1:Wt.RESOLUTION/1,2:Wt.RESOLUTION/2,4:Wt.RESOLUTION/4,8:Wt.RESOLUTION/8,16:Wt.RESOLUTION/16,32:Wt.RESOLUTION/32,64:Wt.RESOLUTION/64,128:Wt.RESOLUTION/128,256:Wt.RESOLUTION/256},Wt.durationAliases={w:"1",h:"2",q:"4",b:"256"},Wt.getGlyphProps=(t,e)=>{t=Wt.sanitizeDuration(t);const i=Wt.getGlyphProps.duration_codes[t];if(void 0===i)return null;e||(e="n");let s=i.type[e];if(void 0===s){const t=Wt.keyProperties.customNoteHeads[e.toUpperCase()];if(void 0===t)return null;s={code_head:t.code,...t}}return{...i.common,...s}},Wt.getGlyphProps.validTypes={n:{name:"note"},r:{name:"rest"},h:{name:"harmonic"},m:{name:"muted"},s:{name:"slash"}},Wt.getGlyphProps.duration_codes={"1/2":{common:{getWidth(t=Wt.DEFAULT_NOTATION_FONT_SCALE){return new Ut(this.code_head||"v53",t).getMetrics().width},stem:!1,stem_offset:0,flag:!1,stem_up_extension:-Wt.STEM_HEIGHT,stem_down_extension:-Wt.STEM_HEIGHT,tabnote_stem_up_extension:-Wt.STEM_HEIGHT,tabnote_stem_down_extension:-Wt.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:()=>Wt.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},1:{common:{getWidth(t=Wt.DEFAULT_NOTATION_FONT_SCALE){return new Ut(this.code_head||"v1d",t).getMetrics().width},stem:!1,stem_offset:0,flag:!1,stem_up_extension:-Wt.STEM_HEIGHT,stem_down_extension:-Wt.STEM_HEIGHT,tabnote_stem_up_extension:-Wt.STEM_HEIGHT,tabnote_stem_down_extension:-Wt.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:()=>Wt.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},2:{common:{getWidth(t=Wt.DEFAULT_NOTATION_FONT_SCALE){return new Ut(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:()=>Wt.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},4:{common:{getWidth(t=Wt.DEFAULT_NOTATION_FONT_SCALE){return new Ut(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:()=>Wt.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},8:{common:{getWidth(t=Wt.DEFAULT_NOTATION_FONT_SCALE){return new Ut(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:()=>Wt.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},16:{common:{beam_count:2,getWidth(t=Wt.DEFAULT_NOTATION_FONT_SCALE){return new Ut(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:()=>Wt.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},32:{common:{beam_count:3,getWidth(t=Wt.DEFAULT_NOTATION_FONT_SCALE){return new Ut(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:()=>Wt.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},64:{common:{beam_count:4,getWidth(t=Wt.DEFAULT_NOTATION_FONT_SCALE){return new Ut(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:()=>Wt.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},128:{common:{beam_count:5,getWidth(t=Wt.DEFAULT_NOTATION_FONT_SCALE){return new Ut(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:()=>Wt.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}}},Wt.smufl={},Wt.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"},Wt.TIME4_4={num_beats:4,beat_value:4,resolution:Wt.RESOLUTION};class zt{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&&(Nt.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:zt.WIDTH,height:zt.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 Yt{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),h=t+i*Math.cos(n),l=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+","+h+","+l+"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 Ht={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};Nt.Merge(Ht.rect,t),Nt.Merge(Ht.path,t)}class Xt{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,s){const n=this.create("g");return this.groups.push(n),this.parent.appendChild(n),this.parent=n,t&&n.setAttribute("class",Nt.Prefix(t)),e&&n.setAttribute("id",Nt.Prefix(e)),i&&i.pointerBBox&&n.setAttribute("pointer-events","bounding-box"),s&&"isX"===s&&(n.style.transformOrigin="center",n.style.transformBox="content-box",n.style.transform="scale(1) translateY(-8px)"),n}closeGroup(t){if(t&&"transform"===t){const t=this.groups.pop();let e=t.getAttribute("class");e+=" vf-stopDot",t.setAttribute("class",e)}else if(t&&"rotate"===t){const t=this.groups.pop();t.style.transform="rotate(180deg)",t.style.transformBox="fill-box",t.style.transformOrigin="center";let e=t.getAttribute("class");e+=" vf-rotateArrow",t.setAttribute("class",e)}else 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 s=!1,n=!1,r="normal";"string"==typeof i&&(-1!==i.indexOf("italic")&&(i=i.replace(/italic/g,""),n=!0),-1!==i.indexOf("bold")&&(i=i.replace(/bold/g,""),s=!0),i=i.replace(/ /g,"")),r=n?"italic":r;const o={"font-family":t,"font-size":e+"pt","font-weight":i=void 0===(i=s?"bold":i)||""===i?"normal":i,"font-style":r};return this.fontSize=Number(e),Nt.Merge(this.attributes,o),Nt.Merge(this.state,o),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 Nt.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=Ht[t.nodeName];return Object.keys(e).forEach((s=>{var n;i&&i[s]||!s||!e[s]||"d"===s&&(null===(n=e[s])||void 0===n?void 0:n.indexOf("NaN"))>-1||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,s,n){s<0&&(e+=s,s*=-1);const r=this.create("rect");return void 0===n&&(n={fill:"none","stroke-width":this.lineWidth,stroke:this.attributes.stroke}),Nt.Merge(n,{x:t,y:e,width:i,height:s}),this.applyAttributes(r,n),this.add(r),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),h=t+i*Math.cos(n),l=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+" "+h+" "+l,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?(t={},Nt.Merge(t,this.attributes),t.stroke="none",i=t):(i=t,Nt.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=void 0){this.glow();const e=this.create("path"),i={};return Nt.Merge(i,this.attributes),t&&Nt.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 s={};Nt.Merge(s,this.attributes),s.stroke="none",s.x=e,s.y=i;const n=this.create("text");n.textContent=t,this.applyAttributes(n,s),this.add(n)}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 Vt=null;class jt{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 Vt}static set lastContext(t){Vt=t}static buildContext(t,e,i,s,n){const r=new jt(t,e);i&&s&&r.resize(i,s),n||(n="#FFF");const o=r.getContext();return o.setBackgroundFillStyle(n),jt.lastContext=o,o}static getCanvasContext(t,e,i,s){return jt.buildContext(t,jt.Backends.CANVAS,e,i,s)}static getRaphaelContext(t,e,i,s){return jt.buildContext(t,jt.Backends.RAPHAEL,e,i,s)}static getSVGContext(t,e,i,s){return jt.buildContext(t,jt.Backends.SVG,e,i,s)}static bolsterCanvasContext(t){return jt.USE_CANVAS_PROXY?new zt(t):(t.vexFlowCanvasContext=t,["clear","setFont","setRawFont","setFillStyle","setBackgroundFillStyle","setStrokeStyle","setShadowColor","setShadowBlur","setLineWidth","setLineCap","setLineDash","openGroup","closeGroup","getGroup"].forEach((e=>{t[e]=t[e]||zt.prototype[e]})),t)}static drawDashedLine(t,e,i,s,n,r){t.beginPath();const o=s-e,a=n-i,h=Math.atan2(a,o);let l=e,c=i;t.moveTo(e,i);let u=0,d=!0;for(;!(o<0?l<=s:l>=s)||!(a<0?c<=n:c>=n);){const e=r[u++%r.length],i=l+Math.cos(h)*e;l=o<0?Math.max(s,i):Math.min(s,i);const p=c+Math.sin(h)*e;c=a<0?Math.max(n,p):Math.min(n,p),d?t.lineTo(l,c):t.moveTo(l,c),d=!d}t.closePath(),t.stroke()}constructor(t,e){if(this.elementId=t,!this.elementId)throw new Nt.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===jt.Backends.CANVAS){if(!this.element.getContext)throw new Nt.RERR("BadElement",`Can't get canvas context from element: ${t}`);this.ctx=jt.bolsterCanvasContext(this.element.getContext("2d",{willReadFrequently:!0}))}else if(this.backend===jt.Backends.RAPHAEL)this.ctx=new Yt(this.element);else{if(this.backend!==jt.Backends.SVG)throw new Nt.RERR("InvalidBackend",`No support for backend: ${this.backend}`);this.ctx=new Xt(this.element)}}resize(t,e){if(this.backend===jt.Backends.CANVAS){if(!this.element.getContext)throw new Nt.RERR("BadElement",`Can't get canvas context from element: ${this.elementId}`);[t,e]=zt.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=jt.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 Kt extends It{static get CATEGORY(){return"stem"}static get UP(){return 1}static get DOWN(){return-1}static get WIDTH(){return Wt.STEM_WIDTH}static get HEIGHT(){return Wt.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)}setResetHeight(t){this.resetHeight=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 Kt.CATEGORY}getHeight(){const t=this.stem_direction===Kt.UP?this.stem_up_y_offset:this.stem_down_y_offset;return(this.y_bottom-this.y_top)*this.stem_direction+(Kt.HEIGHT-t+this.stem_extension)*this.stem_direction}getBoundingBox(){throw new Nt.RERR("NotImplemented","getBoundingBox() not implemented.")}getExtents(){const t=this.stem_direction===Kt.UP,e=[this.y_top,this.y_bottom],i=Kt.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 s=this.stem_direction;s===Kt.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 n=this.getHeight();!function(...t){Kt.DEBUG&&Nt.L("Vex.Flow.Stem",t)}("Rendering stem - ","Top Y: ",this.y_top,"Bottom Y: ",this.y_bottom);const r=this.isStemlet?n-this.stemletHeight*this.stem_direction:0;if(t.save(),this.applyStyle(t),t.beginPath(),t.setLineWidth(Kt.WIDTH),t.moveTo(e,i-r),t.lineTo(e,i-n-this.renderHeightAdjustment*s),t.svg){const e={class:Nt.Prefix("stem")};this.id&&(e.id=this.id),t.stroke(e)}else t.stroke();this.restoreStyle(t),t.restore()}}class $t extends It{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 Nt.RuntimeError("BadArguments","No notes provided for tuplet.");this.options=Nt.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||$t.LOCATION_TOP,Ue.AlignRestsToNotes(t,!0,!0),this.resolveGlyphs(),this.attach()}attach(){for(let t=0;t=1;)this.numerator_glyphs.unshift(new Ut("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 Ut("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===$t.LOCATION_BOTTOM),1,10*this.location),this.context.fillRect(this.x_pos+this.width,this.y_pos+(this.location===$t.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 qt(t){let e=0;return t.forEach((t=>{t.keyProps&&t.keyProps.forEach((t=>{e+=t.line-3}))})),e>=0?Kt.DOWN:Kt.UP}const Zt="L",Jt="B";class Qt extends It{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 Pt).parse(t)));{const e=parseInt(t.split("/")[0],10),i=parseInt(t.split("/")[1],10);if(e%3==0)return[new Pt(3,i)];if(i>4)return[new Pt(2,i)];if(i<=4)return[new Pt(1,i)]}return[new Pt(1,4)]}static applyAndGetBeams(t,e,i){return Qt.generateBeams(t.getTickables(),{groups:i,stem_direction:e})}static generateBeams(t,e){e||(e={}),e.groups&&e.groups.length||(e.groups=[new Pt(2,8)]);const i=e.groups.map((t=>{if(!t.multiply)throw new Nt.RuntimeError("InvalidBeamGroups","The beam groups must be an array of Vex.Flow.Fractions");return t.clone().multiply(Wt.RESOLUTION,1)})),s=t;let n=0,r=[],o=[];function a(){i.length-1>n?n+=1:n=0}!function(){let t=[];s.forEach((e=>{if(t=[],e.shouldIgnoreTicks())return r.push(o),void(o=t);o.push(e);const s=i[n].clone(),h=o.reduce(((t,e)=>e.getTicks().clone().add(t)),new Pt(0,1)),l=Wt.durationToNumber(e.duration)<8;l&&e.tuplet&&(s.numerator*=2),h.greaterThan(s)?(l||t.push(o.pop()),r.push(o),o=t,a()):h.equals(s)&&(r.push(o),o=t,a())})),o.length>0&&r.push(o)}(),function(){const t=[];r.forEach((i=>{let s=[];i.forEach(((i,n,r)=>{const o=0===n||n===r.length-1,a=r[n-1],h=!e.beam_rests&&i.isRest(),l=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;h||l||c||u?(s.length>0&&t.push(s),s=c?[i]:[]):s.push(i)})),s.length>0&&t.push(s)})),r=t}(),r.forEach((t=>{let i;if(e.maintain_stem_directions){const e=function(t){for(let e=0;e{t.setStemDirection(e)}))}(t,i)}));const h=r.filter((t=>{if(t.length>1){let e=!0;return t.forEach((t=>{t.getIntrinsicTicks()>=Wt.durationToTicks("4")&&(e=!1)})),e}return!1})),l=function(){const t=[];return r.forEach((e=>{let i=null;e.forEach((e=>{e.tuplet&&i!==e.tuplet&&(i=e.tuplet,t.push(i))}))})),t}(),c=[];return h.forEach((t=>{const i=new Qt(t);e.show_stemlets&&(i.render_options.show_stemlets=!0),e.secondary_breaks&&(i.render_options.secondary_break_ticks=Wt.durationToTicks(e.secondary_breaks)),!0===e.flat_beams&&(i.render_options.flat_beams=!0,i.render_options.flat_beam_offset=e.flat_beam_offset),c.push(i)})),l.forEach((t=>{const e=t.notes[0].stem_direction===Kt.DOWN?$t.LOCATION_BOTTOM:$t.LOCATION_TOP;t.setTupletLocation(e);let i=!1;for(let s=0;s=Wt.durationToTicks("4"))throw new Nt.RuntimeError("BadArguments","Beams can only be applied to notes shorter than a quarter note.");let i,s;for(this.stem_direction=Kt.UP,i=0;it+e.stem_direction),0);n=e>-1?Kt.UP:Kt.DOWN}for(i=0;it.getGlyph().beam_count));return t.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]),h=(i-s)/n;let l=Number.MAX_VALUE,c=0,u=0;for(let d=s;d<=i;d+=h){let i=0,s=0;for(let r=1;rs)&&(h=s,o=Math.min(...i.getYs()),a=i.getBeamCount())}let l=r/t.length;const c=s+a*(1.5*i),u=o+c*-e;e===Kt.DOWN&&lu&&(l=o-c),n+this.render_options.flat_beam_offset_per_beam>0?(e===Kt.DOWN&&l>n&&!this.render_options.flat_beams||e===Kt.UP&&l0){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,h=t[0],l=this.getBeamYToDraw(),c=h.getStemX();for(let u=0;u=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 o of this.notes)r[o.getAttribute("id")]=0;for(let o=0;o{t.getStave()||t.setStave(this.stave)})),this.preFormatted=!0),this}draw(t=this.context,e=this.stave){this.setRendered();let i=null;for(let s=0;s0&&i){const t=n.getBoundingBox();t&&i.mergeWith(t)}n.setContext(t),n.drawWithStyle()}this.boundingBox=i}}function ee(t,e,i,s,n){if(e!==ie.type.BOLD_DOUBLE_LEFT&&e!==ie.type.BOLD_DOUBLE_RIGHT)throw new Nt.RERR("InvalidConnector","A REPEAT_BEGIN or REPEAT_END type must be provided.");let r=3,o=3.5;e===ie.type.BOLD_DOUBLE_RIGHT&&(r=-5,o=3),t.fillRect(i+r,s,1,n-s),t.fillRect(i-2,s,o,n-s)}class ie extends It{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:ie.type.SINGLE_RIGHT,singleLeft:ie.type.SINGLE_LEFT,single:ie.type.SINGLE,double:ie.type.DOUBLE,brace:ie.type.BRACE,bracket:ie.type.BRACKET,boldDoubleLeft:ie.type.BOLD_DOUBLE_LEFT,boldDoubleRight:ie.type.BOLD_DOUBLE_RIGHT,thinDouble:ie.type.THIN_DOUBLE,none:ie.type.NONE}}constructor(t,e){super(),this.setAttribute("type","StaveConnector"),this.thickness=Wt.STAVE_LINE_THICKNESS,this.width=3,this.top_stave=t,this.bottom_stave=e,this.type=ie.type.DOUBLE,this.font={family:"times",size:16,weight:"normal"},this.x_shift=0,this.texts=[]}setType(t){return(t="string"==typeof t?ie.typeString[t]:t)>=ie.type.SINGLE_RIGHT&&t<=ie.type.NONE&&(this.type=t),this}setText(t,e){return this.texts.push({content:t,options:Nt.Merge({shift_x:0,shift_y:0},e)}),this}setFont(t){Nt.Merge(this.font,t)}setXShift(t){if("number"!=typeof t)throw Nt.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,s=this.width,n=this.top_stave.getX();(this.type===ie.type.SINGLE_RIGHT||this.type===ie.type.BOLD_DOUBLE_RIGHT||this.type===ie.type.THIN_DOUBLE)&&(n=this.top_stave.getX()+this.top_stave.width);let r=i-e;switch(this.type){case ie.type.SINGLE:case ie.type.SINGLE_LEFT:case ie.type.SINGLE_RIGHT:s=1;break;case ie.type.DOUBLE:n-=this.width+2;break;case ie.type.BRACE:{s=12;const n=this.top_stave.getX()-2+this.x_shift,o=e,a=n,h=i,l=n-s,c=o+r/2,u=l-.9*s,d=o+.2*r,p=n+1.1*s,f=c-.135*r,b=p,g=c+.135*r,m=u,_=h-.2*r,y=l-s,x=_,v=n+.4*s,w=c+.135*r,S=v,E=c-.135*r,T=y,k=d;t.beginPath(),t.moveTo(n,o),t.bezierCurveTo(u,d,p,f,l,c),t.bezierCurveTo(b,g,m,_,a,h),t.bezierCurveTo(y,x,v,w,l,c),t.bezierCurveTo(S,E,T,k,n,o),t.fill(),t.stroke();break}case ie.type.BRACKET:e-=4,i+=4,r=i-e,Ut.renderGlyph(t,n-5,e-3,40,"v1b",!0),Ut.renderGlyph(t,n-5,i+3,40,"v10",!0),n-=this.width+2;break;case ie.type.BOLD_DOUBLE_LEFT:ee(t,this.type,n+this.x_shift,e,i);break;case ie.type.BOLD_DOUBLE_RIGHT:ee(t,this.type,n,e,i);break;case ie.type.THIN_DOUBLE:s=1;break;case ie.type.NONE:break;default:throw new Nt.RERR("InvalidType",`The provided StaveConnector.type (${this.type}) is invalid`)}this.type!==ie.type.BRACE&&this.type!==ie.type.BOLD_DOUBLE_LEFT&&this.type!==ie.type.BOLD_DOUBLE_RIGHT&&this.type!==ie.type.NONE&&t.fillRect(n,e,s,r),this.type===ie.type.THIN_DOUBLE&&t.fillRect(n-3,e,s,r),t.save(),t.lineWidth=2,t.setFont(this.font.family,this.font.size,this.font.weight);for(let o=0;o0){const s=f.space.deviation,n=s>=0?"+":"";t.setFillStyle("red"),t.fillText(n+Math.round(s),o+e.getXShift(),i-10)}t.restore()}constructor(t){if(super(),this.setAttribute("type","Note"),!t)throw new Nt.RuntimeError("BadArguments","Note must have valid initialization data to identify duration and type.");const e=Wt.parseNoteStruct(t);if(!e)throw new Nt.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,this.DYMusicScoreType=t.DYMusicScoreType,t.duration_override?this.setDuration(t.duration_override):this.setIntrinsicTicks(e.ticks),this.modifiers=[],this.glyph=Wt.getGlyphProps(this.duration,this.noteType),this.customGlyphs=this.customTypes.map((t=>Wt.getGlyphProps(this.duration,t))),this.positions&&("object"!=typeof this.positions||!this.positions.length))throw new Nt.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:ne.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 ne.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.glyph.getWidth(this.render_options.glyph_font_scale):15}setYs(t){return this.ys=t,this}getYs(){if(0===this.ys.length)throw new Nt.RERR("NoYValues","No Y-values calculated for this note.");return this.ys}getYForTopText(t){if(!this.stave)throw new Nt.RERR("NoStave","No stave attached to this note.");return this.stave.getYForTopText(t)}getBoundingBox(){return null}getVoice(){if(!this.voice)throw new Nt.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 Nt.RERR("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");return{x:this.getAbsoluteX(),y:this.ys[0]}}getMetrics(){if(!this.preFormatted)throw new Nt.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 Nt.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 Nt.RERR("NoTickContext","Note needs a TickContext assigned for an X-Value");return this.tickContext.getX()+this.x_shift}getAbsoluteX(){if(!this.tickContext)throw new Nt.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()&&("jianpu"===this.DYMusicScoreType||(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 re extends ne{static get CATEGORY(){return"notehead"}constructor(t){if(super(t),this.setAttribute("type","NoteHead"),this.index=t.index,this.x_shift=t.x_shift||0,this.x=(t.x||0)+this.x_shift,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||ce.STEM_UP,this.line=t.line,this.glyph=Wt.getGlyphProps(this.duration,this.note_type),!this.glyph)throw new Nt.RuntimeError("BadArguments",`No glyph found for duration '${this.duration}' and type '${this.note_type}'`);this.glyph_code=this.glyph.code_head,this.x_shift_ledger_rest=0,this.y_shift_ledger_rest=0,this.x_shift=t.x_shift||0,this.glyph.rest&&(this.line>5||this.line<0)&&(this.isLedgerLinedRest=!0,"h"===this.duration?(t.custom_glyph_code="rhl",this.x_shift_ledger_rest-=4):"w"===this.duration&&(t.custom_glyph_code="rwl",this.x_shift_ledger_rest-=4,this.y_shift_ledger_rest=-5)),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.stem_up_y_shift=t.stem_up_y_shift||0,this.stem_down_y_shift=t.stem_down_y_shift||0),this.style=t.style,this.slashed=t.slashed,Nt.Merge(this.render_options,{glyph_font_scale:t.glyph_font_scale||Wt.DEFAULT_NOTATION_FONT_SCALE,stroke_px:3}),this.setWidth(this.glyph.getWidth(this.render_options.glyph_font_scale))}getCategory(){return re.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=Kt.WIDTH/2;return t+(this.displaced?(this.width-e)*this.stem_direction:0)}getBoundingBox(){if(!this.preFormatted)throw new Nt.RERR("UnformattedNote","Can't call getBoundingBox on an unformatted note.");const t=this.stave.getSpacingBetweenLines(),e=t/2,i=this.y-e;return new Wt.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(),i=this.y;this.custom_glyph&&(e+=this.x_shift_ledger_rest,this.stem_direction===Kt.UP?(e+=this.stem_up_x_offset,i+=this.stem_up_y_shift||0):this.stem_direction===Kt.DOWN&&(e+=this.stem_down_x_offset,i+=this.stem_down_y_shift||0),i+=this.y_shift_ledger_rest),function(...t){re.DEBUG&&Nt.L("Vex.Flow.NoteHead",t)}("Drawing note head '",this.note_type,this.duration,"' at",e,i);const s=this.stem_direction,n=this.render_options.glyph_font_scale;if(this.style&&this.applyStyle(t),"s"===this.note_type){const n=this.stave.getSpacingBetweenLines();!function(t,e,i,s,n,r){const o=Wt.SLASH_NOTEHEAD_WIDTH;t.save(),t.setLineWidth(Wt.STEM_WIDTH);let a=!1;if(Wt.durationToNumber(e)>2&&(a=!0),a||(i-=Wt.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(),Wt.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 he extends ae{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 u=0;ue.line-t.line));let r=i,o=0,a=null,h=null,l=null,c=0;for(let u=0;uo?r:o,a=d,h=e}return e.right_shift+=o,!0}constructor(){super(),this.setAttribute("type","Dot"),this.note=null,this.index=null,this.position=ae.Position.RIGHT,this.radius=2,this.setWidth(5),this.dot_shiftY=0}getCategory(){return he.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 Nt.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+1);const i=e.x+this.x_shift+this.width-this.radius;let s=this.dot_shiftY*t;this.note&&"jianpu"==this.note.DYMusicScoreType&&(s=-5);const n=e.y+this.y_shift+s,r=this.context;r.beginPath(),r.arc(i,n,this.radius,0,2*Math.PI,!1),r.fill()}}function le(t,e,i){if(t.note.shiftRestVerticalDisabled)return;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 ce extends oe{static get CATEGORY(){return"stavenotes"}static get STEM_UP(){return Kt.UP}static get STEM_DOWN(){return Kt.DOWN}static get DEFAULT_LEDGER_LINE_OFFSET(){return 3}static renderVibrato(t,e,i,s){let{width:n,height:r,wave_width:o,wave_girth:a,wave_height:h,stem_direction:l}=s;const c=Math.floor(n/o);let u=r/(c/2)*l;0==u&&(l=1,u=.3),t.beginPath(),t.moveTo(e,i+a);for(let d=0;d2?i[1]:null;let a=n>2?i[2]:i[1];2!==n||-1!==r.stemDirection||1!==a.stemDirection||r.isrest||a.isRest||(r=i[1],a=i[0]);const h=Math.max(r.voice_shift,a.voice_shift);let l,c=0;if(2===n){const t=r.stemDirection===a.stemDirection?0:.5;if(r.stemDirection===a.stemDirection&&r.minLine<=a.maxLine&&(r.isrest||(l=Math.abs(r.line-(a.maxLine+.5)),l=Math.max(l,r.stemMin),r.minLine=r.line-l,r.note.setStemLength(10*l))),r.minLine<=a.maxLine+t)if(r.isrest)le(r,a,1),r.note.hasLedgerLinedRest&&(r.note.shiftRestVerticalDisabled=!0);else if(a.isrest)le(a,r,-1),a.note.hasLedgerLinedRest&&(a.note.shiftRestVerticalDisabled=!0);else{c=h;const t=Math.abs(r.line-a.line);let e=0,i=0;"h"===r.note.duration?e++:"w"===r.note.duration&&i++,"h"===a.note.duration?e++:"w"===a.note.duration&&i++;let n=1===e||1===i||r.note.dots!==a.note.dots;if(s&&(n=n||2===i),0===t&&n){if(a.note.setXShift(c),r.note.dots>0){let t=0;for(const e of r.note.modifiers)if(e instanceof he&&(t++,e.setYShift(-10*(a.maxLine-r.line+1)),t===r.note.dots))break}}else t<1&&t>0?a.note.setXShift(c):r.note.voice!==a.note.voice&&r.stemDirection===a.stemDirection&&(r.line>a.line?1===r.stemDirection?a.note.renderFlag=!1:r.note.renderFlag=!1:a.line>r.line?1===a.stemDirection?r.note.renderFlag=!1:a.note.renderFlag=!1:1===a.stemDirection&&(a.stemDirection=-1,a.note.setStemDirection(-1)))}return!0}return null!==o&&o.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.vibrato=null,this.slideNote=null,this.glyph=Wt.getGlyphProps(this.duration,this.noteType),!this.glyph)throw new Nt.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.paddingRight=0,this.note_heads=[],this.modifiers=[],Nt.Merge(this.render_options,{glyph_font_scale:t.glyph_font_scale||Wt.DEFAULT_NOTATION_FONT_SCALE,stroke_px:t.stroke_px||ce.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}setVibrato(t){this.vibrato=t}setSlideNote(t){this.slideNote=t}getCategory(){return ce.CATEGORY}buildStem(){this.setStem(new Kt({hide:!!this.isRest()})),this.stem.id=Nt.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===Kt.UP?(i=0,s=e.length,n=1):t===Kt.DOWN&&(i=e.length-1,s=-1,n=-1);for(let h=i;h!==s;h+=n){const e=this.keyProps[h],i=e.line;null===r?r=i:(o=Math.abs(r-i),0===o||.5===o?a=!a:(a=!1,this.use_default_head_x=!0)),r=i;const s=new re({duration:this.duration,note_type:this.noteType,displaced:a,stem_direction:t,custom_glyph_code:e.code,glyph_font_scale:this.render_options.glyph_font_scale,x_shift:e.shift_right,stem_up_x_offset:e.stem_up_x_offset,stem_down_x_offset:e.stem_down_x_offset,stem_up_y_shift:e.stem_up_y_shift,stem_down_y_shift:e.stem_down_y_shift,line:e.line});s.isLedgerLinedRest&&(this.hasLedgerLinedRest=!0),this.note_heads[h]=s}}autoStem(){this.minLine=this.keyProps[0].line,this.maxLine=this.keyProps[this.keyProps.length-1].line;const t=(this.minLine+this.maxLine)/2<3?Kt.UP:Kt.DOWN;this.setStemDirection(t)}calculateKeyProps(){let t=null;for(let e=0;e0&&(this.keyProps[e-1].displaced=!0)),t=r,this.keyProps.push(n)}t=-1/0,this.keyProps.forEach((e=>{e.linet.line-e.line))}getBoundingBox(){if(!this.preFormatted)throw new Nt.RERR("UnformattedNote","Can't call getBoundingBox on an unformatted note.");const{width:t,modLeftPx:e,extraLeftPx:i}=this.getMetrics(),s=this.getAbsoluteX()-e-i-this.paddingRight;let n=0,r=0;const o=this.getStave().getSpacingBetweenLines()/2,a=2*o;if(this.isRest()){const t=this.ys[0],e=Wt.durationToFraction(this.duration);e.equals(1)||e.equals(2)?(n=t-o,r=t+o):(n=t-this.glyph.line_above*a,r=t+this.glyph.line_below*a)}else if(this.glyph.stem){const t=this.getStemExtents();t.baseY+=o*this.stem_direction,n=Math.min(t.topY,t.baseY),r=Math.max(t.topY,t.baseY)}else{n=null,r=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()+(t=>Kt.WIDTH/(2*-t.getStemDirection()))(this)}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),s=Math.min(t,e);t=Nt.MidLine(i,s)}return t}getModifierStartXY(t,e,i){if(i=i||{},!this.preFormatted)throw new Nt.RERR("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");if(0===this.ys.length)throw new Nt.RERR("NoYValues","No Y-Values calculated for this note.");const{ABOVE:s,BELOW:n,LEFT:r,RIGHT:o}=ae.Position;let a=0;return t===r?a=-2:t===o?(a=this.getGlyphWidth()+this.x_shift+2,this.stem_direction===Kt.UP&&this.hasFlag()&&(i.forceFlagRight||((t,e)=>e===(t.getStemDirection()===Kt.UP?t.keyProps.length-1:0))(this,e))&&(a+=this.flag.getMetrics().width)):t!==n&&t!==s||(a=this.getGlyphWidth()/2),{x:this.getAbsoluteX()+a,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 e=0;e{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=o&&e?f-i:e?p-i:d-i;const h=e&&o?r:n;s.beginPath(),s.moveTo(a,t),s.lineTo(a+h,t),s.stroke()},g={...t.getStyle()||{},...this.getLedgerLineStyle()||{}};this.applyStyle(s,g);for(let m=6;m<=o;++m){const e=null!==p&&m<=l,i=null!==d&&m<=h;b(t.getYForNote(m),e,i)}for(let m=0;m>=a;--m){const e=null!==p&&m>=u,i=null!==d&&m>=c;b(t.getYForNote(m),e,i)}this.restoreStyle(s,g)}drawVibrato(){if(this.vibrato){const t=this.context,e=this.vibrato.getNoteHeadEndX()+2;let{y_bottom:i}=this.vibrato.getNoteHeadBounds(),{y_top:s}=this.getNoteHeadBounds();const n=i1&&"Accidental"===a.getAttribute("type")&&this.modifiers.findIndex((t=>"GraceNoteGroup"===t.getAttribute("type")))>=0)continue;if(!a.note||"jianpu"!=a.note.DYMusicScoreType||"Dot"!==a.getAttribute("type")||a.note.formatterMetrics.duration){if(a.note&&"jianpu"==a.note.DYMusicScoreType&&"Dot"===a.getAttribute("type"))try{a.note.getModifierStartXY(a.position,0,{forceFlagRight:!0}).x-a.note.x<9&&(a.x_shift+=7)}catch(r){}var i,s,n;a.note&&"jianpu"==a.note.DYMusicScoreType&&("v28"!==(null==a||null===(i=a.articulation)||void 0===i?void 0:i.code)&&"v42"!==(null==a||null===(s=a.articulation)||void 0===s?void 0:s.code)||(e="transform")),a.note&&"staff"==a.note.DYMusicScoreType&&"v28"===(null==a||null===(n=a.articulation)||void 0===n?void 0:n.code)&&1==this.stem_direction&&(e="rotate"),h.applyStyle(t,l),a.setContext(t),a.drawWithStyle(),h.restoreStyle(t,l)}}}t.closeGroup(e),this.drawVibrato(),this.drawSlide()}drawFlag(){const{stem:t,beam:e,context:i}=this;if(!i)throw new Nt.RERR("NoCanvasContext","Can't draw without a canvas context.");const s=null===e&&this.renderFlag;if(this.getGlyph().flag&&s){const{y_top:s,y_bottom:n}=this.getNoteHeadBounds(),r=t.getHeight(),o=this.getStemX();let a=this.getStemDirection()===Kt.DOWN?s-r+2:n-r-2;if(t&&!e){const t=this.keyProps[0].line;(t>6.5||t<-.5)&&(a+=t>6.5?10*(t-6.5):10*(t+.5))}i.openGroup("flag",null,{pointerBBox:!0}),this.applyStyle(i,this.getFlagStyle()||!1),this.flag.render(i,o,a),this.restoreStyle(i,this.getFlagStyle()||!1),i.closeGroup()}}drawNoteHeads(){this.note_heads.forEach((t=>{this.context.openGroup("notehead",null,{pointerBBox:!0});try{if(this.isRest()&&"w"===this.duration){const e=this.stave.options.line_config.filter((t=>t.visible)).length;4===this.keyProps[0].line&&e<5&&e>1&&t.setY(t.getY()+10),1===e&&t.setLine(3)}if(this.isRest()&&"q"===this.duration){const e=this.stave.options.line_config.filter((t=>t.visible)).length;3===this.keyProps[0].line&&1===e&&t.setY(t.getY()-10)}}catch(e){}t.setContext(this.context).draw(),this.context.closeGroup()}))}drawStem(t){if(!this.context)throw new Nt.RERR("NoCanvasContext","Can't draw without a canvas context.");t&&this.setStem(new Kt(t)),this.stem.id=Nt.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 Nt.RERR("NoCanvasContext","Can't draw without a canvas context.");if(!this.stave)throw new Nt.RERR("NoStave","Can't draw without a stave.");if(0===this.ys.length)throw new Nt.RERR("NoYValues","Can't draw note without Y values.");const t=this.stave.getLines();if(2===t||3===t||4===t)for(let s=0;st.setX(e))),this.stem){let t=this.getStemX();const e=this.keyProps[0].line;(e>6.5||e<-.5)&&(this.beam||(this.stem.renderHeightAdjustment=e>6.5?10*(e-6.5):10*Math.abs(e+.5))),this.stem.setNoteHeadXBounds(t,t)}!function(...t){ce.DEBUG&&Nt.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}),i&&this.drawStem(),this.drawNoteHeads(),this.drawFlag(),this.context.closeGroup(),this.drawModifiers(),this.context.closeGroup(),this.restoreStyle(),this.setRendered()}}class ue extends ae{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 f=0;fe.line-t.line));let h=0,l=0,c=0,u=0,d=null,p=null;for(let f=0;fc?t:c):r===ae.Position.RIGHT&&(o.setXShift(l),t=a+_,u=t>u?t:u),d=b,p=e}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=ae.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 ue.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 Nt.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,s=e.y+this.y_shift+this.y_offset+5;switch(this.position){case ae.Position.ABOVE:i-=4,s-=12;break;case ae.Position.BELOW:i-=2,s+=10;break;case ae.Position.LEFT:i-=this.width;break;case ae.Position.RIGHT:i+=1;break;default:throw new Nt.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,s),t.restore()}}class de{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:de.scales.major,m:de.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>=de.NUM_TONES)}isValidIntervalValue(t){return this.isValidNoteValue(t)}getNoteParts(t){if(!t||t.length<1)throw new Nt.RERR("BadArguments","Invalid note name: "+t);if(t.length>3)throw new Nt.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 Nt.RERR("BadArguments","Invalid note name: "+t)}getKeyParts(t){if(!t||t.length<1)throw new Nt.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 Nt.RERR("BadArguments",`Invalid key: ${t}`)}getNoteValue(t){const e=de.noteValues[t];if(null==e)throw new Nt.RERR("BadArguments",`Invalid note name: ${t}`);return e.int_val}getIntervalValue(t){const e=de.intervals[t];if(null==e)throw new Nt.RERR("BadArguments",`Invalid interval name: ${t}`);return e}getCanonicalNoteName(t){if(!this.isValidNoteValue(t))throw new Nt.RERR("BadArguments",`Invalid note value: ${t}`);return de.canonical_notes[t]}getCanonicalIntervalName(t){if(!this.isValidIntervalValue(t))throw new Nt.RERR("BadArguments",`Invalid interval value: ${t}`);return de.diatonic_intervals[t]}getRelativeNoteValue(t,e,i){if(null==i&&(i=1),1!==i&&-1!==i)throw new Nt.RERR("BadArguments",`Invalid direction: ${i}`);let s=(t+i*e)%de.NUM_TONES;return s<0&&(s+=de.NUM_TONES),s}getRelativeNoteName(t,e){const i=this.getNoteParts(t),s=this.getNoteValue(i.root);let n=e-s;if(Math.abs(n)>de.NUM_TONES-3){let i=1;n>0&&(i=-1);const r=(e+1+(s+1))%de.NUM_TONES*i;if(Math.abs(r)>2)throw new Nt.RERR("BadArguments",`Notes not related: ${t}, ${e})`);n=r}if(Math.abs(n)>2)throw new Nt.RERR("BadArguments",`Notes not related: ${t}, ${e})`);let r=i.root;if(n>0)for(let o=1;o<=n;++o)r+="#";else if(n<0)for(let o=-1;o>=n;--o)r+="b";return r}getScaleTones(t,e){const i=[t];let s=t;for(let n=0;nt.getMetrics().width;class be extends ae{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 b=0;be.line-t.line));const a=[];let h=0,l=null;for(let b=0;bh?t.shift:h,l=t.line}let c=0;for(let b=0;ba[e+t],n=t=>t.map(s),r=(t,e)=>{const[i,s]=n([t,e]).map((t=>t.line));return i-s},o=(...t)=>t.map(n).every((t=>!this.checkCollision(...t))),h=i-e+1;let l,u,d=this.checkCollision(a[e],a[i])?"a":"b";switch(h){case 3:"a"===d&&.5===r(1,2)&&.5!==r(0,1)&&(d="second_on_bottom");break;case 4:o([0,2],[1,3])&&(d="spaced_out_tetrachord");break;case 5:"b"===d&&o([1,3])&&(d="spaced_out_pentachord",o([0,2],[2,4])&&(d="very_spaced_out_pentachord"));break;case 6:o([0,3],[1,4],[2,5])&&(d="spaced_out_hexachord"),o([0,2],[2,4],[1,3],[3,5])&&(d="very_spaced_out_hexachord")}if(h>=7){let t=2,e=!0;for(;!0===e;){e=!1;for(let i=0;i+tu?c:u}else for(l=b;l<=i;l++)u=Wt.accidentalColumnsTable[h][d][l-b],a[l].column=u,c=c>u?c:u;b=i}const u=[],d=[];for(let b=0;b<=c;b++)u[b]=0,d[b]=0;u[0]=h+i,d[0]=h+i,a.forEach((t=>{t.width>u[t.column]&&(u[t.column]=t.width)}));for(let b=1;b{let e=0;const i=f+t.numAcc;for(;f0?(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 Pt(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 n=new de;e||(e="C");const r=n.createScaleMap(e);i.forEach((t=>{const e=s[t],i=[],o=t=>{t.isRest()||t.shouldIgnoreTicks()||(t.keys.forEach(((e,s)=>{const o=n.getNoteParts(e.split("/")[0]),a=o.accidental||"n",h=o.root+a,l=r[o.root]===h,c=i.indexOf(h)>-1;if(!l||l&&c){r[o.root]=h;const e=new be(a);t.addAccidental(s,e),i.push(h)}})),t.getModifiers().forEach((t=>{"gracenotegroups"===t.getCategory()&&t.getGraceNotes().forEach(o)})))};e.forEach(o)}))}constructor(t=null){if(super(),this.setAttribute("type","Accidental"),pe("New accidental: ",t),this.note=null,this.index=null,this.type=t,this.position=ae.Position.LEFT,this.render_options={font_scale:38,stroke_px:3,parenLeftPadding:2,parenRightPadding:2},this.accidental=Wt.accidentalCodes(this.type),!this.accidental)throw new Nt.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 Ut(this.accidental.code,t),this.glyph.setOriginX(1),this.cautionary&&(this.parenLeft=new Ut(Wt.accidentalCodes("{").code,t),this.parenRight=new Ut(Wt.accidentalCodes("}").code,t),this.parenLeft.setOriginX(1),this.parenRight.setOriginX(1))}getCategory(){return be.CATEGORY}getWidth(){const t=this.cautionary?fe(this.parenLeft)+fe(this.parenRight)+this.render_options.parenLeftPadding+this.render_options.parenRightPadding:0;return fe(this.glyph)+t}setNote(t){if(!t)throw new Nt.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:s,index:n,cautionary:r,x_shift:o,y_shift:a,glyph:h,parenLeft:l,parenRight:c,render_options:{parenLeftPadding:u,parenRightPadding:d}}=this;if(this.checkContext(),!s||null==n)throw new Nt.RERR("NoAttachedNote","Can't draw accidental without a note and index.");const p=s.getModifierStartXY(i,n);let f=p.x+o;const b=p.y+a;pe("Rendering: ",e,f,b),r?(c.render(t,f,b),f-=fe(c),f-=d,f-=this.accidental.parenRightPaddingAdjustment,h.render(t,f,b),f-=fe(h),f-=u,l.render(t,f,b)):h.render(t,f,b),this.setRendered()}}class ge extends ae{static get CATEGORY(){return"notesubgroup"}static format(t,e){if(!t||0===t.length)return!1;let i=0;for(let s=0;s{t.ignore_ticks=!1})),this.width=0,this.preFormatted=!1,this.formatter=new Ue,this.voice=new te({num_beats:4,beat_value:4,resolution:Wt.RESOLUTION}).setStrict(!1),this.voice.addTickables(this.subNotes),this}getCategory(){return ge.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 Nt.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 me extends It{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:15,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 Nt.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 Nt.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 Nt.RERR("BadArguments","No Y-values to render");const e=this.context;let i=this.render_options.cp1,s=this.render_options.cp2;Math.abs(t.last_x_px-t.first_x_px)<10&&(i=2,s=8);const n=this.render_options.first_x_shift,r=this.render_options.last_x_shift,o=this.render_options.y_shift*t.direction;for(let a=0;au&&Math.abs(l-u)<10?-6:0;if(this.first_note&&"jianpu"===this.first_note.DYMusicScoreType){if("TabTie"===this.getAttribute("type"))continue;l1){const e=new Qt(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){ye.DEBUG&&Nt.L("Vex.Flow.GraceNoteGroup",t)}("Drawing grace note group for:",t),!t||null===this.index)throw new Nt.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()===ce.CATEGORY,i=e?me:_e;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 xe extends ae{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 ce){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=Nt.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=ae.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 xe.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 Nt.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,s=t.y;const n=t.x-5,r=this.note.stave.options.spacing_between_lines_px,o=this.getModifierContext().getModifiers(this.note.getCategory());for(let d=0;de.line-t.line));let p=0,f=0,b=0,g=null,m=null;for(r=0;rf?t:f):h===ae.Position.RIGHT&&(o.setXShift(p),t+=c,b=t>b?t:b),g=e,m=a}return e.left_shift+=f,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=ae.Position.ABOVE,this.x_shift=0,this.y_shift=0,this.x_offset=0,this.y_offset=0,this.dashed=!0,this.leg=jt.LineEndType.NONE,this.radius=8,this.font={family:"sans-serif",size:10,weight:"bold"}}getCategory(){return ve.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>=jt.LineEndType.NONE&&t<=jt.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 Nt.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 s=i.x+this.x_shift+this.x_offset,n=i.y+this.y_shift+this.y_offset;switch(this.position){case ae.Position.ABOVE:case ae.Position.BELOW:{const t=this.note.getStemExtents();let s=t.topY,r=t.baseY+2;this.note.stem_direction===ce.STEM_DOWN&&(s=t.baseY,r=t.topY-2),n=this.position===ae.Position.ABOVE?this.note.hasStem()?s-1.75*e:i.y-1.75*e:this.note.hasStem()?r+1.5*e:i.y+1.75*e,n+=this.y_shift+this.y_offset;break}case ae.Position.LEFT:s-=this.radius/2+5;break;case ae.Position.RIGHT:s+=this.radius/2+6;break;default:throw new Nt.RERR("InvalidPosition",`The position ${this.position} is invalid`)}t.save(),t.beginPath(),t.arc(s,n,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 r=s-t.measureText(this.string_number).width/2;if(t.fillText(""+this.string_number,r,n+4.5),null!=this.last_note){const e=this.last_note.getStemX()-this.note.getX()+5;let i,r;switch(t.strokeStyle="#000000",t.lineCap="round",t.lineWidth=.6,this.dashed?jt.drawDashedLine(t,s+10,n,s+e,n,[3,3]):jt.drawDashedLine(t,s+10,n,s+e,n,[3,0]),this.leg){case jt.LineEndType.UP:i=-10,r=this.dashed?[3,3]:[3,0],jt.drawDashedLine(t,s+e,n,s+e,n+i,r);break;case jt.LineEndType.DOWN:i=10,r=this.dashed?[3,3]:[3,0],jt.drawDashedLine(t,s+e,n,s+e,n+i,r)}}t.restore()}}class we extends se{static getNextContext(t){const e=t.tContexts,i=e.indexOf(t);return e[i+1]}constructor(){super(),this.setAttribute("type","TickContext"),this.currentTick=new Pt(0,1),this.maxTicks=new Pt(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),ke=(t,e)=>e===Se?t<=5:t>=1,Ce=(t,e)=>ke(t,e)?e===Se?Math.ceil:Math.floor:Math.round,Ae=t=>{const e=t.getCategory();return"stavenotes"===e||"gracenotes"===e},Re=t=>{const e=t.getCategory();return"tabnotes"===e||"numberednotes"===e};class Ne extends ae{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)=>Te(Ce(e,i),t.glyph.getMetrics().height/10+.5);t.filter((t=>t.getPosition()===Se)).forEach((t=>{t.setTextLine(e.top_text_line),e.top_text_line+=i(t,e.top_text_line,Se)})),t.filter((t=>t.getPosition()===Ee)).forEach((t=>{t.setTextLine(e.text_line),e.text_line+=i(t,e.text_line,Ee)}));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=ae.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=Ee,this.render_options={font_scale:38},this.breathMarkDistance=.8,this.articulation=Wt.articulationCodes(this.type),"abr"===this.type&&(this.articulation={code:"v6c",between_lines:!1}),!this.articulation)throw new Nt.RERR("ArgumentError",`Articulation not found: ${this.type}`);this.glyph=new Ut(this.articulation.code,this.render_options.font_scale),this.setWidth(this.glyph.getMetrics().width)}getCategory(){return Ne.CATEGORY}draw(){const{note:t,index:e,position:i,glyph:s,articulation:{between_lines:n},text_line:r,context:o}=this;if(this.checkContext(),!t||null==e)throw new Nt.RERR("NoAttachedNote","Can't draw Articulation without a note and index.");this.setRendered();const a=t.getStave(),h=a.getSpacingBetweenLines(),l="tabnotes"===t.getCategory();let{x:c}=t.getModifierStartXY(i,e);if("abr"===this.type){let e=0;const i=t.getTickContext(),s=we.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}if(c+=e,c>a.end_x){const t=a.start_x+n;c=t+(a.end_x-t)*this.breathMarkDistance}}const u=this.getXShift();u&&(c+=u);const d=!n||l,p=((t,e)=>{const i=e===Se&&t.getStemDirection()===Kt.UP||e===Ee&&t.getStemDirection()===Kt.DOWN;return Ae(t)?t.hasStem()&&i?.5:1:t.hasStem()&&i?1:0})(t,i);let f={[Se]:()=>{s.setOrigin(.5,1);const e=((t,e)=>{const i=t.getStave(),s=t.getStemDirection(),{topY:n,baseY:r}=t.getStemExtents();if(Ae(t))return t.hasStem()?s===Kt.UP?n:r:Math.min(...t.getYs());if(Re(t))return t.hasStem()&&s===Kt.UP?n:i.getYForTopText(e);throw new Nt.RERR("UnknownCategory","Only can get the top and bottom ys of stavenotes and tabnotes")})(t,r)-(r+p)*h+(this.y_shift||0);return d?Math.min(a.getYForTopText(Ne.INITIAL_OFFSET),e):e},[Ee]:()=>{s.setOrigin(.5,0);const e=((t,e)=>{const i=t.getStave(),s=t.getStemDirection(),{topY:n,baseY:r}=t.getStemExtents();if(Ae(t))return t.hasStem()?s===Kt.UP?r:n:Math.max(...t.getYs());if(Re(t))return t.hasStem()?s===Kt.UP?i.getYForBottomText(e):n:i.getYForBottomText(e);throw new Nt.RERR("UnknownCategory","Only can get the top and bottom ys of stavenotes and tabnotes")})(t,r)+(r+p)*h;return d?Math.max(a.getYForBottomText(Ne.INITIAL_OFFSET),e):e}}[i]();if(!l){const r=i===Se?-1:1,o=l?t.positions[e].str:t.getKeyProps()[e].line,a=(t.getYs()[e]-f)/h+o,c=((t,e,i,s)=>{const n=Te(Ce(e,i),e);return t&&ke(n,i)&&n%1==0?n+.5*-s:n})(n,a,i,r);ke(c,i)&&s.setOrigin(.5,.5),f+=Math.abs(c-a)*h*r}!function(...t){Ne.DEBUG&&Nt.L("Vex.Flow.Articulation",t)}(`Rendering articulation at (x: ${c}, y: ${f})`),s.render(o,c,f)}}class Pe extends ae{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 a=0;a{Ie("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=>{Ie("Postformatting ModifierContext: ",t.CATEGORY),t.postFormat(this.getModifiers(t.CATEGORY),this)}))}}function Fe(t,e){var i,s;const n=t[e+1];return n&&null!=n&&null!==(i=n.keys)&&void 0!==i&&i.includes("b/4")||null!=n&&null!==(s=n.keys)&&void 0!==s&&s.includes("r/4")?Fe(t,e+1):n}function De(t,e,i,s){let n=e;for(i+=1;i{if(e.getMode()===te.Mode.STRICT&&!e.isComplete())throw new Nt.RERR("IncompleteVoice","Voice does not have enough notes.");return Math.max(t,Pt.LCM(t,e.getResolutionMultiplier()))}),1),n={},r=[],o=[];return t.forEach((t=>{const a=new Pt(0,s);t.getTickables().forEach((t=>{const s=a.numerator;if(!n[s]){const t=new e;o.push(t),n[s]=t}i(t,n[s]),r.push(s),a.add(t.getTicks())}))})),{map:n,array:o,list:Nt.SortAndUnique(r,((t,e)=>t-e),((t,e)=>t===e)),resolutionMultiplier:s}}class Ue{static SimpleFormat(t,e=0,{paddingBetween:i=10}={}){t.reduce(((t,e)=>{e.addToModifierContext(new Be);const s=(new we).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+ne.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,s){const n={auto_beam:!1,align_rests:!1};"object"==typeof s?Nt.Merge(n,s):"boolean"==typeof s&&(n.auto_beam=s);const r=new te(Wt.TIME4_4).setMode(te.Mode.SOFT).addTickables(i),o=n.auto_beam?Qt.applyAndGetBeams(r):[];return(new Ue).joinVoices([r],{align_rests:n.align_rests}).formatToStave([r],e,{align_rests:n.align_rests,stave:e}),r.setStave(e).draw(t,e),o.forEach((e=>e.setContext(t).draw())),r.getBoundingBox()}static FormatAndDrawTab(t,e,i,s,n,r,o){const a={auto_beam:r,align_rests:!1};"object"==typeof o?Nt.Merge(a,o):"boolean"==typeof o&&(a.auto_beam=o);const h=new te(Wt.TIME4_4).setMode(te.Mode.SOFT).addTickables(n),l=new te(Wt.TIME4_4).setMode(te.Mode.SOFT).addTickables(s),c=a.auto_beam?Qt.applyAndGetBeams(h):[];(new Ue).joinVoices([h],{align_rests:a.align_rests}).joinVoices([l]).formatToStave([h,l],i,{align_rests:a.align_rests}),h.draw(t,i),l.draw(t,e),c.forEach((e=>e.setContext(t).draw())),new ie(i,e).setContext(t).draw()}static AlignRestsToNotes(t,e,i){return t.forEach(((s,n)=>{if(s instanceof ce&&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=De(t,e.line,n,!1),s.setKeyLine(0,e.line);else if(n>0&&n0){const t=s<1.5?Math.abs(s-1.5)*e:0;n.setResetHeight(t)}else{const t=s>4.5?Math.abs(s-4.5)*e:0;n.setResetHeight(t)}}}}}})),this}constructor(){this.minTotalWidth=0,this.hasMinTotalWidth=!1,this.totalTicks=new Pt(0,1),this.tickContexts=null,this.modiferContexts=null,this.contextGaps={total:0,gaps:[]},this.voices=[]}alignRests(t,e){if(!t||!t.length)throw new Nt.RERR("BadArgument","No voices to format rests");t.forEach((t=>Ue.AlignRestsToNotes(t.getTickables(),e)))}preCalculateMinTotalWidth(t){if(this.hasMinTotalWidth)return this.minTotalWidth;if(!this.tickContexts){if(!t)throw new Nt.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 Nt.RERR("NoMinTotalWidth","Call 'preCalculateMinTotalWidth' or 'preFormat' before calling 'getMinTotalWidth'");return this.minTotalWidth}createModifierContexts(t){const e=Ge(t,Be,((t,e)=>t.addToModifierContext(e)));return this.modiferContexts=e,e}createTickContexts(t){const e=Ge(t,we,((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 h=0,l=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();h=h+l+n.extraLeftPx,i.setX(h),l=s-n.extraLeftPx})),this.minTotalWidth=h+l,this.hasMinTotalWidth=!0,t<=0)return;const u=t-this.minTotalWidth;let d=this.totalTicks.value();0===d&&(d=1);const p=u/(d*a);let f=0;r.forEach(((t,e)=>{const i=r[e-1]||0,s=o[t];f+=(t-i)*p,s.setX(s.getX()+f),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(),h=a-o;this.contextGaps.total+=h,this.contextGaps.gaps.push({x1:o,x2:a}),n.getFormatterMetrics().freedom.left=h,s.getFormatterMetrics().freedom.right=h}));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(),h=i.getX()+o.noteWidth+o.modRightPx+o.extraRightPx;let l=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 h=Math.min(5,Math.abs(t));t=t>0?h:-h})),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 s={align_rests:!1,context:null,stave:null};return Nt.Merge(s,i),this.voices=t,this.alignRests(t,s.align_rests),this.createTickContexts(t),this.preFormat(e,s.context,t,s.stave),this}formatToStave(t,e,i){const s=e.getNoteEndX()-e.getNoteStartX()-10;!function(...t){Ue.DEBUG&&Nt.L("Vex.Flow.Formatter",t)}("Formatting voices to width: ",s);const n={context:e.getContext()};return Nt.Merge(n,i),this.format(t,s,n)}}class We extends It{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=We.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 ze extends We{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:ze.type.SINGLE,double:ze.type.DOUBLE,end:ze.type.END,repeatBegin:ze.type.REPEAT_BEGIN,repeatEnd:ze.type.REPEAT_END,repeatBoth:ze.type.REPEAT_BOTH,none:ze.type.NONE}}constructor(t){super(),this.setAttribute("type","Barline"),this.thickness=Wt.STAVE_LINE_THICKNESS;const e=ze.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(We.Position.BEGIN),this.setType(t)}getCategory(){return ze.CATEGORY}getType(){return this.type}setType(t){return this.type="string"==typeof t?ze.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 ze.type.SINGLE:this.drawVerticalBar(t,this.x,!1);break;case ze.type.DOUBLE:this.drawVerticalBar(t,this.x,!0);break;case ze.type.END:this.drawVerticalEndBar(t,this.x);break;case ze.type.REPEAT_BEGIN:this.drawRepeatBar(t,this.x,!0),t.getX()!==this.x&&this.drawVerticalBar(t,t.getX());break;case ze.type.REPEAT_END:this.drawRepeatBar(t,this.x,!1);break;case ze.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 h=s+a+1;t.context.beginPath(),t.context.arc(o,h,2,0,2*Math.PI,!1),t.context.fill(),h+=t.getSpacingBetweenLines(),t.context.beginPath(),t.context.arc(o,h,2,0,2*Math.PI,!1),t.context.fill()}}class Ye extends We{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 Ye.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 Ye.type.CODA_RIGHT:this.drawCodaFixed(t,e+t.width);break;case Ye.type.CODA_LEFT:this.drawSymbolText(t,e,"Coda",!0);break;case Ye.type.SEGNO_LEFT:this.drawSignoFixed(t,e);break;case Ye.type.SEGNO_RIGHT:this.drawSignoFixed(t,e+t.width);break;case Ye.type.DC:this.drawSymbolText(t,e,"D.C.",!1);break;case Ye.type.DC_AL_CODA:this.drawSymbolText(t,e,"D.C. al",!0);break;case Ye.type.DC_AL_FINE:this.drawSymbolText(t,e,"D.C. al Fine",!1);break;case Ye.type.DS:this.drawSymbolText(t,e,"D.S.",!1);break;case Ye.type.DS_AL_CODA:this.drawSymbolText(t,e,"D.S. al",!0);break;case Ye.type.DS_AL_FINE:this.drawSymbolText(t,e,"D.S. al Fine",!1);break;case Ye.type.FINE:this.drawSymbolText(t,e,"Fine",!1);break;case Ye.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 Ut.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 Ut.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===Ye.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!==Ye.type.DC_AL_FINE&&this.symbol_type!==Ye.type.FINE&&this.symbol_type!==Ye.type.DC&&this.symbol_type!==Ye.type.DS_AL_FINE&&this.symbol_type!==Ye.type.DS&&this.symbol_type!==Ye.type.FINE||(r+=e)}const a=t.getYForTopText(t.options.num_lines)+this.y_shift+25;return s&&Ut.renderGlyph(n,o,a,40,"v4d",!0),n.fillText(i,r,a+5),n.restore(),this}}class He extends We{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 He.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,h=t.getYForTopText(3)+19-1.15*a+this.shift_y;let l=this.x+e-20;return i.beginPath(),i.lineWidth=2,i.rect(l,h+r/4,o,a),i.stroke(),l+=(o-n)/2,i.fillText(""+this.section,l,h+a),i.restore(),this}}class Xe extends We{static get CATEGORY(){return"stavetempo"}constructor(t,e,i){super(),this.setAttribute("type","StaveTempo"),this.tempo=t,this.position=ae.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 Xe.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,h=this.tempo.bpm,l=this.font;let c=this.x+this.shift_x+e;const u=t.getYForTopText(1)+this.shift_y;if(i.save(),i.openGroup("stavetempo",null,{}),r&&(i.setFont(l.family,l.size,l.weight),i.fillText(r,c,u),c+=i.measureText(r).width),o&&h){i.setFont(l.family,l.size,"normal"),r&&(c+=i.measureText(" ").width,i.fillText("(",c,u),c+=i.measureText("(").width);const t=Wt.getGlyphProps(o);if(c+=3*n,Ut.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&&(Ut.renderGlyph(i,c,r,s.glyph_font_scale,t.code_flag_upstem),a||(c+=6*n))}for(let e=0;e=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=Wt.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 r=0;r0?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===We.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){const t=this.stave.context.openGroup("keysignature");for(let e=0;e{const e=t.split("/").filter((t=>""!==t));if(2!==e.length)throw new Nt.RERR("BadTimeSignature",`Invalid time spec: ${t}. Must be in the form "/"`);e.forEach((e=>{if(isNaN(Number(e)))throw new Nt.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 Ut("v0",this.point);i.topGlyphs=[],i.botGlyphs=[];let s=0;for(let c=0;cn?s:n,o=i.getMetrics().x_min;i.getMetrics=()=>({x_min:o,x_max:o+r,width:r});const a=(r-s)/2,h=(r-n)/2,l=this;return i.renderToStave=function(t){let e=t+a;for(let i=0;it.visible)).filter(Boolean).length}formatBegModifiers(t){let e=0;t.forEach((t=>{t.getNoteStartX()>e&&(e=t.getNoteStartX())})),t.forEach((t=>{t.setNoteStartX(e)})),e=0,t.forEach((t=>{t.getModifiers(We.Position.BEGIN,ze.CATEGORY).forEach((t=>{t.getType()==ze.type.REPEAT_BEGIN&&t.getX()>e&&(e=t.getX())}))})),t.forEach((t=>{t.getModifiers(We.Position.BEGIN,ze.CATEGORY).forEach((t=>{t.getType()==ze.type.REPEAT_BEGIN&&t.setX(e)}))})),e=0,t.forEach((t=>{t.getModifiers(We.Position.BEGIN,qe.CATEGORY).forEach((t=>{t.getX()>e&&(e=t.getX())}))})),t.forEach((t=>{t.getModifiers(We.Position.BEGIN,qe.CATEGORY).forEach((t=>{t.setX(e)}))}))}getOptions(){return this.options}setNoteStartX(t){return this.formatted||this.format(),this.setStartX(t),this}setStartX(t){this.start_x=t}getNoteStartX(){return this.formatted||this.format(),this.start_x}getNoteEndX(){return this.formatted||this.format(),this.end_x}getTieStartX(){return this.start_x}getTieEndX(){return this.x+this.width}getX(){return this.x}getNumLines(){return this.options.num_lines}setNumLines(t){return this.options.num_lines=parseInt(t,10),this.resetLines(),this}setY(t){return this.y=t,this}getTopLineTopY(){return this.getYForLine(0)-Wt.STAVE_LINE_THICKNESS/2}getBottomLineBottomY(){return 2===this.getLines()?this.getYForLine(6)+Wt.STAVE_LINE_THICKNESS/2:this.getYForLine(this.getNumLines()-1)+Wt.STAVE_LINE_THICKNESS/2}setX(t){const e=t-this.x;this.formatted=!1,this.x=t,this.start_x+=e,this.end_x+=e;for(let i=0;ii.getWidth()&&(e-=i.getWidth()),e}setRepetitionTypeLeft(t,e){return this.modifiers.push(new Ye(t,this.x,e)),this}setRepetitionTypeRight(t,e){return this.modifiers.push(new Ye(t,this.x,e)),this}setVoltaType(t,e,i,s){if(2===t)2===Qe.type&&Qe.stave.modifiers.push(new Ze(Qe.type,Qe.number_t,Qe.x,Qe.y,s)),Qe={stave:this,type:t,number_t:s||e,MeasureNumber:this.MeasureNumber,y:i,x:this.x};else if(4===t){let t=this.MeasureNumber-Qe.MeasureNumber,n=Math.max(Qe.y,i);for(let i=0;i<=t;i++)ti[Qe.MeasureNumber+i]={type:0===i?2:i===t?4:0,number_t:s||e,y:n};Qe={}}else this.modifiers.push(new Ze(t,e,this.x,i,s));return this}drawVolta(){let t=ti[this.MeasureNumber];t&&(this.modifiers.push(new Ze(t.type,t.number_t,this.x,t.y)),delete ti[this.MeasureNumber]),Qe.type&&Qe.MeasureNumber==this.MeasureNumber&&(this.modifiers.push(new Ze(Qe.type,Qe.number_t,this.x,Qe.y)),Qe={})}setSection(t,e,i=0,s=12){const n=new He(t,this.x+i,e);return n.font.size=s,this.modifiers.push(n),this}setTempo(t,e){return this.modifiers.push(new Xe(t,this.x,e)),this}setText(t,e,i){let s=new je(t,e,i);return s.setFont({family:"Arial",size:14,weight:"normal"}),this.modifiers.push(s),this}getHeight(){return this.height}getSpacingBetweenLines(){return this.options.spacing_between_lines_px}getBoundingBox(){return new Ft(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,i){return void 0!==e&&t.setPosition(e),i&&(this.timeSignature.numerator=i.numerator,this.timeSignature.denominator=i.denominator),t.setStave(this),this.formatted=!1,this.modifiers.push(t),this}addEndModifier(t){return this.addModifier(t,We.Position.END),this}setBegBarType(t){const{SINGLE:e,REPEAT_BEGIN:i,NONE:s}=ze.type;return t!==e&&t!==i&&t!==s||(this.modifiers[0].setType(t),this.formatted=!1),this}setEndBarType(t){return t!==ze.type.REPEAT_BEGIN&&(this.modifiers[1].setType(t),this.formatted=!1),this}setClef(t,e,i,s){void 0===s&&(s=We.Position.BEGIN),s===We.Position.END?this.endClef=t:this.clef=t;const n=this.getModifiers(s,Ke.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,We.Position.END),this}setKeySignature(t,e,i){this.options.keySignature=t,void 0===i&&(i=We.Position.BEGIN);const s=this.getModifiers(i,$e.CATEGORY);return 0===s.length?"jianpu"!==this.options.DYMusicScoreType&&this.addKeySignature(t,e,i):s[0].setKeySig(t,e),this}setEndKeySignature(t,e){return this.setKeySignature(t,e,We.Position.END),this}setTimeSignature(t,e,i){void 0===i&&(i=We.Position.BEGIN);const s=this.getModifiers(i,qe.CATEGORY);return 0===s.length?this.addTimeSignature(t,e,i):s[0].setTimeSig(t),this}setEndTimeSignature(t,e){return this.setTimeSignature(t,e,We.Position.END),this}addKeySignature(t,e,i){return void 0===i&&(i=We.Position.BEGIN),this.addModifier(new $e(t,e).setPosition(i),i),this}addClef(t,e,i,s){return void 0===s||s===We.Position.BEGIN?this.clef=t:s===We.Position.END&&(this.endClef=t),this.addModifier(new Ke(t,e,i),s),this}addEndClef(t,e,i){return this.addClef(t,e,i,We.Position.END),this}addTimeSignature(t,e,i){return this.addModifier(new qe(t,e),i),this}addEndTimeSignature(t,e){return this.addTimeSignature(t,e,We.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(We.Position.BEGIN),s=this.getModifiers(We.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()===ze.type.REPEAT_BEGIN&&(i.push(i.splice(0,1)[0]),i.splice(0,0,new ze(ze.type.SINGLE))),s.indexOf(e)>0&&s.splice(0,0,new ze(ze.type.NONE));let a=0,h=this.x;for(let u=0;uh?h=t:o.setX(h),h+=n,r+n===0&&a--}h>this.start_x&&this.setStartX(h),h=this.x+this.width;const l={left:0,right:0,paddingRight:0,paddingLeft:0};let c=0;for(let u=0;u{t.includes(i)?e.visible=!0:e.visible=!1}))}for(let r=0;rthis.drawStaveTempo())),this.measure>0){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}drawStaveTempo(){if(!this.staveTempos.length)return;const t=document.querySelector(`#${this.attrs.id}`);if(!t)return;const e=t.parentElement.getBBox(),i=this.getYForLine(0),s=t.parentElement.parentElement.querySelectorAll(".vf-curve");if(s.length){const t=this.x+this.staveTempos[0].shift_x+this.getModifierXShift(0),n=this.getYForTopText(1)+e.y-i+5;s.forEach((i=>{const s=i.getBBox();s.x-10t&&s.y-10n&&(e.y=s.y+5)}))}for(let n=0;n1&&(ii=!0)}}else this.options.keySignature!=Je&&this.setText(`1=${i}`,1,{justification:1,shift_x:50,shift_y:-50});Je=this.options.keySignature}if(this.MeasureNumber>=0&&this.timeSignature.numerator){let t=40,e=0;this.MeasureNumber<2&&(t=70,e=-72),this.setText(`${this.timeSignature.numerator}`,1,{justification:1,shift_x:t,shift_y:e-13}),this.setText("á…³",1,{justification:1,shift_x:t+3,shift_y:e-2}),this.setText(`${this.timeSignature.denominator}`,1,{justification:1,shift_x:t,shift_y:e+8})}}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 Nt.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 Nt.RERR("StaveConfigError","The line configuration object is missing the 'visible' property.");if("boolean"!=typeof e.visible)throw new Nt.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 Nt.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]),Nt.Merge(this.options.line_config[e],t[e]);return this.options.line_config=t,this}}class ni extends si{constructor(t,e,i,s){const n={spacing_between_lines_px:13,num_lines:6,top_text_position:1};Nt.Merge(n,s),super(t,e,i,n),this.setAttribute("type","TabStave")}getYForGlyphs(){return this.getYForLine(2.5)}addTabGlyph(){return this.addClef("tab"),this}}class ri extends oe{static get CATEGORY(){return"tabnotes"}constructor(t,e){if(super(t),this.setAttribute("type","TabNote"),this.ghost=!1,this.positions=t.positions,Nt.Merge(this.render_options,{glyph_font_scale:Wt.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=Wt.getGlyphProps(this.duration,this.noteType),!this.glyph)throw new Nt.RuntimeError("BadArguments",`Invalid note initialization data (No glyph found): ${JSON.stringify(t)}`);this.buildStem(),t.stem_direction?this.setStemDirection(t.stem_direction):this.setStemDirection(Kt.UP),this.ghost=!1,this.updateWidth()}reset(){this.stave&&this.setStave(this.stave)}getCategory(){return ri.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 he;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 e=0;e{("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(),h=[];return e.forEach((e=>{const l=e.indexOf(a)>-1,c=e.indexOf(1)>-1;if(n&&c||r&&l)return;1===e.length&&e.push(e[0]);const u=[];e.forEach(((e,n,r)=>{const h=1===e,l=e===a;let c=i.getYForLine(e-1);0!==n||h?n!==r.length-1||l||(c+=o/2-1):c-=o/2-1,u.push(c),1===s&&h?u.push(t-2):-1===s&&l&&u.push(t+2)})),h.push(u.sort(((t,e)=>t-e)))})),h}(e,s,this.getStave(),this.getStemDirection());i.save(),i.setLineWidth(Kt.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)?di.SLIDE_DOWN:di.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 Nt.RERR("BadArguments","No Y-values to render");const e=this.context,i=t.first_x_px,s=t.first_ys,n=t.last_x_px,r=this.slide_direction;if(r!==di.SLIDE_UP&&r!==di.SLIDE_DOWN)throw new Nt.RERR("BadSlide","Invalid slide direction");for(let o=0;othis.numStrings)throw new Nt.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),s=parseInt(t,10);if(s<0)throw new Nt.RERR("BadArguments","Fret number must be 0 or higher: "+t);return i+s}getNoteForFret(t,e){const i=this.getValueForFret(t,e),s=Math.floor(i/12),n=i%12;return Wt.integerToNote(n)+"/"+s}}class gi extends It{static get type(){return{CRESC:1,DECRESC:2}}static FormatByTicksAndDraw(t,e,i,s,n,r){const o=e.pixelsPerTick;if(null==o)throw new Nt.RuntimeError("BadArguments","A valid Formatter must be provide to draw offsets by ticks.");const a=o*r.left_shift_ticks,h=o*r.right_shift_ticks,l={height:r.height,y_shift:r.y_shift,left_shift_px:a,right_shift_px:h};new gi({first_note:i.first_note,last_note:i.last_note},s).setContext(t).setRenderOptions(l).setPosition(n).draw()}constructor(t,e){super(),this.setAttribute("type","StaveHairpin"),this.notes=t,this.hairpin=e,this.position=ae.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!==ae.Position.ABOVE&&t!==ae.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 Nt.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===ae.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 gi.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 gi.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 mi extends It{static get Position(){return{NEAR_HEAD:1,NEAR_TOP:2}}static get PositionString(){return{nearHead:mi.Position.NEAR_HEAD,nearTop:mi.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:mi.Position.NEAR_HEAD,position_end:mi.Position.NEAR_HEAD,invert:!1,cps:[{x:0,y:10},{x:0,y:10}]},Nt.Merge(this.render_options,i),this.setNotes(t,e)}setNotes(t,e){if(!t&&!e)throw new Nt.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,h=t.last_y+n,l=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,h+i[1].y*t.direction,a,h),e.bezierCurveTo(a-c+i[1].x,h+(i[1].y+l)*t.direction,r+c+i[0].x,o+(i[0].y+l)*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",h="baseY";function l(t){return"string"==typeof t?mi.PositionString[t]:t}const c=l(this.render_options.position),u=l(this.render_options.position_end);return c===mi.Position.NEAR_TOP&&(a="topY",h="topY"),u===mi.Position.NEAR_HEAD?h="baseY":u===mi.Position.NEAR_TOP&&(h="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()[h]):(s=t.getStave().getTieEndX(),r=t.getStemExtents()[h]),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 _i(...t){yi.DEBUG&&Nt.L("Vex.Flow.TextDynamics",t)}class yi extends ne{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=[],Nt.Merge(this.render_options,{glyph_font_size:40}),_i("New Dynamics Text: ",this.sequence)}setLine(t){return this.line=t,this}preFormat(){let t=0;return this.sequence.split("").forEach((e=>{const i=yi.GLYPHS[e];if(!i)throw new Nt.RERR("Invalid dynamics character: "+e);const s=this.render_options.glyph_font_size,n=new Ut(i.code,s);this.glyphs.push(n),t+=i.width})),this.setWidth(t),this.preFormatted=!0,this}draw(){this.setRendered();const t=this.getAbsoluteX(),e=this.stave.getYForLine(this.line+-3);_i("Rendering Dynamics: ",this.sequence);let i=t;this.glyphs.forEach(((t,s)=>{const n=this.sequence[s];t.render(this.context,i,e),i+=yi.GLYPHS[n].width}))}}function xi(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 vi extends It{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:vi.TextVerticalPosition.TOP,text_justification:vi.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 Nt.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 Nt.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 h=this.last_indices[a];n=e.getModifierStartXY(2,o),r=i.getModifierStartXY(1,h);const l=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()[h].displaced&&-1===i.getStemDirection()&&(r.x-=c+s.padding_right),n.y+=l?-3:1,r.y+=l?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,h=i.y,l=Math.sqrt((a-r)*(a-r)+(h-o)*(h-o)),c=(l-s.arrowhead_length/3)/l;let u,d,p,f;s.draw_end_arrow||n?(u=Math.round(r+(a-r)*c),d=Math.round(o+(h-o)*c)):(u=a,d=h),s.draw_start_arrow||n?(p=r+(a-r)*(1-c),f=o+(h-o)*(1-c)):(p=r,f=o),s.color&&(t.setStrokeStyle(s.color),t.setFillStyle(s.color)),t.beginPath(),t.moveTo(p,f),t.lineTo(u,d),t.stroke(),t.closePath();const b=Math.atan2(h-o,a-r),g=Math.abs(s.arrowhead_length/Math.cos(s.arrowhead_angle));let m,_,y,x,v,w;(s.draw_end_arrow||n)&&(m=b+Math.PI+s.arrowhead_angle,y=a+Math.cos(m)*g,x=h+Math.sin(m)*g,_=b+Math.PI-s.arrowhead_angle,v=a+Math.cos(_)*g,w=h+Math.sin(_)*g,xi(t,y,x,a,h,v,w)),(s.draw_start_arrow||n)&&(m=b+s.arrowhead_angle,y=r+Math.cos(m)*g,x=o+Math.sin(m)*g,_=b-s.arrowhead_angle,v=r+Math.cos(_)*g,w=o+Math.sin(_)*g,xi(t,y,x,r,o,v,w))}(t,n,r,this.render_options)})),t.restore();const o=t.measureText(this.text).width,a=s.text_justification;let h,l=0;a===vi.TextJustification.LEFT?l=n.x:a===vi.TextJustification.CENTER?l=(r.x-n.x)/2+n.x-o/2:a===vi.TextJustification.RIGHT&&(l=r.x-o);const c=s.text_position_vertical;return c===vi.TextVerticalPosition.TOP?h=e.getStave().getYForTopText():c===vi.TextVerticalPosition.BOTTOM&&(h=e.getStave().getYForBottomText(Wt.TEXT_HEIGHT_OFFSET_HACK)),t.save(),this.applyFontStyle(),t.fillText(this.text,l,h),t.restore(),this}}function wi(t,e,i,s,n){const r=Si.GLYPHS[t];new Ut(r.code,n).render(e,i+r.x_shift,s+r.y_shift)}class Si extends It{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:Si.Styles.TEXT,bracket:Si.Styles.BRACKET,mixed:Si.Styles.MIXED,mixed_open_end:Si.Styles.MIXED_OPEN_END,bracket_open_begin:Si.Styles.BRACKET_OPEN_BEGIN,bracket_open_end:Si.Styles.BRACKET_OPEN_END,bracket_open_both:Si.Styles.BRACKET_OPEN_BOTH}}static createSustain(t){return new Si(t)}static createSostenuto(t){const e=new Si(t);return e.setStyle(Si.Styles.MIXED),e.setCustomText("Sost. Ped."),e}static createUnaCorda(t){const e=new Si(t);return e.setStyle(Si.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=Si.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 e=0;e3)throw new Nt.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 h=0;if(r?(h=r.getNoteHeadBeginX(),this.BeginsStave&&(h=r.getStave().getNoteStartX())):h=this.endStave.end_x+this.endStaveAddedWidth,this.EndsStave)s?this.ChangeBegin&&(h=r.getAbsoluteX()):(h=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&&(h=r.getAbsoluteX());else switch(n.style){case Si.Styles.BRACKET_OPEN_END:case Si.Styles.BRACKET_OPEN_BOTH:case Si.Styles.MIXED_OPEN_END:h=r.getNoteHeadEndX();break;default:this.ChangeEnd?h=r.getAbsoluteX():(h=r.getNoteHeadBeginX()-n.render_options.text_margin_right,this.startMargin=-n.render_options.text_margin_right)}let l=this.endStave;r&&(l=r.getStave());let c=l.getYForBottomText(n.line+3);i&&i>c&&(c=i);const u=a[o+1]===r,d=a[o-1]===r;let p=0;if(s)if(p=d?5:0,n.style!==Si.Styles.MIXED&&n.style!==Si.Styles.MIXED_OPEN_END||d)t.beginPath(),n.style===Si.Styles.BRACKET_OPEN_BEGIN||n.style===Si.Styles.BRACKET_OPEN_BOTH?t.moveTo(h+p,c):(this.ChangeBegin&&(h+=5),t.moveTo(h,c-n.render_options.bracket_height),this.ChangeBegin&&(h+=5),t.lineTo(h+p,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,h-e/2,c),p=e/2+n.render_options.text_margin_right}else wi("pedal_depress",t,h,c,n.render_options.glyph_point_size),p=20+n.render_options.text_margin_right;else p=u&&!this.EndsStave?-5:0,t.beginPath(),t.moveTo(e,i),t.lineTo(h+p,c),n.style!==Si.Styles.BRACKET_OPEN_END&&n.style!==Si.Styles.MIXED_OPEN_END&&n.style!==Si.Styles.BRACKET_OPEN_BOTH&&(this.ChangeEnd&&(h+=5),t.lineTo(h,c-n.render_options.bracket_height)),t.stroke(),t.closePath();e=h+p,i=c}))}drawText(){const t=this.context;let e=!1;const i=this,s=i.render_options.glyph_point_size;this.notes.forEach((n=>{if(!n)return;e=!e;const r=n.getStave(),o=n.getAbsoluteX(),a=r.getYForBottomText(i.line+3);let h=0;e?i.custom_depress_text?(h=t.measureText(i.custom_depress_text).width,t.fillText(i.custom_depress_text,o-h/2,a)):wi("pedal_depress",t,o,a,s):i.custom_release_text?(h=t.measureText(i.custom_release_text).width,t.fillText(i.custom_release_text,o-h/2,a)):wi("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),function(...t){Si.DEBUG&&Nt.L("Vex.Flow.PedalMarking",t)}("Rendering Pedal Marking"),this.style===Si.Styles.BRACKET||this.style===Si.Styles.MIXED||this.style===Si.Styles.MIXED_OPEN_END||this.style===Si.Styles.BRACKET_OPEN_BEGIN||this.style===Si.Styles.BRACKET_OPEN_END||this.style===Si.Styles.BRACKET_OPEN_BOTH?(t.setLineWidth(this.render_options.bracket_line_width),this.drawBracketed()):this.style===Si.Styles.TEXT&&this.drawText(),t.restore()}}class Ei extends It{static get Positions(){return{TOP:1,BOTTOM:-1}}static get PositionString(){return{top:Ei.Positions.TOP,bottom:Ei.Positions.BOTTOM}}constructor({start:t,stop:e,text:i="",superscript:s="",position:n=Ei.Positions.TOP}){super(),this.setAttribute("type","TextBracket"),this.start=t,this.stop=e,this.text=i,this.superscript=s,this.position="string"==typeof n?Ei.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 Ei.Positions.TOP:e=this.start.getStave().getYForTopText(this.line);break;case Ei.Positions.BOTTOM:e=this.start.getStave().getYForBottomText(this.line+Wt.TEXT_HEIGHT_OFFSET_HACK);break;default:throw new Nt.RERR("InvalidPosition",`The position ${this.position} is invalid`)}const i={x:this.start.getAbsoluteX(),y:e},s={x:this.stop.getAbsoluteX(),y:e};!function(...t){Ei.DEBUG&&Nt.L("Vex.Flow.TextBracket",t)}("Rendering TextBracket: start:",i,"stop:",s,"y:",e);const n=this.render_options.bracket_height*this.position;t.save(),this.applyStyle(t),t.fillText(this.text,i.x,i.y);let r=t.measureText(this.text).width;r>0||(r=10*this.text.length);let o=t.measureText("M").width;o>0||(o=20);const a=i.y-o/2.5;t.setFont(this.font.family,this.font.size/1.4,this.font.weight),t.fillText(this.superscript,i.x+r+1,a);let h=t.measureText(this.superscript).width;h>0||(h=12,this.superscript.includes("m")&&(h+=5));let l=t.measureText("M").width;l>0||(l=10);let c=i.x,u=a,d=s.x+this.stop.getGlyph().getWidth();this.position===Ei.Positions.TOP?(c+=r+h+5,u-=l/2.7):this.position===Ei.Positions.BOTTOM&&(u+=l/2.7,c+=r+2,this.render_options.underline_superscript||(c+=h)),this.render_options.dashed?(d0||!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){Pi.DEBUG&&Nt.L("Vex.Flow.Parser",t)}("Evaluating rules:",t),!t)throw new Ri("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 Ri("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(Ni(t)))),i.run&&e.success&&i.run(e),e}}function Oi(...t){Di.DEBUG&&Nt.L("Vex.Flow.EasyScore",t)}const Li=Nt.MakeException("EasyScoreError");class Mi{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 Ii{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(){Oi("resetPiece"),this.piece={chord:[],duration:this.rollingDuration,dots:0,type:void 0,options:{}}}setNoteDots(t){Oi("setNoteDots:",t),t&&(this.piece.dots=t.length)}setNoteDuration(t){Oi("setNoteDuration:",t),this.rollingDuration=this.piece.duration=t||this.rollingDuration}setNoteType(t){Oi("setNoteType:",t),t&&(this.piece.type=t)}addNoteOption(t,e){Oi("addNoteOption: key:",t,"value:",e),this.piece.options[t]=e}addNote(t,e,i){Oi("addNote:",t,e,i),this.piece.chord.push({key:t,accid:e,octave:i})}addSingleNote(t,e,i){Oi("addSingleNote:",t,e,i),this.addNote(t,e,i)}addChord(t){Oi("startChord"),"object"!=typeof t[0]?this.addSingleNote(t[0]):t.forEach((t=>{t&&this.addNote(...t)})),Oi("endChord")}commitPiece(){Oi("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()?ce.STEM_DOWN:ce.STEM_UP,{chord:o,duration:a,dots:h,type:l}=this.piece,c=o.map((t=>t.key+"/"+t.octave)),u=t.StaveNote({keys:c,duration:a,dots:h,type:l,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 p=0;pt(e,u,this))),this.elements.notes.push(u),this.elements.accidentals.concat(d),this.resetPiece()}}function Bi({id:t},e){void 0!==t&&e.setAttribute("id",t)}function Fi(t,e){t.class&&t.class.split(/\s*,\s*/).forEach((t=>e.addClass(t)))}class Di{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:[Bi,Fi,Ne.easyScoreHook],throwOnError:!1,...t},this.factory=this.options.factory,this.builder=this.options.builder||new Ii(this.factory),this.grammar=new Mi(this.builder),this.parser=new Pi(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 Li("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)}}let Gi=null,Ui="C",Wi={notes:[],finish:!1,total:0,staveId:""},zi="",Yi="",Hi="";class Xi extends ce{static get CATEGORY(){return"numberednotes"}static accidentalAndKey(t){switch(t){case"G":return{4:"#"};case"D":return{1:"#",4:"#"};case"A":return{1:"#",4:"#",5:"#"};case"E":return{1:"#",2:"#",4:"#",5:"#"};case"B":return{1:"#",2:"#",4:"#",5:"#",6:"#"};case"F#":return{1:"#",2:"#",3:"#",4:"#",5:"#",6:"#"};case"C#":return{1:"#",2:"#",3:"#",4:"#",5:"#",6:"#",7:"#"};case"F":return{7:"b"};case"Bb":return{7:"b",3:"b"};case"Eb":return{7:"b",3:"b",6:"b"};case"Ab":return{7:"b",2:"b",3:"b",6:"b"};case"Db":return{7:"b",2:"b",3:"b",5:"b",6:"b"};case"Gb":return{7:"b",1:"b",2:"b",3:"b",5:"b",6:"b"};case"Cb":return{7:"b",1:"b",2:"b",3:"b",4:"b",5:"b",6:"b"};default:return{}}}static accidentalMap(t){switch(t){case"C":return"";case"F":case"Bb":case"Eb":case"Ab":case"Db":case"Gb":case"Cb":return{bb:"b",b:"",n:"#","#":"##"};default:return{b:"bb",n:"b","#":"","##":"#"}}}static get noteLift(){switch(Ui){case"G":return["7"];case"D":return["7","3"];case"A":return["7","3","6"];case"E":return["2","6","3","7"];case"B":return["5","2","6","3","7"];case"F#":return["1","5","2","6","3","7"];case"C#":return["4","1","5","2","6","3","7"];case"F":return["4"];case"Bb":return["1","4"];case"Eb":return["5","1","4"];case"Ab":return["2","5","1","4"];case"Db":return["6","2","5","1","4"];case"Gb":return["3","6","2","5","1","4"];case"Cb":return["7","3","6","2","5","1","4"]}}static get longDurationLine(){return{1:3,2:1,6:2}}static get numberedDurationLine(){return{8:1,16:2,32:3,64:4,128:5}}static get durationTime(){return{8:6144,4:4096}}constructor(t){super(t),this.setAttribute("type","NumberedNote"),Ui=t.keyString,this.ornament=!!t.ornament,this.line=0,this.keys=t.keys||[],this.fontSize=20,this.offset_x=0,this.offset_y=0,this.note_tones=[],this.duration_lines=0,this.long_duration_lines=0,this.note_size=t.note_size||16;const e=Wt.sanitizeDuration(this.duration);var i=Xi.numberedDurationLine[e.toString()];if(i&&(this.duration_lines=i),(i=Xi.longDurationLine[e.toString()])&&(this.long_duration_lines=i),!Gi){var s="__$text_wraper$$__";let t=document.createElement("canvas");t.id=s,document.body.append(t);const e=document.getElementById(s),i=e.getContext("2d");i.font="Arial 22px";var n=i.measureText("5");Gi=n.width+2,document.body.removeChild(e)}}getCategory(){return Xi.CATEGORY}setKeySignature(t){this.keySignature=t}preFormat(){this.preFormatted||(this.modifierContext&&this.modifierContext.preFormat(),this.setWidth(this.full_width),this.setPreFormatted(!0))}filterNote(){if(window&&window.sett&&window.sett.keySignature)return;if(!this.keys||!this.keys.length)return;const t=Xi.accidentalMap(Ui);if(!t)return;const e=Xi.noteLift;if(!e)return;var i=this.keys[0].split("/")[0];"b"===i&&(i="R"),(i=(i=i.replace(new RegExp("#","g"),"")).replace(new RegExp("n","g"),"")).length>1&&(i=i.replace(new RegExp("b","g"),""));const s=Vi.numberedNotationMapping[i.toUpperCase()];if(e.includes(s))for(let n=0;n{switch(i.getAttribute("type")){case"Accidental":i.render_options.font_scale=1.4*this.note_width,i.x_shift=2,i.y_shift=this.unit_height/2,this.ornament&&(i.render_options.font_scale=this.note_width,i.x_shift=14,i.y_shift=-10);break;case"Stroke":i.x_shift=-1*t,i.y_shift=1*this.unit_height;break;case"Dot":i.x_shift=e*this.duration_dot_width+7,i.y_shift=1*this.unit_height,e++;break;case"Ornament":i.y_shift=-3;break;default:i.y_shift=1*this.unit_height}i.reset&&i.reset(),t+=i.getWidth()/2}))}handleDeleteDot(){for(let t=0;tt)),s=i.length?i[0]/i[1]:0;if(this.ornament)return;if(0===s)return this.long_duration_lines=this.intrinsicTicks/e-1,this.long_duration_lines>=Yi&&(this.long_duration_lines=Yi-1),8==zi&&(this.long_duration_lines=0,3==Yi&&this.draw_dot(this.context,this.bottom_x+25,this.bottom_y-30,this.dot_width)),Wi={notes:[],finish:!1,total:0,staveId:""};let n={lines:this.duration_lines,duration:s,id:this.attrs.id,x:this.x-this.duration_line_space/2-this.left_width,y:this.y,width:this.full_width};s>2*e&&(this.long_duration_lines=parseInt(s/e)-1,this.handleDeleteDot()),Hi&&(n.x+=this.note_width),Wi.notes.push(n);let r=Wi.notes.reduce(((t,e)=>t+e.duration),0);if(r=parseInt(r),r>e&&(r-=e),r>e-10&&r0===t.lines));t.length&&(this.drawDurationLoneLine(),Wi={notes:[],finish:!1,total:0,staveId:""})}}draw(){if(this.checkContext(),!this.stave)throw new Nt.RERR("NoStave","Can't draw without a stave.");let t=this.context;t.save(),t.setFont("Arial",this.note_height,"normal"),this.setAttribute("el",t.openGroup("stavenote",this.getAttribute("id"))),t.openGroup("note",null,{pointerBBox:!0});let e=this.getAbsoluteX()+2.5;this.x=e;let i=this.stave.getYForLine(2)+this.note_height/2;this.y=i,this.buildToneHeads(),this.preFormatModifier(),this.applyStyle(),this.note_tones.forEach((e=>{null!=e&&e.key.includes("X2")?e.draw(t,"isX"):e.draw(t)})),t.openGroup("modifier",null,{pointerBBox:!0}),this.drawModifiers(),t.closeGroup(),t.closeGroup(),t.closeGroup(),this.calcGroup(),Wi.staveId=this.stave.attrs.id,this.drawDurationLine(t,{}),this.drawLongDurationLines(t),this.restoreStyle(),this.setRendered(),Hi=this.ornament?Hi?Object.assign(Hi,{lines:this.duration_lines,id:this.attrs.id,x:this.x-this.duration_line_space/2-this.left_width,width:this.full_width}):{lines:this.duration_lines,id:this.attrs.id,x:this.x-this.duration_line_space/2-this.left_width,width:this.full_width}:""}drawDurationLoneLine(t,e){t=t||this.context;let i=e||this.y+this.duration_line_space;for(let s=0;s<5;s++){let e=[],n=0;for(let r=0;rs)e.push(o),n++;else{if(e.length>1){let n=e.length-1;i=e[0].y+this.duration_line_space,t.rect(e[0].x,i+3*s,e[n].x-e[0].x+e[n].width,.5)}e=[],n=r+1}}if(e.length>1){let n=e.length-1;i=e[0].y+this.duration_line_space,t.rect(e[0].x,i+3*s,e[n].x-e[0].x+e[n].width,.5)}}}draw_dot(t,e,i,s){t.openGroup("numbered-note-dot"),t.beginPath(),t.arc(e,i,s,0,2*Math.PI),t.closePath(),t.fill(),t.closeGroup()}drawDurationLine(t,e){var i,s,n=this.attrs.id+"-lines";if(t.openGroup("numbered_note_lines",n),this.duration_lines>0){const n=this.duration_line_space;var r=this.full_width;if(e&&e.width&&(r=e.width),r<0&&(r=this.note_width),i=e&&void 0!==e.startX?e.startX:this.x-n/2-this.left_width,s=e&&void 0!==e.startY?e.startY:this.y+this.duration_line_space,Wi.finish&&(this.drawDurationLoneLine(t,s),Wi={notes:[],finish:!1,total:0,staveId:""}),this.ornament?(i+=12,s-=22,r=15,Hi&&(i-=10,r+=10)):Hi&&(i+=this.note_width,r-=this.note_width),r>0){for(var o=0;o"Dot"===t.getAttribute("type"))),i=this.modifiers.findIndex((t=>"Accidental"===t.getAttribute("type"))),n=this.modifiers.findIndex((t=>"GraceNoteGroup"===t.getAttribute("type")));t&&i>-1?this.modifiers[i].accidental.code="#"===t?"v18":"v44":e>=0||n>=0?e>=0&&this.modifiers.splice(e+1,1):this.modifiers.splice(i,1)}}catch(e){}}this.setYs(t)}getFullWidth(){return this.full_width}getFullHeight(){return this.full_height}getLine(){return this.keyProps[0].line}get full_width(){return this.note_width+this.left_width+this.right_width+this.long_duration_line_width}get long_duration_line_width(){return(this.long_duration_width+this.long_duration_space)*this.long_duration_lines}get full_height(){return this.bottom_y-this.top_y}get note_width(){return this.note_size||0}get note_dot_width(){return 6}get note_height(){return this.unit_height}get unit_height(){return this.note_size||0}get note_x(){return this.x||0}get top_x(){return this.x||0}get top_y(){var t=this;return(this.y||0)-(t.note_tones.map((e=>(e.td+e.bd)*(t.dot_space+t.dot_width))).reduce(((t,e)=>t+e),0)+this.note_height*this.note_tones.length-this.unit_height-this.note_tones[0].bd*(t.dot_space+t.dot_width)+(this.note_tones.length-1)*this.head_space)}get bottom_x(){return this.x||0}get bottom_y(){return(this.y||0)+this.unit_height+this.duration_lines*(this.duration_line_height+this.duration_line_space)+this.note_tones[0].meta.bd*(this.dot_width+this.dot_space)}get left_width(){return this.modifiers_width}get right_width(){return this.full_duration_dot_width}get duration_dot_width(){return 6}get full_duration_dot_width(){return this.duration_dot_width*this.getModifiersByCategory(he.CATEGORY).length}getModifiersByCategory(t){var e=[];return this.modifiers.forEach((i=>{i.getCategory()===t&&e.push(i)})),e}get head_space(){return 6}get duration_line_height(){return 2}get duration_line_space(){return 4}get dot_width(){return 2}get dot_space(){return 2}get long_duration_space(){return 10}get long_duration_width(){return 20}getWidth(){return this.full_width}get modifiers_width(){let t=0;return this.modifiers.forEach((e=>{t+=e.getWidth()})),t}}t("N",Xi);class Vi{static get numberedNotationMapping(){let t=Ui;switch(window&&window.sett&&window.sett.keySignature&&(t="C"),t){case"A":return{C:"3",D:"4",E:"5",F:"6",G:"7",A:"1",B:"2",R:"0",X:"x",min:2.5,max:5.5};case"B":case"Bb":case"A#":return{C:"2",D:"3",E:"4",F:"5",G:"6",A:"7",B:"1",R:"0",X:"x",min:-.5,max:2.5};case"D":case"D#":case"Db":return{C:"7",D:"1",E:"2",F:"3",G:"4",A:"5",B:"6",R:"0",X:"x",min:.5,max:3.5};case"E":case"Eb":return{C:"6",D:"7",E:"1",F:"2",G:"3",A:"4",B:"5",R:"0",X:"x",min:1,max:4};case"F":case"F#":return{C:"5",D:"6",E:"7",F:"1",G:"2",A:"3",B:"4",R:"0",X:"x",min:1.5,max:4.5};case"G":case"Gb":return{C:"4",D:"5",E:"6",F:"7",G:"1",A:"2",B:"3",R:"0",X:"x",min:2,max:5};case"Ab":case"G#":return{C:"3",D:"4",E:"5",F:"6",G:"7",A:"1",B:"2",R:"0",X:"x",min:-1,max:2};default:return{C:"1",D:"2",E:"3",F:"4",G:"5",A:"6",B:"7",R:"0",X:"x",min:0,max:3}}}tone_to_numbered_key(){var t=this.key.split("/"),e=t[0];"b"===e&&(e="R"),(e=(e=e.replace(new RegExp("#","g"),"")).replace(new RegExp("n","g"),"")).length>1&&(e=e.replace(new RegExp("b","g"),"")),t.includes("X2")&&(e="X");let i=0,s=0;this.note.stave&&this.note.stave.options&&this.note.stave.options.keySignature&&(Ui=this.note.stave.options.keySignature);const n=this.note.getLine();return nVi.numberedNotationMapping.max&&(s=Math.ceil((n-Vi.numberedNotationMapping.max)/3.5)),"R"===e.toUpperCase()&&(i=0,s=0),{key:Vi.numberedNotationMapping[e.toUpperCase()],td:s,bd:i}}constructor(t){this.key=t.key,this.x=t.x||0,this.y=t.y||0,this.idx=t.idx||0,this.note=t.note||0,this.meta=this.tone_to_numbered_key(),this.noteSize=t.noteSize||16,this.td=this.meta.td,this.bd=this.meta.bd}draw(t,e){let i=this.y;e&&"isX"===e?t.openGroup("numbered-note-head","","","isX"):t.openGroup("numbered-note-head");var s=this.x+(this.note.ornament?-2:0);let n=i-this.note.unit_height-this.note.dot_space-(this.note.ornament?-4:2);for(let r=0;r1&&(t-=this.note.duration_line_space),i+=t}this.draw_dot(t,s+Gi,i,this.note.dot_width),i+=this.note.dot_width+this.note.dot_space}t.closeGroup()}get height(){return this.note.note_height+(this.meta.bd+this.meta.td)*(this.note.dot_width+this.note.dot_space)}draw_dot(t,e,i,s){t.openGroup("numbered-note-dot"),t.beginPath(),t.arc(e,i,s,0,2*Math.PI),t.closePath(),t.fill(),t.closeGroup()}}const ji=Nt.MakeException("FactoryError");function Ki(t={},e){const i=e.options;return(t=Object.assign(e,t)).options=Object.assign(i,t.options),t}class $i{constructor(t){!function(...t){$i.DEBUG&&Nt.L("Vex.Flow.Factory",t)}("New factory: ",t);const e={stave:{space:10},renderer:{context:null,elementId:"",backend:jt.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 $i({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 ji("HTML DOM element not set in Factory");this.context=jt.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=Ki(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 si(t.x,t.y,t.width,t.options);return this.staves.push(e),e.setContext(this.context),this.stave=e,e}TabStave(t){t=Ki(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 ni(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 ce(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}GhostNote(t){const e=new ki(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}TextNote(t){const e=new Ve(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}NumberedNote(t){const e=new Xi(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}BarNote(t){t=Ki(t,{type:"single",options:{}});const e=new Ti(t.type);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}ClefNote(t){t=Ki(t,{type:"treble",options:{size:"default"}});const e=new li(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=Ki(t,{time:"4/4",options:{}});const e=new ui(t.time);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}KeySigNote(t){const e=new ci(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 ri(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}GraceNote(t){const e=new pi(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),e}GraceNoteGroup(t){const e=new ye(t.notes,t.slur);return e.setContext(this.context),e}Accidental(t){t=Ki(t,{type:null,options:{}});const e=new be(t.type);return e.setContext(this.context),e}Annotation(t){t=Ki(t,{text:"p",vJustify:"below",hJustify:"center",fontFamily:"Times",fontSize:14,fontWeight:"bold italic",options:{}});const e=new Oe(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=Ki(t,{type:"a.",position:"above",options:{}});const e=new Ne(t.type);return e.setPosition(t.position),e.setContext(this.context),e}TextDynamics(t){t=Ki(t,{text:"p",duration:"q",dots:0,line:0,options:{}});const e=new yi({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=Ki(t,{number:"0",position:"left",options:{}});const e=new ue(t.number);return e.setPosition(t.position),e.setContext(this.context),e}StringNumber(t){t=Ki(t,{number:"0",position:"left",options:{}});const e=new ve(t.number);return e.setPosition(t.position),e.setContext(this.context),e}TickContext(){return(new we).setContext(this.context)}ModifierContext(){return new Be}MultiMeasureRest(t){const e=new hi(t.number_of_measures,t);return e.setContext(this.context),this.renderQ.push(e),e}Voice(t){t=Ki(t,{time:"4/4",options:{}});const e=new te(t.time);return this.voices.push(e),e}StaveConnector(t){t=Ki(t,{top_stave:null,bottom_stave:null,type:"double",options:{}});const e=new ie(t.top_stave,t.bottom_stave);return e.setType(t.type).setContext(this.context),this.renderQ.push(e),e}Formatter(){return new Ue}Tuplet(t){t=Ki(t,{notes:[],options:{}});const e=new $t(t.notes,t.options).setContext(this.context);return this.renderQ.push(e),e}Beam(t){t=Ki(t,{notes:[],options:{autoStem:!1,secondaryBeamBreaks:[]}});const e=new Qt(t.notes,t.options.autoStem).setContext(this.context);return e.breakSecondaryAt(t.options.secondaryBeamBreaks),this.renderQ.push(e),e}Curve(t){t=Ki(t,{from:null,to:null,options:{}});const e=new mi(t.from,t.to,t.options).setContext(this.context);return this.renderQ.push(e),e}StaveTie(t){t=Ki(t,{from:null,to:null,first_indices:[0],last_indices:[0],text:null,options:{direction:void 0}});const e=new me({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=Ki(t,{from:null,to:null,first_indices:[0],last_indices:[0],options:{}});const e=new vi({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=Ki(t,{from:null,to:null,options:{harsh:!1}});const e=new oi({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=Ki(t,{from:null,to:null,text:"",options:{superscript:"",position:1}});const e=new Ei({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 Zi(t).setContext(this.context);return this.systems.push(e),e}EasyScore(t={}){return t.factory=this,new Di(t)}PedalMarking(t={}){t=Ki(t,{notes:[],options:{style:"mixed"}});const e=new Si(t.notes);return e.setStyle(Si.StylesString[t.options.style]),e.setContext(this.context),this.renderQ.push(e),e}NoteSubGroup(t={}){t=Ki(t,{notes:[],options:{}});const e=new ge(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 qi(t,e){const i=e.options;return(t=Object.assign(e,t)).options=Object.assign(i,t.options),t}class Zi extends It{constructor(t={}){super(),this.setAttribute("type","System"),this.setOptions(t),this.parts=[]}setOptions(t={}){this.options=qi(t,{x:10,y:10,width:500,connector:null,spaceBetweenStaves:12,factory:null,debugFormatter:!1,formatIterations:0,options:{}}),this.factory=this.options.factory||new $i({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=qi(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 Ue;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)-ne.STAVEPADDING;t.format(s,r);for(let o=0;o{e.voice.getTickables().forEach((i=>ne.plotMetrics(t,i,e.y)))}))}}Nt.Flow=Wt,Nt.Flow.Element=It,Nt.Flow.Fraction=Pt,Nt.Flow.Renderer=jt,Nt.Flow.Formatter=Ue,Nt.Flow.Music=de,Nt.Flow.Glyph=Ut,Nt.Flow.Stave=si,Nt.Flow.StaveNote=ce,Nt.Flow.StaveModifier=We,Nt.Flow.StaveTempo=Xe,Nt.Flow.Voice=te,Nt.Flow.Accidental=be,Nt.Flow.Beam=Qt,Nt.Flow.StaveTie=me,Nt.Flow.TabStave=ni,Nt.Flow.TabNote=ri,Nt.Flow.Bend=Le,Nt.Flow.Vibrato=Me,Nt.Flow.VibratoBracket=oi,Nt.Flow.Note=ne,Nt.Flow.ModifierContext=Be,Nt.Flow.MultiMeasureRest=hi,Nt.Flow.TickContext=we,Nt.Flow.Articulation=Ne,Nt.Flow.Annotation=Oe,Nt.Flow.Barline=ze,Nt.Flow.NoteHead=re,Nt.Flow.StaveConnector=ie,Nt.Flow.ClefNote=li,Nt.Flow.KeySignature=$e,Nt.Flow.KeySigNote=ci,Nt.Flow.TimeSignature=qe,Nt.Flow.TimeSigNote=ui,Nt.Flow.Stem=Kt,Nt.Flow.TabTie=_e,Nt.Flow.Clef=Ke,Nt.Flow.Dot=he,Nt.Flow.Modifier=ae,Nt.Flow.TabSlide=di,Nt.Flow.Tuplet=$t,Nt.Flow.GraceNote=pi,Nt.Flow.GraceTabNote=fi,Nt.Flow.Tuning=bi,Nt.Flow.KeyManager=class{constructor(t){this.music=new de,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),!de.scaleTypes[this.keyParts.type])throw new Nt.RERR("BadArguments",`Unsupported key type: ${this.key}`);this.scale=this.music.getScaleTones(this.music.getNoteValue(this.keyString),de.scaleTypes[this.keyParts.type]),this.scaleMap={},this.scaleMapByValue={},this.originalScaleMapByValue={};const t=de.root_indices[this.keyParts.root];for(let e=0;e (c) 2009-2016 Stuart Knightley Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. JSZip uses the library pako released under the MIT license : https://github.com/nodeca/pako/blob/main/LICENSE */ !function(t){t.exports=function t(e,i,s){function n(o,a){if(!i[o]){if(!e[o]){if(!a&&Qi)return Qi(o);if(r)return r(o,!0);var h=new Error("Cannot find module '"+o+"'");throw h.code="MODULE_NOT_FOUND",h}var l=i[o]={exports:{}};e[o][0].call(l.exports,(function(t){return n(e[o][1][t]||t)}),l,l.exports,t,e,i,s)}return i[o].exports}for(var r=Qi,o=0;o>2,a=(3&e)<<4|i>>4,h=1>6:64,l=2>4,i=(15&o)<<4|(a=r.indexOf(t.charAt(l++)))>>2,s=(3&a)<<6|(h=r.indexOf(t.charAt(l++))),d[c++]=e,64!==a&&(d[c++]=i),64!==h&&(d[c++]=s);return d}},{"./support":30,"./utils":32}],2:[function(t,e,i){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){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){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=s+i;t^=-1;for(var a=s;a>>8^r[255&(t^e[a])];return~t}(0|e,t,t.length,0):function(t,e,i,s){var r=n,o=s+i;t^=-1;for(var a=s;a>>8^r[255&(t^e.charCodeAt(a))];return~t}(0|e,t,t.length,0):0}},{"./utils":32}],5:[function(t,e,i){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){var s=null;s="undefined"!=typeof Promise?Promise:t("lie"),e.exports={Promise:s}},{lie:37}],7:[function(t,e,i){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 h(t,e){o.call(this,"FlateWorker/"+t),this._pako=null,this._pakoAction=t,this._pakoOptions=e,this.meta={}}i.magic="\b\0",r.inherits(h,o),h.prototype.processChunk=function(t){this.meta=t.meta,null===this._pako&&this._createPako(),this._pako.push(r.transformTo(a,t.data),!1)},h.prototype.flush=function(){o.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},h.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this._pako=null},h.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 h("Deflate",t)},i.uncompressWorker=function(){return new h("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,e,i){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,p=t.file,f=t.compression,b=c!==a.utf8encode,g=r.transformTo("string",c(p.name)),m=r.transformTo("string",a.utf8encode(p.name)),_=p.comment,y=r.transformTo("string",c(_)),x=r.transformTo("string",a.utf8encode(_)),v=m.length!==p.name.length,w=x.length!==_.length,S="",E="",T="",k=p.dir,C=p.date,A={crc32:0,compressedSize:0,uncompressedSize:0};e&&!i||(A.crc32=t.crc32,A.compressedSize=t.compressedSize,A.uncompressedSize=t.uncompressedSize);var R=0;e&&(R|=8),b||!v&&!w||(R|=2048);var N=0,P=0;k&&(N|=16),"UNIX"===o?(P=798,N|=function(t,e){var i=t;return t||(i=e?16893:33204),(65535&i)<<16}(p.unixPermissions,k)):(P=20,N|=function(t){return 63&(t||0)}(p.dosPermissions)),u=C.getUTCHours(),u<<=6,u|=C.getUTCMinutes(),u<<=5,u|=C.getUTCSeconds()/2,d=C.getUTCFullYear()-1980,d<<=4,d|=C.getUTCMonth()+1,d<<=5,d|=C.getUTCDate(),v&&(E=s(1,1)+s(h(g),4)+m,S+="up"+s(E.length,2)+E),w&&(T=s(1,1)+s(h(y),4)+x,S+="uc"+s(T.length,2)+T);var O="";return O+="\n\0",O+=s(R,2),O+=f.magic,O+=s(u,2),O+=s(d,2),O+=s(A.crc32,4),O+=s(A.compressedSize,4),O+=s(A.uncompressedSize,4),O+=s(g.length,2),O+=s(S.length,2),{fileRecord:l.LOCAL_FILE_HEADER+O+g+S,dirRecord:l.CENTRAL_FILE_HEADER+s(P,2)+O+s(y.length,2)+"\0\0\0\0"+s(N,4)+s(n,4)+g+S+y}}var r=t("../utils"),o=t("../stream/GenericWorker"),a=t("../utf8"),h=t("../crc32"),l=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 l.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){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){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){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){var s=t("../utils"),n=t("../support"),r=t("./ArrayReader"),o=t("./StringReader"),a=t("./NodeBufferReader"),h=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 h(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){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){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){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){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){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){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){var s=t("../utils"),n=t("./ConvertWorker"),r=t("./GenericWorker"),o=t("../base64"),a=t("../support"),h=t("../external"),l=null;if(a.nodestream)try{l=t("../nodejs/NodejsStreamOutputAdapter")}catch(t){}function c(t,e){return new h.Promise((function(i,n){var r=[],a=t._internalType,h=t._outputType,l=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)}}(h,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,h=new Array(2*o);for(e=i=0;e>10&1023,h[i++]=56320|1023&n)}return h.length!==i&&(h.subarray?h=h.subarray(0,i):h.length=i),s.applyFromCharCode(h)}(t=s.transformTo(n.uint8array?"uint8array":"array",t))},s.inherits(l,o),l.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),h=e;o!==e.length&&(n.uint8array?(h=e.subarray(0,o),this.leftOver=e.subarray(o,e.length)):(h=e.slice(0,o),this.leftOver=e.slice(o,e.length))),this.push({data:i.utf8decode(h),meta:t.meta})},l.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=l,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){var s=t("./support"),n=t("./base64"),r=t("./nodejsUtils"),o=t("./external");function a(t){return t}function h(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 h(t,t.length)},i.binstring2buf=function(t){for(var e=new s.Buf8(t.length),i=0,n=e.length;i>10&1023,l[s++]=56320|1023&n)}return h(l,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){e.exports=function(t,e,i,s){for(var n=65535&t,r=t>>>16&65535,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~t}},{}],46:[function(t,e,i){var s,n=t("../utils/common"),r=t("./trees"),o=t("./adler32"),a=t("./crc32"),h=t("./messages"),l=0,c=4,u=0,d=-2,p=-1,f=4,b=2,g=8,m=9,_=286,y=30,x=19,v=2*_+1,w=15,S=3,E=258,T=E+S+1,k=42,C=113,A=1,R=2,N=3,P=4;function O(t,e){return t.msg=h[e],e}function L(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 B(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,I(t.strm)}function F(t,e){t.pending_buf[t.pending++]=e}function D(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function G(t,e){var i,s,n=t.max_chain_length,r=t.strstart,o=t.prev_length,a=t.nice_match,h=t.strstart>t.w_size-T?t.strstart-(t.w_size-T):0,l=t.window,c=t.w_mask,u=t.prev,d=t.strstart+E,p=l[r+o-1],f=l[r+o];t.prev_length>=t.good_match&&(n>>=2),a>t.lookahead&&(a=t.lookahead);do{if(l[(i=e)+o]===f&&l[i+o-1]===p&&l[i]===l[r]&&l[++i]===l[r+1]){r+=2,i++;do{}while(l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&rh&&0!=--n);return o<=t.lookahead?o:t.lookahead}function U(t){var e,i,s,r,h,l,c,u,d,p,f=t.w_size;do{if(r=t.window_size-t.lookahead-t.strstart,t.strstart>=f+(f-T)){for(n.arraySet(t.window,t.window,f,f,0),t.match_start-=f,t.strstart-=f,t.block_start-=f,e=i=t.hash_size;s=t.head[--e],t.head[e]=f<=s?s-f:0,--i;);for(e=i=f;s=t.prev[--e],t.prev[e]=f<=s?s-f:0,--i;);r+=f}if(0===t.strm.avail_in)break;if(l=t.strm,c=t.window,u=t.strstart+t.lookahead,p=void 0,(d=r)<(p=l.avail_in)&&(p=d),i=0===p?0:(l.avail_in-=p,n.arraySet(c,l.input,l.next_in,p,u),1===l.state.wrap?l.adler=o(l.adler,c,p,u):2===l.state.wrap&&(l.adler=a(l.adler,c,p,u)),l.next_in+=p,l.total_in+=p,p),t.lookahead+=i,t.lookahead+t.insert>=S)for(h=t.strstart-t.insert,t.ins_h=t.window[h],t.ins_h=(t.ins_h<=S&&(t.ins_h=(t.ins_h<=S)if(s=r._tr_tally(t,t.strstart-t.match_start,t.match_length-S),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=S){for(t.match_length--;t.strstart++,t.ins_h=(t.ins_h<=S&&(t.ins_h=(t.ins_h<=S&&t.match_length<=t.prev_length){for(n=t.strstart+t.lookahead-S,s=r._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-S),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(U(t),0===t.lookahead&&e===l)return A;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,B(t,!1),0===t.strm.avail_out))return A;if(t.strstart-t.block_start>=t.w_size-T&&(B(t,!1),0===t.strm.avail_out))return A}return t.insert=0,e===c?(B(t,!0),0===t.strm.avail_out?N:P):(t.strstart>t.block_start&&(B(t,!1),t.strm.avail_out),A)})),new Y(4,4,8,4,W),new Y(4,5,16,8,W),new Y(4,6,32,32,W),new Y(4,4,16,16,z),new Y(8,16,32,32,z),new Y(8,16,128,128,z),new Y(8,32,128,256,z),new Y(32,128,258,1024,z),new Y(32,258,258,4096,z)],i.deflateInit=function(t,e){return j(t,e,g,15,8,0)},i.deflateInit2=j,i.deflateReset=V,i.deflateResetKeep=X,i.deflateSetHeader=function(t,e){return t&&t.state?2!==t.state.wrap?d:(t.state.gzhead=e,u):d},i.deflate=function(t,e){var i,n,o,h;if(!t||!t.state||5>8&255),F(n,n.gzhead.time>>16&255),F(n,n.gzhead.time>>24&255),F(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),F(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(F(n,255&n.gzhead.extra.length),F(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):(F(n,0),F(n,0),F(n,0),F(n,0),F(n,0),F(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),F(n,3),n.status=C);else{var p=g+(n.w_bits-8<<4)<<8;p|=(2<=n.strategy||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(p|=32),p+=31-p%31,n.status=C,D(n,p),0!==n.strstart&&(D(n,t.adler>>>16),D(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)),I(t),o=n.pending,n.pending!==n.pending_buf_size));)F(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)),I(t),o=n.pending,n.pending===n.pending_buf_size)){h=1;break}h=n.gzindexo&&(t.adler=a(t.adler,n.pending_buf,n.pending-o,o)),0===h&&(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)),I(t),o=n.pending,n.pending===n.pending_buf_size)){h=1;break}h=n.gzindexo&&(t.adler=a(t.adler,n.pending_buf,n.pending-o,o)),0===h&&(n.status=103)}else n.status=103;if(103===n.status&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&I(t),n.pending+2<=n.pending_buf_size&&(F(n,255&t.adler),F(n,t.adler>>8&255),t.adler=0,n.status=C)):n.status=C),0!==n.pending){if(I(t),0===t.avail_out)return n.last_flush=-1,u}else if(0===t.avail_in&&L(e)<=L(i)&&e!==c)return O(t,-5);if(666===n.status&&0!==t.avail_in)return O(t,-5);if(0!==t.avail_in||0!==n.lookahead||e!==l&&666!==n.status){var f=2===n.strategy?function(t,e){for(var i;;){if(0===t.lookahead&&(U(t),0===t.lookahead)){if(e===l)return A;break}if(t.match_length=0,i=r._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,i&&(B(t,!1),0===t.strm.avail_out))return A}return t.insert=0,e===c?(B(t,!0),0===t.strm.avail_out?N:P):t.last_lit&&(B(t,!1),0===t.strm.avail_out)?A:R}(n,e):3===n.strategy?function(t,e){for(var i,s,n,o,a=t.window;;){if(t.lookahead<=E){if(U(t),t.lookahead<=E&&e===l)return A;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=S&&0t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=S?(i=r._tr_tally(t,1,t.match_length-S),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&&(B(t,!1),0===t.strm.avail_out))return A}return t.insert=0,e===c?(B(t,!0),0===t.strm.avail_out?N:P):t.last_lit&&(B(t,!1),0===t.strm.avail_out)?A:R}(n,e):s[n.level].func(n,e);if(f!==N&&f!==P||(n.status=666),f===A||f===N)return 0===t.avail_out&&(n.last_flush=-1),u;if(f===R&&(1===e?r._tr_align(n):5!==e&&(r._tr_stored_block(n,0,0,!1),3===e&&(M(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),I(t),0===t.avail_out))return n.last_flush=-1,u}return e!==c?u:n.wrap<=0?1:(2===n.wrap?(F(n,255&t.adler),F(n,t.adler>>8&255),F(n,t.adler>>16&255),F(n,t.adler>>24&255),F(n,255&t.total_in),F(n,t.total_in>>8&255),F(n,t.total_in>>16&255),F(n,t.total_in>>24&255)):(D(n,t.adler>>>16),D(n,65535&t.adler)),I(t),0=i.w_size&&(0===a&&(M(i.head),i.strstart=0,i.block_start=0,i.insert=0),p=new n.Buf8(i.w_size),n.arraySet(p,e,f-i.w_size,i.w_size,0),e=p,f=i.w_size),h=t.avail_in,l=t.next_in,c=t.input,t.avail_in=f,t.next_in=0,t.input=e,U(i);i.lookahead>=S;){for(s=i.strstart,r=i.lookahead-(S-1);i.ins_h=(i.ins_h<>>=x=y>>>24,f-=x,0==(x=y>>>16&255))k[r++]=65535&y;else{if(!(16&x)){if(!(64&x)){y=b[(65535&y)+(p&(1<>>=x,f-=x),f<15&&(p+=T[s++]<>>=x=y>>>24,f-=x,!(16&(x=y>>>16&255))){if(!(64&x)){y=g[(65535&y)+(p&(1<>>=x,f-=x,(x=r-o)>3,p&=(1<<(f-=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 g(){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 m(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=d,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(p),e.distcode=e.distdyn=new s.Buf32(f),e.sane=1,e.back=-1,c):u}function _(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,m(t)):u}function y(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,U,2,0),v=x=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&x)<<8)+(x>>8))%31){t.msg="incorrect header check",i.mode=30;break}if(8!=(15&x)){t.msg="unknown compression method",i.mode=30;break}if(v-=4,I=8+(15&(x>>>=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&&(U[0]=255&x,U[1]=x>>>8&255,i.check=r(i.check,U,2,0)),v=x=0,i.mode=3;case 3:for(;v<32;){if(0===_)break t;_--,x+=p[g++]<>>8&255,U[2]=x>>>16&255,U[3]=x>>>24&255,i.check=r(i.check,U,4,0)),v=x=0,i.mode=4;case 4:for(;v<16;){if(0===_)break t;_--,x+=p[g++]<>8),512&i.flags&&(U[0]=255&x,U[1]=x>>>8&255,i.check=r(i.check,U,2,0)),v=x=0,i.mode=5;case 5:if(1024&i.flags){for(;v<16;){if(0===_)break t;_--,x+=p[g++]<>>8&255,i.check=r(i.check,U,2,0)),v=x=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(_<(k=i.length)&&(k=_),k&&(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,p,g,k,I)),512&i.flags&&(i.check=r(i.check,p,k,g)),_-=k,g+=k,i.length-=k),i.length))break t;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===_)break t;for(k=0;I=p[g+k++],i.head&&I&&i.length<65536&&(i.head.name+=String.fromCharCode(I)),I&&k<_;);if(512&i.flags&&(i.check=r(i.check,p,k,g)),_-=k,g+=k,I)break t}else i.head&&(i.head.name=null);i.length=0,i.mode=8;case 8:if(4096&i.flags){if(0===_)break t;for(k=0;I=p[g+k++],i.head&&I&&i.length<65536&&(i.head.comment+=String.fromCharCode(I)),I&&k<_;);if(512&i.flags&&(i.check=r(i.check,p,k,g)),_-=k,g+=k,I)break t}else i.head&&(i.head.comment=null);i.mode=9;case 9:if(512&i.flags){for(;v<16;){if(0===_)break t;_--,x+=p[g++]<>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=12;break;case 10:for(;v<32;){if(0===_)break t;_--,x+=p[g++]<>>=7&v,v-=7&v,i.mode=27;break}for(;v<3;){if(0===_)break t;_--,x+=p[g++]<>>=1)){case 0:i.mode=14;break;case 1:if(E(i),i.mode=20,6!==e)break;x>>>=2,v-=2;break t;case 2:i.mode=17;break;case 3:t.msg="invalid block type",i.mode=30}x>>>=2,v-=2;break;case 14:for(x>>>=7&v,v-=7&v;v<32;){if(0===_)break t;_--,x+=p[g++]<>>16^65535)){t.msg="invalid stored block lengths",i.mode=30;break}if(i.length=65535&x,v=x=0,i.mode=15,6===e)break t;case 15:i.mode=16;case 16:if(k=i.length){if(_>>=5,v-=5,i.ndist=1+(31&x),x>>>=5,v-=5,i.ncode=4+(15&x),x>>>=4,v-=4,286>>=3,v-=3}for(;i.have<19;)i.lens[W[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,F={bits:i.lenbits},B=a(0,i.lens,0,19,i.lencode,0,i.work,F),i.lenbits=F.bits,B){t.msg="invalid code lengths set",i.mode=30;break}i.have=0,i.mode=19;case 19:for(;i.have>>16&255,P=65535&G,!((R=G>>>24)<=v);){if(0===_)break t;_--,x+=p[g++]<>>=R,v-=R,i.lens[i.have++]=P;else{if(16===P){for(D=R+2;v>>=R,v-=R,0===i.have){t.msg="invalid bit length repeat",i.mode=30;break}I=i.lens[i.have-1],k=3+(3&x),x>>>=2,v-=2}else if(17===P){for(D=R+3;v>>=R)),x>>>=3,v-=3}else{for(D=R+7;v>>=R)),x>>>=7,v-=7}if(i.have+k>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=30;break}for(;k--;)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,F={bits:i.lenbits},B=a(h,i.lens,0,i.nlen,i.lencode,0,i.work,F),i.lenbits=F.bits,B){t.msg="invalid literal/lengths set",i.mode=30;break}if(i.distbits=6,i.distcode=i.distdyn,F={bits:i.distbits},B=a(l,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,F),i.distbits=F.bits,B){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<=_&&258<=y){t.next_out=m,t.avail_out=y,t.next_in=g,t.avail_in=_,i.hold=x,i.bits=v,o(t,S),m=t.next_out,f=t.output,y=t.avail_out,g=t.next_in,p=t.input,_=t.avail_in,x=i.hold,v=i.bits,12===i.mode&&(i.back=-1);break}for(i.back=0;N=(G=i.lencode[x&(1<>>16&255,P=65535&G,!((R=G>>>24)<=v);){if(0===_)break t;_--,x+=p[g++]<>O)])>>>16&255,P=65535&G,!(O+(R=G>>>24)<=v);){if(0===_)break t;_--,x+=p[g++]<>>=O,v-=O,i.back+=O}if(x>>>=R,v-=R,i.back+=R,i.length=P,0===N){i.mode=26;break}if(32&N){i.back=-1,i.mode=12;break}if(64&N){t.msg="invalid literal/length code",i.mode=30;break}i.extra=15&N,i.mode=22;case 22:if(i.extra){for(D=i.extra;v>>=i.extra,v-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;N=(G=i.distcode[x&(1<>>16&255,P=65535&G,!((R=G>>>24)<=v);){if(0===_)break t;_--,x+=p[g++]<>O)])>>>16&255,P=65535&G,!(O+(R=G>>>24)<=v);){if(0===_)break t;_--,x+=p[g++]<>>=O,v-=O,i.back+=O}if(x>>>=R,v-=R,i.back+=R,64&N){t.msg="invalid distance code",i.mode=30;break}i.offset=P,i.extra=15&N,i.mode=24;case 24:if(i.extra){for(D=i.extra;v>>=i.extra,v-=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===y)break t;if(k=S-y,i.offset>k){if((k=i.offset-k)>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=30;break}C=k>i.wnext?(k-=i.wnext,i.wsize-k):i.wnext-k,k>i.length&&(k=i.length),A=i.window}else A=f,C=m-i.offset,k=i.length;for(y_?(x=F[D+u[E]],L[M+u[E]]):(x=96,0),p=1<>R)+(f-=p)]=y<<24|x<<16|v,0!==f;);for(p=1<>=1;if(0!==p?(O&=p-1,O+=p):O=0,E++,0==--I[S]){if(S===k)break;S=e[i+u[E]]}if(C>>7)]}function F(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function D(t,e,i){t.bi_valid>b-i?(t.bi_buf|=e<>b-t.bi_valid,t.bi_valid+=i-b):(t.bi_buf|=e<>>=1,i<<=1,0<--e;);return i>>>1}function W(t,e,i){var s,n,r=new Array(f+1),o=0;for(s=1;s<=f;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]=U(r[a]++,a))}}function z(t){var e;for(e=0;e>1;1<=i;i--)X(t,r,i);for(n=h;i=t.heap[1],t.heap[1]=t.heap[t.heap_len--],X(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++,X(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,l=e.max_code,c=e.stat_desc.static_tree,u=e.stat_desc.has_stree,d=e.stat_desc.extra_bits,b=e.stat_desc.extra_base,g=e.stat_desc.max_length,m=0;for(r=0;r<=f;r++)t.bl_count[r]=0;for(h[2*t.heap[t.heap_max]+1]=0,i=t.heap_max+1;i>=7;s>>=1)if(1&i&&0!==t.dyn_ltree[2*e])return n;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return r;for(e=32;e>>3,(a=t.static_len+3+7>>>3)<=o&&(o=a)):o=a=i+5,i+4<=o&&-1!==e?Z(t,e,i,s):4===t.strategy||a===o?(D(t,2+(s?1:0),3),V(t,T,k)):(D(t,4+(s?1:0),3),function(t,e,i,s){var n;for(D(t,e-257,5),D(t,i-1,5),D(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*(A[i]+l+1)]++,t.dyn_dtree[2*B(e)]++),t.last_lit===t.lit_bufsize-1},i._tr_align=function(t){D(t,2,3),G(t,m,T),function(t){16===t.bi_valid?(F(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){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,i,s){(function(t){!function(t,e){if(!t.setImmediate){var i,s,n,r,o=1,a={},h=!1,l=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",p,!1):t.attachEvent("onmessage",p),function(e){t.postMessage(r+e,"*")}):t.MessageChannel?((n=new MessageChannel).port1.onmessage=function(t){d(t.data)},function(t){n.port2.postMessage(t)}):l&&"onreadystatechange"in l.createElement("script")?(s=l.documentElement,function(t){var e=l.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":">",'"':""","'":"'","`":"`","=":"="},hs=/[&<>"'`=]/g,ls=/[&<>"'`=]/;function cs(t){return as[t]}function us(t){for(var e=1;e0?(s.ids&&(s.ids=[s.name]),t.helpers.each(e,s)):n(this);if(s.data&&s.ids){var o=i.createFrame(s.data);o.contextPath=i.appendContextPath(s.data.contextPath,s.name),s={data:o}}return r(e,s)}))},t.exports=e.default}({get exports(){return ms},set exports(t){ms=t}},ms);var _s={};!function(t,e){e.__esModule=!0;var i,s=os,n=(i=bs)&&i.__esModule?i:{default:i};e.default=function(t){t.registerHelper("each",(function(t,e){if(!e)throw new n.default("Must pass iterator to #each");var i,r=e.fn,o=e.inverse,a=0,h="",l=void 0,c=void 0;function u(e,i,n){l&&(l.key=e,l.index=i,l.first=0===i,l.last=!!n,c&&(l.contextPath=c+e)),h+=r(t[e],{data:l,blockParams:s.blockParams([t[e],e],[c+e,null])})}if(e.data&&e.ids&&(c=s.appendContextPath(e.data.contextPath,e.ids[0])+"."),s.isFunction(t)&&(t=t.call(this)),e.data&&(l=s.createFrame(e.data)),t&&"object"==typeof t)if(s.isArray(t))for(var d=t.length;a=0?e:parseInt(t,10)}return t},log:function(t){if(t=s.lookupLevel(t),"undefined"!=typeof console&&s.lookupLevel(s.level)<=t){var e=s.methodMap[t];console[e]||(e="log");for(var i=arguments.length,n=Array(i>1?i-1:0),r=1;r= 2.0.0-beta.1",7:">= 4.0.0 <4.3.0",8:">= 4.3.0"};var Zs="[object Object]";function Js(t,e,i){this.helpers=t||{},this.partials=e||{},this.decorators=i||{},js.registerDefaultHelpers(this),Ks.registerDefaultDecorators(this)}Js.prototype={constructor:Js,logger:$s.default,log:$s.default.log,registerHelper:function(t,e){if(Xs.toString.call(t)===Zs){if(e)throw new Vs.default("Arg not supported with multiple helpers");Xs.extend(this.helpers,t)}else this.helpers[t]=e},unregisterHelper:function(t){delete this.helpers[t]},registerPartial:function(t,e){if(Xs.toString.call(t)===Zs)Xs.extend(this.partials,t);else{if(void 0===e)throw new Vs.default('Attempting to register a partial called "'+t+'" as undefined');this.partials[t]=e}},unregisterPartial:function(t){delete this.partials[t]},registerDecorator:function(t,e){if(Xs.toString.call(t)===Zs){if(e)throw new Vs.default("Arg not supported with multiple decorators");Xs.extend(this.decorators,t)}else this.decorators[t]=e},unregisterDecorator:function(t){delete this.decorators[t]},resetLoggedPropertyAccesses:function(){qs.resetLoggedProperties()}};var Qs=$s.default.log;rs.log=Qs,rs.createFrame=Xs.createFrame,rs.logger=$s.default;var tn={};!function(t,e){function i(t){this.string=t}e.__esModule=!0,i.prototype.toString=i.prototype.toHTML=function(){return""+this.string},e.default=i,t.exports=e.default}({get exports(){return tn},set exports(t){tn=t}},tn);var en={},sn={__esModule:!0,wrapHelper:function(t,e){return"function"!=typeof t?t:function(){return arguments[arguments.length-1]=e(arguments[arguments.length-1]),t.apply(this,arguments)}}};en.__esModule=!0,en.checkRevision=function(t){var e=t&&t[0]||1,i=on.COMPILER_REVISION;if(!(e>=on.LAST_COMPATIBLE_COMPILER_REVISION&&e<=on.COMPILER_REVISION)){if(e2&&_.push("'"+this.terminals_[b]+"'");v=this.lexer.showPosition?"Parse error on line "+(a+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+_.join(", ")+", got '"+(this.terminals_[u]||u)+"'":"Parse error on line "+(a+1)+": Unexpected "+(1==u?"end of input":"'"+(this.terminals_[u]||u)+"'"),this.parseError(v,{text:this.lexer.match,token:this.terminals_[u]||u,line:this.lexer.yylineno,loc:l,expected:_})}if(p[0]instanceof Array&&p.length>1)throw new Error("Parse Error: multiple actions possible at state: "+d+", token: "+u);switch(p[0]){case 1:i.push(u),s.push(this.lexer.yytext),n.push(this.lexer.yylloc),i.push(p[1]),u=null,h=this.lexer.yyleng,o=this.lexer.yytext,a=this.lexer.yylineno,l=this.lexer.yylloc;break;case 2:if(g=this.productions_[p[1]][1],x.$=s[s.length-g],x._$={first_line:n[n.length-(g||1)].first_line,last_line:n[n.length-1].last_line,first_column:n[n.length-(g||1)].first_column,last_column:n[n.length-1].last_column},c&&(x._$.range=[n[n.length-(g||1)].range[0],n[n.length-1].range[1]]),void 0!==(f=this.performAction.call(x,o,h,a,this.yy,p[1],s,n)))return f;g&&(i=i.slice(0,-1*g*2),s=s.slice(0,-1*g),n=n.slice(0,-1*g)),i.push(this.productions_[p[1]][0]),s.push(x.$),n.push(x._$),m=r[i[i.length-2]][i[i.length-1]],i.push(m);break;case 3:return!0}}return!0}},e=function(){var t={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},setInput:function(t){return this._input=t,this._more=this._less=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,i=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e-1),this.offset-=e;var s=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),i.length-1&&(this.yylineno-=i.length-1);var n=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:i?(i.length===s.length?this.yylloc.first_column:0)+s[s.length-i.length].length-i[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[n[0],n[0]+this.yyleng-e]),this},more:function(){return this._more=!0,this},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},next:function(){if(this.done)return this.EOF;var t,e,i,s,n;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var r=this._currentRules(),o=0;oe[0].length)||(e=i,s=o,this.options.flex));o++);return e?((n=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],t=this.performAction.call(this,this.yy,this,r[s],this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),t||void 0):""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return void 0!==t?t:this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){return this.conditionStack.pop()},_currentRules:function(){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules},topState:function(){return this.conditionStack[this.conditionStack.length-2]},pushState:function(t){this.begin(t)},options:{},performAction:function(t,e,i,s){function n(t,i){return e.yytext=e.yytext.substring(t,e.yyleng-i+t)}switch(i){case 0:if("\\\\"===e.yytext.slice(-2)?(n(0,1),this.begin("mu")):"\\"===e.yytext.slice(-1)?(n(0,1),this.begin("emu")):this.begin("mu"),e.yytext)return 15;break;case 1:case 5:return 15;case 2:return this.popState(),15;case 3:return this.begin("raw"),15;case 4:return this.popState(),"raw"===this.conditionStack[this.conditionStack.length-1]?15:(n(5,9),"END_RAW_BLOCK");case 6:case 22:return this.popState(),14;case 7:return 65;case 8:return 68;case 9:return 19;case 10:return this.popState(),this.begin("raw"),23;case 11:return 55;case 12:return 60;case 13:return 29;case 14:return 47;case 15:case 16:return this.popState(),44;case 17:return 34;case 18:return 39;case 19:return 51;case 20:case 23:return 48;case 21:this.unput(e.yytext),this.popState(),this.begin("com");break;case 24:return 73;case 25:case 26:case 41:return 72;case 27:return 87;case 28:break;case 29:return this.popState(),54;case 30:return this.popState(),33;case 31:return e.yytext=n(1,2).replace(/\\"/g,'"'),80;case 32:return e.yytext=n(1,2).replace(/\\'/g,"'"),80;case 33:return 85;case 34:case 35:return 82;case 36:return 83;case 37:return 84;case 38:return 81;case 39:return 75;case 40:return 77;case 42:return e.yytext=e.yytext.replace(/\\([\\\]])/g,"$1"),72;case 43:return"INVALID";case 44:return 5}},rules:[/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/,/^(?:\{\{\{\{(?=[^/]))/,/^(?:\{\{\{\{\/[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.])\}\}\}\})/,/^(?:[^\x00]+?(?=(\{\{\{\{)))/,/^(?:[\s\S]*?--(~)?\}\})/,/^(?:\()/,/^(?:\))/,/^(?:\{\{\{\{)/,/^(?:\}\}\}\})/,/^(?:\{\{(~)?>)/,/^(?:\{\{(~)?#>)/,/^(?:\{\{(~)?#\*?)/,/^(?:\{\{(~)?\/)/,/^(?:\{\{(~)?\^\s*(~)?\}\})/,/^(?:\{\{(~)?\s*else\s*(~)?\}\})/,/^(?:\{\{(~)?\^)/,/^(?:\{\{(~)?\s*else\b)/,/^(?:\{\{(~)?\{)/,/^(?:\{\{(~)?&)/,/^(?:\{\{(~)?!--)/,/^(?:\{\{(~)?![\s\S]*?\}\})/,/^(?:\{\{(~)?\*?)/,/^(?:=)/,/^(?:\.\.)/,/^(?:\.(?=([=~}\s\/.)|])))/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}(~)?\}\})/,/^(?:(~)?\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=([~}\s)])))/,/^(?:false(?=([~}\s)])))/,/^(?:undefined(?=([~}\s)])))/,/^(?:null(?=([~}\s)])))/,/^(?:-?[0-9]+(?:\.[0-9]+)?(?=([~}\s)])))/,/^(?:as\s+\|)/,/^(?:\|)/,/^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)|]))))/,/^(?:\[(\\\]|[^\]])*\])/,/^(?:.)/,/^(?:$)/],conditions:{mu:{rules:[7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44],inclusive:!1},emu:{rules:[2],inclusive:!1},com:{rules:[6],inclusive:!1},raw:{rules:[3,4,5],inclusive:!1},INITIAL:{rules:[0,1,44],inclusive:!0}}};return t}();function i(){this.yy={}}return t.lexer=e,i.prototype=t,t.Parser=i,new i}();e.default=i,t.exports=e.default}({get exports(){return gn},set exports(t){gn=t}},gn);var mn={},_n={get exports(){return mn},set exports(t){mn=t}},yn={};!function(t,e){e.__esModule=!0;var i=function(t){return t&&t.__esModule?t:{default:t}}(bs);function s(){this.parents=[]}function n(t){this.acceptRequired(t,"path"),this.acceptArray(t.params),this.acceptKey(t,"hash")}function r(t){n.call(this,t),this.acceptKey(t,"program"),this.acceptKey(t,"inverse")}function o(t){this.acceptRequired(t,"name"),this.acceptArray(t.params),this.acceptKey(t,"hash")}s.prototype={constructor:s,mutating:!1,acceptKey:function(t,e){var n=this.accept(t[e]);if(this.mutating){if(n&&!s.prototype[n.type])throw new i.default('Unexpected node type "'+n.type+'" found when accepting '+e+" on "+t.type);t[e]=n}},acceptRequired:function(t,e){if(this.acceptKey(t,e),!t[e])throw new i.default(t.type+" requires "+e)},acceptArray:function(t){for(var e=0,i=t.length;e0)throw new vn.default("Invalid path: "+s,{loc:i});".."===h&&r++}}return{type:"PathExpression",data:t,depth:r,parts:n,original:s,loc:i}},prepareMustache:function(t,e,i,s,n,r){var o=s.charAt(3)||s.charAt(2),a="{"!==o&&"&"!==o;return{type:/\*/.test(s)?"Decorator":"MustacheStatement",path:t,params:e,hash:i,escaped:a,strip:n,loc:this.locInfo(r)}},prepareRawBlock:function(t,e,i,s){wn(t,i),s=this.locInfo(s);var n={type:"Program",body:e,strip:{},loc:s};return{type:"BlockStatement",path:t.path,params:t.params,hash:t.hash,program:n,openStrip:{},inverseStrip:{},closeStrip:{},loc:s}},prepareBlock:function(t,e,i,s,n,r){s&&s.path&&wn(t,s);var o=/\*/.test(t.open);e.blockParams=t.blockParams;var a=void 0,h=void 0;if(i){if(o)throw new vn.default("Unexpected inverse block on decorator",i);i.chain&&(i.program.body[0].closeStrip=s.strip),h=i.strip,a=i.program}return n&&(n=a,a=e,e=n),{type:o?"DecoratorBlock":"BlockStatement",path:t.path,params:t.params,hash:t.hash,program:e,inverse:a,openStrip:t.strip,inverseStrip:h,closeStrip:s&&s.strip,loc:this.locInfo(r)}},prepareProgram:function(t,e){if(!e&&t.length){var i=t[0].loc,s=t[t.length-1].loc;i&&s&&(e={source:i.source,start:{line:i.start.line,column:i.start.column},end:{line:s.end.line,column:s.end.column}})}return{type:"Program",body:t,strip:{},loc:e}},preparePartialBlock:function(t,e,i,s){return wn(t,i),{type:"PartialBlockStatement",name:t.path,params:t.params,hash:t.hash,program:e,openStrip:t.strip,closeStrip:i&&i.strip,loc:this.locInfo(s)}}},vn=function(t){return t&&t.__esModule?t:{default:t}}(bs);function wn(t,e){if(e=e.path?e.path.original:e,t.path.original!==e){var i={loc:t.path.loc};throw new vn.default(t.path.original+" doesn't match "+e,i)}}function Sn(t){return t&&t.__esModule?t:{default:t}}bn.__esModule=!0,bn.parseWithoutProcessing=Rn,bn.parse=function(t,e){var i=Rn(t,e);return new Tn.default(e).accept(i)};var En=Sn(gn),Tn=Sn(mn),kn=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e.default=t,e}(xn),Cn=os;bn.parser=En.default;var An={};function Rn(t,e){return"Program"===t.type?t:(En.default.yy=An,An.locInfo=function(t){return new An.SourceLocation(e&&e.srcName,t)},En.default.parse(t))}Cn.extend(An,kn);var Nn={};function Pn(t){return t&&t.__esModule?t:{default:t}}Nn.__esModule=!0,Nn.Compiler=Bn,Nn.precompile=function(t,e,i){if(null==t||"string"!=typeof t&&"Program"!==t.type)throw new On.default("You must pass a string or Handlebars AST to Handlebars.precompile. You passed "+t);"data"in(e=e||{})||(e.data=!0),e.compat&&(e.useDepths=!0);var s=i.parse(t,e),n=(new i.Compiler).compile(s,e);return(new i.JavaScriptCompiler).compile(n,e)},Nn.compile=function(t,e,i){if(void 0===e&&(e={}),null==t||"string"!=typeof t&&"Program"!==t.type)throw new On.default("You must pass a string or Handlebars AST to Handlebars.compile. You passed "+t);"data"in(e=Ln.extend({},e))||(e.data=!0),e.compat&&(e.useDepths=!0);var s=void 0;function n(){var s=i.parse(t,e),n=(new i.Compiler).compile(s,e),r=(new i.JavaScriptCompiler).compile(n,e,void 0,!0);return i.template(r)}function r(t,e){return s||(s=n()),s.call(this,t,e)}return r._setup=function(t){return s||(s=n()),s._setup(t)},r._child=function(t,e,i,r){return s||(s=n()),s._child(t,e,i,r)},r};var On=Pn(bs),Ln=os,Mn=Pn(fn),In=[].slice;function Bn(){}function Fn(t,e){if(t===e)return!0;if(Ln.isArray(t)&&Ln.isArray(e)&&t.length===e.length){for(var i=0;i1)throw new On.default("Unsupported number of partial arguments: "+i.length,t);i.length||(this.options.explicitPartialContext?this.opcode("pushLiteral","undefined"):i.push({type:"PathExpression",parts:[],depth:0}));var s=t.name.original,n="SubExpression"===t.name.type;n&&this.accept(t.name),this.setupFullMustacheParams(t,e,void 0,!0);var r=t.indent||"";this.options.preventIndent&&r&&(this.opcode("appendContent",r),r=""),this.opcode("invokePartial",n,s,r),this.opcode("append")},PartialBlockStatement:function(t){this.PartialStatement(t)},MustacheStatement:function(t){this.SubExpression(t),t.escaped&&!this.options.noEscape?this.opcode("appendEscaped"):this.opcode("append")},Decorator:function(t){this.DecoratorBlock(t)},ContentStatement:function(t){t.value&&this.opcode("appendContent",t.value)},CommentStatement:function(){},SubExpression:function(t){Dn(t);var e=this.classifySexpr(t);"simple"===e?this.simpleSexpr(t):"helper"===e?this.helperSexpr(t):this.ambiguousSexpr(t)},ambiguousSexpr:function(t,e,i){var s=t.path,n=s.parts[0],r=null!=e||null!=i;this.opcode("getContext",s.depth),this.opcode("pushProgram",e),this.opcode("pushProgram",i),s.strict=!0,this.accept(s),this.opcode("invokeAmbiguous",n,r)},simpleSexpr:function(t){var e=t.path;e.strict=!0,this.accept(e),this.opcode("resolvePossibleLambda")},helperSexpr:function(t,e,i){var s=this.setupFullMustacheParams(t,e,i),n=t.path,r=n.parts[0];if(this.options.knownHelpers[r])this.opcode("invokeKnownHelper",s.length,r);else{if(this.options.knownHelpersOnly)throw new On.default("You specified knownHelpersOnly, but used the unknown helper "+r,t);n.strict=!0,n.falsy=!0,this.accept(n),this.opcode("invokeHelper",s.length,n.original,Mn.default.helpers.simpleId(n))}},PathExpression:function(t){this.addDepth(t.depth),this.opcode("getContext",t.depth);var e=t.parts[0],i=Mn.default.helpers.scopedId(t),s=!t.depth&&!i&&this.blockParamIndex(e);s?this.opcode("lookupBlockParam",s,t.parts):e?t.data?(this.options.data=!0,this.opcode("lookupData",t.depth,t.parts,t.strict)):this.opcode("lookupOnContext",t.parts,t.falsy,t.strict,i):this.opcode("pushContext")},StringLiteral:function(t){this.opcode("pushString",t.value)},NumberLiteral:function(t){this.opcode("pushLiteral",t.value)},BooleanLiteral:function(t){this.opcode("pushLiteral",t.value)},UndefinedLiteral:function(){this.opcode("pushLiteral","undefined")},NullLiteral:function(){this.opcode("pushLiteral","null")},Hash:function(t){var e=t.pairs,i=0,s=e.length;for(this.opcode("pushHash");i=0)return[e,n]}}};var Gn,Un,Wn={},zn={get exports(){return Wn},set exports(t){Wn=t}},Yn={},Hn={},Xn={},Vn={},jn={};function Kn(){if(Un)return Vn;Un=1;var t=function(){if(Gn)return jn;Gn=1;var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");return jn.encode=function(e){if(0<=e&&e>>=5)>0&&(i|=32),s+=t.encode(i)}while(n>0);return s},Vn.decode=function(e,i,s){var n,r,o,a,h=e.length,l=0,c=0;do{if(i>=h)throw new Error("Expected more digits in base 64 VLQ value.");if(-1===(r=t.decode(e.charCodeAt(i++))))throw new Error("Invalid base64 digit: "+e.charAt(i-1));n=!!(32&r),l+=(r&=31)<>1,1&~o?a:-a),s.rest=i},Vn}var $n,qn={};function Zn(){return $n||($n=1,function(t){t.getArg=function(t,e,i){if(e in t)return t[e];if(3===arguments.length)return i;throw new Error('"'+e+'" is a required argument.')};var e=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,i=/^data:.+\,.+$/;function s(t){var i=t.match(e);return i?{scheme:i[1],auth:i[2],host:i[3],port:i[4],path:i[5]}:null}function n(t){var e="";return t.scheme&&(e+=t.scheme+":"),e+="//",t.auth&&(e+=t.auth+"@"),t.host&&(e+=t.host),t.port&&(e+=":"+t.port),t.path&&(e+=t.path),e}function r(e){var i=e,r=s(e);if(r){if(!r.path)return e;i=r.path}for(var o,a=t.isAbsolute(i),h=i.split(/\/+/),l=0,c=h.length-1;c>=0;c--)"."===(o=h[c])?h.splice(c,1):".."===o?l++:l>0&&(""===o?(h.splice(c+1,l),l=0):(h.splice(c,2),l--));return""===(i=h.join("/"))&&(i=a?"/":"."),r?(r.path=i,n(r)):i}function o(t,e){""===t&&(t="."),""===e&&(e=".");var o=s(e),a=s(t);if(a&&(t=a.path||"/"),o&&!o.scheme)return a&&(o.scheme=a.scheme),n(o);if(o||e.match(i))return e;if(a&&!a.host&&!a.path)return a.host=e,n(a);var h="/"===e.charAt(0)?e:r(t.replace(/\/+$/,"")+"/"+e);return a?(a.path=h,n(a)):h}t.urlParse=s,t.urlGenerate=n,t.normalize=r,t.join=o,t.isAbsolute=function(t){return"/"===t.charAt(0)||e.test(t)},t.relative=function(t,e){""===t&&(t="."),t=t.replace(/\/$/,"");for(var i=0;0!==e.indexOf(t+"/");){var s=t.lastIndexOf("/");if(s<0)return e;if((t=t.slice(0,s)).match(/^([^\/]+:\/)?\/*$/))return e;++i}return Array(i+1).join("../")+e.substr(t.length+1)};var a=!("__proto__"in Object.create(null));function h(t){return t}function l(t){if(!t)return!1;var e=t.length;if(e<9)return!1;if(95!==t.charCodeAt(e-1)||95!==t.charCodeAt(e-2)||111!==t.charCodeAt(e-3)||116!==t.charCodeAt(e-4)||111!==t.charCodeAt(e-5)||114!==t.charCodeAt(e-6)||112!==t.charCodeAt(e-7)||95!==t.charCodeAt(e-8)||95!==t.charCodeAt(e-9))return!1;for(var i=e-10;i>=0;i--)if(36!==t.charCodeAt(i))return!1;return!0}function c(t,e){return t===e?0:null===t?1:null===e?-1:t>e?1:-1}t.toSetString=a?h:function(t){return l(t)?"$"+t:t},t.fromSetString=a?h:function(t){return l(t)?t.slice(1):t},t.compareByOriginalPositions=function(t,e,i){var s=c(t.source,e.source);return 0!==s||0!=(s=t.originalLine-e.originalLine)||0!=(s=t.originalColumn-e.originalColumn)||i||0!=(s=t.generatedColumn-e.generatedColumn)||0!=(s=t.generatedLine-e.generatedLine)?s:c(t.name,e.name)},t.compareByGeneratedPositionsDeflated=function(t,e,i){var s=t.generatedLine-e.generatedLine;return 0!==s||0!=(s=t.generatedColumn-e.generatedColumn)||i||0!==(s=c(t.source,e.source))||0!=(s=t.originalLine-e.originalLine)||0!=(s=t.originalColumn-e.originalColumn)?s:c(t.name,e.name)},t.compareByGeneratedPositionsInflated=function(t,e){var i=t.generatedLine-e.generatedLine;return 0!==i||0!=(i=t.generatedColumn-e.generatedColumn)||0!==(i=c(t.source,e.source))||0!=(i=t.originalLine-e.originalLine)||0!=(i=t.originalColumn-e.originalColumn)?i:c(t.name,e.name)},t.parseSourceMapInput=function(t){return JSON.parse(t.replace(/^\)]}'[^\n]*\n/,""))},t.computeSourceURL=function(t,e,i){if(e=e||"",t&&("/"!==t[t.length-1]&&"/"!==e[0]&&(t+="/"),e=t+e),i){var a=s(i);if(!a)throw new Error("sourceMapURL could not be parsed");if(a.path){var h=a.path.lastIndexOf("/");h>=0&&(a.path=a.path.substring(0,h+1))}e=o(n(a),e)}return r(e)}}(qn)),qn}var Jn,Qn={};function tr(){if(Jn)return Qn;Jn=1;var t=Zn(),e=Object.prototype.hasOwnProperty,i="undefined"!=typeof Map;function s(){this._array=[],this._set=i?new Map:Object.create(null)}return s.fromArray=function(t,e){for(var i=new s,n=0,r=t.length;n=0)return n}else{var r=t.toSetString(s);if(e.call(this._set,r))return this._set[r]}throw new Error('"'+s+'" is not in the set.')},s.prototype.at=function(t){if(t>=0&&tn||r==n&&a>=o||t.compareByGeneratedPositionsInflated(i,s)<=0?(this._last=e,this._array.push(e)):(this._sorted=!1,this._array.push(e))},e.prototype.toArray=function(){return this._sorted||(this._array.sort(t.compareByGeneratedPositionsInflated),this._sorted=!0),this._array},sr.MappingList=e,sr}function rr(){if(ir)return Xn;ir=1;var t=Kn(),e=Zn(),i=tr().ArraySet,s=nr().MappingList;function n(t){t||(t={}),this._file=e.getArg(t,"file",null),this._sourceRoot=e.getArg(t,"sourceRoot",null),this._skipValidation=e.getArg(t,"skipValidation",!1),this._sources=new i,this._names=new i,this._mappings=new s,this._sourcesContents=null}return n.prototype._version=3,n.fromSourceMap=function(t){var i=t.sourceRoot,s=new n({file:t.file,sourceRoot:i});return t.eachMapping((function(t){var n={generated:{line:t.generatedLine,column:t.generatedColumn}};null!=t.source&&(n.source=t.source,null!=i&&(n.source=e.relative(i,n.source)),n.original={line:t.originalLine,column:t.originalColumn},null!=t.name&&(n.name=t.name)),s.addMapping(n)})),t.sources.forEach((function(n){var r=n;null!==i&&(r=e.relative(i,n)),s._sources.has(r)||s._sources.add(r);var o=t.sourceContentFor(n);null!=o&&s.setSourceContent(n,o)})),s},n.prototype.addMapping=function(t){var i=e.getArg(t,"generated"),s=e.getArg(t,"original",null),n=e.getArg(t,"source",null),r=e.getArg(t,"name",null);this._skipValidation||this._validateMapping(i,s,n,r),null!=n&&(n=String(n),this._sources.has(n)||this._sources.add(n)),null!=r&&(r=String(r),this._names.has(r)||this._names.add(r)),this._mappings.add({generatedLine:i.line,generatedColumn:i.column,originalLine:null!=s&&s.line,originalColumn:null!=s&&s.column,source:n,name:r})},n.prototype.setSourceContent=function(t,i){var s=t;null!=this._sourceRoot&&(s=e.relative(this._sourceRoot,s)),null!=i?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[e.toSetString(s)]=i):this._sourcesContents&&(delete this._sourcesContents[e.toSetString(s)],0===Object.keys(this._sourcesContents).length&&(this._sourcesContents=null))},n.prototype.applySourceMap=function(t,s,n){var r=s;if(null==s){if(null==t.file)throw new Error('SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map\'s "file" property. Both were omitted.');r=t.file}var o=this._sourceRoot;null!=o&&(r=e.relative(o,r));var a=new i,h=new i;this._mappings.unsortedForEach((function(i){if(i.source===r&&null!=i.originalLine){var s=t.originalPositionFor({line:i.originalLine,column:i.originalColumn});null!=s.source&&(i.source=s.source,null!=n&&(i.source=e.join(n,i.source)),null!=o&&(i.source=e.relative(o,i.source)),i.originalLine=s.line,i.originalColumn=s.column,null!=s.name&&(i.name=s.name))}var l=i.source;null==l||a.has(l)||a.add(l);var c=i.name;null==c||h.has(c)||h.add(c)}),this),this._sources=a,this._names=h,t.sources.forEach((function(i){var s=t.sourceContentFor(i);null!=s&&(null!=n&&(i=e.join(n,i)),null!=o&&(i=e.relative(o,i)),this.setSourceContent(i,s))}),this)},n.prototype._validateMapping=function(t,e,i,s){if(e&&"number"!=typeof e.line&&"number"!=typeof e.column)throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.");if((!(t&&"line"in t&&"column"in t&&t.line>0&&t.column>=0)||e||i||s)&&!(t&&"line"in t&&"column"in t&&e&&"line"in e&&"column"in e&&t.line>0&&t.column>=0&&e.line>0&&e.column>=0&&i))throw new Error("Invalid mapping: "+JSON.stringify({generated:t,source:i,original:e,name:s}))},n.prototype._serializeMappings=function(){for(var i,s,n,r,o=0,a=1,h=0,l=0,c=0,u=0,d="",p=this._mappings.toArray(),f=0,b=p.length;f0){if(!e.compareByGeneratedPositionsInflated(s,p[f-1]))continue;i+=","}i+=t.encode(s.generatedColumn-o),o=s.generatedColumn,null!=s.source&&(r=this._sources.indexOf(s.source),i+=t.encode(r-u),u=r,i+=t.encode(s.originalLine-1-l),l=s.originalLine-1,i+=t.encode(s.originalColumn-h),h=s.originalColumn,null!=s.name&&(n=this._names.indexOf(s.name),i+=t.encode(n-c),c=n)),d+=i}return d},n.prototype._generateSourcesContent=function(t,i){return t.map((function(t){if(!this._sourcesContents)return null;null!=i&&(t=e.relative(i,t));var s=e.toSetString(t);return Object.prototype.hasOwnProperty.call(this._sourcesContents,s)?this._sourcesContents[s]:null}),this)},n.prototype.toJSON=function(){var t={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return null!=this._file&&(t.file=this._file),null!=this._sourceRoot&&(t.sourceRoot=this._sourceRoot),this._sourcesContents&&(t.sourcesContent=this._generateSourcesContent(t.sources,t.sourceRoot)),t},n.prototype.toString=function(){return JSON.stringify(this.toJSON())},Xn.SourceMapGenerator=n,Xn}var or,ar={},hr={};function lr(){return or||(or=1,function(t){function e(i,s,n,r,o,a){var h=Math.floor((s-i)/2)+i,l=o(n,r[h],!0);return 0===l?h:l>0?s-h>1?e(h,s,n,r,o,a):a==t.LEAST_UPPER_BOUND?s1?e(i,h,n,r,o,a):a==t.LEAST_UPPER_BOUND?h:i<0?-1:i}t.GREATEST_LOWER_BOUND=1,t.LEAST_UPPER_BOUND=2,t.search=function(i,s,n,r){if(0===s.length)return-1;var o=e(-1,s.length,i,s,n,r||t.GREATEST_LOWER_BOUND);if(o<0)return-1;for(;o-1>=0&&0===n(s[o],s[o-1],!0);)--o;return o}}(hr)),hr}var cr,ur,dr={};function pr(){if(cr)return dr;function t(t,e,i){var s=t[e];t[e]=t[i],t[i]=s}function e(i,s,n,r){if(n=0){var a=this._originalMappings[o];if(void 0===i.column)for(var h=a.originalLine;a&&a.originalLine===h;)r.push({line:t.getArg(a,"generatedLine",null),column:t.getArg(a,"generatedColumn",null),lastColumn:t.getArg(a,"lastGeneratedColumn",null)}),a=this._originalMappings[++o];else for(var l=a.originalColumn;a&&a.originalLine===s&&a.originalColumn==l;)r.push({line:t.getArg(a,"generatedLine",null),column:t.getArg(a,"generatedColumn",null),lastColumn:t.getArg(a,"lastGeneratedColumn",null)}),a=this._originalMappings[++o]}return r},ar.SourceMapConsumer=r,o.prototype=Object.create(r.prototype),o.prototype.consumer=r,o.prototype._findSourceIndex=function(e){var i,s=e;if(null!=this.sourceRoot&&(s=t.relative(this.sourceRoot,s)),this._sources.has(s))return this._sources.indexOf(s);for(i=0;i1&&(r.source=b+h[1],b+=h[1],r.originalLine=p+h[2],p=r.originalLine,r.originalLine+=1,r.originalColumn=f+h[3],f=r.originalColumn,h.length>4&&(r.name=g+h[4],g+=h[4])),w.push(r),"number"==typeof r.originalLine&&v.push(r)}n(w,t.compareByGeneratedPositionsDeflated),this.__generatedMappings=w,n(v,t.compareByOriginalPositions),this.__originalMappings=v},o.prototype._findMapping=function(t,i,s,n,r,o){if(t[s]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+t[s]);if(t[n]<0)throw new TypeError("Column must be greater than or equal to 0, got "+t[n]);return e.search(t,i,r,o)},o.prototype.computeColumnSpans=function(){for(var t=0;t=0){var n=this._generatedMappings[s];if(n.generatedLine===i.generatedLine){var o=t.getArg(n,"source",null);null!==o&&(o=this._sources.at(o),o=t.computeSourceURL(this.sourceRoot,o,this._sourceMapURL));var a=t.getArg(n,"name",null);return null!==a&&(a=this._names.at(a)),{source:o,line:t.getArg(n,"originalLine",null),column:t.getArg(n,"originalColumn",null),name:a}}}return{source:null,line:null,column:null,name:null}},o.prototype.hasContentsOfAllSources=function(){return!!this.sourcesContent&&this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some((function(t){return null==t}))},o.prototype.sourceContentFor=function(e,i){if(!this.sourcesContent)return null;var s=this._findSourceIndex(e);if(s>=0)return this.sourcesContent[s];var n,r=e;if(null!=this.sourceRoot&&(r=t.relative(this.sourceRoot,r)),null!=this.sourceRoot&&(n=t.urlParse(this.sourceRoot))){var o=r.replace(/^file:\/\//,"");if("file"==n.scheme&&this._sources.has(o))return this.sourcesContent[this._sources.indexOf(o)];if((!n.path||"/"==n.path)&&this._sources.has("/"+r))return this.sourcesContent[this._sources.indexOf("/"+r)]}if(i)return null;throw new Error('"'+r+'" is not in the SourceMap.')},o.prototype.generatedPositionFor=function(e){var i=t.getArg(e,"source");if((i=this._findSourceIndex(i))<0)return{line:null,column:null,lastColumn:null};var s={source:i,originalLine:t.getArg(e,"line"),originalColumn:t.getArg(e,"column")},n=this._findMapping(s,this._originalMappings,"originalLine","originalColumn",t.compareByOriginalPositions,t.getArg(e,"bias",r.GREATEST_LOWER_BOUND));if(n>=0){var o=this._originalMappings[n];if(o.source===s.source)return{line:t.getArg(o,"generatedLine",null),column:t.getArg(o,"generatedColumn",null),lastColumn:t.getArg(o,"lastGeneratedColumn",null)}}return{line:null,column:null,lastColumn:null}},ar.BasicSourceMapConsumer=o,h.prototype=Object.create(r.prototype),h.prototype.constructor=r,h.prototype._version=3,Object.defineProperty(h.prototype,"sources",{get:function(){for(var t=[],e=0;e=0;e--)this.prepend(t[e]);else{if(!t[s]&&"string"!=typeof t)throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+t);this.children.unshift(t)}return this},n.prototype.walk=function(t){for(var e,i=0,n=this.children.length;i0){for(e=[],i=0;i0&&(i+=", "+s.join(", "));var n=0;Object.keys(this.aliases).forEach((function(t){var s=e.aliases[t];s.children&&s.referenceCount>1&&(i+=", alias"+ ++n+"="+t,s.children[0]="alias"+n)})),this.lookupPropertyFunctionIsUsed&&(i+=", "+this.lookupPropertyFunctionVarDeclaration());var r=["container","depth0","helpers","partials","data"];(this.useBlockParams||this.useDepths)&&r.push("blockParams"),this.useDepths&&r.push("depths");var o=this.mergeSource(i);return t?(r.push(o),Function.apply(this,r)):this.source.wrap(["function(",r.join(","),") {\n ",o,"}"])},mergeSource:function(t){var e=this.environment.isSimple,i=!this.forceBuffer,s=void 0,n=void 0,r=void 0,o=void 0;return this.source.each((function(t){t.appendToBuffer?(r?t.prepend(" + "):r=t,o=t):(r&&(n?r.prepend("buffer += "):s=!0,o.add(";"),r=o=void 0),n=!0,e||(i=!1))})),i?r?(r.prepend("return "),o.add(";")):n||this.source.push('return "";'):(t+=", buffer = "+(s?"":this.initializeBuffer()),r?(r.prepend("return buffer + "),o.add(";")):this.source.push("return buffer;")),t&&this.source.prepend("var "+t.substring(2)+(s?"":";\n")),this.source.merge()},lookupPropertyFunctionVarDeclaration:function(){return"\n lookupProperty = container.lookupProperty || function(parent, propertyName) {\n if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {\n return parent[propertyName];\n }\n return undefined\n }\n ".trim()},blockValue:function(t){var e=this.aliasable("container.hooks.blockHelperMissing"),i=[this.contextName(0)];this.setupHelperArgs(t,0,i);var s=this.popStack();i.splice(1,0,s),this.push(this.source.functionCall(e,"call",i))},ambiguousBlockValue:function(){var t=this.aliasable("container.hooks.blockHelperMissing"),e=[this.contextName(0)];this.setupHelperArgs("",0,e,!0),this.flushInline();var i=this.topStack();e.splice(1,0,i),this.pushSource(["if (!",this.lastHelper,") { ",i," = ",this.source.functionCall(t,"call",e),"}"])},appendContent:function(t){this.pendingContent?t=this.pendingContent+t:this.pendingLocation=this.source.currentLocation,this.pendingContent=t},append:function(){if(this.isInline())this.replaceStack((function(t){return[" != null ? ",t,' : ""']})),this.pushSource(this.appendToBuffer(this.popStack()));else{var t=this.popStack();this.pushSource(["if (",t," != null) { ",this.appendToBuffer(t,void 0,!0)," }"]),this.environment.isSimple&&this.pushSource(["else { ",this.appendToBuffer("''",void 0,!0)," }"])}},appendEscaped:function(){this.pushSource(this.appendToBuffer([this.aliasable("container.escapeExpression"),"(",this.popStack(),")"]))},getContext:function(t){this.lastContext=t},pushContext:function(){this.pushStackLiteral(this.contextName(this.lastContext))},lookupOnContext:function(t,e,i,s){var n=0;s||!this.options.compat||this.lastContext?this.pushContext():this.push(this.depthedLookup(t[n++])),this.resolvePath("context",t,n,e,i)},lookupBlockParam:function(t,e){this.useBlockParams=!0,this.push(["blockParams[",t[0],"][",t[1],"]"]),this.resolvePath("context",e,1)},lookupData:function(t,e,i){t?this.pushStackLiteral("container.data(data, "+t+")"):this.pushStackLiteral("data"),this.resolvePath("data",e,0,!0,i)},resolvePath:function(t,e,i,s,n){var r=this;if(this.options.strict||this.options.assumeObjects)this.push(function(t,e,i,s,n){var r=e.popStack(),o=i.length;for(t&&o--;sthis.stackVars.length&&this.stackVars.push("stack"+this.stackSlot),this.topStackName()},topStackName:function(){return"stack"+this.stackSlot},flushInline:function(){var t=this.inlineStack;this.inlineStack=[];for(var e=0,i=t.length;e>2)/e)*e:3*o+1>>2,h=new Uint8Array(a),l=0,c=0,u=0;u64&&n<91?n-65:n>96&&n<123?n-71:n>47&&n<58?n+4:43===n?62:47===n?63:0)<<18-6*s,3===s||o-u==1){for(i=0;i<3&&c>>(16>>>i&24)&255;l=0}return h}},wr=function(t,e){return new Promise((function(i,s){var n=new XMLHttpRequest;e&&(n.responseType=e),n.open("GET",t),n.onload=function(){200===n.status?i(n.response):s(Error(n.statusText))},n.onerror=function(){s(Error("Network Error"))},n.send()}))};!function(t){var e=vr,i=wr;function s(t){return function(e){return"string"==typeof e&&t.test(e)}}function n(t,e){return"string"==typeof t?t+e:"function"==typeof t?t(e):e}function r(t,e,i,s){var n=e instanceof ArrayBuffer?o:a(e)?h:function(t){return t&&"function"==typeof t.then}(e)?l:c(e)?u:function(t){return t&&"object"==typeof t}(e)?d:p(e)?f:b(e)?g:m(e)?_:null;return n?n(t,e,i||{}):s?Promise.resolve(s):Promise.reject("Source not valid ("+e+")")}function o(t,e,i){return new Promise((function(i,s){t.decodeAudioData(e,(function(t){i(t)}),(function(){s("Can't decode audio data ("+e.slice(0,30)+"...)")}))}))}r.fetch=i;var a=s(/\.(mp3|wav|ogg)(\?.*)?$/i);function h(t,e,i){var s=n(i.from,e);return r(t,r.fetch(s,"arraybuffer"),i)}function l(t,e,i){return e.then((function(e){return r(t,e,i)}))}var c=Array.isArray;function u(t,e,i){return Promise.all(e.map((function(e){return r(t,e,i,e)})))}function d(t,e,i){var s={},n=Object.keys(e).map((function(n){if(i.only&&-1===i.only.indexOf(n))return null;var o=e[n];return r(t,o,i,o).then((function(t){s[n]=t}))}));return Promise.all(n).then((function(){return s}))}var p=s(/\.json(\?.*)?$/i);function f(t,e,i){var s=n(i.from,e);return r(t,r.fetch(s,"text").then(JSON.parse),i)}var b=s(/^data:audio/);function g(t,i,s){var n=i.indexOf(",");return r(t,e.decode(i.slice(n+1)).buffer,s)}var m=s(/\.js(\?.*)?$/i);function _(t,e,i){var s=n(i.from,e);return r(t,r.fetch(s,"text").then(y),i)}function y(t){var e=t.indexOf("MIDI.Soundfont.");if(e<0)throw Error("Invalid MIDI.js Soundfont format");e=t.indexOf("=",e)+2;var i=t.lastIndexOf(",");return JSON.parse(t.slice(e,i)+"}")}t.exports&&(t.exports=r),"undefined"!=typeof window&&(window.loadAudio=r)}({get exports(){return xr},set exports(t){xr=t}});var Sr={},Er={get exports(){return Sr},set exports(t){Sr=t}},Tr=function(t){var e=t.createGain(),i=e._voltage=function(t){var e=t.createBufferSource(),i=t.createBuffer(1,2,t.sampleRate);return i.getChannelData(0).set(Cr),e.buffer=i,e.loop=!0,e}(t),s=Ar(i),n=Ar(i),r=Ar(i);return e._startAmount=Ar(n),e._endAmount=Ar(r),e._multiplier=Ar(s),e._multiplier.connect(e),e._startAmount.connect(e),e._endAmount.connect(e),e.value=s.gain,e.startValue=n.gain,e.endValue=r.gain,e.startValue.value=0,e.endValue.value=0,Object.defineProperties(e,kr),e},kr={attack:{value:0,writable:!0},decay:{value:0,writable:!0},sustain:{value:1,writable:!0},release:{value:0,writable:!0},getReleaseDuration:{value:function(){return this.release}},start:{value:function(t){var e=this._multiplier.gain,i=this._startAmount.gain,s=this._endAmount.gain;this._voltage.start(t),this._decayFrom=this._decayFrom=t+this.attack,this._startedAt=t;var n=this.sustain;e.cancelScheduledValues(t),i.cancelScheduledValues(t),s.cancelScheduledValues(t),s.setValueAtTime(0,t),this.attack?(e.setValueAtTime(0,t),e.linearRampToValueAtTime(1,t+this.attack),i.setValueAtTime(1,t),i.linearRampToValueAtTime(0,t+this.attack)):(e.setValueAtTime(1,t),i.setValueAtTime(0,t)),this.decay&&e.setTargetAtTime(n,this._decayFrom,Rr(this.decay))}},stop:{value:function(t,e){e&&(t-=this.release);var i=t+this.release;if(this.release){var s=this._multiplier.gain,n=this._startAmount.gain,r=this._endAmount.gain;s.cancelScheduledValues(t),n.cancelScheduledValues(t),r.cancelScheduledValues(t);var o=Rr(this.release);if(this.attack&&t=e&&(o=e),o}(0,1,this._startedAt,this._decayFrom,t);s.linearRampToValueAtTime(a,t),n.linearRampToValueAtTime(1-a,t),n.setTargetAtTime(0,t,o)}r.setTargetAtTime(1,t,o),s.setTargetAtTime(0,t,o)}return this._voltage.stop(i),i}},onended:{get:function(){return this._voltage.onended},set:function(t){this._voltage.onended=t}}},Cr=new Float32Array([1,1]);function Ar(t){var e=t.context.createGain();return t.connect(e),e}function Rr(t){return Math.log(t+1)/Math.log(100)}var Nr=Tr,Pr={},Or={gain:1,attack:.01,decay:.1,sustain:.9,release:.3,loop:!1,cents:0,loopStart:0,loopEnd:0};function Lr(t){return"number"==typeof t}var Mr=["attack","decay","sustain","release"],Ir=function(t,e,i){var s=!1,n=0,r={},o=t.createGain();o.gain.value=1;var a=Object.assign({},Or,i),h={context:t,out:o,opts:a};return e instanceof AudioBuffer?h.buffer=e:h.buffers=e,h.start=function(e,i,o){if(h.buffer&&null!==e)return h.start(null,e,i);var a=e?h.buffers[e]:h.buffer;if(a){if(s){var c=o||Pr;i=Math.max(t.currentTime,i||0),h.emit("start",i,e,c);var u=l(e,a,c);return u.id=function(e,i){return i.id=n++,r[i.id]=i,i.startTime=t.currentTime,i.source.onended=function(){var e=t.currentTime;i.source.disconnect(),i.env.disconnect(),i.disconnect(),h.emit("ended",e,i.id,i)},i.id}(0,u),u.env.start(i),u.source.start(i),h.emit("started",i,u.id,u),c.duration&&u.stop(i+c.duration),u}console.warn("SamplePlayer not connected to any node.")}else console.warn("Buffer "+e+" not found.")},h.play=function(t,e,i){return h.start(t,e,i)},h.stop=function(t,e){var i;return(e=e||Object.keys(r)).map((function(e){return(i=r[e])?(i.stop(t),i.id):null}))},h.connect=function(t){return s=!0,o.connect(t),h},h.emit=function(t,e,i,s){h.onevent&&h.onevent(t,e,i,s);var n=h["on"+t];n&&n.forEach((t=>{t(e,i,s)}))},h;function l(e,i,s){var n,r=t.createGain();return r.gain.value=0,r.connect(o),r.env=function(t,e,i){var s=Nr(t),n=e.adsr||i.adsr;return Mr.forEach((function(t,r){s[t]=n?n[r]:e[t]||i[t]})),s.value.value=Lr(e.gain)?e.gain:Lr(i.gain)?i.gain:1,s}(t,s,a),r.env.connect(r.gain),r.source=t.createBufferSource(),r.source.buffer=i,r.source.connect(r),r.source.loop=s.loop||a.loop,r.source.playbackRate.value=(n=s.cents||a.cents)?Math.pow(2,n/1200):1,r.source.loopStart=s.loopStart||a.loopStart,r.source.loopEnd=s.loopEnd||a.loopEnd,r.stop=function(i){var s=i||t.currentTime;h.emit("stop",s,e);var n=r.env.stop(s);r.source.stop(n)},r}},Br=function(t){return t.on=function(e,i){if(1===arguments.length&&"function"==typeof e)return t.on("event",e);var s="on"+e;return t[s]?t[s].push(i):t[s]=[i],t},t},Fr=/^([a-gA-G])(#{1,}|b{1,}|x{1,}|)(-?\d*)\s*(.*)\s*$/,Dr=[0,2,4,5,7,9,11];function Gr(t,e,i){if("string"!=typeof t)return null;var s=Fr.exec(t);if(!s||!e&&s[4])return null;var n={letter:s[1].toUpperCase(),acc:s[2].replace(/x/g,"##")};return n.pc=n.letter+n.acc,n.step=(n.letter.charCodeAt(0)+3)%7,n.alt="b"===n.acc[0]?-n.acc.length:n.acc.length,n.chroma=Dr[n.step]+n.alt,s[3]&&(n.oct=+s[3],n.midi=n.chroma+12*(n.oct+1),n.freq=Ur(n.midi,i)),e&&(n.tonicOf=s[4]),n}function Ur(t,e){return Math.pow(2,(t-69)/12)*(e||440)}var Wr={parse:Gr,regex:function(){return Fr},midiToFreq:Ur};["letter","acc","pc","step","alt","chroma","oct","midi","freq"].forEach((function(t){Wr[t]=function(e){var i=Gr(e);return i&&void 0!==i[t]?i[t]:null}}));var zr=Wr,Yr=function(t){return function(t){return null!==t&&t!==[]&&t>=0&&t<129}(t)?+t:zr.midi(t)},Hr=function(t){if(t.buffers){var e=t.opts.map,i="function"==typeof e?e:Yr,s=function(t){return t?i(t)||t:null};t.buffers=function(t,e){return Object.keys(t).reduce((function(i,s){return i[e(s)]=t[s],i}),{})}(t.buffers,s);var n=t.start;t.start=function(t,e,i){var r=s(t),o=r%1;return o&&(r=Math.floor(r),i=Object.assign(i||{},{cents:Math.floor(100*o)})),n(r,e,i)}}return t},Xr=Array.isArray,Vr={},jr=function(t){return t.schedule=function(e,i){var s,n,r,o,a=t.context.currentTime,h=e=0&&t<128)return+t;var e=io(t);return e&&function(t){return void 0!==t}(e.midi)?e.midi:null}const no=Object.freeze(Object.defineProperty({__proto__:null,acc:function(t){return(io(t)||{}).acc},alt:function(t){return(io(t)||{}).alt},build:function t(e,i,s){return null==e?null:e.step?t(e.step,e.alt,e.oct):e<0||e>6?null:"CDEFGAB".charAt(e)+(Jr(n=i)?n<0?Zr("b",-n):Zr("#",n):"")+function(t){return Jr(t)?""+t:""}(s);var n},chroma:function(t){return(io(t)||{}).chroma},freq:function(t,e){var i=so(t);return null===i?null:Qr(i,e)},letter:function(t){return(io(t)||{}).letter},midi:so,oct:function(t){return(io(t)||{}).oct},parse:io,pc:function(t){return(io(t)||{}).pc},regex:function(){return to},step:function(t){return(io(t)||{}).step}},Symbol.toStringTag,{value:"Module"})),ro=i(no);var oo,ao;!function(t){var e=xr,i=Sr;function s(t){return/\.js(\?.*)?$/i.test(t)}function n(t,e,i){return"https://gleitz.github.io/midi-js-soundfonts/"+(e="FluidR3_GM"===e?e:"MusyngKite")+"/"+t+"-"+(i="ogg"===i?i:"mp3")+".js"}var r=function(){if(ao)return oo;ao=1;var t=ro;function e(t,i){if(console.warn("new Soundfont() is deprected"),!(this instanceof e))return new e(t);this.nameToUrl=i||e.nameToUrl,this.ctx=t,this.instruments={},this.promises=[]}function i(e,i){return i=i||{},function(s,n,r,o){console.warn("The oscillator player is deprecated.");var a=s>0&&s<129?+s:t.midi(s),h=a?t.midiToFreq(a,440):null;if(h){r=r||.2;var l=(o=o||{}).destination||i.destination||e.destination,c=o.vcoType||i.vcoType||"sine",u=o.gain||i.gain||.4,d=e.createOscillator();d.type=c,d.frequency.value=h;var p=e.createGain();return p.gain.value=u,d.connect(p),p.connect(l),d.start(n),r>0&&d.stop(n+r),d}}}return e.prototype.onready=function(t){console.warn("deprecated API"),Promise.all(this.promises).then(t)},e.prototype.instrument=function(t,s){console.warn("new Soundfont().instrument() is deprecated.");var n=this.ctx;if((t=t||"default")in this.instruments)return this.instruments[t];var r={name:t,play:i(n,s)};if(this.instruments[t]=r,"default"!==t){var o=e.instrument(n,t,s).then((function(t){return r.play=t.play,r}));this.promises.push(o),r.onready=function(t){console.warn("onready is deprecated. Use Soundfont.instrument().then()"),o.then(t)}}else r.onready=function(t){console.warn("onready is deprecated. Use Soundfont.instrument().then()"),t()};return r},e.loadBuffers=function(t,i,s){return console.warn("Soundfont.loadBuffers is deprecate."),e.instrument(t,i,s).then((function(t){return t.buffers}))},e.noteToMidi=t.midi,oo=e}();r.instrument=function t(r,o,a){if(1===arguments.length)return function(e,i){return t(r,e,i)};var h=a||{},l=h.isSoundfontURL||s,c=h.nameToUrl||n,u=l(o)?o:c(o,h.soundfont,h.format);return e(r,u,{only:h.only||h.notes}).then((function(t){var e=i(r,t,h).connect(h.destination?h.destination:r.destination);return e.url=u,e.name=o,e}))},r.nameToUrl=n,t.exports&&(t.exports=r),"undefined"!=typeof window&&(window.Soundfont=r)}(yr)}}}));