1import{aU as t,a as A,aI as e,I as u,be as ka,bd as ba,bj as wa,ao as Sa,aH as Ca,a7 as Ta,g as Es}from"./index-Cgggh05U.js";import{S as ha}from"./StyleTagInput-CPcyM7K7.js";import{p as _a}from"./priceLine-BCTsQhO6.js";/* empty css *//* empty css *//* empty css */const Aa=m=>{if(!m)return m;const g=String(m).match(/^gs:\/\/([^/]+)\/(.+)$/);return g?`${A}/api/assets/file?bucket=${encodeURIComponent(g[1])}&name=${encodeURIComponent(g[2])}`:m},Ia=[.4,.7,.3,.9,.5,1,.6,.35,.8,.5,.65,.9,.45,.75,.3,.55,.85,.4,.95,.6];function Ea({avatar:m,avatarId:g,avatarTracks:N=[],token:J,firstName:fe,fullWidth:d=!1}){const[E,p]=t.useState("daily"),[ts,M]=t.useState(0),[xe,P]=t.useState([]),[L,we]=t.useState(""),[F,X]=t.useState(!1),[Se,Ye]=t.useState(!1),U=t.useRef(!1),se=t.useRef(null),ae=t.useRef(null),D=m?.name||"your artist",W=m?.main_genre||"",_=N[0]?.title,z=m?.profile_animation_status==="ready"&&!!m?.profile_animation_enabled&&!!m?.profile_animation_url?Aa(m.profile_animation_url):null,O=m?.profile_image_url||null,Z=t.useMemo(()=>{const h=[{label:"TODAY'S OFFER",quote:"I've got a new sound I've been sitting on â want the first track in it?",cta:"Make it"}];return _&&h.push({label:"ON YOUR LAST DROP",quote:`"${_}" is still my favorite thing we've made. Want to run that vibe back with something new?`,cta:"Run it back"}),h.push({label:"THE NEXT ONE",quote:`Tell me one thing on your mind and I'll build the whole record around it. Or just say "go".`,cta:"Start it"}),h},[_]),te=t.useMemo(()=>{const h=[];return N.length&&h.push({value:String(N.length),label:N.length===1?"SONG":"SONGS"}),h},[N.length]);t.useEffect(()=>{if(!(E!=="daily"||Z.length<=1))return ae.current=setInterval(()=>M(h=>(h+1)%Z.length),6e3),()=>{ae.current&&clearInterval(ae.current),ae.current=null}},[E,Z.length]),t.useEffect(()=>{if(E!=="chat"||Se||!J)return;let h=!0;return(async()=>{try{const v=await fetch(`${A}/api/chat/history/${g}`,{headers:{Authorization:`Bearer ${J}`}}),R=v.ok?await v.json():{},G=Array.isArray(R.messages)?R.messages:[];h&&P(Y=>Y.length?[...G,...Y]:G)}catch{}finally{h&&Ye(!0)}})(),()=>{h=!1}},[E,Se,J,g]),t.useEffect(()=>{E==="chat"&&se.current&&(se.current.scrollTop=se.current.scrollHeight)},[xe,E,F]);const Fe=()=>{p("daily"),M(0)},[Ce,Te]=t.useState(""),Me=h=>{h.preventDefault();const v=Ce.trim();Te(""),p("chat"),v&&le(v)},le=async h=>{const v=(h??L).trim();if(!(!v||U.current)){we(""),X(!0),U.current=!0,P(R=>[...R,{role:"user",content:v,timestamp:new Date}]);try{const G=await(await fetch(`${A}/api/chat/message`,{method:"POST",headers:{Authorization:`Bearer ${J}`,"Content-Type":"application/json"},body:JSON.stringify({avatarId:g,message:v})})).json();G.requiresUpgrade?P(Y=>[...Y,{role:"assistant",content:`${G.reason||"You've used your free chat messages."} Upgrade to keep chatting!`,timestamp:new Date,isUpgrade:!0}]):G.success&&G.reply?P(Y=>[...Y,{role:"assistant",content:G.reply,timestamp:new Date}]):P(Y=>[...Y,{role:"assistant",content:"I'm having trouble responding right now. Please try again!",timestamp:new Date,isError:!0}])}catch{P(R=>[...R,{role:"assistant",content:"Something went wrong. Please try again.",timestamp:new Date,isError:!0}])}finally{X(!1),U.current=!1}}},Ue=Z[ts]||Z[0];return e.jsxs("div",{className:`collab-hub ${d?"collab-hub--full":"cth-ar-16-9"} ${E==="chat"?"is-chat":""}`,children:[e.jsx("div",{className:"ch-scene",children:z?e.jsx("video",{src:z,poster:O||void 0,autoPlay:!0,muted:!0,loop:!0,playsInline:!0}):O?e.jsx("img",{src:O,alt:""}):null}),e.jsx("div",{className:"ch-scene-overlay"}),E!=="chat"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"ch-presence",children:[e.jsxs("div",{className:"ch-presence-row",children:[e.jsxs("span",{className:"ch-studio-badge",children:[e.jsx("span",{className:"ch-studio-dot"})," IN THE STUDIO"]}),e.jsxs("span",{className:"ch-handle",children:[m?.handle?`@${m.handle}`:D,W?` · ${W.toUpperCase()}`:""]})]}),e.jsxs("div",{className:"ch-eq-row",children:[e.jsx("div",{className:"ch-eq",children:Ia.map((h,v)=>e.jsx("span",{style:{height:`${Math.round(3+h*9)}px`,animationDuration:`${(.7+v%5*.18).toFixed(2)}s`,animationDelay:`${v%7*.09}s`}},v))}),e.jsx("span",{className:"ch-status-line",children:"warming up · ready when you are"})]})]}),te.length>0&&e.jsx("div",{className:"ch-stats",children:te.map((h,v)=>e.jsxs("div",{className:"ch-stat",children:[e.jsx("div",{className:"ch-stat-val",children:h.value}),e.jsx("div",{className:"ch-stat-label",children:h.label})]},v))}),e.jsxs("div",{className:"ch-hero ch-hero--talk",children:[e.jsx("div",{className:"ch-kicker",children:"MAKE IT TOGETHER"}),e.jsxs("div",{className:"ch-hero-bubble",children:[e.jsx("span",{className:"ch-hero-bubble-avatar",children:O?e.jsx("img",{src:O,alt:""}):e.jsx(u,{name:"user",size:12})}),e.jsxs("div",{className:"ch-hero-bubble-body",children:[e.jsx("span",{className:"ch-hero-bubble-name",children:D}),e.jsx("span",{className:"ch-hero-bubble-text",children:Ue.quote})]})]}),e.jsxs("form",{className:"ch-hero-input",onSubmit:Me,children:[e.jsx(u,{name:"comment-dots",size:15}),e.jsx("input",{type:"text",value:Ce,onChange:h=>Te(h.target.value),placeholder:`Reply to ${fe||D} â or just say "go"`,"aria-label":`Chat with ${D} about the next song`}),e.jsx("button",{type:"submit",className:"ch-hero-send","aria-label":"Start the conversation",children:e.jsx(u,{name:"arrow-up",size:14})})]}),e.jsx("div",{className:"ch-cta-sub",children:"They draft, you steer. Lyrics if you want them."})]})]}),E==="chat"&&e.jsxs("div",{className:"ch-chat",children:[e.jsxs("div",{className:"ch-chat-head",children:[e.jsx("span",{className:"ch-chat-avatar",children:O?e.jsx("img",{src:O,alt:D}):e.jsx(u,{name:"user",size:14})}),e.jsxs("div",{className:"ch-chat-title",children:[e.jsx("span",{className:"ch-chat-name",children:D}),e.jsx("span",{className:"ch-chat-status",children:"â talking about the next song"})]}),e.jsxs("button",{type:"button",className:"ch-chat-close",onClick:Fe,children:[e.jsx(u,{name:"xmark",size:12})," Close"]})]}),e.jsxs("div",{className:"ch-chat-msgs",ref:se,children:[Se&&xe.length===0&&e.jsxs("div",{className:"ch-msg ch-msg--artist",children:[e.jsxs("span",{className:"ch-msg-tag",children:["⦠",D.toUpperCase()]}),e.jsx("div",{className:"ch-bubble ch-bubble--artist",children:`Yo! What are we making today? Tell me a feeling, a phrase, or just say "go" and I'll take the pen.`})]}),xe.map((h,v)=>{const R=h.role==="assistant";return e.jsxs("div",{className:`ch-msg ${R?"ch-msg--artist":"ch-msg--user"}`,children:[R&&e.jsxs("span",{className:"ch-msg-tag",children:["⦠",D.toUpperCase()]}),e.jsx("div",{className:`ch-bubble ${R?"ch-bubble--artist":"ch-bubble--user"} ${h.isError?"is-error":""}`,children:h.content})]},h.id||v)}),F&&e.jsx("div",{className:"ch-msg ch-msg--artist",children:e.jsxs("div",{className:"ch-bubble ch-bubble--artist ch-bubble--typing",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]})})]}),e.jsxs("form",{className:"ch-chat-input",onSubmit:h=>{h.preventDefault(),le()},children:[e.jsx("input",{type:"text",value:L,onChange:h=>we(h.target.value),placeholder:`Tell ${fe||D} what you're feelingâ¦`}),e.jsx("button",{type:"submit",className:"ch-send",disabled:F||!L.trim(),"aria-label":"Send",children:e.jsx(u,{name:"arrow-up",size:14})})]})]})]})}const $a="song_generation",$s="Auto (Recommended)",Oa={vocal:"VOCALS",instrument:"INSTRUMENTS",production:"PRODUCTION",mood:"MOOD",genre_modifier:"GENRE"},ua=["vocal","instrument","production","mood","genre_modifier"],ma=[{value:"song",icon:"microphone",name:"Song",desc:"Full track with vocals and lyrics"},{value:"instrumental",icon:"piano-keyboard",name:"Instrumental",desc:"No vocals â pure production"},{value:"spoken_word",icon:"comment-dots",name:"Spoken Word",desc:"Scripted delivery over music"},{value:"narration",icon:"book-open",name:"Narration",desc:"Voice only â no music"}],Ra=m=>String(m||"").split(/\s+/).slice(0,2).map(g=>g[0]||"").join("").toUpperCase(),Ga=m=>m?String(m).split(",").map(g=>
1g.trim()).filter(Boolean):[];function Pa({avatar:m,error:g,onBack:N,onCancel:J,onOpenChat:fe,audioType:d,setAudioType:E,targetLength:p,setTargetLength:ts,songLengths:M=[],includeBackgroundMusic:xe,setIncludeBackgroundMusic:P,lyricsMode:L,setLyricsMode:we,concept:F,setConcept:X,theme:Se,setTheme:Ye,title:U,setTitle:se,lyrics:ae,setLyrics:D,taxonomy:W,genre:_,onGenreChange:ve,setGenre:z,setSelectedGenreId:O,mood:Z,setMood:te,style:Fe,setStyle:Ce,currentStyles:Te=[],voiceType:Me,setVoiceType:le,useMurekaVoice:Ue,setUseMurekaVoice:h,vocalStyles:v,setVocalStyles:R,negativeTags:G,setNegativeTags:Y,avatarTracks:Ve=[],stylePersonaSourceTrackId:_e,setStylePersonaSourceTrackId:Ae,wild:re,setWild:gs,onGenerate:fs,generateDisabled:xs,ctaLabel:vs}){const[ns,js]=t.useState(!1),[De,ze]=t.useState([]),[ce,w]=t.useState(""),[ls,ie]=t.useState(!1),[He,rs]=t.useState(null),[cs,Ke]=t.useState(null);t.useEffect(()=>{let a=!1;return fetch(`${A}/api/taxonomy/vocal-style-options`).then(i=>i.ok?i.json():{options:[]}).then(i=>{a||ze(Array.isArray(i.options)?i.options:[])}).catch(()=>{a||ze([])}),()=>{a=!0}},[]),t.useEffect(()=>{let a=!1;return fetch(`${A}/api/subscriptions/credits/rates/${$a}`).then(i=>i.ok?i.json():null).then(i=>{const f=Number(i?.amount);!a&&Number.isFinite(f)&&f>=0&&Ke({credits:f,display:i.display||null})}).catch(()=>{}),()=>{a=!0}},[]),t.useEffect(()=>{let a=!1;const i=localStorage.getItem("token");if(i)return fetch(`${A}/api/subscriptions/credits/balance`,{headers:{Authorization:`Bearer ${i}`}}).then(f=>f.ok?f.json():null).then(f=>{!a&&f&&rs(f)}).catch(()=>{}),()=>{a=!0}},[]);const qe=["song","spoken_word","narration"].includes(d),K=L==="write"&&qe,oe=d==="song"||d==="instrumental"||d==="spoken_word"&&xe,is=!K,je=d==="spoken_word"||d==="narration",os=_e?Ve.find(a=>String(a.track_id)===String(_e)):null,ds=!!os&&!os.style_persona_id,$=Ga(v),de=m?.name||"your artist",Ns=t.useMemo(()=>{const a=new Set($.map(S=>S.toLowerCase())),i=new Map;for(const S of De){if(!S?.name||a.has(String(S.name).toLowerCase()))continue;const C=S.category||"vocal";i.has(C)||i.set(C,[]),i.get(C).push(S)}const f=ua.filter(S=>i.has(S)),Oe=[...i.keys()].filter(S=>!ua.includes(S)).sort();return[...f,...Oe].map(S=>({key:S,label:Oa[S]||String(S).replace(/_/g," ").toUpperCase(),items:i.get(S)}))},[De,v]),Ie=a=>R(a.join(", ")),Je=a=>{const i=String(a||"").trim();i&&($.some(f=>f.toLowerCase()===i.toLowerCase())||Ie([...$,i]))},Os=a=>Ie($.filter(i=>i!==a)),Rs=a=>{a.key==="Enter"||a.key===","?(a.preventDefault(),Je(ce),w("")):a.key==="Backspace"&&!ce&&$.length&&Ie($.slice(0,-1))},Gs=async()=>{ie(!0);try{const a=localStorage.getItem("token"),i=await fetch(`${A}/api/taxonomy/suggest-styles`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({genre:_,mood:Z})}),f=i.ok?await i.json():null;if(f?.styles){const Oe=String(f.styles).split(",").map(C=>C.trim()).filter(Boolean),S=[...$];for(const C of Oe)S.some(Qe=>Qe.toLowerCase()===C.toLowerCase())||S.push(C);Ie(S)}}catch{}finally{ie(!1)}},B=t.useMemo(()=>{const a=m?.main_genre||"",i=(W?.genres||[]).find(f=>f.name===a);return{genre:i?i.name:"",genreId:i?i.id:null,voiceType:m?.voice_type||"",vocalStyle:m?.vocal_style||""}},[m,W]),Xe=!!(B.genre||B.voiceType||B.vocalStyle),Ps=()=>{B.genre&&(z(B.genre),O(B.genreId)),B.voiceType&&le(B.voiceType),R(B.vocalStyle),Ce($s)},Ls=ma.find(a=>a.value===d)?.name||d,Fs=M.find(a=>a.value===p)?.label||p,he=[{k:"FORMAT",v:Ls}];qe&&he.push({k:"LYRICS",v:K?"Write my own":"AI-generated"}),is&&he.push({k:"LENGTH",v:Fs}),oe&&he.push({k:"GENRE",v:_||"Not set",none:!_}),oe&&he.push({k:"MOOD",v:Z||"Not set",none:!Z}),he.push({k:"TAGS",v:$.length?`${$.length} selected`:"None",none:!$.length}),re&&he.push({k:"RISK",v:"Bigger risk",gold:!0});const V=[];G.trim()&&V.push("exclusions set"),_e&&V.push("reference track"),re&&V.push("bigger risk on");const Ee=V.length?V.join(" · "):"Exclusions, reference track, and risk level",$e=qe&&!K?`You will review the ${je?"script":"lyrics"} before anything is recorded.`:"The track is produced and held for your review.",y=He&&Number.isFinite(Number(He.total))?Number(He.total):null,x=_a(cs),ys=!!cs&&y!==null&&y<cs.credits,ks=e.jsxs("div",{className:"ctf2-price",children:[x?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"ctf2-price-amount",children:x.amount}),x.note&&e.jsx("div",{className:"ctf2-price-note",children:x.note})]}):e.jsx("div",{className:"ctf2-price-note",children:"Priced at generation."}),y!==null&&e.jsx("div",{className:`ctf2-price-bal ${ys?"is-short":""}`,children:ys?`You have ${y} â not enough for this track.`:`${y} credits left`})]}),bs=e.jsx("div",{className:"ctf2-recap-grid",children:he.map(a=>e.jsxs(t.Fragment,{children:[e.jsx("div",{className:"ctf2-recap-k",children:a.k}),e.jsx("div",{className:`ctf2-recap-v ${a.none?"is-none":""} ${a.gold?"is-gold":""}`,children:a.v})]},a.k))}),Ze=e.jsxs("button",{type:"button",className:"ctf2-primary",onClick:fs,disabled:xs,children:[e.jsx(u,{name:"wand-magic-sparkles",size:14})," ",vs]}),Q=je?"script":"lyrics",ne=[{value:"generate",icon:"wand-magic-sparkles",name:"AI-generated",desc:`Describe the idea and ${de} writes the ${Q}. You review them before anything is recorded.`},{value:"write",icon:"pen",name:"Write my own",desc:`Paste your own ${Q}. ${de} performs them exactly as written.`}];return e.jsxs("div",{className:"create-track-page ctf2",children:[e.jsxs("div",{className:"ctf2-head",children:[e.jsx("button",{type:"button",className:"ctf2-back",onClick:N,"aria-label":"Back to create options",children:e.jsx(u,{name:"arrow-left",size:15})}),e.jsxs("div",{className:"ctf2-headline",children:["New song ",e.jsx("span",{children:"for"})," ",de]})]}),g&&e.jsx("div",{className:"ctf2-error",children:g}),e.jsxs("div",{className:"ctf2-layout",children:[e.jsxs("div",{className:"ctf2-form",children:[qe&&e.jsxs("div",{className:"ctf2-sec ctf2-sec--lyrics",children:[e.jsx("div",{className:"ctf2-kicker",children:je?"SCRIPT":"LYRICS"}),e.jsx("div",{className:"ctf2-ask",children:"Who writes the words?"}),e.jsx("div",{className:"ctf2-forks",children:ne.map(a=>e.jsxs("button",{type:"button",className:`ctf2-fork ${L===a.value?"is-on":""}`,"aria-pressed":L===a.value,onClick:()=>
1we(a.value),children:[e.jsxs("span",{className:"ctf2-fork-top",children:[e.jsx("span",{className:"ctf2-fork-glyph",children:e.jsx(u,{name:a.icon,size:20})}),e.jsx("span",{className:"ctf2-radio"})]}),e.jsx("span",{className:"ctf2-fork-name",children:a.name}),e.jsx("span",{className:"ctf2-fork-desc",children:a.desc})]},a.value))})]}),e.jsxs("div",{className:"ctf2-sec",children:[e.jsx("div",{className:"ctf2-sechead",children:e.jsxs("div",{children:[e.jsx("div",{className:"ctf2-kicker",children:K?je?"YOUR SCRIPT":"YOUR LYRICS":"THE IDEA"}),e.jsx("div",{className:"ctf2-sub",children:K?`Paste the full ${Q} â verses, hooks, and any section labels`:"The only thing that really has to be right"})]})}),K?e.jsxs(e.Fragment,{children:[e.jsx("textarea",{className:"ctf2-textarea",rows:12,value:ae,onChange:a=>D(a.target.value),placeholder:je?`[calm] 2Paste your script hereâ¦`:`[Verse 1] 3Paste your lyrics hereâ¦`}),e.jsx("span",{className:"ctf2-hint",children:je?"Performance tags like [calm], [intense] or [short pause] guide the delivery.":"Section tags like [Verse 1], [Chorus] and [Bridge] guide the song structure."})]}):e.jsx("textarea",{className:"ctf2-textarea",rows:4,value:F,onChange:a=>X(a.target.value),placeholder:je?"What is this about? e.g. A motivational message about perseverance":"What is this song about? e.g. Overcoming struggle and rising to success"}),e.jsxs("div",{className:"ctf2-fields",children:[!K&&d==="song"&&e.jsxs("div",{className:"ctf2-field",children:[e.jsxs("label",{className:"ctf2-label",htmlFor:"ctf2-theme",children:["THEME ",e.jsx("span",{className:"ctf2-opt",children:"OPTIONAL"})]}),e.jsx("input",{id:"ctf2-theme",className:"ctf2-input",type:"text",value:Se,onChange:a=>Ye(a.target.value),placeholder:"e.g. Late night grind"})]}),e.jsxs("div",{className:"ctf2-field",children:[e.jsx("label",{className:"ctf2-label",htmlFor:"ctf2-title",children:K?"TITLE":e.jsxs(e.Fragment,{children:["WORKING TITLE ",e.jsx("span",{className:"ctf2-opt",children:"OPTIONAL"})]})}),e.jsx("input",{id:"ctf2-title",className:"ctf2-input",type:"text",value:U,onChange:a=>se(a.target.value),placeholder:K?"What is it called?":"Leave blank and the artist names it"})]})]})]}),e.jsxs("div",{className:"ctf2-sec",children:[e.jsx("div",{className:"ctf2-kicker",children:"FORMAT"}),e.jsx("div",{className:"ctf2-types",children:ma.map(a=>e.jsxs("button",{type:"button",className:`ctf2-type ${d===a.value?"is-on":""}`,"aria-pressed":d===a.value,onClick:()=>E(a.value),children:[e.jsxs("span",{className:"ctf2-type-top",children:[e.jsx("span",{className:"ctf2-type-glyph",children:e.jsx(u,{name:a.icon,size:14})}),e.jsx("span",{className:"ctf2-type-name",children:a.name})]}),e.jsx("span",{className:"ctf2-type-desc",children:a.desc})]},a.value))}),e.jsxs("div",{className:"ctf2-fields",children:[is&&e.jsxs("div",{className:"ctf2-field",children:[e.jsx("label",{className:"ctf2-label",htmlFor:"ctf2-length",children:"TRACK LENGTH"}),e.jsx("select",{id:"ctf2-length",className:"ctf2-select",value:p,onChange:a=>ts(a.target.value),children:M.map(a=>e.jsx("option",{value:a.value,children:a.label},a.value))})]}),d==="spoken_word"&&e.jsxs("div",{className:"ctf2-field",children:[e.jsx("label",{className:"ctf2-label",children:"BACKGROUND MUSIC"}),e.jsxs("label",{className:"ctf2-check",children:[e.jsx("input",{type:"checkbox",checked:xe,onChange:a=>P(a.target.checked)}),"Score it with music"]})]})]})]}),e.jsxs("div",{className:"ctf2-sec",children:[e.jsxs("div",{className:"ctf2-sechead",children:[e.jsxs("div",{children:[e.jsx("div",{className:"ctf2-kicker",children:"SOUND"}),e.jsx("div",{className:"ctf2-sub",children:Xe?`Starts from ${de}'s own sound â change only what matters`:"Change only what matters"})]}),Xe&&e.jsx("div",{className:"ctf2-sechead-acts",children:e.jsx("button",{type:"button",className:"ctf2-textbtn",onClick:Ps,children:"Reset to artist defaults"})})]}),e.jsxs("div",{className:"ctf2-fields",children:[oe&&e.jsxs("div",{className:"ctf2-field",children:[e.jsx("label",{className:"ctf2-label",htmlFor:"ctf2-genre",children:"GENRE"}),e.jsx("select",{id:"ctf2-genre",className:"ctf2-select",value:_||"",onChange:ve,children:(W?.genres||[]).map(a=>e.jsxs("optgroup",{label:a.name,children:[e.jsx("option",{value:a.name,children:a.name}),(W?.stylesByGenre?.[a.id]||[]).filter(i=>i.slug!=="auto").map(i=>e.jsx("option",{value:i.name,children:i.name},i.id))]},a.id))})]}),oe&&e.jsxs("div",{className:"ctf2-field",children:[e.jsx("label",{className:"ctf2-label",htmlFor:"ctf2-mood",children:"MOOD"}),e.jsx("select",{id:"ctf2-mood",className:"ctf2-select",value:Z,onChange:a=>te(a.target.value),children:(W?.moods||[]).map(a=>e.jsx("option",{value:a.name,children:a.name},a.id))})]}),d==="song"&&e.jsxs("div",{className:"ctf2-field",children:[e.jsx("label",{className:"ctf2-label",htmlFor:"ctf2-voice",children:"VOCAL STYLE"}),e.jsxs("select",{id:"ctf2-voice",className:"ctf2-select",value:Me,onChange:a=>le(a.target.value),children:[e.jsx("option",{value:"singing",children:"Singing"}),e.jsx("option",{value:"rapping",children:"Rapping"})]})]}),oe&&e.jsxs("div",{className:"ctf2-field",children:[e.jsx("label",{className:"ctf2-label",htmlFor:"ctf2-style",children:"PRODUCTION STYLE"}),e.jsx("select",{id:"ctf2-style",className:`ctf2-select ${Fe===$s?"is-default":""}
3`,value:Fe,onChange:a=>Ce(a.target.value),children:Te.length===0?e.jsx("option",{value:$s,children:"Auto â recommended"}):[e.jsx("option",{value:$s,children:"Auto â recommended"},"__auto"),...Te.map(a=>e.jsx("option",{value:a.name,children:a.name},a.id))]})]}),d==="song"&&m?.mureka_voice_id&&e.jsxs("div",{className:"ctf2-field",children:[e.jsx("label",{className:"ctf2-label",children:"VOICE"}),e.jsxs("label",{className:"ctf2-check",children:[e.jsx("input",{type:"checkbox",checked:Ue,onChange:a=>h(a.target.checked)}),"Use my uploaded voice"]})]})]})]}),oe&&e.jsxs("div",{className:"ctf2-sec",children:[e.jsxs("div",{className:"ctf2-sechead",children:[e.jsxs("div",{children:[e.jsx("div",{className:"ctf2-kicker",children:"STYLE TAGS"}),e.jsxs("div",{className:"ctf2-sub",children:[$.length?`${$.length} selected`:"Optional"," â the texture and delivery of the track"]})]}),e.jsxs("div",{className:"ctf2-sechead-acts",children:[$.length>0&&e.jsx("button",{type:"button",className:"ctf2-ghost",onClick:()=>Ie([]),children:"Clear all"}),e.jsxs("button",{type:"button",className:"ctf2-ai",onClick:Gs,disabled:ls,children:[e.jsx(u,{name:"wand-magic-sparkles",size:12}),ls?"Writingâ¦":"Auto-write"]})]})]}),e.jsxs("div",{className:"ctf2-well",children:[$.length>0?e.jsx("div",{className:"ctf2-pills",children:$.map(a=>e.jsxs("button",{type:"button",className:"ctf2-pill",onClick:()=>Os(a),"aria-label":`Remove ${a}`,children:[a,e.jsx("span",{"aria-hidden":"true",children:"â"})]},a))}):e.jsxs("div",{className:"ctf2-well-empty",children:["No tags yet â pick from below, or let ",de," choose."]}),e.jsx("input",{className:"ctf2-tagin",type:"text",value:ce,onChange:a=>w(a.target.value),onKeyDown:Rs,onBlur:()=>{ce.trim()&&(Je(ce),w(""))},placeholder:"Type to add your own tagâ¦","aria-label":"Add a style tag"})]}),e.jsx("div",{className:"ctf2-groups",children:Ns.map(a=>e.jsxs("div",{children:[e.jsx("div",{className:"ctf2-label",children:a.label}),e.jsx("div",{className:"ctf2-group-tags",children:a.items.map(i=>e.jsxs("button",{type:"button",className:"ctf2-sug",onClick:()=>Je(i.name),children:[e.jsx("span",{"aria-hidden":"true",children:"+"}),i.name]},i.id??i.name))})]},a.key))})]}),e.jsxs("div",{className:"ctf2-sec",children:[e.jsxs("button",{type:"button",className:"ctf2-advhead","aria-expanded":ns,onClick:()=>js(a=>!a),children:[e.jsxs("span",{className:"ctf2-advhead-copy",children:[e.jsx("span",{className:"ctf2-kicker",children:"ADVANCED"}),e.jsx("span",{className:"ctf2-sub",children:Ee})]}),e.jsx("span",{className:"ctf2-caret","aria-hidden":"true",children:"âº"})]}),ns&&e.jsxs("div",{className:"ctf2-advbody",children:[(d==="song"||d==="instrumental")&&e.jsxs("div",{className:"ctf2-field",children:[e.jsx("label",{className:"ctf2-label",htmlFor:"ctf2-neg",children:"EXCLUDE FROM GENERATION"}),e.jsx("input",{id:"ctf2-neg",className:"ctf2-input",type:"text",value:G,onChange:a=>Y(a.target.value),placeholder:"e.g. autotune, mumble rap, choir, guitar solo"}),e.jsx("span",{className:"ctf2-hint",children:"Anything listed here is kept out of the track."})]}),Ve.length>0&&(d==="song"||d==="instrumental")&&e.jsxs("div",{className:"ctf2-field ctf2-field--narrow",children:[e.jsx("label",{className:"ctf2-label",htmlFor:"ctf2-ref",children:"REFERENCE TRACK"}),e.jsxs("select",{id:"ctf2-ref",className:`ctf2-select ${_e?"":"is-default"}`,value:_e,onChange:a=>Ae(a.target.value),children:[e.jsx("option",{value:"",children:"None â use the artist's own sound"}),Ve.map(a=>e.jsxs("option",{value:a.track_id,children:['Same vibe as⦠"',a.title,'"']},a.track_id))]}),ds&&e.jsx("div",{className:"ctf2-warn",children:"First use of this track as a style source takes a few extra minutes while the style is prepared. After that, copying it is instant."})]}),e.jsxs("button",{type:"button",className:`ctf2-risk ${re?"is-on":""}`,"aria-pressed":re,onClick:()=>gs(!re),children:[e.jsxs("span",{className:"ctf2-risk-copy",children:[e.jsx("span",{className:"ctf2-risk-name",children:"Take a bigger risk"}),e.jsx("span",{className:"ctf2-risk-desc",children:"Experimental: bigger creative swings, so quality varies from song to song. For the most reliable results, turn it on only when you want something unexpected."})]}),e.jsx("span",{className:"ctf2-track",children:e.jsx("span",{className:"ctf2-knob"})})]})]})]}),e.jsxs("div",{className:"ctf2-review",children:[e.jsx("div",{className:"ctf2-kicker",children:"REVIEW"}),bs,ks,Ze,e.jsx("div",{className:"ctf2-submit-hint",children:$e}),e.jsxs("div",{className:"ctf2-foot",children:[e.jsx("button",{type:"button",className:"ctf2-textbtn",onClick:fe,children:"Do this in chat"}),e.jsx("button",{type:"button",className:"ctf2-textbtn",onClick:J,children:"Cancel"})]})]})]}),e.jsxs("div",{className:"ctf2-side",children:[e.jsxs("div",{className:"ctf2-card",children:[e.jsxs("div",{className:"ctf2-artist",children:[e.jsxs("div",{className:"ctf2-artist-img",children:[e.jsx("div",{className:"ctf2-artist-fallback",children:Ra(m?.name)}),m?.profile_image_url&&e.jsx("img",{src:m.profile_image_url,alt:""})]}),e.jsxs("div",{className:"ctf2-artist-meta",children:[e.jsx("div",{className:"ctf2-artist-kicker",children:"PERFORMED BY"}),e.jsx("div",{className:"ctf2-artist-name",children:de})]})]}),e.jsxs("div",{className:"ctf2-recap",children:[e.jsx("div",{className:"ctf2-label",children:"THIS TRACK"}),bs]}),ks,e.jsxs("div",{className:"ctf2-thin",children:[e.jsx("div",{className:"ctf2-thin-recap",children:he.slice(0,3).map(a=>a.v).join(" · ")}),e.jsx("div",{className:"ctf2-thin-cost",children:x?x.amount:""})]})]}),Ze,e.jsx("div",{className:"ctf2-submit-hint",children:$e}),e.jsxs("div",{className:"ctf2-foot",children:[e.jsx("button",{type:"button",className:"ctf2-textbtn",onClick:fe,children:"Do this in chat"}),e.jsx("button",{type:"button",className:"ctf2-textbtn",onClick:J,children:"Cancel"})]})]})]})]})}const pa=(m,g)=>{const N=String(m).replace("#",""),J=parseInt(N.slice(0,2),16),fe=parseInt(N.slice(2,4),16),d=parseInt(N.slice(4,6),16);return`rgba(${J}, ${fe}, ${d}, ${g})`},sa=[{value:"short",label:"Short (~1 min)"},{value:"standard",label:"Standard (~3 min)"},{value:"extended",label:"Extended (~5 min)"}];function Ha({avatarId:m,embedded:g=!1,onViewLibrary:N,user:J}){const{avatarId:fe}=ka(),d=m||fe,E=ba(),[p,ts]=t.useState(null),[M,xe]=t.useState([]),P=()=>E(p?.handle?`/${p.handle}`:`/avatar/${d}/channel`),[L,we]=t.useState(""),[F,X]=t.useState(1),[Se]=wa(),Ye=Se.get("mode")==="upload",U=!Sa(J),se=Ca(J),[ae,D]=t.useState(null),W=(s,{plan:r=!1}={})=>D({reason:r?`${s} requires a paid plan.`:`${s} needs credits. A paid plan comes with monthly credits, and uploading is free.`,upload:!0}),[_,ve]=t.useState(Ye?"upload":"song"),[z,O]=t.useState(!1),[Z,te]=t.useState(g||Ye?"form":"home"),[Fe,Ce]=t.useState(!1),[Te,Me]=t.useState([]),[le,Ue]=t.useState(!1),h=t.useRef(null),[v,R]=t.useState(null),[G,Y]=t.useState(""),[Ve,_e]=t.useState(""),[Ae,re]=t.useState(""),[gs,fs]=t.useState(null),[xs,vs]=t.useState(null),[ns,js]=t.useState(!1),[De,ze]=t.useState(!1),[ce,w]=t.useState(""),[ls,ie]=t.useState(null),[He,rs]=t.useState(!1),[cs,Ke]=t.useState(!1),[qe,K]=t.useState(!1),[oe,is]=t.useState(null),[je,os]=t.useState(!1),[ds,$]=t.useState(!1),de=30,Ns=10,Ie=s=>{if(s&&(s.type.startsWith("audio/")||s.name.endsWith(".mp3"))){if(s.size/(1024*1024)>de){w(`Audio file too large. Maximum size is ${de}MB.`);return}w(""),R(s),G||Y(s.name.replace(/\.[^/.]+$/,""))}},Je=s=>{if(s&&s.type.startsWith("image/")){if(s.size/(1024*1024)>Ns){w(`Image file too large. Maximum size is ${Ns}MB.`);return}fs(s);const r=new FileReader;r.onload=l=>
3vs(l.target.result),r.readAsDataURL(s)}},Os=s=>{s.preventDefault(),rs(!0)},Rs=s=>{s.preventDefault(),rs(!1)},Gs=s=>{s.preventDefault(),rs(!1);const r=s.dataTransfer.files?.[0];r&&(r.type.startsWith("audio/")||r.name.endsWith(".mp3")?Ie(r):r.type.startsWith("image/")&&Je(r))},B=()=>{R(null),Y(""),_e(""),re(""),fs(null),vs(null),js(!1),is(null),os(!1)},Xe=async({deferTranscription:s}={})=>{const r=localStorage.getItem("token"),l=new FormData;l.append("audio",v),l.append("avatar_id",parseInt(d)),l.append("title",G),l.append("genre",Ve),l.append("rights_confirmed","true"),gs&&l.append("artwork",gs),Ae.trim()&&l.append("lyrics",Ae.trim()),s&&l.append("auto_transcribe","false");const j=await(await fetch(`${A}/api/tracks/upload`,{method:"POST",headers:{Authorization:`Bearer ${r}`},body:l})).json();return j.success?j.track:(j.code==="NSFW_CONTENT_DETECTED"?w(j.reason||"This upload was flagged by content moderation."):w(j.error||"Failed to upload track"),null)},Ps=async s=>{if(s.preventDefault(),w(""),!v){w("Please select an MP3 file to upload");return}if(!G.trim()){w("Please enter a track title");return}if(!ns){w("Please confirm you have rights to upload this music");return}if(!Ae.trim()){Ke(!0);return}ze(!0);try{const r=await Xe();r&&(ie(r),B())}catch{w("Upload failed. Please try again.")}finally{ze(!1)}},Ls=async()=>{Ke(!1),ze(!0),w("");try{const s=await Xe();s&&(ie(s),B())}catch{w("Upload failed. Please try again.")}finally{ze(!1)}},Fs=async()=>{Ke(!1),K(!0),w("");try{const s=await Xe({deferTranscription:!0});if(!s){K(!1);return}is(s.track_id);const r=localStorage.getItem("token"),o=await(await fetch(`${A}/api/tracks/${s.track_id}/transcribe-lyrics`,{method:"POST",headers:{Authorization:`Bearer ${r}`}})).json();os(!!o.instrumental),re(o.lyrics||"")}catch{w("We couldnât analyze the track. You can still finish and add lyrics later.")}finally{K(!1)}},he=async()=>{if(oe){$(!0),w("");try{const s=localStorage.getItem("token"),l=await(await fetch(`${A}/api/tracks/${oe}/lyrics`,{method:"PATCH",headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json"},body:JSON.stringify({lyrics:Ae})})).json();l.success?(ie(l.track),B()):w(l.error||"Failed to save lyrics")}catch{w("Failed to save lyrics. Please try again.")}finally{$(!1)}}},[V,Ee]=t.useState(!1),[$e,y]=t.useState(""),[x,ys]=t.useState({genres:[],stylesByGenre:{},moods:[]}),[ks,bs]=t.useState(!0),[Ze,Q]=t.useState(null),[ne,a]=t.useState(""),[i,f]=t.useState("Auto (Recommended)"),[Oe,S]=t.useState(""),[C,Qe]=t.useState(""),[hs,Ms]=t.useState(""),[Ne,ws]=t.useState("Motivational"),[n,Be]=t.useState("song"),[us,Ss]=t.useState("singing"),[I,Cs]=t.useState("generate"),[aa,La]=t.useState("source1"),[Ts,Us]=t.useState(!1),[Re,Ds]=t.useState(!0),[es,zs]=t.useState("standard"),[Bs,Ws]=t.useState(!1),[_s,Ys]=t.useState("");let ms={};try{ms=JSON.parse(localStorage.getItem("user")||"{}")}catch{}const[ue,Ge]=t.useState(""),[H,ye]=t.useState(""),[ga,fa]=t.useState(null),[ta,na]=t.useState(""),[Pe,ke]=t.useState(!1),[Vs,As]=t.useState(null),[Fa,Ma]=t.useState(null),[Hs,la]=t.useState([]),[ss,Ks]=t.useState(null),[as,ra]=t.useState("pending"),[ca,ia]=t.useState(!1),[Is,qs]=t.useState(null),[xa,Js]=t.useState(null),[Xs,Zs]=t.useState(null);t.useEffect(()=>{(async()=>{try{const l=await(await fetch(`${A}/api/taxonomy/all`)).json();if(l.genres&&l.moods&&(ys({genres:l.genres,stylesByGenre:l.stylesByGenre||{},moods:l.moods}),l.genres.length>0&&(Q(l.genres[0].id),a(l.genres[0].name)),l.moods.length>0)){const o=l.moods.find(j=>j.slug==="motivational");ws(o?o.name:l.moods[0].name)}}catch(r){console.error("Failed to load taxonomy:",r)}finally{bs(!1)}})()},[]);const ps=Ze&&x.stylesByGenre[Ze]?x.stylesByGenre[Ze]:[];t.useEffect(()=>{const s=localStorage.getItem("token");fetch(`${A}/api/avatars/${d}`,{headers:{Authorization:`Bearer ${s}`}}).then(r=>{if(!r.ok)throw new Error(`avatar request failed: HTTP ${r.status}`);return r.json()}).then(r=>{ts(r.avatar),r.avatar?.voice_type&&Ss(r.avatar.voice_type),Ws(String(r.avatar?.music_model||"").toUpperCase()==="V6_WILD")}).catch(r=>{console.error("[CreateTrack] avatar load failed:",r),y("Failed to load avatar")})},[d]),t.useEffect(()=>{const s=localStorage.getItem("token");fetch(`${A}/api/tracks/avatar/${d}`,{headers:{Authorization:`Bearer ${s}`}}).then(r=>r.ok?r.json():{tracks:[]}).then(r=>{const l=Array.isArray(r.tracks)?r.tracks:[];xe(l.filter(o=>o.title&&o.audio_url&&(o.status==="released"||o.status==="ready")&&(o.generation_source==="
3kieai"||!o.generation_source)))}).catch(()=>xe([]))},[d]);const Qs=async()=>{if(!C.trim()){y("Please enter a song concept");return}Ee(!0),y("");try{const s=localStorage.getItem("token"),l=await(await fetch(`${A}/api/tracks/generate-lyrics`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify({avatar_id:parseInt(d),genre:ne,style:i==="Auto (Recommended)"?"":i,concept:C,theme:hs,mood:Ne,targetLength:es,voiceType:us,lyricSource:aa})})).json();l.success?(Ge(l.title),ye(l.lyrics),fa(l.bpmHint||null),X(2)):y(l.error||"Failed to generate lyrics")}catch{y("Failed to generate lyrics")}finally{Ee(!1)}},ea=async()=>{if(!C.trim()){y("Please enter a script concept");return}Ee(!0),y("");try{const s=localStorage.getItem("token"),l=await(await fetch(`${A}/api/tracks/generate-script`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify({avatar_id:parseInt(d),concept:C,audioType:n,mood:Ne})})).json();l.success?(Ge(l.title),ye(l.script),X(2)):y(l.error||"Failed to generate script")}catch{y("Failed to generate script")}finally{Ee(!1)}},va=async()=>{Ee(!0),y("");try{const s=localStorage.getItem("token"),l=await(await fetch(`${A}/api/tracks/regenerate-lyrics`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify({avatar_id:parseInt(d),genre:ne,style:i==="Auto (Recommended)"?"":i,concept:C,theme:hs,mood:Ne,previousLyrics:H,feedback:ta})})).json();l.success?(Ge(l.title),ye(l.lyrics),na("")):y(l.error||"Failed to regenerate lyrics")}catch{y("Failed to regenerate lyrics")}finally{Ee(!1)}},be=async(s={})=>{const{useBackupProvider:r=!1}=s;ke(!0),y(""),la([]),ra("pending"),Ks(null);try{const l=localStorage.getItem("token"),j={short:60,standard:180,extended:300}[es]||180;let T=ue.trim();const ee=["instrumental","spoken_word","narration"].includes(n),q=T.length>60||T.toLowerCase().includes("track")||T.toLowerCase().includes("song")||T.split(/\s+/).length>8;ee&&(!T||q)&&(T=C.trim().split(/\s+/).slice(0,4).map(k=>k.charAt(0).toUpperCase()+k.slice(1).toLowerCase()).join(" "),T=T.replace(/[.,!?;:]+$/,""),Ge(T));let me=Vs;if(!me){const k=await(await fetch(`${A}/api/tracks`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`},body:JSON.stringify({avatar_id:parseInt(d),title:T||ue,genre:ne,generation_source:"mureka",generation_prompt:C})})).json();if(!k.success)throw new Error(k.error||"Failed to create track");me=k.track.track_id,As(me)}const pe=me,ge=n==="song"?H:["spoken_word","narration"].includes(n)?H||C:void 0;X(3);try{const c=new AbortController,k=setTimeout(()=>c.abort(),18e4),We=await fetch(`${A}/api/tracks/${pe}/generate-music`,{method:"POST",signal:c.signal,headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`},body:JSON.stringify({lyrics:n==="song"?H:void 0,script:["spoken_word","narration"].includes(n)?ge:void 0,title:ue,genre:ne,style:i==="Auto (Recommended)"?"":i,vocalStyles:Oe,mood:Ne,audioType:n,voiceType:n==="song"?us:void 0,lyricSource:n==="song"?aa:void 0,lyricsAuthor:I==="write"?"user":void 0,useMurekaVoice:n==="song"&&Ts?!0:void 0,includeBackgroundMusic:n==="spoken_word"?Re:void 0,durationSeconds:j,targetLength:es,bpmHint:ga,wild:!!Bs,negativeTags:_s.trim()||void 0,stylePersonaSourceTrackId:L||void 0,useBackupProvider:r||void 0})});clearTimeout(k);const b=await We.json();if(b.success&&b.all_track_ids&&b.all_track_ids.length>1){console.log("Multi-track creation complete:",b.all_track_ids),ke(!1),g&&N?N():P();return}if(b.success&&b.track_id){console.log("Single track creation complete:",b.track_id),ke(!1),b.fallbackProvider&&Js({provider:b.fallbackProvider}),g&&N?N():P();return}if(!We.ok||b.error){if(b.code==="ALREADY_GENERATING"){ke(!1),g&&N?N():P();return}b.code==="PRIMARY_PROVIDER_FAILED"?Zs({credits:b.creditsRefunded}):b.creditsRefunded?qs({credits:b.creditsRefunded,error:b.error||"Generation failed"}):y(b.error||"Generation failed"),As(null),ke(!1),X(2);return}}catch(c){if(console.error("Music generation error:",c),c.name==="AbortError"){ke(!1),As(null),g&&N?N():P();return}y("Generation failed. Please try again."),As(null),ke(!1),X(2);return}const Le=setInterval(async()=>{try{const k=await(await fetch(`${A}/api/tracks/${pe}/generation-status`,{headers:{Authorization:`Bearer ${l}`}})).json();k.success&&(ra(k.status),k.variations&&k.variations.length>0&&(la(k.variations),ss===null&&Ks(0)),k.status==="complete"&&(clearInterval(Le),ke(!1),g&&N?N():P()))}catch(c){console.error("Poll error:",c)}},3e3);return()=>clearInterval(Le)}catch(l){y(l.message),ke(!1)}},ja=async()=>
3{if(!(ss===null||!Vs)){ia(!0);try{const s=localStorage.getItem("token"),l=await(await fetch(`${A}/api/tracks/${Vs}/select-variation`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify({variationIndex:ss})})).json();l.success?g&&N?N():P():y(l.error||"Failed to select variation")}catch(s){y(s.message)}finally{ia(!1)}}};if(t.useEffect(()=>{Fe&&(Ce(!1),te("form"),be())},[Fe]),t.useEffect(()=>{const s=localStorage.getItem("token");if(!s){Me([]);return}let r=!1;return fetch(`${A}/api/inbox/my-avatars`,{headers:{Authorization:`Bearer ${s}`}}).then(l=>l.ok?l.json():{avatars:[]}).then(l=>{r||Me(l.avatars||[])}).catch(()=>{r||Me([])}),()=>{r=!0}},[]),t.useEffect(()=>{if(!le)return;const s=r=>{h.current&&!h.current.contains(r.target)&&Ue(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[le]),!p||ks)return e.jsx("div",{className:`create-track-page ${g?"embedded":""}`,children:e.jsx("div",{className:"loading",children:"Loading..."})});const oa=e.jsx(Ta,{isOpen:!!ae,onClose:()=>D(null),reason:ae?.reason,secondaryActionText:ae?.upload?"Upload a Track Instead":void 0,onSecondaryAction:ae?.upload?()=>{D(null),w(""),ie(null),ve("upload"),te("form")}:void 0}),Na=s=>{ve("song"),Be("song"),Cs("generate"),Qe("Surprise me â pick a theme that fits my style and vibe."),Ce(!0)};if(Z==="home"&&!g){const s=(o,j)=>`linear-gradient(135deg, ${pa(o,.55)}, ${pa(j,.4)})`,r=(p.name||"your artist").split(/\s+/)[0];M[0]?.title;const l=({cls:o,bg:j,title:T,desc:ee,badge:q,onClick:me,flex:pe,locked:ge})=>e.jsxs("div",{className:`cth-card ${o}${ge?" cth-card--locked":""}`,style:pe?{flex:pe}:void 0,role:"button",tabIndex:0,onClick:ge?()=>W(T):me,onKeyDown:Le=>{(Le.key==="Enter"||Le.key===" ")&&(Le.preventDefault(),(ge?()=>W(T):me)())},children:[e.jsx("div",{className:"cth-card-media",style:{background:j}}),e.jsx("div",{className:"cth-card-scrim"}),ge?e.jsxs("span",{className:"cth-badge cth-badge--locked",children:[e.jsx(u,{name:"lock",size:10})," PAID PLAN"]}):q&&e.jsx("span",{className:"cth-badge",children:q}),e.jsxs("div",{className:"cth-card-body",children:[e.jsx("div",{className:"cth-card-title",children:T}),e.jsx("div",{className:"cth-card-desc",children:ee})]})]});return e.jsxs("div",{className:"cth",children:[Te.length>1&&e.jsx("div",{className:"cth-switcher-slot",children:e.jsxs("div",{className:"roster-switcher",ref:h,children:[e.jsxs("button",{type:"button",className:"roster-switcher-trigger",onClick:()=>Ue(o=>!o),"aria-expanded":le,"aria-haspopup":"menu",children:[e.jsx(u,{name:"repeat",size:13})," Switch ",e.jsx(u,{name:"chevron-down",size:10})]}),le&&e.jsx("div",{className:"roster-switcher-menu",role:"menu",children:e.jsx("div",{className:"roster-switcher-menu-scroll",children:Te.map(o=>{const j=String(o.avatar_id)===String(d);return e.jsxs("button",{type:"button",role:"menuitem",className:`roster-switcher-item${j?" is-active":""}`,onClick:()=>{Ue(!1),E(`/avatar/${o.avatar_id}/create-track`)},children:[e.jsx("span",{className:"roster-switcher-thumb",children:o.profile_image_url?e.jsx("img",{src:o.profile_image_url,alt:o.name||"Artist"}):e.jsx(u,{name:"user",size:14})}),e.jsx("span",{className:"roster-switcher-name",children:o.name}),j&&e.jsx(u,{name:"check",size:12})]},o.avatar_id)})})})]})}),e.jsxs("div",{className:"cth-head",children:[e.jsxs("div",{className:"cth-title",children:["Create ",e.jsx("span",{className:"cth-with",children:"with"})," ",e.jsx("span",{className:"cth-artist",children:p.name})]}),e.jsx("div",{className:"cth-sub",children:'Every way in â from "just go" to full control.'})]}),U?e.jsx("div",{className:"cth-row",children:l({cls:"cth-ar-16-9",bg:s("#2a2140","#4a2a6a"),locked:!0,title:`Write with ${r}`,desc:"Talk it through together and they produce the track.",flex:"1 1 100%"})}):e.jsx(Ea,{avatar:p,avatarId:d,avatarTracks:M,token:localStorage.getItem("token"),firstName:r,fullWidth:!0}),e.jsxs("div",{className:"cth-row",children:[l({cls:"cth-ar-4-3",bg:s("#6a4a1a","#b0802a"),title:"Surprise me",desc:`${r} picks everything â you hear it first.`,badge:"1-CLICK",locked:U,onClick:()=>Na()}),l({cls:"cth-ar-1-1",bg:s("#1c3a5a","#2a6a8a"),title:"Full form",desc:"Every dial â audio type, styles, your own lyrics.",badge:"OPENS FORM",locked:U,onClick:()=>{ve("song"),te("form")}}),l({cls:"cth-ar-1-1",bg:s("#2a2140","#4a2a6a"),title:"Upload a track",desc:"Bring your own MP3 and add it to this artist.",badge:"UPLOAD",onClick:()=>{ve("upload"),te("form")}})]}),!1,(()=>{const o=()=>se?W("Automation",{plan:!0}):E(`/avatar/${d}/automation`);return e.jsxs("div",{className:`cth-automate${se?" is-locked":""}`,role:"button",tabIndex:0,onClick:o,onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),o())},children:[e.jsx("span",{className:"cth-automate-icon",children:se?"ð":"ð"}),e.jsxs("div",{className:"cth-automate-body",children:[e.jsx("b",{children:"Automate"}),e.jsx("span",{children:"Schedules, house rules and consent live on the Automations page"})]}),e.jsx("span",{className:"cth-automate-cta",children:se?"Paid plans â":"Open Automations â"})]})})(),oa,z&&e.jsx(Es,{isOpen:z,onClose:()=>O(!1),avatarId:d,avatarName:p.name,avatarImage:p.profile_image_url,token:localStorage.getItem("token"),user:ms,isFollowing:!0,isOwner:!0})]})}if(_==="song"&&F===1&&!g&&Se.get("v2")==="1"){const s=I==="write"&&["song","spoken_word","narration"].includes(n)?be:n==="song"?Qs:n==="instrumental"?be:ea,r=I==="write"&&["song","spoken_word","narration"].includes(n),l=V||Pe||(r?!ue.trim()||!H.trim():!C.trim()),o=V?"Generatingâ¦":Pe?"Creating Trackâ¦":r?"Generate Track":n==="song"?"Generate Lyrics":n==="instrumental"?"Generate Track":n==="spoken_word"?"Generate Script":"Generate Narration";return e.jsxs(e.Fragment,{children:[e.jsx(Pa,{avatar:p,error:$e,onBack:()=>te("home"),onCancel:()=>E(`/avatar/${d}/channel`),onOpenChat:()=>O(!0),audioType:n,setAudioType:Be,targetLength:es,setTargetLength:zs,songLengths:sa,includeBackgroun
3dMusic:Re,setIncludeBackgroundMusic:Ds,lyricsMode:I,setLyricsMode:Cs,concept:C,setConcept:Qe,theme:hs,setTheme:Ms,title:ue,setTitle:Ge,lyrics:H,setLyrics:ye,taxonomy:x,genre:ne,setGenre:a,setSelectedGenreId:Q,onGenreChange:j=>{const T=j.target.value,ee=x.genres.find(q=>q.name===T);if(ee)Q(ee.id),a(ee.name),f("Auto (Recommended)"),["Electronic","Jazz","Classical"].includes(ee.name)&&Be("instrumental");else for(const q of x.genres){const pe=(x.stylesByGenre[q.id]||[]).find(ge=>ge.name===T);if(pe){Q(q.id),a(q.name),f(pe.name);break}}},mood:Ne,setMood:ws,style:i,setStyle:f,currentStyles:ps,voiceType:us,setVoiceType:Ss,useMurekaVoice:Ts,setUseMurekaVoice:Us,vocalStyles:Oe,setVocalStyles:S,negativeTags:_s,setNegativeTags:Ys,avatarTracks:M,stylePersonaSourceTrackId:L,setStylePersonaSourceTrackId:we,wild:Bs,setWild:Ws,onGenerate:s,generateDisabled:l,ctaLabel:o}),z&&p&&e.jsx(Es,{isOpen:z,onClose:()=>O(!1),avatarId:d,avatarName:p.name,avatarImage:p.profile_image_url,token:localStorage.getItem("token"),user:ms,isFollowing:!0,isOwner:!0})]})}if(_==="song"&&F===1&&!g){const s=[{value:"song",icon:"microphone",label:"Song (Vocals)",sub:"Full track with vocals & lyrics"},{value:"instrumental",icon:"piano-keyboard",label:"Instrumental",sub:"No vocals â pure production"},{value:"spoken_word",icon:"comment-dots",label:"Spoken Word",sub:"Scripted delivery over music"},{value:"narration",icon:"book-open",label:"Narration",sub:"Voice only â no music"}],r=["song","spoken_word","narration"].includes(n),l=I==="write"&&r,o=n==="song"||n==="instrumental"||n==="spoken_word"&&Re,j=!l,T=L?M.find(c=>String(c.track_id)===String(L)):null,ee=T&&!T.style_persona_id,q=c=>{const k=c.target.value,We=x.genres.find(b=>b.name===k);if(We)Q(We.id),a(We.name),f("Auto (Recommended)"),["Electronic","Jazz","Classical"].includes(We.name)&&Be("instrumental");else for(const b of x.genres){const da=(x.stylesByGenre[b.id]||[]).find(ya=>ya.name===k);if(da){Q(b.id),a(b.name),f(da.name);break}}},me=l?be:n==="song"?Qs:n==="instrumental"?be:ea,pe=V||Pe||(l?!ue.trim()||!H.trim():!C.trim()),ge=V?"Generatingâ¦":Pe?"Creating Trackâ¦":l?"Generate Track":n==="song"?"Generate Lyrics":n==="instrumental"?"Generate Track":n==="spoken_word"?"Generate Script":"Generate Narration",Le=l||n==="instrumental"?"music":n==="song"?"pen":n==="spoken_word"?"comment-dots":"book-open";return e.jsxs("div",{className:"create-track-page ctf",children:[e.jsxs("div",{className:"ctf-head",children:[e.jsx("button",{type:"button",className:"ctf-back",onClick:()=>te("home"),"aria-label":"Back to create options",children:e.jsx(u,{name:"arrow-left",size:15})}),e.jsxs("div",{className:"ctf-title",children:["Full form ",e.jsx("span",{className:"ctf-for",children:"for"})," ",e.jsx("span",{className:"ctf-artist",children:p.name})]})]}),$e&&e.jsx("div",{className:"error-message",children:$e}),e.jsx("div",{className:"ctf-kicker",children:"AUDIO TYPE"}),e.jsx("div",{className:"ctf-atypes",children:s.map(c=>e.jsxs("button",{type:"button",className:`ctf-atype ${n===c.value?"is-active":""}`,onClick:()=>Be(c.value),children:[e.jsxs("span",{className:"ctf-atype-top",children:[e.jsx("span",{className:"ctf-atype-icon",children:e.jsx(u,{name:c.icon,size:15})}),e.jsx("span",{className:"ctf-atype-label",children:c.label})]}),e.jsx("span",{className:"ctf-atype-sub",children:c.sub})]},c.value))}),e.jsxs("div",{className:"ctf-panel",children:[e.jsxs("div",{className:"ctf-grid",children:[n==="song"&&e.jsxs("div",{className:"ctf-field",children:[e.jsx("label",{className:"ctf-label",children:"VOCAL STYLE"}),e.jsxs("select",{className:"ctf-select",value:us,onChange:c=>Ss(c.target.value),children:[e.jsx("option",{value:"singing",children:"Singing"}),e.jsx("option",{value:"rapping",children:"Rapping"})]})]}),n!=="instrumental"&&e.jsxs("div",{className:"ctf-field",children:[e.jsx("label",{className:"ctf-label",children:n==="song"?"LYRICS SOURCE":"SCRIPT SOURCE"}),e.jsxs("select",{className:"ctf-select",value:I,onChange:c=>Cs(c.target.value),children:[e.jsx("option",{value:"generate",children:"AI-Generated"}),e.jsx("option",{value:"write",children:"Write My Own"})]})]}),n==="spoken_word"&&e.jsxs("div",{className:"ctf-field",children:[e.jsx("label",{className:"ctf-label",children:"BACKGROUND MUSIC"}),e.jsxs("label",{className:"ctf-check",children:[e.jsx("input",{type:"checkbox",checked:Re,onCh
3ange:c=>Ds(c.target.checked)})," Include music"]})]}),e.jsxs("div",{className:"ctf-field",children:[e.jsxs("label",{className:"ctf-check",children:[e.jsx("input",{type:"checkbox",checked:Bs,onChange:c=>Ws(c.target.checked)})," ","Take a bigger risk"]}),e.jsx("div",{className:"ctf-hint",children:"Experimental: bigger creative swings, so quality varies from song to song. For the most reliable results, turn it on only when you want something unexpected."})]}),j&&e.jsxs("div",{className:"ctf-field",children:[e.jsx("label",{className:"ctf-label",children:"TRACK LENGTH"}),e.jsx("select",{className:"ctf-select",value:es,onChange:c=>zs(c.target.value),children:sa.map(c=>e.jsx("option",{value:c.value,children:c.label},c.value))})]}),o&&e.jsxs("div",{className:"ctf-field",children:[e.jsx("label",{className:"ctf-label",children:"MOOD"}),e.jsx("select",{className:"ctf-select",value:Ne,onChange:c=>ws(c.target.value),children:x.moods.map(c=>e.jsx("option",{value:c.name,children:c.name},c.id))})]}),o&&e.jsxs("div",{className:"ctf-field",children:[e.jsx("label",{className:"ctf-label",children:"GENRE"}),e.jsx("select",{className:"ctf-select",value:ne||"",onChange:q,children:x.genres.map(c=>e.jsxs("optgroup",{label:c.name,children:[e.jsx("option",{value:c.name,children:c.name}),(x.stylesByGenre[c.id]||[]).filter(k=>k.slug!=="auto").map(k=>e.jsx("option",{value:k.name,children:k.name},k.id))]},c.id))})]}),o&&e.jsxs("div",{className:"ctf-field",children:[e.jsx("label",{className:"ctf-label",children:"STYLE"}),e.jsx("select",{className:"ctf-select",value:i,onChange:c=>f(c.target.value),children:ps.length===0?e.jsx("option",{value:"Auto (Recommended)",children:"Auto (Recommended)"}):ps.map(c=>e.jsx("option",{value:c.name,children:c.name},c.id))})]}),M.length>0&&(n==="song"||n==="instrumental")&&e.jsxs("div",{className:"ctf-field",children:[e.jsxs("label",{className:"ctf-label",children:["REFERENCE TRACK ",e.jsx("span",{className:"ctf-opt",children:"(OPTIONAL)"})]}),e.jsxs("select",{className:"ctf-select",value:L,onChange:c=>we(c.target.value),children:[e.jsx("option",{value:"",children:"â None (Default) â"}),M.map(c=>e.jsxs("option",{value:c.track_id,children:['Same vibe as⦠"',c.title,'"']},c.track_id))]}),ee&&e.jsx("div",{className:"ctf-warn",children:"â±ï¸ First use of this track as a style source may take a few extra minutes while we prepare the style. After that, copying it is instant."})]}),n==="song"&&p?.mureka_voice_id&&e.jsxs("div",{className:"ctf-field",children:[e.jsx("label",{className:"ctf-label",children:"VOICE"}),e.jsxs("label",{className:"ctf-check",children:[e.jsx("input",{type:"checkbox",checked:Ts,onChange:c=>Us(c.target.checked)})," Use my uploaded voice"]})]}),(n==="song"||n==="instrumental")&&e.jsxs("div",{className:"ctf-field ctf-full",children:[e.jsx("label",{className:"ctf-label",children:"EXCLUDE FROM GENERATION"}),e.jsx("input",{className:"ctf-input",type:"text",value:_s,onChange:c=>Ys(c.target.value),placeholder:"e.g. autotune, mumble rap, choir, guitar solo"})]})]}),o&&e.jsx("div",{className:"ctf-block",children:e.jsx(ha,{value:Oe,onChange:S,avatarVocalStyle:p?.vocal_style||"",genre:ne,mood:Ne})}),(n!=="song"||l)&&e.jsxs("div",{className:"ctf-block ctf-field ctf-full",children:[e.jsx("label",{className:"ctf-label",children:l?"TITLE *":"TRACK TITLE (OPTIONAL)"}),e.jsx("input",{className:"ctf-input",type:"text",value:ue,onChange:c=>Ge(c.target.value),placeholder:l?n==="song"?"What's your song called?":"Give your piece a title":"Leave blank to auto-generate from concept"})]}),l&&n==="song"?e.jsxs("div",{className:"ctf-block ctf-field ctf-full",children:[e.jsx("label",{className:"ctf-label",children:"LYRICS *"}),e.jsx("textarea",{className:"ctf-textarea ctf-writebody",value:H,onChange:c=>ye(c.target.value),placeholder:`Paste your lyrics here. Use section tags like [Verse 1], [Chorus], [Bridge] to mark structure. 4 5Example: 6[Verse 1] 7First line of your verse... 8 9[Chorus] 10First line of your chorus...`}),e.jsx("span",{className:"ctf-hint",children:"Tip: use section tags like [Verse 1], [Chorus], [Bridge] to guide the song structure."})]}):l&&["spoken_word","narration"].includes(n)?e.jsxs("div",{className:"ctf-block ctf-field ctf-full",children:[e.jsx("label",{className:"ctf-label",children:"SCRIPT *"}),e.jsx("textarea",{className:"ctf-textarea ctf-writebody",value:H,onChange:c=>ye(c.target.value),placeholder:n==="spoken_word"?"Paste your script here. You can include performance tags like [calm], [intense], or [short pause] to guide delivery.":"Paste your narration script here. Keep it clear and conversational."}),n==="spoken_word"&&e.jsx("span",{className:"ctf-hint",children:"Tip: use performance tags like [calm], [intense], or [short pause] to control delivery."})]}):e.jsxs("div",{className:"ctf-block ctf-field ctf-full",children:[e.jsx("label",{className:"ctf-label",children:["spoken_word","narration"].includes(n)?"SCRIPT CONCEPT *":"SONG CONCEPT *"}),e.jsx("textarea",{className:"ctf-textarea ctf-concept",value:C,onChange:c=>Qe(c.target.value),rows:3,placeholder:["spoken_word","narration"].includes(n)?"What's the script about? e.g., 'A motivational message about perseverance'":"What's the song about? e.g., 'Overcoming struggle and rising to success'"})]}),n==="song"&&I==="generate"&&e.jsxs("div",{className:"ctf-block ctf-field ctf-full",children:[e.jsx("label",{className:"ctf-label",children:"THEME (OPTIONAL)"}),e.jsx("input",{className:"ctf-input",type:"text",value:hs,onChange:c=>Ms(c.target.value),placeholder:"e.g., 'Late night grind', 'Missing someone'"})]})]}),e.jsxs("div",{className:"ctf-foot",children:[e.jsx("button",{type:"button",className:"ctf-cancel",onClick:()=>E(`/avatar/${d}/channel`),children:"Cancel"}),e.jsxs("button",{type:"button",className:"ctf-chatlink",onClick:()=>O(!0),children:[e.jsx(u,{name:"wand-magic-sparkles",size:12})," Do this in chat instead"]}),e.jsxs("button",{type:"button",className:"ctf-cta",onClick:me,disabled:pe,children:[e.jsx(u,{name:Le,size:14})," ",ge]})]}),z&&p&&e.jsx(Es,{isOpen:z,onClose:()=>O(!1),avatarId:d,avatarName:p.name,avatarImage:p.profile_image_url,token:localStorage.getItem("token"),user:ms,isFollowing:!0,isOwner:!0})]})}return e.jsxs("div",{className:`create-track-page ${g?"embedded":""}`,children:[!g&&e.jsxs("div",{className:"create-track-header",children:[e.jsxs("button",{type:"button",className:"ct-back",onClick:()=>E(`/avatars?artist=${d}`),"aria-label":"Back to your artists",children:[e.jsx(u,{name:"arrow-left",size:16})," Back"]}),e.jsx("h1",{children:"Create Track"}),e.jsxs("p",{children:["for ",e.jsx("strong",{children:p.name})]})]}),!g&&e.jsxs("div",{className:"ct-mode-toggle",role:"tablist","aria-label":"What to add",children:[e.jsxs("button",{type:"button",role:"tab","aria-selected":_==="song",className:`ct-mode-btn ${_==="song"?"is-active":""}${U?" is-locked":""}`,onClick:()=>U?W("Song generation"):ve("song"),children:[e.jsx(u,{name:U?"lock":"music",size:15})," Create Song"]}),e.jsxs("button",{type:"button",role:"tab","aria-selected":_==="upload",className:`ct-mode-btn ${_==="upload"?"is-active":""}`,onClick:()=>{ve("upload"),w(""),ie(null)},children:[e.jsx(u,{name:"upload",size:15})," Upload Track"]}),e.jsxs("button",{type:"button",role:"tab","aria-selected":z,className:`ct-mode-btn ${z?"is-active":""}${U?" is-locked":""}`,onClick:()=>U?W("Collaborating on a song"):O(!0),children:[e.jsx(u,{name:U?"lock":"comments",size:15})," Collaborate"]})]}),oa,z&&p&&e.jsx(Es,{isOpen:z,onClose:()=>O(!1),avatarId:d,avatarName:p.name,avatarImage:p.profile_image_url,token:localStorage.getItem("token"),user:ms,isFollowing:!0,isOwner:!0}),_==="song"&&e.jsxs("div",{className:"step-indicator",children:[e.jsxs("div",{className:`step ${F>=1?"active":""} ${F>1?"completed":""}`,children:[e.jsx("span",{className:"step-number",children:"1"}),e.jsx("span",{className:"step-label",children:"Setup"})]}),e.jsx("div",{className:"step-line"}),e.jsxs("div",{className:`step ${F>=2?"active":""} ${F>2?"completed":""}`,children:[e.jsx("span",{className:"step-number",children:"2"}),e.jsx("span",{className:"step-label",children:"Lyrics"})]}),e.jsx("div",{className:"step-line"}),e.jsxs("div",{className:`step ${F>=3?"active":""}`,children:[e.jsx("span",{className:"step-number",children:"3"}),e.jsx("span",{className:"step-label",children:"Complete"})]})]}),$e&&_==="song"&&e.jsx("div",{className:"error-message",children:$e}),_==="upload"&&e.jsxs("div",{className:"step-content",children:[e.jsxs("h2",{children:[e.jsx(u,{name:"upload",size:20,color:"#f97316"})," Upload a Track"]}),e.jsxs("p",{className:"step-description",children:["Upload an existing MP3 to ",p.name,"'s catalog."]}),ls?e.jsxs("div",{className:"ct-youtube-done",children:[e.jsx("div",{className:"nsfw-modal-icon",children:"â "}),e.jsx("h3",{children:"Track uploaded!"}),e.jsxs("p",{children:['"',ls.title,'" is now in ',p.name,"'s catalog."]}),e.jsxs("div",{className:"step-actions",children:[e.jsx("button",{className:"btn btn-secondary",onClick:()=>{ie(null),B()},children:"Upload another"}),e.jsx("button",{className:"btn btn-primary",onClick:()=>P(),children:"View tracks"})]})]}):oe?e.jsxs("div",{className:"upload-lyrics-review",children:[e.jsxs("h3",{children:[e.jsx(u,{name:"pen",size:16,color:"#f97316"})," Review the lyrics"]}),e.jsx("p",{className:"step-description",children:je?"No vocals were detected â this looks like an instrumental. Add lyrics below if thatâs not right, or finish as-is.":"We pulled these from your track. Edit anything thatâs off, then save to finish."}),e.jsx("textarea",{className:"upload-lyrics-input",rows:14,placeholder:"No lyrics detected â you can type them here.",value:Ae,onChange:s=>re(s.target.value)}),ce&&e.jsx("div",{className:"error-message",children:ce}),e.jsxs("div",{className:"step-actions",children:[e.jsx("button",{className:"btn btn-secondary",disabled:ds,onClick:()=>{ie({title:G}),B()},children:"Finish without saving"}),e.jsx("button",{className:"btn btn-primary",disabled:ds,onClick:he,children:ds?"Savingâ¦":e.jsxs(e.Fragment,{children:[e.jsx(u,{name:"check",size:16})," Save lyrics & finish"]})})]})]}):e.jsxs("form",{className:`upload-track-form ${He?"dragging":""}`,onSubmit:Ps,onDragOver:Os,onDragLeave:Rs,onDrop:Gs,children:[He&&e.jsx("div",{className:"drop-overlay",children:e.jsxs("span",{children:[e.jsx(u,{name:"music",size:16})," Drop MP3 here"]})}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Audio file"}),e.jsxs("label",{className:"file-upload-btn",children:[e.jsx("input",{type:"file",accept:"audio/mpeg,audio/mp3,.mp3",onChange:s=>Ie(s.target.files?.[0]),style:{display:"none"}}),v?`ð ${v.name}`:"ðµ Choose or drop an MP3"]}),e.jsxs("span",{className:"ct-optional",children:["Max ",de,"MB"]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Track title"}),e.jsx("input",{type:"text",placeholder:"Track Title",value:G,onChange:s=>Y(s.target.value),required:!0})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Genre ",e.jsx("span",{className:"ct-optional",children:"(optional)"})]}),e.jsxs("select",{value:Ve,onChange:s=>_e(s.target.value),children:[e.jsx("option",{value:"",children:"Select a genre"}),(x.genres||[]).map(s=>e.jsxs("optgroup",{label:s.name,children:[e.jsx("option",{value:s.name,children:s.name}),(x.stylesByGenre?.[s.id]||[]).filter(r=>r.slug!=="auto").map(r=>e.jsx("option",{value:r.name,children:r.name},r.id))]},s.id))]})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Artwork ",e.jsx("span",{className:"ct-optional",children:"(optional)"})]}),e.jsxs("label",{className:"artwork-upload-btn",children:[e.jsx("input",{type:"file",accept:"image/*",onChange:s=>Je(s.target.files?.[0]),style:{display:"none"}}
10),xs?e.jsx("img",{src:xs,alt:"Artwork preview",className:"artwork-preview"}):e.jsx("span",{children:"ð¼ï¸ Add artwork"})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Lyrics ",e.jsx("span",{className:"ct-optional",children:"(optional)"})]}),e.jsx("textarea",{className:"upload-lyrics-input",rows:6,placeholder:"Paste the lyrics here â or leave blank and we'll offer to pull them from the audio for you to review.",value:Ae,onChange:s=>re(s.target.value)})]}),e.jsxs("label",{className:"ct-rights-check",children:[e.jsx("input",{type:"checkbox",checked:ns,onChange:s=>js(s.target.checked)}),e.jsx("span",{children:"I confirm I own or have rights to upload this music"})]}),ce&&e.jsx("div",{className:"error-message",children:ce}),e.jsx("div",{className:"step-actions",children:e.jsx("button",{type:"submit",className:"btn btn-primary",disabled:De,children:De?"Uploadingâ¦":e.jsxs(e.Fragment,{children:[e.jsx(u,{name:"upload",size:16})," Upload Track"]})})})]})]}),cs&&e.jsx("div",{className:"nsfw-modal-overlay",onClick:()=>Ke(!1),children:e.jsxs("div",{className:"nsfw-modal",onClick:s=>s.stopPropagation(),children:[e.jsx("div",{className:"nsfw-modal-icon",children:"ð¤"}),e.jsx("h3",{children:"No lyrics added"}),e.jsx("p",{children:"Want us to analyze your track and pull the lyrics from the audio, so you can review and edit them before finishing?"}),e.jsxs("div",{className:"step-actions",children:[e.jsx("button",{className:"btn btn-secondary",disabled:De,onClick:Ls,children:"Upload without lyrics"}),e.jsxs("button",{className:"btn btn-primary",disabled:De,onClick:Fs,children:[e.jsx(u,{name:"wand-magic-sparkles",size:16})," Analyze & review"]})]})]})}),qe&&e.jsx("div",{className:"nsfw-modal-overlay",children:e.jsxs("div",{className:"nsfw-modal",onClick:s=>s.stopPropagation(),children:[e.jsx("div",{className:"nsfw-modal-icon",children:e.jsx(u,{name:"spinner",size:28,spin:!0})}),e.jsx("h3",{children:"Analyzing your trackâ¦"}),e.jsx("p",{children:"Uploading and pulling the lyrics from the audio. This can take up to a minute."})]})}),Is&&e.jsx("div",{className:"nsfw-modal-overlay",onClick:()=>qs(null),children:e.jsxs("div",{className:"nsfw-modal",onClick:s=>s.stopPropagation(),children:[e.jsx("div",{className:"nsfw-modal-icon",children:"ð³"}),e.jsx("h3",{children:"Credits Refunded"}),e.jsxs("p",{children:["Music generation encountered an error, but don't worry â your ",e.jsxs("strong",{children:[Is.credits," credit",Is.credits!==1?"s have":" has"]})," been refunded to your account."]}),e.jsxs("p",{className:"nsfw-reason",children:["Error: ",Is.error]}),e.jsx("button",{className:"nsfw-dismiss-btn",onClick:()=>qs(null),children:"Got It"})]})}),Xs&&e.jsx("div",{className:"nsfw-modal-overlay",children:e.jsxs("div",{className:"nsfw-modal",onClick:s=>s.stopPropagation(),children:[e.jsx("div",{className:"nsfw-modal-icon",children:"â ï¸"}),e.jsx("h3",{children:"Music Engine Temporarily Unavailable"}),e.jsxs("p",{children:["Our primary music engine is experiencing issues right now. Your ",e.jsxs("strong",{children:[Xs.credits," credit",Xs.credits!==1?"s have":" has"]})," been refunded."]}),e.jsxs("p",{style:{fontSize:"0.9rem",color:"var(--text-muted)",marginTop:"0.5rem"},children:["You can try again later for best quality, or use our backup engine now. Note: the backup engine uses a generic AI voice and ",e.jsx("strong",{children:"will not"})," use your avatar's trained voice persona."]}),e.jsxs("div",{style:{display:"flex",gap:"10px",marginTop:"1rem",justifyContent:"center"},children:[e.jsx("button",{className:"nsfw-dismiss-btn",onClick:()=>{Zs(null)},children:"Try Later"}),e.jsx("button",{className:"nsfw-dismiss-btn",style:{background:"linear-gradient(135deg, #f59e0b, #d97706)"},onClick:()=>{Zs(null),be({useBackupProvider:!0})},children:"Use Backup Engine"})]})]})}),xa&&e.jsx("div",{className:"nsfw-modal-overlay",onClick:()=>Js(null),children:e.jsxs("div",{className:"nsfw-modal",onClick:s=>s.stopPropagation(),children:[e.jsx("div",{className:"nsfw-modal-icon",children:"ð"}),e.jsx("h3",{children:"Generated via Backup System"}),e.jsx("p",{children:"Your song was generated using our backup system. The quality may differ slightly from the usual output."}),e.jsx("button",{className:"nsfw-dismiss-btn",onClick:()=>Js(null),children:"Got It"})]})}),_==="song"&&F===1&&e.jsxs("div",{className:"step-content",children:[e.jsxs("h2",{children:[e.jsx(u,{name:"music",size:20,color:"#f97316"})," Song Setup"]}),e.jsxs("div",{className:"form-row",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Audio Type"}),e.jsxs("select",{value:n,onChange:s=>Be(s.target.value),children:[e.jsx("option",{value:"song",children:"ð¤ Song (Vocals)"}),e.jsx("option",{value:"instrumental",children:"ð¹ Instrumental"}),e.jsx("option",{value:"spoken_word",children:"ð£ï¸ Spoken Word Track"}),e.jsx("option",{value:"narration",children:"ð¢ Narration"})]})]}),n==="song"&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Vocal Style"}),e.jsxs("select",{value:us,onChange:s=>Ss(s.target.value),children:[e.jsx("option",{value:"singing",children:"ð¤ Singing"}),e.jsx("option",{value:"rapping",children:"ðï¸ Rapping"})]})]}),n!=="instrumental"&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:n==="song"?"Lyrics Source":"Script Source"}),e.jsxs("select",{value:I,onChange:s=>Cs(s.target.value),children:[e.jsx("option",{value:"generate",children:"⨠AI-Generated"}),e.jsx("option",{value:"write",children:"âï¸ Write My Own"})]})]}),n==="song"&&p?.mureka_voice_id&&e.jsxs("div",{className:"form-group checkbox-inline voice-clone-option",children:[e.jsx("span",{children:"ð¤ Voice"}),e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:Ts,onChange:s=>Us(s.target.checked)}),"Use My Uploaded Voice"]}),e.jsx("span",{className:"form-hint",children:"Uses your uploaded voice clone. Note: music quality may be lower than the default model."})]}),(n==="song"||n==="instrumental")&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Exclude from Generation"}),e.jsx("input",{type:"text",value:_s,onChange:s=>Ys(s.target.value),placeholder:"e.g. autotune, mumble rap, choir, guitar solo"}),e.jsx("span",{className:"form-hint",children:"Comma-separated elements to avoid in the generated track."})]}),n==="spoken_word"&&e.jsxs("div",{className:"form-group checkbox-inline",children:[e.jsx("span",{children:"Backgroun
10d Music"}),e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:Re,onChange:s=>Ds(s.target.checked)}),"Include music"]})]})]}),e.jsxs("div",{className:"form-row",children:[!(I==="write"&&["song","spoken_word","narration"].includes(n))&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Track Length"}),e.jsx("select",{value:es,onChange:s=>zs(s.target.value),children:sa.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))})]}),(n==="song"||n==="instrumental"||n==="spoken_word"&&Re)&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Mood"}),e.jsx("select",{value:Ne,onChange:s=>ws(s.target.value),children:x.moods.map(s=>e.jsx("option",{value:s.name,children:s.name},s.id))})]})]}),(n==="song"||n==="instrumental"||n==="spoken_word"&&Re)&&e.jsxs("div",{className:"form-row",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Genre"}),e.jsx("select",{value:ne||"",onChange:s=>{const r=s.target.value,l=x.genres.find(o=>o.name===r);if(l)Q(l.id),a(l.name),f("Auto (Recommended)"),["Electronic","Jazz","Classical"].includes(l.name)&&Be("instrumental");else for(const o of x.genres){const T=(x.stylesByGenre[o.id]||[]).find(ee=>ee.name===r);if(T){Q(o.id),a(o.name),f(T.name);break}}},children:x.genres.map(s=>e.jsxs("optgroup",{label:s.name,children:[e.jsx("option",{value:s.name,children:s.name}),(x.stylesByGenre[s.id]||[]).filter(r=>r.slug!=="auto").map(r=>e.jsx("option",{value:r.name,children:r.name},r.id))]},s.id))})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Style"}),e.jsx("select",{value:i,onChange:s=>f(s.target.value),children:ps.length===0?e.jsx("option",{value:"Auto (Recommended)",children:"Auto (Recommended)"}):ps.map(s=>e.jsx("option",{value:s.name,children:s.name},s.id))})]})]}),M.length>0&&(n==="song"||n==="instrumental")&&(()=>{const s=L?M.find(l=>String(l.track_id)===String(L)):null,r=s&&!s.style_persona_id;return e.jsxs("div",{className:"form-group full-width",children:[e.jsxs("label",{children:["Copy song style ",e.jsx("span",{className:"label-hint",style:{fontWeight:"normal",opacity:.6},children:"(optional â match the musical style of a past track)"})]}),e.jsxs("select",{value:L,onChange:l=>we(l.target.value),children:[e.jsx("option",{value:"",children:"â None (Default) â"}),M.map(l=>e.jsx("option",{value:l.track_id,children:l.title},l.track_id))]}),r&&e.jsx("div",{style:{marginTop:"6px",padding:"8px 10px",fontSize:"12px",lineHeight:1.4,background:"rgba(234, 179, 8, 0.08)",border:"1px solid rgba(234, 179, 8, 0.25)",borderRadius:"6px",color:"var(--text-secondary, #c5c5c5)"},children:"â±ï¸ Heads up â first use of this track as a style source may take a few extra minutes while we prepare the style. After that, any future generation copying this track is instant."})]})})(),(n==="song"||n==="instrumental"||n==="spoken_word"&&Re)&&e.jsx("div",{className:"form-group full-width",children:e.jsx(ha,{value:Oe,onChange:S,avatarVocalStyle:p?.vocal_style||"",genre:ne,mood:Ne})}),(n!=="song"||I==="write")&&e.jsxs("div",{className:"form-group full-width",children:[e.jsx("label",{children:I==="write"&&n==="song"?"Song Title *":I==="write"&&n==="spoken_word"||I==="write"&&n==="narration"?"Title *":"Track Title (optional)"}),e.jsx("input",{type:"text",value:ue,onChange:s=>Ge(s.target.value),placeholder:I==="write"?n==="song"?"What's your song called?":"Give your piece a title":"Leave blank to auto-generate from concept"})]}),n==="song"&&I==="write"?e.jsxs("div",{className:"form-group full-width",children:[e.jsx("label",{children:"Lyrics *"}),e.jsx("textarea",{value:H,onChange:s=>ye(s.target.value),placeholder:`Paste your lyrics here. Use section tags like [Verse 1], [Chorus], [Bridge] to mark structure. 11 12Example: 13[Verse 1] 14First line of your verse... 15Second line... 16 17[Chorus] 18First line of your chorus...`,rows:15,className:"lyrics-editor"}),e.jsxs("span",{className:"form-hint",children:["Tip: Use section tags like ",e.jsx("code",{children:"[Verse 1]"}),", ",e.jsx("code",{children:"[Chorus]"}),", ",e.jsx("code",{children:"[Bridge]"})," to help the music generator understand your song structure."]})]}):["spoken_word","narration"].includes(n)&&I==="write"?e.jsxs("div",{className:"form-group full-width",children:[e.jsx("label",{children:"Script *"}),e.jsx("textarea",{value:H,onChange:s=>ye(s.target.value),placeholder:n==="spoken_word"?`Paste your script here. You can include performance tags like [calm], [intense], or [short pause] to guide delivery. 19 20Example: 21[calm] 22The night was quiet, save for the distant hum of the city. 23 24[intense] 25And then everything changed.`:`Paste your narration script here. Keep it clear and conversational. 26 27Example: 28Welcome back to the show. Today we're going to explore...`,rows:15,className:"lyrics-editor"}),n==="spoken_word"&&e.jsxs("span",{className:"form-hint",children:["Tip: Use performance tags like ",e.jsx("code",{children:"[calm]"}),", ",e.jsx("code",{children:"[intense]"}),", or ",e.jsx("code",{children:"[short pause]"})," to control delivery."]})]}):e.jsxs("div",{className:"form-group full-width",children:[e.jsx("label",{children:["spoken_word","narration"].includes(n)?"Script Concept *":"Song Concept *"}),e.jsx("textarea",{value:C,onChange:s=>Qe(s.target.value),placeholder:["spoken_word","narration"].includes(n)?"What's the script about? e.g., 'A motivational message about perseverance'":"What's the song about? e.g., 'Overcoming struggle and rising to success'",rows:3})]}),n==="song"&&I==="generate"&&e.jsxs("div",{className:"form-group full-width",children:[e.jsx("label",{children:"Theme (optional)"}),e.jsx("input",{type:"text",value:hs,onChange:s=>Ms(s.target.value),placeholder:"e.g., 'Late night grind', 'Missing someone'"})]}),e.jsxs("div",{className:"step-actions",children:[e.jsx("button",{className:"btn-secondary",onClick:()=>E(`/avatar/${d}/channel`),children:"Cancel"}),e.jsx("button",{className:"btn-primary",onClick:I==="write"&&["song","spoken_word","narration"].includes(n)?be:n==="song"?Qs:n==="instrumental"?be:ea,disabled:V||Pe||(I==="write"&&["song","spoken_word","narration"].includes(n)?!ue.trim()||!H.trim():!C.trim()),children:V?"Generating...":Pe?"ðµ Creating Track...":I==="write"&&["song","spoken_word","narration"].includes(n)?"ðµ Generate Track":n==="song"?"âï¸ Generate Lyrics":n==="instrumental"?"ð¹ Generate Track":n==="spoken_word"?"ð£ï¸ Generate Script":"ð¢ Generate Narration"})]})]}),_==="song"&&F===2&&e.jsxs("div",{className:"step-content",children:[e.jsx("h2",{children:["spoken_word","narration"].includes(n)?e.jsxs(e.Fragment,{children:[e.jsx(u,{name:"pen",size:18,color:"#f97316"})," Edit Script"]}):e.jsxs(e.Fragment,{children:[e.jsx(u,{name:"pen",size:18,color:"#f97316"})," Edit Lyrics"]})}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Title"}),e.jsx("input",{type:"text",value:ue,onChange:s=>Ge(s.target.value),placeholder:["spoken_word","narration"].includes(n)?"Script title":"Song title"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:["spoken_word","narration"].includes(n)?"Script":"Lyrics"}),e.jsx("textarea",{value:H,onChange:s=>ye(s.target.value),rows:15,className:"lyrics-editor"}),n==="spoken_word"&&e.jsxs("small",{className:"form-hint",children:["ð¡ Tip: This script includes performance tags like ",e.jsx("code",{children:"[calm]"})," and ",e.jsx("code",{children:"[short pause]"}),". You can edit them."]})]}),e.jsxs("div",{className:"regenerate-section",children:[e.jsx("input",{type:"text",value:ta,onChange:s=>na(s.target.value),placeholder:"Optional: what should be different? e.g., 'Make it more upbeat'"}),e.jsx("button",{className:"btn-secondary",onClick:va,disabled:V,children:V?"...":"ð Regenerate"})]}),e.jsxs("div",{className:"step-actions",children:[e.jsx("button",{className:"btn-secondary",onClick:()=>X(1),children:"â Back"}),e.jsx("button",{className:"btn-primary",onClick:be,disabled:Pe||!H.trim(),children:Pe?"ðµ Generating Music...":"ðµ Create Song"})]})]}),_==="song"&&F===3&&e.jsxs("div",{className:"step-content variation-step",children:[e.jsxs("h2",{children:[e.jsx(u,{name:"music",size:20,color:"#f97316"})," Choose Your Track"]}),e.jsxs("p",{className:"step-description",children:[as==="pending"&&"Generating your track variations...",as==="first_ready"&&"First variation ready! Second one coming...",as==="complete"&&"Both variations ready! Preview and choose your favorite."]}),Hs.length===0&&e.jsxs("div",{className:"generating-spinner",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{children:"Creating your music..."}),e.jsx("small",{children:"This usually takes 2-3 minutes"})]}),e.jsxs("div",{className:"variation-cards",children:[Hs.map((s,r)=>e.jsxs("div",{className:`variation-card ${ss===r?"selected":""}`,onClick:()=>Ks(r),children:[e.jsxs("div",{className:"variation-header",children:[e.jsxs("span",{className:"variation-label",children:["Version ",r+1]}),ss===r&&e.jsx("span",{className:"selected-badge",children:"â Selected"})]}),e.jsx("div",{className:"variation-info",children:e.jsxs("span",{className:"variation-duration",children:[Math.floor(s.duration/60),":",String(Math.floor(s.duration%60)).padStart(2,"0")]})}),e.jsx("audio",{controls:!0,src:s.audioUrl,className:"variation-audio",onClick:l=>l.stopPropagation(),children:"Your browser does not support audio playback."})]},s.id)),Hs.length===1&&as!=="complete"&&e.jsxs("div",{className:"variation-card loading",children:[e.jsx("div",{className:"variation-header",children:e.jsx("span",{className:"variation-label",children:"Version 2"})}),e.jsxs("div",{className:"generating-mini",children:[e.jsx("div",{className:"spinner-small"}),e.jsx("span",{children:"Generating..."})]})]})]}),e.jsxs("div",{className:"step-actions",children:[e.jsx("button",{className:"btn-secondary",onClick:()=>X(2),children:"â Back to Lyrics"}),e.jsx("button",{className:"btn-primary",onClick:ja,disabled:ss===null||ca||as==="pending",children:ca?"Saving...":as==="pending"?"Waiting for results...":"â Use This Track"})]})]})]})}export{Ha as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.