1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3382],{419:(e,r,t)=>{t.d(r,{PlayerProvider:()=>l,F:()=>u});var n=t(5155),a=t(2115),o=t(4477);let c=(0,o.createServerReference)("609f0265ce2181a2c6903a47f2e8a8463d854c8c03",o.callServer,void 0,o.findSourceMapURL,"incrementPlayCount"),i=(0,a.createContext)(void 0);function l(e){let{children:r}=e,[t,o]=(0,a.useState)(null),[l,u]=(0,a.useState)(!1),[d,s]=(0,a.useState)(!1),[f,g]=(0,a.useState)(null),[v,m]=(0,a.useState)([]),[h,k]=(0,a.useState)(0),[p,y]=(0,a.useState)(0),[b,E]=(0,a.useState)(!1),[w,C]=(0,a.useState)(!0),L=(0,a.useRef)(null),_=(0,a.useRef)(!1),R=(0,a.useRef)(!1),P=(0,a.useRef)(null),T=(0,a.useRef)(0),x=(0,a.useRef)(null),S=(0,a.useCallback)((e,r)=>{console.log("[Player] ".concat(e),void 0!==r?r:"")},[]),A=(0,a.useCallback)(e=>{if(!e)return!1;try{new URL(e)}catch(r){return console.error("Invalid URL format:",e),!1}let r=[".mp3",".wav",".ogg",".aac",".m4a",".flac"].some(r=>e.toLowerCase().endsWith(r)),t=e.includes("?");return r||t},[]),I=(0,a.useCallback)(e=>{if(g(e),u(!1),s(!1),w&&t&&v.length>1){let r=v.findIndex(e=>e.id===t.id);-1!==r&&r<v.length-1&&(x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{S("Skipping to next track due to error: ".concat(e)),U()},3e3))}},[t,v,w,S]);(0,a.useEffect)(()=>{if(!R.current){S("Initializing audio element");try{let e=new Audio;e.crossOrigin="anonymous",e.preload="auto",L.current=e,R.current=!0;let r=()=>{k(e.currentTime)},n=()=>{S("Audio load started"),s(!0),g(null)},a=()=>{S("Metadata loaded, duration: ".concat(e.duration)),y(e.duration)},o=()=>{S("Can play event, pendingPlay: ".concat(_.current)),s(!1),g(null),T.current=0,_.current&&M()},c=()=>{S("Play event fired"),u(!0),E(!0),_.current=!1,s(!1),g(null)},i=()=>{S("Pause event fired"),u(!1)},l=()=>{if(S("Track ended"),u(!1),t&&v.length>0){let e=v.findIndex(e=>e.id===t.id);if(-1!==e){if(e===v.length-1)S("End of queue reached, looping back to first track: ".concat(v[0].title)),D(v[0]);else{let r=v[e+1];S("Auto-advancing to next track: ".concat(r.title)),D(r)}}}},d=r=>{console.error("Audio error:",r);let n="Error loading audio";if(r.message)n=r.message;else if(e.error)switch(e.error.code){case MediaError.MEDIA_ERR_ABORTED:n="Playback aborted by the user";break;case MediaError.MEDIA_ERR_NETWORK:n="Network error while loading audio";break;case MediaError.MEDIA_ERR_DECODE:n="Audio decoding error";break;case MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED:n="Audio format not supported";break;default:n="Unknown error (".concat(e.error.code,")")}t&&T.current<3?(T.current++,S("Retry attempt ".concat(T.current," for track: ").concat(t.title)),setTimeout(()=>{if(t){let r="?cb=".concat(Date.now());e.src=t.file_url.includes("?")?"".concat(t.file_url,"&cb=").concat(Date.now()):"".concat(t.file_url).concat(r),e.load(),_.current&&M()}},1e3)):I(n)};return e.addEventListener("timeupdate",r),e.addEventListener("loadstart",n),e.addEventListener("loadedmetadata",a),e.addEventListener("canplay",o),e.addEventListener("play",c),e.addEventListener("pause",i),e.addEventListener("ended",l),e.addEventListener("error",d),()=>{P.current&&clearTimeout(P.current),x.current&&clearTimeout(x.current),e.pause(),e.src="",e.removeEventListener("timeupdate",r),e.removeEventListener("loadstart",n),e.removeEventListener("loadedmetadata",a),e.removeEventListener("canplay",o),e.removeEventListener("play",c),e.removeEventListener("pause",i),e.removeEventListener("ended",l),e.removeEventListener("error",d)}}catch(e){console.error("Error initializing audio:",e)}}},[t,v,S,I]);let M=(0,a.useCallback)(()=>{if(!L.current)return!1;S("Attempting to play audio");try{let e=L.current.play();if(void 0!==e)return e.then(()=>{S("Playback started successfully"),u(!0),_.current=!1,s(!1),g(null),t&&c(t.id).catch(e=>{console.error("Error incrementing play count:",e)}),P.current&&(clearTimeout(P.current),P.current=null)}).catch(e=>{console.error("Playback error:",e),u(!1),s(!1);let r="Playback error";r="NotAllowedError"===e.name?"Playback not allowed. Please interact with the page first.":"NotSupportedError"===e.name?"Audio format not supported by your browser.":"Playback error: ".concat(e.message||"Unknown error"),I(r),_.current=!0,P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{var e;_.current&&(null===(e=L.current)||void 0===e?void 0:e.readyState)>=3&&(S("Retrying playback after timeout"),M())},1e3)}),!0}catch(e){console.error("Error in attemptPlay:",e),u(!1),s(!1),I("Playback error: ".concat(e instanceof Error?e.message:"Unknown error"))}return!1},[t,S,I]),D=(0,a.useCallback)(e=>{if(L.current){if(!A(e.file_url)){S("Invalid audio URL for track: ".concat(e.title)),I("Invalid audio URL for track: ".concat(e.title));return}S("Changing track to: ".concat(e.title,", URL: ").concat(e.file_url)),T.current=0,x.current&&(clearTimeout(x.current),x.current=null),s(!0),g(null),k(0),y(e.duration||0),_.current=!0,o(e);try{let r="";e.file_url.toLowerCase().endsWith(".mp3")?r="audio/mpeg":e.file_url.toLowerCase().endsWith(".wav")?r="audio/wav":e.file_url.toLowerCase().endsWith(".ogg")?r="audio/ogg":e.file_url.toLowerCase().endsWith(".aac")?r="audio/aac":e.file_url.toLowerCase().endsWith(".m4a")?r="audio/mp4":e.file_url.toLowerCase().endsWith(".flac")&&(r="audio/flac"),r&&L.current.canPlayType(r)&&(S("Setting MIME type: ".concat(r)),L.current.type=r),L.current.src=e.file_url,L.current.load(),L.current.readyState>=3&&M(),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{var e;_.current&&(null===(e=L.current)||void 0===e?void 0:e.readyState)>=3&&(S("Attempting playback after timeout"),M())},1e3)}catch(e){console.error("Error changing track:",e),s(!1),_.current=!1,I("Error loading track: ".concat(e instanceof Error?e.message:"Unknown error"))}}},[M,S,A,I]);(0,a.useEffect)(()=>
1{if(!l||!L.current)return;let e=setInterval(()=>{L.current&&k(L.current.currentTime)},1e3);return()=>clearInterval(e)},[l]),(0,a.useEffect)(()=>{if(!d)return;let e=setTimeout(()=>{d&&(S("Loading state timeout - resetting"),s(!1),f||I("Loading timed out. Please try again."))},1e4);return()=>clearTimeout(e)},[d,f,S,I]);let U=(0,a.useCallback)(()=>{if(!t||0===v.length)return;let e=v.findIndex(e=>e.id===t.id);if(-1!==e){if(e===v.length-1)S("End of queue reached, looping back to first track: ".concat(v[0].title)),D(v[0]);else{let r=v[e+1];S("Going to next track: ".concat(r.title)),D(r)}}},[t,v,D,S]),N=(0,a.useCallback)(e=>{S("Play track called: ".concat(e.title)),E(!0),m(r=>r.some(r=>r.id===e.id)?r:[...r,e]),D(e)},[D,S]),W=(0,a.useCallback)(()=>{if(L.current){S("Pause track called"),_.current=!1;try{L.current.pause()}catch(e){console.error("Error pausing track:",e),u(!1)}}},[S]),O=(0,a.useCallback)(()=>{L.current&&t&&(S("Resume track called"),_.current=!0,g(null),M())},[t,M,S]),z=(0,a.useCallback)(()=>{if(!t||0===v.length)return;let e=v.findIndex(e=>e.id===t.id);if(e<=0)return;let r=v[e-1];S("Going to previous track: ".concat(r.title)),D(r)},[t,v,D,S]),j=(0,a.useCallback)(e=>{m(r=>[...r,e])},[]),F=(0,a.useCallback)(()=>{m([])},[]),q=(0,a.useCallback)(e=>{if(L.current)try{L.current.currentTime=e,k(e)}catch(e){console.error("Error setting current time:",e)}},[]),B=(0,a.useCallback)(()=>{E(!1),W()},[W]),G=(0,a.useCallback)(()=>{t&&E(!0)},[t]),$=(0,a.useCallback)(e=>{if(0===e.length)return;S("Play all called with ".concat(e.length," tracks"));let r=e.filter(e=>A(e.file_url));if(0===r.length){I("No valid audio tracks found in the playlist");return}r.length<e.length&&S("Filtered out ".concat(e.length-r.length," invalid tracks")),m(r),D(r[0]),E(!0)},[D,S,A,I]);return(0,n.jsx)(i.Provider,{value:{currentTrack:t,isPlaying:l,queue:v,playTrack:N,pauseTrack:W,resumeTrack:O,nextTrack:U,previousTrack:z,addToQueue:j,clearQueue:F,setQueue:m,audioElement:L.current,currentTime:h,duration:p,setCurrentTime:q,isPlayerVisible:b,hidePlayer:B,showPlayer:G,playAll:$,isLoading:d,error:f,skipToNextOnError:w,setSkipToNextOnError:C},children:r})}function u(){let e=(0,a.useContext)(i);if(void 0===e)throw Error("usePlayer must be used within a PlayerProvider");return e}},3999:(e,r,t)=>{t.d(r,{a3:()=>c,cn:()=>o});var n=t(2596),a=t(9688);function o(){for(var e=arguments.length,r=Array(e),t=0;t<e;t++)r[t]=arguments[t];return(0,a.QP)((0,n.$)(r))}function c(e){let r=Math.floor(e/60),t=Math.floor(e%60);return"".concat(r,":").concat(t.toString().padStart(2,"0"))}},7168:(e,r,t)=>{t.d(r,{$:()=>u,r:()=>l});var n=t(5155),a=t(2115),o=t(9708),c=t(2085),i=t(3999);let l=(0,c.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),u=a.forwardRef((e,r)=>{let{className:t,variant:a,size:c,asChild:u=!1,...d}=e,s=u?o.DX:"button";return(0,n.jsx)(s,{className:(0,i.cn)(l({variant:a,size:c,className:t})),ref:r,...d})});u.displayName="Button"}}]);
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.