1import{k as ue,r as l,b as ae,j as e,L as W,P as ee,m as se,d as pe,X as ge,s as fe,t as m}from"./index-DuFHDgjL.js";import{B as L}from"./button-yDjC60w6.js";import{I as y}from"./input-BchJnEvt.js";import{L as u}from"./label-DBtZhQt0.js";import{S as be}from"./switch-BHFRoUQ8.js";import{D as je,C as Ne,P as ye}from"./dnd.esm-B5OAC8gq.js";import{G as v}from"./genreStyles-pQ4Esg08.js";import{T as ve}from"./trash-2-DGlMKV6d.js";import{C as we}from"./chevron-right-DUHZ3iN5.js";import{G as ke}from"./grip-vertical-ChtztGMs.js";import{P as Ce}from"./pause-DCPLD30Z.js";import{P as _e}from"./play-DilJhz7N.js";import"./index-DFErrfuN.js";import"./index-BKzA9_yg.js";import"./index-Byqjatey.js";import"./index-KNO01SsF.js";import"./tiny-invariant-BaFNuDhB.js";/** 2 * @license lucide-react v0.475.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Pe=[["path",{d:"M21 15V6",key:"h1cx4g"}],["path",{d:"M18.5 18a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z",key:"8saifv"}],["path",{d:"M12 12H3",key:"18klou"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M12 18H3",key:"11ftsu"}]],T=ue("ListMusic",Pe),w=ae.entities.Playlist,Se=ae.entities.AudioTrack;function k(i){const d=Math.round(i||0);return`${Math.floor(d/60)}:${String(d%60).padStart(2,"0")}`}function te({gainDb:i}){if(i==null||i===0)return null;const d=i<0;return e.jsxs("span",{className:`text-[10px] font-bold px-1.5 py-0.5 rounded-full ${d?"bg-orange-500/20 text-orange-200 border border-orange-500/30":"bg-emerald-500/20 text-emerald-200 border border-emerald-500/30"}`,children:[d?"":"+",i," dB"]})}const Ee=["#a78bfa","#60a5fa","#34d399","#f472b6","#fb923c","#fbbf24","#f87171","#22d3ee"];function Xe(){const[i,d]=l.useState([]),[$,re]=l.useState([]),[le,A]=l.useState(!0),[p,g]=l.useState(null),[C,I]=l.useState(""),[M,R]=l.useState(""),[x,O]=l.useState("#a78bfa"),[B,G]=l.useState(!0),[c,f]=l.useState([]),[H,V]=l.useState(!1),[F,U]=l.useState(!1),[b,q]=l.useState(""),[K,_]=l.useState(null),[j]=l.useState({current:null}),[P,X]=l.useState("");l.useEffect(()=>{N()},[]);const N=async()=>{A(!0);const[s,a]=await Promise.all([w.list("-created_date",100),Se.list("name",200)]);d(s),re(a),A(!1)},Y=s=>{if(p===s.id){g(null);return}g(s.id),I(s.name),R(s.description||""),O(s.cover_color||"#a78bfa"),G(s.is_active!==!1),f(s.track_ids||[]),X("")},ie=async()=>{if(!C.trim()){m.error("Name required");return}V(!0);try{await w.update(p,{name:C,description:M,cover_color:x,is_active:B,track_ids:c}),m.success("Playlist saved!"),await N()}catch(s){m.error("Save failed: "+s.message)}finally{V(!1)}},Z=async()=>{if(!b.trim()){m.error("Enter a playlist name");return}U(!0);try{const s=await w.create({name:b,track_ids:[],cover_color:"#a78bfa",is_active:!0});q(""),await N(),setTimeout(()=>Y({...s,track_ids:[]}),100),m.success("Playlist created!")}catch(s){m.error("Create failed: "+s.message)}finally{U(!1)}},ne=async s=>{confirm("Delete this playlist?")&&(await w.delete(s),p===s&&g(null),m.success("Deleted"),N())},ce=s=>{var a;if(K===s.id)(a=j.current)==null||a.pause(),_(null);else{j.current&&j.current.pause();const r=new Audio(s.file_url);r.crossOrigin="anonymous",r.onended=()=>_(null),r.play(),j.current=r,_(s.id)}},oe=s=>{if(!s.destination)return;const a=[...c],[r]=a.splice(s.source.index,1);a.splice(s.destination.index,0,r),f(a)},de=s=>{c.includes(s)||f(a=>[...a,s])},xe=s=>f(a=>a.filter(r=>r!==s)),S=Object.fromEntries($.map(s=>[s.id,s])),z=$.filter(s=>!c.includes(s.id)&&(s.name.toLowerCase().includes(P.toLowerCase())||(s.artist||"").toLowerCase().includes(P.toLowerCase()))),me=c.reduce((s,a)=>{var r;return s+(((r=S[a])==null?void 0:r.duration_seconds)||0)},0);return le?e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[60vh]",children:[e.jsx(T,{className:"w-12 h-12 text-purple-400 animate-pulse"}),e.jsx("p",{className:"mt-4 text-slate-200 text-sm animate-pulse",children:"Loading playlistsâ¦"})]}):e.jsxs("div",{className:"text-white space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[e.jsx("div",{className:"flex-1 min-w-[220px]",children:e.jsx(y,{value:b,onChange:s=>q(s.target.value),onKeyDown:s=>s.key==="Enter"&&Z(),placeholder:"New playlist nameâ¦",className:"bg-black/40 border-white/15 text-white placeholder:text-slate-300 h-10"})}),e.jsxs(L,{onClick:Z,disabled:F||!b.trim(),className:"font-black text-white bg-gradient-to-r from-violet-600 to-purple-500 hover:opacity-90 h-10",children:[F?e.jsx(W,{className:"w-4 h-4 animate-spin mr-2"}):e.jsx(ee,{className:"w-4 h-4 mr-2"}),"Create Playlist"]}),e.jsxs("span",{className:"text-sm text-slate-200 font-semibold",children:[i.length," playlist",i.length!==1?"s":""]})]}),i.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx(T,{className:"w-14 h-14 text-white/10 mx-auto mb-4"}),e.jsx("p",{className:"text-slate-200",children:"No playlists yet. Create one above."})]}):e.jsx("div",{className:"space-y-2",children:i.map(s=>{const a=p===s.id,r=s.cover_color||"#a78bfa",J=(s.track_ids||[]).length,he=(s.track_ids||[]).reduce((t,o)=>{var h;return t+(((h=S[o])==null?void 0:h.duration_seconds)||0)},0);return e.jsxs("div",{className:"rounded-2xl overflow-hidden transition-all",style:{border:`1px solid ${a?r+"55":"rgba(255,255,255,0.08)"}`,background:a?`linear-gradient(145deg, ${r}12, rgba(0,0,0,0.5))`:"rgba(255,255,255,0.03)"},children:[e.jsxs("button",{onClick:()=>Y(s),className:"w-full flex items-center gap-4 px-4 py-3 hover:bg-white/[0.04] transition-all text-left",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:`${r}25`,border:`2px solid ${r}60`},children:e.jsx(T,{className:"w-5 h-5",style:{color:r}})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-black text-white text-sm truncate",children:s.name}),e.jsxs("p",{className:"text-xs text-slate-200",children:[J," track",J!==1?"s":""," · ",k(he)]})]}),!s.is_active&&e.jsx("span",{className:"text-xs font-bold px-2 py-0.5 rounded-full bg-slate-700 text-slate-200 border border-slate-600",children:"Inactive"}),e.jsx("button",{onClick:t=>{t.stopPropagation(),ne(s.id)},className:"p-1.5 rounded-lg hover:bg-red-500/20 transition-colors opacity-0 group-hover:opacity-100 flex-shrink-0",style:{opacity:.6},children:e.jsx(ve,{className:"w-4 h-4 text-red-400"})}),e.jsx(se.div,{animate:{rotate:a?90:0},transition:{duration:.2},className:"flex-shrink-0",children:e.jsx(we,{className:"w-4 h-4 text-slate-300"})})]}),e.jsx(pe,{children:a&&e.jsxs(se.div,{initial:{height:0,opacity:0}
6,animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.25},className:"border-t px-4 pb-5 pt-4 space-y-5",style:{borderColor:`${r}25`},children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(u,{className:"text-slate-100 text-xs font-bold uppercase tracking-wider mb-1.5 block",children:"Playlist Name"}),e.jsx(y,{value:C,onChange:t=>I(t.target.value),className:"bg-black/40 border-white/15 text-white"})]}),e.jsxs("div",{children:[e.jsx(u,{className:"text-slate-100 text-xs font-bold uppercase tracking-wider mb-1.5 block",children:"Description"}),e.jsx(y,{value:M,onChange:t=>R(t.target.value),placeholder:"Optional descriptionâ¦",className:"bg-black/40 border-white/15 text-white placeholder:text-slate-300"})]})]}),e.jsxs("div",{className:"flex items-center gap-5 flex-wrap",children:[e.jsxs("div",{children:[e.jsx(u,{className:"text-slate-100 text-xs font-bold uppercase tracking-wider mb-2 block",children:"Accent Color"}),e.jsx("div",{className:"flex gap-2",children:Ee.map(t=>e.jsx("button",{onClick:()=>O(t),className:"w-7 h-7 rounded-full border-2 transition-all",style:{background:t,borderColor:x===t?"white":"transparent",transform:x===t?"scale(1.2)":"scale(1)"}},t))})]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-white cursor-pointer",children:[e.jsx(be,{checked:B,onCheckedChange:G}),e.jsx("span",{children:"Active / Visible"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center justify-between mb-2",children:e.jsxs(u,{className:"text-slate-100 text-xs font-bold uppercase tracking-wider",children:["Playlist Order (",c.length," tracks · ",k(me),")"]})}),c.length===0?e.jsx("div",{className:"flex items-center justify-center h-24 rounded-xl border-2 border-dashed border-white/10 text-slate-300 text-sm",children:"Add tracks from the right â"}):e.jsx(je,{onDragEnd:oe,children:e.jsx(Ne,{droppableId:"playlist",children:t=>e.jsxs("div",{ref:t.innerRef,...t.droppableProps,className:"space-y-1.5 max-h-72 overflow-y-auto pr-1",children:[c.map((o,h)=>{const n=S[o];if(!n)return null;const E=v[n.genre]||v.ambient;return e.jsx(ye,{draggableId:o,index:h,children:(D,Q)=>e.jsxs("div",{ref:D.innerRef,...D.draggableProps,className:"flex items-center gap-2 px-3 py-2 rounded-xl transition-all",style:{background:Q.isDragging?`${x}25`:"rgba(255,255,255,0.06)",border:`1px solid ${Q.isDragging?x+"50":"rgba(255,255,255,0.08)"}`},children:[e.jsx("span",{className:"text-xs text-slate-300 w-5 text-right flex-shrink-0",children:h+1}),e.jsx("div",{...D.dragHandleProps,className:"flex-shrink-0 cursor-grab active:cursor-grabbing",children:e.jsx(ke,{className:"w-4 h-4 text-slate-300"})}),e.jsx("button",{onClick:()=>ce(n),className:"flex-shrink-0 w-6 h-6 flex items-center justify-center rounded-full",style:{background:`${E.color}20`},children:K===n.id?e.jsx(Ce,{className:"w-3 h-3",style:{color:E.color}}):e.jsx(_e,{className:"w-3 h-3 ml-0.5",style:{color:E.color}})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-white truncate",children:n.name}),e.jsxs("p",{className:"text-xs text-slate-200 truncate",children:[n.artist||"Unknown"," · ",k(n.duration_seconds)]})]}),n.gain_db!==void 0&&n.gain_db!==null&&n.gain_db!==0&&e.jsx(te,{gainDb:n.gain_db}),e.jsx("button",{onClick:()=>xe(o),className:"flex-shrink-0 p-1 rounded hover:bg-red-500/20 transition-colors",children:e.jsx(ge,{className:"w-3.5 h-3.5 text-red-400"})})]})},o)}),t.placeholder]})})})]}),e.jsxs("div",{children:[e.jsx(u,{className:"text-slate-100 text-xs font-bold uppercase tracking-wider mb-2 block",children:"Available Tracks"}),e.jsx(y,{value:P,onChange:t=>X(t.target.value),placeholder:"Search tracksâ¦",className:"bg-black/40 border-white/15 text-white placeholder:text-slate-300 h-8 text-sm mb-2"}),e.jsx("div",{className:"space-y-1.5 max-h-64 overflow-y-auto pr-1",children:z.length===0?e.jsx("p",{className:"text-center text-slate-300 text-sm py-6",children:"All tracks added!"}):z.map(t=>{const o=v[t.genre]||v.ambient;return e.jsxs("button",{onClick:()=>de(t.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-xl text-left transition-all hover:bg-white/[0.08]",style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.07)"},children:[e.jsx("span",{className:"text-base flex-shrink-0",children:o.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-white truncate",children:t.name}),e.jsxs("p",{className:"text-xs text-slate-200 truncate",children:[t.artist||"Unknown"," · ",k(t.duration_seconds)]})]}),t.gain_db!==void 0&&t.gain_db!==null&&t.gain_db!==0&&e.jsx(te,{gainDb:t.gain_db}),e.jsx(ee,{className:"w-4 h-4 text-slate-300 flex-shrink-0"})]},t.id)})})]})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(L,{onClick:ie,disabled:H,className:"font-black text-white",style:{background:`linear-gradient(to right, ${x}, ${x}cc)`},children:H?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-4 h-4 mr-2 animate-spin"}),"Savingâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"w-4 h-4 mr-2"}),"Save Playlist"]})}),e.jsx(L,{onClick:()=>g(null),variant:"outline",className:"border-white/15 text-white hover:bg-white/10",children:"Close"})]})]})})]},s.id)})})]})}export{Xe as default};
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.