function t(t,e){const i=Object.create(null),n=t.split(",");for(let t=0;t!!i[t.toLowerCase()]:t=>!!i[t]}const e=t("Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt"),i=t("itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly");function n(t){if(S(t)){const e={};for(let i=0;i{if(t){const i=t.split(r);i.length>1&&(e[i[0].trim()]=i[1].trim())}})),e}function a(t){let e="";if(E(t))e=t;else if(S(t))for(let i=0;i{},u=()=>!1,d=/^on[^a-z]/,f=t=>d.test(t),p=t=>t.startsWith("onUpdate:"),m=Object.assign,b=(t,e)=>{const i=t.indexOf(e);i>-1&&t.splice(i,1)},g=Object.prototype.hasOwnProperty,y=(t,e)=>g.call(t,e),S=Array.isArray,v=t=>"[object Map]"===P(t),x=t=>"function"==typeof t,E=t=>"string"==typeof t,_=t=>"symbol"==typeof t,w=t=>null!==t&&"object"==typeof t,T=t=>w(t)&&x(t.then)&&x(t.catch),M=Object.prototype.toString,P=t=>M.call(t),L=t=>E(t)&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,A=t(",key,ref,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),C=t=>{const e=Object.create(null);return i=>e[i]||(e[i]=t(i))},I=/-(\w)/g,R=C((t=>t.replace(I,((t,e)=>e?e.toUpperCase():"")))),N=/\B([A-Z])/g,F=C((t=>t.replace(N,"-$1").toLowerCase())),B=C((t=>t.charAt(0).toUpperCase()+t.slice(1))),O=C((t=>t?`on${B(t)}`:"")),D=(t,e)=>t!==e&&(t==t||e==e),k=(t,e)=>{for(let i=0;i{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:i})},G=t=>{const e=parseFloat(t);return isNaN(e)?t:e},W=new WeakMap,U=[];let z;const j=Symbol(""),H=Symbol("");function X(t,e=l){(function(t){return t&&!0===t._isEffect})(t)&&(t=t.raw);const i=function(t,e){const i=function(){if(!i.active)return e.scheduler?void 0:t();if(!U.includes(i)){q(i);try{return J.push($),$=!0,U.push(i),z=i,t()}finally{U.pop(),Q(),z=U[U.length-1]}}};return i.id=K++,i.allowRecurse=!!e.allowRecurse,i._isEffect=!0,i.active=!0,i.raw=t,i.deps=[],i.options=e,i}(t,e);return e.lazy||i(),i}function Y(t){t.active&&(q(t),t.options.onStop&&t.options.onStop(),t.active=!1)}let K=0;function q(t){const{deps:e}=t;if(e.length){for(let i=0;i{t&&t.forEach((t=>{(t!==z||t.allowRecurse)&&a.add(t)}))};if("clear"===e)o.forEach(l);else if("length"===i&&S(t))o.forEach(((t,e)=>{("length"===e||e>=n)&&l(t)}));else switch(void 0!==i&&l(o.get(i)),e){case"add":S(t)?L(i)&&l(o.get("length")):(l(o.get(j)),v(t)&&l(o.get(H)));break;case"delete":S(t)||(l(o.get(j)),v(t)&&l(o.get(H)));break;case"set":v(t)&&l(o.get(j))}a.forEach((t=>{t.options.scheduler?t.options.scheduler(t):t()}))}const it=t("__proto__,__v_isRef,__isVue"),nt=new Set(Object.getOwnPropertyNames(Symbol).map((t=>Symbol[t])).filter(_)),st=ht(),rt=ht(!1,!0),ot=ht(!0),at=ht(!0,!0),lt={};function ht(t=!1,e=!1){return function(i,n,s){if("__v_isReactive"===n)return!t;if("__v_isReadonly"===n)return t;if("__v_raw"===n&&s===(t?Ot:Bt).get(i))return i;const r=S(i);if(!t&&r&&y(lt,n))return Reflect.get(lt,n,s);const o=Reflect.get(i,n,s);if(_(n)?nt.has(n):it(n))return o;if(t||tt(i,0,n),e)return o;if(Xt(o)){return!r||!L(n)?o.value:o}return w(o)?t?Vt(o):kt(o):o}}["includes","indexOf","lastIndexOf"].forEach((t=>{const e=Array.prototype[t];lt[t]=function(...t){const i=jt(this);for(let t=0,e=this.length;t{const e=Array.prototype[t];lt[t]=function(...t){Z();const i=e.apply(this,t);return Q(),i}}));function ct(t=!1){return function(e,i,n,s){const r=e[i];if(!t&&(n=jt(n),!S(e)&&Xt(r)&&!Xt(n)))return r.value=n,!0;const o=S(e)&&L(i)?Number(i)!0,deleteProperty:(t,e)=>!0},ft=m({},ut,{get:rt,set:ct(!0)});m({},dt,{get:at});const pt=t=>w(t)?kt(t):t,mt=t=>w(t)?Vt(t):t,bt=t=>t,gt=t=>Reflect.getPrototypeOf(t);function yt(t,e,i=!1,n=!1){const s=jt(t=t.__v_raw),r=jt(e);e!==r&&!i&&tt(s,0,e),!i&&tt(s,0,r);const{has:o}=gt(s),a=i?mt:n?bt:pt;return o.call(s,e)?a(t.get(e)):o.call(s,r)?a(t.get(r)):void 0}function St(t,e=!1){const i=this.__v_raw,n=jt(i),s=jt(t);return t!==s&&!e&&tt(n,0,t),!e&&tt(n,0,s),t===s?i.has(t):i.has(t)||i.has(s)}function vt(t,e=!1){return t=t.__v_raw,!e&&tt(jt(t),0,j),Reflect.get(t,"size",t)}function xt(t){t=jt(t);const e=jt(this),i=gt(e).has.call(e,t);return e.add(t),i||et(e,"add",t,t),this}function Et(t,e){e=jt(e);const i=jt(this),{has:n,get:s}=gt(i);let r=n.call(i,t);r||(t=jt(t),r=n.call(i,t));const o=s.call(i,t);return i.set(t,e),r?D(e,o)&&et(i,"set",t,e):et(i,"add",t,e),this}function _t(t){const e=jt(this),{has:i,get:n}=gt(e);let s=i.call(e,t);s||(t=jt(t),s=i.call(e,t)),n&&n.call(e,t);const r=e.delete(t);return s&&et(e,"delete",t,void 0),r}function wt(){const t=jt(this),e=0!==t.size,i=t.clear();return e&&et(t,"clear",void 0,void 0),i}function Tt(t,e){return function(i,n){const s=this,r=s.__v_raw,o=jt(r),a=t?mt:e?bt:pt;return!t&&tt(o,0,j),r.forEach(((t,e)=>i.call(n,a(t),a(e),s)))}}function Mt(t,e,i){return function(...n){const s=this.__v_raw,r=jt(s),o=v(r),a="entries"===t||t===Symbol.iterator&&o,l="keys"===t&&o,h=s[t](...n),c=e?mt:i?bt:pt;return!e&&tt(r,0,l?H:j),{next(){const{value:t,done:e}=h.next();return e?{value:t,done:e}:{value:a?[c(t[0]),c(t[1])]:c(t),done:e}},[Symbol.iterator](){return this}}}}function Pt(t){return function(...e){return"delete"!==t&&this}}const Lt={get(t){return yt(this,t)},get size(){return vt(this)},has:St,add:xt,set:Et,delete:_t,clear:wt,forEach:Tt(!1,!1)},At={get(t){return yt(this,t,!1,!0)},get size(){return vt(this)},has:St,add:xt,set:Et,delete:_t,clear:wt,forEach:Tt(!1,!0)},Ct={get(t){return yt(this,t,!0)},get size(){return vt(this,!0)},has(t){return St.call(this,t,!0)},add:Pt("add"),set:Pt("set"),delete:Pt("delete"),clear:Pt("clear"),forEach:Tt(!0,!1)};function It(t,e){const i=e?At:t?Ct:Lt;return(e,n,s)=>"__v_isReactive"===n?!t:"__v_isReadonly"===n?t:"__v_raw"===n?e:Reflect.get(y(i,n)&&n in e?i:e,n,s)}["keys","values","entries",Symbol.iterator].forEach((t=>{Lt[t]=Mt(t,!1,!1),Ct[t]=Mt(t,!0,!1),At[t]=Mt(t,!1,!0)}));const Rt={get:It(!1,!1)},Nt={get:It(!1,!0)},Ft={get:It(!0,!1)},Bt=new WeakMap,Ot=new WeakMap;function Dt(t){return t.__v_skip||!Object.isExtensible(t)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}((t=>P(t).slice(8,-1))(t))}function kt(t){return t&&t.__v_isReadonly?t:Gt(t,!1,ut,Rt)}function Vt(t){return Gt(t,!0,dt,Ft)}function Gt(t,e,i,n){if(!w(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const s=e?Ot:Bt,r=s.get(t);if(r)return r;const o=Dt(t);if(0===o)return t;const a=new Proxy(t,2===o?n:i);return s.set(t,a),a}function Wt(t){return Ut(t)?Wt(t.__v_raw):!(!t||!t.__v_isReactive)}function Ut(t){return!(!t||!t.__v_isReadonly)}function zt(t){return Wt(t)||Ut(t)}function jt(t){return t&&jt(t.__v_raw)||t}const Ht=t=>w(t)?kt(t):t;function Xt(t){return Boolean(t&&!0===t.__v_isRef)}function Yt(t){return function(t,e=!1){if(Xt(t))return t;return new Kt(t,e)}(t)}class Kt{constructor(t,e=!1){this._rawValue=t,this._shallow=e,this.__v_isRef=!0,this._value=e?t:Ht(t)}get value(){return tt(jt(this),0,"value"),this._value}set value(t){D(jt(t),this._rawValue)&&(this._rawValue=t,this._value=this._shallow?t:Ht(t),et(jt(this),"set","value",t))}}function qt(t){return Xt(t)?t.value:t}const $t={get:(t,e,i)=>qt(Reflect.get(t,e,i)),set:(t,e,i,n)=>{const s=t[e];return Xt(s)&&!Xt(i)?(s.value=i,!0):Reflect.set(t,e,i,n)}};function Jt(t){return Wt(t)?t:new Proxy(t,$t)}class Zt{constructor(t,e){this._object=t,this._key=e,this.__v_isRef=!0}get value(){return this._object[this._key]}set value(t){this._object[this._key]=t}}class Qt{constructor(t,e,i){this._setter=e,this._dirty=!0,this.__v_isRef=!0,this.effect=X(t,{lazy:!0,scheduler:()=>{this._dirty||(this._dirty=!0,et(jt(this),"set","value"))}}),this.__v_isReadonly=i}get value(){return this._dirty&&(this._value=this.effect(),this._dirty=!1),tt(jt(this),0,"value"),this._value}set value(t){this._setter(t)}}function te(t,e,i,n){let s;try{s=n?t(...n):t()}catch(t){ie(t,e,i)}return s}function ee(t,e,i,n){if(x(t)){const s=te(t,e,i,n);return s&&T(s)&&s.catch((t=>{ie(t,e,i)})),s}const s=[];for(let r=0;rEe(t)-Ee(e))),de=0;denull==t.id?1/0:t.id;function _e(t){se=!1,ne=!0,ve(t),re.sort(((t,e)=>Ee(t)-Ee(e)));try{for(oe=0;oet.trim())):e&&(s=i.map(G))}let a=O(R(e)),h=n[a];!h&&r&&(a=O(F(e)),h=n[a]),h&&ee(h,t,6,s);const c=n[a+"Once"];if(c){if(t.emitted){if(t.emitted[a])return}else(t.emitted={})[a]=!0;ee(c,t,6,s)}}function Te(t,e,i=!1){if(!e.deopt&&void 0!==t.__emits)return t.__emits;const n=t.emits;let s={},r=!1;if(!x(t)){const n=t=>{r=!0,m(s,Te(t,e,!0))};!i&&e.mixins.length&&e.mixins.forEach(n),t.extends&&n(t.extends),t.mixins&&t.mixins.forEach(n)}return n||r?(S(n)?n.forEach((t=>s[t]=null)):m(s,n),t.__emits=s):t.__emits=null}function Me(t,e){return!(!t||!f(e))&&(e=e.slice(2).replace(/Once$/,""),y(t,e[0].toLowerCase()+e.slice(1))||y(t,F(e))||y(t,e))}let Pe=null;function Le(t){Pe=t}function Ae(t){const{type:e,vnode:i,proxy:n,withProxy:s,props:r,propsOptions:[o],slots:a,attrs:l,emit:h,render:c,renderCache:u,data:d,setupState:f,ctx:m}=t;let b;Pe=t;try{let t;if(4&i.shapeFlag){const e=s||n;b=Ui(c.call(e,e,u,r,f,d,m)),t=l}else{const i=e;0,b=Ui(i.length>1?i(r,{attrs:l,slots:a,emit:h}):i(r,null)),t=e.props?l:Ie(l)}let g=b;if(!1!==e.inheritAttrs&&t){const e=Object.keys(t),{shapeFlag:i}=g;e.length&&(1&i||6&i)&&(o&&e.some(p)&&(t=Re(t,o)),g=Gi(g,t))}i.dirs&&(g.dirs=g.dirs?g.dirs.concat(i.dirs):i.dirs),i.transition&&(g.transition=i.transition),b=g}catch(e){ie(e,t,1),b=Vi(Ci)}return Pe=null,b}function Ce(t){let e;for(let i=0;i{let e;for(const i in t)("class"===i||"style"===i||f(i))&&((e||(e={}))[i]=t[i]);return e},Re=(t,e)=>{const i={};for(const n in t)p(n)&&n.slice(9)in e||(i[n]=t[n]);return i};function Ne(t,e,i){const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!0;for(let s=0;sBe+=t;function De(t,e=Pe){if(!e)return t;const i=(...i)=>{Be||function(t=!1){Ri.push(Ni=t?null:[])}(!0);const n=Pe;Le(e);const s=t(...i);return Le(n),Be||(Ri.pop(),Ni=Ri[Ri.length-1]||null),s};return i._c=!0,i}function ke(t,e,i,n=!1){const s={},r={};V(r,Oi,1),Ve(t,e,s,r),i?t.props=n?s:Gt(s,!1,ft,Nt):t.type.props?t.props=s:t.props=r,t.attrs=r}function Ve(t,e,i,n){const[s,r]=t.propsOptions;if(e)for(const r in e){const o=e[r];if(A(r))continue;let a;s&&y(s,a=R(r))?i[a]=o:Me(t.emitsOptions,r)||(n[r]=o)}if(r){const e=jt(i);for(let n=0;n{o=!0;const[i,n]=We(t,e,!0);m(s,i),n&&r.push(...n)};!i&&e.mixins.length&&e.mixins.forEach(n),t.extends&&n(t.extends),t.mixins&&t.mixins.forEach(n)}if(!n&&!o)return t.__props=h;if(S(n))for(let t=0;t-1,o[1]=i<0||t-1||y(o,"default"))&&r.push(e)}}}return t.__props=[s,r]}function Ue(t){return"$"!==t[0]}function ze(t){const e=t&&t.toString().match(/^\s*function (\w+)/);return e?e[1]:""}function je(t,e){return ze(t)===ze(e)}function He(t,e){if(S(e)){for(let i=0,n=e.length;i{if(i.isUnmounted)return;Z(),hn(i);const s=ee(e,i,t,n);return hn(null),Q(),s});return n?s.unshift(r):s.push(r),r}}const Ye=t=>(e,i=ln)=>!un&&Xe(t,e,i),Ke=Ye("bm"),qe=Ye("m"),$e=Ye("bu"),Je=Ye("u"),Ze=Ye("bum"),Qe=Ye("um"),ti=Ye("rtg"),ei=Ye("rtc"),ii={};function ni(t,e,i){return si(t,e,i)}function si(t,e,{immediate:i,deep:n,flush:s,onTrack:r,onTrigger:o}=l,a=ln){let h,u,d=!1;if(Xt(t)?(h=()=>t.value,d=!!t._shallow):Wt(t)?(h=()=>t,n=!0):h=S(t)?()=>t.map((t=>Xt(t)?t.value:Wt(t)?oi(t):x(t)?te(t,a,2,[a&&a.proxy]):void 0)):x(t)?e?()=>te(t,a,2,[a&&a.proxy]):()=>{if(!a||!a.isUnmounted)return u&&u(),te(t,a,3,[f])}:c,e&&n){const t=h;h=()=>oi(t())}const f=t=>{u=y.options.onStop=()=>{te(t,a,4)}};let p=S(t)?[]:ii;const m=()=>{if(y.active)if(e){const t=y();(n||d||D(t,p))&&(u&&u(),ee(e,a,3,[t,p===ii?void 0:p,f]),p=t)}else y()};let g;m.allowRecurse=!!e,g="sync"===s?m:"post"===s?()=>xi(m,a&&a.suspense):()=>{!a||a.isMounted?function(t){Se(t,le,ae,he)}(m):m()};const y=X(h,{lazy:!0,onTrack:r,onTrigger:o,scheduler:g});return pn(y,a),e?i?m():p=y():"post"===s?xi(y,a&&a.suspense):y(),()=>{Y(y),a&&b(a.effects,y)}}function ri(t,e,i){const n=this.proxy;return si(E(t)?()=>n[t]:t.bind(n),e.bind(n),i,this)}function oi(t,e=new Set){if(!w(t)||e.has(t))return t;if(e.add(t),Xt(t))oi(t.value,e);else if(S(t))for(let i=0;i{oi(t,e)}));else for(const i in t)oi(t[i],e);return t}const ai=t=>t.type.__isKeepAlive;function li(t,e,i=ln){const n=t.__wdc||(t.__wdc=()=>{let e=i;for(;e;){if(e.isDeactivated)return;e=e.parent}t()});if(Xe(e,n,i),i){let t=i.parent;for(;t&&t.parent;)ai(t.parent.vnode)&&hi(n,e,i,t),t=t.parent}}function hi(t,e,i,n){const s=Xe(e,t,n,!0);Qe((()=>{b(n[e],s)}),i)}const ci=t=>"_"===t[0]||"$stable"===t,ui=t=>S(t)?t.map(Ui):[Ui(t)],di=(t,e,i)=>De((t=>ui(e(t))),i),fi=(t,e)=>{const i=t._ctx;for(const n in t){if(ci(n))continue;const s=t[n];if(x(s))e[n]=di(0,s,i);else if(null!=s){const t=ui(s);e[n]=()=>t}}},pi=(t,e)=>{const i=ui(e);t.slots.default=()=>i};function mi(t,e,i,n){const s=t.dirs,r=e&&e.dirs;for(let o=0;o(r.has(t)||(t&&x(t.install)?(r.add(t),t.install(a,...e)):x(t)&&(r.add(t),t(a,...e))),a),mixin:t=>(s.mixins.includes(t)||(s.mixins.push(t),(t.props||t.emits)&&(s.deopt=!0)),a),component:(t,e)=>e?(s.components[t]=e,a):s.components[t],directive:(t,e)=>e?(s.directives[t]=e,a):s.directives[t],mount(r,l){if(!o){const h=Vi(i,n);return h.appContext=s,l&&e?e(h,r):t(h,r),o=!0,a._container=r,r.__vue_app__=a,h.component.proxy}},unmount(){o&&(t(null,a._container),delete a._container.__vue_app__)},provide:(t,e)=>(s.provides[t]=e,a)};return a}}function Si(t){return x(t)?{setup:t,name:t.name}:t}const vi={scheduler:ge,allowRecurse:!0},xi=function(t,e){e&&e.pendingBranch?S(t)?e.effects.push(...t):e.effects.push(t):Se(t,ue,ce,de)},Ei=(t,e,i,n)=>{if(S(t))return void t.forEach(((t,s)=>Ei(t,e&&(S(e)?e[s]:e),i,n)));let s;s=!n||n.type.__asyncLoader?null:4&n.shapeFlag?n.component.exposed||n.component.proxy:n.el;const{i:r,r:o}=t,a=e&&e.r,h=r.refs===l?r.refs={}:r.refs,c=r.setupState;if(null!=a&&a!==o&&(E(a)?(h[a]=null,y(c,a)&&(c[a]=null)):Xt(a)&&(a.value=null)),E(o)){const t=()=>{h[o]=s,y(c,o)&&(c[o]=s)};s?(t.id=-1,xi(t,i)):t()}else if(Xt(o)){const t=()=>{o.value=s};s?(t.id=-1,xi(t,i)):t()}else x(o)&&te(o,r,12,[s,h])};function _i(t){return function(t,e){const{insert:i,remove:n,patchProp:s,forcePatchProp:r,createElement:o,createText:a,createComment:u,setText:d,setElementText:f,parentNode:p,nextSibling:b,setScopeId:g=c,cloneNode:S,insertStaticContent:v}=t,x=(t,e,i,n=null,s=null,r=null,o=!1,a=!1)=>{t&&!Bi(t,e)&&(n=ot(t),tt(t,s,r,!0),t=null),-2===e.patchFlag&&(a=!1,e.dynamicChildren=null);const{type:l,ref:h,shapeFlag:c}=e;switch(l){case Ai:E(t,e,i,n);break;case Ci:_(t,e,i,n);break;case Ii:null==t&&w(e,i,n,o);break;case Li:G(t,e,i,n,s,r,o,a);break;default:1&c?L(t,e,i,n,s,r,o,a):6&c?W(t,e,i,n,s,r,o,a):(64&c||128&c)&&l.process(t,e,i,n,s,r,o,a,lt)}null!=h&&s&&Ei(h,t&&t.ref,r,e)},E=(t,e,n,s)=>{if(null==t)i(e.el=a(e.children),n,s);else{const i=e.el=t.el;e.children!==t.children&&d(i,e.children)}},_=(t,e,n,s)=>{null==t?i(e.el=u(e.children||""),n,s):e.el=t.el},w=(t,e,i,n)=>{[t.el,t.anchor]=v(t.children,e,i,n)},M=({el:t,anchor:e},n,s)=>{let r;for(;t&&t!==e;)r=b(t),i(t,n,s),t=r;i(e,n,s)},P=({el:t,anchor:e})=>{let i;for(;t&&t!==e;)i=b(t),n(t),t=i;n(e)},L=(t,e,i,n,s,r,o,a)=>{o=o||"svg"===e.type,null==t?C(e,i,n,s,r,o,a):B(t,e,s,r,o,a)},C=(t,e,n,r,a,l,h)=>{let c,u;const{type:d,props:p,shapeFlag:m,transition:b,scopeId:g,patchFlag:y,dirs:v}=t;if(t.el&&void 0!==S&&-1===y)c=t.el=S(t.el);else{if(c=t.el=o(t.type,l,p&&p.is),8&m?f(c,t.children):16&m&&N(t.children,c,null,r,a,l&&"foreignObject"!==d,h||!!t.dynamicChildren),v&&mi(t,null,r,"created"),p){for(const e in p)A(e)||s(c,e,null,p[e],l,t.children,r,a,rt);(u=p.onVnodeBeforeMount)&&wi(u,r,t)}I(c,g,t,r)}v&&mi(t,null,r,"beforeMount");const x=(!a||a&&!a.pendingBranch)&&b&&!b.persisted;x&&b.beforeEnter(c),i(c,e,n),((u=p&&p.onVnodeMounted)||x||v)&&xi((()=>{u&&wi(u,r,t),x&&b.enter(c),v&&mi(t,null,r,"mounted")}),a)},I=(t,e,i,n)=>{if(e&&g(t,e),n){const s=n.type.__scopeId;s&&s!==e&&g(t,s+"-s"),i===n.subTree&&I(t,n.vnode.scopeId,n.vnode,n.parent)}},N=(t,e,i,n,s,r,o,a=0)=>{for(let l=a;l{const h=e.el=t.el;let{patchFlag:c,dynamicChildren:u,dirs:d}=e;c|=16&t.patchFlag;const p=t.props||l,m=e.props||l;let b;if((b=m.onVnodeBeforeUpdate)&&wi(b,i,e,t),d&&mi(e,t,i,"beforeUpdate"),c>0){if(16&c)D(h,e,p,m,i,n,o);else if(2&c&&p.class!==m.class&&s(h,"class",null,m.class,o),4&c&&s(h,"style",p.style,m.style,o),8&c){const a=e.dynamicProps;for(let e=0;e{b&&wi(b,i,e,t),d&&mi(e,t,i,"updated")}),n)},O=(t,e,i,n,s,r)=>{for(let o=0;o{if(i!==n){for(const l in n){if(A(l))continue;const c=n[l],u=i[l];(c!==u||r&&r(t,l))&&s(t,l,u,c,h,e.children,o,a,rt)}if(i!==l)for(const r in i)A(r)||r in n||s(t,r,i[r],null,h,e.children,o,a,rt)}},G=(t,e,n,s,r,o,l,h)=>{const c=e.el=t?t.el:a(""),u=e.anchor=t?t.anchor:a("");let{patchFlag:d,dynamicChildren:f}=e;d>0&&(h=!0),null==t?(i(c,n,s),i(u,n,s),N(e.children,n,u,r,o,l,h)):d>0&&64&d&&f&&t.dynamicChildren?(O(t.dynamicChildren,f,n,r,o,l),(null!=e.key||r&&e===r.subTree)&&Ti(t,e,!0)):K(t,e,n,u,r,o,l,h)},W=(t,e,i,n,s,r,o,a)=>{null==t?512&e.shapeFlag?s.ctx.activate(e,i,n,o,a):U(e,i,n,s,r,o,a):z(t,e,a)},U=(t,e,i,n,s,r,o)=>{const a=t.component=function(t,e,i){const n=t.type,s=(e?e.appContext:t.appContext)||on,r={uid:an++,vnode:t,type:n,parent:e,appContext:s,root:null,next:null,subTree:null,update:null,render:null,proxy:null,exposed:null,withProxy:null,effects:null,provides:e?e.provides:Object.create(s.provides),accessCache:null,renderCache:[],components:null,directives:null,propsOptions:We(n,s),emitsOptions:Te(n,s),emit:null,emitted:null,ctx:l,data:l,props:l,attrs:l,slots:l,refs:l,setupState:l,setupContext:null,suspense:i,suspenseId:i?i.pendingId:0,asyncDep:null,asyncResolved:!1,isMounted:!1,isUnmounted:!1,isDeactivated:!1,bc:null,c:null,bm:null,m:null,bu:null,u:null,um:null,bum:null,da:null,a:null,rtg:null,rtc:null,ec:null};return r.ctx={_:r},r.root=e?e.root:r,r.emit=we.bind(null,r),r}(t,n,s);if(ai(t)&&(a.ctx.renderer=lt),function(t,e=!1){un=e;const{props:i,children:n}=t.vnode,s=cn(t);ke(t,i,s,e),((t,e)=>{if(32&t.vnode.shapeFlag){const i=e._;i?(t.slots=e,V(e,"_",i)):fi(e,t.slots={})}else t.slots={},e&&pi(t,e);V(t.slots,Oi,1)})(t,n);const r=s?function(t,e){const i=t.type;t.accessCache=Object.create(null),t.proxy=new Proxy(t.ctx,sn);const{setup:n}=i;if(n){const i=t.setupContext=n.length>1?function(t){const e=e=>{t.exposed=Jt(e)};return{attrs:t.attrs,slots:t.slots,emit:t.emit,expose:e}}(t):null;ln=t,Z();const s=te(n,t,0,[t.props,i]);if(Q(),ln=null,T(s)){if(e)return s.then((e=>{dn(t,e)}));t.asyncDep=s}else dn(t,s)}else fn(t)}(t,e):void 0;un=!1}(a),a.asyncDep){if(s&&s.registerDep(a,j),!t.el){const t=a.subTree=Vi(Ci);_(null,t,e,i)}}else j(a,t,e,i,s,r,o)},z=(t,e,i)=>{const n=e.component=t.component;if(function(t,e,i){const{props:n,children:s,component:r}=t,{props:o,children:a,patchFlag:l}=e,h=r.emitsOptions;if(e.dirs||e.transition)return!0;if(!(i&&l>=0))return!(!s&&!a||a&&a.$stable)||n!==o&&(n?!o||Ne(n,o,h):!!o);if(1024&l)return!0;if(16&l)return n?Ne(n,o,h):!!o;if(8&l){const t=e.dynamicProps;for(let e=0;e-1&&re.splice(e,1)}(n.update),n.update()}else e.component=t.component,e.el=t.el,n.vnode=e},j=(t,e,i,n,s,r,o)=>{t.update=X((function(){if(t.isMounted){let e,{next:i,bu:n,u:a,parent:l,vnode:h}=t,c=i;i?(i.el=h.el,H(t,i,o)):i=h,n&&k(n),(e=i.props&&i.props.onVnodeBeforeUpdate)&&wi(e,l,i,h);const u=Ae(t),d=t.subTree;t.subTree=u,x(d,u,p(d.el),ot(d),t,s,r),i.el=u.el,null===c&&function({vnode:t,parent:e},i){for(;e&&e.subTree===t;)(t=e.vnode).el=i,e=e.parent}(t,u.el),a&&xi(a,s),(e=i.props&&i.props.onVnodeUpdated)&&xi((()=>{wi(e,l,i,h)}),s)}else{let o;const{el:a,props:l}=e,{bm:h,m:c,parent:u}=t;h&&k(h),(o=l&&l.onVnodeBeforeMount)&&wi(o,u,e);const d=t.subTree=Ae(t);if(a&&ct?ct(e.el,d,t,s):(x(null,d,i,n,t,s,r),e.el=d.el),c&&xi(c,s),o=l&&l.onVnodeMounted){const t=e;xi((()=>{wi(o,u,t)}),s)}const{a:f}=t;f&&256&e.shapeFlag&&xi(f,s),t.isMounted=!0,e=i=n=null}}),vi)},H=(t,e,i)=>{e.component=t;const n=t.vnode.props;t.vnode=e,t.next=null,function(t,e,i,n){const{props:s,attrs:r,vnode:{patchFlag:o}}=t,a=jt(s),[h]=t.propsOptions;if(!(n||o>0)||16&o){let n;Ve(t,e,s,r);for(const r in a)e&&(y(e,r)||(n=F(r))!==r&&y(e,n))||(h?!i||void 0===i[r]&&void 0===i[n]||(s[r]=Ge(h,e||l,r,void 0,t)):delete s[r]);if(r!==a)for(const t in r)e&&y(e,t)||delete r[t]}else if(8&o){const i=t.vnode.dynamicProps;for(let n=0;n{const{vnode:i,slots:n}=t;let s=!0,r=l;if(32&i.shapeFlag){const t=e._;t?1===t?s=!1:m(n,e):(s=!e.$stable,fi(e,n)),r=e}else e&&(pi(t,e),r={default:1});if(s)for(const t in n)ci(t)||t in r||delete n[t]})(t,e.children),ve(void 0,t.update)},K=(t,e,i,n,s,r,o,a=!1)=>{const l=t&&t.children,h=t?t.shapeFlag:0,c=e.children,{patchFlag:u,shapeFlag:d}=e;if(u>0){if(128&u)return void $(l,c,i,n,s,r,o,a);if(256&u)return void q(l,c,i,n,s,r,o,a)}8&d?(16&h&&rt(l,s,r),c!==l&&f(i,c)):16&h?16&d?$(l,c,i,n,s,r,o,a):rt(l,s,r,!0):(8&h&&f(i,""),16&d&&N(c,i,n,s,r,o,a))},q=(t,e,i,n,s,r,o,a)=>{e=e||h;const l=(t=t||h).length,c=e.length,u=Math.min(l,c);let d;for(d=0;dc?rt(t,s,r,!0,!1,u):N(e,i,n,s,r,o,a,u)},$=(t,e,i,n,s,r,o,a)=>{let l=0;const c=e.length;let u=t.length-1,d=c-1;for(;l<=u&&l<=d;){const n=t[l],h=e[l]=a?zi(e[l]):Ui(e[l]);if(!Bi(n,h))break;x(n,h,i,null,s,r,o,a),l++}for(;l<=u&&l<=d;){const n=t[u],l=e[d]=a?zi(e[d]):Ui(e[d]);if(!Bi(n,l))break;x(n,l,i,null,s,r,o,a),u--,d--}if(l>u){if(l<=d){const t=d+1,h=td)for(;l<=u;)tt(t[l],s,r,!0),l++;else{const f=l,p=l,m=new Map;for(l=p;l<=d;l++){const t=e[l]=a?zi(e[l]):Ui(e[l]);null!=t.key&&m.set(t.key,l)}let b,g=0;const y=d-p+1;let S=!1,v=0;const E=new Array(y);for(l=0;l=y){tt(n,s,r,!0);continue}let h;if(null!=n.key)h=m.get(n.key);else for(b=p;b<=d;b++)if(0===E[b-p]&&Bi(n,e[b])){h=b;break}void 0===h?tt(n,s,r,!0):(E[h-p]=l+1,h>=v?v=h:S=!0,x(n,e[h],i,null,s,r,o,a),g++)}const _=S?function(t){const e=t.slice(),i=[0];let n,s,r,o,a;const l=t.length;for(n=0;n0&&(e[n]=i[r-1]),i[r]=n)}}r=i.length,o=i[r-1];for(;r-- >0;)i[r]=o,o=e[o];return i}(E):h;for(b=_.length-1,l=y-1;l>=0;l--){const t=p+l,a=e[t],h=t+1{const{el:o,type:a,transition:l,children:h,shapeFlag:c}=t;if(6&c)return void J(t.component.subTree,e,n,s);if(128&c)return void t.suspense.move(e,n,s);if(64&c)return void a.move(t,e,n,lt);if(a===Li){i(o,e,n);for(let t=0;tl.enter(o)),r);else{const{leave:t,delayLeave:s,afterLeave:r}=l,a=()=>i(o,e,n),h=()=>{t(o,(()=>{a(),r&&r()}))};s?s(o,a,h):h()}else i(o,e,n)},tt=(t,e,i,n=!1,s=!1)=>{const{type:r,props:o,ref:a,children:l,dynamicChildren:h,shapeFlag:c,patchFlag:u,dirs:d}=t;if(null!=a&&Ei(a,null,i,null),256&c)return void e.ctx.deactivate(t);const f=1&c&&d;let p;if((p=o&&o.onVnodeBeforeUnmount)&&wi(p,e,t),6&c)st(t.component,i,n);else{if(128&c)return void t.suspense.unmount(i,n);f&&mi(t,null,e,"beforeUnmount"),h&&(r!==Li||u>0&&64&u)?rt(h,e,i,!1,!0):(r===Li&&(128&u||256&u)||!s&&16&c)&&rt(l,e,i),64&c&&(n||!Mi(t.props))&&t.type.remove(t,lt),n&&it(t)}((p=o&&o.onVnodeUnmounted)||f)&&xi((()=>{p&&wi(p,e,t),f&&mi(t,null,e,"unmounted")}),i)},it=t=>{const{type:e,el:i,anchor:s,transition:r}=t;if(e===Li)return void nt(i,s);if(e===Ii)return void P(t);const o=()=>{n(i),r&&!r.persisted&&r.afterLeave&&r.afterLeave()};if(1&t.shapeFlag&&r&&!r.persisted){const{leave:e,delayLeave:n}=r,s=()=>e(i,o);n?n(t.el,o,s):s()}else o()},nt=(t,e)=>{let i;for(;t!==e;)i=b(t),n(t),t=i;n(e)},st=(t,e,i)=>{const{bum:n,effects:s,update:r,subTree:o,um:a}=t;if(n&&k(n),s)for(let t=0;t{t.isUnmounted=!0}),e),e&&e.pendingBranch&&!e.isUnmounted&&t.asyncDep&&!t.asyncResolved&&t.suspenseId===e.pendingId&&(e.deps--,0===e.deps&&e.resolve())},rt=(t,e,i,n=!1,s=!1,r=0)=>{for(let o=r;o6&t.shapeFlag?ot(t.component.subTree):128&t.shapeFlag?t.suspense.next():b(t.anchor||t.el),at=(t,e)=>{null==t?e._vnode&&tt(e._vnode,null,null,!0):x(e._vnode||null,t,e),xe(),e._vnode=t},lt={p:x,um:tt,m:J,r:it,mt:U,mc:N,pc:K,pbc:O,n:ot,o:t};let ht,ct;e&&([ht,ct]=e(lt));return{render:at,hydrate:ht,createApp:yi(at,ht)}}(t)}function wi(t,e,i,n=null){ee(t,e,7,[i,n])}function Ti(t,e,i=!1){const n=t.children,s=e.children;if(S(n)&&S(s))for(let t=0;tt&&(t.disabled||""===t.disabled),Pi=Symbol(),Li=Symbol(void 0),Ai=Symbol(void 0),Ci=Symbol(void 0),Ii=Symbol(void 0),Ri=[];let Ni=null;function Fi(t){return!!t&&!0===t.__v_isVNode}function Bi(t,e){return t.type===e.type&&t.key===e.key}const Oi="__vInternal",Di=({key:t})=>null!=t?t:null,ki=({ref:t})=>null!=t?E(t)||Xt(t)||x(t)?{i:Pe,r:t}:t:null,Vi=function(t,e=null,i=null,s=0,r=null,o=!1){t&&t!==Pi||(t=Ci);if(Fi(t)){const n=Gi(t,e,!0);return i&&ji(n,i),n}l=t,x(l)&&"__vccOpts"in l&&(t=t.__vccOpts);var l;if(e){(zt(e)||Oi in e)&&(e=m({},e));let{class:t,style:i}=e;t&&!E(t)&&(e.class=a(t)),w(i)&&(zt(i)&&!S(i)&&(i=m({},i)),e.style=n(i))}const h=E(t)?1:(t=>t.__isSuspense)(t)?128:(t=>t.__isTeleport)(t)?64:w(t)?4:x(t)?2:0,c={__v_isVNode:!0,__v_skip:!0,type:t,props:e,key:e&&Di(e),ref:e&&ki(e),scopeId:null,children:null,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetAnchor:null,staticCount:0,shapeFlag:h,patchFlag:s,dynamicProps:r,dynamicChildren:null,appContext:null};if(ji(c,i),128&h){const{content:t,fallback:e}=function(t){const{shapeFlag:e,children:i}=t;let n,s;return 32&e?(n=Fe(i.default),s=Fe(i.fallback)):(n=Fe(i),s=Ui(null)),{content:n,fallback:s}}(c);c.ssContent=t,c.ssFallback=e}!o&&Ni&&(s>0||6&h)&&32!==s&&Ni.push(c);return c};function Gi(t,e,i=!1){const{props:s,ref:r,patchFlag:o,children:l}=t,h=e?function(...t){const e=m({},t[0]);for(let i=1;i1)return i&&x(e)?e():e}}let Xi=!1;function Yi(t,e,i=[],n=[],s=[],r=!1){const{mixins:o,extends:a,data:h,computed:u,methods:d,watch:f,provide:p,inject:b,components:g,directives:y,beforeMount:v,mounted:E,beforeUpdate:_,updated:T,activated:M,deactivated:P,beforeDestroy:L,beforeUnmount:A,destroyed:C,unmounted:I,render:R,renderTracked:N,renderTriggered:F,errorCaptured:B,expose:O}=e,D=t.proxy,k=t.ctx,V=t.appContext.mixins;if(r&&R&&t.render===c&&(t.render=R),r||(Xi=!0,Ki("beforeCreate","bc",e,t,V),Xi=!1,Ji(t,V,i,n,s)),a&&Yi(t,a,i,n,s,!0),o&&Ji(t,o,i,n,s),b)if(S(b))for(let t=0;tZi(t,e,D))),h&&Zi(t,h,D)),u)for(const t in u){const e=u[t],i=mn({get:x(e)?e.bind(D,D):x(e.get)?e.get.bind(D,D):c,set:!x(e)&&x(e.set)?e.set.bind(D):c});Object.defineProperty(k,t,{enumerable:!0,configurable:!0,get:()=>i.value,set:t=>i.value=t})}var G;if(f&&n.push(f),!r&&n.length&&n.forEach((t=>{for(const e in t)Qi(t[e],k,D,e)})),p&&s.push(p),!r&&s.length&&s.forEach((t=>{const e=x(t)?t.call(D):t;Reflect.ownKeys(e).forEach((t=>{!function(t,e){if(ln){let i=ln.provides;const n=ln.parent&&ln.parent.provides;n===i&&(i=ln.provides=Object.create(n)),i[t]=e}}(t,e[t])}))})),r&&(g&&m(t.components||(t.components=m({},t.type.components)),g),y&&m(t.directives||(t.directives=m({},t.type.directives)),y)),r||Ki("created","c",e,t,V),v&&Ke(v.bind(D)),E&&qe(E.bind(D)),_&&$e(_.bind(D)),T&&Je(T.bind(D)),M&&li(M.bind(D),"a",G),P&&function(t,e){li(t,"da",e)}(P.bind(D)),B&&((t,e=ln)=>{Xe("ec",t,e)})(B.bind(D)),N&&ei(N.bind(D)),F&&ti(F.bind(D)),A&&Ze(A.bind(D)),I&&Qe(I.bind(D)),S(O)&&!r)if(O.length){const e=t.exposed||(t.exposed=Jt({}));O.forEach((t=>{e[t]=function(t,e){return Xt(t[e])?t[e]:new Zt(t,e)}(D,t)}))}else t.exposed||(t.exposed=l)}function Ki(t,e,i,n,s){$i(t,e,s,n);const{extends:r,mixins:o}=i;r&&qi(t,e,r,n),o&&$i(t,e,o,n);const a=i[t];a&&ee(a.bind(n.proxy),n,e)}function qi(t,e,i,n){i.extends&&qi(t,e,i.extends,n);const s=i[t];s&&ee(s.bind(n.proxy),n,e)}function $i(t,e,i,n){for(let s=0;s{let e=t;for(let t=0;ti[n];if(E(t)){const i=e[t];x(i)&&ni(s,i)}else if(x(t))ni(s,t.bind(i));else if(w(t))if(S(t))t.forEach((t=>Qi(t,e,i,n)));else{const n=x(t.handler)?t.handler.bind(i):e[t.handler];x(n)&&ni(s,n,t)}}function tn(t,e,i){const n=i.appContext.config.optionMergeStrategies,{mixins:s,extends:r}=e;r&&tn(t,r,i),s&&s.forEach((e=>tn(t,e,i)));for(const s in e)n&&y(n,s)?t[s]=n[s](t[s],e[s],i.proxy,s):t[s]=e[s]}const en=t=>t?cn(t)?t.exposed?t.exposed:t.proxy:en(t.parent):null,nn=m(Object.create(null),{$:t=>t,$el:t=>t.vnode.el,$data:t=>t.data,$props:t=>t.props,$attrs:t=>t.attrs,$slots:t=>t.slots,$refs:t=>t.refs,$parent:t=>en(t.parent),$root:t=>en(t.root),$emit:t=>t.emit,$options:t=>function(t){const e=t.type,{__merged:i,mixins:n,extends:s}=e;if(i)return i;const r=t.appContext.mixins;if(!r.length&&!n&&!s)return e;const o={};return r.forEach((e=>tn(o,e,t))),tn(o,e,t),e.__merged=o}(t),$forceUpdate:t=>()=>ge(t.update),$nextTick:t=>be.bind(t.proxy),$watch:t=>ri.bind(t)}),sn={get({_:t},e){const{ctx:i,setupState:n,data:s,props:r,accessCache:o,type:a,appContext:h}=t;if("__v_skip"===e)return!0;let c;if("$"!==e[0]){const a=o[e];if(void 0!==a)switch(a){case 0:return n[e];case 1:return s[e];case 3:return i[e];case 2:return r[e]}else{if(n!==l&&y(n,e))return o[e]=0,n[e];if(s!==l&&y(s,e))return o[e]=1,s[e];if((c=t.propsOptions[0])&&y(c,e))return o[e]=2,r[e];if(i!==l&&y(i,e))return o[e]=3,i[e];Xi||(o[e]=4)}}const u=nn[e];let d,f;return u?("$attrs"===e&&tt(t,0,e),u(t)):(d=a.__cssModules)&&(d=d[e])?d:i!==l&&y(i,e)?(o[e]=3,i[e]):(f=h.config.globalProperties,y(f,e)?f[e]:void 0)},set({_:t},e,i){const{data:n,setupState:s,ctx:r}=t;if(s!==l&&y(s,e))s[e]=i;else if(n!==l&&y(n,e))n[e]=i;else if(y(t.props,e))return!1;return("$"!==e[0]||!(e.slice(1)in t))&&(r[e]=i,!0)},has({_:{data:t,setupState:e,accessCache:i,ctx:n,appContext:s,propsOptions:r}},o){let a;return void 0!==i[o]||t!==l&&y(t,o)||e!==l&&y(e,o)||(a=r[0])&&y(a,o)||y(n,o)||y(nn,o)||y(s.config.globalProperties,o)}},rn=m({},sn,{get(t,e){if(e!==Symbol.unscopables)return sn.get(t,e,t)},has:(t,i)=>"_"!==i[0]&&!e(i)}),on=bi();let an=0;let ln=null;const hn=t=>{ln=t};function cn(t){return 4&t.vnode.shapeFlag}let un=!1;function dn(t,e,i){x(e)?t.render=e:w(e)&&(t.setupState=Jt(e)),fn(t)}function fn(t,e){const i=t.type;t.render||(t.render=i.render||c,t.render._rc&&(t.withProxy=new Proxy(t.ctx,rn))),ln=t,Z(),Yi(t,i),Q(),ln=null}function pn(t,e=ln){e&&(e.effects||(e.effects=[])).push(t)}function mn(t){const e=function(t){let e,i;return x(t)?(e=t,i=c):(e=t.get,i=t.set),new Qt(e,i,x(t)||!t.set)}(t);return pn(e.effect),e}const bn="3.0.6",gn="http://www.w3.org/2000/svg",yn="undefined"!=typeof document?document:null;let Sn,vn;const xn={insert:(t,e,i)=>{e.insertBefore(t,i||null)},remove:t=>{const e=t.parentNode;e&&e.removeChild(t)},createElement:(t,e,i)=>e?yn.createElementNS(gn,t):yn.createElement(t,i?{is:i}:void 0),createText:t=>yn.createTextNode(t),createComment:t=>yn.createComment(t),setText:(t,e)=>{t.nodeValue=e},setElementText:(t,e)=>{t.textContent=e},parentNode:t=>t.parentNode,nextSibling:t=>t.nextSibling,querySelector:t=>yn.querySelector(t),setScopeId(t,e){t.setAttribute(e,"")},cloneNode:t=>t.cloneNode(!0),insertStaticContent(t,e,i,n){const s=n?vn||(vn=yn.createElementNS(gn,"svg")):Sn||(Sn=yn.createElement("div"));s.innerHTML=t;const r=s.firstChild;let o=r,a=o;for(;o;)a=o,xn.insert(o,e,i),o=s.firstChild;return[r,a]}};const En=/\s*!important$/;function _n(t,e,i){if(S(i))i.forEach((i=>_n(t,e,i)));else if(e.startsWith("--"))t.setProperty(e,i);else{const n=function(t,e){const i=Tn[e];if(i)return i;let n=R(e);if("filter"!==n&&n in t)return Tn[e]=n;n=B(n);for(let i=0;idocument.createEvent("Event").timeStamp&&(Pn=()=>performance.now());let Ln=0;const An=Promise.resolve(),Cn=()=>{Ln=0};function In(t,e,i,n,s=null){const r=t._vei||(t._vei={}),o=r[e];if(n&&o)o.value=n;else{const[i,a]=function(t){let e;if(Rn.test(t)){let i;for(e={};i=t.match(Rn);)t=t.slice(0,t.length-i[0].length),e[i[0].toLowerCase()]=!0}return[F(t.slice(2)),e]}(e);if(n){!function(t,e,i,n){t.addEventListener(e,i,n)}(t,i,r[e]=function(t,e){const i=t=>{(t.timeStamp||Pn())>=i.attached-1&&ee(function(t,e){if(S(e)){const i=t.stopImmediatePropagation;return t.stopImmediatePropagation=()=>{i.call(t),t._stopped=!0},e.map((t=>e=>!e._stopped&&t(e)))}return e}(t,i.value),e,5,[t])};return i.value=t,i.attached=(()=>Ln||(An.then(Cn),Ln=Pn()))(),i}(n,s),a)}else o&&(!function(t,e,i,n){t.removeEventListener(e,i,n)}(t,i,o,a),r[e]=void 0)}}const Rn=/(?:Once|Passive|Capture)$/;const Nn=/^on[a-z]/;const Fn=m({patchProp:(t,e,n,s,r=!1,o,a,l,h)=>{switch(e){case"class":!function(t,e,i){if(null==e&&(e=""),i)t.setAttribute("class",e);else{const i=t._vtc;i&&(e=(e?[e,...i]:[...i]).join(" ")),t.className=e}}(t,s,r);break;case"style":!function(t,e,i){const n=t.style;if(i)if(E(i))e!==i&&(n.cssText=i);else{for(const t in i)_n(n,t,i[t]);if(e&&!E(e))for(const t in e)null==i[t]&&_n(n,t,"")}else t.removeAttribute("style")}(t,n,s);break;default:f(e)?p(e)||In(t,e,0,s,a):function(t,e,i,n){if(n)return"innerHTML"===e||!!(e in t&&Nn.test(e)&&x(i));if("spellcheck"===e||"draggable"===e)return!1;if("form"===e)return!1;if("list"===e&&"INPUT"===t.tagName)return!1;if("type"===e&&"TEXTAREA"===t.tagName)return!1;if(Nn.test(e)&&E(i))return!1;return e in t}(t,e,s,r)?function(t,e,i,n,s,r,o){if("innerHTML"===e||"textContent"===e)return n&&o(n,s,r),void(t[e]=null==i?"":i);if("value"!==e||"PROGRESS"===t.tagName){if(""===i||null==i){const n=typeof t[e];if(""===i&&"boolean"===n)return void(t[e]=!0);if(null==i&&"string"===n)return t[e]="",void t.removeAttribute(e);if("number"===n)return t[e]=0,void t.removeAttribute(e)}try{t[e]=i}catch(t){}}else{t._value=i;const e=null==i?"":i;t.value!==e&&(t.value=e)}}(t,e,s,o,a,l,h):("true-value"===e?t._trueValue=s:"false-value"===e&&(t._falseValue=s),function(t,e,n,s){if(s&&e.startsWith("xlink:"))null==n?t.removeAttributeNS(Mn,e.slice(6,e.length)):t.setAttributeNS(Mn,e,n);else{const s=i(e);null==n||s&&!1===n?t.removeAttribute(e):t.setAttribute(e,s?"":n)}}(t,e,s,r))}},forcePatchProp:(t,e)=>"value"===e},xn);let Bn;!function(t,e){var i,n=t.document,s=n.documentElement,r=n.querySelector('meta[name="viewport"]'),o=n.querySelector('meta[name="flexible"]'),a=0,l=0,h=e.flexible||(e.flexible={});if(r){console.warn("将根据已有的meta标签来设置缩放比例");var c=r.getAttribute("content").match(/initial\-scale=([\d\.]+)/);c&&(l=parseFloat(c[1]),a=parseInt(1/l))}else if(o){var u=o.getAttribute("content");if(u){var d=u.match(/initial\-dpr=([\d\.]+)/),f=u.match(/maximum\-dpr=([\d\.]+)/);d&&(a=parseFloat(d[1]),l=parseFloat((1/a).toFixed(2))),f&&(a=parseFloat(f[1]),l=parseFloat((1/a).toFixed(2)))}}if(!a&&!l){t.navigator.appVersion.match(/android/gi);var p=t.navigator.appVersion.match(/iphone/gi),m=t.devicePixelRatio;l=1/(a=p?m>=3&&(!a||a>=3)?3:m>=2&&(!a||a>=2)?2:1:1)}if(s.setAttribute("data-dpr",a),!r)if((r=n.createElement("meta")).setAttribute("name","viewport"),r.setAttribute("content","initial-scale="+l+", maximum-scale="+l+", minimum-scale="+l+", user-scalable=no"),s.firstElementChild)s.firstElementChild.appendChild(r);else{var b=n.createElement("div");b.appendChild(r),n.write(b.innerHTML)}function g(){var e=s.getBoundingClientRect().width;e/a>540&&(e=540*a);var i=e/10;s.style.fontSize=i+"px",h.rem=t.rem=i}t.addEventListener("resize",(function(){clearTimeout(i),i=setTimeout(g,300)}),!1),t.addEventListener("pageshow",(function(t){t.persisted&&(clearTimeout(i),i=setTimeout(g,300))}),!1),"complete"===n.readyState?n.body.style.fontSize=12*a+"px":n.addEventListener("DOMContentLoaded",(function(t){n.body.style.fontSize=12*a+"px"}),!1),g(),h.dpr=t.dpr=a,h.refreshRem=g,h.rem2px=function(t){var e=parseFloat(t)*this.rem;return"string"==typeof t&&t.match(/rem$/)&&(e+="px"),e},h.px2rem=function(t){var e=parseFloat(t)/this.rem;return"string"==typeof t&&t.match(/px$/)&&(e+="rem"),e}}(window,window.lib||(window.lib={}));var On,Dn,kn=(function(t,e){window,t.exports=function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)i.d(n,s,function(e){return t[e]}.bind(null,s));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=184)}([function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.Fraction=void 0;class n{constructor(t=0,e=1,i=0,n=!0){this.numerator=0,this.denominator=1,this.wholeValue=0,this.numerator=t,this.denominator=e,this.wholeValue=i,n&&this.simplify(),this.setRealValue()}static max(t,e){return t.RealValue>e.RealValue?t:e}static Equal(t,e){return t.wholeValue===e.wholeValue&&t.Denominator===e.Denominator&&t.Numerator===e.Numerator}static createFromFraction(t){return new n(t.numerator,t.denominator,t.wholeValue,!1)}static plus(t,e){const i=t.clone();return i.Add(e),i}static minus(t,e){const i=t.clone();return i.Sub(e),i}static multiply(t,e){return new n((t.wholeValue*t.denominator+t.numerator)*(e.wholeValue*e.denominator+e.numerator),t.denominator*e.denominator)}static greatestCommonDenominator(t,e){if(0===t)return e;if(1===e)return 1;for(;Math.abs(e)>1e-8;)t>e?t-=e:e-=t;return Math.round(t)}toString(){let t=this.numerator+"/"+this.denominator;return 0!==this.wholeValue&&(t=this.wholeValue+" "+t),t}clone(){return new n(this.numerator,this.denominator,this.wholeValue,!1)}get Numerator(){return this.numerator}set Numerator(t){this.numerator!==t&&(this.numerator=t,this.simplify(),this.setRealValue())}get Denominator(){return this.denominator}set Denominator(t){this.denominator!==t&&(this.denominator=t,0!==this.numerator&&this.simplify(),this.setRealValue())}get WholeValue(){return this.wholeValue}set WholeValue(t){this.wholeValue!==t&&(this.wholeValue=t,this.setRealValue())}GetExpandedNumerator(){return this.wholeValue*this.denominator+this.numerator}IsNegative(){return this.realValue<0}get RealValue(){return this.realValue}expand(t){this.numerator*=t,this.denominator*=t,0!==this.wholeValue&&(this.numerator+=this.wholeValue*this.denominator,this.wholeValue=0)}Add(t){return this.numerator=(this.wholeValue*this.denominator+this.numerator)*t.denominator+(t.wholeValue*t.denominator+t.numerator)*this.denominator,this.denominator=this.denominator*t.denominator,this.wholeValue=0,this.simplify(),this.setRealValue(),this}Sub(t){return this.numerator=(this.wholeValue*this.denominator+this.numerator)*t.denominator-(t.wholeValue*t.denominator+t.numerator)*this.denominator,this.denominator=this.denominator*t.denominator,this.wholeValue=0,this.simplify(),this.setRealValue(),this}Quantize(t){if(this.denominator<=t)return this;const e=new n(this.numerator+1,this.denominator,this.wholeValue);for(;e.Denominator>t;)e.Numerator++;if(this.numerator>this.denominator){const i=new n(this.numerator-1,this.denominator,this.wholeValue);for(;i.Denominator>t;)i.Numerator--;if(i.Denominatorn.maximumAllowedNumber){const t=this.denominator/n.maximumAllowedNumber;this.numerator=Math.round(this.numerator/t),this.denominator=Math.round(this.denominator/t)}if(this.numerator>n.maximumAllowedNumber){const t=this.numerator/n.maximumAllowedNumber;this.numerator=Math.round(this.numerator/t),this.denominator=Math.round(this.denominator/t)}}isOnBeat(t){const e=this.distanceFromBeat(t);return Math.abs(e)=0&&e<=r.levels.SILENT))throw"log.setLevel() called with invalid level: "+e;if(s=e,!1!==n&&function(t){var e=(i[t]||"silent").toUpperCase();if("undefined"!=typeof window){try{return void(window.localStorage[a]=e)}catch(t){}try{window.document.cookie=encodeURIComponent(a)+"="+e+";"}catch(t){}}}(e),o.call(r,e,t),"undefined"==typeof console&&ei.length-1&&(s=1),r<0&&(r=i.length+r,s=-1),[i[r],s]}static CalculateTransposedHalfTone(t,e){const i=t.fundamentalNote+t.AccidentalHalfTones+e;return o.WrapAroundCheck(i,12)}static WrapAroundCheck(t,e){let i=0;for(;t<0;)t+=e,i--;for(;t>=e;)t-=e,i++;return{overflow:i,halftone:t}}static calcFrequency(t){let e,i=0;if(t instanceof o){const s=t;i=s.octave-1,e=s.fundamentalNote-n.A+s.AccidentalHalfTones}else"number"==typeof t&&(e=t-57);return 440*Math.pow(2,i)*Math.pow(2,e/12)}static calcFractionalKey(t){return Math.log(t/440)/Math.LN10*o.halftoneFactor+57}static fromFrequency(t){const e=o.calcFractionalKey(t)+.5,i=Math.floor(e/12)-o.octXmlDiff,n=Math.floor(e)%12;let r=n,a=s.NONE;return-1===this.pitchEnumValues.indexOf(r)&&(r=n-1,a=s.SHARP),new o(r,i,a)}static fromHalftone(t){const e=Math.floor(t/12)-o.octXmlDiff,i=t%12;let n=i,r=s.NONE;return-1===this.pitchEnumValues.indexOf(n)&&(n=i-1,r=s.SHARP),new o(n,e,r)}static ceiling(t){let e=t%=12;return-1===this.pitchEnumValues.indexOf(e)&&(e=t+1),e}static floor(t){let e=t%=12;return-1===this.pitchEnumValues.indexOf(e)&&(e=t-1),e}static HalfTonesFromAccidental(t){switch(t){case s.NONE:return 0;case s.SHARP:return 1;case s.FLAT:return-1;case s.NATURAL:return 0;case s.DOUBLESHARP:return 2;case s.DOUBLEFLAT:return-2;case s.QUARTERTONESHARP:return.5;case s.QUARTERTONEFLAT:return-.5;case s.TRIPLESHARP:return 3;case s.TRIPLEFLAT:return-3;default:throw new Error("Unhandled AccidentalEnum value")}}static AccidentalFromHalfTones(t){switch(t){case 0:return s.NONE;case 1:return s.SHARP;case-1:return s.FLAT;case 2:return s.DOUBLESHARP;case-2:return s.DOUBLEFLAT;case.5:return s.QUARTERTONESHARP;case-.5:return s.QUARTERTONEFLAT;case 3:return s.TRIPLESHARP;case-3:return s.TRIPLEFLAT;default:return t>0&&t<1?s.QUARTERTONESHARP:t<0&&t>-1?s.QUARTERTONEFLAT:s.QUARTERTONESHARP}}static accidentalVexflow(t){let e;switch(t){case s.NATURAL:e="n";break;case s.FLAT:e="b";break;case s.SHARP:e="#";break;case s.DOUBLESHARP:e="##";break;case s.TRIPLESHARP:e="++";break;case s.DOUBLEFLAT:e="bb";break;case s.TRIPLEFLAT:e="bbs";break;case s.QUARTERTONESHARP:e="+";break;case s.QUARTERTONEFLAT:e="d"}return e}get AccidentalHalfTones(){return o.HalfTonesFromAccidental(this.accidental)}get Octave(){return this.octave}get FundamentalNote(){return this.fundamentalNote}get Accidental(){return this.accidental}get Frequency(){return this.frequency}static get OctaveXmlDifference(){return o.octXmlDiff}getHalfTone(){return this.halfTone}getTransposedPitch(t){if(t>12)throw new Error("rewrite this method to handle bigger octave changes or don't use is with bigger octave changes!");return t>0?this.getHigherPitchByTransposeFactor(t):t<0?this.getLowerPitchByTransposeFactor(-t):this}DoEnharmonicChange(){switch(this.accidental){case s.FLAT:case s.DOUBLEFLAT:this.fundamentalNote=this.getPreviousFundamentalNote(this.fundamentalNote),this.accidental=o.AccidentalFromHalfTones(this.halfTone-(this.fundamentalNote+12*(this.octave+o.octXmlDiff)));break;case s.SHARP:case s.DOUBLESHARP:this.fundamentalNote=this.getNextFundamentalNote(this.fundamentalNote),this.accidental=o.AccidentalFromHalfTones(this.halfTone-(this.fundamentalNote+12*(this.octave+o.octXmlDiff)));break;default:return}}ToString(){let t=o.accidentalVexflow(this.accidental);return t||(t=""),"Key: "+o.getNoteEnumString(this.fundamentalNote)+t+", Note: "+this.fundamentalNote+", octave: "+this.octave.toString()}OperatorEquals(t){return!(!this||!t)&&this.FundamentalNote===t.FundamentalNote&&this.Octave===t.Octave&&this.Accidental===t.Accidental}OperatorNotEqual(t){return!(this===t)}OperatorFundamentalGreaterThan(t){const e=this;return e.Octave===t.Octave?e.FundamentalNote>t.FundamentalNote:e.Octave>t.Octave}OperatorFundamentalLessThan(t){const e=this;return e.Octave===t.Octave?e.FundamentalNoteo.pitchEnumValues.length-1?(i=o.pitchEnumValues[e+t-o.pitchEnumValues.length],n++):i=o.pitchEnumValues[e+t],new o(i,n,s.NONE)}getLowerPitchByTransposeFactor(t){const e=o.pitchEnumValues.indexOf(this.fundamentalNote);let i,n=this.octave;return e-t<0?(i=o.pitchEnumValues[o.pitchEnumValues.length+e-t],n--):i=o.pitchEnumValues[e-t],new o(i,n,s.NONE)}getNextFundamentalNote(t){let e=o.pitchEnumValues.indexOf(t);return e=(e+1)%o.pitchEnumValues.length,o.pitchEnumValues[e]}getPreviousFundamentalNote(t){const e=o.pitchEnumValues.indexOf(t);return e>0?o.pitchEnumValues[e-1]:o.pitchEnumValues[o.pitchEnumValues.length-1]}}e.Pitch=o,o.pitchEnumValues=[n.C,n.D,n.E,n.F,n.G,n.A,n.B],o.halftoneFactor=12/(Math.LN2/Math.LN10),o.octXmlDiff=3},function(t,e,i){var n,s;Object.defineProperty(e,"__esModule",{value:!0}),e.PlacementEnum=e.AbstractExpression=void 0,e.AbstractExpression=class{constructor(t){this.placement=t}static isStringInStringList(t,e){for(let i=0,n=t.length;ithis.borderLeft?this.borderLeft:this.borderMarginLeft}set BorderMarginLeft(t){this.borderMarginLeft=t,this.calculateMarginRectangle()}get BorderMarginRight(){return this.borderMarginRightthis.borderTop?this.borderTop:this.borderMarginTop}set BorderMarginTop(t){this.borderMarginTop=t,this.calculateMarginRectangle()}get BorderMarginBottom(){return this.borderMarginBottom-1&&this.parent.ChildElements.splice(t,1)}this.parent=t,this.parent.ChildElements.indexOf(this)>-1?s.default.error("BoundingBox of "+this.dataObject.constructor.name+" already in children list of "+this.parent.dataObject.constructor.name+"'s BoundingBox"):this.parent.ChildElements.push(this)}get DataObject(){return this.dataObject}get Center(){return new o.PointF2D(this.RelativePosition.x+(this.BorderMarginRight+this.BorderMarginLeft),this.RelativePosition.y+(this.BorderMarginBottom+this.BorderMarginTop))}setAbsolutePositionFromParent(){this.parent?(this.absolutePosition.x=this.parent.AbsolutePosition.x+this.relativePosition.x,this.absolutePosition.y=this.parent.AbsolutePosition.y+this.relativePosition.y):this.absolutePosition=this.relativePosition}calculateAbsolutePosition(){this.absolutePosition.x=this.relativePosition.x,this.absolutePosition.y=this.relativePosition.y;let t=this.parent;for(;t;)this.absolutePosition.x+=t.relativePosition.x,this.absolutePosition.y+=t.relativePosition.y,t=t.parent}calculateAbsolutePositionsRecursiveWithoutTopelement(){this.absolutePosition.x=0,this.absolutePosition.y=0;for(let t=0,e=this.ChildElements.length;t.001;break;case d.Up:case d.Down:n=this.relativePosition.y,t.calculateMarginPositionAlongDirection(this,e),s=Math.abs(n-this.relativePosition.y)>.001;break;default:throw new r.ArgumentOutOfRangeException("direction")}}while(s)}collisionDetection(t){const e=Math.min(this.AbsolutePosition.x+this.borderRight,t.absolutePosition.x+t.borderRight)-Math.max(this.AbsolutePosition.x+this.borderLeft,t.absolutePosition.x+t.borderLeft),i=Math.min(this.AbsolutePosition.y+this.borderBottom,t.absolutePosition.y+t.borderBottom)-Math.max(this.AbsolutePosition.y+this.borderTop,t.absolutePosition.y+t.borderTop);return e>0&&i>0}liesInsideBorders(t){const e=this.AbsolutePosition.x+this.borderLeft<=t.absolutePosition.x+t.borderLeft&&t.absolutePosition.x+t.borderLeft<=this.AbsolutePosition.x+this.borderRight,i=this.AbsolutePosition.x+this.borderLeft<=t.absolutePosition.x+t.borderRight&&t.absolutePosition.x+t.borderRight<=this.AbsolutePosition.x+this.borderRight;if(e&&i){const e=this.AbsolutePosition.y+this.borderTop<=t.absolutePosition.y+t.borderTop&&t.absolutePosition.y+t.borderTop<=this.AbsolutePosition.y+this.borderBottom,i=this.AbsolutePosition.y+this.borderTop<=t.absolutePosition.y+t.borderBottom&&t.absolutePosition.y+t.borderBottom<=this.AbsolutePosition.y+this.borderBottom;if(e&&i)return!0}return!1}pointLiesInsideBorders(t){return this.AbsolutePosition.x+this.borderLeft<=t.x&&t.x<=this.AbsolutePosition.x+this.borderRight&&this.AbsolutePosition.y+this.borderTop<=t.y&&t.y<=this.AbsolutePosition.y+this.borderBottom}marginCollisionDetection(t){const e=Math.min(this.AbsolutePosition.x+this.borderMarginRight,t.absolutePosition.x+t.borderMarginRight)-Math.max(this.AbsolutePosition.x+this.borderMarginLeft,t.absolutePosition.x+t.borderMarginLeft),i=Math.min(this.AbsolutePosition.y+this.borderMarginBottom,t.absolutePosition.y+t.borderMarginBottom)-Math.max(this.AbsolutePosition.y+this.borderMarginTop,t.absolutePosition.y+t.borderMarginTop);return e>0&&i>0}liesInsideMargins(t){const e=this.AbsolutePosition.x+this.borderMarginLeft<=t.absolutePosition.x+t.borderMarginLeft&&t.absolutePosition.x+t.borderMarginLeft<=this.AbsolutePosition.x+this.borderMarginRight,i=this.AbsolutePosition.x+this.borderMarginLeft<=t.absolutePosition.x+t.borderMarginRight&&t.absolutePosition.x+t.borderMarginRight<=this.AbsolutePosition.x+this.borderMarginRight;if(e&&i){const e=this.AbsolutePosition.y+this.borderMarginTop<=t.absolutePosition.y+t.borderMarginTop&&t.absolutePosition.y+t.borderMarginTop<=this.AbsolutePosition.y+this.borderMarginBottom,i=this.AbsolutePosition.y+this.borderMarginTop<=t.absolutePosition.y+t.borderMarginBottom&&t.absolutePosition.y+t.borderMarginBottom<=this.AbsolutePosition.y+this.borderMarginBottom;if(e&&i)return!0}return!1}pointLiesInsideMargins(t){return this.AbsolutePosition.x+this.borderMarginLeft<=t.x&&t.x<=this.AbsolutePosition.x+this.borderMarginRight&&this.AbsolutePosition.y+this.borderMarginTop<=t.y&&t.y<=this.AbsolutePosition.y+this.borderMarginBottom}computeNonOverlappingPosition(t,e,i){this.RelativePosition=new o.PointF2D(i.x,i.y),this.setAbsolutePositionFromParent();let n=0,s=!1;do{switch(e){case d.Left:case d.Right:n=this.relativePosition.x,t.calculatePositionAlongDirection(this,e),s=Math.abs(n-this.relativePosition.x)>1e-4;break;case d.Up:case d.Down:n=this.relativePosition.y,t.calculatePositionAlongDirection(this,e),s=Math.abs(n-this.relativePosition.y)>1e-4;break;default:throw new r.ArgumentOutOfRangeException("direction")}}while(s)}getClickedObjectOfType(t){const e=this.dataObject;if(this.pointLiesInsideBorders(t)&&e)return e;for(let e=0,i=this.childElements.length;e{};n.L=(t,e)=>{if(!e)return;const i=Array.prototype.slice.call(e).join(" ");window.console.log(t+": "+i)},n.MakeException=t=>class extends Error{constructor(e,i){super(e),this.name=t,this.message=e,this.data=i}},n.RERR=n.RuntimeError=class{constructor(t,e){this.code=t,this.message=e}toString(){return"[RuntimeError] "+this.code+":"+this.message}},n.Merge=(t,e)=>{for(const i in e)t[i]=e[i];return t},n.Min=Math.min,n.Max=Math.max,n.forEach=(t,e)=>{for(let i=0;it%e>=e/2?parseInt(t/e,10)*e+e:parseInt(t/e,10)*e,n.MidLine=(t,e)=>{let i=e+(t-e)/2;return i%2>0&&(i=n.RoundN(10*i,5)/10),i},n.SortAndUnique=(t,e,i)=>{if(t.length>1){const n=[];let s;t.sort(e);for(let e=0;e{let i=t.length;for(;i--;)if(t[i]===e)return!0;return!1},n.getCanvasContext=t=>{if(!t)throw new n.RERR("BadArgument","Invalid canvas selector: "+t);const e=document.getElementById(t);if(!e||!e.getContext)throw new n.RERR("UnsupportedBrowserError","This browser does not support HTML5 Canvas");return e.getContext("2d")},n.drawDot=(t,e,i,n="#55")=>{t.save(),t.setFillStyle(n),t.beginPath(),t.arc(e,i,3,0,2*Math.PI,!0),t.closePath(),t.fill(),t.restore()},n.BM=(t,e)=>{const i=(new Date).getTime();e();const s=(new Date).getTime()-i;n.L(t+s+"ms")},n.StackTrace=()=>(new Error).stack,n.W=(...t)=>{const e=t.join(" ");window.console.log("Warning: ",e,n.StackTrace())},(n.Prefix=t=>n.Prefix.prefix+t).prefix="vf-";class s{static GCD(t,e){if("number"!=typeof t||"number"!=typeof e)throw new n.RERR("BadArgument",`Invalid numbers: ${t}, ${e}`);let i;for(;0!==e;)i=e,e=t%e,t=i;return t}static LCM(t,e){return t*e/s.GCD(t,e)}static LCMM(t){if(0===t.length)return 0;if(1===t.length)return t[0];if(2===t.length)return s.LCM(t[0],t[1]);{const e=t[0];return t.shift(),s.LCM(e,s.LCMM(t))}}constructor(t,e){this.set(t,e)}set(t,e){return this.numerator=void 0===t?1:t,this.denominator=void 0===e?1:e,this}value(){return this.numerator/this.denominator}simplify(){let t=this.numerator,e=this.denominator;const i=s.GCD(t,e);return t/=i,e/=i,e<0&&(e=-e,t=-t),this.set(t,e)}add(t,e){let i,n;t instanceof s?(i=t.numerator,n=t.denominator):(i=void 0!==t?t:0,n=void 0!==e?e:1);const r=s.LCM(this.denominator,n),o=r/this.denominator,a=r/n,l=this.numerator*o+i*a;return this.set(l,r)}subtract(t,e){let i,n;t instanceof s?(i=t.numerator,n=t.denominator):(i=void 0!==t?t:0,n=void 0!==e?e:1);const r=s.LCM(this.denominator,n),o=r/this.denominator,a=r/n,l=this.numerator*o-i*a;return this.set(l,r)}multiply(t,e){let i,n;return t instanceof s?(i=t.numerator,n=t.denominator):(i=void 0!==t?t:1,n=void 0!==e?e:1),this.set(this.numerator*i,this.denominator*n)}divide(t,e){let i,n;return t instanceof s?(i=t.numerator,n=t.denominator):(i=void 0!==t?t:1,n=void 0!==e?e:1),this.set(this.numerator*n,this.denominator*i)}equals(t){const e=s.__compareA.copy(t).simplify(),i=s.__compareB.copy(this).simplify();return e.numerator===i.numerator&&e.denominator===i.denominator}greaterThan(t){const e=s.__compareB.copy(this);return e.subtract(t),e.numerator>0}greaterThanEquals(t){const e=s.__compareB.copy(this);return e.subtract(t),e.numerator>=0}lessThan(t){return!this.greaterThanEquals(t)}lessThanEquals(t){return!this.greaterThan(t)}clone(){return new s(this.numerator,this.denominator)}copy(t){return"number"==typeof t?this.set(t||0,1):this.set(t.numerator,t.denominator)}quotient(){return Math.floor(this.numerator/this.denominator)}fraction(){return this.numerator%this.denominator}abs(){return this.denominator=Math.abs(this.denominator),this.numerator=Math.abs(this.numerator),this}toString(){return this.numerator+"/"+this.denominator}toSimplifiedString(){return s.__tmp.copy(this).simplify().toString()}toMixedString(){let t="";const e=this.quotient(),i=s.__tmp.copy(this);return e<0?i.abs().fraction():i.fraction(),0!==e?(t+=e,0!==i.numerator&&(t+=" "+i.toSimplifiedString())):t=0===i.numerator?"0":i.toSimplifiedString(),t}parse(t){const e=t.split("/"),i=parseInt(e[0],10),n=e[1]?parseInt(e[1],10):1;return this.set(i,n)}}s.__compareA=new s,s.__compareB=new s,s.__tmp=new s;const r=n.MakeException("RegistryError");function o(t,e,i,n,s){t[e][i]||(t[e][i]={}),t[e][i][n]=s}class a{static get INDEXES(){return["type"]}constructor(){this.clear()}static enableDefaultRegistry(t){a.defaultRegistry=t}static getDefaultRegistry(){return a.defaultRegistry}static disableDefaultRegistry(){a.defaultRegistry=null}clear(){return this.index={id:{},type:{},class:{}},this}updateIndex({id:t,name:e,value:i,oldValue:n}){const s=this.getElementById(t);null!==n&&this.index[e][n]&&delete this.index[e][n][t],null!==i&&o(this.index,e,i,s.getAttribute("id"),s)}register(t,e){if(!(e=e||t.getAttribute("id")))throw new r("Can't add element without `id` attribute to registry",t);return t.setAttribute("id",e),o(this.index,"id",e,e,t),a.INDEXES.forEach((i=>{this.updateIndex({id:e,name:i,value:t.getAttribute(i),oldValue:null})})),t.onRegister(this),this}getElementById(t){return this.index.id[t]?this.index.id[t][t]:null}getElementsByAttribute(t,e){const i=this.index[t];return i&&i[e]?Object.keys(i[e]).map((t=>i[e][t])):[]}getElementsByType(t){return this.getElementsByAttribute("type",t)}getElementsByClass(t){return this.getElementsByAttribute("class",t)}onUpdate({id:t,name:e,value:i,oldValue:n}){return s=a.INDEXES.concat(["id","class"]),r=e,s.filter((t=>t===r)).length>0?(this.updateIndex({id:t,name:e,value:i,oldValue:n}),this):this;var s,r}}a.defaultRegistry=null;class l{static newID(){return"auto"+l.ID++}constructor({type:t}={}){this.attrs={id:l.newID(),el:null,type:t||"Base",classes:{}},this.boundingBox=null,this.context=null,this.rendered=!1,a.getDefaultRegistry()&&a.getDefaultRegistry().register(this)}setStyle(t){return this.style=t,this}getStyle(){return this.style}applyStyle(t=this.context,e=this.getStyle()){return e?(t.save(),e.shadowColor&&t.setShadowColor(e.shadowColor),e.shadowBlur&&t.setShadowBlur(e.shadowBlur),e.fillStyle&&t.setFillStyle(e.fillStyle),e.strokeStyle&&t.setStrokeStyle(e.strokeStyle),e.lineWidth&&t.setLineWidth(e.lineWidth),this):this}restoreStyle(t=this.context,e=this.getStyle()){return e?(t.restore(),this):this}drawWithStyle(){this.checkContext(),this.applyStyle(),this.draw(),this.restoreStyle()}hasClass(t){return!0===this.attrs.classes[t]}addClass(t){return this.attrs.classes[t]=!0,this.registry&&this.registry.onUpdate({id:this.getAttribute("id"),name:"class",value:t,oldValue:null}),this}removeClass(t){return delete this.attrs.classes[t],this.registry&&this.registry.onUpdate({id:this.getAttribute("id"),name:"class",value:null,oldValue:t}),this}onRegister(t){return this.registry=t,this}isRendered(){return this.rendered}setRendered(t=!0){return this.rendered=t,this}getAttributes(){return this.attrs}getAttribute(t){return this.attrs[t]}setAttribute(t,e){const i=this.attrs.id,n=this.attrs[t];return this.attrs[t]=e,this.registry&&this.registry.onUpdate({id:i,name:t,value:e,oldValue:n}),this}getContext(){return this.context}setContext(t){return this.context=t,this}getBoundingBox(){return this.boundingBox}checkContext(){if(!this.context)throw new n.RERR("NoContext","No rendering context attached to instance");return this.context}}l.ID=1e3;class h{constructor(t,e,i,n){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN,this.addPoint(t,e),this.addPoint(i,n)}width(){return this.x2-this.x1}height(){return this.y2-this.y1}addPoint(t,e){null!=t&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=t,this.x2=t),tthis.x2&&(this.x2=t)),null!=e&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),ethis.y2&&(this.y2=e))}addX(t){this.addPoint(t,null)}addY(t){this.addPoint(null,t)}addQuadraticCurve(t,e,i,n,s,r){const o=t+2/3*(i-t),a=e+2/3*(n-e),l=o+1/3*(s-t),h=a+1/3*(r-e);this.addBezierCurve(t,e,o,a,l,h,s,r)}addBezierCurve(t,e,i,n,s,r,o,a){const l=[t,e],h=[i,n],c=[s,r],u=[o,a];let d;this.addPoint(l[0],l[1]),this.addPoint(u[0],u[1]);const f=(t,e)=>Math.pow(1-t,3)*l[e]+3*Math.pow(1-t,2)*t*h[e]+3*(1-t)*Math.pow(t,2)*c[e]+Math.pow(t,3)*u[e];for(d=0;d<=1;d++){const t=6*l[d]-12*h[d]+6*c[d],e=-3*l[d]+9*h[d]-9*c[d]+3*u[d],i=3*h[d]-3*l[d];if(0===e){if(0===t)continue;const e=-i/t;0{if(!t)throw new n.RERR("BadArgument","Invalid clef: "+t);const e=p.clefProperties.values[t];if(!e)throw new n.RERR("BadArgument","Invalid clef: "+t);return e}};p.clefProperties.values={treble:{line_shift:0},bass:{line_shift:6},tenor:{line_shift:4},alto:{line_shift:3},soprano:{line_shift:1},percussion:{line_shift:0},"mezzo-soprano":{line_shift:2},"baritone-c":{line_shift:5},"baritone-f":{line_shift:5},subbass:{line_shift:7},french:{line_shift:-1}},p.keyProperties=(t,e,i)=>{void 0===e&&(e="treble");const s={octave_shift:0};"object"==typeof i&&n.Merge(s,i);const r=t.split("/");if(r.length<2)throw new n.RERR("BadArguments",`Key must have note + octave and an optional glyph: ${t}`);const o=r[0].toUpperCase(),a=p.keyProperties.note_values[o];if(!a)throw new n.RERR("BadArguments","Invalid key name: "+o);a.octave&&(r[1]=a.octave);let l=parseInt(r[1],10);l+=-1*s.octave_shift;let h=(7*l-28+a.index)/2;h+=p.clefProperties(e).line_shift;let c=0;h<=0&&2*h%2==0&&(c=1),h>=6&&2*h%2==0&&(c=-1);const u=void 0!==a.int_val?12*l+a.int_val:null,d=a.code,f=a.shift_right;let m={};if(r.length>2&&r[2]){const t=r[2].toUpperCase();m=p.keyProperties.customNoteHeads[t]||{}}return{key:o,octave:l,line:h,int_value:u,accidental:a.accidental,code:d,stroke:c,shift_right:f,displaced:!1,...m}},p.keyProperties.note_values={C:{index:0,int_val:0,accidental:null},CN:{index:0,int_val:0,accidental:"n"},"C#":{index:0,int_val:1,accidental:"#"},"C##":{index:0,int_val:2,accidental:"##"},CB:{index:0,int_val:-1,accidental:"b"},CBB:{index:0,int_val:-2,accidental:"bb"},D:{index:1,int_val:2,accidental:null},DN:{index:1,int_val:2,accidental:"n"},"D#":{index:1,int_val:3,accidental:"#"},"D##":{index:1,int_val:4,accidental:"##"},DB:{index:1,int_val:1,accidental:"b"},DBB:{index:1,int_val:0,accidental:"bb"},E:{index:2,int_val:4,accidental:null},EN:{index:2,int_val:4,accidental:"n"},"E#":{index:2,int_val:5,accidental:"#"},"E##":{index:2,int_val:6,accidental:"##"},EB:{index:2,int_val:3,accidental:"b"},EBB:{index:2,int_val:2,accidental:"bb"},F:{index:3,int_val:5,accidental:null},FN:{index:3,int_val:5,accidental:"n"},"F#":{index:3,int_val:6,accidental:"#"},"F##":{index:3,int_val:7,accidental:"##"},FB:{index:3,int_val:4,accidental:"b"},FBB:{index:3,int_val:3,accidental:"bb"},G:{index:4,int_val:7,accidental:null},GN:{index:4,int_val:7,accidental:"n"},"G#":{index:4,int_val:8,accidental:"#"},"G##":{index:4,int_val:9,accidental:"##"},GB:{index:4,int_val:6,accidental:"b"},GBB:{index:4,int_val:5,accidental:"bb"},A:{index:5,int_val:9,accidental:null},AN:{index:5,int_val:9,accidental:"n"},"A#":{index:5,int_val:10,accidental:"#"},"A##":{index:5,int_val:11,accidental:"##"},AB:{index:5,int_val:8,accidental:"b"},ABB:{index:5,int_val:7,accidental:"bb"},B:{index:6,int_val:11,accidental:null},BN:{index:6,int_val:11,accidental:"n"},"B#":{index:6,int_val:12,accidental:"#"},"B##":{index:6,int_val:13,accidental:"##"},BB:{index:6,int_val:10,accidental:"b"},BBB:{index:6,int_val:9,accidental:"bb"},R:{index:6,int_val:9,rest:!0},X:{index:6,accidental:"",octave:4,code:"v3e",shift_right:5.5}},p.keyProperties.customNoteHeads={D0:{code:"v27",shift_right:0,stem_up_x_offset:0,stem_down_x_offset:0,stem_up_y_offset:-1,stem_down_y_offset:0},D1:{code:"v2d",shift_right:-.5},D2:{code:"v22",shift_right:-.5},D3:{code:"v70",shift_right:-.5},T0:{code:"v49",shift_right:-2,stem_up_y_offset:-4,stem_down_y_offset:4},T1:{code:"v93",shift_right:.5,stem_up_y_offset:-4,stem_down_y_offset:4},T2:{code:"v40",shift_right:.5,stem_up_y_offset:-4,stem_down_y_offset:4},T3:{code:"v7d",shift_right:.5,stem_up_y_offset:-4,stem_down_y_offset:4},X0:{code:"v92",stem_up_x_offset:-2,stem_down_x_offset:0,stem_up_y_offset:4,stem_down_y_offset:4},X1:{code:"v95",shift_right:-.5,stem_up_y_offset:4,stem_down_y_offset:4},X2:{code:"v3e",shift_right:.5,stem_up_y_offset:4,stem_down_y_offset:4},X3:{code:"v3b",shift_right:0,stem_up_x_offset:-1.2,stem_down_x_offset:0,stem_up_y_offset:-1,stem_down_y_offset:2},S1:{code:"vd3",shift_right:0},S2:{code:"vd2",shift_right:0},R1:{code:"vd5",shift_right:0},R2:{code:"vd4",shift_right:0}},p.integerToNote=t=>{if(void 0===t)throw new n.RERR("BadArguments","Undefined integer for integerToNote");if(t<-2)throw new n.RERR("BadArguments",`integerToNote requires integer > -2: ${t}`);const e=p.integerToNote.table[t];if(!e)throw new n.RERR("BadArguments",`Unknown note value for integer: ${t}`);return e},p.integerToNote.table={0:"C",1:"C#",2:"D",3:"D#",4:"E",5:"F",6:"F#",7:"G",8:"G#",9:"A",10:"A#",11:"B"},p.tabToGlyph=(t,e=1)=>{let i=null,n=0,s=0;if("X"===t.toString().toUpperCase()){const t=new f("v7f",p.DEFAULT_TABLATURE_FONT_SCALE).getMetrics();i="v7f",n=t.width,s=-t.height/2}else n=p.textWidth(t.toString());return{text:t,code:i,getWidth:()=>n*e,shift_y:s}},p.textWidth=t=>7*t.toString().length,p.articulationCodes=t=>p.articulationCodes.articulations[t],p.articulationCodes.articulations={"a.":{code:"v23",between_lines:!0},av:{code:"v28",between_lines:!0},"a>":{code:"v42",between_lines:!0},"a-":{code:"v25",between_lines:!0},"a^":{code:"va",between_lines:!1},"a+":{code:"v8b",between_lines:!1},ao:{code:"v94",between_lines:!1},ah:{code:"vb9",between_lines:!1},"a@a":{code:"v43",between_lines:!1},"a@u":{code:"v5b",between_lines:!1},"a|":{code:"v75",between_lines:!1},am:{code:"v97",between_lines:!1},"a,":{code:"vb3",between_lines:!1}},p.accidentalCodes=t=>p.accidentalCodes.accidentals[t],p.accidentalCodes.accidentals={"#":{code:"v18",parenRightPaddingAdjustment:-1},"##":{code:"v7f",parenRightPaddingAdjustment:-1},b:{code:"v44",parenRightPaddingAdjustment:-2},bb:{code:"v26",parenRightPaddingAdjustment:-2},n:{code:"v4e",parenRightPaddingAdjustment:-1},"{":{code:"v9c",parenRightPaddingAdjustment:-1},"}":{code:"v84",parenRightPaddingAdjustment:-1},db:{code:"v9e",parenRightPaddingAdjustment:-1},d:{code:"vab",parenRightPaddingAdjustment:0},bbs:{code:"v90",parenRightPaddingAdjustment:-1},"++":{code:"v51",parenRightPaddingAdjustment:-1},"+":{code:"v78",parenRightPaddingAdjustment:-1},"+-":{code:"v8d",parenRightPaddingAdjustment:-1},"++-":{code:"v7a",parenRightPaddingAdjustment:-1},bs:{code:"vb7",parenRightPaddingAdjustment:-1},bss:{code:"v39",parenRightPaddingAdjustment:-1},o:{code:"vd0",parenRightPaddingAdjustment:-1},k:{code:"vd1",parenRightPaddingAdjustment:-1},ashs:{code:"vd6",parenRightPaddingAdjustment:-1},afhf:{code:"vd7",parenRightPaddingAdjustment:-1}},p.accidentalColumnsTable={1:{a:[1],b:[1]},2:{a:[1,2]},3:{a:[1,3,2],b:[1,2,1],second_on_bottom:[1,2,3]},4:{a:[1,3,4,2],b:[1,2,3,1],spaced_out_tetrachord:[1,2,1,2]},5:{a:[1,3,5,4,2],b:[1,2,4,3,1],spaced_out_pentachord:[1,2,3,2,1],very_spaced_out_pentachord:[1,2,1,2,1]},6:{a:[1,3,5,6,4,2],b:[1,2,4,5,3,1],spaced_out_hexachord:[1,3,2,1,3,2],very_spaced_out_hexachord:[1,2,1,2,1,2]}},p.ornamentCodes=t=>p.ornamentCodes.ornaments[t],p.ornamentCodes.ornaments={mordent:{code:"v1e"},mordent_inverted:{code:"v45"},turn:{code:"v72"},turn_inverted:{code:"v33"},tr:{code:"v1f"},upprall:{code:"v60"},downprall:{code:"vb4"},prallup:{code:"v6d"},pralldown:{code:"v2c"},upmordent:{code:"v29"},downmordent:{code:"v68"},lineprall:{code:"v20"},prallprall:{code:"v86"}},p.keySignature=t=>{const e=p.keySignature.keySpecs[t];if(!e)throw new n.RERR("BadKeySignature",`Bad key signature spec: '${t}'`);if(!e.acc)return[];const i=p.keySignature.accidentalList(e.acc),s=[];for(let t=0;t({b:[2,.5,2.5,1,3,1.5,3.5],"#":[0,1.5,-.5,1,2.5,.5,2]}[t]),p.parseNoteDurationString=t=>{if("string"!=typeof t)return null;const e=/(\d*\/?\d+|[a-z])(d*)([nrhms]|$)/.exec(t);if(!e)return null;const i=e[1],n=e[2].length;let s=e[3];return 0===s.length&&(s="n"),{duration:i,dots:n,type:s}},p.parseNoteStruct=t=>{const e=t.duration,i=p.parseNoteDurationString(e);if(!i)return null;let n=p.durationToTicks(i.duration);if(null==n)return null;let s=t.type;const r=[];if(s){if(!p.getGlyphProps.validTypes[s])return null}else s=i.type||"n",void 0!==t.keys&&t.keys.forEach(((t,e)=>{const i=t.split("/");i&&3===i.length&&(r[e]=i[2])}));const o=t.dots?t.dots:i.dots;if("number"!=typeof o)return null;let a=n;for(let t=0;t{const e=p.durationAliases[t];if(void 0!==e&&(t=e),void 0===p.durationToTicks.durations[t])throw new n.RERR("BadArguments",`The provided duration is not valid: ${t}`);return t},p.durationToFraction=t=>(new s).parse(p.sanitizeDuration(t)),p.durationToNumber=t=>p.durationToFraction(t).value(),p.durationToTicks=t=>{t=p.sanitizeDuration(t);const e=p.durationToTicks.durations[t];return void 0===e?null:e},p.durationToTicks.durations={"1/2":2*p.RESOLUTION,1:p.RESOLUTION/1,2:p.RESOLUTION/2,4:p.RESOLUTION/4,8:p.RESOLUTION/8,16:p.RESOLUTION/16,32:p.RESOLUTION/32,64:p.RESOLUTION/64,128:p.RESOLUTION/128,256:p.RESOLUTION/256},p.durationAliases={w:"1",h:"2",q:"4",b:"256"},p.getGlyphProps=(t,e)=>{t=p.sanitizeDuration(t);const i=p.getGlyphProps.duration_codes[t];if(void 0===i)return null;e||(e="n");let n=i.type[e];if(void 0===n){const t=p.keyProperties.customNoteHeads[e.toUpperCase()];if(void 0===t)return null;n={code_head:t.code,...t}}return{...i.common,...n}},p.getGlyphProps.validTypes={n:{name:"note"},r:{name:"rest"},h:{name:"harmonic"},m:{name:"muted"},s:{name:"slash"}},p.getGlyphProps.duration_codes={"1/2":{common:{getWidth(t=p.DEFAULT_NOTATION_FONT_SCALE){return new f(this.code_head||"v53",t).getMetrics().width},stem:!1,stem_offset:0,flag:!1,stem_up_extension:-p.STEM_HEIGHT,stem_down_extension:-p.STEM_HEIGHT,tabnote_stem_up_extension:-p.STEM_HEIGHT,tabnote_stem_down_extension:-p.STEM_HEIGHT,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"v53"},h:{code_head:"v59"},m:{code_head:"vf",stem_offset:0},r:{code_head:"v31",rest:!0,position:"B/5",dot_shiftY:.5},s:{getWidth:()=>p.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},1:{common:{getWidth(t=p.DEFAULT_NOTATION_FONT_SCALE){return new f(this.code_head||"v1d",t).getMetrics().width},stem:!1,stem_offset:0,flag:!1,stem_up_extension:-p.STEM_HEIGHT,stem_down_extension:-p.STEM_HEIGHT,tabnote_stem_up_extension:-p.STEM_HEIGHT,tabnote_stem_down_extension:-p.STEM_HEIGHT,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"v1d"},h:{code_head:"v46"},m:{code_head:"v92",stem_offset:-3},r:{code_head:"v5c",rest:!0,position:"D/5",dot_shiftY:.5},s:{getWidth:()=>p.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},2:{common:{getWidth(t=p.DEFAULT_NOTATION_FONT_SCALE){return new f(this.code_head||"v81",t).getMetrics().width},stem:!0,stem_offset:0,flag:!1,stem_up_extension:0,stem_down_extension:0,tabnote_stem_up_extension:0,tabnote_stem_down_extension:0,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"v81"},h:{code_head:"v2d"},m:{code_head:"v95",stem_offset:-3},r:{code_head:"vc",stem:!1,rest:!0,position:"B/4",dot_shiftY:-.5},s:{getWidth:()=>p.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},4:{common:{getWidth(t=p.DEFAULT_NOTATION_FONT_SCALE){return new f(this.code_head||"vb",t).getMetrics().width},stem:!0,stem_offset:0,flag:!1,stem_up_extension:0,stem_down_extension:0,tabnote_stem_up_extension:0,tabnote_stem_down_extension:0,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"vb"},h:{code_head:"v22"},m:{code_head:"v3e",stem_offset:-3},r:{code_head:"v7c",stem:!1,rest:!0,position:"B/4",dot_shiftY:-.5,line_above:1.5,line_below:1.5},s:{getWidth:()=>p.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},8:{common:{getWidth(t=p.DEFAULT_NOTATION_FONT_SCALE){return new f(this.code_head||"vb",t).getMetrics().width},stem:!0,stem_offset:0,flag:!0,beam_count:1,code_flag_upstem:"v54",code_flag_downstem:"v9a",stem_up_extension:0,stem_down_extension:0,tabnote_stem_up_extension:0,tabnote_stem_down_extension:0,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"vb"},h:{code_head:"v22"},m:{code_head:"v3e"},r:{code_head:"va5",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-.5,line_above:1,line_below:1},s:{getWidth:()=>p.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},16:{common:{beam_count:2,getWidth(t=p.DEFAULT_NOTATION_FONT_SCALE){return new f(this.code_head||"vb",t).getMetrics().width},stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"v3f",code_flag_downstem:"v8f",stem_up_extension:0,stem_down_extension:0,tabnote_stem_up_extension:0,tabnote_stem_down_extension:0,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"vb"},h:{code_head:"v22"},m:{code_head:"v3e"},r:{code_head:"v3c",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-.5,line_above:1,line_below:2},s:{getWidth:()=>p.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},32:{common:{beam_count:3,getWidth(t=p.DEFAULT_NOTATION_FONT_SCALE){return new f(this.code_head||"vb",t).getMetrics().width},stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"v47",code_flag_downstem:"v2a",stem_up_extension:9,stem_down_extension:9,tabnote_stem_up_extension:8,tabnote_stem_down_extension:5,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"vb"},h:{code_head:"v22"},m:{code_head:"v3e"},r:{code_head:"v55",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-1.5,line_above:2,line_below:2},s:{getWidth:()=>p.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},64:{common:{beam_count:4,getWidth(t=p.DEFAULT_NOTATION_FONT_SCALE){return new f(this.code_head||"vb",t).getMetrics().width},stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"va9",code_flag_downstem:"v58",stem_up_extension:13,stem_down_extension:13,tabnote_stem_up_extension:12,tabnote_stem_down_extension:9,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"vb"},h:{code_head:"v22"},m:{code_head:"v3e"},r:{code_head:"v38",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-1.5,line_above:2,line_below:3},s:{getWidth:()=>p.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},128:{common:{beam_count:5,getWidth(t=p.DEFAULT_NOTATION_FONT_SCALE){return new f(this.code_head||"vb",t).getMetrics().width},stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"v9b",code_flag_downstem:"v30",stem_up_extension:22,stem_down_extension:22,tabnote_stem_up_extension:21,tabnote_stem_down_extension:18,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"vb"},h:{code_head:"v22"},m:{code_head:"v3e"},r:{code_head:"vaa",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:1.5,line_above:3,line_below:3},s:{getWidth:()=>p.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}}},p.smufl={},p.smufl.to_code_points={bracketTop:"v1b",bracketBottom:"v10",barlineTick:"v6f",segno:"v8c",coda:"v4d",gClef:"v83",cClef:"vad",fClef:"v79",unpitchedPercussionClef1:"v59","6stringTabClef":"v2f",timeSig0:"v0",timeSig1:"v1",timeSig2:"v2",timeSig3:"v3",timeSig4:"v4",timeSig5:"v5",timeSig6:"v6",timeSig7:"v7",timeSig8:"v8",timeSig9:"v9",timeSigCommon:"v41",timeSigCutCommon:"vb6",noteheadDoubleWhole:"v53",noteheadWhole:"v1d",noteheadHalf:"v81",noteheadBlack:"vb",noteheadXWhole:"v92",noteheadXHalf:"v95",noteheadXBlack:"v3e",noteheadCircleX:"v3b",noteheadTriangleUpWhole:"v49",noteheadTriangleUpHalf:"v93",noteheadTriangleUpBlack:"v40",noteheadDiamondWhole:"v46",noteheadDiamondHalf:"v2d",noteheadDiamondBlack:"v22",augmentationDot:"v23",tremolo1:"v74",flag8thUp:"v54",flag8thDown:"v9a",flag16thUp:"v3f",flag16thDown:"v8f",flag32ndUp:"v47",flag32ndDown:"v2a",flag64thUp:"va9",flag64thDown:"v58",flag128thUp:"v9b",flag128thDown:"v30",accidentalFlat:"v44",accidentalNatural:"v4e",accidentalSharp:"v18",accidentalDoubleSharp:"v7f",accidentalDoubleFlat:"v26",accidentalParensLeft:"v9c",accidentalParensRight:"v84",accidentalQuarterToneFlatStein:"vab",accidentalThreeQuarterTonesFlatZimmermann:"v9e",accidentalQuarterToneSharpStein:"v78",accidentalThreeQuarterTonesSharpStein:"v51",accidentalBuyukMucennebFlat:"v39",accidentalBakiyeFlat:"vb7",accidentalKomaSharp:"v51",accidentalKucukMucennebSharp:"v8d",accidentalKoron:"vd1",accidentalSori:"vd0",articAccentAbove:"v42",articAccentBelow:"v42",articTenutoAbove:"v25",articTenutoBelow:"v25",articStaccatoAbove:"v23",articStaccatoBelow:"v23",articStaccatissimoAbove:"v28",articMarcatoAbove:"va",fermataAbove:"v43",fermataBelow:"v5b",breathMarkComma:"v6c",breathMarkUpbow:"v8a",caesura:"v34",caesuraCurved:"v4b",restMaxima:"v59",restDoubleWhole:"v31",restWhole:"v5c",restHalf:"vc",restQuarter:"v7c",rest8th:"va5",rest16th:"v3c",rest32nd:"v55",rest64th:"v38",rest128th:"vaa",dynamicPiano:"vbf",dynamicMezzo:"v62",dynamicForte:"vba",dynamicRinforzando:"vba",dynamicSforzando:"v4a",dynamicZ:"v80",ornamentTrill:"v1f",ornamentTurn:"v72",ornamentTurnSlash:"v33",ornamentMordent:"v45",ornamentMordentInverted:"v1e",ornamentTremblement:"v86",ornamentPrecompAppoggTrill:"v20",ornamentPrecompSlideTrillDAnglebert:"v60",ornamentPrecompSlideTrillBach:"v29",ornamentPrecompTrillSuffixDandrieu:"v6d",ornamentPrecompDoubleCadenceUpperPrefix:"vb4",ornamentPrecompDoubleCadenceUpperPrefixTurn:"v68",ornamentPrecompTrillLowerSuffix:"v2c",stringsDownBow:"v94",stringsUpBow:"v75",stringsHarmonic:"vb9",pluckedSnapPizzicatoAbove:"v94",pluckedLeftHandPizzicato:"v8b",keyboardPedalPed:"v36",keyboardPedalUp:"v5d",pictChokeCymbal:"vb3",wiggleArpeggiatoUp:"va3",arrowheadBlackUp:"vc3",arrowheadBlackDown:"v52"},p.TIME4_4={num_beats:4,beat_value:4,resolution:p.RESOLUTION};class m{static get WIDTH(){return 600}static get HEIGHT(){return 400}static get CANVAS_BROWSER_SIZE_LIMIT(){return 32767}static SanitizeCanvasDims(t,e){return Math.max(t,e)>this.CANVAS_BROWSER_SIZE_LIMIT&&(n.W("Canvas dimensions exceed browser limit. Cropping to "+this.CANVAS_BROWSER_SIZE_LIMIT),t>this.CANVAS_BROWSER_SIZE_LIMIT&&(t=this.CANVAS_BROWSER_SIZE_LIMIT),e>this.CANVAS_BROWSER_SIZE_LIMIT&&(e=this.CANVAS_BROWSER_SIZE_LIMIT)),[t,e]}constructor(t){this.vexFlowCanvasContext=t,t.canvas?this.canvas=t.canvas:this.canvas={width:m.WIDTH,height:m.HEIGHT}}clear(){this.vexFlowCanvasContext.clearRect(0,0,this.canvas.width,this.canvas.height)}openGroup(){}closeGroup(){}add(){}setFont(t,e,i){return this.vexFlowCanvasContext.font=(i||"")+" "+e+"pt "+t,this}setRawFont(t){return this.vexFlowCanvasContext.font=t,this}setFillStyle(t){return this.vexFlowCanvasContext.fillStyle=t,this}setBackgroundFillStyle(t){return this.background_fillStyle=t,this}setStrokeStyle(t){return this.vexFlowCanvasContext.strokeStyle=t,this}setShadowColor(t){return this.vexFlowCanvasContext.shadowColor=t,this}setShadowBlur(t){return this.vexFlowCanvasContext.shadowBlur=t,this}setLineWidth(t){return this.vexFlowCanvasContext.lineWidth=t,this}setLineCap(t){return this.vexFlowCanvasContext.lineCap=t,this}setLineDash(t){return this.vexFlowCanvasContext.lineDash=t,this}scale(t,e){return this.vexFlowCanvasContext.scale(parseFloat(t),parseFloat(e))}resize(t,e){return[t,e]=this.SanitizeCanvasDims(parseInt(t,10),parseInt(e,10)),this.vexFlowCanvasContext.resize(t,e)}rect(t,e,i,n){return this.vexFlowCanvasContext.rect(t,e,i,n)}fillRect(t,e,i,n){return this.vexFlowCanvasContext.fillRect(t,e,i,n)}clearRect(t,e,i,n){return this.vexFlowCanvasContext.clearRect(t,e,i,n)}beginPath(){return this.vexFlowCanvasContext.beginPath()}moveTo(t,e){return this.vexFlowCanvasContext.moveTo(t,e)}lineTo(t,e){return this.vexFlowCanvasContext.lineTo(t,e)}bezierCurveTo(t,e,i,n,s,r){return this.vexFlowCanvasContext.bezierCurveTo(t,e,i,n,s,r)}quadraticCurveTo(t,e,i,n){return this.vexFlowCanvasContext.quadraticCurveTo(t,e,i,n)}arc(t,e,i,n,s,r){return this.vexFlowCanvasContext.arc(t,e,i,n,s,r)}glow(){return this.vexFlowCanvasContext.glow()}fill(){return this.vexFlowCanvasContext.fill()}stroke(){return this.vexFlowCanvasContext.stroke()}closePath(){return this.vexFlowCanvasContext.closePath()}measureText(t){return this.vexFlowCanvasContext.measureText(t)}fillText(t,e,i){return this.vexFlowCanvasContext.fillText(t,e,i)}save(){return this.vexFlowCanvasContext.save()}restore(){return this.vexFlowCanvasContext.restore()}}class b{constructor(t){this.element=t,this.paper=Raphael(t),this.path="",this.pen={x:0,y:0},this.lineWidth=1,this.state={scale:{x:1,y:1},font_family:"Arial",font_size:8,font_weight:800},this.attributes={"stroke-width":.3,fill:"black",stroke:"black",font:"10pt Arial"},this.background_attributes={"stroke-width":0,fill:"white",stroke:"white",font:"10pt Arial"},this.shadow_attributes={width:0,color:"black"},this.state_stack=[]}openGroup(){}closeGroup(){}add(){}setFont(t,e,i){return this.state.font_family=t,this.state.font_size=e,this.state.font_weight=i,this.attributes.font=(this.state.font_weight||"")+" "+this.state.font_size*this.state.scale.x+"pt "+this.state.font_family,this}setRawFont(t){return this.attributes.font=t,this}setFillStyle(t){return this.attributes.fill=t,this}setBackgroundFillStyle(t){return this.background_attributes.fill=t,this.background_attributes.stroke=t,this}setStrokeStyle(t){return this.attributes.stroke=t,this}setShadowColor(t){return this.shadow_attributes.color=t,this}setShadowBlur(t){return this.shadow_attributes.width=t,this}setLineWidth(t){this.attributes["stroke-width"]=t,this.lineWidth=t}setLineDash(){return this}setLineCap(){return this}scale(t,e){return this.state.scale={x:t,y:e},this.attributes.transform="S"+t+","+e+",0,0",this.attributes.scale=t+","+e+",0,0",this.attributes.font=this.state.font_size*this.state.scale.x+"pt "+this.state.font_family,this.background_attributes.transform="S"+t+","+e+",0,0",this.background_attributes.font=this.state.font_size*this.state.scale.x+"pt "+this.state.font_family,this}clear(){this.paper.clear()}resize(t,e){return this.element.style.width=t,this.paper.setSize(t,e),this}setViewBox(t){this.paper.canvas.setAttribute("viewBox",t)}rect(t,e,i,n){return n<0&&(e+=n,n=-n),this.paper.rect(t,e,i-.5,n-.5).attr(this.attributes).attr("fill","none").attr("stroke-width",this.lineWidth),this}fillRect(t,e,i,n){return n<0&&(e+=n,n=-n),this.paper.rect(t,e,i-.5,n-.5).attr(this.attributes),this}clearRect(t,e,i,n){return n<0&&(e+=n,n=-n),this.paper.rect(t,e,i-.5,n-.5).attr(this.background_attributes),this}beginPath(){return this.path="",this.pen.x=0,this.pen.y=0,this}moveTo(t,e){return this.path+="M"+t+","+e,this.pen.x=t,this.pen.y=e,this}lineTo(t,e){return this.path+="L"+t+","+e,this.pen.x=t,this.pen.y=e,this}bezierCurveTo(t,e,i,n,s,r){return this.path+="C"+t+","+e+","+i+","+n+","+s+","+r,this.pen.x=s,this.pen.y=r,this}quadraticCurveTo(t,e,i,n){return this.path+="Q"+t+","+e+","+i+","+n,this.pen.x=i,this.pen.y=n,this}arc(t,e,i,n,s,r){function o(t){for(;t<0;)t+=2*Math.PI;for(;t>2*Math.PI;)t-=2*Math.PI;return t}if((n=o(n))>(s=o(s))){const t=n;n=s,s=t,r=!r}const a=s-n;return a>Math.PI?(this.arcHelper(t,e,i,n,n+a/2,r),this.arcHelper(t,e,i,n+a/2,s,r)):this.arcHelper(t,e,i,n,s,r),this}arcHelper(t,e,i,n,s,r){const o=t+i*Math.cos(n),a=e+i*Math.sin(n),l=t+i*Math.cos(s),h=e+i*Math.sin(s);let c=0,u=0;r?(u=1,s-nMath.PI&&(c=1),this.path+="M"+o+","+a+",A"+i+","+i+",0,"+c+","+u+","+l+","+h+"M"+this.pen.x+","+this.pen.y}glow(){const t=this.paper.set();if(this.shadow_attributes.width>0){const e=this.shadow_attributes,i=e.width/2;for(let n=1;n<=i;n++)t.push(this.paper.path(this.path).attr({stroke:e.color,"stroke-linejoin":"round","stroke-linecap":"round","stroke-width":+(e.width/i*n).toFixed(3),opacity:+((e.opacity||.3)/i).toFixed(3),transform:this.attributes.transform,scale:this.attributes.scale}))}return t}fill(){const t=this.paper.path(this.path).attr(this.attributes).attr("stroke-width",0);return this.glow(t),this}stroke(){const t=this.lineWidth*(this.state.scale.x+this.state.scale.y)/2,e=this.paper.path(this.path).attr(this.attributes).attr("fill","none").attr("stroke-width",t);return this.glow(e),this}closePath(){return this.path+="Z",this}measureText(t){const e=this.paper.text(0,0,t).attr(this.attributes).attr("fill","none").attr("stroke","none"),i=e.getBBox();return e.remove(),{width:i.width,height:i.height}}fillText(t,e,i){return this.paper.text(e+this.measureText(t).width/2,i-this.state.font_size/(2.25*this.state.scale.y),t).attr(this.attributes),this}save(){return this.state_stack.push({state:{font_family:this.state.font_family},attributes:{font:this.attributes.font,fill:this.attributes.fill,stroke:this.attributes.stroke,"stroke-width":this.attributes["stroke-width"]},shadow_attributes:{width:this.shadow_attributes.width,color:this.shadow_attributes.color}}),this}restore(){const t=this.state_stack.pop();return this.state.font_family=t.state.font_family,this.attributes.font=t.attributes.font,this.attributes.fill=t.attributes.fill,this.attributes.stroke=t.attributes.stroke,this.attributes["stroke-width"]=t.attributes["stroke-width"],this.shadow_attributes.width=t.shadow_attributes.width,this.shadow_attributes.color=t.shadow_attributes.color,this}}const g={path:{x:!0,y:!0,width:!0,height:!0},rect:{},text:{width:!0,height:!0}};{const t={"font-family":!0,"font-weight":!0,"font-style":!0,"font-size":!0};n.Merge(g.rect,t),n.Merge(g.path,t)}class y{constructor(t){this.element=t,this.svgNS="http://www.w3.org/2000/svg";const e=this.create("svg");this.element.appendChild(e),this.svg=e,this.groups=[this.svg],this.parent=this.svg,this.path="",this.pen={x:NaN,y:NaN},this.lineWidth=1,this.state={scale:{x:1,y:1},"font-family":"Arial","font-size":"8pt","font-weight":"normal"},this.attributes={"stroke-width":.3,fill:"black",stroke:"black","stroke-dasharray":"none","font-family":"Arial","font-size":"10pt","font-weight":"normal","font-style":"normal"},this.background_attributes={"stroke-width":0,fill:"white",stroke:"white","stroke-dasharray":"none","font-family":"Arial","font-size":"10pt","font-weight":"normal","font-style":"normal"},this.shadow_attributes={width:0,color:"black"},this.state_stack=[],this.iePolyfill()}create(t){return document.createElementNS(this.svgNS,t)}openGroup(t,e,i){const s=this.create("g");return this.groups.push(s),this.parent.appendChild(s),this.parent=s,t&&s.setAttribute("class",n.Prefix(t)),e&&s.setAttribute("id",n.Prefix(e)),i&&i.pointerBBox&&s.setAttribute("pointer-events","bounding-box"),s}closeGroup(){this.groups.pop(),this.parent=this.groups[this.groups.length-1]}add(t){this.parent.appendChild(t)}iePolyfill(){"undefined"!=typeof navigator&&(this.ie=/MSIE 9/i.test(navigator.userAgent)||/MSIE 10/i.test(navigator.userAgent)||/rv:11\.0/i.test(navigator.userAgent)||/Trident/i.test(navigator.userAgent))}setFont(t,e,i){let s=!1,r=!1,o="normal";"string"==typeof i&&(-1!==i.indexOf("italic")&&(i=i.replace(/italic/g,""),r=!0),-1!==i.indexOf("bold")&&(i=i.replace(/bold/g,""),s=!0),i=i.replace(/ /g,"")),o=r?"italic":o;const a={"font-family":t,"font-size":e+"pt","font-weight":i=void 0===(i=s?"bold":i)||""===i?"normal":i,"font-style":o};return this.fontSize=Number(e),n.Merge(this.attributes,a),n.Merge(this.state,a),this}setRawFont(t){const e=(t=t.trim()).split(" ");return this.attributes["font-family"]=e[1],this.state["font-family"]=e[1],this.attributes["font-size"]=e[0],this.state["font-size"]=e[0],this.fontSize=Number(e[0].match(/\d+/)),this}setFillStyle(t){return this.attributes.fill=t,this}setBackgroundFillStyle(t){return this.background_attributes.fill=t,this.background_attributes.stroke=t,this}setStrokeStyle(t){return this.attributes.stroke=t,this}setShadowColor(t){return this.shadow_attributes.color=t,this}setShadowBlur(t){return this.shadow_attributes.width=t,this}setLineWidth(t){this.attributes["stroke-width"]=t,this.lineWidth=t}setLineDash(t){if("[object Array]"===Object.prototype.toString.call(t))return t=t.join(", "),this.attributes["stroke-dasharray"]=t,this;throw new n.RERR("ArgumentError","lineDash must be an array of integers.")}setLineCap(t){return this.attributes["stroke-linecap"]=t,this}resize(t,e){this.width=t,this.height=e,this.element.style.width=t;const i={width:t,height:e};return this.applyAttributes(this.svg,i),this.scale(this.state.scale.x,this.state.scale.y),this}scale(t,e){this.state.scale={x:t,y:e};const i=this.width/t,n=this.height/e;return this.setViewBox(0,0,i,n),this}setViewBox(...t){if(1===t.length){const[e]=t;this.svg.setAttribute("viewBox",e)}else{const[e,i,n,s]=t,r=e+" "+i+" "+n+" "+s;this.svg.setAttribute("viewBox",r)}}applyAttributes(t,e){const i=g[t.nodeName];return Object.keys(e).forEach((n=>{i&&i[n]||t.setAttributeNS(null,n,e[n])})),t}clear(){for(;this.svg.lastChild;)this.svg.removeChild(this.svg.lastChild);this.scale(this.state.scale.x,this.state.scale.y)}rect(t,e,i,s,r){s<0&&(e+=s,s*=-1);const o=this.create("rect");return void 0===r&&(r={fill:"none","stroke-width":this.lineWidth,stroke:"black"}),n.Merge(r,{x:t,y:e,width:i,height:s}),this.applyAttributes(o,r),this.add(o),this}fillRect(t,e,i,n){return n<0&&(e+=n,n*=-1),this.rect(t,e,i,n,this.attributes),this}clearRect(t,e,i,n){return this.rect(t,e,i,n,this.background_attributes),this}beginPath(){return this.path="",this.pen.x=NaN,this.pen.y=NaN,this}moveTo(t,e){return this.path+="M"+t+" "+e,this.pen.x=t,this.pen.y=e,this}lineTo(t,e){return this.path+="L"+t+" "+e,this.pen.x=t,this.pen.y=e,this}bezierCurveTo(t,e,i,n,s,r){return this.path+="C"+t+" "+e+","+i+" "+n+","+s+" "+r,this.pen.x=s,this.pen.y=r,this}quadraticCurveTo(t,e,i,n){return this.path+="Q"+t+" "+e+","+i+" "+n,this.pen.x=i,this.pen.y=n,this}arc(t,e,i,n,s,r){function o(t){for(;t<0;)t+=2*Math.PI;for(;t>2*Math.PI;)t-=2*Math.PI;return t}if((n=o(n))>(s=o(s))){const t=n;n=s,s=t,r=!r}const a=s-n;return a>Math.PI?(this.arcHelper(t,e,i,n,n+a/2,r),this.arcHelper(t,e,i,n+a/2,s,r)):this.arcHelper(t,e,i,n,s,r),this}arcHelper(t,e,i,n,s,r){const o=t+i*Math.cos(n),a=e+i*Math.sin(n),l=t+i*Math.cos(s),h=e+i*Math.sin(s);let c=0,u=0;r?(u=1,s-nMath.PI&&(c=1),this.path+="M"+o+" "+a+" A"+i+" "+i+" 0 "+c+" "+u+" "+l+" "+h,isNaN(this.pen.x)||isNaN(this.pen.y)||(this.peth+="M"+this.pen.x+" "+this.pen.y)}closePath(){return this.path+="Z",this}glow(){if(this.shadow_attributes.width>0){const t=this.shadow_attributes,e=t.width/2;for(let i=1;i<=e;i++){const n={stroke:t.color,"stroke-linejoin":"round","stroke-linecap":"round","stroke-width":+(.4*t.width/e*i).toFixed(3),opacity:+((t.opacity||.3)/e).toFixed(3)},s=this.create("path");n.d=this.path,this.applyAttributes(s,n),this.add(s)}}return this}fill(t){this.glow();const e=this.create("path");return void 0===t&&(n.Merge(t={},this.attributes),t.stroke="none"),t.d=this.path,this.applyAttributes(e,t),this.add(e),this}stroke(){this.glow();const t=this.create("path"),e={};return n.Merge(e,this.attributes),e.fill="none",e["stroke-width"]=this.lineWidth,e.d=this.path,this.applyAttributes(t,e),this.add(t),this}measureText(t){const e=this.create("text");if("function"!=typeof e.getBBox)return{x:0,y:0,width:0,height:0};e.textContent=t,this.applyAttributes(e,this.attributes),this.svg.appendChild(e);let i=e.getBBox();return this.ie&&""!==t&&"italic"===this.attributes["font-style"]&&(i=this.ieMeasureTextFix(i,t)),this.svg.removeChild(e),i}ieMeasureTextFix(t){const e=1.196*Number(this.fontSize)+1.9598,i=t.width-e,n=t.height-1.5;return{x:t.x,y:t.y,width:i,height:n}}fillText(t,e,i){if(!t||t.length<=0)return;const s={};n.Merge(s,this.attributes),s.stroke="none",s.x=e,s.y=i;const r=this.create("text");r.textContent=t,this.applyAttributes(r,s),this.add(r)}save(){return this.state_stack.push({state:{"font-family":this.state["font-family"],"font-weight":this.state["font-weight"],"font-style":this.state["font-style"],"font-size":this.state["font-size"],scale:this.state.scale},attributes:{"font-family":this.attributes["font-family"],"font-weight":this.attributes["font-weight"],"font-style":this.attributes["font-style"],"font-size":this.attributes["font-size"],fill:this.attributes.fill,stroke:this.attributes.stroke,"stroke-width":this.attributes["stroke-width"],"stroke-dasharray":this.attributes["stroke-dasharray"]},shadow_attributes:{width:this.shadow_attributes.width,color:this.shadow_attributes.color},lineWidth:this.lineWidth}),this}restore(){const t=this.state_stack.pop();return this.state["font-family"]=t.state["font-family"],this.state["font-weight"]=t.state["font-weight"],this.state["font-style"]=t.state["font-style"],this.state["font-size"]=t.state["font-size"],this.state.scale=t.state.scale,this.attributes["font-family"]=t.attributes["font-family"],this.attributes["font-weight"]=t.attributes["font-weight"],this.attributes["font-style"]=t.attributes["font-style"],this.attributes["font-size"]=t.attributes["font-size"],this.attributes.fill=t.attributes.fill,this.attributes.stroke=t.attributes.stroke,this.attributes["stroke-width"]=t.attributes["stroke-width"],this.attributes["stroke-dasharray"]=t.attributes["stroke-dasharray"],this.shadow_attributes.width=t.shadow_attributes.width,this.shadow_attributes.color=t.shadow_attributes.color,this.lineWidth=t.lineWidth,this}}let S=null;class v{static get Backends(){return{CANVAS:1,RAPHAEL:2,SVG:3,VML:4}}static get LineEndType(){return{NONE:1,UP:2,DOWN:3}}static get USE_CANVAS_PROXY(){return!1}static get lastContext(){return S}static set lastContext(t){S=t}static buildContext(t,e,i,n,s){const r=new v(t,e);i&&n&&r.resize(i,n),s||(s="#FFF");const o=r.getContext();return o.setBackgroundFillStyle(s),v.lastContext=o,o}static getCanvasContext(t,e,i,n){return v.buildContext(t,v.Backends.CANVAS,e,i,n)}static getRaphaelContext(t,e,i,n){return v.buildContext(t,v.Backends.RAPHAEL,e,i,n)}static getSVGContext(t,e,i,n){return v.buildContext(t,v.Backends.SVG,e,i,n)}static bolsterCanvasContext(t){return v.USE_CANVAS_PROXY?new m(t):(t.vexFlowCanvasContext=t,["clear","setFont","setRawFont","setFillStyle","setBackgroundFillStyle","setStrokeStyle","setShadowColor","setShadowBlur","setLineWidth","setLineCap","setLineDash","openGroup","closeGroup","getGroup"].forEach((e=>{t[e]=t[e]||m.prototype[e]})),t)}static drawDashedLine(t,e,i,n,s,r){t.beginPath();const o=n-e,a=s-i,l=Math.atan2(a,o);let h=e,c=i;t.moveTo(e,i);let u=0,d=!0;for(;!(o<0?h<=n:h>=n)||!(a<0?c<=s:c>=s);){const e=r[u++%r.length],i=h+Math.cos(l)*e;h=o<0?Math.max(n,i):Math.min(n,i);const f=c+Math.sin(l)*e;c=a<0?Math.max(s,f):Math.min(s,f),d?t.lineTo(h,c):t.moveTo(h,c),d=!d}t.closePath(),t.stroke()}constructor(t,e){if(this.elementId=t,!this.elementId)throw new n.RERR("BadArgument","Invalid id for renderer.");if(this.element=document.getElementById(t),this.element||(this.element=t),this.ctx=null,this.paper=null,this.backend=e,this.backend===v.Backends.CANVAS){if(!this.element.getContext)throw new n.RERR("BadElement",`Can't get canvas context from element: ${t}`);this.ctx=v.bolsterCanvasContext(this.element.getContext("2d"))}else if(this.backend===v.Backends.RAPHAEL)this.ctx=new b(this.element);else{if(this.backend!==v.Backends.SVG)throw new n.RERR("InvalidBackend",`No support for backend: ${this.backend}`);this.ctx=new y(this.element)}}resize(t,e){if(this.backend===v.Backends.CANVAS){if(!this.element.getContext)throw new n.RERR("BadElement",`Can't get canvas context from element: ${this.elementId}`);[t,e]=m.SanitizeCanvasDims(t,e);const i=window.devicePixelRatio||1;this.element.width=t*i,this.element.height=e*i,this.element.style.width=t+"px",this.element.style.height=e+"px",this.ctx=v.bolsterCanvasContext(this.element.getContext("2d")),this.ctx.scale(i,i)}else this.ctx.resize(t,e);return this}getContext(){return this.ctx}}class x extends l{static get CATEGORY(){return"stem"}static get UP(){return 1}static get DOWN(){return-1}static get WIDTH(){return p.STEM_WIDTH}static get HEIGHT(){return p.STEM_HEIGHT}constructor(t={}){super(),this.setAttribute("type","Stem"),this.x_begin=t.x_begin||0,this.x_end=t.x_end||0,this.y_top=t.y_top||0,this.y_bottom=t.y_bottom||0,this.stem_extension=t.stem_extension||0,this.stem_direction=t.stem_direction||0,this.hide=t.hide||!1,this.isStemlet=t.isStemlet||!1,this.stemletHeight=t.stemletHeight||0,this.renderHeightAdjustment=0,this.setOptions(t)}setOptions(t){this.stem_up_y_offset=t.stem_up_y_offset||0,this.stem_down_y_offset=t.stem_down_y_offset||0}setNoteHeadXBounds(t,e){return this.x_begin=t,this.x_end=e,this}setDirection(t){this.stem_direction=t}setExtension(t){this.stem_extension=t}getExtension(){return this.stem_extension}setYBounds(t,e){this.y_top=t,this.y_bottom=e}getCategory(){return x.CATEGORY}getHeight(){const t=this.stem_direction===x.UP?this.stem_up_y_offset:this.stem_down_y_offset;return(this.y_bottom-this.y_top)*this.stem_direction+(x.HEIGHT-t+this.stem_extension)*this.stem_direction}getBoundingBox(){throw new n.RERR("NotImplemented","getBoundingBox() not implemented.")}getExtents(){const t=this.stem_direction===x.UP,e=[this.y_top,this.y_bottom],i=x.HEIGHT+this.stem_extension,n=(t?Math.min:Math.max)(...e),s=(t?Math.max:Math.min)(...e);return{topY:n+i*-this.stem_direction,baseY:s}}setVisibility(t){return this.hide=!t,this}setStemlet(t,e){return this.isStemlet=t,this.stemletHeight=e,this}draw(){if(this.setRendered(),this.hide)return;const t=this.checkContext();let e,i;const s=this.stem_direction;s===x.DOWN?(e=this.x_begin,i=this.y_top+this.stem_down_y_offset):(e=this.x_end,i=this.y_bottom-this.stem_up_y_offset);const r=this.getHeight();!function(...t){x.DEBUG&&n.L("Vex.Flow.Stem",t)}("Rendering stem - ","Top Y: ",this.y_top,"Bottom Y: ",this.y_bottom);const o=this.isStemlet?r-this.stemletHeight*this.stem_direction:0;t.save(),this.applyStyle(t),t.beginPath(),t.setLineWidth(x.WIDTH),t.moveTo(e,i-o),t.lineTo(e,i-r-this.renderHeightAdjustment*s),t.stroke(),this.restoreStyle(t),t.restore()}}class E extends l{static get LOCATION_TOP(){return 1}static get LOCATION_BOTTOM(){return-1}static get NESTING_OFFSET(){return 15}constructor(t,e){if(super(),this.setAttribute("type","Tuplet"),!t||!t.length)throw new n.RuntimeError("BadArguments","No notes provided for tuplet.");this.options=n.Merge({},e),this.notes=t,this.num_notes="num_notes"in this.options?this.options.num_notes:t.length,this.options.beats_occupied&&this.beatsOccupiedDeprecationWarning(),this.notes_occupied=this.options.notes_occupied||this.options.beats_occupied||2,"bracketed"in this.options?this.bracketed=this.options.bracketed:this.bracketed=t.some((t=>null===t.beam)),this.ratioed="ratioed"in this.options?this.options.ratioed:Math.abs(this.notes_occupied-this.num_notes)>1,this.point=28,this.y_pos=16,this.x_pos=100,this.width=200,this.location=this.options.location||E.LOCATION_TOP,ut.AlignRestsToNotes(t,!0,!0),this.resolveGlyphs(),this.attach()}attach(){for(let t=0;t=1;)this.numerator_glyphs.unshift(new f("v"+t%10,this.point)),t=parseInt(t/10,10);for(this.denom_glyphs=[],t=this.notes_occupied;t>=1;)this.denom_glyphs.unshift(new f("v"+t%10,this.point)),t=parseInt(t/10,10)}getNestedTupletCount(){const t=this.location,e=this.notes[0];let i=s(e,t),n=s(e,t);function s(t,e){return t.tupletStack.filter((t=>t.location===e)).length}return this.notes.forEach((e=>{const r=s(e,t);i=r>i?r:i,n=rn&&(n=e)}}return n+t+e}draw(){this.checkContext(),this.setRendered();const t=this.notes[0],e=this.notes[this.notes.length-1];this.bracketed?(this.x_pos=t.getTieLeftX()-5,this.width=e.getTieRightX()-this.x_pos+5):(this.x_pos=t.getStemX(),this.width=e.getStemX()-this.x_pos),this.y_pos=this.getYPosition();const i=(t,e)=>t+e.getMetrics().width;let n=this.numerator_glyphs.reduce(i,0);this.ratioed&&(n=this.denom_glyphs.reduce(i,n),n+=.32*this.point);const s=this.x_pos+this.width/2-n/2;if(this.bracketed){const t=this.width/2-n/2-5;t>0&&(this.context.fillRect(this.x_pos,this.y_pos,t,1),this.context.fillRect(this.x_pos+this.width/2+n/2+5,this.y_pos,t,1),this.context.fillRect(this.x_pos,this.y_pos+(this.location===E.LOCATION_BOTTOM),1,10*this.location),this.context.fillRect(this.x_pos+this.width,this.y_pos+(this.location===E.LOCATION_BOTTOM),1,10*this.location))}let r=0;if(this.numerator_glyphs.forEach((t=>{t.render(this.context,s+r,this.y_pos+this.point/3-2),r+=t.getMetrics().width})),this.ratioed){const t=s+r+.16*this.point,e=.06*this.point;this.context.beginPath(),this.context.arc(t,this.y_pos-.08*this.point,e,0,2*Math.PI,!0),this.context.closePath(),this.context.fill(),this.context.beginPath(),this.context.arc(t,this.y_pos+.12*this.point,e,0,2*Math.PI,!0),this.context.closePath(),this.context.fill(),r+=.32*this.point,this.denom_glyphs.forEach((t=>{t.render(this.context,s+r,this.y_pos+this.point/3-2),r+=t.getMetrics().width}))}}}function _(t){let e=0;return t.forEach((t=>{t.keyProps&&t.keyProps.forEach((t=>{e+=t.line-3}))})),e>=0?x.DOWN:x.UP}const w="L",T="B";class M extends l{static getDefaultBeamGroups(t){t&&"c"!==t||(t="4/4");const e={"1/2":["1/2"],"2/2":["1/2"],"3/2":["1/2"],"4/2":["1/2"],"1/4":["1/4"],"2/4":["1/4"],"3/4":["1/4"],"4/4":["1/4"],"1/8":["1/8"],"2/8":["2/8"],"3/8":["3/8"],"4/8":["2/8"],"1/16":["1/16"],"2/16":["2/16"],"3/16":["3/16"],"4/16":["2/16"]}[t];if(void 0!==e)return e.map((t=>(new s).parse(t)));{const e=parseInt(t.split("/")[0],10),i=parseInt(t.split("/")[1],10);if(e%3==0)return[new s(3,i)];if(i>4)return[new s(2,i)];if(i<=4)return[new s(1,i)]}return[new s(1,4)]}static applyAndGetBeams(t,e,i){return M.generateBeams(t.getTickables(),{groups:i,stem_direction:e})}static generateBeams(t,e){e||(e={}),e.groups&&e.groups.length||(e.groups=[new s(2,8)]);const i=e.groups.map((t=>{if(!t.multiply)throw new n.RuntimeError("InvalidBeamGroups","The beam groups must be an array of Vex.Flow.Fractions");return t.clone().multiply(p.RESOLUTION,1)})),r=t;let o=0,a=[],l=[];function h(){i.length-1>o?o+=1:o=0}!function(){let t=[];r.forEach((e=>{if(t=[],e.shouldIgnoreTicks())return a.push(l),void(l=t);l.push(e);const n=i[o].clone(),r=l.reduce(((t,e)=>e.getTicks().clone().add(t)),new s(0,1)),c=p.durationToNumber(e.duration)<8;c&&e.tuplet&&(n.numerator*=2),r.greaterThan(n)?(c||t.push(l.pop()),a.push(l),l=t,h()):r.equals(n)&&(a.push(l),l=t,h())})),l.length>0&&a.push(l)}(),function(){const t=[];a.forEach((i=>{let n=[];i.forEach(((i,s,r)=>{const o=0===s||s===r.length-1,a=r[s-1],l=!e.beam_rests&&i.isRest(),h=e.beam_rests&&e.beam_middle_only&&i.isRest()&&o;let c=!1;if(e.maintain_stem_directions&&a&&!i.isRest()&&!a.isRest()){const t=a.getStemDirection();c=i.getStemDirection()!==t}const u=parseInt(i.duration,10)<8;l||h||c||u?(n.length>0&&t.push(n),n=c?[i]:[]):n.push(i)})),n.length>0&&t.push(n)})),a=t}(),a.forEach((t=>{let i;if(e.maintain_stem_directions){const e=function(t){for(let e=0;e{t.setStemDirection(n)}))}));const c=a.filter((t=>{if(t.length>1){let e=!0;return t.forEach((t=>{t.getIntrinsicTicks()>=p.durationToTicks("4")&&(e=!1)})),e}return!1})),u=function(){const t=[];return a.forEach((e=>{let i=null;e.forEach((e=>{e.tuplet&&i!==e.tuplet&&(i=e.tuplet,t.push(i))}))})),t}(),d=[];return c.forEach((t=>{const i=new M(t);e.show_stemlets&&(i.render_options.show_stemlets=!0),e.secondary_breaks&&(i.render_options.secondary_break_ticks=p.durationToTicks(e.secondary_breaks)),!0===e.flat_beams&&(i.render_options.flat_beams=!0,i.render_options.flat_beam_offset=e.flat_beam_offset),d.push(i)})),u.forEach((t=>{const e=t.notes[0].stem_direction===x.DOWN?E.LOCATION_BOTTOM:E.LOCATION_TOP;t.setTupletLocation(e);let i=!1;for(let e=0;e=p.durationToTicks("4"))throw new n.RuntimeError("BadArguments","Beams can only be applied to notes shorter than a quarter note.");let i,s;for(this.stem_direction=x.UP,i=0;it+e.stem_direction),0)>-1?x.UP:x.DOWN),i=0;it.getGlyph().beam_count)).reduce(((t,e)=>e>t?e:t))}breakSecondaryAt(t){return this.break_on_indices=t,this}getSlopeY(t,e,i,n){return i+(t-e)*n}calculateSlope(){const{notes:t,stem_direction:e,render_options:{max_slope:i,min_slope:n,slope_iterations:s,slope_cost:r}}=this,o=t[0],a=((t,e)=>{const i=t.getStemExtents().topY,n=t.getStemX();return(e.getStemExtents().topY-i)/(e.getStemX()-n)})(o,t[t.length-1]),l=(i-n)/s;let h=Number.MAX_VALUE,c=0,u=0;for(let s=n;s<=i;s+=l){let i=0,n=0;for(let r=1;rs)&&(l=s,o=Math.min(...n.getYs()),a=n.getBeamCount())}let h=r/t.length;const c=n+a*(1.5*i),u=o+c*-e;e===x.DOWN&&hu&&(h=o-c),s+this.render_options.flat_beam_offset_per_beam>0?(e===x.DOWN&&h>s&&!this.render_options.flat_beams||e===x.UP&&h0){let e=this.render_options.flat_beam_offset;this.render_options.flat_beam_offset_per_beam&&(e+=this.render_options.flat_beam_offset_per_beam*this.getBeamCount());let i=this.notes[0].note_heads[0].y;const n=this.stem_direction>0?Math.min:Math.max;for(const t of this.notes)for(const e of t.note_heads)i=n(i,e.y);t=i+e*-this.stem_direction}return t}applyStemExtensions(){const{notes:t,slope:e,y_shift:i,stem_direction:n,beam_count:s,render_options:{show_stemlets:r,stemlet_extension:o,beam_width:a}}=this,l=t[0],h=this.getBeamYToDraw(),c=l.getStemX();for(let l=0;l=8&&(c=-1!==this.break_on_indices.indexOf(l),this.render_options.secondary_break_ticks&&a>=this.render_options.secondary_break_ticks&&(a=0,c=!0));const u=h.getIntrinsicTicks(){t.getStem()&&t.getStem().setContext(this.context).draw()}),this)}drawBeamLines(){this.checkContext();const t=["4","8","16","32","64"],e=this.notes[0];let i=this.getBeamYToDraw();const n=e.getStemX(),s=this.render_options.beam_width*this.stem_direction;for(let e=0;e{t.getStave()||t.setStave(this.stave)})),this.preFormatted=!0),this}draw(t=this.context,e=this.stave){this.setRendered();let i=null;for(let s=0;s0&&i){const t=r.getBoundingBox();t&&i.mergeWith(t)}r.setContext(t),r.drawWithStyle()}this.boundingBox=i}}function L(t,e,i,s,r){if(e!==A.type.BOLD_DOUBLE_LEFT&&e!==A.type.BOLD_DOUBLE_RIGHT)throw new n.RERR("InvalidConnector","A REPEAT_BEGIN or REPEAT_END type must be provided.");let o=3,a=3.5;e===A.type.BOLD_DOUBLE_RIGHT&&(o=-5,a=3),t.fillRect(i+o,s,1,r-s),t.fillRect(i-2,s,a,r-s)}class A extends l{static get type(){return{SINGLE_RIGHT:0,SINGLE_LEFT:1,SINGLE:1,DOUBLE:2,BRACE:3,BRACKET:4,BOLD_DOUBLE_LEFT:5,BOLD_DOUBLE_RIGHT:6,THIN_DOUBLE:7,NONE:8}}static get typeString(){return{singleRight:A.type.SINGLE_RIGHT,singleLeft:A.type.SINGLE_LEFT,single:A.type.SINGLE,double:A.type.DOUBLE,brace:A.type.BRACE,bracket:A.type.BRACKET,boldDoubleLeft:A.type.BOLD_DOUBLE_LEFT,boldDoubleRight:A.type.BOLD_DOUBLE_RIGHT,thinDouble:A.type.THIN_DOUBLE,none:A.type.NONE}}constructor(t,e){super(),this.setAttribute("type","StaveConnector"),this.thickness=p.STAVE_LINE_THICKNESS,this.width=3,this.top_stave=t,this.bottom_stave=e,this.type=A.type.DOUBLE,this.font={family:"times",size:16,weight:"normal"},this.x_shift=0,this.texts=[]}setType(t){return(t="string"==typeof t?A.typeString[t]:t)>=A.type.SINGLE_RIGHT&&t<=A.type.NONE&&(this.type=t),this}setText(t,e){return this.texts.push({content:t,options:n.Merge({shift_x:0,shift_y:0},e)}),this}setFont(t){n.Merge(this.font,t)}setXShift(t){if("number"!=typeof t)throw n.RERR("InvalidType","x_shift must be a Number");return this.x_shift=t,this}draw(){const t=this.checkContext();this.setRendered();let e=this.top_stave.getYForLine(0),i=this.bottom_stave.getYForLine(this.bottom_stave.getNumLines()-1)+this.thickness,s=this.width,r=this.top_stave.getX();(this.type===A.type.SINGLE_RIGHT||this.type===A.type.BOLD_DOUBLE_RIGHT||this.type===A.type.THIN_DOUBLE)&&(r=this.top_stave.getX()+this.top_stave.width);let o=i-e;switch(this.type){case A.type.SINGLE:case A.type.SINGLE_LEFT:case A.type.SINGLE_RIGHT:s=1;break;case A.type.DOUBLE:r-=this.width+2;break;case A.type.BRACE:{s=12;const n=this.top_stave.getX()-2+this.x_shift,r=e,a=n,l=i,h=n-s,c=r+o/2,u=h-.9*s,d=r+.2*o,f=n+1.1*s,p=c-.135*o,m=f,b=c+.135*o,g=u,y=l-.2*o,S=h-s,v=y,x=n+.4*s,E=c+.135*o,_=x,w=c-.135*o,T=S,M=d;t.beginPath(),t.moveTo(n,r),t.bezierCurveTo(u,d,f,p,h,c),t.bezierCurveTo(m,b,g,y,a,l),t.bezierCurveTo(S,v,x,E,h,c),t.bezierCurveTo(_,w,T,M,n,r),t.fill(),t.stroke();break}case A.type.BRACKET:e-=4,i+=4,o=i-e,f.renderGlyph(t,r-5,e-3,40,"v1b",!0),f.renderGlyph(t,r-5,i+3,40,"v10",!0),r-=this.width+2;break;case A.type.BOLD_DOUBLE_LEFT:L(t,this.type,r+this.x_shift,e,i);break;case A.type.BOLD_DOUBLE_RIGHT:L(t,this.type,r,e,i);break;case A.type.THIN_DOUBLE:s=1;break;case A.type.NONE:break;default:throw new n.RERR("InvalidType",`The provided StaveConnector.type (${this.type}) is invalid`)}this.type!==A.type.BRACE&&this.type!==A.type.BOLD_DOUBLE_LEFT&&this.type!==A.type.BOLD_DOUBLE_RIGHT&&this.type!==A.type.NONE&&t.fillRect(r,e,s,o),this.type===A.type.THIN_DOUBLE&&t.fillRect(r-3,e,s,o),t.save(),t.lineWidth=2,t.setFont(this.font.family,this.font.size,this.font.weight);for(let e=0;e0){const n=m.space.deviation,s=n>=0?"+":"";t.setFillStyle("red"),t.fillText(s+Math.round(n),a+e.getXShift(),i-10)}t.restore()}constructor(t){if(super(),this.setAttribute("type","Note"),!t)throw new n.RuntimeError("BadArguments","Note must have valid initialization data to identify duration and type.");const e=p.parseNoteStruct(t);if(!e)throw new n.RuntimeError("BadArguments",`Invalid note initialization object: ${JSON.stringify(t)}`);if(this.duration=e.duration,this.dots=e.dots,this.noteType=e.type,this.customTypes=e.customTypes,t.duration_override?this.setDuration(t.duration_override):this.setIntrinsicTicks(e.ticks),this.modifiers=[],this.glyph=p.getGlyphProps(this.duration,this.noteType),this.customGlyphs=this.customTypes.map((t=>p.getGlyphProps(this.duration,t))),this.positions&&("object"!=typeof this.positions||!this.positions.length))throw new n.RuntimeError("BadArguments","Note keys must be array type.");this.playNote=null,this.tickContext=null,this.modifierContext=null,this.ignore_ticks=!1,this.width=0,this.extraLeftPx=0,this.extraRightPx=0,this.x_shift=0,this.left_modPx=0,this.right_modPx=0,this.voice=null,this.preFormatted=!1,this.ys=[],t.align_center&&this.setCenterAlignment(t.align_center),this.stave=null,this.render_options={annotation_spacing:5,stave_padding:I.STAVEPADDING}}getPlayNote(){return this.playNote}setPlayNote(t){return this.playNote=t,this}isRest(){return!1}addStroke(t,e){return e.setNote(this),e.setIndex(t),this.modifiers.push(e),this.setPreFormatted(!1),this}getStave(){return this.stave}setStave(t){return this.stave=t,this.setYs([t.getYForLine(0)]),this.context=this.stave.context,this}getCategory(){return I.CATEGORY}setContext(t){return this.context=t,this}getExtraLeftPx(){return this.extraLeftPx}getExtraRightPx(){return this.extraRightPx}setExtraLeftPx(t){return this.extraLeftPx=t,this}setExtraRightPx(t){return this.extraRightPx=t,this}shouldIgnoreTicks(){return this.ignore_ticks}getLineNumber(){return 0}getLineForRest(){return 0}getGlyph(){return this.glyph}getGlyphWidth(){return this.glyph.getWidth(this.render_options.glyph_font_scale)}setYs(t){return this.ys=t,this}getYs(){if(0===this.ys.length)throw new n.RERR("NoYValues","No Y-values calculated for this note.");return this.ys}getYForTopText(t){if(!this.stave)throw new n.RERR("NoStave","No stave attached to this note.");return this.stave.getYForTopText(t)}getBoundingBox(){return null}getVoice(){if(!this.voice)throw new n.RERR("NoVoice","Note has no voice.");return this.voice}setVoice(t){return this.voice=t,this.preFormatted=!1,this}getTickContext(){return this.tickContext}setTickContext(t){return this.tickContext=t,this.preFormatted=!1,this}getDuration(){return this.duration}isDotted(){return this.dots>0}hasStem(){return!1}getDots(){return this.dots}getNoteType(){return this.noteType}setBeam(){return this}setModifierContext(t){return this.modifierContext=t,this}addModifier(t,e=0){return t.setNote(this),t.setIndex(e),this.modifiers.push(t),this.setPreFormatted(!1),this}getModifierStartXY(){if(!this.preFormatted)throw new n.RERR("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");return{x:this.getAbsoluteX(),y:this.ys[0]}}getMetrics(){if(!this.preFormatted)throw new n.RERR("UnformattedNote","Can't call getMetrics on an unformatted note.");let t=0,e=0;null!=this.modifierContext&&(t=this.modifierContext.state.left_shift,e=this.modifierContext.state.right_shift);const i=this.getWidth();return{width:i,noteWidth:i-t-e-this.extraLeftPx-this.extraRightPx,left_shift:this.x_shift,modLeftPx:t,modRightPx:e,extraLeftPx:this.extraLeftPx,extraRightPx:this.extraRightPx}}setWidth(t){this.width=t}getWidth(){if(!this.preFormatted)throw new n.RERR("UnformattedNote","Can't call GetWidth on an unformatted note.");return this.width+(this.modifierContext?this.modifierContext.getWidth():0)}setXShift(t){return this.x_shift=t,this}getXShift(){return this.x_shift}getX(){if(!this.tickContext)throw new n.RERR("NoTickContext","Note needs a TickContext assigned for an X-Value");return this.tickContext.getX()+this.x_shift}getAbsoluteX(){if(!this.tickContext)throw new n.RERR("NoTickContext","Note needs a TickContext assigned for an X-Value");let t=this.tickContext.getX();return this.stave&&(t+=this.stave.getNoteStartX()+this.render_options.stave_padding),this.isCenterAligned()&&(t+=this.getCenterXShift()),t}setPreFormatted(t){if(this.preFormatted=t,this.preFormatted){const t=this.tickContext.getExtraPx();this.left_modPx=Math.max(this.left_modPx,t.left),this.right_modPx=Math.max(this.right_modPx,t.right)}}}class R extends I{static get CATEGORY(){return"notehead"}constructor(t){if(super(t),this.setAttribute("type","NoteHead"),this.index=t.index,this.x=t.x||0,this.y=t.y||0,this.note_type=t.note_type,this.duration=t.duration,this.displaced=t.displaced||!1,this.stem_direction=t.stem_direction||D.STEM_UP,this.line=t.line,this.glyph=p.getGlyphProps(this.duration,this.note_type),!this.glyph)throw new n.RuntimeError("BadArguments",`No glyph found for duration '${this.duration}' and type '${this.note_type}'`);this.glyph_code=this.glyph.code_head,this.x_shift=t.x_shift||0,t.custom_glyph_code&&(this.custom_glyph=!0,this.glyph_code=t.custom_glyph_code,this.stem_up_x_offset=t.stem_up_x_offset||0,this.stem_down_x_offset=t.stem_down_x_offset||0),this.style=t.style,this.slashed=t.slashed,n.Merge(this.render_options,{glyph_font_scale:t.glyph_font_scale||p.DEFAULT_NOTATION_FONT_SCALE,stroke_px:3}),this.setWidth(this.glyph.getWidth(this.render_options.glyph_font_scale))}getCategory(){return R.CATEGORY}getWidth(){return this.width}isDisplaced(){return!0===this.displaced}getGlyph(){return this.glyph}setX(t){return this.x=t,this}getY(){return this.y}setY(t){return this.y=t,this}getLine(){return this.line}setLine(t){return this.line=t,this}getAbsoluteX(){const t=this.preFormatted?super.getAbsoluteX():this.x,e=x.WIDTH/2;return t+(this.displaced?(this.width-e)*this.stem_direction:0)}getBoundingBox(){if(!this.preFormatted)throw new n.RERR("UnformattedNote","Can't call getBoundingBox on an unformatted note.");const t=this.stave.getSpacingBetweenLines(),e=t/2,i=this.y-e;return new p.BoundingBox(this.getAbsoluteX(),i,this.width,t)}setStave(t){const e=this.getLine();return this.stave=t,this.setY(t.getYForNote(e)),this.context=this.stave.context,this}preFormat(){if(this.preFormatted)return this;const t=this.getWidth()+this.extraLeftPx+this.extraRightPx;return this.setWidth(t),this.setPreFormatted(!0),this}draw(){this.checkContext(),this.setRendered();const t=this.context;let e=this.getAbsoluteX();this.custom_glyph&&(e+=this.stem_direction===x.UP?this.stem_up_x_offset:this.stem_down_x_offset);const i=this.y;!function(...t){R.DEBUG&&n.L("Vex.Flow.NoteHead",t)}("Drawing note head '",this.note_type,this.duration,"' at",e,i);const s=this.stem_direction,r=this.render_options.glyph_font_scale;if(this.style&&this.applyStyle(t),"s"===this.note_type){const n=this.stave.getSpacingBetweenLines();!function(t,e,i,n,s,r){const o=p.SLASH_NOTEHEAD_WIDTH;t.save(),t.setLineWidth(p.STEM_WIDTH);let a=!1;if(p.durationToNumber(e)>2&&(a=!0),a||(i-=p.STEM_WIDTH/2*s),t.beginPath(),t.moveTo(i,n+r),t.lineTo(i,n+1),t.lineTo(i+o,n-r),t.lineTo(i+o,n),t.lineTo(i,n+r),t.closePath(),a?t.fill():t.stroke(),p.durationToFraction(e).equals(.5)){const e=[-3,-1,o+1,o+3];for(let s=0;s{const i=t.getTickContext();t.setStave(e.stave),i.setXOffset(s)}))}}class B extends F{static get CATEGORY(){return"dots"}static format(t,e){const i=e.right_shift;if(!t||0===t.length)return!1;const n=[],s={};for(let e=0;ee.line-t.line));let r=i,o=0,a=null,l=null,h=null,c=0;for(let t=0;to?r:o,a=d,l=i}return e.right_shift+=o,!0}constructor(){super(),this.setAttribute("type","Dot"),this.note=null,this.index=null,this.position=F.Position.RIGHT,this.radius=2,this.setWidth(5),this.dot_shiftY=0}getCategory(){return B.CATEGORY}setNote(t){this.note=t,"gracenotes"===this.note.getCategory()&&(this.radius*=.5,this.setWidth(3))}setDotShiftY(t){return this.dot_shiftY=t,this}draw(){if(this.checkContext(),this.setRendered(),!this.note||null===this.index)throw new n.RERR("NoAttachedNote","Can't draw dot without a note and index.");const t=this.note.stave.options.spacing_between_lines_px,e=this.note.getModifierStartXY(this.position,this.index,{forceFlagRight:!0});"tabnotes"===this.note.getCategory()&&(e.y=this.note.getStemExtents().baseY);const i=e.x+this.x_shift+this.width-this.radius,s=e.y+this.y_shift+this.dot_shiftY*t,r=this.context;r.beginPath(),r.arc(i,s,this.radius,0,2*Math.PI,!1),r.fill()}}function O(t,e,i){const n=(e.isrest?0:1)*i;t.line+=n,t.maxLine+=n,t.minLine+=n,t.note.setKeyLine(0,t.note.getKeyLine(0)+n)}class D extends N{static get CATEGORY(){return"stavenotes"}static get STEM_UP(){return x.UP}static get STEM_DOWN(){return x.DOWN}static get DEFAULT_LEDGER_LINE_OFFSET(){return 3}static format(t,e){if(!t||t.length<2)return!1;if(t[0].getStave())return D.formatByY(t,e);const i=[];for(let e=0;e2?i[1]:null;let a=s>2?i[2]:i[1];2===s&&-1===r.stemDirection&&1===a.stemDirection&&(r=i[1],a=i[0]);const l=Math.max(r.voice_shift,a.voice_shift);let h,c=0;if(2===s){const t=r.stemDirection===a.stemDirection?0:.5;return r.stemDirection===a.stemDirection&&r.minLine<=a.maxLine&&(r.isrest||(h=Math.abs(r.line-(a.maxLine+.5)),h=Math.max(h,r.stemMin),r.minLine=r.line-h,r.note.setStemLength(10*h))),r.minLine<=a.maxLine+t&&(r.isrest?O(r,a,1):a.isrest?O(a,r,-1):(c=l,r.stemDirection===a.stemDirection?r.note.setXShift(c+3):a.note.setXShift(c))),!0}return null!==o&&o.minLinet.postFormat())),!0)}constructor(t){if(super(t),this.setAttribute("type","StaveNote"),this.keys=t.keys,this.clef=t.clef,this.octave_shift=t.octave_shift,this.beam=null,this.glyph=p.getGlyphProps(this.duration,this.noteType),!this.glyph)throw new n.RuntimeError("BadArguments",`Invalid note initialization data (No glyph found): ${JSON.stringify(t)}`);this.displaced=!1,this.dot_shiftY=0,this.keyProps=[],this.use_default_head_x=!1,this.note_heads=[],this.modifiers=[],n.Merge(this.render_options,{glyph_font_scale:t.glyph_font_scale||p.DEFAULT_NOTATION_FONT_SCALE,stroke_px:t.stroke_px||D.DEFAULT_LEDGER_LINE_OFFSET}),this.calculateKeyProps(),this.buildStem(),t.auto_stem?this.autoStem():this.setStemDirection(t.stem_direction),this.reset(),this.buildFlag()}reset(){super.reset();const t=this.note_heads.map((t=>t.getStyle()));this.buildNoteHeads(),this.note_heads.forEach(((e,i)=>e.setStyle(t[i]))),this.stave&&this.note_heads.forEach((t=>t.setStave(this.stave))),this.calcExtraPx()}setBeam(t){return this.beam=t,this.calcExtraPx(),this}getCategory(){return D.CATEGORY}buildStem(){this.setStem(new x({hide:!!this.isRest()}))}buildNoteHeads(){this.note_heads=[];const t=this.getStemDirection(),e=this.getKeys();let i,n,s,r=null,o=null,a=!1;t===x.UP?(i=0,n=e.length,s=1):t===x.DOWN&&(i=e.length-1,n=-1,s=-1);for(let e=i;e!==n;e+=s){const i=this.keyProps[e],n=i.line;null===r?r=n:(o=Math.abs(r-n),0===o||.5===o?a=!a:(a=!1,this.use_default_head_x=!0)),r=n;const s=new R({duration:this.duration,note_type:this.noteType,displaced:a,stem_direction:t,custom_glyph_code:i.code,glyph_font_scale:this.render_options.glyph_font_scale,x_shift:i.shift_right,stem_up_x_offset:i.stem_up_x_offset,stem_down_x_offset:i.stem_down_x_offset,line:i.line});this.note_heads[e]=s}}autoStem(){this.minLine=this.keyProps[0].line,this.maxLine=this.keyProps[this.keyProps.length-1].line;const t=(this.minLine+this.maxLine)/2<3?x.UP:x.DOWN;this.setStemDirection(t)}calculateKeyProps(){let t=null;for(let e=0;e0&&(this.keyProps[e-1].displaced=!0)),t=o,this.keyProps.push(r)}t=-1/0,this.keyProps.forEach((e=>{e.linet.line-e.line))}getBoundingBox(){if(!this.preFormatted)throw new n.RERR("UnformattedNote","Can't call getBoundingBox on an unformatted note.");const{width:t,modLeftPx:e,extraLeftPx:i}=this.getMetrics(),s=this.getAbsoluteX()-e-i;let r=0,o=0;const a=this.getStave().getSpacingBetweenLines()/2,l=2*a;if(this.isRest()){const t=this.ys[0],e=p.durationToFraction(this.duration);e.equals(1)||e.equals(2)?(r=t-a,o=t+a):(r=t-this.glyph.line_above*l,o=t+this.glyph.line_below*l)}else if(this.glyph.stem){const t=this.getStemExtents();t.baseY+=a*this.stem_direction,r=Math.min(t.topY,t.baseY),o=Math.max(t.topY,t.baseY)}else{r=null,o=null;for(let t=0;te&&(e=n):n1}hasStem(){return this.glyph.stem}hasFlag(){return super.hasFlag()&&!this.isRest()}getStemX(){return"r"===this.noteType?this.getCenterGlyphX():super.getStemX()+(t=this,x.WIDTH/(2*-t.getStemDirection()));var t}getYForTopText(t){const e=this.getStemExtents();return Math.min(this.stave.getYForTopText(t),e.topY-this.render_options.annotation_spacing*(t+1))}getYForBottomText(t){const e=this.getStemExtents();return Math.max(this.stave.getYForTopText(t),e.baseY+this.render_options.annotation_spacing*t)}setStave(t){super.setStave(t);const e=this.note_heads.map((e=>(e.setStave(t),e.getY())));if(this.setYs(e),this.stem){const{y_top:t,y_bottom:e}=this.getNoteHeadBounds();this.stem.setYBounds(t,e)}return this}getKeys(){return this.keys}getKeyProps(){return this.keyProps}isDisplaced(){return this.displaced}setNoteDisplaced(t){return this.displaced=t,this}getTieRightX(){let t=this.getAbsoluteX();return t+=this.getGlyphWidth()+this.x_shift+this.extraRightPx,this.modifierContext&&(t+=this.modifierContext.getExtraRightPx()),t}getTieLeftX(){let t=this.getAbsoluteX();return t+=this.x_shift-this.extraLeftPx,t}getLineForRest(){let t=this.keyProps[0].line;if(this.keyProps.length>1){const e=this.keyProps[this.keyProps.length-1].line,i=Math.max(t,e),s=Math.min(t,e);t=n.MidLine(i,s)}return t}getModifierStartXY(t,e,i){if(i=i||{},!this.preFormatted)throw new n.RERR("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");if(0===this.ys.length)throw new n.RERR("NoYValues","No Y-Values calculated for this note.");const{ABOVE:s,BELOW:r,LEFT:o,RIGHT:a}=F.Position;let l=0;return t===o?l=-2:t===a?(l=this.getGlyphWidth()+this.x_shift+2,this.stem_direction===x.UP&&this.hasFlag()&&(i.forceFlagRight||e===((h=this).getStemDirection()===x.UP?h.keyProps.length-1:0))&&(l+=this.flag.getMetrics().width)):t!==r&&t!==s||(l=this.getGlyphWidth()/2),{x:this.getAbsoluteX()+l,y:this.ys[e]};var h}setStyle(t){super.setStyle(t),this.note_heads.forEach((e=>e.setStyle(t))),this.stem.setStyle(t)}setStemStyle(t){this.getStem().setStyle(t)}getStemStyle(){return this.stem.getStyle()}setLedgerLineStyle(t){this.ledgerLineStyle=t}getLedgerLineStyle(){return this.ledgerLineStyle}setFlagStyle(t){this.flagStyle=t}getFlagStyle(){return this.flagStyle}setKeyStyle(t,e){return this.note_heads[t].setStyle(e),this}setKeyLine(t,e){return this.keyProps[t].line=e,this.reset(),this}getKeyLine(t){return this.keyProps[t].line}addToModifierContext(t){this.setModifierContext(t);for(let t=0;t{const u=c.getLine(),d=c.getY();(null===t||de)&&(e=d),null===n&&c.isDisplaced()&&(n=c.getAbsoluteX()),null!==i||c.isDisplaced()||(i=c.getAbsoluteX()),s=u>s?u:s,r=u{let a;a=n&&e?m-i:e?p-i:f-i;const l=e&&n?o:r;s.beginPath(),s.moveTo(a,t),s.lineTo(a+l,t),s.stroke()},g={...t.getStyle()||{},...this.getLedgerLineStyle()||{}};this.applyStyle(s,g);for(let e=6;e<=a;++e){const i=null!==p&&e<=c,n=null!==f&&e<=h;b(t.getYForNote(e),i,n)}for(let e=0;e>=l;--e){const i=null!==p&&e>=d,n=null!==f&&e>=u;b(t.getYForNote(e),i,n)}this.restoreStyle(s,g)}drawModifiers(){if(!this.context)throw new n.RERR("NoCanvasContext","Can't draw without a canvas context.");const t=this.context;t.openGroup("modifiers");for(let e=0;e{this.context.openGroup("notehead",null,{pointerBBox:!0}),t.setContext(this.context).draw(),this.context.closeGroup()}))}drawStem(t){if(!this.context)throw new n.RERR("NoCanvasContext","Can't draw without a canvas context.");t&&this.setStem(new x(t)),this.context.openGroup("stem",null,{pointerBBox:!0}),this.stem.setContext(this.context).draw(),this.context.closeGroup()}draw(){if(!this.context)throw new n.RERR("NoCanvasContext","Can't draw without a canvas context.");if(!this.stave)throw new n.RERR("NoStave","Can't draw without a stave.");if(0===this.ys.length)throw new n.RERR("NoYValues","Can't draw note without Y values.");const t=this.getNoteHeadBeginX(),e=this.hasStem()&&!this.beam;this.note_heads.forEach((e=>e.setX(t)));const i=this.getStemX();this.stem.setNoteHeadXBounds(i,i),function(...t){D.DEBUG&&n.L("Vex.Flow.StaveNote",t)}("Rendering ",this.isChord()?"chord :":"note :",this.keys),this.drawLedgerLines(),this.applyStyle(),this.setAttribute("el",this.context.openGroup("stavenote",this.getAttribute("id"))),this.context.openGroup("note",null,{pointerBBox:!0}),e&&this.drawStem(),this.drawNoteHeads(),this.drawFlag(),this.context.closeGroup(),this.drawModifiers(),this.context.closeGroup(),this.restoreStyle(),this.setRendered()}}class k extends F{static get CATEGORY(){return"frethandfinger"}static format(t,e){const{left_shift:i,right_shift:n}=e;if(!t||0===t.length)return!1;const s=[];let r=null,o=0,a=0;for(let e=0;ee.line-t.line));let l=0,h=0,c=0,u=0,d=null,f=null;for(let t=0;tc?e:c):o===F.Position.RIGHT&&(p.setXShift(h),e=a+y,u=e>u?e:u),d=m,f=r}return e.left_shift+=c,e.right_shift+=u,!0}constructor(t){super(),this.setAttribute("type","FretHandFinger"),this.note=null,this.index=null,this.finger=t,this.width=7,this.position=F.Position.LEFT,this.x_shift=0,this.y_shift=0,this.x_offset=0,this.y_offset=0,this.font={family:"sans-serif",size:9,weight:"bold"}}getCategory(){return k.CATEGORY}setFretHandFinger(t){return this.finger=t,this}setOffsetX(t){return this.x_offset=t,this}setOffsetY(t){return this.y_offset=t,this}draw(){if(this.checkContext(),!this.note||null==this.index)throw new n.RERR("NoAttachedNote","Can't draw string number without a note and index.");this.setRendered();const t=this.context,e=this.note.getModifierStartXY(this.position,this.index);let i=e.x+this.x_shift+this.x_offset,s=e.y+this.y_shift+this.y_offset+5;switch(this.position){case F.Position.ABOVE:i-=4,s-=12;break;case F.Position.BELOW:i-=2,s+=10;break;case F.Position.LEFT:i-=this.width;break;case F.Position.RIGHT:i+=1;break;default:throw new n.RERR("InvalidPostion",`The position ${this.position} does not exist`)}t.save(),t.setFont(this.font.family,this.font.size,this.font.weight),t.fillText(""+this.finger,i,s),t.restore()}}class V{static get NUM_TONES(){return 12}static get roots(){return["c","d","e","f","g","a","b"]}static get root_values(){return[0,2,4,5,7,9,11]}static get root_indices(){return{c:0,d:1,e:2,f:3,g:4,a:5,b:6}}static get canonical_notes(){return["c","c#","d","d#","e","f","f#","g","g#","a","a#","b"]}static get diatonic_intervals(){return["unison","m2","M2","m3","M3","p4","dim5","p5","m6","M6","b7","M7","octave"]}static get diatonic_accidentals(){return{unison:{note:0,accidental:0},m2:{note:1,accidental:-1},M2:{note:1,accidental:0},m3:{note:2,accidental:-1},M3:{note:2,accidental:0},p4:{note:3,accidental:0},dim5:{note:4,accidental:-1},p5:{note:4,accidental:0},m6:{note:5,accidental:-1},M6:{note:5,accidental:0},b7:{note:6,accidental:-1},M7:{note:6,accidental:0},octave:{note:7,accidental:0}}}static get intervals(){return{u:0,unison:0,m2:1,b2:1,min2:1,S:1,H:1,2:2,M2:2,maj2:2,T:2,W:2,m3:3,b3:3,min3:3,M3:4,3:4,maj3:4,4:5,p4:5,"#4":6,b5:6,aug4:6,dim5:6,5:7,p5:7,"#5":8,b6:8,aug5:8,6:9,M6:9,maj6:9,b7:10,m7:10,min7:10,dom7:10,M7:11,maj7:11,8:12,octave:12}}static get scales(){return{major:[2,2,1,2,2,2,1],dorian:[2,1,2,2,2,1,2],mixolydian:[2,2,1,2,2,1,2],minor:[2,1,2,2,1,2,2]}}static get scaleTypes(){return{M:V.scales.major,m:V.scales.minor}}static get accidentals(){return["bb","b","n","#","##"]}static get noteValues(){return{c:{root_index:0,int_val:0},cn:{root_index:0,int_val:0},"c#":{root_index:0,int_val:1},"c##":{root_index:0,int_val:2},cb:{root_index:0,int_val:11},cbb:{root_index:0,int_val:10},d:{root_index:1,int_val:2},dn:{root_index:1,int_val:2},"d#":{root_index:1,int_val:3},"d##":{root_index:1,int_val:4},db:{root_index:1,int_val:1},dbb:{root_index:1,int_val:0},e:{root_index:2,int_val:4},en:{root_index:2,int_val:4},"e#":{root_index:2,int_val:5},"e##":{root_index:2,int_val:6},eb:{root_index:2,int_val:3},ebb:{root_index:2,int_val:2},f:{root_index:3,int_val:5},fn:{root_index:3,int_val:5},"f#":{root_index:3,int_val:6},"f##":{root_index:3,int_val:7},fb:{root_index:3,int_val:4},fbb:{root_index:3,int_val:3},g:{root_index:4,int_val:7},gn:{root_index:4,int_val:7},"g#":{root_index:4,int_val:8},"g##":{root_index:4,int_val:9},gb:{root_index:4,int_val:6},gbb:{root_index:4,int_val:5},a:{root_index:5,int_val:9},an:{root_index:5,int_val:9},"a#":{root_index:5,int_val:10},"a##":{root_index:5,int_val:11},ab:{root_index:5,int_val:8},abb:{root_index:5,int_val:7},b:{root_index:6,int_val:11},bn:{root_index:6,int_val:11},"b#":{root_index:6,int_val:0},"b##":{root_index:6,int_val:1},bb:{root_index:6,int_val:10},bbb:{root_index:6,int_val:9}}}isValidNoteValue(t){return!(null==t||t<0||t>=V.NUM_TONES)}isValidIntervalValue(t){return this.isValidNoteValue(t)}getNoteParts(t){if(!t||t.length<1)throw new n.RERR("BadArguments","Invalid note name: "+t);if(t.length>3)throw new n.RERR("BadArguments","Invalid note name: "+t);const e=t.toLowerCase(),i=/^([cdefgab])(b|bb|n|#|##)?$/.exec(e);if(null!=i)return{root:i[1],accidental:i[2]};throw new n.RERR("BadArguments","Invalid note name: "+t)}getKeyParts(t){if(!t||t.length<1)throw new n.RERR("BadArguments","Invalid key: "+t);const e=t.toLowerCase(),i=/^([cdefgab])(b|#)?(mel|harm|m|M)?$/.exec(e);if(null!=i){const t=i[1],e=i[2];let n=i[3];return n||(n="M"),{root:t,accidental:e,type:n}}throw new n.RERR("BadArguments",`Invalid key: ${t}`)}getNoteValue(t){const e=V.noteValues[t];if(null==e)throw new n.RERR("BadArguments",`Invalid note name: ${t}`);return e.int_val}getIntervalValue(t){const e=V.intervals[t];if(null==e)throw new n.RERR("BadArguments",`Invalid interval name: ${t}`);return e}getCanonicalNoteName(t){if(!this.isValidNoteValue(t))throw new n.RERR("BadArguments",`Invalid note value: ${t}`);return V.canonical_notes[t]}getCanonicalIntervalName(t){if(!this.isValidIntervalValue(t))throw new n.RERR("BadArguments",`Invalid interval value: ${t}`);return V.diatonic_intervals[t]}getRelativeNoteValue(t,e,i){if(null==i&&(i=1),1!==i&&-1!==i)throw new n.RERR("BadArguments",`Invalid direction: ${i}`);let s=(t+i*e)%V.NUM_TONES;return s<0&&(s+=V.NUM_TONES),s}getRelativeNoteName(t,e){const i=this.getNoteParts(t),s=this.getNoteValue(i.root);let r=e-s;if(Math.abs(r)>V.NUM_TONES-3){let i=1;r>0&&(i=-1);const o=(e+1+(s+1))%V.NUM_TONES*i;if(Math.abs(o)>2)throw new n.RERR("BadArguments",`Notes not related: ${t}, ${e})`);r=o}if(Math.abs(r)>2)throw new n.RERR("BadArguments",`Notes not related: ${t}, ${e})`);let o=i.root;if(r>0)for(let t=1;t<=r;++t)o+="#";else if(r<0)for(let t=-1;t>=r;--t)o+="b";return o}getScaleTones(t,e){const i=[t];let n=t;for(let s=0;st.getMetrics().width;class U extends F{static get CATEGORY(){return"accidentals"}static format(t,e){const i=e.left_shift+1;if(!t||0===t.length)return;const n=[];let s,r=null,o=0;for(let e=0;ee.line-t.line));const a=[];let l=0,h=null;for(let t=0;tl?e.shift:l,h=e.line}let c=0;for(let t=0;ta[i+t],r=t=>t.map(s),o=(t,e)=>{const[i,n]=r([t,e]).map((t=>t.line));return i-n},l=(...t)=>t.map(r).every((t=>!this.checkCollision(...t))),h=n-i+1;let u,d,f=this.checkCollision(a[i],a[n])?"a":"b";switch(h){case 3:"a"===f&&.5===o(1,2)&&.5!==o(0,1)&&(f="second_on_bottom");break;case 4:l([0,2],[1,3])&&(f="spaced_out_tetrachord");break;case 5:"b"===f&&l([1,3])&&(f="spaced_out_pentachord",l([0,2],[2,4])&&(f="very_spaced_out_pentachord"));break;case 6:l([0,3],[1,4],[2,5])&&(f="spaced_out_hexachord"),l([0,2],[2,4],[1,3],[3,5])&&(f="very_spaced_out_hexachord")}if(h>=7){let e=2,i=!0;for(;!0===i;){i=!1;for(let t=0;t+ed?c:d}else for(u=t;u<=n;u++)d=p.accidentalColumnsTable[h][f][u-t],a[u].column=d,c=c>d?c:d;t=n}const u=[],d=[];for(let t=0;t<=c;t++)u[t]=0,d[t]=0;u[0]=l+i,d[0]=l+i,a.forEach((t=>{t.width>u[t.column]&&(u[t.column]=t.width)}));for(let t=1;t{let e=0;const i=m+t.numAcc;for(;m0?(n=e.flatLine||e.dblSharpLine?2.5:3,t.dblSharpLine&&(i-=.5)):(n=t.flatLine||t.dblSharpLine?2.5:3,e.dblSharpLine&&(i-=.5));const s=Math.abs(i){const e=new s(0,1);t.getTickables().forEach((t=>{if(t.shouldIgnoreTicks())return;const s=n[e.value()];s?s.push(t):(i.push(e.value()),n[e.value()]=[t]),e.add(t.getTicks())}))}));const r=new V;e||(e="C");const o=r.createScaleMap(e);i.forEach((t=>{const e=n[t],i=[],s=t=>{t.isRest()||t.shouldIgnoreTicks()||(t.keys.forEach(((e,n)=>{const s=r.getNoteParts(e.split("/")[0]),a=s.accidental||"n",l=s.root+a,h=o[s.root]===l,c=i.indexOf(l)>-1;if(!h||h&&c){o[s.root]=l;const e=new U(a);t.addAccidental(n,e),i.push(l)}})),t.getModifiers().forEach((t=>{"gracenotegroups"===t.getCategory()&&t.getGraceNotes().forEach(s)})))};e.forEach(s)}))}constructor(t=null){if(super(),this.setAttribute("type","Accidental"),G("New accidental: ",t),this.note=null,this.index=null,this.type=t,this.position=F.Position.LEFT,this.render_options={font_scale:38,stroke_px:3,parenLeftPadding:2,parenRightPadding:2},this.accidental=p.accidentalCodes(this.type),!this.accidental)throw new n.RERR("ArgumentError",`Unknown accidental type: ${t}`);this.cautionary=!1,this.parenLeft=null,this.parenRight=null,this.reset()}reset(){const t=this.render_options.font_scale;this.glyph=new f(this.accidental.code,t),this.glyph.setOriginX(1),this.cautionary&&(this.parenLeft=new f(p.accidentalCodes("{").code,t),this.parenRight=new f(p.accidentalCodes("}").code,t),this.parenLeft.setOriginX(1),this.parenRight.setOriginX(1))}getCategory(){return U.CATEGORY}getWidth(){const t=this.cautionary?W(this.parenLeft)+W(this.parenRight)+this.render_options.parenLeftPadding+this.render_options.parenRightPadding:0;return W(this.glyph)+t}setNote(t){if(!t)throw new n.RERR("ArgumentError",`Bad note value: ${t}`);this.note=t,"gracenotes"===this.note.getCategory()&&(this.render_options.font_scale=25,this.reset())}setAsCautionary(){return this.cautionary=!0,this.render_options.font_scale=28,this.reset(),this}draw(){const{context:t,type:e,position:i,note:s,index:r,cautionary:o,x_shift:a,y_shift:l,glyph:h,parenLeft:c,parenRight:u,render_options:{parenLeftPadding:d,parenRightPadding:f}}=this;if(this.checkContext(),!s||null==r)throw new n.RERR("NoAttachedNote","Can't draw accidental without a note and index.");const p=s.getModifierStartXY(i,r);let m=p.x+a;const b=p.y+l;G("Rendering: ",e,m,b),o?(u.render(t,m,b),m-=W(u),m-=f,m-=this.accidental.parenRightPaddingAdjustment,h.render(t,m,b),m-=W(h),m-=d,c.render(t,m,b)):h.render(t,m,b),this.setRendered()}}class z extends F{static get CATEGORY(){return"notesubgroup"}static format(t,e){if(!t||0===t.length)return!1;let i=0;for(let e=0;e{t.ignore_ticks=!1})),this.width=0,this.preFormatted=!1,this.formatter=new ut,this.voice=new P({num_beats:4,beat_value:4,resolution:p.RESOLUTION}).setStrict(!1),this.voice.addTickables(this.subNotes),this}getCategory(){return z.CATEGORY}preFormat(){this.preFormatted||(this.formatter.joinVoices([this.voice]).format([this.voice],0),this.setWidth(this.formatter.getMinTotalWidth()),this.preFormatted=!0)}setNote(t){this.note=t}setWidth(t){this.width=t}getWidth(){return this.width}draw(){this.checkContext();const t=this.getNote();if(!t||null===this.index)throw new n.RuntimeError("NoAttachedNote","Can't draw notes without a parent note and parent note index.");this.setRendered(),this.alignSubNotesWithNote(this.subNotes,t),this.subNotes.forEach((t=>t.setContext(this.context).drawWithStyle()))}}class j extends l{constructor(t,e){super(),this.setAttribute("type","StaveTie"),this.notes=t,this.context=null,this.text=e,this.direction=null,this.render_options={cp1:8,cp2:12,text_shift_x:0,first_x_shift:0,last_x_shift:0,y_shift:7,tie_spacing:0,font:{family:"Arial",size:10,style:""}},this.font=this.render_options.font,this.setNotes(t)}setFont(t){return this.font=t,this}setDirection(t){return this.direction=t,this}setNotes(t){if(!t.first_note&&!t.last_note)throw new n.RuntimeError("BadArguments","Tie needs to have either first_note or last_note set.");if(t.first_indices||(t.first_indices=[0]),t.last_indices||(t.last_indices=[0]),t.first_indices.length!==t.last_indices.length)throw new n.RuntimeError("BadArguments","Tied notes must have similar index sizes");return this.first_note=t.first_note,this.first_indices=t.first_indices,this.last_note=t.last_note,this.last_indices=t.last_indices,this}isPartial(){return!this.first_note||!this.last_note}renderTie(t){if(0===t.first_ys.length||0===t.last_ys.length)throw new n.RERR("BadArguments","No Y-values to render");const e=this.context;let i=this.render_options.cp1,s=this.render_options.cp2;Math.abs(t.last_x_px-t.first_x_px)<10&&(i=2,s=8);const r=this.render_options.first_x_shift,o=this.render_options.last_x_shift,a=this.render_options.y_shift*t.direction;for(let l=0;l1){const e=new M(t);e.render_options.beam_width=3,e.render_options.partial_beam_length=4,this.beams.push(e)}return this}setNote(t){this.note=t}setWidth(t){this.width=t}getWidth(){return this.width}getGraceNotes(){return this.grace_notes}draw(){this.checkContext();const t=this.getNote();if(function(...t){X.DEBUG&&n.L("Vex.Flow.GraceNoteGroup",t)}("Drawing grace note group for:",t),!t||null===this.index)throw new n.RuntimeError("NoAttachedNote","Can't draw grace note without a parent note and parent note index.");if(this.setRendered(),this.alignSubNotesWithNote(this.getGraceNotes(),t),this.grace_notes.forEach((t=>{t.setContext(this.context).draw()})),this.beams.forEach((t=>{t.setContext(this.context).draw()})),this.show_slur){const e=this.getNote().getCategory()===D.CATEGORY,i=e?j:H;this.slur=new i({last_note:this.grace_notes[0],first_note:t,first_indices:[0],last_indices:[0]}),this.slur.render_options.cp2=12,this.slur.render_options.y_shift=(e?7:5)+this.render_options.slur_y_shift,this.slur.setContext(this.context).draw()}}}class Y extends F{static get CATEGORY(){return"strokes"}static get Type(){return{BRUSH_DOWN:1,BRUSH_UP:2,ROLL_DOWN:3,ROLL_UP:4,RASQUEDO_DOWN:5,RASQUEDO_UP:6,ARPEGGIO_DIRECTIONLESS:7}}static format(t,e){const i=e.left_shift;if(!t||0===t.length)return this;const n=t.map((t=>{const e=t.getNote();if(e instanceof D){const{line:i,displaced:n}=e.getKeyProps()[t.getIndex()];return{line:i,shift:n?e.getExtraLeftPx():0,stroke:t}}{const{str:i}=e.getPositions()[t.getIndex()];return{line:i,shift:0,stroke:t}}})),s=i,r=n.reduce(((t,{stroke:e,shift:i})=>(e.setXShift(s+i),Math.max(e.getWidth()+0,t))),0);return e.left_shift+=r,!0}constructor(t,e){super(),this.setAttribute("type","Stroke"),this.note=null,this.options=n.Merge({},e),this.all_voices=!("all_voices"in this.options)||this.options.all_voices,this.note_end=null,this.index=null,this.type=t,this.position=F.Position.LEFT,this.render_options={font_scale:38,stroke_px:3,stroke_spacing:10},this.font={family:"serif",size:10,weight:"bold italic"},this.setXShift(0),this.setWidth(10)}getCategory(){return Y.CATEGORY}getPosition(){return this.position}addEndNote(t){return this.note_end=t,this}draw(){if(this.checkContext(),this.setRendered(),!this.note||null==this.index)throw new n.RERR("NoAttachedNote","Can't draw stroke without a note and index.");const t=this.note.getModifierStartXY(this.position,this.index);let e=this.note.getYs(),i=t.y,s=t.y;const r=t.x-5,o=this.note.stave.options.spacing_between_lines_px,a=this.getModifierContext().getModifiers(this.note.getCategory());for(let t=0;te.line-t.line));let f=0,p=0,m=0,b=null,g=null;for(r=0;rp?t:p):l===F.Position.RIGHT&&(o.setXShift(f),t+=c,m=t>m?t:m),b=e,g=a}return e.left_shift+=p,e.right_shift+=m,!0}constructor(t){super(),this.setAttribute("type","StringNumber"),this.note=null,this.last_note=null,this.index=null,this.string_number=t,this.setWidth(20),this.position=F.Position.ABOVE,this.x_shift=0,this.y_shift=0,this.x_offset=0,this.y_offset=0,this.dashed=!0,this.leg=v.LineEndType.NONE,this.radius=8,this.font={family:"sans-serif",size:10,weight:"bold"}}getCategory(){return K.CATEGORY}getNote(){return this.note}setNote(t){return this.note=t,this}getIndex(){return this.index}setIndex(t){return this.index=t,this}setLineEndType(t){return t>=v.LineEndType.NONE&&t<=v.LineEndType.DOWN&&(this.leg=t),this}setStringNumber(t){return this.string_number=t,this}setOffsetX(t){return this.x_offset=t,this}setOffsetY(t){return this.y_offset=t,this}setLastNote(t){return this.last_note=t,this}setDashed(t){return this.dashed=t,this}draw(){const t=this.checkContext();if(!this.note||null==this.index)throw new n.RERR("NoAttachedNote","Can't draw string number without a note and index.");this.setRendered();const e=this.note.stave.options.spacing_between_lines_px,i=this.note.getModifierStartXY(this.position,this.index);let s=i.x+this.x_shift+this.x_offset,r=i.y+this.y_shift+this.y_offset;switch(this.position){case F.Position.ABOVE:case F.Position.BELOW:{const t=this.note.getStemExtents();let n=t.topY,s=t.baseY+2;this.note.stem_direction===D.STEM_DOWN&&(n=t.baseY,s=t.topY-2),r=this.position===F.Position.ABOVE?this.note.hasStem()?n-1.75*e:i.y-1.75*e:this.note.hasStem()?s+1.5*e:i.y+1.75*e,r+=this.y_shift+this.y_offset;break}case F.Position.LEFT:s-=this.radius/2+5;break;case F.Position.RIGHT:s+=this.radius/2+6;break;default:throw new n.RERR("InvalidPosition",`The position ${this.position} is invalid`)}t.save(),t.beginPath(),t.arc(s,r,this.radius,0,2*Math.PI,!1),t.lineWidth=1.5,t.stroke(),t.setFont(this.font.family,this.font.size,this.font.weight);const o=s-t.measureText(this.string_number).width/2;if(t.fillText(""+this.string_number,o,r+4.5),null!=this.last_note){const e=this.last_note.getStemX()-this.note.getX()+5;let i,n;switch(t.strokeStyle="#000000",t.lineCap="round",t.lineWidth=.6,this.dashed?v.drawDashedLine(t,s+10,r,s+e,r,[3,3]):v.drawDashedLine(t,s+10,r,s+e,r,[3,0]),this.leg){case v.LineEndType.UP:i=-10,n=this.dashed?[3,3]:[3,0],v.drawDashedLine(t,s+e,r,s+e,r+i,n);break;case v.LineEndType.DOWN:i=10,n=this.dashed?[3,3]:[3,0],v.drawDashedLine(t,s+e,r,s+e,r+i,n)}}t.restore()}}const{ABOVE:q,BELOW:$}=F.Position,J=(t,e)=>.5*t(e/.5),Z=(t,e)=>e===q?t<=5:t>=1,Q=(t,e)=>Z(t,e)?e===q?Math.ceil:Math.floor:Math.round,tt=t=>{const e=t.getCategory();return"stavenotes"===e||"gracenotes"===e};class et extends F{static get CATEGORY(){return"articulations"}static get INITIAL_OFFSET(){return-.5}static format(t,e){if(!t||0===t.length)return!1;const i=(t,e,i)=>J(Q(e,i),t.glyph.getMetrics().height/10+.5);t.filter((t=>t.getPosition()===q)).forEach((t=>{t.setTextLine(e.top_text_line),e.top_text_line+=i(t,e.top_text_line,q)})),t.filter((t=>t.getPosition()===$)).forEach((t=>{t.setTextLine(e.text_line),e.text_line+=i(t,e.text_line,$)}));const n=t.map((t=>t.getWidth())).reduce(((t,e)=>Math.max(e,t)));return e.left_shift+=n/2,e.right_shift+=n/2,!0}static easyScoreHook({articulations:t},e,i){if(!t)return;const n={staccato:"a.",tenuto:"a-"};t.split(",").map((t=>t.trim().split("."))).map((([t,e])=>{const s={type:n[t]};return e&&(s.position=F.PositionString[e]),i.getFactory().Articulation(s)})).map((t=>e.addModifier(0,t)))}constructor(t){if(super(),this.setAttribute("type","Articulation"),this.note=null,this.index=null,this.type=t,this.position=$,this.render_options={font_scale:38},this.articulation=p.articulationCodes(this.type),!this.articulation)throw new n.RERR("ArgumentError",`Articulation not found: ${this.type}`);this.glyph=new f(this.articulation.code,this.render_options.font_scale),this.setWidth(this.glyph.getMetrics().width)}getCategory(){return et.CATEGORY}draw(){const{note:t,index:e,position:i,glyph:s,articulation:{between_lines:r},text_line:o,context:a}=this;if(this.checkContext(),!t||null==e)throw new n.RERR("NoAttachedNote","Can't draw Articulation without a note and index.");this.setRendered();const l=t.getStave(),h=l.getSpacingBetweenLines(),c="tabnotes"===t.getCategory(),{x:u}=t.getModifierStartXY(i,e),d=!r||c,f=((t,e)=>{const i=e===q&&t.getStemDirection()===x.UP||e===$&&t.getStemDirection()===x.DOWN;return tt(t)?t.hasStem()&&i?.5:1:t.hasStem()&&i?1:0})(t,i);let p={[q]:()=>{s.setOrigin(.5,1);const e=((t,e)=>{const i=t.getStave(),s=t.getStemDirection(),{topY:r,baseY:o}=t.getStemExtents();if(tt(t))return t.hasStem()?s===x.UP?r:o:Math.min(...t.getYs());if("tabnotes"===t.getCategory())return t.hasStem()&&s===x.UP?r:i.getYForTopText(e);throw new n.RERR("UnknownCategory","Only can get the top and bottom ys of stavenotes and tabnotes")})(t,o)-(o+f)*h;return d?Math.min(l.getYForTopText(et.INITIAL_OFFSET),e):e},[$]:()=>{s.setOrigin(.5,0);const e=((t,e)=>{const i=t.getStave(),s=t.getStemDirection(),{topY:r,baseY:o}=t.getStemExtents();if(tt(t))return t.hasStem()?s===x.UP?o:r:Math.max(...t.getYs());if("tabnotes"===t.getCategory())return t.hasStem()?s===x.UP?i.getYForBottomText(e):r:i.getYForBottomText(e);throw new n.RERR("UnknownCategory","Only can get the top and bottom ys of stavenotes and tabnotes")})(t,o)+(o+f)*h;return d?Math.max(l.getYForBottomText(et.INITIAL_OFFSET),e):e}}[i]();if(!c){const n=i===q?-1:1,o=c?t.positions[e].str:t.getKeyProps()[e].line,a=(t.getYs()[e]-p)/h+o,l=((t,e,i,n)=>{const s=J(Q(e,i),e);return t&&Z(s,i)&&s%1==0?s+.5*-n:s})(r,a,i,n);Z(l,i)&&s.setOrigin(.5,.5),p+=Math.abs(l-a)*h*n}!function(...t){et.DEBUG&&n.L("Vex.Flow.Articulation",t)}(`Rendering articulation at (x: ${u}, y: ${p})`),s.render(a,u,p)}}class it extends C{static getNextContext(t){const e=t.tContexts,i=e.indexOf(t);return e[i+1]}constructor(){super(),this.setAttribute("type","TickContext"),this.currentTick=new s(0,1),this.maxTicks=new s(0,1),this.minTicks=null,this.padding=3,this.x=0,this.xBase=0,this.xOffset=0,this.tickables=[],this.notePx=0,this.extraLeftPx=0,this.extraRightPx=0,this.tContexts=[]}getX(){return this.x}setX(t){return this.x=t,this.xBase=t,this.xOffset=0,this}getXBase(){return this.xBase}setXBase(t){this.xBase=t,this.x=t+this.xOffset}getXOffset(){return this.xOffset}setXOffset(t){this.xOffset=t,this.x=this.xBase+t}getWidth(){return this.width+2*this.padding}setPadding(t){return this.padding=t,this}getMaxTicks(){return this.maxTicks}getMinTicks(){return this.minTicks}getTickables(){return this.tickables}getCenterAlignedTickables(){return this.tickables.filter((t=>t.isCenterAligned()))}getMetrics(){const{width:t,notePx:e,extraLeftPx:i,extraRightPx:n}=this;return{width:t,notePx:e,extraLeftPx:i,extraRightPx:n}}getCurrentTick(){return this.currentTick}setCurrentTick(t){this.currentTick=t,this.preFormatted=!1}getExtraPx(){let t=0,e=0,i=0,n=0;for(let s=0;s0&&n--;for(let e=0;e{at("Preformatting ModifierContext: ",t.CATEGORY),t.format(this.getModifiers(t.CATEGORY),this.state,this)})),this.width=this.state.left_shift+this.state.right_shift,this.preFormatted=!0)}postFormat(){this.postFormatted||this.POSTFORMAT.forEach((t=>{at("Postformatting ModifierContext: ",t.CATEGORY),t.postFormat(this.getModifiers(t.CATEGORY),this)}))}}function ht(t,e,i,s){let r=e;for(i+=1;i{if(!e.getTotalTicks().equals(r))throw new n.RERR("TickMismatch","Voices should have same total note duration in ticks.");if(e.getMode()===P.Mode.STRICT&&!e.isComplete())throw new n.RERR("IncompleteVoice","Voice does not have enough notes.");return Math.max(t,s.LCM(t,e.getResolutionMultiplier()))}),1),a={},l=[],h=[];return t.forEach((t=>{const n=new s(0,o);t.getTickables().forEach((t=>{const s=n.numerator;if(!a[s]){const t=new e;h.push(t),a[s]=t}i(t,a[s]),l.push(s),n.add(t.getTicks())}))})),{map:a,array:h,list:n.SortAndUnique(l,((t,e)=>t-e),((t,e)=>t===e)),resolutionMultiplier:o}}class ut{static SimpleFormat(t,e=0,{paddingBetween:i=10}={}){t.reduce(((t,e)=>{e.addToModifierContext(new lt);const n=(new it).addTickable(e).preFormat(),s=n.getExtraPx();return n.setX(t+s.left),t+n.getWidth()+s.right+i}),e)}static plotDebugging(t,e,i,n,s){const r=i+I.STAVEPADDING,o=e.contextGaps;t.save(),t.setFont("Arial",8,""),o.gaps.forEach((e=>{var i,o,a;i=r+e.x1,o=r+e.x2,a="#aaa",t.beginPath(),t.setStrokeStyle(a),t.setFillStyle(a),t.setLineWidth(1),t.fillRect(i,n,o-i,s-n),t.fillText(Math.round(e.x2-e.x1),r+e.x1,s+12)})),t.fillText(Math.round(o.total)+"px",r-20,s+12),t.setFillStyle("red"),t.fillText("Loss: "+e.lossHistory.map((t=>Math.round(t))),r-20,s+22),t.restore()}static FormatAndDraw(t,e,i,s){const r={auto_beam:!1,align_rests:!1};"object"==typeof s?n.Merge(r,s):"boolean"==typeof s&&(r.auto_beam=s);const o=new P(p.TIME4_4).setMode(P.Mode.SOFT).addTickables(i),a=r.auto_beam?M.applyAndGetBeams(o):[];return(new ut).joinVoices([o],{align_rests:r.align_rests}).formatToStave([o],e,{align_rests:r.align_rests,stave:e}),o.setStave(e).draw(t,e),a.forEach((e=>e.setContext(t).draw())),o.getBoundingBox()}static FormatAndDrawTab(t,e,i,s,r,o,a){const l={auto_beam:o,align_rests:!1};"object"==typeof a?n.Merge(l,a):"boolean"==typeof a&&(l.auto_beam=a);const h=new P(p.TIME4_4).setMode(P.Mode.SOFT).addTickables(r),c=new P(p.TIME4_4).setMode(P.Mode.SOFT).addTickables(s),u=l.auto_beam?M.applyAndGetBeams(h):[];(new ut).joinVoices([h],{align_rests:l.align_rests}).joinVoices([c]).formatToStave([h,c],i,{align_rests:l.align_rests}),h.draw(t,i),c.draw(t,e),u.forEach((e=>e.setContext(t).draw())),new A(i,e).setContext(t).draw()}static AlignRestsToNotes(t,e,i){return t.forEach(((n,s)=>{if(n instanceof D&&n.isRest()){if(n.tuplet&&!i)return;const r=n.getGlyph().position.toUpperCase();if("R/4"!==r&&"B/4"!==r)return;if(e||null!=n.beam){const e=n.getKeyProps()[0];if(0===s)e.line=ht(t,e.line,s,!1),n.setKeyLine(0,e.line);else if(s>0&&sut.AlignRestsToNotes(t.getTickables(),e)))}preCalculateMinTotalWidth(t){if(this.hasMinTotalWidth)return this.minTotalWidth;if(!this.tickContexts){if(!t)throw new n.RERR("BadArgument","'voices' required to run preCalculateMinTotalWidth");this.createTickContexts(t)}const{list:e,map:i}=this.tickContexts;return this.minTotalWidth=e.map((t=>{const e=i[t];return e.preFormat(),e.getWidth()})).reduce(((t,e)=>t+e),0),this.hasMinTotalWidth=!0,this.minTotalWidth}getMinTotalWidth(){if(!this.hasMinTotalWidth)throw new n.RERR("NoMinTotalWidth","Call 'preCalculateMinTotalWidth' or 'preFormat' before calling 'getMinTotalWidth'");return this.minTotalWidth}createModifierContexts(t){const e=ct(t,lt,((t,e)=>t.addToModifierContext(e)));return this.modiferContexts=e,e}createTickContexts(t){const e=ct(t,it,((t,e)=>e.addTickable(t)));return e.array.forEach((t=>{t.tContexts=e.array})),this.totalTicks=t[0].getTicksUsed().clone(),this.tickContexts=e,e}preFormat(t=0,e,i,n){const s=this.tickContexts,{list:r,map:o,resolutionMultiplier:a}=s;i&&n&&i.forEach((t=>t.setStave(n).preFormat()));let l=0,h=0;const c=t/2;if(this.minTotalWidth=0,r.forEach((t=>{const i=o[t];e&&i.setContext(e),i.preFormat();const n=i.getWidth();this.minTotalWidth+=n;const s=i.getMetrics();l=l+h+s.extraLeftPx,i.setX(l),h=n-s.extraLeftPx})),this.minTotalWidth=l+h,this.hasMinTotalWidth=!0,t<=0)return;const u=(t-this.minTotalWidth)/(this.totalTicks.value()*a);let d=0;r.forEach(((t,e)=>{const i=r[e-1]||0,n=o[t];d+=(t-i)*u,n.setX(n.getX()+d),n.getCenterAlignedTickables().forEach((t=>{t.center_x_shift=c-n.getX()}))})),1!==r.length&&(this.justifyWidth=t,this.lossHistory=[],this.evaluate())}evaluate(){const t=this.justifyWidth;this.contextGaps={total:0,gaps:[]},this.tickContexts.list.forEach(((t,e)=>{if(0===e)return;const i=this.tickContexts.list[e-1],n=this.tickContexts.map[i],s=this.tickContexts.map[t],r=n.getMetrics(),o=n.getX()+r.width,a=s.getX(),l=a-o;this.contextGaps.total+=l,this.contextGaps.gaps.push({x1:o,x2:a}),s.getFormatterMetrics().freedom.left=l,n.getFormatterMetrics().freedom.right=l}));const e=this.durationStats={};this.voices.forEach((i=>{i.getTickables().forEach(((i,n,s)=>{const r=i.getTicks().clone().simplify().toString(),o=i.getMetrics(),a=i.getFormatterMetrics(),l=i.getX()+o.noteWidth+o.modRightPx+o.extraRightPx;let h=0;if(n{t.getTickables().forEach((t=>{const n=t.getTicks().clone().simplify().toString(),s=t.getFormatterMetrics();s.iterations+=1,s.space.deviation=s.space.used-e[n].mean,s.duration=n,s.space.mean=e[n].mean,i+=Math.pow(e[n].mean,2)}))})),this.totalCost=Math.sqrt(i),this.lossHistory.push(this.totalCost),this}tune(){let t=0;return this.tickContexts.list.forEach(((e,i,n)=>{const s=this.tickContexts.map[e],r=i>0?this.tickContexts.map[n[i-1]]:null,o=it.getFormatterMetrics().space.deviation)).reduce(((t,e)=>t+e));u>0?t=-Math.min(s.getFormatterMetrics().freedom.right,Math.abs(u)):u<0&&(t=o?Math.min(o.getFormatterMetrics().freedom.right,Math.abs(u)):0);const d=Math.min(5,Math.abs(t));t=t>0?d:-d})),this.evaluate()}postFormat(){const t=t=>t.list.forEach((e=>t.map[e].postFormat()));return t(this.modiferContexts),t(this.tickContexts),this}joinVoices(t){return this.createModifierContexts(t),this.hasMinTotalWidth=!1,this}format(t,e,i){const s={align_rests:!1,context:null,stave:null};return n.Merge(s,i),this.voices=t,this.alignRests(t,s.align_rests),this.createTickContexts(t),this.preFormat(e,s.context,t,s.stave),s.stave&&this.postFormat(),this}formatToStave(t,e,i){const s=e.getNoteEndX()-e.getNoteStartX()-10;!function(...t){ut.DEBUG&&n.L("Vex.Flow.Formatter",t)}("Formatting voices to width: ",s);const r={context:e.getContext()};return n.Merge(r,i),this.format(t,s,r)}}class dt extends l{static get Position(){return{LEFT:1,RIGHT:2,ABOVE:3,BELOW:4,BEGIN:5,END:6}}constructor(){super(),this.setAttribute("type","StaveModifier"),this.padding=10,this.position=dt.Position.ABOVE,this.layoutMetrics=null}getPosition(){return this.position}setPosition(t){return this.position=t,this}getStave(){return this.stave}setStave(t){return this.stave=t,this}getWidth(){return this.width}setWidth(t){return this.width=t,this}getX(){return this.x}setX(t){return this.x=t,this}getCategory(){return""}makeSpacer(t){return{getContext:()=>!0,setStave(){},renderToStave(){},getMetrics:()=>({width:t})}}placeGlyphOnLine(t,e,i){t.setYShift(e.getYForLine(i)-e.getYForGlyphs())}getPadding(t){return void 0!==t&&t<2?0:this.padding}setPadding(t){return this.padding=t,this}setLayoutMetrics(t){return this.layoutMetrics=t,this}getLayoutMetrics(){return this.layoutMetrics}}class ft extends dt{static get CATEGORY(){return"barlines"}static get type(){return{SINGLE:1,DOUBLE:2,END:3,REPEAT_BEGIN:4,REPEAT_END:5,REPEAT_BOTH:6,NONE:7}}static get typeString(){return{single:ft.type.SINGLE,double:ft.type.DOUBLE,end:ft.type.END,repeatBegin:ft.type.REPEAT_BEGIN,repeatEnd:ft.type.REPEAT_END,repeatBoth:ft.type.REPEAT_BOTH,none:ft.type.NONE}}constructor(t){super(),this.setAttribute("type","Barline"),this.thickness=p.STAVE_LINE_THICKNESS;const e=ft.type;this.widths={},this.widths[e.SINGLE]=5,this.widths[e.DOUBLE]=5,this.widths[e.END]=5,this.widths[e.REPEAT_BEGIN]=5,this.widths[e.REPEAT_END]=5,this.widths[e.REPEAT_BOTH]=5,this.widths[e.NONE]=5,this.paddings={},this.paddings[e.SINGLE]=0,this.paddings[e.DOUBLE]=0,this.paddings[e.END]=0,this.paddings[e.REPEAT_BEGIN]=15,this.paddings[e.REPEAT_END]=15,this.paddings[e.REPEAT_BOTH]=15,this.paddings[e.NONE]=0,this.layoutMetricsMap={},this.layoutMetricsMap[e.SINGLE]={xMin:0,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[e.DOUBLE]={xMin:-3,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[e.END]={xMin:-5,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[e.REPEAT_END]={xMin:-10,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[e.REPEAT_BEGIN]={xMin:-2,xMax:10,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[e.REPEAT_BOTH]={xMin:-10,xMax:10,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[e.NONE]={xMin:0,xMax:0,paddingLeft:5,paddingRight:5},this.setPosition(dt.Position.BEGIN),this.setType(t)}getCategory(){return ft.CATEGORY}getType(){return this.type}setType(t){return this.type="string"==typeof t?ft.typeString[t]:t,this.setWidth(this.widths[this.type]),this.setPadding(this.paddings[this.type]),this.setLayoutMetrics(this.layoutMetricsMap[this.type]),this}draw(t){switch(t.checkContext(),this.setRendered(),this.type){case ft.type.SINGLE:this.drawVerticalBar(t,this.x,!1);break;case ft.type.DOUBLE:this.drawVerticalBar(t,this.x,!0);break;case ft.type.END:this.drawVerticalEndBar(t,this.x);break;case ft.type.REPEAT_BEGIN:this.drawRepeatBar(t,this.x,!0),t.getX()!==this.x&&this.drawVerticalBar(t,t.getX());break;case ft.type.REPEAT_END:this.drawRepeatBar(t,this.x,!1);break;case ft.type.REPEAT_BOTH:this.drawRepeatBar(t,this.x,!1),this.drawRepeatBar(t,this.x,!0)}}drawVerticalBar(t,e,i){t.checkContext();const n=t.getTopLineTopY(),s=t.getBottomLineBottomY();i&&t.context.fillRect(e-3,n,1,s-n),t.context.fillRect(e,n,1,s-n)}drawVerticalEndBar(t,e){t.checkContext();const i=t.getTopLineTopY(),n=t.getBottomLineBottomY();t.context.fillRect(e-5,i,1,n-i),t.context.fillRect(e-2,i,3,n-i)}drawRepeatBar(t,e,i){t.checkContext();const n=t.getTopLineTopY(),s=t.getBottomLineBottomY();let r=3;i||(r=-5),t.context.fillRect(e+r,n,1,s-n),t.context.fillRect(e-2,n,3,s-n),i?r+=4:r-=4;const o=e+r+1;let a=(t.getNumLines()-1)*t.getSpacingBetweenLines();a=a/2-t.getSpacingBetweenLines()/2;let l=n+a+1;t.context.beginPath(),t.context.arc(o,l,2,0,2*Math.PI,!1),t.context.fill(),l+=t.getSpacingBetweenLines(),t.context.beginPath(),t.context.arc(o,l,2,0,2*Math.PI,!1),t.context.fill()}}class pt extends dt{static get CATEGORY(){return"repetitions"}static get type(){return{NONE:1,CODA_LEFT:2,CODA_RIGHT:3,SEGNO_LEFT:4,SEGNO_RIGHT:5,DC:6,DC_AL_CODA:7,DC_AL_FINE:8,DS:9,DS_AL_CODA:10,DS_AL_FINE:11,FINE:12,TO_CODA:13}}constructor(t,e,i){super(),this.setAttribute("type","Repetition"),this.symbol_type=t,this.x=e,this.x_shift=0,this.y_shift=i,this.font={family:"times",size:12,weight:"bold italic"}}getCategory(){return pt.CATEGORY}setShiftX(t){return this.x_shift=t,this}setShiftY(t){return this.y_shift=t,this}setX(t){return this.x=t,this}draw(t,e){switch(this.setRendered(),this.symbol_type){case pt.type.CODA_RIGHT:this.drawCodaFixed(t,e+t.width);break;case pt.type.CODA_LEFT:this.drawSymbolText(t,e,"Coda",!0);break;case pt.type.SEGNO_LEFT:this.drawSignoFixed(t,e);break;case pt.type.SEGNO_RIGHT:this.drawSignoFixed(t,e+t.width);break;case pt.type.DC:this.drawSymbolText(t,e,"D.C.",!1);break;case pt.type.DC_AL_CODA:this.drawSymbolText(t,e,"D.C. al",!0);break;case pt.type.DC_AL_FINE:this.drawSymbolText(t,e,"D.C. al Fine",!1);break;case pt.type.DS:this.drawSymbolText(t,e,"D.S.",!1);break;case pt.type.DS_AL_CODA:this.drawSymbolText(t,e,"D.S. al",!0);break;case pt.type.DS_AL_FINE:this.drawSymbolText(t,e,"D.S. al Fine",!1);break;case pt.type.FINE:this.drawSymbolText(t,e,"Fine",!1);break;case pt.type.TO_CODA:this.drawSymbolText(t,e,"To",!0)}return this}drawCodaFixed(t,e){const i=t.getYForTopText(t.options.num_lines)+this.y_shift;return f.renderGlyph(t.context,this.x+e+this.x_shift,i+25,40,"v4d",!0),this}drawSignoFixed(t,e){const i=t.getYForTopText(t.options.num_lines)+this.y_shift;return f.renderGlyph(t.context,this.x+e+this.x_shift,i+25,30,"v8c",!0),this}drawSymbolText(t,e,i,n){const s=t.checkContext();s.save(),s.setFont(this.font.family,this.font.size,this.font.weight);let r=0+this.x_shift,o=e+this.x_shift;this.symbol_type===pt.type.CODA_LEFT?(r=this.x+t.options.vertical_bar_width,o=r+s.measureText(i).width+12):this.symbol_type===pt.type.TO_CODA||this.symbol_type===pt.type.DS_AL_CODA?(this.x_shift=-(r+s.measureText(i).width+12+t.options.vertical_bar_width+12),r=this.x+this.x_shift+t.options.vertical_bar_width,o=r+s.measureText(i).width+12):(o=this.x+e+t.width-5+this.x_shift,r=o-+s.measureText(i).width-12);const a=t.getYForTopText(t.options.num_lines)+this.y_shift+25;return n&&f.renderGlyph(s,o,a,40,"v4d",!0),s.fillText(i,r,a+5),s.restore(),this}}class mt extends dt{static get CATEGORY(){return"stavesection"}constructor(t,e,i){super(),this.setAttribute("type","StaveSection"),this.setWidth(16),this.section=t,this.x=e,this.shift_x=0,this.shift_y=i,this.font={family:"sans-serif",size:12,weight:"bold"}}getCategory(){return mt.CATEGORY}setStaveSection(t){return this.section=t,this}setShiftX(t){return this.shift_x=t,this}setShiftY(t){return this.shift_y=t,this}draw(t,e){const i=t.checkContext();this.setRendered(),i.save(),i.lineWidth=2,i.setFont(this.font.family,this.font.size,this.font.weight);const n=i.measureText(""+this.section),s=n.width,r=n.height;let o=s+6;o<18&&(o=18);const a=r,l=t.getYForTopText(3)+this.shift_y;let h=this.x+e;return i.beginPath(),i.lineWidth=2,i.rect(h,l+r/4,o,a),i.stroke(),h+=(o-s)/2,i.fillText(""+this.section,h,l+16),i.restore(),this}}class bt extends dt{static get CATEGORY(){return"stavetempo"}constructor(t,e,i){super(),this.setAttribute("type","StaveTempo"),this.tempo=t,this.position=F.Position.ABOVE,this.x=e,this.shift_x=10,this.shift_y=i,this.font={family:"times",size:14,weight:"bold"},this.render_options={glyph_font_scale:30}}getCategory(){return bt.CATEGORY}setTempo(t){return this.tempo=t,this}setShiftX(t){return this.shift_x=t,this}setShiftY(t){return this.shift_y=t,this}draw(t,e){const i=t.checkContext();this.setRendered();const n=this.render_options,s=n.glyph_font_scale/38,r=this.tempo.name,o=this.tempo.duration,a=this.tempo.dots,l=this.tempo.bpm,h=this.font;let c=this.x+this.shift_x+e;const u=t.getYForTopText(1)+this.shift_y;if(i.save(),r&&(i.setFont(h.family,h.size,h.weight),i.fillText(r,c,u),c+=i.measureText(r).width),o&&l){i.setFont(h.family,h.size,"normal"),r&&(c+=i.measureText(" ").width,i.fillText("(",c,u),c+=i.measureText("(").width);const t=p.getGlyphProps(o);if(c+=3*s,f.renderGlyph(i,c,u,n.glyph_font_scale,t.code_head),c+=t.getWidth()*s,t.stem){let e=30;t.beam_count&&(e+=3*(t.beam_count-1)),e*=s;const r=u-e;i.fillRect(c-s,r,s,e),t.flag&&(f.renderGlyph(i,c,r,n.glyph_font_scale,t.code_flag_upstem),a||(c+=6*s))}for(let t=0;t=t.line?i.above:i.below)}this.placeGlyphOnLine(n,this.stave,t.line),this.glyphs.push(n);const r=this.xPositions[this.xPositions.length-1],o=n.getMetrics().width+s;this.xPositions.push(r+o),this.width+=o}cancelKey(t){return this.formatted=!1,this.cancelKeySpec=t,this}convertToCancelAccList(t){const e=p.keySignature(t),i=this.accList.length>0&&e.length>0&&e[0].type!==this.accList[0].type,n=i?e.length:e.length-this.accList.length;if(n<1)return;const s=[];for(let t=0;t0?t[0].type:null;let i;if(this.cancelKeySpec&&(i=this.convertToCancelAccList(this.cancelKeySpec)),this.alterKeySpec&&this.convertToAlterAccList(this.alterKeySpec),this.accList.length>0){const n=(this.position===dt.Position.END?this.stave.endClef:this.stave.clef)||this.stave.clef;i&&this.convertAccLines(n,i.type,i.accList),this.convertAccLines(n,e,t);for(let t=0;t{const e=t.split("/").filter((t=>""!==t));if(2!==e.length)throw new n.RERR("BadTimeSignature",`Invalid time spec: ${t}. Must be in the form "/"`);e.forEach((e=>{if(isNaN(Number(e)))throw new n.RERR("BadTimeSignature",`Invalid time spec: ${t}. Must contain two valid numbers.`)}))})(t);const[e,i]=t.split("/").map((t=>t.split("")));return{num:!0,glyph:this.makeTimeSignatureGlyph(e,i)}}makeTimeSignatureGlyph(t,e){const i=new f("v0",this.point);i.topGlyphs=[],i.botGlyphs=[];let n=0;for(let e=0;es?n:s,o=i.getMetrics().x_min;i.getMetrics=()=>({x_min:o,x_max:o+r,width:r});const a=(r-n)/2,l=(r-s)/2,h=this;return i.renderToStave=function(t){let e=t+a;for(let t=0;ti.getWidth()&&(e-=i.getWidth()),e}setRepetitionTypeLeft(t,e){return this.modifiers.push(new pt(t,this.x,e)),this}setRepetitionTypeRight(t,e){return this.modifiers.push(new pt(t,this.x,e)),this}setVoltaType(t,e,i){return this.modifiers.push(new Et(t,e,this.x,i)),this}setSection(t,e,i=0,n=12){const s=new mt(t,this.x+i,e);return s.font.size=n,this.modifiers.push(s),this}setTempo(t,e){return this.modifiers.push(new bt(t,this.x,e)),this}setText(t,e,i){return this.modifiers.push(new yt(t,e,i)),this}getHeight(){return this.height}getSpacingBetweenLines(){return this.options.spacing_between_lines_px}getBoundingBox(){return new c(this.x,this.y,this.width,this.getBottomY()-this.y)}getBottomY(){const t=this.options,e=t.spacing_between_lines_px;return this.getYForLine(t.num_lines)+t.space_below_staff_ln*e}getBottomLineY(){return this.getYForLine(this.options.num_lines)}getYForLine(t){const e=this.options,i=e.spacing_between_lines_px,n=e.space_above_staff_ln;return this.y+t*i+n*i}getLineForY(t){const e=this.options,i=e.spacing_between_lines_px,n=e.space_above_staff_ln;return(t-this.y)/i-n}getYForTopText(t){const e=t||0;return this.getYForLine(-e-this.options.top_text_position)}getYForBottomText(t){const e=t||0;return this.getYForLine(this.options.bottom_text_position+e)}getYForNote(t){const e=this.options,i=e.spacing_between_lines_px,n=e.space_above_staff_ln;return this.y+n*i+5*i-t*i}getYForGlyphs(){return this.getYForLine(3)}addModifier(t,e){return void 0!==e&&t.setPosition(e),t.setStave(this),this.formatted=!1,this.modifiers.push(t),this}addEndModifier(t){return this.addModifier(t,dt.Position.END),this}setBegBarType(t){const{SINGLE:e,REPEAT_BEGIN:i,NONE:n}=ft.type;return t!==e&&t!==i&&t!==n||(this.modifiers[0].setType(t),this.formatted=!1),this}setEndBarType(t){return t!==ft.type.REPEAT_BEGIN&&(this.modifiers[1].setType(t),this.formatted=!1),this}setClef(t,e,i,n){void 0===n&&(n=dt.Position.BEGIN),n===dt.Position.END?this.endClef=t:this.clef=t;const s=this.getModifiers(n,St.CATEGORY);return 0===s.length?this.addClef(t,e,i,n):s[0].setType(t,e,i),this}setEndClef(t,e,i){return this.setClef(t,e,i,dt.Position.END),this}setKeySignature(t,e,i){void 0===i&&(i=dt.Position.BEGIN);const n=this.getModifiers(i,vt.CATEGORY);return 0===n.length?this.addKeySignature(t,e,i):n[0].setKeySig(t,e),this}setEndKeySignature(t,e){return this.setKeySignature(t,e,dt.Position.END),this}setTimeSignature(t,e,i){void 0===i&&(i=dt.Position.BEGIN);const n=this.getModifiers(i,xt.CATEGORY);return 0===n.length?this.addTimeSignature(t,e,i):n[0].setTimeSig(t),this}setEndTimeSignature(t,e){return this.setTimeSignature(t,e,dt.Position.END),this}addKeySignature(t,e,i){return void 0===i&&(i=dt.Position.BEGIN),this.addModifier(new vt(t,e).setPosition(i),i),this}addClef(t,e,i,n){return void 0===n||n===dt.Position.BEGIN?this.clef=t:n===dt.Position.END&&(this.endClef=t),this.addModifier(new St(t,e,i),n),this}addEndClef(t,e,i){return this.addClef(t,e,i,dt.Position.END),this}addTimeSignature(t,e,i){return this.addModifier(new xt(t,e),i),this}addEndTimeSignature(t,e){return this.addTimeSignature(t,e,dt.Position.END),this}addTrebleGlyph(){return this.addClef("treble"),this}getModifiers(t,e){return void 0===t&&void 0===e?this.modifiers:this.modifiers.filter((i=>!(void 0!==t&&t!==i.getPosition()||void 0!==e&&e!==i.getCategory())))}sortByCategory(t,e){for(let i=t.length-1;i>=0;i--)for(let n=0;ne[t[n+1].getCategory()]){const e=t[n];t[n]=t[n+1],t[n+1]=e}}format(){const t=this.modifiers[0],e=this.modifiers[1],i=this.getModifiers(dt.Position.BEGIN),n=this.getModifiers(dt.Position.END);let s,r,o;this.sortByCategory(i,{barlines:0,clefs:1,keysignatures:2,timesignatures:3}),this.sortByCategory(n,{timesignatures:0,keysignatures:1,barlines:2,clefs:3}),i.length>1&&t.getType()===ft.type.REPEAT_BEGIN&&(i.push(i.splice(0,1)[0]),i.splice(0,0,new ft(ft.type.SINGLE))),n.indexOf(e)>0&&n.splice(0,0,new ft(ft.type.NONE));let a=0,l=this.x;for(let t=0;t0){this.context.save(),this.context.setFont(this.font.family,this.font.size,this.font.weight);const t=this.context.measureText(""+this.measure).width;n=this.getYForTopText(0)+3,this.context.fillText(""+this.measure,this.x-t/2,n),this.context.restore()}return this}drawVertical(t,e){this.drawVerticalFixed(this.x+t,e)}drawVerticalFixed(t,e){this.checkContext();const i=this.getYForLine(0),n=this.getYForLine(this.options.num_lines-1);e&&this.context.fillRect(t-3,i,1,n-i+1),this.context.fillRect(t,i,1,n-i+1)}drawVerticalBar(t){this.drawVerticalBarFixed(this.x+t,!1)}drawVerticalBarFixed(t){this.checkContext();const e=this.getYForLine(0),i=this.getYForLine(this.options.num_lines-1);this.context.fillRect(t,e,1,i-e+1)}getConfigForLines(){return this.options.line_config}setConfigForLine(t,e){if(t>=this.options.num_lines||t<0)throw new n.RERR("StaveConfigError","The line number must be within the range of the number of lines in the Stave.");if(void 0===e.visible)throw new n.RERR("StaveConfigError","The line configuration object is missing the 'visible' property.");if("boolean"!=typeof e.visible)throw new n.RERR("StaveConfigError","The line configuration objects 'visible' property must be true or false.");return this.options.line_config[t]=e,this}setConfigForLines(t){if(t.length!==this.options.num_lines)throw new n.RERR("StaveConfigError","The length of the lines configuration array must match the number of lines in the Stave");for(const e in t)t[e]||(t[e]=this.options.line_config[e]),n.Merge(this.options.line_config[e],t[e]);return this.options.line_config=t,this}}class wt extends _t{constructor(t,e,i,s){const r={spacing_between_lines_px:13,num_lines:6,top_text_position:1};n.Merge(r,s),super(t,e,i,r),this.setAttribute("type","TabStave")}getYForGlyphs(){return this.getYForLine(2.5)}addTabGlyph(){return this.addClef("tab"),this}}class Tt extends N{static get CATEGORY(){return"tabnotes"}constructor(t,e){if(super(t),this.setAttribute("type","TabNote"),this.ghost=!1,this.positions=t.positions,n.Merge(this.render_options,{glyph_font_scale:p.DEFAULT_TABLATURE_FONT_SCALE,draw_stem:e,draw_dots:e,draw_stem_through_stave:!1,y_shift:0,scale:1,font:"10pt Arial"}),this.glyph=p.getGlyphProps(this.duration,this.noteType),!this.glyph)throw new n.RuntimeError("BadArguments",`Invalid note initialization data (No glyph found): ${JSON.stringify(t)}`);this.buildStem(),t.stem_direction?this.setStemDirection(t.stem_direction):this.setStemDirection(x.UP),this.ghost=!1,this.updateWidth()}reset(){this.stave&&this.setStave(this.stave)}getCategory(){return Tt.CATEGORY}setGhost(t){return this.ghost=t,this.updateWidth(),this}hasStem(){return this.render_options.draw_stem}getStemExtension(){const t=this.getGlyph();return null!=this.stem_extension_override?this.stem_extension_override:t?1===this.getStemDirection()?t.tabnote_stem_up_extension:t.tabnote_stem_down_extension:0}addDot(){const t=new B;return this.dots+=1,this.addModifier(t,0)}updateWidth(){this.glyphs=[],this.width=0;for(let t=0;tthis.width}setStave(t){let e;if(super.setStave(t),this.context=t.context,this.context){const t=this.context;for(this.width=0,e=0;ei.width),this.width=Math.max(i.getWidth(),this.width)}this.glyph.getWidth=()=>this.width}const i=this.positions.map((({str:e})=>t.getYForLine(e-1)));return this.setYs(i),this.stem&&this.stem.setYBounds(this.getStemY(),this.getStemY()),this}getPositions(){return this.positions}addToModifierContext(t){this.setModifierContext(t);for(let t=0;t{("dots"!==t.getCategory()||this.render_options.draw_dots)&&(t.setContext(this.context),t.drawWithStyle())}))}drawStemThrough(){const t=this.getStemX(),e=this.getStemY(),i=this.context,n=this.render_options.draw_stem_through_stave;if(this.render_options.draw_stem&&n){const n=function(t,e,i,n){const s=1!==n,r=-1!==n,o=i.getSpacingBetweenLines(),a=i.getNumLines(),l=[];return e.forEach((e=>{const h=e.indexOf(a)>-1,c=e.indexOf(1)>-1;if(s&&c||r&&h)return;1===e.length&&e.push(e[0]);const u=[];e.forEach(((e,s,r)=>{const l=1===e,h=e===a;let c=i.getYForLine(e-1);0!==s||l?s!==r.length-1||h||(c+=o/2-1):c-=o/2-1,u.push(c),1===n&&l?u.push(t-2):-1===n&&h&&u.push(t+2)})),l.push(u.sort(((t,e)=>t-e)))})),l}(e,function(t,e){const i=[];let n=[];for(let s=1;s<=t;s++)e.indexOf(s)>-1?(i.push(n),n=[]):n.push(s);return n.length>0&&i.push(n),i}(this.stave.getNumLines(),this.positions.map((t=>t.str))),this.getStave(),this.getStemDirection());i.save(),i.setLineWidth(x.WIDTH),n.forEach((e=>{0!==e.length&&(i.beginPath(),i.moveTo(t,e[0]),i.lineTo(t,e[e.length-1]),i.stroke(),i.closePath())})),i.restore()}}drawPositions(){const t=this.context,e=this.getAbsoluteX(),i=this.ys;for(let n=0;nparseInt(n,10)?Rt.SLIDE_DOWN:Rt.SLIDE_UP}this.slide_direction=e,this.render_options.cp1=11,this.render_options.cp2=14,this.render_options.y_shift=.5,this.setFont({font:"Times",size:10,style:"bold italic"}),this.setNotes(t)}renderTie(t){if(0===t.first_ys.length||0===t.last_ys.length)throw new n.RERR("BadArguments","No Y-values to render");const e=this.context,i=t.first_x_px,s=t.first_ys,r=t.last_x_px,o=this.slide_direction;if(o!==Rt.SLIDE_UP&&o!==Rt.SLIDE_DOWN)throw new n.RERR("BadSlide","Invalid slide direction");for(let t=0;tthis.numStrings)throw new n.RERR("BadArguments",`String number must be between 1 and ${this.numStrings}:${t}`);return this.tuningValues[e-1]}getValueForFret(t,e){const i=this.getValueForString(e),s=parseInt(t,10);if(s<0)throw new n.RERR("BadArguments","Fret number must be 0 or higher: "+t);return i+s}getNoteForFret(t,e){const i=this.getValueForFret(t,e),n=Math.floor(i/12),s=i%12;return p.integerToNote(s)+"/"+n}}class Ot extends l{static get type(){return{CRESC:1,DECRESC:2}}static FormatByTicksAndDraw(t,e,i,s,r,o){const a=e.pixelsPerTick;if(null==a)throw new n.RuntimeError("BadArguments","A valid Formatter must be provide to draw offsets by ticks.");const l=a*o.left_shift_ticks,h=a*o.right_shift_ticks,c={height:o.height,y_shift:o.y_shift,left_shift_px:l,right_shift_px:h};new Ot({first_note:i.first_note,last_note:i.last_note},s).setContext(t).setRenderOptions(c).setPosition(r).draw()}constructor(t,e){super(),this.setAttribute("type","StaveHairpin"),this.notes=t,this.hairpin=e,this.position=F.Position.BELOW,this.render_options={height:10,y_shift:0,left_shift_px:0,right_shift_px:0},this.setNotes(t)}setPosition(t){return t!==F.Position.ABOVE&&t!==F.Position.BELOW||(this.position=t),this}setRenderOptions(t){return null!=t.height&&null!=t.y_shift&&null!=t.left_shift_px&&null!=t.right_shift_px&&(this.render_options=t),this}setNotes(t){if(!t.first_note&&!t.last_note)throw new n.RuntimeError("BadArguments","Hairpin needs to have either first_note or last_note set.");return this.first_note=t.first_note,this.last_note=t.last_note,this}renderHairpin(t){const e=this.checkContext();let i=this.render_options.y_shift+20,n=t.first_y;this.position===F.Position.ABOVE&&(i=30-i,n=t.first_y-t.staff_height);const s=this.render_options.left_shift_px,r=this.render_options.right_shift_px;switch(e.beginPath(),this.hairpin){case Ot.type.CRESC:e.moveTo(t.last_x+r,n+i),e.lineTo(t.first_x+s,n+this.render_options.height/2+i),e.lineTo(t.last_x+r,n+this.render_options.height+i);break;case Ot.type.DECRESC:e.moveTo(t.first_x+s,n+i),e.lineTo(t.last_x+r,n+this.render_options.height/2+i),e.lineTo(t.first_x+s,n+this.render_options.height+i)}e.stroke(),e.closePath()}draw(){this.checkContext(),this.setRendered();const t=this.first_note,e=this.last_note,i=t.getModifierStartXY(this.position,0),n=e.getModifierStartXY(this.position,0);return this.renderHairpin({first_x:i.x,last_x:n.x,first_y:t.getStave().y+t.getStave().height,last_y:e.getStave().y+e.getStave().height,staff_height:t.getStave().height}),!0}}class Dt extends l{static get Position(){return{NEAR_HEAD:1,NEAR_TOP:2}}static get PositionString(){return{nearHead:Dt.Position.NEAR_HEAD,nearTop:Dt.Position.NEAR_TOP}}constructor(t,e,i){super(),this.setAttribute("type","Curve"),this.render_options={spacing:2,thickness:2,x_shift:0,y_shift:10,position:Dt.Position.NEAR_HEAD,position_end:Dt.Position.NEAR_HEAD,invert:!1,cps:[{x:0,y:10},{x:0,y:10}]},n.Merge(this.render_options,i),this.setNotes(t,e)}setNotes(t,e){if(!t&&!e)throw new n.RuntimeError("BadArguments","Curve needs to have either first_note or last_note set.");return this.from=t,this.to=e,this}isPartial(){return!this.from||!this.to}renderCurve(t){const e=this.context,i=this.render_options.cps,n=this.render_options.x_shift,s=this.render_options.y_shift*t.direction,r=t.first_x+n,o=t.first_y+s,a=t.last_x-n,l=t.last_y+s,h=this.render_options.thickness,c=(a-r)/(i.length+2);e.beginPath(),e.moveTo(r,o),e.bezierCurveTo(r+c+i[0].x,o+i[0].y*t.direction,a-c+i[1].x,l+i[1].y*t.direction,a,l),e.bezierCurveTo(a-c+i[1].x,l+(i[1].y+h)*t.direction,r+c+i[0].x,o+(i[0].y+h)*t.direction,r,o),e.stroke(),e.closePath(),e.fill()}draw(){this.checkContext(),this.setRendered();const t=this.from,e=this.to;let i,n,s,r,o,a="baseY",l="baseY";function h(t){return"string"==typeof t?Dt.PositionString[t]:t}const c=h(this.render_options.position),u=h(this.render_options.position_end);return c===Dt.Position.NEAR_TOP&&(a="topY",l="topY"),u===Dt.Position.NEAR_HEAD?l="baseY":u===Dt.Position.NEAR_TOP&&(l="topY"),t?(i=t.getTieRightX(),o=t.getStemDirection(),s=t.getStemExtents()[a]):(i=e.getStave().getTieStartX(),s=e.getStemExtents()[a]),e?(n=e.getTieLeftX(),o=e.getStemDirection(),r=e.getStemExtents()[l]):(n=t.getStave().getTieEndX(),r=t.getStemExtents()[l]),this.renderCurve({first_x:i,last_x:n,first_y:s,last_y:r,direction:o*(!0===this.render_options.invert?-1:1)}),!0}}function kt(...t){Vt.DEBUG&&n.L("Vex.Flow.TextDynamics",t)}class Vt extends I{static get GLYPHS(){return{f:{code:"vba",width:12},p:{code:"vbf",width:14},m:{code:"v62",width:17},s:{code:"v4a",width:10},z:{code:"v80",width:12},r:{code:"vb1",width:12}}}constructor(t){super(t),this.setAttribute("type","TextDynamics"),this.sequence=t.text.toLowerCase(),this.line=t.line||0,this.glyphs=[],n.Merge(this.render_options,{glyph_font_size:40}),kt("New Dynamics Text: ",this.sequence)}setLine(t){return this.line=t,this}preFormat(){let t=0;return this.sequence.split("").forEach((e=>{const i=Vt.GLYPHS[e];if(!i)throw new n.RERR("Invalid dynamics character: "+e);const s=this.render_options.glyph_font_size,r=new f(i.code,s);this.glyphs.push(r),t+=i.width})),this.setWidth(t),this.preFormatted=!0,this}draw(){this.setRendered();const t=this.getAbsoluteX(),e=this.stave.getYForLine(this.line+-3);kt("Rendering Dynamics: ",this.sequence);let i=t;this.glyphs.forEach(((t,n)=>{const s=this.sequence[n];t.render(this.context,i,e),i+=Vt.GLYPHS[s].width}))}}function Gt(t,e,i,n,s,r,o){t.beginPath(),t.moveTo(e,i),t.lineTo(n,s),t.lineTo(r,o),t.lineTo(e,i),t.closePath(),t.fill()}class Wt extends l{static get TextVerticalPosition(){return{TOP:1,BOTTOM:2}}static get TextJustification(){return{LEFT:1,CENTER:2,RIGHT:3}}constructor(t){super(),this.setAttribute("type","StaveLine"),this.notes=t,this.text="",this.font={family:"Arial",size:10,weight:""},this.render_options={padding_left:4,padding_right:3,line_width:1,line_dash:null,rounded_end:!0,color:null,draw_start_arrow:!1,draw_end_arrow:!1,arrowhead_length:10,arrowhead_angle:Math.PI/8,text_position_vertical:Wt.TextVerticalPosition.TOP,text_justification:Wt.TextJustification.CENTER},this.setNotes(t)}setFont(t){return this.font=t,this}setText(t){return this.text=t,this}setNotes(t){if(!t.first_note&&!t.last_note)throw new n.RuntimeError("BadArguments","Notes needs to have either first_note or last_note set.");if(t.first_indices||(t.first_indices=[0]),t.last_indices||(t.last_indices=[0]),t.first_indices.length!==t.last_indices.length)throw new n.RuntimeError("BadArguments","Connected notes must have similar index sizes");return this.first_note=t.first_note,this.first_indices=t.first_indices,this.last_note=t.last_note,this.last_indices=t.last_indices,this}applyLineStyle(){const t=this.checkContext(),e=this.render_options;e.line_dash&&t.setLineDash(e.line_dash),e.line_width&&t.setLineWidth(e.line_width),e.rounded_end?t.setLineCap("round"):t.setLineCap("square")}applyFontStyle(){const t=this.checkContext();this.font&&t.setFont(this.font.family,this.font.size,this.font.weight),this.render_options.color&&(t.setStrokeStyle(this.render_options.color),t.setFillStyle(this.render_options.color))}draw(){const t=this.checkContext();this.setRendered();const e=this.first_note,i=this.last_note,n=this.render_options;let s,r;t.save(),this.applyLineStyle(),this.first_indices.forEach(((o,a)=>{const l=this.last_indices[a];s=e.getModifierStartXY(2,o),r=i.getModifierStartXY(1,l);const h=s.y>r.y;s.x+=e.getMetrics().modRightPx+n.padding_left,r.x-=i.getMetrics().modLeftPx+n.padding_right;const c=e.getGlyph().getWidth();e.getKeyProps()[o].displaced&&1===e.getStemDirection()&&(s.x+=c+n.padding_left),i.getKeyProps()[l].displaced&&-1===i.getStemDirection()&&(r.x-=c+n.padding_right),s.y+=h?-3:1,r.y+=h?2:0,function(t,e,i,n){const s=n.draw_start_arrow&&n.draw_end_arrow,r=e.x,o=e.y,a=i.x,l=i.y,h=Math.sqrt((a-r)*(a-r)+(l-o)*(l-o)),c=(h-n.arrowhead_length/3)/h;let u,d,f,p;n.draw_end_arrow||s?(u=Math.round(r+(a-r)*c),d=Math.round(o+(l-o)*c)):(u=a,d=l),n.draw_start_arrow||s?(f=r+(a-r)*(1-c),p=o+(l-o)*(1-c)):(f=r,p=o),n.color&&(t.setStrokeStyle(n.color),t.setFillStyle(n.color)),t.beginPath(),t.moveTo(f,p),t.lineTo(u,d),t.stroke(),t.closePath();const m=Math.atan2(l-o,a-r),b=Math.abs(n.arrowhead_length/Math.cos(n.arrowhead_angle));let g,y,S,v,x,E;(n.draw_end_arrow||s)&&(g=m+Math.PI+n.arrowhead_angle,S=a+Math.cos(g)*b,v=l+Math.sin(g)*b,y=m+Math.PI-n.arrowhead_angle,x=a+Math.cos(y)*b,E=l+Math.sin(y)*b,Gt(t,S,v,a,l,x,E)),(n.draw_start_arrow||s)&&(g=m+n.arrowhead_angle,S=r+Math.cos(g)*b,v=o+Math.sin(g)*b,y=m-n.arrowhead_angle,x=r+Math.cos(y)*b,E=o+Math.sin(y)*b,Gt(t,S,v,r,o,x,E))}(t,s,r,this.render_options)})),t.restore();const o=t.measureText(this.text).width,a=n.text_justification;let l,h=0;a===Wt.TextJustification.LEFT?h=s.x:a===Wt.TextJustification.CENTER?h=(r.x-s.x)/2+s.x-o/2:a===Wt.TextJustification.RIGHT&&(h=r.x-o);const c=n.text_position_vertical;return c===Wt.TextVerticalPosition.TOP?l=e.getStave().getYForTopText():c===Wt.TextVerticalPosition.BOTTOM&&(l=e.getStave().getYForBottomText(p.TEXT_HEIGHT_OFFSET_HACK)),t.save(),this.applyFontStyle(),t.fillText(this.text,h,l),t.restore(),this}}function Ut(t,e,i,n,s){const r=zt.GLYPHS[t];new f(r.code,s).render(e,i+r.x_shift,n+r.y_shift)}class zt extends l{static get GLYPHS(){return{pedal_depress:{code:"v36",x_shift:-10,y_shift:0},pedal_release:{code:"v5d",x_shift:-2,y_shift:3}}}static get Styles(){return{TEXT:1,BRACKET:2,MIXED:3}}static get StylesString(){return{text:zt.Styles.TEXT,bracket:zt.Styles.BRACKET,mixed:zt.Styles.MIXED}}static createSustain(t){return new zt(t)}static createSostenuto(t){const e=new zt(t);return e.setStyle(zt.Styles.MIXED),e.setCustomText("Sost. Ped."),e}static createUnaCorda(t){const e=new zt(t);return e.setStyle(zt.Styles.TEXT),e.setCustomText("una corda","tre corda"),e}constructor(t){super(),this.setAttribute("type","PedalMarking"),this.notes=t,this.style=zt.TEXT,this.line=0,this.custom_depress_text="",this.custom_release_text="",this.font={family:"Times New Roman",size:12,weight:"italic bold"},this.render_options={bracket_height:10,text_margin_right:6,bracket_line_width:1,glyph_point_size:40,color:"black"}}setCustomText(t,e){return this.custom_depress_text=t||"",this.custom_release_text=e||"",this}setStyle(t){if(t<1&&t>3)throw new n.RERR("InvalidParameter","The style must be one found in PedalMarking.Styles");return this.style=t,this}setLine(t){return this.line=t,this}drawBracketed(){const t=this.context;let e,i,s=!1;const r=this;this.notes.forEach(((o,a,l)=>{s=!s;const h=o.getAbsoluteX(),c=o.getStave().getYForBottomText(r.line+3);if(h{e=!e;const r=s.getStave(),o=s.getAbsoluteX(),a=r.getYForBottomText(i.line+3);let l=0;e?i.custom_depress_text?(l=t.measureText(i.custom_depress_text).width,t.fillText(i.custom_depress_text,o-l/2,a)):Ut("pedal_depress",t,o,a,n):i.custom_release_text?(l=t.measureText(i.custom_release_text).width,t.fillText(i.custom_release_text,o-l/2,a)):Ut("pedal_release",t,o,a,n)}))}draw(){const t=this.checkContext();this.setRendered(),t.save(),t.setStrokeStyle(this.render_options.color),t.setFillStyle(this.render_options.color),t.setFont(this.font.family,this.font.size,this.font.weight),function(...t){zt.DEBUG&&n.L("Vex.Flow.PedalMarking",t)}("Rendering Pedal Marking"),this.style===zt.Styles.BRACKET||this.style===zt.Styles.MIXED?(t.setLineWidth(this.render_options.bracket_line_width),this.drawBracketed()):this.style===zt.Styles.TEXT&&this.drawText(),t.restore()}}class jt extends l{static get Positions(){return{TOP:1,BOTTOM:-1}}static get PositionString(){return{top:jt.Positions.TOP,bottom:jt.Positions.BOTTOM}}constructor({start:t,stop:e,text:i="",superscript:n="",position:s=jt.Positions.TOP}){super(),this.setAttribute("type","TextBracket"),this.start=t,this.stop=e,this.text=i,this.superscript=n,this.position="string"==typeof s?jt.PositionString[s]:s,this.line=1,this.font={family:"Serif",size:15,weight:"italic"},this.render_options={dashed:!0,dash:[5],color:"black",line_width:1,show_bracket:!0,bracket_height:8,underline_superscript:!0}}applyStyle(t){return t.setFont(this.font.family,this.font.size,this.font.weight),t.setStrokeStyle(this.render_options.color),t.setFillStyle(this.render_options.color),t.setLineWidth(this.render_options.line_width),this}setDashed(t,e){return this.render_options.dashed=t,e&&(this.render_options.dash=e),this}setFont(t){return this.font={...this.font,...t},this}setLine(t){return this.line=t,this}draw(){const t=this.context;this.setRendered();let e=0;switch(this.position){case jt.Positions.TOP:e=this.start.getStave().getYForTopText(this.line);break;case jt.Positions.BOTTOM:e=this.start.getStave().getYForBottomText(this.line+p.TEXT_HEIGHT_OFFSET_HACK);break;default:throw new n.RERR("InvalidPosition",`The position ${this.position} is invalid`)}const i={x:this.start.getAbsoluteX(),y:e},s={x:this.stop.getAbsoluteX(),y:e};!function(...t){jt.DEBUG&&n.L("Vex.Flow.TextBracket",t)}("Rendering TextBracket: start:",i,"stop:",s,"y:",e);const r=this.render_options.bracket_height*this.position;t.save(),this.applyStyle(t),t.fillText(this.text,i.x,i.y);const o=t.measureText(this.text).width,a=t.measureText("M").width,l=i.y-a/2.5;t.setFont(this.font.family,this.font.size/1.4,this.font.weight),t.fillText(this.superscript,i.x+o+1,l);const h=t.measureText(this.superscript).width,c=t.measureText("M").width;let u=i.x,d=l;const f=s.x+this.stop.getGlyph().getWidth();this.position===jt.Positions.TOP?(u+=o+h+5,d-=c/2.7):this.position===jt.Positions.BOTTOM&&(d+=c/2.7,u+=o+2,this.render_options.underline_superscript||(u+=h)),this.render_options.dashed?(v.drawDashedLine(t,u,d,f,d,this.render_options.dash),this.render_options.show_bracket&&v.drawDashedLine(t,f,d+1*this.position,f,d+r,this.render_options.dash)):(t.beginPath(),t.moveTo(u,d),t.lineTo(f,d),this.render_options.show_bracket&&t.lineTo(f,d+r),t.stroke(),t.closePath()),t.restore()}}class Ht extends I{constructor(t=ft.type.SINGLE){super({duration:"b"}),this.setAttribute("type","BarNote"),this.metrics={widths:{}};const e=ft.type;this.metrics.widths={[e.SINGLE]:8,[e.DOUBLE]:12,[e.END]:15,[e.REPEAT_BEGIN]:14,[e.REPEAT_END]:14,[e.REPEAT_BOTH]:18,[e.NONE]:0},this.ignore_ticks=!0,this.setType(t)}getType(){return this.type}setType(t){return this.type="string"==typeof t?ft.typeString[t]:t,this.setWidth(this.metrics.widths[this.type]),this}getBoundingBox(){return super.getBoundingBox()}addToModifierContext(){return this}preFormat(){return this.setPreFormatted(!0),this}draw(){if(this.checkContext(),!this.stave)throw new n.RERR("NoStave","Can't draw without a stave.");!function(...t){Ht.DEBUG&&n.L("Vex.Flow.BarNote",t)}("Rendering bar line at: ",this.getAbsoluteX());const t=new ft(this.type);t.setX(this.getAbsoluteX()),t.draw(this.stave),this.setRendered()}}class Xt extends N{constructor(t){if(!t)throw new n.RuntimeError("BadArguments","Ghost note must have valid initialization data to identify duration.");let e;if("string"==typeof t)e={duration:t};else{if("object"!=typeof t)throw new n.RuntimeError("BadArguments","Ghost note must have valid initialization data to identify duration.");e=t}super(e),this.setAttribute("type","GhostNote"),this.setWidth(0)}isRest(){return!0}setStave(t){super.setStave(t)}addToModifierContext(){return this}preFormat(){return this.setPreFormatted(!0),this}draw(){if(!this.stave)throw new n.RERR("NoStave","Can't draw without a stave.");this.setRendered();for(let t=0;t0||!0===e;return!e||s>0||(this.pos=n),o?this.matchSuccess():this.matchFail(n),{success:o,results:i,numMatches:s}}expectZeroOrMore(t){return this.expectOneOrMore(t,!0)}expect(t){let e;if(function(...t){Jt.DEBUG&&n.L("Vex.Flow.Parser",t)}("Evaluating rules:",t),!t)throw new qt("Invalid Rule: "+t,t);const i=t.bind(this.grammar)();if(i.token)e=this.matchToken(i.token,!0===i.noSpace),e.success&&(this.pos+=e.incrementPos);else{if(!i.expect)throw new qt("Bad grammar! No `token` or `expect` property",i);e=i.oneOrMore?this.expectOneOrMore(i):i.zeroOrMore?this.expectZeroOrMore(i):this.expectOne(i)}return e.matches=[],e.results&&e.results.forEach((t=>e.matches.push($t(t)))),i.run&&e.success&&i.run(e),e}}function Zt(...t){se.DEBUG&&n.L("Vex.Flow.EasyScore",t)}const Qt=n.MakeException("EasyScoreError");class te{constructor(t){this.builder=t}begin(){return this.LINE}LINE(){return{expect:[this.PIECE,this.PIECES,this.EOL]}}PIECE(){return{expect:[this.CHORDORNOTE,this.PARAMS],run:()=>this.builder.commitPiece()}}PIECES(){return{expect:[this.COMMA,this.PIECE],zeroOrMore:!0}}PARAMS(){return{expect:[this.DURATION,this.TYPE,this.DOTS,this.OPTS]}}CHORDORNOTE(){return{expect:[this.CHORD,this.SINGLENOTE],or:!0}}CHORD(){return{expect:[this.LPAREN,this.NOTES,this.RPAREN],run:t=>this.builder.addChord(t.matches[1])}}NOTES(){return{expect:[this.NOTE],oneOrMore:!0}}NOTE(){return{expect:[this.NOTENAME,this.ACCIDENTAL,this.OCTAVE]}}SINGLENOTE(){return{expect:[this.NOTENAME,this.ACCIDENTAL,this.OCTAVE],run:t=>this.builder.addSingleNote(t.matches[0],t.matches[1],t.matches[2])}}ACCIDENTAL(){return{expect:[this.ACCIDENTALS],maybe:!0}}DOTS(){return{expect:[this.DOT],zeroOrMore:!0,run:t=>this.builder.setNoteDots(t.matches[0])}}TYPE(){return{expect:[this.SLASH,this.MAYBESLASH,this.TYPES],maybe:!0,run:t=>this.builder.setNoteType(t.matches[2])}}DURATION(){return{expect:[this.SLASH,this.DURATIONS],maybe:!0,run:t=>this.builder.setNoteDuration(t.matches[1])}}OPTS(){return{expect:[this.LBRACKET,this.KEYVAL,this.KEYVALS,this.RBRACKET],maybe:!0}}KEYVALS(){return{expect:[this.COMMA,this.KEYVAL],zeroOrMore:!0}}KEYVAL(){return{expect:[this.KEY,this.EQUALS,this.VAL],run:t=>this.builder.addNoteOption(t.matches[0],t.matches[2].slice(1,-1))}}VAL(){return{expect:[this.SVAL,this.DVAL],or:!0}}KEY(){return{token:"[a-zA-Z][a-zA-Z0-9]*"}}DVAL(){return{token:'["][^"]*["]'}}SVAL(){return{token:"['][^']*[']"}}NOTENAME(){return{token:"[a-gA-G]"}}OCTAVE(){return{token:"[0-9]+"}}ACCIDENTALS(){return{token:"bbs|bb|bss|bs|b|db|d|##|#|n|\\+\\+-|\\+-|\\+\\+|\\+|k|o"}}DURATIONS(){return{token:"[0-9whq]+"}}TYPES(){return{token:"[rRsSxX]"}}LPAREN(){return{token:"[(]"}}RPAREN(){return{token:"[)]"}}COMMA(){return{token:"[,]"}}DOT(){return{token:"[.]"}}SLASH(){return{token:"[/]"}}MAYBESLASH(){return{token:"[/]?"}}EQUALS(){return{token:"[=]"}}LBRACKET(){return{token:"\\["}}RBRACKET(){return{token:"\\]"}}EOL(){return{token:"$"}}}class ee{constructor(t){this.factory=t,this.commitHooks=[],this.reset()}reset(t={}){this.options={stem:"auto",clef:"treble"},this.elements={notes:[],accidentals:[]},this.rollingDuration="8",this.resetPiece(),Object.assign(this.options,t)}getFactory(){return this.factory}getElements(){return this.elements}addCommitHook(t){this.commitHooks.push(t)}resetPiece(){Zt("resetPiece"),this.piece={chord:[],duration:this.rollingDuration,dots:0,type:void 0,options:{}}}setNoteDots(t){Zt("setNoteDots:",t),t&&(this.piece.dots=t.length)}setNoteDuration(t){Zt("setNoteDuration:",t),this.rollingDuration=this.piece.duration=t||this.rollingDuration}setNoteType(t){Zt("setNoteType:",t),t&&(this.piece.type=t)}addNoteOption(t,e){Zt("addNoteOption: key:",t,"value:",e),this.piece.options[t]=e}addNote(t,e,i){Zt("addNote:",t,e,i),this.piece.chord.push({key:t,accid:e,octave:i})}addSingleNote(t,e,i){Zt("addSingleNote:",t,e,i),this.addNote(t,e,i)}addChord(t){Zt("startChord"),"object"!=typeof t[0]?this.addSingleNote(t[0]):t.forEach((t=>{t&&this.addNote(...t)})),Zt("endChord")}commitPiece(){Zt("commitPiece");const{factory:t}=this;if(!t)return;const e={...this.options,...this.piece.options},{stem:i,clef:n}=e,s="auto"===i.toLowerCase(),r=s||"up"!==i.toLowerCase()?D.STEM_DOWN:D.STEM_UP,{chord:o,duration:a,dots:l,type:h}=this.piece,c=o.map((t=>t.key+"/"+t.octave)),u=t.StaveNote({keys:c,duration:a,dots:l,type:h,clef:n,auto_stem:s});s||u.setStemDirection(r);const d=o.map((t=>t.accid||null));d.forEach(((e,i)=>{e&&u.addAccidental(i,t.Accidental({type:e}))}));for(let t=0;tt(e,u,this))),this.elements.notes.push(u),this.elements.accidentals.concat(d),this.resetPiece()}}function ie({id:t},e){void 0!==t&&e.setAttribute("id",t)}function ne(t,e){t.class&&t.class.split(/\s*,\s*/).forEach((t=>e.addClass(t)))}class se{constructor(t={}){this.setOptions(t),this.defaults={clef:"treble",time:"4/4",stem:"auto"}}set(t){return Object.assign(this.defaults,t),this}setOptions(t){return this.options={factory:null,builder:null,commitHooks:[ie,ne,et.easyScoreHook],throwOnError:!1,...t},this.factory=this.options.factory,this.builder=this.options.builder||new ee(this.factory),this.grammar=new te(this.builder),this.parser=new Jt(this.grammar),this.options.commitHooks.forEach((t=>this.addCommitHook(t))),this}setContext(t){return this.factory&&this.factory.setContext(t),this}parse(t,e={}){this.builder.reset(e);const i=this.parser.parse(t);if(!i.success&&this.options.throwOnError)throw new Qt("Error parsing line: "+t,i);return i}beam(t,e={}){return this.factory.Beam({notes:t,options:e}),t}tuplet(t,e={}){return this.factory.Tuplet({notes:t,options:e}),t}notes(t,e={}){return e={clef:this.defaults.clef,stem:this.defaults.stem,...e},this.parse(t,e),this.builder.getElements().notes}voice(t,e){return e={time:this.defaults.time,...e},this.factory.Voice(e).addTickables(t)}addCommitHook(t){return this.builder.addCommitHook(t)}}const re=n.MakeException("FactoryError");function oe(t={},e){const i=e.options;return(t=Object.assign(e,t)).options=Object.assign(i,t.options),t}class ae{constructor(t){!function(...t){ae.DEBUG&&n.L("Vex.Flow.Factory",t)}("New factory: ",t);const e={stave:{space:10},renderer:{context:null,elementId:"",backend:v.Backends.SVG,width:500,height:200,background:"#FFF"},font:{face:"Arial",point:10,style:""}};this.options=e,this.setOptions(t)}static newFromElementId(t,e=500,i=200){return new ae({renderer:{elementId:t,width:e,height:i}})}reset(){this.renderQ=[],this.systems=[],this.staves=[],this.voices=[],this.stave=null}getOptions(){return this.options}setOptions(t){for(const e of["stave","renderer","font"])Object.assign(this.options[e],t[e]);(null!==this.options.renderer.elementId||this.options.renderer.context)&&this.initRenderer(),this.reset()}initRenderer(){const{elementId:t,backend:e,width:i,height:n,background:s}=this.options.renderer;if(""===t)throw new re("HTML DOM element not set in Factory");this.context=v.buildContext(t,e,i,n,s)}getContext(){return this.context}setContext(t){return this.context=t,this}getStave(){return this.stave}getVoices(){return this.voices}space(t){return this.options.stave.space*t}Stave(t){t=oe(t,{x:0,y:0,width:this.options.renderer.width-this.space(1),options:{spacing_between_lines_px:this.options.stave.space}});const e=new _t(t.x,t.y,t.width,t.options);return this.staves.push(e),e.setContext(this.context),this.stave=e,e}TabStave(t){t=oe(t,{x:0,y:0,width:this.options.renderer.width-this.space(1),options:{spacing_between_lines_px:1.3*this.options.stave.space}});const e=new wt(t.x,t.y,t.width,t.options);return this.staves.push(e),e.setContext(this.context),this.stave=e,e}StaveNote(t){const e=new D(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}GhostNote(t){const e=new Xt(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}TextNote(t){const e=new gt(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}BarNote(t){t=oe(t,{type:"single",options:{}});const e=new Ht(t.type);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}ClefNote(t){t=oe(t,{type:"treble",options:{size:"default"}});const e=new At(t.type,t.options.size,t.options.annotation);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}TimeSigNote(t){t=oe(t,{time:"4/4",options:{}});const e=new It(t.time);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}KeySigNote(t){const e=new Ct(t.key,t.cancelKey,t.alterKey);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}TabNote(t){const e=new Tt(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}GraceNote(t){const e=new Nt(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),e}GraceNoteGroup(t){const e=new X(t.notes,t.slur);return e.setContext(this.context),e}Accidental(t){t=oe(t,{type:null,options:{}});const e=new U(t.type);return e.setContext(this.context),e}Annotation(t){t=oe(t,{text:"p",vJustify:"below",hJustify:"center",fontFamily:"Times",fontSize:14,fontWeight:"bold italic",options:{}});const e=new st(t.text);return e.setJustification(t.hJustify),e.setVerticalJustification(t.vJustify),e.setFont(t.fontFamily,t.fontSize,t.fontWeight),e.setContext(this.context),e}Articulation(t){t=oe(t,{type:"a.",position:"above",options:{}});const e=new et(t.type);return e.setPosition(t.position),e.setContext(this.context),e}TextDynamics(t){t=oe(t,{text:"p",duration:"q",dots:0,line:0,options:{}});const e=new Vt({text:t.text,line:t.line,duration:t.duration,dots:t.dots});return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}Fingering(t){t=oe(t,{number:"0",position:"left",options:{}});const e=new k(t.number);return e.setPosition(t.position),e.setContext(this.context),e}StringNumber(t){t=oe(t,{number:"0",position:"left",options:{}});const e=new K(t.number);return e.setPosition(t.position),e.setContext(this.context),e}TickContext(){return(new it).setContext(this.context)}ModifierContext(){return new lt}MultiMeasureRest(t){const e=new Lt(t.number_of_measures,t);return e.setContext(this.context),this.renderQ.push(e),e}Voice(t){t=oe(t,{time:"4/4",options:{}});const e=new P(t.time);return this.voices.push(e),e}StaveConnector(t){t=oe(t,{top_stave:null,bottom_stave:null,type:"double",options:{}});const e=new A(t.top_stave,t.bottom_stave);return e.setType(t.type).setContext(this.context),this.renderQ.push(e),e}Formatter(){return new ut}Tuplet(t){t=oe(t,{notes:[],options:{}});const e=new E(t.notes,t.options).setContext(this.context);return this.renderQ.push(e),e}Beam(t){t=oe(t,{notes:[],options:{autoStem:!1,secondaryBeamBreaks:[]}});const e=new M(t.notes,t.options.autoStem).setContext(this.context);return e.breakSecondaryAt(t.options.secondaryBeamBreaks),this.renderQ.push(e),e}Curve(t){t=oe(t,{from:null,to:null,options:{}});const e=new Dt(t.from,t.to,t.options).setContext(this.context);return this.renderQ.push(e),e}StaveTie(t){t=oe(t,{from:null,to:null,first_indices:[0],last_indices:[0],text:null,options:{direction:void 0}});const e=new j({first_note:t.from,last_note:t.to,first_indices:t.first_indices,last_indices:t.last_indices},t.text);return t.options.direction&&e.setDirection(t.options.direction),e.setContext(this.context),this.renderQ.push(e),e}StaveLine(t){t=oe(t,{from:null,to:null,first_indices:[0],last_indices:[0],options:{}});const e=new Wt({first_note:t.from,last_note:t.to,first_indices:t.first_indices,last_indices:t.last_indices});return t.options.text&&e.setText(t.options.text),t.options.font&&e.setFont(t.options.font),e.setContext(this.context),this.renderQ.push(e),e}VibratoBracket(t){t=oe(t,{from:null,to:null,options:{harsh:!1}});const e=new Mt({start:t.from,stop:t.to});return t.options.line&&e.setLine(t.options.line),t.options.harsh&&e.setHarsh(t.options.harsh),e.setContext(this.context),this.renderQ.push(e),e}TextBracket(t){t=oe(t,{from:null,to:null,text:"",options:{superscript:"",position:1}});const e=new jt({start:t.from,stop:t.to,text:t.text,superscript:t.options.superscript,position:t.options.position});return t.options.line&&e.setLine(t.options.line),t.options.font&&e.setFont(t.options.font),e.setContext(this.context),this.renderQ.push(e),e}System(t={}){t.factory=this;const e=new he(t).setContext(this.context);return this.systems.push(e),e}EasyScore(t={}){return t.factory=this,new se(t)}PedalMarking(t={}){t=oe(t,{notes:[],options:{style:"mixed"}});const e=new zt(t.notes);return e.setStyle(zt.StylesString[t.options.style]),e.setContext(this.context),this.renderQ.push(e),e}NoteSubGroup(t={}){t=oe(t,{notes:[],options:{}});const e=new z(t.notes);return e.setContext(this.context),e}draw(){this.systems.forEach((t=>t.setContext(this.context).format())),this.staves.forEach((t=>t.setContext(this.context).draw())),this.voices.forEach((t=>t.setContext(this.context).draw())),this.renderQ.forEach((t=>{t.isRendered()||t.setContext(this.context).draw()})),this.systems.forEach((t=>t.setContext(this.context).draw())),this.reset()}}function le(t,e){const i=e.options;return(t=Object.assign(e,t)).options=Object.assign(i,t.options),t}class he extends l{constructor(t={}){super(),this.setAttribute("type","System"),this.setOptions(t),this.parts=[]}setOptions(t={}){this.options=le(t,{x:10,y:10,width:500,connector:null,spaceBetweenStaves:12,factory:null,debugFormatter:!1,formatIterations:0,options:{}}),this.factory=this.options.factory||new ae({renderer:{el:null}})}setContext(t){return super.setContext(t),this.factory.setContext(t),this}addConnector(t="double"){return this.connector=this.factory.StaveConnector({top_stave:this.parts[0].stave,bottom_stave:this.parts[this.parts.length-1].stave,type:t}),this.connector}addStave(t){return(t=le(t,{stave:null,voices:[],spaceAbove:0,spaceBelow:0,debugNoteMetrics:!1,options:{left_bar:!1}})).stave||(t.stave=this.factory.Stave({x:this.options.x,y:this.options.y,width:this.options.width,options:t.options})),t.voices.forEach((e=>e.setContext(this.context).setStave(t.stave).getTickables().forEach((e=>e.setStave(t.stave))))),this.parts.push(t),t.stave}format(){const t=new ut;this.formatter=t;let e=this.options.y,i=0,n=[];const s=[];this.parts.forEach((r=>{e+=r.stave.space(r.spaceAbove),r.stave.setY(e),t.joinVoices(r.voices),e+=r.stave.space(r.spaceBelow),e+=r.stave.space(this.options.spaceBetweenStaves),r.debugNoteMetrics&&(s.push({y:e,voice:r.voices[0]}),e+=15),n=n.concat(r.voices),i=Math.max(i,r.stave.getNoteStartX())})),this.parts.forEach((t=>t.stave.setNoteStartX(i)));const r=this.options.width-(i-this.options.x)-I.STAVEPADDING;t.format(n,r);for(let e=0;e{e.voice.getTickables().forEach((i=>I.plotMetrics(t,i,e.y)))}))}}(n.Flow=p).Element=l,n.Flow.Fraction=s,n.Flow.Renderer=v,n.Flow.Formatter=ut,n.Flow.Music=V,n.Flow.Glyph=f,n.Flow.Stave=_t,n.Flow.StaveNote=D,n.Flow.StaveModifier=dt,n.Flow.StaveTempo=bt,n.Flow.Voice=P,n.Flow.Accidental=U,n.Flow.Beam=M,n.Flow.StaveTie=j,n.Flow.TabStave=wt,n.Flow.TabNote=Tt,n.Flow.Bend=rt,n.Flow.Vibrato=ot,n.Flow.VibratoBracket=Mt,n.Flow.Note=I,n.Flow.ModifierContext=lt,n.Flow.MultiMeasureRest=Lt,n.Flow.TickContext=it,n.Flow.Articulation=et,n.Flow.Annotation=st,n.Flow.Barline=ft,n.Flow.NoteHead=R,n.Flow.StaveConnector=A,n.Flow.ClefNote=At,n.Flow.KeySignature=vt,n.Flow.KeySigNote=Ct,n.Flow.TimeSignature=xt,n.Flow.TimeSigNote=It,n.Flow.Stem=x,n.Flow.TabTie=H,n.Flow.Clef=St,n.Flow.Dot=B,n.Flow.Modifier=F,n.Flow.TabSlide=Rt,n.Flow.Tuplet=E,n.Flow.GraceNote=Nt,n.Flow.GraceTabNote=Ft,n.Flow.Tuning=Bt,n.Flow.KeyManager=class{constructor(t){this.music=new V,this.setKey(t)}setKey(t){return this.key=t,this.reset(),this}getKey(){return this.key}reset(){if(this.keyParts=this.music.getKeyParts(this.key),this.keyString=this.keyParts.root,this.keyParts.accidental&&(this.keyString+=this.keyParts.accidental),!V.scaleTypes[this.keyParts.type])throw new n.RERR("BadArguments",`Unsupported key type: ${this.key}`);this.scale=this.music.getScaleTones(this.music.getNoteValue(this.keyString),V.scaleTypes[this.keyParts.type]),this.scaleMap={},this.scaleMapByValue={},this.originalScaleMapByValue={};const t=V.root_indices[this.keyParts.root];for(let e=0;e=1?"w":i<1&&i>=.5?e&&i>.5?"w":"h":i<.5&&i>=.25?e&&i>.25?"h":"q":i<.25&&i>=.125?e&&i>.125?"q":"8":i<.125&&i>=.0625?e&&i>.0625?"8":"16":i<.0625&&i>=.03125?e&&i>.03125?"16":"32":i<.03125&&i>=.015625?e&&i>.015625?"32":"64":e?"64":"128"}static pitch(t,e,i,n){let s=3;e&&(s=0,i.ClefType===r.ClefEnum.F&&(s=2),i.ClefType===r.ClefEnum.C&&(s=2));const a=c.NoteEnum[t.FundamentalNote].toLowerCase(),l=o.Pitch.accidentalVexflow(t.Accidental),h=t.Octave-i.OctaveOffset+s;let u="";return n&&(u=this.NoteHeadCode(n)),[a+"n/"+h+u,l,i]}static restToNotePitch(t,e){let i=t.Octave;switch(e){case r.ClefEnum.C:case r.ClefEnum.F:i+=2;break;case r.ClefEnum.G:}return new o.Pitch(t.FundamentalNote,i,h.AccidentalEnum.NONE)}static NoteHeadCode(t){const e=t.Filled?"2":"1";switch(t.Shape){case S.NoteHeadShape.NORMAL:return"";case S.NoteHeadShape.DIAMOND:return"/D"+e;case S.NoteHeadShape.TRIANGLE:return"/T"+e;case S.NoteHeadShape.X:return"/X"+e;case S.NoteHeadShape.CIRCLEX:return"/X3";case S.NoteHeadShape.RECTANGLE:return"/R"+e;case S.NoteHeadShape.SQUARE:return"/S"+e;case S.NoteHeadShape.SLASH:default:return""}}static GhostNote(t){return new s.default.Flow.GhostNote({duration:_.duration(t,!1)})}static StaveNote(t){var e,i,n,r,o,a,l,h,c,u;t.sortForVexflow();const d=t.notes,f=t.parentStaffEntry.parentMeasure.parentSourceMeasure.Rules,p=d[0];let m=[];const g=[],y=p.graphicalNoteLength,x=void 0!==p.sourceNote.NoteTuplet;let E=_.duration(y,x);void 0!==p.sourceNote.TypeLength&&p.sourceNote.TypeLength!==y&&(E=_.duration(p.sourceNote.TypeLength,x));let w,T,M=p.numberOfDots,P=!1,L=0,A=!1,C=!1;for(const t of d){if(M=1&&e.length-1>=d+1&&(c=null===(o=null===(r=e[d-1])||void 0===r?void 0:r.graphicalVoiceEntries[0])||void 0===o?void 0:o.parentVoiceEntry,u=null===(l=null===(a=e[d+1])||void 0===a?void 0:a.graphicalVoiceEntries[0])||void 0===l?void 0:l.parentVoiceEntry,c&&u)){const e=c.Notes[0],i=u.Notes[0];if(null===(h=e.NoteBeam)||void 0===h?void 0:h.Notes.includes(i)){const e=c.Notes.last().Pitch,i=t.Clef();m=[_.pitch(_.restToNotePitch(e.getTransposedPitch(-2),i.ClefType),!1,i,void 0)[0]]}}}}if(y.RealValue===t.sourceNote.SourceMeasure.ActiveTimeSignature.RealValue&&(m=["d/5"],E="w",M=0,P=!0,L=f.WholeRestXShiftVexflow*v.unitInPixels),t.sourceNote.ParentStaff.Voices.length>1){let e=0;for(let i=0;i1)switch(null===(u=null===(c=t.sourceNote.ParentVoiceEntry)||void 0===c?void 0:c.ParentVoice)||void 0===u?void 0:u.VoiceId){case 1:m=["e/5"];break;case 2:m=["f/4"]}}break}t.sourceNote.Notehead&&t.sourceNote.Notehead.Shape===S.NoteHeadShape.SLASH&&(A=!0);const s=t.vfpitch;m.push(s[0]),g.push(s[1]),T||(T=_.Clef(s[2]).type)}for(let t=0,e=M;tt.notes[i].staffLine=e)),(f.LedgerLineWidth||f.LedgerLineStrokeStyle)&&(w.ledgerLineStyle||(w.ledgerLineStyle={}),f.LedgerLineWidth&&(w.ledgerLineStyle.lineWidth=f.LedgerLineWidth),f.LedgerLineStrokeStyle&&(w.ledgerLineStyle.strokeStyle=f.LedgerLineStrokeStyle)),f.ColoringEnabled){const e=f.DefaultColorStem;let i=t.parentVoiceEntry.StemColor;!i&&e&&(i=e);const n={fillStyle:i,strokeStyle:i};i&&(t.parentVoiceEntry.StemColor=i,w.setStemStyle(n),w.flag&&f.ColorFlags&&w.setFlagStyle(n))}if(w.x_shift=L,t.parentVoiceEntry.IsGrace&&t.notes[0].sourceNote.NoteBeam&&(t.parentVoiceEntry.WantedStemDirection=t.notes[0].sourceNote.NoteBeam.Notes[0].ParentVoiceEntry.WantedStemDirection),t.parentVoiceEntry)switch(t.parentVoiceEntry.WantedStemDirection){case b.StemDirectionType.Up:w.setStemDirection(s.default.Flow.Stem.UP),t.parentVoiceEntry.StemDirection=b.StemDirectionType.Up;break;case b.StemDirectionType.Down:w.setStemDirection(s.default.Flow.Stem.DOWN),t.parentVoiceEntry.StemDirection=b.StemDirectionType.Down}for(let t=0,e=d.length;t0){const i=new s.default.Flow.Tremolo(e);i.extra_stroke_scale=f.TremoloStrokeScale,i.y_spacing_scale=f.TremoloYSpacingScale,w.addModifier(t,i)}}if(.25===R.Length.RealValue&&R.Notehead&&!1===R.Notehead.Filled){const t=w.getKeyProps();for(let e=0;e");break;case b.ArticulationEnum.downbow:e=new s.default.Flow.Articulation("am"),void 0===n.placement&&(r=s.default.Flow.Modifier.Position.ABOVE);break;case b.ArticulationEnum.fermata:e=new s.default.Flow.Articulation("a@a"),r=s.default.Flow.Modifier.Position.ABOVE;break;case b.ArticulationEnum.marcatodown:e=new s.default.Flow.Articulation("a|");break;case b.ArticulationEnum.marcatoup:e=new s.default.Flow.Articulation("a^");break;case b.ArticulationEnum.invertedfermata:e=new s.default.Flow.Articulation("a@u"),r=s.default.Flow.Modifier.Position.BELOW;break;case b.ArticulationEnum.lefthandpizzicato:e=new s.default.Flow.Articulation("a+");break;case b.ArticulationEnum.naturalharmonic:e=new s.default.Flow.Articulation("ah");break;case b.ArticulationEnum.snappizzicato:e=new s.default.Flow.Articulation("ao");break;case b.ArticulationEnum.staccatissimo:e=new s.default.Flow.Articulation("av");break;case b.ArticulationEnum.staccato:e=new s.default.Flow.Articulation("a.");break;case b.ArticulationEnum.tenuto:e=new s.default.Flow.Articulation("a-");break;case b.ArticulationEnum.upbow:e=new s.default.Flow.Articulation("a|"),void 0===n.placement&&(r=s.default.Flow.Modifier.Position.ABOVE);break;case b.ArticulationEnum.strongaccent:e=new s.default.Flow.Articulation("a^")}e&&(e.setPosition(r),t.addModifier(0,e))}}static generateOrnaments(t,e){let i,n=s.default.Flow.Modifier.Position.ABOVE;switch(e.placement===E.PlacementEnum.Below&&(n=s.default.Flow.Modifier.Position.BELOW),e.GetOrnament){case y.OrnamentEnum.DelayedInvertedTurn:i=new s.default.Flow.Ornament("turn_inverted"),i.setDelayed(!0);break;case y.OrnamentEnum.DelayedTurn:i=new s.default.Flow.Ornament("turn"),i.setDelayed(!0);break;case y.OrnamentEnum.InvertedMordent:i=new s.default.Flow.Ornament("mordent"),i.setDelayed(!1);break;case y.OrnamentEnum.InvertedTurn:i=new s.default.Flow.Ornament("turn_inverted"),i.setDelayed(!1);break;case y.OrnamentEnum.Mordent:i=new s.default.Flow.Ornament("mordent_inverted"),i.setDelayed(!1);break;case y.OrnamentEnum.Trill:i=new s.default.Flow.Ornament("tr"),i.setDelayed(!1);break;case y.OrnamentEnum.Turn:i=new s.default.Flow.Ornament("turn"),i.setDelayed(!1);break;default:return void m.default.warn("unhandled OrnamentEnum type: "+e.GetOrnament)}i&&(e.AccidentalBelow!==h.AccidentalEnum.NONE&&i.setLowerAccidental(o.Pitch.accidentalVexflow(e.AccidentalBelow)),e.AccidentalAbove!==h.AccidentalEnum.NONE&&i.setUpperAccidental(o.Pitch.accidentalVexflow(e.AccidentalAbove)),i.setPosition(n),t.addModifier(0,i))}static StrokeTypeFromArpeggioType(t){switch(t){case x.ArpeggioType.ARPEGGIO_DIRECTIONLESS:return s.default.Flow.Stroke.Type.ARPEGGIO_DIRECTIONLESS;case x.ArpeggioType.BRUSH_DOWN:return s.default.Flow.Stroke.Type.BRUSH_UP;case x.ArpeggioType.BRUSH_UP:return s.default.Flow.Stroke.Type.BRUSH_DOWN;case x.ArpeggioType.RASQUEDO_DOWN:return s.default.Flow.Stroke.Type.RASQUEDO_UP;case x.ArpeggioType.RASQUEDO_UP:return s.default.Flow.Stroke.Type.RASQUEDO_DOWN;case x.ArpeggioType.ROLL_DOWN:return s.default.Flow.Stroke.Type.ROLL_UP;case x.ArpeggioType.ROLL_UP:return s.default.Flow.Stroke.Type.ROLL_DOWN;default:return s.default.Flow.Stroke.Type.ARPEGGIO_DIRECTIONLESS}}static CreateTabNote(t){const e=[],i=t.notes.reverse(),n=[],r=t.notes[0].graphicalNoteLength,o=void 0!==t.notes[0].sourceNote.NoteTuplet;let a=_.duration(r,o),l=0,h=!1;for(const i of t.notes){const t=i.sourceNote,r={str:t.StringNumberTab,fret:t.FretNumber};e.push(r),t.BendArray&&t.BendArray.forEach((function(t){let e;const i=t.bendalter-r.fret;e=i>1?"Full":1===i?"1/2":"1/4","up"===t.direction?n.push({type:s.default.Flow.Bend.UP,text:e,width:10}):n.push({type:s.default.Flow.Bend.DOWN,text:e,width:10})})),t.VibratoStroke&&(h=!0),l0)return!0;return!1}isStaccato(){for(const t of this.Articulations)if(t.articulationEnum===c.staccato)return!0;return!1}isAccent(){for(const t of this.Articulations)if(t.articulationEnum===c.accent||t.articulationEnum===c.strongaccent)return!0;return!1}getVerseNumberForLyricEntry(t){let e=1;return this.lyricsEntries.forEach(((i,n)=>{t===n&&(e=i)})),e}createVoiceEntriesForOrnament(t,e){t||(t=this);const i=[];if(!t.ornamentContainer)return;const s=this.notes[0],r=s.Length,l=t.ParentVoice,h=t.Timestamp;let c=n.Fraction.createFromFraction(h);switch(t.ornamentContainer.GetOrnament){case o.OrnamentEnum.Trill:{const o=new n.Fraction(r.Numerator,8*r.Denominator),u=s.Pitch.getTransposedPitch(1);let d=e.getAlterationForPitch(u);t.OrnamentContainer.AccidentalAbove!==a.AccidentalEnum.NONE&&(d=t.ornamentContainer.AccidentalAbove);for(let t=0;t<8;t++)c=n.Fraction.plus(h,new n.Fraction(t*o.Numerator,o.Denominator)),t%2==0?this.createBaseVoiceEntry(c,o,l,s,i):this.createAlteratedVoiceEntry(c,o,l,s.SourceMeasure,u,d,i);break}case o.OrnamentEnum.Turn:{const t=new n.Fraction(r.Numerator,4*r.Denominator),o=s.Pitch.getTransposedPitch(-1),a=e.getAlterationForPitch(o),h=s.Pitch.getTransposedPitch(1),u=e.getAlterationForPitch(h);this.createAlteratedVoiceEntry(c,t,l,s.SourceMeasure,h,u,i),c.Add(t),this.createBaseVoiceEntry(c,t,l,s,i),c.Add(t),this.createAlteratedVoiceEntry(c,t,l,s.SourceMeasure,o,a,i),c.Add(t),this.createBaseVoiceEntry(c,t,l,s,i);break}case o.OrnamentEnum.InvertedTurn:{const t=new n.Fraction(r.Numerator,4*r.Denominator),o=s.Pitch.getTransposedPitch(-1),a=e.getAlterationForPitch(o),h=s.Pitch.getTransposedPitch(1),u=e.getAlterationForPitch(h);this.createAlteratedVoiceEntry(c,t,l,s.SourceMeasure,o,a,i),c.Add(t),this.createBaseVoiceEntry(c,t,l,s,i),c.Add(t),this.createAlteratedVoiceEntry(c,t,l,s.SourceMeasure,h,u,i),c.Add(t),this.createBaseVoiceEntry(c,t,l,s,i);break}case o.OrnamentEnum.DelayedTurn:{const t=new n.Fraction(r.Numerator,2*r.Denominator),o=s.Pitch.getTransposedPitch(-1),a=e.getAlterationForPitch(o),u=s.Pitch.getTransposedPitch(1),d=e.getAlterationForPitch(u);this.createBaseVoiceEntry(c,t,l,s,i),c=n.Fraction.plus(h,t),t.Denominator=8*r.Denominator,this.createAlteratedVoiceEntry(c,t,l,s.SourceMeasure,u,d,i),c.Add(t),this.createBaseVoiceEntry(c,t,l,s,i),c.Add(t),this.createAlteratedVoiceEntry(c,t,l,s.SourceMeasure,o,a,i),c.Add(t),this.createBaseVoiceEntry(c,t,l,s,i);break}case o.OrnamentEnum.DelayedInvertedTurn:{const t=new n.Fraction(r.Numerator,2*r.Denominator),o=s.Pitch.getTransposedPitch(-1),a=e.getAlterationForPitch(o),u=s.Pitch.getTransposedPitch(1),d=e.getAlterationForPitch(u);this.createBaseVoiceEntry(c,t,l,s,i),c=n.Fraction.plus(h,t),t.Denominator=8*r.Denominator,this.createAlteratedVoiceEntry(c,t,l,s.SourceMeasure,o,a,i),c.Add(t),this.createBaseVoiceEntry(c,t,l,s,i),c.Add(t),this.createAlteratedVoiceEntry(c,t,l,s.SourceMeasure,u,d,i),c.Add(t),this.createBaseVoiceEntry(c,t,l,s,i);break}case o.OrnamentEnum.Mordent:{const t=new n.Fraction(r.Numerator,4*r.Denominator),o=s.Pitch.getTransposedPitch(1),a=e.getAlterationForPitch(o);this.createBaseVoiceEntry(c,t,l,s,i),c.Add(t),this.createAlteratedVoiceEntry(c,t,l,s.SourceMeasure,o,a,i),t.Denominator=2*r.Denominator,c=n.Fraction.plus(h,t),this.createBaseVoiceEntry(c,t,l,s,i);break}case o.OrnamentEnum.InvertedMordent:{const t=new n.Fraction(r.Numerator,4*r.Denominator),o=s.Pitch.getTransposedPitch(-1),a=e.getAlterationForPitch(o);this.createBaseVoiceEntry(c,t,l,s,i),c.Add(t),this.createAlteratedVoiceEntry(c,t,l,s.SourceMeasure,o,a,i),t.Denominator=2*r.Denominator,c=n.Fraction.plus(h,t),this.createBaseVoiceEntry(c,t,l,s,i);break}default:throw new RangeError}return i}createBaseVoiceEntry(t,e,i,n,o){const a=new h(t,i,n.ParentStaffEntry),l=new r.Pitch(n.Pitch.FundamentalNote,n.Pitch.Octave,n.Pitch.Accidental),c=new s.Note(a,void 0,e,l,n.SourceMeasure);a.Notes.push(c),o.push(a)}createAlteratedVoiceEntry(t,e,i,n,o,a,l){const c=new h(t,i,void 0),u=new r.Pitch(o.FundamentalNote,o.Octave,a),d=new s.Note(c,void 0,e,u,n);c.Notes.push(d),l.push(c)}}var c,u,d;e.VoiceEntry=h,(d=c=e.ArticulationEnum||(e.ArticulationEnum={}))[d.accent=0]="accent",d[d.strongaccent=1]="strongaccent",d[d.marcatoup=2]="marcatoup",d[d.marcatodown=3]="marcatodown",d[d.invertedstrongaccent=4]="invertedstrongaccent",d[d.staccato=5]="staccato",d[d.staccatissimo=6]="staccatissimo",d[d.spiccato=7]="spiccato",d[d.tenuto=8]="tenuto",d[d.fermata=9]="fermata",d[d.invertedfermata=10]="invertedfermata",d[d.breathmark=11]="breathmark",d[d.caesura=12]="caesura",d[d.lefthandpizzicato=13]="lefthandpizzicato",d[d.naturalharmonic=14]="naturalharmonic",d[d.snappizzicato=15]="snappizzicato",d[d.upbow=16]="upbow",d[d.downbow=17]="downbow",d[d.scoop=18]="scoop",d[d.plop=19]="plop",d[d.doit=20]="doit",d[d.falloff=21]="falloff",d[d.stress=22]="stress",d[d.unstress=23]="unstress",d[d.detachedlegato=24]="detachedlegato",d[d.otherarticulation=25]="otherarticulation",d[d.bend=26]="bend",function(t){t[t.Undefined=-1]="Undefined",t[t.Up=0]="Up",t[t.Down=1]="Down",t[t.None=2]="None",t[t.Double=3]="Double"}(u=e.StemDirectionType||(e.StemDirectionType={}))},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0});var n=i(35);e.arrays=n;var s=i(157);e.Bag=s.default;var r=i(158);e.BSTree=r.default;var o=i(83);e.BSTreeKV=o.default;var a=i(29);e.Dictionary=a.default;var l=i(85);e.Heap=l.default;var h=i(159);e.LinkedDictionary=h.default;var c=i(53);e.LinkedList=c.default;var u=i(160);e.MultiDictionary=u.default;var d=i(86);e.FactoryDictionary=d.default;var f=i(86);e.DefaultDictionary=f.default;var p=i(84);e.Queue=p.default;var m=i(161);e.PriorityQueue=m.default;var b=i(82);e.Set=b.default;var g=i(162);e.Stack=g.default;var y=i(163);e.MultiRootTree=y.default;var S=i(10);e.util=S},function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowMusicSheetDrawer=e.unitInPixels=void 0;const s=n(i(8)),r=i(119),o=i(46),a=i(4),l=i(63),h=i(22),c=i(3),u=i(70),d=i(79),f=n(i(1)),p=i(52),m=i(33),b=i(88);e.unitInPixels=10;class g extends r.MusicSheetDrawer{constructor(t=new m.DrawingParameters){super(new l.VexFlowTextMeasurer(t.Rules),t),this.backends=[],this.zoom=1,this.pageIdx=0}get Backends(){return this.backends}drawSheet(t){var i,n,r;"gonville"===this.rules.DefaultVexFlowNoteFont&&(s.default.Flow.DEFAULT_FONT_STACK=[null===(i=s.default.Flow.Fonts)||void 0===i?void 0:i.Gonville,null===(n=s.default.Flow.Fonts)||void 0===n?void 0:n.Bravura,null===(r=s.default.Flow.Fonts)||void 0===r?void 0:r.Custom]),s.default.Flow.STAVE_LINE_THICKNESS=this.rules.StaffLineWidth*e.unitInPixels,s.default.Flow.STEM_WIDTH=this.rules.StemWidth*e.unitInPixels,s.default.Flow.DEFAULT_NOTATION_FONT_SCALE=this.rules.VexFlowDefaultNotationFontScale,s.default.Flow.DEFAULT_TAB_FONT_SCALE=this.rules.VexFlowDefaultTabFontScale,this.pageIdx=0;for(const e of t.MusicPages){if(e.PageNumber>this.rules.MaxPageToDrawNumber)break;const t=this.backends[this.pageIdx];t.graphicalMusicPage=e,t.scale(this.zoom),this.pageIdx+=1}this.pageIdx=0,this.backend=this.backends[0],super.drawSheet(t)}drawPage(t){t&&(this.backend=this.backends[t.PageNumber-1],super.drawPage(t),this.pageIdx+=1)}clear(){for(const t of this.backends)t.clear()}setZoom(t){this.zoom=t}calculatePixelDistance(t){return t*e.unitInPixels}drawStaffLine(t){super.drawStaffLine(t);const e=t.PositionAndShape.AbsolutePosition;this.rules.RenderSlurs&&this.drawSlurs(t,e)}drawSlurs(t,e){for(const i of t.GraphicalSlurs)i.slur.isCrossed()||this.drawSlur(i,e)}drawSlur(t,e){const i=[],n=new a.PointF2D(t.bezierStartPt.x+e.x,t.bezierStartPt.y+e.y),s=new a.PointF2D(t.bezierStartControlPt.x+e.x,t.bezierStartControlPt.y+e.y),r=new a.PointF2D(t.bezierEndControlPt.x+e.x,t.bezierEndControlPt.y+e.y),o=new a.PointF2D(t.bezierEndPt.x+e.x,t.bezierEndPt.y+e.y);i.push(this.applyScreenTransformation(n)),i.push(this.applyScreenTransformation(s)),i.push(this.applyScreenTransformation(r)),i.push(this.applyScreenTransformation(o)),t.placement===c.PlacementEnum.Above?(n.y-=.05,s.y-=.3,r.y-=.3,o.y-=.05):(n.y+=.05,s.y+=.3,r.y+=.3,o.y+=.05),i.push(this.applyScreenTransformation(n)),i.push(this.applyScreenTransformation(s)),i.push(this.applyScreenTransformation(r)),i.push(this.applyScreenTransformation(o)),this.backend.renderCurve(i)}drawMeasure(t){t.setAbsoluteCoordinates(t.PositionAndShape.AbsolutePosition.x*e.unitInPixels,t.PositionAndShape.AbsolutePosition.y*e.unitInPixels);try{t.draw(this.backend.getContext())}catch(t){f.default.warn("VexFlowMusicSheetDrawer.drawMeasure",t)}for(const e of t.staffEntries)this.drawStaffEntry(e)}drawLine(t,i,n="#FF0000FF",s=.2){return t=this.applyScreenTransformation(t),i=this.applyScreenTransformation(i),this.backend.renderLine(t,i,n,s*e.unitInPixels)}DrawOverlayLine(t,i,n,s="#FF0000FF",r=.2){if(!n.PageNumber||n.PageNumber>this.backends.length||n.PageNumber<1)return void console.log("VexFlowMusicSheetDrawer.drawOverlayLine: invalid page number / music page number doesn't correspond to an existing backend.");const o=n.PageNumber-1,a=this.backends[o];return t=this.applyScreenTransformation(t),i=this.applyScreenTransformation(i),a.renderLine(t,i,s,r*e.unitInPixels)}drawSkyLine(t){const e=t.PositionAndShape.AbsolutePosition,i=t.PositionAndShape.Size.width;this.drawSampledLine(t.SkyLine,e,i)}drawBottomLine(t){const e=new a.PointF2D(t.PositionAndShape.AbsolutePosition.x,t.PositionAndShape.AbsolutePosition.y),i=t.PositionAndShape.Size.width;this.drawSampledLine(t.BottomLine,e,i,"#0000FFFF")}drawSampledLine(t,e,i,n="#FF0000FF"){const s=[];let r=0;for(let e=0;e0){const e=this.rules.SamplingUnit;let r,l,h=new a.PointF2D(o.x,o.y),c=new a.PointF2D(s[0]/e+o.x,o.y);this.drawLine(h,c,n),t[0]>=0&&(r=new a.PointF2D(s[0]/e+o.x,o.y),l=new a.PointF2D(s[0]/e+o.x,o.y+t[s[0]]),this.drawLine(r,l,n));for(let i=1;i0)for(const e of t.graphicalChordContainers)this.drawLabel(e.GraphicalLabel,h.GraphicalLayers.Notes);this.rules.RenderLyrics&&t.LyricsEntries.length>0&&this.drawLyrics(t.LyricsEntries,h.GraphicalLayers.Notes)}drawLyrics(t,e){t.forEach((t=>this.drawLabel(t.GraphicalLabel,e)))}drawInstrumentBrace(t,e){t.draw(this.backend.getContext())}drawGroupBracket(t,e){t.draw(this.backend.getContext())}drawOctaveShifts(t){for(const e of t.OctaveShifts)if(e){const t=e,i=this.backend.getContext(),n=t.getTextBracket();n.setContext(i),n.draw()}}drawExpressions(t){for(const e of t.AbstractExpressions)e instanceof d.GraphicalInstantaneousDynamicExpression?this.drawInstantaneousDynamic(e):e instanceof u.GraphicalInstantaneousTempoExpression?this.drawLabel(e.GraphicalLabel,h.GraphicalLayers.Notes):e instanceof p.GraphicalContinuousDynamicExpression?this.drawContinuousDynamic(e):e instanceof b.GraphicalUnknownExpression?this.drawLabel(e.Label,h.GraphicalLayers.Notes):f.default.warn("Unkown type of expression!")}drawInstantaneousDynamic(t){this.drawLabel(t.Label,h.GraphicalLayers.Notes)}drawContinuousDynamic(t){if(t.IsVerbal)this.drawLabel(t.Label,h.GraphicalLayers.Notes);else for(const e of t.Lines){const i=new a.PointF2D(t.ParentStaffLine.PositionAndShape.AbsolutePosition.x+e.Start.x,t.ParentStaffLine.PositionAndShape.AbsolutePosition.y+e.Start.y),n=new a.PointF2D(t.ParentStaffLine.PositionAndShape.AbsolutePosition.x+e.End.x,t.ParentStaffLine.PositionAndShape.AbsolutePosition.y+e.End.y);this.drawLine(i,n,"black",e.Width)}}renderLabel(t,i,n,s,r,o){var l;if(!t.Label.print)return[];const h=[],c=t.Label.fontHeight*e.unitInPixels,{font:u}=t.Label;let d;this.rules.ColoringEnabled&&(d=t.Label.colorDefault,d||(d=this.rules.DefaultColorLabel));let{fontStyle:f,fontFamily:p}=t.Label;f||(f=this.rules.DefaultFontStyle),p||(p=this.rules.DefaultFontFamily);for(let e=0;e<(null===(l=t.TextLines)||void 0===l?void 0:l.length);e++){const i=t.TextLines[e],n=this.calculatePixelDistance(i.xOffset),s=new a.PointF2D(o.x+n,o.y);h.push(this.backend.renderText(c,f,u,i.text,r,s,d,t.Label.fontFamily)),o.y=o.y+r,t.TextLines.length>1&&(o.y+=this.rules.SpacingBetweenTextLines)}return h}renderRectangle(t,e,i,n,s){return this.backend.renderRectangle(t,i,n,s)}applyScreenTransformation(t){return new a.PointF2D(t.x*e.unitInPixels,t.y*e.unitInPixels)}applyScreenTransformationForRect(t){return new o.RectangleF2D(t.x*e.unitInPixels,t.y*e.unitInPixels,t.width*e.unitInPixels,t.height*e.unitInPixels)}}e.VexFlowMusicSheetDrawer=g},function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.MusicSheetCalculator=void 0;const s=i(68),r=i(0),o=i(36),a=i(7),l=i(30),h=i(14),c=i(113),u=i(4),d=i(31),f=i(24),p=i(9),m=i(18),b=i(41),g=i(5),y=i(115),S=i(116),v=i(7),x=n(i(1)),E=i(15),_=i(27),w=i(12),T=i(54),M=i(3),P=i(70),L=i(37),A=i(56),C=i(32),I=i(52),R=i(25),N=i(88);class F{constructor(){this.staffEntriesWithGraphicalTies=[],this.staffEntriesWithOrnaments=[],this.staffEntriesWithChordSymbols=[],this.staffLinesWithLyricWords=[],this.graphicalLyricWords=[],this.abstractNotImplementedErrorMessage="abstract, not implemented"}static get TextMeasurer(){return F.textMeasurer}static set TextMeasurer(t){F.textMeasurer=t}get leadSheet(){return this.graphicalMusicSheet.LeadSheet}static setMeasuresMinStaffEntriesWidth(t,e){for(let i=0,n=t.length;i0&&this.rules.RenderMultipleRestMeasures){a.isReducedToMultiRest=!0,a.multipleRestMeasureNumber=1;const i=a.multipleRestMeasures-1;r+=i;for(let n=1;n<=i;n++){const i=t.SourceMeasures[a.MeasureNumber-1+n];i.multipleRestMeasureNumber=n+1,i.isReducedToMultiRest=!0,e.push([void 0])}}}if(this.rules.AutoGenerateMutipleRestMeasuresFromRestMeasures&&this.rules.RenderMultipleRestMeasures){let r,a=0;for(let l=0,h=t.SourceMeasures.length;l0){r.isReducedToMultiRest=!0,r.multipleRestMeasureNumber=1,a++,h.multipleRestMeasureNumber=a,h.isReducedToMultiRest=!0;for(let t=0;t1){r.multipleRestMeasures=a;const t=this.createGraphicalMeasuresForSourceMeasure(r,i,s,o,n);e[r.measureListIndex]=t,a=0,r=void 0}else a=0,r=void 0}if(a>1){r.multipleRestMeasures=a,r.isReducedToMultiRest=!0;const t=this.createGraphicalMeasuresForSourceMeasure(r,i,s,o,n);e[r.measureListIndex]=t,a=0,r=void 0}}const l=n.map((t=>t.ClefType===a.ClefEnum.percussion));this.handleStaffEntries(l),this.calculateVerticalContainersList(),this.setIndicesToVerticalGraphicalContainers()}calculate(){this.musicSystems=[],this.clearSystemsAndMeasures(),this.clearRecreatedObjects(),this.createGraphicalTies(),this.calculateSheetLabelBoundingBoxes(),this.calculateXLayout(this.graphicalMusicSheet,this.maxInstrNameLabelLength()),this.graphicalMusicSheet.MusicPages.length=0,this.calculateMusicSystems(),s.GraphicalMusicSheet.transformRelativeToAbsolutePosition(this.graphicalMusicSheet)}calculateXLayout(t,e){if(this.graphicalMusicSheet.MeasureList.length>0){let t=this.graphicalMusicSheet.MeasureList[0],e=this.calculateMeasureXLayout(t);e=this.calculateMeasureWidthFromStaffEntries(t,e),F.setMeasuresMinStaffEntriesWidth(t,e);for(let i=1;i0)return;const r=e.Measures[s];0!==r.MeasureNumber&&1!==r.MeasureNumber||(i=r.MeasureNumber),n=r!==e.Measures[0]&&this.rules.MeasureNumberLabelXOffset?this.rules.MeasureNumberLabelXOffset:0;const o=this.rules.UseXMLMeasureNumbers&&1===r.MeasureNumber&&1!==r.parentSourceMeasure.getPrintedMeasureNumber();((r.MeasureNumber===i||r.MeasureNumber>=i+this.rules.MeasureNumberLabelOffset)&&!r.parentSourceMeasure.ImplicitMeasure||o)&&((1!==r.MeasureNumber||1===r.MeasureNumber&&r!==e.Measures[0]||o)&&this.calculateSingleMeasureNumberPlacement(r,e,t,n),i=r.MeasureNumber)}}calculateSingleMeasureNumberPlacement(t,e,i,n=0){const s=t.parentSourceMeasure.getPrintedMeasureNumber().toString(),r=new w.Label(s),o=new f.GraphicalLabel(r,this.rules.MeasureNumberLabelHeight,p.TextAlignmentEnum.LeftBottom,this.rules),a=e.SkyBottomLineCalculator;o.setLabelPositionAndShapeBorders(),o.PositionAndShape.Parent=i.PositionAndShape;const l=e.PositionAndShape.RelativePosition.x+t.PositionAndShape.RelativePosition.x-o.PositionAndShape.BorderMarginLeft+n;let h,c=l,d=l-o.PositionAndShape.BorderLeft+o.PositionAndShape.BorderRight;c-=e.PositionAndShape.RelativePosition.x,d-=e.PositionAndShape.RelativePosition.x;const m=c+.5,b=d-.5,g=a.getSkyLineMinInRange(m,b);if(t===e.Measures[0]){let t=0;if(i.GroupBrackets.length>0)for(const e of i.GroupBrackets)t=Math.min(t,e.PositionAndShape.BorderTop);h=Math.min(g,t)}else h=g;h=Math.min(0,h),o.PositionAndShape.RelativePosition=new u.PointF2D(l,h),a.updateSkyLineInRange(c,d,h+o.PositionAndShape.BorderMarginTop),i.MeasureNumberLabels.push(o)}layoutGraphicalTie(t,e,i){throw new Error(this.abstractNotImplementedErrorMessage)}calculateSingleStaffLineLyricsPosition(t,e){let i=0,n=this.rules.StaffHeight;const s=[],r=t.SkyBottomLineCalculator;let o=t.Measures.length;for(let e=0;e0){s.push(e),i=Math.max(i,e.LyricsEntries.length);const t=e.PositionAndShape.RelativePosition.x+a.x;let o=Number.MAX_VALUE,l=Number.MIN_VALUE;for(let i=0;i0){const e=t.PositionAndShape.Size.width;let i=s[0].PositionAndShape.RelativePosition.x+s[0].PositionAndShape.BorderMarginLeft+s[0].parentMeasure.PositionAndShape.RelativePosition.x;i=i>e?e:i,r.updateBottomLineInRange(i,e,a)}return s}calculateLyricsExtendsAndDashes(t){for(let e=0,i=t.length;e0||t.UnknownList.length>0){let e="";for(let i=0,n=t.EntriesList.length;it.length-1&&(x.default.debug("minimum measure to draw index out of range. resetting min measure index to limit."),this.rules.MinMeasureToDrawIndex=t.length-1);const e=[];for(let i=this.rules.MinMeasureToDrawIndex,n=t.length;id){const e=u.StaffLines[t].PositionAndShape.RelativePosition.y-s.PositionAndShape.RelativePosition.y-this.rules.StaffHeight;v=this.rules.StaffHeight+e/2}else v=this.rules.WedgePlacementBelowY;v-=this.rules.WedgeOpeningLength/2,a||(E=v);let e=f.getBottomLineMaxInRange(b,y);if(e>v&&(v=e),dE&&(E=e),E+=this.rules.WedgeOpeningLength/2,E+=this.rules.WedgeVerticalMargin),v+=this.rules.WedgeOpeningLength/2,v+=this.rules.WedgeVerticalMargin}else if(p===M.PlacementEnum.Above){if(1===s.ParentStaff.ParentInstrument.Staves.length)v=this.rules.WedgePlacementAboveY;else{let t=0;d>0&&(t=d-1);const e=u.StaffLines[t];v=-(s.PositionAndShape.RelativePosition.y-e.PositionAndShape.RelativePosition.y-this.rules.StaffHeight)/2}v+=this.rules.WedgeOpeningLength/2,a||(E=v);let t=f.getSkyLineMinInRange(b,y);if(t1&&d>0){const t=s.findClosestStaffEntry(b),e=s.findClosestStaffEntry(y);t&&e&&t.parentVerticalContainer}a||(t=o.SkyBottomLineCalculator.getSkyLineMinInRange(g,S),t-n/2?-n/2:a-t.PositionAndShape.BorderMarginBottom}else o=a-t.PositionAndShape.BorderMarginBottom;t.PositionAndShape.RelativePosition=new u.PointF2D(e.x,o)}else if(t.Placement===M.PlacementEnum.Below){const a=r.getBottomLineMaxInRange(n,s),l=i.ParentStaff.ParentInstrument.Staves[i.ParentStaff.ParentInstrument.Staves.length-1];if(i.isPartOfMultiStaffInstrument()&&i.ParentStaff!==l){const e=i.ParentMusicSystem.StaffLines[i.ParentMusicSystem.StaffLines.indexOf(i)+1].PositionAndShape.RelativePosition.y-i.PositionAndShape.RelativePosition.y-this.rules.StaffHeight;o=a+t.PositionAndShape.BorderMarginBottomt.PositionAndShape.Size.width&&(d=t.PositionAndShape.Size.width-this.rules.MeasureRightMargin,c=d-l.PositionAndShape.MarginSize.width,e.x=c-l.PositionAndShape.BorderMarginLeft);const m=t.SkyBottomLineCalculator;return h=s===M.PlacementEnum.Below?m.getBottomLineMaxInRange(c,d):m.getSkyLineMinInRange(c,d),l.PositionAndShape.RelativePosition=new u.PointF2D(e.x,h),s===M.PlacementEnum.Below?m.updateBottomLineInRange(c,d,l.PositionAndShape.BorderMarginBottom+h):m.updateSkyLineInRange(c,d,l.PositionAndShape.BorderMarginTop+h),l}calculateTempoExpressionsForMultiTempoExpression(t,e,i){const n=r.Fraction.plus(t.AbsoluteTimestamp,e.Timestamp),s=this.graphicalMusicSheet.MeasureList[i];let o=new u.PointF2D;if(e.ContinuousTempo||e.InstantaneousTempo){if(this.rules.MinMeasureToDrawIndex>0)return;if(!s[0])return;let t=s[0].ParentStaffLine,i=s[0].PositionAndShape.RelativePosition.x,r=0;for(let e=0;e0){t=s[e].ParentStaffLine,i=s[e].PositionAndShape.RelativePosition.x,r=e;break}if(o=this.getRelativePositionInStaffLineFromTimestamp(n,r,t,t.isPartOfMultiStaffInstrument(),i),e.EntriesList.length>0&&e.EntriesList[0].Expression instanceof L.InstantaneousTempoExpression&&(e.EntriesList[0].Expression.Placement=M.PlacementEnum.Above,t.Measures[0].staffEntries.length>0&&0===Math.abs(o.x-t.Measures[0].staffEntries[0].PositionAndShape.RelativePosition.x)&&t.ParentMusicSystem===this.musicSystems[0])){const e=t.Measures[0].FirstInstructionStaffEntry;if(e){const t=e.GraphicalInstructions.last();o.x=t.PositionAndShape.RelativePosition.x}this.rules.CompactMode&&(o.x=t.PositionAndShape.RelativePosition.x+t.Measures[0].PositionAndShape.RelativePosition.x)}for(const i of e.EntriesList){let n=p.TextAlignmentEnum.CenterBottom;this.rules.CompactMode&&(n=p.TextAlignmentEnum.LeftBottom);const s=this.calculateLabel(t,o,i.label,e.getFontstyleOfFirstEntry(),i.Expression.Placement,this.rules.UnknownTextHeight,n);if(i.Expression instanceof L.InstantaneousTempoExpression){for(const e of t.AbstractExpressions)e instanceof P.GraphicalInstantaneousTempoExpression&&(e.SourceExpression.Label,i.Expression.Label);if(new P.GraphicalInstantaneousTempoExpression(i.Expression,s).ParentStaffLine||x.default.warn("Adding staffline didn't work"),this.rules.MetronomeMarksDrawn&&i.Expression.Enum===L.TempoEnum.metronomeMark){this.createMetronomeMark(i.Expression);continue}}else i.Expression,A.ContinuousTempoExpression}}}createMetronomeMark(t){throw new Error(this.abstractNotImplementedErrorMessage)}graphicalMeasureCreatedCalculations(t){}clearSystemsAndMeasures(){for(let t=0,e=this.graphicalMusicSheet.MusicPages.length;t-1&&i.PositionAndShape.ChildElements.splice(t,1),i.FirstInstructionStaffEntry=void 0,i.beginInstructionsWidth=0}if(i.LastInstructionStaffEntry){const t=i.PositionAndShape.ChildElements.indexOf(i.LastInstructionStaffEntry.PositionAndShape);t>-1&&i.PositionAndShape.ChildElements.splice(t,1),i.LastInstructionStaffEntry=void 0,i.endInstructionsWidth=0}}e.Measures=[],e.PositionAndShape.ChildElements=[]}i.StaffLines.length=0,i.PositionAndShape.ChildElements=[]}e.MusicSystems=[],e.PositionAndShape.ChildElements=[]}this.graphicalMusicSheet.MusicPages=[]}handleVoiceEntry(t,e,i,n,s,r,o,a,l,c,u){t.StemDirectionXml!==h.StemDirectionType.Undefined&&this.rules.SetWantedStemDirectionByXml&&void 0!==t.StemDirectionXml?t.WantedStemDirection=t.StemDirectionXml:this.calculateStemDirectionFromVoices(t);const d=e.findOrCreateGraphicalVoiceEntry(t);d.octaveShiftValue=a;const f=e.tabStaffEntry;let p;f&&(p=f.findOrCreateGraphicalVoiceEntry(t));for(let n=0,l=t.Notes.length;n-1)continue;let h;if(t.IsGrace?h=F.symbolFactory.createGraceNote(l,d,s,this.rules,a):(h=F.symbolFactory.createNote(l,d,s,a,this.rules,void 0),F.stafflineNoteCalculator.trackNote(h)),l.Pitch&&this.checkNoteForAccidental(h,i,s,a),this.resetYPositionForLeadSheet(h.PositionAndShape),e.addGraphicalNoteToListAtCorrectYPosition(d,h),h.PositionAndShape.calculateBoundingBox(),this.leadSheet||(void 0!==l.NoteBeam&&l.PrintObject&&this.handleBeam(h,l.NoteBeam,o),void 0!==l.NoteTuplet&&l.PrintObject&&this.handleTuplet(h,l.NoteTuplet,r)),p){const t=F.symbolFactory.createNote(l,p,s,a,this.rules,void 0);f.addGraphicalNoteToListAtCorrectYPosition(p,t),t.PositionAndShape.calculateBoundingBox(),this.leadSheet||l.NoteTuplet&&this.handleTuplet(t,l.NoteTuplet,r)}}return t.Articulations.length>0&&this.handleVoiceEntryArticulations(t.Articulations,t,e),t.TechnicalInstructions.length>0&&this.handleVoiceEntryTechnicalInstructions(t.TechnicalInstructions,t,e),t.LyricsEntries.size()>0&&this.handleVoiceEntryLyrics(t,e,n),t.OrnamentContainer&&this.handleVoiceEntryOrnaments(t.OrnamentContainer,t,e),a}resetYPositionForLeadSheet(t){this.leadSheet&&(t.RelativePosition=new u.PointF2D(t.RelativePosition.x,0))}layoutVoiceEntries(t,e){if(t.PositionAndShape.RelativePosition=new u.PointF2D(0,0),!this.leadSheet)for(const e of t.graphicalVoiceEntries){const i=e.notes;if(0===i.length)continue;const n=i[0].sourceNote.ParentVoiceEntry,s=void 0!==i[0].sourceNote.Pitch;this.layoutVoiceEntry(n,i,t,s)}}maxInstrNameLabelLength(){var t;let e=0;for(const i of this.graphicalMusicSheet.ParentMusicSheet.Instruments)if((null===(t=i.NameLabel)||void 0===t?void 0:t.print)&&i.Voices.length>0&&i.Voices[0].Visible){let t=i.NameLabel;this.rules.RenderPartNames||(t=new w.Label("",t.textAlignment,t.font));const n=new f.GraphicalLabel(t,this.rules.InstrumentLabelTextHeight,p.TextAlignmentEnum.LeftCenter,this.rules);n.setLabelPositionAndShapeBorders(),e=Math.max(e,n.PositionAndShape.MarginSize.width)}return this.rules.RenderPartNames?e:0}calculateSheetLabelBoundingBoxes(){const t=this.graphicalMusicSheet.ParentMusicSheet,e=this.rules.DefaultColorTitle;if(void 0!==t.Title&&this.rules.RenderTitle){const i=new f.GraphicalLabel(t.Title,this.rules.SheetTitleHeight,p.TextAlignmentEnum.CenterBottom,this.rules);i.Label.IsCreditLabel=!0,i.Label.colorDefault=e,this.graphicalMusicSheet.Title=i,i.setLabelPositionAndShapeBorders()}else this.rules.RenderTitle||(this.graphicalMusicSheet.Title=void 0);if(void 0!==t.Subtitle&&this.rules.RenderSubtitle){const i=new f.GraphicalLabel(t.Subtitle,this.rules.SheetSubtitleHeight,p.TextAlignmentEnum.CenterCenter,this.rules);i.Label.IsCreditLabel=!0,i.Label.colorDefault=e,this.graphicalMusicSheet.Subtitle=i,i.setLabelPositionAndShapeBorders()}else this.rules.RenderSubtitle||(this.graphicalMusicSheet.Subtitle=void 0);if(void 0!==t.Composer&&this.rules.RenderComposer){const i=new f.GraphicalLabel(t.Composer,this.rules.SheetComposerHeight,p.TextAlignmentEnum.RightCenter,this.rules);i.Label.IsCreditLabel=!0,i.Label.colorDefault=e,this.graphicalMusicSheet.Composer=i,i.setLabelPositionAndShapeBorders()}else this.rules.RenderComposer||(this.graphicalMusicSheet.Composer=void 0);if(void 0!==t.Lyricist&&this.rules.RenderLyricist){const i=new f.GraphicalLabel(t.Lyricist,this.rules.SheetAuthorHeight,p.TextAlignmentEnum.LeftCenter,this.rules);i.Label.IsCreditLabel=!0,i.Label.colorDefault=e,this.graphicalMusicSheet.Lyricist=i,i.setLabelPositionAndShapeBorders()}else this.rules.RenderLyricist||(this.graphicalMusicSheet.Lyricist=void 0)}checkMeasuresForWholeRestNotes(){for(let t=0,e=this.musicSystems.length;t0&&1===t.graphicalVoiceEntries[0].notes.length){const i=t.graphicalVoiceEntries[0].notes[0];!i.sourceNote.Pitch&&new r.Fraction(1,2).lt(i.sourceNote.Length)&&this.layoutMeasureWithWholeRest(i,t,e)}}}}}}optimizeRestNotePlacement(t,e){if(0===t.graphicalVoiceEntries.length)return;const i=t.graphicalVoiceEntries[0].notes;if(0===i.length)return;const n=i[0],s=n.sourceNote.isRest();if(2===t.graphicalVoiceEntries.length){let e=!1;const i=t.graphicalVoiceEntries[1].notes;i.length>0&&(e=i[0].sourceNote.isRest()),s&&e?this.calculateTwoRestNotesPlacementWithCollisionDetection(t):(s||e)&&this.calculateRestNotePlacementWithCollisionDetectionFromGraphicalNote(t)}else if(s&&t!==e.staffEntries[0]&&t!==e.staffEntries[e.staffEntries.length-1]){const i=e.staffEntries.indexOf(t),s=e.staffEntries[i-1],r=e.staffEntries[i+1];if(1===s.graphicalVoiceEntries.length){const e=s.graphicalVoiceEntries[0].notes[0];if(void 0!==e.sourceNote.NoteBeam&&1===r.graphicalVoiceEntries.length){const i=r.graphicalVoiceEntries[0].notes[0];void 0!==i.sourceNote.NoteBeam&&e.sourceNote.NoteBeam===i.sourceNote.NoteBeam&&(this.calculateRestNotePlacementWithinGraphicalBeam(t,n,e,r,i),t.PositionAndShape.calculateBoundingBox())}}}}getRelativePositionInStaffLineFromTimestamp(t,e,i,n,s=0){let o,a,l=new u.PointF2D;const h=this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers.length,c=this.graphicalMusicSheet.GetInterpolatedIndexInVerticalContainers(t),d=Math.min(Math.floor(c),h-1),f=Math.min(Math.ceil(c),h-1);if(d<0||e<0)return l;if(o=this.getFirstLeftNotNullStaffEntryFromContainer(d,e,n),a=this.getFirstRightNotNullStaffEntryFromContainer(f,e,n),o&&a){let e=o.parentMeasure.PositionAndShape.RelativePosition.x;s>0&&(e=s);let n=o.PositionAndShape.RelativePosition.x+e,h=a.PositionAndShape.RelativePosition.x+a.parentMeasure.PositionAndShape.RelativePosition.x;s>0&&(h=a.PositionAndShape.RelativePosition.x+e);let c=0;if(o!==a){const e=o.getAbsoluteTimestamp(),i=a.getAbsoluteTimestamp();c=r.Fraction.minus(t,e).RealValue/r.Fraction.minus(i,e).RealValue}o.parentMeasure.ParentStaffLine!==a.parentMeasure.ParentStaffLine&&(o.parentMeasure.ParentStaffLine===i?h=i.PositionAndShape.Size.width:n=i.PositionAndShape.RelativePosition.x),l=new u.PointF2D(n+(h-n)*c,0)}return l}getRelativeXPositionFromTimestamp(t){const e=this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers.length,i=this.graphicalMusicSheet.GetInterpolatedIndexInVerticalContainers(t),n=Math.max(0,Math.min(Math.round(i),e-1)),s=this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[n].getFirstNonNullStaffEntry();return s.PositionAndShape.RelativePosition.x+s.parentMeasure.PositionAndShape.RelativePosition.x}calculatePageLabels(t){var e;this.rules.RenderSingleHorizontalStaffline&&(t.PositionAndShape.BorderRight=t.PositionAndShape.Size.width,t.PositionAndShape.calculateBoundingBox(),this.graphicalMusicSheet.ParentMusicSheet.pageWidth=t.PositionAndShape.Size.width);let i=10;if(t.MusicSystems.length>0){const e=t.MusicSystems[0];i=e.PositionAndShape.RelativePosition.y+e.PositionAndShape.BorderTop}if(this.graphicalMusicSheet.Title){const e=this.graphicalMusicSheet.Title;e.PositionAndShape.Parent=t.PositionAndShape;const i=new u.PointF2D;i.x=this.graphicalMusicSheet.ParentMusicSheet.pageWidth/2,i.y=this.rules.TitleTopDistance+this.rules.SheetTitleHeight,e.PositionAndShape.RelativePosition=i,t.Labels.push(e)}if(this.graphicalMusicSheet.Subtitle){const e=this.graphicalMusicSheet.Subtitle;e.PositionAndShape.Parent=t.PositionAndShape;const i=new u.PointF2D;i.x=this.graphicalMusicSheet.ParentMusicSheet.pageWidth/2,i.y=this.rules.TitleTopDistance+this.rules.SheetTitleHeight+this.rules.SheetMinimumDistanceBetweenTitleAndSubtitle,e.PositionAndShape.RelativePosition=i,t.Labels.push(e)}const n=this.graphicalMusicSheet.Composer;let s;if(n){n.PositionAndShape.Parent=t.PositionAndShape,n.setLabelPositionAndShapeBorders();const r=new u.PointF2D;r.x=this.graphicalMusicSheet.ParentMusicSheet.pageWidth-this.rules.PageRightMargin,r.y=i,r.y-=this.rules.SystemComposerDistance;const o=null===(e=n.TextLines)||void 0===e?void 0:e.length;o>1&&(r.y-=n.PositionAndShape.BorderBottom*(o-1)/o),s=r.y,n.PositionAndShape.RelativePosition=r,t.Labels.push(n)}const r=this.graphicalMusicSheet.Lyricist;if(r){r.PositionAndShape.Parent=t.PositionAndShape,r.setLabelPositionAndShapeBorders();const e=new u.PointF2D;e.x=this.rules.PageLeftMargin,e.y=i,e.y+=r.PositionAndShape.BorderBottom,e.y=Math.min(e.y,s),r.PositionAndShape.RelativePosition=e,t.Labels.push(r)}}createGraphicalTies(){for(let t=0;t=0&&this.staffEntriesWithGraphicalTies.push(a)}a=r}}createAccidentalCalculators(){const t=[],e=this.graphicalMusicSheet.ParentMusicSheet.getFirstSourceMeasure();if(e)for(let i=0;i1)return;x=F.symbolFactory.createGraphicalMeasure(t,S)}if(x.hasError=t.getErrorInMeasure(f),t.FirstInstructionsStaffEntries[f])for(let e=0,i=t.FirstInstructionsStaffEntries[f].Instructions.length;e0){const e=o.Instructions[0];F.symbolFactory.createInStaffClef(t,e)}this.rules.RenderChordSymbols&&(null===(g=o.ChordContainers)||void 0===g?void 0:g.length)>0&&(o.ParentStaff.ParentInstrument.HasChordSymbols=!0,F.symbolFactory.createChordSymbols(o,t,n.ActiveKeyInstruction,this.graphicalMusicSheet.ParentMusicSheet.Transpose))}}if(n.doCalculationsAtEndOfMeasure(),t.LastInstructionsStaffEntries[f]){const e=t.LastInstructionsStaffEntries[f];for(let t=0,i=e.Instructions.length;t=1&&0===x.staffEntries.length){const e=new d.SourceStaffEntry(new T.VerticalSourceStaffEntryContainer(x.parentSourceMeasure,x.parentSourceMeasure.AbsoluteTimestamp,x.parentSourceMeasure.CompleteNumberOfStaves),S),i=new h.VoiceEntry(new r.Fraction(0,1),S.Voices[0],e),n=new o.Note(i,e,r.Fraction.createFromFraction(t.Duration),void 0,t);n.PrintObject=this.rules.FillEmptyMeasuresWithWholeRest===R.FillEmptyMeasuresWithWholeRests.YesVisible,i.Notes.push(n);const s=F.symbolFactory.createStaffEntry(e,x);x.addGraphicalStaffEntry(s),s.relInMeasureTimestamp=i.Timestamp;const c=F.symbolFactory.createVoiceEntry(i,s);s.graphicalVoiceEntries.push(c);const u=F.symbolFactory.createNote(n,c,new a.ClefInstruction,l.OctaveEnum.NONE,void 0);F.stafflineNoteCalculator.trackNote(u),c.notes.push(u)}x.hasOnlyRests=!0;for(const t of x.staffEntries)if(x.hasOnlyRests=t.hasOnlyRests(),!x.hasOnlyRests)break;return x}checkNoteForAccidental(t,e,i,n){let s=t.sourceNote.Pitch;const r=this.graphicalMusicSheet.ParentMusicSheet.Transpose;0!==r&&t.sourceNote.ParentStaffEntry.ParentStaff.ParentInstrument.MidiInstrumentId!==v.MidiInstrument.Percussion&&(s=t.Transpose(e.ActiveKeyInstruction,i,r,n)),t.sourceNote.halfTone=s.getHalfTone(),e.checkAccidental(t,s)}handleStaffEntries(t){for(let e=0,i=this.graphicalMusicSheet.MeasureList.length;e0&&t.graphicalVoiceEntries[0].notes.length>0&&(this.layoutVoiceEntries(t,e),this.layoutStaffEntry(t));this.graphicalMeasureCreatedCalculations(n)}}}}calculateSkyBottomLines(){for(const t of this.musicSystems)for(const e of t.StaffLines)e.SkyBottomLineCalculator.calculateLines()}calculateExpressionAlignements(){}calculateStaffEntryArticulationMarks(){for(let t=0,e=this.musicSystems.length;t0&&this.layoutArticulationMarks(e.Articulations,e,i)}}}}}}calculateOrnaments(){for(let t=0,e=this.musicSystems.length;t0&&e.LyricVersesNumbers.sort()}for(let e=0,i=this.musicSystems.length;e=0&&(n=e.GraphicalLyricsEntries[i+1]),!n)return;const s=t.StaffEntryParent.parentMeasure.ParentStaffLine,r=n.StaffEntryParent.parentMeasure.ParentStaffLine,o=t.StaffEntryParent,a=n.StaffEntryParent;if(t.StaffEntryParent.parentMeasure.ParentStaffLine===n.StaffEntryParent.parentMeasure.ParentStaffLine){const e=o.parentMeasure.PositionAndShape.RelativePosition.x+o.PositionAndShape.RelativePosition.x+t.GraphicalLabel.PositionAndShape.RelativePosition.x+t.GraphicalLabel.PositionAndShape.BorderMarginRight,i=a.parentMeasure.PositionAndShape.RelativePosition.x+a.PositionAndShape.RelativePosition.x+t.GraphicalLabel.PositionAndShape.RelativePosition.x+n.GraphicalLabel.PositionAndShape.BorderMarginLeft,r=t.GraphicalLabel.PositionAndShape.RelativePosition.y;let l=1;i-e>3*this.rules.MinimumDistanceBetweenDashes&&(l=Math.floor((i-e)/this.rules.MinimumDistanceBetweenDashes)-1),1===l?this.calculateSingleDashForLyricWord(s,e,i,r):this.calculateDashes(s,e,i,r)}else{const e=o.parentMeasure.PositionAndShape.RelativePosition.x+o.PositionAndShape.RelativePosition.x+t.GraphicalLabel.PositionAndShape.BorderMarginRight,i=s.Measures[s.Measures.length-1],l=i.PositionAndShape.RelativePosition.x+i.PositionAndShape.Size.width;let h=t.GraphicalLabel.PositionAndShape.RelativePosition.y;if(this.calculateDashes(s,e,l,h),r&&r.Measures[0]&&a.parentMeasure.ParentStaffLine&&(a!==a.parentMeasure.staffEntries[0]||a.parentMeasure!==a.parentMeasure.ParentStaffLine.Measures[0])){const t=r.Measures[0].staffEntries[0].PositionAndShape.RelativePosition.x,e=a.parentMeasure.PositionAndShape.RelativePosition.x+a.PositionAndShape.RelativePosition.x+n.GraphicalLabel.PositionAndShape.BorderMarginLeft;h=n.GraphicalLabel.PositionAndShape.RelativePosition.y,this.calculateDashes(r,t,e,h)}}}calculateDashes(t,e,i,n){let s=i-e;if(s<3*this.rules.MinimumDistanceBetweenDashes)this.calculateSingleDashForLyricWord(t,e,i,n);else{const r=Math.floor(s/this.rules.MinimumDistanceBetweenDashes)-1,o=s/(r+1);let a=0;for(e+=o,i-=o;a<=Math.floor(r/2)&&i>e;)s=this.calculateRightAndLeftDashesForLyricWord(t,e,i,n),e+=o,i-=o,a++;s>2*o&&this.calculateSingleDashForLyricWord(t,e,i,n)}}calculateSingleDashForLyricWord(t,e,i,n){const s=new w.Label("-"),r=new f.GraphicalLabel(s,this.rules.LyricsHeight,p.TextAlignmentEnum.CenterBottom,this.rules);r.setLabelPositionAndShapeBorders(),t.LyricsDashes.push(r),-1===this.staffLinesWithLyricWords.indexOf(t)&&this.staffLinesWithLyricWords.push(t),r.PositionAndShape.Parent=t.PositionAndShape;const o=new u.PointF2D(e+(i-e)/2,n);r.PositionAndShape.RelativePosition=o}calculateLyricExtend(t){let e=t.GraphicalLabel.PositionAndShape.RelativePosition.y;const i=t.StaffEntryParent,n=i.parentMeasure.ParentStaffLine;let s,r;const o=i.parentMeasure.ParentStaff.idInMusicSheet;for(let t=i.parentVerticalContainer.Index+1;t0)break;s=e,r=s.parentMeasure.ParentStaffLine,r||(r=i.parentMeasure.ParentStaffLine)}}if(s&&r)if(n===r&&s.parentMeasure.ParentStaffLine){const r=i.parentMeasure.PositionAndShape.RelativePosition.x+i.PositionAndShape.RelativePosition.x+t.GraphicalLabel.PositionAndShape.BorderMarginRight,o=s.parentMeasure.PositionAndShape.RelativePosition.x+s.PositionAndShape.RelativePosition.x+s.PositionAndShape.BorderMarginRight;e-=t.GraphicalLabel.PositionAndShape.Size.height/4,this.calculateSingleLyricWordWithUnderscore(n,r,o,e)}else{const o=n.Measures[n.Measures.length-1].PositionAndShape,a=i.parentMeasure.PositionAndShape.RelativePosition.x+i.PositionAndShape.RelativePosition.x+t.GraphicalLabel.PositionAndShape.BorderMarginRight,l=o.RelativePosition.x+o.Size.width;if(e-=t.GraphicalLabel.PositionAndShape.Size.height/4,this.calculateSingleLyricWordWithUnderscore(n,a,l,e),!s)return;if(s.parentMeasure.ParentStaffLine&&s.parentMeasure.staffEntries&&(s!==s.parentMeasure.staffEntries[0]||s.parentMeasure!==s.parentMeasure.ParentStaffLine.Measures[0])){const t=r.Measures[0].staffEntries[0].PositionAndShape.RelativePosition.x,i=s.parentMeasure.PositionAndShape.RelativePosition.x+s.PositionAndShape.RelativePosition.x+s.PositionAndShape.BorderMarginRight;this.calculateSingleLyricWordWithUnderscore(r,t,i,e)}}}calculateSingleLyricWordWithUnderscore(t,e,i,n){const s=new u.PointF2D(e,n),r=new u.PointF2D(i,n),o=new _.GraphicalLine(s,r,this.rules.LyricUnderscoreLineWidth);t.LyricLines.push(o),-1===this.staffLinesWithLyricWords.indexOf(t)&&this.staffLinesWithLyricWords.push(t)}calculateRightAndLeftDashesForLyricWord(t,e,i,n){const s=new w.Label("-"),r=new f.GraphicalLabel(s,this.rules.LyricsHeight,p.TextAlignmentEnum.CenterBottom,this.rules);r.setLabelPositionAndShapeBorders(),t.LyricsDashes.push(r),-1===this.staffLinesWithLyricWords.indexOf(t)&&this.staffLinesWithLyricWords.push(t),r.PositionAndShape.Parent=t.PositionAndShape;const o=new u.PointF2D(e,n);r.PositionAndShape.RelativePosition=o;const a=new w.Label("-"),l=new f.GraphicalLabel(a,this.rules.LyricsHeight,p.TextAlignmentEnum.CenterBottom,this.rules);l.setLabelPositionAndShapeBorders(),t.LyricsDashes.push(l),l.PositionAndShape.Parent=t.PositionAndShape;const h=new u.PointF2D(i,n);return l.PositionAndShape.RelativePosition=h,l.PositionAndShape.RelativePosition.x-r.PositionAndShape.RelativePosition.x}calculateDynamicExpressions(){const t=Math.min(this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length-1,this.rules.MaxMeasureToDrawIndex);for(let e=Math.min(this.rules.MinMeasureToDrawIndex,this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length);e<=t;e++){const t=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures[e];for(let i=0;i=0;i--)if(this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[i].StaffEntries[e])return this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[i].StaffEntries[e]}getFirstRightNotNullStaffEntryFromContainer(t,e,i){if(this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[t].StaffEntries[e])return this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[t].StaffEntries[e];for(let i=t+1;i0||e.StaffLinkedExpressions[i][n].UnknownList.length>0)&&this.calculateMoodAndUnknownExpression(e.StaffLinkedExpressions[i][n],t,i)}}calculateStemDirectionFromVoices(t){if(void 0!==t.ParentSourceStaffEntry.Link)return t===t.ParentSourceStaffEntry.VoiceEntries[0]?void(t.WantedStemDirection=h.StemDirectionType.Up):void(t.WantedStemDirection=h.StemDirectionType.Down);t.ParentVoice instanceof b.LinkedVoice?t.WantedStemDirection=h.StemDirectionType.Down:t.ParentSourceStaffEntry.VoiceEntries.length>1&&(t.WantedStemDirection=h.StemDirectionType.Up)}setBeamNotesWantedStemDirections(t){if(!(t.Notes.length>0))return;const e=t.Notes[0].NoteBeam;if(e)for(const i of e.Notes)if(i.ParentVoiceEntry.WantedStemDirection!==h.StemDirectionType.Undefined&&i.ParentVoiceEntry.ParentSourceStaffEntry.ParentStaff.Id===t.ParentSourceStaffEntry.ParentStaff.Id){t.WantedStemDirection=i.ParentVoiceEntry.WantedStemDirection;break}}}e.MusicSheetCalculator=F},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.KeyEnum=e.NoteEnumToHalfToneLink=e.KeyInstruction=void 0;const n=i(49),s=i(2),r=i(2);class o extends n.AbstractNotationInstruction{constructor(t,e=0,i=a.major){super(t),this.isTransposedBy=0,this.Key=e,this.keyTypeOriginal=e,this.mode=i,this.alteratedNotes=this.calcAlteratedNotes()}static copy(t){const e=new o(t.parent,t.Key,t.Mode);return e.keyTypeOriginal=t.keyTypeOriginal,e}static getAllPossibleMajorKeyInstructions(){const t=[];for(let e=-7;e<7;e++){const i=new o(void 0,e,a.major);t.push(i)}return t}get Key(){return this.keyType}set Key(t){this.keyType=t,this.alteratedNotes=this.calcAlteratedNotes()}get Mode(){return this.mode}set Mode(t){this.mode=t}get AlteratedNotes(){return this.alteratedNotes}calcAlteratedNotes(){const t=[];if(this.keyType>0)for(let e=0;e=0}getAlterationForPitch(t){return this.keyType>0&&this.alteratedNotes.indexOf(t.FundamentalNote)<=this.keyType?r.AccidentalEnum.SHARP:this.keyType<0&&this.alteratedNotes.indexOf(t.FundamentalNote)<=Math.abs(this.keyType)?r.AccidentalEnum.FLAT:r.AccidentalEnum.NONE}ToString(){return"Key: "+this.keyType+this.mode}OperatorEquals(t){return this===t||!(!this||!t)&&this.Key===t.Key&&this.Mode===t.Mode}OperatorNotEqual(t){return!this.OperatorEquals(t)}}var a,l;e.KeyInstruction=o,o.sharpPositionList=[s.NoteEnum.F,s.NoteEnum.C,s.NoteEnum.G,s.NoteEnum.D,s.NoteEnum.A,s.NoteEnum.E,s.NoteEnum.B],o.flatPositionList=[s.NoteEnum.B,s.NoteEnum.E,s.NoteEnum.A,s.NoteEnum.D,s.NoteEnum.G,s.NoteEnum.C,s.NoteEnum.F],e.NoteEnumToHalfToneLink=class{constructor(t,e){this.note=t,this.halfTone=e}},(l=a=e.KeyEnum||(e.KeyEnum={}))[l.major=0]="major",l[l.minor=1]="minor",l[l.none=2]="none",l[l.dorian=3]="dorian",l[l.phrygian=4]="phrygian",l[l.lydian=5]="lydian",l[l.mixolydian=6]="mixolydian",l[l.aeolian=7]="aeolian",l[l.ionian=8]="ionian",l[l.locrian=9]="locrian"},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.RhythmSymbolEnum=e.RhythmInstruction=void 0;const n=i(49);class s extends n.AbstractNotationInstruction{constructor(t,e){super(void 0),this.rhythm=t,this.numerator=t.Numerator,this.denominator=t.Denominator,this.symbolEnum=e}get Rhythm(){return this.rhythm}set Rhythm(t){this.rhythm=t}get SymbolEnum(){return this.symbolEnum}set SymbolEnum(t){this.symbolEnum=t}clone(){return new s(this.rhythm.clone(),this.symbolEnum)}OperatorEquals(t){return this===t||!(!this||!t)&&this.numerator===t.numerator&&this.denominator===t.denominator}OperatorNotEqual(t){return!(this===t)}ToString(){return"Rhythm: "+this.rhythm.toString()}}var r;e.RhythmInstruction=s,(r=e.RhythmSymbolEnum||(e.RhythmSymbolEnum={}))[r.NONE=0]="NONE",r[r.COMMON=1]="COMMON",r[r.CUT=2]="CUT"},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.ITextTranslation=void 0,e.ITextTranslation=class{static translateText(t,e){if(!this.defaultTextTranslation)return e}}},function(t,e,i){var n;Object.defineProperty(e,"__esModule",{value:!0}),e.FontStyles=void 0,(n=e.FontStyles||(e.FontStyles={}))[n.Regular=0]="Regular",n[n.Bold=1]="Bold",n[n.Italic=2]="Italic",n[n.BoldItalic=3]="BoldItalic",n[n.Underlined=4]="Underlined"},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.AutoColorSet=e.NoteState=e.GraphicalLayers=e.StyleSets=e.OUTLINE_AND_FILL_STYLE_DICT=e.OutlineAndFillStyleEnum=void 0;const n=i(15);var s,r;(r=s=e.OutlineAndFillStyleEnum||(e.OutlineAndFillStyleEnum={}))[r.BaseWritingColor=0]="BaseWritingColor",r[r.FollowingCursor=1]="FollowingCursor",r[r.AlternativeFollowingCursor=2]="AlternativeFollowingCursor",r[r.PlaybackCursor=3]="PlaybackCursor",r[r.Highlighted=4]="Highlighted",r[r.ErrorUnderlay=5]="ErrorUnderlay",r[r.Selected=6]="Selected",r[r.SelectionSymbol=7]="SelectionSymbol",r[r.DebugColor1=8]="DebugColor1",r[r.DebugColor2=9]="DebugColor2",r[r.DebugColor3=10]="DebugColor3",r[r.SplitScreenDivision=11]="SplitScreenDivision",r[r.GreyTransparentOverlay=12]="GreyTransparentOverlay",r[r.MarkedArea1=13]="MarkedArea1",r[r.MarkedArea2=14]="MarkedArea2",r[r.MarkedArea3=15]="MarkedArea3",r[r.MarkedArea4=16]="MarkedArea4",r[r.MarkedArea5=17]="MarkedArea5",r[r.MarkedArea6=18]="MarkedArea6",r[r.MarkedArea7=19]="MarkedArea7",r[r.MarkedArea8=20]="MarkedArea8",r[r.MarkedArea9=21]="MarkedArea9",r[r.MarkedArea10=22]="MarkedArea10",r[r.Comment1=23]="Comment1",r[r.Comment2=24]="Comment2",r[r.Comment3=25]="Comment3",r[r.Comment4=26]="Comment4",r[r.Comment5=27]="Comment5",r[r.Comment6=28]="Comment6",r[r.Comment7=29]="Comment7",r[r.Comment8=30]="Comment8",r[r.Comment9=31]="Comment9",r[r.Comment10=32]="Comment10",e.OUTLINE_AND_FILL_STYLE_DICT=new n.Dictionary,e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.BaseWritingColor,"Thistle"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.FollowingCursor,"Aqua"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.AlternativeFollowingCursor,"Azure"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.PlaybackCursor,"Bisque"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.Highlighted,"CadetBlue"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.ErrorUnderlay,"DarkBlue"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.Selected,"DarkGoldenRod"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.SelectionSymbol,"BlanchedAlmond"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.DebugColor1,"Chartreuse"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.DebugColor2,"DarkGreen"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.DebugColor3,"DarkOrange"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.SplitScreenDivision,"FireBrick"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.GreyTransparentOverlay,"DarkSalmon"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.MarkedArea1,"DarkSeaGreen"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.MarkedArea2,"DarkOrchid"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.MarkedArea3,"Aquamarine"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.MarkedArea4,"DarkKhaki"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.MarkedArea5,"ForestGreen"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.MarkedArea6,"AliceBlue"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.MarkedArea7,"DeepPink"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.MarkedArea8,"Coral"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.MarkedArea9,"DarkOliveGreen"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.MarkedArea10,"Chocolate"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.Comment1,"DodgerBlue"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.Comment2,"Blue"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.Comment3,"Beige"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.Comment4,"Crimson"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.Comment5,"Fuchsia"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.Comment6,"Brown"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.Comment7,"BlanchedAlmond"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.Comment8,"CornflowerBlue"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.Comment9,"Cornsilk"),e.OUTLINE_AND_FILL_STYLE_DICT.setValue(s.Comment10,"DarkGrey"),function(t){t[t.MarkedArea=0]="MarkedArea",t[t.Comment=1]="Comment"}(e.StyleSets||(e.StyleSets={})),function(t){t[t.Background=0]="Background",t[t.Highlight=1]="Highlight",t[t.MeasureError=2]="MeasureError",t[t.SelectionSymbol=3]="SelectionSymbol",t[t.Cursor=4]="Cursor",t[t.PSI_Debug=5]="PSI_Debug",t[t.Notes=6]="Notes",t[t.Comment=7]="Comment",t[t.Debug_above=8]="Debug_above"}(e.GraphicalLayers||(e.GraphicalLayers={})),function(t){t[t.Normal=0]="Normal",t[t.Selected=1]="Selected",t[t.Follow_Confirmed=2]="Follow_Confirmed",t[t.QFeedback_NotFound=3]="QFeedback_NotFound",t[t.QFeedback_OK=4]="QFeedback_OK",t[t.QFeedback_Perfect=5]="QFeedback_Perfect",t[t.Debug1=6]="Debug1",t[t.Debug2=7]="Debug2",t[t.Debug3=8]="Debug3"}(e.NoteState||(e.NoteState={})),function(t){t.C="#d82c6b",t.D="#F89D15",t.E="#FFE21A",t.F="#4dbd5c",t.G="#009D96",t.A="#43469d",t.B="#76429c",t.Rest="#000000"}(e.AutoColorSet||(e.AutoColorSet={}))},function(t,e,i){var n,s;Object.defineProperty(e,"__esModule",{value:!0}),e.SystemLinesEnumHelper=e.SystemLinesEnum=void 0,(s=n=e.SystemLinesEnum||(e.SystemLinesEnum={}))[s.SingleThin=0]="SingleThin",s[s.DoubleThin=1]="DoubleThin",s[s.ThinBold=2]="ThinBold",s[s.BoldThinDots=3]="BoldThinDots",s[s.DotsThinBold=4]="DotsThinBold",s[s.DotsBoldBoldDots=5]="DotsBoldBoldDots",s[s.None=6]="None",s[s.Dotted=7]="Dotted",s[s.Dashed=8]="Dashed",s[s.Bold=9]="Bold",s[s.BoldThin=10]="BoldThin",s[s.DoubleBold=11]="DoubleBold",s[s.Tick=12]="Tick",s[s.Short=13]="Short",e.SystemLinesEnumHelper=class{static xmlBarlineStyleToSystemLinesEnum(t){return"regular"===t?n.SingleThin:"dotted"===t?n.Dotted:"dashed"===t?n.Dashed:"heavy"===t?n.Bold:"light-light"===t?n.DoubleThin:"light-heavy"===t?n.ThinBold:"heavy-light"===t?n.BoldThin:"heavy-heavy"===t?n.DoubleBold:"tick"===t?n.Tick:"short"===t?n.Short:"none"===t?n.None:n.SingleThin}}},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalLabel=void 0;const n=i(9),s=i(5),r=i(114),o=i(17);class a extends r.Clickable{constructor(t,e,i,n,r){super(),this.label=t,this.boundingBox=new s.BoundingBox(this,r),this.label.fontHeight=e,this.label.textAlignment=i,this.rules=n}get Label(){return this.label}toString(){return`${this.label.text} (${this.boundingBox.RelativePosition.x},${this.boundingBox.RelativePosition.y})`}setLabelPositionAndShapeBorders(){var t,e;if(""===this.Label.text.trim())return;this.TextLines=[];const i=null!==(e=null===(t=this.rules)||void 0===t?void 0:t.LabelMarginBorderFactor)&&void 0!==e?e:.1,s=this.Label.text.split(/[\n\r]+/g),r=s.length;let a=0;for(let t=0;t0&&this.TextLines.length>1&&(l+=this.rules.SpacingBetweenTextLines*r/10);const h=this.PositionAndShape;switch(this.Label.textAlignment){case n.TextAlignmentEnum.CenterBottom:h.BorderTop=-l,h.BorderLeft=-a/2,h.BorderBottom=0,h.BorderRight=a/2;break;case n.TextAlignmentEnum.CenterCenter:h.BorderTop=-l/2,h.BorderLeft=-a/2,h.BorderBottom=l/2,h.BorderRight=a/2;break;case n.TextAlignmentEnum.CenterTop:h.BorderTop=0,h.BorderLeft=-a/2,h.BorderBottom=l,h.BorderRight=a/2;break;case n.TextAlignmentEnum.LeftBottom:h.BorderTop=-l,h.BorderLeft=0,h.BorderBottom=0,h.BorderRight=a;break;case n.TextAlignmentEnum.LeftCenter:h.BorderTop=-l/2,h.BorderLeft=0,h.BorderBottom=l/2,h.BorderRight=a;break;case n.TextAlignmentEnum.LeftTop:h.BorderTop=0,h.BorderLeft=0,h.BorderBottom=l,h.BorderRight=a;break;case n.TextAlignmentEnum.RightBottom:h.BorderTop=-l,h.BorderLeft=-a,h.BorderBottom=0,h.BorderRight=0;break;case n.TextAlignmentEnum.RightCenter:h.BorderTop=-l/2,h.BorderLeft=-a,h.BorderBottom=l/2,h.BorderRight=0;break;case n.TextAlignmentEnum.RightTop:h.BorderTop=0,h.BorderLeft=-a,h.BorderBottom=l,h.BorderRight=0}h.BorderMarginTop=h.BorderTop-l*i,h.BorderMarginLeft=h.BorderLeft-l*i,h.BorderMarginBottom=h.BorderBottom+l*i,h.BorderMarginRight=h.BorderRight+l*i}}e.GraphicalLabel=a},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.OSMDOptions=e.BackendType=e.FillEmptyMeasuresWithWholeRests=e.AlignRestOption=void 0;const n=i(33);var s,r;(r=e.AlignRestOption||(e.AlignRestOption={}))[r.Never=0]="Never",r[r.Always=1]="Always",r[r.Auto=2]="Auto",function(t){t[t.No=0]="No",t[t.YesVisible=1]="YesVisible",t[t.YesInvisible=2]="YesInvisible"}(e.FillEmptyMeasuresWithWholeRests||(e.FillEmptyMeasuresWithWholeRests={})),function(t){t[t.SVG=0]="SVG",t[t.Canvas=1]="Canvas"}(s=e.BackendType||(e.BackendType={})),e.OSMDOptions=class{static OSMDOptionsStandard(){return{autoResize:!0,backend:"svg",drawingParameters:n.DrawingParametersEnum.default}}static BackendTypeFromString(t){return t&&"canvas"===t.toLowerCase()?s.Canvas:s.SVG}}},function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.PageFormat=e.EngravingRules=void 0;const s=i(45),r=n(i(1)),o=i(9),a=i(3),l=i(25),h=i(33),c=i(15),u=i(67),d=i(48),f=i(71);class p{constructor(){this.NoteDistances=[1,1,1.3,1.6,2,2.5,3,4],this.NoteDistancesScalingFactors=[1,2,4,8,16,32,64,128],this.DurationDistanceDict={},this.DurationScalingDistanceDict={},this.NoteToGraphicalNoteMapObjectCount=0,this.loadDefaultValues()}loadDefaultValues(){this.SamplingUnit=3*p.unit,this.SheetTitleHeight=4,this.SheetSubtitleHeight=2,this.SheetMinimumDistanceBetweenTitleAndSubtitle=1,this.SheetComposerHeight=2,this.SheetAuthorHeight=2,this.CompactMode=!1,this.PagePlacementEnum=s.PagePlacementEnum.Down,this.PageHeight=100001,this.PageTopMargin=5,this.PageTopMarginNarrow=0,this.PageBottomMargin=5,this.PageLeftMargin=5,this.PageRightMargin=5,this.TitleTopDistance=5,this.TitleBottomDistance=1,this.StaffDistance=7,this.BetweenStaffDistance=5,this.MinimumStaffLineDistance=4,this.MinSkyBottomDistBetweenStaves=1,this.StaffHeight=4,this.TabStaffInterlineHeight=1.1111,this.BetweenStaffLinesDistance=p.unit,this.SystemLeftMargin=0,this.SystemRightMargin=0,this.SystemLabelsRightMargin=2,this.SystemComposerDistance=2,this.InstrumentLabelTextHeight=2,this.MinimumDistanceBetweenSystems=7,this.MinSkyBottomDistBetweenSystems=5,this.LastSystemMaxScalingFactor=1.4,this.AutoBeamNotes=!1,this.AutoBeamOptions={beam_middle_rests_only:!1,beam_rests:!1,maintain_stem_directions:!1},this.BeamWidth=p.unit/2,this.BeamSpaceWidth=p.unit/3,this.BeamForwardLength=1.25*p.unit,this.FlatBeams=!1,this.FlatBeamOffset=20,this.FlatBeamOffsetPerBeam=10,this.ClefLeftMargin=.5,this.ClefRightMargin=.75,this.PercussionOneLineCutoff=3,this.PercussionForceVoicesOneLineCutoff=1,this.PercussionOneLineUseXMLDisplayStep=!0,this.PercussionOneLineXMLDisplayStepOctaveOffset=0,this.BetweenKeySymbolsDistance=.2,this.KeyRightMargin=.75,this.RhythmRightMargin=1.25,this.ShowRhythmAgainAfterPartEndOrFinalBarline=!0,this.NewPartAndSystemAfterFinalBarline=!1,this.InStaffClefScalingFactor=.8,this.DistanceBetweenNaturalAndSymbolWhenCancelling=.4,this.NoteHelperLinesOffset=.25,this.MeasureLeftMargin=.7,this.MeasureRightMargin=0,this.DistanceBetweenLastInstructionAndRepetitionBarline=1,this.ArpeggioDistance=.6,this.StaccatoShorteningFactor=2,this.IdealStemLength=3,this.StemNoteHeadBorderYOffset=.2,this.StemMargin=.2,this.StemMinLength=2.5,this.StemMaxLength=4.5,this.BeamSlopeMaxAngle=10,this.StemMinAllowedDistanceBetweenNoteHeadAndBeamLine=1,this.SetWantedStemDirectionByXml=!0,this.GraceNoteScalingFactor=.6,this.GraceNoteXOffset=.2,this.WedgeOpeningLength=1.2,this.WedgeMeasureEndOpeningLength=.75,this.WedgeMeasureBeginOpeningLength=.75,this.WedgePlacementAboveY=-1.5,this.WedgePlacementBelowY=1.5,this.WedgeHorizontalMargin=.6,this.WedgeVerticalMargin=.5,this.DistanceOffsetBetweenTwoHorizontallyCrossedWedges=.3,this.WedgeMinLength=2,this.DistanceBetweenAdjacentDynamics=.75,this.TempoChangeMeasureValidity=4,this.TempoContinousFactor=.7,this.StaccatoScalingFactor=.8,this.BetweenDotsDistance=.8,this.OrnamentAccidentalScalingFactor=.65,this.ChordSymbolTextHeight=2,this.ChordSymbolTextAlignment=o.TextAlignmentEnum.LeftBottom,this.ChordSymbolRelativeXOffset=-1,this.ChordSymbolXSpacing=1,this.ChordOverlapAllowedIntoNextMeasure=0,this.ChordSymbolYOffset=2,this.ChordSymbolLabelTexts=new c.Dictionary,this.resetChordSymbolLabelTexts(this.ChordSymbolLabelTexts),this.CustomChords=[],this.resetChordNames(),this.RepetitionSymbolsYOffset=0,this.RehearsalMarkXOffsetDefault=10,this.RehearsalMarkXOffset=0,this.RehearsalMarkXOffsetSystemStartMeasure=-20,this.RehearsalMarkYOffsetDefault=-15,this.RehearsalMarkYOffset=0,this.RehearsalMarkFontSize=10,this.MeasureNumberLabelHeight=1.5*p.unit,this.MeasureNumberLabelOffset=2,this.MeasureNumberLabelXOffset=-.5,this.TupletsRatioed=!1,this.TupletsBracketed=!1,this.TripletsBracketed=!1,this.TupletNumberLabelHeight=1.5*p.unit,this.TupletNumberYOffset=.5,this.LabelMarginBorderFactor=.1,this.TupletVerticalLineLength=.5,this.TupletNumbersInTabs=!1,this.SlurPlacementFromXML=!0,this.BezierCurveStepSize=1e3,this.calculateCurveParametersArrays(),this.TieGhostObjectWidth=.75,this.TieYPositionOffsetFactor=.3,this.MinimumNeededXspaceForTieGhostObject=1,this.TieHeightMinimum=.28,this.TieHeightMaximum=1.2,this.TieHeightInterpolationK=.0288,this.TieHeightInterpolationD=.136,this.SlurNoteHeadYOffset=.5,this.SlurStemXOffset=.3,this.SlurSlopeMaxAngle=15,this.SlurTangentMinAngle=30,this.SlurTangentMaxAngle=80,this.SlurHeightFactor=1,this.SlurHeightFlattenLongSlursFactorByWidth=.24,this.SlurHeightFlattenLongSlursFactorByAngle=.36,this.SlurHeightFlattenLongSlursCutoffAngle=47,this.SlurHeightFlattenLongSlursCutoffWidth=16,this.SlursStartingAtSameStaffEntryYOffset=.8,this.RepetitionEndingLabelHeight=2,this.RepetitionEndingLabelXOffset=.5,this.RepetitionEndingLabelYOffset=.3,this.RepetitionEndingLineYLowerOffset=.5,this.RepetitionEndingLineYUpperOffset=.3,this.VoltaOffset=2.5,this.LyricsAlignmentStandard=o.TextAlignmentEnum.LeftBottom,this.LyricsHeight=2,this.LyricsYOffsetToStaffHeight=0,this.VerticalBetweenLyricsDistance=.5,this.HorizontalBetweenLyricsDistance=.2,this.BetweenSyllableMaximumDistance=10,this.BetweenSyllableMinimumDistance=.5,this.LyricOverlapAllowedIntoNextMeasure=3.4,this.MinimumDistanceBetweenDashes=10,this.MaximumLyricsElongationFactor=2.5,this.InstantaneousTempoTextHeight=2.3,this.ContinuousDynamicTextHeight=2.3,this.MoodTextHeight=2.3,this.UnknownTextHeight=2,this.ContinuousTempoTextHeight=2.3,this.DynamicExpressionMaxDistance=2,this.DynamicExpressionSpacer=.5,this.VexFlowDefaultNotationFontScale=39,this.VexFlowDefaultTabFontScale=39,this.TremoloStrokeScale=1,this.TremoloYSpacingScale=1,this.StemWidth=.15,this.StaffLineWidth=.1,this.StaffLineColor=void 0,this.LedgerLineWidth=1,this.LedgerLineStrokeStyle=void 0,this.LedgerLineColorDefault="#000000",this.WedgeLineWidth=.12,this.TupletLineWidth=.12,this.LyricUnderscoreLineWidth=.12,this.SystemThinLineWidth=.12,this.SystemBoldLineWidth=p.unit/2,this.SystemRepetitionEndingLineWidth=.12,this.SystemDotWidth=p.unit/5,this.DistanceBetweenVerticalSystemLines=.35,this.DistanceBetweenDotAndLine=.7,this.OctaveShiftLineWidth=.12,this.OctaveShiftVerticalLineLength=p.unit,this.GraceLineWidth=this.StaffLineWidth*this.GraceNoteScalingFactor,this.MultipleRestMeasureDefaultWidth=4,this.MinimumCrossedBeamDifferenceMargin=1e-4,this.VoiceSpacingMultiplierVexflow=.85,this.VoiceSpacingAddendVexflow=3,this.PickupMeasureWidthMultiplier=1,this.DisplacedNoteMargin=.1,this.MinNoteDistance=2,this.SubMeasureXSpacingThreshold=35,this.MeasureDynamicsMaxScalingFactor=2.5,this.WholeRestXShiftVexflow=-1.5,this.MetronomeMarksDrawn=!0,this.MetronomeMarkXShift=-6,this.MetronomeMarkYShift=-.5,this.SoftmaxFactorVexFlow=15,this.AlignRests=l.AlignRestOption.Never,this.FillEmptyMeasuresWithWholeRest=l.FillEmptyMeasuresWithWholeRests.No,this.ArpeggiosGoAcrossVoices=!1,this.RenderArpeggios=!0,this.RenderSlurs=!0,this.ColoringMode=h.ColoringModes.XML,this.ColoringEnabled=!0,this.ColorStemsLikeNoteheads=!1,this.ColorBeams=!0,this.ColorFlags=!0,this.DefaultColorNotehead="#000000",this.DefaultColorRest=this.DefaultColorNotehead,this.DefaultColorStem=this.DefaultColorNotehead,this.DefaultColorLabel=this.DefaultColorNotehead,this.DefaultColorTitle=this.DefaultColorNotehead,this.DefaultColorCursor="#33e02f",this.DefaultFontFamily="Times New Roman",this.DefaultFontStyle=u.FontStyles.Regular,this.DefaultVexFlowNoteFont="gonville",this.MaxMeasureToDrawIndex=Number.MAX_VALUE,this.MinMeasureToDrawIndex=0,this.MaxSystemToDrawNumber=Number.MAX_VALUE,this.MaxPageToDrawNumber=Number.MAX_VALUE,this.RenderComposer=!0,this.RenderTitle=!0,this.RenderSubtitle=!0,this.RenderLyricist=!0,this.RenderPartNames=!0,this.RenderPartAbbreviations=!0,this.RenderFingerings=!0,this.RenderMeasureNumbers=!0,this.RenderMeasureNumbersOnlyAtSystemStart=!1,this.UseXMLMeasureNumbers=!0,this.RenderLyrics=!0,this.RenderChordSymbols=!0,this.RenderMultipleRestMeasures=!0,this.AutoGenerateMutipleRestMeasuresFromRestMeasures=!0,this.RenderRehearsalMarks=!0,this.RenderKeySignatures=!0,this.RenderTimeSignatures=!0,this.ArticulationPlacementFromXML=!0,this.FingeringPosition=a.PlacementEnum.Left,this.FingeringInsideStafflines=!1,this.FingeringLabelFontHeight=1.7,this.FingeringOffsetX=0,this.RenderStringNumbersClassical=!0,this.StringNumberOffsetY=0,this.NewSystemAtXMLNewSystemAttribute=!1,this.NewPageAtXMLNewPageAttribute=!1,this.RestoreCursorAfterRerender=!0,this.StretchLastSystemLine=!1,p.FixStafflineBoundingBox=!1,this.PageFormat=m.UndefinedPageFormat,this.PageBackgroundColor=void 0,this.RenderSingleHorizontalStaffline=!1,this.SpacingBetweenTextLines=0,this.NoteToGraphicalNoteMap=new c.Dictionary,this.NoteToGraphicalNoteMapObjectCount=0;try{this.MaxInstructionsConstValue=this.ClefLeftMargin+this.ClefRightMargin+this.KeyRightMargin+this.RhythmRightMargin+11}catch(t){r.default.info("EngravingRules()",t)}}addGraphicalNoteToNoteMap(t,e){t.NoteToGraphicalNoteObjectId=this.NoteToGraphicalNoteMapObjectCount,this.NoteToGraphicalNoteMap.setValue(t.NoteToGraphicalNoteObjectId,e),this.NoteToGraphicalNoteMapObjectCount++}GNote(t){return f.GraphicalNote.FromNote(t,this)}clearMusicSheetObjects(){this.NoteToGraphicalNoteMap=new c.Dictionary,this.NoteToGraphicalNoteMapObjectCount=0}setChordSymbolLabelText(t,e){this.ChordSymbolLabelTexts.setValue(t,e)}resetChordSymbolLabelTexts(t){return t.setValue(d.ChordSymbolEnum.minor,"m"),t.setValue(d.ChordSymbolEnum.augmented,"aug"),t.setValue(d.ChordSymbolEnum.diminished,"dim"),t.setValue(d.ChordSymbolEnum.dominant,"7"),t.setValue(d.ChordSymbolEnum.majorseventh,"maj7"),t.setValue(d.ChordSymbolEnum.minorseventh,"m7"),t.setValue(d.ChordSymbolEnum.diminishedseventh,"dim7"),t.setValue(d.ChordSymbolEnum.augmentedseventh,"aug7"),t.setValue(d.ChordSymbolEnum.halfdiminished,"m7b5"),t.setValue(d.ChordSymbolEnum.majorminor,"m(maj7)"),t.setValue(d.ChordSymbolEnum.majorsixth,"maj6"),t.setValue(d.ChordSymbolEnum.minorsixth,"m6"),t.setValue(d.ChordSymbolEnum.dominantninth,"9"),t.setValue(d.ChordSymbolEnum.majorninth,"maj9"),t.setValue(d.ChordSymbolEnum.minorninth,"m9"),t.setValue(d.ChordSymbolEnum.dominant11th,"11"),t.setValue(d.ChordSymbolEnum.major11th,"maj11"),t.setValue(d.ChordSymbolEnum.minor11th,"m11"),t.setValue(d.ChordSymbolEnum.dominant13th,"13"),t.setValue(d.ChordSymbolEnum.major13th,"maj13"),t.setValue(d.ChordSymbolEnum.minor13th,"m13"),t.setValue(d.ChordSymbolEnum.suspendedsecond,"sus2"),t.setValue(d.ChordSymbolEnum.suspendedfourth,"sus4"),t.setValue(d.ChordSymbolEnum.power,"5"),t.setValue(d.ChordSymbolEnum.none,"N.C."),t}addChordName(t,e,i,n,s){if(void 0!==d.ChordSymbolEnum[e]){const r={adds:i,alts:n,subs:s};this.CustomChords.push(d.CustomChord.createCustomChord(t,d.ChordSymbolEnum[e],r))}}renameChord(t,e){d.CustomChord.renameCustomChord(t,e,this.CustomChords)}resetChordNames(){this.addChordName("alt","major",["#5","b9","#9"],["b5"],[]),this.addChordName("7alt","dominant",["#5","b9","#9"],["b5"],[]),this.addChordName("7sus4","dominant",["4"],[],["3"]),this.addChordName("7sus4","suspendedfourth",["7"],[],[]),this.addChordName("9sus4","dominantninth",["4"],[],["3"]),this.addChordName("9sus4","suspendedfourth",["9"],[],[]),this.addChordName("11sus4","dominant11th",["4"],[],["3"]),this.addChordName("11sus4","suspendedfourth",["11"],[],[]),this.addChordName("13sus4","dominant13th",["4"],[],["3"]),this.addChordName("13sus4","suspendedfourth",["13"],[],[]),this.addChordName("7sus2","dominant",["2"],[],["3"]),this.addChordName("7sus2","suspendedsecond",["7"],[],[]),this.addChordName("m7b5","minorseventh",[],["b5"],[]),this.addChordName("9sus2","dominantninth",["2"],[],["3"]),this.addChordName("9sus2","suspendedsecond",["9"],[],[]),this.addChordName("11sus2","dominant11th",["2"],[],["3"]),this.addChordName("11sus2","suspendedsecond",["11"],[],[]),this.addChordName("13sus2","dominant13th",["2"],[],["3"]),this.addChordName("13sus2","suspendedsecond",["13"],[],[]),this.addChordName("m(maj9)","majorminor",["9"],[],[]),this.addChordName("m(maj11)","majorminor",["11"],[],[]),this.addChordName("m(maj13)","majorminor",["13"],[],[]),this.addChordName("69","majorsixth",["9"],[],[]),this.addChordName("mi69","minorsixth",["9"],[],[])}calculateCurveParametersArrays(){this.TPower3=new Array(this.BezierCurveStepSize),this.OneMinusTPower3=new Array(this.BezierCurveStepSize),this.FactorOne=new Array(this.BezierCurveStepSize),this.FactorTwo=new Array(this.BezierCurveStepSize);for(let t=0;te.parentRepetition.StartIndex)return-1}if(t.alignment===s.Begin&&e.alignment===s.Begin){if(t.parentRepetition.EndIndexe.parentRepetition.EndIndex)return-1}}return 0}},e.RepetitionInstruction=class{constructor(t,e,i=s.End,n,r){this.endingIndices=void 0,this.measureIndex=t,r&&(this.endingIndices=r.slice()),this.type=e,this.alignment=i,this.parentRepetition=n}CompareTo(t){const e=t;if(this.measureIndex>e.measureIndex)return 1;if(this.measureIndex0)return!0;return!1}hasTie(){for(let t=0,e=this.VoiceEntries.length;t=0;r--)if(s(t[r],e))return r;return-1},e.contains=function(t,e,i){return s(t,e,i)>=0},e.remove=function(t,e,i){var n=s(t,e,i);return!(n<0||(t.splice(n,1),0))},e.frequency=function(t,e,i){for(var s=i||n.defaultEquals,r=t.length,o=0,a=0;a=t.length||i<0||i>=t.length)return!1;var n=t[e];return t[e]=t[i],t[i]=n,!0},e.toString=function(t){return"["+t.toString()+"]"},e.forEach=function(t,e){for(var i=0,n=t;i0){c.default.trace(`Ghost Found in between (measure ${this.MeasureNumber})`);const e=l.VexFlowConverter.GhostNote(n),s=new m.VexFlowVoiceEntry(void 0,void 0);s.vfStaveNote=e,i.splice(t,0,s),t++}}else{const e=b.Fraction.minus(s,this.parentSourceMeasure.AbsoluteTimestamp);if(e.RealValue>0){c.default.trace(`Ghost Found at start (measure ${this.MeasureNumber})`);const n=l.VexFlowConverter.GhostNote(e),s=new m.VexFlowVoiceEntry(void 0,void 0);s.vfStaveNote=n,i.splice(0,0,s),t++}}e=r}const n=b.Fraction.plus(this.parentSourceMeasure.AbsoluteTimestamp,this.parentSourceMeasure.Duration),s=b.Fraction.minus(n,e);if(s.RealValue>0){c.default.trace(`Ghost Found at end (measure ${this.MeasureNumber})`);const t=l.VexFlowConverter.GhostNote(s),e=new m.VexFlowVoiceEntry(void 0,void 0);e.vfStaveNote=t,i.push(e)}return i}handleBeam(t,e){const i=t.sourceNote.ParentVoiceEntry.ParentVoice.VoiceId;let n,s=this.beams[i];s||(s=this.beams[i]=[]);for(const t of s)t[0]===e&&(n=t);n||(n=[e,[]],s.push(n));const r=t.parentVoiceEntry;n[1].indexOf(r)<0&&n[1].push(r)}handleTuplet(t,e){const i=t.sourceNote.ParentVoiceEntry.ParentVoice.VoiceId;e=t.sourceNote.NoteTuplet;let n,s=this.tuplets[i];s||(s=this.tuplets[i]=[]);for(const t of s)t[0]===e&&(n=t);n||(n=[e,[]],s.push(n));const r=t.parentVoiceEntry;n[1].indexOf(r)<0&&n[1].push(r)}finalizeBeams(){this.vfbeams={};const t=[];for(const e in this.beams)if(this.beams.hasOwnProperty(e)){let i=this.vfbeams[e];i||(i=this.vfbeams[e]=[]);for(const n of this.beams[e]){let e=!1;for(const t of n[0].Notes)if(t.Length.RealValue>=new b.Fraction(1,4).RealValue&&(!t.TypeLength||t.TypeLength.RealValue>.125)){e=!0;break}if(e){c.default.debug("Beam between note >= quarter, likely tremolo, currently unsupported. continuing.");continue}const r=[],o=n[0],a=n[1];let l=!0;for(const t of a)t.parentVoiceEntry.ParentVoice===o.Notes[0].ParentVoiceEntry.ParentVoice&&(l=t.parentVoiceEntry.WantedStemDirection===p.StemDirectionType.Undefined);let h,u=!1;const d=[];for(const e of a){const i=e.vfStaveNote;i&&(r.push(i),t.push(i)),e.parentVoiceEntry.IsGrace&&(u=!0),e.parentVoiceEntry.StemColor&&this.rules.ColoringEnabled&&d.push(e.parentVoiceEntry.StemColor)}if(r.length>1){const t=new s.default.Flow.Beam(r,l);if(u&&(t.render_options.beam_width=3,t.render_options.partial_beam_length=4),d.length>=2&&this.rules.ColorBeams){h=d[0];for(const t of d)if(t!==h){h=void 0;break}t.setStyle({fillStyle:h,strokeStyle:h})}this.rules.FlatBeams&&(t.render_options.flat_beams=!0,t.render_options.flat_beam_offset=this.rules.FlatBeamOffset,t.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),i.push(t)}else c.default.debug("Warning! Beam with no notes!")}}this.rules.AutoBeamNotes&&this.autoBeamNotes(t)}autoBeamNotes(t){let e,i=[],n=[],r=[];this.autoTupletVfBeams=[];const o=[];this.autoVfBeams=[];let a=this.parentSourceMeasure.ActiveTimeSignature;a||(a=this.parentSourceMeasure.Duration);for(const l of this.staffEntries)for(const h of l.graphicalVoiceEntries){const c=h.vfStaveNote,u=h.notes[0],d=l.relInMeasureTimestamp.isOnBeat(a),f=n.length>=2,p=u.sourceNote.Length.RealValue-new b.Fraction(1,4).RealValue>-b.Fraction.FloatInaccuracyTolerance,m=h.parentVoiceEntry.IsGrace||p||t.contains(c);if(m||d){if(f){for(const t of n)i.push(t);o.push(i.slice()),i=[]}if(n=[],m)continue}const g=h.notes[0].sourceNote.NoteTuplet;if(g){let t=!1;for(const e of g.Notes){for(const i of e)if(i.NoteTypeXml>=S.NoteType.QUARTER||i.ParentVoiceEntry.IsGrace||i.isRest()&&!this.rules.AutoBeamOptions.beam_rests){t=!0;break}if(t)break}if(e){if(e!==g){if(r.length>1){const t=new s.default.Flow.Beam(r,!0);this.rules.FlatBeams&&(t.render_options.flat_beams=!0,t.render_options.flat_beam_offset=this.rules.FlatBeamOffset,t.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),this.autoTupletVfBeams.push(t)}r=[],e=g}}else e=g;t||r.push(c)}else e=void 0,n.push(c)}if(r.length>=2){const t=new s.default.Flow.Beam(r,!0);this.rules.FlatBeams&&(t.render_options.flat_beams=!0,t.render_options.flat_beam_offset=this.rules.FlatBeamOffset,t.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),this.autoTupletVfBeams.push(t)}if(n.length>=2){for(const t of n)i.push(t);o.push(i)}const l=this.rules.AutoBeamOptions,h={beam_middle_only:l.beam_middle_rests_only,beam_rests:l.beam_rests,maintain_stem_directions:l.maintain_stem_directions};if(l.groups&&l.groups.length){const t=[];for(const e of l.groups)t.push(new s.default.Flow.Fraction(e[0],e[1]));h.groups=t}for(const t of o){const e=s.default.Flow.Beam.generateBeams(t,h);for(const t of e)this.rules.FlatBeams&&(t.render_options.flat_beams=!0,t.render_options.flat_beam_offset=this.rules.FlatBeamOffset,t.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),this.autoVfBeams.push(t)}}finalizeTuplets(){this.vftuplets={};for(const t in this.tuplets)if(this.tuplets.hasOwnProperty(t)){let e=this.vftuplets[t];e||(e=this.vftuplets[t]=[]);for(const i of this.tuplets[t]){const t=[],n=i[1];for(const e of n)t.push(e.vfStaveNote);if(t.length>1){const n=i[0],r=n.Notes[0][0].NormalNotes,o=n.Bracket||3===n.TupletLabelNumber&&this.rules.TripletsBracketed||3!==n.TupletLabelNumber&&this.rules.TupletsBracketed;let a=s.default.Flow.Tuplet.LOCATION_TOP;n.tupletLabelNumberPlacement===y.PlacementEnum.Below&&(a=s.default.Flow.Tuplet.LOCATION_BOTTOM),e.push(new s.default.Flow.Tuplet(t,{bracketed:o,location:a,notes_occupied:r,num_notes:n.TupletLabelNumber,ratioed:this.rules.TupletsRatioed}))}else c.default.debug("Warning! Tuplet with no notes! Trying to ignore, but this is a serious problem.")}}}layoutStaffEntry(t){}graphicalMeasureCreatedCalculations(){let t,e=[];const i=[];for(const n of this.staffEntries){t=!1,e=[];for(const r of n.graphicalVoiceEntries)if(r.parentVoiceEntry.IsGrace)e.push(r),i.push(r),t||(t=r.parentVoiceEntry.GraceSlur);else if(r.notes[0].sourceNote.PrintObject,r.vfStaveNote=l.VexFlowConverter.StaveNote(r),e.length>0){const i=[];for(let t=0;t0)for(const t of e)t.vfStaveNote=l.VexFlowConverter.StaveNote(t),t.parentVoiceEntry.GraceAfterMainNote=!0;this.finalizeBeams(),this.finalizeTuplets();const n=this.getVoicesWithinMeasure();if(this.rules.RenderFingerings)for(const t of this.staffEntries)t.setModifierXOffsets();for(const t of n){if(!t)continue;const e=!(t instanceof g.LinkedVoice);this.vfVoices[t.VoiceId]=new s.default.Flow.Voice({beat_value:this.parentSourceMeasure.Duration.Denominator,num_beats:this.parentSourceMeasure.Duration.Numerator,resolution:s.default.Flow.RESOLUTION}).setMode(s.default.Flow.Voice.Mode.SOFT);const i=this.getRestFilledVexFlowStaveNotesPerVoice(t);for(const n of i){if(n.parentVoiceEntry&&n.parentVoiceEntry.IsGrace&&!n.parentVoiceEntry.GraceAfterMainNote)continue;const i=n;if(0!==n.notes.length&&n.notes[0]&&n.notes[0].sourceNote.PrintObject){if(e){const t=i.parentStaffEntry;if(t&&t.vfClefBefore){const e=new h([t.vfClefBefore]);i.vfStaveNote.getCategory&&"stavenotes"===i.vfStaveNote.getCategory()&&i.vfStaveNote.addModifier(0,e)}}n.parentVoiceEntry&&this.rules.RenderFingerings&&(this.createFingerings(n),this.createStringNumber(n)),this.createArpeggio(n),this.vfVoices[t.VoiceId].addTickable(i.vfStaveNote)}else this.vfVoices[t.VoiceId].addTickable(i.vfStaveNote)}}for(const t of i)this.createFingerings(t),this.createStringNumber(t),this.createArpeggio(t);this.createArticulations(),this.createOrnaments(),this.setStemDirectionFromVexFlow()}createArpeggio(t){if(t.parentVoiceEntry&&t.parentVoiceEntry.Arpeggio){const e=t.parentVoiceEntry.Arpeggio;if(t.notes&&t.notes.length>1){const i=l.VexFlowConverter.StrokeTypeFromArpeggioType(e.type),n=new s.default.Flow.Stroke(i,{all_voices:this.rules.ArpeggiosGoAcrossVoices});this.rules.RenderArpeggios&&t.vfStaveNote.addStroke(0,n)}else c.default.debug(`[OSMD] arpeggio in measure ${this.MeasureNumber} could not be drawn.\n voice entry had less than two notes, arpeggio is likely between voice entries, not currently supported in Vexflow.`)}}setStemDirectionFromVexFlow(){for(const t of this.staffEntries)for(const e of t.graphicalVoiceEntries)for(const t of e.notes){const i=t.vfnote;if(i&&i[0])switch(i[0].getStemDirection()){case s.default.Flow.Stem.UP:e.parentVoiceEntry.StemDirection=p.StemDirectionType.Up;break;case s.default.Flow.Stem.DOWN:e.parentVoiceEntry.StemDirection=p.StemDirectionType.Down}}}createArticulations(){for(let t=0,e=this.staffEntries.length;t1||t.parentStaffEntry.graphicalVoiceEntries.length>1?l=s.default.Flow.StaveModifier.Position.LEFT:0===e.idInMusicSheet?(l=s.default.Flow.StaveModifier.Position.ABOVE,a=y.PlacementEnum.Above):(l=s.default.Flow.StaveModifier.Position.BELOW,a=y.PlacementEnum.Below)}const c=new s.default.Flow.FretHandFinger(o.value);if(c.setPosition(l),c.setOffsetX(h),a===y.PlacementEnum.Above||a===y.PlacementEnum.Below){const t=a===y.PlacementEnum.Above?-1:1,r=a===y.PlacementEnum.Above?n:i-1-n;if(this.rules.FingeringInsideStafflines&&i>1){const e=c.getWidth()/2,n=2.5*i;c.setOffsetY(t*(r+n)*e)}else if(!this.rules.FingeringInsideStafflines){const i=new s.default.Flow.StringNumber(o.value);i.radius=0,i.setPosition(l),i.setOffsetY(t*r*i.getWidth()*2/3),e.vfStaveNote.addModifier(n,i);continue}}e.vfStaveNote.addModifier(n,c)}}createStringNumber(t){if(!this.rules.RenderStringNumbersClassical)return;const e=t;t.notes.forEach(((i,n)=>{const r=i.sourceNote.StringInstruction;if(r){let o=r.value;switch(o){case"1":o="I";break;case"2":o="II";break;case"3":o="III";break;case"4":o="IV";break;case"5":o="V";break;case"6":o="VI"}const a=new s.default.Flow.StringNumber(o);a.radius=0;const l=-this.rules.StringNumberOffsetY;t.notes.length>1||t.parentStaffEntry.graphicalVoiceEntries.length>1?(a.setOffsetX(13*i.baseStringNumberXOffset),a.setPosition(s.default.Flow.Modifier.Position.RIGHT)):a.setPosition(s.default.Flow.Modifier.Position.ABOVE),a.setOffsetY(l),e.vfStaveNote.addModifier(n,a)}}))}lineTo(t,e){const i=new s.default.Flow.StaveConnector(t.getVFStave(),this.stave);i.setType(e),this.connectors.push(i)}getVFStave(){return this.stave}updateInstructionWidth(){let t=0,e=0;const i=this.stave.getModifiers();for(const n of i)n.getPosition()===x.BEGIN?t+=n.getWidth()+n.getPadding(void 0):n.getPosition()===x.END&&(e+=n.getWidth()+n.getPadding(void 0));this.beginInstructionsWidth=(null!=t?t:0)/u.unitInPixels,this.endInstructionsWidth=(null!=e?e:0)/u.unitInPixels}}var x,E;e.VexFlowMeasure=v,(E=x=e.StavePositionEnum||(e.StavePositionEnum={}))[E.LEFT=1]="LEFT",E[E.RIGHT=2]="RIGHT",E[E.ABOVE=3]="ABOVE",E[E.BELOW=4]="BELOW",E[E.BEGIN=5]="BEGIN",E[E.END=6]="END"},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.PagePlacementEnum=e.GraphicalMusicPage=void 0;const n=i(5),s=i(6),r=i(4);class o extends s.GraphicalObject{constructor(t){super(),this.musicSystems=[],this.labels=[],this.parent=t,this.boundingBox=new n.BoundingBox(this,void 0)}get MusicSystems(){return this.musicSystems}set MusicSystems(t){this.musicSystems=t}get Labels(){return this.labels}set Labels(t){this.labels=t}get Parent(){return this.parent}set Parent(t){this.parent=t}get PageNumber(){return this.pageNumber}set PageNumber(t){this.pageNumber=t}setMusicPageAbsolutePosition(t,e){return new r.PointF2D(0,0)}}var a;e.GraphicalMusicPage=o,(a=e.PagePlacementEnum||(e.PagePlacementEnum={}))[a.Down=0]="Down",a[a.Right=1]="Right",a[a.RightDown=2]="RightDown"},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.RectangleF2D=void 0;const n=i(66),s=i(4);class r{constructor(t,e,i,n){this.x=0,this.y=0,this.width=0,this.height=0,this.x=t,this.y=e,this.width=i,this.height=n}static createFromLocationAndSize(t,e){return new r(t.x,t.y,e.width,e.height)}get Location(){return new s.PointF2D(this.x,this.y)}get Size(){return new n.SizeF2D(this.width,this.height)}}e.RectangleF2D=r},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.StaffLineActivitySymbol=void 0;const n=i(6),s=i(5);class r extends n.GraphicalObject{constructor(t){super(),this.parentStaffLine=t;const e=t.PositionAndShape;this.boundingBox=new s.BoundingBox(this,e),this.boundingBox.BorderRight=6,this.boundingBox.BorderBottom=4.5,this.boundingBox.BorderLeft=-1.5,this.boundingBox.BorderTop=-1.5}}e.StaffLineActivitySymbol=r},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.ChordSymbolEnum=e.ChordDegreeText=e.CustomChord=e.Degree=e.ChordSymbolContainer=void 0;const n=i(2),s=i(17),r=i(2);e.ChordSymbolContainer=class{constructor(t,e,i,n,s){this.rootPitch=t,this.chordKind=e,this.bassPitch=i,this.degrees=n,this.rules=s}get RootPitch(){return this.rootPitch}get ChordKind(){return this.chordKind}get BassPitch(){return this.bassPitch}get ChordDegrees(){return this.degrees}static calculateChordText(t,e,i){let o=t.RootPitch;if(s.MusicSheetCalculator.transposeCalculator&&(o=s.MusicSheetCalculator.transposeCalculator.transposePitch(t.RootPitch,i,e)),t.ChordKind===l.none)return t.getTextFromChordKindEnum(t.ChordKind);let h=n.Pitch.getNoteEnumString(o.FundamentalNote);o.Accidental!==r.AccidentalEnum.NONE&&(h+=this.getTextForAccidental(o.Accidental));const c={adds:[],alts:[],subs:[]};for(const e of t.ChordDegrees)if(e){let t="";switch(e.alteration!==r.AccidentalEnum.NONE&&(t+=this.getTextForAccidental(e.alteration)),t+=e.value,e.text){case a.add:c.adds.push(t);break;case a.alter:c.alts.push(t);break;case a.subtract:c.subs.push(t)}}let u=t.getTextFromChordKindEnum(t.ChordKind);const d=["adds","alts","subs"],f=t.rules.CustomChords;for(const e of f){if(e.chordKind!==t.chordKind)continue;let i=!0;for(const t of d){for(const n of e.degrees[t]||[])if(c[t].indexOf(n)<0){i=!1;break}if(!i)break}if(i){for(const t of d)for(const i of e.degrees[t]||[])c[t].splice(c[t].indexOf(i),1);u=e.alternateName}}if(h+=u,c.adds.length>0&&(h+="("+c.adds.join(",")+")"),c.alts.length>0&&(h+="(alt "+c.alts.join(",")+")"),c.subs.length>0&&(h+="(omit "+c.subs.join(",")+")"),t.BassPitch){let r=t.BassPitch;s.MusicSheetCalculator.transposeCalculator&&(r=s.MusicSheetCalculator.transposeCalculator.transposePitch(t.BassPitch,i,e)),h+="/",h+=n.Pitch.getNoteEnumString(r.FundamentalNote),h+=this.getTextForAccidental(r.Accidental)}return h}static getTextForAccidental(t){let e="";switch(t){case r.AccidentalEnum.DOUBLEFLAT:e+="bb";break;case r.AccidentalEnum.FLAT:e+="b";break;case r.AccidentalEnum.SHARP:e+="#";break;case r.AccidentalEnum.DOUBLESHARP:e+="x"}return e}getTextFromChordKindEnum(t){var e;return null!==(e=this.rules.ChordSymbolLabelTexts.getValue(t))&&void 0!==e?e:""}},e.Degree=class{constructor(t,e,i){this.value=t,this.alteration=e,this.text=i}};class o{constructor(t,e,i){this.alternateName=t,this.chordKind=e,this.degrees=i}static createCustomChord(t,e,i){return new o(t,e,i)}static renameCustomChord(t,e,i){for(const n of i)n.alternateName===t&&(n.alternateName=e)}}var a,l,h;e.CustomChord=o,(h=a=e.ChordDegreeText||(e.ChordDegreeText={}))[h.add=0]="add",h[h.alter=1]="alter",h[h.subtract=2]="subtract",function(t){t[t.major=0]="major",t[t.minor=1]="minor",t[t.augmented=2]="augmented",t[t.diminished=3]="diminished",t[t.dominant=4]="dominant",t[t.majorseventh=5]="majorseventh",t[t.minorseventh=6]="minorseventh",t[t.diminishedseventh=7]="diminishedseventh",t[t.augmentedseventh=8]="augmentedseventh",t[t.halfdiminished=9]="halfdiminished",t[t.majorminor=10]="majorminor",t[t.majorsixth=11]="majorsixth",t[t.minorsixth=12]="minorsixth",t[t.dominantninth=13]="dominantninth",t[t.majorninth=14]="majorninth",t[t.minorninth=15]="minorninth",t[t.dominant11th=16]="dominant11th",t[t.major11th=17]="major11th",t[t.minor11th=18]="minor11th",t[t.dominant13th=19]="dominant13th",t[t.major13th=20]="major13th",t[t.minor13th=21]="minor13th",t[t.suspendedsecond=22]="suspendedsecond",t[t.suspendedfourth=23]="suspendedfourth",t[t.Neapolitan=24]="Neapolitan",t[t.Italian=25]="Italian",t[t.French=26]="French",t[t.German=27]="German",t[t.pedal=28]="pedal",t[t.power=29]="power",t[t.Tristan=30]="Tristan",t[t.none=31]="none"}(l=e.ChordSymbolEnum||(e.ChordSymbolEnum={}))},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.AbstractNotationInstruction=void 0,e.AbstractNotationInstruction=class{constructor(t){this.printObject=!0,this.parent=t}get Parent(){return this.parent}set Parent(t){this.parent=t}get PrintObject(){return this.printObject}set PrintObject(t){this.printObject=t}}},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.OrnamentEnum=e.OrnamentContainer=void 0;const n=i(2),s=i(3);var r;e.OrnamentContainer=class{constructor(t){this.placement=s.PlacementEnum.Above,this.accidentalAbove=n.AccidentalEnum.NONE,this.accidentalBelow=n.AccidentalEnum.NONE,this.ornament=t}get GetOrnament(){return this.ornament}get AccidentalAbove(){return this.accidentalAbove}set AccidentalAbove(t){this.accidentalAbove=t}get AccidentalBelow(){return this.accidentalBelow}set AccidentalBelow(t){this.accidentalBelow=t}},(r=e.OrnamentEnum||(e.OrnamentEnum={}))[r.Trill=0]="Trill",r[r.Turn=1]="Turn",r[r.InvertedTurn=2]="InvertedTurn",r[r.DelayedTurn=3]="DelayedTurn",r[r.DelayedInvertedTurn=4]="DelayedInvertedTurn",r[r.Mordent=5]="Mordent",r[r.InvertedMordent=6]="InvertedMordent"},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.Voice=void 0,e.Voice=class{constructor(t,e){this.voiceEntries=[],this.volume=1,this.parent=t,this.visible=!0,this.audible=!0,this.following=!0,this.voiceId=e}get VoiceEntries(){return this.voiceEntries}get Parent(){return this.parent}get Visible(){return this.visible}set Visible(t){this.visible=t}get Audible(){return this.audible}set Audible(t){this.audible=t}get Following(){return this.following}set Following(t){this.following=t}get VoiceId(){return this.voiceId}get Volume(){return this.volume}set Volume(t){this.volume=t}}},function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalContinuousDynamicExpression=void 0;const s=i(27),r=i(32),o=i(4),a=i(42),l=i(3),h=n(i(1));class c extends a.AbstractGraphicalExpression{constructor(t,e,i){super(e,t,i),this.lines=[],this.isSplittedPart=!1,this.notToBeRemoved=!1}get StartMeasure(){return this.startMeasure}set StartMeasure(t){this.startMeasure=t}get EndMeasure(){return this.endMeasure}set EndMeasure(t){this.endMeasure=t}get EndStaffLine(){return this.endMeasure?this.endMeasure.ParentStaffLine:void 0}get IsSplittedPart(){return this.isSplittedPart}set IsSplittedPart(t){this.isSplittedPart=t}get IsVerbal(){return this.ContinuousDynamic.Label&&this.ContinuousDynamic.Label.length>0}get NotToBeRemoved(){return this.notToBeRemoved}set NotToBeRemoved(t){this.notToBeRemoved=t}get Lines(){return this.lines}get ContinuousDynamic(){return this.SourceExpression}updateSkyBottomLine(){var t;const e=this.parentStaffLine.SkyBottomLineCalculator,i=this.IsVerbal?this.label.PositionAndShape.RelativePosition.x+this.label.PositionAndShape.BorderMarginLeft:0,n=this.IsVerbal?this.label.PositionAndShape.RelativePosition.x+this.label.PositionAndShape.BorderMarginRight:0;switch(!this.IsVerbal&&this.lines.length<2&&h.default.warn("Not enough lines for SkyBottomLine calculation"),this.IsVerbal||this.ContinuousDynamic.DynamicType!==r.ContDynamicEnum.crescendo&&this.ContinuousDynamic.DynamicType!==r.ContDynamicEnum.diminuendo&&h.default.warn("GraphicalContinuousDynamicExpression.updateSkyBottomLine(): unhandled continuous dynamic type. start measure: "+(null===(t=this.startMeasure)||void 0===t?void 0:t.MeasureNumber)),this.Placement){case l.PlacementEnum.Above:if(this.IsVerbal){const t=this.label.PositionAndShape.BorderMarginTop+this.label.PositionAndShape.RelativePosition.y;e.updateSkyLineInRange(i,n,t)}else this.ContinuousDynamic.DynamicType===r.ContDynamicEnum.crescendo?e.updateSkyLineWithWedge(this.lines[0].Start,this.lines[0].End):this.ContinuousDynamic.DynamicType===r.ContDynamicEnum.diminuendo&&e.updateSkyLineWithWedge(this.lines[0].End,this.lines[0].Start);break;case l.PlacementEnum.Below:if(this.IsVerbal){const t=this.label.PositionAndShape.BorderMarginBottom+this.label.PositionAndShape.RelativePosition.y;e.updateBottomLineInRange(i,n,t)}else this.ContinuousDynamic.DynamicType===r.ContDynamicEnum.crescendo?e.updateBottomLineWithWedge(this.lines[1].Start,this.lines[1].End):this.ContinuousDynamic.DynamicType===r.ContDynamicEnum.diminuendo&&e.updateBottomLineWithWedge(this.lines[1].End,this.lines[1].Start);break;default:h.default.error("Placement for GraphicalContinuousDynamicExpression is unknown")}}createCrescendoLines(t,e,i,n=this.rules.WedgeOpeningLength,s=this.rules.WedgeLineWidth){const r=new o.PointF2D(t,i),a=new o.PointF2D(e,i-n/2),l=new o.PointF2D(e,i+n/2);this.addWedgeLines(r,a,l,s)}createFirstHalfCrescendoLines(t,e,i,n=this.rules.WedgeMeasureEndOpeningLength,s=this.rules.WedgeLineWidth){const r=new o.PointF2D(t,i),a=new o.PointF2D(e,i-n/2),l=new o.PointF2D(e,i+n/2);this.addWedgeLines(r,a,l,s)}createSecondHalfCrescendoLines(t,e,i,n=this.rules.WedgeMeasureBeginOpeningLength,s=this.rules.WedgeOpeningLength,r=this.rules.WedgeLineWidth){const a=new o.PointF2D(t,i-n/2),l=new o.PointF2D(t,i+n/2),h=new o.PointF2D(e,i-s/2),c=new o.PointF2D(e,i+s/2);this.addDoubleLines(a,h,l,c,r)}recalculateCrescendoLines(t,e,i){const n=Math.abs(this.lines[0].Start.y-this.lines[1].Start.y)>1e-4;this.lines.clear(),n?this.createSecondHalfCrescendoLines(t,e,i):this.isSplittedPart?this.createFirstHalfCrescendoLines(t,e,i):this.createCrescendoLines(t,e,i)}createDiminuendoLines(t,e,i,n=this.rules.WedgeOpeningLength,s=this.rules.WedgeLineWidth){const r=new o.PointF2D(t,i-n/2),a=new o.PointF2D(t,i+n/2),l=new o.PointF2D(e,i);this.addWedgeLines(l,r,a,s)}createFirstHalfDiminuendoLines(t,e,i,n=this.rules.WedgeOpeningLength,s=this.rules.WedgeMeasureEndOpeningLength,r=this.rules.WedgeLineWidth){const a=new o.PointF2D(t,i-n/2),l=new o.PointF2D(t,i+n/2),h=new o.PointF2D(e,i-s/2),c=new o.PointF2D(e,i+s/2);this.addDoubleLines(a,h,l,c,r)}createSecondHalfDiminuendoLines(t,e,i,n=this.rules.WedgeMeasureBeginOpeningLength,s=this.rules.WedgeLineWidth){const r=new o.PointF2D(t,i-n/2),a=new o.PointF2D(t,i+n/2),l=new o.PointF2D(e,i);this.addWedgeLines(l,r,a,s)}recalculateDiminuendoLines(t,e,i){const n=Math.abs(this.lines[0].End.y-this.lines[1].End.y)>1e-4;this.lines.clear(),n?this.createFirstHalfDiminuendoLines(t,e,i):this.isSplittedPart?this.createSecondHalfDiminuendoLines(t,e,i):this.createDiminuendoLines(t,e,i)}calcPsi(){this.IsVerbal?this.PositionAndShape.calculateBoundingBox():(this.PositionAndShape.RelativePosition=this.lines[0].Start,this.PositionAndShape.BorderMarginTop=this.lines[0].End.y-this.lines[0].Start.y,this.PositionAndShape.BorderMarginBottom=this.lines[1].End.y-this.lines[1].Start.y,this.PositionAndShape.Center.y=(this.PositionAndShape.BorderMarginTop+this.PositionAndShape.BorderMarginBottom)/2,this.ContinuousDynamic.DynamicType===r.ContDynamicEnum.crescendo?(this.PositionAndShape.BorderMarginLeft=0,this.PositionAndShape.BorderMarginRight=this.lines[0].End.x-this.lines[0].Start.x):(this.PositionAndShape.BorderMarginLeft=this.lines[0].End.x-this.lines[0].Start.x,this.PositionAndShape.BorderMarginRight=0))}cleanUp(){this.lines.clear()}shiftYPosition(t){this.IsVerbal?(this.PositionAndShape.RelativePosition.y+=t,this.PositionAndShape.calculateBoundingBox()):(this.lines[0].Start.y+=t,this.lines[0].End.y+=t,this.lines[1].End.y+=t)}squeeze(t){this.IsVerbal||Math.abs(this.lines[0].End.x-this.lines[0].Start.x)0?this.lines[0].Start.x+=t:(this.lines[0].End.x+=t,this.lines[1].End.x+=t):t<0?this.lines[0].Start.x+=t:(this.lines[0].End.x+=t,this.lines[1].End.x+=t),this.calcPsi())}addWedgeLines(t,e,i,n){const r=new s.GraphicalLine(t,e,n),o=new s.GraphicalLine(t,i,n);this.lines.push(r),this.lines.push(o)}addDoubleLines(t,e,i,n,r){const o=new s.GraphicalLine(t,e,r),a=new s.GraphicalLine(i,n,r);this.lines.push(o),this.lines.push(a)}}e.GraphicalContinuousDynamicExpression=c},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0});var n=i(10),s=i(35),r=function(){function t(){this.firstNode=null,this.lastNode=null,this.nElements=0}return t.prototype.add=function(t,e){if(n.isUndefined(e)&&(e=this.nElements),e<0||e>this.nElements||n.isUndefined(t))return!1;var i=this.createNode(t);if(0===this.nElements||null===this.lastNode)this.firstNode=i,this.lastNode=i;else if(e===this.nElements)this.lastNode.next=i,this.lastNode=i;else if(0===e)i.next=this.firstNode,this.firstNode=i;else{var s=this.nodeAtIndex(e-1);if(null===s)return!1;i.next=s.next,s.next=i}return this.nElements++,!0},t.prototype.first=function(){if(null!==this.firstNode)return this.firstNode.element},t.prototype.last=function(){if(null!==this.lastNode)return this.lastNode.element},t.prototype.elementAtIndex=function(t){var e=this.nodeAtIndex(t);if(null!==e)return e.element},t.prototype.indexOf=function(t,e){var i=e||n.defaultEquals;if(n.isUndefined(t))return-1;for(var s=this.firstNode,r=0;null!==s;){if(i(s.element,t))return r;r++,s=s.next}return-1},t.prototype.contains=function(t,e){return this.indexOf(t,e)>=0},t.prototype.remove=function(t,e){var i=e||n.defaultEquals;if(this.nElements<1||n.isUndefined(t))return!1;for(var s=null,r=this.firstNode;null!==r;){if(i(r.element,t))return null===s?(this.firstNode=r.next,r===this.lastNode&&(this.lastNode=null)):r===this.lastNode?(this.lastNode=s,s.next=r.next,r.next=null):(s.next=r.next,r.next=null),this.nElements--,!0;s=r,r=r.next}return!1},t.prototype.clear=function(){this.firstNode=null,this.lastNode=null,this.nElements=0},t.prototype.equals=function(e,i){var s=i||n.defaultEquals;return e instanceof t&&this.size()===e.size()&&this.equalsAux(this.firstNode,e.firstNode,s)},t.prototype.equalsAux=function(t,e,i){for(;null!==t&&null!==e;){if(!i(t.element,e.element))return!1;t=t.next,e=e.next}return!0},t.prototype.removeElementAtIndex=function(t){if(!(t<0||t>=this.nElements||null===this.firstNode||null===this.lastNode)){var e;if(1===this.nElements)e=this.firstNode.element,this.firstNode=null,this.lastNode=null;else{var i=this.nodeAtIndex(t-1);null===i?(e=this.firstNode.element,this.firstNode=this.firstNode.next):i.next===this.lastNode&&(e=this.lastNode.element,this.lastNode=i),null!==i&&null!==i.next&&(e=i.next.element,i.next=i.next.next)}return this.nElements--,e}},t.prototype.forEach=function(t){for(var e=this.firstNode;null!==e&&!1!==t(e.element);)e=e.next},t.prototype.reverse=function(){for(var t=null,e=this.firstNode,i=null;null!==e;)i=e.next,e.next=t,t=e,e=i;i=this.firstNode,this.firstNode=this.lastNode,this.lastNode=i},t.prototype.toArray=function(){for(var t=[],e=this.firstNode;null!==e;)t.push(e.element),e=e.next;return t},t.prototype.size=function(){return this.nElements},t.prototype.isEmpty=function(){return this.nElements<=0},t.prototype.toString=function(){return s.toString(this.toArray())},t.prototype.nodeAtIndex=function(t){if(t<0||t>=this.nElements)return null;if(t===this.nElements-1)return this.lastNode;for(var e=this.firstNode,i=0;i=o.allargando&&t<=o.ritenuto}get TempoType(){return this.tempoType}set TempoType(t){this.tempoType=t}get StartTempo(){return this.startTempo}set StartTempo(t){this.startTempo=t}get EndTempo(){return this.endTempo}set EndTempo(t){this.endTempo=t}get AbsoluteEndTimestamp(){return this.absoluteEndTimestamp}set AbsoluteEndTimestamp(t){this.absoluteEndTimestamp=t}get AbsoluteTimestamp(){return this.ParentMultiTempoExpression.AbsoluteTimestamp}getAbsoluteFloatTimestamp(){return this.ParentMultiTempoExpression.AbsoluteTimestamp.RealValue}getInterpolatedTempo(t){const e=n.Fraction.plus(this.parentMultiTempoExpression.SourceMeasureParent.AbsoluteTimestamp,this.parentMultiTempoExpression.Timestamp);if(t.lt(e))return-1;if(this.absoluteEndTimestamp.lt(t))return-2;const i=n.Fraction.minus(t,e).RealValue/n.Fraction.minus(this.absoluteEndTimestamp,e).RealValue;return Math.max(0,Math.min(250,this.startTempo+(this.endTempo-this.startTempo)*i))}setTempoType(){r.isStringInStringList(r.listContinuousTempoFaster,this.label)?this.tempoType=o.accelerando:r.isStringInStringList(r.listContinuousTempoSlower,this.label)&&(this.tempoType=o.ritardando)}}var o,a;e.ContinuousTempoExpression=r,r.listContinuousTempoFaster=["accelerando","piu mosso","poco piu","stretto"],r.listContinuousTempoSlower=["poco meno","meno mosso","piu lento","calando","allargando","rallentando","ritardando","ritenuto","ritard.","ritard","rit.","rit","riten.","riten"],(a=o=e.ContinuousTempoType||(e.ContinuousTempoType={}))[a.accelerando=0]="accelerando",a[a.stretto=1]="stretto",a[a.stringendo=2]="stringendo",a[a.mosso=3]="mosso",a[a.piuMosso=4]="piuMosso",a[a.allargando=5]="allargando",a[a.calando=6]="calando",a[a.menoMosso=7]="menoMosso",a[a.rallentando=8]="rallentando",a[a.ritardando=9]="ritardando",a[a.ritard=10]="ritard",a[a.rit=11]="rit",a[a.ritenuto=12]="ritenuto",a[a.rubato=13]="rubato",a[a.precipitando=14]="precipitando"},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowContinuousDynamicExpression=void 0;const n=i(52),s=i(24),r=i(12),o=i(9),a=i(21);class l extends n.GraphicalContinuousDynamicExpression{constructor(t,e,i,n){if(super(t,e,i),this.IsVerbal){const e=new r.Label(t.Label);this.label=new s.GraphicalLabel(e,n||this.rules.ContinuousDynamicTextHeight,o.TextAlignmentEnum.LeftCenter,this.rules,this.PositionAndShape),this.label.Label.fontStyle=a.FontStyles.Italic,this.label.setLabelPositionAndShapeBorders(),this.PositionAndShape.calculateBoundingBox()}}}e.VexFlowContinuousDynamicExpression=l},function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.CanvasVexFlowBackend=void 0;const s=n(i(8)),r=i(59),o=i(13),a=i(25),l=i(45);class h extends r.VexFlowBackend{constructor(t){super(),this.rules=t}getVexflowBackendType(){return s.default.Flow.Renderer.Backends.CANVAS}getOSMDBackendType(){return a.BackendType.Canvas}getCanvasSize(){var t;return null===(t=document.getElementById("osmdCanvasPage"+this.graphicalMusicPage.PageNumber))||void 0===t?void 0:t.offsetHeight}initialize(t,e){this.zoom=e,this.canvas=document.createElement("canvas"),this.graphicalMusicPage||(this.graphicalMusicPage=new l.GraphicalMusicPage(void 0),this.graphicalMusicPage.PageNumber=1),this.canvas.id="osmdCanvasVexFlowBackendCanvas"+this.graphicalMusicPage.PageNumber,this.inner=document.createElement("div"),this.inner.id="osmdCanvasPage"+this.graphicalMusicPage.PageNumber,this.inner.style.position="relative",this.canvas.style.zIndex="0",this.inner.appendChild(this.canvas),t.appendChild(this.inner),this.renderer=new s.default.Flow.Renderer(this.canvas,this.getVexflowBackendType()),this.ctx=this.renderer.getContext()}initializeHeadless(t=300,e=300){this.graphicalMusicPage||(this.graphicalMusicPage=new l.GraphicalMusicPage(void 0),this.graphicalMusicPage.PageNumber=1),this.canvas=document.createElement("canvas"),this.canvas.width=t,this.canvas.height=e,this.renderer=new s.default.Flow.Renderer(this.canvas,this.getVexflowBackendType()),this.ctx=this.renderer.getContext()}getContext(){return this.ctx}clear(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.rules.PageBackgroundColor&&(this.ctx.save(),this.ctx.setFillStyle(this.rules.PageBackgroundColor),this.zoom=1,this.ctx.fillRect(0,0,this.canvas.width/this.zoom,this.canvas.height/this.zoom),this.ctx.restore())}scale(t){this.ctx.scale(t,t)}translate(t,e){this.CanvasRenderingCtx.translate(t,e)}renderText(t,e,i,n,s,r,a,l){const h=this.CanvasRenderingCtx.font;this.CanvasRenderingCtx.save(),this.CanvasRenderingCtx.font=o.VexFlowConverter.font(t,e,i,this.rules,l),this.CanvasRenderingCtx.fillStyle=a,this.CanvasRenderingCtx.strokeStyle=a,this.CanvasRenderingCtx.fillText(n,r.x,r.y+s),this.CanvasRenderingCtx.restore(),this.CanvasRenderingCtx.font=h}renderRectangle(t,e,i,n=1){const s=this.CanvasRenderingCtx.fillStyle;this.CanvasRenderingCtx.fillStyle=i||o.VexFlowConverter.style(e),this.CanvasRenderingCtx.globalAlpha=n,this.ctx.fillRect(t.x,t.y,t.width,t.height),this.CanvasRenderingCtx.fillStyle=s,this.CanvasRenderingCtx.globalAlpha=1}renderLine(t,e,i="#FF0000FF",n=2){const s=this.CanvasRenderingCtx.strokeStyle;this.CanvasRenderingCtx.strokeStyle=i,this.CanvasRenderingCtx.beginPath(),this.CanvasRenderingCtx.moveTo(t.x,t.y),this.CanvasRenderingCtx.lineTo(e.x,e.y),this.CanvasRenderingCtx.stroke(),this.CanvasRenderingCtx.strokeStyle=s}renderCurve(t){this.ctx.beginPath(),this.ctx.moveTo(t[0].x,t[0].y),this.ctx.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y),this.ctx.lineTo(t[7].x,t[7].y),this.ctx.bezierCurveTo(t[6].x,t[6].y,t[5].x,t[5].y,t[4].x,t[4].y),this.ctx.lineTo(t[0].x,t[0].y),this.ctx.closePath(),this.ctx.fill()}get CanvasRenderingCtx(){return this.ctx.vexFlowCanvasContext}}e.CanvasVexFlowBackend=h},function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowBackend=e.VexFlowBackends=void 0;const s=n(i(8));e.VexFlowBackends=class{},e.VexFlowBackend=class{getInnerElement(){return this.inner}getCanvas(){return this.canvas}getRenderElement(){let t=this.canvas;return this.getVexflowBackendType()===s.default.Flow.Renderer.Backends.CANVAS&&(t=this.inner),t}getRenderer(){return this.renderer}removeAllChildrenFromContainer(t){for(;0!==t.children.length;)t.removeChild(t.children.item(0))}removeFromContainer(t){const e=this.getRenderElement();for(let i=0;ithis.vfnoteIndex&&i[this.vfnoteIndex]?e.note_heads[this.vfnoteIndex]:{line:0}}Clef(){return this.clef}getSVGId(){return this.vfnote[0].getAttribute("id")}getSVGGElement(){return this.vfnote[0].getAttribute("el")}}e.VexFlowGraphicalNote=o},function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowInstrumentBracket=void 0;const s=n(i(8)),r=i(6),o=i(5),a=i(16);class l extends r.GraphicalObject{constructor(t,e,i=0){super(),this.PositionAndShape=new o.BoundingBox(this,t.ParentMusicSystem.PositionAndShape);const n=t.Measures[0],r=e.Measures[0];this.addConnector(n.getVFStave(),r.getVFStave(),s.default.Flow.StaveConnector.type.BRACKET,i)}draw(t){this.vexflowConnector.setContext(t).draw();const e=this.vexflowConnector,i=e.top_stave.getYForLine(0),n=e.bottom_stave.getYForLine(e.bottom_stave.getNumLines()-1)+e.thickness;this.PositionAndShape.AbsolutePosition.x=(e.top_stave.getX()-2+e.x_shift)/a.unitInPixels,this.PositionAndShape.AbsolutePosition.y=i/a.unitInPixels,this.PositionAndShape.Size.height=(n-i)/a.unitInPixels,this.PositionAndShape.Size.width=12/a.unitInPixels}addConnector(t,e,i,n){this.vexflowConnector=new s.default.Flow.StaveConnector(t,e).setType(i).setXShift(-5*n)}}e.VexFlowInstrumentBracket=l},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowVoiceEntry=void 0;const n=i(69),s=i(16),r=i(33);class o extends n.GraphicalVoiceEntry{constructor(t,e){super(t,e)}applyBordersFromVexflow(){const t=this.vfStaveNote;if(!t.getNoteHeadBeginX)return;const e=t.getBoundingBox(),i=t.getNoteHeadBeginX()-e.x;this.PositionAndShape.RelativePosition.y=e.y/s.unitInPixels,this.PositionAndShape.BorderTop=0,this.PositionAndShape.BorderBottom=e.h/s.unitInPixels,this.PositionAndShape.BorderLeft=-(i+t.width/2)/s.unitInPixels,this.PositionAndShape.BorderRight=(e.w-i)/s.unitInPixels}set vfStaveNote(t){this.mVexFlowStaveNote=t}get vfStaveNote(){return this.mVexFlowStaveNote}color(){var t;const e=this.rules.DefaultColorNotehead,i=this.rules.DefaultColorRest,n=this.rules.DefaultColorStem;let s,o;const a=this.vfStaveNote;for(let n=0;n=0;i--){const t=this.measureList[i][e];if(t)return t}}findGraphicalStaffEntryFromMeasureList(t,e,i){for(let n=e;n0)return i.staffEntries[0]}}getFirstVisibleMeasuresListFromIndices(t,e){const i=[],n=this.measureList[0].length;for(let s=t;s<=e;s++)for(let t=0;t=0;e--){if(this.verticalGraphicalStaffEntryContainers[e].AbsoluteTimestamp.lt(t)){const i=new s.VerticalGraphicalStaffEntryContainer(this.numberOfStaves,t);return this.verticalGraphicalStaffEntryContainers.splice(e+1,0,i),i}if(this.verticalGraphicalStaffEntryContainers[e].AbsoluteTimestamp.Equals(t))return this.verticalGraphicalStaffEntryContainers[e]}}GetVerticalContainerFromTimestamp(t,e=0){const i=d.CollectionUtil.binarySearch(this.verticalGraphicalStaffEntryContainers,new s.VerticalGraphicalStaffEntryContainer(0,t),s.VerticalGraphicalStaffEntryContainer.compareByTimestamp,e);if(i>=0)return this.verticalGraphicalStaffEntryContainers[i]}GetInterpolatedIndexInVerticalContainers(t){const e=this.verticalGraphicalStaffEntryContainers;let i,n,s=0,r=e.length-1;if(t.lte(e[e.length-1].AbsoluteTimestamp)){for(;r-s>1;){const i=Math.floor((r+s)/2);if(e[s].AbsoluteTimestamp.Equals(t)){r=s;break}if(e[r].AbsoluteTimestamp.Equals(t)){s=r;break}if(e[i].AbsoluteTimestamp.Equals(t))return this.verticalGraphicalStaffEntryContainers.indexOf(e[i]);t.lt(e[i].AbsoluteTimestamp)?r=i:s=i}if(s===r)return this.verticalGraphicalStaffEntryContainers.indexOf(e[s]);i=e[s].AbsoluteTimestamp,n=e[r].AbsoluteTimestamp}else i=e[e.length-1].AbsoluteTimestamp,n=h.Fraction.plus(this.getLongestStaffEntryDuration(e.length-1),i),r=e.length;const o=n.RealValue-i.RealValue,a=r-(n.RealValue-t.RealValue)/o;return Math.min(a,this.verticalGraphicalStaffEntryContainers.length)}getVisibleStavesIndicesFromSourceMeasure(t){const e=[],i=[];for(let i=0,n=t.length;ivoid 0!==t.parentStaffEntry.relInMeasureTimestamp))}GetNearestNote(t,e){const i=this.GetNearestVoiceEntry(t);if(!i)return;let n,s=Number.MAX_SAFE_INTEGER;for(const e of i.notes){const i=e.PositionAndShape.AbsolutePosition.y,r=Math.abs(e.PositionAndShape.AbsolutePosition.x-t.x),o=Math.abs(i-t.y);r+on.PositionAndShape.RelativePosition.x&&(i=n):i=n)}}catch(t){u.default.info("GraphicalMusicSheet.getStaffEntry",t)}return i}GetPreviousVisibleContainerIndex(t){for(let e=t-1;e>=0;e--){const t=this.verticalGraphicalStaffEntryContainers[e].StaffEntries;for(let i=0,n=t.length;i=0;t--)if(i=this.getStaffEntry(t),i){if(!e)return i;if(i.sourceStaffEntry.ParentStaff.ParentInstrument.Visible)return i}}findClosestRightStaffEntry(t,e){let i;for(let n=Math.max(0,Math.ceil(t));ne.sourceNote.Pitch.getHalfTone()-t.sourceNote.Pitch.getHalfTone())),this.notes}sortForVexflow(){return this.notes.sort(((t,e)=>t.sourceNote.Pitch.getHalfTone()-e.sourceNote.Pitch.getHalfTone())),this.notes}color(){}}e.GraphicalVoiceEntry=o},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalInstantaneousTempoExpression=void 0;const n=i(42);class s extends n.AbstractGraphicalExpression{constructor(t,e){super(e.PositionAndShape.Parent.DataObject,t,t.parentMeasure),this.label=e}get GraphicalLabel(){return this.label}updateSkyBottomLine(){}}e.GraphicalInstantaneousTempoExpression=s},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalNote=void 0;const n=i(2),s=i(6),r=i(17),o=i(5);class a extends s.GraphicalObject{constructor(t,e,i,s){super(),this.DrawnAccidental=n.AccidentalEnum.NONE,this.sourceNote=t,this.parentVoiceEntry=e,this.PositionAndShape=new o.BoundingBox(this,e.PositionAndShape),this.graphicalNoteLength=s||t.Length,this.numberOfDots=this.calculateNumberOfNeededDots(this.graphicalNoteLength),this.rules=i,this.rules.addGraphicalNoteToNoteMap(t,this)}Transpose(t,e,i,n){let s=this.sourceNote.Pitch;return r.MusicSheetCalculator.transposeCalculator&&(s=r.MusicSheetCalculator.transposeCalculator.transposePitch(this.sourceNote.Pitch,t,i)),s}calculateNumberOfNeededDots(t){let e=1,i=2;const n=t.GetExpandedNumerator();if(!this.sourceNote||!this.sourceNote.NoteTuplet)for(;i0&&this.Voices[0].Visible}set Visible(t){for(let e=0,i=this.Voices.length;e2:(s.default.warn("notehead: sourceNote and filledXmlAttribute undefined."),i=!0)),this.filled=i}get SourceNote(){return this.sourceNote}get Shape(){return this.shape}get Filled(){return this.filled}static ShapeTypeXmlToShape(t){switch(t.toLowerCase()){case"normal":return o.NORMAL;case"x":return o.X;case"slash":return o.SLASH;case"diamond":return o.DIAMOND;case"square":case"la":return o.SQUARE;case"do":case"triangle":return o.TRIANGLE;case"rectangle":return o.RECTANGLE;case"circle-x":return o.CIRCLEX;default:return s.default.info("unsupported/unhandled xml notehead '"+t+"'. Using normal notehead."),o.NORMAL}}}var o,a;e.Notehead=r,(a=o=e.NoteHeadShape||(e.NoteHeadShape={}))[a.CIRCLEX=0]="CIRCLEX",a[a.DIAMOND=1]="DIAMOND",a[a.NORMAL=2]="NORMAL",a[a.RECTANGLE=3]="RECTANGLE",a[a.SLASH=4]="SLASH",a[a.SQUARE=5]="SQUARE",a[a.TRIANGLE=6]="TRIANGLE",a[a.X=7]="X"},function(t,e,i){var n;Object.defineProperty(e,"__esModule",{value:!0}),e.MusicSymbol=void 0,(n=e.MusicSymbol||(e.MusicSymbol={}))[n.Unused_first_Symbol=0]="Unused_first_Symbol",n[n.BLACK_HEAD=1]="BLACK_HEAD",n[n.UPWARDS_TAIL=2]="UPWARDS_TAIL",n[n.DOWNWARDS_TAIL=3]="DOWNWARDS_TAIL",n[n.UPWARDS_DOUBLE_TAIL=4]="UPWARDS_DOUBLE_TAIL",n[n.DOWNWARDS_DOUBLE_TAIL=5]="DOWNWARDS_DOUBLE_TAIL",n[n.UPWARDS_TRIPLE_TAIL=6]="UPWARDS_TRIPLE_TAIL",n[n.DOWNWARDS_TRIPLE_TAIL=7]="DOWNWARDS_TRIPLE_TAIL",n[n.UPWARDS_QUAD_TAIL=8]="UPWARDS_QUAD_TAIL",n[n.DOWNWARDS_QUAD_TAIL=9]="DOWNWARDS_QUAD_TAIL",n[n.ROUND_HEAD=10]="ROUND_HEAD",n[n.WHITE_HEAD=11]="WHITE_HEAD",n[n.G_CLEF=12]="G_CLEF",n[n.F_CLEF=13]="F_CLEF",n[n.C_CLEF=14]="C_CLEF",n[n.BREVE=15]="BREVE",n[n.BREVE_REST=16]="BREVE_REST",n[n.COMMON_TIME=17]="COMMON_TIME",n[n.CUT_TIME=18]="CUT_TIME",n[n.WHOLE_REST=19]="WHOLE_REST",n[n.HALF_REST=20]="HALF_REST",n[n.QUARTER_REST=21]="QUARTER_REST",n[n.EIGHTH_REST=22]="EIGHTH_REST",n[n.SIXTEENTH_REST=23]="SIXTEENTH_REST",n[n.THIRTYSECOND_REST=24]="THIRTYSECOND_REST",n[n.SIXTYFOURTH_REST=25]="SIXTYFOURTH_REST",n[n.FLAT=26]="FLAT",n[n.SHARP=27]="SHARP",n[n.NATURAL=28]="NATURAL",n[n.DOUBLE_FLAT=29]="DOUBLE_FLAT",n[n.DOUBLE_SHARP=30]="DOUBLE_SHARP",n[n.ZERO=31]="ZERO",n[n.ONE=32]="ONE",n[n.TWO=33]="TWO",n[n.THREE=34]="THREE",n[n.FOUR=35]="FOUR",n[n.FIVE=36]="FIVE",n[n.SIX=37]="SIX",n[n.SEVEN=38]="SEVEN",n[n.EIGHT=39]="EIGHT",n[n.NINE=40]="NINE",n[n.DOT=41]="DOT",n[n.FERMATA=42]="FERMATA",n[n.INVERTED_FERMATA=43]="INVERTED_FERMATA",n[n.SPICCATO=44]="SPICCATO",n[n.TENUTO=45]="TENUTO",n[n.MARCATO=46]="MARCATO",n[n.MARCATISSIMO=47]="MARCATISSIMO",n[n.INVERTED_MARCATISSIMO=48]="INVERTED_MARCATISSIMO",n[n.P=49]="P",n[n.F=50]="F",n[n.S=51]="S",n[n.Z=52]="Z",n[n.M=53]="M",n[n.R=54]="R",n[n.SEGNO=55]="SEGNO",n[n.CODA=56]="CODA",n[n.DRUM_CLEF=57]="DRUM_CLEF",n[n.G_CLEF_SUB8=58]="G_CLEF_SUB8",n[n.G_CLEF_SUPER8=59]="G_CLEF_SUPER8",n[n.G_CLEF_SUB15=60]="G_CLEF_SUB15",n[n.G_CLEF_SUPER15=61]="G_CLEF_SUPER15",n[n.F_CLEF_SUB8=62]="F_CLEF_SUB8",n[n.F_CLEF_SUPER8=63]="F_CLEF_SUPER8",n[n.F_CLEF_SUB15=64]="F_CLEF_SUB15",n[n.F_CLEF_SUPER15=65]="F_CLEF_SUPER15",n[n.DOWN_BOW=66]="DOWN_BOW",n[n.MORDENT=67]="MORDENT",n[n.INVERTED_MORDENT=68]="INVERTED_MORDENT",n[n.TURN=69]="TURN",n[n.INVERTED_TURN=70]="INVERTED_TURN",n[n.LEFTHAND_PIZZICATO=71]="LEFTHAND_PIZZICATO",n[n.RELEASE_PED=72]="RELEASE_PED",n[n.ENGAGE_PED=73]="ENGAGE_PED",n[n.VA8=74]="VA8",n[n.VB8=75]="VB8",n[n.TRILL=76]="TRILL",n[n.MA15=77]="MA15",n[n.MB15=78]="MB15",n[n.HIGH=79]="HIGH",n[n.PLAY=80]="PLAY",n[n.MIC=81]="MIC",n[n.SNAP_PIZZICATO=82]="SNAP_PIZZICATO",n[n.NATURAL_HARMONIC=83]="NATURAL_HARMONIC",n[n.EditPen=84]="EditPen"},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.AlignmentManager=void 0;const n=i(57),s=i(4);e.AlignmentManager=class{constructor(t){this.parentStaffline=t,this.rules=this.parentStaffline.ParentMusicSystem.rules}alignDynamicExpressions(){var t,e;const i=[];let s=new Array;for(let n=0;n0){const e=t.map((t=>t.PositionAndShape.Center.y)),i=Math.max(...e);for(let s=0;s0?t[s-1]:void 0;if(e){const t=this.getOverlap(r.PositionAndShape,e.PositionAndShape);r.squeeze(-(t.x+this.rules.DynamicExpressionSpacer))}if(i){const t=this.getOverlap(i.PositionAndShape,r.PositionAndShape);r.squeeze(t.x+this.rules.DynamicExpressionSpacer)}}}}}getDistance(t,e){const i=t.RelativePosition.x+t.BorderMarginRight,n=e.RelativePosition.x+e.BorderMarginLeft,r=t.RelativePosition.y+t.BorderMarginBottom,o=e.RelativePosition.y+e.BorderMarginTop;return new s.PointF2D(n-i,o-r)}getOverlap(t,e){return new s.PointF2D(t.RelativePosition.x+t.BorderMarginRight-(e.RelativePosition.x+e.BorderMarginLeft),t.RelativePosition.y+t.BorderMarginBottom-(e.RelativePosition.y+e.BorderMarginTop))}}},function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalInstantaneousDynamicExpression=void 0;const s=i(42),r=i(3),o=n(i(1));class a extends s.AbstractGraphicalExpression{constructor(t,e,i){super(e,t,i.parentSourceMeasure),this.mInstantaneousDynamicExpression=t,this.mMeasure=i}updateSkyBottomLine(){const t=this.parentStaffLine.SkyBottomLineCalculator,e=this.PositionAndShape.RelativePosition.x+this.PositionAndShape.BorderMarginLeft,i=this.PositionAndShape.RelativePosition.x+this.PositionAndShape.BorderMarginRight;let n=0;switch(this.Placement){case r.PlacementEnum.Above:n=this.PositionAndShape.RelativePosition.y+this.PositionAndShape.BorderMarginTop,t.updateSkyLineInRange(e,i,n);break;case r.PlacementEnum.Below:n=this.PositionAndShape.RelativePosition.y+this.PositionAndShape.BorderMarginBottom,t.updateBottomLineInRange(e,i,n);break;default:o.default.error("Placement for GraphicalInstantaneousDynamicExpression is unknown")}}}e.GraphicalInstantaneousDynamicExpression=a},function(t,e,i){var n,s;Object.defineProperty(e,"__esModule",{value:!0}),e.ArpeggioType=e.Arpeggio=void 0,e.Arpeggio=class{constructor(t,e=n.ARPEGGIO_DIRECTIONLESS){this.parentVoiceEntry=t,this.type=e,this.notes=[]}addNote(t){this.notes.push(t),t.Arpeggio=this}},(s=n=e.ArpeggioType||(e.ArpeggioType={}))[s.BRUSH_DOWN=1]="BRUSH_DOWN",s[s.BRUSH_UP=2]="BRUSH_UP",s[s.ROLL_DOWN=3]="ROLL_DOWN",s[s.ROLL_UP=4]="ROLL_UP",s[s.RASQUEDO_DOWN=5]="RASQUEDO_DOWN",s[s.RASQUEDO_UP=6]="RASQUEDO_UP",s[s.ARPEGGIO_DIRECTIONLESS=7]="ARPEGGIO_DIRECTIONLESS"},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.PartListEntry=void 0,e.PartListEntry=class{constructor(t){this.enrolledTimestamps=[],this.visible=!0,this.musicSheet=t}get Visible(){return this.visible}set Visible(t){this.visible=t}getFirstSourceMeasure(){return this.musicSheet.SourceMeasures[this.startIndex]}getLastSourceMeasure(){return this.musicSheet.SourceMeasures[this.endIndex]}}},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0});var n=i(10),s=i(35),r=i(29),o=function(){function t(t){this.dictionary=new r.default(t)}return t.prototype.contains=function(t){return this.dictionary.containsKey(t)},t.prototype.add=function(t){return!this.contains(t)&&!n.isUndefined(t)&&(this.dictionary.setValue(t,t),!0)},t.prototype.intersection=function(t){var e=this;this.forEach((function(i){return t.contains(i)||e.remove(i),!0}))},t.prototype.union=function(t){var e=this;t.forEach((function(t){return e.add(t),!0}))},t.prototype.difference=function(t){var e=this;t.forEach((function(t){return e.remove(t),!0}))},t.prototype.isSubsetOf=function(t){if(this.size()>t.size())return!1;var e=!0;return this.forEach((function(i){return!!t.contains(i)||(e=!1,!1)})),e},t.prototype.remove=function(t){return!!this.contains(t)&&(this.dictionary.remove(t),!0)},t.prototype.forEach=function(t){this.dictionary.forEach((function(e,i){return t(i)}))},t.prototype.toArray=function(){return this.dictionary.values()},t.prototype.isEmpty=function(){return this.dictionary.isEmpty()},t.prototype.size=function(){return this.dictionary.size()},t.prototype.clear=function(){this.dictionary.clear()},t.prototype.toString=function(){return s.toString(this.toArray())},t}();e.default=o},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0});var n=i(10),s=i(84),r=function(){function t(t){this.root=null,this.compare=t||n.defaultCompare,this.nElements=0}return t.prototype.add=function(t){return!n.isUndefined(t)&&null!==this.insertNode(this.createNode(t))&&(this.nElements++,!0)},t.prototype.clear=function(){this.root=null,this.nElements=0},t.prototype.isEmpty=function(){return 0===this.nElements},t.prototype.size=function(){return this.nElements},t.prototype.contains=function(t){return!n.isUndefined(t)&&null!==this.searchNode(this.root,t)},t.prototype.search=function(t){var e=this.searchNode(this.root,t);if(null!==e)return e.element},t.prototype.remove=function(t){var e=this.searchNode(this.root,t);return null!==e&&(this.removeNode(e),this.nElements--,!0)},t.prototype.inorderTraversal=function(t){this.inorderTraversalAux(this.root,t,{stop:!1})},t.prototype.preorderTraversal=function(t){this.preorderTraversalAux(this.root,t,{stop:!1})},t.prototype.postorderTraversal=function(t){this.postorderTraversalAux(this.root,t,{stop:!1})},t.prototype.levelTraversal=function(t){this.levelTraversalAux(this.root,t)},t.prototype.minimum=function(){if(!this.isEmpty()&&null!==this.root)return this.minimumAux(this.root).element},t.prototype.maximum=function(){if(!this.isEmpty()&&null!==this.root)return this.maximumAux(this.root).element},t.prototype.forEach=function(t){this.inorderTraversal(t)},t.prototype.toArray=function(){var t=[];return this.inorderTraversal((function(e){return t.push(e),!0})),t},t.prototype.height=function(){return this.heightAux(this.root)},t.prototype.searchNode=function(t,e){for(var i=1;null!==t&&0!==i;)(i=this.compare(e,t.element))<0?t=t.leftCh:i>0&&(t=t.rightCh);return t},t.prototype.transplant=function(t,e){null===t.parent?this.root=e:t===t.parent.leftCh?t.parent.leftCh=e:t.parent.rightCh=e,null!==e&&(e.parent=t.parent)},t.prototype.removeNode=function(t){if(null===t.leftCh)this.transplant(t,t.rightCh);else if(null===t.rightCh)this.transplant(t,t.leftCh);else{var e=this.minimumAux(t.rightCh);e.parent!==t&&(this.transplant(e,e.rightCh),e.rightCh=t.rightCh,e.rightCh.parent=e),this.transplant(t,e),e.leftCh=t.leftCh,e.leftCh.parent=e}},t.prototype.inorderTraversalAux=function(t,e,i){null===t||i.stop||(this.inorderTraversalAux(t.leftCh,e,i),i.stop||(i.stop=!1===e(t.element),i.stop||this.inorderTraversalAux(t.rightCh,e,i)))},t.prototype.levelTraversalAux=function(t,e){var i=new s.default;for(null!==t&&i.enqueue(t),t=i.dequeue()||null;null!=t;){if(!1===e(t.element))return;null!==t.leftCh&&i.enqueue(t.leftCh),null!==t.rightCh&&i.enqueue(t.rightCh),t=i.dequeue()||null}},t.prototype.preorderTraversalAux=function(t,e,i){null===t||i.stop||(i.stop=!1===e(t.element),i.stop||(this.preorderTraversalAux(t.leftCh,e,i),i.stop||this.preorderTraversalAux(t.rightCh,e,i)))},t.prototype.postorderTraversalAux=function(t,e,i){null===t||i.stop||(this.postorderTraversalAux(t.leftCh,e,i),i.stop||(this.postorderTraversalAux(t.rightCh,e,i),i.stop||(i.stop=!1===e(t.element))))},t.prototype.minimumAux=function(t){for(;null!=t&&null!==t.leftCh;)t=t.leftCh;return t},t.prototype.maximumAux=function(t){for(;null!=t&&null!==t.rightCh;)t=t.rightCh;return t},t.prototype.heightAux=function(t){return null===t?-1:Math.max(this.heightAux(t.leftCh),this.heightAux(t.rightCh))+1},t.prototype.insertNode=function(t){for(var e=null,i=this.root;null!==i;){var n=this.compare(t.element,i.element);if(0===n)return null;n<0?(e=i,i=i.leftCh):(e=i,i=i.rightCh)}return t.parent=e,null===e?this.root=t:this.compare(t.element,e.element)<0?e.leftCh=t:e.rightCh=t,t},t.prototype.createNode=function(t){return{element:t,leftCh:null,rightCh:null,parent:null}},t}();e.default=r},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0});var n=i(53),s=function(){function t(){this.list=new n.default}return t.prototype.enqueue=function(t){return this.list.add(t)},t.prototype.add=function(t){return this.list.add(t)},t.prototype.dequeue=function(){if(0!==this.list.size()){var t=this.list.first();return this.list.removeElementAtIndex(0),t}},t.prototype.peek=function(){if(0!==this.list.size())return this.list.first()},t.prototype.size=function(){return this.list.size()},t.prototype.contains=function(t,e){return this.list.contains(t,e)},t.prototype.isEmpty=function(){return this.list.size()<=0},t.prototype.clear=function(){this.list.clear()},t.prototype.forEach=function(t){this.list.forEach(t)},t}();e.default=s},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0});var n=i(10),s=i(35),r=function(){function t(t){this.data=[],this.compare=t||n.defaultCompare}return t.prototype.leftChildIndex=function(t){return 2*t+1},t.prototype.rightChildIndex=function(t){return 2*t+2},t.prototype.parentIndex=function(t){return Math.floor((t-1)/2)},t.prototype.minIndex=function(t,e){return e>=this.data.length?t>=this.data.length?-1:t:this.compare(this.data[t],this.data[e])<=0?t:e},t.prototype.siftUp=function(t){for(var e=this.parentIndex(t);t>0&&this.compare(this.data[e],this.data[t])>0;)s.swap(this.data,e,t),t=e,e=this.parentIndex(t)},t.prototype.siftDown=function(t){for(var e=this.minIndex(this.leftChildIndex(t),this.rightChildIndex(t));e>=0&&this.compare(this.data[t],this.data[e])>0;)s.swap(this.data,e,t),t=e,e=this.minIndex(this.leftChildIndex(t),this.rightChildIndex(t))},t.prototype.peek=function(){return this.data.length>0?this.data[0]:void 0},t.prototype.add=function(t){return!n.isUndefined(t)&&(this.data.push(t),this.siftUp(this.data.length-1),!0)},t.prototype.removeRoot=function(){if(this.data.length>0){var t=this.data[0];return this.data[0]=this.data[this.data.length-1],this.data.splice(this.data.length-1,1),this.data.length>0&&this.siftDown(0),t}},t.prototype.contains=function(t){var e=n.compareToEquals(this.compare);return s.contains(this.data,t,e)},t.prototype.size=function(){return this.data.length},t.prototype.isEmpty=function(){return this.data.length<=0},t.prototype.clear=function(){this.data.length=0},t.prototype.forEach=function(t){s.forEach(this.data,t)},t}();e.default=r},function(t,e,i){var n,s=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])},function(t,e){function i(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0});var r=i(29),o=i(10),a=function(t){function e(e,i){var n=t.call(this,i)||this;return n.defaultFactoryFunction=e,n}return s(e,t),e.prototype.setDefault=function(e,i){var n=t.prototype.getValue.call(this,e);return o.isUndefined(n)?(this.setValue(e,i),i):n},e.prototype.getValue=function(t){return this.setDefault(t,this.defaultFactoryFunction())},e}(r.default);e.default=a},function(t,e,i){var n;Object.defineProperty(e,"__esModule",{value:!0}),e.Fonts=void 0,(n=e.Fonts||(e.Fonts={}))[n.TimesNewRoman=0]="TimesNewRoman",n[n.Kokila=1]="Kokila"},function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalUnknownExpression=void 0;const s=i(42),r=i(3),o=n(i(1));class a extends s.AbstractGraphicalExpression{constructor(t,e,i,n,s){super(t,new r.AbstractExpression(i),n),this.label=e,this.sourceMultiExpression=s}updateSkyBottomLine(){const t=this.parentStaffLine.SkyBottomLineCalculator,e=this.label.PositionAndShape.RelativePosition.x+this.label.PositionAndShape.BorderMarginLeft,i=this.label.PositionAndShape.RelativePosition.x+this.label.PositionAndShape.BorderMarginRight;switch(this.Placement){case r.PlacementEnum.Above:const n=this.label.PositionAndShape.BorderMarginTop+this.label.PositionAndShape.RelativePosition.y;t.updateSkyLineInRange(e,i,n);break;case r.PlacementEnum.Below:const s=this.label.PositionAndShape.BorderMarginBottom+this.label.PositionAndShape.RelativePosition.y;t.updateBottomLineInRange(e,i,s);break;default:o.default.error("Placement for GraphicalUnknownExpression is unknown")}}}e.GraphicalUnknownExpression=a},function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowMusicSheetCalculator=void 0;const s=i(17),r=i(90),o=i(128),a=i(63),l=n(i(8)),h=n(i(1)),c=i(16),u=i(129),d=i(130),f=i(97),p=i(93),m=i(9),b=i(131),g=i(57),y=i(37),S=i(25),v=i(100),x=i(39),E=i(13),_=i(102);class w extends s.MusicSheetCalculator{constructor(t){var e,i,n,o,h,c,u,d;super(),this.beamsNeedUpdate=!1,this.rules=t,s.MusicSheetCalculator.symbolFactory=new r.VexFlowGraphicalSymbolFactory,s.MusicSheetCalculator.TextMeasurer=new a.VexFlowTextMeasurer(this.rules),s.MusicSheetCalculator.stafflineNoteCalculator=new v.VexflowStafflineNoteCalculator(this.rules),"gonville"===(null===(e=this.rules.DefaultVexFlowNoteFont)||void 0===e?void 0:e.toLowerCase())?l.default.Flow.DEFAULT_FONT_STACK=[null===(i=l.default.Flow.Fonts)||void 0===i?void 0:i.Gonville,null===(n=l.default.Flow.Fonts)||void 0===n?void 0:n.Bravura,null===(o=l.default.Flow.Fonts)||void 0===o?void 0:o.Custom]:"petaluma"===(null===(h=this.rules.DefaultVexFlowNoteFont)||void 0===h?void 0:h.toLowerCase())&&(l.default.Flow.DEFAULT_FONT_STACK=[null===(c=l.default.Flow.Fonts)||void 0===c?void 0:c.Petaluma,null===(u=l.default.Flow.Fonts)||void 0===u?void 0:u.Gonville,null===(d=l.default.Flow.Fonts)||void 0===d?void 0:d.Bravura])}clearRecreatedObjects(){var t;super.clearRecreatedObjects(),s.MusicSheetCalculator.stafflineNoteCalculator=new v.VexflowStafflineNoteCalculator(this.rules);for(const e of this.graphicalMusicSheet.MeasureList)for(const i of e)null===(t=i)||void 0===t||t.clean()}formatMeasures(){for(const t of this.graphicalMusicSheet.MeasureList)if(t&&t[0]){t[0].format();for(const e of t){for(const t of e.staffEntries)t.calculateXPosition();e.finalizeBeams()}}this.beamsNeedUpdate=!1}calculateMeasureXLayout(t){const e=[];for(const i of t)i&&e.push(i);if(0===e.length)return 0;t=e;const i=[],n=new l.default.Flow.Formatter({softmaxFactor:this.rules.SoftmaxFactorVexFlow});let r=t[0].staffEntries.length,o=1;for(const e of t){if(!e)continue;let t=0;for(const i of e.staffEntries)t+=i.setMaxAccidentals();e.parentSourceMeasure.ImplicitMeasure&&(r=Math.max(e.staffEntries.length,r),o=Math.max(e.staffEntries.length+t,o));const s=e.vfVoices,a=[];for(const t in s)s.hasOwnProperty(t)&&(a.push(s[t]),i.push(s[t]));0!==a.length?n.joinVoices(a):h.default.debug("Found a measure with no voices. Continuing anyway.",s)}let a=12;const u=t[0].parentSourceMeasure;if(i.length>0){const e=.3;a=n.preCalculateMinTotalWidth(i)/c.unitInPixels*this.rules.VoiceSpacingMultiplierVexflow+this.rules.VoiceSpacingAddendVexflow+r*e,(null==u?void 0:u.ImplicitMeasure)&&(a=u.Duration.RealValue/u.ActiveTimeSignature.RealValue*a,r>1&&(a+=o*e*1.5),a*=this.rules.PickupMeasureWidthMultiplier),s.MusicSheetCalculator.setMeasuresMinStaffEntriesWidth(t,a);const l=(t,e)=>{n.formatToStave(i,e.getVFStave())},h=(t,e)=>{n.formatToStave(i,e.getVFStave(),{align_rests:!0,context:void 0})};for(const e of t){if(this.rules.AlignRests===S.AlignRestOption.Never)e.formatVoices=l;else if(this.rules.AlignRests===S.AlignRestOption.Always)e.formatVoices=h;else if(this.rules.AlignRests===S.AlignRestOption.Auto){let t=!1;for(const i of e.staffEntries){let e=0,n=0;for(const s of i.graphicalVoiceEntries)if(s.parentVoiceEntry.IsGrace||s&&s.notes&&s.notes[0]&&s.notes[0].sourceNote&&s.notes[0].sourceNote.PrintObject&&e++,s&&s.notes&&s.notes[0]&&s.notes[0].sourceNote&&s.notes[0].sourceNote.isRest()&&s.notes[0].sourceNote.PrintObject&&n++,e>1&&n>=1){t=!0;break}if(t)break}e.formatVoices=t?h:l}if(e===t[0]){const t=e;t.formatVoices(a*c.unitInPixels,t)}}}for(const e of t)if(e)for(const t of e.staffEntries)t.calculateXPosition();return a}calculateElongationFactor(t,e,i,n,s,r,o,a){let l=s,h=0;for(const c of t){const t=c.GraphicalLabel.Label.textAlignment;let d=o,f=a;if(c instanceof u.GraphicalLyricEntry&&c.ParentLyricWord){c.LyricsEntry.SyllableIndex>0&&(d=this.rules.BetweenSyllableMinimumDistance,m.TextAlignment.IsCenterAligned(t)&&(d+=1));const e=c.ParentLyricWord.GetLyricWord.Syllables;e.length>1&&c.LyricsEntry.SyllableIndex4&&(T*=1.1)}}else i[h]&&(T=y/S);_=Math.max(w,T),l=Math.max(l,_);let M=Math.max(y-S||0,0);i[h]&&(M+=i[h].cumulativeOverlap),i[h]={cumulativeOverlap:M,extend:c instanceof u.GraphicalLyricEntry&&c.LyricsEntry.extend,labelWidth:b,measureNumber:r,sourceNoteDuration:c instanceof u.GraphicalLyricEntry&&c.LyricsEntry&&c.LyricsEntry.Parent.Notes[0].Length,text:c instanceof u.GraphicalLyricEntry?c.LyricsEntry.Text:c.GraphicalLabel.Label.text,xPosition:g},h++}return l}calculateElongationFactorFromStaffEntries(t,e,i,n){let s=i;const r={},o={};for(const i of t)i.LyricsEntries.length>0&&(s=this.calculateElongationFactor(i.LyricsEntries,i,r,e,s,n,this.rules.HorizontalBetweenLyricsDistance,this.rules.LyricOverlapAllowedIntoNextMeasure)),i.graphicalChordContainers.length>0&&(s=this.calculateElongationFactor(i.graphicalChordContainers,i,o,e,s,n,this.rules.ChordSymbolXSpacing,this.rules.ChordOverlapAllowedIntoNextMeasure));return s}calculateMeasureWidthFromStaffEntries(t,e){let i=1;for(const n of t)n&&0!==n.staffEntries.length&&(i=this.calculateElongationFactorFromStaffEntries(n.staffEntries,e,i,n.MeasureNumber));return i=Math.min(i,this.rules.MaximumLyricsElongationFactor),e*i}createGraphicalTie(t,e,i,n,s){return new o.GraphicalTie(t,n,s)}updateStaffLineBorders(t){t.SkyBottomLineCalculator.updateStaffLineBorders()}graphicalMeasureCreatedCalculations(t){t.rules=this.rules,t.graphicalMeasureCreatedCalculations()}layoutVoiceEntry(t,e,i,n){for(let t=0;t=2&&(r=n.vfnote[0],o=n.vfnote[1]);let a,h=0;if(s&&s.vfnote&&s.vfnote.length>=2&&(a=s.vfnote[0],h=s.vfnote[1]),e){if(r){const t=new l.default.Flow.StaveTie({first_indices:[o],first_note:r});n.parentVoiceEntry.parentStaffEntry.parentMeasure.vfTies.push(t)}if(a){const t=new l.default.Flow.StaveTie({last_indices:[h],last_note:a});s.parentVoiceEntry.parentStaffEntry.parentMeasure.vfTies.push(t)}}else if(r||a){let e;if(i)if("S"===t.Tie.Type){const i=t.StartNote.sourceNote,n=t.EndNote.sourceNote;let s=1;i.FretNumber>n.FretNumber&&(s=-1),e=new l.default.Flow.TabSlide({first_indices:[o],first_note:r,last_indices:[h],last_note:a},s)}else e=new l.default.Flow.TabTie({first_indices:[o],first_note:r,last_indices:[h],last_note:a},t.Tie.Type);else e=new l.default.Flow.StaveTie({first_indices:[o],first_note:r,last_indices:[h],last_note:a});s.parentVoiceEntry.parentStaffEntry.parentMeasure.vfTies.push(e)}}calculateDynamicExpressionsForMultiExpression(t,e,i){if(ethis.rules.MaxMeasureToDrawIndex)return;const n=t.AbsoluteTimestamp,s=this.graphicalMusicSheet.MeasureList[e],r=s[i].ParentStaffLine,o=s[i],a=this.getRelativePositionInStaffLineFromTimestamp(n,i,r,null==r?void 0:r.isPartOfMultiStaffInstrument()),l=a;if(a.x<=0&&(l.x=o.beginInstructionsWidth+this.rules.RhythmRightMargin),t.InstantaneousDynamic){const e=new p.VexFlowInstantaneousDynamicExpression(t.InstantaneousDynamic,r,o);this.calculateGraphicalInstantaneousDynamicExpression(e,l)}if(t.StartingContinuousDynamic){const e=t.StartingContinuousDynamic,i=new g.VexFlowContinuousDynamicExpression(t.StartingContinuousDynamic,r,o.parentSourceMeasure);if(i.StartMeasure=o,!i.IsVerbal&&e.EndMultiExpression)try{this.calculateGraphicalContinuousDynamic(i,l)}catch(t){}else i.IsVerbal?this.calculateGraphicalVerbalContinuousDynamic(i,l):h.default.warn("This continuous dynamic is not covered")}}createMetronomeMark(t){var e;const i=Math.max(t.ParentMultiTempoExpression.SourceMeasureParent.MeasureNumber-1,0),n=Math.max(t.StaffNumber-1,0),s=0===i&&0===n,r=this.graphicalMusicSheet.MeasureList[i][n].getVFStave();let o="q";if(t.beatUnit){const e=x.NoteTypeHandler.getNoteDurationFromType(t.beatUnit);o=E.VexFlowConverter.duration(e,!1)}let a=this.rules.MetronomeMarkYShift,l=!1;for(const i of t.parentMeasure.TempoExpressions){const t=(null===(e=i.InstantaneousTempo)||void 0===e?void 0:e.Enum)===y.TempoEnum.metronomeMark;if(i.getPlacementOfFirstEntry()===_.PlacementEnum.Above&&!t){l=!0;break}}l&&(a-=1.4);const h=this.graphicalMusicSheet.MeasureList[0][0].ParentStaffLine.SkyLine;r.setTempo({bpm:t.TempoInBpm,dots:t.dotted,duration:o},a*c.unitInPixels);const u=s?this.rules.MetronomeMarkXShift*c.unitInPixels:0;r.getModifiers()[r.getModifiers().length-1].setShiftX(u),h[0]=Math.min(h[0],-4.5+a)}calculateRehearsalMark(t){const e=t.rehearsalExpression;if(!e)return;const i=Math.max(t.MeasureNumber-1,0),n=this.graphicalMusicSheet.MeasureList[i][0].getVFStave(),s=-this.rules.RehearsalMarkYOffsetDefault-this.rules.RehearsalMarkYOffset;let r=this.rules.RehearsalMarkXOffsetDefault+this.rules.RehearsalMarkXOffset;t.IsSystemStartMeasure&&(r+=this.rules.RehearsalMarkXOffsetSystemStartMeasure);const o=this.rules.RehearsalMarkFontSize;n.setSection(e.label,s,r,o)}calculateSingleOctaveShift(t,e,i,n){var s;const r=e.OctaveShiftStart,o=r.ParentStartMultiExpression.Timestamp,a=null===(s=r.ParentEndMultiExpression)||void 0===s?void 0:s.Timestamp,l=this.rules.MinMeasureToDrawIndex,c=this.rules.MaxMeasureToDrawIndex;let u,d,p=this.graphicalMusicSheet.MeasureList[i][n].ParentStaffLine;if(p||(p=this.graphicalMusicSheet.MeasureList[l][n].ParentStaffLine),u=r.ParentEndMultiExpression?this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(r.ParentEndMultiExpression.SourceMeasureParent,n):this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(n,!0),u.MeasureNumber>c+1&&(u=this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(n,!0)),d=r.ParentEndMultiExpression?this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(r.ParentStartMultiExpression.SourceMeasureParent,n):this.graphicalMusicSheet.MeasureList[l][n],d.MeasureNumberc+1||u.MeasureNumberc+1)return;let m=u.ParentStaffLine;if(m||(m=p),u&&p&&m){const t=new f.VexFlowOctaveShift(r,p.PositionAndShape);if(!t.startNote){let e;for(const t of d.staffEntries)if(t){e=t;break}if(!e)return;if(t.setStartNote(e),!t.startNote)return}if(!t.endNote){let e;for(let t=u.staffEntries.length-1;t>=0;t++)if(u.staffEntries[t]){e=u.staffEntries[t];break}if(t.setEndNote(e),!t.endNote)return}let e=d.findGraphicalStaffEntryFromTimestamp(o);e||(e=d.staffEntries[0]);let i=u.findGraphicalStaffEntryFromTimestamp(a);if(i||(i=u.staffEntries[u.staffEntries.length-1]),t.setStartNote(e),m!==p){t.endsOnDifferentStaffLine=!0;let s=p.Measures[p.Measures.length-1];void 0===s&&(s=u);const o=s.staffEntries[s.staffEntries.length-1];t.setEndNote(o);const a=m.ParentMusicSystem.Id-p.ParentMusicSystem.Id;if(a>0)for(let t=p.ParentMusicSystem.Id;t{t.updateSkyBottomLine()}))}catch(t){}}handleTiedGraphicalNote(t,e,i,n,s,r,o,a){}handleBeam(t,e,i){t.parentVoiceEntry.parentStaffEntry.parentMeasure.handleBeam(t,e)}handleVoiceEntryLyrics(t,e,i){t.LyricsEntries.forEach(((t,n)=>{const s=new u.GraphicalLyricEntry(n,e,this.rules.LyricsHeight,this.rules.StaffHeight);if(e.LyricsEntries.push(s),s.GraphicalLabel.setLabelPositionAndShapeBorders(),n.Word){const t=n.Word.Syllables.indexOf(n);let e=i.indexOf(n.Word);if(-1===e&&(i.push(n.Word),e=i.indexOf(n.Word)),0===this.graphicalLyricWords.length||e>this.graphicalLyricWords.length-1){const e=new d.GraphicalLyricWord(n.Word);s.ParentLyricWord=e,e.GraphicalLyricsEntries[t]=s,this.graphicalLyricWords.push(e)}else{const n=this.graphicalLyricWords[e];s.ParentLyricWord=n,n.GraphicalLyricsEntries[t]=s,n.isFilled()&&(i.splice(e,1),this.graphicalLyricWords.splice(this.graphicalLyricWords.indexOf(n),1))}}}))}handleVoiceEntryOrnaments(t,e,i){}handleVoiceEntryArticulations(t,e,i){}handleVoiceEntryTechnicalInstructions(t,e,i){}handleTuplet(t,e,i){t.parentVoiceEntry.parentStaffEntry.parentMeasure.handleTuplet(t,e)}findIndexGraphicalSlurFromSlur(t,e){for(let i=0;i=0){const t=e[i];-1===t.staffEntries.indexOf(n)&&t.staffEntries.push(n),e.splice(i,1)}}}for(const t of e)-1===t.staffEntries.indexOf(n)&&t.staffEntries.push(n)}}for(const t of this.musicSystems)for(const e of t.StaffLines){const t=e.GraphicalSlurs.sort(b.GraphicalSlur.Compare);for(const e of t)e.slur.isCrossed()||e.calculateCurve(this.rules)}}}e.VexFlowMusicSheetCalculator=w},function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowGraphicalSymbolFactory=void 0;const s=n(i(8)),r=i(91),o=i(44),a=i(98),l=i(30),h=i(60),c=i(127),u=i(62),d=i(13),f=i(101),p=i(99),m=i(96);e.VexFlowGraphicalSymbolFactory=class{createMusicSystem(t,e){return new r.VexFlowMusicSystem(t,e)}createStaffLine(t,e){return new p.VexFlowStaffLine(t,e)}createGraphicalMeasure(t,e,i=!1){return new o.VexFlowMeasure(e,t,void 0)}createMultiRestMeasure(t,e,i){return new m.VexFlowMultiRestMeasure(e,t,i)}createTabStaffMeasure(t,e){return new f.VexFlowTabMeasure(e,t)}createExtraGraphicalMeasure(t){return new o.VexFlowMeasure(t.ParentStaff,void 0,t)}createStaffEntry(t,e){return new a.VexFlowStaffEntry(e,t,void 0)}createVoiceEntry(t,e){return new u.VexFlowVoiceEntry(t,e)}createNote(t,e,i,n=l.OctaveEnum.NONE,s,r){return new h.VexFlowGraphicalNote(t,e,i,n,s,r)}createGraceNote(t,e,i,n,s=l.OctaveEnum.NONE){return new h.VexFlowGraphicalNote(t,e,i,s,n)}addGraphicalAccidental(t,e){t.setAccidental(e)}addFermataAtTiedEndNote(t,e){}createInStaffClef(t,e){const i=t,n=d.VexFlowConverter.Clef(e,"small");i.vfClefBefore=new s.default.Flow.ClefNote(n.type,n.size,n.annotation)}createChordSymbols(t,e,i,n){const s=e.parentMeasure.parentSourceMeasure.Rules;let r=0;const o=s.ChordSymbolXSpacing;for(const a of t.ChordContainers){const t=new c.GraphicalChordSymbolContainer(a,e.PositionAndShape,s.ChordSymbolTextHeight,i,n,e.parentMeasure.parentSourceMeasure.Rules),l=t.GraphicalLabel;l.PositionAndShape.RelativePosition.y-=s.ChordSymbolYOffset,l.PositionAndShape.RelativePosition.x+=r,l.setLabelPositionAndShapeBorders(),t.PositionAndShape.calculateBoundingBox(),e.graphicalChordContainers.push(t),r+=l.PositionAndShape.Size.width+o}}createGraphicalTechnicalInstruction(t,e){}}},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowMusicSystem=void 0;const n=i(117),s=i(75),r=i(13),o=i(61),a=i(95);class l extends n.MusicSystem{constructor(t,e){super(t),this.rules=e}calculateBorders(t){if(0===this.staffLines.length)return;const e=this.calcBracketsWidth();this.boundingBox.BorderLeft=-e,this.boundingBox.BorderMarginLeft=-e,this.boundingBox.XBordersHaveBeenSet=!0;const i=this.staffLines[0].SkyBottomLineCalculator.getSkyLineMin();this.boundingBox.BorderTop=i,this.boundingBox.BorderMarginTop=i;const n=this.staffLines[this.staffLines.length-1],s=n.SkyBottomLineCalculator.getBottomLineMax()+n.PositionAndShape.RelativePosition.y;this.boundingBox.BorderBottom=s,this.boundingBox.BorderMarginBottom=s,this.boundingBox.XBordersHaveBeenSet=!0,this.boundingBox.YBordersHaveBeenSet=!0}createSystemLine(t,e,i,n,o,a,l){const h=a;let c=!1;return l&&(c=!0,l.lineTo(a,r.VexFlowConverter.line(i,n)),l.addMeasureLine(i,n)),h&&h.addMeasureLine(i,n,c),new s.SystemLine(i,n,this,a,l)}createInstrumentBracket(t,e){const i=t,n=e,s=new a.VexFlowInstrumentBrace(i,n);this.InstrumentBrackets.push(s)}createGroupBracket(t,e,i){const n=t,s=e;if(0===i){const t=new o.VexFlowInstrumentBracket(n,s,i);this.GroupBrackets.push(t)}else{const t=new a.VexFlowInstrumentBrace(n,s,i);this.GroupBrackets.push(t)}}}e.VexFlowMusicSystem=l},function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.SvgVexFlowBackend=void 0;const s=n(i(8)),r=i(59),o=i(13),a=i(21),l=i(25),h=n(i(1));class c extends r.VexFlowBackend{constructor(t){super(),this.rules=t}getVexflowBackendType(){return s.default.Flow.Renderer.Backends.SVG}getOSMDBackendType(){return l.BackendType.SVG}getCanvasSize(){var t;return null===(t=document.getElementById("osmdCanvasPage"+this.graphicalMusicPage.PageNumber))||void 0===t?void 0:t.offsetHeight}initialize(t,e){this.zoom=e,this.canvas=document.createElement("div"),this.canvas.id="osmdCanvasPage"+this.graphicalMusicPage.PageNumber,this.inner=this.canvas,this.inner.style.position="relative",this.canvas.style.zIndex="0",t.appendChild(this.inner),this.renderer=new s.default.Flow.Renderer(this.canvas,this.getVexflowBackendType()),this.ctx=this.renderer.getContext(),this.ctx.svg.id="osmdSvgPage"+this.graphicalMusicPage.PageNumber}getContext(){return this.ctx}getSvgElement(){return this.ctx.svg}removeNode(t){var e;const i=null===(e=this.ctx)||void 0===e?void 0:e.svg;if(!i)return!1;try{i.removeChild(t)}catch(t){return h.default.error(t),!1}return!0}clear(){if(!this.ctx)return;const t=this.ctx.svg;for(;t.lastChild;)t.removeChild(t.lastChild);this.rules.PageBackgroundColor&&(this.ctx.save(),this.ctx.setFillStyle(this.rules.PageBackgroundColor),this.ctx.setStrokeStyle("#12345600"),this.ctx.fillRect(0,0,this.canvas.offsetWidth/this.zoom,this.canvas.offsetHeight/this.zoom),this.ctx.restore())}scale(t){this.ctx.scale(t,t)}translate(t,e){}renderText(t,e,i,n,s,r,l,h){this.ctx.save();const c=this.ctx.openGroup();l&&(this.ctx.attributes.fill=l,this.ctx.attributes.stroke=l);let u=h;h&&"default"!==h||(u=this.rules.DefaultFontFamily),this.ctx.setFont(u,t,o.VexFlowConverter.fontStyle(e)),this.ctx.attributes["font-size"]=`${t}px`,this.ctx.state["font-size"]=`${t}px`;let d="normal",f="normal";switch(e){case a.FontStyles.Bold:d="bold";break;case a.FontStyles.Italic:f="italic";break;case a.FontStyles.BoldItalic:d="bold",f="italic";break;default:d="normal"}return this.ctx.attributes["font-weight"]=d,this.ctx.state["font-weight"]=d,this.ctx.attributes["font-style"]=f,this.ctx.state["font-style"]=f,this.ctx.fillText(n,r.x,r.y+s),this.ctx.closeGroup(),this.ctx.restore(),c}renderRectangle(t,e,i,n=1){this.ctx.save();const s=this.ctx.openGroup();return this.ctx.attributes.fill=i||o.VexFlowConverter.style(e),this.ctx.attributes["fill-opacity"]=n,this.ctx.fillRect(t.x,t.y,t.width,t.height),this.ctx.restore(),this.ctx.attributes["fill-opacity"]=1,this.ctx.closeGroup(),s}renderLine(t,e,i="#FF0000FF",n=2){this.ctx.save();const s=this.ctx.openGroup();return this.ctx.beginPath(),this.ctx.moveTo(t.x,t.y),this.ctx.lineTo(e.x,e.y),this.ctx.attributes.stroke=i,this.ctx.lineWidth=n,this.ctx.stroke(),this.ctx.closeGroup(),this.ctx.restore(),s}renderCurve(t){this.ctx.beginPath(),this.ctx.moveTo(t[0].x,t[0].y),this.ctx.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y),this.ctx.lineTo(t[7].x,t[7].y),this.ctx.bezierCurveTo(t[6].x,t[6].y,t[5].x,t[5].y,t[4].x,t[4].y),this.ctx.lineTo(t[0].x,t[0].y),this.ctx.closePath(),this.ctx.fill()}export(){const t=this.ctx.svg.cloneNode(!0),e=document.implementation.createDocumentType("svg","-//W3C//DTD SVG 1.1//EN","http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"),i=document.implementation.createDocument("http://www.w3.org/2000/svg","svg",e);i.replaceChild(t,i.documentElement);const n=(new XMLSerializer).serializeToString(i),s=document.createElement("a");s.href="data:image/svg+xml; charset=utf8, "+encodeURIComponent(n.replace(/>\n\r<")),s.download="opensheetmusicdisplay_download.svg",s.innerHTML=window.location.href+"/download",document.body.appendChild(s)}}e.SvgVexFlowBackend=c},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowInstantaneousDynamicExpression=void 0;const n=i(79),s=i(38),r=i(24),o=i(12),a=i(9),l=i(21);class h extends n.GraphicalInstantaneousDynamicExpression{constructor(t,e,i){super(t,e,i);const n=new o.Label(this.Expression);this.label=new r.GraphicalLabel(n,this.rules.ContinuousDynamicTextHeight,a.TextAlignmentEnum.CenterCenter,this.rules,this.PositionAndShape),this.label.Label.fontStyle=l.FontStyles.BoldItalic,this.label.setLabelPositionAndShapeBorders(),this.PositionAndShape.calculateBoundingBox()}get InstantaneousDynamic(){return this.mInstantaneousDynamicExpression}get Expression(){return s.DynamicEnum[this.mInstantaneousDynamicExpression.DynEnum]}}e.VexFlowInstantaneousDynamicExpression=h},function(t,e,i){var n;Object.defineProperty(e,"__esModule",{value:!0}),e.DynamicExpressionSymbolEnum=void 0,(n=e.DynamicExpressionSymbolEnum||(e.DynamicExpressionSymbolEnum={}))[n.p=0]="p",n[n.f=1]="f",n[n.s=2]="s",n[n.z=3]="z",n[n.m=4]="m",n[n.r=5]="r"},function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowInstrumentBrace=void 0;const s=n(i(8)),r=i(61);class o extends r.VexFlowInstrumentBracket{constructor(t,e,i=0){super(t,e,i),this.vexflowConnector.setType(s.default.Flow.StaveConnector.type.BRACE)}}e.VexFlowInstrumentBrace=o},function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowMultiRestMeasure=void 0;const s=n(i(8)),r=i(44);class o extends r.VexFlowMeasure{constructor(t,e,i){super(t,e,i),this.minimumStaffEntriesWidth=-1,i?this.rules=i.ParentMusicSystem.rules:e&&(this.rules=e.Rules),this.resetLayout(),this.multiRestElement=new s.default.Flow.MultiMeasureRest(e.multipleRestMeasures,{})}draw(t){this.stave.setContext(t).draw(),this.multiRestElement.setStave(this.stave),this.multiRestElement.setContext(t),this.multiRestElement.draw();for(const e of this.connectors)e.setContext(t).draw()}format(){}getVoicesWithinMeasure(){return[]}getGraphicalVoiceEntriesPerVoice(t){return[]}getRestFilledVexFlowStaveNotesPerVoice(t){return[]}handleBeam(t,e){}handleTuplet(t,e){}finalizeBeams(){}finalizeTuplets(){}layoutStaffEntry(t){}graphicalMeasureCreatedCalculations(){}createArticulations(){}createOrnaments(){}createFingerings(t){}getVFStave(){return this.stave}}e.VexFlowMultiRestMeasure=o},function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowOctaveShift=void 0;const s=n(i(8)),r=i(123),o=i(30),a=n(i(1));class l extends r.GraphicalOctaveShift{constructor(t,e){switch(super(t,e),t.Type){case o.OctaveEnum.VA8:this.position=s.default.Flow.TextBracket.Positions.TOP,this.supscript="va",this.text="8";break;case o.OctaveEnum.MA15:this.position=s.default.Flow.TextBracket.Positions.TOP,this.supscript="ma",this.text="15";break;case o.OctaveEnum.VB8:this.position=s.default.Flow.TextBracket.Positions.BOTTOM,this.supscript="vb",this.text="8";break;case o.OctaveEnum.MB15:this.position=s.default.Flow.TextBracket.Positions.BOTTOM,this.supscript="mb",this.text="15";break;default:a.default.error("Unknown or NONE octaveshift. This should not be called!")}}setStartNote(t){for(const e of t.graphicalVoiceEntries){const t=e;if(null==t?void 0:t.vfStaveNote)return this.startNote=t.vfStaveNote,!0}return!1}setEndNote(t){for(const e of t.graphicalVoiceEntries){const t=e;if(null==t?void 0:t.vfStaveNote)return this.endNote=t.vfStaveNote,!0}return!1}getTextBracket(){return new s.default.Flow.TextBracket({position:this.position,start:this.startNote,stop:this.endNote,superscript:this.supscript,text:this.text})}}e.VexFlowOctaveShift=l},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowStaffEntry=void 0;const n=i(124),s=i(16),r=i(2);class o extends n.GraphicalStaffEntry{constructor(t,e,i){super(t,e,i)}calculateXPosition(){const t=this.parentMeasure.getVFStave();let e=0;for(const i of this.graphicalVoiceEntries)if(i.vfStaveNote){if(i.vfStaveNote.setStave(t),!i.vfStaveNote.preFormatted)continue;i.applyBordersFromVexflow(),this.parentMeasure.ParentStaff.isTab?this.PositionAndShape.RelativePosition.x=(i.vfStaveNote.getAbsoluteX()+i.vfStaveNote.glyph.getWidth())/s.unitInPixels:this.PositionAndShape.RelativePosition.x=i.vfStaveNote.getBoundingBox().getX()/s.unitInPixels;const n=i.notes[0].sourceNote;n.isRest()&&n.Length.RealValue===this.parentMeasure.parentSourceMeasure.ActiveTimeSignature.RealValue&&(this.PositionAndShape.RelativePosition.x+=this.parentMeasure.parentSourceMeasure.Rules.WholeRestXShiftVexflow-.1,i.PositionAndShape.BorderLeft=-.7,i.PositionAndShape.BorderRight=.7),i.PositionAndShape.BorderLeftt.staffLine)),i=this.calculateModifierXOffsets(e,1),n=this.calculateModifierXOffsets(e,.5);t.forEach(((t,e)=>{t.baseFingeringXOffset=n[e],t.baseStringNumberXOffset=i[e]}))}calculateModifierXOffsets(t,e){const i=[];for(let n=0;n=0;o--){if(Math.abs(t[n]-t[o])<=e&&s===i[o]){s++,r=!0;break}r=!1}i.push(s)}return i}}e.VexFlowStaffEntry=o},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowStaffLine=void 0;const n=i(125),s=i(78);class r extends n.StaffLine{constructor(t,e){super(t,e),this.slursInVFStaffLine=[],this.alignmentManager=new s.AlignmentManager(this)}get SlursInVFStaffLine(){return this.slursInVFStaffLine}addVFSlurToVFStaffline(t){this.slursInVFStaffLine.push(t)}get AlignmentManager(){return this.alignmentManager}}e.VexFlowStaffLine=r},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.VexflowStafflineNoteCalculator=void 0;const n=i(2),s=i(60),r=i(15),o=i(7),a=i(14);class l{constructor(t){this.staffPitchListMapping=new r.Dictionary,this.baseLineNote=n.NoteEnum.B,this.baseLineOctave=1,this.rules=t}trackNote(t){if(!(t instanceof s.VexFlowGraphicalNote)||t.Clef().ClefType!==o.ClefEnum.percussion||t.sourceNote.isRest()||0===this.rules.PercussionOneLineCutoff||-1===this.rules.PercussionForceVoicesOneLineCutoff)return;const e=t.parentVoiceEntry.parentStaffEntry.sourceStaffEntry.ParentStaff.idInMusicSheet;let i;this.staffPitchListMapping.containsKey(e)||this.staffPitchListMapping.setValue(e,new Array),i=this.staffPitchListMapping.getValue(e);const n=t.sourceNote.Pitch;l.findOrInsert(i,n)}static PitchIndexOf(t,e,i=0){if(i>t.length-1)return-1;for(let n=i;nthis.rules.PercussionOneLineCutoff&&!o)return t;const h=t,c=t.sourceNote.Pitch;let u=this.baseLineNote,d=this.baseLineOctave;if(this.rules.PercussionOneLineUseXMLDisplayStep&&void 0!==t.sourceNote.displayStepUnpitched&&r&&(u=t.sourceNote.displayStepUnpitched,d=t.sourceNote.displayOctaveUnpitched+this.rules.PercussionOneLineXMLDisplayStepOctaveOffset),i.length<=this.rules.PercussionForceVoicesOneLineCutoff)h.setAccidental(new n.Pitch(u,d,c.Accidental));else{const t=l.PitchIndexOf(i,c);if(t>-1){const e=Math.ceil(i.length/2);if(!this.rules.PercussionOneLineUseXMLDisplayStep)if(t>=e)switch(d=2,(t-e)%5){case 1:u=n.NoteEnum.E;break;case 2:u=n.NoteEnum.G;break;case 3:u=n.NoteEnum.B;break;case 4:u=n.NoteEnum.D,d=3;break;default:u=n.NoteEnum.C}else switch(t%5){case 1:u=n.NoteEnum.F;break;case 2:u=n.NoteEnum.D;break;case 3:u=n.NoteEnum.B,d=0;break;case 4:u=n.NoteEnum.G,d=0;break;default:u=n.NoteEnum.A}const s=new n.Pitch(u,d,c.Accidental);h.setAccidental(s);const r=h.parentVoiceEntry.parentVoiceEntry;!this.rules.SetWantedStemDirectionByXml&&r.Notes.length<2&&(s.Octave>this.baseLineOctave||s.FundamentalNote===this.baseLineNote&&s.Octave===this.baseLineOctave?h.parentVoiceEntry.parentVoiceEntry.WantedStemDirection=a.StemDirectionType.Up:h.parentVoiceEntry.parentVoiceEntry.WantedStemDirection=a.StemDirectionType.Down)}}return h}getStafflineUniquePositionCount(t){return this.staffPitchListMapping.containsKey(t)?this.staffPitchListMapping.getValue(t).length:0}}e.VexflowStafflineNoteCalculator=l},function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.VexFlowTabMeasure=void 0;const s=n(i(8)),r=i(44),o=i(13),a=n(i(1));class l extends r.VexFlowMeasure{constructor(t,e,i){super(t,e,i),this.isTabMeasure=!0}resetLayout(){this.stave=new s.default.Flow.TabStave(0,0,0,{space_above_staff_ln:0,space_below_staff_ln:0}),this.updateInstructionWidth()}graphicalMeasureCreatedCalculations(){for(let t=0,e=this.staffEntries.length;t1){const i=o.VexFlowConverter.StrokeTypeFromArpeggioType(e.type),n=new s.default.Flow.Stroke(i,{all_voices:this.rules.ArpeggiosGoAcrossVoices});this.rules.RenderArpeggios&&t.vfStaveNote.addStroke(0,n)}else a.default.debug(`[OSMD] arpeggio in measure ${this.MeasureNumber} could not be drawn.\n voice entry had less than two notes, arpeggio is likely between voice entries, not currently supported in Vexflow.`)}this.vfVoices[e.VoiceId].addTickable(t.vfStaveNote)}else this.vfVoices[e.VoiceId].addTickable(t.vfStaveNote)}}}}e.VexFlowTabMeasure=l},function(t,e,i){var n=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[i]}})}:function(t,e,i,n){void 0===n&&(n=i),t[n]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||e.hasOwnProperty(i)||n(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),s(i(3),e),s(i(55),e),s(i(94),e),s(i(38),e),s(i(37),e),s(i(64),e),s(i(103),e),s(i(104),e),s(i(105),e),s(i(65),e)},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.MultiExpressionEntry=e.MultiExpression=void 0;const n=i(0),s=i(38),r=i(32),o=i(64),a=i(65),l=i(3),h=i(21);e.MultiExpression=class{constructor(t,e){this.unknownList=[],this.moodList=[],this.expressions=[],this.sourceMeasure=t,this.timestamp=e}get SourceMeasureParent(){return this.sourceMeasure}set SourceMeasureParent(t){this.sourceMeasure=t}get StaffNumber(){return this.staffNumber}set StaffNumber(t){this.staffNumber=t}get Timestamp(){return this.timestamp}set Timestamp(t){this.timestamp=t}get AbsoluteTimestamp(){return n.Fraction.plus(this.timestamp,this.sourceMeasure.AbsoluteTimestamp)}get InstantaneousDynamic(){return this.instantaneousDynamic}set InstantaneousDynamic(t){this.instantaneousDynamic=t}get EndingContinuousDynamic(){return this.endingContinuousDynamic}set EndingContinuousDynamic(t){this.endingContinuousDynamic=t}get StartingContinuousDynamic(){return this.startingContinuousDynamic}set StartingContinuousDynamic(t){this.startingContinuousDynamic=t}get MoodList(){return this.moodList}get UnknownList(){return this.unknownList}get EntriesList(){return this.expressions}get OctaveShiftStart(){return this.octaveShiftStart}set OctaveShiftStart(t){this.octaveShiftStart=t}get OctaveShiftEnd(){return this.octaveShiftEnd}set OctaveShiftEnd(t){this.octaveShiftEnd=t}get CombinedExpressionsText(){return this.combinedExpressionsText}set CombinedExpressionsText(t){this.combinedExpressionsText=t}getPlacementOfFirstEntry(){let t=l.PlacementEnum.Above;return this.expressions.length>0&&(this.expressions[0].expression instanceof s.InstantaneousDynamicExpression||this.expressions[0].expression instanceof r.ContinuousDynamicExpression||this.expressions[0].expression instanceof o.MoodExpression||this.expressions[0].expression instanceof a.UnknownExpression)&&(t=this.expressions[0].expression.Placement),t}getFontstyleOfFirstEntry(){var t;let e=h.FontStyles.Regular;return this.expressions.length>0&&(this.expressions[0].expression instanceof r.ContinuousDynamicExpression||this.expressions[0].expression instanceof o.MoodExpression?e=h.FontStyles.Italic:this.expressions[0].expression instanceof a.UnknownExpression&&(e=null!==(t=this.expressions[0].expression.fontStyle)&&void 0!==t?t:h.FontStyles.Regular)),e}addExpression(t,e){t instanceof s.InstantaneousDynamicExpression?(this.instantaneousDynamic&&this.removeExpressionFromEntryList(this.InstantaneousDynamic),this.instantaneousDynamic=t,this.instantaneousDynamic.ParentMultiExpression=this):t instanceof r.ContinuousDynamicExpression?this.startingContinuousDynamic=t:t instanceof o.MoodExpression?this.moodList.push(t):t instanceof a.UnknownExpression&&this.unknownList.push(t),this.addExpressionToEntryList(t,e)}CompareTo(t){return this.Timestamp.RealValue>t.Timestamp.RealValue?1:this.Timestamp.RealValue0&&(this.expressions[0].Expression instanceof s.InstantaneousTempoExpression||this.expressions[0].Expression instanceof a.ContinuousTempoExpression)&&(t=this.expressions[0].Expression.Placement),t}getFontstyleOfFirstEntry(){let t=o.FontStyles.Regular;return this.expressions[0].Expression instanceof s.InstantaneousTempoExpression?t=o.FontStyles.Bold:this.expressions[0].Expression instanceof a.ContinuousTempoExpression&&(t=o.FontStyles.Italic),t}addExpression(t,e){if(this.checkIfAlreadyExists(t))return;t instanceof s.InstantaneousTempoExpression?this.instantaneousTempo=t:t instanceof a.ContinuousTempoExpression&&(this.continuousTempo=t);const i=new l;i.prefix=e,i.Expression=t,i.label=t.Label,this.expressions.push(i)}CompareTo(t){return this.Timestamp.RealValue>t.Timestamp.RealValue?1:this.Timestamp.RealValue1)return t[this.measureListIndex-1]}get Rules(){return this.rules}get VerticalMeasureList(){return this.verticalMeasureList}set VerticalMeasureList(t){this.verticalMeasureList=t}get TempoInBPM(){return this.tempoInBPM}set TempoInBPM(t){this.tempoInBPM=t}findOrCreateStaffEntry(t,e,i){let n,o;for(const e of this.verticalSourceStaffEntryContainers)if(e.Timestamp.Equals(t)){n=e;break}if(n)return n.StaffEntries[e]?o=n.StaffEntries[e]:(o=new r.SourceStaffEntry(n,i),n.StaffEntries[e]=o),{createdNewContainer:!1,staffEntry:o};const a=this.verticalSourceStaffEntryContainers[this.verticalSourceStaffEntryContainers.length-1];if(0===this.verticalSourceStaffEntryContainers.length||a.Timestamp.lt(t)){const n=new s.VerticalSourceStaffEntryContainer(this,t.clone(),this.completeNumberOfStaves);this.verticalSourceStaffEntryContainers.push(n),o=new r.SourceStaffEntry(n,i),n.StaffEntries[e]=o}else for(let n=this.verticalSourceStaffEntryContainers.length-1;n>=0;n--){if(this.verticalSourceStaffEntryContainers[n].Timestamp.lt(t)){const a=new s.VerticalSourceStaffEntryContainer(this,t.clone(),this.completeNumberOfStaves);this.verticalSourceStaffEntryContainers.splice(n+1,0,a),o=new r.SourceStaffEntry(a,i),a.StaffEntries[e]=o;break}if(0===n){const a=new s.VerticalSourceStaffEntryContainer(this,t.clone(),this.completeNumberOfStaves);this.verticalSourceStaffEntryContainers.splice(n,0,a),o=new r.SourceStaffEntry(a,i),a.StaffEntries[e]=o;break}}return{createdNewContainer:!0,staffEntry:o}}findOrCreateVoiceEntry(t,e){let i,n=!1;for(const n of t.VoiceEntries)if(n.ParentVoice===e){i=n;break}return i||(i=new a.VoiceEntry(t.Timestamp,e,t),n=!0),{createdVoiceEntry:n,voiceEntry:i}}getPreviousSourceStaffEntryFromIndex(t,e){for(let i=e-1;i>=0;i--)if(this.verticalSourceStaffEntryContainers[i][t])return this.verticalSourceStaffEntryContainers[i][t]}getVerticalContainerIndexByTimestamp(t){for(let e=0,i=this.VerticalSourceStaffEntryContainers.length;e=0;e--){const t=this.verticalSourceStaffEntryContainers[e][r+s];if(void 0!==t&&t.hasTie()&&i.lt(n.Fraction.plus(t.Timestamp,t.calculateMaxNoteLength()))){i=n.Fraction.plus(t.Timestamp,t.calculateMaxNoteLength());break}}}s.push(i)}for(let t=0,e=s.length;t0)return!0}return!1}beginsWithLineRepetition(){for(let t=0,e=this.FirstRepetitionInstructions.length;t=0&&(e=this.verticalSourceStaffEntryContainers[i].StaffEntries[t],!e);i--);return e}canBeReducedToMultiRest(){var t,e;if(!this.allRests||this.hasLyrics||this.hasMoodExpressions||this.tempoExpressions.length>0)return!1;for(const t of this.staffLinkedExpressions)if(t.length>0)return!1;for(const t of this.lastInstructionsStaffEntries)for(let e=0,i=null==t?void 0:t.Instructions.length;ei.load(t)),(t=>{throw m.default.debug(t),new Error("OpenSheetMusicDisplay: Invalid MXL file")}));if(""===e.substr(0,3))return m.default.debug("[OSMD] UTF with BOM detected, truncate first three bytes and pass along: "+e),i.load(e.substr(3));let n=e;if(/^\s/.test(n)&&(n=n.trim()),n.substr(0,6).includes("i.load(t)),(t=>{throw t}));console.error("[OSMD] osmd.load(string): Could not process string. Did not find this.rules.MaxPageToDrawNumber)break;const n=this.createBackend(this.backendType,i),s=" exceeds CanvasBackend limit of 32767. Cutting off score.";n.getOSMDBackendType()===g.BackendType.Canvas&&e>32767&&(m.default.warn("[OSMD] Warning: width of "+e+s),e=32767),this.rules.PageFormat&&!this.rules.PageFormat.IsUndefined?t=e/this.rules.PageFormat.aspectRatio:(t=i.PositionAndShape.Size.height,t+=this.rules.PageBottomMargin,t+=this.rules.CompactMode?this.rules.PageTopMarginNarrow:this.rules.PageTopMargin,this.rules.RenderTitle&&(t+=this.rules.TitleTopDistance),t*=10*this.zoom),n.getOSMDBackendType()===g.BackendType.Canvas&&t>32767&&(m.default.warn("[OSMD] Warning: height of "+t+s),t=Math.min(t,32767)),n.resize(e,t),n.clear(),this.drawer.Backends.push(n),this.graphic.drawer=this.drawer}}exportSVG(){var t;for(const e of null===(t=this.drawer)||void 0===t?void 0:t.Backends)e instanceof c.SvgVexFlowBackend&&e.export()}IsReadyToRender(){return void 0!==this.graphic}clear(){this.drawer.clear(),this.reset()}setOptions(t){if(this.rules||(this.rules=new y.EngravingRules),this.drawingParameters||(this.drawingParameters=new b.DrawingParameters,this.drawingParameters.Rules=this.rules),null==t)return void m.default.warn("warning: osmd.setOptions() called without an options parameter, has no effect.\nexample usage: osmd.setOptions({drawCredits: false, drawPartNames: false})");t.drawingParameters&&(this.drawingParameters.DrawingParametersEnum=b.DrawingParametersEnum[t.drawingParameters.toLowerCase()]);let e=!this.drawer||!this.drawer.Backends||this.drawer.Backends.length<1;if(void 0!==t.backend){const i=g.OSMDOptions.BackendTypeFromString(t.backend);e=e||this.backendType!==i,this.backendType=i}this.needBackendUpdate=e,void 0!==t.autoBeam&&(this.rules.AutoBeamNotes=t.autoBeam);const i=t.autoBeamOptions;if(i&&(void 0===i.maintain_stem_directions&&(i.maintain_stem_directions=!1),this.rules.AutoBeamOptions=i,i.groups&&i.groups.length))for(const t of i.groups)if(2!==t.length)throw new Error("Each fraction in autoBeamOptions.groups must be of length 2, e.g. [3,4] for beaming three fourths");void 0!==t.percussionOneLineCutoff&&(this.rules.PercussionOneLineCutoff=t.percussionOneLineCutoff),0!==this.rules.PercussionOneLineCutoff&&void 0!==t.percussionForceVoicesOneLineCutoff&&(this.rules.PercussionForceVoicesOneLineCutoff=t.percussionForceVoicesOneLineCutoff),void 0!==t.alignRests&&(this.rules.AlignRests=t.alignRests),void 0!==t.coloringMode&&this.setColoringMode(t),void 0!==t.coloringEnabled&&(this.rules.ColoringEnabled=t.coloringEnabled),void 0!==t.colorStemsLikeNoteheads&&(this.rules.ColorStemsLikeNoteheads=t.colorStemsLikeNoteheads),t.disableCursor&&(this.drawingParameters.drawCursors=!1),t.drawHiddenNotes&&(this.drawingParameters.drawHiddenNotes=!0),void 0!==t.drawCredits&&(this.drawingParameters.DrawCredits=t.drawCredits),void 0!==t.drawComposer&&(this.drawingParameters.DrawComposer=t.drawComposer),void 0!==t.drawTitle&&(this.drawingParameters.DrawTitle=t.drawTitle),void 0!==t.drawSubtitle&&(this.drawingParameters.DrawSubtitle=t.drawSubtitle),void 0!==t.drawLyricist&&(this.drawingParameters.DrawLyricist=t.drawLyricist),void 0!==t.drawMetronomeMarks&&(this.rules.MetronomeMarksDrawn=t.drawMetronomeMarks),void 0!==t.drawPartNames&&(this.drawingParameters.DrawPartNames=t.drawPartNames,t.drawPartAbbreviations||(this.rules.RenderPartAbbreviations=t.drawPartNames)),void 0!==t.drawPartAbbreviations&&(this.rules.RenderPartAbbreviations=t.drawPartAbbreviations),!1===t.drawFingerings&&(this.rules.RenderFingerings=!1),void 0!==t.drawMeasureNumbers&&(this.rules.RenderMeasureNumbers=t.drawMeasureNumbers),t.drawMeasureNumbersOnlyAtSystemStart&&(this.rules.RenderMeasureNumbersOnlyAtSystemStart=t.drawMeasureNumbersOnlyAtSystemStart),void 0!==t.drawLyrics&&(this.rules.RenderLyrics=t.drawLyrics),void 0!==t.drawTimeSignatures&&(this.rules.RenderTimeSignatures=t.drawTimeSignatures),void 0!==t.drawSlurs&&(this.rules.RenderSlurs=t.drawSlurs),void 0!==t.measureNumberInterval&&(this.rules.MeasureNumberLabelOffset=t.measureNumberInterval),void 0!==t.useXMLMeasureNumbers&&(this.rules.UseXMLMeasureNumbers=t.useXMLMeasureNumbers),void 0!==t.fingeringPosition&&(this.rules.FingeringPosition=S.AbstractExpression.PlacementEnumFromString(t.fingeringPosition)),void 0!==t.fingeringInsideStafflines&&(this.rules.FingeringInsideStafflines=t.fingeringInsideStafflines),void 0!==t.newSystemFromXML&&(this.rules.NewSystemAtXMLNewSystemAttribute=t.newSystemFromXML),void 0!==t.newPageFromXML&&(this.rules.NewPageAtXMLNewPageAttribute=t.newPageFromXML),void 0!==t.fillEmptyMeasuresWithWholeRest&&(this.rules.FillEmptyMeasuresWithWholeRest=t.fillEmptyMeasuresWithWholeRest),void 0!==t.followCursor&&(this.FollowCursor=t.followCursor),void 0!==t.setWantedStemDirectionByXml&&(this.rules.SetWantedStemDirectionByXml=t.setWantedStemDirectionByXml),t.defaultColorNotehead&&(this.rules.DefaultColorNotehead=t.defaultColorNotehead),t.defaultColorRest&&(this.rules.DefaultColorRest=t.defaultColorRest),t.defaultColorStem&&(this.rules.DefaultColorStem=t.defaultColorStem),t.defaultColorLabel&&(this.rules.DefaultColorLabel=t.defaultColorLabel),t.defaultColorTitle&&(this.rules.DefaultColorTitle=t.defaultColorTitle),t.defaultFontFamily&&(this.rules.DefaultFontFamily=t.defaultFontFamily),t.defaultFontStyle&&(this.rules.DefaultFontStyle=t.defaultFontStyle),t.drawUpToMeasureNumber&&(this.rules.MaxMeasureToDrawIndex=t.drawUpToMeasureNumber-1),t.drawFromMeasureNumber&&(this.rules.MinMeasureToDrawIndex=t.drawFromMeasureNumber-1),t.drawUpToPageNumber&&(this.rules.MaxPageToDrawNumber=t.drawUpToPageNumber),t.drawUpToSystemNumber&&(this.rules.MaxSystemToDrawNumber=t.drawUpToSystemNumber),t.tupletsRatioed&&(this.rules.TupletsRatioed=!0),t.tupletsBracketed&&(this.rules.TupletsBracketed=!0),t.tripletsBracketed&&(this.rules.TripletsBracketed=!0),t.autoResize?(this.resizeHandlerAttached||this.autoResize(),this.autoResizeEnabled=!0):!1===t.autoResize&&(this.autoResizeEnabled=!1),void 0!==t.pageFormat&&this.setPageFormat(t.pageFormat),void 0!==t.pageBackgroundColor&&(this.rules.PageBackgroundColor=t.pageBackgroundColor),void 0!==t.renderSingleHorizontalStaffline&&(this.rules.RenderSingleHorizontalStaffline=t.renderSingleHorizontalStaffline),void 0!==t.spacingFactorSoftmax&&(this.rules.SoftmaxFactorVexFlow=t.spacingFactorSoftmax),void 0!==t.spacingBetweenTextLines&&(this.rules.SpacingBetweenTextLines=t.spacingBetweenTextLines),void 0!==t.stretchLastSystemLine&&(this.rules.StretchLastSystemLine=t.stretchLastSystemLine),void 0!==t.autoGenerateMutipleRestMeasuresFromRestMeasures&&(this.rules.AutoGenerateMutipleRestMeasuresFromRestMeasures=t.autoGenerateMutipleRestMeasuresFromRestMeasures)}setColoringMode(t){if(t.coloringMode===b.ColoringModes.XML)return void(this.rules.ColoringMode=b.ColoringModes.XML);const e=[E.NoteEnum.C,E.NoteEnum.D,E.NoteEnum.E,E.NoteEnum.F,E.NoteEnum.G,E.NoteEnum.A,E.NoteEnum.B,-1];let i;if(t.coloringMode===b.ColoringModes.CustomColorSet){if(!t.coloringSetCustom||8!==t.coloringSetCustom.length)throw new Error("Invalid amount of colors: With coloringModes.customColorSet, you have to provide a coloringSetCustom parameter with 8 strings (C to B, rest note).");for(const e of t.coloringSetCustom)if(!/^\#[0-9a-fA-F]{6}$/.test(e))throw new Error("One of the color strings in options.coloringSetCustom was not a valid HTML Hex color:\n"+e);i=t.coloringSetCustom}else if(t.coloringMode===b.ColoringModes.AutoColoring){i=[];const t=Object.keys(x.AutoColorSet);for(let e=0;e{}),(()=>{var e;(null===(e=this.graphic)||void 0===e?void 0:e.GetCalculator)instanceof r.VexFlowMusicSheetCalculator&&(this.graphic.GetCalculator.beamsNeedUpdate=!0),t.IsReadyToRender()&&t.render()}))}handleResize(t,e){let i,n;const s=this;function r(){s.AutoResizeEnabled&&(i=(new Date).getTime(),n||(t(),i=(new Date).getTime(),n=window.setTimeout(o,200)))}function o(){n=void 0,window.clearTimeout(n),(new Date).getTime()-i<200?n=window.setTimeout(o,200):e()}window.attachEvent?window.attachEvent("onresize",r):window.addEventListener("resize",r),this.resizeHandlerAttached=!0,window.setTimeout(t,0),window.setTimeout(e,1)}enableOrDisableCursor(t){var e,i,n,s;if(this.drawingParameters.drawCursors=t,t){const t=null===(e=this.cursor)||void 0===e?void 0:e.Hidden,r=null===(i=this.cursor)||void 0===i?void 0:i.Iterator;null===(n=this.cursor)||void 0===n||n.hide();let o=null===(s=this.drawer)||void 0===s?void 0:s.Backends[0];if(o&&this.rules.RestoreCursorAfterRerender&&this.cursor){const t=this.cursor.updateCurrentPage();o=this.drawer.Backends[t-1]}o&&o.getRenderElement()&&(this.cursor=new d.Cursor(o.getRenderElement(),this)),this.sheet&&this.graphic&&this.cursor&&this.cursor.init(this.sheet.MusicPartManager,this.graphic),this.rules.RestoreCursorAfterRerender&&(this.cursor.hidden=t,r&&(this.cursor.iterator=r,this.cursor.update()))}else{if(!this.cursor)return;this.cursor.hide()}}createBackend(t,e){let i;return i=void 0===t||t===g.BackendType.SVG?new c.SvgVexFlowBackend(this.rules):new u.CanvasVexFlowBackend(this.rules),i.graphicalMusicPage=e,i.initialize(this.container,this.zoom),i}static StringToPageFormat(t){let e=y.PageFormat.UndefinedPageFormat;if(t.match("^[0-9]+x[0-9]+$")){const i=t.split("x"),n=Number.parseInt(i[0],10),s=Number.parseInt(i[1],10);n>0&&n<32768&&s>0&&s<32768&&(e=new y.PageFormat(n,s,`customPageFormat${t}`))}return t=(t=(t=t.replace(" ","_")).replace("Landscape","L")).replace("Portrait","P"),_.PageFormatStandards.hasOwnProperty(t)?(e=_.PageFormatStandards[t],e):e}setPageFormat(t){const e=_.StringToPageFormat(t);this.needBackendUpdate=!e.Equals(this.rules.PageFormat),this.rules.PageFormat=e}setCustomPageFormat(t,e){if(t>0&&e>0){const i=new y.PageFormat(t,e);this.rules.PageFormat=i}}set DrawSkyLine(t){this.drawSkyLine=t,this.drawer&&(this.drawer.skyLineVisible=t)}get DrawSkyLine(){return this.drawer.skyLineVisible}set DrawBottomLine(t){this.drawBottomLine=t,this.drawer&&(this.drawer.bottomLineVisible=t)}get DrawBottomLine(){return this.drawer.bottomLineVisible}set DrawBoundingBox(t){this.setDrawBoundingBox(t,!0)}get DrawBoundingBox(){return this.drawBoundingBox}setDrawBoundingBox(t,e=!1){this.drawBoundingBox=t,this.drawer&&(this.drawer.drawableBoundingBoxElement=t),e&&this.render()}get AutoResizeEnabled(){return this.autoResizeEnabled}set AutoResizeEnabled(t){this.autoResizeEnabled=t}get Zoom(){return this.zoom}set Zoom(t){var e;this.zoom=t,this.zoomUpdated=!0,(null===(e=this.graphic)||void 0===e?void 0:e.GetCalculator)instanceof r.VexFlowMusicSheetCalculator&&(this.graphic.GetCalculator.beamsNeedUpdate=this.zoomUpdated)}set FollowCursor(t){this.followCursor=t}get FollowCursor(){return this.followCursor}set TransposeCalculator(t){l.MusicSheetCalculator.transposeCalculator=t}get TransposeCalculator(){return l.MusicSheetCalculator.transposeCalculator}get Sheet(){return this.sheet}get Drawer(){return this.drawer}get GraphicSheet(){return this.graphic}get DrawingParameters(){return this.drawingParameters}get EngravingRules(){return this.rules}get Version(){return this.version}}e.OpenSheetMusicDisplay=_,_.PageFormatStandards={A3_L:new y.PageFormat(420,297,"A3_L"),A3_P:new y.PageFormat(297,420,"A3_P"),A4_L:new y.PageFormat(297,210,"A4_L"),A4_P:new y.PageFormat(210,297,"A4_P"),A5_L:new y.PageFormat(210,148,"A5_L"),A5_P:new y.PageFormat(148,210,"A5_P"),A6_L:new y.PageFormat(148,105,"A6_L"),A6_P:new y.PageFormat(105,148,"A6_P"),Endless:y.PageFormat.UndefinedPageFormat,Letter_L:new y.PageFormat(279.4,215.9,"Letter_L"),Letter_P:new y.PageFormat(215.9,279.4,"Letter_P")}},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.AJAX=void 0,e.AJAX=class{static ajax(t,e=9e3){let i;const n=t.indexOf(".mxl")>-1?"text/plain; charset=x-user-defined":"application/xml";if(XMLHttpRequest)i=new XMLHttpRequest;else{if(!ActiveXObject)return Promise.reject(new Error("XMLHttp not supported."));i=new ActiveXObject("Microsoft.XMLHTTP")}return i.timeout=e,new Promise(((e,s)=>{i.onreadystatechange=()=>{i.readyState===XMLHttpRequest.DONE&&(200===i.status||0===i.status&&i.responseText?e(i.responseText):s(new Error("Could not retrieve requested URL "+i.status)))},i.ontimeout=t=>{s(new Error("Server request Timeout"))},i.overrideMimeType(n),i.open("GET",t,!0),i.send()}))}}},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.Cursor=void 0;const n=i(0);e.Cursor=class{constructor(t,e){this.hidden=!0,this.currentPageNumber=1,this.container=t,this.openSheetMusicDisplay=e,this.rules=this.openSheetMusicDisplay.EngravingRules;let i=0;for(this.cursorElementId="cursorImg-0";document.getElementById(this.cursorElementId);)i++,this.cursorElementId=`cursorImg-${i}`;const n=document.createElement("img");n.id=this.cursorElementId,n.style.position="absolute",n.style.zIndex="-1",this.cursorElement=n,this.container.appendChild(n)}init(t,e){this.manager=t,this.graphic=e,this.reset(),this.hidden=!0,this.hide()}show(){this.hidden=!1,this.resetIterator(),this.update()}resetIterator(){if(!this.openSheetMusicDisplay.Sheet||!this.openSheetMusicDisplay.Sheet.SourceMeasures)return void console.log("OSMD.Cursor.resetIterator(): sheet or measures were null/undefined.");const t=this.openSheetMusicDisplay.Sheet.SourceMeasures.length-1;let e=this.rules.MinMeasureToDrawIndex;e=Math.min(e,t);let i=this.rules.MaxMeasureToDrawIndex;if(i=Math.min(i,t),this.openSheetMusicDisplay.Sheet&&this.openSheetMusicDisplay.Sheet.SourceMeasures.length>e&&(this.openSheetMusicDisplay.Sheet.SelectionStart=this.openSheetMusicDisplay.Sheet.SourceMeasures[e].AbsoluteTimestamp),this.openSheetMusicDisplay.Sheet&&this.openSheetMusicDisplay.Sheet.SourceMeasures.length>i){const t=this.openSheetMusicDisplay.Sheet.SourceMeasures[i];this.openSheetMusicDisplay.Sheet.SelectionEnd=n.Fraction.plus(t.AbsoluteTimestamp,t.Duration)}this.iterator=this.manager.getIterator()}getStaffEntryFromVoiceEntry(t){const e=t.ParentSourceStaffEntry.VerticalContainerParent.ParentMeasure.measureListIndex,i=t.ParentSourceStaffEntry.ParentStaff.idInMusicSheet;return this.graphic.findGraphicalStaffEntryFromMeasureList(i,e,t.ParentSourceStaffEntry)}update(){if(this.hidden||void 0===this.hidden||null===this.hidden)return;this.updateCurrentPage();const t=this.iterator,e=t.CurrentVisibleVoiceEntries();if(t.EndReached||!t.CurrentVoiceEntries||0===e.length)return;let i,n=0,s=0,r=0;if(t.CurrentMeasure.isReducedToMultiRest){const e=this.graphic.findGraphicalMeasure(t.CurrentMeasureIndex,0),s=e.parentSourceMeasure.multipleRestMeasures,r=t.CurrentMeasure.multipleRestMeasureNumber/(s+1),o=e.PositionAndShape.Size.width-e.beginInstructionsWidth;n=e.PositionAndShape.AbsolutePosition.x+e.beginInstructionsWidth+r*o,i=e.ParentMusicSystem}else{const t=e.map((t=>this.getStaffEntryFromVoiceEntry(t))).sort(((t,e)=>{var i,n,s,r;return(null===(n=null===(i=null==t?void 0:t.PositionAndShape)||void 0===i?void 0:i.AbsolutePosition)||void 0===n?void 0:n.x)<=(null===(r=null===(s=null==e?void 0:e.PositionAndShape)||void 0===s?void 0:s.AbsolutePosition)||void 0===r?void 0:r.x)?-1:1}))[0];n=t.PositionAndShape.AbsolutePosition.x,i=t.parentMeasure.ParentMusicSystem}if(!i)return;s=i.PositionAndShape.AbsolutePosition.y+i.StaffLines[0].PositionAndShape.RelativePosition.y;const o=i.StaffLines[i.StaffLines.length-1];r=i.PositionAndShape.AbsolutePosition.y+o.PositionAndShape.RelativePosition.y+o.StaffHeight-s;const a=this.cursorElement;a.style.top=10*s*this.openSheetMusicDisplay.zoom+"px",a.style.left=10*(n-1.5)*this.openSheetMusicDisplay.zoom+"px",a.height=10*r*this.openSheetMusicDisplay.zoom;const l=30*this.openSheetMusicDisplay.zoom;if(l!==a.width&&(a.width=l,this.updateStyle(l)),this.openSheetMusicDisplay.FollowCursor){const t=this.cursorElement.getBoundingClientRect().top;this.cursorElement.scrollIntoView({behavior:t<1e3?"smooth":"auto",block:"center"})}this.cursorElement.style.display=""}hide(){this.cursorElement.style.display="none",this.hidden=!0}next(){this.iterator.moveToNextVisibleVoiceEntry(!1),this.update()}reset(){this.resetIterator(),this.update()}updateStyle(t,e){e||(e=this.rules.DefaultColorCursor);const i=document.createElement("canvas");i.width=this.cursorElement.width,i.height=1;const n=i.getContext("2d");n.globalAlpha=.5;const s=n.createLinearGradient(0,0,this.cursorElement.width,0);s.addColorStop(0,"white"),s.addColorStop(.2,e),s.addColorStop(.8,e),s.addColorStop(1,"white"),n.fillStyle=s,n.fillRect(0,0,t,1),this.cursorElement.src=i.toDataURL("image/png")}get Iterator(){return this.iterator}get Hidden(){return this.hidden}VoicesUnderCursor(t){return this.iterator.CurrentVisibleVoiceEntries(t)}NotesUnderCursor(t){const e=this.VoicesUnderCursor(t),i=[];return e.forEach((t=>{i.push.apply(i,t.Notes)})),i}updateCurrentPage(){const t=this.iterator.currentTimeStamp;for(const e of this.graphic.MusicPages)if(e.MusicSystems.last().GetSystemsLastTimeStamp().gt(t)){const t=e.PageNumber;return t!==this.currentPageNumber&&(this.container.removeChild(this.cursorElement),this.container=document.getElementById("osmdCanvasPage"+t),this.container.appendChild(this.cursorElement)),this.currentPageNumber=t}return 1}}},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.AClassHierarchyTrackable=void 0,e.AClassHierarchyTrackable=class{isInstanceOfClass(t){let e=this.constructor.prototype;for(;e;){if(t===e.constructor.name)return!0;e=e.__proto__}return!1}}},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.VerticalGraphicalStaffEntryContainer=void 0,e.VerticalGraphicalStaffEntryContainer=class{constructor(t,e){this.staffEntries=[],this.absoluteTimestamp=e,this.staffEntries=new Array(t)}get Index(){return this.index}set Index(t){this.index=t}get AbsoluteTimestamp(){return this.absoluteTimestamp}get StaffEntries(){return this.staffEntries}set StaffEntries(t){this.staffEntries=t}static compareByTimestamp(t,e){const i=t.absoluteTimestamp.RealValue,n=e.absoluteTimestamp.RealValue;return in?1:0}getFirstNonNullStaffEntry(){for(let t=0,e=this.staffEntries.length;t0){if(this.rules.MaxSystemToDrawNumber===this.musicSystems.length)return this.finalizeCurrentSystem(this.measureList[this.measureList.length-1],!this.rules.StretchLastSystemLine,!1),this.musicSystems;this.finalizeCurrentAndCreateNewSystem(this.measureList[this.measureList.length-1],!this.rules.StretchLastSystemLine,!1)}return this.musicSystems}calculateSystemYLayout(){for(const t of this.musicSystems)this.optimizeDistanceBetweenStaffLines(t);this.calculateMusicSystemsRelativePositions()}setMeasureWidth(t,e,i,n){for(let s=0,r=t.length;s0&&(r.beginInstructionsWidth=i),n>0&&(r.endInstructionsWidth=n)}}finalizeCurrentAndCreateNewSystem(t,e=!1,i=!0,n=!1){this.finalizeCurrentSystem(t,e,i,n),this.currentSystemParams=new p,void 0!==t&&this.measureListIndex=1){const e=this.currentSystemParams.currentSystem.GraphicalMeasures[this.currentSystemParams.currentSystem.GraphicalMeasures.length-1],i=t[t.length-1];let n=0;i.endLine===h.SystemLinesEnum.DotsBoldBoldDots&&(i.endLine=h.SystemLinesEnum.DotsThinBold,n=e[0].getLineWidth(h.SystemLinesEnum.DotsBoldBoldDots)/2-e[0].getLineWidth(h.SystemLinesEnum.DotsThinBold)),this.currentSystemParams.currentSystemFixWidth-=n;for(let t=0,i=e.length;t1){r=!0;break}let o=0;for(let e=0;e=0){const e=null===(l=this.measureList[i][0])||void 0===l?void 0:l.parentSourceMeasure;(null==e?void 0:e.ImplicitMeasure)&&(null==e?void 0:e.RhythmPrinted)&&(t=!1)}t&&(e.addRhythmAtBegin(u),e.parentSourceMeasure.RhythmPrinted=!0,m=!0)}return(f||p||m)&&(d+=e.beginInstructionsWidth,m&&(d+=this.rules.RhythmRightMargin)),d}addInstructionsAtMeasureEnd(t,e,i){if(!t||!t.Instructions||0===t.Instructions.length)return 0;for(let n=0,s=t.Instructions.length;n0&&(this.currentSystemParams.systemMeasures.push({beginLine:h.SystemLinesEnum.None,endLine:h.SystemLinesEnum.None}),this.currentSystemParams.currentWidth+=n,this.currentSystemParams.currentSystemFixWidth+=n)}addExtraInstructionMeasure(t,e,i){const n=this.currentSystemParams.currentSystem,s=c.MusicSheetCalculator.symbolFactory.createExtraGraphicalMeasure(n.StaffLines[t]);e&&s.addKeyAtBegin(e,this.activeKeys[t],this.activeClefs[t]),void 0!==i&&i.PrintObject&&s.addRhythmAtBegin(i),s.PositionAndShape.BorderLeft=0,s.PositionAndShape.BorderTop=0,s.PositionAndShape.BorderBottom=this.rules.StaffHeight;const r=this.rules.MeasureLeftMargin+s.beginInstructionsWidth+this.rules.MeasureRightMargin;return s.PositionAndShape.BorderRight=r,n.StaffLines[t].Measures.push(s),r}addStaveMeasuresToSystem(t){if(t[0]){const e=[];for(let i=0;i1){const e=Math.min(this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length-1,t.measureListIndex+t.multipleRestMeasures-1);t=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures[e]}}finally{}return this.nextMeasureBeginsLineRepetition()&&this.thisMeasureEndsLineRepetition()?h.SystemLinesEnum.DotsBoldBoldDots:this.thisMeasureEndsLineRepetition()?h.SystemLinesEnum.DotsThinBold:this.nextMeasureHasKeyInstructionChange()||this.thisMeasureEndsWordRepetition()||this.nextMeasureBeginsWordRepetition()?h.SystemLinesEnum.DoubleThin:t&&void 0!==t.endingBarStyleEnum?t.endingBarStyleEnum:h.SystemLinesEnum.SingleThin}getLineWidth(t,e,i){let n=t.getLineWidth(e);return e===h.SystemLinesEnum.DotsBoldBoldDots&&(n/=2),i&&e===h.SystemLinesEnum.BoldThinDots&&(n+=this.rules.DistanceBetweenLastInstructionAndRepetitionBarline),n}previousMeasureEndsLineRepetition(){if(0===this.measureListIndex)return!1;for(let t=0,e=this.measureList[this.measureListIndex-1].length;t=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length||!this.measureList[t])return!1;for(let e=0,i=this.measureList[t].length;e=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length||t>this.measureList.length-1)return!1;for(let e=0,i=this.measureList[t].length;ethis.rules.PageHeight-this.rules.PageBottomMargin&&(n++,n<=4&&console.log(`warning: could not fit a single system on page ${t.PageNumber} and measure number ${i.GraphicalMeasures[0][0].MeasureNumber}.\n The PageFormat may be too small for this sheet."\n Will not give further warnings for all pages, only total.`))}else{const n=this.musicSystems[s-1],r=n.StaffLines[n.StaffLines.length-1],o=r.PositionAndShape;let l=this.findRequiredDistanceWithSkyBottomLine(n,i);l+=this.rules.MinSkyBottomDistBetweenSystems,l=Math.max(l,this.rules.MinimumDistanceBetweenSystems+r.StaffHeight);const h=e+o.RelativePosition.y+l,c=h+i.PositionAndShape.BorderMarginBottom;if(this.rules.NewPageAtXMLNewPageAttribute&&n.breaksPage||!(c0&&console.log(`total amount of pages that couldn't fit a single music system: ${n} of ${t.PageNumber}`)}findRequiredDistanceWithSkyBottomLine(t,e){const i=t.StaffLines[t.StaffLines.length-1],n=e.StaffLines[0],s=i.BottomLine,r=n.SkyLine,o=i.PositionAndShape,a=n.PositionAndShape,l=1/this.rules.SamplingUnit;let h=0;for(let t=0;t=r.length)break;const n=Math.max(0,i-6),c=Math.min(r.length-1,i+6);let u=0;for(let t=n;t<=c;t++)u=Math.min(u,r[t]);const d=e-u;h=Math.max(d,h)}return 0===h&&(h=o.BorderBottom-a.BorderTop),h}};class p{constructor(){this.systemMeasures=[],this.systemMeasureIndex=0,this.currentWidth=0,this.currentSystemFixWidth=0,this.currentSystemVarWidth=0,this.maxLabelLength=0}IsSystemStartMeasure(){return 0===this.systemMeasureIndex}}e.SystemBuildParameters=p,e.MeasureBuildParameters=class{}},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.Clickable=void 0;const n=i(6);class s extends n.GraphicalObject{}e.Clickable=s},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.OctaveShiftParams=void 0,e.OctaveShiftParams=class{constructor(t,e,i){this.getOpenOctaveShift=t,this.getAbsoluteStartTimestamp=e,this.getAbsoluteEndTimestamp=i}}},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.AccidentalCalculator=void 0;const n=i(2),s=i(2),r=i(15),o=i(17);e.AccidentalCalculator=class{constructor(){this.keySignatureNoteAlterationsDict=new r.Dictionary,this.currentAlterationsComparedToKeyInstructionList=[],this.currentInMeasureNoteAlterationsDict=new r.Dictionary}get ActiveKeyInstruction(){return this.activeKeyInstruction}set ActiveKeyInstruction(t){this.activeKeyInstruction=t,this.reactOnKeyInstructionChange()}doCalculationsAtEndOfMeasure(){this.currentInMeasureNoteAlterationsDict.clear(),this.currentAlterationsComparedToKeyInstructionList.clear();for(const t of this.keySignatureNoteAlterationsDict.keys())this.currentInMeasureNoteAlterationsDict.setValue(t,this.keySignatureNoteAlterationsDict.getValue(t))}checkAccidental(t,e){if(!e)return;const i=e.FundamentalNote+12*e.Octave,r=this.currentAlterationsComparedToKeyInstructionList.indexOf(i)>=0;if(this.currentInMeasureNoteAlterationsDict.containsKey(i)){if(r&&this.currentAlterationsComparedToKeyInstructionList.splice(this.currentAlterationsComparedToKeyInstructionList.indexOf(i),1),this.currentInMeasureNoteAlterationsDict.getValue(i)!==e.AccidentalHalfTones){this.keySignatureNoteAlterationsDict.containsKey(i)&&this.keySignatureNoteAlterationsDict.getValue(i)!==e.AccidentalHalfTones?(this.currentAlterationsComparedToKeyInstructionList.push(i),this.currentInMeasureNoteAlterationsDict.setValue(i,e.AccidentalHalfTones)):e.Accidental!==n.AccidentalEnum.NONE&&this.currentInMeasureNoteAlterationsDict.remove(i);const r=this.currentInMeasureNoteAlterationsDict.getValue(i);e.Accidental===n.AccidentalEnum.NONE&&(e=.5===Math.abs(r)?new s.Pitch(e.FundamentalNote,e.Octave,n.AccidentalEnum.NONE):new s.Pitch(e.FundamentalNote,e.Octave,n.AccidentalEnum.NATURAL)),o.MusicSheetCalculator.symbolFactory.addGraphicalAccidental(t,e)}}else e.Accidental!==n.AccidentalEnum.NONE?(r||this.currentAlterationsComparedToKeyInstructionList.push(i),this.currentInMeasureNoteAlterationsDict.setValue(i,e.AccidentalHalfTones),o.MusicSheetCalculator.symbolFactory.addGraphicalAccidental(t,e)):r&&(e=new s.Pitch(e.FundamentalNote,e.Octave,n.AccidentalEnum.NATURAL),this.currentAlterationsComparedToKeyInstructionList.splice(this.currentAlterationsComparedToKeyInstructionList.indexOf(i),1),o.MusicSheetCalculator.symbolFactory.addGraphicalAccidental(t,e))}reactOnKeyInstructionChange(){const t=this.activeKeyInstruction.AlteratedNotes;let e;e=this.activeKeyInstruction.Key>0?n.AccidentalEnum.SHARP:n.AccidentalEnum.FLAT,this.keySignatureNoteAlterationsDict.clear(),this.currentAlterationsComparedToKeyInstructionList.length=0;for(let i=-9;i<9;i++)for(let n=0;n-1&&this.parent.MusicSystems.splice(t,1)}this.parent=t,this.boundingBox.Parent=t.PositionAndShape}get NextSystem(){const t=this.Parent.MusicSystems.indexOf(this);return t!==this.Parent.MusicSystems.length?this.Parent.MusicSystems[t+1]:void 0}get StaffLines(){return this.staffLines}get GraphicalMeasures(){return this.graphicalMeasures}get MeasureNumberLabels(){return this.measureNumberLabels}get Labels(){return this.labels.values()}get ObjectsToRedraw(){return this.objectsToRedraw}get InstrumentBrackets(){return this.instrumentBrackets}get GroupBrackets(){return this.groupBrackets}get GraphicalMarkedAreas(){return this.graphicalMarkedAreas}get GraphicalComments(){return this.graphicalComments}get SystemLines(){return this.systemLines}get Id(){return this.id}createSystemLeftLine(t,e,i){let n=-t/2;i&&(n=this.maxLabelLength+e-t/2);const s=this.staffLines[0].Measures[0];let r;this.staffLines.length>1&&(r=this.staffLines[this.staffLines.length-1].Measures[0]);const o=this.createSystemLine(n,t,c.SystemLinesEnum.SingleThin,d.SystemLinePosition.MeasureBegin,this,s,r);this.SystemLines.push(o),o.PositionAndShape.RelativePosition=new h.PointF2D(n,0),o.PositionAndShape.BorderLeft=0,o.PositionAndShape.BorderRight=t,o.PositionAndShape.BorderTop=0,o.PositionAndShape.BorderBottom=this.boundingBox.Size.height,this.createLinesForSystemLine(o)}createVerticalLineForMeasure(t,e,i,n,s,r){const o=r.ParentStaffLine,a=new h.PointF2D(o.PositionAndShape.RelativePosition.x,o.PositionAndShape.RelativePosition.y),l=o.ParentStaff.ParentInstrument.Staves;if(o.ParentStaff===l[0]){let c;l.length>1&&(c=this.getBottomStaffLine(o).Measures[s]);const u=this.createSystemLine(t,e,i,n,this,r,c),d=a.x+t;u.PositionAndShape.RelativePosition=new h.PointF2D(d,0),u.PositionAndShape.BorderLeft=0,u.PositionAndShape.BorderRight=e,this.SystemLines.push(u)}}setYPositionsToVerticalLineObjectsAndCreateLines(t){}calculateBorders(t){}alignBeginInstructions(){}GetLeftBorderAbsoluteXPosition(){return this.StaffLines[0].PositionAndShape.AbsolutePosition.x+this.StaffLines[0].Measures[0].beginInstructionsWidth}GetRightBorderAbsoluteXPosition(){return this.StaffLines[0].PositionAndShape.AbsolutePosition.x+this.StaffLines[0].StaffLines[0].End.x}AddGraphicalMeasures(t){for(let e=0,i=t.length;e1){let t,e;for(let n=0,s=this.staffLines.length;nthis.maxLabelLength&&(this.maxLabelLength=i.PositionAndShape.Size.width,e=r)}this.updateMusicSystemStaffLineXPosition(e)}setMusicSystemLabelsYPosition(){this.labels.forEach(((t,e)=>{let i=0,n=0;for(let e=0;e0&&(e.PositionAndShape.RelativePosition=new h.PointF2D(0,i/n+2))}))}checkStaffEntriesForStaffEntryLink(){let t=!1,e=!1;for(let i=0;i=0;i--){if(e=t.InstrumentalGroups[i],!(e instanceof n.Instrument))return this.findLastVisibleInstrumentInInstrumentalGroup(e);if(!0===e.Visible)return e}}updateMusicSystemStaffLineXPosition(t){for(let e=0,i=this.StaffLines.length;e0&&this.drawDashes(e.LyricsDashes),e.LyricLines.length>0&&this.drawLyricLines(e.LyricLines,e));for(const e of t.SystemLines)this.drawSystemLineObject(e);if(t.Parent===t.Parent.Parent.MusicPages[0])for(const e of t.Labels)this.drawLabel(e,s.GraphicalLayers.Notes);for(const e of t.InstrumentBrackets)this.drawInstrumentBrace(e,t);for(const e of t.GroupBrackets)this.drawGroupBracket(e,t);if(!this.leadSheet)for(const e of t.MeasureNumberLabels)this.drawLabel(e,s.GraphicalLayers.Notes);for(const e of t.StaffLines)this.drawStaffLineSymbols(e);this.drawingParameters.drawMarkedAreas&&this.drawMarkedAreas(t),this.drawingParameters.drawComments&&this.drawComment(t)}activateSystemRendering(t,e,i,n){return!0}drawSystemLineObject(t){}drawStaffLine(t){for(const e of t.Measures)this.drawMeasure(e);this.rules.RenderLyrics&&t.LyricsDashes.length>0&&this.drawDashes(t.LyricsDashes),this.drawOctaveShifts(t),this.drawExpressions(t),this.skyLineVisible&&this.drawSkyLine(t),this.bottomLineVisible&&this.drawBottomLine(t)}drawLyricLines(t,e){e.LyricLines.forEach((t=>{t.Start.y+=e.PositionAndShape.AbsolutePosition.y,t.End.y+=e.PositionAndShape.AbsolutePosition.y,t.Start.x+=e.PositionAndShape.AbsolutePosition.x,t.End.x+=e.PositionAndShape.AbsolutePosition.x,this.drawGraphicalLine(t,this.rules.LyricUnderscoreLineWidth)}))}drawExpressions(t){}drawGraphicalLine(t,e,i="black"){return this.drawLine(t.Start,t.End,i,e)}drawLine(t,e,i="#FF0000FF",n){}drawDashes(t){t.forEach((t=>this.drawLabel(t,s.GraphicalLayers.Notes)))}drawOctaveShifts(t){}drawStaffLines(t){if(t.StaffLines){const e=t.PositionAndShape.AbsolutePosition;for(let i=0;i<5;i++)this.drawLineAsHorizontalRectangleWithOffset(t.StaffLines[i],e,s.GraphicalLayers.Notes)}}drawInstantaneousDynamic(t){throw new Error("not implemented")}drawContinuousDynamic(t){throw new Error("not implemented")}drawSymbol(t,e,i,n=1,r=s.GraphicalLayers.Notes){}get leadSheet(){return this.graphicalMusicSheet.LeadSheet}set leadSheet(t){this.graphicalMusicSheet.LeadSheet=t}drawPage(t){if(this.isVisible(t.PositionAndShape)){for(const e of t.MusicSystems)this.isVisible(e.PositionAndShape)&&this.drawMusicSystem(e);if(t===t.Parent.MusicPages[0])for(const e of t.Labels)this.drawLabel(e,s.GraphicalLayers.Notes);this.drawableBoundingBoxElement&&this.drawBoundingBoxes(t.PositionAndShape,0,this.drawableBoundingBoxElement)}}drawBoundingBoxes(t,e=0,i="all"){const n=t.DataObject.constructor.name;let s=!1;"all"===i?s=!0:"VexFlowStaffEntry"===i?s=t.DataObject instanceof m.VexFlowStaffEntry:"VexFlowMeasure"===i?s=t.DataObject instanceof m.VexFlowMeasure:"VexFlowGraphicalNote"===i?s=t.DataObject instanceof m.VexFlowGraphicalNote:"VexFlowVoiceEntry"===i?s=t.DataObject instanceof m.VexFlowVoiceEntry:"GraphicalLabel"===i?s=t.DataObject instanceof l.GraphicalLabel:"VexFlowStaffLine"===i?s=t.DataObject instanceof m.VexFlowStaffLine:"SystemLine"===i?s=t.DataObject instanceof d.SystemLine:"StaffLineActivitySymbol"===i?s=t.DataObject instanceof b.StaffLineActivitySymbol:"VexFlowContinuousDynamicExpression"===i&&(s=t.DataObject instanceof m.VexFlowContinuousDynamicExpression),(s||n===i)&&this.drawBoundingBox(t,void 0,!0,n,e),e++,t.ChildElements.forEach((t=>this.drawBoundingBoxes(t,e,i)))}drawBoundingBox(t,e,i=!1,n,u=0){let d=new o.RectangleF2D(t.AbsolutePosition.x+t.BorderMarginLeft,t.AbsolutePosition.y+t.BorderMarginTop,t.BorderMarginRight-t.BorderMarginLeft,t.BorderMarginBottom-t.BorderMarginTop);i&&(this.drawLineAsHorizontalRectangle(new r.GraphicalLine(new a.PointF2D(t.AbsolutePosition.x-1,t.AbsolutePosition.y),new a.PointF2D(t.AbsolutePosition.x+1,t.AbsolutePosition.y),.1,s.OutlineAndFillStyleEnum.BaseWritingColor,e),u-1),this.drawLineAsVerticalRectangle(new r.GraphicalLine(new a.PointF2D(t.AbsolutePosition.x,t.AbsolutePosition.y-1),new a.PointF2D(t.AbsolutePosition.x,t.AbsolutePosition.y+1),.1,s.OutlineAndFillStyleEnum.BaseWritingColor,e),u-1)),d=this.applyScreenTransformationForRect(d);const f=this.renderRectangle(d,s.GraphicalLayers.Background,u,e,.5);if(n){const t=new h.Label(n);this.renderLabel(new l.GraphicalLabel(t,.8,c.TextAlignmentEnum.CenterCenter,this.rules),u,d.width,d.height,d.height,new a.PointF2D(d.x,d.y+12))}return f}drawMarkedAreas(t){for(const e of t.GraphicalMarkedAreas)e&&(e.systemRectangle&&this.drawRectangle(e.systemRectangle,s.GraphicalLayers.Background),e.settings&&this.drawLabel(e.settings,s.GraphicalLayers.Comment),e.labelRectangle&&this.drawRectangle(e.labelRectangle,s.GraphicalLayers.Background),e.label&&this.drawLabel(e.label,s.GraphicalLayers.Comment))}drawComment(t){for(const e of t.GraphicalComments)e&&(e.settings&&this.drawLabel(e.settings,s.GraphicalLayers.Comment),e.label&&this.drawLabel(e.label,s.GraphicalLayers.Comment))}drawStaffLineSymbols(t){const e=t.ParentStaff.ParentInstrument,i=t.PositionAndShape.AbsolutePosition.x,n=t.PositionAndShape.AbsolutePosition.y+2,o=t.PositionAndShape.BorderRight;e.highlight&&this.drawingParameters.drawHighlights&&this.drawLineAsHorizontalRectangle(new r.GraphicalLine(new a.PointF2D(i,n),new a.PointF2D(i+o,n),4,s.OutlineAndFillStyleEnum.Highlighted),s.GraphicalLayers.Highlight);let l=p.MusicSymbolDrawingStyle.Disabled,h=f.MusicSymbol.PLAY,c=this.drawingParameters.drawActivitySymbols;switch(this.phonicScoreMode){case p.PhonicScoreModes.Midi:h=f.MusicSymbol.PLAY,this.midiPlaybackAvailable&&t.ParentStaff.audible&&(l=p.MusicSymbolDrawingStyle.PlaybackSymbols);break;case p.PhonicScoreModes.Following:h=f.MusicSymbol.MIC,t.ParentStaff.following&&(l=p.MusicSymbolDrawingStyle.FollowSymbols);break;default:c=!1}if(c){const t=new a.PointF2D(i+o+2,n);this.drawSymbol(h,l,t)}if(this.drawingParameters.drawErrors)for(const e of t.Measures){const t=e.PositionAndShape,i=t.AbsolutePosition.x,n=t.AbsolutePosition.y+2;e.hasError&&this.graphicalMusicSheet.ParentMusicSheet.DrawErroneousMeasures&&this.drawLineAsHorizontalRectangle(new r.GraphicalLine(new a.PointF2D(i,n),new a.PointF2D(i+t.BorderRight,n),4,s.OutlineAndFillStyleEnum.ErrorUnderlay),s.GraphicalLayers.MeasureError)}}}},function(t,e,i){var n;Object.defineProperty(e,"__esModule",{value:!0}),e.PhonicScoreModes=e.MusicSymbolDrawingStyle=e.DrawingMode=void 0,(n=e.DrawingMode||(e.DrawingMode={}))[n.All=0]="All",n[n.NoOverlays=1]="NoOverlays",n[n.Leadsheet=2]="Leadsheet",function(t){t[t.Normal=0]="Normal",t[t.Disabled=1]="Disabled",t[t.Selected=2]="Selected",t[t.Clickable=3]="Clickable",t[t.PlaybackSymbols=4]="PlaybackSymbols",t[t.FollowSymbols=5]="FollowSymbols",t[t.QFeedbackNotFound=6]="QFeedbackNotFound",t[t.QFeedbackOk=7]="QFeedbackOk",t[t.QFeedbackPerfect=8]="QFeedbackPerfect",t[t.Debug1=9]="Debug1",t[t.Debug2=10]="Debug2",t[t.Debug3=11]="Debug3"}(e.MusicSymbolDrawingStyle||(e.MusicSymbolDrawingStyle={})),function(t){t[t.Following=0]="Following",t[t.Midi=1]="Midi",t[t.Manual=2]="Manual"}(e.PhonicScoreModes||(e.PhonicScoreModes={}))},function(t,e,i){var n=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[i]}})}:function(t,e,i,n){void 0===n&&(n=i),t[n]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||e.hasOwnProperty(i)||n(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),s(i(78),e),s(i(58),e),s(i(92),e),s(i(59),e),s(i(57),e),s(i(13),e),s(i(60),e),s(i(90),e),s(i(93),e),s(i(95),e),s(i(61),e),s(i(44),e),s(i(96),e),s(i(89),e),s(i(16),e),s(i(91),e),s(i(97),e),s(i(165),e),s(i(98),e),s(i(99),e),s(i(100),e),s(i(101),e),s(i(63),e),s(i(62),e)},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalMeasure=void 0;const n=i(6),s=i(0),r=i(5),o=i(4);class a extends n.GraphicalObject{constructor(t,e,i){super(),this.hasOnlyRests=!1,this.measureNumber=-1,this.parentStaff=t,this.parentSourceMeasure=e,this.parentStaffLine=i,i?(this.parentStaff=i.ParentStaff,this.PositionAndShape=new r.BoundingBox(this,i.PositionAndShape)):this.PositionAndShape=new r.BoundingBox(this),this.PositionAndShape.BorderBottom=4,this.parentSourceMeasure&&(this.measureNumber=this.parentSourceMeasure.MeasureNumber),this.staffEntries=[]}get ParentStaff(){return this.parentStaff}get ParentMusicSystem(){return this.parentMusicSystem}set ParentMusicSystem(t){this.parentMusicSystem=t}get MeasureNumber(){return this.measureNumber}get FirstInstructionStaffEntry(){return this.firstInstructionStaffEntry}set FirstInstructionStaffEntry(t){this.firstInstructionStaffEntry=t}get LastInstructionStaffEntry(){return this.lastInstructionStaffEntry}set LastInstructionStaffEntry(t){this.lastInstructionStaffEntry=t}get ParentStaffLine(){return this.parentStaffLine}set ParentStaffLine(t){this.parentStaffLine=t,this.parentStaffLine&&(this.PositionAndShape.Parent=this.parentStaffLine.PositionAndShape)}resetLayout(){throw new Error("not implemented")}getLineWidth(t){throw new Error("not implemented")}addClefAtBegin(t){throw new Error("not implemented")}addKeyAtBegin(t,e,i){throw new Error("not implemented")}addRhythmAtBegin(t){throw new Error("not implemented")}addClefAtEnd(t,e=!0){throw new Error("not implemented")}setPositionInStaffline(t){this.PositionAndShape.RelativePosition=new o.PointF2D(t,0)}setWidth(t){this.PositionAndShape.BorderRight=t}layoutSymbols(){throw new Error("not implemented")}findGraphicalStaffEntryFromTimestamp(t){var e;for(let i=0,n=this.staffEntries.length;i1}isVisible(){return this.ParentStaff.ParentInstrument.Visible}getGraphicalMeasureDurationFromStaffEntries(){let t=new s.Fraction(0,1);const e=[];for(let t=0,i=this.staffEntries.length;t0&&r.Add(e.notes[0].graphicalNoteLength);t.lt(r)&&(t=s.Fraction.createFromFraction(r))}return t}addGraphicalStaffEntry(t){this.staffEntries.push(t)}addGraphicalStaffEntryAtTimestamp(t){if(t)if(0===this.staffEntries.length||this.staffEntries[this.staffEntries.length-1].relInMeasureTimestamp.lt(t.relInMeasureTimestamp))this.staffEntries.push(t);else for(let e=this.staffEntries.length-1;e>=0;e--){if(this.staffEntries[e].relInMeasureTimestamp.lt(t.relInMeasureTimestamp)){this.staffEntries.splice(e+1,0,t);break}0===e&&this.staffEntries.splice(e,0,t)}}beginsWithLineRepetition(){const t=this.parentSourceMeasure;return!!t&&t.beginsWithLineRepetition()}endsWithLineRepetition(){const t=this.parentSourceMeasure;return!!t&&t.endsWithLineRepetition()}beginsWithWordRepetition(){const t=this.parentSourceMeasure;return!!t&&t.beginsWithWordRepetition()}endsWithWordRepetition(){const t=this.parentSourceMeasure;return!!t&&t.endsWithWordRepetition()}}e.GraphicalMeasure=a},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalOctaveShift=void 0;const n=i(6),s=i(30),r=i(5),o=i(77),a=i(11);class l extends n.GraphicalObject{constructor(t,e){super(),this.getOctaveShift=t,this.setSymbol(),this.PositionAndShape=new r.BoundingBox(this,e)}setSymbol(){switch(this.getOctaveShift.Type){case s.OctaveEnum.VA8:this.octaveSymbol=o.MusicSymbol.VA8;break;case s.OctaveEnum.VB8:this.octaveSymbol=o.MusicSymbol.VB8;break;case s.OctaveEnum.MA15:this.octaveSymbol=o.MusicSymbol.MA15;break;case s.OctaveEnum.MB15:this.octaveSymbol=o.MusicSymbol.MB15;break;default:throw new a.ArgumentOutOfRangeException("")}}}e.GraphicalOctaveShift=l},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalStaffEntry=void 0;const n=i(5),s=i(0),r=i(6),o=i(34),a=i(17);class l extends r.GraphicalObject{constructor(t,e,i){super(),this.graphicalChordContainers=[],this.tabStaffEntry=void 0,this.MaxAccidentals=0,this.graphicalInstructions=[],this.graphicalTies=[],this.lyricsEntries=[],this.parentMeasure=t,this.graphicalVoiceEntries=[],this.sourceStaffEntry=e,i?(this.staffEntryParent=i,this.parentVerticalContainer=i.parentVerticalContainer,this.PositionAndShape=new n.BoundingBox(this,i.PositionAndShape)):this.PositionAndShape=new n.BoundingBox(this,t.PositionAndShape),e&&(this.relInMeasureTimestamp=e.Timestamp)}get GraphicalInstructions(){return this.graphicalInstructions}get GraphicalTies(){return this.graphicalTies}get LyricsEntries(){return this.lyricsEntries}set LyricsEntries(t){this.lyricsEntries=t}getAbsoluteTimestamp(){const t=this.parentMeasure.parentSourceMeasure.AbsoluteTimestamp.clone();return this.relInMeasureTimestamp&&t.Add(this.relInMeasureTimestamp),t}findTieGraphicalNoteFromNote(t){for(const e of this.graphicalVoiceEntries)for(const i of e.notes){const e=i.sourceNote;if(!e.isRest()&&e.Pitch.FundamentalNote===t.Pitch.FundamentalNote&&e.Pitch.Octave===t.Pitch.Octave&&e.getAbsoluteTimestamp().Equals(t.getAbsoluteTimestamp()))return i}}findEndTieGraphicalNoteFromNoteWithStartingSlur(t,e){if(t)for(const i of this.graphicalVoiceEntries)if(i.parentVoiceEntry===t.ParentVoiceEntry)for(const t of i.notes){const i=t.sourceNote;if(i.NoteTie&&-1!==i.NoteSlurs.indexOf(e))return t}}findGraphicalNoteFromGraceNote(t){if(t)for(const e of this.graphicalVoiceEntries)if(e.parentVoiceEntry===t.ParentVoiceEntry)for(const i of e.notes)if(i.sourceNote===t)return i}findGraphicalNoteFromNote(t){if(t)for(const e of this.graphicalVoiceEntries)if(e.parentVoiceEntry===t.ParentVoiceEntry)for(const i of e.notes)if(i.sourceNote===t&&this.getAbsoluteTimestamp().Equals(t.getAbsoluteTimestamp()))return i}getGraphicalNoteDurationFromVoice(t){for(const e of this.graphicalVoiceEntries)if(e.parentVoiceEntry.ParentVoice===t)return e.notes[0].graphicalNoteLength;return new s.Fraction(0,1)}findVoiceEntryGraphicalNotes(t){for(const e of this.graphicalVoiceEntries)if(e.parentVoiceEntry===t)return e.notes}isVoiceEntryPartOfLinkedVoiceEntry(t){if(this.sourceStaffEntry.Link)for(let e=0,i=this.sourceStaffEntry.Link.LinkStaffEntries.length;e0&&(t=e)}return t}findStaffEntryMaxNoteLength(){let t=new s.Fraction(0,1);for(const e of this.graphicalVoiceEntries)for(const i of e.notes){const e=i.graphicalNoteLength;t.lt(e)&&e.GetExpandedNumerator()>0&&(t=e)}return t}findOrCreateGraphicalVoiceEntry(t){for(const e of this.graphicalVoiceEntries)if(e.parentVoiceEntry===t)return e;const e=a.MusicSheetCalculator.symbolFactory.createVoiceEntry(t,this);return this.graphicalVoiceEntries.push(e),e}findOrCreateGraphicalVoiceEntryFromGraphicalNote(t){for(const e of this.graphicalVoiceEntries)if(e===t.parentVoiceEntry)return e;const e=a.MusicSheetCalculator.symbolFactory.createVoiceEntry(t.sourceNote.ParentVoiceEntry,this);return this.graphicalVoiceEntries.push(e),e}addGraphicalNoteToListAtCorrectYPosition(t,e){const i=t.notes;if(0===i.length||e.PositionAndShape.RelativePosition.y=0;t--){if(i[t].PositionAndShape.RelativePosition.y>e.PositionAndShape.RelativePosition.y){i.splice(t+1,0,e);break}if(0===t){i.splice(0,0,e);break}}}hasOnlyRests(){for(const t of this.graphicalVoiceEntries)for(const e of t.notes)if(!e.sourceNote.isRest())return!1;return!0}}e.GraphicalStaffEntry=l},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.StaffLine=void 0;const n=i(5),s=i(6),r=i(47),o=i(4),a=i(126);class l extends s.GraphicalObject{constructor(t,e){super(),this.measures=[],this.staffLines=new Array(5),this.octaveShifts=[],this.lyricLines=[],this.lyricsDashes=[],this.abstractExpressions=[],this.graphicalSlurs=[],this.parentMusicSystem=t,this.parentStaff=e,this.boundingBox=new n.BoundingBox(this,t.PositionAndShape),this.skyBottomLine=new a.SkyBottomLineCalculator(this),this.staffHeight=this.parentMusicSystem.rules.StaffHeight,this.topLineOffset=0,this.bottomLineOffset=4,this.calculateStaffLineOffsets()}calculateStaffLineOffsets(){if(this.ParentStaff.isTab)switch(this.ParentStaff.StafflineCount){case 5:this.staffHeight=this.bottomLineOffset=6*this.ParentStaff.ParentInstrument.GetMusicSheet.Rules.TabStaffInterlineHeight;break;default:this.staffHeight=this.bottomLineOffset=this.ParentStaff.ParentInstrument.GetMusicSheet.Rules.TabStaffInterlineHeight*this.ParentStaff.StafflineCount}else switch(this.ParentStaff.StafflineCount){case 4:this.bottomLineOffset=1;break;case 3:this.topLineOffset=1,this.bottomLineOffset=1;break;case 2:this.topLineOffset=2,this.bottomLineOffset=1;break;case 1:this.topLineOffset=2,this.bottomLineOffset=2}}get Measures(){return this.measures}set Measures(t){this.measures=t}get StaffLines(){return this.staffLines}set StaffLines(t){this.staffLines=t}get NextStaffLine(){const t=this.parentMusicSystem.StaffLines.indexOf(this);return t!==this.parentMusicSystem.StaffLines.length?this.parentMusicSystem.StaffLines[t+1]:void 0}get LyricLines(){return this.lyricLines}get AbstractExpressions(){return this.abstractExpressions}set AbstractExpressions(t){this.abstractExpressions=t}set LyricLines(t){this.lyricLines=t}get LyricsDashes(){return this.lyricsDashes}set LyricsDashes(t){this.lyricsDashes=t}get ParentMusicSystem(){return this.parentMusicSystem}set ParentMusicSystem(t){this.parentMusicSystem=t}get ParentStaff(){return this.parentStaff}set ParentStaff(t){this.parentStaff=t}get SkyBottomLineCalculator(){return this.skyBottomLine}get SkyLine(){return this.skyBottomLine.SkyLine}get BottomLine(){return this.skyBottomLine.BottomLine}get OctaveShifts(){return this.octaveShifts}set OctaveShifts(t){this.octaveShifts=t}get StaffHeight(){return this.staffHeight}get TopLineOffset(){return this.topLineOffset}get BottomLineOffset(){return this.bottomLineOffset}get GraphicalSlurs(){return this.graphicalSlurs}addSlurToStaffline(t){this.graphicalSlurs.push(t)}addActivitySymbolClickArea(){const t=new r.StaffLineActivitySymbol(this),e=this.PositionAndShape;t.PositionAndShape.RelativePosition=new o.PointF2D(e.RelativePosition.x+e.BorderRight+.5,e.RelativePosition.y+.5),t.PositionAndShape.Parent=this.parentMusicSystem.PositionAndShape}isPartOfMultiStaffInstrument(){return this.parentStaff.ParentInstrument.Staves.length>1}findClosestStaffEntry(t){let e;for(let i=0,n=this.Measures.length;i0||(o.default.warn("SkyBottomLineCalculator: width not > 0 in measure "+t.MeasureNumber),n=50),e.initializeHeadless(n);const s=e.getContext(),r=e.getCanvas();n=r.width;const a=r.height;i.setY(i.y+100);const l=i.getWidth();i.setWidth(n),t.format(),i.setWidth(l);try{t.draw(s)}catch(t){o.default.warn("SkyBottomLineCalculator.calculateLines.draw",t)}const h=s.getImageData(0,0,n,a),c=4,u=Math.max(Math.ceil(t.PositionAndShape.Size.width*this.mRules.SamplingUnit),1),d=new Array(u),f=new Array(u);for(let t=0;t0){d[t]=e;break}}for(let e=a;e>0;e--){const i=e*n*c+t*c;if(h.data[i+3]>0){f[t]=e;break}}}for(let t=0;t(t-Math.max(...this.mSkyLine))/r.unitInPixels+this.StaffLineParent.TopLineOffset)),this.mBottomLine=this.mBottomLine.map((t=>(t-Math.min(...this.mBottomLine))/r.unitInPixels+this.StaffLineParent.BottomLineOffset))}findPreviousValidNumber(t,e){for(let i=t;i>=0;i--)if(!isNaN(e[i]))return e[i];return 0}findNextValidNumber(t,e){if(t>=e.length)return e[t-1];for(let i=t;i=this.BottomLine.length&&(i=this.BottomLine.length-1),n<0&&(n=0),n>=this.BottomLine.length&&(n=this.BottomLine.length),this.SkyLine[i]=t.y;for(let t=i+1;t=this.BottomLine.length&&(i=this.BottomLine.length-1),n<0&&(n=0),n>=this.BottomLine.length&&(n=this.BottomLine.length),this.BottomLine[i]=t.y;for(let t=i+1;tt))}setBottomLineWithValue(t){this.BottomLine.forEach((e=>t))}getLeftIndexForPointX(t,e){const i=Math.floor(t*this.SamplingUnit);return i<0?0:i>=e?e-1:i}getRightIndexForPointX(t,e){const i=Math.ceil(t*this.SamplingUnit);return i<0?0:i>=e?e-1:i}updateStaffLineBorders(){this.mStaffLineParent.PositionAndShape.BorderTop=this.getSkyLineMin(),this.mStaffLineParent.PositionAndShape.BorderMarginTop=this.getSkyLineMin(),this.mStaffLineParent.PositionAndShape.BorderBottom=this.getBottomLineMax(),this.mStaffLineParent.PositionAndShape.BorderMarginBottom=this.getBottomLineMax()}getSkyLineMin(){return Math.min(...this.SkyLine.filter((t=>!isNaN(t))))}getSkyLineMinAtPoint(t){const e=Math.round(t*this.SamplingUnit);return this.mSkyLine[e]}getSkyLineMinInRange(t,e){return this.getMinInRange(this.SkyLine,t,e)}getBottomLineMax(){return Math.max(...this.BottomLine.filter((t=>!isNaN(t))))}getBottomLineMaxAtPoint(t){const e=Math.round(t*this.SamplingUnit);return this.mBottomLine[e]}getBottomLineMaxInRange(t,e){return this.getMaxInRange(this.BottomLine,t,e)}getBottomLineMaxInBoundingBox(t){const e=Math.floor(t.AbsolutePosition.x+t.BorderLeft),i=Math.ceil(t.AbsolutePosition.x+t.BorderRight);return this.getMaxInRange(this.mBottomLine,e,i)}updateWithBoundingBoxRecursively(t){if(t.ChildElements&&t.ChildElements.length>0)this.updateWithBoundingBoxRecursively(t);else{const e=t.BorderTop+t.AbsolutePosition.y,i=t.BorderBottom+t.AbsolutePosition.y;if(e<0){const i=Math.floor(t.AbsolutePosition.x+t.BorderLeft),n=Math.ceil(t.AbsolutePosition.x+t.BorderRight);this.updateInRange(this.mSkyLine,i,n,e)}else if(i>this.StaffLineParent.StaffHeight){const e=Math.floor(t.AbsolutePosition.x+t.BorderLeft),n=Math.ceil(t.AbsolutePosition.x+t.BorderRight);this.updateInRange(this.mBottomLine,e,n,i)}}}updateInRange(t,e=0,i=t.length,n=0){if(e=Math.floor(e*this.SamplingUnit),(i=Math.ceil(i*this.SamplingUnit))t.length&&(i=t.length);for(let s=e;sMath.abs(t[s])?n:t[s]}setInRange(t,e=0,i=t.length,n=0){if(e=Math.floor(e*this.SamplingUnit),(i=Math.ceil(i*this.SamplingUnit))t.length&&(i=t.length);for(let s=e;s=t.length&&(e=t.length-1),i<0&&(i=0),i>=t.length&&(i=t.length),e>=0&&i<=t.length?Math.min(...t.slice(e,i+1)):void 0):Number.MAX_VALUE}getMaxInRange(t,e,i){return e=Math.floor(e*this.SamplingUnit),i=Math.ceil(i*this.SamplingUnit),t?(e<0&&(e=0),e>=t.length&&(e=t.length-1),i<0&&(i=0),i>=t.length&&(i=t.length),e>=0&&i<=t.length?Math.max(...t.slice(e,i+1)):void 0):Number.MIN_VALUE}get SamplingUnit(){return this.mRules.SamplingUnit}get StaffLineParent(){return this.mStaffLineParent}get SkyLine(){return this.mSkyLine}get BottomLine(){return this.mBottomLine}}},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalChordSymbolContainer=void 0;const n=i(12),s=i(24),r=i(48),o=i(5),a=i(6),l=i(4);class h extends a.GraphicalObject{constructor(t,e,i,n,s,r){super(),this.chordSymbolContainer=t,this.boundingBox=new o.BoundingBox(this,e),this.rules=r,this.calculateLabel(i,s,n)}get GetChordSymbolContainer(){return this.chordSymbolContainer}get GraphicalLabel(){return this.graphicalLabel}calculateLabel(t,e,i){const o=r.ChordSymbolContainer.calculateChordText(this.chordSymbolContainer,e,i);this.graphicalLabel=new s.GraphicalLabel(new n.Label(o),t,this.rules.ChordSymbolTextAlignment,this.rules,this.boundingBox),this.graphicalLabel.PositionAndShape.RelativePosition=new l.PointF2D(this.rules.ChordSymbolRelativeXOffset,0)}}e.GraphicalChordSymbolContainer=h},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalTie=void 0,e.GraphicalTie=class{constructor(t,e,i){this.tie=t,this.startNote=e,this.endNote=i}get GetTie(){return this.tie}get StartNote(){return this.startNote}get Tie(){return this.tie}set StartNote(t){this.startNote=t}get EndNote(){return this.endNote}set EndNote(t){this.endNote=t}}},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalLyricEntry=void 0;const n=i(24),s=i(12),r=i(4),o=i(9);e.GraphicalLyricEntry=class{constructor(t,e,i,a){this.lyricsEntry=t,this.graphicalStaffEntry=e;const l=e.parentMeasure.parentSourceMeasure.Rules.LyricsAlignmentStandard;t.Text.length>=4&&t.Parent.Notes[0].Length.Denominator>4&&o.TextAlignmentEnum.LeftBottom;const h=new s.Label(t.Text);this.graphicalLabel=new n.GraphicalLabel(h,i,l,this.graphicalStaffEntry.parentMeasure.parentSourceMeasure.Rules,e.PositionAndShape),this.graphicalLabel.PositionAndShape.RelativePosition=new r.PointF2D(0,a),l===o.TextAlignmentEnum.LeftBottom&&(this.graphicalLabel.PositionAndShape.RelativePosition.x-=1)}get LyricsEntry(){return this.lyricsEntry}get ParentLyricWord(){return this.graphicalLyricWord}set ParentLyricWord(t){this.graphicalLyricWord=t}get GraphicalLabel(){return this.graphicalLabel}set GraphicalLabel(t){this.graphicalLabel=t}get StaffEntryParent(){return this.graphicalStaffEntry}set StaffEntryParent(t){this.graphicalStaffEntry=t}}},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalLyricWord=void 0,e.GraphicalLyricWord=class{constructor(t){this.graphicalLyricsEntries=[],this.lyricWord=t,this.initialize()}get GetLyricWord(){return this.lyricWord}get GraphicalLyricsEntries(){return this.graphicalLyricsEntries}set GraphicalLyricsEntries(t){this.graphicalLyricsEntries=t}isFilled(){for(let t=0;tn.RealValue?1:n.RealValue>i.RealValue?-1:0}calculateCurve(t){const e=this.staffEntries[0],i=this.staffEntries[this.staffEntries.length-1];let s=e.findGraphicalNoteFromNote(this.slur.StartNote);!s&&this.graceStart&&(s=e.findGraphicalNoteFromGraceNote(this.slur.StartNote)),s||(s=e.findEndTieGraphicalNoteFromNoteWithStartingSlur(this.slur.StartNote,this.slur));let a=i.findGraphicalNoteFromNote(this.slur.EndNote);!a&&this.graceEnd&&(a=i.findGraphicalNoteFromGraceNote(this.slur.EndNote));const l=e.parentMeasure.ParentStaffLine,h=l.SkyBottomLineCalculator;this.calculatePlacement(h,l);const c=this.calculateStartAndEnd(s,a,l,t,h),u=c.startX,d=c.endX;let f=c.startY,p=c.endY;const m=t.SlurTangentMinAngle,b=t.SlurTangentMaxAngle;let g;if(this.placement===r.PlacementEnum.Above){f-=t.SlurNoteHeadYOffset,p-=t.SlurNoteHeadYOffset;const e=new n.PointF2D(this.staffEntries[0].parentMeasure.PositionAndShape.RelativePosition.x+this.staffEntries[0].PositionAndShape.RelativePosition.x,f);s?e.x+=this.staffEntries[0].PositionAndShape.BorderRight:e.x=this.staffEntries[0].parentMeasure.beginInstructionsWidth,this.graceStart&&(e.x+=i.PositionAndShape.RelativePosition.x);const r=new n.PointF2D(this.staffEntries[this.staffEntries.length-1].parentMeasure.PositionAndShape.RelativePosition.x+this.staffEntries[this.staffEntries.length-1].PositionAndShape.RelativePosition.x,p);if(a?r.x+=this.staffEntries[this.staffEntries.length-1].PositionAndShape.BorderLeft:r.x=this.staffEntries[this.staffEntries.length-1].parentMeasure.PositionAndShape.RelativePosition.x+this.staffEntries[this.staffEntries.length-1].parentMeasure.PositionAndShape.Size.width,this.graceEnd&&(r.x+=i.staffEntryParent.PositionAndShape.RelativePosition.x),g=this.calculateTopPoints(e,r,l,h),0===g.length){const t=new n.PointF2D((r.x-e.x)/2+e.x,(r.y-e.y)/2+e.y);g.push(t)}const c=Math.atan((p-f)/(d-u)),y=new n.PointF2D(0,0);let S=new n.PointF2D(d-u,-(p-f));const v=o.Matrix2D.getRotationMatrix(c),x=v.getTransposeMatrix();S=v.vectorMultiplication(S);const E=this.calculateTranslatedAndRotatedPointListAbove(g,u,f,v),_=this.calculateMaxLeftSlope(E,y,S),w=this.calculateMaxRightSlope(E,y,S),T=y.y-y.x*_,M=S.y-S.x*w,P=new n.PointF2D;let L=!1;Math.abs(Math.abs(_)-Math.abs(w))<1e-4?(P.x=S.x/2,P.y=0,L=!0):(P.x=(M-T)/(_-w),P.y=_*P.x+T);const A=this.calculateHeightWidthRatio(S.x,E),C=0,I=0;let R=m,N=-m;if(!L){const t=this.calculateAngles(m,_,w,b);R=t.startAngle,N=t.endAngle}const F=this.calculateControlPoints(S.x,R,N,E,A);let B=F.startControlPoint,O=F.endControlPoint;B=x.vectorMultiplication(B),B.x+=u,B.y=-B.y+f,O=x.vectorMultiplication(O),O.x+=u,O.y=-O.y+f,this.bezierStartPt=new n.PointF2D(u,f-C),this.bezierStartControlPt=new n.PointF2D(B.x,B.y-C),this.bezierEndControlPt=new n.PointF2D(O.x,O.y-I),this.bezierEndPt=new n.PointF2D(d,p-I);const D=l.SkyLine.length,k=h.getLeftIndexForPointX(this.bezierStartPt.x,D),V=h.getLeftIndexForPointX(this.bezierEndPt.x,D),G=this.bezierEndPt.x-this.bezierStartPt.x,W=h.SamplingUnit;for(let t=k;t=k&&(l.SkyLine[n]=Math.min(l.SkyLine[n],i.y)),n++,n=k&&(l.BottomLine[n]=Math.max(l.BottomLine[n],i.y)),n++,n0)return void(this.placement=r.PlacementEnum.Above);const i=this.staffEntries[0],n=this.staffEntries[this.staffEntries.length-1],s=i.graphicalVoiceEntries[0].parentVoiceEntry.StemDirection;if(s===n.graphicalVoiceEntries[0].parentVoiceEntry.StemDirection)this.placement=s===h.StemDirectionType.Up?r.PlacementEnum.Below:r.PlacementEnum.Above;else{let s=i.PositionAndShape.BorderLeft+i.PositionAndShape.RelativePosition.x+i.parentMeasure.PositionAndShape.RelativePosition.x,o=n.PositionAndShape.BorderRight+n.PositionAndShape.RelativePosition.x+n.parentMeasure.PositionAndShape.RelativePosition.x;this.graceStart&&(s+=n.PositionAndShape.RelativePosition.x),this.graceEnd&&(o+=n.staffEntryParent.PositionAndShape.RelativePosition.x);const a=-1*t.getSkyLineMinInRange(s,o),l=t.getBottomLineMaxInRange(s,o)-e.StaffHeight;this.placement=l>a?r.PlacementEnum.Above:r.PlacementEnum.Below}}calculateTopPoints(t,e,i,s){const r=[];let o=s.getRightIndexForPointX(t.x,i.SkyLine.length),a=s.getLeftIndexForPointX(e.x,i.SkyLine.length);o<0&&(o=0),a>=i.SkyLine.length&&(a=i.SkyLine.length-1);for(let t=o;t=i.BottomLine.length&&(a=i.BottomLine.length-1);for(let t=o;tl&&t>h&&(a+=t/70*this.rules.SlurHeightFlattenLongSlursFactorByWidth,a*=1+e/30*this.rules.SlurHeightFlattenLongSlursFactorByAngle,o/=a);const u=Math.min(.5,Math.max(.1,1.7*e/80*o*Math.pow(Math.max(r,.05),.4))),d=Math.min(.5,Math.max(.1,1.7*-i/80*o*Math.pow(Math.max(r,.05),.4))),f=new n.PointF2D;f.x=t*u*Math.cos(e*c.degreesToRadiansFactor),f.y=t*u*Math.sin(e*c.degreesToRadiansFactor);const p=new n.PointF2D;return p.x=t-t*d*Math.cos(i*c.degreesToRadiansFactor),p.y=-t*d*Math.sin(i*c.degreesToRadiansFactor),{startControlPoint:f,endControlPoint:p}}calculateAngles(t,e,i,n){let s=Math.atan(e)/c.degreesToRadiansFactor;e>0?s+=20:s-=20;let r=Math.atan(i)/c.degreesToRadiansFactor;return i<0?r-=20:r+=20,{startAngle:Math.min(Math.max(t,s),n),endAngle:Math.max(Math.min(-t,r),-n)}}}e.GraphicalSlur=c,c.degreesToRadiansFactor=Math.PI/180},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.GraphicalCurve=void 0;const n=i(4);class s{constructor(){s.tPow3=new Array(s.bezierCurveStepSize),s.oneMinusTPow3=new Array(s.bezierCurveStepSize),s.bezierFactorOne=new Array(s.bezierCurveStepSize),s.bezierFactorTwo=new Array(s.bezierCurveStepSize);for(let t=0;t=s.bezierCurveStepSize?new n.PointF2D:new n.PointF2D(s.oneMinusTPow3[e]*this.bezierStartPt.x+s.bezierFactorOne[e]*this.bezierStartControlPt.x+s.bezierFactorTwo[e]*this.bezierEndControlPt.x+s.tPow3[e]*this.bezierEndPt.x,s.oneMinusTPow3[e]*this.bezierStartPt.y+s.bezierFactorOne[e]*this.bezierStartControlPt.y+s.bezierFactorTwo[e]*this.bezierEndControlPt.y+s.tPow3[e]*this.bezierEndPt.y)}}e.GraphicalCurve=s,s.bezierCurveStepSize=1e3},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.Matrix2D=void 0;const n=i(4);class s{constructor(){this.matrix=[];for(let t=0;t<2;t++){this.matrix[t]=[];for(let e=0;e<2;e++)this.matrix[t][e]=0}}static getRotationMatrix(t){const e=new s,i=Math.cos(t),n=Math.sin(t);return e.matrix[0][0]=i,e.matrix[0][1]=-n,e.matrix[1][0]=n,e.matrix[1][1]=i,e}scalarMultiplication(t){for(let e=0;e<2;e++)for(let i=0;i<2;i++)this.matrix[e][i]*=t}getTransposeMatrix(){const t=new s;for(let e=0;e<2;e++)for(let i=0;i<2;i++)t.matrix[e][i]=this.matrix[i][e];return t}vectorMultiplication(t){const e=new n.PointF2D;return e.x=t.x*this.matrix[0][0]+t.y*this.matrix[0][1],e.y=t.x*this.matrix[1][0]+t.y*this.matrix[1][1],e}}e.Matrix2D=s},function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.MusicSheetReader=void 0;const s=i(135),r=i(106),o=i(0),a=i(139),l=i(73),h=i(20),c=i(11),u=n(i(1)),d=i(19),f=i(19),p=i(31),m=i(74),b=i(150),g=i(7),y=i(12),S=i(151),v=i(26),x=i(154);class E{constructor(t,e=new v.EngravingRules){this.completeNumberOfStaves=0,this.pluginManager=new x.ReaderPluginManager,this.afterSheetReadingModules=t||[],this.repetitionInstructionReader=S.MusicSymbolModuleFactory.createRepetitionInstructionReader(),this.repetitionCalculator=S.MusicSymbolModuleFactory.createRepetitionCalculator(),this.rules=e}get PluginManager(){return this.pluginManager}get CompleteNumberOfStaves(){return this.completeNumberOfStaves}static doCalculationsAfterDurationHasBeenSet(t){for(const e of t)e.doCalculationsAfterDurationHasBeenSet()}createMusicSheet(t,e){try{return this._createMusicSheet(t,e)}catch(t){return void u.default.error("MusicSheetReader.CreateMusicSheet",t)}}_removeFromArray(t,e){const i=t.indexOf(e);-1!==i&&t.splice(i,1)}trimString(t){return t.replace(/^\s+|\s+$/g,"")}_lastElement(t){return t[t.length-1]}_createMusicSheet(t,e){const i=[];let n=0;if(this.musicSheet=new s.MusicSheet,this.musicSheet.Path=e,this.musicSheet.Rules=this.rules,!t)throw new c.MusicSheetReadingException("Undefined root element");this.pushSheetLabels(t,e);const a=t.element("part-list");if(!a)throw new c.MusicSheetReadingException("Undefined partListNode");const l=t.elements("part"),u=a.elements();this.initializeReading(u,l,i);let d=!0;this.currentFraction=new o.Fraction(0,1);let f=!1,p=t.element("identification");for(p&&(p=p.element("encoding")),p&&(p=p.element("software")),void 0!==p&&"Guitar Pro 5"===p.value&&(f=!0);d;){void 0!==this.currentMeasure&&this.currentMeasure.HasEndLine&&this.rules.NewPartAndSystemAfterFinalBarline&&(n=0),this.currentMeasure=new r.SourceMeasure(this.completeNumberOfStaves,this.musicSheet.Rules);for(const t of i)try{d=d&&t.readNextXmlMeasure(this.currentMeasure,this.currentFraction,f)}catch(t){const e=h.ITextTranslation.translateText("ReaderErrorMessages/InstrumentError","Error while reading instruments.");throw new c.MusicSheetReadingException(e,t)}d&&(this.musicSheet.addMeasure(this.currentMeasure),this.checkIfRhythmInstructionsAreSetAndEqual(i),this.checkSourceMeasureForNullEntries(),n=this.setSourceMeasureDuration(i,n),E.doCalculationsAfterDurationHasBeenSet(i),this.currentMeasure.AbsoluteTimestamp=this.currentFraction.clone(),this.musicSheet.SheetErrors.finalizeMeasure(this.currentMeasure.MeasureNumber),this.currentFraction.Add(this.currentMeasure.Duration),this.previousMeasure=this.currentMeasure)}this.repetitionInstructionReader&&(this.repetitionInstructionReader.removeRedundantInstructions(),this.repetitionCalculator&&this.repetitionCalculator.calculateRepetitions(this.musicSheet,this.repetitionInstructionReader.repetitionInstructions)),this.musicSheet.checkForInstrumentWithNoVoice(),this.musicSheet.fillStaffList();for(let t=0,e=this.afterSheetReadingModules.length;ti){if(this.areRhythmInstructionsMixed(e)&&s.SymbolEnum!==f.RhythmSymbolEnum.NONE)continue;i=s.Rhythm.RealValue,n=e.indexOf(s)}}if(e.length>0&&e.lengtht.Denominator){const i=e.Denominator/t.Denominator;t.expand(i)}}checkIfMeasureIsImplicit(t,e){return!(this.previousMeasure||!t.lt(e))||!!this.previousMeasure&&o.Fraction.plus(this.previousMeasure.Duration,t).Equals(e)}allInstrumentsHaveSameDuration(t,e){let i=0;for(let n=0,s=t.length;n=0;t--)for(let e=this.currentMeasure.VerticalSourceStaffEntryContainers[t].StaffEntries.length-1;e>=0;e--){const i=this.currentMeasure.VerticalSourceStaffEntryContainers[t].StaffEntries[e];if(i)for(let t=i.VoiceEntries.length-1;t>=0;t--){const e=i.VoiceEntries[t];0===e.Notes.length&&(this._removeFromArray(e.ParentVoice.VoiceEntries,e),this._removeFromArray(i.VoiceEntries,e))}void 0!==i&&0===i.VoiceEntries.length&&(this.currentMeasure.VerticalSourceStaffEntryContainers[t].StaffEntries[e]=void 0)}for(let t=this.currentMeasure.VerticalSourceStaffEntryContainers.length-1;t>=0;t--){let e=0;for(let i=0,n=this.currentMeasure.VerticalSourceStaffEntryContainers[t].StaffEntries.length;in){if(!this.musicSheet.Title){const e=t.attribute("font-size").value,i=parseFloat(e);a0&&s.MidiInstrumentId!==g.MidiInstrument.Percussion&&(t.midiInstrumentID=Math.max(0,parseInt(n.value,10)-1));else if("midi-unpitched"===n.name)t.fixedKey=Math.max(0,parseInt(n.value,10));else if("volume"===n.name)try{const e=parseFloat(n.value);t.volume=e/127}catch(t){u.default.debug("ExpressionReader.readExpressionParameters","read volume",t)}else if("pan"===n.name)try{const e=parseFloat(n.value);t.pan=e/64}catch(t){u.default.debug("ExpressionReader.readExpressionParameters","read pan",t)}}catch(t){u.default.info("MusicSheetReader.createInstrumentGroups midi settings: ",t)}}}}catch(t){u.default.info("MusicSheetReader.createInstrumentGroups: ",t)}}if(0===s.SubInstruments.length){const t=new b.SubInstrument(s);s.SubInstruments.push(t)}i[t]=s,n?(n.InstrumentalGroups.push(s),this.musicSheet.Instruments.push(s)):(this.musicSheet.InstrumentalGroups.push(s),this.musicSheet.Instruments.push(s))}else if("part-group"===r.name&&"start"===r.attribute("type").value){const t=new m.InstrumentalGroup("group",this.musicSheet,n);n?n.InstrumentalGroups.push(t):this.musicSheet.InstrumentalGroups.push(t),n=t}else if("part-group"===r.name&&"stop"===r.attribute("type").value&&n){if(1===n.InstrumentalGroups.length){const t=n.InstrumentalGroups[0];n.Parent?(n.Parent.InstrumentalGroups.push(t),this._removeFromArray(n.Parent.InstrumentalGroups,n)):(this.musicSheet.InstrumentalGroups.push(t),this._removeFromArray(this.musicSheet.InstrumentalGroups,n))}n=n.Parent}}}catch(t){const e=h.ITextTranslation.translateText("ReaderErrorMessages/InstrumentError","Error while reading Instruments");throw new c.MusicSheetReadingException(e,t)}for(let t=0,e=this.musicSheet.Instruments.length;t0){const i=t[0];if(i){let t=i.element("attributes");t&&(t=t.element("staves")),t?e+=parseInt(t.value,10):e++}}}if(isNaN(e)||e<=0){const t=h.ITextTranslation.translateText("ReaderErrorMessages/StaffError","Invalid number of staves.");throw new c.MusicSheetReadingException(t)}return e}getInstrumentNumberOfStavesFromXml(t){let e=0;const i=t.element("measure");if(i){const t=i.element("attributes");let n;t&&(n=t.element("staves")),e=t&&n?parseInt(n.value,10):1}if(isNaN(e)||e<=0){const t=h.ITextTranslation.translateText("ReaderErrorMessages/StaffError","Invalid number of Staves.");throw new c.MusicSheetReadingException(t)}return e}}e.MusicSheetReader=E},function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.MusicSheet=e.PlaybackSettings=void 0;const s=i(0),r=i(166),o=i(136),a=i(12),l=i(51),h=i(138),c=i(26),u=i(22),d=n(i(1));class f{}e.PlaybackSettings=f;class p{constructor(){this.idString="random idString, not initialized",this.sourceMeasures=[],this.repetitions=[],this.dynListStaves=[],this.timestampSortedDynamicExpressionsList=[],this.timestampSortedTempoExpressionsList=[],this.instrumentalGroups=[],this.instruments=[],this.musicPartManager=void 0,this.musicSheetErrors=new h.MusicSheetErrors,this.staves=[],this.transpose=0,this.defaultStartTempoInBpm=0,this.drawErroneousMeasures=!1,this.hasBeenOpenedForTheFirstTime=!1,this.currentEnrolledPosition=new s.Fraction(0,1),this.playbackSettings=new f,this.playbackSettings.rhythm=new s.Fraction(4,4,0,!1),this.userStartTempoInBPM=100,this.pageWidth=120,this.MusicPartManager=new r.MusicPartManager(this),this.hasBPMInfo=!1}static getIndexFromStaff(t){return t.idInMusicSheet}get SourceMeasures(){return this.sourceMeasures}set SourceMeasures(t){this.sourceMeasures=t}get Repetitions(){return this.repetitions}set Repetitions(t){this.repetitions=t}get DynListStaves(){return this.dynListStaves}get TimestampSortedTempoExpressionsList(){return this.timestampSortedTempoExpressionsList}get TimestampSortedDynamicExpressionsList(){return this.timestampSortedDynamicExpressionsList}get InstrumentalGroups(){return this.instrumentalGroups}get Parts(){return this.instruments}get Instruments(){return this.instruments}get SheetPlaybackSetting(){return this.playbackSettings}set SheetPlaybackSetting(t){this.playbackSettings=t}get DrawErroneousMeasures(){return this.drawErroneousMeasures}set DrawErroneousMeasures(t){this.drawErroneousMeasures=t}get HasBeenOpenedForTheFirstTime(){return this.hasBeenOpenedForTheFirstTime}set HasBeenOpenedForTheFirstTime(t){this.hasBeenOpenedForTheFirstTime=t}InitializeStartTempoInBPM(t){this.userStartTempoInBPM=t}get DefaultStartTempoInBpm(){return this.defaultStartTempoInBpm}set DefaultStartTempoInBpm(t){this.defaultStartTempoInBpm=t,this.InitializeStartTempoInBPM(t)}get Path(){return this.path}set Path(t){this.path=t}get Staves(){return this.staves}get TitleString(){return this.title?this.title.text:""}set TitleString(t){this.Title=new a.Label(t)}get SubtitleString(){return this.subtitle?this.subtitle.text:""}set SubtitleString(t){this.Subtitle=new a.Label(t)}get ComposerString(){return this.composer?this.composer.text:""}set ComposerString(t){this.Composer=new a.Label(t)}get LyricistString(){return this.lyricist?this.lyricist.text:""}set LyricistString(t){this.Lyricist=new a.Label(t)}get Title(){return this.title}set Title(t){this.title=t}get Subtitle(){return this.subtitle}set Subtitle(t){this.subtitle=t}get Composer(){return this.composer}set Composer(t){this.composer=t}get Lyricist(){return this.lyricist}set Lyricist(t){this.lyricist=t}get Rules(){return this.rules||(d.default.debug("warning: sheet.Rules was undefined. Creating new EngravingRules."),this.rules=new c.EngravingRules),this.rules}set Rules(t){this.rules=t}get SheetErrors(){return this.musicSheetErrors}get SelectionStart(){return this.selectionStart}set SelectionStart(t){this.selectionStart=t.clone(),this.currentEnrolledPosition=t.clone()}get SelectionEnd(){return this.selectionEnd}set SelectionEnd(t){this.selectionEnd=t}set HasBPMInfo(t){this.hasBPMInfo=t}get HasBPMInfo(){return this.hasBPMInfo}addMeasure(t){this.sourceMeasures.push(t),t.measureListIndex=this.sourceMeasures.length-1}checkForInstrumentWithNoVoice(){for(let t=0,e=this.instruments.length;t0){const t=this.TimestampSortedTempoExpressionsList[0];if(t.InstantaneousTempo)return t.InstantaneousTempo.TempoInBpm;if(t.ContinuousTempo)return t.ContinuousTempo.StartTempo}return this.userStartTempoInBPM}get Errors(){return this.musicSheetErrors.measureErrors}get FirstMeasureNumber(){try{return this.getFirstSourceMeasure().MeasureNumber}catch(t){return d.default.info("MusicSheet.FirstMeasureNumber: ",t),0}}get LastMeasureNumber(){try{return this.getLastSourceMeasure().MeasureNumber}catch(t){return d.default.info("MusicSheet.LastMeasureNumber: ",t),0}}get CurrentEnrolledPosition(){return this.currentEnrolledPosition.clone()}set CurrentEnrolledPosition(t){this.currentEnrolledPosition=t.clone()}get Transpose(){return this.transpose}set Transpose(t){this.transpose=t}get FullNameString(){return this.ComposerString+" "+this.TitleString}get IdString(){return this.idString}set IdString(t){this.idString=t}getEnrolledSelectionStartTimeStampWorkaround(){const t=this.MusicPartManager.getIterator(this.SelectionStart);return s.Fraction.createFromFraction(t.CurrentEnrolledTimestamp)}get SheetEndTimestamp(){const t=this.getLastSourceMeasure();return s.Fraction.plus(t.AbsoluteTimestamp,t.Duration)}getSourceMeasureFromTimeStamp(t){for(let e=0,i=this.sourceMeasures.length;e0&&i.Voices[0].Visible&&t.push(i)}return t}}e.MusicSheet=p,p.defaultTitle="[no title given]"},function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.RepetitionEndingPart=e.Repetition=void 0;const s=i(137),r=i(0),o=i(81),a=n(i(1));class l extends o.PartListEntry{constructor(t,e){super(t),this.backwardJumpInstructions=[],this.endingParts=[],this.endingIndexDict={},this.userNumberOfRepetitions=0,this.visibles=[],this.fromWords=!1,this.repetitonIterationOrder=[],this.numberOfEndings=1,this.musicSheet2=t,this.virtualOverallRepetition=e}get BackwardJumpInstructions(){return this.backwardJumpInstructions}get EndingIndexDict(){return this.endingIndexDict}get EndingParts(){return this.endingParts}get Visibles(){return this.visibles}set Visibles(t){this.visibles=t}get DefaultNumberOfRepetitions(){let t=2;return this.virtualOverallRepetition&&(t=1),Math.max(t,Object.keys(this.endingIndexDict).length,this.checkRepetitionForMultipleLyricVerses())}get UserNumberOfRepetitions(){return this.userNumberOfRepetitions}set UserNumberOfRepetitions(t){this.userNumberOfRepetitions=t,this.repetitonIterationOrder=[];const e=this.userNumberOfRepetitions-this.NumberOfEndings;for(let t=1;t<=this.userNumberOfRepetitions;t++)t<=e?this.repetitonIterationOrder.push(1):this.repetitonIterationOrder.push(t-e)}getForwardJumpTargetForIteration(t){const e=this.repetitonIterationOrder[t-1];return this.endingIndexDict[e]?this.endingIndexDict[e].part.StartIndex:-1}getBackwardJumpTarget(){return this.startMarker.measureIndex}SetEndingStartIndex(t,e){const i=new h(new s.SourceMusicPart(this.musicSheet2,e,e));this.endingParts.push(i);for(const e of t)try{this.endingIndexDict[e]=i,i.endingIndices.push(e),this.numberOfEndings=this.xmlMeasureList.length)return!1;this.currentMeasure=t,this.inSourceMeasureInstrumentIndex=this.musicSheet.getGlobalStaffIndexOfFirstStaff(this.instrument),this.repetitionInstructionReader&&this.repetitionInstructionReader.prepareReadingMeasure(t,this.currentXmlMeasureIndex);let o=new h.Fraction(0,1),a=new h.Fraction(0,1),l=!1;this.maxTieNoteFraction=new h.Fraction(0,1);let d=!1;try{const f=this.xmlMeasureList[this.currentXmlMeasureIndex],p=f.elements();if(t.Rules.UseXMLMeasureNumbers&&!Number.isInteger(t.MeasureNumberXML)){const e=parseInt(null===(n=f.attribute("number"))||void 0===n?void 0:n.value,10);Number.isInteger(e)&&(t.MeasureNumberXML=e)}let b;for(let n=0;n0&&(b=p[n-1]),"print"===f.name){const e=f.attribute("new-system");"yes"===(null==e?void 0:e.value)&&(t.printNewSystemXml=!0);const i=f.attribute("new-page");"yes"===(null==i?void 0:i.value)&&(t.printNewPageXml=!0)}else if("note"===f.name){let t=!0;"no"===(null===(s=f.attribute("print-object"))||void 0===s?void 0:s.value)&&(t=!1);let n=1;this.instrument.Staves.length>1&&f.element("staff")&&(n=parseInt(f.element("staff").value,10),isNaN(n)&&(m.default.debug("InstrumentReader.readNextXmlMeasure.get staff number"),n=1)),this.currentStaff=this.instrument.Staves[n-1];const r=void 0!==f.element("chord");if(f.element("voice")){const t=parseInt(f.element("voice").value,10);this.currentVoiceGenerator=this.getOrCreateVoiceGenerator(t,n-1)}else r&&this.currentVoiceGenerator||(this.currentVoiceGenerator=this.getOrCreateVoiceGenerator(1,n-1));let l,u=0,p=new h.Fraction(0,1),b=2,g=!1;if(f.element("duration")){if(u=parseInt(f.element("duration").value,10),isNaN(u)){const t=c.ITextTranslation.translateText("ReaderErrorMessages/NoteDurationError","Invalid Note Duration.");this.musicSheet.SheetErrors.pushMeasureError(t),m.default.debug("InstrumentReader.readNextXmlMeasure",t);continue}if(p=new h.Fraction(u,4*this.divisions),0===u?p=this.getNoteDurationFromTypeNode(f):l=this.getNoteDurationFromTypeNode(f),f.element("time-modification")){p=this.getNoteDurationForTuplet(f);const t=f.element("time-modification");(null==t?void 0:t.element("normal-notes"))&&(b=parseInt(t.element("normal-notes").value,10)),g=!0}}const y=void 0!==f.element("rest"),S=f.element("notations"),E=void 0!==f.element("grace")||0===u||r&&d;let _=!1,w=!1;if(E){const t=f.element("grace");t&&t.attributes()&&t.attribute("slash")&&"yes"===t.attribute("slash").value&&(_=!0),p=this.getNoteDurationFromTypeNode(f);const e=f.element("notations");e&&e.element("slur")&&(w=!0)}let T=!1;f.element("cue")&&(T=!0);const M=f.element("type");let P=x.NoteType.UNDEFINED;if(M){const t=M.attribute("size");"cue"===(null==t?void 0:t.value)&&(T=!0),P=x.NoteTypeHandler.StringToNoteType(M.value)}let L,A=v.StemDirectionType.Undefined;const C=f.element("stem");if(C){switch(C.value){case"down":A=v.StemDirectionType.Down;break;case"up":A=v.StemDirectionType.Up;break;case"double":A=v.StemDirectionType.Double;break;case"none":A=v.StemDirectionType.None;break;default:A=v.StemDirectionType.Undefined}const t=C.attribute("color");t&&(L=this.parseXmlColor(t.value))}let I,R=0,N=!1;if(S){const t=S.element("ornaments");if(t){const e=t.element("tremolo");if(e){const t=e.attribute("type");if(t&&"single"===t.value){const t=parseInt(e.value,10);t>0&&(R=t)}}const i=t.element("wavy-line");if(void 0!==i){const t=i.attribute("type");t&&"start"===t.value&&(N=!0)}}}const F=f.element("notehead");if(F){const t=F.attribute("color");t&&(I=this.parseXmlColor(t.value))}let B;const O=f.attribute("color");O&&(B=this.parseXmlColor(O.value),I||(I=B),L||(L=B));let D=o.clone();r&&(D=a.clone()),this.currentStaffEntry=this.currentMeasure.findOrCreateStaffEntry(D,this.inSourceMeasureInstrumentIndex+n-1,this.currentStaff).staffEntry,(!this.currentVoiceGenerator.hasVoiceEntry()||!r&&!E&&!d||E&&!d||E&&!r||!E&&d)&&this.currentVoiceGenerator.createVoiceEntry(D,this.currentStaffEntry,!y&&!E,E,_,w),E||r||(a=o.clone(),o.Add(p)),r&&void 0!==this.currentStaffEntry&&this.currentStaffEntry.ParentStaff!==this.currentStaff&&(this.currentStaffEntry=this.currentVoiceGenerator.checkForStaffEntryLink(this.inSourceMeasureInstrumentIndex+n-1,this.currentStaff,this.currentStaffEntry,this.currentMeasure));const k=void 0!==this.currentStaffEntry&&void 0!==this.currentStaffEntry.Timestamp&&this.currentStaffEntry.Timestamp.Equals(new h.Fraction(0,1))&&!this.currentStaffEntry.hasNotes();if(this.saveAbstractInstructionList(this.instrument.Staves.length,k),0!==this.openChordSymbolContainers.length&&(this.currentStaffEntry.ChordContainers=this.openChordSymbolContainers,this.openChordSymbolContainers=[]),this.activeRhythm,g||E||(p=new h.Fraction(u,4*this.divisions)),this.currentVoiceGenerator.read(f,p,l,P,b,y,this.currentStaffEntry,this.currentMeasure,e,this.maxTieNoteFraction,r,i,t,T,E,A,R,L,I,N),void 0!==S&&S.element("dynamics")){const t=this.expressionReaders[this.readExpressionStaffNumber(f)-1];t&&(t.readExpressionParameters(f,this.instrument,this.divisions,o,a,this.currentMeasure.MeasureNumber,!1),t.read(f,this.currentMeasure,a))}d=E}else if("attributes"===f.name){const e=f.element("divisions");if(e&&(this.divisions=parseInt(e.value,10),isNaN(this.divisions))){const t=c.ITextTranslation.translateText("ReaderErrorMessages/DivisionError","Invalid divisions value at Instrument: ");if(m.default.debug("InstrumentReader.readNextXmlMeasure",t),this.divisions=this.readDivisionsFromNotes(),!(this.divisions>0))throw l=!0,new u.MusicSheetReadingException(t+this.instrument.Name);this.musicSheet.SheetErrors.push(t+this.instrument.Name)}if(!f.element("divisions")&&0===this.divisions&&0===this.currentXmlMeasureIndex){const t=c.ITextTranslation.translateText("ReaderErrorMessages/DivisionError","Invalid divisions value at Instrument: ");if(this.divisions=this.readDivisionsFromNotes(),!(this.divisions>0))throw l=!0,new u.MusicSheetReadingException(t+this.instrument.Name);this.musicSheet.SheetErrors.push(t+this.instrument.Name)}this.addAbstractInstruction(f,i,b),o.Equals(new h.Fraction(0,1))&&this.isAttributesNodeAtBeginOfMeasure(this.xmlMeasureList[this.currentXmlMeasureIndex],f)&&this.saveAbstractInstructionList(this.instrument.Staves.length,!0),this.isAttributesNodeAtEndOfMeasure(this.xmlMeasureList[this.currentXmlMeasureIndex],f)&&this.saveClefInstructionAtEndOfMeasure();const n=f.element("staff-details");if(n){const t=n.element("staff-lines");if(t){let e=1;const i=n.attribute("number");i&&(e=parseInt(i.value,10)),this.instrument.Staves[e-1].StafflineCount=parseInt(t.value,10)}}const s=f.element("measure-style");if(s){const e=s.element("multiple-rest");if(e){const i=e.value;let n=0;try{n=Number.parseInt(i,10),void 0!==t.multipleRestMeasures&&n!==t.multipleRestMeasures?t.multipleRestMeasures=0:t.multipleRestMeasures=n}catch(t){console.log("multirest parse error: "+t)}}}}else if("forward"===f.name){const t=parseInt(f.element("duration").value,10);o.Add(new h.Fraction(t,4*this.divisions))}else if("backup"===f.name){const t=parseInt(f.element("duration").value,10);o.Sub(new h.Fraction(t,4*this.divisions)),o.IsNegative()&&(o=new h.Fraction(0,1)),a.Sub(new h.Fraction(t,4*this.divisions)),a.IsNegative()&&(a=new h.Fraction(0,1))}else if("direction"===f.name){const t=f.element("direction-type");let e=Math.min(1,o.RealValue);void 0!==this.activeRhythm&&this.activeRhythm.Rhythm&&(e/=this.activeRhythm.Rhythm.RealValue);let i=!1;if(this.repetitionInstructionReader&&(i=this.repetitionInstructionReader.handleRepetitionInstructionsFromWordsOrSymbols(t,e)),!i){let e=this.expressionReaders[0];const i=this.readExpressionStaffNumber(f)-1;i0?this.musicSheet.SourceMeasures[0]:this.currentMeasure;const i=new o.ClefInstruction(d.ClefEnum.G,0,2);let n;e.FirstInstructionsStaffEntries[t]?(n=e.FirstInstructionsStaffEntries[t],n.removeFirstInstructionOfTypeClefInstruction()):(n=new r.SourceStaffEntry(void 0,void 0),e.FirstInstructionsStaffEntries[t]=n),i.Parent=n,n.Instructions.splice(0,0,i)}createDefaultKeyInstruction(){let t;t=this.musicSheet.SourceMeasures.length>0?this.musicSheet.SourceMeasures[0]:this.currentMeasure;const e=new a.KeyInstruction(void 0,0,p.KeyEnum.major);for(let i=this.inSourceMeasureInstrumentIndex;i0&&"backup"===i[n-1].name)return!0;let s=-1;for(let t=0;t0||s<0}isAttributesNodeAtEndOfMeasure(t,e){const i=t.elements().slice();let n=0;for(let t=0;ts}getNoteDurationFromTypeNode(t){const e=t.element("type");if(e){const t=e.value;return x.NoteTypeHandler.getNoteDurationFromType(t)}return new h.Fraction(0,4*this.divisions)}addAbstractInstruction(t,e,i){if(t.element("divisions")&&1===t.elements().length)return;const n=t.element("transpose");if(n){const t=n.element("chromatic");t&&(this.instrument.PlaybackTranspose=parseInt(t.value,10))}const s=t.elements("clef");let r;if(s.length>0)for(let t=0,e=s.length;t using default clef line."),this.musicSheet.SheetErrors.pushMeasureError(r),a=2,m.default.debug("InstrumentReader.addAbstractInstruction",r,t)}const f=e.element("sign");if(f)try{n=d.ClefEnum[f.value],o.ClefInstruction.isSupportedClef(n)||(r=c.ITextTranslation.translateText("ReaderErrorMessages/ClefError","Unsupported clef found -> using default clef."),this.musicSheet.SheetErrors.pushMeasureError(r),n=d.ClefEnum.G,a=2),n===d.ClefEnum.TAB&&(h=-1)}catch(t){r=c.ITextTranslation.translateText("ReaderErrorMessages/ClefError","Invalid clef found -> using default clef."),this.musicSheet.SheetErrors.pushMeasureError(r),n=d.ClefEnum.G,a=2,m.default.debug("InstrumentReader.addAbstractInstruction",r,t)}const p=e.element("clef-octave-change");if(p)try{h=parseInt(p.value,10)}catch(t){r=c.ITextTranslation.translateText("ReaderErrorMessages/ClefOctaveError","Invalid clef octave found -> using default clef octave."),this.musicSheet.SheetErrors.pushMeasureError(r),h=0}if(e.hasAttributes&&"number"===e.attributes()[0].name)try{l=parseInt(e.attributes()[0].value,10),l>this.currentClefNumber&&(l=this.currentClefNumber),this.currentClefNumber=l+1}catch(t){r=c.ITextTranslation.translateText("ReaderErrorMessages/ClefError","Invalid clef found -> using default clef."),this.musicSheet.SheetErrors.pushMeasureError(r),l=1,this.currentClefNumber=l+1}if("forward"!==(null==i?void 0:i.name)){const t=new o.ClefInstruction(n,h,a);this.abstractInstructions.push([l,t])}}if(void 0!==t.element("key")&&this.instrument.MidiInstrumentId!==b.MidiInstrument.Percussion){let e=0;const i=t.element("key").element("fifths");if(i)try{e=parseInt(i.value,10)}catch(t){r=c.ITextTranslation.translateText("ReaderErrorMessages/KeyError","Invalid key found -> set to default."),this.musicSheet.SheetErrors.pushMeasureError(r),e=0,m.default.debug("InstrumentReader.addAbstractInstruction",r,t)}let n=p.KeyEnum.none,s=t.element("key");if(s&&(s=s.element("mode")),s)try{n=p.KeyEnum[s.value]}catch(t){r=c.ITextTranslation.translateText("ReaderErrorMessages/KeyError","Invalid key found -> set to default."),this.musicSheet.SheetErrors.pushMeasureError(r),n=p.KeyEnum.major,m.default.debug("InstrumentReader.addAbstractInstruction",r,t)}const o=new a.KeyInstruction(void 0,e,n);this.abstractInstructions.push([1,o])}if(t.element("time")){const e=t.element("time");let i=f.RhythmSymbolEnum.NONE,n=!0;if(void 0!==e&&e.hasAttributes){const t=e.attribute("symbol");t&&("common"===t.value?i=f.RhythmSymbolEnum.COMMON:"cut"===t.value&&(i=f.RhythmSymbolEnum.CUT));const s=e.attribute("print-object");s&&"no"===s.value&&(n=!1)}let s=0,o=0;const a=e&&void 0!==e.element("senza-misura"),u=t.elements("time"),d=[],p=[];for(let t=0,e=u.length;t0&&void 0!==p&&d.length===p.length){const t=d.length,e=new Array(t);let i=0;for(let n=0;n set to default."),this.musicSheet.SheetErrors.pushMeasureError(r),s=4,o=4,m.default.debug("InstrumentReader.addAbstractInstruction",r,t)}const e=new l.RhythmInstruction(new h.Fraction(s,o,0,!1),i);e.PrintObject=n,this.abstractInstructions.push([1,e])}}}saveAbstractInstructionList(t,e){for(let i=this.abstractInstructions.length-1;i>=0;i--){const n=this.abstractInstructions[i],s=n[0],h=n[1];if(h instanceof o.ClefInstruction){const t=h;if(0===this.currentXmlMeasureIndex||s<=this.activeClefs.length&&t!==this.activeClefs[s-1])if(e||void 0===this.currentStaffEntry||this.currentStaffEntry.hasNotes()||s-1!==this.instrument.Staves.indexOf(this.currentStaffEntry.ParentStaff)){if(e){let e;if(this.currentMeasure){const n=t,a=this.inSourceMeasureInstrumentIndex+s-1,l=this.currentMeasure.FirstInstructionsStaffEntries[a];if(0===this.currentXmlMeasureIndex)if(l)if(void 0===this.currentMeasure.FirstInstructionsStaffEntries[a]||l.Instructions[0]instanceof o.ClefInstruction){const t=new r.SourceStaffEntry(void 0,void 0);this.currentMeasure.LastInstructionsStaffEntries[a]=t,n.Parent=t,t.Instructions.push(n)}else e=l,n.Parent=e,e.removeFirstInstructionOfTypeClefInstruction(),e.Instructions.splice(0,0,n),this.activeClefsHaveBeenInitialized[s-1]=!0;else e=new r.SourceStaffEntry(void 0,void 0),this.currentMeasure.FirstInstructionsStaffEntries[a]=e,n.Parent=e,e.Instructions.push(n),this.activeClefsHaveBeenInitialized[s-1]=!0;else if(this.activeClefsHaveBeenInitialized[s-1]){const t=new r.SourceStaffEntry(void 0,void 0);this.previousMeasure.LastInstructionsStaffEntries[a]=t,n.Parent=t,t.Instructions.push(n)}else{const t=this.musicSheet.SourceMeasures[0];t.FirstInstructionsStaffEntries[a]?(e=t.FirstInstructionsStaffEntries[a],e.removeFirstInstructionOfTypeClefInstruction()):e=new r.SourceStaffEntry(void 0,void 0),n.Parent=e,e.Instructions.splice(0,0,n),this.activeClefsHaveBeenInitialized[s-1]=!0}this.activeClefs[s-1]=t,this.abstractInstructions.splice(i,1)}}}else{const e=t;e.Parent=this.currentStaffEntry,this.currentStaffEntry.removeFirstInstructionOfTypeClefInstruction(),this.currentStaffEntry.Instructions.push(e),this.activeClefs[s-1]=t,this.abstractInstructions.splice(i,1)}else s<=this.activeClefs.length&&t===this.activeClefs[s-1]&&this.abstractInstructions.splice(i,1)}if(h instanceof a.KeyInstruction){const e=h;if(this.activeKey&&this.activeKey.Key===e.Key)this.abstractInstructions.splice(i,1);else{let n;if(this.activeKey=e,this.abstractInstructions.splice(i,1),this.activeKeyHasBeenInitialized?n=this.currentMeasure:(this.activeKeyHasBeenInitialized=!0,n=this.currentXmlMeasureIndex>0?this.musicSheet.SourceMeasures[0]:this.currentMeasure),n)for(let i=this.inSourceMeasureInstrumentIndex;i=0;t--){const e=this.abstractInstructions[t][0],i=this.abstractInstructions[t][1];if(i instanceof o.ClefInstruction){const n=i;if(!this.activeClefs[e-1]||n.ClefType!==this.activeClefs[e-1].ClefType||n.ClefType===this.activeClefs[e-1].ClefType&&n.Line!==this.activeClefs[e-1].Line){const i=new r.SourceStaffEntry(void 0,void 0);this.currentMeasure.LastInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex+e-1]=i;const s=n;s.Parent=i,i.Instructions.push(s),this.activeClefs[e-1]=n,this.abstractInstructions.splice(t,1)}}}}getNoteDurationForTuplet(t){let e=new h.Fraction(0,1);const i=this.getNoteDurationFromTypeNode(t);if(t.element("time-modification")){const n=t.element("time-modification");if(n&&void 0!==n.element("actual-notes")&&n.element("normal-notes")){const t=n.element("actual-notes"),s=n.element("normal-notes");if(void 0!==t&&s){const n=parseInt(t.value,10),r=parseInt(s.value,10);e=new h.Fraction(r*i.Numerator,n*i.Denominator)}}}return e}readExpressionStaffNumber(t){let e=1;if(t.element("staff")){const i=t.element("staff");if(i)try{e=parseInt(i.value,10)}catch(t){const i=c.ITextTranslation.translateText("ReaderErrorMessages/ExpressionStaffError","Invalid Expression staff number -> set to default.");this.musicSheet.SheetErrors.pushMeasureError(i),e=1,m.default.debug("InstrumentReader.readExpressionStaffNumber",i,t)}}return e}readDivisionsFromNotes(){let t=0,e=this.currentXmlMeasureIndex,i=!1;for(;!i;){const n=this.xmlMeasureList[e].elements();for(let e=0,s=n.length;e0){i=!0;break}}if(0===t&&(e++,e===this.xmlMeasureList.length)){const t=c.ITextTranslation.translateText("ReaderErrorMEssages/DivisionsError","Invalid divisions value at Instrument: ");throw new u.MusicSheetReadingException(t+this.instrument.Name)}}return t}}},function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.VoiceGenerator=void 0;const s=i(41),r=i(51),o=i(14),a=i(36),l=i(31),h=i(141),c=i(107),u=i(67),d=i(142),f=i(0),p=i(20),m=i(143),b=i(11),g=i(2),y=i(2),S=i(144),v=n(i(1)),x=i(2),E=i(34),_=i(145),w=i(76),T=i(80),M=i(39),P=i(172),L=i(3);e.VoiceGenerator=class{constructor(t,e,i,n,o){this.openBeams=[],this.beamNumberOffset=0,this.openTieDict={},this.currentOctaveShift=0,this.tupletDict={},this.openTupletNumber=0,this.staff=e,this.instrument=e.ParentInstrument,this.musicSheet=this.instrument.GetMusicSheet,this.slurReader=n,this.pluginManager=t,this.voice=o?new s.LinkedVoice(this.instrument,i,o):new r.Voice(this.instrument,i),this.instrument.Voices.push(this.voice),this.staff.Voices.push(this.voice),this.lyricsReader=new m.LyricsReader(this.musicSheet),this.articulationReader=new _.ArticulationReader}get GetVoice(){return this.voice}get OctaveShift(){return this.currentOctaveShift}set OctaveShift(t){this.currentOctaveShift=t}createVoiceEntry(t,e,i,n=!1,s=!1,r=!1){this.currentVoiceEntry=new o.VoiceEntry(t.clone(),this.voice,e,n,s,r),i&&this.voice.VoiceEntries.push(this.currentVoiceEntry)}read(t,e,i,n,s,r,o,a,l,h,c,d,m,b,g,y,S,v,x,E){this.currentStaffEntry=o,this.currentMeasure=a;try{this.currentNote=r?this.addRestNote(t.element("rest"),e,n,s,m,b,x):this.addSingleNote(t,e,n,i,s,c,d,m,b,g,y,S,v,x,E);const o=t.elements("lyric");void 0!==this.lyricsReader&&o&&(this.lyricsReader.addLyricEntry(o,this.currentVoiceEntry),this.voice.Parent.HasLyrics=!0);let a=!1;const p=t.element("notations");if(p){this.articulationReader&&this.readArticulations(p,this.currentVoiceEntry,this.currentNote);const e=p.elements("slur");void 0!==this.slurReader&&e.length>0&&!this.currentNote.ParentVoiceEntry.IsGrace&&this.slurReader.addSlur(e,this.currentNote);const i=p.elements("tuplet");i.length>0&&(this.openTupletNumber=this.addTuplet(t,i),a=!0);const n=p.element("arpeggiate");if(void 0!==n){let t;if(this.currentVoiceEntry.Arpeggio)t=this.currentVoiceEntry.Arpeggio;else{let e=!1;for(const i of this.currentStaffEntry.VoiceEntries)if(i.Arpeggio){e=!0,t=i.Arpeggio;break}if(!e){let e=T.ArpeggioType.ARPEGGIO_DIRECTIONLESS;const i=n.attribute("direction");if(i)switch(i.value){case"up":e=T.ArpeggioType.ROLL_UP;break;case"down":e=T.ArpeggioType.ROLL_DOWN;break;default:e=T.ArpeggioType.ARPEGGIO_DIRECTIONLESS}t=new T.Arpeggio(this.currentVoiceEntry,e),this.currentVoiceEntry.Arpeggio=t}}t.addNote(this.currentNote)}const s=p.elements("tied");s.length>0&&this.addTie(s,l,h,u.TieTypes.SIMPLE);const r=p.elements("slide");r.length>0&&this.addTie(r,l,h,u.TieTypes.SLIDE);const o=p.element("technical");if(o){const t=o.elements("hammer-on");t.length>0&&this.addTie(t,l,h,u.TieTypes.HAMMERON);const e=o.elements("pull-off");e.length>0&&this.addTie(e,l,h,u.TieTypes.PULLOFF)}const c=this.openTieDict;for(const t in c)if(c.hasOwnProperty(t)){const e=c[t];f.Fraction.plus(e.StartNote.ParentStaffEntry.Timestamp,e.Duration).lt(this.currentStaffEntry.Timestamp)&&delete c[t]}}void 0===t.element("time-modification")||a||this.handleTimeModificationNode(t)}catch(t){const e=p.ITextTranslation.translateText("ReaderErrorMessages/NoteError","Ignored erroneous Note.");this.musicSheet.SheetErrors.pushMeasureError(e)}return this.currentNote}checkForStaffEntryLink(t,e,i,n){const s=new S.StaffEntryLink(this.currentVoiceEntry);s.LinkStaffEntries.push(i),i.Link=s;const r=this.currentVoiceEntry.Timestamp.clone(),o=n.getVerticalContainerByTimestamp(r);return(i=o.StaffEntries[t])||(i=new l.SourceStaffEntry(o,e),o.StaffEntries[t]=i),i.VoiceEntries.push(this.currentVoiceEntry),s.LinkStaffEntries.push(i),i.Link=s,i}checkForOpenBeam(){this.openBeams.length>0&&this.currentNote&&this.handleOpenBeam()}checkOpenTies(){const t=this.openTieDict;for(const e in t)if(t.hasOwnProperty(e)){const i=t[e];f.Fraction.plus(i.StartNote.ParentStaffEntry.Timestamp,i.Duration).lt(i.StartNote.SourceMeasure.Duration)&&delete t[e]}}hasVoiceEntry(){return void 0!==this.currentVoiceEntry}readArticulations(t,e,i){const n=t.element("articulations");n&&this.articulationReader.addArticulationExpression(n,e);const s=t.element("fermata");s&&this.articulationReader.addFermata(s,e);const r=t.element("technical");r&&this.articulationReader.addTechnicalArticulations(r,e,i);const o=t.element("ornaments");o&&this.articulationReader.addOrnament(o,e)}addSingleNote(t,e,i,n,s,r,l,h,c,u,d,m,S,E,_){let T,M,L,A=0,C=g.AccidentalEnum.NONE,I=y.NoteEnum.C,R=y.NoteEnum.C,N=0,F=0;const B=t.elements();for(let t=0,e=B.length;t0&&this.openBeams.last().ExtendedNoteList.push(m),m}addNoteInfo(t,e,i,n,s,r,o,a,l){t.NoteTypeXml=e,t.PrintObject=i,t.IsCueNote=n,t.NormalNotes=s,t.displayStepUnpitched=r,t.displayOctaveUnpitched=o,t.NoteheadColorXml=a,t.NoteheadColor=a}createBeam(t,e){var i;try{const n=t.element("beam");let s;if(void 0!==n&&n.hasAttributes&&(s=n.attribute("number")),s){let n=parseInt(s.value,10);const r=t.elements("beam"),o=r[0].value;r&&("begin"===o?(n===(null===(i=this.openBeams.last())||void 0===i?void 0:i.BeamNumber)?(this.beamNumberOffset++,n+=this.beamNumberOffset):this.openBeams.last()&&this.handleOpenBeam(),this.openBeams.push(new h.Beam(n,this.beamNumberOffset))):n+=this.beamNumberOffset);let a=!1;if(!(n>0&&n<=this.openBeams.length&&this.openBeams[n-1]))return void v.default.debug("[OSMD] invalid beamnumber");for(let t=0,e=this.openBeams[n-1].Notes.length;t1){let n=t.element("time-modification");n&&(n=n.element("actual-notes"));const s=e;for(let e=0,r=s.length;e1&&this.openTupletNumber--),this.tupletDict[e]=a;const l=[];l.push(this.currentNote),a.Notes.push(l),a.Fractions.push(this.getTupletNoteDurationFromType(t)),this.currentNote.NoteTuplet=a,this.openTupletNumber=e}else if("stop"===a.value){let e=1;r.attribute("number")&&(e=parseInt(r.attribute("number").value,10));const i=this.tupletDict[e];if(i){const n=[];n.push(this.currentNote),i.Notes.push(n),i.Fractions.push(this.getTupletNoteDurationFromType(t)),this.currentNote.NoteTuplet=i,delete this.tupletDict[e],0===Object.keys(this.tupletDict).length?this.openTupletNumber=0:Object.keys(this.tupletDict).length>1&&this.openTupletNumber--}}}}}else if(e[0]){const n=e[0];if(n.hasAttributes){const e=n.attribute("type").value;let s=1;n.attribute("number")&&(s=parseInt(n.attribute("number").value,10));const r=isNaN(s),o=n.attribute("bracket");o&&"yes"===o.value&&(i=!0);const a=n.attribute("placement"),l=a&&"below"===a.value;if("start"===e){let e=0,n=t.element("time-modification");if(n&&(n=n.element("actual-notes")),n&&(e=parseInt(n.value,10),isNaN(e))){const t=p.ITextTranslation.translateText("ReaderErrorMessages/TupletNoteDurationError","Invalid tuplet note duration.");throw this.musicSheet.SheetErrors.pushMeasureError(t),new b.MusicSheetReadingException(t)}r&&(this.openTupletNumber++,s=this.openTupletNumber);let o=this.tupletDict[s];o||(o=this.tupletDict[s]=new d.Tuplet(e,i),o.tupletLabelNumberPlacement=l?L.PlacementEnum.Below:L.PlacementEnum.Above);const a=[];a.push(this.currentNote),o.Notes.push(a),o.Fractions.push(this.getTupletNoteDurationFromType(t)),this.currentNote.NoteTuplet=o,this.openTupletNumber=s}else if("stop"===e){r&&(s=this.openTupletNumber);const e=this.tupletDict[this.openTupletNumber];if(e){const i=[];i.push(this.currentNote),e.Notes.push(i),e.Fractions.push(this.getTupletNoteDurationFromType(t)),this.currentNote.NoteTuplet=e,0===Object.keys(this.tupletDict).length?this.openTupletNumber=0:Object.keys(this.tupletDict).length>1&&this.openTupletNumber--,delete this.tupletDict[s]}}}}return this.openTupletNumber}handleTimeModificationNode(t){if(this.tupletDict[this.openTupletNumber])try{const e=this.tupletDict[this.openTupletNumber],i=E.CollectionUtil.last(e.Notes);let n;i[0].ParentVoiceEntry.Timestamp.Equals(this.currentVoiceEntry.Timestamp)?n=i:(n=[],e.Notes.push(n),e.Fractions.push(this.getTupletNoteDurationFromType(t))),n.push(this.currentNote),this.currentNote.NoteTuplet=e}catch(t){const e=p.ITextTranslation.translateText("ReaderErrorMessages/TupletNumberError","Invalid tuplet number.");throw this.musicSheet.SheetErrors.pushMeasureError(e),t}else if(this.currentVoiceEntry.Notes.length>0){const t=this.currentVoiceEntry.Notes[0];if(t.NoteTuplet){const e=t.NoteTuplet;E.CollectionUtil.last(e.Notes).push(this.currentNote),this.currentNote.NoteTuplet=e}}}addTie(t,e,i,n){if(t)if(1===t.length){const e=t[0];if(void 0!==e&&e.attributes()){const t=e.attribute("type").value;try{if("start"===t){const t=this.findCurrentNoteInTieDict(this.currentNote);t<0&&delete this.openTieDict[t];const e=this.getNextAvailableNumberForTie(),i=new c.Tie(this.currentNote,n);this.openTieDict[e]=i}else if("stop"===t){const t=this.findCurrentNoteInTieDict(this.currentNote),e=this.openTieDict[t];e&&(e.AddNote(this.currentNote),delete this.openTieDict[t])}}catch(t){const e=p.ITextTranslation.translateText("ReaderErrorMessages/TieError","Error while reading tie.");this.musicSheet.SheetErrors.pushMeasureError(e)}}}else if(2===t.length){const t=this.findCurrentNoteInTieDict(this.currentNote);t>=0&&this.openTieDict[t].AddNote(this.currentNote)}}getNextAvailableNumberForTie(){const t=Object.keys(this.openTieDict);if(0===t.length)return 1;t.sort(((t,e)=>+t-+e));for(let e=0;e=0;e--)for(let i=0;i0)for(let t=s;t1&&(d=parseInt(t[1],10))}catch(t){const e=r.ITextTranslation.translateText("ReaderErrorMessages/LyricVerseNumberError","Invalid lyric verse number");this.musicSheet.SheetErrors.pushMeasureError(e);continue}}if("single"===t||"end"===t){if(this.openLyricWords[d]){this.currentLyricWord=this.openLyricWords[d];const t=this.currentLyricWord.Syllables.length;u=new s.LyricsEntry(h,d,this.currentLyricWord,e,t),this.currentLyricWord.Syllables.push(u),delete this.openLyricWords[d],this.currentLyricWord=void 0}else u=new s.LyricsEntry(h,d,void 0,e);u.extend=void 0!==l.element("extend")}else if("begin"===t)this.openLyricWords[d]&&(delete this.openLyricWords[d],this.currentLyricWord=void 0),this.currentLyricWord=new n.LyricWord,this.openLyricWords[d]=this.currentLyricWord,u=new s.LyricsEntry(h,d,this.currentLyricWord,e,0),this.currentLyricWord.Syllables.push(u);else if("middle"===t)if(this.openLyricWords[d]){this.currentLyricWord=this.openLyricWords[d];const t=this.currentLyricWord.Syllables.length;u=new s.LyricsEntry(h,d,this.currentLyricWord,e,t),this.currentLyricWord.Syllables.push(u)}else u=new s.LyricsEntry(h,d,void 0,e);u&&(e.LyricsEntries[d]||(e.LyricsEntries.setValue(d,u),(null===(o=null===(i=e.ParentSourceStaffEntry)||void 0===i?void 0:i.VerticalContainerParent)||void 0===o?void 0:o.ParentMeasure)&&(e.ParentSourceStaffEntry.VerticalContainerParent.ParentMeasure.hasLyrics=!0)),e.ParentVoice.Parent.LyricVersesNumbers[d]||e.ParentVoice.Parent.LyricVersesNumbers.push(d))}}}catch(t){const e=r.ITextTranslation.translateText("ReaderErrorMessages/LyricError","Error while reading lyric entry.");this.musicSheet.SheetErrors.pushMeasureError(e);continue}}e.ParentVoice.Parent.LyricVersesNumbers=e.ParentVoice.Parent.LyricVersesNumbers.filter(((t,e,i)=>i.indexOf(t)===e))}}}},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.StaffEntryLink=void 0,e.StaffEntryLink=class{constructor(t){this.linkStaffEntries=[],this.voiceEntry=t}get GetVoiceEntry(){return this.voiceEntry}get LinkStaffEntries(){return this.linkStaffEntries}set LinkStaffEntries(t){this.linkStaffEntries=t}}},function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.ArticulationReader=void 0;const s=i(14),r=n(i(1)),o=i(146),a=i(50),l=i(3),h=i(2),c=i(171);e.ArticulationReader=class{getAccEnumFromString(t){switch(t){case"sharp":return h.AccidentalEnum.SHARP;case"flat":return h.AccidentalEnum.FLAT;case"natural":return h.AccidentalEnum.NATURAL;case"double-sharp":case"sharp-sharp":return h.AccidentalEnum.DOUBLESHARP;case"double-flat":case"flat-flat":return h.AccidentalEnum.DOUBLEFLAT;case"quarter-sharp":return h.AccidentalEnum.QUARTERTONESHARP;case"quarter-flat":return h.AccidentalEnum.QUARTERTONEFLAT;case"triple-sharp":return h.AccidentalEnum.TRIPLESHARP;case"triple-flat":return h.AccidentalEnum.TRIPLEFLAT;default:return h.AccidentalEnum.NONE}}addArticulationExpression(t,e){var i,n;if(void 0!==t&&t.elements().length>0){const o=t.elements();for(let t=0,a=o.length;t0&&e.Articulations[0].articulationEnum!==s.ArticulationEnum.staccato&&e.Articulations.splice(0,0,u),"strongaccent"===h){const t=null===(n=null==a?void 0:a.attribute("type"))||void 0===n?void 0:n.value;"up"===t?u.articulationEnum=s.ArticulationEnum.marcatoup:"down"===t&&(u.articulationEnum=s.ArticulationEnum.marcatodown)}e.hasArticulation(u)||e.Articulations.push(u)}}catch(t){const e="Invalid note articulation.";return void r.default.debug("addArticulationExpression",e,t)}}}}addFermata(t,e){var i;let n=s.ArticulationEnum.fermata;t.attributes().length>0&&t.attribute("type")&&"inverted"===t.attribute("type").value&&(n=s.ArticulationEnum.invertedfermata);let r=l.PlacementEnum.Above;"below"===(null===(i=t.attribute("placement"))||void 0===i?void 0:i.value)&&(r=l.PlacementEnum.Below),e.Articulations.push(new c.Articulation(n,r))}addTechnicalArticulations(t,e,i){var n,r;const a={bend:s.ArticulationEnum.bend,"down-bow":s.ArticulationEnum.downbow,"open-string":s.ArticulationEnum.naturalharmonic,"snap-pizzicato":s.ArticulationEnum.snappizzicato,stopped:s.ArticulationEnum.lefthandpizzicato,"up-bow":s.ArticulationEnum.upbow};for(const i in a){if(!a.hasOwnProperty(i))continue;const s=a[i],o=t.element(i);if(o){let t;"above"===(null===(n=o.attribute("placement"))||void 0===n?void 0:n.value)&&(t=l.PlacementEnum.Above),"below"===(null===(r=o.attribute("placement"))||void 0===r?void 0:r.value)&&(t=l.PlacementEnum.Below);const i=new c.Articulation(s,t);e.hasArticulation(i)||e.Articulations.push(i)}}const h=t.element("fingering");if(h){const t=this.createTechnicalInstruction(h,i);t.type=o.TechnicalInstructionType.Fingering,i.Fingering=t,e.TechnicalInstructions.push(t)}const u=t.element("string");if(u){const t=this.createTechnicalInstruction(u,i);t.type=o.TechnicalInstructionType.String,i.StringInstruction=t,e.TechnicalInstructions.push(t)}}createTechnicalInstruction(t,e){const i=new o.TechnicalInstruction;i.sourceNote=e,i.value=t.value;const n=t.attribute("placement");return i.placement=this.getPlacement(n),i}getPlacement(t,e=l.PlacementEnum.NotYetDefined){if(e!==l.PlacementEnum.NotYetDefined)return e;if(!t)return l.PlacementEnum.NotYetDefined;switch(t.value){case"above":return l.PlacementEnum.Above;case"below":return l.PlacementEnum.Below;case"left":return l.PlacementEnum.Left;case"right":return l.PlacementEnum.Right;default:return l.PlacementEnum.NotYetDefined}}addOrnament(t,e){if(t){let i;const n={"delayed-inverted-turn":a.OrnamentEnum.DelayedInvertedTurn,"delayed-turn":a.OrnamentEnum.DelayedTurn,"inverted-mordent":a.OrnamentEnum.InvertedMordent,"inverted-turn":a.OrnamentEnum.InvertedTurn,mordent:a.OrnamentEnum.Mordent,"trill-mark":a.OrnamentEnum.Trill,turn:a.OrnamentEnum.Turn};for(const e in n){if(!n.hasOwnProperty(e))continue;const s=t.element(e);if(s){i=new a.OrnamentContainer(n[e]);const t=s.attribute("placement");t&&"below"===t.value&&(i.placement=l.PlacementEnum.Below)}}if(i){const n=t.elements("accidental-mark");if(n){let t=l.PlacementEnum.Below,e=h.AccidentalEnum.NONE;const s=n;for(let n=0,r=s.length;n0?n.RealValue>0?(h=s.Fraction.multiply(s.Fraction.minus(n,r),h),this.directionTimestamp=s.Fraction.plus(h,n)):this.directionTimestamp=s.Fraction.createFromFraction(h):this.offsetDivisions<0&&(n.RealValue>0?(h=s.Fraction.multiply(s.Fraction.minus(n,r),h),this.directionTimestamp=s.Fraction.minus(n,h)):this.directionTimestamp=s.Fraction.createFromFraction(h));const c=t.attribute("placement");if(c)try{const t=c.value;"below"===t?this.placement=p.PlacementEnum.Below:"above"===t&&(this.placement=p.PlacementEnum.Above)}catch(t){const e=b.ITextTranslation.translateText("ReaderErrorMessages/ExpressionPlacementError","Invalid expression placement -> set to default.");g.default.debug("ExpressionReader.readExpressionParameters",e,t),this.musicSheet.SheetErrors.pushMeasureError(e),this.placement=p.PlacementEnum.Below}if(this.placement===p.PlacementEnum.NotYetDefined)try{const e=t.element("direction-type");if(e){const t=e.element("dynamics");if(t){const e=t.attribute("default-y");e&&this.readExpressionPlacement(e,"read dynamics y pos")}const i=e.element("wedge");if(i){const t=i.attribute("default-y");t&&this.readExpressionPlacement(t,"read wedge y pos")}const n=e.element("words");if(n){const t=n.attribute("default-y");t&&this.readExpressionPlacement(t,"read words y pos")}const s=e.element("rehearsal");if(s){const t=s.attribute("default-y");t&&this.readExpressionPlacement(t,"read rehearsal pos")}}}catch(t){const e=b.ITextTranslation.translateText("ReaderErrorMessages/ExpressionPlacementError","Invalid expression placement -> set to default.");g.default.debug("ExpressionReader.readExpressionParameters",e,t),this.musicSheet.SheetErrors.pushMeasureError(e),this.placement=p.PlacementEnum.Below}this.placement===p.PlacementEnum.NotYetDefined&&(e.Staves.length>1?this.placement=p.PlacementEnum.Below:e.HasLyrics?this.placement=p.PlacementEnum.Above:this.placement=p.PlacementEnum.Below)}read(t,e,i){let n=!1,r=!1;const o=t.element("sound");if(o){const t=o.attribute("tempo"),i=o.attribute("dynamics");if(t){const i=t.value.match(/\d+/);this.soundTempo=void 0!==i?parseInt(i[0],10):100,e.TempoInBPM=this.soundTempo,0===this.musicSheet.DefaultStartTempoInBpm&&(this.musicSheet.DefaultStartTempoInBpm=this.soundTempo),this.musicSheet.HasBPMInfo=!0,n=!0}if(i){const t=i.value.match(/\d+/);this.soundDynamic=void 0!==t?parseInt(t[0],10):100,r=!0}}const a=t.element("direction-type");if(!a)return;let l=a.element("metronome");if(l){const t=l.element("beat-unit"),n=void 0!==l.element("beat-unit-dot"),r=l.element("per-minute");if(void 0!==t&&r){l.hasAttributes&&void 0!==l.attribute("default-x")&&(this.directionTimestamp=s.Fraction.createFromFraction(i));const o=parseInt(r.value,10);this.createNewTempoExpressionIfNeeded(e);const a=new u.InstantaneousTempoExpression(void 0,this.placement,this.staffNumber,o,this.currentMultiTempoExpression,!0);a.parentMeasure=e,this.soundTempo=o,e.TempoInBPM=this.soundTempo,0===this.musicSheet.DefaultStartTempoInBpm&&(this.musicSheet.DefaultStartTempoInBpm=this.soundTempo),this.musicSheet.HasBPMInfo=!0,a.dotted=n,a.beatUnit=t.value,this.currentMultiTempoExpression.addExpression(a,""),this.currentMultiTempoExpression.CombinedExpressionsText="test"}}else if(l=a.element("dynamics"),l){const n=void 0!==t.element("notations");this.interpretInstantaneousDynamics(l,e,i,n)}else if(l=a.element("words"),l)if(n){this.createNewTempoExpressionIfNeeded(e),this.currentMultiTempoExpression.CombinedExpressionsText=l.value;const t=new u.InstantaneousTempoExpression(l.value,this.placement,this.staffNumber,this.soundTempo,this.currentMultiTempoExpression);this.currentMultiTempoExpression.addExpression(t,"")}else r||this.interpretWords(l,e,i);else l=a.element("wedge"),l?this.interpretWedge(l,e,i,e.MeasureNumber):(l=a.element("rehearsal"),l&&this.interpretRehearsalMark(l,e,i,e.MeasureNumber))}checkForOpenExpressions(t,e){this.openContinuousDynamicExpression&&(this.createNewMultiExpressionIfNeeded(t,e),this.closeOpenContinuousDynamic()),this.openContinuousTempoExpression&&this.closeOpenContinuousTempo(s.Fraction.plus(t.AbsoluteTimestamp,e))}addOctaveShift(t,e,i){let n=1;const s=t.element("staff");if(s)try{n=parseInt(s.value,10)}catch(t){const e=b.ITextTranslation.translateText("ReaderErrorMessages/OctaveShiftStaffError","Invalid octave shift staff number -> set to default");this.musicSheet.SheetErrors.pushMeasureError(e),n=1,g.default.debug("ExpressionReader.addOctaveShift",e,t)}const r=t.element("direction-type");if(r){const t=r.element("octave-shift");if(void 0!==t&&t.hasAttributes)try{if(t.attribute("size")){const s=parseInt(t.attribute("size").value,10);let r=0;if(8===s?r=1:15===s&&(r=2),t.attribute("type")){const s=t.attribute("type").value;if("up"===s||"down"===s){const t=new h.OctaveShift(s,r);t.StaffNumber=n,this.createNewMultiExpressionIfNeeded(e),this.getMultiExpression.OctaveShiftStart=t,t.ParentStartMultiExpression=this.getMultiExpression,this.openOctaveShift=t}else"stop"===s&&this.openOctaveShift&&(this.createNewMultiExpressionIfNeeded(e,i),this.getMultiExpression.OctaveShiftEnd=this.openOctaveShift,this.openOctaveShift.ParentEndMultiExpression=this.getMultiExpression,this.openOctaveShift=void 0)}}}catch(t){const e=b.ITextTranslation.translateText("ReaderErrorMessages/OctaveShiftError","Error while reading octave shift.");this.musicSheet.SheetErrors.pushMeasureError(e),g.default.debug("ExpressionReader.addOctaveShift",e,t)}}}initialize(){this.placement=p.PlacementEnum.NotYetDefined,this.soundTempo=0,this.soundDynamic=0,this.offsetDivisions=0}readExpressionPlacement(t,e){try{const e=parseInt(t.value,10);e<0?this.placement=p.PlacementEnum.Below:e>0&&(this.placement=p.PlacementEnum.Above)}catch(t){g.default.debug("ExpressionReader.readExpressionParameters",e,t)}}interpretInstantaneousDynamics(t,e,i,n){if(t.hasElements){t.hasAttributes&&t.attribute("default-x")&&(this.directionTimestamp=s.Fraction.createFromFraction(i));let r=t.elements()[0].name;if("other-dynamics"===r&&(r=t.elements()[0].value),r){n?this.createNewMultiExpressionIfNeeded(e,s.Fraction.createFromFraction(i)):this.createNewMultiExpressionIfNeeded(e),void 0!==this.openContinuousDynamicExpression&&this.openContinuousDynamicExpression.StartMultiExpression!==this.getMultiExpression&&this.closeOpenContinuousDynamic();const t=new l.InstantaneousDynamicExpression(r,this.soundDynamic,this.placement,this.staffNumber,e);this.getMultiExpression.addExpression(t,""),this.initialize(),this.activeInstantaneousDynamic?this.activeInstantaneousDynamic.DynEnum=t.DynEnum:this.activeInstantaneousDynamic=new l.InstantaneousDynamicExpression(r,0,p.PlacementEnum.NotYetDefined,1,e)}}}interpretWords(t,e,i){const n=t.value;let r;const o=t.attribute("font-style");if(o&&"italic"===o.value&&(r=y.FontStyles.Italic),n.length>0){if(t.hasAttributes&&t.attribute("default-x")&&(this.directionTimestamp=s.Fraction.createFromFraction(i)),this.checkIfWordsNodeIsRepetitionInstruction(n))return;this.fillMultiOrTempoExpression(n,e,r),this.initialize()}}interpretWedge(t,e,i,n){void 0!==t&&t.hasAttributes&&t.attribute("default-x")&&(this.directionTimestamp=s.Fraction.createFromFraction(i)),this.createNewMultiExpressionIfNeeded(e),this.addWedge(t,e),this.initialize()}interpretRehearsalMark(t,e,i,n){e.rehearsalExpression=new S.RehearsalExpression(t.value,this.placement)}createNewMultiExpressionIfNeeded(t,e){e||(e=this.directionTimestamp),(!this.getMultiExpression||this.getMultiExpression&&(this.getMultiExpression.SourceMeasureParent!==t||this.getMultiExpression.SourceMeasureParent===t&&this.getMultiExpression.Timestamp!==e))&&(this.getMultiExpression=new c.MultiExpression(t,s.Fraction.createFromFraction(e)),t.StaffLinkedExpressions[this.globalStaffIndex].push(this.getMultiExpression))}createNewTempoExpressionIfNeeded(t){this.currentMultiTempoExpression&&this.currentMultiTempoExpression.SourceMeasureParent===t&&this.currentMultiTempoExpression.Timestamp===this.directionTimestamp||(this.currentMultiTempoExpression=new r.MultiTempoExpression(t,s.Fraction.createFromFraction(this.directionTimestamp)),t.TempoExpressions.push(this.currentMultiTempoExpression))}addWedge(t,e){if(void 0!==t&&t.hasAttributes){const i=t.attribute("type").value.toLowerCase();try{if("crescendo"===i||"diminuendo"===i){const t=new o.ContinuousDynamicExpression(o.ContDynamicEnum[i],this.placement,this.staffNumber,e);this.openContinuousDynamicExpression&&this.closeOpenContinuousDynamic(),this.openContinuousDynamicExpression=t,this.getMultiExpression.StartingContinuousDynamic=t,t.StartMultiExpression=this.getMultiExpression,void 0!==this.activeInstantaneousDynamic&&this.activeInstantaneousDynamic.StaffNumber===t.StaffNumber&&(this.activeInstantaneousDynamic=void 0)}else"stop"===i&&this.openContinuousDynamicExpression&&this.closeOpenContinuousDynamic()}catch(t){const e="ReaderErrorMessages/WedgeError, Error while reading Crescendo / Diminuendo.";this.musicSheet.SheetErrors.pushMeasureError(e),g.default.debug("ExpressionReader.addWedge",e,t)}}}fillMultiOrTempoExpression(t,e,i){if(!t)return;const n=t.trim();this.createExpressionFromString("",n,e,t,i)}createExpressionFromString(t,e,i,n,s){if(u.InstantaneousTempoExpression.isInputStringInstantaneousTempo(e)||a.ContinuousTempoExpression.isInputStringContinuousTempo(e)){if(i.TempoExpressions.length>0)for(let t=0,n=i.TempoExpressions.length;t0)for(let t=0,n=i.TempoExpressions.length;t0&&!this.hasDigit(e)&&this.globalStaffIndex>0){if(n.EntriesList[0].label.indexOf(e)>=0)return!1;break}}let r=m.TextAlignmentEnum.CenterBottom;this.musicSheet.Rules.CompactMode&&(r=m.TextAlignmentEnum.LeftBottom);const h=new f.UnknownExpression(e,this.placement,r,this.staffNumber);return h.fontStyle=s,this.getMultiExpression.addExpression(h,t),!1}closeOpenContinuousDynamic(){this.openContinuousDynamicExpression.EndMultiExpression=this.getMultiExpression,this.getMultiExpression.EndingContinuousDynamic=this.openContinuousDynamicExpression,this.openContinuousDynamicExpression=void 0}closeOpenContinuousTempo(t){this.openContinuousTempoExpression.AbsoluteEndTimestamp=t,this.openContinuousTempoExpression=void 0}checkIfWordsNodeIsRepetitionInstruction(t){return"coda"===(t=t.trim().toLowerCase())||"tocoda"===t||"to coda"===t||"fine"===t||"d.c."===t||"dacapo"===t||"da capo"===t||"d.s."===t||"dalsegno"===t||"dal segno"===t||"d.c. al fine"===t||"d.s. al fine"===t||"d.c. al coda"===t||"d.s. al coda"===t}hasDigit(t){return/\d/.test(t)}}},function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.SlurReader=void 0;const s=i(173),r=n(i(1)),o=i(20),a=i(102);e.SlurReader=class{constructor(t){this.openSlurDict={},this.musicSheet=t}addSlur(t,e){try{if(t)for(const i of t)if(i.attributes().length>0){const t=i.attribute("type").value;let n=1;try{i.attribute("number")&&(n=parseInt(i.attribute("number").value,10))}catch(t){r.default.debug("VoiceGenerator.addSlur number: ",t)}let o=a.PlacementEnum.NotYetDefined;const l=i.attribute("placement");l&&l.value&&("above"===l.value?o=a.PlacementEnum.Above:"below"===l.value&&(o=a.PlacementEnum.Below));const h=i.attribute("orientation");if(h&&h.value&&("over"===h.value?o=a.PlacementEnum.Above:"under"===h.value&&(o=a.PlacementEnum.Below)),"start"===t){let t=this.openSlurDict[n];t||(t=new s.Slur,this.openSlurDict[n]=t),t.StartNote=e,t.PlacementXml=o}else if("stop"===t){const t=this.openSlurDict[n];t&&(t.EndNote=e,e.checkForDoubleSlur(t)||(e.NoteSlurs.push(t),t.StartNote.NoteSlurs.push(t)),delete this.openSlurDict[n])}}}catch(t){const e=o.ITextTranslation.translateText("ReaderErrorMessages/SlurError","Error while reading slur.");this.musicSheet.SheetErrors.pushMeasureError(e)}}}},function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.SubInstrument=void 0;const s=i(7),r=n(i(1));class o{constructor(t){this.parentInstrument=t,this.fixedKey=-1,this.name=this.parseMidiInstrument(this.parentInstrument.Name),this.midiInstrumentID=o.midiInstrument[this.name],this.volume=1}get ParentInstrument(){return this.parentInstrument}static isPianoInstrument(t){return t===s.MidiInstrument.Acoustic_Grand_Piano||t===s.MidiInstrument.Bright_Acoustic_Piano||t===s.MidiInstrument.Electric_Grand_Piano||t===s.MidiInstrument.Electric_Piano_1||t===s.MidiInstrument.Electric_Piano_2}setMidiInstrument(t){this.midiInstrumentID=o.midiInstrument[this.parseMidiInstrument(t)]}parseMidiInstrument(t){try{if(t){const e=t.toLowerCase().trim();for(const t in o.midiInstrument)if(-1!==e.indexOf(t))return t}if(this.parentInstrument.Name){const t=this.parentInstrument.Name.toLowerCase().trim();for(const e in o.midiInstrument)if(-1!==t.indexOf(e))return e}}catch(t){r.default.error("Error parsing MIDI Instrument. Default to Grand Piano.")}return"unnamed"}}e.SubInstrument=o,o.midiInstrument={alt:s.MidiInstrument.Synth_Voice,alto:s.MidiInstrument.Synth_Voice,banjo:s.MidiInstrument.Banjo,bariton:s.MidiInstrument.Synth_Voice,baritone:s.MidiInstrument.Synth_Voice,bass:s.MidiInstrument.Synth_Voice,"blockflöte":s.MidiInstrument.Recorder,brass:s.MidiInstrument.Trombone,bratsche:s.MidiInstrument.Viola,cello:s.MidiInstrument.Cello,clarinet:s.MidiInstrument.Clarinet,contrabass:s.MidiInstrument.Contrabass,drums:s.MidiInstrument.Percussion,flute:s.MidiInstrument.Flute,"flöte":s.MidiInstrument.Flute,frenchhorn:s.MidiInstrument.French_Horn,gitarre:s.MidiInstrument.Acoustic_Guitar_nylon,guitar:s.MidiInstrument.Acoustic_Guitar_nylon,harfe:s.MidiInstrument.Orchestral_Harp,harp:s.MidiInstrument.Orchestral_Harp,klarinette:s.MidiInstrument.Clarinet,klavier:s.MidiInstrument.Acoustic_Grand_Piano,kontrabass:s.MidiInstrument.Contrabass,oboe:s.MidiInstrument.Oboe,organ:s.MidiInstrument.Church_Organ,orgel:s.MidiInstrument.Church_Organ,orgue:s.MidiInstrument.Church_Organ,percussion:s.MidiInstrument.Percussion,piano:s.MidiInstrument.Acoustic_Grand_Piano,piccolo:s.MidiInstrument.Piccolo,posaune:s.MidiInstrument.Trombone,recorder:s.MidiInstrument.Recorder,sax:s.MidiInstrument.Tenor_Sax,schlagwerk:s.MidiInstrument.Percussion,schlagzeug:s.MidiInstrument.Percussion,sopran:s.MidiInstrument.Synth_Voice,steeldrum:s.MidiInstrument.Steel_Drums,streicher:s.MidiInstrument.String_Ensemble_1,strings:s.MidiInstrument.String_Ensemble_1,tenor:s.MidiInstrument.Synth_Voice,tpt:s.MidiInstrument.Trumpet,trombone:s.MidiInstrument.Trombone,trompete:s.MidiInstrument.Trumpet,trumpet:s.MidiInstrument.Trumpet,tuba:s.MidiInstrument.Tuba,unnamed:s.MidiInstrument.Acoustic_Grand_Piano,viola:s.MidiInstrument.Viola,violin:s.MidiInstrument.Violin,"violon-c":s.MidiInstrument.Cello,"violon.":s.MidiInstrument.Violin,voice:s.MidiInstrument.Synth_Voice,woodblock:s.MidiInstrument.Woodblock}},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.MusicSymbolModuleFactory=void 0;const n=i(152),s=i(153);e.MusicSymbolModuleFactory=class{static createRepetitionInstructionReader(){return new n.RepetitionInstructionReader}static createRepetitionCalculator(){return new s.RepetitionCalculator}}},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.RepetitionInstructionReader=void 0;const n=i(28),s=i(28),r=i(174);e.RepetitionInstructionReader=class{set MusicSheet(t){this.musicSheet=t,this.xmlMeasureList=new Array(this.musicSheet.Instruments.length),this.repetitionInstructions=[]}prepareReadingMeasure(t,e){this.currentMeasureIndex=e}handleLineRepetitionInstructions(t){let e=!1;if(t.elements().length>0){let i="",s=!1,r="",o="",a="";const l=[],h=t.element("bar-style");h&&(a=h.value),i=t.attributes().length>0&&t.attribute("location")?t.attribute("location").value:"right";const c=t.elements();for(let t=0,e=c.length;t0)if("left"===i){if("start"===o){const t=new n.RepetitionInstruction(this.currentMeasureIndex,n.RepetitionInstructionEnum.Ending,n.AlignmentType.Begin,void 0,l);this.addInstruction(this.repetitionInstructions,t)}if("forward"===r){const t=new n.RepetitionInstruction(this.currentMeasureIndex,n.RepetitionInstructionEnum.StartLine);this.addInstruction(this.repetitionInstructions,t)}}else{if("stop"===o){const t=new n.RepetitionInstruction(this.currentMeasureIndex,n.RepetitionInstructionEnum.Ending,n.AlignmentType.End,void 0,l);this.addInstruction(this.repetitionInstructions,t)}if("backward"===r){const t=new n.RepetitionInstruction(this.currentMeasureIndex,n.RepetitionInstructionEnum.BackJumpLine);this.addInstruction(this.repetitionInstructions,t)}}}return e}handleRepetitionInstructionsFromWordsOrSymbols(t,e){const i=t.element("words"),s=this.currentMeasureIndex;if(i){const t="d\\s?\\.s\\.",e=i.value.trim().toLowerCase();if(r.StringUtil.StringContainsSeparatedWord(e,t+" al fine",!0)){const t=new n.RepetitionInstruction(s,n.RepetitionInstructionEnum.DalSegnoAlFine);return this.addInstruction(this.repetitionInstructions,t),!0}const o="d\\.\\s?c\\.";if(r.StringUtil.StringContainsSeparatedWord(e,o+" al coda",!0)){const t=new n.RepetitionInstruction(s,n.RepetitionInstructionEnum.DalSegnoAlCoda);return this.addInstruction(this.repetitionInstructions,t),!0}if(r.StringUtil.StringContainsSeparatedWord(e,o+" al fine",!0)){const t=new n.RepetitionInstruction(s,n.RepetitionInstructionEnum.DaCapoAlFine);return this.addInstruction(this.repetitionInstructions,t),!0}if(r.StringUtil.StringContainsSeparatedWord(e,o+" al coda",!0)){const t=new n.RepetitionInstruction(s,n.RepetitionInstructionEnum.DaCapoAlCoda);return this.addInstruction(this.repetitionInstructions,t),!0}if(r.StringUtil.StringContainsSeparatedWord(e,o)||r.StringUtil.StringContainsSeparatedWord(e,"da\\s?capo",!0)){const t=new n.RepetitionInstruction(s,n.RepetitionInstructionEnum.DaCapo);return this.addInstruction(this.repetitionInstructions,t),!0}if(r.StringUtil.StringContainsSeparatedWord(e,t,!0)||r.StringUtil.StringContainsSeparatedWord(e,"dal\\s?segno",!0)){let t;return t=r.StringUtil.StringContainsSeparatedWord(e,"al\\s?coda",!0)?new n.RepetitionInstruction(s,n.RepetitionInstructionEnum.DalSegnoAlCoda):new n.RepetitionInstruction(s,n.RepetitionInstructionEnum.DalSegno),this.addInstruction(this.repetitionInstructions,t),!0}if(r.StringUtil.StringContainsSeparatedWord(e,"to\\s?coda",!0)||r.StringUtil.StringContainsSeparatedWord(e,"a (la )?coda",!0)){const t=new n.RepetitionInstruction(s,n.RepetitionInstructionEnum.ToCoda);return this.addInstruction(this.repetitionInstructions,t),!0}if(r.StringUtil.StringContainsSeparatedWord(e,"fine",!0)){const t=new n.RepetitionInstruction(s,n.RepetitionInstructionEnum.Fine);return this.addInstruction(this.repetitionInstructions,t),!0}if(r.StringUtil.StringContainsSeparatedWord(e,"coda",!0)){const t=new n.RepetitionInstruction(s,n.RepetitionInstructionEnum.Coda);return this.addInstruction(this.repetitionInstructions,t),!0}if(r.StringUtil.StringContainsSeparatedWord(e,"segno",!0)){const t=new n.RepetitionInstruction(s,n.RepetitionInstructionEnum.Segno);return this.addInstruction(this.repetitionInstructions,t),!0}}else{if(t.element("segno")){const t=new n.RepetitionInstruction(s,n.RepetitionInstructionEnum.Segno);return this.addInstruction(this.repetitionInstructions,t),!0}if(t.element("coda")){const t=new n.RepetitionInstruction(s,n.RepetitionInstructionEnum.Coda);return this.addInstruction(this.repetitionInstructions,t),!0}}return!1}removeRedundantInstructions(){let t=0,e=0,i=0,r=0;for(let s=0;s0&&this.findInstructionInPreviousMeasure(s,o.measureIndex,n.RepetitionInstructionEnum.ToCoda)&&(o.type=n.RepetitionInstructionEnum.None),0===e&&0===i&&(o.type=n.RepetitionInstructionEnum.ToCoda,o.alignment=n.AlignmentType.End,o.measureIndex--);break;case n.RepetitionInstructionEnum.Segno:if(t-r>0){let t=!1;for(let s=0,r=this.repetitionInstructions.length;s0?n.RepetitionInstructionEnum.DalSegnoAlCoda:n.RepetitionInstructionEnum.DalSegno,o.type=n.RepetitionInstructionEnum.None,t=!0;break;case n.RepetitionInstructionEnum.DalSegno:case n.RepetitionInstructionEnum.DalSegnoAlFine:case n.RepetitionInstructionEnum.DalSegnoAlCoda:o.type=n.RepetitionInstructionEnum.None,t=!0}if(t)break}if(t)break;o.type=i-e>0?n.RepetitionInstructionEnum.DalSegnoAlCoda:n.RepetitionInstructionEnum.DalSegno,o.alignment=n.AlignmentType.End,o.measureIndex--}}if(this.backwardSearchForPreviousIdenticalInstruction(s,o)||o.type===n.RepetitionInstructionEnum.None)this.repetitionInstructions.splice(s,1),s--;else switch(o.type){case n.RepetitionInstructionEnum.Fine:break;case n.RepetitionInstructionEnum.ToCoda:i++;break;case n.RepetitionInstructionEnum.Coda:e++;break;case n.RepetitionInstructionEnum.Segno:t++;break;case n.RepetitionInstructionEnum.DalSegnoAlFine:case n.RepetitionInstructionEnum.DalSegnoAlCoda:r++}}this.repetitionInstructions.sort(s.RepetitionInstructionComparer.Compare)}findInstructionInPreviousMeasure(t,e,i){for(let n=t-1;n>=0;n--){const t=this.repetitionInstructions[n];if(e-t.measureIndex==1&&t.type===i)return!0}return!1}backwardSearchForPreviousIdenticalInstruction(t,e){for(let i=t-1;i>=0;i--)if(this.repetitionInstructions[i].equals(e))return!0;return!1}addInstruction(t,e){let i=!0;for(let n=0,s=t.length;n1&&e.FirstRepetitionInstructions.sort(s.RepetitionInstructionComparer.Compare),e.LastRepetitionInstructions.length>1&&e.LastRepetitionInstructions.sort(s.RepetitionInstructionComparer.Compare)}}handleRepetitionInstructions(t){if(!this.currentMeasure)return!1;switch(t.type){case n.RepetitionInstructionEnum.StartLine:this.currentMeasure.FirstRepetitionInstructions.push(t);break;case n.RepetitionInstructionEnum.BackJumpLine:this.currentMeasure.LastRepetitionInstructions.push(t);break;case n.RepetitionInstructionEnum.Ending:if(t.alignment===n.AlignmentType.Begin)this.currentMeasure.FirstRepetitionInstructions.push(t);else for(let e=0,i=t.endingIndices.length;ee.file("META-INF/container.xml").async("text")),(t=>{throw t})).then((t=>{const i=(new DOMParser).parseFromString(t,"text/xml").getElementsByTagName("rootfile")[0].getAttribute("full-path");return e.file(i).async("text")}),(t=>{throw t})).then((t=>{const e=(new DOMParser).parseFromString(t,"text/xml"),i=new s.IXmlElement(e.documentElement);return Promise.resolve(i)}),(t=>{throw t})).then((t=>t),(t=>{throw new Error("extractSheetFromMxl: "+t.message)}))}static MXLtoXMLstring(t){const e=new r.default;return e.loadAsync(t).then((t=>e.file("META-INF/container.xml").async("text")),(t=>{throw t})).then((t=>{const i=(new DOMParser).parseFromString(t,"text/xml").getElementsByTagName("rootfile")[0].getAttribute("full-path");return e.file(i).async("text")}),(t=>{throw t}))}}},function(t,e){var i,n,s=t.exports={};function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(i===setTimeout)return setTimeout(t,0);if((i===r||!i)&&setTimeout)return i=setTimeout,setTimeout(t,0);try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:r}catch(t){i=r}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(t){n=o}}();var l,h=[],c=!1,u=-1;function d(){c&&l&&(c=!1,l.length?h=l.concat(h):u=-1,h.length&&f())}function f(){if(!c){var t=a(d);c=!0;for(var e=h.length;e;){for(l=h,h=[];++u1)for(var i=1;ii.copies?this.nElements-=i.copies:this.nElements-=e,i.copies-=e,i.copies<=0&&this.dictionary.remove(t),!0}return!1},t.prototype.toArray=function(){for(var t=[],e=0,i=this.dictionary.values();e-1&&this.insertIdIntoRoot(e,i),this.nodes)if(this.nodes.hasOwnProperty(n)){var s=this.findNodeId(n,t);s>-1&&this.insertIdIntoNode(n,e,s)}},t.prototype.insertIdAfterId=function(t,e){var i=this.findRootId(t);for(var n in i>-1&&this.insertIdIntoRoot(e,i+1),this.nodes)if(this.nodes.hasOwnProperty(n)){var s=this.findNodeId(n,t);s>-1&&this.insertIdIntoNode(n,e,s+1)}},t.prototype.insertIdIntoId=function(t,e){this.nodeInsertAtEnd(t,e),this.nodes[e]=[]},t.prototype.insertIdIntoRoot=function(t,e){if(void 0===e)this.rootInsertAtEnd(t);else if(e<0){var i=this.rootIds.length;this.rootIds.splice(e+i+1,0,t)}else this.rootIds.splice(e,0,t);this.nodes[t]=this.nodes[t]||[]},t.prototype.insertIdIntoNode=function(t,e,i){if(this.nodes[t]=this.nodes[t]||[],this.nodes[e]=this.nodes[e]||[],void 0===i)this.nodeInsertAtEnd(t,e);else if(i<0){var n=this.nodes[t].length;this.nodes[t].splice(i+n+1,0,e)}else this.nodes[t].splice(i,0,e)},t.prototype.moveId=function(t,e,i){var s=t,r=this.findRootId(s);for(var o in this.nodes[e],this.nodes)if(this.nodes.hasOwnProperty(o)){this.findNodeId(o,e);break}var a=e,l=this.findRootId(a);for(var o in this.nodes[e],this.nodes)if(this.nodes.hasOwnProperty(o)){this.findNodeId(o,e);break}if(r>-1){if(l>-1)switch(this.rootDelete(r),l>r&&l--,i){case n.BEFORE:this.insertIdIntoRoot(s,l);break;case n.AFTER:this.insertIdIntoRoot(s,l+1);break;case n.INSIDE_AT_START:this.nodeInsertAtStart(a,s);break;case n.INSIDE_AT_END:this.nodeInsertAtEnd(a,s)}else for(var o in this.rootDelete(r),this.nodes)if(this.nodes.hasOwnProperty(o)&&(h=this.findNodeId(o,a))>-1){switch(i){case n.BEFORE:this.insertIdIntoNode(o,s,h);break;case n.AFTER:this.insertIdIntoNode(o,s,h+1);break;case n.INSIDE_AT_START:this.nodeInsertAtStart(a,s);break;case n.INSIDE_AT_END:this.nodeInsertAtEnd(a,s)}break}}else if(l>-1){for(var o in this.nodes)if(this.nodes.hasOwnProperty(o)&&(h=this.findNodeId(o,s))>-1){this.nodeDeleteAtIndex(o,h);break}switch(i){case n.BEFORE:this.insertIdIntoRoot(s,l);break;case n.AFTER:this.insertIdIntoRoot(s,l+1);break;case n.INSIDE_AT_START:this.nodeInsertAtStart(a,s);break;case n.INSIDE_AT_END:this.nodeInsertAtEnd(a,s)}}else{for(var o in this.nodes)if(this.nodes.hasOwnProperty(o)&&(h=this.findNodeId(o,s))>-1){this.nodeDeleteAtIndex(o,h);break}for(var o in this.nodes){var h;if(this.nodes.hasOwnProperty(o)&&(h=this.findNodeId(o,a))>-1){switch(i){case n.BEFORE:this.insertIdIntoNode(o,s,h);break;case n.AFTER:this.insertIdIntoNode(o,s,h+1);break;case n.INSIDE_AT_START:this.nodeInsertAtStart(a,s);break;case n.INSIDE_AT_END:this.nodeInsertAtEnd(a,s)}break}}}},t.prototype.swapArrayElements=function(t,e,i){var n=t[e];return t[e]=t[i],t[i]=n,t},t.prototype.rootDeleteId=function(t){var e=this.findRootId(t);e>-1&&this.rootDelete(e)},t.prototype.nodeAndSubNodesDelete=function(t){for(var e=[],i=0;i=0;i--)if(e=this.timestamps[i],t.gte(e.$from))return e;return this.timestamps[0]}absoluteEnrolledToSheetTimestamp(t){if(0===this.timestamps.length)return t;const e=this.getCurrentRepetitionTimestampTransform(t);return n.Fraction.plus(t,n.Fraction.minus(e.to,e.$from))}get Parts(){return this.parts}get MusicSheet(){return this.musicSheet}getIterator(t){return t?new s.MusicPartManagerIterator(this.musicSheet,t,void 0):new s.MusicPartManagerIterator(this.musicSheet,this.musicSheet.SelectionStart,this.musicSheet.SelectionEnd)}setSelectionStart(t){this.musicSheet.SelectionStart=t,this.musicSheet.SelectionEnd=void 0}setSelectionRange(t,e){this.musicSheet.SelectionStart=null!=t?t:this.sheetStart,this.musicSheet.SelectionEnd=null!=e?e:this.sheetEnd}calcMapping(){const t=[],e=this.getIterator();let i=e.CurrentRepetition,n=new r(e.CurrentEnrolledTimestamp.clone(),e.CurrentSourceTimestamp.clone(),void 0,0);for(t.push(n);!e.EndReached;){if(e.JumpOccurred||i!==e.CurrentRepetition){if(i=e.CurrentRepetition,e.backJumpOccurred){const i=e.JumpResponsibleRepetition;n.nextBackJump=e.CurrentEnrolledTimestamp,n.curRepetition=i,n.curRepetitionIteration=e.CurrentJumpResponsibleRepetitionIterationBeforeJump;for(let e=this.timestamps.length-2;e>=0&&!t[e].to.lt(i.AbsoluteTimestamp)&&!t[e].curRepetition;e--)t[e].nextBackJump=n.nextBackJump,t[e].curRepetition=i,t[e].curRepetitionIteration=n.curRepetitionIteration}n=new r(e.CurrentEnrolledTimestamp.clone(),e.CurrentSourceTimestamp.clone(),void 0,0),t.push(n)}e.moveToNext()}this.timestamps=t}};class r{constructor(t,e,i,n){this.$from=t,this.to=e,this.curRepetition=i,this.curRepetitionIteration=n,this.nextBackJump=void 0,this.nextForwardJump=void 0}}e.TimestampTransform=r},function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.MusicPartManagerIterator=void 0;const s=i(0),r=i(168),o=i(19),a=i(32),l=n(i(1));class h{constructor(t,e,i){this.currentMeasureIndex=0,this.currentPartIndex=0,this.currentVoiceEntryIndex=-1,this.currentDynamicEntryIndex=0,this.currentTempoEntryIndex=0,this.currentDynamicChangingExpressions=[],this.currentRepetition=void 0,this.endReached=!1,this.frontReached=!1,this.currentTimeStamp=new s.Fraction(0,1),this.currentEnrolledMeasureTimestamp=new s.Fraction(0,1),this.currentRelativeInMeasureTimestamp=new s.Fraction(0,1),this.currentVerticalContainerInMeasureTimestamp=new s.Fraction(0,1),this.jumpResponsibleRepetition=void 0,this.activeDynamicExpressions=[];try{this.frontReached=!0,this.musicSheet=t,this.currentVoiceEntries=void 0,this.frontReached=!1;for(const t of this.musicSheet.Repetitions)this.setRepetitionIterationCount(t,1);if(this.activeDynamicExpressions=new Array(this.musicSheet.getCompleteNumberOfStaves()),this.currentMeasure=this.musicSheet.SourceMeasures[0],!e)return;do{this.moveToNext()}while((!this.currentVoiceEntries||this.currentTimeStamp.lt(e))&&!this.endReached);for(let t=0;t=this.JumpResponsibleRepetition.StartIndex&&i.EndIndex<=this.JumpResponsibleRepetition.EndIndex&&this.resetRepetitionIterationCount(i)}}handleRepetitionsAtMeasureEnd(){for(let t=0,e=this.currentMeasure.LastRepetitionInstructions.length;t-1&&this.getRepetitionIterationCount(i)=this.JumpResponsibleRepetition.StartIndex&&i.EndIndex<=this.JumpResponsibleRepetition.EndIndex&&this.resetRepetitionIterationCount(i);const t=i.getForwardJumpTargetForIteration(this.getRepetitionIterationCount(i));if(t>=0)return this.currentMeasureIndex=t,this.currentMeasure=this.musicSheet.SourceMeasures[this.currentMeasureIndex],this.currentVoiceEntryIndex=-1,this.jumpResponsibleRepetition=i,void(this.forwardJumpOccurred=!0);-2===t&&(this.endReached=!0)}}}this.currentMeasureIndex++,void 0!==this.JumpResponsibleRepetition&&this.currentMeasureIndex>this.JumpResponsibleRepetition.EndIndex&&(this.jumpResponsibleRepetition=void 0)}doBackJump(t){this.currentMeasureIndex=t.getBackwardJumpTarget(),this.currentMeasure=this.musicSheet.SourceMeasures[this.currentMeasureIndex],this.currentVoiceEntryIndex=-1,this.incrementRepetitionIterationCount(t),this.jumpResponsibleRepetition=t}activateCurrentRhythmInstructions(){if(void 0!==this.currentMeasure&&this.currentMeasure.FirstInstructionsStaffEntries.length>0&&void 0!==this.currentMeasure.FirstInstructionsStaffEntries[0]){const t=this.currentMeasure.FirstInstructionsStaffEntries[0].Instructions;for(let e=0,i=t.length;e0&&(this.currentDynamicEntryIndex>=t.length||this.CurrentSourceTimestamp.lte(t[this.currentDynamicEntryIndex].parMultiExpression().AbsoluteTimestamp));)this.currentDynamicEntryIndex--;for(;this.currentDynamicEntryIndex0&&(this.currentTempoEntryIndex>=e.length||this.CurrentSourceTimestamp.lte(e[this.currentTempoEntryIndex].AbsoluteTimestamp));)this.currentTempoEntryIndex--;for(;this.currentTempoEntryIndex=0&&this.currentVoiceEntryIndex=0&&this.currentMeasureIndex0){if(!t)return!0;for(let t=0,i=e.length;t=0&&(this.syllableIndex=s)}get Text(){return this.text}set Text(t){this.text=t}get Word(){return this.word}get Parent(){return this.parent}set Parent(t){this.parent=t}get VerseNumber(){return this.verseNumber}get SyllableIndex(){return this.syllableIndex}}},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.Articulation=void 0,e.Articulation=class{constructor(t,e){this.articulationEnum=t,this.placement=e}Equals(t){return t.articulationEnum===this.articulationEnum&&t.placement===this.placement}}},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.TabNote=void 0;const n=i(36);class s extends n.Note{constructor(t,e,i,n,s,r,o,a,l){super(t,e,i,n,s),this.stringNumberTab=r,this.fretNumber=o,this.bendArray=a,this.vibratoStroke=l}get StringNumberTab(){return this.stringNumberTab}get FretNumber(){return this.fretNumber}get BendArray(){return this.bendArray}get VibratoStroke(){return this.vibratoStroke}}e.TabNote=s},function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.Slur=void 0;const n=i(0);e.Slur=class{constructor(){}get StartNote(){return this.startNote}set StartNote(t){this.startNote=t}get EndNote(){return this.endNote}set EndNote(t){this.endNote=t}startNoteHasMoreStartingSlurs(){if(!this.startNote)return!1;for(let t=0,e=this.startNote.NoteSlurs.length;t>2,a=(3&e)<<4|i>>4,l=1>6:64,h=2>4,i=(15&o)<<4|(a=r.indexOf(t.charAt(h++)))>>2,n=(3&a)<<6|(l=r.indexOf(t.charAt(h++))),d[c++]=e,64!==a&&(d[c++]=i),64!==l&&(d[c++]=n);return d}},{"./support":30,"./utils":32}],2:[function(t,e,i){var n=t("./external"),s=t("./stream/DataWorker"),r=t("./stream/DataLengthProbe"),o=t("./stream/Crc32Probe");function a(t,e,i,n,s){this.compressedSize=t,this.uncompressedSize=e,this.crc32=i,this.compression=n,this.compressedContent=s}r=t("./stream/DataLengthProbe"),a.prototype={getContentWorker:function(){var t=new s(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new r("data_length")),e=this;return t.on("end",(function(){if(this.streamInfo.data_length!==e.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),t},getCompressedWorker:function(){return new s(n.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},a.createWorkerFrom=function(t,e,i){return t.pipe(new o).pipe(new r("uncompressedSize")).pipe(e.compressWorker(i)).pipe(new r("compressedSize")).withStreamInfo("compression",e)},e.exports=a},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,e,i){var n=t("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(t){return new n("STORE compression")},uncompressWorker:function(){return new n("STORE decompression")}},i.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,e,i){var n=t("./utils"),s=function(){for(var t,e=[],i=0;i<256;i++){t=i;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e}();e.exports=function(t,e){return void 0!==t&&t.length?"string"!==n.getTypeOf(t)?function(t,e,i,n){var r=s,o=0+i;t^=-1;for(var a=0;a>>8^r[255&(t^e[a])];return-1^t}(0|e,t,t.length):function(t,e,i,n){var r=s,o=0+i;t^=-1;for(var a=0;a>>8^r[255&(t^e.charCodeAt(a))];return-1^t}(0|e,t,t.length):0}},{"./utils":32}],5:[function(t,e,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(t,e,i){var n;n="undefined"!=typeof Promise?Promise:t("lie"),e.exports={Promise:n}},{lie:37}],7:[function(t,e,i){var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,s=t("pako"),r=t("./utils"),o=t("./stream/GenericWorker"),a=n?"uint8array":"array";function l(t,e){o.call(this,"FlateWorker/"+t),this._pako=null,this._pakoAction=t,this._pakoOptions=e,this.meta={}}i.magic="\b\0",r.inherits(l,o),l.prototype.processChunk=function(t){this.meta=t.meta,null===this._pako&&this._createPako(),this._pako.push(r.transformTo(a,t.data),!1)},l.prototype.flush=function(){o.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},l.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this._pako=null},l.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var t=this;this._pako.onData=function(e){t.push({data:e,meta:t.meta})}},i.compressWorker=function(t){return new l("Deflate",t)},i.uncompressWorker=function(){return new l("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,e,i){function n(t,e){var i,n="";for(i=0;i>>=8;return n}function s(t,e,i,s,o,c){var u,d,f=t.file,p=t.compression,m=c!==a.utf8encode,b=r.transformTo("string",c(f.name)),g=r.transformTo("string",a.utf8encode(f.name)),y=f.comment,S=r.transformTo("string",c(y)),v=r.transformTo("string",a.utf8encode(y)),x=g.length!==f.name.length,E=v.length!==y.length,_="",w="",T="",M=f.dir,P=f.date,L={crc32:0,compressedSize:0,uncompressedSize:0};e&&!i||(L.crc32=t.crc32,L.compressedSize=t.compressedSize,L.uncompressedSize=t.uncompressedSize);var A=0;e&&(A|=8),m||!x&&!E||(A|=2048);var C,I,R,N=0,F=0;M&&(N|=16),"UNIX"===o?(F=798,N|=(C=f.unixPermissions,I=M,R=C,C||(R=I?16893:33204),(65535&R)<<16)):(F=20,N|=function(t){return 63&(t||0)}(f.dosPermissions)),u=P.getUTCHours(),u<<=6,u|=P.getUTCMinutes(),u<<=5,u|=P.getUTCSeconds()/2,d=P.getUTCFullYear()-1980,d<<=4,d|=P.getUTCMonth()+1,d<<=5,d|=P.getUTCDate(),x&&(w=n(1,1)+n(l(b),4)+g,_+="up"+n(w.length,2)+w),E&&(T=n(1,1)+n(l(S),4)+v,_+="uc"+n(T.length,2)+T);var B="";return B+="\n\0",B+=n(A,2),B+=p.magic,B+=n(u,2),B+=n(d,2),B+=n(L.crc32,4),B+=n(L.compressedSize,4),B+=n(L.uncompressedSize,4),B+=n(b.length,2),B+=n(_.length,2),{fileRecord:h.LOCAL_FILE_HEADER+B+b+_,dirRecord:h.CENTRAL_FILE_HEADER+n(F,2)+B+n(S.length,2)+"\0\0\0\0"+n(N,4)+n(s,4)+b+_+S}}var r=t("../utils"),o=t("../stream/GenericWorker"),a=t("../utf8"),l=t("../crc32"),h=t("../signature");function c(t,e,i,n){o.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=e,this.zipPlatform=i,this.encodeFileName=n,this.streamFiles=t,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}r.inherits(c,o),c.prototype.push=function(t){var e=t.meta.percent||0,i=this.entriesCount,n=this._sources.length;this.accumulate?this.contentBuffer.push(t):(this.bytesWritten+=t.data.length,o.prototype.push.call(this,{data:t.data,meta:{currentFile:this.currentFile,percent:i?(e+100*(i-n-1))/i:100}}))},c.prototype.openedSource=function(t){this.currentSourceOffset=this.bytesWritten,this.currentFile=t.file.name;var e=this.streamFiles&&!t.file.dir;if(e){var i=s(t,e,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:i.fileRecord,meta:{percent:0}})}else this.accumulate=!0},c.prototype.closedSource=function(t){this.accumulate=!1;var e,i=this.streamFiles&&!t.file.dir,r=s(t,i,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(r.dirRecord),i)this.push({data:(e=t,h.DATA_DESCRIPTOR+n(e.crc32,4)+n(e.compressedSize,4)+n(e.uncompressedSize,4)),meta:{percent:100}});else for(this.push({data:r.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},c.prototype.flush=function(){for(var t=this.bytesWritten,e=0;e=this.index;e--)i=(i<<8)+this.byteAt(e);return this.index+=t,i},readString:function(t){return n.transformTo("string",this.readData(t))},readData:function(t){},lastIndexOfSignature:function(t){},readAndCheckSignature:function(t){},readDate:function(){var t=this.readInt(4);return new Date(Date.UTC(1980+(t>>25&127),(t>>21&15)-1,t>>16&31,t>>11&31,t>>5&63,(31&t)<<1))}},e.exports=s},{"../utils":32}],19:[function(t,e,i){var n=t("./Uint8ArrayReader");function s(t){n.call(this,t)}t("../utils").inherits(s,n),s.prototype.readData=function(t){this.checkOffset(t);var e=this.data.slice(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,e,i){var n=t("./DataReader");function s(t){n.call(this,t)}t("../utils").inherits(s,n),s.prototype.byteAt=function(t){return this.data.charCodeAt(this.zero+t)},s.prototype.lastIndexOfSignature=function(t){return this.data.lastIndexOf(t)-this.zero},s.prototype.readAndCheckSignature=function(t){return t===this.readData(4)},s.prototype.readData=function(t){this.checkOffset(t);var e=this.data.slice(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=s},{"../utils":32,"./DataReader":18}],21:[function(t,e,i){var n=t("./ArrayReader");function s(t){n.call(this,t)}t("../utils").inherits(s,n),s.prototype.readData=function(t){if(this.checkOffset(t),0===t)return new Uint8Array(0);var e=this.data.subarray(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(t,e,i){var n=t("../utils"),s=t("../support"),r=t("./ArrayReader"),o=t("./StringReader"),a=t("./NodeBufferReader"),l=t("./Uint8ArrayReader");e.exports=function(t){var e=n.getTypeOf(t);return n.checkSupport(e),"string"!==e||s.uint8array?"nodebuffer"===e?new a(t):s.uint8array?new l(n.transformTo("uint8array",t)):new r(n.transformTo("array",t)):new o(t)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,e,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\b"},{}],24:[function(t,e,i){var n=t("./GenericWorker"),s=t("../utils");function r(t){n.call(this,"ConvertWorker to "+t),this.destType=t}s.inherits(r,n),r.prototype.processChunk=function(t){this.push({data:s.transformTo(this.destType,t.data),meta:t.meta})},e.exports=r},{"../utils":32,"./GenericWorker":28}],25:[function(t,e,i){var n=t("./GenericWorker"),s=t("../crc32");function r(){n.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(r,n),r.prototype.processChunk=function(t){this.streamInfo.crc32=s(t.data,this.streamInfo.crc32||0),this.push(t)},e.exports=r},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,e,i){var n=t("../utils"),s=t("./GenericWorker");function r(t){s.call(this,"DataLengthProbe for "+t),this.propName=t,this.withStreamInfo(t,0)}n.inherits(r,s),r.prototype.processChunk=function(t){if(t){var e=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=e+t.data.length}s.prototype.processChunk.call(this,t)},e.exports=r},{"../utils":32,"./GenericWorker":28}],27:[function(t,e,i){var n=t("../utils"),s=t("./GenericWorker");function r(t){s.call(this,"DataWorker");var e=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,t.then((function(t){e.dataIsReady=!0,e.data=t,e.max=t&&t.length||0,e.type=n.getTypeOf(t),e.isPaused||e._tickAndRepeat()}),(function(t){e.error(t)}))}n.inherits(r,s),r.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},r.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,n.delay(this._tickAndRepeat,[],this)),!0)},r.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(n.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},r.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var t=null,e=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":t=this.data.substring(this.index,e);break;case"uint8array":t=this.data.subarray(this.index,e);break;case"array":case"nodebuffer":t=this.data.slice(this.index,e)}return this.index=e,this.push({data:t,meta:{percent:this.max?this.index/this.max*100:0}})},e.exports=r},{"../utils":32,"./GenericWorker":28}],28:[function(t,e,i){function n(t){this.name=t||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}n.prototype={push:function(t){this.emit("data",t)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(t){this.emit("error",t)}return!0},error:function(t){return!this.isFinished&&(this.isPaused?this.generatedError=t:(this.isFinished=!0,this.emit("error",t),this.previous&&this.previous.error(t),this.cleanUp()),!0)},on:function(t,e){return this._listeners[t].push(e),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(t,e){if(this._listeners[t])for(var i=0;i "+t:t}},e.exports=n},{}],29:[function(t,i,n){var s=t("../utils"),r=t("./ConvertWorker"),o=t("./GenericWorker"),a=t("../base64"),l=t("../support"),h=t("../external"),c=null;if(l.nodestream)try{c=t("../nodejs/NodejsStreamOutputAdapter")}catch(t){}function u(t,e,i){var n=e;switch(e){case"blob":case"arraybuffer":n="uint8array";break;case"base64":n="string"}try{this._internalType=n,this._outputType=e,this._mimeType=i,s.checkSupport(n),this._worker=t.pipe(new r(n)),t.lock()}catch(t){this._worker=new o("error"),this._worker.error(t)}}u.prototype={accumulate:function(t){return i=this,n=t,new h.Promise((function(t,r){var o=[],l=i._internalType,h=i._outputType,c=i._mimeType;i.on("data",(function(t,e){o.push(t),n&&n(e)})).on("error",(function(t){o=[],r(t)})).on("end",(function(){try{var i=function(t,e,i){switch(t){case"blob":return s.newBlob(s.transformTo("arraybuffer",e),i);case"base64":return a.encode(e);default:return s.transformTo(t,e)}}(h,function(t,i){var n,s=0,r=null,o=0;for(n=0;n>>6:(i<65536?e[o++]=224|i>>>12:(e[o++]=240|i>>>18,e[o++]=128|i>>>12&63),e[o++]=128|i>>>6&63),e[o++]=128|63&i);return e}(t)},i.utf8decode=function(t){return s.nodebuffer?n.transformTo("nodebuffer",t).toString("utf-8"):function(t){var e,i,s,r,o=t.length,l=new Array(2*o);for(e=i=0;e>10&1023,l[i++]=56320|1023&s)}return l.length!==i&&(l.subarray?l=l.subarray(0,i):l.length=i),n.applyFromCharCode(l)}(t=n.transformTo(s.uint8array?"uint8array":"array",t))},n.inherits(h,o),h.prototype.processChunk=function(t){var e=n.transformTo(s.uint8array?"uint8array":"array",t.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var r=e;(e=new Uint8Array(r.length+this.leftOver.length)).set(this.leftOver,0),e.set(r,this.leftOver.length)}else e=this.leftOver.concat(e);this.leftOver=null}var o=function(t,e){var i;for((e=e||t.length)>t.length&&(e=t.length),i=e-1;0<=i&&128==(192&t[i]);)i--;return i<0||0===i?e:i+a[t[i]]>e?i:e}(e),l=e;o!==e.length&&(s.uint8array?(l=e.subarray(0,o),this.leftOver=e.subarray(o,e.length)):(l=e.slice(0,o),this.leftOver=e.slice(o,e.length))),this.push({data:i.utf8decode(l),meta:t.meta})},h.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=h,n.inherits(c,o),c.prototype.processChunk=function(t){this.push({data:i.utf8encode(t.data),meta:t.meta})},i.Utf8EncodeWorker=c},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,e,i){var n=t("./support"),s=t("./base64"),r=t("./nodejsUtils"),o=t("set-immediate-shim"),a=t("./external");function l(t){return t}function h(t,e){for(var i=0;i>8;this.dir=!!(16&this.externalFileAttributes),0==t&&(this.dosPermissions=63&this.externalFileAttributes),3==t&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(t){if(this.extraFields[1]){var e=n(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(t){var e,i,n,s=t.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});t.index>>6:(i<65536?e[o++]=224|i>>>12:(e[o++]=240|i>>>18,e[o++]=128|i>>>12&63),e[o++]=128|i>>>6&63),e[o++]=128|63&i);return e},i.buf2binstring=function(t){return l(t,t.length)},i.binstring2buf=function(t){for(var e=new n.Buf8(t.length),i=0,s=e.length;i>10&1023,h[n++]=56320|1023&s)}return l(h,n)},i.utf8border=function(t,e){var i;for((e=e||t.length)>t.length&&(e=t.length),i=e-1;0<=i&&128==(192&t[i]);)i--;return i<0||0===i?e:i+o[t[i]]>e?i:e}},{"./common":41}],43:[function(t,e,i){e.exports=function(t,e,i,n){for(var s=65535&t|0,r=t>>>16&65535|0,o=0;0!==i;){for(i-=o=2e3>>1:t>>>1;e[i]=t}return e}();e.exports=function(t,e,i,s){var r=n,o=s+i;t^=-1;for(var a=s;a>>8^r[255&(t^e[a])];return-1^t}},{}],46:[function(t,e,i){var n,s=t("../utils/common"),r=t("./trees"),o=t("./adler32"),a=t("./crc32"),l=t("./messages"),h=-2,c=258,u=262,d=113;function f(t,e){return t.msg=l[e],e}function p(t){return(t<<1)-(4t.avail_out&&(i=t.avail_out),0!==i&&(s.arraySet(t.output,e.pending_buf,e.pending_out,i,t.next_out),t.next_out+=i,e.pending_out+=i,t.total_out+=i,t.avail_out-=i,e.pending-=i,0===e.pending&&(e.pending_out=0))}function g(t,e){r._tr_flush_block(t,0<=t.block_start?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,b(t.strm)}function y(t,e){t.pending_buf[t.pending++]=e}function S(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function v(t,e){var i,n,s=t.max_chain_length,r=t.strstart,o=t.prev_length,a=t.nice_match,l=t.strstart>t.w_size-u?t.strstart-(t.w_size-u):0,h=t.window,d=t.w_mask,f=t.prev,p=t.strstart+c,m=h[r+o-1],b=h[r+o];t.prev_length>=t.good_match&&(s>>=2),a>t.lookahead&&(a=t.lookahead);do{if(h[(i=e)+o]===b&&h[i+o-1]===m&&h[i]===h[r]&&h[++i]===h[r+1]){r+=2,i++;do{}while(h[++r]===h[++i]&&h[++r]===h[++i]&&h[++r]===h[++i]&&h[++r]===h[++i]&&h[++r]===h[++i]&&h[++r]===h[++i]&&h[++r]===h[++i]&&h[++r]===h[++i]&&rl&&0!=--s);return o<=t.lookahead?o:t.lookahead}function x(t){var e,i,n,r,l,h,c,d,f,p,m=t.w_size;do{if(r=t.window_size-t.lookahead-t.strstart,t.strstart>=m+(m-u)){for(s.arraySet(t.window,t.window,m,m,0),t.match_start-=m,t.strstart-=m,t.block_start-=m,e=i=t.hash_size;n=t.head[--e],t.head[e]=m<=n?n-m:0,--i;);for(e=i=m;n=t.prev[--e],t.prev[e]=m<=n?n-m:0,--i;);r+=m}if(0===t.strm.avail_in)break;if(h=t.strm,c=t.window,d=t.strstart+t.lookahead,p=void 0,(f=r)<(p=h.avail_in)&&(p=f),i=0===p?0:(h.avail_in-=p,s.arraySet(c,h.input,h.next_in,p,d),1===h.state.wrap?h.adler=o(h.adler,c,p,d):2===h.state.wrap&&(h.adler=a(h.adler,c,p,d)),h.next_in+=p,h.total_in+=p,p),t.lookahead+=i,t.lookahead+t.insert>=3)for(l=t.strstart-t.insert,t.ins_h=t.window[l],t.ins_h=(t.ins_h<=3&&(t.ins_h=(t.ins_h<=3)if(n=r._tr_tally(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){for(t.match_length--;t.strstart++,t.ins_h=(t.ins_h<=3&&(t.ins_h=(t.ins_h<=3&&t.match_length<=t.prev_length){for(s=t.strstart+t.lookahead-3,n=r._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;++t.strstart<=s&&(t.ins_h=(t.ins_h<t.pending_buf_size-5&&(i=t.pending_buf_size-5);;){if(t.lookahead<=1){if(x(t),0===t.lookahead&&0===e)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var n=t.block_start+i;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,g(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-u&&(g(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(g(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(g(t,!1),t.strm.avail_out),1)})),new w(4,4,8,4,E),new w(4,5,16,8,E),new w(4,6,32,32,E),new w(4,4,16,16,_),new w(8,16,32,32,_),new w(8,16,128,128,_),new w(8,32,128,256,_),new w(32,128,258,1024,_),new w(32,258,258,4096,_)],i.deflateInit=function(t,e){return L(t,e,8,15,8,0)},i.deflateInit2=L,i.deflateReset=P,i.deflateResetKeep=M,i.deflateSetHeader=function(t,e){return t&&t.state?2!==t.state.wrap?h:(t.state.gzhead=e,0):h},i.deflate=function(t,e){var i,s,o,l;if(!t||!t.state||5>8&255),y(s,s.gzhead.time>>16&255),y(s,s.gzhead.time>>24&255),y(s,9===s.level?2:2<=s.strategy||s.level<2?4:0),y(s,255&s.gzhead.os),s.gzhead.extra&&s.gzhead.extra.length&&(y(s,255&s.gzhead.extra.length),y(s,s.gzhead.extra.length>>8&255)),s.gzhead.hcrc&&(t.adler=a(t.adler,s.pending_buf,s.pending,0)),s.gzindex=0,s.status=69):(y(s,0),y(s,0),y(s,0),y(s,0),y(s,0),y(s,9===s.level?2:2<=s.strategy||s.level<2?4:0),y(s,3),s.status=d);else{var u=8+(s.w_bits-8<<4)<<8;u|=(2<=s.strategy||s.level<2?0:s.level<6?1:6===s.level?2:3)<<6,0!==s.strstart&&(u|=32),u+=31-u%31,s.status=d,S(s,u),0!==s.strstart&&(S(s,t.adler>>>16),S(s,65535&t.adler)),t.adler=1}if(69===s.status)if(s.gzhead.extra){for(o=s.pending;s.gzindex<(65535&s.gzhead.extra.length)&&(s.pending!==s.pending_buf_size||(s.gzhead.hcrc&&s.pending>o&&(t.adler=a(t.adler,s.pending_buf,s.pending-o,o)),b(t),o=s.pending,s.pending!==s.pending_buf_size));)y(s,255&s.gzhead.extra[s.gzindex]),s.gzindex++;s.gzhead.hcrc&&s.pending>o&&(t.adler=a(t.adler,s.pending_buf,s.pending-o,o)),s.gzindex===s.gzhead.extra.length&&(s.gzindex=0,s.status=73)}else s.status=73;if(73===s.status)if(s.gzhead.name){o=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>o&&(t.adler=a(t.adler,s.pending_buf,s.pending-o,o)),b(t),o=s.pending,s.pending===s.pending_buf_size)){l=1;break}l=s.gzindexo&&(t.adler=a(t.adler,s.pending_buf,s.pending-o,o)),0===l&&(s.gzindex=0,s.status=91)}else s.status=91;if(91===s.status)if(s.gzhead.comment){o=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>o&&(t.adler=a(t.adler,s.pending_buf,s.pending-o,o)),b(t),o=s.pending,s.pending===s.pending_buf_size)){l=1;break}l=s.gzindexo&&(t.adler=a(t.adler,s.pending_buf,s.pending-o,o)),0===l&&(s.status=103)}else s.status=103;if(103===s.status&&(s.gzhead.hcrc?(s.pending+2>s.pending_buf_size&&b(t),s.pending+2<=s.pending_buf_size&&(y(s,255&t.adler),y(s,t.adler>>8&255),t.adler=0,s.status=d)):s.status=d),0!==s.pending){if(b(t),0===t.avail_out)return s.last_flush=-1,0}else if(0===t.avail_in&&p(e)<=p(i)&&4!==e)return f(t,-5);if(666===s.status&&0!==t.avail_in)return f(t,-5);if(0!==t.avail_in||0!==s.lookahead||0!==e&&666!==s.status){var v=2===s.strategy?function(t,e){for(var i;;){if(0===t.lookahead&&(x(t),0===t.lookahead)){if(0===e)return 1;break}if(t.match_length=0,i=r._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,i&&(g(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(g(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(g(t,!1),0===t.strm.avail_out)?1:2}(s,e):3===s.strategy?function(t,e){for(var i,n,s,o,a=t.window;;){if(t.lookahead<=c){if(x(t),t.lookahead<=c&&0===e)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&0t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(i=r._tr_tally(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(i=r._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),i&&(g(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(g(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(g(t,!1),0===t.strm.avail_out)?1:2}(s,e):n[s.level].func(s,e);if(3!==v&&4!==v||(s.status=666),1===v||3===v)return 0===t.avail_out&&(s.last_flush=-1),0;if(2===v&&(1===e?r._tr_align(s):5!==e&&(r._tr_stored_block(s,0,0,!1),3===e&&(m(s.head),0===s.lookahead&&(s.strstart=0,s.block_start=0,s.insert=0))),b(t),0===t.avail_out))return s.last_flush=-1,0}return 4!==e?0:s.wrap<=0?1:(2===s.wrap?(y(s,255&t.adler),y(s,t.adler>>8&255),y(s,t.adler>>16&255),y(s,t.adler>>24&255),y(s,255&t.total_in),y(s,t.total_in>>8&255),y(s,t.total_in>>16&255),y(s,t.total_in>>24&255)):(S(s,t.adler>>>16),S(s,65535&t.adler)),b(t),0=i.w_size&&(0===a&&(m(i.head),i.strstart=0,i.block_start=0,i.insert=0),d=new s.Buf8(i.w_size),s.arraySet(d,e,f-i.w_size,i.w_size,0),e=d,f=i.w_size),l=t.avail_in,c=t.next_in,u=t.input,t.avail_in=f,t.next_in=0,t.input=e,x(i);i.lookahead>=3;){for(n=i.strstart,r=i.lookahead-2;i.ins_h=(i.ins_h<>>=v=S>>>24,p-=v,0==(v=S>>>16&255))M[r++]=65535&S;else{if(!(16&v)){if(0==(64&v)){S=m[(65535&S)+(f&(1<>>=v,p-=v),p<15&&(f+=T[n++]<>>=v=S>>>24,p-=v,!(16&(v=S>>>16&255))){if(0==(64&v)){S=b[(65535&S)+(f&(1<>>=v,p-=v,(v=r-o)>3,f&=(1<<(p-=x<<3))-1,t.next_in=n,t.next_out=r,t.avail_in=n>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function c(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function u(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new n.Buf32(852),e.distcode=e.distdyn=new n.Buf32(592),e.sane=1,e.back=-1,0):l}function d(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,u(t)):l}function f(t,e){var i,n;return t&&t.state?(n=t.state,e<0?(i=0,e=-e):(i=1+(e>>4),e<48&&(e&=15)),e&&(e<8||15=o.wsize?(n.arraySet(o.window,e,i-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(s<(r=o.wsize-o.wnext)&&(r=s),n.arraySet(o.window,e,i-s,r,o.wnext),(s-=r)?(n.arraySet(o.window,e,i-s,s,0),o.wnext=s,o.whave=o.wsize):(o.wnext+=r,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,i.check=r(i.check,O,2,0),g=b=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&b)<<8)+(b>>8))%31){t.msg="incorrect header check",i.mode=30;break}if(8!=(15&b)){t.msg="unknown compression method",i.mode=30;break}if(g-=4,I=8+(15&(b>>>=4)),0===i.wbits)i.wbits=I;else if(I>i.wbits){t.msg="invalid window size",i.mode=30;break}i.dmax=1<>8&1),512&i.flags&&(O[0]=255&b,O[1]=b>>>8&255,i.check=r(i.check,O,2,0)),g=b=0,i.mode=3;case 3:for(;g<32;){if(0===p)break t;p--,b+=c[d++]<>>8&255,O[2]=b>>>16&255,O[3]=b>>>24&255,i.check=r(i.check,O,4,0)),g=b=0,i.mode=4;case 4:for(;g<16;){if(0===p)break t;p--,b+=c[d++]<>8),512&i.flags&&(O[0]=255&b,O[1]=b>>>8&255,i.check=r(i.check,O,2,0)),g=b=0,i.mode=5;case 5:if(1024&i.flags){for(;g<16;){if(0===p)break t;p--,b+=c[d++]<>>8&255,i.check=r(i.check,O,2,0)),g=b=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(p<(E=i.length)&&(E=p),E&&(i.head&&(I=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),n.arraySet(i.head.extra,c,d,E,I)),512&i.flags&&(i.check=r(i.check,c,E,d)),p-=E,d+=E,i.length-=E),i.length))break t;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===p)break t;for(E=0;I=c[d+E++],i.head&&I&&i.length<65536&&(i.head.name+=String.fromCharCode(I)),I&&E>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=12;break;case 10:for(;g<32;){if(0===p)break t;p--,b+=c[d++]<>>=7&g,g-=7&g,i.mode=27;break}for(;g<3;){if(0===p)break t;p--,b+=c[d++]<>>=1)){case 0:i.mode=14;break;case 1:if(y(i),i.mode=20,6!==e)break;b>>>=2,g-=2;break t;case 2:i.mode=17;break;case 3:t.msg="invalid block type",i.mode=30}b>>>=2,g-=2;break;case 14:for(b>>>=7&g,g-=7&g;g<32;){if(0===p)break t;p--,b+=c[d++]<>>16^65535)){t.msg="invalid stored block lengths",i.mode=30;break}if(i.length=65535&b,g=b=0,i.mode=15,6===e)break t;case 15:i.mode=16;case 16:if(E=i.length){if(p>>=5,g-=5,i.ndist=1+(31&b),b>>>=5,g-=5,i.ncode=4+(15&b),b>>>=4,g-=4,286>>=3,g-=3}for(;i.have<19;)i.lens[D[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,N={bits:i.lenbits},R=a(0,i.lens,0,19,i.lencode,0,i.work,N),i.lenbits=N.bits,R){t.msg="invalid code lengths set",i.mode=30;break}i.have=0,i.mode=19;case 19:for(;i.have>>16&255,P=65535&B,!((T=B>>>24)<=g);){if(0===p)break t;p--,b+=c[d++]<>>=T,g-=T,i.lens[i.have++]=P;else{if(16===P){for(F=T+2;g>>=T,g-=T,0===i.have){t.msg="invalid bit length repeat",i.mode=30;break}I=i.lens[i.have-1],E=3+(3&b),b>>>=2,g-=2}else if(17===P){for(F=T+3;g>>=T)),b>>>=3,g-=3}else{for(F=T+7;g>>=T)),b>>>=7,g-=7}if(i.have+E>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=30;break}for(;E--;)i.lens[i.have++]=I}}if(30===i.mode)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=30;break}if(i.lenbits=9,N={bits:i.lenbits},R=a(1,i.lens,0,i.nlen,i.lencode,0,i.work,N),i.lenbits=N.bits,R){t.msg="invalid literal/lengths set",i.mode=30;break}if(i.distbits=6,i.distcode=i.distdyn,N={bits:i.distbits},R=a(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,N),i.distbits=N.bits,R){t.msg="invalid distances set",i.mode=30;break}if(i.mode=20,6===e)break t;case 20:i.mode=21;case 21:if(6<=p&&258<=m){t.next_out=f,t.avail_out=m,t.next_in=d,t.avail_in=p,i.hold=b,i.bits=g,o(t,x),f=t.next_out,u=t.output,m=t.avail_out,d=t.next_in,c=t.input,p=t.avail_in,b=i.hold,g=i.bits,12===i.mode&&(i.back=-1);break}for(i.back=0;M=(B=i.lencode[b&(1<>>16&255,P=65535&B,!((T=B>>>24)<=g);){if(0===p)break t;p--,b+=c[d++]<>L)])>>>16&255,P=65535&B,!(L+(T=B>>>24)<=g);){if(0===p)break t;p--,b+=c[d++]<>>=L,g-=L,i.back+=L}if(b>>>=T,g-=T,i.back+=T,i.length=P,0===M){i.mode=26;break}if(32&M){i.back=-1,i.mode=12;break}if(64&M){t.msg="invalid literal/length code",i.mode=30;break}i.extra=15&M,i.mode=22;case 22:if(i.extra){for(F=i.extra;g>>=i.extra,g-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;M=(B=i.distcode[b&(1<>>16&255,P=65535&B,!((T=B>>>24)<=g);){if(0===p)break t;p--,b+=c[d++]<>L)])>>>16&255,P=65535&B,!(L+(T=B>>>24)<=g);){if(0===p)break t;p--,b+=c[d++]<>>=L,g-=L,i.back+=L}if(b>>>=T,g-=T,i.back+=T,64&M){t.msg="invalid distance code",i.mode=30;break}i.offset=P,i.extra=15&M,i.mode=24;case 24:if(i.extra){for(F=i.extra;g>>=i.extra,g-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=30;break}i.mode=25;case 25:if(0===m)break t;if(E=x-m,i.offset>E){if((E=i.offset-E)>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=30;break}_=E>i.wnext?(E-=i.wnext,i.wsize-E):i.wnext-E,E>i.length&&(E=i.length),w=i.window}else w=u,_=f-i.offset,E=i.length;for(my?(v=D[k+u[w]],N[F+u[w]]):(v=96,0),f=1<<_-A,T=p=1<>A)+(p-=f)]=S<<24|v<<16|x|0,0!==p;);for(f=1<<_-1;R&f;)f>>=1;if(0!==f?(R&=f-1,R+=f):R=0,w++,0==--B[_]){if(_===M)break;_=e[i+u[w]]}if(P<_&&(R&b)!==m){for(0===A&&(A=P),g+=T,C=1<<(L=_-A);L+A>>7)]}function T(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function M(t,e,i){t.bi_valid>16-i?(t.bi_buf|=e<>16-t.bi_valid,t.bi_valid+=i-16):(t.bi_buf|=e<>>=1,i<<=1,0<--e;);return i>>>1}function A(t,e,i){var n,s,r=new Array(16),o=0;for(n=1;n<=l;n++)r[n]=o=o+i[n-1]<<1;for(s=0;s<=e;s++){var a=t[2*s+1];0!==a&&(t[2*s]=L(r[a]++,a))}}function C(t){var e;for(e=0;e>1;1<=i;i--)N(t,r,i);for(s=h;i=t.heap[1],t.heap[1]=t.heap[t.heap_len--],N(t,r,1),n=t.heap[1],t.heap[--t.heap_max]=i,t.heap[--t.heap_max]=n,r[2*s]=r[2*i]+r[2*n],t.depth[s]=(t.depth[i]>=t.depth[n]?t.depth[i]:t.depth[n])+1,r[2*i+1]=r[2*n+1]=s,t.heap[1]=s++,N(t,r,1),2<=t.heap_len;);t.heap[--t.heap_max]=t.heap[1],function(t,e){var i,n,s,r,o,a,h=e.dyn_tree,c=e.max_code,u=e.stat_desc.static_tree,d=e.stat_desc.has_stree,f=e.stat_desc.extra_bits,p=e.stat_desc.extra_base,m=e.stat_desc.max_length,b=0;for(r=0;r<=l;r++)t.bl_count[r]=0;for(h[2*t.heap[t.heap_max]+1]=0,i=t.heap_max+1;i<573;i++)m<(r=h[2*h[2*(n=t.heap[i])+1]+1]+1)&&(r=m,b++),h[2*n+1]=r,c>=7;n>>=1)if(1&i&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e>>3,(o=t.static_len+3+7>>>3)<=s&&(s=o)):s=o=i+5,i+4<=s&&-1!==e?V(t,e,i,n):4===t.strategy||o===s?(M(t,2+(n?1:0),3),F(t,f,p)):(M(t,4+(n?1:0),3),function(t,e,i,n){var s;for(M(t,e-257,5),M(t,i-1,5),M(t,n-4,4),s=0;s>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&i,t.last_lit++,0===e?t.dyn_ltree[2*i]++:(t.matches++,e--,t.dyn_ltree[2*(b[i]+r+1)]++,t.dyn_dtree[2*w(e)]++),t.last_lit===t.lit_bufsize-1},i._tr_align=function(t){var e;M(t,2,3),P(t,256,f),16===(e=t).bi_valid?(T(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}},{"../utils/common":41}],53:[function(t,e,i){e.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(t,e,i){e.exports="function"==typeof n?n:function(){var t=[].slice.apply(arguments);t.splice(1,0,0),setTimeout.apply(null,t)}},{}]},{},[10])(10)}).call(this,i(176).Buffer,i(43),i(180).setImmediate)},function(t,e,i){(function(t){ /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */ var n=i(177),s=i(178),r=i(179);function o(){return l.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function p(t,e){if(l.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return G(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return W(t).length;default:if(n)return G(t).length;e=(""+e).toLowerCase(),n=!0}}function m(t,e,i){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,i);case"utf8":case"utf-8":return M(this,e,i);case"ascii":return P(this,e,i);case"latin1":case"binary":return L(this,e,i);case"base64":return T(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function b(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function g(t,e,i,n,s){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=s?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(s)return-1;i=t.length-1}else if(i<0){if(!s)return-1;i=0}if("string"==typeof e&&(e=l.from(e,n)),l.isBuffer(e))return 0===e.length?-1:y(t,e,i,n,s);if("number"==typeof e)return e&=255,l.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):y(t,[e],i,n,s);throw new TypeError("val must be string, number or Buffer")}function y(t,e,i,n,s){var r,o=1,a=t.length,l=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,l/=2,i/=2}function h(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(s){var c=-1;for(r=i;ra&&(i=a-l),r=i;r>=0;r--){for(var u=!0,d=0;ds&&(n=s):n=s;var r=e.length;if(r%2!=0)throw new TypeError("Invalid hex string");n>r/2&&(n=r/2);for(var o=0;o>8,s=i%256,r.push(s),r.push(n);return r}(e,t.length-i),t,i,n)}function T(t,e,i){return 0===e&&i===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,i))}function M(t,e,i){i=Math.min(t.length,i);for(var n=[],s=e;s239?4:h>223?3:h>191?2:1;if(s+u<=i)switch(u){case 1:h<128&&(c=h);break;case 2:128==(192&(r=t[s+1]))&&(l=(31&h)<<6|63&r)>127&&(c=l);break;case 3:r=t[s+1],o=t[s+2],128==(192&r)&&128==(192&o)&&(l=(15&h)<<12|(63&r)<<6|63&o)>2047&&(l<55296||l>57343)&&(c=l);break;case 4:r=t[s+1],o=t[s+2],a=t[s+3],128==(192&r)&&128==(192&o)&&128==(192&a)&&(l=(15&h)<<18|(63&r)<<12|(63&o)<<6|63&a)>65535&&l<1114112&&(c=l)}null===c?(c=65533,u=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),s+=u}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);for(var i="",n=0;nn)&&(i=n);for(var s="",r=e;ri)throw new RangeError("Trying to access beyond buffer length")}function R(t,e,i,n,s,r){if(!l.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>s||et.length)throw new RangeError("Index out of range")}function N(t,e,i,n){e<0&&(e=65535+e+1);for(var s=0,r=Math.min(t.length-i,2);s>>8*(n?s:1-s)}function F(t,e,i,n){e<0&&(e=4294967295+e+1);for(var s=0,r=Math.min(t.length-i,4);s>>8*(n?s:3-s)&255}function B(t,e,i,n,s,r){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function O(t,e,i,n,r){return r||B(t,0,i,4),s.write(t,e,i,n,23,4),i+4}function D(t,e,i,n,r){return r||B(t,0,i,8),s.write(t,e,i,n,52,8),i+8}e.Buffer=l,e.SlowBuffer=function(t){return+t!=t&&(t=0),l.alloc(+t)},e.INSPECT_MAX_BYTES=50,l.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=o(),l.poolSize=8192,l._augment=function(t){return t.__proto__=l.prototype,t},l.from=function(t,e,i){return h(null,t,e,i)},l.TYPED_ARRAY_SUPPORT&&(l.prototype.__proto__=Uint8Array.prototype,l.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&l[Symbol.species]===l&&Object.defineProperty(l,Symbol.species,{value:null,configurable:!0})),l.alloc=function(t,e,i){return n=null,r=e,o=i,c(s=t),s<=0?a(n,s):void 0!==r?"string"==typeof o?a(n,s).fill(r,o):a(n,s).fill(r):a(n,s);var n,s,r,o},l.allocUnsafe=function(t){return u(null,t)},l.allocUnsafeSlow=function(t){return u(null,t)},l.isBuffer=function(t){return!(null==t||!t._isBuffer)},l.compare=function(t,e){if(!l.isBuffer(t)||!l.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var i=t.length,n=e.length,s=0,r=Math.min(i,n);s0&&(t=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(t+=" ... ")),""},l.prototype.compare=function(t,e,i,n,s){if(!l.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===n&&(n=0),void 0===s&&(s=this.length),e<0||i>t.length||n<0||s>this.length)throw new RangeError("out of range index");if(n>=s&&e>=i)return 0;if(n>=s)return-1;if(e>=i)return 1;if(this===t)return 0;for(var r=(s>>>=0)-(n>>>=0),o=(i>>>=0)-(e>>>=0),a=Math.min(r,o),h=this.slice(n,s),c=t.slice(e,i),u=0;us)&&(i=s),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var r=!1;;)switch(n){case"hex":return S(this,t,e,i);case"utf8":case"utf-8":return v(this,t,e,i);case"ascii":return x(this,t,e,i);case"latin1":case"binary":return E(this,t,e,i);case"base64":return _(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,t,e,i);default:if(r)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),r=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},l.prototype.slice=function(t,e){var i,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e0&&(s*=256);)n+=this[t+--e]*s;return n},l.prototype.readUInt8=function(t,e){return e||I(t,1,this.length),this[t]},l.prototype.readUInt16LE=function(t,e){return e||I(t,2,this.length),this[t]|this[t+1]<<8},l.prototype.readUInt16BE=function(t,e){return e||I(t,2,this.length),this[t]<<8|this[t+1]},l.prototype.readUInt32LE=function(t,e){return e||I(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},l.prototype.readUInt32BE=function(t,e){return e||I(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},l.prototype.readIntLE=function(t,e,i){t|=0,e|=0,i||I(t,e,this.length);for(var n=this[t],s=1,r=0;++r=(s*=128)&&(n-=Math.pow(2,8*e)),n},l.prototype.readIntBE=function(t,e,i){t|=0,e|=0,i||I(t,e,this.length);for(var n=e,s=1,r=this[t+--n];n>0&&(s*=256);)r+=this[t+--n]*s;return r>=(s*=128)&&(r-=Math.pow(2,8*e)),r},l.prototype.readInt8=function(t,e){return e||I(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},l.prototype.readInt16LE=function(t,e){e||I(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},l.prototype.readInt16BE=function(t,e){e||I(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},l.prototype.readInt32LE=function(t,e){return e||I(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},l.prototype.readInt32BE=function(t,e){return e||I(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},l.prototype.readFloatLE=function(t,e){return e||I(t,4,this.length),s.read(this,t,!0,23,4)},l.prototype.readFloatBE=function(t,e){return e||I(t,4,this.length),s.read(this,t,!1,23,4)},l.prototype.readDoubleLE=function(t,e){return e||I(t,8,this.length),s.read(this,t,!0,52,8)},l.prototype.readDoubleBE=function(t,e){return e||I(t,8,this.length),s.read(this,t,!1,52,8)},l.prototype.writeUIntLE=function(t,e,i,n){t=+t,e|=0,i|=0,n||R(this,t,e,i,Math.pow(2,8*i)-1,0);var s=1,r=0;for(this[e]=255&t;++r=0&&(r*=256);)this[e+s]=t/r&255;return e+i},l.prototype.writeUInt8=function(t,e,i){return t=+t,e|=0,i||R(this,t,e,1,255,0),l.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},l.prototype.writeUInt16LE=function(t,e,i){return t=+t,e|=0,i||R(this,t,e,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},l.prototype.writeUInt16BE=function(t,e,i){return t=+t,e|=0,i||R(this,t,e,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},l.prototype.writeUInt32LE=function(t,e,i){return t=+t,e|=0,i||R(this,t,e,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):F(this,t,e,!0),e+4},l.prototype.writeUInt32BE=function(t,e,i){return t=+t,e|=0,i||R(this,t,e,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):F(this,t,e,!1),e+4},l.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e|=0,!n){var s=Math.pow(2,8*i-1);R(this,t,e,i,s-1,-s)}var r=0,o=1,a=0;for(this[e]=255&t;++r>0)-a&255;return e+i},l.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e|=0,!n){var s=Math.pow(2,8*i-1);R(this,t,e,i,s-1,-s)}var r=i-1,o=1,a=0;for(this[e+r]=255&t;--r>=0&&(o*=256);)t<0&&0===a&&0!==this[e+r+1]&&(a=1),this[e+r]=(t/o>>0)-a&255;return e+i},l.prototype.writeInt8=function(t,e,i){return t=+t,e|=0,i||R(this,t,e,1,127,-128),l.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},l.prototype.writeInt16LE=function(t,e,i){return t=+t,e|=0,i||R(this,t,e,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},l.prototype.writeInt16BE=function(t,e,i){return t=+t,e|=0,i||R(this,t,e,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},l.prototype.writeInt32LE=function(t,e,i){return t=+t,e|=0,i||R(this,t,e,4,2147483647,-2147483648),l.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):F(this,t,e,!0),e+4},l.prototype.writeInt32BE=function(t,e,i){return t=+t,e|=0,i||R(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),l.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):F(this,t,e,!1),e+4},l.prototype.writeFloatLE=function(t,e,i){return O(this,t,e,!0,i)},l.prototype.writeFloatBE=function(t,e,i){return O(this,t,e,!1,i)},l.prototype.writeDoubleLE=function(t,e,i){return D(this,t,e,!0,i)},l.prototype.writeDoubleBE=function(t,e,i){return D(this,t,e,!1,i)},l.prototype.copy=function(t,e,i,n){if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--s)t[s+e]=this[s+i];else if(r<1e3||!l.TYPED_ARRAY_SUPPORT)for(s=0;s>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(r=e;r55295&&i<57344){if(!s){if(i>56319){(e-=3)>-1&&r.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&r.push(239,191,189);continue}s=i;continue}if(i<56320){(e-=3)>-1&&r.push(239,191,189),s=i;continue}i=65536+(s-55296<<10|i-56320)}else s&&(e-=3)>-1&&r.push(239,191,189);if(s=null,i<128){if((e-=1)<0)break;r.push(i)}else if(i<2048){if((e-=2)<0)break;r.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;r.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;r.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return r}function W(t){return n.toByteArray(function(t){if((t=(e=t,e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")).replace(k,"")).length<2)return"";for(var e;t.length%4!=0;)t+="=";return t}(t))}function U(t,e,i,n){for(var s=0;s=e.length||s>=t.length);++s)e[s+i]=t[s];return s}}).call(this,i(43))},function(t,e,i){e.byteLength=function(t){var e=h(t),i=e[0],n=e[1];return 3*(i+n)/4-n},e.toByteArray=function(t){var e,i,n,o=h(t),a=o[0],l=o[1],c=new r(3*(a+(n=l))/4-n),u=0,d=l>0?a-4:a;for(i=0;i>16&255,c[u++]=e>>8&255,c[u++]=255&e;return 2===l&&(e=s[t.charCodeAt(i)]<<2|s[t.charCodeAt(i+1)]>>4,c[u++]=255&e),1===l&&(e=s[t.charCodeAt(i)]<<10|s[t.charCodeAt(i+1)]<<4|s[t.charCodeAt(i+2)]>>2,c[u++]=e>>8&255,c[u++]=255&e),c},e.fromByteArray=function(t){for(var e,i=t.length,s=i%3,r=[],o=0,a=i-s;oa?a:o+16383));return 1===s?(e=t[i-1],r.push(n[e>>2]+n[e<<4&63]+"==")):2===s&&(e=(t[i-2]<<8)+t[i-1],r.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"=")),r.join("")};for(var n=[],s=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,l=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function c(t,e,i){for(var s,r,o=[],a=e;a>18&63]+n[r>>12&63]+n[r>>6&63]+n[63&r]);return o.join("")}s["-".charCodeAt(0)]=62,s["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,i,n,s){var r,o,a=8*s-n-1,l=(1<>1,c=-7,u=i?s-1:0,d=i?-1:1,f=t[e+u];for(u+=d,r=f&(1<<-c)-1,f>>=-c,c+=a;c>0;r=256*r+t[e+u],u+=d,c-=8);for(o=r&(1<<-c)-1,r>>=-c,c+=n;c>0;o=256*o+t[e+u],u+=d,c-=8);if(0===r)r=1-h;else{if(r===l)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,n),r-=h}return(f?-1:1)*o*Math.pow(2,r-n)},e.write=function(t,e,i,n,s,r){var o,a,l,h=8*r-s-1,c=(1<>1,d=23===s?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:r-1,p=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+u>=1?d/l:d*Math.pow(2,1-u))*l>=2&&(o++,l/=2),o+u>=c?(a=0,o=c):o+u>=1?(a=(e*l-1)*Math.pow(2,s),o+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,s),o=0));s>=8;t[i+f]=255&a,f+=p,a/=256,s-=8);for(o=o<0;t[i+f]=255&o,f+=p,o/=256,h-=8);t[i+f-p]|=128*m}},function(t,e){var i={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},function(t,e,i){(function(t){var n=void 0!==t&&t||"undefined"!=typeof self&&self||window,s=Function.prototype.apply;function r(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new r(s.call(setTimeout,n,arguments),clearTimeout)},e.setInterval=function(){return new r(s.call(setInterval,n,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},r.prototype.unref=r.prototype.ref=function(){},r.prototype.close=function(){this._clearFn.call(n,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},i(181),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,i(43))},function(t,e,i){(function(t,e){!function(t,i){if(!t.setImmediate){var n,s,r,o,a,l=1,h={},c=!1,u=t.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(t);d=d&&d.setTimeout?d:t,"[object process]"==={}.toString.call(t.process)?n=function(t){e.nextTick((function(){p(t)}))}:function(){if(t.postMessage&&!t.importScripts){var e=!0,i=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=i,e}}()?(o="setImmediate$"+Math.random()+"$",a=function(e){e.source===t&&"string"==typeof e.data&&0===e.data.indexOf(o)&&p(+e.data.slice(o.length))},t.addEventListener?t.addEventListener("message",a,!1):t.attachEvent("onmessage",a),n=function(e){t.postMessage(o+e,"*")}):t.MessageChannel?((r=new MessageChannel).port1.onmessage=function(t){p(t.data)},n=function(t){r.port2.postMessage(t)}):u&&"onreadystatechange"in u.createElement("script")?(s=u.documentElement,n=function(t){var e=u.createElement("script");e.onreadystatechange=function(){p(t),e.onreadystatechange=null,s.removeChild(e),e=null},s.appendChild(e)}):n=function(t){setTimeout(p,0,t)},d.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),i=0;i1;){var e=t.pop(),i=e.obj[e.prop];if(jn(i)){for(var n=[],s=0;s=48&&l<=57||l>=65&&l<=90||l>=97&&l<=122||s===Un.RFC1738&&(40===l||41===l)?o+=r.charAt(a):l<128?o+=Hn[l]:l<2048?o+=Hn[192|l>>6]+Hn[128|63&l]:l<55296||l>=57344?o+=Hn[224|l>>12]+Hn[128|l>>6&63]+Hn[128|63&l]:(a+=1,l=65536+((1023&l)<<10|1023&r.charCodeAt(a)),o+=Hn[240|l>>18]+Hn[128|l>>12&63]+Hn[128|l>>6&63]+Hn[128|63&l])}return o},isBuffer:function(t){return!(!t||"object"!=typeof t)&&!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},isRegExp:function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},maybeMap:function(t,e){if(jn(t)){for(var i=[],n=0;n0?b.join(",")||null:void 0}];else if($n(a))g=a;else{var S=Object.keys(b);g=l?S.sort(l):S}for(var v=0;v-1?t.split(","):t},ls=function(t,e,i,n){if(t){var s=i.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,r=/(\[[^[\]]*])/g,o=i.depth>0&&/(\[[^[\]]*])/.exec(s),a=o?s.slice(0,o.index):s,l=[];if(a){if(!i.plainObjects&&ns.call(Object.prototype,a)&&!i.allowPrototypes)return;l.push(a)}for(var h=0;i.depth>0&&null!==(o=r.exec(s))&&h=0;--r){var o,a=t[r];if("[]"===a&&i.parseArrays)o=[].concat(s);else{o=i.plainObjects?Object.create(null):{};var l="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,h=parseInt(l,10);i.parseArrays||""!==l?!isNaN(h)&&a!==l&&String(h)===l&&h>=0&&i.parseArrays&&h<=i.arrayLimit?(o=[])[h]=s:o[l]=s:o={0:s}}s=o}return s}(l,e,i,n)}},hs=function(t,e){var i=function(t){if(!t)return rs;if(null!==t.decoder&&void 0!==t.decoder&&"function"!=typeof t.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==t.charset&&"utf-8"!==t.charset&&"iso-8859-1"!==t.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var e=void 0===t.charset?rs.charset:t.charset;return{allowDots:void 0===t.allowDots?rs.allowDots:!!t.allowDots,allowPrototypes:"boolean"==typeof t.allowPrototypes?t.allowPrototypes:rs.allowPrototypes,arrayLimit:"number"==typeof t.arrayLimit?t.arrayLimit:rs.arrayLimit,charset:e,charsetSentinel:"boolean"==typeof t.charsetSentinel?t.charsetSentinel:rs.charsetSentinel,comma:"boolean"==typeof t.comma?t.comma:rs.comma,decoder:"function"==typeof t.decoder?t.decoder:rs.decoder,delimiter:"string"==typeof t.delimiter||Yn.isRegExp(t.delimiter)?t.delimiter:rs.delimiter,depth:"number"==typeof t.depth||!1===t.depth?+t.depth:rs.depth,ignoreQueryPrefix:!0===t.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof t.interpretNumericEntities?t.interpretNumericEntities:rs.interpretNumericEntities,parameterLimit:"number"==typeof t.parameterLimit?t.parameterLimit:rs.parameterLimit,parseArrays:!1!==t.parseArrays,plainObjects:"boolean"==typeof t.plainObjects?t.plainObjects:rs.plainObjects,strictNullHandling:"boolean"==typeof t.strictNullHandling?t.strictNullHandling:rs.strictNullHandling}}(e);if(""===t||null==t)return i.plainObjects?Object.create(null):{};for(var n="string"==typeof t?function(t,e){var i,n={},s=e.ignoreQueryPrefix?t.replace(/^\?/,""):t,r=e.parameterLimit===1/0?void 0:e.parameterLimit,o=s.split(e.delimiter,r),a=-1,l=e.charset;if(e.charsetSentinel)for(i=0;i-1&&(c=ss(c)?[c]:c),ns.call(n,h)?n[h]=Yn.combine(n[h],c):n[h]=c}return n}(t,i):t,s=i.plainObjects?Object.create(null):{},r=Object.keys(n),o=0;o0?u+c:""},us="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==us&&us,ds="URLSearchParams"in us,fs="Symbol"in us&&"iterator"in Symbol,ps="FileReader"in us&&"Blob"in us&&function(){try{return new Blob,!0}catch(t){return!1}}(),ms="FormData"in us,bs="ArrayBuffer"in us;if(bs)var gs=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],ys=ArrayBuffer.isView||function(t){return t&&gs.indexOf(Object.prototype.toString.call(t))>-1};function Ss(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||""===t)throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function vs(t){return"string"!=typeof t&&(t=String(t)),t}function xs(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return fs&&(e[Symbol.iterator]=function(){return e}),e}function Es(t){this.map={},t instanceof Es?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function _s(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function ws(t){return new Promise((function(e,i){t.onload=function(){e(t.result)},t.onerror=function(){i(t.error)}}))}function Ts(t){var e=new FileReader,i=ws(e);return e.readAsArrayBuffer(t),i}function Ms(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function Ps(){return this.bodyUsed=!1,this._initBody=function(t){var e;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:ps&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:ms&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:ds&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():bs&&ps&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=Ms(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):bs&&(ArrayBuffer.prototype.isPrototypeOf(t)||ys(t))?this._bodyArrayBuffer=Ms(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="";var i=this.headers.get("content-type");i?i.indexOf("json")>=0&&"string"!=typeof this._bodyInit&&(this._bodyInit=this._bodyText):"string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):ds&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8")},ps&&(this.blob=function(){var t=_s(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=_s(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(Ts)}),this.text=function(){var t,e,i,n=_s(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,i=ws(e),e.readAsText(t),i;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),i=new Array(e.length),n=0;n-1?n:i),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&s)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(s),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==e.cache&&"no-cache"!==e.cache)){var r=/([?&])_=[^&]*/;if(r.test(this.url))this.url=this.url.replace(r,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function Cs(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var i=t.split("="),n=i.shift().replace(/\+/g," "),s=i.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(s))}})),e}function Is(t,e){if(!(this instanceof Is))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText=void 0===e.statusText?"":""+e.statusText,this.headers=new Es(e.headers),this.url=e.url||"",this._initBody(t)}As.prototype.clone=function(){return new As(this,{body:this._bodyInit})},Ps.call(As.prototype),Ps.call(Is.prototype),Is.prototype.clone=function(){return new Is(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new Es(this.headers),url:this.url})},Is.error=function(){var t=new Is(null,{status:0,statusText:""});return t.type="error",t};var Rs=[301,302,303,307,308];Is.redirect=function(t,e){if(-1===Rs.indexOf(e))throw new RangeError("Invalid status code");return new Is(null,{status:e,headers:{location:t}})};var Ns=us.DOMException;try{new Ns}catch(t){(Ns=function(t,e){this.message=t,this.name=e;var i=Error(t);this.stack=i.stack}).prototype=Object.create(Error.prototype),Ns.prototype.constructor=Ns}function Fs(t,e){return new Promise((function(i,n){var s=new As(t,e);if(s.signal&&s.signal.aborted)return n(new Ns("Aborted","AbortError"));var r=new XMLHttpRequest;function o(){r.abort()}r.onload=function(){var t,e,n={status:r.status,statusText:r.statusText,headers:(t=r.getAllResponseHeaders()||"",e=new Es,t.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(t){return 0===t.indexOf("\n")?t.substr(1,t.length):t})).forEach((function(t){var i=t.split(":"),n=i.shift().trim();if(n){var s=i.join(":").trim();e.append(n,s)}})),e)};n.url="responseURL"in r?r.responseURL:n.headers.get("X-Request-URL");var s="response"in r?r.response:r.responseText;setTimeout((function(){i(new Is(s,n))}),0)},r.onerror=function(){setTimeout((function(){n(new TypeError("Network request failed"))}),0)},r.ontimeout=function(){setTimeout((function(){n(new TypeError("Network request failed"))}),0)},r.onabort=function(){setTimeout((function(){n(new Ns("Aborted","AbortError"))}),0)},r.open(s.method,function(t){try{return""===t&&us.location.href?us.location.href:t}catch(e){return t}}(s.url),!0),"include"===s.credentials?r.withCredentials=!0:"omit"===s.credentials&&(r.withCredentials=!1),"responseType"in r&&(ps?r.responseType="blob":bs&&s.headers.get("Content-Type")&&-1!==s.headers.get("Content-Type").indexOf("application/octet-stream")&&(r.responseType="arraybuffer")),!e||"object"!=typeof e.headers||e.headers instanceof Es?s.headers.forEach((function(t,e){r.setRequestHeader(e,t)})):Object.getOwnPropertyNames(e.headers).forEach((function(t){r.setRequestHeader(t,vs(e.headers[t]))})),s.signal&&(s.signal.addEventListener("abort",o),r.onreadystatechange=function(){4===r.readyState&&s.signal.removeEventListener("abort",o)}),r.send(void 0===s._bodyInit?null:s._bodyInit)}))}Fs.polyfill=!0,us.fetch||(us.fetch=Fs,us.Headers=Es,us.Request=As,us.Response=Is),self.fetch.bind(self);var Bs=function(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t};var Os=function(t){for(var e=1;e1&&void 0!==arguments[1]?arguments[1]:{global:!1,core:!1,defaultInstance:!1},n=!1,s=!1,r=!1;"number"==typeof i?(process,n=!0,s=!1):"object"===Hs(i)&&i&&(s=i.global||!1,n=i.core||!1,r=i.defaultInstance||!1),s?t.globalMiddlewares.splice(t.globalMiddlewares.length-t.defaultGlobalMiddlewaresLength,0,e):n?t.coreMiddlewares.splice(t.coreMiddlewares.length-t.defaultCoreMiddlewaresLength,0,e):r?this.defaultMiddlewares.push(e):this.middlewares.push(e)}},{key:"execute",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,i=Xs([].concat(Gs(this.middlewares),Gs(this.defaultMiddlewares),Gs(t.globalMiddlewares),Gs(t.coreMiddlewares)));return i(e)}}]),t}();Ys.globalMiddlewares=[],Ys.defaultGlobalMiddlewaresLength=0,Ys.coreMiddlewares=[],Ys.defaultCoreMiddlewaresLength=0;var Ks=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t};var qs=function(t,e){return!e||"object"!==Hs(e)&&"function"!=typeof e?Ks(t):e},$s=js((function(t){function e(i){return t.exports=e=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},e(i)}t.exports=e})),Js=js((function(t){function e(i,n){return t.exports=e=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},e(i,n)}t.exports=e}));var Zs=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Js(t,e)};var Qs=function(t){return-1!==Function.toString.call(t).indexOf("[native code]")},tr=js((function(t){function e(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function i(n,s,r){return e()?t.exports=i=Reflect.construct:t.exports=i=function(t,e,i){var n=[null];n.push.apply(n,e);var s=new(Function.bind.apply(t,n));return i&&Js(s,i.prototype),s},i.apply(null,arguments)}t.exports=i})),er=js((function(t){function e(i){var n="function"==typeof Map?new Map:void 0;return t.exports=e=function(t){if(null===t||!Qs(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,e)}function e(){return tr(t,arguments,$s(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Js(e,t)},e(i)}t.exports=e})),ir=function(){function t(e){Ws(this,t),this.cache=new Map,this.timer={},this.extendOptions(e)}return zs(t,[{key:"extendOptions",value:function(t){this.maxCache=t.maxCache||0}},{key:"get",value:function(t){return this.cache.get(JSON.stringify(t))}},{key:"set",value:function(t,e){var i=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:6e4;if(this.maxCache>0&&this.cache.size>=this.maxCache){var s=Gs(this.cache.keys())[0];this.cache.delete(s),this.timer[s]&&clearTimeout(this.timer[s])}var r=JSON.stringify(t);this.cache.set(r,e),n>0&&(this.timer[r]=setTimeout((function(){i.cache.delete(r),delete i.timer[r]}),n))}},{key:"delete",value:function(t){var e=JSON.stringify(t);return delete this.timer[e],this.cache.delete(e)}},{key:"clear",value:function(){return this.timer={},this.cache.clear()}}]),t}(),nr=function(t){function e(t,i){var n,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"RequestError";return Ws(this,e),(n=qs(this,$s(e).call(this,t))).name="RequestError",n.request=i,n.type=s,n}return Zs(e,t),e}(er(Error)),sr=function(t){function e(t,i,n,s){var r,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"ResponseError";return Ws(this,e),(r=qs(this,$s(e).call(this,i||t.statusText))).name="ResponseError",r.data=n,r.response=t,r.request=s,r.type=o,r}return Zs(e,t),e}(er(Error));function rr(t){return new Promise((function(e,i){var n=new FileReader;n.onload=function(){e(n.result)},n.onerror=i,n.readAsText(t,"GBK")}))}function or(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;try{return JSON.parse(t)}catch(s){if(e)throw new sr(i,"JSON.parse fail",t,n,"ParseError")}return t}function ar(t){return new Promise((function(e,i){t.cancelToken&&t.cancelToken.promise.then((function(t){i(t)}))}))}var lr=Object.prototype.toString;function hr(){var t;return"undefined"!=typeof process&&"[object process]"===lr.call(process)&&(t="NODE"),"undefined"!=typeof XMLHttpRequest&&(t="BROWSER"),t}function cr(t){return"object"===Hs(t)&&"[object Array]"===Object.prototype.toString.call(t)}function ur(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams}function dr(t){return null!==t&&"object"===Hs(t)}function fr(t,e){if(t)if("object"!==Hs(t)&&(t=[t]),cr(t))for(var i=0;i=200&&i.status<300)return a?void(t.res={data:e,response:i}):void(t.res=e);throw new sr(i,"http error",e,s,"HttpError")}}})).catch((function(e){if(e instanceof nr||e instanceof sr)throw e;var i=t.req,n=t.res;throw e.request=e.request||i,e.response=e.response||n,e.type=e.type||e.name,e.data=e.data||void 0,e}))}],vr=[function(t,e){if(!t)return e();var i=t.req,n=(i=void 0===i?{}:i).options,s=void 0===n?{}:n,r=i.url,o=void 0===r?"":r,a=t.cache,l=t.responseInterceptors,h=s.timeout,c=void 0===h?0:h,u=s.__umiRequestCoreType__,d=void 0===u?"normal":u,f=s.useCache,p=void 0!==f&&f,m=s.method,b=void 0===m?"get":m,g=s.params,y=s.ttl,S=s.validateCache,v=void 0===S?gr:S;if("normal"!==d)return process,e();var x=fetch;if(!x)throw new Error("Global fetch not exist!");var E,_,w,T="BROWSER"===hr(),M=v(o,s)&&p&&T;if(M){var P=a.get({url:o,params:g,method:b});if(P)return(P=P.clone()).useCache=!0,t.res=P,e()}return E=c>0?Promise.race([ar(s),x(o,s),(_=c,w=t.req,new Promise((function(t,e){setTimeout((function(){e(new nr("timeout of ".concat(_,"ms exceeded"),w,"Timeout"))}),_)})))]):Promise.race([ar(s),x(o,s)]),l.forEach((function(t){E=E.then((function(e){var i="function"==typeof e.clone?e.clone():e;return t(i,s)}))})),E.then((function(i){if(M&&200===i.status){var n=i.clone();n.useCache=!0,a.set({url:o,params:g,method:b},n,y)}return t.res=i,e()}))}];Ys.globalMiddlewares=Sr,Ys.defaultGlobalMiddlewaresLength=Sr.length,Ys.coreMiddlewares=vr,Ys.defaultCoreMiddlewaresLength=vr.length;var xr=function(){function t(e){Ws(this,t),this.onion=new Ys([]),this.fetchIndex=0,this.mapCache=new ir(e),this.initOptions=e,this.instanceRequestInterceptors=[],this.instanceResponseInterceptors=[]}return zs(t,[{key:"use",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{global:!1,core:!1};return this.onion.use(t,e),this}},{key:"extendOptions",value:function(t){this.initOptions=br(this.initOptions,t),this.mapCache.extendOptions(t)}},{key:"dealRequestInterceptors",value:function(e){return[].concat(Gs(t.requestInterceptors),Gs(this.instanceRequestInterceptors)).reduce((function(t,i){return t.then((function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e.req.url=t.url||e.req.url,e.req.options=t.options||e.req.options,i(e.req.url,e.req.options)}))}),Promise.resolve()).then((function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e.req.url=t.url||e.req.url,e.req.options=t.options||e.req.options,Promise.resolve()}))}},{key:"request",value:function(e,i){var n=this,s=this.onion,r={req:{url:e,options:i},res:null,cache:this.mapCache,responseInterceptors:[].concat(Gs(t.responseInterceptors),Gs(this.instanceResponseInterceptors))};if("string"!=typeof e)throw new Error("url MUST be a string");return new Promise((function(t,e){n.dealRequestInterceptors(r).then((function(){return s.execute(r)})).then((function(){t(r.res)})).catch((function(i){var n=r.req.options.errorHandler;if(n)try{var s=n(i);t(s)}catch(t){e(t)}else e(i)}))}))}}],[{key:"requestUse",value:function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{global:!0};if("function"!=typeof e)throw new TypeError("Interceptor must be function!");i.global?t.requestInterceptors.push(e):this.instanceRequestInterceptors.push(e)}},{key:"responseUse",value:function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{global:!0};if("function"!=typeof e)throw new TypeError("Interceptor must be function!");i.global?t.responseInterceptors.push(e):this.instanceResponseInterceptors.push(e)}}]),t}();function Er(t){this.message=t}function _r(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise((function(t){e=t}));var i=this;t((function(t){i.reason||(i.reason=new Er(t),e(i.reason))}))}function wr(t){return!(!t||!t.__CANCEL__)}xr.requestInterceptors=[function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=e.prefix,n=e.suffix;return i&&(t="".concat(i).concat(t)),n&&(t="".concat(t).concat(n)),{url:t,options:e}}],xr.responseInterceptors=[],Er.prototype.toString=function(){return this.message?"Cancel: ".concat(this.message):"Cancel"},Er.prototype.__CANCEL__=!0,_r.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},_r.source=function(){var t;return{token:new _r((function(e){t=e})),cancel:t}};var Tr=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=new xr(t),i=function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=br(e.initOptions,i);return e.request(t,n)};i.use=e.use.bind(e),i.fetchIndex=e.fetchIndex,i.interceptors={request:{use:xr.requestUse.bind(e)},response:{use:xr.responseUse.bind(e)}};var n=["get","post","delete","put","patch","head","options","rpc"];return n.forEach((function(t){i[t]=function(e,n){return i(e,Os({},n,{method:t}))}})),i.Cancel=Er,i.CancelToken=_r,i.isCancel=wr,i.extendOptions=e.extendOptions.bind(e),i.middlewares={instance:e.onion.middlewares,defaultInstance:e.onion.defaultMiddlewares,global:Ys.globalMiddlewares,core:Ys.coreMiddlewares},i};Tr({parseResponse:!1});var Mr=Tr({});function Pr(t){return null!=t}function Lr(t){return"function"==typeof t}function Ar(t,e){var i=e.split("."),n=t;return i.forEach((function(t){var e;n=null!=(e=n[t])?e:""})),n}function Cr(t,e){return e?"string"==typeof e?" "+t+"--"+e:Array.isArray(e)?e.reduce((function(e,i){return e+Cr(t,i)}),""):Object.keys(e).reduce((function(i,n){return i+(e[n]?Cr(t,n):"")}),""):""}function Ir(t){return function(e,i){return e&&"string"!=typeof e&&(i=e,e=""),""+(e=e?t+"__"+e:t)+Cr(e,i)}}var Rr=/-(\w)/g;function Nr(t){return t.replace(Rr,(function(t,e){return e.toUpperCase()}))}function Fr(t){return function(e){return e.name=t,e.install=function(i){i.component(t,e),i.component(Nr("-"+t),e)},Si(e)}}Object.prototype.hasOwnProperty;var Br=Yt("zh-CN"),Or=kt({"zh-CN":{name:"姓名",tel:"电话",save:"保存",confirm:"确认",cancel:"取消",delete:"删除",complete:"完成",loading:"加载中...",telEmpty:"请填写电话",nameEmpty:"请填写姓名",nameInvalid:"请输入正确的姓名",confirmDelete:"确定要删除吗",telInvalid:"请输入正确的手机号",vanCalendar:{end:"结束",start:"开始",title:"日期选择",confirm:"确定",startEnd:"开始/结束",weekdays:["日","一","二","三","四","五","六"],monthTitle:function(t,e){return t+"年"+e+"月"},rangePrompt:function(t){return"选择天数不能超过 "+t+" 天"}},vanCascader:{select:"请选择"},vanContactCard:{addText:"添加联系人"},vanContactList:{addText:"新建联系人"},vanPagination:{prev:"上一页",next:"下一页"},vanPullRefresh:{pulling:"下拉即可刷新...",loosing:"释放即可刷新..."},vanSubmitBar:{label:"合计:"},vanCoupon:{unlimited:"无使用门槛",discount:function(t){return t+"折"},condition:function(t){return"满"+t+"元可用"}},vanCouponCell:{title:"优惠券",tips:"暂无可用",count:function(t){return t+"张可用"}},vanCouponList:{empty:"暂无优惠券",exchange:"兑换",close:"不使用优惠券",enable:"可用",disabled:"不可用",placeholder:"请输入优惠码"},vanAddressEdit:{area:"地区",postal:"邮政编码",areaEmpty:"请选择地区",addressEmpty:"请填写详细地址",postalEmpty:"邮政编码格式不正确",defaultAddress:"设为默认收货地址",telPlaceholder:"收货人手机号",namePlaceholder:"收货人姓名",areaPlaceholder:"选择省 / 市 / 区"},vanAddressEditDetail:{label:"详细地址",placeholder:"街道门牌、楼层房间号等信息"},vanAddressList:{add:"新增地址"}}}),Dr=function(){return Or[Br.value]};function kr(t){var e=Nr(t)+".";return function(t){for(var i=Dr(),n=Ar(i,e+t)||Ar(i,t),s=arguments.length,r=new Array(s>1?s-1:0),o=1;os?s+"+":r},r=function(){if(n()||t.dot){var e={background:t.color};if(t.offset){var r=t.offset,o=r[0],a=r[1];i.default?(e.top=a+"px",e.right=-o+"px"):(e.marginTop=a+"px",e.marginLeft=o+"px")}return Vi("div",{class:Jr({dot:t.dot,fixed:!!i.default}),style:e},[s()])}};return function(){if(i.default){var e=t.tag;return Vi(e,{class:Jr("wrapper")},{default:function(){return[i.default(),r()]}})}return r()}}}),Qr=Vr("icon"),to=Qr[0],eo=Qr[1];for(var io=to({props:{dot:Boolean,name:String,size:[Number,String],badge:[Number,String],color:String,tag:{type:String,default:"i"},classPrefix:{type:String,default:eo()}},setup:function(t,e){var i=e.slots;return function(){var e=t.tag,n=t.dot,s=t.name,r=t.size,o=t.badge,a=t.color,l=t.classPrefix,h=function(t){return!!t&&-1!==t.indexOf("/")}(s);return Vi(Zr,{dot:n,tag:e,content:o,class:[l,h?"":l+"-"+s],style:{color:a,fontSize:Wr(r)}},{default:function(){return[null==i.default?void 0:i.default(),h&&Vi("img",{class:eo("image"),src:s},null)]}})}}}),no=Vr("loading"),so=no[0],ro=no[1],oo=[],ao=0;ao<12;ao++)oo.push(Vi("i",null,null));var lo=Vi("svg",{class:ro("circular"),viewBox:"25 25 50 50"},[Vi("circle",{cx:"50",cy:"50",r:"20",fill:"none"},null)]),ho=so({props:{size:[Number,String],color:String,vertical:Boolean,textSize:[Number,String],textColor:String,type:{type:String,default:"circular"}},setup:function(t,e){var i=e.slots,n=mn((function(){return Xr({color:t.color},Ur(t.size))})),s=function(){var e;if(i.default)return Vi("span",{class:ro("text"),style:{fontSize:Wr(t.textSize),color:null!=(e=t.textColor)?e:t.color}},[i.default()])};return function(){var e=t.type,i=t.vertical;return Vi("div",{class:ro([e,{vertical:i}])},[Vi("span",{class:ro("spinner",e),style:n.value},["spinner"===e?oo:lo]),s()])}}});function co(t){return"function"==typeof t||"[object Object]"===Object.prototype.toString.call(t)&&!Fi(t)}var uo=Vr("button"),fo=uo[0],po=uo[1],mo=fo({props:Xr({},Yr,{text:String,icon:String,color:String,block:Boolean,plain:Boolean,round:Boolean,square:Boolean,loading:Boolean,hairline:Boolean,disabled:Boolean,iconPrefix:String,loadingText:String,loadingType:String,tag:{type:String,default:"button"},type:{type:String,default:"default"},size:{type:String,default:"normal"},nativeType:{type:String,default:"button"},loadingSize:{type:String,default:"20px"},iconPosition:{type:String,default:"left"}}),emits:["click"],setup:function(t,e){var i=e.emit,n=e.slots,s=Kr(),r=function(){return t.loading?n.loading?n.loading():Vi(ho,{class:po("loading"),size:t.loadingSize,type:t.loadingType,color:"currentColor"},null):t.icon?Vi(io,{name:t.icon,class:po("icon"),classPrefix:t.iconPrefix},null):void 0},o=function(){var e;if(e=t.loading?t.loadingText:n.default?n.default():t.text)return Vi("span",{class:po("text")},co(e)?e:{default:function(){return[e]}})},a=function(){var e=t.color,i=t.plain;if(e){var n={};return n.color=i?e:"white",i||(n.background=e),-1!==e.indexOf("gradient")?n.border=0:n.borderColor=e,n}},l=function(e){t.loading&&e.preventDefault(),t.loading||t.disabled||(i("click",e),s())};return function(){var e,i,n=t.tag,s=t.type,h=t.size,c=t.block,u=t.round,d=t.plain,f=t.square,p=t.loading,m=t.disabled,b=t.hairline,g=t.nativeType,y=t.iconPosition,S=[po([s,h,{plain:d,block:c,round:u,square:f,loading:p,disabled:m,hairline:b}]),(i={},i["van-hairline--surround"]=b,i)];return Vi(n,{type:g,class:S,style:a(),disabled:m,onClick:l},co(e=Vi("div",{class:po("content")},["left"===y&&r(),o(),"right"===y&&r()]))?e:{default:function(){return[e]}})}}});var bo=Vr("slider"),go=bo[0],yo=bo[1],So=go({props:{range:Boolean,disabled:Boolean,readonly:Boolean,vertical:Boolean,barHeight:[Number,String],buttonSize:[Number,String],activeColor:String,inactiveColor:String,min:{type:[Number,String],default:0},max:{type:[Number,String],default:100},step:{type:[Number,String],default:1},modelValue:{type:[Number,Array],default:0}},emits:["change","drag-end","drag-start","update:modelValue"],setup:function(t,e){var i,n,s,r,o,a,l,h,c,u,d,f,p,m=e.emit,b=e.slots,g=Yt(),y=Yt(),S=(r=Yt(0),o=Yt(0),a=Yt(0),l=Yt(0),h=Yt(0),c=Yt(0),u=Yt(""),{move:function(t){var e,i,n=t.touches[0];a.value=n.clientX-r.value,l.value=n.clientY-o.value,h.value=Math.abs(a.value),c.value=Math.abs(l.value),u.value||(u.value=(e=h.value)>(i=c.value)&&e>10?"horizontal":i>e&&i>10?"vertical":"")},start:function(t){d(),r.value=t.touches[0].clientX,o.value=t.touches[0].clientY},reset:d=function(){a.value=0,l.value=0,h.value=0,c.value=0,u.value=""},startX:r,startY:o,deltaX:a,deltaY:l,offsetX:h,offsetY:c,direction:u,isVertical:function(){return"vertical"===u.value},isHorizontal:function(){return"horizontal"===u.value}}),v=mn((function(){return Number(t.max)-Number(t.min)})),x=mn((function(){var e,i=t.vertical?"width":"height";return(e={background:t.inactiveColor})[i]=Wr(t.barHeight),e})),E=function(e){return!!t.range&&Array.isArray(e)},_=function(){var e=t.modelValue,i=t.min;return E(e)?100*(e[0]-Number(i))/v.value+"%":"0%"},w=mn((function(){var e,i,n;return(e={})[t.vertical?"height":"width"]=(i=t.modelValue,n=t.min,E(i)?100*(i[1]-i[0])/v.value+"%":100*(i-Number(n))/v.value+"%"),e.left=t.vertical?void 0:_(),e.top=t.vertical?_():void 0,e.background=t.activeColor,e.transition=y.value?"none":void 0,e})),T=function(e){var i=t.min,n=t.max,s=t.step;return e=Math.max(+i,Math.min(e,+n)),Math.round(e/+s)*+s},M=function(t,e){return JSON.stringify(t)===JSON.stringify(e)},P=function(e,i){e=E(e)?function(t){return t[0]>t[1]?t.slice(0).reverse():t}(e).map(T):T(e),M(e,t.modelValue)||m("update:modelValue",e),i&&!M(e,n)&&m("change",e)},L=function(e){if(e.stopPropagation(),!t.disabled&&!t.readonly){var i=t.min,n=t.vertical,s=t.modelValue,r=Hr(g),o=n?e.clientY-r.top:e.clientX-r.left,a=n?r.height:r.width,l=Number(i)+o/a*v.value;if(E(s)){var h=s[0],c=s[1];P(l<=(h+c)/2?[l,c]:[h,l],!0)}else P(l,!0)}},A=function(e){if(!t.disabled&&!t.readonly){"start"===y.value&&m("drag-start"),function(t,e){("boolean"!=typeof t.cancelable||t.cancelable)&&t.preventDefault(),e&&zr(t)}(e,!0),S.move(e),y.value="draging";var r=Hr(g),o=(t.vertical?S.deltaY.value:S.deltaX.value)/(t.vertical?r.height:r.width)*v.value;E(n)?s[i]=n[i]+o:s=n+o,P(s)}},C=function(){t.disabled||t.readonly||("draging"===y.value&&(P(s,!0),m("drag-end")),y.value="")},I=function(e){var r="number"==typeof e?t.modelValue[e]:t.modelValue;return Vi("div",{role:"slider",class:yo(function(){if("number"==typeof e){return"button-wrapper-"+["left","right"][e]}return"button-wrapper"}()),tabindex:t.disabled||t.readonly?-1:0,"aria-valuemin":+t.min,"aria-valuenow":r,"aria-valuemax":+t.max,"aria-orientation":t.vertical?"vertical":"horizontal",onTouchstart:function(r){var o;"number"==typeof e&&(i=e),o=r,t.disabled||t.readonly||(S.start(o),s=t.modelValue,n=E(s)?s.map(T):T(s),y.value="start")},onTouchmove:A,onTouchend:C,onTouchcancel:C,onClick:zr},[b.button?b.button():Vi("div",{class:yo("button"),style:Ur(t.buttonSize)},null)])};return P(t.modelValue),f=function(){return t.modelValue},(p=Hi("vanField",null))&&!p.childFieldValue.value&&(p.childFieldValue.value=f,ni(f,(function(){p.resetValidation(),p.validateWithTrigger("onChange")}))),function(){return Vi("div",{ref:g,style:x.value,class:yo({vertical:t.vertical,disabled:t.disabled}),onClick:L},[Vi("div",{class:yo("bar"),style:w.value},[t.range?[I(0),I(1)]:I()])])}}});class vo{constructor(t){this.audios={},this.status="init",this.muted=!1,this.audio=null,this.audio=null,this.audios={};for(const e of t){const t=new Audio(e);this.audios[e]=t,this.audio||(this.audio=t)}t.length&&(this.status="pause")}syncEvent(){for(const t of Object.values(this.audios))t.addEventListener("play",(()=>{this.play()})),t.addEventListener("pause",(()=>{this.pause()}))}play(){Object.values(this.audios).map((t=>t.play())),this.status="play"}pause(){Object.values(this.audios).map((t=>t.pause())),this.status="pause"}setMute(t,e){e?this.audios[e]&&(this.audios[e].muted=t):(this.muted=t,Object.values(this.audios).map((e=>e.muted=t)))}setCurrentTime(t){Object.values(this.audios).map((e=>e.currentTime=t))}toggleMute(t){t?this.audios[t]&&(this.audios[t].muted=!this.audios[t].muted):(Object.values(this.audios).map((t=>t.muted=!this.muted)),this.muted=!this.muted)}togglePlay(){"pause"===this.status?this.play():"play"===this.status&&this.pause()}}const xo=t=>t<10?"0"+t:t,Eo=t=>{const e=t%60,i=t/60;return xo(Math.floor(i))+":"+xo(Math.floor(e))};class _o{constructor(){this.el=document.createElement("div"),this.init()}init(){this.el.id="section-hint"+Math.floor(1e5*Math.random()),document.body.appendChild(this.el)}showForElement(t){const{x:e,y:i,width:n,height:s,context:r}=t.sourceMeasure.verticalMeasureList[0].stave;this.el.style.position="absolute",this.el.style.top=r.element.offsetTop+i+"px",this.el.style.left=e+"px",this.el.style.width=n+"px",this.el.style.height=s+"px",this.el.style.backgroundColor="#01C1B5",this.el.style.opacity="0.12"}hide(){this.el.style.display="none"}show(){this.el.style.display=""}destroy(){this.el.remove()}}var wo="player_3b8eb2e8",To="times_3b8eb2e8";const Mo=Array.prototype.slice;function Po(t,e=null,i=null){return(arguments.length>3||Fi(i))&&(i=Mo.call(arguments,2)),Vi(t,e,i)}var Lo=Si({name:"player",props:{osmd:Object,times:Array},setup(t){const e=kt({audiosInstance:new vo(["https://daya.ks3-cn-beijing.ksyun.com/202012/SJEBRO6.mp3"]),currentTime:Eo(0),duration:Eo(0),currentTimeNum:0,durationNum:0,playState:"pause",loading:!1});let i=new _o;const n=()=>{t.osmd.cursor.reset(),t.osmd.cursor.hide(),i.destroy(),i=new _o,i.hide(),e.audiosInstance.pause(),s(0)};e.audiosInstance.audio?.addEventListener("loadedmetadata",(t=>{e.duration=Eo(t.target.duration),e.durationNum=t.target.duration})),e.audiosInstance.audio?.addEventListener("waiting",(()=>{e.loading=!0}),!1),e.audiosInstance.audio?.addEventListener("playing",(()=>{e.loading=!1}),!1),e.audiosInstance.audio?.addEventListener("play",(()=>{i.show(),e.playState=e.audiosInstance.status}),!1),e.audiosInstance.audio?.addEventListener("pause",(()=>{e.playState=e.audiosInstance.status}),!1),e.audiosInstance.audio?.addEventListener("ended",n,!1),e.audiosInstance.audio?.addEventListener("timeupdate",(n=>{if(e.audiosInstance.audio){e.currentTimeNum=n.target.currentTime,e.currentTime=Eo(n.target.currentTime);const s=((t,e)=>{let i=0;for(let n=0;n=t[n].time;n++)i=n;return i})(t.times,e.audiosInstance.audio.currentTime);e.currentTimeNum+.3>=t.times[s].time&&t.osmd.cursor.show(),t.times[s]&&t.times[s].noteElement&&i.showForElement(t.times[s].noteElement),t.times[s]&&t.times[s].noteElement.sourceMeasure.verticalMeasureList[0].vfVoices,((t,e)=>{let i=0;for(t.cursor.reset();i{e.currentTimeNum=t,e.currentTime=Eo(t),e.audiosInstance.setCurrentTime(t),e.playState=e.audiosInstance.status};return()=>Po("div",{class:wo},Po(mo,{icon:"play"===e.playState?"./_assets/pause.8d5e2893.svg":"./_assets/play.ab0b15cc.svg",loading:e.loading,onClick:()=>{e.audiosInstance.togglePlay(),e.playState=e.audiosInstance.status}}),Po("div",{class:To},Po("span",null,e.currentTime),Po(So,{min:0,max:e.durationNum,modelValue:e.currentTimeNum,step:1,onChange:t=>{const i=Math.min(t,e.durationNum);s(i)},activeColor:"#14928A"}),Po("span",null,e.duration)),Po(mo,{icon:"./_assets/replay.3079c074.svg",onClick:()=>n()}),Po(mo,{icon:"./_assets/setting.46621af4.svg"}))}}),Ao="container_35767ee5";const Co=Yt(null),Io=Yt(null),Ro=Yt(null),No=kt({osmd:{},times:[],scoreData:null});var Fo=Si({name:"SheetMusic",setup:()=>((async()=>{try{const t=await Mr.get("./Fundamental-Level 1 - 4Flute.xml");await No.osmd.load(t),await No.osmd.render(),No.times=(t=>{t.cursor.reset();const e=t.cursor.iterator,i=[];for(;!e.endReached;){for(const t of e.currentVoiceEntries)for(const n of t.notes)n&&i.push({note:n.halfTone+12,time:4*e.currentTimeStamp.realValue*(60/90)+5,realValue:e.currentTimeStamp.realValue,noteElement:n});e.moveToNext()}return i})(No.osmd),console.log(No)}catch(t){}})(),()=>Po("div",{class:Ao,ref:Io},Po("div",{ref:Co}),Po(Lo,{ref:Ro,osmd:No.osmd,times:No.times}))),data:()=>({osmd:{},times:[],scoreData:null}),mounted(){No.osmd=new kn.OpenSheetMusicDisplay(Co.value,{followCursor:!0,autoResize:!0,drawingParameters:"compacttight"})},methods:{play(){},soundLoaded(t){console.log(t)},setStepIndex(t){let e=0;for(this.osmd.cursor.reset();e=this.times[i].time))break;e=i}return e},async loadAndRender(){try{const t=await Mr.get("/Fundamental-Level 1 - 4Flute.xml");await this.osmd.load(t),await this.$nextTick(),await this.osmd.render(),await this.getAllNodes()}catch(t){}},async getAllNodes(){this.osmd.cursor.reset();const t=this.osmd.cursor.iterator,e=[];for(await this.$nextTick();!t.endReached;){for(const i of t.currentVoiceEntries)for(const n of i.notes)n&&e.push({note:n.halfTone+12,time:4*t.currentTimeStamp.realValue*(60/90)+5,realValue:t.currentTimeStamp.realValue});t.moveToNext()}return this.times=[...e],e}}});((...t)=>{const e=(Bn||(Bn=_i(Fn))).createApp(...t),{mount:i}=e;return e.mount=t=>{const n=function(t){if(E(t)){return document.querySelector(t)}return t}(t);if(!n)return;const s=e._component;x(s)||s.render||s.template||(s.template=n.innerHTML),n.innerHTML="";const r=i(n);return n instanceof Element&&(n.removeAttribute("v-cloak"),n.setAttribute("data-v-app","")),r},e})(Si({setup:()=>()=>Po("div",null,Po(Fo,null))})).mount("#app");