(function(c,b,y,a,f,P,u,R,_,C,I){"use strict";functionF(e,n){if(!(einstanceofn))thrownewTypeError("Cannot call a class as a function")}functionw(e,n){for(vart=0;t<n.length;t++){varr=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"inr&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}functionD(e,n,t){returnn&&w(e.prototype,n),t&&w(e,t),e}functionU(e,n,t){returnnine?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}consto={DEFAULT_APP_NAME:"Music",DEFAULT_TIME_INTERVAL:5,APPLICATION_ID:"1054951789318909972",LFM_API_KEY:"615322f0047e12aedbc610d9d71f7430",LFM_DEFAULT_COVER_HASHES:["2a96cbd8b46e442fc41c2b86b821562f","c6f59c1e5e7240a4c0d427abd71f3dbb"]},L=y.findByProps("getAssetIds"),k=y.findByStoreName("PresenceStore");varT;(function(e){e[e.PLAYING=0]="PLAYING",e[e.STREAMING=1]="STREAMING",e[e.LISTENING=2]="LISTENING",e[e.COMPETING=5]="COMPETING"})(T||(T={}));asyncfunctionO(){conste=newURLSearchParams({method:"user.getrecenttracks",user:s.username,api_key:o.LFM_API_KEY,format:"json",limit:"1",extended:"1"}).toString(),n=awaitfetch(`https://ws.audioscrobbler.com/2.0/?${e}`);if(!n.ok)thrownewError(`Failed to fetch the latest scrobble: ${n.statusText}`);constt=awaitn.json(),r=t?.recenttracks?.track?.[0];if(!r)throwt;return{name:r.name,artist:r.artist.name,album:r.album["#text"],albumArt:awaitM(r.image[3]["#text"]),url:r.url,date:r.date?.["#text"]??"now",nowPlaying:!!r["@attr"]?.nowplaying,loved:r.loved==="1"}}asyncfunctionM(e){returno.LFM_DEFAULT_COVER_HASHES.some(function(n){returne.includes(n)})?null:e}functiond(){returni.lastActivity&&l("--> Clearing activity..."),S(null)}functionS(e){i.pluginStopped&&(console.log("--> Plugin is unloaded, aborting..."),i.updateInterval&&clearInterval(i.updateInterval),e=null),i.lastActivity=e,a.FluxDispatcher.dispatch({type:"LOCAL_ACTIVITY_UPDATE",activity:e,pid:2312,socketId:"Last.fm@Vendetta"})}asyncfunctionV(e){letn=arguments.length>1&&arguments[1]!==void0?arguments[1]:o.APPLICATION_ID;if(!e)return[];constt=L.getAssetIds(n,e);returnt.length>0?t:awaitL.fetchAssetIds(n,e)}asyncfunctionN(){if(l("--> Fetching last track..."),!s.username)throw_.showToast("Last.fm username is not set!",u.getAssetIDByName("Small")),h(),newError("Username is not set");if(s.ignoreSpotify){for(consttofk.getActivities(A.getCurrentUser().id))if(t?.type===T.LISTENING&&t.application_id!==o.APPLICATION_ID){l("--> Spotify is currently playing, aborting..."),d();return}}conste=awaitO().catch(asyncfunction(t){throwl("--> An error occurred while fetching the last track, aborting..."),d(),t});if(!e.nowPlaying){l("--> Last track is not currently playing, aborting..."),d();return}if(l("--> Track fetched!"),i.lastTrackUrl===e.url){l("--> Last track is the same as the previous one, aborting...");return}constn={name:s.appName||o.DEFAULT_APP_NAME,flags:0,type:s.listeningTo?2:0,details:e.name,state:`by ${e.artist}`,application_id:o.APPLICATION_ID};if(i.lastTrackUrl=e.url,n.name.includes("{{"))for(consttine)n.name=n.name.replace(`{{${t}}}`,e[t]);s.showTimestamp&&(n.timestamps={start:Date.now()/1e3|0}),e.album&&(n.assets={large_image:(awaitV([e.albumArt]))[0],large_text:`on ${e.album}`}),l("--> Setting activity..."),l(n);try{S(n)}catch(t){throwl("--> An error occurred while setting the activity"),d(),t}l("--> Successfully set activity!")}functionh(){console.log("--> Flushing..."),i.lastActivity=null,i.lastTrackUrl=null,i.updateInterval&&clearInterval(i.updateInterval),d()}asyncfunctionE(){if(console.log("--> Initializing..."),i.pluginStopped)thrownewError("Plugin is already stopped!");h();lete=0;awaitN().catch(function(n){console.error(n),e++}),i.updateInterval=setInterval(function(){returnN().then(function(){e=0}).catch(function(n){console.error(n),++e>3&&(console.error("Failed to fetch/set activity 3 times, aborting..."),h())})},(Number(s.timeInterval)||o.DEFAULT_TIME_INTERVAL)*1e3)}const{FormInput:v,FormDivider:g,FormSwitchRow:p,FormText:B,FormIcon:m}=R.Forms;functionx(){asyncfunctione(){for(constninf.storage