/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@phantom/browser-sdk@2.0.1/dist/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";var __create=Object.create,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(e,t)=>{for(var r in t)__defProp(e,r,{get:t[r],enumerable:!0})},__copyProps=(e,t,r,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let n of __getOwnPropNames(t))__hasOwnProp.call(e,n)||n===r||__defProp(e,n,{get:()=>t[n],enumerable:!(a=__getOwnPropDesc(t,n))||a.enumerable});return e},__toESM=(e,t,r)=>(r=null!=e?__create(__getProtoOf(e)):{},__copyProps(!t&&e&&e.__esModule?r:__defProp(r,"default",{value:e,enumerable:!0}),e)),__toCommonJS=e=>__copyProps(__defProp({},"__esModule",{value:!0}),e),src_exports={};__export(src_exports,{AddressType:()=>import_client5.AddressType,BrowserSDK:()=>BrowserSDK,DebugCategory:()=>DebugCategory,DebugLevel:()=>DebugLevel,NetworkId:()=>import_constants7.NetworkId,PHANTOM_ICON:()=>import_constants8.PHANTOM_ICON,base64urlDecode:()=>import_base64url.base64urlDecode,base64urlEncode:()=>import_base64url.base64urlEncode,debug:()=>debug,detectBrowser:()=>detectBrowser,getBrowserDisplayName:()=>getBrowserDisplayName,getDeeplinkToPhantom:()=>getDeeplinkToPhantom,getPlatformName:()=>getPlatformName,isMobileDevice:()=>isMobileDevice,isPhantomLoginAvailable:()=>isPhantomLoginAvailable,parseBrowserFromUserAgent:()=>parseBrowserFromUserAgent,waitForPhantomExtension:()=>waitForPhantomExtension}),module.exports=__toCommonJS(src_exports);var import_client=require("@phantom/client"),import_client4=require("@phantom/client"),DebugLevel=(e=>(e[e.ERROR=0]="ERROR",e[e.WARN=1]="WARN",e[e.INFO=2]="INFO",e[e.DEBUG=3]="DEBUG",e))(DebugLevel||{}),Debug=class{constructor(){this.level=0,this.enabled=!1}static getInstance(){return Debug.instance||(Debug.instance=new Debug),Debug.instance}setCallback(e){this.callback=e}setLevel(e){this.level=e}enable(){this.enabled=!0}disable(){this.enabled=!1}writeLog(e,t,r,a){if(!this.enabled||e>this.level)return;const n={timestamp:Date.now(),level:e,category:t,message:r,data:a};this.callback&&this.callback(n)}error(e,t,r){this.writeLog(0,e,t,r)}warn(e,t,r){this.writeLog(1,e,t,r)}info(e,t,r){this.writeLog(2,e,t,r)}debug(e,t,r){this.writeLog(3,e,t,r)}log(e,t,r){this.writeLog(3,e,t,r)}},debug=Debug.getInstance(),DebugCategory={BROWSER_SDK:"BrowserSDK",PROVIDER_MANAGER:"ProviderManager",EMBEDDED_PROVIDER:"EmbeddedProvider",INJECTED_PROVIDER:"InjectedProvider",PHANTOM_CONNECT_AUTH:"PhantomConnectAuth",JWT_AUTH:"JWTAuth",STORAGE:"Storage",SESSION:"Session"},import_constants=require("@phantom/constants"),import_client3=require("@phantom/client"),import_browser_injected_sdk=require("@phantom/browser-injected-sdk"),import_browser_injected_sdk2=require("@phantom/browser-injected-sdk"),import_solana=require("@phantom/browser-injected-sdk/solana"),import_ethereum=require("@phantom/browser-injected-sdk/ethereum"),import_auto_confirm=require("@phantom/browser-injected-sdk/auto-confirm"),import_client2=require("@phantom/client"),CUSTOM_WALLET_CONFIGS=[{id:"coinbase-wallet",name:"Coinbase Wallet",icon:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTI4IDU2YzE1LjQ2NCAwIDI4LTEyLjUzNiAyOC0yOFM0My40NjQgMCAyOCAwIDAgMTIuNTM2IDAgMjhzMTIuNTM2IDI4IDI4IDI4WiIgZmlsbD0iIzFCNTNFNCIvPjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNNyAyOGMwIDExLjU5OCA5LjQwMiAyMSAyMSAyMXMyMS05LjQwMiAyMS0yMVMzOS41OTggNyAyOCA3IDcgMTYuNDAyIDcgMjhabTE3LjIzNC02Ljc2NmEzIDMgMCAwIDAtMyAzdjcuNTMzYTMgMyAwIDAgMCAzIDNoNy41MzNhMyAzIDAgMCAwIDMtM3YtNy41MzNhMyAzIDAgMCAwLTMtM2gtNy41MzNaIiBmaWxsPSIjZmZmIi8+PC9zdmc+",windowProperty:"coinbaseSolana",addressTypes:[import_client2.AddressType.solana]}];function generateWalletIdFromEIP6963(e){return e.rdns?e.rdns.split(".").reverse().join("-"):e.name.toLowerCase().replace(/\s+/g,"-")}function generateWalletIdFromName(e){return e.toLowerCase().replace(/\s+/g,"-")}function processEIP6963Providers(e){const t=[];debug.log(DebugCategory.BROWSER_SDK,"Processing EIP-6963 providers",{providerCount:e.size,providerNames:Array.from(e.values()).map((e=>e.info.name))});for(const[,r]of e){const{info:e,provider:a}=r;if(e.name.toLowerCase().includes("phantom")||e.rdns&&(e.rdns.toLowerCase().includes("phantom")||"app.phantom"===e.rdns.toLowerCase())){debug.log(DebugCategory.BROWSER_SDK,"Skipping Phantom from EIP-6963",{name:e.name,rdns:e.rdns});continue}const n=generateWalletIdFromEIP6963(e);debug.log(DebugCategory.BROWSER_SDK,"Discovered EIP-6963 wallet",{walletId:n,walletName:e.name,rdns:e.rdns}),t.push({id:n,name:e.name,icon:e.icon,addressTypes:[import_client3.AddressType.ethereum],providers:{ethereum:a},rdns:e.rdns,discovery:"eip6963"})}return debug.log(DebugCategory.BROWSER_SDK,"EIP-6963 discovery completed",{discoveredCount:t.length,walletIds:t.map((e=>e.id))}),t}function discoverEthereumWallets(){return new Promise((e=>{const t=new Map;if("undefined"==typeof window)return void e([]);const r=e=>{const r=e.detail;r?.info&&r?.provider&&t.set(r.info.uuid,r)};window.addEventListener("eip6963:announceProvider",r),window.dispatchEvent(new Event("eip6963:requestProvider"));setTimeout((()=>{const a=processEIP6963Providers(t);window.removeEventListener("eip6963:announceProvider",r),e(a)}),400)}))}async function discoverSolanaWallets(){const e=[];if("undefined"==typeof window||"undefined"==typeof navigator)return debug.log(DebugCategory.BROWSER_SDK,"Wallet Standard discovery skipped (not in browser environment)"),e;const t=new Set;let r;function a(){return r||(r=[...t]),r}function n(...e){return(e=e.filter((e=>!t.has(e)))).length?(e.forEach((e=>function(e){r=void 0,t.add(e);const a=e.features?Object.keys(e.features):[];debug.log(DebugCategory.BROWSER_SDK,"Wallet registered",{name:e.name,chains:e.chains,featureKeys:a,totalWallets:t.size})}(e))),function(){e.forEach((e=>function(e){r=void 0,t.delete(e)}(e)))}):()=>{}}const s=Object.freeze({register:n}),o=e=>{const t=e.detail;if("function"==typeof t)try{t(s)}catch(e){debug.warn(DebugCategory.BROWSER_SDK,"Error calling wallet registration callback",{error:e})}};try{window.addEventListener("wallet-standard:register-wallet",o)}catch(e){debug.warn(DebugCategory.BROWSER_SDK,"Could not add register-wallet event listener",{error:e})}class i extends Event{constructor(e){super("wallet-standard:app-ready",{bubbles:!1,cancelable:!1,composed:!1}),this.detail=e}}try{window.dispatchEvent(new i(s)),debug.log(DebugCategory.BROWSER_SDK,"Dispatched wallet-standard:app-ready event")}catch(e){debug.warn(DebugCategory.BROWSER_SDK,"Could not dispatch app-ready event",{error:e})}const l={getWallets:()=>({get:a,on:(e,t)=>()=>{},register:n})};navigator.wallets||(navigator.wallets=l),debug.log(DebugCategory.BROWSER_SDK,"Initialized Wallet Standard registry"),await new Promise((e=>setTimeout(e,100)));const d=navigator.wallets||window.wallets;if(!d||"function"!=typeof d.getWallets){const t={hasNavigator:!!navigator,hasWindow:"undefined"!=typeof window,note:"Wallet Standard API not properly initialized"};return debug.log(DebugCategory.BROWSER_SDK,"Wallet Standard API not available",t),e}const c=d.getWallets(),u=()=>Promise.resolve([...c.get()]);debug.log(DebugCategory.BROWSER_SDK,"Wallet Standard API detected, starting discovery");try{let t=[],r=0;const a=5,n=100,s=400;for(await new Promise((e=>setTimeout(e,n)));r<a;){t=await u();const e={attempt:r+1,walletCount:t.length,walletNames:t.map((e=>e.name)),chains:t.flatMap((e=>e.chains))};if(debug.log(DebugCategory.BROWSER_SDK,`Wallet Standard getWallets attempt ${r+1}`,e),t.length>0||r===a-1)break;await new Promise((e=>setTimeout(e,n))),r++}const o=n+r*n;if(o<s){const e=s-o;await new Promise((t=>setTimeout(t,e))),t=await u()}debug.log(DebugCategory.BROWSER_SDK,"Wallet Standard getWallets final result",{walletCount:t.length,walletNames:t.map((e=>e.name)),attempts:r+1});for(const r of t){if(!(r.chains.some((e=>{const t=e.toLowerCase();return t.startsWith("solana:")||"solana"===t}))||r.features&&"object"==typeof r.features&&Object.keys(r.features).some((e=>e.toLowerCase().startsWith("solana:"))))){const e=r.features?Object.keys(r.features):[];debug.log(DebugCategory.BROWSER_SDK,"Wallet does not support Solana",{walletName:r.name,chains:r.chains,featureKeys:e});continue}if(r.name.toLowerCase().includes("phantom")){debug.log(DebugCategory.BROWSER_SDK,"Skipping Phantom from Wallet Standard (handled separately)");continue}const t=generateWalletIdFromName(r.name),a=r.features?Object.keys(r.features):[];debug.log(DebugCategory.BROWSER_SDK,"Discovered Wallet Standard Solana wallet",{walletId:t,walletName:r.name,chains:r.chains,featureKeys:a,icon:r.icon,version:r.version,accountCount:r.accounts?.length||0}),e.push({id:t,name:r.name,icon:r.icon,addressTypes:[import_client3.AddressType.solana],providers:{solana:r},discovery:"standard"})}}catch(e){debug.warn(DebugCategory.BROWSER_SDK,"Wallet Standard API error",{error:e instanceof Error?e.message:String(e),stack:e instanceof Error?e.stack:void 0})}const g={discoveredCount:e.length,walletIds:e.map((e=>e.id)),walletNames:e.map((e=>e.name))};debug.log(DebugCategory.BROWSER_SDK,"Wallet Standard Solana discovery completed",g);const h=discoverCustomSolanaWallets();return e.push(...h),e}function discoverCustomSolanaWallets(){const e=[];if("undefined"==typeof window)return debug.log(DebugCategory.BROWSER_SDK,"Custom wallet discovery skipped (not in browser environment)"),e;debug.log(DebugCategory.BROWSER_SDK,"Starting custom Solana wallet discovery",{configCount:CUSTOM_WALLET_CONFIGS.length});for(const t of CUSTOM_WALLET_CONFIGS){if(!t.addressTypes.includes(import_client3.AddressType.solana))continue;const r=window[t.windowProperty];r?(debug.log(DebugCategory.BROWSER_SDK,"Discovered custom Solana wallet",{walletId:t.id,walletName:t.name,windowProperty:t.windowProperty}),e.push({id:t.id,name:t.name,icon:t.icon,addressTypes:t.addressTypes,providers:{solana:r},discovery:"custom"})):debug.log(DebugCategory.BROWSER_SDK,"Custom wallet not found",{walletId:t.id,windowProperty:t.windowProperty})}return debug.log(DebugCategory.BROWSER_SDK,"Custom Solana wallet discovery completed",{discoveredCount:e.length,walletIds:e.map((e=>e.id))}),e}function discoverPhantomWallet(e){if("undefined"==typeof window)return null;if(!(0,import_browser_injected_sdk.isPhantomExtensionInstalled)())return null;const t=[(0,import_browser_injected_sdk2.createExtensionPlugin)()];e.includes(import_client3.AddressType.solana)&&t.push((0,import_solana.createSolanaPlugin)()),e.includes(import_client3.AddressType.ethereum)&&t.push((0,import_ethereum.createEthereumPlugin)()),t.push((0,import_auto_confirm.createAutoConfirmPlugin)());const r=(0,import_browser_injected_sdk2.createPhantom)({plugins:t});return{id:"phantom",name:"Phantom",icon:import_constants.PHANTOM_ICON,addressTypes:e,providers:{solana:e.includes(import_client3.AddressType.solana)?r.solana:void 0,ethereum:e.includes(import_client3.AddressType.ethereum)?r.ethereum:void 0},isPhantom:!0,phantomInstance:r,discovery:"phantom"}}async function discoverWallets(e){const t=e||[];debug.log(DebugCategory.BROWSER_SDK,"Starting all wallet discovery methods",{addressTypes:t});const[r,a]=await Promise.all([discoverSolanaWallets(),discoverEthereumWallets()]),n=discoverPhantomWallet(t);debug.log(DebugCategory.BROWSER_SDK,"All wallet discovery methods completed",{phantomFound:!!n,solanaWalletsCount:r.length,ethereumWalletsCount:a.length,solanaWalletIds:r.map((e=>e.id)),ethereumWalletIds:a.map((e=>e.id))});const s=new Map;n&&s.set("phantom",n);for(const e of[...r,...a]){const t=s.get(e.id);if(t){const r=Array.from(new Set([...t.addressTypes,...e.addressTypes])),a={...t.providers,...e.providers},n={...t,addressTypes:r,icon:e.icon||t.icon,providers:a};s.set(e.id,n),debug.log(DebugCategory.BROWSER_SDK,"Merged wallet by ID",{walletName:e.name,walletId:e.id,existingAddressTypes:t.addressTypes,newAddressTypes:e.addressTypes,mergedAddressTypes:r,existingProviders:Object.keys(t.providers||{}),newProviders:Object.keys(e.providers||{}),mergedProviders:Object.keys(a)}),debug.log(DebugCategory.BROWSER_SDK,"Merged wallet from multiple discovery methods",{walletId:e.id,walletName:e.name,existingAddressTypes:t.addressTypes,newAddressTypes:e.addressTypes,mergedAddressTypes:r})}else s.set(e.id,e)}return Array.from(s.values())}var import_constants2=require("@phantom/constants"),import_eventemitter3=require("eventemitter3"),import_buffer=require("buffer"),InjectedWalletSolanaChain=class{constructor(e,t,r){this.eventEmitter=new import_eventemitter3.EventEmitter,this._publicKey=null,this.provider=e,this.walletId=t,this.walletName=r,this.setupEventListeners()}get publicKey(){return this._publicKey}get isConnected(){return this.provider.isConnected||!!this._publicKey}async connect(e){try{await this.provider.connect(e);const t=this.provider.isConnected;if(!t||null===this.provider.publicKey)throw debug.error(DebugCategory.INJECTED_PROVIDER,"Provider not connected after connect() call",{walletId:this.walletId,walletName:this.walletName,providerConnected:t,providerPublicKey:this.provider.publicKey}),new Error("Provider not connected after connect() call");let r;const a=this.provider.publicKey;if("string"==typeof a)r=a;else{if(null==a||"function"!=typeof a.toString)throw debug.error(DebugCategory.INJECTED_PROVIDER,"Invalid publicKey format in provider state",{walletId:this.walletId,walletName:this.walletName,publicKeyType:typeof a}),new Error("Invalid publicKey format in provider state");r=a.toString()}if(!r||0===r.length)throw new Error("Empty publicKey from provider");return this._publicKey=r,debug.info(DebugCategory.INJECTED_PROVIDER,"External wallet Solana connected",{walletId:this.walletId,walletName:this.walletName,publicKey:r}),{publicKey:r}}catch(e){throw debug.error(DebugCategory.INJECTED_PROVIDER,"External wallet Solana connect failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async disconnect(){debug.log(DebugCategory.INJECTED_PROVIDER,"External wallet Solana disconnect",{walletId:this.walletId,walletName:this.walletName});try{await this.provider.disconnect(),this._publicKey=null,debug.info(DebugCategory.INJECTED_PROVIDER,"External wallet Solana disconnected",{walletId:this.walletId,walletName:this.walletName})}catch(e){throw debug.error(DebugCategory.INJECTED_PROVIDER,"External wallet Solana disconnect failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async signMessage(e){const t="string"==typeof e?(new TextEncoder).encode(e):e,r="string"==typeof e?e.substring(0,50):`${t.length} bytes`;debug.log(DebugCategory.INJECTED_PROVIDER,"External wallet Solana signMessage",{walletId:this.walletId,walletName:this.walletName,messagePreview:r,messageLength:t.length});try{const t=await this.provider.signMessage(e);return debug.info(DebugCategory.INJECTED_PROVIDER,"External wallet Solana signMessage success",{walletId:this.walletId,walletName:this.walletName,signatureLength:t.signature.length}),{signature:t.signature instanceof Uint8Array?t.signature:new Uint8Array(import_buffer.Buffer.from(t.signature,"base64")),publicKey:t.publicKey||this._publicKey||""}}catch(e){throw debug.error(DebugCategory.INJECTED_PROVIDER,"External wallet Solana signMessage failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async signTransaction(e){debug.log(DebugCategory.INJECTED_PROVIDER,"External wallet Solana signTransaction",{walletId:this.walletId,walletName:this.walletName});try{const t=await this.provider.signTransaction(e);return debug.info(DebugCategory.INJECTED_PROVIDER,"External wallet Solana signTransaction success",{walletId:this.walletId,walletName:this.walletName}),t}catch(e){throw debug.error(DebugCategory.INJECTED_PROVIDER,"External wallet Solana signTransaction failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async signAndSendTransaction(e){debug.log(DebugCategory.INJECTED_PROVIDER,"External wallet Solana signAndSendTransaction",{walletId:this.walletId,walletName:this.walletName});try{const t=await this.provider.signAndSendTransaction(e);return debug.info(DebugCategory.INJECTED_PROVIDER,"External wallet Solana signAndSendTransaction success",{walletId:this.walletId,walletName:this.walletName,signature:t.signature}),t}catch(e){throw debug.error(DebugCategory.INJECTED_PROVIDER,"External wallet Solana signAndSendTransaction failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async signAllTransactions(e){debug.log(DebugCategory.INJECTED_PROVIDER,"External wallet Solana signAllTransactions",{walletId:this.walletId,walletName:this.walletName,transactionCount:e.length});try{const t=await this.provider.signAllTransactions(e);return debug.info(DebugCategory.INJECTED_PROVIDER,"External wallet Solana signAllTransactions success",{walletId:this.walletId,walletName:this.walletName,signedCount:t.length}),t}catch(e){throw debug.error(DebugCategory.INJECTED_PROVIDER,"External wallet Solana signAllTransactions failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async signAndSendAllTransactions(e){debug.log(DebugCategory.INJECTED_PROVIDER,"External wallet Solana signAndSendAllTransactions",{walletId:this.walletId,walletName:this.walletName,transactionCount:e.length});try{const t=await this.provider.signAndSendAllTransactions(e);return debug.info(DebugCategory.INJECTED_PROVIDER,"External wallet Solana signAndSendAllTransactions success",{walletId:this.walletId,walletName:this.walletName,signatureCount:t.signatures.length}),t}catch(e){throw debug.error(DebugCategory.INJECTED_PROVIDER,"External wallet Solana signAndSendAllTransactions failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}switchNetwork(e){return Promise.resolve()}setupEventListeners(){"function"==typeof this.provider.on&&(this.provider.on("connect",(e=>{this._publicKey=e,this.eventEmitter.emit("connect",e)})),this.provider.on("disconnect",(()=>{this._publicKey=null,this.eventEmitter.emit("disconnect")})),this.provider.on("accountChanged",(e=>{this._publicKey=e||null,this.eventEmitter.emit("accountChanged",this._publicKey)})))}on(e,t){this.eventEmitter.on(e,t)}off(e,t){this.eventEmitter.off(e,t)}},import_eventemitter32=require("eventemitter3"),import_parsers=require("@phantom/parsers"),import_buffer2=require("buffer"),import_bs58=__toESM(require("bs58")),WalletStandardSolanaAdapter=class{constructor(e,t,r){this.eventEmitter=new import_eventemitter32.EventEmitter,this._publicKey=null,this.wallet=e,this.walletId=t,this.walletName=r,this.setupEventListeners()}get publicKey(){return this._publicKey}get isConnected(){return null!==this._publicKey}async connect(e){try{const e=this.wallet.features["standard:connect"];if(!e)throw new Error("Wallet Standard connect feature not available");const t=await e.connect();let r;if(Array.isArray(t)&&t.length>0?r=t:this.wallet.accounts&&this.wallet.accounts.length>0&&(r=Array.from(this.wallet.accounts)),!r||0===r.length)throw new Error("No accounts available after connecting to wallet");const a=r[0];if(!a)throw new Error("First account is null or undefined");let n;if("string"==typeof a?n=a:"object"==typeof a&&null!==a&&(n=a.address||a.publicKey?.toString()||(a.publicKey instanceof Uint8Array?import_buffer2.Buffer.from(a.publicKey).toString("hex"):void 0)),!n)throw new Error(`Could not extract address from account. Account structure: ${JSON.stringify(a,null,2)}`);return this._publicKey=n,{publicKey:n}}catch(e){throw debug.error(DebugCategory.INJECTED_PROVIDER,"Wallet Standard Solana connect failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async disconnect(){try{const e=this.wallet.features["standard:disconnect"];e&&await e.disconnect(),this._publicKey=null}catch(e){throw debug.error(DebugCategory.INJECTED_PROVIDER,"Wallet Standard Solana disconnect failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async signMessage(e){try{const t=this.wallet.features["solana:signMessage"];if(!t)throw new Error("Wallet Standard signMessage feature not available");const r="string"==typeof e?(new TextEncoder).encode(e):e,a=await t.signMessage({message:r,account:this.wallet.accounts[0]});if(!Array.isArray(a)||0===a.length)throw new Error("Expected array result from signMessage, got: "+typeof a);const n=a[0];if(!n||!n.signature)throw new Error(`Invalid signMessage result structure: ${JSON.stringify(a)}`);const s=this.parseUint8Array(n.signature);if(0===s.length)throw new Error("Signature is empty");return{signature:s,publicKey:n.account?.address||this.wallet.accounts[0]?.address||this._publicKey||""}}catch(e){throw debug.error(DebugCategory.INJECTED_PROVIDER,"Wallet Standard Solana signMessage failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async signTransaction(e){try{const t=this.wallet.features["solana:signTransaction"];if(!t)throw new Error("Wallet Standard signTransaction feature not available");if(!this.wallet.accounts||0===this.wallet.accounts.length)throw new Error("No accounts available. Please connect first.");const r=this.wallet.accounts[0],a=this.serializeTransaction(e),n=await t.signTransaction({transaction:a,account:r});let s;if(Array.isArray(n)&&n.length>0){const e=n[0];e&&"object"==typeof e&&(s=e.signedTransaction||e.transaction)}else if(n&&"object"==typeof n&&!Array.isArray(n)){const e=n;s=e.transaction||e.signedTransaction}if(!s)throw new Error("No transaction data found in Wallet Standard result");const o=this.parseUint8Array(s);if(0===o.length)throw new Error("Empty signed transaction returned from Wallet Standard");return(0,import_parsers.deserializeSolanaTransaction)(o)}catch(e){throw debug.error(DebugCategory.INJECTED_PROVIDER,"Wallet Standard Solana signTransaction failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async signAndSendTransaction(e){try{const t=this.wallet.features["solana:signAndSendTransaction"];if(!t)throw new Error("Wallet Standard signAndSendTransaction feature not available");if(!this.wallet.accounts||0===this.wallet.accounts.length)throw new Error("No accounts available. Please connect first.");const r=this.wallet.accounts[0],a=r.chains?.[0]||"solana:mainnet",n=this.serializeTransaction(e),s=await t.signAndSendTransaction({transaction:n,account:r,chain:a});let o;if(Array.isArray(s)&&s.length>0)o=s[0];else{if(!s||"object"!=typeof s||Array.isArray(s))throw new Error("Invalid signAndSendTransaction result format");o=s}if(!o.signature)throw new Error("No signature found in signAndSendTransaction result");const i=this.parseUint8Array(o.signature);return{signature:import_bs58.default.encode(i)}}catch(e){throw debug.error(DebugCategory.INJECTED_PROVIDER,"Wallet Standard Solana signAndSendTransaction failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async signAllTransactions(e){try{const t=[];for(const r of e){const e=await this.signTransaction(r);t.push(e)}return t}catch(e){throw debug.error(DebugCategory.INJECTED_PROVIDER,"Wallet Standard Solana signAllTransactions failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async signAndSendAllTransactions(e){try{const t=[];for(const r of e){const e=await this.signAndSendTransaction(r);t.push(e.signature)}return{signatures:t}}catch(e){throw debug.error(DebugCategory.INJECTED_PROVIDER,"Wallet Standard Solana signAndSendAllTransactions failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async switchNetwork(e){return Promise.resolve()}setupEventListeners(){const e=this.wallet.features["standard:events"];e?(debug.log(DebugCategory.INJECTED_PROVIDER,"Setting up Wallet Standard event listeners",{walletId:this.walletId,walletName:this.walletName}),e.on("change",(e=>{if(debug.log(DebugCategory.INJECTED_PROVIDER,"Wallet Standard change event received",{walletId:this.walletId,walletName:this.walletName,hasAccounts:!!e.accounts,accountCount:e.accounts?.length||0}),void 0!==e.accounts)if(e.accounts.length>0){const t=e.accounts[0],r=this.extractAccountAddress(t);r?(this._publicKey=r,this.eventEmitter.emit("accountChanged",r),this.eventEmitter.emit("connect",r),debug.log(DebugCategory.INJECTED_PROVIDER,"Emitted accountChanged and connect events",{walletId:this.walletId,walletName:this.walletName,address:r})):(this._publicKey=null,this.eventEmitter.emit("accountChanged",null),debug.log(DebugCategory.INJECTED_PROVIDER,"Emitted accountChanged event (null - invalid account)",{walletId:this.walletId,walletName:this.walletName}))}else this._publicKey=null,this.eventEmitter.emit("accountChanged",null),this.eventEmitter.emit("disconnect"),debug.log(DebugCategory.INJECTED_PROVIDER,"Emitted accountChanged and disconnect events",{walletId:this.walletId,walletName:this.walletName})}))):debug.log(DebugCategory.INJECTED_PROVIDER,"Wallet Standard events feature not available",{walletId:this.walletId,walletName:this.walletName})}extractAccountAddress(e){return e.address}on(e,t){this.eventEmitter.on(e,t),debug.log(DebugCategory.INJECTED_PROVIDER,"Added event listener",{walletId:this.walletId,walletName:this.walletName,event:e})}off(e,t){this.eventEmitter.off(e,t),debug.log(DebugCategory.INJECTED_PROVIDER,"Removed event listener",{walletId:this.walletId,walletName:this.walletName,event:e})}serializeTransaction(e){return"function"==typeof e.serialize?e.serialize({requireAllSignatures:!1,verifySignatures:!1}):e instanceof Uint8Array?e:new Uint8Array(0)}parseUint8Array(e){if(e instanceof Uint8Array)return e;if(Array.isArray(e))return new Uint8Array(e);if("object"==typeof e&&null!==e){const t=Object.keys(e).map(Number).filter((e=>!isNaN(e)&&e>=0)).sort(((e,t)=>e-t));if(t.length>0){const r=Math.max(...t),a=new Uint8Array(r+1);for(const r of t)a[r]=Number(e[r])||0;return a}}return new Uint8Array(0)}},import_eventemitter33=require("eventemitter3"),InjectedWalletEthereumChain=class{constructor(e,t,r){this.eventEmitter=new import_eventemitter33.EventEmitter,this._connected=!1,this._chainId="0x1",this._accounts=[],this.provider=e,this.walletId=t,this.walletName=r,this.setupEventListeners()}get chainId(){return this._chainId}get accounts(){return this._accounts}async request(e){debug.log(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum request",{walletId:this.walletId,walletName:this.walletName,method:e.method});try{!["personal_sign","eth_sign","eth_signTypedData","eth_signTypedData_v4","eth_sendTransaction","eth_signTransaction"].includes(e.method)||this._connected&&0!==this._accounts.length||(debug.log(DebugCategory.INJECTED_PROVIDER,"Method requires authorization, ensuring connection",{walletId:this.walletId,walletName:this.walletName,method:e.method}),await this.connect());const t=await this.provider.request(e);return debug.info(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum request success",{walletId:this.walletId,walletName:this.walletName,method:e.method}),t}catch(t){if(4100===t?.code){debug.log(DebugCategory.INJECTED_PROVIDER,"Got 4100 Unauthorized, attempting to re-authorize",{walletId:this.walletId,walletName:this.walletName,method:e.method});try{await this.provider.request({method:"eth_requestAccounts"});const t=await this.provider.request(e);return debug.info(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum request success (after re-auth)",{walletId:this.walletId,walletName:this.walletName,method:e.method}),t}catch(t){throw debug.error(DebugCategory.INJECTED_PROVIDER,"Failed after re-authorization",{walletId:this.walletId,walletName:this.walletName,method:e.method,error:t instanceof Error?t.message:String(t)}),t}}throw debug.error(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum request failed",{walletId:this.walletId,walletName:this.walletName,method:e.method,error:t instanceof Error?t.message:String(t),errorCode:t?.code}),t}}async connect(){debug.log(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum connect",{walletId:this.walletId,walletName:this.walletName});try{const e=await this.provider.request({method:"eth_requestAccounts"});return this._connected=e.length>0,this._accounts=e,debug.info(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum connected (via eth_requestAccounts)",{walletId:this.walletId,walletName:this.walletName,accountCount:e.length,accounts:e}),e}catch(e){throw debug.error(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum connect failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async disconnect(){debug.log(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum disconnect",{walletId:this.walletId,walletName:this.walletName});try{await this.provider.disconnect(),this._connected=!1,this._accounts=[],debug.info(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum disconnected",{walletId:this.walletId,walletName:this.walletName})}catch(e){throw debug.error(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum disconnect failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async signPersonalMessage(e,t){const r=e.length>50?e.substring(0,50)+"...":e;debug.log(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum signPersonalMessage",{walletId:this.walletId,walletName:this.walletName,messagePreview:r,messageLength:e.length,address:t});try{const r=this.provider,a="function"==typeof r.isConnected&&r.isConnected()||"boolean"==typeof r.connected&&r.connected;this._connected&&0!==this._accounts.length&&a||(debug.log(DebugCategory.INJECTED_PROVIDER,"Not connected, attempting to connect before signing",{walletId:this.walletId,walletName:this.walletName,internalConnected:this._connected,accountsLength:this._accounts.length,providerConnected:a}),await this.connect());const n=t.toLowerCase();if(!this._accounts.map((e=>e.toLowerCase())).includes(n)){debug.warn(DebugCategory.INJECTED_PROVIDER,"Address not in connected accounts, refreshing connection",{walletId:this.walletId,walletName:this.walletName,requestedAddress:t,connectedAccounts:this._accounts});const e=await this.getAccounts();if(!e.map((e=>e.toLowerCase())).includes(n))throw new Error(`Address ${t} is not connected. Connected accounts: ${e.join(", ")}`);this._accounts=e}if("function"==typeof this.provider.signPersonalMessage){const r=await this.provider.signPersonalMessage(e,t);return debug.info(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum signPersonalMessage success",{walletId:this.walletId,walletName:this.walletName,signatureLength:r.length}),r}const s=await this.request({method:"personal_sign",params:[e,t]});return debug.info(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum signPersonalMessage success",{walletId:this.walletId,walletName:this.walletName,signatureLength:s.length}),s}catch(e){throw debug.error(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum signPersonalMessage failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e),errorCode:e?.code}),e}}async signTypedData(e,t){debug.log(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum signTypedData",{walletId:this.walletId,walletName:this.walletName,primaryType:e?.primaryType,address:t});try{if("function"==typeof this.provider.signTypedData){const r=await this.provider.signTypedData(e,t);return debug.info(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum signTypedData success",{walletId:this.walletId,walletName:this.walletName,signatureLength:r.length}),r}const r=await this.request({method:"eth_signTypedData_v4",params:[t,e]});return debug.info(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum signTypedData success",{walletId:this.walletId,walletName:this.walletName,signatureLength:r.length}),r}catch(e){throw debug.error(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum signTypedData failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async signTransaction(e){debug.log(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum signTransaction",{walletId:this.walletId,walletName:this.walletName,from:e.from,to:e.to});try{if("function"==typeof this.provider.signTransaction){const t=await this.provider.signTransaction(e);return debug.info(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum signTransaction success",{walletId:this.walletId,walletName:this.walletName,signatureLength:t.length}),t}const t=await this.request({method:"eth_signTransaction",params:[e]});return debug.info(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum signTransaction success",{walletId:this.walletId,walletName:this.walletName,signatureLength:t.length}),t}catch(e){throw debug.error(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum signTransaction failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async sendTransaction(e){debug.log(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum sendTransaction",{walletId:this.walletId,walletName:this.walletName,from:e.from,to:e.to,value:e.value});try{if("function"==typeof this.provider.sendTransaction){const t=await this.provider.sendTransaction(e);return debug.info(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum sendTransaction success",{walletId:this.walletId,walletName:this.walletName,txHash:t}),t}const t=await this.request({method:"eth_sendTransaction",params:[e]});return debug.info(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum sendTransaction success",{walletId:this.walletId,walletName:this.walletName,txHash:t}),t}catch(e){throw debug.error(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum sendTransaction failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async switchChain(e){debug.log(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum switchChain",{walletId:this.walletId,walletName:this.walletName,chainId:e});try{const t="string"==typeof e?e.toLowerCase().startsWith("0x")?e:`0x${parseInt(e,10).toString(16)}`:`0x${e.toString(16)}`;"function"==typeof this.provider.switchChain?await this.provider.switchChain(t):await this.request({method:"wallet_switchEthereumChain",params:[{chainId:t}]}),this._chainId=t,this.eventEmitter.emit("chainChanged",this._chainId),debug.info(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum switchChain success",{walletId:this.walletId,walletName:this.walletName,chainId:t})}catch(e){throw debug.error(DebugCategory.INJECTED_PROVIDER,"External wallet Ethereum switchChain failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async getChainId(){if("function"==typeof this.provider.getChainId){const e=await this.provider.getChainId();return this._chainId=`0x${e.toString(16)}`,e}const e=await this.request({method:"eth_chainId"}),t=parseInt(e,16);return this._chainId=e,t}async getAccounts(){if("function"==typeof this.provider.getAccounts){const e=await this.provider.getAccounts();return this._accounts=e,e}const e=await this.request({method:"eth_accounts"});return this._accounts=e,e}isConnected(){return this._connected}setupEventListeners(){"function"==typeof this.provider.on&&(this.provider.on("connect",(e=>{this._connected=!0,this._chainId=e.chainId,this.eventEmitter.emit("connect",e)})),this.provider.on("disconnect",(e=>{this._connected=!1,this._accounts=[],this.eventEmitter.emit("disconnect",e),this.eventEmitter.emit("accountsChanged",[])})),this.provider.on("accountsChanged",(e=>{this._accounts=e,this._connected=e.length>0,this.eventEmitter.emit("accountsChanged",e)})),this.provider.on("chainChanged",(e=>{this._chainId=e,this.eventEmitter.emit("chainChanged",e)})))}on(e,t){this.eventEmitter.on(e,t)}off(e,t){this.eventEmitter.off(e,t)}};function isPhantomWallet(e){return void 0!==e&&"phantom"===e.id&&"isPhantom"in e&&!0===e.isPhantom}function isWalletStandardWallet(e){return null!==e&&"object"==typeof e&&"features"in e&&"object"==typeof e.features}var InjectedWalletRegistry=class{constructor(){this.wallets=new Map,this.discoveryPromise=null}register(e){const t={};e.providers?.solana&&(isWalletStandardWallet(e.providers.solana)?(t.solana=new WalletStandardSolanaAdapter(e.providers.solana,e.id,e.name),debug.log(DebugCategory.BROWSER_SDK,"Wrapped Wallet Standard Solana wallet with adapter",{walletId:e.id,walletName:e.name})):(t.solana=new InjectedWalletSolanaChain(e.providers.solana,e.id,e.name),debug.log(DebugCategory.BROWSER_SDK,"Wrapped Solana provider with InjectedWalletSolanaChain",{walletId:e.id,walletName:e.name}))),e.providers?.ethereum&&(t.ethereum=new InjectedWalletEthereumChain(e.providers.ethereum,e.id,e.name),debug.log(DebugCategory.BROWSER_SDK,"Wrapped Ethereum provider with InjectedWalletEthereumChain",{walletId:e.id,walletName:e.name}));const r={...e,providers:Object.keys(t).length>0?t:e.providers};this.wallets.set(e.id,r)}registerPhantom(e,t){const r={};t.includes(import_client.AddressType.solana)&&e.solana&&(r.solana=new InjectedWalletSolanaChain(e.solana,"phantom","Phantom"),debug.log(DebugCategory.BROWSER_SDK,"Created InjectedWalletSolanaChain wrapper for Phantom",{walletId:"phantom"})),t.includes(import_client.AddressType.ethereum)&&e.ethereum&&(r.ethereum=new InjectedWalletEthereumChain(e.ethereum,"phantom","Phantom"),debug.log(DebugCategory.BROWSER_SDK,"Created InjectedWalletEthereumChain wrapper for Phantom",{walletId:"phantom"}));const a={id:"phantom",name:"Phantom",icon:import_constants2.PHANTOM_ICON,addressTypes:t,providers:r,isPhantom:!0,phantomInstance:e,discovery:"phantom"};this.wallets.set("phantom",a),debug.log(DebugCategory.BROWSER_SDK,"Registered Phantom wallet with chain wrappers",{addressTypes:t,hasSolana:!!r.solana,hasEthereum:!!r.ethereum})}unregister(e){this.wallets.delete(e)}has(e){return this.wallets.has(e)}getById(e){return this.wallets.get(e)}getAll(){return Array.from(this.wallets.values())}getByAddressTypes(e){if(0===e.length)return this.getAll();const t=new Set(e);return this.getAll().filter((e=>e.addressTypes.some((e=>t.has(e)))))}discover(e){return this.discoveryPromise||(debug.log(DebugCategory.BROWSER_SDK,"Starting wallet discovery",{addressTypes:e}),this.discoveryPromise=discoverWallets(e).then((t=>{const r=e?t.filter((t=>t.addressTypes.some((t=>e.includes(t))))):t;for(const e of r)"phantom"===e.id&&isPhantomWallet(e)?this.registerPhantom(e.phantomInstance,e.addressTypes):this.register(e),debug.log(DebugCategory.BROWSER_SDK,"Registered discovered wallet",{id:e.id,name:e.name,addressTypes:e.addressTypes});debug.info(DebugCategory.BROWSER_SDK,"Wallet discovery completed",{totalDiscovered:t.length,relevantWallets:r.length})})).catch((e=>{throw debug.warn(DebugCategory.BROWSER_SDK,"Wallet discovery failed",{error:e}),this.discoveryPromise=null,e}))),this.discoveryPromise}},walletRegistry=null;function getWalletRegistry(){return walletRegistry||(walletRegistry=new InjectedWalletRegistry),walletRegistry}var WAS_CONNECTED_KEY="phantom-injected-was-connected",WAS_CONNECTED_VALUE="true",LAST_WALLET_ID_KEY="phantom-injected-last-wallet-id",InjectedProvider=class{constructor(e){this.selectedWalletId=null,this.walletStates=new Map,this.eventListeners=new Map,this.eventsInitialized=!1,this.eventListenersSetup=new Set,this.eventListenerCleanups=new Map,debug.log(DebugCategory.INJECTED_PROVIDER,"Initializing InjectedProvider",{config:e}),this.addressTypes=e.addressTypes,this.walletRegistry=getWalletRegistry(),debug.log(DebugCategory.INJECTED_PROVIDER,"Address types configured",{addressTypes:this.addressTypes}),this.walletRegistry.discover(this.addressTypes).catch((e=>{debug.warn(DebugCategory.INJECTED_PROVIDER,"Wallet discovery failed during initialization",{error:e})})),debug.info(DebugCategory.INJECTED_PROVIDER,"InjectedProvider initialized")}async waitForWalletDiscovery(e){if(!this.walletRegistry.has(e)){debug.log(DebugCategory.INJECTED_PROVIDER,"Wallet not found in registry, waiting for discovery",{walletId:e});try{await this.walletRegistry.discover(this.addressTypes),debug.log(DebugCategory.INJECTED_PROVIDER,"Wallet discovery completed",{walletId:e})}catch(t){debug.warn(DebugCategory.INJECTED_PROVIDER,"Wallet discovery failed",{walletId:e,error:t instanceof Error?t.message:String(t)})}}}getChainProvider(e,t,r){if(!this.addressTypes.includes(e))throw new Error(`${r} not enabled for this provider`);const a=this.selectedWalletId||"phantom",n=this.walletRegistry.getById(a);if(!n){if(this.walletRegistry.discoveryPromise)throw new Error(`Wallet "${a}" not found. Wallet discovery is still in progress. Please wait for sdk.discoverWallets() to complete before accessing chain properties.`);throw new Error(`Wallet "${a}" not found. Please ensure wallet discovery has completed. Make sure you call sdk.discoverWallets() and await it before accessing chain properties.`)}const s=n.providers?.[t];if(!s)throw new Error(`Selected wallet "${n.name}" does not support ${r}. This wallet only supports: ${n.addressTypes.join(", ")}. Make sure your SDK config includes ${r} in addressTypes.`);return s}get solana(){return this.getChainProvider(import_client4.AddressType.solana,"solana","Solana")}get ethereum(){return this.getChainProvider(import_client4.AddressType.ethereum,"ethereum","Ethereum")}validateAndSelectWallet(e){if(!this.walletRegistry.has(e))throw debug.error(DebugCategory.INJECTED_PROVIDER,"Unknown injected wallet id requested",{walletId:e}),new Error(`Unknown injected wallet id: ${e}`);const t=this.walletRegistry.getById(e);if(!t||!t.providers)throw debug.warn(DebugCategory.INJECTED_PROVIDER,"Wallet not available for connection",{walletId:e}),new Error(`Wallet not available for connection: ${e}`);return this.selectedWalletId=e,debug.log(DebugCategory.INJECTED_PROVIDER,"Selected injected wallet for connection",{walletId:e}),t}async connectToWallet(e,t){if(!e.providers){const e=new Error(`Wallet adapter not available for wallet: ${this.selectedWalletId}`);throw debug.error(DebugCategory.INJECTED_PROVIDER,"Wallet adapter not available",{walletId:this.selectedWalletId}),this.emit("connect_error",{error:e.message,source:t?.skipEventListeners?"auto-connect":"manual-connect"}),e}debug.log(DebugCategory.INJECTED_PROVIDER,"Connecting via wallet",{walletId:this.selectedWalletId,walletName:e.name,options:t}),t?.skipEventListeners||this.setupEventListeners(e);const r=[];if(this.addressTypes.includes(import_client4.AddressType.solana)&&e.providers?.solana){debug.log(DebugCategory.INJECTED_PROVIDER,"Attempting Solana connection",{walletId:this.selectedWalletId,walletName:e.name,onlyIfTrusted:t?.onlyIfTrusted});try{const a=(await e.providers.solana.connect(t?.onlyIfTrusted?{onlyIfTrusted:!0}:void 0)).publicKey;r.push({addressType:import_client4.AddressType.solana,address:a}),debug.info(DebugCategory.INJECTED_PROVIDER,"Solana connected successfully",{address:a,walletId:this.selectedWalletId,walletName:e.name})}catch(t){debug.warn(DebugCategory.INJECTED_PROVIDER,"Failed to connect Solana, continuing with other chains",{error:t,walletId:this.selectedWalletId,walletName:e.name})}}if(this.addressTypes.includes(import_client4.AddressType.ethereum)&&e.providers?.ethereum){debug.log(DebugCategory.INJECTED_PROVIDER,"Attempting Ethereum connection",{walletId:this.selectedWalletId,walletName:e.name,silent:t?.silent});try{let a;a=t?.silent?await e.providers.ethereum.request({method:"eth_accounts"}):await e.providers.ethereum.connect(),a.length>0&&(r.push(...a.map((e=>({addressType:import_client4.AddressType.ethereum,address:e})))),debug.info(DebugCategory.INJECTED_PROVIDER,"Ethereum connected successfully",{addresses:a,walletId:this.selectedWalletId,walletName:e.name}))}catch(t){debug.warn(DebugCategory.INJECTED_PROVIDER,"Failed to connect Ethereum, continuing with other chains",{error:t,walletId:this.selectedWalletId,walletName:e.name})}}return r}async finalizeConnection(e,t,r){if(0===e.length){const e=new Error("Failed to connect to any supported wallet provider");throw this.emit("connect_error",{error:e.message,source:"manual-connect"}),e}this.selectedWalletId&&this.setWalletState(this.selectedWalletId,{connected:!0,addresses:e}),debug.log(DebugCategory.INJECTED_PROVIDER,"Finalized connection with addresses",{addressCount:e.length,addresses:e.map((e=>({type:e.addressType,address:e.address.substring(0,10)+"..."})))});const a=await this.getAuthUserId("manual-connect");try{localStorage.setItem(WAS_CONNECTED_KEY,WAS_CONNECTED_VALUE),debug.log(DebugCategory.INJECTED_PROVIDER,"Set was-connected flag - auto-reconnect enabled"),this.selectedWalletId&&(localStorage.setItem(LAST_WALLET_ID_KEY,this.selectedWalletId),debug.log(DebugCategory.INJECTED_PROVIDER,"Stored last injected wallet id",{walletId:this.selectedWalletId}))}catch(e){debug.warn(DebugCategory.INJECTED_PROVIDER,"Failed to persist injected provider state",{error:e})}const n=r?this.walletRegistry.getById(r):void 0,s={addresses:e,status:"completed",authUserId:a,authProvider:t,walletId:r,wallet:n?{id:n.id,name:n.name,icon:n.icon,addressTypes:n.addressTypes,rdns:n.rdns,discovery:n.discovery}:void 0};return this.emit("connect",{addresses:e,source:"manual-connect",authUserId:a,walletId:r}),s}async connect(e){if(debug.info(DebugCategory.INJECTED_PROVIDER,"Starting injected provider connect",{addressTypes:this.addressTypes,provider:e.provider}),"injected"!==e.provider)throw new Error(`Invalid provider for injected connection: ${e.provider}. Must be "injected"`);const t=e.walletId||"phantom";this.emit("connect_start",{source:"manual-connect",providerType:"injected",walletId:t});try{const e=this.validateAndSelectWallet(t),r=await this.connectToWallet(e);return await this.finalizeConnection(r,"injected",this.selectedWalletId||void 0)}catch(e){throw this.emit("connect_error",{error:e instanceof Error?e.message:"Failed to connect",source:"manual-connect"}),e}}async disconnect(){debug.info(DebugCategory.INJECTED_PROVIDER,"Starting injected provider disconnect");const e=this.walletRegistry.getById(this.selectedWalletId||"phantom");if(e?.providers){if(this.addressTypes.includes(import_client4.AddressType.solana)&&e.providers.solana)try{await e.providers.solana.disconnect(),debug.log(DebugCategory.INJECTED_PROVIDER,"Solana disconnected successfully")}catch(e){debug.warn(DebugCategory.INJECTED_PROVIDER,"Failed to disconnect Solana",{error:e})}if(this.addressTypes.includes(import_client4.AddressType.ethereum)&&e.providers.ethereum)try{await e.providers.ethereum.disconnect(),debug.log(DebugCategory.INJECTED_PROVIDER,"Ethereum disconnected successfully")}catch(e){debug.warn(DebugCategory.INJECTED_PROVIDER,"Failed to disconnect Ethereum",{error:e})}}const t=this.selectedWalletId||"phantom",r=this.eventListenerCleanups.get(t);r&&(r.forEach((e=>e())),this.eventListenerCleanups.delete(t)),this.eventListenersSetup.delete(t),this.selectedWalletId&&this.setWalletState(this.selectedWalletId,{connected:!1,addresses:[]});try{localStorage.removeItem(WAS_CONNECTED_KEY),debug.log(DebugCategory.INJECTED_PROVIDER,"Cleared was connected flag to prevent auto-reconnect")}catch(e){debug.warn(DebugCategory.INJECTED_PROVIDER,"Failed to clear was-connected flag",{error:e})}this.emit("disconnect",{source:"manual-disconnect"}),debug.info(DebugCategory.INJECTED_PROVIDER,"Injected provider disconnected successfully")}async autoConnect(){debug.log(DebugCategory.INJECTED_PROVIDER,"Attempting auto-connect");let e=null;try{if(localStorage.getItem(WAS_CONNECTED_KEY)!==WAS_CONNECTED_VALUE)return void debug.log(DebugCategory.INJECTED_PROVIDER,"Skipping auto-connect: user was not previously connected");e=localStorage.getItem(LAST_WALLET_ID_KEY),debug.log(DebugCategory.INJECTED_PROVIDER,"User was previously connected, attempting auto-connect",{lastWalletId:e||"phantom"})}catch(e){return void debug.warn(DebugCategory.INJECTED_PROVIDER,"Failed to check was-connected flag",{error:e})}this.emit("connect_start",{source:"auto-connect",providerType:"injected"});try{const t=e||"phantom";await this.waitForWalletDiscovery(t);const r=this.validateAndSelectWallet(t);let a=[];try{a=await this.connectToWallet(r,{onlyIfTrusted:!0,silent:!0,skipEventListeners:!0})}catch(e){debug.log(DebugCategory.INJECTED_PROVIDER,"Auto-connect failed (expected if not trusted)",{error:e,walletId:this.selectedWalletId})}if(0===a.length)return debug.log(DebugCategory.INJECTED_PROVIDER,"Auto-connect failed: no trusted connections available"),void this.emit("connect_error",{error:"No trusted connections available",source:"auto-connect"});this.setupEventListeners(r),this.selectedWalletId&&this.setWalletState(this.selectedWalletId,{connected:!0,addresses:a});const n=await this.getAuthUserId("auto-connect");this.emit("connect",{addresses:a,source:"auto-connect",authUserId:n,walletId:this.selectedWalletId}),debug.info(DebugCategory.INJECTED_PROVIDER,"Auto-connect successful",{addressCount:a.length,addresses:a.map((e=>({type:e.addressType,address:e.address.substring(0,8)+"..."}))),walletId:this.selectedWalletId,authUserId:n})}catch(e){debug.log(DebugCategory.INJECTED_PROVIDER,"Auto-connect failed with error",{error:e instanceof Error?e.message:String(e)}),this.emit("connect_error",{error:e instanceof Error?e.message:"Auto-connect failed",source:"auto-connect"})}}getWalletState(e){return this.walletStates.has(e)||this.walletStates.set(e,{connected:!1,addresses:[]}),this.walletStates.get(e)}setWalletState(e,t){this.walletStates.set(e,t)}updateWalletAddresses(e,t,r){const a=[...this.getWalletState(e).addresses.filter((e=>e.addressType!==r)),...t.map((e=>({addressType:r,address:e})))];return this.setWalletState(e,{connected:a.length>0,addresses:a}),a}getAccountChangeSource(e){return`${e}-account-change`}createSolanaConnectHandler(e,t){return async r=>{debug.log(DebugCategory.INJECTED_PROVIDER,"Solana connect event received",{publicKey:r,walletId:e});const a=this.updateWalletAddresses(e,[r],import_client4.AddressType.solana),n=await this.getAuthUserId("Solana connect event");this.emit("connect",{addresses:a,source:t,authUserId:n,walletId:this.selectedWalletId})}}createSolanaDisconnectHandler(e,t){return()=>{debug.log(DebugCategory.INJECTED_PROVIDER,"Solana disconnect event received",{walletId:e});const r=this.getWalletState(e).addresses.filter((e=>e.addressType!==import_client4.AddressType.solana));this.setWalletState(e,{connected:r.length>0,addresses:r}),this.emit("disconnect",{source:t})}}createSolanaAccountChangeHandler(e,t){return async r=>{if(debug.log(DebugCategory.INJECTED_PROVIDER,"Solana account changed event received",{publicKey:r,walletId:e}),r){const a=this.updateWalletAddresses(e,[r],import_client4.AddressType.solana),n=await this.getAuthUserId("Solana account changed event");this.emit("connect",{addresses:a,source:this.getAccountChangeSource(t),authUserId:n,walletId:this.selectedWalletId})}else{const r=this.getWalletState(e).addresses.filter((e=>e.addressType!==import_client4.AddressType.solana));this.setWalletState(e,{connected:r.length>0,addresses:r}),this.emit("disconnect",{source:this.getAccountChangeSource(t)})}}}createEthereumConnectHandler(e,t){return async r=>{let a=[];if(Array.isArray(r))a=r;else try{const t=this.walletRegistry.getById(e);t?.providers?.ethereum&&(a=await t.providers.ethereum.getAccounts())}catch(e){debug.warn(DebugCategory.INJECTED_PROVIDER,"Failed to get accounts on connect",{error:e})}if(debug.log(DebugCategory.INJECTED_PROVIDER,"Ethereum connect event received",{accounts:a,walletId:e}),a.length>0){const r=this.updateWalletAddresses(e,a,import_client4.AddressType.ethereum),n=await this.getAuthUserId("Ethereum connect event");this.emit("connect",{addresses:r,source:t,authUserId:n,walletId:this.selectedWalletId})}}}createEthereumDisconnectHandler(e,t){return()=>{debug.log(DebugCategory.INJECTED_PROVIDER,"Ethereum disconnect event received",{walletId:e});const r=this.getWalletState(e).addresses.filter((e=>e.addressType!==import_client4.AddressType.ethereum));this.setWalletState(e,{connected:r.length>0,addresses:r}),this.emit("disconnect",{source:t})}}createEthereumAccountChangeHandler(e,t){return async r=>{if(debug.log(DebugCategory.INJECTED_PROVIDER,"Ethereum accounts changed event received",{accounts:r,walletId:e}),r&&r.length>0){const a=this.updateWalletAddresses(e,r,import_client4.AddressType.ethereum),n=await this.getAuthUserId("Ethereum accounts changed event");this.emit("connect",{addresses:a,source:this.getAccountChangeSource(t),authUserId:n,walletId:this.selectedWalletId})}else{const r=this.getWalletState(e).addresses.filter((e=>e.addressType!==import_client4.AddressType.ethereum));this.setWalletState(e,{connected:r.length>0,addresses:r}),this.emit("disconnect",{source:this.getAccountChangeSource(t)})}}}getAddresses(){const e=this.selectedWalletId||"phantom";return this.getWalletState(e).addresses}getEnabledAddressTypes(){if(!this.selectedWalletId||"phantom"===this.selectedWalletId)return this.addressTypes;const e=this.walletRegistry.getById(this.selectedWalletId);return e?e.addressTypes:this.addressTypes}isConnected(){const e=this.selectedWalletId||"phantom";return this.getWalletState(e).connected}async enableAutoConfirm(e){const t=this.walletRegistry.getById(this.selectedWalletId||"phantom");if(!isPhantomWallet(t))throw new Error("Auto-confirm is only available for Phantom wallet");return debug.log(DebugCategory.INJECTED_PROVIDER,"Enabling autoConfirm",{params:e}),await t.phantomInstance.autoConfirm.autoConfirmEnable(e)}async disableAutoConfirm(){const e=this.walletRegistry.getById(this.selectedWalletId||"phantom");if(!isPhantomWallet(e))throw new Error("Auto-confirm is only available for Phantom wallet");debug.log(DebugCategory.INJECTED_PROVIDER,"Disabling autoConfirm"),await e.phantomInstance.autoConfirm.autoConfirmDisable()}async getAutoConfirmStatus(){const e=this.walletRegistry.getById(this.selectedWalletId||"phantom");if(!isPhantomWallet(e))throw new Error("Auto-confirm is only available for Phantom wallet");return debug.log(DebugCategory.INJECTED_PROVIDER,"Getting autoConfirm status"),await e.phantomInstance.autoConfirm.autoConfirmStatus()}async getSupportedAutoConfirmChains(){const e=this.walletRegistry.getById(this.selectedWalletId||"phantom");if(!isPhantomWallet(e))throw new Error("Auto-confirm is only available for Phantom wallet");return debug.log(DebugCategory.INJECTED_PROVIDER,"Getting supported autoConfirm chains"),await e.phantomInstance.autoConfirm.autoConfirmSupportedChains()}async getAuthUserId(e){if(isPhantomWallet(this.walletRegistry.getById(this.selectedWalletId||"phantom")))try{if(window.phantom?.app?.getUser){const t=await window.phantom.app.getUser(),r=t?.authUserId;return r&&debug.log(DebugCategory.INJECTED_PROVIDER,`Retrieved authUserId from window.phantom.app.getUser() during ${e}`,{authUserId:r}),r}}catch(t){debug.log(DebugCategory.INJECTED_PROVIDER,`Failed to get user info during ${e} (method may not be supported)`,{error:t})}}on(e,t){if(debug.log(DebugCategory.INJECTED_PROVIDER,"Adding event listener",{event:e}),!this.eventsInitialized){const e=this.selectedWalletId||"phantom",t=this.walletRegistry.getById(e);t&&this.setupEventListeners(t)}this.eventListeners.has(e)||this.eventListeners.set(e,new Set),this.eventListeners.get(e)?.add(t)}off(e,t){debug.log(DebugCategory.INJECTED_PROVIDER,"Removing event listener",{event:e}),this.eventListeners.has(e)&&(this.eventListeners.get(e)?.delete(t),0===this.eventListeners.get(e)?.size&&this.eventListeners.delete(e))}emit(e,t){debug.log(DebugCategory.INJECTED_PROVIDER,"Emitting event",{event:e,listenerCount:this.eventListeners.get(e)?.size||0,data:t});const r=this.eventListeners.get(e);r&&r.size>0&&r.forEach((r=>{try{r(t)}catch(t){debug.error(DebugCategory.INJECTED_PROVIDER,"Event callback error",{event:e,error:t})}}))}setupSolanaEventListeners(e,t,r){if("function"!=typeof e.on)return;debug.log(DebugCategory.INJECTED_PROVIDER,"Setting up Solana event listeners",{walletId:t,source:r});const a={connect:this.createSolanaConnectHandler(t,r),disconnect:this.createSolanaDisconnectHandler(t,r),accountChanged:this.createSolanaAccountChangeHandler(t,r)};e.on("connect",a.connect),e.on("disconnect",a.disconnect),e.on("accountChanged",a.accountChanged);const n=[];"function"==typeof e.off&&n.push((()=>e.off("connect",a.connect)),(()=>e.off("disconnect",a.disconnect)),(()=>e.off("accountChanged",a.accountChanged)));const s=this.eventListenerCleanups.get(t)||[];this.eventListenerCleanups.set(t,[...s,...n])}setupEthereumEventListeners(e,t,r){if("function"!=typeof e.on)return;debug.log(DebugCategory.INJECTED_PROVIDER,"Setting up Ethereum event listeners",{walletId:t,source:r});const a={connect:this.createEthereumConnectHandler(t,r),disconnect:this.createEthereumDisconnectHandler(t,r),accountsChanged:this.createEthereumAccountChangeHandler(t,r)};e.on("connect",a.connect),e.on("disconnect",a.disconnect),e.on("accountsChanged",a.accountsChanged);const n=[];"function"==typeof e.off&&n.push((()=>e.off("connect",a.connect)),(()=>e.off("disconnect",a.disconnect)),(()=>e.off("accountsChanged",a.accountsChanged)));const s=this.eventListenerCleanups.get(t)||[];this.eventListenerCleanups.set(t,[...s,...n])}setupEventListeners(e){const t=this.selectedWalletId||"phantom";if(this.eventListenersSetup.has(t))debug.log(DebugCategory.INJECTED_PROVIDER,"Event listeners already set up for wallet",{walletId:t});else{for(const e of this.eventListenersSetup){if(e===t)continue;const r=this.eventListenerCleanups.get(e);r&&(debug.log(DebugCategory.INJECTED_PROVIDER,"Cleaning up event listeners for wallet",{existingWalletId:e}),r.forEach((e=>e()))),this.eventListenersSetup.delete(e)}debug.log(DebugCategory.INJECTED_PROVIDER,"Setting up event listeners",{walletId:t}),this.addressTypes.includes(import_client4.AddressType.solana)&&e.providers?.solana&&this.setupSolanaEventListeners(e.providers.solana,t,"wallet"),this.addressTypes.includes(import_client4.AddressType.ethereum)&&e.providers?.ethereum&&this.setupEthereumEventListeners(e.providers.ethereum,t,"wallet"),this.eventListenersSetup.add(t),this.eventsInitialized=!0}}},import_embedded_provider_core=require("@phantom/embedded-provider-core"),import_auth22=require("@phantom/auth2"),BrowserStorage=class{constructor(){this.dbName="phantom-browser-sdk",this.storeName="sessions",this.version=1}async getDB(){return new Promise(((e,t)=>{const r=indexedDB.open(this.dbName,this.version);r.onerror=()=>t(r.error),r.onsuccess=()=>e(r.result),r.onupgradeneeded=e=>{const t=e.target.result;t.objectStoreNames.contains(this.storeName)||t.createObjectStore(this.storeName)}}))}async getSession(){debug.log(DebugCategory.STORAGE,"Getting session from IndexedDB");const e=await this.getDB();return new Promise(((t,r)=>{const a=e.transaction([this.storeName],"readonly").objectStore(this.storeName).get("currentSession");a.onsuccess=()=>{const e=a.result||null;debug.log(DebugCategory.STORAGE,"Retrieved session from IndexedDB",{hasSession:!!e,sessionId:e?.sessionId}),t(e)},a.onerror=()=>{debug.error(DebugCategory.STORAGE,"Failed to get session from IndexedDB",{error:a.error}),r(a.error)}}))}async saveSession(e){debug.log(DebugCategory.STORAGE,"Saving session to IndexedDB",{sessionId:e.sessionId,walletId:e.walletId,status:e.status});const t=await this.getDB();return new Promise(((r,a)=>{const n=t.transaction([this.storeName],"readwrite").objectStore(this.storeName).put(e,"currentSession");n.onsuccess=()=>{debug.log(DebugCategory.STORAGE,"Successfully saved session to IndexedDB"),r()},n.onerror=()=>{debug.error(DebugCategory.STORAGE,"Failed to save session to IndexedDB",{error:n.error}),a(n.error)}}))}async clearSession(){debug.log(DebugCategory.STORAGE,"Clearing session from IndexedDB");const e=await this.getDB();return new Promise(((t,r)=>{const a=e.transaction([this.storeName],"readwrite").objectStore(this.storeName).delete("currentSession");a.onsuccess=()=>{debug.log(DebugCategory.STORAGE,"Successfully cleared session from IndexedDB"),t()},a.onerror=()=>{debug.error(DebugCategory.STORAGE,"Failed to clear session from IndexedDB",{error:a.error}),r(a.error)}}))}async getShouldClearPreviousSession(){debug.log(DebugCategory.STORAGE,"Getting shouldClearPreviousSession flag from IndexedDB");const e=await this.getDB();return new Promise(((t,r)=>{const a=e.transaction([this.storeName],"readonly").objectStore(this.storeName).get("shouldClearPreviousSession");a.onsuccess=()=>{const e=a.result??!1;debug.log(DebugCategory.STORAGE,"Retrieved shouldClearPreviousSession flag from IndexedDB",{shouldClear:e}),t(e)},a.onerror=()=>{debug.error(DebugCategory.STORAGE,"Failed to get shouldClearPreviousSession flag from IndexedDB",{error:a.error}),r(a.error)}}))}async setShouldClearPreviousSession(e){debug.log(DebugCategory.STORAGE,"Setting shouldClearPreviousSession flag in IndexedDB",{should:e});const t=await this.getDB();return new Promise(((r,a)=>{const n=t.transaction([this.storeName],"readwrite").objectStore(this.storeName).put(e,"shouldClearPreviousSession");n.onsuccess=()=>{debug.log(DebugCategory.STORAGE,"Successfully set shouldClearPreviousSession flag in IndexedDB"),r()},n.onerror=()=>{debug.error(DebugCategory.STORAGE,"Failed to set shouldClearPreviousSession flag in IndexedDB",{error:n.error}),a(n.error)}}))}},BrowserURLParamsAccessor=class{getParam(e){return new URLSearchParams(window.location.search).get(e)}},browserUrlParamsAccessor=new BrowserURLParamsAccessor,import_constants3=require("@phantom/constants");function parseBrowserFromUserAgent(e,t){let r="unknown",a="unknown";if(!e||"string"!=typeof e)return{name:r,version:a,userAgent:"unknown"};try{if(e.includes("Edg/")){r="edge";const t=e.match(/Edg\/([0-9]+(?:\.[0-9]+)*)/);t&&(a=t[1].split(".")[0])}else if(e.includes("OPR/")||e.includes("Opera/")){r="opera";const t=e.match(/(?:OPR|Opera)\/([0-9]+(?:\.[0-9]+)*)/);t&&(a=t[1].split(".")[0])}else if(e.includes("SamsungBrowser/")){r="samsung";const t=e.match(/SamsungBrowser\/([0-9]+(?:\.[0-9]+)*)/);t&&(a=t[1].split(".")[0])}else if(e.includes("DuckDuckGo/")){r="duckduckgo";const t=e.match(/DuckDuckGo\/([0-9]+(?:\.[0-9]+)*)/);t&&(a=t[1].split(".")[0])}else if(e.includes("Chrome/")&&t){r="brave";const t=e.match(/Chrome\/([0-9]+(?:\.[0-9]+)*)/);t&&(a=t[1].split(".")[0])}else if(e.includes("Mobile/")||e.includes("Android"))if(e.includes("Chrome/")){r="chrome-mobile";const t=e.match(/Chrome\/([0-9]+(?:\.[0-9]+)*)/);t&&(a=t[1].split(".")[0])}else if(e.includes("Firefox/")){r="firefox-mobile";const t=e.match(/Firefox\/([0-9]+(?:\.[0-9]+)*)/);t&&(a=t[1].split(".")[0])}else if(e.includes("Safari/")&&e.includes("Mobile/")){r="safari-mobile";const t=e.match(/Version\/([0-9]+(?:\.[0-9]+)*)/);t&&(a=t[1].split(".")[0])}else r="mobile";else if(e.includes("Chrome/")){r="chrome";const t=e.match(/Chrome\/([0-9]+(?:\.[0-9]+)*)/);t&&(a=t[1].split(".")[0])}else if(e.includes("Firefox/")){r="firefox";const t=e.match(/Firefox\/([0-9]+(?:\.[0-9]+)*)/);t&&(a=t[1].split(".")[0])}else if(e.includes("Safari/")&&!e.includes("Chrome/")){r="safari";const t=e.match(/Version\/([0-9]+(?:\.[0-9]+)*)/);t&&(a=t[1].split(".")[0])}if("unknown"===r){const t=[{regex:/Chrome\/([0-9]+)/,name:"chrome"},{regex:/Firefox\/([0-9]+)/,name:"firefox"},{regex:/Safari\/([0-9]+)/,name:"safari"},{regex:/Edge\/([0-9]+)/,name:"edge"},{regex:/Opera\/([0-9]+)/,name:"opera"}];for(const n of t){const t=e.match(n.regex);if(t){r=n.name,a=t[1];break}}}}catch(e){}return{name:r,version:a,userAgent:e}}function detectBrowser(){if("undefined"==typeof window||!window.navigator?.userAgent)return{name:"unknown",version:"unknown",userAgent:"unknown"};return parseBrowserFromUserAgent(window.navigator.userAgent,!!navigator.brave)}function getPlatformName(){const{name:e,version:t}=detectBrowser();return"unknown"!==t?`${e}-v${t}`:e}function getBrowserDisplayName(){const{name:e,version:t}=detectBrowser(),r=e.charAt(0).toUpperCase()+e.slice(1);return"unknown"!==t?`${r} ${t}`:r}function isMobileDevice(){if("undefined"==typeof window||!window.navigator?.userAgent)return!1;const e=window.navigator.userAgent.toLowerCase(),t=[/android/,/iphone|ipad|ipod/,/blackberry/,/windows phone/,/mobile/,/tablet/,/silk/,/kindle/,/opera mini/,/opera mobi/].some((t=>t.test(e)));let r=!1;try{r=window.screen.width<=768||window.screen.height<=768}catch(e){r=!1}let a=!1;try{a="ontouchstart"in window||navigator.maxTouchPoints>0}catch(e){a=!1}return t||r&&a}var import_auth2=require("@phantom/auth2"),Auth2AuthProvider=class{constructor(e,t,r,a,n){this.stamper=e,this.storage=t,this.urlParamsAccessor=r,this.auth2ProviderOptions=a,this.kms=new import_auth2.Auth2KmsRpcClient(e,n)}static navigate(e){window.location.href=e}async authenticate(e){const t=await this.storage.getSession();if(!t)throw new Error("Session not found.");const{url:r,codeVerifier:a}=await(0,import_auth2.prepareAuth2Flow)({stamper:this.stamper,auth2Options:this.auth2ProviderOptions,sessionId:e.sessionId,provider:e.provider});await this.storage.saveSession({...t,pkceCodeVerifier:a}),Auth2AuthProvider.navigate(r)}async resumeAuthFromRedirect(e){if(!this.urlParamsAccessor.getParam("code"))return null;this.stamper.getKeyInfo()||await this.stamper.init();const t=await this.storage.getSession();if(!t)throw new Error("Session not found.");const r=t?.pkceCodeVerifier;if(!r)return null;const a=(0,import_auth2.validateAuth2Callback)({getParam:e=>this.urlParamsAccessor.getParam(e),expectedSessionId:t.sessionId}),n=await(0,import_auth2.completeAuth2Exchange)({stamper:this.stamper,kms:this.kms,auth2Options:this.auth2ProviderOptions,code:a,codeVerifier:r,provider:e});return await this.storage.saveSession({...t,status:"completed",bearerToken:n.bearerToken,authUserId:n.authUserId,pkceCodeVerifier:void 0}),n}},STORE_NAME="crypto-keys",ACTIVE_KEY="auth2-p256-signing-key",IndexedDBAuth2StamperStorage=class{constructor(e){this.dbName=e,this.db=null,this.requiresExtractableKeys=!1}async open(){return new Promise(((e,t)=>{const r=indexedDB.open(this.dbName,1);r.onsuccess=()=>{this.db=r.result,e()},r.onerror=()=>t(r.error),r.onupgradeneeded=e=>{const t=e.target.result;t.objectStoreNames.contains(STORE_NAME)||t.createObjectStore(STORE_NAME)}}))}async load(){return new Promise(((e,t)=>{if(!this.db)throw new Error("Database not initialized");const r=this.db.transaction([STORE_NAME],"readonly").objectStore(STORE_NAME).get(ACTIVE_KEY);r.onsuccess=()=>{e(r.result??null)},r.onerror=()=>{t(r.error)}}))}async save(e){return new Promise(((t,r)=>{if(!this.db)throw new Error("Database not initialized");const a=this.db.transaction([STORE_NAME],"readwrite").objectStore(STORE_NAME).put(e,ACTIVE_KEY);a.onsuccess=()=>{t()},a.onerror=()=>{r(a.error)}}))}async clear(){return new Promise(((e,t)=>{if(!this.db)throw new Error("Database not initialized");const r=this.db.transaction([STORE_NAME],"readwrite").objectStore(STORE_NAME).delete(ACTIVE_KEY);r.onsuccess=()=>{e()},r.onerror=()=>{t(r.error)}}))}},import_browser_injected_sdk4=require("@phantom/browser-injected-sdk"),import_browser_injected_sdk3=require("@phantom/browser-injected-sdk");async function waitForPhantomExtension(e=3e3){return new Promise((t=>{const r=Date.now(),a=()=>{try{if((0,import_browser_injected_sdk3.isPhantomExtensionInstalled)())return void t(!0)}catch(e){}Date.now()-r>=e?t(!1):setTimeout(a,100)};a()}))}async function isPhantomLoginAvailable(e=3e3){if(!await waitForPhantomExtension(e))return!1;try{if(!window.phantom?.app?.features||"function"!=typeof window.phantom.app.features)return!1;const e=await window.phantom.app.features();return!!Array.isArray(e.features)&&e.features.includes("phantom_login")}catch(e){return console.error("Error checking Phantom extension features",e),!1}}var BrowserPhantomAppProvider=class{isAvailable(){return(0,import_browser_injected_sdk4.isPhantomExtensionInstalled)()}async authenticate(e){if(!this.isAvailable())throw new Error("Phantom extension is not installed. Please install the Phantom browser extension to use this authentication method.");if(!await isPhantomLoginAvailable())throw new Error("Phantom Login is not available. Please update your Phantom extension to use this authentication method.");try{if(!window.phantom?.app?.login)throw new Error("Phantom extension login method not found");const t=await window.phantom.app.login({publicKey:e.publicKey,appId:e.appId,sessionId:e.sessionId});if(!t||!t.walletId||!t.organizationId)throw new Error("Invalid authentication response from Phantom extension");return{walletId:t.walletId,organizationId:t.organizationId,provider:"phantom",accountDerivationIndex:t.accountDerivationIndex??0,expiresInMs:t.expiresInMs??0,authUserId:t.authUserId}}catch(e){if(e instanceof Error)throw e;throw new Error(`Phantom extension authentication failed: ${String(e)}`)}}},BrowserLogger=class{info(e,...t){debug.info(e,t.length>0?String(t[0]):"",t[1])}warn(e,...t){debug.warn(e,t.length>0?String(t[0]):"",t[1])}error(e,...t){debug.error(e,t.length>0?String(t[0]):"",t[1])}debug(e,...t){debug.log(e,t.length>0?String(t[0]):"",t[1])}},import_constants4=require("@phantom/constants"),EmbeddedProvider=class extends import_embedded_provider_core.EmbeddedProvider{constructor(e){debug.log(DebugCategory.EMBEDDED_PROVIDER,"Initializing Browser EmbeddedProvider",{config:e});const t=new BrowserURLParamsAccessor,r=new BrowserStorage,a=new import_auth22.Auth2Stamper(new IndexedDBAuth2StamperStorage(`phantom-auth2-${e.appId}`),{authApiBaseUrl:e.authOptions.authApiBaseUrl,clientId:e.appId,redirectUri:e.authOptions.redirectUrl}),n=getPlatformName(),{name:s,version:o}=detectBrowser(),i={storage:r,authProvider:new Auth2AuthProvider(a,r,t,{redirectUri:e.authOptions.redirectUrl,connectLoginUrl:e.authOptions.authUrl,clientId:e.appId,authApiBaseUrl:e.authOptions.authApiBaseUrl},{apiBaseUrl:e.apiBaseUrl,appId:e.appId}),phantomAppProvider:new BrowserPhantomAppProvider,urlParamsAccessor:t,stamper:a,name:n,analyticsHeaders:{[import_constants4.ANALYTICS_HEADERS.SDK_TYPE]:"browser",[import_constants4.ANALYTICS_HEADERS.PLATFORM]:"ext-sdk",[import_constants4.ANALYTICS_HEADERS.PLATFORM_VERSION]:o,[import_constants4.ANALYTICS_HEADERS.CLIENT]:s,[import_constants4.ANALYTICS_HEADERS.APP_ID]:e.appId,[import_constants4.ANALYTICS_HEADERS.WALLET_TYPE]:e.embeddedWalletType,[import_constants4.ANALYTICS_HEADERS.SDK_VERSION]:"2.0.1"}};debug.log(DebugCategory.EMBEDDED_PROVIDER,"Detected platform",{platformName:n});super(e,i,new BrowserLogger),this.addressTypes=e.addressTypes,debug.info(DebugCategory.EMBEDDED_PROVIDER,"Browser EmbeddedProvider initialized")}getEnabledAddressTypes(){return this.addressTypes}},import_embedded_provider_core2=require("@phantom/embedded-provider-core"),import_constants5=require("@phantom/constants");function isAuthFailureCallback(e){if("undefined"==typeof window&&!e)return!1;const t=e||new URLSearchParams(window.location.search),r=t.get("response_type"),a=t.get("session_id");return"failure"===r&&!!a}function isAuthCallbackUrl(e){if("undefined"==typeof window&&!e)return!1;const t=e||new URLSearchParams(window.location.search);return!(!t.get("session_id")||!t.has("response_type")&&!t.has("wallet_id"))}function getDeeplinkToPhantom(e,t){const r=t??window.location.href;if(!r.startsWith("http:")&&!r.startsWith("https:"))throw new Error("Invalid URL protocol - only HTTP/HTTPS URLs are supported for deeplinks");return`https://phantom.app/ul/browse/${encodeURIComponent(r)}${e?`?ref=${encodeURIComponent(e)}`:""}`}var ProviderManager=class{constructor(e){this.providers=new Map,this.currentProvider=null,this.currentProviderKey=null,this.eventListeners=new Map,this.providerForwardingSetup=new WeakSet,debug.log(DebugCategory.PROVIDER_MANAGER,"Initializing ProviderManager",{config:e}),this.config=e,debug.log(DebugCategory.PROVIDER_MANAGER,"Setting default provider"),this.setDefaultProvider(),debug.info(DebugCategory.PROVIDER_MANAGER,"ProviderManager initialized",{currentProviderKey:this.currentProviderKey})}getValidatedCurrentUrl(){if("undefined"==typeof window)return"";const e=window.location.href;if(!e.startsWith("http:")&&!e.startsWith("https:"))throw new Error("Invalid URL protocol - only HTTP/HTTPS URLs are supported");return e}switchProvider(e,t){if(t?.embeddedWalletType&&!["app-wallet","user-wallet"].includes(t.embeddedWalletType))throw new Error(`Invalid embeddedWalletType: ${t.embeddedWalletType}. Must be "app-wallet" or "user-wallet".`);const r=this.getProviderKey(e,t?.embeddedWalletType);return this.providers.has(r)||this.createProvider(e,t?.embeddedWalletType),this.currentProvider=this.providers.get(r),this.currentProviderKey=r,this.ensureProviderEventForwarding(),this.currentProvider}getCurrentProvider(){return this.currentProvider}getCurrentProviderInfo(){if(!this.currentProviderKey)return null;const e=this.currentProviderKey.split("-"),[t,r]=e;return{type:t,embeddedWalletType:r}}isProviderAllowed(e){return this.config.providers.includes(e)}async connect(e){if(debug.info(DebugCategory.PROVIDER_MANAGER,"Starting connection",{currentProviderKey:this.currentProviderKey,authOptions:{provider:e.provider}}),!this.isProviderAllowed(e.provider)){const t=`Provider "${e.provider}" is not in the allowed providers list: ${JSON.stringify(this.config.providers)}`;throw debug.error(DebugCategory.PROVIDER_MANAGER,t),new Error(t)}const t=e.provider;let r=null;if("injected"===t)r="injected";else if("deeplink"===t)try{const e=getDeeplinkToPhantom();if("undefined"!=typeof window&&window.location)try{window.location.href=e}catch(e){debug.warn(DebugCategory.PROVIDER_MANAGER,"Failed to set deeplink location",{error:e instanceof Error?e.message:String(e)})}return{addresses:[],walletId:void 0,authUserId:void 0}}catch(e){const t=e instanceof Error?e.message:"Failed to open deeplink";throw debug.error(DebugCategory.PROVIDER_MANAGER,"Deeplink error",{error:t}),new Error(`Failed to open deeplink: ${t}`)}else import_embedded_provider_core2.EMBEDDED_PROVIDER_AUTH_TYPES.includes(t)&&(r="embedded");if(r){const e=this.getCurrentProviderInfo();if(e?.type!==r){debug.log(DebugCategory.PROVIDER_MANAGER,"Auto-switching provider based on auth options",{from:e?.type,to:r,requestedProvider:t});const a={};"embedded"===r&&(a.embeddedWalletType=e?.embeddedWalletType||this.config.embeddedWalletType),this.switchProvider(r,a)}}if(!this.currentProvider)throw debug.error(DebugCategory.PROVIDER_MANAGER,"No provider selected"),new Error("No provider selected");debug.log(DebugCategory.PROVIDER_MANAGER,"Delegating to provider connect method");const a=await this.currentProvider.connect(e);return debug.log(DebugCategory.PROVIDER_MANAGER,"Connection successful, saving preferences",{addressCount:a.addresses?.length||0,provider:e.provider}),this.saveProviderPreference(),debug.info(DebugCategory.PROVIDER_MANAGER,"Connect completed",{addresses:a.addresses,provider:e.provider}),a}async disconnect(){this.currentProvider&&await this.currentProvider.disconnect()}getAddresses(){return this.currentProvider?this.currentProvider.getAddresses():[]}isConnected(){return this.currentProvider?.isConnected()??!1}async autoConnect(){if(debug.log(DebugCategory.PROVIDER_MANAGER,"Starting auto-connect with fallback strategy"),isAuthFailureCallback())return debug.warn(DebugCategory.PROVIDER_MANAGER,"Auth failure detected in URL, skipping autoConnect fallback"),!1;const e=this.config.embeddedWalletType||"user-wallet",t=this.getProviderKey("embedded",e);if(this.config.providers.some((e=>"injected"!==e))&&this.providers.has(t)){debug.log(DebugCategory.PROVIDER_MANAGER,"Trying auto-connect with existing embedded provider");const e=this.providers.get(t);try{const r=this.currentProvider,a=this.currentProviderKey;if(this.currentProvider=e,this.currentProviderKey=t,this.ensureProviderEventForwarding(),await e.autoConnect(),e.isConnected())return debug.info(DebugCategory.PROVIDER_MANAGER,"Embedded auto-connect successful"),this.saveProviderPreference(),!0;debug.log(DebugCategory.PROVIDER_MANAGER,"Embedded provider did not connect, restoring previous provider"),this.currentProvider=r,this.currentProviderKey=a}catch(e){if(debug.log(DebugCategory.PROVIDER_MANAGER,"Embedded auto-connect failed",{error:e.message}),isAuthCallbackUrl())return debug.log(DebugCategory.PROVIDER_MANAGER,"In auth callback URL, not attempting injected fallback"),!1}}const r=this.config.providers.includes("injected"),a=this.getProviderKey("injected");if(r&&this.providers.has(a)){debug.log(DebugCategory.PROVIDER_MANAGER,"Trying auto-connect with existing injected provider");const e=this.providers.get(a);try{if(this.currentProvider=e,this.currentProviderKey=a,this.ensureProviderEventForwarding(),await e.autoConnect(),e.isConnected())return debug.info(DebugCategory.PROVIDER_MANAGER,"Injected auto-connect successful"),this.saveProviderPreference(),!0}catch(e){debug.log(DebugCategory.PROVIDER_MANAGER,"Injected auto-connect failed",{error:e.message})}}return debug.log(DebugCategory.PROVIDER_MANAGER,"Auto-connect failed for all allowed providers"),!1}on(e,t){debug.log(DebugCategory.PROVIDER_MANAGER,"Adding event listener",{event:e}),this.eventListeners.has(e)||this.eventListeners.set(e,new Set),this.eventListeners.get(e)?.add(t),this.ensureProviderEventForwarding()}off(e,t){debug.log(DebugCategory.PROVIDER_MANAGER,"Removing event listener",{event:e}),this.eventListeners.has(e)&&(this.eventListeners.get(e)?.delete(t),0===this.eventListeners.get(e)?.size&&this.eventListeners.delete(e))}emit(e,t){debug.log(DebugCategory.PROVIDER_MANAGER,"Emitting event to stored callbacks",{event:e,listenerCount:this.eventListeners.get(e)?.size||0,data:t});const r=this.eventListeners.get(e);r&&r.size>0?r.forEach((r=>{try{debug.log(DebugCategory.PROVIDER_MANAGER,"Calling stored callback for event",{event:e}),r(t)}catch(t){debug.error(DebugCategory.PROVIDER_MANAGER,"Event callback error",{event:e,error:t})}})):debug.warn(DebugCategory.PROVIDER_MANAGER,"No stored callbacks for event",{event:e})}ensureProviderEventForwarding(){if(!this.currentProvider||!("on"in this.currentProvider))return void debug.warn(DebugCategory.PROVIDER_MANAGER,"Current provider does not support events",{providerType:this.getCurrentProviderInfo()?.type});if(this.providerForwardingSetup.has(this.currentProvider))return void debug.log(DebugCategory.PROVIDER_MANAGER,"Event forwarding already set up for current provider");debug.log(DebugCategory.PROVIDER_MANAGER,"Setting up event forwarding from current provider");const e=["connect_start","connect","connect_error","disconnect","error","spending_limit_reached"];for(const t of e){const e=e=>{debug.log(DebugCategory.PROVIDER_MANAGER,"Forwarding event from provider",{event:t,data:e}),this.emit(t,e)};debug.log(DebugCategory.PROVIDER_MANAGER,"Attaching forwarding callback for event",{event:t}),this.currentProvider.on(t,e)}this.providerForwardingSetup.add(this.currentProvider)}setDefaultProvider(){const e=this.config.embeddedWalletType||"user-wallet",t=this.config.providers.includes("injected"),r=this.config.providers.some((e=>"injected"!==e&&"deeplink"!==e));let a;if(t&&(debug.log(DebugCategory.PROVIDER_MANAGER,"Creating injected provider (allowed by providers array)"),this.createProvider("injected")),r&&(debug.log(DebugCategory.PROVIDER_MANAGER,"Creating embedded provider (allowed by providers array)"),this.createProvider("embedded",e)),r&&this.providers.has(`embedded-${e}`))a="embedded";else{if(!t||!this.providers.has("injected"))throw new Error("No valid providers could be created from the providers array");a="injected"}const n={};"embedded"===a&&(n.embeddedWalletType=e),this.switchProvider(a,n)}createProvider(e,t){const r=this.getProviderKey(e,t);if(this.providers.has(r))return;let a;if("injected"===e)a=new InjectedProvider({addressTypes:this.config.addressTypes||[import_client.AddressType.solana]});else{if("embedded"!==e)throw new Error(`Unsupported provider type: ${e}`);{if(!this.config.appId)throw new Error("appId is required for embedded provider");const e=this.config.apiBaseUrl||import_constants5.DEFAULT_WALLET_API_URL,r=this.config.authOptions?.authUrl||import_constants5.DEFAULT_AUTH_URL,n=this.config.authOptions?.authApiBaseUrl||import_constants5.DEFAULT_AUTH_API_BASE_URL;a=new EmbeddedProvider({apiBaseUrl:e,appId:this.config.appId,authOptions:{...this.config.authOptions||{},authUrl:r,redirectUrl:this.config.authOptions?.redirectUrl||this.getValidatedCurrentUrl(),authApiBaseUrl:n},embeddedWalletType:t||import_constants5.DEFAULT_EMBEDDED_WALLET_TYPE,addressTypes:this.config.addressTypes||[import_client.AddressType.solana]})}}this.providers.set(r,a)}getProviderKey(e,t){if("injected"===e)return"injected";if("embedded"===e)return`embedded-${t||"app-wallet"}`;throw new Error(`Unsupported provider type: ${e}`)}saveProviderPreference(){try{const e=this.getCurrentProviderInfo();e&&localStorage.setItem("phantom-provider-preference",JSON.stringify(e))}catch(e){console.error("Failed to save provider preference:",e)}}},import_embedded_provider_core3=require("@phantom/embedded-provider-core"),import_constants6=require("@phantom/constants"),BROWSER_SDK_PROVIDER_TYPES=[...import_embedded_provider_core3.EMBEDDED_PROVIDER_AUTH_TYPES,"injected","deeplink"],BrowserSDK=class{constructor(e){if(this.walletRegistry=getWalletRegistry(),this.isLoading=!0,debug.info(DebugCategory.BROWSER_SDK,"Initializing BrowserSDK",{providers:e.providers,embeddedWalletType:e.embeddedWalletType,addressTypes:e.addressTypes}),!Array.isArray(e.providers)||0===e.providers.length)throw debug.error(DebugCategory.BROWSER_SDK,"Invalid providers array",{providers:e.providers}),new Error("providers must be a non-empty array of AuthProviderType");const t=e.providers.filter((e=>!BROWSER_SDK_PROVIDER_TYPES.includes(e)));if(t.length>0)throw debug.error(DebugCategory.BROWSER_SDK,"Invalid provider types",{invalidProviders:t,validProviders:BROWSER_SDK_PROVIDER_TYPES}),new Error(`Invalid provider type(s): ${t.join(", ")}. Valid providers are: ${BROWSER_SDK_PROVIDER_TYPES.join(", ")}`);if(e.providers.some((e=>"injected"!==e))&&!e.appId)throw debug.error(DebugCategory.BROWSER_SDK,"appId required for embedded providers",{providers:e.providers}),new Error("appId is required when using embedded providers (google, apple, phantom, etc.)");const r=e.embeddedWalletType||import_constants6.DEFAULT_EMBEDDED_WALLET_TYPE;if(!["app-wallet","user-wallet"].includes(r))throw debug.error(DebugCategory.BROWSER_SDK,"Invalid embeddedWalletType",{embeddedWalletType:e.embeddedWalletType}),new Error(`Invalid embeddedWalletType: ${e.embeddedWalletType}. Must be "app-wallet" or "user-wallet".`);this.config=e,this.providerManager=new ProviderManager(e),this.discoverWallets()}discoverWallets(){return this.walletRegistry.discover(this.config.addressTypes).finally((()=>{this.isLoading=!1}))}get solana(){const e=this.providerManager.getCurrentProvider();if(!e)throw new Error("No provider available. Call connect() first.");return e.solana}get ethereum(){const e=this.providerManager.getCurrentProvider();if(!e)throw new Error("No provider available. Call connect() first.");return e.ethereum}async connect(e){debug.info(DebugCategory.BROWSER_SDK,"Starting connection",e);try{const t=await this.providerManager.connect(e);return debug.info(DebugCategory.BROWSER_SDK,"Connection successful",{addressCount:t.addresses.length,status:t.status}),t}catch(e){throw debug.error(DebugCategory.BROWSER_SDK,"Connection failed",{error:e.message}),e}}async disconnect(){debug.info(DebugCategory.BROWSER_SDK,"Disconnecting");try{await this.providerManager.disconnect(),debug.info(DebugCategory.BROWSER_SDK,"Disconnection successful")}catch(e){throw debug.error(DebugCategory.BROWSER_SDK,"Disconnection failed",{error:e.message}),e}}isConnected(){return this.providerManager.isConnected()}getAddresses(){return this.providerManager.getAddresses()}getCurrentProviderInfo(){return this.providerManager.getCurrentProviderInfo()}getEnabledAddressTypes(){const e=this.providerManager.getCurrentProvider();return e?e.getEnabledAddressTypes():[]}on(e,t){debug.log(DebugCategory.BROWSER_SDK,"Adding event listener",{event:e}),this.providerManager.on(e,t)}off(e,t){debug.log(DebugCategory.BROWSER_SDK,"Removing event listener",{event:e}),this.providerManager.off(e,t)}async autoConnect(){debug.log(DebugCategory.BROWSER_SDK,"Attempting auto-connect with fallback strategy"),await this.discoverWallets();await this.providerManager.autoConnect()?debug.info(DebugCategory.BROWSER_SDK,"Auto-connect successful",{providerType:this.getCurrentProviderInfo()?.type}):debug.log(DebugCategory.BROWSER_SDK,"Auto-connect failed for all providers")}enableDebug(){debug.enable(),debug.info(DebugCategory.BROWSER_SDK,"Debug logging enabled")}disableDebug(){debug.disable()}setDebugLevel(e){debug.setLevel(e),debug.info(DebugCategory.BROWSER_SDK,"Debug level updated",{level:e})}setDebugCallback(e){debug.setCallback(e),debug.info(DebugCategory.BROWSER_SDK,"Debug callback updated")}configureDebug(e){void 0!==e.enabled&&(e.enabled?this.enableDebug():this.disableDebug()),void 0!==e.level&&this.setDebugLevel(e.level),void 0!==e.callback&&this.setDebugCallback(e.callback)}async enableAutoConfirm(e){debug.info(DebugCategory.BROWSER_SDK,"Enabling auto-confirm",{params:e});const t=this.providerManager.getCurrentProvider();if(!t)throw new Error("No provider available. Call connect() first.");if(!("enableAutoConfirm"in t))throw new Error("Auto-confirm is only available for injected providers");try{const r=await t.enableAutoConfirm(e);return debug.info(DebugCategory.BROWSER_SDK,"Auto-confirm enabled successfully",{result:r}),r}catch(e){throw debug.error(DebugCategory.BROWSER_SDK,"Failed to enable auto-confirm",{error:e.message}),e}}async disableAutoConfirm(){debug.info(DebugCategory.BROWSER_SDK,"Disabling auto-confirm");const e=this.providerManager.getCurrentProvider();if(!e)throw new Error("No provider available. Call connect() first.");if(!("disableAutoConfirm"in e))throw new Error("Auto-confirm is only available for injected providers");try{await e.disableAutoConfirm(),debug.info(DebugCategory.BROWSER_SDK,"Auto-confirm disabled successfully")}catch(e){throw debug.error(DebugCategory.BROWSER_SDK,"Failed to disable auto-confirm",{error:e.message}),e}}async getAutoConfirmStatus(){debug.info(DebugCategory.BROWSER_SDK,"Getting auto-confirm status");const e=this.providerManager.getCurrentProvider();if(!e)throw new Error("No provider available. Call connect() first.");if(!("getAutoConfirmStatus"in e))throw new Error("Auto-confirm is only available for injected providers");try{const t=await e.getAutoConfirmStatus();return debug.info(DebugCategory.BROWSER_SDK,"Got auto-confirm status",{result:t}),t}catch(e){throw debug.error(DebugCategory.BROWSER_SDK,"Failed to get auto-confirm status",{error:e.message}),e}}async getSupportedAutoConfirmChains(){debug.info(DebugCategory.BROWSER_SDK,"Getting supported auto-confirm chains");const e=this.providerManager.getCurrentProvider();if(!e)throw new Error("No provider available. Call connect() first.");if(!("getSupportedAutoConfirmChains"in e))throw new Error("Auto-confirm is only available for injected providers");try{const t=await e.getSupportedAutoConfirmChains();return debug.info(DebugCategory.BROWSER_SDK,"Got supported auto-confirm chains",{result:t}),t}catch(e){throw debug.error(DebugCategory.BROWSER_SDK,"Failed to get supported auto-confirm chains",{error:e.message}),e}}getDiscoveredWallets(){debug.log(DebugCategory.BROWSER_SDK,"Getting discovered wallets");try{const e=this.walletRegistry.getByAddressTypes(this.config.addressTypes);return debug.log(DebugCategory.BROWSER_SDK,"Retrieved discovered wallets",{count:e.length,walletIds:e.map((e=>e.id))}),e}catch(e){return debug.error(DebugCategory.BROWSER_SDK,"Failed to get discovered wallets",{error:e.message}),[]}}},import_constants7=require("@phantom/constants"),import_client5=require("@phantom/client"),import_base64url=require("@phantom/base64url"),import_constants8=require("@phantom/constants");
//# sourceMappingURL=/sm/20d4718f7cc22aa2aea87b1fc558776e6148414f32f95d4cdf3f9395a432ec12.map