import{c as a}from"./chains-By83jz87.js";const i={1:{amount:.02},56:{amount:.1},143:{amount:1e3},999:{amount:1},8453:{amount:.02}};async function p(t){return((await chrome.storage.local.get("bloom.sitePreferences"))?.["bloom.sitePreferences"]||{})[t]!==!1}function q(t){return/^0x[a-fA-F0-9]{40}$/.test(t)}function A(t){if(!t||typeof t!="string")return null;const o=t.match(/0x[a-fA-F0-9]{40}/);return o?o[0]:null}async function l(t,o={},n=5e3){const e=new AbortController,c=e.signal,s=setTimeout(()=>{e.abort()},n);try{return await fetch(t,{...o,signal:c})}finally{clearTimeout(s)}}async function m(){return(await chrome.storage.local.get("bloom.token"))["bloom.token"]??null}function C(t,o){t.parentNode&&t.parentNode.insertBefore(o,t.nextSibling)}async function y(t){const{"bloom.quickBuyAmounts":o}=await chrome.storage.local.get(["bloom.quickBuyAmounts"]),n=t.token,e=o?.[n];return typeof e=="number"&&e>0?e:i[t.id].amount}async function f(t){return`${await y(t)} ${t.token}`}const b="https://evm.bloom-ext.app";async function S(t){try{const o=await m();if(!o)return;const n={address:t,auth_token:o},c=await(await l(`${b}/get-chain-id`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})).json();return c.success?a.find(s=>s.key===c.chain_id):void 0}catch(o){console.error(`Failed to fetch chain id for address: ${t}`,o);return}}const u={color:"#00ff95",backgroundColor:"#00563180"},T={...u},d=[".bloom-buy-qt-btn",".bloom-snipe-qt-btn",".bloom-search-qt-btn",".bloom-top-qt-btn",".bloom-limit-buy-qt-btn",".bloom-limit-sell-qt-btn",".bloom-sell-qt-btn",".bloom-toggle-memescope-btn",".bloom-evm-quick-buy-btn",".bloom-evm-quick-panel-btn"];async function g(){const t=(await chrome.storage.local.get("bloom.quickBuyButton"))?.["bloom.quickBuyButton"];return{color:t?.color||u.color,backgroundColor:t?.backgroundColor||u.backgroundColor}}async function w(){return g()}function _(t){const o=async n=>{const e={};if(n["bloom.quickBuyAmounts"]&&await B(),n["bloom.quickBuyButton"]){const c=n["bloom.quickBuyButton"].newValue||{};e.color=c?.color||u.color,e.backgroundColor=c?.backgroundColor||u.backgroundColor}Object.keys(e).length>0&&t(e)};return chrome.storage.onChanged.addListener(o),()=>chrome.storage.onChanged.removeListener(o)}function k(t,o,n,e){t.style.color=o,t.style.backgroundColor=n,t.style.borderColor=`${n}${n.length===7?"80":""}`;const c=t.querySelector("svg");c&&c.setAttribute("fill",o),t.onmouseover=function(){t.style.backgroundColor=n.slice(0,7)+"CC"},t.onmouseout=function(){t.style.backgroundColor=n}}function L(t,o,n=d){document.querySelectorAll(n.join(", ")).forEach(c=>{k(c,t,o)})}async function B(){const t=document.querySelectorAll("[data-chain-key]");for(const o of t){const n=o.dataset.chainKey,e=a.find(r=>r.key===n);if(!e)continue;const c=await f(e),s=o.querySelector(".bloom-evm-quick-buy-btn span");s&&(s.textContent=c)}}export{T as Q,q as a,S as b,f as c,C as d,A as e,m as f,w as g,y as h,p as i,_ as s,L as u};
