1 2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a74cb331-cad1-54a0-950c-085168422aae")}catch(e){}}(); 3(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,983455,e=>{"use strict";var t=e.i(673157),i=e.i(249892);let s="share-follow-shown-ids",r=null;function n(){if(null===r)try{let e=localStorage.getItem(s),t=e?JSON.parse(e):[];r=Array.isArray(t)?t:[]}catch{r=[]}return r}function a(e){try{localStorage.setItem(s,JSON.stringify(e))}catch{}}function o(e){let t=n();t.includes(e)||(t.push(e),t.length>50&&t.splice(0,t.length-50),a(t))}let l=(0,i.createContext)(void 0);e.s(["ShareFollowModalProvider",0,({children:e})=>{let[s,r]=(0,i.useState)(null),[u,d]=(0,i.useState)(!1),[c,h]=(0,i.useState)(!1),p=(0,i.useRef)(new Set),m=(0,i.useRef)(null),g=(0,i.useRef)(null);(0,i.useEffect)(()=>()=>{g.current&&clearTimeout(g.current)},[]);let y=(0,i.useCallback)(()=>{var e;let t,i;d(!0),h(!1),s?.shareId&&(e=s.shareId,-1!==(i=(t=n()).indexOf(e))&&(t.splice(i,1),a(t))),g.current&&(clearTimeout(g.current),g.current=null),m.current=null},[s?.shareId]),S=(0,i.useCallback)(()=>{r(null),d(!1),h(!1),g.current&&(clearTimeout(g.current),g.current=null),m.current=null},[]),P=(0,i.useCallback)(()=>{!s?.shareId||u||p.current.has(s.shareId)||g.current&&m.current===s.shareId||(g.current&&clearTimeout(g.current),m.current=s.shareId,g.current=setTimeout(()=>{m.current&&(p.current.add(m.current),o(m.current)),h(!0),g.current=null,m.current=null},1e4))},[s?.shareId,u]),v=(0,i.useCallback)(()=>!!s?.shareId&&!u&&(p.current.add(s.shareId),o(s.shareId),h(!0),!0),[s?.shareId,u]),f=(0,i.useCallback)(e=>n().includes(e),[]);return(0,t.jsx)(l.Provider,{value:{sharerInfo:s,setSharerInfo:r,isModalDismissed:u,dismissModal:y,resetModal:S,shouldShowModal:c,triggerModalAfterDelay:P,triggerModalImmediately:v,wasShownBefore:f},children:e})},"useShareFollowModal",0,()=>{let e=(0,i.useContext)(l);if(void 0===e)throw Error("useShareFollowModal must be used within a ShareFollowModalProvider");return e}])},855181,e=>{"use strict";let t=new Set;e.s(["notifyUnrecoverablePlayback",0,function(){t.forEach(e=>e())},"subscribeUnrecoverablePlayback",0,function(e){return t.add(e),()=>{t.delete(e)}}])},92963,e=>{"use strict";var t,i=e.i(323372),s=e.i(379309),r=e.i(197895),n=e.i(285809),a=e.i(98638),o=e.i(870357);function l(e){if(!e)return"";let t=e.audio_url??"",i=(0,o.findAudioMediaItem)(e.media_urls,{encrypted:!1,delivery:"progressive"})??(0,o.findAudioMediaItem)(e.media_urls,{encrypted:!1,delivery:"streaming"});return i?.url??t}function u(e,t){let i=t.encrypted?(0,o.findAudioMediaItem)(e.media_urls,{encrypted:!0}):void 0,s=l(e),r=s;s===e.audio_url&&(r=t.preferredAudioUrl??s,(0,o.isAudiopipeUrl)(s)&&t.useStreamingWebm&&(r=(0,o.modifyClipAudioUrl)(s,{queryParams:{format:"webm"}})));let n=i?.url??r;return{contentId:e.id,url:n,isComplete:(0,o.isComplete)(e),isStreaming:i?.delivery==="streaming"||(0,o.isAudiopipeUrl)(n),duration:(0,o.getKnownDurationSeconds)(e)}}var d=e.i(208070);let c=[{threshold:5,milestone:"5s",actionName:"SongPlayed5s"},{threshold:30,milestone:"30s",actionName:"SongPlayed30s"},{threshold:60,milestone:"60s",actionName:"SongPlayed60s"}],h=null,p=null;function m(){h=null,S()}function g(){!h||h.fired.has("completed")||null!==h.lastPosition&&(h.fired.add("completed"),h.onMilestone("completed","SongCompleted"))}function y(){if(!h)return;let e=(0,d.getAudioCurrentTime)(),t=h.lastPosition;if(h.lastPosition=e,null===t||!(0,d.getIsPlaying)())return;let i=e-t;if(!(i<=0)&&!(i>2)){let e;for(let{threshold:e,milestone:t,actionName:s}of(h.accruedSeconds+=i,c))h.accruedSeconds>=e&&!h.fired.has(t)&&(h.fired.add(t),h.onMilestone(t,s));(e=h?.fired)&&c.every(({milestone:t})=>e.has(t))&&S()}}function S(){p?.(),p=null}class P{element=null;active=null;onSettled;onError;constructor(e){this.onSettled=e.onSettled,this.onError=e.onError}setHTMLElement(e){this.element!==e&&this.cancel(),this.element=e}get isTransitioning(){return!!this.active?.metadata}get hasPendingSeek(){return this.active?.pendingSeekTo!=null}getCurrentTime(){return this.active?.pendingSeekTo!=null?this.active.pen
3dingSeekTo:this.isTransitioning?this.active.intent.seekTo:(0,d.getAudioCurrentTime)()}getShouldPlay(){return this.active?.intent.shouldPlay??(0,d.getIsPlaying)()}setPlaying(e){let t=this.active;if(e&&(0,d.setPlayIntent)("play"),t&&(t.intent.shouldPlay=e),e)if(t)return t.attached?this.play(t):t.startRequest??void 0;else{let e=(0,d.playAudio)();return e.catch(this.onError),e}t&&(t.playRequest=null),(0,d.pauseAudio)()}shouldReplaceBeforeSeek(e,t){return!(this.isTransitioning||!e.isComplete||!e.url||e.isStreaming||(0,o.isAudiopipeUrl)(e.url))&&!!this.isBoundSourceUnseekableTo(t)&&(this.isLiveSource()||null!==e.duration)}seek(e){let{time:t,source:i}=e;!Number.isFinite(t)||(this.active&&(this.active.intent.seekTo=t,this.active.pendingSeekTo=this.getPendingLiveSeekTo(this.active)),this.isTransitioning||(i&&this.shouldReplaceBeforeSeek(i.description,t)?this.replace({source:i,seekTo:t}):(0,d.seekAudio)(t)))}updateSource(e){let t=this.active,i=e.description;!t||null===t.pendingSeekTo||i.contentId!==t.source.description.contentId||!i.isComplete||!i.url||i.isStreaming||(0,o.isAudiopipeUrl)(i.url)||this.replace({source:e,seekTo:t.pendingSeekTo})}replace(e){this.select({source:e.source,intent:{seekTo:e.seekTo??this.getCurrentTime(),shouldPlay:this.getShouldPlay()}})}select(e){let t=this.element;if(!t)return;this.cancel();let i={source:e.source,intent:{...e.intent},controller:new AbortController,metadata:new AbortController,attached:!1,startRequest:null,playRequest:null,pendingSeekTo:e.source.description.isStreaming&&e.intent.seekTo>0?e.intent.seekTo:null};this.active=i,(0,d.pauseAudio)();let s=()=>{this.active===i&&null!==i.pendingSeekTo&&!t.seeking&&t.readyState>=3&&t.currentTime>=i.pendingSeekTo&&(i.pendingSeekTo=null)};for(let e of["seeked","canplay","timeupdate"])t.addEventListener(e,s,{signal:i.controller.signal});let r=()=>{this.active===i&&i.attached&&((0,d.seekAudio)(i.intent.seekTo),this.finishMetadata(i),i.intent.shouldPlay?t.paused&&this.play(i):(0,d.pauseAudio)())};t.addEventListener("loadedmetadata",r,{signal:i.metadata.signal}),t.addEventListener("error",()=>{i.attached&&this.fail(i,t.error??Error("Audio source failed"))},{signal:i.controller.signal});let n=()=>{if(this.active===i&&(i.attached=!0,i.pendingSeekTo=this.getPendingLiveSeekTo(i),(0,d.seekAudio)(i.intent.seekTo),t.readyState>=1&&r(),i.intent.shouldPlay))return this.play(i)};try{let s=e.source.attach({element:t,signal:i.controller.signal});s?(i.startRequest=s.then(n),i.startRequest.catch(e=>{i.attached||this.fail(i,e)})):n()}catch(e){this.fail(i,e)}}cancel(){let e=this.active;this.active=null,e?.metadata?.abort(),e?.controller.abort()}stop(){this.cancel(),(0,d.stopAudio)(),this.onSettled()}play(e){if(e.playRequest)return e.playRequest;let t=(0,d.playAudio)();return e.playRequest=t,t.then(()=>{this.active===e&&e.playRequest===t&&(e.playRequest=null,this.active!==e||e.intent.shouldPlay||(0,d.pauseAudio)())},i=>{if(this.active===e&&e.playRequest===t&&(e.playRequest=null,e.intent.shouldPlay)){if(i instanceof DOMException&&("NotAllowedError"===i.name||"AbortError"===i.name)){e.intent.shouldPlay=!1,this.onError(i);return}this.fail(e,i)}}),t}fail(e,t){if(this.active===e)if(e.source.onError){if(e.source.onError(t),this.active!==e)return;e.attached?this.finishMetadata(e):this.stop()}else this.stop(),this.onError(t)}finishMetadata(e){e.metadata&&(e.metadata.abort(),e.metadata=null,this.onSettled())}isLiveSource(){return!!this.element&&((0,o.isAudiopipeUrl)(this.element.src)||!!this.active?.source.description.isStreaming)}isBoundSourceUnseekableTo(e){if(!this.element)return!1;let t=this.element.seekable;for(let i=0;i<t.length;i++)if(e>=t.start(i)&&e<=t.end(i))return!1;return!!this.isLiveSource()||!Number.isFinite(this.element.duration)&&e>this.getSeekableEnd()}getSeekableEnd(){let e=this.element?.seekable;return e?.length?e.end(e.length-1):0}getPendingLiveSeekTo(e){let t=e.intent.seekTo;return e.source.description.isStreaming&&t>0&&(!e.attached||t>this.getSeekableEnd())?t:null}}var v=e.i(277565);let f=!1,b=!1;var A=e.i(615383),C=e.i(830178),T=e.i(330018),E=e.i(38232),M=e.i(61374
36),k=e.i(166700),I=e.i(382403),_=e.i(63300),L=e.i(855181),w=e.i(163522);class U{element;constructor(e){this.element=e}play(){return this.element.play()}pause(){this.element.pause()}load(){this.element.load()}get src(){return this.element.src}set src(e){this.element.src=e}get currentTime(){return this.element.currentTime}set currentTime(e){this.element.currentTime=e}get duration(){return this.element.duration}get badgeTitle(){return null}get error(){return this.element.error}get paused(){return this.element.paused}get volume(){return this.element.volume}set volume(e){this.element.volume=e}get muted(){return this.element.muted}set muted(e){this.element.muted=e}addEventListener(e,t,i){this.element.addEventListener(e,t,i)}removeEventListener(e,t,i){this.element.removeEventListener(e,t,i)}getElement(){return this.element}}var D=e.i(345730),x=e.i(629265),N=e.i(725516),O=e.i(947485),q=e.i(42305),F=e.i(972404),R=e.i(245321),B=e.i(941011),j=e.i(418627);let V=(0,O.createDebugLogger)({name:"Playbar",silent:!F.isDevOrStaging});function W(e){try{return new URL(e,"https://placeholder").pathname}catch{return e}}let H="play-state",Q=new Date("2025-04-27"),$=new Date("2025-09-03"),K=`${N.UnifiedFeedPrefix.GenericPlaylist}:`;var G=((t={}).PLAY="play",t.PAUSE="pause",t.WAITING="waiting",t.STALLED="stalled",t.SEEKED="seeked",t.SEEKING="seeking",t.PLAYING="playing",t.ENDED="ended",t.SUSPEND="suspend",t.ERROR="error",t.DURATION_CHANGE="durationchange",t.TIME_UPDATE="timeupdate",t);class z{startTime=0;endTime=0;clip=null;songSessionId="";previousSongSessionId="";actionIndex=-1;noClipPlayCallback=null;recentlyPlayedIds=[];audioElement=null;silentAudioElement=null;currentBlobUrl=null;mangoStreamType=null;playAttemptedAt=null;activePlaylistListenId=null;pendingPlaylistListenClipId=null;pendingPlaylistListenPreviousId=null;hasSetListenContextReaction=!1;repeat=!1;loadingStream=!1;loadingDuration=!1;isLoadingClip=!1;mediaManager=new P({onSettled:()=>this.updatePlaybarState(),onError:e=>V.warn("Playback failed:",e)});isInitialized=!1;hasSetListeners=!1;isClipPreloaded=!1;isDragging=!1;disableStepForward=!1;stopAtSeconds=null;stopAtArmed=!1;root;get apiClient(){return this.root.apiClient}get logger(){return this.root.logger}get isInPreviewMode(){return this.clip?.preview_seconds!=null&&this.clip.preview_seconds>0}constructor(e){this.root=e,(0,D.makeAutoObservableSubstore)(this,{persistToLocalStorage:!1,debouncedUpsertPlaybarState:!1})}initialize(){this.loadFromLocalStorage(),this.initLocalStorageUpdate()}handleBeforeUnload=()=>{this.upsertPlaybarState()};get shuffle(){return this.root.queue.shuffle}getStreamingSourceHost(){let e=this.audioElement?.src??"";if((0,o.isAudiopipeUrl)(e))return new URL(e).hostname;let t=this.clip?.audio_url??"";return(0,o.isAudiopipeUrl)(t)?new URL(t).hostname:null}getAudioPlayerEvent(e,t){this.actionIndex=this.actionIndex+1;let i=null!=this.root.queue.activeQueue&&null!=this.root.queue.contextClipCount&&"context"===this.root.queue.activeQueue&&this.root.queue.contextQueueIndex>=this.root.queue.contextClipCount,s="manual"===this.root.queue.activeQueue;return{songSessionId:this.songSessionId,hasClip:this.clip?.id!=null,songId:this.clip?.id||void 0,contextId:this.root.queue.contextId??void 0,contextType:this.root.queue.contextType??void 0,isSongAutoplayQueue:i,isSongManualQueue:s,startTime:this.startTime,endTime:this.endTime,isPlaying:(0,d.getIsPlaying)(),playDuration:this.endTime-this.startTime,isAudioElementNull:!this.audioElement,audioElementCurrentTime:this.audioElement?.currentTime,actionName:e,isUserSongOwner:this.root.session?.userId!==void 0&&this.root.session?.userId===t,volume:((0,d.getAudioMuted)()?0:(0,x.getDisplayVolumeFromAudioVolume)((0,d.getAudioVolume)()))*100,clickSourceUrl:"u">typeof location?location.pathname:"",isShuffleOn:this.shuffle,isAutoplayOn:this.root.queue.continuous,isRepeatOn:this.repeat,userId:this.root.session?.userId,previousSongSessionId:this.previousSongSessionId,actionIndex:this.actionIndex,songLength:this.clip?.metadata?.duration||0,modelVersion:this.clip?.major_model_version,modelKey:this.clip?.model_name,metadata:{surfaceType:this.root.queue.surfaceType,surfaceId:this.root.queue.surfaceId,browserHistory:(0,a.getNavigationHistory)(),streamType:null!==this.mangoStreamType?`mango-${this.mangoStreamType}`:void 0}}}setSilentAudioElement(e){this.silentAudioElement=e}resumeSilentAudioForMediaSession(){this.silentAudioElement?.play()?.catch(()=>{})}isPlaylistListenContext(){let{contextType:e,contextId:t}=this.root.queue;return e===w.ContextType.Playlist||e===w.ContextType.UnifiedFeed&&"string"==typeof t&&t.startsWith(K)}getPlaylistListenContextId(){let{contextType:e,contextId:t}=this.root.queue;return t?e===w.ContextType.Playlist?t:e===w.ContextType.UnifiedFeed&&t.startsWith(K)?t.slice(K.length):null:null}getPlaylistListenProperties(){let e=this.root.queue,t=this.clip?.id,i=this.getPlaylistListenContextId();if(!i||!t)return null;let s=e.contextClips;return!Array.isArray(s)||s.some(e=>e?.id===t)?{playlist_id:i,playlist_size:e.contextClipCount??void 0,surface_type:e.surfaceType??void 0,surface_id:e.surfaceId??void 0}:null}
3setCurrentClip(e){this.clip?.id!==e?.id&&this.mediaManager.cancel(),this.clip=e,e||(this.activePlaylistListenId=null,this.pendingPlaylistListenClipId=null,this.pendingPlaylistListenPreviousId=null)}syncPlaylistContextFromQueue(){let e=this.clip?.id;if(!e||!this.isPlaylistListenContext()){this.activePlaylistListenId=null,this.pendingPlaylistListenClipId=null,this.pendingPlaylistListenPreviousId=null;return}this.pendingPlaylistListenClipId===e&&this.logPlaylistListenSession()}initListenContextUpdate(){this.hasSetListenContextReaction||(this.hasSetListenContextReaction=!0,(0,s.reaction)(()=>({clipId:this.clip?.id,contextType:this.root.queue.contextType,contextId:this.root.queue.contextId,contextClipCount:this.root.queue.contextClipCount,surfaceType:this.root.queue.surfaceType,surfaceId:this.root.queue.surfaceId,contextClipIds:this.root.queue.contextClips?.filter(e=>e?.id!=null).map(e=>e.id).join(",")}),()=>this.syncPlaylistContextFromQueue()))}getCurrentClipListenProperties(){return{clip_id:this.clip?.id,clip_title:(0,o.getClipTitle)(this.clip),creator_id:this.clip?.user_id,is_own_song:this.clip?.user_id===this.root.session.userId}}logPlaylistListenSession(){let e=this.getPlaylistListenProperties();if(!e)return void(this.isPlaylistListenContext()?this.pendingPlaylistListenClipId===this.clip?.id&&(this.activePlaylistListenId&&(this.pendingPlaylistListenPreviousId=this.activePlaylistListenId),this.activePlaylistListenId=null):(this.activePlaylistListenId=null,this.pendingPlaylistListenClipId=null,this.pendingPlaylistListenPreviousId=null));if(this.pendingPlaylistListenPreviousId===e.playlist_id){this.activePlaylistListenId=e.playlist_id,this.pendingPlaylistListenClipId=null,this.pendingPlaylistListenPreviousId=null;return}if(this.activePlaylistListenId===e.playlist_id){this.pendingPlaylistListenClipId=null,this.pendingPlaylistListenPreviousId=null;return}this.activePlaylistListenId=e.playlist_id,this.pendingPlaylistListenClipId=null,this.pendingPlaylistListenPreviousId=null,(0,A.logCustomEvent)("playlist_listen",e)}trackListenMilestonesForNewPlay(e){var t;t=(t,i)=>{(0,s.runInAction)(()=>{this.clip?.id===e.id&&this.emitListenMilestone(t,i)})},h={accruedSeconds:0,lastPosition:null,fired:new Set,onMilestone:t},p||(p=(0,d.subscribeToAudioEvents)(["timeupdate"],y))}emitListenMilestone(e,t){this.apiClient.POST("/api/gen/{gen_id}/listen_milestone",{params:{path:{gen_id:this.clip?.id||""}},body:{milestone:e}}),this.logger.segmentTrack(R.EventNames.audioPlayerEvent,{...this.getAudioPlayerEvent(t,this.clip?.user_id||""),startTime:null,endTime:null,playDuration:null},this.root.session)}logListenCustomEvents(e){let t=this.endTime-this.startTime;t<=0||(0,A.logCustomEvent)("song_listen",{...this.getCurrentClipListenProperties(),listen_duration_s:Math.round(t),song_duration_s:Math.round((0,d.getAudioDuration)()),completed:e})}handleSetupListeners(e){(0,E.initMangoSwListener)();let t=(e,t)=>{if(t.target instanceof HTMLElement&&"active-audio-play"==t.target.id)switch(e){case"error":V.error("Playback error:",t);break;case"pause":if(f){this.endTime=this.audioElement?.currentTime||0;let e=this.endTime===(0,d.getAudioDuration)();this.logger.segmentTrack(R.EventNames.audioPlayerEvent,this.getAudioPlayerEvent(e?"SongEnd":"PauseSong",this.clip?.user_id||""),this.root.session),this.logListenCustomEvents(e),e&&g(),this.startTime=this.endTime,f=!1}}},i=e=>{(0,s.runInAction)(()=>{t(e.type,e)})},r=e=>{i(e)},n=async e=>{(0,s.runInAction)(()=>{this.isLoadingClip=!1}),this.playAttemptedAt&&this.clip?.id&&(this.logger.segmentTrack(R.EventNames.audioPlayerEvent,{...this.getAudioPlayerEvent("PlaybackPlaying",this.clip?.user_id||""),timeToPlayingMs:Date.now()-this.playAttemptedAt,streamHost:this.getStreamingSourceHost(),startTime:null,endTime:null,playDuration:null},this.root.session),this.playAttemptedAt=null);let t=(0,E.getMangoSession)(this.clip?.id);t&&!t.decryptStartFired&&(t.decryptStartFired=!0,(0,v.default)({actionName:"MangoDecodeStart",principalObjectType:"clip",principalObjectValue:t.clipId,componentContext:"mango",context:{...(0,E.buildCommonProps)(t),timeToFirstAudioMs:Date.now()-t.sourceSelectedAt,seekTs:Math.round((this.audioElement?.currentTime??0)*1e3),keySource:t.keySource,byteRangeStart:0,byteRangeEnd:null}})),i(e),await this.root.queue.autoplayRunwayCheck()};
3e.addEventListener("seeking",i),e.addEventListener("playing",n),e.addEventListener("play",i),e.addEventListener("pause",i),e.addEventListener("waiting",i),e.addEventListener("stalled",r),e.addEventListener("error",r)}getHTMLElement(){if(this.audioElement instanceof U)return this.audioElement.getElement();let e=this.audioElement;return e instanceof HTMLAudioElement?e:null}setupIAudioPlayerElement(e){return this.audioElement?.onDetach?.(),new U(e)}swapAudioElement(e){this.isIAudioPlayerEnabled?(this.audioElement&&this.audioElement.onDetach?.(),m(),this.audioElement=e,this.mediaManager.setHTMLElement(this.getHTMLElement()),(0,d.bindAudio)(this.audioElement)):V.warn("swapAudioElement called but playbar-store-iaudioplayer flag is off")}setAudioElement(e){(this.audioElement=this.isIAudioPlayerEnabled?this.setupIAudioPlayerElement(e):e,b||(b=!0,(0,d.subscribeToAudioEvents)(["play","playing"],()=>{f=!0}),(0,d.subscribeToAudioEvents)(["error","emptied"],()=>{f=!1}),(0,d.onBindChange)(()=>{f=!1}),(0,d.subscribeToAudioEvents)(["play","playing"],()=>{(0,d.getAudioPaused)()||(0,v.setContentPlaying)(!0)}),(0,d.subscribeToAudioEvents)(["pause","ended","error","emptied"],()=>{(0,v.setContentPlaying)(!1)}),(0,d.onBindChange)(()=>{(0,v.setContentPlaying)(!1)})),this.mediaManager.setHTMLElement(this.getHTMLElement()),(0,d.bindAudio)(this.audioElement),this.initListenContextUpdate(),this.hasSetListeners||(this.hasSetListeners=!0,this.handleSetupListeners(this.audioElement),this.loadFromLocalStorage()),this.isInPreviewMode&&this.clip?.preview_seconds!=null&&this.audioElement?.currentTime>this.clip.preview_seconds)?this.stepForward():(this.audioElement.addEventListener("durationchange",()=>{(0,s.runInAction)(()=>{let e=this.audioElement?.duration;e===1/0||void 0===e||Number.isNaN(e)?this.loadingDuration=!0:this.loadingDuration=!1,this.loadingStream=!1,this.isLoadingClip=!1})}),this.audioElement.addEventListener("timeupdate",()=>{if(!this.stopIfStopAtReached()){if(!this.isLoadingClip&&this.isInPreviewMode&&this.clip?.preview_seconds!=null&&(this.audioElement?.currentTime||0)>this.clip.preview_seconds){!this.stepForward()&&this.audioElement&&(this.mediaManager.seek({time:this.clip.preview_seconds}),this.mediaManager.setPlaying(!1));return}if(!this.isLoadingClip&&!this.loadingDuration&&(0,d.getAudioDuration)()>0&&(this.audioElement?.currentTime||0)>(0,d.getAudioDuration)())return void this.handleEnded()}}),this.audioElement.addEventListener("ended",this.handleEnded),this.audioElement.addEventListener("play",()=>{(0,s.runInAction)(()=>{let e=!("u"<typeof navigator)&&"mediaSession"in navigator&&navigator.mediaSession&&"function"==typeof navigator.mediaSession.setActionHandler?navigator.mediaSession:null;if(e&&this.clip){let t=this.clip,i=[],r=(0,o.getClipTitle)(t);t.image_url&&(i=[{src:t.image_url,sizes:"256x256",type:"image/png"}]),e.metadata=new MediaMetadata({title:r,artist:t.metadata?.tags?`Suno - ${t.metadata?.tags}`:"Suno",artwork:i}),e.setActionHandler("play",()=>{if(!(0,n.isVideoHooksPath)(window.location.pathname)){if(this.mediaManager.isTransitioning)return void this.togglePlay(!0);(0,s.runInAction)(()=>{this.mediaManager.setPlaying(!0),this.endTime=this.audioElement?.currentTime||0,this.startTime=this.audioElement?.currentTime||0,this.logger.segmentTrack(R.EventNames.audioPlayerEvent,this.getAudioPlayerEvent(R.ActionName.playSongInMediaSession,this.clip?.user_id||""),this.root.session)})}}),e.setActionHandler("pause",()=>{this.mediaManager.isTransitioning?this.togglePlay(!1):this.mediaManager.setPlaying(!1)}),e.setActionHandler("nexttrack",()=>{this.stepForward()}),e.setActionHandler("previoustrack",()=>{this.stepBackward()}),e.setActionHandler("seekto",e=>{(0,s.runInAction)(()=>{null!=e.seekTime&&this.audioElement&&((0,d.getIsPlaying)()&&(this.endTime=this.getCurrentTime(),this.logger.segmentTrack(R.EventNames.audioPlayerEvent,this.getAudioPlayerEvent(R.ActionName.seekProgressBarPauseSongInMediaSession,this.clip?.user_id||""),this.root.session),this.startTime=this.endTime),this.seekToTime(e.seekTime),this.startTime=this.getCurrentTime(),this.endTime=this.getCurrentTime(),this.logger.segmentTrack(R.EventNames.audioPlayerEvent,this.getAudioPlayerEvent(R.ActionName.seekProgressBarPlaySongInMediaSession,this.clip?.user_id||""),this.root.session))})})}})}))}
3shouldUseM4a=e=>!(!e.audio_url||!this.root.session.checkGate("enable-m4a-audio")||(0,o.isAudiopipeUrl)(e.audio_url)||new Date(e.created_at)<$)&&this.shouldUseOpusWebm(e);shouldUseOpusWebm=e=>{if(!e.audio_url||new Date(e.created_at)<Q)return!1;let t=/safari/i.test(navigator.userAgent),i=/chrome|chromium/i.test(navigator.userAgent);if(t&&!i){if("streaming"===e.status||(0,o.isAudiopipeUrl)(e.audio_url))return!1;let t=(0,q.parseSafariVersion)(navigator.userAgent);return!!t&&(!!(t.major>17)||17===t.major&&!!(t.minor>=5))}return(0,o.isAudiopipeUrl)(e.audio_url),!0};shouldUseMediaUrl=e=>{if(!(0,o.findAudioMediaItem)(e?.media_urls,{encrypted:!0}))return!1;let t=this.root.session.statsigClient?.getParameterStore(B.ParameterStore.SUNO_WEB);return t?.get(B.Parameter.EDEN_AUDIO_PLAYBACK,!1)===!0};getPreferredAudioUrl=e=>{let t=e.audio_url;return!t||(0,o.isAudiopipeUrl)(t)?null:this.shouldUseM4a(e)?(0,o.modifyClipAudioUrl)(t,{extension:"m4a"}):this.shouldUseOpusWebm(e)?(0,o.modifyClipAudioUrl)(t,{extension:"webm"}):t};get isIAudioPlayerEnabled(){let e=this.root.session.statsigClient?.getParameterStore(B.ParameterStore.SUNO_WEB);return e?.get(B.Parameter.PLAYBAR_STORE_USE_IAUDIOPLAYER,!1)===!0}isUnencryptedFallbackDisabled(){let e=this.root.session.statsigClient?.getParameterStore(B.ParameterStore.SUNO_WEB);return e?.get(B.Parameter.WEB_DRM_FALLBACKS_DISABLED,!1)===!0}shouldRecoverMseErrorOnEncryptedPath(e,t){return e===_.SwDrmMode.MseFirst||!(0,o.isAudiopipeUrl)(t)}stopForDisabledFallback(e){this.audioElement&&(this.mediaManager.stop(),this.revokeBlobUrl(),(0,s.runInAction)(()=>{this.isLoadingClip=!1,this.loadingStream=!1}),(3===e||4===e)&&(0,L.notifyUnrecoverablePlayback)())}recoverEncryptedPlaybackError(e){let t=this.currentBlobUrl,i=this.clip;if(!t||!i)return;let s=this.getHTMLElement()?.error;if(!s)return void V.warn("[Mango] playback request failed:",e);let r=this.getCurrentTime(),n=(0,M.isSwProxyUrl)(t),a=(0,E.getMangoSession)(i.id)?.streamingMode,l=s.code;if("progressive"===a&&!n){V.warn("[Mango] progressive retry also failed at media element"),this.fallBackToUnencryptedOrStop({clip:i,seekTo:r,errorDetail:"progressive_decode_failed",mediaErrorCode:l});return}if(!n)return;let u=(0,o.findAudioMediaItem)(i.media_urls,{encrypted:!0});if(!u||(0,o.isAudiopipeUrl)(u.url))return void this.fallBackToUnencryptedOrStop({clip:i,seekTo:r,errorDetail:"sw_playback_failed_no_progressive_path",mediaErrorCode:l});V.warn("[Mango] SW playback failed at media element, retrying progressive",{mediaErrorCode:l});let d=(0,E.getMangoSession)(i.id);d&&(0,v.default)({actionName:"MangoInternalFallback",principalObjectType:"clip",principalObjectValue:i.id,componentContext:"mango",context:{...(0,E.buildCommonProps)(d),from:"sw",to:"progressive",errorDetail:`sw_native_playback: media_error_code=${l}`,errorCategory:"sw_error"}}),this.retryEncryptedAudio({clip:i,encryptedUrl:u.url,encryptedItem:u,swDrmMode:this.getSwDrmMode(),retryVia:"progressive"})}getSwDrmMode(){let e=this.root.session.statsigClient?.getParameterStore(B.ParameterStore.SUNO_WEB);return e?.get(B.Parameter.EDEN_SW_MODE,_.SwDrmMode.MseFirst)??_.SwDrmMode.MseFirst}fallBackToUnencryptedOrStop(e){let{clip:t,seekTo:i,errorDetail:s,mediaErrorCode:r}=e,n=this.isUnencryptedFallbackDisabled(),a=(0,E.getMangoSession)(t.id);if(a){let e=t.audio_url??"";(0,v.default)({actionName:"MangoFallback",principalObjectType:"clip",principalObjectValue:t.id,componentContext:"mango",context:{...(0,E.buildCommonProps)(a),errorCategory:"player_error",errorDetail:s,isMidStreamFailure:i>0,fallbackPath:W(e),fallbackDelivery:(0,o.isAudiopipeUrl)(e)?"streaming":"progressive",attemptDurationMs:Date.now()-a.sourceSelectedAt,fallbackDisabled:n}})}(this.revokeBlobUrl(),n)?this.stopForDisabledFallback(r):this.mediaManager.replace({source:this.createStandardSource(t)})}revokeBlobUrl(){this.currentBlobUrl&&!(0,M.isSwProxyUrl)(this.currentBlobUrl)&&URL.revokeObjectURL(this.currentBlobUrl),this.currentBlobUrl=null,this.mangoStreamType=null,(0,E.endAllMangoSessions)()}async attachEncryptedAudio(e){let t,{clip:i,element:r,signal:n}=e,a=(0,o.findAudioMediaItem)(i.media_urls,{encrypted:!0});if(!r||!a)return;let l=a.url;this.revokeBlobUrl();let u=this.root.session.statsigClient?.getParameterStore(B.ParameterStore.SUNO_WEB),c=this.getSwDrmMode(),h=u?.get(B.Parameter.EDEN_MSE_DOWNLOAD_MODE,_.MseDownloadMode.Eager)??_.MseDownloadMode.Eager,p=Date.now(),m=a.content_type??"",g=a.delivery??"progressive";(0,E.startMangoSession)(i.id,{clipId:i.id,songSessionId:this.songSessionId,sourceSelectedAt:p,keySource:"unknown",streamingMode:"unknown",mseDownloadMode:h,mediaFormat:m,delivery:g,encoded:!!a.encoding,decryptStartFired:!1});let y=(0,E.getMangoSession)(i.id);(0,v.default)({actionName:"MangoPlaybackSourceSelected",principalObjectType:"clip",principalObjectValue:i.id,componentContext:"mango",context:(0,E.buildCommonProps)(y)});try{t=await (0,k.streamEncryptedMedia)({apiClient:this.root.apiClient,encryptedUrl:l,contentId:i.id,contentType:"clip",mediaContentType:a.content_type,audioElement:r,duration:i.metadata?.duration??void 0,signal:n,swDrmMode:c,downloadMode:h,onProgress:e=>{(0,s.runInAction)(()=>{this.mangoStreamType=e.containerFormat}),(0,E.setStreamingMode)(i.id,e.mode)},onInternalFallback:e=>{let t=(0,E.getMangoSession)(i.id);t&&(0,v.default)({actionName:"MangoInternalFallback",principalObjectType:"clip",principalObjectValue:i.id,componentContext:"mango",context:{...(0,E.buildCommonProps)(t),from:e.from,to:e.to,errorDetail:e.error,errorCategory:e.errorCategory}})},onDecryptComplete:e=>{let t=(0,E.getMangoSession)(i.id);t&&(0,v.default)({actionName:"MangoDecodeComplete",principalObjectType:"clip",principalObjectValue:i.id,componentContext:"mango",context:{...(0,E.buildCommonProps)(t),byteRangeStart:0,byteRangeEnd:e.totalBytesDecrypted,totalBytesDecrypted:e.totalBytesDecrypted,decryptDurationMs:e.decryptDurationMs}})},onSwMseError:(e,{phase:t})=>{let s=(0,E.getMangoSession)(i.id);s&&(0,v.default)({actionName:"MangoDecodeError",principalObjectType:"clip",principalObjectValue:i.id,componentContext:"mango",context:{...(0,E.buildCommonProps)(s),errorDetail:`sw_mse_${t}: ${e instanceof Error?e.message:String(e)}`,isFatal:!0}})},onMseEvent:e=>{if("quota_exceeded"!==e.type)return;let t=(0,E.getMangoSession)(i.id);t&&(0,v.default)({actionName:"MangoMseQuotaExceeded",principalObjectType:"clip",principalObjectValue:i.id,componentContext:"mango",context:{...(0,E.buildCommonProps)(t),bufferAheadTargetS:e.bufferAheadTargetS,evictMarginS:e.evictMarginS}})},onMseError:(e,{readyState:t,updating:s,chunksAppended:r,bytesDecrypted:u,bufferedSeconds:d})=>{if(n.aborted)return;V.warn("MSE streaming error, retrying via SW/progressive:",e);let h=(0,E.getMangoSession)(i.id),p=this.getHTMLElement()?.error?.code??null;if(h){let n=e instanceof Error?e.message:String(e);(0,v.default)({actionName:"MangoDecodeError",principalObjectType:"clip",principalObjectValue:i.id,componentContext:"mango",context:{...(0,E.buildCommonProps)(h),errorDetail:`mse: ${n}`,isFatal:!0,mseReadyState:t,mseUpdating:s,mseChunksAppended:r,mseBytesDecrypted:u,mseBufferedSeconds:d,mediaErrorCode:p}})}if(this.clip?.id!==i.id)return;if((0,I.isMseBroken)()||this.shouldRecoverMseErrorOnEncryptedPath(c,l))return void this.retryEncryptedAudio({clip:i,encryptedUrl:l,encryptedItem:a,swDrmMode:c,retryVia:"skip-mse"});let m=this.isUnencryptedFallbackDisabled();if(h){let t=i.audio_url??"";(0,v.default)({actionName:"MangoFallback",principalObjectType:"clip",principalObjectValue:i.id,componentContext:"mango",context:{...(0,E.buildCommonProps)(h),errorCategory:"player_error",errorDetail:`mse: ${e instanceof Error?e.message:String(e)}`,isMidStreamFailure:r>0,fallbackPath:W(t),fallbackDelivery:(0,o.isAudiopipeUrl)(t)?"streaming":"progressive",attemptDurationMs:Date.now()-h.sourceSelectedAt,fallbackDisabled:m}}),(0,E.endMangoSession)(i.id)}
3m?this.stopForDisabledFallback(p):this.mediaManager.replace({source:this.createStandardSource(i)})}})}catch(s){if(n.aborted)return;V.warn("[Mango] Stream failed, falling back to standard playback:",s.message);let e=this.isUnencryptedFallbackDisabled(),t=(0,E.getMangoSession)(i.id);if(t){let r=s instanceof Error?s.message:String(s),n=i.audio_url??"",a=r.includes("License")?"license_error":r.includes("fetch")||r.includes("network")||r.includes("Failed to fetch")?"network_error":"decryption_error";(0,v.default)({actionName:"MangoFallback",principalObjectType:"clip",principalObjectValue:i.id,componentContext:"mango",context:{...(0,E.buildCommonProps)(t),errorCategory:a,errorDetail:r,isMidStreamFailure:!1,fallbackPath:W(n),fallbackDelivery:(0,o.isAudiopipeUrl)(n)?"streaming":"progressive",attemptDurationMs:Date.now()-t.sourceSelectedAt,fallbackDisabled:e}}),(0,E.endMangoSession)(i.id)}if(this.clip?.id!==i.id)return;if(e)return void this.stopForDisabledFallback(null);this.mediaManager.replace({source:this.createStandardSource(i)});return}(0,s.runInAction)(()=>{if(this.audioElement){if(n.aborted||this.clip?.id!==i.id||this.getHTMLElement()!==r){(0,M.isSwProxyUrl)(t)||URL.revokeObjectURL(t);return}this.currentBlobUrl=t,(0,d.setAudioSource)(t)}})}async attachEncryptedRetry(e){let{retryVia:t,clip:i,encryptedUrl:r,encryptedItem:n,swDrmMode:a,signal:l,element:u}=e;this.currentBlobUrl&&!(0,M.isSwProxyUrl)(this.currentBlobUrl)&&URL.revokeObjectURL(this.currentBlobUrl),this.currentBlobUrl=null,this.mangoStreamType=null;try{let e=await (0,k.streamEncryptedMedia)({apiClient:this.root.apiClient,encryptedUrl:r,contentId:i.id,contentType:"clip",mediaContentType:n.content_type,audioElement:u,duration:i.metadata?.duration??void 0,signal:l,swDrmMode:a,forceSkipMse:"skip-mse"===t,forceProgressiveDownload:"progressive"===t,onProgress:e=>{(0,s.runInAction)(()=>{this.mangoStreamType=e.containerFormat}),(0,E.setStreamingMode)(i.id,e.mode)},onInternalFallback:e=>{let t=(0,E.getMangoSession)(i.id);t&&(0,v.default)({actionName:"MangoInternalFallback",principalObjectType:"clip",principalObjectValue:i.id,componentContext:"mango",context:{...(0,E.buildCommonProps)(t),from:e.from,to:e.to,errorDetail:e.error,errorCategory:e.errorCategory}})},onDecryptComplete:e=>{let t=(0,E.getMangoSession)(i.id);t&&(0,v.default)({actionName:"MangoDecodeComplete",principalObjectType:"clip",principalObjectValue:i.id,componentContext:"mango",context:{...(0,E.buildCommonProps)(t),byteRangeStart:0,byteRangeEnd:e.totalBytesDecrypted,totalBytesDecrypted:e.totalBytesDecrypted,decryptDurationMs:e.decryptDurationMs}})}});(0,s.runInAction)(()=>{if(l.aborted||this.getHTMLElement()!==u||this.clip?.id!==i.id){(0,M.isSwProxyUrl)(e)||URL.revokeObjectURL(e);return}this.currentBlobUrl=e,(0,d.setAudioSource)(e);let s=(0,E.getMangoSession)(i.id);s&&"skip-mse"===t&&(0,v.default)({actionName:"MangoMseRecovered",principalObjectType:"clip",principalObjectValue:i.id,componentContext:"mango",context:{...(0,E.buildCommonProps)(s),seekTs:this.mediaManager.getCurrentTime()}})})}catch(r){if(l.aborted)return;V.warn("[Mango] encrypted retry also failed, falling back to unencrypted:",r.message);let e=this.isUnencryptedFallbackDisabled(),s=(0,E.getMangoSession)(i.id);if(s){let n=r instanceof Error?r.message:String(r),a=i.audio_url??"";(0,v.default)({actionName:"MangoFallback",principalObjectType:"clip",principalObjectValue:i.id,componentContext:"mango",context:{...(0,E.buildCommonProps)(s),errorCategory:"player_error",errorDetail:`${t}_retry: ${n}`,isMidStreamFailure:!1,fallbackPath:W(a),fallbackDelivery:(0,o.isAudiopipeUrl)(a)?"streaming":"progressive",attemptDurationMs:Date.now()-s.sourceSelectedAt,fallbackDisabled:e}}),(0,E.endMangoSession)(i.id)}if(this.clip?.id!==i.id)return;if(e)return void this.stopForDisabledFallback(null);this.mediaManager.replace({source:this.createStandardSource(i)})}}createPlaybackSource(e,t=!1){return this.shouldUseMediaUrl(e)?{description:this.describeAudioSource(e),attach:t=>this.attachEncryptedAudio({clip:e,...t}),onError:e=>this.recoverEncryptedPlaybackError(e)}:this.createStandardSource(e,t)}retryEncryptedAudio(e){this.mediaManager.replace({source:{description:this.describeAudioSource(e.clip),attach:t=>this.attachEncryptedRetry({...e,...t}),onError:e=>this.recoverEncryptedPlaybackError(e)}})}createStandardSource(e,t=!1){let i=function(e,t){let i=l(e);if(!i)return[];let s=i!==(e.audio_url??""),r=[""];return s||(0,o.isAudiopipeUrl)(i)||(t.useStreamingWebm&&r.unshift("webm"),t.useM4a&&r.unshift("m4a")),r.map(e=>({extension:e,url:(0,o.modifyClipAudioUrl)(i,{...e?{extension:e}:{},queryParams:{...!s&&(0,o.isAudiopipeUrl)(i)&&t.useStreamingWebm?{format:"webm"}:{}
3,...t.cacheBust?{_t:Date.now().toString()}:{}}})}))}(e,{useM4a:this.shouldUseM4a(e),useStreamingWebm:this.shouldUseOpusWebm(e),cacheBust:t}),s=u(e,{encrypted:!1}),r=this.mangoStreamType,n=a=>({description:{...s,url:i[a]?.url??""},attach:()=>{this.revokeBlobUrl();let e=i[a]?.url;if(!e)throw Error("No audio source available");(0,d.setAudioSource)(e),t&&(0,d.reloadAudio)()},onError:t=>{a+1<i.length?this.mediaManager.replace({source:n(a+1)}):((0,o.isAudiopipeUrl)(s.url)||(0,v.default)({actionName:"PlaybarPlayFallbacksExhausted",context:{clipId:e.id,attemptedExtensions:i.map(({extension:e})=>e),errorMessage:t instanceof Error?t.message:String(t),errorCode:this.audioElement?.error?.code,streamType:r}}),V.warn("Playback formats exhausted:",t),this.mediaManager.stop(),this.isLoadingClip=!1,this.loadingStream=!1)}});return n(0)}playClip(e,t,i,r=!1,n=0,a=!1){this.audioElement&&e&&this.canPlayClip(e)&&0!==e.preview_seconds&&(this.mediaManager.cancel(),r||(this.playAttemptedAt=Date.now()),(0,s.runInAction)(()=>{if(!this.audioElement)return;(0,o.isAudiopipeUrl)(l(e))&&(this.loadingDuration=!0),"streaming"===e.status&&(this.loadingStream=!0),f&&(this.endTime=this.audioElement.currentTime,this.logger.segmentTrack(R.EventNames.audioPlayerEvent,this.getAudioPlayerEvent(i||R.ActionName.playNewSongPauseSong,this.clip?.user_id||""),this.root.session),this.logListenCustomEvents(!1),this.startTime=this.endTime,f=!1),r||(this.pendingPlaylistListenPreviousId=null,this.pendingPlaylistListenClipId=e.id),this.clip?.id!==e.id&&this.clearStopAt(),this.setCurrentClip(e),r||this.logPlaylistListenSession(),this.isClipPreloaded=!1,this.isLoadingClip=!0,this.resumeSilentAudioForMediaSession(),this.mediaManager.select({source:this.createPlaybackSource(e),intent:{seekTo:n,shouldPlay:!r}}),r||this.root.session.clearTooltipOnPlay(),this.silentAudioElement?.pause(),a||this.incrementPlayCountWithSpec();let s=(0,E.getMangoSession)(e.id);s&&(s.songSessionId=this.songSessionId),this.trackListenMilestonesForNewPlay(e),this.logger.segmentTrack(R.EventNames.audioPlayerEvent,this.getAudioPlayerEvent(t||"PlayNewSong",this.clip?.user_id||""),this.root.session),this.updatePlaybarState()}))}playOrTogglePreloadedClip=e=>{(e||this.clip)&&!this.isClipPreloaded?this.togglePlay():this.noClipPlayCallback?.()};incrementPlayCountWithSpec=()=>{let e=1+Math.floor((this.clip?.play_count??0)/100);(0,s.runInAction)(()=>{this.previousSongSessionId=this.songSessionId,this.songSessionId=(0,r.v4)(),this.startTime=0,this.endTime=0,this.actionIndex=-1}),this.apiClient.POST("/api/gen/{gen_id}/increment_play_count/v2",{params:{path:{gen_id:this.clip?.id||""}},body:{sample_factor:e}}),this.clip?.id&&(0,C.optimisticallyIncrementClipPlayCount)(this.root.queryClient,this.clip.id)};handleEnded=()=>{if(!this.mediaManager.isTransitioning&&!this.mediaManager.hasPendingSeek)if(this.mediaManager.setPlaying(!1),g(),this.repeat){if(!this.audioElement)return;this.mediaManager.seek({time:0}),this.startTime=0,this.endTime=0,this.mediaManager.setPlaying(!0),this.incrementPlayCountWithSpec(),this.clip&&this.trackListenMilestonesForNewPlay(this.clip),this.logger.segmentTrack(R.EventNames.audioPlayerEvent,this.getAudioPlayerEvent(R.ActionName.autoRepeatPlaySong,this.clip?.user_id||""),this.root.session)}else this.root.queue.continuous&&this.stepForward(!1,R.ActionName.autoPlayNewSong,R.ActionName.autoRepeatPauseSong)};toggleShuffle=e=>{this.root.queue.toggleShuffle(e),this.updatePlaybarState()};toggleRepeat=(e=!this.repeat)=>{this.repeat=e,this.updatePlaybarState()};togglePlay=(e=!(0,d.getIsPlaying)(),t)=>{if(!this.audioElement)return;if(e&&!t?.preserveStopAt&&this.clearStopAt(),this.mediaManager.isTransitioning)return void this.mediaManager.setPlaying(e);let i=(0,d.getIsPlaying)();(0,s.runInAction)(()=>{if(!this.clip?.id){if(e&&this.root.queue.contextClips.length){this.root.queue.contextQueueIndex=0,this.root.queue.activeQueue="context",this.root.queue.contextClipCount=null;let e=this.root.queue.getCurrentClip();e&&this.playClip(e)}return}if(this.audioElement){if(this.playAttemptedAt=null,e){this.pendingPlaylistListenPreviousId=null,this.pendingPlaylistListenClipId=this.clip.id,this.logPlaylistListenSession();let e=this.getHTMLElement();e&&(e.error||(this.shouldUseMediaUrl(this.clip)?!this.currentBlobUrl:!e.getAttribute("src")))?this.mediaManager.select({source:this.createPlaybackSource(this.clip),intent:{seekTo:this.getCurrentTime(),shouldPlay:!0}}):this.mediaManager.setPlaying(!0),this.endTime=this.getCurrentTime(),this.startTime=this.getCurrentTime(),this.logger.segmentTrack(R.EventNames.audioPlayerEvent,this.getAudioPlayerEvent("PlaySong",this.clip.user_id||""),this.root.session),t?.preserveStopAt&&null!==this.stopAtSeconds&&this.armStopAtIfAhead()}else this.mediaManager.setPlaying(!1),this.endTime=this.audioElement.currentTime,this.logger.segmentTrack(R.EventNames.audioPlayerEvent,this.getAudioPlayerEvent("PauseSong",this.clip?.user_id||""),this.root.session),this.startTime=this.endTime;i!==(0,d.getIsPlaying)()&&this.updatePlaybarState()}})};setStopAtSeconds=e=>{this.stopAtSeconds=e,this.armStopAtIfAhead()};armStopAtIfAhead=()=>{this.stopAtArmed=null!==this.stopAtSeconds&&this.stopAtSeconds>this.getCurrentTime()};stopIfStopAtReached=()=>!!(this.stopAtArmed&&null!==this.stopAtSeconds&&!this.isLoadingClip&&(this.audioElement?.currentTime??0)>=this.stopAtSeconds)&&(this.stopAtArmed=!1,this.togglePlay(!1),!0);clearStopAt=()=>{this.stopAtSeconds=null,this.stopAtArmed=!1};userSetCurrentProgress=e=>{let t=e/100*(0,d.getAudioDuration)();return this.userSetCurrentProgressWithTime(t)};describeAudioSource(e){return u(e,{encrypted:this.shouldUseMediaUrl(e),preferredAudioUrl:this.getPreferredAudioUrl(e),useStreamingWebm:this.shouldUseOpusWebm(e)})}
3shouldReloadBeforeSeek(e,t){return this.mediaManager.shouldReplaceBeforeSeek(this.describeAudioSource(e),t)}seekToTime(e){let t=this.clip?this.resolveQueueClip(this.clip):null;t&&this.setCurrentClip(t),this.mediaManager.seek({time:e,source:t?this.createPlaybackSource(t,!0):void 0})}userSetCurrentProgressWithTime=(e,{preserveStopAt:t}={})=>{!this.audioElement||Number.isFinite(e)&&((0,s.runInAction)(()=>{this.audioElement&&((0,d.getIsPlaying)()&&(this.endTime=this.getCurrentTime(),this.logger.segmentTrack(R.EventNames.audioPlayerEvent,this.getAudioPlayerEvent(R.ActionName.seekProgressBarPauseSong,this.clip?.user_id||"")),this.startTime=this.endTime),this.seekToTime(e),t?this.armStopAtIfAhead():this.clearStopAt(),this.startTime=this.getCurrentTime(),this.endTime=this.getCurrentTime(),this.logger.segmentTrack(R.EventNames.audioPlayerEvent,this.getAudioPlayerEvent(R.ActionName.seekProgressBarPlaySong,this.clip?.user_id||""),this.root.session))}),this.updatePlaybarState())};getCurrentTime(){return this.clip?this.mediaManager.getCurrentTime():0}setDuration=e=>{};setClip=e=>{this.setCurrentClip(e)};updateCurrentClip=e=>{e.id===this.clip?.id&&(this.setCurrentClip(e),this.mediaManager.updateSource(this.createPlaybackSource(e,!0)))};reloadCurrentAudio=(e={})=>{let t=e.clip??this.clip;this.audioElement&&t&&this.canPlayClip(t)&&(this.setCurrentClip(t),this.mediaManager.replace({source:this.createPlaybackSource(t,!0),seekTo:e.seekTo}))};unsetClip=()=>{m(),this.mediaManager.stop(),this.revokeBlobUrl(),this.clip&&(this.setCurrentClip(null),this.startTime=0,this.endTime=0)};setLoadingDuration=e=>{this.loadingDuration=e};setNoClipPlayCallback=e=>{this.noClipPlayCallback=e};restartCurrentSong=(e=R.ActionName.backwardRepeatSong)=>!!this.audioElement&&(f&&(this.endTime=this.audioElement.currentTime,this.logger.segmentTrack(R.EventNames.audioPlayerEvent,this.getAudioPlayerEvent("ForwardRepeatSong",this.clip?.user_id||""),this.root.session),this.startTime=this.endTime),this.mediaManager.seek({time:0}),this.startTime=0,this.endTime=0,f&&this.mediaManager.setPlaying(!0),this.logger.segmentTrack(R.EventNames.audioPlayerEvent,this.getAudioPlayerEvent(e,this.clip?.user_id||""),this.root.session),this.updatePlaybarState(),!0);stepBackward=()=>{if(this.repeat)return void this.restartCurrentSong();if((0,d.getAudioCurrentTime)()>3)f&&(this.endTime=this.audioElement?.currentTime||0,this.logger.segmentTrack(R.EventNames.audioPlayerEvent,this.getAudioPlayerEvent("BackwardPauseSong",this.clip?.user_id||""),this.root.session),this.startTime=this.endTime),this.audioElement&&this.mediaManager.seek({time:0}),this.startTime=0,this.endTime=0,this.logger.segmentTrack(R.EventNames.audioPlayerEvent,this.getAudioPlayerEvent(R.ActionName.backwardRepeatSong,this.clip?.user_id||""),this.root.session);else{let e=this.root.queue.setToPreviousClip(),t=this.root.queue.getCurrentClip();this.root.queue.setCurrentPlayingSongIsRemoved(!1),t&&e?this.playClip(t,R.ActionName.backwardPlayNewSong,R.ActionName.backwardPauseSong):e||this.restartCurrentSong()}this.updatePlaybarState()};canStepForward=()=>!this.disableStepForward&&(!!this.clip&&!!this.root.queue.autoplay||this.root.queue.manualQueue.length>0||!!this.root.queue.contextClips.length&&("context"!==this.root.queue.activeQueue||this.root.queue.contextQueueIndex!==this.root.queue.contextClips.length-1));canPlayClip=e=>!!l(e)||this.shouldUseMediaUrl(e??null);resolveQueueClip=e=>{let t=this.root.queryClient.getQueryData(T.clipsKeys.clip({clipId:e.id}));return t&&this.canPlayClip(t)?t:e};stepForward=(e=!0,t,i)=>{if(this.repeat&&!e)return this.restartCurrentSong();let s=this.root.queue.setToNextClip(),r=this.root.queue.getCurrentClip();return(this.root.queue.setCurrentPlayingSongIsRemoved(!1),r&&s)?(this.playClip(this.resolveQueueClip(r),t||R.ActionName.forwardPlayNewSong,i||R.ActionName.forwardPausePreSong),!0):!s&&this.restartCurrentSong()};setVolume=e=>{let t=Math.max(0,Math.min(1,e));this.audioElement&&((0,d.setAudioVolume)(t),(0,d.setAudioMuted)(0===t)),this.persistToLocalStorage(),this.updatePlaybarState()};setIsClipPreloaded=e=>{this.isClipPreloaded=e};setIsDragging=e=>{this.isDragging=e};toggleMute=()=>{let e=!(0,d.getAudioMuted)(),t=e||0!==(0,d.getAudioVolume)()?(0,d.getAudioVolume)():.6;this.audioElement&&((0,d.setAudioVolume)(t),(0,d.setAudioMuted)(e)),this.persistToLocalStorage()};storageObject=()=>({continuous:this.root.queue.continuous,prefersContinuous:this.root.queue.prefersContinuous,autoplay:this.root.queue.autoplay,repeat:this.repeat,volume:(0,d.getAudioVolume)(),muted:(0,d.getAudioMuted)(),recentlyPlayedIds:this.recentlyPlayedIds});persistToLocalStorage=(0,i.throttle)(()=>{this.root.isLocalStorageAvailable&&localStorage.setItem(H,JSON.stringify(this.storageObject()))},500);initLocalStorageUpdate=()=>{(0,s.reaction)(this.storageObject,this.persistToLocalStorage)};addToRecentlyPlayedIds=e=>{this.recentlyPlayedIds.push(e),this.recentlyPlayedIds.length>50&&(this.recentlyPlayedIds=this.recentlyPlayedIds.slice(-50))};loadFromLocalStorage=()=>{if(this.root.isLocalStorageAvailable){let e=localStorage.getItem(H);try{let t=JSON.parse(e||"");t&&(0,s.runInAction)(()=>{null==t.prefersContinuous?(this.root.queue.continuous=(0,j.valueOrDefault)(t.autoplay,!0),this.root.queue.prefersContinuous=(0,j.valueOrDefault)(t.autoplay,!0)):(this.root.queue.continuous=(0,j.valueOrDefault)(t.continuous,!0),this.root.queue.prefersContinuous=(0,j.valueOrDefault)(t.prefersContinuous,!0)),this.root.queue.autoplay=(0,j.valueOrDefault)(t.autoplay,!0),this.repeat=(0,j.valueOrDefault)(t.repeat,!1);let e=(0,j.valueOrDefault)(t.volume,1),i=(0,j.valueOrDefault)(t.muted,!1);this.audioElement&&((0,d.setAudioVolume)(e),(0,d.setAudioMuted)(i)),this.recentlyPlayedIds=(0,j.valueOrDefault)(t.recentlyPlayedIds,[])})}catch(e){}}};upsertPlaybarState=()=>{this.root.session.user?.id&&this.root.apiClient.POST("/api/music_player/playbar_state",{body:{playbar_state:(0,d.getIsPlaying)()?"playing":"paused",song_index:this.root?.queue?.activeQueue==="context"?this.root.queue.contextQueueIndex:null,song_play_time:this.getCurrentTime(),repeat_state:this.repeat?"repeat":"no-repeat",action_time:new Date().toISOString(),song_ids_in_queue:this.root.queue.contextClips.filter(e=>e?.id!=null).map(e=>e.id.toString()),volume:100*(0,d.getAudioVolume)(),device_id:(0,q.getDeviceId)(),device_type:(0,q.getDeviceType)(),playlist_context:null,device_context:null,context_id:this.root?.queue.contextId,context_type:this.root?.queue?.contextType}})};updatePlaybarState=()=>{this.debouncedUpsertPlaybarState()};debouncedUpsertPlaybarState=(0,i.throttle)(this.upsertPlaybarState,500);initPlaybarState=async()=>
3{if(!this.isInitialized)try{if(window.location.pathname.includes("/song/")||window.location.pathname.includes("/s/")||window.location.pathname.includes("/home")||window.location.pathname.includes("/create")||window.location.pathname.includes("/studio")||window.location.pathname.includes("/playlist/")||(0,n.isVideoHooksPath)(window.location.pathname))return;this.isInitialized=!0;let e=await this.root.apiClient.GET("/api/music_player/playbar_state");if(!e.data||!e.data.song_ids_in_queue||!e.data.song_ids_in_queue.length)return;let t=await this.root.apiClient.GET("/api/clips/get_songs_by_ids",{params:{query:{ids:e.data.song_ids_in_queue||[]}}});if(!Array.isArray(t.data?.clips)||!t.data?.clips?.length)return;(0,s.runInAction)(()=>{this.root.clips.updateClips(t.data.clips),t.data.clips.forEach(e=>{this.root.clips.syncClipToQueryCache(e.id)}),this.root.queue.setClips(t.data.clips);let i=e.data.song_play_time||0;this.repeat="repeat"===e.data.repeat_state,this.root.queue.setPlayContext({clips:t.data.clips||[],contextId:e.data.context_id||"",contextType:e.data.context_type,currentIndex:e.data.song_index||0});let s=this.root.queue.contextClips[e.data.song_index||0];if(s){if(this.setCurrentClip(s),this.isClipPreloaded=!1,this.getHTMLElement()&&!this.shouldUseMediaUrl(s)&&l(s))this.mediaManager.select({source:this.createStandardSource(s),intent:{seekTo:i,shouldPlay:!1}});else if(this.audioElement&&s.audio_url){let e=s.audio_url;this.shouldUseOpusWebm(s)&&(e=(0,o.isAudiopipeUrl)(e)?(0,o.modifyClipAudioUrl)(e,{queryParams:{format:"webm"}}):(0,o.modifyClipAudioUrl)(e,{extension:"webm"})),(0,d.setAudioSource)(e),(0,d.seekAudio)(i),(0,d.reloadAudio)()}s.metadata?.duration&&(this.loadingDuration=!1)}})}catch(e){this.isInitialized=!1}}}e.s(["PlaybarStore",0,z,"PlayerEvents",()=>G],92963)}]); 4 5//# sourceMappingURL=14ohnow00sm-8.js.map 6//# debugId=a74cb331-cad1-54a0-950c-085168422aae
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.