@aori/mega-swap-widget 0.1.6 → 0.1.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/AssetSelectionMenu-2ILVPQBL.js +2 -0
- package/dist/AssetSelectionMenu-VK275DDY.cjs +2 -0
- package/dist/ChainSelectionMenu-2B6QTSXZ.cjs +2 -0
- package/dist/ChainSelectionMenu-UYQJ6BP3.js +2 -0
- package/dist/{SwapFormHorizontal-FTVJMZUH.cjs → SwapFormHorizontal-2JDBQ4PM.cjs} +1 -1
- package/dist/SwapFormHorizontal-DXO6F5JC.js +2 -0
- package/dist/{SwapFormSplit-LGXDW3FM.cjs → SwapFormSplit-C5Z6MUBP.cjs} +1 -1
- package/dist/{SwapFormSplit-5RRDB6H6.js → SwapFormSplit-FORONC7U.js} +1 -1
- package/dist/{WidgetWalletPanel-AMSL4XY3.js → WidgetWalletPanel-5EAZBMPR.js} +1 -1
- package/dist/{WidgetWalletPanel-OL7FBQVY.cjs → WidgetWalletPanel-H2MQ4HNZ.cjs} +1 -1
- package/dist/chunk-2UW2RRTC.js +2 -0
- package/dist/chunk-4SV4EZY2.cjs +2 -0
- package/dist/chunk-565H4OUG.js +2 -0
- package/dist/chunk-74M7ZIF5.js +2 -0
- package/dist/chunk-BJXIGJVO.js +2 -0
- package/dist/chunk-EDQ3SNQJ.cjs +2 -0
- package/dist/{chunk-YMQZ3S43.cjs → chunk-GIWNS54F.cjs} +1 -1
- package/dist/chunk-I7TSQM4Y.cjs +2 -0
- package/dist/chunk-IKVRF6NO.js +2 -0
- package/dist/{chunk-LFRHC3KG.js → chunk-K5X3YHME.js} +1 -1
- package/dist/{chunk-D6APGPYS.cjs → chunk-N7IYXS4X.cjs} +1 -1
- package/dist/chunk-T2JA5EHN.cjs +2 -0
- package/dist/chunk-TXQ6Q4S3.cjs +2 -0
- package/dist/{chunk-M26W6COT.js → chunk-XEB3SYOB.js} +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.css +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/dist/AssetSelectionMenu-52ZJ2NVY.cjs +0 -2
- package/dist/AssetSelectionMenu-56FPUYSG.js +0 -2
- package/dist/ChainSelectionMenu-L2OAYLQ7.js +0 -2
- package/dist/ChainSelectionMenu-W7J6YVYH.cjs +0 -2
- package/dist/SwapFormHorizontal-CZ57BLFP.js +0 -2
- package/dist/chunk-2TYL5SWO.js +0 -2
- package/dist/chunk-46YHIOXG.cjs +0 -2
- package/dist/chunk-BV64BFUW.cjs +0 -2
- package/dist/chunk-GW2VVH4J.js +0 -2
- package/dist/chunk-I4RIO7H2.js +0 -2
- package/dist/chunk-I6MMPBVA.cjs +0 -2
- package/dist/chunk-MGRWSY3Y.js +0 -2
- package/dist/chunk-T2XGDQM3.cjs +0 -2
- package/dist/chunk-V6LSLSFL.cjs +0 -2
- package/dist/chunk-WUZBSXU3.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
|
|
2
|
-
var _chunkKH57FLSTcjs = require('./chunk-KH57FLST.cjs');var _chunkV6LSLSFLcjs = require('./chunk-V6LSLSFL.cjs');var _chunk46YHIOXGcjs = require('./chunk-46YHIOXG.cjs');var _chunkT2K2NOGZcjs = require('./chunk-T2K2NOGZ.cjs');var _chunk34N36GUDcjs = require('./chunk-34N36GUD.cjs');var _chunkT3I3AJXVcjs = require('./chunk-T3I3AJXV.cjs');var _reactquery = require('@tanstack/react-query');var _react = require('react');function kr(e){if(e.length===0)return 5e3;let l=Math.max(...e.map(s=>_nullishCoalesce(_optionalChain([_chunkT2K2NOGZcjs.c.call(void 0, s), 'optionalAccess', _2 => _2.blockTimeMs]), () => (2e3))));return Math.min(5e3,Math.max(1e3,l*2+1e3))}var Nr=()=>{let{address:e}=_chunk34N36GUDcjs.a.call(void 0, ),t=_chunk46YHIOXGcjs.c.call(void 0, ),r=_reactquery.useQueryClient.call(void 0, ),c=_react.useRef.call(void 0, null),l=_react.useRef.call(void 0, !0),s=_react.useCallback.call(void 0, a=>{if(!e)return;let v=[...new Set(a.tokens.map(d=>d.asset.chainId))],m=kr(v);c.current&&(clearTimeout(c.current),c.current=null),c.current=setTimeout(async()=>{if(c.current=null,!!l.current)try{let d=a.tokens.map(w=>({chainId:w.asset.chainId,tokenAddress:w.asset.address})),o=await _chunkT2K2NOGZcjs.H.call(void 0, e,d);if(o.balances.length===0)return;if(a.tokens.length>=2){let w=a.tokens[0].asset,u=a.tokens[1].asset,h=_chunkT2K2NOGZcjs.I.swap(e,w.chainId,w.address,u.chainId,u.address);r.setQueryData(h,o)}let n=_chunkT2K2NOGZcjs.I.bulk(e,t),y=r.getQueryData(n);if(y){let w=y.balances.map(u=>_nullishCoalesce(o.balances.find(g=>g.chainId===u.chainId&&g.token.toLowerCase()===u.token.toLowerCase()), () => (u)));for(let u of o.balances)w.some(h=>h.chainId===u.chainId&&h.token.toLowerCase()===u.token.toLowerCase())||w.push(u);for(let u of a.tokens)if(!o.balances.some(g=>g.chainId===u.asset.chainId&&g.token.toLowerCase()===u.asset.address.toLowerCase())){let g=w.findIndex(i=>i.chainId===u.asset.chainId&&i.token.toLowerCase()===u.asset.address.toLowerCase());g!==-1&&(w[g]={...w[g],balance:"0",shiftedBalance:"0"})}r.setQueryData(n,{balances:w})}}catch (e2){}},m)},[e,t,r]);return _react.useEffect.call(void 0, ()=>(l.current=!0,()=>{l.current=!1,c.current&&(clearTimeout(c.current),c.current=null)}),[]),{triggerBalanceUpdate:s}},ot=class extends EventTarget{emit(t){this.dispatchEvent(new CustomEvent("balance-update",{detail:t}))}},at=new ot,Oe= exports.b =()=>e=>at.emit(e),is= exports.c =()=>{let{triggerBalanceUpdate:e}=Nr();_react.useEffect.call(void 0, ()=>{let t=r=>{e(r.detail)};return at.addEventListener("balance-update",t),()=>at.removeEventListener("balance-update",t)},[e])};var _viem = require('viem');var _jsxruntime = require('react/jsx-runtime');var Mt=_react.createContext.call(void 0, void 0),Ut=1e4,Ur=3e4,Mr=1e3,Lr=2;function Wr(e){return _nullishCoalesce(e.find(r=>_optionalChain([r, 'access', _3 => _3.routeSteps, 'optionalAccess', _4 => _4[0], 'optionalAccess', _5 => _5.type])==="AORI_V1"), () => (e[0]))}var gs=({children:e,recipient:t})=>{let{address:r}=_chunk34N36GUDcjs.a.call(void 0, ),c=t||r,[l,s]=_react.useState.call(void 0, "idle"),[a,v]=_react.useState.call(void 0, "idle"),[m,d]=_react.useState.call(void 0, null),[o,n]=_react.useState.call(void 0, null),[y,w]=_react.useState.call(void 0, !1),[u,h]=_react.useState.call(void 0, !1),[g,i]=_react.useState.call(void 0, !1),p=_react.useRef.call(void 0, null),x=_react.useRef.call(void 0, null),f=_react.useRef.call(void 0, null),k=_react.useRef.call(void 0, null),P=_react.useRef.call(void 0, null),S=_react.useRef.call(void 0, 0),U=_react.useRef.call(void 0, 0),W=_react.useRef.call(void 0, 0),N=_react.useRef.call(void 0, !1),E=_react.useRef.call(void 0, new Map),I=_react.useCallback.call(void 0, ()=>{f.current&&clearTimeout(f.current),k.current&&clearTimeout(k.current),P.current&&clearTimeout(P.current),f.current=null,k.current=null,P.current=null},[]),M=_react.useCallback.call(void 0, ()=>{I(),p.current=null,S.current=0,s(()=>N.current?"fresh":"idle")},[I]),D=_react.useCallback.call(void 0, ()=>{M(),x.current=null,d(null),n(null),w(!1),h(!1),i(!1),E.current.clear(),s("idle"),v("idle")},[M]),Y=_react.useCallback.call(void 0, C=>{if(!C)return;k.current&&clearTimeout(k.current);let R=Math.max(0,C+Ur-Date.now());k.current=setTimeout(()=>{s($=>$==="idle"?"idle":"stale")},R)},[]),H=_react.useCallback.call(void 0, async(C,R)=>{let{inputToken:$,outputToken:O,inputAmount:z,setOutputAmount:te}=C;if(!$||!O||!z||parseFloat(z)<=0||Date.now()-(U.current||0)<Ut-10)return;let _e=++S.current;try{if(!_optionalChain([$, 'optionalAccess', _6 => _6.decimals])||!_optionalChain([O, 'optionalAccess', _7 => _7.decimals]))return;let G=_chunkT2K2NOGZcjs.F.call(void 0, $.chainId)||_optionalChain([_chunkT2K2NOGZcjs.c.call(void 0, $.chainId), 'optionalAccess', _8 => _8.key])||"",le=_chunkT2K2NOGZcjs.F.call(void 0, O.chainId)||_optionalChain([_chunkT2K2NOGZcjs.c.call(void 0, O.chainId), 'optionalAccess', _9 => _9.key])||"";if(!G||!le)throw new Error("Unknown chain");let re=_viem.parseUnits.call(void 0, z.toString(),$.decimals).toString(),Te={srcChainKey:G,dstChainKey:le,srcTokenAddress:_chunkT2K2NOGZcjs.v.call(void 0, $.address),dstTokenAddress:_chunkT2K2NOGZcjs.v.call(void 0, O.address),amount:re,srcWalletAddress:r||"0x0000000000000000000000000000000000000000",dstWalletAddress:c||r||"0x0000000000000000000000000000000000000000",options:{amountType:"EXACT_SRC_AMOUNT",feeTolerance:{type:"PERCENT",amount:2}}};U.current=Date.now();let ne=await fetch(`${_chunkT2K2NOGZcjs.k.call(void 0, )}/quotes`,{method:"POST",headers:_chunkT2K2NOGZcjs.m.call(void 0, ),body:JSON.stringify(Te),signal:AbortSignal.timeout(15e3)});if(!ne.ok){let Re=await _asyncOptionalChain([(await ne.json().catch(()=>({}))), 'optionalAccess', async _10 => _10.message])||ne.statusText;throw Object.assign(new Error(Re),{status:ne.status})}let oe=await ne.json();if(_e!==S.current||p.current!==R)return;let Ue=_nullishCoalesce(oe.quotes, () => ([])),ue=Wr(Ue);if(!ue)throw Object.assign(new Error("No quotes returned"),{emptyQuotes:!0});let Ze=Number(_viem.formatUnits.call(void 0, _chunkT2K2NOGZcjs.q.call(void 0, ue.dstAmount),O.decimals));typeof te=="function"&&te(Ze),ue._receivedAt=Date.now(),d(ue),n(null),w(!1),s("fresh"),Y(ue._receivedAt),R&&E.current.delete(R)}catch(G){if(_e!==S.current||p.current!==R)return;let le=_optionalChain([G, 'optionalAccess', _11 => _11.status]),re=G instanceof Error?G.message:"",Te=!!_optionalChain([G, 'optionalAccess', _12 => _12.emptyQuotes]);if((le===400||Te||re.includes("Quote request failed"))&&R){let oe=(E.current.get(R)||0)+1;if(E.current.set(R,oe),oe>=Lr){h(!0),I(),p.current=null;return}}if(re.toLowerCase().includes("order cap exceeded")){i(!0),I(),p.current=null;return}if(re.toLowerCase().includes("insufficient executor balance")){w(!0),I(),p.current=null;return}n(G instanceof Error?G.message:"Unknown error")}},[r,c,Y,I]),L=_react.useCallback.call(void 0, (C,R)=>{I(),x.current=C,U.current=0,E.current.delete(R),w(!1),h(!1),i(!1),n(null),s("polling");let $=async()=>{p.current===R&&(await H(C,R),p.current===R&&(f.current=setTimeout($,Ut)))};$()},[I,H]),T=_react.useCallback.call(void 0, C=>{if(!_optionalChain([C, 'optionalAccess', _13 => _13.inputToken])||!_optionalChain([C, 'optionalAccess', _14 => _14.outputToken])||!_optionalChain([C, 'optionalAccess', _15 => _15.inputAmount])||parseFloat(C.inputAmount)<=0){M();return}let R=x.current;if(R&&_optionalChain([R, 'access', _16 => _16.inputToken, 'optionalAccess', _17 => _17.address])===_optionalChain([C, 'access', _18 => _18.inputToken, 'optionalAccess', _19 => _19.address])&&_optionalChain([R, 'access', _20 => _20.inputToken, 'optionalAccess', _21 => _21.chainId])===_optionalChain([C, 'access', _22 => _22.inputToken, 'optionalAccess', _23 => _23.chainId])&&_optionalChain([R, 'access', _24 => _24.outputToken, 'optionalAccess', _25 => _25.address])===_optionalChain([C, 'access', _26 => _26.outputToken, 'optionalAccess', _27 => _27.address])&&_optionalChain([R, 'access', _28 => _28.outputToken, 'optionalAccess', _29 => _29.chainId])===_optionalChain([C, 'access', _30 => _30.outputToken, 'optionalAccess', _31 => _31.chainId])&&R.inputAmount===C.inputAmount&&p.current)return;let O=Date.now();if(O-W.current<100)return;W.current=O;let z=`${Date.now()}-${Math.random().toString(36).slice(2)}`;p.current=z,L(C,z)},[L,M]),F=_react.useCallback.call(void 0, ({amount:C,inputToken:R,outputToken:$,setOutputAmount:O})=>{O(null),P.current&&clearTimeout(P.current),!C||C===0?(v("idle"),M(),d(null),n(null),w(!1),h(!1),i(!1)):(v("typing"),M(),d(null),w(!1),h(!1),i(!1),n(null),P.current=setTimeout(()=>{v("settled"),R&&$&&C>0&&T({inputToken:R,outputToken:$,inputAmount:C.toString(),setOutputAmount:O})},Mr))},[M,T]),B=_react.useCallback.call(void 0, ()=>{let C=x.current;if(!C)return;d(null);let R=`${Date.now()}-${Math.random().toString(36).slice(2)}`;p.current=R,s("refreshing"),typeof C.setOutputAmount=="function"&&C.setOutputAmount(null),L(C,R)},[L]);_react.useEffect.call(void 0, ()=>{N.current=!!m},[m]),_react.useEffect.call(void 0, ()=>()=>I(),[I]);let J=_react.useMemo.call(void 0, ()=>({status:l,inputState:a,rfqQuote:m,error:o,liquidityError:y,routingError:u,sizeCapError:g,ensureForParams:T,stop:M,refresh:B,clear:D,handleInputChange:F}),[l,a,m,o,y,u,g,T,M,B,D,F]);return _jsxruntime.jsx.call(void 0, Mt.Provider,{value:J,children:e})},Be= exports.e =()=>{let e=_react.useContext.call(void 0, Mt);if(e===void 0)throw new Error("useRfq must be used within an RfqProvider");return e};var Fr=_react.createContext.call(void 0, {openConnectModal:()=>{}}),ys= exports.g =()=>_react.useContext.call(void 0, Fr);var Br=20,qr=({side:e,asset:t,otherAsset:r,isPlacingOrder:c,isWrappingPair:l,isUnwrappingPair:s})=>{let{baseAmount:a,quoteAmount:v,setBaseAmount:m,setQuoteAmount:d}=_chunkV6LSLSFLcjs.f.call(void 0, ),{amountInputVariant:o,hideAmountInputSymbol:n,widgetType:y}=_chunk46YHIOXGcjs.b.call(void 0, ),w=y==="compact",[u,h]=e==="base"?[m,d]:[d,m],g=!t||e==="quote"||c,i=w?32:o==="default"?64:32,[p,x]=_react.useState.call(void 0, i),[f,k]=_react.useState.call(void 0, ""),P=_react.useRef.call(void 0, null),S=_react.useRef.call(void 0, null),U=_react.useRef.call(void 0, null),W=_react.useRef.call(void 0, null),N="USD",E=e==="base"?a:v,[I,M]=_react.useState.call(void 0, !1),D=_react.useCallback.call(void 0, ()=>{if(o!=="default"){x(i);return}if(!P.current||!S.current||!U.current)return;let L=P.current.offsetWidth,T=20,F=i;for(;F>20&&(S.current.style.fontSize=`${F}px`,U.current.style.fontSize=`${F}px`,!(S.current.offsetWidth+U.current.offsetWidth+T<=L));)F-=1;x(F)},[o,i]),Y=_react.useCallback.call(void 0, L=>{L.key==="."&&f.includes(".")&&L.preventDefault()},[f]),H=_react.useCallback.call(void 0, L=>{let T=L.target.value;if(T==="."&&(T="0."),!/^\d*\.?\d*$/.test(T)||(T.match(/\./g)||[]).length>1)return;if(T.length>1&&T[0]==="0"&&T[1]!=="."&&(T=T.replace(/^0+/,"")||"0"),_optionalChain([t, 'optionalAccess', _32 => _32.decimals])!==void 0&&T.includes(".")){let[,B]=T.split(".");if(B&&B.length>t.decimals)return}if(T.length>Br)return;k(T);let F=parseFloat(T);T!==f&&(T===""||T==="0."||T.endsWith(".")?(u(null),e==="base"&&h(null)):!Number.isNaN(F)&&F>=0&&u(F),e==="base"&&d(null),(s||l)&&d(F||0))},[f,u,e,d,_optionalChain([t, 'optionalAccess', _33 => _33.decimals]),h,s,l]);return _react.useEffect.call(void 0, ()=>{let L=B=>{if(B===null)return"";let J=_optionalChain([t, 'optionalAccess', _34 => _34.decimals]);if(J===void 0)return"";let C=B.toString();if(/e/i.test(C)&&(C=Number(B).toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:J})),C.includes(".")){let[R,$]=C.split("."),O=$.slice(0,J);return O?`${R}.${O}`:R}return C};if(E===null){f==="0."||f!==""&&f.endsWith(".")||k("");return}if(!g&&(f.endsWith(".")||f.match(/\.\d*0$/)||f==="0"||f==="0.")&&f!=="")return;let F=parseFloat(f)||0;(f===""||Math.abs(F-E)>1e-10)&&k(L(E))},[E,_optionalChain([t, 'optionalAccess', _35 => _35.decimals]),f,g]),_react.useEffect.call(void 0, ()=>{D()},[f,D]),_react.useEffect.call(void 0, ()=>{M(!0)},[]),_react.useEffect.call(void 0, ()=>{I&&D()},[I,D]),_react.useEffect.call(void 0, ()=>{S.current&&W.current&&(W.current.style.width=`${S.current.offsetWidth}px`)},[f]),_react.useEffect.call(void 0, ()=>{if(!I)return;let L=new ResizeObserver(()=>{I&&D()});return P.current&&L.observe(P.current),()=>L.disconnect()},[I,D]),_jsxruntime.jsx.call(void 0, "div",{ref:P,style:{fontSize:`${p}px`,transition:"font-size 0.05s ease-in-out"},className:`mt-2 box-border font-sans flex ${w?o==="normal"?"h-12 my-1":"h-10 my-0.5":o==="normal"?"h-12 my-1":"h-20 my-1"} w-full flex-row items-center ${g?"cursor-default":"cursor-text"}`,onClick:()=>_optionalChain([W, 'access', _36 => _36.current, 'optionalAccess', _37 => _37.focus, 'call', _38 => _38()]),children:_jsxruntime.jsxs.call(void 0, "div",{className:"relative flex w-full items-center",children:[_jsxruntime.jsx.call(void 0, "label",{htmlFor:`${e}Amount`,className:"sr-only",children:e==="base"?"Input token amount":"Output token amount"}),_jsxruntime.jsx.call(void 0, "input",{ref:W,type:"text",inputMode:"decimal",placeholder:"0",autoComplete:"off",id:`${e}Amount`,value:f,onWheel:L=>L.target.blur(),onKeyDown:Y,onChange:H,style:{transition:"width 0.15s ease-in-out",color:"var(--widget-foreground)",WebkitTextFillColor:"var(--widget-foreground)",opacity:1},className:"flex min-w-[45px] whitespace-nowrap bg-transparent placeholder:opacity-50 font-sans font-thin",disabled:g}),_jsxruntime.jsx.call(void 0, "span",{style:{transition:"width 0.15s ease-in-out"},ref:S,className:"pointer-events-none absolute flex whitespace-nowrap invisible",children:f||0}),!n&&o!=="normal"&&_jsxruntime.jsx.call(void 0, "span",{ref:U,className:"ml-2 font-thin uppercase",style:{color:"var(--widget-foreground)",opacity:.5,fontSize:`${p}px`},children:_optionalChain([t, 'optionalAccess', _39 => _39.symbol])?t.symbol.length>6?`${t.symbol.slice(0,6)}...`:t.symbol:N}),(n||o==="normal")&&_jsxruntime.jsx.call(void 0, "span",{ref:U,className:"hidden"})]})})},Rs= exports.h =qr;var Qr=({toggle:e,side:t,asset:r,isPlacingOrder:c,hideDropdown:l})=>{let{baseBalance:s,quoteBalance:a}=_chunkV6LSLSFLcjs.f.call(void 0, ),{tokenDisplay:v,tokenBadgeOrientation:m,widgetType:d}=_chunk46YHIOXGcjs.b.call(void 0, ),o=d==="compact",n=o?"h-10":"h-11",y=o?"h-10 w-10":"h-11 w-11",w=t==="base"?s.formatted?(()=>{let h=parseFloat(s.formatted);return h>=1e8?_chunkT2K2NOGZcjs.o.call(void 0, h):h.toFixed(3)})():void 0:a.formatted?(()=>{let h=parseFloat(a.formatted);return h>=1e8?_chunkT2K2NOGZcjs.o.call(void 0, h):h.toFixed(3)})():void 0,u={role:"button",tabIndex:c?-1:0,"aria-disabled":c,"aria-label":`Select ${t==="base"?"input":"output"} token${r?`: ${r.symbol}`:""}`,onClick:c?void 0:e,onKeyDown:c?void 0:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),e())}};return v==="pill"?_jsxruntime.jsx.call(void 0, "div",{...u,className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-full cursor-pointer transition-colors ${m==="right"?"ml-auto":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-secondary)",color:"var(--widget-secondary-foreground)"},children:r?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.M,{chain:r.chainId,size:"xs"}),_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.N,{className:"rounded-full",asset:r,size:"xxs",noChain:!0}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs font-thin uppercase",children:r.symbol}),!l&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.T,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-xs opacity-70",children:"Select"}),!l&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.T,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]})}):v==="ghost"?_jsxruntime.jsxs.call(void 0, "div",{...u,className:"inline-flex items-center gap-1.5 cursor-pointer transition-opacity hover:opacity-70 py-1",style:{color:"var(--widget-foreground)"},children:[r?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.M,{chain:r.chainId,size:"xs"}),_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.N,{className:"rounded-full",asset:r,size:"xxs",noChain:!0}),_jsxruntime.jsx.call(void 0, "span",{className:"text-sm font-thin uppercase",children:r.symbol})]}):_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Select token"}),!l&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.T,{className:"w-1.5 opacity-50"})]}):_jsxruntime.jsx.call(void 0, "div",{...u,className:`relative ${n} w-full cursor-pointer text-xl duration-100 ease-linear`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-secondary)",borderTopLeftRadius:"9999px",borderBottomLeftRadius:"9999px",borderTopRightRadius:"var(--widget-radius)",borderBottomRightRadius:"var(--widget-radius)"},children:_jsxruntime.jsx.call(void 0, "div",{className:"relative flex h-full w-full flex-row items-center",children:r?_jsxruntime.jsxs.call(void 0, "div",{className:"relative flex h-full w-full flex-row items-center",children:[_jsxruntime.jsx.call(void 0, "div",{className:`${y} pl-px flex items-center justify-center`,children:_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.N,{className:"rounded-full",asset:r,size:"md"})}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full w-full flex-row items-center justify-between pl-1.5 pr-7",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full flex-col justify-center",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-thin uppercase",style:{color:"var(--widget-secondary-foreground)"},children:r.symbol}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-2xs font-sans",style:{color:"var(--widget-muted-foreground)"},children:[_optionalChain([r, 'access', _40 => _40.address, 'optionalAccess', _41 => _41.slice, 'call', _42 => _42(0,6)]),"...",_optionalChain([r, 'access', _43 => _43.address, 'optionalAccess', _44 => _44.slice, 'call', _45 => _45(-4)])]})]}),w!==void 0&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col text-right",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Balance"}),_jsxruntime.jsx.call(void 0, "span",{className:"font-sans text-xs tabular-nums",style:{color:"var(--widget-foreground)",opacity:.5},children:w})]})]}),!l&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.T,{className:"absolute right-3 top-1/2 w-1.5 translate-y-[-50%]",style:{color:"var(--widget-secondary-foreground)",opacity:.6}})]}):_jsxruntime.jsx.call(void 0, "div",{className:"flex h-full w-full items-center justify-center",children:_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",style:{color:"var(--widget-secondary-foreground)",opacity:.7},children:"Select token"})})})})},Os= exports.i =Qr;var Wt=_chunkT3I3AJXVcjs.b.call(void 0, _chunkKH57FLSTcjs.a.call(void 0, ),1);var jr=()=>{let[e,t]=_react.useState.call(void 0, null),[r,c]=_react.useState.call(void 0, ""),l=_chunkT2K2NOGZcjs.x.call(void 0, r,1e3),[s,a]=_react.useState.call(void 0, !1),[v,m]=_react.useState.call(void 0, "");_react.useEffect.call(void 0, ()=>{_chunkV6LSLSFLcjs.c.getState().setRecipient(e)},[e]),_react.useEffect.call(void 0, ()=>{c(e||"")},[e]);let d=n=>{let y=n.target.value;s&&(a(!1),m(""),t(null)),c(y),y===""&&t(null)};_react.useEffect.call(void 0, ()=>{l===""||!l?(a(!1),m(""),t(null)):_chunkT2K2NOGZcjs.w.call(void 0, l)?(a(!1),m(""),t(l)):(a(!0),m("Invalid wallet address..."),t(null),c(""))},[l]),_react.useEffect.call(void 0, ()=>{if(s){let n=setTimeout(()=>{t(null),c(""),a(!1),m("")},2e3);return()=>clearTimeout(n)}},[s]);let o=()=>{t(null),c(""),a(!1),m("")};return _jsxruntime.jsx.call(void 0, "div",{className:"w-full",children:_jsxruntime.jsxs.call(void 0, "div",{className:"relative flex flex-row items-center",children:[_jsxruntime.jsx.call(void 0, "input",{type:"password",style:{display:"none"},"aria-hidden":"true",tabIndex:-1}),_jsxruntime.jsx.call(void 0, "label",{htmlFor:"recipient-address",className:"sr-only",children:"Recipient wallet address"}),_jsxruntime.jsx.call(void 0, "div",{className:"absolute left-3 flex h-6 w-6 items-end justify-center overflow-hidden rounded-full",style:{backgroundColor:"var(--widget-secondary)"},children:e&&!s?_jsxruntime.jsx.call(void 0, "img",{className:"h-full w-full rounded-full object-cover",src:(0,Wt.makeGradient)(e),alt:"Recipient avatar"}):_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.S,{className:"h-5 w-5",style:{color:s?"var(--widget-destructive)":"var(--widget-muted-foreground)"}})}),_jsxruntime.jsx.call(void 0, "div",{className:"absolute left-12 top-1.5 -translate-y-1 text-xs font-medium opacity-60",style:{color:s?"var(--widget-destructive)":"var(--widget-muted-foreground)"},"aria-hidden":"true",children:"To:"}),_jsxruntime.jsx.call(void 0, "input",{id:"recipient-address",className:"font-sans block h-10 w-full items-center pl-12 pt-4 pr-8 text-xs",style:{backgroundColor:s?"color-mix(in srgb, var(--widget-destructive) 10%, transparent)":"transparent",color:s?"var(--widget-destructive)":"var(--widget-foreground)",outline:"none",opacity:s?.9:1},placeholder:s?v:"Enter recipient address...",value:r,onChange:d,spellCheck:!1,"aria-invalid":s,"aria-describedby":s?"recipient-error":void 0}),s&&_jsxruntime.jsx.call(void 0, "span",{id:"recipient-error",className:"sr-only",children:v}),e&&!s&&_jsxruntime.jsxs.call(void 0, "button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 cursor-pointer flex items-center justify-center h-4 w-4 rounded-full transition-colors hover:[color:var(--widget-destructive)]",style:{color:"var(--widget-muted-foreground)"},onClick:o,"aria-label":"Clear recipient",children:[_jsxruntime.jsx.call(void 0, "svg",{className:"h-2.5 w-2.5",viewBox:"0 -0.5 21 21",fill:"none",children:_jsxruntime.jsx.call(void 0, "g",{fill:"currentColor",fillRule:"evenodd",children:_jsxruntime.jsx.call(void 0, "polygon",{points:"375.0183 90 384 98.554 382.48065 100 373.5 91.446 364.5183 100 363 98.554 371.98065 90 363 81.446 364.5183 80 373.5 88.554 382.48065 80 384 81.446",transform:"translate(-363 -80)"})})}),_jsxruntime.jsx.call(void 0, "span",{className:"sr-only",children:"Clear recipient"})]})]})})},Ds= exports.j =jr;function Fs(e){return _jsxruntime.jsxs.call(void 0, "svg",{width:"485",height:"484",viewBox:"0 0 485 484",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[_jsxruntime.jsx.call(void 0, "path",{d:"M265.974 52.8127C270.567 50.9299 273.227 53.6338 275.917 56.1595C301.879 80.5364 327.828 104.927 353.786 129.308C380.101 154.024 406.44 178.715 432.721 203.467C436.002 206.557 440.744 209.272 438.226 215.021C435.865 220.415 430.758 219.123 426.424 219.124C305.965 219.169 185.506 219.163 65.0464 219.166C53.0995 219.166 49.0676 215.225 49.0125 203.316C48.9563 191.154 48.9813 178.991 48.9973 166.829C49.0119 155.717 53.3581 151.358 64.4131 151.358C127.892 151.357 191.37 151.364 254.849 151.368C262.591 151.368 262.645 151.344 262.588 143.559C262.388 116.237 262.191 88.914 261.918 61.5922C261.883 58.0834 262.161 54.9042 265.974 52.8127Z",fill:"currentColor"}),_jsxruntime.jsx.call(void 0, "path",{d:"M80.5649 300.432C71.3447 291.747 62.4175 283.264 53.4064 274.87C50.4552 272.122 47.8959 269.327 49.7894 264.946C51.6154 260.72 55.4624 260.923 59.1682 260.923C164.476 260.927 269.785 260.932 375.093 260.935C391.422 260.935 407.752 260.9 424.081 260.933C434.679 260.955 438.994 265.286 439.015 275.854C439.04 288.517 439.048 301.181 439.013 313.845C438.985 324.225 434.466 328.73 424.01 328.732C360.359 328.741 296.707 328.729 233.056 328.714C225.392 328.713 225.368 328.686 225.426 336.583C225.628 363.741 225.815 390.9 226.101 418.057C226.142 421.935 225.905 425.512 221.852 427.329C217.686 429.197 214.934 426.578 212.212 424.02C172.068 386.302 131.922 348.587 91.7738 310.874C88.1374 307.459 84.4753 304.07 80.5649 300.432Z",fill:"currentColor"})]})}var Gr=["SUCCEEDED","FAILED","COMPLETED","CANCELLED"];async function Vt(e,t,r={}){let{onStatusChange:c,onComplete:l,onError:s,interval:a=4e3,timeout:v=3e5,txHash:m,signal:d}=r,o=null,n=Date.now(),y=0,w=8,u=null,h=m?`?txHash=${m}`:"";return new Promise((g,i)=>{let p=async()=>{try{if(_optionalChain([d, 'optionalAccess', _46 => _46.aborted])){u&&clearTimeout(u),i(new DOMException("Polling aborted","AbortError"));return}if(Date.now()-n>v){u&&clearTimeout(u);let P=new Error("Order status polling timed out");_optionalChain([s, 'optionalCall', _47 => _47(P)]),i(P);return}let x=await fetch(`${t}/status/${e}${h}`,{headers:_chunkT2K2NOGZcjs.m.call(void 0, ),signal:d});if(x.status===404){u=setTimeout(p,a);return}if(!x.ok)throw new Error(`Failed to fetch order status: ${await x.text()}`);let f=await x.json();if(!f||typeof f!="object"||!f.status)throw new Error(`Invalid status response format: ${JSON.stringify(f)}`);y=0;let k=f.status.toUpperCase();if(k!==o&&(o=k,_optionalChain([c, 'optionalCall', _48 => _48(f)])),Gr.includes(k)){u&&clearTimeout(u),_optionalChain([l, 'optionalCall', _49 => _49(f)]),g(f);return}u=setTimeout(p,a)}catch(x){if(x instanceof Error&&x.name==="AbortError"){u&&clearTimeout(u),i(x);return}if(++y>=w){u&&clearTimeout(u);let f=x instanceof Error?x:new Error(String(x));_optionalChain([s, 'optionalCall', _50 => _50(f)]),i(f);return}u=setTimeout(p,a)}};p()})}function _t(e){let t=e.toUpperCase();return t==="SUCCEEDED"||t==="COMPLETED"?"completed":t==="FAILED"?"failed":t==="CANCELLED"?"cancelled":t==="PROCESSING"?"received":"pending"}var Ft=e=>{let t=_react.useRef.call(void 0, new Map),r=_react.useRef.call(void 0, new Map),c=_react.useRef.call(void 0, new Map),l=_react.useRef.call(void 0, 0),s=_react.useCallback.call(void 0, ()=>++l.current,[]),{address:a}=_chunk34N36GUDcjs.a.call(void 0, ),v=Oe(),m=_react.useCallback.call(void 0, (n,y)=>{if(t.current.get(n))return;y&&r.current.set(n,y),t.current.set(n,!0);let w=l.current,u=new AbortController;c.current.set(n,u);let h=_optionalChain([y, 'optionalAccess', _51 => _51.baseToken, 'optionalAccess', _52 => _52.chainId])===1;Vt(n,_chunkT2K2NOGZcjs.k.call(void 0, ),{interval:h?1e3:500,timeout:3e5,signal:u.signal,onStatusChange:g=>{if(!_optionalChain([g, 'optionalAccess', _53 => _53.status]))return;let i=_t(g.status);if(_optionalChain([e, 'optionalCall', _54 => _54(n,i,g.explorerUrl)]),i==="completed"&&a){let p=r.current.get(n);if(p&&(p.baseToken||p.quoteToken)){let x=[];p.baseToken&&x.push({asset:p.baseToken,userAddress:a}),p.quoteToken&&x.push({asset:p.quoteToken,userAddress:a}),v({type:"swap",tokens:x})}}["completed","failed","cancelled"].includes(i)&&(t.current.delete(n),r.current.delete(n)),w!==l.current&&(t.current.delete(n),r.current.delete(n))},onComplete:g=>{_optionalChain([g, 'optionalAccess', _55 => _55.status])&&_optionalChain([e, 'optionalCall', _56 => _56(n,_t(g.status),g.explorerUrl)]),t.current.delete(n),r.current.delete(n)},onError:()=>{t.current.delete(n),r.current.delete(n)}}).catch(g=>{g instanceof Error&&g.name==="AbortError"||(t.current.delete(n),r.current.delete(n),c.current.delete(n))})},[a,v,e]),d=_react.useCallback.call(void 0, n=>{let y=c.current.get(n);y&&(y.abort(),c.current.delete(n)),s(),t.current.delete(n),r.current.delete(n)},[s]),o=_react.useCallback.call(void 0, ()=>{for(let n of c.current.values())n.abort();c.current.clear(),s(),t.current.clear(),r.current.clear()},[s]);return _react.useEffect.call(void 0, ()=>()=>o(),[o]),{startPolling:m,stopPolling:d,stopAllPolling:o,isPolling:n=>t.current.has(n)}};var Jr=_react.createContext.call(void 0, {registerTransaction:()=>{},enabled:!1}),Bt= exports.n =()=>_react.useContext.call(void 0, Jr);var _actions = require('viem/actions');function zt(e){return e instanceof Error?e.name==="UserRejectedRequestError"||e.message.includes("User rejected")||e.message.includes("rejected")||e.message.includes("denied")||e.message.includes("cancelled")||e.message.includes("canceled"):!1}async function qt(e){if(_optionalChain([e, 'access', _57 => _57.chain, 'optionalAccess', _58 => _58.id]))return e.chain.id;let t=_optionalChain([e, 'access', _59 => _59.getChainId, 'optionalCall', _60 => _60()]);return t!=null?await t:null}var en=async(e,t)=>{try{if(await qt(e)===t)return!0;if(e.request)await e.request({method:"wallet_switchEthereumChain",params:[{chainId:`0x${t.toString(16)}`}]});else if(e.switchChain)await e.switchChain({id:t});else if(e.send)await e.send("wallet_switchEthereumChain",[{chainId:`0x${t.toString(16)}`}]);else throw new Error("Wallet doesn't support chain switching");return await qt(e)===t}catch(r){throw zt(r)?new Error("User rejected the chain switch request"):new Error(`Please switch your wallet to the required network (Chain ID: ${t})`)}},Qt= exports.p =async e=>{let{quote:t,signatureStep:r,userAddress:c,walletClient:l}=e;if(!l)throw new Error("Wallet client not available");if(r.type!=="SIGNATURE"||!_optionalChain([r, 'access', _61 => _61.signature, 'optionalAccess', _62 => _62.typedData]))throw new Error("Invalid signature step");try{let s=r.signature.typedData,a={...s.message};for(let o of["inputAmount","outputAmount","startTime","endTime"])a[o]!=null&&(a[o]=BigInt(a[o]));let v=s.domain;if(v.chainId!=null){let o=Number(v.chainId);await en(l,o)}let m=await _actions.signTypedData.call(void 0, l,{account:c,domain:v,types:s.types,primaryType:s.primaryType,message:a}),d=await fetch(`${_chunkT2K2NOGZcjs.k.call(void 0, )}/submit-signature`,{method:"POST",headers:_chunkT2K2NOGZcjs.m.call(void 0, ),body:JSON.stringify({quoteId:t.id,signatures:[m]})});if(!d.ok){let o=await d.json().catch(()=>({}));throw new Error(_optionalChain([o, 'optionalAccess', _63 => _63.message])||`Submit failed: ${d.status}`)}return{quoteId:t.id,signature:m}}catch(s){throw zt(s)?new Error("User rejected the signing request"):s instanceof Error&&s.message.includes("chain")?new Error("Chain switching failed. Please manually switch to the correct network."):s}};var jt="vt_submitted_quotes";var ut=()=>{try{let e=localStorage.getItem(jt);return e?JSON.parse(e):[]}catch (e3){return[]}},Ht=e=>{try{localStorage.setItem(jt,JSON.stringify(e))}catch (e4){}},tn= exports.q =e=>{let t=Date.now(),r=typeof e=="string"?new Date(e).getTime():e>9999999999?e:e*1e3;return t<r+3e4},rn=e=>ut().some(t=>t.quoteId===e),Gt= exports.r =(e,t)=>rn(e)?{canSubmit:!1,reason:"Order already submitted"}:tn(t)?{canSubmit:!0}:{canSubmit:!1,reason:"Quote has expired"},Kt= exports.s =(e,t)=>{let r=typeof t=="string"?new Date(t).getTime():t,c=ut();c.push({quoteId:e,submittedAt:Date.now(),createdAt:r}),Ht(c)},Xt= exports.t =()=>{let e=ut(),t=Date.now(),r=300*1e3,c=e.filter(l=>t-l.submittedAt<r);c.length!==e.length&&Ht(c)};var _core = require('@wagmi/core');var _abis = require('abitype/abis');var _wagmi = require('wagmi');function Yt(){let e=_wagmi.useConfig.call(void 0, );return _reactquery.useMutation.call(void 0, {mutationFn:async({chainId:t,accountAddress:r,amountRaw:c,writeContractAsync:l})=>{let s=_chunkT2K2NOGZcjs.c.call(void 0, t);if(!s)throw new Error(`No wrapping contract for chain ${t}`);let a=s.wrappedAsset.address,v=await l({abi:_abis.wethAbi,functionName:"withdraw",address:a,account:r,args:[c],chainId:t});if((await _core.waitForTransactionReceipt.call(void 0, e,{hash:v,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Unwrap transaction did not get successful receipt");return{success:!0,hash:v}}})}function Jt(){let e=_wagmi.useConfig.call(void 0, );return _reactquery.useMutation.call(void 0, {mutationFn:async({chainId:t,accountAddress:r,amountRaw:c,writeContractAsync:l})=>{let s=_chunkT2K2NOGZcjs.c.call(void 0, t);if(!s)throw new Error(`No wrapping contract for chain ${t}`);let a=s.wrappedAsset.address,v=await l({abi:_abis.wethAbi,functionName:"deposit",address:a,account:r,value:c,chainId:t});if((await _core.waitForTransactionReceipt.call(void 0, e,{hash:v,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Wrap transaction did not get successful receipt");return{success:!0,hash:v}}})}function er(){let{registerTransaction:e,enabled:t}=Bt(),r=_react.useRef.call(void 0, new Set),c=_react.useCallback.call(void 0, (s,a)=>{!t||r.current.has(s)||(r.current.add(s),e(s,a))},[t,e]),l=_react.useCallback.call(void 0, (s,a)=>{!t||r.current.has(s)||(r.current.add(s),e(s,a))},[t,e]);return{trackOrderTransaction:c,trackNativeTransaction:l,txTrackingEnabled:t}}var hn=15e3,Ge="chain",vn=({needsChainSwitch:e,requiredChain:t,reviewState:r,goToNextStep:c,cancel:l})=>{let s=_chunkT2K2NOGZcjs.r.call(void 0, Ge,r),[a,v]=_react.useState.call(void 0, "pending"),m=_react.useRef.call(void 0, !1),d=_react.useRef.call(void 0, !1),o=_react.useRef.call(void 0, null),n=_wagmi.useChainId.call(void 0, ),{switchChainAsync:y}=_wagmi.useSwitchChain.call(void 0, ),{status:w,isReconnecting:u}=_wagmi.useAccount.call(void 0, ),h=_react.useCallback.call(void 0, ()=>{o.current&&(clearTimeout(o.current),o.current=null)},[]),g=_react.useCallback.call(void 0, async()=>{if(!(m.current||d.current||w!=="connected"||u)){m.current=!0,d.current=!0,v("pending"),o.current=setTimeout(()=>{m.current&&(v("error"),m.current=!1)},hn);try{await y({chainId:t.chainId}),h(),v("success"),c(Ge,r)}catch (e5){h(),v("error")}finally{m.current=!1}}},[y,w,u,t.chainId,c,r,h]);_react.useEffect.call(void 0, ()=>{m.current||d.current||r===Ge&&a==="pending"&&w==="connected"&&!u&&(e&&n!==t.chainId?g():(v("success"),c(Ge,r)))},[r,a,e,n,t.chainId,w,u,g,c]),_react.useEffect.call(void 0, ()=>()=>h(),[h]);let i=()=>{a==="error"&&(d.current=!1,v("pending"))},p=!s&&a==="error",x=!s&&(a==="pending"||a==="error"),f=p?"var(--widget-status-failed)":"var(--widget-primary)";return _jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full flex-row justify-between space-x-3",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${p?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${f} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${f} 20%, transparent)`,color:f,borderRadius:"var(--widget-radius)"},onClick:p?i:void 0,children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.M,{chain:t.chainId,size:"xs"}),_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-nowrap",children:p?"Retry Switch":`Switch to ${t.name}`}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!s&&a==="pending"&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.U,{size:"5"}),(s||a==="success")&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.O,{className:"h-8 w-8"}),p&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.R,{className:"h-[12px] w-[12px]"})]})]})}),x&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-sans font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:l,children:"Cancel"})]})},nr=vn;var yn=({startTime:e,onExpired:t})=>{let[r,c]=_react.useState.call(void 0, 30),[l,s]=_react.useState.call(void 0, !1),a=_react.useRef.call(void 0, !1),v=_react.useRef.call(void 0, t);v.current=t,_react.useEffect.call(void 0, ()=>{a.current=!1},[e]),_react.useEffect.call(void 0, ()=>{let d=()=>{let n=Date.now(),w=(e>9999999999?e:e*1e3)+30*1e3,u=Math.max(0,w-n),h=Math.floor(u/1e3);if(h<=0){c(0),a.current||(a.current=!0,s(!0),v.current());return}c(h),s(!1)};if(l)return;d();let o=setInterval(d,1e3);return()=>clearInterval(o)},[e,l]);let m=d=>{let o=Math.floor(d/60),n=d%60;return`${o.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`};return l?null:_jsxruntime.jsx.call(void 0, "span",{className:"text-xs font-sans",children:m(r)})},ir=yn;function Nn(e){return e.name==="UserRejectedRequestError"||e.message.includes("User rejected")||e.message.includes("rejected")||e.message.includes("denied")||e.message.includes("cancelled")||e.message.includes("canceled")}var ye="signingOrder";async function En(e,t,r,c,l){let s=_optionalChain([e, 'access', _64 => _64.transaction, 'optionalAccess', _65 => _65.encoded]),a=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _66 => _66.to]), () => (e.to)),v=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _67 => _67.data]), () => (e.data)),m=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _68 => _68.value]), () => (e.value));if(!a)throw new Error('Transaction step missing "to" address');let d=_optionalChain([s, 'optionalAccess', _69 => _69.chainId]),o=e.chainKey||l,n=d||(o?_chunkT2K2NOGZcjs.E.call(void 0, o):void 0);if(!n)throw new Error(`Unknown chain: ${o}`);let y=_chunkT2K2NOGZcjs.h.call(void 0, )[n],w=await r({account:t,chain:y,to:a,data:v||"0x",value:BigInt(m||"0")});return await _core.waitForTransactionReceipt.call(void 0, c,{hash:w,chainId:n}),w}var In=({base:e,baseAmount:t,quote:r,quoteAmount:c,userAddress:l,reviewState:s,goToNextStep:a,cancel:v,isWrappingPair:m,isUnwrappingPair:d,restartSigningFlow:o,onSwapInitiated:n,onOrderSubmitted:y,onSwapComplete:w,startPolling:u,trackNativeTransaction:h})=>{let g=_chunkT2K2NOGZcjs.r.call(void 0, ye,s),[i,p]=_react.useState.call(void 0, "idle"),x=_react.useRef.call(void 0, !1),f=_react.useRef.call(void 0, null),k=_wagmi.useConfig.call(void 0, ),{isReconnecting:P}=_wagmi.useAccount.call(void 0, ),{rfqQuote:S,stop:U,refresh:W}=Be(),{data:N}=_wagmi.useWalletClient.call(void 0, {chainId:e.chainId}),{switchChain:E}=_wagmi.useSwitchChain.call(void 0, ),{sendTransactionAsync:I}=_wagmi.useSendTransaction.call(void 0, ),M=_nullishCoalesce(_optionalChain([S, 'optionalAccess', _70 => _70._receivedAt]), () => (0)),D=_react.useCallback.call(void 0, ()=>M?Date.now()>=M+30*1e3:!1,[M]),Y=_react.useCallback.call(void 0, async()=>{if(x.current||!["idle","error"].includes(i))return;if(!_optionalChain([S, 'optionalAccess', _71 => _71.id])||!_optionalChain([S, 'optionalAccess', _72 => _72._receivedAt])){p("error");return}if(!Gt(S.id,S._receivedAt).canSubmit){p("stale");return}x.current=!0;try{if(!N)throw new Error("Wallet client not available");Xt();let R=_nullishCoalesce(S.userSteps, () => ([])),$;for(let O of R)if(O.type==="TRANSACTION"){p("submitting");let z=O.chainKey||S.srcChainKey,te=z?_chunkT2K2NOGZcjs.E.call(void 0, z):void 0;te&&_optionalChain([N, 'access', _73 => _73.chain, 'optionalAccess', _74 => _74.id])!==te&&(await E({chainId:te}),await new Promise(Ve=>setTimeout(Ve,800))),$=await En(O,l,I,k,S.srcChainKey),h($,O.description||`Tx on ${z}`)}else O.type==="SIGNATURE"&&(p("signing"),await Qt({quote:S,signatureStep:O,userAddress:l,walletClient:N}));Kt(S.id,S._receivedAt),_optionalChain([y, 'optionalCall', _75 => _75(S.id)]),u(S.id,{baseToken:e,quoteToken:r}),_optionalChain([n, 'optionalCall', _76 => _76()]),U(),p("success"),a(ye,s),_optionalChain([w, 'optionalCall', _77 => _77(S.id)])}catch(R){R instanceof Error&&Nn(R),p("error")}finally{x.current=!1}},[i,S,N,e,r,l,U,u,a,s,w,E,I,n,y,h,k]);_react.useEffect.call(void 0, ()=>{if(s===ye&&U(),g&&i!=="success"){p("success"),a(ye,s);return}if(i==="success"){a(ye,s);return}if(s===ye&&i==="idle"&&!_optionalChain([S, 'optionalAccess', _78 => _78.id])){p("refreshingQuote"),W();return}if(s===ye&&i==="idle"&&N&&!x.current&&!P){let C=_optionalChain([S, 'optionalAccess', _79 => _79.id])||null;C&&f.current!==C&&(f.current=C,Y())}},[g,s,i,N,P,Y,a,_optionalChain([S, 'optionalAccess', _80 => _80.id]),W,U]),_react.useEffect.call(void 0, ()=>{i==="refreshingQuote"&&_optionalChain([S, 'optionalAccess', _81 => _81.id])&&p("idle")},[i,_optionalChain([S, 'optionalAccess', _82 => _82.id])]),_react.useEffect.call(void 0, ()=>{s!==ye&&(f.current=null)},[s]),_react.useEffect.call(void 0, ()=>{let C=setInterval(()=>{D()&&!x.current&&i!=="submitting"&&i!=="success"&&p("stale")},1e3);return()=>clearInterval(C)},[D,i]);let H=()=>{i==="error"&&!x.current&&(f.current=null,p("idle"))},L=_react.useCallback.call(void 0, ()=>{f.current=null,p("refreshingQuote"),W()},[W]),T=_react.useCallback.call(void 0, ()=>{o?o(!0):v()},[o,v]),F=()=>i==="error"?"Retry swap":i==="signing"?"Sign Swap Order":i==="submitting"?"Submitting...":i==="refreshingQuote"?"Refreshing Quote...":i==="stale"?"Quote Stale":"Sign & Submit",B=!g&&(i==="error"||i==="stale"),J=B?"var(--widget-status-failed)":"var(--widget-primary)";return _jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full flex-row justify-between space-x-3",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${B?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${J} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${J} 20%, transparent)`,color:J,borderRadius:"var(--widget-radius)"},onClick:!g&&i==="error"?H:i==="stale"?T:void 0,children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.N,{asset:e,size:"xs",noChain:!0}),_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-nowrap",children:F()}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),M>0&&i!=="success"&&i!=="error"&&i!=="stale"&&_jsxruntime.jsx.call(void 0, ir,{startTime:M,onExpired:()=>p("stale")}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!g&&(i==="idle"||i==="signing"||i==="submitting"||i==="refreshingQuote")&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.U,{size:"5"}),(g||i==="success")&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.O,{className:"h-8 w-8"}),!g&&(i==="error"||i==="stale")&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.R,{className:"h-[12px] w-[12px]"})]})]})}),!g&&i==="error"&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-sans font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:v,children:"Cancel"})]})},lr=In;var Pn=()=>_jsxruntime.jsxs.call(void 0, "svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M18 13V19C18 20.1046 17.1046 21 16 21H5C3.89543 21 3 20.1046 3 19V8C3 6.89543 3.89543 6 5 6H11",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),_jsxruntime.jsx.call(void 0, "path",{d:"M15 3H21V9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),_jsxruntime.jsx.call(void 0, "path",{d:"M10 14L21 3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),$n="trackingTx",ur={pending:{icon:_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.U,{size:"5"}),buttonText:"Trade Pending",showNewSwap:!1,statusVar:"var(--widget-primary)",clickable:!1},received:{icon:_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.U,{size:"5"}),buttonText:"Trade Received",showNewSwap:!1,statusVar:"var(--widget-primary)",clickable:!1},completed:{icon:_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.O,{className:"h-5 w-5"}),buttonText:"View Transaction",showNewSwap:!1,statusVar:"var(--widget-status-completed)",clickable:!0},failed:{icon:_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.X,{}),buttonText:"Retry Swap",showNewSwap:!0,statusVar:"var(--widget-status-failed)",clickable:!0},cancelled:{icon:_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.X,{}),buttonText:"View Transaction",showNewSwap:!1,statusVar:"var(--widget-status-failed)",clickable:!0}},Un=({orderHash:e,base:t,quote:r,baseAmount:c,quoteAmount:l,reviewState:s,onNewSwap:a,onRetry:v,status:m})=>{let d=_chunkT2K2NOGZcjs.r.call(void 0, $n,s),o=ur[m]||ur.pending,n=_chunkV6LSLSFLcjs.c.call(void 0, u=>u.explorerUrl);_react.useEffect.call(void 0, ()=>{if(m==="completed"){let u=setTimeout(a,15e3);return()=>clearTimeout(u)}},[m,a]);let y=()=>{m==="failed"?v():(m==="completed"||m==="cancelled")&&n&&window.open(n,"_blank","noopener,noreferrer")},w=o.statusVar;return _jsxruntime.jsx.call(void 0, "div",{className:"flex flex-row justify-between space-x-3 w-full px-4",children:_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${o.clickable?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${w} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${w} 20%, transparent)`,color:w,borderRadius:"var(--widget-radius)"},onClick:o.clickable?y:void 0,children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[_jsxruntime.jsx.call(void 0, "div",{className:"flex h-6 w-6 items-center justify-center rounded-full overflow-hidden shrink-0",children:o.icon}),_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-nowrap",children:o.buttonText}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),o.clickable&&_jsxruntime.jsx.call(void 0, "div",{className:"flex h-6 w-6 items-center justify-center",children:m==="failed"?_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.W,{}):_jsxruntime.jsx.call(void 0, Pn,{})})]})})})},dr=Un;var Vn=15e3,Ye="unwrapping",_n=({needsToUnwrap:e,amount:t,chainId:r,token:c,reviewState:l,setReviewState:s,goToNextStep:a,cancel:v,delayedClose:m})=>{let d=_chunkT2K2NOGZcjs.r.call(void 0, Ye,l),[o,n]=_react.useState.call(void 0, "idle"),y=Yt(),{writeContractAsync:w}=_wagmi.useWriteContract.call(void 0, ),{address:u}=_chunk34N36GUDcjs.a.call(void 0, ),h=Oe(),g=_react.useRef.call(void 0, !1),i=_react.useRef.call(void 0, !1),p=_react.useRef.call(void 0, null),{status:x}=_wagmi.useAccount.call(void 0, ),f=_react.useCallback.call(void 0, ()=>{p.current&&(clearTimeout(p.current),p.current=null)},[]),k=_react.useCallback.call(void 0, async()=>{if(!(g.current||i.current||!u||x!=="connected")){g.current=!0,i.current=!0,n("pending"),p.current=setTimeout(()=>{g.current&&(n("error"),g.current=!1)},Vn);try{let N=_chunkT2K2NOGZcjs.c.call(void 0, r);if(!N)throw new Error(`No config for chain ${r}`);let E=_nullishCoalesce(N.wrappedAsset.decimals, () => (N.nativeAsset.decimals)),I=_viem.parseUnits.call(void 0, t.toString(),E);await y.mutateAsync({chainId:r,accountAddress:u,amountRaw:I,writeContractAsync:w});let M={symbol:N.nativeAsset.symbol,name:N.nativeAsset.name,address:_chunkT2K2NOGZcjs.a,decimals:N.nativeAsset.decimals,chainId:r},D={symbol:N.wrappedAsset.symbol,name:N.wrappedAsset.name,address:N.wrappedAsset.address,decimals:N.wrappedAsset.decimals,chainId:r};h({type:"unwrap",tokens:[{asset:M,userAddress:u},{asset:D,userAddress:u}]}),f(),n("success"),a(Ye,l),await m()}catch (e6){f(),n("error")}finally{g.current=!1}}},[u,x,r,t,y,w,h,a,l,m,f]);_react.useEffect.call(void 0, ()=>{g.current||i.current||l===Ye&&o==="idle"&&x==="connected"&&(e?k():(n("success"),a(Ye,l)))},[l,o,e,x,k,a]),_react.useEffect.call(void 0, ()=>()=>f(),[f]);let P=()=>{o==="error"&&(i.current=!1,n("idle"))},S=!d&&o==="error",U=!d&&(o==="pending"||o==="idle"||o==="error"),W=S?"var(--widget-status-failed)":"var(--widget-primary)";return _jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full flex-row justify-between space-x-3",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${S?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${W} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${W} 20%, transparent)`,color:W,borderRadius:"var(--widget-radius)"},onClick:S?P:void 0,children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-nowrap",children:S?"Retry Unwrap":c?`Unwrap ${c.symbol}`:"Unwrap Native Token"}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!d&&(o==="pending"||o==="idle")&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.U,{size:"5"}),(d||o==="success")&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.O,{className:"h-8 w-8"}),S&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.R,{className:"h-[12px] w-[12px]"})]})]})}),U&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-sans font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:v,children:"Cancel"})]})},gr=_n;var Qn=15e3,Je="wrapping",jn=({needsToWrap:e,amount:t,chainId:r,token:c,reviewState:l,setReviewState:s,goToNextStep:a,cancel:v,delayedClose:m,isWrappingPair:d})=>{let o=_chunkT2K2NOGZcjs.r.call(void 0, Je,l),[n,y]=_react.useState.call(void 0, "idle"),w=Jt(),{writeContractAsync:u}=_wagmi.useWriteContract.call(void 0, ),{address:h}=_chunk34N36GUDcjs.a.call(void 0, ),g=Oe(),i=_react.useRef.call(void 0, !1),p=_react.useRef.call(void 0, !1),x=_react.useRef.call(void 0, null),{status:f}=_wagmi.useAccount.call(void 0, ),k=_react.useCallback.call(void 0, ()=>{x.current&&(clearTimeout(x.current),x.current=null)},[]),P=_react.useCallback.call(void 0, async()=>{if(!(i.current||p.current||!h||f!=="connected")){i.current=!0,p.current=!0,y("pending"),x.current=setTimeout(()=>{i.current&&(y("error"),i.current=!1)},Qn);try{let E=_chunkT2K2NOGZcjs.c.call(void 0, r);if(!E)throw new Error(`No config for chain ${r}`);let I=_viem.parseUnits.call(void 0, t.toString(),E.nativeAsset.decimals);await w.mutateAsync({chainId:r,accountAddress:h,amountRaw:I,writeContractAsync:u});let M={symbol:E.nativeAsset.symbol,name:E.nativeAsset.name,address:_chunkT2K2NOGZcjs.a,decimals:E.nativeAsset.decimals,chainId:r},D={symbol:E.wrappedAsset.symbol,name:E.wrappedAsset.name,address:E.wrappedAsset.address,decimals:E.wrappedAsset.decimals,chainId:r};g({type:"wrap",tokens:[{asset:M,userAddress:h},{asset:D,userAddress:h}]}),k(),y("success"),a(Je,l),d&&await m()}catch (e7){k(),y("error")}finally{i.current=!1}}},[h,f,r,t,w,u,g,a,l,m,d,k]);_react.useEffect.call(void 0, ()=>{i.current||p.current||l===Je&&n==="idle"&&f==="connected"&&(e?P():(y("success"),a(Je,l)))},[l,n,e,f,P,a]),_react.useEffect.call(void 0, ()=>()=>k(),[k]);let S=()=>{n==="error"&&(p.current=!1,y("idle"))},U=!o&&n==="error",W=!o&&(n==="pending"||n==="idle"||n==="error"),N=U?"var(--widget-status-failed)":"var(--widget-primary)";return _jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full flex-row justify-between space-x-3",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${U?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${N} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${N} 20%, transparent)`,color:N,borderRadius:"var(--widget-radius)"},onClick:U?S:void 0,children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-nowrap",children:U?"Retry Wrap":c?`Wrap ${c.symbol}`:"Wrap Native Token"}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!o&&(n==="pending"||n==="idle")&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.U,{size:"5"}),(o||n==="success")&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.O,{className:"h-8 w-8"}),U&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.R,{className:"h-[12px] w-[12px]"})]})]})}),W&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-sans font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:v,children:"Cancel"})]})},vr=jn;var $a=({base:e,baseAmount:t,quote:r,quoteAmount:c,userAddress:l,isWrappingPair:s,isUnwrappingPair:a,isBaseGasToken:v,isQuoteGasToken:m,reviewActionProps:d,reviewState:o,setReviewState:n,trackedOrderHash:y,setTrackedOrderHash:w,txStatus:u,onSwapComplete:h,onSwapInitiated:g,onOrderSubmitted:i,onStaleQuoteRestart:p,setExitHandler:x,setRetryHandler:f})=>{let{rfqQuote:k,status:P,liquidityError:S,routingError:U,sizeCapError:W,stop:N,clear:E}=Be(),{clearForm:I}=_chunkV6LSLSFLcjs.f.call(void 0, ),M=_wagmi.useChainId.call(void 0, ),{swapButtonVariant:D,widgetType:Y}=_chunk46YHIOXGcjs.b.call(void 0, ),H=Y==="compact",{trackOrderTransaction:L,trackNativeTransaction:T}=er(),{startPolling:F}=Ft((_,ge,Le)=>{_chunkV6LSLSFLcjs.c.getState().setTxStatus(ge),Le&&_chunkV6LSLSFLcjs.c.getState().setExplorerUrl(Le),ge==="completed"&&L(_,`Swap ${e.symbol} \u2192 ${r.symbol}`)}),[B,J]=_react.useState.call(void 0, !1),C=_react.useRef.call(void 0, !1),R=_react.useRef.call(void 0, null),$=s,O=a,z=!s&&!a,te=M!==_optionalChain([e, 'optionalAccess', _83 => _83.chainId])&&($||O||z),Ve=_chunkT2K2NOGZcjs.c.call(void 0, e.chainId),_e={chainId:e.chainId,name:_nullishCoalesce(_optionalChain([Ve, 'optionalAccess', _84 => _84.displayName]), () => (`Chain ${e.chainId}`))},G=_react.useCallback.call(void 0, (_,ge)=>{if(ge!==_)return;if(_==="chain"){if($){n("wrapping");return}if(O){n("unwrapping");return}n("signingOrder");return}if(_==="signingOrder"){n("trackingTx");return}if(_==="wrapping"){if(!s){n("signingOrder");return}n("wrapSuccess");return}if(_==="unwrapping"){n("wrapSuccess");return}let Le=_chunkT2K2NOGZcjs.s.call(void 0, _);Le&&n(Le)},[n,s,$,O,z]),le=_react.useCallback.call(void 0, ()=>te?"chain":$?"wrapping":O?"unwrapping":z?"signingOrder":null,[te,$,O,z]),re=_react.useCallback.call(void 0, ()=>{n(null),I()},[I,n]),Te=_react.useCallback.call(void 0, async()=>{n("wrapSuccess");for(let _=0;_<3;_++)await _chunkT2K2NOGZcjs.t.call(void 0, 700);re()},[re,n]),ne=_react.useCallback.call(void 0, async()=>{E(),n("cancelled");for(let _=0;_<3;_++)await _chunkT2K2NOGZcjs.t.call(void 0, 500);re()},[E,re,n]),oe=_react.useCallback.call(void 0, ()=>{y&&(_chunkV6LSLSFLcjs.c.getState().stopTracking(),n(null),w(null),I())},[y,n,w,I]),Ue=_react.useCallback.call(void 0, ()=>{n(null),w(null),C.current=!0,_optionalChain([p, 'optionalCall', _85 => _85()])},[n,w,p]),ue=_react.useCallback.call(void 0, ()=>{d&&n(le())},[le,d,n]),Ze=_react.useCallback.call(void 0, (_=!1)=>{_?(C.current=!0,n(null),_optionalChain([p, 'optionalCall', _86 => _86()])):(n(null),R.current=setTimeout(()=>{d&&(n(le()),J(!1))},100))},[n,d,le,p]);_react.useEffect.call(void 0, ()=>{o!==null&&N()},[o,N]),_react.useEffect.call(void 0, ()=>{o!==null&&B&&J(!1)},[o,B]),_react.useEffect.call(void 0, ()=>{_optionalChain([x, 'optionalCall', _87 => _87(oe)])},[x,oe]),_react.useEffect.call(void 0, ()=>(_chunkV6LSLSFLcjs.c.getState().setExitHandler(oe),()=>_chunkV6LSLSFLcjs.c.getState().setExitHandler(null)),[oe]),_react.useEffect.call(void 0, ()=>{_optionalChain([f, 'optionalCall', _88 => _88(Ue)])},[f,Ue]),_react.useEffect.call(void 0, ()=>()=>{R.current&&clearTimeout(R.current)},[]),_react.useEffect.call(void 0, ()=>{C.current&&P==="fresh"&&_optionalChain([k, 'optionalAccess', _89 => _89.id])&&(C.current=!1,n("signingOrder"))},[P,_optionalChain([k, 'optionalAccess', _90 => _90.id]),n]);let Me=_=>{if(!_)return{backgroundColor:D==="default"?"var(--widget-muted)":"transparent",color:"var(--widget-muted-foreground)",border:D!=="default"?"1px solid var(--widget-border)":"none",borderRadius:"var(--widget-radius)"};switch(D){case"outline":return{backgroundColor:"transparent",color:"var(--widget-primary)",border:"1px solid var(--widget-primary)",borderRadius:"var(--widget-radius)"};case"ghost":return{backgroundColor:"transparent",color:"var(--widget-primary)",border:"none",borderRadius:"var(--widget-radius)"};default:return{backgroundColor:"var(--widget-primary)",color:"var(--widget-primary-foreground)",borderRadius:"var(--widget-radius)"}}},Re=`w-full ${H?"py-2":"py-3"} text-sm font-sans font-medium transition-colors cursor-pointer mt-1`;if(o===null&&!s&&!a){if(B)return _jsxruntime.jsx.call(void 0, "button",{className:Re,disabled:!0,style:{...Me(!1),opacity:.6,cursor:"not-allowed"},children:"Getting fresh quote..."});let _=()=>S?"Insufficient Liquidity":U?"Route Not Available":W?"Size Cap Exceeded":!k&&P==="polling"?"Getting Quote...":k?"Swap":"Enter Amount",ge=!!d;return _jsxruntime.jsx.call(void 0, "button",{onClick:ge?ue:void 0,disabled:!ge,className:`${Re} disabled:opacity-40 disabled:cursor-not-allowed`,style:Me(ge),children:_()})}return o===null&&a?_jsxruntime.jsx.call(void 0, "button",{onClick:d?ue:void 0,disabled:!d,className:`${Re} disabled:opacity-40 disabled:cursor-not-allowed`,style:Me(!!d),children:"Unwrap"}):o===null&&s?_jsxruntime.jsx.call(void 0, "button",{onClick:d?ue:void 0,disabled:!d,className:`${Re} disabled:opacity-40 disabled:cursor-not-allowed`,style:Me(!!d),children:"Wrap"}):o==="success"?_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col gap-2 w-full",children:_jsxruntime.jsx.call(void 0, "button",{className:`w-full ${H?"py-2":"py-3"} text-sm font-sans font-medium cursor-default`,style:{backgroundColor:"color-mix(in srgb, var(--widget-status-completed) 15%, transparent)",color:"var(--widget-status-completed)",border:"1px solid color-mix(in srgb, var(--widget-status-completed) 20%, transparent)",borderRadius:"var(--widget-radius)"},children:"Order Placed"})}):o==="wrapSuccess"?_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col gap-2 w-full",children:_jsxruntime.jsx.call(void 0, "button",{className:`w-full ${H?"py-2":"py-3"} text-sm font-sans font-medium cursor-default`,style:{backgroundColor:"color-mix(in srgb, var(--widget-status-completed) 15%, transparent)",color:"var(--widget-status-completed)",border:"1px solid color-mix(in srgb, var(--widget-status-completed) 20%, transparent)",borderRadius:"var(--widget-radius)"},children:s?"Wrapped Successfully":"Unwrapped Successfully"})}):o==="cancelled"?_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col gap-2 w-full",children:_jsxruntime.jsx.call(void 0, "button",{onClick:re,className:`w-full ${H?"py-2":"py-3"} text-sm font-sans font-medium cursor-pointer`,style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 15%, transparent)",color:"var(--widget-status-failed)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",borderRadius:"var(--widget-radius)"},children:"Order Cancelled"})}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full",children:[o==="chain"&&te&&_jsxruntime.jsx.call(void 0, nr,{requiredChain:_e,needsChainSwitch:te&&M!==e.chainId,reviewState:o,goToNextStep:G,cancel:ne}),o==="wrapping"&&$&&_jsxruntime.jsx.call(void 0, vr,{needsToWrap:$,amount:t,chainId:e.chainId,token:e,reviewState:o,setReviewState:n,goToNextStep:G,cancel:ne,delayedClose:Te,isWrappingPair:s}),o==="unwrapping"&&O&&_jsxruntime.jsx.call(void 0, gr,{needsToUnwrap:O,amount:t,chainId:e.chainId,token:e,reviewState:o,setReviewState:n,goToNextStep:G,cancel:ne,delayedClose:Te}),o==="signingOrder"&&z&&_jsxruntime.jsx.call(void 0, lr,{base:e,baseAmount:t,quote:r,quoteAmount:c,userAddress:l,reviewState:o,goToNextStep:G,cancel:ne,restartSigningFlow:Ze,onSwapInitiated:g,onOrderSubmitted:i,isWrappingPair:s,isUnwrappingPair:a,onSwapComplete:h,startPolling:F,trackNativeTransaction:T}),o==="trackingTx"&&y&&_jsxruntime.jsx.call(void 0, dr,{orderHash:y,base:e,quote:r,baseAmount:t,quoteAmount:c,reviewState:o,status:u,onNewSwap:oe,onRetry:Ue}),o&&!["chain","wrapping","unwrapping","approval","signingOrder","trackingTx","success","wrapSuccess","cancelled"].includes(o)&&_jsxruntime.jsx.call(void 0, "button",{disabled:!0,className:`w-full ${H?"py-2":"py-3"} text-sm font-sans font-medium`,style:{backgroundColor:"var(--widget-muted)",color:"var(--widget-muted-foreground)",borderRadius:"var(--widget-radius)"},children:"Processing..."})]})};var _shallow = require('zustand/react/shallow');var br={pending:"var(--widget-status-pending)",received:"var(--widget-status-received)",completed:"var(--widget-status-completed)",failed:"var(--widget-status-failed)",cancelled:"var(--widget-status-failed)"},Jn=({status:e})=>{let t=_nullishCoalesce(br[e], () => (br.pending));switch(e){case"completed":return _jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.O,{className:"h-6 w-6"});case"failed":case"cancelled":return _jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.X,{className:"h-6 w-6"});default:return _jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.U,{size:"5",color:t})}};function Zn(e){if(e===0)return"0";let t=Math.abs(e);return t>=1e4?e.toFixed(0):t>=1e3?e.toFixed(1):t>=100?e.toFixed(2):t>=1?e.toFixed(4):t>=.01?e.toFixed(6):e.toExponential(3)}function xr(e){try{let t=new URL(e).pathname.split("/"),r=t[t.length-1];return r&&r.startsWith("0x")?r:null}catch (e8){return null}}function Cr(e){let t=e.length;return t<=4?48:t<=6?40:t<=8?34:28}var xt=()=>_jsxruntime.jsxs.call(void 0, "svg",{className:"w-3 h-3 shrink-0",style:{color:"var(--widget-secondary-foreground)"},viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M18 13V19C18 20.1046 17.1046 21 16 21H5C3.89543 21 3 20.1046 3 19V8C3 6.89543 3.89543 6 5 6H11",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),_jsxruntime.jsx.call(void 0, "path",{d:"M15 3H21V9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),_jsxruntime.jsx.call(void 0, "path",{d:"M10 14L21 3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),es=()=>_jsxruntime.jsxs.call(void 0, "svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 195 321",fill:"var(--widget-secondary-foreground)",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "path",{fillRule:"evenodd",d:"M195,189C195,207.02,195,225.04,194.7,243.21C193.68,244.78,192.9,246.17,192.25,247.63C189.71,253.38,187.74,259.46,184.6,264.86C169.44,290.97,147.86,309.46,118.54,318.86C116.44,319.55,114.72,320.27,113,321C97.65,321,82.29,321,66.36,320.66C64.21,319.86,62.64,319.4,60.77,318.73C34.51,310.12,15.56,293.82,4.22,268.85C3.68,267.66,2.1,266.94,1,266C1,242.31,1,218.62,1.29,194.79C2.84,192.16,4.11,189.7,5.34,187.22C18.42,160.94,39.89,144.07,66.64,133.63C76.92,129.62,87.87,127.33,98.67,124.2C97.79,123.24,96.8,121.93,95.59,120.86C85.84,112.3,75.95,103.89,66.3,95.21C55.93,85.86,45.02,76.96,35.71,66.63C21.14,50.5,20.04,23.08,45.41,9.57C50.08,7.08,55.12,5.26,59.93,3.03C60.76,2.64,61.32,1.69,62,1C86.69,1,111.38,1,136.23,1.32C138.04,2.32,139.67,3.01,141.32,3.67C147.64,6.19,154.12,8.39,160.26,11.32C166.83,14.45,172.19,19.18,175.44,25.95C179.39,34.19,178.09,43.36,172.05,49.56C165.75,56.03,157.21,57.8,148.78,52.89C142.4,49.17,136.86,43.96,131.1,39.23C122.63,32.28,115.05,23.88,105.74,18.38C87.78,7.76,68.84,9.07,51.16,19.53C38.68,26.91,36.37,41.4,45.53,52.71C50.38,58.69,56.45,64,62.83,68.36C87.15,84.99,111.86,101.05,136.34,117.44C162.56,135,183.88,156.57,193.26,187.79C193.42,188.32,194.4,188.6,195,189ZM77.06,146.49C61.39,155.71,51.27,169.26,45.93,186.5C39.48,207.32,39.44,228.5,42.93,249.76C45.84,267.48,53.16,282.95,66.59,295.39C83.82,311.34,108.85,312.86,127.37,298.41C138.98,289.35,146.05,277.03,149.48,263.04C161.53,213.92,148.4,171.97,112.16,137.05C111.13,136.06,108.71,135.6,107.31,136.05C97.38,139.22,87.54,142.7,77.06,146.49Z"}),_jsxruntime.jsx.call(void 0, "path",{d:"M118.83,199C121.61,197.69,122.77,198.41,122.77,201.27C122.71,217.43,122.78,233.58,122.65,249.73C122.65,250.83,121.43,251.92,120.77,253.01C119.97,252.05,118.63,251.17,118.45,250.1C116.32,237.7,113.36,235.12,100.61,235.02C98.12,235,95.62,234.98,93.12,235.01C81.26,235.16,77.72,238.3,75.94,249.84C75.74,251.15,74.39,252.28,73.57,253.49C73.11,253.23,72.64,252.98,72.17,252.73C72.17,234.81,72.17,216.88,72.17,198.96C72.49,198.62,72.81,198.28,73.13,197.93C74.09,198.95,75.72,199.85,75.92,201C78.13,213.8,80.95,216.26,94.05,216.3C97.38,216.31,100.72,216.44,104.04,216.27C113.28,215.79,117.15,212.05,118.22,202.81C118.35,201.65,118.47,200.49,118.83,199Z"})]}),ts=({orderHash:e,base:t,quote:r,baseAmount:c,quoteAmount:l,status:s})=>{let[a,v]=_react.useState.call(void 0, !1),[m,d]=_react.useState.call(void 0, !0),o=_react.useRef.call(void 0, null),n=_react.useRef.call(void 0, Date.now()),[y,w]=_react.useState.call(void 0, null),u=_react.useRef.call(void 0, null),{isRecipientInputOpen:h,recipient:g,explorerUrl:i}=_chunkV6LSLSFLcjs.c.call(void 0, _shallow.useShallow.call(void 0, T=>({isRecipientInputOpen:T.isRecipientInputOpen,recipient:T.recipient,explorerUrl:T.explorerUrl})));_react.useEffect.call(void 0, ()=>{s==="received"&&(o.current=Date.now())},[s]),_react.useEffect.call(void 0, ()=>{if(s==="completed"&&!y){let T=o.current||n.current;w((Date.now()-T)/1e3)}},[s,y]),_react.useEffect.call(void 0, ()=>()=>{u.current&&clearTimeout(u.current)},[]);let p=_react.useCallback.call(void 0, ()=>{if(!_optionalChain([navigator, 'access', _91 => _91.clipboard, 'optionalAccess', _92 => _92.writeText]))return;let T=i?_nullishCoalesce(xr(i), () => (e)):e;navigator.clipboard.writeText(T).then(()=>{v(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>v(!1),2e3)}).catch(()=>{})},[e,i]),x=_chunkT2K2NOGZcjs.o.call(void 0, c),f=_chunkT2K2NOGZcjs.o.call(void 0, l),k=s==="completed"||s==="failed"||s==="cancelled",P=!k,S=c&&l?c/l:0,U=_chunkT2K2NOGZcjs.c.call(void 0, t.chainId),W=_chunkT2K2NOGZcjs.c.call(void 0, r.chainId),N=_nullishCoalesce(_optionalChain([U, 'optionalAccess', _93 => _93.displayName]), () => (`Chain ${t.chainId}`)),E=_nullishCoalesce(_optionalChain([W, 'optionalAccess', _94 => _94.displayName]), () => (`Chain ${r.chainId}`)),I=t.chainId!==r.chainId,M=_nullishCoalesce(_optionalChain([U, 'optionalAccess', _95 => _95.estimatedTimeMs]), () => (0)),D=_nullishCoalesce(_optionalChain([W, 'optionalAccess', _96 => _96.estimatedTimeMs]), () => (0)),Y=(I?M+D:M)/1e3,H=i?_nullishCoalesce(xr(i), () => (e)):e,L=`${H.slice(0,6)} \u2026 ${H.slice(-4)}`;return _jsxruntime.jsxs.call(void 0, "div",{className:"relative w-full flex flex-col",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"mx-4 mt-2",style:{backgroundColor:"var(--widget-secondary)"},children:[_jsxruntime.jsx.call(void 0, "div",{className:"p-5",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-3 mb-3",children:[_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.N,{asset:t,size:"md",noChain:!0}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-xl font-thin uppercase",style:{color:"var(--widget-foreground)"},children:t.symbol}),_jsxruntime.jsx.call(void 0, "p",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:t.name})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1",style:{backgroundColor:"color-mix(in srgb, var(--widget-muted-foreground) 20%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-muted-foreground) 30%, transparent)"},children:[_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.M,{chain:t.chainId,size:"xs"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs pt-0.5",style:{color:"var(--widget-muted-foreground)"},children:N})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"text-right",children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-thin tracking-tight font-sans",style:{color:"var(--widget-foreground)",fontSize:`${Cr(x)}px`,transition:"font-size 0.1s ease-out"},children:x}),t.price&&_jsxruntime.jsxs.call(void 0, "p",{className:"text-xs mt-1 font-sans",style:{color:"var(--widget-muted-foreground)"},children:["$",(t.price*c).toFixed(2)]})]})]})}),_jsxruntime.jsxs.call(void 0, "div",{className:"relative",children:[_jsxruntime.jsx.call(void 0, "div",{style:{borderTop:"1px solid var(--widget-border)"}}),_jsxruntime.jsx.call(void 0, "div",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",children:_jsxruntime.jsx.call(void 0, "div",{className:"w-10 h-10 rounded-full flex items-center justify-center",style:{backgroundColor:"var(--widget-secondary)",border:"1px solid var(--widget-border)"},children:_jsxruntime.jsx.call(void 0, Jn,{status:s})})})]}),_jsxruntime.jsx.call(void 0, "div",{className:"p-5",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-3 mb-3",children:[_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.N,{asset:r,size:"md",noChain:!0}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-xl font-thin uppercase",style:{color:"var(--widget-foreground)"},children:r.symbol}),_jsxruntime.jsx.call(void 0, "p",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:r.name})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1",style:{backgroundColor:"color-mix(in srgb, var(--widget-muted-foreground) 20%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-muted-foreground) 30%, transparent)"},children:[_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.M,{chain:r.chainId,size:"xs"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs pt-0.5",style:{color:"var(--widget-muted-foreground)"},children:E})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"text-right",children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-thin tracking-tight font-sans",style:{color:"var(--widget-foreground)",fontSize:`${Cr(f)}px`,transition:"font-size 0.1s ease-out"},children:f}),r.price&&_jsxruntime.jsxs.call(void 0, "p",{className:"text-xs mt-1 font-sans",style:{color:"var(--widget-muted-foreground)"},children:["$",(r.price*l).toFixed(2)]})]})]})})]}),h&&g&&_jsxruntime.jsx.call(void 0, "div",{className:"mx-4 mt-2 px-5 pb-2",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2 p-2 rounded-full",style:{backgroundColor:"var(--widget-secondary)"},children:[_jsxruntime.jsx.call(void 0, "div",{className:"flex h-5 w-5 items-center justify-center overflow-hidden rounded-full",style:{backgroundColor:"var(--widget-muted)"},children:_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",children:"\u{1F464}"})}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:"To:"}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs font-sans",style:{color:"var(--widget-foreground)"},children:[g.slice(0,6),"...",g.slice(-4)]})]})}),_jsxruntime.jsxs.call(void 0, "div",{className:"px-4 mt-4",style:{borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"},children:[_jsxruntime.jsx.call(void 0, "div",{className:"relative box-border flex flex-row h-8 w-full items-center cursor-pointer",role:"button",tabIndex:0,onClick:()=>d(!m),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),d(!m))},children:_jsxruntime.jsx.call(void 0, "div",{className:"flex h-full items-center w-full overflow-hidden",style:{color:"var(--widget-muted-foreground)"},children:_jsxruntime.jsxs.call(void 0, "div",{className:"translate-y-px font-sans flex w-full flex-row items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center gap-2 whitespace-nowrap",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center gap-1",children:[_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.N,{asset:r,size:"3xs",noChain:!0,className:"mb-0.5"}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:["1 ",r.symbol]})]}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:"="}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center gap-1",children:[_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.N,{asset:t,size:"3xs",noChain:!0,className:"mb-0.5"}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:[Zn(S)," ",t.symbol]})]}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:t.price?`\u2248 $${(t.price*S).toFixed(2)}`:""})]}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs ml-2 transition-transform duration-200 shrink-0",style:{color:"var(--widget-muted-foreground)",transform:m?"rotate(180deg)":"rotate(0deg)",display:"inline-block"},children:"\u25BE"})]})})}),_jsxruntime.jsx.call(void 0, "div",{className:"overflow-hidden transition-all duration-200",style:{maxHeight:m?"200px":"0px",opacity:m?1:0},children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1 pb-1 font-sans",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:"USD Value"}),_jsxruntime.jsxs.call(void 0, "span",{style:{color:"var(--widget-secondary-foreground)"},children:["$",t.price?(t.price*c).toFixed(2):"\u2014"]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{style:{color:"var(--widget-muted-foreground)"},children:"Order Type"}),_jsxruntime.jsx.call(void 0, "span",{style:{color:"var(--widget-secondary-foreground)"},children:"RFQ (Exact Fill)"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:"Transaction"}),i?_jsxruntime.jsxs.call(void 0, "a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 transition-colors hover:opacity-80",style:{color:"var(--widget-secondary-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:a?"Copied!":L}),_jsxruntime.jsx.call(void 0, xt,{})]}):_jsxruntime.jsxs.call(void 0, "button",{type:"button",onClick:p,className:"flex items-center gap-1 cursor-pointer transition-colors",style:{color:"var(--widget-secondary-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{style:{color:"var(--widget-secondary-foreground)"},children:a?"Copied!":L}),_jsxruntime.jsx.call(void 0, xt,{})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:k?"Speed":"Est. Time"}),_jsxruntime.jsx.call(void 0, "span",{style:{color:"var(--widget-secondary-foreground)"},children:y?`${y.toFixed(2)}s`:Y>0?`~${Y}s`:"\u2014"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:"Route"}),_jsxruntime.jsxs.call(void 0, "a",{href:"https://www.aori.io/scan",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 transition-colors hover:opacity-80",style:{color:"var(--widget-secondary-foreground)"},children:[_jsxruntime.jsx.call(void 0, es,{}),"Aori",_jsxruntime.jsx.call(void 0, xt,{})]})]})]})})]})]})},Fa= exports.x =ts;exports.a = Nr; exports.b = Oe; exports.c = is; exports.d = gs; exports.e = Be; exports.f = Fr; exports.g = ys; exports.h = Rs; exports.i = Os; exports.j = Ds; exports.k = Fs; exports.l = Vt; exports.m = Ft; exports.n = Bt; exports.o = en; exports.p = Qt; exports.q = tn; exports.r = Gt; exports.s = Kt; exports.t = Xt; exports.u = Yt; exports.v = Jt; exports.w = $a; exports.x = Fa;
|
|
2
|
+
var _chunkKH57FLSTcjs = require('./chunk-KH57FLST.cjs');var _chunkT2JA5EHNcjs = require('./chunk-T2JA5EHN.cjs');var _chunkTXQ6Q4S3cjs = require('./chunk-TXQ6Q4S3.cjs');var _chunkT2K2NOGZcjs = require('./chunk-T2K2NOGZ.cjs');var _chunk34N36GUDcjs = require('./chunk-34N36GUD.cjs');var _chunkT3I3AJXVcjs = require('./chunk-T3I3AJXV.cjs');var _reactquery = require('@tanstack/react-query');var _react = require('react');function kr(e){if(e.length===0)return 5e3;let l=Math.max(...e.map(s=>_nullishCoalesce(_optionalChain([_chunkT2K2NOGZcjs.c.call(void 0, s), 'optionalAccess', _2 => _2.blockTimeMs]), () => (2e3))));return Math.min(5e3,Math.max(1e3,l*2+1e3))}var Nr=()=>{let{address:e}=_chunk34N36GUDcjs.a.call(void 0, ),t=_chunkTXQ6Q4S3cjs.c.call(void 0, ),r=_reactquery.useQueryClient.call(void 0, ),c=_react.useRef.call(void 0, null),l=_react.useRef.call(void 0, !0),s=_react.useCallback.call(void 0, a=>{if(!e)return;let v=[...new Set(a.tokens.map(d=>d.asset.chainId))],m=kr(v);c.current&&(clearTimeout(c.current),c.current=null),c.current=setTimeout(async()=>{if(c.current=null,!!l.current)try{let d=a.tokens.map(w=>({chainId:w.asset.chainId,tokenAddress:w.asset.address})),o=await _chunkT2K2NOGZcjs.H.call(void 0, e,d);if(o.balances.length===0)return;if(a.tokens.length>=2){let w=a.tokens[0].asset,u=a.tokens[1].asset,h=_chunkT2K2NOGZcjs.I.swap(e,w.chainId,w.address,u.chainId,u.address);r.setQueryData(h,o)}let n=_chunkT2K2NOGZcjs.I.bulk(e,t),y=r.getQueryData(n);if(y){let w=y.balances.map(u=>_nullishCoalesce(o.balances.find(g=>g.chainId===u.chainId&&g.token.toLowerCase()===u.token.toLowerCase()), () => (u)));for(let u of o.balances)w.some(h=>h.chainId===u.chainId&&h.token.toLowerCase()===u.token.toLowerCase())||w.push(u);for(let u of a.tokens)if(!o.balances.some(g=>g.chainId===u.asset.chainId&&g.token.toLowerCase()===u.asset.address.toLowerCase())){let g=w.findIndex(i=>i.chainId===u.asset.chainId&&i.token.toLowerCase()===u.asset.address.toLowerCase());g!==-1&&(w[g]={...w[g],balance:"0",shiftedBalance:"0"})}r.setQueryData(n,{balances:w})}}catch (e2){}},m)},[e,t,r]);return _react.useEffect.call(void 0, ()=>(l.current=!0,()=>{l.current=!1,c.current&&(clearTimeout(c.current),c.current=null)}),[]),{triggerBalanceUpdate:s}},ot=class extends EventTarget{emit(t){this.dispatchEvent(new CustomEvent("balance-update",{detail:t}))}},at=new ot,Oe= exports.b =()=>e=>at.emit(e),is= exports.c =()=>{let{triggerBalanceUpdate:e}=Nr();_react.useEffect.call(void 0, ()=>{let t=r=>{e(r.detail)};return at.addEventListener("balance-update",t),()=>at.removeEventListener("balance-update",t)},[e])};var _viem = require('viem');var _jsxruntime = require('react/jsx-runtime');var Mt=_react.createContext.call(void 0, void 0),Ut=1e4,Ur=3e4,Mr=1e3,Lr=2;function Wr(e){return _nullishCoalesce(e.find(r=>_optionalChain([r, 'access', _3 => _3.routeSteps, 'optionalAccess', _4 => _4[0], 'optionalAccess', _5 => _5.type])==="AORI_V1"), () => (e[0]))}var gs=({children:e,recipient:t})=>{let{address:r}=_chunk34N36GUDcjs.a.call(void 0, ),c=t||r,[l,s]=_react.useState.call(void 0, "idle"),[a,v]=_react.useState.call(void 0, "idle"),[m,d]=_react.useState.call(void 0, null),[o,n]=_react.useState.call(void 0, null),[y,w]=_react.useState.call(void 0, !1),[u,h]=_react.useState.call(void 0, !1),[g,i]=_react.useState.call(void 0, !1),p=_react.useRef.call(void 0, null),x=_react.useRef.call(void 0, null),f=_react.useRef.call(void 0, null),k=_react.useRef.call(void 0, null),P=_react.useRef.call(void 0, null),S=_react.useRef.call(void 0, 0),U=_react.useRef.call(void 0, 0),W=_react.useRef.call(void 0, 0),N=_react.useRef.call(void 0, !1),E=_react.useRef.call(void 0, new Map),I=_react.useCallback.call(void 0, ()=>{f.current&&clearTimeout(f.current),k.current&&clearTimeout(k.current),P.current&&clearTimeout(P.current),f.current=null,k.current=null,P.current=null},[]),M=_react.useCallback.call(void 0, ()=>{I(),p.current=null,S.current=0,s(()=>N.current?"fresh":"idle")},[I]),D=_react.useCallback.call(void 0, ()=>{M(),x.current=null,d(null),n(null),w(!1),h(!1),i(!1),E.current.clear(),s("idle"),v("idle")},[M]),Y=_react.useCallback.call(void 0, C=>{if(!C)return;k.current&&clearTimeout(k.current);let R=Math.max(0,C+Ur-Date.now());k.current=setTimeout(()=>{s($=>$==="idle"?"idle":"stale")},R)},[]),H=_react.useCallback.call(void 0, async(C,R)=>{let{inputToken:$,outputToken:O,inputAmount:z,setOutputAmount:te}=C;if(!$||!O||!z||parseFloat(z)<=0||Date.now()-(U.current||0)<Ut-10)return;let _e=++S.current;try{if(!_optionalChain([$, 'optionalAccess', _6 => _6.decimals])||!_optionalChain([O, 'optionalAccess', _7 => _7.decimals]))return;let G=_chunkT2K2NOGZcjs.F.call(void 0, $.chainId)||_optionalChain([_chunkT2K2NOGZcjs.c.call(void 0, $.chainId), 'optionalAccess', _8 => _8.key])||"",le=_chunkT2K2NOGZcjs.F.call(void 0, O.chainId)||_optionalChain([_chunkT2K2NOGZcjs.c.call(void 0, O.chainId), 'optionalAccess', _9 => _9.key])||"";if(!G||!le)throw new Error("Unknown chain");let re=_viem.parseUnits.call(void 0, z.toString(),$.decimals).toString(),Te={srcChainKey:G,dstChainKey:le,srcTokenAddress:_chunkT2K2NOGZcjs.v.call(void 0, $.address),dstTokenAddress:_chunkT2K2NOGZcjs.v.call(void 0, O.address),amount:re,srcWalletAddress:r||"0x0000000000000000000000000000000000000000",dstWalletAddress:c||r||"0x0000000000000000000000000000000000000000",options:{amountType:"EXACT_SRC_AMOUNT",feeTolerance:{type:"PERCENT",amount:2}}};U.current=Date.now();let ne=await fetch(`${_chunkT2K2NOGZcjs.k.call(void 0, )}/quotes`,{method:"POST",headers:_chunkT2K2NOGZcjs.m.call(void 0, ),body:JSON.stringify(Te),signal:AbortSignal.timeout(15e3)});if(!ne.ok){let Re=await _asyncOptionalChain([(await ne.json().catch(()=>({}))), 'optionalAccess', async _10 => _10.message])||ne.statusText;throw Object.assign(new Error(Re),{status:ne.status})}let oe=await ne.json();if(_e!==S.current||p.current!==R)return;let Ue=_nullishCoalesce(oe.quotes, () => ([])),ue=Wr(Ue);if(!ue)throw Object.assign(new Error("No quotes returned"),{emptyQuotes:!0});let Ze=Number(_viem.formatUnits.call(void 0, _chunkT2K2NOGZcjs.q.call(void 0, ue.dstAmount),O.decimals));typeof te=="function"&&te(Ze),ue._receivedAt=Date.now(),d(ue),n(null),w(!1),s("fresh"),Y(ue._receivedAt),R&&E.current.delete(R)}catch(G){if(_e!==S.current||p.current!==R)return;let le=_optionalChain([G, 'optionalAccess', _11 => _11.status]),re=G instanceof Error?G.message:"",Te=!!_optionalChain([G, 'optionalAccess', _12 => _12.emptyQuotes]);if((le===400||Te||re.includes("Quote request failed"))&&R){let oe=(E.current.get(R)||0)+1;if(E.current.set(R,oe),oe>=Lr){h(!0),I(),p.current=null;return}}if(re.toLowerCase().includes("order cap exceeded")){i(!0),I(),p.current=null;return}if(re.toLowerCase().includes("insufficient executor balance")){w(!0),I(),p.current=null;return}n(G instanceof Error?G.message:"Unknown error")}},[r,c,Y,I]),L=_react.useCallback.call(void 0, (C,R)=>{I(),x.current=C,U.current=0,E.current.delete(R),w(!1),h(!1),i(!1),n(null),s("polling");let $=async()=>{p.current===R&&(await H(C,R),p.current===R&&(f.current=setTimeout($,Ut)))};$()},[I,H]),T=_react.useCallback.call(void 0, C=>{if(!_optionalChain([C, 'optionalAccess', _13 => _13.inputToken])||!_optionalChain([C, 'optionalAccess', _14 => _14.outputToken])||!_optionalChain([C, 'optionalAccess', _15 => _15.inputAmount])||parseFloat(C.inputAmount)<=0){M();return}let R=x.current;if(R&&_optionalChain([R, 'access', _16 => _16.inputToken, 'optionalAccess', _17 => _17.address])===_optionalChain([C, 'access', _18 => _18.inputToken, 'optionalAccess', _19 => _19.address])&&_optionalChain([R, 'access', _20 => _20.inputToken, 'optionalAccess', _21 => _21.chainId])===_optionalChain([C, 'access', _22 => _22.inputToken, 'optionalAccess', _23 => _23.chainId])&&_optionalChain([R, 'access', _24 => _24.outputToken, 'optionalAccess', _25 => _25.address])===_optionalChain([C, 'access', _26 => _26.outputToken, 'optionalAccess', _27 => _27.address])&&_optionalChain([R, 'access', _28 => _28.outputToken, 'optionalAccess', _29 => _29.chainId])===_optionalChain([C, 'access', _30 => _30.outputToken, 'optionalAccess', _31 => _31.chainId])&&R.inputAmount===C.inputAmount&&p.current)return;let O=Date.now();if(O-W.current<100)return;W.current=O;let z=`${Date.now()}-${Math.random().toString(36).slice(2)}`;p.current=z,L(C,z)},[L,M]),F=_react.useCallback.call(void 0, ({amount:C,inputToken:R,outputToken:$,setOutputAmount:O})=>{O(null),P.current&&clearTimeout(P.current),!C||C===0?(v("idle"),M(),d(null),n(null),w(!1),h(!1),i(!1)):(v("typing"),M(),d(null),w(!1),h(!1),i(!1),n(null),P.current=setTimeout(()=>{v("settled"),R&&$&&C>0&&T({inputToken:R,outputToken:$,inputAmount:C.toString(),setOutputAmount:O})},Mr))},[M,T]),B=_react.useCallback.call(void 0, ()=>{let C=x.current;if(!C)return;d(null);let R=`${Date.now()}-${Math.random().toString(36).slice(2)}`;p.current=R,s("refreshing"),typeof C.setOutputAmount=="function"&&C.setOutputAmount(null),L(C,R)},[L]);_react.useEffect.call(void 0, ()=>{N.current=!!m},[m]),_react.useEffect.call(void 0, ()=>()=>I(),[I]);let J=_react.useMemo.call(void 0, ()=>({status:l,inputState:a,rfqQuote:m,error:o,liquidityError:y,routingError:u,sizeCapError:g,ensureForParams:T,stop:M,refresh:B,clear:D,handleInputChange:F}),[l,a,m,o,y,u,g,T,M,B,D,F]);return _jsxruntime.jsx.call(void 0, Mt.Provider,{value:J,children:e})},Be= exports.e =()=>{let e=_react.useContext.call(void 0, Mt);if(e===void 0)throw new Error("useRfq must be used within an RfqProvider");return e};var Fr=_react.createContext.call(void 0, {openConnectModal:()=>{}}),ys= exports.g =()=>_react.useContext.call(void 0, Fr);var Br=20,qr=({side:e,asset:t,otherAsset:r,isPlacingOrder:c,isWrappingPair:l,isUnwrappingPair:s})=>{let{baseAmount:a,quoteAmount:v,setBaseAmount:m,setQuoteAmount:d}=_chunkT2JA5EHNcjs.e.call(void 0, ),{amountInputVariant:o,hideAmountInputSymbol:n,widgetType:y}=_chunkTXQ6Q4S3cjs.b.call(void 0, ),w=y==="compact",[u,h]=e==="base"?[m,d]:[d,m],g=!t||e==="quote"||c,i=w?32:o==="default"?64:32,[p,x]=_react.useState.call(void 0, i),[f,k]=_react.useState.call(void 0, ""),P=_react.useRef.call(void 0, null),S=_react.useRef.call(void 0, null),U=_react.useRef.call(void 0, null),W=_react.useRef.call(void 0, null),N="USD",E=e==="base"?a:v,[I,M]=_react.useState.call(void 0, !1),D=_react.useCallback.call(void 0, ()=>{if(o!=="default"){x(i);return}if(!P.current||!S.current||!U.current)return;let L=P.current.offsetWidth,T=20,F=i;for(;F>20&&(S.current.style.fontSize=`${F}px`,U.current.style.fontSize=`${F}px`,!(S.current.offsetWidth+U.current.offsetWidth+T<=L));)F-=1;x(F)},[o,i]),Y=_react.useCallback.call(void 0, L=>{L.key==="."&&f.includes(".")&&L.preventDefault()},[f]),H=_react.useCallback.call(void 0, L=>{let T=L.target.value;if(T==="."&&(T="0."),!/^\d*\.?\d*$/.test(T)||(T.match(/\./g)||[]).length>1)return;if(T.length>1&&T[0]==="0"&&T[1]!=="."&&(T=T.replace(/^0+/,"")||"0"),_optionalChain([t, 'optionalAccess', _32 => _32.decimals])!==void 0&&T.includes(".")){let[,B]=T.split(".");if(B&&B.length>t.decimals)return}if(T.length>Br)return;k(T);let F=parseFloat(T);T!==f&&(T===""||T==="0."||T.endsWith(".")?(u(null),e==="base"&&h(null)):!Number.isNaN(F)&&F>=0&&u(F),e==="base"&&d(null),(s||l)&&d(F||0))},[f,u,e,d,_optionalChain([t, 'optionalAccess', _33 => _33.decimals]),h,s,l]);return _react.useEffect.call(void 0, ()=>{let L=B=>{if(B===null)return"";let J=_optionalChain([t, 'optionalAccess', _34 => _34.decimals]);if(J===void 0)return"";let C=B.toString();if(/e/i.test(C)&&(C=Number(B).toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:J})),C.includes(".")){let[R,$]=C.split("."),O=$.slice(0,J);return O?`${R}.${O}`:R}return C};if(E===null){f==="0."||f!==""&&f.endsWith(".")||k("");return}if(!g&&(f.endsWith(".")||f.match(/\.\d*0$/)||f==="0"||f==="0.")&&f!=="")return;let F=parseFloat(f)||0;(f===""||Math.abs(F-E)>1e-10)&&k(L(E))},[E,_optionalChain([t, 'optionalAccess', _35 => _35.decimals]),f,g]),_react.useEffect.call(void 0, ()=>{D()},[f,D]),_react.useEffect.call(void 0, ()=>{M(!0)},[]),_react.useEffect.call(void 0, ()=>{I&&D()},[I,D]),_react.useEffect.call(void 0, ()=>{S.current&&W.current&&(W.current.style.width=`${S.current.offsetWidth}px`)},[f]),_react.useEffect.call(void 0, ()=>{if(!I)return;let L=new ResizeObserver(()=>{I&&D()});return P.current&&L.observe(P.current),()=>L.disconnect()},[I,D]),_jsxruntime.jsx.call(void 0, "div",{ref:P,style:{fontSize:`${p}px`,transition:"font-size 0.05s ease-in-out"},className:`mt-2 box-border font-sans flex ${w?o==="normal"?"h-12 my-1":"h-10 my-0.5":o==="normal"?"h-12 my-1":"h-20 my-1"} w-full flex-row items-center ${g?"cursor-default":"cursor-text"}`,onClick:()=>_optionalChain([W, 'access', _36 => _36.current, 'optionalAccess', _37 => _37.focus, 'call', _38 => _38()]),children:_jsxruntime.jsxs.call(void 0, "div",{className:"relative flex w-full items-center",children:[_jsxruntime.jsx.call(void 0, "label",{htmlFor:`${e}Amount`,className:"sr-only",children:e==="base"?"Input token amount":"Output token amount"}),_jsxruntime.jsx.call(void 0, "input",{ref:W,type:"text",inputMode:"decimal",placeholder:"0",autoComplete:"off",id:`${e}Amount`,value:f,onWheel:L=>L.target.blur(),onKeyDown:Y,onChange:H,style:{transition:"width 0.15s ease-in-out",color:"var(--widget-foreground)",WebkitTextFillColor:"var(--widget-foreground)",opacity:1},className:"flex min-w-[45px] whitespace-nowrap bg-transparent placeholder:opacity-50 font-sans font-thin",disabled:g}),_jsxruntime.jsx.call(void 0, "span",{style:{transition:"width 0.15s ease-in-out"},ref:S,className:"pointer-events-none absolute flex whitespace-nowrap invisible",children:f||0}),!n&&o!=="normal"&&_jsxruntime.jsx.call(void 0, "span",{ref:U,className:"ml-2 font-thin uppercase",style:{color:"var(--widget-foreground)",opacity:.5,fontSize:`${p}px`},children:_optionalChain([t, 'optionalAccess', _39 => _39.symbol])?t.symbol.length>6?`${t.symbol.slice(0,6)}...`:t.symbol:N}),(n||o==="normal")&&_jsxruntime.jsx.call(void 0, "span",{ref:U,className:"hidden"})]})})},Rs= exports.h =qr;var Qr=({toggle:e,side:t,asset:r,isPlacingOrder:c,hideDropdown:l})=>{let{baseBalance:s,quoteBalance:a}=_chunkT2JA5EHNcjs.e.call(void 0, ),{tokenDisplay:v,tokenBadgeOrientation:m,widgetType:d}=_chunkTXQ6Q4S3cjs.b.call(void 0, ),o=d==="compact",n=o?"h-10":"h-11",y=o?"h-10 w-10":"h-11 w-11",w=t==="base"?s.formatted?(()=>{let h=parseFloat(s.formatted);return h>=1e8?_chunkT2K2NOGZcjs.o.call(void 0, h):h.toFixed(3)})():void 0:a.formatted?(()=>{let h=parseFloat(a.formatted);return h>=1e8?_chunkT2K2NOGZcjs.o.call(void 0, h):h.toFixed(3)})():void 0,u={role:"button",tabIndex:c?-1:0,"aria-disabled":c,"aria-label":`Select ${t==="base"?"input":"output"} token${r?`: ${r.symbol}`:""}`,onClick:c?void 0:e,onKeyDown:c?void 0:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),e())}};return v==="pill"?_jsxruntime.jsx.call(void 0, "div",{...u,className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-full cursor-pointer transition-colors ${m==="right"?"ml-auto":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-secondary)",color:"var(--widget-secondary-foreground)"},children:r?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.M,{chain:r.chainId,size:"xs"}),_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.N,{className:"rounded-full",asset:r,size:"xxs",noChain:!0}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs font-thin uppercase",children:r.symbol}),!l&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.T,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-xs opacity-70",children:"Select"}),!l&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.T,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]})}):v==="ghost"?_jsxruntime.jsxs.call(void 0, "div",{...u,className:"inline-flex items-center gap-1.5 cursor-pointer transition-opacity hover:opacity-70 py-1",style:{color:"var(--widget-foreground)"},children:[r?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.M,{chain:r.chainId,size:"xs"}),_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.N,{className:"rounded-full",asset:r,size:"xxs",noChain:!0}),_jsxruntime.jsx.call(void 0, "span",{className:"text-sm font-thin uppercase",children:r.symbol})]}):_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Select token"}),!l&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.T,{className:"w-1.5 opacity-50"})]}):_jsxruntime.jsx.call(void 0, "div",{...u,className:`relative ${n} w-full cursor-pointer text-xl duration-100 ease-linear`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-secondary)",borderTopLeftRadius:"9999px",borderBottomLeftRadius:"9999px",borderTopRightRadius:"var(--widget-radius)",borderBottomRightRadius:"var(--widget-radius)"},children:_jsxruntime.jsx.call(void 0, "div",{className:"relative flex h-full w-full flex-row items-center",children:r?_jsxruntime.jsxs.call(void 0, "div",{className:"relative flex h-full w-full flex-row items-center",children:[_jsxruntime.jsx.call(void 0, "div",{className:`${y} pl-px flex items-center justify-center`,children:_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.N,{className:"rounded-full",asset:r,size:"md"})}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full w-full flex-row items-center justify-between pl-1.5 pr-7",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full flex-col justify-center",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-thin uppercase",style:{color:"var(--widget-secondary-foreground)"},children:r.symbol}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-2xs font-sans",style:{color:"var(--widget-muted-foreground)"},children:[_optionalChain([r, 'access', _40 => _40.address, 'optionalAccess', _41 => _41.slice, 'call', _42 => _42(0,6)]),"...",_optionalChain([r, 'access', _43 => _43.address, 'optionalAccess', _44 => _44.slice, 'call', _45 => _45(-4)])]})]}),w!==void 0&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col text-right",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Balance"}),_jsxruntime.jsx.call(void 0, "span",{className:"font-sans text-xs tabular-nums",style:{color:"var(--widget-foreground)",opacity:.5},children:w})]})]}),!l&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.T,{className:"absolute right-3 top-1/2 w-1.5 translate-y-[-50%]",style:{color:"var(--widget-secondary-foreground)",opacity:.6}})]}):_jsxruntime.jsx.call(void 0, "div",{className:"flex h-full w-full items-center justify-center",children:_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",style:{color:"var(--widget-secondary-foreground)",opacity:.7},children:"Select token"})})})})},Os= exports.i =Qr;var Wt=_chunkT3I3AJXVcjs.b.call(void 0, _chunkKH57FLSTcjs.a.call(void 0, ),1);var jr=()=>{let[e,t]=_react.useState.call(void 0, null),[r,c]=_react.useState.call(void 0, ""),l=_chunkT2K2NOGZcjs.x.call(void 0, r,1e3),[s,a]=_react.useState.call(void 0, !1),[v,m]=_react.useState.call(void 0, "");_react.useEffect.call(void 0, ()=>{_chunkTXQ6Q4S3cjs.d.getState().setRecipient(e)},[e]),_react.useEffect.call(void 0, ()=>{c(e||"")},[e]);let d=n=>{let y=n.target.value;s&&(a(!1),m(""),t(null)),c(y),y===""&&t(null)};_react.useEffect.call(void 0, ()=>{l===""||!l?(a(!1),m(""),t(null)):_chunkT2K2NOGZcjs.w.call(void 0, l)?(a(!1),m(""),t(l)):(a(!0),m("Invalid wallet address..."),t(null),c(""))},[l]),_react.useEffect.call(void 0, ()=>{if(s){let n=setTimeout(()=>{t(null),c(""),a(!1),m("")},2e3);return()=>clearTimeout(n)}},[s]);let o=()=>{t(null),c(""),a(!1),m("")};return _jsxruntime.jsx.call(void 0, "div",{className:"w-full",children:_jsxruntime.jsxs.call(void 0, "div",{className:"relative flex flex-row items-center",children:[_jsxruntime.jsx.call(void 0, "input",{type:"password",style:{display:"none"},"aria-hidden":"true",tabIndex:-1}),_jsxruntime.jsx.call(void 0, "label",{htmlFor:"recipient-address",className:"sr-only",children:"Recipient wallet address"}),_jsxruntime.jsx.call(void 0, "div",{className:"absolute left-3 flex h-6 w-6 items-end justify-center overflow-hidden rounded-full",style:{backgroundColor:"var(--widget-secondary)"},children:e&&!s?_jsxruntime.jsx.call(void 0, "img",{className:"h-full w-full rounded-full object-cover",src:(0,Wt.makeGradient)(e),alt:"Recipient avatar"}):_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.S,{className:"h-5 w-5",style:{color:s?"var(--widget-destructive)":"var(--widget-muted-foreground)"}})}),_jsxruntime.jsx.call(void 0, "div",{className:"absolute left-12 top-1.5 -translate-y-1 text-xs font-medium opacity-60",style:{color:s?"var(--widget-destructive)":"var(--widget-muted-foreground)"},"aria-hidden":"true",children:"To:"}),_jsxruntime.jsx.call(void 0, "input",{id:"recipient-address",className:"font-sans block h-10 w-full items-center pl-12 pt-4 pr-8 text-xs",style:{backgroundColor:s?"color-mix(in srgb, var(--widget-destructive) 10%, transparent)":"transparent",color:s?"var(--widget-destructive)":"var(--widget-foreground)",outline:"none",opacity:s?.9:1},placeholder:s?v:"Enter recipient address...",value:r,onChange:d,spellCheck:!1,"aria-invalid":s,"aria-describedby":s?"recipient-error":void 0}),s&&_jsxruntime.jsx.call(void 0, "span",{id:"recipient-error",className:"sr-only",children:v}),e&&!s&&_jsxruntime.jsxs.call(void 0, "button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 cursor-pointer flex items-center justify-center h-4 w-4 rounded-full transition-colors hover:[color:var(--widget-destructive)]",style:{color:"var(--widget-muted-foreground)"},onClick:o,"aria-label":"Clear recipient",children:[_jsxruntime.jsx.call(void 0, "svg",{className:"h-2.5 w-2.5",viewBox:"0 -0.5 21 21",fill:"none",children:_jsxruntime.jsx.call(void 0, "g",{fill:"currentColor",fillRule:"evenodd",children:_jsxruntime.jsx.call(void 0, "polygon",{points:"375.0183 90 384 98.554 382.48065 100 373.5 91.446 364.5183 100 363 98.554 371.98065 90 363 81.446 364.5183 80 373.5 88.554 382.48065 80 384 81.446",transform:"translate(-363 -80)"})})}),_jsxruntime.jsx.call(void 0, "span",{className:"sr-only",children:"Clear recipient"})]})]})})},Ds= exports.j =jr;function Fs(e){return _jsxruntime.jsxs.call(void 0, "svg",{width:"485",height:"484",viewBox:"0 0 485 484",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[_jsxruntime.jsx.call(void 0, "path",{d:"M265.974 52.8127C270.567 50.9299 273.227 53.6338 275.917 56.1595C301.879 80.5364 327.828 104.927 353.786 129.308C380.101 154.024 406.44 178.715 432.721 203.467C436.002 206.557 440.744 209.272 438.226 215.021C435.865 220.415 430.758 219.123 426.424 219.124C305.965 219.169 185.506 219.163 65.0464 219.166C53.0995 219.166 49.0676 215.225 49.0125 203.316C48.9563 191.154 48.9813 178.991 48.9973 166.829C49.0119 155.717 53.3581 151.358 64.4131 151.358C127.892 151.357 191.37 151.364 254.849 151.368C262.591 151.368 262.645 151.344 262.588 143.559C262.388 116.237 262.191 88.914 261.918 61.5922C261.883 58.0834 262.161 54.9042 265.974 52.8127Z",fill:"currentColor"}),_jsxruntime.jsx.call(void 0, "path",{d:"M80.5649 300.432C71.3447 291.747 62.4175 283.264 53.4064 274.87C50.4552 272.122 47.8959 269.327 49.7894 264.946C51.6154 260.72 55.4624 260.923 59.1682 260.923C164.476 260.927 269.785 260.932 375.093 260.935C391.422 260.935 407.752 260.9 424.081 260.933C434.679 260.955 438.994 265.286 439.015 275.854C439.04 288.517 439.048 301.181 439.013 313.845C438.985 324.225 434.466 328.73 424.01 328.732C360.359 328.741 296.707 328.729 233.056 328.714C225.392 328.713 225.368 328.686 225.426 336.583C225.628 363.741 225.815 390.9 226.101 418.057C226.142 421.935 225.905 425.512 221.852 427.329C217.686 429.197 214.934 426.578 212.212 424.02C172.068 386.302 131.922 348.587 91.7738 310.874C88.1374 307.459 84.4753 304.07 80.5649 300.432Z",fill:"currentColor"})]})}var Gr=["SUCCEEDED","FAILED","COMPLETED","CANCELLED"];async function Vt(e,t,r={}){let{onStatusChange:c,onComplete:l,onError:s,interval:a=4e3,timeout:v=3e5,txHash:m,signal:d}=r,o=null,n=Date.now(),y=0,w=8,u=null,h=m?`?txHash=${m}`:"";return new Promise((g,i)=>{let p=async()=>{try{if(_optionalChain([d, 'optionalAccess', _46 => _46.aborted])){u&&clearTimeout(u),i(new DOMException("Polling aborted","AbortError"));return}if(Date.now()-n>v){u&&clearTimeout(u);let P=new Error("Order status polling timed out");_optionalChain([s, 'optionalCall', _47 => _47(P)]),i(P);return}let x=await fetch(`${t}/status/${e}${h}`,{headers:_chunkT2K2NOGZcjs.m.call(void 0, ),signal:d});if(x.status===404){u=setTimeout(p,a);return}if(!x.ok)throw new Error(`Failed to fetch order status: ${await x.text()}`);let f=await x.json();if(!f||typeof f!="object"||!f.status)throw new Error(`Invalid status response format: ${JSON.stringify(f)}`);y=0;let k=f.status.toUpperCase();if(k!==o&&(o=k,_optionalChain([c, 'optionalCall', _48 => _48(f)])),Gr.includes(k)){u&&clearTimeout(u),_optionalChain([l, 'optionalCall', _49 => _49(f)]),g(f);return}u=setTimeout(p,a)}catch(x){if(x instanceof Error&&x.name==="AbortError"){u&&clearTimeout(u),i(x);return}if(++y>=w){u&&clearTimeout(u);let f=x instanceof Error?x:new Error(String(x));_optionalChain([s, 'optionalCall', _50 => _50(f)]),i(f);return}u=setTimeout(p,a)}};p()})}function _t(e){let t=e.toUpperCase();return t==="SUCCEEDED"||t==="COMPLETED"?"completed":t==="FAILED"?"failed":t==="CANCELLED"?"cancelled":t==="PROCESSING"?"received":"pending"}var Ft=e=>{let t=_react.useRef.call(void 0, new Map),r=_react.useRef.call(void 0, new Map),c=_react.useRef.call(void 0, new Map),l=_react.useRef.call(void 0, 0),s=_react.useCallback.call(void 0, ()=>++l.current,[]),{address:a}=_chunk34N36GUDcjs.a.call(void 0, ),v=Oe(),m=_react.useCallback.call(void 0, (n,y)=>{if(t.current.get(n))return;y&&r.current.set(n,y),t.current.set(n,!0);let w=l.current,u=new AbortController;c.current.set(n,u);let h=_optionalChain([y, 'optionalAccess', _51 => _51.baseToken, 'optionalAccess', _52 => _52.chainId])===1;Vt(n,_chunkT2K2NOGZcjs.k.call(void 0, ),{interval:h?1e3:500,timeout:3e5,signal:u.signal,onStatusChange:g=>{if(!_optionalChain([g, 'optionalAccess', _53 => _53.status]))return;let i=_t(g.status);if(_optionalChain([e, 'optionalCall', _54 => _54(n,i,g.explorerUrl)]),i==="completed"&&a){let p=r.current.get(n);if(p&&(p.baseToken||p.quoteToken)){let x=[];p.baseToken&&x.push({asset:p.baseToken,userAddress:a}),p.quoteToken&&x.push({asset:p.quoteToken,userAddress:a}),v({type:"swap",tokens:x})}}["completed","failed","cancelled"].includes(i)&&(t.current.delete(n),r.current.delete(n)),w!==l.current&&(t.current.delete(n),r.current.delete(n))},onComplete:g=>{_optionalChain([g, 'optionalAccess', _55 => _55.status])&&_optionalChain([e, 'optionalCall', _56 => _56(n,_t(g.status),g.explorerUrl)]),t.current.delete(n),r.current.delete(n)},onError:()=>{t.current.delete(n),r.current.delete(n)}}).catch(g=>{g instanceof Error&&g.name==="AbortError"||(t.current.delete(n),r.current.delete(n),c.current.delete(n))})},[a,v,e]),d=_react.useCallback.call(void 0, n=>{let y=c.current.get(n);y&&(y.abort(),c.current.delete(n)),s(),t.current.delete(n),r.current.delete(n)},[s]),o=_react.useCallback.call(void 0, ()=>{for(let n of c.current.values())n.abort();c.current.clear(),s(),t.current.clear(),r.current.clear()},[s]);return _react.useEffect.call(void 0, ()=>()=>o(),[o]),{startPolling:m,stopPolling:d,stopAllPolling:o,isPolling:n=>t.current.has(n)}};var Jr=_react.createContext.call(void 0, {registerTransaction:()=>{},enabled:!1}),Bt= exports.n =()=>_react.useContext.call(void 0, Jr);var _actions = require('viem/actions');function zt(e){return e instanceof Error?e.name==="UserRejectedRequestError"||e.message.includes("User rejected")||e.message.includes("rejected")||e.message.includes("denied")||e.message.includes("cancelled")||e.message.includes("canceled"):!1}async function qt(e){if(_optionalChain([e, 'access', _57 => _57.chain, 'optionalAccess', _58 => _58.id]))return e.chain.id;let t=_optionalChain([e, 'access', _59 => _59.getChainId, 'optionalCall', _60 => _60()]);return t!=null?await t:null}var en=async(e,t)=>{try{if(await qt(e)===t)return!0;if(e.request)await e.request({method:"wallet_switchEthereumChain",params:[{chainId:`0x${t.toString(16)}`}]});else if(e.switchChain)await e.switchChain({id:t});else if(e.send)await e.send("wallet_switchEthereumChain",[{chainId:`0x${t.toString(16)}`}]);else throw new Error("Wallet doesn't support chain switching");return await qt(e)===t}catch(r){throw zt(r)?new Error("User rejected the chain switch request"):new Error(`Please switch your wallet to the required network (Chain ID: ${t})`)}},Qt= exports.p =async e=>{let{quote:t,signatureStep:r,userAddress:c,walletClient:l}=e;if(!l)throw new Error("Wallet client not available");if(r.type!=="SIGNATURE"||!_optionalChain([r, 'access', _61 => _61.signature, 'optionalAccess', _62 => _62.typedData]))throw new Error("Invalid signature step");try{let s=r.signature.typedData,a={...s.message};for(let o of["inputAmount","outputAmount","startTime","endTime"])a[o]!=null&&(a[o]=BigInt(a[o]));let v=s.domain;if(v.chainId!=null){let o=Number(v.chainId);await en(l,o)}let m=await _actions.signTypedData.call(void 0, l,{account:c,domain:v,types:s.types,primaryType:s.primaryType,message:a}),d=await fetch(`${_chunkT2K2NOGZcjs.k.call(void 0, )}/submit-signature`,{method:"POST",headers:_chunkT2K2NOGZcjs.m.call(void 0, ),body:JSON.stringify({quoteId:t.id,signatures:[m]})});if(!d.ok){let o=await d.json().catch(()=>({}));throw new Error(_optionalChain([o, 'optionalAccess', _63 => _63.message])||`Submit failed: ${d.status}`)}return{quoteId:t.id,signature:m}}catch(s){throw zt(s)?new Error("User rejected the signing request"):s instanceof Error&&s.message.includes("chain")?new Error("Chain switching failed. Please manually switch to the correct network."):s}};var jt="vt_submitted_quotes";var ut=()=>{try{let e=localStorage.getItem(jt);return e?JSON.parse(e):[]}catch (e3){return[]}},Ht=e=>{try{localStorage.setItem(jt,JSON.stringify(e))}catch (e4){}},tn= exports.q =e=>{let t=Date.now(),r=typeof e=="string"?new Date(e).getTime():e>9999999999?e:e*1e3;return t<r+3e4},rn=e=>ut().some(t=>t.quoteId===e),Gt= exports.r =(e,t)=>rn(e)?{canSubmit:!1,reason:"Order already submitted"}:tn(t)?{canSubmit:!0}:{canSubmit:!1,reason:"Quote has expired"},Kt= exports.s =(e,t)=>{let r=typeof t=="string"?new Date(t).getTime():t,c=ut();c.push({quoteId:e,submittedAt:Date.now(),createdAt:r}),Ht(c)},Xt= exports.t =()=>{let e=ut(),t=Date.now(),r=300*1e3,c=e.filter(l=>t-l.submittedAt<r);c.length!==e.length&&Ht(c)};var _core = require('@wagmi/core');var _abis = require('abitype/abis');var _wagmi = require('wagmi');function Yt(){let e=_wagmi.useConfig.call(void 0, );return _reactquery.useMutation.call(void 0, {mutationFn:async({chainId:t,accountAddress:r,amountRaw:c,writeContractAsync:l})=>{let s=_chunkT2K2NOGZcjs.c.call(void 0, t);if(!s)throw new Error(`No wrapping contract for chain ${t}`);let a=s.wrappedAsset.address,v=await l({abi:_abis.wethAbi,functionName:"withdraw",address:a,account:r,args:[c],chainId:t});if((await _core.waitForTransactionReceipt.call(void 0, e,{hash:v,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Unwrap transaction did not get successful receipt");return{success:!0,hash:v}}})}function Jt(){let e=_wagmi.useConfig.call(void 0, );return _reactquery.useMutation.call(void 0, {mutationFn:async({chainId:t,accountAddress:r,amountRaw:c,writeContractAsync:l})=>{let s=_chunkT2K2NOGZcjs.c.call(void 0, t);if(!s)throw new Error(`No wrapping contract for chain ${t}`);let a=s.wrappedAsset.address,v=await l({abi:_abis.wethAbi,functionName:"deposit",address:a,account:r,value:c,chainId:t});if((await _core.waitForTransactionReceipt.call(void 0, e,{hash:v,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Wrap transaction did not get successful receipt");return{success:!0,hash:v}}})}function er(){let{registerTransaction:e,enabled:t}=Bt(),r=_react.useRef.call(void 0, new Set),c=_react.useCallback.call(void 0, (s,a)=>{!t||r.current.has(s)||(r.current.add(s),e(s,a))},[t,e]),l=_react.useCallback.call(void 0, (s,a)=>{!t||r.current.has(s)||(r.current.add(s),e(s,a))},[t,e]);return{trackOrderTransaction:c,trackNativeTransaction:l,txTrackingEnabled:t}}var hn=15e3,Ge="chain",vn=({needsChainSwitch:e,requiredChain:t,reviewState:r,goToNextStep:c,cancel:l})=>{let s=_chunkT2K2NOGZcjs.r.call(void 0, Ge,r),[a,v]=_react.useState.call(void 0, "pending"),m=_react.useRef.call(void 0, !1),d=_react.useRef.call(void 0, !1),o=_react.useRef.call(void 0, null),n=_wagmi.useChainId.call(void 0, ),{switchChainAsync:y}=_wagmi.useSwitchChain.call(void 0, ),{status:w,isReconnecting:u}=_wagmi.useAccount.call(void 0, ),h=_react.useCallback.call(void 0, ()=>{o.current&&(clearTimeout(o.current),o.current=null)},[]),g=_react.useCallback.call(void 0, async()=>{if(!(m.current||d.current||w!=="connected"||u)){m.current=!0,d.current=!0,v("pending"),o.current=setTimeout(()=>{m.current&&(v("error"),m.current=!1)},hn);try{await y({chainId:t.chainId}),h(),v("success"),c(Ge,r)}catch (e5){h(),v("error")}finally{m.current=!1}}},[y,w,u,t.chainId,c,r,h]);_react.useEffect.call(void 0, ()=>{m.current||d.current||r===Ge&&a==="pending"&&w==="connected"&&!u&&(e&&n!==t.chainId?g():(v("success"),c(Ge,r)))},[r,a,e,n,t.chainId,w,u,g,c]),_react.useEffect.call(void 0, ()=>()=>h(),[h]);let i=()=>{a==="error"&&(d.current=!1,v("pending"))},p=!s&&a==="error",x=!s&&(a==="pending"||a==="error"),f=p?"var(--widget-status-failed)":"var(--widget-primary)";return _jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full flex-row justify-between space-x-3",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${p?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${f} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${f} 20%, transparent)`,color:f,borderRadius:"var(--widget-radius)"},onClick:p?i:void 0,children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.M,{chain:t.chainId,size:"xs"}),_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-nowrap",children:p?"Retry Switch":`Switch to ${t.name}`}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!s&&a==="pending"&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.U,{size:"5"}),(s||a==="success")&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.O,{className:"h-8 w-8"}),p&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.R,{className:"h-[12px] w-[12px]"})]})]})}),x&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-sans font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:l,children:"Cancel"})]})},nr=vn;var yn=({startTime:e,onExpired:t})=>{let[r,c]=_react.useState.call(void 0, 30),[l,s]=_react.useState.call(void 0, !1),a=_react.useRef.call(void 0, !1),v=_react.useRef.call(void 0, t);v.current=t,_react.useEffect.call(void 0, ()=>{a.current=!1},[e]),_react.useEffect.call(void 0, ()=>{let d=()=>{let n=Date.now(),w=(e>9999999999?e:e*1e3)+30*1e3,u=Math.max(0,w-n),h=Math.floor(u/1e3);if(h<=0){c(0),a.current||(a.current=!0,s(!0),v.current());return}c(h),s(!1)};if(l)return;d();let o=setInterval(d,1e3);return()=>clearInterval(o)},[e,l]);let m=d=>{let o=Math.floor(d/60),n=d%60;return`${o.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`};return l?null:_jsxruntime.jsx.call(void 0, "span",{className:"text-xs font-sans",children:m(r)})},ir=yn;function Nn(e){return e.name==="UserRejectedRequestError"||e.message.includes("User rejected")||e.message.includes("rejected")||e.message.includes("denied")||e.message.includes("cancelled")||e.message.includes("canceled")}var ye="signingOrder";async function En(e,t,r,c,l){let s=_optionalChain([e, 'access', _64 => _64.transaction, 'optionalAccess', _65 => _65.encoded]),a=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _66 => _66.to]), () => (e.to)),v=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _67 => _67.data]), () => (e.data)),m=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _68 => _68.value]), () => (e.value));if(!a)throw new Error('Transaction step missing "to" address');let d=_optionalChain([s, 'optionalAccess', _69 => _69.chainId]),o=e.chainKey||l,n=d||(o?_chunkT2K2NOGZcjs.E.call(void 0, o):void 0);if(!n)throw new Error(`Unknown chain: ${o}`);let y=_chunkT2K2NOGZcjs.h.call(void 0, )[n],w=await r({account:t,chain:y,to:a,data:v||"0x",value:BigInt(m||"0")});return await _core.waitForTransactionReceipt.call(void 0, c,{hash:w,chainId:n}),w}var In=({base:e,baseAmount:t,quote:r,quoteAmount:c,userAddress:l,reviewState:s,goToNextStep:a,cancel:v,isWrappingPair:m,isUnwrappingPair:d,restartSigningFlow:o,onSwapInitiated:n,onOrderSubmitted:y,onSwapComplete:w,startPolling:u,trackNativeTransaction:h})=>{let g=_chunkT2K2NOGZcjs.r.call(void 0, ye,s),[i,p]=_react.useState.call(void 0, "idle"),x=_react.useRef.call(void 0, !1),f=_react.useRef.call(void 0, null),k=_wagmi.useConfig.call(void 0, ),{isReconnecting:P}=_wagmi.useAccount.call(void 0, ),{rfqQuote:S,stop:U,refresh:W}=Be(),{data:N}=_wagmi.useWalletClient.call(void 0, {chainId:e.chainId}),{switchChain:E}=_wagmi.useSwitchChain.call(void 0, ),{sendTransactionAsync:I}=_wagmi.useSendTransaction.call(void 0, ),M=_nullishCoalesce(_optionalChain([S, 'optionalAccess', _70 => _70._receivedAt]), () => (0)),D=_react.useCallback.call(void 0, ()=>M?Date.now()>=M+30*1e3:!1,[M]),Y=_react.useCallback.call(void 0, async()=>{if(x.current||!["idle","error"].includes(i))return;if(!_optionalChain([S, 'optionalAccess', _71 => _71.id])||!_optionalChain([S, 'optionalAccess', _72 => _72._receivedAt])){p("error");return}if(!Gt(S.id,S._receivedAt).canSubmit){p("stale");return}x.current=!0;try{if(!N)throw new Error("Wallet client not available");Xt();let R=_nullishCoalesce(S.userSteps, () => ([])),$;for(let O of R)if(O.type==="TRANSACTION"){p("submitting");let z=O.chainKey||S.srcChainKey,te=z?_chunkT2K2NOGZcjs.E.call(void 0, z):void 0;te&&_optionalChain([N, 'access', _73 => _73.chain, 'optionalAccess', _74 => _74.id])!==te&&(await E({chainId:te}),await new Promise(Ve=>setTimeout(Ve,800))),$=await En(O,l,I,k,S.srcChainKey),h($,O.description||`Tx on ${z}`)}else O.type==="SIGNATURE"&&(p("signing"),await Qt({quote:S,signatureStep:O,userAddress:l,walletClient:N}));Kt(S.id,S._receivedAt),_optionalChain([y, 'optionalCall', _75 => _75(S.id)]),u(S.id,{baseToken:e,quoteToken:r}),_optionalChain([n, 'optionalCall', _76 => _76()]),U(),p("success"),a(ye,s),_optionalChain([w, 'optionalCall', _77 => _77(S.id)])}catch(R){R instanceof Error&&Nn(R),p("error")}finally{x.current=!1}},[i,S,N,e,r,l,U,u,a,s,w,E,I,n,y,h,k]);_react.useEffect.call(void 0, ()=>{if(s===ye&&U(),g&&i!=="success"){p("success"),a(ye,s);return}if(i==="success"){a(ye,s);return}if(s===ye&&i==="idle"&&!_optionalChain([S, 'optionalAccess', _78 => _78.id])){p("refreshingQuote"),W();return}if(s===ye&&i==="idle"&&N&&!x.current&&!P){let C=_optionalChain([S, 'optionalAccess', _79 => _79.id])||null;C&&f.current!==C&&(f.current=C,Y())}},[g,s,i,N,P,Y,a,_optionalChain([S, 'optionalAccess', _80 => _80.id]),W,U]),_react.useEffect.call(void 0, ()=>{i==="refreshingQuote"&&_optionalChain([S, 'optionalAccess', _81 => _81.id])&&p("idle")},[i,_optionalChain([S, 'optionalAccess', _82 => _82.id])]),_react.useEffect.call(void 0, ()=>{s!==ye&&(f.current=null)},[s]),_react.useEffect.call(void 0, ()=>{let C=setInterval(()=>{D()&&!x.current&&i!=="submitting"&&i!=="success"&&p("stale")},1e3);return()=>clearInterval(C)},[D,i]);let H=()=>{i==="error"&&!x.current&&(f.current=null,p("idle"))},L=_react.useCallback.call(void 0, ()=>{f.current=null,p("refreshingQuote"),W()},[W]),T=_react.useCallback.call(void 0, ()=>{o?o(!0):v()},[o,v]),F=()=>i==="error"?"Retry swap":i==="signing"?"Sign Swap Order":i==="submitting"?"Submitting...":i==="refreshingQuote"?"Refreshing Quote...":i==="stale"?"Quote Stale":"Sign & Submit",B=!g&&(i==="error"||i==="stale"),J=B?"var(--widget-status-failed)":"var(--widget-primary)";return _jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full flex-row justify-between space-x-3",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${B?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${J} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${J} 20%, transparent)`,color:J,borderRadius:"var(--widget-radius)"},onClick:!g&&i==="error"?H:i==="stale"?T:void 0,children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.N,{asset:e,size:"xs",noChain:!0}),_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-nowrap",children:F()}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),M>0&&i!=="success"&&i!=="error"&&i!=="stale"&&_jsxruntime.jsx.call(void 0, ir,{startTime:M,onExpired:()=>p("stale")}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!g&&(i==="idle"||i==="signing"||i==="submitting"||i==="refreshingQuote")&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.U,{size:"5"}),(g||i==="success")&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.O,{className:"h-8 w-8"}),!g&&(i==="error"||i==="stale")&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.R,{className:"h-[12px] w-[12px]"})]})]})}),!g&&i==="error"&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-sans font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:v,children:"Cancel"})]})},lr=In;var Pn=()=>_jsxruntime.jsxs.call(void 0, "svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M18 13V19C18 20.1046 17.1046 21 16 21H5C3.89543 21 3 20.1046 3 19V8C3 6.89543 3.89543 6 5 6H11",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),_jsxruntime.jsx.call(void 0, "path",{d:"M15 3H21V9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),_jsxruntime.jsx.call(void 0, "path",{d:"M10 14L21 3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),$n="trackingTx",ur={pending:{icon:_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.U,{size:"5"}),buttonText:"Trade Pending",showNewSwap:!1,statusVar:"var(--widget-primary)",clickable:!1},received:{icon:_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.U,{size:"5"}),buttonText:"Trade Received",showNewSwap:!1,statusVar:"var(--widget-primary)",clickable:!1},completed:{icon:_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.O,{className:"h-5 w-5"}),buttonText:"View Transaction",showNewSwap:!1,statusVar:"var(--widget-status-completed)",clickable:!0},failed:{icon:_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.X,{}),buttonText:"Retry Swap",showNewSwap:!0,statusVar:"var(--widget-status-failed)",clickable:!0},cancelled:{icon:_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.X,{}),buttonText:"View Transaction",showNewSwap:!1,statusVar:"var(--widget-status-failed)",clickable:!0}},Un=({orderHash:e,base:t,quote:r,baseAmount:c,quoteAmount:l,reviewState:s,onNewSwap:a,onRetry:v,status:m})=>{let d=_chunkT2K2NOGZcjs.r.call(void 0, $n,s),o=ur[m]||ur.pending,n=_chunkTXQ6Q4S3cjs.d.call(void 0, u=>u.explorerUrl);_react.useEffect.call(void 0, ()=>{if(m==="completed"){let u=setTimeout(a,15e3);return()=>clearTimeout(u)}},[m,a]);let y=()=>{m==="failed"?v():(m==="completed"||m==="cancelled")&&n&&window.open(n,"_blank","noopener,noreferrer")},w=o.statusVar;return _jsxruntime.jsx.call(void 0, "div",{className:"flex flex-row justify-between space-x-3 w-full px-4",children:_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${o.clickable?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${w} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${w} 20%, transparent)`,color:w,borderRadius:"var(--widget-radius)"},onClick:o.clickable?y:void 0,children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[_jsxruntime.jsx.call(void 0, "div",{className:"flex h-6 w-6 items-center justify-center rounded-full overflow-hidden shrink-0",children:o.icon}),_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-nowrap",children:o.buttonText}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),o.clickable&&_jsxruntime.jsx.call(void 0, "div",{className:"flex h-6 w-6 items-center justify-center",children:m==="failed"?_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.W,{}):_jsxruntime.jsx.call(void 0, Pn,{})})]})})})},dr=Un;var Vn=15e3,Ye="unwrapping",_n=({needsToUnwrap:e,amount:t,chainId:r,token:c,reviewState:l,setReviewState:s,goToNextStep:a,cancel:v,delayedClose:m})=>{let d=_chunkT2K2NOGZcjs.r.call(void 0, Ye,l),[o,n]=_react.useState.call(void 0, "idle"),y=Yt(),{writeContractAsync:w}=_wagmi.useWriteContract.call(void 0, ),{address:u}=_chunk34N36GUDcjs.a.call(void 0, ),h=Oe(),g=_react.useRef.call(void 0, !1),i=_react.useRef.call(void 0, !1),p=_react.useRef.call(void 0, null),{status:x}=_wagmi.useAccount.call(void 0, ),f=_react.useCallback.call(void 0, ()=>{p.current&&(clearTimeout(p.current),p.current=null)},[]),k=_react.useCallback.call(void 0, async()=>{if(!(g.current||i.current||!u||x!=="connected")){g.current=!0,i.current=!0,n("pending"),p.current=setTimeout(()=>{g.current&&(n("error"),g.current=!1)},Vn);try{let N=_chunkT2K2NOGZcjs.c.call(void 0, r);if(!N)throw new Error(`No config for chain ${r}`);let E=_nullishCoalesce(N.wrappedAsset.decimals, () => (N.nativeAsset.decimals)),I=_viem.parseUnits.call(void 0, t.toString(),E);await y.mutateAsync({chainId:r,accountAddress:u,amountRaw:I,writeContractAsync:w});let M={symbol:N.nativeAsset.symbol,name:N.nativeAsset.name,address:_chunkT2K2NOGZcjs.a,decimals:N.nativeAsset.decimals,chainId:r},D={symbol:N.wrappedAsset.symbol,name:N.wrappedAsset.name,address:N.wrappedAsset.address,decimals:N.wrappedAsset.decimals,chainId:r};h({type:"unwrap",tokens:[{asset:M,userAddress:u},{asset:D,userAddress:u}]}),f(),n("success"),a(Ye,l),await m()}catch (e6){f(),n("error")}finally{g.current=!1}}},[u,x,r,t,y,w,h,a,l,m,f]);_react.useEffect.call(void 0, ()=>{g.current||i.current||l===Ye&&o==="idle"&&x==="connected"&&(e?k():(n("success"),a(Ye,l)))},[l,o,e,x,k,a]),_react.useEffect.call(void 0, ()=>()=>f(),[f]);let P=()=>{o==="error"&&(i.current=!1,n("idle"))},S=!d&&o==="error",U=!d&&(o==="pending"||o==="idle"||o==="error"),W=S?"var(--widget-status-failed)":"var(--widget-primary)";return _jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full flex-row justify-between space-x-3",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${S?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${W} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${W} 20%, transparent)`,color:W,borderRadius:"var(--widget-radius)"},onClick:S?P:void 0,children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-nowrap",children:S?"Retry Unwrap":c?`Unwrap ${c.symbol}`:"Unwrap Native Token"}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!d&&(o==="pending"||o==="idle")&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.U,{size:"5"}),(d||o==="success")&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.O,{className:"h-8 w-8"}),S&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.R,{className:"h-[12px] w-[12px]"})]})]})}),U&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-sans font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:v,children:"Cancel"})]})},gr=_n;var Qn=15e3,Je="wrapping",jn=({needsToWrap:e,amount:t,chainId:r,token:c,reviewState:l,setReviewState:s,goToNextStep:a,cancel:v,delayedClose:m,isWrappingPair:d})=>{let o=_chunkT2K2NOGZcjs.r.call(void 0, Je,l),[n,y]=_react.useState.call(void 0, "idle"),w=Jt(),{writeContractAsync:u}=_wagmi.useWriteContract.call(void 0, ),{address:h}=_chunk34N36GUDcjs.a.call(void 0, ),g=Oe(),i=_react.useRef.call(void 0, !1),p=_react.useRef.call(void 0, !1),x=_react.useRef.call(void 0, null),{status:f}=_wagmi.useAccount.call(void 0, ),k=_react.useCallback.call(void 0, ()=>{x.current&&(clearTimeout(x.current),x.current=null)},[]),P=_react.useCallback.call(void 0, async()=>{if(!(i.current||p.current||!h||f!=="connected")){i.current=!0,p.current=!0,y("pending"),x.current=setTimeout(()=>{i.current&&(y("error"),i.current=!1)},Qn);try{let E=_chunkT2K2NOGZcjs.c.call(void 0, r);if(!E)throw new Error(`No config for chain ${r}`);let I=_viem.parseUnits.call(void 0, t.toString(),E.nativeAsset.decimals);await w.mutateAsync({chainId:r,accountAddress:h,amountRaw:I,writeContractAsync:u});let M={symbol:E.nativeAsset.symbol,name:E.nativeAsset.name,address:_chunkT2K2NOGZcjs.a,decimals:E.nativeAsset.decimals,chainId:r},D={symbol:E.wrappedAsset.symbol,name:E.wrappedAsset.name,address:E.wrappedAsset.address,decimals:E.wrappedAsset.decimals,chainId:r};g({type:"wrap",tokens:[{asset:M,userAddress:h},{asset:D,userAddress:h}]}),k(),y("success"),a(Je,l),d&&await m()}catch (e7){k(),y("error")}finally{i.current=!1}}},[h,f,r,t,w,u,g,a,l,m,d,k]);_react.useEffect.call(void 0, ()=>{i.current||p.current||l===Je&&n==="idle"&&f==="connected"&&(e?P():(y("success"),a(Je,l)))},[l,n,e,f,P,a]),_react.useEffect.call(void 0, ()=>()=>k(),[k]);let S=()=>{n==="error"&&(p.current=!1,y("idle"))},U=!o&&n==="error",W=!o&&(n==="pending"||n==="idle"||n==="error"),N=U?"var(--widget-status-failed)":"var(--widget-primary)";return _jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full flex-row justify-between space-x-3",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${U?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${N} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${N} 20%, transparent)`,color:N,borderRadius:"var(--widget-radius)"},onClick:U?S:void 0,children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-nowrap",children:U?"Retry Wrap":c?`Wrap ${c.symbol}`:"Wrap Native Token"}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!o&&(n==="pending"||n==="idle")&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.U,{size:"5"}),(o||n==="success")&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.O,{className:"h-8 w-8"}),U&&_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.R,{className:"h-[12px] w-[12px]"})]})]})}),W&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-sans font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:v,children:"Cancel"})]})},vr=jn;var $a=({base:e,baseAmount:t,quote:r,quoteAmount:c,userAddress:l,isWrappingPair:s,isUnwrappingPair:a,isBaseGasToken:v,isQuoteGasToken:m,reviewActionProps:d,reviewState:o,setReviewState:n,trackedOrderHash:y,setTrackedOrderHash:w,txStatus:u,onSwapComplete:h,onSwapInitiated:g,onOrderSubmitted:i,onStaleQuoteRestart:p,setExitHandler:x,setRetryHandler:f})=>{let{rfqQuote:k,status:P,liquidityError:S,routingError:U,sizeCapError:W,stop:N,clear:E}=Be(),{clearForm:I}=_chunkT2JA5EHNcjs.e.call(void 0, ),M=_wagmi.useChainId.call(void 0, ),{swapButtonVariant:D,widgetType:Y}=_chunkTXQ6Q4S3cjs.b.call(void 0, ),H=Y==="compact",{trackOrderTransaction:L,trackNativeTransaction:T}=er(),{startPolling:F}=Ft((_,ge,Le)=>{_chunkTXQ6Q4S3cjs.d.getState().setTxStatus(ge),Le&&_chunkTXQ6Q4S3cjs.d.getState().setExplorerUrl(Le),ge==="completed"&&L(_,`Swap ${e.symbol} \u2192 ${r.symbol}`)}),[B,J]=_react.useState.call(void 0, !1),C=_react.useRef.call(void 0, !1),R=_react.useRef.call(void 0, null),$=s,O=a,z=!s&&!a,te=M!==_optionalChain([e, 'optionalAccess', _83 => _83.chainId])&&($||O||z),Ve=_chunkT2K2NOGZcjs.c.call(void 0, e.chainId),_e={chainId:e.chainId,name:_nullishCoalesce(_optionalChain([Ve, 'optionalAccess', _84 => _84.displayName]), () => (`Chain ${e.chainId}`))},G=_react.useCallback.call(void 0, (_,ge)=>{if(ge!==_)return;if(_==="chain"){if($){n("wrapping");return}if(O){n("unwrapping");return}n("signingOrder");return}if(_==="signingOrder"){n("trackingTx");return}if(_==="wrapping"){if(!s){n("signingOrder");return}n("wrapSuccess");return}if(_==="unwrapping"){n("wrapSuccess");return}let Le=_chunkT2K2NOGZcjs.s.call(void 0, _);Le&&n(Le)},[n,s,$,O,z]),le=_react.useCallback.call(void 0, ()=>te?"chain":$?"wrapping":O?"unwrapping":z?"signingOrder":null,[te,$,O,z]),re=_react.useCallback.call(void 0, ()=>{n(null),I()},[I,n]),Te=_react.useCallback.call(void 0, async()=>{n("wrapSuccess");for(let _=0;_<3;_++)await _chunkT2K2NOGZcjs.t.call(void 0, 700);re()},[re,n]),ne=_react.useCallback.call(void 0, async()=>{E(),n("cancelled");for(let _=0;_<3;_++)await _chunkT2K2NOGZcjs.t.call(void 0, 500);re()},[E,re,n]),oe=_react.useCallback.call(void 0, ()=>{y&&(_chunkTXQ6Q4S3cjs.d.getState().stopTracking(),n(null),w(null),I())},[y,n,w,I]),Ue=_react.useCallback.call(void 0, ()=>{n(null),w(null),C.current=!0,_optionalChain([p, 'optionalCall', _85 => _85()])},[n,w,p]),ue=_react.useCallback.call(void 0, ()=>{d&&n(le())},[le,d,n]),Ze=_react.useCallback.call(void 0, (_=!1)=>{_?(C.current=!0,n(null),_optionalChain([p, 'optionalCall', _86 => _86()])):(n(null),R.current=setTimeout(()=>{d&&(n(le()),J(!1))},100))},[n,d,le,p]);_react.useEffect.call(void 0, ()=>{o!==null&&N()},[o,N]),_react.useEffect.call(void 0, ()=>{o!==null&&B&&J(!1)},[o,B]),_react.useEffect.call(void 0, ()=>{_optionalChain([x, 'optionalCall', _87 => _87(oe)])},[x,oe]),_react.useEffect.call(void 0, ()=>(_chunkTXQ6Q4S3cjs.d.getState().setExitHandler(oe),()=>_chunkTXQ6Q4S3cjs.d.getState().setExitHandler(null)),[oe]),_react.useEffect.call(void 0, ()=>{_optionalChain([f, 'optionalCall', _88 => _88(Ue)])},[f,Ue]),_react.useEffect.call(void 0, ()=>()=>{R.current&&clearTimeout(R.current)},[]),_react.useEffect.call(void 0, ()=>{C.current&&P==="fresh"&&_optionalChain([k, 'optionalAccess', _89 => _89.id])&&(C.current=!1,n("signingOrder"))},[P,_optionalChain([k, 'optionalAccess', _90 => _90.id]),n]);let Me=_=>{if(!_)return{backgroundColor:D==="default"?"var(--widget-muted)":"transparent",color:"var(--widget-muted-foreground)",border:D!=="default"?"1px solid var(--widget-border)":"none",borderRadius:"var(--widget-radius)"};switch(D){case"outline":return{backgroundColor:"transparent",color:"var(--widget-primary)",border:"1px solid var(--widget-primary)",borderRadius:"var(--widget-radius)"};case"ghost":return{backgroundColor:"transparent",color:"var(--widget-primary)",border:"none",borderRadius:"var(--widget-radius)"};default:return{backgroundColor:"var(--widget-primary)",color:"var(--widget-primary-foreground)",borderRadius:"var(--widget-radius)"}}},Re=`w-full ${H?"py-2":"py-3"} text-sm font-sans font-medium transition-colors cursor-pointer mt-1`;if(o===null&&!s&&!a){if(B)return _jsxruntime.jsx.call(void 0, "button",{className:Re,disabled:!0,style:{...Me(!1),opacity:.6,cursor:"not-allowed"},children:"Getting fresh quote..."});let _=()=>S?"Insufficient Liquidity":U?"Route Not Available":W?"Size Cap Exceeded":!k&&P==="polling"?"Getting Quote...":k?"Swap":"Enter Amount",ge=!!d;return _jsxruntime.jsx.call(void 0, "button",{onClick:ge?ue:void 0,disabled:!ge,className:`${Re} disabled:opacity-40 disabled:cursor-not-allowed`,style:Me(ge),children:_()})}return o===null&&a?_jsxruntime.jsx.call(void 0, "button",{onClick:d?ue:void 0,disabled:!d,className:`${Re} disabled:opacity-40 disabled:cursor-not-allowed`,style:Me(!!d),children:"Unwrap"}):o===null&&s?_jsxruntime.jsx.call(void 0, "button",{onClick:d?ue:void 0,disabled:!d,className:`${Re} disabled:opacity-40 disabled:cursor-not-allowed`,style:Me(!!d),children:"Wrap"}):o==="success"?_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col gap-2 w-full",children:_jsxruntime.jsx.call(void 0, "button",{className:`w-full ${H?"py-2":"py-3"} text-sm font-sans font-medium cursor-default`,style:{backgroundColor:"color-mix(in srgb, var(--widget-status-completed) 15%, transparent)",color:"var(--widget-status-completed)",border:"1px solid color-mix(in srgb, var(--widget-status-completed) 20%, transparent)",borderRadius:"var(--widget-radius)"},children:"Order Placed"})}):o==="wrapSuccess"?_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col gap-2 w-full",children:_jsxruntime.jsx.call(void 0, "button",{className:`w-full ${H?"py-2":"py-3"} text-sm font-sans font-medium cursor-default`,style:{backgroundColor:"color-mix(in srgb, var(--widget-status-completed) 15%, transparent)",color:"var(--widget-status-completed)",border:"1px solid color-mix(in srgb, var(--widget-status-completed) 20%, transparent)",borderRadius:"var(--widget-radius)"},children:s?"Wrapped Successfully":"Unwrapped Successfully"})}):o==="cancelled"?_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col gap-2 w-full",children:_jsxruntime.jsx.call(void 0, "button",{onClick:re,className:`w-full ${H?"py-2":"py-3"} text-sm font-sans font-medium cursor-pointer`,style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 15%, transparent)",color:"var(--widget-status-failed)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",borderRadius:"var(--widget-radius)"},children:"Order Cancelled"})}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full",children:[o==="chain"&&te&&_jsxruntime.jsx.call(void 0, nr,{requiredChain:_e,needsChainSwitch:te&&M!==e.chainId,reviewState:o,goToNextStep:G,cancel:ne}),o==="wrapping"&&$&&_jsxruntime.jsx.call(void 0, vr,{needsToWrap:$,amount:t,chainId:e.chainId,token:e,reviewState:o,setReviewState:n,goToNextStep:G,cancel:ne,delayedClose:Te,isWrappingPair:s}),o==="unwrapping"&&O&&_jsxruntime.jsx.call(void 0, gr,{needsToUnwrap:O,amount:t,chainId:e.chainId,token:e,reviewState:o,setReviewState:n,goToNextStep:G,cancel:ne,delayedClose:Te}),o==="signingOrder"&&z&&_jsxruntime.jsx.call(void 0, lr,{base:e,baseAmount:t,quote:r,quoteAmount:c,userAddress:l,reviewState:o,goToNextStep:G,cancel:ne,restartSigningFlow:Ze,onSwapInitiated:g,onOrderSubmitted:i,isWrappingPair:s,isUnwrappingPair:a,onSwapComplete:h,startPolling:F,trackNativeTransaction:T}),o==="trackingTx"&&y&&_jsxruntime.jsx.call(void 0, dr,{orderHash:y,base:e,quote:r,baseAmount:t,quoteAmount:c,reviewState:o,status:u,onNewSwap:oe,onRetry:Ue}),o&&!["chain","wrapping","unwrapping","approval","signingOrder","trackingTx","success","wrapSuccess","cancelled"].includes(o)&&_jsxruntime.jsx.call(void 0, "button",{disabled:!0,className:`w-full ${H?"py-2":"py-3"} text-sm font-sans font-medium`,style:{backgroundColor:"var(--widget-muted)",color:"var(--widget-muted-foreground)",borderRadius:"var(--widget-radius)"},children:"Processing..."})]})};var _shallow = require('zustand/react/shallow');var br={pending:"var(--widget-status-pending)",received:"var(--widget-status-received)",completed:"var(--widget-status-completed)",failed:"var(--widget-status-failed)",cancelled:"var(--widget-status-failed)"},Jn=({status:e})=>{let t=_nullishCoalesce(br[e], () => (br.pending));switch(e){case"completed":return _jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.O,{className:"h-6 w-6"});case"failed":case"cancelled":return _jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.X,{className:"h-6 w-6"});default:return _jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.U,{size:"5",color:t})}};function Zn(e){if(e===0)return"0";let t=Math.abs(e);return t>=1e4?e.toFixed(0):t>=1e3?e.toFixed(1):t>=100?e.toFixed(2):t>=1?e.toFixed(4):t>=.01?e.toFixed(6):e.toExponential(3)}function xr(e){try{let t=new URL(e).pathname.split("/"),r=t[t.length-1];return r&&r.startsWith("0x")?r:null}catch (e8){return null}}function Cr(e){let t=e.length;return t<=4?48:t<=6?40:t<=8?34:28}var xt=()=>_jsxruntime.jsxs.call(void 0, "svg",{className:"w-3 h-3 shrink-0",style:{color:"var(--widget-secondary-foreground)"},viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M18 13V19C18 20.1046 17.1046 21 16 21H5C3.89543 21 3 20.1046 3 19V8C3 6.89543 3.89543 6 5 6H11",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),_jsxruntime.jsx.call(void 0, "path",{d:"M15 3H21V9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),_jsxruntime.jsx.call(void 0, "path",{d:"M10 14L21 3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),es=()=>_jsxruntime.jsxs.call(void 0, "svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 195 321",fill:"var(--widget-secondary-foreground)",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "path",{fillRule:"evenodd",d:"M195,189C195,207.02,195,225.04,194.7,243.21C193.68,244.78,192.9,246.17,192.25,247.63C189.71,253.38,187.74,259.46,184.6,264.86C169.44,290.97,147.86,309.46,118.54,318.86C116.44,319.55,114.72,320.27,113,321C97.65,321,82.29,321,66.36,320.66C64.21,319.86,62.64,319.4,60.77,318.73C34.51,310.12,15.56,293.82,4.22,268.85C3.68,267.66,2.1,266.94,1,266C1,242.31,1,218.62,1.29,194.79C2.84,192.16,4.11,189.7,5.34,187.22C18.42,160.94,39.89,144.07,66.64,133.63C76.92,129.62,87.87,127.33,98.67,124.2C97.79,123.24,96.8,121.93,95.59,120.86C85.84,112.3,75.95,103.89,66.3,95.21C55.93,85.86,45.02,76.96,35.71,66.63C21.14,50.5,20.04,23.08,45.41,9.57C50.08,7.08,55.12,5.26,59.93,3.03C60.76,2.64,61.32,1.69,62,1C86.69,1,111.38,1,136.23,1.32C138.04,2.32,139.67,3.01,141.32,3.67C147.64,6.19,154.12,8.39,160.26,11.32C166.83,14.45,172.19,19.18,175.44,25.95C179.39,34.19,178.09,43.36,172.05,49.56C165.75,56.03,157.21,57.8,148.78,52.89C142.4,49.17,136.86,43.96,131.1,39.23C122.63,32.28,115.05,23.88,105.74,18.38C87.78,7.76,68.84,9.07,51.16,19.53C38.68,26.91,36.37,41.4,45.53,52.71C50.38,58.69,56.45,64,62.83,68.36C87.15,84.99,111.86,101.05,136.34,117.44C162.56,135,183.88,156.57,193.26,187.79C193.42,188.32,194.4,188.6,195,189ZM77.06,146.49C61.39,155.71,51.27,169.26,45.93,186.5C39.48,207.32,39.44,228.5,42.93,249.76C45.84,267.48,53.16,282.95,66.59,295.39C83.82,311.34,108.85,312.86,127.37,298.41C138.98,289.35,146.05,277.03,149.48,263.04C161.53,213.92,148.4,171.97,112.16,137.05C111.13,136.06,108.71,135.6,107.31,136.05C97.38,139.22,87.54,142.7,77.06,146.49Z"}),_jsxruntime.jsx.call(void 0, "path",{d:"M118.83,199C121.61,197.69,122.77,198.41,122.77,201.27C122.71,217.43,122.78,233.58,122.65,249.73C122.65,250.83,121.43,251.92,120.77,253.01C119.97,252.05,118.63,251.17,118.45,250.1C116.32,237.7,113.36,235.12,100.61,235.02C98.12,235,95.62,234.98,93.12,235.01C81.26,235.16,77.72,238.3,75.94,249.84C75.74,251.15,74.39,252.28,73.57,253.49C73.11,253.23,72.64,252.98,72.17,252.73C72.17,234.81,72.17,216.88,72.17,198.96C72.49,198.62,72.81,198.28,73.13,197.93C74.09,198.95,75.72,199.85,75.92,201C78.13,213.8,80.95,216.26,94.05,216.3C97.38,216.31,100.72,216.44,104.04,216.27C113.28,215.79,117.15,212.05,118.22,202.81C118.35,201.65,118.47,200.49,118.83,199Z"})]}),ts=({orderHash:e,base:t,quote:r,baseAmount:c,quoteAmount:l,status:s})=>{let[a,v]=_react.useState.call(void 0, !1),[m,d]=_react.useState.call(void 0, !0),o=_react.useRef.call(void 0, null),n=_react.useRef.call(void 0, Date.now()),[y,w]=_react.useState.call(void 0, null),u=_react.useRef.call(void 0, null),{isRecipientInputOpen:h,recipient:g,explorerUrl:i}=_chunkTXQ6Q4S3cjs.d.call(void 0, _shallow.useShallow.call(void 0, T=>({isRecipientInputOpen:T.isRecipientInputOpen,recipient:T.recipient,explorerUrl:T.explorerUrl})));_react.useEffect.call(void 0, ()=>{s==="received"&&(o.current=Date.now())},[s]),_react.useEffect.call(void 0, ()=>{if(s==="completed"&&!y){let T=o.current||n.current;w((Date.now()-T)/1e3)}},[s,y]),_react.useEffect.call(void 0, ()=>()=>{u.current&&clearTimeout(u.current)},[]);let p=_react.useCallback.call(void 0, ()=>{if(!_optionalChain([navigator, 'access', _91 => _91.clipboard, 'optionalAccess', _92 => _92.writeText]))return;let T=i?_nullishCoalesce(xr(i), () => (e)):e;navigator.clipboard.writeText(T).then(()=>{v(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>v(!1),2e3)}).catch(()=>{})},[e,i]),x=_chunkT2K2NOGZcjs.o.call(void 0, c),f=_chunkT2K2NOGZcjs.o.call(void 0, l),k=s==="completed"||s==="failed"||s==="cancelled",P=!k,S=c&&l?c/l:0,U=_chunkT2K2NOGZcjs.c.call(void 0, t.chainId),W=_chunkT2K2NOGZcjs.c.call(void 0, r.chainId),N=_nullishCoalesce(_optionalChain([U, 'optionalAccess', _93 => _93.displayName]), () => (`Chain ${t.chainId}`)),E=_nullishCoalesce(_optionalChain([W, 'optionalAccess', _94 => _94.displayName]), () => (`Chain ${r.chainId}`)),I=t.chainId!==r.chainId,M=_nullishCoalesce(_optionalChain([U, 'optionalAccess', _95 => _95.estimatedTimeMs]), () => (0)),D=_nullishCoalesce(_optionalChain([W, 'optionalAccess', _96 => _96.estimatedTimeMs]), () => (0)),Y=(I?M+D:M)/1e3,H=i?_nullishCoalesce(xr(i), () => (e)):e,L=`${H.slice(0,6)} \u2026 ${H.slice(-4)}`;return _jsxruntime.jsxs.call(void 0, "div",{className:"relative w-full flex flex-col",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"mx-4 mt-2",style:{backgroundColor:"var(--widget-secondary)"},children:[_jsxruntime.jsx.call(void 0, "div",{className:"p-5",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-3 mb-3",children:[_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.N,{asset:t,size:"md",noChain:!0}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-xl font-thin uppercase",style:{color:"var(--widget-foreground)"},children:t.symbol}),_jsxruntime.jsx.call(void 0, "p",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:t.name})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1",style:{backgroundColor:"color-mix(in srgb, var(--widget-muted-foreground) 20%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-muted-foreground) 30%, transparent)"},children:[_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.M,{chain:t.chainId,size:"xs"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs pt-0.5",style:{color:"var(--widget-muted-foreground)"},children:N})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"text-right",children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-thin tracking-tight font-sans",style:{color:"var(--widget-foreground)",fontSize:`${Cr(x)}px`,transition:"font-size 0.1s ease-out"},children:x}),t.price&&_jsxruntime.jsxs.call(void 0, "p",{className:"text-xs mt-1 font-sans",style:{color:"var(--widget-muted-foreground)"},children:["$",(t.price*c).toFixed(2)]})]})]})}),_jsxruntime.jsxs.call(void 0, "div",{className:"relative",children:[_jsxruntime.jsx.call(void 0, "div",{style:{borderTop:"1px solid var(--widget-border)"}}),_jsxruntime.jsx.call(void 0, "div",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",children:_jsxruntime.jsx.call(void 0, "div",{className:"w-10 h-10 rounded-full flex items-center justify-center",style:{backgroundColor:"var(--widget-secondary)",border:"1px solid var(--widget-border)"},children:_jsxruntime.jsx.call(void 0, Jn,{status:s})})})]}),_jsxruntime.jsx.call(void 0, "div",{className:"p-5",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-3 mb-3",children:[_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.N,{asset:r,size:"md",noChain:!0}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-xl font-thin uppercase",style:{color:"var(--widget-foreground)"},children:r.symbol}),_jsxruntime.jsx.call(void 0, "p",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:r.name})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1",style:{backgroundColor:"color-mix(in srgb, var(--widget-muted-foreground) 20%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-muted-foreground) 30%, transparent)"},children:[_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.M,{chain:r.chainId,size:"xs"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs pt-0.5",style:{color:"var(--widget-muted-foreground)"},children:E})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"text-right",children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-thin tracking-tight font-sans",style:{color:"var(--widget-foreground)",fontSize:`${Cr(f)}px`,transition:"font-size 0.1s ease-out"},children:f}),r.price&&_jsxruntime.jsxs.call(void 0, "p",{className:"text-xs mt-1 font-sans",style:{color:"var(--widget-muted-foreground)"},children:["$",(r.price*l).toFixed(2)]})]})]})})]}),h&&g&&_jsxruntime.jsx.call(void 0, "div",{className:"mx-4 mt-2 px-5 pb-2",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2 p-2 rounded-full",style:{backgroundColor:"var(--widget-secondary)"},children:[_jsxruntime.jsx.call(void 0, "div",{className:"flex h-5 w-5 items-center justify-center overflow-hidden rounded-full",style:{backgroundColor:"var(--widget-muted)"},children:_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",children:"\u{1F464}"})}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:"To:"}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs font-sans",style:{color:"var(--widget-foreground)"},children:[g.slice(0,6),"...",g.slice(-4)]})]})}),_jsxruntime.jsxs.call(void 0, "div",{className:"px-4 mt-4",style:{borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"},children:[_jsxruntime.jsx.call(void 0, "div",{className:"relative box-border flex flex-row h-8 w-full items-center cursor-pointer",role:"button",tabIndex:0,onClick:()=>d(!m),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),d(!m))},children:_jsxruntime.jsx.call(void 0, "div",{className:"flex h-full items-center w-full overflow-hidden",style:{color:"var(--widget-muted-foreground)"},children:_jsxruntime.jsxs.call(void 0, "div",{className:"translate-y-px font-sans flex w-full flex-row items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center gap-2 whitespace-nowrap",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center gap-1",children:[_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.N,{asset:r,size:"3xs",noChain:!0,className:"mb-0.5"}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:["1 ",r.symbol]})]}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:"="}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center gap-1",children:[_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.N,{asset:t,size:"3xs",noChain:!0,className:"mb-0.5"}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:[Zn(S)," ",t.symbol]})]}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:t.price?`\u2248 $${(t.price*S).toFixed(2)}`:""})]}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs ml-2 transition-transform duration-200 shrink-0",style:{color:"var(--widget-muted-foreground)",transform:m?"rotate(180deg)":"rotate(0deg)",display:"inline-block"},children:"\u25BE"})]})})}),_jsxruntime.jsx.call(void 0, "div",{className:"overflow-hidden transition-all duration-200",style:{maxHeight:m?"200px":"0px",opacity:m?1:0},children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1 pb-1 font-sans",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:"USD Value"}),_jsxruntime.jsxs.call(void 0, "span",{style:{color:"var(--widget-secondary-foreground)"},children:["$",t.price?(t.price*c).toFixed(2):"\u2014"]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{style:{color:"var(--widget-muted-foreground)"},children:"Order Type"}),_jsxruntime.jsx.call(void 0, "span",{style:{color:"var(--widget-secondary-foreground)"},children:"RFQ (Limit)"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:"Transaction"}),i?_jsxruntime.jsxs.call(void 0, "a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 transition-colors hover:opacity-80",style:{color:"var(--widget-secondary-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:a?"Copied!":L}),_jsxruntime.jsx.call(void 0, xt,{})]}):_jsxruntime.jsxs.call(void 0, "button",{type:"button",onClick:p,className:"flex items-center gap-1 cursor-pointer transition-colors",style:{color:"var(--widget-secondary-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{style:{color:"var(--widget-secondary-foreground)"},children:a?"Copied!":L}),_jsxruntime.jsx.call(void 0, xt,{})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:k?"Speed":"Est. Time"}),_jsxruntime.jsx.call(void 0, "span",{style:{color:"var(--widget-secondary-foreground)"},children:y?`${y.toFixed(2)}s`:Y>0?`~${Y}s`:"\u2014"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:"Route"}),_jsxruntime.jsxs.call(void 0, "a",{href:"https://www.aori.io",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 transition-colors hover:opacity-80",style:{color:"var(--widget-secondary-foreground)"},children:[_jsxruntime.jsx.call(void 0, es,{}),"Aori",_jsxruntime.jsx.call(void 0, xt,{})]})]})]})})]})]})},Fa= exports.x =ts;exports.a = Nr; exports.b = Oe; exports.c = is; exports.d = gs; exports.e = Be; exports.f = Fr; exports.g = ys; exports.h = Rs; exports.i = Os; exports.j = Ds; exports.k = Fs; exports.l = Vt; exports.m = Ft; exports.n = Bt; exports.o = en; exports.p = Qt; exports.q = tn; exports.r = Gt; exports.s = Kt; exports.t = Xt; exports.u = Yt; exports.v = Jt; exports.w = $a; exports.x = Fa;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
|
|
2
|
+
var _chunkEDQ3SNQJcjs = require('./chunk-EDQ3SNQJ.cjs');var _chunkTXQ6Q4S3cjs = require('./chunk-TXQ6Q4S3.cjs');var _chunkT2K2NOGZcjs = require('./chunk-T2K2NOGZ.cjs');var _react = require('react'); var _react2 = _interopRequireDefault(_react);var _jsxruntime = require('react/jsx-runtime');var P=({toggle:D,side:y,onChainSelect:u,onChainHover:p,containerHeight:E})=>{let[i,m]=_react.useState.call(void 0, ""),l=_chunkT2K2NOGZcjs.x.call(void 0, i,300),x=_chunkTXQ6Q4S3cjs.c.call(void 0, ),s=_chunkT2K2NOGZcjs.e.call(void 0, x),{effectivePrioritizedInputChains:w}=_chunkEDQ3SNQJcjs.a.call(void 0, ),n=y==="base"?w:[],d=_react.useMemo.call(void 0, ()=>{if(n.length===0)return s;let e=new Set(n),r=new Map(n.map((o,c)=>[o,c])),S=s.filter(o=>e.has(o.id)).sort((o,c)=>(_nullishCoalesce(r.get(o.id), () => (0)))-(_nullishCoalesce(r.get(c.id), () => (0)))),I=s.filter(o=>!e.has(o.id));return[...S,...I]},[s,n]),f=_react2.default.useMemo(()=>{if(!l)return d;let e=l.toLowerCase();return d.filter(r=>r.displayName.toLowerCase().includes(e)||r.name.toLowerCase().includes(e)||r.id.toString().includes(e))},[d,l]),N=_react.useCallback.call(void 0, e=>u(e),[u]);return _jsxruntime.jsxs.call(void 0, "div",{className:"w-full h-full flex flex-col",children:[_jsxruntime.jsx.call(void 0, "div",{className:"flex-shrink-0",children:_jsxruntime.jsxs.call(void 0, "div",{className:"relative mt-3",children:[_jsxruntime.jsx.call(void 0, "input",{className:"w-full h-10 px-4 text-sm",style:{backgroundColor:"var(--widget-card)",color:"var(--widget-card-foreground)",border:"1px solid var(--widget-border)"},placeholder:"Search chains by name or chain ID...",autoComplete:"off",value:i,onChange:e=>m(e.target.value.toLowerCase())}),i&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>m(""),className:"absolute right-2 top-1/2 -translate-y-1/2 cursor-pointer rounded-full px-2 py-1 text-xs",style:{backgroundColor:"var(--widget-secondary)",color:"var(--widget-secondary-foreground)",border:"1px solid var(--widget-border)"},children:"clear"})]})}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex-1 min-h-0 overflow-auto mt-2 pb-4",style:{backgroundColor:"var(--widget-background)"},children:[_jsxruntime.jsx.call(void 0, "p",{className:"my-2 ml-4 text-xs",style:{color:"var(--widget-muted-foreground)"},children:i?"Search Results":"Available Chains"}),f.length===0?_jsxruntime.jsx.call(void 0, "div",{className:"px-4 py-3 text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Chain Not Found"}):f.map(e=>_jsxruntime.jsxs.call(void 0, "button",{type:"button",className:"w-full flex items-center justify-between p-3 cursor-pointer transition-colors",style:{borderBottom:"1px solid var(--widget-border)"},onClick:()=>N(e.id),onMouseEnter:()=>_optionalChain([p, 'optionalCall', _ => _(e.displayName)]),onMouseLeave:()=>_optionalChain([p, 'optionalCall', _2 => _2(null)]),children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center space-x-3 min-w-0 flex-1",children:[_jsxruntime.jsx.call(void 0, "div",{className:"flex-shrink-0",children:_jsxruntime.jsx.call(void 0, _chunkT2K2NOGZcjs.M,{chain:e.id,size:"md"})}),_jsxruntime.jsx.call(void 0, "span",{className:"text-base font-medium truncate",style:{color:"var(--widget-foreground)"},children:e.displayName})]}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs font-sans",style:{color:"var(--widget-muted-foreground)"},children:["Chain ID: ",e.id]})]},e.id))]})]})},F= exports.a =P;exports.a = F;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{a as b}from"./chunk-BJXIGJVO.js";import{c as C}from"./chunk-74M7ZIF5.js";import{M as h,e as g,x as v}from"./chunk-DUMYILH6.js";import k,{useCallback as M,useMemo as L,useState as z}from"react";import{jsx as t,jsxs as a}from"react/jsx-runtime";var P=({toggle:D,side:y,onChainSelect:u,onChainHover:p,containerHeight:E})=>{let[i,m]=z(""),l=v(i,300),x=C(),s=g(x),{effectivePrioritizedInputChains:w}=b(),n=y==="base"?w:[],d=L(()=>{if(n.length===0)return s;let e=new Set(n),r=new Map(n.map((o,c)=>[o,c])),S=s.filter(o=>e.has(o.id)).sort((o,c)=>(r.get(o.id)??0)-(r.get(c.id)??0)),I=s.filter(o=>!e.has(o.id));return[...S,...I]},[s,n]),f=k.useMemo(()=>{if(!l)return d;let e=l.toLowerCase();return d.filter(r=>r.displayName.toLowerCase().includes(e)||r.name.toLowerCase().includes(e)||r.id.toString().includes(e))},[d,l]),N=M(e=>u(e),[u]);return a("div",{className:"w-full h-full flex flex-col",children:[t("div",{className:"flex-shrink-0",children:a("div",{className:"relative mt-3",children:[t("input",{className:"w-full h-10 px-4 text-sm",style:{backgroundColor:"var(--widget-card)",color:"var(--widget-card-foreground)",border:"1px solid var(--widget-border)"},placeholder:"Search chains by name or chain ID...",autoComplete:"off",value:i,onChange:e=>m(e.target.value.toLowerCase())}),i&&t("button",{type:"button",onClick:()=>m(""),className:"absolute right-2 top-1/2 -translate-y-1/2 cursor-pointer rounded-full px-2 py-1 text-xs",style:{backgroundColor:"var(--widget-secondary)",color:"var(--widget-secondary-foreground)",border:"1px solid var(--widget-border)"},children:"clear"})]})}),a("div",{className:"flex-1 min-h-0 overflow-auto mt-2 pb-4",style:{backgroundColor:"var(--widget-background)"},children:[t("p",{className:"my-2 ml-4 text-xs",style:{color:"var(--widget-muted-foreground)"},children:i?"Search Results":"Available Chains"}),f.length===0?t("div",{className:"px-4 py-3 text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Chain Not Found"}):f.map(e=>a("button",{type:"button",className:"w-full flex items-center justify-between p-3 cursor-pointer transition-colors",style:{borderBottom:"1px solid var(--widget-border)"},onClick:()=>N(e.id),onMouseEnter:()=>p?.(e.displayName),onMouseLeave:()=>p?.(null),children:[a("div",{className:"flex items-center space-x-3 min-w-0 flex-1",children:[t("div",{className:"flex-shrink-0",children:t(h,{chain:e.id,size:"md"})}),t("span",{className:"text-base font-medium truncate",style:{color:"var(--widget-foreground)"},children:e.displayName})]}),a("span",{className:"text-xs font-sans",style:{color:"var(--widget-muted-foreground)"},children:["Chain ID: ",e.id]})]},e.id))]})]})},F=P;export{F as a};
|