1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6260],{76260:(e,t,l)=>{l.d(t,{A:()=>w});var a=l(37876),s=l(14232),n=l(48230),i=l.n(n),r=l(20621),o=l(19512),d=l(85749),c=l(4186),u=l(71134),x=l(91394),p=l(11613);function m(e,t){let l=t.spinKey,a=t.shouldSpin,s={...e};return s[l]=a,s}function h({enabled:e,label:t,spinKey:l,message:n,url:i,timeout:r,setSpinners:d,disabled:u=!1,onDownload:x}){let m=(0,s.useCallback)(e=>{e.preventDefault();let t=e.target;if(t&&"function"==typeof t.blur&&t.blur(),document.activeElement&&"function"==typeof document.activeElement.blur&&document.activeElement.blur(),x){x(),setTimeout(()=>{d({spinKey:l,shouldSpin:!0,timeout:r})},0);return}let a=document.createElement("a");a.href=i,a.setAttribute("download",""),a.rel="noopener",document.body.appendChild(a),a.click(),a.remove(),setTimeout(()=>{d({spinKey:l,shouldSpin:!0,timeout:r}),(0,p.VX)(n)},0)},[l,r,i,n,d,x]);return(0,a.jsx)(o.A,{size:"small",variant:e?"contained":u?"outlined":"contained",component:"button",type:"button",onClick:m,disabled:u||e,children:(0,a.jsxs)("span",{className:"text-xxs",children:[(0,a.jsx)(c.S3Y,{size:16,className:"inline"}),t]})})}let f=s.memo(function({item:e,trackIndex:t,spinners:l,setSpinners:s,isSelected:n,isHighlighted:o,onSelect:d,onToggleSelect:p,trackProps:m,thisTrackOrReleaseIsPlaying:f,inPlayList:w,sessionString:k}){let g=`${e.id}-mp3`,b=`${e.id}-wav`,j=`${e.id}-flac`,v=l[g],y=l[b],N=l[j];return(0,a.jsxs)("li",{className:`flex p-1 flex-row p-2 gap-4 rounded-md place-items-center cursor-pointer select-none border-4 border-dotted ${o?"border-neutral-400":"border-transparent"} ${n?"bg-neutral-700":"bg-neutral-900 hover:bg-neutral-800"}`,onClick:l=>{l.target.closest("a, button, input, [data-no-row-select]")||d(l,e.id,t)},children:[(0,a.jsxs)("div",{className:" w-[60px] shrink-0 flex flex-row place-items-center gap-1 ","data-no-row-select":!0,children:[(0,a.jsx)("div",{className:"w-1/2 md:ml-1 text-2xl "+(w(e)?"text-neutral-700":"text-neutral-400"),onClick:()=>{m.addToPlayList(e)},children:(0,a.jsx)(c.FED,{className:"hover:text-neutral-200 cursor-pointer"})}),(0,a.jsx)("div",{className:"w-1/2 text-3xl text-neutral-200",children:(0,a.jsx)(x.f,{children:f(e)?(0,a.jsx)("div",{onClick:()=>{m.pauseTrack()},children:(0,a.jsx)(c.u3P,{className:"hover:text-neutral-100 cursor-pointer"})}):(0,a.jsx)("div",{onClick:()=>{m.playTrack(e)},children:(0,a.jsx)(c._xj,{className:"hover:text-neutral-100 cursor-pointer"})})})})]}),(0,a.jsx)("div",{className:"w-[40px] text-sm truncate",children:(0,a.jsx)("img",{className:"rounded",height:"50",width:"50",src:(0,u.Zn)(e.source_image_url)})}),(0,a.jsxs)("div",{className:"flex-grow text-sm truncate",children:[(0,a.jsx)(i(),{href:`/track/${e.id}`,prefetch:!1,children:e._full_title}),(0,a.jsx)(r.A,{className:"md:hidden text-xxs",item:e})]}),(0,a.jsx)("div",{className:"text-left w-[100px] shrink-0 hidden md:block text-xs",children:(0,a.jsx)(r.A,{className:"",item:e})}),(0,a.jsxs)("div",{className:"text-left w-[90px] md:w-[250px] shrink-0 flex flex-col md:flex-row gap-x-2 gap-y-1 place-content-center",children:[(0,a.jsx)(h,{enabled:y,spinKey:b,label:"WAV",setSpinners:s,timeout:5e3,url:`/api/download?id=${e.id}${k}&format=wav`,message:"Your wav download will start soon"}),(0,a.jsx)(h,{enabled:v,spinKey:g,label:"MP3-320",setSpinners:s,timeout:1e4,url:`/api/download?id=${e.id}${k}&format=mp3-320`,message:"Your mp3 download will start soon. Mp3 takes a short time to convert first.."}),(0,a.jsx)(h,{enabled:N,spinKey:j,label:"FLAC",setSpinners:s,timeout:1e4,url:`/api/download?id=${e.id}${k}&format=flac`,message:"Your flac download will start soon. Flac takes a short time to convert first.."})]}),(0,a.jsx)("div",{className:"text-left w-[50px] shrink-0 hidden md:block text-xs",children:e.download_count||0}),(0,a.jsx)("div",{className:"w-[50px] shrink-0 text-center hidden md:block rounded p-1","data-no-row-select":!0,onClick:t=>{t.stopPropagation(),p(e.id)},children:(0,a.jsx)("input",{type:"checkbox",id:`chk-${e.id}`,checked:n,onChange:()=>{},className:"pointer-events-none"})})]})});function w({tracks:e=[],purchaseSessionId:t,downloadFn:l,downloadAll:n,...i}
1){let[r,o]=(0,s.useState)({}),[u,x]=(0,s.useState)(null),k=(0,s.useRef)(null),[g,b]=(0,s.useState)(!1),j=(0,s.useRef)(null),v=(0,s.useCallback)(e=>{k.current=e,x(e)},[]);(0,s.useEffect)(()=>{let e=()=>{j.current&&b(j.current.getBoundingClientRect().top<=46)};return window.addEventListener("scroll",e),()=>window.removeEventListener("scroll",e)},[]);let y=(0,s.useCallback)(()=>{(0,p.uA)("Maximum 100 tracks can be selected for download at once")},[]),N=(0,s.useCallback)(()=>{o({}),v(null)},[v]),S=(0,s.useCallback)(e=>{let t=String(e),l=!1;o(e=>{let a={...e};if(a[t])delete a[t];else{if(Object.keys(a).length>=100)return l=!0,e;a[t]=!0}return a}),l&&y()},[y]),C=(0,s.useCallback)((t,l,a)=>{if(t.preventDefault(),t.ctrlKey||t.metaKey)return void S(l);let s=k.current;if(t.shiftKey&&null!=s){let t=Math.min(s,a),l=Math.max(s,a),n=e.slice(t,l+1).map(e=>String(e.id)),i=!1;o(e=>{let t={...e},l=Object.keys(t).length;for(let e of n)if(!t[e]){if(l>=100){i=!0;break}t[e]=!0,l++}return t}),i&&y(),v(null);return}v(a)},[e,y,v,S]),P=t?`&session_id=${t}`:"",T=Object.keys(r),$=T.length>5,A="/api/download?format=mp3-320"+P+T.map(e=>`&id=${e}`).join(""),L="/api/download?format=flac"+P+T.map(e=>`&id=${e}`).join(""),M="/api/download?format=wav"+P+T.map(e=>`&id=${e}`).join(""),_=(0,s.useCallback)(async(e,l,a)=>{let s=await fetch("/api/download/batch",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({format:e,trackIds:T,session_id:t??void 0})}),n=await s.json().catch(()=>({}));if(!s.ok){(0,p.UG)(n.error||"Failed to queue download"),F({spinKey:l,shouldSpin:!1});return}N(),(0,p.VX)(a),F({spinKey:l,shouldSpin:!1})},[T,t,N]),[K,F]=(0,s.useReducer)(m,{}),E=(0,s.useCallback)(e=>{F(e),e.shouldSpin&&setTimeout(()=>{F({...e,shouldSpin:!1})},e.timeout)},[]),D=(0,s.useCallback)(e=>{if(i.isPlaying&&i.playingTrack)if(e.tracks)return e.tracks.map(e=>e.id).includes(i.playingTrack.id);else return i.playingTrack.id===e.id},[i.isPlaying,i.playingTrack]),V=(0,s.useCallback)(e=>i.playList?.find(t=>t.id===e.id),[i.playList]),Y=(0,s.useMemo)(()=>({addToPlayList:i.addToPlayList,playTrack:i.playTrack,pauseTrack:i.pauseTrack,isPlaying:i.isPlaying,playingTrack:i.playingTrack,playList:i.playList}),[i.addToPlayList,i.playTrack,i.pauseTrack,i.isPlaying,i.playingTrack,i.playList]),z=({className:e=""})=>{let t=T.length>0,l=!t;return(0,a.jsx)("div",{className:`border rounded-lg p-3 shadow-lg transition-all duration-300 ${t?"bg-neutral-800 border-neutral-700":"bg-neutral-900 border-neutral-800 opacity-60"} ${e}`,children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(c.S3Y,{size:20,className:t?"text-blue-400":"text-neutral-600"}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsxs)("span",{className:`font-medium transition-colors duration-300 ${t?"text-white":"text-neutral-500"}`,children:[t?`Download ${T.length} selected track${T.length>1?"s":""}`:"Select tracks to download",t&&(0,a.jsxs)("span",{className:"text-neutral-400 text-sm ml-2",children:["(",T.length,"/",100,$?", queued download":"",")"]})]}),t&&(0,a.jsx)("button",{onClick:N,className:"text-xs text-neutral-400 hover:text-red-400 transition-colors duration-200 underline",title:"Clear all selections",children:"Clear all"})]})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(h,{enabled:K.wavSel,spinKey:"wavSel",label:"WAV",setSpinners:E,timeout:2e4,url:M,message:$?"Preparing your WAV download.":"Your WAV download will start soon...",onDownload:$?()=>_("wav","wavSel","Preparing your WAV download."):void 0,disabled:l}),(0,a.jsx)(h,{enabled:K.mp3Sel,spinKey:"mp3Sel",label:"MP3",setSpinners:E,timeout:3e4,url:A,message:$?"Preparing your MP3 download.":"Your MP3 download will start soon. MP3 takes a short time to convert first..",onDownload:$?()=>_("mp3-320","mp3Sel","Preparing your MP3 download."):void 0,disabled:l}),(0,a.jsx)(h,{enabled:K.flacSel,spinKey:"flacSel",label:"FLAC",setSpinners:E,timeout:3e4,url:L,message:$?"Preparing your FLAC download.":"Your FLAC download will start soon. FLAC takes a short time to convert first..",onDownload:$?()=>_("flac","flacSel","Preparing your FLAC download."):void 0,disabled:l})]})]})})};return(0,a.jsxs)(a.Fragment,{children:[g&&T.length>0&&(0,a.jsx)(z,{className:"fixed top-[calc(46px+env(safe-area-inset-top,0px)+0.5rem)] left-1/2 -translate-x-1/2 z-40 shadow-2xl max-w-2xl w-[calc(100%-2rem)]"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{ref:j,className:"mb-4",children:(0,a.jsx)(z,{})}),(0,a.jsxs)("ul",{className:"mt-2 flex flex-col gap-y-2",children:[(0,a.jsxs)("li",{className:"flex p-1 flex-row bg-neutral-900 rounded-md gap-4 text-xs place-items-center text-neutral-400 ",children:[(0,a.jsx)("div",{className:" w-[60px]"}),(0,a.jsx)("div",{className:" w-[40px]"}),(0,a.jsx)("div",{className:"flex-grow",children:"Title"}),(0,a.jsx)("div",{className:"text-left w-[100px] hidden md:block",children:"Artist(s)"}),(0,a.jsx)("div",{className:"text-left w-[90px] md:w-[250px] text-center",children:(0,a.jsx)(d.A,{})}),(0,a.jsx)("div",{className:"text-left w-[50px] hidden md:block",children:"DL"}),(0,a.jsx)("div",{className:"text-left w-[50px] text-center hidden md:block "})]}),e.map((e,t)=>{let l=r[String(e.id)]||!1;return(0,a.jsx)(f,{spinners:K,setSpinners:E,item:e,trackIndex:t,isSelected:l,isHighlighted:u===t,onSelect:C,onToggleSelect:S,trackProps:Y,thisTrackOrReleaseIsPlaying:D,inPlayList:V,sessionString:P},e._key)})]})]})]})}},85749:(e,t,l)=>{var a=l(29563);t.A=void 0;var s=a(l(78652)),n=l(37876);t.A=(0,s.default)((0,n.jsx)("path",{d:"M19 9h-4V3H9v6H5l7 7zM5 18v2h14v-2z"}),"FileDownload")}}]);
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.