import{removeBloomQuickPanels as a}from"./panel.js-PlKG13TM.js";import{createTradingPanel as d}from"./panel-new.ts-DTBxtLQQ.js";import{getQuickBuyAmountForCurrentChain as f,showSwapToast as b}from"./utils.js-CC0KFyjC.js";import"./chains-By83jz87.js";const p="dexscreener";window.platform=p;let c="#00ff95",r="#00563180";function w(){document.querySelectorAll(".bloom-buy-qt-btn").forEach(n=>{n.style.color=c,n.style.backgroundColor=r,n.style.borderColor=`${r}${r.length===7?"80":""}`;const t=n.querySelector("svg");t&&t.setAttribute("fill",c),n.onmouseover=function(){n.style.backgroundColor=r.slice(0,7)+"CC"},n.onmouseout=function(){n.style.backgroundColor=r}})}chrome.storage.onChanged.addListener(async e=>{if(e["bloom.quickBuyAmounts"]&&await f(),e["bloom.quickBuyButton"]){const n=e["bloom.quickBuyButton"].newValue||{};c=n?.color||"#00ff95",r=n?.backgroundColor||"#00563180"}(e["bloom.quickBuyAmounts"]||e["bloom.quickBuyButton"])&&w()});async function h(){return window.location.pathname.includes("bsc/0x")?56:window.location.pathname.includes("base/0x")?8453:window.location.pathname.includes("ethereum/0x")?1:window.location.pathname.includes("hyperevm/0x")?999:window.location.pathname.includes("monad/0x")?143:null}window.getChainId=h;async function k(){return window.location.pathname.split("/").pop()}window.getPoolId=k;async function T(){const e=[...document.getElementsByClassName("chakra-text")].find(m=>m.innerText==="Pair");if(!e)return showToast("Token mint not found!","top-center","error");const n=e.parentElement;if(!n)return showToast("Token mint not found!","top-center","error");const t=[n.nextSibling.nextSibling,n.nextSibling.nextSibling.nextSibling];let l="";for(const m of t){const o=m.firstChild;if(!o.innerText.startsWith("USD")&&o.innerText!=="WETH"&&o.innerText!=="WBNB"&&o.innerText!=="WHYPE"&&o.innerText!=="ETH"&&o.innerText!=="BNB"&&o.innerText!=="HYPE"&&o.innerText!=="WXPL"&&o.innerText!=="XPL"&&o.innerText!=="WMON"&&o.innerText!=="MON"){l=o.getAttribute("title");break}}return l||showToast("Failed to get token mint!","top-center","error")}window.getTokenMint=T;let i,g;const y=2e3;let s=null;function u(){s!==null&&(clearInterval(s),s=null)}function x(){u(),s=setInterval(()=>{if(i!=="dexscreener-token"){u();return}document.querySelector("#bloom-extension-panel")||(console.log("[bloom] panel missing, re-creating"),d())},y)}chrome.runtime.onMessage.addListener(async function(e){if(console.log("dexscreener message",e),g=e.tabId,e.shouldWarnAboutUpdate&&showToast("A new version of the Bloom Extension is available! Check out how to install it <a href='https://docs.bloombot.app/extension/setup/download-chrome/.zip-file' target='_blank' style='text-decoration: underline; color: #EEA7ED;'>here</a>","top-center","info"),e.message==="txUpdate")return b(e);if(e.message==="quickBuyAmount"){await f(),w();return}if(((await chrome.storage.local.get("bloom.sitePreferences"))?.["bloom.sitePreferences"]||{})[p]===!1){u(),a(),i=null;return}await f();const t=(await chrome.storage.local.get("bloom.quickBuyButton"))?.["bloom.quickBuyButton"]||{};c=t?.color||"#00ff95",r=t?.backgroundColor||"#00563180",e.message==="dexscreener-token"?(window.__BLOOM_TAB_ID__=g,(!document.querySelector("#bloom-extension-panel")||i!=="dexscreener-token")&&(a(),console.log("creating trading panel"),d()),i="dexscreener-token",x()):e.message==="reset"&&i==="dexscreener-token"?(a(),d(),x()):e.message==="dexscreener"&&(u(),a(),i="other")});
