@webgamekit/strudel-flow 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/dist/callArguments.d.ts +15 -0
- package/dist/chordSymbols.d.ts +15 -0
- package/dist/chords.d.ts +42 -0
- package/dist/codeScanner.d.ts +54 -0
- package/dist/compileStrudelFlow.d.ts +27 -0
- package/dist/components/notation/notationContextKey.d.ts +4 -0
- package/dist/components/overlayTargetKey.d.ts +3 -0
- package/dist/components/previewSoundKey.d.ts +3 -0
- package/dist/components/sampleFamilyIcons.d.ts +6 -0
- package/dist/components/visualizerWidgetIdsKey.d.ts +3 -0
- package/dist/config.d.ts +315 -0
- package/dist/connections.d.ts +29 -0
- package/dist/defaultPatch.d.ts +7 -0
- package/dist/envelopeShape.d.ts +13 -0
- package/dist/fretPlacement.d.ts +9 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.js +5997 -0
- package/dist/index.umd.cjs +21 -0
- package/dist/layout.d.ts +30 -0
- package/dist/nodeCodeRange.d.ts +36 -0
- package/dist/nodeDefaults.d.ts +55 -0
- package/dist/nodeDefinitions.d.ts +9 -0
- package/dist/nodePatterns.d.ts +23 -0
- package/dist/notationPick.d.ts +22 -0
- package/dist/notationSequence.d.ts +15 -0
- package/dist/noteValues.d.ts +20 -0
- package/dist/parseStrudelFlowCode.d.ts +20 -0
- package/dist/patchStorage.d.ts +9 -0
- package/dist/patternVariables.d.ts +16 -0
- package/dist/readStoredValue.d.ts +32 -0
- package/dist/readStrudelFlowNodeData.d.ts +15 -0
- package/dist/sampleFamilies.d.ts +10 -0
- package/dist/sampleSequence.d.ts +14 -0
- package/dist/sheetLayout.d.ts +11 -0
- package/dist/solo.d.ts +23 -0
- package/dist/storage.d.ts +12 -0
- package/dist/structSteps.d.ts +12 -0
- package/dist/style.css +1 -0
- package/dist/tabLayout.d.ts +11 -0
- package/dist/tempo.d.ts +12 -0
- package/dist/types.d.ts +453 -0
- package/dist/useStrudelFlow.d.ts +8 -0
- package/package.json +43 -3
- package/README.md +0 -3
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
(function(d,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@vue-flow/controls"),require("@vue-flow/core"),require("lucide-vue-next")):typeof define=="function"&&define.amd?define(["exports","vue","@vue-flow/controls","@vue-flow/core","lucide-vue-next"],e):(d=typeof globalThis<"u"?globalThis:d||self,e(d.WebGameKitStrudelFlow={},d.Vue,d.VueFlowControls,d.VueFlow,d.lucideVueNext))})(this,function(d,e,Ka,j,w){"use strict";const ht="strudel-flow-patch",Le={name:"Strudel Flow",url:"https://xyflow.com/strudel-flow",author:"xyflow",authorUrl:"https://xyflow.com",sourceUrl:"https://github.com/xyflow/strudel-flow",license:"AGPL-3.0"},we=120,Ge=1,ye=300,J=4,St=[{value:"2",label:"2"},{value:"3",label:"3"},{value:"4",label:"4"},{value:"5",label:"5"},{value:"6",label:"6"},{value:"7",label:"7"},{value:"8",label:"8"}],X=16,xe=16,Xe=8,re=80,ze=120,Rn=480,ja=360,On=2,Fe=1e5,Nn=20,Cn=2e4,An=.1,Dn=20,Mn=20,Be=[{value:"pianoroll",label:"Pianoroll"},{value:"punchcard",label:"Punchcard"},{value:"scope",label:"Scope"},{value:"spiral",label:"Spiral"},{value:"pitchwheel",label:"Pitch wheel"},{value:"spectrum",label:"Spectrum"}],Un=[{value:"inline",label:"Under the line"},{value:"background",label:"Behind the code"}],Ya=[{value:"code",label:"Code"},{value:"flow",label:"Flow"}],gt=[{value:"triangle",label:"Triangle"},{value:"sawtooth",label:"Sawtooth"},{value:"square",label:"Square"},{value:"sine",label:"Sine"}],ce=[{value:"C",label:"C"},{value:"C#",label:"C#"},{value:"D",label:"D"},{value:"D#",label:"D#"},{value:"E",label:"E"},{value:"F",label:"F"},{value:"F#",label:"F#"},{value:"G",label:"G"},{value:"G#",label:"G#"},{value:"A",label:"A"},{value:"A#",label:"A#"},{value:"B",label:"B"}],ie=[{value:"major",label:"Major"},{value:"minor",label:"Minor"},{value:"dorian",label:"Dorian"},{value:"phrygian",label:"Phrygian"},{value:"lydian",label:"Lydian"},{value:"mixolydian",label:"Mixolydian"},{value:"aeolian",label:"Aeolian"},{value:"locrian",label:"Locrian"},{value:"major:pentatonic",label:"Major pentatonic"},{value:"minor:pentatonic",label:"Minor pentatonic"},{value:"blues",label:"Blues"},{value:"chromatic",label:"Chromatic"},{value:"diminished",label:"Diminished"},{value:"harmonic:minor",label:"Harmonic minor"},{value:"melodic:minor",label:"Melodic minor"}],Ke=[{value:"major",label:"Major"},{value:"minor",label:"Minor"}],$e=[{value:"",label:"None"},{value:"!2",label:"!2"},{value:"!3",label:"!3"},{value:"!4",label:"!4"},{value:"/2",label:"/2"},{value:"/3",label:"/3"},{value:"/4",label:"/4"},{value:"@2",label:"@2"},{value:"@3",label:"@3"},{value:"@4",label:"@4"},{value:"*2",label:"*2"},{value:"*3",label:"*3"},{value:"*4",label:"*4"}],Re=8,kt=16,Pn=[{sound:"bd",hits:[0,4,8,12]},{sound:"sd",hits:[4,12]},{sound:"hh",hits:[0,2,4,6,8,10,12,14]}],bt=["bd","sd","hh","cp","ho","lt","mt","cr"],Tt=[{label:"Kicks",sounds:["bd","808bd","clubkick","hardkick","kicklinn","popkick","reverbkick"]},{label:"Snares",sounds:["sd","sn","808sd","dr","dr2","dr55","dr_few","drum","drumtraks","electro1","gretsch","hardcore","house","ifdrums","jungle"]},{label:"Hi-hats",sounds:["hh","hh27","linnhats","hc","ho","oc","808hc","808oh"]},{label:"Claps",sounds:["cp","realclaps","hand","clak"]},{label:"Toms",sounds:["lt","mt","ht","808lt","808mt","808ht","808lc","808mc"]},{label:"Cymbals",sounds:["cr","808cy","cb","rm","rs"]},{label:"Percussion",sounds:["perc","tabla","tok","tink","click","stomp","glasstap","can","bottle"]}],In="_widget_",Vn="test-canvas",Wn={mask:[{kind:"toggles",label:"Plays"}],struct:[{kind:"toggles",label:"Hits"}],sometimesBy:[{kind:"number",label:"Chance",min:0,max:1,step:.01},{kind:"text",label:"Then"}],someCyclesBy:[{kind:"number",label:"Chance",min:0,max:1,step:.01},{kind:"text",label:"Then"}],degradeBy:[{kind:"number",label:"Drop",min:0,max:1,step:.01}],swingBy:[{kind:"number",label:"Swing",min:0,max:.5,step:.01},{kind:"number",label:"Subdivision",min:1,max:16,step:1}],fast:[{kind:"number",label:"Speed",min:.25,max:8,step:.25}],slow:[{kind:"number",label:"Speed",min:.25,max:8,step:.25}],ply:[{kind:"number",label:"Repeats",min:1,max:8,step:1}],late:[{kind:"number",label:"Shift",min:0,max:1,step:.01}],early:[{kind:"number",label:"Shift",min:0,max:1,step:.01}],velocity:[{kind:"number",label:"Velocity",min:0,max:1,step:.01}],speed:[{kind:"number",label:"Rate",min:-2,max:4,step:.05}],crush:[{kind:"number",label:"Bits",min:1,max:16,step:1}],shape:[{kind:"number",label:"Drive",min:0,max:1,step:.01}],hpf:[{kind:"number",label:"Cutoff",min:20,max:2e4,step:10}]},Hn={bass:[43,38,33,28],guitar:[64,59,55,50,45,40]},Gn=24,xn=4,Oe=[{value:"auto",label:"Auto"},{value:"guitar",label:"Guitar tab"},{value:"bass",label:"Bass tab"},{value:"sheet",label:"Piano sheet"},{value:"piano",label:"Piano roll"},{value:"names",label:"Note names"},{value:"text",label:"Mini notation"}],Xn=[{word:"bass",view:"bass"},{word:"guitar",view:"guitar"},{word:"piano",view:"sheet"},{word:"keys",view:"sheet"},{word:"organ",view:"sheet"},{word:"rhodes",view:"sheet"},{word:"harpsichord",view:"sheet"},{word:"clavinet",view:"sheet"}],zn=12,Kn=1.5,qa=.8,Lt=3,jn=1,Yn=2.6,wt=.2,qn=.4,Zn=.8,Jn=3.4,yt=.62,Ft=.68,Qn=.15,vn=.2,el=.6,tl=.3,je=2,nl=1.5,Ne=[1,.5,.25,.125],Bt=2,$t=3,de=8,Rt=32,ll=26,ol=12,al=[1,3,6,8,10],Ot=5,Nt=.8,Ct=.35,sl=.1,rl=.12,cl=1,il=.36,At=.5,Ce=.3,Dt=.25,Mt=.7,Ut=.25,dl=4.3,ml={c:0,d:2,e:4,f:5,g:7,a:9,b:11},ul=3,_l=["#","s"],pl=24,Pt=["c","d","e","f","g","a","b"],fl=[{letter:"c",alteration:0},{letter:"c",alteration:1},{letter:"d",alteration:0},{letter:"d",alteration:1},{letter:"e",alteration:0},{letter:"f",alteration:0},{letter:"f",alteration:1},{letter:"g",alteration:0},{letter:"g",alteration:1},{letter:"a",alteration:0},{letter:"a",alteration:1},{letter:"b",alteration:0}],Ye=60,El={treble:30,bass:18},me=[{beats:4,filled:!1,stem:!1,flags:0},{beats:2,filled:!1,stem:!0,flags:0},{beats:1,filled:!0,stem:!0,flags:0},{beats:.5,filled:!0,stem:!0,flags:1},{beats:.25,filled:!0,stem:!0,flags:2},{beats:.125,filled:!0,stem:!0,flags:3}],hl=1.5,Sl={treble:"𝄞",bass:"𝄢"},gl={sharp:"♯",flat:"♭",natural:"♮"},kl=8,bl=5,Tl=4,Ll=10,wl=4.5,qe=2.4,yl=2.5,Fl=1.4,Bl=6,It=.65,$l=.45,Rl=3.5,Ol=.8,Vt=1,Nl=1.4,Cl=1.1,Ze=.7,Al=.7,Dl=3,Ml=.12,Wt=[{value:"",label:"Once",kind:"once"},{value:"*2",label:"2 hits in its step",kind:"faster"},{value:"*3",label:"3 hits in its step",kind:"faster"},{value:"*4",label:"4 hits in its step",kind:"faster"},{value:"*8",label:"8 hits in its step",kind:"faster"},{value:"!2",label:"Repeat over 2 steps",kind:"repeat"},{value:"!3",label:"Repeat over 3 steps",kind:"repeat"},{value:"!4",label:"Repeat over 4 steps",kind:"repeat"},{value:"@2",label:"Last 2 steps",kind:"hold"},{value:"@3",label:"Last 3 steps",kind:"hold"},{value:"/2",label:"Every 2nd cycle",kind:"slower"},{value:"/4",label:"Every 4th cycle",kind:"slower"},{value:"?",label:"Sometimes",kind:"chance"},{value:"(3,8)",label:"3 hits spread over 8",kind:"rhythm"},{value:"(5,8)",label:"5 hits spread over 8",kind:"rhythm"},{value:"(3,8,2)",label:"3 over 8, shifted by 2",kind:"rhythm"}],Ul=[{id:"once",label:"Plays"},{id:"faster",label:"Faster"},{id:"repeat",label:"Repeat"},{id:"hold",label:"Longer"},{id:"slower",label:"Slower"},{id:"chance",label:"Chance"},{id:"rhythm",label:"Rhythm"}],Ht=[{id:"kick",label:"Kicks",match:"(^|[_\\d])(bd|kick)|kick|bassdrum"},{id:"snare",label:"Snares",match:"(^|[_\\d])(sd|sn|rim|rs)(\\b|_|$|\\d)|snare|rimshot"},{id:"hihat",label:"Hi-hats",match:"(^|[_\\d])(hh|oh|ch|hc|ho|oc)|hat"},{id:"clap",label:"Claps",match:"(^|[_\\d])cp|clap|hand"},{id:"tom",label:"Toms",match:"(^|[_\\d])(lt|mt|ht|lc|mc|hc)(\\b|_|$|\\d)|tom"},{id:"cymbal",label:"Cymbals",match:"(^|[_\\d])(cr|cy|cb|rd)(\\b|_|$|\\d)|ride|crash|cymbal|cowbell"},{id:"percussion",label:"Percussion",match:"perc|tabla|conga|bongo|shaker|tamb|tok|tink|click|stomp|clave|glass|can|bottle|wood"},{id:"bass",label:"Bass",match:"bass|sub|jvbass|jungbass"},{id:"keys",label:"Keys",match:"piano|keys|rhodes|organ|epiano|casio|wurli|clav|pad|arpy"},{id:"strings",label:"Guitar and strings",match:"guitar|gtr|string|violin|cello|harp|pluck"},{id:"voice",label:"Voices",match:"voc|voice|vox|choir|speech|sing|numbers|alphabet|mouth"},{id:"fx",label:"Effects and noise",match:"fx|noise|glitch|sweep|wind|metal|industrial|space"}],Pl=t=>{try{return localStorage.getItem(t)}catch{return null}},Il=(t,n)=>{try{localStorage.setItem(t,n)}catch{}},Y=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),x=(t,n)=>typeof t=="string"?t:n,W=(t,n,l,o)=>typeof t=="number"&&Number.isFinite(t)?Math.min(o,Math.max(l,t)):n,ue=(t,n,l)=>typeof n=="string"&&t.some(o=>o.value===n)?n:l,Za=["C","C♯","D","E♭","E","F","F♯","G","A♭","A","B♭","B"],Ja={C:0,"C#":1,Db:1,D:2,"D#":3,Eb:3,E:4,F:5,"F#":6,Gb:6,G:7,"G#":8,Ab:8,A:9,"A#":10,Bb:10,B:11},Gt=[0,2,4,5,7,9,11],xt=[0,2,3,5,7,8,10],Qa={major:["I","ii","iii","IV","V","vi","vii°"],minor:["i","ii°","III","iv","v","VI","VII"]},Vl=[{label:"Home",steps:[0,5,3,4]},{label:"Turnaround",steps:[1,4,0,0]},{label:"Descending",steps:[0,6,5,4]}],va=3,Xt=t=>{var n;return((n=t.chordNotes)==null?void 0:n.map(l=>(l[0]??0)%7))??t.chordProgression},es=t=>Array.from({length:va},(n,l)=>t+l*2),Je=t=>t.chordNotes??Xt(t).map(es),Wl=t=>{const n=t.scaleType==="minor"?xt:Gt,l=Qa[t.scaleType],o=c=>(Ja[t.key]??0)+n[c%7]+Math.floor(c/7)*12,a=c=>Za[o(c)%12];return{degrees:l,noteName:a,noteLabel:c=>`${a(c)}${t.octave+Math.floor(o(c)/12)}`,chordName:c=>{const i=l[c%7];return i.includes("°")?`${a(c)}°`:`${a(c)}${i===i.toLowerCase()?"m":""}`}}},ts=t=>[...t],zt=new Set(['"',"'","`"]),ns=new Set(["(","[","{"]),ls=new Set([")","]","}"]),os=new Set([".",",","(","[","{","+","-","*","/","=","&","|","?",":"]),as={parts:[],current:"",quote:"",escaped:!1,depth:0},Ae=(t,n)=>({...t,current:t.current+n}),ss=(t,n)=>t.escaped?{...Ae(t,n),escaped:!1}:n==="\\"?{...Ae(t,n),escaped:!0}:{...Ae(t,n),quote:n===t.quote?"":t.quote},Hl=t=>{const n=t.current.trim();return{...t,parts:n.length>0?[...t.parts,n]:t.parts,current:""}},Gl=t=>ns.has(t)?1:ls.has(t)?-1:0,rs=t=>(n,l,o)=>n.quote.length>0?ss(n,l):zt.has(l)?{...Ae(n,l),quote:l}:n.depth===0&&t(l,o,n.current)?Hl(n):{...Ae(n,l),depth:n.depth+Gl(l)},xl=(t,n)=>Hl([...t].reduce(rs(n),as)).parts,Q=(t,n)=>xl(t,l=>l===n),cs=t=>{const n=[...t],l=n.reduce((o,a,s)=>{if(o.end!==-1)return o;if(o.quote.length>0){const r=!o.escaped&&a===o.quote;return{...o,quote:r?"":o.quote,escaped:!o.escaped&&a==="\\"}}return zt.has(a)?{...o,quote:a}:a==="/"&&n[s+1]==="/"?{...o,end:s}:o},{quote:"",escaped:!1,end:-1}).end;return(l===-1?t:t.slice(0,l)).trimEnd()},Kt=t=>t.split(`
|
|
2
|
+
`).map(cs).join(`
|
|
3
|
+
`),Xl=t=>xl(t,(n,l,o)=>{if(n===";")return!0;if(n!==`
|
|
4
|
+
`)return!1;const a=o.trim();return a.length>0&&!t.slice(l+1).trimStart().startsWith(".")&&!os.has(a.at(-1)??"")}),is=t=>{try{return typeof new Function(`return async () => {
|
|
5
|
+
${t}
|
|
6
|
+
}`)=="function"}catch{return!1}},ds=t=>{if(!t.startsWith("(")||!t.endsWith(")"))return!1;const n=t.length-1;return![...t].reduce((o,a,s)=>{if(o.closesEarly)return o;if(o.quote.length>0){const c=!o.escaped&&a===o.quote;return{...o,quote:c?"":o.quote,escaped:!o.escaped&&a==="\\"}}if(zt.has(a))return{...o,quote:a};const r=o.depth+Gl(a);return{...o,depth:r,closesEarly:r===0&&s<n}},{quote:"",escaped:!1,depth:0,closesEarly:!1}).closesEarly},ms=new Set(["[","<","(","{"]),us=new Set(["]",">",")","}"]),zl=t=>{const n=t.current.trim();return{parts:n.length>0?[...t.parts,n]:t.parts,current:"",depth:0}},v=(t,n)=>zl([...t].reduce((l,o)=>{if(l.depth===0&&n(o))return{...zl(l),depth:0};const a=ms.has(o)?1:us.has(o)?-1:0;return{...l,current:l.current+o,depth:Math.max(0,l.depth+a)}},{parts:[],current:"",depth:0})).parts,_e=t=>/^(["'`])[\S\s]*\1$/.test(t.trim()),z=t=>{const n=t.trim();if(n.startsWith('"'))try{const l=JSON.parse(n);return typeof l=="string"?l:n.slice(1,-1)}catch{return n.slice(1,-1)}return n.slice(1,-1).replace(/\\'/g,"'")},jt=12,_s=[0,2,4],Kl="~",ps=/^([A-G]#?)(m|dim)?$/,De=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],jl={major:Gt,minor:xt},Yl={major:["","m","m","","","m","dim"],minor:["m","dim","","m","m","",""]},fs=t=>{if(t===Kl)return null;const n=ps.exec(t);return n===null?void 0:{rootPitch:De.indexOf(n[1]),suffix:n[2]??""}},Es=(t,n,l)=>{if(t===null)return 0;const o=(t.rootPitch-n+jt)%jt,a=jl[l].indexOf(o);return a!==-1&&Yl[l][a]===t.suffix?a:void 0},hs=(t,n,l)=>{const o=t.map(a=>Es(a,n,l));return o.every(a=>a!==void 0)?{key:De[n],scaleType:l,degrees:o}:null},Ss=t=>t.degrees[0]===0,gs=t=>{const n=t.trim();if(!n.startsWith("<")||!n.endsWith(">"))return null;const l=n.slice(1,-1).trim().split(/\s+/).map(fs);if(l.some(r=>r===void 0)||l.every(r=>r===null))return null;const o=Ke.flatMap(r=>De.map((c,i)=>hs(l,i,r.value))).filter(r=>r!==null),a=o.find(Ss)??o[0];if(a===void 0)return null;const s=l.some(r=>r===null);return{kind:"chords",key:a.key,octave:4,scaleType:a.scaleType,chordProgression:a.degrees,chordSymbols:!0,...s?{chordNotes:a.degrees.map((r,c)=>l[c]===null?[]:_s.map(i=>r+i))}:{}}},ks=t=>{const n=De.indexOf(t.key),l=jl[t.scaleType];return`<${Je(t).map(a=>{if(a.length===0)return Kl;const s=a[0]%l.length;return`${De[(n+l[s])%jt]}${Yl[t.scaleType][s]}`}).join(" ")}>`},bs="~",H=t=>Number.isFinite(t)?Math.round(t*100)/100:0,ql=t=>{if(!Number.isFinite(t))return"0.0";if(Math.abs(t)>=1e4)return`${(t/1e3).toFixed(1)}k`;if(Math.abs(t)>=1e3)return`${(t/1e3).toFixed(2)}k`;if(Math.abs(t)>=100)return t.toFixed(0);if(Math.abs(t)>=10)return t.toFixed(1);const n=t.toFixed(2);return n.endsWith("0")?n.slice(0,-1):n},Ts=(t,n,l)=>{const o=(t??[]).map((s,r)=>s?String(r):null).filter(s=>s!==null),a=l.columnModifiers[n]??"";return o.length===0?`[~]${a}`:`[${o.join(l.mode==="arp"?" ":", ")}]${a}`},Ls=t=>{const n=Math.max(1,Math.min(t.steps,t.grid.length)),l=t.grid.slice(0,n).map((a,s)=>Ts(a,s,t));if(l.every(a=>a.startsWith("[~]")))return"";const o=`${t.key}${t.octave}:${t.scaleType}`;return`n(${JSON.stringify(l.join(" "))}).scale(${JSON.stringify(o)})`},ws=(t,n)=>{const l=t.steps.slice(0,n);if(!l.some(a=>a))return"";const o=l.map((a,s)=>a?`${t.sound}${t.modifiers[s]??""}`:bs);return`s(${JSON.stringify(o.join(" "))})`},ys=t=>{const n=t.rows.map(l=>ws(l,t.steps)).filter(l=>l.length>0);return n.length===0?"":n.length===1?n[0]:`stack(${n.join(", ")})`},Fs=t=>{const n=Je(t);if(n.every(a=>a.length===0))return"";if(t.chordSymbols===!0)return`chord(${JSON.stringify(ks(t))})`;const l=n.map(a=>a.length>0?`[${a.join(",")}]`:"~"),o=`${t.key}${t.octave}:${t.scaleType}`;return`n(${JSON.stringify(`<${l.join(" ")}>`)}).scale(${JSON.stringify(o)})`},Zl=(t,n)=>n.trim().length===0?"":`${t}(${JSON.stringify(n.trim())})`,Bs=t=>{const n=t.code.trim().replace(/;+\s*$/,"");return n.length===0?"":n.includes(`
|
|
7
|
+
`)?`(
|
|
8
|
+
${n}
|
|
9
|
+
)`:`(${n})`},$s=(t,n)=>n.length===0?"":`${n}.sound(${JSON.stringify(t.sound)})`,Rs=(t,n)=>n.length===0?"":`${n}.lpf(${H(t.cutoff)}).lpq(${H(t.resonance)})`,Os=(t,n)=>n.length===0?"":`${n}.delay(${H(t.mix)}).delaytime(${H(t.time)}).delayfeedback(${H(t.feedback)})`,Ns=(t,n)=>n.length===0?"":`${n}.room(${H(t.room)}).roomsize(${H(t.roomSize)}).roomfade(${H(t.roomFade)}).roomlp(${H(t.roomLowPass)}).roomdim(${H(t.roomDim)})`,Cs=(t,n)=>n.length===0?"":`${n}.gain(${H(t.gain)})`,As=(t,n)=>n.length===0?"":`${n}.pan(${H(t.pan)}).postgain(${H(t.postgain)})`,Ds=(t,n)=>{const l=t.argument.trim();return n.length===0||l.length===0?n:`${n}.mask(${l})`},Ms=(t,n)=>{const l=t.argument.trim();return n.length===0||l.length===0?n:`${n}.struct(${l})`},Us=(t,n)=>n.length===0?"":`${n}.slow(${H(t.amount)})`,Ps=(t,n)=>n.length===0?"":`${n}.attack(${H(t.attack)}).decay(${H(t.decay)}).sustain(${H(t.sustain)}).release(${H(t.release)})`,Is=(t,n)=>{if(n.length===0)return"";const l=t.placement==="inline"?"_":"";return`${n}.${l}${t.visual}(${t.options.trim()})`},Vs=t=>t.filter(n=>n.method.trim().length>0).map(n=>`.${n.method.trim()}(${n.argument.trim()})`).join(""),Ws={pad:Ls,beats:ys,chords:Fs,notes:t=>Zl(t.head??"note",t.pattern),samples:t=>Zl("s",t.pattern),code:Bs,voice:$s,filter:Rs,delay:Os,space:Ns,gain:Cs,level:As,mask:Ds,struct:Ms,slow:Us,voicing:(t,n)=>n.length===0?"":`${n}.voicing()`,envelope:Ps,visualizer:Is,effect:(t,n)=>n.length===0?"":`${n}${Vs(t.calls)}`},Hs=(t,n)=>Ws[t.kind](t,n),Me=(t,n)=>Hs(t,n),Gs=/^-?(\d+\.?\d*|\.\d+)(\/(\d+\.?\d*|\.\d+))?$/,xs=/^(["'])(<?)\s*([01](?:!\d+)?(?:\s+[01](?:!\d+)?)*)\s*(>?)\1$/,Xs=64,zs=t=>{if(!Gs.test(t))return null;const[n,l]=t.split("/").map(Number),o=l===void 0?n:n/l;return Number.isFinite(o)?o:null},Ks=(t,n)=>{const l=xs.exec(n);if(l===null||l[2]==="<"!=(l[4]===">"))return null;const o=l[3].split(/\s+/).flatMap(a=>{const[s,r]=a.split("!");return Array.from({length:Number(r??1)},()=>s==="1")});return o.length>Xs?null:{kind:"toggles",label:t,steps:o,perCycle:l[2]==="<",...l[3].includes("!")?{repeated:!0}:{}}},js=(t,n)=>{if(t.kind==="text")return n.length===0?null:{...t,value:n};if(t.kind==="toggles")return Ks(t.label,n);const l=zs(n);return l===null?null:{...t,value:l}},Yt=t=>{const n=Wn[t.method.trim()],l=Q(t.argument,",").map(a=>a.trim());if(n===void 0||l.length!==n.length)return null;const o=n.map((a,s)=>js(a,l[s]));return o.every(a=>a!==null)?o:null},Jl=t=>t?"1":"0",Ys=t=>t.reduce((n,l)=>{var o,a;return((o=n.at(-1))==null?void 0:o.step)===l?[...n.slice(0,-1),{step:l,length:(((a=n.at(-1))==null?void 0:a.length)??0)+1}]:[...n,{step:l,length:1}]},[]).map(n=>`${Jl(n.step)}${n.length>1?`!${n.length}`:""}`),qs=t=>{if(t.kind==="number")return String(H(t.value));if(t.kind==="text")return t.value;const n=(t.repeated===!0?Ys(t.steps):t.steps.map(Jl)).join(" ");return t.perCycle?`"<${n}>"`:`"${n}"`},qt=t=>t.map(qs).join(", "),Ql=["pad","beats","chords","notes","samples","code"],Zs=[[0,7],[1,5],[2,3],[3,1],[4,3],[5,2],[6,6],[7,3]],Js=new Set(Zs.map(([t,n])=>`${t}:${n}`)),Qe=()=>Array.from({length:xe},(t,n)=>Array.from({length:Xe},(l,o)=>Js.has(`${n}:${o}`))),ne={kind:"pad",steps:8,mode:"arp",octave:3,key:"C",scaleType:"major",grid:Qe(),columnModifiers:{}},pe={kind:"chords",key:"C",octave:4,scaleType:"major",chordProgression:[0,5,3,4]},ve={kind:"notes",pattern:"c3 [e3 g3] a3 [g3 e3]",notation:"auto"},Zt={kind:"samples",pattern:"bd*2 [~ sd] bd sd"},et={kind:"code",code:'n("<[0,2,4,6] [5,7,9,11]>").scale("C3:major").slow(2)'},Jt={kind:"voice",sound:"triangle"},Qt={kind:"effect",calls:[{method:"fast",argument:"2"}]},tt={kind:"filter",cutoff:1500,resonance:1},Ue={kind:"delay",mix:.5,time:.25,feedback:.4},le={kind:"space",room:.4,roomSize:2,roomFade:.5,roomLowPass:1e4,roomDim:8e3},vt={kind:"gain",gain:1},nt={kind:"level",pan:.5,postgain:1},en={kind:"mask",argument:'"<1 1 1 0>"'},tn={kind:"struct",argument:'"x ~ x x ~ x x ~"'},nn={kind:"slow",amount:2},vl={kind:"voicing"},fe={kind:"envelope",attack:.1,decay:.1,sustain:.7,release:.2},ln={kind:"visualizer",visual:"pianoroll",placement:"inline",options:""},Ee=(t,n=[])=>({sound:t,steps:Array.from({length:X},(l,o)=>n.includes(o)),modifiers:{}}),on=()=>Pn.map(t=>Ee(t.sound,t.hits)),Qs={pad:()=>({...ne,grid:Qe(),columnModifiers:{}}),beats:()=>({kind:"beats",steps:kt,rows:on(),showModifiers:!1}),chords:()=>({...pe,chordProgression:[0,5,3,4]}),notes:()=>({...ve}),samples:()=>({...Zt}),code:()=>({...et}),voice:()=>({...Jt}),filter:()=>({...tt}),delay:()=>({...Ue}),space:()=>({...le}),gain:()=>({...vt}),level:()=>({...nt}),mask:()=>({...en}),struct:()=>({...tn}),slow:()=>({...nn}),voicing:()=>({...vl}),envelope:()=>({...fe}),visualizer:()=>({...ln}),effect:()=>({...Qt,calls:Qt.calls.map(t=>({...t}))})},he=t=>Qs[t](),K=t=>Ql.includes(t),vs=t=>!Ql.includes(t),er=["pad","beats","chords","notes","samples","code","voice","filter","delay","space","gain","level","mask","struct","slow","voicing","envelope","visualizer","effect"],tr=(t,n)=>Array.isArray(t)&&t.length===X&&t.every(l=>typeof l=="boolean")?t:n,nr=t=>typeof t=="string"&&t.length>0&&$e.some(n=>n.value===t),eo=t=>Y(t)?Object.fromEntries(Object.entries(t).flatMap(([n,l])=>{const o=Number(n);return Number.isInteger(o)&&o>=0&&o<X&&nr(l)?[[o,l]]:[]})):{},lr=t=>{if(!Y(t))return null;const n=x(t.sound??t.instrument,"").trim();return n.length===0?null:{sound:n,steps:tr(t.steps,Ee(n).steps),modifiers:eo(t.modifiers)}},or=t=>{const n=(Array.isArray(t)?t:[]).map(lr).filter(l=>l!==null).slice(0,Re);return n.length>0?n:on()},lt=(t,n,l,o)=>Math.round(W(t,n,l,o)),ar=t=>{const n=Qe();return Array.isArray(t)?Array.from({length:xe},(l,o)=>{const a=t[o];return Array.from({length:Xe},(s,r)=>Array.isArray(a)?a[r]===!0:!1)}):n},sr=t=>{const n=pe.chordProgression;return!Array.isArray(t)||t.length===0||t.length>X||!t.every(l=>Number.isInteger(l)&&l>=0&&l<=6)?n:t},rr=t=>{if(!(!Array.isArray(t)||t.length===0||t.length>X||!t.every(n=>Array.isArray(n)&&n.every(l=>Number.isInteger(l)&&l>=0&&l<28))))return t.map(n=>[...n].sort((l,o)=>l-o))},to=t=>typeof t=="string"&&er.some(n=>n===t),Se=t=>t.muted===!0?{muted:!0}:{},cr=t=>({...Se(t),kind:"pad",steps:lt(t.steps,ne.steps,1,xe),mode:ue([{value:"arp"},{value:"chord"}],t.mode,ne.mode),octave:lt(t.octave,ne.octave,1,8),key:ue(ce,t.key,ne.key),scaleType:ue(ie,t.scaleType,ne.scaleType),grid:ar(t.grid),columnModifiers:eo(t.columnModifiers)}),ir=t=>{const n=rr(t.chordNotes);return{...Se(t),kind:"chords",key:ue(ce,t.key,pe.key),octave:lt(t.octave,pe.octave,1,8),scaleType:ue(Ke,t.scaleType,pe.scaleType),chordProgression:sr(t.chordProgression),...n===void 0?{}:{chordNotes:n},...t.chordSymbols===!0?{chordSymbols:!0}:{}}},dr=t=>Y(t)&&typeof t.method=="string"&&typeof t.argument=="string",mr=t=>Array.isArray(t)?t.filter(dr).map(n=>({method:n.method,argument:n.argument})):[],ur={pad:cr,beats:t=>({...Se(t),kind:"beats",steps:lt(t.steps,kt,1,X),rows:or(t.rows),showModifiers:t.showModifiers===!0}),chords:ir,notes:t=>{var n;return{...Se(t),kind:"notes",pattern:x(t.pattern,ve.pattern),notation:((n=Oe.find(l=>l.value===t.notation))==null?void 0:n.value)??ve.notation,...t.head==="chord"?{head:"chord"}:{},...t.showPattern===!0?{showPattern:!0}:{}}},samples:t=>({...Se(t),kind:"samples",pattern:x(t.pattern,Zt.pattern),...t.showPattern===!0?{showPattern:!0}:{}}),code:t=>({...Se(t),kind:"code",code:x(t.code,et.code)}),voice:t=>({kind:"voice",sound:x(t.sound,Jt.sound)}),filter:t=>({kind:"filter",cutoff:W(t.cutoff,tt.cutoff,Nn,Cn),resonance:W(t.resonance,tt.resonance,An,Dn)}),delay:t=>({kind:"delay",mix:W(t.mix,Ue.mix,0,1),time:W(t.time,Ue.time,0,1),feedback:W(t.feedback,Ue.feedback,0,1)}),space:t=>({kind:"space",room:W(t.room,le.room,0,1),roomSize:W(t.roomSize,le.roomSize,0,Mn),roomFade:W(t.roomFade,le.roomFade,0,10),roomLowPass:W(t.roomLowPass,le.roomLowPass,0,2e4),roomDim:W(t.roomDim,le.roomDim,0,2e4)}),gain:t=>({kind:"gain",gain:W(t.gain,vt.gain,0,2)}),mask:t=>({kind:"mask",argument:x(t.argument,en.argument)}),struct:t=>({kind:"struct",argument:x(t.argument,tn.argument)}),slow:t=>({kind:"slow",amount:W(t.amount,nn.amount,.25,8)}),voicing:()=>({kind:"voicing"}),level:t=>({kind:"level",pan:W(t.pan,nt.pan,0,1),postgain:W(t.postgain,nt.postgain,0,2)}),envelope:t=>({kind:"envelope",attack:W(t.attack,fe.attack,0,2),decay:W(t.decay,fe.decay,0,2),sustain:W(t.sustain,fe.sustain,0,1),release:W(t.release,fe.release,0,2)}),visualizer:t=>{var n;return{kind:"visualizer",visual:((n=Be.find(l=>l.value===t.visual))==null?void 0:n.value)??ln.visual,placement:t.placement==="background"?"background":"inline",options:x(t.options,"")}},effect:t=>({kind:"effect",calls:t.calls===void 0&&typeof t.method=="string"?[{method:t.method,argument:x(t.argument,"")}]:mr(t.calls)})},no=(t,n)=>{const l=Y(n)?n:{};return ur[t](l)},ot=[{kind:"pad",title:"Pad",category:"Instruments",description:"An eight-step note grid on a key and scale."},{kind:"beats",title:"Beats",category:"Instruments",description:"Drum tracks of any sample, such as cp or 808bd, on a step grid."},{kind:"chords",title:"Chords",category:"Instruments",description:"A chord progression with editable scale degrees."},{kind:"notes",title:"Notes",category:"Instruments",description:"A note line in mini notation, such as c3 [e3 g3]."},{kind:"samples",title:"Samples",category:"Instruments",description:"A line of samples, rests and groups, such as bd*2 [~ sd]."},{kind:"code",title:"Code",category:"Instruments",description:"One custom Strudel expression."},{kind:"voice",title:"Voice",category:"Sounds",description:"The synth or sample bank that plays the notes."},{kind:"filter",title:"Filter",category:"Effects",description:"A low-pass filter and its resonance."},{kind:"delay",title:"Delay",category:"Effects",description:"A feedback delay with mix and time."},{kind:"space",title:"Space",category:"Effects",description:"A room reverb with size, fade and damping."},{kind:"gain",title:"Gain",category:"Effects",description:"How loud the pattern plays."},{kind:"level",title:"Level",category:"Effects",description:"Stereo pan and postgain."},{kind:"mask",title:"Mask",category:"Effects",description:"Which steps or cycles of the pattern play, such as <1 1 1 0>."},{kind:"struct",title:"Struct",category:"Effects",description:"Which steps of the pattern hit, picked with switches."},{kind:"slow",title:"Slow",category:"Effects",description:"Stretches each cycle over more time."},{kind:"voicing",title:"Voicing",category:"Effects",description:"Spreads chord symbols into played notes."},{kind:"envelope",title:"Envelope",category:"Effects",description:"An attack, decay, sustain and release shape."},{kind:"visualizer",title:"Visualizer",category:"Effects",description:"A pianoroll, punchcard, scope, spiral, pitch wheel or spectrum of the pattern."},{kind:"effect",title:"Effect",category:"Effects",description:"Any other Strudel call, such as fast(2) or jux(rev)."}],lo=t=>ot.find(n=>n.kind===t)??ot[0],oe=t=>Number.isFinite(t)?Math.min(ye,Math.max(Ge,Math.round(t))):we,Pe=t=>St.some(n=>Number(n.value)===t)?t:J,_r={visiting:[],visited:[],ordered:[],hasCycle:!1},pr=t=>t.reduce((n,l)=>{const o=n.get(l.source)??[],a=n.get(l.target)??[];return new Map([...n,[l.source,[...o,l.target]],[l.target,[...a,l.source]]])},new Map),oo=(t,n)=>t.reduce((l,o)=>!n.includes(o.source)||!n.includes(o.target)?l:new Map([...l,[o.source,[...l.get(o.source)??[],o.target]]]),new Map),ao=(t,n,l)=>{if(l.includes(t))return{component:[],visited:l};const o=[...l,t];return(n.get(t)??[]).reduce((a,s)=>{const r=ao(s,n,a.visited);return{component:[...a.component,...r.component],visited:r.visited}},{component:[t],visited:o})},so=(t,n)=>{const l=pr(n);return t.reduce((o,a)=>{if(o.visited.includes(a.id))return o;const s=ao(a.id,l,o.visited);return{components:[...o.components,s.component],visited:s.visited}},{components:[],visited:[]}).components},ro=(t,n,l)=>{if(l.visiting.includes(t))return{...l,hasCycle:!0};if(l.visited.includes(t))return l;const o={...l,visiting:[...l.visiting,t]},a=(n.get(t)??[]).reduce((s,r)=>ro(r,n,s),o);return{visiting:a.visiting.filter(s=>s!==t),visited:[...a.visited,t],ordered:[t,...a.ordered],hasCycle:a.hasCycle}},co=(t,n)=>{const l=oo(n,t);return t.reduce((o,a)=>ro(a,l,o),_r)},fr=(t,n)=>t.find(l=>{const o=n.get(l.target);return o!==void 0&&K(o.data.kind)}),io=t=>"muted"in t.data&&t.data.muted===!0,Er=(t,n)=>t.map(l=>n.get(l)).filter(l=>l!==void 0).filter(l=>K(l.data.kind)),mo=(t,n,l)=>(n.get(t)??[]).reduce((o,a)=>o.includes(a)?o:mo(a,n,[...o,a]),l),hr=t=>{const n=Math.min(...t.map(l=>l.length));return Array.from({length:n},(l,o)=>o+1).findLast(l=>t.every(o=>o.slice(-l).join()===t[0].slice(-l).join()))??0},uo=(t,n,l)=>n.reduce((o,a)=>{const s=l.get(a);return s===void 0?o:Me(s.data,o)},t),Sr=(t,n,l)=>{const o=Er(t,l),a=o.length>0&&o.every(io),s=oo(n,t),r=co(t,n).ordered,c=o.flatMap(m=>{const u=Me(m.data,"");if(u.length===0)return[];const p=mo(m.id,s,[]);return[{nodeId:m.id,pattern:!a&&io(m)?`${u}.hush()`:u,effectIds:r.filter(S=>p.includes(S))}]});if(c.length===0)return null;const i=hr(c.map(m=>m.effectIds));return{label:a?"_$:":"$:",branches:c.map(m=>({nodeId:m.nodeId,pattern:m.pattern,effectIds:m.effectIds.slice(0,m.effectIds.length-i)})),sharedIds:c[0].effectIds.slice(c[0].effectIds.length-i)}},gr=(t,n)=>{const l=t.branches.map(o=>uo(o.pattern,o.effectIds,n));return`${t.label} ${uo(kr(l),t.sharedIds,n)}`},an=(t,n,l)=>so(t,n).flatMap(o=>{const a=Sr(o,n,l);return a===null?[]:[a]}),kr=t=>t.length===1?t[0]:`stack(${t.join(", ")})`,_o=t=>{const n=new Map(t.nodes.map(c=>[c.id,c]));if(fr(t.edges,n)!==void 0)return{code:"",errorMessage:"An instrument cannot take an input. Connect the effect to another effect instead."};if(!t.nodes.some(c=>K(c.data.kind)))return{code:"",errorMessage:"Add an instrument node such as Pad, Beats, Chords or Code to start a pattern."};if(so(t.nodes,t.edges).find(c=>co(c,t.edges).hasCycle)!==void 0)return{code:"",errorMessage:"Remove the loop from the flow: an effect cannot feed back into itself."};const a=an(t.nodes,t.edges,n).map(c=>gr(c,n));if(a.length===0)return{code:"",errorMessage:"The flow makes no sound yet. Turn on a drum step, add notes, or write an expression."};const s=`setcpm(${oe(t.beatsPerMinute)}/${Pe(t.beatsPerCycle)})`,r=t.setup.trim();return{code:[s,...r.length>0?[r]:[],...a].join(`
|
|
10
|
+
`),errorMessage:null}},po=(t,n)=>{const l=new Map(t.map(a=>[a.id,a])),o=an(t,n,l).flatMap(a=>[...a.branches.flatMap(s=>s.effectIds),...a.sharedIds]).flatMap(a=>{var r;const s=(r=l.get(a))==null?void 0:r.data;return(s==null?void 0:s.kind)==="visualizer"&&s.placement==="inline"?[{nodeId:a,call:`_${s.visual}`}]:[]});return Object.fromEntries(o.map(({nodeId:a,call:s},r)=>{const c=o.slice(0,r).filter(i=>i.call===s).length;return[a,`${In}${s}_${c}`]}))},fo=(t,n)=>{const l=new Map(t.map(o=>[o.id,o]));return an(t,n,l).flatMap(o=>[...o.branches.flatMap(a=>[a.nodeId,...a.effectIds]),...o.sharedIds])},Eo=(t,n,l,o=[])=>{if(t===n)return!0;if(o.includes(t))return!1;const a=[...o,t];return l.filter(s=>s.source===t).some(s=>Eo(s.target,n,l,a))},at=(t,n,l,o)=>{if(t===n)return!1;const a=l.find(r=>r.id===t),s=l.find(r=>r.id===n);return a===void 0||s===void 0||K(s.data.kind)||o.some(r=>r.source===t&&r.target===n)?!1:!Eo(n,t,o)},ho=(t,n,l)=>t.id!==void 0||at(t.source??"",t.target??"",n,l),sn=()=>({nodes:[{id:"pad-starter",type:"strudel",position:{x:80,y:120},data:he("pad")},{id:"voice-starter",type:"strudel",position:{x:640,y:120},data:he("voice")},{id:"filter-starter",type:"strudel",position:{x:640,y:420},data:he("filter")}],edges:[{id:"pad-starter-voice-starter",source:"pad-starter",target:"voice-starter"},{id:"voice-starter-filter-starter",source:"voice-starter",target:"filter-starter"}],beatsPerMinute:we,beatsPerCycle:J,setup:""}),br=t=>{if(!Y(t))return null;const n=x(t.id,""),l=Y(t.position)?t.position:{},o=Y(t.data)?t.data:{};return n.length===0||!to(o.kind)?null:{id:n,type:x(t.type,"strudel"),position:{x:W(l.x,0,-Fe,Fe),y:W(l.y,0,-Fe,Fe)},data:no(o.kind,o)}},Tr=t=>Array.isArray(t)?t.flatMap(n=>{const l=br(n);return l===null?[]:[l]}).reduce((n,l)=>n.some(o=>o.id===l.id)?n:[...n,l],[]):[],Lr=(t,n,l,o)=>{const a=x(t.id,"");return a.length>0&&!o.some(s=>s.id===a)?a:`${n}-${l}`},wr=(t,n,l)=>{if(!Y(t))return null;const o=x(t.source,""),a=x(t.target,"");return at(o,a,n,l)?{id:Lr(t,o,a,l),source:o,target:a}:null},yr=(t,n)=>Array.isArray(t)?t.reduce((l,o)=>{const a=wr(o,n,l);return a===null?l:[...l,a]},[]):[],So=t=>{if(t===null)return null;try{const n=JSON.parse(t);if(!Y(n)||!Array.isArray(n.nodes))return null;const l=Tr(n.nodes);return{nodes:l,edges:yr(n.edges,l),beatsPerMinute:oe(W(n.beatsPerMinute,we,Ge,ye)),beatsPerCycle:Pe(W(n.beatsPerCycle,J,1,ye)),setup:x(n.setup,"")}}catch{return null}},Fr={width:448,height:300},Br={pad:{width:448,height:540},beats:{width:704,height:320},chords:{width:416,height:520},notes:{width:384,height:440},samples:{width:480,height:320},code:{width:448,height:300},voice:{width:320,height:240},filter:{width:448,height:240},delay:{width:448,height:240},space:{width:448,height:460},gain:{width:256,height:220},level:{width:320,height:220},mask:{width:384,height:240},struct:{width:384,height:240},slow:{width:256,height:220},voicing:{width:256,height:140},envelope:{width:448,height:260},visualizer:{width:384,height:320},effect:{width:320,height:220}},ge=32,$r=40,Rr=1e3,st=t=>Br[t]??Fr,Ie=t=>{var l,o;const n=st(t.data.kind);return{width:((l=t.dimensions)==null?void 0:l.width)??n.width,height:((o=t.dimensions)==null?void 0:o.height)??n.height}},go=(t,n)=>t.x<n.x+n.width+ge&&n.x<t.x+t.width+ge&&t.y<n.y+n.height+ge&&n.y<t.y+t.height+ge,ko=(t,n)=>go({...t.position,...Ie(t)},{...n.position,...Ie(n)}),Or=(t,n)=>{const l=st(n),o=s=>t.every(r=>!go({...s,...l},{...r.position,...Ie(r)}));return Array.from({length:Rr},(s,r)=>Array.from({length:On},(c,i)=>({x:re+i*Rn,y:ze+r*$r}))).flat().find(o)??{x:re,y:ze}},Nr=t=>t.position.y+Ie(t).height,Cr=t=>t.position.x+Ie(t).width,Ar=(t,n)=>{const l=Nr(n)+ge-t.position.y,o=Cr(n)+ge-t.position.x;return o<l&&t.position.x>=n.position.x?{...t,position:{...t.position,x:t.position.x+o}}:{...t,position:{...t.position,y:t.position.y+l}}},Dr=t=>{const n=[...t].sort((l,o)=>l.position.y-o.position.y||l.position.x-o.position.x).reduce((l,o)=>{const a=l.find(s=>ko(o,s));return[...l,a===void 0?o:Ar(o,a)]},[]);return t.map(l=>n.find(o=>o.id===l.id)??l)},Mr=/^(?:const|let|var)\s+([$A-Z_a-z][\w$]*)\s*=\s*([\S\s]+?);?\s*$/,Ur=/^[$A-Z_a-z][\w$]*$/,Pr=/^arrange\s*\(([\S\s]*)\)$/,Ir=/^\[([\S\s]*)]$/,Vr=/^([\S\s]+)!(\d+)$/,Wr=new RegExp("(?<![\\w$.])(note|chord)\\(\\s*([$A-Z_a-z][\\w$]*)\\s*\\)","g"),Hr="silence",bo="~",Gr=8,xr=8,rn=t=>/\s/.test(t),cn=(t,n)=>n===0?t:cn(n,t%n),Xr=(t,n)=>t*n/cn(t,n),zr=t=>!t.includes("<")&&!t.includes("/")&&t!=="_"&&v(t,n=>n==="@").length<=1,Kr=t=>v(t,rn).length>1||v(t,n=>n===",").length>1?`[${t}]`:t,jr=t=>{const n=Vr.exec(t);return n===null?[t]:Array.from({length:Number(n[2])},()=>n[1])},Yr=t=>t.startsWith("<")&&t.endsWith(">")&&v(t,rn).length===1&&v(t,n=>n===",").length===1,qr=t=>{const n=Yr(t)?v(t.slice(1,-1),rn).flatMap(jr):[Kr(t)];return n.length>0&&n.every(zr)?n:null},Zr=t=>`<${t.reduce((n,l)=>{const o=n.at(-1);return(o==null?void 0:o.bar)===l?[...n.slice(0,-1),{bar:l,count:o.count+1}]:[...n,{bar:l,count:1}]},[]).map(({bar:n,count:l})=>l>1?`${n}!${l}`:n).join(" ")}>`,Jr=(t,n,l)=>{var u;const o=(u=Ir.exec(t.trim()))==null?void 0:u[1],[a,s,...r]=o===void 0?[]:Q(o,","),c=Number(a);if(s===void 0||r.length>0||!Number.isInteger(c)||c<1)return null;const i=dn(s,n,l+1),m=i===null?null:qr(i);return m===null?null:{cycles:c,bars:m}},Qr=(t,n,l)=>{const o=Q(t,",").map(r=>Jr(r,n,l));if(o.length===0||o.some(r=>r===null))return null;const a=o.filter(r=>r!==null),s=a.reduce((r,{cycles:c,bars:i})=>Xr(r,i.length/cn(c,i.length)),1);return s>xr?null:Zr(Array.from({length:s},(r,c)=>c).flatMap(r=>a.flatMap(({cycles:c,bars:i})=>Array.from({length:c},(m,u)=>i[(r*c+u)%i.length]??bo))))},dn=(t,n,l)=>{var r;const o=t.trim();if(l>Gr)return null;if(o===Hr)return bo;if(_e(o))return z(o);const a=Ur.test(o)?n.get(o):void 0;if(a!==void 0)return dn(a,n,l+1);const s=(r=Pr.exec(o))==null?void 0:r[1];return s===void 0?null:Qr(s,n,l)},vr=t=>new Map(t.flatMap(n=>{const l=Mr.exec(n.trim());return l===null?[]:[[l[1],l[2].trim()]]})),ec=(t,n)=>t.replace(Wr,(l,o,a)=>{const s=dn(a,n,0);return s===null?l:`${o}(${JSON.stringify(s)})`}),tc=48,nc=40,lc=64,To=96,oc={key:"C",octave:3,scaleType:"major"},ac="~",sc=new Map(Be.map(t=>t.value).flatMap(t=>[[`_${t}`,t],[t,t]])),Lo=/^(\d*[A-Za-z]\w*(?::\d+)?)(![2-4]|\/[2-4]|@[2-4]|\*[2-4])?$/,rc={Db:"C#",Eb:"D#",Gb:"F#",Ab:"G#",Bb:"A#"},cc=new Set(["sound","s"]),ic="mask",dc="struct",mc="slow",uc="voicing",mn=new Set(["s","sound"]),un="chord",rt=/^(_?\$|[A-Z_a-z]\w*)\s*:(?!:)\s*/,wo=/^(const|let|var|function|async|await|import|class)\b/,_c=/^setc(pm|ps)\s*\(([^)]*)\)$/,pc={lpf:{kind:"filter",field:"cutoff"},lpq:{kind:"filter",field:"resonance"},delay:{kind:"delay",field:"mix"},delaytime:{kind:"delay",field:"time"},delayfeedback:{kind:"delay",field:"feedback"},room:{kind:"space",field:"room"},roomsize:{kind:"space",field:"roomSize"},roomfade:{kind:"space",field:"roomFade"},roomlp:{kind:"space",field:"roomLowPass"},roomdim:{kind:"space",field:"roomDim"},gain:{kind:"gain",field:"gain"},pan:{kind:"level",field:"pan"},postgain:{kind:"level",field:"postgain"},attack:{kind:"envelope",field:"attack"},decay:{kind:"envelope",field:"decay"},sustain:{kind:"envelope",field:"sustain"},release:{kind:"envelope",field:"release"}},yo=t=>{const n=/^\s*([$A-Z_a-z][\w$]*)\s*\(([\S\s]*)\)\s*$/.exec(t);return n===null?null:{name:n[1],argument:n[2].trim()}},Fo=t=>{const n=Number(t.trim());return t.trim().length>0&&Number.isFinite(n)?n:null},Bo=t=>ds(t)?t.slice(1,-1).trim():null,fc=t=>{const n=/^([A-G][#b]?)(-?\d+):(.+)$/.exec(t);if(n===null)return oc;const l=rc[n[1]]??n[1];return{key:ce.some(o=>o.value===l)?l:"C",octave:Math.min(8,Math.max(1,Number(n[2]))),scaleType:ie.some(o=>o.value===n[3])?n[3]:"major"}},Ec=t=>{const n=/^\[([^\]]*)](![2-4]|\/[2-4]|@[2-4]|\*[2-4])?$/.exec(t);if(n===null)return null;const l=n[1].split(/[\s,]+/).filter(a=>a.length>0&&a!=="~").map(Number);if(l.some(a=>!Number.isInteger(a)||a<0||a>7))return null;const o=$e.some(a=>a.value===n[2])?n[2]??"":"";return{notes:l,modifier:o}},hc=(t,n)=>{const o=Q(t," ").map(Ec);if(o.length===0||o.length>16||o.some(s=>s===null))return null;const a=o.filter(s=>s!==null);return{kind:"pad",steps:a.length,mode:t.includes(",")?"chord":"arp",...n,grid:Array.from({length:16},(s,r)=>Array.from({length:8},(c,i)=>{var m;return((m=a[r])==null?void 0:m.notes.includes(i))??!1})),columnModifiers:Object.fromEntries(a.flatMap((s,r)=>s.modifier.length>0?[[r,s.modifier]]:[]))}},Sc=t=>{if(t==="~")return[];const n=/^\[([^\]]*)]$/.exec(t);if(n===null)return null;const l=Q(n[1],",").map(Number);return l.every(o=>Number.isInteger(o)&&o>=0&&o<28)?l:null},gc=(t,n)=>{if(!t.startsWith("<")||!t.endsWith(">"))return null;const l=Q(t.slice(1,-1)," ").map(Sc);if(l.length===0||l.length>16||l.some(r=>r===null))return null;const o=l.filter(r=>r!==null),a=o.map(r=>(r[0]??0)%7),s=o.some((r,c)=>r.join(",")!==[0,2,4].map(i=>i+a[c]).join(","));return{kind:"chords",key:n.key,octave:n.octave,scaleType:n.scaleType==="minor"?"minor":"major",chordProgression:a,...s?{chordNotes:o}:{}}},_n=(t,n)=>({kind:"beats",steps:n,rows:t,showModifiers:t.some(l=>Object.keys(l.modifiers).length>0)}),kc=t=>{if(t===ac)return[];const n=/^\[([^\]]+)]$/.exec(t),l=(n===null?[t]:n[1].split(",")).map(o=>Lo.exec(o.trim()));return l.every(o=>o!==null)?l.map(o=>({sound:(o==null?void 0:o[1])??"",modifier:(o==null?void 0:o[2])??""})):null},bc=t=>{if(!mn.has(t.name)||!_e(t.argument))return null;const n=z(t.argument).trim().split(/\s+/),l=n.map(kc);if(n.length>X||l.some(s=>s===null))return null;const o=l.map(s=>s??[]),a=[...new Set(o.flat().map(s=>s.sound))];return a.length===0||a.length>Re?null:_n(a.map(s=>({...Ee(s),steps:Array.from({length:X},(r,c)=>(o[c]??[]).some(i=>i.sound===s)),modifiers:Object.fromEntries(o.flatMap((r,c)=>r.filter(i=>i.sound===s&&i.modifier.length>0).map(i=>[c,i.modifier])))})),n.length)},Tc=(t,n)=>{if(!mn.has(t.name)||n===void 0||!_e(t.argument))return null;const l=z(t.argument),o=z(n.argument).split(/\s+/);if(!Lo.test(l)||o.length>X)return null;const a=o.flatMap((s,r)=>s==="1"?[r]:[]);return _n([Ee(l,a)],o.length)},$o=t=>{const[n]=t.instruments;return t.instruments.length===1&&t.effects.length===0&&(n==null?void 0:n.kind)==="beats"&&n.muted!==!0?n:null},Lc=t=>t.reduce((n,l)=>{const o=n.at(-1),a=o===void 0?null:$o(o),s=$o(l);return a===null||s===null||a.steps!==s.steps||a.rows.length+s.rows.length>Re?[...n,l]:[...n.slice(0,-1),ee(_n([...a.rows,...s.rows],s.steps))]},[]),Ro=t=>{const n=Bo(t.trim());return n===null?t.trim():Ro(n)},ct=t=>({kind:"code",code:Ro(t)}),wc=(t,n)=>n&&K(t.kind)?Object.assign({},t,{muted:!0}):t,ee=t=>({instruments:[t],effects:[]}),yc=t=>{const n=fn(t);if(n.effects.length===0)return n.branches;const[l]=n.branches;return n.branches.length===1&&l!==void 0?[{...l,effects:[...l.effects,...n.effects]}]:[ee(ct(t))]},Oo=(t,n)=>t.map(l=>({...l,instruments:l.instruments.map(o=>wc(o,n))})),Fc=t=>Lc(Q(t,",").flatMap(yc)),Bc=(t,n)=>{const l=n.find(s=>s.name==="scale");if(t.name!=="n"||l===void 0||!_e(t.argument))return null;const o=z(t.argument),a=fc(z(l.argument));return o.startsWith("<")?gc(o,a):hc(o,a)},$c=t=>{if(!_e(t.argument))return null;if(t.name==="note")return{kind:"notes",pattern:z(t.argument),notation:"auto"};const n=t.name===un?gs(z(t.argument)):null;return n!==null?n:t.name===un?{kind:"notes",pattern:z(t.argument),notation:"names",head:un}:mn.has(t.name)?{kind:"samples",pattern:z(t.argument)}:null},No=(t,n)=>{const l=t.findIndex(o=>o.name===n);return l===-1?t:[...t.slice(0,l),...t.slice(l+1)]},Rc=(t,n)=>{const l=yo(t);if(l===null)return{branches:[ee(ct(t))],remaining:n};const o=Tc(l,n.find(c=>c.name==="struct"));if(o!==null)return{branches:[ee(o)],remaining:No(n,"struct")};const a=Bc(l,n);if(a!==null)return{branches:[ee(a)],remaining:No(n,"scale")};if(l.name==="stack")return{branches:Fc(l.argument),remaining:n};const s=bc(l);if(s!==null)return{branches:[ee(s)],remaining:n};const r=$c(l);return{branches:[ee(r??ct(t))],remaining:n}},Co=(t,n,l)=>Object.assign({},t,{[n]:l}),Oc=(t,n)=>[...t.slice(0,-1),n],Nc=(t,n)=>({...t,effects:[...t.effects,{kind:"effect",calls:[{method:n.name,argument:n.argument}]}],fieldsOnLast:[]}),pn={[ic]:t=>t.argument.length>0?{kind:"mask",argument:t.argument}:null,[dc]:t=>t.argument.length>0?{kind:"struct",argument:t.argument}:null,[mc]:t=>{const n=Fo(t.argument);return n===null?null:{kind:"slow",amount:n}},[uc]:t=>t.argument.length===0?{kind:"voicing"}:null},Cc=t=>{if(cc.has(t.name)&&_e(t.argument))return{kind:"voice",sound:z(t.argument)};const n=sc.get(t.name);return n===void 0?null:{kind:"visualizer",visual:n,placement:t.name.startsWith("_")?"inline":"background",options:t.argument}},Ac=t=>{var n;return((n=pn[t.name])==null?void 0:n.call(pn,t))??Cc(t)},Dc=(t,n)=>{const l=Ac(n);if(l!==null)return{...t,effects:[...t.effects,l],fieldsOnLast:[]};const o=pc[n.name],a=Fo(n.argument);if(o===void 0||a===null)return Nc(t,n);const s=t.effects.at(-1);return(s==null?void 0:s.kind)===o.kind&&!t.fieldsOnLast.includes(o.field)?{...t,effects:Oc(t.effects,Co(s,o.field,a)),fieldsOnLast:[...t.fieldsOnLast,o.field]}:{...t,effects:[...t.effects,Co(he(o.kind),o.field,a)],fieldsOnLast:[o.field]}},Ao=(t,n)=>{const l=n.some(a=>a.name==="hush"),o=n.filter(a=>a.name!=="hush").reduce(Dc,{...t,fieldsOnLast:[]});return{branches:Oo(o.branches,l),effects:o.effects}},fn=t=>{const n=Q(t,"."),l=n.slice(1).map(yo);if(n.length===0||l.some(c=>c===null))return{branches:[ee(ct(t))],effects:[]};const o=l.filter(c=>c!==null),a=Bo(n[0]);if(a!==null)return Ao(fn(a),o);const s=Rc(n[0],o.filter(c=>c.name!=="hush")),r=o.some(c=>c.name==="hush");return Ao({branches:s.branches,effects:[]},r?[...s.remaining,{name:"hush",argument:""}]:s.remaining)},Mc=t=>t.split("/").map(n=>Number(n.trim())),En=t=>{const n=_c.exec(t);if(n===null)return null;const l=Mc(n[2]);if(l.some(s=>!Number.isFinite(s)||s<=0))return null;if(n[1]==="pm"&&l.length===2)return{beatsPerMinute:oe(l[0]),beatsPerCycle:Pe(l[1])};const o=l.slice(1).reduce((s,r)=>s/r,l[0]),a=n[1]==="pm"?o:o*60;return{beatsPerMinute:oe(a*J),beatsPerCycle:J}},Uc=t=>{const n=Xl(Kt(t)),l=n.map(En).find(c=>c!==null)??{beatsPerMinute:we,beatsPerCycle:J},o=n.filter(c=>En(c)===null),a=o.filter(c=>rt.test(c));if(a.length>0)return{blocks:a.map(c=>({expression:c.replace(rt,""),muted:c.startsWith("_")})),setup:o.filter(c=>!rt.test(c)),tempo:l};const s=o.at(-1),r=s!==void 0&&!wo.test(s);return{blocks:r?[{expression:s,muted:!1}]:[],setup:r?o.slice(0,-1):o,tempo:l}},Pc=(t,n)=>{const l=t.reusable.findIndex(o=>o.data.kind===n);return l===-1?{node:null,reusable:t.reusable}:{node:t.reusable[l],reusable:[...t.reusable.slice(0,l),...t.reusable.slice(l+1)]}},Ic=(t,n)=>t.kind==="notes"&&(n==null?void 0:n.data.kind)==="notes"&&n.data.head===t.head?{...t,notation:n.data.notation,...n.data.showPattern===!0?{showPattern:!0}:{}}:t,Vc=(t,n)=>{const l=new Set(n.map(a=>a.id)),o=Array.from({length:n.length+1},(a,s)=>s+1).find(a=>!l.has(`${t}-${a}`))??n.length+1;return`${t}-${o}`},Do=(t,n,l)=>{var s;const o=Pc(t,n.kind),a=Vc(n.kind,t.nodes);return{nodeId:a,state:{...t,reusable:o.reusable,layoutPositions:o.node===null?t.layoutPositions:{...t.layoutPositions,[a]:l},nodes:[...t.nodes,{id:a,type:"strudel",position:((s=o.node)==null?void 0:s.position)??l,data:Ic(n,o.node)}]}}},Wc=(t,n,l)=>({...t,edges:[...t.edges,{id:`${n}-${l}`,source:n,target:l}]}),Hc=t=>t.kind==="effect"?lc+t.calls.length*nc:0,it=t=>st(t.kind).height+Hc(t)+tc,Gc=t=>Math.max(t.instruments.reduce((n,l)=>n+it(l),0),...t.effects.map(it)),Mo=t=>st(t.kind).width,Uo=(t,n,l)=>n.reduce((o,a)=>{const s=Do(o.state,a,{x:o.nextX,y:l});return{state:o.previousIds.reduce((r,c)=>Wc(r,c,s.nodeId),s.state),previousIds:[s.nodeId],nextX:o.nextX+Mo(a)+To}},t),xc=(t,n,l)=>{const o=n.instruments.reduce((s,r)=>{const c=Do(s.state,r,{x:re,y:s.y});return{state:c.state,previousIds:[...s.previousIds,c.nodeId],y:s.y+it(r)}},{state:t,previousIds:[],y:l}),a=Math.max(0,...n.instruments.map(Mo));return Uo({state:o.state,previousIds:o.previousIds,nextX:re+a+To},n.effects,l)},Xc=(t,n)=>{const l=n.branches.reduce((s,r)=>{const c=xc(s.state,r,s.y);return{state:c.state,tails:[...s.tails,...c.previousIds],y:s.y+Gc(r),rightEdge:Math.max(s.rightEdge,c.nextX)}},{state:t,tails:[],y:t.rowTop,rightEdge:re}),o=Uo({state:l.state,previousIds:l.tails,nextX:l.rightEdge},n.effects,t.rowTop),a=Math.max(0,...n.effects.map(it));return{...o.state,rowTop:Math.max(l.y,t.rowTop+a)}},Po=(t,n)=>{const l=r=>r.id in n,o=t.find(r=>l(r)&&t.some(c=>!l(c)&&ko(r,c)));if(o===void 0)return t;const{[o.id]:a,...s}=n;return Po(t.map(r=>r.id===o.id?{...r,position:a}:r),s)},zc=(t,n)=>{const l=o=>o.map(a=>a.data.kind).sort().join(",");return l(t)===l(n)},Io=(t,n=[])=>{if(!is(t))return null;const l=Uc(t),o=vr(l.setup),a=c=>l.blocks.map(i=>{const m=fn(ec(i.expression,o));return{...m,branches:Oo(m.branches,i.muted)}}).reduce(Xc,{nodes:[],edges:[],reusable:c,layoutPositions:{},rowTop:ze}),s=a([]),r=zc(s.nodes,n)?a(n):s;return{nodes:Po(r.nodes,r.layoutPositions),edges:r.edges,beatsPerMinute:l.tempo.beatsPerMinute,beatsPerCycle:l.tempo.beatsPerCycle,setup:l.setup.join(`
|
|
11
|
+
`)}},Kc=t=>{const n=Kt(t),l=Xl(n).filter(m=>En(m)===null),o=l.at(-1);if(o===void 0||wo.test(o)||l.some(m=>rt.test(m)))return t;const a=n.lastIndexOf(o.split(`
|
|
12
|
+
`)[0]),s=n.slice(0,a).split(`
|
|
13
|
+
`).length-1,r=a-(n.lastIndexOf(`
|
|
14
|
+
`,a-1)+1),c=t.split(`
|
|
15
|
+
`),i=c[s];return[...c.slice(0,s),`${i.slice(0,r)}$: ${i.slice(r)}`,...c.slice(s+1)].join(`
|
|
16
|
+
`)},jc=(t,n)=>{const l=t.trimEnd();return l.length===0?n:`${Kc(l)}
|
|
17
|
+
|
|
18
|
+
${n}`},Yc=()=>So(Pl(ht))??sn(),Vo=(t,n,l)=>n.some(o=>o.id===`${t}-${l}`)?Vo(t,n,l+1):`${t}-${l}`,qc=t=>({...t,nodes:t.nodes.map(n=>({id:n.id,type:n.type,position:{x:n.position.x,y:n.position.y},data:n.data})),edges:t.edges.map(n=>({id:n.id,source:n.source,target:n.target}))}),Zc=()=>{const t=Yc(),n=e.ref(t.nodes),l=e.ref(t.edges),o=e.ref(t.beatsPerMinute),a=e.ref(t.beatsPerCycle),s=e.ref(t.setup),r=()=>({nodes:n.value,edges:l.value,beatsPerMinute:o.value,beatsPerCycle:a.value,setup:s.value}),c=_=>{n.value=_.nodes,l.value=_.edges,o.value=_.beatsPerMinute,a.value=_.beatsPerCycle,s.value=_.setup},i=e.computed(()=>_o(r())),m=_=>{n.value=[...n.value,{id:Vo(_,n.value,1),type:"strudel",position:Or(n.value,_),data:he(_)}]},u=(_,g)=>{n.value=n.value.map(T=>T.id===_?{...T,data:g}:T)},p=_=>{n.value=n.value.filter(g=>g.id!==_),l.value=l.value.filter(g=>g.source!==_&&g.target!==_)},S=(_,g)=>at(_,g,n.value,l.value)?(l.value=[...l.value,{id:`${_}-${g}`,source:_,target:g}],!0):!1,E=_=>{o.value=oe(_)},b=_=>{a.value=Pe(_)},h=()=>{c(sn())},f=_=>{const g=Io(_,n.value);return g===null?!1:(c(g),!0)};return e.watch([n,l,o,a,s],()=>{Il(ht,JSON.stringify(qc(r())))},{deep:!0}),{nodes:n,edges:l,beatsPerMinute:o,beatsPerCycle:a,compilation:i,addNode:m,updateNodeData:u,removeNode:p,connectNodes:S,setBeatsPerMinute:E,setBeatsPerCycle:b,resetPatch:h,loadCode:f}},Jc=/^([a-g])([#bfs]*)(-?\d+)?$/i,Qc=/^-?\d+(\.\d+)?$/,Ve=12,vc=1e-6,ei=t=>{const n=(t%Ve+Ve)%Ve;return{...fl[n],octave:Math.floor(t/Ve)-1,midiNote:t}},dt=t=>{if(Qc.test(t))return ei(Math.round(Number(t)));const n=Jc.exec(t);if(n===null)return null;const[,l,o,a]=n,s=[...o].reduce((c,i)=>c+(_l.includes(i)?1:-1),0),r=Number(a??ul);return{letter:l.toLowerCase(),alteration:s,octave:r,midiNote:(r+1)*Ve+ml[l.toLowerCase()]+s}},hn=t=>{var n;return((n=dt(t))==null?void 0:n.midiNote)??null},Wo=t=>{const n=Array.from({length:pl},(o,a)=>a+1).find(o=>Math.abs(t*o-Math.round(t*o))<vc*o);if(n===void 0)return String(Math.round(t*100)/100);const l=Math.round(t*n);return n===1?String(l):`${l}/${n}`},ti=(t,n)=>n.flatMap((l,o)=>{const a=t-l;return a>=0&&a<=Gn?[{lineIndex:o,fret:a}]:[]}),ni=t=>t.reduce((n,l)=>n.flatMap(o=>l.filter(a=>!o.some(s=>s.lineIndex===a.lineIndex)).map(a=>[...o,a])),[[]]),li=t=>{const n=t.filter(l=>l.fret>0).map(l=>l.fret);return n.length===0||Math.max(...n)-Math.min(...n)<=xn},Ho=(t,n)=>t.reduce((l,o)=>l+Math.abs(o.fret-n),0),Go=(t,n)=>{const l=ni(t);if(l.length===0)return Go(t.slice(0,-1),n);const o=l.filter(li);return(o.length>0?o:l).reduce((a,s)=>Ho(s,n)<Ho(a,n)?s:a)},xo=(t,n)=>t.reduce((l,o)=>{const a=o.toSorted((c,i)=>c-i).map(c=>ti(c,n)).filter(c=>c.length>0),s=a.length===0?[]:Go(a,l.handFret),r=s.length===0?l.handFret:s.reduce((c,i)=>c+i.fret,0)/s.length;return{chords:[...l.chords,s],handFret:r}},{chords:[],handFret:0}).chords,Sn=t=>{var n;return((n=Xn.find(l=>t.toLowerCase().includes(l.word)))==null?void 0:n.view)??"names"},Xo=(t,n)=>t==="auto"?Sn(n):t,zo=(t,n,l,o)=>{const a=l.filter(c=>c.source===t&&!o.has(c.target)).map(c=>c.target),s=a.map(c=>{var i;return(i=n.find(m=>m.id===c))==null?void 0:i.data}).find(c=>(c==null?void 0:c.kind)==="voice");if((s==null?void 0:s.kind)==="voice")return s.sound;const r=new Set([...o,...a]);return a.reduce((c,i)=>c.length>0?c:zo(i,n,l,r),"")},Ko=(t,n,l)=>zo(t,n,l,new Set([t])),jo=t=>{const n=t.toSorted((l,o)=>l.start-o.start);return n.map((l,o)=>{var s;const a=((s=n[o+1])==null?void 0:s.start)??1/0;return{...l,beats:Math.min(l.beats,a-l.start)}})},gn=(t,n)=>t.reduce((l,o,a)=>{const s=t[a-1];return s!==void 0&&n(s,o)?[...l.slice(0,-1),[...l.at(-1),o]]:[...l,[o]]},[]),ke=1e-6,I=zn,Yo=Ne.length-1,qo=t=>Math.floor(t.start+ke),oi=t=>Ne.findIndex(n=>Math.abs(n*Bt/$t-t)<ke),ai=(t,n)=>{const l=t+n,o=Math.floor(t+ke)+1,a=Array.from({length:Math.max(0,Math.ceil(l-ke)-o)},(r,c)=>o+c),s=[t,...a,l];return s.slice(1).map((r,c)=>({start:s[c],beats:r-s[c]}))},si=t=>Ne.reduce((n,l)=>{const o=Math.floor((n.left+ke)/l);return{left:n.left-o*l,lengths:[...n.lengths,...Array.from({length:o},()=>l)]}},{left:t,lengths:[]}).lengths,ri=t=>{const n=oi(t.beats);if(n!==-1)return[{start:t.start,beats:t.beats,beams:n,isTriplet:!0}];const l=ai(t.start,t.beats).flatMap(o=>si(o.beats).reduce((a,s)=>{const r=a.reduce((c,i)=>c+i.beats,o.start);return[...a,{start:r,beats:s,beams:Ne.indexOf(s),isTriplet:!1}]},[]));return l.length>0?l:[{start:t.start,beats:t.beats,beams:Yo,isTriplet:!1}]},ci=(t,n)=>{const l=t.map(jo),o=l.flat().map(r=>r.notes.flatMap(c=>{const i=hn(c);return i===null?[]:[i]})),a=xo(o,n),s=l.map((r,c)=>l.slice(0,c).reduce((i,m)=>i+m.length,0));return l.map((r,c)=>r.map((i,m)=>({...i,positions:a[s[c]+m]})))},Zo=t=>(je+nl*t)*I,kn=(t,n)=>n>ke?{...t,x:t.x+Zo(n),restXs:[...t.restXs,t.x+je/2*I]}:t,ii=(t,n,l)=>{const o=kn(t,n.start-t.beat),a=n.start+n.beats;if(n.positions.length===0)return{...kn(o,n.beats),beat:a};const s=ri(n).reduce((r,c,i)=>{var m;return{x:r.x+Zo(c.beats),units:[...r.units,{...c,x:r.x+je/2*I,barIndex:l,positions:n.positions,tiedFromX:i===0?null:((m=r.units.at(-1))==null?void 0:m.x)??null}]}},{x:o.x,units:[]});return{...o,beat:a,x:s.x,units:[...o.units,...s.units]}},di=(t,n,l,o)=>{const a=t.reduce((s,r)=>ii(s,r,n),{beat:0,x:l,units:[],restXs:[]});return kn(a,o-a.beat)},mi=(t,n,l)=>t.reduce((o,a,s)=>{var S;const r=((S=o.at(-1))==null?void 0:S.endX)??n,c=s===0,i=s===t.length-1,m=r+(c?Lt*I:0),u=di(a,s,m,l),p=Math.max(u.x+(i?Lt*I:0),r+Ot*I);return[...o,{units:u.units,restXs:u.restXs,endX:p}]},[]),ui=(t,n)=>t-(wt/2+(n-1)*qn)*I,_i=(t,n)=>Array.from({length:Yo},(l,o)=>o+1).flatMap(l=>{const o=ui(n,l);return gn(t,(s,r)=>s.beams>=l&&r.beams>=l).filter(s=>s[0].beams>=l).map(s=>{if(s.length>1)return{x1:s[0].x,y1:o,x2:s.at(-1).x,y2:o};const r=s[0]===t[0]?1:-1;return{x1:s[0].x,y1:o,x2:s[0].x+r*Zn*I,y2:o}})}),pi=(t,n)=>gn(t,(l,o)=>l.beams>0&&o.beams>0&&l.barIndex===o.barIndex&&qo(l)===qo(o)).filter(l=>l[0].beams>0).flatMap(l=>_i(l,n)),fi=(t,n)=>gn(t,(l,o)=>l.isTriplet&&o.isTriplet&&l.barIndex===o.barIndex).filter(l=>l[0].isTriplet).map(l=>{const o=l[0].x-Ce*I,a=l.at(-1).x+Ce*I,s=(o+a)/2,r=n-Dt*I,c=At*I;return{labelX:s,path:[`M ${o} ${r} L ${o} ${n} L ${s-c} ${n}`,`M ${s+c} ${n} L ${a} ${n} L ${a} ${r}`].join(" ")}}),Ei=(t,n,l)=>{const o=l+vn*I,a=l+el*I,s=t+yt*I,r=n-tl*I;return`M ${s} ${o} Q ${(s+r)/2} ${a} ${r} ${o}`},hi=(t,n)=>{const l=[...String(t)],o=n-(l.length-1)*Ft*I/2;return l.map((a,s)=>({digit:a,x:o+s*Ft*I}))},Jo=t=>String(t).length*yt*I/2+Qn*I,Si=(t,n,l,o,a)=>{const r=l.filter(c=>c.lineIndex===t).map(c=>[c.x-Jo(c.fret),c.x+Jo(c.fret)]).toSorted((c,i)=>c[0]-i[0]).reduce((c,[i,m])=>({fromX:Math.max(c.fromX,m),segments:i>c.fromX?[...c.segments,{x1:c.fromX,y1:n,x2:i,y2:n}]:c.segments}),{fromX:o,segments:[]});return[...r.segments,{x1:r.fromX,y1:n,x2:a,y2:n}]},Qo=(t,n,l)=>{var b;const o=Hn[n],a=o.map((h,f)=>(Kn+f)*I),s=a.at(-1),r=I/2,c=mi(ci(t,o),r,l),i=((b=c.at(-1))==null?void 0:b.endX)??r+Ot*I,m=c.flatMap(h=>h.units),u=s+Yn*I,p=s+Jn*I,S=m.filter(h=>h.tiedFromX===null).flatMap(h=>h.positions.map(f=>({...f,x:h.x,y:a[f.lineIndex],digits:hi(f.fret,h.x)}))),E=m.flatMap(h=>h.tiedFromX===null?[]:h.positions.map(f=>Ei(h.tiedFromX,h.x,a[f.lineIndex])));return{width:i+I/2,height:s+dl*I,lineGap:I,strings:a.map((h,f)=>Si(f,h,S,r,i)),barLines:[r,...c.map(h=>h.endX)].map(h=>({x1:h,y1:a[0],x2:h,y2:s})),frets:S,stems:m.map(h=>({x:h.x})),rests:c.flatMap(h=>h.restXs).map(h=>({x:h-Nt/2*I,y:(a[0]+s-Ct*I)/2,width:Nt*I,height:Ct*I})),beams:pi(m,u),ties:E,brackets:fi(m,p),stemTop:s+jn*I,stemBottom:u,bracketLabelY:p+Ut*I}},mt=1e-6,B=kl,q=B/2,gi=Pt.length,vo=4,bn=8,ki=Bt/$t,ea=me[0].beats,bi=me.at(-1).beats,Ti=me.flatMap(t=>[{beats:t.beats*hl,value:t.beats,dotted:!0},{beats:t.beats,value:t.beats,dotted:!1}]).filter(t=>t.beats<=ea+mt).toSorted((t,n)=>n.beats-t.beats),ta=t=>{const n=Ti.find(l=>l.beats<=t+mt);return n===void 0?[]:[{...n,isTriplet:!1},...ta(t-n.beats)]},na=t=>{var o;const n=(o=me.find(a=>Math.abs(a.beats*ki-t)<mt))==null?void 0:o.beats;if(n!==void 0)return[{beats:t,value:n,dotted:!1,isTriplet:!0}];const l=ta(t);return l.length>0?l:[{beats:t,value:bi,dotted:!1,isTriplet:!1}]},ut=t=>Pt.indexOf(t.letter)+gi*t.octave,Li=t=>{const n=t.length===0||t.some(a=>a.midiNote>=Ye),l=t.some(a=>a.midiNote<Ye);return[...n?["treble"]:[],...l?["bass"]:[]].map((a,s)=>{const r=(bl+s*Ll)*B;return{clef:a,topY:r,bottomY:r+bn*q,bottomStep:El[a]}})},wi=(t,n)=>n.length===1||t.midiNote>=Ye?0:1,la=(t,n)=>t>mt?na(t).map(l=>({unit:l,notesByStaff:Array.from({length:n},()=>[]),isFirstUnit:!0,tiedForward:!1})):[],yi=(t,n,l)=>{const o=jo(t).reduce((a,s)=>{const r=s.notes.flatMap(m=>{const u=dt(m);return u===null?[]:[u]}),c=n.map((m,u)=>r.filter(p=>wi(p,n)===u)),i=na(s.beats);return{beat:s.start+s.beats,columns:[...a.columns,...la(s.start-a.beat,n.length),...i.map((m,u)=>({unit:m,notesByStaff:c,isFirstUnit:u===0,tiedForward:u<i.length-1}))]}},{beat:0,columns:[]});return[...o.columns,...la(l-o.beat,n.length)]},Fi=t=>t>0?"sharp":t<0?"flat":"natural",Bi=(t,n)=>{const l=Array.from({length:Math.max(0,Math.floor(-n/2))},(a,s)=>-2*(s+1)),o=Array.from({length:Math.max(0,Math.floor((n-bn)/2))},(a,s)=>bn+2*(s+1));return[...l,...o].map(a=>t.bottomY-a*q)},$i=(t,n,l,o)=>t.toSorted((a,s)=>ut(a)-ut(s)).reduce((a,s)=>{const r=String(ut(s)),c=ut(s)-n.bottomStep,i=o&&(a.signs.get(r)??0)!==s.alteration;return{signs:i?new Map(a.signs).set(r,s.alteration):a.signs,heads:[...a.heads,{y:n.bottomY-c*q,step:c,accidental:i?Fi(s.alteration):null,ledgerYs:Bi(n,c)}]}},{heads:[],signs:l}),Ri=(t,n,l)=>`M ${t} ${n} c ${.1*B} ${l*.8*B} ${1.1*B} ${l*B} ${.9*B} ${l*2*B}`,Oi=(t,n,l,o)=>{const a=me.find(p=>p.beats===n.unit.value),s=t.reduce((p,S)=>p+S.step,0)/t.length<vo,r=t.map(p=>p.y),c=s?-1:1,i=o+(s?1:-1)*It*B,m=s?Math.max(...r):Math.min(...r),u=(s?Math.min(...r):Math.max(...r))+c*Rl*B;return{x:o,staffIndex:l,heads:t.map(({y:p,accidental:S,ledgerYs:E})=>({y:p,accidental:S,ledgerYs:E})),filled:a.filled,stem:a.stem?{x1:i,y1:m,x2:i,y2:u}:null,flags:Array.from({length:a.flags},(p,S)=>Ri(i,u-c*S*Ol*B,-c)),dots:n.unit.dotted?t.map(p=>({x:o+Cl*B,y:p.step%2===0?p.y-q:p.y})):[],isTriplet:n.unit.isTriplet,tiedForward:n.tiedForward}},Ni=(t,n,l)=>{const o=l.topY+vo*q;if(t>=2){const r=t===ea?l.topY+B:o-q;return`M ${n-.6*B} ${r} h ${1.2*B} v ${q} h ${-1.2*B} Z`}if(t===1)return`M ${n-.2*B} ${o-1.5*B} l ${.6*B} ${.8*B} l ${-.5*B} ${.6*B} l ${.5*B} ${.8*B} c ${-.6*B} ${-.3*B} ${-.9*B} ${.2*B} ${-.3*B} ${.8*B}`;const a=Math.round(Math.log2(1/t));return[...Array.from({length:a},(r,c)=>{const i=o-.6*B+c*.7*B,m=n-.35*B,u=.16*B;return[`M ${m-u} ${i} a ${u} ${u} 0 1 0 ${2*u} 0 a ${u} ${u} 0 1 0 ${-2*u} 0`,`M ${m} ${i+u} q ${.4*B} ${.15*B} ${.75*B} ${-.25*B}`].join(" ")}),`M ${n+.4*B} ${o-.8*B} L ${n-.1*B} ${o+1.2*B}`].join(" ")},Ci=(t,n,l)=>{const o=t.stem===null||t.stem.y2<t.stem.y1?1:-1,a=t.x+Ze*B,s=n.x-Ze*B,r=l+o*Ze*B,c=r+o*Al*B;return`M ${a} ${r} Q ${(a+s)/2} ${c} ${s} ${r}`},Ai=t=>(qe+yl*t.beats)*B,Di=(t,n,l)=>{const o=l.map((u,p)=>$i(n.notesByStaff[p],u,t.signs,n.isFirstUnit)),a=o.some(u=>u.heads.some(p=>p.accidental!==null)),s=t.x+(a?Fl*B:0)+qe/2*B,r=o.reduce((u,p)=>new Map([...u,...p.signs]),t.signs),c=l.map((u,p)=>o[p].heads.length===0?{chord:null,rest:{x:s,staffIndex:p,beats:n.unit.value,dotted:n.unit.dotted,isTriplet:n.unit.isTriplet,path:Ni(n.unit.value,s,u),solid:n.unit.value>=2}}:{chord:Oi(o[p].heads,n,p,s),rest:null}),i=c.flatMap((u,p)=>{const S=t.lastChordByStaff[p];return u.chord!==null&&!n.isFirstUnit&&S!==null?u.chord.heads.map(E=>Ci(S,u.chord,E.y)):[]}),m=t.tripletXs.at(-1);return{x:s+Ai(n.unit)-qe/2*B,chords:[...t.chords,...c.flatMap(u=>u.chord===null?[]:[u.chord])],rests:[...t.rests,...c.flatMap(u=>u.rest===null?[]:[u.rest])],ties:[...t.ties,...i],tripletXs:n.unit.isTriplet?[...t.tripletXs.slice(0,-1),[...m??[],s]]:m===void 0||m.length>0?[...t.tripletXs,[]]:t.tripletXs,signs:r,lastChordByStaff:c.map(u=>u.chord)}},Mi=(t,n)=>{const l=t[0]-Ce*B,o=t.at(-1)+Ce*B,a=(l+o)/2,s=n+Dt*B,r=At*B;return{labelX:a,path:[`M ${l} ${s} L ${l} ${n} L ${a-r} ${n}`,`M ${a+r} ${n} L ${o} ${n} L ${o} ${s}`].join(" ")}},oa=(t,n)=>{const l=t.flat().flatMap(i=>i.notes.flatMap(m=>{const u=dt(m);return u===null?[]:[u]})),o=Li(l),a=q,s=t.reduce((i,m)=>{const u=i.x,p=yi(m,o,n).reduce((E,b)=>Di(E,b,o),{x:u,chords:[],rests:[],ties:[],tripletXs:[],signs:new Map,lastChordByStaff:o.map(()=>null)}),S=Math.max(p.x+B,u+Bl*B);return{x:S,barEndXs:[...i.barEndXs,S],chords:[...i.chords,...p.chords],rests:[...i.rests,...p.rests],ties:[...i.ties,...p.ties],tripletXs:[...i.tripletXs,...p.tripletXs]}},{x:a+wl*B,barEndXs:[],chords:[],rests:[],ties:[],tripletXs:[]}),r=s.barEndXs.at(-1)??s.x,c=o[0].topY-Dl*B;return{width:r+q,height:o.at(-1).bottomY+Tl*B,lineGap:B,staves:o,staffStartX:a,staffEndX:r,barEndXs:s.barEndXs,chords:s.chords,rests:s.rests,ties:s.ties,brackets:s.tripletXs.filter(i=>i.length>0).map(i=>Mi(i,c)),bracketLabelY:c+Ut*B}},Ui=new Set(["[","<","(","{"]),Pi=new Set(["]",">",")","}"]),Ii=new Set(["~","-"]),Vi=/^([\dA-Za-z][\w.]*(?::\d+)?)(.*)$/,aa=/^(?:[!*/@]\d*\.?\d+|!|\?\d*\.?\d*|\(\s*\d+\s*(?:,\s*\d+\s*){1,2}\))*$/,sa={subdivide:["[","]"],alternate:["<",">"]},Wi=(t,n)=>[...t].reduce((l,o,a)=>{if(l.closedAt!==-1)return l;const s=l.depth+(Ui.has(o)?1:Pi.has(o)?-1:0);return{depth:s,closedAt:s===0&&o===n?a:-1}},{depth:0,closedAt:-1}).closedAt,Hi=t=>{const n=t.startsWith("[")?"subdivide":t.startsWith("<")?"alternate":null;if(n===null)return null;const l=Wi(t,sa[n][1]),o=t.slice(l+1);return l===-1||!aa.test(o)?null:{kind:"group",bracket:n,layers:Tn(t.slice(1,l)),modifier:o}},Gi=t=>{if(Ii.has(t))return{kind:"rest"};const n=Hi(t);if(n!==null)return n;const l=Vi.exec(t);return l!==null&&aa.test(l[2])?{kind:"sound",sound:l[1],modifier:l[2]}:{kind:"text",text:t}},Tn=t=>v(t,n=>n===",").map(n=>v(n,l=>/\s/.test(l)).map(Gi)),xi=t=>{if(t.kind==="rest")return"~";if(t.kind==="text")return t.text;if(t.kind==="sound")return`${t.sound}${t.modifier}`;const[n,l]=sa[t.bracket];return`${n}${Ln(t.layers)}${l}${t.modifier}`},Ln=t=>t.map(n=>n.map(xi).join(" ")).filter(n=>n.length>0).join(", "),wn={id:"other",label:"Other",match:""},yn=t=>Ht.find(n=>new RegExp(n.match).test(t.toLowerCase()))??wn,Xi=["s","sound"],ra="input",zi=/^\(?\s*([$A-Z_a-z][\w$]*)\s*\(/,Ki=new RegExp(`^${ra}\\.([$A-Z_a-z][\\w$]*)\\(`),ji=t=>{var o;const n=t.data;if(n.kind==="beats"||n.kind==="samples"||n.kind==="voice")return{chained:n.kind==="voice",names:Xi};if(n.kind!=="effect")return null;const l=((o=n.calls[0])==null?void 0:o.method.trim())??"";return{chained:!0,names:l.length===0?[]:[l]}},Yi=t=>{var s;const n=ji(t);if(n!==null)return n.names.length===0?null:n;const l=K(t.data.kind),o=Me(t.data,l?"":ra),a=(s=(l?zi:Ki).exec(o))==null?void 0:s[1];return a===void 0?null:{chained:!l,names:[a]}},qi=t=>`${t.chained}:${[...t.names].sort().join(",")}`,Zi=t=>t.data.kind==="beats"?Math.max(1,t.data.rows.filter(n=>n.steps.some(l=>l)).length):1,Ji=t=>{const n=Kt(t).split(`
|
|
19
|
+
`);return t.split(`
|
|
20
|
+
`).map((l,o)=>(n[o]??"").padEnd(l.length)).join(`
|
|
21
|
+
`)},Qi=(t,n)=>[...t.slice(n)].reduce((l,o,a)=>{if(l.end!==-1)return l;const s=l.depth+(o==="("?1:o===")"?-1:0);return{depth:s,end:s===0?n+a+1:-1}},{depth:0,end:-1}).end,vi=(t,n)=>{const l=n.names.map(s=>s.replace(/\$/g,"\\$")).join("|"),o=n.chained?"\\.\\s*":"(?<![\\w$.])",a=new RegExp(`${o}(${l})\\s*\\(`,"g");return[...t.matchAll(a)].flatMap(s=>{const r=(s.index??0)+s[0].indexOf(s[1]),c=Qi(t,(s.index??0)+s[0].length-1);return c===-1?[]:[{from:r,to:c}]})},ca=(t,n,l)=>{const o=new Map(n.map(c=>[c.id,c])),a=Ji(t),s=fo(n,l).flatMap(c=>{const i=o.get(c),m=i===void 0?null:Yi(i);return i===void 0||m===null?[]:[{nodeId:c,key:m,id:qi(m),count:Zi(i)}]}),r=Object.fromEntries(s.map(c=>[c.id,vi(a,c.key)]));return s.flatMap((c,i)=>{const m=s.slice(0,i).reduce((u,p)=>u+(p.id===c.id?p.count:0),0);return(r[c.id]??[]).slice(m,m+c.count).map(u=>({...u,nodeId:c.nodeId}))})},ed=(t,n,l,o)=>{const a=ca(t,n,l).find(s=>s.nodeId===o);return a===void 0?null:{from:a.from,to:a.to}},td=t=>t.reduce((n,l)=>n===null||l.from<n.from?l:n,null),ia=(t,n,l,o=[])=>{const a=t.get(l);if(a===void 0||o.includes(l))return[];if(K(a.data.kind))return[l];const s=[...o,l];return n.filter(r=>r.target===l).flatMap(r=>ia(t,n,r.source,s))},nd=(t,n,l,o)=>{const a=new Map(l.map(i=>[i.id,i])),s=i=>{const m=a.get(i.nodeId);return m!==void 0&&K(m.data.kind)},r=i=>t.filter(m=>m.from<=i&&i<m.to).reduce((m,u)=>m===null||u.to-u.from<m.to-m.from?u:m,null),c=n.flatMap(i=>{const m=i.flatMap(S=>r(S)??[]),u=td(m.filter(s));if(u!==null)return[u.nodeId];const p=[...new Set(m.flatMap(S=>ia(a,o,S.nodeId)))];return p.length===1?p:[]});return[...new Set(c)]},ld=e.defineComponent({__name:"StrudelFlowCable",props:{id:{},sourceNode:{},targetNode:{},source:{},target:{},type:{},label:{type:[String,Object,Function]},style:{},selected:{type:Boolean},sourcePosition:{},targetPosition:{},sourceHandleId:{},targetHandleId:{},animated:{type:Boolean},updatable:{type:Boolean},markerStart:{},markerEnd:{},curvature:{},interactionWidth:{},data:{},events:{},labelStyle:{},labelShowBg:{type:Boolean},labelBgStyle:{},labelBgPadding:{},labelBgBorderRadius:{},sourceX:{},sourceY:{},targetX:{},targetY:{}},setup(t){const n=t,{removeEdges:l}=j.useVueFlow(),o=e.computed(()=>j.getBezierPath({sourceX:n.sourceX,sourceY:n.sourceY,sourcePosition:n.sourcePosition,targetX:n.targetX,targetY:n.targetY,targetPosition:n.targetPosition}));return(a,s)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(j.BaseEdge),{id:t.id,path:o.value[0],"marker-end":t.markerEnd,style:e.normalizeStyle(t.style),"interaction-width":24},null,8,["id","path","marker-end","style"]),e.createVNode(e.unref(j.EdgeLabelRenderer),null,{default:e.withCtx(()=>[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["strudel-flow-edge__remove nodrag nopan",{"strudel-flow-edge__remove--selected":t.selected}]),style:e.normalizeStyle({transform:`translate(-50%, -50%) translate(${o.value[1]}px, ${o.value[2]}px)`}),"aria-label":"Disconnect",title:"Disconnect",onClick:s[0]||(s[0]=e.withModifiers(r=>e.unref(l)([t.id]),["stop"]))},[e.createVNode(e.unref(w.Unplug),{"aria-hidden":"true"})],6)]),_:1})],64))}}),od={class:"strudel-flow-accordion"},ad={class:"strudel-flow-accordion__trigger"},sd={class:"strudel-flow-accordion__badge"},rd={class:"strudel-flow-accordion__summary"},cd={key:0,class:"strudel-flow-accordion__meta"},id={class:"strudel-flow-accordion__content"},_t=e.defineComponent({__name:"StrudelFlowAccordion",props:{badge:{},summary:{},meta:{}},setup(t){return(n,l)=>(e.openBlock(),e.createElementBlock("details",od,[e.createElementVNode("summary",ad,[e.createVNode(e.unref(w.SlidersHorizontal),{class:"strudel-flow-accordion__icon","aria-hidden":"true"}),e.createElementVNode("span",sd,e.toDisplayString(t.badge),1),e.createElementVNode("span",rd,e.toDisplayString(t.summary),1),t.meta?(e.openBlock(),e.createElementBlock("span",cd,"· "+e.toDisplayString(t.meta),1)):e.createCommentVNode("",!0),e.createVNode(e.unref(w.ChevronDown),{class:"strudel-flow-accordion__chevron","aria-hidden":"true"})]),e.createElementVNode("div",id,[e.renderSlot(n.$slots,"default")])]))}}),da=Symbol("strudel-flow-overlay-target"),ma=Symbol("strudel-flow-preview-sound"),ua={kick:e.markRaw(w.Drum),snare:e.markRaw(w.CircleDot),hihat:e.markRaw(w.Sparkles),clap:e.markRaw(w.Hand),tom:e.markRaw(w.Cylinder),cymbal:e.markRaw(w.Disc),percussion:e.markRaw(w.Bell),bass:e.markRaw(w.Speaker),keys:e.markRaw(w.Piano),strings:e.markRaw(w.Guitar),voice:e.markRaw(w.Mic),fx:e.markRaw(w.Zap),other:e.markRaw(w.AudioWaveform)},dd={once:e.markRaw(w.Circle),faster:e.markRaw(w.FastForward),repeat:e.markRaw(w.Repeat),hold:e.markRaw(w.MoveHorizontal),slower:e.markRaw(w.Hourglass),chance:e.markRaw(w.Dices),rhythm:e.markRaw(w.CircleDashed)},md={class:"strudel-flow-field"},ud={class:"strudel-flow-select"},_d=["value","aria-label"],pd=["value"],fd=["label"],Ed=["value"],Z=e.defineComponent({__name:"StrudelFlowSelect",props:{label:{},modelValue:{},options:{},groups:{},hideLabel:{type:Boolean}},emits:["update:modelValue"],setup(t,{emit:n}){const l=n,o=a=>{const s=a.target;s instanceof HTMLSelectElement&&l("update:modelValue",s.value)};return(a,s)=>(e.openBlock(),e.createElementBlock("label",md,[e.createElementVNode("span",{class:e.normalizeClass(["strudel-flow-field__label",{"strudel-flow-field__label--hidden":t.hideLabel}])},e.toDisplayString(t.label),3),e.createElementVNode("span",ud,[e.createElementVNode("select",{value:t.modelValue,"aria-label":t.label,class:"nodrag",onChange:o},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.options??[],r=>(e.openBlock(),e.createElementBlock("option",{key:r.value,value:r.value},e.toDisplayString(r.label),9,pd))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.groups??[],r=>(e.openBlock(),e.createElementBlock("optgroup",{key:r.label,label:r.label},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.options,c=>(e.openBlock(),e.createElementBlock("option",{key:c.value,value:c.value},e.toDisplayString(c.label),9,Ed))),128))],8,fd))),128))],40,_d),e.createVNode(e.unref(w.ChevronDown),{class:"strudel-flow-select__chevron","aria-hidden":"true"})])]))}}),hd=["aria-label","title","aria-expanded"],Sd={class:"strudel-flow-sample-picker__trigger-text"},gd=["aria-label","onKeydown"],kd={class:"strudel-flow-sample-picker__search"},bd=["onKeydown"],Td={class:"strudel-flow-sample-picker__body"},Ld={class:"strudel-flow-sample-picker__families","aria-label":"Instrument families"},wd=["aria-pressed"],yd={class:"strudel-flow-sample-picker__count"},Fd=["aria-pressed","onClick"],Bd={class:"strudel-flow-sample-picker__count"},$d={class:"strudel-flow-sample-picker__results"},Rd={key:0,class:"strudel-flow-sample-picker__note"},Od={key:1,class:"strudel-flow-sample-picker__grid","aria-label":"Samples"},Nd=["aria-pressed","title","onClick"],Cd={class:"strudel-flow-sample-picker__option-text"},Ad={class:"strudel-flow-sample-picker__option-label"},Dd={class:"strudel-flow-sample-picker__option-group"},Md=["aria-label","onClick"],Ud={key:2,class:"strudel-flow-sample-picker__note"},ae="all",Pd=480,_a=360,be=4,Id=240,We=e.defineComponent({__name:"StrudelFlowSamplePicker",props:{label:{},modelValue:{},groups:{},placeholder:{},emptyIcon:{}},emits:["update:modelValue"],setup(t,{emit:n}){const l=t,o=n,a=e.inject(da,null),s=e.inject(ma,null),r=e.computed(()=>(a==null?void 0:a.value)??"body"),c=e.ref(null),i=e.ref(null),m=e.ref(null),u=e.ref(!1),p=e.ref(!1),S=e.ref(""),E=e.ref(ae),b=e.ref({left:0,top:0}),h=R=>ua[R]??ua.other,f=e.computed(()=>l.modelValue.length===0||l.groups.some(R=>R.samples.some(P=>P.value===l.modelValue))?l.groups:[{label:"In this pattern",samples:[{value:l.modelValue,label:l.modelValue}]},...l.groups]),_=e.computed(()=>{const R=new Set;return f.value.flatMap(P=>P.samples.flatMap(M=>R.has(M.value)?[]:(R.add(M.value),[{...M,group:P.label,familyId:M.familyId??yn(M.value).id}])))}),g=e.computed(()=>[...Ht,wn].map(R=>({...R,count:_.value.filter(P=>P.familyId===R.id).length})).filter(R=>R.count>0)),T=e.computed(()=>{const R=S.value.toLowerCase().split(/\s+/).filter(Boolean);return _.value.filter(P=>(E.value===ae||P.familyId===E.value)&&R.every(M=>`${P.value} ${P.label} ${P.group}`.toLowerCase().includes(M)))}),O=e.computed(()=>T.value.slice(0,Id)),V=e.computed(()=>_.value.find(R=>R.value===l.modelValue)),C=e.computed(()=>{var R;return l.modelValue.length===0?l.placeholder??"":((R=V.value)==null?void 0:R.label)??l.modelValue}),y=e.computed(()=>{var R;return l.modelValue.length===0?ae:((R=V.value)==null?void 0:R.familyId)??yn(l.modelValue).id}),L=e.computed(()=>f.value.filter(R=>R.samples.length>0).map(R=>({label:R.label,options:R.samples}))),k=e.computed(()=>l.placeholder===void 0?[]:[{value:"",label:l.placeholder}]),F=()=>{var M;const R=(M=c.value)==null?void 0:M.getBoundingClientRect();if(R===void 0)return;const P=R.bottom+be+_a<=window.innerHeight;b.value={left:Math.max(be,Math.min(R.left,window.innerWidth-Pd-be)),top:P?R.bottom+be:Math.max(be,R.top-be-_a)}},$=()=>{p.value=!1},D=()=>{S.value="",E.value=g.value.some(R=>R.id===y.value)?y.value:ae,F(),p.value=!0,e.nextTick(()=>{var R;return(R=m.value)==null?void 0:R.focus()})};e.watch(S,(R,P)=>{R.trim().length>0&&P.trim().length===0&&(E.value=ae)});const N=R=>{var P;o("update:modelValue",R),s==null||s(R),$(),(P=c.value)==null||P.focus()},A=()=>{const[R]=T.value;R!==void 0&&N(R.value)},U=R=>{var M,te;const P=R.target;p.value&&P instanceof Node&&!((M=i.value)!=null&&M.contains(P))&&!((te=c.value)!=null&&te.contains(P))&&$()};return e.onMounted(()=>{var R;u.value=((R=window.matchMedia)==null?void 0:R.call(window,"(pointer: fine)").matches)===!0,window.addEventListener("pointerdown",U)}),e.onBeforeUnmount(()=>window.removeEventListener("pointerdown",U)),(R,P)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[u.value?(e.openBlock(),e.createElementBlock("button",{key:1,ref_key:"trigger",ref:c,type:"button",class:e.normalizeClass(["strudel-flow-sample-picker__trigger nodrag",{"strudel-flow-sample-picker__trigger--empty":t.modelValue.length===0}]),"aria-label":t.label,title:t.modelValue,"aria-haspopup":"dialog","aria-expanded":p.value,onClick:P[1]||(P[1]=M=>p.value?$():D())},[t.modelValue.length>0||t.emptyIcon!==void 0?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.modelValue.length>0?h(y.value):t.emptyIcon),{key:0,class:"strudel-flow-sample-picker__icon","aria-hidden":"true"})):e.createCommentVNode("",!0),e.createElementVNode("span",Sd,e.toDisplayString(C.value),1),e.createVNode(e.unref(w.ChevronDown),{class:"strudel-flow-sample-picker__chevron","aria-hidden":"true"})],10,hd)):(e.openBlock(),e.createBlock(Z,{key:0,label:t.label,"hide-label":"","model-value":t.modelValue,options:k.value,groups:L.value,"onUpdate:modelValue":P[0]||(P[0]=M=>o("update:modelValue",M))},null,8,["label","model-value","options","groups"])),p.value?(e.openBlock(),e.createBlock(e.Teleport,{key:2,to:r.value},[e.createElementVNode("div",{ref_key:"popover",ref:i,class:"strudel-flow-sample-picker nodrag nowheel",role:"dialog","aria-label":t.label,style:e.normalizeStyle({left:`${b.value.left}px`,top:`${b.value.top}px`}),onKeydown:e.withKeys(e.withModifiers($,["stop"]),["escape"])},[e.createElementVNode("label",kd,[e.createVNode(e.unref(w.Search),{class:"strudel-flow-sample-picker__icon","aria-hidden":"true"}),e.withDirectives(e.createElementVNode("input",{ref_key:"searchField",ref:m,"onUpdate:modelValue":P[2]||(P[2]=M=>S.value=M),type:"search",placeholder:"Search samples","aria-label":"Search samples",spellcheck:"false",onKeydown:e.withKeys(e.withModifiers(A,["prevent"]),["enter"])},null,40,bd),[[e.vModelText,S.value]])]),e.createElementVNode("div",Td,[e.createElementVNode("ul",Ld,[e.createElementVNode("li",null,[e.createElementVNode("button",{type:"button",class:"strudel-flow-sample-picker__family","aria-pressed":E.value===ae,onClick:P[3]||(P[3]=M=>E.value=ae)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(h("other")),{class:"strudel-flow-sample-picker__icon","aria-hidden":"true"})),P[4]||(P[4]=e.createElementVNode("span",null,"All",-1)),e.createElementVNode("span",yd,e.toDisplayString(_.value.length),1)],8,wd)]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,M=>(e.openBlock(),e.createElementBlock("li",{key:M.id},[e.createElementVNode("button",{type:"button",class:"strudel-flow-sample-picker__family","aria-pressed":E.value===M.id,onClick:te=>E.value=M.id},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(h(M.id)),{class:"strudel-flow-sample-picker__icon","aria-hidden":"true"})),e.createElementVNode("span",null,e.toDisplayString(M.label),1),e.createElementVNode("span",Bd,e.toDisplayString(M.count),1)],8,Fd)]))),128))]),e.createElementVNode("div",$d,[T.value.length===0?(e.openBlock(),e.createElementBlock("p",Rd," No sample matches. ")):(e.openBlock(),e.createElementBlock("ul",Od,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(O.value,M=>(e.openBlock(),e.createElementBlock("li",{key:M.value,class:"strudel-flow-sample-picker__item"},[e.createElementVNode("button",{type:"button",class:"strudel-flow-sample-picker__option","aria-pressed":M.value===t.modelValue,title:`${M.value} · ${M.group}`,onClick:te=>N(M.value)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(h(M.familyId)),{class:"strudel-flow-sample-picker__icon","aria-hidden":"true"})),e.createElementVNode("span",Cd,[e.createElementVNode("span",Ad,e.toDisplayString(M.label),1),e.createElementVNode("span",Dd,e.toDisplayString(M.group),1)])],8,Nd),e.unref(s)!==null?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"strudel-flow-sample-picker__play","aria-label":`Play ${M.label}, ${M.group}`,onClick:te=>e.unref(s)(M.value)},[e.createVNode(e.unref(w.Play),{class:"strudel-flow-sample-picker__icon","aria-hidden":"true"})],8,Md)):e.createCommentVNode("",!0)]))),128))])),T.value.length>O.value.length?(e.openBlock(),e.createElementBlock("p",Ud,e.toDisplayString(T.value.length-O.value.length)+" more; type to narrow the list. ",1)):e.createCommentVNode("",!0)])])],44,gd)],8,["to"])):e.createCommentVNode("",!0)],64))}}),Vd={class:"strudel-flow-field"},Wd={class:"strudel-flow-field__label"},Hd=["aria-label"],Gd=["aria-label","disabled"],xd={class:"strudel-flow-stepper__value"},Xd=["aria-label","disabled"],se=e.defineComponent({__name:"StrudelFlowStepper",props:{label:{},modelValue:{},min:{},max:{}},emits:["update:modelValue"],setup(t,{emit:n}){const l=t,o=n,a=s=>{o("update:modelValue",Math.min(l.max,Math.max(l.min,l.modelValue+s)))};return(s,r)=>(e.openBlock(),e.createElementBlock("div",Vd,[e.createElementVNode("span",Wd,e.toDisplayString(t.label),1),e.createElementVNode("div",{class:"strudel-flow-stepper",role:"group","aria-label":t.label},[e.createElementVNode("button",{type:"button",class:"strudel-flow-stepper__button nodrag","aria-label":`Decrease ${t.label.toLowerCase()}`,disabled:t.modelValue<=t.min,onClick:r[0]||(r[0]=c=>a(-1))},[e.createVNode(e.unref(w.Minus),{"aria-hidden":"true"})],8,Gd),e.createElementVNode("output",xd,e.toDisplayString(t.modelValue),1),e.createElementVNode("button",{type:"button",class:"strudel-flow-stepper__button nodrag","aria-label":`Increase ${t.label.toLowerCase()}`,disabled:t.modelValue>=t.max,onClick:r[1]||(r[1]=c=>a(1))},[e.createVNode(e.unref(w.Plus),{"aria-hidden":"true"})],8,Xd)],8,Hd)]))}}),zd={class:"strudel-flow-beats"},Kd={class:"strudel-flow-beats__tracks",role:"group","aria-label":"Drum tracks"},jd=["aria-pressed","aria-label","title","onClick"],Yd={key:0,class:"strudel-flow-select strudel-flow-pad__modifier"},qd=["value","aria-label","onChange"],Zd=["value"],Jd={class:"strudel-flow-accordion__row"},Qd={class:"strudel-flow-field"},vd=["aria-checked"],pa=e.defineComponent({__name:"StrudelFlowBeatsControls",props:{data:{},sampleGroups:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=e.computed(()=>Array.from({length:l.data.steps},(h,f)=>f)),s=new Set(Tt.flatMap(h=>h.sounds)),r=e.computed(()=>(l.sampleGroups??[]).map(h=>({label:h.label,samples:h.samples.filter(f=>!s.has(f.value))})).filter(h=>h.samples.length>0)),c=h=>h.map(f=>({value:f,label:f})),i=e.computed(()=>[...Tt.map(h=>({label:h.label,samples:c(h.sounds)})),...r.value]),m=h=>{o("update",{...l.data,...h})},u=(h,f)=>{m({rows:l.data.rows.map((_,g)=>g===h?{..._,...f}:_)})},p=(h,f)=>{const _=l.data.rows[h];_!==void 0&&u(h,{steps:_.steps.map((g,T)=>T===f?!g:g)})},S=(h,f,_)=>{const g=l.data.rows[h];if(g===void 0||!(_.target instanceof HTMLSelectElement))return;const T=_.target.value;u(h,{modifiers:Object.fromEntries([...Object.entries(g.modifiers).filter(([O])=>Number(O)!==f),...T.length>0?[[f,T]]:[]])})},E=h=>bt.find(f=>!h.some(_=>_.sound===f))??bt[0],b=h=>{const f=h<=l.data.rows.length?l.data.rows.slice(0,h):Array.from({length:h-l.data.rows.length}).reduce(_=>[..._,Ee(E(_))],l.data.rows);m({rows:f})};return(h,f)=>(e.openBlock(),e.createElementBlock("div",zd,[e.createElementVNode("div",Kd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.data.rows,(_,g)=>(e.openBlock(),e.createElementBlock("div",{key:g,class:"strudel-flow-beats__track"},[e.createVNode(We,{label:`Track ${g+1} sound`,"model-value":_.sound,groups:i.value,"onUpdate:modelValue":T=>u(g,{sound:T})},null,8,["label","model-value","groups","onUpdate:modelValue"]),e.createElementVNode("div",{class:"strudel-flow-beats__steps",style:e.normalizeStyle({"--beats-steps":t.data.steps})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,T=>(e.openBlock(),e.createElementBlock("div",{key:T,class:"strudel-flow-pad__column"},[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["strudel-flow-pad__cell nodrag",{"strudel-flow-pad__cell--on":_.steps[T]}]),"aria-pressed":_.steps[T]===!0,"aria-label":`${_.sound} step ${T+1}`,title:`${_.sound} step ${T+1}`,onClick:O=>p(g,T)},null,10,jd),t.data.showModifiers?(e.openBlock(),e.createElementBlock("span",Yd,[e.createElementVNode("select",{class:"nodrag",value:_.modifiers[T]??"","aria-label":`${_.sound} step ${T+1} variation`,onChange:O=>S(g,T,O)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref($e),O=>(e.openBlock(),e.createElementBlock("option",{key:O.value,value:O.value},e.toDisplayString(O.value||"○"),9,Zd))),128))],40,qd)])):e.createCommentVNode("",!0)]))),128))],4)]))),128))]),e.createVNode(_t,{badge:String(t.data.rows.length),summary:"Shape",meta:`${t.data.steps} steps`},{default:e.withCtx(()=>[e.createElementVNode("div",Jd,[e.createVNode(se,{label:"Steps","model-value":t.data.steps,min:1,max:e.unref(X),"onUpdate:modelValue":f[0]||(f[0]=_=>m({steps:_}))},null,8,["model-value","max"]),e.createVNode(se,{label:"Tracks","model-value":t.data.rows.length,min:1,max:e.unref(Re),"onUpdate:modelValue":b},null,8,["model-value","max"]),e.createElementVNode("div",Qd,[f[3]||(f[3]=e.createElementVNode("span",{class:"strudel-flow-field__label"},"Modifiers",-1)),e.createElementVNode("button",{type:"button",role:"switch",class:"strudel-flow-switch nodrag","aria-checked":t.data.showModifiers,"aria-label":"Show step modifiers",onClick:f[1]||(f[1]=_=>m({showModifiers:!t.data.showModifiers}))},[...f[2]||(f[2]=[e.createElementVNode("span",{class:"strudel-flow-switch__thumb","aria-hidden":"true"},null,-1)])],8,vd)])])]),_:1},8,["badge","meta"])]))}}),em={class:"strudel-flow-knob"},tm={class:"strudel-flow-knob__dial"},nm={class:"strudel-flow-knob__graphic",viewBox:"0 0 100 100","aria-hidden":"true"},lm=["stroke-dasharray"],om=["transform"],am=["value","min","max","step","aria-label","aria-valuetext"],sm={class:"strudel-flow-knob__value"},rm={class:"strudel-flow-knob__label"},Fn=-135,fa=270,Ea=50,pt=46,G=e.defineComponent({__name:"StrudelFlowKnob",props:{label:{},modelValue:{},min:{},max:{},step:{},suffix:{}},emits:["update:modelValue"],setup(t,{emit:n}){const l=t,o=n,a=(p,S)=>{const E=S*Math.PI/180;return`${Ea+p*Math.sin(E)} ${Ea-p*Math.cos(E)}`},s=`M ${a(pt,Fn)} A ${pt} ${pt} 0 1 1 ${a(pt,Fn+fa)}`,r=e.computed(()=>{const p=l.max-l.min;return p<=0?0:Math.min(1,Math.max(0,(l.modelValue-l.min)/p))}),c=e.computed(()=>Fn+r.value*fa),i=e.computed(()=>ql(l.modelValue)),m=e.computed(()=>{var p;return((p=l.suffix)==null?void 0:p.trim())??""}),u=p=>{const S=p.target;S instanceof HTMLInputElement&&o("update:modelValue",Number(S.value))};return(p,S)=>(e.openBlock(),e.createElementBlock("label",em,[e.createElementVNode("span",tm,[(e.openBlock(),e.createElementBlock("svg",nm,[e.createElementVNode("path",{class:"strudel-flow-knob__track",d:s}),e.createElementVNode("path",{class:"strudel-flow-knob__fill",d:s,pathLength:"100","stroke-dasharray":`${r.value*100} 100`},null,8,lm),S[0]||(S[0]=e.createElementVNode("circle",{class:"strudel-flow-knob__face",cx:"50",cy:"50",r:"38"},null,-1)),e.createElementVNode("line",{class:"strudel-flow-knob__indicator",x1:"50",y1:"41",x2:"50",y2:"28",transform:`rotate(${c.value} 50 50)`},null,8,om)])),e.createElementVNode("input",{class:"strudel-flow-knob__input",type:"range",value:t.modelValue,min:t.min,max:t.max,step:t.step,"aria-label":t.label,"aria-valuetext":`${i.value}${m.value}`,onInput:u},null,40,am)]),e.createElementVNode("span",sm,e.toDisplayString(i.value),1),e.createElementVNode("span",rm,e.toDisplayString(t.label),1)]))}}),cm={class:"strudel-flow-calls","aria-label":"Chained calls"},im={class:"strudel-flow-calls__list"},dm={key:0,class:"strudel-flow-calls__row strudel-flow-calls__row--controls"},mm={class:"strudel-flow-calls__heading"},um={class:"strudel-flow-calls__name"},_m=["aria-label","title","onClick"],pm={key:0,class:"strudel-flow-knobs"},fm={key:0,class:"strudel-flow-calls__control"},Em={class:"strudel-flow-calls__control-label"},hm=["value","aria-label","onInput"],Sm={key:1,class:"strudel-flow-calls__control"},gm={class:"strudel-flow-calls__control-label"},km=["aria-label"],bm=["aria-pressed","aria-label","onClick"],Tm={key:1,class:"strudel-flow-calls__row"},Lm=["value","size","onInput"],wm=["value","aria-label","onInput"],ym=["aria-label","title","onClick"],Fm=e.defineComponent({__name:"StrudelFlowCallList",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=e.computed(()=>l.data.calls),s=e.computed(()=>a.value.map(Yt)),r=h=>{o("update",{...l.data,calls:h})},c=(h,f,_)=>{const g=_.target;(g instanceof HTMLInputElement||g instanceof HTMLTextAreaElement)&&r(a.value.map((T,O)=>O===h?{...T,[f]:g.value}:T))},i=(h,f)=>{r(a.value.map((_,g)=>g===h?{..._,argument:f}:_))},m=(h,f,_)=>{const g=s.value[h]??[];i(h,qt(g.map((T,O)=>O===f?_:T)))},u=(h,f,_,g)=>{m(h,f,{..._,value:g})},p=h=>h.some(f=>f.kind==="number"),S=(h,f,_,g)=>{g.target instanceof HTMLInputElement&&m(h,f,{..._,value:g.target.value})},E=(h,f,_,g)=>{m(h,f,{..._,steps:_.steps.map((T,O)=>O===g?!T:T)})},b=h=>{r(a.value.filter((f,_)=>_!==h))};return(h,f)=>(e.openBlock(),e.createElementBlock("section",cm,[f[3]||(f[3]=e.createElementVNode("span",{class:"strudel-flow-field__label"},"Calls",-1)),e.createElementVNode("ul",im,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(_,g)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:g},[s.value[g]!==null?(e.openBlock(),e.createElementBlock("li",dm,[e.createElementVNode("div",mm,[e.createElementVNode("span",um,"."+e.toDisplayString(_.method),1),e.createElementVNode("button",{type:"button",class:"strudel-flow-calls__remove nodrag","aria-label":`Remove ${_.method}`,title:`Remove ${_.method}`,onClick:T=>b(g)},[e.createVNode(e.unref(w.X),{"aria-hidden":"true"})],8,_m)]),p(s.value[g]??[])?(e.openBlock(),e.createElementBlock("div",pm,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value[g],(T,O)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:O},[T.kind==="number"?(e.openBlock(),e.createBlock(G,{key:0,label:T.label,"model-value":T.value,min:T.min,max:T.max,step:T.step,"onUpdate:modelValue":V=>u(g,O,T,V)},null,8,["label","model-value","min","max","step","onUpdate:modelValue"])):e.createCommentVNode("",!0)],64))),128))])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value[g],(T,O)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:O},[T.kind==="text"?(e.openBlock(),e.createElementBlock("label",fm,[e.createElementVNode("span",Em,e.toDisplayString(T.label),1),e.createElementVNode("input",{class:"strudel-flow-calls__text nodrag",value:T.value,"aria-label":`${_.method} ${T.label.toLowerCase()}`,spellcheck:"false",onInput:V=>S(g,O,T,V)},null,40,hm)])):T.kind==="toggles"?(e.openBlock(),e.createElementBlock("div",Sm,[e.createElementVNode("span",gm,e.toDisplayString(T.label),1),e.createElementVNode("div",{class:"strudel-flow-calls__steps",role:"group","aria-label":`${_.method} ${T.perCycle?"cycles":"steps"}`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.steps,(V,C)=>(e.openBlock(),e.createElementBlock("button",{key:C,type:"button",class:e.normalizeClass(["strudel-flow-calls__step nodrag",{"strudel-flow-calls__step--on":V}]),"aria-pressed":V,"aria-label":`${T.perCycle?"Cycle":"Step"} ${C+1}`,onClick:y=>E(g,O,T,C)},null,10,bm))),128))],8,km)])):e.createCommentVNode("",!0)],64))),128))])):(e.openBlock(),e.createElementBlock("li",Tm,[f[0]||(f[0]=e.createElementVNode("span",{class:"strudel-flow-calls__punctuation","aria-hidden":"true"},".",-1)),e.createElementVNode("input",{class:"strudel-flow-calls__method nodrag",value:_.method,placeholder:"fast",size:Math.max(4,_.method.length),"aria-label":"Call name",spellcheck:"false",onInput:T=>c(g,"method",T)},null,40,Lm),f[1]||(f[1]=e.createElementVNode("span",{class:"strudel-flow-calls__punctuation","aria-hidden":"true"},"(",-1)),e.createElementVNode("textarea",{class:"strudel-flow-calls__argument nodrag nowheel",value:_.argument,rows:"1",placeholder:"2","aria-label":`${_.method||"Call"} argument`,spellcheck:"false",onInput:T=>c(g,"argument",T)},null,40,wm),f[2]||(f[2]=e.createElementVNode("span",{class:"strudel-flow-calls__punctuation","aria-hidden":"true"},")",-1)),e.createElementVNode("button",{type:"button",class:"strudel-flow-calls__remove nodrag","aria-label":`Remove ${_.method||"call"}`,title:`Remove ${_.method||"call"}`,onClick:T=>b(g)},[e.createVNode(e.unref(w.X),{"aria-hidden":"true"})],8,ym)]))],64))),128))])]))}}),Bm={class:"strudel-flow-chord-editor"},$m=["data-degree","aria-label","aria-pressed","title","onClick","onKeydown"],Rm={class:"strudel-flow-chord-editor__degree"},Om={key:0,class:"strudel-flow-chord-editor__bar"},Nm={class:"strudel-flow-chord-editor__name"},ha=e.defineComponent({__name:"StrudelFlowChordEditor",props:{notes:{},noteSlots:{},noteName:{type:Function},noteLabel:{type:Function}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=e.ref(null),s=e.ref(null),r=e.ref(null),c=e.computed(()=>Array.from({length:l.noteSlots},(f,_)=>_)),i=f=>{o("update",l.notes.includes(f)?l.notes.filter(_=>_!==f):[...l.notes,f].sort((_,g)=>_-g))},m=(f,_,g)=>[...new Set([...f.filter(T=>T!==_),g])].sort((T,O)=>T-O),u=()=>{s.value=null,r.value=null},p=f=>{var O;if(!f.isPrimary||f.button!==0)return;const _=f.target;if(!(_ instanceof Element))return;const g=_.closest("button[data-degree]");if(g===null)return;f.preventDefault(),g.focus();const T=Number(g.dataset.degree);s.value={pointerId:f.pointerId,startX:f.clientX,degree:T,target:T,moved:!1,notes:[...l.notes],slots:l.noteSlots},(O=a.value)==null||O.setPointerCapture(f.pointerId)},S=f=>{var O;const _=s.value;if(_===null||_.pointerId!==f.pointerId||!_.moved&&Math.abs(f.clientX-_.startX)<4)return;_.moved=!0;const g=(O=a.value)==null?void 0:O.getBoundingClientRect();if(g===void 0||g.width===0)return;const T=Math.max(0,Math.min(_.slots-1,_.degree+(f.clientX-_.startX)/g.width*_.slots));_.target=Math.round(T),r.value={from:_.degree,target:_.target,position:(T+.5)/_.slots*100}},E=f=>{var g;const _=s.value;_===null||_.pointerId!==f.pointerId||(s.value=null,r.value=null,_.moved?o("update",m(_.notes,_.degree,_.target)):i(_.degree),(g=a.value)==null||g.releasePointerCapture(f.pointerId))},b=(f,_)=>{_.detail===0&&i(f)},h=async(f,_)=>{var T,O;if(!l.notes.includes(_)||!["ArrowLeft","ArrowRight"].includes(f.key))return;f.preventDefault();const g=Math.max(0,Math.min(l.noteSlots-1,_+(f.key==="ArrowRight"?1:-1)));o("update",m(l.notes,_,g)),await e.nextTick(),(O=(T=a.value)==null?void 0:T.querySelector(`[data-degree="${g}"]`))==null||O.focus()};return(f,_)=>(e.openBlock(),e.createElementBlock("div",Bm,[e.createElementVNode("div",{ref_key:"container",ref:a,class:"strudel-flow-chord-editor__grid",role:"group","aria-label":"Edit chord notes",style:e.normalizeStyle({gridTemplateColumns:`repeat(${t.noteSlots}, minmax(0, 1fr))`}),onPointerdown:p,onPointermove:S,onPointerup:E,onPointercancel:u,onLostpointercapture:u},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,g=>{var T,O;return e.openBlock(),e.createElementBlock("button",{key:g,type:"button",class:"strudel-flow-chord-editor__slot nodrag","data-degree":g,"aria-label":`Scale degree ${g}: ${t.noteLabel(g)}`,"aria-pressed":t.notes.includes(g),title:`${g}: ${t.noteName(g)} · Click to ${t.notes.includes(g)?"remove":"add"}${t.notes.includes(g)?", drag to move":""}`,onClick:V=>b(g,V),onKeydown:V=>h(V,g)},[e.createElementVNode("span",Rm,e.toDisplayString(g),1),e.createElementVNode("span",{class:e.normalizeClass(["strudel-flow-chord-editor__lane",{"strudel-flow-chord-editor__lane--target":((T=r.value)==null?void 0:T.target)===g}])},[t.notes.includes(g)&&((O=r.value)==null?void 0:O.from)!==g?(e.openBlock(),e.createElementBlock("span",Om,[..._[0]||(_[0]=[e.createElementVNode("span",{class:"strudel-flow-chord-editor__bar-dot"},null,-1)])])):e.createCommentVNode("",!0)],2),e.createElementVNode("span",Nm,e.toDisplayString(t.noteName(g)),1)],40,$m)}),128)),r.value!==null?(e.openBlock(),e.createElementBlock("span",{key:0,class:"strudel-flow-chord-editor__preview",style:e.normalizeStyle({left:`${r.value.position}%`}),"aria-hidden":"true"},[..._[1]||(_[1]=[e.createElementVNode("span",{class:"strudel-flow-chord-editor__bar-dot"},null,-1)])],4)):e.createCommentVNode("",!0)],36)]))}}),Cm={class:"strudel-flow-chords"},Am={class:"strudel-flow-chords__presets",role:"group","aria-label":"Progression presets"},Dm=["onClick"],Mm={viewBox:"0 0 72 22","aria-hidden":"true"},Um=["points"],Pm=["cx","cy"],Im={class:"strudel-flow-chords__progression",role:"group","aria-label":"Chord progression"},Vm=["aria-label","aria-pressed","onClick"],Wm={class:"strudel-flow-chords__card-meta"},Hm={viewBox:"0 0 48 40",class:"strudel-flow-chords__shape","aria-hidden":"true"},Gm=["d"],xm=["x","y"],Xm={class:"strudel-flow-chords__card-name"},zm=["disabled"],Km={class:"strudel-flow-accordion__row"},Sa=e.defineComponent({__name:"StrudelFlowChordsControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=e.ref(0),s=e.computed(()=>Je(l.data)),r=e.computed(()=>Xt(l.data)),c=e.computed(()=>Wl(l.data)),i=e.computed(()=>Math.min(a.value,Math.max(0,s.value.length-1))),m=e.computed(()=>s.value[i.value]??[]),u=e.computed(()=>Math.max(14,Math.ceil((Math.max(0,...s.value.flat())+1)/7)*7)),p=e.computed(()=>{var C;return((C=ie.find(y=>y.value===l.data.scaleType))==null?void 0:C.label)??l.data.scaleType}),S=e.computed(()=>Math.max(13,...s.value.flat())),E=C=>{o("update",{...l.data,...C})},b=C=>{E({chordNotes:C})},h=C=>{b(s.value.length>0?s.value.map((y,L)=>L===i.value?C:y):[C])},f=C=>{E({chordProgression:[...C],chordNotes:void 0}),a.value=0},_=()=>{if(r.value.length>=16)return;const C=s.value.at(-1)??[0,2,4];b([...s.value,[...C]]),a.value=s.value.length},g=C=>C.map((y,L)=>`${9+L*18},${18-y*2}`).join(" "),T=C=>{(C==="major"||C==="minor")&&E({scaleType:C})},O=C=>{var y;return l.data.chordNotes!==void 0?(y=s.value[C])!=null&&y.length?s.value[C].join(", "):"rest":c.value.degrees[r.value[C]??0]??""},V=C=>{var y;return l.data.chordNotes!==void 0?(y=s.value[C])!=null&&y.length?s.value[C].join("·"):"Rest":c.value.chordName(r.value[C]??0)};return(C,y)=>(e.openBlock(),e.createElementBlock("div",Cm,[(e.openBlock(),e.createBlock(ha,{key:i.value,notes:m.value,"note-slots":u.value,"note-name":c.value.noteName,"note-label":c.value.noteLabel,onUpdate:h},null,8,["notes","note-slots","note-name","note-label"])),e.createElementVNode("div",Am,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(Vl),L=>(e.openBlock(),e.createElementBlock("button",{key:L.label,type:"button",class:"strudel-flow-chords__preset nodrag",onClick:k=>f(L.steps)},[(e.openBlock(),e.createElementBlock("svg",Mm,[e.createElementVNode("polyline",{points:g(L.steps),fill:"none"},null,8,Um),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(L.steps,(k,F)=>(e.openBlock(),e.createElementBlock("circle",{key:F,cx:9+F*18,cy:18-k*2,r:"3"},null,8,Pm))),128))])),e.createTextVNode(" "+e.toDisplayString(L.label),1)],8,Dm))),128))]),e.createElementVNode("div",Im,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(L,k)=>(e.openBlock(),e.createElementBlock("button",{key:k,type:"button",class:e.normalizeClass(["strudel-flow-chords__card nodrag",{"strudel-flow-chords__card--active":i.value===k}]),"aria-label":`Chord step ${k+1}: ${O(k)}`,"aria-pressed":i.value===k,onClick:F=>a.value=k},[e.createElementVNode("span",Wm,[e.createElementVNode("span",null,e.toDisplayString(k+1),1),e.createElementVNode("span",null,e.toDisplayString(t.data.chordNotes!==void 0?"n":c.value.degrees[L]),1)]),(e.openBlock(),e.createElementBlock("svg",Hm,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList([0,1,2,3,4],F=>e.createElementVNode("path",{key:F,d:`M4 ${6+F*7}H44`,class:"strudel-flow-chords__staff"},null,8,Gm)),64)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value[k],(F,$)=>{var D;return e.openBlock(),e.createElementBlock("rect",{key:$,x:5+$*28/Math.max(1,(((D=s.value[k])==null?void 0:D.length)??1)-1),y:32-F/S.value*26,width:"15",height:"4",rx:"2",class:"strudel-flow-chords__note"},null,8,xm)}),128))])),e.createElementVNode("span",Xm,e.toDisplayString(V(k)),1)],10,Vm))),128))]),e.createElementVNode("button",{type:"button",class:"strudel-flow-chords__add nodrag","aria-label":"Add chord step",disabled:r.value.length>=16,onClick:_}," + ",8,zm),e.createVNode(_t,{badge:`${t.data.key}${t.data.octave}`,summary:p.value,meta:`${r.value.length} chords`},{default:e.withCtx(()=>[e.createElementVNode("div",Km,[e.createVNode(Z,{label:"Key","model-value":t.data.key,options:e.unref(ce),"onUpdate:modelValue":y[0]||(y[0]=L=>E({key:L}))},null,8,["model-value","options"]),e.createVNode(Z,{label:"Scale","model-value":t.data.scaleType,options:e.unref(Ke),"onUpdate:modelValue":T},null,8,["model-value","options"]),e.createVNode(se,{label:"Octave","model-value":t.data.octave,min:1,max:8,"onUpdate:modelValue":y[1]||(y[1]=L=>E({octave:L}))},null,8,["model-value"])])]),_:1},8,["badge","summary","meta"])]))}}),jm={class:"strudel-flow-field"},Ym=["value","placeholder"],ga=e.defineComponent({__name:"StrudelFlowCodeControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=s=>{const r=s.target;r instanceof HTMLTextAreaElement&&o("update",{kind:"code",code:r.value})};return(s,r)=>(e.openBlock(),e.createElementBlock("label",jm,[r[0]||(r[0]=e.createElementVNode("span",{class:"strudel-flow-field__label"},"Expression",-1)),e.createElementVNode("textarea",{class:"strudel-flow-textarea",value:l.data.code,placeholder:e.unref(et).code,"aria-label":"Code expression",rows:"5",spellcheck:"false",onInput:a},null,40,Ym)]))}}),qm={class:"strudel-flow-knobs"},ka=e.defineComponent({__name:"StrudelFlowDelayControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=c=>{o("update",{...l.data,mix:c})},s=c=>{o("update",{...l.data,time:c})},r=c=>{o("update",{...l.data,feedback:c})};return(c,i)=>(e.openBlock(),e.createElementBlock("div",qm,[e.createVNode(G,{label:"Mix","model-value":t.data.mix,min:0,max:1,step:.01,"onUpdate:modelValue":a},null,8,["model-value"]),e.createVNode(G,{label:"Time","model-value":t.data.time,min:0,max:1,step:.01,suffix:"s","onUpdate:modelValue":s},null,8,["model-value"]),e.createVNode(G,{label:"Feedback","model-value":t.data.feedback,min:0,max:1,step:.01,"onUpdate:modelValue":r},null,8,["model-value"])]))}}),Zm=.25,Jm=.1,Qm=t=>{const{attack:n,decay:l,sustain:o,release:a}=t,s=n+l+a,r=Math.max(s*Zm,Jm),c=s+r,i=n/c,m=(n+l)/c,u=(n+l+r)/c;return[{x:0,y:0},{x:i,y:1},{x:m,y:o},{x:u,y:o},{x:1,y:0}]},vm=["viewBox"],eu=["points"],tu=["points"],nu={class:"strudel-flow-knobs"},ba=160,ft=56,Te=4,Ta=e.defineComponent({__name:"StrudelFlowEnvelopeControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=r=>{o("update",{...l.data,...r})},s=e.computed(()=>Qm(l.data).map(({x:r,y:c})=>`${Te+r*(ba-Te*2)},${ft-Te-c*(ft-Te*2)}`).join(" "));return(r,c)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[(e.openBlock(),e.createElementBlock("svg",{class:"strudel-flow-envelope-chart",viewBox:`0 0 ${ba} ${ft}`,role:"img","aria-label":"Envelope shape"},[e.createElementVNode("polygon",{points:`${Te},${ft-Te} ${s.value}`,class:"fill"},null,8,eu),e.createElementVNode("polyline",{points:s.value,class:"line"},null,8,tu)],8,vm)),e.createElementVNode("div",nu,[e.createVNode(G,{label:"Attack","model-value":t.data.attack,min:0,max:2,step:.01,"onUpdate:modelValue":c[0]||(c[0]=i=>a({attack:i}))},null,8,["model-value"]),e.createVNode(G,{label:"Decay","model-value":t.data.decay,min:0,max:2,step:.01,"onUpdate:modelValue":c[1]||(c[1]=i=>a({decay:i}))},null,8,["model-value"]),e.createVNode(G,{label:"Sustain","model-value":t.data.sustain,min:0,max:1,step:.01,"onUpdate:modelValue":c[2]||(c[2]=i=>a({sustain:i}))},null,8,["model-value"]),e.createVNode(G,{label:"Release","model-value":t.data.release,min:0,max:2,step:.01,"onUpdate:modelValue":c[3]||(c[3]=i=>a({release:i}))},null,8,["model-value"])])],64))}}),lu={class:"strudel-flow-knobs"},La=e.defineComponent({__name:"StrudelFlowFilterControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=r=>{o("update",{...l.data,cutoff:r})},s=r=>{o("update",{...l.data,resonance:r})};return(r,c)=>(e.openBlock(),e.createElementBlock("div",lu,[e.createVNode(G,{label:"LPF","model-value":t.data.cutoff,min:20,max:2e4,step:10,suffix:"Hz","onUpdate:modelValue":a},null,8,["model-value"]),e.createVNode(G,{label:"LPQ","model-value":t.data.resonance,min:.1,max:20,step:.1,"onUpdate:modelValue":s},null,8,["model-value"])]))}}),ou={class:"strudel-flow-knobs"},au=e.defineComponent({__name:"StrudelFlowGainControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n;return(a,s)=>(e.openBlock(),e.createElementBlock("div",ou,[e.createVNode(G,{label:"Gain","model-value":l.data.gain,min:0,max:2,step:.01,suffix:"×","onUpdate:modelValue":s[0]||(s[0]=r=>o("update",{...l.data,gain:r}))},null,8,["model-value"])]))}}),su={class:"strudel-flow-knobs"},wa=e.defineComponent({__name:"StrudelFlowLevelControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=s=>{o("update",{...l.data,...s})};return(s,r)=>(e.openBlock(),e.createElementBlock("div",su,[e.createVNode(G,{label:"Pan","model-value":t.data.pan,min:0,max:1,step:.01,"onUpdate:modelValue":r[0]||(r[0]=c=>a({pan:c}))},null,8,["model-value"]),e.createVNode(G,{label:"Postgain","model-value":t.data.postgain,min:0,max:2,step:.01,suffix:"×","onUpdate:modelValue":r[1]||(r[1]=c=>a({postgain:c}))},null,8,["model-value"])]))}}),ru={key:0,class:"strudel-flow-calls__control"},cu={class:"strudel-flow-field__label"},iu=["aria-label"],du=["aria-pressed","aria-label","onClick"],mu={class:"strudel-flow-field"},uu=["value"],_u=e.defineComponent({__name:"StrudelFlowMaskControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=e.computed(()=>{const[i]=Yt({method:"mask",argument:l.data.argument})??[];return(i==null?void 0:i.kind)==="toggles"?i:null}),s=i=>{o("update",{...l.data,argument:i})},r=i=>{a.value!==null&&s(qt([{...a.value,steps:a.value.steps.map((m,u)=>u===i?!m:m)}]))},c=i=>{i.target instanceof HTMLInputElement&&s(i.target.value)};return(i,m)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[a.value!==null?(e.openBlock(),e.createElementBlock("div",ru,[e.createElementVNode("span",cu,e.toDisplayString(a.value.perCycle?"Cycles that play":"Steps that play"),1),e.createElementVNode("div",{class:"strudel-flow-calls__steps",role:"group","aria-label":`Mask ${a.value.perCycle?"cycles":"steps"}`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value.steps,(u,p)=>(e.openBlock(),e.createElementBlock("button",{key:p,type:"button",class:e.normalizeClass(["strudel-flow-calls__step nodrag",{"strudel-flow-calls__step--on":u}]),"aria-pressed":u,"aria-label":`${a.value.perCycle?"Cycle":"Step"} ${p+1}`,onClick:S=>r(p)},null,10,du))),128))],8,iu)])):e.createCommentVNode("",!0),e.createElementVNode("label",mu,[m[0]||(m[0]=e.createElementVNode("span",{class:"strudel-flow-field__label"},"Mask pattern",-1)),e.createElementVNode("input",{class:"strudel-flow-calls__text nodrag",value:t.data.argument,"aria-label":"Mask pattern",spellcheck:"false",onInput:c},null,40,uu)])],64))}}),pu={class:"strudel-flow-knobs"},fu=e.defineComponent({__name:"StrudelFlowSlowControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n;return(a,s)=>(e.openBlock(),e.createElementBlock("div",pu,[e.createVNode(G,{label:"Slower by","model-value":l.data.amount,min:.25,max:8,step:.25,suffix:"×","onUpdate:modelValue":s[0]||(s[0]=r=>o("update",{...l.data,amount:r}))},null,8,["model-value"])]))}}),Eu=/^"\s*([x~](?:\s+[x~])*)\s*"$/,hu=t=>{var l;const n=(l=Eu.exec(t.trim()))==null?void 0:l[1].split(/\s+/);return n===void 0||n.length>X?null:n.map(o=>o==="x")},Su=t=>`"${t.map(n=>n?"x":"~").join(" ")}"`,gu={class:"strudel-flow-calls__steps",role:"group","aria-label":"Struct steps"},ku=["aria-pressed","aria-label","onClick"],bu={class:"strudel-flow-field"},Tu=["value"],Lu=e.defineComponent({__name:"StrudelFlowStructControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=e.computed(()=>hu(l.data.argument)),s=u=>{o("update",{...l.data,argument:u})},r=u=>{s(Su(u))},c=u=>{a.value!==null&&r(a.value.map((p,S)=>S===u?!p:p))},i=u=>{a.value!==null&&r(Array.from({length:u},(p,S)=>{var E;return((E=a.value)==null?void 0:E[S])??!1}))},m=u=>{u.target instanceof HTMLInputElement&&s(u.target.value)};return(u,p)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[a.value!==null?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(se,{label:"Steps","model-value":a.value.length,min:1,max:e.unref(X),"onUpdate:modelValue":i},null,8,["model-value","max"]),e.createElementVNode("div",gu,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(S,E)=>(e.openBlock(),e.createElementBlock("button",{key:E,type:"button",class:e.normalizeClass(["strudel-flow-calls__step nodrag",{"strudel-flow-calls__step--on":S}]),"aria-pressed":S,"aria-label":`Step ${E+1}`,onClick:b=>c(E)},null,10,ku))),128))])],64)):e.createCommentVNode("",!0),e.createElementVNode("label",bu,[p[0]||(p[0]=e.createElementVNode("span",{class:"strudel-flow-field__label"},"Struct pattern",-1)),e.createElementVNode("input",{class:"strudel-flow-calls__text nodrag",value:t.data.argument,"aria-label":"Struct pattern",spellcheck:"false",onInput:m},null,40,Tu)])],64))}}),wu={class:"strudel-flow-field__label"},yu=e.defineComponent({__name:"StrudelFlowVoicingControls",props:{data:{}},setup(t){return(n,l)=>(e.openBlock(),e.createElementBlock("p",wu,"Chord symbols play as voiced notes."))}}),Fu={class:"strudel-flow-pad"},Bu=["aria-pressed","aria-label","title","onClick"],$u={class:"strudel-flow-select strudel-flow-pad__modifier"},Ru=["value","aria-label","title","onChange"],Ou=["value"],Nu={class:"strudel-flow-accordion__row"},Cu={class:"strudel-flow-accordion__row"},Au={class:"strudel-flow-field"},Du={class:"strudel-flow-mode",role:"group","aria-label":"Pad mode"},Mu=["aria-pressed","onClick"],ya=e.defineComponent({__name:"StrudelFlowPadControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=Array.from({length:Xe},(p,S)=>S),s=["arp","chord"],r=e.computed(()=>Array.from({length:l.data.steps},(p,S)=>S)),c=e.computed(()=>{var p;return((p=ie.find(S=>S.value===l.data.scaleType))==null?void 0:p.label)??l.data.scaleType}),i=p=>{o("update",{...l.data,...p})},m=(p,S)=>{i({grid:l.data.grid.map((E,b)=>b===p?E.map((h,f)=>f===S?!h:h):E)})},u=(p,S)=>{const E=S.target;if(!(E instanceof HTMLSelectElement))return;const b={...l.data.columnModifiers};E.value.length===0?delete b[p]:b[p]=E.value,i({columnModifiers:b})};return(p,S)=>(e.openBlock(),e.createElementBlock("div",Fu,[e.createElementVNode("div",{class:"strudel-flow-pad__grid",style:e.normalizeStyle({"--pad-steps":t.data.steps}),role:"group","aria-label":"Pad notes"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,E=>(e.openBlock(),e.createElementBlock("div",{key:E,class:"strudel-flow-pad__column"},[S[4]||(S[4]=e.createElementVNode("span",{class:"strudel-flow-pad__playhead","aria-hidden":"true"},null,-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(a),b=>{var h,f;return e.openBlock(),e.createElementBlock("button",{key:b,type:"button",class:e.normalizeClass(["strudel-flow-pad__cell nodrag",{"strudel-flow-pad__cell--on":((h=t.data.grid[E])==null?void 0:h[b])===!0}]),"aria-pressed":((f=t.data.grid[E])==null?void 0:f[b])===!0,"aria-label":`Note ${b+1}, step ${E+1}`,title:`Note ${b+1}, step ${E+1}`,onClick:_=>m(E,b)},null,10,Bu)}),128)),e.createElementVNode("span",$u,[e.createElementVNode("select",{value:t.data.columnModifiers[E]??"","aria-label":`Step ${E+1} variation`,title:`Step ${E+1} variation`,onChange:b=>u(E,b)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref($e),b=>(e.openBlock(),e.createElementBlock("option",{key:b.value,value:b.value},e.toDisplayString(b.value||"○"),9,Ou))),128))],40,Ru)])]))),128))],4),e.createVNode(_t,{badge:`${t.data.key}${t.data.octave}`,summary:c.value,meta:`${t.data.steps} steps`},{default:e.withCtx(()=>[e.createElementVNode("div",Nu,[e.createVNode(Z,{label:"Key","model-value":t.data.key,options:e.unref(ce),"onUpdate:modelValue":S[0]||(S[0]=E=>i({key:E}))},null,8,["model-value","options"]),e.createVNode(Z,{label:"Scale","model-value":t.data.scaleType,options:e.unref(ie),"onUpdate:modelValue":S[1]||(S[1]=E=>i({scaleType:E}))},null,8,["model-value","options"]),e.createVNode(se,{label:"Octave","model-value":t.data.octave,min:1,max:8,"onUpdate:modelValue":S[2]||(S[2]=E=>i({octave:E}))},null,8,["model-value"])]),e.createElementVNode("div",Cu,[e.createVNode(se,{label:"Steps","model-value":t.data.steps,min:1,max:16,"onUpdate:modelValue":S[3]||(S[3]=E=>i({steps:E}))},null,8,["model-value"]),e.createElementVNode("div",Au,[S[5]||(S[5]=e.createElementVNode("span",{class:"strudel-flow-field__label"},"Mode",-1)),e.createElementVNode("div",Du,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(s,E=>e.createElementVNode("button",{key:E,type:"button",class:e.normalizeClass(["strudel-flow-mode__button nodrag",{"strudel-flow-mode__button--active":t.data.mode===E}]),"aria-pressed":t.data.mode===E,onClick:b=>i({mode:E})},e.toDisplayString(E==="arp"?"Arp":"Chord"),11,Mu)),64))])])])]),_:1},8,["badge","summary","meta"])]))}}),Uu={class:"strudel-flow-note-names nowheel","aria-label":"Notes by bar"},Pu={class:"strudel-flow-note-names__bar-number"},Iu={class:"strudel-flow-note-names__name"},Vu={class:"strudel-flow-note-names__length"},Wu="~",Hu=1e-6,Fa=e.defineComponent({__name:"StrudelFlowNoteNames",props:{bars:{},beatsPerBar:{}},setup(t){const n=t,l=a=>a>Hu?[{name:Wu,beats:a}]:[],o=e.computed(()=>n.bars.map(a=>{const s=a.reduce((r,c)=>({end:c.start+c.beats,entries:[...r.entries,...l(c.start-r.end),{name:c.notes.join(","),beats:c.beats}]}),{end:0,entries:[]});return[...s.entries,...l(n.beatsPerBar-s.end)]}));return(a,s)=>(e.openBlock(),e.createElementBlock("ol",Uu,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,(r,c)=>(e.openBlock(),e.createElementBlock("li",{key:c,class:"strudel-flow-note-names__bar"},[e.createElementVNode("span",Pu,e.toDisplayString(c+1),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r,(i,m)=>(e.openBlock(),e.createElementBlock("span",{key:m,class:"strudel-flow-note-names__note"},[e.createElementVNode("span",Iu,e.toDisplayString(i.name),1),s[0]||(s[0]=e.createTextVNode()),e.createElementVNode("span",Vu,e.toDisplayString(e.unref(Wo)(i.beats)),1)]))),128))]))),128))]))}}),Gu={key:0,class:"strudel-flow-piano-roll nowheel"},xu=["width","height","viewBox","aria-label"],Xu=["y","width","height"],zu=["y"],Ku=["x1","x2","y2"],ju=["x","y","width","height"],Bn=12,Ba=e.defineComponent({__name:"StrudelFlowPianoRoll",props:{bars:{},beatsPerBar:{}},setup(t){const n=t,l=e.computed(()=>n.bars.flatMap((S,E)=>S.flatMap(b=>b.notes.flatMap(h=>{const f=hn(h);return f===null?[]:[{midiNote:f,beat:E*n.beatsPerBar+b.start,beats:b.beats}]})))),o=e.computed(()=>{const S=l.value.map(h=>h.midiNote),E=Math.min(...S)-1,b=Math.max(Math.max(...S)+1,E+ol-1);return{low:E,high:b}}),a=e.computed(()=>Array.from({length:o.value.high-o.value.low+1},(S,E)=>o.value.high-E)),s=S=>(o.value.high-S)*de,r=S=>ll+S*Rt,c=e.computed(()=>r(n.bars.length*n.beatsPerBar)),i=e.computed(()=>a.value.length*de),m=S=>al.includes(S%Bn),u=S=>S%Bn===0,p=S=>Math.floor(S/Bn)-1;return(S,E)=>l.value.length>0?(e.openBlock(),e.createElementBlock("div",Gu,[(e.openBlock(),e.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg","data-notation":"piano",width:c.value,height:i.value,viewBox:`0 0 ${c.value} ${i.value}`,role:"img","aria-label":`Piano roll, ${t.bars.length} bars`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,b=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:b},[m(b)?(e.openBlock(),e.createElementBlock("rect",{key:0,class:"strudel-flow-piano-roll__black-key",x:0,y:s(b),width:c.value,height:e.unref(de)},null,8,Xu)):e.createCommentVNode("",!0),u(b)?(e.openBlock(),e.createElementBlock("text",{key:1,class:"strudel-flow-piano-roll__label",x:2,y:s(b)+e.unref(de)}," C"+e.toDisplayString(p(b)),9,zu)):e.createCommentVNode("",!0)],64))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.bars.length+1,b=>(e.openBlock(),e.createElementBlock("line",{key:`bar-${b}`,class:"strudel-flow-piano-roll__bar-line",x1:r((b-1)*t.beatsPerBar),y1:0,x2:r((b-1)*t.beatsPerBar),y2:i.value},null,8,Ku))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,(b,h)=>(e.openBlock(),e.createElementBlock("rect",{key:`note-${h}`,class:"strudel-flow-piano-roll__note",x:r(b.beat),y:s(b.midiNote),width:Math.max(1,b.beats*e.unref(Rt)-1),height:e.unref(de),rx:"1"},null,8,ju))),128))],8,xu))])):e.createCommentVNode("",!0)}}),Yu={class:"strudel-flow-sheet nowheel"},qu=["width","height","viewBox","aria-label"],Zu=["data-clef","stroke-width"],Ju=["x1","y1","x2","y2"],Qu=["x","y","font-size"],vu=["x1","y1","x2","y2","stroke-width"],e_=["d","stroke-width"],t_=["d","stroke-width"],n_=["x1","y1","x2","y2","stroke-width"],l_=["cx","cy","rx","ry","transform","stroke-width"],o_=["x","y","font-size"],a_=["x1","y1","x2","y2","stroke-width"],s_=["d","stroke-width"],r_=["cx","cy","r"],c_=["d","stroke-width"],i_=["x","y","font-size"],d_="'Noto Music', 'Apple Symbols', 'Segoe UI Symbol', serif",m_=4.2,u_=-20,$a=e.defineComponent({__name:"StrudelFlowSheet",props:{bars:{},beatsPerBar:{}},setup(t){const n=t,l=[0,1,2,3,4],o={treble:3,bass:1},a=e.computed(()=>oa(n.bars,n.beatsPerBar)),s=e.computed(()=>a.value.lineGap),r=e.computed(()=>Ml*s.value),c=e.computed(()=>a.value.staves[0].topY),i=e.computed(()=>a.value.staves.at(-1).bottomY),m=(p,S)=>p.bottomY-S*s.value,u=e.computed(()=>`Piano sheet on ${a.value.staves.map(p=>p.clef).join(" and ")} clef, ${n.bars.length} bars`);return(p,S)=>(e.openBlock(),e.createElementBlock("div",Yu,[(e.openBlock(),e.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg","data-notation":"sheet",width:a.value.width,height:a.value.height,viewBox:`0 0 ${a.value.width} ${a.value.height}`,role:"img","aria-label":u.value},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value.staves,E=>(e.openBlock(),e.createElementBlock("g",{key:E.clef,class:"strudel-flow-sheet__staff","data-clef":E.clef,"stroke-width":r.value},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(l,b=>e.createElementVNode("line",{key:b,class:"strudel-flow-sheet__line",x1:a.value.staffStartX,y1:m(E,b),x2:a.value.staffEndX,y2:m(E,b)},null,8,Ju)),64)),e.createElementVNode("text",{class:"strudel-flow-sheet__clef",x:a.value.staffStartX+s.value*.4,y:m(E,o[E.clef])+(E.clef==="treble"?s.value:0),"font-size":m_*s.value,"font-family":d_},e.toDisplayString(e.unref(Sl)[E.clef]),9,Qu)],8,Zu))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList([a.value.staffStartX,...a.value.barEndXs],E=>(e.openBlock(),e.createElementBlock("line",{key:`bar-${E}`,class:"strudel-flow-sheet__bar-line",x1:E,y1:c.value,x2:E,y2:i.value,"stroke-width":r.value},null,8,vu))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value.ties,(E,b)=>(e.openBlock(),e.createElementBlock("path",{key:`tie-${b}`,class:"strudel-flow-sheet__tie",d:E,fill:"none","stroke-width":r.value*1.4},null,8,e_))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value.rests,(E,b)=>(e.openBlock(),e.createElementBlock("path",{key:`rest-${b}`,class:e.normalizeClass(["strudel-flow-sheet__rest",{"strudel-flow-sheet__rest--solid":E.solid}]),d:E.path,"stroke-width":r.value*2},null,10,t_))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value.chords,(E,b)=>(e.openBlock(),e.createElementBlock("g",{key:`chord-${b}`,class:"strudel-flow-sheet__chord"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E.heads,(h,f)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:f},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.ledgerYs,_=>(e.openBlock(),e.createElementBlock("line",{key:`ledger-${_}`,class:"strudel-flow-sheet__ledger",x1:E.x-e.unref(Vt)*s.value,y1:_,x2:E.x+e.unref(Vt)*s.value,y2:_,"stroke-width":r.value},null,8,n_))),128)),e.createElementVNode("ellipse",{class:e.normalizeClass(["strudel-flow-sheet__head",{"strudel-flow-sheet__head--open":!E.filled}]),cx:E.x,cy:h.y,rx:e.unref(It)*s.value,ry:e.unref($l)*s.value,transform:`rotate(${u_} ${E.x} ${h.y})`,"stroke-width":r.value*1.5},null,10,l_),h.accidental!==null?(e.openBlock(),e.createElementBlock("text",{key:0,class:"strudel-flow-sheet__accidental",x:E.x-e.unref(Nl)*s.value,y:h.y+s.value*.5,"text-anchor":"middle","font-size":s.value*2},e.toDisplayString(e.unref(gl)[h.accidental]),9,o_)):e.createCommentVNode("",!0)],64))),128)),E.stem!==null?(e.openBlock(),e.createElementBlock("line",{key:0,class:"strudel-flow-sheet__stem",x1:E.stem.x1,y1:E.stem.y1,x2:E.stem.x2,y2:E.stem.y2,"stroke-width":r.value},null,8,a_)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E.flags,(h,f)=>(e.openBlock(),e.createElementBlock("path",{key:`flag-${f}`,class:"strudel-flow-sheet__flag",d:h,fill:"none","stroke-width":r.value*1.5},null,8,s_))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E.dots,(h,f)=>(e.openBlock(),e.createElementBlock("circle",{key:`dot-${f}`,class:"strudel-flow-sheet__dot",cx:h.x,cy:h.y,r:s.value*.18},null,8,r_))),128))]))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value.brackets,(E,b)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`bracket-${b}`},[e.createElementVNode("path",{class:"strudel-flow-sheet__bracket",d:E.path,fill:"none","stroke-width":r.value},null,8,c_),e.createElementVNode("text",{class:"strudel-flow-sheet__bracket-label",x:E.labelX,y:a.value.bracketLabelY,"text-anchor":"middle","font-size":e.unref(Mt)*s.value*1.4}," 3 ",8,i_)],64))),128))],8,qu))]))}}),__={class:"strudel-flow-tab-staff nowheel"},p_=["data-notation","width","height","viewBox","aria-label"],f_=["stroke-width"],E_=["x1","y1","x2","y2"],h_=["x1","y1","x2","y2","stroke-width"],S_=["d","stroke-width"],g_=["x","y","font-size"],k_=["x"],b_=["x","y","width","height"],T_=["x1","y1","x2","y2","stroke-width"],L_=["x1","y1","x2","y2","stroke-width"],w_=["d","stroke-width"],y_=["x","y","font-size"],Ra="Arial, Helvetica, sans-serif",Oa=e.defineComponent({__name:"StrudelFlowTabStaff",props:{bars:{},instrument:{},beatsPerBar:{}},setup(t){const n=t,l=e.computed(()=>Qo(n.bars,n.instrument,n.beatsPerBar)),o=e.computed(()=>sl*l.value.lineGap),a=e.computed(()=>`${n.instrument==="bass"?"Bass":"Guitar"} tab, ${n.bars.length} bars`);return(s,r)=>(e.openBlock(),e.createElementBlock("div",__,[(e.openBlock(),e.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",class:"strudel-flow-tab-staff__staff","data-notation":t.instrument,width:l.value.width,height:l.value.height,viewBox:`0 0 ${l.value.width} ${l.value.height}`,role:"img","aria-label":a.value},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value.strings,(c,i)=>(e.openBlock(),e.createElementBlock("g",{key:`string-${i}`,class:"strudel-flow-tab-staff__string","stroke-width":o.value},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c,(m,u)=>(e.openBlock(),e.createElementBlock("line",{key:u,x1:m.x1,y1:m.y1,x2:m.x2,y2:m.y2},null,8,E_))),128))],8,f_))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value.barLines,(c,i)=>(e.openBlock(),e.createElementBlock("line",{key:`bar-${i}`,class:"strudel-flow-tab-staff__bar-line",x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,"stroke-width":o.value},null,8,h_))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value.ties,(c,i)=>(e.openBlock(),e.createElementBlock("path",{key:`tie-${i}`,class:"strudel-flow-tab-staff__tie",d:c,fill:"none","stroke-width":o.value},null,8,S_))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value.frets,(c,i)=>(e.openBlock(),e.createElementBlock("text",{key:`fret-${i}`,class:"strudel-flow-tab-staff__fret",x:c.x,y:c.y+e.unref(il)*l.value.lineGap,"text-anchor":"middle","font-family":Ra,"font-weight":"700","font-size":e.unref(cl)*l.value.lineGap},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.digits,(m,u)=>(e.openBlock(),e.createElementBlock("tspan",{key:u,x:m.x},e.toDisplayString(m.digit),9,k_))),128))],8,g_))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value.rests,(c,i)=>(e.openBlock(),e.createElementBlock("rect",{key:`rest-${i}`,class:"strudel-flow-tab-staff__rest",x:c.x,y:c.y,width:c.width,height:c.height},null,8,b_))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value.stems,(c,i)=>(e.openBlock(),e.createElementBlock("line",{key:`stem-${i}`,class:"strudel-flow-tab-staff__stem",x1:c.x,y1:l.value.stemTop,x2:c.x,y2:l.value.stemBottom,"stroke-width":e.unref(rl)*l.value.lineGap},null,8,T_))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value.beams,(c,i)=>(e.openBlock(),e.createElementBlock("line",{key:`beam-${i}`,class:"strudel-flow-tab-staff__beam",x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,"stroke-width":e.unref(wt)*l.value.lineGap},null,8,L_))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value.brackets,(c,i)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`bracket-${i}`},[e.createElementVNode("path",{class:"strudel-flow-tab-staff__bracket",d:c.path,fill:"none","stroke-width":o.value},null,8,w_),e.createElementVNode("text",{class:"strudel-flow-tab-staff__bracket-label",x:c.labelX,y:l.value.bracketLabelY,"text-anchor":"middle","font-family":Ra,"font-size":e.unref(Mt)*l.value.lineGap}," 3 ",8,y_)],64))),128))],8,p_))]))}}),$n=Symbol("strudelFlowNotationContext"),F_={key:0,class:"strudel-flow-field"},B_=["aria-checked"],Na=e.defineComponent({__name:"StrudelFlowNotation",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=e.inject($n,null),s=j.useNodeId(),r=e.ref([]),c=e.computed(()=>(a==null?void 0:a.value.beatsPerCycle)??J),i=e.computed(()=>(a==null?void 0:a.value.soundOf(s))??""),m=new Set(["names","text"]),u=e.computed(()=>l.data.head==="chord"),p=e.computed(()=>{const f=Xo(l.data.notation,i.value);return u.value&&!m.has(f)?"names":f}),S=f=>{var _;return((_=Oe.find(g=>g.value===f))==null?void 0:_.label)??f},E=e.computed(()=>Oe.filter(f=>!u.value||m.has(f.value)).map(f=>f.value==="auto"?{...f,label:`Auto: ${S(Sn(i.value))}`}:f));e.watch([()=>l.data.pattern,c,()=>a==null?void 0:a.value.readNoteBars],async([f,_,g])=>{const T=g==null?[]:await g(f,_);f===l.data.pattern&&(r.value=T)},{immediate:!0});const b=()=>{o("update",{...l.data,showPattern:l.data.showPattern!==!0})},h=f=>{var g;const _=(g=Oe.find(T=>T.value===f))==null?void 0:g.value;_!==void 0&&o("update",{...l.data,notation:_})};return(f,_)=>{var g;return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(Z,{label:"Notation","model-value":t.data.notation,options:E.value,"onUpdate:modelValue":h},null,8,["model-value","options"]),p.value!=="text"&&((g=e.unref(a))!=null&&g.readNoteBars)?(e.openBlock(),e.createElementBlock("div",F_,[_[1]||(_[1]=e.createElementVNode("span",{class:"strudel-flow-field__label"},"Mini notation",-1)),e.createElementVNode("button",{type:"button",role:"switch",class:"strudel-flow-switch nodrag","aria-checked":t.data.showPattern===!0,"aria-label":"Show mini notation",onClick:b},[..._[0]||(_[0]=[e.createElementVNode("span",{class:"strudel-flow-switch__thumb","aria-hidden":"true"},null,-1)])],8,B_)])):e.createCommentVNode("",!0),r.value.length>0&&p.value!=="text"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[p.value==="bass"||p.value==="guitar"?(e.openBlock(),e.createBlock(Oa,{key:0,bars:r.value,instrument:p.value,"beats-per-bar":c.value},null,8,["bars","instrument","beats-per-bar"])):p.value==="sheet"?(e.openBlock(),e.createBlock($a,{key:1,bars:r.value,"beats-per-bar":c.value},null,8,["bars","beats-per-bar"])):p.value==="piano"?(e.openBlock(),e.createBlock(Ba,{key:2,bars:r.value,"beats-per-bar":c.value},null,8,["bars","beats-per-bar"])):(e.openBlock(),e.createBlock(Fa,{key:3,bars:r.value,"beats-per-bar":c.value},null,8,["bars","beats-per-bar"]))],64)):e.createCommentVNode("",!0)],64)}}}),$_={key:0,class:"strudel-flow-field"},R_=["value"],O_=e.defineComponent({__name:"StrudelFlowPatternControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=e.inject($n,null),s=e.computed(()=>!(a!=null&&a.value.readNoteBars)||l.data.notation==="text"||l.data.showPattern===!0),r=c=>{const i=c.target;i instanceof HTMLTextAreaElement&&o("update",{...l.data,pattern:i.value})};return(c,i)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(Na,{data:t.data,onUpdate:i[0]||(i[0]=m=>o("update",m))},null,8,["data"]),s.value?(e.openBlock(),e.createElementBlock("label",$_,[i[1]||(i[1]=e.createElementVNode("span",{class:"strudel-flow-field__label"},"Notes in mini notation",-1)),e.createElementVNode("textarea",{class:"strudel-flow-textarea",value:t.data.pattern,"aria-label":"Notes pattern",rows:"2",spellcheck:"false",onInput:r},null,40,R_)])):e.createCommentVNode("",!0)],64))}}),N_={key:0,class:"strudel-flow-sample-steps__hint"},C_=["aria-label"],A_={key:0,class:"strudel-flow-sample-steps__layer-label"},D_=["aria-label","onClick"],M_={class:"strudel-flow-sample-steps__sequence"},U_={class:"strudel-flow-sample-steps__tile-header"},P_={class:"strudel-flow-sample-steps__index","aria-hidden":"true"},I_={key:0,class:"strudel-flow-sample-steps__bracket",role:"group","aria-label":"Group timing"},V_=["aria-pressed","aria-label","title","onClick"],W_=["aria-label","title","onClick"],H_=["value","aria-label","onChange"],G_={key:4,class:"strudel-flow-sample-steps__modifier"},x_={class:"strudel-flow-sample-steps__add"},X_=["onClick"],z_=["onClick"],K_=e.defineComponent({__name:"StrudelFlowSampleSteps",props:{layers:{},sampleGroups:{},nested:{type:Boolean}},emits:["update:layers"],setup(t,{emit:n}){const l=t,o=n,a=[{value:"subdivide",label:"Fit in one step",icon:e.markRaw(w.Brackets)},{value:"alternate",label:"One per cycle",icon:e.markRaw(w.ArrowLeftRight)}],s=e.markRaw(w.Plus),r=e.markRaw(w.Pause),c=e.markRaw(w.Code),i=L=>{var k;return(k=Wt.find(F=>F.value===L))==null?void 0:k.kind},m=L=>{const k=i(L);return k===void 0?c:dd[k]},u=L=>{const k=Ul.map(F=>({label:F.label,options:Wt.filter($=>$.kind===F.id)}));return i(L)===void 0?[{label:"In this pattern",options:[{value:L,label:L}]},...k]:k},p=L=>L.kind==="group"&&L.layers.every(k=>k.length===0),S=L=>{o("update:layers",L)},E=(L,k)=>{S(l.layers.map((F,$)=>$===L?k.filter(D=>!p(D)):F))},b=(L,k,F)=>{E(L,(l.layers[L]??[]).map(($,D)=>D===k?F:$))},h=(L,k)=>{E(L,(l.layers[L]??[]).filter((F,$)=>$!==k))},f=(L,k)=>{E(L,[...l.layers[L]??[],k])},_=(L,k)=>{k.length>0&&f(L,{kind:"sound",sound:k,modifier:""})},g=(L,k,F)=>{F.length>0&&b(L,k,{kind:"sound",sound:F,modifier:""})},T=L=>{f(L,{kind:"group",bracket:"subdivide",layers:[[{kind:"rest"}]],modifier:""})},O=()=>{S([...l.layers,[{kind:"rest"}]])},V=L=>{S(l.layers.filter((k,F)=>F!==L))},C=L=>L.target instanceof HTMLInputElement?L.target.value:"",y=L=>L.kind==="sound"?L.sound:L.kind==="text"?"notation":L.kind;return(L,k)=>{const F=e.resolveComponent("StrudelFlowSampleSteps",!0);return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["strudel-flow-sample-steps",{"strudel-flow-sample-steps--nested":t.nested}])},[t.nested?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("p",N_," Steps share one cycle, left to right. Layers play together. ")),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.layers,($,D)=>(e.openBlock(),e.createElementBlock("div",{key:D,class:"strudel-flow-sample-steps__layer",role:"group","aria-label":t.layers.length>1?`Layer ${D+1}`:"Steps"},[t.layers.length>1?(e.openBlock(),e.createElementBlock("div",A_,[e.createVNode(e.unref(w.Layers),{"aria-hidden":"true"}),e.createElementVNode("span",null,"Layer "+e.toDisplayString(D+1),1),e.createElementVNode("button",{type:"button",class:"strudel-flow-calls__remove nodrag","aria-label":`Remove layer ${D+1}`,title:"Remove layer",onClick:N=>V(D)},[e.createVNode(e.unref(w.X),{"aria-hidden":"true"})],8,D_)])):e.createCommentVNode("",!0),e.createElementVNode("ol",M_,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList($,(N,A)=>(e.openBlock(),e.createElementBlock("li",{key:A,class:e.normalizeClass(["strudel-flow-sample-steps__tile",`strudel-flow-sample-steps__tile--${N.kind}`])},[e.createElementVNode("div",U_,[e.createElementVNode("span",P_,e.toDisplayString(A+1),1),N.kind==="group"?(e.openBlock(),e.createElementBlock("div",I_,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(a,U=>e.createElementVNode("button",{key:U.value,type:"button",class:e.normalizeClass(["strudel-flow-sample-steps__bracket-button nodrag",{"strudel-flow-sample-steps__bracket-button--active":N.bracket===U.value}]),"aria-pressed":N.bracket===U.value,"aria-label":U.label,title:U.label,onClick:R=>b(D,A,{...N,bracket:U.value})},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(U.icon),{"aria-hidden":"true"}))],10,V_)),64))])):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"strudel-flow-calls__remove strudel-flow-sample-steps__remove nodrag","aria-label":`Remove ${y(N)} step ${A+1}`,title:`Remove ${y(N)}`,onClick:U=>h(D,A)},[e.createVNode(e.unref(w.X),{"aria-hidden":"true"})],8,W_)]),N.kind==="group"?(e.openBlock(),e.createBlock(F,{key:0,layers:N.layers,"sample-groups":t.sampleGroups,nested:"","onUpdate:layers":U=>b(D,A,{...N,layers:U})},null,8,["layers","sample-groups","onUpdate:layers"])):N.kind==="sound"?(e.openBlock(),e.createBlock(We,{key:1,label:`Step ${A+1} sample`,"model-value":N.sound,groups:t.sampleGroups,"onUpdate:modelValue":U=>b(D,A,{...N,sound:U})},null,8,["label","model-value","groups","onUpdate:modelValue"])):N.kind==="rest"?(e.openBlock(),e.createBlock(We,{key:2,label:`Step ${A+1} sample`,"model-value":"",placeholder:"Rest","empty-icon":e.unref(r),groups:t.sampleGroups,"onUpdate:modelValue":U=>g(D,A,U)},null,8,["label","empty-icon","groups","onUpdate:modelValue"])):(e.openBlock(),e.createElementBlock("input",{key:3,class:"strudel-flow-calls__text nodrag",value:N.text,"aria-label":`Step ${A+1} mini notation`,spellcheck:"false",onChange:U=>b(D,A,{kind:"text",text:C(U)})},null,40,H_)),N.kind==="sound"||N.kind==="group"?(e.openBlock(),e.createElementBlock("div",G_,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(m(N.modifier)),{class:"strudel-flow-sample-steps__modifier-icon","aria-hidden":"true"})),e.createVNode(Z,{label:N.kind==="group"?"Group plays":`Step ${A+1} plays`,"hide-label":"","model-value":N.modifier,groups:u(N.modifier),"onUpdate:modelValue":U=>b(D,A,{...N,modifier:U})},null,8,["label","model-value","groups","onUpdate:modelValue"])])):e.createCommentVNode("",!0)],2))),128)),e.createElementVNode("li",x_,[t.sampleGroups.length>0?(e.openBlock(),e.createBlock(We,{key:0,label:"Add sample","model-value":"",placeholder:"Sample","empty-icon":e.unref(s),groups:t.sampleGroups,"onUpdate:modelValue":N=>_(D,N)},null,8,["empty-icon","groups","onUpdate:modelValue"])):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"strudel-flow-sample-steps__add-button nodrag","aria-label":"Add rest",title:"Add a rest",onClick:N=>f(D,{kind:"rest"})},[e.createVNode(e.unref(w.Pause),{"aria-hidden":"true"})],8,X_),e.createElementVNode("button",{type:"button",class:"strudel-flow-sample-steps__add-button nodrag","aria-label":"Add group",title:"Add a group of steps that share one step",onClick:N=>T(D)},[e.createVNode(e.unref(w.Brackets),{"aria-hidden":"true"})],8,z_)])])],8,C_))),128)),t.nested?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"strudel-flow-calls__add nodrag",title:"Add a layer that plays alongside",onClick:O},[e.createVNode(e.unref(w.Layers),{"aria-hidden":"true"}),k[0]||(k[0]=e.createTextVNode(" Add layer ",-1))]))],2)}}}),j_={class:"strudel-flow-field strudel-flow-field--inline"},Y_=["aria-checked"],q_=["value"],Z_=e.defineComponent({__name:"StrudelFlowSamplesControls",props:{data:{},sampleGroups:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=e.computed(()=>Tn(l.data.pattern)),s=i=>{o("update",{...l.data,...i})},r=i=>{s({pattern:Ln(i)})},c=i=>{i.target instanceof HTMLTextAreaElement&&s({pattern:i.target.value})};return(i,m)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(K_,{layers:a.value,"sample-groups":t.sampleGroups??[],"onUpdate:layers":r},null,8,["layers","sample-groups"]),e.createElementVNode("div",j_,[m[2]||(m[2]=e.createElementVNode("span",{class:"strudel-flow-field__label"},"Mini notation",-1)),e.createElementVNode("button",{type:"button",role:"switch",class:"strudel-flow-switch nodrag","aria-checked":t.data.showPattern===!0,"aria-label":"Show mini notation",onClick:m[0]||(m[0]=u=>s({showPattern:t.data.showPattern!==!0}))},[...m[1]||(m[1]=[e.createElementVNode("span",{class:"strudel-flow-switch__thumb","aria-hidden":"true"},null,-1)])],8,Y_)]),t.data.showPattern===!0?(e.openBlock(),e.createElementBlock("textarea",{key:0,class:"strudel-flow-textarea",value:t.data.pattern,"aria-label":"Samples pattern",rows:"2",spellcheck:"false",onInput:c},null,40,q_)):e.createCommentVNode("",!0)],64))}}),J_={class:"strudel-flow-visualizer__settings"},Q_={class:"strudel-flow-mode",role:"group","aria-label":"Where the visual draws"},v_=["aria-pressed","onClick"],Ca=e.defineComponent({__name:"StrudelFlowVisualizerControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=r=>{o("update",{...l.data,...r})},s=r=>{const c=Be.find(i=>i.value===r);c!==void 0&&a({visual:c.value})};return(r,c)=>(e.openBlock(),e.createElementBlock("div",J_,[e.createVNode(Z,{label:"Type","hide-label":"","model-value":t.data.visual,options:e.unref(Be),"onUpdate:modelValue":s},null,8,["model-value","options"]),e.createElementVNode("div",Q_,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(Un),i=>(e.openBlock(),e.createElementBlock("button",{key:i.value,type:"button",class:e.normalizeClass(["strudel-flow-mode__button nodrag",{"strudel-flow-mode__button--active":t.data.placement===i.value}]),"aria-pressed":t.data.placement===i.value,onClick:m=>a({placement:i.value==="background"?"background":"inline"})},e.toDisplayString(i.label),11,v_))),128))])]))}}),ep={key:0,class:"strudel-flow-visualizer__hint"},Aa=e.defineComponent({__name:"StrudelFlowVisualPreview",props:{placement:{},widgetId:{}},setup(t){const n=t,l=e.ref(null),o=e.ref(!1);let a=null;const s=e.computed(()=>n.placement==="background"),r=e.computed(()=>n.widgetId===null&&n.placement==="inline"?"Connect an instrument to draw its visual here.":"Press Play to draw the visual here."),c=e.computed(()=>n.placement==="background"?Vn:n.widgetId),i=()=>{const u=c.value===null?null:document.getElementById(c.value);return u instanceof HTMLCanvasElement&&u.width>0&&u.height>0?u:null},m=()=>{const u=i(),p=l.value,S=p==null?void 0:p.getContext("2d");u!==null&&p!==null&&S!==null&&S!==void 0&&((p.width!==u.width||p.height!==u.height)&&(p.width=u.width,p.height=u.height),S.clearRect(0,0,p.width,p.height),S.drawImage(u,0,0)),o.value!==(u!==null)&&(o.value=u!==null),a=window.requestAnimationFrame(m)};return e.onMounted(()=>{a=window.requestAnimationFrame(m)}),e.onBeforeUnmount(()=>{a!==null&&window.cancelAnimationFrame(a)}),(u,p)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["strudel-flow-visual-preview",{"strudel-flow-visual-preview--backdrop":s.value}])},[e.withDirectives(e.createElementVNode("canvas",{ref_key:"previewCanvas",ref:l,class:"strudel-flow-visual-preview__canvas",role:"img","aria-label":"Live visual of the pattern"},null,512),[[e.vShow,o.value]]),!o.value&&!s.value?(e.openBlock(),e.createElementBlock("p",ep,e.toDisplayString(r.value),1)):e.createCommentVNode("",!0)],2))}}),tp={class:"strudel-flow-knobs"},Da=e.defineComponent({__name:"StrudelFlowSpaceControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=s=>{o("update",{...l.data,...s})};return(s,r)=>(e.openBlock(),e.createElementBlock("div",tp,[e.createVNode(G,{label:"Room","model-value":t.data.room,min:0,max:1,step:.01,"onUpdate:modelValue":r[0]||(r[0]=c=>a({room:c}))},null,8,["model-value"]),e.createVNode(G,{label:"Size","model-value":t.data.roomSize,min:0,max:20,step:.1,"onUpdate:modelValue":r[1]||(r[1]=c=>a({roomSize:c}))},null,8,["model-value"]),e.createVNode(G,{label:"Fade","model-value":t.data.roomFade,min:0,max:10,step:.1,"onUpdate:modelValue":r[2]||(r[2]=c=>a({roomFade:c}))},null,8,["model-value"]),e.createVNode(G,{label:"Low-pass","model-value":t.data.roomLowPass,min:0,max:2e4,step:100,suffix:"Hz","onUpdate:modelValue":r[3]||(r[3]=c=>a({roomLowPass:c}))},null,8,["model-value"]),e.createVNode(G,{label:"Dim","model-value":t.data.roomDim,min:0,max:2e4,step:100,suffix:"Hz","onUpdate:modelValue":r[4]||(r[4]=c=>a({roomDim:c}))},null,8,["model-value"])]))}}),np={class:"strudel-flow-voice"},lp={class:"strudel-flow-voice__waveforms",role:"group","aria-label":"Voice waveform"},op=["aria-label","title","aria-pressed","onClick"],ap={viewBox:"0 0 36 32","aria-hidden":"true"},sp=["d"],Ma=e.defineComponent({__name:"StrudelFlowVoiceControls",props:{data:{},voiceGroups:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=e.computed(()=>l.data.sound),s=new Set(gt.map(m=>m.value)),r=e.computed(()=>[{label:"Waveforms",samples:gt},...(l.voiceGroups??[]).map(m=>({label:m.label,samples:m.samples.filter(u=>!s.has(u.value))})).filter(m=>m.samples.length>0)]),c=m=>{o("update",{kind:"voice",sound:m})},i=[{value:"sine",label:"Sine",path:"M2 16 C8 0 12 0 18 16 S28 32 34 16"},{value:"triangle",label:"Triangle",path:"M2 24 L10 8 L26 24 L34 8"},{value:"sawtooth",label:"Saw",path:"M2 24 L17 8 L17 24 L32 8 L32 24"},{value:"square",label:"Square",path:"M2 24 L2 8 L18 8 L18 24 L34 24 L34 8"}];return(m,u)=>(e.openBlock(),e.createElementBlock("div",np,[e.createElementVNode("div",lp,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(i,p=>e.createElementVNode("button",{key:p.value,type:"button",class:e.normalizeClass(["strudel-flow-voice__waveform nodrag",{"strudel-flow-voice__waveform--active":a.value===p.value}]),"aria-label":p.label,title:p.label,"aria-pressed":a.value===p.value,onClick:S=>c(p.value)},[(e.openBlock(),e.createElementBlock("svg",ap,[e.createElementVNode("path",{d:p.path},null,8,sp)]))],10,op)),64))]),e.createVNode(We,{label:"Voice","model-value":a.value,groups:r.value,"onUpdate:modelValue":c},null,8,["model-value","groups"])]))}}),Ua=Symbol("strudelFlowVisualizerWidgetIds"),rp=["data-node-kind"],cp={class:"strudel-flow-node__header"},ip={class:"strudel-flow-node__title"},dp=["title","aria-label","aria-pressed"],mp=["title","aria-label","aria-pressed"],up=["title","aria-label","aria-expanded"],_p={key:2,class:"strudel-flow-node__menu nodrag",role:"menu"},pp={key:2,class:"strudel-flow-node__code nodrag"},fp={class:"strudel-flow-node__body nodrag"},Ep="pattern",Pa=e.defineComponent({__name:"StrudelFlowNode",props:{id:{},data:{},selected:{type:Boolean},sampleGroups:{},voiceGroups:{},isSoloed:{type:Boolean},isPlaying:{type:Boolean}},emits:["update","remove","showCode","solo"],setup(t,{emit:n}){const l=t,o=n,a={pad:e.markRaw(ya),beats:e.markRaw(pa),chords:e.markRaw(Sa),notes:e.markRaw(O_),samples:e.markRaw(Z_),code:e.markRaw(ga),voice:e.markRaw(Ma),filter:e.markRaw(La),delay:e.markRaw(ka),space:e.markRaw(Da),gain:e.markRaw(au),level:e.markRaw(wa),mask:e.markRaw(_u),struct:e.markRaw(Lu),slow:e.markRaw(fu),voicing:e.markRaw(yu),envelope:e.markRaw(Ta),visualizer:e.markRaw(Ca)},s=new Set(["samples","beats"]),r=e.ref(!1),c=e.ref(!1),i=e.computed(()=>lo(l.data.kind)),m=e.computed(()=>i.value.title),u=e.computed(()=>s.has(l.data.kind)?{sampleGroups:l.sampleGroups??[]}:l.data.kind==="voice"?{voiceGroups:l.voiceGroups??[]}:{}),p=e.inject(Ua,null),S=e.computed(()=>(p==null?void 0:p.value[l.id])??null),E=e.computed(()=>K(l.data.kind)),b=e.computed(()=>"muted"in l.data&&l.data.muted===!0),h=e.computed(()=>E.value||l.data.kind==="voice"),f=e.computed(()=>`${l.isSoloed?"End solo of":"Solo"} ${m.value}`),_=e.computed(()=>`${m.value} pattern input`),g=e.computed(()=>`${m.value} pattern output`),T=e.computed(()=>`${b.value?"Unmute":"Mute"} ${m.value}`),O=e.computed(()=>Me(l.data,E.value?"":Ep)),V=F=>{o("update",F)},C=()=>{o("update",Object.assign({},l.data,{muted:!b.value}))},y=()=>{c.value=!c.value,r.value=!1},L=()=>{r.value=!1,o("showCode",l.id)},k=()=>{r.value=!1,o("remove",l.id)};return(F,$)=>(e.openBlock(),e.createElementBlock("article",{class:e.normalizeClass(["strudel-flow-node",{"strudel-flow-node--selected":t.selected,"strudel-flow-node--muted":b.value,"strudel-flow-node--playing":t.isPlaying}]),"data-node-kind":t.data.kind},[t.data.kind==="visualizer"&&t.data.placement==="background"?(e.openBlock(),e.createBlock(Aa,{key:0,placement:t.data.placement,"widget-id":S.value},null,8,["placement","widget-id"])):e.createCommentVNode("",!0),E.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(e.unref(j.Handle),{key:1,type:"target",position:e.unref(j.Position).Left,class:"strudel-flow-node__handle strudel-flow-node__handle--input","aria-label":_.value},null,8,["position","aria-label"])),e.createElementVNode("header",cp,[e.createElementVNode("h3",ip,e.toDisplayString(m.value),1),h.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"strudel-flow-node__action nodrag",title:f.value,"aria-label":f.value,"aria-pressed":t.isSoloed===!0,onPointerdown:$[0]||($[0]=e.withModifiers(()=>{},["stop"])),onClick:$[1]||($[1]=e.withModifiers(D=>o("solo",t.id),["stop"]))},[e.createVNode(e.unref(w.Headphones),{"aria-hidden":"true"})],40,dp)):e.createCommentVNode("",!0),E.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"strudel-flow-node__action nodrag",title:T.value,"aria-label":T.value,"aria-pressed":b.value,onPointerdown:$[2]||($[2]=e.withModifiers(()=>{},["stop"])),onClick:e.withModifiers(C,["stop"])},[b.value?(e.openBlock(),e.createBlock(e.unref(w.VolumeX),{key:0,"aria-hidden":"true"})):(e.openBlock(),e.createBlock(e.unref(w.Volume2),{key:1,"aria-hidden":"true"}))],40,mp)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"strudel-flow-node__action nodrag",title:`${m.value} options`,"aria-label":`${m.value} options`,"aria-expanded":r.value,onPointerdown:$[3]||($[3]=e.withModifiers(()=>{},["stop"])),onClick:$[4]||($[4]=e.withModifiers(D=>r.value=!r.value,["stop"])),onKeydown:$[5]||($[5]=e.withKeys(D=>r.value=!1,["escape"]))},[e.createVNode(e.unref(w.Ellipsis),{"aria-hidden":"true"})],40,up),r.value?(e.openBlock(),e.createElementBlock("div",_p,[e.createElementVNode("button",{type:"button",class:"strudel-flow-node__menu-item",role:"menuitem",onPointerdown:$[6]||($[6]=e.withModifiers(()=>{},["stop"])),onClick:e.withModifiers(y,["stop"])},[e.createVNode(e.unref(w.Code2),{"aria-hidden":"true"}),e.createTextVNode(" "+e.toDisplayString(c.value?"Hide code":"View code"),1)],32),e.createElementVNode("button",{type:"button",class:"strudel-flow-node__menu-item",role:"menuitem",onPointerdown:$[7]||($[7]=e.withModifiers(()=>{},["stop"])),onClick:e.withModifiers(L,["stop"])},[e.createVNode(e.unref(w.SquareCode),{"aria-hidden":"true"}),$[9]||($[9]=e.createTextVNode(" Go to code ",-1))],32),e.createElementVNode("button",{type:"button",class:"strudel-flow-node__menu-item strudel-flow-node__menu-item--danger",role:"menuitem",onPointerdown:$[8]||($[8]=e.withModifiers(()=>{},["stop"])),onClick:e.withModifiers(k,["stop"])},[e.createVNode(e.unref(w.Trash2),{"aria-hidden":"true"}),$[10]||($[10]=e.createTextVNode(" Remove ",-1))],32)])):e.createCommentVNode("",!0)]),c.value?(e.openBlock(),e.createElementBlock("pre",pp,e.toDisplayString(O.value),1)):e.createCommentVNode("",!0),e.createElementVNode("div",fp,[t.data.kind==="visualizer"&&t.data.placement==="inline"?(e.openBlock(),e.createBlock(Aa,{key:0,placement:t.data.placement,"widget-id":S.value},null,8,["placement","widget-id"])):e.createCommentVNode("",!0),t.data.kind==="effect"?(e.openBlock(),e.createBlock(Fm,{key:1,data:t.data,onUpdate:V},null,8,["data"])):(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a[t.data.kind]),e.mergeProps({key:2,data:t.data},u.value,{onUpdate:V}),null,16,["data"]))]),e.createVNode(e.unref(j.Handle),{type:"source",position:e.unref(j.Position).Right,class:"strudel-flow-node__handle strudel-flow-node__handle--output","aria-label":g.value},null,8,["position","aria-label"])],10,rp))}}),hp={class:"strudel-flow-radial",role:"dialog","aria-modal":"true","aria-label":"Add node"},Sp=["viewBox"],gp=["d","onMouseenter","onClick"],kp=["d","onMouseenter","onClick"],bp=["aria-label","aria-expanded","onClick","onFocus"],Tp=["aria-label","onClick","onFocus"],He=380,Lp=73,wp=145,Ia=150,Va=e.defineComponent({__name:"StrudelFlowRadialMenu",emits:["add"],setup(t,{expose:n,emit:l}){const o=l,a=He/2,s=[{label:"Instruments",category:"Instruments",icon:e.markRaw(w.Piano)},{label:"Effects",category:"Effects",icon:e.markRaw(w.SlidersHorizontal)},{label:"Sounds",category:"Sounds",icon:e.markRaw(w.AudioLines)}],r={pad:e.markRaw(w.Grid3x3),beats:e.markRaw(w.Drum),chords:e.markRaw(w.Music2),notes:e.markRaw(w.Music),samples:e.markRaw(w.Disc3),code:e.markRaw(w.Code),voice:e.markRaw(w.AudioLines),filter:e.markRaw(w.SlidersHorizontal),delay:e.markRaw(w.Clock),space:e.markRaw(w.Waves),gain:e.markRaw(w.Gauge),level:e.markRaw(w.Volume1),mask:e.markRaw(w.EyeOff),struct:e.markRaw(w.Rows3),slow:e.markRaw(w.Hourglass),voicing:e.markRaw(w.Piano),envelope:e.markRaw(w.Activity),visualizer:e.markRaw(w.AudioWaveform),effect:e.markRaw(w.Wand2)},c=e.ref(!1),i=e.ref(0),m=e.ref(null),u=e.computed(()=>s.map(k=>({...k,items:ot.filter(F=>F.category===k.category)}))),p=e.computed(()=>u.value[i.value]??null),S=e.computed(()=>90+180/u.value.length),E=e.computed(()=>u.value.map((k,F)=>h(Lp,S.value-(F+.5)*360/u.value.length))),b=e.computed(()=>{var F;const k=((F=p.value)==null?void 0:F.items)??[];return k.map(($,D)=>h(wp,k.length===1?90:Ia-(D+.5)*360/k.length))}),h=(k,F)=>{const $=F*Math.PI/180;return{x:a+k*Math.cos($),y:a-k*Math.sin($)}},f=(k,F)=>[`M ${a+k} ${a}`,`A ${k} ${k} 0 1 ${F} ${a-k} ${a}`,`A ${k} ${k} 0 1 ${F} ${a+k} ${a}`,"Z"].join(" "),_=(k,F,$,D,N=180)=>{const A=360/F;if(F===1)return`${f($,1)} ${f(D,0)}`;const U=N-k*A,R=U-A,P=h($,U),M=h($,R),te=h(D,U),Xa=h(D,R),za=A>180?1:0;return[`M ${P.x} ${P.y}`,`A ${$} ${$} 0 ${za} 1 ${M.x} ${M.y}`,`L ${Xa.x} ${Xa.y}`,`A ${D} ${D} 0 ${za} 0 ${te.x} ${te.y}`,"Z"].join(" ")},g=k=>_(k,u.value.length,110,36,S.value),T=k=>p.value===null?"":_(k,p.value.items.length,178,112,Ia),O=k=>({left:`${k.x/He*100}%`,top:`${k.y/He*100}%`}),V=()=>{i.value=0,c.value=!0},C=()=>{c.value=!1},y=k=>{o("add",k),C()},L=k=>{k.key==="Escape"&&c.value&&C()};return e.onMounted(()=>window.addEventListener("keydown",L)),e.onBeforeUnmount(()=>window.removeEventListener("keydown",L)),n({open:V}),(k,F)=>{var $,D;return c.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:"strudel-flow-radial__overlay",onClick:e.withModifiers(C,["self"])},[e.createElementVNode("div",hp,[(e.openBlock(),e.createElementBlock("svg",{class:"strudel-flow-radial__sectors",viewBox:`0 0 ${He} ${He}`,"aria-hidden":"true"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(u.value,(N,A)=>(e.openBlock(),e.createElementBlock("path",{key:`category-${A}`,d:g(A),class:e.normalizeClass(["strudel-flow-radial__sector",{"strudel-flow-radial__sector--active":i.value===A,"strudel-flow-radial__sector--hover":m.value===`category-${A}`}]),onMouseenter:U=>m.value=`category-${A}`,onMouseleave:F[0]||(F[0]=U=>m.value=null),onClick:U=>i.value=A},null,42,gp))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList((($=p.value)==null?void 0:$.items)??[],(N,A)=>(e.openBlock(),e.createElementBlock("path",{key:`item-${A}`,d:T(A),class:e.normalizeClass(["strudel-flow-radial__sector strudel-flow-radial__sector--item",{"strudel-flow-radial__sector--hover":m.value===`item-${A}`}]),onMouseenter:U=>m.value=`item-${A}`,onMouseleave:F[1]||(F[1]=U=>m.value=null),onClick:U=>y(N.kind)},null,42,kp))),128))],8,Sp)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(u.value,(N,A)=>(e.openBlock(),e.createElementBlock("button",{key:N.label,type:"button",class:e.normalizeClass(["strudel-flow-radial__category nodrag",{"strudel-flow-radial__category--active":i.value===A}]),style:e.normalizeStyle(O(E.value[A]??{x:a,y:a})),"aria-label":N.label,"aria-expanded":i.value===A,onClick:U=>i.value=A,onFocus:U=>m.value=`category-${A}`,onBlur:F[2]||(F[2]=U=>m.value=null)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(N.icon),{class:"strudel-flow-radial__icon","aria-hidden":"true"})),e.createElementVNode("span",null,e.toDisplayString(N.label),1)],46,bp))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(((D=p.value)==null?void 0:D.items)??[],(N,A)=>(e.openBlock(),e.createElementBlock("button",{key:N.kind,type:"button",class:"strudel-flow-radial__item nodrag",style:e.normalizeStyle(O(b.value[A]??{x:a,y:a})),"aria-label":`Add ${N.title} node`,onClick:U=>y(N.kind),onFocus:U=>m.value=`item-${A}`,onBlur:F[3]||(F[3]=U=>m.value=null)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r[N.kind]),{class:"strudel-flow-radial__icon","aria-hidden":"true"})),e.createElementVNode("span",null,e.toDisplayString(N.title),1)],44,Tp))),128)),e.createElementVNode("button",{type:"button",class:"strudel-flow-radial__close nodrag","aria-label":"Close menu",title:"Close menu",onClick:C},[e.createVNode(e.unref(w.X),{"aria-hidden":"true"})])])])):(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"strudel-flow-radial__trigger nodrag","aria-label":"Add node",title:"Add node",onClick:e.withModifiers(V,["stop"])},[e.createVNode(e.unref(w.Plus),{"aria-hidden":"true"})]))}}}),yp={class:"strudel-flow-toolbar nodrag",role:"group","aria-label":"Tempo"},Fp={class:"strudel-flow-toolbar__field"},Bp=["min","max","value"],$p={class:"strudel-flow-toolbar__field"},Rp={class:"strudel-flow-toolbar__cycle"},Op=["value"],Np=["value"],Cp=e.defineComponent({__name:"StrudelFlowToolbar",props:{beatsPerMinute:{},beatsPerCycle:{}},emits:["update:beatsPerMinute","update:beatsPerCycle"],setup(t,{emit:n}){const l=t,o=n,a=e.ref(String(l.beatsPerMinute));e.watch(()=>l.beatsPerMinute,i=>{a.value=String(i)});const s=()=>{const i=Number(a.value);if(a.value.trim().length===0||!Number.isFinite(i)){a.value=String(l.beatsPerMinute);return}const m=oe(i);a.value=String(m),m!==l.beatsPerMinute&&o("update:beatsPerMinute",m)},r=i=>{i.target instanceof HTMLInputElement&&(a.value=i.target.value)},c=i=>{i.target instanceof HTMLSelectElement&&o("update:beatsPerCycle",Number(i.target.value))};return(i,m)=>(e.openBlock(),e.createElementBlock("div",yp,[e.createElementVNode("label",Fp,[e.createElementVNode("input",{class:"strudel-flow-toolbar__tempo",type:"number",inputmode:"numeric",min:e.unref(Ge),max:e.unref(ye),value:a.value,"aria-label":"Beats per minute",onInput:r,onBlur:s,onKeydown:e.withKeys(s,["enter"])},null,40,Bp),m[0]||(m[0]=e.createElementVNode("span",{class:"strudel-flow-toolbar__unit"},"BPM",-1))]),e.createElementVNode("label",$p,[e.createElementVNode("span",Rp,[e.createElementVNode("select",{value:String(t.beatsPerCycle),"aria-label":"Beats per cycle",onChange:c},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(St),u=>(e.openBlock(),e.createElementBlock("option",{key:u.value,value:u.value},e.toDisplayString(u.label),9,Np))),128))],40,Op),e.createVNode(e.unref(w.ChevronDown),{"aria-hidden":"true"})]),m[1]||(m[1]=e.createElementVNode("span",{class:"strudel-flow-toolbar__unit"},"B/C",-1))])]))}}),Et=t=>K(t.data.kind),Wa=t=>"muted"in t.data&&t.data.muted===!0,Ap=(t,n)=>n.flatMap(l=>l.source===t?[l.target]:l.target===t?[l.source]:[]),Ha=(t,n,l=[])=>l.includes(t)?l:Ap(t,n).reduce((o,a)=>Ha(a,n,o),[...l,t]),Ga=(t,n,l)=>{const o=t.find(s=>s.id===l);if(o===void 0)return[];if(Et(o))return[l];const a=Ha(l,n);return t.filter(s=>Et(s)&&a.includes(s.id)).map(({id:s})=>s)},xa=(t,n,l)=>{const o=Ga(t,n,l),a=t.filter(Et);return o.length>0&&a.length>o.length&&a.every(s=>o.includes(s.id)!==Wa(s))},Dp=(t,n,l)=>{const o=Ga(t,n,l),a=xa(t,n,l);return t.filter(Et).map(s=>({node:s,muted:a?!1:!o.includes(s.id)})).filter(({node:s,muted:r})=>Wa(s)!==r).map(({node:s,muted:r})=>({nodeId:s.id,muted:r}))},Mp={class:"strudel-flow-credit"},Up=["href"],Pp=["href"],Ip=e.defineComponent({__name:"StrudelFlowEditor",props:{nodes:{},edges:{},beatsPerMinute:{},beatsPerCycle:{},sampleGroups:{},voiceGroups:{},noteReader:{type:Function},previewSound:{type:Function},playingNodeIds:{}},emits:["update:nodes","update:edges","connect","update-node","remove-node","show-code","add-node","update:beatsPerMinute","update:beatsPerCycle"],setup(t,{emit:n}){const l=t,o=n,a={type:"strudel"},s=e.ref(null);e.provide(da,s),e.provide(ma,y=>{var L;return(L=l.previewSound)==null?void 0:L.call(l,y)}),e.provide(Ua,e.computed(()=>po(l.nodes,l.edges))),e.provide($n,e.computed(()=>({readNoteBars:l.noteReader??null,beatsPerCycle:l.beatsPerCycle,soundOf:y=>Ko(y,l.nodes,l.edges)})));const r=e.ref(null),c=e.shallowRef(null),i=e.ref(!1),m=["Backspace","Delete"];e.watch(()=>l.nodes.length,(y,L)=>{y<=L||(i.value=!0,e.nextTick(()=>{var k;return(k=c.value)==null?void 0:k.fitView({padding:.2})}))});const u=y=>{c.value=y},p=()=>{var F;const y=((F=c.value)==null?void 0:F.getNodes.value)??[],L=Dr(y);L.some(($,D)=>{var N,A;return $.position.x!==((N=y[D])==null?void 0:N.position.x)||$.position.y!==((A=y[D])==null?void 0:A.position.y)})&&o("update:nodes",L)},S=e.computed(()=>{var y;return(((y=c.value)==null?void 0:y.getNodes.value)??[]).map(L=>`${L.dimensions.width}x${L.dimensions.height}`).join()});e.watch(S,()=>e.nextTick(p));const E=()=>{var y;p(),i.value&&(i.value=!1,(y=c.value)==null||y.fitView({padding:.2}))},b=y=>ho(y,l.nodes,l.edges),h=y=>{b(y)&&o("connect",y.source,y.target)},f=y=>{o("update:nodes",y)},_=y=>{o("update:edges",y)},g=(y,L)=>{o("update-node",y,L)},T=y=>{Dp(l.nodes,l.edges,y).forEach(L=>{const k=l.nodes.find(F=>F.id===L.nodeId);k!==void 0&&o("update-node",L.nodeId,{...k.data,muted:L.muted})})},O=y=>{o("remove-node",y)},V=y=>{o("add-node",y)},C=()=>{var y;(y=r.value)==null||y.open()};return(y,L)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"shell",ref:s,class:"strudel-flow-editor-shell",onContextmenu:e.withModifiers(C,["prevent"])},[e.createVNode(e.unref(j.VueFlow),{class:"strudel-flow-editor",nodes:t.nodes,edges:t.edges,"default-edge-options":a,"delete-key-code":m,"edges-updatable":!1,"fit-view-on-init":!0,"connect-on-click":!0,"is-valid-connection":b,"min-zoom":.2,"max-zoom":2,"onUpdate:nodes":f,"onUpdate:edges":_,onConnect:h,onPaneReady:u,onNodesInitialized:E},{"node-strudel":e.withCtx(k=>{var F;return[e.createVNode(Pa,{id:k.id,data:k.data,selected:k.selected,"sample-groups":t.sampleGroups??[],"voice-groups":t.voiceGroups??[],"is-soloed":e.unref(xa)(t.nodes,t.edges,k.id),"is-playing":((F=t.playingNodeIds)==null?void 0:F.includes(k.id))??!1,onUpdate:$=>g(k.id,$),onSolo:T,onRemove:O,onShowCode:L[0]||(L[0]=$=>o("show-code",$))},null,8,["id","data","selected","sample-groups","voice-groups","is-soloed","is-playing","onUpdate"])]}),"edge-strudel":e.withCtx(k=>[e.createVNode(ld,e.normalizeProps(e.guardReactiveProps(k)),null,16)]),default:e.withCtx(()=>[e.createVNode(e.unref(Ka.Controls))]),_:1},8,["nodes","edges"]),e.createVNode(Cp,{"beats-per-minute":t.beatsPerMinute,"beats-per-cycle":t.beatsPerCycle,"onUpdate:beatsPerMinute":L[1]||(L[1]=k=>o("update:beatsPerMinute",k)),"onUpdate:beatsPerCycle":L[2]||(L[2]=k=>o("update:beatsPerCycle",k))},null,8,["beats-per-minute","beats-per-cycle"]),e.createVNode(Va,{ref_key:"radialMenu",ref:r,onAdd:V},null,512),e.createElementVNode("p",Mp,[L[3]||(L[3]=e.createTextVNode(" After ",-1)),e.createElementVNode("a",{href:e.unref(Le).url,target:"_blank",rel:"noopener"},e.toDisplayString(e.unref(Le).name),9,Up),L[4]||(L[4]=e.createTextVNode(" by ",-1)),e.createElementVNode("a",{href:e.unref(Le).authorUrl,target:"_blank",rel:"noopener"},e.toDisplayString(e.unref(Le).author),9,Pp)])],544))}});d.MAJOR_SCALE=Gt,d.MINOR_SCALE=xt,d.STRUDEL_FLOW_BACKGROUND_CANVAS_ID=Vn,d.STRUDEL_FLOW_BEATS_PER_CYCLE_OPTIONS=St,d.STRUDEL_FLOW_BLACK_KEY_CLASSES=al,d.STRUDEL_FLOW_CALL_PARAMETERS=Wn,d.STRUDEL_FLOW_CHORDS_DEFAULTS=pe,d.STRUDEL_FLOW_CHORD_FRET_SPAN=xn,d.STRUDEL_FLOW_CHORD_PRESETS=Vl,d.STRUDEL_FLOW_CHORD_SCALE_OPTIONS=Ke,d.STRUDEL_FLOW_CODE_DEFAULTS=et,d.STRUDEL_FLOW_DEFAULT_BEATS_PER_CYCLE=J,d.STRUDEL_FLOW_DEFAULT_BEATS_PER_MINUTE=we,d.STRUDEL_FLOW_DEFAULT_BEATS_STEPS=kt,d.STRUDEL_FLOW_DEFAULT_OCTAVE=ul,d.STRUDEL_FLOW_DELAY_DEFAULTS=Ue,d.STRUDEL_FLOW_DRUM_ROWS=Pn,d.STRUDEL_FLOW_DRUM_SOUND_GROUPS=Tt,d.STRUDEL_FLOW_EDITOR_MODE_OPTIONS=Ya,d.STRUDEL_FLOW_EFFECT_DEFAULTS=Qt,d.STRUDEL_FLOW_ENVELOPE_DEFAULTS=fe,d.STRUDEL_FLOW_FILTER_DEFAULTS=tt,d.STRUDEL_FLOW_GAIN_DEFAULTS=vt,d.STRUDEL_FLOW_KEY_OPTIONS=ce,d.STRUDEL_FLOW_LEVEL_DEFAULTS=nt,d.STRUDEL_FLOW_MASK_DEFAULTS=en,d.STRUDEL_FLOW_MAX_BEATS_PER_MINUTE=ye,d.STRUDEL_FLOW_MAX_DRUM_ROWS=Re,d.STRUDEL_FLOW_MAX_FILTER_CUTOFF=Cn,d.STRUDEL_FLOW_MAX_FILTER_RESONANCE=Dn,d.STRUDEL_FLOW_MAX_FRET=Gn,d.STRUDEL_FLOW_MAX_LENGTH_DENOMINATOR=pl,d.STRUDEL_FLOW_MAX_NODE_COORDINATE=Fe,d.STRUDEL_FLOW_MAX_ROOM_SIZE=Mn,d.STRUDEL_FLOW_MIN_BEATS_PER_MINUTE=Ge,d.STRUDEL_FLOW_MIN_FILTER_CUTOFF=Nn,d.STRUDEL_FLOW_MIN_FILTER_RESONANCE=An,d.STRUDEL_FLOW_NEW_DRUM_SOUNDS=bt,d.STRUDEL_FLOW_NODE_COLUMNS=On,d.STRUDEL_FLOW_NODE_COLUMN_GAP=Rn,d.STRUDEL_FLOW_NODE_DEFINITIONS=ot,d.STRUDEL_FLOW_NODE_ROW_GAP=ja,d.STRUDEL_FLOW_NODE_START_X=re,d.STRUDEL_FLOW_NODE_START_Y=ze,d.STRUDEL_FLOW_NOTATION_BY_SOUND=Xn,d.STRUDEL_FLOW_NOTATION_OPTIONS=Oe,d.STRUDEL_FLOW_NOTES_DEFAULTS=ve,d.STRUDEL_FLOW_NOTE_LETTERS=Pt,d.STRUDEL_FLOW_OPEN_STRINGS=Hn,d.STRUDEL_FLOW_OTHER_SAMPLE_FAMILY=wn,d.STRUDEL_FLOW_PAD_DEFAULTS=ne,d.STRUDEL_FLOW_PAD_MODIFIER_OPTIONS=$e,d.STRUDEL_FLOW_PAD_NOTE_COUNT=Xe,d.STRUDEL_FLOW_PAD_STEP_COUNT=xe,d.STRUDEL_FLOW_PATCH_STORAGE_KEY=ht,d.STRUDEL_FLOW_PIANO_ROLL_BEAT_WIDTH=Rt,d.STRUDEL_FLOW_PIANO_ROLL_GUTTER=ll,d.STRUDEL_FLOW_PIANO_ROLL_MIN_ROWS=ol,d.STRUDEL_FLOW_PIANO_ROLL_ROW_HEIGHT=de,d.STRUDEL_FLOW_PITCH_CLASSES=ml,d.STRUDEL_FLOW_REFERENCE=Le,d.STRUDEL_FLOW_SAMPLES_DEFAULTS=Zt,d.STRUDEL_FLOW_SAMPLE_FAMILIES=Ht,d.STRUDEL_FLOW_SAMPLE_MODIFIER_KINDS=Ul,d.STRUDEL_FLOW_SAMPLE_MODIFIER_OPTIONS=Wt,d.STRUDEL_FLOW_SCALE_OPTIONS=ie,d.STRUDEL_FLOW_SHARP_SIGNS=_l,d.STRUDEL_FLOW_SHARP_SPELLINGS=fl,d.STRUDEL_FLOW_SHEET_ACCIDENTAL_GLYPHS=gl,d.STRUDEL_FLOW_SHEET_ACCIDENTAL_OFFSET=Nl,d.STRUDEL_FLOW_SHEET_ACCIDENTAL_SPACE=Fl,d.STRUDEL_FLOW_SHEET_BOTTOM_MARGIN=Tl,d.STRUDEL_FLOW_SHEET_BOTTOM_STEPS=El,d.STRUDEL_FLOW_SHEET_BRACKET_RISE=Dl,d.STRUDEL_FLOW_SHEET_CLEF_GLYPHS=Sl,d.STRUDEL_FLOW_SHEET_CLEF_SPACE=wl,d.STRUDEL_FLOW_SHEET_COLUMN_SPACE=qe,d.STRUDEL_FLOW_SHEET_DOT_FACTOR=hl,d.STRUDEL_FLOW_SHEET_DOT_OFFSET=Cl,d.STRUDEL_FLOW_SHEET_FLAG_STEP=Ol,d.STRUDEL_FLOW_SHEET_HEAD_RADIUS_X=It,d.STRUDEL_FLOW_SHEET_HEAD_RADIUS_Y=$l,d.STRUDEL_FLOW_SHEET_LEDGER_HALF_WIDTH=Vt,d.STRUDEL_FLOW_SHEET_LINE_GAP=kl,d.STRUDEL_FLOW_SHEET_MIN_BAR_WIDTH=Bl,d.STRUDEL_FLOW_SHEET_SPACE_PER_BEAT=yl,d.STRUDEL_FLOW_SHEET_STAFF_DISTANCE=Ll,d.STRUDEL_FLOW_SHEET_STEM_LENGTH=Rl,d.STRUDEL_FLOW_SHEET_STROKE_WIDTH=Ml,d.STRUDEL_FLOW_SHEET_TIE_OFFSET=Ze,d.STRUDEL_FLOW_SHEET_TIE_SAG=Al,d.STRUDEL_FLOW_SHEET_TOP_MARGIN=bl,d.STRUDEL_FLOW_SHEET_TREBLE_LOWEST_NOTE=Ye,d.STRUDEL_FLOW_SHEET_VALUES=me,d.STRUDEL_FLOW_SLOW_DEFAULTS=nn,d.STRUDEL_FLOW_SOUND_OPTIONS=gt,d.STRUDEL_FLOW_SPACE_DEFAULTS=le,d.STRUDEL_FLOW_STEP_COUNT=X,d.STRUDEL_FLOW_STRUCT_DEFAULTS=tn,d.STRUDEL_FLOW_TAB_BEAM_BEATS=Ne,d.STRUDEL_FLOW_TAB_BEAM_STEP=qn,d.STRUDEL_FLOW_TAB_BEAM_THICKNESS=wt,d.STRUDEL_FLOW_TAB_BOTTOM_MARGIN=qa,d.STRUDEL_FLOW_TAB_BOTTOM_SPACE=dl,d.STRUDEL_FLOW_TAB_BRACKET_HOOK=Dt,d.STRUDEL_FLOW_TAB_BRACKET_LABEL_BASELINE=Ut,d.STRUDEL_FLOW_TAB_BRACKET_LABEL_GAP=At,d.STRUDEL_FLOW_TAB_BRACKET_LABEL_SIZE=Mt,d.STRUDEL_FLOW_TAB_BRACKET_OVERHANG=Ce,d.STRUDEL_FLOW_TAB_BRACKET_Y=Jn,d.STRUDEL_FLOW_TAB_DIGIT_BASELINE=il,d.STRUDEL_FLOW_TAB_DIGIT_CLEARANCE=Qn,d.STRUDEL_FLOW_TAB_DIGIT_PITCH=Ft,d.STRUDEL_FLOW_TAB_DIGIT_SIZE=cl,d.STRUDEL_FLOW_TAB_DIGIT_WIDTH=yt,d.STRUDEL_FLOW_TAB_FLAG_LENGTH=Zn,d.STRUDEL_FLOW_TAB_LINE_GAP=zn,d.STRUDEL_FLOW_TAB_MIN_BAR_WIDTH=Ot,d.STRUDEL_FLOW_TAB_REST_HEIGHT=Ct,d.STRUDEL_FLOW_TAB_REST_WIDTH=Nt,d.STRUDEL_FLOW_TAB_SIDE_MARGIN=Lt,d.STRUDEL_FLOW_TAB_SPACE_PER_BEAT=nl,d.STRUDEL_FLOW_TAB_STEM_BOTTOM=Yn,d.STRUDEL_FLOW_TAB_STEM_SPACE=je,d.STRUDEL_FLOW_TAB_STEM_TOP=jn,d.STRUDEL_FLOW_TAB_STEM_WIDTH=rl,d.STRUDEL_FLOW_TAB_STROKE_WIDTH=sl,d.STRUDEL_FLOW_TAB_TIE_END_GAP=tl,d.STRUDEL_FLOW_TAB_TIE_SAG=el,d.STRUDEL_FLOW_TAB_TIE_TOP=vn,d.STRUDEL_FLOW_TAB_TOP_MARGIN=Kn,d.STRUDEL_FLOW_TAB_TRIPLET_DENOMINATOR=$t,d.STRUDEL_FLOW_TAB_TRIPLET_NUMERATOR=Bt,d.STRUDEL_FLOW_VISUALIZER_DEFAULTS=ln,d.STRUDEL_FLOW_VISUAL_OPTIONS=Be,d.STRUDEL_FLOW_VISUAL_PLACEMENT_OPTIONS=Un,d.STRUDEL_FLOW_VOICE_DEFAULTS=Jt,d.STRUDEL_FLOW_VOICING_DEFAULTS=vl,d.STRUDEL_FLOW_WIDGET_ID_PREFIX=In,d.StrudelFlowAccordion=_t,d.StrudelFlowBeatsControls=pa,d.StrudelFlowChordEditor=ha,d.StrudelFlowChordsControls=Sa,d.StrudelFlowCodeControls=ga,d.StrudelFlowDelayControls=ka,d.StrudelFlowEditor=Ip,d.StrudelFlowEnvelopeControls=Ta,d.StrudelFlowFilterControls=La,d.StrudelFlowKnob=G,d.StrudelFlowLevelControls=wa,d.StrudelFlowNode=Pa,d.StrudelFlowNotation=Na,d.StrudelFlowNoteNames=Fa,d.StrudelFlowPadControls=ya,d.StrudelFlowPianoRoll=Ba,d.StrudelFlowRadialMenu=Va,d.StrudelFlowSelect=Z,d.StrudelFlowSheet=$a,d.StrudelFlowSpaceControls=Da,d.StrudelFlowStepper=se,d.StrudelFlowTabStaff=Oa,d.StrudelFlowVisualizerControls=Ca,d.StrudelFlowVoiceControls=Ma,d.appendStrudelFlowBlocks=jc,d.canConnectStrudelFlowNodes=at,d.canUseStrudelFlowConnection=ho,d.compileStrudelFlow=_o,d.copyStrudelFlowChord=ts,d.createDefaultDrumRows=on,d.createDefaultPadGrid=Qe,d.createDefaultStrudelFlowPatch=sn,d.createStrudelFlowDrumRow=Ee,d.createStrudelFlowNodeData=he,d.findStrudelFlowNodeCode=ed,d.findStrudelFlowNotesSound=Ko,d.findStrudelFlowPlayingNodeIds=nd,d.findStrudelFlowSampleFamily=yn,d.formatStrudelFlowBeats=Wo,d.formatStrudelFlowKnobValue=ql,d.formatStrudelFlowNumber=H,d.generateStrudelFlowNodePattern=Me,d.getStrudelFlowChordLabels=Wl,d.getStrudelFlowChordNotes=Je,d.getStrudelFlowChordProgression=Xt,d.getStrudelFlowCodeOrder=fo,d.getStrudelFlowNodeCodeRanges=ca,d.getStrudelFlowNodeDefinition=lo,d.getStrudelFlowVisualizerWidgetIds=po,d.isStoredRecord=Y,d.isStrudelFlowEffectKind=vs,d.isStrudelFlowInstrumentKind=K,d.isStrudelFlowNodeKind=to,d.layoutStrudelFlowSheet=oa,d.layoutStrudelFlowTab=Qo,d.normalizeStrudelFlowBeatsPerCycle=Pe,d.normalizeStrudelFlowBeatsPerMinute=oe,d.parseStrudelFlowCode=Io,d.parseStrudelFlowPatch=So,d.parseStrudelFlowSampleLayers=Tn,d.pickStrudelFlowNotation=Sn,d.placeStrudelFlowFrets=xo,d.readStorage=Pl,d.readStoredChoice=ue,d.readStoredNumber=W,d.readStoredString=x,d.readStrudelFlowCallFields=Yt,d.readStrudelFlowMidiNote=hn,d.readStrudelFlowNodeData=no,d.readStrudelFlowSpelledNote=dt,d.resolveStrudelFlowNotation=Xo,d.useStrudelFlow=Zc,d.writeStorage=Il,d.writeStrudelFlowCallFields=qt,d.writeStrudelFlowSampleLayers=Ln,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
package/dist/layout.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { StrudelFlowNode, StrudelFlowNodeKind, StrudelFlowNodePosition, StrudelFlowNodeSize as NodeSize } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* The size a node of this kind is laid out with before the canvas has measured it.
|
|
4
|
+
* @param kind - the node kind
|
|
5
|
+
* @returns its expected width and height
|
|
6
|
+
*/
|
|
7
|
+
export declare const getStrudelFlowNodeSize: (kind: StrudelFlowNodeKind) => NodeSize;
|
|
8
|
+
/**
|
|
9
|
+
* Whether two nodes would be drawn on top of each other or closer than the canvas gap.
|
|
10
|
+
* @param left - one node, at its position and measured or expected size
|
|
11
|
+
* @param right - the other node
|
|
12
|
+
* @returns true when their boxes, padded by the gap, intersect
|
|
13
|
+
*/
|
|
14
|
+
export declare const doStrudelFlowNodesOverlap: (left: StrudelFlowNode, right: StrudelFlowNode) => boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Finds the first free slot for a new node on the two-column canvas. Existing nodes keep
|
|
17
|
+
* their positions, so adding a node near a tall pad or accordion never hides it underneath.
|
|
18
|
+
* @param nodes - nodes already on the canvas
|
|
19
|
+
* @param kind - the node that is about to be added
|
|
20
|
+
* @returns a position that does not overlap any existing node
|
|
21
|
+
*/
|
|
22
|
+
export declare const findStrudelFlowNodePosition: (nodes: StrudelFlowNode[], kind: StrudelFlowNodeKind) => StrudelFlowNodePosition;
|
|
23
|
+
/**
|
|
24
|
+
* Moves overlapping nodes apart using the sizes the canvas measured. The layout only knows a
|
|
25
|
+
* node's expected size, and one with an open accordion or a long pattern renders larger, so
|
|
26
|
+
* the node next to it would otherwise be drawn underneath.
|
|
27
|
+
* @param nodes - nodes with their measured dimensions
|
|
28
|
+
* @returns the nodes, each moved clear of whatever it overlapped, in the same order
|
|
29
|
+
*/
|
|
30
|
+
export declare const separateStrudelFlowNodes: (nodes: StrudelFlowNode[]) => StrudelFlowNode[];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { StrudelFlowCodeRange, StrudelFlowEdge, StrudelFlowNode, StrudelFlowNodeCodeRange } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Finds the code every node writes in the program: for each node, the calls of its kind that
|
|
4
|
+
* follow the nodes of the same kind before it in code order, one per sounding Beats row.
|
|
5
|
+
* ponytail: matched by call name and position, not by parsing; a helper in the setup that makes
|
|
6
|
+
* the same call shifts the count. Track source offsets in the parser if that ever matters.
|
|
7
|
+
* @param code - the program in the code editor
|
|
8
|
+
* @param nodes - the patch's nodes
|
|
9
|
+
* @param edges - the patch's cables
|
|
10
|
+
* @returns the ranges of every node's calls, in code order of the nodes
|
|
11
|
+
*/
|
|
12
|
+
export declare const getStrudelFlowNodeCodeRanges: (code: string, nodes: StrudelFlowNode[], edges: StrudelFlowEdge[]) => StrudelFlowNodeCodeRange[];
|
|
13
|
+
/**
|
|
14
|
+
* Finds the code a node writes in the program.
|
|
15
|
+
* @param code - the program in the code editor
|
|
16
|
+
* @param nodes - the patch's nodes
|
|
17
|
+
* @param edges - the patch's cables
|
|
18
|
+
* @param nodeId - the node to find
|
|
19
|
+
* @returns the range of the node's first call, or null when the code has no such call
|
|
20
|
+
*/
|
|
21
|
+
export declare const findStrudelFlowNodeCode: (code: string, nodes: StrudelFlowNode[], edges: StrudelFlowEdge[], nodeId: string) => StrudelFlowCodeRange | null;
|
|
22
|
+
/**
|
|
23
|
+
* Finds the instruments a sounding note came from. A note carries a location for each piece of
|
|
24
|
+
* mini-notation it was built from, in no reliable order, and a note held in a setup variable has
|
|
25
|
+
* none in any node. Each offset is mapped to its node (the narrowest range wins); the leftmost
|
|
26
|
+
* instrument among them owns the note, else the instruments upstream of the owners do, when
|
|
27
|
+
* there is exactly one.
|
|
28
|
+
* ponytail: a note whose mini-notation lives in a setup variable and passes through a shared
|
|
29
|
+
* effect lights nothing; give the parser source offsets for setup variables to light it.
|
|
30
|
+
* @param ranges - every node's code ranges
|
|
31
|
+
* @param offsetsPerHap - for each sounding note, the character offsets of its locations
|
|
32
|
+
* @param nodes - the patch's nodes
|
|
33
|
+
* @param edges - the patch's cables
|
|
34
|
+
* @returns the id of the instrument each note came from, once each
|
|
35
|
+
*/
|
|
36
|
+
export declare const findStrudelFlowPlayingNodeIds: (ranges: StrudelFlowNodeCodeRange[], offsetsPerHap: number[][], nodes: StrudelFlowNode[], edges: StrudelFlowEdge[]) => string[];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { StrudelFlowChordsData, StrudelFlowCodeData, StrudelFlowDelayData, StrudelFlowDrumRow, StrudelFlowEffectData, StrudelFlowEnvelopeData, StrudelFlowFilterData, StrudelFlowGainData, StrudelFlowLevelData, StrudelFlowMaskData, StrudelFlowSlowData, StrudelFlowStructData, StrudelFlowVoicingData, StrudelFlowNodeData, StrudelFlowNodeKind, StrudelFlowNotesData, StrudelFlowPadData, StrudelFlowSamplesData, StrudelFlowSpaceData, StrudelFlowVisualizerData, StrudelFlowVoiceData } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* A fresh pad grid, wide enough for the full sixteen steps.
|
|
4
|
+
* @returns sixteen rows of eight cells with the starter arpeggio on
|
|
5
|
+
*/
|
|
6
|
+
export declare const createDefaultPadGrid: () => boolean[][];
|
|
7
|
+
export declare const STRUDEL_FLOW_PAD_DEFAULTS: StrudelFlowPadData;
|
|
8
|
+
export declare const STRUDEL_FLOW_CHORDS_DEFAULTS: StrudelFlowChordsData;
|
|
9
|
+
export declare const STRUDEL_FLOW_NOTES_DEFAULTS: StrudelFlowNotesData;
|
|
10
|
+
export declare const STRUDEL_FLOW_SAMPLES_DEFAULTS: StrudelFlowSamplesData;
|
|
11
|
+
export declare const STRUDEL_FLOW_CODE_DEFAULTS: StrudelFlowCodeData;
|
|
12
|
+
export declare const STRUDEL_FLOW_VOICE_DEFAULTS: StrudelFlowVoiceData;
|
|
13
|
+
export declare const STRUDEL_FLOW_EFFECT_DEFAULTS: StrudelFlowEffectData;
|
|
14
|
+
export declare const STRUDEL_FLOW_FILTER_DEFAULTS: StrudelFlowFilterData;
|
|
15
|
+
export declare const STRUDEL_FLOW_DELAY_DEFAULTS: StrudelFlowDelayData;
|
|
16
|
+
export declare const STRUDEL_FLOW_SPACE_DEFAULTS: StrudelFlowSpaceData;
|
|
17
|
+
export declare const STRUDEL_FLOW_GAIN_DEFAULTS: StrudelFlowGainData;
|
|
18
|
+
export declare const STRUDEL_FLOW_LEVEL_DEFAULTS: StrudelFlowLevelData;
|
|
19
|
+
export declare const STRUDEL_FLOW_MASK_DEFAULTS: StrudelFlowMaskData;
|
|
20
|
+
export declare const STRUDEL_FLOW_STRUCT_DEFAULTS: StrudelFlowStructData;
|
|
21
|
+
export declare const STRUDEL_FLOW_SLOW_DEFAULTS: StrudelFlowSlowData;
|
|
22
|
+
export declare const STRUDEL_FLOW_VOICING_DEFAULTS: StrudelFlowVoicingData;
|
|
23
|
+
export declare const STRUDEL_FLOW_ENVELOPE_DEFAULTS: StrudelFlowEnvelopeData;
|
|
24
|
+
export declare const STRUDEL_FLOW_VISUALIZER_DEFAULTS: StrudelFlowVisualizerData;
|
|
25
|
+
/**
|
|
26
|
+
* A silent Beats track for one sample.
|
|
27
|
+
* @param sound - the sample name, such as "cp"
|
|
28
|
+
* @param hits - the steps that play, none by default
|
|
29
|
+
* @returns a track with all sixteen steps and no variations
|
|
30
|
+
*/
|
|
31
|
+
export declare const createStrudelFlowDrumRow: (sound: string, hits?: number[]) => StrudelFlowDrumRow;
|
|
32
|
+
/**
|
|
33
|
+
* Copies the starter drum grid so two Beats nodes never share the same step arrays.
|
|
34
|
+
* @returns a fresh set of drum rows with all sixteen steps
|
|
35
|
+
*/
|
|
36
|
+
export declare const createDefaultDrumRows: () => StrudelFlowDrumRow[];
|
|
37
|
+
/**
|
|
38
|
+
* The settings a node of this kind starts with.
|
|
39
|
+
* @param kind - the node kind
|
|
40
|
+
* @returns fresh node data, including arrays that are safe to edit in place
|
|
41
|
+
*/
|
|
42
|
+
export declare const createStrudelFlowNodeData: (kind: StrudelFlowNodeKind) => StrudelFlowNodeData;
|
|
43
|
+
/**
|
|
44
|
+
* Whether a node kind starts a pattern rather than transforming one.
|
|
45
|
+
* @param kind - the node kind
|
|
46
|
+
* @returns true for an instrument
|
|
47
|
+
*/
|
|
48
|
+
export declare const isStrudelFlowInstrumentKind: (kind: StrudelFlowNodeKind) => boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Whether a node kind transforms an incoming pattern. Sounds count: a voice reshapes the notes
|
|
51
|
+
* it is given rather than starting a pattern.
|
|
52
|
+
* @param kind - the node kind
|
|
53
|
+
* @returns true for an effect or a sound
|
|
54
|
+
*/
|
|
55
|
+
export declare const isStrudelFlowEffectKind: (kind: StrudelFlowNodeKind) => boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { StrudelFlowNodeDefinition, StrudelFlowNodeKind } from './types';
|
|
2
|
+
/** Every node the flow palette offers, in the order it lists them. */
|
|
3
|
+
export declare const STRUDEL_FLOW_NODE_DEFINITIONS: StrudelFlowNodeDefinition[];
|
|
4
|
+
/**
|
|
5
|
+
* The definition the palette and a node's header read their title from.
|
|
6
|
+
* @param kind - the node kind
|
|
7
|
+
* @returns the matching definition
|
|
8
|
+
*/
|
|
9
|
+
export declare const getStrudelFlowNodeDefinition: (kind: StrudelFlowNodeKind) => StrudelFlowNodeDefinition;
|