@fretfall/player 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -5
- package/highway.js +1 -1
- package/index.html +139 -37
- package/package.json +4 -4
- package/player.js +1 -1
- package/demo.atex +0 -113
package/README.md
CHANGED
|
@@ -2,11 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
An arcade-style note highway for Guitar Pro and MusicXML tabs, in the browser.
|
|
4
4
|
|
|
5
|
-
[](https://github.com/fretfall/player/actions/workflows/ci.yml)
|
|
6
|
+
[](https://github.com/fretfall/player/actions/workflows/perf.yml)
|
|
7
7
|
[](https://www.npmjs.com/package/@fretfall/player)
|
|
8
8
|
[](LICENSE)
|
|
9
9
|
|
|
10
|
+
[**Try it**](https://fretfall.github.io/player/) — the demo is the published package with a front door of its own, served from GitHub Pages.
|
|
11
|
+
|
|
12
|
+

|
|
13
|
+
|
|
10
14
|
Open a tab and play along: the notes fall down a 3D fretboard, with hand positions and fingering worked out for you. Add the
|
|
11
15
|
band's recording and the player lines the tab up with it on its own.
|
|
12
16
|
|
|
@@ -26,7 +30,8 @@ Any static file server works. Tabs are read and played by [alphaTab](https://www
|
|
|
26
30
|
|
|
27
31
|
## Build on it
|
|
28
32
|
|
|
29
|
-
Serve the package's files and add your own page around it. The player
|
|
33
|
+
Serve the package's files and add your own page around it. The player starts with no song of its own — the page around it
|
|
34
|
+
opens the first one, as the demo's front door does with its demo tab. The player exposes `window.fretfall` once it dispatches
|
|
30
35
|
`fretfall:ready`:
|
|
31
36
|
|
|
32
37
|
```js
|
|
@@ -40,7 +45,7 @@ fretfall.part = 1;
|
|
|
40
45
|
| Member | |
|
|
41
46
|
|:--|:--|
|
|
42
47
|
| `open(files, options)` / `pick()` | Open songs, or show the file dialog |
|
|
43
|
-
| `playing`, `time`, `length` | Where playback is, in seconds |
|
|
48
|
+
| `playing`, `time`, `length` | Where playback is, in seconds. `playing` is settable: it waits for the synth's instruments |
|
|
44
49
|
| `parts`, `part` | The song's parts, and the one shown (settable) |
|
|
45
50
|
| `addFormat({ name, extensions, open })` | Read another file type: `open(file)` resolves to `{ song, audio }` |
|
|
46
51
|
| `closeSheets()` | Close Settings and the notation sheet |
|
|
@@ -55,12 +60,17 @@ Keys: <kbd>Space</kbd> play · <kbd>L</kbd> loop · <kbd>O</kbd> open · <kbd>D<
|
|
|
55
60
|
|
|
56
61
|
```sh
|
|
57
62
|
npm ci
|
|
63
|
+
npm start # the demo on http://localhost:4410, rebuilt from src/ on every request
|
|
58
64
|
npm test # node --test
|
|
59
65
|
npm run lint # oxlint: correctness and performance rules
|
|
60
|
-
npm run build # dist/, the published package
|
|
66
|
+
npm run build # dist/, the published package (DEMO=1: with the demo's front door, as github.io serves it)
|
|
61
67
|
npm run bench # frame time, draw calls, sync and size of dist/
|
|
62
68
|
```
|
|
63
69
|
|
|
70
|
+
`src/` is the player's modules, `demo/` the page they ship with, and the demo's front door and tab. The build flattens both
|
|
71
|
+
into `dist/`, which is what npm publishes and what the demo serves — so the page next to the modules, as a page built on the
|
|
72
|
+
player has it. The front door, between `<!-- demo -->` and `<!-- /demo -->` in the page, stays out of the package.
|
|
73
|
+
|
|
64
74
|
No pull request may make the player slower or bigger. CI builds it and the base branch, benchmarks both in turns on the same
|
|
65
75
|
runner, and fails on more than 10% frame or sync time, 5% draw calls or 1% gzipped size. A regression taken on purpose
|
|
66
76
|
passes with the `perf-ok` label.
|
package/highway.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{lap as fe}from"./perf.js";import{noteName as bi}from"./music.js";const Ft=900,yi=84,Yn=28,qn=2.2,Si=.9,ki=2.4,Ti=a=>yi*(a.drawDistance??1)/(Yn*(a.noteSpeed??1)),Pi=.34,Lt=24,an=1.2,Ai=1.25,wi=1.25,Ce=5,sn=1,vi=1.6,Wi=2,ln=.19,Xn=.12,Un=3,$i=11,Ii=[{time:-1/0,endTime:1/0,fret:1,width:4}],jn=[3,5,7,9,12,15,17,19,21,24],Jn=(a,l,h,o,t)=>{const[m,M,d,e]=[Math.min(a,l),Math.max(a,l),Math.min(h,o),Math.max(h,o)],$=Math.min(t,(M-m)/2,(e-d)/2),_=(U,ct,R)=>{const ot=Array.from({length:5},(lt,vt)=>[U+Math.cos(R+vt*Math.PI/8)*$,ct+Math.sin(R+vt*Math.PI/8)*$]);return[ot[0],...ot,ot[4]]};return[..._(M-$,e-$,0),..._(m+$,e-$,Math.PI/2),..._(m+$,d+$,Math.PI),..._(M-$,d+$,1.5*Math.PI)]},Li=a=>[...a,a.at(-1),...a.slice(0,-1).reverse().map(([l,h])=>[l,-h])],Di={inline:{label:"6 in line",outline:[[0,1],[.42,1.05],[.73,1.3],[1.01,1.53],[1.46,1.45],[2.73,1.08],[4.38,.62],[5.79,.17],[6.54,-.13],[6.88,-.35],[7.03,-.88],[6.98,-1.56],[6.64,-2.11],[6.14,-2.38],[5.59,-2.34],[5.21,-2.05],[4.99,-1.66],[4.75,-1.39],[4.25,-1.3],[3.5,-1.39],[2.6,-1.6],[1.85,-1.81],[1.18,-1.75],[.83,-1.36],[.47,-1.06],[0,-1]],posts:{from:[1.56,.95],to:[6.01,-.58]},keys:"machine",tree:2.47},fourTwo:{label:"4 + 2",outline:[[0,1],[.48,1.03],[.94,1.35],[1.21,1.72],[1.52,1.72],[2.99,1.31],[4.23,.95],[5.53,.57],[5.92,.28],[6.07,-.36],[6.05,-1.03],[5.79,-1.53],[5.36,-1.67],[4.95,-1.53],[4.68,-1.29],[4.36,-1.19],[4.02,-1.32],[3.67,-1.56],[2.99,-1.67],[2.08,-1.6],[1.4,-1.43],[.94,-1.16],[.48,-1.03],[0,-1]],posts:{from:[1.81,1.08],to:[4.94,-.03],treble:{share:1/3,from:[2.33,-1.03],to:[3.38,-.69]}},keys:"machine"},openBook:{label:"3 + 3 open book",outline:Li([[0,1],[.48,1.07],[.96,1.33],[1.47,1.53],[3.16,1.67],[4.98,1.76],[6.25,1.8],[6.25,1.8],[6.42,.93],[6.3,0]]),posts:{from:[2.5,1.07],to:[5.1,1.07],treble:{share:1/2}},keys:"tulip",cover:[[.22,0],[.22,.4],[.36,.5],[.78,.4],[1.3,.25],[1.82,.16],[2.13,.1],[2.24,0],[2.13,-.1],[1.82,-.16],[1.3,-.25],[.78,-.4],[.36,-.5],[.22,-.4],[.22,0]],screws:[[.43,0],[1.98,0]]},pointed:{label:"3 + 3 pointed",outline:[[0,1],[.36,1.12],[.75,1.47],[1.07,1.84],[1.38,1.93],[2.29,1.73],[3.26,1.55],[4.36,1.35],[5.45,1.12],[5.75,.95],[5.86,.43],[5.98,-.22],[6.29,-.75],[6.75,-1.22],[6.75,-1.22],[6.17,-1.24],[5.33,-1.3],[4.36,-1.37],[3.26,-1.55],[2.29,-1.73],[1.38,-1.93],[1.07,-1.84],[.75,-1.47],[.36,-1.12],[0,-1]],posts:{from:[2.07,1],to:[4.65,.46],treble:{share:1/2}},keys:"machine",cover:[[.1,.44],[.1,.44],[.59,.4],[1.1,.28],[1.69,0],[1.69,0],[1.1,-.28],[.59,-.4],[.1,-.44],[.1,-.44],[.1,.44]],screws:[]},headless:{label:"Headless",outline:Jn(.2,.95,-1.06,1.06,.2),clamps:.58}};function Ci(a,l){const h=l.length,o=Qn(a.outline,10);let t=l.map(e=>[a.clamps,e]),m=l.map(()=>1);if(a.posts){const{from:e,to:$,treble:_}=a.posts,U=_?Math.floor(h*_.share+1e-9):0,ct=h-U,R=(Q,G,A)=>P=>Q.map((Mt,tt)=>Mt+(G[tt]-Mt)*P/Math.max(1,A-1)),ot=([Q,G])=>[Q,-G],lt=R(e,$,ct),vt=R(_?.from??ot(e),_?.to??ot($),U);t=l.map((Q,G)=>G<ct?lt(G):vt(h-1-G)),m=l.map((Q,G)=>G<ct?1:-1)}const M=(e,$)=>{let _=null;for(let U=1;U<o.length;U++){const[ct,R]=o[U-1],[ot,lt]=o[U];if((ct-e)*(ot-e)>0||ct===ot)continue;const vt=R+(lt-R)*(e-ct)/(ot-ct);(_===null||vt*$>_*$)&&(_=vt)}return _??$},d=a.keys?t.map(([e],$)=>({u:e,side:m[$],edge:M(e,m[$])})):[];return{outline:o,ends:t,keys:d}}const Kn=new WeakMap,ze=new Map,Ri=(a,l)=>{const h=l.join(),o=Kn.get(a);if(o?.key===h)return o.parts;const t=Ci(a,l);return Kn.set(a,{key:h,parts:t}),t},Vn=(a,l)=>(ze.has(a)||(ze.size>500&&ze.clear(),ze.set(a,l())),ze.get(a)),Qn=(a,l=8)=>[...a.slice(0,-1).flatMap((h,o)=>{const t=a[Math.max(0,o-1)],m=a[o+1],M=a[Math.min(a.length-1,o+2)];return h[0]===m[0]&&h[1]===m[1]?[h]:Array.from({length:l},(d,e)=>{const $=e/l;return[0,1].map(_=>.5*(2*h[_]+(m[_]-t[_])*$+(2*t[_]-5*h[_]+4*m[_]-M[_])*$*$+(3*h[_]-t[_]-3*m[_]+M[_])*$**3))})}),a.at(-1)],Wn=(a,l)=>{if(!a.startsWith("#"))return a;const h=o=>{const t=parseInt(a.slice(o,o+2),16);return Math.round(l>0?t+(255-t)*l:t*(1+l)).toString(16).padStart(2,"0")};return`#${h(1)}${h(3)}${h(5)}`},rn=new Map,L=(a,l)=>{if(!a.startsWith("#"))return a;const h=a+l;let o=rn.get(h);return o||(rn.size>1e3&&rn.clear(),rn.set(h,o=`rgba(${parseInt(a.slice(1,3),16)}, ${parseInt(a.slice(3,5),16)}, ${parseInt(a.slice(5,7),16)}, ${l})`)),o},Ge=(a,l)=>{let h=0,o=a.length;for(;h<o;){const t=h+o>>1;a[t].time<l?h=t+1:o=t}return h};function Zn(a){if(a.links?.next.length===a.notes.length)return a.links;const l=a.notes.length,h=new Array(l).fill(-1),o=new Array(l).fill(-1),t={};let m=0;for(let M=0;M<l;M++){const{string:d,sustain:e}=a.notes[M];t[d]!==void 0&&([o[M],h[t[d]]]=[t[d],M]),t[d]=M,m=Math.max(m,e)}return a.links={next:h,prev:o,held:m}}const ce=a=>Math.round(a*4)/4,de=32,hn=new Map;let ti=0;const jt=(a,l,h)=>{let o=hn.get(l);o||hn.set(l,o=new Map);let t=o.get(h);if(!t){++ti>5e3&&([ti,o]=[0,new Map],hn.clear(),hn.set(l,o)),a.font=l;const m=a.measureText(h);o.set(h,t={width:m.width,middle:(m.actualBoundingBoxAscent-m.actualBoundingBoxDescent)/2})}return t},fn=128,$n=new WeakMap,Ei=a=>{if(!$n.has(a)){const l=new OffscreenCanvas(1,fn),h=l.getContext("2d"),[o,t]=[a.floor0,a.floor1].map(M=>[1,3,5].map(d=>parseInt(M.slice(d,d+2),16))),m=Array.from({length:fn},(M,d)=>{const e=(d+.5)/fn;return`rgba(${o.map(($,_)=>Math.round($+(t[_]-$)*e))}, ${1-e})`});m.forEach((M,d)=>{h.fillStyle=M,h.fillRect(0,fn-1-d,1,1)}),$n.set(a,{strip:l,near:m[0]})}return $n.get(a)},Re=new Map,ei=new WeakMap,ni=(a,l,h)=>{let o=ei.get(a);o||ei.set(a,o=new Map);let t=o.get(l);if(!t){t=a.createLinearGradient(0,0,0,1);for(const[m,M]of h)t.addColorStop(m,M);o.set(l,t)}return t},cn=new Map,ii=(a,l,h,o,t)=>{const m=`${l}|${h}|${o}|${t}`;let M=cn.get(m);return M||(cn.size>20&&cn.clear(),M=a.createLinearGradient(0,l,0,h),M.addColorStop(0,o),M.addColorStop(1,t),cn.set(m,M)),M},dn=(a,l)=>[a[0]-l[0],a[1]-l[1],a[2]-l[2]],mn=(a,l)=>a[0]*l[0]+a[1]*l[1]+a[2]*l[2],Oi=(a,l)=>[a[1]*l[2]-a[2]*l[1],a[2]*l[0]-a[0]*l[2],a[0]*l[1]-a[1]*l[0]],Bi=a=>a.map(l=>l/Math.hypot(...a)),gn=(a,l)=>{let h=0,o=a.length;for(;h<o;){const t=h+o>>1;a[t].time<=l?h=t+1:o=t}return a[Math.max(0,h-1)]},oi=a=>a*a*(3-2*a),_i=.3,ai=new WeakMap;function si(a,l){let h=ai.get(a);if(h||ai.set(a,h={}),!(l in h)){const o=Math.max(a.sustain,.05),m=(a[l]??(l==="bendCurve"&&a.bend?[[0,0],[.25,a.bend]]:null))?.map(([M,d])=>[M*o,d,!1])??[];m.length&&m[0][0]>.001&&(m[0][2]=!0,m.unshift([0,0,!1])),h[l]=m.length?m:null}return h[l]}function li(a,l){if(!a)return 0;let h=a[0][1];for(let o=1;o<a.length&&l>a[o-1][0];o++){const[[t,m],[M,d,e]]=[a[o-1],a[o]],$=Math.min(M-t,_i)||1e-6;h=m+(d-m)*oi(Math.min(1,Math.max(0,(l-(e?M-$:t))/$)))}return h}const Hi=(a,l)=>li(si(a,"bendCurve"),l),Fi=(a,l)=>Hi(a,l)+li(si(a,"whammy"),l),ri=new WeakMap,Ee=a=>{let l=ri.get(a);return l===void 0&&ri.set(a,l=Math.max(a.bend||0,...(a.bendCurve??[]).map(([,h])=>h))),l};function Ni(a){if(a.chordSpans)return a.chordSpans;const l=[];for(const h of a.chords){const o=Math.max(h.time+.25,...h.notes.map(m=>a.notes[m].time+a.notes[m].sustain)),t=l.at(-1);t&&h.time-t.end<1&&(h.name?h.name===t.name:h.highDensity)?t.end=Math.max(t.end,o):h.name&&l.push({name:h.name,time:h.time,end:o})}for(const h of a.handShapes??[])h.arpeggio&&h.name&&l.push({name:h.name,time:h.startTime,end:h.endTime});return a.chordSpans=l.sort((h,o)=>h.time-o.time)}function zi(a){if(a.chordRails)return a.chordRails;const l=[],h=o=>Math.max(o.time+.15,...o.notes.map(t=>a.notes[t].time+a.notes[t].sustain));for(let o=0;o<a.chords.length;o++){const t=a.chords[o];if(t.highDensity)continue;let m=h(t),M=o+1;for(;a.chords[M]?.highDensity&&a.chords[M].time-m<1;M++)m=Math.max(m,h(a.chords[M]));m=Math.min(m,a.chords[M]?.time??1/0),m-t.time>.2&&l.push({time:t.time,end:m,frets:t.notes.map(d=>a.notes[d].fret)})}for(const o of a.handShapes??[])o.arpeggio&&l.push({time:o.startTime,end:o.endTime,frets:o.frets,arpeggio:o});return a.chordRails=l}const hi={artificial:"AH",pinch:"PH",tap:"TH",semi:"SH",feedback:"FH"},fi=a=>a<.5?"¼":a===.5?"½":a===1?"full":a%1?`${Math.floor(a)}½`:String(a),ci=(a,l,h,o)=>{if(a===void 0)return l;const t=a+(l-a)*(1-Math.exp(-h/o));return Math.abs(l-t)<1e-6?l:t};function di(a,l,h,o,t){a[l]===void 0&&([a[l],a[l+"Speed"]]=[h,0]);const m=2/o,M=m*t,d=1/(1+M+.48*M*M+.235*M*M*M),e=a[l]-h,$=(a[l+"Speed"]+m*e)*t;a[l+"Speed"]=(a[l+"Speed"]-m*$)*d,a[l]=h+(e+$)*d,Math.abs(a[l]-h)<1e-6&&Math.abs(a[l+"Speed"])<1e-6&&([a[l],a[l+"Speed"]]=[h,0])}function mi(a,l){let h=1/0,o=-1/0;for(const m of a)m.endTime<=l||m.time>=l+Un||(h=Math.min(h,m.fret-1),o=Math.max(o,m.fret-1+m.width));if(h===1/0){const m=gn(a,l);[h,o]=[m.fret-1,m.fret-1+m.width]}const t=Math.max($i,o-h+2)+1;return{lo:h,hi:o,span:t,center:Math.min(25-t/2,Math.max(t/2-1,(h+o)/2))}}function Gi(a,l,h,o){const t=mi(l,h),m=a.target,M=!m||t.lo<m.center-m.span/2||t.hi>m.center+m.span/2,d=m&&m.span-Math.max(t.span,mi(l,h+Un).span)>2;(M||d)&&(a.target=t);const e=Math.min(o-(a.at??o),100);a.at=o,di(a,"span",a.target.span,a.target.span>a.span?.8:1.4,e/1e3),di(a,"center",a.target.center,1,e/1e3);const $=gn(l,h);return a.left=ci(a.left,$.fret-1,e,90),a.right=ci(a.right,$.fret-1+$.width,e,90),$}function gi(a,l,h,o,t,m,M,d){a.beginPath(),a.moveTo(l-o,h-m*t),a.lineTo(l,h),a.lineTo(l+o,h-m*t),a.lineWidth=Math.max(3,t*1.15),a.strokeStyle=d,a.stroke(),a.lineWidth=Math.max(1.5,t*.65),a.strokeStyle=M,a.stroke(),a.lineWidth=Math.max(.6,t*.2),a.strokeStyle="rgba(255, 255, 255, 0.5)",a.stroke()}function Ye(a,l,h,o,t){a.beginPath(),a.moveTo(l,h),a.lineTo(o,t),a.stroke()}function pi(a){const l=devicePixelRatio||1,h=a.clientWidth,o=a.clientHeight;(a.width!==Math.round(h*l)||a.height!==Math.round(o*l))&&(a.width=Math.round(h*l),a.height=Math.round(o*l));const t=a.getContext("2d"),m=o/Ft,M=h/m,d=l*m;return t.setTransform(d,0,0,d,0,0),t.clearRect(0,0,M,Ft),{g:t,W:M,B:d}}function Ki(a,l,h,o,t){const{g:m,W:M,B:d}=pi(a);let e=m;if(!l)return;const $=l.anchors.length?l.anchors:Ii,_=Gi(t,$,h,performance.now()),U=l.strings,ct=Math.min(.5,5*Pi/Math.max(1,U-1)),R=ct*wi*(o.boardHeight??1),ot=R*(U-1),lt=i=>(o.stringOrder==="high"?i:U-1-i)*R,vt=Yn*(o.noteSpeed??1),Q=Ti(o),G=-.22,A=ot+.22,P=G-.06,Mt=Q*vt,tt=i=>Math.max(0,i)*vt,Tt=i=>o.str[i%o.str.length],ge=o.noteLines===0?null:`rgba(255, 255, 255, ${o.noteLines??.5})`,Jt=t.span,rt=[t.center,ct*(U-1)/2,0],Pe=(o.viewAngle??30)*Math.PI/180,Ae=.6*Math.SQRT2*Jt,Be=[rt[0],ot+Ae*Math.sin(Pe),-Ae*Math.cos(Pe)],Kt=Bi(dn([rt[0],0,2.2*Jt],Be)),se=Oi(Kt,[1,0,0]),we=(o.sideAngle??0)*Math.PI/180,[W,K]=[Math.sin(we),Math.cos(we)],j=dn(Be,rt),St=mn(j,Kt),Et=mn(j,se),Wt=[-W,Kt[1]*K,Kt[2]*K],Vt=[K,Kt[1]*W,Kt[2]*W],ve=[rt[0]+Et*se[0]+St*Wt[0],rt[1]+Et*se[1]+St*Wt[1],Et*se[2]+St*Wt[2]],pe=Math.min(M*.88,Ft*(o.fill?1.3:1.05)),ue=pe*mn(dn(rt,ve),Wt)/Jt,pt=Math.min(Ai*(o.fretWidth??1),M*Jt/(pe*Math.max(1,Jt-2.5)));let qe=0,We=0;const[Qt,pn,un]=ve,[Mn,xn,Xe]=Wt,[_e,Me,bn]=Vt,[xe,yn,Ue]=se,D=(i,n,c)=>{const s=i-Qt,r=n-pn,p=c-un,u=ue/Math.max(.05,s*Mn+r*xn+p*Xe);return[M/2+(s*_e+r*Me+p*bn)*pt*u+qe,Ft/2-(s*xe+r*yn+p*Ue)*u+We,u]},[je,Je,xt]=D(...rt);[qe,We]=[M/2-je,Ft*(o.fill?.83:.81)-Je];const[,Ke]=D(t.center-Jt/2,P,0),[,Ve]=D(t.center+Jt/2,P,0),[,x]=D(t.center,P,0);We-=Math.min(Ft*.08,Math.max(0,Ke-x,Ve-x)),fe("setup");const f=(i,n=!0)=>{e.beginPath();for(let c=0;c<i.length;c++){const[s,r]=D(i[c][0],i[c][1],i[c][2]);c?e.lineTo(s,r):e.moveTo(s,r)}n&&e.closePath()},S=(i,n)=>{f([i,n],!1),N()},nt=(i,n,c,s,r)=>{if(o.gem!=="pill")return f([[i-s,n-r,c],[i+s,n-r,c],[i+s,n+r,c],[i-s,n+r,c]]);const[p,u]=D(i-s,n,c),[v,b]=D(i+s,n,c),[,k]=D(i,n+r,c),[,J]=D(i,n-r,c),H=Math.atan2(b-u,v-p),F=Math.min(Math.abs(J-k),Math.hypot(v-p,b-u))/2,[I,B]=[F*Math.cos(H),F*Math.sin(H)];e.beginPath(),e.arc(p+I,u+B,F,H+Math.PI/2,H+Math.PI*1.5),e.arc(v-I,b-B,F,H-Math.PI/2,H+Math.PI/2),e.closePath()},Y=(i,n)=>{const c=gn($,n),s=i.filter(r=>r>0);return[Math.min(c.fret-1,...s.map(r=>r-1))+.05,Math.max(c.fret-1+Math.max(4,c.width),...s)-.05]},et=(i,n,c,s,r)=>{S([i-s,n-r,c],[i+s,n+r,c]),S([i-s,n+r,c],[i+s,n-r,c])},Ot=o.markings==="white",ht=Ot?"#ffffff":o.ink,be=(i,n,c,s,r,p,u,v=null)=>{const[b,k]=u?[r*.85,p*.8]:[Math.min(r,.34)*.4,p*.55],J=u&&!Ot&&!v;v||(e.strokeStyle=L(o.ink,J?.85:.7),e.lineWidth=J?Math.max(2,.06*s):Math.max(3.5,.1*s),et(i,n,c,b,k)),!J&&(e.strokeStyle=v??"#ffffff",e.lineWidth=Math.max(v?2:1.8,.05*s),et(i,n,c,b,k))};let ee=null,Pt=0;const $e=i=>{i!==ee&&(e.font=ee=i)},Ie={},ne=(i,n,c,s,r,p)=>{const u=Ie[r]??=`${r} ${de}px ${o.num}`,v=s/de;return jt(e,u,i),$e(u),e.textAlign=p,e.setTransform(d*v,0,0,d*v,d*n,d*(c-Pt)),jt(e,u,i).middle},qt=()=>e.setTransform(d,0,0,d,0,-d*Pt),ye=(i,n,c)=>{e.fillStyle=i,e.setTransform(d,0,0,d*(c-n),0,d*(n-Pt)),e.fill(),qt()},Dt=(i,n,c,s,r,p,u=700,v="center",b=!0,k=!1)=>{const[J,H,F]=D(n,c,s),I=r*(k?F:Math.sqrt(F*xt));if(I<(k?1:8)||J<-60||J>M+60)return;e.textBaseline="alphabetic";const B=ne(i,J,H,I,u,v);b&&(e.lineWidth=de*.2,e.strokeStyle=L(o.ink,.9),e.strokeText(i,0,B)),e.fillStyle=p,e.fillText(i,0,B),qt(),e.textBaseline="middle"},[,ie]=D(rt[0],P,0),[,Se]=D(rt[0],P,Mt),gt=(i,n,c)=>{const s=`${ie}|${Se}`;(Re.span!==s||Re.size>300)&&(Re.clear(),Re.span=s);const r=`${i}|${n}|${c}`;let p=Re.get(r);return p||(p=e.createLinearGradient(0,ie,0,Se),p.addColorStop(0,L(i,n)),p.addColorStop(1,L(i,c)),Re.set(r,p)),p};let $t=null;const E=(i,n,c=10,s=!1)=>$t=i?{color:n,blur:c,faded:s}:null,Sn=[[.6,.05],[.35,.13],[.15,.27]],He=[[.4,.3]],Le=i=>{if(!$t)return;const{lineWidth:n,globalAlpha:c}=e,s=i?1:Math.min(1,2*n/$t.blur);e.save(),e.strokeStyle=$t.faded?gt($t.color,1,.1):$t.color;for(const[r,p]of $t.blur>4?Sn:He)e.lineWidth=(i?0:n)+2*$t.blur*r,e.globalAlpha=c*p*s,e.stroke();e.restore()},N=()=>{Le(!1),e.stroke()},at=()=>{Le(!0),e.fill()};e.textBaseline="middle",e.lineCap="round",e.lineJoin="round";const{strip:le,near:re}=Ei(o);let[Zt,bt]=[-60,Lt+60];if(we){const i=rt[0]+(1-mn(dn([rt[0],P,0],ve),Wt))/Wt[0];[Zt,bt]=Wt[0]>0?[Math.max(-60,i),Lt+60]:[-60,Math.min(Lt+60,i)]}e.save(),f([[Zt,P,0],[bt,P,0],[bt,P,Mt],[Zt,P,Mt]]),e.clip(),we&&(e.fillStyle=re,e.fillRect(0,ie,M,Ft-ie)),e.imageSmoothingEnabled=!1,e.drawImage(le,0,Se,M,ie-Se),e.restore();const Xt=(i,n)=>{const[c,s]=D(...i),[r,p]=D(...n);e.moveTo(c,s),e.lineTo(r,p)};e.strokeStyle=gt(o.lane,.5,.04),e.lineWidth=Si,e.beginPath();for(let i=0;i<=Lt;i++)Xt([i,P,0],[i,P,Mt]);N();for(const i of[!1,!0]){e.strokeStyle=i?o.measure:o.beat,e.lineWidth=i?1.6:1,e.beginPath();for(let n=Ge(l.beats,h);n<l.beats.length;n++){const c=l.beats[n],s=c.time-h;if(s>Q)break;c.measure>=0===i&&Xt([0,P,tt(s)],[Lt,P,tt(s)])}N()}(o.guides===!1?[]:$.filter(i=>i.endTime>h&&i.time<h+Q)).forEach((i,n)=>{const c=tt(Math.max(0,i.time-h)),s=tt(Math.min(Q,i.endTime-h)),r=i.fret-1,p=r+i.width;e.fillStyle=gt(o.anchorFill,o.anchorOpacity,.02),f([[r,P,c],[p,P,c],[p,P,s],[r,P,s]]),at(),e.strokeStyle=gt(o.anchorLane,.55,.04),e.lineWidth=ki*.6;for(const u of[r,p])S([u,P,c],[u,P,s]);n&&i.time>h&&S([r,P,c],[p,P,c]),n&&i.time>h+.3&&Dt(String(i.fret),r-.2,P,c,.3,o.anchorLane,700,"right")});const dt=new Map,ft=i=>{const n=Math.round(i*100);return dt.has(n)||dt.set(n,{dt:i-h,texts:[],pins:[]}),dt.get(n)};for(const i of l.markers??[])i.time>=h&&i.time<=h+Q&&!ft(i.time).texts.includes(i.text)&&ft(i.time).texts.push(i.text);for(const i of l.hairpins??[])i.time>=h&&i.time<=h+Q&&ft(i.time).pins.push(i.kind);const At=Math.min(t.center-(t.span/2+.5)/pt,-.5);for(const{dt:i,texts:n,pins:c}of dt.values()){const[s,r,p]=D(At,P,tt(i)),u=Math.sqrt(p*xt),v=n.join(" · "),b=.25*u,k=`700 ${de}px ${o.num}`,J=.3*u/de,H=v?jt(e,k,v).width*J:0,F=H+c.length*(.9*u+b);$e(k);let I=Math.max(s-.3*u,16+F);e.globalAlpha=Math.min(1,(Q-i)/.4),v&&(e.save(),e.translate(I,r),e.scale(J,J),e.textAlign="right",e.lineWidth=de*.2,e.strokeStyle=L(o.ink,.9),e.strokeText(v,0,0),e.fillStyle=o.accent,e.fillText(v,0,0),e.restore(),I-=H+b);for(const B of c){const yt=I-.9*u,ut=.14*u,[X,st]=B==="cresc"?[yt,I]:[I,yt];for(const[y,It]of[[L(o.ink,.9),Math.max(3.5,.12*u)],[o.text,Math.max(1.5,.05*u)]])e.strokeStyle=y,e.lineWidth=It,e.beginPath(),e.moveTo(st,r-ut),e.lineTo(X,r),e.lineTo(st,r+ut),N();I=yt-b}}e.globalAlpha=1,fe("floor");const mt=[];for(let i=Ge(l.notes,h-Zn(l).held-.3);i<l.notes.length;i++){const n=l.notes[i];if(n.time>h+Q)break;const c=Math.max(n.sustain,(n.slideTo??n.slideUnpitchTo??null)===null?0:.25,.15);n.time+c>=h-.05&&mt.push(n)}const Ut=i=>i.chord===null||i.chord===void 0?null:l.chords[i.chord],te=i=>o.repeatMarks==="frame"&&(i.repeat||Ut(i)?.highDensity),he=i=>{const n=gn($,i.time),c=i.fret===0;return{a:n,open:c,x:c?n.fret-1+n.width/2:i.fret-.5,y:lt(i.string)}},Qe=(i,n,c)=>{const s=i.slideTo??i.slideUnpitchTo??null,r=Math.min(1,Math.max(0,c/Math.max(i.sustain,.25)));return s===null||i.fret===0?n:n+(s-.5-n)*r*r*(3-2*r)},In=(i,n)=>Fi(i,n)*R*sn,Ln=i=>{const n=h-i.time;return n<0||i.fret===0||!(Ee(i)>0)?0:In(i,Math.min(n,Math.max(i.sustain,.15)))},Ze=new Map;for(const i of mt){const n=i.time-h,c=Math.max(i.sustain,.15);n>0||-n>c||i.fret===0||!(Ee(i)>0)||Ze.set(i.string,{note:i,x:i.fret-.5,dy:Ln(i)})}const kn=(i,n=0,c=!1)=>{const s=Ze.get(i),r=lt(i)+n,p=c?[[0,r,0]]:[en?[en[i][0],en[i][1]+n,0]:[-.6,r,0],[0,r,0]];if(!s)return f([...p,[Lt+.6,r,0]],!1);f([...p,[s.x,r+s.dy,0],[Lt+.6,r,0]],!1)},tn=i=>lt(i.string)+Ln(i),Nt=Di[o.headstock],ke=(A-G)/2,Tn=o.stringOrder==="high"?-1:1,oe=([i,n])=>[-i*ke/pt,ot/2+n*ke*Tn,0],Pn=i=>(lt(i)-ot/2)*Tn/ke,zt=Nt&&Ri(Nt,Array.from({length:U},(i,n)=>Pn(n))),en=zt?.ends.map(oe),kt=(i,n,c=1)=>{i&&(e.fillStyle=i,at()),n&&(e.strokeStyle=n,e.lineWidth=c,N())},Te=(i,n,c)=>{const[s,r]=oe(i),[p,u]=D(s,r,0),[v]=D(s+n*ke/pt,r,0),[,b]=D(s,r+c*ke,0);e.beginPath(),e.ellipse(p,u,Math.abs(v-p),Math.abs(b-u),0,0,Math.PI*2)},De=(i,n,c,s,r)=>f(Vn(`${i},${n},${c},${s},${r}`,()=>Jn(i,n,c,s,r)).map(oe)),Dn=()=>{for(const{u:c,side:s,edge:r}of zt.keys){const p=(u,v)=>[r+s*u,r+s*v];Nt.keys==="machine"?(De(c-.15,c+.15,...p(-.12,.08),.03),kt(L(o.text,.12),L(o.anchorLane,.35)),De(c-.03,c+.03,...p(.06,.22),0),kt(L(o.text,.28)),De(c-.11,c+.11,...p(.2,.68),.1),kt(L(o.text,.18),L(o.anchorLane,.55))):(De(c-.035,c+.035,...p(-.05,.22),0),kt(L(o.text,.28)),Te([c,r+s*.18],.08,.04),kt(L(o.text,.3)),Te([c,r+s*.4],.14,.2),kt(L(o.text,.18),L(o.anchorLane,.55)))}f(zt.outline.map(oe));const[,i]=D(...oe([0,1.6])),[,n]=D(...oe([0,-1.2]));if(kt(ii(e,i,n,o.floor0,o.ink)),e.save(),e.clip(),kt(null,L(o.text,.07),.3*ke*xt),e.restore(),E(!0,o.anchorLane,8),kt(null,L(o.anchorLane,.6),Math.max(1.5,.03*xt)),E(!1),Nt.cover){f(Vn(Nt.cover,()=>Qn(Nt.cover)).map(oe)),kt(L(o.text,.09),L(o.text,.4));for(const c of Nt.screws)Te(c,.04,.04),kt(L(o.nut,.85))}},Cn=i=>qn*(.7+.14*(U-1-i)),Mi=()=>{if(t.plate?.key!==An||t.plate.t!==o)return t.plate={key:An,t:o},Dn();const i=t.plate;if(!i.image){const[n,c]=[[],[]];for(const J of[...zt.outline,...zt.keys.map(({u:H,side:F,edge:I})=>[H,I+F*.8])]){const[H,F]=D(...oe(J));n.push(H),c.push(F)}const s=Math.floor(Math.max(0,Math.min(...n)-24)*d)/d,r=Math.min(M,Math.max(...n)+24),p=Math.floor(Math.max(0,Math.min(...c)-24)*d)/d,u=Math.min(Ft,Math.max(...c)+24);i.image=new OffscreenCanvas(Math.max(1,Math.ceil((r-s)*d)),Math.max(1,Math.ceil((u-p)*d)));const[v,b,k]=[e,Pt,ee];[e,Pt,ee,i.x,i.y]=[i.image.getContext("2d"),0,null,s,p],e.setTransform(d,0,0,d,-s*d,-p*d),e.lineCap=e.lineJoin="round",Dn(),[e,Pt,ee]=[v,b,k]}e.drawImage(i.image,i.x,i.y,i.image.width/d,i.image.height/d)},Rn=()=>{e.fillStyle=o.board,f([[0,G,0],[Lt+.6,G,0],[Lt+.6,A,0],[0,A,0]]),at(),e.fillStyle=L(o.anchorFill,.16),f([[t.left,G,0],[t.right,G,0],[t.right,A,0],[t.left,A,0]]),at(),e.fillStyle=o.inlayDot;const i=s=>(Math.max(0,Math.ceil(s)-1)+.5)*R;e.beginPath();for(const s of jn)for(const r of s%12?[i((U-1)/2)]:[i((U-1)/4),ot-i((U-1)/4)]){const[p,u,v]=D(s-.5,r,0);e.moveTo(p+.1*v,u),e.ellipse(p,u,.1*v,.08*v,0,0,Math.PI*2)}at(),zt&&Mi();const[,n]=D(rt[0],A,0),[,c]=D(rt[0],G,0);e.strokeStyle=ii(e,n,c,L(o.anchorPost,.75),o.post),e.lineWidth=Math.max(1.5,.05*xt),e.beginPath();for(let s=1;s<=Lt;s++)Xt([s,G-.04,0],[s,A+.04,0]);N(),e.strokeStyle=o.nut,e.lineWidth=Math.max(3,.12*xt),S([0,G-.06,0],[0,A+.06,0]),E(!0,o.anchorPost,12),e.strokeStyle=o.anchorPost,e.lineWidth=Math.max(3,.07*xt);for(const s of[t.left,t.right])S([s,G-.14,0],[s,A+.14,0]);E(!1);for(let s=0;s<U;s++){const r=Cn(s);E(!0,Tt(s),3),e.strokeStyle=L(Tt(s),.9),e.lineWidth=r,kn(s),N(),E(!1),e.strokeStyle="rgba(255, 255, 255, 0.25)",e.lineWidth=Math.max(.6,r*.3),kn(s,.012),N()}if(zt&&(zt.ends.forEach(([s,r],p)=>{if(Nt.clamps)De(s-.1,s+.1,r-.1,r+.1,.04),kt(L(o.text,.22),L(o.text,.45)),Te([s,r],.05,.05),kt(o.nut);else{Te([s,r],.17,.17),kt(L(o.ink,.5),L(o.nut,.4)),Te([s,r],.085,.085),kt(o.nut),Te([s,r],.03,.03),kt(L(o.ink,.85));const[u,v,b]=D(...en[p]),[k,J]=D(0,lt(p),0),H=Math.atan2(J-v,k-u);e.beginPath(),e.arc(u,v,.1*ke*b,H-1.3,H+1.3),kt(null,Tt(p),Cn(p))}}),Nt.tree)){const s=[U-2,U-1].map(r=>{const[p,u]=zt.ends[r];return Pn(r)+(u-Pn(r))*Nt.tree/p});De(Nt.tree-.05,Nt.tree+.05,Math.min(...s)-.08,Math.max(...s)+.08,.04),kt(L(o.nut,.7),L(o.ink,.6))}for(const s of[!1,!0])for(let r=1;r<=Lt;r++){const p=r>=_.fret&&r<_.fret+_.width,u=jn.includes(r);(p||u)===s&&Dt(String(r),r-.5,G-.3,0,p?.3:u?.26:.2,p?o.accent:u?o.inlay:o.numOff,s?800:500,"center",!1)}},Fe=(i,n)=>D(i,n,0).slice(0,2).map(c=>Math.round(c*d*10)).join(":"),An=[o.headstock,U,R,Tn,M,d,Math.round(pt*1e4),Fe(0,G),Fe(Lt,G),Fe(0,A),Fe(Lt,A),Fe(-4,ot/2)].join(),nn=!Ze.size&&[An,_.fret,_.width,Math.round(t.left*1e3),Math.round(t.right*1e3)].join();if(!nn||t.board?.key!==nn||t.board.t!==o)t.board=nn&&{key:nn,t:o},Rn();else{const i=t.board;if(!i.drawn){const n=[[0,A+.2],[Lt,A+.2],[0,G-.9],[Lt,G-.9]].map(([u,v])=>D(u,v,0)[1]);zt&&n.push(...[...zt.outline,...zt.keys.map(({u,side:v,edge:b})=>[u,b+v*.8])].map(u=>D(...oe(u))[1]));const c=Math.floor(Math.max(0,Math.min(...n)-24)*d)/d,s=Math.min(Ft,Math.max(...n)+24),[r,p]=[Math.ceil(M*d),Math.max(1,Math.ceil((s-c)*d))];(t.boardImage?.width!==r||t.boardImage.height!==p)&&(t.boardImage=new OffscreenCanvas(r,p)),[e,Pt,ee,i.y,i.drawn]=[t.boardImage.getContext("2d"),c,null,c,!0],e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,r,p),qt(),e.lineCap=e.lineJoin="round",e.textBaseline="middle",Rn(),[e,Pt,ee]=[m,0,null]}e.drawImage(t.boardImage,0,i.y,t.boardImage.width/d,t.boardImage.height/d)}fe("board");const En=(i,n)=>i.letRing&&-n>.25;for(const i of mt){const n=i.time-h;if(n>0||-n>Math.max(i.sustain,.15)||i.mute)continue;const c=Tt(i.string),s=tn(i);if(E(!En(i,n),c,10),e.strokeStyle=c,e.lineWidth=qn+3,kn(i.string,0,!0),N(),E(!1),-n<.2){const[r,p,u]=D(he(i).x,s,0);e.save(),e.translate(r,p),e.scale(1,.4);const v=e.createRadialGradient(0,0,0,0,0,.5*u);v.addColorStop(0,L(o.flash,.8*(1+n/.2))),v.addColorStop(1,L(o.flash,0)),e.fillStyle=v,e.beginPath(),e.arc(0,0,.5*u,0,Math.PI*2),at(),e.restore()}}e.strokeStyle=o.anchorLane,e.lineWidth=2.5,E(!0,o.anchorLane,10);for(const i of l.handShapes??[]){if(i.startTime>h||i.endTime<=h||i.endTime-i.startTime<.3||!i.frets.some((s,r)=>s>=0&&r<U))continue;const[n,c]=Y(i.frets.filter((s,r)=>r<U),i.startTime);f([[n,G,0],[c,G,0],[c,A,0],[n,A,0]]),N()}E(!1),fe("strings");for(const i of mt){const n=i.time-h,c=tt(n),s=Ut(i),{a:r,open:p,x:u,y:v}=he(i),b=Qe(i,u,-n);if(n<-.15||Math.abs(D(b,v,c)[0]-M/2)>M/2+200)continue;const k=p?(r.width-.2)/2:.34;e.globalAlpha=n<0?Math.max(0,1+n/.15):Math.min(1,(Q-n)/.4),!s&&ge&&(e.strokeStyle=ge,e.lineWidth=2,S([b-k,P,c],[b+k,P,c])),!(p||te(i))&&(e.strokeStyle=L(Tt(i.string),i.repeat||s?.highDensity?.35:.75),e.lineWidth=1.5,S([b,Math.min(v,tn(i))-.42*R,c],[b,P,c]))}e.globalAlpha=1;const On=(i,n,c)=>{const s=Array.from({length:13},(r,p)=>{const u=p/12;return[i[0]+(n[0]-i[0])*u,i[1]+(n[1]-i[1])*u+Math.sin(Math.PI*u)*c,i[2]+(n[2]-i[2])*u]});f(s,!1),N()};for(const i of zi(l)){if(i.end<=h||i.time>=h+Q)continue;const[n,c]=Y(i.frets,i.time),s=i.time-h,r=tt(Math.max(s,0)),p=tt(Math.min(i.end-h,Q));e.globalAlpha=Math.min(1,(Q-Math.max(s,0))/.4),E(!i.arpeggio,o.anchorLane,10,!0),e.strokeStyle=gt(o.anchorLane,1,.2),e.lineWidth=3.5;for(const u of[n,c])S([u,P,r],[u,P,p]);E(!1),i.arpeggio&&s>0&&(e.strokeStyle=L(o.anchorLane,.7),e.lineWidth=1.5,f([[n,P,r],[n,A,r],[c,A,r],[c,P,r]],!1),N(),i.arpeggio.name&&r>Ce&&Dt(i.arpeggio.name,n-.12,A/2,r,.34,o.text,600,"right"))}e.globalAlpha=1;const wn=(i,n)=>{const c=he(i);return Math.abs(c.x-n)<(c.open?(c.a.width-.2)/2+.1:.45)};for(const[i,n]of mt.entries()){const c=n.time-h,s=Ut(n),r=n.slideTo??n.slideUnpitchTo??null,{a:p,open:u,x:v,y:b}=he(n),k=Tt(n.string),J=tt(c),H=(u?(p.width-.2)/2:.34)*(n.grace?.6:1),F=(u?.12:.42)*R*(n.grace?.6:1);if(c>-.15&&!s?.highDensity&&!n.repeat){if(e.globalAlpha=Math.min(1,(Q-c)/.4),e.strokeStyle=k,e.lineWidth=2,e.setLineDash([4,4]),n.slideIn&&S([v+(n.slideIn==="below"?-1.4:1.4),b-F,Math.max(0,J-1)],[v+(n.slideIn==="below"?-H:H),b,J]),n.slideOut&&S([v+(n.slideOut==="up"?H:-H),b,J],[v+(n.slideOut==="up"?1.4:-1.4),b-F,J+1]),e.setLineDash([]),typeof n.tieTo=="number"){const C=l.notes[n.tieTo],z=he(C);e.setLineDash([5,4]),On([v,b+F,J],[z.x,z.y+F,tt(C.time-h)],R*.9),e.setLineDash([])}e.globalAlpha=1}const I=r===null?n.sustain:Math.max(n.sustain,.25),B=r!==null||n.bend||n.bendCurve||n.whammy;if(I<=.2||c+I<=0||s&&!B||te(n))continue;u&&r&&(e.strokeStyle=k,e.lineWidth=2.5,e.setLineDash(n.letRing?[7,6]:[]),On([v,b,tt(Math.max(c,0))],[r-.5,b,tt(Math.min(c+I,Q))],R*1.5),e.setLineDash([]));let yt=null;for(let C=i+1;C<mt.length&&mt[C].time<=n.time+I+.02;C++){const z=mt[C];if(!(z.time<=n.time+.005)&&(Ut(z)||z.string===n.string||wn(z,v))){yt=z;break}}const ut=Math.max(c,0),X=n.bend||n.bendCurve||n.whammy;let st=Math.min(c+I,Q,yt?yt.time-h:1/0);if(st<=ut)continue;const y=C=>{const z=C-c,g=tt(C),T=n.bend||n.bendCurve||n.whammy,w=n.vibrato&&!T?Math.sin(g/1.6*Math.PI*2)*R*(n.vibratoWide?.45:.25):0,it=n.tremolo?Math.floor(g/.3)%2?.05:-.05:0,q=sn+(vi-sn)*oi(Math.min(1,g/Wi));return[Qe(n,v,z)+it,b+w+In(n,z)*q/sn,g]},It=yt&&y(st)[0],Ct=yt&&Ut(yt)?.notes.find(C=>wn(l.notes[C],It)),Z=typeof Ct=="number"?l.notes[Ct]:yt;if(yt&&(X||wn(Z,It))){const C=he(Z),z=tt(Z.time-h),g=C.open?(C.a.width-.2)/2:.34,T=D(C.x,C.y-(C.open?.12:.42)*R,z)[1]+3,[w]=D(C.x-g,C.y,z),[it]=D(C.x+g,C.y,z),q=wt=>{const[Yt,V]=D(...y(wt));return V<T&&Yt>Math.min(w,it)-2&&Yt<Math.max(w,it)+2};if(q(st)&&!q(ut)){let wt=ut,Yt=st;for(let V=0;V<24;V++)[wt,Yt]=q((wt+Yt)/2)?[wt,(wt+Yt)/2]:[(wt+Yt)/2,Yt];st=wt}if(st<=ut+.001)continue}const Bt=r===null&&!X&&!n.vibrato&&!n.tremolo?1:Math.min(400,Math.max(12,Math.ceil((st-ut)*vt*8))),Gt=Array.from({length:Bt+1},(C,z)=>y(ut+(st-ut)*z/Bt));if(u&&!s){e.fillStyle=gt(k,n.letRing?.14:.26,.03),f([...Gt.map(([C,z,g])=>[C-H,z,g]),...Gt.slice().reverse().map(([C,z,g])=>[C+H,z,g])]),at(),E(!n.letRing,k,6,!0),e.strokeStyle=gt(k,.95,.3),e.lineWidth=2.5,e.setLineDash(n.letRing?[7,6]:[]);for(const C of[-H,H])f(Gt.map(([z,g,T])=>[z+C,g,T]),!1),N();e.setLineDash([]),E(!1)}else if(n.bend||n.bendCurve||n.whammy){const C=z=>f([...Gt.map(([g,T,w])=>[g-z,T,w]),...Gt.slice().reverse().map(([g,T,w])=>[g+z,T,w])]);C(ln),e.fillStyle=gt(k,1,.6),at(),C(ln*.35),e.fillStyle=gt(Wn(k,-.22),1,.55),at(),E(!0,k,8,!0),e.strokeStyle=gt(Wn(k,.6),1,.5),e.lineWidth=2;for(const z of[-ln,ln])f(Gt.map(([g,T,w])=>[g+z,T,w]),!1),N();E(!1)}else E(!n.letRing,k,6,!0),e.fillStyle=gt(k,n.letRing?.4:.75,n.letRing?.15:.3),f([...Gt.map(([C,z,g])=>[C-.09,z,g]),...Gt.slice().reverse().map(([C,z,g])=>[C+.09,z,g])]),at(),E(!1);if((n.letRing||r!==null||!X&&(n.vibrato||n.tremolo))&&(e.strokeStyle=gt(n.letRing?k:"#ffffff",.75,.3),e.lineWidth=n.letRing?2:1.5,e.setLineDash(n.letRing?[7,6]:[]),f(Gt,!1),N(),e.setLineDash([])),r!==null&&st>=Math.min(c+I,Q)-.001){const[C,z,g]=y(c+I);e.strokeStyle=k,e.lineWidth=2,e.setLineDash(n.slideTo===null?[5,4]:[]),u?nt(r-.5,z,g,.34,.42*R):nt(C,z,g,H,F),N(),e.setLineDash([])}}fe("trails");const Bn=new Set;for(let i=mt.length-1;i>=0;i--){const n=mt[i],c=n.time-h,s=tt(c),r=Ut(n),{a:p,open:u,x:v}=he(n),b=Qe(n,v,-c),k=tn(n),J=n.mute||r?.fretHandMute,H=n.palmMute||r?.palmMute,F=Tt(n.string),I=(u?(p.width-.2)/2:.34)*(n.grace?.6:1),B=(u?.12:.42)*R*(n.grace?.6:1),yt=n.slideTo??n.slideUnpitchTo??null;if(c<-.15)continue;const ut=c<0?Math.max(0,1+c/.15):Math.min(1,(Q-c)/.4);if(e.globalAlpha=ut,r&&!Bn.has(n.chord)){Bn.add(n.chord);const[g,T]=Y(r.notes.map(V=>l.notes[V].fret),n.time),w=e.globalAlpha,it=s<Ce,q=it?.65:r.highDensity&&o.repeatMarks!=="frame"?.18:.5;if(f([[g,P,s],[T,P,s],[T,A,s],[g,A,s]]),o.frames==="gradient"){const[,V]=D(g,P,s),[,_t]=D(g,A,s),Rt=it?o.anchorLane:o.anchorFill;ye(ni(e,`${Rt}|${q}`,[[0,L(Rt,q*.6)],[1,L(Rt,0)]]),V,_t)}else e.globalAlpha=w*q,r.highDensity||(e.fillStyle=o.chordFill,at()),e.strokeStyle=it?o.anchorLane:o.chordBox,e.lineWidth=it||!r.highDensity?1.5:1.2,E(it,o.anchorLane,8),N(),E(!1);if(e.globalAlpha=w,e.strokeStyle=ge,e.lineWidth=2,ge&&S([g,P,s],[T,P,s]),r.highDensity&&(r.palmMute||r.fretHandMute)&&(e.strokeStyle=r.palmMute?o.muted:"#ffffff",et((g+T)/2,P+R*.4,s,r.palmMute?.22:.12,R*(r.palmMute?.35:.22))),r.accent){const V=Math.min(.6,(T-g)*.22),_t=(A-P)*.35,Rt=Math.min(1,D(g,A,s)[2]/D(g,A,Ce)[2]);e.strokeStyle="#ffffff",e.lineWidth=Math.max(1,3.5*Rt*(r.accent==="heavy"?1.4:1)),e.lineCap="square",E(!0,"#ffffff",Math.max(2,12*Rt)),f([[g,A-_t,s],[g,A,s],[g+V,A,s]],!1),N(),f([[T-V,A,s],[T,A,s],[T,A-_t,s]],!1),N(),E(!1),e.lineCap="round"}if(r.barre&&(!r.highDensity||o.repeatMarks==="grey")){const V=r.barre.fret-.5;e.strokeStyle=r.highDensity?o.muted:"rgba(255, 255, 255, 0.7)",e.lineWidth=Math.max(3,.1*D(V,ot/2,s)[2]);const[_t,Rt]=[lt(r.barre.from),lt(r.barre.to)].sort((ae,Ht)=>ae-Ht);S([V,_t-R*.4,s],[V,Rt+R*.4,s]),Dt(r.barre.half?"½B":"B",V,A+.12,s,.22,r.highDensity?o.muted:o.text)}if(r.strum||r.roll){const V=g-.25,_t=lt(0)>lt(U-1)?A-.1:P+.15,Rt=_t>ot/2?P+.15:A-.1,[ae,Ht]=(r.strum??r.roll)==="down"?[_t,Rt]:[Rt,_t];e.strokeStyle=o.text,e.lineWidth=2,r.roll?f(Array.from({length:17},(Ui,Gn)=>[V+Math.sin(Gn/16*Math.PI*6)*.06,ae+(Ht-ae)*Gn/16,s]),!1):f([[V,ae,s],[V,Ht,s]],!1),N();const zn=Ht<ae?.14:-.14;S([V-.08,Ht+zn,s],[V,Ht,s]),S([V+.08,Ht+zn,s],[V,Ht,s])}const wt=l.chords[n.chord-1],Yt=!wt||n.time-wt.time>1||wt.name!==r.name;s>Ce&&r.name&&!r.highDensity&&Yt&&Dt(r.name,g-.12,A/2,s,.34,o.text,600,"right")}const[X,st,y]=D(b,k,s);if(X<-200||X>M+200||te(n)){e.globalAlpha=1;continue}const It=n.repeat||r?.highDensity;if(It){const g=s<Ce;e.globalAlpha*=g?.9:.4,e.strokeStyle=F,e.lineWidth=g?2:1.5,E(g,F,8),nt(b,k,s,I,B),N(),E(!1),(J||H)&&o.repeatMarks!=="hide"&&be(b,k,s,y,u?.34:I,u?R*.3:B,H,o.muted),e.globalAlpha=ut}else{if(!u&&s>1.75&&o.fretNumbers){const g=n.harmonic||n.harmonicPinch?`<${n.fret}>`:n.ghost?`(${n.fret})`:String(n.fret);Dt(g,b,P,s-.55,n.grace?.18:.26,F)}if(n.dynamicLabel&&Dt(n.dynamicLabel,b-.6,P,s,.3,o.text,"italic 700","right"),n.ghost&&(e.globalAlpha=ut*.5),o.gem==="pill")o.notes3d!==!1&&(nt(b,k,s+Xn,I,B),e.fillStyle=F,at(),e.fillStyle="rgba(255, 255, 255, 0.35)",at()),nt(b,k,s,I,B),e.fillStyle=F,at();else{const g=n.harmonic||n.harmonicPinch,T=Xn;if(!g&&o.notes3d!==!1)for(const[q,wt]of[[[[b-I,k+B,s],[b+I,k+B,s],[b+I,k+B,s+T],[b-I,k+B,s+T]],"rgba(255, 255, 255, 0.35)"],[[[b-I,k-B,s],[b-I,k+B,s],[b-I,k+B,s+T],[b-I,k-B,s+T]],"rgba(0, 0, 0, 0.4)"],[[[b+I,k-B,s],[b+I,k+B,s],[b+I,k+B,s+T],[b+I,k-B,s+T]],"rgba(0, 0, 0, 0.4)"]])f(q),e.fillStyle=F,at(),e.fillStyle=wt,at();E(s<Ce,F,8),e.fillStyle=F,g?f([[b,k+B*1.3,s],[b+I*.8,k,s],[b,k-B*1.3,s],[b-I*.8,k,s]]):nt(b,k,s,I,B),at(),E(!1);const[,w]=D(b,k+B,s),[,it]=D(b,k-B,s);ye(ni(e,"shine",[[0,"rgba(255, 255, 255, 0.45)"],[.5,"rgba(255, 255, 255, 0)"],[1,"rgba(0, 0, 0, 0.25)"]]),w,it),e.strokeStyle="rgba(255, 255, 255, 0.6)",e.lineWidth=1,N()}if((J||H)&&be(b,k,s,y,u?.34:I,u?R*.3:B,H,u&&H?F:null),!u&&!J&&!H){const g=n.finger??(r?.fingers?.[n.string]>=0?r.fingers[n.string]:null),T=g!==null?g===0?"T":String(g):"";if(T){const w=e.globalAlpha;e.globalAlpha=w*Math.min(1,Math.max(0,(1-c/Q)/.4)),Dt(T,b,k,s-.01,R*.62,ht,700,"center",Ot,!0),e.globalAlpha=w}}}if(It&&o.repeatMarks==="hide"){e.globalAlpha=1;continue}const Ct=It?o.muted:o.text;if(e.globalAlpha=ut*(It?.8:1)*Math.min(1,Math.max(0,(1-c/Q)/.15)),n.ghost){const[g]=D(b-I,k,s),[T]=D(b+I,k,s),w=B*y*1.5;e.strokeStyle=It?Ct:F,e.lineWidth=Math.max(1.2,.035*y),e.beginPath(),e.arc(g+w*.35,st,w,Math.PI*.7,Math.PI*1.3),N(),e.beginPath(),e.arc(T-w*.35,st,w,-Math.PI*.3,Math.PI*.3),N()}if(n.grace&&(e.strokeStyle=Ct,e.lineWidth=Math.max(1,.03*y),Ye(e,X-I*y*pt*1.2,st+B*y*1.4,X+I*y*pt*1.2,st-B*y*1.4)),n.showString){const[g]=D(b-I,k,s),T=.12*y,w=g-T-.06*y;e.strokeStyle=e.fillStyle=It?Ct:F,e.lineWidth=Math.max(1,.025*y),e.beginPath(),e.arc(w,st,T,0,Math.PI*2),N(),ne(String(U-n.string),w,st,.15*y,700,"center"),e.fillText(String(U-n.string),0,0),qt()}let Z=st-B*y-.18*y;e.strokeStyle=e.fillStyle=Ct,e.lineWidth=Math.max(1.2,.04*y),e.textAlign="center";const on=(g,T,w="700")=>{T*y<2||(ne(g,X,Z,T*y,w,"center"),e.fillText(g,0,0),qt(),Z-=(T+.04)*y)};let Bt=st-B*y;const Gt=n.tap&&!n.tapLeft;if((n.hammerOn||n.pullOff)&&!Gt){const g=n.grace?.6:1,T=.2*y*pt*g,w=.38*R*y*g,[it,q]=n.hammerOn?[Bt+.4*w,Bt-.6*w]:[Bt-.6*w,Bt+.4*w];e.beginPath(),e.moveTo(X-T,q),e.lineTo(X+T,q),e.lineTo(X,it),e.closePath(),e.fillStyle=It?Ct:"#ffffff",e.strokeStyle=L(o.ink,.9),e.lineWidth=Math.max(1.5,.03*y),N(),at(),Bt-=.6*w,Z=Math.min(Z,Bt-.14*y),e.strokeStyle=e.fillStyle=Ct,e.lineWidth=Math.max(1.2,.04*y)}if(Gt){const g=n.grace?.6:1,T=.28*y*pt*g,w=.62*R*y*g,it=Bt+.15*w,q=it-w;e.beginPath(),e.moveTo(X,it),e.lineTo(X+T,q),e.lineTo(X,q+.38*w),e.lineTo(X-T,q),e.closePath(),e.strokeStyle=L(o.ink,.9),e.lineWidth=Math.max(3.5,.1*y),N(),e.fillStyle=It?L(Ct,.4):L(Wn(F,.55),.85),at(),e.strokeStyle=It?Ct:F,e.lineWidth=Math.max(1.8,.05*y),N(),Bt=q,Z=Math.min(Z,Bt-.14*y),e.strokeStyle=e.fillStyle=Ct,e.lineWidth=Math.max(1.2,.04*y)}const C=Ee(n);if(C>0){const g=n.bendCurve?.[0]?.[1]>0,T=(n.bendCurve?.length??0)>1&&n.bendCurve.at(-1)[1]<C,w=Math.min(3,Math.max(1,Math.round(C*2))),it=I*y*pt*.6,q=I*y*.3,wt=q*1.25,Yt=L(o.ink,.9);let V=Bt-.04*y;const _t=ae=>{for(let Ht=0;Ht<w;Ht++)gi(e,X,V-Ht*wt-(ae>0?0:q),it,q,ae,It?Ct:F,Yt);V-=w*wt+.08*y};(!g||!T)&&_t(-1),T&&_t(1);const Rt=`${g?"pre ":""}${fi(C)}`;e.fillStyle=Ct,ne(Rt,X+it+.08*y,(st-B*y+V)/2,.22*y,700,"left"),e.fillText(Rt,0,0),qt(),e.textAlign="center",Z=Math.min(Z,V-.1*y)}n.staccato&&(e.beginPath(),e.arc(X,Z+.04*y,Math.max(1.5,.045*y),0,Math.PI*2),at(),Z-=.16*y),n.accent&&(n.accent==="tenuto"||!r?.accent)&&on({heavy:"^",tenuto:"–"}[n.accent]??">",.3);const z=[n.tapLeft?"m.g.":"",hi[n.harmonicType]??(n.harmonicPinch?"PH":""),n.slap?"slap":n.pop?"pop":"",n.golpe?`golpe (${n.golpe})`:"",n.rasgueado?`rasg. ${n.rasgueado}`:"",typeof n.trill=="number"?`tr ${n.trill}`:"",n.ornament??"",n.fade??"",n.whammy?"w/bar":"",n.wah==="open"?"o":n.wah==="closed"?"+":""];for(const g of z)g&&on(g,g.length>2?.22:.28);if(n.rightFinger&&on(n.rightFinger,.26,"italic 700"),n.vibrato){const g=.24*y,T=(n.vibratoWide?.07:.035)*y;e.beginPath();for(let w=0;w<=20;w++)e[w?"lineTo":"moveTo"](X-g+2*g*w/20,Z+Math.sin(w/20*Math.PI*4)*T);N(),Z-=(.16+(n.vibratoWide?.06:0))*y}if(n.pick){const g=.09*y,T=.13*y;e.beginPath(),n.pick==="down"?[[-g,T/2],[-g,-T/2],[g,-T/2],[g,T/2]].forEach(([w,it],q)=>e[q?"lineTo":"moveTo"](X+w,Z+it)):[[-g,-T/2],[0,T/2],[g,-T/2]].forEach(([w,it],q)=>e[q?"lineTo":"moveTo"](X+w,Z+it)),N(),Z-=.22*y}if(n.fermata&&(e.beginPath(),e.arc(X,Z+.06*y,.14*y,Math.PI,0),N(),e.beginPath(),e.arc(X,Z+.02*y,Math.max(1.5,.03*y),0,Math.PI*2),at(),Z-=.24*y),n.tremolo){for(let g=-1;g<=1;g++)Ye(e,X-.12*y,Z+(g*.08+.05)*y,X+.12*y,Z+(g*.08-.05)*y);Z-=.34*y}if(yt!==null&&!u){const g=Math.sign(yt-n.fret)||1,T=X-g*.16*y,w=X+g*.16*y,it=Z+.07*y,q=Z-.09*y;Ye(e,T,it,w,q),Ye(e,w,q,w-g*.1*y,q),Ye(e,w,q,w,q+.1*y),Z-=.3*y}e.globalAlpha=1}fe("notes");const _n=new Set;for(const i of mt){const n=i.time-h,c=Ut(i);if(!c?.barre||_n.has(c)||n>.06||n<-Math.max(i.sustain,.12))continue;_n.add(c),e.strokeStyle="rgba(255, 255, 255, 0.85)",e.lineWidth=Math.max(4,.12*xt);const[s,r]=[lt(c.barre.from),lt(c.barre.to)].sort((p,u)=>p-u);S([c.barre.fret-.5,s-R*.45,0],[c.barre.fret-.5,r+R*.45,0])}const Hn=new Set,Fn=new Set;for(const i of mt){const n=i.time-h,c=Ut(i),s=Ze.get(i.string),r=i.heldFrom??null,p=n<=.06||r!==null&&h>=r-.06,u=(i.slideTo??i.slideUnpitchTo??null)!==null;if(i.mute||n>an||n<-Math.max(i.sustain,u?.25:.12)||(c?.highDensity||r!==null)&&!p||s&&s.note!==i&&!p||p&&Hn.has(`${i.string}:${i.fret}`))continue;p&&Hn.add(`${i.string}:${i.fret}`),Fn.add(`${i.string}:${i.fret}`);const{a:v,open:b,x:k}=he(i),J=Qe(i,k,-n),H=tn(i),F=Tt(i.string),I=(b?(v.width-.2)/2:.32)+2/xt,B=(b?.1:.36)*R+2/xt;if(nt(J,H,0,I,B),p)E(!En(i,n),F,14),e.fillStyle=F,at(),E(!1),e.strokeStyle="rgba(255, 255, 255, 0.7)",e.lineWidth=1.5,N();else{const ut=(1-n/an)**2;e.globalAlpha=.35*ut,e.fillStyle=F,at(),e.globalAlpha=.25+.75*ut,e.strokeStyle=F,e.lineWidth=2.2,N()}const yt=i.finger??(c?.fingers?.[i.string]>=0?c.fingers[i.string]:null);if(!b&&yt!==null&&Dt(yt===0?"T":String(yt),J,H,0,R*.55,p?ht:o.text,800,"center",!p||Ot),!b&&Ee(i)>0){const[ut,X]=D(J,H+B,0),st=i.bendCurve?.[0]?.[1]>0&&i.bendCurve.at(-1)[1]<Ee(i);gi(e,ut,X-(st?.14:.05)*xt,.17*xt*pt,.085*xt,st?1:-1,"#ffffff",L(o.ink,.9))}e.globalAlpha=1}for(const i of l.handShapes??[])!i.arpeggio||i.startTime-h>an||i.endTime<=h||(e.globalAlpha=.3+.5*Math.min(1,1-(i.startTime-h)/an)**2,i.frets.forEach((n,c)=>{if(n<=0||c>=U||Fn.has(`${c}:${n}`))return;const s=n-.5,r=lt(c),p=i.fingers[c];nt(s,r,0,.32+2/xt,.36*R+2/xt),e.strokeStyle=Tt(c),e.lineWidth=2.2,N(),p>=0&&Dt(p===0?"T":String(p),s,r,0,R*.55,o.text,800)}),e.globalAlpha=1);fe("targets");const Nn=Ni(l),vn=Nn.findLast(i=>i.time<=h&&h<i.end+.3),xi=vn?null:Nn.find(i=>i.time>h&&i.time-h<1.2),Ne=vn??xi;if(Ne){const[i,n]=D(t.right+.4,A+.5,0),c=jt(e,Ie[700]??=`700 ${de}px ${o.num}`,Ne.name).width*52/de;e.globalAlpha=vn?1:Math.max(.35,1-(Ne.time-h)/1.2),e.fillStyle=o.text,ne(Ne.name,Math.min(i,M-24-c),n,52,700,"left"),e.fillText(Ne.name,0,0),qt(),e.globalAlpha=1}fe("labels")}const Yi=240,qi=64,me=100,Oe=24,ui=150;function Xi(a,l){if(a.tabPages?.length===l)return a.tabPages.pages;const h=a.notes.at(-1),o=Math.max(h?h.time+h.sustain:0,a.beats.at(-1)?.time??0)+.5;let t=a.beats.filter(d=>d.measure>=0).map(d=>d.time);t.length<2&&(t=Array.from({length:Math.ceil(o/l)+1},(d,e)=>e*l)),t=[Math.min(0,t[0]),...t.filter(d=>d>0),Math.max(o,t.at(-1)+.01)];const m=[];let M=t[0];for(let d=1;d<t.length;d++)t[d]-M>l&&t[d-1]>M&&m.push({start:M,end:M=t[d-1]});m.push({start:M,end:t.at(-1)});for(let d=0;d<m.length-1;d++)m[d].end=m[d+1].start;return a.tabPages={length:l,pages:m},m}function Vi(a,l,h,o){const{g:t,W:m}=pi(a);if(!l)return;const M=l.strings,d=Math.min(qi,320/Math.max(1,M-1))*(o.boardHeight??1),e=Ft*.62-d*(M-1)/2,$=e+d*(M-1),_=e-d*1.65,U=$+d*1.45,ct=W=>e+(o.stringOrder==="high"?M-1-W:W)*d,R=Yi*(o.noteSpeed??1),ot=o.tabLayout==="pages",lt=me+30,vt=m-Oe-30,Q=ot?Math.min(170,(vt-lt)*.14):0,G=vt-(ot?Q+24:0);let A,P,Mt,tt,Tt=null;if(ot){const W=Xi(l,(G-lt)/R),K=Math.max(0,W.findLastIndex(Et=>Et.start<=h)),j=W[K],St=(G-lt)/(j.end-j.start);A=Et=>lt+(Et-j.start)*St,[Mt,tt]=[j.start,j.end-.001],P=A(Math.min(Math.max(h,j.start),j.end)),W[K+1]&&(Tt={start:W[K+1].start,scale:St})}else P=Math.max(me+ui+60,m*.2),A=W=>P+(W-h)*R,[Mt,tt]=[h-(P-me)/R,h+(m-P)/R];const ge=W=>o.str[W%o.str.length],Jt=W=>W.chord===null||W.chord===void 0?null:l.chords[W.chord],rt=(W,K,j,St)=>{t.beginPath(),t.moveTo(W,K),t.lineTo(j,St),t.stroke()},Pe=(W,K,j,St)=>{const Et=Math.hypot(j,St),[Wt,Vt]=[j/Et,St/Et];rt(W,K,W-6*Wt-4*Vt,K-6*Vt+4*Wt),rt(W,K,W-6*Wt+4*Vt,K-6*Vt-4*Wt)},Ae=W=>W>=P-1?1:.4;t.lineCap="round",t.lineJoin="round",t.textBaseline="alphabetic";const Be=[],Kt=W=>{W&&(t.save(),t.beginPath(),t.rect(W[0],0,W[1]-W[0],Ft),t.clip());const K=`600 ${ce(Math.min(15,d*.26))}px ${o.num}`,j=`700 ${ce(Math.min(13,d*.22))}px ${o.num}`,St=new Map;t.font=K,t.textAlign="left";const Et=new Path2D,Wt=new Path2D;t.fillStyle=o.muted;for(let x=Ge(l.beats,Mt-1);x<l.beats.length;x++){const f=l.beats[x];if(f.time>tt)break;const S=A(f.time),nt=f.measure>=0,Y=nt?Et:Wt;Y.moveTo(S,e-d*.35),Y.lineTo(S,$+d*.35),nt&&(t.fillText(String(f.measure),S+6,_+d*.36),St.set(Math.round(f.time*50),jt(t,K,String(f.measure)).width+16))}t.lineWidth=1,t.strokeStyle=L(o.text,.05),t.stroke(Wt),t.lineWidth=1.5,t.strokeStyle=L(o.text,.16),t.stroke(Et),t.fillStyle=o.accent;const Vt=new Map;for(const x of l.markers??[])x.time>=Mt&&x.time<=tt&&Vt.set(Math.round(x.time*50),[...Vt.get(Math.round(x.time*50))??[],x.text]);for(const[x,f]of Vt)t.fillText([...new Set(f)].join(" · "),A(x/50)+6+(St.get(x)??0),_+d*.36);t.strokeStyle=L(o.text,.14),t.beginPath();for(let x=0;x<M;x++)t.moveTo(me,ct(x)),t.lineTo(m-Oe,ct(x));t.stroke();const ve=$+d*.92,pe=$+d*1.24;if(o.guides!==!1){t.font=K,t.fillStyle=t.strokeStyle=o.anchorLane,t.lineWidth=2;let x=-1/0;const f=l.anchors??[];for(let S=Math.max(1,Ge(f,Mt));S<f.length&&f[S].time<=tt;S++){const nt=f[S],Y=A(nt.time);if(Y<x)continue;const et=`fret ${nt.fret}`;t.globalAlpha=Ae(Y),rt(Y,$+d*.6,Y,ve-2),t.fillText(et,Y+5,ve),x=Y+5+jt(t,K,et).width+8}t.globalAlpha=1}t.strokeStyle=o.text,t.lineWidth=1.5;for(const x of l.hairpins??[]){if(x.endTime<Mt||x.time>tt)continue;const f=A(x.time),S=Math.max(f+30,A(x.endTime)),[nt,Y]=x.kind==="cresc"?[f,S]:[S,f];t.globalAlpha=Ae(S),t.beginPath(),t.moveTo(Y,pe-11),t.lineTo(nt,pe-5),t.lineTo(Y,pe+1),t.stroke()}t.globalAlpha=1;const ue=ce(Math.min(26,d*.42)),pt=ue*1.3,qe=ue*.32,We=o.gem==="pill"?pt/2:5,Qt={note:`700 ${ue}px ${o.num}`,grace:`700 ${ce(ue*.72)}px ${o.num}`,finger:`700 ${ce(ue*.5)}px ${o.num}`},pn=o.markings==="white";for(const x of l.handShapes??[]){if(!x.arpeggio||x.endTime<Mt||x.startTime>tt)continue;const f=x.frets.flatMap((Y,et)=>Y>=0&&et<M?[ct(et)]:[]);if(!f.length)continue;const S=A(x.startTime)-12,nt=A(x.endTime);t.globalAlpha=Ae(nt),t.strokeStyle=L(o.text,.4),t.lineWidth=1.5,t.setLineDash([6,5]),t.beginPath(),t.roundRect(S,Math.min(...f)-pt/2-6,nt-S,Math.max(...f)-Math.min(...f)+pt+12,8),t.stroke(),t.setLineDash([]),x.name&&(t.font=`700 ${ce(Math.min(24,d*.4))}px ${o.num}`,t.fillStyle=o.text,t.fillText(x.name,S,e-d*.72))}t.globalAlpha=1;const un=x=>(x.slideTo??x.slideUnpitchTo??null)!==null||!!x.slideOut,Mn=x=>{const f=Jt(x);return!!f&&!x.repeat&&!f.highDensity&&f.notes.length>1},xn=(x,f)=>4+(un(x)?16:0)+(Mn(f)?10:0)+(f.slideIn?18:0)+(f.showString?20:0);let Xe=0,_e=0;const Me=(x,f)=>{f(_e-x/2),_e-=x+3},bn={"":j,"italic ":`italic ${j}`},xe=(x,f="")=>Me(10,S=>{t.font=bn[f],t.fillText(x,Xe,S+5)}),{next:yn,prev:Ue,held:D}=Zn(l),je=new Map,Je=new Set,xt=[],Ke=[];for(let x=Ge(l.notes,Mt-D-.5);x<l.notes.length;x++){const f=l.notes[x];if(f.time>tt)break;if(A(f.time+f.sustain)<me-40-pt*4||W&&f.time<Mt&&A(f.time+f.sustain)-2<=A(Mt)&&typeof f.tieTo!="number")continue;const S=Jt(f),nt=f.grace?.72:1,Y=pt*nt,et=ct(f.string),Ot=ge(f.string),ht=A(f.time),be=f.mute||S?.fretHandMute,ee=f.palmMute||S?.palmMute,Pt=f.repeat||S?.highDensity,$e=be?"×":f.harmonic||f.harmonicPinch?`<${f.fret}>`:f.ghost?`(${f.fret})`:String(f.fret),Ie=f.finger??(S?.fingers?.[f.string]>=0?S.fingers[f.string]:null),ne=be||f.fret===0||Ie===null?"":Ie===0?"T":String(Ie),qt=f.grace?Qt.grace:Qt.note,ye=jt(t,qt,$e).width,Dt=ne?jt(t,Qt.finger,ne).width+3:0,ie=l.notes[yn[x]],Se=ie?A(ie.time)-xn(f,ie):1/0,gt=Math.min(Math.max(Y,ye+Dt+qe*2*nt),Math.max(10,Se-ht)),$t=Math.max(ht+gt,Math.min(A(f.time+f.sustain)-2,Se)),E=ht+gt/2,Sn=Math.min(1,(gt-4)/(ye+Dt)),He=je.get(f.string)??(Ue[x]>=0?{x0:A(l.notes[Ue[x]].time),w:pt}:null);if(je.set(f.string,{x0:ht,w:gt}),$t<me-40&&typeof f.tieTo!="number")continue;const Le=f.time<=h&&h<f.time+Math.max(f.sustain,.15),N=(Le||ht>=P-1?1:.4)*(f.ghost?.55:1);if(t.globalAlpha=N,S&&!Je.has(S)){Je.add(S);const le=S.notes.map(O=>ct(l.notes[O].string)),re=Math.min(...le)-pt/2,Zt=Math.max(...le)+pt/2,bt=ht-7;if(le.length>1&&!Pt&&(t.strokeStyle=S.accent?"#ffffff":L(o.text,.7),t.lineWidth=S.accent==="heavy"?4:S.accent?3:2,t.beginPath(),t.moveTo(bt+4,re),t.lineTo(bt,re),t.lineTo(bt,Zt),t.lineTo(bt+4,Zt),t.stroke()),t.font=j,t.fillStyle=t.strokeStyle=Pt?o.muted:o.text,t.lineWidth=1.8,t.textAlign="left",S.barre&&!Pt&&t.fillText(`${S.barre.half?"½":""}B${S.barre.fret}`,bt,re-5),S.strum||S.roll){const O=S.notes.map(te=>l.notes[te].string),dt=ct(Math.min(...O)),ft=ct(Math.max(...O)),[At,mt]=(S.strum??S.roll)==="down"?[dt,ft]:[ft,dt],Ut=bt-9;t.beginPath();for(let te=0;te<=16;te++)t.lineTo(Ut+(S.roll?Math.sin(te/16*Math.PI*6)*2.5:0),At+(mt-At)*te/16);t.stroke(),Pe(Ut,mt,0,mt-At||1)}const Xt=l.chords[f.chord-1];S.name&&!Pt&&(!Xt||f.time-Xt.time>1||Xt.name!==S.name)&&(t.font=`700 ${ce(Math.min(24,d*.4))}px ${o.num}`,t.fillStyle=o.text,t.fillText(S.name,ht,e-d*.72))}t.beginPath(),t.roundRect(ht,et-Y/2,$t-ht,Y,We*nt),Le&&!Pt&&(t.shadowColor=Ot,t.shadowBlur=18),Pt?(t.strokeStyle=Ot,t.lineWidth=2,t.stroke()):f.letRing&&$t>ht+gt+2?(t.fillStyle=L(Ot,.3),t.fill(),t.shadowBlur=0,t.strokeStyle=Ot,t.lineWidth=2,t.setLineDash([6,5]),rt(ht+gt+4,et,$t-4,et),t.setLineDash([]),t.beginPath(),t.roundRect(ht,et-Y/2,gt,Y,We*nt),t.fillStyle=Ot,t.fill()):(t.fillStyle=be?L(o.text,.22):Ot,t.fill()),t.shadowBlur=0,Le&&Be.push({y:et,c:Ot});const at=Pt?Ot:be?o.text:pn?"#ffffff":o.ink;xt.push({text:$e,font:qt,finger:ne,fill:at,shown:N,squeeze:Sn,x:E,y:et+jt(t,qt,$e).middle,left:-(ye+Dt)/2,textWidth:ye}),Ke.push(()=>{t.globalAlpha=N;const le=Pt?o.muted:o.text;t.strokeStyle=t.fillStyle=le,t.lineWidth=1.6;const re=f.slideTo??f.slideUnpitchTo??null,Zt=re===null?f.slideOut==="up"?1:f.slideOut?-1:0:Math.sign(re-f.fret)||1;if(Zt){const O=f.slideTo===null&&f.slideUnpitchTo!==null&&f.slideUnpitchTo!==void 0;O&&t.setLineDash([3,3]),rt($t+4,et+Zt*Y*.3,$t+14,et-Zt*Y*.3),O&&t.setLineDash([])}if(f.slideIn&&rt(ht-16,et+(f.slideIn==="below"?1:-1)*Y*.3,ht-6,et-(f.slideIn==="below"?1:-1)*Y*.3),typeof f.tieTo=="number"){const O=A(l.notes[f.tieTo].time)+Y/2;t.setLineDash([4,3]),t.beginPath(),t.moveTo(E,et+Y/2+3),t.quadraticCurveTo((E+O)/2,et+Y/2+14,O,et+Y/2+3),t.stroke(),t.setLineDash([])}if(f.showString){const O=ht-(S?26:13);t.beginPath(),t.arc(O,et,8,0,Math.PI*2),t.stroke(),t.font=Qt.finger,t.textAlign="center",t.fillText(String(M-f.string),O,et+jt(t,Qt.finger,"1").middle)}f.dynamicLabel&&(t.font=`italic ${j}`,t.textAlign="left",t.fillStyle=o.text,t.fillText(f.dynamicLabel,ht,pe),t.fillStyle=le);let bt=et-Y/2-6;if(f.vibrato){t.beginPath();for(let O=ht+2;O<=Math.max($t,ht+24)-2;O+=2)t.lineTo(O,bt+Math.sin((O-ht)/3)*(f.vibratoWide?3:1.8));t.stroke(),bt-=f.vibratoWide?10:8}if(t.textAlign="center",t.font=j,(f.hammerOn||f.pullOff)&&He){const O=He.x0+He.w/2,dt=(O+E)/2;t.beginPath(),t.moveTo(O,bt),t.quadraticCurveTo(dt,bt-12,E,bt),t.stroke(),t.fillText(f.hammerOn?"H":"P",dt,bt-9),bt-=10}const Xt=Ee(f);if(Xt>0){const O=f.bendCurve?.[0]?.[1]>0,dt=(f.bendCurve?.length??0)>1&&f.bendCurve.at(-1)[1]<Xt,ft=ht+gt-2,At=et-Y/2,mt=At-16;t.beginPath(),O?(t.moveTo(ft,At),t.lineTo(ft,mt)):(t.moveTo(ft-4,At+2),t.quadraticCurveTo(ft+4,At,ft+6,mt)),t.stroke(),Pe(O?ft:ft+6,mt,O?0:.3,-1),dt&&(t.beginPath(),t.moveTo(ft+12,mt),t.quadraticCurveTo(ft+16,At-6,ft+16,At),t.stroke(),Pe(ft+16,At,0,1)),t.textAlign="left",t.fillText(`${O?"pre ":""}${fi(Xt)}`,ft+(dt?20:10),mt+4),t.textAlign="center"}[Xe,_e]=[E,bt],f.tap&&!f.tapLeft&&xe("T"),f.staccato&&Me(4,O=>{t.beginPath(),t.arc(E,O,2,0,Math.PI*2),t.fill()}),f.accent&&(f.accent==="tenuto"||!S?.accent)&&xe({heavy:"^",tenuto:"–"}[f.accent]??">"),ee&&xe("PM");for(const O of[f.tapLeft?"m.g.":"",hi[f.harmonicType]??(f.harmonicPinch?"PH":""),f.slap?"slap":f.pop?"pop":"",f.golpe?`golpe (${f.golpe})`:"",f.rasgueado?`rasg. ${f.rasgueado}`:"",typeof f.trill=="number"?`tr ${f.trill}`:"",f.ornament??"",f.fade??"",f.whammy?"w/bar":"",f.wah==="open"?"o":f.wah==="closed"?"+":""])O&&xe(O);f.rightFinger&&xe(f.rightFinger,"italic "),f.pick&&Me(9,O=>{t.beginPath(),f.pick==="down"?[[-4,4.5],[-4,-4.5],[4,-4.5],[4,4.5]].forEach(([dt,ft],At)=>t[At?"lineTo":"moveTo"](E+dt,O+ft)):[[-4,-4.5],[0,4.5],[4,-4.5]].forEach(([dt,ft],At)=>t[At?"lineTo":"moveTo"](E+dt,O+ft)),t.stroke()}),f.fermata&&Me(9,O=>{t.beginPath(),t.arc(E,O+4,7,Math.PI,0),t.stroke(),t.beginPath(),t.arc(E,O+3,1.5,0,Math.PI*2),t.fill()}),f.tremolo&&Me(12,O=>{for(let dt=-1;dt<=1;dt++)rt(E-6,O+dt*4+2.5,E+6,O+dt*4-2.5)})})}const Ve=(x,f,S,nt)=>{if(t.globalAlpha=x.shown*nt,t.fillStyle=x.fill,x.squeeze===1)return t.fillText(f,x.x+x.left+S,x.y);t.save(),t.translate(x.x,x.y),t.scale(x.squeeze,1),t.fillText(f,x.left+S,0),t.restore()};t.textAlign="left";for(const x of[Qt.note,Qt.grace]){t.font=x;for(const f of xt)f.font===x&&Ve(f,f.text,0,1)}t.font=Qt.finger;for(const x of xt)x.finger&&Ve(x,x.finger,x.textWidth+3,.7);for(const x of Ke)x();t.globalAlpha=1,W&&t.restore()};if(!ot)Kt(null);else if(Kt([lt-40,G+4]),Tt){const W=G+24,K=P;A=j=>W+(j-Tt.start)*Tt.scale,[Mt,tt,P]=[Tt.start,Tt.start+Q/Tt.scale,-1/0],Kt([W-8,vt+4]),t.save(),t.globalCompositeOperation="destination-out",t.fillStyle="rgba(0, 0, 0, 0.55)",t.fillRect(W-8,0,vt+12-(W-8),Ft),t.restore(),t.strokeStyle=L(o.text,.22),t.lineWidth=1.5,t.setLineDash([3,5]),rt(G+12,e-d*.6,G+12,$+d*.6),t.setLineDash([]),P=K}t.shadowColor=o.accent,t.shadowBlur=16,t.strokeStyle=o.accent,t.lineWidth=3,rt(P,e-d*.7,P,$+d*.7);for(const{y:W,c:K}of Be)t.shadowColor=K,t.fillStyle="#ffffff",t.beginPath(),t.arc(P,W,4,0,Math.PI*2),t.fill();t.shadowBlur=0,t.globalCompositeOperation="destination-out";for(const[W,K,j]of ot?[]:[[me+10,1,ui],[m-Oe,-1,80]]){const St=t.createLinearGradient(W,0,W+K*j,0);St.addColorStop(0,"rgba(0, 0, 0, 1)"),St.addColorStop(1,"rgba(0, 0, 0, 0)"),t.fillStyle=St,t.fillRect(K>0?0:W-j,0,K>0?W+j:m-W+j,Ft)}t.globalCompositeOperation="destination-over",t.beginPath(),t.roundRect(Oe,_,m-Oe*2,U-_,16),t.fillStyle=L(o.ink,.72),t.fill(),t.globalCompositeOperation="source-over",t.strokeStyle=o.chipBorder,t.lineWidth=1,t.stroke();const se=`700 ${ce(Math.min(14,d*.24))}px ${o.num}`,we=Math.min(13,d*.22);t.font=se,t.textAlign="center";for(let W=0;W<M&&l.open;W++){const K=(Oe+me)/2,j=ct(W);t.strokeStyle=t.fillStyle=ge(W),t.lineWidth=1.8,t.beginPath(),t.arc(K,j,we,0,Math.PI*2),t.stroke(),t.fillText(bi(l.open[W]),K,j+jt(t,se,"E").middle)}}export{Di as HEADSTOCKS,Hi as bendAt,Ki as drawHighway,Vi as drawTab,Ci as headstockParts,Ti as lookAhead,Gi as moveCamera,Jn as rounded,Qn as spline};
|
|
1
|
+
import{lap as ce}from"./perf.js";import{noteName as ki}from"./music.js";const zt=900,Ti=84,qn=28,Xn=2.2,Pi=.9,Ai=2.4,wi=a=>Ti*(a.drawDistance??1)/(qn*(a.noteSpeed??1)),vi=.34,Dt=24,ln=1.2,Wi=1.25,$i=1.25,De=5,rn=1,Ii=1.6,Li=2,hn=.19,jn=.12,Jn=3,Di=11,Ci=[{time:-1/0,endTime:1/0,fret:1,width:4}],$n=[3,5,7,9,12,15,17,19,21,24],Ri=.31,Ei=1.7,Kn=.6,Vn=1,_i=.75,Zn=(a,l,f,o,t)=>{const[g,M,d,e]=[Math.min(a,l),Math.max(a,l),Math.min(f,o),Math.max(f,o)],I=Math.min(t,(M-g)/2,(e-d)/2),H=(X,dt,_)=>{const st=Array.from({length:5},(rt,vt)=>[X+Math.cos(_+vt*Math.PI/8)*I,dt+Math.sin(_+vt*Math.PI/8)*I]);return[st[0],...st,st[4]]};return[...H(M-I,e-I,0),...H(g+I,e-I,Math.PI/2),...H(g+I,d+I,Math.PI),...H(M-I,d+I,1.5*Math.PI)]},Oi=a=>[...a,a.at(-1),...a.slice(0,-1).reverse().map(([l,f])=>[l,-f])],Bi={inline:{label:"6 in line",outline:[[0,1],[.42,1.05],[.73,1.3],[1.01,1.53],[1.46,1.45],[2.73,1.08],[4.38,.62],[5.79,.17],[6.54,-.13],[6.88,-.35],[7.03,-.88],[6.98,-1.56],[6.64,-2.11],[6.14,-2.38],[5.59,-2.34],[5.21,-2.05],[4.99,-1.66],[4.75,-1.39],[4.25,-1.3],[3.5,-1.39],[2.6,-1.6],[1.85,-1.81],[1.18,-1.75],[.83,-1.36],[.47,-1.06],[0,-1]],posts:{from:[1.56,.95],to:[6.01,-.58]},keys:"machine",tree:2.47},fourTwo:{label:"4 + 2",outline:[[0,1],[.48,1.03],[.94,1.35],[1.21,1.72],[1.52,1.72],[2.99,1.31],[4.23,.95],[5.53,.57],[5.92,.28],[6.07,-.36],[6.05,-1.03],[5.79,-1.53],[5.36,-1.67],[4.95,-1.53],[4.68,-1.29],[4.36,-1.19],[4.02,-1.32],[3.67,-1.56],[2.99,-1.67],[2.08,-1.6],[1.4,-1.43],[.94,-1.16],[.48,-1.03],[0,-1]],posts:{from:[1.81,1.08],to:[4.94,-.03],treble:{share:1/3,from:[2.33,-1.03],to:[3.38,-.69]}},keys:"machine"},openBook:{label:"3 + 3 open book",outline:Oi([[0,1],[.48,1.07],[.96,1.33],[1.47,1.53],[3.16,1.67],[4.98,1.76],[6.25,1.8],[6.25,1.8],[6.42,.93],[6.3,0]]),posts:{from:[2.5,1.07],to:[5.1,1.07],treble:{share:1/2}},keys:"tulip",cover:[[.22,0],[.22,.4],[.36,.5],[.78,.4],[1.3,.25],[1.82,.16],[2.13,.1],[2.24,0],[2.13,-.1],[1.82,-.16],[1.3,-.25],[.78,-.4],[.36,-.5],[.22,-.4],[.22,0]],screws:[[.43,0],[1.98,0]]},pointed:{label:"3 + 3 pointed",outline:[[0,1],[.36,1.12],[.75,1.47],[1.07,1.84],[1.38,1.93],[2.29,1.73],[3.26,1.55],[4.36,1.35],[5.45,1.12],[5.75,.95],[5.86,.43],[5.98,-.22],[6.29,-.75],[6.75,-1.22],[6.75,-1.22],[6.17,-1.24],[5.33,-1.3],[4.36,-1.37],[3.26,-1.55],[2.29,-1.73],[1.38,-1.93],[1.07,-1.84],[.75,-1.47],[.36,-1.12],[0,-1]],posts:{from:[2.07,1],to:[4.65,.46],treble:{share:1/2}},keys:"machine",cover:[[.1,.44],[.1,.44],[.59,.4],[1.1,.28],[1.69,0],[1.69,0],[1.1,-.28],[.59,-.4],[.1,-.44],[.1,-.44],[.1,.44]],screws:[]},headless:{label:"Headless",outline:Zn(.2,.95,-1.06,1.06,.2),clamps:.58}};function Hi(a,l){const f=l.length,o=ei(a.outline,10);let t=l.map(e=>[a.clamps,e]),g=l.map(()=>1);if(a.posts){const{from:e,to:I,treble:H}=a.posts,X=H?Math.floor(f*H.share+1e-9):0,dt=f-X,_=(Z,G,w)=>P=>Z.map((xt,tt)=>xt+(G[tt]-xt)*P/Math.max(1,w-1)),st=([Z,G])=>[Z,-G],rt=_(e,I,dt),vt=_(H?.from??st(e),H?.to??st(I),X);t=l.map((Z,G)=>G<dt?rt(G):vt(f-1-G)),g=l.map((Z,G)=>G<dt?1:-1)}const M=(e,I)=>{let H=null;for(let X=1;X<o.length;X++){const[dt,_]=o[X-1],[st,rt]=o[X];if((dt-e)*(st-e)>0||dt===st)continue;const vt=_+(rt-_)*(e-dt)/(st-dt);(H===null||vt*I>H*I)&&(H=vt)}return H??I},d=a.keys?t.map(([e],I)=>({u:e,side:g[I],edge:M(e,g[I])})):[];return{outline:o,ends:t,keys:d}}const Qn=new WeakMap,Ue=new Map,Ni=(a,l)=>{const f=l.join(),o=Qn.get(a);if(o?.key===f)return o.parts;const t=Hi(a,l);return Qn.set(a,{key:f,parts:t}),t},ti=(a,l)=>(Ue.has(a)||(Ue.size>500&&Ue.clear(),Ue.set(a,l())),Ue.get(a)),ei=(a,l=8)=>[...a.slice(0,-1).flatMap((f,o)=>{const t=a[Math.max(0,o-1)],g=a[o+1],M=a[Math.min(a.length-1,o+2)];return f[0]===g[0]&&f[1]===g[1]?[f]:Array.from({length:l},(d,e)=>{const I=e/l;return[0,1].map(H=>.5*(2*f[H]+(g[H]-t[H])*I+(2*t[H]-5*f[H]+4*g[H]-M[H])*I*I+(3*f[H]-t[H]-3*g[H]+M[H])*I**3))})}),a.at(-1)],In=(a,l)=>{if(!a.startsWith("#"))return a;const f=o=>{const t=parseInt(a.slice(o,o+2),16);return Math.round(l>0?t+(255-t)*l:t*(1+l)).toString(16).padStart(2,"0")};return`#${f(1)}${f(3)}${f(5)}`},fn=new Map,D=(a,l)=>{if(!a.startsWith("#"))return a;const f=a+l;let o=fn.get(f);return o||(fn.size>1e3&&fn.clear(),fn.set(f,o=`rgba(${parseInt(a.slice(1,3),16)}, ${parseInt(a.slice(3,5),16)}, ${parseInt(a.slice(5,7),16)}, ${l})`)),o},Ce=(a,l)=>{let f=0,o=a.length;for(;f<o;){const t=f+o>>1;a[t].time<l?f=t+1:o=t}return f};function ni(a){if(a.links?.next.length===a.notes.length)return a.links;const l=a.notes.length,f=new Array(l).fill(-1),o=new Array(l).fill(-1),t={};let g=0;for(let M=0;M<l;M++){const{string:d,sustain:e}=a.notes[M];t[d]!==void 0&&([o[M],f[t[d]]]=[t[d],M]),t[d]=M,g=Math.max(g,e)}return a.links={next:f,prev:o,held:g}}const de=a=>Math.round(a*4)/4,Gt=32,cn=new Map;let ii=0;const Jt=(a,l,f)=>{let o=cn.get(l);o||cn.set(l,o=new Map);let t=o.get(f);if(!t){++ii>5e3&&([ii,o]=[0,new Map],cn.clear(),cn.set(l,o)),a.font=l;const g=a.measureText(f);o.set(f,t={width:g.width,middle:(g.actualBoundingBoxAscent-g.actualBoundingBoxDescent)/2})}return t},dn=128,Ln=new WeakMap,Fi=a=>{if(!Ln.has(a)){const l=new OffscreenCanvas(1,dn),f=l.getContext("2d"),[o,t]=[a.floor0,a.floor1].map(M=>[1,3,5].map(d=>parseInt(M.slice(d,d+2),16))),g=Array.from({length:dn},(M,d)=>{const e=(d+.5)/dn;return`rgba(${o.map((I,H)=>Math.round(I+(t[H]-I)*e))}, ${1-e})`});g.forEach((M,d)=>{f.fillStyle=M,f.fillRect(0,dn-1-d,1,1)}),Ln.set(a,{strip:l,near:g[0]})}return Ln.get(a)},Re=new Map,oi=new WeakMap,ai=(a,l,f)=>{let o=oi.get(a);o||oi.set(a,o=new Map);let t=o.get(l);if(!t){t=a.createLinearGradient(0,0,0,1);for(const[g,M]of f)t.addColorStop(g,M);o.set(l,t)}return t},mn=new Map,si=(a,l,f,o,t)=>{const g=`${l}|${f}|${o}|${t}`;let M=mn.get(g);return M||(mn.size>20&&mn.clear(),M=a.createLinearGradient(0,l,0,f),M.addColorStop(0,o),M.addColorStop(1,t),mn.set(g,M)),M},gn=(a,l)=>[a[0]-l[0],a[1]-l[1],a[2]-l[2]],pn=(a,l)=>a[0]*l[0]+a[1]*l[1]+a[2]*l[2],zi=(a,l)=>[a[1]*l[2]-a[2]*l[1],a[2]*l[0]-a[0]*l[2],a[0]*l[1]-a[1]*l[0]],Gi=a=>a.map(l=>l/Math.hypot(...a)),Ye=(a,l)=>{let f=0,o=a.length;for(;f<o;){const t=f+o>>1;a[t].time<=l?f=t+1:o=t}return a[Math.max(0,f-1)]},li=a=>a*a*(3-2*a),Ui=.3,ri=new WeakMap;function hi(a,l){let f=ri.get(a);if(f||ri.set(a,f={}),!(l in f)){const o=Math.max(a.sustain,.05),g=(a[l]??(l==="bendCurve"&&a.bend?[[0,0],[.25,a.bend]]:null))?.map(([M,d])=>[M*o,d,!1])??[];g.length&&g[0][0]>.001&&(g[0][2]=!0,g.unshift([0,0,!1])),f[l]=g.length?g:null}return f[l]}function fi(a,l){if(!a)return 0;let f=a[0][1];for(let o=1;o<a.length&&l>a[o-1][0];o++){const[[t,g],[M,d,e]]=[a[o-1],a[o]],I=Math.min(M-t,Ui)||1e-6;f=g+(d-g)*li(Math.min(1,Math.max(0,(l-(e?M-I:t))/I)))}return f}const Yi=(a,l)=>fi(hi(a,"bendCurve"),l),qi=(a,l)=>Yi(a,l)+fi(hi(a,"whammy"),l),ci=new WeakMap,Ee=a=>{let l=ci.get(a);return l===void 0&&ci.set(a,l=Math.max(a.bend||0,...(a.bendCurve??[]).map(([,f])=>f))),l};function Xi(a){if(a.chordSpans)return a.chordSpans;const l=[];for(const f of a.chords){const o=Math.max(f.time+.25,...f.notes.map(g=>a.notes[g].time+a.notes[g].sustain)),t=l.at(-1);t&&f.time-t.end<1&&(f.name?f.name===t.name:f.highDensity)?t.end=Math.max(t.end,o):f.name&&l.push({name:f.name,time:f.time,end:o})}for(const f of a.handShapes??[])f.arpeggio&&f.name&&l.push({name:f.name,time:f.startTime,end:f.endTime});return a.chordSpans=l.sort((f,o)=>f.time-o.time)}function ji(a){if(a.chordRails)return a.chordRails;const l=[],f=o=>Math.max(o.time+.15,...o.notes.map(t=>a.notes[t].time+a.notes[t].sustain));for(let o=0;o<a.chords.length;o++){const t=a.chords[o];if(t.highDensity)continue;let g=f(t),M=o+1;for(;a.chords[M]?.highDensity&&a.chords[M].time-g<1;M++)g=Math.max(g,f(a.chords[M]));g=Math.min(g,a.chords[M]?.time??1/0),g-t.time>.2&&l.push({time:t.time,end:g,frets:t.notes.map(d=>a.notes[d].fret)})}for(const o of a.handShapes??[])o.arpeggio&&l.push({time:o.startTime,end:o.endTime,frets:o.frets,arpeggio:o});return a.chordRails=l}const di={artificial:"AH",pinch:"PH",tap:"TH",semi:"SH",feedback:"FH"},mi=a=>a<.5?"¼":a===.5?"½":a===1?"full":a%1?`${Math.floor(a)}½`:String(a),gi=(a,l,f,o)=>{if(a===void 0)return l;const t=a+(l-a)*(1-Math.exp(-f/o));return Math.abs(l-t)<1e-6?l:t};function pi(a,l,f,o,t){a[l]===void 0&&([a[l],a[l+"Speed"]]=[f,0]);const g=2/o,M=g*t,d=1/(1+M+.48*M*M+.235*M*M*M),e=a[l]-f,I=(a[l+"Speed"]+g*e)*t;a[l+"Speed"]=(a[l+"Speed"]-g*I)*d,a[l]=f+(e+I)*d,Math.abs(a[l]-f)<1e-6&&Math.abs(a[l+"Speed"])<1e-6&&([a[l],a[l+"Speed"]]=[f,0])}function ui(a,l){let f=1/0,o=-1/0;for(const g of a)g.endTime<=l||g.time>=l+Jn||(f=Math.min(f,g.fret-1),o=Math.max(o,g.fret-1+g.width));if(f===1/0){const g=Ye(a,l);[f,o]=[g.fret-1,g.fret-1+g.width]}const t=Math.max(Di,o-f+2)+1;return{lo:f,hi:o,span:t,center:Math.min(25-t/2,Math.max(t/2-1,(f+o)/2))}}function Ji(a,l,f,o){const t=ui(l,f),g=a.target,M=!g||t.lo<g.center-g.span/2||t.hi>g.center+g.span/2,d=g&&g.span-Math.max(t.span,ui(l,f+Jn).span)>2;(M||d)&&(a.target=t);const e=Math.min(o-(a.at??o),100);a.at=o,pi(a,"span",a.target.span,a.target.span>a.span?.8:1.4,e/1e3),pi(a,"center",a.target.center,1,e/1e3);const I=Ye(l,f);return a.left=gi(a.left,I.fret-1,e,90),a.right=gi(a.right,I.fret-1+I.width,e,90),I}function Mi(a,l,f,o,t,g,M,d){a.beginPath(),a.moveTo(l-o,f-g*t),a.lineTo(l,f),a.lineTo(l+o,f-g*t),a.lineWidth=Math.max(3,t*1.15),a.strokeStyle=d,a.stroke(),a.lineWidth=Math.max(1.5,t*.65),a.strokeStyle=M,a.stroke(),a.lineWidth=Math.max(.6,t*.2),a.strokeStyle="rgba(255, 255, 255, 0.5)",a.stroke()}function qe(a,l,f,o,t){a.beginPath(),a.moveTo(l,f),a.lineTo(o,t),a.stroke()}function xi(a){const l=devicePixelRatio||1,f=a.clientWidth,o=a.clientHeight;(a.width!==Math.round(f*l)||a.height!==Math.round(o*l))&&(a.width=Math.round(f*l),a.height=Math.round(o*l));const t=a.getContext("2d"),g=o/zt,M=f/g,d=l*g;return t.setTransform(d,0,0,d,0,0),t.clearRect(0,0,M,zt),{g:t,W:M,B:d}}function no(a,l,f,o,t){const{g,W:M,B:d}=xi(a);let e=g;if(!l)return;const I=l.anchors.length?l.anchors:Ci,H=Ji(t,I,f,performance.now()),X=l.strings,dt=Math.min(.5,5*vi/Math.max(1,X-1)),_=dt*$i*(o.boardHeight??1),st=_*(X-1),rt=i=>(o.stringOrder==="high"?i:X-1-i)*_,vt=qn*(o.noteSpeed??1),Z=wi(o),G=-.22,w=st+.22,P=G-.06,xt=Z*vt,tt=i=>Math.max(0,i)*vt,At=i=>o.str[i%o.str.length],ge=o.noteLines===0?null:`rgba(255, 255, 255, ${o.noteLines??.5})`,Zt=t.span,ht=[t.center,dt*(X-1)/2,0],Ae=(o.viewAngle??30)*Math.PI/180,we=.6*Math.SQRT2*Zt,Oe=[ht[0],st+we*Math.sin(Ae),-we*Math.cos(Ae)],Qt=Gi(gn([ht[0],0,2.2*Zt],Oe)),se=zi(Qt,[1,0,0]),ve=(o.sideAngle??0)*Math.PI/180,[$,J]=[Math.sin(ve),Math.cos(ve)],j=gn(Oe,ht),St=pn(j,Qt),_t=pn(j,se),Wt=[-$,Qt[1]*J,Qt[2]*J],te=[J,Qt[1]*$,Qt[2]*$],We=[ht[0]+_t*se[0]+St*Wt[0],ht[1]+_t*se[1]+St*Wt[1],_t*se[2]+St*Wt[2]],pe=Math.min(M*.88,zt*(o.fill?1.3:1.05)),ue=pe*pn(gn(ht,We),Wt)/Zt,pt=Math.min(Wi*(o.fretWidth??1),M*Zt/(pe*Math.max(1,Zt-2.5)));let Xe=0,$e=0;const[ee,un,Mn]=We,[xn,bn,je]=Wt,[Be,Me,yn]=te,[xe,Sn,Je]=se,L=(i,n,h)=>{const s=i-ee,r=n-un,m=h-Mn,u=ue/Math.max(.05,s*xn+r*bn+m*je);return[M/2+(s*Be+r*Me+m*yn)*pt*u+Xe,zt/2-(s*xe+r*Sn+m*Je)*u+$e,u]},[Ke,Ve,ut]=L(...ht);[Xe,$e]=[M/2-Ke,zt*(o.fill?.83:.81)-Ve];const[,Ze]=L(t.center-Zt/2,P,0),[,Qe]=L(t.center+Zt/2,P,0),[,x]=L(t.center,P,0);$e-=Math.min(zt*.08,Math.max(0,Ze-x,Qe-x)),ce("setup");const c=(i,n=!0)=>{e.beginPath();for(let h=0;h<i.length;h++){const[s,r]=L(i[h][0],i[h][1],i[h][2]);h?e.lineTo(s,r):e.moveTo(s,r)}n&&e.closePath()},S=(i,n)=>{c([i,n],!1),F()},ot=(i,n,h,s,r)=>{if(o.gem!=="pill")return c([[i-s,n-r,h],[i+s,n-r,h],[i+s,n+r,h],[i-s,n+r,h]]);const[m,u]=L(i-s,n,h),[T,b]=L(i+s,n,h),[,k]=L(i,n+r,h),[,Y]=L(i,n-r,h),O=Math.atan2(b-u,T-m),B=Math.min(Math.abs(Y-k),Math.hypot(T-m,b-u))/2,[W,C]=[B*Math.cos(O),B*Math.sin(O)];e.beginPath(),e.arc(m+W,u+C,B,O+Math.PI/2,O+Math.PI*1.5),e.arc(T-W,b-C,B,O-Math.PI/2,O+Math.PI/2),e.closePath()},U=(i,n)=>{const h=Ye(I,n),s=i.filter(r=>r>0);return[Math.min(h.fret-1,...s.map(r=>r-1))+.05,Math.max(h.fret-1+Math.max(4,h.width),...s)-.05]},it=(i,n,h,s,r)=>{S([i-s,n-r,h],[i+s,n+r,h]),S([i-s,n+r,h],[i+s,n-r,h])},Ot=o.markings==="white",ft=Ot?"#ffffff":o.ink,be=(i,n,h,s,r,m,u,T=null)=>{const[b,k]=u?[r*.85,m*.8]:[Math.min(r,.34)*.4,m*.55],Y=u&&!Ot&&!T;T||(e.strokeStyle=D(o.ink,Y?.85:.7),e.lineWidth=Y?Math.max(2,.06*s):Math.max(3.5,.1*s),it(i,n,h,b,k)),!Y&&(e.strokeStyle=T??"#ffffff",e.lineWidth=Math.max(T?2:1.8,.05*s),it(i,n,h,b,k))};let ne=null,kt=0;const ye=i=>{i!==ne&&(e.font=ne=i)},Se={},ie=(i,n,h,s,r,m)=>{const u=Se[r]??=`${r} ${Gt}px ${o.num}`,T=s/Gt;return Jt(e,u,i),ye(u),e.textAlign=m,e.setTransform(d*T,0,0,d*T,d*n,d*(h-kt)),Jt(e,u,i).middle},Ut=()=>e.setTransform(d,0,0,d,0,-d*kt),ke=(i,n,h)=>{e.fillStyle=i,e.setTransform(d,0,0,d*(h-n),0,d*(n-kt)),e.fill(),Ut()},Ct=(i,n,h,s,r,m,u=700,T="center",b=!0,k=!1)=>{const[Y,O,B]=L(n,h,s),W=r*(k?B:Math.sqrt(B*ut));if(W<(k?1:8)||Y<-60||Y>M+60)return;e.textBaseline="alphabetic";const C=ie(i,Y,O,W,u,T);b&&(e.lineWidth=Gt*.2,e.strokeStyle=D(o.ink,.9),e.strokeText(i,0,C)),e.fillStyle=m,e.fillText(i,0,C),Ut(),e.textBaseline="middle"},He=(i,n,h,s,r,m,u=700)=>{const[T,b,k]=L(n,P,h),Y=(ut/k)**_i,[O,B]=L(n+s*Y,P,h),[W,C]=L(n,P,h+r*Y),gt=Math.abs(Math.atan2(W-T,b-C)),ct=Math.hypot(W-T,C-b);if(T<-60||T>M+60||ct<Vn||gt>Kn)return;const z=e.globalAlpha;e.globalAlpha=z*Math.min(1,(Kn-gt)/.2,(ct-Vn)/3);const et=Se[u]??=`${u} ${Gt}px ${o.num}`;ye(et),e.textAlign="center",e.textBaseline="alphabetic";const{middle:y}=Jt(e,et,i);e.setTransform(d*(O-T)/Gt,d*(B-b)/Gt,-d*(W-T)/Gt,-d*(C-b)/Gt,d*T,d*(b-kt)),e.fillStyle=m,e.fillText(i,0,y),Ut(),e.globalAlpha=z,e.textBaseline="middle"},[,le]=L(ht[0],P,0),[,Bt]=L(ht[0],P,xt),Mt=(i,n,h)=>{const s=`${le}|${Bt}`;(Re.span!==s||Re.size>300)&&(Re.clear(),Re.span=s);const r=`${i}|${n}|${h}`;let m=Re.get(r);return m||(m=e.createLinearGradient(0,le,0,Bt),m.addColorStop(0,D(i,n)),m.addColorStop(1,D(i,h)),Re.set(r,m)),m};let mt=null;const K=(i,n,h=10,s=!1)=>mt=i?{color:n,blur:h,faded:s}:null,Ne=[[.6,.05],[.35,.13],[.15,.27]],Fe=[[.4,.3]],Ie=i=>{if(!mt)return;const{lineWidth:n,globalAlpha:h}=e,s=i?1:Math.min(1,2*n/mt.blur);e.save(),e.strokeStyle=mt.faded?Mt(mt.color,1,.1):mt.color;for(const[r,m]of mt.blur>4?Ne:Fe)e.lineWidth=(i?0:n)+2*mt.blur*r,e.globalAlpha=h*m*s,e.stroke();e.restore()},F=()=>{Ie(!1),e.stroke()},V=()=>{Ie(!0),e.fill()};e.textBaseline="middle",e.lineCap="round",e.lineJoin="round";const{strip:re,near:he}=Fi(o);let[bt,Kt]=[-60,Dt+60];if(ve){const i=ht[0]+(1-pn(gn([ht[0],P,0],We),Wt))/Wt[0];[bt,Kt]=Wt[0]>0?[Math.max(-60,i),Dt+60]:[-60,Math.min(Dt+60,i)]}e.save(),c([[bt,P,0],[Kt,P,0],[Kt,P,xt],[bt,P,xt]]),e.clip(),ve&&(e.fillStyle=he,e.fillRect(0,le,M,zt-le)),e.imageSmoothingEnabled=!1,e.drawImage(re,0,Bt,M,le-Bt),e.restore();const R=(i,n)=>{const[h,s]=L(...i),[r,m]=L(...n);e.moveTo(h,s),e.lineTo(r,m)};e.strokeStyle=Mt(o.lane,.5,.04),e.lineWidth=Pi,e.beginPath();for(let i=0;i<=Dt;i++)R([i,P,0],[i,P,xt]);F();for(const i of[!1,!0]){e.strokeStyle=i?o.measure:o.beat,e.lineWidth=i?1.6:1,e.beginPath();for(let n=Ce(l.beats,f);n<l.beats.length;n++){const h=l.beats[n],s=h.time-f;if(s>Z)break;h.measure>=0===i&&R([0,P,tt(s)],[Dt,P,tt(s)])}F()}if(o.fretNumbers)for(let i=Ce(l.beats,f);i<l.beats.length;i++){const n=l.beats[i],h=n.time-f;if(h>Z)break;if(n.measure<0||h<.3)continue;const s=Ye(I,n.time),r=tt(h);e.globalAlpha=Math.min(1,(h-.3)/.5);for(const m of $n)(m<s.fret||m>=s.fret+s.width)&&He(String(m),m-.5,r,Ri,Ei,D(o.inlay,.7))}e.globalAlpha=1,(o.guides===!1?[]:I.filter(i=>i.endTime>f&&i.time<f+Z)).forEach((i,n)=>{const h=tt(Math.max(0,i.time-f)),s=tt(Math.min(Z,i.endTime-f)),r=i.fret-1,m=r+i.width;e.fillStyle=Mt(o.anchorFill,o.anchorOpacity,.02),c([[r,P,h],[m,P,h],[m,P,s],[r,P,s]]),V(),e.strokeStyle=Mt(o.anchorLane,.55,.04),e.lineWidth=Ai*.6;for(const u of[r,m])S([u,P,h],[u,P,s]);n&&i.time>f&&S([r,P,h],[m,P,h]),n&&i.time>f+.3&&Ct(String(i.fret),r-.2,P,h,.3,o.anchorLane,700,"right")});const lt=new Map,yt=i=>{const n=Math.round(i*100);return lt.has(n)||lt.set(n,{dt:i-f,texts:[],pins:[]}),lt.get(n)};for(const i of l.markers??[])i.time>=f&&i.time<=f+Z&&!yt(i.time).texts.includes(i.text)&&yt(i.time).texts.push(i.text);for(const i of l.hairpins??[])i.time>=f&&i.time<=f+Z&&yt(i.time).pins.push(i.kind);const Vt=Math.min(t.center-(t.span/2+.5)/pt,-.5);for(const{dt:i,texts:n,pins:h}of lt.values()){const[s,r,m]=L(Vt,P,tt(i)),u=Math.sqrt(m*ut),T=n.join(" · "),b=.25*u,k=`700 ${Gt}px ${o.num}`,Y=.3*u/Gt,O=T?Jt(e,k,T).width*Y:0,B=O+h.length*(.9*u+b);ye(k);let W=Math.max(s-.3*u,16+B);e.globalAlpha=Math.min(1,(Z-i)/.4),T&&(e.save(),e.translate(W,r),e.scale(Y,Y),e.textAlign="right",e.lineWidth=Gt*.2,e.strokeStyle=D(o.ink,.9),e.strokeText(T,0,0),e.fillStyle=o.accent,e.fillText(T,0,0),e.restore(),W-=O+b);for(const C of h){const gt=W-.9*u,ct=.14*u,[z,et]=C==="cresc"?[gt,W]:[W,gt];for(const[y,Lt]of[[D(o.ink,.9),Math.max(3.5,.12*u)],[o.text,Math.max(1.5,.05*u)]])e.strokeStyle=y,e.lineWidth=Lt,e.beginPath(),e.moveTo(et,r-ct),e.lineTo(z,r),e.lineTo(et,r+ct),F();W=gt-b}}e.globalAlpha=1,ce("floor");const $t=[];for(let i=Ce(l.notes,f-ni(l).held-.3);i<l.notes.length;i++){const n=l.notes[i];if(n.time>f+Z)break;const h=Math.max(n.sustain,(n.slideTo??n.slideUnpitchTo??null)===null?0:.25,.15);n.time+h>=f-.05&&$t.push(n)}const It=i=>i.chord===null||i.chord===void 0?null:l.chords[i.chord],kn=i=>o.repeatMarks==="frame"&&(i.repeat||It(i)?.highDensity),fe=i=>{const n=Ye(I,i.time),h=i.fret===0;return{a:n,open:h,x:h?n.fret-1+n.width/2:i.fret-.5,y:rt(i.string)}},tn=(i,n,h)=>{const s=i.slideTo??i.slideUnpitchTo??null,r=Math.min(1,Math.max(0,h/Math.max(i.sustain,.25)));return s===null||i.fret===0?n:n+(s-.5-n)*r*r*(3-2*r)},Dn=(i,n)=>qi(i,n)*_*rn,Cn=i=>{const n=f-i.time;return n<0||i.fret===0||!(Ee(i)>0)?0:Dn(i,Math.min(n,Math.max(i.sustain,.15)))},en=new Map;for(const i of $t){const n=i.time-f,h=Math.max(i.sustain,.15);n>0||-n>h||i.fret===0||!(Ee(i)>0)||en.set(i.string,{note:i,x:i.fret-.5,dy:Cn(i)})}const Tn=(i,n=0,h=!1)=>{const s=en.get(i),r=rt(i)+n,m=h?[[0,r,0]]:[on?[on[i][0],on[i][1]+n,0]:[-.6,r,0],[0,r,0]];if(!s)return c([...m,[Dt+.6,r,0]],!1);c([...m,[s.x,r+s.dy,0],[Dt+.6,r,0]],!1)},nn=i=>rt(i.string)+Cn(i),Yt=Bi[o.headstock],Te=(w-G)/2,Pn=o.stringOrder==="high"?-1:1,oe=([i,n])=>[-i*Te/pt,st/2+n*Te*Pn,0],An=i=>(rt(i)-st/2)*Pn/Te,qt=Yt&&Ni(Yt,Array.from({length:X},(i,n)=>An(n))),on=qt?.ends.map(oe),Pt=(i,n,h=1)=>{i&&(e.fillStyle=i,V()),n&&(e.strokeStyle=n,e.lineWidth=h,F())},Pe=(i,n,h)=>{const[s,r]=oe(i),[m,u]=L(s,r,0),[T]=L(s+n*Te/pt,r,0),[,b]=L(s,r+h*Te,0);e.beginPath(),e.ellipse(m,u,Math.abs(T-m),Math.abs(b-u),0,0,Math.PI*2)},Le=(i,n,h,s,r)=>c(ti(`${i},${n},${h},${s},${r}`,()=>Zn(i,n,h,s,r)).map(oe)),Rn=()=>{for(const{u:h,side:s,edge:r}of qt.keys){const m=(u,T)=>[r+s*u,r+s*T];Yt.keys==="machine"?(Le(h-.15,h+.15,...m(-.12,.08),.03),Pt(D(o.text,.12),D(o.anchorLane,.35)),Le(h-.03,h+.03,...m(.06,.22),0),Pt(D(o.text,.28)),Le(h-.11,h+.11,...m(.2,.68),.1),Pt(D(o.text,.18),D(o.anchorLane,.55))):(Le(h-.035,h+.035,...m(-.05,.22),0),Pt(D(o.text,.28)),Pe([h,r+s*.18],.08,.04),Pt(D(o.text,.3)),Pe([h,r+s*.4],.14,.2),Pt(D(o.text,.18),D(o.anchorLane,.55)))}c(qt.outline.map(oe));const[,i]=L(...oe([0,1.6])),[,n]=L(...oe([0,-1.2]));if(Pt(si(e,i,n,o.floor0,o.ink)),e.save(),e.clip(),Pt(null,D(o.text,.07),.3*Te*ut),e.restore(),K(!0,o.anchorLane,8),Pt(null,D(o.anchorLane,.6),Math.max(1.5,.03*ut)),K(!1),Yt.cover){c(ti(Yt.cover,()=>ei(Yt.cover)).map(oe)),Pt(D(o.text,.09),D(o.text,.4));for(const h of Yt.screws)Pe(h,.04,.04),Pt(D(o.nut,.85))}},En=i=>Xn*(.7+.14*(X-1-i)),yi=()=>{if(t.plate?.key!==wn||t.plate.t!==o)return t.plate={key:wn,t:o},Rn();const i=t.plate;if(!i.image){const[n,h]=[[],[]];for(const Y of[...qt.outline,...qt.keys.map(({u:O,side:B,edge:W})=>[O,W+B*.8])]){const[O,B]=L(...oe(Y));n.push(O),h.push(B)}const s=Math.floor(Math.max(0,Math.min(...n)-24)*d)/d,r=Math.min(M,Math.max(...n)+24),m=Math.floor(Math.max(0,Math.min(...h)-24)*d)/d,u=Math.min(zt,Math.max(...h)+24);i.image=new OffscreenCanvas(Math.max(1,Math.ceil((r-s)*d)),Math.max(1,Math.ceil((u-m)*d)));const[T,b,k]=[e,kt,ne];[e,kt,ne,i.x,i.y]=[i.image.getContext("2d"),0,null,s,m],e.setTransform(d,0,0,d,-s*d,-m*d),e.lineCap=e.lineJoin="round",Rn(),[e,kt,ne]=[T,b,k]}e.drawImage(i.image,i.x,i.y,i.image.width/d,i.image.height/d)},_n=()=>{e.fillStyle=o.board,c([[0,G,0],[Dt+.6,G,0],[Dt+.6,w,0],[0,w,0]]),V(),e.fillStyle=D(o.anchorFill,.16),c([[t.left,G,0],[t.right,G,0],[t.right,w,0],[t.left,w,0]]),V(),e.fillStyle=o.inlayDot;const i=s=>(Math.max(0,Math.ceil(s)-1)+.5)*_;e.beginPath();for(const s of $n)for(const r of s%12?[i((X-1)/2)]:[i((X-1)/4),st-i((X-1)/4)]){const[m,u,T]=L(s-.5,r,0);e.moveTo(m+.1*T,u),e.ellipse(m,u,.1*T,.08*T,0,0,Math.PI*2)}V(),qt&&yi();const[,n]=L(ht[0],w,0),[,h]=L(ht[0],G,0);e.strokeStyle=si(e,n,h,D(o.anchorPost,.75),o.post),e.lineWidth=Math.max(1.5,.05*ut),e.beginPath();for(let s=1;s<=Dt;s++)R([s,G-.04,0],[s,w+.04,0]);F(),e.strokeStyle=o.nut,e.lineWidth=Math.max(3,.12*ut),S([0,G-.06,0],[0,w+.06,0]),K(!0,o.anchorPost,12),e.strokeStyle=o.anchorPost,e.lineWidth=Math.max(3,.07*ut);for(const s of[t.left,t.right])S([s,G-.14,0],[s,w+.14,0]);K(!1);for(let s=0;s<X;s++){const r=En(s);K(!0,At(s),3),e.strokeStyle=D(At(s),.9),e.lineWidth=r,Tn(s),F(),K(!1),e.strokeStyle="rgba(255, 255, 255, 0.25)",e.lineWidth=Math.max(.6,r*.3),Tn(s,.012),F()}if(qt&&(qt.ends.forEach(([s,r],m)=>{if(Yt.clamps)Le(s-.1,s+.1,r-.1,r+.1,.04),Pt(D(o.text,.22),D(o.text,.45)),Pe([s,r],.05,.05),Pt(o.nut);else{Pe([s,r],.17,.17),Pt(D(o.ink,.5),D(o.nut,.4)),Pe([s,r],.085,.085),Pt(o.nut),Pe([s,r],.03,.03),Pt(D(o.ink,.85));const[u,T,b]=L(...on[m]),[k,Y]=L(0,rt(m),0),O=Math.atan2(Y-T,k-u);e.beginPath(),e.arc(u,T,.1*Te*b,O-1.3,O+1.3),Pt(null,At(m),En(m))}}),Yt.tree)){const s=[X-2,X-1].map(r=>{const[m,u]=qt.ends[r];return An(r)+(u-An(r))*Yt.tree/m});Le(Yt.tree-.05,Yt.tree+.05,Math.min(...s)-.08,Math.max(...s)+.08,.04),Pt(D(o.nut,.7),D(o.ink,.6))}for(const s of[!1,!0])for(let r=1;r<=Dt;r++){const m=r>=H.fret&&r<H.fret+H.width,u=$n.includes(r);(m||u)===s&&Ct(String(r),r-.5,G-.3,0,m?.3:u?.26:.2,m?o.accent:u?o.inlay:o.numOff,s?800:500,"center",!1)}},ze=(i,n)=>L(i,n,0).slice(0,2).map(h=>Math.round(h*d*10)).join(":"),wn=[o.headstock,X,_,Pn,M,d,Math.round(pt*1e4),ze(0,G),ze(Dt,G),ze(0,w),ze(Dt,w),ze(-4,st/2)].join(),an=!en.size&&[wn,H.fret,H.width,Math.round(t.left*1e3),Math.round(t.right*1e3)].join();if(!an||t.board?.key!==an||t.board.t!==o)t.board=an&&{key:an,t:o},_n();else{const i=t.board;if(!i.drawn){const n=[[0,w+.2],[Dt,w+.2],[0,G-.9],[Dt,G-.9]].map(([u,T])=>L(u,T,0)[1]);qt&&n.push(...[...qt.outline,...qt.keys.map(({u,side:T,edge:b})=>[u,b+T*.8])].map(u=>L(...oe(u))[1]));const h=Math.floor(Math.max(0,Math.min(...n)-24)*d)/d,s=Math.min(zt,Math.max(...n)+24),[r,m]=[Math.ceil(M*d),Math.max(1,Math.ceil((s-h)*d))];(t.boardImage?.width!==r||t.boardImage.height!==m)&&(t.boardImage=new OffscreenCanvas(r,m)),[e,kt,ne,i.y,i.drawn]=[t.boardImage.getContext("2d"),h,null,h,!0],e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,r,m),Ut(),e.lineCap=e.lineJoin="round",e.textBaseline="middle",_n(),[e,kt,ne]=[g,0,null]}e.drawImage(t.boardImage,0,i.y,t.boardImage.width/d,t.boardImage.height/d)}ce("board");const On=(i,n)=>i.letRing&&-n>.25;for(const i of $t){const n=i.time-f;if(n>0||-n>Math.max(i.sustain,.15)||i.mute)continue;const h=At(i.string),s=nn(i);if(K(!On(i,n),h,10),e.strokeStyle=h,e.lineWidth=Xn+3,Tn(i.string,0,!0),F(),K(!1),-n<.2){const[r,m,u]=L(fe(i).x,s,0);e.save(),e.translate(r,m),e.scale(1,.4);const T=e.createRadialGradient(0,0,0,0,0,.5*u);T.addColorStop(0,D(o.flash,.8*(1+n/.2))),T.addColorStop(1,D(o.flash,0)),e.fillStyle=T,e.beginPath(),e.arc(0,0,.5*u,0,Math.PI*2),V(),e.restore()}}e.strokeStyle=o.anchorLane,e.lineWidth=2.5,K(!0,o.anchorLane,10);for(const i of l.handShapes??[]){if(i.startTime>f||i.endTime<=f||i.endTime-i.startTime<.3||!i.frets.some((s,r)=>s>=0&&r<X))continue;const[n,h]=U(i.frets.filter((s,r)=>r<X),i.startTime);c([[n,G,0],[h,G,0],[h,w,0],[n,w,0]]),F()}K(!1),ce("strings");for(const i of $t){const n=i.time-f,h=tt(n),s=It(i),{a:r,open:m,x:u,y:T}=fe(i),b=tn(i,u,-n);if(n<-.15||Math.abs(L(b,T,h)[0]-M/2)>M/2+200)continue;const k=m?(r.width-.2)/2:.34;e.globalAlpha=n<0?Math.max(0,1+n/.15):Math.min(1,(Z-n)/.4),!s&&ge&&(e.strokeStyle=ge,e.lineWidth=2,S([b-k,P,h],[b+k,P,h])),!(m||kn(i))&&(e.strokeStyle=D(At(i.string),i.repeat||s?.highDensity?.35:.75),e.lineWidth=1.5,S([b,Math.min(T,nn(i))-.42*_,h],[b,P,h]))}e.globalAlpha=1;const Bn=(i,n,h)=>{const s=Array.from({length:13},(r,m)=>{const u=m/12;return[i[0]+(n[0]-i[0])*u,i[1]+(n[1]-i[1])*u+Math.sin(Math.PI*u)*h,i[2]+(n[2]-i[2])*u]});c(s,!1),F()};for(const i of ji(l)){if(i.end<=f||i.time>=f+Z)continue;const[n,h]=U(i.frets,i.time),s=i.time-f,r=tt(Math.max(s,0)),m=tt(Math.min(i.end-f,Z));e.globalAlpha=Math.min(1,(Z-Math.max(s,0))/.4),K(!i.arpeggio,o.anchorLane,10,!0),e.strokeStyle=Mt(o.anchorLane,1,.2),e.lineWidth=3.5;for(const u of[n,h])S([u,P,r],[u,P,m]);K(!1),i.arpeggio&&s>0&&(e.strokeStyle=D(o.anchorLane,.7),e.lineWidth=1.5,c([[n,P,r],[n,w,r],[h,w,r],[h,P,r]],!1),F(),i.arpeggio.name&&r>De&&Ct(i.arpeggio.name,n-.12,w/2,r,.34,o.text,600,"right"))}e.globalAlpha=1;const vn=(i,n)=>{const h=fe(i);return Math.abs(h.x-n)<(h.open?(h.a.width-.2)/2+.1:.45)};for(const[i,n]of $t.entries()){const h=n.time-f,s=It(n),r=n.slideTo??n.slideUnpitchTo??null,{a:m,open:u,x:T,y:b}=fe(n),k=At(n.string),Y=tt(h),O=(u?(m.width-.2)/2:.34)*(n.grace?.6:1),B=(u?.12:.42)*_*(n.grace?.6:1);if(h>-.15&&!s?.highDensity&&!n.repeat){if(e.globalAlpha=Math.min(1,(Z-h)/.4),e.strokeStyle=k,e.lineWidth=2,e.setLineDash([4,4]),n.slideIn&&S([T+(n.slideIn==="below"?-1.4:1.4),b-B,Math.max(0,Y-1)],[T+(n.slideIn==="below"?-O:O),b,Y]),n.slideOut&&S([T+(n.slideOut==="up"?O:-O),b,Y],[T+(n.slideOut==="up"?1.4:-1.4),b-B,Y+1]),e.setLineDash([]),typeof n.tieTo=="number"){const E=l.notes[n.tieTo],N=fe(E);e.setLineDash([5,4]),Bn([T,b+B,Y],[N.x,N.y+B,tt(E.time-f)],_*.9),e.setLineDash([])}e.globalAlpha=1}const W=r===null?n.sustain:Math.max(n.sustain,.25),C=r!==null||n.bend||n.bendCurve||n.whammy;if(W<=.2||h+W<=0||s&&!C||kn(n))continue;u&&r&&(e.strokeStyle=k,e.lineWidth=2.5,e.setLineDash(n.letRing?[7,6]:[]),Bn([T,b,tt(Math.max(h,0))],[r-.5,b,tt(Math.min(h+W,Z))],_*1.5),e.setLineDash([]));let gt=null;for(let E=i+1;E<$t.length&&$t[E].time<=n.time+W+.02;E++){const N=$t[E];if(!(N.time<=n.time+.005)&&(It(N)||N.string===n.string||vn(N,T))){gt=N;break}}const ct=Math.max(h,0),z=n.bend||n.bendCurve||n.whammy;let et=Math.min(h+W,Z,gt?gt.time-f:1/0);if(et<=ct)continue;const y=E=>{const N=E-h,p=tt(E),A=n.bend||n.bendCurve||n.whammy,v=n.vibrato&&!A?Math.sin(p/1.6*Math.PI*2)*_*(n.vibratoWide?.45:.25):0,at=n.tremolo?Math.floor(p/.3)%2?.05:-.05:0,q=rn+(Ii-rn)*li(Math.min(1,p/Li));return[tn(n,T,N)+at,b+v+Dn(n,N)*q/rn,p]},Lt=gt&&y(et)[0],Rt=gt&&It(gt)?.notes.find(E=>vn(l.notes[E],Lt)),nt=typeof Rt=="number"?l.notes[Rt]:gt;if(gt&&(z||vn(nt,Lt))){const E=fe(nt),N=tt(nt.time-f),p=E.open?(E.a.width-.2)/2:.34,A=L(E.x,E.y-(E.open?.12:.42)*_,N)[1]+3,[v]=L(E.x-p,E.y,N),[at]=L(E.x+p,E.y,N),q=wt=>{const[jt,Q]=L(...y(wt));return Q<A&&jt>Math.min(v,at)-2&&jt<Math.max(v,at)+2};if(q(et)&&!q(ct)){let wt=ct,jt=et;for(let Q=0;Q<24;Q++)[wt,jt]=q((wt+jt)/2)?[wt,(wt+jt)/2]:[(wt+jt)/2,jt];et=wt}if(et<=ct+.001)continue}const Ht=r===null&&!z&&!n.vibrato&&!n.tremolo?1:Math.min(400,Math.max(12,Math.ceil((et-ct)*vt*8))),Xt=Array.from({length:Ht+1},(E,N)=>y(ct+(et-ct)*N/Ht));if(u&&!s){e.fillStyle=Mt(k,n.letRing?.14:.26,.03),c([...Xt.map(([E,N,p])=>[E-O,N,p]),...Xt.slice().reverse().map(([E,N,p])=>[E+O,N,p])]),V(),K(!n.letRing,k,6,!0),e.strokeStyle=Mt(k,.95,.3),e.lineWidth=2.5,e.setLineDash(n.letRing?[7,6]:[]);for(const E of[-O,O])c(Xt.map(([N,p,A])=>[N+E,p,A]),!1),F();e.setLineDash([]),K(!1)}else if(n.bend||n.bendCurve||n.whammy){const E=N=>c([...Xt.map(([p,A,v])=>[p-N,A,v]),...Xt.slice().reverse().map(([p,A,v])=>[p+N,A,v])]);E(hn),e.fillStyle=Mt(k,1,.6),V(),E(hn*.35),e.fillStyle=Mt(In(k,-.22),1,.55),V(),K(!0,k,8,!0),e.strokeStyle=Mt(In(k,.6),1,.5),e.lineWidth=2;for(const N of[-hn,hn])c(Xt.map(([p,A,v])=>[p+N,A,v]),!1),F();K(!1)}else K(!n.letRing,k,6,!0),e.fillStyle=Mt(k,n.letRing?.4:.75,n.letRing?.15:.3),c([...Xt.map(([E,N,p])=>[E-.09,N,p]),...Xt.slice().reverse().map(([E,N,p])=>[E+.09,N,p])]),V(),K(!1);if((n.letRing||r!==null||!z&&(n.vibrato||n.tremolo))&&(e.strokeStyle=Mt(n.letRing?k:"#ffffff",.75,.3),e.lineWidth=n.letRing?2:1.5,e.setLineDash(n.letRing?[7,6]:[]),c(Xt,!1),F(),e.setLineDash([])),r!==null&&et>=Math.min(h+W,Z)-.001){const[E,N,p]=y(h+W);e.strokeStyle=k,e.lineWidth=2,e.setLineDash(n.slideTo===null?[5,4]:[]),u?ot(r-.5,N,p,.34,.42*_):ot(E,N,p,O,B),F(),e.setLineDash([])}}ce("trails");const Hn=new Set;for(let i=$t.length-1;i>=0;i--){const n=$t[i],h=n.time-f,s=tt(h),r=It(n),{a:m,open:u,x:T}=fe(n),b=tn(n,T,-h),k=nn(n),Y=n.mute||r?.fretHandMute,O=n.palmMute||r?.palmMute,B=At(n.string),W=(u?(m.width-.2)/2:.34)*(n.grace?.6:1),C=(u?.12:.42)*_*(n.grace?.6:1),gt=n.slideTo??n.slideUnpitchTo??null;if(h<-.15)continue;const ct=h<0?Math.max(0,1+h/.15):Math.min(1,(Z-h)/.4);if(e.globalAlpha=ct,r&&!Hn.has(n.chord)){Hn.add(n.chord);const[p,A]=U(r.notes.map(Q=>l.notes[Q].fret),n.time),v=e.globalAlpha,at=s<De,q=at?.65:r.highDensity&&o.repeatMarks!=="frame"?.18:.5;if(c([[p,P,s],[A,P,s],[A,w,s],[p,w,s]]),o.frames==="gradient"){const[,Q]=L(p,P,s),[,Nt]=L(p,w,s),Et=at?o.anchorLane:o.anchorFill;ke(ai(e,`${Et}|${q}`,[[0,D(Et,q*.6)],[1,D(Et,0)]]),Q,Nt)}else e.globalAlpha=v*q,r.highDensity||(e.fillStyle=o.chordFill,V()),e.strokeStyle=at?o.anchorLane:o.chordBox,e.lineWidth=at||!r.highDensity?1.5:1.2,K(at,o.anchorLane,8),F(),K(!1);if(e.globalAlpha=v,e.strokeStyle=ge,e.lineWidth=2,ge&&S([p,P,s],[A,P,s]),r.highDensity&&(r.palmMute||r.fretHandMute)&&(e.strokeStyle=r.palmMute?o.muted:"#ffffff",it((p+A)/2,P+_*.4,s,r.palmMute?.22:.12,_*(r.palmMute?.35:.22))),r.accent){const Q=Math.min(.6,(A-p)*.22),Nt=(w-P)*.35,Et=Math.min(1,L(p,w,s)[2]/L(p,w,De)[2]);e.strokeStyle="#ffffff",e.lineWidth=Math.max(1,3.5*Et*(r.accent==="heavy"?1.4:1)),e.lineCap="square",K(!0,"#ffffff",Math.max(2,12*Et)),c([[p,w-Nt,s],[p,w,s],[p+Q,w,s]],!1),F(),c([[A-Q,w,s],[A,w,s],[A,w-Nt,s]],!1),F(),K(!1),e.lineCap="round"}if(r.barre&&(!r.highDensity||o.repeatMarks==="grey")){const Q=r.barre.fret-.5;e.strokeStyle=r.highDensity?o.muted:"rgba(255, 255, 255, 0.7)",e.lineWidth=Math.max(3,.1*L(Q,st/2,s)[2]);const[Nt,Et]=[rt(r.barre.from),rt(r.barre.to)].sort((ae,Ft)=>ae-Ft);S([Q,Nt-_*.4,s],[Q,Et+_*.4,s]),Ct(r.barre.half?"½B":"B",Q,w+.12,s,.22,r.highDensity?o.muted:o.text)}if(r.strum||r.roll){const Q=p-.25,Nt=rt(0)>rt(X-1)?w-.1:P+.15,Et=Nt>st/2?P+.15:w-.1,[ae,Ft]=(r.strum??r.roll)==="down"?[Nt,Et]:[Et,Nt];e.strokeStyle=o.text,e.lineWidth=2,r.roll?c(Array.from({length:17},(Qi,Yn)=>[Q+Math.sin(Yn/16*Math.PI*6)*.06,ae+(Ft-ae)*Yn/16,s]),!1):c([[Q,ae,s],[Q,Ft,s]],!1),F();const Un=Ft<ae?.14:-.14;S([Q-.08,Ft+Un,s],[Q,Ft,s]),S([Q+.08,Ft+Un,s],[Q,Ft,s])}const wt=l.chords[n.chord-1],jt=!wt||n.time-wt.time>1||wt.name!==r.name;s>De&&r.name&&!r.highDensity&&jt&&Ct(r.name,p-.12,w/2,s,.34,o.text,600,"right")}const[z,et,y]=L(b,k,s);if(z<-200||z>M+200||kn(n)){e.globalAlpha=1;continue}const Lt=n.repeat||r?.highDensity;if(Lt){const p=s<De;e.globalAlpha*=p?.9:.4,e.strokeStyle=B,e.lineWidth=p?2:1.5,K(p,B,8),ot(b,k,s,W,C),F(),K(!1),(Y||O)&&o.repeatMarks!=="hide"&&be(b,k,s,y,u?.34:W,u?_*.3:C,O,o.muted),e.globalAlpha=ct}else{if(!u&&s>1.75&&o.fretNumbers){const p=n.harmonic||n.harmonicPinch?`<${n.fret}>`:n.ghost?`(${n.fret})`:String(n.fret);Ct(p,b,P,s-.55,n.grace?.18:.26,B)}if(n.dynamicLabel&&Ct(n.dynamicLabel,b-.6,P,s,.3,o.text,"italic 700","right"),n.ghost&&(e.globalAlpha=ct*.5),o.gem==="pill")o.notes3d!==!1&&(ot(b,k,s+jn,W,C),e.fillStyle=B,V(),e.fillStyle="rgba(255, 255, 255, 0.35)",V()),ot(b,k,s,W,C),e.fillStyle=B,V();else{const p=n.harmonic||n.harmonicPinch,A=jn;if(!p&&o.notes3d!==!1)for(const[q,wt]of[[[[b-W,k+C,s],[b+W,k+C,s],[b+W,k+C,s+A],[b-W,k+C,s+A]],"rgba(255, 255, 255, 0.35)"],[[[b-W,k-C,s],[b-W,k+C,s],[b-W,k+C,s+A],[b-W,k-C,s+A]],"rgba(0, 0, 0, 0.4)"],[[[b+W,k-C,s],[b+W,k+C,s],[b+W,k+C,s+A],[b+W,k-C,s+A]],"rgba(0, 0, 0, 0.4)"]])c(q),e.fillStyle=B,V(),e.fillStyle=wt,V();K(s<De,B,8),e.fillStyle=B,p?c([[b,k+C*1.3,s],[b+W*.8,k,s],[b,k-C*1.3,s],[b-W*.8,k,s]]):ot(b,k,s,W,C),V(),K(!1);const[,v]=L(b,k+C,s),[,at]=L(b,k-C,s);ke(ai(e,"shine",[[0,"rgba(255, 255, 255, 0.45)"],[.5,"rgba(255, 255, 255, 0)"],[1,"rgba(0, 0, 0, 0.25)"]]),v,at),e.strokeStyle="rgba(255, 255, 255, 0.6)",e.lineWidth=1,F()}if((Y||O)&&be(b,k,s,y,u?.34:W,u?_*.3:C,O,u&&O?B:null),!u&&!Y&&!O){const p=n.finger??(r?.fingers?.[n.string]>=0?r.fingers[n.string]:null),A=p!==null?p===0?"T":String(p):"";if(A){const v=e.globalAlpha;e.globalAlpha=v*Math.min(1,Math.max(0,(1-h/Z)/.4)),Ct(A,b,k,s-.01,_*.62,ft,700,"center",Ot,!0),e.globalAlpha=v}}}if(Lt&&o.repeatMarks==="hide"){e.globalAlpha=1;continue}const Rt=Lt?o.muted:o.text;if(e.globalAlpha=ct*(Lt?.8:1)*Math.min(1,Math.max(0,(1-h/Z)/.15)),n.ghost){const[p]=L(b-W,k,s),[A]=L(b+W,k,s),v=C*y*1.5;e.strokeStyle=Lt?Rt:B,e.lineWidth=Math.max(1.2,.035*y),e.beginPath(),e.arc(p+v*.35,et,v,Math.PI*.7,Math.PI*1.3),F(),e.beginPath(),e.arc(A-v*.35,et,v,-Math.PI*.3,Math.PI*.3),F()}if(n.grace&&(e.strokeStyle=Rt,e.lineWidth=Math.max(1,.03*y),qe(e,z-W*y*pt*1.2,et+C*y*1.4,z+W*y*pt*1.2,et-C*y*1.4)),n.showString){const[p]=L(b-W,k,s),A=.12*y,v=p-A-.06*y;e.strokeStyle=e.fillStyle=Lt?Rt:B,e.lineWidth=Math.max(1,.025*y),e.beginPath(),e.arc(v,et,A,0,Math.PI*2),F(),ie(String(X-n.string),v,et,.15*y,700,"center"),e.fillText(String(X-n.string),0,0),Ut()}let nt=et-C*y-.18*y;e.strokeStyle=e.fillStyle=Rt,e.lineWidth=Math.max(1.2,.04*y),e.textAlign="center";const sn=(p,A,v="700")=>{A*y<2||(ie(p,z,nt,A*y,v,"center"),e.fillText(p,0,0),Ut(),nt-=(A+.04)*y)};let Ht=et-C*y;const Xt=n.tap&&!n.tapLeft;if((n.hammerOn||n.pullOff)&&!Xt){const p=n.grace?.6:1,A=.2*y*pt*p,v=.38*_*y*p,[at,q]=n.hammerOn?[Ht+.4*v,Ht-.6*v]:[Ht-.6*v,Ht+.4*v];e.beginPath(),e.moveTo(z-A,q),e.lineTo(z+A,q),e.lineTo(z,at),e.closePath(),e.fillStyle=Lt?Rt:"#ffffff",e.strokeStyle=D(o.ink,.9),e.lineWidth=Math.max(1.5,.03*y),F(),V(),Ht-=.6*v,nt=Math.min(nt,Ht-.14*y),e.strokeStyle=e.fillStyle=Rt,e.lineWidth=Math.max(1.2,.04*y)}if(Xt){const p=n.grace?.6:1,A=.28*y*pt*p,v=.62*_*y*p,at=Ht+.15*v,q=at-v;e.beginPath(),e.moveTo(z,at),e.lineTo(z+A,q),e.lineTo(z,q+.38*v),e.lineTo(z-A,q),e.closePath(),e.strokeStyle=D(o.ink,.9),e.lineWidth=Math.max(3.5,.1*y),F(),e.fillStyle=Lt?D(Rt,.4):D(In(B,.55),.85),V(),e.strokeStyle=Lt?Rt:B,e.lineWidth=Math.max(1.8,.05*y),F(),Ht=q,nt=Math.min(nt,Ht-.14*y),e.strokeStyle=e.fillStyle=Rt,e.lineWidth=Math.max(1.2,.04*y)}const E=Ee(n);if(E>0){const p=n.bendCurve?.[0]?.[1]>0,A=(n.bendCurve?.length??0)>1&&n.bendCurve.at(-1)[1]<E,v=Math.min(3,Math.max(1,Math.round(E*2))),at=W*y*pt*.6,q=W*y*.3,wt=q*1.25,jt=D(o.ink,.9);let Q=Ht-.04*y;const Nt=ae=>{for(let Ft=0;Ft<v;Ft++)Mi(e,z,Q-Ft*wt-(ae>0?0:q),at,q,ae,Lt?Rt:B,jt);Q-=v*wt+.08*y};(!p||!A)&&Nt(-1),A&&Nt(1);const Et=`${p?"pre ":""}${mi(E)}`;e.fillStyle=Rt,ie(Et,z+at+.08*y,(et-C*y+Q)/2,.22*y,700,"left"),e.fillText(Et,0,0),Ut(),e.textAlign="center",nt=Math.min(nt,Q-.1*y)}n.staccato&&(e.beginPath(),e.arc(z,nt+.04*y,Math.max(1.5,.045*y),0,Math.PI*2),V(),nt-=.16*y),n.accent&&(n.accent==="tenuto"||!r?.accent)&&sn({heavy:"^",tenuto:"–"}[n.accent]??">",.3);const N=[n.tapLeft?"m.g.":"",di[n.harmonicType]??(n.harmonicPinch?"PH":""),n.slap?"slap":n.pop?"pop":"",n.golpe?`golpe (${n.golpe})`:"",n.rasgueado?`rasg. ${n.rasgueado}`:"",typeof n.trill=="number"?`tr ${n.trill}`:"",n.ornament??"",n.fade??"",n.whammy?"w/bar":"",n.wah==="open"?"o":n.wah==="closed"?"+":""];for(const p of N)p&&sn(p,p.length>2?.22:.28);if(n.rightFinger&&sn(n.rightFinger,.26,"italic 700"),n.vibrato){const p=.24*y,A=(n.vibratoWide?.07:.035)*y;e.beginPath();for(let v=0;v<=20;v++)e[v?"lineTo":"moveTo"](z-p+2*p*v/20,nt+Math.sin(v/20*Math.PI*4)*A);F(),nt-=(.16+(n.vibratoWide?.06:0))*y}if(n.pick){const p=.09*y,A=.13*y;e.beginPath(),n.pick==="down"?[[-p,A/2],[-p,-A/2],[p,-A/2],[p,A/2]].forEach(([v,at],q)=>e[q?"lineTo":"moveTo"](z+v,nt+at)):[[-p,-A/2],[0,A/2],[p,-A/2]].forEach(([v,at],q)=>e[q?"lineTo":"moveTo"](z+v,nt+at)),F(),nt-=.22*y}if(n.fermata&&(e.beginPath(),e.arc(z,nt+.06*y,.14*y,Math.PI,0),F(),e.beginPath(),e.arc(z,nt+.02*y,Math.max(1.5,.03*y),0,Math.PI*2),V(),nt-=.24*y),n.tremolo){for(let p=-1;p<=1;p++)qe(e,z-.12*y,nt+(p*.08+.05)*y,z+.12*y,nt+(p*.08-.05)*y);nt-=.34*y}if(gt!==null&&!u){const p=Math.sign(gt-n.fret)||1,A=z-p*.16*y,v=z+p*.16*y,at=nt+.07*y,q=nt-.09*y;qe(e,A,at,v,q),qe(e,v,q,v-p*.1*y,q),qe(e,v,q,v,q+.1*y),nt-=.3*y}e.globalAlpha=1}ce("notes");const Nn=new Set;for(const i of $t){const n=i.time-f,h=It(i);if(!h?.barre||Nn.has(h)||n>.06||n<-Math.max(i.sustain,.12))continue;Nn.add(h),e.strokeStyle="rgba(255, 255, 255, 0.85)",e.lineWidth=Math.max(4,.12*ut);const[s,r]=[rt(h.barre.from),rt(h.barre.to)].sort((m,u)=>m-u);S([h.barre.fret-.5,s-_*.45,0],[h.barre.fret-.5,r+_*.45,0])}const Fn=new Set,zn=new Set;for(const i of $t){const n=i.time-f,h=It(i),s=en.get(i.string),r=i.heldFrom??null,m=n<=.06||r!==null&&f>=r-.06,u=(i.slideTo??i.slideUnpitchTo??null)!==null;if(i.mute||n>ln||n<-Math.max(i.sustain,u?.25:.12)||(h?.highDensity||r!==null)&&!m||s&&s.note!==i&&!m||m&&Fn.has(`${i.string}:${i.fret}`))continue;m&&Fn.add(`${i.string}:${i.fret}`),zn.add(`${i.string}:${i.fret}`);const{a:T,open:b,x:k}=fe(i),Y=tn(i,k,-n),O=nn(i),B=At(i.string),W=(b?(T.width-.2)/2:.32)+2/ut,C=(b?.1:.36)*_+2/ut;if(ot(Y,O,0,W,C),m)K(!On(i,n),B,14),e.fillStyle=B,V(),K(!1),e.strokeStyle="rgba(255, 255, 255, 0.7)",e.lineWidth=1.5,F();else{const ct=(1-n/ln)**2;e.globalAlpha=.35*ct,e.fillStyle=B,V(),e.globalAlpha=.25+.75*ct,e.strokeStyle=B,e.lineWidth=2.2,F()}const gt=i.finger??(h?.fingers?.[i.string]>=0?h.fingers[i.string]:null);if(!b&>!==null&&Ct(gt===0?"T":String(gt),Y,O,0,_*.55,m?ft:o.text,800,"center",!m||Ot),!b&&Ee(i)>0){const[ct,z]=L(Y,O+C,0),et=i.bendCurve?.[0]?.[1]>0&&i.bendCurve.at(-1)[1]<Ee(i);Mi(e,ct,z-(et?.14:.05)*ut,.17*ut*pt,.085*ut,et?1:-1,"#ffffff",D(o.ink,.9))}e.globalAlpha=1}for(const i of l.handShapes??[])!i.arpeggio||i.startTime-f>ln||i.endTime<=f||(e.globalAlpha=.3+.5*Math.min(1,1-(i.startTime-f)/ln)**2,i.frets.forEach((n,h)=>{if(n<=0||h>=X||zn.has(`${h}:${n}`))return;const s=n-.5,r=rt(h),m=i.fingers[h];ot(s,r,0,.32+2/ut,.36*_+2/ut),e.strokeStyle=At(h),e.lineWidth=2.2,F(),m>=0&&Ct(m===0?"T":String(m),s,r,0,_*.55,o.text,800)}),e.globalAlpha=1);ce("targets");const Gn=Xi(l),Wn=Gn.findLast(i=>i.time<=f&&f<i.end+.3),Si=Wn?null:Gn.find(i=>i.time>f&&i.time-f<1.2),Ge=Wn??Si;if(Ge){const[i,n]=L(t.right+.4,w+.5,0),h=Jt(e,Se[700]??=`700 ${Gt}px ${o.num}`,Ge.name).width*52/Gt;e.globalAlpha=Wn?1:Math.max(.35,1-(Ge.time-f)/1.2),e.fillStyle=o.text,ie(Ge.name,Math.min(i,M-24-h),n,52,700,"left"),e.fillText(Ge.name,0,0),Ut(),e.globalAlpha=1}ce("labels")}const Ki=240,Vi=64,me=100,_e=24,bi=150;function Zi(a,l){if(a.tabPages?.length===l)return a.tabPages.pages;const f=a.notes.at(-1),o=Math.max(f?f.time+f.sustain:0,a.beats.at(-1)?.time??0)+.5;let t=a.beats.filter(d=>d.measure>=0).map(d=>d.time);t.length<2&&(t=Array.from({length:Math.ceil(o/l)+1},(d,e)=>e*l)),t=[Math.min(0,t[0]),...t.filter(d=>d>0),Math.max(o,t.at(-1)+.01)];const g=[];let M=t[0];for(let d=1;d<t.length;d++)t[d]-M>l&&t[d-1]>M&&g.push({start:M,end:M=t[d-1]});g.push({start:M,end:t.at(-1)});for(let d=0;d<g.length-1;d++)g[d].end=g[d+1].start;return a.tabPages={length:l,pages:g},g}function io(a,l,f,o){const{g:t,W:g}=xi(a);if(!l)return;const M=l.strings,d=Math.min(Vi,320/Math.max(1,M-1))*(o.boardHeight??1),e=zt*.62-d*(M-1)/2,I=e+d*(M-1),H=e-d*1.65,X=I+d*1.45,dt=$=>e+(o.stringOrder==="high"?M-1-$:$)*d,_=Ki*(o.noteSpeed??1),st=o.tabLayout==="pages",rt=me+30,vt=g-_e-30,Z=st?Math.min(170,(vt-rt)*.14):0,G=vt-(st?Z+24:0);let w,P,xt,tt,At=null;if(st){const $=Zi(l,(G-rt)/_),J=Math.max(0,$.findLastIndex(_t=>_t.start<=f)),j=$[J],St=(G-rt)/(j.end-j.start);w=_t=>rt+(_t-j.start)*St,[xt,tt]=[j.start,j.end-.001],P=w(Math.min(Math.max(f,j.start),j.end)),$[J+1]&&(At={start:$[J+1].start,scale:St})}else P=Math.max(me+bi+60,g*.2),w=$=>P+($-f)*_,[xt,tt]=[f-(P-me)/_,f+(g-P)/_];const ge=$=>o.str[$%o.str.length],Zt=$=>$.chord===null||$.chord===void 0?null:l.chords[$.chord],ht=($,J,j,St)=>{t.beginPath(),t.moveTo($,J),t.lineTo(j,St),t.stroke()},Ae=($,J,j,St)=>{const _t=Math.hypot(j,St),[Wt,te]=[j/_t,St/_t];ht($,J,$-6*Wt-4*te,J-6*te+4*Wt),ht($,J,$-6*Wt+4*te,J-6*te-4*Wt)},we=$=>$>=P-1?1:.4;t.lineCap="round",t.lineJoin="round",t.textBaseline="alphabetic";const Oe=[],Qt=$=>{$&&(t.save(),t.beginPath(),t.rect($[0],0,$[1]-$[0],zt),t.clip());const J=`600 ${de(Math.min(15,d*.26))}px ${o.num}`,j=`700 ${de(Math.min(13,d*.22))}px ${o.num}`,St=new Map;t.font=J,t.textAlign="left";const _t=new Path2D,Wt=new Path2D;t.fillStyle=o.muted;for(let x=Ce(l.beats,xt-1);x<l.beats.length;x++){const c=l.beats[x];if(c.time>tt)break;const S=w(c.time),ot=c.measure>=0,U=ot?_t:Wt;U.moveTo(S,e-d*.35),U.lineTo(S,I+d*.35),ot&&(t.fillText(String(c.measure),S+6,H+d*.36),St.set(Math.round(c.time*50),Jt(t,J,String(c.measure)).width+16))}t.lineWidth=1,t.strokeStyle=D(o.text,.05),t.stroke(Wt),t.lineWidth=1.5,t.strokeStyle=D(o.text,.16),t.stroke(_t),t.fillStyle=o.accent;const te=new Map;for(const x of l.markers??[])x.time>=xt&&x.time<=tt&&te.set(Math.round(x.time*50),[...te.get(Math.round(x.time*50))??[],x.text]);for(const[x,c]of te)t.fillText([...new Set(c)].join(" · "),w(x/50)+6+(St.get(x)??0),H+d*.36);t.strokeStyle=D(o.text,.14),t.beginPath();for(let x=0;x<M;x++)t.moveTo(me,dt(x)),t.lineTo(g-_e,dt(x));t.stroke();const We=I+d*.92,pe=I+d*1.24;if(o.guides!==!1){t.font=J,t.fillStyle=t.strokeStyle=o.anchorLane,t.lineWidth=2;let x=-1/0;const c=l.anchors??[];for(let S=Math.max(1,Ce(c,xt));S<c.length&&c[S].time<=tt;S++){const ot=c[S],U=w(ot.time);if(U<x)continue;const it=`fret ${ot.fret}`;t.globalAlpha=we(U),ht(U,I+d*.6,U,We-2),t.fillText(it,U+5,We),x=U+5+Jt(t,J,it).width+8}t.globalAlpha=1}t.strokeStyle=o.text,t.lineWidth=1.5;for(const x of l.hairpins??[]){if(x.endTime<xt||x.time>tt)continue;const c=w(x.time),S=Math.max(c+30,w(x.endTime)),[ot,U]=x.kind==="cresc"?[c,S]:[S,c];t.globalAlpha=we(S),t.beginPath(),t.moveTo(U,pe-11),t.lineTo(ot,pe-5),t.lineTo(U,pe+1),t.stroke()}t.globalAlpha=1;const ue=de(Math.min(26,d*.42)),pt=ue*1.3,Xe=ue*.32,$e=o.gem==="pill"?pt/2:5,ee={note:`700 ${ue}px ${o.num}`,grace:`700 ${de(ue*.72)}px ${o.num}`,finger:`700 ${de(ue*.5)}px ${o.num}`},un=o.markings==="white";for(const x of l.handShapes??[]){if(!x.arpeggio||x.endTime<xt||x.startTime>tt)continue;const c=x.frets.flatMap((U,it)=>U>=0&&it<M?[dt(it)]:[]);if(!c.length)continue;const S=w(x.startTime)-12,ot=w(x.endTime);t.globalAlpha=we(ot),t.strokeStyle=D(o.text,.4),t.lineWidth=1.5,t.setLineDash([6,5]),t.beginPath(),t.roundRect(S,Math.min(...c)-pt/2-6,ot-S,Math.max(...c)-Math.min(...c)+pt+12,8),t.stroke(),t.setLineDash([]),x.name&&(t.font=`700 ${de(Math.min(24,d*.4))}px ${o.num}`,t.fillStyle=o.text,t.fillText(x.name,S,e-d*.72))}t.globalAlpha=1;const Mn=x=>(x.slideTo??x.slideUnpitchTo??null)!==null||!!x.slideOut,xn=x=>{const c=Zt(x);return!!c&&!x.repeat&&!c.highDensity&&c.notes.length>1},bn=(x,c)=>4+(Mn(x)?16:0)+(xn(c)?10:0)+(c.slideIn?18:0)+(c.showString?20:0);let je=0,Be=0;const Me=(x,c)=>{c(Be-x/2),Be-=x+3},yn={"":j,"italic ":`italic ${j}`},xe=(x,c="")=>Me(10,S=>{t.font=yn[c],t.fillText(x,je,S+5)}),{next:Sn,prev:Je,held:L}=ni(l),Ke=new Map,Ve=new Set,ut=[],Ze=[];for(let x=Ce(l.notes,xt-L-.5);x<l.notes.length;x++){const c=l.notes[x];if(c.time>tt)break;if(w(c.time+c.sustain)<me-40-pt*4||$&&c.time<xt&&w(c.time+c.sustain)-2<=w(xt)&&typeof c.tieTo!="number")continue;const S=Zt(c),ot=c.grace?.72:1,U=pt*ot,it=dt(c.string),Ot=ge(c.string),ft=w(c.time),be=c.mute||S?.fretHandMute,ne=c.palmMute||S?.palmMute,kt=c.repeat||S?.highDensity,ye=be?"×":c.harmonic||c.harmonicPinch?`<${c.fret}>`:c.ghost?`(${c.fret})`:String(c.fret),Se=c.finger??(S?.fingers?.[c.string]>=0?S.fingers[c.string]:null),ie=be||c.fret===0||Se===null?"":Se===0?"T":String(Se),Ut=c.grace?ee.grace:ee.note,ke=Jt(t,Ut,ye).width,Ct=ie?Jt(t,ee.finger,ie).width+3:0,He=l.notes[Sn[x]],le=He?w(He.time)-bn(c,He):1/0,Bt=Math.min(Math.max(U,ke+Ct+Xe*2*ot),Math.max(10,le-ft)),Mt=Math.max(ft+Bt,Math.min(w(c.time+c.sustain)-2,le)),mt=ft+Bt/2,K=Math.min(1,(Bt-4)/(ke+Ct)),Ne=Ke.get(c.string)??(Je[x]>=0?{x0:w(l.notes[Je[x]].time),w:pt}:null);if(Ke.set(c.string,{x0:ft,w:Bt}),Mt<me-40&&typeof c.tieTo!="number")continue;const Fe=c.time<=f&&f<c.time+Math.max(c.sustain,.15),Ie=(Fe||ft>=P-1?1:.4)*(c.ghost?.55:1);if(t.globalAlpha=Ie,S&&!Ve.has(S)){Ve.add(S);const V=S.notes.map(R=>dt(l.notes[R].string)),re=Math.min(...V)-pt/2,he=Math.max(...V)+pt/2,bt=ft-7;if(V.length>1&&!kt&&(t.strokeStyle=S.accent?"#ffffff":D(o.text,.7),t.lineWidth=S.accent==="heavy"?4:S.accent?3:2,t.beginPath(),t.moveTo(bt+4,re),t.lineTo(bt,re),t.lineTo(bt,he),t.lineTo(bt+4,he),t.stroke()),t.font=j,t.fillStyle=t.strokeStyle=kt?o.muted:o.text,t.lineWidth=1.8,t.textAlign="left",S.barre&&!kt&&t.fillText(`${S.barre.half?"½":""}B${S.barre.fret}`,bt,re-5),S.strum||S.roll){const R=S.notes.map(It=>l.notes[It].string),Tt=dt(Math.min(...R)),lt=dt(Math.max(...R)),[yt,Vt]=(S.strum??S.roll)==="down"?[Tt,lt]:[lt,Tt],$t=bt-9;t.beginPath();for(let It=0;It<=16;It++)t.lineTo($t+(S.roll?Math.sin(It/16*Math.PI*6)*2.5:0),yt+(Vt-yt)*It/16);t.stroke(),Ae($t,Vt,0,Vt-yt||1)}const Kt=l.chords[c.chord-1];S.name&&!kt&&(!Kt||c.time-Kt.time>1||Kt.name!==S.name)&&(t.font=`700 ${de(Math.min(24,d*.4))}px ${o.num}`,t.fillStyle=o.text,t.fillText(S.name,ft,e-d*.72))}t.beginPath(),t.roundRect(ft,it-U/2,Mt-ft,U,$e*ot),Fe&&!kt&&(t.shadowColor=Ot,t.shadowBlur=18),kt?(t.strokeStyle=Ot,t.lineWidth=2,t.stroke()):c.letRing&&Mt>ft+Bt+2?(t.fillStyle=D(Ot,.3),t.fill(),t.shadowBlur=0,t.strokeStyle=Ot,t.lineWidth=2,t.setLineDash([6,5]),ht(ft+Bt+4,it,Mt-4,it),t.setLineDash([]),t.beginPath(),t.roundRect(ft,it-U/2,Bt,U,$e*ot),t.fillStyle=Ot,t.fill()):(t.fillStyle=be?D(o.text,.22):Ot,t.fill()),t.shadowBlur=0,Fe&&Oe.push({y:it,c:Ot});const F=kt?Ot:be?o.text:un?"#ffffff":o.ink;ut.push({text:ye,font:Ut,finger:ie,fill:F,shown:Ie,squeeze:K,x:mt,y:it+Jt(t,Ut,ye).middle,left:-(ke+Ct)/2,textWidth:ke}),Ze.push(()=>{t.globalAlpha=Ie;const V=kt?o.muted:o.text;t.strokeStyle=t.fillStyle=V,t.lineWidth=1.6;const re=c.slideTo??c.slideUnpitchTo??null,he=re===null?c.slideOut==="up"?1:c.slideOut?-1:0:Math.sign(re-c.fret)||1;if(he){const R=c.slideTo===null&&c.slideUnpitchTo!==null&&c.slideUnpitchTo!==void 0;R&&t.setLineDash([3,3]),ht(Mt+4,it+he*U*.3,Mt+14,it-he*U*.3),R&&t.setLineDash([])}if(c.slideIn&&ht(ft-16,it+(c.slideIn==="below"?1:-1)*U*.3,ft-6,it-(c.slideIn==="below"?1:-1)*U*.3),typeof c.tieTo=="number"){const R=w(l.notes[c.tieTo].time)+U/2;t.setLineDash([4,3]),t.beginPath(),t.moveTo(mt,it+U/2+3),t.quadraticCurveTo((mt+R)/2,it+U/2+14,R,it+U/2+3),t.stroke(),t.setLineDash([])}if(c.showString){const R=ft-(S?26:13);t.beginPath(),t.arc(R,it,8,0,Math.PI*2),t.stroke(),t.font=ee.finger,t.textAlign="center",t.fillText(String(M-c.string),R,it+Jt(t,ee.finger,"1").middle)}c.dynamicLabel&&(t.font=`italic ${j}`,t.textAlign="left",t.fillStyle=o.text,t.fillText(c.dynamicLabel,ft,pe),t.fillStyle=V);let bt=it-U/2-6;if(c.vibrato){t.beginPath();for(let R=ft+2;R<=Math.max(Mt,ft+24)-2;R+=2)t.lineTo(R,bt+Math.sin((R-ft)/3)*(c.vibratoWide?3:1.8));t.stroke(),bt-=c.vibratoWide?10:8}if(t.textAlign="center",t.font=j,(c.hammerOn||c.pullOff)&&Ne){const R=Ne.x0+Ne.w/2,Tt=(R+mt)/2;t.beginPath(),t.moveTo(R,bt),t.quadraticCurveTo(Tt,bt-12,mt,bt),t.stroke(),t.fillText(c.hammerOn?"H":"P",Tt,bt-9),bt-=10}const Kt=Ee(c);if(Kt>0){const R=c.bendCurve?.[0]?.[1]>0,Tt=(c.bendCurve?.length??0)>1&&c.bendCurve.at(-1)[1]<Kt,lt=ft+Bt-2,yt=it-U/2,Vt=yt-16;t.beginPath(),R?(t.moveTo(lt,yt),t.lineTo(lt,Vt)):(t.moveTo(lt-4,yt+2),t.quadraticCurveTo(lt+4,yt,lt+6,Vt)),t.stroke(),Ae(R?lt:lt+6,Vt,R?0:.3,-1),Tt&&(t.beginPath(),t.moveTo(lt+12,Vt),t.quadraticCurveTo(lt+16,yt-6,lt+16,yt),t.stroke(),Ae(lt+16,yt,0,1)),t.textAlign="left",t.fillText(`${R?"pre ":""}${mi(Kt)}`,lt+(Tt?20:10),Vt+4),t.textAlign="center"}[je,Be]=[mt,bt],c.tap&&!c.tapLeft&&xe("T"),c.staccato&&Me(4,R=>{t.beginPath(),t.arc(mt,R,2,0,Math.PI*2),t.fill()}),c.accent&&(c.accent==="tenuto"||!S?.accent)&&xe({heavy:"^",tenuto:"–"}[c.accent]??">"),ne&&xe("PM");for(const R of[c.tapLeft?"m.g.":"",di[c.harmonicType]??(c.harmonicPinch?"PH":""),c.slap?"slap":c.pop?"pop":"",c.golpe?`golpe (${c.golpe})`:"",c.rasgueado?`rasg. ${c.rasgueado}`:"",typeof c.trill=="number"?`tr ${c.trill}`:"",c.ornament??"",c.fade??"",c.whammy?"w/bar":"",c.wah==="open"?"o":c.wah==="closed"?"+":""])R&&xe(R);c.rightFinger&&xe(c.rightFinger,"italic "),c.pick&&Me(9,R=>{t.beginPath(),c.pick==="down"?[[-4,4.5],[-4,-4.5],[4,-4.5],[4,4.5]].forEach(([Tt,lt],yt)=>t[yt?"lineTo":"moveTo"](mt+Tt,R+lt)):[[-4,-4.5],[0,4.5],[4,-4.5]].forEach(([Tt,lt],yt)=>t[yt?"lineTo":"moveTo"](mt+Tt,R+lt)),t.stroke()}),c.fermata&&Me(9,R=>{t.beginPath(),t.arc(mt,R+4,7,Math.PI,0),t.stroke(),t.beginPath(),t.arc(mt,R+3,1.5,0,Math.PI*2),t.fill()}),c.tremolo&&Me(12,R=>{for(let Tt=-1;Tt<=1;Tt++)ht(mt-6,R+Tt*4+2.5,mt+6,R+Tt*4-2.5)})})}const Qe=(x,c,S,ot)=>{if(t.globalAlpha=x.shown*ot,t.fillStyle=x.fill,x.squeeze===1)return t.fillText(c,x.x+x.left+S,x.y);t.save(),t.translate(x.x,x.y),t.scale(x.squeeze,1),t.fillText(c,x.left+S,0),t.restore()};t.textAlign="left";for(const x of[ee.note,ee.grace]){t.font=x;for(const c of ut)c.font===x&&Qe(c,c.text,0,1)}t.font=ee.finger;for(const x of ut)x.finger&&Qe(x,x.finger,x.textWidth+3,.7);for(const x of Ze)x();t.globalAlpha=1,$&&t.restore()};if(!st)Qt(null);else if(Qt([rt-40,G+4]),At){const $=G+24,J=P;w=j=>$+(j-At.start)*At.scale,[xt,tt,P]=[At.start,At.start+Z/At.scale,-1/0],Qt([$-8,vt+4]),t.save(),t.globalCompositeOperation="destination-out",t.fillStyle="rgba(0, 0, 0, 0.55)",t.fillRect($-8,0,vt+12-($-8),zt),t.restore(),t.strokeStyle=D(o.text,.22),t.lineWidth=1.5,t.setLineDash([3,5]),ht(G+12,e-d*.6,G+12,I+d*.6),t.setLineDash([]),P=J}t.shadowColor=o.accent,t.shadowBlur=16,t.strokeStyle=o.accent,t.lineWidth=3,ht(P,e-d*.7,P,I+d*.7);for(const{y:$,c:J}of Oe)t.shadowColor=J,t.fillStyle="#ffffff",t.beginPath(),t.arc(P,$,4,0,Math.PI*2),t.fill();t.shadowBlur=0,t.globalCompositeOperation="destination-out";for(const[$,J,j]of st?[]:[[me+10,1,bi],[g-_e,-1,80]]){const St=t.createLinearGradient($,0,$+J*j,0);St.addColorStop(0,"rgba(0, 0, 0, 1)"),St.addColorStop(1,"rgba(0, 0, 0, 0)"),t.fillStyle=St,t.fillRect(J>0?0:$-j,0,J>0?$+j:g-$+j,zt)}t.globalCompositeOperation="destination-over",t.beginPath(),t.roundRect(_e,H,g-_e*2,X-H,16),t.fillStyle=D(o.ink,.72),t.fill(),t.globalCompositeOperation="source-over",t.strokeStyle=o.chipBorder,t.lineWidth=1,t.stroke();const se=`700 ${de(Math.min(14,d*.24))}px ${o.num}`,ve=Math.min(13,d*.22);t.font=se,t.textAlign="center";for(let $=0;$<M&&l.open;$++){const J=(_e+me)/2,j=dt($);t.strokeStyle=t.fillStyle=ge($),t.lineWidth=1.8,t.beginPath(),t.arc(J,j,ve,0,Math.PI*2),t.stroke(),t.fillText(ki(l.open[$]),J,j+Jt(t,se,"E").middle)}}export{Bi as HEADSTOCKS,Yi as bendAt,no as drawHighway,io as drawTab,Hi as headstockParts,wi as lookAhead,Ji as moveCamera,Zn as rounded,ei as spline};
|