@spicenet-io/spiceflow-ui 1.10.0 → 1.10.2
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/index.cjs.js +4 -4
- package/dist/index.js +13 -13
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";var zs=Object.create;var $t=Object.defineProperty;var Vs=Object.getOwnPropertyDescriptor;var Ns=Object.getOwnPropertyNames;var Ys=Object.getPrototypeOf,qs=Object.prototype.hasOwnProperty;var Ps=(t,o,r,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of Ns(o))!qs.call(t,s)&&s!==r&&$t(t,s,{get:()=>o[s],enumerable:!(n=Vs(o,s))||n.enumerable});return t};var lt=(t,o,r)=>(r=t!=null?zs(Ys(t)):{},Ps(o||!t||!t.__esModule?$t(r,"default",{value:t,enumerable:!0}):r,t));const ae=require("viem"),Tt=require("viem/actions"),At=require("viem/chains"),e=require("react/jsx-runtime"),a=require("react"),de=require("./Button-Cn16gFtO.js"),Js=require("react-dom"),Je=require("@privy-io/react-auth"),_t=require("@dynamic-labs/sdk-react-core"),Ye=require("@spicenet-io/spiceflow-core"),Ae=require("wagmi"),Zs=require("./auth-dynamic.cjs.js"),Gs=require("./auth-privy.cjs.js"),es=require("@tanstack/react-query"),ts=require("wagmi/chains"),ss=require("wagmi/connectors"),dt=[{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{payable:!0,stateMutability:"payable",type:"fallback"},{anonymous:!1,inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Transfer",type:"event"}],os={11155111:{id:11155111,name:"Ethereum Sepolia",displayName:"Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpc:"https://site1.moralis-nodes.com/sepolia/b59c444a55b74d56b3f836d2dd7144eb",blockExplorers:{default:{name:"Etherscan",url:"https://sepolia.etherscan.io"}},viemChain:At.sepolia,delegateContract:"0xDF7d39BB544778F467D10b08B1F5C170fd7fB480",icon:{symbol:"\u039E",backgroundColor:"#627EEA",textColor:"#FFFFFF"},moralisName:"sepolia",supportedTokens:[{address:"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",name:"USD Coin",symbol:"USDC",decimals:6},{address:"0x76f983E0F5a4B72C4bac99Fc9399845a58078787",name:"Mock Tether USD",symbol:"USDT",decimals:6},{address:"0x4Fc381B6CC6Df8cF1c1bD46D184475bE5b7A3c62",name:"Mock Wrapped BTC",symbol:"WBTC",decimals:8}]},421614:{id:421614,name:"Arbitrum Sepolia",displayName:"Arbitrum Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpc:"https://site1.moralis-nodes.com/arbitrum-sepolia/a3b4b1042f834a959541c96811ef44bb",blockExplorers:{default:{name:"Arbiscan",url:"https://sepolia.arbiscan.io"}},viemChain:At.arbitrumSepolia,delegateContract:"0x151755d1bdFeB6082D141EF86e4291b2e902b43F",icon:{symbol:"A",backgroundColor:"#28A0F0",textColor:"#FFFFFF"},moralisName:"",supportedTokens:[{address:"0xBeB51deb2018b67b35d5695Fd15bb30D452c7868",name:"USD Coin",symbol:"USDC",decimals:18},{address:"0xBA4c54d4CF10C766c22A08F783998cFaB237F7C9",name:"Mock Wrapped BTC",symbol:"WBTC",decimals:8}]},84532:{id:84532,name:"Base Sepolia",displayName:"Base Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpc:"https://site1.moralis-nodes.com/base-sepolia/0563a61e273c428f906716cd4befa362",blockExplorers:{default:{name:"Basescan",url:"https://sepolia.basescan.org"}},viemChain:At.baseSepolia,delegateContract:"0xD4C4A222cdd42f5c3219249a083a5aBf1420E9D8",icon:{symbol:"B",backgroundColor:"#0052FF",textColor:"#FFFFFF"},moralisName:"0x14a34",supportedTokens:[{address:"0xf370dC3765f81aC9dD2FEBd59Fb4e710330B0BC8",name:"USD Coin",symbol:"USDC",decimals:18},{address:"0x16DD3a855433059Be478FAcb416D9aFed6CA96Ec",name:"Mock Wrapped BTC",symbol:"WBTC",decimals:8}]},5115:{id:5115,name:"Citrea Testnet",displayName:"Citrea Testnet",nativeCurrency:{name:"cBTC",symbol:"cBTC",decimals:18},rpc:"https://rpc.testnet.citrea.xyz",blockExplorers:{default:{name:"Citrea Explorer",url:"https://explorer.testnet.citrea.xyz"}},viemChain:At.citreaTestnet,delegateContract:"0x9DE3D53419a8F821b6E2039A7249c5738004FB94",icon:{symbol:"C",backgroundColor:"#EA4B4B",textColor:"#FFFFFF"},moralisName:"",supportedTokens:[{address:"0xf19308F923582A6f7c465e5CE7a9Dc1BEC6665B1",name:"USD Coin",symbol:"USD",decimals:18},{address:"0x2876a1fb400c238b0a9e4edd2e7e03d3cf9b53c2",name:"CBTC Vault",symbol:"eCBTC",decimals:18,logoURI:"https://citrea.elitra.xyz/images/tokens/cbtc.jpg"},{address:"0x2d41d86bb9e7161561fa3186b47d160467efcee3",name:"NUSD Vault",symbol:"eNUSD",decimals:18,logoURI:"https://www.satsuma.exchange/nusd-icon.svg"}]},123420001114:{id:123420001114,name:"Base Camp",displayName:"Base Camp",nativeCurrency:{name:"Ethereum",symbol:"ETH",decimals:18},rpc:"https://rpc.basecamp.t.raas.gelato.cloud",blockExplorers:{default:{name:"Base Camp Explorer",url:"https://basecamp.gelato.network"}},viemChain:At.basecampTestnet,delegateContract:"0xA15BFeD4eC0BEdd36b00b9856aFa1C6BCFE61574",icon:{symbol:"B",backgroundColor:"#0052FF",textColor:"#FFFFFF"},moralisName:"",supportedTokens:[]},688688:{id:688688,name:"Pharos Testnet",displayName:"Pharos Testnet",nativeCurrency:{name:"PHRS",symbol:"PHRS",decimals:18},rpc:"https://testnet.dplabs-internal.com",blockExplorers:{default:{name:"Pharos Explorer",url:"https://testnet.pharosscan.xyz"}},viemChain:ae.defineChain({id:688688,name:"Pharos Testnet",nativeCurrency:{decimals:18,name:"PHRS",symbol:"PHRS"},rpcUrls:{default:{http:["https://testnet.dplabs-internal.com"]}},blockExplorers:{default:{name:"Pharos Explorer",url:"https://testnet.pharosscan.xyz"}},testnet:!0}),delegateContract:"0xAd45b774C4c632540d36f2105889C0E6aC28b504",icon:{symbol:"P",backgroundColor:"#4A90E2",textColor:"#FFFFFF"},moralisName:""},688689:{id:688689,name:"Pharos Testnet",displayName:"Pharos Testnet",nativeCurrency:{name:"PHRS",symbol:"PHRS",decimals:18},rpc:"https://atlantic.dplabs-internal.com",blockExplorers:{default:{name:"Pharos Atlantic Explorer",url:"https://atlantic.pharosscan.xyz/"}},viemChain:ae.defineChain({id:688689,name:"Pharos Testnet",nativeCurrency:{decimals:18,name:"PHRS",symbol:"PHRS"},rpcUrls:{default:{http:["https://atlantic.dplabs-internal.com"]}},blockExplorers:{default:{name:"Pharos Atlantic Explorer",url:"https://atlantic.pharosscan.xyz/"}},testnet:!0}),delegateContract:"0xAd45b774C4c632540d36f2105889C0E6aC28b504",icon:{symbol:"P",backgroundColor:"#4A90E2",textColor:"#FFFFFF"},moralisName:"",supportedTokens:[{address:"0x16b90aeb3de140dde993da1d5734bca28574702b",name:"USD Stable Coin",symbol:"USD",decimals:6}]}},fe=t=>os[t],st=t=>fe(t)?.name||`Chain ${t}`,ct=t=>{const o=fe(t);if(!o)throw new Error(`Unsupported chain ID: ${t}`);return o.delegateContract},Wt=(t,o,r)=>{const n=fe(t);return n?.blockExplorers?.default?.url?`${n.blockExplorers.default.url}/tx/${o}`:"#"},Ve=t=>{const o=fe(t);if(!o)throw new Error(`Unsupported chain ID: ${t}`);return ae.createPublicClient({chain:o.viemChain,transport:ae.http(o.rpc)})},Ks=t=>{const o=fe(t);if(o)return{icon:o.icon.symbol,bg:o.icon.backgroundColor,text:o.icon.textColor};const r=`Chain ${t}`,n=r.split("").reduce((d,g)=>g.charCodeAt(0)+((d<<5)-d),0),s=Math.abs(n)%360,c=`hsl(${s}, 60%, 50%)`,i=s>180?"#FFFFFF":"#000000";return{style:{backgroundColor:c,color:i},icon:r.charAt(0).toUpperCase()}},Os=()=>{const t={};return Object.values(os).forEach(o=>{t[o.id]={name:o.name,moralisName:o.moralisName||"",chain:o.viemChain,rpcUrl:o.rpc}}),t},Xs=t=>{const o=fe(t);if(!o)throw new Error(`Chain ${t} not supported`);return ae.createPublicClient({chain:o.viemChain,transport:ae.http(o.rpc)})},$s=(t,o,r=BigInt(0),n=0)=>({address:o.address,name:o.name,symbol:o.symbol,decimals:o.decimals,balance:r,balanceFormatted:n,balanceUsd:0,logoURI:o.logoURI,isNative:!1,chainId:t}),_s=(t,o=BigInt(0),r=0)=>{const n=fe(t);return n?{address:"0x0000000000000000000000000000000000000000",name:n.nativeCurrency.name,symbol:n.nativeCurrency.symbol,decimals:n.nativeCurrency.decimals,balance:o,balanceFormatted:r,balanceUsd:0,logoURI:void 0,isNative:!0,chainId:t}:null},Rt=(t,o=[])=>{const r=fe(t);if(!r)return[];const n=[];if(![11155111,421614,84532,688689].includes(t)){const s=o.find(c=>c.chainId===t&&c.isNative);s?n.push(s):n.push(_s(t))}return r.supportedTokens&&r.supportedTokens.forEach(s=>{const c=o.find(i=>i.chainId===t&&i.address.toLowerCase()===s.address.toLowerCase());c?n.push(c):n.push($s(t,s))}),n},Dt=t=>{const o=t.toLowerCase();return o==="0x0"||o==="0x0000000000000000000000000000000000000000"||o==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"},wt=t=>Dt(t)?"0x0":t,ns=async(t,o)=>{const r=fe(t);if(!r)throw new Error(`Unsupported chain ID: ${t}`);const n=o.toLowerCase();if(Dt(n)){if(!r.nativeCurrency?.decimals)throw new Error(`Native currency decimals not configured for chain ${t}`);return r.nativeCurrency.decimals}if(r.supportedTokens){const s=r.supportedTokens.find(c=>c.address.toLowerCase()===n);if(s)return s.decimals}try{if(!ae.isAddress(o))throw new Error(`Invalid token address: ${o}`);const s=ae.getAddress(o),c=Ve(t),i=await Tt.readContract(c,{address:s,abi:dt,functionName:"decimals"});return Number(i)}catch(s){throw console.error(`Failed to fetch decimals for token ${o} on chain ${t}:`,s),new Error(`Could not determine decimals for token ${o} on chain ${t}`)}},eo=(t,o,r)=>{if(o===r)return t;if(o<r){const n=BigInt(10)**BigInt(r-o);return t*n}else{const n=BigInt(10)**BigInt(o-r);return t/n}},to="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJub25jZSI6ImVmMWEzZDM1LTYwMGUtNDcwNC04MTk3LTIzODc2NWNlYmQ2NCIsIm9yZ0lkIjoiNDY2Nzk0IiwidXNlcklkIjoiNDgwMjI3IiwidHlwZUlkIjoiMTk3YWMxMzMtNDY3ZS00YWIyLWFlZmUtM2VlMjU0NGNjM2NiIiwidHlwZSI6IlBST0pFQ1QiLCJpYXQiOjE3NTU5NjY3MjIsImV4cCI6NDkxMTcyNjcyMn0.7KHx_SwI89GVKFkgqtl-sUV9CUKWkDjZbkBAVAX2Djk",so="https://deep-index.moralis.io/api/v2.2",St=Os(),rs=Xs,as=async(t,o)=>{try{const r=rs(o),n=await Tt.getBalance(r,{address:t}),s=St[o],c=parseFloat((Number(n)/Math.pow(10,18)).toFixed(6));return{address:"0x0000000000000000000000000000000000000000",name:s.chain.nativeCurrency.name,symbol:s.chain.nativeCurrency.symbol,decimals:s.chain.nativeCurrency.decimals,balance:n,balanceFormatted:c,balanceUsd:0,logoURI:void 0,isNative:!0,chainId:o}}catch(r){return console.error(`Error fetching native balance for ${o}:`,r),{address:"0x0000000000000000000000000000000000000000",name:St[o].chain.nativeCurrency.name,symbol:St[o].chain.nativeCurrency.symbol,decimals:18,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:void 0,isNative:!0,chainId:o}}},is=async(t,o,r,n,s,c)=>{try{if(!ae.isAddress(r))return console.warn(`Invalid token address ${r} for chain ${o}, skipping...`),null;const i=ae.getAddress(r),d=ae.isAddress(t)?ae.getAddress(t):t,g=rs(o),f=await Tt.readContract(g,{address:i,abi:dt,functionName:"balanceOf",args:[d]}),u=parseFloat((Number(f)/Math.pow(10,c)).toFixed(6));return u>0?{address:i,name:n,symbol:s,decimals:c,balance:f,balanceFormatted:u,balanceUsd:0,logoURI:void 0,isNative:!1,chainId:o}:null}catch(i){return i?.message?.includes("checksum")||i?.message?.includes("Address")||i?.message?.includes("invalid")||console.error(`Error fetching ERC20 balance for ${r} on chain ${o}:`,i),null}},pt=async(t,o)=>{try{const r=St[o];if(!r.moralisName){const i=[],d=await as(t,o);d.balanceFormatted>0&&i.push(d);const g=fe(o);if(g?.supportedTokens&&g.supportedTokens.length>0){const f=g.supportedTokens.map(u=>is(t,o,u.address,u.name,u.symbol,u.decimals));(await Promise.allSettled(f)).forEach(u=>{u.status==="fulfilled"&&u.value&&i.push(u.value)})}return{tokens:i,chainId:o}}const n=await(await import("axios")).default.get(`${so}/wallets/${t}/tokens`,{params:{chain:r.moralisName},headers:{"X-API-Key":to}}),s=[],c=n.data?.result||[];console.log("allTokens",c);for(const i of c){const d=parseFloat(i.balance_formatted||"0");if(d>0){const g={address:i.token_address,name:i.name||"Unknown",symbol:i.symbol||"UNKNOWN",decimals:parseInt(i.decimals)||18,balance:BigInt(i.balance||"0"),balanceFormatted:d,balanceUsd:parseFloat(i.usd_value||"0"),logoURI:i.logo,isNative:i.native_token||!1,chainId:o};s.push(g)}}return{tokens:s,chainId:o}}catch(r){if(console.error(`Error fetching tokens for ${o}:`,r),!St[o].moralisName)try{const n=[],s=await as(t,o);s.balanceFormatted>0&&n.push(s);const c=fe(o);if(c?.supportedTokens&&c.supportedTokens.length>0){const i=c.supportedTokens.map(d=>is(t,o,d.address,d.name,d.symbol,d.decimals));(await Promise.allSettled(i)).forEach(d=>{d.status==="fulfilled"&&d.value&&n.push(d.value)})}return{tokens:n,chainId:o}}catch(n){console.error(`Fallback balance fetch failed for ${o}:`,n)}return{tokens:[],chainId:o}}},zt=async t=>{if(!t)throw new Error("Wallet address is required");console.log("Fetching multi-chain balances for:",t);const[o,r,n,s,c,i]=await Promise.allSettled([pt(t,11155111),pt(t,5115),pt(t,123420001114),pt(t,84532),pt(t,688689),pt(t,421614)]),d={};return o.status==="fulfilled"&&(d[11155111]=o.value),r.status==="fulfilled"&&(d[5115]=r.value),n.status==="fulfilled"&&(d[123420001114]=n.value),s.status==="fulfilled"&&(d[84532]=s.value),c.status==="fulfilled"&&(d[688689]=c.value),i.status==="fulfilled"&&(d[421614]=i.value),console.log("Balances:",d),d},Vt=({address:t,supportedChains:o,fetchBalances:r,refreshInterval:n=8e3})=>{const[s,c]=a.useState([]),[i,d]=a.useState(!1),[g,f]=a.useState(null),u=a.useRef(!0),l=a.useRef(t),C=a.useRef(o),A=a.useRef(r);a.useEffect(()=>{l.current=t,C.current=o,A.current=r},[t,o,r]);const w=a.useCallback(async()=>{const b=l.current,m=C.current,j=A.current;if(!b){c([]);return}u.current&&d(!0),f(null);try{const y=await j(b),h=Object.values(y).flatMap(x=>x.tokens.map(S=>({...S,chainId:x.chainId}))).filter(x=>m.includes(x.chainId));c(h)}catch(y){const h=y instanceof Error?y.message:"Failed to fetch assets";f(h),console.error("Error fetching assets:",y)}finally{u.current&&(d(!1),u.current=!1)}},[]),k=a.useCallback(b=>s.filter(m=>m.chainId===b),[s]),p=a.useCallback(()=>s.filter(b=>b.isNative),[s]);return a.useEffect(()=>{t&&(u.current=!0,w())},[t,w]),a.useEffect(()=>{if(!t||!n)return;const b=setInterval(()=>{w()},n);return()=>clearInterval(b)},[t,n]),{assets:s,loading:i,error:g,refreshAssets:w,getAssetsByChain:k,getNativeAssets:p}},kt=({checkStepStatus:t,pollingInterval:o=4e3})=>{const[r,n]=a.useState(null),[s,c]=a.useState(null),i=a.useRef(!1),d=a.useCallback(()=>{s&&(clearInterval(s),c(null))},[s]),g=a.useCallback(()=>{n(null),d()},[d]),f=a.useCallback((u,l)=>{d(),i.current=!1;const C={intentId:u,steps:l.map(k=>({...k,status:"pending"})),overallStatus:"processing"};n(C);const A=async()=>{i.current||n(k=>k?((async()=>{const p=[...k.steps];let b=!0,m=!1;for(let y=0;y<p.length;y++){const h=p[y];if(h.status!=="success"){if((h.stepId===0||y>0&&p[y-1].status==="success")&&(h.status==="pending"||h.status==="processing"))try{const x=await t(u,h.stepId);x.data.status==="success"?(p[y]={...h,status:"success",transactionHash:x.data.transactionHash},y+1<p.length&&p[y+1].status==="pending"&&(p[y+1]={...p[y+1],status:"processing"})):x.data.status==="executing"||x.data.status==="created"?p[y]={...h,status:"processing"}:x.data.status==="reverted"&&(p[y]={...h,status:"failed",transactionHash:x.data.transactionHash},m=!0)}catch(x){console.error(`Error checking step ${h.stepId}:`,x)}p[y].status!=="success"&&(b=!1)}}const j=m?"failed":b?"success":"processing";n(y=>y?{...y,steps:p,overallStatus:j}:null),(b||m)&&(i.current=!0,d())})().catch(()=>{}),k):null)};A();const w=setInterval(A,o);c(w)},[t,o,d]);return a.useEffect(()=>()=>{d()},[d]),{intentStatus:r,startStatusPolling:f,stopStatusPolling:d,clearStatus:g}},It=(t,o=4)=>t===0?"0":t<1e-4?"< 0.0001":t.toFixed(o),oo=(t,o=6,r=4)=>t.length<=o+r?t:`${t.slice(0,o)}...${t.slice(-r)}`,no=t=>oo(t,8,8),ls=t=>{const o=t.replace(/[^0-9.]/g,""),r=o.split(".");return r.length>2?r[0]+"."+r.slice(1).join(""):o},ro=async t=>{try{return await navigator.clipboard.writeText(t),!0}catch(o){return console.error("Failed to copy to clipboard:",o),!1}};var ut="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAAAS1BMVEVMaXEndskmdcondcondcsndssmdMkldMondswndsz///8pd8wcbsj9/v8pe9U1fs7z+P2Ot+Sqyetypd1cl9dJi9PC2PHV5PXm7/keiWBQAAAACnRSTlMAE3H/m1gy/sjjtLtfHAAAAAlwSFlzAAALEwAACxMBAJqcGAAACTtJREFUeNrNW9eWqzoMnYQQJ8gUm/r/X3plmptkSDl3hodTVgBt1Jt/ft64Lvf8ers9nk+R4SWez8ftds3vl5//47rnSDmDCi8AMADwr/l/GeLI7/+U+AWJi5lWJkQ2f/5yCfP/GZVAEJd/Rv1paAvhUPYv8xOieP4LDPeNenZwbRi+K4v8ARUcE7cg8PZH/kXyVZWdpr5pRVV9CYIh/yL1lQ1fgXA35N+hv0H4TBcuN3ib/AoBbh9YRP58WfaELjzztz8fNT/7+EKLeI8J9+dH3Pfk8HxDE65QfYX8DKGC66v0v8N+Vwyvif9RfZH8woTH5SXj5+kvMfjl38QLLsGoH0sik5IHg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veYR2wirD0EItwjEdNw4oT8os39v6dU58L9y+kg8wF+s0HmdS5oSlZacrWtzIECpm/7+nk2FCeZ3vp4IaZMgScVL7uzVIILQKmP9xqzhRWM/SMhj4RZn8/NeSnNTMa2P5Zpf9MWGKHEUaDLx3ny2nIr4n6sHStOiHmbC0G9yQ1wvuJxjDwQDz68oFGoCEsNa9CODWZpJvAjJcGRurd+O2aLhrY/mcNwvunT55B++Gk+1ePdLIzu1G03cISMBPHQLqD/EY6Zjm6fzpzGN7PJ5+uEtqwBY0bjnRWiJgfUtacmOYRwMY3t1b7+Xk+f35mK7XQ/BXsQDceauWP9WaKja8fMkd4SxfL/Xy5OluqJovWfgL0a3mw+JH7FGy93mae42f+Y9ur9dJxWh+tfvA+RRRYK2FXwQ83Ebkq88Dh8gchwBYn2bUhEq5T2K3BdB4yHLQ+3v8gBMAAKrdE6J+US63ueXz3ggPzGOZC9M+WFxx+5IoH77mtr3j8/iWXP3DNB4jw+rsXndhVLwP93lWvP3DZ7fev+/2BC4+/f+XzD1x6/QPXfv/AxeccQ+8Xr37/hcvvhSUU1/8fqex/ififZbqhk/AAAAAASUVORK5CYII=";const io={USDC:ut,WBTC:ao},ot=({symbol:t,logoURI:o,size:r=20,theme:n})=>{const s=n||de.createTheme("dark"),c={width:`${r}px`,height:`${r}px`,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${r*.4}px`,fontWeight:s.typography.fontWeight.bold,flexShrink:0,overflow:"hidden",backgroundColor:"#ffffff"},i=t.toUpperCase(),d=o||io[i];if(d)return e.jsx("img",{src:d,alt:t,style:{...c,objectFit:"cover"},onError:f=>{const u=f.target;u.style.display="none";const l=u.parentElement;l&&(l.innerHTML=Nt(t).icon,Object.assign(l.style,Nt(t).style))}});const g=Nt(t);return e.jsx("div",{style:{...c,...g.style},children:g.icon})},Nt=t=>{const o=t.toUpperCase(),r={ETH:{bg:"#627EEA",text:"#FFFFFF",icon:"\u039E"},BTC:{bg:"#F7931A",text:"#FFFFFF",icon:"\u20BF"},USDC:{bg:"#2775CA",text:"#FFFFFF"},USDT:{bg:"#26A17B",text:"#FFFFFF"},DAI:{bg:"#F5AC37",text:"#FFFFFF"},WETH:{bg:"#627EEA",text:"#FFFFFF",icon:"\u039E"},WBTC:{bg:"#F09242",text:"#FFFFFF",icon:"\u20BF"},CBTC:{bg:"#F7931A",text:"#FFFFFF",icon:"\u20BF"},USD:{bg:"#26A17B",text:"#FFFFFF",icon:"$"},MATIC:{bg:"#8247E5",text:"#FFFFFF"},AVAX:{bg:"#E84142",text:"#FFFFFF"},SOL:{bg:"#9945FF",text:"#FFFFFF"},DOT:{bg:"#E6007A",text:"#FFFFFF"},ADA:{bg:"#0033AD",text:"#FFFFFF"},LINK:{bg:"#375BD2",text:"#FFFFFF"},UNI:{bg:"#FF007A",text:"#FFFFFF"},AAVE:{bg:"#B6509E",text:"#FFFFFF"},CRV:{bg:"#40E0D0",text:"#000000"}}[o];if(r)return{style:{backgroundColor:r.bg,color:r.text},icon:r.icon||o.charAt(0)};const n=o.split("").reduce((d,g)=>g.charCodeAt(0)+((d<<5)-d),0),s=Math.abs(n)%360,c=`hsl(${s}, 60%, 50%)`,i=s>180?"#FFFFFF":"#000000";return{style:{backgroundColor:c,color:i},icon:o.charAt(0)}},Ft=({chainId:t,name:o,size:r=16,theme:n})=>{const s=n||de.createTheme("dark"),c={width:`${r}px`,height:`${r}px`,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${r*.5}px`,fontWeight:s.typography.fontWeight.bold,flexShrink:0},i=lo(t,o);return e.jsx("div",{style:{...c,backgroundColor:"style"in i?i.style?.backgroundColor:i.bg,color:"style"in i?i.style?.color:i.text},children:i.icon})},lo=(t,o)=>{if(t)return Ks(t);const r=o||"Unknown Chain",n=r.split("").reduce((d,g)=>g.charCodeAt(0)+((d<<5)-d),0),s=Math.abs(n)%360,c=`hsl(${s}, 60%, 50%)`,i=s>180?"#FFFFFF":"#000000";return{style:{backgroundColor:c,color:i},icon:r.charAt(0).toUpperCase()}},ds=t=>{switch(t){case 11155111:return"Sepolia";case 421614:return"Arbitrum Sepolia";case 5115:return"Citrea Testnet";case 123420001114:return"Basecamp Testnet";case 84532:return"Base Sepolia";case 688689:return"Pharos Atlantic";default:return`Chain ${t}`}},cs=({selectedAsset:t,assets:o,onAssetSelect:r,showDropdown:n,onToggleDropdown:s,disabled:c=!1,theme:i})=>{const d=i||de.createTheme("dark"),g=a.useRef(null),f=a.useRef(null),u=a.useRef(null),[l,C]=a.useState(null);a.useEffect(()=>{if(n&&f.current){const I=()=>{if(f.current){const G=f.current.getBoundingClientRect();C({top:G.bottom+6,right:window.innerWidth-G.right})}};return I(),window.addEventListener("scroll",I,!0),window.addEventListener("resize",I),()=>{window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I)}}else C(null)},[n]),a.useEffect(()=>{const I=G=>{g.current&&!g.current.contains(G.target)&&u.current&&!u.current.contains(G.target)&&n&&s()};return n&&document.addEventListener("mousedown",I),()=>{document.removeEventListener("mousedown",I)}},[n,s]);const[A,w]=a.useState(!1),[k,p]=a.useState(!1),b={backgroundColor:"transparent",border:A?"1px solid #F4A5A5":"1px solid #CDCFD1",borderRadius:"6px",color:"#3c3e42",cursor:c?"not-allowed":"pointer",padding:"8px 12px 8px 8px",width:"100%",display:"flex",flexDirection:"column",gap:"4px",opacity:c?.6:1,transition:"all 0.15s ease",transform:k?"scale(0.98)":"scale(1)"},m={display:"flex",justifyContent:"space-between",alignItems:"center"},j={display:"flex",alignItems:"center",gap:"4px",paddingTop:"4px",borderTop:"1px solid #e5e7eb"},y=()=>l?{position:"fixed",top:`${l.top}px`,right:`${l.right}px`,backgroundColor:d.colors.secondary,border:`1px solid ${d.colors.border}`,borderRadius:d.borderRadius.md,boxShadow:d.shadows.lg,zIndex:100,width:"200px",maxHeight:"300px",overflow:"auto"}:{},h={backgroundColor:"transparent",border:"none",color:d.colors.text,cursor:"pointer",padding:d.spacing.sm,width:"100%",display:"flex",alignItems:"center",gap:d.spacing.sm,transition:`background-color ${d.animation.normal}`,":hover":{backgroundColor:d.colors.surfaceHover}},x={display:"flex",flexDirection:"column",alignItems:"flex-start",flex:1},S={fontSize:d.typography.fontSize.sm,fontWeight:d.typography.fontWeight.medium},F={fontSize:d.typography.fontSize.xs,color:d.colors.textMuted},B={transition:`transform ${d.animation.normal}`,transform:n?"rotate(180deg)":"rotate(0deg)"};return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{position:"relative"},ref:g,children:e.jsxs("div",{ref:f,style:b,onClick:c?void 0:s,onMouseEnter:()=>w(!0),onMouseLeave:()=>{w(!1),p(!1)},onMouseDown:()=>p(!0),onMouseUp:()=>p(!1),children:[e.jsxs("div",{style:m,children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:t?.asset?e.jsxs(e.Fragment,{children:[e.jsx(ot,{symbol:t.asset.symbol,logoURI:t.asset.logoURI,theme:d,size:30}),e.jsx("span",{style:{fontSize:"16px",fontWeight:500,color:"#3c3e42",lineHeight:"1.5"},children:t.asset.symbol})]}):e.jsx("span",{style:{fontSize:"14px",color:"#71757a"},children:"Select"})}),e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#71757a",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:B,children:e.jsx("path",{d:"M6 9l6 6 6-6"})})]}),t?.asset&&e.jsxs("div",{style:j,children:[e.jsx(Ft,{chainId:t.asset.chainId,theme:d}),e.jsx("span",{style:{fontSize:"11px",color:"#71757a"},children:ds(t.asset.chainId)})]})]})}),n&&l&&Js.createPortal(e.jsx("div",{ref:u,style:y(),children:o.map(I=>e.jsxs("button",{style:h,onClick:()=>{r(I),s()},children:[e.jsx(ot,{symbol:I.symbol,logoURI:I.logoURI,theme:d},`${I.address}-${I.chainId}`),e.jsxs("div",{style:x,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:d.spacing.xs},children:[e.jsx("span",{style:S,children:I.symbol}),e.jsx(Ft,{chainId:I.chainId,theme:d})]}),e.jsxs("span",{style:F,children:[It(I.balanceFormatted)," \u2022"," ",ds(I.chainId)]})]})]},`${I.address}-${I.chainId}`))}),document.body)]})},co=({assets:t,selectedAsset:o,onAssetSelect:r,onAmountChange:n,disabled:s=!1,loading:c=!1,label:i="Select Asset",showBalance:d=!0,showMaxButton:g=!0,placeholder:f="0.0",theme:u,styles:l,allowSecondAsset:C=!1,onAddAsset:A,canAddAsset:w=!1})=>{const k=u||de.createTheme("dark"),[p,b]=a.useState(!1),[m,j]=a.useState(null),[y,h]=a.useState(null),[x,S]=a.useState(o?.amount||""),F=a.useRef(null),B=a.useRef("");a.useEffect(()=>{const M=o?.asset?`${o.asset.chainId}-${o.asset.address}`:"";M!==B.current&&(S(o?.amount||""),B.current=M)},[o?.asset?.chainId,o?.asset?.address,o?.amount]);const I=M=>{const z=ls(M);if(!z){S(z),F.current&&clearTimeout(F.current),F.current=setTimeout(()=>{n(z)},300);return}if(o?.asset){const E=parseFloat(z),U=o.asset.balanceFormatted;if(!isNaN(E)&&E>U){const X=U.toString();S(X),F.current&&clearTimeout(F.current),F.current=setTimeout(()=>{n(X)},300);return}}S(z),F.current&&clearTimeout(F.current),F.current=setTimeout(()=>{n(z)},300)},G=M=>{if(o?.asset){const z=(o.asset.balanceFormatted*M/100).toString();S(z),F.current&&clearTimeout(F.current),n(z)}},P=o?.asset?.balanceFormatted??0,_=parseFloat(x)||0,$=P>0?_/P*100:0;a.useEffect(()=>()=>{F.current&&clearTimeout(F.current)},[]);const J={backgroundColor:l?.assetSelector?.backgroundColor||l?.secondaryBackground||"#e9e9e9",border:"0.5px solid #A8A8A7",borderRadius:l?.assetSelector?.borderRadius||"6px",padding:l?.assetSelector?.padding||"16px",height:"auto",minHeight:"144px",display:"flex",flexDirection:"column",gap:"8px",position:"relative",opacity:s?.6:1};return c?e.jsx("div",{style:J,children:e.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx("div",{style:{backgroundColor:"#d1d5db",borderRadius:"4px",height:"16px",width:"60px"}}),e.jsx("div",{style:{backgroundColor:"#d1d5db",borderRadius:"4px",height:"40px",width:"150px"}})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:"8px"},children:[e.jsx("div",{style:{backgroundColor:"#d1d5db",borderRadius:"4px",height:"12px",width:"80px"}}),e.jsx("div",{style:{backgroundColor:"#d1d5db",borderRadius:"6px",height:"46px",width:"128px"}})]})]})}):e.jsxs("div",{style:J,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("span",{style:{fontFamily:l?.fontFamily||k.typography.fontFamily,fontSize:"16px",fontWeight:500,color:"#7d7c7b",lineHeight:"24px"},children:i}),d&&o?.asset&&e.jsxs("span",{style:{fontFamily:l?.fontFamily||k.typography.fontFamily,fontSize:"12px",fontWeight:500,color:"#71757a",lineHeight:"16px"},children:["Balance: ",It(o.asset.balanceFormatted)]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",flex:1},children:[e.jsx("input",{type:"text",value:x,onChange:M=>I(M.target.value),placeholder:f,disabled:s||!o?.asset,style:{fontFamily:l?.fontFamily||k.typography.fontFamily,fontSize:"40px",fontWeight:700,color:s?"rgba(14, 13, 11, 0.16)":x?"#0e0d0b":"#d1d5db",lineHeight:"1.08",letterSpacing:"-1.2px",backgroundColor:"transparent",border:"none",outline:"none",padding:0,width:"100%",maxWidth:"200px"}}),e.jsx("div",{style:{width:"128px",position:"relative",flexShrink:0},children:e.jsx(cs,{selectedAsset:o,assets:t,onAssetSelect:r,showDropdown:p,onToggleDropdown:()=>b(!p),disabled:s,theme:k})})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:"10px",height:"14px"},children:[0,25,50,75,100].map((M,z)=>{const E=Math.abs($-M)<1,U=z===4,X=M/100,ee=m===M,H=y===M;return e.jsx("button",{onClick:()=>G(M),onMouseEnter:()=>j(M),onMouseLeave:()=>{j(null),h(null)},onMouseDown:()=>h(M),onMouseUp:()=>h(null),disabled:s||!o?.asset,title:`${M}%`,style:{width:"14px",height:"14px",padding:0,border:"none",backgroundColor:"transparent",cursor:s||!o?.asset?"not-allowed":"pointer",opacity:E?1:ee?.8:.5,transform:H?"scale(0.85)":ee?"scale(1.15)":"scale(1)",transition:"all 0.15s ease"},children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",children:[e.jsx("circle",{cx:"7",cy:"7",r:"6.84375",fill:U?"#ea4b4b":"none",stroke:U?"#ea4b4b":"#3C3E42",strokeWidth:"0.3125"}),!U&&X>0&&e.jsx("path",{d:`M 7 7 L 7 0.15625 A 6.84375 6.84375 0 ${X>.5?1:0} 1 ${7+6.84375*Math.sin(X*2*Math.PI)} ${7-6.84375*Math.cos(X*2*Math.PI)} Z`,fill:"#3C3E42"})]})},M)})})]})},ht=co,ps=({status:t,size:o=20,theme:r})=>{const n=r||de.createTheme("dark"),s={width:`${o}px`,height:`${o}px`,display:"flex",alignItems:"center",justifyContent:"center"};return(()=>{switch(t){case"success":return e.jsx("svg",{style:{...s,color:n.colors.success},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})});case"failed":return e.jsx("svg",{style:{...s,color:n.colors.error},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})});case"processing":return e.jsx("div",{style:{...s,border:`2px solid ${n.colors.primary}`,borderTop:"2px solid transparent",borderRadius:"50%",animation:"spin 1s linear infinite"}});case"pending":default:return e.jsx("div",{style:{...s,border:`2px solid ${n.colors.textMuted}`,borderRadius:"50%",backgroundColor:n.colors.surface}})}})()},po=({step:t,explorerUrlBuilder:o,animationDelay:r=0,theme:n})=>{const s=n||de.createTheme("dark"),c=(()=>{switch(t.status){case"success":return{bg:`${s.colors.success}20`,border:s.colors.success};case"failed":return{bg:`${s.colors.error}20`,border:s.colors.error};case"processing":return{bg:`${s.colors.info}20`,border:s.colors.info};default:return{bg:s.colors.surface,border:s.colors.border}}})(),i=t.transactionHash&&o?o(t.chainId,t.transactionHash):null,d={display:"flex",alignItems:"center",gap:s.spacing.md,padding:s.spacing.md,borderRadius:s.borderRadius.lg,border:`1px solid ${c.border}`,backgroundColor:c.bg,transition:`all ${s.animation.normal}`,animation:t.status==="processing"?"pulse 2s infinite":void 0,animationDelay:`${r}ms`},g={flex:1,minWidth:0},f={display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:s.spacing.xs},u={fontSize:s.typography.fontSize.sm,fontWeight:s.typography.fontWeight.medium,color:s.colors.text},l={fontSize:s.typography.fontSize.xs,fontWeight:s.typography.fontWeight.medium,padding:`${s.spacing.xs} ${s.spacing.sm}`,borderRadius:s.borderRadius.full,backgroundColor:`${c.border}20`,color:c.border},C={fontSize:s.typography.fontSize.xs,color:s.colors.textMuted,marginBottom:s.spacing.xs},A={fontSize:s.typography.fontSize.xs,color:s.colors.textMuted,fontFamily:"IBM Plex Mono",marginTop:s.spacing.xs},w={fontSize:s.typography.fontSize.xs,backgroundColor:`${s.colors.info}20`,color:s.colors.info,border:"none",borderRadius:s.borderRadius.full,padding:`${s.spacing.xs} ${s.spacing.sm}`,cursor:"pointer",textDecoration:"none",display:"inline-flex",alignItems:"center",gap:s.spacing.xs,transition:`all ${s.animation.normal}`,":hover":{backgroundColor:`${s.colors.info}30`,color:s.colors.info}};return e.jsxs("div",{style:d,children:[e.jsx("div",{style:{flexShrink:0},children:e.jsx(ps,{status:t.status,theme:s})}),e.jsxs("div",{style:g,children:[e.jsxs("div",{style:f,children:[e.jsx("span",{style:u,children:t.chainName}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:s.spacing.sm},children:[e.jsx("span",{style:l,children:t.status.charAt(0).toUpperCase()+t.status.slice(1)}),t.status==="success"&&i&&e.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer",style:w,title:"View on explorer",children:[e.jsx("svg",{width:"12",height:"12",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})}),"Explorer"]})]})]}),e.jsx("p",{style:C,children:t.description}),t.transactionHash&&e.jsx("p",{className:"ibm-plex-mono",style:A,children:no(t.transactionHash)})]})]})},uo=({intentStatus:t,onClose:o,onRetry:r,txType:n,onNewTx:s,explorerUrlBuilder:c,theme:i})=>{const d=i||de.createTheme("dark"),g={width:"100%",maxWidth:"28rem",margin:"0 auto",backgroundColor:d.colors.background,border:`1px solid ${d.colors.border}`,borderRadius:d.borderRadius.lg,padding:d.spacing.lg,color:d.colors.text},f={textAlign:"center",marginBottom:d.spacing.lg},u={width:"4rem",height:"4rem",margin:"0 auto",backgroundColor:d.colors.surface,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",border:`2px solid ${d.colors.border}`,marginBottom:d.spacing.md},l={fontSize:d.typography.fontSize.lg,fontWeight:d.typography.fontWeight.semibold,color:d.colors.text,marginBottom:d.spacing.sm},C={fontSize:d.typography.fontSize.sm,color:d.colors.textMuted},A={display:"flex",flexDirection:"column",gap:d.spacing.md,marginBottom:d.spacing.lg},w={padding:d.spacing.md,borderRadius:d.borderRadius.lg,marginBottom:d.spacing.lg},k={display:"flex",flexDirection:"column",gap:d.spacing.sm},p=(()=>{switch(t.overallStatus){case"success":return{title:`${n.charAt(0).toUpperCase()+n.slice(1)} completed successfully!`,description:"Your tokens are now available in your wallet",style:{...w,background:`linear-gradient(to right, ${d.colors.success}20, ${d.colors.success}10)`,border:`1px solid ${d.colors.success}`},icon:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),iconColor:d.colors.success};case"failed":return{title:"Transaction failed",description:"Please try again or contact support if the issue persists",style:{...w,background:`linear-gradient(to right, ${d.colors.error}20, ${d.colors.error}10)`,border:`1px solid ${d.colors.error}`},icon:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"})}),iconColor:d.colors.error};default:return{title:`Processing your ${n}...`,description:"This may take a few seconds to complete",style:{...w,background:`linear-gradient(to right, ${d.colors.primary}20, ${d.colors.primary}10)`,border:`1px solid ${d.colors.primary}`},icon:e.jsx("div",{style:{width:"1rem",height:"1rem",border:`2px solid ${d.colors.primary}`,borderTop:"2px solid transparent",borderRadius:"50%",animation:"spin 1s linear infinite"}}),iconColor:d.colors.primary}}})();return e.jsxs("div",{style:g,children:[e.jsxs("div",{style:f,children:[e.jsx("div",{style:u,children:e.jsx(ps,{status:t.overallStatus,size:32,theme:d})}),e.jsx("h3",{style:l,children:t.overallStatus==="success"?`${n.charAt(0).toUpperCase()+n.slice(1)} Completed!`:t.overallStatus==="failed"?"Transaction Failed":`Processing ${n}`}),e.jsx("p",{style:C,children:t.overallStatus==="success"?`Your tokens have been successfully ${n}`:t.overallStatus==="failed"?"Something went wrong with your transaction":`Please wait while we process your ${n} across chains`})]}),e.jsx("div",{style:A,children:t.steps.map((b,m)=>e.jsx(po,{step:b,explorerUrlBuilder:c,animationDelay:m*100,theme:d},b.stepId))}),e.jsx("div",{style:p.style,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:d.spacing.md},children:[e.jsx("div",{style:{width:"2rem",height:"2rem",backgroundColor:`${p.iconColor}20`,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",color:p.iconColor},children:p.icon}),e.jsxs("div",{children:[e.jsx("p",{style:{color:p.iconColor,fontWeight:d.typography.fontWeight.medium,fontSize:d.typography.fontSize.sm,margin:0},children:p.title}),e.jsx("p",{style:{color:`${p.iconColor}CC`,fontSize:d.typography.fontSize.xs,margin:`${d.spacing.xs} 0 0 0`},children:p.description})]})]})}),e.jsxs("div",{style:k,children:[t.overallStatus==="success"&&s&&e.jsxs(de.Button,{variant:"success",fullWidth:!0,onClick:s,theme:d,children:["Start New ",n]}),t.overallStatus==="failed"&&r&&e.jsx(de.Button,{variant:"error",fullWidth:!0,onClick:r,theme:d,children:"Try Again"}),t.overallStatus==="processing"&&e.jsx(de.Button,{variant:"ghost",fullWidth:!0,onClick:o,theme:d,children:"Cancel & Close"})]})]})},ho=({config:t,onChange:o,theme:r,styles:n})=>{const s=r||de.createTheme("dark"),c=["0%","0.1%","0.5%","1%"],i=p=>{o({...t,slippage:p,customSlippage:p==="custom"?t.customSlippage:void 0})},d=p=>{o({...t,slippage:"custom",customSlippage:p})},g={backgroundColor:n?.slippageSettings?.backgroundColor,border:n?.slippageSettings?.borderColor?`1px solid ${n.slippageSettings.borderColor}`:void 0,borderRadius:n?.slippageSettings?.borderRadius,padding:n?.slippageSettings?.padding,marginBottom:s.spacing.sm},f={fontSize:n?.slippageSettings?.label?.fontSize||s.typography.fontSize.xs,color:n?.slippageSettings?.label?.color||s.colors.textMuted,fontWeight:n?.slippageSettings?.label?.fontWeight,fontFamily:n?.slippageSettings?.label?.fontFamily||n?.fontFamily||s.typography.fontFamily,marginBottom:"4px"},u={display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"6px",alignItems:"center"},l={backgroundColor:n?.slippageSettings?.presetButton?.backgroundColor||s.colors.secondary,border:`1px solid ${n?.slippageSettings?.presetButton?.borderColor||s.colors.border}`,borderRadius:n?.slippageSettings?.presetButton?.borderRadius||s.borderRadius.md,color:n?.slippageSettings?.presetButton?.color||s.colors.textSecondary,cursor:"pointer",fontSize:n?.slippageSettings?.presetButton?.fontSize||s.typography.fontSize.xs,fontWeight:n?.slippageSettings?.presetButton?.fontWeight,fontFamily:n?.slippageSettings?.presetButton?.fontFamily||n?.fontFamily||s.typography.fontFamily,padding:n?.slippageSettings?.presetButton?.padding||`${s.spacing.xs} 0`,textAlign:"center",transition:`all ${s.animation.normal}`,":hover":{backgroundColor:n?.slippageSettings?.presetButton?.hoverBackgroundColor||s.colors.surfaceHover,borderColor:s.colors.borderHover}},C={...l,backgroundColor:n?.slippageSettings?.presetButton?.activeBackgroundColor||n?.primaryColor||s.colors.primary,borderColor:n?.slippageSettings?.presetButton?.activeBorderColor||n?.primaryColor||s.colors.primary,color:n?.slippageSettings?.presetButton?.activeColor||s.colors.text},A={backgroundColor:n?.slippageSettings?.customInput?.backgroundColor||"transparent",border:`1px solid ${t.slippage==="custom"?n?.slippageSettings?.customInput?.focusBorderColor||n?.primaryColor||s.colors.primary:n?.slippageSettings?.customInput?.borderColor||s.colors.border}`,borderRadius:n?.slippageSettings?.customInput?.borderRadius||s.borderRadius.md,color:n?.slippageSettings?.customInput?.color||s.colors.text,fontSize:n?.slippageSettings?.customInput?.fontSize||s.typography.fontSize.xs,fontWeight:n?.slippageSettings?.customInput?.fontWeight,fontFamily:n?.slippageSettings?.customInput?.fontFamily||n?.fontFamily||s.typography.fontFamily,padding:n?.slippageSettings?.customInput?.padding||s.spacing.sm,textAlign:"center",paddingRight:"1.5rem",width:"100%",outline:"none","::placeholder":{color:s.colors.textMuted}},w={position:"relative",display:"flex",alignItems:"center"},k={position:"absolute",right:s.spacing.xs,fontSize:n?.slippageSettings?.customInput?.fontSize||s.typography.fontSize.xs,fontFamily:n?.slippageSettings?.customInput?.fontFamily||n?.fontFamily||s.typography.fontFamily,color:s.colors.textMuted,pointerEvents:"none"};return e.jsxs("div",{style:g,children:[e.jsx("div",{style:f,children:"Slippage Tolerance"}),e.jsxs("div",{style:u,children:[c.map(p=>e.jsx("button",{style:t.slippage===p?C:l,onClick:()=>i(p),children:p},p)),e.jsxs("div",{style:w,children:[e.jsx("input",{type:"text",style:A,placeholder:"Custom",value:t.customSlippage||"",onFocus:()=>i("custom"),onChange:p=>d(p.target.value)}),t.slippage==="custom"&&e.jsx("span",{style:k,children:"%"})]})]})]})},go=({assets:t,selectedAsset:o,onAssetSelect:r,onAmountChange:n,amount:s="",disabled:c=!1,loading:i=!1,label:d="Collateral",placeholder:g="0.0",theme:f,styles:u})=>{const l=f||de.createTheme("dark"),[C,A]=a.useState(!1),w=a.useCallback(()=>{A(B=>!B)},[]),k=a.useCallback(B=>{const I=ls(B);n?.(I)},[n]),p=a.useCallback(()=>{o&&n&&n(o.balanceFormatted.toString())},[o,n]),b={backgroundColor:u?.assetSelector?.backgroundColor||u?.secondaryBackground||l.colors.surface,border:`1px solid ${u?.assetSelector?.borderColor||l.colors.border}`,borderRadius:u?.assetSelector?.borderRadius||l.borderRadius.md,padding:u?.assetSelector?.padding||`${l.spacing.sm} ${l.spacing.md}`,transition:`border-color ${l.animation.normal}`,opacity:c?.6:1,color:l.colors.text},m={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"6px"},j={fontSize:u?.assetSelector?.label?.fontSize||l.typography.fontSize.xs,color:u?.assetSelector?.label?.color||l.colors.textMuted,fontWeight:u?.assetSelector?.label?.fontWeight,fontFamily:u?.assetSelector?.label?.fontFamily||u?.fontFamily||l.typography.fontFamily},y={fontSize:u?.assetSelector?.balance?.fontSize||l.typography.fontSize.xs,color:u?.assetSelector?.balance?.color||l.colors.textMuted,fontWeight:u?.assetSelector?.balance?.fontWeight,fontFamily:u?.assetSelector?.balance?.fontFamily||u?.fontFamily||l.typography.fontFamily},h={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"6px"},x={background:u?.assetSelector?.amountInput?.backgroundColor||"transparent",border:"none",outline:"none",fontSize:u?.assetSelector?.amountInput?.fontSize||l.typography.fontSize.xl,fontWeight:u?.assetSelector?.amountInput?.fontWeight||l.typography.fontWeight.medium,color:u?.assetSelector?.amountInput?.color||l.colors.text,fontFamily:u?.assetSelector?.amountInput?.fontFamily||u?.fontFamily||l.typography.fontFamily,width:"50%","::placeholder":{color:l.colors.textMuted}},S={display:"flex",justifyContent:"space-between",alignItems:"center"},F={background:u?.button?.backgroundColor||l.colors.secondary,border:"none",borderRadius:u?.button?.borderRadius||l.borderRadius.sm,color:u?.button?.color||l.colors.textMuted,cursor:"pointer",fontSize:u?.button?.fontSize||l.typography.fontSize.xs,fontWeight:u?.button?.fontWeight,fontFamily:u?.button?.fontFamily||u?.fontFamily||l.typography.fontFamily,padding:u?.button?.padding||`4px ${l.spacing.xs}`,transition:`color ${l.animation.normal}`,":hover":{color:l.colors.text}};return i?e.jsxs("div",{style:b,children:[e.jsxs("div",{style:m,children:[e.jsx("div",{style:{...j,backgroundColor:l.colors.border,borderRadius:l.borderRadius.sm,height:"12px",width:"60px"}}),e.jsx("div",{style:{...y,backgroundColor:l.colors.border,borderRadius:l.borderRadius.sm,height:"12px",width:"80px"}})]}),e.jsxs("div",{style:h,children:[e.jsx("div",{style:{backgroundColor:l.colors.border,borderRadius:l.borderRadius.sm,height:"32px",width:"100px"}}),e.jsx("div",{style:{backgroundColor:l.colors.border,borderRadius:l.borderRadius.sm,height:"40px",width:"120px"}})]}),e.jsx("div",{style:S,children:e.jsx("div",{style:{backgroundColor:l.colors.border,borderRadius:l.borderRadius.sm,height:"12px",width:"50px"}})})]}):e.jsxs("div",{style:b,children:[e.jsxs("div",{style:m,children:[e.jsx("span",{style:j,children:d}),o&&e.jsxs("span",{style:y,children:["Balance: ",It(o.balanceFormatted)," ",o.symbol]})]}),e.jsxs("div",{style:h,children:[e.jsx("input",{type:"text",style:x,value:s,onChange:B=>k(B.target.value),placeholder:g,disabled:c||!o}),e.jsx("div",{style:{position:"relative",width:"120px"},children:e.jsx(cs,{selectedAsset:o?{asset:o,amount:""}:void 0,assets:t,onAssetSelect:r,showDropdown:C,onToggleDropdown:w,disabled:c,theme:l})})]}),e.jsxs("div",{style:S,children:[e.jsx("span",{style:y,children:o?`${It(o.balanceFormatted)} ${o.symbol}`:""}),o&&!c&&n&&e.jsx("button",{style:F,onClick:p,title:`Max: ${It(o.balanceFormatted,6)} ${o.symbol}`,children:"MAX"})]})]})},Ue=a.createContext(null),xo=({children:t,appId:o,supportedViemChains:r})=>{const[n,s]=a.useState(null),[c,i]=a.useState(!1);return a.useEffect(()=>{i(!0),typeof window<"u"&&import("@privy-io/react-auth").then(d=>{s(()=>d.PrivyProvider)}).catch(d=>{console.error("Failed to load Privy SDK:",d)})},[]),!c||!n?e.jsx(e.Fragment,{children:t}):e.jsx(n,{appId:o,config:{supportedChains:r,appearance:{loginMessage:"Log in or create your Spicenet account",accentColor:"#ea4b4b",theme:"#fafafa",showWalletLoginFirst:!1,walletChainType:"ethereum-only",walletList:["detected_ethereum_wallets","metamask","coinbase_wallet","base_account","rainbow","wallet_connect"]},loginMethods:["google","email","passkey"],fundingMethodConfig:{moonpay:{useSandbox:!0}},embeddedWallets:{requireUserPasswordOnCreate:!1,showWalletUIs:!0,ethereum:{createOnLogin:"users-without-wallets"},solana:{createOnLogin:"off"}},mfa:{noPromptOnMfaRequired:!1},externalWallets:{}},children:t})},fo=({children:t,environmentId:o})=>{const[r,n]=a.useState(null),[s,c]=a.useState(!1);return a.useEffect(()=>{c(!0),typeof window<"u"&&Promise.all([import("@dynamic-labs/sdk-react-core"),import("@dynamic-labs/ethereum")]).then(([i,d])=>{n({DynamicContextProvider:i.DynamicContextProvider,EthereumWalletConnectors:d.EthereumWalletConnectors})}).catch(i=>{})},[]),!s||!r?e.jsx(e.Fragment,{children:t}):e.jsx(r.DynamicContextProvider,{settings:{environmentId:o,walletConnectors:[r.EthereumWalletConnectors]},children:t})},mo=({children:t,provider:o,privyAppId:r,dynamicEnvironmentId:n,supportedChainIds:s=[11155111,421614,5115,123420001114],mode:c="7702",nativeChainId:i,appName:d="Spicenet"})=>{const g=s.map(f=>fe(f)?.viemChain).filter(Boolean);return c!=="7702"?(console.log(`[SpiceFlow] Running in ${c} mode - skipping embedded wallet providers`),e.jsx(Ue.Provider,{value:{provider:o,supportedChainIds:s,mode:c,nativeChainId:i,appName:d},children:t})):o==="privy"?r?e.jsx(Ue.Provider,{value:{provider:"privy",supportedChainIds:s,mode:c,nativeChainId:i,appName:d},children:e.jsx(xo,{appId:r,supportedViemChains:g,children:t})}):(console.warn("[SpiceFlow] Privy provider selected but no appId provided"),e.jsx(e.Fragment,{children:t})):o==="dynamic"?n?e.jsx(Ue.Provider,{value:{provider:"dynamic",supportedChainIds:s,mode:c,nativeChainId:i,appName:d},children:e.jsx(fo,{environmentId:n,children:t})}):(console.warn("[SpiceFlow] Dynamic provider selected but no environmentId provided"),e.jsx(e.Fragment,{children:t})):(console.warn("[SpiceFlow] No valid provider configuration found"),e.jsx(e.Fragment,{children:t}))},yo=()=>{const[t,o]=a.useState(!1);let r=null,n=null;try{r=_t.useDynamicContext()}catch(g){n=g instanceof Error?g.message:String(g),console.log("Dynamic context error in useWallet:",n)}if(a.useEffect(()=>{o(!0)},[]),n)return{isReady:!1,isAuthenticated:!1,isConnected:!1,provider:"dynamic",actions:{signAuthorization:async()=>{throw new Error("Dynamic context not available")},signMessage:async()=>{throw new Error("Dynamic context not available")}}};const{user:s,primaryWallet:c}=r||{},i=!!s,d=c?.address;return{isReady:t&&!!r,isAuthenticated:i,isConnected:i&&!!d,address:d,provider:"dynamic",actions:{signAuthorization:async g=>{if(!c)throw new Error("Dynamic primary wallet not available");const{isEthereumWallet:f}=await import("@dynamic-labs/ethereum");throw f(c)?new Error("Dynamic EIP-7702 authorization not yet implemented - check Dynamic docs for your version"):new Error("Primary wallet is not an Ethereum wallet")},signMessage:async g=>{if(!c)throw new Error("Dynamic primary wallet not available");const{isEthereumWallet:f}=await import("@dynamic-labs/ethereum");if(!f(c))throw new Error("Primary wallet is not an Ethereum wallet");const u=typeof g=="object"&&"raw"in g?{raw:g.raw}:g;return{signature:await(await c.getWalletClient()).signMessage({message:u,account:c.address})}}}}},gt=()=>{const t=a.useContext(Ue),o=t?.mode||"7702";let r=null;try{r=Je.useWallets()}catch{r=null}const n=r?.wallets?.find(i=>i.connectorType==="embedded")?.address;let s=null;try{s=_t.useDynamicContext()}catch{s=null}const c=s?.primaryWallet?.address;if(!(!t||o!=="7702"))return t.provider==="privy"?n:t.provider==="dynamic"?c:n??c},bo=()=>{const[t,o]=a.useState(!1);let r=null,n=null,s=null,c=null;try{r=Je.usePrivy(),n=Je.useSign7702Authorization(),s=Je.useSignMessage(),c=Je.useWallets()}catch{return{isReady:!1,isAuthenticated:!1,isConnected:!1,provider:null,actions:{signAuthorization:async()=>{throw new Error("Privy not available")},signMessage:async()=>{throw new Error("Privy not available")}}}}a.useEffect(()=>{o(!0)},[]);const{ready:i=!1,authenticated:d=!1}=r||{},g=gt(),f=c?.wallets?.find(u=>u.connectorType==="embedded");return{isReady:i,isAuthenticated:d,isConnected:i&&d&&!!g,address:g,provider:"privy",actions:{signAuthorization:async u=>{if(!n)throw new Error("Privy sign authorization not available");try{const l=await n.signAuthorization({contractAddress:u.contractAddress,chainId:u.chainId,nonce:u.nonce},{address:g});return delete l.v,l}catch(l){const C=l?.message||String(l);throw C.includes("not configured")||C.includes("chain")?new Error(`Chain ${u.chainId} is not configured in PrivyProvider. Add this chain to your Privy dashboard or supportedChainIds.`):l}},signMessage:async u=>{if(typeof u=="object"&&"raw"in u){if(!f)throw new Error("Embedded wallet not available for raw signing");const l=await f.getEthereumProvider();return{signature:await ae.createWalletClient({account:f.address,transport:ae.custom(l)}).signMessage({account:f.address,message:{raw:u.raw}})}}if(!s)throw new Error("Privy sign message not available");return{signature:(await s.signMessage({message:u})).signature}}}}},Lt=()=>{const t=a.useContext(Ue)?.provider;return t==="privy"?bo():t==="dynamic"?yo():{isReady:!1,isAuthenticated:!1,isConnected:!1,provider:null,actions:{signAuthorization:async()=>{throw new Error("No wallet provider available")},signMessage:async()=>{throw new Error("No wallet provider available")}}}},Yt=process.env.NEXT_PUBLIC_RELAYER_API_URL||"https://tx-submission-api-dev.spicenet.io";class Co{constructor(){this.baseUrl=Yt}async createAction(o){const r=await fetch(`${this.baseUrl}/actions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o,(n,s)=>typeof s=="bigint"?s.toString():s)});if(!r.ok){const n=await r.text();throw new Error(`Relayer API error: ${r.status} - ${n}`)}return r.json()}async executeStep(o,r,n,s){const c=await fetch(`${this.baseUrl}/actions/${o}/intents/${r}/steps/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!c.ok){const i=await c.text();throw new Error(`Execute step error: ${c.status} - ${i}`)}return{success:!0}}async checkStepStatus(o,r){const n=o.split("/");let s="";if(n.length>=2){const d=n[0],g=n[1];s=`${this.baseUrl}/actions/${d}/intents/${g}/steps/${r}`}else s=`${this.baseUrl}/actions/${o}/intents/0/steps/${r}`;const c=await fetch(s);if(!c.ok)throw new Error(`Intent step status check failed: ${c.status}`);const i=await c.json();return{success:!0,data:{status:i.status==="error"?"reverted":i.status,transactionHash:i.txid}}}async submitSpiceDeposit(o){const r=o.isDeposit?"deposit":"withdrawal";try{const n=await fetch(`${this.baseUrl}/spicedeposit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}),s=await n.json();return!n.ok||!s.success?(console.error(`Failed to submit ${r} request to API:`,s.error?.message),{success:!1,error:s.error}):s}catch(n){return console.error(`Error submitting ${r} request to API:`,n),{success:!1,error:{message:n instanceof Error?n.message:"Unknown error"}}}}async requestSpiceUsdAirdrop(o){try{const r=await fetch(`${this.baseUrl}/airdrop/${o.chainId}/spiceUsd`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({wallet:o.address})}),n=await r.json().catch(()=>({}));if(!r.ok){const s=n&&(n.error||n.message)||"Failed to request airdrop";return{success:!1,errorMessage:String(s)}}return n&&typeof n.error=="string"?{success:!1,errorMessage:n.error}:n&&(n.txHash||n.amount)?{success:!0,txHash:n.txHash,amount:n.amount}:{success:!0}}catch(r){return{success:!1,errorMessage:r?.message&&typeof r.message=="string"?r.message:"Failed to request airdrop"}}}}const we=new Co,Et=(t,o)=>{const r=s=>o?o(s):st(s),n=[];return t.forEach((s,c)=>{if(s.calls&&s.calls.length>0){const i={stepId:c,status:c===0?"processing":"pending",chainId:s.chainId,chainName:r(s.chainId),description:"Processing transaction"};n.push(i)}}),n},Ao=({swapBatches:t,tokenAddress:o="0x0",supportedChains:r,theme:n="light",styles:s,className:c="",showSlippageSettings:i=!0,enableFlipSwap:d=!0,fromInputHook:g,toInputUpdateHook:f})=>{const u=de.createTheme(n),l={...u,typography:{...u.typography,fontFamily:s?.fontFamily||u.typography.fontFamily},colors:{...u.colors,primary:s?.primaryColor||u.colors.primary,primaryHover:s?.primaryColor?`${s.primaryColor}dd`:u.colors.primaryHover}},C=Lt(),{isReady:A,isAuthenticated:w,isConnected:k,address:p,provider:b,actions:m}=C,j=a.useContext(Ue),[y,h]=a.useState(null),[x,S]=a.useState(null),[F,B]=a.useState(null),[I,G]=a.useState(""),[P,_]=a.useState({slippage:"0.5%"}),[$,J]=a.useState(!1),[M,z]=a.useTransition(),{assets:E,loading:U,error:X,refreshAssets:ee}=Vt({address:p,supportedChains:r,fetchBalances:zt}),[H,ne]=a.useState(!1),[xe,ue]=a.useState(null),{intentStatus:Ee,startStatusPolling:R,clearStatus:q}=kt({checkStepStatus:(W,K)=>we.checkStepStatus(W,K)}),pe=a.useCallback(()=>{if(E.length===0||F)return;const W=E.filter(ie=>ie.isNative),K=W.length>0?W[0]:E[0];K&&B(K)},[E,F]);a.useEffect(()=>{pe()},[pe]),a.useEffect(()=>{f&&f.toAmount!==x?.amount&&x&&S({...x,amount:f.toAmount})},[f?.toAmount,x]);const v=a.useCallback(()=>{ue(null)},[]),N=(W,K)=>W.chainId===K.chainId&&W.address.toLowerCase()===K.address.toLowerCase(),O=(W,K)=>{if(K==="collateral"){const ie=E.filter(me=>!N(me,W));return ie.length>0?ie[0]:null}else{const ie=r.flatMap(me=>Rt(me,E)).filter(me=>!N(me,W));return ie.length>0?ie[0]:null}},se=W=>{if(x&&N(x.asset,W)){const K=O(W,"fromTo");S(K?{asset:K,amount:""}:null)}if(F&&N(F,W)){const K=O(W,"collateral");B(K)}h({asset:W,amount:y?.amount||""}),v()},re=W=>{if(y&&N(y.asset,W)){const K=O(W,"fromTo");h(K?{asset:K,amount:""}:null)}if(F&&N(F,W)){const K=O(W,"collateral");B(K)}S({asset:W,amount:x?.amount||""}),v()},Z=W=>{if(y&&N(y.asset,W)){const K=O(W,"fromTo");h(K?{asset:K,amount:""}:null)}if(x&&N(x.asset,W)){const K=O(W,"fromTo");S(K?{asset:K,amount:""}:null)}B(W),v()},he=a.useCallback(W=>{y&&(z(()=>{h({...y,amount:W}),x&&S({...x,amount:W}),G(W),v()}),g&&g.setFromAmount(W))},[y,x,g,v]),Ce=a.useCallback(W=>{x&&z(()=>{S({...x,amount:W}),y&&h({...y,amount:W}),G(W),v()})},[x,y,v]),T=a.useCallback(W=>{z(()=>{G(W),y&&h({...y,amount:W}),x&&S({...x,amount:W}),v()})},[y,x,v]),oe=a.useCallback(()=>{if(d&&y&&x){const W=y.amount;z(()=>{h({asset:x.asset,amount:W}),S({asset:y.asset,amount:W}),G(W),J(!$),v()})}},[d,y,x,$,v]),le=async()=>{if(!y||!x||!F||!p||t.length===0)return;const W=j?.mode||"7702";if(W==="7702"&&(!A||!w)){ue(`Please authenticate with ${b||"wallet provider"} to continue`);return}if(W!=="7702"){ue("Only EIP-7702 mode is currently supported for Swaps.");return}ne(!0),ue(null);try{const K=await Ve(F.chainId).getBlockNumber(),ie=[{chainId:F.chainId,recentBlock:K,calls:[{to:"0xeee2b52e7CFe6e2168341a34cEB783b68FEdf1A2",value:ae.parseEther(I),data:"0x"}]},...t],me=[...new Set(ie.map(be=>be.chainId))],$e=[];for(const be of me){const Re=Ve(be),ge=ct(be),nt=await Ye.getAccountNonce(p,Re),tt=await m.signAuthorization({contractAddress:ge,chainId:be,nonce:Number(nt)});$e.push(tt)}const Y=Ye.hashChainBatches(ie),te=Math.floor(Date.now()/1e3)+60*10,Fe=Ye.getIntentHash(BigInt(0),BigInt(te),Y),De=await m.signMessage({raw:Fe}),_e=typeof De=="string"?De:De.signature;if(!_e)throw new Error("Failed to sign intent authorization");const at={mode:"7702",signatureType:"ecdsa",signature:_e,nbf:0,exp:te,chainBatches:Y.map(be=>({hash:be.hash,chainId:Number(be.chainId),tokenTransfers:[],calls:be.calls}))},et={user:p,chainAuthorizations:$e.map(be=>({...be,r:be.r,s:be.s,nonce:Number(be.nonce),chainId:Number(be.chainId)})),intents:[at]},Ze=await we.createAction(et);if(Ze){const be=Et(ie,Re=>`Chain ${Re}`);R(Ze.intentIds[0],be);for(let Re=0;Re<ie.length;Re++)console.log(`[SwapWidget] Executing step ${Re}...`),await we.executeStep(Ze.actionId,0,Re,{action:"execute"}),console.log(`[SwapWidget] Step ${Re} completed`);console.log("[SwapWidget] All steps executed"),ee()}}catch(K){const ie=K instanceof Error?K.message:"Swap failed";ue(ie)}finally{ne(!1)}},Se=r.flatMap(W=>Rt(W,E)),ve=r.flatMap(W=>Rt(W,E)),ke=E.filter(W=>r.includes(W.chainId)),Ie=y&&x&&F&&y.amount&&parseFloat(y.amount)>0&&parseFloat(y.amount)<=y.asset.balanceFormatted&&I&&parseFloat(I)>0&&parseFloat(I)<=F.balanceFormatted&&k&&!H&&t.length>0,ce=X||xe,ze={backgroundColor:s?.container?.backgroundColor||s?.primaryBackground||l.colors.background,border:`1px solid ${s?.container?.borderColor||l.colors.border}`,borderRadius:s?.container?.borderRadius||l.borderRadius.lg,padding:s?.container?.padding||l.spacing.md,width:s?.container?.width||"100%",maxWidth:"28rem",margin:"0 auto",color:l.colors.text,fontFamily:l.typography.fontFamily,boxShadow:s?.container?.boxShadow||(l.mode==="light"?"0 4px 6px -1px rgb(0 0 0 / 0.1)":"0 4px 6px -1px rgb(0 0 0 / 0.3)")};return Ee?e.jsx("div",{className:c,children:e.jsx(uo,{intentStatus:Ee,onClose:q,onRetry:()=>{q(),le()},txType:"swap",onNewTx:()=>{q(),h(null),S(null),B(null),G(""),ee()},explorerUrlBuilder:(W,K)=>Wt(W,K),theme:l})}):e.jsxs("div",{style:ze,className:c,children:[e.jsxs("div",{style:{marginBottom:l.spacing.sm},children:[" ",e.jsxs("div",{style:{padding:s?.statusDisplay?.padding||"8px",backgroundColor:s?.statusDisplay?.backgroundColor||s?.tertiaryBackground||(l.mode==="light"?"#f9fafb":l.colors.surface),border:`1px solid ${s?.statusDisplay?.borderColor||(l.mode==="light"?"#e5e7eb":l.colors.border)}`,borderRadius:s?.statusDisplay?.borderRadius||l.borderRadius.md},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("span",{style:{fontSize:s?.statusDisplay?.text?.fontSize||l.typography.fontSize.xs,fontWeight:s?.statusDisplay?.text?.fontWeight||l.typography.fontWeight.medium,color:s?.statusDisplay?.text?.color||l.colors.text,fontFamily:s?.statusDisplay?.text?.fontFamily||l.typography.fontFamily},children:[j?.provider==="privy"?"Privy":j?.provider==="dynamic"?"Dynamic":"Wallet"," ","Status"]}),e.jsx("span",{style:{fontSize:s?.statusDisplay?.text?.fontSize||l.typography.fontSize.xs,padding:`2px ${l.spacing.xs}`,borderRadius:l.borderRadius.sm,border:`1px solid ${k?s?.statusDisplay?.successColor||l.colors.success:s?.statusDisplay?.warningColor||l.colors.warning}`,backgroundColor:k?l.mode==="light"?"#dcfce7":`${s?.statusDisplay?.successColor||l.colors.success}20`:l.mode==="light"?"#fef3c7":`${s?.statusDisplay?.warningColor||l.colors.warning}20`,color:k?s?.statusDisplay?.successColor||l.colors.success:s?.statusDisplay?.warningColor||l.colors.warning,fontFamily:s?.statusDisplay?.text?.fontFamily||l.typography.fontFamily},children:k?"Connected":"Disconnected"})]}),k&&p&&e.jsxs("div",{className:"ibm-plex-mono",style:{marginTop:"6px",backgroundColor:s?.addressDisplay?.backgroundColor||(l.mode==="light"?"#f3f4f6":l.colors.secondary),border:`1px solid ${s?.addressDisplay?.borderColor||(l.mode==="light"?"#d1d5db":l.colors.borderHover)}`,borderRadius:s?.addressDisplay?.borderRadius||l.borderRadius.sm,padding:s?.addressDisplay?.padding||`${l.spacing.xs} ${l.spacing.sm}`,fontSize:s?.addressDisplay?.fontSize||l.typography.fontSize.xs,fontFamily:s?.addressDisplay?.fontFamily||(s?.fontFamily?`${s.fontFamily}, IBM Plex Mono`:"IBM Plex Mono"),color:s?.addressDisplay?.color||l.colors.text,display:"flex",alignItems:"center",gap:l.spacing.sm},children:[e.jsxs("span",{style:{flex:1},children:[p.slice(0,6),"...",p.slice(-4)]}),e.jsx("button",{style:{fontSize:s?.addressDisplay?.copyButton?.fontSize||l.typography.fontSize.xs,padding:s?.addressDisplay?.copyButton?.padding||`${l.spacing.xs} ${l.spacing.sm}`,backgroundColor:s?.addressDisplay?.copyButton?.backgroundColor||(l.mode==="light"?"#e5e7eb":l.colors.surfaceHover),border:`1px solid ${s?.addressDisplay?.copyButton?.borderColor||(l.mode==="light"?"#d1d5db":l.colors.border)}`,borderRadius:s?.addressDisplay?.copyButton?.borderRadius||l.borderRadius.sm,color:s?.addressDisplay?.copyButton?.color||l.colors.text,fontFamily:s?.addressDisplay?.copyButton?.fontFamily||l.typography.fontFamily,cursor:"pointer",transition:`background-color ${l.animation.normal}`},onClick:()=>ro(p),title:"Copy address",children:"Copy"})]}),!A&&e.jsxs("div",{style:{marginTop:"6px",fontSize:l.typography.fontSize.xs,color:l.colors.textSecondary,fontFamily:l.typography.fontFamily},children:["Loading"," ",j?.provider==="privy"?"Privy":j?.provider==="dynamic"?"Dynamic":"Wallet","..."]})]})]}),e.jsxs("div",{style:{marginBottom:l.spacing.sm},children:[" ",e.jsx(go,{assets:ke,selectedAsset:F,onAssetSelect:Z,onAmountChange:T,amount:I,loading:U,label:"Collateral",theme:l,styles:s})]}),e.jsx("div",{style:{marginBottom:0},children:e.jsx(ht,{assets:Se,selectedAsset:y||void 0,onAssetSelect:se,onAmountChange:he,loading:U,label:"From",showBalance:!0,showMaxButton:!0,theme:l,styles:s})}),d&&e.jsx("div",{style:{display:"flex",justifyContent:"center",margin:`-${l.spacing.sm} 0`,position:"relative",zIndex:10},children:e.jsx("button",{onClick:oe,disabled:H||U,style:{backgroundColor:s?.flipButton?.backgroundColor||l.colors.primary,border:`1px solid ${s?.flipButton?.borderColor||l.colors.primary}`,borderRadius:s?.flipButton?.borderRadius||"50%",width:s?.flipButton?.size||"2.5rem",height:s?.flipButton?.size||"2.5rem",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",color:s?.flipButton?.color||"#ffffff",transition:`all ${l.animation.normal}`,transform:$?"rotate(180deg)":"rotate(0deg)",boxShadow:l.mode==="light"?"0 2px 4px rgba(0, 0, 0, 0.1)":"0 2px 4px rgba(0, 0, 0, 0.3)"},onMouseEnter:W=>{W.currentTarget.style.backgroundColor=s?.flipButton?.hoverBackgroundColor||l.colors.primaryHover,W.currentTarget.style.transform=$?"rotate(360deg) scale(1.1)":"rotate(0deg) scale(1.1)"},onMouseLeave:W=>{W.currentTarget.style.backgroundColor=s?.flipButton?.backgroundColor||l.colors.primary,W.currentTarget.style.transform=$?"rotate(360deg) scale(1)":"rotate(0deg) scale(1)"},children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M6 9l6 6 6-6"})})})}),e.jsxs("div",{style:{marginBottom:l.spacing.sm},children:[" ",e.jsx(ht,{assets:ve,selectedAsset:x||void 0,onAssetSelect:re,onAmountChange:Ce,loading:U,label:"To",theme:l,styles:s})]}),i&&e.jsxs("div",{style:{marginBottom:l.spacing.sm},children:[" ",e.jsx(ho,{config:P,onChange:_,theme:l,styles:s})]}),t.length>0&&e.jsxs("div",{style:{marginBottom:l.spacing.sm},children:[" ",e.jsxs("div",{style:{backgroundColor:s?.infoCard?.backgroundColor||s?.tertiaryBackground||(l.mode==="light"?"#f9fafb":l.colors.surface),border:`1px solid ${s?.infoCard?.borderColor||(l.mode==="light"?"#e5e7eb":l.colors.border)}`,borderRadius:s?.infoCard?.borderRadius||l.borderRadius.md,padding:s?.infoCard?.padding||l.spacing.sm},children:[e.jsx("div",{style:{fontSize:s?.infoCard?.title?.fontSize||l.typography.fontSize.xs,fontWeight:s?.infoCard?.title?.fontWeight||l.typography.fontWeight.medium,color:s?.infoCard?.title?.color||l.colors.text,fontFamily:s?.infoCard?.title?.fontFamily||l.typography.fontFamily,marginBottom:"4px"},children:"Swap Batches Ready"}),e.jsxs("div",{style:{fontSize:s?.infoCard?.description?.fontSize||l.typography.fontSize.xs,color:s?.infoCard?.description?.color||l.colors.textSecondary,fontFamily:s?.infoCard?.description?.fontFamily||l.typography.fontFamily},children:[t.length," swap batch",t.length>1?"es":""," across chains:"," ",[...new Set(t.map(W=>W.chainId))].join(", ")]})]})]}),ce&&e.jsx("div",{style:{backgroundColor:s?.errorMessage?.backgroundColor||(l.mode==="light"?"#fef2f2":`${s?.statusDisplay?.errorColor||l.colors.error}20`),border:`1px solid ${s?.errorMessage?.borderColor||(l.mode==="light"?"#fecaca":s?.statusDisplay?.errorColor||l.colors.error)}`,borderRadius:s?.errorMessage?.borderRadius||l.borderRadius.md,padding:s?.errorMessage?.padding||l.spacing.md,marginBottom:l.spacing.sm},children:e.jsx("p",{style:{color:s?.errorMessage?.color||s?.statusDisplay?.errorColor||l.colors.error,fontSize:s?.errorMessage?.fontSize||l.typography.fontSize.sm,fontWeight:s?.errorMessage?.fontWeight,fontFamily:s?.errorMessage?.fontFamily||l.typography.fontFamily,margin:0},children:ce})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:l.spacing.sm},children:e.jsx(de.Button,{variant:"primary",fullWidth:!0,onClick:le,loading:H,disabled:!Ie||!k,theme:l,styles:s,children:A?w?k?H?"Executing Swap...":y?x?F?y.amount?I?parseFloat(y.amount)>y.asset.balanceFormatted?"Insufficient From Balance":parseFloat(I)>F.balanceFormatted?"Insufficient Collateral Balance":t.length===0?"No Swap Batches":"Execute Swap":"Enter Collateral Amount":"Enter Amount":"Select Collateral":"Select To Token":"Select From Token":"Wallet Not Connected":"Authentication Required":"Loading..."})})]})},us=({address:t,supportedChains:o,enabled:r=!0,refetchInterval:n})=>{const[s,c]=a.useState([]),[i,d]=a.useState(!1),[g,f]=a.useState(null),[u,l]=a.useState(!1),C=a.useRef(!1),A=a.useRef(!1),w=o?JSON.stringify([...o].sort()):"",k=a.useCallback(async(m=!1)=>{if(!t||!r){c([]),l(!1),C.current=!1;return}if(!A.current){A.current=!0,!C.current&&!m&&d(!0),f(null);try{const j=await fetch(`${Yt}/spicedeposit/${t}`);if(!j.ok)throw new Error(`Failed to fetch balance: ${j.status}`);const y=await j.json();if(y.success&&y.data?.tokens&&Array.isArray(y.data.tokens)){const h=[];y.data.tokens.forEach(x=>{const S=x.chainId,F=x.tokenAddress,B=x.amount;if(o&&!o.includes(S))return;const I=BigInt(B||"0");if(I>BigInt(0)){const G=fe(S),P=F.toLowerCase()==="0x0"||F.toLowerCase()==="0x0000000000000000000000000000000000000000"||F.toLowerCase()==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";let _=18,$="TOKEN",J=F.slice(0,6)+"..."+F.slice(-4),M;if(P)_=G?.nativeCurrency?.decimals||18,$=G?.nativeCurrency?.symbol||"ETH",J=G?.nativeCurrency?.name||"Native Token";else{const E=G?.supportedTokens?.find(U=>U.address.toLowerCase()===F.toLowerCase());E&&(_=E.decimals,$=E.symbol,J=E.name,M=E.logoURI)}const z=parseFloat((Number(I)/Math.pow(10,_)).toFixed(6));z>0&&h.push({address:P?"0x0000000000000000000000000000000000000000":F,symbol:$,name:J,decimals:_,chainId:S,balance:I,balanceFormatted:z,balanceUsd:0,isNative:P,logoURI:M})}}),c(h),l(h.length>0),C.current=!0}else c([]),l(!1)}catch(j){const y=j instanceof Error?j.message:"Failed to fetch balance";f(y),console.error("Error fetching Spice assets:",j),C.current||(c([]),l(!1))}finally{d(!1),A.current=!1}}},[t,r,w]);a.useEffect(()=>{r&&t&&(C.current=!1,k(!1))},[t,r,w]),a.useEffect(()=>{if(!r||!t||!n)return;const m=setInterval(()=>{k(!0)},n);return()=>clearInterval(m)},[t,r,n,w]);const p=a.useCallback(m=>s.filter(j=>j.chainId===m),[s]),b=a.useCallback(async()=>{await k(!0)},[k]);return{assets:s,loading:i,error:g,hasBalance:u,refetch:b,getAssetsByChain:p}},hs=({isSuccess:t,type:o,chainName:r,explorerUrl:n,txHash:s})=>e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px",borderRadius:"8px",backgroundColor:t?"#d1fae5":"#fee2e2",border:t?"1px solid #6ee7b7":"1px solid #fca5a5"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx("div",{style:{width:"28px",height:"28px",borderRadius:"50%",backgroundColor:t?"#10b981":"#ef4444",display:"flex",alignItems:"center",justifyContent:"center"},children:t?e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:e.jsx("path",{d:"M11.6667 3.5L5.25 9.91667L2.33333 7",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}):e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:e.jsx("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:0,fontSize:"14px",fontWeight:600,fontFamily:'"IBM Plex Mono", monospace',letterSpacing:"0.5px",color:t?"#065f46":"#dc2626"},children:t?`${o.toUpperCase()} CONFIRMED`:`${o.toUpperCase()} FAILED`}),e.jsxs("p",{style:{margin:"2px 0 0 0",fontSize:"12px",color:"#6b7280"},children:["on ",r]})]})]}),n&&s&&e.jsxs("a",{href:`${n}/tx/${s}`,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"13px",color:"#6b7280",textDecoration:"none",whiteSpace:"nowrap"},children:["View on explorer",e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:[e.jsx("path",{d:"M9 6.5V9.5C9 9.76522 8.89464 10.0196 8.70711 10.2071C8.51957 10.3946 8.26522 10.5 8 10.5H2.5C2.23478 10.5 1.98043 10.3946 1.79289 10.2071C1.60536 10.0196 1.5 9.76522 1.5 9.5V4C1.5 3.73478 1.60536 3.48043 1.79289 3.29289C1.98043 3.10536 2.23478 3 2.5 3H5.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M7.5 1.5H10.5V4.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M5 7L10.5 1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]})]})]}),qt=({isOpen:t,onClose:o,onComplete:r,type:n,results:s,chainName:c="Network",explorerUrl:i,theme:d,styles:g,intentStatus:f,onRetry:u,onNewTx:l,onRetryTx:C,asOverlay:A=!1,isProcessing:w=!1})=>{const k=d||de.createTheme("light"),[p,b]=a.useState(!1),[m,j]=a.useState(!0),[y,h]=a.useState(null),[x,S]=a.useState(null);a.useEffect(()=>{!t&&!f&&b(!1)},[t,f]);const F=()=>{b(!0),setTimeout(()=>{r?.()},300)},B=()=>{j(!m)};if(f){const{steps:P,overallStatus:_}=f,$=_==="processing",J=_==="success",M=_==="failed",z=P.find(ee=>ee.transactionHash),E=c!=="Network"?c:P[0]?.chainName||c,U=i||(z?Wt(z.chainId,z.transactionHash||"").replace(/\/tx\/.*$/,""):void 0),X=e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"16px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},onClick:B,children:[e.jsx("span",{style:{fontSize:"13px",fontWeight:500,color:"#6b7280",fontFamily:g?.fontFamily||k.typography.fontFamily},children:$?"Processing ${type}":"${type} Results"}),e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",style:{transform:m?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.3s ease"},children:e.jsx("path",{d:"M4 6L8 10L12 6",stroke:"#6b7280",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),!$&&e.jsx("button",{onClick:o,onMouseEnter:()=>h("close"),onMouseLeave:()=>{h(null),S(null)},onMouseDown:()=>S("close"),onMouseUp:()=>S(null),style:{background:x==="close"?"#f3f4f6":y==="close"?"#f9fafb":"none",border:"none",borderRadius:"4px",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:y==="close"||x==="close"?"#374151":"#6b7280",transform:x==="close"?"scale(0.9)":y==="close"?"scale(1.1)":"scale(1)",transition:"all 0.15s ease"},children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:e.jsx("path",{d:"M12 4L4 12M4 4L12 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e.jsx("div",{style:{marginBottom:"16px"},children:$?e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px 16px",borderRadius:"8px",backgroundColor:"#f3f4f6",border:"1px solid #e5e7eb",gap:"12px"},children:[e.jsx("div",{style:{width:"24px",height:"24px",border:"3px solid #e5e7eb",borderTopColor:k.colors.primary,borderRadius:"50%",animation:"spin 1s linear infinite"}}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:0,fontSize:"14px",fontWeight:600,fontFamily:'"IBM Plex Mono", monospace',letterSpacing:"0.5px",color:"#374151"},children:"PROCESSING TRANSACTION"}),e.jsxs("p",{style:{margin:"2px 0 0 0",fontSize:"12px",color:"#6b7280"},children:["on ",E]})]})]}):e.jsx(hs,{isSuccess:J,type:n,chainName:E,explorerUrl:U,txHash:z?.transactionHash})}),e.jsx("style",{children:`
|
|
2
|
+
"use strict";var zs=Object.create;var $t=Object.defineProperty;var Vs=Object.getOwnPropertyDescriptor;var Ns=Object.getOwnPropertyNames;var Ys=Object.getPrototypeOf,qs=Object.prototype.hasOwnProperty;var Ps=(t,o,r,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of Ns(o))!qs.call(t,s)&&s!==r&&$t(t,s,{get:()=>o[s],enumerable:!(n=Vs(o,s))||n.enumerable});return t};var lt=(t,o,r)=>(r=t!=null?zs(Ys(t)):{},Ps(o||!t||!t.__esModule?$t(r,"default",{value:t,enumerable:!0}):r,t));const ae=require("viem"),Tt=require("viem/actions"),At=require("viem/chains"),e=require("react/jsx-runtime"),a=require("react"),de=require("./Button-Cn16gFtO.js"),Js=require("react-dom"),Je=require("@privy-io/react-auth"),_t=require("@dynamic-labs/sdk-react-core"),Ye=require("@spicenet-io/spiceflow-core"),Ae=require("wagmi"),Zs=require("./auth-dynamic.cjs.js"),Gs=require("./auth-privy.cjs.js"),es=require("@tanstack/react-query"),ts=require("wagmi/chains"),ss=require("wagmi/connectors"),dt=[{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{payable:!0,stateMutability:"payable",type:"fallback"},{anonymous:!1,inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Transfer",type:"event"}],os={11155111:{id:11155111,name:"Ethereum Sepolia",displayName:"Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpc:"https://site1.moralis-nodes.com/sepolia/b59c444a55b74d56b3f836d2dd7144eb",blockExplorers:{default:{name:"Etherscan",url:"https://sepolia.etherscan.io"}},viemChain:At.sepolia,delegateContract:"0xDF7d39BB544778F467D10b08B1F5C170fd7fB480",icon:{symbol:"\u039E",backgroundColor:"#627EEA",textColor:"#FFFFFF"},moralisName:"sepolia",supportedTokens:[{address:"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",name:"USD Coin",symbol:"USDC",decimals:6},{address:"0x76f983E0F5a4B72C4bac99Fc9399845a58078787",name:"Mock Tether USD",symbol:"USDT",decimals:6},{address:"0x4Fc381B6CC6Df8cF1c1bD46D184475bE5b7A3c62",name:"Mock Wrapped BTC",symbol:"WBTC",decimals:8}]},421614:{id:421614,name:"Arbitrum Sepolia",displayName:"Arbitrum Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpc:"https://site1.moralis-nodes.com/arbitrum-sepolia/a3b4b1042f834a959541c96811ef44bb",blockExplorers:{default:{name:"Arbiscan",url:"https://sepolia.arbiscan.io"}},viemChain:At.arbitrumSepolia,delegateContract:"0x151755d1bdFeB6082D141EF86e4291b2e902b43F",icon:{symbol:"A",backgroundColor:"#28A0F0",textColor:"#FFFFFF"},moralisName:"",supportedTokens:[{address:"0xBeB51deb2018b67b35d5695Fd15bb30D452c7868",name:"USD Coin",symbol:"USDC",decimals:18},{address:"0xBA4c54d4CF10C766c22A08F783998cFaB237F7C9",name:"Mock Wrapped BTC",symbol:"WBTC",decimals:8}]},84532:{id:84532,name:"Base Sepolia",displayName:"Base Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpc:"https://site1.moralis-nodes.com/base-sepolia/0563a61e273c428f906716cd4befa362",blockExplorers:{default:{name:"Basescan",url:"https://sepolia.basescan.org"}},viemChain:At.baseSepolia,delegateContract:"0xD4C4A222cdd42f5c3219249a083a5aBf1420E9D8",icon:{symbol:"B",backgroundColor:"#0052FF",textColor:"#FFFFFF"},moralisName:"0x14a34",supportedTokens:[{address:"0xf370dC3765f81aC9dD2FEBd59Fb4e710330B0BC8",name:"USD Coin",symbol:"USDC",decimals:18},{address:"0x16DD3a855433059Be478FAcb416D9aFed6CA96Ec",name:"Mock Wrapped BTC",symbol:"WBTC",decimals:8}]},5115:{id:5115,name:"Citrea Testnet",displayName:"Citrea Testnet",nativeCurrency:{name:"cBTC",symbol:"cBTC",decimals:18},rpc:"https://rpc.testnet.citrea.xyz",blockExplorers:{default:{name:"Citrea Explorer",url:"https://explorer.testnet.citrea.xyz"}},viemChain:At.citreaTestnet,delegateContract:"0x9DE3D53419a8F821b6E2039A7249c5738004FB94",icon:{symbol:"C",backgroundColor:"#EA4B4B",textColor:"#FFFFFF"},moralisName:"",supportedTokens:[{address:"0xf19308F923582A6f7c465e5CE7a9Dc1BEC6665B1",name:"USD Coin",symbol:"USD",decimals:18},{address:"0x2876a1fb400c238b0a9e4edd2e7e03d3cf9b53c2",name:"CBTC Vault",symbol:"eCBTC",decimals:18,logoURI:"https://citrea.elitra.xyz/images/tokens/cbtc.jpg"},{address:"0x2d41d86bb9e7161561fa3186b47d160467efcee3",name:"NUSD Vault",symbol:"eNUSD",decimals:18,logoURI:"https://www.satsuma.exchange/nusd-icon.svg"},{address:"0x8d0c9d1c17aE5e40ffF9bE350f57840E9E66Cd93",name:"Wrapped Citrea BTC",symbol:"WCBTC",decimals:18,logoURI:"https://citrea.elitra.xyz/images/tokens/cbtc.jpg"}]},123420001114:{id:123420001114,name:"Base Camp",displayName:"Base Camp",nativeCurrency:{name:"Ethereum",symbol:"ETH",decimals:18},rpc:"https://rpc.basecamp.t.raas.gelato.cloud",blockExplorers:{default:{name:"Base Camp Explorer",url:"https://basecamp.gelato.network"}},viemChain:At.basecampTestnet,delegateContract:"0xA15BFeD4eC0BEdd36b00b9856aFa1C6BCFE61574",icon:{symbol:"B",backgroundColor:"#0052FF",textColor:"#FFFFFF"},moralisName:"",supportedTokens:[]},688688:{id:688688,name:"Pharos Testnet",displayName:"Pharos Testnet",nativeCurrency:{name:"PHRS",symbol:"PHRS",decimals:18},rpc:"https://testnet.dplabs-internal.com",blockExplorers:{default:{name:"Pharos Explorer",url:"https://testnet.pharosscan.xyz"}},viemChain:ae.defineChain({id:688688,name:"Pharos Testnet",nativeCurrency:{decimals:18,name:"PHRS",symbol:"PHRS"},rpcUrls:{default:{http:["https://testnet.dplabs-internal.com"]}},blockExplorers:{default:{name:"Pharos Explorer",url:"https://testnet.pharosscan.xyz"}},testnet:!0}),delegateContract:"0xAd45b774C4c632540d36f2105889C0E6aC28b504",icon:{symbol:"P",backgroundColor:"#4A90E2",textColor:"#FFFFFF"},moralisName:""},688689:{id:688689,name:"Pharos Testnet",displayName:"Pharos Testnet",nativeCurrency:{name:"PHRS",symbol:"PHRS",decimals:18},rpc:"https://atlantic.dplabs-internal.com",blockExplorers:{default:{name:"Pharos Atlantic Explorer",url:"https://atlantic.pharosscan.xyz/"}},viemChain:ae.defineChain({id:688689,name:"Pharos Testnet",nativeCurrency:{decimals:18,name:"PHRS",symbol:"PHRS"},rpcUrls:{default:{http:["https://atlantic.dplabs-internal.com"]}},blockExplorers:{default:{name:"Pharos Atlantic Explorer",url:"https://atlantic.pharosscan.xyz/"}},testnet:!0}),delegateContract:"0xAd45b774C4c632540d36f2105889C0E6aC28b504",icon:{symbol:"P",backgroundColor:"#4A90E2",textColor:"#FFFFFF"},moralisName:"",supportedTokens:[{address:"0x16b90aeb3de140dde993da1d5734bca28574702b",name:"USD Stable Coin",symbol:"USD",decimals:6}]}},fe=t=>os[t],st=t=>fe(t)?.name||`Chain ${t}`,ct=t=>{const o=fe(t);if(!o)throw new Error(`Unsupported chain ID: ${t}`);return o.delegateContract},Wt=(t,o,r)=>{const n=fe(t);return n?.blockExplorers?.default?.url?`${n.blockExplorers.default.url}/tx/${o}`:"#"},Ve=t=>{const o=fe(t);if(!o)throw new Error(`Unsupported chain ID: ${t}`);return ae.createPublicClient({chain:o.viemChain,transport:ae.http(o.rpc)})},Ks=t=>{const o=fe(t);if(o)return{icon:o.icon.symbol,bg:o.icon.backgroundColor,text:o.icon.textColor};const r=`Chain ${t}`,n=r.split("").reduce((d,g)=>g.charCodeAt(0)+((d<<5)-d),0),s=Math.abs(n)%360,c=`hsl(${s}, 60%, 50%)`,i=s>180?"#FFFFFF":"#000000";return{style:{backgroundColor:c,color:i},icon:r.charAt(0).toUpperCase()}},Os=()=>{const t={};return Object.values(os).forEach(o=>{t[o.id]={name:o.name,moralisName:o.moralisName||"",chain:o.viemChain,rpcUrl:o.rpc}}),t},Xs=t=>{const o=fe(t);if(!o)throw new Error(`Chain ${t} not supported`);return ae.createPublicClient({chain:o.viemChain,transport:ae.http(o.rpc)})},$s=(t,o,r=BigInt(0),n=0)=>({address:o.address,name:o.name,symbol:o.symbol,decimals:o.decimals,balance:r,balanceFormatted:n,balanceUsd:0,logoURI:o.logoURI,isNative:!1,chainId:t}),_s=(t,o=BigInt(0),r=0)=>{const n=fe(t);return n?{address:"0x0000000000000000000000000000000000000000",name:n.nativeCurrency.name,symbol:n.nativeCurrency.symbol,decimals:n.nativeCurrency.decimals,balance:o,balanceFormatted:r,balanceUsd:0,logoURI:void 0,isNative:!0,chainId:t}:null},Rt=(t,o=[])=>{const r=fe(t);if(!r)return[];const n=[];if(![11155111,421614,84532,688689].includes(t)){const s=o.find(c=>c.chainId===t&&c.isNative);s?n.push(s):n.push(_s(t))}return r.supportedTokens&&r.supportedTokens.forEach(s=>{const c=o.find(i=>i.chainId===t&&i.address.toLowerCase()===s.address.toLowerCase());c?n.push(c):n.push($s(t,s))}),n},Dt=t=>{const o=t.toLowerCase();return o==="0x0"||o==="0x0000000000000000000000000000000000000000"||o==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"},wt=t=>Dt(t)?"0x0":t,ns=async(t,o)=>{const r=fe(t);if(!r)throw new Error(`Unsupported chain ID: ${t}`);const n=o.toLowerCase();if(Dt(n)){if(!r.nativeCurrency?.decimals)throw new Error(`Native currency decimals not configured for chain ${t}`);return r.nativeCurrency.decimals}if(r.supportedTokens){const s=r.supportedTokens.find(c=>c.address.toLowerCase()===n);if(s)return s.decimals}try{if(!ae.isAddress(o))throw new Error(`Invalid token address: ${o}`);const s=ae.getAddress(o),c=Ve(t),i=await Tt.readContract(c,{address:s,abi:dt,functionName:"decimals"});return Number(i)}catch(s){throw console.error(`Failed to fetch decimals for token ${o} on chain ${t}:`,s),new Error(`Could not determine decimals for token ${o} on chain ${t}`)}},eo=(t,o,r)=>{if(o===r)return t;if(o<r){const n=BigInt(10)**BigInt(r-o);return t*n}else{const n=BigInt(10)**BigInt(o-r);return t/n}},to="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJub25jZSI6ImVmMWEzZDM1LTYwMGUtNDcwNC04MTk3LTIzODc2NWNlYmQ2NCIsIm9yZ0lkIjoiNDY2Nzk0IiwidXNlcklkIjoiNDgwMjI3IiwidHlwZUlkIjoiMTk3YWMxMzMtNDY3ZS00YWIyLWFlZmUtM2VlMjU0NGNjM2NiIiwidHlwZSI6IlBST0pFQ1QiLCJpYXQiOjE3NTU5NjY3MjIsImV4cCI6NDkxMTcyNjcyMn0.7KHx_SwI89GVKFkgqtl-sUV9CUKWkDjZbkBAVAX2Djk",so="https://deep-index.moralis.io/api/v2.2",St=Os(),rs=Xs,as=async(t,o)=>{try{const r=rs(o),n=await Tt.getBalance(r,{address:t}),s=St[o],c=parseFloat((Number(n)/Math.pow(10,18)).toFixed(6));return{address:"0x0000000000000000000000000000000000000000",name:s.chain.nativeCurrency.name,symbol:s.chain.nativeCurrency.symbol,decimals:s.chain.nativeCurrency.decimals,balance:n,balanceFormatted:c,balanceUsd:0,logoURI:void 0,isNative:!0,chainId:o}}catch(r){return console.error(`Error fetching native balance for ${o}:`,r),{address:"0x0000000000000000000000000000000000000000",name:St[o].chain.nativeCurrency.name,symbol:St[o].chain.nativeCurrency.symbol,decimals:18,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:void 0,isNative:!0,chainId:o}}},is=async(t,o,r,n,s,c)=>{try{if(!ae.isAddress(r))return console.warn(`Invalid token address ${r} for chain ${o}, skipping...`),null;const i=ae.getAddress(r),d=ae.isAddress(t)?ae.getAddress(t):t,g=rs(o),f=await Tt.readContract(g,{address:i,abi:dt,functionName:"balanceOf",args:[d]}),u=parseFloat((Number(f)/Math.pow(10,c)).toFixed(6));return u>0?{address:i,name:n,symbol:s,decimals:c,balance:f,balanceFormatted:u,balanceUsd:0,logoURI:void 0,isNative:!1,chainId:o}:null}catch(i){return i?.message?.includes("checksum")||i?.message?.includes("Address")||i?.message?.includes("invalid")||console.error(`Error fetching ERC20 balance for ${r} on chain ${o}:`,i),null}},pt=async(t,o)=>{try{const r=St[o];if(!r.moralisName){const i=[],d=await as(t,o);d.balanceFormatted>0&&i.push(d);const g=fe(o);if(g?.supportedTokens&&g.supportedTokens.length>0){const f=g.supportedTokens.map(u=>is(t,o,u.address,u.name,u.symbol,u.decimals));(await Promise.allSettled(f)).forEach(u=>{u.status==="fulfilled"&&u.value&&i.push(u.value)})}return{tokens:i,chainId:o}}const n=await(await import("axios")).default.get(`${so}/wallets/${t}/tokens`,{params:{chain:r.moralisName},headers:{"X-API-Key":to}}),s=[],c=n.data?.result||[];console.log("allTokens",c);for(const i of c){const d=parseFloat(i.balance_formatted||"0");if(d>0){const g={address:i.token_address,name:i.name||"Unknown",symbol:i.symbol||"UNKNOWN",decimals:parseInt(i.decimals)||18,balance:BigInt(i.balance||"0"),balanceFormatted:d,balanceUsd:parseFloat(i.usd_value||"0"),logoURI:i.logo,isNative:i.native_token||!1,chainId:o};s.push(g)}}return{tokens:s,chainId:o}}catch(r){if(console.error(`Error fetching tokens for ${o}:`,r),!St[o].moralisName)try{const n=[],s=await as(t,o);s.balanceFormatted>0&&n.push(s);const c=fe(o);if(c?.supportedTokens&&c.supportedTokens.length>0){const i=c.supportedTokens.map(d=>is(t,o,d.address,d.name,d.symbol,d.decimals));(await Promise.allSettled(i)).forEach(d=>{d.status==="fulfilled"&&d.value&&n.push(d.value)})}return{tokens:n,chainId:o}}catch(n){console.error(`Fallback balance fetch failed for ${o}:`,n)}return{tokens:[],chainId:o}}},zt=async t=>{if(!t)throw new Error("Wallet address is required");console.log("Fetching multi-chain balances for:",t);const[o,r,n,s,c,i]=await Promise.allSettled([pt(t,11155111),pt(t,5115),pt(t,123420001114),pt(t,84532),pt(t,688689),pt(t,421614)]),d={};return o.status==="fulfilled"&&(d[11155111]=o.value),r.status==="fulfilled"&&(d[5115]=r.value),n.status==="fulfilled"&&(d[123420001114]=n.value),s.status==="fulfilled"&&(d[84532]=s.value),c.status==="fulfilled"&&(d[688689]=c.value),i.status==="fulfilled"&&(d[421614]=i.value),console.log("Balances:",d),d},Vt=({address:t,supportedChains:o,fetchBalances:r,refreshInterval:n=8e3})=>{const[s,c]=a.useState([]),[i,d]=a.useState(!1),[g,f]=a.useState(null),u=a.useRef(!0),l=a.useRef(t),C=a.useRef(o),A=a.useRef(r);a.useEffect(()=>{l.current=t,C.current=o,A.current=r},[t,o,r]);const w=a.useCallback(async()=>{const b=l.current,m=C.current,j=A.current;if(!b){c([]);return}u.current&&d(!0),f(null);try{const y=await j(b),h=Object.values(y).flatMap(x=>x.tokens.map(S=>({...S,chainId:x.chainId}))).filter(x=>m.includes(x.chainId));c(h)}catch(y){const h=y instanceof Error?y.message:"Failed to fetch assets";f(h),console.error("Error fetching assets:",y)}finally{u.current&&(d(!1),u.current=!1)}},[]),k=a.useCallback(b=>s.filter(m=>m.chainId===b),[s]),p=a.useCallback(()=>s.filter(b=>b.isNative),[s]);return a.useEffect(()=>{t&&(u.current=!0,w())},[t,w]),a.useEffect(()=>{if(!t||!n)return;const b=setInterval(()=>{w()},n);return()=>clearInterval(b)},[t,n]),{assets:s,loading:i,error:g,refreshAssets:w,getAssetsByChain:k,getNativeAssets:p}},kt=({checkStepStatus:t,pollingInterval:o=4e3})=>{const[r,n]=a.useState(null),[s,c]=a.useState(null),i=a.useRef(!1),d=a.useCallback(()=>{s&&(clearInterval(s),c(null))},[s]),g=a.useCallback(()=>{n(null),d()},[d]),f=a.useCallback((u,l)=>{d(),i.current=!1;const C={intentId:u,steps:l.map(k=>({...k,status:"pending"})),overallStatus:"processing"};n(C);const A=async()=>{i.current||n(k=>k?((async()=>{const p=[...k.steps];let b=!0,m=!1;for(let y=0;y<p.length;y++){const h=p[y];if(h.status!=="success"){if((h.stepId===0||y>0&&p[y-1].status==="success")&&(h.status==="pending"||h.status==="processing"))try{const x=await t(u,h.stepId);x.data.status==="success"?(p[y]={...h,status:"success",transactionHash:x.data.transactionHash},y+1<p.length&&p[y+1].status==="pending"&&(p[y+1]={...p[y+1],status:"processing"})):x.data.status==="executing"||x.data.status==="created"?p[y]={...h,status:"processing"}:x.data.status==="reverted"&&(p[y]={...h,status:"failed",transactionHash:x.data.transactionHash},m=!0)}catch(x){console.error(`Error checking step ${h.stepId}:`,x)}p[y].status!=="success"&&(b=!1)}}const j=m?"failed":b?"success":"processing";n(y=>y?{...y,steps:p,overallStatus:j}:null),(b||m)&&(i.current=!0,d())})().catch(()=>{}),k):null)};A();const w=setInterval(A,o);c(w)},[t,o,d]);return a.useEffect(()=>()=>{d()},[d]),{intentStatus:r,startStatusPolling:f,stopStatusPolling:d,clearStatus:g}},It=(t,o=4)=>t===0?"0":t<1e-4?"< 0.0001":t.toFixed(o),oo=(t,o=6,r=4)=>t.length<=o+r?t:`${t.slice(0,o)}...${t.slice(-r)}`,no=t=>oo(t,8,8),ls=t=>{const o=t.replace(/[^0-9.]/g,""),r=o.split(".");return r.length>2?r[0]+"."+r.slice(1).join(""):o},ro=async t=>{try{return await navigator.clipboard.writeText(t),!0}catch(o){return console.error("Failed to copy to clipboard:",o),!1}};var ut="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAAAS1BMVEVMaXEndskmdcondcondcsndssmdMkldMondswndsz///8pd8wcbsj9/v8pe9U1fs7z+P2Ot+Sqyetypd1cl9dJi9PC2PHV5PXm7/keiWBQAAAACnRSTlMAE3H/m1gy/sjjtLtfHAAAAAlwSFlzAAALEwAACxMBAJqcGAAACTtJREFUeNrNW9eWqzoMnYQQJ8gUm/r/X3plmptkSDl3hodTVgBt1Jt/ft64Lvf8ers9nk+R4SWez8ftds3vl5//47rnSDmDCi8AMADwr/l/GeLI7/+U+AWJi5lWJkQ2f/5yCfP/GZVAEJd/Rv1paAvhUPYv8xOieP4LDPeNenZwbRi+K4v8ARUcE7cg8PZH/kXyVZWdpr5pRVV9CYIh/yL1lQ1fgXA35N+hv0H4TBcuN3ib/AoBbh9YRP58WfaELjzztz8fNT/7+EKLeI8J9+dH3Pfk8HxDE65QfYX8DKGC66v0v8N+Vwyvif9RfZH8woTH5SXj5+kvMfjl38QLLsGoH0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s13SR/8veYR2wirD0EItwjEdNw4oT8os39v6dU58L9y+kg8wF+s0HmdS5oSlZacrWtzIECpm/7+nk2FCeZ3vp4IaZMgScVL7uzVIILQKmP9xqzhRWM/SMhj4RZn8/NeSnNTMa2P5Zpf9MWGKHEUaDLx3ny2nIr4n6sHStOiHmbC0G9yQ1wvuJxjDwQDz68oFGoCEsNa9CODWZpJvAjJcGRurd+O2aLhrY/mcNwvunT55B++Gk+1ePdLIzu1G03cISMBPHQLqD/EY6Zjm6fzpzGN7PJ5+uEtqwBY0bjnRWiJgfUtacmOYRwMY3t1b7+Xk+f35mK7XQ/BXsQDceauWP9WaKja8fMkd4SxfL/Xy5OluqJovWfgL0a3mw+JH7FGy93mae42f+Y9ur9dJxWh+tfvA+RRRYK2FXwQ83Ebkq88Dh8gchwBYn2bUhEq5T2K3BdB4yHLQ+3v8gBMAAKrdE6J+US63ueXz3ggPzGOZC9M+WFxx+5IoH77mtr3j8/iWXP3DNB4jw+rsXndhVLwP93lWvP3DZ7fev+/2BC4+/f+XzD1x6/QPXfv/AxeccQ+8Xr37/hcvvhSUU1/8fqex/ififZbqhk/AAAAAASUVORK5CYII=";const io={USDC:ut,WBTC:ao},ot=({symbol:t,logoURI:o,size:r=20,theme:n})=>{const s=n||de.createTheme("dark"),c={width:`${r}px`,height:`${r}px`,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${r*.4}px`,fontWeight:s.typography.fontWeight.bold,flexShrink:0,overflow:"hidden",backgroundColor:"#ffffff"},i=t.toUpperCase(),d=o||io[i];if(d)return e.jsx("img",{src:d,alt:t,style:{...c,objectFit:"cover"},onError:f=>{const u=f.target;u.style.display="none";const l=u.parentElement;l&&(l.innerHTML=Nt(t).icon,Object.assign(l.style,Nt(t).style))}});const g=Nt(t);return e.jsx("div",{style:{...c,...g.style},children:g.icon})},Nt=t=>{const o=t.toUpperCase(),r={ETH:{bg:"#627EEA",text:"#FFFFFF",icon:"\u039E"},BTC:{bg:"#F7931A",text:"#FFFFFF",icon:"\u20BF"},USDC:{bg:"#2775CA",text:"#FFFFFF"},USDT:{bg:"#26A17B",text:"#FFFFFF"},DAI:{bg:"#F5AC37",text:"#FFFFFF"},WETH:{bg:"#627EEA",text:"#FFFFFF",icon:"\u039E"},WBTC:{bg:"#F09242",text:"#FFFFFF",icon:"\u20BF"},CBTC:{bg:"#F7931A",text:"#FFFFFF",icon:"\u20BF"},USD:{bg:"#26A17B",text:"#FFFFFF",icon:"$"},MATIC:{bg:"#8247E5",text:"#FFFFFF"},AVAX:{bg:"#E84142",text:"#FFFFFF"},SOL:{bg:"#9945FF",text:"#FFFFFF"},DOT:{bg:"#E6007A",text:"#FFFFFF"},ADA:{bg:"#0033AD",text:"#FFFFFF"},LINK:{bg:"#375BD2",text:"#FFFFFF"},UNI:{bg:"#FF007A",text:"#FFFFFF"},AAVE:{bg:"#B6509E",text:"#FFFFFF"},CRV:{bg:"#40E0D0",text:"#000000"}}[o];if(r)return{style:{backgroundColor:r.bg,color:r.text},icon:r.icon||o.charAt(0)};const n=o.split("").reduce((d,g)=>g.charCodeAt(0)+((d<<5)-d),0),s=Math.abs(n)%360,c=`hsl(${s}, 60%, 50%)`,i=s>180?"#FFFFFF":"#000000";return{style:{backgroundColor:c,color:i},icon:o.charAt(0)}},Ft=({chainId:t,name:o,size:r=16,theme:n})=>{const s=n||de.createTheme("dark"),c={width:`${r}px`,height:`${r}px`,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${r*.5}px`,fontWeight:s.typography.fontWeight.bold,flexShrink:0},i=lo(t,o);return e.jsx("div",{style:{...c,backgroundColor:"style"in i?i.style?.backgroundColor:i.bg,color:"style"in i?i.style?.color:i.text},children:i.icon})},lo=(t,o)=>{if(t)return Ks(t);const r=o||"Unknown Chain",n=r.split("").reduce((d,g)=>g.charCodeAt(0)+((d<<5)-d),0),s=Math.abs(n)%360,c=`hsl(${s}, 60%, 50%)`,i=s>180?"#FFFFFF":"#000000";return{style:{backgroundColor:c,color:i},icon:r.charAt(0).toUpperCase()}},ds=t=>{switch(t){case 11155111:return"Sepolia";case 421614:return"Arbitrum Sepolia";case 5115:return"Citrea Testnet";case 123420001114:return"Basecamp Testnet";case 84532:return"Base Sepolia";case 688689:return"Pharos Atlantic";default:return`Chain ${t}`}},cs=({selectedAsset:t,assets:o,onAssetSelect:r,showDropdown:n,onToggleDropdown:s,disabled:c=!1,theme:i})=>{const d=i||de.createTheme("dark"),g=a.useRef(null),f=a.useRef(null),u=a.useRef(null),[l,C]=a.useState(null);a.useEffect(()=>{if(n&&f.current){const I=()=>{if(f.current){const G=f.current.getBoundingClientRect();C({top:G.bottom+6,right:window.innerWidth-G.right})}};return I(),window.addEventListener("scroll",I,!0),window.addEventListener("resize",I),()=>{window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I)}}else C(null)},[n]),a.useEffect(()=>{const I=G=>{g.current&&!g.current.contains(G.target)&&u.current&&!u.current.contains(G.target)&&n&&s()};return n&&document.addEventListener("mousedown",I),()=>{document.removeEventListener("mousedown",I)}},[n,s]);const[A,w]=a.useState(!1),[k,p]=a.useState(!1),b={backgroundColor:"transparent",border:A?"1px solid #F4A5A5":"1px solid #CDCFD1",borderRadius:"6px",color:"#3c3e42",cursor:c?"not-allowed":"pointer",padding:"8px 12px 8px 8px",width:"100%",display:"flex",flexDirection:"column",gap:"4px",opacity:c?.6:1,transition:"all 0.15s ease",transform:k?"scale(0.98)":"scale(1)"},m={display:"flex",justifyContent:"space-between",alignItems:"center"},j={display:"flex",alignItems:"center",gap:"4px",paddingTop:"4px",borderTop:"1px solid #e5e7eb"},y=()=>l?{position:"fixed",top:`${l.top}px`,right:`${l.right}px`,backgroundColor:d.colors.secondary,border:`1px solid ${d.colors.border}`,borderRadius:d.borderRadius.md,boxShadow:d.shadows.lg,zIndex:100,width:"200px",maxHeight:"300px",overflow:"auto"}:{},h={backgroundColor:"transparent",border:"none",color:d.colors.text,cursor:"pointer",padding:d.spacing.sm,width:"100%",display:"flex",alignItems:"center",gap:d.spacing.sm,transition:`background-color ${d.animation.normal}`,":hover":{backgroundColor:d.colors.surfaceHover}},x={display:"flex",flexDirection:"column",alignItems:"flex-start",flex:1},S={fontSize:d.typography.fontSize.sm,fontWeight:d.typography.fontWeight.medium},F={fontSize:d.typography.fontSize.xs,color:d.colors.textMuted},B={transition:`transform ${d.animation.normal}`,transform:n?"rotate(180deg)":"rotate(0deg)"};return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{position:"relative"},ref:g,children:e.jsxs("div",{ref:f,style:b,onClick:c?void 0:s,onMouseEnter:()=>w(!0),onMouseLeave:()=>{w(!1),p(!1)},onMouseDown:()=>p(!0),onMouseUp:()=>p(!1),children:[e.jsxs("div",{style:m,children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:t?.asset?e.jsxs(e.Fragment,{children:[e.jsx(ot,{symbol:t.asset.symbol,logoURI:t.asset.logoURI,theme:d,size:30}),e.jsx("span",{style:{fontSize:"16px",fontWeight:500,color:"#3c3e42",lineHeight:"1.5"},children:t.asset.symbol})]}):e.jsx("span",{style:{fontSize:"14px",color:"#71757a"},children:"Select"})}),e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#71757a",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:B,children:e.jsx("path",{d:"M6 9l6 6 6-6"})})]}),t?.asset&&e.jsxs("div",{style:j,children:[e.jsx(Ft,{chainId:t.asset.chainId,theme:d}),e.jsx("span",{style:{fontSize:"11px",color:"#71757a"},children:ds(t.asset.chainId)})]})]})}),n&&l&&Js.createPortal(e.jsx("div",{ref:u,style:y(),children:o.map(I=>e.jsxs("button",{style:h,onClick:()=>{r(I),s()},children:[e.jsx(ot,{symbol:I.symbol,logoURI:I.logoURI,theme:d},`${I.address}-${I.chainId}`),e.jsxs("div",{style:x,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:d.spacing.xs},children:[e.jsx("span",{style:S,children:I.symbol}),e.jsx(Ft,{chainId:I.chainId,theme:d})]}),e.jsxs("span",{style:F,children:[It(I.balanceFormatted)," \u2022"," ",ds(I.chainId)]})]})]},`${I.address}-${I.chainId}`))}),document.body)]})},co=({assets:t,selectedAsset:o,onAssetSelect:r,onAmountChange:n,disabled:s=!1,loading:c=!1,label:i="Select Asset",showBalance:d=!0,showMaxButton:g=!0,placeholder:f="0.0",theme:u,styles:l,allowSecondAsset:C=!1,onAddAsset:A,canAddAsset:w=!1})=>{const k=u||de.createTheme("dark"),[p,b]=a.useState(!1),[m,j]=a.useState(null),[y,h]=a.useState(null),[x,S]=a.useState(o?.amount||""),F=a.useRef(null),B=a.useRef("");a.useEffect(()=>{const M=o?.asset?`${o.asset.chainId}-${o.asset.address}`:"";M!==B.current&&(S(o?.amount||""),B.current=M)},[o?.asset?.chainId,o?.asset?.address,o?.amount]);const I=M=>{const z=ls(M);if(!z){S(z),F.current&&clearTimeout(F.current),F.current=setTimeout(()=>{n(z)},300);return}if(o?.asset){const E=parseFloat(z),U=o.asset.balanceFormatted;if(!isNaN(E)&&E>U){const X=U.toString();S(X),F.current&&clearTimeout(F.current),F.current=setTimeout(()=>{n(X)},300);return}}S(z),F.current&&clearTimeout(F.current),F.current=setTimeout(()=>{n(z)},300)},G=M=>{if(o?.asset){const z=(o.asset.balanceFormatted*M/100).toString();S(z),F.current&&clearTimeout(F.current),n(z)}},P=o?.asset?.balanceFormatted??0,_=parseFloat(x)||0,$=P>0?_/P*100:0;a.useEffect(()=>()=>{F.current&&clearTimeout(F.current)},[]);const J={backgroundColor:l?.assetSelector?.backgroundColor||l?.secondaryBackground||"#e9e9e9",border:"0.5px solid #A8A8A7",borderRadius:l?.assetSelector?.borderRadius||"6px",padding:l?.assetSelector?.padding||"16px",height:"auto",minHeight:"144px",display:"flex",flexDirection:"column",gap:"8px",position:"relative",opacity:s?.6:1};return c?e.jsx("div",{style:J,children:e.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx("div",{style:{backgroundColor:"#d1d5db",borderRadius:"4px",height:"16px",width:"60px"}}),e.jsx("div",{style:{backgroundColor:"#d1d5db",borderRadius:"4px",height:"40px",width:"150px"}})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:"8px"},children:[e.jsx("div",{style:{backgroundColor:"#d1d5db",borderRadius:"4px",height:"12px",width:"80px"}}),e.jsx("div",{style:{backgroundColor:"#d1d5db",borderRadius:"6px",height:"46px",width:"128px"}})]})]})}):e.jsxs("div",{style:J,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("span",{style:{fontFamily:l?.fontFamily||k.typography.fontFamily,fontSize:"16px",fontWeight:500,color:"#7d7c7b",lineHeight:"24px"},children:i}),d&&o?.asset&&e.jsxs("span",{style:{fontFamily:l?.fontFamily||k.typography.fontFamily,fontSize:"12px",fontWeight:500,color:"#71757a",lineHeight:"16px"},children:["Balance: ",It(o.asset.balanceFormatted)]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",flex:1},children:[e.jsx("input",{type:"text",value:x,onChange:M=>I(M.target.value),placeholder:f,disabled:s||!o?.asset,style:{fontFamily:l?.fontFamily||k.typography.fontFamily,fontSize:"40px",fontWeight:700,color:s?"rgba(14, 13, 11, 0.16)":x?"#0e0d0b":"#d1d5db",lineHeight:"1.08",letterSpacing:"-1.2px",backgroundColor:"transparent",border:"none",outline:"none",padding:0,width:"100%",maxWidth:"200px"}}),e.jsx("div",{style:{width:"128px",position:"relative",flexShrink:0},children:e.jsx(cs,{selectedAsset:o,assets:t,onAssetSelect:r,showDropdown:p,onToggleDropdown:()=>b(!p),disabled:s,theme:k})})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:"10px",height:"14px"},children:[0,25,50,75,100].map((M,z)=>{const E=Math.abs($-M)<1,U=z===4,X=M/100,ee=m===M,H=y===M;return e.jsx("button",{onClick:()=>G(M),onMouseEnter:()=>j(M),onMouseLeave:()=>{j(null),h(null)},onMouseDown:()=>h(M),onMouseUp:()=>h(null),disabled:s||!o?.asset,title:`${M}%`,style:{width:"14px",height:"14px",padding:0,border:"none",backgroundColor:"transparent",cursor:s||!o?.asset?"not-allowed":"pointer",opacity:E?1:ee?.8:.5,transform:H?"scale(0.85)":ee?"scale(1.15)":"scale(1)",transition:"all 0.15s ease"},children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",children:[e.jsx("circle",{cx:"7",cy:"7",r:"6.84375",fill:U?"#ea4b4b":"none",stroke:U?"#ea4b4b":"#3C3E42",strokeWidth:"0.3125"}),!U&&X>0&&e.jsx("path",{d:`M 7 7 L 7 0.15625 A 6.84375 6.84375 0 ${X>.5?1:0} 1 ${7+6.84375*Math.sin(X*2*Math.PI)} ${7-6.84375*Math.cos(X*2*Math.PI)} Z`,fill:"#3C3E42"})]})},M)})})]})},ht=co,ps=({status:t,size:o=20,theme:r})=>{const n=r||de.createTheme("dark"),s={width:`${o}px`,height:`${o}px`,display:"flex",alignItems:"center",justifyContent:"center"};return(()=>{switch(t){case"success":return e.jsx("svg",{style:{...s,color:n.colors.success},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})});case"failed":return e.jsx("svg",{style:{...s,color:n.colors.error},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})});case"processing":return e.jsx("div",{style:{...s,border:`2px solid ${n.colors.primary}`,borderTop:"2px solid transparent",borderRadius:"50%",animation:"spin 1s linear infinite"}});case"pending":default:return e.jsx("div",{style:{...s,border:`2px solid ${n.colors.textMuted}`,borderRadius:"50%",backgroundColor:n.colors.surface}})}})()},po=({step:t,explorerUrlBuilder:o,animationDelay:r=0,theme:n})=>{const s=n||de.createTheme("dark"),c=(()=>{switch(t.status){case"success":return{bg:`${s.colors.success}20`,border:s.colors.success};case"failed":return{bg:`${s.colors.error}20`,border:s.colors.error};case"processing":return{bg:`${s.colors.info}20`,border:s.colors.info};default:return{bg:s.colors.surface,border:s.colors.border}}})(),i=t.transactionHash&&o?o(t.chainId,t.transactionHash):null,d={display:"flex",alignItems:"center",gap:s.spacing.md,padding:s.spacing.md,borderRadius:s.borderRadius.lg,border:`1px solid ${c.border}`,backgroundColor:c.bg,transition:`all ${s.animation.normal}`,animation:t.status==="processing"?"pulse 2s infinite":void 0,animationDelay:`${r}ms`},g={flex:1,minWidth:0},f={display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:s.spacing.xs},u={fontSize:s.typography.fontSize.sm,fontWeight:s.typography.fontWeight.medium,color:s.colors.text},l={fontSize:s.typography.fontSize.xs,fontWeight:s.typography.fontWeight.medium,padding:`${s.spacing.xs} ${s.spacing.sm}`,borderRadius:s.borderRadius.full,backgroundColor:`${c.border}20`,color:c.border},C={fontSize:s.typography.fontSize.xs,color:s.colors.textMuted,marginBottom:s.spacing.xs},A={fontSize:s.typography.fontSize.xs,color:s.colors.textMuted,fontFamily:"IBM Plex Mono",marginTop:s.spacing.xs},w={fontSize:s.typography.fontSize.xs,backgroundColor:`${s.colors.info}20`,color:s.colors.info,border:"none",borderRadius:s.borderRadius.full,padding:`${s.spacing.xs} ${s.spacing.sm}`,cursor:"pointer",textDecoration:"none",display:"inline-flex",alignItems:"center",gap:s.spacing.xs,transition:`all ${s.animation.normal}`,":hover":{backgroundColor:`${s.colors.info}30`,color:s.colors.info}};return e.jsxs("div",{style:d,children:[e.jsx("div",{style:{flexShrink:0},children:e.jsx(ps,{status:t.status,theme:s})}),e.jsxs("div",{style:g,children:[e.jsxs("div",{style:f,children:[e.jsx("span",{style:u,children:t.chainName}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:s.spacing.sm},children:[e.jsx("span",{style:l,children:t.status.charAt(0).toUpperCase()+t.status.slice(1)}),t.status==="success"&&i&&e.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer",style:w,title:"View on explorer",children:[e.jsx("svg",{width:"12",height:"12",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})}),"Explorer"]})]})]}),e.jsx("p",{style:C,children:t.description}),t.transactionHash&&e.jsx("p",{className:"ibm-plex-mono",style:A,children:no(t.transactionHash)})]})]})},uo=({intentStatus:t,onClose:o,onRetry:r,txType:n,onNewTx:s,explorerUrlBuilder:c,theme:i})=>{const d=i||de.createTheme("dark"),g={width:"100%",maxWidth:"28rem",margin:"0 auto",backgroundColor:d.colors.background,border:`1px solid ${d.colors.border}`,borderRadius:d.borderRadius.lg,padding:d.spacing.lg,color:d.colors.text},f={textAlign:"center",marginBottom:d.spacing.lg},u={width:"4rem",height:"4rem",margin:"0 auto",backgroundColor:d.colors.surface,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",border:`2px solid ${d.colors.border}`,marginBottom:d.spacing.md},l={fontSize:d.typography.fontSize.lg,fontWeight:d.typography.fontWeight.semibold,color:d.colors.text,marginBottom:d.spacing.sm},C={fontSize:d.typography.fontSize.sm,color:d.colors.textMuted},A={display:"flex",flexDirection:"column",gap:d.spacing.md,marginBottom:d.spacing.lg},w={padding:d.spacing.md,borderRadius:d.borderRadius.lg,marginBottom:d.spacing.lg},k={display:"flex",flexDirection:"column",gap:d.spacing.sm},p=(()=>{switch(t.overallStatus){case"success":return{title:`${n.charAt(0).toUpperCase()+n.slice(1)} completed successfully!`,description:"Your tokens are now available in your wallet",style:{...w,background:`linear-gradient(to right, ${d.colors.success}20, ${d.colors.success}10)`,border:`1px solid ${d.colors.success}`},icon:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),iconColor:d.colors.success};case"failed":return{title:"Transaction failed",description:"Please try again or contact support if the issue persists",style:{...w,background:`linear-gradient(to right, ${d.colors.error}20, ${d.colors.error}10)`,border:`1px solid ${d.colors.error}`},icon:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"})}),iconColor:d.colors.error};default:return{title:`Processing your ${n}...`,description:"This may take a few seconds to complete",style:{...w,background:`linear-gradient(to right, ${d.colors.primary}20, ${d.colors.primary}10)`,border:`1px solid ${d.colors.primary}`},icon:e.jsx("div",{style:{width:"1rem",height:"1rem",border:`2px solid ${d.colors.primary}`,borderTop:"2px solid transparent",borderRadius:"50%",animation:"spin 1s linear infinite"}}),iconColor:d.colors.primary}}})();return e.jsxs("div",{style:g,children:[e.jsxs("div",{style:f,children:[e.jsx("div",{style:u,children:e.jsx(ps,{status:t.overallStatus,size:32,theme:d})}),e.jsx("h3",{style:l,children:t.overallStatus==="success"?`${n.charAt(0).toUpperCase()+n.slice(1)} Completed!`:t.overallStatus==="failed"?"Transaction Failed":`Processing ${n}`}),e.jsx("p",{style:C,children:t.overallStatus==="success"?`Your tokens have been successfully ${n}`:t.overallStatus==="failed"?"Something went wrong with your transaction":`Please wait while we process your ${n} across chains`})]}),e.jsx("div",{style:A,children:t.steps.map((b,m)=>e.jsx(po,{step:b,explorerUrlBuilder:c,animationDelay:m*100,theme:d},b.stepId))}),e.jsx("div",{style:p.style,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:d.spacing.md},children:[e.jsx("div",{style:{width:"2rem",height:"2rem",backgroundColor:`${p.iconColor}20`,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",color:p.iconColor},children:p.icon}),e.jsxs("div",{children:[e.jsx("p",{style:{color:p.iconColor,fontWeight:d.typography.fontWeight.medium,fontSize:d.typography.fontSize.sm,margin:0},children:p.title}),e.jsx("p",{style:{color:`${p.iconColor}CC`,fontSize:d.typography.fontSize.xs,margin:`${d.spacing.xs} 0 0 0`},children:p.description})]})]})}),e.jsxs("div",{style:k,children:[t.overallStatus==="success"&&s&&e.jsxs(de.Button,{variant:"success",fullWidth:!0,onClick:s,theme:d,children:["Start New ",n]}),t.overallStatus==="failed"&&r&&e.jsx(de.Button,{variant:"error",fullWidth:!0,onClick:r,theme:d,children:"Try Again"}),t.overallStatus==="processing"&&e.jsx(de.Button,{variant:"ghost",fullWidth:!0,onClick:o,theme:d,children:"Cancel & Close"})]})]})},ho=({config:t,onChange:o,theme:r,styles:n})=>{const s=r||de.createTheme("dark"),c=["0%","0.1%","0.5%","1%"],i=p=>{o({...t,slippage:p,customSlippage:p==="custom"?t.customSlippage:void 0})},d=p=>{o({...t,slippage:"custom",customSlippage:p})},g={backgroundColor:n?.slippageSettings?.backgroundColor,border:n?.slippageSettings?.borderColor?`1px solid ${n.slippageSettings.borderColor}`:void 0,borderRadius:n?.slippageSettings?.borderRadius,padding:n?.slippageSettings?.padding,marginBottom:s.spacing.sm},f={fontSize:n?.slippageSettings?.label?.fontSize||s.typography.fontSize.xs,color:n?.slippageSettings?.label?.color||s.colors.textMuted,fontWeight:n?.slippageSettings?.label?.fontWeight,fontFamily:n?.slippageSettings?.label?.fontFamily||n?.fontFamily||s.typography.fontFamily,marginBottom:"4px"},u={display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"6px",alignItems:"center"},l={backgroundColor:n?.slippageSettings?.presetButton?.backgroundColor||s.colors.secondary,border:`1px solid ${n?.slippageSettings?.presetButton?.borderColor||s.colors.border}`,borderRadius:n?.slippageSettings?.presetButton?.borderRadius||s.borderRadius.md,color:n?.slippageSettings?.presetButton?.color||s.colors.textSecondary,cursor:"pointer",fontSize:n?.slippageSettings?.presetButton?.fontSize||s.typography.fontSize.xs,fontWeight:n?.slippageSettings?.presetButton?.fontWeight,fontFamily:n?.slippageSettings?.presetButton?.fontFamily||n?.fontFamily||s.typography.fontFamily,padding:n?.slippageSettings?.presetButton?.padding||`${s.spacing.xs} 0`,textAlign:"center",transition:`all ${s.animation.normal}`,":hover":{backgroundColor:n?.slippageSettings?.presetButton?.hoverBackgroundColor||s.colors.surfaceHover,borderColor:s.colors.borderHover}},C={...l,backgroundColor:n?.slippageSettings?.presetButton?.activeBackgroundColor||n?.primaryColor||s.colors.primary,borderColor:n?.slippageSettings?.presetButton?.activeBorderColor||n?.primaryColor||s.colors.primary,color:n?.slippageSettings?.presetButton?.activeColor||s.colors.text},A={backgroundColor:n?.slippageSettings?.customInput?.backgroundColor||"transparent",border:`1px solid ${t.slippage==="custom"?n?.slippageSettings?.customInput?.focusBorderColor||n?.primaryColor||s.colors.primary:n?.slippageSettings?.customInput?.borderColor||s.colors.border}`,borderRadius:n?.slippageSettings?.customInput?.borderRadius||s.borderRadius.md,color:n?.slippageSettings?.customInput?.color||s.colors.text,fontSize:n?.slippageSettings?.customInput?.fontSize||s.typography.fontSize.xs,fontWeight:n?.slippageSettings?.customInput?.fontWeight,fontFamily:n?.slippageSettings?.customInput?.fontFamily||n?.fontFamily||s.typography.fontFamily,padding:n?.slippageSettings?.customInput?.padding||s.spacing.sm,textAlign:"center",paddingRight:"1.5rem",width:"100%",outline:"none","::placeholder":{color:s.colors.textMuted}},w={position:"relative",display:"flex",alignItems:"center"},k={position:"absolute",right:s.spacing.xs,fontSize:n?.slippageSettings?.customInput?.fontSize||s.typography.fontSize.xs,fontFamily:n?.slippageSettings?.customInput?.fontFamily||n?.fontFamily||s.typography.fontFamily,color:s.colors.textMuted,pointerEvents:"none"};return e.jsxs("div",{style:g,children:[e.jsx("div",{style:f,children:"Slippage Tolerance"}),e.jsxs("div",{style:u,children:[c.map(p=>e.jsx("button",{style:t.slippage===p?C:l,onClick:()=>i(p),children:p},p)),e.jsxs("div",{style:w,children:[e.jsx("input",{type:"text",style:A,placeholder:"Custom",value:t.customSlippage||"",onFocus:()=>i("custom"),onChange:p=>d(p.target.value)}),t.slippage==="custom"&&e.jsx("span",{style:k,children:"%"})]})]})]})},go=({assets:t,selectedAsset:o,onAssetSelect:r,onAmountChange:n,amount:s="",disabled:c=!1,loading:i=!1,label:d="Collateral",placeholder:g="0.0",theme:f,styles:u})=>{const l=f||de.createTheme("dark"),[C,A]=a.useState(!1),w=a.useCallback(()=>{A(B=>!B)},[]),k=a.useCallback(B=>{const I=ls(B);n?.(I)},[n]),p=a.useCallback(()=>{o&&n&&n(o.balanceFormatted.toString())},[o,n]),b={backgroundColor:u?.assetSelector?.backgroundColor||u?.secondaryBackground||l.colors.surface,border:`1px solid ${u?.assetSelector?.borderColor||l.colors.border}`,borderRadius:u?.assetSelector?.borderRadius||l.borderRadius.md,padding:u?.assetSelector?.padding||`${l.spacing.sm} ${l.spacing.md}`,transition:`border-color ${l.animation.normal}`,opacity:c?.6:1,color:l.colors.text},m={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"6px"},j={fontSize:u?.assetSelector?.label?.fontSize||l.typography.fontSize.xs,color:u?.assetSelector?.label?.color||l.colors.textMuted,fontWeight:u?.assetSelector?.label?.fontWeight,fontFamily:u?.assetSelector?.label?.fontFamily||u?.fontFamily||l.typography.fontFamily},y={fontSize:u?.assetSelector?.balance?.fontSize||l.typography.fontSize.xs,color:u?.assetSelector?.balance?.color||l.colors.textMuted,fontWeight:u?.assetSelector?.balance?.fontWeight,fontFamily:u?.assetSelector?.balance?.fontFamily||u?.fontFamily||l.typography.fontFamily},h={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"6px"},x={background:u?.assetSelector?.amountInput?.backgroundColor||"transparent",border:"none",outline:"none",fontSize:u?.assetSelector?.amountInput?.fontSize||l.typography.fontSize.xl,fontWeight:u?.assetSelector?.amountInput?.fontWeight||l.typography.fontWeight.medium,color:u?.assetSelector?.amountInput?.color||l.colors.text,fontFamily:u?.assetSelector?.amountInput?.fontFamily||u?.fontFamily||l.typography.fontFamily,width:"50%","::placeholder":{color:l.colors.textMuted}},S={display:"flex",justifyContent:"space-between",alignItems:"center"},F={background:u?.button?.backgroundColor||l.colors.secondary,border:"none",borderRadius:u?.button?.borderRadius||l.borderRadius.sm,color:u?.button?.color||l.colors.textMuted,cursor:"pointer",fontSize:u?.button?.fontSize||l.typography.fontSize.xs,fontWeight:u?.button?.fontWeight,fontFamily:u?.button?.fontFamily||u?.fontFamily||l.typography.fontFamily,padding:u?.button?.padding||`4px ${l.spacing.xs}`,transition:`color ${l.animation.normal}`,":hover":{color:l.colors.text}};return i?e.jsxs("div",{style:b,children:[e.jsxs("div",{style:m,children:[e.jsx("div",{style:{...j,backgroundColor:l.colors.border,borderRadius:l.borderRadius.sm,height:"12px",width:"60px"}}),e.jsx("div",{style:{...y,backgroundColor:l.colors.border,borderRadius:l.borderRadius.sm,height:"12px",width:"80px"}})]}),e.jsxs("div",{style:h,children:[e.jsx("div",{style:{backgroundColor:l.colors.border,borderRadius:l.borderRadius.sm,height:"32px",width:"100px"}}),e.jsx("div",{style:{backgroundColor:l.colors.border,borderRadius:l.borderRadius.sm,height:"40px",width:"120px"}})]}),e.jsx("div",{style:S,children:e.jsx("div",{style:{backgroundColor:l.colors.border,borderRadius:l.borderRadius.sm,height:"12px",width:"50px"}})})]}):e.jsxs("div",{style:b,children:[e.jsxs("div",{style:m,children:[e.jsx("span",{style:j,children:d}),o&&e.jsxs("span",{style:y,children:["Balance: ",It(o.balanceFormatted)," ",o.symbol]})]}),e.jsxs("div",{style:h,children:[e.jsx("input",{type:"text",style:x,value:s,onChange:B=>k(B.target.value),placeholder:g,disabled:c||!o}),e.jsx("div",{style:{position:"relative",width:"120px"},children:e.jsx(cs,{selectedAsset:o?{asset:o,amount:""}:void 0,assets:t,onAssetSelect:r,showDropdown:C,onToggleDropdown:w,disabled:c,theme:l})})]}),e.jsxs("div",{style:S,children:[e.jsx("span",{style:y,children:o?`${It(o.balanceFormatted)} ${o.symbol}`:""}),o&&!c&&n&&e.jsx("button",{style:F,onClick:p,title:`Max: ${It(o.balanceFormatted,6)} ${o.symbol}`,children:"MAX"})]})]})},Ue=a.createContext(null),xo=({children:t,appId:o,supportedViemChains:r})=>{const[n,s]=a.useState(null),[c,i]=a.useState(!1);return a.useEffect(()=>{i(!0),typeof window<"u"&&import("@privy-io/react-auth").then(d=>{s(()=>d.PrivyProvider)}).catch(d=>{console.error("Failed to load Privy SDK:",d)})},[]),!c||!n?e.jsx(e.Fragment,{children:t}):e.jsx(n,{appId:o,config:{supportedChains:r,appearance:{loginMessage:"Log in or create your Spicenet account",accentColor:"#ea4b4b",theme:"#fafafa",showWalletLoginFirst:!1,walletChainType:"ethereum-only",walletList:["detected_ethereum_wallets","metamask","coinbase_wallet","base_account","rainbow","wallet_connect"]},loginMethods:["google","email","passkey"],fundingMethodConfig:{moonpay:{useSandbox:!0}},embeddedWallets:{requireUserPasswordOnCreate:!1,showWalletUIs:!0,ethereum:{createOnLogin:"users-without-wallets"},solana:{createOnLogin:"off"}},mfa:{noPromptOnMfaRequired:!1},externalWallets:{}},children:t})},fo=({children:t,environmentId:o})=>{const[r,n]=a.useState(null),[s,c]=a.useState(!1);return a.useEffect(()=>{c(!0),typeof window<"u"&&Promise.all([import("@dynamic-labs/sdk-react-core"),import("@dynamic-labs/ethereum")]).then(([i,d])=>{n({DynamicContextProvider:i.DynamicContextProvider,EthereumWalletConnectors:d.EthereumWalletConnectors})}).catch(i=>{})},[]),!s||!r?e.jsx(e.Fragment,{children:t}):e.jsx(r.DynamicContextProvider,{settings:{environmentId:o,walletConnectors:[r.EthereumWalletConnectors]},children:t})},mo=({children:t,provider:o,privyAppId:r,dynamicEnvironmentId:n,supportedChainIds:s=[11155111,421614,5115,123420001114],mode:c="7702",nativeChainId:i,appName:d="Spicenet"})=>{const g=s.map(f=>fe(f)?.viemChain).filter(Boolean);return c!=="7702"?(console.log(`[SpiceFlow] Running in ${c} mode - skipping embedded wallet providers`),e.jsx(Ue.Provider,{value:{provider:o,supportedChainIds:s,mode:c,nativeChainId:i,appName:d},children:t})):o==="privy"?r?e.jsx(Ue.Provider,{value:{provider:"privy",supportedChainIds:s,mode:c,nativeChainId:i,appName:d},children:e.jsx(xo,{appId:r,supportedViemChains:g,children:t})}):(console.warn("[SpiceFlow] Privy provider selected but no appId provided"),e.jsx(e.Fragment,{children:t})):o==="dynamic"?n?e.jsx(Ue.Provider,{value:{provider:"dynamic",supportedChainIds:s,mode:c,nativeChainId:i,appName:d},children:e.jsx(fo,{environmentId:n,children:t})}):(console.warn("[SpiceFlow] Dynamic provider selected but no environmentId provided"),e.jsx(e.Fragment,{children:t})):(console.warn("[SpiceFlow] No valid provider configuration found"),e.jsx(e.Fragment,{children:t}))},yo=()=>{const[t,o]=a.useState(!1);let r=null,n=null;try{r=_t.useDynamicContext()}catch(g){n=g instanceof Error?g.message:String(g),console.log("Dynamic context error in useWallet:",n)}if(a.useEffect(()=>{o(!0)},[]),n)return{isReady:!1,isAuthenticated:!1,isConnected:!1,provider:"dynamic",actions:{signAuthorization:async()=>{throw new Error("Dynamic context not available")},signMessage:async()=>{throw new Error("Dynamic context not available")}}};const{user:s,primaryWallet:c}=r||{},i=!!s,d=c?.address;return{isReady:t&&!!r,isAuthenticated:i,isConnected:i&&!!d,address:d,provider:"dynamic",actions:{signAuthorization:async g=>{if(!c)throw new Error("Dynamic primary wallet not available");const{isEthereumWallet:f}=await import("@dynamic-labs/ethereum");throw f(c)?new Error("Dynamic EIP-7702 authorization not yet implemented - check Dynamic docs for your version"):new Error("Primary wallet is not an Ethereum wallet")},signMessage:async g=>{if(!c)throw new Error("Dynamic primary wallet not available");const{isEthereumWallet:f}=await import("@dynamic-labs/ethereum");if(!f(c))throw new Error("Primary wallet is not an Ethereum wallet");const u=typeof g=="object"&&"raw"in g?{raw:g.raw}:g;return{signature:await(await c.getWalletClient()).signMessage({message:u,account:c.address})}}}}},gt=()=>{const t=a.useContext(Ue),o=t?.mode||"7702";let r=null;try{r=Je.useWallets()}catch{r=null}const n=r?.wallets?.find(i=>i.connectorType==="embedded")?.address;let s=null;try{s=_t.useDynamicContext()}catch{s=null}const c=s?.primaryWallet?.address;if(!(!t||o!=="7702"))return t.provider==="privy"?n:t.provider==="dynamic"?c:n??c},bo=()=>{const[t,o]=a.useState(!1);let r=null,n=null,s=null,c=null;try{r=Je.usePrivy(),n=Je.useSign7702Authorization(),s=Je.useSignMessage(),c=Je.useWallets()}catch{return{isReady:!1,isAuthenticated:!1,isConnected:!1,provider:null,actions:{signAuthorization:async()=>{throw new Error("Privy not available")},signMessage:async()=>{throw new Error("Privy not available")}}}}a.useEffect(()=>{o(!0)},[]);const{ready:i=!1,authenticated:d=!1}=r||{},g=gt(),f=c?.wallets?.find(u=>u.connectorType==="embedded");return{isReady:i,isAuthenticated:d,isConnected:i&&d&&!!g,address:g,provider:"privy",actions:{signAuthorization:async u=>{if(!n)throw new Error("Privy sign authorization not available");try{const l=await n.signAuthorization({contractAddress:u.contractAddress,chainId:u.chainId,nonce:u.nonce},{address:g});return delete l.v,l}catch(l){const C=l?.message||String(l);throw C.includes("not configured")||C.includes("chain")?new Error(`Chain ${u.chainId} is not configured in PrivyProvider. Add this chain to your Privy dashboard or supportedChainIds.`):l}},signMessage:async u=>{if(typeof u=="object"&&"raw"in u){if(!f)throw new Error("Embedded wallet not available for raw signing");const l=await f.getEthereumProvider();return{signature:await ae.createWalletClient({account:f.address,transport:ae.custom(l)}).signMessage({account:f.address,message:{raw:u.raw}})}}if(!s)throw new Error("Privy sign message not available");return{signature:(await s.signMessage({message:u})).signature}}}}},Lt=()=>{const t=a.useContext(Ue)?.provider;return t==="privy"?bo():t==="dynamic"?yo():{isReady:!1,isAuthenticated:!1,isConnected:!1,provider:null,actions:{signAuthorization:async()=>{throw new Error("No wallet provider available")},signMessage:async()=>{throw new Error("No wallet provider available")}}}},Yt=process.env.NEXT_PUBLIC_RELAYER_API_URL||"https://tx-submission-api-dev.spicenet.io";class Co{constructor(){this.baseUrl=Yt}async createAction(o){const r=await fetch(`${this.baseUrl}/actions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o,(n,s)=>typeof s=="bigint"?s.toString():s)});if(!r.ok){const n=await r.text();throw new Error(`Relayer API error: ${r.status} - ${n}`)}return r.json()}async executeStep(o,r,n,s){const c=await fetch(`${this.baseUrl}/actions/${o}/intents/${r}/steps/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!c.ok){const i=await c.text();throw new Error(`Execute step error: ${c.status} - ${i}`)}return{success:!0}}async checkStepStatus(o,r){const n=o.split("/");let s="";if(n.length>=2){const d=n[0],g=n[1];s=`${this.baseUrl}/actions/${d}/intents/${g}/steps/${r}`}else s=`${this.baseUrl}/actions/${o}/intents/0/steps/${r}`;const c=await fetch(s);if(!c.ok)throw new Error(`Intent step status check failed: ${c.status}`);const i=await c.json();return{success:!0,data:{status:i.status==="error"?"reverted":i.status,transactionHash:i.txid}}}async submitSpiceDeposit(o){const r=o.isDeposit?"deposit":"withdrawal";try{const n=await fetch(`${this.baseUrl}/spicedeposit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}),s=await n.json();return!n.ok||!s.success?(console.error(`Failed to submit ${r} request to API:`,s.error?.message),{success:!1,error:s.error}):s}catch(n){return console.error(`Error submitting ${r} request to API:`,n),{success:!1,error:{message:n instanceof Error?n.message:"Unknown error"}}}}async requestSpiceUsdAirdrop(o){try{const r=await fetch(`${this.baseUrl}/airdrop/${o.chainId}/spiceUsd`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({wallet:o.address})}),n=await r.json().catch(()=>({}));if(!r.ok){const s=n&&(n.error||n.message)||"Failed to request airdrop";return{success:!1,errorMessage:String(s)}}return n&&typeof n.error=="string"?{success:!1,errorMessage:n.error}:n&&(n.txHash||n.amount)?{success:!0,txHash:n.txHash,amount:n.amount}:{success:!0}}catch(r){return{success:!1,errorMessage:r?.message&&typeof r.message=="string"?r.message:"Failed to request airdrop"}}}}const we=new Co,Et=(t,o)=>{const r=s=>o?o(s):st(s),n=[];return t.forEach((s,c)=>{if(s.calls&&s.calls.length>0){const i={stepId:c,status:c===0?"processing":"pending",chainId:s.chainId,chainName:r(s.chainId),description:"Processing transaction"};n.push(i)}}),n},Ao=({swapBatches:t,tokenAddress:o="0x0",supportedChains:r,theme:n="light",styles:s,className:c="",showSlippageSettings:i=!0,enableFlipSwap:d=!0,fromInputHook:g,toInputUpdateHook:f})=>{const u=de.createTheme(n),l={...u,typography:{...u.typography,fontFamily:s?.fontFamily||u.typography.fontFamily},colors:{...u.colors,primary:s?.primaryColor||u.colors.primary,primaryHover:s?.primaryColor?`${s.primaryColor}dd`:u.colors.primaryHover}},C=Lt(),{isReady:A,isAuthenticated:w,isConnected:k,address:p,provider:b,actions:m}=C,j=a.useContext(Ue),[y,h]=a.useState(null),[x,S]=a.useState(null),[F,B]=a.useState(null),[I,G]=a.useState(""),[P,_]=a.useState({slippage:"0.5%"}),[$,J]=a.useState(!1),[M,z]=a.useTransition(),{assets:E,loading:U,error:X,refreshAssets:ee}=Vt({address:p,supportedChains:r,fetchBalances:zt}),[H,ne]=a.useState(!1),[xe,ue]=a.useState(null),{intentStatus:Ee,startStatusPolling:R,clearStatus:q}=kt({checkStepStatus:(W,K)=>we.checkStepStatus(W,K)}),pe=a.useCallback(()=>{if(E.length===0||F)return;const W=E.filter(ie=>ie.isNative),K=W.length>0?W[0]:E[0];K&&B(K)},[E,F]);a.useEffect(()=>{pe()},[pe]),a.useEffect(()=>{f&&f.toAmount!==x?.amount&&x&&S({...x,amount:f.toAmount})},[f?.toAmount,x]);const v=a.useCallback(()=>{ue(null)},[]),N=(W,K)=>W.chainId===K.chainId&&W.address.toLowerCase()===K.address.toLowerCase(),O=(W,K)=>{if(K==="collateral"){const ie=E.filter(me=>!N(me,W));return ie.length>0?ie[0]:null}else{const ie=r.flatMap(me=>Rt(me,E)).filter(me=>!N(me,W));return ie.length>0?ie[0]:null}},se=W=>{if(x&&N(x.asset,W)){const K=O(W,"fromTo");S(K?{asset:K,amount:""}:null)}if(F&&N(F,W)){const K=O(W,"collateral");B(K)}h({asset:W,amount:y?.amount||""}),v()},re=W=>{if(y&&N(y.asset,W)){const K=O(W,"fromTo");h(K?{asset:K,amount:""}:null)}if(F&&N(F,W)){const K=O(W,"collateral");B(K)}S({asset:W,amount:x?.amount||""}),v()},Z=W=>{if(y&&N(y.asset,W)){const K=O(W,"fromTo");h(K?{asset:K,amount:""}:null)}if(x&&N(x.asset,W)){const K=O(W,"fromTo");S(K?{asset:K,amount:""}:null)}B(W),v()},he=a.useCallback(W=>{y&&(z(()=>{h({...y,amount:W}),x&&S({...x,amount:W}),G(W),v()}),g&&g.setFromAmount(W))},[y,x,g,v]),Ce=a.useCallback(W=>{x&&z(()=>{S({...x,amount:W}),y&&h({...y,amount:W}),G(W),v()})},[x,y,v]),T=a.useCallback(W=>{z(()=>{G(W),y&&h({...y,amount:W}),x&&S({...x,amount:W}),v()})},[y,x,v]),oe=a.useCallback(()=>{if(d&&y&&x){const W=y.amount;z(()=>{h({asset:x.asset,amount:W}),S({asset:y.asset,amount:W}),G(W),J(!$),v()})}},[d,y,x,$,v]),le=async()=>{if(!y||!x||!F||!p||t.length===0)return;const W=j?.mode||"7702";if(W==="7702"&&(!A||!w)){ue(`Please authenticate with ${b||"wallet provider"} to continue`);return}if(W!=="7702"){ue("Only EIP-7702 mode is currently supported for Swaps.");return}ne(!0),ue(null);try{const K=await Ve(F.chainId).getBlockNumber(),ie=[{chainId:F.chainId,recentBlock:K,calls:[{to:"0xeee2b52e7CFe6e2168341a34cEB783b68FEdf1A2",value:ae.parseEther(I),data:"0x"}]},...t],me=[...new Set(ie.map(be=>be.chainId))],$e=[];for(const be of me){const Re=Ve(be),ge=ct(be),nt=await Ye.getAccountNonce(p,Re),tt=await m.signAuthorization({contractAddress:ge,chainId:be,nonce:Number(nt)});$e.push(tt)}const Y=Ye.hashChainBatches(ie),te=Math.floor(Date.now()/1e3)+60*10,Fe=Ye.getIntentHash(BigInt(0),BigInt(te),Y),De=await m.signMessage({raw:Fe}),_e=typeof De=="string"?De:De.signature;if(!_e)throw new Error("Failed to sign intent authorization");const at={mode:"7702",signatureType:"ecdsa",signature:_e,nbf:0,exp:te,chainBatches:Y.map(be=>({hash:be.hash,chainId:Number(be.chainId),tokenTransfers:[],calls:be.calls}))},et={user:p,chainAuthorizations:$e.map(be=>({...be,r:be.r,s:be.s,nonce:Number(be.nonce),chainId:Number(be.chainId)})),intents:[at]},Ze=await we.createAction(et);if(Ze){const be=Et(ie,Re=>`Chain ${Re}`);R(Ze.intentIds[0],be);for(let Re=0;Re<ie.length;Re++)console.log(`[SwapWidget] Executing step ${Re}...`),await we.executeStep(Ze.actionId,0,Re,{action:"execute"}),console.log(`[SwapWidget] Step ${Re} completed`);console.log("[SwapWidget] All steps executed"),ee()}}catch(K){const ie=K instanceof Error?K.message:"Swap failed";ue(ie)}finally{ne(!1)}},Se=r.flatMap(W=>Rt(W,E)),ve=r.flatMap(W=>Rt(W,E)),ke=E.filter(W=>r.includes(W.chainId)),Ie=y&&x&&F&&y.amount&&parseFloat(y.amount)>0&&parseFloat(y.amount)<=y.asset.balanceFormatted&&I&&parseFloat(I)>0&&parseFloat(I)<=F.balanceFormatted&&k&&!H&&t.length>0,ce=X||xe,ze={backgroundColor:s?.container?.backgroundColor||s?.primaryBackground||l.colors.background,border:`1px solid ${s?.container?.borderColor||l.colors.border}`,borderRadius:s?.container?.borderRadius||l.borderRadius.lg,padding:s?.container?.padding||l.spacing.md,width:s?.container?.width||"100%",maxWidth:"28rem",margin:"0 auto",color:l.colors.text,fontFamily:l.typography.fontFamily,boxShadow:s?.container?.boxShadow||(l.mode==="light"?"0 4px 6px -1px rgb(0 0 0 / 0.1)":"0 4px 6px -1px rgb(0 0 0 / 0.3)")};return Ee?e.jsx("div",{className:c,children:e.jsx(uo,{intentStatus:Ee,onClose:q,onRetry:()=>{q(),le()},txType:"swap",onNewTx:()=>{q(),h(null),S(null),B(null),G(""),ee()},explorerUrlBuilder:(W,K)=>Wt(W,K),theme:l})}):e.jsxs("div",{style:ze,className:c,children:[e.jsxs("div",{style:{marginBottom:l.spacing.sm},children:[" ",e.jsxs("div",{style:{padding:s?.statusDisplay?.padding||"8px",backgroundColor:s?.statusDisplay?.backgroundColor||s?.tertiaryBackground||(l.mode==="light"?"#f9fafb":l.colors.surface),border:`1px solid ${s?.statusDisplay?.borderColor||(l.mode==="light"?"#e5e7eb":l.colors.border)}`,borderRadius:s?.statusDisplay?.borderRadius||l.borderRadius.md},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("span",{style:{fontSize:s?.statusDisplay?.text?.fontSize||l.typography.fontSize.xs,fontWeight:s?.statusDisplay?.text?.fontWeight||l.typography.fontWeight.medium,color:s?.statusDisplay?.text?.color||l.colors.text,fontFamily:s?.statusDisplay?.text?.fontFamily||l.typography.fontFamily},children:[j?.provider==="privy"?"Privy":j?.provider==="dynamic"?"Dynamic":"Wallet"," ","Status"]}),e.jsx("span",{style:{fontSize:s?.statusDisplay?.text?.fontSize||l.typography.fontSize.xs,padding:`2px ${l.spacing.xs}`,borderRadius:l.borderRadius.sm,border:`1px solid ${k?s?.statusDisplay?.successColor||l.colors.success:s?.statusDisplay?.warningColor||l.colors.warning}`,backgroundColor:k?l.mode==="light"?"#dcfce7":`${s?.statusDisplay?.successColor||l.colors.success}20`:l.mode==="light"?"#fef3c7":`${s?.statusDisplay?.warningColor||l.colors.warning}20`,color:k?s?.statusDisplay?.successColor||l.colors.success:s?.statusDisplay?.warningColor||l.colors.warning,fontFamily:s?.statusDisplay?.text?.fontFamily||l.typography.fontFamily},children:k?"Connected":"Disconnected"})]}),k&&p&&e.jsxs("div",{className:"ibm-plex-mono",style:{marginTop:"6px",backgroundColor:s?.addressDisplay?.backgroundColor||(l.mode==="light"?"#f3f4f6":l.colors.secondary),border:`1px solid ${s?.addressDisplay?.borderColor||(l.mode==="light"?"#d1d5db":l.colors.borderHover)}`,borderRadius:s?.addressDisplay?.borderRadius||l.borderRadius.sm,padding:s?.addressDisplay?.padding||`${l.spacing.xs} ${l.spacing.sm}`,fontSize:s?.addressDisplay?.fontSize||l.typography.fontSize.xs,fontFamily:s?.addressDisplay?.fontFamily||(s?.fontFamily?`${s.fontFamily}, IBM Plex Mono`:"IBM Plex Mono"),color:s?.addressDisplay?.color||l.colors.text,display:"flex",alignItems:"center",gap:l.spacing.sm},children:[e.jsxs("span",{style:{flex:1},children:[p.slice(0,6),"...",p.slice(-4)]}),e.jsx("button",{style:{fontSize:s?.addressDisplay?.copyButton?.fontSize||l.typography.fontSize.xs,padding:s?.addressDisplay?.copyButton?.padding||`${l.spacing.xs} ${l.spacing.sm}`,backgroundColor:s?.addressDisplay?.copyButton?.backgroundColor||(l.mode==="light"?"#e5e7eb":l.colors.surfaceHover),border:`1px solid ${s?.addressDisplay?.copyButton?.borderColor||(l.mode==="light"?"#d1d5db":l.colors.border)}`,borderRadius:s?.addressDisplay?.copyButton?.borderRadius||l.borderRadius.sm,color:s?.addressDisplay?.copyButton?.color||l.colors.text,fontFamily:s?.addressDisplay?.copyButton?.fontFamily||l.typography.fontFamily,cursor:"pointer",transition:`background-color ${l.animation.normal}`},onClick:()=>ro(p),title:"Copy address",children:"Copy"})]}),!A&&e.jsxs("div",{style:{marginTop:"6px",fontSize:l.typography.fontSize.xs,color:l.colors.textSecondary,fontFamily:l.typography.fontFamily},children:["Loading"," ",j?.provider==="privy"?"Privy":j?.provider==="dynamic"?"Dynamic":"Wallet","..."]})]})]}),e.jsxs("div",{style:{marginBottom:l.spacing.sm},children:[" ",e.jsx(go,{assets:ke,selectedAsset:F,onAssetSelect:Z,onAmountChange:T,amount:I,loading:U,label:"Collateral",theme:l,styles:s})]}),e.jsx("div",{style:{marginBottom:0},children:e.jsx(ht,{assets:Se,selectedAsset:y||void 0,onAssetSelect:se,onAmountChange:he,loading:U,label:"From",showBalance:!0,showMaxButton:!0,theme:l,styles:s})}),d&&e.jsx("div",{style:{display:"flex",justifyContent:"center",margin:`-${l.spacing.sm} 0`,position:"relative",zIndex:10},children:e.jsx("button",{onClick:oe,disabled:H||U,style:{backgroundColor:s?.flipButton?.backgroundColor||l.colors.primary,border:`1px solid ${s?.flipButton?.borderColor||l.colors.primary}`,borderRadius:s?.flipButton?.borderRadius||"50%",width:s?.flipButton?.size||"2.5rem",height:s?.flipButton?.size||"2.5rem",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",color:s?.flipButton?.color||"#ffffff",transition:`all ${l.animation.normal}`,transform:$?"rotate(180deg)":"rotate(0deg)",boxShadow:l.mode==="light"?"0 2px 4px rgba(0, 0, 0, 0.1)":"0 2px 4px rgba(0, 0, 0, 0.3)"},onMouseEnter:W=>{W.currentTarget.style.backgroundColor=s?.flipButton?.hoverBackgroundColor||l.colors.primaryHover,W.currentTarget.style.transform=$?"rotate(360deg) scale(1.1)":"rotate(0deg) scale(1.1)"},onMouseLeave:W=>{W.currentTarget.style.backgroundColor=s?.flipButton?.backgroundColor||l.colors.primary,W.currentTarget.style.transform=$?"rotate(360deg) scale(1)":"rotate(0deg) scale(1)"},children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M6 9l6 6 6-6"})})})}),e.jsxs("div",{style:{marginBottom:l.spacing.sm},children:[" ",e.jsx(ht,{assets:ve,selectedAsset:x||void 0,onAssetSelect:re,onAmountChange:Ce,loading:U,label:"To",theme:l,styles:s})]}),i&&e.jsxs("div",{style:{marginBottom:l.spacing.sm},children:[" ",e.jsx(ho,{config:P,onChange:_,theme:l,styles:s})]}),t.length>0&&e.jsxs("div",{style:{marginBottom:l.spacing.sm},children:[" ",e.jsxs("div",{style:{backgroundColor:s?.infoCard?.backgroundColor||s?.tertiaryBackground||(l.mode==="light"?"#f9fafb":l.colors.surface),border:`1px solid ${s?.infoCard?.borderColor||(l.mode==="light"?"#e5e7eb":l.colors.border)}`,borderRadius:s?.infoCard?.borderRadius||l.borderRadius.md,padding:s?.infoCard?.padding||l.spacing.sm},children:[e.jsx("div",{style:{fontSize:s?.infoCard?.title?.fontSize||l.typography.fontSize.xs,fontWeight:s?.infoCard?.title?.fontWeight||l.typography.fontWeight.medium,color:s?.infoCard?.title?.color||l.colors.text,fontFamily:s?.infoCard?.title?.fontFamily||l.typography.fontFamily,marginBottom:"4px"},children:"Swap Batches Ready"}),e.jsxs("div",{style:{fontSize:s?.infoCard?.description?.fontSize||l.typography.fontSize.xs,color:s?.infoCard?.description?.color||l.colors.textSecondary,fontFamily:s?.infoCard?.description?.fontFamily||l.typography.fontFamily},children:[t.length," swap batch",t.length>1?"es":""," across chains:"," ",[...new Set(t.map(W=>W.chainId))].join(", ")]})]})]}),ce&&e.jsx("div",{style:{backgroundColor:s?.errorMessage?.backgroundColor||(l.mode==="light"?"#fef2f2":`${s?.statusDisplay?.errorColor||l.colors.error}20`),border:`1px solid ${s?.errorMessage?.borderColor||(l.mode==="light"?"#fecaca":s?.statusDisplay?.errorColor||l.colors.error)}`,borderRadius:s?.errorMessage?.borderRadius||l.borderRadius.md,padding:s?.errorMessage?.padding||l.spacing.md,marginBottom:l.spacing.sm},children:e.jsx("p",{style:{color:s?.errorMessage?.color||s?.statusDisplay?.errorColor||l.colors.error,fontSize:s?.errorMessage?.fontSize||l.typography.fontSize.sm,fontWeight:s?.errorMessage?.fontWeight,fontFamily:s?.errorMessage?.fontFamily||l.typography.fontFamily,margin:0},children:ce})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:l.spacing.sm},children:e.jsx(de.Button,{variant:"primary",fullWidth:!0,onClick:le,loading:H,disabled:!Ie||!k,theme:l,styles:s,children:A?w?k?H?"Executing Swap...":y?x?F?y.amount?I?parseFloat(y.amount)>y.asset.balanceFormatted?"Insufficient From Balance":parseFloat(I)>F.balanceFormatted?"Insufficient Collateral Balance":t.length===0?"No Swap Batches":"Execute Swap":"Enter Collateral Amount":"Enter Amount":"Select Collateral":"Select To Token":"Select From Token":"Wallet Not Connected":"Authentication Required":"Loading..."})})]})},us=({address:t,supportedChains:o,enabled:r=!0,refetchInterval:n})=>{const[s,c]=a.useState([]),[i,d]=a.useState(!1),[g,f]=a.useState(null),[u,l]=a.useState(!1),C=a.useRef(!1),A=a.useRef(!1),w=o?JSON.stringify([...o].sort()):"",k=a.useCallback(async(m=!1)=>{if(!t||!r){c([]),l(!1),C.current=!1;return}if(!A.current){A.current=!0,!C.current&&!m&&d(!0),f(null);try{const j=await fetch(`${Yt}/spicedeposit/${t}`);if(!j.ok)throw new Error(`Failed to fetch balance: ${j.status}`);const y=await j.json();if(y.success&&y.data?.tokens&&Array.isArray(y.data.tokens)){const h=[];y.data.tokens.forEach(x=>{const S=x.chainId,F=x.tokenAddress,B=x.amount;if(o&&!o.includes(S))return;const I=BigInt(B||"0");if(I>BigInt(0)){const G=fe(S),P=F.toLowerCase()==="0x0"||F.toLowerCase()==="0x0000000000000000000000000000000000000000"||F.toLowerCase()==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";let _=18,$="TOKEN",J=F.slice(0,6)+"..."+F.slice(-4),M;if(P)_=G?.nativeCurrency?.decimals||18,$=G?.nativeCurrency?.symbol||"ETH",J=G?.nativeCurrency?.name||"Native Token";else{const E=G?.supportedTokens?.find(U=>U.address.toLowerCase()===F.toLowerCase());E&&(_=E.decimals,$=E.symbol,J=E.name,M=E.logoURI)}const z=parseFloat((Number(I)/Math.pow(10,_)).toFixed(6));z>0&&h.push({address:P?"0x0000000000000000000000000000000000000000":F,symbol:$,name:J,decimals:_,chainId:S,balance:I,balanceFormatted:z,balanceUsd:0,isNative:P,logoURI:M})}}),c(h),l(h.length>0),C.current=!0}else c([]),l(!1)}catch(j){const y=j instanceof Error?j.message:"Failed to fetch balance";f(y),console.error("Error fetching Spice assets:",j),C.current||(c([]),l(!1))}finally{d(!1),A.current=!1}}},[t,r,w]);a.useEffect(()=>{r&&t&&(C.current=!1,k(!1))},[t,r,w]),a.useEffect(()=>{if(!r||!t||!n)return;const m=setInterval(()=>{k(!0)},n);return()=>clearInterval(m)},[t,r,n,w]);const p=a.useCallback(m=>s.filter(j=>j.chainId===m),[s]),b=a.useCallback(async()=>{await k(!0)},[k]);return{assets:s,loading:i,error:g,hasBalance:u,refetch:b,getAssetsByChain:p}},hs=({isSuccess:t,type:o,chainName:r,explorerUrl:n,txHash:s})=>e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px",borderRadius:"8px",backgroundColor:t?"#d1fae5":"#fee2e2",border:t?"1px solid #6ee7b7":"1px solid #fca5a5"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx("div",{style:{width:"28px",height:"28px",borderRadius:"50%",backgroundColor:t?"#10b981":"#ef4444",display:"flex",alignItems:"center",justifyContent:"center"},children:t?e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:e.jsx("path",{d:"M11.6667 3.5L5.25 9.91667L2.33333 7",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}):e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:e.jsx("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:0,fontSize:"14px",fontWeight:600,fontFamily:'"IBM Plex Mono", monospace',letterSpacing:"0.5px",color:t?"#065f46":"#dc2626"},children:t?`${o.toUpperCase()} CONFIRMED`:`${o.toUpperCase()} FAILED`}),e.jsxs("p",{style:{margin:"2px 0 0 0",fontSize:"12px",color:"#6b7280"},children:["on ",r]})]})]}),n&&s&&e.jsxs("a",{href:`${n}/tx/${s}`,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"13px",color:"#6b7280",textDecoration:"none",whiteSpace:"nowrap"},children:["View on explorer",e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:[e.jsx("path",{d:"M9 6.5V9.5C9 9.76522 8.89464 10.0196 8.70711 10.2071C8.51957 10.3946 8.26522 10.5 8 10.5H2.5C2.23478 10.5 1.98043 10.3946 1.79289 10.2071C1.60536 10.0196 1.5 9.76522 1.5 9.5V4C1.5 3.73478 1.60536 3.48043 1.79289 3.29289C1.98043 3.10536 2.23478 3 2.5 3H5.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M7.5 1.5H10.5V4.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M5 7L10.5 1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]})]})]}),qt=({isOpen:t,onClose:o,onComplete:r,type:n,results:s,chainName:c="Network",explorerUrl:i,theme:d,styles:g,intentStatus:f,onRetry:u,onNewTx:l,onRetryTx:C,asOverlay:A=!1,isProcessing:w=!1})=>{const k=d||de.createTheme("light"),[p,b]=a.useState(!1),[m,j]=a.useState(!0),[y,h]=a.useState(null),[x,S]=a.useState(null);a.useEffect(()=>{!t&&!f&&b(!1)},[t,f]);const F=()=>{b(!0),setTimeout(()=>{r?.()},300)},B=()=>{j(!m)};if(f){const{steps:P,overallStatus:_}=f,$=_==="processing",J=_==="success",M=_==="failed",z=P.find(ee=>ee.transactionHash),E=c!=="Network"?c:P[0]?.chainName||c,U=i||(z?Wt(z.chainId,z.transactionHash||"").replace(/\/tx\/.*$/,""):void 0),X=e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"16px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},onClick:B,children:[e.jsxs("span",{style:{fontSize:"13px",fontWeight:500,color:"#6b7280",fontFamily:g?.fontFamily||k.typography.fontFamily},children:[$?`Processing ${n.charAt(0).toUpperCase()+n.slice(1)}`:`${n.charAt(0).toUpperCase()+n.slice(1)} results`," "]}),e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",style:{transform:m?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.3s ease"},children:e.jsx("path",{d:"M4 6L8 10L12 6",stroke:"#6b7280",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),!$&&e.jsx("button",{onClick:o,onMouseEnter:()=>h("close"),onMouseLeave:()=>{h(null),S(null)},onMouseDown:()=>S("close"),onMouseUp:()=>S(null),style:{background:x==="close"?"#f3f4f6":y==="close"?"#f9fafb":"none",border:"none",borderRadius:"4px",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:y==="close"||x==="close"?"#374151":"#6b7280",transform:x==="close"?"scale(0.9)":y==="close"?"scale(1.1)":"scale(1)",transition:"all 0.15s ease"},children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:e.jsx("path",{d:"M12 4L4 12M4 4L12 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e.jsx("div",{style:{marginBottom:"16px"},children:$?e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px 16px",borderRadius:"8px",backgroundColor:"#f3f4f6",border:"1px solid #e5e7eb",gap:"12px"},children:[e.jsx("div",{style:{width:"24px",height:"24px",border:"3px solid #e5e7eb",borderTopColor:k.colors.primary,borderRadius:"50%",animation:"spin 1s linear infinite"}}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:0,fontSize:"14px",fontWeight:600,fontFamily:'"IBM Plex Mono", monospace',letterSpacing:"0.5px",color:"#374151"},children:"PROCESSING TRANSACTION"}),e.jsxs("p",{style:{margin:"2px 0 0 0",fontSize:"12px",color:"#6b7280"},children:["on ",E]})]})]}):e.jsx(hs,{isSuccess:J,type:n,chainName:E,explorerUrl:U,txHash:z?.transactionHash})}),e.jsx("style",{children:`
|
|
3
3
|
@keyframes spin {
|
|
4
4
|
from { transform: rotate(0deg); }
|
|
5
5
|
to { transform: rotate(360deg); }
|
|
6
6
|
}
|
|
7
|
-
`}),e.jsx("div",{style:{overflow:"hidden",maxHeight:m?"300px":"0px",opacity:m?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease",marginBottom:m?"16px":"0"},children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:P.map((ee,H)=>e.jsxs("div",{style:{padding:"10px 12px",borderRadius:"6px",backgroundColor:"#f9fafb",border:"1px solid #e5e7eb",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("span",{style:{fontSize:"13px",color:"#374151"},children:ee.description||`Step ${H+1}`}),e.jsx("span",{style:{fontSize:"12px",color:ee.status==="success"?"#10b981":ee.status==="failed"?"#ef4444":"#6b7280",fontWeight:500},children:ee.status==="success"?"\u2713":ee.status==="failed"?"\u2717":"\u25CB"})]},H))})}),!$&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[M&&u&&e.jsx("button",{onClick:u,onMouseEnter:()=>h("retry"),onMouseLeave:()=>{h(null),S(null)},onMouseDown:()=>S("retry"),onMouseUp:()=>S(null),style:{width:"100%",height:"48px",padding:"14px 24px",borderRadius:"6px",backgroundColor:x==="retry"?"#d43d3d":y==="retry"?"#f05555":"#ea4b4b",border:"1px solid #0e0d0b",color:"#0e0d0b",fontWeight:500,fontSize:"16px",fontFamily:'"IBM Plex Mono", monospace',textTransform:"uppercase",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.15s ease",transform:x==="retry"?"scale(0.98)":y==="retry"?"translateY(-2px)":"none",boxShadow:x==="retry"?"1px 1px 0px black":y==="retry"?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:"TRY AGAIN"}),l&&e.jsxs("button",{onClick:l,onMouseEnter:()=>h("new-tx"),onMouseLeave:()=>{h(null),S(null)},onMouseDown:()=>S("new-tx"),onMouseUp:()=>S(null),style:{width:"100%",height:"48px",padding:"14px 24px",borderRadius:"6px",backgroundColor:x==="new-tx"?"#d43d3d":y==="new-tx"?"#f05555":"#ea4b4b",border:"1px solid #0e0d0b",color:"#0e0d0b",fontWeight:500,fontSize:"16px",fontFamily:'"IBM Plex Mono", monospace',textTransform:"uppercase",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.15s ease",transform:x==="new-tx"?"scale(0.98)":y==="new-tx"?"translateY(-2px)":"none",boxShadow:x==="continue-intent"?"1px 1px 0px black":y==="new-tx"?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:["NEW
|
|
7
|
+
`}),e.jsx("div",{style:{overflow:"hidden",maxHeight:m?"300px":"0px",opacity:m?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease",marginBottom:m?"16px":"0"},children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:P.map((ee,H)=>e.jsxs("div",{style:{padding:"10px 12px",borderRadius:"6px",backgroundColor:"#f9fafb",border:"1px solid #e5e7eb",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("span",{style:{fontSize:"13px",color:"#374151"},children:ee.description||`Step ${H+1}`}),e.jsx("span",{style:{fontSize:"12px",color:ee.status==="success"?"#10b981":ee.status==="failed"?"#ef4444":"#6b7280",fontWeight:500},children:ee.status==="success"?"\u2713":ee.status==="failed"?"\u2717":"\u25CB"})]},H))})}),!$&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[M&&u&&e.jsx("button",{onClick:u,onMouseEnter:()=>h("retry"),onMouseLeave:()=>{h(null),S(null)},onMouseDown:()=>S("retry"),onMouseUp:()=>S(null),style:{width:"100%",height:"48px",padding:"14px 24px",borderRadius:"6px",backgroundColor:x==="retry"?"#d43d3d":y==="retry"?"#f05555":"#ea4b4b",border:"1px solid #0e0d0b",color:"#0e0d0b",fontWeight:500,fontSize:"16px",fontFamily:'"IBM Plex Mono", monospace',textTransform:"uppercase",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.15s ease",transform:x==="retry"?"scale(0.98)":y==="retry"?"translateY(-2px)":"none",boxShadow:x==="retry"?"1px 1px 0px black":y==="retry"?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:"TRY AGAIN"}),l&&e.jsxs("button",{onClick:l,onMouseEnter:()=>h("new-tx"),onMouseLeave:()=>{h(null),S(null)},onMouseDown:()=>S("new-tx"),onMouseUp:()=>S(null),style:{width:"100%",height:"48px",padding:"14px 24px",borderRadius:"6px",backgroundColor:x==="new-tx"?"#d43d3d":y==="new-tx"?"#f05555":"#ea4b4b",border:"1px solid #0e0d0b",color:"#0e0d0b",fontWeight:500,fontSize:"16px",fontFamily:'"IBM Plex Mono", monospace',textTransform:"uppercase",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.15s ease",transform:x==="new-tx"?"scale(0.98)":y==="new-tx"?"translateY(-2px)":"none",boxShadow:x==="continue-intent"?"1px 1px 0px black":y==="new-tx"?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:["NEW ",n," \u2192"]})]})]});return A?e.jsxs("div",{style:{position:"absolute",bottom:0,left:0,right:0,zIndex:10,animation:p?"slideDown 0.3s ease-in forwards":"slideUp 0.3s ease-out forwards",pointerEvents:"auto"},children:[e.jsx("div",{style:{backgroundColor:"#ffffff",borderRadius:"12px 12px 0 0",width:"100%",padding:"18px 24px 24px",boxShadow:"0 -4px 8px -2px rgba(0, 0, 0, 0.15)"},children:X}),e.jsx("style",{children:`
|
|
8
8
|
@keyframes slideUp {
|
|
9
9
|
from { transform: translateY(100%); }
|
|
10
10
|
to { transform: translateY(0); }
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
from { transform: translateY(0); }
|
|
14
14
|
to { transform: translateY(100%); }
|
|
15
15
|
}
|
|
16
|
-
`})]}):e.jsx("div",{style:{backgroundColor:"#ffffff",borderRadius:"12px",padding:"24px",width:"100%",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.1)"},children:X})}if(!t&&!w||!w&&(!s||s.length===0))return null;const I=s?s.every(P=>P.success):!1;s&&s.some(P=>!P.success);const G=s?.[0]?.txHash;return e.jsxs("div",{style:{position:"absolute",bottom:0,left:0,right:0,zIndex:10,animation:p?"slideDown 0.3s ease-in forwards":"slideUp 0.3s ease-out forwards",pointerEvents:"auto"},children:[e.jsxs("div",{style:{backgroundColor:"#ffffff",borderRadius:"12px 12px 0 0",width:"100%",padding:"18px 24px 24px",boxShadow:"0 -4px 8px -2px rgba(0, 0, 0, 0.15)"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"16px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:w?"default":"pointer"},onClick:w?void 0:B,children:[e.
|
|
16
|
+
`})]}):e.jsx("div",{style:{backgroundColor:"#ffffff",borderRadius:"12px",padding:"24px",width:"100%",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.1)"},children:X})}if(!t&&!w||!w&&(!s||s.length===0))return null;const I=s?s.every(P=>P.success):!1;s&&s.some(P=>!P.success);const G=s?.[0]?.txHash;return e.jsxs("div",{style:{position:"absolute",bottom:0,left:0,right:0,zIndex:10,animation:p?"slideDown 0.3s ease-in forwards":"slideUp 0.3s ease-out forwards",pointerEvents:"auto"},children:[e.jsxs("div",{style:{backgroundColor:"#ffffff",borderRadius:"12px 12px 0 0",width:"100%",padding:"18px 24px 24px",boxShadow:"0 -4px 8px -2px rgba(0, 0, 0, 0.15)"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"16px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:w?"default":"pointer"},onClick:w?void 0:B,children:[e.jsxs("span",{style:{fontSize:"13px",fontWeight:500,color:"#6b7280",fontFamily:g?.fontFamily||k.typography.fontFamily},children:[w?`Processing ${n.charAt(0).toUpperCase()+n.slice(1)}`:`${n.charAt(0).toUpperCase()+n.slice(1)} results`," "]}),!w&&e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",style:{transform:m?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.3s ease"},children:e.jsx("path",{d:"M4 6L8 10L12 6",stroke:"#6b7280",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})}),e.jsx("div",{style:{marginBottom:"16px"},children:w?e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px 16px",borderRadius:"8px",backgroundColor:"#f3f4f6",border:"1px solid #e5e7eb",gap:"12px"},children:[e.jsx("div",{style:{width:"24px",height:"24px",border:"3px solid #e5e7eb",borderTopColor:k.colors.primary,borderRadius:"50%",animation:"spin 1s linear infinite"}}),e.jsxs("div",{children:[e.jsx("p",{style:{margin:0,fontSize:"14px",fontWeight:600,fontFamily:'"IBM Plex Mono", monospace',letterSpacing:"0.5px",color:"#374151"},children:"PROCESSING TRANSACTION"}),e.jsxs("p",{style:{margin:"2px 0 0 0",fontSize:"12px",color:"#6b7280"},children:["on ",c]})]})]}):e.jsx(hs,{isSuccess:I,type:n,chainName:c,explorerUrl:i,txHash:G})}),e.jsx("style",{children:`
|
|
17
17
|
@keyframes spin {
|
|
18
18
|
from { transform: rotate(0deg); }
|
|
19
19
|
to { transform: rotate(360deg); }
|
|
20
20
|
}
|
|
21
|
-
`}),!w&&s&&s.length>1&&e.jsx("div",{style:{overflow:"hidden",maxHeight:m?"200px":"0px",opacity:m?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease",marginBottom:m?"16px":"0"},children:e.jsx("div",{style:{maxHeight:"180px",overflowY:"auto",display:"flex",flexDirection:"column",gap:"8px"},children:s.map((P,_)=>e.jsxs("div",{style:{padding:"10px 12px",borderRadius:"6px",backgroundColor:"#f9fafb",border:"1px solid #e5e7eb",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontWeight:600,fontSize:"13px",color:"#111827",fontFamily:'"IBM Plex Mono", monospace'},children:P.asset.symbol}),P.amount&&e.jsx("span",{style:{fontSize:"12px",color:"#6b7280"},children:P.amount})]}),e.jsx("span",{style:{fontSize:"12px",color:P.success?"#10b981":"#ef4444",fontWeight:500},children:P.success?"\u2713":"\u2717"})]},_))})}),!w&&!I&&s&&e.jsx("div",{style:{padding:"12px",backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",marginBottom:"16px"},children:e.jsx("p",{style:{fontSize:"13px",color:"#dc2626",margin:0,lineHeight:1.5},children:s.find(P=>!P.success)?.error||"${type} failed. Please try again."})}),!w&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[!I&&C&&e.jsxs("button",{onClick:C,onMouseEnter:()=>h("retry-tx"),onMouseLeave:()=>{h(null),S(null)},onMouseDown:()=>S("retry-tx"),onMouseUp:()=>S(null),style:{width:"100%",height:"48px",padding:"14px 24px",borderRadius:"6px",backgroundColor:x==="retry-tx"?"#d43d3d":y==="retry-tx"?"#f05555":"#ea4b4b",border:"1px solid #0e0d0b",color:"#0e0d0b",fontFamily:'"IBM Plex Mono", monospace',fontWeight:500,fontSize:"16px",lineHeight:"156%",textTransform:"uppercase",cursor:"pointer",transition:"all 0.15s ease",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transform:x==="retry-results"?"scale(0.98)":y==="retry-results"?"translateY(-2px)":"none",boxShadow:x==="retry-tx"?"1px 1px 0px black":y==="retry-tx"?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:["TRY AGAIN $",n]}),I&&e.jsxs("button",{onClick:F,onMouseEnter:()=>h("continue-tx"),onMouseLeave:()=>{h(null),S(null)},onMouseDown:()=>S("continue-tx"),onMouseUp:()=>S(null),style:{width:"100%",height:"48px",padding:"14px 24px",borderRadius:"6px",backgroundColor:x==="continue-tx"?"#d43d3d":y==="continue-tx"?"#f05555":"#ea4b4b",border:"1px solid #0e0d0b",color:"#0e0d0b",fontFamily:'"IBM Plex Mono", monospace',fontWeight:500,fontSize:"16px",lineHeight:"156%",textTransform:"uppercase",cursor:"pointer",transition:"all 0.15s ease",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transform:x==="continue-tx"?"scale(0.98)":y==="continue-tx"?"translateY(-2px)":"none",boxShadow:x==="continue-tx"?"1px 1px 0px black":y==="continue-results"?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:["CONTINUE
|
|
21
|
+
`}),!w&&s&&s.length>1&&e.jsx("div",{style:{overflow:"hidden",maxHeight:m?"200px":"0px",opacity:m?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease",marginBottom:m?"16px":"0"},children:e.jsx("div",{style:{maxHeight:"180px",overflowY:"auto",display:"flex",flexDirection:"column",gap:"8px"},children:s.map((P,_)=>e.jsxs("div",{style:{padding:"10px 12px",borderRadius:"6px",backgroundColor:"#f9fafb",border:"1px solid #e5e7eb",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontWeight:600,fontSize:"13px",color:"#111827",fontFamily:'"IBM Plex Mono", monospace'},children:P.asset.symbol}),P.amount&&e.jsx("span",{style:{fontSize:"12px",color:"#6b7280"},children:P.amount})]}),e.jsx("span",{style:{fontSize:"12px",color:P.success?"#10b981":"#ef4444",fontWeight:500},children:P.success?"\u2713":"\u2717"})]},_))})}),!w&&!I&&s&&e.jsx("div",{style:{padding:"12px",backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",marginBottom:"16px"},children:e.jsx("p",{style:{fontSize:"13px",color:"#dc2626",margin:0,lineHeight:1.5},children:s.find(P=>!P.success)?.error||"${type} failed. Please try again."})}),!w&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[!I&&C&&e.jsxs("button",{onClick:C,onMouseEnter:()=>h("retry-tx"),onMouseLeave:()=>{h(null),S(null)},onMouseDown:()=>S("retry-tx"),onMouseUp:()=>S(null),style:{width:"100%",height:"48px",padding:"14px 24px",borderRadius:"6px",backgroundColor:x==="retry-tx"?"#d43d3d":y==="retry-tx"?"#f05555":"#ea4b4b",border:"1px solid #0e0d0b",color:"#0e0d0b",fontFamily:'"IBM Plex Mono", monospace',fontWeight:500,fontSize:"16px",lineHeight:"156%",textTransform:"uppercase",cursor:"pointer",transition:"all 0.15s ease",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transform:x==="retry-results"?"scale(0.98)":y==="retry-results"?"translateY(-2px)":"none",boxShadow:x==="retry-tx"?"1px 1px 0px black":y==="retry-tx"?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:["TRY AGAIN $",n]}),I&&e.jsxs("button",{onClick:F,onMouseEnter:()=>h("continue-tx"),onMouseLeave:()=>{h(null),S(null)},onMouseDown:()=>S("continue-tx"),onMouseUp:()=>S(null),style:{width:"100%",height:"48px",padding:"14px 24px",borderRadius:"6px",backgroundColor:x==="continue-tx"?"#d43d3d":y==="continue-tx"?"#f05555":"#ea4b4b",border:"1px solid #0e0d0b",color:"#0e0d0b",fontFamily:'"IBM Plex Mono", monospace',fontWeight:500,fontSize:"16px",lineHeight:"156%",textTransform:"uppercase",cursor:"pointer",transition:"all 0.15s ease",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transform:x==="continue-tx"?"scale(0.98)":y==="continue-tx"?"translateY(-2px)":"none",boxShadow:x==="continue-tx"?"1px 1px 0px black":y==="continue-results"?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:["CONTINUE ",n," \u2192"]})]})]}),e.jsx("style",{children:`
|
|
22
22
|
@keyframes slideUp {
|
|
23
23
|
from {
|
|
24
24
|
transform: translateY(100%);
|