@spicenet-io/spiceflow-ui 4.18.6 → 4.18.7

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.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  (function(){if(typeof document==="undefined"||document.getElementById("spiceflow-styles"))return;var s=document.createElement("style");s.id="spiceflow-styles";s.textContent="@keyframes spiceflow-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}@keyframes spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}@media (prefers-reduced-motion:reduce){*,:after,:before{animation-duration:.001ms!important;animation-iteration-count:1!important;scroll-behavior:auto!important;transition-duration:.001ms!important}}.spiceflow-focus-ring:focus-visible,[data-spiceflow-focus]:focus-visible{border-radius:4px;outline:2px solid currentColor;outline-offset:2px}@media (forced-colors:active){.spiceflow-focus-ring:focus-visible,[data-spiceflow-focus]:focus-visible{outline:2px solid Highlight}}.ibm-plex-mono-thin{font-weight:100}.ibm-plex-mono-extralight,.ibm-plex-mono-thin{font-family:IBM Plex Mono,monospace!important;font-style:normal}.ibm-plex-mono-extralight{font-weight:200}.ibm-plex-mono-light{font-weight:300}.ibm-plex-mono-light,.ibm-plex-mono-regular{font-family:IBM Plex Mono,monospace!important;font-style:normal}.ibm-plex-mono-regular{font-weight:400}.ibm-plex-mono-medium{font-weight:500}.ibm-plex-mono-medium,.ibm-plex-mono-semibold{font-family:IBM Plex Mono,monospace!important;font-style:normal}.ibm-plex-mono-semibold{font-weight:600}.ibm-plex-mono-bold{font-family:IBM Plex Mono,monospace!important;font-style:normal;font-weight:700}#privy-modal-content button{border-radius:6px;font-family:IBM Plex Mono,monospace!important;font-size:small;letter-spacing:-.5px;text-transform:uppercase}#privy-modal-content input{background:#fff;border-radius:6px;padding-top:5px!important}#privy-dialog-title{display:none!important;font-size:18px;padding-bottom:10px;padding-top:10px}.AppLogoContainer-sc-a206bd44-0{display:none}#privy-modal-content{background:var(--Neutral-0,#fafafa);border:6px solid var(--Neutral-1,#e9e9e9);box-shadow:inset 0 0 0 1px rgba(0,0,0,.15),0 330px 92px transparent,0 211px 84px rgba(0,0,0,.01),0 119px 71px rgba(0,0,0,.05),0 53px 53px rgba(0,0,0,.09),0 13px 29px rgba(0,0,0,.1);height:auto!important;padding-bottom:10px}.Subtitle-sc-ddbf22b4-4{font-size:12px;margin-top:-14px;opacity:.5}.StyledLink-sc-1c6127e5-0{background:none!important}.StyledLink-sc-c8577138-0,.login-method-button{font-family:IBM Plex Mono,monospace!important}.StyledLink-sc-c8577138-0{font-style:uppercase}#protected-by-privy{color:#000!important}";document.head.appendChild(s)})();
3
- import{jsxs as A,jsx as p,Fragment as nn}from"react/jsx-runtime";import{g as nt,a as bt,S as ze,b as oe,c as Vr,i as Qr,d as xi,e as Ht,f as jd,E as Gd,C as jr,r as Kd,R as Yd,h as Zd,j as bi,k as yt,l as Ms,u as to,m as ar,n as Ws,o as Tn,z as Io,p as jn,q as Ne,s as Vt,t as Ps,v as Po,w as vi,x as Ci,y as Dn,A as ir,B as Mn,D as Ns,F as Gr,G as Kr,H as Us,I as no,J as Yr,K as Mt,L as No,M as lr,N as Xd,P as Jd,O as mo,Q as ki,T as oo,U as $d,V as cr,W as Zr,X as Ii,Y as _d,Z as dr,_ as eu,$ as Si,a0 as Ls,a1 as So,a2 as tu,a3 as nu,a4 as ou,a5 as ru,a6 as su,a7 as au,a8 as iu}from"./privy-Bf6vkrCg.js";import{a9 as l0,ab as c0,ac as d0,ae as u0,ad as p0,aa as f0}from"./privy-Bf6vkrCg.js";import Hn,{useContext as Kt,useState as P,useMemo as me,useEffect as ue,useCallback as te,useRef as Z,useId as Ai,useLayoutEffect as Ao,memo as Bn}from"react";import{isNativeToken as be,uniV3QuoterV2Abi as lu,uniV3SwapRouterAbi as Ei,applySlippage as Fi,NATIVE_TOKEN_ADDRESS as Ti,getTokenByAddress as Ut,areEquivalent as cu,getTokensForChain as ur,getEscrowContractAddress as ro,getEscrowContract as pr,ZERO_ADDRESS as Dt,normalizeNativeTokenAddress as dt,getChainMeta as Bi,getMainnetChains as du,getTestnetChains as uu,TOKENS as Oi,convertAmountBetweenDecimals as Vn,getChainIdsByNetwork as Xr,hashChainBatches as Gn,isSpicenetChainId as Uo,getAccountNonce as pu,SPICE_COMBINED_FEE_RECIPIENT as fu,SPICE_GAS_FEE_RECIPIENT as Zt,SPICE_PLATFORM_FEE_RECIPIENT as xn,getEquivalenceGroup as mu,SPICENET_NATIVE_CHAIN_ID as Ri,spicenetAbi as zs,getEquivalentAddresses as hu,getTokenBySymbol as Di}from"@spicenet-io/spiceflow-core";import{ZERO_ADDRESS as h0,SPICENET_NATIVE_CHAIN_ID as g0,SPICE_COMBINED_FEE_RECIPIENT as y0,SPICE_GAS_FEE_RECIPIENT as w0,SPICE_PLATFORM_FEE_RECIPIENT as x0,SPICE_SOLVER_ADDRESS as b0,applySlippage as v0,buildUniV3SwapCalls as C0,getChainIdsByNetwork as k0,getEscrowContractAddress as I0,isNativeToken as S0,isSpicenetChainId as A0,normalizeNativeTokenAddress as E0,spicenetAbi as F0,spicenetAbi as T0}from"@spicenet-io/spiceflow-core";import{useWalletClient as gu,useAccount as qs,useDisconnect as Hs,useConnect as yu,useSwitchChain as wu}from"wagmi";import{encodeFunctionData as Tt,parseAbi as Wn,concatHex as xu,encodePacked as Vs,erc20Abi as ot,decodeFunctionData as so,encodeAbiParameters as ao,formatUnits as Ee,isAddress as vn,getAddress as Yt,keccak256 as Lo,createWalletClient as Qs,custom as js,parseUnits as Cn,decodeEventLog as bu,toHex as Mi,stringToHex as vu,bytesToHex as Cu}from"viem";import{readContract as ho,getBalance as Gs}from"viem/actions";import{useConnectWallet as Wi,usePrivy as Pi,useActiveWallet as ku}from"@privy-io/react-auth";import Ks,{createPortal as Ys}from"react-dom";import"@tanstack/react-query";const Iu="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@100;200;300;400;500;600;700&display=swap",Su="spiceflow-ibm-plex-mono",Au="spiceflow-preconnect-googleapis",Eu="spiceflow-preconnect-gstatic";function Zs(e,t){if(document.getElementById(e))return;const n=t();n.id=e,document.head.appendChild(n)}function Fu(){typeof document>"u"||(Zs(Au,()=>{const e=document.createElement("link");return e.rel="preconnect",e.href="https://fonts.googleapis.com",e}),Zs(Eu,()=>{const e=document.createElement("link");return e.rel="preconnect",e.href="https://fonts.gstatic.com",e.crossOrigin="",e}),Zs(Su,()=>{const e=document.createElement("link");return e.rel="stylesheet",e.href=Iu,e}))}const Tu={1:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",8453:"0x4200000000000000000000000000000000000006",42161:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",84532:"0x4200000000000000000000000000000000000006"},Ni=Wn(["function deposit() payable","function withdraw(uint256 wad)"]);function Xs(e){return nt(e)?.wrappedNativeTokenAddress??Tu[e]}const Js=(e,t)=>({to:e,value:t,data:Tt({abi:Ni,functionName:"deposit"})}),$s=(e,t)=>({to:e,value:0n,data:Tt({abi:Ni,functionName:"withdraw",args:[t]})});function _s(e,t,n){const o=be(t),r=be(n);if(!o&&!r)return null;const s=Xs(e);return s?{weth:s,wrapIn:o,unwrapOut:r}:null}function Ui(e,t,n,o){const r=_s(e,t,n);return!r||o<=0n?null:r.wrapIn&&!r.unwrapOut&&n.toLowerCase()===r.weth.toLowerCase()?[Js(r.weth,o)]:r.unwrapOut&&!r.wrapIn&&t.toLowerCase()===r.weth.toLowerCase()?[$s(r.weth,o)]:null}function Bu(e){return{...e,resolve:async(t,n,o,r)=>{const s=Ui(n,t.tokenIn,t.tokenOut,t.amountIn);if(s)return{venue:"native-wrap",amountOut:t.amountIn,amountOutMinimum:t.amountIn,calls:s};const a=await e.resolve(t,n,o,r);if(a)return a;const i=_s(n,t.tokenIn,t.tokenOut);if(!i)return null;const l=await e.resolve({...t,tokenIn:i.wrapIn?i.weth:t.tokenIn,tokenOut:i.unwrapOut?i.weth:t.tokenOut},n,o,r);return l?{...l,calls:[...i.wrapIn?[Js(i.weth,t.amountIn)]:[],...l.calls,...i.unwrapOut?[$s(i.weth,l.amountOutMinimum)]:[]]}:null}}}function Ou(e){return{...e,resolve:async(t,n,o)=>{const r=Ui(n,t.tokenIn,t.tokenOut,t.amountOut);if(r)return{venue:"native-wrap",amountIn:t.amountOut,amountInMax:t.amountOut,amountOut:t.amountOut,calls:r};const s=await e.resolve(t,n,o);if(s)return s;const a=_s(n,t.tokenIn,t.tokenOut);if(!a)return null;const i=await e.resolve({...t,tokenIn:a.wrapIn?a.weth:t.tokenIn,tokenOut:a.unwrapOut?a.weth:t.tokenOut},n,o);return i?{...i,calls:[...a.wrapIn?[Js(a.weth,i.amountInMax)]:[],...i.calls,...a.unwrapOut?[$s(a.weth,i.amountOut)]:[]]}:null}}}const Li=[100,500,3e3,1e4];function Jr(e,t,n,o,r){const s=[];for(const a of n){const i=typeof a=="object"&&!Array.isArray(a)?a:void 0,l=i?i.tokens:Array.isArray(a)?a:[a];if(!l.length||l.length>2)throw new Error("A v3 route must have one or two intermediate tokens");const c=[e,...l,t];if(i&&(i.feeTiers.length!==c.length-1||i.feeTiers.some(u=>!u.length)))throw new Error("A v3 route needs fee tiers for every pool");if(new Set(c.map(u=>u.toLowerCase())).size!==c.length)continue;const d=(u,f)=>{if(u===c.length){s.push(r==="in"?f:zi(f));return}for(const y of i?.feeTiers[u-1]??o)d(u+1,xu([f,Vs(["uint24","address"],[y,c[u]])]))};d(1,c[0])}return[...new Set(s)]}function zi(e){const t=e.slice(2),n=[];for(let o=0;o<t.length;){const r=n.length%2===0?40:6;n.push(t.slice(o,o+r)),o+=r}return`0x${n.reverse().join("")}`}const Ru=Wn(["function exactOutputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountOut, uint256 amountInMaximum, uint160 sqrtPriceLimitX96) params) payable returns (uint256 amountIn)","function exactOutput((bytes path, address recipient, uint256 amountOut, uint256 amountInMaximum) params) payable returns (uint256 amountIn)"]),Du=Wn(["function exactOutputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 deadline, uint256 amountOut, uint256 amountInMaximum, uint160 sqrtPriceLimitX96) params) payable returns (uint256 amountIn)","function exactOutput((bytes path, address recipient, uint256 deadline, uint256 amountOut, uint256 amountInMaximum) params) payable returns (uint256 amountIn)"]),Mu=1800;function qi(e){const{config:t,route:n,tokenIn:o,tokenOut:r,recipient:s,amountOut:a}=e,i=e.amountInMaximum,l=e.routerHasDeadline?Du:Ru,c=e.routerHasDeadline?{deadline:BigInt(Math.floor(Date.now()/1e3)+Mu)}:{},d=n.path?Tt({abi:l,functionName:"exactOutput",args:[{path:n.path,recipient:s,...c,amountOut:a,amountInMaximum:i}]}):Tt({abi:l,functionName:"exactOutputSingle",args:[{tokenIn:o,tokenOut:r,fee:n.fee,recipient:s,...c,amountOut:a,amountInMaximum:i,sqrtPriceLimitX96:0n}]});return{to:t.swapRouter,value:0n,data:d}}const Wu=Wn(["function quoteExactInput(bytes path, uint256 amountIn) returns (uint256 amountOut, uint160[] sqrtPriceX96AfterList, uint32[] initializedTicksCrossedList, uint256 gasEstimate)","function quoteExactOutput(bytes path, uint256 amountOut) returns (uint256 amountIn, uint160[] sqrtPriceX96AfterList, uint32[] initializedTicksCrossedList, uint256 gasEstimate)"]);async function fr(e,t,n,o,r){const s=bt(e),{result:a}=await s.simulateContract({address:t.quoterV2,abi:Wu,functionName:r==="in"?"quoteExactInput":"quoteExactOutput",args:[n,o]}),[i,,,l]=a;if(i<=0n)throw new Error("No liquidity along this path.");return{amount:i,gasEstimate:l}}async function Pu(e){const{tokenIn:t,tokenOut:n,amountIn:o,fee:r,chainId:s,config:a}=e;if(o<=0n)throw new Error("amountIn must be greater than 0");const i=(await bt(s).simulateContract({address:a.quoterV2,abi:lu,functionName:"quoteExactInputSingle",args:[{tokenIn:t,tokenOut:n,amountIn:o,fee:r,sqrtPriceLimitX96:0n}]})).result;if(i[0]<=0n)throw new Error("No liquidity found for this pair. The pool returned 0 output.");return{amountOut:i[0],sqrtPriceX96After:i[1],gasEstimate:i[3]}}async function Hi(e){const t=e.feeTiers??Li,n=Jr(e.tokenIn,e.tokenOut,e.hubs??[],t,"in"),o=await Promise.allSettled([...t.map(async s=>({...await Pu({...e,fee:s}),fee:s})),...n.map(async s=>{const a=await fr(e.chainId,e.config,s,e.amountIn,"in");return{amountOut:a.amount,sqrtPriceX96After:0n,gasEstimate:a.gasEstimate,fee:0,path:s}})]);let r=null;for(const s of o)s.status==="fulfilled"&&(!r||s.value.amountOut>r.amountOut)&&(r=s.value);if(!r)throw new Error("No liquidity found for this pair on any fee tier.");return r}const Nu=[{inputs:[{components:[{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"amount",type:"uint256"},{name:"fee",type:"uint24"},{name:"sqrtPriceLimitX96",type:"uint160"}],name:"params",type:"tuple"}],name:"quoteExactOutputSingle",outputs:[{name:"amountIn",type:"uint256"},{name:"sqrtPriceX96After",type:"uint160"},{name:"initializedTicksCrossed",type:"uint32"},{name:"gasEstimate",type:"uint256"}],stateMutability:"nonpayable",type:"function"}];async function Uu(e){const{tokenIn:t,tokenOut:n,amountOut:o,fee:r,chainId:s,config:a}=e;if(o<=0n)throw new Error("amountOut must be greater than 0");const i=(await bt(s).simulateContract({address:a.quoterV2,abi:Nu,functionName:"quoteExactOutputSingle",args:[{tokenIn:t,tokenOut:n,amount:o,fee:r,sqrtPriceLimitX96:0n}]})).result;if(i[0]<=0n)throw new Error("No liquidity found for this pair. The pool returned 0 input.");return{amountIn:i[0],sqrtPriceX96After:i[1],gasEstimate:i[3]}}async function Vi(e){const t=e.feeTiers??Li,n=Jr(e.tokenIn,e.tokenOut,e.hubs??[],t,"out"),o=await Promise.allSettled([...t.map(async s=>({...await Uu({...e,fee:s}),fee:s})),...n.map(async s=>{const a=await fr(e.chainId,e.config,s,e.amountOut,"out");return{amountIn:a.amount,sqrtPriceX96After:0n,gasEstimate:a.gasEstimate,fee:0,path:s}})]);let r=null;for(const s of o)s.status==="fulfilled"&&(!r||s.value.amountIn<r.amountIn)&&(r=s.value);if(!r)throw new Error("No liquidity found for this pair on any fee tier.");return r}function Lu(e){return e.type==="swap"}const mr=.02,zu=[1,8453,42161,10,137,43114,56],qu="https://api.1inch.dev/swap/v6.0";function ea(e,t){return Fi(e,t)}function Hu(e){const t=e?.baseUrl??qu;return{name:"1inch",chainIds:e?.chainIds??zu,resolve:async(n,o,r)=>{const s=n.maxSlippage??mr,a=s*100,i=be(n.tokenIn)?Ti:n.tokenIn,l=be(n.tokenOut)?Ti:n.tokenOut,c=be(n.tokenIn);try{const d=new URL(`${t}/${o}/swap`);d.searchParams.set("src",i),d.searchParams.set("dst",l),d.searchParams.set("amount",n.amountIn.toString()),d.searchParams.set("from",r),d.searchParams.set("slippage",a.toString()),d.searchParams.set("disableEstimate","true"),d.searchParams.set("allowPartialFill","false");const u={Accept:"application/json"};e?.apiKey&&(u.Authorization=`Bearer ${e.apiKey}`);const f=await fetch(d.toString(),{headers:u});if(!f.ok)throw new ze("VENUE_API_ERROR",`[1inchVenue] API returned ${f.status} for ${n.tokenIn} \u2192 ${n.tokenOut} on chain ${o}`,{venue:"1inch",chainId:o,tokenIn:n.tokenIn,tokenOut:n.tokenOut,amountIn:n.amountIn.toString(),cause:`HTTP ${f.status}`});const y=await f.json();if(!y.dstAmount||!y.tx)return console.warn(`[1inchVenue] No route data for ${n.tokenIn} \u2192 ${n.tokenOut} on chain ${o}`),null;const m=BigInt(y.dstAmount);if(m<=0n)return console.warn(`[1inchVenue] Zero output for ${n.tokenIn} \u2192 ${n.tokenOut} on chain ${o}`),null;const g=ea(m,s),h=[];return y.tx.to&&!c&&h.push({to:n.tokenIn,value:0n,data:Tt({abi:ot,functionName:"approve",args:[y.tx.to,n.amountIn]})}),h.push({to:y.tx.to,value:BigInt(y.tx.value||"0"),data:y.tx.data}),{venue:"1inch",amountOut:m,amountOutMinimum:g,calls:h}}catch(d){if(d instanceof ze)throw d;const u=d instanceof Error?d.message:String(d);throw new ze("VENUE_API_ERROR",`[1inchVenue] Exception for ${n.tokenIn} \u2192 ${n.tokenOut} on chain ${o}: ${u}`,{venue:"1inch",chainId:o,tokenIn:n.tokenIn,tokenOut:n.tokenOut,amountIn:n.amountIn.toString(),cause:u})}}}}const Qi=[4114,5115],ta={name:"Satsuma",swapRouter:"0x565eD3D57fe40f78A46f348C220121AE093c3cF8",quoterV2:"0x428f20dd8926Eabe19653815Ed0BE7D6c36f8425",feeTiers:[3e3]},ji={name:"Uniswap v3",swapRouter:"0x2626664c2603336E57B271c5C0b26F421741e481",quoterV2:"0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a",chainIds:[8453],feeTiers:[100,500,3e3,1e4],hubCurrencies:["0x4200000000000000000000000000000000000006","0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"]},Gi={name:"Uniswap v3",swapRouter:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",quoterV2:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",chainIds:[1],feeTiers:[100,500,3e3,1e4],hubCurrencies:["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2","0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]},Ki={name:"Uniswap v3",swapRouter:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",quoterV2:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",chainIds:[42161],feeTiers:[100,500,3e3,1e4],hubCurrencies:["0x82aF49447D8a07e3bd95BD0d56f35241523fBab1","0xaf88d065e77c8cC2239327C5EDb3A432268e5831"]},Vu={name:"Uniswap v3",swapRouter:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",quoterV2:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",chainIds:[137],feeTiers:[100,500,3e3,1e4],hubCurrencies:["0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270","0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359"]},Qu={name:"Uniswap v3",swapRouter:"0xB971eF87ede563556b2ED4b1C0b0019111Dd85d2",quoterV2:"0x78D78E420Da98ad378D7799bE8f4AF69033EB077",chainIds:[56],feeTiers:[100,500,3e3,1e4],hubCurrencies:["0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c","0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"]},ju={name:"Uniswap v3",swapRouter:"0xfe31f71c1b106eac32f1a19239c9a9a72ddfb900",quoterV2:"0x661e93cca42afacb172121ef892830ca3b70f08d",chainIds:[143],feeTiers:[100,500,3e3,1e4],hubCurrencies:["0x3bd359C1119dA7Da1D913D1C4D2B7c461115433A","0x754704Bc059F8C67012fEd69BC8A327a5aafb603"]},Yi={name:"Uniswap v3",swapRouter:"0xcaf681a66d020601342297493863e78c959e5cb2",quoterV2:"0x33e885ed0ec9bf04ecfb19341582aadcb4c8a9e7",chainIds:[4663],feeTiers:[100,500,3e3,1e4],hubCurrencies:["0x0bd7d308f8e1639fab988df18a8011f41eacad73","0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168"]},Zi={name:"SushiSwap",swapRouter:"0x1e406484F1F204b23cE84B9901C0171a738fd406",quoterV2:"0x3E290e5E01818002A0b672148BdC7514D861C7B3",chainIds:[4663],feeTiers:[100,500,3e3,1e4],hubCurrencies:["0x0bd7d308f8e1639fab988df18a8011f41eacad73","0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168"],routerHasDeadline:!0},Xi=Wn(["function exactInput((bytes path, address recipient, uint256 amountIn, uint256 amountOutMinimum) params) payable returns (uint256 amountOut)"]),Ji=Wn(["function exactInputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 deadline, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96) params) payable returns (uint256 amountOut)","function exactInput((bytes path, address recipient, uint256 deadline, uint256 amountIn, uint256 amountOutMinimum) params) payable returns (uint256 amountOut)"]),Gu=Wn(["function exactInput((bytes path, address recipient, uint256 deadline, uint256 amountIn, uint256 amountOutMinimum) params) payable returns (uint256 amountOut)"]),Ku=Wn(["function exactOutput((bytes path, address recipient, uint256 deadline, uint256 amountOut, uint256 amountInMaximum) params) payable returns (uint256 amountIn)"]),na=1800,$i=[1,50,100,200,2e3],$r={name:"Aerodrome",swapRouter:"0xcbBb8035cAc7D4B3Ca7aBb74cF7BdF900215Ce0D",quoterV2:"0x3d4C22254F86f64B7eC90ab8F7aeC1FBFD271c6C",chainIds:[8453],hubCurrencies:["0x4200000000000000000000000000000000000006","0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"]};function _r(e){const t=e.name??"Aerodrome",n=e.chainIds??[8453],o=e.tickSpacings??$i;return{name:t,chainIds:n,resolve:async(r,s,a)=>{if(be(r.tokenIn)||be(r.tokenOut))return null;const i=r.maxSlippage??mr,l=[...o.map(h=>Vs(["address","uint24","address"],[r.tokenIn,h,r.tokenOut])),...Jr(r.tokenIn,r.tokenOut,e.hubCurrencies??[],o,"in")],c={quoterV2:e.quoterV2},d=await Promise.allSettled(l.map(async h=>({path:h,amountOut:(await fr(s,c,h,r.amountIn,"in")).amount})));let u=null;for(const h of d)h.status==="fulfilled"&&(!u||h.value.amountOut>u.amountOut)&&(u=h.value);if(!u)return console.warn(`[AerodromeVenue] No viable route for ${r.tokenIn} \u2192 ${r.tokenOut} on chain ${s}.`),null;const f=ea(u.amountOut,i),y=BigInt(Math.floor(Date.now()/1e3)+na),m=Tt({abi:Gu,functionName:"exactInput",args:[{path:u.path,recipient:a,deadline:y,amountIn:r.amountIn,amountOutMinimum:f}]}),g=[{to:r.tokenIn,value:0n,data:Tt({abi:ot,functionName:"approve",args:[e.swapRouter,r.amountIn]})},{to:e.swapRouter,value:0n,data:m}];return{venue:t,amountOut:u.amountOut,amountOutMinimum:f,calls:g}}}}function _i(e){const t=e.name??"Aerodrome",n=e.chainIds??[8453],o=e.tickSpacings??$i;return{name:t,chainIds:n,resolve:async(r,s,a)=>{if(be(r.tokenIn)||be(r.tokenOut))return null;const i=r.maxSlippage??mr,l=[...o.map(g=>Vs(["address","uint24","address"],[r.tokenOut,g,r.tokenIn])),...Jr(r.tokenIn,r.tokenOut,e.hubCurrencies??[],o,"out")],c={quoterV2:e.quoterV2},d=await Promise.allSettled(l.map(async g=>({path:g,amountIn:(await fr(s,c,g,r.amountOut,"out")).amount})));let u=null;for(const g of d)g.status==="fulfilled"&&(!u||g.value.amountIn<u.amountIn)&&(u=g.value);if(!u)return console.warn(`[AerodromeExactOutputVenue] No viable route for ${r.tokenIn} \u2192 ${r.tokenOut} on chain ${s}.`),null;const f=BigInt(Math.round(i*1e4)),y=u.amountIn+u.amountIn*f/10000n,m=BigInt(Math.floor(Date.now()/1e3)+na);return{venue:t,amountIn:u.amountIn,amountInMax:y,amountOut:r.amountOut,calls:[{to:e.swapRouter,value:0n,data:Tt({abi:Ku,functionName:"exactOutput",args:[{path:u.path,recipient:a,deadline:m,amountOut:r.amountOut,amountInMaximum:y}]})}]}}}}function hr(e){const t=e.name??"Uniswap v3",n=e.chainIds??Qi;return{name:t,chainIds:n,resolve:async(o,r,s,a)=>{if(be(o.tokenIn)||be(o.tokenOut))return null;const i=o.maxSlippage??mr;let l;try{let m;if(a){if(a.venue!==t)return null;const g=a.calls.find(w=>w.to.toLowerCase()===e.swapRouter.toLowerCase());if(!g)return null;const h=so({abi:e.routerHasDeadline?Ji:[...Xi,...Ei],data:g.data});if(h.functionName==="exactInput"){const{path:w}=h.args[0];if(w.slice(0,42).toLowerCase()!==o.tokenIn.toLowerCase()||`0x${w.slice(-40)}`.toLowerCase()!==o.tokenOut.toLowerCase())return null;m={path:w,fee:0}}else if(h.functionName==="exactInputSingle"){const{tokenIn:w,tokenOut:x,fee:b}=h.args[0];if(w.toLowerCase()!==o.tokenIn.toLowerCase()||x.toLowerCase()!==o.tokenOut.toLowerCase())return null;m={fee:b}}else return null}l=m?.path?{...m,amountOut:(await fr(r,e,m.path,o.amountIn,"in")).amount}:await Hi({tokenIn:o.tokenIn,tokenOut:o.tokenOut,amountIn:o.amountIn,chainId:r,config:{swapRouter:e.swapRouter,quoterV2:e.quoterV2},feeTiers:m?[m.fee]:e.feeTiers,hubs:m?[]:[...e.hubCurrencies??[],...e.hubPaths??[]]})}catch{return console.warn(`[UniV3Venue] No viable route for ${o.tokenIn} \u2192 ${o.tokenOut} on chain ${r}.`),null}const c=ea(l.amountOut,i),d=e.routerHasDeadline?{deadline:BigInt(Math.floor(Date.now()/1e3)+na)}:{},u=e.routerHasDeadline?Ji:l.path?Xi:Ei,f=l.path?Tt({abi:u,functionName:"exactInput",args:[{path:l.path,recipient:s,...d,amountIn:o.amountIn,amountOutMinimum:c}]}):Tt({abi:u,functionName:"exactInputSingle",args:[{tokenIn:o.tokenIn,tokenOut:o.tokenOut,fee:l.fee,recipient:s,...d,amountIn:o.amountIn,amountOutMinimum:c,sqrtPriceLimitX96:0n}]}),y=[{to:o.tokenIn,value:0n,data:Tt({abi:ot,functionName:"approve",args:[e.swapRouter,o.amountIn]})},{to:e.swapRouter,value:0n,data:f}];return{venue:t,amountOut:l.amountOut,amountOutMinimum:c,calls:y}}}}function oa(e){const t=e.name??"Uniswap v3",n=e.chainIds??Qi;return{name:t,chainIds:n,resolve:async(o,r,s)=>{if(be(o.tokenIn)||be(o.tokenOut))return null;const a=o.maxSlippage??mr;let i;try{i=await Vi({tokenIn:o.tokenIn,tokenOut:o.tokenOut,amountOut:o.amountOut,chainId:r,config:{swapRouter:e.swapRouter,quoterV2:e.quoterV2},feeTiers:e.feeTiers,hubs:[...e.hubCurrencies??[],...e.hubPaths??[]]})}catch{return null}const l=BigInt(Math.round(a*1e4)),c=i.amountIn+i.amountIn*l/10000n;return{venue:t,amountIn:i.amountIn,amountInMax:c,amountOut:o.amountOut,calls:[qi({config:{swapRouter:e.swapRouter,quoterV2:e.quoterV2},routerHasDeadline:e.routerHasDeadline,route:i,tokenIn:o.tokenIn,tokenOut:o.tokenOut,recipient:s,amountOut:o.amountOut,amountInMaximum:c})]}}}}function el(e){const t=[];e?.customVenues&&t.push(...e.customVenues),e?.satsuma&&t.push(hr(e.satsuma)),e?.aerodrome!==!1&&t.push(_r(e?.aerodrome??$r)),t.push(Hu(e?.oneInch));const n=t.map(Bu);function o(a){return n.find(i=>i.chainIds.includes(a))}async function r(a,i,l,c){const d=n.filter(m=>m.chainIds.includes(i));if(d.length===0)throw new ze("NO_VENUE_FOR_CHAIN",`No liquidity venue configured for chain ${i}. Cannot resolve swap ${a.tokenIn} \u2192 ${a.tokenOut}.`,{chainId:i,tokenIn:a.tokenIn,tokenOut:a.tokenOut,amountIn:a.amountIn.toString()});const u=await Promise.allSettled(d.map(m=>m.resolve(a,i,l,c)));let f=null;for(const m of u)c&&m.status==="fulfilled"&&m.value&&(m.value.venue!==c.venue||m.value.calls.length!==c.calls.length||m.value.calls.some((g,h)=>g.to.toLowerCase()!==c.calls[h].to.toLowerCase()||g.data.slice(0,10)!==c.calls[h].data.slice(0,10)))||m.status==="fulfilled"&&m.value&&(!f||m.value.amountOut>f.amountOut)&&(f=m.value);if(f)return f;const y=u.find(m=>m.status==="rejected");if(y)throw y.reason;return null}async function s(a,i,l){const c=[],d=[];for(const u of a){if(!Lu(u)){c.push(u);continue}const f=await r(u,i,l);if(!f)throw new ze("NO_LIQUIDITY",`No venue returned a quote for ${u.tokenIn} \u2192 ${u.tokenOut} on chain ${i}.`,{chainId:i,tokenIn:u.tokenIn,tokenOut:u.tokenOut,amountIn:u.amountIn.toString()});c.push(...f.calls),d.push(f)}return{calls:c,resolvedSwaps:d}}return{resolveSwapIntents:s,resolveSwap:r,getVenueForChain:o,venues:t}}const Kn="0x0000000000000000000000000000000000000000",ra=[{fee:100,tickSpacing:1},{fee:500,tickSpacing:10},{fee:3e3,tickSpacing:60},{fee:1e4,tickSpacing:200}],tl=Kn,nl=.02,Yu=1800,ol={name:"Uniswap v4",quoter:"0x0d5e0f971ed27fbff6c2837bf31316121532048d",universalRouter:"0x6ff5693b99212da76ad316178a184ab56d299b43",permit2:"0x000000000022d473030f116ddee9f6b43ac78ba3",chainIds:[8453],hubCurrencies:["0x4200000000000000000000000000000000000006",Kn,"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"]},rl={name:"Uniswap v4",quoter:"0x8dc178efb8111bb0973dd9d722ebeff267c98f94",universalRouter:"0x8876789976decbfcbbbe364623c63652db8c0904",permit2:"0x000000000022d473030f116ddee9f6b43ac78ba3",routerHasHopPrice:!0,chainIds:[4663],hubCurrencies:["0x0bd7d308f8e1639fab988df18a8011f41eacad73",Kn,"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168"]},sl=Wn(["struct PoolKey { address currency0; address currency1; uint24 fee; int24 tickSpacing; address hooks; }","struct PathKey { address intermediateCurrency; uint24 fee; int24 tickSpacing; address hooks; bytes hookData; }","struct QuoteExactSingleParams { PoolKey poolKey; bool zeroForOne; uint128 exactAmount; bytes hookData; }","struct QuoteExactParams { address exactCurrency; PathKey[] path; uint128 exactAmount; }","function quoteExactInputSingle(QuoteExactSingleParams params) returns (uint256 amountOut, uint256 gasEstimate)","function quoteExactInput(QuoteExactParams params) returns (uint256 amountOut, uint256 gasEstimate)","function quoteExactOutputSingle(QuoteExactSingleParams params) returns (uint256 amountIn, uint256 gasEstimate)","function quoteExactOutput(QuoteExactParams params) returns (uint256 amountIn, uint256 gasEstimate)"]),Zu=Wn(["function approve(address token, address spender, uint160 amount, uint48 expiration)"]),Xu=Wn(["function execute(bytes commands, bytes[] inputs, uint256 deadline) payable"]),al="0x10",Ju="04",$u="06",_u="07",ep="08",tp="09",es="0c",ts="0e",np=[{name:"currency0",type:"address"},{name:"currency1",type:"address"},{name:"fee",type:"uint24"},{name:"tickSpacing",type:"int24"},{name:"hooks",type:"address"}],op=[{name:"intermediateCurrency",type:"address"},{name:"fee",type:"uint24"},{name:"tickSpacing",type:"int24"},{name:"hooks",type:"address"},{name:"hookData",type:"bytes"}],io=(e,t)=>e.toLowerCase()===t.toLowerCase();function ns(e){return be(e)?Kn:e}function rp(e,t){return e.toLowerCase()<t.toLowerCase()?[e,t]:[t,e]}function il(e,t,n,o,r){const s=[],[a,i]=rp(e,t);for(const{fee:c,tickSpacing:d}of ra)s.push({kind:"single",poolKey:{currency0:a,currency1:i,fee:c,tickSpacing:d,hooks:tl},zeroForOne:io(e,a)});const l=(c,d)=>!!r&&(io(c,Kn)&&io(d,r)||io(c,r)&&io(d,Kn));for(const c of n)if(!(io(c,e)||io(c,t))&&!(l(c,e)||l(c,t)))for(const d of ra)for(const u of ra){const f=(y,m)=>({intermediateCurrency:y,fee:m.fee,tickSpacing:m.tickSpacing,hooks:tl,hookData:"0x"});s.push({kind:"multi",path:o==="in"?[f(c,d),f(t,u)]:[f(e,d),f(c,u)]})}return s}async function ll(e,t,n,o,r,s){const a=bt(e),i=(await Promise.allSettled(n.map(async l=>{const{result:c}=l.kind==="single"?await a.simulateContract({address:t.quoter,abi:sl,functionName:s==="in"?"quoteExactInputSingle":"quoteExactOutputSingle",args:[{poolKey:l.poolKey,zeroForOne:l.zeroForOne,exactAmount:r,hookData:"0x"}]}):await a.simulateContract({address:t.quoter,abi:sl,functionName:s==="in"?"quoteExactInput":"quoteExactOutput",args:[{exactCurrency:o,path:l.path,exactAmount:r}]}),d=c[0];if(d<=0n)throw new Error("zero quote");return{candidate:l,amount:d}}))).filter(l=>l.status==="fulfilled").map(l=>l.value);return i.length===0?null:(i.sort((l,c)=>l.amount<c.amount?-1:l.amount>c.amount?1:0),s==="in"?i[i.length-1]:i[0])}function cl(e){const{candidate:t,direction:n,currencyIn:o,currencyOut:r,recipient:s,exactAmount:a,limitAmount:i,deadline:l,routerHasHopPrice:c,sweepNativeTo:d}=e;let u,f;t.kind==="single"?(u=n==="in"?`0x${$u}${es}${ts}`:`0x${ep}${es}${ts}`,f=ao([{type:"tuple",components:[{name:"poolKey",type:"tuple",components:np},{name:"zeroForOne",type:"bool"},{name:n==="in"?"amountIn":"amountOut",type:"uint128"},{name:n==="in"?"amountOutMinimum":"amountInMaximum",type:"uint128"},...c?[{name:"minHopPriceX36",type:"uint256"}]:[],{name:"hookData",type:"bytes"}]}],[{poolKey:t.poolKey,zeroForOne:t.zeroForOne,[n==="in"?"amountIn":"amountOut"]:a,[n==="in"?"amountOutMinimum":"amountInMaximum"]:i,...c?{minHopPriceX36:0n}:{},hookData:"0x"}])):(u=n==="in"?`0x${_u}${es}${ts}`:`0x${tp}${es}${ts}`,f=ao([{type:"tuple",components:[{name:n==="in"?"currencyIn":"currencyOut",type:"address"},{name:"path",type:"tuple[]",components:op},...c?[{name:"minHopPriceX36",type:"uint256[]"}]:[],{name:n==="in"?"amountIn":"amountOut",type:"uint128"},{name:n==="in"?"amountOutMinimum":"amountInMaximum",type:"uint128"}]}],[{[n==="in"?"currencyIn":"currencyOut"]:n==="in"?o:r,path:t.path,...c?{minHopPriceX36:[]}:{},[n==="in"?"amountIn":"amountOut"]:a,[n==="in"?"amountOutMinimum":"amountInMaximum"]:i}]));const y=ao([{type:"address"},{type:"uint256"}],[o,n==="in"?a:i]),m=ao([{type:"address"},{type:"address"},{type:"uint256"}],[r,s,0n]),g=ao([{type:"bytes"},{type:"bytes[]"}],[u,[f,y,m]]),h=d?`${al}${Ju}`:al,w=d?[g,ao([{type:"address"},{type:"address"},{type:"uint256"}],[Kn,d,0n])]:[g];return Tt({abi:Xu,functionName:"execute",args:[h,w,l]})}function dl(){return BigInt(Math.floor(Date.now()/1e3)+Yu)}function ul(e,t,n,o){return{to:e.permit2,value:0n,data:Tt({abi:Zu,functionName:"approve",args:[t,e.universalRouter,n,Number(o)]})}}function pl(e){const t=e.name??"Uniswap v4",n=e.v3?hr({...e.v3,chainIds:e.chainIds}):null;return{name:t,chainIds:e.chainIds,resolve:async(o,r,s)=>{const a=o.maxSlippage??nl,i=ns(o.tokenIn),l=ns(o.tokenOut),c=be(o.tokenIn),d=e.hubCurrencies??[Kn];let u=null;if(!io(i,l)&&o.amountIn>0n){const f=await ll(r,e,il(i,l,d,"in",Xs(r)),i,o.amountIn,"in").catch(()=>null);if(f){const y=Fi(f.amount,a),m=dl(),g=[];c||(g.push({to:o.tokenIn,value:0n,data:Tt({abi:ot,functionName:"approve",args:[e.permit2,o.amountIn]})}),g.push(ul(e,o.tokenIn,o.amountIn,m))),g.push({to:e.universalRouter,value:c?o.amountIn:0n,data:cl({candidate:f.candidate,direction:"in",currencyIn:i,currencyOut:l,recipient:s,exactAmount:o.amountIn,limitAmount:y,deadline:m,routerHasHopPrice:e.routerHasHopPrice})}),u={venue:t,amountOut:f.amount,amountOutMinimum:y,calls:g}}}return!u&&n?n.resolve(o,r,s):u}}}function fl(e){const t=e.name??"Uniswap v4";return{name:t,chainIds:e.chainIds,resolve:async(n,o,r)=>{const s=be(n.tokenIn),a=ns(n.tokenIn),i=ns(n.tokenOut);if(io(a,i)||n.amountOut<=0n)return null;const l=n.maxSlippage??nl,c=e.hubCurrencies??[Kn],d=await ll(o,e,il(a,i,c,"out",Xs(o)),i,n.amountOut,"out").catch(()=>null);if(!d)return null;const u=BigInt(Math.round(l*1e4)),f=d.amount+d.amount*u/10000n,y=dl();return{venue:t,amountIn:d.amount,amountInMax:f,amountOut:n.amountOut,calls:[...s?[]:[ul(e,n.tokenIn,f,y)],{to:e.universalRouter,value:s?f:0n,data:cl({candidate:d.candidate,direction:"out",currencyIn:a,currencyOut:i,recipient:r,exactAmount:n.amountOut,limitAmount:f,deadline:y,routerHasHopPrice:e.routerHasHopPrice,sweepNativeTo:s?r:void 0})}]}}}}const sa=[{...ta,protocol:"uniswap-v3",chainId:4114},{...ta,protocol:"uniswap-v3",chainId:5115},{...ji,protocol:"uniswap-v3",chainId:8453},{...Gi,protocol:"uniswap-v3",chainId:1},{...Ki,protocol:"uniswap-v3",chainId:42161},{...Vu,protocol:"uniswap-v3",chainId:137},{...Qu,protocol:"uniswap-v3",chainId:56},{...ju,protocol:"uniswap-v3",chainId:143},{...Yi,protocol:"uniswap-v3",chainId:4663},{...Zi,protocol:"uniswap-v3",chainId:4663},{...ol,protocol:"uniswap-v4",chainId:8453},{...rl,protocol:"uniswap-v4",chainId:4663},{...$r,protocol:"aerodrome-slipstream",chainId:8453}];function Eo(e){const t=e?.includeDefaults===!1?e.venues??[]:[...sa,...e?.venues??[]],n=[],o=[];for(const r of t){const s=[r.chainId];switch(r.protocol){case"uniswap-v3":{const a={...r,chainIds:s};n.push(hr(a)),o.push(oa(a));break}case"uniswap-v4":{const a={...r,chainIds:s};n.push(pl(a)),o.push(fl(a));break}case"aerodrome-slipstream":{const a={...r,chainIds:s};n.push(_r(a)),o.push(_i(a));break}default:{const a=r;throw new ze("INVALID_PARAMS",`Unsupported liquidity venue protocol: ${a.protocol}`,{protocol:a.protocol})}}}return{input:n,output:o}}const aa=new Set(["WBTC","CBTC"]),ml=new Set(["btc","wbtc","wcbtc","cbtc"]);function hl(e,t){return!e||!t?!1:e===t?!0:aa.has(e)&&aa.has(t)}function Yn(e){const[t,n,o]=e.split(":");if(t!=="evm"||!n||!o)return null;const r=Number(n);if(!Number.isFinite(r))return null;const s=o.startsWith("0x")?o.toLowerCase():`0x${o.toLowerCase()}`;return{chainId:r,address:s}}function os(e){return(e??"").trim().replace(/^test\s+/i,"").replace(/^spice/i,"").toLowerCase().replace(/[^a-z0-9]/g,"")}function sp(e){return new Set([e.receiptTokenName,e.displaySymbol,e.symbol,e.displayName,e.name].map(os).filter(Boolean))}function ap(e,t){const n=sp(e),o=[t.symbol,t.name,t.equivalenceGroup].map(os);if(o.some(a=>a&&n.has(a)))return!0;const r=[...n].some(a=>ml.has(a)),s=o.some(a=>ml.has(a))||aa.has(t.equivalenceGroup??"");return r&&s}function gl(e,t,n){const o=new Set(t.map(os).filter(Boolean)),r=s=>{if(n&&oe(s.address,n))return 0;const a=[s.symbol,s.name,s.equivalenceGroup].map(os).findIndex(i=>i&&o.has(i));return a===-1?4:a+1};return[...e].sort((s,a)=>{const i=r(s)-r(a);return i!==0?i:s.address.toLowerCase().localeCompare(a.address.toLowerCase())})}function zo(e,t){const n=e.chainTokens?Object.keys(e.chainTokens):[],o=[];for(const r of n){const s=Yn(r);if(!s||s.chainId!==t)continue;const a=s.address,i=be(a)?nt(t)?.nativeCurrency:void 0,l=Ut(a,t)??(i?{...i}:void 0);l&&(!ia(e,a,t)&&!(e.isUniversal&&ap(e,l))||o.some(c=>oe(c,a))||o.push(a))}return gl(o.map(r=>{const s=Ut(r,t);return{address:r,symbol:s?.symbol,name:s?.name,equivalenceGroup:s?.equivalenceGroup}}),[e.receiptTokenName,e.displaySymbol,e.symbol,e.displayName,e.name],e.chainId===t&&!e.isUniversal?e.address:void 0).map(r=>r.address)}function ia(e,t,n){return e.chainId===n&&oe(e.address,t)?!0:gr(e.address,e.chainId,t,n)}async function ip(e,t){const n=bt(e),o=ro(e);return be(t)?n.getBalance({address:o}):await n.readContract({address:t,abi:ot,functionName:"balanceOf",args:[o]})}function la(e,t,n){const o=ur(n),r=o.find(a=>oe(a.address,e));if(r&&(t===n||!be(e)))return r;const s=Ut(e,t);if(s)return gl(o.filter(a=>hl(a.equivalenceGroup,s.equivalenceGroup)),[s.symbol,s.name,s.equivalenceGroup])[0]}function rs(e){return e.equivalenceGroup==="USDC"&&e.symbol.toUpperCase()!=="USDT"}function yl(e){const t=pr(e);if(!t||t===Dt)return;const n=ur(e).filter(rs);return n.find(o=>o.symbol.toUpperCase()==="USDC")??n[0]}function ca(e,t){if(e.chainId===t)return null;const n=pr(e.chainId),o=pr(t);if(!n||n===Dt||!o||o===Dt)return null;const r=!e.isNative&&!be(e.address)?Ut(e.address,e.chainId):void 0,s=r&&rs(r)?la(e.address,e.chainId,t):void 0,a=s?r:yl(e.chainId),i=s??yl(t);if(!a||!i)return null;const l=c=>({address:c.address,symbol:c.symbol,decimals:c.decimals,chainId:c.chainId});return{source:l(a),destination:l(i)}}function lp(e,t){return!!ca(e,t)}function Pn(e,t){if(e.chainId===t)return e.address;const n=la(e.address,e.chainId,t);return n?n.address:null}async function lo(e,t,n,o){const r=Ut(t,n);return r?r.decimals:e?.chainId===n&&oe(e.address,t)&&!e.isUniversal?e.decimals:o?.chainId===n&&oe(o.address,t)?o.decimals:Vr(n,t)}async function wl(e,t,n={}){const o=Pn(e,t),r=zo(e,t);if(r.length===0)return o;if(r.length===1)return r[0];const s=n.requiredAmount??0n,a=i=>{const l=r.map(c=>({candidate:c,balance:i.get(be(c)?"native":c.toLowerCase())??0n})).filter(c=>c.balance>0n).sort((c,d)=>c.balance===d.balance?0:c.balance>d.balance?-1:1);return l.length===0?null:((s>0n?l.find(c=>c.balance>=s):l[0])??l[0]).candidate};try{const i=await Promise.all(r.map(async d=>({key:be(d)?"native":d.toLowerCase(),value:await ip(t,d)}))),l=new Map(i.map(({key:d,value:u})=>[d,u])),c=a(l);if(c)return c}catch{}return o}function gr(e,t,n,o){const r=Ut(e,t),s=Ut(n,o);return r&&s?hl(r.equivalenceGroup,s.equivalenceGroup):cu(e,n)}function ss(e,t){return gr(e.address,e.chainId,t.address,t.chainId)}const xl=.01;function bl(e,t=!1){const n=Number.isFinite(e.balanceUsd)&&e.balanceUsd>0;return e.isDiscovered?n&&e.balanceUsd>=xl:!t||!n||e.balanceUsd>=xl}function as(e,t=!1){return!!e&&e._source==="wallet"&&(e.location==="external"||e._fundingWallet==="external"||!e.location&&!e._fundingWallet&&t)}function Ce(e){return e.positionId??`${e.owner?.toLowerCase()??""}:${e.location??e._source??""}:${e.chainId}:${e.receiptTokenId??dt(e.address).toLowerCase()}`}function vl(e,t){if(!t?.length||e.symbol!==void 0&&Qr({...e,symbol:e.symbol},t))return!0;const n=o=>t.some(r=>oe(dt(r),dt(o)));return n(e.address)||Object.keys(e.chainTokens??{}).some(o=>{const r=Yn(o);return r?n(r.address):!1})}function go(e,t,n,o,r,s){const a=(g,h=!1)=>({eligible:!1,reason:g,policyExcluded:h}),i=e._source==="wallet"||e.location==="external"||e.location==="embedded",l=t==="spend-source"&&i&&!!o&&e.chainId===o.chainId&&oe(dt(e.address),dt(o.address));if(n.isWhitelistGateActive||!l&&!Qr(e,n.allowedTokens))return a("Asset excluded by client policy",!0);if(t!=="withdraw-destination"&&!l&&!bl(e))return a("Asset is unpriced or below the minimum value",!0);if(t==="holding")return{eligible:!0,reason:null};if(e.balanceError)return a(e.balanceError);if(!l&&!vl(e,r))return a("Asset excluded by action policy",!0);const c=new Set(o?[o.chainId]:[]);e._source!=="spice"&&e.location!=="rollup"&&c.add(e.chainId);for(const g of c)if(!xi(g,n.rpcOverrides)?.trim())return a(`Configure SpiceFlowProvider rpcOverrides[${g}] before using this asset.`);if(s?.requiresEscrow){const g=Ut(e.address,e.chainId);if(!g||!rs(g))return a("This asset has no supported escrow mapping")}if(!o)return{eligible:!0,reason:null};const d=n.liquidityVenues?.includeDefaults===!1?n.liquidityVenues.venues??[]:[...sa,...n.liquidityVenues?.venues??[]],u=g=>d.some(h=>h.chainId===g),f=i&&e.chainId!==o.chainId,y=f?ca(e,o.chainId):null;if(f&&!y)return a("No supported source route");if(y&&!oe(dt(e.address),dt(y.source.address))&&!u(e.chainId))return a("No conversion venue configured on the source chain");const m=y?.destination.address??Pn(e,o.chainId);return t==="withdraw-destination"?(e.chainTokens||e.receiptTokenId?zo(e,o.chainId):m?[m]:[]).some(g=>oe(dt(g),dt(o.address)))?{eligible:!0,reason:null}:a("No supported withdrawal mapping"):m&&oe(dt(m),dt(o.address))?{eligible:!0,reason:null}:!m&&!lp(e,o.chainId)?a("No supported destination route"):u(o.chainId)?{eligible:!0,reason:null}:a("No conversion venue configured on the destination chain")}function is(){const e=Kt(Ht),[t]=P(jd);return e?.inventory??t}function da(e,t,n,o,r){const s=is(),a=r??s,i=me(()=>a.entry(e),[a,e]),[,l]=P(0);ue(()=>{if(n)return i.subscribe(()=>l(d=>d+1),t,o)},[i,n,t,o]);const c=te(()=>i.refresh(),[i]);return{...n?i.snapshot():Gd,refresh:c}}var Cl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAA6lBMVEXc3NzX/v/1hRvZ2dnd3dzb29va7fpMaXHa1tPc3N35/v/c3Nzc3NzCrp/c3Nza2tp1PRbLsJzlr33uhSj0kTHcnWnUva7jdhuNX0B6Qhrsk0LOxMCFVDJ+RyGhfGTkeiGYVSHjdx3lij7khDPEsaPfoW/jgjLQuKXmgzB2PRb2hRvldhvjdRv4hhvpeRtwORb/ihryghvabhnsehrUaRjLXxXtfRt7PxXwexricRbRYhURFBeSTBe0XBrEZxmDRxiiVRrlgCbfzMAvLCmrWBgbMEh9UjBbOBe2pJi9byekk4nkgDHkgDJLNB7jlKArAAAAKXRSTlMzJv0TNSYsADUxKBwK/QUZ/URTx650/vqJ5YpMosxj3ezwkqa6/q3KrihQ98kAAAAJcEhZcwAACxMAAAsTAQCanBgAAATxSURBVHjapVeJcuI4EJXBdiRuw4JzDAFyzeIT22BsNgTIJNnM7Pz/90xLsmV5ChJm6SqqZOR+7teXWujsgLSqdU0jBCFCNK1ebR16D+39t1HXiKqqGDHBsCRavXEsQKutIVWln0aZ0BX8o7VbRwC06gS+LHQLIWAJqbc+A6iC+h7t3BCVVD8EaGgqOqSemaFqjcMA8PkP1RnEb0bIAPXD1peNqO8H0NQj1LkR2j6Ao/XLCOh/6JcQkOD/B/oUoV4GqGb6+HNdnCFUZYBG9nmsE/whBsZE5y9g0pAAcgcQQ1V0fAgDNnRFNQiW3cAA2lwfI3wxvunqyl4z4OOK3r0ZX2CUIbRzgFZOoHY9nW7NXt9QdFTGgCddMfq9cDudXteyLdLKAPII4NqXZcffzIPJQx8zDCFgev9hksw3fmf5pYalSCDJAGAw7Uz9zkuU2CNKRQiYPrIT76Xjwws5B/BjiwG0hQHAgIr/GHpeYvb+EtIzI88LH32+fy1MaDMAKOGCAUdYPnmmE82ERI7pPS25fsEB0UCgs4ZwVO08AwB5sT0zrmQSm7b94mff7yzPa8LBDQAQSSwo5DRsKxO7MF+mwNyIBAPwjHEhIQCNgOsHwnwmF4aeWwAcUEMO97DgABAvkUv13WgrqXeWQ7moGqiqFtkivJjTCADBDWTzZR9SE6pIquOSF6msGYdgPS0BSD4EJ6CikUB+DKcd2QkRB4hkF3SmQyyqHioKaViicF4AQEp7DqfgRJDCSwFxLlPQ5GMAAHJ9n4bRyQEcGkZ/HwColwBYHH3fXz6uHc+xnZgCxLDwnPXj0mcgUhRpOZSblTEE9c32ybMi27ELAHiILO9puwGIoXG48YEJ43UYzGYumG/LADbQcGezIFyPjRr+7aCREfTezLUqFtMB4QB87cSw4c56uqyPSz4A/S6UDuikqzkTmwLYfL1K4aFiVbolBCKHEWHlclahyRvMF4vFarWgOm5KV4vFnIbEqswuFUmD5oF0olAGFZ7+88VqvV05FMBZbderxZwXRqXEgSaSfCTp3cDiAIETvr2+riP64K1fX99ClhMA4AIH+YAqFVPGgGnFu+9v44Quk/Hb913suXyjzAGKSS7nnAEtgBg6WeAxLIjrLM56A+NQKueioVAGruW67OdWrCCwYqoS01XgZmLJHGhDkVqa3oXeSyUESaktvBrBJ5WU/sd3IxFI3tKKpkrwCDIQcjCkUfPAnIAJ+NSjcQ1tuuuNMCk11TORCVh5SEyWdXP2dmzxpk4TEzDnbMtM/lakligfLADQj3gOOysASNPd5l+QzS5NAWCVbUV9RTBol442cIIxsVnlwPthurtv/sOkeb9LQ2oS25qIcs6PNtmNvch0HBOKN/15P3h+5wDvz4P7/1IocNhzop7swvLxTjMpMm0viSa9m6/Pg+cf35j8gOXXm94kSjzbjIo8Esd7cbxCIBNzdNs3dAXdDQbN9ybIe3MwuEOKbvRvR2YigigNGNKMh28vu0ihswGp9ZuDJpNBs0+HFjjuUffyFpcnvfKQhbgym06wcnXHAe6umNWYjSlKkcXlMa8YpIrEIldMCMHyrLNvzDs0aBImxwyap4+6pw/bp4/71A/opAvH6Vee0y9dn1z70OfXvuziudcMSKdjLp786quecPWVL99Zfqt/ePkuX/8Jv/43Dl3/fwH9bPJ09nq7MQAAAABJRU5ErkJggg==",cp="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAQlBMVEVMaXGGl/+Elf+HmP+Hmf+Hl/+Gl/+Flv+Glv+Gl/+Gl/+Gl/////+On/+Akv/4+f/v8f/i5v+9x//S2P+tuP+erP+W3PvUAAAAC3RSTlMArBlx7Isy/vvOXbb4wDYAAAAJcEhZcwAACxMAAAsTAQCanBgAAALuSURBVHjarVfbtqsgDOxu0UBpkOv//+pJRC0i2HZ58uTeqzOEyYXkduvY/Tn8KSEBpFB/w3O8/WTjoCSS6dn4S6rha477QxFGS0nHM56ckJL/ox73b+CDQAQJujKiQxTDR4qH4LN109gP8Ti/uyI46K4BUagTLZ4Cz+CZAsWzhx/oeP3RyImhjf/7ePzmxF8Hr7+zNsP3eL7GkWH4Bc8MlQ7P3/DMsIvFKHRLPzBsTWVBizIfVNMBg9H7mLQxTRdUkb9tfJxebNZjywuJW1bf2xcw4WXtzDF5bVqXuJ9HwETHNnPYeHRii0THgcwQyBxTBDQ9Fx7dEBr0TOCDYyeS6aigsFsCQIFgBh9YiVgxQA7EqM9KiCiS95nh5WsGPZ4k8ZZFRqfoY4shy9i8AaExxRgTMgcApuSODPMdRtn02wc7Z9HkPMsPa1ZVOsiRygga4udfZ5vTKKx/7GIBVFJHCUy0r705DNu3LQ9kEQ6NxMTXwWzhUTD7xlJr2MLvrZCBVazy2OD0iaC4BGh1k4cSLOSbbIuujKW4wT76aYefrGswuBJSEoBeUnaFk7nQcKEIJZRXMPsfM95O3p3KKAoRa/cJTh0pHKMybSqyiO8wMsG0wzODi7UK9u0Ah7FIJAj1+UyQcl4Gqi2uax+L/siJVKQyi+j251sbMoHTZrUqlctiojDGRX27WpivYNtdi4upKme0c/gXBmdzY7ZoOi/cWDeU7MJy+oKn3hzbT9/cFKt6pmKe9udnCoTeG103VW7EjrGZJMOD863GNzfVQ0EDP6aJUH61wBRHGZa23npYDDpuh8EnpPBRS6UUQOg9r8enzaDdmhmsPkH/da3bokkr/i0dwMmYU7lg0pRrwiVzNrW+n/dKhVzVVIbGnE9Jj86IA8glk87h+xGnGrJyzXwYNvdD1uUx7/qgeX3UvT5sXx/3ry8c11ee60vX9bXvvXjWfsC3i+d79YV19+WPH1bf/7B8Lxy8/isBINTp+v8Ph4CTcAywkiYAAAAASUVORK5CYII=",dp="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAPFBMVEVMaXGZhueZh+eYhuWXheWYh+eYhuaXheCYhuaah+j//fmhjvOSf+Sdi+q8sOzNxO/m4fT08fapmuja0/Jb/wGxAAAACnRSTlMArEz/IYtsA87sGIEBYwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAmJJREFUeNqtV4uSgyAMRIECGhTk///1otTKG3s2Mzdz03aXbEJIQkhuYv9jIx+komhKDnxk4v1F1wT+SoxcUj3PWu8Ex39U8lH4bzt4QthL6tlDA8OP5Iv1vMADGFc5+uRQnDWdEES81EwbNquXqDuBx8va6ZcXktUYBOkc/3GixsBvwA8neFGGGO7hdyeGAsMXeM/wBJ8ziLv6LwYeisD4f4lHhiAXmH9FvzYV3AchOw6At9gFKW4KANDbsttGoSyCKd1Ab4uxkzezhBQaRfQygHB3oj2FhjwT9QgifErM6jiOrQgAXe2UmcuiIKSuHG+mki2XCH0kYqzgF1vETyYszLFaxLBMNdsgDGNFAazRoUcwrDMlDYz28RS0newGcCRlDa8TK4YgxuORGj9x8NYVEsxjKQSp/pNAw5YRcJI/JP5nYeqxjAxeIfCeRQQDyWOos/y5xR2V4NIgYhRJVkjgpralBPcvQH4PsBxIX0DjJqKRdgYLtsYPUyqh60CsACXEQew7ECvAICZp7DqwQEIQXaR+CkzaoeKr3FewQdqg4mIy36VgLyZWz4G96N5vs8sKj0UPSlJGy4fAbWX88SgGQYgJVjDXi7JaaxYo9Oj4UQ0lrHCGdN25ceiEfNoZSfIomjhcKN26DarT0q4gaiyfe2C9u9hWNUBvRghbG+yd1AZNFFrjmu+ucXMF2j60OObE7f0m+mrv/5qQkimpO+IU8fKXQ9bDMe/5oPl81P3BsP183EeGu3GoLBw/WHnuLF20sXQ9X/ueL57PV99w+Z7P5Vvj8j3fXr7j9X/f/5Vsrv9/K3NM7mGXOq0AAAAASUVORK5CYII=",yr="data:image/svg+xml,%3csvg width='8' height='11' viewBox='57 6 8 11' fill='none' xmlns='http://www.w3.org/2000/svg'%3e %3cpath d='M62.7081 13.27C62.742 13.27 62.7642 13.3057 62.7491 13.3362V13.336L61.1229 16.6083C61.0892 16.6761 60.9926 16.6759 60.959 16.6083L59.3382 13.336C59.3232 13.3057 59.3453 13.27 59.3792 13.27H62.7081Z' fill='%23EA4B4B'/%3e %3cpath d='M61.0026 9.71913C61.0194 9.68524 61.0678 9.68524 61.0845 9.71913L62.747 13.0897C62.762 13.12 62.7399 13.1557 62.706 13.1557H59.3763C59.3424 13.1557 59.3203 13.12 59.3353 13.0897L61.0026 9.71913Z' fill='%23EA4B4B'/%3e %3cpath d='M60.8426 9.63827C60.8766 9.63827 60.8987 9.6741 60.8835 9.70444L59.2164 13.0594C59.1995 13.0932 59.1513 13.0932 59.1345 13.0594L57.5001 9.77047C57.47 9.70962 57.5142 9.63827 57.5821 9.63827H60.8426Z' fill='%23EA4B4B'/%3e %3cpath d='M64.5036 9.63617C64.5715 9.63618 64.6157 9.70753 64.5855 9.76838H64.5854L62.9512 13.0573C62.9344 13.0911 62.8862 13.0912 62.8692 13.0573L61.2021 9.70235C61.187 9.672 61.2091 9.63617 61.2431 9.63617H64.5036Z' fill='%23EA4B4B'/%3e %3cpath d='M62.8284 6.18281C62.862 6.11518 62.9586 6.11518 62.9922 6.18281L64.5855 9.38969C64.6157 9.45054 64.5715 9.52189 64.5036 9.52189H61.2431C61.2091 9.52189 61.187 9.48605 61.2021 9.45571L62.8283 6.18265L62.8284 6.18281Z' fill='%23EA4B4B'/%3e %3cpath d='M62.3131 6.13196C62.381 6.13196 62.4252 6.20331 62.3951 6.26416C62.154 6.74935 61.9128 7.23455 61.6718 7.71975H61.6716C61.4225 8.22125 61.1733 8.72259 60.9242 9.22409C60.9074 9.25799 60.859 9.25799 60.8422 9.22409L60.6305 8.79587C60.6275 8.78957 60.6259 8.78263 60.6259 8.77553V6.22349C60.6259 6.17297 60.6668 6.13196 60.7173 6.13196H62.3131Z' fill='%23EA4B4B'/%3e%3c/svg%3e";const wr=Bi(1)?.logo??"",up=Oi.find(e=>e.symbol==="USDC")?.logo??"",yo=Object.fromEntries([...du(),...uu()].map(e=>[e.id,e.logo])),xr={metamask:Cl,metaMask:Cl,rabby:cp,phantom:dp},ua=Object.fromEntries(Oi.map(e=>[e.symbol.toUpperCase(),e.logo])),pp={usdc:[8453,1,42161,5115,4114],usdt:[1],btc:[4114,42161,1,5115],wbtc:[1],weth:[8453,1],eth:[8453,1,42161,4663,84532,46630],ctusd:[5115,4114],wcbtc:[5115,4114]},fp={btc:["wcbtc","cbtc","wbtc"]};function ls(e){return e.replace(/^test\s*/i,"").replace(/^spice/i,"").trim()}function co(e){return ls(e).toLowerCase()}function kl(e){return co(e??"").replace(/[^a-z0-9]/g,"")}function pa(e){const t=co(e);return[t,...fp[t]??[]].filter(Boolean)}function mp(e){try{return BigInt(e.balanceAvailable||"0")}catch{return 0n}}function Il(e){return Array.isArray(e.chainTokens)?e.chainTokens:Object.keys(e.chainTokens??{})}function Sl(e,t){const n=nt(e),o=t.toLowerCase();return o===Dt.toLowerCase()?n?.nativeCurrency.decimals??18:n?.supportedTokens?.find(r=>r.address.toLowerCase()===o)?.decimals??18}function hp(e,t,n,o=[]){const r=Sl(t,n),s=e.filter(i=>Al(i,t,n,o));if(s.length===0)return null;const a=s.reduce((i,l)=>Math.min(i,l.decimals??r),r);return{chainDecimals:r,receiptDecimals:a}}function Al(e,t,n,o){if(Il(e).some(s=>{const a=Yn(s);return a&&gr(a.address,a.chainId,n,t)}))return!0;const r=new Set(o.map(kl).filter(Boolean));return r.size===0?!1:r.has(kl(e.tokenName||e.receiptToken))}function fa(e,t,n,o=[]){const r=Sl(t,n);return e.reduce((s,a)=>Al(a,t,n,o)?s+Vn(mp(a),a.decimals??r,r):s,0n)}function El(e,t){const n=new Set([...pa(t),...pa(ls(t))]);return[...e].sort((o,r)=>{const s=co(o.symbol),a=co(r.symbol),i=co(o.name),l=co(r.name),c=n.has(s)?0:n.has(i)?1:2,d=n.has(a)?0:n.has(l)?1:2;return c!==d?c-d:o.address.toLowerCase().localeCompare(r.address.toLowerCase())})[0]}function gp(e){const t=e&&e.length>0?e:Object.keys(jr).map(Number).filter(Number.isFinite),n=new Map;for(const o of t){const r=nt(o);if(!r)continue;const s=`${o}:${Dt.toLowerCase()}`;n.has(s)||n.set(s,{address:Dt,chainId:o,symbol:r.nativeCurrency.symbol,name:r.nativeCurrency.name,decimals:r.nativeCurrency.decimals,isNative:!0,logoURI:ua[r.nativeCurrency.symbol.toUpperCase()]??r.logo});for(const a of r.supportedTokens??[]){const i=a.address.toLowerCase(),l=`${o}:${i}`;n.has(l)||n.set(l,{address:i,chainId:o,symbol:a.symbol,name:a.name,decimals:a.decimals,isNative:be(i),logoURI:a.logo})}}return n}function yp(e,t){const n=gp(t),o=ls(e.tokenName),r=co(e.tokenName),s=pa(e.tokenName),a=Array.isArray(e.chainTokens)?e.chainTokens.map(m=>[m,void 0]):Object.entries(e.chainTokens??{}),i=a.map(([m])=>Yn(m)).filter(m=>m!==null),l=new Map;for(const[m,g]of a){const h=Yn(m);if(!h||!Number.isSafeInteger(h.chainId)||h.chainId<0||!/^evm:[0-9]+:(?:0x)?[0-9a-fA-F]{40}$/.test(m)){if(!Array.isArray(e.chainTokens))throw new Error("Invalid chain token metadata identity");continue}if(g!==void 0&&(!g||typeof g!="object"||Array.isArray(g)||g.name!==void 0&&typeof g.name!="string"||g.decimals!==void 0&&(!Number.isInteger(g.decimals)||g.decimals<0||g.decimals>255)))throw new Error("Invalid chain token metadata");const w=`${h.chainId}:${h.address.toLowerCase()}`;if(l.has(w)){const x=l.get(w);if(x?.name!==g?.name||x?.decimals!==g?.decimals)throw new Error("Conflicting chain token metadata")}l.set(w,g)}const c=(m,g)=>{const h=l.get(`${g.chainId}:${g.address.toLowerCase()}`);return{...m,name:typeof h?.name=="string"&&h.name.length>0?h.name:m.name,decimals:typeof h?.decimals=="number"?h.decimals:m.decimals}},d=i.map(m=>{const g=n.get(`${m.chainId}:${m.address.toLowerCase()}`);return g?c(g,m):void 0}).filter(m=>m!==void 0),u=pp[r]??[];if(u.length>0)for(const m of u){const g=d.filter(h=>h.chainId===m);if(g.length>0)return El(g,e.tokenName)}if(d.length>0)return El(d,e.tokenName);const f=Array.from(n.values()).filter(m=>s.includes(co(m.symbol))||s.includes(co(m.name)));if(u.length>0)for(const m of u){const g=f.find(h=>h.chainId===m);if(g)return g}if(f.length>0)return f[0];const y=i[0];if(y){const m=l.get(`${y.chainId}:${y.address.toLowerCase()}`);return{address:y.address,chainId:y.chainId,symbol:o||e.tokenName,name:typeof m?.name=="string"&&m.name.length>0?m.name:o||e.tokenName,decimals:typeof m?.decimals=="number"?m.decimals:e.decimals??18,isNative:be(y.address),logoURI:void 0}}}function wp(e,t){let n;try{n=BigInt(e.balanceAvailable||"0")}catch{return null}if(n<=0n)return null;if(t?.length){const m=Il(e).map(Yn).filter(g=>g!==null);if(m.length>0&&!m.some(g=>t.includes(g.chainId)))return null}let o;try{o=yp(e,t)}catch{return null}const r=o?.decimals??e.decimals??18,s=e.decimals??r,a=Vn(n,s,r),i=o?.address??Dt,l=o?.chainId??0,c=ls(e.tokenName),d=o?.symbol??c,u=o?.name??c,f=parseFloat(Ee(a,r)),y=typeof e.balanceUsd=="number"?e.balanceUsd:typeof e.balanceUsd=="string"&&Number(e.balanceUsd)||0;return{address:i,symbol:d,name:u,decimals:r,chainId:l,balance:a,balanceFormatted:f,balanceUsd:y,isNative:o?.isNative??be(i),logoURI:o?.logoURI,displaySymbol:c||d,displayName:c||u,displayChainName:"Spicenet",receiptTokenId:e.receiptToken,receiptTokenName:e.tokenName||u,receiptTokenDecimals:s,chainTokens:e.chainTokens&&!Array.isArray(e.chainTokens)?e.chainTokens:void 0,isUniversal:!0}}const ma=6e4,xp=3e5,Fl="https://api.g.alchemy.com/prices/v1",qo=new Map;function ha(e,t){try{const n=t??bt(e).transport.url;if(typeof n!="string")return null;const{hostname:o,pathname:r}=new URL(n);if(!o.endsWith(".g.alchemy.com"))return null;const s=r.split("/").filter(Boolean).pop();return s?{network:o.slice(0,-14),key:s}:null}catch{return null}}const br=(e,t)=>`${e.network}:${e.key}:${t.toLowerCase()}`;function vr(e,t){const n=qo.get(br(e,t));if(!n?.price||n.updatedAt===void 0)return;const o=Date.now()-n.updatedAt;if(!(o>=xp))return{price:n.price,stale:o>=ma}}function Tl(e){const t=Number(e.prices?.find(n=>n.currency==="usd")?.value);return Number.isFinite(t)&&t>0?t:0}async function Bl(e,t,n){const o=[],r=new Set,s=Date.now();for(const a of new Set(t.map(i=>i.toLowerCase()))){const i=qo.get(br(e,a));i?.pending?r.add(i.pending):(!i||s-i.attemptedAt>=ma&&(i.updatedAt===void 0||s-i.updatedAt>=ma))&&o.push(a)}for(let a=0;a<o.length;a+=25){const i=o.slice(a,a+25),l=Promise.resolve().then(async()=>{try{const c=await n(i);for(const d of i){const u=c.get(d);if(!u)continue;const f=qo.get(br(e,d));f.price=u,f.updatedAt=Date.now()}}catch{}finally{for(const c of i)qo.get(br(e,c)).pending=void 0}});for(const c of i){const d=br(e,c);qo.set(d,{...qo.get(d),attemptedAt:s,pending:l})}r.add(l)}await Promise.all(r)}async function ga(e,t){return await Bl(e,t,async n=>{const o=await fetch(`${Fl}/${e.key}/tokens/by-address`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({addresses:n.map(a=>({network:e.network,address:a}))}),signal:AbortSignal.timeout(1e4)});if(!o.ok)throw new Error("Provider price request failed");const r=await o.json(),s=new Map;for(const a of r?.data??[]){if(a.network&&a.network!==e.network)continue;const i=String(a.address).toLowerCase();n.includes(i)&&s.set(i,Tl(a))}return s}),new Map(t.map(n=>[n.toLowerCase(),vr(e,n)?.price??0]))}async function ya(e,t){const n=`native:${t}`;return await Bl(e,[n],async()=>{const o=await fetch(`${Fl}/${e.key}/tokens/by-symbol?symbols=${encodeURIComponent(t)}`,{signal:AbortSignal.timeout(1e4)});if(!o.ok)throw new Error("Provider native price request failed");const r=(await o.json())?.data?.find(s=>s.symbol?.toUpperCase()===t.toUpperCase());return new Map([[n.toLowerCase(),r?Tl(r):0]])}),vr(e,n)?.price??0}async function bp(e,t){const n=t.supportedChains,o=e.map(r=>{if(Number.isFinite(r.balanceUsd)&&r.balanceUsd>0)return[];const s=Object.keys(r.chainTokens??{}).map(Yn).filter(a=>!!a&&vn(a.address)&&!!n?.includes(a.chainId));return s.sort((a,i)=>{const l=c=>c===t.nativeChainId?-1:n.indexOf(c);return l(a.chainId)-l(i.chainId)||+!oe(a.address,r.address)-+!oe(i.address,r.address)}),s.flatMap(a=>{const i=t.rpcOverrides?.[a.chainId];if(!i)return[];const l=ha(a.chainId,i);if(!l)return[];const c=be(a.address)?nt(a.chainId)?.nativeCurrency.symbol:void 0,d=c?`native:${c}`:a.address;return[{rpc:l,token:d,address:a.address,nativeSymbol:c}]})});return(typeof document>"u"||!document.hidden)&&await Promise.all(o.map(async r=>{for(const s of r)if(s.nativeSymbol?await ya(s.rpc,s.nativeSymbol).catch(()=>0):(await ga(s.rpc,[s.address]).catch(()=>new Map)).get(s.address.toLowerCase()))break})),e.map((r,s)=>{if(Number.isFinite(r.balanceUsd)&&r.balanceUsd>0)return r;const a=o[s].map(i=>vr(i.rpc,i.token)).find(Boolean);return{...r,balanceUsd:a?r.balanceFormatted*a.price:0,priceStatus:a?a.stale?"stale":"fresh":"unavailable"}})}function vp(e,t,n){const o=Kt(Ht),[r,s]=P(()=>typeof document>"u"||!document.hidden);ue(()=>{const d=()=>s(!document.hidden);return document.addEventListener("visibilitychange",d),()=>document.removeEventListener("visibilitychange",d)},[]);const a={supportedChains:n??o?.supportedChainIds,nativeChainId:o?.nativeChainId,rpcOverrides:o?.rpcOverrides},i=JSON.stringify([e,a],(d,u)=>typeof u=="bigint"?u.toString():u),l=te(()=>bp(e,a),[i]),c=da(`prices:${i}`,l,t&&r&&e.length>0,6e4);return c.updatedAt?c.assets:e}function Cp(e){const t=e.chainTokens??e.chainTokenConfig;if(Array.isArray(t))return t.filter(n=>typeof n=="string");if(t&&typeof t=="object")return t}const Ol=({address:e,supportedChains:t,enabled:n=!0,refetchInterval:o,priceEnabled:r=!1})=>{const s=Kt(Ht),a=s?.apiUrl||Yd,i=is(),l=s?.supportedChainIds??t,c=JSON.stringify([...l??[]].sort((k,S)=>k-S)),d=e?.toLowerCase(),u=te(async()=>{const k=await Kd(`${a}/wallets/${d}/balance`,{cache:"no-store"});if(!k.ok)throw new Error(`Failed to fetch balance: ${k.status}`);const S=await k.json();if(!Array.isArray(S.balances))throw new Error("Invalid balance response");return S.balances.map(F=>{const T=wp({receiptToken:typeof F.receiptToken=="string"?F.receiptToken:void 0,tokenName:String(F.tokenName??""),balanceAvailable:String(F.balanceAvailable??"0"),chainTokens:Cp(F),decimals:typeof F.decimals=="number"?F.decimals:void 0,balanceUsd:typeof F.balanceUsd=="number"||typeof F.balanceUsd=="string"?F.balanceUsd:null},l);return T?{...T,owner:d,location:"rollup",_source:"spice",positionId:`${d}:rollup:${T.receiptTokenId??T.address}`}:null}).filter(F=>F!==null)},[d,a,c,s?.nativeChainId,s?.rpcOverrides]),{assets:f,loading:y,refreshing:m,error:g,updatedAt:h}=da(`rollup:${d}:${a}:${c}`,u,n&&!!d,o??0,i),w=JSON.stringify(t??[]),x=me(()=>g?f.map(k=>({...k,balanceError:g,balanceStatus:"stale"})):f,[f,g]),b=vp(x,n&&r,l),v=me(()=>b.filter(k=>!t?.length||t.includes(k.chainId)||Object.keys(k.chainTokens??{}).some(S=>t.some(F=>S.startsWith(`evm:${F}:`)))),[b,w]),C=te(k=>v.filter(S=>S.chainId===k),[v]);return{assets:v,loading:y,error:g,hasBalance:v.some(k=>k.balance>0n),refreshing:m,updatedAt:h,refetch:i.invalidate,getAssetsByChain:C}};async function kp(e,t,n){if(n)return{decimals:n.decimals,symbol:n.symbol,name:n.name,logoURI:n.logo};const[o,r,s]=await Promise.all([ho(e,{address:t,abi:ot,functionName:"decimals"}),ho(e,{address:t,abi:ot,functionName:"symbol"}).catch(()=>"TOKEN"),ho(e,{address:t,abi:ot,functionName:"name"}).catch(()=>"TOKEN")]);if(!Number.isInteger(Number(o))||Number(o)<0||Number(o)>255)throw new Error("Invalid token decimals");return{decimals:Number(o),symbol:r,name:s,logoURI:void 0}}const Rl=async(e,t,n)=>{const o=bt(t,n),r=nt(t),s=await Gs(o,{address:e}),a=r.nativeCurrency,i=r.supportedTokens?.find(l=>be(l.address));return{address:Dt,name:a.name,symbol:a.symbol,decimals:a.decimals,balance:s,balanceFormatted:Number(Ee(s,a.decimals)),balanceUsd:0,logoURI:i?.logo||r.logo,isNative:!0,chainId:t}},Ip=async(e,t,n,o,r,s,a)=>{try{if(!vn(n))return null;const i=Yt(n),l=vn(e)?Yt(e):e,c=bt(t,a),d=await ho(c,{address:i,abi:ot,functionName:"balanceOf",args:[l]}),u=Number(Ee(d,s));return d>0n?{address:i,name:o,symbol:r,decimals:s,balance:d,balanceFormatted:u,balanceUsd:0,logoURI:void 0,isNative:!1,chainId:t}:null}catch(i){throw i}},Dl=(e,t)=>{const n=nt(t);if(!n)return e;const o=new Set(e.map(s=>s.address.toLowerCase())),r=e.some(s=>s.isNative);for(const s of n.supportedTokens||[])be(s.address)&&r||o.has(s.address.toLowerCase())||e.push({address:s.address,name:s.name,symbol:s.symbol,decimals:s.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:s.logo,isNative:be(s.address),chainId:t});if(!e.find(s=>s.isNative)){const s=n.supportedTokens?.find(a=>be(a.address));e.push({address:Dt,name:n.nativeCurrency.name,symbol:n.nativeCurrency.symbol,decimals:n.nativeCurrency.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:s?.logo||n.logo,isNative:!0,chainId:t})}return e},Sp=async(e,t,n)=>{const o=[],r=async i=>{for(const l of i){const c=await Ip(e,t,l.address,l.name,l.symbol,l.decimals,n);c&&(c.logoURI=l.logo,o.push(c))}},s=await Rl(e,t,n);s.balance>0n&&o.push(s);const a=(nt(t)?.supportedTokens||[]).filter(i=>!be(i.address));if(a.length>0)try{const i=bt(t,n),l=Yt(e),c=a.filter(y=>vn(y.address)).map(y=>({address:Yt(y.address),abi:ot,functionName:"balanceOf",args:[l]})),d=await i.multicall({contracts:c}),u=a.filter(y=>vn(y.address)),f=[];d.forEach((y,m)=>{if(y.status==="success"){const g=y.result;if(g&&g>0n){const h=u[m],w=Number(Ee(g,h.decimals));g>0n&&o.push({address:Yt(h.address),name:h.name,symbol:h.symbol,decimals:h.decimals,balance:g,balanceFormatted:w,balanceUsd:0,logoURI:h.logo,isNative:!1,chainId:t})}}else f.push(u[m])}),await r(f)}catch{await r(a)}return{tokens:Dl(o,t),chainId:t}},Ap=async(e,t,n)=>{const o=new Map,r=ha(e,n?n[e]??"":void 0);if(!r)return o;const s=t.filter(c=>be(c)),a=t.filter(c=>!be(c)),[i,l]=await Promise.all([a.length?ga(r,a).catch(()=>new Map):new Map,s.length?ya(r,nt(e)?.nativeCurrency?.symbol??"ETH").catch(()=>0):0]);for(const[c,d]of i)d>0&&o.set(c,d);if(l>0)for(const c of s)o.set(c.toLowerCase(),l);return o},Ep=async(e,t,n,o=!0,r)=>{const s=bt(t,r),a=Yt(e),i=[];let l;do{const w=await s.request({method:"alchemy_getTokenBalances",params:[a,"erc20",l?{pageKey:l}:{}]});i.push(...w.tokenBalances),l=w.pageKey||void 0}while(l);const c=i.filter(w=>vn(w.contractAddress)&&!!w.tokenBalance&&BigInt(w.tokenBalance)>0n),d=nt(t)?.supportedTokens||[],u=w=>d.find(x=>x.address.toLowerCase()===w.toLowerCase()),f=[],y=await Rl(e,t,r),[m,g,h]=await Promise.all([Promise.all(c.map(async w=>{const x=u(w.contractAddress);return x?{name:x.name,symbol:x.symbol,decimals:x.decimals,logo:x.logo??null}:await s.request({method:"alchemy_getTokenMetadata",params:[w.contractAddress]})})),o?ga(n,c.map(w=>w.contractAddress)):new Map(c.map(w=>[w.contractAddress.toLowerCase(),vr(n,w.contractAddress)?.price??0])),o&&y.balanceFormatted>0?ya(n,y.symbol):vr(n,`native:${y.symbol}`)?.price??0]);return y.balance>0n&&f.push({...y,balanceUsd:h*y.balanceFormatted}),c.forEach((w,x)=>{const b=m[x];if(!Number.isInteger(b.decimals)||b.decimals===null||b.decimals<0||b.decimals>255)throw new Error(`Invalid token metadata on chain ${t}`);const v=BigInt(w.tokenBalance),C=Number(Ee(v,b.decimals));if(v<=0n)return;const k=g.get(w.contractAddress.toLowerCase()),S=k?k*C:0;f.push({address:Yt(w.contractAddress),name:b.name||"Unknown",symbol:b.symbol||"UNKNOWN",decimals:b.decimals,balance:v,balanceFormatted:C,balanceUsd:S,isDiscovered:!u(w.contractAddress),logoURI:b.logo||void 0,isNative:!1,chainId:t})}),{tokens:Dl(f,t),chainId:t}},Ml=new Set,Fp=async(e,t,n=!0,o)=>{try{const r=ha(t,o?o[t]??"":void 0);if(r)try{return await Ep(e,t,r,n&&(typeof document>"u"||!document.hidden),o)}catch(s){Ml.has(t)||(Ml.add(t),console.warn(`Token discovery unavailable on chain ${t}; listing configured tokens only.`,s))}return await Sp(e,t,o)}catch(r){throw r}},Ho=async(e,t,n=[],o)=>{if(!e)throw new Error("Wallet address is required");const r=Zd(o),s=t?.length?[...new Set(t)]:Object.keys(r).map(Number),a=await Promise.allSettled(s.map(l=>Fp(e,l,!0,o))),i={};return a.forEach((l,c)=>{const d=s[c];i[d]=l.status==="fulfilled"?l.value:{chainId:d,tokens:[],error:`Unable to refresh balances on chain ${d}`}}),(await Promise.allSettled(n.map(async l=>{const c=i[l.chainId];if(!c||c.error||c.tokens.some(g=>dt(g.address).toLowerCase()===dt(l.address).toLowerCase()))return;const d=bt(l.chainId,o),u=await kp(d,l.address,l.decimals!==void 0&&l.symbol?{decimals:l.decimals,symbol:l.symbol,name:l.name||l.symbol,logo:l.logoURI}:void 0),f=await ho(d,{address:l.address,abi:ot,functionName:"balanceOf",args:[e]}),y=await Ap(l.chainId,[l.address],o),m=Number(Ee(f,u.decimals));c.tokens.push({...u,...l,name:u.name,symbol:u.symbol,decimals:u.decimals,balance:f,balanceFormatted:m,balanceUsd:(y.get(l.address.toLowerCase())||0)*m,isNative:!1})}))).forEach((l,c)=>{if(l.status==="rejected"){const d=i[n[c].chainId];d&&(d.error=`Unable to refresh token balances on chain ${d.chainId}`)}}),i},Cr=({address:e,supportedChains:t,fetchBalances:n=Ho,additionalTokens:o=[],enabled:r=!0,refreshInterval:s=0,priceEnabled:a=!0})=>{const i=Kt(Ht),l=is(),c=e?.toLowerCase(),d=JSON.stringify([...i?.supportedChainIds??t??[]].sort((x,b)=>x-b)),u=JSON.stringify(o);ue(()=>l.registerTokens(o),[l,u]);const f=c&&c===i?.embeddedWalletAddress?.toLowerCase()?"embedded":"external",y=`wallet:${JSON.stringify([i?.network,i?.apiUrl,i?.rpcOverrides])}:${c}:${f}:${d}:${l.fetcherId(n)}`,m=te(async()=>{let x;try{x=await n(c,JSON.parse(d),l.tokens(),i?.rpcOverrides)}catch(k){const S=k instanceof Error?k.message:"Unable to refresh balances";x=Object.fromEntries(JSON.parse(d).map(F=>[F,{chainId:F,tokens:[],error:S}]))}const b=l.entry(y).snapshot().assets,v=JSON.parse(d).map(k=>x[k]??{chainId:k,tokens:[],error:`Unable to refresh balances on chain ${k}`}),C=v.flatMap(k=>k.error?[k.error]:[]);return{assets:v.flatMap(k=>k.error?b.filter(S=>S.chainId===k.chainId).map(S=>({...S,balanceError:k.error,balanceStatus:"stale"})):k.tokens.map(S=>({...S,owner:c,location:f,_fundingWallet:f,_source:"wallet",positionId:`${c}:${f}:${k.chainId}:${dt(S.address).toLowerCase()}`}))),error:C.length?C.join("; "):null}},[l,c,d,n,f,y]),g=da(y,m,r&&!!c,s,l),h=JSON.stringify(t&&[...t].sort((x,b)=>x-b)),w=me(()=>t?g.assets.filter(x=>t.includes(x.chainId)):g.assets,[g.assets,h]);return ue(()=>{a&&r&&c&&g.refresh()},[a]),{...g,assets:w,refreshAssets:l.invalidate,getAssetsByChain:te(x=>w.filter(b=>b.chainId===x),[w]),getNativeAssets:te(()=>w.filter(x=>x.isNative),[w])}};function Vo(e){const t=Kt(Ht),n=is(),o=e.owner??((t?.mode||"7702")!=="7702"?t?.externalWalletAddress:t?.embeddedWalletAddress),r=o?.toLowerCase()!==t?.embeddedWalletAddress?.toLowerCase(),s=e.sourceChains??t?.supportedChainIds??[],a=(e.enabled??!0)&&!t?.isWhitelistGateActive,i=me(()=>{const f=[...t?.additionalSourceTokens??[],...e.additionalSourceTokens??[],...e.destination?[e.destination]:[]];for(const y of e.supportedSourceAssets??[])for(const m of s){const g=nt(m)?.supportedTokens?.find(h=>Qr(h,[y]));g&&f.push({...g,address:g.address,chainId:m,logoURI:g.logo})}return f},[e.destination,JSON.stringify(t?.additionalSourceTokens),JSON.stringify(e.additionalSourceTokens),JSON.stringify(e.supportedSourceAssets),JSON.stringify(s)]),l=Cr({address:o,supportedChains:s,fetchBalances:Ho,additionalTokens:i,enabled:a&&e.includeWalletAssets!==!1,refreshInterval:3e4}),c=Ol({address:o,supportedChains:s,enabled:a&&e.includeRollupAssets!==!1&&!!o&&o.toLowerCase()===t?.embeddedWalletAddress?.toLowerCase(),priceEnabled:a,refetchInterval:3e4}),d=me(()=>a?[...(e.includeWalletAssets===!1?[]:l.assets).map(f=>({...f,owner:f.owner??o,location:f.location??(r?"external":"embedded"),_source:"wallet"})),...(e.includeRollupAssets===!1||o?.toLowerCase()!==t?.embeddedWalletAddress?.toLowerCase()?[]:c.assets).map(f=>({...f,owner:f.owner??o,location:"rollup",_source:"spice"}))]:[],[a,l.assets,c.assets,e.includeWalletAssets,e.includeRollupAssets,o,r,t?.embeddedWalletAddress]),u=me(()=>d.map(f=>({asset:f,...go(f,e.role??"holding",{allowedTokens:t?.allowedTokens,rpcOverrides:t?.rpcOverrides,liquidityVenues:t?.liquidityVenues,isWhitelistGateActive:!!t?.isWhitelistGateActive},e.destination,e.supportedSourceAssets,{requiresEscrow:e.requiresEscrow})})),[d,t?.allowedTokens,t?.rpcOverrides,t?.liquidityVenues,t?.isWhitelistGateActive,e.role,e.destination,e.supportedSourceAssets,e.requiresEscrow]);return{positions:u,assets:me(()=>u.filter(f=>f.eligible&&f.asset.balance>0n).map(f=>f.asset),[u]),walletAssets:me(()=>d.filter(f=>f._source==="wallet"),[d]),rollupAssets:me(()=>d.filter(f=>f._source==="spice"),[d]),loading:l.loading||c.loading,refreshing:l.refreshing||c.refreshing,error:l.error||c.error,refresh:n.invalidate}}function wo(e){const t=dt(e.address);if(e.isNative||be(t))return!1;const n=nt(e.chainId)?.supportedTokens?.some(r=>oe(r.address,t)),o=Ut(t,e.chainId);return!!n&&!!o&&rs(o)}const Wl="spiceflow:pendingDeposit",cs="spiceflow:pendingDepositChanged";function Pl(e,t,n){return`${Wl}:${e.toLowerCase()}:${t}:${n.toLowerCase()}`}function wa(){try{const e="__spiceflow_storage_test__";return localStorage.setItem(e,"1"),localStorage.removeItem(e),!0}catch{return!1}}function Tp(e){if(!wa())return;const t=Pl(e.embeddedWalletAddress,e.chainId,e.tokenAddress);try{localStorage.setItem(t,JSON.stringify(e)),window.dispatchEvent(new Event(cs))}catch(n){console.error("[pendingDeposit] Failed to save:",n)}}function Bp(e){if(!wa())return[];const t=`${Wl}:${e.toLowerCase()}:`,n=[],o=Date.now();for(let r=0;r<localStorage.length;r++){const s=localStorage.key(r);if(!(!s||!s.startsWith(t)))try{const a=localStorage.getItem(s);if(!a)continue;const i=JSON.parse(a);if(o-i.timestamp>6048e5){localStorage.removeItem(s);continue}n.push(i)}catch{localStorage.removeItem(s)}}return n}function xa(e,t,n){if(!wa())return;const o=Pl(e,t,n);localStorage.removeItem(o),window.dispatchEvent(new Event(cs))}const Op=new Set(["USDC","SUSD","USD","NUSD","USDT","DAI","ENUSD","USDG"]),Nl={ETH:"ethereum",WETH:"ethereum",BTC:"bitcoin",WBTC:"bitcoin",WCBTC:"bitcoin",CBTC:"bitcoin",ECBTC:"bitcoin",ARB:"arbitrum",MATIC:"matic-network",POL:"matic-network"};let ds=null;const Rp=6e4;async function Ul(e){const t={},n=new Set,o={};for(const s of e){const a=s.toUpperCase();if(Op.has(a))t[a]=1;else if(Nl[a]){const i=Nl[a];n.add(i),o[a]=i}else t[a]=0}if(n.size===0)return t;const r=Date.now();if(ds&&r-ds.timestamp<Rp){for(const[s,a]of Object.entries(o))t[s]=ds.prices[a]??0;return t}try{const s=Array.from(n).join(","),a=await fetch(`https://api.coingecko.com/api/v3/simple/price?ids=${s}&vs_currencies=usd`);if(!a.ok)throw new Error(`CoinGecko ${a.status}`);const i=await a.json(),l={};for(const c of n)l[c]=i[c]?.usd??0;ds={prices:l,timestamp:r};for(const[c,d]of Object.entries(o))t[c]=l[d]??0}catch(s){console.warn("[fetchTokenPrices] CoinGecko fetch failed:",s);for(const a of Object.keys(o))t[a]=t[a]??0}return t}const Dp=new Set(["cbtc","btc","wbtc","wcbtc","tbtc"]),Mp=new Set(["usdc","usdt","dai","usdc.e","usdbc","usdg"]);async function Wp(){const e=(await Ul(["BTC"])).BTC;if(!e||e<=0)throw new Error("Failed to fetch BTC/USD price");return e}function Pp(e){return Dp.has(e.toLowerCase())}function Np(e){return Mp.has(e.toLowerCase())}function Up(e,t,n,o){const r=10n**12n,s=BigInt(Math.round(o*Number(r))),a=t-n,i=10n**BigInt(Math.abs(a));let l=e*s/r;return a>0?l=l/i:a<0&&(l=l*i),l}const Lp=.01,zp=5*60*1e3;function qp(e){const t=Number(Ee(e.verifiedBalance,e.tokenDecimals));return Number.isFinite(t)?t:0}async function Hp(e){const t=Ll(e);let n;try{n=await Ul(t.map(o=>o.tokenSymbol))}catch{return t}return t.filter(o=>{const r=qp(o);if(r<=0)return!0;const s=n[o.tokenSymbol.toUpperCase()]??0;return!Number.isFinite(s)||s<=0?!0:r*s>=Lp})}function Ll(e){const t=new Map;for(const n of e){const o=`${n.chainId}:${n.tokenAddress.toLowerCase()}`;if(!t.get(o)){const r=n.timestamp===0&&n.verifiedBalance>0n;t.set(o,{...n,amount:r?Ee(n.verifiedBalance,n.tokenDecimals):n.amount,rawAmount:r?n.verifiedBalance.toString():n.rawAmount,hasFullBalance:r?!0:n.hasFullBalance})}}return Array.from(t.values())}function zl(e,t){const[n,o]=P([]),[r,s]=P(!1),a=Z(t);a.current=t;const i=!!t?.enabled,l=Z(0),c=Z([]),d=t?.chainIds?.join(","),u=t?.discoverWalletBalances??!0,f=Z(0),y=te(async({forceDiscovery:m=!1}={})=>{if(!e||a.current?.enabled===!1){o([]),s(!1);return}const g=++f.current,h=()=>g!==f.current;s(!0);try{const w=[],x=Bp(e),b=new Set(x.map(F=>`${F.chainId}:${F.tokenAddress.toLowerCase()}`)),v=[...x,...c.current.filter(F=>F.timestamp===0&&!b.has(`${F.chainId}:${F.tokenAddress.toLowerCase()}`))];for(const F of v){if(h())return;if(wo({address:F.tokenAddress,chainId:F.chainId,isNative:F.isNative}))try{const T=bt(F.chainId);let E;if(F.isNative||be(F.tokenAddress)?E=await Gs(T,{address:e}):E=await ho(T,{address:Yt(F.tokenAddress),abi:ot,functionName:"balanceOf",args:[e]}),h())return;if(E>0n)w.push({...F,verifiedBalance:E,hasFullBalance:E>=BigInt(F.rawAmount)});else{const M=Date.now()-F.timestamp;F.timestamp!==0&&M>15*60*1e3&&xa(e,F.chainId,F.tokenAddress)}}catch(T){if(h())return;console.warn(`[usePendingDeposit] Failed to verify balance for ${F.tokenSymbol} on chain ${F.chainId}:`,T),w.push({...F,verifiedBalance:0n,hasFullBalance:!1})}}if(h())return;const C=a.current,k=Date.now(),S=(C?.discoverWalletBalances??!0)&&(m||k-l.current>=zp);if(C?.network&&S){l.current=k;const F=C.chainIds??Xr(C.network),T=new Set(w.map(M=>`${M.chainId}:${M.tokenAddress.toLowerCase()}`)),E=[];for(const M of F){const B=nt(M);if(B?.supportedTokens)for(const D of B.supportedTokens){if(!wo({address:D.address,chainId:M,isNative:!1}))continue;const W=`${M}:${D.address.toLowerCase()}`;T.has(W)||E.push((async()=>{try{const I=bt(M),O=await ho(I,{address:Yt(D.address),abi:ot,functionName:"balanceOf",args:[e]});return O>0n?{chainId:M,tokenAddress:D.address,tokenSymbol:D.symbol,tokenDecimals:D.decimals,amount:Ee(O,D.decimals),rawAmount:O.toString(),embeddedWalletAddress:e,externalWalletAddress:"",timestamp:0,isNative:!1,verifiedBalance:O,hasFullBalance:!0}:null}catch{return null}})())}}if(E.length>0){const M=await Promise.allSettled(E);if(h())return;for(const B of M)B.status==="fulfilled"&&B.value&&w.push(B.value)}}if(!h()){const F=await Hp(w);if(h())return;c.current=Ll(w),o(F)}}catch(w){if(console.error("[usePendingDeposit] Verification error:",w),!h()){const x=c.current.map(b=>({...b,verifiedBalance:0n,hasFullBalance:!1}));c.current=x,o(x)}}finally{h()||s(!1)}},[e]);return ue(()=>{if(c.current=[],l.current=0,o([]),!i){f.current++,s(!1);return}y({forceDiscovery:!0});const m=a.current?.pollIntervalMs??3e4;if(m<=0||!e)return()=>{f.current++};const g=setInterval(()=>{y({forceDiscovery:!1})},m),h=()=>y({forceDiscovery:!0});return window.addEventListener(cs,h),()=>{f.current++,window.removeEventListener(cs,h),clearInterval(g)}},[y,e,i,t?.network,d,u]),{pendingDeposits:n,loading:r,refresh:()=>y({forceDiscovery:!0})}}function ql(e){const t=Kt(Ht),n=t?.embeddedWalletAddress,o=e?.enabled===!1?void 0:n,r=t?.network?{network:t.network,pollIntervalMs:e?.pollIntervalMs,chainIds:e?.chainIds??t.supportedChainIds,discoverWalletBalances:e?.discoverWalletBalances}:void 0;return{...zl(o,r),embeddedWalletAddress:n}}var ba="data:image/svg+xml,%3csvg width='10' height='10' viewBox='0 0 10 10' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M5 4.99995V6.99995M5 3.31245V3.31189M9.5 5C9.5 7.48528 7.48528 9.5 5 9.5C2.51472 9.5 0.5 7.48528 0.5 5C0.5 2.51472 2.51472 0.5 5 0.5C7.48528 0.5 9.5 2.51472 9.5 5Z' stroke='black' stroke-opacity='0.4' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e";function va(e){const t=Z(0),n=Z(null),o=Z(e.run);o.current=e.run;const r=Z(e.onSkip);r.current=e.onSkip;const s=Z(e.onCleanup);s.current=e.onCleanup,ue(()=>{if(!e.shouldRun){t.current+=1,n.current?.abort(),r.current?.();return}let a=!1,i=!1;const l=async f=>{if(f&&i)return;n.current?.abort();const y=new AbortController;n.current=y;const m=++t.current;i=!0;try{await o.current({isBackground:f,isCurrent:()=>!a&&t.current===m,signal:y.signal})}finally{i=!1}},c=window.setTimeout(()=>void l(!1),e.delayMs??250),d=()=>{document.hidden||l(!0)},u=e.backgroundIntervalMs?window.setInterval(d,e.backgroundIntervalMs):void 0;return u!==void 0&&document.addEventListener("visibilitychange",d),()=>{a=!0,n.current?.abort(),clearTimeout(c),u!==void 0&&(window.clearInterval(u),document.removeEventListener("visibilitychange",d)),s.current?.()}},[e.shouldRun,e.delayMs,e.backgroundIntervalMs,...e.deps])}function Hl(e,t){if(e.length!==t.length)return!1;const n=Gn(e),o=Gn(t);return n.every((r,s)=>r.hash===o[s]?.hash)}const Qn=e=>new Promise(t=>setTimeout(t,e)),Vp="0xa9059cbb";function Vl(e){const t=e.findIndex(r=>Uo(r.chainId));if(t<=0)return[];const n=new Map,o=(r,s,a)=>{if(a<=0n)return;const i=`${r}:${s.toLowerCase()}`,l=n.get(i);l?l.amount+=a:n.set(i,{chainId:r,token:s,amount:a})};for(const r of e.slice(0,t)){const s=pr(r.chainId);if(!(!s||s===Dt)){for(const a of r.calls)if(a.value&&a.value>0n&&oe(a.to,s)&&o(r.chainId,Dt,a.value),!!a.data?.startsWith(Vp))try{const i=so({abi:ot,data:a.data});if(i.functionName!=="transfer")continue;const[l,c]=i.args;oe(l,s)&&o(r.chainId,a.to,c)}catch{}}}return[...n.values()]}function Ql(e){const t=Ut(e.token,e.chainId);return[t?.equivalenceGroup,t?.symbol,t?.name]}function jl(e,t){return fa(e,t.chainId,t.token,Ql(t))}function Qp(e,t){const n=hp(e,t.chainId,t.token,Ql(t));return!n||n.receiptDecimals>=n.chainDecimals?t.amount:Vn(Vn(t.amount,n.chainDecimals,n.receiptDecimals),n.receiptDecimals,n.chainDecimals)}async function Gl(e){const{deposits:t,baseline:n,fetchEntries:o,timeoutMs:r=12e4,intervalMs:s,signal:a,wait:i=Qn}=e;if(t.length===0)return!0;const l=new Map(t.map(u=>[u,jl(n,u)])),c=Date.now(),d=c+r;for(;!a?.aborted;){try{const m=await o();if(t.every(g=>jl(m,g)-l.get(g)>=Qp(m,g)))return!0}catch{}const u=Date.now();if(u>=d)return!1;const f=u-c,y=s??(f<5e3?250:f<15e3?1e3:3e3);await i(Math.min(y,d-u))}return!1}function Kl(e,t){const n=Gn(e).map(o=>o.hash);return Lo(ao([{type:"string"},{type:"uint256"},{type:"uint256"},{type:"bytes32[]"}],["ecdsa",0n,t,n]))}async function Yl(e,t,n,o,r){if(o?.aborted)throw new ze("ABORT","Execution transaction aborted");const s={raw:Kl(t,n)},a=r?await e.signMessage(s,r):await e.signMessage(s);console.debug("[SpiceFlow:execution]",{phase:"signature-returned",at:Date.now()});const i=typeof a=="string"?a:a.signature;if(!i)throw new ze("SIGNATURE_FAILED","Failed to sign intent authorization. The wallet returned an empty signature.");return i}function jp(e){return e.domain==="spicenet"||Uo(e.chainId)}async function Zl(e){const{chainBatches:t,signingAddress:n,actions:o,cache:r,signal:s,onSignatureRequested:a,beforeSign:i}=e;if(s?.aborted)throw new ze("ABORT","Execution transaction aborted");const l=[...new Set(t.filter(u=>!jp(u)).map(u=>u.chainId))].map(u=>({chainId:u,client:bt(u),delegateContract:bi(u)})),[c]=await Promise.all([Promise.all(l.map(async({chainId:u,client:f,delegateContract:y})=>{const m=Number(await pu(n,f)),g=[n.toLowerCase(),u,y.toLowerCase(),m].join(":");return{chainId:u,delegateContract:y,nonce:m,cacheKey:g,cached:r?.get(g)}})),l.length?o.prepareSigning?.():void 0,i?.()]),d=[];for(const{chainId:u,delegateContract:f,nonce:y,cacheKey:m,cached:g}of c){if(g){d.push(g);continue}if(s?.aborted)throw new ze("ABORT","Execution transaction aborted");const h=await o.signAuthorization({contractAddress:f,chainId:u,nonce:y},a),w={r:h.r,s:h.s,yParity:h.yParity,address:h.address??f,chainId:Number(h.chainId??u),nonce:Number(h.nonce??y)};r?.set(m,w),d.push(w)}return d}const Xl=15;function Gp(e){return e.now-e.lastProgressAt>=e.pollTimeoutMs}function Jl(e,t){return{intentId:e,steps:t.map(n=>({...n,status:"pending"})),overallStatus:"processing"}}function us(e,t,n){const o=e.steps.map(i=>({...i})),r=o[t];if(!r)return e;n.status==="success"||n.status==="completed"?(o[t]={...r,status:"success",transactionHash:n.transactionHash},t+1<o.length&&o[t+1].status==="pending"&&(o[t+1]={...o[t+1],status:"processing"})):n.status==="reverted"||n.status==="error"?o[t]={...r,status:"failed",transactionHash:n.transactionHash,error:n.error}:o[t]={...r,status:"processing"};const s=o.some(i=>i.status==="failed"),a=o.every(i=>i.status==="success");return{...e,steps:o,overallStatus:s?"failed":a?"success":"processing"}}function Kp({checkStepStatus:e,retryStep:t,maxRetries:n=3,pollingInterval:o=2500,pollTimeoutMs:r=3e5}){const[s,a]=P(null),i=Z(null),l=Z(null),c=Z(!1),d=Z(!1),u=Z(0),f=Z({}),y=Z(0),m=te(v=>{i.current=v,a(v)},[]),g=te(()=>{l.current&&(clearInterval(l.current),l.current=null)},[]),h=te(()=>{u.current=0,f.current={},y.current=0,c.current=!0,g(),m(null)},[g,m]),w=te((v,C)=>{g(),c.current=!1,m(Jl(v,C))},[g,m]),x=te((v,C)=>{const k=i.current;k&&m(us(k,v,C))},[m]),b=te((v,C)=>{g(),c.current=!1,d.current=!1,u.current=0,f.current={},y.current=Date.now(),m(Jl(v,C));const k=async()=>{if(!(c.current||d.current||!e)){d.current=!0;try{if(Gp({now:Date.now(),lastProgressAt:y.current,pollTimeoutMs:r})){const T=i.current;T&&m({...T,steps:T.steps.map(E=>E.status==="success"?E:{...E,status:"failed",error:"Taking longer than expected. It may still complete - check the explorer, then refresh."}),overallStatus:"failed"}),c.current=!0,g();return}const S=i.current;if(!S)return;const F=S.steps.findIndex(T=>T.status!=="success");if(F===-1){c.current=!0,g();return}if(!(F===0||S.steps[F-1].status==="success"))return;try{const T=S.steps[F].stepId,{data:E}=await e(v,T);if(u.current=0,E.status==="success"&&(y.current=Date.now()),E.status==="reverted"){const B=f.current[T]||0;if(t&&B<n){f.current[T]=B+1;try{await t(v,T)}catch(D){console.error(`[intentStatus] retry failed for step ${T}:`,D)}m(us(i.current,F,{status:"executing"}));return}}const M=us(i.current,F,E);m(M),M.overallStatus!=="processing"&&(c.current=!0,g())}catch(T){u.current+=1,console.error(`[intentStatus] poll error (${u.current}/${Xl}):`,T),u.current>=Xl&&(m(us(i.current,F,{status:"error"})),c.current=!0,g())}}finally{d.current=!1}}};k(),l.current=setInterval(k,o)},[e,t,n,o,r,g,m]);return ue(()=>()=>g(),[g]),{intentStatus:s,startStatusPolling:b,beginStatusTracking:w,applyStepUpdate:x,stopStatusPolling:g,clearStatus:h}}function Yp(e,t){return(t||"").trim()||`Transaction ${e}. The transaction was rejected on-chain. This may be due to insufficient balance, price changes, or health factor constraints. Please verify your positions and try again.`}const Zp=350,Xp=2500;async function $l(e){const{actionId:t,intentIndex:n,intentId:o,stepIndex:r,maxPolls:s=48,maxExecuteAttempts:a=3,pollsBeforeRetry:i=5,maxConsecutiveStatusErrors:l=15,onStatusMessage:c,onStepUpdate:d,signal:u,chainId:f,startWithExecute:y=!0,observeOnly:m=!1,relayer:g=yt,completeOnExecution:h=!1}=e;if(u?.aborted)throw new ze("ABORT","Execution transaction aborted");let w="pending",x,b,v=0,C=0,k,S;const F=new Promise((E,M)=>{k=E,S=()=>M(new ze("ABORT","Execution transaction aborted"))}),T=()=>{v++,g.executeStep(t,n,r,{action:"execute"}).then(E=>{E.transactionHash&&(x=E.transactionHash),E.status==="success"&&k({status:E.status,transactionHash:E.transactionHash})}).catch(E=>{const M=E instanceof Error?E.message:String(E);console.warn(`[execution] executeStep ${r} attempt ${v} error (will poll):`,M)})};u?.addEventListener("abort",S,{once:!0});try{y&&!m&&T();for(let E=0;E<s;E++){const M=E===0?Zp:Xp;try{const D=await Promise.race([Qn(M).then(()=>{}),F]);if(u?.aborted)throw new ze("ABORT","Execution transaction aborted");const W=D??await Promise.race([g.checkStepStatus(o,r,h).then(O=>O.data),F]);if(u?.aborted)throw new ze("ABORT","Execution transaction aborted");C=0,w=W.status,b=W.error;const I=W.transactionHash;I&&(x=I),h&&/^0x[0-9a-f]{64}$/i.test(I??"")&&(W.executionStatus==="success"||W.executionStatus==="reverted")&&(w=W.executionStatus,b=void 0),d?.({status:w,transactionHash:x,error:b})}catch(D){if(D instanceof Error&&(D.name==="AbortError"||D instanceof ze&&D.code==="ABORT"))throw D;if(C++,C>=l){if(!m)throw D;c?.("Status is temporarily unavailable. The backend continues this action.",x)}continue}if(!m&&w==="created"&&E>=v*i&&v<a&&T(),w==="reverted"||w==="error")throw new ze("ON_CHAIN_REVERT",Yp(w,b),{status:w,txHash:x,actionId:t,intentId:o,stepId:r,chainId:f});if(w==="success"||w==="completed")return x;let B="Waiting for solver...";w==="executing"?B="Transaction executing...":w==="submitted"?B="Transaction submitted...":w==="created"&&(B="Waiting for relayer..."),c?.(B,x)}throw new ze("POLLING_EXHAUSTED",`Transaction is still processing (status: ${w}). This doesn't mean it failed \u2014 the solver may still complete it. Check your positions in a few minutes, or try refreshing the page.`,{actionId:t,intentId:o,stepId:r,lastStatus:w,pollAttempts:s,maxPolls:s,txHash:x})}finally{u?.removeEventListener("abort",S)}}async function Jp(e){const{actionId:t,intentIndex:n,intentId:o,totalSteps:r,observeOnly:s,delayBeforeSpicenetStepMs:a=5e3,isSpicenetStep:i,beforeStep:l,maxExecuteAttemptsForStep:c,maxPolls:d=48,onStatusMessage:u,onStepUpdate:f,signal:y}=e;let m;for(let g=0;g<r;g++){if(!s&&g>0&&i?.(g)&&a>0&&await Qn(a),await l?.(g),y?.aborted)throw new ze("ABORT","Execution transaction aborted");const h=c?.(g)??3,w=await $l({actionId:t,intentIndex:n,intentId:o,stepIndex:g,observeOnly:s,relayer:e.relayer,maxPolls:d,maxExecuteAttempts:h,maxConsecutiveStatusErrors:h===6?5:15,onStatusMessage:u,onStepUpdate:f?x=>f(g,x):void 0,signal:y,completeOnExecution:g===r-1&&i?.(g)===!1});w&&(m=w)}return m}const $p="0xa9059cbb",_p=[fu,Zt,xn];function _l(e){return _p.some(t=>oe(e,t))}function ps(e,t){return e.map(n=>{if(n.domain==="spicenet"||Uo(n.chainId)||n.calls.length===0)return n;const o=new Set((n.tokenTransfers??[]).filter(a=>(a.from==="escrow"||a.from==="solver")&&oe(a.to,t)).map(a=>a.token.toLowerCase()));if(o.size===0)return n;const r=[...o].some(be);let s=0;for(const a of n.calls){if(r&&a.value>0n&&a.data==="0x"&&_l(a.to)){s+=1;continue}if(!a.data?.startsWith($p))break;try{const i=so({abi:ot,data:a.data});if(i.functionName!=="transfer")break;const[l]=i.args;if(!_l(l)||!o.has(a.to.toLowerCase()))break;s+=1}catch{break}}return s===0?n:{...n,calls:n.calls.slice(s)}})}async function ef(e,t){if(!t||!/^0x[0-9a-f]{64}$/i.test(t))throw new Error("The destination receipt is not available yet; reconcile the existing action before retrying.");const n=await e.waitForTransactionReceipt({hash:t,timeout:12e4,pollingInterval:2e3,confirmations:1});if(n.transactionHash?.toLowerCase()!==t.toLowerCase()||n.status!=="success")throw new Error("The destination transaction has not been confirmed successfully. Reconcile the existing action before retrying.");return t}async function fs(e){let t=e.hash,n=!1;const o=Date.now()+12e4,r=a=>a.transactionHash&&a.transactionHash.toLowerCase()!==t.toLowerCase();let s=await e.client.waitForTransactionReceipt({hash:t,timeout:12e4,pollingInterval:2e3,confirmations:1,onReplaced:a=>{const i=a.transaction,l=a.replacedTransaction;if(!(a.reason==="repriced"&&l?.hash?.toLowerCase()===t.toLowerCase()&&l?.to?.toLowerCase()===e.call.to.toLowerCase()&&(l.input??"0x").toLowerCase()===e.call.data.toLowerCase()&&BigInt(l.value??0)===e.call.value&&l?.from&&l.nonce!==void 0&&/^0x[0-9a-f]{64}$/i.test(i?.hash??"")&&i?.to?.toLowerCase()===e.call.to.toLowerCase()&&(i.input??"0x").toLowerCase()===e.call.data.toLowerCase()&&BigInt(i.value??0)===e.call.value&&i.from?.toLowerCase()===l?.from?.toLowerCase()&&i.nonce===l?.nonce)){n=!0,e.onCancelled?.();return}t=i.hash,e.onRepriced?.(t)}});if(n)throw new Error("Transaction was cancelled or replaced with a different action; retry the unfinished action");if((e.confirmations??1)>1&&!r(s)&&s.status==="success"&&(s=await e.client.waitForTransactionReceipt({hash:t,timeout:Math.max(o-Date.now(),1),pollingInterval:2e3,confirmations:e.confirmations})),r(s))throw new Error("Unexpected transaction receipt; recover the submitted transaction before retrying");return{receipt:s,hash:t}}const tf=10n,nf=10n,of=5;function Ca(e){return e.map(t=>({...t,calls:[...t.calls],tokenTransfers:t.tokenTransfers?[...t.tokenTransfers]:void 0}))}function ms({token:e,recipient:t,amount:n}){return{to:e,value:0n,data:Tt({abi:ot,functionName:"transfer",args:[t,n]})}}function rf({chainBatches:e,token:t,amount:n}){const o=Ca(e),r=o[o.length-1];if(!r)return o;const s=ro(r.chainId);return r.calls=[...r.calls,ms({token:t,recipient:s,amount:n})],o}function ec({chainBatches:e,user:t,token:n,grossAmount:o,gasFee:r}){const s=Ca(e),a=s[s.length-1];if(!a)throw new ze("INVALID_PARAMS","Action-output escrow funding requires at least one chain batch.");const i=Ms(o,nf),l=r+i;if(l>=o)throw new ze("INVALID_PARAMS","Borrow amount is too small after gas and Spicenet fees.",{grossAmount:o.toString(),gasFee:r.toString(),spicenetFee:i.toString()});const c=o-l,d=ro(a.chainId),u=[];return r>0n&&u.push(ms({token:n,recipient:Zt,amount:r})),i>0n&&u.push(ms({token:n,recipient:xn,amount:i})),a.calls=[...a.calls,...u,ms({token:n,recipient:d,amount:c})],a.tokenTransfers=[...a.tokenTransfers??[],...r>0n?[{from:t,to:Zt,token:n,amount:r}]:[],...i>0n?[{from:t,to:xn,token:n,amount:i}]:[],{from:t,to:d,token:n,amount:c}],{chainBatches:s,gasFee:r,spicenetFee:i,netEscrowAmount:c,outputCredit:{chainId:a.chainId,token:n,amount:o}}}async function tc({chainBatches:e,user:t,token:n,grossAmount:o,chainAuthorizations:r}){let s=0n,a=ec({chainBatches:e,user:t,token:n,grossAmount:o,gasFee:s});for(let i=0;i<of;i+=1){const l=Gn(a.chainBatches),c=(await yt.estimateBatchGas({user:t,outputToken:n,chainBatches:a.chainBatches.map((d,u)=>({...d,hash:l[u].hash})),chainAuthorizations:r})).gasFee;if(c===s)return a;s=c,a=ec({chainBatches:e,user:t,token:n,grossAmount:o,gasFee:s})}throw new ze("INVALID_PARAMS","Action-output fee estimate did not converge. Please retry.")}function uo(e){return Uo(e.chainId)}const sf="0xa9059cbb";function kr(e,t){return`${e}:${dt(t).toLowerCase()}`}function nc(e,t){return t===Dt.toLowerCase()?{symbol:Tn(e),decimals:18}:Ut(t,e)??{symbol:"tokens",decimals:18}}function af(e,t){const n=Ut(t,e);return[n?.equivalenceGroup,n?.symbol,n?.name]}async function ka(e){return ar(e)}async function lf(e,t,n){const o=new Map,r=n?.walletFundingRequirement,s=r&&kr(r.chainId,r.token);s&&o.set(s,0n);const a=new Map,i=new Map,l=new Map,c=new Map;for(const u of n?.actionOutputCredits??[]){const f=kr(u.chainId,u.token);c.set(f,(c.get(f)??0n)+u.amount)}for(const u of e){if(uo(u))continue;for(const m of u.tokenTransfers??[]){if(m.from!=="escrow"&&m.from!=="solver"||!oe(m.to,t))continue;const g=BigInt(m.amount??0);if(g<=0n)continue;const h=kr(u.chainId,m.token);a.set(h,(a.get(h)??0n)+g),m.from==="escrow"&&i.set(h,(i.get(h)??0n)+g)}const f=pr(u.chainId),y=m=>!!f&&f!==Dt&&oe(m,f);for(const m of u.calls){if(m.value&&m.value>0n){const g=kr(u.chainId,Dt);o.set(g,(o.get(g)??0n)+m.value),y(m.to)&&l.set(g,(l.get(g)??0n)+m.value)}if(m.data?.startsWith(sf))try{const g=so({abi:ot,data:m.data});if(g.functionName!=="transfer")continue;const[h,w]=g.args,x=m.to.toLowerCase(),b=kr(u.chainId,x);o.set(b,(o.get(b)??0n)+w),y(h)&&l.set(b,(l.get(b)??0n)+w)}catch{}}}let d=null;for(const[u,f]of i){const y=f-(l.get(u)??0n);if(y<=0n)continue;const[m,g]=u.split(":"),h=Number(m),w=nc(h,g);d??(d=await ka(t));const x=fa(d,h,g,af(h,g));if(!(x>=y))throw new ze("INVALID_PARAMS",`Insufficient Spice ${w.symbol}: needs ${Ee(y,w.decimals)}, has ${Ee(x,w.decimals)}.`,{chainId:h,token:g,userAddress:t,requiredAmount:y.toString(),balance:x.toString(),balanceSource:"spice"})}for(const[u,f]of o){const[y,m]=u.split(":"),g=Number(y);let h=f-(a.get(u)??0n)-(c.get(u)??0n);if(r&&u===s&&r.amount>h&&(h=r.amount),h<=0n)continue;const w=bt(g),x=m===Dt.toLowerCase()?await w.getBalance({address:t}):await w.readContract({address:m,abi:ot,functionName:"balanceOf",args:[t]});if(x>=h)continue;const b=nc(g,m);throw new ze("INVALID_PARAMS",`Insufficient ${b.symbol} on ${Tn(g)}: needs ${Ee(h,b.decimals)}, has ${Ee(x,b.decimals)}.`,{chainId:g,token:m,userAddress:t,requiredAmount:h.toString(),balance:x.toString(),balanceSource:"wallet"})}}function cf({chainBatches:e,tokenAddress:t,tokenTransferAmount:n,useCustomTransfers:o}){if(!(e.some(uo)||!(o?e.some(r=>uo(r)?!1:(r.tokenTransfers??[]).some(s=>s.from==="escrow"&&BigInt(s.amount??0)>0n)):n>0n)))throw new ze("INVALID_PARAMS","Payouts funded from Spice balance require a Spicenet funding batch before the destination chain batch. Deposits into Spice balance and gas-only actions do not need one.",{tokenAddress:t,tokenTransferAmount:n.toString(),useCustomTransfers:!!o})}function df(e,t,n,o){t.forEach((r,s)=>{if(!r.to||!r.from||!r.token||r.amount===void 0)throw new ze("INVALID_TOKEN_TRANSFER",`tokenTransfers[${s}] on chain ${e} is missing required fields (to/from/token/amount). This usually means the embedded wallet wasn't ready when the intent was built \u2014 please retry.`,{chainId:e,transferIndex:s,transfer:{from:r.from,to:r.to,token:r.token,amount:r.amount?.toString()},signingAddress:n,useCustomTransfers:o})})}function hs({user:e,chainBatches:t,tokenAddress:n,tokenTransferAmount:o,exp:r,signature:s,chainAuthorizations:a,useCustomTransfers:i}){const l=t,c=Gn(l),d=l.filter(u=>!uo(u)).length;if(cf({chainBatches:l,tokenAddress:n,tokenTransferAmount:o,useCustomTransfers:i}),!i&&o>0n&&d>1)throw new ze("INVALID_PARAMS","Multiple non-Spicenet batches require explicit tokenTransfers. Pass useCustomTransfers with per-batch transfers instead of relying on the default escrow payout injection.",{nonSpicenetBatchCount:d,tokenAddress:n,tokenTransferAmount:o.toString()});return{user:e,...a?{chainAuthorizations:a}:{},intents:[{mode:"7702",signatureType:"ecdsa",signature:s,nbf:0,exp:r,chainBatches:c.map((u,f)=>{const y=l[f],m=uo(y)?[]:i?y.tokenTransfers??[]:o>0n?[{from:"escrow",to:e,token:n,amount:o}]:[];return df(Number(u.chainId),m,e,i),{hash:u.hash,chainId:Number(u.chainId),tokenTransfers:m,calls:u.calls}})}]}}function oc(e,t){const n=t?.depositToEscrow?.gasFundingSource==="action-output"?t.depositToEscrow:null,o=t?.depositToEscrow&&!n?rf({chainBatches:e,token:t.depositToEscrow.token,amount:t.depositToEscrow.amount}):Ca(e);return{actionOutputDeposit:n,batches:o}}let Ia=!1;function Ir(){const{address:e,isConnected:t,isAuthenticated:n,actions:o}=to(),r=Z(null),{intentStatus:s,startStatusPolling:a,beginStatusTracking:i,applyStepUpdate:l,clearStatus:c}=Kp({checkStepStatus:(h,w)=>yt.checkStepStatus(h,w),retryStep:async(h,w)=>{const[x,b]=h.split("/"),v=parseInt(b||"0",10);await yt.executeStep(x,v,w,{action:"execute"})}}),d=Z(o),u=Z(new Map);d.current=o;const f=te((h,w,x,b,v)=>Zl({chainBatches:h,signingAddress:w,actions:d.current,cache:u.current,signal:x,onSignatureRequested:b,beforeSign:v}),[]),y=te((h,w,x,b)=>Yl(d.current,h,w,x,b),[]),m=te(async(h,w,x,b,v,C)=>{const k=(S,F,T)=>{b?.({step:S,message:F,...T})};if(Ia)throw new ze("CONCURRENT_EXECUTION","A execution transaction is already in progress. Please wait.");Ia=!0;try{if(!e)throw new ze("WALLET_DISCONNECTED","No wallet connected. Please log in first.");const S=C?.userOverride||e,F=yt.getBaseUrl(),T=await yt.supportsAutomaticContinuation(),{actionOutputDeposit:E,batches:M}=oc(h,C);let B=M,D=[],W=C?.useCustomTransfers,I=Vl(B),O=null;const U=async()=>{for(let K=0;I.length>0&&K<3;K++)try{O=await ka(S);break}catch(Q){if(v?.aborted)throw new ze("ABORT","Execution transaction aborted");if(K===2)throw new ze("RELAYER_ERROR","Unable to read your Spice balance. Please try again before submitting the transaction.",{cause:Q});await Qn(1e3)}await C?.validateBeforeSubmit?.(B)};k("building","Preparing your wallet and transaction...");const z=await f(B,S,v,()=>k("signing-delegation","Confirm the authorization in your wallet..."),U);if(k("building","Checking transaction fees and balances..."),v?.aborted)throw new ze("ABORT","Execution transaction aborted");const re=BigInt(Math.floor(Date.now()/1e3)+3600);if(E){const K=await tc({chainBatches:h,user:S,token:E.token,grossAmount:E.amount,chainAuthorizations:z});B=K.chainBatches,D=[K.outputCredit],W=!0}if(!C?.skipPreSubmitFeeEstimate){let K=!1;if(C?.feeExecutionMode==="user-transfer"&&C.adjustBatchesForEstimate&&yt.canValidateActionFees()){const Q=await yt.validateActionFees(hs({user:S,chainBatches:B,tokenAddress:w,tokenTransferAmount:x,exp:Number(re),signature:"0x00",chainAuthorizations:z,useCustomTransfers:W}),{signal:v});r.current=Q;const he=await C.adjustBatchesForEstimate({feeEstimate:Q,chainBatches:B});K=!he||Hl(B,he),he&&(B=he)}for(let Q=0;!K&&Q<10;Q++){const he=C?.feeExecutionMode==="user-transfer"?ps(B,S):B,ve=hs({user:S,chainBatches:he,tokenAddress:w,tokenTransferAmount:x,exp:Number(re),signature:"0x00",chainAuthorizations:z,useCustomTransfers:W}),Fe=await yt.estimateActionFees(ve,{signal:v});r.current=Fe;const L=await C?.adjustBatchesForEstimate?.({feeEstimate:Fe,chainBatches:B}),N=!!L&&Hl(B,L);if(!L||N){K=!0;break}B=L}if(!K)throw new ze("INVALID_PARAMS","Fee estimate did not converge. Please retry.")}if(C?.prepareForSigning){const K=await C.prepareForSigning(B);if(K.length!==B.length||K.some((Q,he)=>Q.chainId!==B[he].chainId||Q.domain!==B[he].domain))throw new Error("The funded route changed before signing");B=K}C?.resolveActionOutputCredits&&(D=await C.resolveActionOutputCredits()),(!C?.skipUserFundingPreflight||C.walletFundingRequirement)&&await lf(C?.skipUserFundingPreflight?[]:B,S,{actionOutputCredits:D,walletFundingRequirement:C?.walletFundingRequirement}),I=Vl(B),I.length&&!O&&(O=await ar(S)),await C?.validateBeforeSubmit?.(B),k("building","Preparing the signing request...");const pe=await y(B,re,v,()=>k("signing-intent","Confirm the transaction in your wallet..."));if(v?.aborted)throw new ze("ABORT","Execution transaction aborted");k("submitting","Submitting to relayer...");const se=hs({user:S,chainBatches:B,tokenAddress:w,tokenTransferAmount:x,exp:Number(re),signature:pe,chainAuthorizations:z,useCustomTransfers:W}),V=Date.now();if(await C?.validateBeforeSubmit?.(B),console.debug("[SpiceFlow:execution]",{phase:"submit-check-complete",at:Date.now(),durationMs:Date.now()-V}),yt.getBaseUrl()!==F)throw new Error("The network changed before submission. Review your balances before trying again.");const X=await yt.createAction({...se,...T?{autoContinue:!0}:{}}),[Y,_]=X.intentIds[0].split("/"),j=parseInt(_||"0",10),ke=`${Y}/${j}`;k("executing","Executing on chain..."),k("executing","Executing on chain...",{actionId:Y,intentId:ke,intentIndex:j,totalSteps:B.length,autoContinue:X.autoContinue===!0});const Se=B.length,R=new Ws;R.setBaseUrl(F);const G=await Jp({actionId:Y,intentIndex:j,intentId:ke,totalSteps:Se,signal:v,observeOnly:X.autoContinue===!0,relayer:X.autoContinue?R:yt,...O?{delayBeforeSpicenetStepMs:0}:{},isSpicenetStep:K=>uo(B[K]),beforeStep:async K=>{if(X.autoContinue===!0||!O||!uo(B[K]))return;const Q=await Gl({deposits:I,baseline:O,fetchEntries:()=>ka(S),signal:v});if(v?.aborted)throw new ze("ABORT","Execution transaction aborted");if(!Q)throw new ze("POLLING_EXHAUSTED","Your deposit is still waiting for Spice credit. Check this transaction's status before trying again.",{actionId:Y,intentId:ke,stepId:K})},maxExecuteAttemptsForStep:K=>uo(B[K])?6:3,maxPolls:X.autoContinue?Number.POSITIVE_INFINITY:180,onStatusMessage:(K,Q)=>{k("executing",K,{txHash:Q,actionId:Y,intentId:ke,intentIndex:j,totalSteps:Se,autoContinue:X.autoContinue===!0})}});if(C?.requireDestinationReceipt){const K=[...B].reverse().find(Q=>!uo(Q));if(!K)throw new Error("The action has no destination transaction to verify.");await ef(bt(K.chainId),G)}return k("success","Transaction successful!",{txHash:G,actionId:Y,intentId:ke,intentIndex:j,totalSteps:Se,autoContinue:X.autoContinue===!0}),G||Y}catch(S){throw console.error("[Execution] Error:",S),k("error",S.message||"Transaction failed",{error:S.message}),S}finally{Ia=!1}},[e,n,f,y]),g=te(async(h,w,x,b)=>{if(!e)throw new ze("WALLET_DISCONNECTED","No wallet connected. Please log in first.");const v=b?.userOverride||e,C=b?.validateFeeCalls===!0&&b.feeExecutionMode==="user-transfer"&&yt.canValidateActionFees(),{actionOutputDeposit:k,batches:S}=oc(h,b);let F=S;const T=b?.feeExecutionMode==="user-transfer"&&!C?ps(F,v):F,E=b?.signAuthorizationsForEstimate?await f(T,v):void 0;let M=b?.useCustomTransfers;k&&(F=(await tc({chainBatches:h,user:v,token:k.token,grossAmount:k.amount,chainAuthorizations:E})).chainBatches,M=!0);const B=b?.feeExecutionMode==="user-transfer"&&!C?ps(F,v):F,D=hs({user:v,chainBatches:B,tokenAddress:w,tokenTransferAmount:x,exp:Math.floor(Date.now()/1e3)+3600,signature:"0x00",chainAuthorizations:E,useCustomTransfers:M}),W=await(C?yt.validateActionFees(D,{signal:b?.signal}):yt.estimateActionFees(D,{signal:b?.signal}));return r.current=W,W},[e,f]);return{execute:m,estimate:g,lastFeeEstimate:r.current,hasEmbeddedWallet:t&&n,intentStatus:s,startStatusPolling:a,beginStatusTracking:i,applyStepUpdate:l,clearStatus:c}}const Sa=({color:e})=>A("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:[p("circle",{cx:"7",cy:"7",r:"6.5",stroke:e,strokeWidth:"1.2"}),p("path",{d:"M7 6v4",stroke:e,strokeWidth:"1.2",strokeLinecap:"round"}),p("circle",{cx:"7",cy:"4.5",r:"0.7",fill:e})]}),rc=({content:e,label:t="More info",textColor:n="#f9fafb",backgroundColor:o="#111827",borderColor:r="rgba(255,255,255,0.08)",accentColor:s="#9ca3af",children:a})=>{const i=Ai(),[l,c]=P(!1),d=Z(null),[u,f]=P(!1),[y,m]=P(null);ue(()=>{f(!0)},[]),Ao(()=>{if(!l||!d.current)return;const h=()=>{if(!d.current)return;const w=d.current.getBoundingClientRect(),x=Math.min(220,window.innerWidth-48),b=Math.min(Math.max(w.left+w.width/2,24+x/2),window.innerWidth-24-x/2),v=w.top>84;m({top:v?w.top-10:w.bottom+10,left:b,placement:v?"top":"bottom"})};return h(),window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[l]);const g=l&&u&&y?Ys(A("span",{id:i,role:"tooltip",style:{position:"fixed",left:y.left,top:y.top,transform:y.placement==="top"?"translate(-50%, -100%)":"translate(-50%, 0)",width:"220px",maxWidth:"min(220px, calc(100vw - 48px))",padding:"10px 12px",borderRadius:"10px",backgroundColor:o,color:n,border:`1px solid ${r}`,boxShadow:"0 18px 45px rgba(0,0,0,0.28)",fontSize:"11px",lineHeight:"1.45",fontWeight:500,textAlign:"left",zIndex:Io.tooltip,pointerEvents:"none"},children:[e,p("span",{"aria-hidden":"true",style:{position:"absolute",left:"50%",width:"10px",height:"10px",transform:"translateX(-50%) rotate(45deg)",backgroundColor:o,...y.placement==="top"?{bottom:"-6px",borderRight:`1px solid ${r}`,borderBottom:`1px solid ${r}`}:{top:"-6px",borderTop:`1px solid ${r}`,borderLeft:`1px solid ${r}`}}})]}),document.body):null;return A(nn,{children:[p("span",{ref:d,style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:p("button",{type:"button","aria-label":t,"aria-describedby":l?i:void 0,onFocus:()=>c(!0),onBlur:()=>c(!1),style:{width:"18px",height:"18px",borderRadius:"999px",display:"inline-flex",alignItems:"center",justifyContent:"center",border:`1px solid ${r}`,backgroundColor:"transparent",color:s,cursor:"help",padding:0,outline:"none",boxShadow:l?`0 0 0 2px ${s}26`:"none",transition:"border-color 120ms ease, box-shadow 120ms ease, color 120ms ease"},children:a||p(Sa,{color:s})})}),g]})},Sr=(e,t,n,o)=>({width:e,height:e,fill:"none",className:t,"aria-hidden":n??!0,style:o}),Qo=({size:e=16,color:t="currentColor",strokeWidth:n=2,direction:o="down",className:r,style:s,"aria-hidden":a})=>p("svg",{...Sr(e,r,a,{transform:o==="up"?"rotate(180deg)":void 0,transition:"transform 0.3s ease",...s}),viewBox:"0 0 16 16",children:p("path",{d:"M4 6L8 10L12 6",stroke:t,strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round"})}),uf=({size:e=24,color:t="currentColor",strokeWidth:n=2,className:o,style:r,"aria-hidden":s})=>A("svg",{...Sr(e,o,s,r),viewBox:"0 0 24 24",children:[p("circle",{cx:"11",cy:"11",r:"8",stroke:t,strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round"}),p("path",{d:"m21 21-4.3-4.3",stroke:t,strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round"})]}),pf=({size:e=24,color:t="currentColor",strokeWidth:n=2,className:o,style:r,"aria-hidden":s})=>p("svg",{...Sr(e,o,s,r),viewBox:"0 0 24 24",children:p("path",{d:"m6 9 6 6 6-6",stroke:t,strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round"})}),ff=({size:e=24,color:t="currentColor",strokeWidth:n=2,className:o,style:r,"aria-hidden":s})=>p("svg",{...Sr(e,o,s,r),viewBox:"0 0 24 24",children:p("path",{d:"m9 18 6-6-6-6",stroke:t,strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round"})}),sc=({size:e=14,color:t="currentColor",strokeWidth:n=2,className:o,style:r,"aria-hidden":s})=>p("svg",{...Sr(e,o,s,r),viewBox:"0 0 16 16",children:p("path",{d:"M3 8L6.5 11.5L13 5",stroke:t,strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round"})});function gs(e,t){if(e===0n)return"0";const n=10n**BigInt(t),o=e/n,r=(e%n).toString().padStart(t,"0").replace(/0+$/,"");return r?`${o.toString()}.${r}`:o.toString()}function Aa(e,t,n){const o=`${gs(e,t)} ${n}`;return e===0n?o:`-${o}`}const mf=({fontFamily:e,textPrimary:t,textSecondary:n,cardBg:o,cardBorder:r,resolvedDark:s,darkCardBorder:a,primaryColor:i,feePreview:l,feeOnlyAction:c=!1,asset:d,isLoading:u,errorText:f,directExecutionFeeNote:y=!1})=>{const m=jn(),g=d&&l&&[d.symbol,d.displaySymbol,d.receiptTokenName].includes(l.symbol)?m(d).symbol:l?.symbol,h=s?a??r:"#e5e7eb",w=s?"#111214":"#111827",x=s?"rgba(255,255,255,0.08)":"rgba(17,24,39,0.12)",b="#f87171",v=s?"#d1d5db":"#4b5563",C=s?"#f3f4f6":t,[k,S]=P(!1),F=!!f,T=F?null:l,E=T?[...c?[]:[{label:"Total Required",help:"Total amount required to fund this action.",value:`${gs(T.grossAmount,T.decimals)} ${g}`,tone:"default"}],{label:"Spicenet Fee",help:"Fees paid to Spicenet for intent processing and execution.",value:Aa(T.spicenetFee,T.decimals,g),tone:"fee"},{label:"Network Fee",help:"Network fee shown in the same token you are using for this action.",value:Aa(T.gasFee,T.decimals,g),tone:"fee"},...T.bridgeFee&&T.bridgeFee>0n?[{label:"Bridge Fee",help:"Estimated cost to rebalance liquidity for this action.",value:Aa(T.bridgeFee,T.decimals,g),tone:"fee"}]:[],...c?[]:[{label:"Used in TX",help:"Resulting amount of funds used in the transaction.",value:`${gs(T.netAmount,T.decimals)} ${g}`,tone:"default"}]]:[],M=T?`${gs(c?T.totalFee??T.gasFee+T.spicenetFee+(T.bridgeFee??0n):T.grossAmount,T.decimals)} ${g}`:null;return F?p("div",{style:{backgroundColor:o,border:`1px solid ${r}`,borderRadius:s?"8px":"7px",padding:"14px 16px 12px 16px",marginBottom:"16px",boxShadow:s?"inset 0 1px 0 rgba(255,255,255,0.03)":"none"},children:A("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[p("span",{style:{fontSize:"17px",fontWeight:500,color:v,fontFamily:e,lineHeight:"24px"},children:"Fee"}),p("div",{style:{color:b,fontSize:"12px",lineHeight:"1.55",fontFamily:e},children:f})]})}):A("div",{style:{backgroundColor:o,border:`1px solid ${r}`,borderRadius:s?"8px":"7px",padding:"14px 16px 12px 16px",marginBottom:"16px",boxShadow:s?"inset 0 1px 0 rgba(255,255,255,0.03)":"none"},children:[A("button",{type:"button",onClick:()=>S(B=>!B),style:{display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%",gap:"12px",marginBottom:k?"14px":0,background:"none",border:"none",padding:0,cursor:"pointer",textAlign:"left"},children:[A("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[p("span",{style:{fontSize:"17px",fontWeight:500,color:v,fontFamily:e,lineHeight:"24px"},children:"Fee"}),k&&p("span",{style:{fontSize:"12px",color:n,fontFamily:e,lineHeight:"1.45"},children:"What is funded, spent, and taken as fees"})]}),A("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexShrink:0},children:[M&&A("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:"2px",minWidth:0},children:[p("span",{style:{fontSize:"10px",fontWeight:700,color:n,fontFamily:e,letterSpacing:"0.08em",textTransform:"uppercase"},children:c?"Total fees":"Total required"}),p("span",{style:{fontSize:"14px",fontWeight:700,color:C,fontFamily:e,whiteSpace:"nowrap"},children:M})]}),u&&!y&&p("span",{style:{fontSize:"11px",fontWeight:600,color:i,fontFamily:e,padding:"6px 9px",borderRadius:"999px",backgroundColor:s?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.035)",border:`1px solid ${s?h:"rgba(0,0,0,0.06)"}`,whiteSpace:"nowrap"},children:"Recalculating"}),p(Qo,{color:n,direction:k?"up":"down",style:{flexShrink:0}})]})]}),p("div",{style:{overflow:"hidden",maxHeight:k?"480px":"0px",opacity:k?1:0,transition:"max-height 0.24s ease, opacity 0.18s ease"},children:y?p("p",{style:{margin:0,color:n,fontSize:"12px",lineHeight:"1.55",fontFamily:e},children:"This path executes directly from the external wallet. Network gas is shown and paid in your wallet. No Spicenet fee is charged."}):E.length>0?A(nn,{children:[p("div",{style:{display:"grid",gap:"10px"},children:E.map((B,D)=>A("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) auto",alignItems:"center",gap:"12px",paddingTop:D===0?0:"10px",borderTop:D===0?"none":`1px solid ${h}`,opacity:u?.74:1,transition:"opacity 120ms ease"},children:[A("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:[p("span",{style:{fontSize:"12px",color:n,fontFamily:e,fontWeight:500},children:B.label}),p(rc,{content:B.help,label:`${B.label} info`,textColor:"#f9fafb",backgroundColor:w,borderColor:x,accentColor:s?"#8f96a3":"#6b7280"})]}),p("span",{style:{fontSize:"12px",color:B.tone==="fee"?b:C,fontFamily:Ne.mono,textAlign:"right",fontWeight:B.label==="Used in TX"?600:500,letterSpacing:"-0.01em"},children:B.value})]},B.label))}),p("div",{style:{marginTop:"12px",paddingTop:"12px",borderTop:`1px solid ${h}`,fontSize:"11px",color:n,fontFamily:e,lineHeight:"1.45"},children:T?.gasQuoteSource==="estimated"?"Gas quote uses a live estimate.":T?.gasQuoteSource==="configured_fallback"?"Gas quote uses a configured fallback.":"Gas quote is currently zero."})]}):p("div",{style:{fontSize:"12px",color:f?b:n,fontFamily:e,opacity:f?1:.8,lineHeight:"1.5"},children:f||"Waiting for fee estimate..."})})]})},Ea=Bn(mf),Ar=({size:e=20,strokeWidth:t=2,color:n="currentColor",style:o})=>A("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:n,strokeWidth:t,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:o,children:[p("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),p("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]});var ac="data:image/svg+xml,%3csvg width='108' height='22' viewBox='0 0 108 22' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M1.9916 11.9854V11.2041H3.98379C4.48835 11.2041 4.87897 11.0739 5.15566 10.8135C5.43236 10.5498 5.5707 10.1868 5.5707 9.72461V9.71484C5.5707 9.24935 5.43236 8.88639 5.15566 8.62598C4.87897 8.36556 4.48835 8.23535 3.98379 8.23535H1.9916V7.4541H4.2084C4.65111 7.4541 5.04173 7.5485 5.38027 7.7373C5.71882 7.92611 5.98411 8.18978 6.17617 8.52832C6.37148 8.86686 6.46914 9.25911 6.46914 9.70508V9.71484C6.46914 10.1608 6.37148 10.5547 6.17617 10.8965C5.98411 11.2383 5.71882 11.5052 5.38027 11.6973C5.04173 11.8893 4.65111 11.9854 4.2084 11.9854H1.9916ZM1.55215 14.5V7.4541H2.43106V14.5H1.55215ZM9.51875 14.5928C9.0207 14.5928 8.58939 14.4837 8.2248 14.2656C7.86348 14.0443 7.58353 13.7301 7.38496 13.3232C7.18965 12.9163 7.09199 12.4329 7.09199 11.873V11.8633C7.09199 11.3001 7.18965 10.8151 7.38496 10.4082C7.58353 10.0013 7.86348 9.6888 8.2248 9.4707C8.58939 9.2526 9.0207 9.14355 9.51875 9.14355C10.0201 9.14355 10.4514 9.2526 10.8127 9.4707C11.174 9.6888 11.4523 10.0013 11.6477 10.4082C11.8462 10.8151 11.9455 11.3001 11.9455 11.8633V11.873C11.9455 12.4329 11.8462 12.9163 11.6477 13.3232C11.4523 13.7301 11.174 14.0443 10.8127 14.2656C10.4514 14.4837 10.0201 14.5928 9.51875 14.5928ZM9.51875 13.8408C9.85078 13.8408 10.1324 13.7627 10.3635 13.6064C10.5946 13.4502 10.7704 13.2256 10.8908 12.9326C11.0145 12.6396 11.0764 12.2865 11.0764 11.873V11.8633C11.0764 11.4466 11.0145 11.0918 10.8908 10.7988C10.7704 10.5059 10.5946 10.2829 10.3635 10.1299C10.1324 9.97363 9.85078 9.89551 9.51875 9.89551C9.18672 9.89551 8.90514 9.97363 8.67402 10.1299C8.4429 10.2829 8.26549 10.5059 8.1418 10.7988C8.02135 11.0918 7.96113 11.4466 7.96113 11.8633V11.873C7.96113 12.2865 8.02135 12.6396 8.1418 12.9326C8.26549 13.2256 8.4429 13.4502 8.67402 13.6064C8.90514 13.7627 9.18672 13.8408 9.51875 13.8408ZM13.7842 14.5L12.3096 9.23633H13.1592L14.1943 13.4453H14.2725L15.4492 9.23633H16.2549L17.4316 13.4453H17.5098L18.5449 9.23633H19.3896L17.915 14.5H17.0605L15.8838 10.4277H15.8057L14.6338 14.5H13.7842ZM22.1658 14.5928C21.6645 14.5928 21.2332 14.4821 20.8719 14.2607C20.5138 14.0394 20.2371 13.7269 20.0418 13.3232C19.8497 12.9163 19.7537 12.4378 19.7537 11.8877V11.8828C19.7537 11.3392 19.8497 10.8623 20.0418 10.4521C20.2371 10.042 20.5122 9.72135 20.867 9.49023C21.2218 9.25911 21.6368 9.14355 22.1121 9.14355C22.5906 9.14355 23.0008 9.25423 23.3426 9.47559C23.6876 9.69694 23.9513 10.0062 24.1336 10.4033C24.3191 10.7972 24.4119 11.2562 24.4119 11.7803V12.1123H20.1932V11.4336H23.9773L23.5574 12.0537V11.7168C23.5574 11.3034 23.4956 10.9632 23.3719 10.6963C23.2482 10.4294 23.0773 10.2308 22.8592 10.1006C22.6411 9.96712 22.3904 9.90039 22.1072 9.90039C21.824 9.90039 21.5701 9.97038 21.3455 10.1104C21.1242 10.2471 20.9484 10.4505 20.8182 10.7207C20.688 10.9909 20.6229 11.3229 20.6229 11.7168V12.0537C20.6229 12.4281 20.6863 12.7487 20.8133 13.0156C20.9402 13.2793 21.1209 13.4827 21.3553 13.626C21.5896 13.766 21.8663 13.8359 22.1854 13.8359C22.423 13.8359 22.6297 13.8034 22.8055 13.7383C22.9813 13.6732 23.1261 13.5902 23.24 13.4893C23.354 13.3883 23.4337 13.2858 23.4793 13.1816L23.4988 13.1377H24.3484L24.3387 13.1768C24.2931 13.3558 24.2117 13.5299 24.0945 13.6992C23.9806 13.8652 23.8325 14.0166 23.6502 14.1533C23.4679 14.2868 23.2514 14.3942 23.0008 14.4756C22.7534 14.5537 22.4751 14.5928 22.1658 14.5928ZM25.4303 14.5V9.23633H26.2799V10.0176H26.358C26.4589 9.74089 26.6298 9.52604 26.8707 9.37305C27.1116 9.22005 27.4094 9.14355 27.7643 9.14355C27.8456 9.14355 27.9254 9.14844 28.0035 9.1582C28.0849 9.16471 28.1467 9.17122 28.1891 9.17773V10.0029C28.1012 9.98665 28.0149 9.97526 27.9303 9.96875C27.8489 9.95898 27.761 9.9541 27.6666 9.9541C27.3964 9.9541 27.1572 10.0078 26.9488 10.1152C26.7405 10.2227 26.5761 10.3724 26.4557 10.5645C26.3385 10.7565 26.2799 10.9811 26.2799 11.2383V14.5H25.4303ZM30.9408 14.5928C30.4395 14.5928 30.0082 14.4821 29.6469 14.2607C29.2888 14.0394 29.0121 13.7269 28.8168 13.3232C28.6247 12.9163 28.5287 12.4378 28.5287 11.8877V11.8828C28.5287 11.3392 28.6247 10.8623 28.8168 10.4521C29.0121 10.042 29.2872 9.72135 29.642 9.49023C29.9968 9.25911 30.4118 9.14355 30.8871 9.14355C31.3656 9.14355 31.7758 9.25423 32.1176 9.47559C32.4626 9.69694 32.7263 10.0062 32.9086 10.4033C33.0941 10.7972 33.1869 11.2562 33.1869 11.7803V12.1123H28.9682V11.4336H32.7523L32.3324 12.0537V11.7168C32.3324 11.3034 32.2706 10.9632 32.1469 10.6963C32.0232 10.4294 31.8523 10.2308 31.6342 10.1006C31.4161 9.96712 31.1654 9.90039 30.8822 9.90039C30.599 9.90039 30.3451 9.97038 30.1205 10.1104C29.8992 10.2471 29.7234 10.4505 29.5932 10.7207C29.463 10.9909 29.3979 11.3229 29.3979 11.7168V12.0537C29.3979 12.4281 29.4613 12.7487 29.5883 13.0156C29.7152 13.2793 29.8959 13.4827 30.1303 13.626C30.3646 13.766 30.6413 13.8359 30.9604 13.8359C31.198 13.8359 31.4047 13.8034 31.5805 13.7383C31.7563 13.6732 31.9011 13.5902 32.015 13.4893C32.129 13.3883 32.2087 13.2858 32.2543 13.1816L32.2738 13.1377H33.1234L33.1137 13.1768C33.0681 13.3558 32.9867 13.5299 32.8695 13.6992C32.7556 13.8652 32.6075 14.0166 32.4252 14.1533C32.2429 14.2868 32.0264 14.3942 31.7758 14.4756C31.5284 14.5537 31.2501 14.5928 30.9408 14.5928ZM36.1486 14.5928C35.7059 14.5928 35.3186 14.4805 34.9865 14.2559C34.6545 14.0312 34.3973 13.7155 34.215 13.3086C34.0328 12.8984 33.9416 12.4199 33.9416 11.873V11.8633C33.9416 11.3132 34.0328 10.8346 34.215 10.4277C34.3973 10.0208 34.6529 9.70508 34.9816 9.48047C35.3137 9.25586 35.7027 9.14355 36.1486 9.14355C36.3895 9.14355 36.6158 9.18262 36.8273 9.26074C37.0422 9.33561 37.2326 9.44141 37.3986 9.57812C37.5647 9.71484 37.6949 9.8776 37.7893 10.0664H37.8674V7.14648H38.717V14.5H37.8674V13.6602H37.7893C37.6818 13.8555 37.5467 14.0231 37.384 14.1631C37.2212 14.2998 37.0357 14.4056 36.8273 14.4805C36.619 14.5553 36.3928 14.5928 36.1486 14.5928ZM36.3439 13.8408C36.663 13.8408 36.938 13.7611 37.1691 13.6016C37.4003 13.4421 37.5777 13.2158 37.7014 12.9229C37.8251 12.6266 37.8869 12.2767 37.8869 11.873V11.8633C37.8869 11.4564 37.8251 11.1064 37.7014 10.8135C37.5777 10.5205 37.4003 10.2943 37.1691 10.1348C36.938 9.97526 36.663 9.89551 36.3439 9.89551C36.0249 9.89551 35.7499 9.97526 35.5188 10.1348C35.2909 10.291 35.1151 10.5156 34.9914 10.8086C34.871 11.1016 34.8107 11.4531 34.8107 11.8633V11.873C34.8107 12.2799 34.871 12.6315 34.9914 12.9277C35.1151 13.2207 35.2909 13.4469 35.5188 13.6064C35.7499 13.7627 36.0249 13.8408 36.3439 13.8408ZM45.1775 14.5928C44.9334 14.5928 44.7072 14.5553 44.4988 14.4805C44.2905 14.4056 44.1049 14.2998 43.9422 14.1631C43.7794 14.0231 43.6443 13.8555 43.5369 13.6602H43.4588V14.5H42.6092V7.14648H43.4588V10.0664H43.5369C43.6346 9.8776 43.7648 9.71484 43.9275 9.57812C44.0936 9.44141 44.2824 9.33561 44.4939 9.26074C44.7088 9.18262 44.9367 9.14355 45.1775 9.14355C45.6235 9.14355 46.0109 9.25586 46.3396 9.48047C46.6717 9.70508 46.9288 10.0208 47.1111 10.4277C47.2934 10.8346 47.3846 11.3132 47.3846 11.8633V11.873C47.3846 12.4199 47.2934 12.8984 47.1111 13.3086C46.9288 13.7155 46.6717 14.0312 46.3396 14.2559C46.0109 14.4805 45.6235 14.5928 45.1775 14.5928ZM44.9822 13.8408C45.3045 13.8408 45.5796 13.7627 45.8074 13.6064C46.0353 13.4469 46.2094 13.2207 46.3299 12.9277C46.4536 12.6315 46.5154 12.2799 46.5154 11.873V11.8633C46.5154 11.4531 46.4536 11.1016 46.3299 10.8086C46.2094 10.5156 46.0353 10.291 45.8074 10.1348C45.5796 9.97526 45.3045 9.89551 44.9822 9.89551C44.6632 9.89551 44.3881 9.97526 44.157 10.1348C43.9259 10.2943 43.7485 10.5205 43.6248 10.8135C43.5011 11.1064 43.4393 11.4564 43.4393 11.8633V11.873C43.4393 12.2767 43.5011 12.6266 43.6248 12.9229C43.7485 13.2158 43.9259 13.4421 44.157 13.6016C44.3881 13.7611 44.6632 13.8408 44.9822 13.8408ZM48.6568 16.3457C48.6015 16.3457 48.5396 16.3424 48.4713 16.3359C48.4029 16.3327 48.3395 16.3262 48.2809 16.3164V15.6182C48.3329 15.6279 48.3899 15.6344 48.4518 15.6377C48.5136 15.641 48.5738 15.6426 48.6324 15.6426C48.8733 15.6426 49.0702 15.5807 49.2232 15.457C49.3795 15.3333 49.5048 15.1201 49.5992 14.8174L49.6969 14.5049L47.7486 9.23633H48.6568L50.2779 14.0996L49.941 13.5674H50.3414L50.0045 14.0996L51.6207 9.23633H52.5143L50.4586 14.8223C50.3154 15.2161 50.164 15.5238 50.0045 15.7451C49.845 15.9665 49.6578 16.1211 49.443 16.209C49.2314 16.3001 48.9693 16.3457 48.6568 16.3457Z' fill='%230E0D0B'/%3e%3cpath d='M62.7081 13.27C62.742 13.27 62.7642 13.3057 62.7491 13.3362V13.336L61.1229 16.6083C61.0892 16.6761 60.9926 16.6759 60.959 16.6083L59.3382 13.336C59.3232 13.3057 59.3453 13.27 59.3792 13.27H62.7081Z' fill='%23EA4B4B'/%3e%3cpath d='M61.0026 9.71913C61.0194 9.68524 61.0678 9.68524 61.0845 9.71913L62.747 13.0897C62.762 13.12 62.7399 13.1557 62.706 13.1557H59.3763C59.3424 13.1557 59.3203 13.12 59.3353 13.0897L61.0026 9.71913Z' fill='%23EA4B4B'/%3e%3cpath d='M60.8426 9.63827C60.8766 9.63827 60.8987 9.6741 60.8835 9.70444L59.2164 13.0594C59.1995 13.0932 59.1513 13.0932 59.1345 13.0594L57.5001 9.77047C57.47 9.70962 57.5142 9.63827 57.5821 9.63827H60.8426Z' fill='%23EA4B4B'/%3e%3cpath d='M64.5036 9.63617C64.5715 9.63618 64.6157 9.70753 64.5855 9.76838H64.5854L62.9512 13.0573C62.9344 13.0911 62.8862 13.0912 62.8692 13.0573L61.2021 9.70235C61.187 9.672 61.2091 9.63617 61.2431 9.63617H64.5036Z' fill='%23EA4B4B'/%3e%3cpath d='M62.8284 6.18281C62.862 6.11518 62.9586 6.11518 62.9922 6.18281L64.5855 9.38969C64.6157 9.45054 64.5715 9.52189 64.5036 9.52189H61.2431C61.2091 9.52189 61.187 9.48605 61.2021 9.45571L62.8283 6.18265L62.8284 6.18281Z' fill='%23EA4B4B'/%3e%3cpath d='M62.3131 6.13196C62.381 6.13196 62.4252 6.20331 62.3951 6.26416C62.154 6.74935 61.9128 7.23455 61.6718 7.71975H61.6716C61.4225 8.22125 61.1733 8.72259 60.9242 9.22409C60.9074 9.25799 60.859 9.25799 60.8422 9.22409L60.6305 8.79587C60.6275 8.78957 60.6259 8.78263 60.6259 8.77553V6.22349C60.6259 6.17297 60.6668 6.13196 60.7173 6.13196H62.3131Z' fill='%23EA4B4B'/%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M74.8537 10.0096C75.2721 10.0096 75.654 10.1125 75.9993 10.3184C76.3513 10.5177 76.6303 10.8032 76.8361 11.1751C77.0487 11.547 77.1549 11.9953 77.1549 12.52V12.6495C77.1549 13.1675 77.052 13.6158 76.8461 13.9943C76.6402 14.3729 76.3613 14.6618 76.0093 14.861C75.664 15.0603 75.2788 15.1599 74.8537 15.1599C74.515 15.1599 74.2261 15.1134 73.9871 15.0204C73.7546 14.9341 73.5653 14.8212 73.4192 14.6817C73.2731 14.5423 73.1602 14.3995 73.0805 14.2534H72.941V16.9659L72.1541 16.0013V10.1491H72.9211V10.956H73.0352C73.2729 10.6733 73.3893 10.4911 73.6683 10.2985C73.9538 10.1059 74.349 10.0096 74.8537 10.0096ZM74.6445 10.7069C74.1464 10.7069 73.7347 10.8696 73.4092 11.195C73.0905 11.5138 72.9311 11.9621 72.9311 12.5399V12.6296C72.9311 13.2074 73.0905 13.659 73.4092 13.9844C73.7347 14.3032 74.1464 14.4626 74.6445 14.4626C75.1492 14.4626 75.5577 14.3032 75.8698 13.9844C76.1886 13.659 76.348 13.2074 76.348 12.6296V12.5399C76.348 11.9621 76.1886 11.5138 75.8698 11.195C75.5577 10.8696 75.1492 10.7069 74.6445 10.7069Z' fill='%230E0D0B'/%3e%3cpath d='M78.5848 11.9583L78.5555 15.4596L77.7681 14.4846V10.9583L78.5848 11.9583Z' fill='%230E0D0B'/%3e%3cpath d='M101.588 10.2986H102.444L103 10.986H101.588V10.9867H100.802L101.588 11.9623V14.1937C101.588 14.3929 101.685 14.4926 101.877 14.4926H102.379L102.928 15.17H101.668C101.389 15.17 101.173 15.0936 101.021 14.9409C100.874 14.7881 100.801 14.5789 100.801 14.3133V10.986H99.8799L99.3217 10.2986H100.801V9.13501H101.588V10.2986Z' fill='%230E0D0B'/%3e%3cpath d='M69.0133 7.90764C69.4848 7.90764 69.9065 7.99068 70.2784 8.15671C70.6569 8.3161 70.9525 8.55517 71.165 8.87395C71.3842 9.18609 71.4938 9.58126 71.4938 10.0594V10.4778H70.667V10.0594C70.667 9.72072 70.5939 9.44842 70.4477 9.24254C70.3083 9.03666 70.1124 8.88392 69.86 8.7843C69.6143 8.68469 69.332 8.63487 69.0133 8.63487C68.555 8.63487 68.1864 8.7378 67.9075 8.94367C67.6286 9.14291 67.4891 9.4285 67.4891 9.80041C67.4891 10.0461 67.5488 10.2453 67.6684 10.3981C67.7879 10.5508 67.9573 10.677 68.1764 10.7767C68.3956 10.8696 68.658 10.9527 68.9635 11.0257L69.4815 11.1552C69.8866 11.2416 70.2485 11.3611 70.5673 11.5138C70.8927 11.6599 71.1517 11.8625 71.3443 12.1215C71.5369 12.3739 71.6332 12.706 71.6332 13.1177C71.6332 13.5295 71.5303 13.8881 71.3244 14.1936C71.1185 14.4991 70.8263 14.7382 70.4477 14.9109C70.0758 15.0769 69.6375 15.1599 69.1328 15.1599C68.6281 15.1599 68.1765 15.0702 67.778 14.8909C67.3795 14.7116 67.0641 14.4426 66.8316 14.084C66.6058 13.7187 66.4929 13.2638 66.4929 12.7192V12.51H67.3197V12.7192C67.3197 13.297 67.4891 13.7287 67.8278 14.0143C68.1665 14.2932 68.6015 14.4327 69.1328 14.4327C69.6774 14.4327 70.0924 14.3098 70.378 14.0641C70.6636 13.8183 70.8064 13.5095 70.8064 13.1376C70.8064 12.8786 70.74 12.6727 70.6072 12.52C70.481 12.3673 70.3017 12.2444 70.0692 12.1514C69.8368 12.0518 69.5645 11.9655 69.2523 11.8924L68.7343 11.7629C68.3292 11.6566 67.9706 11.5271 67.6584 11.3744C67.3463 11.2216 67.1006 11.0224 66.9213 10.7767C66.7486 10.5243 66.6623 10.2022 66.6623 9.81035C66.6623 9.41852 66.7585 9.07981 66.9511 8.79424C67.1504 8.50866 67.426 8.28953 67.778 8.13678C68.1366 7.98404 68.5484 7.90764 69.0133 7.90764Z' fill='%230E0D0B'/%3e%3cpath d='M81.6544 10.0096C82.1193 10.0096 82.5145 10.0959 82.8399 10.2686C83.1719 10.4412 83.431 10.6704 83.6169 10.956C83.8095 11.2415 83.9324 11.5471 83.9855 11.8725L83.2185 12.0318C83.1853 11.7928 83.1056 11.5736 82.9794 11.3744C82.8598 11.1752 82.6905 11.0158 82.4713 10.8962C82.2521 10.7767 81.9832 10.7169 81.6644 10.7169C81.339 10.7169 81.0468 10.7899 80.7877 10.936C80.5354 11.0821 80.3328 11.2914 80.1801 11.5637C80.034 11.836 79.9609 12.1614 79.9609 12.5399V12.6296C79.9609 13.0081 80.034 13.3335 80.1801 13.6058C80.3328 13.8781 80.5354 14.0873 80.7877 14.2334C81.0468 14.3795 81.339 14.4526 81.6644 14.4526C82.1492 14.4526 82.5178 14.3264 82.7702 14.0741C83.0292 13.8217 83.1886 13.5095 83.2483 13.1376L84.0254 13.307C83.9523 13.6257 83.8195 13.9279 83.6269 14.2135C83.4343 14.4991 83.172 14.7282 82.8399 14.9009C82.5145 15.0735 82.1193 15.1599 81.6544 15.1599C81.1829 15.1599 80.7579 15.0603 80.3793 14.861C80.0074 14.6551 79.7119 14.363 79.4927 13.9844C79.2802 13.6059 79.1739 13.1575 79.1739 12.6395V12.5299C79.1739 12.0053 79.2802 11.557 79.4927 11.1851C79.7119 10.8066 80.0074 10.5177 80.3793 10.3184C80.7579 10.1126 81.1829 10.0096 81.6544 10.0096Z' fill='%230E0D0B'/%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M86.7515 10.0096C87.2097 10.0096 87.6149 10.1092 87.9668 10.3084C88.3188 10.501 88.5944 10.78 88.7937 11.1452C88.9929 11.5105 89.0925 11.9389 89.0925 12.4304V12.7889H85.1177C85.1377 13.3136 85.3071 13.7254 85.6258 14.0243C85.9446 14.3165 86.3431 14.4626 86.8212 14.4626C87.2396 14.4626 87.5617 14.3663 87.7875 14.1737C88.0133 13.9811 88.186 13.752 88.3056 13.4863L88.983 13.815C88.8833 14.0209 88.7439 14.2268 88.5646 14.4327C88.3919 14.6386 88.1628 14.8113 87.8772 14.9507C87.5983 15.0902 87.2396 15.1599 86.8013 15.1599C86.3099 15.1599 85.8782 15.057 85.5063 14.8511C85.1344 14.6386 84.8455 14.343 84.6396 13.9645C84.4337 13.5859 84.3307 13.1476 84.3307 12.6495V12.5299C84.3307 12.0252 84.4337 11.5836 84.6396 11.205C84.8455 10.8265 85.1311 10.5342 85.4963 10.3284C85.8616 10.1159 86.28 10.0096 86.7515 10.0096ZM86.7515 10.7069C86.3066 10.7069 85.9413 10.8331 85.6557 11.0855C85.3701 11.3378 85.1941 11.6898 85.1277 12.1414H88.2956C88.269 11.6898 88.113 11.3378 87.8274 11.0855C87.5485 10.8331 87.1898 10.7069 86.7515 10.7069Z' fill='%230E0D0B'/%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M97.1624 10.0096C97.6207 10.0096 98.0258 10.1092 98.3778 10.3084C98.7298 10.501 99.0054 10.78 99.2046 11.1452C99.4039 11.5105 99.5035 11.9389 99.5035 12.4304V12.7889H95.5287C95.5487 13.3136 95.718 13.7254 96.0368 14.0243C96.3555 14.3165 96.754 14.4626 97.2322 14.4626C97.6505 14.4626 97.9727 14.3663 98.1985 14.1737C98.4243 13.9811 98.5969 13.752 98.7165 13.4863L99.3939 13.815C99.2943 14.0209 99.1548 14.2268 98.9755 14.4327C98.8028 14.6386 98.5737 14.8113 98.2881 14.9507C98.0092 15.0902 97.6506 15.1599 97.2123 15.1599C96.7208 15.1599 96.2892 15.057 95.9172 14.8511C95.5453 14.6386 95.2564 14.343 95.0505 13.9645C94.8446 13.5859 94.7417 13.1476 94.7417 12.6495V12.5299C94.7417 12.0252 94.8446 11.5836 95.0505 11.205C95.2564 10.8265 95.542 10.5342 95.9073 10.3284C96.2725 10.1158 96.6909 10.0096 97.1624 10.0096ZM97.1624 10.7069C96.7175 10.7069 96.3522 10.8331 96.0666 11.0855C95.7811 11.3378 95.6051 11.6898 95.5387 12.1414H98.7066C98.68 11.6898 98.5239 11.3378 98.2383 11.0855C97.9594 10.8331 97.6008 10.7069 97.1624 10.7069Z' fill='%230E0D0B'/%3e%3cpath d='M92.2484 10.0594C92.6137 10.0594 92.9391 10.1358 93.2247 10.2885C93.5169 10.4413 93.7494 10.6671 93.9221 10.966C94.0947 11.2648 94.1811 11.6334 94.1811 12.0717V15.1458H93.394V12.1315C93.394 11.6467 93.2712 11.2947 93.0255 11.0755C92.7864 10.8564 92.461 10.7468 92.0492 10.7468C91.5777 10.7468 91.1925 10.8995 90.8936 11.205C90.6014 11.5105 90.4553 11.9655 90.4553 12.5698V15.1458H89.6683V10.1491H90.4354V10.9582H90.5361C90.7355 10.7018 90.8604 10.5342 91.1128 10.3483C91.3718 10.1557 91.7503 10.0594 92.2484 10.0594Z' fill='%230E0D0B'/%3e%3cpath d='M78.5932 10.9581H77.7681V10.1514H78.6L78.5932 10.9581Z' fill='%230E0D0B'/%3e%3c/svg%3e";const ic=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(","),Nn=({isOpen:e,onClose:t,title:n,subtitle:o,children:r,overlayContent:s,overlayDimmed:a=!0,styles:i,theme:l,maxWidth:c="522px",dark:d,footerLinkText:u,bannerSrc:f,bannerAlt:y,closeOnBackdropClick:m=!1})=>{const{theme:g,dark:h,dk:w,palette:x}=Vt(i,d),b=d??h,v=l||g,C=i?.fontFamily||v.typography.fontFamily||Ne.ui,k=i?.primaryColor||v.colors.primary,S=Z(null),F=Z(null),T=Z(null),E=Ai(),[M,B]=P(!1),[D,W]=P(!1),I=Z(t);if(ue(()=>{I.current=t},[t]),ue(()=>{if(!e){W(!1);return}F.current=document.activeElement;const z=document.body.style.overflow;document.body.style.overflow="hidden";const re=requestAnimationFrame(()=>{const X=requestAnimationFrame(()=>W(!0));T.current=X}),pe=()=>{const X=S.current;X&&(X.querySelectorAll(ic)[0]??X).focus({preventScroll:!0})},se=X=>{if(X.key==="Escape"){X.stopPropagation(),I.current();return}if(X.key!=="Tab")return;const Y=S.current;if(!Y)return;const _=Array.from(Y.querySelectorAll(ic)).filter(R=>!R.hasAttribute("aria-hidden"));if(_.length===0){X.preventDefault(),Y.focus();return}const j=_[0],ke=_[_.length-1],Se=document.activeElement;X.shiftKey&&Se===j?(X.preventDefault(),ke.focus()):!X.shiftKey&&Se===ke&&(X.preventDefault(),j.focus())},V=requestAnimationFrame(pe);return document.addEventListener("keydown",se),()=>{cancelAnimationFrame(V),cancelAnimationFrame(re),T.current&&cancelAnimationFrame(T.current),document.removeEventListener("keydown",se),document.body.style.overflow=z;const X=F.current;X&&typeof X.focus=="function"&&X.focus({preventScroll:!0})}},[e]),!e)return null;const O=!!f&&!M,U=y??"";return p("div",{onMouseDown:z=>{m&&z.target===z.currentTarget&&I.current()},style:{position:"fixed",inset:0,backgroundColor:b?"rgba(0,0,0,0.72)":"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",padding:"clamp(16px, 4vw, 48px)",zIndex:Io.modal,opacity:D?1:0,transition:`opacity ${Ps.normal} ${Po.out}`},children:p("div",{ref:S,role:"dialog","aria-modal":"true","aria-labelledby":E,tabIndex:-1,style:{backgroundColor:x.shellBorder,borderRadius:"12px",padding:"5px",width:"100%",maxWidth:c,boxSizing:"border-box",boxShadow:"0 16px 48px rgba(0, 0, 0, 0.4)",outline:"none",transform:D?"scale(1)":"scale(0.96)",transition:`transform ${Ps.slow} ${Po.out}`,display:"flex",flexDirection:"column",maxHeight:"100%"},children:A("div",{style:{backgroundColor:x.shell,border:`1px solid ${x.shellInnerBorder}`,borderRadius:"9px",width:"100%",padding:"0",display:"flex",flexDirection:"column",position:"relative",flex:"0 1 auto",minHeight:0,overflowY:"auto",overflowX:"hidden"},children:[s&&a&&p("div",{style:{position:"absolute",inset:0,backgroundColor:"rgba(0, 0, 0, 0.4)",zIndex:5,pointerEvents:"none",borderRadius:"12px"},"aria-hidden":"true"}),O&&A("div",{style:{position:"relative",width:"100%"},children:[p("img",{src:f,style:{width:"100%",height:"auto",display:"block",borderRadius:"6px 6px 0 0"},alt:U,"aria-hidden":U===""?"true":void 0,onError:()=>B(!0)}),p("button",{type:"button",onClick:t,"aria-label":"Close dialog",style:{position:"absolute",top:"8px",right:"8px",minWidth:"44px",minHeight:"44px",color:x.textPrimary,padding:"8px",backgroundColor:"transparent",borderRadius:"9999px",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1},children:p(Ar,{size:28,strokeWidth:2.5})})]}),A("div",{style:{padding:"28px 28px 0 28px",position:"relative"},children:[!O&&p("button",{type:"button",onClick:t,"aria-label":"Close dialog",style:{position:"absolute",top:"10px",right:"10px",minWidth:"44px",minHeight:"44px",color:x.textSecondary,padding:"10px",backgroundColor:"transparent",borderRadius:"50%",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background-color 0.2s",fontSize:"18px",fontWeight:"600"},onMouseEnter:z=>{z.currentTarget.style.backgroundColor=b?`${k}1a`:"#f3f4f6"},onMouseLeave:z=>{z.currentTarget.style.backgroundColor="transparent"},children:p(Ar,{size:24,strokeWidth:2.4})}),p("h2",{id:E,style:{fontSize:"22px",fontWeight:"700",color:x.textPrimary,margin:"0",fontFamily:C,lineHeight:"1.12"},children:n})]}),o&&p("div",{style:{padding:"11px 28px 13px 28px",fontSize:"12px",color:x.textSecondary,margin:"0",lineHeight:"1.35",fontFamily:C,borderBottom:b?`1px solid ${w.cardBorder}`:"1px solid #cdcfd1"},children:o}),r,A("div",{style:{padding:"12px 28px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[p("img",{src:ac,alt:"","aria-hidden":"true",width:108,height:22,decoding:"async",style:{width:"108px",height:"22px",opacity:b?.85:1,filter:b?"brightness(0) invert(1)":"none",margin:0,display:"block"}}),p("a",{href:"https://spiceflow-docs.spicenet.io",target:"_blank",rel:"noopener noreferrer",style:{fontSize:"10px",color:x.textSecondary,textDecoration:"none",display:"flex",alignItems:"center",gap:"4px",fontFamily:C,lineHeight:"1"},children:p("span",{style:{color:k,textDecoration:"underline",fontWeight:"500"},children:u??"Learn more \u2192"})})]}),s]})})})},lc=({dk:e,dark:t,message:n,buttonLabel:o,onAction:r,disabled:s=!1})=>A("div",{style:{padding:"12px",backgroundColor:e.warningBg,borderRadius:"8px",border:`1px solid ${e.warningBorder}`},children:[p("p",{style:{margin:"0 0 10px 0",color:e.warningText,fontSize:"14px"},children:n}),p("button",{onClick:r,disabled:s,style:{width:"100%",padding:"8px 12px",borderRadius:"6px",border:`1px solid ${t?e.warningBorder:"#fbbf24"}`,backgroundColor:t?e.cardBg:"white",cursor:s?"not-allowed":"pointer",fontWeight:600,fontSize:"13px",color:e.warningText,opacity:s?.6:1},children:o})]}),cc=({dk:e,dark:t,borderRadius:n,children:o})=>p("div",{style:{padding:"8px 12px",marginBottom:"8px",backgroundColor:t?e.warningBg:"#fffbeb",border:`1px solid ${e.warningBorder}`,borderRadius:n,fontSize:"12px",color:e.warningText,lineHeight:"1.4"},children:o});async function dc(e,t,n){let o=null;try{const r=await e.request({method:"eth_chainId"});o=parseInt(r,16)}catch{o=null}o!==t&&(n?.(),await vi(e,t))}function uc(e){let t=e;const n=new Set;for(;t&&typeof t=="object"&&!n.has(t);){if(n.add(t),t.code===4001)return!0;t=t.cause}return!1}async function Fa(e){const t=e.provider??await e.wallet?.getEthereumProvider();if(!t)throw new Error("External wallet provider not available");await dc(t,e.chainId,e.onSwitch);const n=await t.request({method:"eth_accounts"});if(!Array.isArray(n)||!n.some(r=>typeof r=="string"&&r.toLowerCase()===e.account.toLowerCase()))throw new Error("The connected source wallet changed. Reconnect the selected account before funding.");const o=nt(e.chainId)?.viemChain;return{extWc:Qs({account:e.account,chain:o,transport:js(t)}),viemChain:o}}async function pc(e,t,n){const o=Date.now()+1e4;for(;Date.now()<o;){let r,s;try{r=await Promise.race([Promise.all([t.getBlockNumber({cacheTime:0}),e.request({method:"eth_blockNumber"}).then(BigInt)]),new Promise(a=>{s=setTimeout(()=>a(null),Math.max(0,o-Date.now()))})])}catch{return}finally{clearTimeout(s)}if(!r||Date.now()>=o||r.every(a=>a>=n))return;await new Promise(a=>setTimeout(a,Math.min(250,o-Date.now())))}}async function hf(e){let t;for(const[n,o]of e.calls.entries()){await e.observer?.onSending?.(n);let r;try{r=await e.extWc.sendTransaction({to:o.to,data:o.data,value:o.value,chain:e.viemChain})}catch(i){throw uc(i)&&e.observer?.onRejected?.(n),i}e.observer?.onSubmitted?.(n,r);const s=await fs({client:e.client,hash:r,call:o,onRepriced:i=>e.observer?.onSubmitted?.(n,i),onCancelled:()=>e.observer?.onReverted?.(n,r)});r=s.hash;const a=s.receipt;if(a.status!=="success")throw e.observer?.onReverted?.(n,r),new Error(e.errorMessage);await pc(e.extWc,e.client,a.blockNumber),e.observer?.onConfirmed?.(n,r),t=r}return t}async function fc(e){const t=await e.client.estimateFeesPerGas(),n=t.maxFeePerGas??t.gasPrice;if(typeof n!="bigint"||n<=0n)throw new Error("Network gas could not be priced.");let o=0n;for(const r of e.calls){const s=await e.client.estimateGas({account:e.account,...r});o+=(s*n*120n+99n)/100n}return o}function ys(e,t,n,o){return n?{to:e,value:o,data:"0x"}:{to:t,value:0n,data:Tt({abi:ot,functionName:"transfer",args:[e,o]})}}async function mc(e){const t=ys(e.recipient,e.token,e.isNative,e.amount),[n,o]=await Promise.all([e.client.estimateGas({account:e.account,...t}),e.client.estimateFeesPerGas()]),r=o.maxFeePerGas??o.gasPrice;if(typeof r!="bigint"||r<=0n)throw new Error("Source transaction gas could not be priced.");return(n*r*120n+99n)/100n}function Ta(e,t){return t.isNative?e.sendTransaction({to:t.recipient,value:t.amount,chain:t.viemChain}):e.sendTransaction({to:t.tokenAddr,data:Tt({abi:ot,functionName:"transfer",args:[t.recipient,t.amount]}),chain:t.viemChain})}async function gf(e){const{extWc:t,sourceClient:n,recipient:o,tokenAddr:r,isNative:s,amount:a}=e;if(a<=0n)return;await e.observer?.onSending?.(0);let i;try{i=await Ta(t,{recipient:o,tokenAddr:r,isNative:s,amount:a,viemChain:e.viemChain})}catch(d){throw uc(d)&&e.observer?.onRejected?.(0),d}e.observer?.onSubmitted?.(0,i);const l=await fs({client:n,hash:i,call:ys(o,r,s,a),onRepriced:d=>e.observer?.onSubmitted?.(0,d),onCancelled:()=>e.observer?.onReverted?.(0,i)});i=l.hash;const c=l.receipt;if(c.status!=="success")throw e.observer?.onReverted?.(0,i),new Error("Embedded wallet funding failed");await pc(t,n,c.blockNumber),e.observer?.onConfirmed?.(0,i)}function hc({escrowAddress:e,tokenAddress:t,isNative:n,amount:o,gasFeeAmount:r}){const s=(a,i)=>n?{to:a,value:i,data:"0x"}:{to:t,value:0n,data:Tt({abi:ot,functionName:"transfer",args:[a,i]})};return[s(e,o),...r>0n?[s(Zt,r)]:[]]}function yf({sourceChainId:e,selectedAsset:t,destinationChainId:n,destinationTokenAddress:o,isCrossDenomination:r,convertedUsdAmount:s}){const a=dt(t.asset.address),i=o;let l,c;if(i&&n)if(l=jr[n]?.supportedTokens?.find(d=>oe(d.address,i))?.decimals??t.asset.decimals,r){if(!s)throw new Error("Destination amount is still being calculated. Please retry in a moment.");c=s}else{const d=Cn(t.amount,t.asset.decimals);c=Vn(d,t.asset.decimals,l)}return{sourceChainId:e,depositTokenAddress:a,depositAmount:t.amount,depositTokenDecimals:t.asset.decimals,destinationChainId:n,destinationTokenAddress:i,destinationAmount:c,destinationTokenDecimals:l}}async function wf(e,t){if(!e)return[];if(Array.isArray(e))return e;const n=e;return e.length>=2?n(t.depositAmount,t.depositTokenAddress):n(t)}function gc(e,t){return!!e&&e.quotedAmount===t.amount&&e.chainId===t.chainId&&oe(e.token,t.token)}async function ws(e,t){const n=await Ta(e,{recipient:t.recipient,tokenAddr:t.tokenAddr,isNative:t.isNative,amount:t.amount});t.afterSend?.(n);const o=bt(t.chainId),{receipt:r,hash:s}=await fs({client:o,hash:n,call:ys(t.recipient,t.tokenAddr,t.isNative,t.amount),confirmations:2});if(r.status!=="success")throw new Error(t.failureMessage);return t.settle&&await o.getBlockNumber()-r.blockNumber<2n&&await Qn(3e3),s}async function xf(e){const t=e.selectedDepositAssets.filter(r=>r.asset&&r.amount&&parseFloat(r.amount)>0);if(t.length===0){console.error("[DepositModal] No valid assets for deposit"),e.setError("Please select an asset and enter an amount");return}const n=t[0];if(!e.escrowOnly&&!e.sourceAddress){e.setError("External wallet not connected. Please connect your wallet in the previous step.");return}if(!e.isNon7702){if(!e.address||!e.embeddedWalletAddress){e.setError("Couldn't find your account wallet. Try reconnecting.");return}if(!e.isReady||!e.isAuthenticated){e.setError("Sign in to continue.");return}}if(e.zeroCreditError){e.setError(e.zeroCreditError);return}if(e.depositBalanceError){e.setError(e.depositBalanceError);return}if(e.isNon7702&&e.sponsorGas&&e.nativeChainId&&n.asset.chainId!==e.nativeChainId&&e.destinationTokenAddress){e.setError("Gas sponsorship is not supported for this deposit route. Disable sponsorGas to continue.");return}e.setIsExecuting(!0),e.setError(null);let o=!1;try{const r=n.asset.chainId,s=ro(r),a=Cn(n.amount,n.asset.decimals),i=t.length===1&&gc(e.effectiveDepositFee,{amount:a,token:dt(n.asset.address),chainId:r}),l=!e.isNon7702&&!e.escrowOnly&&!wo(n.asset);if(!e.isNon7702&&t.length===1&&!l&&!i)throw new Error("Fee quote is out of date. Please wait for it to refresh.");let c=e.externalWalletClient;if(!e.escrowOnly){if(!c)throw new Error("External wallet not connected");if(e.externalProvider){const d=await Fa({provider:e.externalProvider,account:e.sourceAddress,chainId:r});d.viemChain&&(c=d.extWc)}}if(e.isNon7702){if(!c)throw new Error("External wallet not connected");if(!e.sourceAddress)throw new Error("External wallet address not available");if(e.nativeChainId&&r===e.nativeChainId){const d=nt(r),u=t.map(y=>`${y.amount} ${y.asset.symbol}`).join(", ");e.setConfirmationData({network:d?.displayName||`Chain ${r}`,amount:u,symbol:"",chainId:r}),e.setShowConfirmation(!0);let f=null;e.setDirectDepositStatus("processing"),e.setDirectDepositChainId(r);for(const y of t){const m=Cn(y.amount,y.asset.decimals),g=dt(y.asset.address),h=y.asset.isNative||be(g),w=await ws(c,{chainId:r,recipient:s,tokenAddr:g,isNative:h,amount:m,failureMessage:`Escrow deposit failed for ${y.asset.symbol}`});f=w,e.setDirectDepositTxHash(w)}if(t[0]?.amount){const y=t[0].amount;if(e.onDepositExecute){e.setPostDepositStatus("executing");try{await e.onDepositExecute(y),e.setPostDepositStatus("success")}catch(g){console.error("ctx.onDepositExecute failed:",g),e.setPostDepositStatus("error"),e.setPostDepositError(g?.message||"Post-deposit instruction failed")}}else e.setPostDepositStatus("success");e.setDirectDepositStatus("success"),e.setPostDepositAmount(y),e.setPostDepositSuccess(!0);const m={type:"deposit",status:"success",amount:y,asset:t[0].asset.symbol,sourceChain:d?.displayName||`Chain ${r}`,txHash:f??void 0};window.dispatchEvent(new CustomEvent("spiceflow:action",{detail:m})),e.onDepositSuccess?.(m)}e.refreshAssets(),e.onDepositSelect&&e.onDepositSelect(t[0].asset)}else{const d=e.destinationChainId||e.nativeChainId;if(!d)throw new Error("Destination chain ID is required for non-7702 mode. Either pass ctx.destinationChainId to <SpiceDeposit> or set ctx.nativeChainId on <SpiceFlowProvider>.");const u=bi(r),f=s,y=[];let m=null;for(const g of t){const h=Cn(g.amount,g.asset.decimals),w=dt(g.asset.address),x=g.asset.isNative||be(w),b=await ws(c,{chainId:r,recipient:f,tokenAddr:w,isNative:x,amount:h,failureMessage:`Transfer failed for ${g.asset.symbol}`,settle:!0});m||(m=b),e.depositDataRef.current||(e.depositDataRef.current=[]),e.depositDataRef.current.push({txHash:b,sender:e.sourceAddress,tokenAddress:w,chainId:r,amount:h.toString(),user:e.spiceBalanceUser}),y.push({tokenAddress:w,tokenAmount:h.toString(),sender:e.sourceAddress,receiver:f})}if(!m)throw new Error("No transaction hash generated");if(!e.destinationTokenAddress){const g={type:"deposit",status:"success",amount:t[0]?.amount,asset:t[0]?.asset?.symbol,sourceChain:Tn(r),txHash:m};window.dispatchEvent(new CustomEvent("spiceflow:action",{detail:g})),e.onDepositSuccess?.(g),e.depositDataRef.current=null,e.bridgedAmountRef.current=t[0]?.amount||null,e.refreshAssets(),e.onDepositSelect&&e.onDepositSelect(t[0].asset),e.setShowConfirmation(!1);return}if(e.mode==="ondemand"){const g={to:u,value:BigInt(0),data:"0x"},h=await Vr(d,e.destinationTokenAddress);let w=BigInt(0);for(const E of y){const M=BigInt(E.tokenAmount),B=dt(E.tokenAddress),D=t.find(I=>{const O=dt(I.asset.address);return oe(O,B)}),W=D?D.asset.decimals:await Vr(r,Dt);w+=Vn(M,W,h)}e.isCrossDenomination&&e.convertedUsdAmount&&(w=e.convertedUsdAmount);const x={chainId:r,tokenTransfers:y.map(E=>({from:E.sender,to:E.receiver,token:E.tokenAddress,amount:BigInt(E.tokenAmount)})),call:g},b=e.isCrossDenomination&&e.convertedUsdAmount?[{from:e.sourceAddress,to:s,token:dt(t[0].asset.address),amount:Cn(t[0].amount,t[0].asset.decimals)}]:[],v={chainId:d,tokenTransfers:[...b,{from:"escrow",to:e.sourceAddress,token:e.destinationTokenAddress,amount:w}],call:{to:e.destinationTokenAddress,value:BigInt(0),data:"0x"}},C={mode:"non-7702:on-demand",chainBatches:[x,v]},k={user:e.sourceAddress,intents:[C]},S=await yt.createAction(k),F=S.actionId,T=S.intentIds[0];if(!m)throw new Error("No transaction hash available");e.startStatusPolling(T,Ci([{chainId:r,calls:[g]},{chainId:d,calls:[v.call]}],E=>Tn(E))),await yt.executeStep(F,0,0,{action:"execute",hash:m}),t[0]?.amount&&(e.bridgedAmountRef.current=t[0].amount),e.refreshAssets(),e.onDepositSelect&&e.onDepositSelect(t[0].asset),e.setShowConfirmation(!1)}else throw new Error("Presign mode not yet fully supported for cross-chain deposits")}}else{const d=[];let u=0,f;const y=i&&e.effectiveDepositFee?Ee(e.effectiveDepositFee.net,n.asset.decimals):n?.amount;for(const E of t){const M=Cn(E.amount,E.asset.decimals),B=i&&E===n,D=B?e.effectiveDepositFee.fee:0n,W=B?e.effectiveDepositFee.net:M,I=e.escrowOnly?M:M+D,O=dt(E.asset.address),U=E.asset.isNative||be(O);if(!e.escrowOnly&&!wo(E.asset)){e.setDirectDepositStatus("processing"),e.setDirectDepositChainId(r);const z=await ws(c,{chainId:r,recipient:e.address,tokenAddr:O,isNative:U,amount:M,failureMessage:`Transfer to embedded wallet failed for ${E.asset.symbol}`});u+=1,E===n&&(f=z);continue}e.escrowOnly||await ws(c,{chainId:r,recipient:e.address,tokenAddr:O,isNative:U,amount:I,failureMessage:`Transfer to embedded wallet failed for ${E.asset.symbol}`,afterSend:()=>Tp({chainId:r,tokenAddress:dt(E.asset.address),tokenSymbol:E.asset.symbol,tokenDecimals:E.asset.decimals,amount:E.amount,rawAmount:M.toString(),embeddedWalletAddress:e.address,externalWalletAddress:e.sourceAddress,timestamp:Date.now(),isNative:U}),settle:!0}),d.push(...hc({escrowAddress:s,tokenAddress:O,isNative:U,amount:W,gasFeeAmount:D}))}if(d.length===0){e.setDirectDepositTxHash(f??null),e.setDirectDepositStatus("success");const E={type:"deposit",status:"success",amount:n.amount,asset:n.asset.symbol,sourceChain:Tn(r),txHash:f};window.dispatchEvent(new CustomEvent("spiceflow:action",{detail:E})),e.onDepositSuccess?.(E),e.refreshAssets(),e.onDepositSelect&&e.onDepositSelect(n.asset);return}u>0&&e.setDirectDepositStatus("idle");const m=t.find(E=>e.escrowOnly||wo(E.asset))??n,g=await bt(r).getBlockNumber(),h=d.map(E=>({...E,to:Yt(E.to)})),w={chainId:r,recentBlock:g,calls:h,tokenTransfers:[]},x=yf({sourceChainId:r,selectedAsset:m===n&&y?{...n,amount:y}:m,destinationChainId:e.destinationChainId,destinationTokenAddress:e.destinationTokenAddress,isCrossDenomination:e.isCrossDenomination,convertedUsdAmount:e.convertedUsdAmount}),b=await wf(e.depositBatches,x),v=[w,...b];if(!e.address)throw new Error("Address not available");const C=[];if(e.isCrossDenomination&&e.convertedUsdAmount&&e.destinationTokenAddress){const E=e.selectedDepositAssets[0]?.asset;if(E){const M=Cn(e.selectedDepositAssets[0].amount,E.decimals);C.push({from:e.address,to:s,token:dt(E.address),amount:M}),C.push({from:"escrow",to:e.address,token:e.destinationTokenAddress,amount:e.convertedUsdAmount})}}C.length>0&&v[1]&&(v[1].tokenTransfers=C);const k=Ci(v,E=>Tn(E));let S=!1;const F=await e.execution.execute(v,Dt,0n,E=>{if(E.intentId&&!S){S=!0;for(const M of t)xa(e.address,r,dt(M.asset.address));e.startStatusPolling(E.intentId,k)}},void 0,{userOverride:e.address,useCustomTransfers:!0,skipPreSubmitFeeEstimate:!0,skipUserFundingPreflight:!0});if(e.refreshAssets(),e.onDepositExecute&&m.amount)try{e.setPostDepositStatus("executing"),await e.onDepositExecute(y||m.amount),e.setPostDepositStatus("success"),e.setPostDepositAmount(y||m.amount),e.setPostDepositSuccess(!0)}catch(E){console.error("ctx.onDepositExecute failed (7702):",E),e.setPostDepositStatus("error"),e.setPostDepositError(E?.message||"Post-deposit instruction failed");return}const T={type:"deposit",status:"success",amount:m===n&&y||m.amount,asset:m.asset.symbol,sourceChain:Tn(r),txHash:/^0x[0-9a-f]{64}$/i.test(F??"")?F:void 0};window.dispatchEvent(new CustomEvent("spiceflow:action",{detail:T})),e.onDepositSuccess?.(T),e.onDepositSelect&&e.onDepositSelect(m.asset)}}catch(r){o=!0,console.error("[DepositModal] executeDeposit CAUGHT ERROR:",r),console.error("[DepositModal] Error details:",{message:r?.message,code:r?.code,name:r?.name,stack:r?.stack?.slice(0,500)}),e.setError(Dn(r,"Deposit failed")),e.clearStatus()}finally{e.setIsExecuting(!1),o&&e.setDirectDepositStatus("idle"),o||!e.getCurrentIntentStatus()&&e.getCurrentPostDepositStatus()!=="idle"||e.setShowConfirmation(!1)}}async function bf(e){const{asset:t,assetIndex:n,selectedAssetCount:o,address:r,escrowOnly:s,isNon7702:a}=e;if(n!==0||a||o>1||!r||t.balance<=0n)return null;if(!s&&!wo(t))return ir(t.balance,t.decimals);const i=await Ba({address:r,depositQuote:{asset:t,amount:t.balance,token:dt(t.address),chainId:t.chainId},escrowOnly:s}),l=s?t.balance:t.balance>i.fee?t.balance-i.fee:0n;return ir(l,t.decimals)}async function Ba(e){const{address:t,depositQuote:n,escrowOnly:o}=e,{asset:r,amount:s,token:a,chainId:i}=n,l=ro(i),c=r.isNative||be(a),d=s>1n?1n:0n,u=[c?{to:l,value:s,data:"0x"}:{to:a,value:0n,data:Tt({abi:ot,functionName:"transfer",args:[l,s]})}];d>0n&&u.push(c?{to:Zt,value:d,data:"0x"}:{to:a,value:0n,data:Tt({abi:ot,functionName:"transfer",args:[Zt,d]})});const f={chainId:i,tokenTransfers:[],calls:u},y=(await yt.estimateBatchGas({user:t,outputToken:a,chainBatches:[{...f,hash:Gn([f])[0].hash}],signal:e.signal})).gasFee,m=o&&y<s?s-y:s;return{fee:y,net:m,quotedAmount:s,token:a,chainId:i}}function vf(e,t=40,n=18){const o=e.length,r=[{maxLength:7,shrink:0},{maxLength:10,shrink:6},{maxLength:13,shrink:12},{maxLength:16,shrink:16},{maxLength:20,shrink:19}].find(s=>o<=s.maxLength);return Math.max(n,t-(r?.shrink??22))}const Fo=({value:e,element:t="span",placeholder:n,ariaLabel:o,ariaInvalid:r,disabled:s,onChange:a,inputMode:i="decimal",autoComplete:l="off",dataSpiceflowFocus:c,fontFamily:d,fontWeight:u=700,color:f,textAlign:y,lineHeight:m=1,maxFontSize:g=40,minFontSize:h=18,overflow:w="ellipsis",title:x,style:b})=>{const v=Z(null),[C,k]=P(),S=vf(e||n||"",g,h),F=e||n||"";ue(()=>{const M=v.current;if(!M||w!=="ellipsis"){k(void 0);return}let B=!0,D=null;const W=()=>{if(!B)return;const O=getComputedStyle(M),U=M.clientWidth-parseFloat(O.paddingLeft||"0")-parseFloat(O.paddingRight||"0");if(!(U>0))return;if(!D){try{D=document.createElement("canvas").getContext("2d")}catch{return}if(!D)return}D.font=`${O.fontStyle} ${O.fontWeight} ${S}px ${O.fontFamily}`;const z=D.measureText(F),re=Math.max(z.width,(z.actualBoundingBoxLeft||0)+(z.actualBoundingBoxRight||0))+(parseFloat(O.letterSpacing)||0)*Math.max(0,F.length-1),pe=re>U?S*Math.max(0,U-1)/re:void 0;k(se=>se===pe?se:pe)};W();const I=typeof ResizeObserver>"u"?void 0:new ResizeObserver(W);return I?.observe(M),I||window.addEventListener("resize",W),document.fonts?.addEventListener("loadingdone",W),()=>{B=!1,I?.disconnect(),I||window.removeEventListener("resize",W),document.fonts?.removeEventListener("loadingdone",W)}},[F,S,d,u,w,t,b?.fontFamily,b?.fontStyle,b?.fontWeight,b?.letterSpacing,b?.paddingLeft,b?.paddingRight]);const T=w==="wrap"?{overflowWrap:"anywhere",wordBreak:"break-word",whiteSpace:"normal"}:w==="ellipsis"?{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}:{},E={fontFamily:d,fontSize:`${Math.min(S,C??S)}px`,fontWeight:u,color:f,lineHeight:m,letterSpacing:0,textAlign:y,minWidth:0,maxWidth:"100%",...T,...b};return t==="input"?p("input",{ref:v,type:"text",inputMode:i,autoComplete:l,"aria-label":o,"aria-invalid":r||void 0,"data-spiceflow-focus":c||void 0,value:e,onChange:a,placeholder:n,disabled:s,title:x,style:{backgroundColor:"transparent",border:"none",outline:"none",padding:0,width:"100%",...E}}):p(t,{ref:v,title:x,style:E,children:e})},Oa=({pct:e,isMax:t,primaryColor:n,dark:o,fillColor:r})=>{const s=e/100;return A("svg",{width:"14",height:"14",viewBox:"0 0 14 14",children:[p("circle",{cx:"7",cy:"7",r:"6.84375",fill:t?n:"none",stroke:t?n:o?"#4a5568":"#3C3E42",strokeWidth:"0.3125"}),!t&&s>0&&p("path",{d:`M 7 7 L 7 0.15625 A 6.84375 6.84375 0 ${s>.5?1:0} 1 ${7+6.84375*Math.sin(s*2*Math.PI)} ${7-6.84375*Math.cos(s*2*Math.PI)} Z`,fill:r})]})},yc=({chainId:e,name:t,size:n=16})=>{const o=e&&(yo[e]||Bi(e)?.logo)||"";return o?p("img",{src:o,alt:t||`Chain ${e}`,loading:"lazy",decoding:"async",width:n,height:n,style:{width:`${n}px`,height:`${n}px`,borderRadius:"50%",objectFit:"cover",flexShrink:0}}):null},Cf={1:"ethereum",56:"binance-smart-chain",137:"polygon-pos",143:"monad",4114:"citrea",4663:"robinhood",8453:"base",42161:"arbitrum-one"},kf=6e4,Er=new Map;function wc(e,t){return Er.get(e)?.logos?.get(t.toLowerCase())}function If(e,t){const n=Cf[e];if(!n||be(t))return;const o=Er.get(e);if(o?.logos||o?.pending)return o.pending;if(o?.failedAt!==void 0&&Date.now()-o.failedAt<kf)return;const r=Promise.resolve().then(async()=>{try{const s=await fetch(`https://tokens.coingecko.com/${n}/all.json`,{signal:AbortSignal.timeout(1e4)});if(!s.ok)throw new Error("Token list request failed");const a=await s.json(),i=new Map;for(const l of a?.tokens??[])l?.address&&l?.logoURI&&i.set(String(l.address).toLowerCase(),l.logoURI);Er.set(e,{logos:i})}catch(s){console.warn(`[tokenLogos] Token list unavailable for chain ${e}`,s),Er.set(e,{failedAt:Date.now()})}});return Er.set(e,{...o,pending:r}),r}function Ra(e,t,n){const[o,r]=P(),s=e||e===null||t===void 0||!n?void 0:`${t}:${n.toLowerCase()}`,a=s?wc(t,n):void 0;return ue(()=>{if(!s||a||t===void 0||!n)return;let i=!0;const l=()=>{const d=wc(t,n);i&&d&&r({token:s,logo:d})},c=If(t,n);return c?c.then(l):l(),()=>{i=!1}},[s,a,t,n]),e||a||(o&&o.token===s?o.logo:void 0)}const xs=({symbol:e,label:t,logoURI:n,chainId:o,address:r,size:s=20,theme:a})=>{const{theme:i}=Vt(),l=a||i,[c,d]=P(),u={width:`${s}px`,height:`${s}px`,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${s*.4}px`,fontWeight:l.typography.fontWeight.bold,flexShrink:0,overflow:"hidden",backgroundColor:"#ffffff"},f=Ra(n===null?null:n||ua[e.toUpperCase()],o,r);if(n===null)return null;if(f&&f!==c)return p("img",{src:f,alt:t??e,loading:"lazy",decoding:"async",style:{...u,objectFit:"cover"},onError:()=>d(f)});const y=Sf(e);return p("div",{style:{...u,...y.style},children:y.icon})},Sf=e=>{const t=e.toUpperCase(),n={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"}}[t];if(n)return{style:{backgroundColor:n.bg,color:n.text},icon:n.icon||t.charAt(0)};const o=t.split("").reduce((i,l)=>l.charCodeAt(0)+((i<<5)-i),0),r=Math.abs(o)%360,s=`hsl(${r}, 60%, 50%)`,a=r>180?"#FFFFFF":"#000000";return{style:{backgroundColor:s,color:a},icon:t.charAt(0)}},Af=({selectedAsset:e,assets:t,onAssetSelect:n,showDropdown:o,onToggleDropdown:r,disabled:s=!1,theme:a,onViewAllAssets:i,getAvailableBalance:l})=>{const c=jn(),d=I=>{const O=l?l(I):I.balance;return O===void 0?"...":Gr({balance:O,decimals:I.decimals})},{theme:u}=Vt(),f=a||u,y=Z(null),m=Z(null),g=Z(null),[h,w]=P(null);ue(()=>{if(o&&m.current){const I=()=>{if(m.current){const O=m.current.getBoundingClientRect();w({top:O.bottom+6,right:window.innerWidth-O.right})}};return I(),window.addEventListener("scroll",I,!0),window.addEventListener("resize",I),()=>{window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I)}}else w(null)},[o]),ue(()=>{const I=O=>{y.current&&!y.current.contains(O.target)&&g.current&&!g.current.contains(O.target)&&o&&r()};return o&&document.addEventListener("mousedown",I),()=>{document.removeEventListener("mousedown",I)}},[o,r]);const[x,b]=P(!1),v=f.mode==="light",C={backgroundColor:"transparent",border:`1px solid ${v?"#aaaaaa":f.colors.border}`,borderRadius:"6px",color:f.colors.text,cursor:s?"not-allowed":"pointer",padding:"8px 14px 8px 10px",width:"100%",display:"flex",flexDirection:"column",gap:"4px",opacity:s?.6:1,transition:Mn.interactive,transform:x?"scale(0.98)":"scale(1)"},k={display:"flex",justifyContent:"space-between",alignItems:"center",gap:"10px",minWidth:0},S={display:"flex",alignItems:"center",gap:"4px",paddingTop:"4px",borderTop:`1px solid ${f.colors.border}`},F=()=>h?{position:"fixed",top:`${h.top}px`,right:`${h.right}px`,backgroundColor:f.colors.secondary,border:`1px solid ${f.colors.border}`,borderRadius:f.borderRadius.md,boxShadow:f.shadows.lg,zIndex:Io.dropdown,width:"200px",maxHeight:"300px",overflow:"auto"}:{},T={backgroundColor:"transparent",border:"none",color:f.colors.text,cursor:"pointer",padding:f.spacing.sm,width:"100%",display:"flex",alignItems:"center",gap:f.spacing.sm,transition:`background-color ${f.animation.normal}`,":hover":{backgroundColor:f.colors.surfaceHover}},E={display:"flex",flexDirection:"column",alignItems:"flex-start",flex:1},M={fontSize:f.typography.fontSize.sm,fontWeight:f.typography.fontWeight.medium},B={fontSize:f.typography.fontSize.xs,color:f.colors.textMuted},D={backgroundColor:"transparent",border:"none",borderTop:`1px solid ${f.colors.border}`,color:f.colors.primary,cursor:"pointer",padding:"10px 12px",width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",fontFamily:f.typography.fontFamily,fontSize:f.typography.fontSize.xs,fontWeight:f.typography.fontWeight.medium,textDecoration:"underline",textUnderlineOffset:"2px"},W={transition:`transform ${f.animation.normal}`,transform:o?"rotate(180deg)":"rotate(0deg)",flexShrink:0};return A(nn,{children:[p("div",{style:{position:"relative"},ref:y,children:A("div",{ref:m,style:C,onClick:s?void 0:r,onMouseLeave:()=>{b(!1)},onMouseDown:()=>b(!0),onMouseUp:()=>b(!1),children:[A("div",{style:k,children:[p("div",{style:{display:"flex",alignItems:"center",gap:"8px",flex:1,minWidth:0},children:e?.asset?A(nn,{children:[p(xs,{symbol:e.asset.symbol,label:c(e.asset).symbol,logoURI:c(e.asset).logoURI,chainId:e.asset.chainId,address:e.asset.address,theme:f,size:24}),p("span",{style:{fontSize:"15px",fontWeight:500,color:f.colors.text,lineHeight:"1.5",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c(e.asset).symbol})]}):p("span",{style:{fontSize:"14px",color:f.colors.textMuted},children:"Select"})}),p("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:v?f.colors.textMuted:"#c7ccd4",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:W,children:p("path",{d:"M6 9l6 6 6-6"})})]}),e?.asset&&A("div",{style:S,children:[!e.asset.displayChainName&&p(yc,{chainId:e.asset.chainId,theme:f}),p("span",{style:{fontSize:"11px",color:f.colors.textMuted},children:Ns(e.asset)})]})]})}),o&&h&&Ys(A("div",{ref:g,style:F(),children:[t.length===0&&p("div",{style:{padding:"10px 12px",color:f.colors.textMuted,fontSize:f.typography.fontSize.xs},children:"No assets available"}),t.map(I=>A("button",{style:T,onClick:()=>{n(I),r()},children:[p(xs,{symbol:I.symbol,label:c(I).symbol,logoURI:c(I).logoURI,chainId:I.chainId,address:I.address,theme:f},Ce(I)),A("div",{style:E,children:[A("div",{style:{display:"flex",alignItems:"center",gap:f.spacing.xs},children:[p("span",{style:M,children:c(I).symbol}),!I.displayChainName&&p(yc,{chainId:I.chainId,theme:f})]}),A("span",{style:B,children:[d(I)," \u2022 ",Ns(I)]})]})]},Ce(I))),i&&A("button",{type:"button",style:D,onClick:()=>{r(),i()},children:[p("span",{children:"View all assets"}),A("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[p("path",{d:"M5 12h14"}),p("path",{d:"M13 5l7 7-7 7"})]})]})]}),document.body)]})},Ef=({assets:e,selectedAsset:t,onAssetSelect:n,onAmountChange:o,disabled:r=!1,loading:s=!1,label:a="Select Asset",showBalance:i=!0,showMaxButton:l=!0,placeholder:c="0.0",theme:d,styles:u,maxAmount:f,resolveMaxAmount:y,getAvailableBalance:m,hideAmountInput:g=!1,displayAmount:h,dark:w,onViewAllAssets:x})=>{const b=jn(),{theme:v,primaryColor:C,dark:k,dk:S}=Vt(u,w),F=d||v,T=w??k,[E,M]=P(!1),[B,D]=P(null),[W,I]=P(null),[O,U]=P(!1),[z,re]=P(null),[pe,se]=P(t?.amount||""),V=Z(0),X=t?.asset?Ce(t.asset):"",Y=t?.asset?m?m(t.asset):t.asset.balance:void 0,_=z??f;Ao(()=>()=>{V.current++},[]),Ao(()=>{V.current++,se(t?.amount||""),U(!1)},[X,t?.amount]),Ao(()=>{V.current++,re(null),U(!1)},[X,t?.asset.owner,t?.asset.decimals,t?.asset.balance,Y,f,y,r,s]);const j=()=>{V.current++,U(!1)},ke=()=>{const L=t?.asset;if(!L||Y===void 0)return;if(!_)return Y;const N=Cn(_,L.decimals);return N<Y?N:Y},Se=L=>{se(L),o?.(L)},R=L=>{j();const N=t?.asset,$=Kr(L.startsWith(".")?`0${L}`:L,N?.decimals);if(!N||!$)return Se($);const de=Cn($,N.decimals),J=ke();Se(J!==void 0&&de>J?Ee(J,N.decimals):$)},G=async()=>{const L=t?.asset;if(!L||r||s||Y===void 0)return;const N=++V.current,$=()=>V.current===N,de=y;if(z!==null){const ee=ke();ee!==void 0&&Se(Ee(ee,L.decimals));return}if(de){U(!0);try{const ee=await de(L);if(!$())return;if(ee!==null){const Be=Kr(ee,L.decimals),we=ke();if(!Be||we===void 0)return;const ge=Cn(Be,L.decimals)>we?Ee(we,L.decimals):Be;re(ge),Se(ge);return}return}catch(ee){$()&&console.warn("[AssetSelector] Failed to resolve max amount:",ee);return}finally{$()&&U(!1)}}const J=ke();$()&&J!==void 0&&Se(Ee(J,L.decimals))},K=async L=>{if(!t||r||Y===void 0)return;if(L===100)return G();j();const N=ke();N!==void 0&&Se(Ee(N*BigInt(L)/100n,t.asset.decimals))},Q=t&&Y!==void 0?Number(Ee(Y,t.asset.decimals)):0,he=parseFloat(pe)||0,ve=Q>0?he/Q*100:0,Fe={backgroundColor:u?.assetSelector?.backgroundColor||u?.secondaryBackground||(T?S.cardBg:"#e9e9e9"),border:T?`0.5px solid ${S.cardBorder}`:"0.5px solid #A8A8A7",borderRadius:u?.assetSelector?.borderRadius||"6px",padding:u?.assetSelector?.padding||"16px",height:"auto",minHeight:g?void 0:"144px",display:"flex",flexDirection:"column",gap:"8px",position:"relative",opacity:r?.6:1};return s?p("div",{style:Fe,children:A("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[A("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[p("div",{style:{backgroundColor:T?S.hoverBg:"#d1d5db",borderRadius:"4px",height:"16px",width:"60px"}}),p("div",{style:{backgroundColor:T?S.hoverBg:"#d1d5db",borderRadius:"4px",height:"40px",width:"150px"}})]}),A("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:"8px"},children:[p("div",{style:{backgroundColor:T?S.hoverBg:"#d1d5db",borderRadius:"4px",height:"12px",width:"80px"}}),p("div",{style:{backgroundColor:T?S.hoverBg:"#d1d5db",borderRadius:"6px",height:"46px",width:"128px"}})]})]})}):A("div",{style:Fe,children:[A("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[p("span",{style:{fontFamily:u?.fontFamily||F.typography.fontFamily,fontSize:"16px",fontWeight:500,color:T?S.textSecondary:"#7d7c7b",lineHeight:"24px"},children:a}),i&&t?.asset&&A("span",{style:{fontFamily:u?.fontFamily||F.typography.fontFamily,fontSize:"12px",fontWeight:500,color:T?S.textSecondary:"#71757a",lineHeight:"16px"},children:["Balance:"," ",Y===void 0?"...":Gr({balance:Y,decimals:t.asset.decimals})]})]}),A("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 12px",justifyContent:g&&!h?"flex-start":"space-between",alignItems:"center",flex:1},children:[!g&&p(Fo,{element:"input",ariaLabel:t?.asset?`${b(t.asset).symbol} amount`:"Amount",dataSpiceflowFocus:!0,value:pe,onChange:L=>R(L.target.value),placeholder:c,disabled:r||!t?.asset,fontFamily:u?.fontFamily||F.typography.fontFamily,color:r?T?"rgba(255, 255, 255, 0.16)":"rgba(14, 13, 11, 0.16)":pe?T?"#ffffff":"#0e0d0b":T?"#4a5568":"#d1d5db",lineHeight:"1.08",maxFontSize:40,minFontSize:22,style:{width:"100%",maxWidth:"200px",flex:"1 1 200px",minWidth:"min(200px, 100%)"}}),p("div",{style:{width:"176px",maxWidth:"100%",position:"relative",flexShrink:0,marginLeft:g&&!h?void 0:"auto"},children:p(Af,{selectedAsset:t,assets:e,onAssetSelect:L=>{j(),re(null),n(L)},showDropdown:E,onToggleDropdown:()=>M(!E),disabled:r,theme:F,onViewAllAssets:x,getAvailableBalance:m})}),g&&h&&p(Fo,{element:"span",value:h,title:h,fontFamily:u?.fontFamily||F.typography.fontFamily,color:T?"#ffffff":"#0e0d0b",lineHeight:"1.08",textAlign:"right",maxFontSize:40,minFontSize:22,style:{flex:"1 1 200px",minWidth:"min(200px, 100%)"}})]}),!g&&p("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:"10px",height:"14px"},children:[0,25,50,75,100].filter(L=>l||L!==100).map((L,N)=>{const $=Math.abs(ve-L)<1,de=N===4,J=B===L,ee=W===L;return p("button",{onClick:()=>K(L),onMouseEnter:()=>D(L),onMouseLeave:()=>{D(null),I(null)},onMouseDown:()=>I(L),onMouseUp:()=>I(null),disabled:r||!t?.asset||Y===void 0||L===100&&O,title:`${L}%`,style:{width:"14px",height:"14px",padding:0,border:"none",backgroundColor:"transparent",cursor:r||!t?.asset||Y===void 0||L===100&&O?"not-allowed":"pointer",opacity:$?1:J?.8:.5,transform:ee?"scale(0.85)":J?"scale(1.15)":"scale(1)",transition:Mn.interactive},children:p(Oa,{pct:L,isMax:de,primaryColor:C,dark:T,fillColor:T?S.textSecondary:"#3C3E42"})},L)})})]})},jo=Bn(Ef),Ff=({selectedDepositAssets:e,depositAssets:t,secondAssetOptions:n,loadingAssets:o,allowSecondAsset:r,theme:s,styles:a,dark:i,dk:l,onSelect:c,onAmountChange:d,onAdd:u,onRemove:f,resolveMaxAmount:y,onViewAllAssets:m})=>{const g=me(()=>Array.from({length:Math.max(1,e.length)},(h,w)=>y?x=>y(x,w):void 0),[y,e.length]);return A(nn,{children:[e.map((h,w)=>{const x=e.length===1?"Deposit":`Asset ${w+1}`;return A("div",{style:{marginBottom:s.spacing.md,position:"relative"},children:[p(jo,{assets:w===0?t:n,selectedAsset:h||void 0,onAssetSelect:b=>c(b,w),onAmountChange:b=>d(b,w),loading:o,label:x,showBalance:!0,theme:s,styles:a,allowSecondAsset:r&&w===0,onAddAsset:u,canAddAsset:e.length===1&&!!e[0]?.asset,resolveMaxAmount:g[w],onViewAllAssets:w===0?m:void 0}),w===1&&p("button",{onClick:()=>f(w),style:{position:"absolute",top:"-2px",right:"-2px",background:i?`${l.cardBg}ee`:"rgba(255, 255, 255, 0.9)",border:`1px solid ${l.cardBorder}`,borderRadius:"50%",cursor:"pointer",color:s.colors.textMuted,fontSize:"16px",padding:"2px",width:"22px",height:"22px",display:"flex",alignItems:"center",justifyContent:"center",transition:Mn.interactive,boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},onMouseEnter:b=>{b.currentTarget.style.color=i?l.errorText:"#ef4444",b.currentTarget.style.background=i?l.cardBg:"#fff",b.currentTarget.style.borderColor=i?l.errorBorder:"#fecaca"},onMouseLeave:b=>{b.currentTarget.style.color=s.colors.textMuted,b.currentTarget.style.background=i?`${l.cardBg}ee`:"rgba(255, 255, 255, 0.9)",b.currentTarget.style.borderColor=i?l.cardBorder:"#e5e7eb"},title:"Remove asset",children:"\xD7"})]},`asset-${w}`)}),e.length===0&&p("div",{style:{marginBottom:s.spacing.md},children:p(jo,{assets:t,selectedAsset:void 0,onAssetSelect:h=>c(h,0),onAmountChange:h=>d(h,0),loading:o,label:"Deposit",showBalance:!0,theme:s,styles:a,allowSecondAsset:r,onAddAsset:u,canAddAsset:!1,resolveMaxAmount:g[0]},"initial-selector")})]})},Tf=Bn(Ff);function Bf(e,t){switch(e){case"success":return{bg:t.successBg,border:t.successBorder,text:t.successText};case"warning":return{bg:t.warningBg,border:t.warningBorder,text:t.warningText};case"error":return{bg:t.errorBg,border:t.errorBorder,text:t.errorText};case"info":return{bg:t.infoBg,border:t.infoBorder,text:t.infoText}}}const kn=({variant:e,palette:t,children:n,icon:o,style:r,fontFamily:s,size:a="default"})=>{const i=Bf(e,t),l=a==="compact";return A("div",{role:e==="error"?"alert":"status",style:{backgroundColor:i.bg,border:`1px solid ${i.border}`,borderRadius:l?"7px":"8px",padding:l?"8px 10px":"12px 16px",color:i.text,fontSize:l?"12px":"13px",lineHeight:l?1.4:1.5,display:"flex",alignItems:"flex-start",gap:l?"6px":"8px",fontFamily:s,...r},children:[o&&p("span",{style:{flexShrink:0,display:"flex",alignItems:"center"},children:o}),p("span",{style:{minWidth:0,overflowWrap:"anywhere"},children:n})]})},xc=Ne.mono,Un=({label:e,value:t,palette:n,valueColor:o,labelColor:r,style:s})=>A("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:"12px",...s},children:[p("span",{style:{fontSize:"12px",color:r??n.textSecondary,fontFamily:xc,fontWeight:500,letterSpacing:"0.03em",flexShrink:0,whiteSpace:"nowrap"},children:e}),p("span",{style:{fontSize:"13px",color:o??n.textPrimary,fontWeight:500,fontFamily:xc,minWidth:0,textAlign:"right",overflowWrap:"anywhere"},children:t})]}),Da=({onClick:e,label:t="Add Funds",color:n,fontFamily:o,style:r})=>{const[s,a]=P(!1);return A("button",{type:"button",onClick:e,"data-spiceflow-focus":!0,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{background:"none",border:"none",cursor:"pointer",padding:0,display:"inline-flex",alignItems:"center",gap:"4px",color:n,fontSize:"12px",fontWeight:500,fontFamily:o,textDecoration:"underline",textUnderlineOffset:"2px",whiteSpace:"nowrap",opacity:s?.75:1,transition:"opacity 150ms ease",...r},children:[t,A("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[p("circle",{cx:"6",cy:"6",r:"5"}),p("path",{d:"M6 4v4M4 6h4",strokeLinecap:"round"})]})]})},Ma=({value:e,onChange:t,ariaLabel:n,placeholder:o,endAdornment:r,size:s="lg",dark:a,styles:i,inputRef:l,autoFocus:c})=>{const{dark:d,dk:u}=Vt(i,a),f=a??d,y=s==="lg",m=y?"15px":"14px",g=y?"7px":"10px",h=y?Us.input:Us.sm,w=i?.fontFamily||Ne.ui,x=f?u.inputBg:"#FAFAFA",b=f?u.inputBorder:"#e5e7eb",v=f?u.textPrimary:"#374151",C=f?u.textSecondary:"#9ca3af";return A("div",{style:{display:"flex",alignItems:"center",gap:"8px",backgroundColor:x,borderRadius:h,boxShadow:f?"0 2px 4px rgba(0, 0, 0, 0.3)":"0 2px 4px rgba(0, 0, 0, 0.1)",padding:`${g} 5px`,border:`1px solid ${b}`},children:[p(uf,{style:{color:C},size:24}),p("input",{ref:l,type:"text",role:"searchbox","aria-label":n,autoComplete:"off",spellCheck:!1,autoFocus:c,"data-spiceflow-focus":!0,placeholder:o,value:e,onChange:k=>t(k.target.value),style:{flex:1,backgroundColor:x,outline:"none",border:"none",color:v,fontSize:m,fontWeight:400,fontFamily:w}}),r]})},Of="This deposit didn't confirm in time. It may still have gone through, so check the explorer and refresh your balance before retrying.";function Rf(e){return e?.overallStatus!=="failed"?{isFailed:!1,failureMessage:null}:{isFailed:!0,failureMessage:e.steps?.find(t=>t.status==="failed"&&!!t.error)?.error||Of}}const bs=A("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",style:{flexShrink:0},children:[p("circle",{cx:"10",cy:"10",r:"10",fill:"#10b981"}),p("path",{d:"M6 10l3 3 5-6",stroke:"#ffffff",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Df=({isOpen:e,onClose:t,onConfirm:n,data:o,isExecuting:r=!1,error:s=null,theme:a,styles:i,intentStatus:l,postDepositStatus:c="idle",hasPostDepositInstruction:d=!1})=>{const{dark:u,dk:f,theme:y}=Vt(i),[m,g]=P(!1),[h,w]=P(!0);ue(()=>{e||g(!1)},[e]);const x=()=>{g(!0),setTimeout(()=>{t()},300)},b=()=>{w(!h)};if(!e||!o)return null;const v=l?.overallStatus==="processing",C=l?.overallStatus==="success",k=!!l,{isFailed:S,failureMessage:F}=Rf(l),T=!k&&d,E=T&&c==="executing",M=T&&c==="success",B=C&&d&&(c==="idle"||c==="executing")||E,D=C&&(!d||c==="success"||c==="error")||M||T&&c==="error",W=u?f.cardBg:"#ffffff",I=u?"0 -4px 20px rgba(0, 0, 0, 0.4)":"0 -4px 20px rgba(0, 0, 0, 0.15)",O=f.textSecondary,U=u?f.textPrimary:"#1f2937",z=u?f.textPrimary:"#1f2937",re=V=>p("div",{style:{marginBottom:a.spacing.md,padding:a.spacing.md,backgroundColor:i?.errorMessage?.backgroundColor||(a.mode==="light"?"#fef2f2":`${a.colors.error}20`),border:`1px solid ${i?.errorMessage?.borderColor||(a.mode==="light"?"#fecaca":a.colors.error)}`,borderRadius:i?.errorMessage?.borderRadius||a.borderRadius.md},children:p("p",{style:{color:i?.errorMessage?.color||a.colors.error,fontSize:i?.errorMessage?.fontSize||a.typography.fontSize.sm,margin:0,fontFamily:i?.errorMessage?.fontFamily||i?.fontFamily||a.typography.fontFamily},children:V})}),pe={fontSize:a.typography.fontSize.sm,fontWeight:500,color:O,fontFamily:Ne.mono,letterSpacing:"0.5px"},se=(V,X,Y=U)=>A("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[p("span",{style:pe,children:V}),p("span",{style:{fontSize:a.typography.fontSize.sm,fontWeight:500,color:Y,fontFamily:Ne.mono},children:X})]});return A("div",{style:{position:"absolute",bottom:0,left:0,right:0,zIndex:10,animation:m?"slideDown 0.3s ease-in":"slideUp 0.3s ease-out",pointerEvents:"auto"},children:[A("div",{style:{backgroundColor:W,borderRadius:"0",width:"100%",maxWidth:"522px",margin:"0 auto",padding:"18px 24px",boxShadow:I},children:[!C&&!M&&A(nn,{children:[A("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:a.spacing.md},children:[A("div",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},onClick:b,children:[p("span",{style:{fontSize:"13px",fontWeight:a.typography.fontWeight.medium,color:O,fontFamily:i?.fontFamily||a.typography.fontFamily},children:"Transaction Details"}),p(Qo,{color:O,direction:h?"up":"down"})]}),p("button",{onClick:V=>{V.stopPropagation(),t()},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:O,transition:"color 0.2s ease"},onMouseEnter:V=>{V.currentTarget.style.color=z},onMouseLeave:V=>{V.currentTarget.style.color=O},children:p(Ar,{size:16})})]}),A("div",{style:{marginBottom:a.spacing.lg,display:"flex",flexDirection:"column",gap:a.spacing.md,overflow:"hidden",maxHeight:h?"200px":"0px",opacity:h?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:[se("NETWORK",o.network),se("DEPOSITED AMOUNT",o.amount,a.colors.success),o.creditedAmount&&se("CREDITED AMOUNT",o.creditedAmount),o.spicenetFee&&se("SPICENET FEE",o.spicenetFee),o.networkFee&&se("EST. NETWORK FEE",o.networkFee)]})]}),s&&!k&&re(s),S&&F&&re(F),p(Mt,{onClick:D||S?x:n,variant:"outline",fullWidth:!0,disabled:r||v||B||E,styles:i,theme:y,children:r||v||E||B?"PROCESSING...":D?"CONTINUE \u2192":S?"CLOSE":"CONFIRM DEPOSIT"}),D&&p("p",{style:{marginTop:a.spacing.md,marginBottom:0,fontSize:"14px",color:O,textAlign:"center",fontFamily:i?.fontFamily||a.typography.fontFamily},children:"Your funds are now available in your Account"}),p("div",{style:{marginTop:a.spacing.md,display:"flex",justifyContent:"center",alignItems:"center"},children:p("img",{src:ac,alt:"Powered by SpiceNet",style:{height:"auto",width:"130px",opacity:1,filter:u?"brightness(0) invert(1) opacity(0.7)":"none"}})})]}),p("style",{children:`
3
+ import{jsxs as A,jsx as p,Fragment as nn}from"react/jsx-runtime";import{g as nt,a as bt,S as ze,b as oe,c as Vr,i as Qr,d as xi,e as Ht,f as jd,E as Gd,C as jr,r as Kd,R as Yd,h as Zd,j as bi,k as yt,l as Ms,u as to,m as ar,n as Ws,o as Tn,z as Io,p as jn,q as Ne,s as Vt,t as Ps,v as Po,w as vi,x as Ci,y as Dn,A as ir,B as Mn,D as Ns,F as Gr,G as Kr,H as Us,I as no,J as Yr,K as Mt,L as No,M as lr,N as Xd,P as Jd,O as mo,Q as ki,T as oo,U as $d,V as cr,W as Zr,X as Ii,Y as _d,Z as dr,_ as eu,$ as Si,a0 as Ls,a1 as So,a2 as tu,a3 as nu,a4 as ou,a5 as ru,a6 as su,a7 as au,a8 as iu}from"./privy-CcPFNAxM.js";import{a9 as l0,ab as c0,ac as d0,ae as u0,ad as p0,aa as f0}from"./privy-CcPFNAxM.js";import Hn,{useContext as Kt,useState as P,useMemo as me,useEffect as ue,useCallback as te,useRef as Z,useId as Ai,useLayoutEffect as Ao,memo as Bn}from"react";import{isNativeToken as be,uniV3QuoterV2Abi as lu,uniV3SwapRouterAbi as Ei,applySlippage as Fi,NATIVE_TOKEN_ADDRESS as Ti,getTokenByAddress as Ut,areEquivalent as cu,getTokensForChain as ur,getEscrowContractAddress as ro,getEscrowContract as pr,ZERO_ADDRESS as Dt,normalizeNativeTokenAddress as dt,getChainMeta as Bi,getMainnetChains as du,getTestnetChains as uu,TOKENS as Oi,convertAmountBetweenDecimals as Vn,getChainIdsByNetwork as Xr,hashChainBatches as Gn,isSpicenetChainId as Uo,getAccountNonce as pu,SPICE_COMBINED_FEE_RECIPIENT as fu,SPICE_GAS_FEE_RECIPIENT as Zt,SPICE_PLATFORM_FEE_RECIPIENT as xn,getEquivalenceGroup as mu,SPICENET_NATIVE_CHAIN_ID as Ri,spicenetAbi as zs,getEquivalentAddresses as hu,getTokenBySymbol as Di}from"@spicenet-io/spiceflow-core";import{ZERO_ADDRESS as h0,SPICENET_NATIVE_CHAIN_ID as g0,SPICE_COMBINED_FEE_RECIPIENT as y0,SPICE_GAS_FEE_RECIPIENT as w0,SPICE_PLATFORM_FEE_RECIPIENT as x0,SPICE_SOLVER_ADDRESS as b0,applySlippage as v0,buildUniV3SwapCalls as C0,getChainIdsByNetwork as k0,getEscrowContractAddress as I0,isNativeToken as S0,isSpicenetChainId as A0,normalizeNativeTokenAddress as E0,spicenetAbi as F0,spicenetAbi as T0}from"@spicenet-io/spiceflow-core";import{useWalletClient as gu,useAccount as qs,useDisconnect as Hs,useConnect as yu,useSwitchChain as wu}from"wagmi";import{encodeFunctionData as Tt,parseAbi as Wn,concatHex as xu,encodePacked as Vs,erc20Abi as ot,decodeFunctionData as so,encodeAbiParameters as ao,formatUnits as Ee,isAddress as vn,getAddress as Yt,keccak256 as Lo,createWalletClient as Qs,custom as js,parseUnits as Cn,decodeEventLog as bu,toHex as Mi,stringToHex as vu,bytesToHex as Cu}from"viem";import{readContract as ho,getBalance as Gs}from"viem/actions";import{useConnectWallet as Wi,usePrivy as Pi,useActiveWallet as ku}from"@privy-io/react-auth";import Ks,{createPortal as Ys}from"react-dom";import"@tanstack/react-query";const Iu="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@100;200;300;400;500;600;700&display=swap",Su="spiceflow-ibm-plex-mono",Au="spiceflow-preconnect-googleapis",Eu="spiceflow-preconnect-gstatic";function Zs(e,t){if(document.getElementById(e))return;const n=t();n.id=e,document.head.appendChild(n)}function Fu(){typeof document>"u"||(Zs(Au,()=>{const e=document.createElement("link");return e.rel="preconnect",e.href="https://fonts.googleapis.com",e}),Zs(Eu,()=>{const e=document.createElement("link");return e.rel="preconnect",e.href="https://fonts.gstatic.com",e.crossOrigin="",e}),Zs(Su,()=>{const e=document.createElement("link");return e.rel="stylesheet",e.href=Iu,e}))}const Tu={1:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",8453:"0x4200000000000000000000000000000000000006",42161:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",84532:"0x4200000000000000000000000000000000000006"},Ni=Wn(["function deposit() payable","function withdraw(uint256 wad)"]);function Xs(e){return nt(e)?.wrappedNativeTokenAddress??Tu[e]}const Js=(e,t)=>({to:e,value:t,data:Tt({abi:Ni,functionName:"deposit"})}),$s=(e,t)=>({to:e,value:0n,data:Tt({abi:Ni,functionName:"withdraw",args:[t]})});function _s(e,t,n){const o=be(t),r=be(n);if(!o&&!r)return null;const s=Xs(e);return s?{weth:s,wrapIn:o,unwrapOut:r}:null}function Ui(e,t,n,o){const r=_s(e,t,n);return!r||o<=0n?null:r.wrapIn&&!r.unwrapOut&&n.toLowerCase()===r.weth.toLowerCase()?[Js(r.weth,o)]:r.unwrapOut&&!r.wrapIn&&t.toLowerCase()===r.weth.toLowerCase()?[$s(r.weth,o)]:null}function Bu(e){return{...e,resolve:async(t,n,o,r)=>{const s=Ui(n,t.tokenIn,t.tokenOut,t.amountIn);if(s)return{venue:"native-wrap",amountOut:t.amountIn,amountOutMinimum:t.amountIn,calls:s};const a=await e.resolve(t,n,o,r);if(a)return a;const i=_s(n,t.tokenIn,t.tokenOut);if(!i)return null;const l=await e.resolve({...t,tokenIn:i.wrapIn?i.weth:t.tokenIn,tokenOut:i.unwrapOut?i.weth:t.tokenOut},n,o,r);return l?{...l,calls:[...i.wrapIn?[Js(i.weth,t.amountIn)]:[],...l.calls,...i.unwrapOut?[$s(i.weth,l.amountOutMinimum)]:[]]}:null}}}function Ou(e){return{...e,resolve:async(t,n,o)=>{const r=Ui(n,t.tokenIn,t.tokenOut,t.amountOut);if(r)return{venue:"native-wrap",amountIn:t.amountOut,amountInMax:t.amountOut,amountOut:t.amountOut,calls:r};const s=await e.resolve(t,n,o);if(s)return s;const a=_s(n,t.tokenIn,t.tokenOut);if(!a)return null;const i=await e.resolve({...t,tokenIn:a.wrapIn?a.weth:t.tokenIn,tokenOut:a.unwrapOut?a.weth:t.tokenOut},n,o);return i?{...i,calls:[...a.wrapIn?[Js(a.weth,i.amountInMax)]:[],...i.calls,...a.unwrapOut?[$s(a.weth,i.amountOut)]:[]]}:null}}}const Li=[100,500,3e3,1e4];function Jr(e,t,n,o,r){const s=[];for(const a of n){const i=typeof a=="object"&&!Array.isArray(a)?a:void 0,l=i?i.tokens:Array.isArray(a)?a:[a];if(!l.length||l.length>2)throw new Error("A v3 route must have one or two intermediate tokens");const c=[e,...l,t];if(i&&(i.feeTiers.length!==c.length-1||i.feeTiers.some(u=>!u.length)))throw new Error("A v3 route needs fee tiers for every pool");if(new Set(c.map(u=>u.toLowerCase())).size!==c.length)continue;const d=(u,f)=>{if(u===c.length){s.push(r==="in"?f:zi(f));return}for(const y of i?.feeTiers[u-1]??o)d(u+1,xu([f,Vs(["uint24","address"],[y,c[u]])]))};d(1,c[0])}return[...new Set(s)]}function zi(e){const t=e.slice(2),n=[];for(let o=0;o<t.length;){const r=n.length%2===0?40:6;n.push(t.slice(o,o+r)),o+=r}return`0x${n.reverse().join("")}`}const Ru=Wn(["function exactOutputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountOut, uint256 amountInMaximum, uint160 sqrtPriceLimitX96) params) payable returns (uint256 amountIn)","function exactOutput((bytes path, address recipient, uint256 amountOut, uint256 amountInMaximum) params) payable returns (uint256 amountIn)"]),Du=Wn(["function exactOutputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 deadline, uint256 amountOut, uint256 amountInMaximum, uint160 sqrtPriceLimitX96) params) payable returns (uint256 amountIn)","function exactOutput((bytes path, address recipient, uint256 deadline, uint256 amountOut, uint256 amountInMaximum) params) payable returns (uint256 amountIn)"]),Mu=1800;function qi(e){const{config:t,route:n,tokenIn:o,tokenOut:r,recipient:s,amountOut:a}=e,i=e.amountInMaximum,l=e.routerHasDeadline?Du:Ru,c=e.routerHasDeadline?{deadline:BigInt(Math.floor(Date.now()/1e3)+Mu)}:{},d=n.path?Tt({abi:l,functionName:"exactOutput",args:[{path:n.path,recipient:s,...c,amountOut:a,amountInMaximum:i}]}):Tt({abi:l,functionName:"exactOutputSingle",args:[{tokenIn:o,tokenOut:r,fee:n.fee,recipient:s,...c,amountOut:a,amountInMaximum:i,sqrtPriceLimitX96:0n}]});return{to:t.swapRouter,value:0n,data:d}}const Wu=Wn(["function quoteExactInput(bytes path, uint256 amountIn) returns (uint256 amountOut, uint160[] sqrtPriceX96AfterList, uint32[] initializedTicksCrossedList, uint256 gasEstimate)","function quoteExactOutput(bytes path, uint256 amountOut) returns (uint256 amountIn, uint160[] sqrtPriceX96AfterList, uint32[] initializedTicksCrossedList, uint256 gasEstimate)"]);async function fr(e,t,n,o,r){const s=bt(e),{result:a}=await s.simulateContract({address:t.quoterV2,abi:Wu,functionName:r==="in"?"quoteExactInput":"quoteExactOutput",args:[n,o]}),[i,,,l]=a;if(i<=0n)throw new Error("No liquidity along this path.");return{amount:i,gasEstimate:l}}async function Pu(e){const{tokenIn:t,tokenOut:n,amountIn:o,fee:r,chainId:s,config:a}=e;if(o<=0n)throw new Error("amountIn must be greater than 0");const i=(await bt(s).simulateContract({address:a.quoterV2,abi:lu,functionName:"quoteExactInputSingle",args:[{tokenIn:t,tokenOut:n,amountIn:o,fee:r,sqrtPriceLimitX96:0n}]})).result;if(i[0]<=0n)throw new Error("No liquidity found for this pair. The pool returned 0 output.");return{amountOut:i[0],sqrtPriceX96After:i[1],gasEstimate:i[3]}}async function Hi(e){const t=e.feeTiers??Li,n=Jr(e.tokenIn,e.tokenOut,e.hubs??[],t,"in"),o=await Promise.allSettled([...t.map(async s=>({...await Pu({...e,fee:s}),fee:s})),...n.map(async s=>{const a=await fr(e.chainId,e.config,s,e.amountIn,"in");return{amountOut:a.amount,sqrtPriceX96After:0n,gasEstimate:a.gasEstimate,fee:0,path:s}})]);let r=null;for(const s of o)s.status==="fulfilled"&&(!r||s.value.amountOut>r.amountOut)&&(r=s.value);if(!r)throw new Error("No liquidity found for this pair on any fee tier.");return r}const Nu=[{inputs:[{components:[{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"amount",type:"uint256"},{name:"fee",type:"uint24"},{name:"sqrtPriceLimitX96",type:"uint160"}],name:"params",type:"tuple"}],name:"quoteExactOutputSingle",outputs:[{name:"amountIn",type:"uint256"},{name:"sqrtPriceX96After",type:"uint160"},{name:"initializedTicksCrossed",type:"uint32"},{name:"gasEstimate",type:"uint256"}],stateMutability:"nonpayable",type:"function"}];async function Uu(e){const{tokenIn:t,tokenOut:n,amountOut:o,fee:r,chainId:s,config:a}=e;if(o<=0n)throw new Error("amountOut must be greater than 0");const i=(await bt(s).simulateContract({address:a.quoterV2,abi:Nu,functionName:"quoteExactOutputSingle",args:[{tokenIn:t,tokenOut:n,amount:o,fee:r,sqrtPriceLimitX96:0n}]})).result;if(i[0]<=0n)throw new Error("No liquidity found for this pair. The pool returned 0 input.");return{amountIn:i[0],sqrtPriceX96After:i[1],gasEstimate:i[3]}}async function Vi(e){const t=e.feeTiers??Li,n=Jr(e.tokenIn,e.tokenOut,e.hubs??[],t,"out"),o=await Promise.allSettled([...t.map(async s=>({...await Uu({...e,fee:s}),fee:s})),...n.map(async s=>{const a=await fr(e.chainId,e.config,s,e.amountOut,"out");return{amountIn:a.amount,sqrtPriceX96After:0n,gasEstimate:a.gasEstimate,fee:0,path:s}})]);let r=null;for(const s of o)s.status==="fulfilled"&&(!r||s.value.amountIn<r.amountIn)&&(r=s.value);if(!r)throw new Error("No liquidity found for this pair on any fee tier.");return r}function Lu(e){return e.type==="swap"}const mr=.02,zu=[1,8453,42161,10,137,43114,56],qu="https://api.1inch.dev/swap/v6.0";function ea(e,t){return Fi(e,t)}function Hu(e){const t=e?.baseUrl??qu;return{name:"1inch",chainIds:e?.chainIds??zu,resolve:async(n,o,r)=>{const s=n.maxSlippage??mr,a=s*100,i=be(n.tokenIn)?Ti:n.tokenIn,l=be(n.tokenOut)?Ti:n.tokenOut,c=be(n.tokenIn);try{const d=new URL(`${t}/${o}/swap`);d.searchParams.set("src",i),d.searchParams.set("dst",l),d.searchParams.set("amount",n.amountIn.toString()),d.searchParams.set("from",r),d.searchParams.set("slippage",a.toString()),d.searchParams.set("disableEstimate","true"),d.searchParams.set("allowPartialFill","false");const u={Accept:"application/json"};e?.apiKey&&(u.Authorization=`Bearer ${e.apiKey}`);const f=await fetch(d.toString(),{headers:u});if(!f.ok)throw new ze("VENUE_API_ERROR",`[1inchVenue] API returned ${f.status} for ${n.tokenIn} \u2192 ${n.tokenOut} on chain ${o}`,{venue:"1inch",chainId:o,tokenIn:n.tokenIn,tokenOut:n.tokenOut,amountIn:n.amountIn.toString(),cause:`HTTP ${f.status}`});const y=await f.json();if(!y.dstAmount||!y.tx)return console.warn(`[1inchVenue] No route data for ${n.tokenIn} \u2192 ${n.tokenOut} on chain ${o}`),null;const m=BigInt(y.dstAmount);if(m<=0n)return console.warn(`[1inchVenue] Zero output for ${n.tokenIn} \u2192 ${n.tokenOut} on chain ${o}`),null;const g=ea(m,s),h=[];return y.tx.to&&!c&&h.push({to:n.tokenIn,value:0n,data:Tt({abi:ot,functionName:"approve",args:[y.tx.to,n.amountIn]})}),h.push({to:y.tx.to,value:BigInt(y.tx.value||"0"),data:y.tx.data}),{venue:"1inch",amountOut:m,amountOutMinimum:g,calls:h}}catch(d){if(d instanceof ze)throw d;const u=d instanceof Error?d.message:String(d);throw new ze("VENUE_API_ERROR",`[1inchVenue] Exception for ${n.tokenIn} \u2192 ${n.tokenOut} on chain ${o}: ${u}`,{venue:"1inch",chainId:o,tokenIn:n.tokenIn,tokenOut:n.tokenOut,amountIn:n.amountIn.toString(),cause:u})}}}}const Qi=[4114,5115],ta={name:"Satsuma",swapRouter:"0x565eD3D57fe40f78A46f348C220121AE093c3cF8",quoterV2:"0x428f20dd8926Eabe19653815Ed0BE7D6c36f8425",feeTiers:[3e3]},ji={name:"Uniswap v3",swapRouter:"0x2626664c2603336E57B271c5C0b26F421741e481",quoterV2:"0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a",chainIds:[8453],feeTiers:[100,500,3e3,1e4],hubCurrencies:["0x4200000000000000000000000000000000000006","0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"]},Gi={name:"Uniswap v3",swapRouter:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",quoterV2:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",chainIds:[1],feeTiers:[100,500,3e3,1e4],hubCurrencies:["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2","0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]},Ki={name:"Uniswap v3",swapRouter:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",quoterV2:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",chainIds:[42161],feeTiers:[100,500,3e3,1e4],hubCurrencies:["0x82aF49447D8a07e3bd95BD0d56f35241523fBab1","0xaf88d065e77c8cC2239327C5EDb3A432268e5831"]},Vu={name:"Uniswap v3",swapRouter:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",quoterV2:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",chainIds:[137],feeTiers:[100,500,3e3,1e4],hubCurrencies:["0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270","0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359"]},Qu={name:"Uniswap v3",swapRouter:"0xB971eF87ede563556b2ED4b1C0b0019111Dd85d2",quoterV2:"0x78D78E420Da98ad378D7799bE8f4AF69033EB077",chainIds:[56],feeTiers:[100,500,3e3,1e4],hubCurrencies:["0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c","0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"]},ju={name:"Uniswap v3",swapRouter:"0xfe31f71c1b106eac32f1a19239c9a9a72ddfb900",quoterV2:"0x661e93cca42afacb172121ef892830ca3b70f08d",chainIds:[143],feeTiers:[100,500,3e3,1e4],hubCurrencies:["0x3bd359C1119dA7Da1D913D1C4D2B7c461115433A","0x754704Bc059F8C67012fEd69BC8A327a5aafb603"]},Yi={name:"Uniswap v3",swapRouter:"0xcaf681a66d020601342297493863e78c959e5cb2",quoterV2:"0x33e885ed0ec9bf04ecfb19341582aadcb4c8a9e7",chainIds:[4663],feeTiers:[100,500,3e3,1e4],hubCurrencies:["0x0bd7d308f8e1639fab988df18a8011f41eacad73","0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168"]},Zi={name:"SushiSwap",swapRouter:"0x1e406484F1F204b23cE84B9901C0171a738fd406",quoterV2:"0x3E290e5E01818002A0b672148BdC7514D861C7B3",chainIds:[4663],feeTiers:[100,500,3e3,1e4],hubCurrencies:["0x0bd7d308f8e1639fab988df18a8011f41eacad73","0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168"],routerHasDeadline:!0},Xi=Wn(["function exactInput((bytes path, address recipient, uint256 amountIn, uint256 amountOutMinimum) params) payable returns (uint256 amountOut)"]),Ji=Wn(["function exactInputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 deadline, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96) params) payable returns (uint256 amountOut)","function exactInput((bytes path, address recipient, uint256 deadline, uint256 amountIn, uint256 amountOutMinimum) params) payable returns (uint256 amountOut)"]),Gu=Wn(["function exactInput((bytes path, address recipient, uint256 deadline, uint256 amountIn, uint256 amountOutMinimum) params) payable returns (uint256 amountOut)"]),Ku=Wn(["function exactOutput((bytes path, address recipient, uint256 deadline, uint256 amountOut, uint256 amountInMaximum) params) payable returns (uint256 amountIn)"]),na=1800,$i=[1,50,100,200,2e3],$r={name:"Aerodrome",swapRouter:"0xcbBb8035cAc7D4B3Ca7aBb74cF7BdF900215Ce0D",quoterV2:"0x3d4C22254F86f64B7eC90ab8F7aeC1FBFD271c6C",chainIds:[8453],hubCurrencies:["0x4200000000000000000000000000000000000006","0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"]};function _r(e){const t=e.name??"Aerodrome",n=e.chainIds??[8453],o=e.tickSpacings??$i;return{name:t,chainIds:n,resolve:async(r,s,a)=>{if(be(r.tokenIn)||be(r.tokenOut))return null;const i=r.maxSlippage??mr,l=[...o.map(h=>Vs(["address","uint24","address"],[r.tokenIn,h,r.tokenOut])),...Jr(r.tokenIn,r.tokenOut,e.hubCurrencies??[],o,"in")],c={quoterV2:e.quoterV2},d=await Promise.allSettled(l.map(async h=>({path:h,amountOut:(await fr(s,c,h,r.amountIn,"in")).amount})));let u=null;for(const h of d)h.status==="fulfilled"&&(!u||h.value.amountOut>u.amountOut)&&(u=h.value);if(!u)return console.warn(`[AerodromeVenue] No viable route for ${r.tokenIn} \u2192 ${r.tokenOut} on chain ${s}.`),null;const f=ea(u.amountOut,i),y=BigInt(Math.floor(Date.now()/1e3)+na),m=Tt({abi:Gu,functionName:"exactInput",args:[{path:u.path,recipient:a,deadline:y,amountIn:r.amountIn,amountOutMinimum:f}]}),g=[{to:r.tokenIn,value:0n,data:Tt({abi:ot,functionName:"approve",args:[e.swapRouter,r.amountIn]})},{to:e.swapRouter,value:0n,data:m}];return{venue:t,amountOut:u.amountOut,amountOutMinimum:f,calls:g}}}}function _i(e){const t=e.name??"Aerodrome",n=e.chainIds??[8453],o=e.tickSpacings??$i;return{name:t,chainIds:n,resolve:async(r,s,a)=>{if(be(r.tokenIn)||be(r.tokenOut))return null;const i=r.maxSlippage??mr,l=[...o.map(g=>Vs(["address","uint24","address"],[r.tokenOut,g,r.tokenIn])),...Jr(r.tokenIn,r.tokenOut,e.hubCurrencies??[],o,"out")],c={quoterV2:e.quoterV2},d=await Promise.allSettled(l.map(async g=>({path:g,amountIn:(await fr(s,c,g,r.amountOut,"out")).amount})));let u=null;for(const g of d)g.status==="fulfilled"&&(!u||g.value.amountIn<u.amountIn)&&(u=g.value);if(!u)return console.warn(`[AerodromeExactOutputVenue] No viable route for ${r.tokenIn} \u2192 ${r.tokenOut} on chain ${s}.`),null;const f=BigInt(Math.round(i*1e4)),y=u.amountIn+u.amountIn*f/10000n,m=BigInt(Math.floor(Date.now()/1e3)+na);return{venue:t,amountIn:u.amountIn,amountInMax:y,amountOut:r.amountOut,calls:[{to:e.swapRouter,value:0n,data:Tt({abi:Ku,functionName:"exactOutput",args:[{path:u.path,recipient:a,deadline:m,amountOut:r.amountOut,amountInMaximum:y}]})}]}}}}function hr(e){const t=e.name??"Uniswap v3",n=e.chainIds??Qi;return{name:t,chainIds:n,resolve:async(o,r,s,a)=>{if(be(o.tokenIn)||be(o.tokenOut))return null;const i=o.maxSlippage??mr;let l;try{let m;if(a){if(a.venue!==t)return null;const g=a.calls.find(w=>w.to.toLowerCase()===e.swapRouter.toLowerCase());if(!g)return null;const h=so({abi:e.routerHasDeadline?Ji:[...Xi,...Ei],data:g.data});if(h.functionName==="exactInput"){const{path:w}=h.args[0];if(w.slice(0,42).toLowerCase()!==o.tokenIn.toLowerCase()||`0x${w.slice(-40)}`.toLowerCase()!==o.tokenOut.toLowerCase())return null;m={path:w,fee:0}}else if(h.functionName==="exactInputSingle"){const{tokenIn:w,tokenOut:x,fee:b}=h.args[0];if(w.toLowerCase()!==o.tokenIn.toLowerCase()||x.toLowerCase()!==o.tokenOut.toLowerCase())return null;m={fee:b}}else return null}l=m?.path?{...m,amountOut:(await fr(r,e,m.path,o.amountIn,"in")).amount}:await Hi({tokenIn:o.tokenIn,tokenOut:o.tokenOut,amountIn:o.amountIn,chainId:r,config:{swapRouter:e.swapRouter,quoterV2:e.quoterV2},feeTiers:m?[m.fee]:e.feeTiers,hubs:m?[]:[...e.hubCurrencies??[],...e.hubPaths??[]]})}catch{return console.warn(`[UniV3Venue] No viable route for ${o.tokenIn} \u2192 ${o.tokenOut} on chain ${r}.`),null}const c=ea(l.amountOut,i),d=e.routerHasDeadline?{deadline:BigInt(Math.floor(Date.now()/1e3)+na)}:{},u=e.routerHasDeadline?Ji:l.path?Xi:Ei,f=l.path?Tt({abi:u,functionName:"exactInput",args:[{path:l.path,recipient:s,...d,amountIn:o.amountIn,amountOutMinimum:c}]}):Tt({abi:u,functionName:"exactInputSingle",args:[{tokenIn:o.tokenIn,tokenOut:o.tokenOut,fee:l.fee,recipient:s,...d,amountIn:o.amountIn,amountOutMinimum:c,sqrtPriceLimitX96:0n}]}),y=[{to:o.tokenIn,value:0n,data:Tt({abi:ot,functionName:"approve",args:[e.swapRouter,o.amountIn]})},{to:e.swapRouter,value:0n,data:f}];return{venue:t,amountOut:l.amountOut,amountOutMinimum:c,calls:y}}}}function oa(e){const t=e.name??"Uniswap v3",n=e.chainIds??Qi;return{name:t,chainIds:n,resolve:async(o,r,s)=>{if(be(o.tokenIn)||be(o.tokenOut))return null;const a=o.maxSlippage??mr;let i;try{i=await Vi({tokenIn:o.tokenIn,tokenOut:o.tokenOut,amountOut:o.amountOut,chainId:r,config:{swapRouter:e.swapRouter,quoterV2:e.quoterV2},feeTiers:e.feeTiers,hubs:[...e.hubCurrencies??[],...e.hubPaths??[]]})}catch{return null}const l=BigInt(Math.round(a*1e4)),c=i.amountIn+i.amountIn*l/10000n;return{venue:t,amountIn:i.amountIn,amountInMax:c,amountOut:o.amountOut,calls:[qi({config:{swapRouter:e.swapRouter,quoterV2:e.quoterV2},routerHasDeadline:e.routerHasDeadline,route:i,tokenIn:o.tokenIn,tokenOut:o.tokenOut,recipient:s,amountOut:o.amountOut,amountInMaximum:c})]}}}}function el(e){const t=[];e?.customVenues&&t.push(...e.customVenues),e?.satsuma&&t.push(hr(e.satsuma)),e?.aerodrome!==!1&&t.push(_r(e?.aerodrome??$r)),t.push(Hu(e?.oneInch));const n=t.map(Bu);function o(a){return n.find(i=>i.chainIds.includes(a))}async function r(a,i,l,c){const d=n.filter(m=>m.chainIds.includes(i));if(d.length===0)throw new ze("NO_VENUE_FOR_CHAIN",`No liquidity venue configured for chain ${i}. Cannot resolve swap ${a.tokenIn} \u2192 ${a.tokenOut}.`,{chainId:i,tokenIn:a.tokenIn,tokenOut:a.tokenOut,amountIn:a.amountIn.toString()});const u=await Promise.allSettled(d.map(m=>m.resolve(a,i,l,c)));let f=null;for(const m of u)c&&m.status==="fulfilled"&&m.value&&(m.value.venue!==c.venue||m.value.calls.length!==c.calls.length||m.value.calls.some((g,h)=>g.to.toLowerCase()!==c.calls[h].to.toLowerCase()||g.data.slice(0,10)!==c.calls[h].data.slice(0,10)))||m.status==="fulfilled"&&m.value&&(!f||m.value.amountOut>f.amountOut)&&(f=m.value);if(f)return f;const y=u.find(m=>m.status==="rejected");if(y)throw y.reason;return null}async function s(a,i,l){const c=[],d=[];for(const u of a){if(!Lu(u)){c.push(u);continue}const f=await r(u,i,l);if(!f)throw new ze("NO_LIQUIDITY",`No venue returned a quote for ${u.tokenIn} \u2192 ${u.tokenOut} on chain ${i}.`,{chainId:i,tokenIn:u.tokenIn,tokenOut:u.tokenOut,amountIn:u.amountIn.toString()});c.push(...f.calls),d.push(f)}return{calls:c,resolvedSwaps:d}}return{resolveSwapIntents:s,resolveSwap:r,getVenueForChain:o,venues:t}}const Kn="0x0000000000000000000000000000000000000000",ra=[{fee:100,tickSpacing:1},{fee:500,tickSpacing:10},{fee:3e3,tickSpacing:60},{fee:1e4,tickSpacing:200}],tl=Kn,nl=.02,Yu=1800,ol={name:"Uniswap v4",quoter:"0x0d5e0f971ed27fbff6c2837bf31316121532048d",universalRouter:"0x6ff5693b99212da76ad316178a184ab56d299b43",permit2:"0x000000000022d473030f116ddee9f6b43ac78ba3",chainIds:[8453],hubCurrencies:["0x4200000000000000000000000000000000000006",Kn,"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"]},rl={name:"Uniswap v4",quoter:"0x8dc178efb8111bb0973dd9d722ebeff267c98f94",universalRouter:"0x8876789976decbfcbbbe364623c63652db8c0904",permit2:"0x000000000022d473030f116ddee9f6b43ac78ba3",routerHasHopPrice:!0,chainIds:[4663],hubCurrencies:["0x0bd7d308f8e1639fab988df18a8011f41eacad73",Kn,"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168"]},sl=Wn(["struct PoolKey { address currency0; address currency1; uint24 fee; int24 tickSpacing; address hooks; }","struct PathKey { address intermediateCurrency; uint24 fee; int24 tickSpacing; address hooks; bytes hookData; }","struct QuoteExactSingleParams { PoolKey poolKey; bool zeroForOne; uint128 exactAmount; bytes hookData; }","struct QuoteExactParams { address exactCurrency; PathKey[] path; uint128 exactAmount; }","function quoteExactInputSingle(QuoteExactSingleParams params) returns (uint256 amountOut, uint256 gasEstimate)","function quoteExactInput(QuoteExactParams params) returns (uint256 amountOut, uint256 gasEstimate)","function quoteExactOutputSingle(QuoteExactSingleParams params) returns (uint256 amountIn, uint256 gasEstimate)","function quoteExactOutput(QuoteExactParams params) returns (uint256 amountIn, uint256 gasEstimate)"]),Zu=Wn(["function approve(address token, address spender, uint160 amount, uint48 expiration)"]),Xu=Wn(["function execute(bytes commands, bytes[] inputs, uint256 deadline) payable"]),al="0x10",Ju="04",$u="06",_u="07",ep="08",tp="09",es="0c",ts="0e",np=[{name:"currency0",type:"address"},{name:"currency1",type:"address"},{name:"fee",type:"uint24"},{name:"tickSpacing",type:"int24"},{name:"hooks",type:"address"}],op=[{name:"intermediateCurrency",type:"address"},{name:"fee",type:"uint24"},{name:"tickSpacing",type:"int24"},{name:"hooks",type:"address"},{name:"hookData",type:"bytes"}],io=(e,t)=>e.toLowerCase()===t.toLowerCase();function ns(e){return be(e)?Kn:e}function rp(e,t){return e.toLowerCase()<t.toLowerCase()?[e,t]:[t,e]}function il(e,t,n,o,r){const s=[],[a,i]=rp(e,t);for(const{fee:c,tickSpacing:d}of ra)s.push({kind:"single",poolKey:{currency0:a,currency1:i,fee:c,tickSpacing:d,hooks:tl},zeroForOne:io(e,a)});const l=(c,d)=>!!r&&(io(c,Kn)&&io(d,r)||io(c,r)&&io(d,Kn));for(const c of n)if(!(io(c,e)||io(c,t))&&!(l(c,e)||l(c,t)))for(const d of ra)for(const u of ra){const f=(y,m)=>({intermediateCurrency:y,fee:m.fee,tickSpacing:m.tickSpacing,hooks:tl,hookData:"0x"});s.push({kind:"multi",path:o==="in"?[f(c,d),f(t,u)]:[f(e,d),f(c,u)]})}return s}async function ll(e,t,n,o,r,s){const a=bt(e),i=(await Promise.allSettled(n.map(async l=>{const{result:c}=l.kind==="single"?await a.simulateContract({address:t.quoter,abi:sl,functionName:s==="in"?"quoteExactInputSingle":"quoteExactOutputSingle",args:[{poolKey:l.poolKey,zeroForOne:l.zeroForOne,exactAmount:r,hookData:"0x"}]}):await a.simulateContract({address:t.quoter,abi:sl,functionName:s==="in"?"quoteExactInput":"quoteExactOutput",args:[{exactCurrency:o,path:l.path,exactAmount:r}]}),d=c[0];if(d<=0n)throw new Error("zero quote");return{candidate:l,amount:d}}))).filter(l=>l.status==="fulfilled").map(l=>l.value);return i.length===0?null:(i.sort((l,c)=>l.amount<c.amount?-1:l.amount>c.amount?1:0),s==="in"?i[i.length-1]:i[0])}function cl(e){const{candidate:t,direction:n,currencyIn:o,currencyOut:r,recipient:s,exactAmount:a,limitAmount:i,deadline:l,routerHasHopPrice:c,sweepNativeTo:d}=e;let u,f;t.kind==="single"?(u=n==="in"?`0x${$u}${es}${ts}`:`0x${ep}${es}${ts}`,f=ao([{type:"tuple",components:[{name:"poolKey",type:"tuple",components:np},{name:"zeroForOne",type:"bool"},{name:n==="in"?"amountIn":"amountOut",type:"uint128"},{name:n==="in"?"amountOutMinimum":"amountInMaximum",type:"uint128"},...c?[{name:"minHopPriceX36",type:"uint256"}]:[],{name:"hookData",type:"bytes"}]}],[{poolKey:t.poolKey,zeroForOne:t.zeroForOne,[n==="in"?"amountIn":"amountOut"]:a,[n==="in"?"amountOutMinimum":"amountInMaximum"]:i,...c?{minHopPriceX36:0n}:{},hookData:"0x"}])):(u=n==="in"?`0x${_u}${es}${ts}`:`0x${tp}${es}${ts}`,f=ao([{type:"tuple",components:[{name:n==="in"?"currencyIn":"currencyOut",type:"address"},{name:"path",type:"tuple[]",components:op},...c?[{name:"minHopPriceX36",type:"uint256[]"}]:[],{name:n==="in"?"amountIn":"amountOut",type:"uint128"},{name:n==="in"?"amountOutMinimum":"amountInMaximum",type:"uint128"}]}],[{[n==="in"?"currencyIn":"currencyOut"]:n==="in"?o:r,path:t.path,...c?{minHopPriceX36:[]}:{},[n==="in"?"amountIn":"amountOut"]:a,[n==="in"?"amountOutMinimum":"amountInMaximum"]:i}]));const y=ao([{type:"address"},{type:"uint256"}],[o,n==="in"?a:i]),m=ao([{type:"address"},{type:"address"},{type:"uint256"}],[r,s,0n]),g=ao([{type:"bytes"},{type:"bytes[]"}],[u,[f,y,m]]),h=d?`${al}${Ju}`:al,w=d?[g,ao([{type:"address"},{type:"address"},{type:"uint256"}],[Kn,d,0n])]:[g];return Tt({abi:Xu,functionName:"execute",args:[h,w,l]})}function dl(){return BigInt(Math.floor(Date.now()/1e3)+Yu)}function ul(e,t,n,o){return{to:e.permit2,value:0n,data:Tt({abi:Zu,functionName:"approve",args:[t,e.universalRouter,n,Number(o)]})}}function pl(e){const t=e.name??"Uniswap v4",n=e.v3?hr({...e.v3,chainIds:e.chainIds}):null;return{name:t,chainIds:e.chainIds,resolve:async(o,r,s)=>{const a=o.maxSlippage??nl,i=ns(o.tokenIn),l=ns(o.tokenOut),c=be(o.tokenIn),d=e.hubCurrencies??[Kn];let u=null;if(!io(i,l)&&o.amountIn>0n){const f=await ll(r,e,il(i,l,d,"in",Xs(r)),i,o.amountIn,"in").catch(()=>null);if(f){const y=Fi(f.amount,a),m=dl(),g=[];c||(g.push({to:o.tokenIn,value:0n,data:Tt({abi:ot,functionName:"approve",args:[e.permit2,o.amountIn]})}),g.push(ul(e,o.tokenIn,o.amountIn,m))),g.push({to:e.universalRouter,value:c?o.amountIn:0n,data:cl({candidate:f.candidate,direction:"in",currencyIn:i,currencyOut:l,recipient:s,exactAmount:o.amountIn,limitAmount:y,deadline:m,routerHasHopPrice:e.routerHasHopPrice})}),u={venue:t,amountOut:f.amount,amountOutMinimum:y,calls:g}}}return!u&&n?n.resolve(o,r,s):u}}}function fl(e){const t=e.name??"Uniswap v4";return{name:t,chainIds:e.chainIds,resolve:async(n,o,r)=>{const s=be(n.tokenIn),a=ns(n.tokenIn),i=ns(n.tokenOut);if(io(a,i)||n.amountOut<=0n)return null;const l=n.maxSlippage??nl,c=e.hubCurrencies??[Kn],d=await ll(o,e,il(a,i,c,"out",Xs(o)),i,n.amountOut,"out").catch(()=>null);if(!d)return null;const u=BigInt(Math.round(l*1e4)),f=d.amount+d.amount*u/10000n,y=dl();return{venue:t,amountIn:d.amount,amountInMax:f,amountOut:n.amountOut,calls:[...s?[]:[ul(e,n.tokenIn,f,y)],{to:e.universalRouter,value:s?f:0n,data:cl({candidate:d.candidate,direction:"out",currencyIn:a,currencyOut:i,recipient:r,exactAmount:n.amountOut,limitAmount:f,deadline:y,routerHasHopPrice:e.routerHasHopPrice,sweepNativeTo:s?r:void 0})}]}}}}const sa=[{...ta,protocol:"uniswap-v3",chainId:4114},{...ta,protocol:"uniswap-v3",chainId:5115},{...ji,protocol:"uniswap-v3",chainId:8453},{...Gi,protocol:"uniswap-v3",chainId:1},{...Ki,protocol:"uniswap-v3",chainId:42161},{...Vu,protocol:"uniswap-v3",chainId:137},{...Qu,protocol:"uniswap-v3",chainId:56},{...ju,protocol:"uniswap-v3",chainId:143},{...Yi,protocol:"uniswap-v3",chainId:4663},{...Zi,protocol:"uniswap-v3",chainId:4663},{...ol,protocol:"uniswap-v4",chainId:8453},{...rl,protocol:"uniswap-v4",chainId:4663},{...$r,protocol:"aerodrome-slipstream",chainId:8453}];function Eo(e){const t=e?.includeDefaults===!1?e.venues??[]:[...sa,...e?.venues??[]],n=[],o=[];for(const r of t){const s=[r.chainId];switch(r.protocol){case"uniswap-v3":{const a={...r,chainIds:s};n.push(hr(a)),o.push(oa(a));break}case"uniswap-v4":{const a={...r,chainIds:s};n.push(pl(a)),o.push(fl(a));break}case"aerodrome-slipstream":{const a={...r,chainIds:s};n.push(_r(a)),o.push(_i(a));break}default:{const a=r;throw new ze("INVALID_PARAMS",`Unsupported liquidity venue protocol: ${a.protocol}`,{protocol:a.protocol})}}}return{input:n,output:o}}const aa=new Set(["WBTC","CBTC"]),ml=new Set(["btc","wbtc","wcbtc","cbtc"]);function hl(e,t){return!e||!t?!1:e===t?!0:aa.has(e)&&aa.has(t)}function Yn(e){const[t,n,o]=e.split(":");if(t!=="evm"||!n||!o)return null;const r=Number(n);if(!Number.isFinite(r))return null;const s=o.startsWith("0x")?o.toLowerCase():`0x${o.toLowerCase()}`;return{chainId:r,address:s}}function os(e){return(e??"").trim().replace(/^test\s+/i,"").replace(/^spice/i,"").toLowerCase().replace(/[^a-z0-9]/g,"")}function sp(e){return new Set([e.receiptTokenName,e.displaySymbol,e.symbol,e.displayName,e.name].map(os).filter(Boolean))}function ap(e,t){const n=sp(e),o=[t.symbol,t.name,t.equivalenceGroup].map(os);if(o.some(a=>a&&n.has(a)))return!0;const r=[...n].some(a=>ml.has(a)),s=o.some(a=>ml.has(a))||aa.has(t.equivalenceGroup??"");return r&&s}function gl(e,t,n){const o=new Set(t.map(os).filter(Boolean)),r=s=>{if(n&&oe(s.address,n))return 0;const a=[s.symbol,s.name,s.equivalenceGroup].map(os).findIndex(i=>i&&o.has(i));return a===-1?4:a+1};return[...e].sort((s,a)=>{const i=r(s)-r(a);return i!==0?i:s.address.toLowerCase().localeCompare(a.address.toLowerCase())})}function zo(e,t){const n=e.chainTokens?Object.keys(e.chainTokens):[],o=[];for(const r of n){const s=Yn(r);if(!s||s.chainId!==t)continue;const a=s.address,i=be(a)?nt(t)?.nativeCurrency:void 0,l=Ut(a,t)??(i?{...i}:void 0);l&&(!ia(e,a,t)&&!(e.isUniversal&&ap(e,l))||o.some(c=>oe(c,a))||o.push(a))}return gl(o.map(r=>{const s=Ut(r,t);return{address:r,symbol:s?.symbol,name:s?.name,equivalenceGroup:s?.equivalenceGroup}}),[e.receiptTokenName,e.displaySymbol,e.symbol,e.displayName,e.name],e.chainId===t&&!e.isUniversal?e.address:void 0).map(r=>r.address)}function ia(e,t,n){return e.chainId===n&&oe(e.address,t)?!0:gr(e.address,e.chainId,t,n)}async function ip(e,t){const n=bt(e),o=ro(e);return be(t)?n.getBalance({address:o}):await n.readContract({address:t,abi:ot,functionName:"balanceOf",args:[o]})}function la(e,t,n){const o=ur(n),r=o.find(a=>oe(a.address,e));if(r&&(t===n||!be(e)))return r;const s=Ut(e,t);if(s)return gl(o.filter(a=>hl(a.equivalenceGroup,s.equivalenceGroup)),[s.symbol,s.name,s.equivalenceGroup])[0]}function rs(e){return e.equivalenceGroup==="USDC"&&e.symbol.toUpperCase()!=="USDT"}function yl(e){const t=pr(e);if(!t||t===Dt)return;const n=ur(e).filter(rs);return n.find(o=>o.symbol.toUpperCase()==="USDC")??n[0]}function ca(e,t){if(e.chainId===t)return null;const n=pr(e.chainId),o=pr(t);if(!n||n===Dt||!o||o===Dt)return null;const r=!e.isNative&&!be(e.address)?Ut(e.address,e.chainId):void 0,s=r&&rs(r)?la(e.address,e.chainId,t):void 0,a=s?r:yl(e.chainId),i=s??yl(t);if(!a||!i)return null;const l=c=>({address:c.address,symbol:c.symbol,decimals:c.decimals,chainId:c.chainId});return{source:l(a),destination:l(i)}}function lp(e,t){return!!ca(e,t)}function Pn(e,t){if(e.chainId===t)return e.address;const n=la(e.address,e.chainId,t);return n?n.address:null}async function lo(e,t,n,o){const r=Ut(t,n);return r?r.decimals:e?.chainId===n&&oe(e.address,t)&&!e.isUniversal?e.decimals:o?.chainId===n&&oe(o.address,t)?o.decimals:Vr(n,t)}async function wl(e,t,n={}){const o=Pn(e,t),r=zo(e,t);if(r.length===0)return o;if(r.length===1)return r[0];const s=n.requiredAmount??0n,a=i=>{const l=r.map(c=>({candidate:c,balance:i.get(be(c)?"native":c.toLowerCase())??0n})).filter(c=>c.balance>0n).sort((c,d)=>c.balance===d.balance?0:c.balance>d.balance?-1:1);return l.length===0?null:((s>0n?l.find(c=>c.balance>=s):l[0])??l[0]).candidate};try{const i=await Promise.all(r.map(async d=>({key:be(d)?"native":d.toLowerCase(),value:await ip(t,d)}))),l=new Map(i.map(({key:d,value:u})=>[d,u])),c=a(l);if(c)return c}catch{}return o}function gr(e,t,n,o){const r=Ut(e,t),s=Ut(n,o);return r&&s?hl(r.equivalenceGroup,s.equivalenceGroup):cu(e,n)}function ss(e,t){return gr(e.address,e.chainId,t.address,t.chainId)}const xl=.01;function bl(e,t=!1){const n=Number.isFinite(e.balanceUsd)&&e.balanceUsd>0;return e.isDiscovered?n&&e.balanceUsd>=xl:!t||!n||e.balanceUsd>=xl}function as(e,t=!1){return!!e&&e._source==="wallet"&&(e.location==="external"||e._fundingWallet==="external"||!e.location&&!e._fundingWallet&&t)}function Ce(e){return e.positionId??`${e.owner?.toLowerCase()??""}:${e.location??e._source??""}:${e.chainId}:${e.receiptTokenId??dt(e.address).toLowerCase()}`}function vl(e,t){if(!t?.length||e.symbol!==void 0&&Qr({...e,symbol:e.symbol},t))return!0;const n=o=>t.some(r=>oe(dt(r),dt(o)));return n(e.address)||Object.keys(e.chainTokens??{}).some(o=>{const r=Yn(o);return r?n(r.address):!1})}function go(e,t,n,o,r,s){const a=(g,h=!1)=>({eligible:!1,reason:g,policyExcluded:h}),i=e._source==="wallet"||e.location==="external"||e.location==="embedded",l=t==="spend-source"&&i&&!!o&&e.chainId===o.chainId&&oe(dt(e.address),dt(o.address));if(n.isWhitelistGateActive||!l&&!Qr(e,n.allowedTokens))return a("Asset excluded by client policy",!0);if(t!=="withdraw-destination"&&!l&&!bl(e))return a("Asset is unpriced or below the minimum value",!0);if(t==="holding")return{eligible:!0,reason:null};if(e.balanceError)return a(e.balanceError);if(!l&&!vl(e,r))return a("Asset excluded by action policy",!0);const c=new Set(o?[o.chainId]:[]);e._source!=="spice"&&e.location!=="rollup"&&c.add(e.chainId);for(const g of c)if(!xi(g,n.rpcOverrides)?.trim())return a(`Configure SpiceFlowProvider rpcOverrides[${g}] before using this asset.`);if(s?.requiresEscrow){const g=Ut(e.address,e.chainId);if(!g||!rs(g))return a("This asset has no supported escrow mapping")}if(!o)return{eligible:!0,reason:null};const d=n.liquidityVenues?.includeDefaults===!1?n.liquidityVenues.venues??[]:[...sa,...n.liquidityVenues?.venues??[]],u=g=>d.some(h=>h.chainId===g),f=i&&e.chainId!==o.chainId,y=f?ca(e,o.chainId):null;if(f&&!y)return a("No supported source route");if(y&&!oe(dt(e.address),dt(y.source.address))&&!u(e.chainId))return a("No conversion venue configured on the source chain");const m=y?.destination.address??Pn(e,o.chainId);return t==="withdraw-destination"?(e.chainTokens||e.receiptTokenId?zo(e,o.chainId):m?[m]:[]).some(g=>oe(dt(g),dt(o.address)))?{eligible:!0,reason:null}:a("No supported withdrawal mapping"):m&&oe(dt(m),dt(o.address))?{eligible:!0,reason:null}:!m&&!lp(e,o.chainId)?a("No supported destination route"):u(o.chainId)?{eligible:!0,reason:null}:a("No conversion venue configured on the destination chain")}function is(){const e=Kt(Ht),[t]=P(jd);return e?.inventory??t}function da(e,t,n,o,r){const s=is(),a=r??s,i=me(()=>a.entry(e),[a,e]),[,l]=P(0);ue(()=>{if(n)return i.subscribe(()=>l(d=>d+1),t,o)},[i,n,t,o]);const c=te(()=>i.refresh(),[i]);return{...n?i.snapshot():Gd,refresh:c}}var Cl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAA6lBMVEXc3NzX/v/1hRvZ2dnd3dzb29va7fpMaXHa1tPc3N35/v/c3Nzc3NzCrp/c3Nza2tp1PRbLsJzlr33uhSj0kTHcnWnUva7jdhuNX0B6Qhrsk0LOxMCFVDJ+RyGhfGTkeiGYVSHjdx3lij7khDPEsaPfoW/jgjLQuKXmgzB2PRb2hRvldhvjdRv4hhvpeRtwORb/ihryghvabhnsehrUaRjLXxXtfRt7PxXwexricRbRYhURFBeSTBe0XBrEZxmDRxiiVRrlgCbfzMAvLCmrWBgbMEh9UjBbOBe2pJi9byekk4nkgDHkgDJLNB7jlKArAAAAKXRSTlMzJv0TNSYsADUxKBwK/QUZ/URTx650/vqJ5YpMosxj3ezwkqa6/q3KrihQ98kAAAAJcEhZcwAACxMAAAsTAQCanBgAAATxSURBVHjapVeJcuI4EJXBdiRuw4JzDAFyzeIT22BsNgTIJNnM7Pz/90xLsmV5ChJm6SqqZOR+7teXWujsgLSqdU0jBCFCNK1ebR16D+39t1HXiKqqGDHBsCRavXEsQKutIVWln0aZ0BX8o7VbRwC06gS+LHQLIWAJqbc+A6iC+h7t3BCVVD8EaGgqOqSemaFqjcMA8PkP1RnEb0bIAPXD1peNqO8H0NQj1LkR2j6Ao/XLCOh/6JcQkOD/B/oUoV4GqGb6+HNdnCFUZYBG9nmsE/whBsZE5y9g0pAAcgcQQ1V0fAgDNnRFNQiW3cAA2lwfI3wxvunqyl4z4OOK3r0ZX2CUIbRzgFZOoHY9nW7NXt9QdFTGgCddMfq9cDudXteyLdLKAPII4NqXZcffzIPJQx8zDCFgev9hksw3fmf5pYalSCDJAGAw7Uz9zkuU2CNKRQiYPrIT76Xjwws5B/BjiwG0hQHAgIr/GHpeYvb+EtIzI88LH32+fy1MaDMAKOGCAUdYPnmmE82ERI7pPS25fsEB0UCgs4ZwVO08AwB5sT0zrmQSm7b94mff7yzPa8LBDQAQSSwo5DRsKxO7MF+mwNyIBAPwjHEhIQCNgOsHwnwmF4aeWwAcUEMO97DgABAvkUv13WgrqXeWQ7moGqiqFtkivJjTCADBDWTzZR9SE6pIquOSF6msGYdgPS0BSD4EJ6CikUB+DKcd2QkRB4hkF3SmQyyqHioKaViicF4AQEp7DqfgRJDCSwFxLlPQ5GMAAHJ9n4bRyQEcGkZ/HwColwBYHH3fXz6uHc+xnZgCxLDwnPXj0mcgUhRpOZSblTEE9c32ybMi27ELAHiILO9puwGIoXG48YEJ43UYzGYumG/LADbQcGezIFyPjRr+7aCREfTezLUqFtMB4QB87cSw4c56uqyPSz4A/S6UDuikqzkTmwLYfL1K4aFiVbolBCKHEWHlclahyRvMF4vFarWgOm5KV4vFnIbEqswuFUmD5oF0olAGFZ7+88VqvV05FMBZbderxZwXRqXEgSaSfCTp3cDiAIETvr2+riP64K1fX99ClhMA4AIH+YAqFVPGgGnFu+9v44Quk/Hb913suXyjzAGKSS7nnAEtgBg6WeAxLIjrLM56A+NQKueioVAGruW67OdWrCCwYqoS01XgZmLJHGhDkVqa3oXeSyUESaktvBrBJ5WU/sd3IxFI3tKKpkrwCDIQcjCkUfPAnIAJ+NSjcQ1tuuuNMCk11TORCVh5SEyWdXP2dmzxpk4TEzDnbMtM/lakligfLADQj3gOOysASNPd5l+QzS5NAWCVbUV9RTBol442cIIxsVnlwPthurtv/sOkeb9LQ2oS25qIcs6PNtmNvch0HBOKN/15P3h+5wDvz4P7/1IocNhzop7swvLxTjMpMm0viSa9m6/Pg+cf35j8gOXXm94kSjzbjIo8Esd7cbxCIBNzdNs3dAXdDQbN9ybIe3MwuEOKbvRvR2YigigNGNKMh28vu0ihswGp9ZuDJpNBs0+HFjjuUffyFpcnvfKQhbgym06wcnXHAe6umNWYjSlKkcXlMa8YpIrEIldMCMHyrLNvzDs0aBImxwyap4+6pw/bp4/71A/opAvH6Vee0y9dn1z70OfXvuziudcMSKdjLp786quecPWVL99Zfqt/ePkuX/8Jv/43Dl3/fwH9bPJ09nq7MQAAAABJRU5ErkJggg==",cp="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAQlBMVEVMaXGGl/+Elf+HmP+Hmf+Hl/+Gl/+Flv+Glv+Gl/+Gl/+Gl/////+On/+Akv/4+f/v8f/i5v+9x//S2P+tuP+erP+W3PvUAAAAC3RSTlMArBlx7Isy/vvOXbb4wDYAAAAJcEhZcwAACxMAAAsTAQCanBgAAALuSURBVHjarVfbtqsgDOxu0UBpkOv//+pJRC0i2HZ58uTeqzOEyYXkduvY/Tn8KSEBpFB/w3O8/WTjoCSS6dn4S6rha477QxFGS0nHM56ckJL/ox73b+CDQAQJujKiQxTDR4qH4LN109gP8Ti/uyI46K4BUagTLZ4Cz+CZAsWzhx/oeP3RyImhjf/7ePzmxF8Hr7+zNsP3eL7GkWH4Bc8MlQ7P3/DMsIvFKHRLPzBsTWVBizIfVNMBg9H7mLQxTRdUkb9tfJxebNZjywuJW1bf2xcw4WXtzDF5bVqXuJ9HwETHNnPYeHRii0THgcwQyBxTBDQ9Fx7dEBr0TOCDYyeS6aigsFsCQIFgBh9YiVgxQA7EqM9KiCiS95nh5WsGPZ4k8ZZFRqfoY4shy9i8AaExxRgTMgcApuSODPMdRtn02wc7Z9HkPMsPa1ZVOsiRygga4udfZ5vTKKx/7GIBVFJHCUy0r705DNu3LQ9kEQ6NxMTXwWzhUTD7xlJr2MLvrZCBVazy2OD0iaC4BGh1k4cSLOSbbIuujKW4wT76aYefrGswuBJSEoBeUnaFk7nQcKEIJZRXMPsfM95O3p3KKAoRa/cJTh0pHKMybSqyiO8wMsG0wzODi7UK9u0Ah7FIJAj1+UyQcl4Gqi2uax+L/siJVKQyi+j251sbMoHTZrUqlctiojDGRX27WpivYNtdi4upKme0c/gXBmdzY7ZoOi/cWDeU7MJy+oKn3hzbT9/cFKt6pmKe9udnCoTeG103VW7EjrGZJMOD863GNzfVQ0EDP6aJUH61wBRHGZa23npYDDpuh8EnpPBRS6UUQOg9r8enzaDdmhmsPkH/da3bokkr/i0dwMmYU7lg0pRrwiVzNrW+n/dKhVzVVIbGnE9Jj86IA8glk87h+xGnGrJyzXwYNvdD1uUx7/qgeX3UvT5sXx/3ry8c11ee60vX9bXvvXjWfsC3i+d79YV19+WPH1bf/7B8Lxy8/isBINTp+v8Ph4CTcAywkiYAAAAASUVORK5CYII=",dp="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAPFBMVEVMaXGZhueZh+eYhuWXheWYh+eYhuaXheCYhuaah+j//fmhjvOSf+Sdi+q8sOzNxO/m4fT08fapmuja0/Jb/wGxAAAACnRSTlMArEz/IYtsA87sGIEBYwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAmJJREFUeNqtV4uSgyAMRIECGhTk///1otTKG3s2Mzdz03aXbEJIQkhuYv9jIx+komhKDnxk4v1F1wT+SoxcUj3PWu8Ex39U8lH4bzt4QthL6tlDA8OP5Iv1vMADGFc5+uRQnDWdEES81EwbNquXqDuBx8va6ZcXktUYBOkc/3GixsBvwA8neFGGGO7hdyeGAsMXeM/wBJ8ziLv6LwYeisD4f4lHhiAXmH9FvzYV3AchOw6At9gFKW4KANDbsttGoSyCKd1Ab4uxkzezhBQaRfQygHB3oj2FhjwT9QgifErM6jiOrQgAXe2UmcuiIKSuHG+mki2XCH0kYqzgF1vETyYszLFaxLBMNdsgDGNFAazRoUcwrDMlDYz28RS0newGcCRlDa8TK4YgxuORGj9x8NYVEsxjKQSp/pNAw5YRcJI/JP5nYeqxjAxeIfCeRQQDyWOos/y5xR2V4NIgYhRJVkjgpralBPcvQH4PsBxIX0DjJqKRdgYLtsYPUyqh60CsACXEQew7ECvAICZp7DqwQEIQXaR+CkzaoeKr3FewQdqg4mIy36VgLyZWz4G96N5vs8sKj0UPSlJGy4fAbWX88SgGQYgJVjDXi7JaaxYo9Oj4UQ0lrHCGdN25ceiEfNoZSfIomjhcKN26DarT0q4gaiyfe2C9u9hWNUBvRghbG+yd1AZNFFrjmu+ucXMF2j60OObE7f0m+mrv/5qQkimpO+IU8fKXQ9bDMe/5oPl81P3BsP183EeGu3GoLBw/WHnuLF20sXQ9X/ueL57PV99w+Z7P5Vvj8j3fXr7j9X/f/5Vsrv9/K3NM7mGXOq0AAAAASUVORK5CYII=",yr="data:image/svg+xml,%3csvg width='8' height='11' viewBox='57 6 8 11' fill='none' xmlns='http://www.w3.org/2000/svg'%3e %3cpath d='M62.7081 13.27C62.742 13.27 62.7642 13.3057 62.7491 13.3362V13.336L61.1229 16.6083C61.0892 16.6761 60.9926 16.6759 60.959 16.6083L59.3382 13.336C59.3232 13.3057 59.3453 13.27 59.3792 13.27H62.7081Z' fill='%23EA4B4B'/%3e %3cpath d='M61.0026 9.71913C61.0194 9.68524 61.0678 9.68524 61.0845 9.71913L62.747 13.0897C62.762 13.12 62.7399 13.1557 62.706 13.1557H59.3763C59.3424 13.1557 59.3203 13.12 59.3353 13.0897L61.0026 9.71913Z' fill='%23EA4B4B'/%3e %3cpath d='M60.8426 9.63827C60.8766 9.63827 60.8987 9.6741 60.8835 9.70444L59.2164 13.0594C59.1995 13.0932 59.1513 13.0932 59.1345 13.0594L57.5001 9.77047C57.47 9.70962 57.5142 9.63827 57.5821 9.63827H60.8426Z' fill='%23EA4B4B'/%3e %3cpath d='M64.5036 9.63617C64.5715 9.63618 64.6157 9.70753 64.5855 9.76838H64.5854L62.9512 13.0573C62.9344 13.0911 62.8862 13.0912 62.8692 13.0573L61.2021 9.70235C61.187 9.672 61.2091 9.63617 61.2431 9.63617H64.5036Z' fill='%23EA4B4B'/%3e %3cpath d='M62.8284 6.18281C62.862 6.11518 62.9586 6.11518 62.9922 6.18281L64.5855 9.38969C64.6157 9.45054 64.5715 9.52189 64.5036 9.52189H61.2431C61.2091 9.52189 61.187 9.48605 61.2021 9.45571L62.8283 6.18265L62.8284 6.18281Z' fill='%23EA4B4B'/%3e %3cpath d='M62.3131 6.13196C62.381 6.13196 62.4252 6.20331 62.3951 6.26416C62.154 6.74935 61.9128 7.23455 61.6718 7.71975H61.6716C61.4225 8.22125 61.1733 8.72259 60.9242 9.22409C60.9074 9.25799 60.859 9.25799 60.8422 9.22409L60.6305 8.79587C60.6275 8.78957 60.6259 8.78263 60.6259 8.77553V6.22349C60.6259 6.17297 60.6668 6.13196 60.7173 6.13196H62.3131Z' fill='%23EA4B4B'/%3e%3c/svg%3e";const wr=Bi(1)?.logo??"",up=Oi.find(e=>e.symbol==="USDC")?.logo??"",yo=Object.fromEntries([...du(),...uu()].map(e=>[e.id,e.logo])),xr={metamask:Cl,metaMask:Cl,rabby:cp,phantom:dp},ua=Object.fromEntries(Oi.map(e=>[e.symbol.toUpperCase(),e.logo])),pp={usdc:[8453,1,42161,5115,4114],usdt:[1],btc:[4114,42161,1,5115],wbtc:[1],weth:[8453,1],eth:[8453,1,42161,4663,84532,46630],ctusd:[5115,4114],wcbtc:[5115,4114]},fp={btc:["wcbtc","cbtc","wbtc"]};function ls(e){return e.replace(/^test\s*/i,"").replace(/^spice/i,"").trim()}function co(e){return ls(e).toLowerCase()}function kl(e){return co(e??"").replace(/[^a-z0-9]/g,"")}function pa(e){const t=co(e);return[t,...fp[t]??[]].filter(Boolean)}function mp(e){try{return BigInt(e.balanceAvailable||"0")}catch{return 0n}}function Il(e){return Array.isArray(e.chainTokens)?e.chainTokens:Object.keys(e.chainTokens??{})}function Sl(e,t){const n=nt(e),o=t.toLowerCase();return o===Dt.toLowerCase()?n?.nativeCurrency.decimals??18:n?.supportedTokens?.find(r=>r.address.toLowerCase()===o)?.decimals??18}function hp(e,t,n,o=[]){const r=Sl(t,n),s=e.filter(i=>Al(i,t,n,o));if(s.length===0)return null;const a=s.reduce((i,l)=>Math.min(i,l.decimals??r),r);return{chainDecimals:r,receiptDecimals:a}}function Al(e,t,n,o){if(Il(e).some(s=>{const a=Yn(s);return a&&gr(a.address,a.chainId,n,t)}))return!0;const r=new Set(o.map(kl).filter(Boolean));return r.size===0?!1:r.has(kl(e.tokenName||e.receiptToken))}function fa(e,t,n,o=[]){const r=Sl(t,n);return e.reduce((s,a)=>Al(a,t,n,o)?s+Vn(mp(a),a.decimals??r,r):s,0n)}function El(e,t){const n=new Set([...pa(t),...pa(ls(t))]);return[...e].sort((o,r)=>{const s=co(o.symbol),a=co(r.symbol),i=co(o.name),l=co(r.name),c=n.has(s)?0:n.has(i)?1:2,d=n.has(a)?0:n.has(l)?1:2;return c!==d?c-d:o.address.toLowerCase().localeCompare(r.address.toLowerCase())})[0]}function gp(e){const t=e&&e.length>0?e:Object.keys(jr).map(Number).filter(Number.isFinite),n=new Map;for(const o of t){const r=nt(o);if(!r)continue;const s=`${o}:${Dt.toLowerCase()}`;n.has(s)||n.set(s,{address:Dt,chainId:o,symbol:r.nativeCurrency.symbol,name:r.nativeCurrency.name,decimals:r.nativeCurrency.decimals,isNative:!0,logoURI:ua[r.nativeCurrency.symbol.toUpperCase()]??r.logo});for(const a of r.supportedTokens??[]){const i=a.address.toLowerCase(),l=`${o}:${i}`;n.has(l)||n.set(l,{address:i,chainId:o,symbol:a.symbol,name:a.name,decimals:a.decimals,isNative:be(i),logoURI:a.logo})}}return n}function yp(e,t){const n=gp(t),o=ls(e.tokenName),r=co(e.tokenName),s=pa(e.tokenName),a=Array.isArray(e.chainTokens)?e.chainTokens.map(m=>[m,void 0]):Object.entries(e.chainTokens??{}),i=a.map(([m])=>Yn(m)).filter(m=>m!==null),l=new Map;for(const[m,g]of a){const h=Yn(m);if(!h||!Number.isSafeInteger(h.chainId)||h.chainId<0||!/^evm:[0-9]+:(?:0x)?[0-9a-fA-F]{40}$/.test(m)){if(!Array.isArray(e.chainTokens))throw new Error("Invalid chain token metadata identity");continue}if(g!==void 0&&(!g||typeof g!="object"||Array.isArray(g)||g.name!==void 0&&typeof g.name!="string"||g.decimals!==void 0&&(!Number.isInteger(g.decimals)||g.decimals<0||g.decimals>255)))throw new Error("Invalid chain token metadata");const w=`${h.chainId}:${h.address.toLowerCase()}`;if(l.has(w)){const x=l.get(w);if(x?.name!==g?.name||x?.decimals!==g?.decimals)throw new Error("Conflicting chain token metadata")}l.set(w,g)}const c=(m,g)=>{const h=l.get(`${g.chainId}:${g.address.toLowerCase()}`);return{...m,name:typeof h?.name=="string"&&h.name.length>0?h.name:m.name,decimals:typeof h?.decimals=="number"?h.decimals:m.decimals}},d=i.map(m=>{const g=n.get(`${m.chainId}:${m.address.toLowerCase()}`);return g?c(g,m):void 0}).filter(m=>m!==void 0),u=pp[r]??[];if(u.length>0)for(const m of u){const g=d.filter(h=>h.chainId===m);if(g.length>0)return El(g,e.tokenName)}if(d.length>0)return El(d,e.tokenName);const f=Array.from(n.values()).filter(m=>s.includes(co(m.symbol))||s.includes(co(m.name)));if(u.length>0)for(const m of u){const g=f.find(h=>h.chainId===m);if(g)return g}if(f.length>0)return f[0];const y=i[0];if(y){const m=l.get(`${y.chainId}:${y.address.toLowerCase()}`);return{address:y.address,chainId:y.chainId,symbol:o||e.tokenName,name:typeof m?.name=="string"&&m.name.length>0?m.name:o||e.tokenName,decimals:typeof m?.decimals=="number"?m.decimals:e.decimals??18,isNative:be(y.address),logoURI:void 0}}}function wp(e,t){let n;try{n=BigInt(e.balanceAvailable||"0")}catch{return null}if(n<=0n)return null;if(t?.length){const m=Il(e).map(Yn).filter(g=>g!==null);if(m.length>0&&!m.some(g=>t.includes(g.chainId)))return null}let o;try{o=yp(e,t)}catch{return null}const r=o?.decimals??e.decimals??18,s=e.decimals??r,a=Vn(n,s,r),i=o?.address??Dt,l=o?.chainId??0,c=ls(e.tokenName),d=o?.symbol??c,u=o?.name??c,f=parseFloat(Ee(a,r)),y=typeof e.balanceUsd=="number"?e.balanceUsd:typeof e.balanceUsd=="string"&&Number(e.balanceUsd)||0;return{address:i,symbol:d,name:u,decimals:r,chainId:l,balance:a,balanceFormatted:f,balanceUsd:y,isNative:o?.isNative??be(i),logoURI:o?.logoURI,displaySymbol:c||d,displayName:c||u,displayChainName:"Spicenet",receiptTokenId:e.receiptToken,receiptTokenName:e.tokenName||u,receiptTokenDecimals:s,chainTokens:e.chainTokens&&!Array.isArray(e.chainTokens)?e.chainTokens:void 0,isUniversal:!0}}const ma=6e4,xp=3e5,Fl="https://api.g.alchemy.com/prices/v1",qo=new Map;function ha(e,t){try{const n=t??bt(e).transport.url;if(typeof n!="string")return null;const{hostname:o,pathname:r}=new URL(n);if(!o.endsWith(".g.alchemy.com"))return null;const s=r.split("/").filter(Boolean).pop();return s?{network:o.slice(0,-14),key:s}:null}catch{return null}}const br=(e,t)=>`${e.network}:${e.key}:${t.toLowerCase()}`;function vr(e,t){const n=qo.get(br(e,t));if(!n?.price||n.updatedAt===void 0)return;const o=Date.now()-n.updatedAt;if(!(o>=xp))return{price:n.price,stale:o>=ma}}function Tl(e){const t=Number(e.prices?.find(n=>n.currency==="usd")?.value);return Number.isFinite(t)&&t>0?t:0}async function Bl(e,t,n){const o=[],r=new Set,s=Date.now();for(const a of new Set(t.map(i=>i.toLowerCase()))){const i=qo.get(br(e,a));i?.pending?r.add(i.pending):(!i||s-i.attemptedAt>=ma&&(i.updatedAt===void 0||s-i.updatedAt>=ma))&&o.push(a)}for(let a=0;a<o.length;a+=25){const i=o.slice(a,a+25),l=Promise.resolve().then(async()=>{try{const c=await n(i);for(const d of i){const u=c.get(d);if(!u)continue;const f=qo.get(br(e,d));f.price=u,f.updatedAt=Date.now()}}catch{}finally{for(const c of i)qo.get(br(e,c)).pending=void 0}});for(const c of i){const d=br(e,c);qo.set(d,{...qo.get(d),attemptedAt:s,pending:l})}r.add(l)}await Promise.all(r)}async function ga(e,t){return await Bl(e,t,async n=>{const o=await fetch(`${Fl}/${e.key}/tokens/by-address`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({addresses:n.map(a=>({network:e.network,address:a}))}),signal:AbortSignal.timeout(1e4)});if(!o.ok)throw new Error("Provider price request failed");const r=await o.json(),s=new Map;for(const a of r?.data??[]){if(a.network&&a.network!==e.network)continue;const i=String(a.address).toLowerCase();n.includes(i)&&s.set(i,Tl(a))}return s}),new Map(t.map(n=>[n.toLowerCase(),vr(e,n)?.price??0]))}async function ya(e,t){const n=`native:${t}`;return await Bl(e,[n],async()=>{const o=await fetch(`${Fl}/${e.key}/tokens/by-symbol?symbols=${encodeURIComponent(t)}`,{signal:AbortSignal.timeout(1e4)});if(!o.ok)throw new Error("Provider native price request failed");const r=(await o.json())?.data?.find(s=>s.symbol?.toUpperCase()===t.toUpperCase());return new Map([[n.toLowerCase(),r?Tl(r):0]])}),vr(e,n)?.price??0}async function bp(e,t){const n=t.supportedChains,o=e.map(r=>{if(Number.isFinite(r.balanceUsd)&&r.balanceUsd>0)return[];const s=Object.keys(r.chainTokens??{}).map(Yn).filter(a=>!!a&&vn(a.address)&&!!n?.includes(a.chainId));return s.sort((a,i)=>{const l=c=>c===t.nativeChainId?-1:n.indexOf(c);return l(a.chainId)-l(i.chainId)||+!oe(a.address,r.address)-+!oe(i.address,r.address)}),s.flatMap(a=>{const i=t.rpcOverrides?.[a.chainId];if(!i)return[];const l=ha(a.chainId,i);if(!l)return[];const c=be(a.address)?nt(a.chainId)?.nativeCurrency.symbol:void 0,d=c?`native:${c}`:a.address;return[{rpc:l,token:d,address:a.address,nativeSymbol:c}]})});return(typeof document>"u"||!document.hidden)&&await Promise.all(o.map(async r=>{for(const s of r)if(s.nativeSymbol?await ya(s.rpc,s.nativeSymbol).catch(()=>0):(await ga(s.rpc,[s.address]).catch(()=>new Map)).get(s.address.toLowerCase()))break})),e.map((r,s)=>{if(Number.isFinite(r.balanceUsd)&&r.balanceUsd>0)return r;const a=o[s].map(i=>vr(i.rpc,i.token)).find(Boolean);return{...r,balanceUsd:a?r.balanceFormatted*a.price:0,priceStatus:a?a.stale?"stale":"fresh":"unavailable"}})}function vp(e,t,n){const o=Kt(Ht),[r,s]=P(()=>typeof document>"u"||!document.hidden);ue(()=>{const d=()=>s(!document.hidden);return document.addEventListener("visibilitychange",d),()=>document.removeEventListener("visibilitychange",d)},[]);const a={supportedChains:n??o?.supportedChainIds,nativeChainId:o?.nativeChainId,rpcOverrides:o?.rpcOverrides},i=JSON.stringify([e,a],(d,u)=>typeof u=="bigint"?u.toString():u),l=te(()=>bp(e,a),[i]),c=da(`prices:${i}`,l,t&&r&&e.length>0,6e4);return c.updatedAt?c.assets:e}function Cp(e){const t=e.chainTokens??e.chainTokenConfig;if(Array.isArray(t))return t.filter(n=>typeof n=="string");if(t&&typeof t=="object")return t}const Ol=({address:e,supportedChains:t,enabled:n=!0,refetchInterval:o,priceEnabled:r=!1})=>{const s=Kt(Ht),a=s?.apiUrl||Yd,i=is(),l=s?.supportedChainIds??t,c=JSON.stringify([...l??[]].sort((k,S)=>k-S)),d=e?.toLowerCase(),u=te(async()=>{const k=await Kd(`${a}/wallets/${d}/balance`,{cache:"no-store"});if(!k.ok)throw new Error(`Failed to fetch balance: ${k.status}`);const S=await k.json();if(!Array.isArray(S.balances))throw new Error("Invalid balance response");return S.balances.map(F=>{const T=wp({receiptToken:typeof F.receiptToken=="string"?F.receiptToken:void 0,tokenName:String(F.tokenName??""),balanceAvailable:String(F.balanceAvailable??"0"),chainTokens:Cp(F),decimals:typeof F.decimals=="number"?F.decimals:void 0,balanceUsd:typeof F.balanceUsd=="number"||typeof F.balanceUsd=="string"?F.balanceUsd:null},l);return T?{...T,owner:d,location:"rollup",_source:"spice",positionId:`${d}:rollup:${T.receiptTokenId??T.address}`}:null}).filter(F=>F!==null)},[d,a,c,s?.nativeChainId,s?.rpcOverrides]),{assets:f,loading:y,refreshing:m,error:g,updatedAt:h}=da(`rollup:${d}:${a}:${c}`,u,n&&!!d,o??0,i),w=JSON.stringify(t??[]),x=me(()=>g?f.map(k=>({...k,balanceError:g,balanceStatus:"stale"})):f,[f,g]),b=vp(x,n&&r,l),v=me(()=>b.filter(k=>!t?.length||t.includes(k.chainId)||Object.keys(k.chainTokens??{}).some(S=>t.some(F=>S.startsWith(`evm:${F}:`)))),[b,w]),C=te(k=>v.filter(S=>S.chainId===k),[v]);return{assets:v,loading:y,error:g,hasBalance:v.some(k=>k.balance>0n),refreshing:m,updatedAt:h,refetch:i.invalidate,getAssetsByChain:C}};async function kp(e,t,n){if(n)return{decimals:n.decimals,symbol:n.symbol,name:n.name,logoURI:n.logo};const[o,r,s]=await Promise.all([ho(e,{address:t,abi:ot,functionName:"decimals"}),ho(e,{address:t,abi:ot,functionName:"symbol"}).catch(()=>"TOKEN"),ho(e,{address:t,abi:ot,functionName:"name"}).catch(()=>"TOKEN")]);if(!Number.isInteger(Number(o))||Number(o)<0||Number(o)>255)throw new Error("Invalid token decimals");return{decimals:Number(o),symbol:r,name:s,logoURI:void 0}}const Rl=async(e,t,n)=>{const o=bt(t,n),r=nt(t),s=await Gs(o,{address:e}),a=r.nativeCurrency,i=r.supportedTokens?.find(l=>be(l.address));return{address:Dt,name:a.name,symbol:a.symbol,decimals:a.decimals,balance:s,balanceFormatted:Number(Ee(s,a.decimals)),balanceUsd:0,logoURI:i?.logo||r.logo,isNative:!0,chainId:t}},Ip=async(e,t,n,o,r,s,a)=>{try{if(!vn(n))return null;const i=Yt(n),l=vn(e)?Yt(e):e,c=bt(t,a),d=await ho(c,{address:i,abi:ot,functionName:"balanceOf",args:[l]}),u=Number(Ee(d,s));return d>0n?{address:i,name:o,symbol:r,decimals:s,balance:d,balanceFormatted:u,balanceUsd:0,logoURI:void 0,isNative:!1,chainId:t}:null}catch(i){throw i}},Dl=(e,t)=>{const n=nt(t);if(!n)return e;const o=new Set(e.map(s=>s.address.toLowerCase())),r=e.some(s=>s.isNative);for(const s of n.supportedTokens||[])be(s.address)&&r||o.has(s.address.toLowerCase())||e.push({address:s.address,name:s.name,symbol:s.symbol,decimals:s.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:s.logo,isNative:be(s.address),chainId:t});if(!e.find(s=>s.isNative)){const s=n.supportedTokens?.find(a=>be(a.address));e.push({address:Dt,name:n.nativeCurrency.name,symbol:n.nativeCurrency.symbol,decimals:n.nativeCurrency.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:s?.logo||n.logo,isNative:!0,chainId:t})}return e},Sp=async(e,t,n)=>{const o=[],r=async i=>{for(const l of i){const c=await Ip(e,t,l.address,l.name,l.symbol,l.decimals,n);c&&(c.logoURI=l.logo,o.push(c))}},s=await Rl(e,t,n);s.balance>0n&&o.push(s);const a=(nt(t)?.supportedTokens||[]).filter(i=>!be(i.address));if(a.length>0)try{const i=bt(t,n),l=Yt(e),c=a.filter(y=>vn(y.address)).map(y=>({address:Yt(y.address),abi:ot,functionName:"balanceOf",args:[l]})),d=await i.multicall({contracts:c}),u=a.filter(y=>vn(y.address)),f=[];d.forEach((y,m)=>{if(y.status==="success"){const g=y.result;if(g&&g>0n){const h=u[m],w=Number(Ee(g,h.decimals));g>0n&&o.push({address:Yt(h.address),name:h.name,symbol:h.symbol,decimals:h.decimals,balance:g,balanceFormatted:w,balanceUsd:0,logoURI:h.logo,isNative:!1,chainId:t})}}else f.push(u[m])}),await r(f)}catch{await r(a)}return{tokens:Dl(o,t),chainId:t}},Ap=async(e,t,n)=>{const o=new Map,r=ha(e,n?n[e]??"":void 0);if(!r)return o;const s=t.filter(c=>be(c)),a=t.filter(c=>!be(c)),[i,l]=await Promise.all([a.length?ga(r,a).catch(()=>new Map):new Map,s.length?ya(r,nt(e)?.nativeCurrency?.symbol??"ETH").catch(()=>0):0]);for(const[c,d]of i)d>0&&o.set(c,d);if(l>0)for(const c of s)o.set(c.toLowerCase(),l);return o},Ep=async(e,t,n,o=!0,r)=>{const s=bt(t,r),a=Yt(e),i=[];let l;do{const w=await s.request({method:"alchemy_getTokenBalances",params:[a,"erc20",l?{pageKey:l}:{}]});i.push(...w.tokenBalances),l=w.pageKey||void 0}while(l);const c=i.filter(w=>vn(w.contractAddress)&&!!w.tokenBalance&&BigInt(w.tokenBalance)>0n),d=nt(t)?.supportedTokens||[],u=w=>d.find(x=>x.address.toLowerCase()===w.toLowerCase()),f=[],y=await Rl(e,t,r),[m,g,h]=await Promise.all([Promise.all(c.map(async w=>{const x=u(w.contractAddress);return x?{name:x.name,symbol:x.symbol,decimals:x.decimals,logo:x.logo??null}:await s.request({method:"alchemy_getTokenMetadata",params:[w.contractAddress]})})),o?ga(n,c.map(w=>w.contractAddress)):new Map(c.map(w=>[w.contractAddress.toLowerCase(),vr(n,w.contractAddress)?.price??0])),o&&y.balanceFormatted>0?ya(n,y.symbol):vr(n,`native:${y.symbol}`)?.price??0]);return y.balance>0n&&f.push({...y,balanceUsd:h*y.balanceFormatted}),c.forEach((w,x)=>{const b=m[x];if(!Number.isInteger(b.decimals)||b.decimals===null||b.decimals<0||b.decimals>255)throw new Error(`Invalid token metadata on chain ${t}`);const v=BigInt(w.tokenBalance),C=Number(Ee(v,b.decimals));if(v<=0n)return;const k=g.get(w.contractAddress.toLowerCase()),S=k?k*C:0;f.push({address:Yt(w.contractAddress),name:b.name||"Unknown",symbol:b.symbol||"UNKNOWN",decimals:b.decimals,balance:v,balanceFormatted:C,balanceUsd:S,isDiscovered:!u(w.contractAddress),logoURI:b.logo||void 0,isNative:!1,chainId:t})}),{tokens:Dl(f,t),chainId:t}},Ml=new Set,Fp=async(e,t,n=!0,o)=>{try{const r=ha(t,o?o[t]??"":void 0);if(r)try{return await Ep(e,t,r,n&&(typeof document>"u"||!document.hidden),o)}catch(s){Ml.has(t)||(Ml.add(t),console.warn(`Token discovery unavailable on chain ${t}; listing configured tokens only.`,s))}return await Sp(e,t,o)}catch(r){throw r}},Ho=async(e,t,n=[],o)=>{if(!e)throw new Error("Wallet address is required");const r=Zd(o),s=t?.length?[...new Set(t)]:Object.keys(r).map(Number),a=await Promise.allSettled(s.map(l=>Fp(e,l,!0,o))),i={};return a.forEach((l,c)=>{const d=s[c];i[d]=l.status==="fulfilled"?l.value:{chainId:d,tokens:[],error:`Unable to refresh balances on chain ${d}`}}),(await Promise.allSettled(n.map(async l=>{const c=i[l.chainId];if(!c||c.error||c.tokens.some(g=>dt(g.address).toLowerCase()===dt(l.address).toLowerCase()))return;const d=bt(l.chainId,o),u=await kp(d,l.address,l.decimals!==void 0&&l.symbol?{decimals:l.decimals,symbol:l.symbol,name:l.name||l.symbol,logo:l.logoURI}:void 0),f=await ho(d,{address:l.address,abi:ot,functionName:"balanceOf",args:[e]}),y=await Ap(l.chainId,[l.address],o),m=Number(Ee(f,u.decimals));c.tokens.push({...u,...l,name:u.name,symbol:u.symbol,decimals:u.decimals,balance:f,balanceFormatted:m,balanceUsd:(y.get(l.address.toLowerCase())||0)*m,isNative:!1})}))).forEach((l,c)=>{if(l.status==="rejected"){const d=i[n[c].chainId];d&&(d.error=`Unable to refresh token balances on chain ${d.chainId}`)}}),i},Cr=({address:e,supportedChains:t,fetchBalances:n=Ho,additionalTokens:o=[],enabled:r=!0,refreshInterval:s=0,priceEnabled:a=!0})=>{const i=Kt(Ht),l=is(),c=e?.toLowerCase(),d=JSON.stringify([...i?.supportedChainIds??t??[]].sort((x,b)=>x-b)),u=JSON.stringify(o);ue(()=>l.registerTokens(o),[l,u]);const f=c&&c===i?.embeddedWalletAddress?.toLowerCase()?"embedded":"external",y=`wallet:${JSON.stringify([i?.network,i?.apiUrl,i?.rpcOverrides])}:${c}:${f}:${d}:${l.fetcherId(n)}`,m=te(async()=>{let x;try{x=await n(c,JSON.parse(d),l.tokens(),i?.rpcOverrides)}catch(k){const S=k instanceof Error?k.message:"Unable to refresh balances";x=Object.fromEntries(JSON.parse(d).map(F=>[F,{chainId:F,tokens:[],error:S}]))}const b=l.entry(y).snapshot().assets,v=JSON.parse(d).map(k=>x[k]??{chainId:k,tokens:[],error:`Unable to refresh balances on chain ${k}`}),C=v.flatMap(k=>k.error?[k.error]:[]);return{assets:v.flatMap(k=>k.error?b.filter(S=>S.chainId===k.chainId).map(S=>({...S,balanceError:k.error,balanceStatus:"stale"})):k.tokens.map(S=>({...S,owner:c,location:f,_fundingWallet:f,_source:"wallet",positionId:`${c}:${f}:${k.chainId}:${dt(S.address).toLowerCase()}`}))),error:C.length?C.join("; "):null}},[l,c,d,n,f,y]),g=da(y,m,r&&!!c,s,l),h=JSON.stringify(t&&[...t].sort((x,b)=>x-b)),w=me(()=>t?g.assets.filter(x=>t.includes(x.chainId)):g.assets,[g.assets,h]);return ue(()=>{a&&r&&c&&g.refresh()},[a]),{...g,assets:w,refreshAssets:l.invalidate,getAssetsByChain:te(x=>w.filter(b=>b.chainId===x),[w]),getNativeAssets:te(()=>w.filter(x=>x.isNative),[w])}};function Vo(e){const t=Kt(Ht),n=is(),o=e.owner??((t?.mode||"7702")!=="7702"?t?.externalWalletAddress:t?.embeddedWalletAddress),r=o?.toLowerCase()!==t?.embeddedWalletAddress?.toLowerCase(),s=e.sourceChains??t?.supportedChainIds??[],a=(e.enabled??!0)&&!t?.isWhitelistGateActive,i=me(()=>{const f=[...t?.additionalSourceTokens??[],...e.additionalSourceTokens??[],...e.destination?[e.destination]:[]];for(const y of e.supportedSourceAssets??[])for(const m of s){const g=nt(m)?.supportedTokens?.find(h=>Qr(h,[y]));g&&f.push({...g,address:g.address,chainId:m,logoURI:g.logo})}return f},[e.destination,JSON.stringify(t?.additionalSourceTokens),JSON.stringify(e.additionalSourceTokens),JSON.stringify(e.supportedSourceAssets),JSON.stringify(s)]),l=Cr({address:o,supportedChains:s,fetchBalances:Ho,additionalTokens:i,enabled:a&&e.includeWalletAssets!==!1,refreshInterval:3e4}),c=Ol({address:o,supportedChains:s,enabled:a&&e.includeRollupAssets!==!1&&!!o&&o.toLowerCase()===t?.embeddedWalletAddress?.toLowerCase(),priceEnabled:a,refetchInterval:3e4}),d=me(()=>a?[...(e.includeWalletAssets===!1?[]:l.assets).map(f=>({...f,owner:f.owner??o,location:f.location??(r?"external":"embedded"),_source:"wallet"})),...(e.includeRollupAssets===!1||o?.toLowerCase()!==t?.embeddedWalletAddress?.toLowerCase()?[]:c.assets).map(f=>({...f,owner:f.owner??o,location:"rollup",_source:"spice"}))]:[],[a,l.assets,c.assets,e.includeWalletAssets,e.includeRollupAssets,o,r,t?.embeddedWalletAddress]),u=me(()=>d.map(f=>({asset:f,...go(f,e.role??"holding",{allowedTokens:t?.allowedTokens,rpcOverrides:t?.rpcOverrides,liquidityVenues:t?.liquidityVenues,isWhitelistGateActive:!!t?.isWhitelistGateActive},e.destination,e.supportedSourceAssets,{requiresEscrow:e.requiresEscrow})})),[d,t?.allowedTokens,t?.rpcOverrides,t?.liquidityVenues,t?.isWhitelistGateActive,e.role,e.destination,e.supportedSourceAssets,e.requiresEscrow]);return{positions:u,assets:me(()=>u.filter(f=>f.eligible&&f.asset.balance>0n).map(f=>f.asset),[u]),walletAssets:me(()=>d.filter(f=>f._source==="wallet"),[d]),rollupAssets:me(()=>d.filter(f=>f._source==="spice"),[d]),loading:l.loading||c.loading,refreshing:l.refreshing||c.refreshing,error:l.error||c.error,refresh:n.invalidate}}function wo(e){const t=dt(e.address);if(e.isNative||be(t))return!1;const n=nt(e.chainId)?.supportedTokens?.some(r=>oe(r.address,t)),o=Ut(t,e.chainId);return!!n&&!!o&&rs(o)}const Wl="spiceflow:pendingDeposit",cs="spiceflow:pendingDepositChanged";function Pl(e,t,n){return`${Wl}:${e.toLowerCase()}:${t}:${n.toLowerCase()}`}function wa(){try{const e="__spiceflow_storage_test__";return localStorage.setItem(e,"1"),localStorage.removeItem(e),!0}catch{return!1}}function Tp(e){if(!wa())return;const t=Pl(e.embeddedWalletAddress,e.chainId,e.tokenAddress);try{localStorage.setItem(t,JSON.stringify(e)),window.dispatchEvent(new Event(cs))}catch(n){console.error("[pendingDeposit] Failed to save:",n)}}function Bp(e){if(!wa())return[];const t=`${Wl}:${e.toLowerCase()}:`,n=[],o=Date.now();for(let r=0;r<localStorage.length;r++){const s=localStorage.key(r);if(!(!s||!s.startsWith(t)))try{const a=localStorage.getItem(s);if(!a)continue;const i=JSON.parse(a);if(o-i.timestamp>6048e5){localStorage.removeItem(s);continue}n.push(i)}catch{localStorage.removeItem(s)}}return n}function xa(e,t,n){if(!wa())return;const o=Pl(e,t,n);localStorage.removeItem(o),window.dispatchEvent(new Event(cs))}const Op=new Set(["USDC","SUSD","USD","NUSD","USDT","DAI","ENUSD","USDG"]),Nl={ETH:"ethereum",WETH:"ethereum",BTC:"bitcoin",WBTC:"bitcoin",WCBTC:"bitcoin",CBTC:"bitcoin",ECBTC:"bitcoin",ARB:"arbitrum",MATIC:"matic-network",POL:"matic-network"};let ds=null;const Rp=6e4;async function Ul(e){const t={},n=new Set,o={};for(const s of e){const a=s.toUpperCase();if(Op.has(a))t[a]=1;else if(Nl[a]){const i=Nl[a];n.add(i),o[a]=i}else t[a]=0}if(n.size===0)return t;const r=Date.now();if(ds&&r-ds.timestamp<Rp){for(const[s,a]of Object.entries(o))t[s]=ds.prices[a]??0;return t}try{const s=Array.from(n).join(","),a=await fetch(`https://api.coingecko.com/api/v3/simple/price?ids=${s}&vs_currencies=usd`);if(!a.ok)throw new Error(`CoinGecko ${a.status}`);const i=await a.json(),l={};for(const c of n)l[c]=i[c]?.usd??0;ds={prices:l,timestamp:r};for(const[c,d]of Object.entries(o))t[c]=l[d]??0}catch(s){console.warn("[fetchTokenPrices] CoinGecko fetch failed:",s);for(const a of Object.keys(o))t[a]=t[a]??0}return t}const Dp=new Set(["cbtc","btc","wbtc","wcbtc","tbtc"]),Mp=new Set(["usdc","usdt","dai","usdc.e","usdbc","usdg"]);async function Wp(){const e=(await Ul(["BTC"])).BTC;if(!e||e<=0)throw new Error("Failed to fetch BTC/USD price");return e}function Pp(e){return Dp.has(e.toLowerCase())}function Np(e){return Mp.has(e.toLowerCase())}function Up(e,t,n,o){const r=10n**12n,s=BigInt(Math.round(o*Number(r))),a=t-n,i=10n**BigInt(Math.abs(a));let l=e*s/r;return a>0?l=l/i:a<0&&(l=l*i),l}const Lp=.01,zp=5*60*1e3;function qp(e){const t=Number(Ee(e.verifiedBalance,e.tokenDecimals));return Number.isFinite(t)?t:0}async function Hp(e){const t=Ll(e);let n;try{n=await Ul(t.map(o=>o.tokenSymbol))}catch{return t}return t.filter(o=>{const r=qp(o);if(r<=0)return!0;const s=n[o.tokenSymbol.toUpperCase()]??0;return!Number.isFinite(s)||s<=0?!0:r*s>=Lp})}function Ll(e){const t=new Map;for(const n of e){const o=`${n.chainId}:${n.tokenAddress.toLowerCase()}`;if(!t.get(o)){const r=n.timestamp===0&&n.verifiedBalance>0n;t.set(o,{...n,amount:r?Ee(n.verifiedBalance,n.tokenDecimals):n.amount,rawAmount:r?n.verifiedBalance.toString():n.rawAmount,hasFullBalance:r?!0:n.hasFullBalance})}}return Array.from(t.values())}function zl(e,t){const[n,o]=P([]),[r,s]=P(!1),a=Z(t);a.current=t;const i=!!t?.enabled,l=Z(0),c=Z([]),d=t?.chainIds?.join(","),u=t?.discoverWalletBalances??!0,f=Z(0),y=te(async({forceDiscovery:m=!1}={})=>{if(!e||a.current?.enabled===!1){o([]),s(!1);return}const g=++f.current,h=()=>g!==f.current;s(!0);try{const w=[],x=Bp(e),b=new Set(x.map(F=>`${F.chainId}:${F.tokenAddress.toLowerCase()}`)),v=[...x,...c.current.filter(F=>F.timestamp===0&&!b.has(`${F.chainId}:${F.tokenAddress.toLowerCase()}`))];for(const F of v){if(h())return;if(wo({address:F.tokenAddress,chainId:F.chainId,isNative:F.isNative}))try{const T=bt(F.chainId);let E;if(F.isNative||be(F.tokenAddress)?E=await Gs(T,{address:e}):E=await ho(T,{address:Yt(F.tokenAddress),abi:ot,functionName:"balanceOf",args:[e]}),h())return;if(E>0n)w.push({...F,verifiedBalance:E,hasFullBalance:E>=BigInt(F.rawAmount)});else{const M=Date.now()-F.timestamp;F.timestamp!==0&&M>15*60*1e3&&xa(e,F.chainId,F.tokenAddress)}}catch(T){if(h())return;console.warn(`[usePendingDeposit] Failed to verify balance for ${F.tokenSymbol} on chain ${F.chainId}:`,T),w.push({...F,verifiedBalance:0n,hasFullBalance:!1})}}if(h())return;const C=a.current,k=Date.now(),S=(C?.discoverWalletBalances??!0)&&(m||k-l.current>=zp);if(C?.network&&S){l.current=k;const F=C.chainIds??Xr(C.network),T=new Set(w.map(M=>`${M.chainId}:${M.tokenAddress.toLowerCase()}`)),E=[];for(const M of F){const B=nt(M);if(B?.supportedTokens)for(const D of B.supportedTokens){if(!wo({address:D.address,chainId:M,isNative:!1}))continue;const W=`${M}:${D.address.toLowerCase()}`;T.has(W)||E.push((async()=>{try{const I=bt(M),O=await ho(I,{address:Yt(D.address),abi:ot,functionName:"balanceOf",args:[e]});return O>0n?{chainId:M,tokenAddress:D.address,tokenSymbol:D.symbol,tokenDecimals:D.decimals,amount:Ee(O,D.decimals),rawAmount:O.toString(),embeddedWalletAddress:e,externalWalletAddress:"",timestamp:0,isNative:!1,verifiedBalance:O,hasFullBalance:!0}:null}catch{return null}})())}}if(E.length>0){const M=await Promise.allSettled(E);if(h())return;for(const B of M)B.status==="fulfilled"&&B.value&&w.push(B.value)}}if(!h()){const F=await Hp(w);if(h())return;c.current=Ll(w),o(F)}}catch(w){if(console.error("[usePendingDeposit] Verification error:",w),!h()){const x=c.current.map(b=>({...b,verifiedBalance:0n,hasFullBalance:!1}));c.current=x,o(x)}}finally{h()||s(!1)}},[e]);return ue(()=>{if(c.current=[],l.current=0,o([]),!i){f.current++,s(!1);return}y({forceDiscovery:!0});const m=a.current?.pollIntervalMs??3e4;if(m<=0||!e)return()=>{f.current++};const g=setInterval(()=>{y({forceDiscovery:!1})},m),h=()=>y({forceDiscovery:!0});return window.addEventListener(cs,h),()=>{f.current++,window.removeEventListener(cs,h),clearInterval(g)}},[y,e,i,t?.network,d,u]),{pendingDeposits:n,loading:r,refresh:()=>y({forceDiscovery:!0})}}function ql(e){const t=Kt(Ht),n=t?.embeddedWalletAddress,o=e?.enabled===!1?void 0:n,r=t?.network?{network:t.network,pollIntervalMs:e?.pollIntervalMs,chainIds:e?.chainIds??t.supportedChainIds,discoverWalletBalances:e?.discoverWalletBalances}:void 0;return{...zl(o,r),embeddedWalletAddress:n}}var ba="data:image/svg+xml,%3csvg width='10' height='10' viewBox='0 0 10 10' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M5 4.99995V6.99995M5 3.31245V3.31189M9.5 5C9.5 7.48528 7.48528 9.5 5 9.5C2.51472 9.5 0.5 7.48528 0.5 5C0.5 2.51472 2.51472 0.5 5 0.5C7.48528 0.5 9.5 2.51472 9.5 5Z' stroke='black' stroke-opacity='0.4' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e";function va(e){const t=Z(0),n=Z(null),o=Z(e.run);o.current=e.run;const r=Z(e.onSkip);r.current=e.onSkip;const s=Z(e.onCleanup);s.current=e.onCleanup,ue(()=>{if(!e.shouldRun){t.current+=1,n.current?.abort(),r.current?.();return}let a=!1,i=!1;const l=async f=>{if(f&&i)return;n.current?.abort();const y=new AbortController;n.current=y;const m=++t.current;i=!0;try{await o.current({isBackground:f,isCurrent:()=>!a&&t.current===m,signal:y.signal})}finally{i=!1}},c=window.setTimeout(()=>void l(!1),e.delayMs??250),d=()=>{document.hidden||l(!0)},u=e.backgroundIntervalMs?window.setInterval(d,e.backgroundIntervalMs):void 0;return u!==void 0&&document.addEventListener("visibilitychange",d),()=>{a=!0,n.current?.abort(),clearTimeout(c),u!==void 0&&(window.clearInterval(u),document.removeEventListener("visibilitychange",d)),s.current?.()}},[e.shouldRun,e.delayMs,e.backgroundIntervalMs,...e.deps])}function Hl(e,t){if(e.length!==t.length)return!1;const n=Gn(e),o=Gn(t);return n.every((r,s)=>r.hash===o[s]?.hash)}const Qn=e=>new Promise(t=>setTimeout(t,e)),Vp="0xa9059cbb";function Vl(e){const t=e.findIndex(r=>Uo(r.chainId));if(t<=0)return[];const n=new Map,o=(r,s,a)=>{if(a<=0n)return;const i=`${r}:${s.toLowerCase()}`,l=n.get(i);l?l.amount+=a:n.set(i,{chainId:r,token:s,amount:a})};for(const r of e.slice(0,t)){const s=pr(r.chainId);if(!(!s||s===Dt)){for(const a of r.calls)if(a.value&&a.value>0n&&oe(a.to,s)&&o(r.chainId,Dt,a.value),!!a.data?.startsWith(Vp))try{const i=so({abi:ot,data:a.data});if(i.functionName!=="transfer")continue;const[l,c]=i.args;oe(l,s)&&o(r.chainId,a.to,c)}catch{}}}return[...n.values()]}function Ql(e){const t=Ut(e.token,e.chainId);return[t?.equivalenceGroup,t?.symbol,t?.name]}function jl(e,t){return fa(e,t.chainId,t.token,Ql(t))}function Qp(e,t){const n=hp(e,t.chainId,t.token,Ql(t));return!n||n.receiptDecimals>=n.chainDecimals?t.amount:Vn(Vn(t.amount,n.chainDecimals,n.receiptDecimals),n.receiptDecimals,n.chainDecimals)}async function Gl(e){const{deposits:t,baseline:n,fetchEntries:o,timeoutMs:r=12e4,intervalMs:s,signal:a,wait:i=Qn}=e;if(t.length===0)return!0;const l=new Map(t.map(u=>[u,jl(n,u)])),c=Date.now(),d=c+r;for(;!a?.aborted;){try{const m=await o();if(t.every(g=>jl(m,g)-l.get(g)>=Qp(m,g)))return!0}catch{}const u=Date.now();if(u>=d)return!1;const f=u-c,y=s??(f<5e3?250:f<15e3?1e3:3e3);await i(Math.min(y,d-u))}return!1}function Kl(e,t){const n=Gn(e).map(o=>o.hash);return Lo(ao([{type:"string"},{type:"uint256"},{type:"uint256"},{type:"bytes32[]"}],["ecdsa",0n,t,n]))}async function Yl(e,t,n,o,r){if(o?.aborted)throw new ze("ABORT","Execution transaction aborted");const s={raw:Kl(t,n)},a=r?await e.signMessage(s,r):await e.signMessage(s);console.debug("[SpiceFlow:execution]",{phase:"signature-returned",at:Date.now()});const i=typeof a=="string"?a:a.signature;if(!i)throw new ze("SIGNATURE_FAILED","Failed to sign intent authorization. The wallet returned an empty signature.");return i}function jp(e){return e.domain==="spicenet"||Uo(e.chainId)}async function Zl(e){const{chainBatches:t,signingAddress:n,actions:o,cache:r,signal:s,onSignatureRequested:a,beforeSign:i}=e;if(s?.aborted)throw new ze("ABORT","Execution transaction aborted");const l=[...new Set(t.filter(u=>!jp(u)).map(u=>u.chainId))].map(u=>({chainId:u,client:bt(u),delegateContract:bi(u)})),[c]=await Promise.all([Promise.all(l.map(async({chainId:u,client:f,delegateContract:y})=>{const m=Number(await pu(n,f)),g=[n.toLowerCase(),u,y.toLowerCase(),m].join(":");return{chainId:u,delegateContract:y,nonce:m,cacheKey:g,cached:r?.get(g)}})),l.length?o.prepareSigning?.():void 0,i?.()]),d=[];for(const{chainId:u,delegateContract:f,nonce:y,cacheKey:m,cached:g}of c){if(g){d.push(g);continue}if(s?.aborted)throw new ze("ABORT","Execution transaction aborted");const h=await o.signAuthorization({contractAddress:f,chainId:u,nonce:y},a),w={r:h.r,s:h.s,yParity:h.yParity,address:h.address??f,chainId:Number(h.chainId??u),nonce:Number(h.nonce??y)};r?.set(m,w),d.push(w)}return d}const Xl=15;function Gp(e){return e.now-e.lastProgressAt>=e.pollTimeoutMs}function Jl(e,t){return{intentId:e,steps:t.map(n=>({...n,status:"pending"})),overallStatus:"processing"}}function us(e,t,n){const o=e.steps.map(i=>({...i})),r=o[t];if(!r)return e;n.status==="success"||n.status==="completed"?(o[t]={...r,status:"success",transactionHash:n.transactionHash},t+1<o.length&&o[t+1].status==="pending"&&(o[t+1]={...o[t+1],status:"processing"})):n.status==="reverted"||n.status==="error"?o[t]={...r,status:"failed",transactionHash:n.transactionHash,error:n.error}:o[t]={...r,status:"processing"};const s=o.some(i=>i.status==="failed"),a=o.every(i=>i.status==="success");return{...e,steps:o,overallStatus:s?"failed":a?"success":"processing"}}function Kp({checkStepStatus:e,retryStep:t,maxRetries:n=3,pollingInterval:o=2500,pollTimeoutMs:r=3e5}){const[s,a]=P(null),i=Z(null),l=Z(null),c=Z(!1),d=Z(!1),u=Z(0),f=Z({}),y=Z(0),m=te(v=>{i.current=v,a(v)},[]),g=te(()=>{l.current&&(clearInterval(l.current),l.current=null)},[]),h=te(()=>{u.current=0,f.current={},y.current=0,c.current=!0,g(),m(null)},[g,m]),w=te((v,C)=>{g(),c.current=!1,m(Jl(v,C))},[g,m]),x=te((v,C)=>{const k=i.current;k&&m(us(k,v,C))},[m]),b=te((v,C)=>{g(),c.current=!1,d.current=!1,u.current=0,f.current={},y.current=Date.now(),m(Jl(v,C));const k=async()=>{if(!(c.current||d.current||!e)){d.current=!0;try{if(Gp({now:Date.now(),lastProgressAt:y.current,pollTimeoutMs:r})){const T=i.current;T&&m({...T,steps:T.steps.map(E=>E.status==="success"?E:{...E,status:"failed",error:"Taking longer than expected. It may still complete - check the explorer, then refresh."}),overallStatus:"failed"}),c.current=!0,g();return}const S=i.current;if(!S)return;const F=S.steps.findIndex(T=>T.status!=="success");if(F===-1){c.current=!0,g();return}if(!(F===0||S.steps[F-1].status==="success"))return;try{const T=S.steps[F].stepId,{data:E}=await e(v,T);if(u.current=0,E.status==="success"&&(y.current=Date.now()),E.status==="reverted"){const B=f.current[T]||0;if(t&&B<n){f.current[T]=B+1;try{await t(v,T)}catch(D){console.error(`[intentStatus] retry failed for step ${T}:`,D)}m(us(i.current,F,{status:"executing"}));return}}const M=us(i.current,F,E);m(M),M.overallStatus!=="processing"&&(c.current=!0,g())}catch(T){u.current+=1,console.error(`[intentStatus] poll error (${u.current}/${Xl}):`,T),u.current>=Xl&&(m(us(i.current,F,{status:"error"})),c.current=!0,g())}}finally{d.current=!1}}};k(),l.current=setInterval(k,o)},[e,t,n,o,r,g,m]);return ue(()=>()=>g(),[g]),{intentStatus:s,startStatusPolling:b,beginStatusTracking:w,applyStepUpdate:x,stopStatusPolling:g,clearStatus:h}}function Yp(e,t){return(t||"").trim()||`Transaction ${e}. The transaction was rejected on-chain. This may be due to insufficient balance, price changes, or health factor constraints. Please verify your positions and try again.`}const Zp=350,Xp=2500;async function $l(e){const{actionId:t,intentIndex:n,intentId:o,stepIndex:r,maxPolls:s=48,maxExecuteAttempts:a=3,pollsBeforeRetry:i=5,maxConsecutiveStatusErrors:l=15,onStatusMessage:c,onStepUpdate:d,signal:u,chainId:f,startWithExecute:y=!0,observeOnly:m=!1,relayer:g=yt,completeOnExecution:h=!1}=e;if(u?.aborted)throw new ze("ABORT","Execution transaction aborted");let w="pending",x,b,v=0,C=0,k,S;const F=new Promise((E,M)=>{k=E,S=()=>M(new ze("ABORT","Execution transaction aborted"))}),T=()=>{v++,g.executeStep(t,n,r,{action:"execute"}).then(E=>{E.transactionHash&&(x=E.transactionHash),E.status==="success"&&k({status:E.status,transactionHash:E.transactionHash})}).catch(E=>{const M=E instanceof Error?E.message:String(E);console.warn(`[execution] executeStep ${r} attempt ${v} error (will poll):`,M)})};u?.addEventListener("abort",S,{once:!0});try{y&&!m&&T();for(let E=0;E<s;E++){const M=E===0?Zp:Xp;try{const D=await Promise.race([Qn(M).then(()=>{}),F]);if(u?.aborted)throw new ze("ABORT","Execution transaction aborted");const W=D??await Promise.race([g.checkStepStatus(o,r,h).then(O=>O.data),F]);if(u?.aborted)throw new ze("ABORT","Execution transaction aborted");C=0,w=W.status,b=W.error;const I=W.transactionHash;I&&(x=I),h&&/^0x[0-9a-f]{64}$/i.test(I??"")&&(W.executionStatus==="success"||W.executionStatus==="reverted")&&(w=W.executionStatus,b=void 0),d?.({status:w,transactionHash:x,error:b})}catch(D){if(D instanceof Error&&(D.name==="AbortError"||D instanceof ze&&D.code==="ABORT"))throw D;if(C++,C>=l){if(!m)throw D;c?.("Status is temporarily unavailable. The backend continues this action.",x)}continue}if(!m&&w==="created"&&E>=v*i&&v<a&&T(),w==="reverted"||w==="error")throw new ze("ON_CHAIN_REVERT",Yp(w,b),{status:w,txHash:x,actionId:t,intentId:o,stepId:r,chainId:f});if(w==="success"||w==="completed")return x;let B="Waiting for solver...";w==="executing"?B="Transaction executing...":w==="submitted"?B="Transaction submitted...":w==="created"&&(B="Waiting for relayer..."),c?.(B,x)}throw new ze("POLLING_EXHAUSTED",`Transaction is still processing (status: ${w}). This doesn't mean it failed \u2014 the solver may still complete it. Check your positions in a few minutes, or try refreshing the page.`,{actionId:t,intentId:o,stepId:r,lastStatus:w,pollAttempts:s,maxPolls:s,txHash:x})}finally{u?.removeEventListener("abort",S)}}async function Jp(e){const{actionId:t,intentIndex:n,intentId:o,totalSteps:r,observeOnly:s,delayBeforeSpicenetStepMs:a=5e3,isSpicenetStep:i,beforeStep:l,maxExecuteAttemptsForStep:c,maxPolls:d=48,onStatusMessage:u,onStepUpdate:f,signal:y}=e;let m;for(let g=0;g<r;g++){if(!s&&g>0&&i?.(g)&&a>0&&await Qn(a),await l?.(g),y?.aborted)throw new ze("ABORT","Execution transaction aborted");const h=c?.(g)??3,w=await $l({actionId:t,intentIndex:n,intentId:o,stepIndex:g,observeOnly:s,relayer:e.relayer,maxPolls:d,maxExecuteAttempts:h,maxConsecutiveStatusErrors:h===6?5:15,onStatusMessage:u,onStepUpdate:f?x=>f(g,x):void 0,signal:y,completeOnExecution:g===r-1&&i?.(g)===!1});w&&(m=w)}return m}const $p="0xa9059cbb",_p=[fu,Zt,xn];function _l(e){return _p.some(t=>oe(e,t))}function ps(e,t){return e.map(n=>{if(n.domain==="spicenet"||Uo(n.chainId)||n.calls.length===0)return n;const o=new Set((n.tokenTransfers??[]).filter(a=>(a.from==="escrow"||a.from==="solver")&&oe(a.to,t)).map(a=>a.token.toLowerCase()));if(o.size===0)return n;const r=[...o].some(be);let s=0;for(const a of n.calls){if(r&&a.value>0n&&a.data==="0x"&&_l(a.to)){s+=1;continue}if(!a.data?.startsWith($p))break;try{const i=so({abi:ot,data:a.data});if(i.functionName!=="transfer")break;const[l]=i.args;if(!_l(l)||!o.has(a.to.toLowerCase()))break;s+=1}catch{break}}return s===0?n:{...n,calls:n.calls.slice(s)}})}async function ef(e,t){if(!t||!/^0x[0-9a-f]{64}$/i.test(t))throw new Error("The destination receipt is not available yet; reconcile the existing action before retrying.");const n=await e.waitForTransactionReceipt({hash:t,timeout:12e4,pollingInterval:2e3,confirmations:1});if(n.transactionHash?.toLowerCase()!==t.toLowerCase()||n.status!=="success")throw new Error("The destination transaction has not been confirmed successfully. Reconcile the existing action before retrying.");return t}async function fs(e){let t=e.hash,n=!1;const o=Date.now()+12e4,r=a=>a.transactionHash&&a.transactionHash.toLowerCase()!==t.toLowerCase();let s=await e.client.waitForTransactionReceipt({hash:t,timeout:12e4,pollingInterval:2e3,confirmations:1,onReplaced:a=>{const i=a.transaction,l=a.replacedTransaction;if(!(a.reason==="repriced"&&l?.hash?.toLowerCase()===t.toLowerCase()&&l?.to?.toLowerCase()===e.call.to.toLowerCase()&&(l.input??"0x").toLowerCase()===e.call.data.toLowerCase()&&BigInt(l.value??0)===e.call.value&&l?.from&&l.nonce!==void 0&&/^0x[0-9a-f]{64}$/i.test(i?.hash??"")&&i?.to?.toLowerCase()===e.call.to.toLowerCase()&&(i.input??"0x").toLowerCase()===e.call.data.toLowerCase()&&BigInt(i.value??0)===e.call.value&&i.from?.toLowerCase()===l?.from?.toLowerCase()&&i.nonce===l?.nonce)){n=!0,e.onCancelled?.();return}t=i.hash,e.onRepriced?.(t)}});if(n)throw new Error("Transaction was cancelled or replaced with a different action; retry the unfinished action");if((e.confirmations??1)>1&&!r(s)&&s.status==="success"&&(s=await e.client.waitForTransactionReceipt({hash:t,timeout:Math.max(o-Date.now(),1),pollingInterval:2e3,confirmations:e.confirmations})),r(s))throw new Error("Unexpected transaction receipt; recover the submitted transaction before retrying");return{receipt:s,hash:t}}const tf=10n,nf=10n,of=5;function Ca(e){return e.map(t=>({...t,calls:[...t.calls],tokenTransfers:t.tokenTransfers?[...t.tokenTransfers]:void 0}))}function ms({token:e,recipient:t,amount:n}){return{to:e,value:0n,data:Tt({abi:ot,functionName:"transfer",args:[t,n]})}}function rf({chainBatches:e,token:t,amount:n}){const o=Ca(e),r=o[o.length-1];if(!r)return o;const s=ro(r.chainId);return r.calls=[...r.calls,ms({token:t,recipient:s,amount:n})],o}function ec({chainBatches:e,user:t,token:n,grossAmount:o,gasFee:r}){const s=Ca(e),a=s[s.length-1];if(!a)throw new ze("INVALID_PARAMS","Action-output escrow funding requires at least one chain batch.");const i=Ms(o,nf),l=r+i;if(l>=o)throw new ze("INVALID_PARAMS","Borrow amount is too small after gas and Spicenet fees.",{grossAmount:o.toString(),gasFee:r.toString(),spicenetFee:i.toString()});const c=o-l,d=ro(a.chainId),u=[];return r>0n&&u.push(ms({token:n,recipient:Zt,amount:r})),i>0n&&u.push(ms({token:n,recipient:xn,amount:i})),a.calls=[...a.calls,...u,ms({token:n,recipient:d,amount:c})],a.tokenTransfers=[...a.tokenTransfers??[],...r>0n?[{from:t,to:Zt,token:n,amount:r}]:[],...i>0n?[{from:t,to:xn,token:n,amount:i}]:[],{from:t,to:d,token:n,amount:c}],{chainBatches:s,gasFee:r,spicenetFee:i,netEscrowAmount:c,outputCredit:{chainId:a.chainId,token:n,amount:o}}}async function tc({chainBatches:e,user:t,token:n,grossAmount:o,chainAuthorizations:r}){let s=0n,a=ec({chainBatches:e,user:t,token:n,grossAmount:o,gasFee:s});for(let i=0;i<of;i+=1){const l=Gn(a.chainBatches),c=(await yt.estimateBatchGas({user:t,outputToken:n,chainBatches:a.chainBatches.map((d,u)=>({...d,hash:l[u].hash})),chainAuthorizations:r})).gasFee;if(c===s)return a;s=c,a=ec({chainBatches:e,user:t,token:n,grossAmount:o,gasFee:s})}throw new ze("INVALID_PARAMS","Action-output fee estimate did not converge. Please retry.")}function uo(e){return Uo(e.chainId)}const sf="0xa9059cbb";function kr(e,t){return`${e}:${dt(t).toLowerCase()}`}function nc(e,t){return t===Dt.toLowerCase()?{symbol:Tn(e),decimals:18}:Ut(t,e)??{symbol:"tokens",decimals:18}}function af(e,t){const n=Ut(t,e);return[n?.equivalenceGroup,n?.symbol,n?.name]}async function ka(e){return ar(e)}async function lf(e,t,n){const o=new Map,r=n?.walletFundingRequirement,s=r&&kr(r.chainId,r.token);s&&o.set(s,0n);const a=new Map,i=new Map,l=new Map,c=new Map;for(const u of n?.actionOutputCredits??[]){const f=kr(u.chainId,u.token);c.set(f,(c.get(f)??0n)+u.amount)}for(const u of e){if(uo(u))continue;for(const m of u.tokenTransfers??[]){if(m.from!=="escrow"&&m.from!=="solver"||!oe(m.to,t))continue;const g=BigInt(m.amount??0);if(g<=0n)continue;const h=kr(u.chainId,m.token);a.set(h,(a.get(h)??0n)+g),m.from==="escrow"&&i.set(h,(i.get(h)??0n)+g)}const f=pr(u.chainId),y=m=>!!f&&f!==Dt&&oe(m,f);for(const m of u.calls){if(m.value&&m.value>0n){const g=kr(u.chainId,Dt);o.set(g,(o.get(g)??0n)+m.value),y(m.to)&&l.set(g,(l.get(g)??0n)+m.value)}if(m.data?.startsWith(sf))try{const g=so({abi:ot,data:m.data});if(g.functionName!=="transfer")continue;const[h,w]=g.args,x=m.to.toLowerCase(),b=kr(u.chainId,x);o.set(b,(o.get(b)??0n)+w),y(h)&&l.set(b,(l.get(b)??0n)+w)}catch{}}}let d=null;for(const[u,f]of i){const y=f-(l.get(u)??0n);if(y<=0n)continue;const[m,g]=u.split(":"),h=Number(m),w=nc(h,g);d??(d=await ka(t));const x=fa(d,h,g,af(h,g));if(!(x>=y))throw new ze("INVALID_PARAMS",`Insufficient Spice ${w.symbol}: needs ${Ee(y,w.decimals)}, has ${Ee(x,w.decimals)}.`,{chainId:h,token:g,userAddress:t,requiredAmount:y.toString(),balance:x.toString(),balanceSource:"spice"})}for(const[u,f]of o){const[y,m]=u.split(":"),g=Number(y);let h=f-(a.get(u)??0n)-(c.get(u)??0n);if(r&&u===s&&r.amount>h&&(h=r.amount),h<=0n)continue;const w=bt(g),x=m===Dt.toLowerCase()?await w.getBalance({address:t}):await w.readContract({address:m,abi:ot,functionName:"balanceOf",args:[t]});if(x>=h)continue;const b=nc(g,m);throw new ze("INVALID_PARAMS",`Insufficient ${b.symbol} on ${Tn(g)}: needs ${Ee(h,b.decimals)}, has ${Ee(x,b.decimals)}.`,{chainId:g,token:m,userAddress:t,requiredAmount:h.toString(),balance:x.toString(),balanceSource:"wallet"})}}function cf({chainBatches:e,tokenAddress:t,tokenTransferAmount:n,useCustomTransfers:o}){if(!(e.some(uo)||!(o?e.some(r=>uo(r)?!1:(r.tokenTransfers??[]).some(s=>s.from==="escrow"&&BigInt(s.amount??0)>0n)):n>0n)))throw new ze("INVALID_PARAMS","Payouts funded from Spice balance require a Spicenet funding batch before the destination chain batch. Deposits into Spice balance and gas-only actions do not need one.",{tokenAddress:t,tokenTransferAmount:n.toString(),useCustomTransfers:!!o})}function df(e,t,n,o){t.forEach((r,s)=>{if(!r.to||!r.from||!r.token||r.amount===void 0)throw new ze("INVALID_TOKEN_TRANSFER",`tokenTransfers[${s}] on chain ${e} is missing required fields (to/from/token/amount). This usually means the embedded wallet wasn't ready when the intent was built \u2014 please retry.`,{chainId:e,transferIndex:s,transfer:{from:r.from,to:r.to,token:r.token,amount:r.amount?.toString()},signingAddress:n,useCustomTransfers:o})})}function hs({user:e,chainBatches:t,tokenAddress:n,tokenTransferAmount:o,exp:r,signature:s,chainAuthorizations:a,useCustomTransfers:i}){const l=t,c=Gn(l),d=l.filter(u=>!uo(u)).length;if(cf({chainBatches:l,tokenAddress:n,tokenTransferAmount:o,useCustomTransfers:i}),!i&&o>0n&&d>1)throw new ze("INVALID_PARAMS","Multiple non-Spicenet batches require explicit tokenTransfers. Pass useCustomTransfers with per-batch transfers instead of relying on the default escrow payout injection.",{nonSpicenetBatchCount:d,tokenAddress:n,tokenTransferAmount:o.toString()});return{user:e,...a?{chainAuthorizations:a}:{},intents:[{mode:"7702",signatureType:"ecdsa",signature:s,nbf:0,exp:r,chainBatches:c.map((u,f)=>{const y=l[f],m=uo(y)?[]:i?y.tokenTransfers??[]:o>0n?[{from:"escrow",to:e,token:n,amount:o}]:[];return df(Number(u.chainId),m,e,i),{hash:u.hash,chainId:Number(u.chainId),tokenTransfers:m,calls:u.calls}})}]}}function oc(e,t){const n=t?.depositToEscrow?.gasFundingSource==="action-output"?t.depositToEscrow:null,o=t?.depositToEscrow&&!n?rf({chainBatches:e,token:t.depositToEscrow.token,amount:t.depositToEscrow.amount}):Ca(e);return{actionOutputDeposit:n,batches:o}}let Ia=!1;function Ir(){const{address:e,isConnected:t,isAuthenticated:n,actions:o}=to(),r=Z(null),{intentStatus:s,startStatusPolling:a,beginStatusTracking:i,applyStepUpdate:l,clearStatus:c}=Kp({checkStepStatus:(h,w)=>yt.checkStepStatus(h,w),retryStep:async(h,w)=>{const[x,b]=h.split("/"),v=parseInt(b||"0",10);await yt.executeStep(x,v,w,{action:"execute"})}}),d=Z(o),u=Z(new Map);d.current=o;const f=te((h,w,x,b,v)=>Zl({chainBatches:h,signingAddress:w,actions:d.current,cache:u.current,signal:x,onSignatureRequested:b,beforeSign:v}),[]),y=te((h,w,x,b)=>Yl(d.current,h,w,x,b),[]),m=te(async(h,w,x,b,v,C)=>{const k=(S,F,T)=>{b?.({step:S,message:F,...T})};if(Ia)throw new ze("CONCURRENT_EXECUTION","A execution transaction is already in progress. Please wait.");Ia=!0;try{if(!e)throw new ze("WALLET_DISCONNECTED","No wallet connected. Please log in first.");const S=C?.userOverride||e,F=yt.getBaseUrl(),T=await yt.supportsAutomaticContinuation(),{actionOutputDeposit:E,batches:M}=oc(h,C);let B=M,D=[],W=C?.useCustomTransfers,I=Vl(B),O=null;const U=async()=>{for(let K=0;I.length>0&&K<3;K++)try{O=await ka(S);break}catch(Q){if(v?.aborted)throw new ze("ABORT","Execution transaction aborted");if(K===2)throw new ze("RELAYER_ERROR","Unable to read your Spice balance. Please try again before submitting the transaction.",{cause:Q});await Qn(1e3)}await C?.validateBeforeSubmit?.(B)};k("building","Preparing your wallet and transaction...");const z=await f(B,S,v,()=>k("signing-delegation","Confirm the authorization in your wallet..."),U);if(k("building","Checking transaction fees and balances..."),v?.aborted)throw new ze("ABORT","Execution transaction aborted");const re=BigInt(Math.floor(Date.now()/1e3)+3600);if(E){const K=await tc({chainBatches:h,user:S,token:E.token,grossAmount:E.amount,chainAuthorizations:z});B=K.chainBatches,D=[K.outputCredit],W=!0}if(!C?.skipPreSubmitFeeEstimate){let K=!1;if(C?.feeExecutionMode==="user-transfer"&&C.adjustBatchesForEstimate&&yt.canValidateActionFees()){const Q=await yt.validateActionFees(hs({user:S,chainBatches:B,tokenAddress:w,tokenTransferAmount:x,exp:Number(re),signature:"0x00",chainAuthorizations:z,useCustomTransfers:W}),{signal:v});r.current=Q;const he=await C.adjustBatchesForEstimate({feeEstimate:Q,chainBatches:B});K=!he||Hl(B,he),he&&(B=he)}for(let Q=0;!K&&Q<10;Q++){const he=C?.feeExecutionMode==="user-transfer"?ps(B,S):B,ve=hs({user:S,chainBatches:he,tokenAddress:w,tokenTransferAmount:x,exp:Number(re),signature:"0x00",chainAuthorizations:z,useCustomTransfers:W}),Fe=await yt.estimateActionFees(ve,{signal:v});r.current=Fe;const L=await C?.adjustBatchesForEstimate?.({feeEstimate:Fe,chainBatches:B}),N=!!L&&Hl(B,L);if(!L||N){K=!0;break}B=L}if(!K)throw new ze("INVALID_PARAMS","Fee estimate did not converge. Please retry.")}if(C?.prepareForSigning){const K=await C.prepareForSigning(B);if(K.length!==B.length||K.some((Q,he)=>Q.chainId!==B[he].chainId||Q.domain!==B[he].domain))throw new Error("The funded route changed before signing");B=K}C?.resolveActionOutputCredits&&(D=await C.resolveActionOutputCredits()),(!C?.skipUserFundingPreflight||C.walletFundingRequirement)&&await lf(C?.skipUserFundingPreflight?[]:B,S,{actionOutputCredits:D,walletFundingRequirement:C?.walletFundingRequirement}),I=Vl(B),I.length&&!O&&(O=await ar(S)),await C?.validateBeforeSubmit?.(B),k("building","Preparing the signing request...");const pe=await y(B,re,v,()=>k("signing-intent","Confirm the transaction in your wallet..."));if(v?.aborted)throw new ze("ABORT","Execution transaction aborted");k("submitting","Submitting to relayer...");const se=hs({user:S,chainBatches:B,tokenAddress:w,tokenTransferAmount:x,exp:Number(re),signature:pe,chainAuthorizations:z,useCustomTransfers:W}),V=Date.now();if(await C?.validateBeforeSubmit?.(B),console.debug("[SpiceFlow:execution]",{phase:"submit-check-complete",at:Date.now(),durationMs:Date.now()-V}),yt.getBaseUrl()!==F)throw new Error("The network changed before submission. Review your balances before trying again.");const X=await yt.createAction({...se,...T?{autoContinue:!0}:{}}),[Y,_]=X.intentIds[0].split("/"),j=parseInt(_||"0",10),ke=`${Y}/${j}`;k("executing","Executing on chain..."),k("executing","Executing on chain...",{actionId:Y,intentId:ke,intentIndex:j,totalSteps:B.length,autoContinue:X.autoContinue===!0});const Se=B.length,R=new Ws;R.setBaseUrl(F);const G=await Jp({actionId:Y,intentIndex:j,intentId:ke,totalSteps:Se,signal:v,observeOnly:X.autoContinue===!0,relayer:X.autoContinue?R:yt,...O?{delayBeforeSpicenetStepMs:0}:{},isSpicenetStep:K=>uo(B[K]),beforeStep:async K=>{if(X.autoContinue===!0||!O||!uo(B[K]))return;const Q=await Gl({deposits:I,baseline:O,fetchEntries:()=>ka(S),signal:v});if(v?.aborted)throw new ze("ABORT","Execution transaction aborted");if(!Q)throw new ze("POLLING_EXHAUSTED","Your deposit is still waiting for Spice credit. Check this transaction's status before trying again.",{actionId:Y,intentId:ke,stepId:K})},maxExecuteAttemptsForStep:K=>uo(B[K])?6:3,maxPolls:X.autoContinue?Number.POSITIVE_INFINITY:180,onStatusMessage:(K,Q)=>{k("executing",K,{txHash:Q,actionId:Y,intentId:ke,intentIndex:j,totalSteps:Se,autoContinue:X.autoContinue===!0})}});if(C?.requireDestinationReceipt){const K=[...B].reverse().find(Q=>!uo(Q));if(!K)throw new Error("The action has no destination transaction to verify.");await ef(bt(K.chainId),G)}return k("success","Transaction successful!",{txHash:G,actionId:Y,intentId:ke,intentIndex:j,totalSteps:Se,autoContinue:X.autoContinue===!0}),G||Y}catch(S){throw console.error("[Execution] Error:",S),k("error",S.message||"Transaction failed",{error:S.message}),S}finally{Ia=!1}},[e,n,f,y]),g=te(async(h,w,x,b)=>{if(!e)throw new ze("WALLET_DISCONNECTED","No wallet connected. Please log in first.");const v=b?.userOverride||e,C=b?.validateFeeCalls===!0&&b.feeExecutionMode==="user-transfer"&&yt.canValidateActionFees(),{actionOutputDeposit:k,batches:S}=oc(h,b);let F=S;const T=b?.feeExecutionMode==="user-transfer"&&!C?ps(F,v):F,E=b?.signAuthorizationsForEstimate?await f(T,v):void 0;let M=b?.useCustomTransfers;k&&(F=(await tc({chainBatches:h,user:v,token:k.token,grossAmount:k.amount,chainAuthorizations:E})).chainBatches,M=!0);const B=b?.feeExecutionMode==="user-transfer"&&!C?ps(F,v):F,D=hs({user:v,chainBatches:B,tokenAddress:w,tokenTransferAmount:x,exp:Math.floor(Date.now()/1e3)+3600,signature:"0x00",chainAuthorizations:E,useCustomTransfers:M}),W=await(C?yt.validateActionFees(D,{signal:b?.signal}):yt.estimateActionFees(D,{signal:b?.signal}));return r.current=W,W},[e,f]);return{execute:m,estimate:g,lastFeeEstimate:r.current,hasEmbeddedWallet:t&&n,intentStatus:s,startStatusPolling:a,beginStatusTracking:i,applyStepUpdate:l,clearStatus:c}}const Sa=({color:e})=>A("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:[p("circle",{cx:"7",cy:"7",r:"6.5",stroke:e,strokeWidth:"1.2"}),p("path",{d:"M7 6v4",stroke:e,strokeWidth:"1.2",strokeLinecap:"round"}),p("circle",{cx:"7",cy:"4.5",r:"0.7",fill:e})]}),rc=({content:e,label:t="More info",textColor:n="#f9fafb",backgroundColor:o="#111827",borderColor:r="rgba(255,255,255,0.08)",accentColor:s="#9ca3af",children:a})=>{const i=Ai(),[l,c]=P(!1),d=Z(null),[u,f]=P(!1),[y,m]=P(null);ue(()=>{f(!0)},[]),Ao(()=>{if(!l||!d.current)return;const h=()=>{if(!d.current)return;const w=d.current.getBoundingClientRect(),x=Math.min(220,window.innerWidth-48),b=Math.min(Math.max(w.left+w.width/2,24+x/2),window.innerWidth-24-x/2),v=w.top>84;m({top:v?w.top-10:w.bottom+10,left:b,placement:v?"top":"bottom"})};return h(),window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[l]);const g=l&&u&&y?Ys(A("span",{id:i,role:"tooltip",style:{position:"fixed",left:y.left,top:y.top,transform:y.placement==="top"?"translate(-50%, -100%)":"translate(-50%, 0)",width:"220px",maxWidth:"min(220px, calc(100vw - 48px))",padding:"10px 12px",borderRadius:"10px",backgroundColor:o,color:n,border:`1px solid ${r}`,boxShadow:"0 18px 45px rgba(0,0,0,0.28)",fontSize:"11px",lineHeight:"1.45",fontWeight:500,textAlign:"left",zIndex:Io.tooltip,pointerEvents:"none"},children:[e,p("span",{"aria-hidden":"true",style:{position:"absolute",left:"50%",width:"10px",height:"10px",transform:"translateX(-50%) rotate(45deg)",backgroundColor:o,...y.placement==="top"?{bottom:"-6px",borderRight:`1px solid ${r}`,borderBottom:`1px solid ${r}`}:{top:"-6px",borderTop:`1px solid ${r}`,borderLeft:`1px solid ${r}`}}})]}),document.body):null;return A(nn,{children:[p("span",{ref:d,style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:p("button",{type:"button","aria-label":t,"aria-describedby":l?i:void 0,onFocus:()=>c(!0),onBlur:()=>c(!1),style:{width:"18px",height:"18px",borderRadius:"999px",display:"inline-flex",alignItems:"center",justifyContent:"center",border:`1px solid ${r}`,backgroundColor:"transparent",color:s,cursor:"help",padding:0,outline:"none",boxShadow:l?`0 0 0 2px ${s}26`:"none",transition:"border-color 120ms ease, box-shadow 120ms ease, color 120ms ease"},children:a||p(Sa,{color:s})})}),g]})},Sr=(e,t,n,o)=>({width:e,height:e,fill:"none",className:t,"aria-hidden":n??!0,style:o}),Qo=({size:e=16,color:t="currentColor",strokeWidth:n=2,direction:o="down",className:r,style:s,"aria-hidden":a})=>p("svg",{...Sr(e,r,a,{transform:o==="up"?"rotate(180deg)":void 0,transition:"transform 0.3s ease",...s}),viewBox:"0 0 16 16",children:p("path",{d:"M4 6L8 10L12 6",stroke:t,strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round"})}),uf=({size:e=24,color:t="currentColor",strokeWidth:n=2,className:o,style:r,"aria-hidden":s})=>A("svg",{...Sr(e,o,s,r),viewBox:"0 0 24 24",children:[p("circle",{cx:"11",cy:"11",r:"8",stroke:t,strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round"}),p("path",{d:"m21 21-4.3-4.3",stroke:t,strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round"})]}),pf=({size:e=24,color:t="currentColor",strokeWidth:n=2,className:o,style:r,"aria-hidden":s})=>p("svg",{...Sr(e,o,s,r),viewBox:"0 0 24 24",children:p("path",{d:"m6 9 6 6 6-6",stroke:t,strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round"})}),ff=({size:e=24,color:t="currentColor",strokeWidth:n=2,className:o,style:r,"aria-hidden":s})=>p("svg",{...Sr(e,o,s,r),viewBox:"0 0 24 24",children:p("path",{d:"m9 18 6-6-6-6",stroke:t,strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round"})}),sc=({size:e=14,color:t="currentColor",strokeWidth:n=2,className:o,style:r,"aria-hidden":s})=>p("svg",{...Sr(e,o,s,r),viewBox:"0 0 16 16",children:p("path",{d:"M3 8L6.5 11.5L13 5",stroke:t,strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round"})});function gs(e,t){if(e===0n)return"0";const n=10n**BigInt(t),o=e/n,r=(e%n).toString().padStart(t,"0").replace(/0+$/,"");return r?`${o.toString()}.${r}`:o.toString()}function Aa(e,t,n){const o=`${gs(e,t)} ${n}`;return e===0n?o:`-${o}`}const mf=({fontFamily:e,textPrimary:t,textSecondary:n,cardBg:o,cardBorder:r,resolvedDark:s,darkCardBorder:a,primaryColor:i,feePreview:l,feeOnlyAction:c=!1,asset:d,isLoading:u,errorText:f,directExecutionFeeNote:y=!1})=>{const m=jn(),g=d&&l&&[d.symbol,d.displaySymbol,d.receiptTokenName].includes(l.symbol)?m(d).symbol:l?.symbol,h=s?a??r:"#e5e7eb",w=s?"#111214":"#111827",x=s?"rgba(255,255,255,0.08)":"rgba(17,24,39,0.12)",b="#f87171",v=s?"#d1d5db":"#4b5563",C=s?"#f3f4f6":t,[k,S]=P(!1),F=!!f,T=F?null:l,E=T?[...c?[]:[{label:"Total Required",help:"Total amount required to fund this action.",value:`${gs(T.grossAmount,T.decimals)} ${g}`,tone:"default"}],{label:"Spicenet Fee",help:"Fees paid to Spicenet for intent processing and execution.",value:Aa(T.spicenetFee,T.decimals,g),tone:"fee"},{label:"Network Fee",help:"Network fee shown in the same token you are using for this action.",value:Aa(T.gasFee,T.decimals,g),tone:"fee"},...T.bridgeFee&&T.bridgeFee>0n?[{label:"Bridge Fee",help:"Estimated cost to rebalance liquidity for this action.",value:Aa(T.bridgeFee,T.decimals,g),tone:"fee"}]:[],...c?[]:[{label:"Used in TX",help:"Resulting amount of funds used in the transaction.",value:`${gs(T.netAmount,T.decimals)} ${g}`,tone:"default"}]]:[],M=T?`${gs(c?T.totalFee??T.gasFee+T.spicenetFee+(T.bridgeFee??0n):T.grossAmount,T.decimals)} ${g}`:null;return F?p("div",{style:{backgroundColor:o,border:`1px solid ${r}`,borderRadius:s?"8px":"7px",padding:"14px 16px 12px 16px",marginBottom:"16px",boxShadow:s?"inset 0 1px 0 rgba(255,255,255,0.03)":"none"},children:A("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[p("span",{style:{fontSize:"17px",fontWeight:500,color:v,fontFamily:e,lineHeight:"24px"},children:"Fee"}),p("div",{style:{color:b,fontSize:"12px",lineHeight:"1.55",fontFamily:e},children:f})]})}):A("div",{style:{backgroundColor:o,border:`1px solid ${r}`,borderRadius:s?"8px":"7px",padding:"14px 16px 12px 16px",marginBottom:"16px",boxShadow:s?"inset 0 1px 0 rgba(255,255,255,0.03)":"none"},children:[A("button",{type:"button",onClick:()=>S(B=>!B),style:{display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%",gap:"12px",marginBottom:k?"14px":0,background:"none",border:"none",padding:0,cursor:"pointer",textAlign:"left"},children:[A("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[p("span",{style:{fontSize:"17px",fontWeight:500,color:v,fontFamily:e,lineHeight:"24px"},children:"Fee"}),k&&p("span",{style:{fontSize:"12px",color:n,fontFamily:e,lineHeight:"1.45"},children:"What is funded, spent, and taken as fees"})]}),A("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexShrink:0},children:[M&&A("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:"2px",minWidth:0},children:[p("span",{style:{fontSize:"10px",fontWeight:700,color:n,fontFamily:e,letterSpacing:"0.08em",textTransform:"uppercase"},children:c?"Total fees":"Total required"}),p("span",{style:{fontSize:"14px",fontWeight:700,color:C,fontFamily:e,whiteSpace:"nowrap"},children:M})]}),u&&!y&&p("span",{style:{fontSize:"11px",fontWeight:600,color:i,fontFamily:e,padding:"6px 9px",borderRadius:"999px",backgroundColor:s?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.035)",border:`1px solid ${s?h:"rgba(0,0,0,0.06)"}`,whiteSpace:"nowrap"},children:"Recalculating"}),p(Qo,{color:n,direction:k?"up":"down",style:{flexShrink:0}})]})]}),p("div",{style:{overflow:"hidden",maxHeight:k?"480px":"0px",opacity:k?1:0,transition:"max-height 0.24s ease, opacity 0.18s ease"},children:y?p("p",{style:{margin:0,color:n,fontSize:"12px",lineHeight:"1.55",fontFamily:e},children:"This path executes directly from the external wallet. Network gas is shown and paid in your wallet. No Spicenet fee is charged."}):E.length>0?A(nn,{children:[p("div",{style:{display:"grid",gap:"10px"},children:E.map((B,D)=>A("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) auto",alignItems:"center",gap:"12px",paddingTop:D===0?0:"10px",borderTop:D===0?"none":`1px solid ${h}`,opacity:u?.74:1,transition:"opacity 120ms ease"},children:[A("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:[p("span",{style:{fontSize:"12px",color:n,fontFamily:e,fontWeight:500},children:B.label}),p(rc,{content:B.help,label:`${B.label} info`,textColor:"#f9fafb",backgroundColor:w,borderColor:x,accentColor:s?"#8f96a3":"#6b7280"})]}),p("span",{style:{fontSize:"12px",color:B.tone==="fee"?b:C,fontFamily:Ne.mono,textAlign:"right",fontWeight:B.label==="Used in TX"?600:500,letterSpacing:"-0.01em"},children:B.value})]},B.label))}),p("div",{style:{marginTop:"12px",paddingTop:"12px",borderTop:`1px solid ${h}`,fontSize:"11px",color:n,fontFamily:e,lineHeight:"1.45"},children:T?.gasQuoteSource==="estimated"?"Gas quote uses a live estimate.":T?.gasQuoteSource==="configured_fallback"?"Gas quote uses a configured fallback.":"Gas quote is currently zero."})]}):p("div",{style:{fontSize:"12px",color:f?b:n,fontFamily:e,opacity:f?1:.8,lineHeight:"1.5"},children:f||"Waiting for fee estimate..."})})]})},Ea=Bn(mf),Ar=({size:e=20,strokeWidth:t=2,color:n="currentColor",style:o})=>A("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:n,strokeWidth:t,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:o,children:[p("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),p("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]});var ac="data:image/svg+xml,%3csvg width='108' height='22' viewBox='0 0 108 22' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M1.9916 11.9854V11.2041H3.98379C4.48835 11.2041 4.87897 11.0739 5.15566 10.8135C5.43236 10.5498 5.5707 10.1868 5.5707 9.72461V9.71484C5.5707 9.24935 5.43236 8.88639 5.15566 8.62598C4.87897 8.36556 4.48835 8.23535 3.98379 8.23535H1.9916V7.4541H4.2084C4.65111 7.4541 5.04173 7.5485 5.38027 7.7373C5.71882 7.92611 5.98411 8.18978 6.17617 8.52832C6.37148 8.86686 6.46914 9.25911 6.46914 9.70508V9.71484C6.46914 10.1608 6.37148 10.5547 6.17617 10.8965C5.98411 11.2383 5.71882 11.5052 5.38027 11.6973C5.04173 11.8893 4.65111 11.9854 4.2084 11.9854H1.9916ZM1.55215 14.5V7.4541H2.43106V14.5H1.55215ZM9.51875 14.5928C9.0207 14.5928 8.58939 14.4837 8.2248 14.2656C7.86348 14.0443 7.58353 13.7301 7.38496 13.3232C7.18965 12.9163 7.09199 12.4329 7.09199 11.873V11.8633C7.09199 11.3001 7.18965 10.8151 7.38496 10.4082C7.58353 10.0013 7.86348 9.6888 8.2248 9.4707C8.58939 9.2526 9.0207 9.14355 9.51875 9.14355C10.0201 9.14355 10.4514 9.2526 10.8127 9.4707C11.174 9.6888 11.4523 10.0013 11.6477 10.4082C11.8462 10.8151 11.9455 11.3001 11.9455 11.8633V11.873C11.9455 12.4329 11.8462 12.9163 11.6477 13.3232C11.4523 13.7301 11.174 14.0443 10.8127 14.2656C10.4514 14.4837 10.0201 14.5928 9.51875 14.5928ZM9.51875 13.8408C9.85078 13.8408 10.1324 13.7627 10.3635 13.6064C10.5946 13.4502 10.7704 13.2256 10.8908 12.9326C11.0145 12.6396 11.0764 12.2865 11.0764 11.873V11.8633C11.0764 11.4466 11.0145 11.0918 10.8908 10.7988C10.7704 10.5059 10.5946 10.2829 10.3635 10.1299C10.1324 9.97363 9.85078 9.89551 9.51875 9.89551C9.18672 9.89551 8.90514 9.97363 8.67402 10.1299C8.4429 10.2829 8.26549 10.5059 8.1418 10.7988C8.02135 11.0918 7.96113 11.4466 7.96113 11.8633V11.873C7.96113 12.2865 8.02135 12.6396 8.1418 12.9326C8.26549 13.2256 8.4429 13.4502 8.67402 13.6064C8.90514 13.7627 9.18672 13.8408 9.51875 13.8408ZM13.7842 14.5L12.3096 9.23633H13.1592L14.1943 13.4453H14.2725L15.4492 9.23633H16.2549L17.4316 13.4453H17.5098L18.5449 9.23633H19.3896L17.915 14.5H17.0605L15.8838 10.4277H15.8057L14.6338 14.5H13.7842ZM22.1658 14.5928C21.6645 14.5928 21.2332 14.4821 20.8719 14.2607C20.5138 14.0394 20.2371 13.7269 20.0418 13.3232C19.8497 12.9163 19.7537 12.4378 19.7537 11.8877V11.8828C19.7537 11.3392 19.8497 10.8623 20.0418 10.4521C20.2371 10.042 20.5122 9.72135 20.867 9.49023C21.2218 9.25911 21.6368 9.14355 22.1121 9.14355C22.5906 9.14355 23.0008 9.25423 23.3426 9.47559C23.6876 9.69694 23.9513 10.0062 24.1336 10.4033C24.3191 10.7972 24.4119 11.2562 24.4119 11.7803V12.1123H20.1932V11.4336H23.9773L23.5574 12.0537V11.7168C23.5574 11.3034 23.4956 10.9632 23.3719 10.6963C23.2482 10.4294 23.0773 10.2308 22.8592 10.1006C22.6411 9.96712 22.3904 9.90039 22.1072 9.90039C21.824 9.90039 21.5701 9.97038 21.3455 10.1104C21.1242 10.2471 20.9484 10.4505 20.8182 10.7207C20.688 10.9909 20.6229 11.3229 20.6229 11.7168V12.0537C20.6229 12.4281 20.6863 12.7487 20.8133 13.0156C20.9402 13.2793 21.1209 13.4827 21.3553 13.626C21.5896 13.766 21.8663 13.8359 22.1854 13.8359C22.423 13.8359 22.6297 13.8034 22.8055 13.7383C22.9813 13.6732 23.1261 13.5902 23.24 13.4893C23.354 13.3883 23.4337 13.2858 23.4793 13.1816L23.4988 13.1377H24.3484L24.3387 13.1768C24.2931 13.3558 24.2117 13.5299 24.0945 13.6992C23.9806 13.8652 23.8325 14.0166 23.6502 14.1533C23.4679 14.2868 23.2514 14.3942 23.0008 14.4756C22.7534 14.5537 22.4751 14.5928 22.1658 14.5928ZM25.4303 14.5V9.23633H26.2799V10.0176H26.358C26.4589 9.74089 26.6298 9.52604 26.8707 9.37305C27.1116 9.22005 27.4094 9.14355 27.7643 9.14355C27.8456 9.14355 27.9254 9.14844 28.0035 9.1582C28.0849 9.16471 28.1467 9.17122 28.1891 9.17773V10.0029C28.1012 9.98665 28.0149 9.97526 27.9303 9.96875C27.8489 9.95898 27.761 9.9541 27.6666 9.9541C27.3964 9.9541 27.1572 10.0078 26.9488 10.1152C26.7405 10.2227 26.5761 10.3724 26.4557 10.5645C26.3385 10.7565 26.2799 10.9811 26.2799 11.2383V14.5H25.4303ZM30.9408 14.5928C30.4395 14.5928 30.0082 14.4821 29.6469 14.2607C29.2888 14.0394 29.0121 13.7269 28.8168 13.3232C28.6247 12.9163 28.5287 12.4378 28.5287 11.8877V11.8828C28.5287 11.3392 28.6247 10.8623 28.8168 10.4521C29.0121 10.042 29.2872 9.72135 29.642 9.49023C29.9968 9.25911 30.4118 9.14355 30.8871 9.14355C31.3656 9.14355 31.7758 9.25423 32.1176 9.47559C32.4626 9.69694 32.7263 10.0062 32.9086 10.4033C33.0941 10.7972 33.1869 11.2562 33.1869 11.7803V12.1123H28.9682V11.4336H32.7523L32.3324 12.0537V11.7168C32.3324 11.3034 32.2706 10.9632 32.1469 10.6963C32.0232 10.4294 31.8523 10.2308 31.6342 10.1006C31.4161 9.96712 31.1654 9.90039 30.8822 9.90039C30.599 9.90039 30.3451 9.97038 30.1205 10.1104C29.8992 10.2471 29.7234 10.4505 29.5932 10.7207C29.463 10.9909 29.3979 11.3229 29.3979 11.7168V12.0537C29.3979 12.4281 29.4613 12.7487 29.5883 13.0156C29.7152 13.2793 29.8959 13.4827 30.1303 13.626C30.3646 13.766 30.6413 13.8359 30.9604 13.8359C31.198 13.8359 31.4047 13.8034 31.5805 13.7383C31.7563 13.6732 31.9011 13.5902 32.015 13.4893C32.129 13.3883 32.2087 13.2858 32.2543 13.1816L32.2738 13.1377H33.1234L33.1137 13.1768C33.0681 13.3558 32.9867 13.5299 32.8695 13.6992C32.7556 13.8652 32.6075 14.0166 32.4252 14.1533C32.2429 14.2868 32.0264 14.3942 31.7758 14.4756C31.5284 14.5537 31.2501 14.5928 30.9408 14.5928ZM36.1486 14.5928C35.7059 14.5928 35.3186 14.4805 34.9865 14.2559C34.6545 14.0312 34.3973 13.7155 34.215 13.3086C34.0328 12.8984 33.9416 12.4199 33.9416 11.873V11.8633C33.9416 11.3132 34.0328 10.8346 34.215 10.4277C34.3973 10.0208 34.6529 9.70508 34.9816 9.48047C35.3137 9.25586 35.7027 9.14355 36.1486 9.14355C36.3895 9.14355 36.6158 9.18262 36.8273 9.26074C37.0422 9.33561 37.2326 9.44141 37.3986 9.57812C37.5647 9.71484 37.6949 9.8776 37.7893 10.0664H37.8674V7.14648H38.717V14.5H37.8674V13.6602H37.7893C37.6818 13.8555 37.5467 14.0231 37.384 14.1631C37.2212 14.2998 37.0357 14.4056 36.8273 14.4805C36.619 14.5553 36.3928 14.5928 36.1486 14.5928ZM36.3439 13.8408C36.663 13.8408 36.938 13.7611 37.1691 13.6016C37.4003 13.4421 37.5777 13.2158 37.7014 12.9229C37.8251 12.6266 37.8869 12.2767 37.8869 11.873V11.8633C37.8869 11.4564 37.8251 11.1064 37.7014 10.8135C37.5777 10.5205 37.4003 10.2943 37.1691 10.1348C36.938 9.97526 36.663 9.89551 36.3439 9.89551C36.0249 9.89551 35.7499 9.97526 35.5188 10.1348C35.2909 10.291 35.1151 10.5156 34.9914 10.8086C34.871 11.1016 34.8107 11.4531 34.8107 11.8633V11.873C34.8107 12.2799 34.871 12.6315 34.9914 12.9277C35.1151 13.2207 35.2909 13.4469 35.5188 13.6064C35.7499 13.7627 36.0249 13.8408 36.3439 13.8408ZM45.1775 14.5928C44.9334 14.5928 44.7072 14.5553 44.4988 14.4805C44.2905 14.4056 44.1049 14.2998 43.9422 14.1631C43.7794 14.0231 43.6443 13.8555 43.5369 13.6602H43.4588V14.5H42.6092V7.14648H43.4588V10.0664H43.5369C43.6346 9.8776 43.7648 9.71484 43.9275 9.57812C44.0936 9.44141 44.2824 9.33561 44.4939 9.26074C44.7088 9.18262 44.9367 9.14355 45.1775 9.14355C45.6235 9.14355 46.0109 9.25586 46.3396 9.48047C46.6717 9.70508 46.9288 10.0208 47.1111 10.4277C47.2934 10.8346 47.3846 11.3132 47.3846 11.8633V11.873C47.3846 12.4199 47.2934 12.8984 47.1111 13.3086C46.9288 13.7155 46.6717 14.0312 46.3396 14.2559C46.0109 14.4805 45.6235 14.5928 45.1775 14.5928ZM44.9822 13.8408C45.3045 13.8408 45.5796 13.7627 45.8074 13.6064C46.0353 13.4469 46.2094 13.2207 46.3299 12.9277C46.4536 12.6315 46.5154 12.2799 46.5154 11.873V11.8633C46.5154 11.4531 46.4536 11.1016 46.3299 10.8086C46.2094 10.5156 46.0353 10.291 45.8074 10.1348C45.5796 9.97526 45.3045 9.89551 44.9822 9.89551C44.6632 9.89551 44.3881 9.97526 44.157 10.1348C43.9259 10.2943 43.7485 10.5205 43.6248 10.8135C43.5011 11.1064 43.4393 11.4564 43.4393 11.8633V11.873C43.4393 12.2767 43.5011 12.6266 43.6248 12.9229C43.7485 13.2158 43.9259 13.4421 44.157 13.6016C44.3881 13.7611 44.6632 13.8408 44.9822 13.8408ZM48.6568 16.3457C48.6015 16.3457 48.5396 16.3424 48.4713 16.3359C48.4029 16.3327 48.3395 16.3262 48.2809 16.3164V15.6182C48.3329 15.6279 48.3899 15.6344 48.4518 15.6377C48.5136 15.641 48.5738 15.6426 48.6324 15.6426C48.8733 15.6426 49.0702 15.5807 49.2232 15.457C49.3795 15.3333 49.5048 15.1201 49.5992 14.8174L49.6969 14.5049L47.7486 9.23633H48.6568L50.2779 14.0996L49.941 13.5674H50.3414L50.0045 14.0996L51.6207 9.23633H52.5143L50.4586 14.8223C50.3154 15.2161 50.164 15.5238 50.0045 15.7451C49.845 15.9665 49.6578 16.1211 49.443 16.209C49.2314 16.3001 48.9693 16.3457 48.6568 16.3457Z' fill='%230E0D0B'/%3e%3cpath d='M62.7081 13.27C62.742 13.27 62.7642 13.3057 62.7491 13.3362V13.336L61.1229 16.6083C61.0892 16.6761 60.9926 16.6759 60.959 16.6083L59.3382 13.336C59.3232 13.3057 59.3453 13.27 59.3792 13.27H62.7081Z' fill='%23EA4B4B'/%3e%3cpath d='M61.0026 9.71913C61.0194 9.68524 61.0678 9.68524 61.0845 9.71913L62.747 13.0897C62.762 13.12 62.7399 13.1557 62.706 13.1557H59.3763C59.3424 13.1557 59.3203 13.12 59.3353 13.0897L61.0026 9.71913Z' fill='%23EA4B4B'/%3e%3cpath d='M60.8426 9.63827C60.8766 9.63827 60.8987 9.6741 60.8835 9.70444L59.2164 13.0594C59.1995 13.0932 59.1513 13.0932 59.1345 13.0594L57.5001 9.77047C57.47 9.70962 57.5142 9.63827 57.5821 9.63827H60.8426Z' fill='%23EA4B4B'/%3e%3cpath d='M64.5036 9.63617C64.5715 9.63618 64.6157 9.70753 64.5855 9.76838H64.5854L62.9512 13.0573C62.9344 13.0911 62.8862 13.0912 62.8692 13.0573L61.2021 9.70235C61.187 9.672 61.2091 9.63617 61.2431 9.63617H64.5036Z' fill='%23EA4B4B'/%3e%3cpath d='M62.8284 6.18281C62.862 6.11518 62.9586 6.11518 62.9922 6.18281L64.5855 9.38969C64.6157 9.45054 64.5715 9.52189 64.5036 9.52189H61.2431C61.2091 9.52189 61.187 9.48605 61.2021 9.45571L62.8283 6.18265L62.8284 6.18281Z' fill='%23EA4B4B'/%3e%3cpath d='M62.3131 6.13196C62.381 6.13196 62.4252 6.20331 62.3951 6.26416C62.154 6.74935 61.9128 7.23455 61.6718 7.71975H61.6716C61.4225 8.22125 61.1733 8.72259 60.9242 9.22409C60.9074 9.25799 60.859 9.25799 60.8422 9.22409L60.6305 8.79587C60.6275 8.78957 60.6259 8.78263 60.6259 8.77553V6.22349C60.6259 6.17297 60.6668 6.13196 60.7173 6.13196H62.3131Z' fill='%23EA4B4B'/%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M74.8537 10.0096C75.2721 10.0096 75.654 10.1125 75.9993 10.3184C76.3513 10.5177 76.6303 10.8032 76.8361 11.1751C77.0487 11.547 77.1549 11.9953 77.1549 12.52V12.6495C77.1549 13.1675 77.052 13.6158 76.8461 13.9943C76.6402 14.3729 76.3613 14.6618 76.0093 14.861C75.664 15.0603 75.2788 15.1599 74.8537 15.1599C74.515 15.1599 74.2261 15.1134 73.9871 15.0204C73.7546 14.9341 73.5653 14.8212 73.4192 14.6817C73.2731 14.5423 73.1602 14.3995 73.0805 14.2534H72.941V16.9659L72.1541 16.0013V10.1491H72.9211V10.956H73.0352C73.2729 10.6733 73.3893 10.4911 73.6683 10.2985C73.9538 10.1059 74.349 10.0096 74.8537 10.0096ZM74.6445 10.7069C74.1464 10.7069 73.7347 10.8696 73.4092 11.195C73.0905 11.5138 72.9311 11.9621 72.9311 12.5399V12.6296C72.9311 13.2074 73.0905 13.659 73.4092 13.9844C73.7347 14.3032 74.1464 14.4626 74.6445 14.4626C75.1492 14.4626 75.5577 14.3032 75.8698 13.9844C76.1886 13.659 76.348 13.2074 76.348 12.6296V12.5399C76.348 11.9621 76.1886 11.5138 75.8698 11.195C75.5577 10.8696 75.1492 10.7069 74.6445 10.7069Z' fill='%230E0D0B'/%3e%3cpath d='M78.5848 11.9583L78.5555 15.4596L77.7681 14.4846V10.9583L78.5848 11.9583Z' fill='%230E0D0B'/%3e%3cpath d='M101.588 10.2986H102.444L103 10.986H101.588V10.9867H100.802L101.588 11.9623V14.1937C101.588 14.3929 101.685 14.4926 101.877 14.4926H102.379L102.928 15.17H101.668C101.389 15.17 101.173 15.0936 101.021 14.9409C100.874 14.7881 100.801 14.5789 100.801 14.3133V10.986H99.8799L99.3217 10.2986H100.801V9.13501H101.588V10.2986Z' fill='%230E0D0B'/%3e%3cpath d='M69.0133 7.90764C69.4848 7.90764 69.9065 7.99068 70.2784 8.15671C70.6569 8.3161 70.9525 8.55517 71.165 8.87395C71.3842 9.18609 71.4938 9.58126 71.4938 10.0594V10.4778H70.667V10.0594C70.667 9.72072 70.5939 9.44842 70.4477 9.24254C70.3083 9.03666 70.1124 8.88392 69.86 8.7843C69.6143 8.68469 69.332 8.63487 69.0133 8.63487C68.555 8.63487 68.1864 8.7378 67.9075 8.94367C67.6286 9.14291 67.4891 9.4285 67.4891 9.80041C67.4891 10.0461 67.5488 10.2453 67.6684 10.3981C67.7879 10.5508 67.9573 10.677 68.1764 10.7767C68.3956 10.8696 68.658 10.9527 68.9635 11.0257L69.4815 11.1552C69.8866 11.2416 70.2485 11.3611 70.5673 11.5138C70.8927 11.6599 71.1517 11.8625 71.3443 12.1215C71.5369 12.3739 71.6332 12.706 71.6332 13.1177C71.6332 13.5295 71.5303 13.8881 71.3244 14.1936C71.1185 14.4991 70.8263 14.7382 70.4477 14.9109C70.0758 15.0769 69.6375 15.1599 69.1328 15.1599C68.6281 15.1599 68.1765 15.0702 67.778 14.8909C67.3795 14.7116 67.0641 14.4426 66.8316 14.084C66.6058 13.7187 66.4929 13.2638 66.4929 12.7192V12.51H67.3197V12.7192C67.3197 13.297 67.4891 13.7287 67.8278 14.0143C68.1665 14.2932 68.6015 14.4327 69.1328 14.4327C69.6774 14.4327 70.0924 14.3098 70.378 14.0641C70.6636 13.8183 70.8064 13.5095 70.8064 13.1376C70.8064 12.8786 70.74 12.6727 70.6072 12.52C70.481 12.3673 70.3017 12.2444 70.0692 12.1514C69.8368 12.0518 69.5645 11.9655 69.2523 11.8924L68.7343 11.7629C68.3292 11.6566 67.9706 11.5271 67.6584 11.3744C67.3463 11.2216 67.1006 11.0224 66.9213 10.7767C66.7486 10.5243 66.6623 10.2022 66.6623 9.81035C66.6623 9.41852 66.7585 9.07981 66.9511 8.79424C67.1504 8.50866 67.426 8.28953 67.778 8.13678C68.1366 7.98404 68.5484 7.90764 69.0133 7.90764Z' fill='%230E0D0B'/%3e%3cpath d='M81.6544 10.0096C82.1193 10.0096 82.5145 10.0959 82.8399 10.2686C83.1719 10.4412 83.431 10.6704 83.6169 10.956C83.8095 11.2415 83.9324 11.5471 83.9855 11.8725L83.2185 12.0318C83.1853 11.7928 83.1056 11.5736 82.9794 11.3744C82.8598 11.1752 82.6905 11.0158 82.4713 10.8962C82.2521 10.7767 81.9832 10.7169 81.6644 10.7169C81.339 10.7169 81.0468 10.7899 80.7877 10.936C80.5354 11.0821 80.3328 11.2914 80.1801 11.5637C80.034 11.836 79.9609 12.1614 79.9609 12.5399V12.6296C79.9609 13.0081 80.034 13.3335 80.1801 13.6058C80.3328 13.8781 80.5354 14.0873 80.7877 14.2334C81.0468 14.3795 81.339 14.4526 81.6644 14.4526C82.1492 14.4526 82.5178 14.3264 82.7702 14.0741C83.0292 13.8217 83.1886 13.5095 83.2483 13.1376L84.0254 13.307C83.9523 13.6257 83.8195 13.9279 83.6269 14.2135C83.4343 14.4991 83.172 14.7282 82.8399 14.9009C82.5145 15.0735 82.1193 15.1599 81.6544 15.1599C81.1829 15.1599 80.7579 15.0603 80.3793 14.861C80.0074 14.6551 79.7119 14.363 79.4927 13.9844C79.2802 13.6059 79.1739 13.1575 79.1739 12.6395V12.5299C79.1739 12.0053 79.2802 11.557 79.4927 11.1851C79.7119 10.8066 80.0074 10.5177 80.3793 10.3184C80.7579 10.1126 81.1829 10.0096 81.6544 10.0096Z' fill='%230E0D0B'/%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M86.7515 10.0096C87.2097 10.0096 87.6149 10.1092 87.9668 10.3084C88.3188 10.501 88.5944 10.78 88.7937 11.1452C88.9929 11.5105 89.0925 11.9389 89.0925 12.4304V12.7889H85.1177C85.1377 13.3136 85.3071 13.7254 85.6258 14.0243C85.9446 14.3165 86.3431 14.4626 86.8212 14.4626C87.2396 14.4626 87.5617 14.3663 87.7875 14.1737C88.0133 13.9811 88.186 13.752 88.3056 13.4863L88.983 13.815C88.8833 14.0209 88.7439 14.2268 88.5646 14.4327C88.3919 14.6386 88.1628 14.8113 87.8772 14.9507C87.5983 15.0902 87.2396 15.1599 86.8013 15.1599C86.3099 15.1599 85.8782 15.057 85.5063 14.8511C85.1344 14.6386 84.8455 14.343 84.6396 13.9645C84.4337 13.5859 84.3307 13.1476 84.3307 12.6495V12.5299C84.3307 12.0252 84.4337 11.5836 84.6396 11.205C84.8455 10.8265 85.1311 10.5342 85.4963 10.3284C85.8616 10.1159 86.28 10.0096 86.7515 10.0096ZM86.7515 10.7069C86.3066 10.7069 85.9413 10.8331 85.6557 11.0855C85.3701 11.3378 85.1941 11.6898 85.1277 12.1414H88.2956C88.269 11.6898 88.113 11.3378 87.8274 11.0855C87.5485 10.8331 87.1898 10.7069 86.7515 10.7069Z' fill='%230E0D0B'/%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M97.1624 10.0096C97.6207 10.0096 98.0258 10.1092 98.3778 10.3084C98.7298 10.501 99.0054 10.78 99.2046 11.1452C99.4039 11.5105 99.5035 11.9389 99.5035 12.4304V12.7889H95.5287C95.5487 13.3136 95.718 13.7254 96.0368 14.0243C96.3555 14.3165 96.754 14.4626 97.2322 14.4626C97.6505 14.4626 97.9727 14.3663 98.1985 14.1737C98.4243 13.9811 98.5969 13.752 98.7165 13.4863L99.3939 13.815C99.2943 14.0209 99.1548 14.2268 98.9755 14.4327C98.8028 14.6386 98.5737 14.8113 98.2881 14.9507C98.0092 15.0902 97.6506 15.1599 97.2123 15.1599C96.7208 15.1599 96.2892 15.057 95.9172 14.8511C95.5453 14.6386 95.2564 14.343 95.0505 13.9645C94.8446 13.5859 94.7417 13.1476 94.7417 12.6495V12.5299C94.7417 12.0252 94.8446 11.5836 95.0505 11.205C95.2564 10.8265 95.542 10.5342 95.9073 10.3284C96.2725 10.1158 96.6909 10.0096 97.1624 10.0096ZM97.1624 10.7069C96.7175 10.7069 96.3522 10.8331 96.0666 11.0855C95.7811 11.3378 95.6051 11.6898 95.5387 12.1414H98.7066C98.68 11.6898 98.5239 11.3378 98.2383 11.0855C97.9594 10.8331 97.6008 10.7069 97.1624 10.7069Z' fill='%230E0D0B'/%3e%3cpath d='M92.2484 10.0594C92.6137 10.0594 92.9391 10.1358 93.2247 10.2885C93.5169 10.4413 93.7494 10.6671 93.9221 10.966C94.0947 11.2648 94.1811 11.6334 94.1811 12.0717V15.1458H93.394V12.1315C93.394 11.6467 93.2712 11.2947 93.0255 11.0755C92.7864 10.8564 92.461 10.7468 92.0492 10.7468C91.5777 10.7468 91.1925 10.8995 90.8936 11.205C90.6014 11.5105 90.4553 11.9655 90.4553 12.5698V15.1458H89.6683V10.1491H90.4354V10.9582H90.5361C90.7355 10.7018 90.8604 10.5342 91.1128 10.3483C91.3718 10.1557 91.7503 10.0594 92.2484 10.0594Z' fill='%230E0D0B'/%3e%3cpath d='M78.5932 10.9581H77.7681V10.1514H78.6L78.5932 10.9581Z' fill='%230E0D0B'/%3e%3c/svg%3e";const ic=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(","),Nn=({isOpen:e,onClose:t,title:n,subtitle:o,children:r,overlayContent:s,overlayDimmed:a=!0,styles:i,theme:l,maxWidth:c="522px",dark:d,footerLinkText:u,bannerSrc:f,bannerAlt:y,closeOnBackdropClick:m=!1})=>{const{theme:g,dark:h,dk:w,palette:x}=Vt(i,d),b=d??h,v=l||g,C=i?.fontFamily||v.typography.fontFamily||Ne.ui,k=i?.primaryColor||v.colors.primary,S=Z(null),F=Z(null),T=Z(null),E=Ai(),[M,B]=P(!1),[D,W]=P(!1),I=Z(t);if(ue(()=>{I.current=t},[t]),ue(()=>{if(!e){W(!1);return}F.current=document.activeElement;const z=document.body.style.overflow;document.body.style.overflow="hidden";const re=requestAnimationFrame(()=>{const X=requestAnimationFrame(()=>W(!0));T.current=X}),pe=()=>{const X=S.current;X&&(X.querySelectorAll(ic)[0]??X).focus({preventScroll:!0})},se=X=>{if(X.key==="Escape"){X.stopPropagation(),I.current();return}if(X.key!=="Tab")return;const Y=S.current;if(!Y)return;const _=Array.from(Y.querySelectorAll(ic)).filter(R=>!R.hasAttribute("aria-hidden"));if(_.length===0){X.preventDefault(),Y.focus();return}const j=_[0],ke=_[_.length-1],Se=document.activeElement;X.shiftKey&&Se===j?(X.preventDefault(),ke.focus()):!X.shiftKey&&Se===ke&&(X.preventDefault(),j.focus())},V=requestAnimationFrame(pe);return document.addEventListener("keydown",se),()=>{cancelAnimationFrame(V),cancelAnimationFrame(re),T.current&&cancelAnimationFrame(T.current),document.removeEventListener("keydown",se),document.body.style.overflow=z;const X=F.current;X&&typeof X.focus=="function"&&X.focus({preventScroll:!0})}},[e]),!e)return null;const O=!!f&&!M,U=y??"";return p("div",{onMouseDown:z=>{m&&z.target===z.currentTarget&&I.current()},style:{position:"fixed",inset:0,backgroundColor:b?"rgba(0,0,0,0.72)":"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",padding:"clamp(16px, 4vw, 48px)",zIndex:Io.modal,opacity:D?1:0,transition:`opacity ${Ps.normal} ${Po.out}`},children:p("div",{ref:S,role:"dialog","aria-modal":"true","aria-labelledby":E,tabIndex:-1,style:{backgroundColor:x.shellBorder,borderRadius:"12px",padding:"5px",width:"100%",maxWidth:c,boxSizing:"border-box",boxShadow:"0 16px 48px rgba(0, 0, 0, 0.4)",outline:"none",transform:D?"scale(1)":"scale(0.96)",transition:`transform ${Ps.slow} ${Po.out}`,display:"flex",flexDirection:"column",maxHeight:"100%"},children:A("div",{style:{backgroundColor:x.shell,border:`1px solid ${x.shellInnerBorder}`,borderRadius:"9px",width:"100%",padding:"0",display:"flex",flexDirection:"column",position:"relative",flex:"0 1 auto",minHeight:0,overflowY:"auto",overflowX:"hidden"},children:[s&&a&&p("div",{style:{position:"absolute",inset:0,backgroundColor:"rgba(0, 0, 0, 0.4)",zIndex:5,pointerEvents:"none",borderRadius:"12px"},"aria-hidden":"true"}),O&&A("div",{style:{position:"relative",width:"100%"},children:[p("img",{src:f,style:{width:"100%",height:"auto",display:"block",borderRadius:"6px 6px 0 0"},alt:U,"aria-hidden":U===""?"true":void 0,onError:()=>B(!0)}),p("button",{type:"button",onClick:t,"aria-label":"Close dialog",style:{position:"absolute",top:"8px",right:"8px",minWidth:"44px",minHeight:"44px",color:x.textPrimary,padding:"8px",backgroundColor:"transparent",borderRadius:"9999px",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1},children:p(Ar,{size:28,strokeWidth:2.5})})]}),A("div",{style:{padding:"28px 28px 0 28px",position:"relative"},children:[!O&&p("button",{type:"button",onClick:t,"aria-label":"Close dialog",style:{position:"absolute",top:"10px",right:"10px",minWidth:"44px",minHeight:"44px",color:x.textSecondary,padding:"10px",backgroundColor:"transparent",borderRadius:"50%",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background-color 0.2s",fontSize:"18px",fontWeight:"600"},onMouseEnter:z=>{z.currentTarget.style.backgroundColor=b?`${k}1a`:"#f3f4f6"},onMouseLeave:z=>{z.currentTarget.style.backgroundColor="transparent"},children:p(Ar,{size:24,strokeWidth:2.4})}),p("h2",{id:E,style:{fontSize:"22px",fontWeight:"700",color:x.textPrimary,margin:"0",fontFamily:C,lineHeight:"1.12"},children:n})]}),o&&p("div",{style:{padding:"11px 28px 13px 28px",fontSize:"12px",color:x.textSecondary,margin:"0",lineHeight:"1.35",fontFamily:C,borderBottom:b?`1px solid ${w.cardBorder}`:"1px solid #cdcfd1"},children:o}),r,A("div",{style:{padding:"12px 28px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[p("img",{src:ac,alt:"","aria-hidden":"true",width:108,height:22,decoding:"async",style:{width:"108px",height:"22px",opacity:b?.85:1,filter:b?"brightness(0) invert(1)":"none",margin:0,display:"block"}}),p("a",{href:"https://spiceflow-docs.spicenet.io",target:"_blank",rel:"noopener noreferrer",style:{fontSize:"10px",color:x.textSecondary,textDecoration:"none",display:"flex",alignItems:"center",gap:"4px",fontFamily:C,lineHeight:"1"},children:p("span",{style:{color:k,textDecoration:"underline",fontWeight:"500"},children:u??"Learn more \u2192"})})]}),s]})})})},lc=({dk:e,dark:t,message:n,buttonLabel:o,onAction:r,disabled:s=!1})=>A("div",{style:{padding:"12px",backgroundColor:e.warningBg,borderRadius:"8px",border:`1px solid ${e.warningBorder}`},children:[p("p",{style:{margin:"0 0 10px 0",color:e.warningText,fontSize:"14px"},children:n}),p("button",{onClick:r,disabled:s,style:{width:"100%",padding:"8px 12px",borderRadius:"6px",border:`1px solid ${t?e.warningBorder:"#fbbf24"}`,backgroundColor:t?e.cardBg:"white",cursor:s?"not-allowed":"pointer",fontWeight:600,fontSize:"13px",color:e.warningText,opacity:s?.6:1},children:o})]}),cc=({dk:e,dark:t,borderRadius:n,children:o})=>p("div",{style:{padding:"8px 12px",marginBottom:"8px",backgroundColor:t?e.warningBg:"#fffbeb",border:`1px solid ${e.warningBorder}`,borderRadius:n,fontSize:"12px",color:e.warningText,lineHeight:"1.4"},children:o});async function dc(e,t,n){let o=null;try{const r=await e.request({method:"eth_chainId"});o=parseInt(r,16)}catch{o=null}o!==t&&(n?.(),await vi(e,t))}function uc(e){let t=e;const n=new Set;for(;t&&typeof t=="object"&&!n.has(t);){if(n.add(t),t.code===4001)return!0;t=t.cause}return!1}async function Fa(e){const t=e.provider??await e.wallet?.getEthereumProvider();if(!t)throw new Error("External wallet provider not available");await dc(t,e.chainId,e.onSwitch);const n=await t.request({method:"eth_accounts"});if(!Array.isArray(n)||!n.some(r=>typeof r=="string"&&r.toLowerCase()===e.account.toLowerCase()))throw new Error("The connected source wallet changed. Reconnect the selected account before funding.");const o=nt(e.chainId)?.viemChain;return{extWc:Qs({account:e.account,chain:o,transport:js(t)}),viemChain:o}}async function pc(e,t,n){const o=Date.now()+1e4;for(;Date.now()<o;){let r,s;try{r=await Promise.race([Promise.all([t.getBlockNumber({cacheTime:0}),e.request({method:"eth_blockNumber"}).then(BigInt)]),new Promise(a=>{s=setTimeout(()=>a(null),Math.max(0,o-Date.now()))})])}catch{return}finally{clearTimeout(s)}if(!r||Date.now()>=o||r.every(a=>a>=n))return;await new Promise(a=>setTimeout(a,Math.min(250,o-Date.now())))}}async function hf(e){let t;for(const[n,o]of e.calls.entries()){await e.observer?.onSending?.(n);let r;try{r=await e.extWc.sendTransaction({to:o.to,data:o.data,value:o.value,chain:e.viemChain})}catch(i){throw uc(i)&&e.observer?.onRejected?.(n),i}e.observer?.onSubmitted?.(n,r);const s=await fs({client:e.client,hash:r,call:o,onRepriced:i=>e.observer?.onSubmitted?.(n,i),onCancelled:()=>e.observer?.onReverted?.(n,r)});r=s.hash;const a=s.receipt;if(a.status!=="success")throw e.observer?.onReverted?.(n,r),new Error(e.errorMessage);await pc(e.extWc,e.client,a.blockNumber),e.observer?.onConfirmed?.(n,r),t=r}return t}async function fc(e){const t=await e.client.estimateFeesPerGas(),n=t.maxFeePerGas??t.gasPrice;if(typeof n!="bigint"||n<=0n)throw new Error("Network gas could not be priced.");let o=0n;for(const r of e.calls){const s=await e.client.estimateGas({account:e.account,...r});o+=(s*n*120n+99n)/100n}return o}function ys(e,t,n,o){return n?{to:e,value:o,data:"0x"}:{to:t,value:0n,data:Tt({abi:ot,functionName:"transfer",args:[e,o]})}}async function mc(e){const t=ys(e.recipient,e.token,e.isNative,e.amount),[n,o]=await Promise.all([e.client.estimateGas({account:e.account,...t}),e.client.estimateFeesPerGas()]),r=o.maxFeePerGas??o.gasPrice;if(typeof r!="bigint"||r<=0n)throw new Error("Source transaction gas could not be priced.");return(n*r*120n+99n)/100n}function Ta(e,t){return t.isNative?e.sendTransaction({to:t.recipient,value:t.amount,chain:t.viemChain}):e.sendTransaction({to:t.tokenAddr,data:Tt({abi:ot,functionName:"transfer",args:[t.recipient,t.amount]}),chain:t.viemChain})}async function gf(e){const{extWc:t,sourceClient:n,recipient:o,tokenAddr:r,isNative:s,amount:a}=e;if(a<=0n)return;await e.observer?.onSending?.(0);let i;try{i=await Ta(t,{recipient:o,tokenAddr:r,isNative:s,amount:a,viemChain:e.viemChain})}catch(d){throw uc(d)&&e.observer?.onRejected?.(0),d}e.observer?.onSubmitted?.(0,i);const l=await fs({client:n,hash:i,call:ys(o,r,s,a),onRepriced:d=>e.observer?.onSubmitted?.(0,d),onCancelled:()=>e.observer?.onReverted?.(0,i)});i=l.hash;const c=l.receipt;if(c.status!=="success")throw e.observer?.onReverted?.(0,i),new Error("Embedded wallet funding failed");await pc(t,n,c.blockNumber),e.observer?.onConfirmed?.(0,i)}function hc({escrowAddress:e,tokenAddress:t,isNative:n,amount:o,gasFeeAmount:r}){const s=(a,i)=>n?{to:a,value:i,data:"0x"}:{to:t,value:0n,data:Tt({abi:ot,functionName:"transfer",args:[a,i]})};return[s(e,o),...r>0n?[s(Zt,r)]:[]]}function yf({sourceChainId:e,selectedAsset:t,destinationChainId:n,destinationTokenAddress:o,isCrossDenomination:r,convertedUsdAmount:s}){const a=dt(t.asset.address),i=o;let l,c;if(i&&n)if(l=jr[n]?.supportedTokens?.find(d=>oe(d.address,i))?.decimals??t.asset.decimals,r){if(!s)throw new Error("Destination amount is still being calculated. Please retry in a moment.");c=s}else{const d=Cn(t.amount,t.asset.decimals);c=Vn(d,t.asset.decimals,l)}return{sourceChainId:e,depositTokenAddress:a,depositAmount:t.amount,depositTokenDecimals:t.asset.decimals,destinationChainId:n,destinationTokenAddress:i,destinationAmount:c,destinationTokenDecimals:l}}async function wf(e,t){if(!e)return[];if(Array.isArray(e))return e;const n=e;return e.length>=2?n(t.depositAmount,t.depositTokenAddress):n(t)}function gc(e,t){return!!e&&e.quotedAmount===t.amount&&e.chainId===t.chainId&&oe(e.token,t.token)}async function ws(e,t){const n=await Ta(e,{recipient:t.recipient,tokenAddr:t.tokenAddr,isNative:t.isNative,amount:t.amount});t.afterSend?.(n);const o=bt(t.chainId),{receipt:r,hash:s}=await fs({client:o,hash:n,call:ys(t.recipient,t.tokenAddr,t.isNative,t.amount),confirmations:2});if(r.status!=="success")throw new Error(t.failureMessage);return t.settle&&await o.getBlockNumber()-r.blockNumber<2n&&await Qn(3e3),s}async function xf(e){const t=e.selectedDepositAssets.filter(r=>r.asset&&r.amount&&parseFloat(r.amount)>0);if(t.length===0){console.error("[DepositModal] No valid assets for deposit"),e.setError("Please select an asset and enter an amount");return}const n=t[0];if(!e.escrowOnly&&!e.sourceAddress){e.setError("External wallet not connected. Please connect your wallet in the previous step.");return}if(!e.isNon7702){if(!e.address||!e.embeddedWalletAddress){e.setError("Couldn't find your account wallet. Try reconnecting.");return}if(!e.isReady||!e.isAuthenticated){e.setError("Sign in to continue.");return}}if(e.zeroCreditError){e.setError(e.zeroCreditError);return}if(e.depositBalanceError){e.setError(e.depositBalanceError);return}if(e.isNon7702&&e.sponsorGas&&e.nativeChainId&&n.asset.chainId!==e.nativeChainId&&e.destinationTokenAddress){e.setError("Gas sponsorship is not supported for this deposit route. Disable sponsorGas to continue.");return}e.setIsExecuting(!0),e.setError(null);let o=!1;try{const r=n.asset.chainId,s=ro(r),a=Cn(n.amount,n.asset.decimals),i=t.length===1&&gc(e.effectiveDepositFee,{amount:a,token:dt(n.asset.address),chainId:r}),l=!e.isNon7702&&!e.escrowOnly&&!wo(n.asset);if(!e.isNon7702&&t.length===1&&!l&&!i)throw new Error("Fee quote is out of date. Please wait for it to refresh.");let c=e.externalWalletClient;if(!e.escrowOnly){if(!c)throw new Error("External wallet not connected");if(e.externalProvider){const d=await Fa({provider:e.externalProvider,account:e.sourceAddress,chainId:r});d.viemChain&&(c=d.extWc)}}if(e.isNon7702){if(!c)throw new Error("External wallet not connected");if(!e.sourceAddress)throw new Error("External wallet address not available");if(e.nativeChainId&&r===e.nativeChainId){const d=nt(r),u=t.map(y=>`${y.amount} ${y.asset.symbol}`).join(", ");e.setConfirmationData({network:d?.displayName||`Chain ${r}`,amount:u,symbol:"",chainId:r}),e.setShowConfirmation(!0);let f=null;e.setDirectDepositStatus("processing"),e.setDirectDepositChainId(r);for(const y of t){const m=Cn(y.amount,y.asset.decimals),g=dt(y.asset.address),h=y.asset.isNative||be(g),w=await ws(c,{chainId:r,recipient:s,tokenAddr:g,isNative:h,amount:m,failureMessage:`Escrow deposit failed for ${y.asset.symbol}`});f=w,e.setDirectDepositTxHash(w)}if(t[0]?.amount){const y=t[0].amount;if(e.onDepositExecute){e.setPostDepositStatus("executing");try{await e.onDepositExecute(y),e.setPostDepositStatus("success")}catch(g){console.error("ctx.onDepositExecute failed:",g),e.setPostDepositStatus("error"),e.setPostDepositError(g?.message||"Post-deposit instruction failed")}}else e.setPostDepositStatus("success");e.setDirectDepositStatus("success"),e.setPostDepositAmount(y),e.setPostDepositSuccess(!0);const m={type:"deposit",status:"success",amount:y,asset:t[0].asset.symbol,sourceChain:d?.displayName||`Chain ${r}`,txHash:f??void 0};window.dispatchEvent(new CustomEvent("spiceflow:action",{detail:m})),e.onDepositSuccess?.(m)}e.refreshAssets(),e.onDepositSelect&&e.onDepositSelect(t[0].asset)}else{const d=e.destinationChainId||e.nativeChainId;if(!d)throw new Error("Destination chain ID is required for non-7702 mode. Either pass ctx.destinationChainId to <SpiceDeposit> or set ctx.nativeChainId on <SpiceFlowProvider>.");const u=bi(r),f=s,y=[];let m=null;for(const g of t){const h=Cn(g.amount,g.asset.decimals),w=dt(g.asset.address),x=g.asset.isNative||be(w),b=await ws(c,{chainId:r,recipient:f,tokenAddr:w,isNative:x,amount:h,failureMessage:`Transfer failed for ${g.asset.symbol}`,settle:!0});m||(m=b),e.depositDataRef.current||(e.depositDataRef.current=[]),e.depositDataRef.current.push({txHash:b,sender:e.sourceAddress,tokenAddress:w,chainId:r,amount:h.toString(),user:e.spiceBalanceUser}),y.push({tokenAddress:w,tokenAmount:h.toString(),sender:e.sourceAddress,receiver:f})}if(!m)throw new Error("No transaction hash generated");if(!e.destinationTokenAddress){const g={type:"deposit",status:"success",amount:t[0]?.amount,asset:t[0]?.asset?.symbol,sourceChain:Tn(r),txHash:m};window.dispatchEvent(new CustomEvent("spiceflow:action",{detail:g})),e.onDepositSuccess?.(g),e.depositDataRef.current=null,e.bridgedAmountRef.current=t[0]?.amount||null,e.refreshAssets(),e.onDepositSelect&&e.onDepositSelect(t[0].asset),e.setShowConfirmation(!1);return}if(e.mode==="ondemand"){const g={to:u,value:BigInt(0),data:"0x"},h=await Vr(d,e.destinationTokenAddress);let w=BigInt(0);for(const E of y){const M=BigInt(E.tokenAmount),B=dt(E.tokenAddress),D=t.find(I=>{const O=dt(I.asset.address);return oe(O,B)}),W=D?D.asset.decimals:await Vr(r,Dt);w+=Vn(M,W,h)}e.isCrossDenomination&&e.convertedUsdAmount&&(w=e.convertedUsdAmount);const x={chainId:r,tokenTransfers:y.map(E=>({from:E.sender,to:E.receiver,token:E.tokenAddress,amount:BigInt(E.tokenAmount)})),call:g},b=e.isCrossDenomination&&e.convertedUsdAmount?[{from:e.sourceAddress,to:s,token:dt(t[0].asset.address),amount:Cn(t[0].amount,t[0].asset.decimals)}]:[],v={chainId:d,tokenTransfers:[...b,{from:"escrow",to:e.sourceAddress,token:e.destinationTokenAddress,amount:w}],call:{to:e.destinationTokenAddress,value:BigInt(0),data:"0x"}},C={mode:"non-7702:on-demand",chainBatches:[x,v]},k={user:e.sourceAddress,intents:[C]},S=await yt.createAction(k),F=S.actionId,T=S.intentIds[0];if(!m)throw new Error("No transaction hash available");e.startStatusPolling(T,Ci([{chainId:r,calls:[g]},{chainId:d,calls:[v.call]}],E=>Tn(E))),await yt.executeStep(F,0,0,{action:"execute",hash:m}),t[0]?.amount&&(e.bridgedAmountRef.current=t[0].amount),e.refreshAssets(),e.onDepositSelect&&e.onDepositSelect(t[0].asset),e.setShowConfirmation(!1)}else throw new Error("Presign mode not yet fully supported for cross-chain deposits")}}else{const d=[];let u=0,f;const y=i&&e.effectiveDepositFee?Ee(e.effectiveDepositFee.net,n.asset.decimals):n?.amount;for(const E of t){const M=Cn(E.amount,E.asset.decimals),B=i&&E===n,D=B?e.effectiveDepositFee.fee:0n,W=B?e.effectiveDepositFee.net:M,I=e.escrowOnly?M:M+D,O=dt(E.asset.address),U=E.asset.isNative||be(O);if(!e.escrowOnly&&!wo(E.asset)){e.setDirectDepositStatus("processing"),e.setDirectDepositChainId(r);const z=await ws(c,{chainId:r,recipient:e.address,tokenAddr:O,isNative:U,amount:M,failureMessage:`Transfer to embedded wallet failed for ${E.asset.symbol}`});u+=1,E===n&&(f=z);continue}e.escrowOnly||await ws(c,{chainId:r,recipient:e.address,tokenAddr:O,isNative:U,amount:I,failureMessage:`Transfer to embedded wallet failed for ${E.asset.symbol}`,afterSend:()=>Tp({chainId:r,tokenAddress:dt(E.asset.address),tokenSymbol:E.asset.symbol,tokenDecimals:E.asset.decimals,amount:E.amount,rawAmount:M.toString(),embeddedWalletAddress:e.address,externalWalletAddress:e.sourceAddress,timestamp:Date.now(),isNative:U}),settle:!0}),d.push(...hc({escrowAddress:s,tokenAddress:O,isNative:U,amount:W,gasFeeAmount:D}))}if(d.length===0){e.setDirectDepositTxHash(f??null),e.setDirectDepositStatus("success");const E={type:"deposit",status:"success",amount:n.amount,asset:n.asset.symbol,sourceChain:Tn(r),txHash:f};window.dispatchEvent(new CustomEvent("spiceflow:action",{detail:E})),e.onDepositSuccess?.(E),e.refreshAssets(),e.onDepositSelect&&e.onDepositSelect(n.asset);return}u>0&&e.setDirectDepositStatus("idle");const m=t.find(E=>e.escrowOnly||wo(E.asset))??n,g=await bt(r).getBlockNumber(),h=d.map(E=>({...E,to:Yt(E.to)})),w={chainId:r,recentBlock:g,calls:h,tokenTransfers:[]},x=yf({sourceChainId:r,selectedAsset:m===n&&y?{...n,amount:y}:m,destinationChainId:e.destinationChainId,destinationTokenAddress:e.destinationTokenAddress,isCrossDenomination:e.isCrossDenomination,convertedUsdAmount:e.convertedUsdAmount}),b=await wf(e.depositBatches,x),v=[w,...b];if(!e.address)throw new Error("Address not available");const C=[];if(e.isCrossDenomination&&e.convertedUsdAmount&&e.destinationTokenAddress){const E=e.selectedDepositAssets[0]?.asset;if(E){const M=Cn(e.selectedDepositAssets[0].amount,E.decimals);C.push({from:e.address,to:s,token:dt(E.address),amount:M}),C.push({from:"escrow",to:e.address,token:e.destinationTokenAddress,amount:e.convertedUsdAmount})}}C.length>0&&v[1]&&(v[1].tokenTransfers=C);const k=Ci(v,E=>Tn(E));let S=!1;const F=await e.execution.execute(v,Dt,0n,E=>{if(E.intentId&&!S){S=!0;for(const M of t)xa(e.address,r,dt(M.asset.address));e.startStatusPolling(E.intentId,k)}},void 0,{userOverride:e.address,useCustomTransfers:!0,skipPreSubmitFeeEstimate:!0,skipUserFundingPreflight:!0});if(e.refreshAssets(),e.onDepositExecute&&m.amount)try{e.setPostDepositStatus("executing"),await e.onDepositExecute(y||m.amount),e.setPostDepositStatus("success"),e.setPostDepositAmount(y||m.amount),e.setPostDepositSuccess(!0)}catch(E){console.error("ctx.onDepositExecute failed (7702):",E),e.setPostDepositStatus("error"),e.setPostDepositError(E?.message||"Post-deposit instruction failed");return}const T={type:"deposit",status:"success",amount:m===n&&y||m.amount,asset:m.asset.symbol,sourceChain:Tn(r),txHash:/^0x[0-9a-f]{64}$/i.test(F??"")?F:void 0};window.dispatchEvent(new CustomEvent("spiceflow:action",{detail:T})),e.onDepositSuccess?.(T),e.onDepositSelect&&e.onDepositSelect(m.asset)}}catch(r){o=!0,console.error("[DepositModal] executeDeposit CAUGHT ERROR:",r),console.error("[DepositModal] Error details:",{message:r?.message,code:r?.code,name:r?.name,stack:r?.stack?.slice(0,500)}),e.setError(Dn(r,"Deposit failed")),e.clearStatus()}finally{e.setIsExecuting(!1),o&&e.setDirectDepositStatus("idle"),o||!e.getCurrentIntentStatus()&&e.getCurrentPostDepositStatus()!=="idle"||e.setShowConfirmation(!1)}}async function bf(e){const{asset:t,assetIndex:n,selectedAssetCount:o,address:r,escrowOnly:s,isNon7702:a}=e;if(n!==0||a||o>1||!r||t.balance<=0n)return null;if(!s&&!wo(t))return ir(t.balance,t.decimals);const i=await Ba({address:r,depositQuote:{asset:t,amount:t.balance,token:dt(t.address),chainId:t.chainId},escrowOnly:s}),l=s?t.balance:t.balance>i.fee?t.balance-i.fee:0n;return ir(l,t.decimals)}async function Ba(e){const{address:t,depositQuote:n,escrowOnly:o}=e,{asset:r,amount:s,token:a,chainId:i}=n,l=ro(i),c=r.isNative||be(a),d=s>1n?1n:0n,u=[c?{to:l,value:s,data:"0x"}:{to:a,value:0n,data:Tt({abi:ot,functionName:"transfer",args:[l,s]})}];d>0n&&u.push(c?{to:Zt,value:d,data:"0x"}:{to:a,value:0n,data:Tt({abi:ot,functionName:"transfer",args:[Zt,d]})});const f={chainId:i,tokenTransfers:[],calls:u},y=(await yt.estimateBatchGas({user:t,outputToken:a,chainBatches:[{...f,hash:Gn([f])[0].hash}],signal:e.signal})).gasFee,m=o&&y<s?s-y:s;return{fee:y,net:m,quotedAmount:s,token:a,chainId:i}}function vf(e,t=40,n=18){const o=e.length,r=[{maxLength:7,shrink:0},{maxLength:10,shrink:6},{maxLength:13,shrink:12},{maxLength:16,shrink:16},{maxLength:20,shrink:19}].find(s=>o<=s.maxLength);return Math.max(n,t-(r?.shrink??22))}const Fo=({value:e,element:t="span",placeholder:n,ariaLabel:o,ariaInvalid:r,disabled:s,onChange:a,inputMode:i="decimal",autoComplete:l="off",dataSpiceflowFocus:c,fontFamily:d,fontWeight:u=700,color:f,textAlign:y,lineHeight:m=1,maxFontSize:g=40,minFontSize:h=18,overflow:w="ellipsis",title:x,style:b})=>{const v=Z(null),[C,k]=P(),S=vf(e||n||"",g,h),F=e||n||"";ue(()=>{const M=v.current;if(!M||w!=="ellipsis"){k(void 0);return}let B=!0,D=null;const W=()=>{if(!B)return;const O=getComputedStyle(M),U=M.clientWidth-parseFloat(O.paddingLeft||"0")-parseFloat(O.paddingRight||"0");if(!(U>0))return;if(!D){try{D=document.createElement("canvas").getContext("2d")}catch{return}if(!D)return}D.font=`${O.fontStyle} ${O.fontWeight} ${S}px ${O.fontFamily}`;const z=D.measureText(F),re=Math.max(z.width,(z.actualBoundingBoxLeft||0)+(z.actualBoundingBoxRight||0))+(parseFloat(O.letterSpacing)||0)*Math.max(0,F.length-1),pe=re>U?S*Math.max(0,U-1)/re:void 0;k(se=>se===pe?se:pe)};W();const I=typeof ResizeObserver>"u"?void 0:new ResizeObserver(W);return I?.observe(M),I||window.addEventListener("resize",W),document.fonts?.addEventListener("loadingdone",W),()=>{B=!1,I?.disconnect(),I||window.removeEventListener("resize",W),document.fonts?.removeEventListener("loadingdone",W)}},[F,S,d,u,w,t,b?.fontFamily,b?.fontStyle,b?.fontWeight,b?.letterSpacing,b?.paddingLeft,b?.paddingRight]);const T=w==="wrap"?{overflowWrap:"anywhere",wordBreak:"break-word",whiteSpace:"normal"}:w==="ellipsis"?{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}:{},E={fontFamily:d,fontSize:`${Math.min(S,C??S)}px`,fontWeight:u,color:f,lineHeight:m,letterSpacing:0,textAlign:y,minWidth:0,maxWidth:"100%",...T,...b};return t==="input"?p("input",{ref:v,type:"text",inputMode:i,autoComplete:l,"aria-label":o,"aria-invalid":r||void 0,"data-spiceflow-focus":c||void 0,value:e,onChange:a,placeholder:n,disabled:s,title:x,style:{backgroundColor:"transparent",border:"none",outline:"none",padding:0,width:"100%",...E}}):p(t,{ref:v,title:x,style:E,children:e})},Oa=({pct:e,isMax:t,primaryColor:n,dark:o,fillColor:r})=>{const s=e/100;return A("svg",{width:"14",height:"14",viewBox:"0 0 14 14",children:[p("circle",{cx:"7",cy:"7",r:"6.84375",fill:t?n:"none",stroke:t?n:o?"#4a5568":"#3C3E42",strokeWidth:"0.3125"}),!t&&s>0&&p("path",{d:`M 7 7 L 7 0.15625 A 6.84375 6.84375 0 ${s>.5?1:0} 1 ${7+6.84375*Math.sin(s*2*Math.PI)} ${7-6.84375*Math.cos(s*2*Math.PI)} Z`,fill:r})]})},yc=({chainId:e,name:t,size:n=16})=>{const o=e&&(yo[e]||Bi(e)?.logo)||"";return o?p("img",{src:o,alt:t||`Chain ${e}`,loading:"lazy",decoding:"async",width:n,height:n,style:{width:`${n}px`,height:`${n}px`,borderRadius:"50%",objectFit:"cover",flexShrink:0}}):null},Cf={1:"ethereum",56:"binance-smart-chain",137:"polygon-pos",143:"monad",4114:"citrea",4663:"robinhood",8453:"base",42161:"arbitrum-one"},kf=6e4,Er=new Map;function wc(e,t){return Er.get(e)?.logos?.get(t.toLowerCase())}function If(e,t){const n=Cf[e];if(!n||be(t))return;const o=Er.get(e);if(o?.logos||o?.pending)return o.pending;if(o?.failedAt!==void 0&&Date.now()-o.failedAt<kf)return;const r=Promise.resolve().then(async()=>{try{const s=await fetch(`https://tokens.coingecko.com/${n}/all.json`,{signal:AbortSignal.timeout(1e4)});if(!s.ok)throw new Error("Token list request failed");const a=await s.json(),i=new Map;for(const l of a?.tokens??[])l?.address&&l?.logoURI&&i.set(String(l.address).toLowerCase(),l.logoURI);Er.set(e,{logos:i})}catch(s){console.warn(`[tokenLogos] Token list unavailable for chain ${e}`,s),Er.set(e,{failedAt:Date.now()})}});return Er.set(e,{...o,pending:r}),r}function Ra(e,t,n){const[o,r]=P(),s=e||e===null||t===void 0||!n?void 0:`${t}:${n.toLowerCase()}`,a=s?wc(t,n):void 0;return ue(()=>{if(!s||a||t===void 0||!n)return;let i=!0;const l=()=>{const d=wc(t,n);i&&d&&r({token:s,logo:d})},c=If(t,n);return c?c.then(l):l(),()=>{i=!1}},[s,a,t,n]),e||a||(o&&o.token===s?o.logo:void 0)}const xs=({symbol:e,label:t,logoURI:n,chainId:o,address:r,size:s=20,theme:a})=>{const{theme:i}=Vt(),l=a||i,[c,d]=P(),u={width:`${s}px`,height:`${s}px`,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${s*.4}px`,fontWeight:l.typography.fontWeight.bold,flexShrink:0,overflow:"hidden",backgroundColor:"#ffffff"},f=Ra(n===null?null:n||ua[e.toUpperCase()],o,r);if(n===null)return null;if(f&&f!==c)return p("img",{src:f,alt:t??e,loading:"lazy",decoding:"async",style:{...u,objectFit:"cover"},onError:()=>d(f)});const y=Sf(e);return p("div",{style:{...u,...y.style},children:y.icon})},Sf=e=>{const t=e.toUpperCase(),n={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"}}[t];if(n)return{style:{backgroundColor:n.bg,color:n.text},icon:n.icon||t.charAt(0)};const o=t.split("").reduce((i,l)=>l.charCodeAt(0)+((i<<5)-i),0),r=Math.abs(o)%360,s=`hsl(${r}, 60%, 50%)`,a=r>180?"#FFFFFF":"#000000";return{style:{backgroundColor:s,color:a},icon:t.charAt(0)}},Af=({selectedAsset:e,assets:t,onAssetSelect:n,showDropdown:o,onToggleDropdown:r,disabled:s=!1,theme:a,onViewAllAssets:i,getAvailableBalance:l})=>{const c=jn(),d=I=>{const O=l?l(I):I.balance;return O===void 0?"...":Gr({balance:O,decimals:I.decimals})},{theme:u}=Vt(),f=a||u,y=Z(null),m=Z(null),g=Z(null),[h,w]=P(null);ue(()=>{if(o&&m.current){const I=()=>{if(m.current){const O=m.current.getBoundingClientRect();w({top:O.bottom+6,right:window.innerWidth-O.right})}};return I(),window.addEventListener("scroll",I,!0),window.addEventListener("resize",I),()=>{window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I)}}else w(null)},[o]),ue(()=>{const I=O=>{y.current&&!y.current.contains(O.target)&&g.current&&!g.current.contains(O.target)&&o&&r()};return o&&document.addEventListener("mousedown",I),()=>{document.removeEventListener("mousedown",I)}},[o,r]);const[x,b]=P(!1),v=f.mode==="light",C={backgroundColor:"transparent",border:`1px solid ${v?"#aaaaaa":f.colors.border}`,borderRadius:"6px",color:f.colors.text,cursor:s?"not-allowed":"pointer",padding:"8px 14px 8px 10px",width:"100%",display:"flex",flexDirection:"column",gap:"4px",opacity:s?.6:1,transition:Mn.interactive,transform:x?"scale(0.98)":"scale(1)"},k={display:"flex",justifyContent:"space-between",alignItems:"center",gap:"10px",minWidth:0},S={display:"flex",alignItems:"center",gap:"4px",paddingTop:"4px",borderTop:`1px solid ${f.colors.border}`},F=()=>h?{position:"fixed",top:`${h.top}px`,right:`${h.right}px`,backgroundColor:f.colors.secondary,border:`1px solid ${f.colors.border}`,borderRadius:f.borderRadius.md,boxShadow:f.shadows.lg,zIndex:Io.dropdown,width:"200px",maxHeight:"300px",overflow:"auto"}:{},T={backgroundColor:"transparent",border:"none",color:f.colors.text,cursor:"pointer",padding:f.spacing.sm,width:"100%",display:"flex",alignItems:"center",gap:f.spacing.sm,transition:`background-color ${f.animation.normal}`,":hover":{backgroundColor:f.colors.surfaceHover}},E={display:"flex",flexDirection:"column",alignItems:"flex-start",flex:1},M={fontSize:f.typography.fontSize.sm,fontWeight:f.typography.fontWeight.medium},B={fontSize:f.typography.fontSize.xs,color:f.colors.textMuted},D={backgroundColor:"transparent",border:"none",borderTop:`1px solid ${f.colors.border}`,color:f.colors.primary,cursor:"pointer",padding:"10px 12px",width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",fontFamily:f.typography.fontFamily,fontSize:f.typography.fontSize.xs,fontWeight:f.typography.fontWeight.medium,textDecoration:"underline",textUnderlineOffset:"2px"},W={transition:`transform ${f.animation.normal}`,transform:o?"rotate(180deg)":"rotate(0deg)",flexShrink:0};return A(nn,{children:[p("div",{style:{position:"relative"},ref:y,children:A("div",{ref:m,style:C,onClick:s?void 0:r,onMouseLeave:()=>{b(!1)},onMouseDown:()=>b(!0),onMouseUp:()=>b(!1),children:[A("div",{style:k,children:[p("div",{style:{display:"flex",alignItems:"center",gap:"8px",flex:1,minWidth:0},children:e?.asset?A(nn,{children:[p(xs,{symbol:e.asset.symbol,label:c(e.asset).symbol,logoURI:c(e.asset).logoURI,chainId:e.asset.chainId,address:e.asset.address,theme:f,size:24}),p("span",{style:{fontSize:"15px",fontWeight:500,color:f.colors.text,lineHeight:"1.5",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c(e.asset).symbol})]}):p("span",{style:{fontSize:"14px",color:f.colors.textMuted},children:"Select"})}),p("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:v?f.colors.textMuted:"#c7ccd4",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:W,children:p("path",{d:"M6 9l6 6 6-6"})})]}),e?.asset&&A("div",{style:S,children:[!e.asset.displayChainName&&p(yc,{chainId:e.asset.chainId,theme:f}),p("span",{style:{fontSize:"11px",color:f.colors.textMuted},children:Ns(e.asset)})]})]})}),o&&h&&Ys(A("div",{ref:g,style:F(),children:[t.length===0&&p("div",{style:{padding:"10px 12px",color:f.colors.textMuted,fontSize:f.typography.fontSize.xs},children:"No assets available"}),t.map(I=>A("button",{style:T,onClick:()=>{n(I),r()},children:[p(xs,{symbol:I.symbol,label:c(I).symbol,logoURI:c(I).logoURI,chainId:I.chainId,address:I.address,theme:f},Ce(I)),A("div",{style:E,children:[A("div",{style:{display:"flex",alignItems:"center",gap:f.spacing.xs},children:[p("span",{style:M,children:c(I).symbol}),!I.displayChainName&&p(yc,{chainId:I.chainId,theme:f})]}),A("span",{style:B,children:[d(I)," \u2022 ",Ns(I)]})]})]},Ce(I))),i&&A("button",{type:"button",style:D,onClick:()=>{r(),i()},children:[p("span",{children:"View all assets"}),A("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[p("path",{d:"M5 12h14"}),p("path",{d:"M13 5l7 7-7 7"})]})]})]}),document.body)]})},Ef=({assets:e,selectedAsset:t,onAssetSelect:n,onAmountChange:o,disabled:r=!1,loading:s=!1,label:a="Select Asset",showBalance:i=!0,showMaxButton:l=!0,placeholder:c="0.0",theme:d,styles:u,maxAmount:f,resolveMaxAmount:y,getAvailableBalance:m,hideAmountInput:g=!1,displayAmount:h,dark:w,onViewAllAssets:x})=>{const b=jn(),{theme:v,primaryColor:C,dark:k,dk:S}=Vt(u,w),F=d||v,T=w??k,[E,M]=P(!1),[B,D]=P(null),[W,I]=P(null),[O,U]=P(!1),[z,re]=P(null),[pe,se]=P(t?.amount||""),V=Z(0),X=t?.asset?Ce(t.asset):"",Y=t?.asset?m?m(t.asset):t.asset.balance:void 0,_=z??f;Ao(()=>()=>{V.current++},[]),Ao(()=>{V.current++,se(t?.amount||""),U(!1)},[X,t?.amount]),Ao(()=>{V.current++,re(null),U(!1)},[X,t?.asset.owner,t?.asset.decimals,t?.asset.balance,Y,f,y,r,s]);const j=()=>{V.current++,U(!1)},ke=()=>{const L=t?.asset;if(!L||Y===void 0)return;if(!_)return Y;const N=Cn(_,L.decimals);return N<Y?N:Y},Se=L=>{se(L),o?.(L)},R=L=>{j();const N=t?.asset,$=Kr(L.startsWith(".")?`0${L}`:L,N?.decimals);if(!N||!$)return Se($);const de=Cn($,N.decimals),J=ke();Se(J!==void 0&&de>J?Ee(J,N.decimals):$)},G=async()=>{const L=t?.asset;if(!L||r||s||Y===void 0)return;const N=++V.current,$=()=>V.current===N,de=y;if(z!==null){const ee=ke();ee!==void 0&&Se(Ee(ee,L.decimals));return}if(de){U(!0);try{const ee=await de(L);if(!$())return;if(ee!==null){const Be=Kr(ee,L.decimals),we=ke();if(!Be||we===void 0)return;const ge=Cn(Be,L.decimals)>we?Ee(we,L.decimals):Be;re(ge),Se(ge);return}return}catch(ee){$()&&console.warn("[AssetSelector] Failed to resolve max amount:",ee);return}finally{$()&&U(!1)}}const J=ke();$()&&J!==void 0&&Se(Ee(J,L.decimals))},K=async L=>{if(!t||r||Y===void 0)return;if(L===100)return G();j();const N=ke();N!==void 0&&Se(Ee(N*BigInt(L)/100n,t.asset.decimals))},Q=t&&Y!==void 0?Number(Ee(Y,t.asset.decimals)):0,he=parseFloat(pe)||0,ve=Q>0?he/Q*100:0,Fe={backgroundColor:u?.assetSelector?.backgroundColor||u?.secondaryBackground||(T?S.cardBg:"#e9e9e9"),border:T?`0.5px solid ${S.cardBorder}`:"0.5px solid #A8A8A7",borderRadius:u?.assetSelector?.borderRadius||"6px",padding:u?.assetSelector?.padding||"16px",height:"auto",minHeight:g?void 0:"144px",display:"flex",flexDirection:"column",gap:"8px",position:"relative",opacity:r?.6:1};return s?p("div",{style:Fe,children:A("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[A("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[p("div",{style:{backgroundColor:T?S.hoverBg:"#d1d5db",borderRadius:"4px",height:"16px",width:"60px"}}),p("div",{style:{backgroundColor:T?S.hoverBg:"#d1d5db",borderRadius:"4px",height:"40px",width:"150px"}})]}),A("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:"8px"},children:[p("div",{style:{backgroundColor:T?S.hoverBg:"#d1d5db",borderRadius:"4px",height:"12px",width:"80px"}}),p("div",{style:{backgroundColor:T?S.hoverBg:"#d1d5db",borderRadius:"6px",height:"46px",width:"128px"}})]})]})}):A("div",{style:Fe,children:[A("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[p("span",{style:{fontFamily:u?.fontFamily||F.typography.fontFamily,fontSize:"16px",fontWeight:500,color:T?S.textSecondary:"#7d7c7b",lineHeight:"24px"},children:a}),i&&t?.asset&&A("span",{style:{fontFamily:u?.fontFamily||F.typography.fontFamily,fontSize:"12px",fontWeight:500,color:T?S.textSecondary:"#71757a",lineHeight:"16px"},children:["Balance:"," ",Y===void 0?"...":Gr({balance:Y,decimals:t.asset.decimals})]})]}),A("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 12px",justifyContent:g&&!h?"flex-start":"space-between",alignItems:"center",flex:1},children:[!g&&p(Fo,{element:"input",ariaLabel:t?.asset?`${b(t.asset).symbol} amount`:"Amount",dataSpiceflowFocus:!0,value:pe,onChange:L=>R(L.target.value),placeholder:c,disabled:r||!t?.asset,fontFamily:u?.fontFamily||F.typography.fontFamily,color:r?T?"rgba(255, 255, 255, 0.16)":"rgba(14, 13, 11, 0.16)":pe?T?"#ffffff":"#0e0d0b":T?"#4a5568":"#d1d5db",lineHeight:"1.08",maxFontSize:40,minFontSize:22,style:{width:"100%",maxWidth:"200px",flex:"1 1 200px",minWidth:"min(200px, 100%)"}}),p("div",{style:{width:"176px",maxWidth:"100%",position:"relative",flexShrink:0,marginLeft:g&&!h?void 0:"auto"},children:p(Af,{selectedAsset:t,assets:e,onAssetSelect:L=>{j(),re(null),n(L)},showDropdown:E,onToggleDropdown:()=>M(!E),disabled:r,theme:F,onViewAllAssets:x,getAvailableBalance:m})}),g&&h&&p(Fo,{element:"span",value:h,title:h,fontFamily:u?.fontFamily||F.typography.fontFamily,color:T?"#ffffff":"#0e0d0b",lineHeight:"1.08",textAlign:"right",maxFontSize:40,minFontSize:22,style:{flex:"1 1 200px",minWidth:"min(200px, 100%)"}})]}),!g&&p("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:"10px",height:"14px"},children:[0,25,50,75,100].filter(L=>l||L!==100).map((L,N)=>{const $=Math.abs(ve-L)<1,de=N===4,J=B===L,ee=W===L;return p("button",{onClick:()=>K(L),onMouseEnter:()=>D(L),onMouseLeave:()=>{D(null),I(null)},onMouseDown:()=>I(L),onMouseUp:()=>I(null),disabled:r||!t?.asset||Y===void 0||L===100&&O,title:`${L}%`,style:{width:"14px",height:"14px",padding:0,border:"none",backgroundColor:"transparent",cursor:r||!t?.asset||Y===void 0||L===100&&O?"not-allowed":"pointer",opacity:$?1:J?.8:.5,transform:ee?"scale(0.85)":J?"scale(1.15)":"scale(1)",transition:Mn.interactive},children:p(Oa,{pct:L,isMax:de,primaryColor:C,dark:T,fillColor:T?S.textSecondary:"#3C3E42"})},L)})})]})},jo=Bn(Ef),Ff=({selectedDepositAssets:e,depositAssets:t,secondAssetOptions:n,loadingAssets:o,allowSecondAsset:r,theme:s,styles:a,dark:i,dk:l,onSelect:c,onAmountChange:d,onAdd:u,onRemove:f,resolveMaxAmount:y,onViewAllAssets:m})=>{const g=me(()=>Array.from({length:Math.max(1,e.length)},(h,w)=>y?x=>y(x,w):void 0),[y,e.length]);return A(nn,{children:[e.map((h,w)=>{const x=e.length===1?"Deposit":`Asset ${w+1}`;return A("div",{style:{marginBottom:s.spacing.md,position:"relative"},children:[p(jo,{assets:w===0?t:n,selectedAsset:h||void 0,onAssetSelect:b=>c(b,w),onAmountChange:b=>d(b,w),loading:o,label:x,showBalance:!0,theme:s,styles:a,allowSecondAsset:r&&w===0,onAddAsset:u,canAddAsset:e.length===1&&!!e[0]?.asset,resolveMaxAmount:g[w],onViewAllAssets:w===0?m:void 0}),w===1&&p("button",{onClick:()=>f(w),style:{position:"absolute",top:"-2px",right:"-2px",background:i?`${l.cardBg}ee`:"rgba(255, 255, 255, 0.9)",border:`1px solid ${l.cardBorder}`,borderRadius:"50%",cursor:"pointer",color:s.colors.textMuted,fontSize:"16px",padding:"2px",width:"22px",height:"22px",display:"flex",alignItems:"center",justifyContent:"center",transition:Mn.interactive,boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},onMouseEnter:b=>{b.currentTarget.style.color=i?l.errorText:"#ef4444",b.currentTarget.style.background=i?l.cardBg:"#fff",b.currentTarget.style.borderColor=i?l.errorBorder:"#fecaca"},onMouseLeave:b=>{b.currentTarget.style.color=s.colors.textMuted,b.currentTarget.style.background=i?`${l.cardBg}ee`:"rgba(255, 255, 255, 0.9)",b.currentTarget.style.borderColor=i?l.cardBorder:"#e5e7eb"},title:"Remove asset",children:"\xD7"})]},`asset-${w}`)}),e.length===0&&p("div",{style:{marginBottom:s.spacing.md},children:p(jo,{assets:t,selectedAsset:void 0,onAssetSelect:h=>c(h,0),onAmountChange:h=>d(h,0),loading:o,label:"Deposit",showBalance:!0,theme:s,styles:a,allowSecondAsset:r,onAddAsset:u,canAddAsset:!1,resolveMaxAmount:g[0]},"initial-selector")})]})},Tf=Bn(Ff);function Bf(e,t){switch(e){case"success":return{bg:t.successBg,border:t.successBorder,text:t.successText};case"warning":return{bg:t.warningBg,border:t.warningBorder,text:t.warningText};case"error":return{bg:t.errorBg,border:t.errorBorder,text:t.errorText};case"info":return{bg:t.infoBg,border:t.infoBorder,text:t.infoText}}}const kn=({variant:e,palette:t,children:n,icon:o,style:r,fontFamily:s,size:a="default"})=>{const i=Bf(e,t),l=a==="compact";return A("div",{role:e==="error"?"alert":"status",style:{backgroundColor:i.bg,border:`1px solid ${i.border}`,borderRadius:l?"7px":"8px",padding:l?"8px 10px":"12px 16px",color:i.text,fontSize:l?"12px":"13px",lineHeight:l?1.4:1.5,display:"flex",alignItems:"flex-start",gap:l?"6px":"8px",fontFamily:s,...r},children:[o&&p("span",{style:{flexShrink:0,display:"flex",alignItems:"center"},children:o}),p("span",{style:{minWidth:0,overflowWrap:"anywhere"},children:n})]})},xc=Ne.mono,Un=({label:e,value:t,palette:n,valueColor:o,labelColor:r,style:s})=>A("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:"12px",...s},children:[p("span",{style:{fontSize:"12px",color:r??n.textSecondary,fontFamily:xc,fontWeight:500,letterSpacing:"0.03em",flexShrink:0,whiteSpace:"nowrap"},children:e}),p("span",{style:{fontSize:"13px",color:o??n.textPrimary,fontWeight:500,fontFamily:xc,minWidth:0,textAlign:"right",overflowWrap:"anywhere"},children:t})]}),Da=({onClick:e,label:t="Add Funds",color:n,fontFamily:o,style:r})=>{const[s,a]=P(!1);return A("button",{type:"button",onClick:e,"data-spiceflow-focus":!0,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{background:"none",border:"none",cursor:"pointer",padding:0,display:"inline-flex",alignItems:"center",gap:"4px",color:n,fontSize:"12px",fontWeight:500,fontFamily:o,textDecoration:"underline",textUnderlineOffset:"2px",whiteSpace:"nowrap",opacity:s?.75:1,transition:"opacity 150ms ease",...r},children:[t,A("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[p("circle",{cx:"6",cy:"6",r:"5"}),p("path",{d:"M6 4v4M4 6h4",strokeLinecap:"round"})]})]})},Ma=({value:e,onChange:t,ariaLabel:n,placeholder:o,endAdornment:r,size:s="lg",dark:a,styles:i,inputRef:l,autoFocus:c})=>{const{dark:d,dk:u}=Vt(i,a),f=a??d,y=s==="lg",m=y?"15px":"14px",g=y?"7px":"10px",h=y?Us.input:Us.sm,w=i?.fontFamily||Ne.ui,x=f?u.inputBg:"#FAFAFA",b=f?u.inputBorder:"#e5e7eb",v=f?u.textPrimary:"#374151",C=f?u.textSecondary:"#9ca3af";return A("div",{style:{display:"flex",alignItems:"center",gap:"8px",backgroundColor:x,borderRadius:h,boxShadow:f?"0 2px 4px rgba(0, 0, 0, 0.3)":"0 2px 4px rgba(0, 0, 0, 0.1)",padding:`${g} 5px`,border:`1px solid ${b}`},children:[p(uf,{style:{color:C},size:24}),p("input",{ref:l,type:"text",role:"searchbox","aria-label":n,autoComplete:"off",spellCheck:!1,autoFocus:c,"data-spiceflow-focus":!0,placeholder:o,value:e,onChange:k=>t(k.target.value),style:{flex:1,backgroundColor:x,outline:"none",border:"none",color:v,fontSize:m,fontWeight:400,fontFamily:w}}),r]})},Of="This deposit didn't confirm in time. It may still have gone through, so check the explorer and refresh your balance before retrying.";function Rf(e){return e?.overallStatus!=="failed"?{isFailed:!1,failureMessage:null}:{isFailed:!0,failureMessage:e.steps?.find(t=>t.status==="failed"&&!!t.error)?.error||Of}}const bs=A("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",style:{flexShrink:0},children:[p("circle",{cx:"10",cy:"10",r:"10",fill:"#10b981"}),p("path",{d:"M6 10l3 3 5-6",stroke:"#ffffff",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Df=({isOpen:e,onClose:t,onConfirm:n,data:o,isExecuting:r=!1,error:s=null,theme:a,styles:i,intentStatus:l,postDepositStatus:c="idle",hasPostDepositInstruction:d=!1})=>{const{dark:u,dk:f,theme:y}=Vt(i),[m,g]=P(!1),[h,w]=P(!0);ue(()=>{e||g(!1)},[e]);const x=()=>{g(!0),setTimeout(()=>{t()},300)},b=()=>{w(!h)};if(!e||!o)return null;const v=l?.overallStatus==="processing",C=l?.overallStatus==="success",k=!!l,{isFailed:S,failureMessage:F}=Rf(l),T=!k&&d,E=T&&c==="executing",M=T&&c==="success",B=C&&d&&(c==="idle"||c==="executing")||E,D=C&&(!d||c==="success"||c==="error")||M||T&&c==="error",W=u?f.cardBg:"#ffffff",I=u?"0 -4px 20px rgba(0, 0, 0, 0.4)":"0 -4px 20px rgba(0, 0, 0, 0.15)",O=f.textSecondary,U=u?f.textPrimary:"#1f2937",z=u?f.textPrimary:"#1f2937",re=V=>p("div",{style:{marginBottom:a.spacing.md,padding:a.spacing.md,backgroundColor:i?.errorMessage?.backgroundColor||(a.mode==="light"?"#fef2f2":`${a.colors.error}20`),border:`1px solid ${i?.errorMessage?.borderColor||(a.mode==="light"?"#fecaca":a.colors.error)}`,borderRadius:i?.errorMessage?.borderRadius||a.borderRadius.md},children:p("p",{style:{color:i?.errorMessage?.color||a.colors.error,fontSize:i?.errorMessage?.fontSize||a.typography.fontSize.sm,margin:0,fontFamily:i?.errorMessage?.fontFamily||i?.fontFamily||a.typography.fontFamily},children:V})}),pe={fontSize:a.typography.fontSize.sm,fontWeight:500,color:O,fontFamily:Ne.mono,letterSpacing:"0.5px"},se=(V,X,Y=U)=>A("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[p("span",{style:pe,children:V}),p("span",{style:{fontSize:a.typography.fontSize.sm,fontWeight:500,color:Y,fontFamily:Ne.mono},children:X})]});return A("div",{style:{position:"absolute",bottom:0,left:0,right:0,zIndex:10,animation:m?"slideDown 0.3s ease-in":"slideUp 0.3s ease-out",pointerEvents:"auto"},children:[A("div",{style:{backgroundColor:W,borderRadius:"0",width:"100%",maxWidth:"522px",margin:"0 auto",padding:"18px 24px",boxShadow:I},children:[!C&&!M&&A(nn,{children:[A("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:a.spacing.md},children:[A("div",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},onClick:b,children:[p("span",{style:{fontSize:"13px",fontWeight:a.typography.fontWeight.medium,color:O,fontFamily:i?.fontFamily||a.typography.fontFamily},children:"Transaction Details"}),p(Qo,{color:O,direction:h?"up":"down"})]}),p("button",{onClick:V=>{V.stopPropagation(),t()},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:O,transition:"color 0.2s ease"},onMouseEnter:V=>{V.currentTarget.style.color=z},onMouseLeave:V=>{V.currentTarget.style.color=O},children:p(Ar,{size:16})})]}),A("div",{style:{marginBottom:a.spacing.lg,display:"flex",flexDirection:"column",gap:a.spacing.md,overflow:"hidden",maxHeight:h?"200px":"0px",opacity:h?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:[se("NETWORK",o.network),se("DEPOSITED AMOUNT",o.amount,a.colors.success),o.creditedAmount&&se("CREDITED AMOUNT",o.creditedAmount),o.spicenetFee&&se("SPICENET FEE",o.spicenetFee),o.networkFee&&se("EST. NETWORK FEE",o.networkFee)]})]}),s&&!k&&re(s),S&&F&&re(F),p(Mt,{onClick:D||S?x:n,variant:"outline",fullWidth:!0,disabled:r||v||B||E,styles:i,theme:y,children:r||v||E||B?"PROCESSING...":D?"CONTINUE \u2192":S?"CLOSE":"CONFIRM DEPOSIT"}),D&&p("p",{style:{marginTop:a.spacing.md,marginBottom:0,fontSize:"14px",color:O,textAlign:"center",fontFamily:i?.fontFamily||a.typography.fontFamily},children:"Your funds are now available in your Account"}),p("div",{style:{marginTop:a.spacing.md,display:"flex",justifyContent:"center",alignItems:"center"},children:p("img",{src:ac,alt:"Powered by SpiceNet",style:{height:"auto",width:"130px",opacity:1,filter:u?"brightness(0) invert(1) opacity(0.7)":"none"}})})]}),p("style",{children:`
4
4
  @keyframes slideUp {
5
5
  from {
6
6
  transform: translateY(100%);