diff --git a/musicxml-singer-with-oddvoices/dist/assets/index-B5YbPQmc.js b/musicxml-singer-with-oddvoices/dist/assets/index-CCqCXGcx.js similarity index 99% rename from musicxml-singer-with-oddvoices/dist/assets/index-B5YbPQmc.js rename to musicxml-singer-with-oddvoices/dist/assets/index-CCqCXGcx.js index 59e0308..763fe75 100644 --- a/musicxml-singer-with-oddvoices/dist/assets/index-B5YbPQmc.js +++ b/musicxml-singer-with-oddvoices/dist/assets/index-CCqCXGcx.js @@ -264,7 +264,7 @@ void main() { `);const t=new Ch("!xml");let n=t,s="",m="";for(let b=0;b",b,"Closing Tag is not closed.");let u=e.substring(b+2,r).trim();if(this.options.removeNSPrefix){const c=u.indexOf(":");c!==-1&&(u=u.substr(c+1))}this.options.transformTagName&&(u=this.options.transformTagName(u)),n&&(s=this.saveTextToParentTag(s,n,m));const a=m.substring(m.lastIndexOf(".")+1);if(u&&this.options.unpairedTags.indexOf(u)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: `);let g=0;a&&this.options.unpairedTags.indexOf(a)!==-1?(g=m.lastIndexOf(".",m.lastIndexOf(".")-1),this.tagsNodeStack.pop()):g=m.lastIndexOf("."),m=m.substring(0,g),n=this.tagsNodeStack.pop(),s="",b=r}else if(e[b+1]==="?"){let r=nb(e,b,!1,"?>");if(!r)throw new Error("Pi Tag is not closed.");if(s=this.saveTextToParentTag(s,n,m),!(this.options.ignoreDeclaration&&r.tagName==="?xml"||this.options.ignorePiTags)){const u=new Ch(r.tagName);u.add(this.options.textNodeName,""),r.tagName!==r.tagExp&&r.attrExpPresent&&(u[":@"]=this.buildAttributesMap(r.tagExp,m,r.tagName)),this.addChild(n,u,m)}b=r.closeIndex+1}else if(e.substr(b+1,3)==="!--"){const r=wl(e,"-->",b+4,"Comment is not closed.");if(this.options.commentPropName){const u=e.substring(b+4,r-2);s=this.saveTextToParentTag(s,n,m),n.add(this.options.commentPropName,[{[this.options.textNodeName]:u}])}b=r}else if(e.substr(b+1,2)==="!D"){const r=yz(e,b);this.docTypeEntities=r.entities,b=r.i}else if(e.substr(b+1,2)==="!["){const r=wl(e,"]]>",b,"CDATA is not closed.")-2,u=e.substring(b+9,r);if(s=this.saveTextToParentTag(s,n,m),this.options.cdataPropName)n.add(this.options.cdataPropName,[{[this.options.textNodeName]:u}]);else{let a=this.parseTextData(u,n.tagname,m,!0,!1,!0);a==null&&(a=""),n.add(this.options.textNodeName,a)}b=r+2}else{let r=nb(e,b,this.options.removeNSPrefix),u=r.tagName;const a=r.rawTagName;let g=r.tagExp,c=r.attrExpPresent,l=r.closeIndex;this.options.transformTagName&&(u=this.options.transformTagName(u)),n&&s&&n.tagname!=="!xml"&&(s=this.saveTextToParentTag(s,n,m,!1));const h=n;if(h&&this.options.unpairedTags.indexOf(h.tagname)!==-1&&(n=this.tagsNodeStack.pop(),m=m.substring(0,m.lastIndexOf("."))),u!==t.tagname&&(m+=m?"."+u:u),this.isItStopNode(this.options.stopNodes,m,u)){let d="";if(g.length>0&&g.lastIndexOf("/")===g.length-1)b=r.closeIndex;else if(this.options.unpairedTags.indexOf(u)!==-1)b=r.closeIndex;else{const f=this.readStopNodeData(e,a,l+1);if(!f)throw new Error(`Unexpected end of ${a}`);b=f.i,d=f.tagContent}const S=new Ch(u);u!==g&&c&&(S[":@"]=this.buildAttributesMap(g,m,u)),d&&(d=this.parseTextData(d,u,m,!0,c,!0,!0)),m=m.substr(0,m.lastIndexOf(".")),S.add(this.options.textNodeName,d),this.addChild(n,S,m)}else{if(g.length>0&&g.lastIndexOf("/")===g.length-1){u[u.length-1]==="/"?(u=u.substr(0,u.length-1),m=m.substr(0,m.length-1),g=u):g=g.substr(0,g.length-1),this.options.transformTagName&&(u=this.options.transformTagName(u));const d=new Ch(u);u!==g&&c&&(d[":@"]=this.buildAttributesMap(g,m,u)),this.addChild(n,d,m),m=m.substr(0,m.lastIndexOf("."))}else{const d=new Ch(u);this.tagsNodeStack.push(n),u!==g&&c&&(d[":@"]=this.buildAttributesMap(g,m,u)),this.addChild(n,d,m),n=d}s="",b=l}}else s+=e[b];return t.child};function Mz(e,t,n){const s=this.options.updateTag(t.tagname,n,t[":@"]);s===!1||(typeof s=="string"&&(t.tagname=s),e.addChild(t))}const Cz=function(e){if(this.options.processEntities){for(let t in this.docTypeEntities){const n=this.docTypeEntities[t];e=e.replace(n.regx,n.val)}for(let t in this.lastEntities){const n=this.lastEntities[t];e=e.replace(n.regex,n.val)}if(this.options.htmlEntities)for(let t in this.htmlEntities){const n=this.htmlEntities[t];e=e.replace(n.regex,n.val)}e=e.replace(this.ampEntity.regex,this.ampEntity.val)}return e};function Lz(e,t,n,s){return e&&(s===void 0&&(s=Object.keys(t.child).length===0),e=this.parseTextData(e,t.tagname,n,!1,t[":@"]?Object.keys(t[":@"]).length!==0:!1,s),e!==void 0&&e!==""&&t.add(this.options.textNodeName,e),e=""),e}function Az(e,t,n){const s="*."+n;for(const m in e){const b=e[m];if(s===b||t===b)return!0}return!1}function Rz(e,t,n=">"){let s,m="";for(let b=t;b",n,`${t} is not closed`);if(e.substring(n+2,b).trim()===t&&(m--,m===0))return{tagContent:e.substring(s,n),i:b};n=b}else if(e[n+1]==="?")n=wl(e,"?>",n+1,"StopNode is not closed.");else if(e.substr(n+1,3)==="!--")n=wl(e,"-->",n+3,"StopNode is not closed.");else if(e.substr(n+1,2)==="![")n=wl(e,"]]>",n,"StopNode is not closed.")-2;else{const b=nb(e,n,">");b&&((b&&b.tagName)===t&&b.tagExp[b.tagExp.length-1]!=="/"&&m++,n=b.closeIndex)}}function ib(e,t,n){if(t&&typeof e=="string"){const s=e.trim();return s==="true"?!0:s==="false"?!1:vz(e,n)}else return R7.isExist(e)?e:""}var Nz=Sz,I7={};function kz(e,t){return N7(e,t)}function N7(e,t,n){let s;const m={};for(let b=0;b0&&(m[t.textNodeName]=s):s!==void 0&&(m[t.textNodeName]=s),m}function Oz(e){const t=Object.keys(e);for(let n=0;n0&&(n=Uz),k7(e,t,"",n)}function k7(e,t,n,s){let m="",b=!1;for(let o=0;o`,b=!1;continue}else if(u===t.commentPropName){m+=s+``,b=!0;continue}else if(u[0]==="?"){const d=S5(r[":@"],t),S=u==="?xml"?"":s;let f=r[u][0][t.textNodeName];f=f.length!==0?" "+f:"",m+=S+`<${u}${f}${d}?>`,b=!0;continue}let g=s;g!==""&&(g+=t.indentBy);const c=S5(r[":@"],t),l=s+`<${u}${c}`,h=k7(r[u],t,a,g);t.unpairedTags.indexOf(u)!==-1?t.suppressUnpairedNode?m+=l+">":m+=l+"/>":(!h||h.length===0)&&t.suppressEmptyNode?m+=l+"/>":h&&h.endsWith(">")?m+=l+`>${h}${s}`:(m+=l+">",h&&s!==""&&(h.includes("/>")||h.includes("`),b=!0}return m}function Hz(e){const t=Object.keys(e);for(let n=0;n0&&t.processEntities)for(let n=0;n","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("'","g"),val:"'"},{regex:new RegExp('"',"g"),val:"""}],processEntities:!0,stopNodes:[],oneListGroup:!1};function tl(e){this.options=Object.assign({},qz,e),this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=Zz),this.processTextOrObjNode=Qz,this.options.format?(this.indentate=Jz,this.tagEndChar=`> `,this.newLine=` -`):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}tl.prototype.build=function(e){return this.options.preserveOrder?Kz(e,this.options):(Array.isArray(e)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(e={[this.options.arrayNodeName]:e}),this.j2x(e,0).val)};tl.prototype.j2x=function(e,t){let n="",s="";for(let m in e)if(Object.prototype.hasOwnProperty.call(e,m))if(typeof e[m]>"u")this.isAttribute(m)&&(s+="");else if(e[m]===null)this.isAttribute(m)?s+="":m[0]==="?"?s+=this.indentate(t)+"<"+m+"?"+this.tagEndChar:s+=this.indentate(t)+"<"+m+"/"+this.tagEndChar;else if(e[m]instanceof Date)s+=this.buildTextValNode(e[m],m,"",t);else if(typeof e[m]!="object"){const b=this.isAttribute(m);if(b)n+=this.buildAttrPairStr(b,""+e[m]);else if(m===this.options.textNodeName){let o=this.options.tagValueProcessor(m,""+e[m]);s+=this.replaceEntitiesValue(o)}else s+=this.buildTextValNode(e[m],m,"",t)}else if(Array.isArray(e[m])){const b=e[m].length;let o="";for(let r=0;r"u"||(u===null?m[0]==="?"?s+=this.indentate(t)+"<"+m+"?"+this.tagEndChar:s+=this.indentate(t)+"<"+m+"/"+this.tagEndChar:typeof u=="object"?this.options.oneListGroup?o+=this.j2x(u,t+1).val:o+=this.processTextOrObjNode(u,m,t):o+=this.buildTextValNode(u,m,"",t))}this.options.oneListGroup&&(o=this.buildObjectNode(o,m,"",t)),s+=o}else if(this.options.attributesGroupName&&m===this.options.attributesGroupName){const b=Object.keys(e[m]),o=b.length;for(let r=0;r"+e+m:this.options.commentPropName!==!1&&t===this.options.commentPropName&&b.length===0?this.indentate(s)+``+this.newLine:this.indentate(s)+"<"+t+n+b+this.tagEndChar+e+this.indentate(s)+m}};tl.prototype.closeTag=function(e){let t="";return this.options.unpairedTags.indexOf(e)!==-1?this.options.suppressUnpairedNode||(t="/"):this.options.suppressEmptyNode?t="/":t=`>`+this.newLine;if(this.options.commentPropName!==!1&&t===this.options.commentPropName)return this.indentate(s)+``+this.newLine;if(t[0]==="?")return this.indentate(s)+"<"+t+n+"?"+this.tagEndChar;{let m=this.options.tagValueProcessor(t,e);return m=this.replaceEntitiesValue(m),m===""?this.indentate(s)+"<"+t+n+this.closeTag(t)+this.tagEndChar:this.indentate(s)+"<"+t+n+">"+m+"0&&this.options.processEntities)for(let t=0;tft.includes(["part","score-part","measure","credit","note"],e),trimValues:!0,preserveOrder:!0};function o$(e){try{return new r$.XMLParser(s$).parse(e)}catch(t){throw new Error(`Error reading XML: ${t}`)}}const Js=e=>{if(!e||!ft.isPlainObject(e))return!1;const t=ft.filter(ft.keys(e),n=>n!==":@");return t.length===1&&ft.isArray(e[ft.first(t)])},Ks=e=>Js(e)?ft.first(ft.filter(ft.keys(e),t=>t!==":@")):void 0,Qo=e=>{const t=Ks(e);return t?e[t]:[]},Jn=(e,t)=>{if(!Js(e))return;const n=Qo(e);return ft.find(n,s=>Ks(s)===t)},Kr=e=>{var n;if(!Js(e))return;const t=Qo(e);return(n=ft.find(t,s=>!!s["#text"]))==null?void 0:n["#text"]},Xy=(e,t)=>{var n;if(Js(e))return(n=e[":@"])==null?void 0:n[t]},Eo=(e,t)=>{if(!Js(e))return[];const n=Qo(e);return ft.filter(n,s=>!!(s!=null&&s[t]))},a$=120;class l${constructor(t,n,s,m){this.partName=t,this.partIdx=n,this.voices=s,this.largestChordPerVoice=m}}function u$(e){const t=Jn(e,"part-list"),n=Eo(t,"score-part");return ft.compact(ft.map(n,s=>Kr(Jn(s,"part-name"))))}const c$=e=>{const t=Qo(e),n=ft.first(t),s=Jn(n,"attributes"),m=Jn(s,"clef"),b=Jn(m,"sign");return Kr(b)};function h$(e){const t=u$(e),n=Eo(e,"part"),s=[];for(let m=0;mft.map(Eo(c,"note"),l=>Kr(Jn(l,"voice"))))));if(a.length===0){console.log(`Found no voices in part ${b}`);continue}const g=ft.times(a.length,()=>1);for(let c=0;cJs(e)&&Ks(e)==="measure",F7=e=>Js(e)&&Ks(e)==="attributes",B7=e=>Js(e)&&Ks(e)==="direction",S1=e=>Js(e)&&Ks(e)==="note",g$=e=>Js(e)&&Ks(e)==="lyric",x5=["","-","_","..."],Bp=["a","e","i","o","u"],w5=[...Bp,"h"],b$=e=>{let t=e;return t=t.replace(/[^a-zA-Z\s-]/g,""),t=t.replace(/-/g," "),t=t.replace(/\s+/g," "),t=t.replace(/Ooo+/g,"Oo"),t=t.replace(/ooo+/g,"oo"),t=t.replace(/Aa+/g,"Ah"),t=t.replace(/aa+/g,"ah"),t=t.trim(),t},y$=({measureChild:e,timeElapsed:t,currentDivisions:n,currentTempo:s,partIdx:m,partName:b,measureIdx:o})=>{const r=[];if(F7(e)){const u=Jn(e,"divisions"),a=Kr(u);a&&(console.info(`Found new divisions ${a}`),n=parseInt(a,10),r.push({time:t,partIdx:m,partName:b,measureIdx:o,tempo:s,divisions:n}))}else if(B7(e)){console.info("Looking for tempo changes in measure direction");const u=Eo(e,"sound"),a=ft.compact(ft.map(u,g=>{const c=Xy(g,"tempo");return c?parseFloat(c):null}));a.length>0&&(console.info(`Found new tempo ${ft.last(a)}`),s=ft.last(a),r.push({time:t,partIdx:m,partName:b,measureIdx:o,tempo:s,divisions:n}))}return{newTempoEvents:r,newTempo:s,newDivisions:n}},v$=e=>{var c,l,h;const t=e[1],n=Jn(t,"part-list");if(!n)throw new Error("Could not find part-list");const s=ft.compact(ft.map(Eo(n,"score-part"),d=>{const S=Jn(d,"part-name");return S?Kr(S):void 0})),m=Eo(t,"part"),b=ft.map(m,d=>Eo(d,"measure")),o=[],r=[],u=[],a=Math.max(...ft.map(b,d=>d.length)),g={};for(let d=0;d{const w=(y?Qo(y):[])[d];if(w&&Js(w)){const P=Eo(w,"sound");return ft.some(P,_=>Xy(_,"tempo"))}return!1}),f=ft.sortBy(ft.times(s.length),y=>S[y]?0:1);for(const y of f){const x=s[y],w=(c=b[y])==null?void 0:c[d],P=Qo(w),_=Math.max(...ft.compact(ft.map(ft.filter(r,W=>W.partIdx===y&&W.measureIdxNumber(W??0)+Number(Y??0))),0),E={};let M=((l=ft.findLast(o,W=>W.measureIdx<=d&&!isNaN(Number(W.tempo))))==null?void 0:l.divisions)??1,R=1,I=((h=ft.findLast(o,W=>W.measureIdx<=d&&!isNaN(Number(W.tempo))))==null?void 0:h.tempo)??a$;const L={};let F=1;ft.forEach(P,(W,Y)=>{var G,X,A,U,ie,re;const k=Jn(W,"voice"),z=Kr(k);if(z&&(R=parseInt(z,10)),F7(W)||B7(W)){const ge=((G=E==null?void 0:E[y])==null?void 0:G[R])??_,{newTempoEvents:ae,newTempo:me,newDivisions:ue}=y$({measureChild:W,timeElapsed:ge,currentDivisions:M,currentTempo:I,partIdx:y,partName:x,measureIdx:d});o.push(...ae),I=me,M=ue}else{const ge=Jn(W,"chord"),ae=((X=E==null?void 0:E[y])==null?void 0:X[R])??_;if(ge){F+=1;const Z=ft.findLast(r,H=>H.partIdx===y&&H.voice===R&&H.chordLevel===F),be=(Z==null?void 0:Z.time)??0,ve=ft.filter(r,H=>H.partIdx===y&&H.voice===R&&H.time>=be&&H.time{const ee=ft.find(r,O=>O.partIdx===y&&O.voice===R&&O.time===H.time&&O.chordLevel===F);if(ee){console.log("Event already exists for this chord level at this time",{restEvent:H,existingRestEvent:ee});return}const ne=ft.cloneDeep(ft.pick(H,["time","partIdx","partName","measureIdx","voice","eventSeconds","chordLevel","isRest"]));ne.isRest=!0,ne.chordLevel=F,r.push(ne)})}else{F=1;const Z=((A=L==null?void 0:L[y])==null?void 0:A[R])??0;E[y]=(E==null?void 0:E[y])||{},E[y][R]=ae+Z,L[y]=(L==null?void 0:L[y])||{},L[y][R]=0}const me=Jn(W,"duration"),ue=Kr(me);if(!S1(W)||Jn(W,"rest")){console.log("Not a note / is a rest",{measureChild:W,measureChildIdx:Y});const Z=Jn(W,"duration");if(Z){if(!ue)throw new Error(`No duration text content: ${JSON.stringify(Z)}`);const be=Ks(W)==="backup",ve=parseFloat(ue)*(be?-1:1),H=E5(ve,M,I),ee=((U=E==null?void 0:E[y])==null?void 0:U[R])??_;r.push({time:ee,partIdx:y,partName:x,measureIdx:d,voice:R,chordLevel:F,eventSeconds:H,isRest:!0}),E[y]=(E==null?void 0:E[y])||{},E[y][R]=ee+H}}else{if(!S1(W))throw new Error(`Unexpected measure child: ${JSON.stringify(W)}`);const Z=ft.findLastIndex(u,je=>!je.continuesPrevious&&je.partIdx===y&&je.voice===d),be=Z!==-1,ve=be?-1:ft.findLastIndex(u,je=>!je.continuesPrevious&&je.partIdx===y),ee=be?ft.filter(ft.slice(u,Z!==-1?Z:ve),je=>je.partIdx===y&&je.voice===R):ve!==-1?ft.filter(ft.slice(u,ve),je=>je.partIdx===y):[],ne=ft.reduce(ee,(je,Xe)=>(je+(Xe.continuesPrevious?"":" ")+Xe.lyric).trim(),"");g[`${y}_${F}`]=g[`${y}_${F}`]??"";let O="";const $=((ie=E==null?void 0:E[y])==null?void 0:ie[R])??_;let K=!1;const q=Jn(W,"staccato"),{frequency:de,isUnpitched:ce}=f$(W),le=ft.findLast(r,je=>je.partIdx===y&&je.voice===R&&je.chordLevel===F),ye=le==null?void 0:le.frequency,we=le==null?void 0:le.isUnpitched,Ae=le==null?void 0:le.isRest,We=Ae||de!==ye||ce!==we;if(ft.forEach(Qo(W),je=>{var ct;if(!g$(je))return;const Xe=Jn(je,"text");if(!Xe){console.log("No text in the lyric",{lyricEl:je});return}const Qe=((ct=Kr(Xe))==null?void 0:ct.trim())??"";if(!Qe||x5.includes(Qe)){if(console.log("Lyrics are continuation strings, no need to add them",{lyricEl:je,newTextString:Qe,LYRICS_TO_CONSIDER_AS_CONTINUATIONS:x5}),We){const vt=ne||ft.last(ft.split(g[`${y}_${F}`]," "))||"ah",Ct=ft.findLastIndex(vt,ei=>!ft.includes(Bp,ei)),Kt=Ct!==-1?vt.slice(Ct):vt;O+=Kt,console.log("Adding continuation lyric",{lyricEl:je,newTextString:Qe,newLyricText:O,partChordLyrics:g[`${y}_${F}`]}),u.push({time:$,partIdx:y,partName:x,measureIdx:d,voice:R,chordLevel:F,lyric:Kt,continuesPrevious:!Ae}),K=!Ae}return}if(!ne){O+=Qe,console.log("First lyric",{lyricEl:je,measureChild:W,newTextString:Qe,newLyricText:O,partChordLyrics:g[`${y}_${F}`]}),u.push({time:$,partIdx:y,partName:x,measureIdx:d,voice:R,chordLevel:F,lyric:Qe,continuesPrevious:!1});return}const nt=Jn(je,"syllabic"),ht=Kr(nt);if(!ht||ht==="single"||ht==="begin"||!ft.includes(w5,Qe[0])){O+=` ${Qe}`,console.log("Adding new syllable",{lyricEl:je,measureChild:W,newTextString:Qe,newLyricText:O,partChordLyrics:g[`${y}_${F}`],syllabicText:ht,LETTERS_TO_CONSIDER_APPENDING:w5}),u.push({time:$,partIdx:y,partName:x,measureIdx:d,voice:R,chordLevel:F,lyric:Qe,continuesPrevious:!1});return}const yt=ft.last(ne);let rt=Qe.length;for(let vt=0;vt!ft.includes(Bp,Ct));rt=vt!==-1?vt+1:0}const bt=Qe.slice(rt).trim();if(bt){const vt=ft.uniq(bt).length===1,Ct=ft.includes(Bp,bt[0]);K=vt&&!Ct&&!Ae&&!We&&!q,O+=`${K?"":" "}${bt}`,console.log("Adding after new letter",{lyricEl:je,measureChild:W,newText:bt,newLyricText:O,partChordLyrics:g[`${y}_${F}`],firstNewLetter:rt,newTextString:Qe,lastLetterInPreviousLyric:yt,continuesPreviousLyric:K}),u.push({time:$,partIdx:y,partName:x,measureIdx:d,voice:R,chordLevel:F,lyric:bt,continuesPrevious:K});return}}),!O&&F>1){const je=ft.findLast(u,Xe=>Xe.partIdx===y&&Xe.voice===R&&Xe.time===$);if(je){const Xe=ft.cloneDeep(je);Xe.chordLevel=F,ft.find(u,Xe)||(K=!!Xe.continuesPrevious,O=`${K?"":" "}${Xe.lyric??""}`,console.log("Adding previous lyric",{measureChild:W,newLyricText:O,partChordLyrics:g[`${y}_${F}`],lastLyricEvent:je,newLyricEvent:Xe}),u.push(Xe))}}const De=!!O;if(g[`${y}_${F}`]+=O,!ue)throw new Error(`No duration element found: ${JSON.stringify(W)}`);const Je=parseFloat(ue),ke=E5(Je,M,I);console.log(`Note number ${Y} with duration ${Je} (${ke} seconds) and frequency ${de}`),K&&le&&le.eventSeconds!==void 0&&le.eventSeconds!==null?(le.lyrics+=O,le.lyricsChanged=De,le.eventSeconds+=ke):(K&&console.warn("Continues previous lyric but no previous note found",{partIdx:y,currentVoice:R,currChordLvl:F,newLyricText:O,partChordLyrics:g[`${y}_${F}`],lastPartVoiceChord:le}),r.push({time:$,partIdx:y,partName:x,measureIdx:d,voice:R,chordLevel:F,eventSeconds:ke,frequency:de,isRest:!1,lyricsChanged:De,lyrics:O,isStaccato:!!q,isUnpitched:ce}));const ze=((re=L==null?void 0:L[y])==null?void 0:re[R])??0;L[y]=(L==null?void 0:L[y])||{},L[y][R]=Math.max(ze,ke)}}})}}return{noteEvents:r,tempoEvents:o,lyricsEvents:u}},S$=({splitParams:e,noteEvents:t})=>{const n={lyrics:"",events:[]},s=ft.filter(t,b=>b.partIdx===e.partIdx&&b.voice===e.voice&&b.chordLevel===e.chordLevel);n.lyrics=b$(ft.map(ft.reject(s,"isRest"),b=>b.lyrics??"").join("").trim()),n.events=ft.flatMap(s,(b,o)=>{const{time:r,frequency:u,lyricsChanged:a,isStaccato:g,eventSeconds:c,isRest:l}=b,h=[];return l?(h.push(Ea({eventType:Uo.NoteOff,time:r})),h.push(Ea({eventType:Uo.Empty,time:r}))):(a&&(console.log("Found new lyrics"),h.push(Ea({eventType:Uo.NoteOff,time:r}))),h.push(Ea({eventType:Uo.SetTargetFrequency,time:r,frequency:u})),a&&(h.push(Ea({eventType:Uo.NoteOn,time:r})),g&&(h.push(Ea({eventType:Uo.SetPhonemeSpeed,time:r,phonemeSpeed:1.5})),h.push(Ea({eventType:Uo.SetPhonemeSpeed,time:r+(c??0),phonemeSpeed:1}))))),console.log({noteEvent:b,noteEventIdx:o,newEvents:h}),h});const m=ft.last(s);return m&&(m.isRest||n.events.push(Ea({eventType:Uo.NoteOff,time:m.time+(m.eventSeconds??0)}))),n},E$=e=>{const t=e[1],n=h$(t),s=ft.flatMap(n,b=>ft.flatMap(b.voices,(o,r)=>ft.times(b.largestChordPerVoice[r],u=>({partIdx:b.partIdx,partName:b.partName,voice:o,chordLevel:u+1,largestChordLvl:b.largestChordPerVoice[r],numVoices:b.voices.length})))),m=v$(e);return ft.map(s,b=>({splitParams:b,output:S$({splitParams:b,...m}),unparsedPartEvents:{tempoEvents:m==null?void 0:m.tempoEvents,noteEvents:ft.filter(m==null?void 0:m.noteEvents,o=>o.partIdx===b.partIdx&&o.voice===b.voice&&o.chordLevel===b.chordLevel),lyricsEvents:ft.filter(m==null?void 0:m.lyricsEvents,o=>o.partIdx===b.partIdx&&o.voice===b.voice&&o.chordLevel===b.chordLevel)}}))},x$=Lt("input")({clip:"rect(0 0 0 0)",clipPath:"inset(50%)",height:1,overflow:"hidden",position:"absolute",bottom:0,left:0,whiteSpace:"nowrap",width:1}),w$=({isLoadingVoice:e,setOddVoiceOutputs:t,setRawFile:n,resetAudioOutputs:s})=>{const[,m]=dn.useTransition(),b=dn.useCallback(o=>{var a,g;const r=(g=(a=o==null?void 0:o.target)==null?void 0:a.files)==null?void 0:g[0];if(!r)return;const u=new FileReader;u.onload=c=>{var h;if(!((h=c==null?void 0:c.target)!=null&&h.result))return;s(),t([]),n("");const l=c.target.result;m(()=>{const d=E$(o$(l));t(d),n(l)})},u.readAsText(r)},[s,t,n,m]);return Te.jsxs(xu,{component:"label",role:void 0,variant:"contained",tabIndex:-1,startIcon:Te.jsx(L7,{}),disabled:e,children:["Upload file",Te.jsx(x$,{type:"file",onChange:b})]})},_$=()=>Te.jsxs(xn,{item:!0,container:!0,direction:"column",p:2,gap:3,alignItems:"flex-start",children:[Te.jsx(xn,{item:!0,children:Te.jsx(oi,{variant:"h6",textAlign:"start",children:"Copyrights"})}),Te.jsxs(xn,{item:!0,container:!0,gap:3,children:[Te.jsxs(oi,{textAlign:"start",variant:"caption",children:["The source code for this project is released under the"," ",Te.jsx("a",{href:"https://github.com/VehpuS/singing-synthesis/blob/main/LICENSE",children:"GNU GPL v3.0"})," license."]}),Te.jsxs(oi,{textAlign:"start",variant:"caption",children:["OddVoices is copyright © 2021-2022 ",Te.jsx("a",{href:"https://nathan.ho.name/",children:"Nathan Ho"})," and is available under the"," ",Te.jsx("a",{href:"https://github.com/oddvoices/oddvoices/blob/develop/LICENSE",children:"Apache License"}),". Its voice files are in the Public Domain."]}),Te.jsxs(oi,{textAlign:"start",variant:"caption",children:["Midifile is copyright © 1999-2018 Craig Stuart Sapp and is available under the"," ",Te.jsx("a",{href:"https://github.com/craigsapp/midifile",children:"BSD 2-Clause License"}),"."]}),Te.jsxs(oi,{textAlign:"start",variant:"caption",children:["The CMU Pronouncing Dictionary is copyright © 1993-2015 Carnegie Mellon University and available under the"," ",Te.jsx("a",{href:"http://svn.code.sf.net/p/cmusphinx/code/trunk/cmudict/",children:"BSD 2-Clause License"}),"."]})]})]}),T$=e=>typeof e=="boolean"||e instanceof Boolean,P$=e=>typeof e=="number"||e instanceof Number,M$=e=>typeof e=="bigint"||e instanceof BigInt,D7=e=>!!e&&e instanceof Date,C$=e=>typeof e=="string"||e instanceof String,L$=e=>Array.isArray(e),A$=e=>e instanceof Object&&e!==null;function R$(e){const[t,n]=Me.useState(e());return[t,()=>n(m=>!m),n]}let I$=1;const N$=()=>I$++;function k$(){const e=Me.useRef();return e.current===void 0&&(e.current=`:jsnvw:${N$()}:`),e.current}function V7(e){let{field:t,value:n,data:s,lastElement:m,openBracket:b,closeBracket:o,level:r,style:u,shouldExpandNode:a}=e;const g=Me.useRef(!1),[c,l,h]=R$(()=>a(r,n,t));Me.useEffect(()=>{g.current?h(a(r,n,t)):g.current=!0},[a]);const d=c?u.collapseIcon:u.expandIcon,S=c?"collapse JSON":"expand JSON",f=k$(),y=r+1,x=s.length-1,w=P=>{P.key===" "&&l()};return Me.createElement("div",{className:u.basicChildStyle,role:"list"},Me.createElement("span",{className:d,onClick:l,onKeyDown:w,role:"button",tabIndex:0,"aria-label":S,"aria-expanded":c,"aria-controls":c?f:void 0}),t&&Me.createElement("span",{className:u.label},t,":"),Me.createElement("span",{className:u.punctuation},b),c?Me.createElement("div",{id:f},s.map((P,_)=>Me.createElement(G7,{key:P[0]||_,field:P[0],value:P[1],style:u,lastElement:_===x,level:y,shouldExpandNode:a}))):Me.createElement("span",{className:u.collapsedContent,onClick:l,onKeyDown:w,role:"button",tabIndex:-1,"aria-hidden":!0,"aria-label":S,"aria-expanded":c}),Me.createElement("span",{className:u.punctuation},o),!m&&Me.createElement("span",{className:u.punctuation},","))}function O$(e){let{field:t,value:n,style:s,lastElement:m,shouldExpandNode:b,level:o}=e;return V7({field:t,value:n,lastElement:m||!1,level:o,openBracket:"{",closeBracket:"}",style:s,shouldExpandNode:b,data:Object.keys(n).map(r=>[r,n[r]])})}function F$(e){let{field:t,value:n,style:s,lastElement:m,level:b,shouldExpandNode:o}=e;return V7({field:t,value:n,lastElement:m||!1,level:b,openBracket:"[",closeBracket:"]",style:s,shouldExpandNode:o,data:n.map(r=>[void 0,r])})}function B$(e){let{field:t,value:n,style:s,lastElement:m}=e,b=n,o=s.otherValue;return n===null?(b="null",o=s.nullValue):n===void 0?(b="undefined",o=s.undefinedValue):C$(n)?(b=`"${n}"`,o=s.stringValue):T$(n)?(b=n?"true":"false",o=s.booleanValue):P$(n)?(b=n.toString(),o=s.numberValue):M$(n)?(b=`${n.toString()}n`,o=s.numberValue):D7(n)?b=n.toISOString():b=n.toString(),t===""&&(t='""'),Me.createElement("div",{className:s.basicChildStyle,role:"listitem"},t&&Me.createElement("span",{className:s.label},t,":"),Me.createElement("span",{className:o},b),!m&&Me.createElement("span",{className:s.punctuation},","))}function G7(e){const t=e.value;return L$(t)?Me.createElement(F$,Object.assign({},e)):A$(t)&&!D7(t)?Me.createElement(O$,Object.assign({},e)):Me.createElement(B$,Object.assign({},e))}var $n={"container-base":"_GzYRV","punctuation-base":"_3eOF8",pointer:"_1MFti","expander-base":"_f10Tu _1MFti","expand-icon":"_1UmXx","collapse-icon":"_1LId0","collapsed-content-base":"_1pNG9 _1MFti","container-light":"_2IvMF _GzYRV","basic-element-style":"_2bkNM","label-light":"_1MGIk","punctuation-light":"_3uHL6 _3eOF8","value-null-light":"_2T6PJ","value-undefined-light":"_1Gho6","value-string-light":"_vGjyY","value-number-light":"_1bQdo","value-boolean-light":"_3zQKs","value-other-light":"_1xvuR","collapse-icon-light":"_oLqym _f10Tu _1MFti _1LId0","expand-icon-light":"_2AXVT _f10Tu _1MFti _1UmXx","collapsed-content-light":"_2KJWg _1pNG9 _1MFti","container-dark":"_11RoI _GzYRV","expand-icon-dark":"_17H2C _f10Tu _1MFti _1UmXx","collapse-icon-dark":"_3QHg2 _f10Tu _1MFti _1LId0","collapsed-content-dark":"_3fDAz _1pNG9 _1MFti","label-dark":"_2bSDX","punctuation-dark":"_gsbQL _3eOF8","value-null-dark":"_LaAZe","value-undefined-dark":"_GTKgm","value-string-dark":"_Chy1W","value-number-dark":"_2bveF","value-boolean-dark":"_2vRm-","value-other-dark":"_1prJR"};const D$={container:$n["container-light"],basicChildStyle:$n["basic-element-style"],label:$n["label-light"],nullValue:$n["value-null-light"],undefinedValue:$n["value-undefined-light"],stringValue:$n["value-string-light"],booleanValue:$n["value-boolean-light"],numberValue:$n["value-number-light"],otherValue:$n["value-other-light"],punctuation:$n["punctuation-light"],collapseIcon:$n["collapse-icon-light"],expandIcon:$n["expand-icon-light"],collapsedContent:$n["collapsed-content-light"]},_5={container:$n["container-dark"],basicChildStyle:$n["basic-element-style"],label:$n["label-dark"],nullValue:$n["value-null-dark"],undefinedValue:$n["value-undefined-dark"],stringValue:$n["value-string-dark"],booleanValue:$n["value-boolean-dark"],numberValue:$n["value-number-dark"],otherValue:$n["value-other-dark"],punctuation:$n["punctuation-dark"],collapseIcon:$n["collapse-icon-dark"],expandIcon:$n["expand-icon-dark"],collapsedContent:$n["collapsed-content-dark"]},V$=()=>!0,T5=e=>e<1,P5=e=>{let{data:t,style:n=D$,shouldExpandNode:s=V$}=e;return Me.createElement("div",{className:n.container},Me.createElement(G7,{value:t,style:n,lastElement:!0,level:0,shouldExpandNode:s}))};function mp(e){return e<26?e+65:e<52?e+71:e<62?e-4:e===62?43:e===63?47:65}function G$(e){let t=2,n="";for(let s=e.length,m=0,b=0;b0&&b*4/3%76===0&&(n+=`\r +`):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}tl.prototype.build=function(e){return this.options.preserveOrder?Kz(e,this.options):(Array.isArray(e)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(e={[this.options.arrayNodeName]:e}),this.j2x(e,0).val)};tl.prototype.j2x=function(e,t){let n="",s="";for(let m in e)if(Object.prototype.hasOwnProperty.call(e,m))if(typeof e[m]>"u")this.isAttribute(m)&&(s+="");else if(e[m]===null)this.isAttribute(m)?s+="":m[0]==="?"?s+=this.indentate(t)+"<"+m+"?"+this.tagEndChar:s+=this.indentate(t)+"<"+m+"/"+this.tagEndChar;else if(e[m]instanceof Date)s+=this.buildTextValNode(e[m],m,"",t);else if(typeof e[m]!="object"){const b=this.isAttribute(m);if(b)n+=this.buildAttrPairStr(b,""+e[m]);else if(m===this.options.textNodeName){let o=this.options.tagValueProcessor(m,""+e[m]);s+=this.replaceEntitiesValue(o)}else s+=this.buildTextValNode(e[m],m,"",t)}else if(Array.isArray(e[m])){const b=e[m].length;let o="";for(let r=0;r"u"||(u===null?m[0]==="?"?s+=this.indentate(t)+"<"+m+"?"+this.tagEndChar:s+=this.indentate(t)+"<"+m+"/"+this.tagEndChar:typeof u=="object"?this.options.oneListGroup?o+=this.j2x(u,t+1).val:o+=this.processTextOrObjNode(u,m,t):o+=this.buildTextValNode(u,m,"",t))}this.options.oneListGroup&&(o=this.buildObjectNode(o,m,"",t)),s+=o}else if(this.options.attributesGroupName&&m===this.options.attributesGroupName){const b=Object.keys(e[m]),o=b.length;for(let r=0;r"+e+m:this.options.commentPropName!==!1&&t===this.options.commentPropName&&b.length===0?this.indentate(s)+``+this.newLine:this.indentate(s)+"<"+t+n+b+this.tagEndChar+e+this.indentate(s)+m}};tl.prototype.closeTag=function(e){let t="";return this.options.unpairedTags.indexOf(e)!==-1?this.options.suppressUnpairedNode||(t="/"):this.options.suppressEmptyNode?t="/":t=`>`+this.newLine;if(this.options.commentPropName!==!1&&t===this.options.commentPropName)return this.indentate(s)+``+this.newLine;if(t[0]==="?")return this.indentate(s)+"<"+t+n+"?"+this.tagEndChar;{let m=this.options.tagValueProcessor(t,e);return m=this.replaceEntitiesValue(m),m===""?this.indentate(s)+"<"+t+n+this.closeTag(t)+this.tagEndChar:this.indentate(s)+"<"+t+n+">"+m+"0&&this.options.processEntities)for(let t=0;tft.includes(["part","score-part","measure","credit","note"],e),trimValues:!0,preserveOrder:!0};function o$(e){try{return new r$.XMLParser(s$).parse(e)}catch(t){throw new Error(`Error reading XML: ${t}`)}}const Js=e=>{if(!e||!ft.isPlainObject(e))return!1;const t=ft.filter(ft.keys(e),n=>n!==":@");return t.length===1&&ft.isArray(e[ft.first(t)])},Ks=e=>Js(e)?ft.first(ft.filter(ft.keys(e),t=>t!==":@")):void 0,Qo=e=>{const t=Ks(e);return t?e[t]:[]},Jn=(e,t)=>{if(!Js(e))return;const n=Qo(e);return ft.find(n,s=>Ks(s)===t)},Kr=e=>{var n;if(!Js(e))return;const t=Qo(e);return(n=ft.find(t,s=>!!s["#text"]))==null?void 0:n["#text"]},Xy=(e,t)=>{var n;if(Js(e))return(n=e[":@"])==null?void 0:n[t]},Eo=(e,t)=>{if(!Js(e))return[];const n=Qo(e);return ft.filter(n,s=>!!(s!=null&&s[t]))},a$=120;class l${constructor(t,n,s,m){this.partName=t,this.partIdx=n,this.voices=s,this.largestChordPerVoice=m}}function u$(e){const t=Jn(e,"part-list"),n=Eo(t,"score-part");return ft.compact(ft.map(n,s=>Kr(Jn(s,"part-name"))))}const c$=e=>{const t=Qo(e),n=ft.first(t),s=Jn(n,"attributes"),m=Jn(s,"clef"),b=Jn(m,"sign");return Kr(b)};function h$(e){const t=u$(e),n=Eo(e,"part"),s=[];for(let m=0;mft.map(Eo(c,"note"),l=>Kr(Jn(l,"voice"))))));if(a.length===0){console.log(`Found no voices in part ${b}`);continue}const g=ft.times(a.length,()=>1);for(let c=0;cJs(e)&&Ks(e)==="measure",F7=e=>Js(e)&&Ks(e)==="attributes",B7=e=>Js(e)&&Ks(e)==="direction",S1=e=>Js(e)&&Ks(e)==="note",g$=e=>Js(e)&&Ks(e)==="lyric",x5=["","-","_","..."],Bp=["a","e","i","o","u"],w5=[...Bp,"h"],b$=e=>{let t=e;return t=t.replace(/[^a-zA-Z\s-']/g,""),t=t.replace(/-/g," "),t=t.replace(/\s+/g," "),t=t.replace(/Ooo+/g,"Oo"),t=t.replace(/ooo+/g,"oo"),t=t.replace(/AA+([ $])/g,"Ah$1"),t=t.replace(/Aa+([ $])/g,"Ah$1"),t=t.replace(/aa+([ $])/g,"ah$1"),t=t.replace(/be lieve/g,"be leave"),t=t.replace(/Be lieve/g,"Be leave"),t=t.replace(/BE LIEVE/g,"BE LEAVE"),t=t.replace(/lis ten/g,"liss sen"),t=t.replace(/Lis ten/g,"Liss sen"),t=t.replace(/LIS TEN/g,"LISS SEN"),t=t.replace(/de cide/g,"de side"),t=t.replace(/De cide/g,"De side"),t=t.replace(/DE CIDE/g,"DE SIDE"),t=t.trim(),t},y$=({measureChild:e,timeElapsed:t,currentDivisions:n,currentTempo:s,partIdx:m,partName:b,measureIdx:o})=>{const r=[];if(F7(e)){const u=Jn(e,"divisions"),a=Kr(u);a&&(console.info(`Found new divisions ${a}`),n=parseInt(a,10),r.push({time:t,partIdx:m,partName:b,measureIdx:o,tempo:s,divisions:n}))}else if(B7(e)){console.info("Looking for tempo changes in measure direction");const u=Eo(e,"sound"),a=ft.compact(ft.map(u,g=>{const c=Xy(g,"tempo");return c?parseFloat(c):null}));a.length>0&&(console.info(`Found new tempo ${ft.last(a)}`),s=ft.last(a),r.push({time:t,partIdx:m,partName:b,measureIdx:o,tempo:s,divisions:n}))}return{newTempoEvents:r,newTempo:s,newDivisions:n}},v$=e=>{var c,l,h;const t=e[1],n=Jn(t,"part-list");if(!n)throw new Error("Could not find part-list");const s=ft.compact(ft.map(Eo(n,"score-part"),d=>{const S=Jn(d,"part-name");return S?Kr(S):void 0})),m=Eo(t,"part"),b=ft.map(m,d=>Eo(d,"measure")),o=[],r=[],u=[],a=Math.max(...ft.map(b,d=>d.length)),g={};for(let d=0;d{const w=(y?Qo(y):[])[d];if(w&&Js(w)){const P=Eo(w,"sound");return ft.some(P,_=>Xy(_,"tempo"))}return!1}),f=ft.sortBy(ft.times(s.length),y=>S[y]?0:1);for(const y of f){const x=s[y],w=(c=b[y])==null?void 0:c[d],P=Qo(w),_=Math.max(...ft.compact(ft.map(ft.filter(r,W=>W.partIdx===y&&W.measureIdxNumber(W??0)+Number(Y??0))),0),E={};let M=((l=ft.findLast(o,W=>W.measureIdx<=d&&!isNaN(Number(W.tempo))))==null?void 0:l.divisions)??1,R=1,I=((h=ft.findLast(o,W=>W.measureIdx<=d&&!isNaN(Number(W.tempo))))==null?void 0:h.tempo)??a$;const L={};let F=1;ft.forEach(P,(W,Y)=>{var G,X,A,U,ie,re;const k=Jn(W,"voice"),z=Kr(k);if(z&&(R=parseInt(z,10)),F7(W)||B7(W)){const ge=((G=E==null?void 0:E[y])==null?void 0:G[R])??_,{newTempoEvents:ae,newTempo:me,newDivisions:ue}=y$({measureChild:W,timeElapsed:ge,currentDivisions:M,currentTempo:I,partIdx:y,partName:x,measureIdx:d});o.push(...ae),I=me,M=ue}else{const ge=Jn(W,"chord"),ae=((X=E==null?void 0:E[y])==null?void 0:X[R])??_;if(ge){F+=1;const Z=ft.findLast(r,H=>H.partIdx===y&&H.voice===R&&H.chordLevel===F),be=(Z==null?void 0:Z.time)??0,ve=ft.filter(r,H=>H.partIdx===y&&H.voice===R&&H.time>=be&&H.time{const ee=ft.find(r,O=>O.partIdx===y&&O.voice===R&&O.time===H.time&&O.chordLevel===F);if(ee){console.log("Event already exists for this chord level at this time",{restEvent:H,existingRestEvent:ee});return}const ne=ft.cloneDeep(ft.pick(H,["time","partIdx","partName","measureIdx","voice","eventSeconds","chordLevel","isRest"]));ne.isRest=!0,ne.chordLevel=F,r.push(ne)})}else{F=1;const Z=((A=L==null?void 0:L[y])==null?void 0:A[R])??0;E[y]=(E==null?void 0:E[y])||{},E[y][R]=ae+Z,L[y]=(L==null?void 0:L[y])||{},L[y][R]=0}const me=Jn(W,"duration"),ue=Kr(me);if(!S1(W)||Jn(W,"rest")){console.log("Not a note / is a rest",{measureChild:W,measureChildIdx:Y});const Z=Jn(W,"duration");if(Z){if(!ue)throw new Error(`No duration text content: ${JSON.stringify(Z)}`);const be=Ks(W)==="backup",ve=parseFloat(ue)*(be?-1:1),H=E5(ve,M,I),ee=((U=E==null?void 0:E[y])==null?void 0:U[R])??_;r.push({time:ee,partIdx:y,partName:x,measureIdx:d,voice:R,chordLevel:F,eventSeconds:H,isRest:!0}),E[y]=(E==null?void 0:E[y])||{},E[y][R]=ee+H}}else{if(!S1(W))throw new Error(`Unexpected measure child: ${JSON.stringify(W)}`);const Z=ft.findLastIndex(u,je=>!je.continuesPrevious&&je.partIdx===y&&je.voice===d),be=Z!==-1,ve=be?-1:ft.findLastIndex(u,je=>!je.continuesPrevious&&je.partIdx===y),ee=be?ft.filter(ft.slice(u,Z!==-1?Z:ve),je=>je.partIdx===y&&je.voice===R):ve!==-1?ft.filter(ft.slice(u,ve),je=>je.partIdx===y):[],ne=ft.reduce(ee,(je,Xe)=>(je+(Xe.continuesPrevious?"":" ")+Xe.lyric).trim(),"");g[`${y}_${F}`]=g[`${y}_${F}`]??"";let O="";const $=((ie=E==null?void 0:E[y])==null?void 0:ie[R])??_;let K=!1;const q=Jn(W,"staccato"),{frequency:de,isUnpitched:ce}=f$(W),le=ft.findLast(r,je=>je.partIdx===y&&je.voice===R&&je.chordLevel===F),ye=le==null?void 0:le.frequency,we=le==null?void 0:le.isUnpitched,Ae=le==null?void 0:le.isRest,We=Ae||de!==ye||ce!==we;if(ft.forEach(Qo(W),je=>{var ct;if(!g$(je))return;const Xe=Jn(je,"text");if(!Xe){console.log("No text in the lyric",{lyricEl:je});return}const Qe=((ct=Kr(Xe))==null?void 0:ct.trim())??"";if(!Qe||x5.includes(Qe)){if(console.log("Lyrics are continuation strings, no need to add them",{lyricEl:je,newTextString:Qe,LYRICS_TO_CONSIDER_AS_CONTINUATIONS:x5}),We){const vt=ne||ft.last(ft.split(g[`${y}_${F}`]," "))||"ah",Ct=ft.findLastIndex(vt,ei=>!ft.includes(Bp,ei)),Kt=Ct!==-1?vt.slice(Ct):vt;O+=Kt,console.log("Adding continuation lyric",{lyricEl:je,newTextString:Qe,newLyricText:O,partChordLyrics:g[`${y}_${F}`]}),u.push({time:$,partIdx:y,partName:x,measureIdx:d,voice:R,chordLevel:F,lyric:Kt,continuesPrevious:!Ae}),K=!Ae}return}if(!ne){O+=Qe,console.log("First lyric",{lyricEl:je,measureChild:W,newTextString:Qe,newLyricText:O,partChordLyrics:g[`${y}_${F}`]}),u.push({time:$,partIdx:y,partName:x,measureIdx:d,voice:R,chordLevel:F,lyric:Qe,continuesPrevious:!1});return}const nt=Jn(je,"syllabic"),ht=Kr(nt);if(!ht||ht==="single"||ht==="begin"||!ft.includes(w5,Qe[0])){O+=` ${Qe}`,console.log("Adding new syllable",{lyricEl:je,measureChild:W,newTextString:Qe,newLyricText:O,partChordLyrics:g[`${y}_${F}`],syllabicText:ht,LETTERS_TO_CONSIDER_APPENDING:w5}),u.push({time:$,partIdx:y,partName:x,measureIdx:d,voice:R,chordLevel:F,lyric:Qe,continuesPrevious:!1});return}const yt=ft.last(ne);let rt=Qe.length;for(let vt=0;vt!ft.includes(Bp,Ct));rt=vt!==-1?vt+1:0}const bt=Qe.slice(rt).trim();if(bt){const vt=ft.uniq(bt).length===1,Ct=ft.includes(Bp,bt[0]);K=vt&&!Ct&&!Ae&&!We&&!q,O+=`${K?"":" "}${bt}`,console.log("Adding after new letter",{lyricEl:je,measureChild:W,newText:bt,newLyricText:O,partChordLyrics:g[`${y}_${F}`],firstNewLetter:rt,newTextString:Qe,lastLetterInPreviousLyric:yt,continuesPreviousLyric:K}),u.push({time:$,partIdx:y,partName:x,measureIdx:d,voice:R,chordLevel:F,lyric:bt,continuesPrevious:K});return}}),!O&&F>1){const je=ft.findLast(u,Xe=>Xe.partIdx===y&&Xe.voice===R&&Xe.time===$);if(je){const Xe=ft.cloneDeep(je);Xe.chordLevel=F,ft.find(u,Xe)||(K=!!Xe.continuesPrevious,O=`${K?"":" "}${Xe.lyric??""}`,console.log("Adding previous lyric",{measureChild:W,newLyricText:O,partChordLyrics:g[`${y}_${F}`],lastLyricEvent:je,newLyricEvent:Xe}),u.push(Xe))}}const De=!!O;if(g[`${y}_${F}`]+=O,!ue)throw new Error(`No duration element found: ${JSON.stringify(W)}`);const Je=parseFloat(ue),ke=E5(Je,M,I);console.log(`Note number ${Y} with duration ${Je} (${ke} seconds) and frequency ${de}`),K&&le&&le.eventSeconds!==void 0&&le.eventSeconds!==null?(le.lyrics+=O,le.lyricsChanged=De,le.eventSeconds+=ke):(K&&console.warn("Continues previous lyric but no previous note found",{partIdx:y,currentVoice:R,currChordLvl:F,newLyricText:O,partChordLyrics:g[`${y}_${F}`],lastPartVoiceChord:le}),r.push({time:$,partIdx:y,partName:x,measureIdx:d,voice:R,chordLevel:F,eventSeconds:ke,frequency:de,isRest:!1,lyricsChanged:De,lyrics:O,isStaccato:!!q,isUnpitched:ce}));const ze=((re=L==null?void 0:L[y])==null?void 0:re[R])??0;L[y]=(L==null?void 0:L[y])||{},L[y][R]=Math.max(ze,ke)}}})}}return{noteEvents:r,tempoEvents:o,lyricsEvents:u}},S$=({splitParams:e,noteEvents:t})=>{const n={lyrics:"",events:[]},s=ft.filter(t,b=>b.partIdx===e.partIdx&&b.voice===e.voice&&b.chordLevel===e.chordLevel);n.lyrics=b$(ft.map(ft.reject(s,"isRest"),b=>b.lyrics??"").join("").trim()),n.events=ft.flatMap(s,(b,o)=>{const{time:r,frequency:u,lyricsChanged:a,isStaccato:g,eventSeconds:c,isRest:l}=b,h=[];return l?(h.push(Ea({eventType:Uo.NoteOff,time:r})),h.push(Ea({eventType:Uo.Empty,time:r}))):(a&&(console.log("Found new lyrics"),h.push(Ea({eventType:Uo.NoteOff,time:r}))),h.push(Ea({eventType:Uo.SetTargetFrequency,time:r,frequency:u})),a&&(h.push(Ea({eventType:Uo.NoteOn,time:r})),g&&(h.push(Ea({eventType:Uo.SetPhonemeSpeed,time:r,phonemeSpeed:1.5})),h.push(Ea({eventType:Uo.SetPhonemeSpeed,time:r+(c??0),phonemeSpeed:1}))))),console.log({noteEvent:b,noteEventIdx:o,newEvents:h}),h});const m=ft.last(s);return m&&(m.isRest||n.events.push(Ea({eventType:Uo.NoteOff,time:m.time+(m.eventSeconds??0)}))),n},E$=e=>{const t=e[1],n=h$(t),s=ft.flatMap(n,b=>ft.flatMap(b.voices,(o,r)=>ft.times(b.largestChordPerVoice[r],u=>({partIdx:b.partIdx,partName:b.partName,voice:o,chordLevel:u+1,largestChordLvl:b.largestChordPerVoice[r],numVoices:b.voices.length})))),m=v$(e);return ft.map(s,b=>({splitParams:b,output:S$({splitParams:b,...m}),unparsedPartEvents:{tempoEvents:m==null?void 0:m.tempoEvents,noteEvents:ft.filter(m==null?void 0:m.noteEvents,o=>o.partIdx===b.partIdx&&o.voice===b.voice&&o.chordLevel===b.chordLevel),lyricsEvents:ft.filter(m==null?void 0:m.lyricsEvents,o=>o.partIdx===b.partIdx&&o.voice===b.voice&&o.chordLevel===b.chordLevel)}}))},x$=Lt("input")({clip:"rect(0 0 0 0)",clipPath:"inset(50%)",height:1,overflow:"hidden",position:"absolute",bottom:0,left:0,whiteSpace:"nowrap",width:1}),w$=({isLoadingVoice:e,setOddVoiceOutputs:t,setRawFile:n,resetAudioOutputs:s})=>{const[,m]=dn.useTransition(),b=dn.useCallback(o=>{var a,g;const r=(g=(a=o==null?void 0:o.target)==null?void 0:a.files)==null?void 0:g[0];if(!r)return;const u=new FileReader;u.onload=c=>{var h;if(!((h=c==null?void 0:c.target)!=null&&h.result))return;s(),t([]),n("");const l=c.target.result;m(()=>{const d=E$(o$(l));t(d),n(l)})},u.readAsText(r)},[s,t,n,m]);return Te.jsxs(xu,{component:"label",role:void 0,variant:"contained",tabIndex:-1,startIcon:Te.jsx(L7,{}),disabled:e,children:["Upload file",Te.jsx(x$,{type:"file",onChange:b})]})},_$=()=>Te.jsxs(xn,{item:!0,container:!0,direction:"column",p:2,gap:3,alignItems:"flex-start",children:[Te.jsx(xn,{item:!0,children:Te.jsx(oi,{variant:"h6",textAlign:"start",children:"Copyrights"})}),Te.jsxs(xn,{item:!0,container:!0,gap:3,children:[Te.jsxs(oi,{textAlign:"start",variant:"caption",children:["The source code for this project is released under the"," ",Te.jsx("a",{href:"https://github.com/VehpuS/singing-synthesis/blob/main/LICENSE",children:"GNU GPL v3.0"})," license."]}),Te.jsxs(oi,{textAlign:"start",variant:"caption",children:["OddVoices is copyright © 2021-2022 ",Te.jsx("a",{href:"https://nathan.ho.name/",children:"Nathan Ho"})," and is available under the"," ",Te.jsx("a",{href:"https://github.com/oddvoices/oddvoices/blob/develop/LICENSE",children:"Apache License"}),". Its voice files are in the Public Domain."]}),Te.jsxs(oi,{textAlign:"start",variant:"caption",children:["Midifile is copyright © 1999-2018 Craig Stuart Sapp and is available under the"," ",Te.jsx("a",{href:"https://github.com/craigsapp/midifile",children:"BSD 2-Clause License"}),"."]}),Te.jsxs(oi,{textAlign:"start",variant:"caption",children:["The CMU Pronouncing Dictionary is copyright © 1993-2015 Carnegie Mellon University and available under the"," ",Te.jsx("a",{href:"http://svn.code.sf.net/p/cmusphinx/code/trunk/cmudict/",children:"BSD 2-Clause License"}),"."]})]})]}),T$=e=>typeof e=="boolean"||e instanceof Boolean,P$=e=>typeof e=="number"||e instanceof Number,M$=e=>typeof e=="bigint"||e instanceof BigInt,D7=e=>!!e&&e instanceof Date,C$=e=>typeof e=="string"||e instanceof String,L$=e=>Array.isArray(e),A$=e=>e instanceof Object&&e!==null;function R$(e){const[t,n]=Me.useState(e());return[t,()=>n(m=>!m),n]}let I$=1;const N$=()=>I$++;function k$(){const e=Me.useRef();return e.current===void 0&&(e.current=`:jsnvw:${N$()}:`),e.current}function V7(e){let{field:t,value:n,data:s,lastElement:m,openBracket:b,closeBracket:o,level:r,style:u,shouldExpandNode:a}=e;const g=Me.useRef(!1),[c,l,h]=R$(()=>a(r,n,t));Me.useEffect(()=>{g.current?h(a(r,n,t)):g.current=!0},[a]);const d=c?u.collapseIcon:u.expandIcon,S=c?"collapse JSON":"expand JSON",f=k$(),y=r+1,x=s.length-1,w=P=>{P.key===" "&&l()};return Me.createElement("div",{className:u.basicChildStyle,role:"list"},Me.createElement("span",{className:d,onClick:l,onKeyDown:w,role:"button",tabIndex:0,"aria-label":S,"aria-expanded":c,"aria-controls":c?f:void 0}),t&&Me.createElement("span",{className:u.label},t,":"),Me.createElement("span",{className:u.punctuation},b),c?Me.createElement("div",{id:f},s.map((P,_)=>Me.createElement(G7,{key:P[0]||_,field:P[0],value:P[1],style:u,lastElement:_===x,level:y,shouldExpandNode:a}))):Me.createElement("span",{className:u.collapsedContent,onClick:l,onKeyDown:w,role:"button",tabIndex:-1,"aria-hidden":!0,"aria-label":S,"aria-expanded":c}),Me.createElement("span",{className:u.punctuation},o),!m&&Me.createElement("span",{className:u.punctuation},","))}function O$(e){let{field:t,value:n,style:s,lastElement:m,shouldExpandNode:b,level:o}=e;return V7({field:t,value:n,lastElement:m||!1,level:o,openBracket:"{",closeBracket:"}",style:s,shouldExpandNode:b,data:Object.keys(n).map(r=>[r,n[r]])})}function F$(e){let{field:t,value:n,style:s,lastElement:m,level:b,shouldExpandNode:o}=e;return V7({field:t,value:n,lastElement:m||!1,level:b,openBracket:"[",closeBracket:"]",style:s,shouldExpandNode:o,data:n.map(r=>[void 0,r])})}function B$(e){let{field:t,value:n,style:s,lastElement:m}=e,b=n,o=s.otherValue;return n===null?(b="null",o=s.nullValue):n===void 0?(b="undefined",o=s.undefinedValue):C$(n)?(b=`"${n}"`,o=s.stringValue):T$(n)?(b=n?"true":"false",o=s.booleanValue):P$(n)?(b=n.toString(),o=s.numberValue):M$(n)?(b=`${n.toString()}n`,o=s.numberValue):D7(n)?b=n.toISOString():b=n.toString(),t===""&&(t='""'),Me.createElement("div",{className:s.basicChildStyle,role:"listitem"},t&&Me.createElement("span",{className:s.label},t,":"),Me.createElement("span",{className:o},b),!m&&Me.createElement("span",{className:s.punctuation},","))}function G7(e){const t=e.value;return L$(t)?Me.createElement(F$,Object.assign({},e)):A$(t)&&!D7(t)?Me.createElement(O$,Object.assign({},e)):Me.createElement(B$,Object.assign({},e))}var $n={"container-base":"_GzYRV","punctuation-base":"_3eOF8",pointer:"_1MFti","expander-base":"_f10Tu _1MFti","expand-icon":"_1UmXx","collapse-icon":"_1LId0","collapsed-content-base":"_1pNG9 _1MFti","container-light":"_2IvMF _GzYRV","basic-element-style":"_2bkNM","label-light":"_1MGIk","punctuation-light":"_3uHL6 _3eOF8","value-null-light":"_2T6PJ","value-undefined-light":"_1Gho6","value-string-light":"_vGjyY","value-number-light":"_1bQdo","value-boolean-light":"_3zQKs","value-other-light":"_1xvuR","collapse-icon-light":"_oLqym _f10Tu _1MFti _1LId0","expand-icon-light":"_2AXVT _f10Tu _1MFti _1UmXx","collapsed-content-light":"_2KJWg _1pNG9 _1MFti","container-dark":"_11RoI _GzYRV","expand-icon-dark":"_17H2C _f10Tu _1MFti _1UmXx","collapse-icon-dark":"_3QHg2 _f10Tu _1MFti _1LId0","collapsed-content-dark":"_3fDAz _1pNG9 _1MFti","label-dark":"_2bSDX","punctuation-dark":"_gsbQL _3eOF8","value-null-dark":"_LaAZe","value-undefined-dark":"_GTKgm","value-string-dark":"_Chy1W","value-number-dark":"_2bveF","value-boolean-dark":"_2vRm-","value-other-dark":"_1prJR"};const D$={container:$n["container-light"],basicChildStyle:$n["basic-element-style"],label:$n["label-light"],nullValue:$n["value-null-light"],undefinedValue:$n["value-undefined-light"],stringValue:$n["value-string-light"],booleanValue:$n["value-boolean-light"],numberValue:$n["value-number-light"],otherValue:$n["value-other-light"],punctuation:$n["punctuation-light"],collapseIcon:$n["collapse-icon-light"],expandIcon:$n["expand-icon-light"],collapsedContent:$n["collapsed-content-light"]},_5={container:$n["container-dark"],basicChildStyle:$n["basic-element-style"],label:$n["label-dark"],nullValue:$n["value-null-dark"],undefinedValue:$n["value-undefined-dark"],stringValue:$n["value-string-dark"],booleanValue:$n["value-boolean-dark"],numberValue:$n["value-number-dark"],otherValue:$n["value-other-dark"],punctuation:$n["punctuation-dark"],collapseIcon:$n["collapse-icon-dark"],expandIcon:$n["expand-icon-dark"],collapsedContent:$n["collapsed-content-dark"]},V$=()=>!0,T5=e=>e<1,P5=e=>{let{data:t,style:n=D$,shouldExpandNode:s=V$}=e;return Me.createElement("div",{className:n.container},Me.createElement(G7,{value:t,style:n,lastElement:!0,level:0,shouldExpandNode:s}))};function mp(e){return e<26?e+65:e<52?e+71:e<62?e-4:e===62?43:e===63?47:65}function G$(e){let t=2,n="";for(let s=e.length,m=0,b=0;b0&&b*4/3%76===0&&(n+=`\r `),m|=e[b]<<(16>>>t&24),(t===2||e.length-b===1)&&(n+=String.fromCharCode(mp(m>>>18&63),mp(m>>>12&63),mp(m>>>6&63),mp(m&63)),m=0);return n.substring(0,n.length-2+t)+(t===2?"":t===1?"=":"==")}const W$="voices/";var Ha=(e=>(e.air="air",e.cicada="cicada",e.quake="quake",e))(Ha||{});const Dp=ft.filter(Object.keys(Ha),e=>isNaN(Number(e))),z$=({audioOutput:e,lyricsEvents:t})=>{const n=dn.useCallback(s=>{if(!s)return;const m=s.addTextTrack("captions","Lyrics","en");m&&ft.forEach(t,(b,o)=>{var u;const r=t[o+1]?((u=t[o+1])==null?void 0:u.time)-b.time:3;b.lyric&&b.time!==void 0&&m.addCue(new VTTCue(b.time,b.time+r,b.lyric))})},[t]);return e?Te.jsx("audio",{controls:!0,src:e?"data:audio/wav;base64,"+G$(e):void 0,ref:n}):null};var $$=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,n=[],s=0;s"u"){n&&console.warn("unable to use e.clipboardData"),n&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var c=M5[t.format]||M5.default;window.clipboardData.setData(c,e)}else g.clipboardData.clearData(),g.clipboardData.setData(t.format,e);t.onCopy&&(g.preventDefault(),t.onCopy(g.clipboardData))}),document.body.appendChild(r),b.selectNodeContents(r),o.addRange(b);var a=document.execCommand("copy");if(!a)throw new Error("copy command was unsuccessful");u=!0}catch(g){n&&console.error("unable to copy using execCommand: ",g),n&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(t.format||"text",e),t.onCopy&&t.onCopy(window.clipboardData),u=!0}catch(c){n&&console.error("unable to copy using clipboardData: ",c),n&&console.error("falling back to prompt"),s=H$("message"in t?t.message:j$),window.prompt(s,e)}}finally{o&&(typeof o.removeRange=="function"?o.removeRange(b):o.removeAllRanges()),r&&document.body.removeChild(r),m()}return u}var Y$=X$;const K$=sb(Y$);function q$(e,t){var n=Me.useState(!1),s=n[0],m=n[1],b=t&&t.successDuration;return Me.useEffect(function(){if(s&&b){var o=setTimeout(function(){m(!1)},b);return function(){clearTimeout(o)}}},[s,b]),[s,function(){var o=K$(e);m(o)}]}var Yy={},Q$=Mo;Object.defineProperty(Yy,"__esModule",{value:!0});var W7=Yy.default=void 0,J$=Q$(Co()),Z$=Te;W7=Yy.default=(0,J$.default)((0,Z$.jsx)("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2m0 16H8V7h11z"}),"ContentCopy");var Ky={},eU=Mo;Object.defineProperty(Ky,"__esModule",{value:!0});var z7=Ky.default=void 0,tU=eU(Co()),nU=Te;z7=Ky.default=(0,tU.default)((0,nU.jsx)("path",{d:"M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"}),"Check");const rb=({text:e,successDuration:t=1e3})=>{const[n,s]=q$(e,{successDuration:t});return Te.jsx(fG,{title:n?"Copied!":"Copy",placement:"top",children:Te.jsx(Fk,{size:"small",onClick:m=>{m.stopPropagation(),s()},color:"primary",children:n?Te.jsx(z7,{}):Te.jsx(W7,{})})})},iU=({customVoiceForPart:e,splitIndex:t,setCustomVoicePerPart:n})=>{const s=dn.useCallback(m=>n(b=>(b[t]=m,[...b])),[n,t]);return Te.jsx(v7,{value:e??Ha.air,onChange:m=>s==null?void 0:s(m.target.value),children:ft.map(Dp,m=>Te.jsx(TV,{value:m,children:m},m))})};var qy={},rU=Mo;Object.defineProperty(qy,"__esModule",{value:!0});var $7=qy.default=void 0,sU=rU(Co()),oU=Te;$7=qy.default=(0,sU.default)((0,oU.jsx)("path",{d:"M4 7v2c0 .55-.45 1-1 1H2v4h1c.55 0 1 .45 1 1v2c0 1.65 1.35 3 3 3h3v-2H7c-.55 0-1-.45-1-1v-2c0-1.3-.84-2.42-2-2.83v-.34C5.16 11.42 6 10.3 6 9V7c0-.55.45-1 1-1h3V4H7C5.35 4 4 5.35 4 7m17 3c-.55 0-1-.45-1-1V7c0-1.65-1.35-3-3-3h-3v2h3c.55 0 1 .45 1 1v2c0 1.3.84 2.42 2 2.83v.34c-1.16.41-2 1.52-2 2.83v2c0 .55-.45 1-1 1h-3v2h3c1.65 0 3-1.35 3-3v-2c0-.55.45-1 1-1h1v-4z"}),"DataObject");var Qy={},aU=Mo;Object.defineProperty(Qy,"__esModule",{value:!0});var U7=Qy.default=void 0,lU=aU(Co()),uU=Te;U7=Qy.default=(0,lU.default)((0,uU.jsx)("path",{d:"M7 18h2V6H7zm4 4h2V2h-2zm-8-8h2v-4H3zm12 4h2V6h-2zm4-8v4h2v-4z"}),"GraphicEq");const cU=({output:e,splitParams:t,audioOutput:n})=>{const s=`${t.partName}${t.numVoices>1?`_(voice_${t.voice})`:""}${t.largestChordLvl>1?`_chord-level_${t.chordLevel}-${t.largestChordLvl}`:""}`;return Te.jsxs(Te.Fragment,{children:[Te.jsx(xn,{item:!0,children:Te.jsx(zS,{clickable:!0,color:"primary",label:"Download Audio (.wav)",component:"a",href:n?URL.createObjectURL(new Blob([n],{type:"audio/wav"})):void 0,download:s+".wav",icon:Te.jsx(U7,{}),sx:{"&:hover":{color:"grey.50"}}})}),Te.jsx(xn,{item:!0,children:Te.jsx(zS,{color:"secondary",label:"Download JSON",component:"a",href:`data:text/json;charset=utf-8,${encodeURIComponent(JSON.stringify(e,null,2))}`,download:s+".json",clickable:!0,icon:Te.jsx($7,{}),sx:{"&:hover":{color:"grey.50"}}})})]})},hU=({output:e,splitIndex:t,setOddVoiceOutputs:n})=>{const s=dn.useRef(e==null?void 0:e.lyrics);dn.useEffect(()=>{!s.current&&(e!=null&&e.lyrics)&&(s.current=e==null?void 0:e.lyrics)},[e==null?void 0:e.lyrics]);const[m,b]=dn.useState(!1),[o,r]=dn.useState(null),u=o??(e==null?void 0:e.lyrics)??s.current??"",a=dn.useCallback(g=>{g&&g!==(e==null?void 0:e.lyrics)&&n(c=>{const l=[...c];return l[t]=ft.cloneDeep(l[t]),l[t].output.lyrics=g,l}),r(null),b(!1)},[n,t,e==null?void 0:e.lyrics]);return Te.jsxs(xc,{children:[Te.jsx(_c,{expandIcon:Te.jsx(jl,{}),children:Te.jsxs(xn,{container:!0,direction:"row",justifyContent:"flex-start",alignItems:"center",gap:1,children:[Te.jsx(rb,{text:e==null?void 0:e.lyrics}),Te.jsx(oi,{variant:"subtitle2",children:"Lyrics"})]})}),Te.jsx(wc,{children:Te.jsx(xn,{container:!0,direction:"column",gap:1,children:m?Te.jsxs(Te.Fragment,{children:[Te.jsxs(xn,{item:!0,container:!0,direction:"row",justifyContent:"flex-start",alignItems:"center",gap:1,children:[Te.jsx(xu,{variant:"contained",onClick:()=>a(u),disabled:u===(e==null?void 0:e.lyrics),children:"Save"}),Te.jsx(xu,{variant:"contained",onClick:()=>b(!1),children:"Cancel"}),Te.jsx(xu,{variant:"contained",onClick:()=>{r(e==null?void 0:e.lyrics)},children:"Reset"})]}),Te.jsx(xn,{item:!0,children:Te.jsx(n7,{value:u,onChange:g=>r(g.target.value),style:{width:"100%"}})})]}):Te.jsxs(Te.Fragment,{children:[Te.jsxs(xn,{item:!0,container:!0,direction:"row",justifyContent:"flex-start",alignItems:"center",gap:1,children:[Te.jsx(xu,{variant:"contained",onClick:()=>b(!0),children:"Edit"}),Te.jsx(xu,{variant:"contained",onClick:()=>{s.current&&s.current!==e.lyrics&&a(s.current)},disabled:s.current===e.lyrics||!s.current,children:"Restore from generated"})]}),Te.jsx(xn,{item:!0,children:Te.jsx(oi,{variant:"body2",children:e.lyrics})})]})})})]})},dU=({customVoiceForPart:e,output:t,splitParams:n,audioOutput:s,splitIndex:m,debugInfo:b,lyricsEvents:o,setCustomVoicePerPart:r,setOddVoiceOutputs:u})=>Te.jsxs(xn,{item:!0,container:!0,direction:"column",children:[Te.jsxs(xn,{item:!0,container:!0,direction:"row",justifyContent:"flex-start",alignItems:"center",gap:2,pb:1,children:[Te.jsx(xn,{item:!0,children:Te.jsxs(oi,{variant:"subtitle1",children:["Part ",m+1]})}),Te.jsx(xn,{item:!0,children:Te.jsxs(oi,{variant:"h6",color:"primary",children:[n.partName,n.numVoices>1?` (voice ${n.voice})`:"",n.largestChordLvl>1?` - chord level ${n.chordLevel}/${n.largestChordLvl}`:""]})})]}),s?Te.jsxs(xn,{item:!0,container:!0,direction:"row",justifyContent:"flex-start",alignItems:"center",gap:1,children:[Te.jsx(xn,{item:!0,children:Te.jsx(z$,{audioOutput:s,lyricsEvents:o})}),Te.jsx(cU,{output:t,splitParams:n,audioOutput:s}),Te.jsx(xn,{item:!0,children:Te.jsx(iU,{customVoiceForPart:e,splitIndex:m,setCustomVoicePerPart:r})})]}):Te.jsxs(xn,{item:!0,container:!0,direction:"row",justifyContent:"flex-start",alignItems:"center",p:1,gap:3,children:[Te.jsx(Fp,{size:20}),Te.jsx(oi,{variant:"subtitle1",children:"Generating audio output..."})]}),Te.jsx(hU,{output:t,splitIndex:m,setOddVoiceOutputs:u}),Te.jsxs(xc,{children:[Te.jsx(_c,{expandIcon:Te.jsx(jl,{}),children:Te.jsxs(xn,{container:!0,direction:"row",justifyContent:"flex-start",alignItems:"center",gap:1,children:[Te.jsx(rb,{text:JSON.stringify(t.events,null,2)}),Te.jsx(oi,{variant:"subtitle2",children:"Events"})]})}),Te.jsx(wc,{children:Te.jsx(xn,{item:!0,justifyContent:"flex-start",children:Te.jsx(P5,{data:t.events,style:_5,shouldExpandNode:T5})})})]}),b&&Te.jsxs(xc,{children:[Te.jsx(_c,{expandIcon:Te.jsx(jl,{}),children:Te.jsxs(xn,{container:!0,direction:"row",justifyContent:"flex-start",alignItems:"center",gap:1,children:[Te.jsx(rb,{text:JSON.stringify(b,null,2)}),Te.jsx(oi,{variant:"subtitle2",children:"Debug Info"})]})}),Te.jsx(wc,{children:Te.jsx(xn,{item:!0,justifyContent:"flex-start",children:Te.jsx(P5,{data:b,style:_5,shouldExpandNode:T5})})})]})]});var fU=(()=>{var e=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(t={}){var n=t,s,m;n.ready=new Promise((N,V)=>{s=N,m=V}),["_memory","___indirect_function_table","onRuntimeInitialized"].forEach(N=>{Object.getOwnPropertyDescriptor(n.ready,N)||Object.defineProperty(n.ready,N,{get:()=>K("You are getting "+N+" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js"),set:()=>K("You are setting "+N+" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")})}),n.expectedDataFileDownloads||(n.expectedDataFileDownloads=0),n.expectedDataFileDownloads++,function(){if(!(n.ENVIRONMENT_IS_PTHREAD||n.$ww)){var N=function(V){typeof window=="object"?window.encodeURIComponent(window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/"):typeof process>"u"&&typeof location<"u"&&encodeURIComponent(location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/");var Q="../../../public/oddvoices_wasm.data",oe="oddvoices_wasm.data";typeof n.locateFilePackage=="function"&&!n.locateFile&&(n.locateFile=n.locateFilePackage,y("warning: you defined Module.locateFilePackage, that has been renamed to Module.locateFile (using your locateFilePackage for now)"));var Ee=n.locateFile?n.locateFile(oe,""):oe,Ie=V.remote_package_size;function Be(ot,St,xt,_t){var wt=new XMLHttpRequest;wt.open("GET",ot,!0),wt.responseType="arraybuffer",wt.onprogress=function(Wt){var qt=ot,En=St;if(Wt.total&&(En=Wt.total),Wt.loaded){wt.addedTotal?n.dataFileDownloads[qt].loaded=Wt.loaded:(wt.addedTotal=!0,n.dataFileDownloads||(n.dataFileDownloads={}),n.dataFileDownloads[qt]={loaded:Wt.loaded,total:En});var ut=0,Rt=0,zn=0;for(var Pn in n.dataFileDownloads){var _i=n.dataFileDownloads[Pn];ut+=_i.total,Rt+=_i.loaded,zn++}ut=Math.ceil(ut*n.expectedDataFileDownloads/zn),n.setStatus&&n.setStatus(`Downloading data... (${Rt}/${ut})`)}else n.dataFileDownloads||n.setStatus&&n.setStatus("Downloading data...")},wt.onerror=function(Wt){throw new Error("NetworkError for: "+ot)},wt.onload=function(Wt){if(wt.status==200||wt.status==304||wt.status==206||wt.status==0&&wt.response){var qt=wt.response;xt(qt)}else throw new Error(wt.statusText+" : "+wt.responseURL)},wt.send(null)}var Ve=null,et=n.getPreloadedPackage?n.getPreloadedPackage(Ee,Ie):null;et||Be(Ee,Ie,function(ot){Ve?(Ve(ot),Ve=null):et=ot});function st(){function ot(Wt,qt){if(!Wt)throw qt+new Error().stack}n.FS_createPath("/","oddvoices",!0,!0);function St(Wt,qt,En){this.start=Wt,this.end=qt,this.audio=En}St.prototype={requests:{},open:function(Wt,qt){this.name=qt,this.requests[qt]=this,n.addRunDependency(`fp ${this.name}`)},send:function(){},onload:function(){var Wt=this.byteArray.subarray(this.start,this.end);this.finish(Wt)},finish:function(Wt){var qt=this;n.FS_createDataFile(this.name,null,Wt,!0,!0,!0),n.removeRunDependency(`fp ${qt.name}`),this.requests[this.name]=null}};for(var xt=V.files,_t=0;_t{var V=new XMLHttpRequest;return V.open("GET",N,!1),V.send(null),V.responseText},S=(N,V,Q)=>{var oe=new XMLHttpRequest;oe.open("GET",N,!0),oe.responseType="arraybuffer",oe.onload=()=>{if(oe.status==200||oe.status==0&&oe.response){V(oe.response);return}Q()},oe.onerror=Q,oe.send(null)}}var f=n.print||console.log.bind(console),y=n.printErr||console.error.bind(console);Object.assign(n,o),o=null,Yt(),n.arguments&&n.arguments,je("arguments","arguments_"),n.thisProgram&&(r=n.thisProgram),je("thisProgram","thisProgram"),n.quit&&n.quit,je("quit","quit_"),_(typeof n.memoryInitializerPrefixURL>"u","Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"),_(typeof n.pthreadMainPrefixURL>"u","Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead"),_(typeof n.cdInitializerPrefixURL>"u","Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead"),_(typeof n.filePackagePrefixURL>"u","Module.filePackagePrefixURL option was removed, use Module.locateFile instead"),_(typeof n.read>"u","Module.read option was removed (modify read_ in JS)"),_(typeof n.readAsync>"u","Module.readAsync option was removed (modify readAsync in JS)"),_(typeof n.readBinary>"u","Module.readBinary option was removed (modify readBinary in JS)"),_(typeof n.setWindowTitle>"u","Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)"),_(typeof n.TOTAL_MEMORY>"u","Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY"),je("asm","wasmExports"),je("read","read_"),je("readAsync","readAsync"),je("readBinary","readBinary"),je("setWindowTitle","setWindowTitle"),_(!a,"worker environment detected but not enabled at build time. Add 'worker' to `-sENVIRONMENT` to enable."),_(!g,"node environment detected but not enabled at build time. Add 'node' to `-sENVIRONMENT` to enable."),_(!c,"shell environment detected but not enabled at build time. Add 'shell' to `-sENVIRONMENT` to enable.");var x;n.wasmBinary&&(x=n.wasmBinary),je("wasmBinary","wasmBinary"),typeof WebAssembly!="object"&&K("no native wasm support detected");var w,P=!1;function _(N,V){N||K("Assertion failed"+(V?": "+V:""))}var E,M,R,I,L,F,W,Y;function k(){var N=w.buffer;n.HEAP8=E=new Int8Array(N),n.HEAP16=R=new Int16Array(N),n.HEAPU8=M=new Uint8Array(N),n.HEAPU16=I=new Uint16Array(N),n.HEAP32=L=new Int32Array(N),n.HEAPU32=F=new Uint32Array(N),n.HEAPF32=W=new Float32Array(N),n.HEAPF64=Y=new Float64Array(N)}_(!n.STACK_SIZE,"STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time"),_(typeof Int32Array<"u"&&typeof Float64Array<"u"&&Int32Array.prototype.subarray!=null&&Int32Array.prototype.set!=null,"JS engine does not provide full typed array support"),_(!n.wasmMemory,"Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally"),_(!n.INITIAL_MEMORY,"Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically");function z(){var N=qc();_((N&3)==0),N==0&&(N+=4),F[N>>2]=34821223,F[N+4>>2]=2310721022,F[0]=1668509029}function G(){if(!P){var N=qc();N==0&&(N+=4);var V=F[N>>2],Q=F[N+4>>2];(V!=34821223||Q!=2310721022)&&K(`Stack overflow! Stack cookie has been overwritten at ${bt(N)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${bt(Q)} ${bt(V)}`),F[0]!=1668509029&&K("Runtime error: The application has corrupted its heap memory area (address zero)!")}}(function(){var N=new Int16Array(1),V=new Int8Array(N.buffer);if(N[0]=25459,V[0]!==115||V[1]!==99)throw"Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)"})();var X=[],A=[],U=[],ie=!1;function re(){if(n.preRun)for(typeof n.preRun=="function"&&(n.preRun=[n.preRun]);n.preRun.length;)me(n.preRun.shift());rt(X)}function ge(){_(!ie),ie=!0,G(),!n.noFSInit&&!fe.init.initialized&&fe.init(),fe.ignorePermissions=!1,rt(A)}function ae(){if(G(),n.postRun)for(typeof n.postRun=="function"&&(n.postRun=[n.postRun]);n.postRun.length;)Z(n.postRun.shift());rt(U)}function me(N){X.unshift(N)}function ue(N){A.unshift(N)}function Z(N){U.unshift(N)}_(Math.imul,"This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),_(Math.fround,"This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),_(Math.clz32,"This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),_(Math.trunc,"This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill");var be=0,ve=null,H=null,ee={};function ne(N){for(var V=N;;){if(!ee[N])return N;N=V+Math.random()}}function O(N){var V;be++,(V=n.monitorRunDependencies)==null||V.call(n,be),N?(_(!ee[N]),ee[N]=1,ve===null&&typeof setInterval<"u"&&(ve=setInterval(()=>{if(P){clearInterval(ve),ve=null;return}var Q=!1;for(var oe in ee)Q||(Q=!0,y("still waiting on run dependencies:")),y(`dependency: ${oe}`);Q&&y("(end of list)")},1e4))):y("warning: run dependency added without ID")}function $(N){var Q;if(be--,(Q=n.monitorRunDependencies)==null||Q.call(n,be),N?(_(ee[N]),delete ee[N]):y("warning: run dependency removed without ID"),be==0&&(ve!==null&&(clearInterval(ve),ve=null),H)){var V=H;H=null,V()}}function K(N){var Q;(Q=n.onAbort)==null||Q.call(n,N),N="Aborted("+N+")",y(N),P=!0;var V=new WebAssembly.RuntimeError(N);throw m(V),V}var q="data:application/octet-stream;base64,",de=N=>N.startsWith(q),ce=N=>N.startsWith("file://");function le(N){return function(){_(ie,`native function \`${N}\` called before runtime initialization`);var V=Vn[N];return _(V,`exported native function \`${N}\` not found`),V.apply(null,arguments)}}var ye;ye="oddvoices_wasm.wasm",de(ye)||(ye=h(ye));function we(N){if(N==ye&&x)return new Uint8Array(x);throw"both async and sync fetching of the wasm failed"}function Ae(N){return!x&&u&&typeof fetch=="function"?fetch(N,{credentials:"same-origin"}).then(V=>{if(!V.ok)throw"failed to load wasm binary file at '"+N+"'";return V.arrayBuffer()}).catch(()=>we(N)):Promise.resolve().then(()=>we(N))}function We(N,V,Q){return Ae(N).then(oe=>WebAssembly.instantiate(oe,V)).then(oe=>oe).then(Q,oe=>{y(`failed to asynchronously prepare wasm: ${oe}`),ce(ye)&&y(`warning: Loading from a file URI (${ye}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`),K(oe)})}function De(N,V,Q,oe){return!N&&typeof WebAssembly.instantiateStreaming=="function"&&!de(V)&&typeof fetch=="function"?fetch(V,{credentials:"same-origin"}).then(Ee=>{var Ie=WebAssembly.instantiateStreaming(Ee,Q);return Ie.then(oe,function(Be){return y(`wasm streaming compile failed: ${Be}`),y("falling back to ArrayBuffer instantiation"),We(V,Q,oe)})}):We(V,Q,oe)}function Je(){var N={env:vn,wasi_snapshot_preview1:vn};function V(Ee,Ie){return Vn=Ee.exports,w=Vn.memory,_(w,"memory not found in wasm exports"),k(),Bs=Vn.__indirect_function_table,_(Bs,"table not found in wasm exports"),ue(Vn.__wasm_call_ctors),$("wasm-instantiate"),Vn}O("wasm-instantiate");var Q=n;function oe(Ee){_(n===Q,"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?"),Q=null,V(Ee.instance)}if(n.instantiateWasm)try{return n.instantiateWasm(N,V)}catch(Ee){y(`Module.instantiateWasm callback failed with error: ${Ee}`),m(Ee)}return De(x,ye,N,oe).catch(m),{}}var ke,ze;function je(N,V,Q=!0){Object.getOwnPropertyDescriptor(n,N)||Object.defineProperty(n,N,{configurable:!0,get(){let oe=Q?" (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)":"";K(`\`Module.${N}\` has been replaced by \`${V}\``+oe)}})}function Xe(N){Object.getOwnPropertyDescriptor(n,N)&&K(`\`Module.${N}\` was supplied but \`${N}\` not included in INCOMING_MODULE_JS_API`)}function Qe(N){return N==="FS_createPath"||N==="FS_createDataFile"||N==="FS_createPreloadedFile"||N==="FS_unlink"||N==="addRunDependency"||N==="FS_createLazyFile"||N==="FS_createDevice"||N==="removeRunDependency"}function nt(N,V){typeof globalThis<"u"&&Object.defineProperty(globalThis,N,{configurable:!0,get(){ct(`\`${N}\` is not longer defined by emscripten. ${V}`)}})}nt("buffer","Please use HEAP8.buffer or wasmMemory.buffer"),nt("asm","Please use wasmExports instead");function ht(N){typeof globalThis<"u"&&!Object.getOwnPropertyDescriptor(globalThis,N)&&Object.defineProperty(globalThis,N,{configurable:!0,get(){var V=`\`${N}\` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line`,Q=N;Q.startsWith("_")||(Q="$"+N),V+=` (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE='${Q}')`,Qe(N)&&(V+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),ct(V)}}),yt(N)}function yt(N){Object.getOwnPropertyDescriptor(n,N)||Object.defineProperty(n,N,{configurable:!0,get(){var V=`'${N}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;Qe(N)&&(V+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),K(V)}})}var rt=N=>{for(;N.length>0;)N.shift()(n)};n.noExitRuntime;var bt=N=>(_(typeof N=="number"),N>>>=0,"0x"+N.toString(16).padStart(8,"0")),ct=N=>{ct.shown||(ct.shown={}),ct.shown[N]||(ct.shown[N]=1,y(N))},vt=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Ct=(N,V,Q)=>{for(var oe=V+Q,Ee=V;N[Ee]&&!(Ee>=oe);)++Ee;if(Ee-V>16&&N.buffer&&vt)return vt.decode(N.subarray(V,Ee));for(var Ie="";V>10,56320|st&1023)}}return Ie},Kt=(N,V)=>(_(typeof N=="number",`UTF8ToString expects a number (got ${typeof N})`),N?Ct(M,N,V):""),ei=(N,V,Q,oe)=>{K(`Assertion failed: ${Kt(N)}, at: `+[V?Kt(V):"unknown filename",Q,oe?Kt(oe):"unknown function"])};class jn{constructor(V){this.excPtr=V,this.ptr=V-24}set_type(V){F[this.ptr+4>>2]=V}get_type(){return F[this.ptr+4>>2]}set_destructor(V){F[this.ptr+8>>2]=V}get_destructor(){return F[this.ptr+8>>2]}set_caught(V){V=V?1:0,E[this.ptr+12>>0]=V}get_caught(){return E[this.ptr+12>>0]!=0}set_rethrown(V){V=V?1:0,E[this.ptr+13>>0]=V}get_rethrown(){return E[this.ptr+13>>0]!=0}init(V,Q){this.set_adjusted_ptr(0),this.set_type(V),this.set_destructor(Q)}set_adjusted_ptr(V){F[this.ptr+16>>2]=V}get_adjusted_ptr(){return F[this.ptr+16>>2]}get_exception_ptr(){var V=Cn(this.get_type());if(V)return F[this.excPtr>>2];var Q=this.get_adjusted_ptr();return Q!==0?Q:this.excPtr}}var hr=(N,V,Q)=>{var oe=new jn(N);oe.init(V,Q),_(!1,"Exception thrown, but exception catching is not enabled. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch.")},Nt={isAbs:N=>N.charAt(0)==="/",splitPath:N=>{var V=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return V.exec(N).slice(1)},normalizeArray:(N,V)=>{for(var Q=0,oe=N.length-1;oe>=0;oe--){var Ee=N[oe];Ee==="."?N.splice(oe,1):Ee===".."?(N.splice(oe,1),Q++):Q&&(N.splice(oe,1),Q--)}if(V)for(;Q;Q--)N.unshift("..");return N},normalize:N=>{var V=Nt.isAbs(N),Q=N.substr(-1)==="/";return N=Nt.normalizeArray(N.split("/").filter(oe=>!!oe),!V).join("/"),!N&&!V&&(N="."),N&&Q&&(N+="/"),(V?"/":"")+N},dirname:N=>{var V=Nt.splitPath(N),Q=V[0],oe=V[1];return!Q&&!oe?".":(oe&&(oe=oe.substr(0,oe.length-1)),Q+oe)},basename:N=>{if(N==="/")return"/";N=Nt.normalize(N),N=N.replace(/\/$/,"");var V=N.lastIndexOf("/");return V===-1?N:N.substr(V+1)},join:function(){var N=Array.prototype.slice.call(arguments);return Nt.normalize(N.join("/"))},join2:(N,V)=>Nt.normalize(N+"/"+V)},Bn=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return N=>crypto.getRandomValues(N);K("no cryptographic support found for randomDevice. consider polyfilling it if you want to use something insecure like Math.random(), e.g. put this in a --pre-js: var crypto = { getRandomValues: (array) => { for (var i = 0; i < array.length; i++) array[i] = (Math.random()*256)|0 } };")},an=N=>(an=Bn())(N),Xt={resolve:function(){for(var N="",V=!1,Q=arguments.length-1;Q>=-1&&!V;Q--){var oe=Q>=0?arguments[Q]:fe.cwd();if(typeof oe!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!oe)return"";N=oe+"/"+N,V=Nt.isAbs(oe)}return N=Nt.normalizeArray(N.split("/").filter(Ee=>!!Ee),!V).join("/"),(V?"/":"")+N||"."},relative:(N,V)=>{N=Xt.resolve(N).substr(1),V=Xt.resolve(V).substr(1);function Q(st){for(var ot=0;ot=0&&st[St]==="";St--);return ot>St?[]:st.slice(ot,St-ot+1)}for(var oe=Q(N.split("/")),Ee=Q(V.split("/")),Ie=Math.min(oe.length,Ee.length),Be=Ie,Ve=0;Ve{for(var V=0,Q=0;Q=55296&&oe<=57343?(V+=4,++Q):V+=3}return V},Hn=(N,V,Q,oe)=>{if(_(typeof N=="string",`stringToUTF8Array expects a string (got ${typeof N})`),!(oe>0))return 0;for(var Ee=Q,Ie=Q+oe-1,Be=0;Be=55296&&Ve<=57343){var et=N.charCodeAt(++Be);Ve=65536+((Ve&1023)<<10)|et&1023}if(Ve<=127){if(Q>=Ie)break;V[Q++]=Ve}else if(Ve<=2047){if(Q+1>=Ie)break;V[Q++]=192|Ve>>6,V[Q++]=128|Ve&63}else if(Ve<=65535){if(Q+2>=Ie)break;V[Q++]=224|Ve>>12,V[Q++]=128|Ve>>6&63,V[Q++]=128|Ve&63}else{if(Q+3>=Ie)break;Ve>1114111&&ct("Invalid Unicode code point "+bt(Ve)+" encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF)."),V[Q++]=240|Ve>>18,V[Q++]=128|Ve>>12&63,V[Q++]=128|Ve>>6&63,V[Q++]=128|Ve&63}}return V[Q]=0,Q-Ee};function Ai(N,V,Q){var oe=Q>0?Q:Nn(N)+1,Ee=new Array(oe),Ie=Hn(N,Ee,0,Ee.length);return V&&(Ee.length=Ie),Ee}var dr=()=>{if(!Wn.length){var N=null;if(typeof window<"u"&&typeof window.prompt=="function"?(N=window.prompt("Input: "),N!==null&&(N+=` `)):typeof readline=="function"&&(N=readline(),N!==null&&(N+=` `)),!N)return null;Wn=Ai(N,!0)}return Wn.shift()},Xn={ttys:[],init(){},shutdown(){},register(N,V){Xn.ttys[N]={input:[],output:[],ops:V},fe.registerDevice(N,Xn.stream_ops)},stream_ops:{open(N){var V=Xn.ttys[N.node.rdev];if(!V)throw new fe.ErrnoError(43);N.tty=V,N.seekable=!1},close(N){N.tty.ops.fsync(N.tty)},fsync(N){N.tty.ops.fsync(N.tty)},read(N,V,Q,oe,Ee){if(!N.tty||!N.tty.ops.get_char)throw new fe.ErrnoError(60);for(var Ie=0,Be=0;Be0&&(f(Ct(N.output,0)),N.output=[])},ioctl_tcgets(N){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(N,V,Q){return 0},ioctl_tiocgwinsz(N){return[24,80]}},default_tty1_ops:{put_char(N,V){V===null||V===10?(y(Ct(N.output,0)),N.output=[]):V!=0&&N.output.push(V)},fsync(N){N.output&&N.output.length>0&&(y(Ct(N.output,0)),N.output=[])}}},rs=N=>{K("internal error: mmapAlloc called but `emscripten_builtin_memalign` native symbol not exported")},Vt={ops_table:null,mount(N){return Vt.createNode(null,"/",16895,0)},createNode(N,V,Q,oe){if(fe.isBlkdev(Q)||fe.isFIFO(Q))throw new fe.ErrnoError(63);Vt.ops_table||(Vt.ops_table={dir:{node:{getattr:Vt.node_ops.getattr,setattr:Vt.node_ops.setattr,lookup:Vt.node_ops.lookup,mknod:Vt.node_ops.mknod,rename:Vt.node_ops.rename,unlink:Vt.node_ops.unlink,rmdir:Vt.node_ops.rmdir,readdir:Vt.node_ops.readdir,symlink:Vt.node_ops.symlink},stream:{llseek:Vt.stream_ops.llseek}},file:{node:{getattr:Vt.node_ops.getattr,setattr:Vt.node_ops.setattr},stream:{llseek:Vt.stream_ops.llseek,read:Vt.stream_ops.read,write:Vt.stream_ops.write,allocate:Vt.stream_ops.allocate,mmap:Vt.stream_ops.mmap,msync:Vt.stream_ops.msync}},link:{node:{getattr:Vt.node_ops.getattr,setattr:Vt.node_ops.setattr,readlink:Vt.node_ops.readlink},stream:{}},chrdev:{node:{getattr:Vt.node_ops.getattr,setattr:Vt.node_ops.setattr},stream:fe.chrdev_stream_ops}});var Ee=fe.createNode(N,V,Q,oe);return fe.isDir(Ee.mode)?(Ee.node_ops=Vt.ops_table.dir.node,Ee.stream_ops=Vt.ops_table.dir.stream,Ee.contents={}):fe.isFile(Ee.mode)?(Ee.node_ops=Vt.ops_table.file.node,Ee.stream_ops=Vt.ops_table.file.stream,Ee.usedBytes=0,Ee.contents=null):fe.isLink(Ee.mode)?(Ee.node_ops=Vt.ops_table.link.node,Ee.stream_ops=Vt.ops_table.link.stream):fe.isChrdev(Ee.mode)&&(Ee.node_ops=Vt.ops_table.chrdev.node,Ee.stream_ops=Vt.ops_table.chrdev.stream),Ee.timestamp=Date.now(),N&&(N.contents[V]=Ee,N.timestamp=Ee.timestamp),Ee},getFileDataAsTypedArray(N){return N.contents?N.contents.subarray?N.contents.subarray(0,N.usedBytes):new Uint8Array(N.contents):new Uint8Array(0)},expandFileStorage(N,V){var Q=N.contents?N.contents.length:0;if(!(Q>=V)){var oe=1024*1024;V=Math.max(V,Q*(Q>>0),Q!=0&&(V=Math.max(V,256));var Ee=N.contents;N.contents=new Uint8Array(V),N.usedBytes>0&&N.contents.set(Ee.subarray(0,N.usedBytes),0)}},resizeFileStorage(N,V){if(N.usedBytes!=V)if(V==0)N.contents=null,N.usedBytes=0;else{var Q=N.contents;N.contents=new Uint8Array(V),Q&&N.contents.set(Q.subarray(0,Math.min(V,N.usedBytes))),N.usedBytes=V}},node_ops:{getattr(N){var V={};return V.dev=fe.isChrdev(N.mode)?N.id:1,V.ino=N.id,V.mode=N.mode,V.nlink=1,V.uid=0,V.gid=0,V.rdev=N.rdev,fe.isDir(N.mode)?V.size=4096:fe.isFile(N.mode)?V.size=N.usedBytes:fe.isLink(N.mode)?V.size=N.link.length:V.size=0,V.atime=new Date(N.timestamp),V.mtime=new Date(N.timestamp),V.ctime=new Date(N.timestamp),V.blksize=4096,V.blocks=Math.ceil(V.size/V.blksize),V},setattr(N,V){V.mode!==void 0&&(N.mode=V.mode),V.timestamp!==void 0&&(N.timestamp=V.timestamp),V.size!==void 0&&Vt.resizeFileStorage(N,V.size)},lookup(N,V){throw fe.genericErrors[44]},mknod(N,V,Q,oe){return Vt.createNode(N,V,Q,oe)},rename(N,V,Q){if(fe.isDir(N.mode)){var oe;try{oe=fe.lookupNode(V,Q)}catch{}if(oe)for(var Ee in oe.contents)throw new fe.ErrnoError(55)}delete N.parent.contents[N.name],N.parent.timestamp=Date.now(),N.name=Q,V.contents[Q]=N,V.timestamp=N.parent.timestamp,N.parent=V},unlink(N,V){delete N.contents[V],N.timestamp=Date.now()},rmdir(N,V){var Q=fe.lookupNode(N,V);for(var oe in Q.contents)throw new fe.ErrnoError(55);delete N.contents[V],N.timestamp=Date.now()},readdir(N){var V=[".",".."];for(var Q of Object.keys(N.contents))V.push(Q);return V},symlink(N,V,Q){var oe=Vt.createNode(N,V,41471,0);return oe.link=Q,oe},readlink(N){if(!fe.isLink(N.mode))throw new fe.ErrnoError(28);return N.link}},stream_ops:{read(N,V,Q,oe,Ee){var Ie=N.node.contents;if(Ee>=N.node.usedBytes)return 0;var Be=Math.min(N.node.usedBytes-Ee,oe);if(_(Be>=0),Be>8&&Ie.subarray)V.set(Ie.subarray(Ee,Ee+Be),Q);else for(var Ve=0;Ve0||Q+V{var Ee=oe?"":ne(`al ${N}`);S(N,Ie=>{_(Ie,`Loading data file "${N}" failed (no arrayBuffer).`),V(new Uint8Array(Ie)),Ee&&$(Ee)},Ie=>{if(Q)Q();else throw`Loading data file "${N}" failed.`}),Ee&&O(Ee)},Ri=(N,V,Q,oe,Ee,Ie)=>{fe.createDataFile(N,V,Q,oe,Ee,Ie)},Si=n.preloadPlugins||[],Br=(N,V,Q,oe)=>{typeof Browser<"u"&&Browser.init();var Ee=!1;return Si.forEach(Ie=>{Ee||Ie.canHandle(V)&&(Ie.handle(N,V,Q,oe),Ee=!0)}),Ee},Dr=(N,V,Q,oe,Ee,Ie,Be,Ve,et,st)=>{var ot=V?Xt.resolve(Nt.join2(N,V)):N,St=ne(`cp ${ot}`);function xt(_t){function wt(Wt){st==null||st(),Ve||Ri(N,V,Wt,oe,Ee,et),Ie==null||Ie(),$(St)}Br(_t,ot,wt,()=>{Be==null||Be(),$(St)})||wt(_t)}O(St),typeof Q=="string"?Zs(Q,xt,Be):xt(Q)},ss=N=>{var V={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},Q=V[N];if(typeof Q>"u")throw new Error(`Unknown file open mode: ${N}`);return Q},fr=(N,V)=>{var Q=0;return N&&(Q|=365),V&&(Q|=146),Q},Ii={0:"Success",1:"Arg list too long",2:"Permission denied",3:"Address already in use",4:"Address not available",5:"Address family not supported by protocol family",6:"No more processes",7:"Socket already connected",8:"Bad file number",9:"Trying to read unreadable message",10:"Mount device busy",11:"Operation canceled",12:"No children",13:"Connection aborted",14:"Connection refused",15:"Connection reset by peer",16:"File locking deadlock error",17:"Destination address required",18:"Math arg out of domain of func",19:"Quota exceeded",20:"File exists",21:"Bad address",22:"File too large",23:"Host is unreachable",24:"Identifier removed",25:"Illegal byte sequence",26:"Connection already in progress",27:"Interrupted system call",28:"Invalid argument",29:"I/O error",30:"Socket is already connected",31:"Is a directory",32:"Too many symbolic links",33:"Too many open files",34:"Too many links",35:"Message too long",36:"Multihop attempted",37:"File or path name too long",38:"Network interface is not configured",39:"Connection reset by network",40:"Network is unreachable",41:"Too many open files in system",42:"No buffer space available",43:"No such device",44:"No such file or directory",45:"Exec format error",46:"No record locks available",47:"The link has been severed",48:"Not enough core",49:"No message of desired type",50:"Protocol not available",51:"No space left on device",52:"Function not implemented",53:"Socket is not connected",54:"Not a directory",55:"Directory not empty",56:"State not recoverable",57:"Socket operation on non-socket",59:"Not a typewriter",60:"No such device or address",61:"Value too large for defined data type",62:"Previous owner died",63:"Not super-user",64:"Broken pipe",65:"Protocol error",66:"Unknown protocol",67:"Protocol wrong type for socket",68:"Math result not representable",69:"Read only file system",70:"Illegal seek",71:"No such process",72:"Stale file handle",73:"Connection timed out",74:"Text file busy",75:"Cross-device link",100:"Device not a stream",101:"Bad font file fmt",102:"Invalid slot",103:"Invalid request code",104:"No anode",105:"Block device required",106:"Channel number out of range",107:"Level 3 halted",108:"Level 3 reset",109:"Link number out of range",110:"Protocol driver not attached",111:"No CSI structure available",112:"Level 2 halted",113:"Invalid exchange",114:"Invalid request descriptor",115:"Exchange full",116:"No data (for no delay io)",117:"Timer expired",118:"Out of streams resources",119:"Machine is not on the network",120:"Package not installed",121:"The object is remote",122:"Advertise error",123:"Srmount error",124:"Communication error on send",125:"Cross mount point (not really error)",126:"Given log. name not unique",127:"f.d. invalid for this operation",128:"Remote address changed",129:"Can access a needed shared lib",130:"Accessing a corrupted shared lib",131:".lib section in a.out corrupted",132:"Attempting to link in too many libs",133:"Attempting to exec a shared library",135:"Streams pipe error",136:"Too many users",137:"Socket type not supported",138:"Not supported",139:"Protocol family not supported",140:"Can't send after socket shutdown",141:"Too many references",142:"Host is down",148:"No medium (in tape drive)",156:"Level 2 not synchronized"},Is={EPERM:63,ENOENT:44,ESRCH:71,EINTR:27,EIO:29,ENXIO:60,E2BIG:1,ENOEXEC:45,EBADF:8,ECHILD:12,EAGAIN:6,EWOULDBLOCK:6,ENOMEM:48,EACCES:2,EFAULT:21,ENOTBLK:105,EBUSY:10,EEXIST:20,EXDEV:75,ENODEV:43,ENOTDIR:54,EISDIR:31,EINVAL:28,ENFILE:41,EMFILE:33,ENOTTY:59,ETXTBSY:74,EFBIG:22,ENOSPC:51,ESPIPE:70,EROFS:69,EMLINK:34,EPIPE:64,EDOM:18,ERANGE:68,ENOMSG:49,EIDRM:24,ECHRNG:106,EL2NSYNC:156,EL3HLT:107,EL3RST:108,ELNRNG:109,EUNATCH:110,ENOCSI:111,EL2HLT:112,EDEADLK:16,ENOLCK:46,EBADE:113,EBADR:114,EXFULL:115,ENOANO:104,EBADRQC:103,EBADSLT:102,EDEADLOCK:16,EBFONT:101,ENOSTR:100,ENODATA:116,ETIME:117,ENOSR:118,ENONET:119,ENOPKG:120,EREMOTE:121,ENOLINK:47,EADV:122,ESRMNT:123,ECOMM:124,EPROTO:65,EMULTIHOP:36,EDOTDOT:125,EBADMSG:9,ENOTUNIQ:126,EBADFD:127,EREMCHG:128,ELIBACC:129,ELIBBAD:130,ELIBSCN:131,ELIBMAX:132,ELIBEXEC:133,ENOSYS:52,ENOTEMPTY:55,ENAMETOOLONG:37,ELOOP:32,EOPNOTSUPP:138,EPFNOSUPPORT:139,ECONNRESET:15,ENOBUFS:42,EAFNOSUPPORT:5,EPROTOTYPE:67,ENOTSOCK:57,ENOPROTOOPT:50,ESHUTDOWN:140,ECONNREFUSED:14,EADDRINUSE:3,ECONNABORTED:13,ENETUNREACH:40,ENETDOWN:38,ETIMEDOUT:73,EHOSTDOWN:142,EHOSTUNREACH:23,EINPROGRESS:26,EALREADY:7,EDESTADDRREQ:17,EMSGSIZE:35,EPROTONOSUPPORT:66,ESOCKTNOSUPPORT:137,EADDRNOTAVAIL:4,ENETRESET:39,EISCONN:30,ENOTCONN:53,ETOOMANYREFS:141,EUSERS:136,EDQUOT:19,ESTALE:72,ENOTSUP:138,ENOMEDIUM:148,EILSEQ:25,EOVERFLOW:61,ECANCELED:11,ENOTRECOVERABLE:56,EOWNERDEAD:62,ESTRPIPE:135},Vr=N=>(ct("warning: build with -sDEMANGLE_SUPPORT to link in libcxxabi demangling"),N),sa=N=>{var V=/\b_Z[\w\d_]+/g;return N.replace(V,function(Q){var oe=Vr(Q);return Q===oe?Q:oe+" ["+Q+"]"})},fe={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath(N,V={}){if(N=Xt.resolve(N),!N)return{path:"",node:null};var Q={follow_mount:!0,recurse_count:0};if(V=Object.assign(Q,V),V.recurse_count>8)throw new fe.ErrnoError(32);for(var oe=N.split("/").filter(St=>!!St),Ee=fe.root,Ie="/",Be=0;Be40)throw new fe.ErrnoError(32)}}return{path:Ie,node:Ee}},getPath(N){for(var V;;){if(fe.isRoot(N)){var Q=N.mount.mountpoint;return V?Q[Q.length-1]!=="/"?`${Q}/${V}`:Q+V:Q}V=V?`${N.name}/${V}`:N.name,N=N.parent}},hashName(N,V){for(var Q=0,oe=0;oe>>0)%fe.nameTable.length},hashAddNode(N){var V=fe.hashName(N.parent.id,N.name);N.name_next=fe.nameTable[V],fe.nameTable[V]=N},hashRemoveNode(N){var V=fe.hashName(N.parent.id,N.name);if(fe.nameTable[V]===N)fe.nameTable[V]=N.name_next;else for(var Q=fe.nameTable[V];Q;){if(Q.name_next===N){Q.name_next=N.name_next;break}Q=Q.name_next}},lookupNode(N,V){var Q=fe.mayLookup(N);if(Q)throw new fe.ErrnoError(Q,N);for(var oe=fe.hashName(N.id,V),Ee=fe.nameTable[oe];Ee;Ee=Ee.name_next){var Ie=Ee.name;if(Ee.parent.id===N.id&&Ie===V)return Ee}return fe.lookup(N,V)},createNode(N,V,Q,oe){_(typeof N=="object");var Ee=new fe.FSNode(N,V,Q,oe);return fe.hashAddNode(Ee),Ee},destroyNode(N){fe.hashRemoveNode(N)},isRoot(N){return N===N.parent},isMountpoint(N){return!!N.mounted},isFile(N){return(N&61440)===32768},isDir(N){return(N&61440)===16384},isLink(N){return(N&61440)===40960},isChrdev(N){return(N&61440)===8192},isBlkdev(N){return(N&61440)===24576},isFIFO(N){return(N&61440)===4096},isSocket(N){return(N&49152)===49152},flagsToPermissionString(N){var V=["r","w","rw"][N&3];return N&512&&(V+="w"),V},nodePermissions(N,V){return fe.ignorePermissions?0:V.includes("r")&&!(N.mode&292)||V.includes("w")&&!(N.mode&146)||V.includes("x")&&!(N.mode&73)?2:0},mayLookup(N){var V=fe.nodePermissions(N,"x");return V||(N.node_ops.lookup?0:2)},mayCreate(N,V){try{var Q=fe.lookupNode(N,V);return 20}catch{}return fe.nodePermissions(N,"wx")},mayDelete(N,V,Q){var oe;try{oe=fe.lookupNode(N,V)}catch(Ie){return Ie.errno}var Ee=fe.nodePermissions(N,"wx");if(Ee)return Ee;if(Q){if(!fe.isDir(oe.mode))return 54;if(fe.isRoot(oe)||fe.getPath(oe)===fe.cwd())return 10}else if(fe.isDir(oe.mode))return 31;return 0},mayOpen(N,V){return N?fe.isLink(N.mode)?32:fe.isDir(N.mode)&&(fe.flagsToPermissionString(V)!=="r"||V&512)?31:fe.nodePermissions(N,fe.flagsToPermissionString(V)):44},MAX_OPEN_FDS:4096,nextfd(){for(var N=0;N<=fe.MAX_OPEN_FDS;N++)if(!fe.streams[N])return N;throw new fe.ErrnoError(33)},getStreamChecked(N){var V=fe.getStream(N);if(!V)throw new fe.ErrnoError(8);return V},getStream:N=>fe.streams[N],createStream(N,V=-1){return fe.FSStream||(fe.FSStream=function(){this.shared={}},fe.FSStream.prototype={},Object.defineProperties(fe.FSStream.prototype,{object:{get(){return this.node},set(Q){this.node=Q}},isRead:{get(){return(this.flags&2097155)!==1}},isWrite:{get(){return(this.flags&2097155)!==0}},isAppend:{get(){return this.flags&1024}},flags:{get(){return this.shared.flags},set(Q){this.shared.flags=Q}},position:{get(){return this.shared.position},set(Q){this.shared.position=Q}}})),N=Object.assign(new fe.FSStream,N),V==-1&&(V=fe.nextfd()),N.fd=V,fe.streams[V]=N,N},closeStream(N){fe.streams[N]=null},chrdev_stream_ops:{open(N){var Q,oe;var V=fe.getDevice(N.node.rdev);N.stream_ops=V.stream_ops,(oe=(Q=N.stream_ops).open)==null||oe.call(Q,N)},llseek(){throw new fe.ErrnoError(70)}},major:N=>N>>8,minor:N=>N&255,makedev:(N,V)=>N<<8|V,registerDevice(N,V){fe.devices[N]={stream_ops:V}},getDevice:N=>fe.devices[N],getMounts(N){for(var V=[],Q=[N];Q.length;){var oe=Q.pop();V.push(oe),Q.push.apply(Q,oe.mounts)}return V},syncfs(N,V){typeof N=="function"&&(V=N,N=!1),fe.syncFSRequests++,fe.syncFSRequests>1&&y(`warning: ${fe.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var Q=fe.getMounts(fe.root.mount),oe=0;function Ee(Be){return _(fe.syncFSRequests>0),fe.syncFSRequests--,V(Be)}function Ie(Be){if(Be)return Ie.errored?void 0:(Ie.errored=!0,Ee(Be));++oe>=Q.length&&Ee(null)}Q.forEach(Be=>{if(!Be.type.syncfs)return Ie(null);Be.type.syncfs(Be,N,Ie)})},mount(N,V,Q){if(typeof N=="string")throw N;var oe=Q==="/",Ee=!Q,Ie;if(oe&&fe.root)throw new fe.ErrnoError(10);if(!oe&&!Ee){var Be=fe.lookupPath(Q,{follow_mount:!1});if(Q=Be.path,Ie=Be.node,fe.isMountpoint(Ie))throw new fe.ErrnoError(10);if(!fe.isDir(Ie.mode))throw new fe.ErrnoError(54)}var Ve={type:N,opts:V,mountpoint:Q,mounts:[]},et=N.mount(Ve);return et.mount=Ve,Ve.root=et,oe?fe.root=et:Ie&&(Ie.mounted=Ve,Ie.mount&&Ie.mount.mounts.push(Ve)),et},unmount(N){var V=fe.lookupPath(N,{follow_mount:!1});if(!fe.isMountpoint(V.node))throw new fe.ErrnoError(28);var Q=V.node,oe=Q.mounted,Ee=fe.getMounts(oe);Object.keys(fe.nameTable).forEach(Be=>{for(var Ve=fe.nameTable[Be];Ve;){var et=Ve.name_next;Ee.includes(Ve.mount)&&fe.destroyNode(Ve),Ve=et}}),Q.mounted=null;var Ie=Q.mount.mounts.indexOf(oe);_(Ie!==-1),Q.mount.mounts.splice(Ie,1)},lookup(N,V){return N.node_ops.lookup(N,V)},mknod(N,V,Q){var oe=fe.lookupPath(N,{parent:!0}),Ee=oe.node,Ie=Nt.basename(N);if(!Ie||Ie==="."||Ie==="..")throw new fe.ErrnoError(28);var Be=fe.mayCreate(Ee,Ie);if(Be)throw new fe.ErrnoError(Be);if(!Ee.node_ops.mknod)throw new fe.ErrnoError(63);return Ee.node_ops.mknod(Ee,Ie,V,Q)},create(N,V){return V=V!==void 0?V:438,V&=4095,V|=32768,fe.mknod(N,V,0)},mkdir(N,V){return V=V!==void 0?V:511,V&=1023,V|=16384,fe.mknod(N,V,0)},mkdirTree(N,V){for(var Q=N.split("/"),oe="",Ee=0;Ee"u"&&(Q=V,V=438),V|=8192,fe.mknod(N,V,Q)},symlink(N,V){if(!Xt.resolve(N))throw new fe.ErrnoError(44);var Q=fe.lookupPath(V,{parent:!0}),oe=Q.node;if(!oe)throw new fe.ErrnoError(44);var Ee=Nt.basename(V),Ie=fe.mayCreate(oe,Ee);if(Ie)throw new fe.ErrnoError(Ie);if(!oe.node_ops.symlink)throw new fe.ErrnoError(63);return oe.node_ops.symlink(oe,Ee,N)},rename(N,V){var Q=Nt.dirname(N),oe=Nt.dirname(V),Ee=Nt.basename(N),Ie=Nt.basename(V),Be,Ve,et;if(Be=fe.lookupPath(N,{parent:!0}),Ve=Be.node,Be=fe.lookupPath(V,{parent:!0}),et=Be.node,!Ve||!et)throw new fe.ErrnoError(44);if(Ve.mount!==et.mount)throw new fe.ErrnoError(75);var st=fe.lookupNode(Ve,Ee),ot=Xt.relative(N,oe);if(ot.charAt(0)!==".")throw new fe.ErrnoError(28);if(ot=Xt.relative(V,Q),ot.charAt(0)!==".")throw new fe.ErrnoError(55);var St;try{St=fe.lookupNode(et,Ie)}catch{}if(st!==St){var xt=fe.isDir(st.mode),_t=fe.mayDelete(Ve,Ee,xt);if(_t)throw new fe.ErrnoError(_t);if(_t=St?fe.mayDelete(et,Ie,xt):fe.mayCreate(et,Ie),_t)throw new fe.ErrnoError(_t);if(!Ve.node_ops.rename)throw new fe.ErrnoError(63);if(fe.isMountpoint(st)||St&&fe.isMountpoint(St))throw new fe.ErrnoError(10);if(et!==Ve&&(_t=fe.nodePermissions(Ve,"w"),_t))throw new fe.ErrnoError(_t);fe.hashRemoveNode(st);try{Ve.node_ops.rename(st,et,Ie)}catch(wt){throw wt}finally{fe.hashAddNode(st)}}},rmdir(N){var V=fe.lookupPath(N,{parent:!0}),Q=V.node,oe=Nt.basename(N),Ee=fe.lookupNode(Q,oe),Ie=fe.mayDelete(Q,oe,!0);if(Ie)throw new fe.ErrnoError(Ie);if(!Q.node_ops.rmdir)throw new fe.ErrnoError(63);if(fe.isMountpoint(Ee))throw new fe.ErrnoError(10);Q.node_ops.rmdir(Q,oe),fe.destroyNode(Ee)},readdir(N){var V=fe.lookupPath(N,{follow:!0}),Q=V.node;if(!Q.node_ops.readdir)throw new fe.ErrnoError(54);return Q.node_ops.readdir(Q)},unlink(N){var V=fe.lookupPath(N,{parent:!0}),Q=V.node;if(!Q)throw new fe.ErrnoError(44);var oe=Nt.basename(N),Ee=fe.lookupNode(Q,oe),Ie=fe.mayDelete(Q,oe,!1);if(Ie)throw new fe.ErrnoError(Ie);if(!Q.node_ops.unlink)throw new fe.ErrnoError(63);if(fe.isMountpoint(Ee))throw new fe.ErrnoError(10);Q.node_ops.unlink(Q,oe),fe.destroyNode(Ee)},readlink(N){var V=fe.lookupPath(N),Q=V.node;if(!Q)throw new fe.ErrnoError(44);if(!Q.node_ops.readlink)throw new fe.ErrnoError(28);return Xt.resolve(fe.getPath(Q.parent),Q.node_ops.readlink(Q))},stat(N,V){var Q=fe.lookupPath(N,{follow:!V}),oe=Q.node;if(!oe)throw new fe.ErrnoError(44);if(!oe.node_ops.getattr)throw new fe.ErrnoError(63);return oe.node_ops.getattr(oe)},lstat(N){return fe.stat(N,!0)},chmod(N,V,Q){var oe;if(typeof N=="string"){var Ee=fe.lookupPath(N,{follow:!Q});oe=Ee.node}else oe=N;if(!oe.node_ops.setattr)throw new fe.ErrnoError(63);oe.node_ops.setattr(oe,{mode:V&4095|oe.mode&-4096,timestamp:Date.now()})},lchmod(N,V){fe.chmod(N,V,!0)},fchmod(N,V){var Q=fe.getStreamChecked(N);fe.chmod(Q.node,V)},chown(N,V,Q,oe){var Ee;if(typeof N=="string"){var Ie=fe.lookupPath(N,{follow:!oe});Ee=Ie.node}else Ee=N;if(!Ee.node_ops.setattr)throw new fe.ErrnoError(63);Ee.node_ops.setattr(Ee,{timestamp:Date.now()})},lchown(N,V,Q){fe.chown(N,V,Q,!0)},fchown(N,V,Q){var oe=fe.getStreamChecked(N);fe.chown(oe.node,V,Q)},truncate(N,V){if(V<0)throw new fe.ErrnoError(28);var Q;if(typeof N=="string"){var oe=fe.lookupPath(N,{follow:!0});Q=oe.node}else Q=N;if(!Q.node_ops.setattr)throw new fe.ErrnoError(63);if(fe.isDir(Q.mode))throw new fe.ErrnoError(31);if(!fe.isFile(Q.mode))throw new fe.ErrnoError(28);var Ee=fe.nodePermissions(Q,"w");if(Ee)throw new fe.ErrnoError(Ee);Q.node_ops.setattr(Q,{size:V,timestamp:Date.now()})},ftruncate(N,V){var Q=fe.getStreamChecked(N);if(!(Q.flags&2097155))throw new fe.ErrnoError(28);fe.truncate(Q.node,V)},utime(N,V,Q){var oe=fe.lookupPath(N,{follow:!0}),Ee=oe.node;Ee.node_ops.setattr(Ee,{timestamp:Math.max(V,Q)})},open(N,V,Q){if(N==="")throw new fe.ErrnoError(44);V=typeof V=="string"?ss(V):V,Q=typeof Q>"u"?438:Q,V&64?Q=Q&4095|32768:Q=0;var oe;if(typeof N=="object")oe=N;else{N=Nt.normalize(N);try{var Ee=fe.lookupPath(N,{follow:!(V&131072)});oe=Ee.node}catch{}}var Ie=!1;if(V&64)if(oe){if(V&128)throw new fe.ErrnoError(20)}else oe=fe.mknod(N,Q,0),Ie=!0;if(!oe)throw new fe.ErrnoError(44);if(fe.isChrdev(oe.mode)&&(V&=-513),V&65536&&!fe.isDir(oe.mode))throw new fe.ErrnoError(54);if(!Ie){var Be=fe.mayOpen(oe,V);if(Be)throw new fe.ErrnoError(Be)}V&512&&!Ie&&fe.truncate(oe,0),V&=-131713;var Ve=fe.createStream({node:oe,path:fe.getPath(oe),flags:V,seekable:!0,position:0,stream_ops:oe.stream_ops,ungotten:[],error:!1});return Ve.stream_ops.open&&Ve.stream_ops.open(Ve),n.logReadFiles&&!(V&1)&&(fe.readFiles||(fe.readFiles={}),N in fe.readFiles||(fe.readFiles[N]=1)),Ve},close(N){if(fe.isClosed(N))throw new fe.ErrnoError(8);N.getdents&&(N.getdents=null);try{N.stream_ops.close&&N.stream_ops.close(N)}catch(V){throw V}finally{fe.closeStream(N.fd)}N.fd=null},isClosed(N){return N.fd===null},llseek(N,V,Q){if(fe.isClosed(N))throw new fe.ErrnoError(8);if(!N.seekable||!N.stream_ops.llseek)throw new fe.ErrnoError(70);if(Q!=0&&Q!=1&&Q!=2)throw new fe.ErrnoError(28);return N.position=N.stream_ops.llseek(N,V,Q),N.ungotten=[],N.position},read(N,V,Q,oe,Ee){if(_(Q>=0),oe<0||Ee<0)throw new fe.ErrnoError(28);if(fe.isClosed(N))throw new fe.ErrnoError(8);if((N.flags&2097155)===1)throw new fe.ErrnoError(8);if(fe.isDir(N.node.mode))throw new fe.ErrnoError(31);if(!N.stream_ops.read)throw new fe.ErrnoError(28);var Ie=typeof Ee<"u";if(!Ie)Ee=N.position;else if(!N.seekable)throw new fe.ErrnoError(70);var Be=N.stream_ops.read(N,V,Q,oe,Ee);return Ie||(N.position+=Be),Be},write(N,V,Q,oe,Ee,Ie){if(_(Q>=0),oe<0||Ee<0)throw new fe.ErrnoError(28);if(fe.isClosed(N))throw new fe.ErrnoError(8);if(!(N.flags&2097155))throw new fe.ErrnoError(8);if(fe.isDir(N.node.mode))throw new fe.ErrnoError(31);if(!N.stream_ops.write)throw new fe.ErrnoError(28);N.seekable&&N.flags&1024&&fe.llseek(N,0,2);var Be=typeof Ee<"u";if(!Be)Ee=N.position;else if(!N.seekable)throw new fe.ErrnoError(70);var Ve=N.stream_ops.write(N,V,Q,oe,Ee,Ie);return Be||(N.position+=Ve),Ve},allocate(N,V,Q){if(fe.isClosed(N))throw new fe.ErrnoError(8);if(V<0||Q<=0)throw new fe.ErrnoError(28);if(!(N.flags&2097155))throw new fe.ErrnoError(8);if(!fe.isFile(N.node.mode)&&!fe.isDir(N.node.mode))throw new fe.ErrnoError(43);if(!N.stream_ops.allocate)throw new fe.ErrnoError(138);N.stream_ops.allocate(N,V,Q)},mmap(N,V,Q,oe,Ee){if(oe&2&&!(Ee&2)&&(N.flags&2097155)!==2)throw new fe.ErrnoError(2);if((N.flags&2097155)===1)throw new fe.ErrnoError(2);if(!N.stream_ops.mmap)throw new fe.ErrnoError(43);return N.stream_ops.mmap(N,V,Q,oe,Ee)},msync(N,V,Q,oe,Ee){return _(Q>=0),N.stream_ops.msync?N.stream_ops.msync(N,V,Q,oe,Ee):0},munmap:N=>0,ioctl(N,V,Q){if(!N.stream_ops.ioctl)throw new fe.ErrnoError(59);return N.stream_ops.ioctl(N,V,Q)},readFile(N,V={}){if(V.flags=V.flags||0,V.encoding=V.encoding||"binary",V.encoding!=="utf8"&&V.encoding!=="binary")throw new Error(`Invalid encoding type "${V.encoding}"`);var Q,oe=fe.open(N,V.flags),Ee=fe.stat(N),Ie=Ee.size,Be=new Uint8Array(Ie);return fe.read(oe,Be,0,Ie,0),V.encoding==="utf8"?Q=Ct(Be,0):V.encoding==="binary"&&(Q=Be),fe.close(oe),Q},writeFile(N,V,Q={}){Q.flags=Q.flags||577;var oe=fe.open(N,Q.flags,Q.mode);if(typeof V=="string"){var Ee=new Uint8Array(Nn(V)+1),Ie=Hn(V,Ee,0,Ee.length);fe.write(oe,Ee,0,Ie,void 0,Q.canOwn)}else if(ArrayBuffer.isView(V))fe.write(oe,V,0,V.byteLength,void 0,Q.canOwn);else throw new Error("Unsupported data type");fe.close(oe)},cwd:()=>fe.currentPath,chdir(N){var V=fe.lookupPath(N,{follow:!0});if(V.node===null)throw new fe.ErrnoError(44);if(!fe.isDir(V.node.mode))throw new fe.ErrnoError(54);var Q=fe.nodePermissions(V.node,"x");if(Q)throw new fe.ErrnoError(Q);fe.currentPath=V.path},createDefaultDirectories(){fe.mkdir("/tmp"),fe.mkdir("/home"),fe.mkdir("/home/web_user")},createDefaultDevices(){fe.mkdir("/dev"),fe.registerDevice(fe.makedev(1,3),{read:()=>0,write:(oe,Ee,Ie,Be,Ve)=>Be}),fe.mkdev("/dev/null",fe.makedev(1,3)),Xn.register(fe.makedev(5,0),Xn.default_tty_ops),Xn.register(fe.makedev(6,0),Xn.default_tty1_ops),fe.mkdev("/dev/tty",fe.makedev(5,0)),fe.mkdev("/dev/tty1",fe.makedev(6,0));var N=new Uint8Array(1024),V=0,Q=()=>(V===0&&(V=an(N).byteLength),N[--V]);fe.createDevice("/dev","random",Q),fe.createDevice("/dev","urandom",Q),fe.mkdir("/dev/shm"),fe.mkdir("/dev/shm/tmp")},createSpecialDirectories(){fe.mkdir("/proc");var N=fe.mkdir("/proc/self");fe.mkdir("/proc/self/fd"),fe.mount({mount(){var V=fe.createNode(N,"fd",16895,73);return V.node_ops={lookup(Q,oe){var Ee=+oe,Ie=fe.getStreamChecked(Ee),Be={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>Ie.path}};return Be.parent=Be,Be}},V}},{},"/proc/self/fd")},createStandardStreams(){n.stdin?fe.createDevice("/dev","stdin",n.stdin):fe.symlink("/dev/tty","/dev/stdin"),n.stdout?fe.createDevice("/dev","stdout",null,n.stdout):fe.symlink("/dev/tty","/dev/stdout"),n.stderr?fe.createDevice("/dev","stderr",null,n.stderr):fe.symlink("/dev/tty1","/dev/stderr");var N=fe.open("/dev/stdin",0),V=fe.open("/dev/stdout",1),Q=fe.open("/dev/stderr",1);_(N.fd===0,`invalid handle for stdin (${N.fd})`),_(V.fd===1,`invalid handle for stdout (${V.fd})`),_(Q.fd===2,`invalid handle for stderr (${Q.fd})`)},ensureErrnoError(){fe.ErrnoError||(fe.ErrnoError=function(V,Q){this.name="ErrnoError",this.node=Q,this.setErrno=function(oe){this.errno=oe;for(var Ee in Is)if(Is[Ee]===oe){this.code=Ee;break}},this.setErrno(V),this.message=Ii[V],this.stack&&(Object.defineProperty(this,"stack",{value:new Error().stack,writable:!0}),this.stack=sa(this.stack))},fe.ErrnoError.prototype=new Error,fe.ErrnoError.prototype.constructor=fe.ErrnoError,[44].forEach(N=>{fe.genericErrors[N]=new fe.ErrnoError(N),fe.genericErrors[N].stack=""}))},staticInit(){fe.ensureErrnoError(),fe.nameTable=new Array(4096),fe.mount(Vt,{},"/"),fe.createDefaultDirectories(),fe.createDefaultDevices(),fe.createSpecialDirectories(),fe.filesystems={MEMFS:Vt}},init(N,V,Q){_(!fe.init.initialized,"FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)"),fe.init.initialized=!0,fe.ensureErrnoError(),n.stdin=N||n.stdin,n.stdout=V||n.stdout,n.stderr=Q||n.stderr,fe.createStandardStreams()},quit(){fe.init.initialized=!1,xr(0);for(var N=0;Nthis.length-1||_t<0)){var wt=_t%this.chunkSize,Wt=_t/this.chunkSize|0;return this.getter(Wt)[wt]}},Ie.prototype.setDataGetter=function(_t){this.getter=_t},Ie.prototype.cacheLength=function(){var _t=new XMLHttpRequest;if(_t.open("HEAD",Q,!1),_t.send(null),!(_t.status>=200&&_t.status<300||_t.status===304))throw new Error("Couldn't load "+Q+". Status: "+_t.status);var wt=Number(_t.getResponseHeader("Content-length")),Wt,qt=(Wt=_t.getResponseHeader("Accept-Ranges"))&&Wt==="bytes",En=(Wt=_t.getResponseHeader("Content-Encoding"))&&Wt==="gzip",ut=1024*1024;qt||(ut=wt);var Rt=(Pn,_i)=>{if(Pn>_i)throw new Error("invalid range ("+Pn+", "+_i+") or no bytes requested!");if(_i>wt-1)throw new Error("only "+wt+" bytes available! programmer error!");var Zt=new XMLHttpRequest;if(Zt.open("GET",Q,!1),wt!==ut&&Zt.setRequestHeader("Range","bytes="+Pn+"-"+_i),Zt.responseType="arraybuffer",Zt.overrideMimeType&&Zt.overrideMimeType("text/plain; charset=x-user-defined"),Zt.send(null),!(Zt.status>=200&&Zt.status<300||Zt.status===304))throw new Error("Couldn't load "+Q+". Status: "+Zt.status);return Zt.response!==void 0?new Uint8Array(Zt.response||[]):Ai(Zt.responseText||"",!0)},zn=this;zn.setDataGetter(Pn=>{var _i=Pn*ut,Zt=(Pn+1)*ut-1;if(Zt=Math.min(Zt,wt-1),typeof zn.chunks[Pn]>"u"&&(zn.chunks[Pn]=Rt(_i,Zt)),typeof zn.chunks[Pn]>"u")throw new Error("doXHR failed!");return zn.chunks[Pn]}),(En||!wt)&&(ut=wt=1,wt=this.getter(0).length,ut=wt,f("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=wt,this._chunkSize=ut,this.lengthKnown=!0},typeof XMLHttpRequest<"u"){throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var Be,Ve}else var Ve={isDevice:!1,url:Q};var et=fe.createFile(N,V,Ve,oe,Ee);Ve.contents?et.contents=Ve.contents:Ve.url&&(et.contents=null,et.url=Ve.url),Object.defineProperties(et,{usedBytes:{get:function(){return this.contents.length}}});var st={},ot=Object.keys(et.stream_ops);ot.forEach(xt=>{var _t=et.stream_ops[xt];st[xt]=function(){return fe.forceLoadFile(et),_t.apply(null,arguments)}});function St(xt,_t,wt,Wt,qt){var En=xt.node.contents;if(qt>=En.length)return 0;var ut=Math.min(En.length-qt,Wt);if(_(ut>=0),En.slice)for(var Rt=0;Rt(fe.forceLoadFile(et),St(xt,_t,wt,Wt,qt)),st.mmap=(xt,_t,wt,Wt,qt)=>{fe.forceLoadFile(et);var En=rs();if(!En)throw new fe.ErrnoError(48);return St(xt,E,En,_t,wt),{ptr:En,allocated:!0}},et.stream_ops=st,et},absolutePath(){K("FS.absolutePath has been removed; use PATH_FS.resolve instead")},createFolder(){K("FS.createFolder has been removed; use FS.mkdir instead")},createLink(){K("FS.createLink has been removed; use FS.symlink instead")},joinPath(){K("FS.joinPath has been removed; use PATH.join instead")},mmapAlloc(){K("FS.mmapAlloc has been replaced by the top level function mmapAlloc")},standardizePath(){K("FS.standardizePath has been removed; use PATH.normalize instead")}},Sn={DEFAULT_POLLMASK:5,calculateAt(N,V,Q){if(Nt.isAbs(V))return V;var oe;if(N===-100)oe=fe.cwd();else{var Ee=Sn.getStreamFromFD(N);oe=Ee.path}if(V.length==0){if(!Q)throw new fe.ErrnoError(44);return oe}return Nt.join2(oe,V)},doStat(N,V,Q){try{var oe=N(V)}catch(Ve){if(Ve&&Ve.node&&Nt.normalize(V)!==Nt.normalize(fe.getPath(Ve.node)))return-54;throw Ve}L[Q>>2]=oe.dev,L[Q+4>>2]=oe.mode,F[Q+8>>2]=oe.nlink,L[Q+12>>2]=oe.uid,L[Q+16>>2]=oe.gid,L[Q+20>>2]=oe.rdev,ze=[oe.size>>>0,(ke=oe.size,+Math.abs(ke)>=1?ke>0?+Math.floor(ke/4294967296)>>>0:~~+Math.ceil((ke-+(~~ke>>>0))/4294967296)>>>0:0)],L[Q+24>>2]=ze[0],L[Q+28>>2]=ze[1],L[Q+32>>2]=4096,L[Q+36>>2]=oe.blocks;var Ee=oe.atime.getTime(),Ie=oe.mtime.getTime(),Be=oe.ctime.getTime();return ze=[Math.floor(Ee/1e3)>>>0,(ke=Math.floor(Ee/1e3),+Math.abs(ke)>=1?ke>0?+Math.floor(ke/4294967296)>>>0:~~+Math.ceil((ke-+(~~ke>>>0))/4294967296)>>>0:0)],L[Q+40>>2]=ze[0],L[Q+44>>2]=ze[1],F[Q+48>>2]=Ee%1e3*1e3,ze=[Math.floor(Ie/1e3)>>>0,(ke=Math.floor(Ie/1e3),+Math.abs(ke)>=1?ke>0?+Math.floor(ke/4294967296)>>>0:~~+Math.ceil((ke-+(~~ke>>>0))/4294967296)>>>0:0)],L[Q+56>>2]=ze[0],L[Q+60>>2]=ze[1],F[Q+64>>2]=Ie%1e3*1e3,ze=[Math.floor(Be/1e3)>>>0,(ke=Math.floor(Be/1e3),+Math.abs(ke)>=1?ke>0?+Math.floor(ke/4294967296)>>>0:~~+Math.ceil((ke-+(~~ke>>>0))/4294967296)>>>0:0)],L[Q+72>>2]=ze[0],L[Q+76>>2]=ze[1],F[Q+80>>2]=Be%1e3*1e3,ze=[oe.ino>>>0,(ke=oe.ino,+Math.abs(ke)>=1?ke>0?+Math.floor(ke/4294967296)>>>0:~~+Math.ceil((ke-+(~~ke>>>0))/4294967296)>>>0:0)],L[Q+88>>2]=ze[0],L[Q+92>>2]=ze[1],0},doMsync(N,V,Q,oe,Ee){if(!fe.isFile(V.node.mode))throw new fe.ErrnoError(43);if(oe&2)return 0;var Ie=M.slice(N,N+Q);fe.msync(V,Ie,Ee,Q,oe)},varargs:void 0,get(){_(Sn.varargs!=null);var N=L[+Sn.varargs>>2];return Sn.varargs+=4,N},getp(){return Sn.get()},getStr(N){var V=Kt(N);return V},getStreamFromFD(N){var V=fe.getStreamChecked(N);return V}};function Jt(N,V,Q){Sn.varargs=Q;try{var oe=Sn.getStreamFromFD(N);switch(V){case 0:{var Ee=Sn.get();if(Ee<0)return-28;for(;fe.streams[Ee];)Ee++;var Ie;return Ie=fe.createStream(oe,Ee),Ie.fd}case 1:case 2:return 0;case 3:return oe.flags;case 4:{var Ee=Sn.get();return oe.flags|=Ee,0}case 12:{var Ee=Sn.getp(),Be=0;return R[Ee+Be>>1]=2,0}case 13:case 14:return 0}return-28}catch(Ve){if(typeof fe>"u"||Ve.name!=="ErrnoError")throw Ve;return-Ve.errno}}function Gt(N,V,Q){Sn.varargs=Q;try{var oe=Sn.getStreamFromFD(N);switch(V){case 21509:return oe.tty?0:-59;case 21505:{if(!oe.tty)return-59;if(oe.tty.ops.ioctl_tcgets){var Ee=oe.tty.ops.ioctl_tcgets(oe),Ie=Sn.getp();L[Ie>>2]=Ee.c_iflag||0,L[Ie+4>>2]=Ee.c_oflag||0,L[Ie+8>>2]=Ee.c_cflag||0,L[Ie+12>>2]=Ee.c_lflag||0;for(var Be=0;Be<32;Be++)E[Ie+Be+17>>0]=Ee.c_cc[Be]||0;return 0}return 0}case 21510:case 21511:case 21512:return oe.tty?0:-59;case 21506:case 21507:case 21508:{if(!oe.tty)return-59;if(oe.tty.ops.ioctl_tcsets){for(var Ie=Sn.getp(),Ve=L[Ie>>2],et=L[Ie+4>>2],st=L[Ie+8>>2],ot=L[Ie+12>>2],St=[],Be=0;Be<32;Be++)St.push(E[Ie+Be+17>>0]);return oe.tty.ops.ioctl_tcsets(oe.tty,V,{c_iflag:Ve,c_oflag:et,c_cflag:st,c_lflag:ot,c_cc:St})}return 0}case 21519:{if(!oe.tty)return-59;var Ie=Sn.getp();return L[Ie>>2]=0,0}case 21520:return oe.tty?-28:-59;case 21531:{var Ie=Sn.getp();return fe.ioctl(oe,V,Ie)}case 21523:{if(!oe.tty)return-59;if(oe.tty.ops.ioctl_tiocgwinsz){var xt=oe.tty.ops.ioctl_tiocgwinsz(oe.tty),Ie=Sn.getp();R[Ie>>1]=xt[0],R[Ie+2>>1]=xt[1]}return 0}case 21524:return oe.tty?0:-59;case 21515:return oe.tty?0:-59;default:return-28}}catch(_t){if(typeof fe>"u"||_t.name!=="ErrnoError")throw _t;return-_t.errno}}function Yn(N,V,Q,oe){Sn.varargs=oe;try{V=Sn.getStr(V),V=Sn.calculateAt(N,V);var Ee=oe?Sn.get():0;return fe.open(V,Q,Ee).fd}catch(Ie){if(typeof fe>"u"||Ie.name!=="ErrnoError")throw Ie;return-Ie.errno}}var Yl=(N,V,Q,oe,Ee)=>{},pr=()=>{for(var N=new Array(256),V=0;V<256;++V)N[V]=String.fromCharCode(V);oa=N},oa,Vi=N=>{for(var V="",Q=N;M[Q];)V+=oa[M[Q++]];return V},Gr={},mr={},Ni={},Ns,pn=N=>{throw new Ns(N)},Kl,aa=N=>{throw new Kl(N)},eo=(N,V,Q)=>{N.forEach(function(Ve){Ni[Ve]=V});function oe(Ve){var et=Q(Ve);et.length!==N.length&&aa("Mismatched type converter count");for(var st=0;st{mr.hasOwnProperty(Ve)?Ee[et]=mr[Ve]:(Ie.push(Ve),Gr.hasOwnProperty(Ve)||(Gr[Ve]=[]),Gr[Ve].push(()=>{Ee[et]=mr[Ve],++Be,Be===Ie.length&&oe(Ee)}))}),Ie.length===0&&oe(Ee)};function la(N,V,Q={}){var oe=V.name;if(N||pn(`type "${oe}" must have a positive integer typeid pointer`),mr.hasOwnProperty(N)){if(Q.ignoreDuplicateRegistrations)return;pn(`Cannot register type '${oe}' twice`)}if(mr[N]=V,delete Ni[N],Gr.hasOwnProperty(N)){var Ee=Gr[N];delete Gr[N],Ee.forEach(Ie=>Ie())}}function gr(N,V,Q={}){if(!("argPackAdvance"in V))throw new TypeError("registerType registeredInstance requires argPackAdvance");return la(N,V,Q)}var bn=8,ks=(N,V,Q,oe)=>{V=Vi(V),gr(N,{name:V,fromWireType:function(Ee){return!!Ee},toWireType:function(Ee,Ie){return Ie?Q:oe},argPackAdvance:bn,readValueFromPointer:function(Ee){return this.fromWireType(M[Ee])},destructorFunction:null})},ql=N=>({count:N.count,deleteScheduled:N.deleteScheduled,preservePointerOnDelete:N.preservePointerOnDelete,ptr:N.ptr,ptrType:N.ptrType,smartPtr:N.smartPtr,smartPtrType:N.smartPtrType}),Lo=N=>{function V(Q){return Q.$$.ptrType.registeredClass.name}pn(V(N)+" instance already deleted")},to=!1,Oe=N=>{},i=N=>{N.smartPtr?N.smartPtrType.rawDestructor(N.smartPtr):N.ptrType.registeredClass.rawDestructor(N.ptr)},v=N=>{N.count.value-=1;var V=N.count.value===0;V&&i(N)},C=(N,V,Q)=>{if(V===Q)return N;if(Q.baseClass===void 0)return null;var oe=C(N,V,Q.baseClass);return oe===null?null:Q.downcast(oe)},D={},j=()=>Object.keys(Ne).length,J=()=>{var N=[];for(var V in Ne)Ne.hasOwnProperty(V)&&N.push(Ne[V]);return N},se=[],he=()=>{for(;se.length;){var N=se.pop();N.$$.deleteScheduled=!1,N.delete()}},Se,_e=N=>{Se=N,se.length&&Se&&Se(he)},Ce=()=>{n.getInheritedInstanceCount=j,n.getLiveInheritedInstances=J,n.flushPendingDeletes=he,n.setDelayFunction=_e},Ne={},Re=(N,V)=>{for(V===void 0&&pn("ptr should not be undefined");N.baseClass;)V=N.upcast(V),N=N.baseClass;return V},Ge=(N,V)=>(V=Re(N,V),Ne[V]),Ke=(N,V)=>{(!V.ptrType||!V.ptr)&&aa("makeClassHandle requires ptr and ptrType");var Q=!!V.smartPtrType,oe=!!V.smartPtr;return Q!==oe&&aa("Both smartPtrType and smartPtr must be specified"),V.count={value:1},Ze(Object.create(N,{$$:{value:V,writable:!0}}))};function Ue(N){var V=this.getPointee(N);if(!V)return this.destructor(N),null;var Q=Ge(this.registeredClass,V);if(Q!==void 0){if(Q.$$.count.value===0)return Q.$$.ptr=V,Q.$$.smartPtr=N,Q.clone();var oe=Q.clone();return this.destructor(N),oe}function Ee(){return this.isSmartPointer?Ke(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:V,smartPtrType:this,smartPtr:N}):Ke(this.registeredClass.instancePrototype,{ptrType:this,ptr:N})}var Ie=this.registeredClass.getActualType(V),Be=D[Ie];if(!Be)return Ee.call(this);var Ve;this.isConst?Ve=Be.constPointerType:Ve=Be.pointerType;var et=C(V,this.registeredClass,Ve.registeredClass);return et===null?Ee.call(this):this.isSmartPointer?Ke(Ve.registeredClass.instancePrototype,{ptrType:Ve,ptr:et,smartPtrType:this,smartPtr:N}):Ke(Ve.registeredClass.instancePrototype,{ptrType:Ve,ptr:et})}var Ze=N=>typeof FinalizationRegistry>"u"?(Ze=V=>V,N):(to=new FinalizationRegistry(V=>{console.warn(V.leakWarning.stack.replace(/^Error: /,"")),v(V.$$)}),Ze=V=>{var Q=V.$$,oe=!!Q.smartPtr;if(oe){var Ee={$$:Q},Ie=Q.ptrType.registeredClass;Ee.leakWarning=new Error(`Embind found a leaked C++ instance ${Ie.name} <${bt(Q.ptr)}>. diff --git a/musicxml-singer-with-oddvoices/dist/index.html b/musicxml-singer-with-oddvoices/dist/index.html index fe4b2f5..cf3330e 100644 --- a/musicxml-singer-with-oddvoices/dist/index.html +++ b/musicxml-singer-with-oddvoices/dist/index.html @@ -5,7 +5,7 @@ MusicXML Singer with Odd Voices - +