veza/apps/web/dist_verification/assets/PlaylistCard-Due74KZ6.js
2026-02-07 20:36:48 +01:00

1 line
5.5 KiB
JavaScript

import{a as t,C as h,d as f,e as y}from"./index-D2uzyr9g.js";import{r as d}from"./features-CKIBrJL0.js";import{j as s}from"./vendor-react-YMhRUmcb.js";import{L as w}from"./vendor-router-DX94Iu-2.js";import{a6 as b,i as g,w as k,aE as P}from"./vendor-icons-DINCNwpk.js";async function j(a){return(await t.post("/playlists",a)).data.playlist}async function x(a){return(await t.get(`/playlists/${a}`)).data.playlist}async function v(a,e){return(await t.put(`/playlists/${a}`,e)).data.playlist}async function $(a){await t.delete(`/playlists/${a}`)}async function N(a=1,e=20,n,i,o){const l=Math.max(e,1),c={page:Math.max(a,1),limit:l};return n&&(c.user_id=n),i&&(c.sort_by=i),o&&(c.sort_order=o),(await t.get("/playlists",{params:c})).data}async function _(a,e){return(await t.post(`/playlists/${a}/collaborators`,e)).data}async function C(a,e){await t.delete(`/playlists/${a}/collaborators/${e}`)}async function D(a,e,n){await t.put(`/playlists/${a}/collaborators/${e}`,n)}async function L(a){return d("PLAYLIST_SEARCH"),(await t.get("/playlists/search",{params:a})).data}async function T(a){return d("PLAYLIST_SHARE"),(await t.post(`/playlists/${a}/share`)).data.share_link}async function E(a,e){await t.put(`/playlists/${a}/tracks/reorder`,e)}async function A(a,e){await t.delete(`/playlists/${a}/tracks/${e}`)}async function R(a){return d("PLAYLIST_RECOMMENDATIONS"),Promise.resolve({recommendations:[]})}async function S(a){return(await t.get(`/playlists/${a}/collaborators`)).data.collaborators||[]}async function M(a,e){await t.post(`/playlists/${a}/tracks`,{track_id:e})}async function F(a){return{message:(await t.post(`/playlists/${a}/follow`)).data.message||"Playlist followed",is_following:!0}}async function I(a){return{message:(await t.delete(`/playlists/${a}/follow`)).data.message||"Playlist unfollowed",is_following:!1}}async function q(a){const e=await x(a);return{is_following:e.is_following??!1,follower_count:e.follower_count??0}}const U={create:j,get:x,update:v,delete:$,list:N,search:L,addTrack:M,removeTrack:A,reorderTracks:E,addCollaborator:_,removeCollaborator:C,updateCollaboratorPermission:D,getCollaborators:S,createShareLink:T,follow:F,unfollow:I,getFollowStatus:q,getRecommendations:R};function V({playlist:a,className:e,onClick:n,selectable:i=!1,selected:o=!1,onSelect:l}){const u=r=>{if(i&&l){r.preventDefault(),r.stopPropagation(),l(a,!o);return}n&&(r.preventDefault(),n(a))},c=r=>{if(i&&l&&(r.key==="Enter"||r.key===" ")){r.preventDefault(),r.stopPropagation(),l(a,!o);return}n&&(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),n(a))},p=r=>{r.preventDefault(),r.stopPropagation(),l&&l(a,!o)},m=s.jsx(h,{className:f("cursor-pointer active:opacity-90 transition-opacity duration-200","touch-manipulation",i&&o&&"ring-2 ring-blue-500 border-kodo-steel",e),children:s.jsxs(y,{className:"p-0",children:[s.jsxs("div",{className:"relative aspect-square bg-gradient-to-br from-purple-500 to-pink-500 overflow-hidden",children:[a.cover_url?s.jsx("img",{src:a.cover_url,alt:`Couverture de la playlist ${a.title}`,className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center",role:"img","aria-label":`Pas de couverture pour la playlist ${a.title}`,children:s.jsx(b,{className:"w-16 h-16 text-white/50","aria-hidden":"true"})}),i&&s.jsx("div",{className:"absolute top-2 left-2 z-10",children:s.jsx("button",{type:"button",onClick:p,className:f("w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all","touch-manipulation min-h-[24px] min-w-[24px]",o?"bg-kodo-cyan border-kodo-cyan text-white":"bg-white/90 dark:bg-kodo-graphite/90 border-kodo-steel dark:border-kodo-steel text-transparent hover:border-kodo-steel/50"),"aria-label":o?`Désélectionner ${a.title}`:`Sélectionner ${a.title}`,"aria-checked":o,role:"checkbox",children:o&&s.jsx(g,{className:"w-4 h-4","aria-hidden":"true"})})}),s.jsx("div",{className:"absolute top-2 right-2",children:a.is_public?s.jsxs("div",{className:"bg-kodo-lime/100/80 text-white px-2 py-1 rounded-full text-xs flex items-center gap-1","aria-label":"Playlist publique",children:[s.jsx(k,{className:"w-3 h-3","aria-hidden":"true"}),"Public"]}):s.jsxs("div",{className:"bg-kodo-steel/80 text-white px-2 py-1 rounded-full text-xs flex items-center gap-1","aria-label":"Playlist privée",children:[s.jsx(P,{className:"w-3 h-3","aria-hidden":"true"}),"Privé"]})})]}),s.jsxs("div",{className:"p-4 sm:p-4",children:[s.jsx("h3",{className:"font-semibold text-base sm:text-lg truncate mb-1",id:`playlist-title-${a.id}`,children:a.title}),a.description&&s.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground line-clamp-2 mb-2",id:`playlist-description-${a.id}`,children:a.description}),s.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-1 sm:gap-0 text-xs sm:text-sm text-muted-foreground",children:[s.jsxs("span",{"aria-describedby":`playlist-title-${a.id}`,children:[a.track_count," track",a.track_count!==1?"s":""]}),a.user&&s.jsxs("span",{className:"truncate sm:ml-2","aria-label":`Créée par ${a.user.username}`,children:["par ",a.user.username]})]})]})]})});return i?s.jsx("div",{onClick:u,onKeyDown:c,role:"button",tabIndex:0,"aria-label":`${o?"Désélectionner":"Sélectionner"} la playlist ${a.title}`,className:"touch-manipulation",children:m}):s.jsx(w,{to:`/playlists/${a.id}`,onClick:u,onKeyDown:c,"aria-label":`Voir la playlist ${a.title}`,className:"touch-manipulation",children:m})}export{V as P,v as a,E as b,T as c,$ as d,M as e,_ as f,x as g,q as h,F as i,I as j,R as k,N as l,U as p,C as r,D as u};