"use strict";const waitFor=async(o,n=50,s=20)=>{for(let a=0;asetTimeout(u,n))}return o()},getChunkQueue=()=>window?.webpackChunkclient_web||window?.rspackChunkclient_web,loadWebpack=async()=>{try{const o=await waitFor(getChunkQueue,50);if(!o)throw new Error("Could not find webpack/rspack chunk queue");const n=o.push([[Symbol()],{},c=>c]),s=Object.keys(n.m).map(c=>n(c)),a=s.filter(c=>typeof c=="object").flatMap(c=>{try{return Object.values(c)}catch{}}),r=new Set(Object.values(n.m)),u=a.flatMap(c=>typeof c=="function"?[c]:typeof c=="object"&&c?Object.values(c).filter(f=>typeof f=="function"&&!r.has(f)):[]);return{cache:s,functionModules:u}}catch(o){return console.error("adblockify: Failed to load webpack",o),{cache:[],functionModules:[]}}},getSettingsClient=(o,n=[],s={})=>{try{const a=o.find(r=>r?.settingsClient)?.settingsClient;if(!a){const r=n.find(u=>u?.SERVICE_ID==="spotify.ads.esperanto.settings.proto.Settings"||u?.SERVICE_ID==="spotify.ads.esperanto.proto.Settings");return new r(s)}return a}catch(a){return console.error("adblockify: Failed to get ads settings client",a),null}},getSlotsClient=(o,n)=>{try{const s=o.find(a=>a.SERVICE_ID==="spotify.ads.esperanto.slots.proto.Slots"||a.SERVICE_ID==="spotify.ads.esperanto.proto.Slots");return new s(n)}catch(s){return console.error("adblockify: Failed to get slots client",s),null}},getTestingClient=(o,n)=>{try{const s=o.find(a=>a.SERVICE_ID==="spotify.ads.esperanto.testing.proto.Testing"||a.SERVICE_ID==="spotify.ads.esperanto.proto.Testing");return new s(n)}catch(s){return console.error("adblockify: Failed to get testing client",s),null}},map=new Map,retryCounter=(o,n)=>{if(map.has(o)||map.set(o,{count:0}),n==="increment")map.get(o).count++;else if(n==="clear")map.delete(o);else if(n==="get")return map.get(o)?.count};(async function o(){await new Promise(e=>Spicetify.Events.platformLoaded.on(e)),await new Promise(e=>Spicetify.Events.webpackLoaded.on(e));const n=await loadWebpack(),{Platform:s,Locale:a}=Spicetify,{AdManagers:r}=s;if(!r?.audio||Object.keys(r).length===0){setTimeout(o,100);return}const{audio:u}=r,{UserAPI:c}=s,f=c._product_state||c._product_state_service||s?.ProductStateAPI?.productStateApi,b=Spicetify.Platform.version.split(".").map(e=>Number.parseInt(e));if(!Spicetify?.CosmosAsync){setTimeout(o,100);return}const{CosmosAsync:w}=Spicetify;let m=[];const v=getSlotsClient(n.functionModules,f.transport);if(v)m=(await v.getSlots()).adSlots;else try{m=await w.get("sp://ads/v1/slots")}catch{setTimeout(o,100);return}const k=()=>{const e=document.createElement("style"),t=a.get("upgrade.tooltip.title");e.className="adblockify",e.innerHTML=`.ScclvBC0NsMgQLQC, .Mvhjv8IKLGjQx94MVOgP, .sl_aPp6GDg05ItSfmsS7, .sl_aPp6GDg05ItSfmsS7, .nHCJskDZVlmDhNNS9Ixv, .utUDWsORU96S7boXm2Aq, .cpBP3znf6dhHLA2dywjy, .G7JYBeU1c2QawLyFs5VK, .vYl1kgf1_R18FCmHgdw2, .vZkc6VwrFz0EjVBuHGmx, .iVAZDcTm1XGjxwKlQisz, ._I_1HMbDnNlNAaViEnbp, .xXj7eFQ8SoDKYXy6L3E1, .F68SsPm8lZFktQ1lWsQz, .MnW5SczTcbdFHxLZ_Z8j, .WiPggcPDzbwGxoxwLWFf, .ReyA3uE3K7oEz7PTTnAn, .x8e0kqJPS0bM4dVK7ESH, .gZ2Nla3mdRREDCwybK6X, .SChMe0Tert7lmc5jqH01, .AwF4EfqLOIJ2xO7CjHoX, .UlkNeRDFoia4UDWtrOr4, .k_RKSQxa2u5_6KmcOoSw, ._mWmycP_WIvMNQdKoAFb, .O3UuqEx6ibrxyOJIdpdg, .akCwgJVf4B4ep6KYwrk5, .bIA4qeTh_LSwQJuVxDzl, .ajr9pah2nj_5cXrAofU_, .gvn0k6QI7Yl_A0u46hKn, .obTnuSx7ZKIIY1_fwJhe, .IiLMLyxs074DwmEH4x5b, .RJjM91y1EBycwhT_wH59, .mxn5B5ceO2ksvMlI1bYz, .l8wtkGVi89_AsA3nXDSR, .Th1XPPdXMnxNCDrYsnwb, .SJMBltbXfqUiByDAkUN_, .Nayn_JfAUsSO0EFapLuY, .YqlFpeC9yMVhGmd84Gdo, .HksuyUyj1n3aTnB4nHLd, .DT8FJnRKoRVWo77CPQbQ, ._Cq69xKZBtHaaeMZXIdk, .main-leaderboardComponent-container, .sponsor-container, a.link-subtle.main-navBar-navBarLink.GKnnhbExo0U9l7Jz2rdc, button[title="${t}"], button[aria-label="${t}"], .main-topBar-UpgradeButton, .main-contextMenu-menuItem a[href^="https://www.spotify.com/premium/"], div[data-testid*="hpto"] {display: none !important;}`,document.head.appendChild(e)},I=async()=>{try{await f.putOverridesValues({pairs:{ads:"0",catalogue:"premium",product:"premium",type:"premium"}})}catch(e){console.error("adblockify: Failed inside `disableAds` function\n",e)}},h=async()=>{try{const{billboard:e,leaderboard:t,sponsoredPlaylist:i}=r,l=getTestingClient(n.functionModules,f.transport);if(l?l.addPlaytime({seconds:-1e11}):await w.post("sp://ads/v1/testing/playtime",{value:-1e11}),await u.disable(),u.isNewAdsNpvEnabled=!1,await e.disable(),await t?.disableLeaderboard(),await i.disable(),r?.inStreamApi){const{inStreamApi:d}=r;await d.disable()}if(r?.vto){const{vto:d}=r;await d.manager.disable(),d.isNewAdsNpvEnabled=!1}setTimeout(I,100)}catch(e){console.error("adblockify: Failed inside `configureAdManagers` function\n",e)}},M=async()=>{for(const e of m)E(e.slotId||e.slot_id),setTimeout(()=>g({adSlotEvent:{slotId:e.slotId||e.slot_id}}),50)},g=e=>{const t=e?.adSlotEvent?.slotId;try{const i=u?.inStreamApi?.adsCoreConnector;typeof i?.clearSlot=="function"&&i.clearSlot(t);const l=getSlotsClient(n.functionModules,f.transport);l&&l.clearAllAds({slotId:t}),C(t)}catch(i){if(console.error("adblockify: Failed inside `handleAdSlot` function. Retrying in 1 second...\n",i),retryCounter(t,"increment"),retryCounter(t,"get")>5){console.error(`adblockify: Failed inside \`handleAdSlot\` function for 5th time. Giving up... Slot id: ${t}.`),retryCounter(t,"clear");return}setTimeout(g,1*1e3,e)}h()},C=async e=>{try{const t=getSettingsClient(n.cache,n.functionModules,f.transport);if(!t)return;const i=b[0]===1&&b[1]>=2&&b[2]>=82?0n:"0";await t.updateAdServerEndpoint({slotIds:[e],url:"http://localhost/no/thanks"}),await t.updateStreamTimeInterval({slotId:e,timeInterval:i}),await t.updateSlotEnabled({slotId:e,enabled:!1}),await t.updateDisplayTimeInterval({slotId:e,timeInterval:i})}catch(t){console.error("adblockify: Failed inside `updateSlotSettings` function\n",t)}},P=async()=>{for(const e of m)C(e.slotId||e.slot_id)},E=e=>{try{u.inStreamApi.adsCoreConnector.subscribeToSlot(e,g)}catch(t){console.error("adblockify: Failed inside `subToSlot` function\n",t)}},_=()=>{const e=Array.from(document.querySelectorAll(".ReactModalPortal")),t=new MutationObserver(i=>{for(const l of i)if(l.addedNodes.length){const d=l.addedNodes[0];if(!d.classList.contains("GenericModal__overlay"))continue;const p=d.querySelector("iframe");if(!p)continue;const y=p?.contentWindow?.document.body;if(!y||!y.querySelector("[data-click-to-action-url*='/premium-promotional-offer-terms']"))continue;d.remove()}});for(const i of e)t.observe(i,{childList:!0})},A=async()=>{try{const e=JSON.parse(localStorage.getItem("spicetify-exp-features")||"{}");typeof e?.enableEsperantoMigration?.value<"u"&&(e.enableEsperantoMigration.value=!0),typeof e?.enableInAppMessaging?.value<"u"&&(e.enableInAppMessaging.value=!1),typeof e?.hideUpgradeCTA?.value<"u"&&(e.hideUpgradeCTA.value=!0),typeof e?.enablePremiumUserForMiniPlayer?.value<"u"&&(e.enablePremiumUserForMiniPlayer.value=!0),localStorage.setItem("spicetify-exp-features",JSON.stringify(e));const t={enableEsperantoMigration:!0,enableInAppMessaging:!1,hideUpgradeCTA:!0,enablePremiumUserForMiniPlayer:!0};if(Spicetify.Platform?.RemoteConfigDebugAPI?.getProperties&&Spicetify.Platform.RemoteConfigDebugAPI?.setOverride){const i=Spicetify.Platform.RemoteConfigDebugAPI,l=await i.getProperties();for(const[d,S]of Object.entries(t)){const p=l.find(y=>y?.source==="web"&&y?.type==="boolean"&&y?.name===d);p&&await i.setOverride({ref:p,value:S},{autoRunOverrideEffects:p.localValue!==S})}}else if(Spicetify.Platform?.RemoteConfigDebugAPI?.setOverride){const i=Spicetify.Platform.RemoteConfigDebugAPI;for(const[l,d]of Object.entries(t))await i.setOverride({source:"web",type:"boolean",name:l},d)}else if(Spicetify?.RemoteConfigResolver&&typeof Spicetify.createInternalMap=="function"){const i=Spicetify.createInternalMap(t);Spicetify.RemoteConfigResolver.value.setOverrides(i)}}catch(e){console.error("adblockify: Failed inside `enableExperimentalFeatures` function\n",e)}};M(),k(),f.subValues({keys:["ads","catalogue","product","type"]},()=>h()),A(),setTimeout(A,3*1e3),setTimeout(P,5*1e3)})();