vextab 7.0.0 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/runtime/auto.mjs +1 -1
- package/dist/runtime/browser.mjs +1 -1
- package/dist/runtime/parse.mjs +1 -1
- package/dist/runtime/resolve.mjs +1 -0
- package/dist/runtime/shared/OKFI2OP5.mjs +1 -0
- package/dist/runtime/shared/OWAKZY4J.mjs +352 -0
- package/dist/runtime/shared/SGMFW7I5.mjs +2 -0
- package/dist/runtime/shared/TH2FBVEP.mjs +20 -0
- package/dist/runtime/types/browser.d.ts +2 -0
- package/dist/runtime/types/playback/decorations.d.ts +1 -1
- package/dist/runtime/types/score/commands.d.ts +1 -1
- package/dist/runtime/types/score/drums.d.ts +1 -1
- package/dist/runtime/types/score/layout-map.d.ts +61 -0
- package/dist/runtime/types/score/layout.d.ts +4 -0
- package/dist/runtime/types/score/model.d.ts +2 -0
- package/dist/runtime/types/score/music.d.ts +1 -1
- package/dist/runtime/types/score/resolve.d.ts +7 -0
- package/dist/runtime/vextab.js +10 -10
- package/package.json +5 -1
- package/dist/runtime/shared/PRHM4TS2.mjs +0 -21
- package/dist/runtime/shared/TVARZYJR.mjs +0 -352
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import{a as ne,b as ke,c as Lt}from"./SGMFW7I5.mjs";import{a as an}from"./3EDRGUJG.mjs";import{b as nn}from"./WEGSFFPO.mjs";import{a as wt,b as rn,c as Ee,d as on,e as re,f as sn,g as yt}from"./OKFI2OP5.mjs";import{a as Et,b as et,c as Kt,d as X,e as pt,f as Xe,g as $e,h as Zt,i as Je,j as Ke,k as Qt,l as bt,m as Ft,n as te,p as Ze,q as Qe,t as tt,u as tn,v as ee,w as en}from"./TH2FBVEP.mjs";import{a as Ue,b as nr}from"./7VX7ANVZ.mjs";var Tn=Ue((Pn,Mn)=>{(function(a,t){typeof define=="function"&&define.amd?define(function(){return t(a)}):t(a)})(Pn,function(){var a=(function(){var t,e,n,r,o=[],s=o.concat,i=o.filter,c=o.slice,l=window.document,d={},h={},f={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},m=/^\s*<(\w+|!)[^>]*>/,g=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,b=/^(?:body|html)$/i,k=/([A-Z])/g,_=["val","css","html","text","data","width","height","offset"],C=["after","prepend","before","append"],S=l.createElement("table"),p=l.createElement("tr"),A={tr:l.createElement("tbody"),tbody:S,thead:S,tfoot:S,td:p,th:p,"*":l.createElement("div")},I=/complete|loaded|interactive/,L=/^[\w-]*$/,V={},P=V.toString,x={},F,v,E=l.createElement("div"),B={tabindex:"tabIndex",readonly:"readOnly",for:"htmlFor",class:"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},H=Array.isArray||function(u){return u instanceof Array};x.matches=function(u,w){if(!w||!u||u.nodeType!==1)return!1;var M=u.matches||u.webkitMatchesSelector||u.mozMatchesSelector||u.oMatchesSelector||u.matchesSelector;if(M)return M.call(u,w);var O,Y=u.parentNode,W=!Y;return W&&(Y=E).appendChild(u),O=~x.qsa(Y,w).indexOf(u),W&&E.removeChild(u),O};function z(u){return u==null?String(u):V[P.call(u)]||"object"}function D(u){return z(u)=="function"}function U(u){return u!=null&&u==u.window}function j(u){return u!=null&&u.nodeType==u.DOCUMENT_NODE}function K(u){return z(u)=="object"}function $(u){return K(u)&&!U(u)&&Object.getPrototypeOf(u)==Object.prototype}function T(u){var w=!!u&&"length"in u&&u.length,M=n.type(u);return M!="function"&&!U(u)&&(M=="array"||w===0||typeof w=="number"&&w>0&&w-1 in u)}function R(u){return i.call(u,function(w){return w!=null})}function J(u){return u.length>0?n.fn.concat.apply([],u):u}F=function(u){return u.replace(/-+(.)?/g,function(w,M){return M?M.toUpperCase():""})};function G(u){return u.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}v=function(u){return i.call(u,function(w,M){return u.indexOf(w)==M})};function q(u){return u in h?h[u]:h[u]=new RegExp("(^|\\s)"+u+"(\\s|$)")}function Z(u,w){return typeof w=="number"&&!f[G(u)]?w+"px":w}function Q(u){var w,M;return d[u]||(w=l.createElement(u),l.body.appendChild(w),M=getComputedStyle(w,"").getPropertyValue("display"),w.parentNode.removeChild(w),M=="none"&&(M="block"),d[u]=M),d[u]}function it(u){return"children"in u?c.call(u.children):n.map(u.childNodes,function(w){if(w.nodeType==1)return w})}function lt(u,w){var M,O=u?u.length:0;for(M=0;M<O;M++)this[M]=u[M];this.length=O,this.selector=w||""}x.fragment=function(u,w,M){var O,Y,W;return g.test(u)&&(O=n(l.createElement(RegExp.$1))),O||(u.replace&&(u=u.replace(y,"<$1></$2>")),w===t&&(w=m.test(u)&&RegExp.$1),w in A||(w="*"),W=A[w],W.innerHTML=""+u,O=n.each(c.call(W.childNodes),function(){W.removeChild(this)})),$(M)&&(Y=n(O),n.each(M,function(mt,ft){_.indexOf(mt)>-1?Y[mt](ft):Y.attr(mt,ft)})),O},x.Z=function(u,w){return new lt(u,w)},x.isZ=function(u){return u instanceof x.Z},x.init=function(u,w){var M;if(u)if(typeof u=="string")if(u=u.trim(),u[0]=="<"&&m.test(u))M=x.fragment(u,RegExp.$1,w),u=null;else{if(w!==t)return n(w).find(u);M=x.qsa(l,u)}else{if(D(u))return n(l).ready(u);if(x.isZ(u))return u;if(H(u))M=R(u);else if(K(u))M=[u],u=null;else if(m.test(u))M=x.fragment(u.trim(),RegExp.$1,w),u=null;else{if(w!==t)return n(w).find(u);M=x.qsa(l,u)}}else return x.Z();return x.Z(M,u)},n=function(u,w){return x.init(u,w)};function rt(u,w,M){for(e in w)M&&($(w[e])||H(w[e]))?($(w[e])&&!$(u[e])&&(u[e]={}),H(w[e])&&!H(u[e])&&(u[e]=[]),rt(u[e],w[e],M)):w[e]!==t&&(u[e]=w[e])}n.extend=function(u){var w,M=c.call(arguments,1);return typeof u=="boolean"&&(w=u,u=M.shift()),M.forEach(function(O){rt(u,O,w)}),u},x.qsa=function(u,w){var M,O=w[0]=="#",Y=!O&&w[0]==".",W=O||Y?w.slice(1):w,mt=L.test(W);return u.getElementById&&mt&&O?(M=u.getElementById(W))?[M]:[]:u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11?[]:c.call(mt&&!O&&u.getElementsByClassName?Y?u.getElementsByClassName(W):u.getElementsByTagName(w):u.querySelectorAll(w))};function nt(u,w){return w==null?n(u):n(u).filter(w)}n.contains=l.documentElement.contains?function(u,w){return u!==w&&u.contains(w)}:function(u,w){for(;w&&(w=w.parentNode);)if(w===u)return!0;return!1};function at(u,w,M,O){return D(w)?w.call(u,M,O):w}function ht(u,w,M){M==null?u.removeAttribute(w):u.setAttribute(w,M)}function ut(u,w){var M=u.className||"",O=M&&M.baseVal!==t;if(w===t)return O?M.baseVal:M;O?M.baseVal=w:u.className=w}function We(u){try{return u&&(u=="true"||(u=="false"?!1:u=="null"?null:+u+""==u?+u:/^[\[\{]/.test(u)?n.parseJSON(u):u))}catch{return u}}n.type=z,n.isFunction=D,n.isWindow=U,n.isArray=H,n.isPlainObject=$,n.isEmptyObject=function(u){var w;for(w in u)return!1;return!0},n.isNumeric=function(u){var w=Number(u),M=typeof u;return u!=null&&M!="boolean"&&(M!="string"||u.length)&&!isNaN(w)&&isFinite(w)||!1},n.inArray=function(u,w,M){return o.indexOf.call(w,u,M)},n.camelCase=F,n.trim=function(u){return u==null?"":String.prototype.trim.call(u)},n.uuid=0,n.support={},n.expr={},n.noop=function(){},n.map=function(u,w){var M,O=[],Y,W;if(T(u))for(Y=0;Y<u.length;Y++)M=w(u[Y],Y),M!=null&&O.push(M);else for(W in u)M=w(u[W],W),M!=null&&O.push(M);return J(O)},n.each=function(u,w){var M,O;if(T(u)){for(M=0;M<u.length;M++)if(w.call(u[M],M,u[M])===!1)return u}else for(O in u)if(w.call(u[O],O,u[O])===!1)return u;return u},n.grep=function(u,w){return i.call(u,w)},window.JSON&&(n.parseJSON=JSON.parse),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(u,w){V["[object "+w+"]"]=w.toLowerCase()}),n.fn={constructor:x.Z,length:0,forEach:o.forEach,reduce:o.reduce,push:o.push,sort:o.sort,splice:o.splice,indexOf:o.indexOf,concat:function(){var u,w,M=[];for(u=0;u<arguments.length;u++)w=arguments[u],M[u]=x.isZ(w)?w.toArray():w;return s.apply(x.isZ(this)?this.toArray():this,M)},map:function(u){return n(n.map(this,function(w,M){return u.call(w,M,w)}))},slice:function(){return n(c.apply(this,arguments))},ready:function(u){return I.test(l.readyState)&&l.body?u(n):l.addEventListener("DOMContentLoaded",function(){u(n)},!1),this},get:function(u){return u===t?c.call(this):this[u>=0?u:u+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each(function(){this.parentNode!=null&&this.parentNode.removeChild(this)})},each:function(u){return o.every.call(this,function(w,M){return u.call(w,M,w)!==!1}),this},filter:function(u){return D(u)?this.not(this.not(u)):n(i.call(this,function(w){return x.matches(w,u)}))},add:function(u,w){return n(v(this.concat(n(u,w))))},is:function(u){return this.length>0&&x.matches(this[0],u)},not:function(u){var w=[];if(D(u)&&u.call!==t)this.each(function(O){u.call(this,O)||w.push(this)});else{var M=typeof u=="string"?this.filter(u):T(u)&&D(u.item)?c.call(u):n(u);this.forEach(function(O){M.indexOf(O)<0&&w.push(O)})}return n(w)},has:function(u){return this.filter(function(){return K(u)?n.contains(this,u):n(this).find(u).size()})},eq:function(u){return u===-1?this.slice(u):this.slice(u,+u+1)},first:function(){var u=this[0];return u&&!K(u)?u:n(u)},last:function(){var u=this[this.length-1];return u&&!K(u)?u:n(u)},find:function(u){var w,M=this;return u?typeof u=="object"?w=n(u).filter(function(){var O=this;return o.some.call(M,function(Y){return n.contains(Y,O)})}):this.length==1?w=n(x.qsa(this[0],u)):w=this.map(function(){return x.qsa(this,u)}):w=n(),w},closest:function(u,w){var M=[],O=typeof u=="object"&&n(u);return this.each(function(Y,W){for(;W&&!(O?O.indexOf(W)>=0:x.matches(W,u));)W=W!==w&&!j(W)&&W.parentNode;W&&M.indexOf(W)<0&&M.push(W)}),n(M)},parents:function(u){for(var w=[],M=this;M.length>0;)M=n.map(M,function(O){if((O=O.parentNode)&&!j(O)&&w.indexOf(O)<0)return w.push(O),O});return nt(w,u)},parent:function(u){return nt(v(this.pluck("parentNode")),u)},children:function(u){return nt(this.map(function(){return it(this)}),u)},contents:function(){return this.map(function(){return this.contentDocument||c.call(this.childNodes)})},siblings:function(u){return nt(this.map(function(w,M){return i.call(it(M.parentNode),function(O){return O!==M})}),u)},empty:function(){return this.each(function(){this.innerHTML=""})},pluck:function(u){return n.map(this,function(w){return w[u]})},show:function(){return this.each(function(){this.style.display=="none"&&(this.style.display=""),getComputedStyle(this,"").getPropertyValue("display")=="none"&&(this.style.display=Q(this.nodeName))})},replaceWith:function(u){return this.before(u).remove()},wrap:function(u){var w=D(u);if(this[0]&&!w)var M=n(u).get(0),O=M.parentNode||this.length>1;return this.each(function(Y){n(this).wrapAll(w?u.call(this,Y):O?M.cloneNode(!0):M)})},wrapAll:function(u){if(this[0]){n(this[0]).before(u=n(u));for(var w;(w=u.children()).length;)u=w.first();n(u).append(this)}return this},wrapInner:function(u){var w=D(u);return this.each(function(M){var O=n(this),Y=O.contents(),W=w?u.call(this,M):u;Y.length?Y.wrapAll(W):O.append(W)})},unwrap:function(){return this.parent().each(function(){n(this).replaceWith(n(this).children())}),this},clone:function(){return this.map(function(){return this.cloneNode(!0)})},hide:function(){return this.css("display","none")},toggle:function(u){return this.each(function(){var w=n(this);(u===t?w.css("display")=="none":u)?w.show():w.hide()})},prev:function(u){return n(this.pluck("previousElementSibling")).filter(u||"*")},next:function(u){return n(this.pluck("nextElementSibling")).filter(u||"*")},html:function(u){return 0 in arguments?this.each(function(w){var M=this.innerHTML;n(this).empty().append(at(this,u,w,M))}):0 in this?this[0].innerHTML:null},text:function(u){return 0 in arguments?this.each(function(w){var M=at(this,u,w,this.textContent);this.textContent=M==null?"":""+M}):0 in this?this.pluck("textContent").join(""):null},attr:function(u,w){var M;return typeof u=="string"&&!(1 in arguments)?0 in this&&this[0].nodeType==1&&(M=this[0].getAttribute(u))!=null?M:t:this.each(function(O){if(this.nodeType===1)if(K(u))for(e in u)ht(this,e,u[e]);else ht(this,u,at(this,w,O,this.getAttribute(u)))})},removeAttr:function(u){return this.each(function(){this.nodeType===1&&u.split(" ").forEach(function(w){ht(this,w)},this)})},prop:function(u,w){return u=B[u]||u,1 in arguments?this.each(function(M){this[u]=at(this,w,M,this[u])}):this[0]&&this[0][u]},removeProp:function(u){return u=B[u]||u,this.each(function(){delete this[u]})},data:function(u,w){var M="data-"+u.replace(k,"-$1").toLowerCase(),O=1 in arguments?this.attr(M,w):this.attr(M);return O!==null?We(O):t},val:function(u){return 0 in arguments?(u==null&&(u=""),this.each(function(w){this.value=at(this,u,w,this.value)})):this[0]&&(this[0].multiple?n(this[0]).find("option").filter(function(){return this.selected}).pluck("value"):this[0].value)},offset:function(u){if(u)return this.each(function(M){var O=n(this),Y=at(this,u,M,O.offset()),W=O.offsetParent().offset(),mt={top:Y.top-W.top,left:Y.left-W.left};O.css("position")=="static"&&(mt.position="relative"),O.css(mt)});if(!this.length)return null;if(l.documentElement!==this[0]&&!n.contains(l.documentElement,this[0]))return{top:0,left:0};var w=this[0].getBoundingClientRect();return{left:w.left+window.pageXOffset,top:w.top+window.pageYOffset,width:Math.round(w.width),height:Math.round(w.height)}},css:function(u,w){if(arguments.length<2){var M=this[0];if(typeof u=="string")return M?M.style[F(u)]||getComputedStyle(M,"").getPropertyValue(u):void 0;if(H(u)){if(!M)return;var O={},Y=getComputedStyle(M,"");return n.each(u,function(mt,ft){O[ft]=M.style[F(ft)]||Y.getPropertyValue(ft)}),O}}var W="";if(z(u)=="string")!w&&w!==0?this.each(function(){this.style.removeProperty(G(u))}):W=G(u)+":"+Z(u,w);else for(e in u)!u[e]&&u[e]!==0?this.each(function(){this.style.removeProperty(G(e))}):W+=G(e)+":"+Z(e,u[e])+";";return this.each(function(){this.style.cssText+=";"+W})},index:function(u){return u?this.indexOf(n(u)[0]):this.parent().children().indexOf(this[0])},hasClass:function(u){return u?o.some.call(this,function(w){return this.test(ut(w))},q(u)):!1},addClass:function(u){return u?this.each(function(w){if("className"in this){r=[];var M=ut(this),O=at(this,u,w,M);O.split(/\s+/g).forEach(function(Y){n(this).hasClass(Y)||r.push(Y)},this),r.length&&ut(this,M+(M?" ":"")+r.join(" "))}}):this},removeClass:function(u){return this.each(function(w){if("className"in this){if(u===t)return ut(this,"");r=ut(this),at(this,u,w,r).split(/\s+/g).forEach(function(M){r=r.replace(q(M)," ")}),ut(this,r.trim())}})},toggleClass:function(u,w){return u?this.each(function(M){var O=n(this),Y=at(this,u,M,ut(this));Y.split(/\s+/g).forEach(function(W){(w===t?!O.hasClass(W):w)?O.addClass(W):O.removeClass(W)})}):this},scrollTop:function(u){if(this.length){var w="scrollTop"in this[0];return u===t?w?this[0].scrollTop:this[0].pageYOffset:this.each(w?function(){this.scrollTop=u}:function(){this.scrollTo(this.scrollX,u)})}},scrollLeft:function(u){if(this.length){var w="scrollLeft"in this[0];return u===t?w?this[0].scrollLeft:this[0].pageXOffset:this.each(w?function(){this.scrollLeft=u}:function(){this.scrollTo(u,this.scrollY)})}},position:function(){if(this.length){var u=this[0],w=this.offsetParent(),M=this.offset(),O=b.test(w[0].nodeName)?{top:0,left:0}:w.offset();return M.top-=parseFloat(n(u).css("margin-top"))||0,M.left-=parseFloat(n(u).css("margin-left"))||0,O.top+=parseFloat(n(w[0]).css("border-top-width"))||0,O.left+=parseFloat(n(w[0]).css("border-left-width"))||0,{top:M.top-O.top,left:M.left-O.left}}},offsetParent:function(){return this.map(function(){for(var u=this.offsetParent||l.body;u&&!b.test(u.nodeName)&&n(u).css("position")=="static";)u=u.offsetParent;return u})}},n.fn.detach=n.fn.remove,["width","height"].forEach(function(u){var w=u.replace(/./,function(M){return M[0].toUpperCase()});n.fn[u]=function(M){var O,Y=this[0];return M===t?U(Y)?Y["inner"+w]:j(Y)?Y.documentElement["scroll"+w]:(O=this.offset())&&O[u]:this.each(function(W){Y=n(this),Y.css(u,at(this,M,W,Y[u]()))})}});function qe(u,w){w(u);for(var M=0,O=u.childNodes.length;M<O;M++)qe(u.childNodes[M],w)}return C.forEach(function(u,w){var M=w%2;n.fn[u]=function(){var O,Y=n.map(arguments,function(ft){var dt=[];return O=z(ft),O=="array"?(ft.forEach(function(_t){if(_t.nodeType!==t)return dt.push(_t);if(n.zepto.isZ(_t))return dt=dt.concat(_t.get());dt=dt.concat(x.fragment(_t))}),dt):O=="object"||ft==null?ft:x.fragment(ft)}),W,mt=this.length>1;return Y.length<1?this:this.each(function(ft,dt){W=M?dt:dt.parentNode,dt=w==0?dt.nextSibling:w==1?dt.firstChild:w==2?dt:null;var _t=n.contains(l.documentElement,W);Y.forEach(function(Gt){if(mt)Gt=Gt.cloneNode(!0);else if(!W)return n(Gt).remove();W.insertBefore(Gt,dt),_t&&qe(Gt,function(kt){if(kt.nodeName!=null&&kt.nodeName.toUpperCase()==="SCRIPT"&&(!kt.type||kt.type==="text/javascript")&&!kt.src){var Ye=kt.ownerDocument?kt.ownerDocument.defaultView:window;Ye.eval.call(Ye,kt.innerHTML)}})})})},n.fn[M?u+"To":"insert"+(w?"Before":"After")]=function(O){return n(O)[u](this),this}}),x.Z.prototype=lt.prototype=n.fn,x.uniq=v,x.deserializeValue=We,n.zepto=x,n})();return window.Zepto=a,window.$===void 0&&(window.$=a),Mn.exports=a,(function(t){var e=1,n,r=Array.prototype.slice,o=t.isFunction,s=function(P){return typeof P=="string"},i={},c={},l="onfocusin"in window,d={focus:"focusin",blur:"focusout"},h={mouseenter:"mouseover",mouseleave:"mouseout"};c.click=c.mousedown=c.mouseup=c.mousemove="MouseEvents";function f(P){return P._zid||(P._zid=e++)}function m(P,x,F,v){if(x=g(x),x.ns)var E=y(x.ns);return(i[f(P)]||[]).filter(function(B){return B&&(!x.e||B.e==x.e)&&(!x.ns||E.test(B.ns))&&(!F||f(B.fn)===f(F))&&(!v||B.sel==v)})}function g(P){var x=(""+P).split(".");return{e:x[0],ns:x.slice(1).sort().join(" ")}}function y(P){return new RegExp("(?:^| )"+P.replace(" "," .* ?")+"(?: |$)")}function b(P,x){return P.del&&!l&&P.e in d||!!x}function k(P){return h[P]||l&&d[P]||P}function _(P,x,F,v,E,B,H){var z=f(P),D=i[z]||(i[z]=[]);x.split(/\s/).forEach(function(U){if(U=="ready")return t(document).ready(F);var j=g(U);j.fn=F,j.sel=E,j.e in h&&(F=function($){var T=$.relatedTarget;if(!T||T!==this&&!t.contains(this,T))return j.fn.apply(this,arguments)}),j.del=B;var K=B||F;j.proxy=function($){if($=L($),!$.isImmediatePropagationStopped()){$.data=v;var T=K.apply(P,$._args==n?[$]:[$].concat($._args));return T===!1&&($.preventDefault(),$.stopPropagation()),T}},j.i=D.length,D.push(j),"addEventListener"in P&&P.addEventListener(k(j.e),j.proxy,b(j,H))})}function C(P,x,F,v,E){var B=f(P);(x||"").split(/\s/).forEach(function(H){m(P,H,F,v).forEach(function(z){delete i[B][z.i],"removeEventListener"in P&&P.removeEventListener(k(z.e),z.proxy,b(z,E))})})}t.event={add:_,remove:C},t.proxy=function(P,x){var F=2 in arguments&&r.call(arguments,2);if(o(P)){var v=function(){return P.apply(x,F?F.concat(r.call(arguments)):arguments)};return v._zid=f(P),v}else{if(s(x))return F?(F.unshift(P[x],P),t.proxy.apply(null,F)):t.proxy(P[x],P);throw new TypeError("expected function")}},t.fn.bind=function(P,x,F){return this.on(P,x,F)},t.fn.unbind=function(P,x){return this.off(P,x)},t.fn.one=function(P,x,F,v){return this.on(P,x,F,v,1)};var S=function(){return!0},p=function(){return!1},A=/^([A-Z]|returnValue$|layer[XY]$|webkitMovement[XY]$)/,I={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};function L(P,x){return(x||!P.isDefaultPrevented)&&(x||(x=P),t.each(I,function(F,v){var E=x[F];P[F]=function(){return this[v]=S,E&&E.apply(x,arguments)},P[v]=p}),P.timeStamp||(P.timeStamp=Date.now()),(x.defaultPrevented!==n?x.defaultPrevented:"returnValue"in x?x.returnValue===!1:x.getPreventDefault&&x.getPreventDefault())&&(P.isDefaultPrevented=S)),P}function V(P){var x,F={originalEvent:P};for(x in P)!A.test(x)&&P[x]!==n&&(F[x]=P[x]);return L(F,P)}t.fn.delegate=function(P,x,F){return this.on(x,P,F)},t.fn.undelegate=function(P,x,F){return this.off(x,P,F)},t.fn.live=function(P,x){return t(document.body).delegate(this.selector,P,x),this},t.fn.die=function(P,x){return t(document.body).undelegate(this.selector,P,x),this},t.fn.on=function(P,x,F,v,E){var B,H,z=this;return P&&!s(P)?(t.each(P,function(D,U){z.on(D,x,F,U,E)}),z):(!s(x)&&!o(v)&&v!==!1&&(v=F,F=x,x=n),(v===n||F===!1)&&(v=F,F=n),v===!1&&(v=p),z.each(function(D,U){E&&(B=function(j){return C(U,j.type,v),v.apply(this,arguments)}),x&&(H=function(j){var K,$=t(j.target).closest(x,U).get(0);if($&&$!==U)return K=t.extend(V(j),{currentTarget:$,liveFired:U}),(B||v).apply($,[K].concat(r.call(arguments,1)))}),_(U,P,v,F,x,H||B)}))},t.fn.off=function(P,x,F){var v=this;return P&&!s(P)?(t.each(P,function(E,B){v.off(E,x,B)}),v):(!s(x)&&!o(F)&&F!==!1&&(F=x,x=n),F===!1&&(F=p),v.each(function(){C(this,P,F,x)}))},t.fn.trigger=function(P,x){return P=s(P)||t.isPlainObject(P)?t.Event(P):L(P),P._args=x,this.each(function(){P.type in d&&typeof this[P.type]=="function"?this[P.type]():"dispatchEvent"in this?this.dispatchEvent(P):t(this).triggerHandler(P,x)})},t.fn.triggerHandler=function(P,x){var F,v;return this.each(function(E,B){F=V(s(P)?t.Event(P):P),F._args=x,F.target=B,t.each(m(B,P.type||P),function(H,z){if(v=z.proxy(F),F.isImmediatePropagationStopped())return!1})}),v},"focusin focusout focus blur load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach(function(P){t.fn[P]=function(x){return 0 in arguments?this.bind(P,x):this.trigger(P)}}),t.Event=function(P,x){s(P)||(x=P,P=x.type);var F=document.createEvent(c[P]||"Events"),v=!0;if(x)for(var E in x)E=="bubbles"?v=!!x[E]:F[E]=x[E];return F.initEvent(P,v,!0),L(F)}})(a),(function(t){var e=+new Date,n=window.document,r,o,s=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,i=/^(?:text|application)\/javascript/i,c=/^(?:text|application)\/xml/i,l="application/json",d="text/html",h=/^\s*$/,f=n.createElement("a");f.href=window.location.href;function m(v,E,B){var H=t.Event(E);return t(v).trigger(H,B),!H.isDefaultPrevented()}function g(v,E,B,H){if(v.global)return m(E||n,B,H)}t.active=0;function y(v){v.global&&t.active++===0&&g(v,null,"ajaxStart")}function b(v){v.global&&!--t.active&&g(v,null,"ajaxStop")}function k(v,E){var B=E.context;if(E.beforeSend.call(B,v,E)===!1||g(E,B,"ajaxBeforeSend",[v,E])===!1)return!1;g(E,B,"ajaxSend",[v,E])}function _(v,E,B,H){var z=B.context,D="success";B.success.call(z,v,D,E),H&&H.resolveWith(z,[v,D,E]),g(B,z,"ajaxSuccess",[E,B,v]),S(D,E,B)}function C(v,E,B,H,z){var D=H.context;H.error.call(D,B,E,v),z&&z.rejectWith(D,[B,E,v]),g(H,D,"ajaxError",[B,H,v||E]),S(E,B,H)}function S(v,E,B){var H=B.context;B.complete.call(H,E,v),g(B,H,"ajaxComplete",[E,B]),b(B)}function p(v,E,B){if(B.dataFilter==A)return v;var H=B.context;return B.dataFilter.call(H,v,E)}function A(){}t.ajaxJSONP=function(v,E){if(!("type"in v))return t.ajax(v);var B=v.jsonpCallback,H=(t.isFunction(B)?B():B)||"Zepto"+e++,z=n.createElement("script"),D=window[H],U,j=function(T){t(z).triggerHandler("error",T||"abort")},K={abort:j},$;return E&&E.promise(K),t(z).on("load error",function(T,R){clearTimeout($),t(z).off().remove(),T.type=="error"||!U?C(null,R||"error",K,v,E):_(U[0],K,v,E),window[H]=D,U&&t.isFunction(D)&&D(U[0]),D=U=void 0}),k(K,v)===!1?(j("abort"),K):(window[H]=function(){U=arguments},z.src=v.url.replace(/\?(.+)=\?/,"?$1="+H),n.head.appendChild(z),v.timeout>0&&($=setTimeout(function(){j("timeout")},v.timeout)),K)},t.ajaxSettings={type:"GET",beforeSend:A,success:A,error:A,complete:A,context:null,global:!0,xhr:function(){return new window.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript, application/x-javascript",json:l,xml:"application/xml, text/xml",html:d,text:"text/plain"},crossDomain:!1,timeout:0,processData:!0,cache:!0,dataFilter:A};function I(v){return v&&(v=v.split(";",2)[0]),v&&(v==d?"html":v==l?"json":i.test(v)?"script":c.test(v)&&"xml")||"text"}function L(v,E){return E==""?v:(v+"&"+E).replace(/[&?]{1,2}/,"?")}function V(v){v.processData&&v.data&&t.type(v.data)!="string"&&(v.data=t.param(v.data,v.traditional)),v.data&&(!v.type||v.type.toUpperCase()=="GET"||v.dataType=="jsonp")&&(v.url=L(v.url,v.data),v.data=void 0)}t.ajax=function(v){var E=t.extend({},v||{}),B=t.Deferred&&t.Deferred(),H,z;for(r in t.ajaxSettings)E[r]===void 0&&(E[r]=t.ajaxSettings[r]);y(E),E.crossDomain||(H=n.createElement("a"),H.href=E.url,H.href=H.href,E.crossDomain=f.protocol+"//"+f.host!=H.protocol+"//"+H.host),E.url||(E.url=window.location.toString()),(z=E.url.indexOf("#"))>-1&&(E.url=E.url.slice(0,z)),V(E);var D=E.dataType,U=/\?.+=\?/.test(E.url);if(U&&(D="jsonp"),(E.cache===!1||(!v||v.cache!==!0)&&(D=="script"||D=="jsonp"))&&(E.url=L(E.url,"_="+Date.now())),D=="jsonp")return U||(E.url=L(E.url,E.jsonp?E.jsonp+"=?":E.jsonp===!1?"":"callback=?")),t.ajaxJSONP(E,B);var j=E.accepts[D],K={},$=function(Z,Q){K[Z.toLowerCase()]=[Z,Q]},T=/^([\w-]+:)\/\//.test(E.url)?RegExp.$1:window.location.protocol,R=E.xhr(),J=R.setRequestHeader,G;if(B&&B.promise(R),E.crossDomain||$("X-Requested-With","XMLHttpRequest"),$("Accept",j||"*/*"),(j=E.mimeType||j)&&(j.indexOf(",")>-1&&(j=j.split(",",2)[0]),R.overrideMimeType&&R.overrideMimeType(j)),(E.contentType||E.contentType!==!1&&E.data&&E.type.toUpperCase()!="GET")&&$("Content-Type",E.contentType||"application/x-www-form-urlencoded"),E.headers)for(o in E.headers)$(o,E.headers[o]);if(R.setRequestHeader=$,R.onreadystatechange=function(){if(R.readyState==4){R.onreadystatechange=A,clearTimeout(G);var Z,Q=!1;if(R.status>=200&&R.status<300||R.status==304||R.status==0&&T=="file:"){if(D=D||I(E.mimeType||R.getResponseHeader("content-type")),R.responseType=="arraybuffer"||R.responseType=="blob")Z=R.response;else{Z=R.responseText;try{Z=p(Z,D,E),D=="script"?(0,eval)(Z):D=="xml"?Z=R.responseXML:D=="json"&&(Z=h.test(Z)?null:t.parseJSON(Z))}catch(it){Q=it}if(Q)return C(Q,"parsererror",R,E,B)}_(Z,R,E,B)}else C(R.statusText||null,R.status?"error":"abort",R,E,B)}},k(R,E)===!1)return R.abort(),C(null,"abort",R,E,B),R;var q="async"in E?E.async:!0;if(R.open(E.type,E.url,q,E.username,E.password),E.xhrFields)for(o in E.xhrFields)R[o]=E.xhrFields[o];for(o in K)J.apply(R,K[o]);return E.timeout>0&&(G=setTimeout(function(){R.onreadystatechange=A,R.abort(),C(null,"timeout",R,E,B)},E.timeout)),R.send(E.data?E.data:null),R};function P(v,E,B,H){return t.isFunction(E)&&(H=B,B=E,E=void 0),t.isFunction(B)||(H=B,B=void 0),{url:v,data:E,success:B,dataType:H}}t.get=function(){return t.ajax(P.apply(null,arguments))},t.post=function(){var v=P.apply(null,arguments);return v.type="POST",t.ajax(v)},t.getJSON=function(){var v=P.apply(null,arguments);return v.dataType="json",t.ajax(v)},t.fn.load=function(v,E,B){if(!this.length)return this;var H=this,z=v.split(/\s/),D,U=P(v,E,B),j=U.success;return z.length>1&&(U.url=z[0],D=z[1]),U.success=function(K){H.html(D?t("<div>").html(K.replace(s,"")).find(D):K),j&&j.apply(H,arguments)},t.ajax(U),this};var x=encodeURIComponent;function F(v,E,B,H){var z,D=t.isArray(E),U=t.isPlainObject(E);t.each(E,function(j,K){z=t.type(K),H&&(j=B?H:H+"["+(U||z=="object"||z=="array"?j:"")+"]"),!H&&D?v.add(K.name,K.value):z=="array"||!B&&z=="object"?F(v,K,B,j):v.add(j,K)})}t.param=function(v,E){var B=[];return B.add=function(H,z){t.isFunction(z)&&(z=z()),z==null&&(z=""),this.push(x(H)+"="+x(z))},F(B,v,E),B.join("&").replace(/%20/g,"+")}})(a),(function(t){t.fn.serializeArray=function(){var e,n,r=[],o=function(s){if(s.forEach)return s.forEach(o);r.push({name:e,value:s})};return this[0]&&t.each(this[0].elements,function(s,i){n=i.type,e=i.name,e&&i.nodeName.toLowerCase()!="fieldset"&&!i.disabled&&n!="submit"&&n!="reset"&&n!="button"&&n!="file"&&(n!="radio"&&n!="checkbox"||i.checked)&&o(t(i).val())}),r},t.fn.serialize=function(){var e=[];return this.serializeArray().forEach(function(n){e.push(encodeURIComponent(n.name)+"="+encodeURIComponent(n.value))}),e.join("&")},t.fn.submit=function(e){if(0 in arguments)this.bind("submit",e);else if(this.length){var n=t.Event("submit");this.eq(0).trigger(n),n.isDefaultPrevented()||this.get(0).submit()}return this}})(a),(function(){try{getComputedStyle(void 0)}catch{var t=getComputedStyle;window.getComputedStyle=function(n,r){try{return t(n,r)}catch{return null}}}})(),a})});var er=Ue(()=>{var tr=document.createElement("style");tr.textContent=`/* Score and editor styles for the browser embed. */
|
|
2
|
+
div.vextab-auto {
|
|
3
|
+
font-family: Academico, Georgia, serif;
|
|
4
|
+
font-size: 18px;
|
|
5
|
+
color: #554;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
div.vextab-auto .editor {
|
|
9
|
+
background: #dfd;
|
|
10
|
+
border: 0 solid #afa;
|
|
11
|
+
border-left: 6px solid #afa;
|
|
12
|
+
font-family: Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace;
|
|
13
|
+
font-size: 14px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
div.vextab-auto .editor-error, .vex-tabdiv .editor-error {
|
|
17
|
+
font: 14px/1.4 monospace;
|
|
18
|
+
color: #9b241e;
|
|
19
|
+
white-space: pre-wrap;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
div.vextab-auto .title {
|
|
23
|
+
font-family: Academico, Georgia, serif;
|
|
24
|
+
font-size: 18px;
|
|
25
|
+
padding: 10px;
|
|
26
|
+
color: #554;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.vex-canvas[data-preview-stale="true"] {
|
|
30
|
+
opacity: 0.65;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* An indivisible bar can scroll inside a narrow flow embed. */
|
|
34
|
+
.vextab-flow > .vex-canvas { max-width: 100%; overflow-x: auto; }
|
|
35
|
+
.vextab-flow textarea.editor { max-width: 100%; box-sizing: border-box; }
|
|
36
|
+
|
|
37
|
+
/* The sheet takes its size from the score. Only the controls intercept pointer events. */
|
|
38
|
+
.vextab-sheet {
|
|
39
|
+
position: relative;
|
|
40
|
+
width: fit-content;
|
|
41
|
+
max-width: 100%;
|
|
42
|
+
isolation: isolate;
|
|
43
|
+
display: grid;
|
|
44
|
+
}
|
|
45
|
+
.vextab-sheet > :is(svg, canvas, .vextab-playback-page, .vextab-transport) { grid-area: 1 / 1; }
|
|
46
|
+
.vextab-sheet > :is(svg, canvas) { display: block; }
|
|
47
|
+
.vextab-transport { position: relative; min-width: 0; pointer-events: none; container-type: inline-size; }
|
|
48
|
+
.vextab-canvas-ink, .vextab-sheet-controls {
|
|
49
|
+
position: absolute;
|
|
50
|
+
inset: 0;
|
|
51
|
+
pointer-events: none;
|
|
52
|
+
}
|
|
53
|
+
.vextab-transport > .vextab-canvas-ink { width: 100%; height: 100%; }
|
|
54
|
+
.vextab-sheet-controls {
|
|
55
|
+
--control-events: none;
|
|
56
|
+
--ink: #244f43;
|
|
57
|
+
--edge: #aaa697;
|
|
58
|
+
--control-size: 32px;
|
|
59
|
+
--panel-height: var(--control-size);
|
|
60
|
+
--control-gap: 6px;
|
|
61
|
+
--control-paper: #faf9f5;
|
|
62
|
+
--control-hover: #f0ede3;
|
|
63
|
+
--shadow: 0 1px 2px rgb(57 49 31 / 10%), 0 2px 6px rgb(57 49 31 / 9%);
|
|
64
|
+
display: flex;
|
|
65
|
+
justify-content: center;
|
|
66
|
+
align-items: end;
|
|
67
|
+
box-sizing: border-box;
|
|
68
|
+
clip-path: inset(0);
|
|
69
|
+
padding: var(--control-inset);
|
|
70
|
+
opacity: 0;
|
|
71
|
+
transition: opacity 220ms ease;
|
|
72
|
+
font: 500 13px/1.2 system-ui, sans-serif;
|
|
73
|
+
}
|
|
74
|
+
.vextab-sheet-controls[data-position^="top"] { align-items: start; }
|
|
75
|
+
.vextab-sheet-controls[data-position$="-left"] { justify-content: start; }
|
|
76
|
+
.vextab-sheet-controls[data-position$="-right"] { justify-content: end; }
|
|
77
|
+
.vextab-sheet-controls[data-visibility="always"],
|
|
78
|
+
.vextab-sheet-controls[data-visible],
|
|
79
|
+
.vextab-sheet-controls:has(:focus-visible),
|
|
80
|
+
.vextab-sheet-controls:has([aria-expanded="true"]),
|
|
81
|
+
.vextab-sheet-controls:has([role=status]:not(:empty)) { opacity: 1; --control-events: auto; }
|
|
82
|
+
.vextab-sheet-controls { container-type: size; }
|
|
83
|
+
/* The two mini buttons stay in place when the tempo stepper opens. */
|
|
84
|
+
.vextab-control-panel {
|
|
85
|
+
display: grid;
|
|
86
|
+
grid-template-columns: repeat(2, var(--control-size));
|
|
87
|
+
align-items: center;
|
|
88
|
+
gap: var(--control-gap);
|
|
89
|
+
flex: none;
|
|
90
|
+
}
|
|
91
|
+
.vextab-sheet-controls button {
|
|
92
|
+
display: inline-grid;
|
|
93
|
+
place-items: center;
|
|
94
|
+
box-sizing: border-box;
|
|
95
|
+
height: var(--control-size);
|
|
96
|
+
width: var(--control-size);
|
|
97
|
+
margin: 0;
|
|
98
|
+
padding: 0;
|
|
99
|
+
border: 1px solid var(--edge);
|
|
100
|
+
border-radius: 50%;
|
|
101
|
+
color: var(--ink);
|
|
102
|
+
background: var(--control-paper);
|
|
103
|
+
font: inherit;
|
|
104
|
+
cursor: pointer;
|
|
105
|
+
touch-action: manipulation;
|
|
106
|
+
pointer-events: var(--control-events);
|
|
107
|
+
}
|
|
108
|
+
.vextab-sheet-controls button:focus-visible { outline: 2px solid #126854; outline-offset: 2px; }
|
|
109
|
+
.vextab-sheet-controls :is(.vextab-play, .vextab-stop) {
|
|
110
|
+
box-shadow: var(--shadow);
|
|
111
|
+
}
|
|
112
|
+
.vextab-sheet-controls :is(.vextab-play, .vextab-stop):hover { background: var(--control-hover); }
|
|
113
|
+
.vextab-sheet-controls .vextab-play::before {
|
|
114
|
+
content: '';
|
|
115
|
+
border: solid transparent;
|
|
116
|
+
border-width: 7px 0 7px 11px;
|
|
117
|
+
border-left-color: currentColor;
|
|
118
|
+
margin-left: 2px;
|
|
119
|
+
}
|
|
120
|
+
.vextab-sheet-controls .vextab-stop::before {
|
|
121
|
+
content: '';
|
|
122
|
+
width: 10px;
|
|
123
|
+
height: 10px;
|
|
124
|
+
border-radius: 2px;
|
|
125
|
+
background: currentColor;
|
|
126
|
+
}
|
|
127
|
+
.vextab-tempo {
|
|
128
|
+
pointer-events: var(--control-events);
|
|
129
|
+
display: flex;
|
|
130
|
+
justify-self: start;
|
|
131
|
+
width: max-content;
|
|
132
|
+
align-items: center;
|
|
133
|
+
border-radius: 18px;
|
|
134
|
+
background: var(--control-paper);
|
|
135
|
+
box-shadow: inset 0 0 0 1px var(--edge), var(--shadow);
|
|
136
|
+
}
|
|
137
|
+
.vextab-sheet-controls .vextab-metronome,
|
|
138
|
+
.vextab-sheet-controls .vextab-step { border: none; background: transparent; }
|
|
139
|
+
.vextab-sheet-controls .vextab-auto-scroll { display: none; }
|
|
140
|
+
.vextab-metronome::before {
|
|
141
|
+
content: '';
|
|
142
|
+
width: 21px;
|
|
143
|
+
height: 21px;
|
|
144
|
+
background: currentColor;
|
|
145
|
+
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 20 9.4 3h4L18 20ZM7 16.8h9M11.5 14.6l7-9'/%3E%3Cpath d='m15.9 7.3 2.1 1.6 2-2.7-2.1-1.6z' fill='black'/%3E%3C/svg%3E") center / contain no-repeat;
|
|
146
|
+
}
|
|
147
|
+
.vextab-tempo-stepper[inert] { display: none; }
|
|
148
|
+
.vextab-tempo-stepper:not([inert]) {
|
|
149
|
+
display: flex;
|
|
150
|
+
align-items: center;
|
|
151
|
+
margin-right: 3px;
|
|
152
|
+
}
|
|
153
|
+
.vextab-sheet-controls .vextab-step { height: 26px; width: 26px; font-size: 18px; }
|
|
154
|
+
.vextab-sheet-controls .vextab-metronome:hover { background: var(--control-hover); }
|
|
155
|
+
/* Paint a 20px highlight inside the full 26px button target. */
|
|
156
|
+
.vextab-sheet-controls .vextab-step:enabled:hover {
|
|
157
|
+
background: radial-gradient(circle, var(--control-hover) 9.5px, transparent 10.5px);
|
|
158
|
+
}
|
|
159
|
+
.vextab-bpm { color: var(--ink); font-size: 11px; font-weight: 400; font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
160
|
+
.vextab-sheet-controls [role=status] { position: absolute; }
|
|
161
|
+
.vextab-sheet-controls [role=status]:not(:empty) {
|
|
162
|
+
bottom: calc(var(--control-y-inset, var(--control-inset)) + var(--panel-height) + 5px);
|
|
163
|
+
left: 50%;
|
|
164
|
+
transform: translateX(-50%);
|
|
165
|
+
width: max-content;
|
|
166
|
+
box-sizing: border-box;
|
|
167
|
+
max-width: calc(100% - 16px);
|
|
168
|
+
padding: 4px 8px;
|
|
169
|
+
border-radius: 4px;
|
|
170
|
+
background: white;
|
|
171
|
+
color: var(--ink);
|
|
172
|
+
box-shadow: var(--shadow);
|
|
173
|
+
}
|
|
174
|
+
/* On narrow sheets and at the right edge, open toward the sheet instead of past its margin. */
|
|
175
|
+
.vextab-sheet-controls[data-position$="-right"] .vextab-tempo,
|
|
176
|
+
.vextab-sheet-controls[data-position$="-left"] .vextab-tempo { position: relative; }
|
|
177
|
+
.vextab-sheet-controls[data-position$="-right"] .vextab-tempo-stepper:not([inert]) {
|
|
178
|
+
position: absolute; bottom: 100%; right: 0;
|
|
179
|
+
}
|
|
180
|
+
@container (max-width: 340px) {
|
|
181
|
+
.vextab-tempo { position: relative; }
|
|
182
|
+
.vextab-tempo-stepper:not([inert]) {
|
|
183
|
+
position: absolute;
|
|
184
|
+
bottom: 100%;
|
|
185
|
+
right: 0;
|
|
186
|
+
}
|
|
187
|
+
.vextab-sheet-controls[data-position$="-left"] .vextab-tempo-stepper { left: calc(0px - var(--control-size) - var(--control-gap)); right: auto; }
|
|
188
|
+
}
|
|
189
|
+
.vextab-tempo-stepper:not([inert]) { background: var(--control-paper); border-radius: 16px; }
|
|
190
|
+
.vextab-sheet-controls[data-position^="top"] .vextab-tempo-stepper:not([inert]) { top: 100%; bottom: auto; }
|
|
191
|
+
/* A single translucent surface holds the primary action and current tempo on larger scores. */
|
|
192
|
+
.vextab-sheet-controls[data-size="large"] {
|
|
193
|
+
--control-size: 44px;
|
|
194
|
+
--control-gap: 4px;
|
|
195
|
+
--panel-height: calc(var(--control-size) + 10px);
|
|
196
|
+
--panel-fill: rgb(36 79 67 / 92%);
|
|
197
|
+
}
|
|
198
|
+
.vextab-sheet-controls[data-size="large"] .vextab-control-panel {
|
|
199
|
+
grid-template-columns: var(--control-size) auto var(--control-size);
|
|
200
|
+
padding: 4px 8px;
|
|
201
|
+
border: 1px solid rgb(21 54 45 / 65%);
|
|
202
|
+
border-radius: 9px;
|
|
203
|
+
background: var(--panel-fill);
|
|
204
|
+
box-shadow: 0 2px 7px rgb(18 43 35 / 19%);
|
|
205
|
+
pointer-events: var(--control-events);
|
|
206
|
+
}
|
|
207
|
+
.vextab-sheet-controls[data-size="large"] :is(.vextab-play, .vextab-stop) {
|
|
208
|
+
background: radial-gradient(circle, var(--control-paper) 16px, transparent 17px);
|
|
209
|
+
border: 0;
|
|
210
|
+
box-shadow: none;
|
|
211
|
+
}
|
|
212
|
+
.vextab-sheet-controls[data-size="large"] :is(.vextab-play, .vextab-stop):is(:hover, :focus-visible) {
|
|
213
|
+
color: #19382e;
|
|
214
|
+
background: radial-gradient(circle, #d6dfd8 16px, transparent 17px);
|
|
215
|
+
}
|
|
216
|
+
.vextab-sheet-controls[data-size="large"] .vextab-tempo {
|
|
217
|
+
position: relative;
|
|
218
|
+
border-radius: 0;
|
|
219
|
+
background: transparent;
|
|
220
|
+
box-shadow: none;
|
|
221
|
+
}
|
|
222
|
+
.vextab-sheet-controls[data-size="large"] .vextab-metronome {
|
|
223
|
+
display: flex;
|
|
224
|
+
align-items: center;
|
|
225
|
+
justify-content: center;
|
|
226
|
+
gap: 5px;
|
|
227
|
+
width: auto;
|
|
228
|
+
padding: 0 6px;
|
|
229
|
+
color: var(--control-paper);
|
|
230
|
+
border-radius: 5px;
|
|
231
|
+
}
|
|
232
|
+
.vextab-sheet-controls[data-size="large"] .vextab-metronome::after {
|
|
233
|
+
content: attr(aria-description);
|
|
234
|
+
font-variant-numeric: tabular-nums;
|
|
235
|
+
white-space: nowrap;
|
|
236
|
+
}
|
|
237
|
+
.vextab-sheet-controls[data-size="large"] .vextab-metronome:hover,
|
|
238
|
+
.vextab-sheet-controls[data-size="large"] .vextab-metronome[aria-expanded="true"] { background: rgb(255 255 255 / 12%); }
|
|
239
|
+
.vextab-sheet-controls[data-size="large"] .vextab-auto-scroll {
|
|
240
|
+
display: inline-grid;
|
|
241
|
+
color: var(--control-paper);
|
|
242
|
+
background: transparent;
|
|
243
|
+
border: 0;
|
|
244
|
+
border-radius: 6px;
|
|
245
|
+
}
|
|
246
|
+
.vextab-auto-scroll::before {
|
|
247
|
+
content: '';
|
|
248
|
+
width: 22px;
|
|
249
|
+
height: 22px;
|
|
250
|
+
background: currentColor;
|
|
251
|
+
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 3 7 4 7-4m-14 7 7 4 7-4m-14 7 7 4 7-4'/%3E%3C/svg%3E") center / contain no-repeat;
|
|
252
|
+
}
|
|
253
|
+
.vextab-auto-scroll[aria-pressed="true"]::before {
|
|
254
|
+
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='black' stroke-width='3.4' stroke-linecap='round'%3E%3Cpath d='M5 5h14M5 12h14M5 19h14'/%3E%3C/svg%3E");
|
|
255
|
+
}
|
|
256
|
+
.vextab-sheet-controls[data-size="large"] .vextab-auto-scroll:hover { background: rgb(255 255 255 / 18%); }
|
|
257
|
+
.vextab-sheet-controls[data-size="large"] button:focus-visible { outline-color: #ffdc7b; }
|
|
258
|
+
/* Slide the two adjustments into the panel above the BPM, leaving the metronome in place. */
|
|
259
|
+
.vextab-sheet-controls[data-size="large"] .vextab-metronome::after { transition: transform 150ms ease; }
|
|
260
|
+
.vextab-sheet-controls[data-size="large"] .vextab-metronome[aria-expanded="true"]::after { transform: translateY(9px); }
|
|
261
|
+
.vextab-sheet-controls[data-size="large"] .vextab-tempo .vextab-tempo-stepper {
|
|
262
|
+
position: absolute;
|
|
263
|
+
display: flex;
|
|
264
|
+
align-items: center;
|
|
265
|
+
justify-content: center;
|
|
266
|
+
top: -3px;
|
|
267
|
+
right: 3px;
|
|
268
|
+
bottom: auto;
|
|
269
|
+
left: auto;
|
|
270
|
+
width: 52px;
|
|
271
|
+
height: 24px;
|
|
272
|
+
margin: 0;
|
|
273
|
+
border-radius: 4px;
|
|
274
|
+
background: transparent;
|
|
275
|
+
transition: opacity 150ms ease, translate 150ms ease, visibility 0s;
|
|
276
|
+
}
|
|
277
|
+
.vextab-sheet-controls[data-size="large"] .vextab-tempo-stepper[inert] {
|
|
278
|
+
visibility: hidden;
|
|
279
|
+
opacity: 0;
|
|
280
|
+
translate: 0 6px;
|
|
281
|
+
transition-delay: 0s, 0s, 150ms;
|
|
282
|
+
}
|
|
283
|
+
.vextab-sheet-controls[data-size="large"] .vextab-step {
|
|
284
|
+
width: 26px;
|
|
285
|
+
height: 24px;
|
|
286
|
+
font: 500 15px/1 system-ui, sans-serif;
|
|
287
|
+
color: #d2e2d8;
|
|
288
|
+
background: transparent;
|
|
289
|
+
}
|
|
290
|
+
.vextab-sheet-controls[data-size="large"] .vextab-step:enabled:hover {
|
|
291
|
+
color: white;
|
|
292
|
+
background: radial-gradient(circle, rgb(225 242 233 / 14%) 9px, transparent 10px);
|
|
293
|
+
}
|
|
294
|
+
/* The tempo is printed on the large metronome button. Keep its live announcement when adjusting it. */
|
|
295
|
+
.vextab-sheet-controls[data-size="large"] .vextab-bpm {
|
|
296
|
+
position: absolute;
|
|
297
|
+
width: 1px;
|
|
298
|
+
height: 1px;
|
|
299
|
+
overflow: hidden;
|
|
300
|
+
clip-path: inset(50%);
|
|
301
|
+
}
|
|
302
|
+
/* In a narrow embed the tempo value moves into the stepper to make room for Auto-scroll. */
|
|
303
|
+
@container (max-width: 220px) {
|
|
304
|
+
.vextab-sheet-controls[data-size="large"] .vextab-metronome::after { display: none; }
|
|
305
|
+
.vextab-sheet-controls[data-size="large"] .vextab-tempo .vextab-tempo-stepper {
|
|
306
|
+
top: auto;
|
|
307
|
+
bottom: 100%;
|
|
308
|
+
background: var(--panel-fill);
|
|
309
|
+
width: 110px;
|
|
310
|
+
right: 50%;
|
|
311
|
+
transform: translateX(50%);
|
|
312
|
+
}
|
|
313
|
+
.vextab-sheet-controls[data-size="large"][data-position^="top"] .vextab-tempo .vextab-tempo-stepper { top: 100%; bottom: auto; }
|
|
314
|
+
.vextab-sheet-controls[data-size="large"] .vextab-bpm {
|
|
315
|
+
position: static;
|
|
316
|
+
width: auto;
|
|
317
|
+
height: auto;
|
|
318
|
+
clip-path: none;
|
|
319
|
+
color: var(--control-paper);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
.vextab-sheet-controls[data-position^="top"] [role=status]:not(:empty) { bottom: auto; }
|
|
323
|
+
.vextab-sheet-controls[data-position^="top"] [role=status]:not(:empty) { top: calc(var(--control-y-inset, var(--control-inset)) + var(--panel-height) + 5px); }
|
|
324
|
+
@media (prefers-reduced-motion: reduce) {
|
|
325
|
+
.vextab-sheet-controls,
|
|
326
|
+
.vextab-sheet-controls[data-size="large"] .vextab-metronome::after,
|
|
327
|
+
.vextab-sheet-controls[data-size="large"] .vextab-tempo .vextab-tempo-stepper { transition: none; }
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/* Tint sounding notes and custom position markers. */
|
|
331
|
+
.vextab-playback-ink {
|
|
332
|
+
color: var(--vextab-playback-tint, #fff600);
|
|
333
|
+
}
|
|
334
|
+
.vextab-playback-marker {
|
|
335
|
+
color: var(--vextab-playback-tint, #6baed6);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/* Stack preview ink in the same grid cell as the page, at its intrinsic or responsive size. */
|
|
339
|
+
.vextab-playback-page { display: grid; grid-template-columns: minmax(0, 1fr); }
|
|
340
|
+
.vextab-playback-page > svg { grid-area: 1 / 1; }
|
|
341
|
+
|
|
342
|
+
/* Host-mounted controls stay above the music, including in legacy documentation. */
|
|
343
|
+
.vextab-playback-controls { display: inline-flex; align-items: center; gap: .65em; }
|
|
344
|
+
.vextab-playback-controls button { cursor: pointer; font: inherit; }
|
|
345
|
+
.vextab-playback-controls button::before { content: '\u25B6'; margin-right: .45em; font-size: .8em; }
|
|
346
|
+
.vextab-playback-controls .vextab-stop::before { content: '\u25A0'; }
|
|
347
|
+
@media print {
|
|
348
|
+
.vextab-playback-controls, .vextab-transport, .vextab-playback-ink, .vextab-playback-paper { display: none !important; }
|
|
349
|
+
}
|
|
350
|
+
`;document.head.append(tr)});import vt from"vexflow";vt.Flow||(vt.Flow=vt);!vt.RERR&&vt.RuntimeError&&(vt.RERR=vt.RuntimeError);vt.BM||(vt.BM=(a,t)=>t());var N=vt;import Pt from"vexflow";var Pe="Academico",gt=()=>Pt.getTextFonts()[0],At=()=>Pt.getFonts()[0],Ot=()=>gt()==="Petaluma Script"?"normal":"bold";function Nt(a,t){if(!a)return t();let e=Pt.getFonts(),n=Pt.getTextFonts();try{return a==="Petaluma"?Pt.setFonts("Petaluma","Petaluma Script"):Pt.setFonts("Bravura",Pe),t()}finally{Pt.setFonts(...e),Pt.setTextFonts(...n)}}import{Annotation as cn,Beam as ln,Formatter as rr,Fraction as un,TextNote as or,Voice as oe}from"vexflow";var se=class{constructor(t){this.artist=t}prepareStave(t,e){if(!t)return[];let n=N.Flow.Barline.type,r=n.SINGLE,o=e.map(s=>{let i=X(s);return i instanceof N.Flow.BarNote&&i.getType()!==n.REPEAT_BEGIN?(r=i.getType(),s.slice(0,-1)):s});return t.setEndBarType(r),o}makeBeams(t,e,n,r,o){let s=e.options;if(o&&s["tab-stems"]!=="true")return[];let i;e.direction==="top"?i=1:e.direction==="bottom"?i=-1:n.voiceSettings.length>1?i=r===0?1:-1:o&&(i=s["tab-stem-direction"]==="down"?-1:1);for(let c of t)i&&c.setStemDirection&&c.setStemDirection(i);return s.beams==="off"?[]:s.beams==="explicit"?e.groups.map(([c,l])=>{let d=new ln(t.slice(c,l),i===void 0);return d.renderOptions.showStemlets=s["beam-stemlets"]==="true",d}):ln.generateBeams(t,{groups:n.beam_groups,stemDirection:i,beamRests:s["beam-rests"]==="true",showStemlets:s["beam-stemlets"]==="true",beamMiddleOnly:s["beam-middle-only"]==="true"})}alignTopAnnotations(t,e){let n=[];for(let o of t.getTickables())o.getModifiers().filter(i=>i instanceof cn&&i.getVerticalJustification()===cn.VerticalJustify.TOP).forEach((i,c)=>{i.setLayoutBaseline(void 0),(n[c]??=[]).push(i)});let r=e.getYForLine(-1);for(let o of n){for(let s of o)r=Math.min(r,s.computeY().y);for(let s of o)s.setLayoutBaseline(r);r-=Math.max(...o.map(s=>s.computeY().textHeight))}}alignTextBars(t,e){let n=[],r=new un(0,1);for(let i of e)i.shouldIgnoreTicks()?n.push(r.clone()):r.add(i.getTicks());if(!n.length)return t;let o=[];r=new un(0,1);let s=0;for(let i of t){for(;s<n.length&&!n[s].greaterThan(r)&&!(n[s++].equals(r)&&i.shouldIgnoreTicks());)o.push(new or({text:"",duration:"b",ignoreTicks:!0}));o.push(i),i.shouldIgnoreTicks()||r.add(i.getTicks())}return o}formatAndRender(t,e,n,r){let o=[],s=(k,_,C)=>k.flatMap((S,p)=>{if(!S.length)return[];S.forEach(I=>I.setStave(_));let A=new oe(e.meter).setMode(oe.Mode.SOFT).addTickables(S);return o.push(...this.makeBeams(S,e.voiceSettings[p],e,p,C)),[A]}),i=e.tab,c=e.note,l=s(n,i,!0),d=s(r,c,!1),h=c||i,f=h,g=e.text_voices.filter(k=>k.length).map(k=>{let _=this.alignTextBars(k,r[0]??n[0]??[]);return _.forEach(C=>C.setStave(f)),new oe(e.meter).setMode(oe.Mode.SOFT).addTickables(_)}),y=new rr,b=[...l,...d,...g];for(let k of[l,d,g])k.length&&y.joinVoices(k);b.length&&y.formatToStave(b,h,{alignRests:d.length>1});for(let k of l)this.alignTopAnnotations(k,i),k.draw(t,i);for(let k of d)k.draw(t,c);for(let k of o)k.setContext(t).draw();for(let k of g)k.draw(t,f);return i&&c&&new N.Flow.StaveConnector(c,i).setType(N.Flow.StaveConnector.type.BRACKET).setContext(t).draw(),c?d:l}render(t){let e=this.artist;e.log("Render: ",e.options),e.closeBends(),t.resize(Number(e.customizations.width)*Number(e.customizations.scale),(e.last_y+e.options.bottom_spacing)*Number(e.customizations.scale));let n=t.getContext();n.setViewBox?n.setViewBox(0,0,Number(e.customizations.width),e.last_y+e.options.bottom_spacing):n.scale(Number(e.customizations.scale),Number(e.customizations.scale)),n.clear(),n.setFont(e.options.font_face,e.options.font_size,""),e.renderer_context=n,e.player_voices=[];let r=o=>{o.note&&e.notes.applyAccidentals(o);let s=this.prepareStave(o.tab,o.tab_voices),i=this.prepareStave(o.note,o.note_voices);if(o.tab&&o.note){let l=Math.max(o.tab.getNoteStartX(),o.note.getNoteStartX());o.tab.setNoteStartX(l),o.note.setNoteStartX(l)}o.tab&&o.tab.setContext(n).draw(),o.note&&o.note.setContext(n).draw();let c=this.formatAndRender(n,o,s,i);e.player_voices.push(c)};for(let o of e.staves){if(!o.color){r(o);continue}let s=n.getDefaultStyle();n.save();try{n.setDefaultStyle(et(o.color)).setStrokeStyle(o.color).setFillStyle(o.color),r(o)}finally{n.setDefaultStyle(s),n.restore()}}e.log("Rendering tab articulations."),e.tab_articulations.forEach(o=>o.setContext(n).drawWithStyle()),e.log("Rendering note articulations."),e.stave_articulations.forEach(o=>o.setContext(n).drawWithStyle()),e.player&&(e.customizations.player==="true"?(e.player.setTempo(parseInt(String(e.customizations.tempo),10)),e.player.setInstrument(String(e.customizations.instrument)),e.player.render()):e.player.removeControls()),e.rendered=!0}};import{Annotation as Me,Articulation as sr,FretHandFinger as ir,Modifier as Ht,StringNumber as ar}from"vexflow";var cr={left:Ht.Position.LEFT,right:Ht.Position.RIGHT,above:Ht.Position.ABOVE,below:Ht.Position.BELOW};function Te(a,t,e=!1,n=!1){let r=!n&&(t===Ht.Position.LEFT||t===Ht.Position.RIGHT),o=e?new ar(a):new ir(a,{headPlacement:r}).setDrawCircle(n&&/^\d$/.test(a));return o.setPosition(t),o}function Vt(a,t,e,n,r=!1,o=!1){for(let s of e){let i=cr[s.position];if(s.finger!==void 0){if(n&&!r)continue;if((o||/^[pimac]$/.test(s.finger))&&(s.position==="above"||s.position==="below")){let c=s.position==="above"?Me.VerticalJustify.TOP:Me.VerticalJustify.BOTTOM;a.addModifier(new Me(s.finger).setFont(gt(),11).setVerticalJustification(c),t);continue}a.addModifier(Te(s.finger,i,s.stringNumber,n),t)}else a.addModifier(new sr(s.articulation??"a>").setPosition(i),t)}}function _e(a,t){return a?.find(e=>!e.finger||!/^\d$/.test(e.finger)||e.stringNumber?!1:e.position==="left"||e.position==="right"?!0:t.some(n=>n.marks?.some(r=>r!==e&&r.position===e.position&&/^\d$/.test(r.finger??"")&&!r.stringNumber)))}function Ae(a,t){let e=a.measures.map(l=>l.number);if(!t)return e;let n=[...a.repeats??[]];for(let l of n){if(l.count!==void 0&&(!Number.isInteger(l.count)||l.count<2||l.count>32||l.endings.length))throw new tt("measure","Invalid counted repeat",a.measures[0].range);let d=l.bodyEnd;if(!Number.isInteger(l.first)||!Number.isInteger(d)||l.first<1||d<l.first||d>e.length)throw new tt("measure","Invalid repeat body",a.measures[0].range);for(let h of l.endings){if(h.first!==d+1||!Number.isInteger(h.last)||h.last<h.first||h.last>e.length)throw new tt("measure","Invalid repeat ending",a.measures[l.first-1].range);d=h.last}}let r=[],o=new Set(n.flatMap(l=>l.count?[l.bodyEnd]:l.endings.slice(0,-1).map(d=>d.last)));for(let l of a.measures){let d=l.voices[0];if(["repeat-begin","repeat-both"].includes(d.opening?.type)&&!n.some(h=>h.first===l.number)&&r.push(l.number),["repeat-end","repeat-both"].includes(d.closing?.type)&&!o.has(l.number)){let h=r.pop()??1;n.push({first:h,bodyEnd:l.number,endings:[],range:[l.range.start,l.range.end]})}}let s=l=>l.endings[l.endings.length-1]?.last??l.bodyEnd;n.sort((l,d)=>l.first-d.first||s(d)-s(l));let i=[];function c(l,d,h){for(let f=l;f<=d;f++){let m=h.find(y=>y.first===f&&s(y)<=d);if(!m){if(i.length>=16384)throw new tt("measure","Performed repeat exceeds 16384 bar visits",a.measures[f-1].range);i.push(f);continue}let g=h.filter(y=>y!==m);for(let y=0;y<(m.count??Math.max(2,m.endings.length));y++){c(f,m.bodyEnd,g);let b=m.endings[y];b&&c(b.first,b.last,g)}f=s(m)}}return c(1,e.length,n),i}function dn(a,t){let e=new Map,n=new Map;for(let r of a){let o=Ae(r,t);if(e.set(r,o),o.length===r.measures.length)continue;let s=r.measures.map(c=>c.span).join(","),i=n.get(s);if(i&&(i.length!==o.length||i.some((c,l)=>c!==o[l])))throw new tt("measure","Parts disagree about the performed repeat order",r.measures[0].range);n.set(s,o)}if(n.size)for(let r of a){let o=n.get(r.measures.map(s=>s.span).join(","));o&&e.set(r,o)}return e}function fn(a,t,e,n){let r="cdefgab",[o,s]=a.split("/"),i=r.indexOf(o[0])+e,c=n.getAccidental(r[(i+7)%7]).note,l=bt(c+"/"+(Number(s)+Math.floor(i/7)));return l===void 0?t:Math.max(0,Math.min(127,l+t-bt(a)))}function pn(a,t,e,n=.25){if(!a.notes.length)return[a];let r=a.notes[0],o=t.heads.find(d=>d.sounding&&bt(d.sounding)===r.pitch);if(!o)return[a];let s=[],i=a.time,c=a.duration;function l(d,h,f){let m=f/d.length;d.forEach((g,y)=>s.push({...a,time:h+y*m,duration:m,notes:(Array.isArray(g)?g:[g]).map(b=>({pitch:b,duration:m,velocity:r.velocity,...r.fixedVelocity&&{fixedVelocity:!0},program:r.program}))}))}if(t.grace){let d=r.pitch-bt(o.written),h=t.grace.pitches.map(f=>(Array.isArray(f)?f:[f]).map(m=>bt(m)+d).filter(m=>m>=0&&m<=127)).filter(f=>f.length);if(h.length){let f=t.grace.side==="before",g=(f&&!t.grace.steal?Math.min(c,...a.notes.map(b=>b.duration)):c)*n,y=f?i:i+c-g;l(h,y,g),c-=g,f&&(i+=g);for(let b of a.notes)f?b.duration=Math.max(0,b.duration-g):b.duration-=Math.min(g,Math.max(0,b.duration-(y-a.time)))}}if(t.ornament){let d=fn(o.written,r.pitch,1,e),h=fn(o.written,r.pitch,-1,e),f=r.pitch,g={tr:[f,d,f,d],mordent:[f,d],mordent_inverted:[f,h],turn:[d,f,h],turn_inverted:[h,f,d]}[t.ornament],y=Math.min(c,r.duration)/2;l(g,i,y),a.notes.length>1&&s.push({...a,time:i,duration:c,notes:a.notes.slice(1)}),r.duration=Math.max(0,r.duration-y),s.push({...a,time:i+y,duration:c-y,notes:[r]})}else s.push({...a,time:i,duration:c});return s}import lr,{KeyManager as ur}from"vexflow/core";function hn(a,t,e){let n=bt(a);if(n===void 0)return;let r={pitch:n,duration:t,velocity:100};return e&&(r.bend=[{time:t,semitones:-e}]),r}function ot(a,t){let[e,n]=a.split("/").map(Number);return e/n*t}function dr(a,t,e){if(t.midi!==void 0&&!a.silent)return{pitch:t.midi,duration:e,velocity:100};if(!t.sounding||a.silent)return;let n=hn(t.sounding,e,t.prebend?.release&&t.prebend.semitones),r=t.bend??a.bend?.spec;if(!n||!r||r.string!==t.position?.str)return n;let o=i=>e*i[0]/i[1],s=[{time:o(r.rise),semitones:r.semitones}];return r.hold&&s.push({time:o(r.hold),semitones:r.semitones}),r.release&&s.push({time:o(r.release),semitones:0}),n.bend=s,n}var Ne=class{constructor(){this.from=100;this.target=100;this.start=0;this.hasSounded=!1}at(t){let e=(t-this.start)*4,n=Math.max(0,1-e);return this.target+(this.from-this.target)*n*n}attack(t,e,n,r){if(e!==void 0&&(e!==this.target||!r)){let o=this.at(t);this.from=this.hasSounded&&r?(o+e)/2:e,this.target=e,this.start=t}return n&&(this.hasSounded=!0),Math.round(this.at(t))}};function fr(a,t,e){let n=[],r=new Map;for(let g of a.playback?.tempoChanges??[]){let y=r.get(g.bar)??[];y.push({at:ot(g.at,1),bpm:g.bpm*t/(a.playback.tempo??120)}),r.set(g.bar,y)}let o=new Map,s=new Map,i=[],c={ppp:28,pp:40,p:52,mp:66,mf:82,f:98,ff:112,fff:124},l=new Set(e&&a.measures[0]?.state.piano?a.measures.flatMap(g=>g.voices.filter(y=>y.hand&&y.events.some(b=>b.dynamic)).map(y=>y.hand)):[]),d=new Map,h=new Set((a.spans??[]).flatMap(g=>g.kind==="crescendo"||g.kind==="diminuendo"?[g.from,g.to]:[])),f=t,m=0;for(let g of a.measures){let y=a.playback?.tempos?.[g.number];y&&(f=y*t/(a.playback.tempo??120)),n.push(f);let b=r.get(g.number);b&&(f=b[b.length-1].bpm);let k=g.voices.flatMap((_,C)=>_.events.map(S=>({attack:S,voice:C,onset:ot(S.onset,1)}))).sort((_,C)=>_.onset-C.onset||+!!C.attack.dynamic-+!!_.attack.dynamic);for(let{attack:_,voice:C,onset:S}of k){let p=l.size===2?g.voices[C].hand??"":"";d.has(p)||d.set(p,new Ne);let A=d.get(p);o.set(_.id,A.attack(m+S,c[_.dynamic],!_.silent&&_.heads.length>0,e&&!h.has(_.id)));let I=i[C]??=[],L={id:_.id,time:m+S,voice:C,explicit:!!_.dynamic,index:I.length};s.set(_.id,L),I.push(L)}m+=ot(g.span,1)}for(let g of a.spans??[]){if(g.kind!=="crescendo"&&g.kind!=="diminuendo")continue;let y=s.get(g.from),b=s.get(g.to);if(!y||!b||b.time<=y.time)continue;let k=g.kind==="crescendo",_=k&&g.niente?1:o.get(g.from),C=!k&&g.niente?1:b.explicit?o.get(g.to):Math.min(127,Math.max(1,_+(k?24:-24)));for(let S=y.index;S<=b.index;S++){let p=i[y.voice][S];o.set(p.id,Math.round(_+(C-_)*(p.time-y.time)/(b.time-y.time)))}}return{tempi:n,tempoChanges:r,velocities:o}}function pr(a,t,e){if(!t.length)return;t.sort((o,s)=>o.start-s.start);let n=[];for(let o of t){let s=n[n.length-1];s&&o.start<s.end?s.end=Math.max(s.end,o.end):n.push(o)}let r=new Map;for(let o=a.length-1;o>=0;o--){let s=a[o];for(let i of s.notes){let c=s.time+i.duration,l=0,d=n.length;for(;l<d;){let f=l+d>>>1;n[f].end<=c?l=f+1:d=f}let h=n[l];if(e&&(h?.start<c||n[l-1]?.end===c)&&(i.holdRelease=!0),h&&h.start<c){let f=Math.min(h.end,r.get(i.pitch)??1/0);i.duration=Math.max(i.duration,f-s.time)}r.set(i.pitch,s.time)}}}function hr(a,t,e,n,r){let o=n(ot(a.span,1)),s=t/4,[i,c]=a.state.meter.split("/").map(Number),l=Math.max(0,i/c-ot(a.span,1))*4,d=Math.abs(l-Math.round(l))>1e-8?l%1*s:0,h=[];if(r!==void 0){let g=ot(a.span,1),y=0,b=(1-d/s)/4;for(;y<g-1e-12;){let k=Math.min(y+b,g);h.push({end:n(k),...k-y>=.25-1e-12&&{eighth:n(y+.125)}}),y=k,b=.25}}let f=[],m=!1;for(let g of a.voices)for(let y of g.events){let b=n(ot(y.onset,1)+ot(y.duration,1));y.heads.some(k=>k.marks?.some(_=>_.articulation?.startsWith("a@")))&&f.push(b),b>=o-1e-8&&e.has(y.id)&&(m=!0)}return{duration:o,quarter:s,beatOffset:d,...r!==void 0&&{beats:h,endingQuarter:r},swingable:c===2||c===4,fermatas:f,phraseEnd:m||!!f.length}}function mn(a){let t=a[0]??[];for(let e of a.slice(1)){let n=0,r=0,o=0;for(let s of e){let i=n,c=r,l=o+s.duration;for(;i<t.length&&c<l-1e-9;){let d=t[i],h=c+d.duration;s.swingable===!1&&(d.swingable=!1),s.phraseEnd&&Math.abs(l-h)<1e-8&&(d.phraseEnd=!0);for(let f of s.fermatas??[]){let m=o+f;m>c+1e-9&&m<=h+1e-9&&(d.fermatas=[...d.fermatas??[],m-c])}if(h>l+1e-9)break;c=h,i++}n=i,r=c,o=l}}return t}function gn(a,t,e,n=Ae(a,!1),r,o){let s=[],i=new Map(a.ties.map(v=>[v.to+":"+v.toHead,v])),c=new Map,l=!!r&&!r.literal,d=!1,{tempi:h,tempoChanges:f,velocities:m}=fr(a,t,l),g=new Set((a.spans??[]).filter(v=>v.kind==="slur").map(v=>v.to)),y=new Map((a.spans??[]).filter(v=>v.kind==="tremolo").map(v=>[v.from,v])),b=new Map((a.spans??[]).flatMap(v=>v.kind==="glissando"?[[v.to+":"+v.toHead,v]]:[])),k=new Map,_=new Map,C=(a.spans??[]).filter(v=>v.kind==="pedal"),S=new Map(C.map(v=>[v.from,v.to])),p=new Set(C.filter(v=>v.onset).map(v=>v.to)),A=new Map,I=[];function L(v){for(let E of A.values())I.push({start:E,end:v});A.clear()}let V=new Map((a.repeats??[]).flatMap(v=>v.endings.slice(1).map(E=>[E.first,v.bodyEnd]))),P=0,x=0;for(let v of n){let E=a.measures[v-1];if(v!==P+1){if(V.get(v)===P)for(let[T,R]of c)(R.barNumber!==P||Math.abs(R.writtenEnd-x)>1e-8)&&c.delete(T);else c.clear();L(x)}else if(V.has(v)){let T=V.get(v);for(let[R,J]of c)J.barNumber===T&&c.delete(R)}P=v;let B=240/h[v-1],H=0,z=0,D=B,U=[{start:H,timeAtStart:z,rate:D}];for(let T of f.get(v)??[])z+=(T.at-H)*D,H=T.at,D=240/T.bpm,U.push({start:H,timeAtStart:z,rate:D});let j=T=>{let R=0,J=U.length;for(;R+1<J;){let q=R+J>>>1;U[q].start<=T?R=q:J=q}let G=U[R];return G.timeAtStart+(T-G.start)*G.rate},K=E.voices.flatMap(T=>T.events).map(T=>({attack:T,time:x+j(ot(T.onset,1))}));K.sort((T,R)=>T.time-R.time),o&&ot(E.span,B)>0&&o.push(hr(E,B,g,j,U.length>1?D/4:void 0));let $=new Map;for(let{attack:T,time:R}of K){let J=j(ot(T.onset,1)+ot(T.duration,1))-j(ot(T.onset,1));S.has(T.id)&&A.set(S.get(T.id),R),A.has(T.id)&&(I.push({start:A.get(T.id),end:p.has(T.id)?R:R+J}),A.delete(T.id));let G=[];if(T.grace||T.ornament){let q=T.activeKey??E.state.key??"C";_.has(q)||_.set(q,new ur(q));let Z;if(T.grace?.steal){let Q=ot(T.onset,1),it=ot(T.duration,1),lt=it*ot(T.grace.steal,1),rt=T.grace.side==="before"?Q:Q+it-lt;Z=(j(rt+lt)-j(rt))/J}k.set(T.id,{attack:T,key:_.get(q),graceShare:Z})}T.heads.forEach((q,Z)=>{let Q=q.sustain?j(ot(T.onset,1)+ot(q.sustain,1))-j(ot(T.onset,1)):J,it=T.id+":"+Z,lt=i.get(it),rt=lt&&c.get(lt.from+":"+lt.fromHead);if(rt){if(l&&(rt.note.holdRelease=!0),rt.note.duration=Math.max(rt.note.duration,R+Q-rt.start),lt.bend){let{semitones:nt,hold:at,release:ht}=lt.bend;rt.note.bend=[...rt.note.bend??[],{time:R-rt.start+Q*at[0]/at[1],semitones:nt},{time:R-rt.start+Q*ht[0]/ht[1],semitones:0}]}c.set(it,{...rt,barNumber:v,writtenEnd:R+Q})}else{let nt=dr(T,q,Q);if(nt){let at=b.get(it),ht=at&&c.get(at.from+":"+at.fromHead);ht&&(ht.note.bend=[...ht.note.bend??[],{time:R-ht.start,semitones:nt.pitch-ht.note.pitch}]),nt.velocity=m.get(T.id),l&&q.marks&&(q.marks.some(ut=>ut.articulation==="a>"||!ut.articulation&&!ut.finger&&!ut.stringNumber)&&(nt.velocity=Math.min(127,nt.velocity+10)),!nt.bend&&!T.grace&&!T.ornament&&q.marks.some(ut=>ut.articulation==="a.")&&(nt.duration*=.58)),q.velocity!==void 0&&(nt.velocity=q.velocity,nt.fixedVelocity=!0,q.velocity===0&&(d=!0)),a.program!==void 0&&(nt.program=a.program),G.push(nt),c.set(it,{note:nt,start:R,barNumber:v,writtenEnd:R+Q})}}}),$.set(T.id,{time:R,duration:J,source:T.id,notes:G,mark:e&&(()=>e(T.id))})}for(let[T,R]of $){let J=y.get(T);if(J?.kind!=="tremolo"){s.push(R);continue}let G=$.get(J.to),q=R.duration+G.duration,Z=B/2**(2+J.strokes);for(let Q=0;Q*Z<q-1e-9;Q++){let it=Q%2?G:R,lt=Math.min(Z,q-Q*Z);s.push({...it,time:R.time+Q*Z,duration:lt,notes:it.notes.map(rt=>({...rt,duration:lt}))})}$.delete(J.to)}x+=j(ot(E.span,1))}let F=k.size?s.flatMap(v=>{let E=k.get(String(v.source));if(!E)return[v];let B=E.attack.grace,H=E.graceShare??(B&&r?.graceFraction(v.time,v.duration,B.pitches.length,B.slash));return pn(v,E.attack,E.key,H)}):s;if(d)for(let v of F)v.notes=v.notes.filter(E=>E.velocity!==0);return F.sort((v,E)=>v.time-E.time),L(x),pr(F,I,l),{events:F,duration:x}}function bn(a,t){let e=[],n=240/(t*lr.RESOLUTION),r=new Map,o=0;for(let s of a.getPlayerData().voices){let i=0;for(let c of s){let l=0;for(let d of c.getTickables()){if(d.shouldIgnoreTicks())continue;let h=d.getTicks().value(),f=h*n,m=[];if(!d.isRest()){let g=xt.get(d)??(d.getPlayNote?.()??[]).map(b=>({key:b})),y=new Map;g.forEach((b,k)=>{let _=hn(b.key,f,b.release);if(!_)return;let C=ie.get(d)?.get(k),S=C&&r.get(C.glyph)?.get(C.index);S&&S.pitch===_.pitch?(S.duration+=f,y.set(k,S)):(m.push(_),y.set(k,_))}),r.set(d,y)}e.push({time:(o+l)*n,duration:f,source:d,notes:m}),l+=h}i=Math.max(i,l)}o+=i}return{events:e.sort((s,i)=>s.time-i.time),duration:o*n}}var xt=new WeakMap,ie=new WeakMap;function yn(a,t){let e=ie.get(a)?.get(t);return e&&xt.get(e.glyph)?.[e.index]}function Re(a,t,e,n){if(!a||!t)return;let r=ie.get(t)??new Map;n.forEach((o,s)=>r.set(o,{glyph:a,index:e[s]})),ie.set(t,r)}var ae=class{constructor(t){this.artist=t}makeBend(t,e){let n=N.Flow.Bend.UP,r="";if(parseInt(t,10)>parseInt(e,10))n=N.Flow.Bend.DOWN;else switch(Math.abs(parseInt(e,10)-parseInt(t,10))){case 1:r="1/2";break;case 2:r="Full";break;case 3:r="1 1/2";break;default:r=`Bend to ${e}`;break}return{type:n,text:r}}openBends(t,e,n,r){this.artist.log("openBends",t,e,n,r);let o=X(this.artist.staves).tab_notes,s=t,i=n;pt(this.artist.current_bends)?(this.artist.bend_start_index=o.indexOf(t),this.artist.bend_start_strings=n):(s=o[this.artist.bend_start_index],i=this.artist.bend_start_strings);let c=s.getPositions(),l=e.getPositions();i.forEach((d,h)=>{let f=r[h],m=c[d],g=l[f];this.artist.current_bends[d]||(this.artist.current_bends[d]=[]),this.artist.current_bends[d].push(this.makeBend(m.fret,g.fret))})}closeBends(t=1){if(this.artist.bend_start_index==null)return;this.artist.log(`closeBends(${t})`);let e=X(this.artist.staves).tab_notes;Xe(this.artist.current_bends,(n,r)=>{let o=[];n.forEach(c=>o.push(c));let s=N.Flow.Bend.length<=1?new N.Flow.Bend(o):new N.Flow.Bend(null,null,o),i=parseInt(String(r),10);e[this.artist.bend_start_index].addModifier(s,i)}),e.slice(this.artist.bend_start_index+1,e.length-2+t+1).forEach(n=>n.setGhost(!0)),this.artist.current_bends={},this.artist.bend_start_index=null}makeTuplets(t,e){this.artist.log("makeTuplets",t,e);let n=Number(e??t),r=Number(t),o=X(this.artist.staves);if(!Number.isSafeInteger(n)||n<1||!Number.isSafeInteger(r)||r<1)throw new N.RERR("ArtistError","Tuplet counts must be positive integers");let s=Qe(r,o.meter),i=(c,l,d)=>{let h=c.slice(-n);if(h.length!==n||h.some(m=>m instanceof N.Flow.BarNote))throw new N.RERR("ArtistError","Not enough notes for tuplet in this bar and voice");let f=new N.Flow.Tuplet(h,{numNotes:r,notesOccupied:s});l&&d.push(f)};o.note&&i(o.note_notes,!0,this.artist.stave_articulations),i(o.tab_notes,!!o.tab&&this.artist.customizations["tab-stems"]==="true",this.artist.tab_articulations)}getFingering(t){return t.match(/^\.fingering\/([^.]+)\./)}makeFingering(t){let e=this.getFingering(t),n=N.Flow.Modifier.Position,r=[],o=[];if(e)e[1].split(/-/).forEach(i=>r.push(i.trim()));else return null;let s=()=>new N.RERR("ArtistError",`Bad fingering: ${e[1]}`);return r.forEach(i=>{let c=i.match(/(\d+):([ablr]):([fs]):([^-.]+)/);if(!c)throw s();let l=parseInt(c[1],10)-1,d=n.RIGHT;switch(c[2]){case"l":d=n.LEFT;break;case"r":d=n.RIGHT;break;case"a":d=n.ABOVE;break;case"b":d=n.BELOW;break;default:break}let h=Te(c[4],d,c[3]==="s");o.push({num:l,modifier:h})}),o}getStrokeParts(t){return t.match(/^\.stroke\/([^.]+)\./)}makeStroke(t){let e=this.getStrokeParts(t),n=N.Flow.Stroke.Type;if(!e)return null;switch(e[1]){case"bu":return new N.Flow.Stroke(n.BRUSH_UP);case"bd":return new N.Flow.Stroke(n.BRUSH_DOWN);case"ru":return new N.Flow.Stroke(n.ROLL_UP);case"rd":return new N.Flow.Stroke(n.ROLL_DOWN);case"qu":return new N.Flow.Stroke(n.RASQUEDO_UP);case"qd":return new N.Flow.Stroke(n.RASQUEDO_DOWN);default:throw new N.RERR("ArtistError",`Invalid stroke type: ${e[1]}`)}}getScoreArticulationParts(t){return t.match(/^\.(a[^/]*)\/(t|b)[^.]*\./)}makeScoreArticulation(t){let e=this.getScoreArticulationParts(t);if(!e)return null;let n=e[1],r=e[2],o=N.Flow.Modifier.Position,s=r==="t"?o.ABOVE:o.BELOW;return new N.Flow.Articulation(n).setPosition(s)}makeAnnotation(t){let e=this.artist.customizations["font-face"],n=this.artist.customizations["font-size"],r=this.artist.customizations["font-style"],o=this.artist.customizations["annotation-position"],s=N.Flow.Annotation.VerticalJustify,i=o==="top"?s.TOP:s.BOTTOM,c=(d,h=i)=>new N.Flow.Annotation(d).setFont(e,n,r).setVerticalJustification(h),l=t.match(/^\.([^-]*)-([^-]*)-([^.-]*)(?:-([^.]*))?\.(.*)/);if(l){e=l[1],n=l[2],r=l[3];let[,,,,d,h]=l;if(d!==void 0&&!Et(d))throw new N.RERR("ArtistError",`Invalid annotation color '${d}'`);if(!h)return null;let f=c(h);return d?f.setStyle(et(d)):f}if(l=t.match(/^\.([^.]*)\.(.*)/),l){let d=i,h=l[1],f=l[2];switch(h){case"big":r="bold",n="14";break;case"italic":case"italics":r="italic";break;case"medium":n="12";break;case"top":d=s.TOP,this.artist.customizations["annotation-position"]="top";break;case"bottom":d=s.BOTTOM,this.artist.customizations["annotation-position"]="bottom";break;default:break}return f?c(f,d):null}return c(t)}formatOverrideFretText(t){if(!t)return null;let e=N.Flow?.unicode??{},n=e.sharp??"#",r=e.flat??"b",o=e.natural??"n",s=t.match(/^([A-G])([#@n]{1,2})?(~?)(\d+)?(?:_(\d+)\/(\d+))?$/);if(s&&(s[4]||s[6])){let c=s[1],l=s[2]??"",d=s[4]??"",h=s[6],f=(()=>{switch(l){case"##":return`${n}${n}`;case"#":return n;case"@@":return`${r}${r}`;case"@":return r;case"n":return o;default:return""}})();return{text:`${c}${f}${d}`,string:h}}let i=t.match(/^(\d+)\/(\d+)$/);return i?{text:i[1],string:i[2]}:null}applyFretOverride(t,e){if(!t||!e||!t.fretElement||!t.positions)return;let n=0;if(e.string){let l=parseInt(e.string,10);if(!Number.isNaN(l)){let d=-1;t.positions.forEach((h,f)=>{parseInt(h.str,10)===l&&d<0&&(d=f)}),n=d>=0?d:0}}let r=t.fretElement[n];if(!r)return;r.setText(e.text);let o=this.artist.customizations["font-face"],s=this.artist.customizations["font-size"],i=this.artist.customizations["font-style"];o&&r.setFont(o,s,i);let c=0;t.fretElement.forEach(l=>{c=Math.max(c,l.getWidth())}),t.setWidth(c)}addAnnotations(t){let e=X(this.artist.staves),n=e.note_notes,r=e.tab_notes;if(t.length>r.length)throw new N.RERR("ArtistError","More annotations than note elements");e.tab?r.slice(r.length-t.length).forEach((o,s)=>{if(this.getScoreArticulationParts(t[s])){let i=this.makeScoreArticulation(t[s]);o.addModifier(i,0)}else if(this.getStrokeParts(t[s])){let i=this.makeStroke(t[s]);o.addModifier(i,0)}else{let i=t[s],c=this.formatOverrideFretText(i);if(c)this.applyFretOverride(o,c);else{let l=this.makeAnnotation(i);l&&o.addModifier(l,0)}}}):n.slice(n.length-t.length).forEach((o,s)=>{if(!this.getScoreArticulationParts(t[s])){let i=this.makeAnnotation(t[s]);i&&(typeof o.addAnnotation=="function"?o.addAnnotation(0,i):typeof o.addModifier=="function"&&o.addModifier(i,0))}}),e.note&&n.slice(n.length-t.length).forEach((o,s)=>{let i=this.makeScoreArticulation(t[s]);i&&(typeof o.addArticulation=="function"?o.addArticulation(0,i):typeof o.addModifier=="function"&&o.addModifier(i,0));let c=this.makeStroke(t[s]);c&&o.addStroke(0,c);let l=this.makeFingering(t[s]);if(l)try{l.forEach(d=>o.addModifier(d.modifier,d.num))}catch{throw new N.RERR("ArtistError",`Bad note number in fingering: ${t[s]}`)}})}addTabArticulation(t,e,n,r,o){if(this.artist.log("addTabArticulations: ",t,e,n,r,o),t==="T"&&Re(e,n,r,o),t==="t"&&n.addModifier(new N.Flow.Annotation("T").setVerticalJustification(N.Flow.Annotation.VerticalJustify.BOTTOM)),pt(r)&&pt(o))return;let s=null,i={first_note:e,last_note:n,first_indices:r,last_indices:o,firstNote:e,lastNote:n,firstIndexes:r,lastIndexes:o};if(t==="s"&&(s=new N.Flow.TabSlide(i)),(t==="h"||t==="p")&&(s=new N.Flow.TabTie(i,t.toUpperCase())),(t==="T"||t==="t")&&(s=new N.Flow.TabTie(i," ")),t==="b"&&this.openBends(e,n,r,o),s){let c=X(this.artist.staves)?.color;c&&s.setStyle(et(c)),this.artist.tab_articulations.push(s)}}addStaveArticulation(t,e,n,r,o){this.artist.log("addStaveArticulations: ",t,e,n,r,o);let s=null;if(t==="T"&&Re(e,n,r,o),["b","s","h","p","t","T"].includes(t)&&(s=new N.Flow.StaveTie({first_note:e,last_note:n,first_indices:r,last_indices:o,firstNote:e,lastNote:n,firstIndexes:r,lastIndexes:o})),s){let i=X(this.artist.staves)?.color;i&&s.setStyle(et(i)),this.artist.stave_articulations.push(s)}}getPreviousNoteIndex(){let t=X(this.artist.staves).tab_notes,e=2;for(;e<=t.length;){let n=t[t.length-e];if(n instanceof N.Flow.TabNote)return t.length-e;if(!(n instanceof N.Flow.BarNote))break;e+=1}return-1}addDecorator(t){if(this.artist.log("addDecorator: ",t),!t)return;let e=X(this.artist.staves),n=e.tab_notes,r=e.note_notes,o=null,s=null;t==="v"&&(o=new N.Flow.Vibrato),t==="V"&&(o=new N.Flow.Vibrato,typeof o.setHarsh=="function"&&o.setHarsh(!0)),t==="u"&&(o=new N.Flow.Articulation("a|").setPosition(N.Flow.Modifier.Position.BELOW),s=new N.Flow.Articulation("a|").setPosition(N.Flow.Modifier.Position.BELOW)),t==="d"&&(o=new N.Flow.Articulation("am").setPosition(N.Flow.Modifier.Position.BELOW),s=new N.Flow.Articulation("am").setPosition(N.Flow.Modifier.Position.BELOW));let i=X(n);if(i&&o&&i.addModifier(o,0),s){let c=X(r);c&&(typeof c.addArticulation=="function"?c.addArticulation(0,s):typeof c.addModifier=="function"&&c.addModifier(s,0))}}addArticulations(t){this.artist.log("addArticulations: ",t);let e=X(this.artist.staves),n=e.tab_notes,r=e.note_notes;if(pt(n)||pt(t)){this.closeBends(0);return}let o=X(n),s=!1;["b","s","h","p","t","T","v","V"].forEach(i=>{let c=t.map((m,g)=>m&&m===i?g:-1).filter(m=>m>=0);if(pt(c))return;i==="b"&&(s=!0);let l=this.getPreviousNoteIndex(),d=null,h=null,f=[];if(l===-1)d=null,h=null;else{d=n[l];let m=d.getPositions();h=[];for(let g of c){let y=o.getPositions()[g];if(!y)continue;let b=y.fret==="X"&&i==="T",k=m.findIndex((_,C)=>{if(h.includes(C))return!1;if(b){let S=e.note?r[l].getKeys():d.getPlayNote(),p=e.note?X(r).getKeys():o.getPlayNote();return _.fret==="X"&&S[C]===p[g]}return _.str===y.str});k>=0&&(h.push(k),f.push(g))}}e.tab&&this.addTabArticulation(i,d,o,h||[],f),e.note&&f.length&&this.addStaveArticulation(i,r[l],X(r),h||[],f)}),s||this.closeBends(0)}};import{Accidental as gr,Fraction as br,Music as yr,StaveNote as wn,WrittenAccidentalState as vr}from"vexflow";import{Modifier as Ce}from"vexflow";var ce=10,vn=5;function zt(a,t){let e=a.side==="above"?"higher":"lower";return"Slide "+(a.edge==="in"?"in from "+a.side:"out toward a "+e+" fret")+" on string "+t}function mr(a,t,e){return{x:a+(e.edge==="in"?-ce:ce),y:t+(e.side==="above"?-vn:vn)}}var le=class extends Ce{constructor(e){super();this.slide=e;this.setPosition(e.edge==="in"?Ce.Position.LEFT:Ce.Position.RIGHT)}static get CATEGORY(){return"OpenSlide"}draw(){let e=this.checkContext(),n=this.checkAttachedNote().getModifierStartXY(this.getPosition(),this.checkIndex()),r=mr(n.x,n.y,this.slide);e.openGroup("open-slide",this.getAttribute("id")),e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(r.x,r.y),e.stroke(),e.closeGroup(),this.setRendered()}};function ue(a,t,e){let n=new le(e);a.getModifiers().some(o=>o instanceof le&&o.getPosition()===n.getPosition())||(e.edge==="in"?a.setLeftDisplacedHeadPx(a.getLeftDisplacedHeadPx()+ce+2):a.setRightDisplacedHeadPx(a.getRightDisplacedHeadPx()+ce+2)),a.addModifier(n,t)}var de=class{constructor(t){this.signs=new WeakMap;this.artist=t}getNoteForFret(t,e){return Ze(this.artist.tuning,this.artist.key_manager,this.artist.music_api,t,e)}getNoteForABC(t,e){let n=t.key,r=e,o=t.accidental;return t.accidental_type&&(o=`${o||"n"}_${t.accidental_type}`),[n,r,o]}addStaveNote(t){let e={is_rest:!1,play_note:null,...t},n=X(this.artist.staves).note_notes,r=new N.Flow.StaveNote({keys:e.spec,duration:this.artist.current_duration,type:this.artist.current_head,clef:this.artist.current_clef,autoStem:!0});this.signs.set(r,e.signs),this.attachDots(r),e.play_note&&r.setPlayNote(e.play_note),n.push(r)}applyAccidentals(t){let e={};for(let[s,i]of Object.entries(new yr().createScaleMap(t.key)))e[s]=i.slice(1)||"n";let n=new vr(e),r=new Map;for(let s of t.note_voices){let i=new br(0,1);for(let c of s){let l=i.clone().simplify().toString(),d=r.get(l);d||(d={at:i.clone(),bar:!1,notes:[]},r.set(l,d)),c instanceof N.Flow.BarNote?d.bar=!0:(this.signs.has(c)&&d.notes.push(c),i.add(c.getTicks()))}}let o=new Map;for(let s of[...r.values()].sort((i,c)=>i.at.value()-c.at.value())){s.bar&&(n.reset(),o.clear());let i=new Map;for(let c of s.notes)xt.get(c)?.forEach((l,d)=>{if(!l.inherit)return;let h=l.inherit.written[0],f=o.get(l.inherit.written)??e[h],m=yn(c,d);if(l.key=m?.key??h+(f==="n"?"":f)+l.key.slice(l.key.indexOf("/")),bt(l.key)===void 0)throw new tt("syntax","Transposed note is outside the playable MIDI range",l.inherit.range)}),this.signs.get(c).forEach((l,d)=>{if(!l)return;let h=i.get(l.key)??[];h.push({head:l,note:c,index:d}),i.set(l.key,h)});for(let[c,l]of i){let d=l[0].head.sign,h=l.some(m=>m.head.sign!==d);o.set(c,d);let f=n.sign(c,h?"ambiguous":d)!==void 0;for(let{head:m,note:g,index:y}of l)this.updateSign(g,y,m,f||h)}}}updateSign(t,e,n,r){let o=n.cautionary&&(n.literal||!r),s=n.literal||r||o;if(n.mark&&(!s||n.mark.isCautionary()!==o)){let i=t.getModifiers(),c=i.indexOf(n.mark);c>=0&&i.splice(c,1),delete n.mark}s&&!n.mark&&(n.mark=new gr(n.sign),o&&n.mark.setAsCautionary(),t.addModifier(n.mark,e))}addTabNote(t,e=null){let n=X(this.artist.staves).tab_notes;this.artist.stavesBuilder.reserveTabRhythmSpace();let r=new N.Flow.TabNote({positions:t.map(({str:o,fret:s})=>({str:o,fret:s})),duration:this.artist.current_duration},this.artist.customizations["tab-stems"]==="true");e&&r.setPlayNote(e),t.forEach(({prebend:o,openSlide:s},i)=>{s&&ue(r,i,s),o&&r.addModifier(te(o),i)}),n.push(r),this.attachDots(r)}attachDots(t){for(let e=0;e<this.artist.current_dots;e++)N.Flow.Dot.buildAndAttach([t],t instanceof N.Flow.TabNote?{index:0}:{all:!0})}setDuration(t,e=!1){let n=/^(\d+|[whq])(s?)(d*)$/i.exec(t.trim());if(!n)throw new N.RERR("ArtistError",`Invalid duration '${t}'`);let r=Number(e)||n[3].length;this.artist.current_dots=r,this.artist.current_head=n[2]?"s":"n",this.artist.current_duration=n[1]+"d".repeat(r)}addDrums(t){let e=X(this.artist.staves),n=this.artist.current_duration,r=new wn(ee.note(t,n));this.attachDots(r),e.note_notes.push(r),e.tab_notes.push(new N.Flow.GhostNote(n)),xt.set(r,[])}addRest(t){this.artist.closeBends();let e=X(this.artist.staves);this.artist.stavesBuilder.reserveTabRhythmSpace();let n=t.explicit||Number(t.position)!==0,r=o=>{let s=new wn({keys:["r/4"],duration:this.artist.current_duration,type:"r"});if(s.setStave(o),n){let i=Number(t.position),c=o.getNumLines(),l=6-c,d=2*c-1,h=l+(i-1)/2;i<=0&&(h=l-1+i/2),i>=d&&(h=6+(i-d)/2),s.setRestLine(h)}return this.attachDots(s),s};e.note&&e.note_notes.push(r(e.note)),e.tab_notes.push(e.tab&&this.artist.customizations["tab-stems"]==="true"?r(e.tab):new N.Flow.GhostNote(this.artist.current_duration))}addChord(t,e,n){if(pt(t))return;this.artist.log("addChord: ",t);let r=X(this.artist.staves),o=[],s=[],i=[],c=[],l=[],d=[],h=[],f=[],m=0,g=t[0].string,y=0;if(t.forEach(b=>{m+=1,(b.abc||b.string!==g)&&(y=0,g=b.string),o[y]||(o[y]=[],s[y]=[],i[y]=[],c[y]=[],h[y]=[],l[y]=[],d[y]=null);let k=null,_=null,C=null,S=null,p,A,I;if(b.abc){let v=b.octave?b.octave:b.string;[k,_,C]=this.getNoteForABC(b.abc,v);let E=C?C.split("_")[0]:"";if(S=`${k}${E}`,b.abc.transposed&&!C&&!b.fret&&(I={written:k.toLowerCase()+"/"+_,range:b.abc.transposed},S=this.artist.music_api.createScaleMap(r.key)[k.toLowerCase()].replace(/n$/,"")),b.fret&&b.abc.transposed){let[B,H]=this.artist.tuning.getNoteForFret(Number(b.fret)+r.capo,b.string).split("/");A=B+"/"+(Number(H)-1+this.artist.current_octave_shift)}b.fret||(b.fret="X")}else if(b.fret){let v=String(Number(b.fret)+r.capo+(b.prebend?.semitones??0));[k,_,C]=this.getNoteForFret(v,b.string);let[E,B]=this.artist.tuning.getNoteForFret(v,b.string).split("/");S=E,p=Number(B)-1}else throw new N.RERR("ArtistError","No note specified");let L=parseInt(String(_),10)+this.artist.current_octave_shift,V=b.time?{time:b.time,dot:b.dot}:null,P=C?.split("_")[0],x=b.abc&&P&&P!=="n"?k+P:k;o[y].push(`${x}/${_}`);let F=(p??Number(_))+this.artist.current_octave_shift;s[y].push(`${S}/${L}`),i[y].push(A??`${S}/${F}`),c[y].push(P&&/^[a-g]/i.test(k)?{key:`${k[0].toLowerCase()}/${_}`,sign:P,literal:!!b.abc,cautionary:b.abc?b.abc.accidental_type==="c":this.artist.customizations.accidentals==="cautionary"&&P!=="n"}:null),h[y].push({fret:b.fret,str:b.string,prebend:b.prebend,openSlide:b.openSlide,marks:b.marks,inherit:I}),b.articulation?l[y].push(b.articulation):l[y].push(null),f[y]=V,b.decorator&&(d[y]=b.decorator),y+=1}),o.forEach((b,k)=>{if(f[k]&&this.setDuration(f[k].time,f[k].dot),this.addTabNote(h[k],s[k]),r.note&&(this.addStaveNote({spec:b,signs:c[k],play_note:s[k]}),!r.tab)){let C=h[k].filter(S=>S.prebend).map(S=>Ft(S.prebend,S.str));for(let S of h[k])S.openSlide&&C.push(zt(S.openSlide,S.str));if(C.length){let S=new N.Flow.Annotation(C.join(" \xB7 "));S.setVerticalJustification(N.Flow.Annotation.VerticalJustify.TOP),X(r.note_notes).addModifier(S,0)}}h[k].forEach((C,S)=>{C.marks&&(r.tab&&Vt(X(r.tab_notes),S,C.marks,!0),r.note&&Vt(X(r.note_notes),S,C.marks,!1))});let _=i[k].map((C,S)=>{let p=h[k][S].prebend;return{key:C,release:p?.release?p.semitones:0,inherit:h[k][S].inherit}});xt.set(X(r.tab_notes),_),r.note&&xt.set(X(r.note_notes),_),this.artist.addArticulations(l[k]),d[k]&&this.artist.addDecorator(d[k])}),e){let b=[];for(let k=0;k<m;k+=1)b.push(e);this.artist.addArticulations(b)}n&&this.artist.addDecorator(n)}addNote(t){this.addChord([t],null,null)}};import{Beam as wr,Fraction as xr,Voice as Sr}from"vexflow";function Be(a){let t=a;t==="C"&&(t="4/4"),t==="C|"&&(t="2/2");let e=/^(?:\((\d+(?:\+\d+)+)\)|(\d+(?:\+\d+)+))\/(\d+)$/.exec(t),n;if(e){let r=(e[1]||e[2]).split("+").map(Number),o=Number(e[3]);if(r.includes(0))throw new Error("Empty beat group");n=r.map(s=>new xr(s,o)),t=r.reduce((s,i)=>s+i,0)+"/"+o}return new Sr(t),{meter:t,groups:n??wr.getDefaultBeamGroups(t)}}var fe=class{constructor(t){this.artist=t}addBar(t){this.artist.log("addBar: ",t),this.artist.closeBends(),this.artist.key_manager.reset();let e=X(this.artist.staves),n=N.Flow.Barline.type,r=n.SINGLE;switch(t){case"single":r=n.SINGLE;break;case"double":r=n.DOUBLE;break;case"end":r=n.END;break;case"repeat-begin":r=n.REPEAT_BEGIN;break;case"repeat-end":r=n.REPEAT_END;break;case"repeat-both":r=n.REPEAT_BOTH;break;default:r=n.SINGLE;break}let o=new N.Flow.BarNote().setType(r);e.tab_notes.push(o),e.note&&e.note_notes.push(new N.Flow.BarNote().setType(r))}reserveTabRhythmSpace(){let t=X(this.artist.staves);!t.tab||t.tabRhythmSpace||this.artist.customizations["tab-stems"]!=="true"||(t.tabRhythmSpace=(t.note?3:2)*t.tab.getSpacingBetweenLines(),t.tab.setY(t.tab.getY()+t.tabRhythmSpace),this.artist.last_y+=t.tabRhythmSpace)}addVoice(t={}){this.artist.closeBends();let e=X(this.artist.staves);if(!e){this.addStave("stave",t);return}e.tab_notes.length?(e.tab_notes=[],e.note_notes=[],e.tab_voices.push(e.tab_notes),e.note_voices.push(e.note_notes),e.voiceSettings.push({options:{...this.artist.customizations},direction:t.voice,groups:[]})):Object.assign(X(e.voiceSettings),{direction:t.voice,options:{...this.artist.customizations}})}addStave(t,e){let n={tuning:"standard",clef:"treble",key:"C",notation:t==="tabstave"?"false":"true",tablature:t==="stave"?"false":"true",strings:6};Zt(n,e),this.artist.log("addStave: ",t,n);let r=null,o=null,s=this.artist.x+Number(this.artist.customizations["connector-space"]),i=40;n.notation==="true"&&(o=new N.Flow.Stave(s,this.artist.last_y,Number(this.artist.customizations.width)-20,{leftBar:!1}),n.color&&o.setDefaultLedgerLineStyle(et(n.color)),n.clef!=="none"&&o.addClef(n.clef),o.addKeySignature(n.key),n.time&&n["show-time"]!=="false"&&o.addTimeSignature(n.time),this.artist.last_y+=o.getHeight()+this.artist.options.note_stave_lower_spacing+parseInt(String(this.artist.customizations["stave-distance"]),10),i=o.getNoteStartX(),this.artist.current_clef=n.clef==="none"?"treble":n.clef),n.tablature==="true"&&(r=new N.Flow.TabStave(s,this.artist.last_y,Number(this.artist.customizations.width)-20,{leftBar:!1}).setNumLines(n.strings),n.clef!=="none"&&r.addTabGlyph(),r.setNoteStartX(i),this.artist.last_y+=r.getHeight()+this.artist.options.tab_stave_lower_spacing),this.artist.closeBends();let{meter:c,groups:l}=Be(n.time||"4/4"),d=[],h=[];this.artist.staves.push({tab:r,note:o,tab_voices:[d],note_voices:[h],tab_notes:d,note_notes:h,meter:c,key:n.key,capo:Number(n.capo??0),color:n.color,tabRhythmSpace:0,voiceSettings:[{options:{...this.artist.customizations},direction:n.voice,groups:[]}],text_voices:[],beam_groups:l}),this.artist.tuning.setTuning(n.tuning),this.artist.key_manager.setKey(n.key)}};var pe=class{constructor(t){this.artist=t}addTextVoice(){this.color=void 0,X(this.artist.staves).text_voices.push([])}setTextFont(t){if(!t)return;let e=t.match(/^([^-]*)-([^-]*)-([^-]*)(?:-(.*))?$/);if(e){if(e[4]!==void 0&&!Et(e[4]))throw new N.RERR("ArtistError",`Invalid text color '${e[4]}'`);this.color=e[4],this.artist.customizations["font-face"]=e[1],this.artist.customizations["font-size"]=parseInt(e[2],10),this.artist.customizations["font-style"]=e[3]}}addTextNote(t,e=0,n="center",r=!0,o=!1){let s=X(this.artist.staves).text_voices;if(pt(s))throw new N.RERR("ArtistError","Can't add text note without text voice");let i=this.artist.customizations["font-face"],c=this.artist.customizations["font-size"],l=this.artist.customizations["font-style"],d=N.Flow.TextNote.Justification.CENTER;switch(n){case"center":d=N.Flow.TextNote.Justification.CENTER;break;case"left":d=N.Flow.TextNote.Justification.LEFT;break;case"right":d=N.Flow.TextNote.Justification.RIGHT;break;default:d=N.Flow.TextNote.Justification.CENTER;break}let h=o?"b":this.artist.current_duration,f={text:t,duration:h,smooth:r,ignoreTicks:o,font:{family:i,size:c,weight:l}};t.startsWith("#")&&(f.glyph=t.slice(1),f.text="",f.font=null);let m=new N.Flow.TextNote(f).setLine(e).setJustification(d);this.color&&m.setStyle(et(this.color)),X(s).push(m)}};var Rt=class a{constructor(t,e,n,r){this.customizations={};this.staves=[];this.tab_articulations=[];this.stave_articulations=[];this.player_voices=[];this.last_y=0;this.current_duration="q";this.current_dots=0;this.current_head="n";this.current_clef="treble";this.current_bends={};this.current_octave_shift=0;this.bend_start_index=null;this.bend_start_strings=null;this.rendered=!1;this.renderer_context=null;this.player=null;this.x=t,this.y=e,this.width=n,this.options={font_face:Pe,font_size:10,font_style:null,bottom_spacing:30,tab_stave_lower_spacing:10,note_stave_lower_spacing:0,scale:1},r&&Zt(this.options,r),this.renderer=new se(this),this.articulations=new ae(this),this.notes=new de(this),this.stavesBuilder=new fe(this),this.text=new pe(this),this.reset()}static{this.DEBUG=!1}static{this.NOLOGO=!0}log(...t){a.DEBUG&&console&&console.log("(Vex.Flow.Artist)",...t)}reset(){this.tuning=new N.Flow.Tuning,this.key_manager=new N.Flow.KeyManager("C"),this.music_api=new N.Flow.Music,this.customizations={"font-size":this.options.font_size,"font-face":this.options.font_face,"font-style":this.options.font_style,"annotation-position":"bottom",scale:this.options.scale,width:this.width,"stave-distance":0,space:0,player:"false",tempo:120,instrument:"acoustic_grand_piano",accidentals:"standard","tab-stems":"false","tab-stem-direction":"up",beams:"auto","beam-rests":"true","beam-stemlets":"true","beam-middle-only":"false","connector-space":5},this.staves=[],this.tab_articulations=[],this.stave_articulations=[],this.player_voices=[],this.last_y=this.y,this.current_duration="q",this.current_dots=0,this.current_head="n",this.current_clef="treble",this.current_bends={},this.current_octave_shift=0,this.bend_start_index=null,this.bend_start_strings=null,this.rendered=!1,this.renderer_context=null}attachPlayer(t){this.player=t}setOptions(t,e=(n,r)=>new N.RERR("ArtistError",r)){this.log("setOptions: ",t);let n=Je(this.customizations);if(Object.entries(t).forEach(([r,o])=>{if(!n.includes(r))throw e(r,`Invalid option '${r}'`);if(["width","scale","font-size","tempo","space","stave-distance","connector-space"].includes(r)){let s=Number(o),i=["width","scale","font-size","tempo"].includes(r);if(!Number.isFinite(s)||String(o).trim()===""||i&&s<=0)throw e(r,`Invalid numeric value for '${r}': ${o}`)}if(r==="accidentals"&&!["standard","cautionary"].includes(o))throw e(r,"accidentals must be standard or cautionary");if(r==="beams"&&!["auto","off","explicit"].includes(o))throw e(r,"beams must be auto, explicit or off")}),Object.assign(this.customizations,t),this.rendered&&t.width!==void 0)for(let r of this.staves)r.note?.setWidth(Number(t.width)-20),r.tab?.setWidth(Number(t.width)-20);this.last_y+=Number(t.space??0),t.player==="true"&&(this.last_y+=15)}getPlayerData(){return{voices:this.player_voices,context:this.renderer_context,scale:Number(this.customizations.scale)}}render(t){this.renderer.render(t)}draw(t){this.render(t)}isRendered(){return this.rendered}isLogoHidden(){return!0}setDuration(t,e=!1){this.notes.setDuration(t,e)}addBar(t){this.stavesBuilder.addBar(t)}makeTuplets(t,e){this.articulations.makeTuplets(t,e)}addAnnotations(t){this.articulations.addAnnotations(t)}addArticulations(t){this.articulations.addArticulations(t)}addDecorator(t){this.articulations.addDecorator(t||null)}addRest(t){this.notes.addRest(t)}addChord(t,e,n){this.notes.addChord(t,e||null,n||null)}addNote(t){this.notes.addNote(t)}addTextVoice(){this.text.addTextVoice()}setTextFont(t){this.text.setTextFont(t)}addTextNote(t,e=0,n="center",r=!0,o=!1){this.text.addTextNote(t,e,n,r,o)}addVoice(t){this.stavesBuilder.addVoice(t||{})}addStave(t,e){this.stavesBuilder.addStave(t,e)}openBends(t,e,n,r){this.articulations.openBends(t,e,n,r)}closeBends(t=1){this.articulations.closeBends(t)}runCommand(t,e=0,n=0){this.log("runCommand: ",t);let r=t.split(/\s+/);switch(r[0]){case"color":{if(r.length!==2||!Et(r[1]))throw new N.RERR("ArtistError",`Expected a CSS color name or hex value at line ${e} column ${n}`);let o=X(this.staves),s=o&&X(o.note_notes),i=o&&X(o.tab_notes);if(!s&&!i||(s||i)instanceof N.Flow.BarNote)throw new N.RERR("ArtistError",`Put !color! after a note or rest at line ${e} column ${n}`);s?.setStyle(et(r[1])),s?.setLedgerLineStyle?.(et(r[1])),i?.setStyle(et(r[1]));break}case"octave-shift":if(r.length!==2||!/^[+-]?\d+$/.test(r[1])||!Number.isSafeInteger(Number(r[1])))throw new N.RERR("ArtistError",`Invalid octave shift at line ${e} column ${n}`);this.current_octave_shift=Number(r[1]),this.log("Octave shift: ",this.current_octave_shift);break;default:throw new N.RERR("ArtistError",`Invalid command '${r[0]}' at line ${e} column ${n}`)}}};var he=class{constructor(t){this.artist=t}newError(t,e){return new N.RERR("ParseError",`${e} in line ${t._l} column ${t._c}`)}parseStaveOptions(t,e="voice"){let n={};if(!t)return n;let r=null;t.forEach(i=>{let c=l=>this.newError(i,l);switch(n[i.key]=i.value,i.key){case"fingering":case"accents":break;case"notation":case"tablature":if(r=i,!["true","false"].includes(i.value))throw c(`'${i.key}' must be 'true' or 'false'`);break;case"color":if(e==="voice"||!Et(i.value))throw c("Expected a stave color as a CSS name or hex value");break;case"pickup":if(!/^([1-9]\d*)\/([1-9]\d*)$/.test(i.value))throw c("Expected a pickup span such as 1/4");break;case"fragment":if(!["true","false"].includes(i.value))throw c("fragment must be true or false");break;case"show-time":if(!["true","false"].includes(i.value))throw c("show-time must be true or false");break;case"key":{if(!(N.Flow?.hasKeySignature?N.Flow.hasKeySignature(i.value):Ke(N.Flow?.keySignature?.keySpecs,i.value)))throw c(`Invalid key signature '${i.value}'`);break}case"clef":{let l=["treble","bass","tenor","alto","percussion","none"];if(!l.includes(i.value))throw c(`'clef' must be one of ${l.join(", ")}`);break}case"voice":{let l=["top","bottom","new"];if(!l.includes(i.value))throw c(`'voice' must be one of ${l.join(", ")}`);break}case"time":try{Be(i.value)}catch{throw c(`Invalid time signature: '${i.value}'`)}break;case"tuning":try{new N.Flow.Tuning(i.value)}catch{throw c(`Invalid tuning: '${i.value}'`)}break;case"capo":if(!/^\d+$/.test(i.value)||!Number.isSafeInteger(Number(i.value)))throw c("Expected a nonnegative capo fret");break;case"strings":{let l=Number(i.value);if(!Number.isInteger(l)||l<4||l>8)throw c(`Invalid number of strings: ${l}`);break}default:throw c(`Invalid option '${i.key}'`)}});let o=n.notation??(e==="tabstave"?"false":"true"),s=n.tablature??(e==="stave"?"false":"true");if(o==="false"&&s==="false")throw this.newError(r,"Both 'notation' and 'tablature' can't be invisible");return n}parseCommand(t){t.command==="bar"&&this.artist.addBar(t.type),t.command==="tuplet"&&this.artist.makeTuplets(t.params.tuplet,t.params.notes),t.command==="annotations"&&this.artist.addAnnotations(t.params),t.command==="rest"&&this.artist.addRest(t.params),t.command==="command"&&this.artist.runCommand(t.params,t._l,t._c)}parseChord(t){this.artist.log("parseChord:",t),this.artist.addChord($e(t.chord,e=>Qt(e,"time","dot","fret","prebend","openSlide","marks","abc","octave","string","articulation","decorator")),t.articulation,t.decorator)}parseFret(t){this.artist.addNote(Qt(t,"time","dot","fret","prebend","openSlide","marks","string","articulation","decorator"))}parseABC(t){this.artist.addNote(Qt(t,"time","dot","fret","prebend","openSlide","marks","abc","octave","string","articulation","decorator"))}parseStaveElements(t){this.artist.log("parseStaveElements:",t);let e=X(this.artist.staves),n=X(e.voiceSettings),r;if(t.forEach(o=>{if(n.options.beams==="explicit"){if(o.command==="open_beam"){if(r)throw this.newError(o,"Nested beam group");r={index:e.tab_notes.length,token:o}}if(o.command==="close_beam"){if(!r)throw this.newError(o,"Missing opening beam bracket");let s=e.tab_notes.slice(r.index);if(s.length<2||s.some(i=>i.getIntrinsicTicks()>=N.Flow.RESOLUTION/4))throw this.newError(o,"Beams need at least two eighth notes or shorter values");n.groups.push([r.index,e.tab_notes.length]),r=void 0}if(r&&o.command==="bar")throw this.newError(o,"Beam crosses a barline")}if(o.time&&this.artist.setDuration(o.time,o.dot),o.command&&this.parseCommand(o),o.drums){let s=o.drums.map(c=>c.id),i=en(this.artist.current_clef,!!e.tab,s,this.artist.current_head==="s");if(i)throw this.newError(o,i);this.artist.notes.addDrums(s)}o.chord&&this.parseChord(o),o.abc?this.parseABC(o):o.fret&&this.parseFret(o)}),r)throw this.newError(r.token,"Missing closing beam bracket")}parseStaveText(t){pt(t)||this.artist.addTextVoice();let e=0,n="center",r=!0,o=null,s=()=>this.artist.addTextNote("",0,n,!1,!0),i=(c,l)=>{let d=!1,h=c;h[0]==="|"&&(d=!0,h=h.slice(1));try{this.artist.addTextNote(h,e,n,r,d)}catch(f){throw this.newError(l,`Bad text or duration. Did you forget a comma?${f}`)}};t.forEach(c=>{let l=c.text.trim();if(l.match(/\.font=.*/))o=l.slice(6),this.artist.setTextFont(o);else if(l[0]===":")this.artist.setDuration(l.slice(1));else if(l[0]==="."){let d=l.slice(1);switch(d){case"center":case"left":case"right":n=d;break;case"strict":r=!1;break;case"smooth":r=!0;break;case"bar":case"|":s();break;default:if(!/^[+-]?\d+$/.test(d))throw this.newError(c,`Invalid text position '${d}'`);e=Number(d);break}}else l==="|"?s():l.slice(0,2)==="++"?this.artist.addTextVoice():i(l,c)})}generate(t){t.forEach(e=>{switch(e.element){case"piano":throw this.newError(e,'Use layout="flow" or parseScore for a piano grand staff');case"stave":case"tabstave":this.artist.addStave(e.element,this.parseStaveOptions(e.options,e.element)),e.notes&&this.parseStaveElements(e.notes),e.text&&this.parseStaveText(e.text);break;case"voice":this.artist.addVoice(this.parseStaveOptions(e.options,e.element)),e.notes&&this.parseStaveElements(e.notes),e.text&&this.parseStaveText(e.text);break;case"options":{let n={};e.params.forEach(r=>{r.key!=="transpose"&&(n[r.key]=r.value)}),this.artist.setOptions(n,(r,o)=>this.newError(e.params.find(s=>s.key===r),o));break}default:throw this.newError(e,`Invalid keyword '${e.element}'`)}})}};function kr(a){return typeof a?.addStave=="function"}var Ct=class a{constructor(t,e){this.valid=!1;if(kr(t)){if(e?.language!==1)throw new TypeError("Use new VexTab(artist, { language: 1 }) for fixed engraving, or new VexTab() and renderScore() for language 2.");this.artist=t,this.compiler=new he(t)}else{if(e||t?.language===1)throw new TypeError("Language 1 fixed engraving requires new VexTab(artist, { language: 1 }).");if(t?.language!==void 0&&t.language!==2)throw new RangeError("Expected VexTab language 1 or 2");this.capacity=t?.capacity}}static{this.DEBUG=!1}reset(){this.valid=!1}isValid(){return this.valid}getArtist(){return this.artist}parse(t=""){this.reset(),a.DEBUG&&console.log(`(Vex.Flow.VexTab) Parsing:
|
|
351
|
+
`+t);let e=this.compiler?this.parseFixed(t):Lt(t,{language:2,capacity:this.capacity});return this.valid=!!e,e}parseFixed(t){let e;try{e=tn(t)}catch(n){throw n instanceof tt?Object.assign(new N.RERR("ParseError",n.message),{range:n.range}):n}return e&&this.compiler.generate(e),e}};function Fe(a){if(typeof a=="number")return a;if(!/^\d+\/[1-9]\d*$/.test(a))return NaN;let[t,e]=a.split("/").map(Number);return Number.isSafeInteger(t)&&Number.isSafeInteger(e)?t/e:NaN}function xn(a){let t=a.getSpacingBetweenLines()/2;return{left:a.getX(),right:a.getX()+a.getWidth(),top:a.getYForLine(0)-t,bottom:a.getYForLine(a.getNumLines()-1)+t}}function Er(a,t,e,n){let r=new Map,o=new Map;for(let c of a){let{partIndex:l,score:d,local:h,view:f}=c,m=d.measures[t-1],g=h.staves[t-1];g.forEach((y,b)=>r.set(y,{partIndex:l,staffIndex:b,bounds:xn(y)}));for(let[y,b]of f.staves.entries())for(let k of m.voices)if(!(k.hand&&k.hand!==b))for(let _ of k.events){let C=Fe(_.onset),S=h.getNote(f.eventId(b,_.id)),p=o.get(C);if(!p){let L=S.getAbsoluteX()-(S.isCenterAligned()?S.getCenterXShift():0);p={time:C,x:L,events:new Map},o.set(C,p)}let A=r.get(S.getStave())??r.get(g[y]),I=p.events.get(A);I?I.push(_.id):p.events.set(A,[_.id])}}let s=[...o.values()].sort((c,l)=>c.time-l.time),i=[...r.values()];return s.push({time:Fe(a[0].score.measures[t-1].span),x:i[0].bounds.right,events:new Map}),{measure:t,system:e,systemBounds:n,anchors:s,staves:i}}function Sn(a,t,e){let n=0,r=a.length;for(;n<r;){let o=Math.floor((n+r)/2);a[o][e]<t?n=o+1:r=o}return n}function kn(a,t,e,n,r){return n+(a-t)/(e-t)*(r-n)}function Wt(a,t,e,n,r){let{partIndex:o,staffIndex:s,bounds:i}=t;return{partIndex:o,staffIndex:s,measure:a.measure,offset:e,system:a.system,x:n,staffBounds:i,staffCenterY:(i.top+i.bottom)/2,systemBounds:a.systemBounds,eventIds:r?.events.get(t)??[]}}var qt=.5;function Pr(a,t,e){let n=a.anchors;if(t<n[0].x-qt||t>n[n.length-1].x+qt)return;let r=a.staves.find(l=>e>=l.bounds.top&&e<=l.bounds.bottom);if(!r)return;let o=Math.min(n.length-1,Sn(n,t,"x")),s=n[o],i=n[o-1],c=i&&t-i.x<s.x-t?i:s;return Math.abs(c.x-t)<=qt?Wt(a,r,c.time,c.x,c):Wt(a,r,kn(t,i.x,s.x,i.time,s.time),t)}function me(a){if(a instanceof SVGSVGElement)return({clientX:n,clientY:r})=>{let o=a.getScreenCTM();if(!o)return;let{x:s,y:i}=new DOMPoint(n,r).matrixTransform(o.inverse());if(Number.isFinite(s)&&Number.isFinite(i))return{x:s,y:i}};let t=parseFloat(a.style.width),e=parseFloat(a.style.height);return({clientX:n,clientY:r})=>{let o=a.getBoundingClientRect();if(o.width&&o.height)return{x:(n-o.left)*t/o.width,y:(r-o.top)*e/o.height}}}function En(a,t,e,n,r){let o=a.sheet.getContinuousLayout().rows,s=[],i=o.map(c=>{let l=c.measures.flatMap(d=>a.staves[d-1].map(xn));return{left:Math.min(...l.map(d=>d.left)),right:Math.max(...l.map(d=>d.right)),top:Math.min(...l.map(d=>d.top)),bottom:Math.max(...l.map(d=>d.bottom))}});return o.forEach((c,l)=>{for(let d of c.measures)s[d-1]=Er(t,d,l+1,i[l])}),{clientPoint:r,positionAt({partIndex:c,staffIndex:l=0,measure:d,offset:h}){if(!Number.isInteger(d))return;let f=s[d-1],m=f?.staves.find(_=>_.partIndex===c&&_.staffIndex===l),g=Fe(h);if(!m||!Number.isFinite(g)||g<0)return;let y=Sn(f.anchors,g,"time"),b=f.anchors[y];if(!b)return;if(b.time===g)return Wt(f,m,g,b.x,b);let k=f.anchors[y-1];if(k)return Wt(f,m,g,kn(g,k.time,b.time,k.x,b.x))},hitTest({x:c,y:l}){if(!Number.isFinite(c)||!Number.isFinite(l))return;let d=i.findIndex(y=>l>=y.top&&l<=y.bottom&&c>=y.left-qt&&c<=y.right+qt);if(d>=0)for(let y of o[d].measures){let b=Pr(s[y-1],c,l);if(b)return b}let h=e.hitTest(c,l);if(!h||h.reference||h.role==="mark")return;let f=s[h.measure-1],m=f.staves[n.findIndex(y=>y.id===h.staff)],g=f.anchors.find(y=>y.events.get(m)?.includes(h.sourceEvent));if(g)return Wt(f,m,g.time,g.x,g)}}}var ct=nr(Tn());var Mr="http://www.w3.org/2000/svg";var Tr=0;function Mt(a,t={}){let e=document.createElementNS(Mr,a);for(let[n,r]of Object.entries(t))e.setAttribute(n,String(r));return e}var Yt=class{constructor(t,e,n,r){this.surface=t;this.music=e;this.follow=r;this.layer=Mt("g",{class:"vextab-playback-ink","pointer-events":"none","aria-hidden":"true"});this.bar=Mt("line",{stroke:"#a8a8a8","stroke-opacity":.55,"stroke-width":3.5,"stroke-linecap":"round"});this.gradient="vextab-glow-"+ ++Tr;this.dots=[];this.anchors=[];this.pulses=[];this.active=[];this.anchor=0;this.pulse=0;this.frame=0;this.pages=new Map;this.printedRows=new Map;let o=Mt("radialGradient",{id:this.gradient});for(let[i,c]of[[0,.5],[.32,.72],[.52,.6],[.76,.22],[1,0]])o.append(Mt("stop",{offset:i,"stop-color":"currentColor","stop-opacity":c}));let s=Mt("defs");s.append(o),this.layer.append(s,this.bar);for(let i of e.events){let c=n.get(i.source);if(!c)continue;let{x:l,row:d,heads:h}=c,f=this.anchors[this.anchors.length-1];(!f||Math.abs(f.time-i.time)>1e-6)&&this.anchors.push({time:i.time,x:l,row:d,slope:0,speed:0}),h.length&&this.pulses.push({time:i.time,end:i.time+i.duration,heads:h,row:d})}this.anchors.forEach((i,c)=>{let l=this.anchors[c+1],d=(l?.row===i.row?l.x:i.row.right)-i.x,h=(l?.time??e.duration)-i.time;i.slope=h>0?d/h:0;let f=this.anchors[c-1];i.speed=i.slope,f?.row===i.row&&(i.speed=f.slope*i.slope>0?2/(1/f.slope+1/i.slope):0)})}rowLayer(t){let e=t.printedPage;if(!e)return this.layer.parentNode||this.surface?.append(this.layer),this.layer;let n=this.printedRows.get(t);if(n)return n;let r=this.pages.get(e);if(!r){let s=document.createElement("div");s.className="vextab-playback-page",e.before(s),r=Mt("svg",{"aria-hidden":"true",class:"vextab-playback-paper"});for(let i of["viewBox","width","height","preserveAspectRatio"])e.hasAttribute(i)&&r.setAttribute(i,e.getAttribute(i));r.style.cssText="pointer-events:none;background:transparent;border-color:transparent",s.append(e,r),this.pages.set(e,r),this.layer.parentNode||r.append(this.layer)}let o=Mt("g",{transform:"scale("+t.scale+")",class:"vextab-playback-ink","pointer-events":"none"});return r.append(o),this.printedRows.set(t,o),o}moveToRow(t){this.rowLayer(t).prepend(this.bar),this.bar.setAttribute("y1",String(t.top)),this.bar.setAttribute("y2",String(t.bottom)),this.row=t}start(t){if(!this.anchors.length)return;let e=()=>{let n=t();for(;this.anchor+1<this.anchors.length&&this.anchors[this.anchor+1].time<=n;)this.anchor++;let r=this.anchors[this.anchor],o=r.row!==this.row;o&&this.moveToRow(r.row),this.drawBar(n,r,this.anchors[this.anchor+1]),this.follow?.(this.bar,o),this.drawHeads(n),this.frame=requestAnimationFrame(e)};e()}drawBar(t,e,n){let r=n?.row===e.row,o=(r?n.x:e.row.right)-e.x,s=(n?.time??this.music.duration)-e.time,i=s>0?Math.max(0,Math.min(1,(t-e.time)/s)):0,c=r?n.speed:e.slope,l=(1-i)*(e.speed*s-o)+i*(o-c*s),d=e.x+i*o+i*(1-i)*l;this.bar.setAttribute("transform","translate("+d+" 0)")}drawHeads(t){for(;this.pulse<this.pulses.length&&this.pulses[this.pulse].time<=t+.075;)this.active.push(this.pulses[this.pulse++]);let e=0,n=0;for(let r of this.active){if(r.end<=t)continue;this.active[e++]=r;let o=r.end-r.time,s=Math.min(.075,o/2),i=Math.min(.14,o/2),c=Math.min(1,(t-r.time+s)/s,(r.end-t)/i);if(c>0)for(let l of r.heads)this.drawDot(n++,l,c,r.row)}this.active.length=e;for(let r=n;r<this.dots.length;r++){let o=this.dots[r];o.opacity!==0&&o.node.setAttribute("opacity","0"),o.opacity=0}}drawDot(t,e,n,r){let o=this.dots[t];if(o||(o={node:Mt("ellipse",{rx:17,ry:13,fill:"url(#"+this.gradient+")",stroke:"none"})},this.dots.push(o)),o.point!==e){let s=this.rowLayer(r);o.node.parentNode!==s&&s.append(o.node),o.node.setAttribute("cx",String(e.x)),o.node.setAttribute("cy",String(e.y)),o.point=e}o.opacity!==n&&o.node.setAttribute("opacity",String(n)),o.opacity=n}stop(){cancelAnimationFrame(this.frame),this.layer.remove();for(let[t,e]of this.pages)e.parentElement?.replaceWith(t)}};var Dt=new WeakMap;function ge(a){return{top:Math.min(...a.map(t=>t.getYForLine(0)))-7,bottom:Math.max(...a.map(t=>t.getYForLine(t.getNumLines()-1)))+7,right:Math.max(...a.map(t=>t.getNoteEndX()))}}function _r(a,t,e){let n=[],r=t[0].getAbsoluteX();for(let o of t){if(o.isRest()||!e.some(Boolean))continue;let s=o.getYs(),i="getHeadInk"in o?o.getHeadInk():[];for(let c=0;c<s.length;c++){let l=i[c]?i[c].x+i[c].w/2:o.getAbsoluteX();c===0&&o===t[0]&&(r=l),e[c]&&n.push({x:l,y:s[c]})}}return{row:a,x:r,heads:n}}function _n(a){let t=new Map;for(let e of a.staves){let n=[e.note,e.tab].filter(Boolean);if(!n.length)continue;let r=ge(n);(e.note?e.note_voices:e.tab_voices).forEach((s,i)=>s.forEach((c,l)=>{if(c.shouldIgnoreTicks())return;let d=e.note&&e.tab&&e.tab_voices[i]?.[l],h=d&&!d.shouldIgnoreTicks()?[c,d]:[c],f=(xt.get(c)??[]).map(m=>/^[a-g]/i.test(m.key));t.set(c,_r(r,h,f))}))}return t}function An(a,t,e,n){let r=new Map,o=new Map;for(let s of e){let{measure:i}=s[1];o.has(i)||o.set(i,[]),o.get(i).push(s)}for(let s of a.pages){for(let i of s.systems){let c=s.svg.querySelector('[data-system="'+i.measures[0]+'"] > g:last-child'),l=i.y/n+(c?.transform.baseVal[0]?.matrix.f??0),d=i.x/n,h;for(let f of i.measures)for(let[m,g]of o.get(f)??[])h??={top:l+g.row.top,bottom:l+g.row.bottom,right:d+g.row.right,printedPage:s.svg,scale:n},r.set(m,{row:h,x:d+g.x,heads:[]})}for(let i of s.heads.occurrences){if(i.reference||i.role==="mark")continue;let c=t.get(i.sourceEvent),l=r.get(i.sourceEvent);if(!c||!l||typeof i.sourceHead!="number")continue;let d=c.heads[i.sourceHead];if(c.silent||!d||!d.sounding&&d.midi===void 0)continue;let h=i.bounds,f={x:(h.x+h.w/2)/n,y:(h.y+h.h/2)/n};l.heads.length||(l.x=f.x),l.heads.push(f)}}return r}function Ar(a){let t=[];for(let e=a.parentElement;e&&e!==document.scrollingElement;e=e.parentElement){if(!(e instanceof HTMLElement))continue;let n=getComputedStyle(e),r=/^(auto|scroll|overlay)$/.test(n.overflowX),o=/^(auto|scroll|overlay)$/.test(n.overflowY);(r||o)&&t.push({element:e,x:r,y:o})}return t.push({element:document.scrollingElement,x:!0,y:!0}),t}function Nn(a,t,e,n){return t-a>=n-e||a<e?a-e:Math.max(0,t-n)}var be=class{constructor(){this.ports=[];this.reducedMotion=matchMedia("(prefers-reduced-motion: reduce)");this.lastFrame=0;this.nextCheck=0}update(t,e){let n=performance.now();if(!e&&n<this.nextCheck)return;(e||!this.ports.length)&&(this.ports=Ar(t));let r=Math.min(40,this.lastFrame?n-this.lastFrame:16),o=this.reducedMotion.matches?1:1-Math.exp(-r/65);this.lastFrame=n;let s=t.getBoundingClientRect(),{left:i,right:c,top:l,bottom:d}=s,h=!1;for(let{element:f,x:m,y:g}of this.ports){let y=f===document.scrollingElement,b=y?void 0:f.getBoundingClientRect(),k=b?b.width/(f.offsetWidth||1):1,_=b?b.height/(f.offsetHeight||1):1;if(!k||!_)continue;let C=window.visualViewport,S=b?b.left+f.clientLeft*k:C?.offsetLeft??0,p=b?b.top+f.clientTop*_:C?.offsetTop??0,A=y?C?.width??f.clientWidth:f.clientWidth*k,I=y?C?.height??f.clientHeight:f.clientHeight*_,L=m?Nn(i,c,S+12,S+A-12)/k:0,V=Math.min(68,I*.12),P=g?Nn(l,d,p+V,p+I-V)/_:0,x=Math.max(0,Math.min(f.scrollWidth-f.clientWidth,f.scrollLeft+L)),F=Math.max(0,Math.min(f.scrollHeight-f.clientHeight,f.scrollTop+P)),v=x-f.scrollLeft,E=F-f.scrollTop;if(Math.abs(v)>=1||Math.abs(E)>=1){h=!0;let B=H=>Math.sign(H)*Math.min(Math.abs(H),Math.max(1,Math.abs(H)*o));f.scrollBy({left:B(v),top:B(E),behavior:"instant"})}i-=v*k,c-=v*k,l-=E*_,d-=E*_}this.nextCheck=h?n:n+120}};function Nr(a){let t=[];for(let e=a.parentElement;e&&e!==document.documentElement;e=e.parentElement){let n=getComputedStyle(e),r=n.overflowX!=="visible",o=n.overflowY!=="visible";(r||o)&&t.push({element:e,x:r,y:o})}return t}function Rn(a,t,e,n,{size:r,inset:o}){let s=Nr(a),i=n.querySelector(".vextab-control-panel"),c=window.visualViewport,l=0,d,h=!1;function f(){l=0;let k=t.getBoundingClientRect(),_=e.getBoundingClientRect();if(h&&(!d||k.left!==d.left||k.top!==d.top||k.right!==d.right||k.bottom!==d.bottom)&&m(),d=k,!_.width||!_.height)return;let C=e.offsetWidth/_.width,S=e.offsetHeight/_.height,p=c?.offsetLeft??0,A=c?.offsetTop??0,I=Math.max(k.left,p),L=Math.max(k.top,A),V=c?.width??document.documentElement.clientWidth,P=c?.height??document.documentElement.clientHeight,x=Math.min(k.right,p+V),F=Math.min(k.bottom,A+P),v=k.height>=P*.8||k.width>V+1;for(let{element:z,x:D,y:U}of s){let j=z.getBoundingClientRect(),K=j.width/(z.offsetWidth||1),$=j.height/(z.offsetHeight||1),T=j.left+z.clientLeft*K,R=j.top+z.clientTop*$;(D&&k.width>z.clientWidth*K+1||U&&k.height>z.clientHeight*$+1)&&(v=!0),D&&(I=Math.max(I,T),x=Math.min(x,T+z.clientWidth*K)),U&&(L=Math.max(L,R),F=Math.min(F,R+z.clientHeight*$))}if(x<=I||F<=L){n.style.inset="0";return}let E=r==="auto"?v?"large":"mini":r;n.dataset.size!==E&&(n.dataset.size=E);let B=Math.min(o,Math.max(0,((x-I)*C-i.offsetWidth)/2)),H=Math.min(o,Math.max(0,((F-L)*S-i.offsetHeight)/2));n.style.padding=H+"px "+B+"px",n.style.setProperty("--control-y-inset",H+"px"),n.style.inset=[(L-_.top)*S,(_.right-x)*C,(_.bottom-F)*S,(I-_.left)*C].map(z=>z+"px").join(" ")}function m(){l||(l=requestAnimationFrame(f))}let g,y=new IntersectionObserver(k=>{if(h=k[k.length-1].isIntersecting,h){if(d=void 0,!g){g=new AbortController;let _={signal:g.signal,passive:!0};document.addEventListener("scroll",m,{..._,capture:!0}),window.addEventListener("resize",m,_),c?.addEventListener("scroll",m,_),c?.addEventListener("resize",m,_)}m()}else g?.abort(),g=void 0,n.style.inset="0"},{threshold:[0,.25,.5,.75,1]}),b=new ResizeObserver(m);for(let k of[a,...s.map(_=>_.element)])b.observe(k);return y.observe(t),f(),()=>{g?.abort(),y.disconnect(),b.disconnect(),cancelAnimationFrame(l)}}var Cn="http://www.w3.org/2000/svg",Bn=3e3;function Ut(a,t,e){let n=document.createElement("button");return n.type="button",n.className=t,n.setAttribute("aria-label",a),n.title=a,n.onclick=e,n}var ye=class{constructor(t,e,n,r,o,s,i,c,l){this.root=document.createElement("div");this.status=document.createElement("span");this.listeners=new AbortController;this.hideAt=0;if(this.root.className=`vextab-transport ${e}`,this.controls=document.createElement(l?"span":"div"),this.controls.className=l?"vextab-playback-controls":"vextab-sheet-controls",this.status.setAttribute("role","status"),n)if(this.toggle=Ut("Play","vextab-play",()=>this.toggle.classList.contains("vextab-stop")?o():r()),this.setButton(!1),l)this.controls.append(this.toggle);else{let d=document.createElement("div");d.className="vextab-control-panel",d.setAttribute("role","group"),d.setAttribute("aria-label","Playback"),this.scrollButton=Ut("Auto-scroll","vextab-auto-scroll",()=>this.setFollowing(!this.follower)),this.setFollowing(c.size!=="mini"),d.append(this.toggle,this.addTempo(i),this.scrollButton),this.controls.append(d),this.controls.dataset.position=c.position,this.controls.dataset.visibility=c.visibility,this.controls.style.setProperty("--control-inset",c.inset+"px")}this.setTempo(s),this.controls.append(this.status),(l??this.root).append(n||l?this.controls:this.status),t instanceof SVGSVGElement&&(this.surface=t),t&&(!l||t instanceof HTMLCanvasElement)&&this.mountSheet(t,n&&!l,c)}setFollowing(t){this.follower=t?new be:void 0,this.scrollButton.setAttribute("aria-pressed",String(t))}followSystem(t,e){this.controls.dataset.size==="large"&&this.follower?.update(t,e)}mountSheet(t,e,n){let r=this.sheet=document.createElement("div");if(r.className="vextab-sheet",t.before(r),r.append(t,this.root),t instanceof HTMLCanvasElement){let o=document.createElementNS(Cn,"svg");o.setAttribute("viewBox",`0 0 ${t.width} ${t.height}`),o.setAttribute("preserveAspectRatio","none"),o.setAttribute("aria-hidden","true"),o.classList.add("vextab-canvas-ink"),this.surface=document.createElementNS(Cn,"g"),this.surface.setAttribute("transform",t.getContext("2d").getTransform().toString()),o.append(this.surface),this.root.prepend(o)}if(e){if(this.controls.addEventListener("click",o=>o.stopPropagation(),{signal:this.listeners.signal}),this.controls.dataset.visibility==="hover"){let o=()=>this.reveal();o();for(let s of["pointerenter","pointermove","pointerdown"])r.addEventListener(s,o,{passive:!0,signal:this.listeners.signal})}this.untrack=Rn(r,t,this.root,this.controls,n)}}reveal(){if(this.hideAt=performance.now()+Bn,this.revealTimer!==void 0)return;this.controls.setAttribute("data-visible","");let t=()=>{let e=this.hideAt-performance.now();if(e>0){this.revealTimer=window.setTimeout(t,e);return}this.revealTimer=void 0,this.dismissHoverTempo?.(),this.controls.removeAttribute("data-visible")};this.revealTimer=window.setTimeout(t,Bn)}addTempo(t){let e=document.createElement("div");e.className="vextab-tempo";let n=document.createElement("div");n.className="vextab-tempo-stepper";let r=i=>{e.contains(i.target)||o(!1)},o=(i,c=!1)=>{this.dismissHoverTempo=i&&c?()=>{e.querySelector(":focus-visible")||o(!1)}:void 0,i?document.addEventListener("pointerdown",r,{signal:this.listeners.signal}):document.removeEventListener("pointerdown",r),n.inert=!i,this.metronome.setAttribute("aria-expanded",String(i))};this.metronome=Ut("Adjust tempo","vextab-metronome",()=>o(n.inert)),this.decrease=Ut("Decrease tempo","vextab-step",()=>t(Math.max(1,this.tempo-5))),this.decrease.textContent="\u2212";let s=Ut("Increase tempo","vextab-step",()=>t(this.tempo+5));return s.textContent="+",this.readout=document.createElement("span"),this.readout.className="vextab-bpm",this.readout.setAttribute("aria-live","polite"),n.append(this.decrease,this.readout,s),e.append(this.metronome,n),o(!1),e.onpointerenter=i=>{i.pointerType==="mouse"&&n.inert&&o(!0,!0)},e.onpointerleave=i=>{i.pointerType==="mouse"&&!e.querySelector(":focus-visible")&&o(!1)},e.addEventListener("focusout",i=>{e.contains(i.relatedTarget)||o(!1)}),e.onkeydown=i=>{i.key==="Escape"&&(this.metronome.focus(),o(!1))},e}setTempo(t){this.tempo=t,this.readout&&(this.readout.textContent=t+" BPM",this.metronome.setAttribute("aria-description",this.readout.textContent),this.decrease.disabled=t<=1)}setStatus(t){this.status.textContent=t}setPlaying(t){this.root.toggleAttribute("data-playing",t),this.setButton(t),t||(this.marker?.remove(),this.marker=void 0)}setButton(t){if(!this.toggle)return;let e=t?"Stop":"Play";this.controls.classList.contains("vextab-playback-controls")&&(this.toggle.textContent=e),this.toggle.title=e,this.toggle.setAttribute("aria-label",e),this.toggle.className=t?"vextab-stop":"vextab-play"}moveCursor(t,e){this.surface&&(this.marker||(this.marker=document.createElementNS("http://www.w3.org/2000/svg","circle"),this.marker.setAttribute("r","6"),this.marker.classList.add("vextab-playback-marker"),this.marker.setAttribute("fill","currentColor"),this.marker.setAttribute("opacity",".45"),this.marker.setAttribute("pointer-events","none"),this.surface.append(this.marker)),this.marker.setAttribute("cx",String(t)),this.marker.setAttribute("cy",String(e)))}remove(){this.untrack?.(),this.listeners.abort(),window.clearTimeout(this.revealTimer),this.marker?.remove(),this.controls.remove(),this.root.remove(),this.sheet&&this.sheet.replaceWith(...this.sheet.childNodes)}};function Fn(a,t){return{async open(e,n){let r=new Map,o=!1;function s(){o=!0,r.forEach(i=>i.stop()),r.clear()}n.addEventListener("abort",s,{once:!0});try{return await Promise.all([...new Set(t)].map(async i=>{let c=await a.open(i,n);o||n.aborted?c.stop():r.set(i,c)})),{get currentTime(){return r.values().next().value?.currentTime},playNote(i){r.get(i.program??e)?.playNote(i)},stop:s}}catch(i){throw s(),i}}}}function Rr(a){if(!a.some(e=>e.notes.some(n=>n.onsetOffset)))return a;let t=[];for(let e of a){let n=[];t.push({time:e.time,notes:n,mark:e.mark});for(let r of e.notes){if(!r.onsetOffset){n.push(r);continue}let{onsetOffset:o,...s}=r;t.push({time:e.time+o,notes:[s]})}}return t.sort((e,n)=>e.time-n.time)}var ve=class{constructor(){this.rate=1}setRate(t){this.retime?this.retime(t):this.rate=t}get active(){return!!this.request}play(t,e,n,r,o=0){this.stop();let s=this.request=new AbortController;return globalThis.addEventListener?.("pagehide",()=>this.stop(),{capture:!0,signal:s.signal}),new Promise((i,c)=>{s.signal.addEventListener("abort",()=>i(),{once:!0});let l=h=>{s.signal.aborted||(c(h),this.stop())},d=h=>{if(s.signal.aborted){h.stop();return}this.session=h;let f=()=>h.currentTime??performance.now()/1e3,m=Rr(n.events),g=f(),y=-o,b=()=>y+(f()-g)*this.rate,k=0,_=()=>{if(!s.signal.aborted)try{let C=b();for(;k<m.length&&m[k].time<=C;){let p=m[k++];p.mark?.();for(let A of p.notes)p.time+A.duration>C&&h.playNote(Cr(A,this.rate))}if(k===m.length&&C>=n.duration){this.stop();return}let S=m[k]?.time??n.duration;this.timer=window.setTimeout(_,Math.max(1,(S-b())/this.rate*1e3))}catch(C){l(C)}};this.retime=C=>{y=b(),g=f(),this.rate=C,window.clearTimeout(this.timer),_()},r(b),_()};try{let h=t.open(e,s.signal);"playNote"in h?d(h):h.then(d).catch(l)}catch(h){l(h)}})}stop(){this.retime=void 0,this.rate=1,this.request?.abort(),this.request=void 0,window.clearTimeout(this.timer),this.timer=void 0;let t=this.session;this.session=void 0,t?.stop()}};function Cr(a,t){return t===1?a:{...a,duration:a.duration/t,bend:a.bend?.map(e=>({...e,time:e.time/t}))}}function Xt(a){async function t(e,n){let r=a??new AudioContext,o=new Set,s=!1;function i(){if(!s){s=!0;for(let l of o)l.stop();!a&&r instanceof AudioContext&&r.state!=="closed"&&r.close(),n.removeEventListener("abort",i)}}n.addEventListener("abort",i,{once:!0});try{r instanceof AudioContext&&r.state!=="running"&&await r.resume(),n.throwIfAborted()}catch(l){throw i(),l}function c(l){let d=r.currentTime,h=d+l.duration,f=r.createOscillator(),m=r.createGain();f.type=e>=72&&e<=79?"sine":"triangle",f.frequency.value=440*2**((l.pitch-69)/12),f.detune.setValueAtTime(0,d);for(let g of l.bend??[])f.detune.linearRampToValueAtTime(g.semitones*100,d+g.time);m.gain.setValueAtTime(0,d),m.gain.linearRampToValueAtTime(l.velocity/127*.12,d+Math.min(.006,l.duration/3)),m.gain.exponentialRampToValueAtTime(.001,h),f.connect(m).connect(r.destination),o.add(f),f.onended=()=>{o.delete(f),f.disconnect(),m.disconnect()},f.start(d),f.stop(h)}return{playNote:c,stop:i,get currentTime(){return r.currentTime}}}return{open:t}}function Ln(a,t,e,n=!0){return{open(r,o){function s(){return o.throwIfAborted(),MIDI.programChange(0,r),{playNote(i){MIDI.noteOn(0,i.pitch,n&&!i.fixedVelocity?127:i.velocity,0),MIDI.noteOff(0,i.pitch,i.duration)},stop(){}}}return e[a]?s():new Promise((i,c)=>{MIDI.loadPlugin({instruments:[a],soundfontUrl:t,onerror:c,callback(){e[a]=!0;try{i(s())}catch(l){c(l)}}})})}}}var Fr={acoustic_grand_piano:0,acoustic_guitar_nylon:24,acoustic_guitar_steel:25,electric_guitar_jazz:26,distortion_guitar:30,electric_bass_finger:33,electric_bass_pick:34,trumpet:56,brass_section:61,soprano_sax:64,alto_sax:65,tenor_sax:66,baritone_sax:67,flute:73,synth_drum:118};function On(a){let t=/^\d+$/.test(String(a))?Number(a):Fr[a];if(!Number.isInteger(t)||t<0||t>127)throw new RangeError("Invalid instrument: "+a);return t}var Tt=class a{constructor(t,e={}){this.transport=new ve;this.generation=0;this.performanceTempo=120;this.sharedSurface=!1;this.companions=[];this.animations=[];if(this.options={instrument:"acoustic_grand_piano",tempo:120,show_controls:!0,soundfont_url:"/soundfont/",overlay_class:"vextab-player",...e},"parts"in t){let n=t;e.partId===void 0&&e.partIndex===void 0&&n.parts.length>1&&(this.ensemble=n.parts.map((r,o)=>yt(n,o))),t=yt(n,wt(n,e))}"measures"in t?(this.score=t,this.options.tempo=e.tempo??t.playback?.tempo??120,this.options.instrument=e.instrument??t.playback?.instrument??"acoustic_grand_piano"):this.artist=t,this.setTempo(this.options.tempo),this.setInstrument(this.options.instrument),this.reset()}static{this.DEBUG=!1}static{this.INSTRUMENTS_LOADED={}}setArtist(t){this.dispose(),this.score=void 0,this.ensemble=void 0,this.artist=t,this.reset()}setTempo(t){if(!Number.isFinite(t)||t<=0)throw new RangeError("Tempo must be positive");this.options.tempo=t,this.overlay?.setTempo(t),this.transport.active&&this.transport.setRate(t/this.performanceTempo)}setInstrument(t){On(t),this.options.instrument=t,this.stop()}reset(){this.artist?.attachPlayer(this),this.stop()}removeControls(){this.stop(),this.overlay?.remove(),this.overlay=void 0;for(let t of this.companions)t.overlay.remove();this.companions=[]}dispose(){this.removeControls(),this.mark=void 0,this.geometry=void 0,this.artist?.player===this&&this.artist.attachPlayer(null)}render(t,e,n=[]){this.removeControls(),this.mark=e;let r=t&&Dt.get(t);this.sharedSurface=!!this.ensemble&&!!r?.ensemble&&this.ensemble.every((g,y)=>r.ensemble[y]===g),this.geometry=r&&r.score===this.score?r.read:void 0;let o=this.artist?.getPlayerData().context,s=t??o?.canvas??o?.svg,i=this.options.controls,c=i instanceof HTMLElement?i:void 0;if(!s&&!c)throw new Error("Render the score before mounting playback controls");let l=this.score?.playback?.controls,d=typeof i=="object"&&!(i instanceof HTMLElement)?i:void 0,h=ne({...l,...d});(i===!0||c)&&h.visibility==="off"&&(h.visibility="hover");let f=(g,y,b)=>new ye(g,this.options.overlay_class,y,()=>{this.play().catch(()=>{})},()=>this.stop(),this.options.tempo,k=>this.setTempo(k),h,b);this.overlay=f(s,this.options.show_controls&&i!==!1&&h.visibility!=="off",c);let m=new Set(this.ensemble);for(let g of n){let y=Dt.get(g);y&&m.has(y.score)&&this.companions.push({...y,overlay:f(g,!1)})}}moveCursor(t,e){this.overlay?.moveCursor(t,e)}async play(){if(this.transport.active)return;let t=++this.generation,{tempo:e,instrument:n,playback:r,soundfont_url:o}=this.options;this.performanceTempo=e;let s=this.ensemble??(this.score?[this.score]:[]),i=dn(s,this.options.order==="performed"),c=an(this.options.performer??this.score?.playback?.performer,this.options.seed,this.options.swing??this.score?.playback?.swing),l=s.map(()=>[]),d=s.length?s.map((b,k)=>gn(b,e,this.mark,i.get(b),c,c.needsBeatGrid?l[k]:void 0)):[bn(this.artist,e)],h=c.perform(d,mn(l),e),f=h[0],m=new Map(s.map((b,k)=>[b,h[k]])),g=h.length===1?f:{events:h.flatMap(b=>b.events).sort((b,k)=>b.time-k.time),duration:Math.max(...h.map(b=>b.duration))},y=r??(!this.artist||typeof MIDI>"u"?Xt():Ln(String(n),o,a.INSTRUMENTS_LOADED,c.literal));if(this.overlay&&!g.events.some(b=>b.notes.length)){this.overlay?.setStatus("This example has no pitched notes to play.");return}this.overlay?.setPlaying(!0),this.overlay?.setStatus("Loading instruments...");try{let b=this.geometry?.()??(this.artist&&this.overlay?_n(this.artist):void 0);b?.size&&this.animations.push(new Yt(this.overlay?.surface,this.sharedSurface?g:f,b,(S,p)=>this.overlay?.followSystem(S,p)));for(let S of this.companions){let p=m.get(S.score);p&&this.animations.push(new Yt(S.overlay.surface,p,S.read()))}let k=On(n),_=[...new Set(g.events.flatMap(S=>S.notes.map(p=>p.program??k)))],C=_.some(S=>S!==k)?Fn(y,_):y;await this.transport.play(C,k,g,S=>{for(let p of this.animations)p.start(S);this.overlay?.setStatus(""),this.overlay?.setPlaying(!0)},this.animations.length?.075:0)}catch(b){throw t===this.generation&&(this.overlay?.setPlaying(!1),this.overlay?.setStatus(b instanceof Error?b.message:String(b))),b}finally{t===this.generation&&(this.stopAnimations(),this.overlay?.setPlaying(!1))}}stopAnimations(){for(let t of this.animations)t.stop();this.animations=[]}stop(){this.generation++,this.transport.stop(),this.stopAnimations(),this.overlay?.setStatus(""),this.overlay?.setPlaying(!1)}};N.Flow.Player||(N.Flow.Player=Tt);function In(a,t,e){let n=(a.editions??[]).filter(c=>!c.conductor&&!c.part),r=a.editions?.find(c=>t==="conductor"?c.conductor:c.part&&c.part===a.parts[t].id);r&&n.push(r);let o={},s=[];for(let c of n)Object.assign(o,c.settings),s.push(...c.anchors);for(let c of["systemBreaks","pageBreaks","preferredTurns","forbiddenTurns"])o[c]=s.filter(l=>l.field===c).map(l=>l.measure);let i={...o.margins,...e.margins};return{settings:{...o,...e,margins:i},cues:r?.cues??[],anchors:s,range:(r??n[0])?.range}}import{TextNote as Bt}from"vexflow";function Vn(a,t,e){return a.flatMap(n=>{let r=!1,o=n.map(s=>{let i=(d=0)=>d-3>e+4,c=s.text&&i(s.style.line)===t?s.text:"",l=s.boundaries?.filter(d=>i(d.style.line)===t).map(d=>t?{...d,style:{...d.style,line:d.style.line-e}}:d);return(c||l?.length)&&(r=!0),{...s,text:c,boundaries:l,belowBassStaff:t,style:c&&t?{...s.style,line:s.style.line-e}:s.style}});return r?[o]:[]})}function Hn(a){return a.boundaries?.some(t=>t.edge==="start"&&t.style.line===a.style.line)}var we=class{constructor(){this.regions=new Map;this.cells=new Map;this.smoothMeasures=new Map;this.smoothNotes=new Map}voices(t,e,n){let o=[{notes:t.map(i=>{let c=n(i.id,i.range);return i.text&&i.style.smooth&&!i.boundaries?.length&&this.smoothMeasures.set(c,e),this.anchor(i,c)})}],s=Math.max(0,...t.map(i=>i.boundaries?.length??0));for(let i=0;i<s;i++)o.push({notes:t.map(c=>{let l=c.boundaries?.[i];if(!l)return{skip:{duration:c.base,dots:c.dots}};let d=c.id+"-at-"+l.range.start;return this.anchor({...c,...l,id:d},n(d,l.range),l.edge)})});return o}anchor(t,e,n="beat"){let r={duration:t.base,dots:t.dots};if(!t.text)return{id:e,skip:r};if(this.cells.set(e,t),t.style.smooth&&n==="beat"&&!t.boundaries?.length)return"B4/"+t.base+"/r"+".".repeat(t.dots)+'[clef="treble",id="'+e+'"]';let{family:o,size:s,style:i,align:c,line:l}=t.style,d=t.glyph?Bt.GLYPHS[t.text]??t.text:t.text,h={...o&&{family:o},...s&&{size:s},...i==="italic"&&{style:i},...i==="bold"&&{weight:i},...t.glyph&&{family:At(),style:"normal",weight:"normal"}},m=n==="beat"&&Hn(t)?"right":c??"center";return{id:e,direction:{...r,text:d,anchor:n,line:l,align:m,font:h}}}prepare(t,e){let n=this.smoothMeasures.get(t);if(n===void 0||e instanceof Bt)return;e.renderOptions.draw=!1;let r=this.smoothNotes.get(n);r||this.smoothNotes.set(n,r=new Map),r.set(t,e)}smoothLabel(t,e,n){let{family:r,size:o,style:s,align:i,line:c}=e.style,l=new Bt({duration:e.base,...e.glyph?{glyph:e.text}:{text:e.text},line:c}).setDirectionAnchor("beat").setAttribute("id",n);return e.glyph?o&&l.setFontSize(o):l.setFont(r??l.fontInfo.family,o??l.fontInfo.size,s==="bold"?"bold":void 0,s==="italic"?"italic":void 0),l.setJustification(i==="right"?Bt.Justification.RIGHT:i==="left"?Bt.Justification.LEFT:Bt.Justification.CENTER),l.setStave(t.checkStave()).setTickContext(t.checkTickContext()),l.preFormat(),l}inkBounds(t,e){let n=[];for(let[r,o]of this.smoothNotes.get(e)??[]){if(o.getStave()!==t)continue;let s=this.cells.get(r),i=this.smoothLabel(o,s,r);this.positionLabel(i,t,s.glyph),n.push(i.getBoundingBox())}return n}positionLabel(t,e,n){if(t.getLine()-3<e.getNumLines())return;t.setYShift(0);let r=n?-t.getTextInk(0,0).y:t.getTextMetrics().fontBoundingBoxAscent;t.setYShift(e.getSpacingBetweenLines()+r)}place(t,e,n){let r=t.getAttribute("id"),o=this.cells.get(r);if(!o)return;let s;if(t instanceof Bt){if(s=t,s.getDirectionAnchor()==="beat"&&Hn(o)){let l=s.getTextMetrics().width;s.setXShift(o.style.align==="right"?0:o.style.align==="left"?l:l/2)}}else{if(!o.style.smooth)return;s=this.smoothLabel(t,o,r)}o.style.ink&&s.setStyle(et(o.style.ink));let i=t.checkStave();if(this.positionLabel(s,i,o.glyph),o.belowBassStaff){let l=s.getBoundingBox(),d=l.y;for(let h of n.notes.flat(3)){let f=h,m=f.getBeam?.();if(!(!m||m.getNotes()[0]!==f||f.getStave()?.getY()!==i.getY()))for(let g of m.getStripBounds())g.x<l.x+l.w&&g.x+g.w>l.x&&(d=Math.max(d,g.y+g.h+i.space(.4)))}s.setYShift(s.getYShift()+d-l.y)}let c=s.getBoundingBox();this.regions.set(r,{id:r,source:o.id,kind:"event",x:c.x,y:c.y,w:c.w,h:c.h}),s!==t&&e({source:t,bounds:c,draw:l=>s.setContext(l).drawWithStyle()})}};import zn,{KeyManager as Lr,Ornament as Or}from"vexflow";function Dn(a,t,e,n,r){a.save(),a.openGroup("score-heading");let o=t.align==="center",s=Math.min(1,o?Math.max(.75,n/620):n/620),i=0;function c(l,d,h,f,m=0){if(!l)return;let g=l.split(/(\^\{[^{}]+\}|♩|𝅗𝅥)/u).filter(Boolean).map(S=>{let p=S.startsWith("^{")&&S.endsWith("}"),A=p?S.slice(2,-1):S,I=S==="\u2669"?zn.Glyphs.metNoteQuarterUp:S==="\u{1D15E}"?zn.Glyphs.metNoteHalfUp:void 0,L=I?At():gt(),V=I?"normal":Ot(),P=I??A.trim(),x=f*s*(p?.62:1);a.setFont(L,x,V,"normal");let F=I?0:a.measureText("a a").width-a.measureText("aa").width,v=(A.length-A.trimStart().length)*F,E=(A.length-P.length)*F+a.measureText(P).width;return{label:P,family:L,weight:V,fontSize:x,raised:p,leading:v,advance:E}}),y=g.reduce((S,p)=>S+p.advance,0),b=o&&y>n?n/y:1,k=f*s*b,_=e+d*n-y*b*m,C=o?r+i+k*1.3:r-h*s;for(let S of g)a.setFont(S.family,S.fontSize*b,S.weight,"normal"),a.fillText(S.label,_+S.leading*b,C-(S.raised?k*.5:0)),_+=S.advance*b;o&&(i+=k*1.85)}return o?(c(t.title,.5,0,32,.5),c(t.dedication,.5,0,16,.5),c(t.composer,.5,0,16,.5),c(t.tempo,.5,0,16,.5)):(c(t.title,.5,112,34,.5),c(t.dedication,.045,74,18),c(t.tempo,.17,39,23),c(t.composer,.985,32,19,1)),a.closeGroup(),a.restore(),i}function jn(a,t){let e=new Lr(t),n=new Map;return a.notes.map(r=>{let[o,s]=r.key.split("/"),i=o[0],c=o.slice(1)||"n",l=i+s,d=n.get(l)??e.getAccidental(i).accidental??"n";n.set(l,c);let h=r.ornament&&new Or(r.ornament.replace("_inverted","Inverted")).getText(),f=h?'[stem="down",articulations="'+h+'.above"]':'[stem="down"]';return i+(d===c?"":c)+s+"/"+a.duration+f}).join(", ")}import qn,{AlternatingTremolo as $n,GraceNoteGroup as Yn,GraceTabNote as Vr,Ornament as zr,TextDynamics as Dr,Clef as jr,FretDiagram as Gr,Registry as xe,Fraction as $t,Annotation as St,Stroke as Un,Vibrato as Wr,Articulation as qr,Modifier as Ie,TabSlide as Le,Barline as Xn,StaveNote as Jt,TabNote as Se,TabTie as Oe,Factory as Yr,FrettedInstrument as Ur,Publication as Xr,ScoreNavigation as $r,SVGContext as Jr,CanvasContext as Kr}from"vexflow";import{Fraction as Ir}from"vexflow";function Gn(a,t,e,n,r=!1,o=!1,s=new Map){let i=[],c=[];for(let l of a.voices){let d=new Map;for(let[h,f]of l.events.entries()){let m=e(f.id),g=f.chord?[f.chord.text]:[];if(n)for(let y of f.heads)(y.connection||y.hammer)&&t==="tab"&&g.push(y.connection==="pull"?"P":y.connection==="slide"?"Slide":"H"),y.openSlide&&t==="notation"&&g.push(zt(y.openSlide,y.position.str)),y.prebend&&g.push(Ft(y.prebend,y.position.str));if(r)for(let y of f.gestures??[])"direction"in y?!a.state.piano&&!o&&g.push(y.kind+" "+y.direction):g.push(y.kind==="tap"?"T":y.wide?"Wide vibrato":"Vibrato");f.harmony&&g.length===1?i.push({note:m,harmony:f.harmony}):g.length&&i.push({note:m,text:g.join(" \xB7 ")});for(let y of re(f)){let{text:b,hyphen:k,extend:_,range:C,verse:S,elideWith:p,crossConnector:A}=y;if(t==="tab")throw new tt("fixed-layout","This lyric needs a notation staff",C);let I=S??"";d.has(I)||d.set(I,[]),d.get(I).push({note:m,text:b,elideWith:p,hyphenAfter:k,extendTo:_?e(A?s.get(C.start):l.events[h+_].id):void 0})}}for(let h of[...d.keys()].sort())c.push({id:h,syllables:d.get(h)})}return{chords:i,verses:c}}function Hr(a){return a.voices.flatMap(t=>t.events.filter(e=>e.frame)).map(t=>({event:t,beat:new Ir().parse(t.onset).value()})).sort((t,e)=>t.beat-e.beat)}function Wn(a,t){return a.measures.flatMap(e=>Hr(e).map(({event:n})=>{let{spec:r,range:o}=n.frame,s="frame"+o.start;return{id:t(s,o,n.id),source:s,diagram:{...r,label:n.chord.text}}}))}var Zr=0;function Qr(a,t){let e=a.measures[0].state,r=(e.piano?["right","left"]:["notation","tab"].filter(o=>e[o])).filter(o=>t==="score"||t===o||e.piano&&t==="notation");if(!r.length)throw new tt("fixed-layout",`No ${t} staff in this score`,e.declaration);for(let o of a.measures)if(o.state.piano!==e.piano||["notation","tab"].some(s=>(t==="score"||t===s)&&o.state[s]!==e[s])||r.includes("tab")&&o.state.strings!==e.strings)throw new tt("fixed-layout","A flow score must keep its staff configuration",o.state.declaration);return r}function jt(a,t){return a.state.piano?a.voices.filter(e=>e.hand===t):a.voices}var He=class{constructor(t){this.revision=t;this.ids=Object.create(null);this.ranges=new Map;this.prefix="vt"+ ++Zr+"-";this.id=(t,e)=>this.prefix+t+"-"+e;this.rangeFor=(t,e)=>e===this.revision?this.ranges.get(this.ids[t]??t):void 0;this.sourceFor=t=>this.ids[t]}project(t,e,n,r){let o=this.id(t,r?e+"-"+r:e);return this.ids[o]=e,this.ranges.set(e,n),o}};function to(a,t){let e=a.heads.flatMap((r,o)=>r.position?[{...r.position,displayKey:r.written,index:o}]:[]),n=[];if(a.bend){let r=e.map(s=>({str:s.str,fret:Number(s.fret)}));n.push(...t.attack(e,a.base).note.notation);let o=a.heads.some(s=>s.bend)?a.heads.flatMap(s=>s.bend&&!s.tiedBendStart?[s.bend]:[]):[a.bend.spec];for(let s of o)n.push(...t.bentAttack(r,a.base,s).note.notation.filter(i=>i.bend))}else if(e.length)for(let r of t.attack(e,a.base).note.notation)n.push({...r,index:e[r.index].index});return a.heads.forEach((r,o)=>{r.openSlide&&n.push({kind:"technique",id:"open-slide",index:o,label:zt(r.openSlide,r.position.str)}),r.prebend&&n.push({kind:"technique",id:"pre-bend",index:o,label:Ft(r.prebend,r.position.str)}),!r.position&&r.sounding===null&&n.push({kind:"unpitched",id:"slash",label:"Rhythm slash",index:o})}),n}function eo(a){let t=new Map;if(!a.hand)return t;for(let e of a.beamGroups??[]){let n=a.events.slice(e.start,e.end+1),r=n.map(o=>o.displayHand??a.hand);r.some(o=>o!==r[0])&&n.forEach((o,s)=>t.set(o,r[s]==="right"?-1:1))}return t}function no(a,t,e,n){let r=a.stem,o=r?r==="up"?1:-1:e==="tab"?a.tabDirection:void 0,s=new Ur(t.state.tuning,t.state.capo),i=e==="left"?"bass":t.state.clef,c=eo(a),l,d=a.events.map(m=>{let g=n.project(e,m.id,m.range);m.heads.forEach((L,V)=>n.project(e,m.id+"-head-"+V,L.range));let y=t.state.piano?m.displayHand:void 0,b=c.get(m),k=m.stem==="up"?1:m.stem==="down"?-1:void 0,_={duration:m.base,dots:m.dots,stemDirection:k??b??o,headSource:{event:m.id}};if(m.silent)return{id:g,skip:_};if(!m.heads.length){let L=e==="tab"?5-t.state.strings:0,V=m.restLine===void 0?void 0:m.restLine+L;return{id:g,...y&&{stave:y},note:{..._,keys:["r/4"],clef:"treble",type:"r",restLine:V}}}if(m.heads[0].drum){let L=(t.state.kit??ee).note(m.heads.map(V=>V.drum),m.base,m.stem??r);return{id:g,note:{...L,dots:m.dots,headSource:_.headSource}}}let C=to(m,s),S=m.heads.map(L=>L.position?.fret==="X"?L.written+"/X":L.written);if(e==="tab")return{id:g,tab:{..._,keys:S,notation:C,positions:m.heads.map(L=>({...L.position}))},drawStem:a.tabStems&&!["w","1"].includes(m.base)};let p=m.writtenClef??i;if(y&&y!==a.hand){let L=t.staffState?.[y];p=L?.clef??(y==="left"?"bass":"treble");for(let V of L?.changes??[]){if(new $t().parse(V.at).greaterThan(new $t().parse(m.onset)))break;p=V.clef??p}}let A=m.heads.map((L,V)=>{let P=_e(L.marks,m.heads);return{key:S[V],...P&&{fingering:{finger:P.finger,position:P.position}},...L.accidental&&{accidental:L.cautionary?"cautionary":"force"}}}),I={..._,heads:A,notation:C,clef:p,type:m.slash?"s":"n",autoStem:_.stemDirection===void 0};return m.tremolo&&(l===void 0?(l=_.stemDirection??new Jt({...I,autoStem:!0}).getStemDirection(),I.stemDirection=l):(I.stemDirection=l,l=void 0),I.autoStem=!1),{id:g,...y&&{stave:y},note:m.tremolo?$n.endpoint(I,m.tremolo):I,...m.grace&&{grace:{side:m.grace.side,slur:!0,beam:m.grace.pitches.length>1,notes:m.grace.pitches.map(L=>({keys:Array.isArray(L)?L:[L],duration:m.grace.slash?"8":"16",slash:m.grace.slash,clef:p}))}}}}),h=new Map;if(e!=="tab")for(let m of t.staffState?.[e]?.changes??[])!m.clef&&!m.key||h.set(m.at,{...h.get(m.at),...m.clef&&{clef:m.clef},...m.key&&{key:m.key}});return{notes:h.size?d.flatMap((m,g)=>{let y=h.get(a.events[g].onset);return y?[{change:y},m]:[m]}):d,stem:r??"auto",autoBeam:!a.events.some(m=>m.tremolo)&&a.beams&&(e!=="tab"||a.tabStems)&&{groups:a.beatGroups?.map(m=>new $t(m,Number(t.state.meter.split("/")[1]))),stemDirection:a.events.some(m=>m.stem)?void 0:o,flatBeams:a.flatBeams,beamRests:a.beamRests,showStemlets:a.stemlets,beamMiddleOnly:a.middleRests},beams:e==="tab"&&!a.tabStems?[]:a.beamGroups?.map(m=>({start:m.start,count:m.end-m.start+1,flatBeams:a.flatBeams,feathered:m.feather,showStemlets:a.stemlets})),tuplets:a.tuplets.map(m=>({start:m.start,count:m.count,options:{numNotes:m.numNotes,notesOccupied:m.notesOccupied}}))}}function ro(a){let t=a.voices[0].closing?.type;if(t==="end")return Xn.type.END;if(t==="double")return Xn.type.DOUBLE}function Jn(a,t,e,n=!1){let r=Qr(a,t);if(!r.includes("tab"))for(let p of a.measures)for(let A of p.voices){let I=A.events.find(L=>L.bend)?.bend;if(I)throw new tt("fixed-layout","A timed bend contour needs a tab staff",I.range)}let o=new He(a.source),s=o.id,i=a.layout?.heading,c=i&&(i.align==="center"||Object.keys(i).length===1)&&!Object.values(i).some(p=>/\^\{/.test(p)),l=Wn(a,(p,A,I)=>o.project(r[0],p,A,I)),d=[];if(c)for(let p of["title","dedication","composer","tempo"])i[p]&&d.push({kind:"text",runs:i[p].split(/([♩𝅗𝅥])/u).filter(Boolean).map(A=>A==="\u2669"||A==="\u{1D15E}"?{text:A==="\u2669"?qn.Glyphs.metNoteQuarterUp:qn.Glyphs.metNoteHalfUp,font:{family:At(),weight:"normal"}}:A),align:i.align??(p==="title"?"center":p==="composer"?"right":"left"),font:{family:gt(),weight:Ot(),size:p==="title"?32:16}});l.length&&d.push({kind:"diagrams",align:i?.align??"left",diagrams:l.map(p=>p.diagram),font:{family:gt(),size:12}}),a.playback?.swing==="eighths"&&d.push({kind:"text",font:{family:gt(),size:12,weight:Ot()},runs:["Swing ",{notes:["8","8"],beam:!0}," = ",{notes:["q","8"],tuplet:[3,2]}]});let h=new we,f=new Map(a.spans.filter(p=>p.kind==="lyric").map(p=>[p.range.start,p.to])),m=a.measures[0].state.tab&&a.measures.some(p=>p.voices.length>1),g=[],y=new Set(a.measures.flatMap(p=>p.voices.flatMap(A=>A.events.filter(I=>!I.heads.length).map(I=>I.id)))),b=new Map,k=[],_={stemPolicy:a.layout?.stemPolicy==="pitch"?void 0:"active-voices",accidentals:"key-aware",graceAccidentals:"ordered",sheet:{width:e,x:10,y:a.layout?.top??14,rowGap:a.layout?.rowGap??36,...a.layout?.spacing&&{measurePadding:18,measureGap:0}},system:{...a.layout?.spacing&&{details:{spacing:{mode:a.layout.spacing}}},spaceBetweenStaves:a.layout?.staffDistance??9},staves:r.map(p=>({id:p,kind:p==="tab"?"tab":"stave",...p==="right"&&{name:"R.H.",shortName:"R.H."},...p==="left"&&{name:"L.H.",shortName:"L.H."},...rn(a,p,p===r[0]),options:p==="tab"?{numLines:a.measures[0].state.strings}:{},measures:a.measures.map(A=>{let I=jt(A,p);if(p!=="tab"&&a.ties.length&&I.filter(x=>x.events.some(F=>F.heads.length)).length>1){for(let x of I)if(x.stem)for(let F of x.events)b.set(F.id,x.stem==="up"?"above":"below")}let L=p===r[0]||A.state.piano,V=p==="tab"?void 0:A.staffState?.[p];return{clef:V?.clef??(p==="tab"?"tab":p==="left"?"bass":A.state.clef),key:V?.key??A.state.key,time:A.state.meterSign??A.state.meter,span:A.span==="0/1"?"1/1":A.span,showTimeSignature:A.state.showTime&&!(p==="tab"&&r.includes("notation")),endBarline:ro(A),...L&&Gn({...A,voices:I},p==="tab"?"tab":"notation",x=>s(p,x),n||!r.includes("tab"),n,m,f),voices:[...I.map((x,F)=>x.events.length?no(x,A,p,o):{notes:[{id:s(p,"blank-"+A.number+"-"+F),skip:"w"}]}),...(A.state.piano&&r.length===2?Vn(A.text??[],p==="left",a.layout?.staffDistance??9):p===r[0]?A.text??[]:[]).flatMap(x=>h.voices(x,A.number,(F,v)=>o.project(p,F,v)))]}})})),continuous:{inkBounds:(p,A)=>h.inkBounds(p,A),verticalSpacing:a.measures[0].state.piano||r.length>1?"profile":"envelope",textLanes:"system",opening:{indent:a.layout?.firstSystemIndent,blocks:d},courtesy:!1,measureNumbers:a.measureNumbers,spans:g,groups:r.length===2?[{first:r[0],last:r[1],type:a.measures[0].state.piano?"brace":"bracket",barlines:!!a.measures[0].state.piano}]:[],boundaries:a.measures.map(p=>({measure:p.number,rehearsal:p.voices[0].rehearsal,breakBefore:p.newRow&&p.number>1?"force":void 0,repeatStart:["repeat-begin","repeat-both"].includes(p.voices[0].opening?.type),repeatEnd:["repeat-end","repeat-both"].includes(p.voices[0].closing?.type)}))}};for(let p of a.ties)for(let A of r){let I=s(A,p.from);o.ids[I]&&g.push({kind:"tie",id:o.project(A,p.id,p.range),from:I,to:s(A,p.to),side:A==="tab"?void 0:p.side??b.get(p.from)??b.get(p.to),...A==="tab"&&p.bend&&{bend:p.bend,string:p.string},fromHead:p.fromHead,toHead:p.toHead})}for(let p of a.spans??[]){if(p.kind==="pedal"){for(let V of r){let P=s(V,p.from),x=s(V,p.to);V!=="tab"&&o.ids[P]&&o.ids[x]&&g.push({kind:"pedal",pedalStyle:"text",id:o.project(V,p.id,p.range),from:P,to:x})}continue}if(p.kind==="lyric"||p.kind==="hyphen"||p.kind==="tremolo")continue;if(p.kind==="continuousBeam"||p.kind==="crescendo"||p.kind==="diminuendo"){for(let V of r){let P=s(V,p.from),x=s(V,p.to);!o.ids[P]||!o.ids[x]||V==="tab"||g.push({kind:p.kind==="continuousBeam"?"beam":p.kind,from:P,to:x,..."niente"in p&&{niente:p.niente},...p.side&&{side:p.side},id:o.project(V,p.id,p.range)})}continue}if("fromHead"in p){for(let V of r){if(V==="tab")continue;let P=s(V,p.from);o.ids[P]&&g.push({kind:p.kind==="glissando"?"glissando":"tie",id:o.project(V,p.id,p.range),from:P,to:s(V,p.to),fromHead:p.fromHead,toHead:p.toHead})}continue}if(p.kind==="slur"){for(let V of r){let P=s(V,p.from);V==="tab"&&(y.has(p.from)||y.has(p.to))||o.ids[P]&&g.push({kind:"slur",side:p.side??(V==="tab"?"below":void 0),id:o.project(V,p.id,p.range),from:P,to:s(V,p.to)})}continue}if(p.kind==="palmMute"&&!r.includes("tab"))throw new tt("fixed-layout","A string-specific palm mute needs a tab staff",p.range);if(p.kind!=="palmMute"&&p.kind!=="volta")continue;let A=p.kind==="palmMute"?"tab":r[0],L={id:o.project(A,p.id,p.range),from:s(A,p.from),to:s(A,p.to)};if(p.kind==="palmMute")g.push({...L,kind:p.kind,strings:p.strings});else if(A==="tab"&&y.has(p.from)!==y.has(p.to)){let V=a.measures[p.firstBar-1].voices.flatMap(v=>v.events),x=a.measures[p.lastBar-1].voices.flatMap(v=>v.events).find(v=>y.has(v.id)===y.has(p.from)),F=V.find(v=>y.has(v.id)===y.has(p.to));x||F?g.push({...L,kind:"volta",text:p.label,from:x?L.from:s(A,F.id),to:x?s(A,x.id):L.to}):k.push(p)}else g.push({...L,kind:p.kind,text:p.label})}let C=[];for(let p of a.measures)for(let A of r)if(A!=="tab")for(let I of jt(p,A))for(let L of I.events){let V=L.ossia;V&&C.push({id:s(A,L.id+"-ossia"),at:s(A,L.id),label:"Ossia.",notes:jn(V,p.state.key??"C"),beam:V.notes.length>1&&V.duration!=="q",scale:.63})}if(_.continuous.ossias=C,r.includes("left")&&r.includes("right")){let p=[];for(let A of a.measures){let I=new Map;for(let L of A.voices)for(let V of L.events)if(V.sharedStem){let P=V.sharedStem+":"+V.onset,x=I.get(P)??{},F=L.hand==="right"?"upper":"lower";if(x[F])throw new tt("measure","Duplicate shared stem endpoint",V.range);x[F]=s(L.hand,V.id),I.set(P,x)}for(let L of I.values()){if(!L.upper||!L.lower)throw new tt("measure","Shared stems need simultaneous notes on both staves",A.range);p.push({id:L.upper+"-shared",upper:L.upper,lower:L.lower})}}_.continuous.splitChords=p}let S={spec:_,nativeHeading:c,frames:l,staves:r,sources:o,eventId:s,mixedEndings:k,textLanes:h,printAnchors:n?new Map:void 0,endingRegions:[]};return _.engraving=lo(a,S),S}function oo(a,t,e){for(let n of t.labels??[]){let r=new St(n.text).setVerticalJustification(n.position==="below"?St.VerticalJustify.BOTTOM:St.VerticalJustify.TOP);r.setFont(n.family??gt(),n.size??12,n.style==="bold"?"bold":void 0,n.style==="italic"?"italic":void 0),n.ink&&r.setStyle(et(n.ink)),a.addModifier(r,0)}for(let n of t.gestures??[])if(n.kind==="tap")e&&a.addModifier(new St("T"),0);else if(n.kind==="vibrato")e&&a.addModifier(new Wr().setVibratoWidth(n.wide?28:18),0);else if(n.kind==="stroke")a.addModifier(new qr(n.direction==="up"?"a|":"am").setPosition(Ie.Position.BELOW),0);else if("direction"in n){let r=(n.kind==="rasgueado"?"RASGUEADO":n.kind.toUpperCase())+"_"+n.direction.toUpperCase();a.addModifier(new Un(Un.Type[r]),0)}}function so(a,t,e,n,r){if(t.grace?.positions&&a instanceof Se){let o=t.grace.positions.map(i=>new Vr({positions:i,duration:"16"})),s=new Yn(o).setPosition(t.grace.side==="before"?Ie.Position.LEFT:Ie.Position.RIGHT);a.addModifier(s,0)}if(t.grace?.fingerings){let o=a.getModifiers().find(s=>s instanceof Yn);for(let{attack:s,head:i,finger:c,position:l}of t.grace.fingerings)o&&Vt(o.getGraceNotes()[s],i,[{finger:c,position:l}],e==="tab",!0,!0)}if(t.ornament&&e!=="tab"&&a.addModifier(new zr(t.ornament.replace("_inverted","Inverted")),0),t.dynamic&&(n.hand||r)){let o=[...t.dynamic].map(i=>Dr.GLYPHS[i]).join(""),s=n.hand==="right"&&t.displayHand==="left"?St.VerticalJustify.TOP:St.VerticalJustify.BOTTOM;a.addModifier(new St(o).setFont(At(),15).setVerticalJustification(s),0)}oo(a,t,e==="tab"),t.color&&(a.setStyle(et(t.color)),a instanceof Jt&&a.setLedgerLineStyle(et(t.color))),t.silent&&(a.renderOptions.draw=!1),t.heads.forEach((o,s)=>{if(!o.marks)return;let i=a instanceof Jt&&!o.drum?_e(o.marks,t.heads):void 0;Vt(a,s,o.marks.filter(c=>c!==i),e==="tab",!0)}),a instanceof Se&&t.heads.forEach((o,s)=>{o.openSlide&&ue(a,s,o.openSlide),o.prebend&&a.addModifier(te(o.prebend),s)}),e==="tab"&&!n.tabStems&&!t.heads.length&&(a.renderOptions.draw=!1)}function io(a,t,e,n){let r=re(t).sort((s,i)=>(s.verse??"").localeCompare(i.verse??"")),o=0;for(let s of a.getModifiers()){if(!(s instanceof St))continue;let i=t.chord&&s.getText().split(" \xB7 ")[0]===t.chord.text,c=s.phraseManaged&&s.getVerticalJustification()===St.VerticalJustify.BOTTOM&&r[o++],l=i?t.chord.range:c&&c.range;if(!l)continue;i&&t.chord.color&&s.setStyle(et(t.chord.color));let d=(i?"chord":"lyric")+l.start;e.sources.project(n,d,l,t.id),e.sources.ids[s.getAttribute("id")]=d}}function ao(a,t,e,n,r){t.endingRegions.length=0;for(let o of t.mixedEndings){if(o.kind!=="volta")continue;let s=t.eventId("tab",o.id),i=c=>n.get(t.eventId("tab",a.measures[c-1].voices[0].events[0]?.id));for(let[c,l]of e.sheet.getContinuousLayout().rows.entries()){let d=l.measures.filter(S=>S>=o.firstBar&&S<=o.lastBar);if(!d.length)continue;let h=d[0],f=d[d.length-1],m=i(h),g=i(f);if(!m||!g)continue;let y=m.checkStave(),b=y.getX()+1,k=g.checkStave().getNoteEndX(),_=l.y+y.getY()-e.staves[h-1][0].getY()-15,C={x:b,y:_,w:k-b,h:14};t.endingRegions.push({id:s,kind:"span",source:o.id,row:c,...C}),r({source:m,bounds:C,draw(S){S.openGroup("tab-ending",s+"-"+c),S.fillRect(b,_,k-b,1),h===o.firstBar&&(S.fillRect(b,_,1,12),S.setFont(gt(),11).fillText(o.label,b+4,_+12)),f===o.lastBar&&S.fillRect(k-1,_,1,12),S.closeGroup()}})}}}function co(a,t,e,n){for(let r of a.spans)for(let o of t.staves){let s=e.get(t.eventId(o,r.from)),i=e.get(t.eventId(o,r.to));if(!s||!i)continue;if(r.kind==="tremolo"&&s instanceof Jt&&i instanceof Jt){let d=new $n(s,i,r.strokes);n({source:s,bounds:s.getBoundingBox().clone().mergeWith(i.getBoundingBox()),draw:h=>d.setContext(h).draw()})}if(!("fromHead"in r)||!(s instanceof Se)||!(i instanceof Se))continue;let c=Number(i.getPositions()[r.toHead].fret)>Number(s.getPositions()[r.fromHead].fret),l=(d,h)=>{let f={firstNote:d,lastNote:h,firstIndexes:[r.fromHead],lastIndexes:[r.toHead]},m=r.kind==="slide"||r.kind==="glissando"?new Le(f,c?Le.SLIDE_UP:Le.SLIDE_DOWN):d?r.kind==="pull"?Oe.createPulloff(f):Oe.createHammeron(f):new Oe(f);d&&(r.kind==="hammer"||r.kind==="pull")&&m.setFont({...m.fontInfo,family:gt(),weight:Ot()}),n({source:d??h,head:d?r.fromHead:r.toHead,bounds:m.getRibbonBounds(),draw:y=>m.setContext(y).draw()})};s.getStave().getY()===i.getStave().getY()?l(s,i):(l(s),l(void 0,i))}}function lo(a,t){let e=new Map;for(let n of a.measures)for(let r of t.staves)for(let o of jt(n,r))for(let s of o.events)e.set(t.eventId(r,s.id),{event:s,staff:r,voice:o,measure:n});return{prepareNote(n,r){let o=e.get(n.id);o?so(r,o.event,o.staff,o.voice,o.staff===t.staves[0]):t.textLanes.prepare(n.id,r)},place(n,r){let o=new Map,s=new Map;if(t.printAnchors)for(let d of n.sheet.getContinuousLayout().rows){let h=ge(d.measures.flatMap(f=>n.staves[f-1]));for(let f of d.measures)s.set(f,h)}for(let d of n.notes)for(let h of d)for(let f of h)for(let m of f){let g=m.getAttribute("id"),y=e.get(g),b=m;if(!y){t.textLanes.place(b,r,n);continue}let{measure:k,voice:_,staff:C,event:S}=y;o.set(g,b),t.printAnchors&&b.preFormatted&&s.has(k.number)&&(!t.printAnchors.has(S.id)||C===t.staves[0])&&t.printAnchors.set(S.id,{measure:k.number,x:b.getAbsoluteX(),row:s.get(k.number)}),S.silent&&(b.renderOptions.draw=!1);let p=b.checkStave();if(k.state.hideClef)for(let A of p.getModifiers(void 0,jr.CATEGORY))A.setText("");if(k.state.color){let A=et(k.state.color);p.setStyle(A),b.getVoice().setStyle(A),b.getBeam()?.setStyle(A)}if(C==="tab"&&!_.tabStems)for(let A of b.getTupletStack())A.setRendered();io(b,S,t,C)}co(a,t,o,r),t.mixedEndings.length&&ao(a,t,n,o,r);let i=o.get(t.eventId(t.staves[0],jt(a.measures[0],t.staves[0])[0]?.events[0]?.id));if(!i)return;let c=n.sheet.getRows()[0],l=!t.nativeHeading&&a.layout?.heading;if(l){let d=i.checkStave().getYForLine(0);r({source:i,bounds:{x:c.x,y:d-150,w:c.width,h:145},draw:h=>{Dn(h,l,c.x,c.width,l.align==="center"?d-150:d)}})}}}}function uo(a,t){let e=new Set(a.measures.flatMap(n=>n.voices.filter(r=>!r.tabStems).flatMap(r=>r.events.filter(o=>!o.heads.length).map(o=>t.eventId("tab",o.id)))));for(let n of a.measures)for(let r of n.voices)for(let o of r.events)if(o.silent)for(let s of t.staves)e.add(t.eventId(s,o.id));return e}var Ve=class extends $r{constructor(t,e,n,r){super(t,e,n);let o=[],s=0;for(let{score:c,view:l}of r)for(let d of l.staves){let h=e[s++];for(let f of c.measures)for(let[m,g]of jt(f,d).entries())for(let y of g.events)y.silent&&o.push({id:l.eventId(d,y.id),source:y.id,staff:h.id,measure:f.number,voice:m+1,onset:y.onset,duration:y.duration,label:["Measure "+f.number,h.name||h.id,"voice "+(m+1),y.duration+" rest"].join(", ")})}let i=new Map(e.map((c,l)=>[c.id,l]));o.length&&(this.events=[...this.events,...o].sort((c,l)=>c.measure-l.measure||new $t().parse(c.onset).value()-new $t().parse(l.onset).value()||i.get(c.staff)-i.get(l.staff)||c.voice-l.voice))}};function fo(a,t,e){let n=new Map;for(let r of a.sheet.getContinuousLayout().rows){let o=ge(r.measures.flatMap(s=>a.staves[s-1]));for(let{score:s,view:i}of t)for(let c of r.measures)for(let l of s.measures[c-1].voices)for(let d of l.events){let h=l.hand?[l.hand]:i.staves,f=e.heads.get(d.id).flatMap(g=>{if(g.role==="mark"||g.reference||typeof g.sourceHead!="number")return[];let y=d.heads[g.sourceHead];if(d.silent||!y||!y.sounding&&y.midi===void 0)return[];let b=g.bounds;return[{x:b.x+b.w/2,y:b.y+b.h/2}]}),m=f[0]?.x??a.getNote(i.eventId(h[0],d.id)).getAbsoluteX();n.set(d.id,{row:o,x:m,heads:f})}}return n}function ze(a,t,e={}){let n=e.part??"score",r="parts"in t?wt(t,e):0,o="parts"in t?yt(t,r):t;return Nt(o.layout?.font,()=>Kn(a,[je(o,n)],n,e,!1,r))}function De(a,t,e={}){return Nt(t.layout?.font,()=>Kn(a,t.parts.map((n,r)=>yt(t,r)),"score",e,!0))}function Kn(a,t,e,n,r=!1,o=0){let s=t[0],i=n.width??s.layout?.width??(a.clientWidth||640);if(!Number.isFinite(i)||i<=20)throw new RangeError("Score width must exceed 20 pixels");let c=t.map(T=>Jn(T,e,i-20)),l=c.map(T=>T.spec),d=r?Ee(t,l):l[0],h=document.createElement("div"),f=n.renderer==="canvas"?h.appendChild(document.createElement("canvas")):void 0,m=f?new Kr(f.getContext("2d")):new Jr(h);f||Kt(m,a),s.layout?.heading&&!c[0].nativeHeading&&(d.sheet.y+=125),c.some(T=>T.mixedEndings.length)&&(d.sheet.y+=20);let g=new Yr({renderer:{elementId:null,width:i,height:1}}).setContext(m),y=g.EasyScore();if(f){let T=d.engraving.place;d.engraving={...d.engraving,place(R,J){let G=0;for(let q of R.sheet.getContinuousLayout().detailMarks)G=Math.max(G,q.bounds.y+q.bounds.h);T(R,q=>{G=Math.max(G,q.bounds.y+q.bounds.h),J(q)}),C(R.sheet,G)}}}let b=y.compose(d),k=0,_=c.map((T,R)=>{let J=c.length===1?b:on(b,k,T.staves.length);k+=T.staves.length;let G=t[R];return{partIndex:o+R,score:G,view:T,local:J}});function C(T,R=0){let J=Math.max(i,...T.getRows().map(G=>G.x+G.width+10));m.resize(J,Math.ceil(Math.max(T.getHeight(),R)+20))}let S=[],p=c.flatMap(T=>T.frames.map(R=>({frame:R,sources:T.sources})));if(p.length){let T=xe.getDefaultRegistry(),R=T??new xe;T||xe.enableDefaultRegistry(R);try{g.draw(),R.getElementsByType(Gr.CATEGORY).filter(G=>G.isRendered()&&G.getContext()===m).forEach((G,q)=>{let{frame:Z,sources:Q}=p[q],{x:it,y:lt,w:rt,h:nt}=G.getBoundingBox();Q.ids[G.getAttribute("id")]=Z.source,S.push({id:Z.id,source:Z.source,kind:"event",x:it,y:lt,w:rt,h:nt})})}finally{T||xe.disableDefaultRegistry()}}else g.draw();let A=c.flatMap(T=>[...T.textLanes.regions.values()]),I=[...A,...S,...c.flatMap(T=>T.endingRegions)],L=Object.assign(Object.create(null),...c.map(T=>T.sources.ids)),V=_.flatMap(({score:T,view:R},J)=>R.staves.map(G=>{let q=T.measures[0].state,Z=T.instrument?.name??(q.piano?"Piano":q.tab?"Guitar":"Part "+(J+1)),Q={right:"right hand",left:"left hand",tab:"tablature",notation:"notation"}[G];return Z+", "+Q})),P=r?d.staves.map((T,R)=>({...T,name:V[R]})):d.staves,x=new Ve(b,P,L,_),F=new Map(_.flatMap(({score:T,view:R})=>T.ties.map(J=>[R.eventId("tab",J.id),[]])));for(let T of x.regions)F.get(T.id)?.push(T);let v=[...F.values()].flat(),E=new Set(_.flatMap(({score:T,view:R})=>[...uo(T,R)]));function B(T,R){let J=Q=>T>=Q.x&&T<=Q.x+Q.w&&R>=Q.y&&R<=Q.y+Q.h,G=A.find(J);if(G)return G;let q=x.heads.hitTest(T,R);if(q&&typeof q.sourceHead=="number"&&q.role!=="mark")return{id:q.sourceEvent+"-head-"+q.sourceHead,source:q.sourceEvent,kind:"event",...q.bounds};let Z=x.hitTest(T,R);return Z&&!E.has(Z.id)?Z:I.find(J)}f?(f.setAttribute("role","img"),f.setAttribute("aria-label",x.events.map(T=>T.label).join(". "))):C(b.sheet);let H=s.layout?.scale??1;if(H!==1){let T=f??m.svg;T.style.zoom=String(H),f||(h.style.width=parseFloat(T.style.width)*H+"px")}a.replaceChildren(h);function z(T,R,J){return D(T+"-head-"+R,J)}function D(T,R){for(let J of c){let G=J.sources.rangeFor(T,R);if(G)return G}}let U=b.sheet.getContinuousLayout().diagnostics.map(T=>({...T,range:T.source&&D(T.source,s.source)||s.measures[T.measures[0]-1]?.range}));for(let T of s.measures)if(t.some(R=>R.measures[T.number-1].voices.some(J=>J.events.some(G=>G.chord||G.lyric))))for(let R of b.systems[T.number-1].getPhraseLayout().diagnostics){let J=R.sources.find(G=>D(G,s.source));U.push({code:R.code,measures:[T.number],source:J,range:D(J,s.source)??T.range})}let j=f??m.svg,K=me(j),$;return Dt.set(j,{score:s,ensemble:r?t:void 0,read:()=>Nt(s.layout?.font,()=>fo(b,_,x))}),{score:s,parts:t,composition:b,navigation:x,hitTest:B,tabRegions:v,extraRegions:I,diagnostics:U,rangeFor:D,headRangeFor:z,get layoutMap(){return $??=Nt(s.layout?.font,()=>En(b,_,x.heads,P,K))},sourceFor:T=>L[T]}}function je(a,t,e){let n=t==="right"||t==="left"?t:void 0;if(!n&&e===void 0)return a;if(n&&!a.measures[0].state.piano)throw new tt("measure","A hand part needs a piano score",a.measures[0].range);if(!n&&a.measures[0].state.piano&&e!==void 0)throw new tt("measure","Choose a hand before selecting its voice",a.measures[0].range);let r=new Set,o=a.measures.map(c=>{let l=n?jt(c,n):c.voices;if(e!==void 0){let d=l[e-1];if(!Number.isInteger(e)||!d)throw new tt("measure","Missing voice "+e+" in bar "+c.number,c.range);l=[{...d,stem:void 0}]}for(let d of l)for(let h of d.events)r.add(h.id);return{...c,voices:l.map((d,h)=>({...d,rehearsal:h?d.rehearsal:c.voices[0].rehearsal,events:n?d.events.map(f=>f.displayHand?{...f,displayHand:void 0}:f):d.events}))}}),s=a.ties.filter(c=>r.has(c.from)&&r.has(c.to)),i=(a.spans??[]).filter(c=>c.kind==="volta"||r.has(c.from)).map(c=>{if(c.kind!=="volta")return c;let l=o[c.lastBar-1].voices[0].events;return{...c,from:o[c.firstBar-1].voices[0].events[0].id,to:l[l.length-1].id}});return{...a,measures:o,ties:s,spans:i}}function po(a,t,e,n={}){let{voice:r,partId:o,partIndex:s,...i}=n;return Nt(t.layout?.font,()=>"parts"in t?Zn(a,t,wt(t,{partId:o,partIndex:s}),i,e,r):Qn(a,[je(t,e,r)],[e],i))}function ho(a,t,e="conductor",n={}){return Nt(t.layout?.font,()=>Zn(a,t,e==="conductor"?e:wt(t,e),n,"score"))}function Zn(a,t,e,n,r,o){let s=e==="conductor",i=In(t,e,n),c=n.regions===void 0?i.cues.map(f=>wt(t,{partId:f.part})):[],l=s?t.parts.map((f,m)=>m):[...new Set([e,...c])],d=l.map((f,m)=>{let g=yt(t,f);return m===0&&!s?je(g,r,o):g}),h=d.map((f,m)=>m===0?r:"score");return Qn(a,d,h,i.settings,{conductor:s,donors:c.map(f=>l.indexOf(f)),edition:i,document:t})}function Qn(a,t,e,n,r){let o=t[0],s=t.map((S,p)=>Jn(S,e[p],600,!0)),i=s.length>1?Ee(t,s.map(S=>S.spec)):s[0].spec;r?.conductor||(i.continuous.boundaries=s[0].spec.continuous.boundaries),r?.conductor||(i.continuous.opening=s[0].spec.continuous.opening);let{compressRests:c,...l}=n;if(c){let S=new Set([...l.preferredTurns??[],...l.forbiddenTurns??[]].map(p=>p+1));i.continuous.compressRests=!0,i.continuous.boundaries=i.continuous.boundaries.flatMap(p=>S.has(p.measure)||o.measures[p.measure-1].state.fragment?[{...p,keepRest:!0}]:p.rehearsal||p.breakBefore||p.repeatStart||p.repeatEnd?[p]:[])}let{noteHooks:d,...h}=l;if(d?.length){for(let p of i.staves)for(let A of p.measures)for(let I of A.voices)typeof I.notes!="string"&&(I.notes=I.notes.map(L=>typeof L!="object"||!("skip"in L)||typeof L.skip=="string"?L:"B4/"+L.skip.duration+"/g"+".".repeat(L.skip.dots??0)+'[id="'+L.id+'"]'));let S=i.engraving.prepareNote;i.engraving={...i.engraving,prepareNote(p,A,I){S(p,A,I);for(let L of d)L(p,A,I)}}}r&&!r.conductor&&(h.staves=i.staves.slice(0,s[0].staves.length).map(S=>S.id)),r?.donors.length&&(h.regions=r.edition.cues.map((S,p)=>{let A=s.slice(0,r.donors[p]).reduce((I,L)=>I+L.staves.length,0);return{kind:"cue",staff:i.staves[A].id,label:S.label,measure:S.measure}}));let f=sn(o.source),m;try{m=new Xr(i).render(a,h)}catch(S){throw r?.edition.range&&S.code==="BadPublication"?new tt("fixed-layout",S.message,f(r.edition.range)):S}let g=(r?.conductor?s:s.slice(0,1)).flatMap(S=>S.frames.map(p=>({frame:p,sources:S.sources})));g.length&&m.pages.flatMap(p=>[...p.svg.querySelectorAll(".vf-score-opening .vf-fret-diagram")]).forEach((p,A)=>{let I=p.getAttribute("data-vf-id")?.replace(/^vf-/,"");I&&g[A]&&(g[A].sources.ids[I]=g[A].frame.source)});let y=(S,p)=>s.map(A=>A.sources.rangeFor(S,p)).find(Boolean),b=m.diagnostics.map(S=>{let p=S.measures[0],A=S.code==="ForbiddenTurn"&&r?.edition.anchors.find(x=>x.field==="forbiddenTurns"&&x.measure===p),I=S.detail.startsWith("cue exceeds")&&r?.edition.cues.find(x=>x.measure===p),L=A||I,V=S.code==="ExcludedAnchor"?S.detail:S.detail.split(" ")[1],P=L?f(L.range):y(V,o.source)||S.code==="TextOverflow"&&r?.edition.range&&f(r.edition.range)||o.measures[p-1]?.range;return{...S,range:P}}),k=new Map,_=r?.conductor?t:[o];for(let S of _)for(let p of S.measures)for(let A of p.voices)for(let I of A.events)k.set(I.id,I);let C=new Map((r?.conductor?s:s.slice(0,1)).flatMap(S=>[...S.printAnchors]));for(let S of m.pages)Dt.set(S.svg,{score:o,ensemble:r?.conductor?t:void 0,read:()=>An(m,k,C,(h.staffSize??7)/40)});return{publication:m,diagnostics:b,score:o,rangeFor:y,headRangeFor:(S,p,A)=>y(S+"-head-"+p,A),sourceFor:S=>s.map(p=>p.sources.sourceFor(S)).find(Boolean)}}er();function st(a,t,e){return a.getAttribute(`data-${t}`)||(e?a.getAttribute(`data-${e}`):null)||a.getAttribute(t)}function mo(a){let t=st(a,"playback-controls"),e=st(a,"playback-position"),n=st(a,"playback-inset"),r=st(a,"playback-size");if(t===null&&e===null&&n===null&&r===null)return;if(t==="off"||t==="false")return!1;let o={};return t&&t!=="on"&&t!=="true"&&(o.visibility=t),r&&(o.size=r),e&&(o.position=e),n!==null&&(o.inset=Number(n)),ne(o),(t==="on"||t==="true")&&!o.visibility&&(o.visibility="hover"),o}function go(a,t){let e=st(a,"layout");return e==="flow"||!e&&/^[ \t]*piano(?:\s|$)/m.test(t)}var Ge=class{constructor(t,e={}){this.part="score";this.disposed=!1;this.composing=!1;this.surface=null;this.text_area=null;this.editor_error=null;this.timeoutID=null;if(this.order=e.order,this.playback=e.playback??Xt(),this.sel=t,!this.sel)throw new Error(`VexTab.Div: invalid selector: ${t}`);this.code=(0,ct.default)(t).text(),(0,ct.default)(t).empty(),(0,ct.default)(t).css("position")==="static"&&(0,ct.default)(t).css("position","relative");let n=(0,ct.default)(t)[0];this.playbackControls=e.playbackControls??mo(n),this.enablePlayer=e.player??(this.playbackControls===void 0?void 0:!!this.playbackControls);let r=st(n,"performer");if(e.performer!==void 0)this.performer=e.performer;else if(r){if(!nn(r))throw new RangeError("Unknown performer: "+r);this.performer=r}this.seed=e.seed;let o=st(n,"width");this.width=parseInt(o,10)||400,this.scale=parseFloat(st(n,"scale"))||1,this.rendererBackend=st(n,"renderer")||"svg";let s=e.language??Number(st(n,"language")??2);if(s!==1&&s!==2)throw new RangeError("Expected VexTab language 1 or 2");this.grammar2=s===2;let i=e.capacity??st(n,"capacity")??"default";if(i!=="default"&&i!=="large")throw new RangeError("Expected score capacity default or large");if(this.capacity=i,this.partIndex=e.partIndex,this.partId=e.partId??st(n,"part-id")??void 0,this.conductor=(e.view??st(n,"view"))==="conductor",this.conductor&&(!this.grammar2||this.partIndex!==void 0||this.partId!==void 0))throw new Error("The conductor view requires a complete v2 score");this.flow=this.grammar2||go(n,this.code),n.classList.toggle("vextab-flow",this.flow),this.editor=st(n,"editor")||"",this.show_errors=st(n,"show-errors")||"",this.editor_width=parseInt(st(n,"editor-width","editor_width"),10)||this.width,this.editor_height=parseInt(st(n,"editor-height","editor_height"),10)||200,this.editor==="true"?(this.text_area=(0,ct.default)('<textarea aria-label="VexTab source"></textarea>').addClass("editor").val(this.code),this.code=this.text_area.val(),this.editor_error=(0,ct.default)('<div role="status"></div>').addClass("editor-error"),(0,ct.default)(t).append((0,ct.default)("<p/>")).append(this.editor_error),(0,ct.default)(t).append((0,ct.default)("<p/>")).append(this.text_area),this.text_area.width(this.editor_width),this.text_area.height(this.editor_height),this.text_area.on("compositionstart.vextab",()=>{this.composing=!0,window.clearTimeout(this.timeoutID)}),this.text_area.on("compositionend.vextab",()=>{this.composing=!1,this.scheduleEdit()}),this.text_area.on("input.vextab",()=>this.scheduleEdit()),this.text_area.on("keydown.vextab",c=>{!this.composing&&(c.ctrlKey||c.metaKey)&&c.key==="Enter"&&(c.preventDefault(),this.run())})):this.show_errors==="true"&&(this.editor_error=(0,ct.default)('<div role="status"></div>').addClass("editor-error"),(0,ct.default)(t).append((0,ct.default)("<p/>")).append(this.editor_error)),this.flow||(this.artist=new Rt(10,0,this.width,{scale:this.scale}),this.parser=new Ct(this.artist,{language:1})),this.autoWidth=this.flow&&st(n,"layout")!=="fixed"&&(o===null||o==="auto"),this.autoWidth&&n.clientWidth>20&&(this.width=n.clientWidth),this.redraw(),document.fonts.status==="loading"&&document.fonts.ready.then(()=>{this.disposed||this.redraw()}),this.autoWidth&&(this.observer=new ResizeObserver(([c])=>{let l=Math.floor(c.contentRect.width);cancelAnimationFrame(this.resizeFrame),l>20&&l!==this.width&&(this.resizeFrame=requestAnimationFrame(()=>{this.width=l,this.draw()}))}),this.observer.observe(n))}dispose(){this.disposed=!0,this.player?.dispose(),this.observer?.disconnect(),cancelAnimationFrame(this.resizeFrame),window.clearTimeout(this.timeoutID),this.text_area?.off(".vextab")}scheduleEdit(){window.clearTimeout(this.timeoutID),this.player?.removeControls(),this.composing||(this.timeoutID=window.setTimeout(()=>this.run(),250))}run(){return window.clearTimeout(this.timeoutID),this.disposed||this.composing?this:(this.code=this.text_area?.val()??this.code,this.redraw())}getReadingEvents(){return this.getScore()?this.current.layouts.flatMap(t=>t.navigation.events):[]}getDiagnosticRange(){return!this.disposed&&this.code===(this.text_area?.val()??this.code)?this.diagnostic:void 0}selectError(){let t=this.getDiagnosticRange();return!t||!this.text_area?!1:(this.text_area[0].focus(),this.text_area[0].setSelectionRange(t.start,t.end),!0)}getScoreDocument(){return!this.disposed&&this.document?.source===(this.text_area?.val()??this.code)?this.document:void 0}setInstrumentView(t,e="score"){if(!this.grammar2)throw new Error("Instrument selection requires a v2 score");return this.conductor=t==="conductor",this.partIndex=t==="conductor"?void 0:t.partIndex,this.partId=t==="conductor"?void 0:t.partId,this.part=t==="conductor"?"score":e,this.run()}setPart(t){if(!this.flow)throw new Error('setPart requires layout="flow"');return this.part=t,this.draw()}redraw(){return N.BM("Total render time: ",()=>{this.parse(),this.draw()}),this}reportError(t){this.player?.removeControls(),this.diagnostic=t instanceof ke?{start:t.range[0],end:t.range[1],line:t.line,column:t.column-1}:t.range,this.surface?.setAttribute("data-preview-stale","true");let e=this.surface?"Showing the last valid score. ":"";this.editor_error?.text(e+t.message),(0,ct.default)(this.sel)[0].dispatchEvent(new Event("vextab-render"))}getScore(){if(!this.disposed&&this.current&&this.current.score===this.candidate&&!this.surface?.hasAttribute("data-preview-stale")&&this.current.score.source===(this.text_area?.val()??this.code))return this.current.score}setWidth(t){if(!this.flow)throw new Error('setWidth requires layout="flow"');return this.observer?.disconnect(),cancelAnimationFrame(this.resizeFrame),this.autoWidth=!1,this.width=t,this.draw()}selectSource(t,e){let n=this.getScore(),r=n&&n===e&&this.current.layouts.map(s=>s.rangeFor(t,n.source)).find(Boolean);if(!r||!this.text_area)return!1;let o=this.text_area[0];return o.focus(),o.setSelectionRange(r.start,r.end),!0}drawView(t,e,n){let r=this.rendererBackend.toLowerCase()==="canvas"?"canvas":"svg",o=Math.max(21,this.width/(e.layout?.scale??1)),s=this.autoWidth?e.layout?.width??o:this.width,i="parts"in e?De(t,e,{width:s,renderer:r}):ze(t,e,{width:s,part:this.part,renderer:r}),c=t.querySelector("svg, canvas"),l=me(c);return this.text_area&&c.addEventListener("click",d=>{let h=l(d);if(!h)return;let f=i.hitTest(h.x,h.y);f&&this.selectSource(f.id,n)}),{layout:i,surface:c}}drawFlow(t){if(!this.grammar2&&(this.rendererBackend.toLowerCase()!=="svg"||this.scale!==1))throw new Error("Flow layout requires SVG at scale 1. Use width to reflow.");let e=this.candidate,n=this.document,r=n&&this.part==="score"&&this.partId===void 0&&this.partIndex===void 0&&n.parts.length>1,s=this.conductor&&this.part==="score"?[this.drawView(t,n,e)]:r?n.parts.map((i,c)=>{let l=t.appendChild(document.createElement("div"));return this.drawView(l,yt(n,c),e)}):[this.drawView(t,e,e)];this.grammar2&&this.scale!==1&&(t.style.zoom=String(this.scale)),this.player?.dispose(),this.player=void 0,(this.enablePlayer??e.playback?.enabled)&&(this.player=new Tt(r?n:s[0].layout.score,{playback:this.playback,controls:this.playbackControls,performer:this.performer,seed:this.seed,order:this.order})).render(s[0].surface,void 0,s.slice(1).map(c=>c.surface)),this.current={score:e,layouts:s.map(i=>i.layout)}}drawInternal(){if(this.flow?!this.candidate:!this.parser.isValid())return this;let t=this.rendererBackend.toLowerCase()==="canvas",e=document.createElement(t&&!this.flow?"canvas":"div");e.className="vex-canvas";let n=(0,ct.default)(this.sel)[0];n.insertBefore(e,n.firstChild);try{if(this.flow)this.drawFlow(e);else{let o=t?N.Flow.Renderer.Backends.CANVAS:N.Flow.Renderer.Backends.SVG,s=new N.Flow.Renderer(e,o);if(t||Kt(s.getContext(),e),this.enablePlayer!==void 0&&(this.artist.customizations.player=String(this.enablePlayer)),!this.player&&this.artist.customizations.player==="true"&&(this.player=new Tt(this.artist,{playback:this.playback,controls:this.playbackControls,performer:this.performer,seed:this.seed})),this.artist.draw(s),t){let i=this.artist.staves.map((c,l)=>{let h=(c.tab?c.tab_voices:c.note_voices).map((f,m)=>"Voice "+(m+1)+". "+f.filter(g=>!g.shouldIgnoreTicks()).map(g=>{let y=g.getPositions?.(),b=c.note?.getClef()==="percussion"?g.notation?.filter(C=>C.kind==="unpitched").map(C=>C.label):void 0,k=b?.length?b:y?.map(C=>"string "+C.str+" fret "+C.fret);return(g.isRest()?"rest":(k??g.getKeys()).join(", "))+" ("+g.getDuration()+")"}).join(". "));return"Stave "+(l+1)+", meter "+c.meter+". "+h.join(". ")}).join(". ");e.setAttribute("role","img"),e.setAttribute("aria-label",i),e.textContent=i}}this.surface?.remove(),this.surface=e;let r=this.flow?this.current.layouts.flatMap(o=>o.diagnostics):[];this.diagnostic=r[0]?.range,this.editor_error?.text(r.map(o=>{let s=o.range?" (line "+o.range.line+", column "+o.range.column+")":"";return(o.code==="RowOverflow"?"Bar "+o.measures.join(", ")+" exceeds this width":o.code)+s}).join(`
|
|
352
|
+
`)),n.dispatchEvent(new Event("vextab-render"))}catch(r){e.remove(),this.reportError(r)}return this}parseInternal(){try{this.flow?(this.candidate=void 0,this.document=this.grammar2?Lt(this.code,{capacity:this.capacity}):void 0,this.candidate=this.document?yt(this.document,wt(this.document,{partId:this.partId,partIndex:this.partIndex})):Lt(this.code,{language:1})):(this.artist.reset(),this.parser.parse(this.code))}catch(t){this.reportError(t)}return this}parse(){return N.BM("Parse time: ",()=>{this.parseInternal()}),this}draw(){return N.BM("Draw time: ",()=>{this.drawInternal()}),this}},bo=Ge;function yo(a,t){let e={time:0,semitones:0};for(let n of a){if(t<n.time)return e.semitones+(n.semitones-e.semitones)*(t-e.time)/(n.time-e.time);e=n}return e.semitones}function vo(a,t=[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15]){let e=[...new Set(t)];if(!e.length||e.some(o=>!Number.isInteger(o)||o<0||o>15))throw new RangeError("Supply MIDI channels from 0 to 15");let n=new Set;async function r(o,s){let i=a.context,c="resume"in i?i.resume():Promise.resolve();await Promise.all([c,a.isReady]),s.throwIfAborted();let l=new Set,d=new Set,h;function f(g){a.noteOff(g.channel,g.note.pitch),g.range&&a.pitchWheel(g.channel,8192),l.delete(g)}function m(){window.clearTimeout(h);let g=1/0;for(let y of l){let b=i.currentTime-y.start;if(b>=y.note.duration){f(y);continue}if(y.range){let k=yo(y.note.bend,b)/y.range;a.pitchWheel(y.channel,Math.max(0,Math.min(16383,Math.round(8192+k*8192)))),g=Math.min(g,.012)}g=Math.min(g,y.note.duration-b)}l.size&&(h=window.setTimeout(m,Math.max(1,g*1e3)))}return{get currentTime(){return i.currentTime},playNote(g){m();let y=Math.ceil(Math.max(0,...(g.bend??[]).map(k=>Math.abs(k.semitones)))),b=e.find(k=>(!n.has(k)||d.has(k))&&![...l].some(_=>_.channel===k&&(y||_.range||_.note.pitch===g.pitch)));if(b===void 0)throw new Error("Insufficient reserved SpessaSynth channels for this chord");d.has(b)||(a.programChange(b,o),d.add(b),n.add(b)),y&&a.pitchWheelRange(b,y),a.noteOn(b,g.pitch,g.velocity),l.add({channel:b,note:g,start:i.currentTime,range:y}),m()},stop(){window.clearTimeout(h);for(let g of l)f(g);for(let g of d)n.delete(g);d.clear()}}}return{open:r}}export{Tn as a,N as b,Rt as c,Ct as d,Xt as e,Tt as f,ze as g,De as h,po as i,ho as j,bo as k,vo as l};
|