import{w as n,A as m,a as d,o as s,L as c}from"./chunk-NL6KNZEE-DfxmOBHd.js";import{T as u}from"./TopTracks-Bd_3i0l5.js";import{e as p}from"./api-BuTqLiNI.js";import{L as x,A as f}from"./LastPlays-CphKmpl1.js";import{P as b}from"./PeriodSelector-pCJGRgEO.js";import{M as h,I as j}from"./InterestGraph-DdMDFwP0.js";import{t as g}from"./utils-BqohOHgI.js";import"./useTheme-DylenN4B.js";import"./AppProvider-DDBhlShu.js";import"./TopItemList-BRD-rnKC.js";import"./ArtistLinks-B4A9lGBW.js";import"./createLucideIcon-Bp-vR5YK.js";import"./color.esm-brSKLyvp.js";import"./SearchResults-DjG_lSbe.js";import"./index-0dO883bS.js";import"./AsyncButton-Dzd9rf7C.js";async function z({params:r}){const t=await fetch(`/apis/web/v1/album?id=${r.id}`);if(!t.ok)throw new Response("Failed to load album",{status:500});return await t.json()}const E=n(function(){const t=m(),[a,l]=d.useState("week");return console.log(t),s.jsxs(h,{type:"Album",title:t.title,img:t.image,id:t.id,rank:t.all_time_rank,musicbrainzId:t.musicbrainz_id,imgItemId:t.id,mergeFunc:p,mergeCleanerFunc:(i,o)=>{i.artists=[],i.tracks=[];for(let e=0;e<i.albums.length;e++)i.albums[e].id===o&&delete i.albums[e];return i},subContent:s.jsxs("div",{className:"flex flex-col gap-2 items-start",children:[t.artists.length>0&&!t.is_various_artists&&s.jsx("p",{children:s.jsx("span",{children:s.jsx(c,{className:"hover:underline",to:`/artist/${t.artists[0].id}`,children:t.artists[0].name})},t.artists[0].id)}),t.is_various_artists&&s.jsx("p",{children:"Various Artists"}),t.listen_count!==0&&s.jsxs("p",{children:[t.listen_count," play",t.listen_count>1?"s":""]}),t.time_listened!==0&&s.jsx("p",{title:Math.floor(t.time_listened/60/60)+" hours",children:g(t.time_listened)}),t.first_listen>0&&s.jsxs("p",{title:new Date(t.first_listen*1e3).toLocaleString(),children:["Listening since"," ",new Date(t.first_listen*1e3).toLocaleDateString()]})]}),children:[s.jsx("div",{className:"mt-10",children:s.jsx(b,{setter:l,current:a})}),s.jsxs("div",{className:"flex flex-wrap gap-20 mt-10",children:[s.jsx(x,{limit:30,albumId:t.id}),s.jsx(u,{limit:12,period:a,albumId:t.id}),s.jsxs("div",{className:"flex flex-col items-start gap-4",children:[s.jsx(f,{configurable:!0,albumId:t.id}),s.jsx(j,{albumId:t.id})]})]})]})});export{z as clientLoader,E as default};
