import{S as F,i as X,s as Y,e as v,k as w,c as y,a as b,d as h,m as E,K as te,b as _,g as B,J as u,L as z,t as C,h as S,j as Ie,E as W,M as He,N as j,O as ue,P as Ge,w as V,x as H,y as G,Q as Ue,q as A,o as M,B as U,R as oe,T as Fe,U as fe,f as ce,V as Xe,W as ae,n as Ne,p as De,X as Ye,l as de,Y as Je}from"../chunks/index-f8f7cfca.js";import{w as se}from"../chunks/index-7a30815e.js";const be=se("synth"),ke=se("medium"),$e=se("medium"),ye=se(!1),we=se(""),Ee=se(""),Te=se(""),_e={piano:"Piano",chamber:"Chamber Music",rock_and_metal:"Rock and Metal",synth:"Synthesizer",church:"Church",timpani_strings_harp:"Timpani, Contrabass, Harp",country:"Country"},Ke={low:"Low",medium:"Medium",high:"High"},Qe={low:"Low",medium:"Medium",high:"High",very_high:"Very High"};function Me(a,e,t){const s=a.slice();return s[4]=e[t],s[6]=t,s}function je(a){let e,t,s,c,l,n,r,i,d,f,o,g;return{c(){e=v("label"),t=v("div"),s=v("img"),n=w(),r=v("input"),d=w(),this.h()},l(p){e=y(p,"LABEL",{"data-selected":!0,class:!0});var $=b(e);t=y($,"DIV",{class:!0});var O=b(t);s=y(O,"IMG",{src:!0,alt:!0,class:!0}),O.forEach(h),n=E($),r=y($,"INPUT",{type:!0,class:!0}),d=E($),$.forEach(h),this.h()},h(){te(s.src,c=`${a[4]}.svg`)||_(s,"src",c),_(s,"alt",l=_e[a[4]]),_(s,"class","svelte-1r9pswz"),_(t,"class","svelte-1r9pswz"),_(r,"type","radio"),r.__value=i=a[4],r.value=r.__value,_(r,"class","svelte-1r9pswz"),a[3][0].push(r),_(e,"data-selected",f=a[0]===a[4]),_(e,"class","svelte-1r9pswz")},m(p,$){B(p,e,$),u(e,t),u(t,s),u(e,n),u(e,r),r.checked=r.__value===a[0],u(e,d),o||(g=z(r,"change",a[2]),o=!0)},p(p,$){$&1&&(r.checked=r.__value===p[0]),$&1&&f!==(f=p[0]===p[4])&&_(e,"data-selected",f)},d(p){p&&h(e),a[3][0].splice(a[3][0].indexOf(r),1),o=!1,g()}}}function Ze(a){let e,t,s=(_e[a[0]]||"Synthesizer")+"",c,l,n,r=a[1],i=[];for(let d=0;dt(0,s=r));const c=Object.keys(_e),l=[[]];function n(){s=this.__value,be.set(s)}return[s,c,n,l]}class et extends F{constructor(e){super(),X(this,e,xe,Ze,Y,{})}}function ze(a,e,t){const s=a.slice();return s[5]=e[t],s}function Pe(a){let e,t=a[1][a[5]]+"",s,c,l,n,r,i,d;return{c(){e=v("label"),s=C(t),c=w(),l=v("input"),this.h()},l(f){e=y(f,"LABEL",{"data-selected":!0,class:!0});var o=b(e);s=S(o,t),c=E(o),l=y(o,"INPUT",{type:!0,class:!0}),o.forEach(h),this.h()},h(){_(l,"type","radio"),l.__value=n=a[5],l.value=l.__value,_(l,"class","svelte-1m848u0"),a[4][0].push(l),_(e,"data-selected",r=a[5]===a[0]),_(e,"class","svelte-1m848u0")},m(f,o){B(f,e,o),u(e,s),u(e,c),u(e,l),l.checked=l.__value===a[0],i||(d=z(l,"change",a[3]),i=!0)},p(f,o){o&2&&t!==(t=f[1][f[5]]+"")&&Ie(s,t),o&1&&(l.checked=l.__value===f[0]),o&1&&r!==(r=f[5]===f[0])&&_(e,"data-selected",r)},d(f){f&&h(e),a[4][0].splice(a[4][0].indexOf(l),1),i=!1,d()}}}function tt(a){let e,t,s,c=a[2],l=[];for(let n=0;n{"options"in i&&t(1,s=i.options),"selection"in i&&t(0,l=i.selection)},[l,s,c,r,n]}class We extends F{constructor(e){super(),X(this,e,st,tt,Y,{options:1,selection:0})}}function lt(a){let e,t,s,c,l,n,r,i;function d(o){a[1](o)}let f={options:Ke};return a[0]!==void 0&&(f.selection=a[0]),n=new We({props:f}),ue.push(()=>Ge(n,"selection",d)),{c(){e=v("div"),t=v("fieldset"),s=v("legend"),c=C("Note density"),l=w(),V(n.$$.fragment),this.h()},l(o){e=y(o,"DIV",{});var g=b(e);t=y(g,"FIELDSET",{class:!0});var p=b(t);s=y(p,"LEGEND",{class:!0});var $=b(s);c=S($,"Note density"),$.forEach(h),l=E(p),H(n.$$.fragment,p),p.forEach(h),g.forEach(h),this.h()},h(){_(s,"class","svelte-1ikh8be"),_(t,"class","svelte-1ikh8be")},m(o,g){B(o,e,g),u(e,t),u(t,s),u(s,c),u(t,l),G(n,t,null),i=!0},p(o,[g]){const p={};!r&&g&1&&(r=!0,p.selection=o[0],Ue(()=>r=!1)),n.$set(p)},i(o){i||(A(n.$$.fragment,o),i=!0)},o(o){M(n.$$.fragment,o),i=!1},d(o){o&&h(e),U(n)}}}function nt(a,e,t){let s;j(a,ke,l=>t(0,s=l));function c(l){s=l,ke.set(s)}return[s,c]}class at extends F{constructor(e){super(),X(this,e,nt,lt,Y,{})}}function rt(a){let e,t,s,c,l,n,r,i;function d(o){a[1](o)}let f={options:Qe};return a[0]!==void 0&&(f.selection=a[0]),n=new We({props:f}),ue.push(()=>Ge(n,"selection",d)),{c(){e=v("div"),t=v("fieldset"),s=v("legend"),c=C("Temperature"),l=w(),V(n.$$.fragment),this.h()},l(o){e=y(o,"DIV",{});var g=b(e);t=y(g,"FIELDSET",{class:!0});var p=b(t);s=y(p,"LEGEND",{class:!0});var $=b(s);c=S($,"Temperature"),$.forEach(h),l=E(p),H(n.$$.fragment,p),p.forEach(h),g.forEach(h),this.h()},h(){_(s,"class","svelte-1ikh8be"),_(t,"class","svelte-1ikh8be")},m(o,g){B(o,e,g),u(e,t),u(t,s),u(s,c),u(t,l),G(n,t,null),i=!0},p(o,[g]){const p={};!r&&g&1&&(r=!0,p.selection=o[0],Ue(()=>r=!1)),n.$set(p)},i(o){i||(A(n.$$.fragment,o),i=!0)},o(o){M(n.$$.fragment,o),i=!1},d(o){o&&h(e),U(n)}}}function ot(a,e,t){let s;j(a,$e,l=>t(0,s=l));function c(l){s=l,$e.set(s)}return[s,c]}class it extends F{constructor(e){super(),X(this,e,ot,rt,Y,{})}}function ct(a){let e,t,s;return{c(){e=C("Compose "),t=v("img"),this.h()},l(c){e=S(c,"Compose "),t=y(c,"IMG",{src:!0,alt:!0,class:!0}),this.h()},h(){te(t.src,s="wand.svg")||_(t,"src",s),_(t,"alt","Magic wand"),_(t,"class","svelte-18w38ow")},m(c,l){B(c,e,l),B(c,t,l)},d(c){c&&h(e),c&&h(t)}}}function ut(a){let e;return{c(){e=C("Composing...")},l(t){e=S(t,"Composing...")},m(t,s){B(t,e,s)},d(t){t&&h(e)}}}function ft(a){let e,t,s;function c(r,i){return r[0]?ut:ct}let l=c(a),n=l(a);return{c(){e=v("button"),n.c(),this.h()},l(r){e=y(r,"BUTTON",{class:!0});var i=b(e);n.l(i),i.forEach(h),this.h()},h(){e.disabled=a[0],_(e,"class","svelte-18w38ow")},m(r,i){B(r,e,i),n.m(e,null),t||(s=z(e,"click",a[1]),t=!0)},p(r,[i]){l!==(l=c(r))&&(n.d(1),n=l(r),n&&(n.c(),n.m(e,null))),i&1&&(e.disabled=r[0])},i:W,o:W,d(r){r&&h(e),n.d(),t=!1,s()}}}function dt(a,e,t){let s,c,l,n,r,i,d;return j(a,ye,o=>t(0,s=o)),j(a,we,o=>t(2,c=o)),j(a,Te,o=>t(3,l=o)),j(a,Ee,o=>t(4,n=o)),j(a,$e,o=>t(5,r=o)),j(a,ke,o=>t(6,i=o)),j(a,be,o=>t(7,d=o)),[s,async()=>{try{oe(ye,s=!0,s);const o=await fetch("compose",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({music_style:d,density:i,temperature:r})});if(!o.ok)throw new Error(`Unable to create composition: [${o.status}] ${o.text()}`);const{audio:g,image:p,tokens:$}=await o.json();oe(Ee,n=p,n),oe(Te,l=$,l),oe(we,c=g,c)}catch(o){console.error(o)}finally{oe(ye,s=!1,s)}}]}class _t extends F{constructor(e){super(),X(this,e,dt,ft,Y,{})}}function re(a,{delay:e=0,duration:t=400,easing:s=Fe}={}){const c=+getComputedStyle(a).opacity;return{delay:e,duration:t,easing:s,css:l=>`opacity: ${l*c}`}}function qe(a){let e,t,s,c,l,n,r,i=!1,d,f=!0,o,g,p=`translateX(${a[5]*(a[0]/a[1])}px)`,$,O,L,P,q;function R(){cancelAnimationFrame(d),n.paused||(d=Je(R),i=!0),a[12].call(n)}let m=a[2]&&Re(a);return{c(){e=v("section"),t=v("div"),s=v("img"),l=w(),n=v("audio"),o=w(),g=v("div"),$=w(),m&&m.c(),this.h()},l(k){e=y(k,"SECTION",{class:!0});var N=b(e);t=y(N,"DIV",{class:!0});var T=b(t);s=y(T,"IMG",{class:!0,src:!0,alt:!0,draggable:!0}),l=E(T),n=y(T,"AUDIO",{src:!0,class:!0}),b(n).forEach(h),o=E(T),g=y(T,"DIV",{class:!0}),b(g).forEach(h),$=E(T),m&&m.l(T),T.forEach(h),N.forEach(h),this.h()},h(){_(s,"class","visualisation svelte-t1xv1q"),te(s.src,c=a[7])||_(s,"src",c),_(s,"alt","MIDI notes of composition"),_(s,"draggable","false"),te(n.src,r=a[6])||_(n,"src",r),_(n,"class","svelte-t1xv1q"),a[1]===void 0&&fe(()=>a[13].call(n)),_(g,"class","handle svelte-t1xv1q"),ce(g,"transform",p,!1),_(t,"class","container svelte-t1xv1q"),ce(t,"width",a[5]?a[5]+"px":"512px",!1),_(e,"class","svelte-t1xv1q")},m(k,N){B(k,e,N),u(e,t),u(t,s),a[10](s),u(t,l),u(t,n),u(t,o),u(t,g),u(t,$),m&&m.m(t,null),a[16](t),L=!0,P||(q=[z(s,"click",a[11]),z(n,"timeupdate",R),z(n,"durationchange",a[13]),z(n,"play",a[14]),z(n,"pause",a[14]),z(t,"mousemove",a[8]),z(t,"touchmove",Xe(a[8]))],P=!0)},p(k,N){(!L||N&128&&!te(s.src,c=k[7]))&&_(s,"src",c),(!L||N&64&&!te(n.src,r=k[6]))&&_(n,"src",r),!i&&N&1&&!isNaN(k[0])&&(n.currentTime=k[0]),i=!1,N&4&&f!==(f=k[2])&&n[f?"pause":"play"](),N&35&&p!==(p=`translateX(${k[5]*(k[0]/k[1])}px)`)&&ce(g,"transform",p,!1),k[2]?m?(m.p(k,N),N&4&&A(m,1)):(m=Re(k),m.c(),A(m,1),m.m(t,null)):m&&(Ne(),M(m,1,1,()=>{m=null}),De()),N&32&&ce(t,"width",k[5]?k[5]+"px":"512px",!1)},i(k){L||(A(m),fe(()=>{O||(O=ae(e,re,{},!0)),O.run(1)}),L=!0)},o(k){M(m),O||(O=ae(e,re,{},!1)),O.run(0),L=!1},d(k){k&&h(e),a[10](null),m&&m.d(),a[16](null),k&&O&&O.end(),P=!1,Ye(q)}}}function Re(a){let e,t,s,c,l,n;return{c(){e=v("img"),this.h()},l(r){e=y(r,"IMG",{class:!0,src:!0,alt:!0,draggable:!0}),this.h()},h(){_(e,"class","play svelte-t1xv1q"),te(e.src,t="play.svg")||_(e,"src",t),_(e,"alt","Play button"),_(e,"draggable","false")},m(r,i){B(r,e,i),c=!0,l||(n=z(e,"click",a[15]),l=!0)},p:W,i(r){c||(fe(()=>{s||(s=ae(e,re,{},!0)),s.run(1)}),c=!0)},o(r){s||(s=ae(e,re,{},!1)),s.run(0),c=!1},d(r){r&&h(e),r&&s&&s.end(),l=!1,n()}}}function ht(a){let e,t,s,c,l=a[6]&&qe(a);return{c(){l&&l.c(),e=de()},l(n){l&&l.l(n),e=de()},m(n,r){l&&l.m(n,r),B(n,e,r),t=!0,s||(c=z(window,"keydown",a[9]),s=!0)},p(n,[r]){n[6]?l?(l.p(n,r),r&64&&A(l,1)):(l=qe(n),l.c(),A(l,1),l.m(e.parentNode,e)):l&&(Ne(),M(l,1,1,()=>{l=null}),De())},i(n){t||(A(l),t=!0)},o(n){M(l),t=!1},d(n){l&&l.d(n),n&&h(e),s=!1,c()}}}function pt(a,e,t){let s,c,l;j(a,we,m=>t(6,c=m)),j(a,Ee,m=>t(7,l=m));let n,r,i=!0,d,f;const o=m=>{if(!r||m.type!=="touchmove"&&!(m.buttons&1))return;const{left:k,right:N}=d.getBoundingClientRect();t(0,n=r*(m.clientX-k)/(N-k)),console.log(s),console.log(f.clientWidth)},g=m=>{m.code==="Space"&&t(2,i=!i)};function p(m){ue[m?"unshift":"push"](()=>{f=m,t(3,f)})}const $=()=>t(2,i=!i);function O(){n=this.currentTime,t(0,n)}function L(){r=this.duration,t(1,r)}function P(){i=this.paused,t(2,i)}const q=()=>t(2,i=!i);function R(m){ue[m?"unshift":"push"](()=>{d=m,t(4,d)})}return a.$$.update=()=>{a.$$.dirty&8&&t(5,s=f&&f.clientWidth),a.$$.dirty&15&&(n||r||!i)&&t(5,s=f&&f.clientWidth)},[n,r,i,f,d,s,c,l,o,g,p,$,O,L,P,q,R]}class mt extends F{constructor(e){super(),X(this,e,pt,ht,Y,{})}}function Ve(a){let e,t,s,c,l,n,r,i;return{c(){e=v("section"),t=v("h2"),s=C("Tokenized notes"),c=w(),l=v("p"),n=C(a[0]),this.h()},l(d){e=y(d,"SECTION",{class:!0});var f=b(e);t=y(f,"H2",{});var o=b(t);s=S(o,"Tokenized notes"),o.forEach(h),c=E(f),l=y(f,"P",{class:!0});var g=b(l);n=S(g,a[0]),g.forEach(h),f.forEach(h),this.h()},h(){_(l,"class","svelte-4un5mw"),_(e,"class","svelte-4un5mw")},m(d,f){B(d,e,f),u(e,t),u(t,s),u(e,c),u(e,l),u(l,n),i=!0},p(d,f){(!i||f&1)&&Ie(n,d[0])},i(d){i||(fe(()=>{r||(r=ae(e,re,{},!0)),r.run(1)}),i=!0)},o(d){r||(r=ae(e,re,{},!1)),r.run(0),i=!1},d(d){d&&h(e),d&&r&&r.end()}}}function gt(a){let e,t,s=a[0]&&Ve(a);return{c(){s&&s.c(),e=de()},l(c){s&&s.l(c),e=de()},m(c,l){s&&s.m(c,l),B(c,e,l),t=!0},p(c,[l]){c[0]?s?(s.p(c,l),l&1&&A(s,1)):(s=Ve(c),s.c(),A(s,1),s.m(e.parentNode,e)):s&&(Ne(),M(s,1,1,()=>{s=null}),De())},i(c){t||(A(s),t=!0)},o(c){M(s),t=!1},d(c){s&&s.d(c),c&&h(e)}}}function vt(a,e,t){let s;return j(a,Te,c=>t(0,s=c)),[s]}class yt extends F{constructor(e){super(),X(this,e,vt,gt,Y,{})}}function bt(a){let e,t,s,c,l,n,r,i,d,f,o,g,p,$,O,L,P,q,R,m,k,N,T,J,he,K,pe,Q,me,Z,ge,x,ve,ee,ie;return J=new et({}),K=new at({}),Q=new it({}),Z=new _t({}),x=new mt({}),ee=new yt({}),{c(){e=v("main"),t=v("h1"),s=C("Composer"),c=w(),l=v("p"),n=C("A hundred thousand songs used to train. One AI model. Infinite compositions."),r=w(),i=v("p"),d=C(`This space contains a deep neural network model that can compose music. You can use it to generate music in different styles, 4 bars at a time.`),f=w(),o=v("p"),g=C("Developed by "),p=v("a"),$=C("Ron Au"),O=C(` and `),L=v("a"),P=C("Tristan Behrens"),q=C("."),R=w(),m=v("p"),k=C("Have fun! And always feel free to send us some feedback and share your compositions!"),N=w(),T=v("section"),V(J.$$.fragment),he=w(),V(K.$$.fragment),pe=w(),V(Q.$$.fragment),me=w(),V(Z.$$.fragment),ge=w(),V(x.$$.fragment),ve=w(),V(ee.$$.fragment),this.h()},l(D){e=y(D,"MAIN",{class:!0});var I=b(e);t=y(I,"H1",{class:!0});var Oe=b(t);s=S(Oe,"Composer"),Oe.forEach(h),c=E(I),l=y(I,"P",{class:!0});var Ce=b(l);n=S(Ce,"A hundred thousand songs used to train. One AI model. Infinite compositions."),Ce.forEach(h),r=E(I),i=y(I,"P",{class:!0});var Se=b(i);d=S(Se,`This space contains a deep neural network model that can compose music. You can use it to generate music in different styles, 4 bars at a time.`),Se.forEach(h),f=E(I),o=y(I,"P",{class:!0});var le=b(o);g=S(le,"Developed by "),p=y(le,"A",{href:!0});var Ae=b(p);$=S(Ae,"Ron Au"),Ae.forEach(h),O=S(le,` and `),L=y(le,"A",{href:!0});var Be=b(L);P=S(Be,"Tristan Behrens"),Be.forEach(h),q=S(le,"."),le.forEach(h),R=E(I),m=y(I,"P",{class:!0});var Le=b(m);k=S(Le,"Have fun! And always feel free to send us some feedback and share your compositions!"),Le.forEach(h),N=E(I),T=y(I,"SECTION",{id:!0,class:!0});var ne=b(T);H(J.$$.fragment,ne),he=E(ne),H(K.$$.fragment,ne),pe=E(ne),H(Q.$$.fragment,ne),ne.forEach(h),me=E(I),H(Z.$$.fragment,I),ge=E(I),H(x.$$.fragment,I),ve=E(I),H(ee.$$.fragment,I),I.forEach(h),this.h()},h(){_(t,"class","svelte-1rfjlkw"),_(l,"class","heading svelte-1rfjlkw"),_(i,"class","svelte-1rfjlkw"),_(p,"href","https://twitter.com/ronvoluted"),_(L,"href","https://twitter.com/DrTBehrens"),_(o,"class","svelte-1rfjlkw"),_(m,"class","svelte-1rfjlkw"),_(T,"id","options"),_(T,"class","svelte-1rfjlkw"),_(e,"class","svelte-1rfjlkw")},m(D,I){B(D,e,I),u(e,t),u(t,s),u(e,c),u(e,l),u(l,n),u(e,r),u(e,i),u(i,d),u(e,f),u(e,o),u(o,g),u(o,p),u(p,$),u(o,O),u(o,L),u(L,P),u(o,q),u(e,R),u(e,m),u(m,k),u(e,N),u(e,T),G(J,T,null),u(T,he),G(K,T,null),u(T,pe),G(Q,T,null),u(e,me),G(Z,e,null),u(e,ge),G(x,e,null),u(e,ve),G(ee,e,null),ie=!0},p:W,i(D){ie||(A(J.$$.fragment,D),A(K.$$.fragment,D),A(Q.$$.fragment,D),A(Z.$$.fragment,D),A(x.$$.fragment,D),A(ee.$$.fragment,D),ie=!0)},o(D){M(J.$$.fragment,D),M(K.$$.fragment,D),M(Q.$$.fragment,D),M(Z.$$.fragment,D),M(x.$$.fragment,D),M(ee.$$.fragment,D),ie=!1},d(D){D&&h(e),U(J),U(K),U(Q),U(Z),U(x),U(ee)}}}class wt extends F{constructor(e){super(),X(this,e,null,bt,Y,{})}}export{wt as default};