const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./discordrpc-P8-rm87s.js","./rolldown-runtime-DAXXjFlN.js","./vendor-6bGPahzI.js","./vendor-BJaREVC_.css","./ws-BfVPV0ME.js","./vendor-vue-DqH63YZy.js","./vendor-quasar-Bl8FKFQs.js","./vendor-quasar-0mkwHnJZ.css","./TokenManager-7Ay6nr15.js","./vendor-lodash-C2wwRdEA.js","./IPCRegistry-OPUQsWEY.js","./client-api-DGgiwyPh.js","./vendor-musicmeta-BKsi8oWf.js","./cider_wasm-BRQq_2-2.js","./wasm-init-7c-yCFTQ.js","./useNotifications-DKQR3Y1H.js","./PlaybackEventBus--BJS1dhm.js","./vendor-hls-Dfw4y8Ys.js","./vendor-parse-BDAhPOvR.js","./vendor-socketio-Ew0LBRtA.js","./ws-B3rFR7Xu.css"])))=>i.map(i=>d[i]);
import{dn as e,gr as t}from"./vendor-6bGPahzI.js";import{$n as n,F as r,Kt as i,N as a,Nt as o,Pt as s,Qn as c,pn as l,qt as u,wn as d}from"./ws-BfVPV0ME.js";import{n as f,r as p}from"./IPCRegistry-OPUQsWEY.js";import{c as m,d as h}from"./client-api-DGgiwyPh.js";import{i as g,r as _}from"./vendor-musicmeta-BKsi8oWf.js";import{r as v,t as y}from"./PlaybackEventBus--BJS1dhm.js";import{r as b,t as x}from"./RPC-1FKcoLOK.js";v(),c(),d(),r(),e(),h(),s(),p(),b(),g();async function S(){console.log(`Hello Genten!`),document.body.setAttribute(`data-os`,m()),i(()=>{_(()=>import(`./discordrpc-P8-rm87s.js`).then(e=>e.setupConnectionLifecycle()),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]),import.meta.url),t(()=>u().visual.appearance,e=>{switch(e){case`dark`:f.window.setNativeTheme({theme:`dark`});break;case`light`:f.window.setNativeTheme({theme:`light`});break;default:case`auto`:f.window.setNativeTheme({theme:`system`});break}},{immediate:!0})},!0)}async function C(){if(n(),`mediaSession`in navigator){let e=window.navigator.mediaSession,t=(t,n)=>{e.setActionHandler(t,e=>{a(`mediaSession.action`,{action:t,hidden:document.hidden,focused:document.hasFocus()}),n(e)})};t(`play`,()=>{x.play()}),t(`pause`,()=>{x.pause()}),t(`previoustrack`,()=>{x.previous()}),t(`nexttrack`,()=>{x.next()}),t(`seekto`,e=>{let t=e?.seekTime;typeof t==`number`&&Number.isFinite(t)&&x.seekToTime(t)}),t(`seekbackward`,e=>{x.seekBy(-Math.abs(e?.seekOffset??10))}),t(`seekforward`,e=>{x.seekBy(Math.abs(e?.seekOffset??10))})}let e=null,t=null,r=null,i=null,s=()=>{t=null;let n=e;if(e=null,n)try{let e=n.item;if(!e)return;let t=n.attributes??{},a=l(t?.artwork?.url,640,640,void 0,`jpg`)??``,s={id:e.id,type:e.type,attributes:{name:t?.name??``,artistName:t?.artistName??``,albumName:t?.albumName??``,durationInMillis:t?.durationInMillis,genreNames:Array.isArray(t?.genreNames)?[...t.genreNames]:[],artwork:{url:a},personalRating:+!!n.inFavorites,inLibrary:n.inLibrary}};r=s,f.playback.setNowPlayingItem(s);try{e.id&&e.id!==i&&(i=e.id,o(`connectivity.playbackNotifications`)&&!document.hasFocus()&&f.showNotification({title:s.attributes.name||``,body:s.attributes.artistName||``}))}catch(e){console.warn(`[Genten] Failed to send track-change notification`,e)}let c=window.navigator.mediaSession;if(!c)return;c.metadata=new MediaMetadata({title:s.attributes.name,artist:s.attributes.artistName,album:s.attributes.albumName,artwork:a?[{src:a,sizes:`640x640`,type:`image/jpeg`}]:[]})}catch(e){console.error(`Error updating media session metadata`,e)}};y.on(`playbackStatus.nowPlayingItemDidChange`,n=>{e=n,t===null&&(t=setTimeout(s,120))}),y.on(`playbackStatus.nowPlayingStatusDidChange`,e=>{try{r&&(r.attributes.personalRating=+!!e.inFavorites,r.attributes.inLibrary=e.inLibrary,f.playback.setNowPlayingItem(r))}catch{}}),y.on(`playbackStatus.playbackStateDidChange`,e=>{try{let t=e.state,n=window.navigator.mediaSession;if(n&&(t===`playing`||t===`seeking`?n.playbackState=`playing`:t===`paused`?n.playbackState=`paused`:t===`stopped`&&(n.playbackState=`none`)),t!==`playing`&&t!==`paused`&&t!==`stopped`&&t!==`seeking`)return;if(f.playback.setPlaybackState({state:t}),n&&e.item&&e.attributes){let t=e.attributes,r=l(t?.artwork?.url,640,640,void 0,`jpg`)??``;n.metadata=new MediaMetadata({title:t?.name??``,artist:t?.artistName??``,album:t?.albumName??``,artwork:r?[{src:r,sizes:`640x640`,type:`image/jpeg`}]:[]})}}catch{}}),y.on(`playbackStatus.playbackTimeDidChange`,e=>{try{f.playback.setPlaybackTime({currentPlaybackDuration:e.currentPlaybackDuration,currentPlaybackTime:e.currentPlaybackTime,currentPlaybackTimeRemaining:e.currentPlaybackTimeRemaining,isPlaying:e.isPlaying,anchor:e.anchor});let t=window.navigator.mediaSession;if(!t)return;t.setPositionState?.({duration:e.currentPlaybackDuration,position:e.currentPlaybackTime,playbackRate:1})}catch{}}),y.on(`playerStatus.shuffleModeDidChange`,e=>{try{f.playback.setShuffleMode(e.shuffleMode??0)}catch{}}),y.on(`playerStatus.repeatModeDidChange`,e=>{try{f.playback.setRepeatMode(e.repeatMode??0)}catch{}}),y.on(`playerStatus.volumeDidChange`,e=>{try{f.playback.setVolume({volume:e.volume})}catch{}})}export{C as n,S as t};