// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0-or-later
// @source: https://gitlab.com/soapbox-pub/ditto/-/tree/f0a3877c
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ht as t,It as n,Zt as r,_n as i,qi as a}from"./lucide-icons-BdRF0moN.js";import{t as o}from"./jsx-runtime-By8HlURe.js";import{u as s}from"./esm-CRVqHnq2.js";import{r as c}from"./sanitizeUrl-Bk5f35GN.js";import{l}from"./useCurrentUser-C6OJJlWo.js";import{t as u}from"./utils-BFSTDHdM.js";import{n as d}from"./chunk-62JRHF6Z-yJW_vgm4.js";import{t as f}from"./skeleton-CVls4GW9.js";import{a as p,i as m,n as h,r as g,s as _}from"./musicHelpers-B271Bg0t.js";import{t as v}from"./formatTime-CT4ZmnVr.js";import{t as y}from"./DecryptedImage-DLbW5kmn.js";var b=e(a(),1),x=o();function S({event:e,index:a}){let o=_(),f=(0,b.useMemo)(()=>h(e),[e]),S=l(e.pubkey),[C,w]=(0,b.useState)(!1),T=p(e.id),E=(0,b.useMemo)(()=>{let t=e.tags.find(([e])=>e===`d`)?.[1]??``;return`/`+s.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:t})},[e]);if(!f)return null;let D=o.currentTrack?.id===e.id,O=f.duration?v(f.duration):void 0;return(0,x.jsxs)(d,{to:E,className:u(`flex items-center gap-3 px-4 py-2.5 transition-colors cursor-pointer group`,D?`bg-primary/5`:`hover:bg-secondary/30`),children:[(0,x.jsx)(`button`,{onClick:t=>{if(t.preventDefault(),t.stopPropagation(),D&&o.isPlaying)o.pause();else if(D)o.resume();else{let t=g(e,f);t.artwork??=c(S.data?.metadata?.picture),o.playTrack(t)}},disabled:T.status===`decrypting`,className:`size-8 flex items-center justify-center shrink-0 disabled:cursor-progress`,"aria-label":D&&o.isPlaying?`Pause`:`Play`,children:T.status===`decrypting`?(0,x.jsx)(i,{className:`size-4 text-primary animate-spin`}):D&&o.isPlaying?(0,x.jsx)(t,{className:`size-4 text-primary`,fill:`currentColor`}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`span`,{className:`text-sm text-muted-foreground group-hover:hidden tabular-nums`,children:a===void 0?``:a+1}),(0,x.jsx)(n,{className:`size-4 text-muted-foreground hidden group-hover:block`,fill:`currentColor`})]})}),(0,x.jsx)(`div`,{className:`relative size-12 rounded-lg overflow-hidden shrink-0 bg-muted`,children:f.artwork&&!C?(0,x.jsx)(y,{url:f.artwork,encryption:f.artworkEncryption,alt:f.title,className:`size-full object-cover`,loading:`lazy`,onError:()=>w(!0),decoding:`async`,noticeFill:!0}):(0,x.jsx)(`div`,{className:`size-full flex items-center justify-center bg-primary/10`,children:(0,x.jsx)(r,{className:`size-5 text-primary/30`})})}),(0,x.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,x.jsx)(`p`,{className:u(`text-sm font-medium truncate`,D&&`text-primary`),children:f.title}),T.status===`ready`?(0,x.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:f.artist}):(0,x.jsx)(m,{trackId:e.id})]}),O&&(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums shrink-0`,children:O})]})}function C(){return(0,x.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2.5`,children:[(0,x.jsx)(f,{className:`size-8 rounded`}),(0,x.jsx)(f,{className:`size-12 rounded-lg`}),(0,x.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1`,children:[(0,x.jsx)(f,{className:`h-4 w-3/4`}),(0,x.jsx)(f,{className:`h-3 w-1/2`})]}),(0,x.jsx)(f,{className:`h-3 w-8`})]})}export{C as n,S as t};
// @license-end
