PageSourceSearch

https://www.itembo.com/assets/AlbumDetailPage-CtnYuFFX.js

js itembo.com collected 2026-09-25 10:25:35 UTC 30,721 bytes, 2 lines download raw bytes

1import{j as e}from"./vendor-ui-core-DWyIHxpY.js";import{s as w,as as A,C as D,h as E,B as g,v as q,ao as N,aD as ne,aE as de,aF as oe,aG as ce,az as Y,c_ as me,a as L,b as O,b2 as v,V as X,au as R,a0 as U,a1 as $,a2 as z,a3 as K,a4 as S,b4 as Z,be as ue,aX as xe,b5 as ee,b6 as se,b7 as re,u as te,aH as ae,a7 as G,bs as Q,a9 as B,J as F,a$ as he,G as V,S as pe,M as H,af as ge}from"./main-Z1rTqt3M.js";import{a as fe,b as ve}from"./useAlbums-tOR9-D1l.js";import{u as be}from"./useAlbumTracks-CARkoT3A.js";import{f as I}from"./formatDuration-BTRstT7R.js";import{r as b,u as ie,k as je}from"./vendor-react-DzMUrXFC.js";import{u as T,c as P}from"./vendor-query-9q-iqsHw.js";import{u as ye,a as J,D as Ne,c as _e,S as we,v as ke,b as Ce,C as Ae,s as Te,K as Se,P as De,d as Ee}from"./vendor-dnd-Drj6T_V6.js";import{A as Pe}from"./arrow-up-down-cj33NoWo.js";import{S as Fe,G as qe,R as Ie,u as Me}from"./useUploadAlbumCover-BsLQRomj.js";import{P as Le}from"./pen-line-HnwWhziJ.js";import{G as Oe}from"./grip-vertical-CebIQCeM.js";import{E as Re}from"./ellipsis-vertical-COUYPsf4.js";import{T as Ue}from"./textarea-h_Dc3zR5.js";import{C as M}from"./checkbox-CjB-c5Lc.js";import{t as $e}from"./trackTransformation-Cruz9XYF.js";import{A as ze,a as Ke,b as Ge,c as Qe,d as Be,e as Ve,f as He,g as Je}from"./alert-dialog-B7MSYimd.js";import{E as We}from"./eye-BLj0-hDQ.js";import{C as Ye}from"./calendar-D6iLKdsX.js";import"./vendor-supabase-B3U3ReBo.js";import"./vendor-charts-CBBN6_gB.js";import"./vendor-ui-extra-C3HD5Ard.js";import"./vendor-motion-YGI21uN_.js";import"./vendor-forms-BIjZt7Hz.js";import"./addDays-CWYe6_zy.js";import"./format-C0UkOshh.js";function Xe(){const s=T(),{toast:o}=A();return P({mutationFn:async({albumTrackId:a})=>{const{error:l}=await w.from("album_tracks").delete().eq("id",a);if(l)throw console.error("Error removing track from album:",l),l},onSuccess:(a,{albumId:l})=>{s.invalidateQueries({queryKey:["albumTracks",l]}),s.invalidateQueries({queryKey:["albums"]}),s.invalidateQueries({queryKey:["artist-albums"]}),o({title:"Track Removed",description:"Track has been removed from the album successfully.",variant:"success"})},onError:a=>{console.error("Failed to remove track from album:",a),o({title:"Error",description:a.message||"Failed to remove track from album. Please try again.",variant:"destructive"})}})}function Ze(){const s=T(),{toast:o}=A();return P({mutationFn:async({albumId:a,trackOrders:l})=>{const{error:r}=await w.rpc("reorder_album_tracks",{p_album_id:a,p_orders:l.map(({albumTrackId:i,trackOrder:t})=>({albumTrackId:i,trackOrder:t}))});if(r)throw r},onSuccess:(a,{albumId:l})=>{s.invalidateQueries({queryKey:["albumTracks",l]}),o({title:"Track Order Updated",description:"Album track order has been updated successfully.",variant:"success"})},onError:a=>{console.error("Failed to update track order:",a),o({title:"Error",description:a.message||"Failed to update track order. Please try again.",variant:"destructive"})}})}function W({track:s,onRemove:o,isDragOverlay:a}){const{attributes:l,listeners:r,setNodeRef:i,transform:t,transition:u,isDragging:x}=Ce({id:s.album_track_id}),c=me(),d={transform:Ae.Transform.toString(t),transition:u,opacity:x?.5:1};return e.jsx(D,{ref:i,style:d,className:`group transition-all duration-300 hover-scale border-border/50 backdrop-blur-sm hover:border-primary/20 ${x?"z-50 border-primary/40 scale-105":""} ${a?" rotate-2 border-primary/60":""}`,children:e.jsx(E,{className:`${c?"p-2":"p-4"} hover:bg-muted/20 transition-all duration-200`,children:e.jsxs("div",{className:`flex items-center ${c?"gap-2":"gap-4"}`,children:[e.jsx("div",{className:"cursor-grab active:cursor-grabbing hover:text-primary transition-all duration-200 hover:scale-110 rounded-md p-1 hover:bg-primary/10",...l,...r,children:e.jsx(Oe,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary/70"})}),e.jsx("div",{className:`${c?"w-6 h-6 text-xs":"w-8 h-8 text-sm"} rounded-full bg-primary/10 border border-primary/20 flex items-center justify-center font-medium text-primary group-hover:bg-primary/20 transition-all duration-200`,children:s.track_order}),e.jsx(g,{size:"sm",variant:"ghost",className:`${c?"h-7 w-7":"h-9 w-9"} p-0 hover-scale bg-primary/5 hover:bg-primary/15 border border-primary/10 hover:border-primary/30 transition-all duration-200`,children:e.jsx(q,{className:`${c?"h-3 w-3":"h-4 w-4"} text-primary/70 group-hover:text-primary`})}),e.jsx("div",{className:`${c?"h-10 w-10":"h-14 w-14"} rounded-xl flex-shrink-0 overflow-hidden border border-border/30 hover:border-primary/30 transition-all duration-300`,children:s.coverUrl?e.jsx("img",{src:s.coverUrl,alt:s.title,className:"h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(q,{className:"h-5 w-5 text-muted-foreground
1/70"})})}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[e.jsx("h4",{className:`${c?"text-sm":"text-base"} font-semibold truncate text-foreground group-hover:text-primary/90 transition-colors duration-200`,children:s.title}),e.jsx("p",{className:`${c?"text-xs":"text-sm"} text-muted-foreground truncate`,children:s.artist})]}),c?e.jsxs("div",{className:"flex flex-col items-end gap-1",children:[e.jsxs("div",{className:"flex gap-1",children:[s.isExplicit&&e.jsx(N,{variant:"outline",className:"text-xs border-destructive/30 text-destructive bg-destructive/5",children:"E"}),s.isSponsored&&e.jsx(N,{variant:"secondary",className:"text-xs bg-primary/10 text-primary border-primary/20",children:"Sponsored"})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:I(s.duration)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s.streams>999?`${Math.floor(s.streams/1e3)}k`:s.streams})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[s.isExplicit&&e.jsx(N,{variant:"outline",className:"text-xs border-destructive/30 text-destructive bg-destructive/5 hover:bg-destructive/10 transition-colors",children:"E"}),s.isSponsored&&e.jsx(N,{variant:"secondary",className:"text-xs bg-primary/10 text-primary border-primary/20 hover:bg-primary/15 transition-colors",children:"Sponsored"})]}),e.jsx("div",{className:"text-sm font-medium text-muted-foreground w-16 text-right bg-muted/20 rounded-md px-2 py-1 border border-border/20 group-hover:bg-muted/30 transition-all duration-200",children:I(s.duration)}),e.jsx("div",{className:"text-sm font-medium text-muted-foreground w-20 text-right bg-muted/20 rounded-md px-2 py-1 border border-border/20 group-hover:bg-muted/30 transition-all duration-200",children:s.streams.toLocaleString()})]}),e.jsxs(ne,{children:[e.jsx(de,{asChild:!0,children:e.jsx(g,{variant:"ghost",size:"sm",className:"h-9 w-9 p-0 hover-scale hover:bg-muted/50 hover:border-border/50 border border-transparent transition-all duration-200",children:e.jsx(Re,{className:"h-4 w-4 text-muted-foreground group-hover:text-foreground"})})}),e.jsx(oe,{align:"end",className:"border-border/50 bg-card/95 backdrop-blur-sm",children:e.jsxs(ce,{onClick:()=>o(s.album_track_id),className:"text-destructive hover:bg-destructive/10 hover:text-destructive focus:bg-destructive/10 focus:text-destructive transition-colors",children:[e.jsx(Y,{className:"h-4 w-4 mr-2"}),"Remove from Album"]})})]})]})})})}function es({tracks:s,albumId:o}){const[a,l]=b.useState(s),[r,i]=b.useState(!1),t=Xe(),u=Ze(),x=ye(J(De),J(Se,{coordinateGetter:Te}));b.useEffect(()=>{l(s)},[s]);const c=h=>{const{active:m,over:y}=h;if(y&&m.id!==y.id){const n=a.findIndex(_=>_.album_track_id===m.id),p=a.findIndex(_=>_.album_track_id===y.id),k=Ee(a,n,p).map((_,le)=>({..._,track_order:le+1}));l(k)}},d=h=>{t.mutate({albumTrackId:h,albumId:o})},f=()=>{const h=a.map(m=>({albumTrackId:m.album_track_id,trackOrder:m.track_order}));u.mutate({albumId:o,trackOrders:h}),i(!1)},j=()=>{l(s),i(!1)};return s.length===0?e.jsx(D,{children:e.jsx(E,{className:"p-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No tracks in this album yet."})})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pe,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Track Order"})]}),e.jsx("div",{className:"flex gap-2",children:r?e.jsxs(e.Fragment,{children:[e.jsx(g,{variant:"outline",size:"sm",onClick:j,disabled:u.isPending,children:"Cancel"}),e.jsxs(g,{size:"sm",onClick:f,disabled:u.isPending,children:[e.jsx(Fe,{className:"h-4 w-4 mr-2"}),u.isPending?"Saving...":"Save Order"]})]}):e.jsxs(g,{variant:"outline",size:"sm",onClick:()=>i(!0),children:[e.jsx(Le,{className:"h-4 w-4 mr-2"}),"Reorder Tracks"]})})]}),e.jsx("div",{className:"space-y-2",children:r?e.jsx(Ne,{sensors:x,collisionDetection:_e,onDragEnd:c,children:e.jsx(we,{items:a.map(h=>h.album_track_id),strategy:ke,children:a.map(h=>e.jsx(W,{track:h,onRemove:d},h.album_track_id))})}):s.map(h=>e.jsx(W,{track:h,onRemove:d},h.album_track_id))})]})}function ss(){const s=T(),{toast:o}=A();return P({mutationFn:async({albumId:a,updates:l})=>{const{data:r,error:i}=await w.from("albums").update(l).eq("id",a).select().single();if(i)throw console.error("Error updating album:",i),i;return r},onSuccess:()=>{s.invalidateQueries({queryKey:["albums"]}),s.invalidateQueries({queryKey:["artist-albums"]}),o({title:"Album Updated",description:"Album has been updated successfully.",variant:"success"})},onError:a=>{console.error("Failed to update album:",a),o({title:"Error",description:a.message||"Failed to update album. Please try again.",variant:"destructive"})}})}function rs({album:s,onSuccess:o}
1){const[a,l]=b.useState(!1),[r,i]=b.useState({title:s.title,description:s.description||"",album_type:s.album_type,genre:s.genre||"",release_date:s.release_date?new Date(s.release_date):null,is_explicit:s.is_explicit,is_pre_release:s.is_pre_release,scheduled_release_at:s.scheduled_release_at?new Date(s.scheduled_release_at):null,verified_only_content:s.verified_only_content}),[t,u]=b.useState(null),[x,c]=b.useState(s.cover_url||""),d=ss(),{toast:f}=A(),{upload:j}=Me(),h=n=>{if(!n){u(null),c(s.cover_url||"");return}if(!n.type.startsWith("image/")){f({title:"Invalid file type",description:"Please select an image file (JPEG, PNG, etc.)",variant:"destructive"});return}if(n.size>5*1024*1024){f({title:"File too large",description:"Album artwork must be smaller than 5MB",variant:"destructive"});return}u(n);const p=new FileReader;p.onloadend=()=>{c(p.result)},p.readAsDataURL(n)},m=async n=>{var k,_;n.preventDefault();let p=null;t&&(p=await j(t,{albumId:s.id}),p||f({title:"Artwork upload failed",description:"We couldn't upload the album artwork. Please try again.",variant:"destructive"}));const C={title:r.title,description:r.description||null,album_type:r.album_type,genre:r.genre||null,release_date:((k=r.release_date)==null?void 0:k.toISOString().split("T")[0])||null,is_explicit:r.is_explicit,is_pre_release:r.is_pre_release,scheduled_release_at:((_=r.scheduled_release_at)==null?void 0:_.toISOString())||null,verified_only_content:r.verified_only_content,...p?{cover_url:p}:{}};d.mutate({albumId:s.id,updates:C},{onSuccess:()=>{l(!1),u(null),o==null||o()}})},y=()=>{i({title:s.title,description:s.description||"",album_type:s.album_type,genre:s.genre||"",release_date:s.release_date?new Date(s.release_date):null,is_explicit:s.is_explicit,is_pre_release:s.is_pre_release,scheduled_release_at:s.scheduled_release_at?new Date(s.scheduled_release_at):null,verified_only_content:s.verified_only_content}),u(null),c(s.cover_url||""),l(!1)};return a?e.jsxs(D,{className:"animate-fade-in border-border/50 backdrop-blur-sm",children:[e.jsx(L,{className:"border-b border-border/30",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx(O,{className:"text-xl font-semibold text-foreground",children:"Edit Album"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Update your album information and settings"})]})}),e.jsx(E,{className:"p-6",children:e.jsxs("form",{onSubmit:m,className:"space-y-8",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{htmlFor:"title",className:"text-sm font-medium text-foreground",children:"Album Title *"}),e.jsx(X,{id:"title",value:r.title,className:"bg-background/50 border-border/50 focus:border-primary/50 transition-all duration-200",onChange:n=>i({...r,title:n.target.value}),required:!0,disabled:d.isPending})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(v,{className:"text-sm font-medium text-foreground",children:"Album Artwork"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"relative w-40 h-40 mx-auto border-2 border-dashed border-border/50 rounded-xl flex items-center justify-center bg-muted/20 hover:bg-muted/30 transition-all duration-300 group",children:x?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative overflow-hidden rounded-lg w-full h-full",children:[e.jsx("img",{src:x,alt:"Album cover preview",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-105"}),e.jsx("div",{className:"absolute inset-0"})]}),e.jsx(g,{type:"button",variant:"ghost",size:"sm",className:"absolute -top-2 -right-2 p-2 bg-destructive hover:bg-destructive/90 rounded-full border border-background",onClick:()=>h(null),disabled:d.isPending,children:e.jsx(Y,{className:"w-4 h-4 text-destructive-foreground"})})]}):e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(R,{className:"w-10 h-10 text-muted-foreground mx-auto"}),e.jsx("p",{className:"text-sm text-muted-foreground font-medium",children:"No artwork uploaded"}),e.jsx("p",{className:"text-xs text-muted-foreground/70",children:"Click below to add"})]})}),e.jsxs("div",{className:"text-center space-y-2",children:[e.jsxs(g,{type:"button",variant:"outline",onClick:()=>{var n;return(n=document.getElementById("cover-upload-edit"))==null?void 0:n.click()},className:"w-full sm:w-auto hover-scale bg-primary/5 hover:bg-primary/10 border-primary/20 hover:border-primary/30 transition-all duration-200",disabled:d.isPending,children:[e.jsx(R,{className:"w-4 h-4 mr-2"}),x?"Change Artwork":"Upload Artwork"]}),e.jsx("input",{id:"cover-upload-edit",type:"file",accept:"image/*",onChange:n=>{var p;return h(((p=n.target.files)==null?void 0:p[0])||null)},className:"hidden",disabled:d.isPending}
1),e.jsx("p",{className:"text-xs text-muted-foreground/70",children:"Recommended: 1000x1000px, max 5MB (JPEG, PNG)"})]})]})]}),e.jsxs("div",{children:[e.jsx(v,{htmlFor:"description",children:"Description"}),e.jsx(Ue,{id:"description",value:r.description,onChange:n=>i({...r,description:n.target.value}),disabled:d.isPending,rows:3})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(v,{children:"Album Type *"}),e.jsxs(U,{value:r.album_type,onValueChange:n=>i({...r,album_type:n}),disabled:d.isPending,children:[e.jsx($,{children:e.jsx(z,{})}),e.jsxs(K,{children:[e.jsx(S,{value:"album",children:"Album"}),e.jsx(S,{value:"ep",children:"EP"}),e.jsx(S,{value:"single",children:"Single"})]})]})]}),e.jsxs("div",{children:[e.jsx(v,{children:"Genre"}),e.jsxs(U,{value:r.genre,onValueChange:n=>i({...r,genre:n}),disabled:d.isPending,children:[e.jsx($,{children:e.jsx(z,{placeholder:"Select a genre"})}),e.jsx(K,{children:qe.map(n=>e.jsx(S,{value:n,children:n},n))})]})]})]}),e.jsxs("div",{children:[e.jsx(v,{children:"Release Date"}),e.jsx(Ie,{value:r.release_date,onChange:n=>i({...r,release_date:n}),disabled:d.isPending})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(M,{id:"explicit",checked:r.is_explicit,onCheckedChange:n=>i({...r,is_explicit:!!n}),disabled:d.isPending}),e.jsx(v,{htmlFor:"explicit",children:"Explicit Content"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(M,{id:"verifiedOnly",checked:r.verified_only_content,onCheckedChange:n=>i({...r,verified_only_content:!!n}),disabled:d.isPending}),e.jsx(v,{htmlFor:"verifiedOnly",children:"Verified Artists Only"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(g,{type:"button",variant:"outline",onClick:y,disabled:d.isPending,children:"Cancel"}),e.jsx(g,{type:"submit",disabled:d.isPending||!r.title.trim(),children:d.isPending?"Updating...":"Update Album"})]})]})})]}):e.jsxs(D,{className:"animate-fade-in hover-scale border-border/50 backdrop-blur-sm",children:[e.jsxs(L,{className:"flex flex-row items-center justify-between pb-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(O,{className:"text-lg font-semibold text-foreground",children:"Album Information"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage your album details and settings"})]}),e.jsx(g,{variant:"outline",onClick:()=>l(!0),className:"hover-scale bg-primary/5 hover:bg-primary/10 border-primary/20 hover:border-primary/30 transition-all duration-200",children:"Edit"})]}),e.jsxs(E,{className:"space-y-6 pt-2",children:[s.cover_url&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(v,{className:"text-sm font-medium text-foreground",children:"Album Artwork"}),e.jsx("div",{className:"group relative w-fit",children:e.jsxs("div",{className:"relative overflow-hidden rounded-xl border-2 border-border/50 p-1",children:[e.jsx("img",{src:s.cover_url,alt:`${s.title} cover`,className:"w-32 h-32 object-cover rounded-lg transition-transform duration-300 group-hover:scale-105"}),e.jsx("div",{className:"absolute inset-0 rounded-lg"})]})})]}),e.jsxs("div",{className:"grid gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{className:"text-sm font-medium text-foreground",children:"Title"}),e.jsx("p",{className:"text-base font-medium text-foreground bg-muted/30 rounded-lg px-3 py-2 border border-border/30",children:s.title})]}),s.description&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{className:"text-sm font-medium text-foreground",children:"Description"}),e.jsx("p",{className:"text-sm text-muted-foreground bg-muted/20 rounded-lg px-3 py-2 border border-border/20 leading-relaxed",children:s.description})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{className:"text-sm font-medium text-foreground",children:"Type"}),e.jsx("div",{className:"bg-primary/10 text-primary rounded-lg px-3 py-2 text-sm font-medium capitalize border border-primary/20",children:s.album_type})]}),s.genre&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{className:"text-sm font-medium text-foreground",children:"Genre"}),e.jsx("div",{className:"bg-secondary/50 text-secondary-foreground rounded-lg px-3 py-2 text-sm font-medium border border-secondary/30",children:s.genre})]})]}),s.release_date&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{className:"text-sm font-medium text-foreground",children:"Release Date"}),e.jsx("div",{className:"bg-muted/30 text-foreground rounded-lg px-3 py-2 text-sm font-medium border border-border/30",children:new Date(s.release_date).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})})]})]})]})]})}function ts(){const s=T(),{toast:o}=A();return P({mutationFn:async({albumId:a,trackIds:l})=>{var d;const{data:r,error:i}=await w.from("album_tracks").select("track_order").eq("album_id",a).order("track_order",{ascending:!1}).limit(1);if(i)throw i;const t=((d=r==null?void 0:r[0])==null?void 0:d.track_order)||0,u=l.map((f,j)=>({album_id:a,track_id:f,track_order:t+j+1})),{data:x,error:c}=await w.from("album_tracks").insert(u).select();if(c)throw console.error("Error adding tracks to album:",c),c;return x},onSuccess:(a,{albumId:l})=>{s.invalidateQueries({queryKey:["albumTracks",l]}),s.invalidateQueries({queryKey:["albums"]}),s.invalidateQueries({queryKey:["artist-albums"]}
1),o({title:"Tracks Added",description:"Tracks have been added to the album successfully.",variant:"success"})},onError:a=>{console.error("Failed to add tracks to album:",a),o({title:"Error",description:a.message||"Failed to add tracks to album. Please try again.",variant:"destructive"})}})}function as({albumId:s,albumTitle:o,existingTrackIds:a}){const[l,r]=b.useState(!1),[i,t]=b.useState([]),{tracks:u,isLoading:x}=fe(),c=ts(),f=$e(u||[]).filter(m=>!a.includes(m.id)),j=m=>{t(y=>y.includes(m)?y.filter(n=>n!==m):[...y,m])},h=()=>{i.length!==0&&c.mutate({albumId:s,trackIds:i},{onSuccess:()=>{t([]),r(!1)}})};return e.jsxs(Z,{open:l,onOpenChange:r,children:[e.jsx(ue,{asChild:!0,children:e.jsxs(g,{children:[e.jsx(xe,{className:"h-4 w-4 mr-2"}),"Add Tracks"]})}),e.jsxs(ee,{className:"max-w-2xl max-h-[600px] flex flex-col",children:[e.jsx(se,{children:e.jsxs(re,{children:["Add Tracks to ",o]})}),e.jsx("div",{className:"flex-1 overflow-y-auto space-y-2",children:x?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading tracks..."}):f.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No available tracks to add to this album."}):f.map(m=>e.jsxs("div",{className:"flex items-center gap-4 p-3 border rounded-lg hover:bg-accent/50 transition-colors",children:[e.jsx(M,{checked:i.includes(m.id),onCheckedChange:()=>j(m.id)}),e.jsx("div",{className:"h-12 w-12 rounded-md flex-shrink-0 overflow-hidden",children:m.coverUrl?e.jsx("img",{src:m.coverUrl,alt:m.title,className:"h-full w-full object-cover"}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(q,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-medium truncate",children:m.title}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[m.streams.toLocaleString()," streams"]})]}),e.jsxs("div",{className:"flex gap-2",children:[m.isExplicit&&e.jsx(N,{variant:"outline",className:"text-xs",children:"E"}),m.isSponsored&&e.jsx(N,{variant:"secondary",className:"text-xs",children:"Sponsored"})]})]},m.id))}),e.jsxs("div",{className:"flex justify-between items-center pt-4 border-t",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[i.length," track",i.length!==1?"s":""," selected"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(g,{onClick:h,disabled:i.length===0||c.isPending,children:c.isPending?"Adding...":`Add ${i.length} Track${i.length!==1?"s":""}`})]})]})]})]})}function is({album:s,open:o,onOpenChange:a}){const[l,r]=b.useState(""),[i,t]=b.useState(!1),[u,x]=b.useState(!1),[c,d]=b.useState(""),{user:f}=te(),j=T(),h=ie(),m=async()=>{if(!f||!l.trim()){d("Password is required");return}t(!0),d("");try{const{error:p}=await w.auth.signInWithPassword({email:f.email,password:l});if(p){d("Incorrect password"),t(!1);return}const{error:C}=await w.from("albums").delete().eq("id",s.id).eq("artist_id",f.id);if(C){console.error("Error deleting album:",C),F.error("Failed to delete album"),t(!1);return}w.functions.invoke("send-album-deleted-notification",{body:{artist_id:f.id,album_title:s.title,track_count:s.track_count||0,stream_count:s.streams||0}}).then(k=>{k.error?console.error("Failed to send deletion notification:",k.error):console.log("Album deleti
1on notification sent successfully")}),j.invalidateQueries({queryKey:["albums"]}),j.invalidateQueries({queryKey:["album",s.id]}),j.invalidateQueries({queryKey:["artistAlbums"]}),F.success("Album deleted successfully"),a(!1),r(""),x(!1),h("/dashboard/artist")}catch(p){console.error("Error during album deletion:",p),F.error("An error occurred while deleting the album")}finally{t(!1)}},y=()=>{if(!l.trim()){d("Password is required");return}d(""),x(!0)},n=()=>{r(""),d(""),x(!1),a(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(Z,{open:o&&!u,onOpenChange:a,children:e.jsxs(ee,{className:"sm:max-w-[500px]",children:[e.jsx(se,{children:e.jsxs(re,{className:"flex items-center gap-2 text-destructive",children:[e.jsx(ae,{className:"w-5 h-5"}),"Delete Album"]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(G,{className:"border-destructive/50 bg-destructive/10",children:[e.jsx(Q,{className:"h-4 w-4 text-destructive"}),e.jsxs(B,{className:"text-destructive",children:[e.jsx("strong",{children:"Warning:"})," This action cannot be undone. You will permanently lose:",e.jsxs("ul",{className:"mt-2 ml-4 list-disc space-y-1",children:[e.jsxs("li",{children:["All stream counts (",s.streams.toLocaleString()," streams)"]}),e.jsx("li",{children:"Album analytics and history"}),e.jsx("li",{children:"Cover image"})]})]})]}),e.jsxs(G,{className:"border-warning/50 bg-warning/10",children:[e.jsx(Q,{className:"h-4 w-4 text-warning"}),e.jsxs(B,{className:"text-warning-foreground",children:[e.jsx("strong",{children:"Note:"})," The ",s.track_count," track",s.track_count!==1?"s":""," in this album will be disassociated but not deleted. They will remain in your tracks library."]})]}),e.jsxs("div",{className:"bg-muted p-4 rounded-lg",children:[e.jsx("h3",{className:"font-medium mb-2",children:"Album to be deleted:"}),e.jsx("p",{className:"text-lg font-semibold",children:s.title}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.track_count," tracks • ",s.streams.toLocaleString()," ","streams • Created"," ",new Date(s.created_at).toLocaleDateString()]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{htmlFor:"password",className:"text-sm font-medium",children:"Enter your account password to confirm deletion:"}),e.jsx(X,{id:"password",type:"password",placeholder:"Your account password",value:l,onChange:p=>{r(p.target.value),d("")},className:c?"border-destructive":"",disabled:i}),c&&e.jsx("p",{className:"text-sm text-destructive",children:c})]}),e.jsxs("div",{className:"flex justify-end space-x-3 pt-4",children:[e.jsx(g,{type:"button",variant:"outline",onClick:n,disabled:i,children:"Cancel"}),e.jsx(g,{type:"button",variant:"destructive",onClick:y,disabled:i||!l.trim(),children:"Delete Album"})]})]})]})}),e.jsx(ze,{open:u,onOpenChange:x,children:e.jsxs(Ke,{children:[e.jsxs(Ge,{children:[e.jsx(Qe,{className:"text-destructive",children:"Are you absolutely sure?"}),e.jsxs(Be,{children:['You are about to permanently delete "',s.title,'" with'," ",s.track_count," tracks. This action cannot be undone."]})]}),e.jsxs(Ve,{children:[e.jsx(He,{onClick:()=>x(!1),disabled:i,children:"Cancel"}),e.jsx(Je,{onClick:m,disabled:i,className:"bg-destructive hover:bg-destructive/90",children:i?"Deleting...":"Yes, delete album"})]})]})})]})}function ls({album:s,size:o="default",variant:a="destructive",showText:l=!0}){const[r,i]=b.useState(!1),{user:t}=te();return!t||t.id!==s.artist_id?null:e.jsxs(e.Fragment,{children:[e.jsxs(g,{variant:a,size:o,onClick:()=>i(!0),className:"gap-2",children:[e.jsx(ae,{className:"h-4 w-4"}),l&&"Delete Album"]}),e.jsx(is,{album:s,open:r,onOpenChange:i})]})}function Fs(){const{albumId:s}=je(),o=ie(),{data:a,isLoading:l}=ve(),{data:r,isLoading:i}=be(s),t=a==null?void 0:a.find(d=>d.id===s);if(l||i)return e.jsx(he,{});if(!t)return e.jsxs("div",{className:"container mx-auto p-6",children:["",e.jsxs("div",{className:"text-center",children:["",e.jsx("h1",{className:"text-2xl font-bold mb-4",children:"Album Not Found"}),"",e.jsxs("p",{className:"text-muted-foreground mb-6",children:["","The album you're looking for doesn't exist or you don't have access to it.",""]}),"",e.jsxs(g,{onClick:()=>o("/dashboard/artist"),children:["",e.jsx(V,{className:"h-4 w-4 mr-2"})," Back to Dashboard",""]}),""]}),""]});const u=(r==null?void 0:r.map(d=>d.id))||[],x=t?`${t.title} - Album Management`:"Album Management",c=t?`Manage your album"${t.title}" on PayStreem. Edit tracks, update album details, and monitor performance in your artist dashboard.`:"Manage your music albums on PayStreem. Edit album details, organize tracks, and optimize your releases for maximum exposure.";return e.jsxs(e.Fragment,{children:["",e.jsx(pe,{title:x,description:c,url:`https://paystreem.com/dashboard/albums/${s}`,type:"website"}),"",e.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:["","",e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:["",e.jsxs(g,{variant:"ghost",size:"sm",onClick:()=>o("/dashboard/artist"),children:["",e.jsx(V,{className:"h-4 w-4 mr-2"})," Back to Dashboard",""]}),""]}),"","",e.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:["","",e.jsxs("div",{className:"lg:w-80 flex-shrink-0",children:["",e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden",children:["",t.cover_url?e.jsx("img",{src:t.cover_url,alt:t.title,className:"h-full w-full object-cover"}):e.jsxs("div",{className:"h-full w-full flex items-center justify-center",children:["",e.jsx(H,{className:"h-20 w-20 text-muted-foreground"}),""]}),""]}),""]}),"","",e.jsxs("div",{className:"flex-1 space-y-4",children:["",e.jsxs("div",{children:["",e.jsxs(N,{variant:"outline",className:"mb-2 capitalize",children:["",t.album_type,""]}),"",e.jsx("h1",{className:"text-4xl font-bold mb-2",children:t.title}),"",t.description&&e.jsx("p",{className:"text-lg text-muted-foreground",children:t.description}),""]}),"","",e.jsxs("div",{className:"flex flex-wrap gap-6 text-sm text-muted-foreground",children:["",e.jsxs("div",{className:"flex items-center gap-2",children:["",e.jsx(H,{className:"h-4 w-4"})," ",t.track_count," track",t.track_count!==1?"s":"",""]}),"",e.jsxs("div",{className:"flex items-center gap-2",children:["",e.jsx(ge,{className:"h-4 w-4"}),"",I(t.total_duration),""]}),"",e.jsxs("div",{className:"flex items-center gap-2",children:["",e.jsx(We,{className:"h-4 w-4"}
1)," ",t.streams.toLocaleString(),"","streams",""]}),"",t.release_date&&e.jsxs("div",{className:"flex items-center gap-2",children:["",e.jsx(Ye,{className:"h-4 w-4"}),"",new Date(t.release_date).toLocaleDateString(),""]}),""]}),"","",e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:["",t.is_explicit&&e.jsx(N,{variant:"outline",children:"E"}),"",t.is_pre_release&&e.jsx(N,{variant:"secondary",children:"Pre-release"}),"",t.verified_only_content&&e.jsx(N,{variant:"secondary",children:"Verified Only"}),"",e.jsx(ls,{album:t,size:"sm"}),""]}),""]}),""]}),""," ",e.jsx(rs,{album:t}),"","",e.jsxs("div",{className:"space-y-4",children:["",e.jsxs("div",{className:"flex items-center justify-between",children:["",e.jsx("h2",{className:"text-2xl font-bold",children:"Tracks"}),"",e.jsx(as,{albumId:t.id,albumTitle:t.title,existingTrackIds:u}),""]}),"",e.jsx(es,{tracks:r||[],albumId:t.id}),""]}),""]}),""]})}export{Fs as default};
2//# sourceMappingURL=AlbumDetailPage-CtnYuFFX.js.map

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.