import{N as e,i as t,k as n,t as r}from"./jsx-runtime-ktpX_HJe.js";import{n as i,t as a}from"./LastPlayed-DXY9A300.js";import{v as o}from"./Image-Cn5a1pql.js";import{n as s,t as c}from"./InterestGraph-BEEbJaCi.js";var l=r();async function u({params:e}){let t=await fetch(`/apis/web/v1/track/${e.id}`);if(!t.ok)throw new Response(`Failed to load track`,{status:t.status});let n=await t.json();if(t=await fetch(`/apis/web/v1/album/${n.album_id}`),!t.ok)throw new Response(`Failed to load album for track`,{status:t.status});return{track:n,album:await t.json()}}var d=e(function(){let{track:e,album:r}=n();return(0,l.jsx)(s,{type:`Track`,title:e.title,img:e.image,id:e.id,rank:e.all_time_rank,musicbrainzId:e.musicbrainz_id,timeListened:e.time_listened,listenCount:e.listen_count,firstListen:e.first_listen,imgItemId:e.album_id,mergeFunc:o,mergeCleanerFunc:(e,t)=>{e.albums=[],e.artists=[];for(let n=0;n<e.tracks.length;n++)e.tracks[n].id===t&&e.tracks.splice(n,1);return e},subContent:(0,l.jsxs)(l.Fragment,{children:[e.artists.length>0&&(0,l.jsxs)(`p`,{children:[`By`,` `,e.artists.map((n,r)=>(0,l.jsxs)(`span`,{children:[r>0&&r!==e.artists.length-1&&`, `,r===e.artists.length-1&&e.artists.length>1?` and `:``,(0,l.jsx)(t,{className:`hover:underline`,to:`/artist/${n.id}`,children:n.name})]},n.id))]}),(0,l.jsxs)(`p`,{children:[`Appears on`,` `,(0,l.jsx)(t,{className:`hover:underline`,to:`/album/${e.album_id}`,children:r.title})]})]}),children:(0,l.jsxs)(`div`,{className:`flex flex-col gap-10 md:gap-20 mt-14`,children:[(0,l.jsx)(`div`,{className:`min-w-[350px] flex-1`,children:(0,l.jsx)(a,{limit:11,trackId:e.id,showNowPlaying:!0})}),(0,l.jsxs)(`div`,{className:`flex flex-wrap gap-10`,children:[(0,l.jsx)(c,{type:`track`,id:e.id}),(0,l.jsx)(i,{configurable:!0,trackId:e.id})]})]})})});export{u as clientLoader,d as default};