1import{r as c,s as x,ci as F,u as Y,bc as q,t as G,j as e,S as V,N as $,B as g,by as B,o as f,ad as N,a1 as A,aU as J,aV as K,aS as Q,V as U,b7 as W,cj as X,C as H,f as M,b as Z,d as ee,ck as se,cl as ae,cm as te,cn as L,w as re}from"./index-pYWJnAYc.js";import{A as ne}from"./AudioOnlyPlayer-1xssBAJX.js";import{U as ie}from"./users-DykgCc6C.js";import{E as le}from"./external-link-Dtl4xqQR.js";import{S as oe}from"./share-2-2ZsQTWwm.js";function ce(r=20){const[i,l]=c.useState([]),[d,p]=c.useState([]),[y,b]=c.useState(!0),[j,v]=c.useState(null),s=c.useCallback(async()=>{try{b(!0),v(null);const{data:a,error:m}=await x.from("song_challenges").select("*").eq("is_active",!0).or("expires_at.is.null,expires_at.gt.now()").order("created_at",{ascending:!1}).limit(r);if(m)throw m;if(!a||a.length===0){l([]);return}const o=[...new Set(a.map(t=>t.creator_id))];let C={};try{const{data:t}=await x.from("profiles").select("user_id, full_name, email").in("user_id",o);t&&(C=Object.fromEntries(t.map(u=>[u.user_id,F(u)])))}catch{}const _=a.filter(t=>t.share_creator_video&&t.creator_session_id),S={};if(_.length>0)try{const t=_.map(w=>w.creator_session_id),{data:u}=await x.from("analysis_sessions").select("id, video_upload_id").in("id",t);if(u){const w=u.filter(h=>h.video_upload_id).map(h=>h.video_upload_id);if(w.length>0){const{data:h}=await x.from("video_uploads").select("id, file_url").in("id",w);if(h){const P=Object.fromEntries(h.map(n=>[n.id,n.file_url])),E=Object.fromEntries(u.filter(n=>n.video_upload_id&&P[n.video_upload_id]).map(n=>[n.id,P[n.video_upload_id]])),z=_.filter(n=>E[n.creator_session_id]).map(async n=>{const D=E[n.creator_session_id].replace(/^\/+/,""),{data:I}=await x.storage.from("videos").createSignedUrl(D,3600);I?.signedUrl&&(S[n.id]=I.signedUrl)});await Promise.all(z)}}}}catch(t){console.warn("[useSongChallengesList] Failed to fetch creator video URLs:",t)}const k=a.map(t=>({...t,creator_name:C[t.creator_id]||"A friend",creator_video_url:S[t.id]||null})),O=k.filter(t=>t.is_public_challenge),R=k.filter(t=>!t.is_public_challenge);p(O),l(R)}catch(a){console.error("Error fetching song challenges list:",a),v(a instanceof Error?a:new Error("Failed to fetch song challenges"))}finally{b(!1)}},[r]);return c.useEffect(()=>{s()},[s]),{challenges:i,publicChallenges:d,isLoading:y,error:j,refetch:s}}const de={vocals:e.jsx(re,{className:"h-4 w-4"}),guitars:e.jsx(L,{className:"h-4 w-4"}),guitar:e.jsx(L,{className:"h-4 w-4"}),bass:e.jsx(te,{className:"h-4 w-4"}),drums:e.jsx(ae,{className:"h-4 w-4"}),keys:e.jsx(se,{className:"h-4 w-4"})};function T(r,i){return i.includes("percentage")?r<50?{label:"Easy",color:"bg-success/10 text-success border-success/20"}:r<75?{label:"Medium",color:"bg-warning/10 text-warning border-warning/20"}:{label:"Hard",color:"bg-destructive/10 text-destructive border-destructive/20"}:r<60?{label:"Easy",color:"bg-success/10 text-success border-success/20"}:r<80?{label:"Medium",color:"bg-warning/10 text-warning border-warning/20"}:{label:"Hard",color:"bg-destructive/10 text-destructive border-destructive/20"}}function me(r){if(!r)return null;const i=r.match(/(?:youtu\.be\/|youtube\.com\/(?:watch\?v=|embed\/|v\/|shorts\/))([\w-]{11})/);return i?i[1]:null}function pe(){const r=Y(),{user:i}=q(),{publicChallenges:l}=ce(30),[d,p]=c.useState("recent"),y=c.useMemo(()=>d==="popular"?[...l].sort((s,a)=>(a.participant_count||0)-(s.participant_count||0)):l,[l,d]);c.useEffect(()=>{G.coverSongHeroViewed()},[]);const b=()=>{if(!i){r("/auth",{state:{returnTo:"/new-analysis?coverSongHero=true"}});return}r("/new-analysis?coverSongHero=true")},j=s=>{r(s.slug?`/challenge/${s.slug}`:`/challenge/s/${s.short_code}`)},v={"@context":"https://schema.org","@type":"CollectionPage",name:"Cover Song Hero - AI Music Challenge",description:"Pick a song. Record your cover. Challenge friends to beat your score. Get AI coaching feedback on guitar, vocals, drums, bass, and keys.",url:"https://performancecoach.ai/challenges/cover-song-hero",mainEntity:{"@type":"ItemList",numberOfItems:l.length},provider:{"@type":"Organization",name:"Performance Coach",url:"https://performancecoach.ai"}};return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(V,{title:"Cover Song Hero - AI Music Challenge | Performance Coach",description:"Pick a song you love. Record your cover. Challenge friends to beat your score. Get instant AI coaching feedback on guitar, vocals, drums, bass, and keys.",keywords:"cover song challenge, music challenge, AI music coaching, cover song competition, guitar challenge, vocal challenge, song cover contest",canonicalUrl:"https://performancecoach.ai/challenges/cover-song-hero",structuredData:v}),e.jsx($,{}),e.jsxs("main",{className:"container mx-auto px-4 py-8 max-w-4xl",children:[e.jsxs(g,{variant:"ghost",className:"mb-4",onClick:()=>
1r("/challenges"),children:[e.jsx(B,{className:"h-4 w-4 mr-2"}),"All Challenges"]}),e.jsxs("div",{className:"text-center mb-8",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 mb-4",children:[e.jsx(f,{className:"bg-warning/10 px-3 py-1 text-sm text-warning",children:"Featured"}),e.jsxs(f,{className:"text-sm bg-primary/10 text-primary border-primary/20 px-3 py-1",children:[e.jsx(N,{className:"h-3 w-3 mr-1"}),"Cover Song"]})]}),e.jsxs("h1",{className:"text-4xl md:text-5xl font-bold mb-3",children:["Think You Can"," ",e.jsx("span",{className:"text-transparent bg-clip-text bg-gradient-primary",children:"Nail That Song?"})]}),e.jsx("p",{className:"text-sm font-medium text-primary mb-2",children:"Cover Song Hero"}),e.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:"Pick a song you love. Record your cover. Get scored by AI in under 2 minutes. Challenge your friends to beat your score - no credit card required."})]}),e.jsxs("div",{className:"text-center mb-10",children:[e.jsxs(g,{size:"lg",onClick:b,className:"w-full max-w-sm bg-gradient-primary hover:opacity-90 text-white shadow-lg",children:[e.jsx(A,{className:"h-5 w-5 mr-2"}),i?"Start a Cover Song Challenge":"Sign In to Start"]}),!i&&e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Requires a free account"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Free with your account - no credit card required"})]}),l.length>0&&e.jsxs("div",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Public Challenges"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(g,{variant:d==="recent"?"default":"outline",size:"sm",className:"h-7 text-xs px-2.5",onClick:()=>p("recent"),children:[e.jsx(J,{className:"h-3 w-3 mr-1"}),"Recent"]}),e.jsxs(g,{variant:d==="popular"?"default":"outline",size:"sm",className:"h-7 text-xs px-2.5",onClick:()=>p("popular"),children:[e.jsx(K,{className:"h-3 w-3 mr-1"}),"Popular"]})]})]}),e.jsx("div",{className:"space-y-4",children:y.map(s=>{const a=me(s.youtube_reference_url),m=de[s.focus_instrument]||e.jsx(N,{className:"h-5 w-5"});return e.jsx("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-primary p-[1px] cursor-pointer",onClick:()=>j(s),children:e.jsxs("div",{className:"rounded-[15px] bg-gradient-primary p-6 sm:p-8",children:[e.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-white/5 rounded-full -translate-y-1/2 translate-x-1/2"}),e.jsx("div",{className:"absolute bottom-0 left-0 w-48 h-48 bg-white/5 rounded-full translate-y-1/2 -translate-x-1/2"}),e.jsxs("div",{className:"relative z-10",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(f,{className:"border-0 bg-warning/90 text-xs font-semibold text-warning-foreground",children:[e.jsx(Q,{className:"h-3 w-3 mr-1 fill-current"}),"Public Challenge"]}),e.jsxs(f,{className:"bg-white/15 text-white border-0 text-xs",children:[m,e.jsx("span",{className:"ml-1 capitalize",children:s.focus_instrument})]}),e.jsx(f,{className:`border-0 text-xs font-semibold ${T(s.creator_score,s.challenge_metric).color}`,children:T(s.creator_score,s.challenge_metric).label})]}),a&&e.jsx("div",{className:"flex-shrink-0 w-[320px] h-[180px] rounded-lg overflow-hidden bg-black/30",onClick:o=>o.stopPropagation(),children:e.jsx("iframe",{src:`https://www.youtube.com/embed/${a}?rel=0&modestbranding=1`,title:`${s.song_name} - Preview`,allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",className:"w-full h-full border-0"})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-end sm:justify-between gap-4",children:[e.jsxs("div",{className:"text-white",children:[e.jsxs("h3",{className:"text-2xl sm:text-3xl font-bold mb-1",children:['"',s.song_name,'"']}),s.song_artist&&e.jsx("p",{className:"text-white/70 text-lg mb-1",children:s.song_artist}),s.song_section&&s.song_section!=="Performance"&&e.jsxs("div",{className:"flex items-center gap-1.5 mb-3",children:[e.jsx(N,{className:"h-3.5 w-3.5 text-white/50"}),e.jsx("span",{className:"text-sm text-white/60",children:s.song_section})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-white/60",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ie,{className:"h-4 w-4"}),s.participant_count||0," participant",(s.participant_count||0)!==1?"s":""]}),(s.beat_count||0)>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(U,{className:"h-4 w-4"}),s.beat_count," beat",s.beat_count!==1?"s":""]})]}),s.share_creator_video&&s.creator_video_url&&e.jsx("div",{className:"mt-2",onClick:o=>o.stopPropagation(),children:e.jsx(ne,{src:s.creator_video_url,performerName:s.creator_name||"Challenger",variant:"compact"})})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-3xl sm:text-4xl font-bold text-white",children:W(s.creator_score,s.challenge_metric)}),e.jsxs("div",{className:"text-xs text-white/50 uppercase tracking-wide",children:[X(s.challenge_metric)," to beat"]})]}),e.jsxs(g,{size:"lg",className:"bg-white text-primary hover:bg-white/90 font-semibold shadow-lg",onClick:o=>{o.stopPropagation(),j(s)},children:[e.jsx(le,{className:"h-4 w-4 mr-2"}),"Learn More"]})]})]})]})]})},s.id)})})]}),e.jsx(H,{className:"mb-8",children:e.jsxs(M,{className:"py-6",children:[e.jsx("h3",{className:"font-semibold mb-4 text-center",children:"How it works"}),e.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:[{step:1,title:"Pick a Song",desc:"Choose any song and add a YouTube reference",icon:N},{step:2,title:"Record Your Cover",desc:"Upload your performance video",icon:A},{step:3,title:"Get Your Score",desc:"AI analyzes your cover with detailed coaching",icon:U},{step:4,title:"Challenge Friends",desc:"Share your link - they have to beat you",icon:oe}].map(({step:s,title:a,desc:m,icon:o})=>e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-gradient-primary text-white flex items-center justify-center text-sm font-bold mx-auto mb-2",children:s}),e.jsxs("div",{className:"flex items-center justify-center gap-1.5 mb-1",children:[e.jsx(o,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:a})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m})]},s))})]})}
1),e.jsxs(H,{className:"mt-8",children:[e.jsx(Z,{children:e.jsx(ee,{children:"Pro Tips"})}),e.jsx(M,{children:e.jsx("ul",{className:"space-y-2.5",children:["Choose a song you know inside out - familiarity gives you an edge","Add a YouTube reference so the AI can compare your cover to the original","Listen to the original 2-3 times right before recording for accuracy","Focus on your strongest instrument when creating the challenge","Share your challenge link on social media for maximum competition"].map((s,a)=>e.jsxs("li",{className:"flex gap-3 text-sm",children:[e.jsxs("span",{className:"text-primary font-bold",children:[a+1,"."]}),e.jsx("span",{children:s})]},a))})})]})]})]})}export{pe 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.