@idosgames/wallet 0.6.2 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{bridge-C5z9TgKG.d.cts → bridge-BAyA43hM.d.cts} +1 -1
- package/dist/{bridge-BPZNXQuQ.d.ts → bridge-BsVqE7-T.d.ts} +1 -1
- package/dist/chunk-B4KT5CVC.js +1 -0
- package/dist/chunk-DOWG5IDM.js +1 -0
- package/dist/chunk-NU3WMVH2.js +2 -0
- package/dist/chunk-ZOWZE7MU.js +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/{platformWalletLogin-Ysdf-Tt8.d.cts → platformWalletLogin-BBBBN68y.d.cts} +1 -1
- package/dist/{platformWalletLogin-DNC2Ajle.d.ts → platformWalletLogin-BxAoMCd9.d.ts} +1 -1
- package/dist/react/index.cjs +2 -2
- package/dist/react/index.d.cts +8 -1
- package/dist/react/index.d.ts +8 -1
- package/dist/react/index.js +1 -1
- package/dist/react/lazyIndex.cjs +2 -2
- package/dist/react/lazyIndex.d.cts +9 -2
- package/dist/react/lazyIndex.d.ts +9 -2
- package/dist/react/lazyIndex.js +1 -1
- package/dist/react/solanaIndex.cjs +2 -2
- package/dist/react/solanaIndex.d.cts +9 -3
- package/dist/react/solanaIndex.d.ts +9 -3
- package/dist/react/solanaIndex.js +1 -1
- package/dist/topUp-CCNQcHcH.d.cts +18 -0
- package/dist/topUp-CCNQcHcH.d.ts +18 -0
- package/package.json +2 -2
- package/dist/chunk-D2ZPJ33L.js +0 -1
- package/dist/chunk-XJV2C5QX.js +0 -1
package/dist/react/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {p as p$1,o as o$1,j
|
|
1
|
+
import {p as p$1,o as o$1,j,h,q as q$2,r as r$1,b as b$3}from'../chunk-YTTVLBAW.js';export{a as useWalletTopUp}from'../chunk-DOWG5IDM.js';import {a,c as c$1,b as b$2}from'../chunk-NU3WMVH2.js';import'../chunk-ZOWZE7MU.js';import {k as k$1,l,m,n,o,p,q as q$1,r,u,b as b$1,c}from'../chunk-K3THMWU2.js';export{o as arbitrum,n as base,l as bsc,t as chainById,s as idosChains,k as mainnet,p as optimism,m as polygon,r as polygonAmoy,q as sepolia}from'../chunk-K3THMWU2.js';import {http,createConfig,WagmiProvider,useAccount,usePublicClient,useWalletClient,useConfig,useConnect,useDisconnect,useSwitchChain}from'wagmi';import {injected,coinbaseWallet}from'wagmi/connectors';import {WagmiAdapter}from'@reown/appkit-adapter-wagmi';import {createAppKit}from'@reown/appkit/react';import {QueryClient,QueryClientProvider}from'@tanstack/react-query';import {useState,useRef,useEffect,useMemo}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {getAccount,getPublicClient,watchAccount,getWalletClient}from'wagmi/actions';import {authErrorText}from'@idosgames/core';import {parseUnits}from'viem';var se=[k$1,l,m,n,o,p,q$1,r],q=new Map;function O(e){let{chains:n=se,walletConnectProjectId:t,appName:o,appUrl:r,appIcon:i,transports:m,connectors:s}=e,c=t??"__extension_only__";if(!s){let p=q.get(c);if(p)return p}let f={};for(let p of n)f[p.id]=m?.[p.id]??http();let l=r??(typeof window<"u"?window.location.origin:""),w={name:o??"iDosGames",description:o??"iDosGames game",url:l,icons:i?[i]:[]};if(t&&!s){let p=n.map(u),a$1=new WagmiAdapter({networks:p,projectId:t,transports:f});return a(createAppKit({adapters:[a$1],networks:p,projectId:t,metadata:w,features:{analytics:false,email:false,socials:false}})),q.set(c,a$1.wagmiConfig),a$1.wagmiConfig}let C=s??[injected(),coinbaseWallet({appName:o??"iDosGames"})],v=createConfig({chains:n,connectors:C,transports:f});return s||q.set(c,v),v}function b(e){let{wagmiConfig:n,queryClient:t,children:o}=e,[r]=useState(()=>t??new QueryClient);return jsx(WagmiProvider,{config:n,children:jsx(QueryClientProvider,{client:r,children:o})})}function N(){let{address:e}=useAccount(),n=usePublicClient(),{data:t}=useWalletClient();return !e||!n||!t?null:{account:e,publicClient:n,walletClient:t}}var k="Wallet not connected.";function K(e,n){let t=N();return {connected:!!t,account:t?.account??null,loginWithWallet:(o,r)=>t?q$2({client:e,clients:t,networkID:o,walletAddress:r}):Promise.resolve(c("challenge",k)),depositToken:o=>t?h({client:e,clients:t,titleID:n,...o}):Promise.resolve(b$1("approve",k)),depositNft:o=>t?j({client:e,clients:t,titleID:n,...o}):Promise.resolve(b$1("deposit-onchain",k)),withdrawToken:o=>t?o$1({client:e,clients:t,...o}):Promise.resolve(b$1("withdraw-onchain",k)),withdrawNft:o=>t?p$1({client:e,clients:t,...o}):Promise.resolve(b$1("withdraw-onchain",k))}}function je(e){let{wagmiConfig:n,...t}=e;return jsx(b,{wagmiConfig:n,children:jsx(ge,{...t})})}function qe(e){return e instanceof Error&&(e.name==="ConnectorAlreadyConnectedError"||e.message.includes("already connected"))}function Oe(e){let n="Wallet sign-in failed. Please try again.";return e instanceof Error?e.name==="ProviderNotFoundError"||/provider not found/i.test(e.message)?"No crypto wallet found in this browser. Install a wallet extension (e.g. MetaMask) or open this page in your wallet's browser, then try again.":e.name==="UserRejectedRequestError"||/user (rejected|denied|cancelled|canceled)/i.test(e.message)?"Request declined in the wallet.":/timed? ?out/i.test(e.message)?"The wallet did not respond. Open your wallet and try again.":n:n}async function de(e){let n=await getWalletClient(e).catch(()=>null);if(!n)return null;let t=getPublicClient(e);return t?{account:n.account.address,publicClient:t,walletClient:n}:null}function Ke(e,n=18e4){return getAccount(e).isConnected?Promise.resolve(true):new Promise(t=>{let o=false,r=s=>{o||(o=true,i(),clearTimeout(m),t(s));},i=watchAccount(e,{onChange:s=>{s.isConnected&&r(true);}}),m=setTimeout(()=>r(false),n);})}function Me(e,n=8e3){let t=o=>o==="reconnecting"||o==="connecting";return t(getAccount(e).status)?new Promise(o=>{let r=false,i=()=>{r||(r=true,m(),clearTimeout(s),o());},m=watchAccount(e,{onChange:c=>{t(c.status)||i();}}),s=setTimeout(i,n);}):Promise.resolve()}function Qe(e){let n=r=>e.find(i=>i.id===r||i.type===r),t=n("injected"),o=typeof window<"u"&&window.ethereum!=null;return t&&o?t:n("walletConnect")??t??e[0]}var ue=9e4;async function Ve(e){try{let o=(await getAccount(e).connector?.getProvider?.())?.session?.peer?.metadata?.redirect,r=o?.native||o?.universal;return !r||typeof window>"u"?!1:(window.location.href=r,!0)}catch{return false}}function me(e,n){return new Promise((t,o)=>{let r=setTimeout(()=>o(new Error("The wallet request timed out.")),n);e.then(i=>{clearTimeout(r),t(i);},i=>{clearTimeout(r),o(i instanceof Error?i:new Error(String(i)));});})}function ge(e){let{client:n,networkID:t,onAuthenticated:o,disabled:r,label:i,style:m,autoStart:s,mode:c="login",onLinked:f}=e,l=useConfig(),{isConnected:w}=useAccount(),{connectAsync:C,connectors:v}=useConnect(),p=N(),[a,y]=useState(false),[P,d]=useState(null),[E,T]=useState(false),V=useRef(0),$=useRef(false),z=async()=>{let Ce=++V.current,W=()=>V.current===Ce;y(true),d(null);try{if(await Me(l),!W())return;if(!getAccount(l).isConnected){let g=b$2();if(g){if(await g.open(),!await Ke(l)){d("No wallet was connected.");return}}else {let H=Qe(v);if(!H){d("No wallet connector is configured.");return}try{await C({connector:H});}catch(J){if(!qe(J))throw J}}}let h=p??await de(l);if(!h&&getAccount(l).isConnected&&(await new Promise(g=>setTimeout(g,300)),h=await de(l),!W()))return;if(!h){d("Wallet client is not available.");return}if(T(!0),c==="link"){let g=await me(r$1({client:n,clients:h,networkID:t}),ue);if(!W())return;if(g.ok){f?.(g.data.PlayAccess??null);return}d(g.stage==="sign"?"Signature declined.":authErrorText(g.error,"Could not link the wallet."));return}let S=await me(q$2({client:n,clients:h,networkID:t}),ue);if(!W())return;if(S.ok){o();return}d(S.stage==="sign"?"Signature declined.":authErrorText(S.error,"Wallet sign-in failed."));}catch(h){if(!W())return;console.error("[idosgames/wallet] wallet sign-in failed:",h),d(Oe(h));}finally{W()&&(y(false),T(false));}};useEffect(()=>{!s||$.current||($.current=true,z());},[s]);let we=async()=>{await Ve(l)||await b$2()?.open();};return jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:()=>{E?we():z();},disabled:r,style:{...$e,...r?{opacity:.6,cursor:"default"}:null,...m},children:E?"Waiting for signature \u2014 tap to open wallet":a?"Check your wallet\u2026":w?i??(c==="link"?"Link wallet":"Sign in with wallet"):"Connect wallet"}),P&&jsx("span",{role:"alert",style:ze,children:P})]})}var $e={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},ze={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};function st(e){let{client:n,walletConnectProjectId:t,appName:o,onClose:r,style:i,topUp:m}=e,[s,c]=useState(t??"");useEffect(()=>{if(t)return;let l=true;return (async()=>{let w=await n.blockchain.getDefinitions();if(!l||!w.ok)return;let C=w.data.Blockchain?.WalletLogin?.WalletConnectProjectId;C&&c(C);})(),()=>{l=false;}},[n,t]);let f=useMemo(()=>O({walletConnectProjectId:s||void 0,appName:o}),[s,o]);return jsx(b,{wagmiConfig:f,children:jsx(lt,{client:n,onClose:r,style:i,topUp:m})})}function lt({client:e,onClose:n,style:t,topUp:o}){let r=K(e,e.titleID),{address:i,isConnected:m,chainId:s}=useAccount(),{connect:c,connectors:f}=useConnect(),{disconnect:l}=useDisconnect(),{switchChainAsync:w}=useSwitchChain(),C=useConfig();async function v(a){if(!a||s===a)return true;try{return await w({chainId:a}),!0}catch{return false}}let p={networkType:"EVM",address:m&&i?i:null,connectChoices:f.map(a=>({key:a.uid,label:a.name,connect:()=>c({connector:a})})),disconnect:()=>l(),deposit:async({network:a,binding:y,amount:P})=>{if(!y.ContractAddress)return b$1("approve","This token cannot be deposited.");if(!await v(a.ChainID))return b$1("approve",`Switch your wallet to chain ${a.ChainID} to continue.`);let d;try{let T=getPublicClient(C,{chainId:a.ChainID??void 0});if(!T)throw new Error("no client");d=Number(await T.readContract({address:y.ContractAddress,abi:b$3,functionName:"decimals"}));}catch{return b$1("approve","Could not read the token from the network. Try again.")}let E;try{E=parseUnits(P,d);}catch{return b$1("approve","Invalid amount.")}return r.depositToken({network:a,tokenAddress:y.ContractAddress,amount:E})},withdraw:async({network:a,networkID:y,currencyID:P,amount:d})=>r.account?await v(a.ChainID)?r.withdrawToken({currencyID:P,networkID:y,walletAddress:r.account,amount:d}):b$1("request",`Switch your wallet to chain ${a.ChainID} to continue.`):b$1("request","Wallet not connected.")};return jsx(c$1,{client:e,engine:p,onClose:n,style:t,topUp:o})}export{se as DEFAULT_EVM_CHAINS,b as IDosGamesWalletProvider,je as WalletLogin,ge as WalletLoginButton,st as WalletPanel,O as createEvmWalletConfig,K as useEvmBridge,N as useEvmBridgeClients};
|
package/dist/react/lazyIndex.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var viem=require('viem'),core=require('@idosgames/core'),wagmi=require('wagmi'),connectors=require('wagmi/connectors'),appkitAdapterWagmi=require('@reown/appkit-adapter-wagmi'),react$1=require('@reown/appkit/react'),reactQuery=require('@tanstack/react-query'),react=require('react'),jsxRuntime=require('react/jsx-runtime'),actions=require('wagmi/actions'),appkitAdapterSolana=require('@reown/appkit-adapter-solana'),buffer=require('buffer'),web3_js=require('@solana/web3.js');var Tn=Object.defineProperty;var k=(t,e)=>()=>(t&&(e=t(t=0)),e);var Wt=(t,e)=>{for(var n in e)Tn(t,n,{get:e[n],enumerable:true});};function I(t){return t instanceof viem.BaseError?t.shortMessage:t instanceof Error?t.message:String(t)}function f(t,e,n){return {ok:false,stage:t,error:e,...n}}function b(t,e){return {ok:false,stage:t,error:e}}var L=k(()=>{});function Dn(t=typeof window>"u"?"":window.location.hostname){let e=t.toLowerCase();return In.test(e)?true:e!=="localhost"&&e!=="127.0.0.1"?false:globalThis.__IDOS_PREVIEW__!=null}function S(){if(typeof window>"u"||Dn())return false;try{return window.self!==window.top}catch{return true}}function Ue(){if(typeof window>"u")return false;try{return window.parent!==window.top}catch{return true}}function U(t){return f(t,At)}function ee(t){return b(t,At)}var At,In,V=k(()=>{L();At="WALLET_USE_SITE_PANEL",In=/^[a-z0-9]{8}-preview\.idos\.games$/;});function qe(t){return Object.values(exports.idosChains).find(e=>e.id===t)}function Dt(t){return {...t,chainNamespace:"eip155",caipNetworkId:`eip155:${t.id}`}}exports.mainnet=void 0;exports.bsc=void 0;exports.polygon=void 0;exports.base=void 0;exports.arbitrum=void 0;exports.optimism=void 0;exports.sepolia=void 0;exports.polygonAmoy=void 0;exports.idosChains=void 0;exports.solanaMainnet=void 0;exports.solanaDevnet=void 0;var Q=k(()=>{exports.mainnet={id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://eth.llamarpc.com"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io"}}},exports.bsc={id:56,name:"BNB Smart Chain",nativeCurrency:{name:"BNB",symbol:"BNB",decimals:18},rpcUrls:{default:{http:["https://bsc-dataseed.binance.org"]}},blockExplorers:{default:{name:"BscScan",url:"https://bscscan.com"}}},exports.polygon={id:137,name:"Polygon",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://polygon-rpc.com"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://polygonscan.com"}}},exports.base={id:8453,name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.base.org"]}},blockExplorers:{default:{name:"BaseScan",url:"https://basescan.org"}}},exports.arbitrum={id:42161,name:"Arbitrum One",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://arbiscan.io"}}},exports.optimism={id:10,name:"OP Mainnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.optimism.io"]}},blockExplorers:{default:{name:"Optimistic Etherscan",url:"https://optimistic.etherscan.io"}}},exports.sepolia={id:11155111,name:"Sepolia",testnet:true,nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.sepolia.org"]}},blockExplorers:{default:{name:"Etherscan",url:"https://sepolia.etherscan.io"}}},exports.polygonAmoy={id:80002,name:"Polygon Amoy",testnet:true,nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://rpc-amoy.polygon.technology"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://amoy.polygonscan.com"}}},exports.idosChains={mainnet:exports.mainnet,bsc:exports.bsc,polygon:exports.polygon,base:exports.base,arbitrum:exports.arbitrum,optimism:exports.optimism,sepolia:exports.sepolia,polygonAmoy:exports.polygonAmoy};exports.solanaMainnet={id:"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",name:"Solana",network:"solana-mainnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://api.mainnet-beta.solana.com"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:false,chainNamespace:"solana",caipNetworkId:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"},exports.solanaDevnet={id:"EtWTRABZaYq6iMfeYKouRu166VU2xqa1",name:"Solana Devnet",network:"solana-devnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://api.devnet.solana.com"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:true,chainNamespace:"solana",caipNetworkId:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"};});function Te(t){xt=t;}function H(){return xt}var xt,ce=k(()=>{xt=null;});function ve(t){let{chains:e=ze,walletConnectProjectId:n,appName:o,appUrl:a,appIcon:r,transports:c,connectors:l}=t,i=n??"__extension_only__";if(!l){let g=Ve.get(i);if(g)return g}let d={};for(let g of e)d[g.id]=c?.[g.id]??wagmi.http();let s=a??(typeof window<"u"?window.location.origin:""),u={name:o??"iDosGames",description:o??"iDosGames game",url:s,icons:r?[r]:[]};if(n&&!l){let g=e.map(Dt),y=new appkitAdapterWagmi.WagmiAdapter({networks:g,projectId:n,transports:d});return Te(react$1.createAppKit({adapters:[y],networks:g,projectId:n,metadata:u,features:{analytics:false,email:false,socials:false}})),Ve.set(i,y.wagmiConfig),y.wagmiConfig}let p=l??[connectors.injected(),connectors.coinbaseWallet({appName:o??"iDosGames"})],m=wagmi.createConfig({chains:e,connectors:p,transports:d});return l||Ve.set(i,m),m}var ze,Ve,je=k(()=>{Q();ce();ze=[exports.mainnet,exports.bsc,exports.polygon,exports.base,exports.arbitrum,exports.optimism,exports.sepolia,exports.polygonAmoy],Ve=new Map;});function de(t){let{wagmiConfig:e,queryClient:n,children:o}=t,[a]=react.useState(()=>n??new reactQuery.QueryClient);return jsxRuntime.jsx(wagmi.WagmiProvider,{config:e,children:jsxRuntime.jsx(reactQuery.QueryClientProvider,{client:a,children:o})})}var Ie=k(()=>{});var De,Lt,$e,Rt,Ye=k(()=>{De=[{type:"function",name:"depositERC20",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"amount",type:"uint256"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"withdrawERC20",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"amount",type:"uint256"},{name:"burnAmount",type:"uint256"},{name:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{name:"amount",type:"uint256"}]},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC1155",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{name:"amount",type:"uint256"}]},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC721",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"tokenId",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]}],Lt=[{type:"function",name:"withdrawERC1155Mint",stateMutability:"nonpayable",inputs:[{name:"collection",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{name:"amount",type:"uint256"}]},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC721Mint",stateMutability:"nonpayable",inputs:[{name:"collection",type:"address"},{name:"to",type:"address"},{name:"tokenId",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]}],$e=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{name:"",type:"uint8"}]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{name:"",type:"uint256"}]}],Rt=[{type:"function",name:"safeTransferFrom",stateMutability:"nonpayable",inputs:[{name:"from",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"data",type:"bytes"}],outputs:[]},{type:"function",name:"isApprovedForAll",stateMutability:"view",inputs:[{name:"account",type:"address"},{name:"operator",type:"address"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"setApprovalForAll",stateMutability:"nonpayable",inputs:[{name:"operator",type:"address"},{name:"approved",type:"bool"}],outputs:[]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"},{name:"id",type:"uint256"}],outputs:[{name:"",type:"uint256"}]}];});function Bt(t,e,n){return viem.encodeAbiParameters([{type:"string"},{type:"string"},{type:"string"}],[t,e,core.normalizeBlockchainCategory(n)])}var _t=k(()=>{});async function Z(t,e){let{walletClient:n,publicClient:o,account:a}=t,r=await n.writeContract({address:e.address,abi:e.abi,functionName:e.functionName,args:e.args,account:a,chain:n.chain,value:e.value});if((await o.waitForTransactionReceipt({hash:r})).status==="reverted")throw new Error(`On-chain transaction reverted (${r}).`);return r}var Qe=k(()=>{});function Ot(t){let e=t.RewardPoolAddress;return e||null}async function Mt(t,e,n,o){return await t.publicClient.readContract({address:e,abi:$e,functionName:"allowance",args:[t.account,n]})>=o?null:Z(t,{address:e,abi:$e,functionName:"approve",args:[n,o]})}async function Ze(t){let{client:e,clients:n,network:o,tokenAddress:a,amount:r,titleID:c,category:l}=t;if(S())return U("approve");let i=e.auth.context?.userID;if(!i)return f("approve","Not logged in.");let d=Ot(o);if(!d)return f("approve","Network has no RewardPoolAddress.");if(r<=0n)return f("approve","Amount must be positive.");try{await Mt(n,a,d,r);}catch(p){return f("approve",I(p))}let s;try{s=await Z(n,{address:d,abi:De,functionName:"depositERC20",args:[a,r,i,c,l??""]});}catch(p){return f("deposit-onchain",I(p))}let u=await e.blockchain.depositToken(o.NetworkID??"",s);return u.ok?{ok:true,onChainTxHash:s,data:u.data}:f("report",u.error,{onChainTxHash:s})}async function Je(t){let{client:e,clients:n,network:o,nftContractAddress:a,tokenId:r,amount:c,titleID:l,category:i}=t;if(S())return U("deposit-onchain");let d=e.auth.context?.userID;if(!d)return f("deposit-onchain","Not logged in.");let s=Ot(o);if(!s)return f("deposit-onchain","Network has no RewardPoolAddress.");if(c<=0n)return f("deposit-onchain","Amount must be positive.");let u=Bt(d,l,i),p;try{p=await Z(n,{address:a,abi:Rt,functionName:"safeTransferFrom",args:[n.account,s,r,c,u]});}catch(g){return f("deposit-onchain",I(g))}let m=await e.blockchain.depositNFT(o.NetworkID??"",p);return m.ok?{ok:true,onChainTxHash:p,data:m.data}:f("report",m.error,{onChainTxHash:p})}var Ft=k(()=>{Ye();_t();Qe();L();V();});function Kt(t){return (t.Splits??[]).map(e=>({to:e.To,amount:BigInt(e.Amount??"0")}))}async function Gt(t,e){return Z(t,{address:e.ContractAddress,abi:De,functionName:"withdrawERC20",args:[e.TokenAddress,e.WalletAddress,BigInt(e.Amount??"0"),BigInt(e.BurnAmount??"0"),Kt(e),BigInt(e.Nonce??"0"),e.Signature??"0x",e.UserID??"",e.TitleID??"",e.Category??"",BigInt(e.Deadline??"0")]})}async function Ut(t,e){return Z(t,{address:e.ContractAddress,abi:Lt,functionName:"withdrawERC1155Mint",args:[e.TokenAddress,e.WalletAddress,BigInt(e.TokenId??"0"),BigInt(e.Amount??"0"),Kt(e),BigInt(e.Nonce??"0"),e.Signature??"0x",e.UserID??"",e.TitleID??"",e.Category??"",BigInt(e.Deadline??"0")]})}async function Xe(t){let{client:e,clients:n,currencyID:o,networkID:a,walletAddress:r,amount:c,category:l}=t;if(S())return U("request");let i=await e.blockchain.requestTokenWithdrawal(o,a,r,c,l);if(!i.ok)return f("request",i.error);let d=i.data.EvmSignature,s=i.data.TitleTransactionID??void 0;if(!d)return f("request","Withdrawal response carried no EVM signature.",{titleTransactionID:s});let u;try{u=await Gt(n,d);}catch(m){return f("withdraw-onchain",I(m),{titleTransactionID:s})}let p=await Ht(e,s,u);return p.ok?{ok:true,onChainTxHash:u,data:i.data}:p}async function et(t){let{client:e,clients:n,itemID:o,networkID:a,walletAddress:r,amount:c,category:l}=t;if(S())return U("request");let i=await e.blockchain.requestNFTWithdrawal(o,a,r,c,l);if(!i.ok)return f("request",i.error);let d=i.data.EvmSignature,s=i.data.TitleTransactionID??void 0;if(!d)return f("request","Withdrawal response carried no EVM signature.",{titleTransactionID:s});let u;try{u=await Ut(n,d);}catch(m){return f("withdraw-onchain",I(m),{titleTransactionID:s})}let p=await Ht(e,s,u);return p.ok?{ok:true,onChainTxHash:u,data:i.data}:p}async function Ht(t,e,n){if(!e)return f("confirm","Missing TitleTransactionID.",{onChainTxHash:n});let o=await t.blockchain.confirmWithdrawal(e,n);return o.ok?{ok:true,onChainTxHash:n,data:o.data}:f("confirm",o.error,{onChainTxHash:n,titleTransactionID:e})}var qt=k(()=>{Ye();Qe();L();V();});async function he(t){let{client:e,clients:n,networkID:o}=t;if(S())return ee("challenge");let a=t.walletAddress??n.account,r=await e.auth.requestWalletChallenge(a,o);if(!r.ok)return b("challenge",r.error);let c;try{c=await n.walletClient.signMessage({account:n.account,message:r.data.Message});}catch(i){return b("sign",I(i))}let l=await e.auth.loginWithWallet(a,o,c);return l.ok?{ok:true,data:l.data}:b("login",l.error)}async function tt(t){let{client:e,clients:n,networkID:o}=t;if(S())return ee("challenge");let a=t.walletAddress??n.account,r=await e.auth.linkWallet(a,o);if(!r.ok)return b("challenge",r.error);if(!r.data.Challenge)return b("challenge","No challenge was issued.");let c;try{c=await n.walletClient.signMessage({account:n.account,message:r.data.Challenge});}catch(i){return b("sign",I(i))}let l=await e.auth.linkWallet(a,o,c);return l.ok?{ok:true,data:l.data}:b("login",l.error)}var Vt=k(()=>{L();V();});var nt=k(()=>{Ft();qt();Vt();});function be(){let{address:t}=wagmi.useAccount(),e=wagmi.usePublicClient(),{data:n}=wagmi.useWalletClient();return !t||!e||!n?null:{account:t,publicClient:e,walletClient:n}}function xe(t,e){let n=be();return {connected:!!n,account:n?.account??null,loginWithWallet:(o,a)=>n?he({client:t,clients:n,networkID:o,walletAddress:a}):Promise.resolve(b("challenge",ke)),depositToken:o=>n?Ze({client:t,clients:n,titleID:e,...o}):Promise.resolve(f("approve",ke)),depositNft:o=>n?Je({client:t,clients:n,titleID:e,...o}):Promise.resolve(f("deposit-onchain",ke)),withdrawToken:o=>n?Xe({client:t,clients:n,...o}):Promise.resolve(f("withdraw-onchain",ke)),withdrawNft:o=>n?et({client:t,clients:n,...o}):Promise.resolve(f("withdraw-onchain",ke))}}var ke,Ne=k(()=>{nt();L();ke="Wallet not connected.";});function ue(t,e){switch(t){case null:case void 0:case "":return e;case "PLAY_ACCESS_WALLET_USED_BY_ANOTHER_ACCOUNT":return "This wallet already plays with another account.";case "WALLET_UNLINK_COOLDOWN":return "This wallet was unlinked from another account less than 7 days ago. Try again after the 7 days.";case "WALLET_CHANGES_TOO_FREQUENT":return "Too many wallets were changed this week. Try again in a few days.";case "PLAY_ACCESS_WALLET_LOGIN_ONLY":return "This game is played with a wallet login only.";case "INVALID_WALLET_SIGNATURE":return "The signature does not match the wallet. Please try again.";case "WALLET_CHALLENGE_EXPIRED":return "The request expired. Please try again.";default:return t}}var ot=k(()=>{});function Zt(t){let{wagmiConfig:e,...n}=t;return jsxRuntime.jsx(de,{wagmiConfig:e,children:jsxRuntime.jsx(at,{...n})})}function ro(t){return t instanceof Error&&(t.name==="ConnectorAlreadyConnectedError"||t.message.includes("already connected"))}function ao(t){let e="Wallet sign-in failed. Please try again.";return t instanceof Error?t.name==="ProviderNotFoundError"||/provider not found/i.test(t.message)?"No crypto wallet found in this browser. Install a wallet extension (e.g. MetaMask) or open this page in your wallet's browser, then try again.":t.name==="UserRejectedRequestError"||/user (rejected|denied|cancelled|canceled)/i.test(t.message)?"Request declined in the wallet.":/timed? ?out/i.test(t.message)?"The wallet did not respond. Open your wallet and try again.":e:e}async function jt(t){let e=await actions.getWalletClient(t).catch(()=>null);if(!e)return null;let n=actions.getPublicClient(t);return n?{account:e.account.address,publicClient:n,walletClient:e}:null}function io(t,e=18e4){return actions.getAccount(t).isConnected?Promise.resolve(true):new Promise(n=>{let o=false,a=l=>{o||(o=true,r(),clearTimeout(c),n(l));},r=actions.watchAccount(t,{onChange:l=>{l.isConnected&&a(true);}}),c=setTimeout(()=>a(false),e);})}function so(t,e=8e3){let n=o=>o==="reconnecting"||o==="connecting";return n(actions.getAccount(t).status)?new Promise(o=>{let a=false,r=()=>{a||(a=true,c(),clearTimeout(l),o());},c=actions.watchAccount(t,{onChange:i=>{n(i.status)||r();}}),l=setTimeout(r,e);}):Promise.resolve()}function lo(t){let e=a=>t.find(r=>r.id===a||r.type===a),n=e("injected"),o=typeof window<"u"&&window.ethereum!=null;return n&&o?n:e("walletConnect")??n??t[0]}async function co(t){try{let o=(await actions.getAccount(t).connector?.getProvider?.())?.session?.peer?.metadata?.redirect,a=o?.native||o?.universal;return !a||typeof window>"u"?!1:(window.location.href=a,!0)}catch{return false}}function Yt(t,e){return new Promise((n,o)=>{let a=setTimeout(()=>o(new Error("The wallet request timed out.")),e);t.then(r=>{clearTimeout(a),n(r);},r=>{clearTimeout(a),o(r instanceof Error?r:new Error(String(r)));});})}function at(t){let{client:e,networkID:n,onAuthenticated:o,disabled:a,label:r,style:c,autoStart:l,mode:i="login",onLinked:d}=t,s=wagmi.useConfig(),{isConnected:u}=wagmi.useAccount(),{connectAsync:p,connectors:m}=wagmi.useConnect(),g=be(),[y,w]=react.useState(false),[W,A]=react.useState(null),[B,M]=react.useState(false),_=react.useRef(0),j=react.useRef(false),N=async()=>{let h=++_.current,C=()=>_.current===h;w(true),A(null);try{if(await so(s),!C())return;if(!actions.getAccount(s).isConnected){let v=H();if(v){if(await v.open(),!await io(s)){A("No wallet was connected.");return}}else {let X=lo(m);if(!X){A("No wallet connector is configured.");return}try{await p({connector:X});}catch(G){if(!ro(G))throw G}}}let T=g??await jt(s);if(!T&&actions.getAccount(s).isConnected&&(await new Promise(v=>setTimeout(v,300)),T=await jt(s),!C()))return;if(!T){A("Wallet client is not available.");return}if(M(!0),i==="link"){let v=await Yt(tt({client:e,clients:T,networkID:n}),$t);if(!C())return;if(v.ok){d?.(v.data.PlayAccess??null);return}A(v.stage==="sign"?"Signature declined.":ue(v.error,"Could not link the wallet."));return}let F=await Yt(he({client:e,clients:T,networkID:n}),$t);if(!C())return;if(F.ok){o();return}A(F.stage==="sign"?"Signature declined.":ue(F.error,"Wallet sign-in failed."));}catch(T){if(!C())return;console.error("[idosgames/wallet] wallet sign-in failed:",T),A(ao(T));}finally{C()&&(w(false),M(false));}};react.useEffect(()=>{!l||j.current||(j.current=true,N());},[l]);let q=async()=>{await co(s)||await H()?.open();};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{B?q():N();},disabled:a,style:{...uo,...a?{opacity:.6,cursor:"default"}:null,...c},children:B?"Waiting for signature \u2014 tap to open wallet":y?"Check your wallet\u2026":u?r??(i==="link"?"Link wallet":"Sign in with wallet"):"Connect wallet"}),W&&jsxRuntime.jsx("span",{role:"alert",style:po,children:W})]})}var $t,uo,po,Jt=k(()=>{ce();ot();nt();Ie();Ne();$t=9e4;uo={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},po={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};});function Be({client:t,engine:e,onClose:n,style:o}){let[,a]=react.useReducer(h=>h+1,0),[r,c]=react.useState({}),[l,i]=react.useState({}),[d,s]=react.useState(""),[u,p]=react.useState(""),[m,g]=react.useState(""),[y,w]=react.useState(false),[W,A]=react.useState(null);react.useEffect(()=>{let h=true;return (async()=>{let C=await t.blockchain.getDefinitions();if(await t.blockchain.getUserState(),!h||!C.ok)return;let T={};for(let[F,v]of Object.entries(C.data.Blockchain?.Networks??{}))v.Type===e.networkType&&(T[F]=v);c(T),i(C.data.CryptoCurrencies??{}),s(Object.keys(T)[0]??"");})(),()=>{h=false;}},[t,e.networkType]),react.useEffect(()=>t.on("user:anyUpdated",a),[t]);let B=react.useMemo(()=>Object.entries(l).filter(([,h])=>h.Networks?.some(C=>C.NetworkID===d&&!!C.ContractAddress)),[l,d]);react.useEffect(()=>{let h=B[0]?.[0]??"";p(C=>B.some(([T])=>T===C)?C:h);},[B]);let M=d?r[d]:void 0,_=u?l[u]?.Networks?.find(h=>h.NetworkID===d):void 0,j=u?t.data.user.getCryptoCurrencyAmount(u):"0",N=!!e.address;async function q(h){w(true),A(null);try{let C=await h();A(C),C.ok&&await t.blockchain.getUserState();}finally{w(false);}}return jsxRuntime.jsxs("div",{style:{...wo,...o},children:[jsxRuntime.jsxs("div",{style:{...lt,justifyContent:"space-between"},children:[jsxRuntime.jsx("span",{style:ho,children:"Crypto wallet"}),n&&jsxRuntime.jsx("button",{type:"button",style:Re,onClick:n,children:"\u2715"})]}),N?jsxRuntime.jsxs("div",{style:lt,children:[jsxRuntime.jsxs("span",{style:{...z,flex:1,alignSelf:"center"},children:[e.address.slice(0,6),"\u2026",e.address.slice(-4)]}),jsxRuntime.jsx("button",{type:"button",style:Re,onClick:e.disconnect,children:"Disconnect"})]}):jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[jsxRuntime.jsx("span",{style:z,children:"Connect a browser or mobile wallet"}),e.connectChoices.length===0?jsxRuntime.jsx("span",{style:z,children:"Wallet connection is not configured for this title."}):e.connectChoices.map(h=>jsxRuntime.jsx("button",{type:"button",style:Re,onClick:h.connect,children:h.label},h.key))]}),Object.keys(r).length===0?jsxRuntime.jsxs("span",{style:z,children:["No ",e.networkType," networks configured for this title."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:z,children:"Network"}),jsxRuntime.jsx("select",{style:st,value:d,onChange:h=>s(h.target.value),children:Object.entries(r).map(([h,C])=>jsxRuntime.jsx("option",{value:h,children:C.DisplayName??h},h))})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:z,children:"Token"}),jsxRuntime.jsxs("select",{style:st,value:u,onChange:h=>p(h.target.value),children:[B.length===0&&jsxRuntime.jsx("option",{value:"",children:"\u2014 no depositable tokens \u2014"}),B.map(([h,C])=>jsxRuntime.jsx("option",{value:h,children:C.DisplayName??h},h))]})]}),jsxRuntime.jsxs("div",{style:z,children:["In-game balance: ",jsxRuntime.jsx("b",{children:j})," ",u]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:z,children:"Amount"}),jsxRuntime.jsx("input",{style:st,inputMode:"decimal",placeholder:"0.0",value:m,onChange:h=>g(h.target.value)})]}),jsxRuntime.jsxs("div",{style:lt,children:[jsxRuntime.jsx("button",{type:"button",style:{...ko,flex:1,opacity:y?.6:1},disabled:y||!N||!_?.ContractAddress,onClick:()=>{!M||!_||q(()=>e.deposit({network:M,binding:_,currencyID:u,amount:m||"0"}));},children:"Deposit"}),jsxRuntime.jsx("button",{type:"button",style:{...Re,flex:1,opacity:y?.6:1},disabled:y||!N||!u,onClick:()=>{M&&q(()=>e.withdraw({network:M,networkID:d,currencyID:u,amount:m||"0"}));},children:"Withdraw"})]})]}),W&&jsxRuntime.jsx(bo,{result:W})]})}function bo({result:t}){let e={fontSize:12,borderRadius:8,padding:"8px 10px",background:t.ok?"#1e3a2a":"#3a1e28",color:t.ok?"#8ef0b0":"#f2a0b4",wordBreak:"break-all"};return t.ok?jsxRuntime.jsxs("div",{style:e,children:["\u2713 Done \xB7 tx ",t.onChainTxHash]}):jsxRuntime.jsxs("div",{style:e,children:["\u2715 [",t.stage,"] ",t.error,t.titleTransactionID?` \xB7 already debited (tx ${t.titleTransactionID}) \u2014 retry/confirm, don't re-request`:""]})}var wo,ho,z,st,ko,Re,lt,ct=k(()=>{wo={pointerEvents:"auto",background:"#04276bf5",border:"1px solid #1e59c8",borderRadius:12,padding:16,color:"#fff",width:320,boxSizing:"border-box",fontFamily:"system-ui, sans-serif",display:"flex",flexDirection:"column",gap:10,maxHeight:"80vh",overflow:"auto"},ho={fontWeight:700,fontSize:16},z={fontSize:12,opacity:.7},st={background:"#052e7e",border:"1px solid #1e59c8",borderRadius:8,color:"#fff",padding:"8px 10px",width:"100%",boxSizing:"border-box"},ko={background:"#0d66fe",color:"#fff",border:"none",borderRadius:8,padding:"9px 14px",fontWeight:700,cursor:"pointer"},Re={background:"#1e59c8",color:"#fff",border:"none",borderRadius:8,padding:"7px 12px",fontWeight:600,cursor:"pointer"},lt={display:"flex",gap:8};});function Xt(t){let{client:e,walletConnectProjectId:n,appName:o,onClose:a,style:r}=t,[c,l]=react.useState(n??"");react.useEffect(()=>{if(n)return;let d=true;return (async()=>{let s=await e.blockchain.getDefinitions();if(!d||!s.ok)return;let u=s.data.Blockchain?.WalletLogin?.WalletConnectProjectId;u&&l(u);})(),()=>{d=false;}},[e,n]);let i=react.useMemo(()=>ve({walletConnectProjectId:c||void 0,appName:o}),[c,o]);return jsxRuntime.jsx(de,{wagmiConfig:i,children:jsxRuntime.jsx(Do,{client:e,onClose:a,style:r})})}function Do({client:t,onClose:e,style:n}){let o=xe(t,t.titleID),{address:a,isConnected:r,chainId:c}=wagmi.useAccount(),{connect:l,connectors:i}=wagmi.useConnect(),{disconnect:d}=wagmi.useDisconnect(),{switchChainAsync:s}=wagmi.useSwitchChain();async function u(m){if(!m||c===m)return true;try{return await s({chainId:m}),!0}catch{return false}}let p={networkType:"EVM",address:r&&a?a:null,connectChoices:i.map(m=>({key:m.uid,label:m.name,connect:()=>l({connector:m})})),disconnect:()=>d(),deposit:async({network:m,binding:g,amount:y})=>{if(!g.ContractAddress)return f("approve","This token cannot be deposited.");if(!await u(m.ChainID))return f("approve",`Switch your wallet to chain ${m.ChainID} to continue.`);let w;try{w=viem.parseUnits(y,g.Decimals??18);}catch{return f("approve","Invalid amount.")}return o.depositToken({network:m,tokenAddress:g.ContractAddress,amount:w})},withdraw:async({network:m,networkID:g,currencyID:y,amount:w})=>o.account?await u(m.ChainID)?o.withdrawToken({currencyID:y,networkID:g,walletAddress:o.account,amount:w}):f("request",`Switch your wallet to chain ${m.ChainID} to continue.`):f("request","Wallet not connected.")};return jsxRuntime.jsx(Be,{client:t,engine:p,onClose:e,style:n})}var en=k(()=>{je();Ie();Ne();L();ct();});var ut={};Wt(ut,{DEFAULT_EVM_CHAINS:()=>ze,IDosGamesWalletProvider:()=>de,WalletLogin:()=>Zt,WalletLoginButton:()=>at,WalletPanel:()=>Xt,arbitrum:()=>exports.arbitrum,base:()=>exports.base,bsc:()=>exports.bsc,chainById:()=>qe,createEvmWalletConfig:()=>ve,idosChains:()=>exports.idosChains,mainnet:()=>exports.mainnet,optimism:()=>exports.optimism,polygon:()=>exports.polygon,polygonAmoy:()=>exports.polygonAmoy,sepolia:()=>exports.sepolia,useEvmBridge:()=>xe,useEvmBridgeClients:()=>be});var pt=k(()=>{je();Q();Ie();Ne();Jt();en();});function _e(t){let{walletConnectProjectId:e,appName:n,appUrl:o,appIcon:a,wallets:r}=t,c=tn.get(e);if(c)return c;let l=t.networks??[exports.solanaMainnet],i=o??(typeof window<"u"?window.location.origin:""),d={name:n??"iDosGames",description:n??"iDosGames game",url:i,icons:a?[a]:[]},s=new appkitAdapterSolana.SolanaAdapter(r?{wallets:r}:{});return Te(react$1.createAppKit({adapters:[s],networks:l,projectId:e,metadata:d,features:{analytics:false,email:false,socials:false}})),tn.set(e,s),s}var tn,mt=k(()=>{Q();ce();tn=new Map;});async function Pe(t){let{client:e,adapter:n,network:o,mint:a,amountRaw:r,titleID:c,category:l}=t;if(S())return U("deposit-onchain");let i=e.auth.context?.userID;if(!i)return f("deposit-onchain","Not logged in.");if(r<=0n)return f("deposit-onchain","Amount must be positive.");let d;try{d=await n.depositSpl({mint:a,amountRaw:r,userID:i,titleID:c,category:core.normalizeBlockchainCategory(l)});}catch(u){return f("deposit-onchain",I(u))}let s=await e.blockchain.depositToken(o.NetworkID??"",d);return s.ok?{ok:true,onChainTxHash:d,data:s.data}:f("report",s.error,{onChainTxHash:d})}async function Se(t){let{client:e,adapter:n,currencyID:o,networkID:a,walletAddress:r,amount:c,category:l}=t;if(S())return U("request");let i=await e.blockchain.requestTokenWithdrawal(o,a,r,c,l);if(!i.ok)return f("request",i.error);let d=i.data.SolanaSignature,s=i.data.TitleTransactionID??void 0;if(!d)return f("request","Withdrawal response carried no Solana signature.",{titleTransactionID:s});let u;try{u=await n.submitWithdrawal(d);}catch(m){return f("withdraw-onchain",I(m),{titleTransactionID:s})}if(!s)return f("confirm","Missing TitleTransactionID.",{onChainTxHash:u});let p=await e.blockchain.confirmWithdrawal(s,u);return p.ok?{ok:true,onChainTxHash:u,data:i.data}:f("confirm",p.error,{onChainTxHash:u,titleTransactionID:s})}var nn=k(()=>{L();V();});async function We(t){let{client:e,networkID:n,walletAddress:o,signMessage:a}=t;if(S())return ee("challenge");let r=await e.auth.requestWalletChallenge(o,n);if(!r.ok)return b("challenge",r.error);let c;try{let i=await a(new TextEncoder().encode(r.data.Message));c=on(i);}catch(i){return b("sign",I(i))}let l=await e.auth.loginWithWallet(o,n,c);return l.ok?{ok:true,data:l.data}:b("login",l.error)}async function ft(t){let{client:e,networkID:n,walletAddress:o,signMessage:a}=t;if(S())return ee("challenge");let r=await e.auth.linkWallet(o,n);if(!r.ok)return b("challenge",r.error);if(!r.data.Challenge)return b("challenge","No challenge was issued.");let c;try{let i=await a(new TextEncoder().encode(r.data.Challenge));c=on(i);}catch(i){return b("sign",I(i))}let l=await e.auth.linkWallet(o,n,c);return l.ok?{ok:true,data:l.data}:b("login",l.error)}function on(t){let e="0x";for(let n of t)e+=n.toString(16).padStart(2,"0");return e}var rn=k(()=>{L();V();});var Oe=k(()=>{nn();rn();});function sn(t,e,n){let{address:o}=react$1.useAppKitAccount(),{walletProvider:a}=react$1.useAppKitProvider("solana"),r=o??null,c=a?.signMessage?.bind(a);return {connected:!!r,account:r,loginWithWallet:(l,i)=>{let d=i??r;return d?c?We({client:t,networkID:l,walletAddress:d,signMessage:c}):Promise.resolve(b("sign","The connected wallet does not support message signing.")):Promise.resolve(b("challenge",an))},depositToken:l=>Pe({client:t,adapter:n,titleID:e,...l}),withdrawToken:l=>{let i=l.walletAddress??r;return i?Se({client:t,adapter:n,...l,walletAddress:i}):Promise.resolve(f("request",an))}}}var an,ln=k(()=>{Oe();L();an="Wallet not connected.";});function Fo(t){try{let n=t?.session?.peer?.metadata?.redirect,o=n?.native||n?.universal;return !o||typeof window>"u"?!1:(window.location.href=o,!0)}catch{return false}}function dn(t,e){return new Promise((n,o)=>{let a=setTimeout(()=>o(new Error("The wallet request timed out.")),e);t.then(r=>{clearTimeout(a),n(r);},r=>{clearTimeout(a),o(r instanceof Error?r:new Error(String(r)));});})}function Ko(t){let e="Wallet sign-in failed. Please try again.";return t instanceof Error?/user (rejected|denied|cancelled|canceled)|rejected the request/i.test(t.message)?"Request declined in the wallet.":/timed? ?out/i.test(t.message)?"The wallet did not respond. Open your wallet and try again.":e:e}function pn(t){let{client:e,networkID:n,onAuthenticated:o,disabled:a,label:r,style:c,autoStart:l,mode:i="login",onLinked:d}=t,{address:s,isConnected:u}=react$1.useAppKitAccount(),{walletProvider:p}=react$1.useAppKitProvider("solana"),[m,g]=react.useState(false),[y,w]=react.useState(null),[W,A]=react.useState(false),[B,M]=react.useState(false),_=react.useRef(null),j=react.useRef(0),N=react.useCallback(()=>{_.current&&clearTimeout(_.current),_.current=null;},[]);react.useEffect(()=>N,[N]);let q=react.useRef(false),h=react.useCallback(async()=>{let F=++j.current,v=()=>j.current===F,X=p?.signMessage?.bind(p);if(!s||!X){w("The connected wallet cannot sign messages."),g(false);return}g(true),w(null);try{if(M(!0),i==="link"){let Ae=await dn(ft({client:e,networkID:n,walletAddress:s,signMessage:X}),cn);if(!v())return;if(Ae.ok){d?.(Ae.data.PlayAccess??null);return}w(Ae.stage==="sign"?"Signature declined.":ue(Ae.error,"Could not link the wallet."));return}let G=await dn(We({client:e,networkID:n,walletAddress:s,signMessage:X}),cn);if(!v())return;if(G.ok){o();return}w(G.stage==="sign"?"Signature declined.":ue(G.error,"Wallet sign-in failed."));}catch(G){if(!v())return;console.error("[idosgames/wallet] solana sign-in failed:",G),w(Ko(G));}finally{v()&&(g(false),M(false));}},[s,p,e,n,o,i,d]),C=react.useCallback(()=>{Fo(p)||H()?.open();},[p]);react.useEffect(()=>{!W||!u||!s||!p||(A(false),N(),h());},[W,u,s,p,h,N]);let T=()=>{if(B){C();return}if(w(null),q.current=true,u&&s&&p){h();return}let F=H();if(!F){w("Wallet sign-in is not configured for this title.");return}g(true),A(true),N(),_.current=setTimeout(()=>{A(false),g(false),w("No wallet was connected.");},Mo),F.open();};return react.useEffect(()=>{!l||q.current||(q.current=true,T());},[l]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:T,disabled:a,style:{...Go,...a?{opacity:.6,cursor:"default"}:null,...c},children:B?"Waiting for signature \u2014 tap to open wallet":m?"Check your wallet\u2026":u?r??(i==="link"?"Link wallet":"Sign in with wallet"):"Connect wallet"}),y&&jsxRuntime.jsx("span",{role:"alert",style:Uo,children:y})]})}var Mo,cn,Go,Uo,mn=k(()=>{ot();Oe();ce();Mo=18e4,cn=9e4;Go={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},Uo={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};});function Fe(t){let e=(t??"").replace(/^0x/i,""),n=new Uint8Array(e.length>>1);for(let o=0;o<n.length;o++)n[o]=parseInt(e.slice(o*2,o*2+2),16);return n}function pe(t){let e=buffer.Buffer.alloc(8);return e.writeBigUInt64LE(BigInt(t||0)),e}function tr(t){let e=buffer.Buffer.alloc(8);return e.writeBigInt64LE(BigInt(t||0)),e}function fe(t){let e=buffer.Buffer.from(t??"","utf8"),n=buffer.Buffer.alloc(4);return n.writeUInt32LE(e.length),buffer.Buffer.concat([n,e])}function nr(t){return buffer.Buffer.concat([buffer.Buffer.from(Yo,"hex"),pe(t.amountRaw),fe(t.userID),fe(t.titleID),fe(t.category)])}function or(t){let e=t.Splits??[],n=buffer.Buffer.alloc(4);return n.writeUInt32LE(e.length),buffer.Buffer.concat([buffer.Buffer.from(t.Domain==="SPL_DEV"?Zo:Qo,"hex"),pe(t.Amount),pe(t.BurnAmount),pe(t.Nonce),tr(t.ExpiresAt),n,...e.map(o=>buffer.Buffer.concat([buffer.Buffer.from(new web3_js.PublicKey(o.To??"").toBytes()),pe(o.Amount)])),fe(t.UserID),fe(t.TitleID),fe(t.Category)])}function me(t,e,n){return web3_js.PublicKey.findProgramAddressSync([e.toBuffer(),n.toBuffer(),t.toBuffer()],Ke)[0]}function rr(t,e,n,o,a){return new web3_js.TransactionInstruction({programId:Ke,keys:[{pubkey:t,isSigner:true,isWritable:true},{pubkey:e,isSigner:false,isWritable:true},{pubkey:n,isSigner:false,isWritable:false},{pubkey:o,isSigner:false,isWritable:false},{pubkey:web3_js.SystemProgram.programId,isSigner:false,isWritable:false},{pubkey:a,isSigner:false,isWritable:false}],data:buffer.Buffer.from([1])})}function ge(t,...e){return web3_js.PublicKey.findProgramAddressSync(e,t)[0]}function ar(t){let{programId:e,user:n,mint:o,tokenProgram:a}=t,r=ge(e,buffer.Buffer.from("vault"));return new web3_js.TransactionInstruction({programId:e,keys:[{pubkey:ge(e,buffer.Buffer.from("config")),isSigner:false,isWritable:false},{pubkey:r,isSigner:false,isWritable:true},{pubkey:o,isSigner:false,isWritable:false},{pubkey:n,isSigner:true,isWritable:true},{pubkey:me(o,n,a),isSigner:false,isWritable:true},{pubkey:me(o,r,a),isSigner:false,isWritable:true},{pubkey:a,isSigner:false,isWritable:false},{pubkey:Ke,isSigner:false,isWritable:false},{pubkey:web3_js.SystemProgram.programId,isSigner:false,isWritable:false}],data:nr(t)})}function ir(t){let{sig:e,payer:n,tokenProgram:o}=t,a=new web3_js.PublicKey(e.ProgramID??""),r=new web3_js.PublicKey(e.Mint??""),c=new web3_js.PublicKey(e.WalletAddress??""),l=ge(a,buffer.Buffer.from("vault")),i=new web3_js.PublicKey(Jo),d=(e.Splits??[]).map(g=>new web3_js.PublicKey(g.To??"")),s=d.map(g=>me(r,g,o)),u=web3_js.Ed25519Program.createInstructionWithPublicKey({publicKey:Fe(e.Ed25519PublicKey),message:Fe(e.Ed25519Message),signature:Fe(e.SignatureHex)}),p=d.map((g,y)=>rr(n,s[y],g,r,o)),m=new web3_js.TransactionInstruction({programId:a,keys:[{pubkey:ge(a,buffer.Buffer.from("config")),isSigner:false,isWritable:false},{pubkey:n,isSigner:true,isWritable:true},{pubkey:l,isSigner:false,isWritable:true},{pubkey:ge(a,buffer.Buffer.from("nonce"),pe(e.Nonce)),isSigner:false,isWritable:true},{pubkey:r,isSigner:false,isWritable:false},{pubkey:c,isSigner:false,isWritable:false},{pubkey:me(r,l,o),isSigner:false,isWritable:true},{pubkey:me(r,c,o),isSigner:false,isWritable:true},{pubkey:i,isSigner:false,isWritable:false},{pubkey:me(r,i,o),isSigner:false,isWritable:true},{pubkey:web3_js.SYSVAR_INSTRUCTIONS_PUBKEY,isSigner:false,isWritable:false},{pubkey:o,isSigner:false,isWritable:false},{pubkey:Ke,isSigner:false,isWritable:false},{pubkey:web3_js.SystemProgram.programId,isSigner:false,isWritable:false},...s.map(g=>({pubkey:g,isSigner:false,isWritable:true}))],data:or(e)});return [u,...p,m]}function Ge(t){let{connection:e,signTransaction:n}=t;async function o(r){let c=await e.getAccountInfo(r);if(!c)throw new O("MINT_NOT_FOUND",`mint ${r.toBase58()} not found`);return c.owner}async function a(r,c){let{blockhash:l,lastValidBlockHeight:i}=await e.getLatestBlockhash("confirmed"),d=new web3_js.Transaction;d.feePayer=r,d.recentBlockhash=l,d.add(...c);let s=await n(d),u=await e.sendRawTransaction(s.serialize());return await e.confirmTransaction({signature:u,blockhash:l,lastValidBlockHeight:i},"confirmed"),u}return {async depositSpl({mint:r,amountRaw:c,userID:l,titleID:i,category:d}){let s=new web3_js.PublicKey(t.owner),u=new web3_js.PublicKey(r),p=await o(u);return a(s,[ar({programId:new web3_js.PublicKey(t.programId),user:s,mint:u,tokenProgram:p,amountRaw:c,userID:l,titleID:i,category:d})])},async submitWithdrawal(r){if(!r.ProgramID||!r.Mint||!r.WalletAddress)throw new O("BAD_VOUCHER","the voucher has no program, mint or wallet");let c=new web3_js.PublicKey(t.owner),l=new web3_js.PublicKey(r.ProgramID),i=await e.getAccountInfo(ge(l,buffer.Buffer.from("config")));if(!i)throw new O("POOL_NOT_ON_THIS_CLUSTER","the pool's config account is not on this cluster");if(i.data.length!==fn)throw new O("POOL_NOT_MIGRATED",`config is ${i.data.length} bytes, expected ${fn} (migrate_config not run)`);let d=buffer.Buffer.from(i.data);if(d[er]===1)throw new O("POOL_PAUSED","pool withdrawals are paused");let s=d.readBigUInt64LE(wn);if(s!==BigInt(r.SignatureEpoch||0))throw new O("VOUCHER_REVOKED",`signature epoch mismatch: voucher ${r.SignatureEpoch}, on-chain ${s}`);let u=buffer.Buffer.from(Fe(r.Ed25519PublicKey)),p=false;for(let g=0;g<yn;g++){let y=gn+g*32;u.equals(d.subarray(y,y+32))&&(p=true);}if(!p)throw new O("SIGNER_NOT_TRUSTED","the voucher's signer is not in the pool's server_pubkeys");let m=await o(new web3_js.PublicKey(r.Mint));return a(c,[web3_js.ComputeBudgetProgram.setComputeUnitLimit({units:Xo}),...ir({sig:r,payer:c,tokenProgram:m})])}}}var Yo,Qo,Zo,Ke,Jo,fn,Xo,gn,yn,wn,er,O,bt=k(()=>{Yo="e000c6afc62f69cc",Qo="b59a5e563e7306ba",Zo="d668e18c1bdc33f1",Ke=new web3_js.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),Jo="1nc1nerator11111111111111111111111111111111",fn=177,Xo=3e5,gn=40,yn=4,wn=gn+32*yn,er=wn+8,O=class extends Error{constructor(n,o){super(o);this.code=n;this.name="PlatformPoolError";}code};});function gr(t){return (t.ChainID===fr?exports.solanaDevnet:exports.solanaMainnet).rpcUrls.default.http[0]}function hn(t){let{client:e,walletConnectProjectId:n,appName:o,onClose:a,style:r}=t,[c,l]=react.useState(n??"");react.useEffect(()=>{if(n)return;let y=true;return (async()=>{let w=await e.blockchain.getDefinitions();if(!y||!w.ok)return;let W=w.data.Blockchain?.WalletLogin?.WalletConnectProjectId;W&&l(W);})(),()=>{y=false;}},[e,n]);let i=react.useMemo(()=>c?(_e({walletConnectProjectId:c,appName:o}),true):false,[c,o]),{address:d,isConnected:s}=react$1.useAppKitAccount(),{walletProvider:u}=react$1.useAppKitProvider("solana"),p=s&&d?d:null,m=(y,w)=>Ge({connection:new web3_js.Connection(gr(y),"confirmed"),owner:w,programId:y.RewardPoolAddress??"",signTransaction:async W=>{if(!u)throw new Error("Wallet not connected.");return u.signTransaction(W)}});return jsxRuntime.jsx(Be,{client:e,engine:{networkType:"Solana",address:p,connectChoices:i?[{key:"appkit",label:"Connect wallet",connect:()=>{H()?.open();}}]:[],disconnect:()=>{H()?.disconnect("solana");},deposit:async({network:y,binding:w,amount:W})=>{if(!p)return f("deposit-onchain","Wallet not connected.");if(!w.ContractAddress)return f("deposit-onchain","This token cannot be deposited.");if(!y.RewardPoolAddress)return f("deposit-onchain","POOL_NOT_IN_REGISTRY");let A;try{A=viem.parseUnits(W,w.Decimals??9);}catch{return f("deposit-onchain","Invalid amount.")}return Pe({client:e,adapter:m(y,p),network:y,mint:w.ContractAddress,amountRaw:A,titleID:e.titleID})},withdraw:async({network:y,networkID:w,currencyID:W,amount:A})=>p?Se({client:e,adapter:m(y,p),currencyID:W,networkID:w,walletAddress:p,amount:A}):f("request","Wallet not connected.")},onClose:a,style:r})}var fr,kn=k(()=>{Q();Oe();bt();L();ce();mt();ct();fr=103;});var Ct={};Wt(Ct,{PlatformPoolError:()=>O,SolanaWalletLogin:()=>pn,SolanaWalletPanel:()=>hn,createPlatformPoolAdapter:()=>Ge,createSolanaWalletConfig:()=>_e,solanaDevnet:()=>exports.solanaDevnet,solanaMainnet:()=>exports.solanaMainnet,useSolanaBridge:()=>sn});var Pt=k(()=>{mt();ln();mn();kn();bt();Q();});V();L();var $={addressRequest:"IDOS_PLATFORM_WALLET_ADDRESS_REQUEST",addressResponse:"IDOS_PLATFORM_WALLET_ADDRESS_RESPONSE",signRequest:"IDOS_PLATFORM_WALLET_SIGN_REQUEST",signResponse:"IDOS_PLATFORM_WALLET_SIGN_RESPONSE",ack:"IDOS_PLATFORM_WALLET_ACK",openRequest:"IDOS_PLATFORM_WALLET_OPEN_REQUEST",openResponse:"IDOS_PLATFORM_WALLET_OPEN_RESPONSE"},ye="PLATFORM_WALLET_UNAVAILABLE",Nn=5e3,Ln=18e4;function Rn(){let t=[...core.PLATFORM_ORIGINS],e=window.location.ancestorOrigins?.[0];return e&&!t.includes(e)&&core.isPlatformParentOrigin(e)&&t.push(e),t}function Bn(){return `wallet-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function He(t,e,n){if(typeof window>"u"||window.self===window.top)return Promise.resolve({ok:false,error:ye});let o=window.parent;if(!o)return Promise.resolve({ok:false,error:ye});let a=Bn();return new Promise(r=>{let c=false,l,i=s=>{c||(c=true,window.removeEventListener("message",d),clearTimeout(l),r(s));},d=s=>{if(!core.isPlatformParentOrigin(s.origin))return;let u=s.data;if(!(!u||u.requestId!==a)){if(u.type===$.ack){clearTimeout(l),l=setTimeout(()=>i({ok:false,error:"TIMEOUT"}),Ln);return}u.type===e&&i({ok:u.ok===true,error:typeof u.error=="string"?u.error:void 0,address:typeof u.address=="string"?u.address:void 0,signature:typeof u.signature=="string"?u.signature:void 0});}};l=setTimeout(()=>i({ok:false,error:ye}),Nn),window.addEventListener("message",d);for(let s of Rn())try{o.postMessage({type:t,requestId:a,...n},s);}catch{}})}async function _n(){return (await He($.openRequest,$.openResponse,{})).ok}async function Tt(t){let{client:e,networkID:n}=t;return It(t,async o=>{let a=await e.auth.requestWalletChallenge(o,n);return a.ok?{ok:true,message:a.data.Message}:{ok:false,error:a.error}},(o,a)=>e.auth.loginWithWallet(o,n,a))}async function vt(t){let{client:e,networkID:n}=t;return It(t,async o=>{let a=await e.auth.linkWallet(o,n);return a.ok?a.data.Challenge?{ok:true,message:a.data.Challenge}:{ok:false,error:"No challenge was issued."}:{ok:false,error:a.error}},(o,a)=>e.auth.linkWallet(o,n,a))}async function It(t,e,n){let{client:o,family:a}=t,r=o.titleID,c=await He($.addressRequest,$.addressResponse,{titleID:r,family:a});if(!c.ok||!c.address)return b("challenge",c.error??"NO_WALLET");let l=c.address,i=await e(l);if(!i.ok)return b("challenge",i.error);let d=await He($.signRequest,$.signResponse,{titleID:r,family:a,address:l,message:i.message});if(!d.ok||!d.signature)return b("sign",d.error??"SIGN_FAILED");let s=await n(l,d.signature);return s.ok?{ok:true,data:s.data}:b("login",s.error)}var Cn={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},Pn={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};function bn(t){switch(t){case ye:return "Wallet sign-in is not available on this page.";case "NO_WALLET":case "CANCELLED":return "Connect a wallet on the page to sign in.";case "REJECTED":return "The signature was declined.";case "TIMEOUT":return "The wallet did not answer. Please try again.";default:return t}}function hr(t){let{client:e,networkID:n,onAuthenticated:o,onLinked:a,mode:r="login",family:c,disabled:l,label:i,style:d}=t,[s,u]=react.useState(false),[p,m]=react.useState(null);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{u(true),m(null),(async()=>{if(r==="link"){let w=await vt({client:e,networkID:n,family:c});if(w.ok){u(false),a?.(w.data.PlayAccess??null);return}m(bn(w.error)),u(false);return}let y=await Tt({client:e,networkID:n,family:c});if(y.ok){o?.();return}m(bn(y.error)),u(false);})();},disabled:l||s,style:{...Cn,...l||s?{opacity:.6,cursor:"default"}:null,...d},children:s?"Waiting for the wallet\u2026":i??(r==="link"?"Link wallet":"Sign in with wallet")}),p&&jsxRuntime.jsx("span",{role:"alert",style:Pn,children:p})]})}function Sn(t,e){return Ue()?null:jsxRuntime.jsx(hr,{...t,family:e})}function Wn(t){let{loading:e,disabled:n,label:o,style:a,error:r,onClick:c}=t;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:c,disabled:n||e,style:{...Cn,...n||e?{opacity:.6,cursor:"default"}:null,...a},children:e?"Loading wallet\u2026":o??"Sign in with wallet"}),r&&jsxRuntime.jsx("span",{role:"alert",style:Pn,children:r})]})}function kr(t){let{chains:e,walletConnectProjectId:n,appName:o,disabled:a,label:r,style:c,onAuthenticated:l,...i}=t,[d,s]=react.useState(null),[u,p]=react.useState(false),[m,g]=react.useState(null);if(S())return Sn(t,"evm");let y=()=>{p(true),g(null),(async()=>{try{let w=await Promise.resolve().then(()=>(pt(),ut)),W=w.createEvmWalletConfig({chains:e,walletConnectProjectId:n,appName:o});s({mod:w,config:W});}catch(w){console.error("[idosgames/wallet] failed to load the wallet module:",w),g("Could not load the wallet. Please try again.");}finally{p(false);}})();};if(d){let{WalletLogin:w}=d.mod;return jsxRuntime.jsx(w,{...i,onAuthenticated:l??An,wagmiConfig:d.config,disabled:a,label:r,style:c,autoStart:true})}return jsxRuntime.jsx(Wn,{loading:u,disabled:a,label:r??(t.mode==="link"?"Link wallet":void 0),style:c,error:m,onClick:y})}function An(){}function br(t){let{walletConnectProjectId:e,appName:n,disabled:o,label:a,style:r,onAuthenticated:c,...l}=t,[i,d]=react.useState(null),[s,u]=react.useState(false),[p,m]=react.useState(null);if(S())return Sn(t,"solana");let g=()=>{u(true),m(null),(async()=>{try{let y=await Promise.resolve().then(()=>(Pt(),Ct));e&&y.createSolanaWalletConfig({walletConnectProjectId:e,appName:n}),d(y);}catch(y){console.error("[idosgames/wallet] failed to load the wallet module:",y),m("Could not load the wallet. Please try again.");}finally{u(false);}})();};if(i){let{SolanaWalletLogin:y}=i;return jsxRuntime.jsx(y,{...l,onAuthenticated:c??An,disabled:o,label:a,style:r,autoStart:true})}return jsxRuntime.jsx(Wn,{loading:s,disabled:o,label:a??(t.mode==="link"?"Link wallet":void 0),style:r,error:p,onClick:g})}var Cr={pointerEvents:"auto",background:"#04276bf5",border:"1px solid #1e59c8",borderRadius:12,padding:16,color:"#fff",width:320,boxSizing:"border-box",fontFamily:"system-ui, sans-serif",fontSize:13};function Pr(t){let{client:e,onClose:n,style:o}=t,a=S(),[r,c]=react.useState(null),[l,i]=react.useState(null);return react.useEffect(()=>{if(a)return;let d=true;return (async()=>{try{let s=await e.blockchain.getDefinitions(),u=Object.values((s.ok?s.data.Blockchain?.Networks:null)??{}).map(g=>g.Type),m=u.includes("Solana")&&!u.includes("EVM")?{kind:"solana",mod:await Promise.resolve().then(()=>(Pt(),Ct))}:{kind:"evm",mod:await Promise.resolve().then(()=>(pt(),ut))};d&&c(m);}catch(s){console.error("[idosgames/wallet] failed to load the wallet panel:",s),d&&i("Could not load the wallet.");}})(),()=>{d=false;}},[a,e]),a?null:r?.kind==="evm"?jsxRuntime.jsx(r.mod.WalletPanel,{...t}):r?.kind==="solana"?jsxRuntime.jsx(r.mod.SolanaWalletPanel,{...t}):jsxRuntime.jsxs("div",{style:{...Cr,...o},children:[l??"Loading wallet\u2026",n&&jsxRuntime.jsx("button",{type:"button",onClick:n,style:{background:"#1e59c8",color:"#fff",border:"none",borderRadius:8,padding:"7px 12px",fontWeight:600,cursor:"pointer",marginLeft:10},children:"\u2715"})]})}V();Q();
|
|
2
|
-
exports.LazySolanaWalletLogin=
|
|
1
|
+
'use strict';var viem=require('viem'),core=require('@idosgames/core'),wagmi=require('wagmi'),connectors=require('wagmi/connectors'),appkitAdapterWagmi=require('@reown/appkit-adapter-wagmi'),react$1=require('@reown/appkit/react'),reactQuery=require('@tanstack/react-query'),react=require('react'),jsxRuntime=require('react/jsx-runtime'),actions=require('wagmi/actions'),appkitAdapterSolana=require('@reown/appkit-adapter-solana'),buffer=require('buffer'),web3_js=require('@solana/web3.js');var ko=Object.defineProperty;var P=(t,e)=>()=>(t&&(e=t(t=0)),e);var Qt=(t,e)=>{for(var n in e)ko(t,n,{get:e[n],enumerable:true});};function _(t){return t instanceof viem.BaseError?t.shortMessage:t instanceof Error?t.message:String(t)}function g(t,e,n){return {ok:false,stage:t,error:e,...n}}function T(t,e){return {ok:false,stage:t,error:e}}var z=P(()=>{});function Po(t=typeof window>"u"?"":window.location.hostname){let e=t.toLowerCase();return So.test(e)?true:e!=="localhost"&&e!=="127.0.0.1"?false:globalThis.__IDOS_PREVIEW__!=null}function E(){if(typeof window>"u"||Po())return false;try{return window.self!==window.top}catch{return true}}function Ee(){if(typeof window>"u")return false;try{return window.parent!==window.top}catch{return true}}function ee(t){return g(t,Jt)}function me(t){return T(t,Jt)}var Jt,So,te=P(()=>{z();Jt="WALLET_USE_SITE_PANEL",So=/^[a-z0-9]{8}-preview\.idos\.games$/;});function se(t,e=false,n="md"){let[o,r,a]=e?["#8e95b8","#5b6187","#ffffff"]:Xt[t];return {...B,color:a,boxSizing:"border-box",fontFamily:m.font,fontSize:n==="sm"?13:n==="lg"?18:16,border:"none",borderRadius:m.buttonRadius,padding:n==="sm"?"6px 12px":n==="lg"?"13px 22px":"10px 18px",minHeight:n==="sm"?34:n==="lg"?52:44,cursor:e?"default":"pointer",background:`linear-gradient(180deg, ${o} 0%, ${r} 100%)`,boxShadow:`0 4px 0 ${m.edge}, inset 0 2px 0 rgba(255,255,255,.35)`,opacity:e?.75:1,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:8}}function en(t){let[e,n,o]=Xt[t];return {background:`linear-gradient(180deg, ${e} 0%, ${n} 100%)`,color:o,borderRadius:16,boxShadow:`0 4px 0 ${m.edge}, inset 0 2px 0 rgba(255,255,255,.3)`}}function xo(){if(typeof navigator>"u")return false;let t=(navigator.language||"").toLowerCase();return To.some(e=>t.startsWith(e))}function k(t,e){let n=(xo()?Wo:Zt)[t]??Zt[t];for(let[o,r]of Object.entries(e??{}))n=n.replace(`{${o}}`,String(r));return n}var W,m,Xt,B,De,ne,O,To,Zt,Wo,lt=P(()=>{W=(t,e)=>`var(--idos-ui-${t}, ${e})`,m={panel:W("panel","#2c3480"),panelDeep:W("panel-deep","#1d2360"),panelEdge:W("panel-edge","#4f5bc9"),text:W("text","#ffffff"),textDim:W("text-dim","#aeb6f0"),gold:W("gold","#ffd24a"),goldDeep:W("gold-deep","#e89a12"),green:W("green","#59d35b"),greenDeep:W("green-deep","#2b9936"),blue:W("blue","#4fb1ff"),blueDeep:W("blue-deep","#2276d6"),red:W("red","#ff5a5a"),redDeep:W("red-deep","#b83232"),onGreen:W("on-green","#ffffff"),onBlue:W("on-blue","#ffffff"),onGold:W("on-gold","#ffffff"),textOutline:W("text-outline","0 2px 0 rgba(0,0,0,.45), 0 0 1px rgba(0,0,0,.6)"),well:W("well","rgba(8, 10, 40, 0.6)"),wellSoft:W("well-soft","rgba(0, 0, 0, 0.3)"),wellShadow:W("well-shadow","inset 0 2px 4px rgba(0, 0, 0, 0.4)"),edge:W("edge","rgba(0, 0, 0, 0.35)"),line:W("line","rgba(255, 255, 255, 0.2)"),panelShadow:W("panel-shadow","0 6px 0 rgba(4, 6, 30, 0.55), inset 0 2px 0 rgba(255, 255, 255, 0.12)"),radius:W("radius","18px"),buttonRadius:W("button-radius","14px"),font:W("font","'Baloo 2', 'Nunito', 'Trebuchet MS', system-ui, sans-serif"),fast:W("fast","120ms")},Xt={green:[m.green,m.greenDeep,m.onGreen],blue:[m.blue,m.blueDeep,m.onBlue],gold:[m.gold,m.goldDeep,m.onGold],red:[m.red,m.redDeep,"#ffffff"]},B={color:m.text,fontWeight:800,textShadow:m.textOutline,letterSpacing:.2},De={boxSizing:"border-box",background:`linear-gradient(180deg, ${m.panel} 0%, ${m.panelDeep} 100%)`,border:`2px solid ${m.panelEdge}`,borderRadius:m.radius,boxShadow:m.panelShadow},ne={boxSizing:"border-box",background:m.well,border:`2px solid ${m.panelEdge}`,boxShadow:m.wellShadow,borderRadius:14};O={...B,fontSize:13,color:m.textDim},To=["ru","kk","uk","be","ky","uz","tg"];Zt={title:"Wallet",topUpTitle:"Top up to buy",connectHint:"Connect a wallet to deposit and withdraw",connect:"Connect wallet",notConfigured:"Wallet connection is not set up for this app.",disconnect:"Disconnect",balance:"In-game balance",deposit:"Deposit",withdraw:"Withdraw",network:"Network",token:"Token",amount:"Amount",max:"MAX",minWithdraw:"Minimum to withdraw: {n}",noNetworks:"Crypto is not set up for this app yet.",noTokens:"No tokens on this network.",depositing:"Confirm in your wallet\u2026",withdrawing:"Withdrawing\u2026",confirming:"Waiting for the network to confirm\u2026",loading:"Loading\u2026",doneDeposit:"Deposited \u2014 the balance is updated.",doneWithdraw:"Sent to your wallet.",topUpNeed:"This purchase needs",topUpMore:"more",topUpHint:"Deposit it from your wallet \u2014 the purchase completes by itself once it is credited.",topUpCannot:"{name} cannot be deposited here.",depositAmount:"Deposit {amount} {name}",failed:"Did not go through",debited:"The amount is already debited \u2014 retry this withdrawal, do not request a new one.",tx:"Transaction",backed:"Crypto (withdrawable)",unbacked:"IOU (not backed yet)",total:"Total",iouHint:"IOUs spend in the app like crypto, but you can withdraw only the backed part; the developer backs IOUs later.",backedHint:"All of it is real crypto and can be withdrawn."},Wo={title:"\u041A\u043E\u0448\u0435\u043B\u0451\u043A",topUpTitle:"\u041F\u043E\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u0435 \u0434\u043B\u044F \u043F\u043E\u043A\u0443\u043F\u043A\u0438",connectHint:"\u041F\u043E\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u0435 \u043A\u043E\u0448\u0435\u043B\u0451\u043A, \u0447\u0442\u043E\u0431\u044B \u043F\u043E\u043F\u043E\u043B\u043D\u044F\u0442\u044C \u0438 \u0432\u044B\u0432\u043E\u0434\u0438\u0442\u044C",connect:"\u041F\u043E\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u044C \u043A\u043E\u0448\u0435\u043B\u0451\u043A",notConfigured:"\u041F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u0435 \u043A\u043E\u0448\u0435\u043B\u044C\u043A\u0430 \u0434\u043B\u044F \u044D\u0442\u043E\u0433\u043E \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u044F \u043D\u0435 \u043D\u0430\u0441\u0442\u0440\u043E\u0435\u043D\u043E.",disconnect:"\u041E\u0442\u043A\u043B\u044E\u0447\u0438\u0442\u044C",balance:"\u0411\u0430\u043B\u0430\u043D\u0441 \u0432 \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0438",deposit:"\u041F\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u044C",withdraw:"\u0412\u044B\u0432\u0435\u0441\u0442\u0438",network:"\u0421\u0435\u0442\u044C",token:"\u0422\u043E\u043A\u0435\u043D",amount:"\u0421\u0443\u043C\u043C\u0430",max:"\u0412\u0421\u0401",minWithdraw:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C \u0434\u043B\u044F \u0432\u044B\u0432\u043E\u0434\u0430: {n}",noNetworks:"\u041A\u0440\u0438\u043F\u0442\u0430 \u0434\u043B\u044F \u044D\u0442\u043E\u0433\u043E \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u044F \u0435\u0449\u0451 \u043D\u0435 \u043D\u0430\u0441\u0442\u0440\u043E\u0435\u043D\u0430.",noTokens:"\u0412 \u044D\u0442\u043E\u0439 \u0441\u0435\u0442\u0438 \u043D\u0435\u0442 \u0442\u043E\u043A\u0435\u043D\u043E\u0432.",depositing:"\u041F\u043E\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u0435 \u0432 \u043A\u043E\u0448\u0435\u043B\u044C\u043A\u0435\u2026",withdrawing:"\u0412\u044B\u0432\u043E\u0434\u0438\u043C\u2026",confirming:"\u0416\u0434\u0451\u043C \u043F\u043E\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043D\u0438\u044F \u0441\u0435\u0442\u0438\u2026",loading:"\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430\u2026",doneDeposit:"\u041F\u043E\u043F\u043E\u043B\u043D\u0435\u043D\u043E \u2014 \u0431\u0430\u043B\u0430\u043D\u0441 \u043E\u0431\u043D\u043E\u0432\u043B\u0451\u043D.",doneWithdraw:"\u041E\u0442\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u043E \u043D\u0430 \u0432\u0430\u0448 \u043A\u043E\u0448\u0435\u043B\u0451\u043A.",topUpNeed:"\u0414\u043B\u044F \u043F\u043E\u043A\u0443\u043F\u043A\u0438 \u043D\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442",topUpMore:"",topUpHint:"\u041F\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u0435 \u0441 \u043A\u043E\u0448\u0435\u043B\u044C\u043A\u0430 \u2014 \u043F\u043E\u043A\u0443\u043F\u043A\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u0441\u044F \u0441\u0430\u043C\u0430, \u043A\u0430\u043A \u0442\u043E\u043B\u044C\u043A\u043E \u043F\u043E\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u0435 \u0437\u0430\u0447\u0438\u0441\u043B\u0438\u0442\u0441\u044F.",topUpCannot:"{name} \u0437\u0434\u0435\u0441\u044C \u043F\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u044C \u043D\u0435\u043B\u044C\u0437\u044F.",depositAmount:"\u041F\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u044C \u043D\u0430 {amount} {name}",failed:"\u041D\u0435 \u043F\u0440\u043E\u0448\u043B\u043E",debited:"\u0421\u0443\u043C\u043C\u0430 \u0443\u0436\u0435 \u0441\u043F\u0438\u0441\u0430\u043D\u0430 \u2014 \u043F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u0435 \u044D\u0442\u043E\u0442 \u0432\u044B\u0432\u043E\u0434, \u043D\u043E\u0432\u044B\u0439 \u043D\u0435 \u0437\u0430\u043F\u0440\u0430\u0448\u0438\u0432\u0430\u0439\u0442\u0435.",tx:"\u0422\u0440\u0430\u043D\u0437\u0430\u043A\u0446\u0438\u044F",backed:"\u041A\u0440\u0438\u043F\u0442\u0430 (\u043C\u043E\u0436\u043D\u043E \u0432\u044B\u0432\u0435\u0441\u0442\u0438)",unbacked:"\u0420\u0430\u0441\u043F\u0438\u0441\u043A\u0438 (\u043F\u043E\u043A\u0430 \u043D\u0435 \u043E\u0431\u0435\u0441\u043F\u0435\u0447\u0435\u043D\u044B)",total:"\u0412\u0441\u0435\u0433\u043E",iouHint:"\u0420\u0430\u0441\u043F\u0438\u0441\u043A\u0438 \u0442\u0440\u0430\u0442\u044F\u0442\u0441\u044F \u0432 \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0438 \u043A\u0430\u043A \u043A\u0440\u0438\u043F\u0442\u0430, \u043D\u043E \u0432\u044B\u0432\u0435\u0441\u0442\u0438 \u043C\u043E\u0436\u043D\u043E \u0442\u043E\u043B\u044C\u043A\u043E \u043E\u0431\u0435\u0441\u043F\u0435\u0447\u0435\u043D\u043D\u0443\u044E \u0447\u0430\u0441\u0442\u044C; \u0440\u0430\u0437\u0440\u0430\u0431\u043E\u0442\u0447\u0438\u043A \u043E\u0431\u0435\u0441\u043F\u0435\u0447\u0438\u0442 \u0440\u0430\u0441\u043F\u0438\u0441\u043A\u0438 \u043F\u043E\u0437\u0436\u0435.",backedHint:"\u042D\u0442\u043E \u043D\u0430\u0441\u0442\u043E\u044F\u0449\u0430\u044F \u043A\u0440\u0438\u043F\u0442\u0430, \u0435\u0451 \u043C\u043E\u0436\u043D\u043E \u0432\u044B\u0432\u0435\u0441\u0442\u0438 \u0446\u0435\u043B\u0438\u043A\u043E\u043C."};});function dt(t){return Object.values(exports.idosChains).find(e=>e.id===t)}function an(t){return {...t,chainNamespace:"eip155",caipNetworkId:`eip155:${t.id}`}}exports.mainnet=void 0;exports.bsc=void 0;exports.polygon=void 0;exports.base=void 0;exports.arbitrum=void 0;exports.optimism=void 0;exports.sepolia=void 0;exports.polygonAmoy=void 0;exports.idosChains=void 0;exports.solanaMainnet=void 0;exports.solanaDevnet=void 0;var ce=P(()=>{exports.mainnet={id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://eth.llamarpc.com"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io"}}},exports.bsc={id:56,name:"BNB Smart Chain",nativeCurrency:{name:"BNB",symbol:"BNB",decimals:18},rpcUrls:{default:{http:["https://bsc-dataseed.binance.org"]}},blockExplorers:{default:{name:"BscScan",url:"https://bscscan.com"}}},exports.polygon={id:137,name:"Polygon",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://polygon-rpc.com"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://polygonscan.com"}}},exports.base={id:8453,name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.base.org"]}},blockExplorers:{default:{name:"BaseScan",url:"https://basescan.org"}}},exports.arbitrum={id:42161,name:"Arbitrum One",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://arbiscan.io"}}},exports.optimism={id:10,name:"OP Mainnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.optimism.io"]}},blockExplorers:{default:{name:"Optimistic Etherscan",url:"https://optimistic.etherscan.io"}}},exports.sepolia={id:11155111,name:"Sepolia",testnet:true,nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.sepolia.org"]}},blockExplorers:{default:{name:"Etherscan",url:"https://sepolia.etherscan.io"}}},exports.polygonAmoy={id:80002,name:"Polygon Amoy",testnet:true,nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://rpc-amoy.polygon.technology"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://amoy.polygonscan.com"}}},exports.idosChains={mainnet:exports.mainnet,bsc:exports.bsc,polygon:exports.polygon,base:exports.base,arbitrum:exports.arbitrum,optimism:exports.optimism,sepolia:exports.sepolia,polygonAmoy:exports.polygonAmoy};exports.solanaMainnet={id:"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",name:"Solana",network:"solana-mainnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://api.mainnet-beta.solana.com"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:false,chainNamespace:"solana",caipNetworkId:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"},exports.solanaDevnet={id:"EtWTRABZaYq6iMfeYKouRu166VU2xqa1",name:"Solana Devnet",network:"solana-devnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://api.devnet.solana.com"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:true,chainNamespace:"solana",caipNetworkId:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"};});function Ge(t){sn=t;}function oe(){return sn}var sn,Pe=P(()=>{sn=null;});function ze(t){let{chains:e=ut,walletConnectProjectId:n,appName:o,appUrl:r,appIcon:a,transports:s,connectors:l}=t,i=n??"__extension_only__";if(!l){let h=pt.get(i);if(h)return h}let d={};for(let h of e)d[h.id]=s?.[h.id]??wagmi.http();let c=r??(typeof window<"u"?window.location.origin:""),p={name:o??"iDosGames",description:o??"iDosGames game",url:c,icons:a?[a]:[]};if(n&&!l){let h=e.map(an),w=new appkitAdapterWagmi.WagmiAdapter({networks:h,projectId:n,transports:d});return Ge(react$1.createAppKit({adapters:[w],networks:h,projectId:n,metadata:p,features:{analytics:false,email:false,socials:false}})),pt.set(i,w.wagmiConfig),w.wagmiConfig}let u=l??[connectors.injected(),connectors.coinbaseWallet({appName:o??"iDosGames"})],b=wagmi.createConfig({chains:e,connectors:u,transports:d});return l||pt.set(i,b),b}var ut,pt,mt=P(()=>{ce();Pe();ut=[exports.mainnet,exports.bsc,exports.polygon,exports.base,exports.arbitrum,exports.optimism,exports.sepolia,exports.polygonAmoy],pt=new Map;});function Te(t){let{wagmiConfig:e,queryClient:n,children:o}=t,[r]=react.useState(()=>n??new reactQuery.QueryClient);return jsxRuntime.jsx(wagmi.WagmiProvider,{config:e,children:jsxRuntime.jsx(reactQuery.QueryClientProvider,{client:r,children:o})})}var qe=P(()=>{});var $e,cn,Re,dn,Ve=P(()=>{$e=[{type:"function",name:"depositERC20",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"amount",type:"uint256"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"withdrawERC20",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"amount",type:"uint256"},{name:"burnAmount",type:"uint256"},{name:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{name:"amount",type:"uint256"}]},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC1155",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{name:"amount",type:"uint256"}]},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC721",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"tokenId",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]}],cn=[{type:"function",name:"withdrawERC1155Mint",stateMutability:"nonpayable",inputs:[{name:"collection",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{name:"amount",type:"uint256"}]},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC721Mint",stateMutability:"nonpayable",inputs:[{name:"collection",type:"address"},{name:"to",type:"address"},{name:"tokenId",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]}],Re=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{name:"",type:"uint8"}]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{name:"",type:"uint256"}]}],dn=[{type:"function",name:"safeTransferFrom",stateMutability:"nonpayable",inputs:[{name:"from",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"data",type:"bytes"}],outputs:[]},{type:"function",name:"isApprovedForAll",stateMutability:"view",inputs:[{name:"account",type:"address"},{name:"operator",type:"address"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"setApprovalForAll",stateMutability:"nonpayable",inputs:[{name:"operator",type:"address"},{name:"approved",type:"bool"}],outputs:[]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"},{name:"id",type:"uint256"}],outputs:[{name:"",type:"uint256"}]}];});function pn(t,e,n){return viem.encodeAbiParameters([{type:"string"},{type:"string"},{type:"string"}],[t,e,core.normalizeBlockchainCategory(n)])}var un=P(()=>{});async function de(t,e){let{walletClient:n,publicClient:o,account:r}=t,a=await n.writeContract({address:e.address,abi:e.abi,functionName:e.functionName,args:e.args,account:r,chain:n.chain,value:e.value});if((await o.waitForTransactionReceipt({hash:a})).status==="reverted")throw new Error(`On-chain transaction reverted (${a}).`);return a}var ft=P(()=>{});function mn(t){let e=t.RewardPoolAddress;return e||null}async function fn(t,e,n,o){return await t.publicClient.readContract({address:e,abi:Re,functionName:"allowance",args:[t.account,n]})>=o?null:de(t,{address:e,abi:Re,functionName:"approve",args:[n,o]})}async function gt(t){let{client:e,clients:n,network:o,tokenAddress:r,amount:a,titleID:s,category:l}=t;if(E())return ee("approve");let i=e.auth.context?.userID;if(!i)return g("approve","Not logged in.");let d=mn(o);if(!d)return g("approve","Network has no RewardPoolAddress.");if(a<=0n)return g("approve","Amount must be positive.");try{await fn(n,r,d,a);}catch(u){return g("approve",_(u))}let c;try{c=await de(n,{address:d,abi:$e,functionName:"depositERC20",args:[r,a,i,s,l??""]});}catch(u){return g("deposit-onchain",_(u))}let p=await e.blockchain.depositToken(o.NetworkID??"",c);return p.ok?{ok:true,onChainTxHash:c,data:p.data}:g("report",p.error,{onChainTxHash:c})}async function yt(t){let{client:e,clients:n,network:o,nftContractAddress:r,tokenId:a,amount:s,titleID:l,category:i}=t;if(E())return ee("deposit-onchain");let d=e.auth.context?.userID;if(!d)return g("deposit-onchain","Not logged in.");let c=mn(o);if(!c)return g("deposit-onchain","Network has no RewardPoolAddress.");if(s<=0n)return g("deposit-onchain","Amount must be positive.");let p=pn(d,l,i),u;try{u=await de(n,{address:r,abi:dn,functionName:"safeTransferFrom",args:[n.account,c,a,s,p]});}catch(h){return g("deposit-onchain",_(h))}let b=await e.blockchain.depositNFT(o.NetworkID??"",u);return b.ok?{ok:true,onChainTxHash:u,data:b.data}:g("report",b.error,{onChainTxHash:u})}var gn=P(()=>{Ve();un();ft();z();te();});function yn(t){return (t.Splits??[]).map(e=>({to:e.To,amount:BigInt(e.Amount??"0")}))}async function wn(t,e){return de(t,{address:e.ContractAddress,abi:$e,functionName:"withdrawERC20",args:[e.TokenAddress,e.WalletAddress,BigInt(e.Amount??"0"),BigInt(e.BurnAmount??"0"),yn(e),BigInt(e.Nonce??"0"),e.Signature??"0x",e.UserID??"",e.TitleID??"",e.Category??"",BigInt(e.Deadline??"0")]})}async function hn(t,e){return de(t,{address:e.ContractAddress,abi:cn,functionName:"withdrawERC1155Mint",args:[e.TokenAddress,e.WalletAddress,BigInt(e.TokenId??"0"),BigInt(e.Amount??"0"),yn(e),BigInt(e.Nonce??"0"),e.Signature??"0x",e.UserID??"",e.TitleID??"",e.Category??"",BigInt(e.Deadline??"0")]})}async function wt(t){let{client:e,clients:n,currencyID:o,networkID:r,walletAddress:a,amount:s,category:l}=t;if(E())return ee("request");let i=await e.blockchain.requestTokenWithdrawal(o,r,a,s,l);if(!i.ok)return g("request",i.error);let d=i.data.EvmSignature,c=i.data.TitleTransactionID??void 0;if(!d)return g("request","Withdrawal response carried no EVM signature.",{titleTransactionID:c});let p;try{p=await wn(n,d);}catch(b){return g("withdraw-onchain",_(b),{titleTransactionID:c})}let u=await bn(e,c,p);return u.ok?{ok:true,onChainTxHash:p,data:i.data}:u}async function ht(t){let{client:e,clients:n,itemID:o,networkID:r,walletAddress:a,amount:s,category:l}=t;if(E())return ee("request");let i=await e.blockchain.requestNFTWithdrawal(o,r,a,s,l);if(!i.ok)return g("request",i.error);let d=i.data.EvmSignature,c=i.data.TitleTransactionID??void 0;if(!d)return g("request","Withdrawal response carried no EVM signature.",{titleTransactionID:c});let p;try{p=await hn(n,d);}catch(b){return g("withdraw-onchain",_(b),{titleTransactionID:c})}let u=await bn(e,c,p);return u.ok?{ok:true,onChainTxHash:p,data:i.data}:u}async function bn(t,e,n){if(!e)return g("confirm","Missing TitleTransactionID.",{onChainTxHash:n});let o=await t.blockchain.confirmWithdrawal(e,n);return o.ok?{ok:true,onChainTxHash:n,data:o.data}:g("confirm",o.error,{onChainTxHash:n,titleTransactionID:e})}var kn=P(()=>{Ve();ft();z();te();});async function Le(t){let{client:e,clients:n,networkID:o}=t;if(E())return me("challenge");let r=t.walletAddress??n.account,a=await e.auth.requestWalletChallenge(r,o);if(!a.ok)return T("challenge",a.error);let s;try{s=await n.walletClient.signMessage({account:n.account,message:a.data.Message});}catch(i){return T("sign",_(i))}let l=await e.auth.loginWithWallet(r,o,s);return l.ok?{ok:true,data:l.data}:T("login",l.error)}async function bt(t){let{client:e,clients:n,networkID:o}=t;if(E())return me("challenge");let r=t.walletAddress??n.account,a=await e.auth.linkWallet(r,o);if(!a.ok)return T("challenge",a.error);if(!a.data.Challenge)return T("challenge","No challenge was issued.");let s;try{s=await n.walletClient.signMessage({account:n.account,message:a.data.Challenge});}catch(i){return T("sign",_(i))}let l=await e.auth.linkWallet(r,o,s);return l.ok?{ok:true,data:l.data}:T("login",l.error)}var Cn=P(()=>{z();te();});var kt=P(()=>{gn();kn();Cn();});function Oe(){let{address:t}=wagmi.useAccount(),e=wagmi.usePublicClient(),{data:n}=wagmi.useWalletClient();return !t||!e||!n?null:{account:t,publicClient:e,walletClient:n}}function je(t,e){let n=Oe();return {connected:!!n,account:n?.account??null,loginWithWallet:(o,r)=>n?Le({client:t,clients:n,networkID:o,walletAddress:r}):Promise.resolve(T("challenge",Be)),depositToken:o=>n?gt({client:t,clients:n,titleID:e,...o}):Promise.resolve(g("approve",Be)),depositNft:o=>n?yt({client:t,clients:n,titleID:e,...o}):Promise.resolve(g("deposit-onchain",Be)),withdrawToken:o=>n?wt({client:t,clients:n,...o}):Promise.resolve(g("withdraw-onchain",Be)),withdrawNft:o=>n?ht({client:t,clients:n,...o}):Promise.resolve(g("withdraw-onchain",Be))}}var Be,Ye=P(()=>{kt();z();Be="Wallet not connected.";});function In(t){let{wagmiConfig:e,...n}=t;return jsxRuntime.jsx(Te,{wagmiConfig:e,children:jsxRuntime.jsx(St,{...n})})}function Zo(t){return t instanceof Error&&(t.name==="ConnectorAlreadyConnectedError"||t.message.includes("already connected"))}function Xo(t){let e="Wallet sign-in failed. Please try again.";return t instanceof Error?t.name==="ProviderNotFoundError"||/provider not found/i.test(t.message)?"No crypto wallet found in this browser. Install a wallet extension (e.g. MetaMask) or open this page in your wallet's browser, then try again.":t.name==="UserRejectedRequestError"||/user (rejected|denied|cancelled|canceled)/i.test(t.message)?"Request declined in the wallet.":/timed? ?out/i.test(t.message)?"The wallet did not respond. Open your wallet and try again.":e:e}async function Tn(t){let e=await actions.getWalletClient(t).catch(()=>null);if(!e)return null;let n=actions.getPublicClient(t);return n?{account:e.account.address,publicClient:n,walletClient:e}:null}function er(t,e=18e4){return actions.getAccount(t).isConnected?Promise.resolve(true):new Promise(n=>{let o=false,r=l=>{o||(o=true,a(),clearTimeout(s),n(l));},a=actions.watchAccount(t,{onChange:l=>{l.isConnected&&r(true);}}),s=setTimeout(()=>r(false),e);})}function tr(t,e=8e3){let n=o=>o==="reconnecting"||o==="connecting";return n(actions.getAccount(t).status)?new Promise(o=>{let r=false,a=()=>{r||(r=true,s(),clearTimeout(l),o());},s=actions.watchAccount(t,{onChange:i=>{n(i.status)||a();}}),l=setTimeout(a,e);}):Promise.resolve()}function nr(t){let e=r=>t.find(a=>a.id===r||a.type===r),n=e("injected"),o=typeof window<"u"&&window.ethereum!=null;return n&&o?n:e("walletConnect")??n??t[0]}async function or(t){try{let o=(await actions.getAccount(t).connector?.getProvider?.())?.session?.peer?.metadata?.redirect,r=o?.native||o?.universal;return !r||typeof window>"u"?!1:(window.location.href=r,!0)}catch{return false}}function Wn(t,e){return new Promise((n,o)=>{let r=setTimeout(()=>o(new Error("The wallet request timed out.")),e);t.then(a=>{clearTimeout(r),n(a);},a=>{clearTimeout(r),o(a instanceof Error?a:new Error(String(a)));});})}function St(t){let{client:e,networkID:n,onAuthenticated:o,disabled:r,label:a,style:s,autoStart:l,mode:i="login",onLinked:d}=t,c=wagmi.useConfig(),{isConnected:p}=wagmi.useAccount(),{connectAsync:u,connectors:b}=wagmi.useConnect(),h=Oe(),[w,f]=react.useState(false),[A,S]=react.useState(null),[R,M]=react.useState(false),V=react.useRef(0),Z=react.useRef(false),q=async()=>{let re=++V.current,F=()=>V.current===re;f(true),S(null);try{if(await tr(c),!F())return;if(!actions.getAccount(c).isConnected){let v=oe();if(v){if(await v.open(),!await er(c)){S("No wallet was connected.");return}}else {let Y=nr(b);if(!Y){S("No wallet connector is configured.");return}try{await u({connector:Y});}catch(G){if(!Zo(G))throw G}}}let D=h??await Tn(c);if(!D&&actions.getAccount(c).isConnected&&(await new Promise(v=>setTimeout(v,300)),D=await Tn(c),!F()))return;if(!D){S("Wallet client is not available.");return}if(M(!0),i==="link"){let v=await Wn(bt({client:e,clients:D,networkID:n}),xn);if(!F())return;if(v.ok){d?.(v.data.PlayAccess??null);return}S(v.stage==="sign"?"Signature declined.":core.authErrorText(v.error,"Could not link the wallet."));return}let H=await Wn(Le({client:e,clients:D,networkID:n}),xn);if(!F())return;if(H.ok){o();return}S(H.stage==="sign"?"Signature declined.":core.authErrorText(H.error,"Wallet sign-in failed."));}catch(D){if(!F())return;console.error("[idosgames/wallet] wallet sign-in failed:",D),S(Xo(D));}finally{F()&&(f(false),M(false));}};react.useEffect(()=>{!l||Z.current||(Z.current=true,q());},[l]);let ae=async()=>{await or(c)||await oe()?.open();};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{R?ae():q();},disabled:r,style:{...rr,...r?{opacity:.6,cursor:"default"}:null,...s},children:R?"Waiting for signature \u2014 tap to open wallet":w?"Check your wallet\u2026":p?a??(i==="link"?"Link wallet":"Sign in with wallet"):"Connect wallet"}),A&&jsxRuntime.jsx("span",{role:"alert",style:ar,children:A})]})}var xn,rr,ar,vn=P(()=>{Pe();kt();qe();Ye();xn=9e4;rr={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},ar={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};});function mr(t,e){let n=Math.max(0,Math.floor(e||0)),[o="0",r=""]=t.split(".");if(r.length<=n)return t;let a=r.slice(0,n),s=BigInt(o+a)+(/^0*$/.test(r.slice(n))?BigInt(0):BigInt(1));if(n===0)return s.toString();let l=s.toString().padStart(n+1,"0");return `${l.slice(0,-n)}.${l.slice(-n)}`.replace(/\.?0+$/,"")}function xt(t,e=6){let n=Number(t);return Number.isFinite(n)?n.toLocaleString("en-US",{maximumFractionDigits:Math.max(0,e)}).replace(/,/g," "):String(t)}function Je({client:t,engine:e,onClose:n,style:o,topUp:r}){let[,a]=react.useReducer(C=>C+1,0),[s,l]=react.useState(false),[i,d]=react.useState({}),[c,p]=react.useState({}),[u,b]=react.useState("deposit"),[h,w]=react.useState(""),[f,A]=react.useState(""),[S,R]=react.useState(""),[M,V]=react.useState(false),[Z,q]=react.useState(null),[ae,re]=react.useState(false);react.useEffect(()=>{let C=true;return (async()=>{let[L]=await Promise.all([t.blockchain.getDefinitions(),t.cache.ensureState(["InventoryV2","Blockchain"])]);if(!C||(l(true),!L.ok))return;let N={};for(let[Q,ie]of Object.entries(L.data.Blockchain?.Networks??{}))ie.Type===e.networkType&&(N[Q]=ie);d(N);let ue=L.data.CryptoCurrencies??{};p(ue);let ve=r?ue[r.currencyID]?.Networks?.find(Q=>!!Q.NetworkID&&!!N[Q.NetworkID]&&!!Q.ContractAddress&&Q.DepositsEnabled!==false&&N[Q.NetworkID]?.DepositsEnabled!==false)?.NetworkID:null;w(ve??Object.keys(N)[0]??"");})(),()=>{C=false;}},[t,e.networkType]),react.useEffect(()=>t.on("user:anyUpdated",a),[t]);let F=react.useMemo(()=>Object.entries(c).filter(([,C])=>C.Networks?.some(L=>L.NetworkID===h&&!!L.ContractAddress)),[c,h]);react.useEffect(()=>{let C=F[0]?.[0]??"";A(L=>r?r.currencyID:F.some(([N])=>N===L)?L:C);},[F,r]);let D=h?i[h]:void 0,H=f?c[f]:void 0,v=H?.Networks?.find(C=>C.NetworkID===h),Y=f?t.data.user.getCryptoCurrencyAmount(f):"0",G=H?.DisplayName??f,X=f?H?.UnbackedRewardCurrencyID||`${f}_IOU`:"",uo=X&&Number(t.data.user.state?.InventoryV2?.VirtualCurrencies?.[X]?.Amount??0)||0,mo=!!X&&t.data.user.state?.InventoryV2?.VirtualCurrencies?.[X]!=null,Gt=H?.DisplayDecimals??6,He=!!e.address,zt=!!r&&!!v?.ContractAddress&&f===r.currencyID,rt=r&&v?mr(r.amount,v.Decimals??18):"",at=r?c[r.currencyID]?.DisplayName??r.currencyID:"",qt=Number(v?.MinWithdraw??0);async function it(C,L){V(true),q(null);try{let N=await L();return q({tab:C,res:N}),N.ok&&R(""),N}finally{V(false);}}async function $t(C){let L=await Vt();if(!L)return g("approve",k("noNetworks"));let N=await e.deposit({...C,network:L});if(N.ok||N.stage!=="report"||!N.onChainTxHash)return N;let ue=N.onChainTxHash,ve=N.error;re(true);try{for(let Q=1;Q<=pr&&dr.test(ve);Q++){await new Promise(bo=>setTimeout(bo,ur));let ie=await t.blockchain.depositToken(h,ue);if(ie.ok)return {ok:!0,onChainTxHash:ue,data:ie.data};if(/^Transaction hash already used/.test(ie.error))return await t.cache.ensureState(["InventoryV2"],{force:!0}),{ok:!0,onChainTxHash:ue,data:null};ve=ie.error;}}finally{re(false);}return {...N,error:ve}}async function Vt(){let C=await t.blockchain.getDefinitions({forceRefresh:true});return C.ok?C.data.Blockchain?.Networks?.[h]??null:null}async function fo(){let C=await Vt();return C?e.withdraw({network:C,networkID:h,currencyID:f,amount:S}):g("request",k("noNetworks"))}let st=ae?k("confirming"):u==="withdraw"&&!r?k("withdrawing"):k("depositing"),go=He?jsxRuntime.jsxs("div",{style:{...ne,display:"flex",alignItems:"center",gap:10,padding:"8px 8px 8px 12px"},children:[jsxRuntime.jsx("span",{style:yr,"aria-hidden":true}),jsxRuntime.jsxs("div",{style:{display:"grid",flex:1,minWidth:0},children:[jsxRuntime.jsx("span",{style:{...B,fontSize:15,fontFamily:"ui-monospace, Consolas, monospace"},children:Nn(e.address)}),D?jsxRuntime.jsx("span",{style:{...O,fontSize:12},children:D.DisplayName??h}):null]}),jsxRuntime.jsx("button",{type:"button",className:"idos-press",style:wr,onClick:e.disconnect,children:k("disconnect")})]}):jsxRuntime.jsxs("div",{style:{display:"grid",gap:8},children:[jsxRuntime.jsx("span",{style:O,children:k("connectHint")}),e.connectChoices.length===0?jsxRuntime.jsx("div",{style:{...ne,padding:"10px 12px",...O},children:k("notConfigured")}):e.connectChoices.length===1?jsxRuntime.jsx("button",{type:"button",className:"idos-press",style:{...se("blue",false,"lg"),width:"100%"},onClick:e.connectChoices[0].connect,children:k("connect")}):e.connectChoices.map(C=>jsxRuntime.jsxs("button",{type:"button",className:"idos-press",style:hr,onClick:C.connect,children:[jsxRuntime.jsx("span",{style:{flex:1,textAlign:"left"},children:C.label}),jsxRuntime.jsx("span",{"aria-hidden":true,style:{color:m.textDim},children:"\u203A"})]},C.key))]}),jt=f?jsxRuntime.jsx(Sr,{icon:jsxRuntime.jsx(Cr,{assets:H?.AssetPaths,name:G}),name:G,backed:Number(Y)||0,unbacked:uo,hasIou:mo,decimals:Gt}):null,yo=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[Object.keys(i).length>1?jsxRuntime.jsx(Dn,{caption:k("network"),value:h,onChange:w,options:Object.entries(i).map(([C,L])=>[C,L.DisplayName??C])}):null,F.length===0?jsxRuntime.jsx("div",{style:{...ne,padding:"10px 12px",...O},children:k("noTokens")}):F.length>1?jsxRuntime.jsx(Dn,{caption:k("token"),value:f,onChange:A,options:F.map(([C,L])=>[C,L.DisplayName??C])}):null]}),wo=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Pr,{value:u,onChange:C=>{b(C),q(null),R("");}}),yo,jsxRuntime.jsxs("div",{style:{display:"grid",gap:6},children:[jsxRuntime.jsx("span",{style:O,children:k("amount")}),jsxRuntime.jsxs("div",{style:{...ne,display:"flex",alignItems:"center",gap:8,padding:"4px 6px 4px 14px"},children:[jsxRuntime.jsx("input",{style:kr,inputMode:"decimal",placeholder:"0.0",value:S,onChange:C=>R(C.target.value.replace(",","."))}),jsxRuntime.jsx("span",{style:{...O,fontSize:14},children:G}),u==="withdraw"&&Number(Y)>0?jsxRuntime.jsx("button",{type:"button",className:"idos-press",style:se("gold",false,"sm"),onClick:()=>R(String(Y)),children:k("max")}):null]}),u==="withdraw"&&qt>0?jsxRuntime.jsx("span",{style:{...O,fontSize:12},children:k("minWithdraw",{n:xt(qt,Gt)})}):null]}),u==="deposit"?jsxRuntime.jsx(Tt,{tone:"green",busy:M,busyText:st,disabled:!He||!v?.ContractAddress||!En(S),onClick:()=>{!D||!v||it("deposit",()=>$t({network:D,binding:v,currencyID:f,amount:S}));},children:k("deposit")}):jsxRuntime.jsx(Tt,{tone:"blue",busy:M,busyText:st,disabled:!He||!f||!En(S),onClick:()=>{D&&it("withdraw",()=>fo());},children:k("withdraw")})]}),ho=r?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:{...en("gold"),padding:"12px 14px",display:"grid",gap:4},children:zt?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{style:{...B,color:"inherit",fontSize:13,opacity:.9},children:k("topUpNeed")}),jsxRuntime.jsxs("span",{style:{...B,color:"inherit",fontSize:24,lineHeight:1.1},children:[rt," ",at," ",k("topUpMore")]}),jsxRuntime.jsx("span",{style:{fontSize:13,fontWeight:600,opacity:.95},children:k("topUpHint")})]}):jsxRuntime.jsx("span",{style:{...B,color:"inherit",fontSize:15},children:s?k("topUpCannot",{name:at}):k("loading")})}),jt,jsxRuntime.jsx(Tt,{tone:"green",busy:M,busyText:st,disabled:!He||!zt,onClick:()=>{!D||!v||it("deposit",()=>$t({network:D,binding:v,currencyID:f,amount:rt})).then(C=>{C.ok&&r.onDone(true);});},children:k("depositAmount",{amount:rt,name:at})})]}):null,Yt=!!n;return jsxRuntime.jsxs("div",{style:{...gr,...Yt?{...De,padding:16,width:360,maxWidth:"100%",maxHeight:"80vh",overflow:"auto"}:{},...o},children:[jsxRuntime.jsx("style",{children:fr}),Yt?jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[jsxRuntime.jsx("span",{style:{...B,fontSize:20},children:r?k("topUpTitle"):k("title")}),jsxRuntime.jsx("button",{type:"button",className:"idos-press",style:br,onClick:n,"aria-label":"\u2715",children:"\u2715"})]}):null,go,s?Object.keys(i).length===0?jsxRuntime.jsx("div",{style:{...ne,padding:"12px 14px",...O},children:k("noNetworks")}):r?ho:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jt,wo]}):jsxRuntime.jsx("div",{style:{...O,textAlign:"center",padding:12},children:k("loading")}),Z?jsxRuntime.jsx(Tr,{tab:Z.tab,result:Z.res}):null]})}function Cr({assets:t,name:e}){let n=t?.Default||t?.Icon||"",o={width:40,height:40,borderRadius:"50%",flex:"none",display:"grid",placeItems:"center",background:`linear-gradient(180deg, ${m.gold}, ${m.goldDeep})`,boxShadow:`0 3px 0 ${m.edge}`,overflow:"hidden",fontSize:22};return /^(https?:)?\/\/|^\//.test(n)?jsxRuntime.jsx("span",{style:o,children:jsxRuntime.jsx("img",{src:n,alt:"",style:{width:"100%",height:"100%",objectFit:"cover"}})}):jsxRuntime.jsx("span",{style:{...o,...B,fontSize:20},"aria-hidden":true,children:(e.trim()[0]??"?").toUpperCase()})}function Sr({icon:t,name:e,backed:n,unbacked:o,hasIou:r,decimals:a}){let[s,l]=react.useState(false),i=(d,c,p=false)=>jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:16},children:[jsxRuntime.jsx("span",{style:{...O,fontSize:13},children:d}),jsxRuntime.jsx("span",{style:{...B,fontSize:14,color:p?m.textDim:m.text},children:xt(c,a)})]});return jsxRuntime.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),children:[jsxRuntime.jsxs("button",{type:"button","aria-expanded":s,onClick:()=>l(d=>!d),onBlur:()=>l(false),style:{...ne,display:"flex",alignItems:"center",gap:12,padding:"10px 14px",width:"100%",cursor:"pointer",font:"inherit",textAlign:"left"},children:[t,jsxRuntime.jsxs("span",{style:{display:"grid",minWidth:0,flex:1},children:[jsxRuntime.jsx("span",{style:{...O,fontSize:12},children:k("balance")}),jsxRuntime.jsxs("span",{style:{...B,fontSize:22,lineHeight:1.1},children:[xt(n+o,a)," ",jsxRuntime.jsx("span",{style:{fontSize:15,color:m.textDim},children:e})]})]}),jsxRuntime.jsx("span",{"aria-hidden":true,style:{...O,fontSize:16},children:"\u24D8"})]}),s?jsxRuntime.jsxs("div",{role:"tooltip",style:{...De,position:"absolute",left:0,right:0,top:"calc(100% + 6px)",zIndex:5,padding:"10px 12px",display:"grid",gap:6},children:[i(k("backed"),n),r?i(k("unbacked"),o,o===0):null,jsxRuntime.jsx("div",{style:{height:1,background:m.line}}),i(k("total"),n+o),jsxRuntime.jsx("span",{style:{fontSize:12,color:m.textDim,lineHeight:1.35},children:r?k("iouHint"):k("backedHint")})]}):null]})}function Pr({value:t,onChange:e}){let n=[["deposit",k("deposit")],["withdraw",k("withdraw")]];return jsxRuntime.jsx("div",{role:"tablist",style:{display:"flex",gap:6,padding:4,borderRadius:16,background:m.wellSoft},children:n.map(([o,r])=>{let a=o===t;return jsxRuntime.jsx("button",{role:"tab","aria-selected":a,type:"button",className:"idos-press",onClick:()=>!a&&e(o),style:{...B,fontFamily:m.font,fontSize:15,flex:1,border:"none",borderRadius:12,padding:"9px 14px",cursor:"pointer",color:a?m.onBlue:m.textDim,background:a?`linear-gradient(180deg, ${m.blue}, ${m.blueDeep})`:"transparent",boxShadow:a?`0 3px 0 ${m.edge}, inset 0 2px 0 rgba(255,255,255,.3)`:"none",transition:`background ${m.fast} ease`},children:r},o)})})}function Dn({caption:t,value:e,onChange:n,options:o}){return jsxRuntime.jsxs("label",{style:{display:"grid",gap:6},children:[jsxRuntime.jsx("span",{style:O,children:t}),jsxRuntime.jsxs("span",{style:{position:"relative",display:"block"},children:[jsxRuntime.jsx("select",{value:e,onChange:r=>n(r.target.value),style:{...ne,...B,fontFamily:m.font,fontSize:15,width:"100%",padding:"10px 36px 10px 12px",appearance:"none",WebkitAppearance:"none",cursor:"pointer",outline:"none"},children:o.map(([r,a])=>jsxRuntime.jsx("option",{value:r,style:{color:"#111"},children:a},r))}),jsxRuntime.jsx("span",{"aria-hidden":true,style:{position:"absolute",right:14,top:"50%",transform:"translateY(-50%)",color:m.textDim,pointerEvents:"none"},children:"\u25BE"})]})]})}function Tt({tone:t,busy:e,busyText:n,disabled:o,onClick:r,children:a}){return jsxRuntime.jsx("button",{type:"button",className:"idos-press",disabled:o||e,onClick:r,style:{...se(t,o&&!e,"lg"),width:"100%"},children:e?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{"aria-hidden":true,style:{width:18,height:18,borderRadius:"50%",border:"3px solid rgba(255,255,255,.35)",borderTopColor:"#fff",animation:"idosw-spin .8s linear infinite"}}),n]}):a})}function Tr({tab:t,result:e}){let n=e.ok,o={borderRadius:14,padding:"10px 12px",display:"grid",gap:4,background:`color-mix(in srgb, ${n?m.green:m.red} 22%, transparent)`,border:`2px solid color-mix(in srgb, ${n?m.green:m.red} 60%, transparent)`,wordBreak:"break-word"};return n?jsxRuntime.jsxs("div",{style:o,role:"status",children:[jsxRuntime.jsxs("span",{style:{...B,fontSize:15},children:["\u2713 ",t==="withdraw"?k("doneWithdraw"):k("doneDeposit")]}),jsxRuntime.jsxs("span",{style:{...O,fontSize:12},children:[k("tx"),": ",Nn(e.onChainTxHash)]})]}):jsxRuntime.jsxs("div",{style:o,role:"alert",children:[jsxRuntime.jsxs("span",{style:{...B,fontSize:15},children:["\u2715 ",k("failed")]}),jsxRuntime.jsx("span",{style:{fontSize:13,color:m.text,opacity:.9},children:e.error}),e.titleTransactionID?jsxRuntime.jsx("span",{style:{...O,fontSize:12},children:k("debited")}):null]})}var dr,pr,ur,Nn,En,fr,gr,yr,wr,hr,br,kr,Wt=P(()=>{z();lt();dr=/^(Not enough confirmations|Transaction not found on chain)/,pr=8,ur=5e3;Nn=t=>t.length>14?`${t.slice(0,6)}\u2026${t.slice(-4)}`:t,En=t=>/^\d+(\.\d+)?$/.test(t)&&Number(t)>0;fr="@keyframes idosw-spin { to { transform: rotate(360deg) } }",gr={pointerEvents:"auto",color:m.text,fontFamily:m.font,display:"flex",flexDirection:"column",gap:12,boxSizing:"border-box",width:"100%",minWidth:0,maxWidth:"100%"},yr={width:10,height:10,borderRadius:"50%",background:m.green,boxShadow:`0 0 0 3px color-mix(in srgb, ${m.green} 30%, transparent)`,flex:"none"},wr={...B,fontFamily:m.font,fontSize:13,color:m.textDim,background:"transparent",border:`2px solid ${m.line}`,borderRadius:10,padding:"5px 10px",cursor:"pointer"},hr={...ne,...B,fontFamily:m.font,fontSize:15,display:"flex",alignItems:"center",gap:10,padding:"10px 12px",cursor:"pointer",width:"100%"},br={...se("red",false,"sm"),width:36,minHeight:36,padding:0,borderRadius:"50%"},kr={...B,fontFamily:m.font,fontSize:22,flex:1,minWidth:0,background:"transparent",border:"none",outline:"none",padding:"6px 0"};});function Rn(t){let{client:e,walletConnectProjectId:n,appName:o,onClose:r,style:a,topUp:s}=t,[l,i]=react.useState(n??"");react.useEffect(()=>{if(n)return;let c=true;return (async()=>{let p=await e.blockchain.getDefinitions();if(!c||!p.ok)return;let u=p.data.Blockchain?.WalletLogin?.WalletConnectProjectId;u&&i(u);})(),()=>{c=false;}},[e,n]);let d=react.useMemo(()=>ze({walletConnectProjectId:l||void 0,appName:o}),[l,o]);return jsxRuntime.jsx(Te,{wagmiConfig:d,children:jsxRuntime.jsx(Br,{client:e,onClose:r,style:a,topUp:s})})}function Br({client:t,onClose:e,style:n,topUp:o}){let r=je(t,t.titleID),{address:a,isConnected:s,chainId:l}=wagmi.useAccount(),{connect:i,connectors:d}=wagmi.useConnect(),{disconnect:c}=wagmi.useDisconnect(),{switchChainAsync:p}=wagmi.useSwitchChain(),u=wagmi.useConfig();async function b(w){if(!w||l===w)return true;try{return await p({chainId:w}),!0}catch{return false}}let h={networkType:"EVM",address:s&&a?a:null,connectChoices:d.map(w=>({key:w.uid,label:w.name,connect:()=>i({connector:w})})),disconnect:()=>c(),deposit:async({network:w,binding:f,amount:A})=>{if(!f.ContractAddress)return g("approve","This token cannot be deposited.");if(!await b(w.ChainID))return g("approve",`Switch your wallet to chain ${w.ChainID} to continue.`);let S;try{let M=actions.getPublicClient(u,{chainId:w.ChainID??void 0});if(!M)throw new Error("no client");S=Number(await M.readContract({address:f.ContractAddress,abi:Re,functionName:"decimals"}));}catch{return g("approve","Could not read the token from the network. Try again.")}let R;try{R=viem.parseUnits(A,S);}catch{return g("approve","Invalid amount.")}return r.depositToken({network:w,tokenAddress:f.ContractAddress,amount:R})},withdraw:async({network:w,networkID:f,currencyID:A,amount:S})=>r.account?await b(w.ChainID)?r.withdrawToken({currencyID:A,networkID:f,walletAddress:r.account,amount:S}):g("request",`Switch your wallet to chain ${w.ChainID} to continue.`):g("request","Wallet not connected.")};return jsxRuntime.jsx(Je,{client:t,engine:h,onClose:e,style:n,topUp:o})}var Ln=P(()=>{Ve();mt();qe();Ye();z();Wt();});function It(t){let[e,n]=react.useState(null);return react.useEffect(()=>{if(E()||Ee())return;let o=null;return t.checkout.setTopUpHandler(r=>new Promise(a=>{o?.(false);let s=false,l=i=>{s||(s=true,o===l&&(o=null),n(d=>d?.onDone===l?null:d),a(i));};o=l,n({currencyID:r.currencyID,amount:r.missingAmount??String(r.missing),onDone:l});})),()=>{t.checkout.setTopUpHandler(null),o?.(false);}},[t]),e}var vt=P(()=>{te();});var Et={};Qt(Et,{DEFAULT_EVM_CHAINS:()=>ut,IDosGamesWalletProvider:()=>Te,WalletLogin:()=>In,WalletLoginButton:()=>St,WalletPanel:()=>Rn,arbitrum:()=>exports.arbitrum,base:()=>exports.base,bsc:()=>exports.bsc,chainById:()=>dt,createEvmWalletConfig:()=>ze,idosChains:()=>exports.idosChains,mainnet:()=>exports.mainnet,optimism:()=>exports.optimism,polygon:()=>exports.polygon,polygonAmoy:()=>exports.polygonAmoy,sepolia:()=>exports.sepolia,useEvmBridge:()=>je,useEvmBridgeClients:()=>Oe,useWalletTopUp:()=>It});var Dt=P(()=>{mt();ce();qe();Ye();vn();Ln();vt();});function Ze(t){let{walletConnectProjectId:e,appName:n,appUrl:o,appIcon:r,wallets:a}=t,s=Bn.get(e);if(s)return s;let l=t.networks??[exports.solanaMainnet],i=o??(typeof window<"u"?window.location.origin:""),d={name:n??"iDosGames",description:n??"iDosGames game",url:i,icons:r?[r]:[]},c=new appkitAdapterSolana.SolanaAdapter(a?{wallets:a}:{});return Ge(react$1.createAppKit({adapters:[c],networks:l,projectId:e,metadata:d,features:{analytics:false,email:false,socials:false}})),Bn.set(e,c),c}var Bn,Nt=P(()=>{ce();Pe();Bn=new Map;});async function Me(t){let{client:e,adapter:n,network:o,mint:r,amountRaw:a,titleID:s,category:l}=t;if(E())return ee("deposit-onchain");let i=e.auth.context?.userID;if(!i)return g("deposit-onchain","Not logged in.");if(a<=0n)return g("deposit-onchain","Amount must be positive.");let d;try{d=await n.depositSpl({mint:r,amountRaw:a,userID:i,titleID:s,category:core.normalizeBlockchainCategory(l)});}catch(p){return g("deposit-onchain",_(p))}let c=await e.blockchain.depositToken(o.NetworkID??"",d);return c.ok?{ok:true,onChainTxHash:d,data:c.data}:g("report",c.error,{onChainTxHash:d})}async function Fe(t){let{client:e,adapter:n,currencyID:o,networkID:r,walletAddress:a,amount:s,category:l}=t;if(E())return ee("request");let i=await e.blockchain.requestTokenWithdrawal(o,r,a,s,l);if(!i.ok)return g("request",i.error);let d=i.data.SolanaSignature,c=i.data.TitleTransactionID??void 0;if(!d)return g("request","Withdrawal response carried no Solana signature.",{titleTransactionID:c});let p;try{p=await n.submitWithdrawal(d);}catch(b){return g("withdraw-onchain",_(b),{titleTransactionID:c})}if(!c)return g("confirm","Missing TitleTransactionID.",{onChainTxHash:p});let u=await e.blockchain.confirmWithdrawal(c,p);return u.ok?{ok:true,onChainTxHash:p,data:i.data}:g("confirm",u.error,{onChainTxHash:p,titleTransactionID:c})}var On=P(()=>{z();te();});async function Ue(t){let{client:e,networkID:n,walletAddress:o,signMessage:r}=t;if(E())return me("challenge");let a=await e.auth.requestWalletChallenge(o,n);if(!a.ok)return T("challenge",a.error);let s;try{let i=await r(new TextEncoder().encode(a.data.Message));s=_n(i);}catch(i){return T("sign",_(i))}let l=await e.auth.loginWithWallet(o,n,s);return l.ok?{ok:true,data:l.data}:T("login",l.error)}async function Rt(t){let{client:e,networkID:n,walletAddress:o,signMessage:r}=t;if(E())return me("challenge");let a=await e.auth.linkWallet(o,n);if(!a.ok)return T("challenge",a.error);if(!a.data.Challenge)return T("challenge","No challenge was issued.");let s;try{let i=await r(new TextEncoder().encode(a.data.Challenge));s=_n(i);}catch(i){return T("sign",_(i))}let l=await e.auth.linkWallet(o,n,s);return l.ok?{ok:true,data:l.data}:T("login",l.error)}function _n(t){let e="0x";for(let n of t)e+=n.toString(16).padStart(2,"0");return e}var Mn=P(()=>{z();te();});var Xe=P(()=>{On();Mn();});function Un(t,e,n){let{address:o}=react$1.useAppKitAccount(),{walletProvider:r}=react$1.useAppKitProvider("solana"),a=o??null,s=r?.signMessage?.bind(r);return {connected:!!a,account:a,loginWithWallet:(l,i)=>{let d=i??a;return d?s?Ue({client:t,networkID:l,walletAddress:d,signMessage:s}):Promise.resolve(T("sign","The connected wallet does not support message signing.")):Promise.resolve(T("challenge",Fn))},depositToken:l=>Me({client:t,adapter:n,titleID:e,...l}),withdrawToken:l=>{let i=l.walletAddress??a;return i?Fe({client:t,adapter:n,...l,walletAddress:i}):Promise.resolve(g("request",Fn))}}}var Fn,Hn=P(()=>{Xe();z();Fn="Wallet not connected.";});function $r(t){try{let n=t?.session?.peer?.metadata?.redirect,o=n?.native||n?.universal;return !o||typeof window>"u"?!1:(window.location.href=o,!0)}catch{return false}}function zn(t,e){return new Promise((n,o)=>{let r=setTimeout(()=>o(new Error("The wallet request timed out.")),e);t.then(a=>{clearTimeout(r),n(a);},a=>{clearTimeout(r),o(a instanceof Error?a:new Error(String(a)));});})}function Vr(t){let e="Wallet sign-in failed. Please try again.";return t instanceof Error?/user (rejected|denied|cancelled|canceled)|rejected the request/i.test(t.message)?"Request declined in the wallet.":/timed? ?out/i.test(t.message)?"The wallet did not respond. Open your wallet and try again.":e:e}function $n(t){let{client:e,networkID:n,onAuthenticated:o,disabled:r,label:a,style:s,autoStart:l,mode:i="login",onLinked:d}=t,{address:c,isConnected:p}=react$1.useAppKitAccount(),{walletProvider:u}=react$1.useAppKitProvider("solana"),[b,h]=react.useState(false),[w,f]=react.useState(null),[A,S]=react.useState(false),[R,M]=react.useState(false),V=react.useRef(null),Z=react.useRef(0),q=react.useCallback(()=>{V.current&&clearTimeout(V.current),V.current=null;},[]);react.useEffect(()=>q,[q]);let ae=react.useRef(false),re=react.useCallback(async()=>{let H=++Z.current,v=()=>Z.current===H,Y=u?.signMessage?.bind(u);if(!c||!Y){f("The connected wallet cannot sign messages."),h(false);return}h(true),f(null);try{if(M(!0),i==="link"){let X=await zn(Rt({client:e,networkID:n,walletAddress:c,signMessage:Y}),Gn);if(!v())return;if(X.ok){d?.(X.data.PlayAccess??null);return}f(X.stage==="sign"?"Signature declined.":core.authErrorText(X.error,"Could not link the wallet."));return}let G=await zn(Ue({client:e,networkID:n,walletAddress:c,signMessage:Y}),Gn);if(!v())return;if(G.ok){o();return}f(G.stage==="sign"?"Signature declined.":core.authErrorText(G.error,"Wallet sign-in failed."));}catch(G){if(!v())return;console.error("[idosgames/wallet] solana sign-in failed:",G),f(Vr(G));}finally{v()&&(h(false),M(false));}},[c,u,e,n,o,i,d]),F=react.useCallback(()=>{$r(u)||oe()?.open();},[u]);react.useEffect(()=>{!A||!p||!c||!u||(S(false),q(),re());},[A,p,c,u,re,q]);let D=()=>{if(R){F();return}if(f(null),ae.current=true,p&&c&&u){re();return}let H=oe();if(!H){f("Wallet sign-in is not configured for this title.");return}h(true),S(true),q(),V.current=setTimeout(()=>{S(false),h(false),f("No wallet was connected.");},qr),H.open();};return react.useEffect(()=>{!l||ae.current||(ae.current=true,D());},[l]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:D,disabled:r,style:{...jr,...r?{opacity:.6,cursor:"default"}:null,...s},children:R?"Waiting for signature \u2014 tap to open wallet":b?"Check your wallet\u2026":p?a??(i==="link"?"Link wallet":"Sign in with wallet"):"Connect wallet"}),w&&jsxRuntime.jsx("span",{role:"alert",style:Yr,children:w})]})}var qr,Gn,jr,Yr,Vn=P(()=>{Xe();Pe();qr=18e4,Gn=9e4;jr={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},Yr={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};});function tt(t){let e=(t??"").replace(/^0x/i,""),n=new Uint8Array(e.length>>1);for(let o=0;o<n.length;o++)n[o]=parseInt(e.slice(o*2,o*2+2),16);return n}function We(t){let e=buffer.Buffer.alloc(8);return e.writeBigUInt64LE(BigInt(t||0)),e}function la(t){let e=buffer.Buffer.alloc(8);return e.writeBigInt64LE(BigInt(t||0)),e}function Ie(t){let e=buffer.Buffer.from(t??"","utf8"),n=buffer.Buffer.alloc(4);return n.writeUInt32LE(e.length),buffer.Buffer.concat([n,e])}async function Yn(t){let e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t??""));return new Uint8Array(e)}function Xn(t,e,n){return pe(t,buffer.Buffer.from("title_balance"),buffer.Buffer.from(e),n.toBuffer())}function ca(t){return buffer.Buffer.concat([buffer.Buffer.from(na,"hex"),We(t.amountRaw),Ie(t.userID),Ie(t.titleID),Ie(t.category),buffer.Buffer.from(t.titleHash)])}function da(t,e){let n=t.Splits??[],o=buffer.Buffer.alloc(4);return o.writeUInt32LE(n.length),buffer.Buffer.concat([buffer.Buffer.from(t.Domain==="SPL_DEV"?ra:oa,"hex"),We(t.Amount),We(t.BurnAmount),We(t.Nonce),la(t.ExpiresAt),o,...n.map(r=>buffer.Buffer.concat([buffer.Buffer.from(new web3_js.PublicKey(r.To??"").toBytes()),We(r.Amount)])),Ie(t.UserID),Ie(t.TitleID),Ie(t.Category),buffer.Buffer.from(e)])}function Ae(t,e,n){return web3_js.PublicKey.findProgramAddressSync([e.toBuffer(),n.toBuffer(),t.toBuffer()],nt)[0]}function pa(t,e,n,o,r){return new web3_js.TransactionInstruction({programId:nt,keys:[{pubkey:t,isSigner:true,isWritable:true},{pubkey:e,isSigner:false,isWritable:true},{pubkey:n,isSigner:false,isWritable:false},{pubkey:o,isSigner:false,isWritable:false},{pubkey:web3_js.SystemProgram.programId,isSigner:false,isWritable:false},{pubkey:r,isSigner:false,isWritable:false}],data:buffer.Buffer.from([1])})}function pe(t,...e){return web3_js.PublicKey.findProgramAddressSync(e,t)[0]}function ua(t){let{programId:e,user:n,mint:o,tokenProgram:r}=t,a=pe(e,buffer.Buffer.from("vault"));return new web3_js.TransactionInstruction({programId:e,keys:[{pubkey:pe(e,buffer.Buffer.from("config")),isSigner:false,isWritable:false},{pubkey:a,isSigner:false,isWritable:true},{pubkey:o,isSigner:false,isWritable:false},{pubkey:n,isSigner:true,isWritable:true},{pubkey:Ae(o,n,r),isSigner:false,isWritable:true},{pubkey:Ae(o,a,r),isSigner:false,isWritable:true},{pubkey:r,isSigner:false,isWritable:false},{pubkey:nt,isSigner:false,isWritable:false},{pubkey:web3_js.SystemProgram.programId,isSigner:false,isWritable:false},{pubkey:Xn(e,t.titleHash,o),isSigner:false,isWritable:true}],data:ca(t)})}function ma(t){let{sig:e,payer:n,tokenProgram:o,titleHash:r}=t,a=new web3_js.PublicKey(e.ProgramID??""),s=new web3_js.PublicKey(e.Mint??""),l=new web3_js.PublicKey(e.WalletAddress??""),i=pe(a,buffer.Buffer.from("vault")),d=new web3_js.PublicKey(aa),c=(e.Splits??[]).map(w=>new web3_js.PublicKey(w.To??"")),p=c.map(w=>Ae(s,w,o)),u=web3_js.Ed25519Program.createInstructionWithPublicKey({publicKey:tt(e.Ed25519PublicKey),message:tt(e.Ed25519Message),signature:tt(e.SignatureHex)}),b=c.map((w,f)=>pa(n,p[f],w,s,o)),h=new web3_js.TransactionInstruction({programId:a,keys:[{pubkey:pe(a,buffer.Buffer.from("config")),isSigner:false,isWritable:false},{pubkey:n,isSigner:true,isWritable:true},{pubkey:i,isSigner:false,isWritable:true},{pubkey:pe(a,buffer.Buffer.from("nonce"),We(e.Nonce)),isSigner:false,isWritable:true},{pubkey:s,isSigner:false,isWritable:false},{pubkey:l,isSigner:false,isWritable:false},{pubkey:Ae(s,i,o),isSigner:false,isWritable:true},{pubkey:Ae(s,l,o),isSigner:false,isWritable:true},{pubkey:d,isSigner:false,isWritable:false},{pubkey:Ae(s,d,o),isSigner:false,isWritable:true},{pubkey:web3_js.SYSVAR_INSTRUCTIONS_PUBKEY,isSigner:false,isWritable:false},{pubkey:o,isSigner:false,isWritable:false},{pubkey:nt,isSigner:false,isWritable:false},{pubkey:web3_js.SystemProgram.programId,isSigner:false,isWritable:false},{pubkey:Xn(a,r,s),isSigner:false,isWritable:true},...p.map(w=>({pubkey:w,isSigner:false,isWritable:true}))],data:da(e,r)});return [u,...b,h]}async function fa(t,e,n){let o=async a=>{let s=(await t.getSignatureStatuses([e],{searchTransactionHistory:a})).value[0];if(s?.err)throw new K("TRANSACTION_FAILED",`transaction ${e} failed: ${JSON.stringify(s.err)}`);return s},r=a=>a?.confirmationStatus==="confirmed"||a?.confirmationStatus==="finalized";for(let a=1;;a++){await new Promise(i=>setTimeout(i,ga));let s=null;try{s=await o(!1);}catch(i){if(i instanceof K)throw i}if(r(s))return;if(!(s||a%ya!==0||await t.getBlockHeight("confirmed").catch(()=>-1)<=n)){if(r(await o(true).catch(()=>null)))return;throw new K("TRANSACTION_EXPIRED",`transaction ${e} expired: block height exceeded`)}}}function ot(t){let{connection:e,signTransaction:n}=t;async function o(a){let s=await e.getAccountInfo(a);if(!s)throw new K("MINT_NOT_FOUND",`mint ${a.toBase58()} not found`);return s.owner}async function r(a,s){let{blockhash:l,lastValidBlockHeight:i}=await e.getLatestBlockhash("confirmed"),d=new web3_js.Transaction;d.feePayer=a,d.recentBlockhash=l,d.add(...s);let c=await n(d),p=await e.sendRawTransaction(c.serialize());return await fa(e,p,i),p}return {async depositSpl({mint:a,amountRaw:s,userID:l,titleID:i,category:d}){let c=new web3_js.PublicKey(t.owner),p=new web3_js.PublicKey(a),u=await o(p);return r(c,[ua({programId:new web3_js.PublicKey(t.programId),user:c,mint:p,tokenProgram:u,amountRaw:s,userID:l,titleID:i,category:d,titleHash:await Yn(i)})])},async submitWithdrawal(a){if(!a.ProgramID||!a.Mint||!a.WalletAddress)throw new K("BAD_VOUCHER","the voucher has no program, mint or wallet");let s=new web3_js.PublicKey(t.owner),l=new web3_js.PublicKey(a.ProgramID),i=await e.getAccountInfo(pe(l,buffer.Buffer.from("config")));if(!i)throw new K("POOL_NOT_ON_THIS_CLUSTER","the pool's config account is not on this cluster");if(i.data.length!==jn)throw new K("POOL_NOT_MIGRATED",`config is ${i.data.length} bytes, expected ${jn} (migrate_config not run)`);let d=buffer.Buffer.from(i.data);if(d[sa]===1)throw new K("POOL_PAUSED","pool withdrawals are paused");let c=d.readBigUInt64LE(Zn);if(c!==BigInt(a.SignatureEpoch||0))throw new K("VOUCHER_REVOKED",`signature epoch mismatch: voucher ${a.SignatureEpoch}, on-chain ${c}`);let p=buffer.Buffer.from(tt(a.Ed25519PublicKey)),u=false;for(let h=0;h<Jn;h++){let w=Qn+h*32;p.equals(d.subarray(w,w+32))&&(u=true);}if(!u)throw new K("SIGNER_NOT_TRUSTED","the voucher's signer is not in the pool's server_pubkeys");let b=await o(new web3_js.PublicKey(a.Mint));return r(s,[web3_js.ComputeBudgetProgram.setComputeUnitLimit({units:ia}),...ma({sig:a,payer:s,tokenProgram:b,titleHash:await Yn(a.TitleID??"")})])}}}var na,oa,ra,nt,aa,jn,ia,Qn,Jn,Zn,sa,K,ga,ya,Ft=P(()=>{na="e000c6afc62f69cc",oa="b59a5e563e7306ba",ra="d668e18c1bdc33f1",nt=new web3_js.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),aa="1nc1nerator11111111111111111111111111111111",jn=177,ia=3e5,Qn=40,Jn=4,Zn=Qn+32*Jn,sa=Zn+8,K=class extends Error{constructor(n,o){super(o);this.code=n;this.name="PlatformPoolError";}code};ga=2e3,ya=5;});function to(t){return (t.ChainID===Ta?exports.solanaDevnet:exports.solanaMainnet).rpcUrls.default.http[0]}function no(t){let{client:e,walletConnectProjectId:n,appName:o,onClose:r,style:a,topUp:s}=t,[l,i]=react.useState(n??"");react.useEffect(()=>{if(n)return;let f=true;return (async()=>{let A=await e.blockchain.getDefinitions();if(!f||!A.ok)return;let S=A.data.Blockchain?.WalletLogin?.WalletConnectProjectId;S&&i(S);})(),()=>{f=false;}},[e,n]);let d=react.useMemo(()=>l?(Ze({walletConnectProjectId:l,appName:o}),true):false,[l,o]),{address:c,isConnected:p}=react$1.useAppKitAccount(),{walletProvider:u}=react$1.useAppKitProvider("solana"),b=p&&c?c:null,h=(f,A)=>ot({connection:new web3_js.Connection(to(f),"confirmed"),owner:A,programId:f.RewardPoolAddress??"",signTransaction:async S=>{if(!u)throw new Error("Wallet not connected.");return u.signTransaction(S)}});return jsxRuntime.jsx(Je,{client:e,engine:{networkType:"Solana",address:b,connectChoices:d?[{key:"appkit",label:"Connect wallet",connect:()=>{oe()?.open();}}]:[],disconnect:()=>{oe()?.disconnect("solana");},deposit:async({network:f,binding:A,amount:S})=>{if(!b)return g("deposit-onchain","Wallet not connected.");if(!A.ContractAddress)return g("deposit-onchain","This token cannot be deposited.");if(!f.RewardPoolAddress)return g("deposit-onchain","POOL_NOT_IN_REGISTRY");let R;try{R=(await new web3_js.Connection(to(f),"confirmed").getTokenSupply(new web3_js.PublicKey(A.ContractAddress))).value.decimals;}catch{return g("deposit-onchain","Could not read the token from the network. Try again.")}let M;try{M=viem.parseUnits(S,R);}catch{return g("deposit-onchain","Invalid amount.")}return Me({client:e,adapter:h(f,b),network:f,mint:A.ContractAddress,amountRaw:M,titleID:e.titleID})},withdraw:async({network:f,networkID:A,currencyID:S,amount:R})=>b?Fe({client:e,adapter:h(f,b),currencyID:S,networkID:A,walletAddress:b,amount:R}):g("request","Wallet not connected.")},onClose:r,style:a,topUp:s})}var Ta,oo=P(()=>{ce();Xe();Ft();z();Pe();Nt();Wt();Ta=103;});var Ut={};Qt(Ut,{PlatformPoolError:()=>K,SolanaWalletLogin:()=>$n,SolanaWalletPanel:()=>no,createPlatformPoolAdapter:()=>ot,createSolanaWalletConfig:()=>Ze,solanaDevnet:()=>exports.solanaDevnet,solanaMainnet:()=>exports.solanaMainnet,useSolanaBridge:()=>Un});var Ht=P(()=>{Nt();Hn();Vn();oo();Ft();ce();});te();lt();z();var fe={addressRequest:"IDOS_PLATFORM_WALLET_ADDRESS_REQUEST",addressResponse:"IDOS_PLATFORM_WALLET_ADDRESS_RESPONSE",signRequest:"IDOS_PLATFORM_WALLET_SIGN_REQUEST",signResponse:"IDOS_PLATFORM_WALLET_SIGN_RESPONSE",openRequest:"IDOS_PLATFORM_WALLET_OPEN_REQUEST",openResponse:"IDOS_PLATFORM_WALLET_OPEN_RESPONSE"},tn=core.PLATFORM_PAGE_UNAVAILABLE;async function ct(t,e,n){let o=await core.askPlatformPage(t,e,n),{address:r,signature:a}=o.data;return {ok:o.ok,error:o.error,address:typeof r=="string"?r:void 0,signature:typeof a=="string"?a:void 0}}async function Eo(){return (await ct(fe.openRequest,fe.openResponse,{})).ok}async function nn(t){let{client:e,networkID:n}=t;return rn(t,async o=>{let r=await e.auth.requestWalletChallenge(o,n);return r.ok?{ok:true,message:r.data.Message}:{ok:false,error:r.error}},(o,r)=>e.auth.loginWithWallet(o,n,r))}async function on(t){let{client:e,networkID:n}=t;return rn(t,async o=>{let r=await e.auth.linkWallet(o,n);return r.ok?r.data.Challenge?{ok:true,message:r.data.Challenge}:{ok:false,error:"No challenge was issued."}:{ok:false,error:r.error}},(o,r)=>e.auth.linkWallet(o,n,r))}async function rn(t,e,n){let{client:o,family:r}=t,a=o.titleID,s=await ct(fe.addressRequest,fe.addressResponse,{titleID:a,family:r});if(!s.ok||!s.address)return T("challenge",s.error??"NO_WALLET");let l=s.address,i=await e(l);if(!i.ok)return T("challenge",i.error);let d=await ct(fe.signRequest,fe.signResponse,{titleID:a,family:r,address:l,message:i.message});if(!d.ok||!d.signature)return T("sign",d.error??"SIGN_FAILED");let c=await n(l,d.signature);return c.ok?{ok:true,data:c.data}:T("login",c.error)}var ao={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},io={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};function ro(t){switch(t){case tn:return "Wallet sign-in is not available on this page.";case "NO_WALLET":case "CANCELLED":return "Connect a wallet on the page to sign in.";case "REJECTED":return "The signature was declined.";case "TIMEOUT":return "The wallet did not answer. Please try again.";default:return t}}function Aa(t){let{client:e,networkID:n,onAuthenticated:o,onLinked:r,mode:a="login",family:s,disabled:l,label:i,style:d}=t,[c,p]=react.useState(false),[u,b]=react.useState(null);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{p(true),b(null),(async()=>{if(a==="link"){let f=await on({client:e,networkID:n,family:s});if(f.ok){p(false),r?.(f.data.PlayAccess??null);return}b(ro(f.error)),p(false);return}let w=await nn({client:e,networkID:n,family:s});if(w.ok){o?.();return}b(ro(w.error)),p(false);})();},disabled:l||c,style:{...ao,...l||c?{opacity:.6,cursor:"default"}:null,...d},children:c?"Waiting for the wallet\u2026":i??(a==="link"?"Link wallet":"Sign in with wallet")}),u&&jsxRuntime.jsx("span",{role:"alert",style:io,children:u})]})}function so(t,e){return Ee()?null:jsxRuntime.jsx(Aa,{...t,family:e})}function lo(t){let{loading:e,disabled:n,label:o,style:r,error:a,onClick:s}=t;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:s,disabled:n||e,style:{...ao,...n||e?{opacity:.6,cursor:"default"}:null,...r},children:e?"Loading wallet\u2026":o??"Sign in with wallet"}),a&&jsxRuntime.jsx("span",{role:"alert",style:io,children:a})]})}function Ia(t){let{chains:e,walletConnectProjectId:n,appName:o,disabled:r,label:a,style:s,onAuthenticated:l,...i}=t,[d,c]=react.useState(null),[p,u]=react.useState(false),[b,h]=react.useState(null);if(E())return so(t,"evm");let w=()=>{u(true),h(null),(async()=>{try{let f=await Promise.resolve().then(()=>(Dt(),Et)),A=f.createEvmWalletConfig({chains:e,walletConnectProjectId:n,appName:o});c({mod:f,config:A});}catch(f){console.error("[idosgames/wallet] failed to load the wallet module:",f),h("Could not load the wallet. Please try again.");}finally{u(false);}})();};if(d){let{WalletLogin:f}=d.mod;return jsxRuntime.jsx(f,{...i,onAuthenticated:l??co,wagmiConfig:d.config,disabled:r,label:a,style:s,autoStart:true})}return jsxRuntime.jsx(lo,{loading:p,disabled:r,label:a??(t.mode==="link"?"Link wallet":void 0),style:s,error:b,onClick:w})}function co(){}function va(t){let{walletConnectProjectId:e,appName:n,disabled:o,label:r,style:a,onAuthenticated:s,...l}=t,[i,d]=react.useState(null),[c,p]=react.useState(false),[u,b]=react.useState(null);if(E())return so(t,"solana");let h=()=>{p(true),b(null),(async()=>{try{let w=await Promise.resolve().then(()=>(Ht(),Ut));e&&w.createSolanaWalletConfig({walletConnectProjectId:e,appName:n}),d(w);}catch(w){console.error("[idosgames/wallet] failed to load the wallet module:",w),b("Could not load the wallet. Please try again.");}finally{p(false);}})();};if(i){let{SolanaWalletLogin:w}=i;return jsxRuntime.jsx(w,{...l,onAuthenticated:s??co,disabled:o,label:r,style:a,autoStart:true})}return jsxRuntime.jsx(lo,{loading:c,disabled:o,label:r??(t.mode==="link"?"Link wallet":void 0),style:a,error:u,onClick:h})}var Ea={...O,pointerEvents:"auto",padding:16,boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,fontSize:15};function Da(t){let{client:e,onClose:n,style:o}=t,r=E(),[a,s]=react.useState(null),[l,i]=react.useState(null);return react.useEffect(()=>{if(r)return;let d=true;return (async()=>{try{let c=await e.blockchain.getDefinitions(),p=Object.values((c.ok?c.data.Blockchain?.Networks:null)??{}).map(h=>h.Type),b=p.includes("Solana")&&!p.includes("EVM")?{kind:"solana",mod:await Promise.resolve().then(()=>(Ht(),Ut))}:{kind:"evm",mod:await Promise.resolve().then(()=>(Dt(),Et))};d&&s(b);}catch(c){console.error("[idosgames/wallet] failed to load the wallet panel:",c),d&&i("Could not load the wallet.");}})(),()=>{d=false;}},[r,e]),r?null:a?.kind==="evm"?jsxRuntime.jsx(a.mod.WalletPanel,{...t}):a?.kind==="solana"?jsxRuntime.jsx(a.mod.SolanaWalletPanel,{...t}):jsxRuntime.jsxs("div",{style:{...Ea,...n?{...De,width:360,maxWidth:"100%"}:{},...o},children:[l??k("loading"),n&&jsxRuntime.jsx("button",{type:"button",className:"idos-press",onClick:n,"aria-label":"\u2715",style:{...se("red",false,"sm"),width:36,minHeight:36,padding:0,borderRadius:"50%"},children:"\u2715"})]})}te();vt();ce();
|
|
2
|
+
exports.LazySolanaWalletLogin=va;exports.LazyWalletLogin=Ia;exports.LazyWalletPanel=Da;exports.chainById=dt;exports.isEmbeddedInPlatform=E;exports.isEmbeddedOnForeignSite=Ee;exports.openPlatformWalletPanel=Eo;exports.useWalletTopUp=It;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { CSSProperties, ReactNode } from 'react';
|
|
2
2
|
import { Chain } from 'viem';
|
|
3
3
|
import { IDosGamesClient, PlayAccessStatus } from '@idosgames/core';
|
|
4
|
-
|
|
4
|
+
import { W as WalletTopUpRequest } from '../topUp-CCNQcHcH.cjs';
|
|
5
|
+
export { u as useWalletTopUp } from '../topUp-CCNQcHcH.cjs';
|
|
6
|
+
export { c as isEmbeddedInPlatform, d as isEmbeddedOnForeignSite, f as openPlatformWalletPanel } from '../platformWalletLogin-BBBBN68y.cjs';
|
|
5
7
|
export { a as AppKitSolanaNetwork, h as arbitrum, i as base, k as bsc, l as chainById, m as idosChains, n as mainnet, o as optimism, p as polygon, q as polygonAmoy, s as sepolia, r as solanaDevnet, t as solanaMainnet } from '../chains-B2jQ-L0B.cjs';
|
|
6
8
|
|
|
7
9
|
interface LazyLoginCommonProps {
|
|
@@ -54,6 +56,11 @@ interface LazyWalletPanelProps {
|
|
|
54
56
|
onClose?: () => void;
|
|
55
57
|
/** Overrides for the outer card container. */
|
|
56
58
|
style?: CSSProperties;
|
|
59
|
+
/**
|
|
60
|
+
* Top up for a purchase the engine refused for a crypto shortfall: the panel shows only this
|
|
61
|
+
* currency and the missing amount, then calls `topUp.onDone(true)` (see `useWalletTopUp`).
|
|
62
|
+
*/
|
|
63
|
+
topUp?: WalletTopUpRequest;
|
|
57
64
|
}
|
|
58
65
|
/**
|
|
59
66
|
* "Sign in with wallet" for **EVM** titles that loads its machinery on demand.
|
|
@@ -79,4 +86,4 @@ declare function LazySolanaWalletLogin(props: LazySolanaWalletLoginProps): React
|
|
|
79
86
|
*/
|
|
80
87
|
declare function LazyWalletPanel(props: LazyWalletPanelProps): ReactNode;
|
|
81
88
|
|
|
82
|
-
export { LazySolanaWalletLogin, type LazySolanaWalletLoginProps, LazyWalletLogin, type LazyWalletLoginProps, LazyWalletPanel, type LazyWalletPanelProps };
|
|
89
|
+
export { LazySolanaWalletLogin, type LazySolanaWalletLoginProps, LazyWalletLogin, type LazyWalletLoginProps, LazyWalletPanel, type LazyWalletPanelProps, WalletTopUpRequest };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { CSSProperties, ReactNode } from 'react';
|
|
2
2
|
import { Chain } from 'viem';
|
|
3
3
|
import { IDosGamesClient, PlayAccessStatus } from '@idosgames/core';
|
|
4
|
-
|
|
4
|
+
import { W as WalletTopUpRequest } from '../topUp-CCNQcHcH.js';
|
|
5
|
+
export { u as useWalletTopUp } from '../topUp-CCNQcHcH.js';
|
|
6
|
+
export { c as isEmbeddedInPlatform, d as isEmbeddedOnForeignSite, f as openPlatformWalletPanel } from '../platformWalletLogin-BxAoMCd9.js';
|
|
5
7
|
export { a as AppKitSolanaNetwork, h as arbitrum, i as base, k as bsc, l as chainById, m as idosChains, n as mainnet, o as optimism, p as polygon, q as polygonAmoy, s as sepolia, r as solanaDevnet, t as solanaMainnet } from '../chains-B2jQ-L0B.js';
|
|
6
8
|
|
|
7
9
|
interface LazyLoginCommonProps {
|
|
@@ -54,6 +56,11 @@ interface LazyWalletPanelProps {
|
|
|
54
56
|
onClose?: () => void;
|
|
55
57
|
/** Overrides for the outer card container. */
|
|
56
58
|
style?: CSSProperties;
|
|
59
|
+
/**
|
|
60
|
+
* Top up for a purchase the engine refused for a crypto shortfall: the panel shows only this
|
|
61
|
+
* currency and the missing amount, then calls `topUp.onDone(true)` (see `useWalletTopUp`).
|
|
62
|
+
*/
|
|
63
|
+
topUp?: WalletTopUpRequest;
|
|
57
64
|
}
|
|
58
65
|
/**
|
|
59
66
|
* "Sign in with wallet" for **EVM** titles that loads its machinery on demand.
|
|
@@ -79,4 +86,4 @@ declare function LazySolanaWalletLogin(props: LazySolanaWalletLoginProps): React
|
|
|
79
86
|
*/
|
|
80
87
|
declare function LazyWalletPanel(props: LazyWalletPanelProps): ReactNode;
|
|
81
88
|
|
|
82
|
-
export { LazySolanaWalletLogin, type LazySolanaWalletLoginProps, LazyWalletLogin, type LazyWalletLoginProps, LazyWalletPanel, type LazyWalletPanelProps };
|
|
89
|
+
export { LazySolanaWalletLogin, type LazySolanaWalletLoginProps, LazyWalletLogin, type LazyWalletLoginProps, LazyWalletPanel, type LazyWalletPanelProps, WalletTopUpRequest };
|
package/dist/react/lazyIndex.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {e,d,b}from'../chunk-
|
|
1
|
+
import {e as e$1,d,b}from'../chunk-B4KT5CVC.js';export{c as openPlatformWalletPanel}from'../chunk-B4KT5CVC.js';export{a as useWalletTopUp}from'../chunk-DOWG5IDM.js';import {g,c,h,e}from'../chunk-ZOWZE7MU.js';import {f,g as g$1}from'../chunk-K3THMWU2.js';export{o as arbitrum,n as base,l as bsc,t as chainById,s as idosChains,f as isEmbeddedInPlatform,g as isEmbeddedOnForeignSite,k as mainnet,p as optimism,m as polygon,r as polygonAmoy,q as sepolia,w as solanaDevnet,v as solanaMainnet}from'../chunk-K3THMWU2.js';import {useState,useEffect}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var A={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},N={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};function z(e){switch(e){case b:return "Wallet sign-in is not available on this page.";case "NO_WALLET":case "CANCELLED":return "Connect a wallet on the page to sign in.";case "REJECTED":return "The signature was declined.";case "TIMEOUT":return "The wallet did not answer. Please try again.";default:return e}}function Z(e){let{client:t,networkID:o,onAuthenticated:u,onLinked:a,mode:l="login",family:s,disabled:y,label:g,style:d$1}=e,[n,i]=useState(false),[b,p]=useState(null);return jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:()=>{i(true),p(null),(async()=>{if(l==="link"){let m=await e$1({client:t,networkID:o,family:s});if(m.ok){i(false),a?.(m.data.PlayAccess??null);return}p(z(m.error)),i(false);return}let c=await d({client:t,networkID:o,family:s});if(c.ok){u?.();return}p(z(c.error)),i(false);})();},disabled:y||n,style:{...A,...y||n?{opacity:.6,cursor:"default"}:null,...d$1},children:n?"Waiting for the wallet\u2026":g??(l==="link"?"Link wallet":"Sign in with wallet")}),b&&jsx("span",{role:"alert",style:N,children:b})]})}function T(e,t){return g$1()?null:jsx(Z,{...e,family:t})}function I(e){let{loading:t,disabled:o,label:u,style:a,error:l,onClick:s}=e;return jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:s,disabled:o||t,style:{...A,...o||t?{opacity:.6,cursor:"default"}:null,...a},children:t?"Loading wallet\u2026":u??"Sign in with wallet"}),l&&jsx("span",{role:"alert",style:N,children:l})]})}function $(e){let{chains:t,walletConnectProjectId:o,appName:u,disabled:a,label:l,style:s,onAuthenticated:y,...g}=e,[d,n]=useState(null),[i,b]=useState(false),[p,L]=useState(null);if(f())return T(e,"evm");let c=()=>{b(true),L(null),(async()=>{try{let m=await import('./index.js'),D=m.createEvmWalletConfig({chains:t,walletConnectProjectId:o,appName:u});n({mod:m,config:D});}catch(m){console.error("[idosgames/wallet] failed to load the wallet module:",m),L("Could not load the wallet. Please try again.");}finally{b(false);}})();};if(d){let{WalletLogin:m}=d.mod;return jsx(m,{...g,onAuthenticated:y??R,wagmiConfig:d.config,disabled:a,label:l,style:s,autoStart:true})}return jsx(I,{loading:i,disabled:a,label:l??(e.mode==="link"?"Link wallet":void 0),style:s,error:p,onClick:c})}function R(){}function ee(e){let{walletConnectProjectId:t,appName:o,disabled:u,label:a,style:l,onAuthenticated:s,...y}=e,[g,d]=useState(null),[n,i]=useState(false),[b,p]=useState(null);if(f())return T(e,"solana");let L=()=>{i(true),p(null),(async()=>{try{let c=await import('./solanaIndex.js');t&&c.createSolanaWalletConfig({walletConnectProjectId:t,appName:o}),d(c);}catch(c){console.error("[idosgames/wallet] failed to load the wallet module:",c),p("Could not load the wallet. Please try again.");}finally{i(false);}})();};if(g){let{SolanaWalletLogin:c}=g;return jsx(c,{...y,onAuthenticated:s??R,disabled:u,label:a,style:l,autoStart:true})}return jsx(I,{loading:n,disabled:u,label:a??(e.mode==="link"?"Link wallet":void 0),style:l,error:b,onClick:L})}var te={...g,pointerEvents:"auto",padding:16,boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,fontSize:15};function le(e$1){let{client:t,onClose:o,style:u}=e$1,a=f(),[l,s]=useState(null),[y,g]=useState(null);return useEffect(()=>{if(a)return;let d=true;return (async()=>{try{let n=await t.blockchain.getDefinitions(),i=Object.values((n.ok?n.data.Blockchain?.Networks:null)??{}).map(L=>L.Type),p=i.includes("Solana")&&!i.includes("EVM")?{kind:"solana",mod:await import('./solanaIndex.js')}:{kind:"evm",mod:await import('./index.js')};d&&s(p);}catch(n){console.error("[idosgames/wallet] failed to load the wallet panel:",n),d&&g("Could not load the wallet.");}})(),()=>{d=false;}},[a,t]),a?null:l?.kind==="evm"?jsx(l.mod.WalletPanel,{...e$1}):l?.kind==="solana"?jsx(l.mod.SolanaWalletPanel,{...e$1}):jsxs("div",{style:{...te,...o?{...c,width:360,maxWidth:"100%"}:{},...u},children:[y??h("loading"),o&&jsx("button",{type:"button",className:"idos-press",onClick:o,"aria-label":"\u2715",style:{...e("red",false,"sm"),width:36,minHeight:36,padding:0,borderRadius:"50%"},children:"\u2715"})]})}export{ee as LazySolanaWalletLogin,$ as LazyWalletLogin,le as LazyWalletPanel};
|