import{g as w,a as f}from"./chunk-CMnPkCrZ.js";import{g as u}from"./chunk-CwBz3wv4.js";const c=document.getElementById("ipfs-status"),m=document.getElementById("ipfs-dot"),t=document.getElementById("helios-status"),i=document.getElementById("helios-dot"),g=document.getElementById("helios-error-card"),b=document.getElementById("helios-error-detail");let l=!1;function n(e,o){e.classList.remove("ok","bad","syncing","caution"),o!=="idle"&&e.classList.add(o)}function r(e,o){e.classList.remove("ok","bad","caution"),o!=="idle"&&e.classList.add(o)}async function y(){const e=w(await u());try{if(!await f(e,{force:!0,timeoutMs:1500}))throw new Error("gateway probe failed");c.textContent="online",r(c,"ok"),n(m,"ok")}catch{c.textContent="offline",r(c,"bad"),n(m,"bad")}}function h(e){b.textContent=e,g.hidden=!1}function s(){g.hidden=!0}function d(e){if(r(t,"idle"),l){t.textContent="RPC-trusted",r(t,"caution"),n(i,"caution"),s();return}if(!e){t.textContent="unknown",n(i,"idle"),s();return}switch(e.state){case"idle":t.textContent="not started",n(i,"idle"),s();break;case"booting":t.textContent="booting…",n(i,"syncing"),s();break;case"syncing":t.textContent="syncing…",n(i,"syncing"),s();break;case"synced":e.rpcHealth?.state==="failing"?(t.textContent="RPC failing",r(t,"bad"),n(i,"bad"),h(e.rpcHealth.lastError??"The Ethereum RPC is rejecting requests.")):(t.textContent="online",r(t,"ok"),n(i,"ok"),s());break;case"error":t.textContent="error",r(t,"bad"),n(i,"bad"),h(e.error??"Unknown error");break}}async function p(){for(;;){try{const e=await chrome.runtime.sendMessage({type:"get-helios-status"});d(e?.status??null)}catch{d(null)}await new Promise(e=>setTimeout(e,1e3))}}document.getElementById("open-options")?.addEventListener("click",async()=>{const e=await u(),o=!e.onboardingComplete&&!e.rpcUrl?chrome.runtime.getURL("onboarding.html"):chrome.runtime.getURL("options.html");await chrome.tabs.create({url:o}),window.close()});document.getElementById("open-bookmarks")?.addEventListener("click",async()=>{await chrome.tabs.create({url:chrome.runtime.getURL("bookmarks.html")}),window.close()});document.getElementById("open-home")?.addEventListener("click",async()=>{await chrome.tabs.create({url:chrome.runtime.getURL("home.html")}),window.close()});async function E(){const e=await u();if(!e.onboardingComplete){const o=chrome.runtime.getURL("onboarding.html"),a=(await chrome.tabs.query({url:o}))[0];a?.id!=null?(await chrome.tabs.update(a.id,{active:!0}),a.windowId!=null&&await chrome.windows.update(a.windowId,{focused:!0})):await chrome.tabs.create({url:o}),window.close();return}if(y(),l=e.trustRpcDirectly,l){d(null);return}p()}E();
//# sourceMappingURL=chunk-Dd3SohMk.js.map
