@aori/mega-swap-widget 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +9 -1
  2. package/dist/AssetSelectionMenu-4E576X3D.cjs +2 -0
  3. package/dist/AssetSelectionMenu-ZFY7XFRX.js +2 -0
  4. package/dist/ChainSelectionMenu-SKXLHK3S.js +2 -0
  5. package/dist/ChainSelectionMenu-VU3SIBVL.cjs +2 -0
  6. package/dist/{SwapFormHorizontal-XMZKEAIL.js → SwapFormHorizontal-GI4X7ISS.js} +1 -1
  7. package/dist/{SwapFormHorizontal-ACRBI6GC.cjs → SwapFormHorizontal-V557YBX2.cjs} +1 -1
  8. package/dist/{SwapFormSplit-SOC2XMBW.js → SwapFormSplit-52RBMJIO.js} +1 -1
  9. package/dist/{SwapFormSplit-XHAGOXQX.cjs → SwapFormSplit-PQCS3BPT.cjs} +1 -1
  10. package/dist/{WidgetWalletPanel-KZFLFLUD.js → WidgetWalletPanel-XYV3YL4I.js} +1 -1
  11. package/dist/{WidgetWalletPanel-FQDNFYFL.cjs → WidgetWalletPanel-YBMN5KZH.cjs} +1 -1
  12. package/dist/{chunk-F7IECVJU.js → chunk-4BQRVCQR.js} +1 -1
  13. package/dist/{chunk-Z2BLIAFE.js → chunk-4LJJMEOG.js} +1 -1
  14. package/dist/{chunk-JSWDMAZQ.js → chunk-726CI6GC.js} +1 -1
  15. package/dist/{chunk-XUTR7YYC.cjs → chunk-DUIRZSBV.cjs} +1 -1
  16. package/dist/{chunk-CHDFHEPH.js → chunk-EW2OR6CJ.js} +1 -1
  17. package/dist/{chunk-TWJY6EY4.js → chunk-FDQKBTWP.js} +1 -1
  18. package/dist/{chunk-E44WNKS4.cjs → chunk-HTWUZKYO.cjs} +1 -1
  19. package/dist/{chunk-BX3KCZRT.cjs → chunk-LXEKOQAG.cjs} +1 -1
  20. package/dist/{chunk-NQ4QSGGF.cjs → chunk-MCT3UZTP.cjs} +1 -1
  21. package/dist/{chunk-537OMWA3.cjs → chunk-UZWGYG2S.cjs} +1 -1
  22. package/dist/{chunk-4XEJKRRM.js → chunk-XYF2YBR3.js} +1 -1
  23. package/dist/{chunk-C3X6NJIB.cjs → chunk-XZRXVBSB.cjs} +1 -1
  24. package/dist/index.cjs +2 -2
  25. package/dist/index.js +1 -1
  26. package/package.json +1 -1
  27. package/dist/AssetSelectionMenu-INISSBWT.js +0 -2
  28. package/dist/AssetSelectionMenu-ZT2PDBHV.cjs +0 -2
  29. package/dist/ChainSelectionMenu-N65VG257.js +0 -2
  30. package/dist/ChainSelectionMenu-URYJUECJ.cjs +0 -2
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{a as vr}from"./chunk-OPN7WCJR.js";import{c as he,f as Ne}from"./chunk-JSWDMAZQ.js";import{B as tt,C as rt,J as Rt,K as nt,O as Me,P as ce,Q as Y,T as ge,U as At,V as De,W as G,Y as kt,Z as We,_ as Nt,b as Te,c as _e,e as j,j as vt,m as Re,o as Ae,q as ke,s as xt,t as re,u as Ct,v as Ze,x as et,y as St,z as Tt}from"./chunk-CHDFHEPH.js";import{a as ne}from"./chunk-46H44R7V.js";import{b as yr}from"./chunk-73CB2I7U.js";import{useQueryClient as xr}from"@tanstack/react-query";import{useCallback as Cr,useEffect as It,useRef as Et}from"react";function Sr(e){if(e.length===0)return 5e3;let u=Math.max(...e.map(r=>j(r)?.blockTimeMs??2e3));return Math.min(5e3,Math.max(1e3,u*2+1e3))}var Tr=()=>{let{address:e}=ne(),t=Nt(),s=xr(),l=Et(null),u=Et(!0),r=Cr(a=>{if(!e)return;let h=[...new Set(a.tokens.map(p=>p.asset.chainId))],b=Sr(h);l.current&&(clearTimeout(l.current),l.current=null),l.current=setTimeout(async()=>{if(l.current=null,!!u.current)try{let p=a.tokens.map(f=>({chainId:f.asset.chainId,tokenAddress:f.asset.address})),i=await Rt(e,p);if(i.balances.length===0)return;if(a.tokens.length>=2){let f=a.tokens[0].asset,c=a.tokens[1].asset,x=nt.swap(e,f.chainId,f.address,c.chainId,c.address);s.setQueryData(x,i)}let n=nt.bulk(e,t),w=s.getQueryData(n);if(w){let f=w.balances.map(c=>i.balances.find(g=>g.chainId===c.chainId&&g.token.toLowerCase()===c.token.toLowerCase())??c);for(let c of i.balances)f.some(x=>x.chainId===c.chainId&&x.token.toLowerCase()===c.token.toLowerCase())||f.push(c);for(let c of a.tokens)if(!i.balances.some(g=>g.chainId===c.asset.chainId&&g.token.toLowerCase()===c.asset.address.toLowerCase())){let g=f.findIndex(o=>o.chainId===c.asset.chainId&&o.token.toLowerCase()===c.asset.address.toLowerCase());g!==-1&&(f[g]={...f[g],balance:"0",shiftedBalance:"0"})}s.setQueryData(n,{balances:f})}}catch{}},b)},[e,t,s]);return It(()=>(u.current=!0,()=>{u.current=!1,l.current&&(clearTimeout(l.current),l.current=null)}),[]),{triggerBalanceUpdate:r}},st=class extends EventTarget{emit(t){this.dispatchEvent(new CustomEvent("balance-update",{detail:t}))}},ot=new st,Ee=()=>e=>ot.emit(e),ts=()=>{let{triggerBalanceUpdate:e}=Tr();It(()=>{let t=s=>{e(s.detail)};return ot.addEventListener("balance-update",t),()=>ot.removeEventListener("balance-update",t)},[e])};import{createContext as Rr,useCallback as le,useContext as Ar,useEffect as Ot,useMemo as kr,useRef as se,useState as ye}from"react";import{formatUnits as Nr,parseUnits as Er}from"viem";import{jsx as Ur}from"react/jsx-runtime";var $t=Rr(void 0),Pt=1e4,Ir=3e4,Or=1e3,Pr=2;function $r(e){return e.find(s=>s.routeSteps?.[0]?.type==="AORI_V1")??e[0]}var ls=({children:e,recipient:t})=>{let{address:s}=ne(),l=t||s,[u,r]=ye("idle"),[a,h]=ye("idle"),[b,p]=ye(null),[i,n]=ye(null),[w,f]=ye(!1),[c,x]=ye(!1),[g,o]=ye(!1),m=se(null),y=se(null),d=se(null),T=se(null),P=se(null),C=se(0),$=se(0),L=se(0),N=se(!1),E=se(new Map),I=le(()=>{d.current&&clearTimeout(d.current),T.current&&clearTimeout(T.current),P.current&&clearTimeout(P.current),d.current=null,T.current=null,P.current=null},[]),U=le(()=>{I(),m.current=null,C.current=0,r(()=>N.current?"fresh":"idle")},[I]),B=le(()=>{U(),y.current=null,p(null),n(null),f(!1),x(!1),o(!1),E.current.clear(),r("idle"),h("idle")},[U]),oe=le(v=>{if(!v)return;T.current&&clearTimeout(T.current);let S=Math.max(0,v+Ir-Date.now());T.current=setTimeout(()=>{r(O=>O==="idle"?"idle":"stale")},S)},[]),H=le(async(v,S)=>{let{inputToken:O,outputToken:A,inputAmount:q,setOutputAmount:Z}=v;if(!O||!A||!q||parseFloat(q)<=0||Date.now()-($.current||0)<Pt-10)return;let Be=++C.current;try{if(!O?.decimals||!A?.decimals)return;let z=rt(O.chainId)||j(O.chainId)?.key||"",ie=rt(A.chainId)||j(A.chainId)?.key||"";if(!z||!ie)throw new Error("Unknown chain");let ee=Er(q.toString(),O.decimals).toString(),Ce={srcChainKey:z,dstChainKey:ie,srcTokenAddress:et(O.address),dstTokenAddress:et(A.address),amount:ee,srcWalletAddress:s||"0x0000000000000000000000000000000000000000",dstWalletAddress:l||s||"0x0000000000000000000000000000000000000000",options:{amountType:"EXACT_SRC_AMOUNT",feeTolerance:{type:"PERCENT",amount:2}}};$.current=Date.now();let te=await fetch(`${Re()}/quotes`,{method:"POST",headers:Ae(),body:JSON.stringify(Ce),signal:AbortSignal.timeout(15e3)});if(!te.ok){let Se=(await te.json().catch(()=>({})))?.message||te.statusText;throw Object.assign(new Error(Se),{status:te.status})}let me=await te.json();if(Be!==C.current||m.current!==S)return;let $e=me.quotes??[],ae=$r($e);if(!ae)throw Object.assign(new Error("No quotes returned"),{emptyQuotes:!0});let Je=Number(Nr(xt(ae.dstAmount),A.decimals));typeof Z=="function"&&Z(Je),ae._receivedAt=Date.now(),p(ae),n(null),f(!1),r("fresh"),oe(ae._receivedAt),S&&E.current.delete(S)}catch(z){if(Be!==C.current||m.current!==S)return;let ie=z?.status,ee=z instanceof Error?z.message:"",Ce=!!z?.emptyQuotes;if((ie===400||Ce||ee.includes("Quote request failed"))&&S){let me=(E.current.get(S)||0)+1;if(E.current.set(S,me),me>=Pr){x(!0),I(),m.current=null;return}}if(ee.toLowerCase().includes("order cap exceeded")){o(!0),I(),m.current=null;return}if(ee.toLowerCase().includes("insufficient executor balance")){f(!0),I(),m.current=null;return}n(z instanceof Error?z.message:"Unknown error")}},[s,l,oe,I]),W=le((v,S)=>{I(),y.current=v,$.current=0,E.current.delete(S),f(!1),x(!1),o(!1),n(null),r("polling");let O=async()=>{m.current===S&&(await H(v,S),m.current===S&&(d.current=setTimeout(O,Pt)))};O()},[I,H]),R=le(v=>{if(!v?.inputToken||!v?.outputToken||!v?.inputAmount||parseFloat(v.inputAmount)<=0){U();return}let S=y.current;if(S&&S.inputToken?.address===v.inputToken?.address&&S.inputToken?.chainId===v.inputToken?.chainId&&S.outputToken?.address===v.outputToken?.address&&S.outputToken?.chainId===v.outputToken?.chainId&&S.inputAmount===v.inputAmount&&m.current)return;let A=Date.now();if(A-L.current<100)return;L.current=A;let q=`${Date.now()}-${Math.random().toString(36).slice(2)}`;m.current=q,W(v,q)},[W,U]),V=le(({amount:v,inputToken:S,outputToken:O,setOutputAmount:A})=>{A(null),P.current&&clearTimeout(P.current),!v||v===0?(h("idle"),U(),p(null),n(null),f(!1),x(!1),o(!1)):(h("typing"),U(),p(null),f(!1),x(!1),o(!1),n(null),P.current=setTimeout(()=>{h("settled"),S&&O&&v>0&&R({inputToken:S,outputToken:O,inputAmount:v.toString(),setOutputAmount:A})},Or))},[U,R]),F=le(()=>{let v=y.current;if(!v)return;p(null);let S=`${Date.now()}-${Math.random().toString(36).slice(2)}`;m.current=S,r("refreshing"),typeof v.setOutputAmount=="function"&&v.setOutputAmount(null),W(v,S)},[W]);Ot(()=>{N.current=!!b},[b]),Ot(()=>()=>I(),[I]);let X=kr(()=>({status:u,inputState:a,rfqQuote:b,error:i,liquidityError:w,routingError:c,sizeCapError:g,ensureForParams:R,stop:U,refresh:F,clear:B,handleInputChange:V}),[u,a,b,i,w,c,g,R,U,F,B,V]);return Ur($t.Provider,{value:X,children:e})},Ve=()=>{let e=Ar($t);if(e===void 0)throw new Error("useRfq must be used within an RfqProvider");return e};import{createContext as Mr,useContext as Dr}from"react";var Wr=Mr({openConnectModal:()=>{}}),ms=()=>Dr(Wr);import{useCallback as it,useEffect as Ie,useRef as Fe,useState as at}from"react";import{jsx as Oe,jsxs as _r}from"react/jsx-runtime";var Lr=20,Br=({side:e,asset:t,otherAsset:s,isPlacingOrder:l,isWrappingPair:u,isUnwrappingPair:r})=>{let{baseAmount:a,quoteAmount:h,setBaseAmount:b,setQuoteAmount:p}=Ne(),{amountInputVariant:i,hideAmountInputSymbol:n,widgetType:w}=Te(),f=w==="compact",[c,x]=e==="base"?[b,p]:[p,b],g=!t||e==="quote"||l,o=f?32:i==="default"?64:32,[m,y]=at(o),[d,T]=at(""),P=Fe(null),C=Fe(null),$=Fe(null),L=Fe(null),N="USD",E=e==="base"?a:h,[I,U]=at(!1),B=it(()=>{if(i!=="default"){y(o);return}if(!P.current||!C.current||!$.current)return;let W=P.current.offsetWidth,R=20,V=o;for(;V>20&&(C.current.style.fontSize=`${V}px`,$.current.style.fontSize=`${V}px`,!(C.current.offsetWidth+$.current.offsetWidth+R<=W));)V-=1;y(V)},[i,o]),oe=it(W=>{W.key==="."&&d.includes(".")&&W.preventDefault()},[d]),H=it(W=>{let R=W.target.value;if(R==="."&&(R="0."),!/^\d*\.?\d*$/.test(R)||(R.match(/\./g)||[]).length>1)return;if(R.length>1&&R[0]==="0"&&R[1]!=="."&&(R=R.replace(/^0+/,"")||"0"),t?.decimals!==void 0&&R.includes(".")){let[,F]=R.split(".");if(F&&F.length>t.decimals)return}if(R.length>Lr)return;T(R);let V=parseFloat(R);R!==d&&(R===""||R==="0."||R.endsWith(".")?(c(null),e==="base"&&x(null)):!Number.isNaN(V)&&V>=0&&c(V),e==="base"&&p(null),(r||u)&&p(V||0))},[d,c,e,p,t?.decimals,x,r,u]);return Ie(()=>{let W=F=>{if(F===null)return"";let X=t?.decimals;if(X===void 0)return"";let v=F.toString();if(/e/i.test(v)&&(v=Number(F).toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:X})),v.includes(".")){let[S,O]=v.split("."),A=O.slice(0,X);return A?`${S}.${A}`:S}return v};if(E===null){d==="0."||d!==""&&d.endsWith(".")||T("");return}if(!g&&(d.endsWith(".")||d.match(/\.\d*0$/)||d==="0"||d==="0.")&&d!=="")return;let V=parseFloat(d)||0;(d===""||Math.abs(V-E)>1e-10)&&T(W(E))},[E,t?.decimals,d,g]),Ie(()=>{B()},[d,B]),Ie(()=>{U(!0)},[]),Ie(()=>{I&&B()},[I,B]),Ie(()=>{C.current&&L.current&&(L.current.style.width=`${C.current.offsetWidth}px`)},[d]),Ie(()=>{if(!I)return;let W=new ResizeObserver(()=>{I&&B()});return P.current&&W.observe(P.current),()=>W.disconnect()},[I,B]),Oe("div",{ref:P,style:{fontSize:`${m}px`,transition:"font-size 0.05s ease-in-out"},className:`mt-2 box-border flex ${f?i==="normal"?"h-12 my-1":"h-10 my-0.5":i==="normal"?"h-12 my-1":"h-20 my-1"} w-full flex-row items-center ${g?"cursor-default":"cursor-text"}`,onClick:()=>L.current?.focus(),children:_r("div",{className:"relative flex w-full items-center",children:[Oe("label",{htmlFor:`${e}Amount`,className:"sr-only",children:e==="base"?"Input token amount":"Output token amount"}),Oe("input",{ref:L,type:"text",inputMode:"decimal",placeholder:"0",autoComplete:"off",id:`${e}Amount`,value:d,onWheel:W=>W.target.blur(),onKeyDown:oe,onChange:H,style:{transition:"width 0.15s ease-in-out",color:"var(--widget-foreground)",WebkitTextFillColor:"var(--widget-foreground)",opacity:g?.4:1},className:"flex min-w-[45px] whitespace-nowrap bg-transparent placeholder:opacity-50",disabled:g}),Oe("span",{style:{transition:"width 0.15s ease-in-out"},ref:C,className:"pointer-events-none absolute flex whitespace-nowrap invisible",children:d||0}),!n&&i!=="normal"&&Oe("span",{ref:$,className:"ml-2 font-light uppercase",style:{color:"var(--widget-foreground)",opacity:.5,fontSize:`${m}px`},children:t?.symbol?t.symbol.length>6?`${t.symbol.slice(0,6)}...`:t.symbol:N}),(n||i==="normal")&&Oe("span",{ref:$,className:"hidden"})]})})},ys=Br;import{Fragment as ct,jsx as D,jsxs as ue}from"react/jsx-runtime";var Vr=({toggle:e,side:t,asset:s,isPlacingOrder:l})=>{let{baseBalance:u,quoteBalance:r}=Ne(),{tokenDisplay:a,tokenBadgeOrientation:h,widgetType:b}=Te(),p=b==="compact",i=p?"h-10":"h-12",n=p?"h-10 w-10":"h-12 w-12",w=t==="base"?u.formatted?(()=>{let c=parseFloat(u.formatted);return c>=1e8?ke(c):c.toFixed(3)})():void 0:r.formatted?(()=>{let c=parseFloat(r.formatted);return c>=1e8?ke(c):c.toFixed(3)})():void 0,f={role:"button",tabIndex:l?-1:0,"aria-disabled":l,"aria-label":`Select ${t==="base"?"input":"output"} token${s?`: ${s.symbol}`:""}`,onClick:l?void 0:e,onKeyDown:l?void 0:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),e())}};return a==="pill"?D("div",{...f,className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-full cursor-pointer transition-colors ${h==="right"?"ml-auto":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-secondary)",color:"var(--widget-secondary-foreground)"},children:s?ue(ct,{children:[D(Me,{chain:s.chainId,size:"xs"}),D(ce,{className:"rounded-full",asset:s,size:"xxs",noChain:!0}),D("span",{className:"text-xs font-medium uppercase",children:s.symbol}),D(De,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]}):ue(ct,{children:[D("span",{className:"text-xs opacity-70",children:"Select"}),D(De,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]})}):a==="ghost"?ue("div",{...f,className:"inline-flex items-center gap-1.5 cursor-pointer transition-opacity hover:opacity-70 py-1",style:{color:"var(--widget-foreground)"},children:[s?ue(ct,{children:[D(Me,{chain:s.chainId,size:"xs"}),D(ce,{className:"rounded-full",asset:s,size:"xxs",noChain:!0}),D("span",{className:"text-sm font-medium uppercase",children:s.symbol})]}):D("span",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Select token"}),D(De,{className:"w-1.5 opacity-50"})]}):D("div",{...f,className:`relative ${i} 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:D("div",{className:"relative flex h-full w-full flex-row items-center",children:s?ue("div",{className:"relative flex h-full w-full flex-row items-center",children:[D("div",{className:`${n} pl-px flex items-center justify-center`,children:D(ce,{className:"rounded-full",asset:s,size:"md"})}),ue("div",{className:"flex h-full w-full flex-row items-center justify-between pl-1.5 pr-7",children:[ue("div",{className:"flex h-full flex-col justify-center",children:[D("p",{className:"text-sm font-medium uppercase",style:{color:"var(--widget-secondary-foreground)"},children:s.symbol}),ue("span",{className:"text-2xs font-mono",style:{color:"var(--widget-secondary-foreground)",opacity:.6},children:[s.address?.slice(0,6),"...",s.address?.slice(-4)]})]}),w!==void 0&&ue("div",{className:"flex flex-col text-right",children:[D("p",{className:"text-2xs",style:{color:"var(--widget-secondary-foreground)",opacity:.5},children:"Balance"}),D("span",{className:"font-mono text-xs tabular-nums",style:{color:"var(--widget-secondary-foreground)"},children:w})]})]}),D(De,{className:"absolute right-3 top-1/2 w-1.5 translate-y-[-50%]",style:{color:"var(--widget-secondary-foreground)",opacity:.6}})]}):D("div",{className:"flex h-full w-full items-center justify-center",children:D("span",{className:"text-sm",style:{color:"var(--widget-secondary-foreground)",opacity:.7},children:"Select token"})})})})},Rs=Vr;var Mt=yr(vr(),1);import{useState as qe,useEffect as Qe}from"react";import{jsx as K,jsxs as Ut}from"react/jsx-runtime";var Fr=()=>{let[e,t]=qe(null),[s,l]=qe(""),u=Tt(s,1e3),[r,a]=qe(!1),[h,b]=qe("");Qe(()=>{he.getState().setRecipient(e)},[e]),Qe(()=>{l(e||"")},[e]);let p=n=>{let w=n.target.value;r&&(a(!1),b(""),t(null)),l(w),w===""&&t(null)};Qe(()=>{u===""||!u?(a(!1),b(""),t(null)):St(u)?(a(!1),b(""),t(u)):(a(!0),b("Invalid wallet address..."),t(null),l(""))},[u]),Qe(()=>{if(r){let n=setTimeout(()=>{t(null),l(""),a(!1),b("")},2e3);return()=>clearTimeout(n)}},[r]);let i=()=>{t(null),l(""),a(!1),b("")};return K("div",{className:"w-full",children:Ut("div",{className:"relative flex flex-row items-center",children:[K("input",{type:"password",style:{display:"none"},"aria-hidden":"true",tabIndex:-1}),K("label",{htmlFor:"recipient-address",className:"sr-only",children:"Recipient wallet address"}),K("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&&!r?K("img",{className:"h-full w-full rounded-full object-cover",src:(0,Mt.makeGradient)(e),alt:"Recipient avatar"}):K(At,{className:"h-5 w-5",style:{color:r?"var(--widget-destructive)":"var(--widget-muted-foreground)"}})}),K("div",{className:"absolute left-12 top-1.5 -translate-y-1 text-xs font-medium opacity-60",style:{color:r?"var(--widget-destructive)":"var(--widget-muted-foreground)"},"aria-hidden":"true",children:"To:"}),K("input",{id:"recipient-address",className:"mono block h-10 w-full items-center pl-12 pt-4 pr-8 text-xs",style:{backgroundColor:r?"color-mix(in srgb, var(--widget-destructive) 10%, transparent)":"transparent",color:r?"var(--widget-destructive)":"var(--widget-foreground)",outline:"none",opacity:r?.9:1},placeholder:r?h:"Enter recipient address...",value:s,onChange:p,spellCheck:!1,"aria-invalid":r,"aria-describedby":r?"recipient-error":void 0}),r&&K("span",{id:"recipient-error",className:"sr-only",children:h}),e&&!r&&Ut("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:i,"aria-label":"Clear recipient",children:[K("svg",{className:"h-2.5 w-2.5",viewBox:"0 -0.5 21 21",fill:"none",children:K("g",{fill:"currentColor",fillRule:"evenodd",children:K("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)"})})}),K("span",{className:"sr-only",children:"Clear recipient"})]})]})})},Ps=Fr;var qr=["SUCCEEDED","FAILED","COMPLETED","CANCELLED"];async function Dt(e,t,s={}){let{onStatusChange:l,onComplete:u,onError:r,interval:a=4e3,timeout:h=3e5,txHash:b,signal:p}=s,i=null,n=Date.now(),w=0,f=8,c=null,x=b?`?txHash=${b}`:"";return new Promise((g,o)=>{let m=async()=>{try{if(p?.aborted){c&&clearTimeout(c),o(new DOMException("Polling aborted","AbortError"));return}if(Date.now()-n>h){c&&clearTimeout(c);let P=new Error("Order status polling timed out");r?.(P),o(P);return}let y=await fetch(`${t}/status/${e}${x}`,{headers:Ae(),signal:p});if(y.status===404){c=setTimeout(m,a);return}if(!y.ok)throw new Error(`Failed to fetch order status: ${await y.text()}`);let d=await y.json();if(!d||typeof d!="object"||!d.status)throw new Error(`Invalid status response format: ${JSON.stringify(d)}`);w=0;let T=d.status.toUpperCase();if(T!==i&&(i=T,l?.(d)),qr.includes(T)){c&&clearTimeout(c),u?.(d),g(d);return}c=setTimeout(m,a)}catch(y){if(y instanceof Error&&y.name==="AbortError"){c&&clearTimeout(c),o(y);return}if(++w>=f){c&&clearTimeout(c);let d=y instanceof Error?y:new Error(String(y));r?.(d),o(d);return}c=setTimeout(m,a)}};m()})}import{useCallback as je,useEffect as Qr,useRef as ze}from"react";function Wt(e){let t=e.toUpperCase();return t==="SUCCEEDED"||t==="COMPLETED"?"completed":t==="FAILED"?"failed":t==="CANCELLED"?"cancelled":t==="PROCESSING"?"received":"pending"}var Lt=e=>{let t=ze(new Map),s=ze(new Map),l=ze(new Map),u=ze(0),r=je(()=>++u.current,[]),{address:a}=ne(),h=Ee(),b=je((n,w)=>{if(t.current.get(n))return;w&&s.current.set(n,w),t.current.set(n,!0);let f=u.current,c=new AbortController;l.current.set(n,c);let x=w?.baseToken?.chainId===1;Dt(n,Re(),{interval:x?1e3:500,timeout:3e5,signal:c.signal,onStatusChange:g=>{if(!g?.status)return;let o=Wt(g.status);if(e?.(n,o),o==="completed"&&a){let m=s.current.get(n);if(m&&(m.baseToken||m.quoteToken)){let y=[];m.baseToken&&y.push({asset:m.baseToken,userAddress:a}),m.quoteToken&&y.push({asset:m.quoteToken,userAddress:a}),h({type:"swap",tokens:y})}}["completed","failed","cancelled"].includes(o)&&(t.current.delete(n),s.current.delete(n)),f!==u.current&&(t.current.delete(n),s.current.delete(n))},onComplete:g=>{g?.status&&e?.(n,Wt(g.status)),t.current.delete(n),s.current.delete(n)},onError:()=>{t.current.delete(n),s.current.delete(n)}}).catch(g=>{g instanceof Error&&g.name==="AbortError"||(t.current.delete(n),s.current.delete(n),l.current.delete(n))})},[a,h,e]),p=je(n=>{let w=l.current.get(n);w&&(w.abort(),l.current.delete(n)),r(),t.current.delete(n),s.current.delete(n)},[r]),i=je(()=>{for(let n of l.current.values())n.abort();l.current.clear(),r(),t.current.clear(),s.current.clear()},[r]);return Qr(()=>()=>i(),[i]),{startPolling:b,stopPolling:p,stopAllPolling:i,isPolling:n=>t.current.has(n)}};import{createContext as jr,useContext as zr}from"react";var Gr=jr({registerTransaction:()=>{},enabled:!1}),Bt=()=>zr(Gr);import{signTypedData as Kr}from"viem/actions";function Vt(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 _t(e){if(e.chain?.id)return e.chain.id;let t=e.getChainId?.();return t!=null?await t:null}var Hr=async(e,t)=>{try{if(await _t(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 _t(e)===t}catch(s){throw Vt(s)?new Error("User rejected the chain switch request"):new Error(`Please switch your wallet to the required network (Chain ID: ${t})`)}},Ft=async e=>{let{quote:t,signatureStep:s,userAddress:l,walletClient:u}=e;if(!u)throw new Error("Wallet client not available");if(s.type!=="SIGNATURE"||!s.signature?.typedData)throw new Error("Invalid signature step");try{let r=s.signature.typedData,a={...r.message};for(let i of["inputAmount","outputAmount","startTime","endTime"])a[i]!=null&&(a[i]=BigInt(a[i]));let h=r.domain;if(h.chainId!=null){let i=Number(h.chainId);await Hr(u,i)}let b=await Kr(u,{account:l,domain:h,types:r.types,primaryType:r.primaryType,message:a}),p=await fetch(`${Re()}/submit-signature`,{method:"POST",headers:Ae(),body:JSON.stringify({quoteId:t.id,signatures:[b]})});if(!p.ok){let i=await p.json().catch(()=>({}));throw new Error(i?.message||`Submit failed: ${p.status}`)}return{quoteId:t.id,signature:b}}catch(r){throw Vt(r)?new Error("User rejected the signing request"):r instanceof Error&&r.message.includes("chain")?new Error("Chain switching failed. Please manually switch to the correct network."):r}};var qt="vt_submitted_quotes";var lt=()=>{try{let e=localStorage.getItem(qt);return e?JSON.parse(e):[]}catch{return[]}},Qt=e=>{try{localStorage.setItem(qt,JSON.stringify(e))}catch{}},Xr=e=>{let t=Date.now(),s=typeof e=="string"?new Date(e).getTime():e>9999999999?e:e*1e3;return t<s+3e4},Yr=e=>lt().some(t=>t.quoteId===e),jt=(e,t)=>Yr(e)?{canSubmit:!1,reason:"Order already submitted"}:Xr(t)?{canSubmit:!0}:{canSubmit:!1,reason:"Quote has expired"},zt=(e,t)=>{let s=typeof t=="string"?new Date(t).getTime():t,l=lt();l.push({quoteId:e,submittedAt:Date.now(),createdAt:s}),Qt(l)},Gt=()=>{let e=lt(),t=Date.now(),s=300*1e3,l=e.filter(u=>t-u.submittedAt<s);l.length!==e.length&&Qt(l)};import{useMutation as Jr}from"@tanstack/react-query";import{waitForTransactionReceipt as Zr}from"@wagmi/core";import{wethAbi as en}from"abitype/abis";import{useConfig as tn}from"wagmi";function Kt(){let e=tn();return Jr({mutationFn:async({chainId:t,accountAddress:s,amountRaw:l,writeContractAsync:u})=>{let r=j(t);if(!r)throw new Error(`No wrapping contract for chain ${t}`);let a=r.wrappedAsset.address,h=await u({abi:en,functionName:"withdraw",address:a,account:s,args:[l],chainId:t});if((await Zr(e,{hash:h,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Unwrap transaction did not get successful receipt");return{success:!0,hash:h}}})}import{useMutation as rn}from"@tanstack/react-query";import{waitForTransactionReceipt as nn}from"@wagmi/core";import{wethAbi as sn}from"abitype/abis";import{useConfig as on}from"wagmi";function Ht(){let e=on();return rn({mutationFn:async({chainId:t,accountAddress:s,amountRaw:l,writeContractAsync:u})=>{let r=j(t);if(!r)throw new Error(`No wrapping contract for chain ${t}`);let a=r.wrappedAsset.address,h=await u({abi:sn,functionName:"deposit",address:a,account:s,value:l,chainId:t});if((await nn(e,{hash:h,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Wrap transaction did not get successful receipt");return{success:!0,hash:h}}})}import{useCallback as pe,useEffect as Pe,useRef as gr,useState as Fn}from"react";import{useChainId as qn}from"wagmi";import{useCallback as Xt,useRef as an}from"react";function Yt(){let{registerTransaction:e,enabled:t}=Bt(),s=an(new Set),l=Xt((r,a)=>{!t||s.current.has(r)||(s.current.add(r),e(r,a))},[t,e]),u=Xt((r,a)=>{!t||s.current.has(r)||(s.current.add(r),e(r,a))},[t,e]);return{trackOrderTransaction:l,trackNativeTransaction:u,txTrackingEnabled:t}}import{useEffect as Jt,useState as cn,useCallback as Zt,useRef as ut}from"react";import{useAccount as ln,useChainId as un,useSwitchChain as dn}from"wagmi";import{jsx as we,jsxs as dt}from"react/jsx-runtime";var pn=15e3,Ge="chain",mn=({needsChainSwitch:e,requiredChain:t,reviewState:s,goToNextStep:l,cancel:u})=>{let r=re(Ge,s),[a,h]=cn("pending"),b=ut(!1),p=ut(!1),i=ut(null),n=un(),{switchChainAsync:w}=dn(),{status:f,isReconnecting:c}=ln(),x=Zt(()=>{i.current&&(clearTimeout(i.current),i.current=null)},[]),g=Zt(async()=>{if(!(b.current||p.current||f!=="connected"||c)){b.current=!0,p.current=!0,h("pending"),i.current=setTimeout(()=>{b.current&&(h("error"),b.current=!1)},pn);try{await w({chainId:t.chainId}),x(),h("success"),l(Ge,s)}catch{x(),h("error")}finally{b.current=!1}}},[w,f,c,t.chainId,l,s,x]);Jt(()=>{b.current||p.current||s===Ge&&a==="pending"&&f==="connected"&&!c&&(e&&n!==t.chainId?g():(h("success"),l(Ge,s)))},[s,a,e,n,t.chainId,f,c,g,l]),Jt(()=>()=>x(),[x]);let o=()=>{a==="error"&&(p.current=!1,h("pending"))},m=!r&&a==="error",y=!r&&(a==="pending"||a==="error"),d=m?"var(--widget-status-failed)":"var(--widget-status-pending)";return dt("div",{className:"flex w-full flex-row justify-between space-x-3",children:[we("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${m?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${d} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${d} 20%, transparent)`,color:d,borderRadius:"var(--widget-radius)"},onClick:m?o:void 0,children:dt("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[we(Me,{chain:t.chainId,size:"xs"}),we("p",{className:"whitespace-nowrap",children:m?"Retry Switch":`Switch to ${t.name}`}),we("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),dt("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!r&&a==="pending"&&we(G,{size:"5"}),(r||a==="success")&&we(Y,{className:"h-8 w-8"}),m&&we(ge,{className:"h-[12px] w-[12px]"})]})]})}),y&&we("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm 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:u,children:"Cancel"})]})},er=mn;import{waitForTransactionReceipt as wn}from"@wagmi/core";import{useCallback as Ke,useEffect as He,useState as bn,useRef as or}from"react";import{useAccount as hn,useConfig as yn,useSendTransaction as vn,useSwitchChain as xn,useWalletClient as Cn}from"wagmi";import{useEffect as tr,useRef as rr,useState as nr}from"react";import{jsx as gn}from"react/jsx-runtime";var fn=({startTime:e,onExpired:t})=>{let[s,l]=nr(30),[u,r]=nr(!1),a=rr(!1),h=rr(t);h.current=t,tr(()=>{a.current=!1},[e]),tr(()=>{let p=()=>{let n=Date.now(),f=(e>9999999999?e:e*1e3)+30*1e3,c=Math.max(0,f-n),x=Math.floor(c/1e3);if(x<=0){l(0),a.current||(a.current=!0,r(!0),h.current());return}l(x),r(!1)};if(u)return;p();let i=setInterval(p,1e3);return()=>clearInterval(i)},[e,u]);let b=p=>{let i=Math.floor(p/60),n=p%60;return`${i.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`};return u?null:gn("span",{className:"text-xs font-mono",children:b(s)})},sr=fn;import{jsx as de,jsxs as pt}from"react/jsx-runtime";function Sn(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 be="signingOrder";async function Tn(e,t,s,l,u){let r=e.transaction?.encoded,a=r?.to??e.to,h=r?.data??e.data,b=r?.value??e.value;if(!a)throw new Error('Transaction step missing "to" address');let p=r?.chainId,i=e.chainKey||u,n=p||(i?tt(i):void 0);if(!n)throw new Error(`Unknown chain: ${i}`);let w=vt()[n],f=await s({account:t,chain:w,to:a,data:h||"0x",value:BigInt(b||"0")});return await wn(l,{hash:f,chainId:n}),f}var Rn=({base:e,baseAmount:t,quote:s,quoteAmount:l,userAddress:u,reviewState:r,goToNextStep:a,cancel:h,isWrappingPair:b,isUnwrappingPair:p,restartSigningFlow:i,onSwapInitiated:n,onOrderSubmitted:w,onSwapComplete:f,startPolling:c,trackNativeTransaction:x})=>{let g=re(be,r),[o,m]=bn("idle"),y=or(!1),d=or(null),T=yn(),{isReconnecting:P}=hn(),{rfqQuote:C,stop:$,refresh:L}=Ve(),{data:N}=Cn({chainId:e.chainId}),{switchChain:E}=xn(),{sendTransactionAsync:I}=vn(),U=C?._receivedAt??0,B=Ke(()=>U?Date.now()>=U+30*1e3:!1,[U]),oe=Ke(async()=>{if(y.current||!["idle","error"].includes(o))return;if(!C?.id||!C?._receivedAt){m("error");return}if(!jt(C.id,C._receivedAt).canSubmit){m("stale");return}y.current=!0;try{if(!N)throw new Error("Wallet client not available");Gt();let S=C.userSteps??[],O;for(let A of S)if(A.type==="TRANSACTION"){m("submitting");let q=A.chainKey||C.srcChainKey,Z=q?tt(q):void 0;Z&&N.chain?.id!==Z&&(await E({chainId:Z}),await new Promise(Le=>setTimeout(Le,800))),O=await Tn(A,u,I,T,C.srcChainKey),x(O,A.description||`Tx on ${q}`)}else A.type==="SIGNATURE"&&(m("signing"),await Ft({quote:C,signatureStep:A,userAddress:u,walletClient:N}));zt(C.id,C._receivedAt),w?.(C.id),c(C.id,{baseToken:e,quoteToken:s}),n?.(),$(),m("success"),a(be,r),f?.(C.id)}catch(S){S instanceof Error&&Sn(S)?(d.current=null,m("idle")):m("error")}finally{y.current=!1}},[o,C,N,e,s,u,$,c,a,r,f,E,I,n,w,x,T]);He(()=>{if(r===be&&$(),g&&o!=="success"){m("success"),a(be,r);return}if(o==="success"){a(be,r);return}if(r===be&&o==="idle"&&!C?.id){m("refreshingQuote"),L();return}if(r===be&&o==="idle"&&N&&!y.current&&!P){let v=C?.id||null;v&&d.current!==v&&(d.current=v,oe())}},[g,r,o,N,P,oe,a,C?.id,L,$]),He(()=>{o==="refreshingQuote"&&C?.id&&m("idle")},[o,C?.id]),He(()=>{r!==be&&(d.current=null)},[r]),He(()=>{let v=setInterval(()=>{B()&&!y.current&&o!=="submitting"&&o!=="success"&&m("stale")},1e3);return()=>clearInterval(v)},[B,o]);let H=()=>{o==="error"&&!y.current&&(d.current=null,m("idle"))},W=Ke(()=>{d.current=null,m("refreshingQuote"),L()},[L]),R=Ke(()=>{i?i(!0):h()},[i,h]),V=()=>o==="error"?"Retry swap":o==="signing"?"Sign Swap Order":o==="submitting"?"Submitting...":o==="refreshingQuote"?"Refreshing Quote...":o==="stale"?"Quote Stale":"Sign & Submit",F=!g&&(o==="error"||o==="stale"),X=F?"var(--widget-status-failed)":"var(--widget-status-pending)";return pt("div",{className:"flex w-full flex-row justify-between space-x-3",children:[de("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${F?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${X} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${X} 20%, transparent)`,color:X,borderRadius:"var(--widget-radius)"},onClick:!g&&o==="error"?H:o==="stale"?R:void 0,children:pt("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[de(ce,{asset:e,size:"xs",noChain:!0}),de("p",{className:"whitespace-nowrap",children:V()}),de("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),U>0&&o!=="success"&&o!=="error"&&o!=="stale"&&de(sr,{startTime:U,onExpired:()=>m("stale")}),pt("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!g&&(o==="idle"||o==="signing"||o==="submitting"||o==="refreshingQuote")&&de(G,{size:"5"}),(g||o==="success")&&de(Y,{className:"h-8 w-8"}),!g&&(o==="error"||o==="stale")&&de(ge,{className:"h-[12px] w-[12px]"})]})]})}),!g&&o==="error"&&de("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm 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:h,children:"Cancel"})]})},ir=Rn;import{useEffect as An}from"react";import{jsx as J,jsxs as En}from"react/jsx-runtime";var kn="trackingTx",ar={pending:{icon:J(G,{size:"5"}),buttonText:"Trade Pending",showNewSwap:!1,statusVar:"var(--widget-status-pending)",clickable:!1},received:{icon:J(G,{size:"5"}),buttonText:"Trade Received",showNewSwap:!1,statusVar:"var(--widget-status-received)",clickable:!1},completed:{icon:J(Y,{}),buttonText:"Continue Swapping",showNewSwap:!0,statusVar:"var(--widget-status-completed)",clickable:!0},failed:{icon:J(We,{}),buttonText:"Retry Swap",showNewSwap:!0,statusVar:"var(--widget-status-failed)",clickable:!0},cancelled:{icon:J(We,{}),buttonText:"Continue Swapping",showNewSwap:!0,statusVar:"var(--widget-status-failed)",clickable:!0}},Nn=({orderHash:e,base:t,quote:s,baseAmount:l,quoteAmount:u,reviewState:r,onNewSwap:a,onRetry:h,status:b})=>{let p=re(kn,r),i=ar[b]||ar.pending;An(()=>{if(b==="completed"){let f=setTimeout(a,5e3);return()=>clearTimeout(f)}},[b,a]);let n=()=>{b==="failed"?h():i.showNewSwap&&a()},w=i.statusVar;return J("div",{className:"flex flex-row justify-between space-x-3 w-full",children:J("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${i.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:i.showNewSwap?n:void 0,children:En("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[J("div",{className:"flex h-6 w-6 items-center justify-center rounded-full",children:i.icon}),J("p",{className:"whitespace-nowrap",children:i.buttonText}),J("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),i.showNewSwap&&J("div",{className:"flex h-6 w-6 items-center justify-center",children:J(kt,{})})]})})})},cr=Nn;import{useCallback as lr,useEffect as ur,useState as In,useRef as mt}from"react";import{parseUnits as On}from"viem";import{useAccount as Pn,useWriteContract as $n}from"wagmi";import{jsx as ve,jsxs as ft}from"react/jsx-runtime";var Un=15e3,Xe="unwrapping",Mn=({needsToUnwrap:e,amount:t,chainId:s,token:l,reviewState:u,setReviewState:r,goToNextStep:a,cancel:h,delayedClose:b})=>{let p=re(Xe,u),[i,n]=In("idle"),w=Kt(),{writeContractAsync:f}=$n(),{address:c}=ne(),x=Ee(),g=mt(!1),o=mt(!1),m=mt(null),{status:y}=Pn(),d=lr(()=>{m.current&&(clearTimeout(m.current),m.current=null)},[]),T=lr(async()=>{if(!(g.current||o.current||!c||y!=="connected")){g.current=!0,o.current=!0,n("pending"),m.current=setTimeout(()=>{g.current&&(n("error"),g.current=!1)},Un);try{let N=j(s);if(!N)throw new Error(`No config for chain ${s}`);let E=N.wrappedAsset.decimals??N.nativeAsset.decimals,I=On(t.toString(),E);await w.mutateAsync({chainId:s,accountAddress:c,amountRaw:I,writeContractAsync:f});let U={symbol:N.nativeAsset.symbol,name:N.nativeAsset.name,address:_e,decimals:N.nativeAsset.decimals,chainId:s},B={symbol:N.wrappedAsset.symbol,name:N.wrappedAsset.name,address:N.wrappedAsset.address,decimals:N.wrappedAsset.decimals,chainId:s};x({type:"unwrap",tokens:[{asset:U,userAddress:c},{asset:B,userAddress:c}]}),d(),n("success"),a(Xe,u),await b()}catch{d(),n("error")}finally{g.current=!1}}},[c,y,s,t,w,f,x,a,u,b,d]);ur(()=>{g.current||o.current||u===Xe&&i==="idle"&&y==="connected"&&(e?T():(n("success"),a(Xe,u)))},[u,i,e,y,T,a]),ur(()=>()=>d(),[d]);let P=()=>{i==="error"&&(o.current=!1,n("idle"))},C=!p&&i==="error",$=!p&&(i==="pending"||i==="idle"||i==="error"),L=C?"var(--widget-status-failed)":"var(--widget-status-pending)";return ft("div",{className:"flex w-full flex-row justify-between space-x-3",children:[ve("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${C?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${L} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${L} 20%, transparent)`,color:L,borderRadius:"var(--widget-radius)"},onClick:C?P:void 0,children:ft("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[ve("p",{className:"whitespace-nowrap",children:C?"Retry Unwrap":l?`Unwrap ${l.symbol}`:"Unwrap Native Token"}),ve("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),ft("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!p&&(i==="pending"||i==="idle")&&ve(G,{size:"5"}),(p||i==="success")&&ve(Y,{className:"h-8 w-8"}),C&&ve(ge,{className:"h-[12px] w-[12px]"})]})]})}),$&&ve("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm 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:h,children:"Cancel"})]})},dr=Mn;import{useCallback as pr,useEffect as mr,useState as Dn,useRef as gt}from"react";import{parseUnits as Wn}from"viem";import{useAccount as Ln,useWriteContract as Bn}from"wagmi";import{jsx as xe,jsxs as wt}from"react/jsx-runtime";var _n=15e3,Ye="wrapping",Vn=({needsToWrap:e,amount:t,chainId:s,token:l,reviewState:u,setReviewState:r,goToNextStep:a,cancel:h,delayedClose:b,isWrappingPair:p})=>{let i=re(Ye,u),[n,w]=Dn("idle"),f=Ht(),{writeContractAsync:c}=Bn(),{address:x}=ne(),g=Ee(),o=gt(!1),m=gt(!1),y=gt(null),{status:d}=Ln(),T=pr(()=>{y.current&&(clearTimeout(y.current),y.current=null)},[]),P=pr(async()=>{if(!(o.current||m.current||!x||d!=="connected")){o.current=!0,m.current=!0,w("pending"),y.current=setTimeout(()=>{o.current&&(w("error"),o.current=!1)},_n);try{let E=j(s);if(!E)throw new Error(`No config for chain ${s}`);let I=Wn(t.toString(),E.nativeAsset.decimals);await f.mutateAsync({chainId:s,accountAddress:x,amountRaw:I,writeContractAsync:c});let U={symbol:E.nativeAsset.symbol,name:E.nativeAsset.name,address:_e,decimals:E.nativeAsset.decimals,chainId:s},B={symbol:E.wrappedAsset.symbol,name:E.wrappedAsset.name,address:E.wrappedAsset.address,decimals:E.wrappedAsset.decimals,chainId:s};g({type:"wrap",tokens:[{asset:U,userAddress:x},{asset:B,userAddress:x}]}),T(),w("success"),a(Ye,u),p&&await b()}catch{T(),w("error")}finally{o.current=!1}}},[x,d,s,t,f,c,g,a,u,b,p,T]);mr(()=>{o.current||m.current||u===Ye&&n==="idle"&&d==="connected"&&(e?P():(w("success"),a(Ye,u)))},[u,n,e,d,P,a]),mr(()=>()=>T(),[T]);let C=()=>{n==="error"&&(m.current=!1,w("idle"))},$=!i&&n==="error",L=!i&&(n==="pending"||n==="idle"||n==="error"),N=$?"var(--widget-status-failed)":"var(--widget-status-pending)";return wt("div",{className:"flex w-full flex-row justify-between space-x-3",children:[xe("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${$?"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:$?C:void 0,children:wt("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[xe("p",{className:"whitespace-nowrap",children:$?"Retry Wrap":l?`Wrap ${l.symbol}`:"Wrap Native Token"}),xe("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),wt("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!i&&(n==="pending"||n==="idle")&&xe(G,{size:"5"}),(i||n==="success")&&xe(Y,{className:"h-8 w-8"}),$&&xe(ge,{className:"h-[12px] w-[12px]"})]})]})}),L&&xe("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm 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:h,children:"Cancel"})]})},fr=Vn;import{jsx as Q,jsxs as Qn}from"react/jsx-runtime";var Si=({base:e,baseAmount:t,quote:s,quoteAmount:l,userAddress:u,isWrappingPair:r,isUnwrappingPair:a,isBaseGasToken:h,isQuoteGasToken:b,reviewActionProps:p,reviewState:i,setReviewState:n,trackedOrderHash:w,setTrackedOrderHash:f,txStatus:c,onSwapComplete:x,onSwapInitiated:g,onOrderSubmitted:o,onStaleQuoteRestart:m,setExitHandler:y,setRetryHandler:d})=>{let{rfqQuote:T,status:P,liquidityError:C,routingError:$,sizeCapError:L,stop:N,clear:E}=Ve(),{clearForm:I}=Ne(),U=qn(),{swapButtonVariant:B,widgetType:oe}=Te(),H=oe==="compact",{trackOrderTransaction:W,trackNativeTransaction:R}=Yt(),{startPolling:V}=Lt((_,fe)=>{he.getState().setTxStatus(fe),fe==="completed"&&W(_,`Swap ${e.symbol} \u2192 ${s.symbol}`)}),[F,X]=Fn(!1),v=gr(!1),S=gr(null),O=r,A=a,q=!r&&!a,Z=U!==e?.chainId&&(O||A||q),Le=j(e.chainId),Be={chainId:e.chainId,name:Le?.displayName??`Chain ${e.chainId}`},z=pe((_,fe)=>{if(fe!==_)return;if(_==="chain"){if(O){n("wrapping");return}if(A){n("unwrapping");return}n("signingOrder");return}if(_==="signingOrder"){n("trackingTx");return}if(_==="wrapping"){if(!r){n("signingOrder");return}n("wrapSuccess");return}if(_==="unwrapping"){n("wrapSuccess");return}let yt=Ct(_);yt&&n(yt)},[n,r,O,A,q]),ie=pe(()=>Z?"chain":O?"wrapping":A?"unwrapping":q?"signingOrder":null,[Z,O,A,q]),ee=pe(()=>{n(null),I()},[I,n]),Ce=pe(async()=>{n("wrapSuccess");for(let _=0;_<3;_++)await Ze(700);ee()},[ee,n]),te=pe(async()=>{E(),n("cancelled");for(let _=0;_<3;_++)await Ze(500);ee()},[E,ee,n]),me=pe(()=>{w&&(he.getState().stopTracking(),n(null),f(null),I())},[w,n,f,I]),$e=pe(()=>{n(null),f(null),v.current=!0,m?.()},[n,f,m]),ae=pe(()=>{p&&n(ie())},[ie,p,n]),Je=pe((_=!1)=>{_?(v.current=!0,n(null),m?.()):(n(null),S.current=setTimeout(()=>{p&&(n(ie()),X(!1))},100))},[n,p,ie,m]);Pe(()=>{i!==null&&N()},[i,N]),Pe(()=>{i!==null&&F&&X(!1)},[i,F]),Pe(()=>{y?.(me)},[y,me]),Pe(()=>{d?.($e)},[d,$e]),Pe(()=>()=>{S.current&&clearTimeout(S.current)},[]),Pe(()=>{v.current&&P==="fresh"&&T?.id&&(v.current=!1,n("signingOrder"))},[P,T?.id,n]);let Ue=_=>{if(!_)return{backgroundColor:B==="default"?"var(--widget-muted)":"transparent",color:"var(--widget-muted-foreground)",border:B!=="default"?"1px solid var(--widget-border)":"none",borderRadius:"var(--widget-radius)"};switch(B){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)"}}},Se=`w-full ${H?"py-2":"py-3"} text-sm font-medium transition-colors cursor-pointer mt-1`;if(i===null&&!r&&!a){if(F)return Q("button",{className:Se,disabled:!0,style:{...Ue(!1),opacity:.6,cursor:"not-allowed"},children:"Getting fresh quote..."});let _=()=>C?"Insufficient Liquidity":$?"Route Not Available":L?"Size Cap Exceeded":!T&&P==="polling"?"Getting Quote...":T?"Swap":"Enter Amount",fe=!!p;return Q("button",{onClick:fe?ae:void 0,disabled:!fe,className:`${Se} disabled:opacity-40 disabled:cursor-not-allowed`,style:Ue(fe),children:_()})}return i===null&&a?Q("button",{onClick:p?ae:void 0,disabled:!p,className:`${Se} disabled:opacity-40 disabled:cursor-not-allowed`,style:Ue(!!p),children:"Unwrap"}):i===null&&r?Q("button",{onClick:p?ae:void 0,disabled:!p,className:`${Se} disabled:opacity-40 disabled:cursor-not-allowed`,style:Ue(!!p),children:"Wrap"}):i==="success"?Q("div",{className:"flex flex-col gap-2 w-full",children:Q("button",{className:`w-full ${H?"py-2":"py-3"} text-sm 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"})}):i==="wrapSuccess"?Q("div",{className:"flex flex-col gap-2 w-full",children:Q("button",{className:`w-full ${H?"py-2":"py-3"} text-sm 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:r?"Wrapped Successfully":"Unwrapped Successfully"})}):i==="cancelled"?Q("div",{className:"flex flex-col gap-2 w-full",children:Q("button",{onClick:ee,className:`w-full ${H?"py-2":"py-3"} text-sm 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"})}):Qn("div",{className:"flex w-full",children:[i==="chain"&&Z&&Q(er,{requiredChain:Be,needsChainSwitch:Z&&U!==e.chainId,reviewState:i,goToNextStep:z,cancel:te}),i==="wrapping"&&O&&Q(fr,{needsToWrap:O,amount:t,chainId:e.chainId,token:e,reviewState:i,setReviewState:n,goToNextStep:z,cancel:te,delayedClose:Ce,isWrappingPair:r}),i==="unwrapping"&&A&&Q(dr,{needsToUnwrap:A,amount:t,chainId:e.chainId,token:e,reviewState:i,setReviewState:n,goToNextStep:z,cancel:te,delayedClose:Ce}),i==="signingOrder"&&q&&Q(ir,{base:e,baseAmount:t,quote:s,quoteAmount:l,userAddress:u,reviewState:i,goToNextStep:z,cancel:te,restartSigningFlow:Je,onSwapInitiated:g,onOrderSubmitted:o,isWrappingPair:r,isUnwrappingPair:a,onSwapComplete:x,startPolling:V,trackNativeTransaction:R}),i==="trackingTx"&&w&&Q(cr,{orderHash:w,base:e,quote:s,baseAmount:t,quoteAmount:l,reviewState:i,status:c,onNewSwap:me,onRetry:$e}),i&&!["chain","wrapping","unwrapping","approval","signingOrder","trackingTx","success","wrapSuccess","cancelled"].includes(i)&&Q("button",{disabled:!0,className:`w-full ${H?"py-2":"py-3"} text-sm font-medium`,style:{backgroundColor:"var(--widget-muted)",color:"var(--widget-muted-foreground)",borderRadius:"var(--widget-radius)"},children:"Processing..."})]})};import{useState as wr,useCallback as jn,useRef as bt,useEffect as ht}from"react";import{useShallow as zn}from"zustand/react/shallow";import{jsx as k,jsxs as M}from"react/jsx-runtime";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)"},hr={pending:{title:"Trade Pending",subtitle:"Submitting to network"},received:{title:"Trade Received",subtitle:"Processing settlement"},completed:{title:"Trade Filled",subtitle:"Settlement complete"},failed:{title:"Trade Failed",subtitle:"Settlement unsuccessful"},cancelled:{title:"Trade Cancelled",subtitle:"Order was cancelled"}};function Gn(e){let t=br[e]??br.pending;return{textColor:t,bgColor:`color-mix(in srgb, ${t} 15%, transparent)`,borderColor:`color-mix(in srgb, ${t} 20%, transparent)`,cardBgColor:`color-mix(in srgb, ${t} 8%, transparent)`,cardBorderColor:`color-mix(in srgb, ${t} 15%, transparent)`,iconBgColor:`color-mix(in srgb, ${t} 12%, transparent)`,iconBorderColor:`color-mix(in srgb, ${t} 15%, transparent)`}}var Kn=({status:e})=>{switch(e){case"completed":return k(Y,{});case"failed":case"cancelled":return k(We,{});default:return k(G,{size:"10"})}},Hn=({orderHash:e,base:t,quote:s,baseAmount:l,quoteAmount:u,status:r})=>{let[a,h]=wr(!1),b=bt(null),p=bt(Date.now()),[i,n]=wr(null),w=bt(null),{isRecipientInputOpen:f,recipient:c}=he(zn(d=>({isRecipientInputOpen:d.isRecipientInputOpen,recipient:d.recipient})));ht(()=>{r==="received"&&(b.current=Date.now())},[r]),ht(()=>{if(r==="completed"&&!i){let d=b.current||p.current;n((Date.now()-d)/1e3)}},[r,i]),ht(()=>()=>{w.current&&clearTimeout(w.current)},[]);let x=jn(()=>{navigator.clipboard?.writeText&&navigator.clipboard.writeText(e).then(()=>{h(!0),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>h(!1),2e3)}).catch(()=>{})},[e]),g=hr[r]??hr.pending,o=Gn(r),m=ke(l),y=ke(u);return k("div",{className:"relative w-full h-full overflow-hidden flex flex-col",style:{backgroundColor:o.bgColor,border:`1px var(--widget-border-style) ${o.borderColor}`,backdropFilter:"blur(8px)"},children:M("div",{className:"relative z-10 px-3 pt-5 pb-3 flex-1 flex flex-col",children:[k("div",{className:"flex items-center justify-center mb-2",children:M("div",{className:"flex flex-col items-center gap-1 text-center",children:[k("div",{className:"flex h-10 w-10 items-center justify-center rounded-full border",style:{backgroundColor:o.iconBgColor,borderColor:o.iconBorderColor},children:k("div",{className:"h-7 w-7 flex items-center justify-center",children:k(Kn,{status:r})})}),M("div",{children:[k("h3",{className:"text-xl font-bold",style:{color:o.textColor},children:g.title}),k("p",{className:"text-2xs uppercase tracking-wider",style:{color:o.textColor,opacity:.6},children:g.subtitle})]})]})}),k("div",{className:"flex-1 flex flex-col justify-center",children:M("div",{className:"space-y-1.5",children:[M("div",{className:"flex items-center justify-between backdrop-blur-sm p-2.5 border transition-all duration-300",style:{backgroundColor:o.cardBgColor,borderColor:o.cardBorderColor},children:[M("div",{className:"flex items-center gap-2.5",children:[k(ce,{asset:t,size:"sm"}),M("div",{children:[k("div",{className:"text-sm font-bold",style:{color:o.textColor},children:t.symbol}),k("div",{className:"text-2xs",style:{color:o.textColor,opacity:.5},children:t.name})]})]}),M("div",{className:"text-right",children:[k("div",{className:"text-lg font-bold mono",style:{color:o.textColor},children:m}),t.price&&M("div",{className:"text-2xs mono",style:{color:o.textColor,opacity:.5},children:["$",(t.price*l).toFixed(2)]})]})]}),k("div",{className:"flex justify-center pb-0.5 pt-1",children:k("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border",style:{backgroundColor:o.cardBgColor,borderColor:o.cardBorderColor},children:k("span",{className:"text-base",style:{color:o.textColor},children:"\u2193"})})}),M("div",{className:"flex items-center justify-between backdrop-blur-sm p-2.5 border transition-all duration-300",style:{backgroundColor:o.cardBgColor,borderColor:o.cardBorderColor},children:[M("div",{className:"flex items-center gap-2.5",children:[k(ce,{asset:s,size:"sm"}),M("div",{children:[k("div",{className:"text-sm font-bold",style:{color:o.textColor},children:s.symbol}),k("div",{className:"text-2xs",style:{color:o.textColor,opacity:.5},children:s.name})]})]}),M("div",{className:"text-right",children:[k("div",{className:"text-lg font-bold mono",style:{color:o.textColor},children:y}),s.price&&M("div",{className:"text-2xs mono",style:{color:o.textColor,opacity:.5},children:["$",(s.price*u).toFixed(2)]})]})]}),f&&c&&M("div",{className:"mt-1.5",children:[k("div",{className:"text-2xs mb-0.5 uppercase tracking-wider font-medium",style:{color:o.textColor,opacity:.5},children:"Recipient"}),k("div",{className:"flex items-center backdrop-blur-sm p-2 border transition-all duration-300",style:{backgroundColor:o.cardBgColor,borderColor:o.cardBorderColor},children:M("div",{className:"flex items-center gap-2",children:[k("div",{className:"flex h-5 w-5 items-center justify-center overflow-hidden rounded-full",style:{backgroundColor:o.iconBgColor},children:k("span",{className:"text-2xs",children:"\u{1F464}"})}),M("div",{className:"flex flex-col",children:[k("div",{className:"text-2xs",style:{color:o.textColor,opacity:.5},children:"To:"}),M("div",{className:"text-xs mono",style:{color:o.textColor},children:[c.slice(0,6),"...",c.slice(-4)]})]})]})})]})]})}),M("div",{className:"mt-3 pt-2.5 space-y-1.5",style:{borderTop:`1px solid ${o.cardBorderColor}`},children:[M("div",{role:"button",tabIndex:0,onClick:x,onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),x())},className:"flex items-center justify-between cursor-pointer group hover:opacity-80 transition-opacity",children:[k("div",{className:"text-xs uppercase tracking-wider font-medium",style:{color:o.textColor,opacity:.5},children:a?"Copied!":r==="completed"||r==="failed"||r==="cancelled"?"Order Hash":r==="received"?"Received":"Pending"}),M("div",{className:"text-xs mono transition-colors",style:{color:o.textColor},children:[e.slice(0,6),"...",e.slice(-4)]})]}),r==="completed"&&i?M("div",{className:"flex items-center justify-between",children:[k("div",{className:"text-xs uppercase tracking-wider font-medium",style:{color:o.textColor,opacity:.5},children:"Speed"}),M("div",{className:"text-base font-bold mono",style:{color:o.textColor},children:[i.toFixed(2),"s"]})]}):k("div",{className:"h-5"})]})]})})},Oi=Hn;export{Tr as a,Ee as b,ts as c,ls as d,Ve as e,Wr as f,ms as g,ys as h,Rs as i,Ps as j,Dt as k,Lt as l,Bt as m,Hr as n,Ft as o,Xr as p,jt as q,zt as r,Gt as s,Kt as t,Ht as u,Si as v,Oi as w};
2
+ import{a as vr}from"./chunk-OPN7WCJR.js";import{c as he,f as Ne}from"./chunk-726CI6GC.js";import{B as tt,C as rt,J as Rt,K as nt,O as Me,P as ce,Q as Y,T as ge,U as At,V as De,W as G,Y as kt,Z as We,_ as Nt,b as Te,c as _e,e as j,j as vt,m as Re,o as Ae,q as ke,s as xt,t as re,u as Ct,v as Ze,x as et,y as St,z as Tt}from"./chunk-EW2OR6CJ.js";import{a as ne}from"./chunk-46H44R7V.js";import{b as yr}from"./chunk-73CB2I7U.js";import{useQueryClient as xr}from"@tanstack/react-query";import{useCallback as Cr,useEffect as It,useRef as Et}from"react";function Sr(e){if(e.length===0)return 5e3;let u=Math.max(...e.map(r=>j(r)?.blockTimeMs??2e3));return Math.min(5e3,Math.max(1e3,u*2+1e3))}var Tr=()=>{let{address:e}=ne(),t=Nt(),s=xr(),l=Et(null),u=Et(!0),r=Cr(a=>{if(!e)return;let h=[...new Set(a.tokens.map(p=>p.asset.chainId))],b=Sr(h);l.current&&(clearTimeout(l.current),l.current=null),l.current=setTimeout(async()=>{if(l.current=null,!!u.current)try{let p=a.tokens.map(f=>({chainId:f.asset.chainId,tokenAddress:f.asset.address})),i=await Rt(e,p);if(i.balances.length===0)return;if(a.tokens.length>=2){let f=a.tokens[0].asset,c=a.tokens[1].asset,x=nt.swap(e,f.chainId,f.address,c.chainId,c.address);s.setQueryData(x,i)}let n=nt.bulk(e,t),w=s.getQueryData(n);if(w){let f=w.balances.map(c=>i.balances.find(g=>g.chainId===c.chainId&&g.token.toLowerCase()===c.token.toLowerCase())??c);for(let c of i.balances)f.some(x=>x.chainId===c.chainId&&x.token.toLowerCase()===c.token.toLowerCase())||f.push(c);for(let c of a.tokens)if(!i.balances.some(g=>g.chainId===c.asset.chainId&&g.token.toLowerCase()===c.asset.address.toLowerCase())){let g=f.findIndex(o=>o.chainId===c.asset.chainId&&o.token.toLowerCase()===c.asset.address.toLowerCase());g!==-1&&(f[g]={...f[g],balance:"0",shiftedBalance:"0"})}s.setQueryData(n,{balances:f})}}catch{}},b)},[e,t,s]);return It(()=>(u.current=!0,()=>{u.current=!1,l.current&&(clearTimeout(l.current),l.current=null)}),[]),{triggerBalanceUpdate:r}},st=class extends EventTarget{emit(t){this.dispatchEvent(new CustomEvent("balance-update",{detail:t}))}},ot=new st,Ee=()=>e=>ot.emit(e),ts=()=>{let{triggerBalanceUpdate:e}=Tr();It(()=>{let t=s=>{e(s.detail)};return ot.addEventListener("balance-update",t),()=>ot.removeEventListener("balance-update",t)},[e])};import{createContext as Rr,useCallback as le,useContext as Ar,useEffect as Ot,useMemo as kr,useRef as se,useState as ye}from"react";import{formatUnits as Nr,parseUnits as Er}from"viem";import{jsx as Ur}from"react/jsx-runtime";var $t=Rr(void 0),Pt=1e4,Ir=3e4,Or=1e3,Pr=2;function $r(e){return e.find(s=>s.routeSteps?.[0]?.type==="AORI_V1")??e[0]}var ls=({children:e,recipient:t})=>{let{address:s}=ne(),l=t||s,[u,r]=ye("idle"),[a,h]=ye("idle"),[b,p]=ye(null),[i,n]=ye(null),[w,f]=ye(!1),[c,x]=ye(!1),[g,o]=ye(!1),m=se(null),y=se(null),d=se(null),T=se(null),P=se(null),C=se(0),$=se(0),L=se(0),N=se(!1),E=se(new Map),I=le(()=>{d.current&&clearTimeout(d.current),T.current&&clearTimeout(T.current),P.current&&clearTimeout(P.current),d.current=null,T.current=null,P.current=null},[]),U=le(()=>{I(),m.current=null,C.current=0,r(()=>N.current?"fresh":"idle")},[I]),B=le(()=>{U(),y.current=null,p(null),n(null),f(!1),x(!1),o(!1),E.current.clear(),r("idle"),h("idle")},[U]),oe=le(v=>{if(!v)return;T.current&&clearTimeout(T.current);let S=Math.max(0,v+Ir-Date.now());T.current=setTimeout(()=>{r(O=>O==="idle"?"idle":"stale")},S)},[]),H=le(async(v,S)=>{let{inputToken:O,outputToken:A,inputAmount:q,setOutputAmount:Z}=v;if(!O||!A||!q||parseFloat(q)<=0||Date.now()-($.current||0)<Pt-10)return;let Be=++C.current;try{if(!O?.decimals||!A?.decimals)return;let z=rt(O.chainId)||j(O.chainId)?.key||"",ie=rt(A.chainId)||j(A.chainId)?.key||"";if(!z||!ie)throw new Error("Unknown chain");let ee=Er(q.toString(),O.decimals).toString(),Ce={srcChainKey:z,dstChainKey:ie,srcTokenAddress:et(O.address),dstTokenAddress:et(A.address),amount:ee,srcWalletAddress:s||"0x0000000000000000000000000000000000000000",dstWalletAddress:l||s||"0x0000000000000000000000000000000000000000",options:{amountType:"EXACT_SRC_AMOUNT",feeTolerance:{type:"PERCENT",amount:2}}};$.current=Date.now();let te=await fetch(`${Re()}/quotes`,{method:"POST",headers:Ae(),body:JSON.stringify(Ce),signal:AbortSignal.timeout(15e3)});if(!te.ok){let Se=(await te.json().catch(()=>({})))?.message||te.statusText;throw Object.assign(new Error(Se),{status:te.status})}let me=await te.json();if(Be!==C.current||m.current!==S)return;let $e=me.quotes??[],ae=$r($e);if(!ae)throw Object.assign(new Error("No quotes returned"),{emptyQuotes:!0});let Je=Number(Nr(xt(ae.dstAmount),A.decimals));typeof Z=="function"&&Z(Je),ae._receivedAt=Date.now(),p(ae),n(null),f(!1),r("fresh"),oe(ae._receivedAt),S&&E.current.delete(S)}catch(z){if(Be!==C.current||m.current!==S)return;let ie=z?.status,ee=z instanceof Error?z.message:"",Ce=!!z?.emptyQuotes;if((ie===400||Ce||ee.includes("Quote request failed"))&&S){let me=(E.current.get(S)||0)+1;if(E.current.set(S,me),me>=Pr){x(!0),I(),m.current=null;return}}if(ee.toLowerCase().includes("order cap exceeded")){o(!0),I(),m.current=null;return}if(ee.toLowerCase().includes("insufficient executor balance")){f(!0),I(),m.current=null;return}n(z instanceof Error?z.message:"Unknown error")}},[s,l,oe,I]),W=le((v,S)=>{I(),y.current=v,$.current=0,E.current.delete(S),f(!1),x(!1),o(!1),n(null),r("polling");let O=async()=>{m.current===S&&(await H(v,S),m.current===S&&(d.current=setTimeout(O,Pt)))};O()},[I,H]),R=le(v=>{if(!v?.inputToken||!v?.outputToken||!v?.inputAmount||parseFloat(v.inputAmount)<=0){U();return}let S=y.current;if(S&&S.inputToken?.address===v.inputToken?.address&&S.inputToken?.chainId===v.inputToken?.chainId&&S.outputToken?.address===v.outputToken?.address&&S.outputToken?.chainId===v.outputToken?.chainId&&S.inputAmount===v.inputAmount&&m.current)return;let A=Date.now();if(A-L.current<100)return;L.current=A;let q=`${Date.now()}-${Math.random().toString(36).slice(2)}`;m.current=q,W(v,q)},[W,U]),V=le(({amount:v,inputToken:S,outputToken:O,setOutputAmount:A})=>{A(null),P.current&&clearTimeout(P.current),!v||v===0?(h("idle"),U(),p(null),n(null),f(!1),x(!1),o(!1)):(h("typing"),U(),p(null),f(!1),x(!1),o(!1),n(null),P.current=setTimeout(()=>{h("settled"),S&&O&&v>0&&R({inputToken:S,outputToken:O,inputAmount:v.toString(),setOutputAmount:A})},Or))},[U,R]),F=le(()=>{let v=y.current;if(!v)return;p(null);let S=`${Date.now()}-${Math.random().toString(36).slice(2)}`;m.current=S,r("refreshing"),typeof v.setOutputAmount=="function"&&v.setOutputAmount(null),W(v,S)},[W]);Ot(()=>{N.current=!!b},[b]),Ot(()=>()=>I(),[I]);let X=kr(()=>({status:u,inputState:a,rfqQuote:b,error:i,liquidityError:w,routingError:c,sizeCapError:g,ensureForParams:R,stop:U,refresh:F,clear:B,handleInputChange:V}),[u,a,b,i,w,c,g,R,U,F,B,V]);return Ur($t.Provider,{value:X,children:e})},Ve=()=>{let e=Ar($t);if(e===void 0)throw new Error("useRfq must be used within an RfqProvider");return e};import{createContext as Mr,useContext as Dr}from"react";var Wr=Mr({openConnectModal:()=>{}}),ms=()=>Dr(Wr);import{useCallback as it,useEffect as Ie,useRef as Fe,useState as at}from"react";import{jsx as Oe,jsxs as _r}from"react/jsx-runtime";var Lr=20,Br=({side:e,asset:t,otherAsset:s,isPlacingOrder:l,isWrappingPair:u,isUnwrappingPair:r})=>{let{baseAmount:a,quoteAmount:h,setBaseAmount:b,setQuoteAmount:p}=Ne(),{amountInputVariant:i,hideAmountInputSymbol:n,widgetType:w}=Te(),f=w==="compact",[c,x]=e==="base"?[b,p]:[p,b],g=!t||e==="quote"||l,o=f?32:i==="default"?64:32,[m,y]=at(o),[d,T]=at(""),P=Fe(null),C=Fe(null),$=Fe(null),L=Fe(null),N="USD",E=e==="base"?a:h,[I,U]=at(!1),B=it(()=>{if(i!=="default"){y(o);return}if(!P.current||!C.current||!$.current)return;let W=P.current.offsetWidth,R=20,V=o;for(;V>20&&(C.current.style.fontSize=`${V}px`,$.current.style.fontSize=`${V}px`,!(C.current.offsetWidth+$.current.offsetWidth+R<=W));)V-=1;y(V)},[i,o]),oe=it(W=>{W.key==="."&&d.includes(".")&&W.preventDefault()},[d]),H=it(W=>{let R=W.target.value;if(R==="."&&(R="0."),!/^\d*\.?\d*$/.test(R)||(R.match(/\./g)||[]).length>1)return;if(R.length>1&&R[0]==="0"&&R[1]!=="."&&(R=R.replace(/^0+/,"")||"0"),t?.decimals!==void 0&&R.includes(".")){let[,F]=R.split(".");if(F&&F.length>t.decimals)return}if(R.length>Lr)return;T(R);let V=parseFloat(R);R!==d&&(R===""||R==="0."||R.endsWith(".")?(c(null),e==="base"&&x(null)):!Number.isNaN(V)&&V>=0&&c(V),e==="base"&&p(null),(r||u)&&p(V||0))},[d,c,e,p,t?.decimals,x,r,u]);return Ie(()=>{let W=F=>{if(F===null)return"";let X=t?.decimals;if(X===void 0)return"";let v=F.toString();if(/e/i.test(v)&&(v=Number(F).toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:X})),v.includes(".")){let[S,O]=v.split("."),A=O.slice(0,X);return A?`${S}.${A}`:S}return v};if(E===null){d==="0."||d!==""&&d.endsWith(".")||T("");return}if(!g&&(d.endsWith(".")||d.match(/\.\d*0$/)||d==="0"||d==="0.")&&d!=="")return;let V=parseFloat(d)||0;(d===""||Math.abs(V-E)>1e-10)&&T(W(E))},[E,t?.decimals,d,g]),Ie(()=>{B()},[d,B]),Ie(()=>{U(!0)},[]),Ie(()=>{I&&B()},[I,B]),Ie(()=>{C.current&&L.current&&(L.current.style.width=`${C.current.offsetWidth}px`)},[d]),Ie(()=>{if(!I)return;let W=new ResizeObserver(()=>{I&&B()});return P.current&&W.observe(P.current),()=>W.disconnect()},[I,B]),Oe("div",{ref:P,style:{fontSize:`${m}px`,transition:"font-size 0.05s ease-in-out"},className:`mt-2 box-border flex ${f?i==="normal"?"h-12 my-1":"h-10 my-0.5":i==="normal"?"h-12 my-1":"h-20 my-1"} w-full flex-row items-center ${g?"cursor-default":"cursor-text"}`,onClick:()=>L.current?.focus(),children:_r("div",{className:"relative flex w-full items-center",children:[Oe("label",{htmlFor:`${e}Amount`,className:"sr-only",children:e==="base"?"Input token amount":"Output token amount"}),Oe("input",{ref:L,type:"text",inputMode:"decimal",placeholder:"0",autoComplete:"off",id:`${e}Amount`,value:d,onWheel:W=>W.target.blur(),onKeyDown:oe,onChange:H,style:{transition:"width 0.15s ease-in-out",color:"var(--widget-foreground)",WebkitTextFillColor:"var(--widget-foreground)",opacity:g?.4:1},className:"flex min-w-[45px] whitespace-nowrap bg-transparent placeholder:opacity-50",disabled:g}),Oe("span",{style:{transition:"width 0.15s ease-in-out"},ref:C,className:"pointer-events-none absolute flex whitespace-nowrap invisible",children:d||0}),!n&&i!=="normal"&&Oe("span",{ref:$,className:"ml-2 font-light uppercase",style:{color:"var(--widget-foreground)",opacity:.5,fontSize:`${m}px`},children:t?.symbol?t.symbol.length>6?`${t.symbol.slice(0,6)}...`:t.symbol:N}),(n||i==="normal")&&Oe("span",{ref:$,className:"hidden"})]})})},ys=Br;import{Fragment as ct,jsx as D,jsxs as ue}from"react/jsx-runtime";var Vr=({toggle:e,side:t,asset:s,isPlacingOrder:l})=>{let{baseBalance:u,quoteBalance:r}=Ne(),{tokenDisplay:a,tokenBadgeOrientation:h,widgetType:b}=Te(),p=b==="compact",i=p?"h-10":"h-12",n=p?"h-10 w-10":"h-12 w-12",w=t==="base"?u.formatted?(()=>{let c=parseFloat(u.formatted);return c>=1e8?ke(c):c.toFixed(3)})():void 0:r.formatted?(()=>{let c=parseFloat(r.formatted);return c>=1e8?ke(c):c.toFixed(3)})():void 0,f={role:"button",tabIndex:l?-1:0,"aria-disabled":l,"aria-label":`Select ${t==="base"?"input":"output"} token${s?`: ${s.symbol}`:""}`,onClick:l?void 0:e,onKeyDown:l?void 0:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),e())}};return a==="pill"?D("div",{...f,className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-full cursor-pointer transition-colors ${h==="right"?"ml-auto":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-secondary)",color:"var(--widget-secondary-foreground)"},children:s?ue(ct,{children:[D(Me,{chain:s.chainId,size:"xs"}),D(ce,{className:"rounded-full",asset:s,size:"xxs",noChain:!0}),D("span",{className:"text-xs font-medium uppercase",children:s.symbol}),D(De,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]}):ue(ct,{children:[D("span",{className:"text-xs opacity-70",children:"Select"}),D(De,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]})}):a==="ghost"?ue("div",{...f,className:"inline-flex items-center gap-1.5 cursor-pointer transition-opacity hover:opacity-70 py-1",style:{color:"var(--widget-foreground)"},children:[s?ue(ct,{children:[D(Me,{chain:s.chainId,size:"xs"}),D(ce,{className:"rounded-full",asset:s,size:"xxs",noChain:!0}),D("span",{className:"text-sm font-medium uppercase",children:s.symbol})]}):D("span",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Select token"}),D(De,{className:"w-1.5 opacity-50"})]}):D("div",{...f,className:`relative ${i} 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:D("div",{className:"relative flex h-full w-full flex-row items-center",children:s?ue("div",{className:"relative flex h-full w-full flex-row items-center",children:[D("div",{className:`${n} pl-px flex items-center justify-center`,children:D(ce,{className:"rounded-full",asset:s,size:"md"})}),ue("div",{className:"flex h-full w-full flex-row items-center justify-between pl-1.5 pr-7",children:[ue("div",{className:"flex h-full flex-col justify-center",children:[D("p",{className:"text-sm font-medium uppercase",style:{color:"var(--widget-secondary-foreground)"},children:s.symbol}),ue("span",{className:"text-2xs font-mono",style:{color:"var(--widget-secondary-foreground)",opacity:.6},children:[s.address?.slice(0,6),"...",s.address?.slice(-4)]})]}),w!==void 0&&ue("div",{className:"flex flex-col text-right",children:[D("p",{className:"text-2xs",style:{color:"var(--widget-secondary-foreground)",opacity:.5},children:"Balance"}),D("span",{className:"font-mono text-xs tabular-nums",style:{color:"var(--widget-secondary-foreground)"},children:w})]})]}),D(De,{className:"absolute right-3 top-1/2 w-1.5 translate-y-[-50%]",style:{color:"var(--widget-secondary-foreground)",opacity:.6}})]}):D("div",{className:"flex h-full w-full items-center justify-center",children:D("span",{className:"text-sm",style:{color:"var(--widget-secondary-foreground)",opacity:.7},children:"Select token"})})})})},Rs=Vr;var Mt=yr(vr(),1);import{useState as qe,useEffect as Qe}from"react";import{jsx as K,jsxs as Ut}from"react/jsx-runtime";var Fr=()=>{let[e,t]=qe(null),[s,l]=qe(""),u=Tt(s,1e3),[r,a]=qe(!1),[h,b]=qe("");Qe(()=>{he.getState().setRecipient(e)},[e]),Qe(()=>{l(e||"")},[e]);let p=n=>{let w=n.target.value;r&&(a(!1),b(""),t(null)),l(w),w===""&&t(null)};Qe(()=>{u===""||!u?(a(!1),b(""),t(null)):St(u)?(a(!1),b(""),t(u)):(a(!0),b("Invalid wallet address..."),t(null),l(""))},[u]),Qe(()=>{if(r){let n=setTimeout(()=>{t(null),l(""),a(!1),b("")},2e3);return()=>clearTimeout(n)}},[r]);let i=()=>{t(null),l(""),a(!1),b("")};return K("div",{className:"w-full",children:Ut("div",{className:"relative flex flex-row items-center",children:[K("input",{type:"password",style:{display:"none"},"aria-hidden":"true",tabIndex:-1}),K("label",{htmlFor:"recipient-address",className:"sr-only",children:"Recipient wallet address"}),K("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&&!r?K("img",{className:"h-full w-full rounded-full object-cover",src:(0,Mt.makeGradient)(e),alt:"Recipient avatar"}):K(At,{className:"h-5 w-5",style:{color:r?"var(--widget-destructive)":"var(--widget-muted-foreground)"}})}),K("div",{className:"absolute left-12 top-1.5 -translate-y-1 text-xs font-medium opacity-60",style:{color:r?"var(--widget-destructive)":"var(--widget-muted-foreground)"},"aria-hidden":"true",children:"To:"}),K("input",{id:"recipient-address",className:"mono block h-10 w-full items-center pl-12 pt-4 pr-8 text-xs",style:{backgroundColor:r?"color-mix(in srgb, var(--widget-destructive) 10%, transparent)":"transparent",color:r?"var(--widget-destructive)":"var(--widget-foreground)",outline:"none",opacity:r?.9:1},placeholder:r?h:"Enter recipient address...",value:s,onChange:p,spellCheck:!1,"aria-invalid":r,"aria-describedby":r?"recipient-error":void 0}),r&&K("span",{id:"recipient-error",className:"sr-only",children:h}),e&&!r&&Ut("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:i,"aria-label":"Clear recipient",children:[K("svg",{className:"h-2.5 w-2.5",viewBox:"0 -0.5 21 21",fill:"none",children:K("g",{fill:"currentColor",fillRule:"evenodd",children:K("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)"})})}),K("span",{className:"sr-only",children:"Clear recipient"})]})]})})},Ps=Fr;var qr=["SUCCEEDED","FAILED","COMPLETED","CANCELLED"];async function Dt(e,t,s={}){let{onStatusChange:l,onComplete:u,onError:r,interval:a=4e3,timeout:h=3e5,txHash:b,signal:p}=s,i=null,n=Date.now(),w=0,f=8,c=null,x=b?`?txHash=${b}`:"";return new Promise((g,o)=>{let m=async()=>{try{if(p?.aborted){c&&clearTimeout(c),o(new DOMException("Polling aborted","AbortError"));return}if(Date.now()-n>h){c&&clearTimeout(c);let P=new Error("Order status polling timed out");r?.(P),o(P);return}let y=await fetch(`${t}/status/${e}${x}`,{headers:Ae(),signal:p});if(y.status===404){c=setTimeout(m,a);return}if(!y.ok)throw new Error(`Failed to fetch order status: ${await y.text()}`);let d=await y.json();if(!d||typeof d!="object"||!d.status)throw new Error(`Invalid status response format: ${JSON.stringify(d)}`);w=0;let T=d.status.toUpperCase();if(T!==i&&(i=T,l?.(d)),qr.includes(T)){c&&clearTimeout(c),u?.(d),g(d);return}c=setTimeout(m,a)}catch(y){if(y instanceof Error&&y.name==="AbortError"){c&&clearTimeout(c),o(y);return}if(++w>=f){c&&clearTimeout(c);let d=y instanceof Error?y:new Error(String(y));r?.(d),o(d);return}c=setTimeout(m,a)}};m()})}import{useCallback as je,useEffect as Qr,useRef as ze}from"react";function Wt(e){let t=e.toUpperCase();return t==="SUCCEEDED"||t==="COMPLETED"?"completed":t==="FAILED"?"failed":t==="CANCELLED"?"cancelled":t==="PROCESSING"?"received":"pending"}var Lt=e=>{let t=ze(new Map),s=ze(new Map),l=ze(new Map),u=ze(0),r=je(()=>++u.current,[]),{address:a}=ne(),h=Ee(),b=je((n,w)=>{if(t.current.get(n))return;w&&s.current.set(n,w),t.current.set(n,!0);let f=u.current,c=new AbortController;l.current.set(n,c);let x=w?.baseToken?.chainId===1;Dt(n,Re(),{interval:x?1e3:500,timeout:3e5,signal:c.signal,onStatusChange:g=>{if(!g?.status)return;let o=Wt(g.status);if(e?.(n,o),o==="completed"&&a){let m=s.current.get(n);if(m&&(m.baseToken||m.quoteToken)){let y=[];m.baseToken&&y.push({asset:m.baseToken,userAddress:a}),m.quoteToken&&y.push({asset:m.quoteToken,userAddress:a}),h({type:"swap",tokens:y})}}["completed","failed","cancelled"].includes(o)&&(t.current.delete(n),s.current.delete(n)),f!==u.current&&(t.current.delete(n),s.current.delete(n))},onComplete:g=>{g?.status&&e?.(n,Wt(g.status)),t.current.delete(n),s.current.delete(n)},onError:()=>{t.current.delete(n),s.current.delete(n)}}).catch(g=>{g instanceof Error&&g.name==="AbortError"||(t.current.delete(n),s.current.delete(n),l.current.delete(n))})},[a,h,e]),p=je(n=>{let w=l.current.get(n);w&&(w.abort(),l.current.delete(n)),r(),t.current.delete(n),s.current.delete(n)},[r]),i=je(()=>{for(let n of l.current.values())n.abort();l.current.clear(),r(),t.current.clear(),s.current.clear()},[r]);return Qr(()=>()=>i(),[i]),{startPolling:b,stopPolling:p,stopAllPolling:i,isPolling:n=>t.current.has(n)}};import{createContext as jr,useContext as zr}from"react";var Gr=jr({registerTransaction:()=>{},enabled:!1}),Bt=()=>zr(Gr);import{signTypedData as Kr}from"viem/actions";function Vt(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 _t(e){if(e.chain?.id)return e.chain.id;let t=e.getChainId?.();return t!=null?await t:null}var Hr=async(e,t)=>{try{if(await _t(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 _t(e)===t}catch(s){throw Vt(s)?new Error("User rejected the chain switch request"):new Error(`Please switch your wallet to the required network (Chain ID: ${t})`)}},Ft=async e=>{let{quote:t,signatureStep:s,userAddress:l,walletClient:u}=e;if(!u)throw new Error("Wallet client not available");if(s.type!=="SIGNATURE"||!s.signature?.typedData)throw new Error("Invalid signature step");try{let r=s.signature.typedData,a={...r.message};for(let i of["inputAmount","outputAmount","startTime","endTime"])a[i]!=null&&(a[i]=BigInt(a[i]));let h=r.domain;if(h.chainId!=null){let i=Number(h.chainId);await Hr(u,i)}let b=await Kr(u,{account:l,domain:h,types:r.types,primaryType:r.primaryType,message:a}),p=await fetch(`${Re()}/submit-signature`,{method:"POST",headers:Ae(),body:JSON.stringify({quoteId:t.id,signatures:[b]})});if(!p.ok){let i=await p.json().catch(()=>({}));throw new Error(i?.message||`Submit failed: ${p.status}`)}return{quoteId:t.id,signature:b}}catch(r){throw Vt(r)?new Error("User rejected the signing request"):r instanceof Error&&r.message.includes("chain")?new Error("Chain switching failed. Please manually switch to the correct network."):r}};var qt="vt_submitted_quotes";var lt=()=>{try{let e=localStorage.getItem(qt);return e?JSON.parse(e):[]}catch{return[]}},Qt=e=>{try{localStorage.setItem(qt,JSON.stringify(e))}catch{}},Xr=e=>{let t=Date.now(),s=typeof e=="string"?new Date(e).getTime():e>9999999999?e:e*1e3;return t<s+3e4},Yr=e=>lt().some(t=>t.quoteId===e),jt=(e,t)=>Yr(e)?{canSubmit:!1,reason:"Order already submitted"}:Xr(t)?{canSubmit:!0}:{canSubmit:!1,reason:"Quote has expired"},zt=(e,t)=>{let s=typeof t=="string"?new Date(t).getTime():t,l=lt();l.push({quoteId:e,submittedAt:Date.now(),createdAt:s}),Qt(l)},Gt=()=>{let e=lt(),t=Date.now(),s=300*1e3,l=e.filter(u=>t-u.submittedAt<s);l.length!==e.length&&Qt(l)};import{useMutation as Jr}from"@tanstack/react-query";import{waitForTransactionReceipt as Zr}from"@wagmi/core";import{wethAbi as en}from"abitype/abis";import{useConfig as tn}from"wagmi";function Kt(){let e=tn();return Jr({mutationFn:async({chainId:t,accountAddress:s,amountRaw:l,writeContractAsync:u})=>{let r=j(t);if(!r)throw new Error(`No wrapping contract for chain ${t}`);let a=r.wrappedAsset.address,h=await u({abi:en,functionName:"withdraw",address:a,account:s,args:[l],chainId:t});if((await Zr(e,{hash:h,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Unwrap transaction did not get successful receipt");return{success:!0,hash:h}}})}import{useMutation as rn}from"@tanstack/react-query";import{waitForTransactionReceipt as nn}from"@wagmi/core";import{wethAbi as sn}from"abitype/abis";import{useConfig as on}from"wagmi";function Ht(){let e=on();return rn({mutationFn:async({chainId:t,accountAddress:s,amountRaw:l,writeContractAsync:u})=>{let r=j(t);if(!r)throw new Error(`No wrapping contract for chain ${t}`);let a=r.wrappedAsset.address,h=await u({abi:sn,functionName:"deposit",address:a,account:s,value:l,chainId:t});if((await nn(e,{hash:h,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Wrap transaction did not get successful receipt");return{success:!0,hash:h}}})}import{useCallback as pe,useEffect as Pe,useRef as gr,useState as Fn}from"react";import{useChainId as qn}from"wagmi";import{useCallback as Xt,useRef as an}from"react";function Yt(){let{registerTransaction:e,enabled:t}=Bt(),s=an(new Set),l=Xt((r,a)=>{!t||s.current.has(r)||(s.current.add(r),e(r,a))},[t,e]),u=Xt((r,a)=>{!t||s.current.has(r)||(s.current.add(r),e(r,a))},[t,e]);return{trackOrderTransaction:l,trackNativeTransaction:u,txTrackingEnabled:t}}import{useEffect as Jt,useState as cn,useCallback as Zt,useRef as ut}from"react";import{useAccount as ln,useChainId as un,useSwitchChain as dn}from"wagmi";import{jsx as we,jsxs as dt}from"react/jsx-runtime";var pn=15e3,Ge="chain",mn=({needsChainSwitch:e,requiredChain:t,reviewState:s,goToNextStep:l,cancel:u})=>{let r=re(Ge,s),[a,h]=cn("pending"),b=ut(!1),p=ut(!1),i=ut(null),n=un(),{switchChainAsync:w}=dn(),{status:f,isReconnecting:c}=ln(),x=Zt(()=>{i.current&&(clearTimeout(i.current),i.current=null)},[]),g=Zt(async()=>{if(!(b.current||p.current||f!=="connected"||c)){b.current=!0,p.current=!0,h("pending"),i.current=setTimeout(()=>{b.current&&(h("error"),b.current=!1)},pn);try{await w({chainId:t.chainId}),x(),h("success"),l(Ge,s)}catch{x(),h("error")}finally{b.current=!1}}},[w,f,c,t.chainId,l,s,x]);Jt(()=>{b.current||p.current||s===Ge&&a==="pending"&&f==="connected"&&!c&&(e&&n!==t.chainId?g():(h("success"),l(Ge,s)))},[s,a,e,n,t.chainId,f,c,g,l]),Jt(()=>()=>x(),[x]);let o=()=>{a==="error"&&(p.current=!1,h("pending"))},m=!r&&a==="error",y=!r&&(a==="pending"||a==="error"),d=m?"var(--widget-status-failed)":"var(--widget-status-pending)";return dt("div",{className:"flex w-full flex-row justify-between space-x-3",children:[we("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${m?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${d} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${d} 20%, transparent)`,color:d,borderRadius:"var(--widget-radius)"},onClick:m?o:void 0,children:dt("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[we(Me,{chain:t.chainId,size:"xs"}),we("p",{className:"whitespace-nowrap",children:m?"Retry Switch":`Switch to ${t.name}`}),we("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),dt("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!r&&a==="pending"&&we(G,{size:"5"}),(r||a==="success")&&we(Y,{className:"h-8 w-8"}),m&&we(ge,{className:"h-[12px] w-[12px]"})]})]})}),y&&we("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm 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:u,children:"Cancel"})]})},er=mn;import{waitForTransactionReceipt as wn}from"@wagmi/core";import{useCallback as Ke,useEffect as He,useState as bn,useRef as or}from"react";import{useAccount as hn,useConfig as yn,useSendTransaction as vn,useSwitchChain as xn,useWalletClient as Cn}from"wagmi";import{useEffect as tr,useRef as rr,useState as nr}from"react";import{jsx as gn}from"react/jsx-runtime";var fn=({startTime:e,onExpired:t})=>{let[s,l]=nr(30),[u,r]=nr(!1),a=rr(!1),h=rr(t);h.current=t,tr(()=>{a.current=!1},[e]),tr(()=>{let p=()=>{let n=Date.now(),f=(e>9999999999?e:e*1e3)+30*1e3,c=Math.max(0,f-n),x=Math.floor(c/1e3);if(x<=0){l(0),a.current||(a.current=!0,r(!0),h.current());return}l(x),r(!1)};if(u)return;p();let i=setInterval(p,1e3);return()=>clearInterval(i)},[e,u]);let b=p=>{let i=Math.floor(p/60),n=p%60;return`${i.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`};return u?null:gn("span",{className:"text-xs font-mono",children:b(s)})},sr=fn;import{jsx as de,jsxs as pt}from"react/jsx-runtime";function Sn(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 be="signingOrder";async function Tn(e,t,s,l,u){let r=e.transaction?.encoded,a=r?.to??e.to,h=r?.data??e.data,b=r?.value??e.value;if(!a)throw new Error('Transaction step missing "to" address');let p=r?.chainId,i=e.chainKey||u,n=p||(i?tt(i):void 0);if(!n)throw new Error(`Unknown chain: ${i}`);let w=vt()[n],f=await s({account:t,chain:w,to:a,data:h||"0x",value:BigInt(b||"0")});return await wn(l,{hash:f,chainId:n}),f}var Rn=({base:e,baseAmount:t,quote:s,quoteAmount:l,userAddress:u,reviewState:r,goToNextStep:a,cancel:h,isWrappingPair:b,isUnwrappingPair:p,restartSigningFlow:i,onSwapInitiated:n,onOrderSubmitted:w,onSwapComplete:f,startPolling:c,trackNativeTransaction:x})=>{let g=re(be,r),[o,m]=bn("idle"),y=or(!1),d=or(null),T=yn(),{isReconnecting:P}=hn(),{rfqQuote:C,stop:$,refresh:L}=Ve(),{data:N}=Cn({chainId:e.chainId}),{switchChain:E}=xn(),{sendTransactionAsync:I}=vn(),U=C?._receivedAt??0,B=Ke(()=>U?Date.now()>=U+30*1e3:!1,[U]),oe=Ke(async()=>{if(y.current||!["idle","error"].includes(o))return;if(!C?.id||!C?._receivedAt){m("error");return}if(!jt(C.id,C._receivedAt).canSubmit){m("stale");return}y.current=!0;try{if(!N)throw new Error("Wallet client not available");Gt();let S=C.userSteps??[],O;for(let A of S)if(A.type==="TRANSACTION"){m("submitting");let q=A.chainKey||C.srcChainKey,Z=q?tt(q):void 0;Z&&N.chain?.id!==Z&&(await E({chainId:Z}),await new Promise(Le=>setTimeout(Le,800))),O=await Tn(A,u,I,T,C.srcChainKey),x(O,A.description||`Tx on ${q}`)}else A.type==="SIGNATURE"&&(m("signing"),await Ft({quote:C,signatureStep:A,userAddress:u,walletClient:N}));zt(C.id,C._receivedAt),w?.(C.id),c(C.id,{baseToken:e,quoteToken:s}),n?.(),$(),m("success"),a(be,r),f?.(C.id)}catch(S){S instanceof Error&&Sn(S)?(d.current=null,m("idle")):m("error")}finally{y.current=!1}},[o,C,N,e,s,u,$,c,a,r,f,E,I,n,w,x,T]);He(()=>{if(r===be&&$(),g&&o!=="success"){m("success"),a(be,r);return}if(o==="success"){a(be,r);return}if(r===be&&o==="idle"&&!C?.id){m("refreshingQuote"),L();return}if(r===be&&o==="idle"&&N&&!y.current&&!P){let v=C?.id||null;v&&d.current!==v&&(d.current=v,oe())}},[g,r,o,N,P,oe,a,C?.id,L,$]),He(()=>{o==="refreshingQuote"&&C?.id&&m("idle")},[o,C?.id]),He(()=>{r!==be&&(d.current=null)},[r]),He(()=>{let v=setInterval(()=>{B()&&!y.current&&o!=="submitting"&&o!=="success"&&m("stale")},1e3);return()=>clearInterval(v)},[B,o]);let H=()=>{o==="error"&&!y.current&&(d.current=null,m("idle"))},W=Ke(()=>{d.current=null,m("refreshingQuote"),L()},[L]),R=Ke(()=>{i?i(!0):h()},[i,h]),V=()=>o==="error"?"Retry swap":o==="signing"?"Sign Swap Order":o==="submitting"?"Submitting...":o==="refreshingQuote"?"Refreshing Quote...":o==="stale"?"Quote Stale":"Sign & Submit",F=!g&&(o==="error"||o==="stale"),X=F?"var(--widget-status-failed)":"var(--widget-status-pending)";return pt("div",{className:"flex w-full flex-row justify-between space-x-3",children:[de("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${F?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${X} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${X} 20%, transparent)`,color:X,borderRadius:"var(--widget-radius)"},onClick:!g&&o==="error"?H:o==="stale"?R:void 0,children:pt("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[de(ce,{asset:e,size:"xs",noChain:!0}),de("p",{className:"whitespace-nowrap",children:V()}),de("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),U>0&&o!=="success"&&o!=="error"&&o!=="stale"&&de(sr,{startTime:U,onExpired:()=>m("stale")}),pt("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!g&&(o==="idle"||o==="signing"||o==="submitting"||o==="refreshingQuote")&&de(G,{size:"5"}),(g||o==="success")&&de(Y,{className:"h-8 w-8"}),!g&&(o==="error"||o==="stale")&&de(ge,{className:"h-[12px] w-[12px]"})]})]})}),!g&&o==="error"&&de("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm 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:h,children:"Cancel"})]})},ir=Rn;import{useEffect as An}from"react";import{jsx as J,jsxs as En}from"react/jsx-runtime";var kn="trackingTx",ar={pending:{icon:J(G,{size:"5"}),buttonText:"Trade Pending",showNewSwap:!1,statusVar:"var(--widget-status-pending)",clickable:!1},received:{icon:J(G,{size:"5"}),buttonText:"Trade Received",showNewSwap:!1,statusVar:"var(--widget-status-received)",clickable:!1},completed:{icon:J(Y,{}),buttonText:"Continue Swapping",showNewSwap:!0,statusVar:"var(--widget-status-completed)",clickable:!0},failed:{icon:J(We,{}),buttonText:"Retry Swap",showNewSwap:!0,statusVar:"var(--widget-status-failed)",clickable:!0},cancelled:{icon:J(We,{}),buttonText:"Continue Swapping",showNewSwap:!0,statusVar:"var(--widget-status-failed)",clickable:!0}},Nn=({orderHash:e,base:t,quote:s,baseAmount:l,quoteAmount:u,reviewState:r,onNewSwap:a,onRetry:h,status:b})=>{let p=re(kn,r),i=ar[b]||ar.pending;An(()=>{if(b==="completed"){let f=setTimeout(a,5e3);return()=>clearTimeout(f)}},[b,a]);let n=()=>{b==="failed"?h():i.showNewSwap&&a()},w=i.statusVar;return J("div",{className:"flex flex-row justify-between space-x-3 w-full",children:J("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${i.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:i.showNewSwap?n:void 0,children:En("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[J("div",{className:"flex h-6 w-6 items-center justify-center rounded-full",children:i.icon}),J("p",{className:"whitespace-nowrap",children:i.buttonText}),J("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),i.showNewSwap&&J("div",{className:"flex h-6 w-6 items-center justify-center",children:J(kt,{})})]})})})},cr=Nn;import{useCallback as lr,useEffect as ur,useState as In,useRef as mt}from"react";import{parseUnits as On}from"viem";import{useAccount as Pn,useWriteContract as $n}from"wagmi";import{jsx as ve,jsxs as ft}from"react/jsx-runtime";var Un=15e3,Xe="unwrapping",Mn=({needsToUnwrap:e,amount:t,chainId:s,token:l,reviewState:u,setReviewState:r,goToNextStep:a,cancel:h,delayedClose:b})=>{let p=re(Xe,u),[i,n]=In("idle"),w=Kt(),{writeContractAsync:f}=$n(),{address:c}=ne(),x=Ee(),g=mt(!1),o=mt(!1),m=mt(null),{status:y}=Pn(),d=lr(()=>{m.current&&(clearTimeout(m.current),m.current=null)},[]),T=lr(async()=>{if(!(g.current||o.current||!c||y!=="connected")){g.current=!0,o.current=!0,n("pending"),m.current=setTimeout(()=>{g.current&&(n("error"),g.current=!1)},Un);try{let N=j(s);if(!N)throw new Error(`No config for chain ${s}`);let E=N.wrappedAsset.decimals??N.nativeAsset.decimals,I=On(t.toString(),E);await w.mutateAsync({chainId:s,accountAddress:c,amountRaw:I,writeContractAsync:f});let U={symbol:N.nativeAsset.symbol,name:N.nativeAsset.name,address:_e,decimals:N.nativeAsset.decimals,chainId:s},B={symbol:N.wrappedAsset.symbol,name:N.wrappedAsset.name,address:N.wrappedAsset.address,decimals:N.wrappedAsset.decimals,chainId:s};x({type:"unwrap",tokens:[{asset:U,userAddress:c},{asset:B,userAddress:c}]}),d(),n("success"),a(Xe,u),await b()}catch{d(),n("error")}finally{g.current=!1}}},[c,y,s,t,w,f,x,a,u,b,d]);ur(()=>{g.current||o.current||u===Xe&&i==="idle"&&y==="connected"&&(e?T():(n("success"),a(Xe,u)))},[u,i,e,y,T,a]),ur(()=>()=>d(),[d]);let P=()=>{i==="error"&&(o.current=!1,n("idle"))},C=!p&&i==="error",$=!p&&(i==="pending"||i==="idle"||i==="error"),L=C?"var(--widget-status-failed)":"var(--widget-status-pending)";return ft("div",{className:"flex w-full flex-row justify-between space-x-3",children:[ve("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${C?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${L} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${L} 20%, transparent)`,color:L,borderRadius:"var(--widget-radius)"},onClick:C?P:void 0,children:ft("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[ve("p",{className:"whitespace-nowrap",children:C?"Retry Unwrap":l?`Unwrap ${l.symbol}`:"Unwrap Native Token"}),ve("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),ft("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!p&&(i==="pending"||i==="idle")&&ve(G,{size:"5"}),(p||i==="success")&&ve(Y,{className:"h-8 w-8"}),C&&ve(ge,{className:"h-[12px] w-[12px]"})]})]})}),$&&ve("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm 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:h,children:"Cancel"})]})},dr=Mn;import{useCallback as pr,useEffect as mr,useState as Dn,useRef as gt}from"react";import{parseUnits as Wn}from"viem";import{useAccount as Ln,useWriteContract as Bn}from"wagmi";import{jsx as xe,jsxs as wt}from"react/jsx-runtime";var _n=15e3,Ye="wrapping",Vn=({needsToWrap:e,amount:t,chainId:s,token:l,reviewState:u,setReviewState:r,goToNextStep:a,cancel:h,delayedClose:b,isWrappingPair:p})=>{let i=re(Ye,u),[n,w]=Dn("idle"),f=Ht(),{writeContractAsync:c}=Bn(),{address:x}=ne(),g=Ee(),o=gt(!1),m=gt(!1),y=gt(null),{status:d}=Ln(),T=pr(()=>{y.current&&(clearTimeout(y.current),y.current=null)},[]),P=pr(async()=>{if(!(o.current||m.current||!x||d!=="connected")){o.current=!0,m.current=!0,w("pending"),y.current=setTimeout(()=>{o.current&&(w("error"),o.current=!1)},_n);try{let E=j(s);if(!E)throw new Error(`No config for chain ${s}`);let I=Wn(t.toString(),E.nativeAsset.decimals);await f.mutateAsync({chainId:s,accountAddress:x,amountRaw:I,writeContractAsync:c});let U={symbol:E.nativeAsset.symbol,name:E.nativeAsset.name,address:_e,decimals:E.nativeAsset.decimals,chainId:s},B={symbol:E.wrappedAsset.symbol,name:E.wrappedAsset.name,address:E.wrappedAsset.address,decimals:E.wrappedAsset.decimals,chainId:s};g({type:"wrap",tokens:[{asset:U,userAddress:x},{asset:B,userAddress:x}]}),T(),w("success"),a(Ye,u),p&&await b()}catch{T(),w("error")}finally{o.current=!1}}},[x,d,s,t,f,c,g,a,u,b,p,T]);mr(()=>{o.current||m.current||u===Ye&&n==="idle"&&d==="connected"&&(e?P():(w("success"),a(Ye,u)))},[u,n,e,d,P,a]),mr(()=>()=>T(),[T]);let C=()=>{n==="error"&&(m.current=!1,w("idle"))},$=!i&&n==="error",L=!i&&(n==="pending"||n==="idle"||n==="error"),N=$?"var(--widget-status-failed)":"var(--widget-status-pending)";return wt("div",{className:"flex w-full flex-row justify-between space-x-3",children:[xe("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${$?"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:$?C:void 0,children:wt("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[xe("p",{className:"whitespace-nowrap",children:$?"Retry Wrap":l?`Wrap ${l.symbol}`:"Wrap Native Token"}),xe("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),wt("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!i&&(n==="pending"||n==="idle")&&xe(G,{size:"5"}),(i||n==="success")&&xe(Y,{className:"h-8 w-8"}),$&&xe(ge,{className:"h-[12px] w-[12px]"})]})]})}),L&&xe("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm 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:h,children:"Cancel"})]})},fr=Vn;import{jsx as Q,jsxs as Qn}from"react/jsx-runtime";var Si=({base:e,baseAmount:t,quote:s,quoteAmount:l,userAddress:u,isWrappingPair:r,isUnwrappingPair:a,isBaseGasToken:h,isQuoteGasToken:b,reviewActionProps:p,reviewState:i,setReviewState:n,trackedOrderHash:w,setTrackedOrderHash:f,txStatus:c,onSwapComplete:x,onSwapInitiated:g,onOrderSubmitted:o,onStaleQuoteRestart:m,setExitHandler:y,setRetryHandler:d})=>{let{rfqQuote:T,status:P,liquidityError:C,routingError:$,sizeCapError:L,stop:N,clear:E}=Ve(),{clearForm:I}=Ne(),U=qn(),{swapButtonVariant:B,widgetType:oe}=Te(),H=oe==="compact",{trackOrderTransaction:W,trackNativeTransaction:R}=Yt(),{startPolling:V}=Lt((_,fe)=>{he.getState().setTxStatus(fe),fe==="completed"&&W(_,`Swap ${e.symbol} \u2192 ${s.symbol}`)}),[F,X]=Fn(!1),v=gr(!1),S=gr(null),O=r,A=a,q=!r&&!a,Z=U!==e?.chainId&&(O||A||q),Le=j(e.chainId),Be={chainId:e.chainId,name:Le?.displayName??`Chain ${e.chainId}`},z=pe((_,fe)=>{if(fe!==_)return;if(_==="chain"){if(O){n("wrapping");return}if(A){n("unwrapping");return}n("signingOrder");return}if(_==="signingOrder"){n("trackingTx");return}if(_==="wrapping"){if(!r){n("signingOrder");return}n("wrapSuccess");return}if(_==="unwrapping"){n("wrapSuccess");return}let yt=Ct(_);yt&&n(yt)},[n,r,O,A,q]),ie=pe(()=>Z?"chain":O?"wrapping":A?"unwrapping":q?"signingOrder":null,[Z,O,A,q]),ee=pe(()=>{n(null),I()},[I,n]),Ce=pe(async()=>{n("wrapSuccess");for(let _=0;_<3;_++)await Ze(700);ee()},[ee,n]),te=pe(async()=>{E(),n("cancelled");for(let _=0;_<3;_++)await Ze(500);ee()},[E,ee,n]),me=pe(()=>{w&&(he.getState().stopTracking(),n(null),f(null),I())},[w,n,f,I]),$e=pe(()=>{n(null),f(null),v.current=!0,m?.()},[n,f,m]),ae=pe(()=>{p&&n(ie())},[ie,p,n]),Je=pe((_=!1)=>{_?(v.current=!0,n(null),m?.()):(n(null),S.current=setTimeout(()=>{p&&(n(ie()),X(!1))},100))},[n,p,ie,m]);Pe(()=>{i!==null&&N()},[i,N]),Pe(()=>{i!==null&&F&&X(!1)},[i,F]),Pe(()=>{y?.(me)},[y,me]),Pe(()=>{d?.($e)},[d,$e]),Pe(()=>()=>{S.current&&clearTimeout(S.current)},[]),Pe(()=>{v.current&&P==="fresh"&&T?.id&&(v.current=!1,n("signingOrder"))},[P,T?.id,n]);let Ue=_=>{if(!_)return{backgroundColor:B==="default"?"var(--widget-muted)":"transparent",color:"var(--widget-muted-foreground)",border:B!=="default"?"1px solid var(--widget-border)":"none",borderRadius:"var(--widget-radius)"};switch(B){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)"}}},Se=`w-full ${H?"py-2":"py-3"} text-sm font-medium transition-colors cursor-pointer mt-1`;if(i===null&&!r&&!a){if(F)return Q("button",{className:Se,disabled:!0,style:{...Ue(!1),opacity:.6,cursor:"not-allowed"},children:"Getting fresh quote..."});let _=()=>C?"Insufficient Liquidity":$?"Route Not Available":L?"Size Cap Exceeded":!T&&P==="polling"?"Getting Quote...":T?"Swap":"Enter Amount",fe=!!p;return Q("button",{onClick:fe?ae:void 0,disabled:!fe,className:`${Se} disabled:opacity-40 disabled:cursor-not-allowed`,style:Ue(fe),children:_()})}return i===null&&a?Q("button",{onClick:p?ae:void 0,disabled:!p,className:`${Se} disabled:opacity-40 disabled:cursor-not-allowed`,style:Ue(!!p),children:"Unwrap"}):i===null&&r?Q("button",{onClick:p?ae:void 0,disabled:!p,className:`${Se} disabled:opacity-40 disabled:cursor-not-allowed`,style:Ue(!!p),children:"Wrap"}):i==="success"?Q("div",{className:"flex flex-col gap-2 w-full",children:Q("button",{className:`w-full ${H?"py-2":"py-3"} text-sm 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"})}):i==="wrapSuccess"?Q("div",{className:"flex flex-col gap-2 w-full",children:Q("button",{className:`w-full ${H?"py-2":"py-3"} text-sm 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:r?"Wrapped Successfully":"Unwrapped Successfully"})}):i==="cancelled"?Q("div",{className:"flex flex-col gap-2 w-full",children:Q("button",{onClick:ee,className:`w-full ${H?"py-2":"py-3"} text-sm 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"})}):Qn("div",{className:"flex w-full",children:[i==="chain"&&Z&&Q(er,{requiredChain:Be,needsChainSwitch:Z&&U!==e.chainId,reviewState:i,goToNextStep:z,cancel:te}),i==="wrapping"&&O&&Q(fr,{needsToWrap:O,amount:t,chainId:e.chainId,token:e,reviewState:i,setReviewState:n,goToNextStep:z,cancel:te,delayedClose:Ce,isWrappingPair:r}),i==="unwrapping"&&A&&Q(dr,{needsToUnwrap:A,amount:t,chainId:e.chainId,token:e,reviewState:i,setReviewState:n,goToNextStep:z,cancel:te,delayedClose:Ce}),i==="signingOrder"&&q&&Q(ir,{base:e,baseAmount:t,quote:s,quoteAmount:l,userAddress:u,reviewState:i,goToNextStep:z,cancel:te,restartSigningFlow:Je,onSwapInitiated:g,onOrderSubmitted:o,isWrappingPair:r,isUnwrappingPair:a,onSwapComplete:x,startPolling:V,trackNativeTransaction:R}),i==="trackingTx"&&w&&Q(cr,{orderHash:w,base:e,quote:s,baseAmount:t,quoteAmount:l,reviewState:i,status:c,onNewSwap:me,onRetry:$e}),i&&!["chain","wrapping","unwrapping","approval","signingOrder","trackingTx","success","wrapSuccess","cancelled"].includes(i)&&Q("button",{disabled:!0,className:`w-full ${H?"py-2":"py-3"} text-sm font-medium`,style:{backgroundColor:"var(--widget-muted)",color:"var(--widget-muted-foreground)",borderRadius:"var(--widget-radius)"},children:"Processing..."})]})};import{useState as wr,useCallback as jn,useRef as bt,useEffect as ht}from"react";import{useShallow as zn}from"zustand/react/shallow";import{jsx as k,jsxs as M}from"react/jsx-runtime";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)"},hr={pending:{title:"Trade Pending",subtitle:"Submitting to network"},received:{title:"Trade Received",subtitle:"Processing settlement"},completed:{title:"Trade Filled",subtitle:"Settlement complete"},failed:{title:"Trade Failed",subtitle:"Settlement unsuccessful"},cancelled:{title:"Trade Cancelled",subtitle:"Order was cancelled"}};function Gn(e){let t=br[e]??br.pending;return{textColor:t,bgColor:`color-mix(in srgb, ${t} 15%, transparent)`,borderColor:`color-mix(in srgb, ${t} 20%, transparent)`,cardBgColor:`color-mix(in srgb, ${t} 8%, transparent)`,cardBorderColor:`color-mix(in srgb, ${t} 15%, transparent)`,iconBgColor:`color-mix(in srgb, ${t} 12%, transparent)`,iconBorderColor:`color-mix(in srgb, ${t} 15%, transparent)`}}var Kn=({status:e})=>{switch(e){case"completed":return k(Y,{});case"failed":case"cancelled":return k(We,{});default:return k(G,{size:"10"})}},Hn=({orderHash:e,base:t,quote:s,baseAmount:l,quoteAmount:u,status:r})=>{let[a,h]=wr(!1),b=bt(null),p=bt(Date.now()),[i,n]=wr(null),w=bt(null),{isRecipientInputOpen:f,recipient:c}=he(zn(d=>({isRecipientInputOpen:d.isRecipientInputOpen,recipient:d.recipient})));ht(()=>{r==="received"&&(b.current=Date.now())},[r]),ht(()=>{if(r==="completed"&&!i){let d=b.current||p.current;n((Date.now()-d)/1e3)}},[r,i]),ht(()=>()=>{w.current&&clearTimeout(w.current)},[]);let x=jn(()=>{navigator.clipboard?.writeText&&navigator.clipboard.writeText(e).then(()=>{h(!0),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>h(!1),2e3)}).catch(()=>{})},[e]),g=hr[r]??hr.pending,o=Gn(r),m=ke(l),y=ke(u);return k("div",{className:"relative w-full h-full overflow-hidden flex flex-col",style:{backgroundColor:o.bgColor,border:`1px var(--widget-border-style) ${o.borderColor}`,backdropFilter:"blur(8px)"},children:M("div",{className:"relative z-10 px-3 pt-5 pb-3 flex-1 flex flex-col",children:[k("div",{className:"flex items-center justify-center mb-2",children:M("div",{className:"flex flex-col items-center gap-1 text-center",children:[k("div",{className:"flex h-10 w-10 items-center justify-center rounded-full border",style:{backgroundColor:o.iconBgColor,borderColor:o.iconBorderColor},children:k("div",{className:"h-7 w-7 flex items-center justify-center",children:k(Kn,{status:r})})}),M("div",{children:[k("h3",{className:"text-xl font-bold",style:{color:o.textColor},children:g.title}),k("p",{className:"text-2xs uppercase tracking-wider",style:{color:o.textColor,opacity:.6},children:g.subtitle})]})]})}),k("div",{className:"flex-1 flex flex-col justify-center",children:M("div",{className:"space-y-1.5",children:[M("div",{className:"flex items-center justify-between backdrop-blur-sm p-2.5 border transition-all duration-300",style:{backgroundColor:o.cardBgColor,borderColor:o.cardBorderColor},children:[M("div",{className:"flex items-center gap-2.5",children:[k(ce,{asset:t,size:"sm"}),M("div",{children:[k("div",{className:"text-sm font-bold",style:{color:o.textColor},children:t.symbol}),k("div",{className:"text-2xs",style:{color:o.textColor,opacity:.5},children:t.name})]})]}),M("div",{className:"text-right",children:[k("div",{className:"text-lg font-bold mono",style:{color:o.textColor},children:m}),t.price&&M("div",{className:"text-2xs mono",style:{color:o.textColor,opacity:.5},children:["$",(t.price*l).toFixed(2)]})]})]}),k("div",{className:"flex justify-center pb-0.5 pt-1",children:k("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border",style:{backgroundColor:o.cardBgColor,borderColor:o.cardBorderColor},children:k("span",{className:"text-base",style:{color:o.textColor},children:"\u2193"})})}),M("div",{className:"flex items-center justify-between backdrop-blur-sm p-2.5 border transition-all duration-300",style:{backgroundColor:o.cardBgColor,borderColor:o.cardBorderColor},children:[M("div",{className:"flex items-center gap-2.5",children:[k(ce,{asset:s,size:"sm"}),M("div",{children:[k("div",{className:"text-sm font-bold",style:{color:o.textColor},children:s.symbol}),k("div",{className:"text-2xs",style:{color:o.textColor,opacity:.5},children:s.name})]})]}),M("div",{className:"text-right",children:[k("div",{className:"text-lg font-bold mono",style:{color:o.textColor},children:y}),s.price&&M("div",{className:"text-2xs mono",style:{color:o.textColor,opacity:.5},children:["$",(s.price*u).toFixed(2)]})]})]}),f&&c&&M("div",{className:"mt-1.5",children:[k("div",{className:"text-2xs mb-0.5 uppercase tracking-wider font-medium",style:{color:o.textColor,opacity:.5},children:"Recipient"}),k("div",{className:"flex items-center backdrop-blur-sm p-2 border transition-all duration-300",style:{backgroundColor:o.cardBgColor,borderColor:o.cardBorderColor},children:M("div",{className:"flex items-center gap-2",children:[k("div",{className:"flex h-5 w-5 items-center justify-center overflow-hidden rounded-full",style:{backgroundColor:o.iconBgColor},children:k("span",{className:"text-2xs",children:"\u{1F464}"})}),M("div",{className:"flex flex-col",children:[k("div",{className:"text-2xs",style:{color:o.textColor,opacity:.5},children:"To:"}),M("div",{className:"text-xs mono",style:{color:o.textColor},children:[c.slice(0,6),"...",c.slice(-4)]})]})]})})]})]})}),M("div",{className:"mt-3 pt-2.5 space-y-1.5",style:{borderTop:`1px solid ${o.cardBorderColor}`},children:[M("div",{role:"button",tabIndex:0,onClick:x,onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),x())},className:"flex items-center justify-between cursor-pointer group hover:opacity-80 transition-opacity",children:[k("div",{className:"text-xs uppercase tracking-wider font-medium",style:{color:o.textColor,opacity:.5},children:a?"Copied!":r==="completed"||r==="failed"||r==="cancelled"?"Order Hash":r==="received"?"Received":"Pending"}),M("div",{className:"text-xs mono transition-colors",style:{color:o.textColor},children:[e.slice(0,6),"...",e.slice(-4)]})]}),r==="completed"&&i?M("div",{className:"flex items-center justify-between",children:[k("div",{className:"text-xs uppercase tracking-wider font-medium",style:{color:o.textColor,opacity:.5},children:"Speed"}),M("div",{className:"text-base font-bold mono",style:{color:o.textColor},children:[i.toFixed(2),"s"]})]}):k("div",{className:"h-5"})]})]})})},Oi=Hn;export{Tr as a,Ee as b,ts as c,ls as d,Ve as e,Wr as f,ms as g,ys as h,Rs as i,Ps as j,Dt as k,Lt as l,Bt as m,Hr as n,Ft as o,Xr as p,jt as q,zt as r,Gt as s,Kt as t,Ht as u,Si as v,Oi as w};
@@ -1,2 +1,2 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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 _chunkBX3KCZRTcjs = require('./chunk-BX3KCZRT.cjs');var _react = require('react'); var _react2 = _interopRequireDefault(_react);var _jsxruntime = require('react/jsx-runtime');var y=({toggle:x,side:w,onChainSelect:i,onChainHover:l,containerHeight:N})=>{let[a,d]=_react.useState.call(void 0, ""),r=_chunkBX3KCZRTcjs.z.call(void 0, a,300),v=_chunkBX3KCZRTcjs._.call(void 0, ),s=_chunkBX3KCZRTcjs.g.call(void 0, v),u=_react2.default.useMemo(()=>{if(!r)return s;let e=r.toLowerCase();return s.filter(n=>n.displayName.toLowerCase().includes(e)||n.name.toLowerCase().includes(e)||n.id.toString().includes(e))},[s,r]),f=_react.useCallback.call(void 0, e=>i(e),[i]);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-1",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:a,onChange:e=>d(e.target.value.toLowerCase())}),a&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>d(""),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",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:a?"Search Results":"Available Chains"}),u.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"}):u.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:()=>f(e.id),onMouseEnter:()=>_optionalChain([l, 'optionalCall', _2 => _2(e.displayName)]),onMouseLeave:()=>_optionalChain([l, 'optionalCall', _3 => _3(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, _chunkBX3KCZRTcjs.O,{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-mono",style:{color:"var(--widget-muted-foreground)"},children:["Chain ID: ",e.id]})]},e.id))]})]})},M= exports.a =y;exports.a = M;
2
+ var _chunkLXEKOQAGcjs = require('./chunk-LXEKOQAG.cjs');var _react = require('react'); var _react2 = _interopRequireDefault(_react);var _jsxruntime = require('react/jsx-runtime');var y=({toggle:x,side:w,onChainSelect:i,onChainHover:l,containerHeight:N})=>{let[a,d]=_react.useState.call(void 0, ""),r=_chunkLXEKOQAGcjs.z.call(void 0, a,300),v=_chunkLXEKOQAGcjs._.call(void 0, ),s=_chunkLXEKOQAGcjs.g.call(void 0, v),u=_react2.default.useMemo(()=>{if(!r)return s;let e=r.toLowerCase();return s.filter(n=>n.displayName.toLowerCase().includes(e)||n.name.toLowerCase().includes(e)||n.id.toString().includes(e))},[s,r]),f=_react.useCallback.call(void 0, e=>i(e),[i]);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-1",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:a,onChange:e=>d(e.target.value.toLowerCase())}),a&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>d(""),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",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:a?"Search Results":"Available Chains"}),u.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"}):u.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:()=>f(e.id),onMouseEnter:()=>_optionalChain([l, 'optionalCall', _2 => _2(e.displayName)]),onMouseLeave:()=>_optionalChain([l, 'optionalCall', _3 => _3(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, _chunkLXEKOQAGcjs.O,{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-mono",style:{color:"var(--widget-muted-foreground)"},children:["Chain ID: ",e.id]})]},e.id))]})]})},M= exports.a =y;exports.a = M;
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } 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; } var _class;"use client";
2
- var _chunkXUTR7YYCcjs = require('./chunk-XUTR7YYC.cjs');var _chunkNQ4QSGGFcjs = require('./chunk-NQ4QSGGF.cjs');require('./chunk-KH57FLST.cjs');var _chunk537OMWA3cjs = require('./chunk-537OMWA3.cjs');var _chunkBX3KCZRTcjs = require('./chunk-BX3KCZRT.cjs');var _chunk34N36GUDcjs = require('./chunk-34N36GUD.cjs');require('./chunk-T3I3AJXV.cjs');var _react = require('react'); var _react2 = _interopRequireDefault(_react);var _shallow = require('zustand/react/shallow');var _jsxruntime = require('react/jsx-runtime');var qt=({onSwapComplete:e,onSwapInitiated:t})=>{let{web3ConnectionType:c,hasConnectHandler:a,lockBase:s,lockQuote:b,disableInverting:k,tokenDisplay:N,tokenBadgeOrientation:W,widgetType:w}=_chunkBX3KCZRTcjs.b.call(void 0, ),S=N==="pill"||N==="ghost",C=w==="compact",I=C?"px-4 pt-3 pb-1":"px-4 pt-4 pb-2",O=C?"px-4 pt-4 pb-1":"px-4 pt-6 pb-2",{baseToken:r,quoteToken:i,baseAmount:d,quoteAmount:T,isBaseGasToken:X,isQuoteGasToken:L,isWrappingPair:u,isUnwrappingPair:g,baseBalance:m,quoteBalance:Y,setBaseAmount:R,setQuoteAmount:h,swapTokens:U,clearForm:M}=_chunk537OMWA3cjs.f.call(void 0, ),{rfqQuote:j,status:G,handleInputChange:H,ensureForParams:B,stop:z,clear:q,refresh:v}=_chunkNQ4QSGGFcjs.e.call(void 0, ),{address:x}=_chunk34N36GUDcjs.a.call(void 0, ),{openConnectModal:Z}=_chunkNQ4QSGGFcjs.g.call(void 0, ),{isRecipientInputOpen:E,txStatus:$}=_chunk537OMWA3cjs.c.call(void 0, _shallow.useShallow.call(void 0, o=>({isRecipientInputOpen:o.isRecipientInputOpen,txStatus:o.txStatus}))),[D,ee]=_react.useState.call(void 0, null),[Q,te]=_react.useState.call(void 0, null),ie=_react.useRef.call(void 0, !1),y=!1,J=_react.useMemo.call(void 0, ()=>!r||!i||typeof d!="number"||!T||!x||parseFloat(m.formatted)<d?null:{base:r,quote:i,baseAmount:d,quoteAmount:T,userAddress:x},[r,i,d,T,x,m.formatted]),ve=_react.useCallback.call(void 0, o=>{te(o),_chunk537OMWA3cjs.c.getState().startTracking(o)},[]),be=_react.useCallback.call(void 0, ()=>{ie.current=!0,v()},[v]);_react.useEffect.call(void 0, ()=>{if(D===null&&!(!r||!i)){if(!d||d<=0){H({amount:null,inputToken:r,outputToken:i,setOutputAmount:h});return}if(u||g){h(d);return}H({amount:d,inputToken:r,outputToken:i,setOutputAmount:h})}},[D,d,r,i,u,g,H,h]);let le=_react.useCallback.call(void 0, ()=>{_chunk537OMWA3cjs.c.getState().setView("baseSelection")},[]),ye=_react.useCallback.call(void 0, ()=>{_chunk537OMWA3cjs.c.getState().setView("quoteSelection")},[]),xe=_react.useCallback.call(void 0, ()=>{U(),h(null)},[U,h]),ce=_react.useCallback.call(void 0, ()=>{if(!m.formatted||!r||!i)return;let o=parseFloat(m.formatted);if(!o||o<=0)return;let V=o*.9999999999;u||g?(R(V),h(V),q()):(R(V),h(null),B({inputToken:r,outputToken:i,inputAmount:V.toString(),setOutputAmount:re=>h(re)}))},[m.formatted,r,i,u,g,R,h,q,B]),Ne=_react.useCallback.call(void 0, ()=>{q(),M()},[q,M]),we=m.formatted?parseFloat(m.formatted):null,ke=!!(d||T),Se=_optionalChain([r, 'optionalAccess', _2 => _2.price])&&d?`$${(r.price*d).toFixed(2)}`:"$0.00",Ae=_optionalChain([i, 'optionalAccess', _3 => _3.price])&&T?`$${(i.price*T).toFixed(2)}`:"$0.00",Ce=D==="trackingTx"&&!!Q&&!!r&&!!i&&!!d&&!!T;return _jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full",children:[Ce&&Q&&r&&i&&d&&T?_jsxruntime.jsx.call(void 0, "div",{className:"overflow-hidden",children:_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.w,{orderHash:Q,base:r,quote:i,baseAmount:d,quoteAmount:T,status:$})}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "div",{className:`relative ${I}`,style:{borderBottom:"1px solid var(--widget-border)"},children:[S?C?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 mb-2 ${W==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.i,{toggle:le,side:"base",asset:r,isPlacingOrder:y||s}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.h,{side:"base",asset:_nullishCoalesce(r, () => (null)),otherAsset:_nullishCoalesce(i, () => (null)),isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${W==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.i,{toggle:le,side:"base",asset:r,isPlacingOrder:y||s}),_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.h,{side:"base",asset:_nullishCoalesce(r, () => (null)),otherAsset:_nullishCoalesce(i, () => (null)),isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})]}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.i,{toggle:le,side:"base",asset:r,isPlacingOrder:y||s}),_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.h,{side:"base",asset:_nullishCoalesce(r, () => (null)),otherAsset:_nullishCoalesce(i, () => (null)),isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mb-1 flex w-full flex-row items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"mono text-sm",style:{color:"var(--widget-muted-foreground)"},children:Se}),x&&we!==null&&we>0&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:ce,disabled:y,className:"absolute bottom-3 right-4 flex items-center px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-colors bg-(--widget-primary) text-(--widget-primary-foreground) hover:bg-(--widget-foreground) hover:text-(--widget-card)",style:{borderRadius:"var(--widget-radius)"},children:"Max"})]})]}),!k&&_jsxruntime.jsx.call(void 0, "div",{className:"flex justify-center -my-4 relative z-10",children:_jsxruntime.jsxs.call(void 0, "button",{type:"button",onClick:xe,"aria-label":"Swap input and output tokens",className:"flex h-8 w-8 items-center justify-center rounded-full cursor-pointer transition-colors bg-(--widget-card) text-(--widget-muted-foreground) hover:bg-(--widget-secondary) hover:text-(--widget-foreground)",style:{border:"1px solid var(--widget-border)"},children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",children:"\u2191"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",children:"\u2193"})]})}),_jsxruntime.jsxs.call(void 0, "div",{className:`relative ${O}`,children:[S?C?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${W==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.i,{toggle:ye,side:"quote",asset:i,isPlacingOrder:y||b}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.h,{side:"quote",asset:_nullishCoalesce(i, () => (null)),otherAsset:_nullishCoalesce(r, () => (null)),isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${W==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.i,{toggle:ye,side:"quote",asset:i,isPlacingOrder:y||b}),_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.h,{side:"quote",asset:_nullishCoalesce(i, () => (null)),otherAsset:_nullishCoalesce(r, () => (null)),isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})]}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.i,{toggle:ye,side:"quote",asset:i,isPlacingOrder:y||b}),_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.h,{side:"quote",asset:_nullishCoalesce(i, () => (null)),otherAsset:_nullishCoalesce(r, () => (null)),isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full flex-row items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"mono text-sm",style:{color:"var(--widget-muted-foreground)"},children:Ae}),ke&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Ne,disabled:y,className:"absolute bottom-2 right-4 flex items-center px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-colors text-(--widget-muted-foreground) hover:bg-(--widget-secondary)",style:{borderRadius:"var(--widget-radius)"},children:"Clear"})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-row items-center w-full overflow-hidden",style:{borderTop:E?"1px solid var(--widget-border)":"none",maxHeight:E?"60px":"0px",opacity:E?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.j,{})}),_jsxruntime.jsx.call(void 0, "div",{className:"px-4",style:{borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"},children:_jsxruntime.jsx.call(void 0, _chunkXUTR7YYCcjs.a,{})})]}),_jsxruntime.jsx.call(void 0, "div",{className:`relative ${Ce?"px-0":"px-4"} ${C?"py-2":"py-4"}`,children:x&&r&&i&&d&&d>0?_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.v,{base:r,baseAmount:d,quote:i,quoteAmount:_nullishCoalesce(T, () => (0)),userAddress:x,isWrappingPair:u,isUnwrappingPair:g,isBaseGasToken:X,isQuoteGasToken:L,reviewActionProps:J,reviewState:D,setReviewState:ee,trackedOrderHash:Q,setTrackedOrderHash:te,onSwapComplete:e,onSwapInitiated:t,onOrderSubmitted:ve,onStaleQuoteRestart:be,txStatus:$}):!x&&a?_jsxruntime.jsx.call(void 0, "button",{onClick:()=>Z(),className:`w-full ${C?"py-2":"py-3"} text-sm font-medium cursor-pointer transition-opacity hover:opacity-80`,style:{backgroundColor:"var(--widget-primary)",color:"var(--widget-primary-foreground)",borderRadius:"var(--widget-radius)"},children:"Connect Wallet"}):_jsxruntime.jsx.call(void 0, "button",{disabled:!0,className:`w-full ${C?"py-2":"py-3"} text-sm font-medium transition-colors disabled:opacity-40 cursor-not-allowed`,style:{backgroundColor:"var(--widget-primary)",color:"var(--widget-primary-foreground)",borderRadius:"var(--widget-radius)"},children:x?"Enter Amount":"Connect Wallet"})})]})},rt=qt;var at=()=>_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"relative px-4 pt-4 pb-2",style:{borderBottom:"1px solid var(--widget-border)"},children:[_jsxruntime.jsx.call(void 0, "div",{className:"h-12 w-full animate-pulse",style:{backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-2 h-20 w-2/3 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-1 mb-1 flex w-full items-center justify-between",children:_jsxruntime.jsx.call(void 0, "div",{className:"h-4 w-12 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.4,borderRadius:"0.25rem"}})})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex justify-center -my-4 relative z-10",children:_jsxruntime.jsx.call(void 0, "div",{className:"h-8 w-8",style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)",borderRadius:"9999px"}})}),_jsxruntime.jsxs.call(void 0, "div",{className:"relative px-4 pt-6 pb-2",children:[_jsxruntime.jsx.call(void 0, "div",{className:"h-12 w-full animate-pulse",style:{backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-2 h-20 w-2/3 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-1 mb-1 flex w-full items-center justify-between",children:_jsxruntime.jsx.call(void 0, "div",{className:"h-4 w-12 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.4,borderRadius:"0.25rem"}})})]}),_jsxruntime.jsx.call(void 0, "div",{className:"px-4",style:{height:"28px",borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"}}),_jsxruntime.jsx.call(void 0, "div",{className:"relative px-4 py-4",children:_jsxruntime.jsx.call(void 0, "div",{className:"w-full animate-pulse",style:{height:"44px",backgroundColor:"var(--widget-secondary)",borderRadius:"var(--widget-radius)",opacity:.6}})})]});var Ht=({targetText:e,isError:t})=>{let{displayText:c,suffix:a,characterColors:s}=_chunkBX3KCZRTcjs.A.call(void 0, e,t);return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[c.split("").map((b,k)=>_jsxruntime.jsx.call(void 0, "span",{style:s[k]?{color:"var(--widget-destructive)"}:void 0,children:b},k)),_jsxruntime.jsx.call(void 0, "span",{style:{color:t?"var(--widget-destructive)":"var(--widget-muted-foreground)",opacity:t?.5:1},children:a})]})},Vt=({headerText:e,onBackClick:t,isSameChain:c,isWrappingPair:a,isUnwrappingPair:s,hasLowLiquidity:b,hasInsufficientLiquidity:k,hasRoutingError:N,hasSizeCapError:W})=>{let w=_chunk537OMWA3cjs.c.call(void 0, v=>v.view),{isRecipientInputOpen:S,hasAllowanceError:C,hoveredChainName:I,isTrackingTx:O,txStatus:r,walletTab:i}=_chunk537OMWA3cjs.c.call(void 0, _shallow.useShallow.call(void 0, v=>({isRecipientInputOpen:v.isRecipientInputOpen,hasAllowanceError:v.hasAllowanceError,hoveredChainName:v.hoveredChainName,isTrackingTx:v.isTrackingTx,txStatus:v.txStatus,walletTab:v.walletTab}))),{web3ConnectionType:d,swapHeaderVariant:T,customWalletUI:X,walletButtonEnabled:L}=_chunkBX3KCZRTcjs.b.call(void 0, ),{isConnected:u}=_chunk34N36GUDcjs.a.call(void 0, ),{openAccountModal:g}=_chunkNQ4QSGGFcjs.g.call(void 0, ),[m,Y]=_react.useState.call(void 0, !1);_react.useEffect.call(void 0, ()=>Y(!0),[]);let[R,h]=_react.useState.call(void 0, !1),U=`${w}-${R}-${S}-${I||"none"}`,j=(()=>{if(O&&r)switch(r){case"pending":return"Trade Pending";case"received":return"Trade Received";case"completed":return"Trade Filled";case"failed":return"Trade Failed";case"cancelled":return"Trade Cancelled";default:return"Processing Trade"}if(I&&(w==="baseSelection"||w==="quoteSelection"||w==="baseChainSelection"||w==="quoteChainSelection"))return I;if(w==="swap"&&R)return S?"Remove Custom Recipient":"Add Custom Recipient";switch(w){case"wallet":return"Wallet";case"baseSelection":return"Select Source Token";case"quoteSelection":return"Select Destination Token";case"baseChainSelection":return"Select Source Chain";case"quoteChainSelection":return"Select Destination Chain";default:if(w==="swap"){if(C&&!a&&!s)return"Allowance check failed";if(W&&!a&&!s)return"Size limit exceeded";if(k&&!a&&!s)return"Insufficient Liquidity";if(N&&!a&&!s)return"Route Not Found";if(b&&!a&&!s)return"High Price Impact"}return c&&!a&&!s?"Swap":a?"Wrap":s?"Unwrap":e}})(),G=!O&&w==="swap"&&!R&&(C&&!a&&!s||W&&!a&&!s||k&&!a&&!s||N&&!a&&!s||b&&!a&&!s),H={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)"},B=()=>!O||!r?null:_nullishCoalesce(H[r], () => (null)),z=()=>O?null:w==="swap"?_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[L&&m&&d==="custom"&&u&&_jsxruntime.jsx.call(void 0, "button",{onClick:()=>{X==="provider"&&g?g():_chunk537OMWA3cjs.c.getState().setView("wallet")},"aria-label":"Open wallet",className:"size-4 -translate-y-0.5 flex cursor-pointer items-center justify-center rounded-full transition-colors text-(--widget-muted-foreground) opacity-60 hover:text-(--widget-foreground) hover:opacity-100",children:_jsxruntime.jsxs.call(void 0, "svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "rect",{x:"2",y:"5",width:"20",height:"15",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),_jsxruntime.jsx.call(void 0, "path",{d:"M16 12C16 11.4477 16.4477 11 17 11H21V13H17C16.4477 13 16 12.5523 16 12Z",fill:"currentColor"}),_jsxruntime.jsx.call(void 0, "path",{d:"M2 9H22",stroke:"currentColor",strokeWidth:"1.5"})]})}),L&&m&&d==="standalone"&&u&&g&&_jsxruntime.jsx.call(void 0, "button",{onClick:()=>g(),"aria-label":"Open account",className:"size-4 -translate-y-0.5 flex cursor-pointer items-center justify-center rounded-full transition-colors text-(--widget-muted-foreground) opacity-60 hover:text-(--widget-foreground) hover:opacity-100",children:_jsxruntime.jsxs.call(void 0, "svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "rect",{x:"2",y:"5",width:"20",height:"15",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),_jsxruntime.jsx.call(void 0, "path",{d:"M16 12C16 11.4477 16.4477 11 17 11H21V13H17C16.4477 13 16 12.5523 16 12Z",fill:"currentColor"}),_jsxruntime.jsx.call(void 0, "path",{d:"M2 9H22",stroke:"currentColor",strokeWidth:"1.5"})]})}),_jsxruntime.jsx.call(void 0, "button",{onClick:()=>_chunk537OMWA3cjs.c.getState().toggleRecipientInput(),onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),"aria-label":S?"Remove custom recipient":"Add custom recipient",className:`size-4 -translate-y-0.5 flex cursor-pointer items-center justify-center rounded-full transition-colors hover:text-(--widget-foreground) hover:opacity-100 ${S?"text-(--widget-destructive) opacity-80":"text-(--widget-muted-foreground) opacity-60"}`,children:_jsxruntime.jsxs.call(void 0, "svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M2 7.75C1.58579 7.75 1.25 8.08579 1.25 8.5C1.25 8.91421 1.58579 9.25 2 9.25V7.75ZM2 8.5V9.25H13.5V8.5V7.75H2V8.5Z",fill:"currentColor"}),_jsxruntime.jsx.call(void 0, "path",{d:"M6 16.5H8",stroke:"currentColor",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"butt",strokeLinejoin:"miter"}),_jsxruntime.jsx.call(void 0, "path",{d:"M10.5 16.5H14.5",stroke:"currentColor",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"butt",strokeLinejoin:"miter"}),_jsxruntime.jsx.call(void 0, "path",{d:"M22 12.03V16.11C22 20.5 22 20.5 17.56 20.5H6.44C2 20.5 2 20.5 2 16.11V7.89C2 3.5 2 3.5 6.44 3.5H13.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"miter"}),_jsxruntime.jsxs.call(void 0, "g",{style:{transform:`rotate(${S?"45deg":"0deg"})`,transformOrigin:"18.75px 6.75px",transition:"transform 150ms ease-out"},children:[_jsxruntime.jsx.call(void 0, "path",{d:"M15 6.75H22.5",stroke:"currentColor",strokeWidth:"1.5"}),_jsxruntime.jsx.call(void 0, "path",{d:"M18.75 10.5V3",stroke:"currentColor",strokeWidth:"1.5"})]})]})})]}):_jsxruntime.jsxs.call(void 0, "button",{onClick:()=>t?t():_chunk537OMWA3cjs.c.getState().setView("swap"),className:"flex cursor-pointer items-center justify-center whitespace-nowrap h-6 transition-colors text-(--widget-muted-foreground) opacity-70 hover:text-(--widget-foreground) hover:opacity-100",children:[_jsxruntime.jsx.call(void 0, "span",{className:"pr-1",children:"\u2190"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",children:"Back"})]}),q=B();return T==="none"?null:_jsxruntime.jsxs.call(void 0, "div",{className:"w-full pt-3 px-2 mono text-base flex flex-row justify-between h-6 shrink-0",children:[w==="wallet"?_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-1 mono uppercase -translate-y-0.5 text-xs",children:[_jsxruntime.jsxs.call(void 0, "button",{type:"button",onClick:()=>_chunk537OMWA3cjs.c.getState().setWalletTab("wallet"),className:"cursor-pointer transition-colors",style:{color:i==="wallet"?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{style:{color:"var(--widget-muted-foreground)"},children:">> "}),_jsxruntime.jsx.call(void 0, "span",{children:"Wallet"})]}),_jsxruntime.jsx.call(void 0, "span",{style:{color:"var(--widget-foreground)",opacity:.4},children:">>"}),_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>_chunk537OMWA3cjs.c.getState().setWalletTab("activity"),className:"cursor-pointer transition-colors",style:{color:i==="activity"?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:"Activity"})]}):_jsxruntime.jsxs.call(void 0, "div",{className:"mono uppercase -translate-y-0.5 text-xs flex items-center",children:[_jsxruntime.jsx.call(void 0, "span",{className:"mr-1.5",style:{color:"var(--widget-muted-foreground)",opacity:.4},children:">> "}),_jsxruntime.jsx.call(void 0, "span",{className:"relative",style:{color:q||"var(--widget-foreground)"},children:_jsxruntime.jsx.call(void 0, Ht,{targetText:j,isError:_nullishCoalesce(G, () => (!1))})},U)]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-row items-center",children:z()})]})},Be=Vt;var st=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./AssetSelectionMenu-ZT2PDBHV.cjs")))),dt=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./ChainSelectionMenu-URYJUECJ.cjs")))),jt=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./SwapFormHorizontal-ACRBI6GC.cjs")))),$t=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./SwapFormSplit-XHAGOXQX.cjs")))),Dt=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./WidgetWalletPanel-FQDNFYFL.cjs"))).then(e=>({default:e.WidgetWalletPanel}))),Qt=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./WalletPlaceholderPanel-TTONBBI4.cjs"))).then(e=>({default:e.WalletPlaceholderPanel}))),_t=({onSwapComplete:e,cardStyles:t,cardWidth:c})=>{let{baseToken:a,quoteToken:s,baseAmount:b,quoteAmount:k,isWrappingPair:N,isUnwrappingPair:W,isRegistryLoading:w}=_chunk537OMWA3cjs.f.call(void 0, ),{liquidityError:S,routingError:C,sizeCapError:I,stop:O,clear:r}=_chunkNQ4QSGGFcjs.e.call(void 0, ),i=_chunk537OMWA3cjs.c.call(void 0, o=>o.view),{isTransitioning:d,isRecipientInputOpen:T,recipient:X,selectedChainFilterChainId:L}=_chunk537OMWA3cjs.c.call(void 0, _shallow.useShallow.call(void 0, o=>({isTransitioning:o.isTransitioning,isRecipientInputOpen:o.isRecipientInputOpen,recipient:o.recipient,selectedChainFilterChainId:_nullishCoalesce(_optionalChain([o, 'access', _4 => _4.selectedChainFilter, 'optionalAccess', _5 => _5.chainId]), () => (null))}))),u=_react.useRef.call(void 0, null),g=_react.useRef.call(void 0, null),[m,Y]=_react.useState.call(void 0, null);_chunkNQ4QSGGFcjs.c.call(void 0, ),_react.useEffect.call(void 0, ()=>()=>{u.current&&clearTimeout(u.current),g.current&&clearTimeout(g.current)},[]),_react.useEffect.call(void 0, ()=>{_chunk537OMWA3cjs.c.getState().resetUI()},[]),_react.useEffect.call(void 0, ()=>{if(d)return u.current=setTimeout(()=>{_chunk537OMWA3cjs.c.getState().setIsTransitioning(!1),u.current=null},20),()=>{u.current&&(clearTimeout(u.current),u.current=null)}},[d]);let R=_react.useCallback.call(void 0, (o,V="navigation")=>{g.current&&(clearTimeout(g.current),g.current=null,Y(null)),_chunk537OMWA3cjs.c.getState().view!=="swap"&&o!=="swap"?(_chunk537OMWA3cjs.c.getState().setView(o),_chunk537OMWA3cjs.c.getState().setIsTransitioning(!1)):_chunk537OMWA3cjs.c.getState().transitionToView(o,V)},[]),h=_react.useCallback.call(void 0, ()=>{u.current&&(clearTimeout(u.current),u.current=null),g.current&&(clearTimeout(g.current),g.current=null);let o=_chunk537OMWA3cjs.c.getState().view;Y(o),_chunk537OMWA3cjs.c.getState().setChainFilter(null),_chunk537OMWA3cjs.c.getState().setView("swap"),_chunk537OMWA3cjs.c.getState().setIsTransitioning(!1),_chunk537OMWA3cjs.c.getState().resetAssetSelection(),g.current=setTimeout(()=>{Y(null),g.current=null},200)},[]),U=_react.useCallback.call(void 0, o=>{let re=i==="baseChainSelection"?"base":"quote";_chunk537OMWA3cjs.c.getState().setChainFilter({chainId:o,side:re}),_chunk537OMWA3cjs.c.getState().pushRecentChain(o),R(re==="base"?"baseSelection":"quoteSelection","chainSelection")},[i,R]),M=_react.useCallback.call(void 0, ()=>{let o=_chunk537OMWA3cjs.c.getState().view;o==="baseSelection"?R("baseChainSelection","chainSelection"):o==="quoteSelection"&&R("quoteChainSelection","chainSelection")},[R]),j=_react.useCallback.call(void 0, ()=>{O(),r()},[O,r]),G=a&&s?a.chainId===s.chainId:!0,H=()=>{switch(i){case"wallet":return"Wallet";case"baseSelection":return"Select Input Token";case"quoteSelection":return"Select Output Token";case"baseChainSelection":case"quoteChainSelection":return"Select Chain";default:return"Swap"}},{assetMenuVariant:B,widgetType:z,customWalletUI:q}=_chunkBX3KCZRTcjs.b.call(void 0, ),v=i==="baseSelection"||i==="quoteSelection",x=i==="baseChainSelection"||i==="quoteChainSelection",Z=B==="split"&&(z==="default"||z==="compact"),E=B==="split"&&(z==="horizontal"||z==="split"),$=B==="default",D=i==="swap"||v||x||i==="wallet",ee=m==="baseSelection"||m==="quoteSelection",Q=m==="baseChainSelection"||m==="quoteChainSelection",te=v||ee,ie=x||Q,y=v&&!d,J=x&&!d,ve=v?i:m,be=ve==="baseSelection"?"base":"quote",le=ve==="baseSelection"?s:a,xe=(x?i:m)==="baseChainSelection"?"base":"quote",ce=o=>({backgroundColor:"var(--widget-background)",opacity:o?1:0,transform:o?"translateY(0)":"translateY(6px)",transition:"opacity 200ms ease-in-out, transform 200ms ease-in-out"}),Ne=$&&(v||x||i==="wallet"||m!=null),we=w?_jsxruntime.jsx.call(void 0, at,{}):z==="horizontal"?_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, jt,{onSwapComplete:e,onSwapInitiated:j,onBackToSwap:E?h:void 0,onMoreChainsClick:E?M:void 0})}):z==="split"?_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, $t,{onSwapComplete:e,onSwapInitiated:j,onBackToSwap:E?h:void 0,onMoreChainsClick:E?M:void 0})}):_jsxruntime.jsx.call(void 0, rt,{onSwapComplete:e,onSwapInitiated:j}),ke=_nullishCoalesce(t, () => ({})),Se=_react.useRef.call(void 0, null),[Ae,Ce]=_react.useState.call(void 0, 420);return _react.useEffect.call(void 0, ()=>{if(!Z)return;let o=Se.current;if(!o)return;let V=new ResizeObserver(re=>{for(let ft of re)Ce(ft.contentRect.height)});return V.observe(o),()=>V.disconnect()},[Z]),Z?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "div",{ref:Se,className:"flex flex-col w-full overflow-hidden transition-colors duration-300",style:{flex:"1 1 0",minWidth:0,...ke},children:[_jsxruntime.jsx.call(void 0, Be,{headerText:"Swap",onBackClick:h,isSameChain:G,isWrappingPair:N,isUnwrappingPair:W,hasLowLiquidity:S,hasInsufficientLiquidity:S,hasRoutingError:C,hasSizeCapError:I}),_jsxruntime.jsx.call(void 0, "div",{className:"overflow-hidden",children:we})]}),(te||ie)&&_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col overflow-hidden shrink-0",style:{width:c,height:`${Ae}px`,...ke,...ce((v||x)&&!d)},children:v||ee?_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, st,{toggle:h,side:be,otherAsset:le,onMoreChainsClick:M,selectedChainFilter:L})}):_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, dt,{toggle:h,side:xe,onChainSelect:U})})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full",style:{overflow:"hidden",position:"relative"},children:[_jsxruntime.jsx.call(void 0, Be,{headerText:H(),onBackClick:h,isSameChain:G,isWrappingPair:N,isUnwrappingPair:W,hasLowLiquidity:S,hasInsufficientLiquidity:S,hasRoutingError:C,hasSizeCapError:I}),_jsxruntime.jsxs.call(void 0, "div",{className:"relative overflow-hidden",children:[D&&_jsxruntime.jsx.call(void 0, "div",{className:"overflow-hidden",style:Ne?{pointerEvents:"none"}:void 0,children:we}),(i==="wallet"||m==="wallet")&&_jsxruntime.jsx.call(void 0, "div",{className:"absolute inset-0 overflow-hidden",style:ce(i==="wallet"&&!d),children:_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:q==="none"?_jsxruntime.jsx.call(void 0, Qt,{}):_jsxruntime.jsx.call(void 0, Dt,{})})}),$&&te&&_jsxruntime.jsx.call(void 0, "div",{className:"absolute inset-0 overflow-hidden",style:ce(y),children:_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, st,{toggle:h,side:be,otherAsset:le,onMoreChainsClick:M,selectedChainFilter:L})})}),$&&ie&&_jsxruntime.jsx.call(void 0, "div",{className:"absolute inset-0 overflow-hidden",style:ce(J),children:_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, dt,{toggle:h,side:xe,onChainSelect:U})})})]})]})},lt=({onSwapComplete:e,defaultBaseToken:t,defaultQuoteToken:c,onBaseTokenChange:a,onQuoteTokenChange:s,cardStyles:b,cardWidth:k})=>{let{address:N}=_chunk34N36GUDcjs.a.call(void 0, ),W=_chunk537OMWA3cjs.c.call(void 0, w=>w.recipient);return _jsxruntime.jsx.call(void 0, _chunk537OMWA3cjs.e,{defaultBaseToken:t,defaultQuoteToken:c,onBaseTokenChange:a,onQuoteTokenChange:s,children:_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.d,{recipient:W,children:_jsxruntime.jsx.call(void 0, _t,{onSwapComplete:e,cardStyles:b,cardWidth:k})})})};var Ee={background:"#ffffff",foreground:"#0a0a0a",card:"#ffffff","card-foreground":"#0a0a0a",popover:"#ffffff","popover-foreground":"#0a0a0a",primary:"#171717","primary-foreground":"#fafafa",secondary:"#f5f5f5","secondary-foreground":"#171717",muted:"#f5f5f5","muted-foreground":"#737373",accent:"#f5f5f5","accent-foreground":"#171717",destructive:"#e7000b","destructive-foreground":"#ffffff",border:"#e5e5e5",input:"#e5e5e5",ring:"#a1a1a1",radius:"0.625rem","border-style":"dotted","status-pending":"#a1a1aa","status-received":"#f59e0b","status-completed":"#10b981","status-failed":"#ef4444"},he= exports.defaultDarkTheme ={background:"#0a0a0a",foreground:"#fafafa",card:"#171717","card-foreground":"#fafafa",popover:"#262626","popover-foreground":"#fafafa",primary:"#e5e5e5","primary-foreground":"#171717",secondary:"#262626","secondary-foreground":"#fafafa",muted:"#262626","muted-foreground":"#a1a1a1",accent:"#404040","accent-foreground":"#fafafa",destructive:"#ff6467","destructive-foreground":"#fafafa",border:"#282828",input:"#343434",ring:"#737373",radius:"0.625rem","border-style":"dotted","status-pending":"#a1a1aa","status-received":"#fbbf24","status-completed":"#2dd4bf","status-failed":"#fb7185"};function Fe(e){let t={"--widget-background":e.background,"--widget-foreground":e.foreground,"--widget-card":e.card,"--widget-card-foreground":e["card-foreground"],"--widget-popover":e.popover,"--widget-popover-foreground":e["popover-foreground"],"--widget-primary":e.primary,"--widget-primary-foreground":e["primary-foreground"],"--widget-secondary":e.secondary,"--widget-secondary-foreground":e["secondary-foreground"],"--widget-muted":e.muted,"--widget-muted-foreground":e["muted-foreground"],"--widget-accent":e.accent,"--widget-accent-foreground":e["accent-foreground"],"--widget-destructive":e.destructive,"--widget-destructive-foreground":e["destructive-foreground"],"--widget-border":e.border,"--widget-input":e.input,"--widget-ring":e.ring,"--widget-radius":e.radius,"--widget-border-style":e["border-style"]||"dotted"};return t["--widget-font-sans"]=e["font-sans"]||"inherit",t["--widget-font-mono"]=e["font-mono"]||"inherit",t["--widget-shadow-color"]=e["shadow-color"]||"oklch(0 0 0)",t["--widget-shadow-opacity"]=e["shadow-opacity"]||"0.1",t["--widget-shadow-blur"]=e["shadow-blur"]||"3px",t["--widget-shadow-spread"]=e["shadow-spread"]||"0px",t["--widget-shadow-offset-x"]=e["shadow-offset-x"]||"0",t["--widget-shadow-offset-y"]=e["shadow-offset-y"]||"1px",t["--widget-letter-spacing"]=e["letter-spacing"]||"normal",t["--widget-status-pending"]=e["status-pending"]||"#a1a1aa",t["--widget-status-received"]=e["status-received"]||"#fbbf24",t["--widget-status-completed"]=e["status-completed"]||"#2dd4bf",t["--widget-status-failed"]=e["status-failed"]||"#fb7185",t}var ct=_react.createContext.call(void 0, he);function He({theme:e,children:t}){return _jsxruntime.jsx.call(void 0, ct.Provider,{value:e,children:t})}function Zt(){return _react.useContext.call(void 0, ct)}var ei=[],ti=[],ii=[],pt=[],ri=`
2
+ var _chunkDUIRZSBVcjs = require('./chunk-DUIRZSBV.cjs');var _chunkMCT3UZTPcjs = require('./chunk-MCT3UZTP.cjs');require('./chunk-KH57FLST.cjs');var _chunkUZWGYG2Scjs = require('./chunk-UZWGYG2S.cjs');var _chunkLXEKOQAGcjs = require('./chunk-LXEKOQAG.cjs');var _chunk34N36GUDcjs = require('./chunk-34N36GUD.cjs');require('./chunk-T3I3AJXV.cjs');var _react = require('react'); var _react2 = _interopRequireDefault(_react);var _shallow = require('zustand/react/shallow');var _jsxruntime = require('react/jsx-runtime');var qt=({onSwapComplete:e,onSwapInitiated:t})=>{let{web3ConnectionType:c,hasConnectHandler:a,lockBase:s,lockQuote:b,disableInverting:k,tokenDisplay:N,tokenBadgeOrientation:W,widgetType:w}=_chunkLXEKOQAGcjs.b.call(void 0, ),S=N==="pill"||N==="ghost",C=w==="compact",I=C?"px-4 pt-3 pb-1":"px-4 pt-4 pb-2",O=C?"px-4 pt-4 pb-1":"px-4 pt-6 pb-2",{baseToken:r,quoteToken:i,baseAmount:d,quoteAmount:T,isBaseGasToken:X,isQuoteGasToken:L,isWrappingPair:u,isUnwrappingPair:g,baseBalance:m,quoteBalance:Y,setBaseAmount:R,setQuoteAmount:h,swapTokens:U,clearForm:M}=_chunkUZWGYG2Scjs.f.call(void 0, ),{rfqQuote:j,status:G,handleInputChange:H,ensureForParams:B,stop:z,clear:q,refresh:v}=_chunkMCT3UZTPcjs.e.call(void 0, ),{address:x}=_chunk34N36GUDcjs.a.call(void 0, ),{openConnectModal:Z}=_chunkMCT3UZTPcjs.g.call(void 0, ),{isRecipientInputOpen:E,txStatus:$}=_chunkUZWGYG2Scjs.c.call(void 0, _shallow.useShallow.call(void 0, o=>({isRecipientInputOpen:o.isRecipientInputOpen,txStatus:o.txStatus}))),[D,ee]=_react.useState.call(void 0, null),[Q,te]=_react.useState.call(void 0, null),ie=_react.useRef.call(void 0, !1),y=!1,J=_react.useMemo.call(void 0, ()=>!r||!i||typeof d!="number"||!T||!x||parseFloat(m.formatted)<d?null:{base:r,quote:i,baseAmount:d,quoteAmount:T,userAddress:x},[r,i,d,T,x,m.formatted]),ve=_react.useCallback.call(void 0, o=>{te(o),_chunkUZWGYG2Scjs.c.getState().startTracking(o)},[]),be=_react.useCallback.call(void 0, ()=>{ie.current=!0,v()},[v]);_react.useEffect.call(void 0, ()=>{if(D===null&&!(!r||!i)){if(!d||d<=0){H({amount:null,inputToken:r,outputToken:i,setOutputAmount:h});return}if(u||g){h(d);return}H({amount:d,inputToken:r,outputToken:i,setOutputAmount:h})}},[D,d,r,i,u,g,H,h]);let le=_react.useCallback.call(void 0, ()=>{_chunkUZWGYG2Scjs.c.getState().setView("baseSelection")},[]),ye=_react.useCallback.call(void 0, ()=>{_chunkUZWGYG2Scjs.c.getState().setView("quoteSelection")},[]),xe=_react.useCallback.call(void 0, ()=>{U(),h(null)},[U,h]),ce=_react.useCallback.call(void 0, ()=>{if(!m.formatted||!r||!i)return;let o=parseFloat(m.formatted);if(!o||o<=0)return;let V=o*.9999999999;u||g?(R(V),h(V),q()):(R(V),h(null),B({inputToken:r,outputToken:i,inputAmount:V.toString(),setOutputAmount:re=>h(re)}))},[m.formatted,r,i,u,g,R,h,q,B]),Ne=_react.useCallback.call(void 0, ()=>{q(),M()},[q,M]),we=m.formatted?parseFloat(m.formatted):null,ke=!!(d||T),Se=_optionalChain([r, 'optionalAccess', _2 => _2.price])&&d?`$${(r.price*d).toFixed(2)}`:"$0.00",Ae=_optionalChain([i, 'optionalAccess', _3 => _3.price])&&T?`$${(i.price*T).toFixed(2)}`:"$0.00",Ce=D==="trackingTx"&&!!Q&&!!r&&!!i&&!!d&&!!T;return _jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full",children:[Ce&&Q&&r&&i&&d&&T?_jsxruntime.jsx.call(void 0, "div",{className:"overflow-hidden",children:_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.w,{orderHash:Q,base:r,quote:i,baseAmount:d,quoteAmount:T,status:$})}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "div",{className:`relative ${I}`,style:{borderBottom:"1px solid var(--widget-border)"},children:[S?C?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 mb-2 ${W==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.i,{toggle:le,side:"base",asset:r,isPlacingOrder:y||s}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.h,{side:"base",asset:_nullishCoalesce(r, () => (null)),otherAsset:_nullishCoalesce(i, () => (null)),isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${W==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.i,{toggle:le,side:"base",asset:r,isPlacingOrder:y||s}),_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.h,{side:"base",asset:_nullishCoalesce(r, () => (null)),otherAsset:_nullishCoalesce(i, () => (null)),isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})]}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.i,{toggle:le,side:"base",asset:r,isPlacingOrder:y||s}),_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.h,{side:"base",asset:_nullishCoalesce(r, () => (null)),otherAsset:_nullishCoalesce(i, () => (null)),isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mb-1 flex w-full flex-row items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"mono text-sm",style:{color:"var(--widget-muted-foreground)"},children:Se}),x&&we!==null&&we>0&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:ce,disabled:y,className:"absolute bottom-3 right-4 flex items-center px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-colors bg-(--widget-primary) text-(--widget-primary-foreground) hover:bg-(--widget-foreground) hover:text-(--widget-card)",style:{borderRadius:"var(--widget-radius)"},children:"Max"})]})]}),!k&&_jsxruntime.jsx.call(void 0, "div",{className:"flex justify-center -my-4 relative z-10",children:_jsxruntime.jsxs.call(void 0, "button",{type:"button",onClick:xe,"aria-label":"Swap input and output tokens",className:"flex h-8 w-8 items-center justify-center rounded-full cursor-pointer transition-colors bg-(--widget-card) text-(--widget-muted-foreground) hover:bg-(--widget-secondary) hover:text-(--widget-foreground)",style:{border:"1px solid var(--widget-border)"},children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",children:"\u2191"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",children:"\u2193"})]})}),_jsxruntime.jsxs.call(void 0, "div",{className:`relative ${O}`,children:[S?C?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${W==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.i,{toggle:ye,side:"quote",asset:i,isPlacingOrder:y||b}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.h,{side:"quote",asset:_nullishCoalesce(i, () => (null)),otherAsset:_nullishCoalesce(r, () => (null)),isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${W==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.i,{toggle:ye,side:"quote",asset:i,isPlacingOrder:y||b}),_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.h,{side:"quote",asset:_nullishCoalesce(i, () => (null)),otherAsset:_nullishCoalesce(r, () => (null)),isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})]}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.i,{toggle:ye,side:"quote",asset:i,isPlacingOrder:y||b}),_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.h,{side:"quote",asset:_nullishCoalesce(i, () => (null)),otherAsset:_nullishCoalesce(r, () => (null)),isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full flex-row items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"mono text-sm",style:{color:"var(--widget-muted-foreground)"},children:Ae}),ke&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Ne,disabled:y,className:"absolute bottom-2 right-4 flex items-center px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-colors text-(--widget-muted-foreground) hover:bg-(--widget-secondary)",style:{borderRadius:"var(--widget-radius)"},children:"Clear"})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-row items-center w-full overflow-hidden",style:{borderTop:E?"1px solid var(--widget-border)":"none",maxHeight:E?"60px":"0px",opacity:E?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.j,{})}),_jsxruntime.jsx.call(void 0, "div",{className:"px-4",style:{borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"},children:_jsxruntime.jsx.call(void 0, _chunkDUIRZSBVcjs.a,{})})]}),_jsxruntime.jsx.call(void 0, "div",{className:`relative ${Ce?"px-0":"px-4"} ${C?"py-2":"py-4"}`,children:x&&r&&i&&d&&d>0?_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.v,{base:r,baseAmount:d,quote:i,quoteAmount:_nullishCoalesce(T, () => (0)),userAddress:x,isWrappingPair:u,isUnwrappingPair:g,isBaseGasToken:X,isQuoteGasToken:L,reviewActionProps:J,reviewState:D,setReviewState:ee,trackedOrderHash:Q,setTrackedOrderHash:te,onSwapComplete:e,onSwapInitiated:t,onOrderSubmitted:ve,onStaleQuoteRestart:be,txStatus:$}):!x&&a?_jsxruntime.jsx.call(void 0, "button",{onClick:()=>Z(),className:`w-full ${C?"py-2":"py-3"} text-sm font-medium cursor-pointer transition-opacity hover:opacity-80`,style:{backgroundColor:"var(--widget-primary)",color:"var(--widget-primary-foreground)",borderRadius:"var(--widget-radius)"},children:"Connect Wallet"}):_jsxruntime.jsx.call(void 0, "button",{disabled:!0,className:`w-full ${C?"py-2":"py-3"} text-sm font-medium transition-colors disabled:opacity-40 cursor-not-allowed`,style:{backgroundColor:"var(--widget-primary)",color:"var(--widget-primary-foreground)",borderRadius:"var(--widget-radius)"},children:x?"Enter Amount":"Connect Wallet"})})]})},rt=qt;var at=()=>_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"relative px-4 pt-4 pb-2",style:{borderBottom:"1px solid var(--widget-border)"},children:[_jsxruntime.jsx.call(void 0, "div",{className:"h-12 w-full animate-pulse",style:{backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-2 h-20 w-2/3 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-1 mb-1 flex w-full items-center justify-between",children:_jsxruntime.jsx.call(void 0, "div",{className:"h-4 w-12 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.4,borderRadius:"0.25rem"}})})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex justify-center -my-4 relative z-10",children:_jsxruntime.jsx.call(void 0, "div",{className:"h-8 w-8",style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)",borderRadius:"9999px"}})}),_jsxruntime.jsxs.call(void 0, "div",{className:"relative px-4 pt-6 pb-2",children:[_jsxruntime.jsx.call(void 0, "div",{className:"h-12 w-full animate-pulse",style:{backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-2 h-20 w-2/3 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-1 mb-1 flex w-full items-center justify-between",children:_jsxruntime.jsx.call(void 0, "div",{className:"h-4 w-12 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.4,borderRadius:"0.25rem"}})})]}),_jsxruntime.jsx.call(void 0, "div",{className:"px-4",style:{height:"28px",borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"}}),_jsxruntime.jsx.call(void 0, "div",{className:"relative px-4 py-4",children:_jsxruntime.jsx.call(void 0, "div",{className:"w-full animate-pulse",style:{height:"44px",backgroundColor:"var(--widget-secondary)",borderRadius:"var(--widget-radius)",opacity:.6}})})]});var Ht=({targetText:e,isError:t})=>{let{displayText:c,suffix:a,characterColors:s}=_chunkLXEKOQAGcjs.A.call(void 0, e,t);return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[c.split("").map((b,k)=>_jsxruntime.jsx.call(void 0, "span",{style:s[k]?{color:"var(--widget-destructive)"}:void 0,children:b},k)),_jsxruntime.jsx.call(void 0, "span",{style:{color:t?"var(--widget-destructive)":"var(--widget-muted-foreground)",opacity:t?.5:1},children:a})]})},Vt=({headerText:e,onBackClick:t,isSameChain:c,isWrappingPair:a,isUnwrappingPair:s,hasLowLiquidity:b,hasInsufficientLiquidity:k,hasRoutingError:N,hasSizeCapError:W})=>{let w=_chunkUZWGYG2Scjs.c.call(void 0, v=>v.view),{isRecipientInputOpen:S,hasAllowanceError:C,hoveredChainName:I,isTrackingTx:O,txStatus:r,walletTab:i}=_chunkUZWGYG2Scjs.c.call(void 0, _shallow.useShallow.call(void 0, v=>({isRecipientInputOpen:v.isRecipientInputOpen,hasAllowanceError:v.hasAllowanceError,hoveredChainName:v.hoveredChainName,isTrackingTx:v.isTrackingTx,txStatus:v.txStatus,walletTab:v.walletTab}))),{web3ConnectionType:d,swapHeaderVariant:T,customWalletUI:X,walletButtonEnabled:L}=_chunkLXEKOQAGcjs.b.call(void 0, ),{isConnected:u}=_chunk34N36GUDcjs.a.call(void 0, ),{openAccountModal:g}=_chunkMCT3UZTPcjs.g.call(void 0, ),[m,Y]=_react.useState.call(void 0, !1);_react.useEffect.call(void 0, ()=>Y(!0),[]);let[R,h]=_react.useState.call(void 0, !1),U=`${w}-${R}-${S}-${I||"none"}`,j=(()=>{if(O&&r)switch(r){case"pending":return"Trade Pending";case"received":return"Trade Received";case"completed":return"Trade Filled";case"failed":return"Trade Failed";case"cancelled":return"Trade Cancelled";default:return"Processing Trade"}if(I&&(w==="baseSelection"||w==="quoteSelection"||w==="baseChainSelection"||w==="quoteChainSelection"))return I;if(w==="swap"&&R)return S?"Remove Custom Recipient":"Add Custom Recipient";switch(w){case"wallet":return"Wallet";case"baseSelection":return"Select Source Token";case"quoteSelection":return"Select Destination Token";case"baseChainSelection":return"Select Source Chain";case"quoteChainSelection":return"Select Destination Chain";default:if(w==="swap"){if(C&&!a&&!s)return"Allowance check failed";if(W&&!a&&!s)return"Size limit exceeded";if(k&&!a&&!s)return"Insufficient Liquidity";if(N&&!a&&!s)return"Route Not Found";if(b&&!a&&!s)return"High Price Impact"}return c&&!a&&!s?"Swap":a?"Wrap":s?"Unwrap":e}})(),G=!O&&w==="swap"&&!R&&(C&&!a&&!s||W&&!a&&!s||k&&!a&&!s||N&&!a&&!s||b&&!a&&!s),H={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)"},B=()=>!O||!r?null:_nullishCoalesce(H[r], () => (null)),z=()=>O?null:w==="swap"?_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[L&&m&&d==="custom"&&u&&_jsxruntime.jsx.call(void 0, "button",{onClick:()=>{X==="provider"&&g?g():_chunkUZWGYG2Scjs.c.getState().setView("wallet")},"aria-label":"Open wallet",className:"size-4 -translate-y-0.5 flex cursor-pointer items-center justify-center rounded-full transition-colors text-(--widget-muted-foreground) opacity-60 hover:text-(--widget-foreground) hover:opacity-100",children:_jsxruntime.jsxs.call(void 0, "svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "rect",{x:"2",y:"5",width:"20",height:"15",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),_jsxruntime.jsx.call(void 0, "path",{d:"M16 12C16 11.4477 16.4477 11 17 11H21V13H17C16.4477 13 16 12.5523 16 12Z",fill:"currentColor"}),_jsxruntime.jsx.call(void 0, "path",{d:"M2 9H22",stroke:"currentColor",strokeWidth:"1.5"})]})}),L&&m&&d==="standalone"&&u&&g&&_jsxruntime.jsx.call(void 0, "button",{onClick:()=>g(),"aria-label":"Open account",className:"size-4 -translate-y-0.5 flex cursor-pointer items-center justify-center rounded-full transition-colors text-(--widget-muted-foreground) opacity-60 hover:text-(--widget-foreground) hover:opacity-100",children:_jsxruntime.jsxs.call(void 0, "svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "rect",{x:"2",y:"5",width:"20",height:"15",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),_jsxruntime.jsx.call(void 0, "path",{d:"M16 12C16 11.4477 16.4477 11 17 11H21V13H17C16.4477 13 16 12.5523 16 12Z",fill:"currentColor"}),_jsxruntime.jsx.call(void 0, "path",{d:"M2 9H22",stroke:"currentColor",strokeWidth:"1.5"})]})}),_jsxruntime.jsx.call(void 0, "button",{onClick:()=>_chunkUZWGYG2Scjs.c.getState().toggleRecipientInput(),onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),"aria-label":S?"Remove custom recipient":"Add custom recipient",className:`size-4 -translate-y-0.5 flex cursor-pointer items-center justify-center rounded-full transition-colors hover:text-(--widget-foreground) hover:opacity-100 ${S?"text-(--widget-destructive) opacity-80":"text-(--widget-muted-foreground) opacity-60"}`,children:_jsxruntime.jsxs.call(void 0, "svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M2 7.75C1.58579 7.75 1.25 8.08579 1.25 8.5C1.25 8.91421 1.58579 9.25 2 9.25V7.75ZM2 8.5V9.25H13.5V8.5V7.75H2V8.5Z",fill:"currentColor"}),_jsxruntime.jsx.call(void 0, "path",{d:"M6 16.5H8",stroke:"currentColor",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"butt",strokeLinejoin:"miter"}),_jsxruntime.jsx.call(void 0, "path",{d:"M10.5 16.5H14.5",stroke:"currentColor",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"butt",strokeLinejoin:"miter"}),_jsxruntime.jsx.call(void 0, "path",{d:"M22 12.03V16.11C22 20.5 22 20.5 17.56 20.5H6.44C2 20.5 2 20.5 2 16.11V7.89C2 3.5 2 3.5 6.44 3.5H13.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"miter"}),_jsxruntime.jsxs.call(void 0, "g",{style:{transform:`rotate(${S?"45deg":"0deg"})`,transformOrigin:"18.75px 6.75px",transition:"transform 150ms ease-out"},children:[_jsxruntime.jsx.call(void 0, "path",{d:"M15 6.75H22.5",stroke:"currentColor",strokeWidth:"1.5"}),_jsxruntime.jsx.call(void 0, "path",{d:"M18.75 10.5V3",stroke:"currentColor",strokeWidth:"1.5"})]})]})})]}):_jsxruntime.jsxs.call(void 0, "button",{onClick:()=>t?t():_chunkUZWGYG2Scjs.c.getState().setView("swap"),className:"flex cursor-pointer items-center justify-center whitespace-nowrap h-6 transition-colors text-(--widget-muted-foreground) opacity-70 hover:text-(--widget-foreground) hover:opacity-100",children:[_jsxruntime.jsx.call(void 0, "span",{className:"pr-1",children:"\u2190"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",children:"Back"})]}),q=B();return T==="none"?null:_jsxruntime.jsxs.call(void 0, "div",{className:"w-full pt-3 px-2 mono text-base flex flex-row justify-between h-6 shrink-0",children:[w==="wallet"?_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-1 mono uppercase -translate-y-0.5 text-xs",children:[_jsxruntime.jsxs.call(void 0, "button",{type:"button",onClick:()=>_chunkUZWGYG2Scjs.c.getState().setWalletTab("wallet"),className:"cursor-pointer transition-colors",style:{color:i==="wallet"?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{style:{color:"var(--widget-muted-foreground)"},children:">> "}),_jsxruntime.jsx.call(void 0, "span",{children:"Wallet"})]}),_jsxruntime.jsx.call(void 0, "span",{style:{color:"var(--widget-foreground)",opacity:.4},children:">>"}),_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>_chunkUZWGYG2Scjs.c.getState().setWalletTab("activity"),className:"cursor-pointer transition-colors",style:{color:i==="activity"?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:"Activity"})]}):_jsxruntime.jsxs.call(void 0, "div",{className:"mono uppercase -translate-y-0.5 text-xs flex items-center",children:[_jsxruntime.jsx.call(void 0, "span",{className:"mr-1.5",style:{color:"var(--widget-muted-foreground)",opacity:.4},children:">> "}),_jsxruntime.jsx.call(void 0, "span",{className:"relative",style:{color:q||"var(--widget-foreground)"},children:_jsxruntime.jsx.call(void 0, Ht,{targetText:j,isError:_nullishCoalesce(G, () => (!1))})},U)]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-row items-center",children:z()})]})},Be=Vt;var st=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./AssetSelectionMenu-4E576X3D.cjs")))),dt=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./ChainSelectionMenu-VU3SIBVL.cjs")))),jt=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./SwapFormHorizontal-V557YBX2.cjs")))),$t=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./SwapFormSplit-PQCS3BPT.cjs")))),Dt=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./WidgetWalletPanel-YBMN5KZH.cjs"))).then(e=>({default:e.WidgetWalletPanel}))),Qt=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./WalletPlaceholderPanel-TTONBBI4.cjs"))).then(e=>({default:e.WalletPlaceholderPanel}))),_t=({onSwapComplete:e,cardStyles:t,cardWidth:c})=>{let{baseToken:a,quoteToken:s,baseAmount:b,quoteAmount:k,isWrappingPair:N,isUnwrappingPair:W,isRegistryLoading:w}=_chunkUZWGYG2Scjs.f.call(void 0, ),{liquidityError:S,routingError:C,sizeCapError:I,stop:O,clear:r}=_chunkMCT3UZTPcjs.e.call(void 0, ),i=_chunkUZWGYG2Scjs.c.call(void 0, o=>o.view),{isTransitioning:d,isRecipientInputOpen:T,recipient:X,selectedChainFilterChainId:L}=_chunkUZWGYG2Scjs.c.call(void 0, _shallow.useShallow.call(void 0, o=>({isTransitioning:o.isTransitioning,isRecipientInputOpen:o.isRecipientInputOpen,recipient:o.recipient,selectedChainFilterChainId:_nullishCoalesce(_optionalChain([o, 'access', _4 => _4.selectedChainFilter, 'optionalAccess', _5 => _5.chainId]), () => (null))}))),u=_react.useRef.call(void 0, null),g=_react.useRef.call(void 0, null),[m,Y]=_react.useState.call(void 0, null);_chunkMCT3UZTPcjs.c.call(void 0, ),_react.useEffect.call(void 0, ()=>()=>{u.current&&clearTimeout(u.current),g.current&&clearTimeout(g.current)},[]),_react.useEffect.call(void 0, ()=>{_chunkUZWGYG2Scjs.c.getState().resetUI()},[]),_react.useEffect.call(void 0, ()=>{if(d)return u.current=setTimeout(()=>{_chunkUZWGYG2Scjs.c.getState().setIsTransitioning(!1),u.current=null},20),()=>{u.current&&(clearTimeout(u.current),u.current=null)}},[d]);let R=_react.useCallback.call(void 0, (o,V="navigation")=>{g.current&&(clearTimeout(g.current),g.current=null,Y(null)),_chunkUZWGYG2Scjs.c.getState().view!=="swap"&&o!=="swap"?(_chunkUZWGYG2Scjs.c.getState().setView(o),_chunkUZWGYG2Scjs.c.getState().setIsTransitioning(!1)):_chunkUZWGYG2Scjs.c.getState().transitionToView(o,V)},[]),h=_react.useCallback.call(void 0, ()=>{u.current&&(clearTimeout(u.current),u.current=null),g.current&&(clearTimeout(g.current),g.current=null);let o=_chunkUZWGYG2Scjs.c.getState().view;Y(o),_chunkUZWGYG2Scjs.c.getState().setChainFilter(null),_chunkUZWGYG2Scjs.c.getState().setView("swap"),_chunkUZWGYG2Scjs.c.getState().setIsTransitioning(!1),_chunkUZWGYG2Scjs.c.getState().resetAssetSelection(),g.current=setTimeout(()=>{Y(null),g.current=null},200)},[]),U=_react.useCallback.call(void 0, o=>{let re=i==="baseChainSelection"?"base":"quote";_chunkUZWGYG2Scjs.c.getState().setChainFilter({chainId:o,side:re}),_chunkUZWGYG2Scjs.c.getState().pushRecentChain(o),R(re==="base"?"baseSelection":"quoteSelection","chainSelection")},[i,R]),M=_react.useCallback.call(void 0, ()=>{let o=_chunkUZWGYG2Scjs.c.getState().view;o==="baseSelection"?R("baseChainSelection","chainSelection"):o==="quoteSelection"&&R("quoteChainSelection","chainSelection")},[R]),j=_react.useCallback.call(void 0, ()=>{O(),r()},[O,r]),G=a&&s?a.chainId===s.chainId:!0,H=()=>{switch(i){case"wallet":return"Wallet";case"baseSelection":return"Select Input Token";case"quoteSelection":return"Select Output Token";case"baseChainSelection":case"quoteChainSelection":return"Select Chain";default:return"Swap"}},{assetMenuVariant:B,widgetType:z,customWalletUI:q}=_chunkLXEKOQAGcjs.b.call(void 0, ),v=i==="baseSelection"||i==="quoteSelection",x=i==="baseChainSelection"||i==="quoteChainSelection",Z=B==="split"&&(z==="default"||z==="compact"),E=B==="split"&&(z==="horizontal"||z==="split"),$=B==="default",D=i==="swap"||v||x||i==="wallet",ee=m==="baseSelection"||m==="quoteSelection",Q=m==="baseChainSelection"||m==="quoteChainSelection",te=v||ee,ie=x||Q,y=v&&!d,J=x&&!d,ve=v?i:m,be=ve==="baseSelection"?"base":"quote",le=ve==="baseSelection"?s:a,xe=(x?i:m)==="baseChainSelection"?"base":"quote",ce=o=>({backgroundColor:"var(--widget-background)",opacity:o?1:0,transform:o?"translateY(0)":"translateY(6px)",transition:"opacity 200ms ease-in-out, transform 200ms ease-in-out"}),Ne=$&&(v||x||i==="wallet"||m!=null),we=w?_jsxruntime.jsx.call(void 0, at,{}):z==="horizontal"?_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, jt,{onSwapComplete:e,onSwapInitiated:j,onBackToSwap:E?h:void 0,onMoreChainsClick:E?M:void 0})}):z==="split"?_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, $t,{onSwapComplete:e,onSwapInitiated:j,onBackToSwap:E?h:void 0,onMoreChainsClick:E?M:void 0})}):_jsxruntime.jsx.call(void 0, rt,{onSwapComplete:e,onSwapInitiated:j}),ke=_nullishCoalesce(t, () => ({})),Se=_react.useRef.call(void 0, null),[Ae,Ce]=_react.useState.call(void 0, 420);return _react.useEffect.call(void 0, ()=>{if(!Z)return;let o=Se.current;if(!o)return;let V=new ResizeObserver(re=>{for(let ft of re)Ce(ft.contentRect.height)});return V.observe(o),()=>V.disconnect()},[Z]),Z?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "div",{ref:Se,className:"flex flex-col w-full overflow-hidden transition-colors duration-300",style:{flex:"1 1 0",minWidth:0,...ke},children:[_jsxruntime.jsx.call(void 0, Be,{headerText:"Swap",onBackClick:h,isSameChain:G,isWrappingPair:N,isUnwrappingPair:W,hasLowLiquidity:S,hasInsufficientLiquidity:S,hasRoutingError:C,hasSizeCapError:I}),_jsxruntime.jsx.call(void 0, "div",{className:"overflow-hidden",children:we})]}),(te||ie)&&_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col overflow-hidden shrink-0",style:{width:c,height:`${Ae}px`,...ke,...ce((v||x)&&!d)},children:v||ee?_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, st,{toggle:h,side:be,otherAsset:le,onMoreChainsClick:M,selectedChainFilter:L})}):_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, dt,{toggle:h,side:xe,onChainSelect:U})})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full",style:{overflow:"hidden",position:"relative"},children:[_jsxruntime.jsx.call(void 0, Be,{headerText:H(),onBackClick:h,isSameChain:G,isWrappingPair:N,isUnwrappingPair:W,hasLowLiquidity:S,hasInsufficientLiquidity:S,hasRoutingError:C,hasSizeCapError:I}),_jsxruntime.jsxs.call(void 0, "div",{className:"relative overflow-hidden",children:[D&&_jsxruntime.jsx.call(void 0, "div",{className:"overflow-hidden",style:Ne?{pointerEvents:"none"}:void 0,children:we}),(i==="wallet"||m==="wallet")&&_jsxruntime.jsx.call(void 0, "div",{className:"absolute inset-0 overflow-hidden",style:ce(i==="wallet"&&!d),children:_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:q==="none"?_jsxruntime.jsx.call(void 0, Qt,{}):_jsxruntime.jsx.call(void 0, Dt,{})})}),$&&te&&_jsxruntime.jsx.call(void 0, "div",{className:"absolute inset-0 overflow-hidden",style:ce(y),children:_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, st,{toggle:h,side:be,otherAsset:le,onMoreChainsClick:M,selectedChainFilter:L})})}),$&&ie&&_jsxruntime.jsx.call(void 0, "div",{className:"absolute inset-0 overflow-hidden",style:ce(J),children:_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, dt,{toggle:h,side:xe,onChainSelect:U})})})]})]})},lt=({onSwapComplete:e,defaultBaseToken:t,defaultQuoteToken:c,onBaseTokenChange:a,onQuoteTokenChange:s,cardStyles:b,cardWidth:k})=>{let{address:N}=_chunk34N36GUDcjs.a.call(void 0, ),W=_chunkUZWGYG2Scjs.c.call(void 0, w=>w.recipient);return _jsxruntime.jsx.call(void 0, _chunkUZWGYG2Scjs.e,{defaultBaseToken:t,defaultQuoteToken:c,onBaseTokenChange:a,onQuoteTokenChange:s,children:_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.d,{recipient:W,children:_jsxruntime.jsx.call(void 0, _t,{onSwapComplete:e,cardStyles:b,cardWidth:k})})})};var Ee={background:"#ffffff",foreground:"#0a0a0a",card:"#ffffff","card-foreground":"#0a0a0a",popover:"#ffffff","popover-foreground":"#0a0a0a",primary:"#171717","primary-foreground":"#fafafa",secondary:"#f5f5f5","secondary-foreground":"#171717",muted:"#f5f5f5","muted-foreground":"#737373",accent:"#f5f5f5","accent-foreground":"#171717",destructive:"#e7000b","destructive-foreground":"#ffffff",border:"#e5e5e5",input:"#e5e5e5",ring:"#a1a1a1",radius:"0.625rem","border-style":"dotted","status-pending":"#a1a1aa","status-received":"#f59e0b","status-completed":"#10b981","status-failed":"#ef4444"},he= exports.defaultDarkTheme ={background:"#0a0a0a",foreground:"#fafafa",card:"#171717","card-foreground":"#fafafa",popover:"#262626","popover-foreground":"#fafafa",primary:"#e5e5e5","primary-foreground":"#171717",secondary:"#262626","secondary-foreground":"#fafafa",muted:"#262626","muted-foreground":"#a1a1a1",accent:"#404040","accent-foreground":"#fafafa",destructive:"#ff6467","destructive-foreground":"#fafafa",border:"#282828",input:"#343434",ring:"#737373",radius:"0.625rem","border-style":"dotted","status-pending":"#a1a1aa","status-received":"#fbbf24","status-completed":"#2dd4bf","status-failed":"#fb7185"};function Fe(e){let t={"--widget-background":e.background,"--widget-foreground":e.foreground,"--widget-card":e.card,"--widget-card-foreground":e["card-foreground"],"--widget-popover":e.popover,"--widget-popover-foreground":e["popover-foreground"],"--widget-primary":e.primary,"--widget-primary-foreground":e["primary-foreground"],"--widget-secondary":e.secondary,"--widget-secondary-foreground":e["secondary-foreground"],"--widget-muted":e.muted,"--widget-muted-foreground":e["muted-foreground"],"--widget-accent":e.accent,"--widget-accent-foreground":e["accent-foreground"],"--widget-destructive":e.destructive,"--widget-destructive-foreground":e["destructive-foreground"],"--widget-border":e.border,"--widget-input":e.input,"--widget-ring":e.ring,"--widget-radius":e.radius,"--widget-border-style":e["border-style"]||"dotted"};return t["--widget-font-sans"]=e["font-sans"]||"inherit",t["--widget-font-mono"]=e["font-mono"]||"inherit",t["--widget-shadow-color"]=e["shadow-color"]||"oklch(0 0 0)",t["--widget-shadow-opacity"]=e["shadow-opacity"]||"0.1",t["--widget-shadow-blur"]=e["shadow-blur"]||"3px",t["--widget-shadow-spread"]=e["shadow-spread"]||"0px",t["--widget-shadow-offset-x"]=e["shadow-offset-x"]||"0",t["--widget-shadow-offset-y"]=e["shadow-offset-y"]||"1px",t["--widget-letter-spacing"]=e["letter-spacing"]||"normal",t["--widget-status-pending"]=e["status-pending"]||"#a1a1aa",t["--widget-status-received"]=e["status-received"]||"#fbbf24",t["--widget-status-completed"]=e["status-completed"]||"#2dd4bf",t["--widget-status-failed"]=e["status-failed"]||"#fb7185",t}var ct=_react.createContext.call(void 0, he);function He({theme:e,children:t}){return _jsxruntime.jsx.call(void 0, ct.Provider,{value:e,children:t})}function Zt(){return _react.useContext.call(void 0, ct)}var ei=[],ti=[],ii=[],pt=[],ri=`
3
3
  .aori-widget .text-2xs { font-size: 0.75rem; }
4
4
  .aori-widget .text-3xs { font-size: 0.68rem; }
5
5
  .aori-widget ::-webkit-scrollbar { width: 0px; height: 0px; display: none; }
@@ -7,4 +7,4 @@ var _chunkXUTR7YYCcjs = require('./chunk-XUTR7YYC.cjs');var _chunkNQ4QSGGFcjs =
7
7
  .aori-widget input:focus, .aori-widget input:focus-visible,
8
8
  .aori-widget button:focus, .aori-widget button:focus-visible,
9
9
  .aori-widget select:focus, .aori-widget select:focus-visible { outline: none; }
10
- `,Ve= (_class =class extends _react2.default.Component{constructor(...args) { super(...args); _class.prototype.__init.call(this); }__init() {this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?_jsxruntime.jsxs.call(void 0, "div",{style:{padding:"1.5rem",textAlign:"center",color:"var(--widget-foreground, #888)",fontFamily:"system-ui, sans-serif"},children:[_jsxruntime.jsx.call(void 0, "p",{style:{margin:"0 0 0.75rem",fontSize:"0.875rem"},children:"Something went wrong."}),_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>this.setState({hasError:!1}),style:{padding:"0.375rem 1rem",fontSize:"0.8125rem",cursor:"pointer",border:"1px solid currentColor",borderRadius:"0.25rem",background:"transparent",color:"inherit"},children:"Retry"})]}):this.props.children}}, _class);function ai(e){let t=e.theme.mode==="light"?Ee:he,c=e.theme.mode==="light"?e.theme.light:e.theme.dark;return c?{...t,...c}:t}function oi({config:e,className:t,onSwapComplete:c,onBaseTokenChange:a,onQuoteTokenChange:s,onRequestConnect:b,onRequestAccount:k,customWalletUI:N="builtin"}){_chunkBX3KCZRTcjs.n.call(void 0, e.apiKey),_chunkBX3KCZRTcjs.p.call(void 0, e.rpcOverrides),_chunkBX3KCZRTcjs.l.call(void 0, e.vtApiBaseUrl);let W=ai(e),w=_nullishCoalesce(_optionalChain([e, 'access', _6 => _6.appearance, 'optionalAccess', _7 => _7.widgetType]), () => ("default")),S=_nullishCoalesce(_optionalChain([e, 'access', _8 => _8.appearance, 'optionalAccess', _9 => _9.tokenDisplay]), () => ("default")),C=_nullishCoalesce(_optionalChain([e, 'access', _10 => _10.appearance, 'optionalAccess', _11 => _11.tokenBadgeOrientation]), () => ("left")),I=_nullishCoalesce(_optionalChain([e, 'access', _12 => _12.appearance, 'optionalAccess', _13 => _13.assetMenuVariant]), () => ("default")),O=_nullishCoalesce(_optionalChain([e, 'access', _14 => _14.appearance, 'optionalAccess', _15 => _15.amountInputVariant]), () => ("default")),r=_nullishCoalesce(_optionalChain([e, 'access', _16 => _16.appearance, 'optionalAccess', _17 => _17.hideAmountInputSymbol]), () => (!1)),i=_nullishCoalesce(_optionalChain([e, 'access', _18 => _18.appearance, 'optionalAccess', _19 => _19.swapButtonVariant]), () => ("default")),d=_nullishCoalesce(_optionalChain([e, 'access', _20 => _20.appearance, 'optionalAccess', _21 => _21.swapHeaderVariant]), () => ("default")),T=_nullishCoalesce(_optionalChain([e, 'access', _22 => _22.appearance, 'optionalAccess', _23 => _23.quoteLoaderVariant]), () => ("default")),X=_nullishCoalesce(_optionalChain([e, 'access', _24 => _24.appearance, 'optionalAccess', _25 => _25.walletButtonEnabled]), () => (!0)),L=_nullishCoalesce(_optionalChain([e, 'access', _26 => _26.appearance, 'optionalAccess', _27 => _27.fillContainer]), () => (!1)),u=_nullishCoalesce(_optionalChain([e, 'access', _28 => _28.appearance, 'optionalAccess', _29 => _29.hideBorder]), () => (!1)),g=Fe(W),m=I==="split"&&(w==="default"||w==="compact"),Y=_chunk537OMWA3cjs.c.call(void 0, J=>J.view==="baseSelection"||J.view==="quoteSelection"||J.view==="baseChainSelection"||J.view==="quoteChainSelection"),R=w==="compact"?"22rem":"24rem",U=m?{maxWidth:Y?w==="compact"?"46rem":"49rem":R,transition:"max-width 0.3s ease",height:"auto",overflow:"visible",display:"flex",gap:"1rem",alignItems:"stretch",backgroundColor:"transparent",border:"none",borderRadius:0,boxShadow:"none",padding:0}:{width:"100%",...L?{}:{maxWidth:w==="split"||w==="horizontal"?"48rem":w==="compact"?"22rem":"24rem"},height:"auto",overflow:"hidden"},M={boxSizing:"border-box",backgroundColor:"var(--widget-background)",color:"var(--widget-foreground)",borderRadius:"var(--widget-radius)",...u?{border:"none"}:{borderWidth:"1px",borderStyle:"var(--widget-border-style)",borderColor:"var(--widget-border)"},boxShadow:"var(--widget-shadow-offset-x) var(--widget-shadow-offset-y) var(--widget-shadow-blur) var(--widget-shadow-spread) color-mix(in srgb, var(--widget-shadow-color) calc(var(--widget-shadow-opacity) * 100%), transparent)",padding:"0.25rem 0.5rem",paddingTop:"0.25rem"},j=_nullishCoalesce(_optionalChain([e, 'access', _30 => _30.tokens, 'optionalAccess', _31 => _31.enabledChains]), () => (ei)),G=_nullishCoalesce(_optionalChain([e, 'access', _32 => _32.tokens, 'optionalAccess', _33 => _33.supportedInputTokens]), () => (ti)),H=_nullishCoalesce(_optionalChain([e, 'access', _34 => _34.tokens, 'optionalAccess', _35 => _35.supportedOutputTokens]), () => (ii)),B=_nullishCoalesce(_optionalChain([e, 'access', _36 => _36.tokens, 'optionalAccess', _37 => _37.supportedInputChains]), () => (pt)),z=_nullishCoalesce(_optionalChain([e, 'access', _38 => _38.tokens, 'optionalAccess', _39 => _39.supportedOutputChains]), () => (pt)),q=_nullishCoalesce(_optionalChain([e, 'access', _40 => _40.tokens, 'optionalAccess', _41 => _41.inputSelectionSearch]), () => (!0)),v=_nullishCoalesce(_optionalChain([e, 'access', _42 => _42.tokens, 'optionalAccess', _43 => _43.outputSelectionSearch]), () => (!0)),x=_nullishCoalesce(_optionalChain([e, 'access', _44 => _44.tokens, 'optionalAccess', _45 => _45.showInputSelectionTokenBalances]), () => (!0)),Z=_nullishCoalesce(_optionalChain([e, 'access', _46 => _46.tokens, 'optionalAccess', _47 => _47.showOutputSelectionTokenBalances]), () => (!0)),E=_nullishCoalesce(_optionalChain([e, 'access', _48 => _48.tokens, 'optionalAccess', _49 => _49.lockBase]), () => (!1)),$=_nullishCoalesce(_optionalChain([e, 'access', _50 => _50.tokens, 'optionalAccess', _51 => _51.lockQuote]), () => (!1)),D=_nullishCoalesce(_optionalChain([e, 'access', _52 => _52.tokens, 'optionalAccess', _53 => _53.disableInverting]), () => (!1)),ee=_nullishCoalesce(_optionalChain([e, 'access', _54 => _54.settings, 'optionalAccess', _55 => _55.defaultSlippage]), () => (.01)),Q=!!b,te=_react.useMemo.call(void 0, ()=>({apiKey:e.apiKey,web3ConnectionType:"custom",enabledChains:j,supportedInputTokens:G,supportedOutputTokens:H,supportedInputChains:B,supportedOutputChains:z,inputSelectionSearch:q,outputSelectionSearch:v,showInputSelectionTokenBalances:x,showOutputSelectionTokenBalances:Z,lockBase:E,lockQuote:$,disableInverting:D,defaultSlippage:ee,widgetType:w,tokenDisplay:S,tokenBadgeOrientation:C,assetMenuVariant:I,amountInputVariant:O,hideAmountInputSymbol:r,swapButtonVariant:i,swapHeaderVariant:d,quoteLoaderVariant:T,walletButtonEnabled:X,hasConnectHandler:Q,customWalletUI:N}),[e.apiKey,j,G,H,B,z,q,v,x,Z,E,$,D,ee,w,S,C,I,O,r,i,d,T,X,Q,N]),ie=_react.useMemo.call(void 0, ()=>b?{openConnectModal:b,openAccountModal:k}:null,[b,k]),y=_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.N,{children:_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.a.Provider,{value:te,children:_jsxruntime.jsx.call(void 0, He,{theme:W,children:_jsxruntime.jsxs.call(void 0, "div",{className:`aori-widget${t?` ${t}`:""}`,style:{...g,"--font-sans":"var(--widget-font-sans)","--font-mono":"var(--widget-font-mono)",fontFamily:"var(--widget-font-sans)",letterSpacing:"var(--widget-letter-spacing)",width:"100%",...U,position:"relative",...m?{}:M},children:[_jsxruntime.jsx.call(void 0, "style",{dangerouslySetInnerHTML:{__html:ri}}),_jsxruntime.jsx.call(void 0, Ve,{children:_jsxruntime.jsx.call(void 0, lt,{onSwapComplete:c,defaultBaseToken:_optionalChain([e, 'access', _56 => _56.tokens, 'optionalAccess', _57 => _57.defaultBase]),defaultQuoteToken:_optionalChain([e, 'access', _58 => _58.tokens, 'optionalAccess', _59 => _59.defaultQuote]),onBaseTokenChange:a,onQuoteTokenChange:s,cardStyles:m?M:void 0,cardWidth:m?R:void 0})})]})})})});return ie?_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.f.Provider,{value:ie,children:y}):y}function ni(){let{openConnectModal:e}=_chunkNQ4QSGGFcjs.g.call(void 0, ),{isConnected:t,address:c}=_chunk34N36GUDcjs.a.call(void 0, ),a=t&&c?`${c.slice(0,6)}...${c.slice(-4)}`:"Connect";return _jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>e(),className:"h-8 cursor-pointer px-3 text-xs font-bold uppercase tracking-wide transition-colors duration-150 border border-border rounded-sm bg-card text-foreground hover:bg-secondary hover:border-foreground/20",children:a})}var _wagmi = require('wagmi');function li(e){let t=Object.entries(_chunkBX3KCZRTcjs.d);return Object.fromEntries(t.map(([c,a])=>{let s=_optionalChain([e, 'optionalAccess', _60 => _60[Number(c)]]),b=s?Array.isArray(s)?s:[s]:[],k=b.length>0?[...b,...a.rpcUrls]:a.rpcUrls;return[c,k.length>1?_wagmi.fallback.call(void 0, k.map(N=>_wagmi.http.call(void 0, N,{batch:{batchSize:50,wait:50}}))):_wagmi.http.call(void 0, k[0],{batch:{batchSize:50,wait:50}})]}))}var ci=_chunkBX3KCZRTcjs.f.call(void 0, ).map(e=>e.wagmiChain);var gi=e=>{let{tokenRegistry:t,isLoadingRegistry:c,error:a}=_chunkBX3KCZRTcjs.F.call(void 0, );return{tokens:_react.useMemo.call(void 0, ()=>t.filter(b=>b.chainId===e),[t,e]),isLoading:c,error:a}},pi= exports.useIsTokenSupported =(e,t)=>{let{tokenRegistry:c}=_chunkBX3KCZRTcjs.F.call(void 0, );return _react.useMemo.call(void 0, ()=>!e||!c.length?!1:c.some(a=>a.address.toLowerCase()===e.toLowerCase()&&a.chainId===t),[c,e,t])},wi= exports.useTokenByAddress =(e,t)=>{let{getToken:c}=_chunkBX3KCZRTcjs.F.call(void 0, );return _react.useMemo.call(void 0, ()=>{if(!(!e||!t))return c(t,e)},[c,e,t])},Nr=_chunkBX3KCZRTcjs.i.call(void 0, );exports.ChainSwitch = _chunkNQ4QSGGFcjs.n; exports.ConnectButton = ni; exports.RfqProvider = _chunkNQ4QSGGFcjs.d; exports.SignSwap = _chunkNQ4QSGGFcjs.o; exports.SwapFormProvider = _chunk537OMWA3cjs.e; exports.SwapWidget = oi; exports.WidgetThemeProvider = He; exports.buildTransports = li; exports.canSubmitOrder = _chunkNQ4QSGGFcjs.q; exports.cleanupOldSubmissions = _chunkNQ4QSGGFcjs.s; exports.defaultDarkTheme = he; exports.defaultLightTheme = Ee; exports.isQuoteFresh = _chunkNQ4QSGGFcjs.p; exports.markOrderAsSubmitted = _chunkNQ4QSGGFcjs.r; exports.pollOrderStatus = _chunkNQ4QSGGFcjs.k; exports.themeToCSS = Fe; exports.useBalanceEventListener = _chunkNQ4QSGGFcjs.a; exports.useBalanceEventSubscription = _chunkNQ4QSGGFcjs.c; exports.useEmitBalanceEvent = _chunkNQ4QSGGFcjs.b; exports.useIsTokenSupported = pi; exports.useOrderStatusPolling = _chunkNQ4QSGGFcjs.l; exports.useRfq = _chunkNQ4QSGGFcjs.e; exports.useSwapForm = _chunk537OMWA3cjs.d; exports.useSwapFormContext = _chunk537OMWA3cjs.f; exports.useTokenByAddress = wi; exports.useTokenSelection = _chunk537OMWA3cjs.b; exports.useTokenSelectionStore = _chunk537OMWA3cjs.a; exports.useTokensForChain = gi; exports.useTransactionRegistry = _chunkNQ4QSGGFcjs.m; exports.useUnwrapToken = _chunkNQ4QSGGFcjs.t; exports.useWalletModal = _chunkNQ4QSGGFcjs.g; exports.useWalletState = _chunk34N36GUDcjs.a; exports.useWidgetSwapUIStore = _chunk537OMWA3cjs.c; exports.useWidgetTheme = Zt; exports.useWrapToken = _chunkNQ4QSGGFcjs.u; exports.wagmiChains = ci;
10
+ `,Ve= (_class =class extends _react2.default.Component{constructor(...args) { super(...args); _class.prototype.__init.call(this); }__init() {this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?_jsxruntime.jsxs.call(void 0, "div",{style:{padding:"1.5rem",textAlign:"center",color:"var(--widget-foreground, #888)",fontFamily:"system-ui, sans-serif"},children:[_jsxruntime.jsx.call(void 0, "p",{style:{margin:"0 0 0.75rem",fontSize:"0.875rem"},children:"Something went wrong."}),_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>this.setState({hasError:!1}),style:{padding:"0.375rem 1rem",fontSize:"0.8125rem",cursor:"pointer",border:"1px solid currentColor",borderRadius:"0.25rem",background:"transparent",color:"inherit"},children:"Retry"})]}):this.props.children}}, _class);function ai(e){let t=e.theme.mode==="light"?Ee:he,c=e.theme.mode==="light"?e.theme.light:e.theme.dark;return c?{...t,...c}:t}function oi({config:e,className:t,onSwapComplete:c,onBaseTokenChange:a,onQuoteTokenChange:s,onRequestConnect:b,onRequestAccount:k,customWalletUI:N="builtin"}){_chunkLXEKOQAGcjs.n.call(void 0, e.apiKey),_chunkLXEKOQAGcjs.p.call(void 0, e.rpcOverrides),_chunkLXEKOQAGcjs.l.call(void 0, e.vtApiBaseUrl);let W=ai(e),w=_nullishCoalesce(_optionalChain([e, 'access', _6 => _6.appearance, 'optionalAccess', _7 => _7.widgetType]), () => ("default")),S=_nullishCoalesce(_optionalChain([e, 'access', _8 => _8.appearance, 'optionalAccess', _9 => _9.tokenDisplay]), () => ("default")),C=_nullishCoalesce(_optionalChain([e, 'access', _10 => _10.appearance, 'optionalAccess', _11 => _11.tokenBadgeOrientation]), () => ("left")),I=_nullishCoalesce(_optionalChain([e, 'access', _12 => _12.appearance, 'optionalAccess', _13 => _13.assetMenuVariant]), () => ("default")),O=_nullishCoalesce(_optionalChain([e, 'access', _14 => _14.appearance, 'optionalAccess', _15 => _15.amountInputVariant]), () => ("default")),r=_nullishCoalesce(_optionalChain([e, 'access', _16 => _16.appearance, 'optionalAccess', _17 => _17.hideAmountInputSymbol]), () => (!1)),i=_nullishCoalesce(_optionalChain([e, 'access', _18 => _18.appearance, 'optionalAccess', _19 => _19.swapButtonVariant]), () => ("default")),d=_nullishCoalesce(_optionalChain([e, 'access', _20 => _20.appearance, 'optionalAccess', _21 => _21.swapHeaderVariant]), () => ("default")),T=_nullishCoalesce(_optionalChain([e, 'access', _22 => _22.appearance, 'optionalAccess', _23 => _23.quoteLoaderVariant]), () => ("default")),X=_nullishCoalesce(_optionalChain([e, 'access', _24 => _24.appearance, 'optionalAccess', _25 => _25.walletButtonEnabled]), () => (!0)),L=_nullishCoalesce(_optionalChain([e, 'access', _26 => _26.appearance, 'optionalAccess', _27 => _27.fillContainer]), () => (!1)),u=_nullishCoalesce(_optionalChain([e, 'access', _28 => _28.appearance, 'optionalAccess', _29 => _29.hideBorder]), () => (!1)),g=Fe(W),m=I==="split"&&(w==="default"||w==="compact"),Y=_chunkUZWGYG2Scjs.c.call(void 0, J=>J.view==="baseSelection"||J.view==="quoteSelection"||J.view==="baseChainSelection"||J.view==="quoteChainSelection"),R=w==="compact"?"22rem":"24rem",U=m?{maxWidth:Y?w==="compact"?"46rem":"49rem":R,transition:"max-width 0.3s ease",height:"auto",overflow:"visible",display:"flex",gap:"1rem",alignItems:"stretch",backgroundColor:"transparent",border:"none",borderRadius:0,boxShadow:"none",padding:0}:{width:"100%",...L?{}:{maxWidth:w==="split"||w==="horizontal"?"48rem":w==="compact"?"22rem":"24rem"},height:"auto",overflow:"hidden"},M={boxSizing:"border-box",backgroundColor:"var(--widget-background)",color:"var(--widget-foreground)",borderRadius:"var(--widget-radius)",...u?{border:"none"}:{borderWidth:"1px",borderStyle:"var(--widget-border-style)",borderColor:"var(--widget-border)"},boxShadow:"var(--widget-shadow-offset-x) var(--widget-shadow-offset-y) var(--widget-shadow-blur) var(--widget-shadow-spread) color-mix(in srgb, var(--widget-shadow-color) calc(var(--widget-shadow-opacity) * 100%), transparent)",padding:"0.25rem 0.5rem",paddingTop:"0.25rem"},j=_nullishCoalesce(_optionalChain([e, 'access', _30 => _30.tokens, 'optionalAccess', _31 => _31.enabledChains]), () => (ei)),G=_nullishCoalesce(_optionalChain([e, 'access', _32 => _32.tokens, 'optionalAccess', _33 => _33.supportedInputTokens]), () => (ti)),H=_nullishCoalesce(_optionalChain([e, 'access', _34 => _34.tokens, 'optionalAccess', _35 => _35.supportedOutputTokens]), () => (ii)),B=_nullishCoalesce(_optionalChain([e, 'access', _36 => _36.tokens, 'optionalAccess', _37 => _37.supportedInputChains]), () => (pt)),z=_nullishCoalesce(_optionalChain([e, 'access', _38 => _38.tokens, 'optionalAccess', _39 => _39.supportedOutputChains]), () => (pt)),q=_nullishCoalesce(_optionalChain([e, 'access', _40 => _40.tokens, 'optionalAccess', _41 => _41.inputSelectionSearch]), () => (!0)),v=_nullishCoalesce(_optionalChain([e, 'access', _42 => _42.tokens, 'optionalAccess', _43 => _43.outputSelectionSearch]), () => (!0)),x=_nullishCoalesce(_optionalChain([e, 'access', _44 => _44.tokens, 'optionalAccess', _45 => _45.showInputSelectionTokenBalances]), () => (!0)),Z=_nullishCoalesce(_optionalChain([e, 'access', _46 => _46.tokens, 'optionalAccess', _47 => _47.showOutputSelectionTokenBalances]), () => (!0)),E=_nullishCoalesce(_optionalChain([e, 'access', _48 => _48.tokens, 'optionalAccess', _49 => _49.lockBase]), () => (!1)),$=_nullishCoalesce(_optionalChain([e, 'access', _50 => _50.tokens, 'optionalAccess', _51 => _51.lockQuote]), () => (!1)),D=_nullishCoalesce(_optionalChain([e, 'access', _52 => _52.tokens, 'optionalAccess', _53 => _53.disableInverting]), () => (!1)),ee=_nullishCoalesce(_optionalChain([e, 'access', _54 => _54.settings, 'optionalAccess', _55 => _55.defaultSlippage]), () => (.01)),Q=!!b,te=_react.useMemo.call(void 0, ()=>({apiKey:e.apiKey,web3ConnectionType:"custom",enabledChains:j,supportedInputTokens:G,supportedOutputTokens:H,supportedInputChains:B,supportedOutputChains:z,inputSelectionSearch:q,outputSelectionSearch:v,showInputSelectionTokenBalances:x,showOutputSelectionTokenBalances:Z,lockBase:E,lockQuote:$,disableInverting:D,defaultSlippage:ee,widgetType:w,tokenDisplay:S,tokenBadgeOrientation:C,assetMenuVariant:I,amountInputVariant:O,hideAmountInputSymbol:r,swapButtonVariant:i,swapHeaderVariant:d,quoteLoaderVariant:T,walletButtonEnabled:X,hasConnectHandler:Q,customWalletUI:N}),[e.apiKey,j,G,H,B,z,q,v,x,Z,E,$,D,ee,w,S,C,I,O,r,i,d,T,X,Q,N]),ie=_react.useMemo.call(void 0, ()=>b?{openConnectModal:b,openAccountModal:k}:null,[b,k]),y=_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.N,{children:_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.a.Provider,{value:te,children:_jsxruntime.jsx.call(void 0, He,{theme:W,children:_jsxruntime.jsxs.call(void 0, "div",{className:`aori-widget${t?` ${t}`:""}`,style:{...g,"--font-sans":"var(--widget-font-sans)","--font-mono":"var(--widget-font-mono)",fontFamily:"var(--widget-font-sans)",letterSpacing:"var(--widget-letter-spacing)",width:"100%",...U,position:"relative",...m?{}:M},children:[_jsxruntime.jsx.call(void 0, "style",{dangerouslySetInnerHTML:{__html:ri}}),_jsxruntime.jsx.call(void 0, Ve,{children:_jsxruntime.jsx.call(void 0, lt,{onSwapComplete:c,defaultBaseToken:_optionalChain([e, 'access', _56 => _56.tokens, 'optionalAccess', _57 => _57.defaultBase]),defaultQuoteToken:_optionalChain([e, 'access', _58 => _58.tokens, 'optionalAccess', _59 => _59.defaultQuote]),onBaseTokenChange:a,onQuoteTokenChange:s,cardStyles:m?M:void 0,cardWidth:m?R:void 0})})]})})})});return ie?_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.f.Provider,{value:ie,children:y}):y}function ni(){let{openConnectModal:e}=_chunkMCT3UZTPcjs.g.call(void 0, ),{isConnected:t,address:c}=_chunk34N36GUDcjs.a.call(void 0, ),a=t&&c?`${c.slice(0,6)}...${c.slice(-4)}`:"Connect";return _jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>e(),className:"h-8 cursor-pointer px-3 text-xs font-bold uppercase tracking-wide transition-colors duration-150 border border-border rounded-sm bg-card text-foreground hover:bg-secondary hover:border-foreground/20",children:a})}var _wagmi = require('wagmi');function li(e){let t=Object.entries(_chunkLXEKOQAGcjs.d);return Object.fromEntries(t.map(([c,a])=>{let s=_optionalChain([e, 'optionalAccess', _60 => _60[Number(c)]]),b=s?Array.isArray(s)?s:[s]:[],k=b.length>0?[...b,...a.rpcUrls]:a.rpcUrls;return[c,k.length>1?_wagmi.fallback.call(void 0, k.map(N=>_wagmi.http.call(void 0, N,{batch:{batchSize:50,wait:50}}))):_wagmi.http.call(void 0, k[0],{batch:{batchSize:50,wait:50}})]}))}var ci=_chunkLXEKOQAGcjs.f.call(void 0, ).map(e=>e.wagmiChain);var gi=e=>{let{tokenRegistry:t,isLoadingRegistry:c,error:a}=_chunkLXEKOQAGcjs.F.call(void 0, );return{tokens:_react.useMemo.call(void 0, ()=>t.filter(b=>b.chainId===e),[t,e]),isLoading:c,error:a}},pi= exports.useIsTokenSupported =(e,t)=>{let{tokenRegistry:c}=_chunkLXEKOQAGcjs.F.call(void 0, );return _react.useMemo.call(void 0, ()=>!e||!c.length?!1:c.some(a=>a.address.toLowerCase()===e.toLowerCase()&&a.chainId===t),[c,e,t])},wi= exports.useTokenByAddress =(e,t)=>{let{getToken:c}=_chunkLXEKOQAGcjs.F.call(void 0, );return _react.useMemo.call(void 0, ()=>{if(!(!e||!t))return c(t,e)},[c,e,t])},Nr=_chunkLXEKOQAGcjs.i.call(void 0, );exports.ChainSwitch = _chunkMCT3UZTPcjs.n; exports.ConnectButton = ni; exports.RfqProvider = _chunkMCT3UZTPcjs.d; exports.SignSwap = _chunkMCT3UZTPcjs.o; exports.SwapFormProvider = _chunkUZWGYG2Scjs.e; exports.SwapWidget = oi; exports.WidgetThemeProvider = He; exports.buildTransports = li; exports.canSubmitOrder = _chunkMCT3UZTPcjs.q; exports.cleanupOldSubmissions = _chunkMCT3UZTPcjs.s; exports.defaultDarkTheme = he; exports.defaultLightTheme = Ee; exports.isQuoteFresh = _chunkMCT3UZTPcjs.p; exports.markOrderAsSubmitted = _chunkMCT3UZTPcjs.r; exports.pollOrderStatus = _chunkMCT3UZTPcjs.k; exports.themeToCSS = Fe; exports.useBalanceEventListener = _chunkMCT3UZTPcjs.a; exports.useBalanceEventSubscription = _chunkMCT3UZTPcjs.c; exports.useEmitBalanceEvent = _chunkMCT3UZTPcjs.b; exports.useIsTokenSupported = pi; exports.useOrderStatusPolling = _chunkMCT3UZTPcjs.l; exports.useRfq = _chunkMCT3UZTPcjs.e; exports.useSwapForm = _chunkUZWGYG2Scjs.d; exports.useSwapFormContext = _chunkUZWGYG2Scjs.f; exports.useTokenByAddress = wi; exports.useTokenSelection = _chunkUZWGYG2Scjs.b; exports.useTokenSelectionStore = _chunkUZWGYG2Scjs.a; exports.useTokensForChain = gi; exports.useTransactionRegistry = _chunkMCT3UZTPcjs.m; exports.useUnwrapToken = _chunkMCT3UZTPcjs.t; exports.useWalletModal = _chunkMCT3UZTPcjs.g; exports.useWalletState = _chunk34N36GUDcjs.a; exports.useWidgetSwapUIStore = _chunkUZWGYG2Scjs.c; exports.useWidgetTheme = Zt; exports.useWrapToken = _chunkMCT3UZTPcjs.u; exports.wagmiChains = ci;