import{O as g,ak as m,j as u,o as v,c as l,al as p,aj as r,am as P,m as w,b as h}from"./index-D9R0tRpC.js";const x=()=>{const n=g(),[f]=m(),[a,d]=u();let[y,c]=u(!0);const o=async e=>{c(!0);try{if(e){const t=await r.get(e);d(t),console.log("set playlist",t)}else d(void 0),console.log("set playlist undefined")}finally{c(!1)}};return v(async()=>{await o(f.id)}),l(h,{get when(){return w(()=>!!a())()&&!y()},get fallback(){return l(P,{})},get children(){return l(p,{type:"Playlist",get id(){return a()?.id},get name(){return a()?.name},get videos(){return a()?.videos},get isLoading(){return!a()},onPlayAll:e=>n?.actions?.setQueue(0,a().videos,!1,!1,e),onShuffleAll:e=>n?.actions?.setQueue(0,a().videos,!1,!0,e),onPlay:(e,t)=>{const s=a()?.videos;s&&n?.actions?.setQueue(s.findIndex(i=>i===e),s,!1,!1,t)},onRemove:async e=>{const t=a()?.id,s=a()?.videos;if(!t||!s)return;const i=s.indexOf(e);await r.removeContentFromPlaylists(t,i),o(t)},onAddToQueue:e=>n?.actions?.addToQueue(e),onDownload:()=>{},refetch:()=>o(),onDragEnd:async()=>{const e=a();e&&await r.createOrupdate(e)}})}})};export{x as default};
