import{d as q,G as z,u as f,D as te,H as A,J as T,e as d,h as ce,w as D,a3 as ue,b as y,K as W,r as L,f as k,a4 as x,c as b,ag as de,n as O,F as E,O as V,b0 as fe,ae as X,a2 as me,j as H,m as ve,W as pe}from"./lucide-B8zdcbdX.js";import{S as ye,q as he,r as ge,s as _e,t as be}from"./reka-ui-CG62SOKS.js";import{e as ae,$ as Y,_ as ke,P as se,s as P}from"./index-DWBAd6A9.js";import{l as ie}from"./vueuse-B2OvF727.js";import{_ as xe}from"./Spinner.vue_vue_type_script_setup_true_lang-7x-utta7.js";const Le=q({__name:"ScrollBar",props:{orientation:{default:"vertical"},forceMount:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array],default:void 0}},setup(o){const e=o,s=ie(e,"class");return(m,n)=>(d(),z(f(ye),te({"data-slot":"scroll-area-scrollbar"},f(s),{class:f(ae)("flex touch-none p-px transition-colors select-none",o.orientation==="vertical"&&"h-full w-2.5 border-l border-l-transparent",o.orientation==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e.class)}),{default:A(()=>[T(f(he),{"data-slot":"scroll-area-thumb",class:"bg-border relative flex-1 rounded-full"})]),_:1},16,["class"]))}}),Ie=q({__name:"ScrollArea",props:{type:{},dir:{},scrollHideDelay:{},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(o){const e=o,s=ie(e,"class");return(m,n)=>(d(),z(f(ge),te({"data-slot":"scroll-area"},f(s),{class:f(ae)("relative",e.class)}),{default:A(()=>[T(f(_e),{"data-slot":"scroll-area-viewport",class:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1"},{default:A(()=>[ce(m.$slots,"default")]),_:3}),T(Le),T(f(be))]),_:3},16,["class"]))}}),Te=o=>{const e=o.match(/\[(\d+):(\d+)([.:]\d+)?\](.*)/);if(e){const s=parseInt(e[1]),m=parseInt(e[2]);let n=0;if(e[3]){const h=e[3].replace(/[.:]/,".");n=Math.round(parseFloat(h)*1e3)}return{time:(s*60*1e3+m*1e3+n)/1e3,text:e[4].trim()||" "}}return{time:0,text:o.trim()||" "}},Ae={class:"lyrics-container"},Se={key:0,class:"lyrics-loading"},Me={key:1,class:"lyrics-empty"},Be={key:0,class:"lyrics-intro"},Ee={class:"artist-name"},Pe={class:"lyrics-coming-soon"},we={class:"lyrics-content"},Z=5,Ce=5,I=7,ee=.5,Ne=q({__name:"LyricsViewer",props:{mediaItem:{default:void 0},position:{default:void 0},streamDetails:{default:void 0},textColor:{default:"#FFFFFF"},lyrics:{default:void 0},lrcLyrics:{default:void 0},anticipation:{default:0},externalLoading:{type:Boolean,default:!1},highlightAhead:{type:Boolean,default:!0}},setup(o){fe(t=>({v3677615e:re.value,v58a94341:t.textColor}));const e=o,s=L([]),m=L(!1),n=L(-1),p=L(null),u=new Map,h=L(0),v=L(!1),w=(t,a)=>{t?u.set(a,t):u.delete(a)},S=b(()=>{if(!C.value||!s.value.length)return!1;const t=s.value[0].time;return t<2?!1:(e.position||0)<t-e.anticipation}),le=b(()=>{if(!e.mediaItem)return"";if("media_type"in e.mediaItem&&e.mediaItem.media_type==="track"){const t=e.mediaItem;if(t.artists?.length)return t.artists.map(a=>a.name).join(", ")}return"media_type"in e.mediaItem&&e.mediaItem.media_type==="artist"?e.mediaItem.name:""}),U=()=>e.lyrics??e.mediaItem?.metadata?.lyrics??null,j=()=>e.lrcLyrics??e.mediaItem?.metadata?.lrc_lyrics??null,C=b(()=>{if(s.value.some(i=>i.time>0))return!0;const t=j(),a=U();return!!(t&&t.includes("[")||a&&/\[\d+:\d+[.:]?\d*\]/.test(a))}),ne=()=>{m.value=!0;try{const t=j()||"",a=U()||"";let i="",l=!1;if(t?(i=t,l=!0):a&&/\[\d+:\d+[.:]?\d*\]/.test(a)?(i=a,l=!0):a&&(i=a,l=!1),l){const c=i.split(`
`).filter(r=>r.trim()).map(r=>Te(r)).sort((r,F)=>r.time-F.time),_=new Set;for(const r of c)!r.text.trim()&&r.time>0&&_.add(r.time);const g=c.filter(r=>r.text.trim()),M=[];if(g.length>0){const r=g[0].time;r>=Z&&M.push({time:r-Z,text:"",isBreak:!0,breakEnd:r})}for(let r=0;r<g.length;r++)if(M.push({time:g[r].time,text:g[r].text,isBreak:!1}),r<g.length-1){const F=g[r].time,$=g[r+1].time;let B=null;for(const R of _)if(R>F&&R<$){B=R;break}B!==null&&$-B>=Ce&&M.push({time:B,text:"",isBreak:!0,breakEnd:$})}s.value=M}else i?s.value=i.split(`
`).filter(c=>c.trim()).map(c=>({time:0,text:c.trim(),isBreak:!1})).filter(c=>c.text):s.value=[]}catch(t){console.error(`[LyricsViewer] Error processing lyrics: ${t}`),s.value=[]}finally{m.value=!1}},G=b(()=>{const t=n.value;if(t<0)return{filled:I,percent:100};const a=s.value[t];if(!a?.isBreak||!a.breakEnd)return{filled:I,percent:100};const i=e.position||0,l=a.breakEnd-Q.value-a.time;if(l<=0)return{filled:I,percent:100};const _=Math.max(0,i-a.time)/l*I;return{filled:Math.min(I,Math.floor(_)),percent:Math.round((_-Math.floor(_))*100)}}),N=b(()=>G.value.filled),K=b(()=>G.value.percent),re=b(()=>`${ee}s`),Q=b(()=>e.highlightAhead?ee:0),oe=t=>{let a=-1;for(let i=0;i<s.value.length&&Math.round(s.value[i].time*1e3)<=t;i++)a=i;return a},J=t=>{const a=u.get(t),i=p.value;if(!a||!i)return;const c=i.clientHeight*(e.anticipation>0?.5:.35),_=a.offsetTop,g=a.offsetHeight;h.value=c-_-g/2};return D([()=>e.mediaItem?.item_id,()=>e.lyrics,()=>e.lrcLyrics],()=>{n.value=-1,h.value=99999,v.value=!1,u.clear(),ne(),H(()=>{const t=u.get(0),a=p.value;t&&a&&(h.value=a.clientHeight-t.offsetTop+40)})},{immediate:!0}),D(()=>e.position,t=>{if(t===void 0||!s.value.length||!C.value)return;const a=Math.round((t+Q.value)*1e3),i=oe(a);if(i!==n.value)if(i>=0)v.value=!0,n.value=i,H(()=>J(i));else{n.value=-1,v.value=!0;const l=u.get(0),c=p.value;l&&c&&(h.value=c.clientHeight-l.offsetTop+40)}}),D(S,t=>{!t&&s.value.length&&(v.value=!0,H(()=>J(0)))}),ue(()=>{u.clear()}),(t,a)=>(d(),y("div",Ae,[m.value||o.externalLoading?(d(),y("div",Se,[T(f(xe),{class:"size-6"}),k("div",null,x(f(Y)("loading_lyrics")),1)])):s.value.length?C.value?(d(),y("div",{key:2,ref_key:"syncedContainerRef",ref:p,class:"synced-container"},[T(de,{name:"intro-fade"},{default:A(()=>[S.value?(d(),y("div",Be,[k("div",{class:"song-title",style:O({color:o.textColor})},x(e.mediaItem?.name),5),k("div",Ee,x(le.value),1),k("div",Pe,x(f(Y)("lyrics_will_appear_soon")),1)])):W("",!0)]),_:1}),k("div",{class:"synced-content",style:O({transform:`translateY(${h.value}px)`,transition:v.value?void 0:"none"})},[(d(!0),y(E,null,V(s.value,(i,l)=>(d(),y("div",{key:l,ref_for:!0,ref:c=>w(c,l),class:X(["lyrics-line",{active:n.value===l,"lyrics-line--hidden":n.value>=0?l<n.value-1||l>n.value+2:l>2}])},[i.isBreak?(d(),y(E,{key:1},V(I,c=>k("span",{key:c,class:X(["break-note",{"break-note--filled":n.value===l&&c<=N.value,"break-note--filling":n.value===l&&c===N.value+1}]),style:O(n.value===l&&c===N.value+1?{backgroundImage:`linear-gradient(to right, ${o.textColor} ${K.value}%, color-mix(in srgb, ${o.textColor} 35%, transparent) ${K.value}%)`,backgroundClip:"text","-webkit-background-clip":"text","-webkit-text-fill-color":"transparent"}:void 0)},"♫",6)),64)):(d(),y(E,{key:0},[me(x(i.text),1)],64))],2))),128))],4)],512)):e.anticipation?W("",!0):(d(),z(f(Ie),{key:3,class:"h-full w-full static-lyrics"},{default:A(()=>[k("div",we,[(d(!0),y(E,null,V(s.value,(i,l)=>(d(),y("div",{key:l,class:"lyrics-line active"},x(i.text),1))),128))])]),_:1})):(d(),y("div",Me,x(f(Y)("no_lyrics_available")),1))]))}}),He=ke(Ne,[["__scopeId","data-v-828b10ea"]]);function Fe(o,e,s){if(o===void 0||e===void 0||s!==void 0&&s!==se.PLAYING)return o;const m=e*1e3,n=Date.now(),u=Math.max(0,n-m)/1e3;return o+u}function Ye(o){const e=L(0);let s=null;const m=()=>{const v=P.activePlayerQueue;v?.elapsed_time!=null&&v?.elapsed_time_last_updated!=null&&(e.value=Fe(v.elapsed_time,v.elapsed_time_last_updated,P.activePlayer?.playback_state)??0),s=requestAnimationFrame(m)},n=()=>{s||(s=requestAnimationFrame(m))},p=()=>{s&&(cancelAnimationFrame(s),s=null)};let u=!1;const h=()=>{document.visibilityState==="visible"&&u?n():p()};return document.addEventListener("visibilitychange",h),ve(()=>{const v=P.activePlayer?.playback_state===se.PLAYING,w=P.activePlayerQueue,S=o?o.value:!0;u=v&&!!w?.active&&S,u&&document.visibilityState==="visible"?n():p()}),pe(()=>{p(),document.removeEventListener("visibilitychange",h)}),{elapsedTime:e,start:n,stop:p}}export{He as L,Ie as _,Fe as c,Ye as u};
