(()=>{"use strict";const e="SUPER_WALLET_",t=[["locked","WalletNotConnected"],["not connected","Unauthorized"],["No transaction","InvalidInput"],["No message","InvalidInput"],["timed out","RequestTimeout"],["replay detected","DuplicateRequest"],["rejected","UserRejected"]];function o(e){const o=e.toLowerCase();for(const[e,n]of t)if(o.includes(e.toLowerCase()))return n;return"RequestFailed"}const n=new Set(["CONNECT","DISCONNECT","SIGN_TRANSACTION","SIGN_MESSAGE","GET_ACCOUNT","GET_CONNECTED_ORIGINS"]);!function(){try{const e=document.createElement("script");e.src=chrome.runtime.getURL("content/inject.js"),e.type="text/javascript";const t=document.head||document.documentElement;t.insertBefore(e,t.firstChild),e.addEventListener("load",()=>e.remove())}catch(e){console.error("[Super Wallet] Failed to inject provider script:",e)}}(),window.addEventListener("message",async t=>{if(t.source!==window)return;const i=t.data;if(!i||"from-page"!==i.direction)return;const{type:r,id:c,payload:s}=i;if("string"!=typeof r||!r.startsWith(e))return;const d=r.slice(13);if(n.has(d))try{const e=await chrome.runtime.sendMessage({type:`SUPER_${d}`,payload:s,origin:window.location.origin});e&&e.error?window.postMessage({direction:"from-content-script",id:c,error:o(String(e.error))},window.location.origin):window.postMessage({direction:"from-content-script",id:c,payload:e},window.location.origin)}catch(e){window.postMessage({direction:"from-content-script",id:c,error:"RequestFailed"},window.location.origin)}}),chrome.runtime.onMessage.addListener(t=>{"WALLET_LOCKED"===t.type&&window.postMessage({direction:"from-content-script",type:`${e}LOCKED`,payload:{}},window.location.origin)}),console.log("[Super Wallet] Content script loaded")})();