@aori/mega-swap-widget 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +31 -0
  2. package/dist/AssetSelectionMenu-KOJBN3OR.js +2 -0
  3. package/dist/AssetSelectionMenu-M7HHUUWM.cjs +2 -0
  4. package/dist/ChainSelectionMenu-EJANKMWU.cjs +2 -0
  5. package/dist/ChainSelectionMenu-YCFDREZO.js +2 -0
  6. package/dist/SwapFormHorizontal-6YSJJM2S.cjs +2 -0
  7. package/dist/SwapFormHorizontal-E32W3PHA.js +2 -0
  8. package/dist/SwapFormSplit-6Y2B4VU3.cjs +2 -0
  9. package/dist/SwapFormSplit-M4YIQNAW.js +2 -0
  10. package/dist/WidgetWalletPanel-LKFDBFYR.cjs +2 -0
  11. package/dist/WidgetWalletPanel-T5L5224H.js +2 -0
  12. package/dist/WidgetWalletTradeHistory-PZLWJ2IK.js +2 -0
  13. package/dist/WidgetWalletTradeHistory-SDYMU4HL.cjs +2 -0
  14. package/dist/chunk-3RAZPKY5.js +2 -0
  15. package/dist/chunk-4CM44UII.cjs +2 -0
  16. package/dist/chunk-52HJQZWW.cjs +2 -0
  17. package/dist/chunk-5WTODHGO.cjs +2 -0
  18. package/dist/chunk-7QJJOVSV.js +2 -0
  19. package/dist/chunk-BJYKILHS.cjs +2 -0
  20. package/dist/chunk-EXGKQSDI.cjs +2 -0
  21. package/dist/chunk-GDIG4JLQ.cjs +2 -0
  22. package/dist/chunk-JVRQLJXZ.js +2 -0
  23. package/dist/chunk-SBQ3EQ2U.js +2 -0
  24. package/dist/chunk-SE6JOLEM.cjs +27 -0
  25. package/dist/chunk-TCAVGM6Y.cjs +2 -0
  26. package/dist/chunk-VI4ISTPB.js +2 -0
  27. package/dist/chunk-ZA7N764R.js +2 -0
  28. package/dist/chunk-ZFVYFTDI.js +2 -0
  29. package/dist/chunk-ZKDVXDQF.cjs +2 -0
  30. package/dist/chunk-ZWGBVGLP.js +2 -0
  31. package/dist/chunk-ZWNDO5OZ.js +27 -0
  32. package/dist/index.cjs +2 -2
  33. package/dist/index.css +1 -1
  34. package/dist/index.d.cts +3 -1
  35. package/dist/index.d.ts +3 -1
  36. package/dist/index.js +2 -2
  37. package/package.json +1 -1
  38. package/dist/AssetSelectionMenu-4E576X3D.cjs +0 -2
  39. package/dist/AssetSelectionMenu-ZFY7XFRX.js +0 -2
  40. package/dist/ChainSelectionMenu-SKXLHK3S.js +0 -2
  41. package/dist/ChainSelectionMenu-VU3SIBVL.cjs +0 -2
  42. package/dist/SwapFormHorizontal-GI4X7ISS.js +0 -2
  43. package/dist/SwapFormHorizontal-V557YBX2.cjs +0 -2
  44. package/dist/SwapFormSplit-52RBMJIO.js +0 -2
  45. package/dist/SwapFormSplit-PQCS3BPT.cjs +0 -2
  46. package/dist/WidgetWalletPanel-XYV3YL4I.js +0 -2
  47. package/dist/WidgetWalletPanel-YBMN5KZH.cjs +0 -2
  48. package/dist/chunk-4BQRVCQR.js +0 -2
  49. package/dist/chunk-4LJJMEOG.js +0 -2
  50. package/dist/chunk-726CI6GC.js +0 -2
  51. package/dist/chunk-DUIRZSBV.cjs +0 -2
  52. package/dist/chunk-EW2OR6CJ.js +0 -27
  53. package/dist/chunk-FDQKBTWP.js +0 -2
  54. package/dist/chunk-HTWUZKYO.cjs +0 -2
  55. package/dist/chunk-LXEKOQAG.cjs +0 -27
  56. package/dist/chunk-MCT3UZTP.cjs +0 -2
  57. package/dist/chunk-UZWGYG2S.cjs +0 -2
  58. package/dist/chunk-XYF2YBR3.js +0 -2
  59. package/dist/chunk-XZRXVBSB.cjs +0 -2
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import{a as Je}from"./chunk-4BQRVCQR.js";import{a as mt,b as ht,c as Pe,d as Ie,e as ue,f as Ze,g as ae,h as oe,i as ne,j as Xe,k as xt,l as kt,m as St,n as Ct,o as Tt,p as Rt,q as Wt,r as Nt,s as At,t as Pt,u as It,v as et,w as tt}from"./chunk-XYF2YBR3.js";import"./chunk-OPN7WCJR.js";import{a as vt,b as bt,c as n,d as yt,e as Oe,f as fe}from"./chunk-726CI6GC.js";import{A as Ye,F as Te,N as Ge,a as Ue,b as ge,d as je,f as $e,i as De,l as Qe,n as _e,p as Ke}from"./chunk-EW2OR6CJ.js";import{a as _}from"./chunk-46H44R7V.js";import"./chunk-73CB2I7U.js";import Xt,{useMemo as gt}from"react";import{Suspense as de,lazy as pe,useCallback as me,useEffect as Re,useRef as qe,useState as nt}from"react";import{useShallow as Ut}from"zustand/react/shallow";import{useCallback as se,useEffect as Ot,useMemo as zt,useRef as Mt,useState as it}from"react";import{useShallow as Bt}from"zustand/react/shallow";import{Fragment as ze,jsx as l,jsxs as A}from"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}=ge(),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}=fe(),{rfqQuote:j,status:G,handleInputChange:H,ensureForParams:B,stop:z,clear:q,refresh:v}=ue(),{address:x}=_(),{openConnectModal:Z}=ae(),{isRecipientInputOpen:E,txStatus:$}=n(Bt(o=>({isRecipientInputOpen:o.isRecipientInputOpen,txStatus:o.txStatus}))),[D,ee]=it(null),[Q,te]=it(null),ie=Mt(!1),y=!1,J=zt(()=>!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=se(o=>{te(o),n.getState().startTracking(o)},[]),be=se(()=>{ie.current=!0,v()},[v]);Ot(()=>{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=se(()=>{n.getState().setView("baseSelection")},[]),ye=se(()=>{n.getState().setView("quoteSelection")},[]),xe=se(()=>{U(),h(null)},[U,h]),ce=se(()=>{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=se(()=>{q(),M()},[q,M]),we=m.formatted?parseFloat(m.formatted):null,ke=!!(d||T),Se=r?.price&&d?`$${(r.price*d).toFixed(2)}`:"$0.00",Ae=i?.price&&T?`$${(i.price*T).toFixed(2)}`:"$0.00",Ce=D==="trackingTx"&&!!Q&&!!r&&!!i&&!!d&&!!T;return A("div",{className:"flex flex-col w-full",children:[Ce&&Q&&r&&i&&d&&T?l("div",{className:"overflow-hidden",children:l(tt,{orderHash:Q,base:r,quote:i,baseAmount:d,quoteAmount:T,status:$})}):A(ze,{children:[A("div",{className:`relative ${I}`,style:{borderBottom:"1px solid var(--widget-border)"},children:[S?C?A("div",{className:`flex items-center gap-2 mb-2 ${W==="right"?"flex-row-reverse":"flex-row"}`,children:[l(ne,{toggle:le,side:"base",asset:r,isPlacingOrder:y||s}),l("div",{className:"flex-1 min-w-0",children:l(oe,{side:"base",asset:r??null,otherAsset:i??null,isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})})]}):A("div",{className:`flex flex-col ${W==="right"?"items-end":"items-start"}`,children:[l(ne,{toggle:le,side:"base",asset:r,isPlacingOrder:y||s}),l(oe,{side:"base",asset:r??null,otherAsset:i??null,isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})]}):A(ze,{children:[l(ne,{toggle:le,side:"base",asset:r,isPlacingOrder:y||s}),l(oe,{side:"base",asset:r??null,otherAsset:i??null,isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})]}),A("div",{className:"mb-1 flex w-full flex-row items-center justify-between",children:[l("p",{className:"mono text-sm",style:{color:"var(--widget-muted-foreground)"},children:Se}),x&&we!==null&&we>0&&l("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&&l("div",{className:"flex justify-center -my-4 relative z-10",children:A("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:[l("span",{className:"text-2xs",children:"\u2191"}),l("span",{className:"text-2xs",children:"\u2193"})]})}),A("div",{className:`relative ${O}`,children:[S?C?A("div",{className:`flex items-center gap-2 ${W==="right"?"flex-row-reverse":"flex-row"}`,children:[l(ne,{toggle:ye,side:"quote",asset:i,isPlacingOrder:y||b}),l("div",{className:"flex-1 min-w-0",children:l(oe,{side:"quote",asset:i??null,otherAsset:r??null,isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})})]}):A("div",{className:`flex flex-col ${W==="right"?"items-end":"items-start"}`,children:[l(ne,{toggle:ye,side:"quote",asset:i,isPlacingOrder:y||b}),l(oe,{side:"quote",asset:i??null,otherAsset:r??null,isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})]}):A(ze,{children:[l(ne,{toggle:ye,side:"quote",asset:i,isPlacingOrder:y||b}),l(oe,{side:"quote",asset:i??null,otherAsset:r??null,isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})]}),A("div",{className:"flex w-full flex-row items-center justify-between",children:[l("p",{className:"mono text-sm",style:{color:"var(--widget-muted-foreground)"},children:Ae}),ke&&l("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"})]})]}),l("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:l(Xe,{})}),l("div",{className:"px-4",style:{borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"},children:l(Je,{})})]}),l("div",{className:`relative ${Ce?"px-0":"px-4"} ${C?"py-2":"py-4"}`,children:x&&r&&i&&d&&d>0?l(et,{base:r,baseAmount:d,quote:i,quoteAmount: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?l("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"}):l("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;import{jsx as P,jsxs as Me}from"react/jsx-runtime";var at=()=>Me("div",{className:"flex flex-col w-full",children:[Me("div",{className:"relative px-4 pt-4 pb-2",style:{borderBottom:"1px solid var(--widget-border)"},children:[P("div",{className:"h-12 w-full animate-pulse",style:{backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}}),P("div",{className:"mt-2 h-20 w-2/3 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}}),P("div",{className:"mt-1 mb-1 flex w-full items-center justify-between",children:P("div",{className:"h-4 w-12 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.4,borderRadius:"0.25rem"}})})]}),P("div",{className:"flex justify-center -my-4 relative z-10",children:P("div",{className:"h-8 w-8",style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)",borderRadius:"9999px"}})}),Me("div",{className:"relative px-4 pt-6 pb-2",children:[P("div",{className:"h-12 w-full animate-pulse",style:{backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}}),P("div",{className:"mt-2 h-20 w-2/3 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}}),P("div",{className:"mt-1 mb-1 flex w-full items-center justify-between",children:P("div",{className:"h-4 w-12 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.4,borderRadius:"0.25rem"}})})]}),P("div",{className:"px-4",style:{height:"28px",borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"}}),P("div",{className:"relative px-4 py-4",children:P("div",{className:"w-full animate-pulse",style:{height:"44px",backgroundColor:"var(--widget-secondary)",borderRadius:"var(--widget-radius)",opacity:.6}})})]});import{useEffect as Et,useState as ot}from"react";import{useShallow as Ft}from"zustand/react/shallow";import{Fragment as Lt,jsx as f,jsxs as F}from"react/jsx-runtime";var Ht=({targetText:e,isError:t})=>{let{displayText:c,suffix:a,characterColors:s}=Ye(e,t);return F(Lt,{children:[c.split("").map((b,k)=>f("span",{style:s[k]?{color:"var(--widget-destructive)"}:void 0,children:b},k)),f("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=n(v=>v.view),{isRecipientInputOpen:S,hasAllowanceError:C,hoveredChainName:I,isTrackingTx:O,txStatus:r,walletTab:i}=n(Ft(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}=ge(),{isConnected:u}=_(),{openAccountModal:g}=ae(),[m,Y]=ot(!1);Et(()=>Y(!0),[]);let[R,h]=ot(!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:H[r]??null,z=()=>O?null:w==="swap"?F("div",{className:"flex items-center gap-2",children:[L&&m&&d==="custom"&&u&&f("button",{onClick:()=>{X==="provider"&&g?g():n.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:F("svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f("rect",{x:"2",y:"5",width:"20",height:"15",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),f("path",{d:"M16 12C16 11.4477 16.4477 11 17 11H21V13H17C16.4477 13 16 12.5523 16 12Z",fill:"currentColor"}),f("path",{d:"M2 9H22",stroke:"currentColor",strokeWidth:"1.5"})]})}),L&&m&&d==="standalone"&&u&&g&&f("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:F("svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f("rect",{x:"2",y:"5",width:"20",height:"15",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),f("path",{d:"M16 12C16 11.4477 16.4477 11 17 11H21V13H17C16.4477 13 16 12.5523 16 12Z",fill:"currentColor"}),f("path",{d:"M2 9H22",stroke:"currentColor",strokeWidth:"1.5"})]})}),f("button",{onClick:()=>n.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:F("svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f("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"}),f("path",{d:"M6 16.5H8",stroke:"currentColor",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"butt",strokeLinejoin:"miter"}),f("path",{d:"M10.5 16.5H14.5",stroke:"currentColor",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"butt",strokeLinejoin:"miter"}),f("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"}),F("g",{style:{transform:`rotate(${S?"45deg":"0deg"})`,transformOrigin:"18.75px 6.75px",transition:"transform 150ms ease-out"},children:[f("path",{d:"M15 6.75H22.5",stroke:"currentColor",strokeWidth:"1.5"}),f("path",{d:"M18.75 10.5V3",stroke:"currentColor",strokeWidth:"1.5"})]})]})})]}):F("button",{onClick:()=>t?t():n.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:[f("span",{className:"pr-1",children:"\u2190"}),f("span",{className:"text-sm",children:"Back"})]}),q=B();return T==="none"?null:F("div",{className:"w-full pt-3 px-2 mono text-base flex flex-row justify-between h-6 shrink-0",children:[w==="wallet"?F("div",{className:"flex items-center gap-1 mono uppercase -translate-y-0.5 text-xs",children:[F("button",{type:"button",onClick:()=>n.getState().setWalletTab("wallet"),className:"cursor-pointer transition-colors",style:{color:i==="wallet"?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:[f("span",{style:{color:"var(--widget-muted-foreground)"},children:">> "}),f("span",{children:"Wallet"})]}),f("span",{style:{color:"var(--widget-foreground)",opacity:.4},children:">>"}),f("button",{type:"button",onClick:()=>n.getState().setWalletTab("activity"),className:"cursor-pointer transition-colors",style:{color:i==="activity"?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:"Activity"})]}):F("div",{className:"mono uppercase -translate-y-0.5 text-xs flex items-center",children:[f("span",{className:"mr-1.5",style:{color:"var(--widget-muted-foreground)",opacity:.4},children:">> "}),f("span",{className:"relative",style:{color:q||"var(--widget-foreground)"},children:f(Ht,{targetText:j,isError:G??!1})},U)]}),f("div",{className:"flex flex-row items-center",children:z()})]})},Be=Vt;import{Fragment as Kt,jsx as p,jsxs as We}from"react/jsx-runtime";var st=pe(()=>import("./AssetSelectionMenu-ZFY7XFRX.js")),dt=pe(()=>import("./ChainSelectionMenu-SKXLHK3S.js")),jt=pe(()=>import("./SwapFormHorizontal-GI4X7ISS.js")),$t=pe(()=>import("./SwapFormSplit-52RBMJIO.js")),Dt=pe(()=>import("./WidgetWalletPanel-XYV3YL4I.js").then(e=>({default:e.WidgetWalletPanel}))),Qt=pe(()=>import("./WalletPlaceholderPanel-Z4JCFCNV.js").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}=fe(),{liquidityError:S,routingError:C,sizeCapError:I,stop:O,clear:r}=ue(),i=n(o=>o.view),{isTransitioning:d,isRecipientInputOpen:T,recipient:X,selectedChainFilterChainId:L}=n(Ut(o=>({isTransitioning:o.isTransitioning,isRecipientInputOpen:o.isRecipientInputOpen,recipient:o.recipient,selectedChainFilterChainId:o.selectedChainFilter?.chainId??null}))),u=qe(null),g=qe(null),[m,Y]=nt(null);Pe(),Re(()=>()=>{u.current&&clearTimeout(u.current),g.current&&clearTimeout(g.current)},[]),Re(()=>{n.getState().resetUI()},[]),Re(()=>{if(d)return u.current=setTimeout(()=>{n.getState().setIsTransitioning(!1),u.current=null},20),()=>{u.current&&(clearTimeout(u.current),u.current=null)}},[d]);let R=me((o,V="navigation")=>{g.current&&(clearTimeout(g.current),g.current=null,Y(null)),n.getState().view!=="swap"&&o!=="swap"?(n.getState().setView(o),n.getState().setIsTransitioning(!1)):n.getState().transitionToView(o,V)},[]),h=me(()=>{u.current&&(clearTimeout(u.current),u.current=null),g.current&&(clearTimeout(g.current),g.current=null);let o=n.getState().view;Y(o),n.getState().setChainFilter(null),n.getState().setView("swap"),n.getState().setIsTransitioning(!1),n.getState().resetAssetSelection(),g.current=setTimeout(()=>{Y(null),g.current=null},200)},[]),U=me(o=>{let re=i==="baseChainSelection"?"base":"quote";n.getState().setChainFilter({chainId:o,side:re}),n.getState().pushRecentChain(o),R(re==="base"?"baseSelection":"quoteSelection","chainSelection")},[i,R]),M=me(()=>{let o=n.getState().view;o==="baseSelection"?R("baseChainSelection","chainSelection"):o==="quoteSelection"&&R("quoteChainSelection","chainSelection")},[R]),j=me(()=>{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}=ge(),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?p(at,{}):z==="horizontal"?p(de,{fallback:null,children:p(jt,{onSwapComplete:e,onSwapInitiated:j,onBackToSwap:E?h:void 0,onMoreChainsClick:E?M:void 0})}):z==="split"?p(de,{fallback:null,children:p($t,{onSwapComplete:e,onSwapInitiated:j,onBackToSwap:E?h:void 0,onMoreChainsClick:E?M:void 0})}):p(rt,{onSwapComplete:e,onSwapInitiated:j}),ke=t??{},Se=qe(null),[Ae,Ce]=nt(420);return Re(()=>{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?We(Kt,{children:[We("div",{ref:Se,className:"flex flex-col w-full overflow-hidden transition-colors duration-300",style:{flex:"1 1 0",minWidth:0,...ke},children:[p(Be,{headerText:"Swap",onBackClick:h,isSameChain:G,isWrappingPair:N,isUnwrappingPair:W,hasLowLiquidity:S,hasInsufficientLiquidity:S,hasRoutingError:C,hasSizeCapError:I}),p("div",{className:"overflow-hidden",children:we})]}),(te||ie)&&p("div",{className:"flex flex-col overflow-hidden shrink-0",style:{width:c,height:`${Ae}px`,...ke,...ce((v||x)&&!d)},children:v||ee?p(de,{fallback:null,children:p(st,{toggle:h,side:be,otherAsset:le,onMoreChainsClick:M,selectedChainFilter:L})}):p(de,{fallback:null,children:p(dt,{toggle:h,side:xe,onChainSelect:U})})})]}):We("div",{className:"flex flex-col w-full",style:{overflow:"hidden",position:"relative"},children:[p(Be,{headerText:H(),onBackClick:h,isSameChain:G,isWrappingPair:N,isUnwrappingPair:W,hasLowLiquidity:S,hasInsufficientLiquidity:S,hasRoutingError:C,hasSizeCapError:I}),We("div",{className:"relative overflow-hidden",children:[D&&p("div",{className:"overflow-hidden",style:Ne?{pointerEvents:"none"}:void 0,children:we}),(i==="wallet"||m==="wallet")&&p("div",{className:"absolute inset-0 overflow-hidden",style:ce(i==="wallet"&&!d),children:p(de,{fallback:null,children:q==="none"?p(Qt,{}):p(Dt,{})})}),$&&te&&p("div",{className:"absolute inset-0 overflow-hidden",style:ce(y),children:p(de,{fallback:null,children:p(st,{toggle:h,side:be,otherAsset:le,onMoreChainsClick:M,selectedChainFilter:L})})}),$&&ie&&p("div",{className:"absolute inset-0 overflow-hidden",style:ce(J),children:p(de,{fallback:null,children:p(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}=_(),W=n(w=>w.recipient);return p(Oe,{defaultBaseToken:t,defaultQuoteToken:c,onBaseTokenChange:a,onQuoteTokenChange:s,children:p(Ie,{recipient:W,children:p(_t,{onSwapComplete:e,cardStyles:b,cardWidth:k})})})};import{createContext as Yt,useContext as Gt}from"react";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={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}import{jsx as Jt}from"react/jsx-runtime";var ct=Yt(he);function He({theme:e,children:t}){return Jt(ct.Provider,{value:e,children:t})}function Zt(){return Gt(ct)}import{jsx as K,jsxs as wt}from"react/jsx-runtime";var ei=[],ti=[],ii=[],pt=[],ri=`
2
+ import{a as it}from"./chunk-ZFVYFTDI.js";import{a as yt,b as xt,c as Ie,d as Oe,e as me,f as et,g as he,h as ne,i as se,j as rt,k as Tt,l as Rt,m as Wt,n as Nt,o as At,p as Pt,q as zt,r as It,s as Ot,t as Mt,u as Bt,v as at,w as ot}from"./chunk-JVRQLJXZ.js";import{a as tt}from"./chunk-SBQ3EQ2U.js";import"./chunk-OPN7WCJR.js";import{a as kt,b as St,c as r,d as Ct,e as Me,f as ve}from"./chunk-7QJJOVSV.js";import{a as De,b as ge}from"./chunk-VI4ISTPB.js";import{D as Ne,L as Xe,b as Qe,d as _e,g as Ke,j as Ye,l as Ge,n as Je,y as Ze}from"./chunk-ZWNDO5OZ.js";import{a as Y}from"./chunk-46H44R7V.js";import"./chunk-73CB2I7U.js";import ai,{useMemo as ft}from"react";import{Suspense as Z,lazy as le,useCallback as be,useEffect as Ae,useRef as Fe,useState as ct}from"react";import{useShallow as Qt}from"zustand/react/shallow";import{useCallback as de,useEffect as Et,useMemo as qt,useRef as Ft,useState as nt}from"react";import{useShallow as Vt}from"zustand/react/shallow";import{Fragment as Be,jsx as l,jsxs as M}from"react/jsx-runtime";var Ht=({onSwapComplete:e,onSwapInitiated:t})=>{let{web3ConnectionType:p,hasConnectHandler:i,lockBase:s,lockQuote:v,disableInverting:k,tokenDisplay:N,tokenBadgeOrientation:R,widgetType:g}=ge(),{effectiveInputTokens:W,effectiveOutputTokens:H}=tt(),S=W.length===1,C=H.length===1,I=N==="pill"||N==="ghost",a=g==="compact",A=a?"px-4 pt-3 pb-1":"px-4 pt-4 pb-2",X=a?"px-4 pt-4 pb-1":"px-4 pt-6 pb-2",{baseToken:d,quoteToken:o,baseAmount:n,quoteAmount:w,isBaseGasToken:b,isQuoteGasToken:D,isWrappingPair:h,isUnwrappingPair:f,baseBalance:P,quoteBalance:L,setBaseAmount:E,setQuoteAmount:y,swapTokens:Q,clearForm:x}=ve(),{rfqQuote:U,status:we,handleInputChange:z,ensureForParams:q,stop:ee,clear:F,refresh:_}=me(),{address:O}=Y(),{openConnectModal:te}=he(),{isRecipientInputOpen:J,txStatus:ie}=r(Vt(K=>({isRecipientInputOpen:K.isRecipientInputOpen,txStatus:K.txStatus}))),[j,ce]=nt(null),[V,ue]=nt(null),xe=Ft(!1),T=!1,$e=qt(()=>!d||!o||typeof n!="number"||!w||!O||parseFloat(P.formatted)<n?null:{base:d,quote:o,baseAmount:n,quoteAmount:w,userAddress:O},[d,o,n,w,O,P.formatted]),ke=de(K=>{ue(K),r.getState().startTracking(K)},[]),re=de(()=>{xe.current=!0,_()},[_]);Et(()=>{if(j===null&&!(!d||!o)){if(!n||n<=0){z({amount:null,inputToken:d,outputToken:o,setOutputAmount:y});return}if(h||f){y(n);return}z({amount:n,inputToken:d,outputToken:o,setOutputAmount:y})}},[j,n,d,o,h,f,z,y]);let fe=de(()=>{r.getState().setView("baseSelection")},[]),pe=de(()=>{r.getState().setView("quoteSelection")},[]),Se=de(()=>{Q(),y(null)},[Q,y]),Ce=de(()=>{if(!P.formatted||!d||!o)return;let K=parseFloat(P.formatted);if(!K||K<=0)return;let We=K*.9999999999;h||f?(E(We),y(We),F()):(E(We),y(null),q({inputToken:d,outputToken:o,inputAmount:We.toString(),setOutputAmount:bt=>y(bt)}))},[P.formatted,d,o,h,f,E,y,F,q]),ze=de(()=>{F(),x()},[F,x]),Te=P.formatted?parseFloat(P.formatted):null,u=!!(n||w),ae=d?.price&&n?`$${(d.price*n).toFixed(2)}`:"$0.00",oe=o?.price&&w?`$${(o.price*w).toFixed(2)}`:"$0.00",Re=j==="trackingTx"&&!!V&&!!d&&!!o&&!!n&&!!w;return M("div",{className:"flex flex-col w-full",children:[Re&&V&&d&&o&&n&&w?l("div",{className:"overflow-hidden",children:l(ot,{orderHash:V,base:d,quote:o,baseAmount:n,quoteAmount:w,status:ie})}):M(Be,{children:[M("div",{className:`relative ${A}`,style:{borderBottom:"1px solid var(--widget-border)"},children:[I?a?M("div",{className:`flex items-center gap-2 mb-2 ${R==="right"?"flex-row-reverse":"flex-row"}`,children:[l(se,{toggle:fe,side:"base",asset:d,isPlacingOrder:T||s||S,hideDropdown:S}),l("div",{className:"flex-1 min-w-0",children:l(ne,{side:"base",asset:d??null,otherAsset:o??null,isPlacingOrder:T,isWrappingPair:h,isUnwrappingPair:f})})]}):M("div",{className:`flex flex-col ${R==="right"?"items-end":"items-start"}`,children:[l(se,{toggle:fe,side:"base",asset:d,isPlacingOrder:T||s||S,hideDropdown:S}),l(ne,{side:"base",asset:d??null,otherAsset:o??null,isPlacingOrder:T,isWrappingPair:h,isUnwrappingPair:f})]}):M(Be,{children:[l(se,{toggle:fe,side:"base",asset:d,isPlacingOrder:T||s||S,hideDropdown:S}),l(ne,{side:"base",asset:d??null,otherAsset:o??null,isPlacingOrder:T,isWrappingPair:h,isUnwrappingPair:f})]}),M("div",{className:"mb-1 flex w-full flex-row items-center justify-between",children:[l("p",{className:"mono text-sm",style:{color:"var(--widget-muted-foreground)"},children:ae}),O&&Te!==null&&Te>0&&l("button",{type:"button",onClick:Ce,disabled:T,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&&l("div",{className:"flex justify-center -my-4 relative z-10",children:M("button",{type:"button",onClick:Se,"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:[l("span",{className:"text-2xs",children:"\u2191"}),l("span",{className:"text-2xs",children:"\u2193"})]})}),M("div",{className:`relative ${X}`,children:[I?a?M("div",{className:`flex items-center gap-2 ${R==="right"?"flex-row-reverse":"flex-row"}`,children:[l(se,{toggle:pe,side:"quote",asset:o,isPlacingOrder:T||v||C,hideDropdown:C}),l("div",{className:"flex-1 min-w-0",children:l(ne,{side:"quote",asset:o??null,otherAsset:d??null,isPlacingOrder:T,isWrappingPair:h,isUnwrappingPair:f})})]}):M("div",{className:`flex flex-col ${R==="right"?"items-end":"items-start"}`,children:[l(se,{toggle:pe,side:"quote",asset:o,isPlacingOrder:T||v||C,hideDropdown:C}),l(ne,{side:"quote",asset:o??null,otherAsset:d??null,isPlacingOrder:T,isWrappingPair:h,isUnwrappingPair:f})]}):M(Be,{children:[l(se,{toggle:pe,side:"quote",asset:o,isPlacingOrder:T||v||C,hideDropdown:C}),l(ne,{side:"quote",asset:o??null,otherAsset:d??null,isPlacingOrder:T,isWrappingPair:h,isUnwrappingPair:f})]}),M("div",{className:"flex w-full flex-row items-center justify-between",children:[l("p",{className:"mono text-sm",style:{color:"var(--widget-muted-foreground)"},children:oe}),u&&l("button",{type:"button",onClick:ze,disabled:T,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"})]})]}),l("div",{className:"flex flex-row items-center w-full overflow-hidden",style:{borderTop:J?"1px solid var(--widget-border)":"none",maxHeight:J?"60px":"0px",opacity:J?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:l(rt,{})}),l("div",{className:"px-4",style:{borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"},children:l(it,{})})]}),l("div",{className:`relative ${Re?"px-0":"px-4"} ${a?"py-2":"py-4"}`,children:O&&d&&o&&n&&n>0?l(at,{base:d,baseAmount:n,quote:o,quoteAmount:w??0,userAddress:O,isWrappingPair:h,isUnwrappingPair:f,isBaseGasToken:b,isQuoteGasToken:D,reviewActionProps:$e,reviewState:j,setReviewState:ce,trackedOrderHash:V,setTrackedOrderHash:ue,onSwapComplete:e,onSwapInitiated:t,onOrderSubmitted:ke,onStaleQuoteRestart:re,txStatus:ie}):!O&&i?l("button",{onClick:()=>te(),className:`w-full ${a?"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"}):l("button",{disabled:!0,className:`w-full ${a?"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:O?"Enter Amount":"Connect Wallet"})})]})},st=Ht;import{jsx as B,jsxs as Ee}from"react/jsx-runtime";var dt=()=>Ee("div",{className:"flex flex-col w-full",children:[Ee("div",{className:"relative px-4 pt-4 pb-2",style:{borderBottom:"1px solid var(--widget-border)"},children:[B("div",{className:"h-12 w-full animate-pulse",style:{backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}}),B("div",{className:"mt-2 h-20 w-2/3 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}}),B("div",{className:"mt-1 mb-1 flex w-full items-center justify-between",children:B("div",{className:"h-4 w-12 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.4,borderRadius:"0.25rem"}})})]}),B("div",{className:"flex justify-center -my-4 relative z-10",children:B("div",{className:"h-8 w-8",style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)",borderRadius:"9999px"}})}),Ee("div",{className:"relative px-4 pt-6 pb-2",children:[B("div",{className:"h-12 w-full animate-pulse",style:{backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}}),B("div",{className:"mt-2 h-20 w-2/3 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}}),B("div",{className:"mt-1 mb-1 flex w-full items-center justify-between",children:B("div",{className:"h-4 w-12 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.4,borderRadius:"0.25rem"}})})]}),B("div",{className:"px-4",style:{height:"28px",borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"}}),B("div",{className:"relative px-4 py-4",children:B("div",{className:"w-full animate-pulse",style:{height:"44px",backgroundColor:"var(--widget-secondary)",borderRadius:"var(--widget-radius)",opacity:.6}})})]});import{useEffect as Lt,useState as lt}from"react";import{useShallow as Ut}from"zustand/react/shallow";import{Fragment as Dt,jsx as m,jsxs as $}from"react/jsx-runtime";var jt=({targetText:e,isError:t})=>{let{displayText:p,suffix:i,characterColors:s}=Ze(e,t);return $(Dt,{children:[p.split("").map((v,k)=>m("span",{style:s[k]?{color:"var(--widget-destructive)"}:void 0,children:v},k)),m("span",{style:{color:t?"var(--widget-destructive)":"var(--widget-muted-foreground)",opacity:t?.5:1},children:i})]})},$t=({headerText:e,onBackClick:t,isSameChain:p,isWrappingPair:i,isUnwrappingPair:s,hasLowLiquidity:v,hasInsufficientLiquidity:k,hasRoutingError:N,hasSizeCapError:R})=>{let g=r(x=>x.view),{isRecipientInputOpen:W,hasAllowanceError:H,hoveredChainName:S,isTrackingTx:C,txStatus:I,walletTab:a}=r(Ut(x=>({isRecipientInputOpen:x.isRecipientInputOpen,hasAllowanceError:x.hasAllowanceError,hoveredChainName:x.hoveredChainName,isTrackingTx:x.isTrackingTx,txStatus:x.txStatus,walletTab:x.walletTab}))),{swapHeaderVariant:A,walletButtonEnabled:X}=ge(),{isConnected:d}=Y(),[o,n]=lt(!1);Lt(()=>n(!0),[]);let[w,b]=lt(!1),D=`${g}-${w}-${W}-${S||"none"}`,f=(()=>{if(C&&I)switch(I){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(S&&(g==="baseSelection"||g==="quoteSelection"||g==="baseChainSelection"||g==="quoteChainSelection"))return S;if(g==="swap"&&w)return W?"Remove Custom Recipient":"Add Custom Recipient";switch(g){case"wallet":return"Wallet";case"activity":return"Activity";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(g==="swap"){if(H&&!i&&!s)return"Allowance check failed";if(R&&!i&&!s)return"Size limit exceeded";if(k&&!i&&!s)return"Insufficient Liquidity";if(N&&!i&&!s)return"Route Not Found";if(v&&!i&&!s)return"High Price Impact"}return p&&!i&&!s?"Swap":i?"Wrap":s?"Unwrap":e}})(),P=!C&&g==="swap"&&!w&&(H&&!i&&!s||R&&!i&&!s||k&&!i&&!s||N&&!i&&!s||v&&!i&&!s),L={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)"},E=()=>!C||!I?null:L[I]??null,y=()=>C?null:g==="swap"?$("div",{className:"flex items-center gap-2",children:[X&&o&&d&&m("button",{onClick:()=>r.getState().setView("activity"),"aria-label":"Open activity",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:$("svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[m("path",{d:"M12 8V12L14.5 14.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),m("path",{d:"M3.05 11A9 9 0 1 1 3.05 13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),m("path",{d:"M1 7.5L3.05 11L6.5 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),m("button",{onClick:()=>r.getState().toggleRecipientInput(),onMouseEnter:()=>b(!0),onMouseLeave:()=>b(!1),"aria-label":W?"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 ${W?"text-(--widget-destructive) opacity-80":"text-(--widget-muted-foreground) opacity-60"}`,children:$("svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[m("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"}),m("path",{d:"M6 16.5H8",stroke:"currentColor",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"butt",strokeLinejoin:"miter"}),m("path",{d:"M10.5 16.5H14.5",stroke:"currentColor",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"butt",strokeLinejoin:"miter"}),m("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"}),$("g",{style:{transform:`rotate(${W?"45deg":"0deg"})`,transformOrigin:"18.75px 6.75px",transition:"transform 150ms ease-out"},children:[m("path",{d:"M15 6.75H22.5",stroke:"currentColor",strokeWidth:"1.5"}),m("path",{d:"M18.75 10.5V3",stroke:"currentColor",strokeWidth:"1.5"})]})]})})]}):$("button",{onClick:()=>t?t():r.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:[m("span",{className:"pr-1",children:"\u2190"}),m("span",{className:"text-sm",children:"Back"})]}),Q=E();return A==="none"?null:$("div",{className:"w-full pt-3 px-2 mono text-base flex flex-row justify-between h-6 shrink-0",children:[g==="wallet"?$("div",{className:"flex items-center gap-1 mono uppercase -translate-y-0.5 text-xs",children:[$("button",{type:"button",onClick:()=>r.getState().setWalletTab("wallet"),className:"cursor-pointer transition-colors",style:{color:a==="wallet"?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:[m("span",{style:{color:"var(--widget-muted-foreground)"},children:">> "}),m("span",{children:"Wallet"})]}),m("span",{style:{color:"var(--widget-foreground)",opacity:.4},children:">>"}),m("button",{type:"button",onClick:()=>r.getState().setWalletTab("activity"),className:"cursor-pointer transition-colors",style:{color:a==="activity"?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:"Activity"})]}):$("div",{className:"mono uppercase -translate-y-0.5 text-xs flex items-center",children:[m("span",{className:"mr-1.5",style:{color:"var(--widget-muted-foreground)",opacity:.4},children:">> "}),m("span",{className:"relative",style:{color:Q||"var(--widget-foreground)"},children:m(jt,{targetText:f,isError:P??!1})},D)]}),m("div",{className:"flex flex-row items-center",children:y()})]})},qe=$t;import{Fragment as Xt,jsx as c,jsxs as Pe}from"react/jsx-runtime";var pt=le(()=>import("./AssetSelectionMenu-KOJBN3OR.js")),gt=le(()=>import("./ChainSelectionMenu-YCFDREZO.js")),_t=le(()=>import("./SwapFormHorizontal-E32W3PHA.js")),Kt=le(()=>import("./SwapFormSplit-M4YIQNAW.js")),Yt=le(()=>import("./WidgetWalletPanel-T5L5224H.js").then(e=>({default:e.WidgetWalletPanel}))),Gt=le(()=>import("./WalletPlaceholderPanel-Z4JCFCNV.js").then(e=>({default:e.WalletPlaceholderPanel}))),Jt=le(()=>import("./WidgetWalletTradeHistory-PZLWJ2IK.js").then(e=>({default:e.WidgetWalletTradeHistory}))),Zt=({onSwapComplete:e,cardStyles:t,cardWidth:p})=>{let{baseToken:i,quoteToken:s,baseAmount:v,quoteAmount:k,isWrappingPair:N,isUnwrappingPair:R,isRegistryLoading:g}=ve(),{liquidityError:W,routingError:H,sizeCapError:S,stop:C,clear:I}=me(),a=r(u=>u.view),{isTransitioning:A,isRecipientInputOpen:X,recipient:d,selectedChainFilterChainId:o}=r(Qt(u=>({isTransitioning:u.isTransitioning,isRecipientInputOpen:u.isRecipientInputOpen,recipient:u.recipient,selectedChainFilterChainId:u.selectedChainFilter?.chainId??null}))),n=Fe(null),w=Fe(null),[b,D]=ct(null);Ie(),Ae(()=>()=>{n.current&&clearTimeout(n.current),w.current&&clearTimeout(w.current)},[]),Ae(()=>{r.getState().resetUI()},[]),Ae(()=>{if(A)return n.current=setTimeout(()=>{r.getState().setIsTransitioning(!1),n.current=null},20),()=>{n.current&&(clearTimeout(n.current),n.current=null)}},[A]);let h=be((u,ae="navigation")=>{w.current&&(clearTimeout(w.current),w.current=null,D(null)),r.getState().view!=="swap"&&u!=="swap"?(r.getState().setView(u),r.getState().setIsTransitioning(!1)):r.getState().transitionToView(u,ae)},[]),f=be(()=>{n.current&&(clearTimeout(n.current),n.current=null),w.current&&(clearTimeout(w.current),w.current=null);let u=r.getState().view;D(u),r.getState().setChainFilter(null),r.getState().setView("swap"),r.getState().setIsTransitioning(!1),r.getState().resetAssetSelection(),w.current=setTimeout(()=>{D(null),w.current=null},200)},[]),P=be(u=>{let oe=a==="baseChainSelection"?"base":"quote";r.getState().setChainFilter({chainId:u,side:oe}),r.getState().pushRecentChain(u),h(oe==="base"?"baseSelection":"quoteSelection","chainSelection")},[a,h]),L=be(()=>{let u=r.getState().view;u==="baseSelection"?h("baseChainSelection","chainSelection"):u==="quoteSelection"&&h("quoteChainSelection","chainSelection")},[h]),E=be(()=>{C(),I()},[C,I]),y=i&&s?i.chainId===s.chainId:!0,Q=()=>{switch(a){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:x,widgetType:U,customWalletUI:we}=ge(),z=a==="baseSelection"||a==="quoteSelection",q=a==="baseChainSelection"||a==="quoteChainSelection",ee=x==="split"&&(U==="default"||U==="compact"),F=x==="split"&&(U==="horizontal"||U==="split"),_=x==="default",O=a==="swap"||z||q||a==="wallet"||a==="activity",te=b==="baseSelection"||b==="quoteSelection",J=b==="baseChainSelection"||b==="quoteChainSelection",ie=z||te,j=q||J,ce=z&&!A,V=q&&!A,ue=z?a:b,xe=ue==="baseSelection"?"base":"quote",T=ue==="baseSelection"?s:i,ke=(q?a:b)==="baseChainSelection"?"base":"quote",re=u=>({backgroundColor:"var(--widget-background)",opacity:u?1:0,transform:u?"translateY(0)":"translateY(6px)",transition:"opacity 200ms ease-in-out, transform 200ms ease-in-out"}),fe=_&&(z||q||a==="wallet"||a==="activity"||b!=null),pe=g?c(dt,{}):U==="horizontal"?c(Z,{fallback:null,children:c(_t,{onSwapComplete:e,onSwapInitiated:E,onBackToSwap:F?f:void 0,onMoreChainsClick:F?L:void 0})}):U==="split"?c(Z,{fallback:null,children:c(Kt,{onSwapComplete:e,onSwapInitiated:E,onBackToSwap:F?f:void 0,onMoreChainsClick:F?L:void 0})}):c(st,{onSwapComplete:e,onSwapInitiated:E}),Se=t??{},Ce=Fe(null),[ze,Te]=ct(420);return Ae(()=>{if(!ee)return;let u=Ce.current;if(!u)return;let ae=new ResizeObserver(oe=>{for(let Re of oe)Te(Re.contentRect.height)});return ae.observe(u),()=>ae.disconnect()},[ee]),ee?Pe(Xt,{children:[Pe("div",{ref:Ce,className:"flex flex-col w-full overflow-hidden transition-colors duration-300",style:{flex:"1 1 0",minWidth:0,...Se},children:[c(qe,{headerText:"Swap",onBackClick:f,isSameChain:y,isWrappingPair:N,isUnwrappingPair:R,hasLowLiquidity:W,hasInsufficientLiquidity:W,hasRoutingError:H,hasSizeCapError:S}),c("div",{className:"overflow-hidden",children:pe})]}),(ie||j)&&c("div",{className:"flex flex-col overflow-hidden shrink-0",style:{width:p,height:`${ze}px`,...Se,...re((z||q)&&!A)},children:z||te?c(Z,{fallback:null,children:c(pt,{toggle:f,side:xe,otherAsset:T,onMoreChainsClick:L,selectedChainFilter:o})}):c(Z,{fallback:null,children:c(gt,{toggle:f,side:ke,onChainSelect:P})})})]}):Pe("div",{className:"flex flex-col w-full",style:{overflow:"hidden",position:"relative"},children:[c(qe,{headerText:Q(),onBackClick:f,isSameChain:y,isWrappingPair:N,isUnwrappingPair:R,hasLowLiquidity:W,hasInsufficientLiquidity:W,hasRoutingError:H,hasSizeCapError:S}),Pe("div",{className:"relative overflow-hidden",children:[O&&c("div",{className:"overflow-hidden",style:fe?{pointerEvents:"none"}:void 0,children:pe}),(a==="wallet"||b==="wallet")&&c("div",{className:"absolute inset-0 overflow-hidden z-20",style:re(a==="wallet"&&!A),children:c(Z,{fallback:null,children:we==="none"?c(Gt,{}):c(Yt,{})})}),(a==="activity"||b==="activity")&&c("div",{className:"absolute inset-0 overflow-y-auto z-20",style:re(a==="activity"&&!A),children:c(Z,{fallback:null,children:c(Jt,{isActive:a==="activity"})})}),_&&ie&&c("div",{className:"absolute inset-0 overflow-hidden z-20",style:re(ce),children:c(Z,{fallback:null,children:c(pt,{toggle:f,side:xe,otherAsset:T,onMoreChainsClick:L,selectedChainFilter:o})})}),_&&j&&c("div",{className:"absolute inset-0 overflow-hidden z-20",style:re(V),children:c(Z,{fallback:null,children:c(gt,{toggle:f,side:ke,onChainSelect:P})})})]})]})},wt=({onSwapComplete:e,defaultBaseToken:t,defaultQuoteToken:p,onBaseTokenChange:i,onQuoteTokenChange:s,cardStyles:v,cardWidth:k})=>{let{address:N}=Y(),R=r(g=>g.recipient);return c(Me,{defaultBaseToken:t,defaultQuoteToken:p,onBaseTokenChange:i,onQuoteTokenChange:s,children:c(Oe,{recipient:R,children:c(Zt,{onSwapComplete:e,cardStyles:v,cardWidth:k})})})};import{createContext as ei,useContext as ti}from"react";var Ve={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"},ye={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 He(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}import{jsx as ri}from"react/jsx-runtime";var ut=ei(ye);function Le({theme:e,children:t}){return ri(ut.Provider,{value:e,children:t})}function ii(){return ti(ut)}import{jsx as G,jsxs as vt}from"react/jsx-runtime";var oi=[],ni=[],si=[],mt=[],di=`
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 @@ import{a as Je}from"./chunk-4BQRVCQR.js";import{a as mt,b as ht,c as Pe,d as Ie,
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 extends Xt.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?wt("div",{style:{padding:"1.5rem",textAlign:"center",color:"var(--widget-foreground, #888)",fontFamily:"system-ui, sans-serif"},children:[K("p",{style:{margin:"0 0 0.75rem",fontSize:"0.875rem"},children:"Something went wrong."}),K("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}};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"}){_e(e.apiKey),Ke(e.rpcOverrides),Qe(e.vtApiBaseUrl);let W=ai(e),w=e.appearance?.widgetType??"default",S=e.appearance?.tokenDisplay??"default",C=e.appearance?.tokenBadgeOrientation??"left",I=e.appearance?.assetMenuVariant??"default",O=e.appearance?.amountInputVariant??"default",r=e.appearance?.hideAmountInputSymbol??!1,i=e.appearance?.swapButtonVariant??"default",d=e.appearance?.swapHeaderVariant??"default",T=e.appearance?.quoteLoaderVariant??"default",X=e.appearance?.walletButtonEnabled??!0,L=e.appearance?.fillContainer??!1,u=e.appearance?.hideBorder??!1,g=Fe(W),m=I==="split"&&(w==="default"||w==="compact"),Y=n(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=e.tokens?.enabledChains??ei,G=e.tokens?.supportedInputTokens??ti,H=e.tokens?.supportedOutputTokens??ii,B=e.tokens?.supportedInputChains??pt,z=e.tokens?.supportedOutputChains??pt,q=e.tokens?.inputSelectionSearch??!0,v=e.tokens?.outputSelectionSearch??!0,x=e.tokens?.showInputSelectionTokenBalances??!0,Z=e.tokens?.showOutputSelectionTokenBalances??!0,E=e.tokens?.lockBase??!1,$=e.tokens?.lockQuote??!1,D=e.tokens?.disableInverting??!1,ee=e.settings?.defaultSlippage??.01,Q=!!b,te=gt(()=>({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=gt(()=>b?{openConnectModal:b,openAccountModal:k}:null,[b,k]),y=K(Ge,{children:K(Ue.Provider,{value:te,children:K(He,{theme:W,children:wt("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:[K("style",{dangerouslySetInnerHTML:{__html:ri}}),K(Ve,{children:K(lt,{onSwapComplete:c,defaultBaseToken:e.tokens?.defaultBase,defaultQuoteToken:e.tokens?.defaultQuote,onBaseTokenChange:a,onQuoteTokenChange:s,cardStyles:m?M:void 0,cardWidth:m?R:void 0})})]})})})});return ie?K(Ze.Provider,{value:ie,children:y}):y}import{jsx as si}from"react/jsx-runtime";function ni(){let{openConnectModal:e}=ae(),{isConnected:t,address:c}=_(),a=t&&c?`${c.slice(0,6)}...${c.slice(-4)}`:"Connect";return si("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})}import{http as ut,fallback as di}from"wagmi";function li(e){let t=Object.entries(je);return Object.fromEntries(t.map(([c,a])=>{let s=e?.[Number(c)],b=s?Array.isArray(s)?s:[s]:[],k=b.length>0?[...b,...a.rpcUrls]:a.rpcUrls;return[c,k.length>1?di(k.map(N=>ut(N,{batch:{batchSize:50,wait:50}}))):ut(k[0],{batch:{batchSize:50,wait:50}})]}))}var ci=$e().map(e=>e.wagmiChain);import{useMemo as Le}from"react";var gi=e=>{let{tokenRegistry:t,isLoadingRegistry:c,error:a}=Te();return{tokens:Le(()=>t.filter(b=>b.chainId===e),[t,e]),isLoading:c,error:a}},pi=(e,t)=>{let{tokenRegistry:c}=Te();return Le(()=>!e||!c.length?!1:c.some(a=>a.address.toLowerCase()===e.toLowerCase()&&a.chainId===t),[c,e,t])},wi=(e,t)=>{let{getToken:c}=Te();return Le(()=>{if(!(!e||!t))return c(t,e)},[c,e,t])},Nr=De();export{Ct as ChainSwitch,ni as ConnectButton,Ie as RfqProvider,Tt as SignSwap,Oe as SwapFormProvider,oi as SwapWidget,He as WidgetThemeProvider,li as buildTransports,Wt as canSubmitOrder,At as cleanupOldSubmissions,he as defaultDarkTheme,Ee as defaultLightTheme,Rt as isQuoteFresh,Nt as markOrderAsSubmitted,xt as pollOrderStatus,Fe as themeToCSS,mt as useBalanceEventListener,Pe as useBalanceEventSubscription,ht as useEmitBalanceEvent,pi as useIsTokenSupported,kt as useOrderStatusPolling,ue as useRfq,yt as useSwapForm,fe as useSwapFormContext,wi as useTokenByAddress,bt as useTokenSelection,vt as useTokenSelectionStore,gi as useTokensForChain,St as useTransactionRegistry,Pt as useUnwrapToken,ae as useWalletModal,_ as useWalletState,n as useWidgetSwapUIStore,Zt as useWidgetTheme,It as useWrapToken,ci as wagmiChains};
10
+ `,Ue=class extends ai.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?vt("div",{style:{padding:"1.5rem",textAlign:"center",color:"var(--widget-foreground, #888)",fontFamily:"system-ui, sans-serif"},children:[G("p",{style:{margin:"0 0 0.75rem",fontSize:"0.875rem"},children:"Something went wrong."}),G("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}};function li(e){let t=e.theme.mode==="light"?Ve:ye,p=e.theme.mode==="light"?e.theme.light:e.theme.dark;return p?{...t,...p}:t}function ci({config:e,className:t,onSwapComplete:p,onBaseTokenChange:i,onQuoteTokenChange:s,onRequestConnect:v,onRequestAccount:k,customWalletUI:N="builtin"}){Ge(e.apiKey),Je(e.rpcOverrides),Ye(e.vtApiBaseUrl);let R=li(e),g=e.appearance?.widgetType??"default",W=e.appearance?.tokenDisplay??"default",H=e.appearance?.tokenBadgeOrientation??"left",S=e.appearance?.assetMenuVariant??"default",C=e.appearance?.amountInputVariant??"default",I=e.appearance?.hideAmountInputSymbol??!1,a=e.appearance?.swapButtonVariant??"default",A=e.appearance?.swapHeaderVariant??"default",X=e.appearance?.quoteLoaderVariant??"default",d=e.appearance?.walletButtonEnabled??!0,o=e.appearance?.fillContainer??!1,n=e.appearance?.hideBorder??!1,w=He(R),b=S==="split"&&(g==="default"||g==="compact"),D=r(V=>V.view==="baseSelection"||V.view==="quoteSelection"||V.view==="baseChainSelection"||V.view==="quoteChainSelection"),h=g==="compact"?"22rem":"24rem",P=b?{maxWidth:D?g==="compact"?"46rem":"49rem":h,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%",...o?{}:{maxWidth:g==="split"||g==="horizontal"?"48rem":g==="compact"?"22rem":"24rem"},height:"auto",overflow:"hidden"},L={boxSizing:"border-box",backgroundColor:"var(--widget-background)",color:"var(--widget-foreground)",borderRadius:"var(--widget-radius)",...n?{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"},E=e.tokens?.enabledChains??oi,y=e.tokens?.supportedInputTokens??ni,Q=e.tokens?.supportedOutputTokens??si,x=e.tokens?.supportedInputChains??mt,U=e.tokens?.supportedOutputChains??mt,we=e.tokens?.inputSelectionSearch??!0,z=e.tokens?.outputSelectionSearch??!0,q=e.tokens?.showInputSelectionTokenBalances??!0,ee=e.tokens?.showOutputSelectionTokenBalances??!0,F=e.tokens?.lockBase??!1,_=e.tokens?.lockQuote??!1,O=e.tokens?.disableInverting??!1,te=e.settings?.defaultSlippage??.01,J=!!v,ie=ft(()=>({apiKey:e.apiKey,web3ConnectionType:"custom",enabledChains:E,supportedInputTokens:y,supportedOutputTokens:Q,supportedInputChains:x,supportedOutputChains:U,inputSelectionSearch:we,outputSelectionSearch:z,showInputSelectionTokenBalances:q,showOutputSelectionTokenBalances:ee,lockBase:F,lockQuote:_,disableInverting:O,defaultSlippage:te,widgetType:g,tokenDisplay:W,tokenBadgeOrientation:H,assetMenuVariant:S,amountInputVariant:C,hideAmountInputSymbol:I,swapButtonVariant:a,swapHeaderVariant:A,quoteLoaderVariant:X,walletButtonEnabled:d,hasConnectHandler:J,customWalletUI:N}),[e.apiKey,E,y,Q,x,U,we,z,q,ee,F,_,O,te,g,W,H,S,C,I,a,A,X,d,J,N]),j=ft(()=>v?{openConnectModal:v,openAccountModal:k}:null,[v,k]),ce=G(Xe,{children:G(De.Provider,{value:ie,children:G(Le,{theme:R,children:vt("div",{className:`aori-widget${t?` ${t}`:""}`,style:{...w,"--font-sans":"var(--widget-font-sans)","--font-mono":"var(--widget-font-mono)",fontFamily:"var(--widget-font-sans)",letterSpacing:"var(--widget-letter-spacing)",width:"100%",...P,position:"relative",...b?{}:L},children:[G("style",{dangerouslySetInnerHTML:{__html:di}}),G(Ue,{children:G(wt,{onSwapComplete:p,defaultBaseToken:e.tokens?.defaultBase,defaultQuoteToken:e.tokens?.defaultQuote,onBaseTokenChange:i,onQuoteTokenChange:s,cardStyles:b?L:void 0,cardWidth:b?h:void 0})})]})})})});return j?G(et.Provider,{value:j,children:ce}):ce}import{jsx as gi}from"react/jsx-runtime";function pi(){let{openConnectModal:e}=he(),{isConnected:t,address:p}=Y(),i=t&&p?`${p.slice(0,6)}...${p.slice(-4)}`:"Connect";return gi("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:i})}import{http as ht,fallback as wi}from"wagmi";function ui(e){let t=Object.entries(Qe);return Object.fromEntries(t.map(([p,i])=>{let s=e?.[Number(p)],v=s?Array.isArray(s)?s:[s]:[],k=v.length>0?[...v,...i.rpcUrls]:i.rpcUrls;return[p,k.length>1?wi(k.map(N=>ht(N,{batch:{batchSize:50,wait:50}}))):ht(k[0],{batch:{batchSize:50,wait:50}})]}))}var fi=_e().map(e=>e.wagmiChain);import{useMemo as je}from"react";var mi=e=>{let{tokenRegistry:t,isLoadingRegistry:p,error:i}=Ne();return{tokens:je(()=>t.filter(v=>v.chainId===e),[t,e]),isLoading:p,error:i}},vi=(e,t)=>{let{tokenRegistry:p}=Ne();return je(()=>!e||!p.length?!1:p.some(i=>i.address.toLowerCase()===e.toLowerCase()&&i.chainId===t),[p,e,t])},hi=(e,t)=>{let{getToken:p}=Ne();return je(()=>{if(!(!e||!t))return p(t,e)},[p,e,t])},Or=Ke();export{Nt as ChainSwitch,pi as ConnectButton,Oe as RfqProvider,At as SignSwap,Me as SwapFormProvider,ci as SwapWidget,Le as WidgetThemeProvider,ui as buildTransports,zt as canSubmitOrder,Ot as cleanupOldSubmissions,ye as defaultDarkTheme,Ve as defaultLightTheme,Pt as isQuoteFresh,It as markOrderAsSubmitted,Tt as pollOrderStatus,He as themeToCSS,yt as useBalanceEventListener,Ie as useBalanceEventSubscription,xt as useEmitBalanceEvent,vi as useIsTokenSupported,Rt as useOrderStatusPolling,me as useRfq,Ct as useSwapForm,ve as useSwapFormContext,hi as useTokenByAddress,St as useTokenSelection,kt as useTokenSelectionStore,mi as useTokensForChain,Wt as useTransactionRegistry,Mt as useUnwrapToken,he as useWalletModal,Y as useWalletState,r as useWidgetSwapUIStore,ii as useWidgetTheme,Bt as useWrapToken,fi as wagmiChains};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aori/mega-swap-widget",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Embeddable cross-chain swap widget powered by Aori",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
- "use client";var _chunkHTWUZKYOcjs = require('./chunk-HTWUZKYO.cjs');require('./chunk-UZWGYG2S.cjs');require('./chunk-LXEKOQAG.cjs');require('./chunk-34N36GUD.cjs');require('./chunk-T3I3AJXV.cjs');exports.default = _chunkHTWUZKYOcjs.a;
@@ -1,2 +0,0 @@
1
- "use client";
2
- "use client";import{a}from"./chunk-4LJJMEOG.js";import"./chunk-726CI6GC.js";import"./chunk-EW2OR6CJ.js";import"./chunk-46H44R7V.js";import"./chunk-73CB2I7U.js";export{a as default};
@@ -1,2 +0,0 @@
1
- "use client";
2
- "use client";import{a}from"./chunk-FDQKBTWP.js";import"./chunk-EW2OR6CJ.js";import"./chunk-73CB2I7U.js";export{a as default};
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
- "use client";var _chunkXZRXVBSBcjs = require('./chunk-XZRXVBSB.cjs');require('./chunk-LXEKOQAG.cjs');require('./chunk-T3I3AJXV.cjs');exports.default = _chunkXZRXVBSBcjs.a;
@@ -1,2 +0,0 @@
1
- "use client";
2
- "use client";import{a as ne}from"./chunk-4BQRVCQR.js";import{e as oe,g as se,h as f,i as w,j as re,v as ae,w as le}from"./chunk-XYF2YBR3.js";import{a as $}from"./chunk-4LJJMEOG.js";import{a as B}from"./chunk-FDQKBTWP.js";import"./chunk-OPN7WCJR.js";import{c as d,f as ie}from"./chunk-726CI6GC.js";import{b as ee}from"./chunk-EW2OR6CJ.js";import{a as te}from"./chunk-46H44R7V.js";import"./chunk-73CB2I7U.js";import{useCallback as p,useEffect as Fe,useMemo as Me,useRef as Ie,useState as de}from"react";import{useShallow as We}from"zustand/react/shallow";import{Fragment as k,jsx as e,jsxs as r}from"react/jsx-runtime";var P=()=>{},$e=({onSwapComplete:ue,onSwapInitiated:ce,onBackToSwap:h,onMoreChainsClick:Be})=>{let{web3ConnectionType:He,hasConnectHandler:pe,lockBase:O,lockQuote:N,disableInverting:me,swapButtonVariant:q,tokenDisplay:H,tokenBadgeOrientation:x,widgetType:ge,assetMenuVariant:fe}=ee(),Q=H==="pill"||H==="ghost",T=ge==="compact",{baseToken:t,quoteToken:o,baseAmount:i,quoteAmount:u,isBaseGasToken:we,isQuoteGasToken:ve,isWrappingPair:a,isUnwrappingPair:l,baseBalance:g,quoteBalance:Qe,setBaseAmount:R,setQuoteAmount:c,swapTokens:U,clearForm:V}=ie(),{rfqQuote:Ue,status:Ve,handleInputChange:F,ensureForParams:j,stop:je,clear:S,refresh:G}=oe(),{address:m}=te(),{openConnectModal:be}=se(),{isRecipientInputOpen:M,txStatus:z,view:v,selectedChainFilterChainId:D}=d(We(n=>({isRecipientInputOpen:n.isRecipientInputOpen,txStatus:n.txStatus,view:n.view,selectedChainFilterChainId:n.selectedChainFilter?.chainId??null}))),[C,he]=de(null),[y,E]=de(null),xe=Ie(!1),s=!1,Se=Me(()=>!t||!o||typeof i!="number"||!u||!m||parseFloat(g.formatted)<i?null:{base:t,quote:o,baseAmount:i,quoteAmount:u,userAddress:m},[t,o,i,u,m,g.formatted]),Ce=p(n=>{E(n),d.getState().startTracking(n)},[]),ye=p(()=>{xe.current=!0,G()},[G]);Fe(()=>{if(C===null&&!(!t||!o)){if(!i||i<=0){F({amount:null,inputToken:t,outputToken:o,setOutputAmount:c});return}if(a||l){c(i);return}F({amount:i,inputToken:t,outputToken:o,setOutputAmount:c})}},[C,i,t,o,a,l,F,c]);let I=p(()=>{d.getState().setView("baseSelection")},[]),W=p(()=>{d.getState().setView("quoteSelection")},[]),Ae=p(()=>{U(),c(null)},[U,c]),Pe=p(()=>{if(!g.formatted||!t||!o)return;let n=parseFloat(g.formatted);if(!n||n<=0)return;let b=n*.9999999999;a||l?(R(b),c(b),S()):(R(b),c(null),j({inputToken:t,outputToken:o,inputAmount:b.toString(),setOutputAmount:A=>c(A)}))},[g.formatted,t,o,a,l,R,c,S,j]),ke=p(()=>{S(),V()},[S,V]),_=g.formatted?parseFloat(g.formatted):null,Oe=!!(i||u),L=fe==="split",J=L&&(v==="baseSelection"||v==="baseChainSelection"),K=L&&(v==="quoteSelection"||v==="quoteChainSelection"),X=p(n=>{let A=d.getState().view==="baseChainSelection"?"base":"quote";d.getState().setChainFilter({chainId:n,side:A}),d.getState().pushRecentChain(n),d.getState().transitionToView(A==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),Ne=p(()=>{d.getState().transitionToView("baseChainSelection","chainSelection")},[]),qe=p(()=>{d.getState().transitionToView("quoteChainSelection","chainSelection")},[]),Te=t?.price&&i?`$${(t.price*i).toFixed(2)}`:"$0.00",Re=o?.price&&u?`$${(o.price*u).toFixed(2)}`:"$0.00",Y=C==="trackingTx"&&!!y&&!!t&&!!o&&!!i&&!!u,Z={backgroundColor:q==="default"?"var(--widget-primary)":"transparent",color:q==="default"?"var(--widget-primary-foreground)":"var(--widget-primary)",border:q!=="default"?"1px solid var(--widget-primary)":"none",borderRadius:"var(--widget-radius)"};return r("div",{className:"flex flex-col w-full",children:[Y&&y&&t&&o&&i&&u?e("div",{className:"flex-1 min-h-0 overflow-hidden",children:e(le,{orderHash:y,base:t,quote:o,baseAmount:i,quoteAmount:u,status:z})}):r("div",{className:`grid grid-cols-[1fr_auto_1fr] items-stretch px-4 ${T?"pt-3 pb-1":"pt-4 pb-2"} gap-2`,children:[e("div",{className:`relative flex flex-col gap-1 p-3 rounded-lg overflow-hidden ${J?"h-[380px]":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)"},children:J?v==="baseChainSelection"?e(B,{toggle:h??P,side:"base",onChainSelect:X}):e($,{toggle:h??P,side:"base",otherAsset:o,onMoreChainsClick:Ne,selectedChainFilter:D}):r(k,{children:[Q?T?r("div",{className:`flex items-center gap-2 ${x==="right"?"flex-row-reverse":"flex-row"}`,children:[e(w,{toggle:I,side:"base",asset:t,isPlacingOrder:s||O}),e("div",{className:"flex-1 min-w-0",children:e(f,{side:"base",asset:t??null,otherAsset:o??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})})]}):r("div",{className:`flex flex-col ${x==="right"?"items-end":"items-start"}`,children:[e(w,{toggle:I,side:"base",asset:t,isPlacingOrder:s||O}),e(f,{side:"base",asset:t??null,otherAsset:o??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}):r(k,{children:[e(w,{toggle:I,side:"base",asset:t,isPlacingOrder:s||O}),e(f,{side:"base",asset:t??null,otherAsset:o??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}),r("div",{className:"flex items-center justify-between",children:[e("span",{className:"mono text-xs",style:{color:"var(--widget-muted-foreground)"},children:Te}),m&&_!==null&&_>0&&e("button",{type:"button",onClick:Pe,disabled:s,className:"flex items-center rounded-full px-2 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 transition-colors bg-(--widget-primary) text-(--widget-primary-foreground) hover:bg-(--widget-foreground) hover:text-(--widget-card)",children:"Max"})]})]})}),e("div",{className:"flex items-center justify-center px-1",children:me?e("div",{className:"flex h-8 w-8 items-center justify-center opacity-20",children:e("span",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"\u2192"})}):e("button",{type:"button",onClick:Ae,"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:e("span",{className:"text-2xs",children:"\u2194"})})}),e("div",{className:`relative flex flex-col gap-1 p-3 rounded-lg overflow-hidden ${K?"h-[380px]":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)"},children:K?v==="quoteChainSelection"?e(B,{toggle:h??P,side:"quote",onChainSelect:X}):e($,{toggle:h??P,side:"quote",otherAsset:t,onMoreChainsClick:qe,selectedChainFilter:D}):r(k,{children:[Q?T?r("div",{className:`flex items-center gap-2 ${x==="right"?"flex-row-reverse":"flex-row"}`,children:[e(w,{toggle:W,side:"quote",asset:o,isPlacingOrder:s||N}),e("div",{className:"flex-1 min-w-0",children:e(f,{side:"quote",asset:o??null,otherAsset:t??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})})]}):r("div",{className:`flex flex-col ${x==="right"?"items-end":"items-start"}`,children:[e(w,{toggle:W,side:"quote",asset:o,isPlacingOrder:s||N}),e(f,{side:"quote",asset:o??null,otherAsset:t??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}):r(k,{children:[e(w,{toggle:W,side:"quote",asset:o,isPlacingOrder:s||N}),e(f,{side:"quote",asset:o??null,otherAsset:t??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}),r("div",{className:"flex items-center justify-between",children:[e("span",{className:"mono text-xs",style:{color:"var(--widget-muted-foreground)"},children:Re}),Oe&&e("button",{type:"button",onClick:ke,disabled:s,className:"flex items-center rounded-full px-2 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 transition-colors text-(--widget-muted-foreground) hover:bg-(--widget-secondary)",children:"Clear"})]})]})})]}),e("div",{className:"flex flex-row items-center w-full overflow-hidden px-4",style:{borderTop:M?"1px solid var(--widget-border)":"none",maxHeight:M?"60px":"0px",opacity:M?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:e(re,{})}),e("div",{className:"px-4",style:{borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"},children:e(ne,{})}),e("div",{className:`relative ${Y?"px-0":"px-4"} py-4`,children:m&&t&&o&&i&&i>0?e(ae,{base:t,baseAmount:i,quote:o,quoteAmount:u??0,userAddress:m,isWrappingPair:a,isUnwrappingPair:l,isBaseGasToken:we,isQuoteGasToken:ve,reviewActionProps:Se,reviewState:C,setReviewState:he,trackedOrderHash:y,setTrackedOrderHash:E,onSwapComplete:ue,onSwapInitiated:ce,onOrderSubmitted:Ce,onStaleQuoteRestart:ye,txStatus:z}):!m&&pe?e("button",{onClick:()=>be(),className:"w-full py-3 text-sm font-medium cursor-pointer transition-opacity hover:opacity-80",style:Z,children:"Connect Wallet"}):e("button",{disabled:!0,className:"w-full py-3 text-sm font-medium transition-colors disabled:opacity-40 cursor-not-allowed",style:Z,children:m?"Enter Amount":"Connect Wallet"})})]})},rt=$e;export{rt as default};
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
2
- "use client";var _chunkDUIRZSBVcjs = require('./chunk-DUIRZSBV.cjs');var _chunkMCT3UZTPcjs = require('./chunk-MCT3UZTP.cjs');var _chunkHTWUZKYOcjs = require('./chunk-HTWUZKYO.cjs');var _chunkXZRXVBSBcjs = require('./chunk-XZRXVBSB.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 _shallow = require('zustand/react/shallow');var _jsxruntime = require('react/jsx-runtime');var P=()=>{},$e=({onSwapComplete:ue,onSwapInitiated:ce,onBackToSwap:h,onMoreChainsClick:Be})=>{let{web3ConnectionType:He,hasConnectHandler:pe,lockBase:O,lockQuote:N,disableInverting:me,swapButtonVariant:q,tokenDisplay:H,tokenBadgeOrientation:x,widgetType:ge,assetMenuVariant:fe}=_chunkLXEKOQAGcjs.b.call(void 0, ),Q=H==="pill"||H==="ghost",T=ge==="compact",{baseToken:t,quoteToken:o,baseAmount:i,quoteAmount:u,isBaseGasToken:we,isQuoteGasToken:ve,isWrappingPair:a,isUnwrappingPair:l,baseBalance:g,quoteBalance:Qe,setBaseAmount:R,setQuoteAmount:c,swapTokens:U,clearForm:V}=_chunkUZWGYG2Scjs.f.call(void 0, ),{rfqQuote:Ue,status:Ve,handleInputChange:F,ensureForParams:j,stop:je,clear:S,refresh:G}=_chunkMCT3UZTPcjs.e.call(void 0, ),{address:m}=_chunk34N36GUDcjs.a.call(void 0, ),{openConnectModal:be}=_chunkMCT3UZTPcjs.g.call(void 0, ),{isRecipientInputOpen:M,txStatus:z,view:v,selectedChainFilterChainId:D}=_chunkUZWGYG2Scjs.c.call(void 0, _shallow.useShallow.call(void 0, n=>({isRecipientInputOpen:n.isRecipientInputOpen,txStatus:n.txStatus,view:n.view,selectedChainFilterChainId:_nullishCoalesce(_optionalChain([n, 'access', _2 => _2.selectedChainFilter, 'optionalAccess', _3 => _3.chainId]), () => (null))}))),[C,he]=_react.useState.call(void 0, null),[y,E]=_react.useState.call(void 0, null),xe=_react.useRef.call(void 0, !1),s=!1,Se=_react.useMemo.call(void 0, ()=>!t||!o||typeof i!="number"||!u||!m||parseFloat(g.formatted)<i?null:{base:t,quote:o,baseAmount:i,quoteAmount:u,userAddress:m},[t,o,i,u,m,g.formatted]),Ce=_react.useCallback.call(void 0, n=>{E(n),_chunkUZWGYG2Scjs.c.getState().startTracking(n)},[]),ye=_react.useCallback.call(void 0, ()=>{xe.current=!0,G()},[G]);_react.useEffect.call(void 0, ()=>{if(C===null&&!(!t||!o)){if(!i||i<=0){F({amount:null,inputToken:t,outputToken:o,setOutputAmount:c});return}if(a||l){c(i);return}F({amount:i,inputToken:t,outputToken:o,setOutputAmount:c})}},[C,i,t,o,a,l,F,c]);let I=_react.useCallback.call(void 0, ()=>{_chunkUZWGYG2Scjs.c.getState().setView("baseSelection")},[]),W=_react.useCallback.call(void 0, ()=>{_chunkUZWGYG2Scjs.c.getState().setView("quoteSelection")},[]),Ae=_react.useCallback.call(void 0, ()=>{U(),c(null)},[U,c]),Pe=_react.useCallback.call(void 0, ()=>{if(!g.formatted||!t||!o)return;let n=parseFloat(g.formatted);if(!n||n<=0)return;let b=n*.9999999999;a||l?(R(b),c(b),S()):(R(b),c(null),j({inputToken:t,outputToken:o,inputAmount:b.toString(),setOutputAmount:A=>c(A)}))},[g.formatted,t,o,a,l,R,c,S,j]),ke=_react.useCallback.call(void 0, ()=>{S(),V()},[S,V]),_=g.formatted?parseFloat(g.formatted):null,Oe=!!(i||u),L=fe==="split",J=L&&(v==="baseSelection"||v==="baseChainSelection"),K=L&&(v==="quoteSelection"||v==="quoteChainSelection"),X=_react.useCallback.call(void 0, n=>{let A=_chunkUZWGYG2Scjs.c.getState().view==="baseChainSelection"?"base":"quote";_chunkUZWGYG2Scjs.c.getState().setChainFilter({chainId:n,side:A}),_chunkUZWGYG2Scjs.c.getState().pushRecentChain(n),_chunkUZWGYG2Scjs.c.getState().transitionToView(A==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),Ne=_react.useCallback.call(void 0, ()=>{_chunkUZWGYG2Scjs.c.getState().transitionToView("baseChainSelection","chainSelection")},[]),qe=_react.useCallback.call(void 0, ()=>{_chunkUZWGYG2Scjs.c.getState().transitionToView("quoteChainSelection","chainSelection")},[]),Te=_optionalChain([t, 'optionalAccess', _4 => _4.price])&&i?`$${(t.price*i).toFixed(2)}`:"$0.00",Re=_optionalChain([o, 'optionalAccess', _5 => _5.price])&&u?`$${(o.price*u).toFixed(2)}`:"$0.00",Y=C==="trackingTx"&&!!y&&!!t&&!!o&&!!i&&!!u,Z={backgroundColor:q==="default"?"var(--widget-primary)":"transparent",color:q==="default"?"var(--widget-primary-foreground)":"var(--widget-primary)",border:q!=="default"?"1px solid var(--widget-primary)":"none",borderRadius:"var(--widget-radius)"};return _jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full",children:[Y&&y&&t&&o&&i&&u?_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-h-0 overflow-hidden",children:_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.w,{orderHash:y,base:t,quote:o,baseAmount:i,quoteAmount:u,status:z})}):_jsxruntime.jsxs.call(void 0, "div",{className:`grid grid-cols-[1fr_auto_1fr] items-stretch px-4 ${T?"pt-3 pb-1":"pt-4 pb-2"} gap-2`,children:[_jsxruntime.jsx.call(void 0, "div",{className:`relative flex flex-col gap-1 p-3 rounded-lg overflow-hidden ${J?"h-[380px]":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)"},children:J?v==="baseChainSelection"?_jsxruntime.jsx.call(void 0, _chunkXZRXVBSBcjs.a,{toggle:_nullishCoalesce(h, () => (P)),side:"base",onChainSelect:X}):_jsxruntime.jsx.call(void 0, _chunkHTWUZKYOcjs.a,{toggle:_nullishCoalesce(h, () => (P)),side:"base",otherAsset:o,onMoreChainsClick:Ne,selectedChainFilter:D}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[Q?T?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${x==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.i,{toggle:I,side:"base",asset:t,isPlacingOrder:s||O}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.h,{side:"base",asset:_nullishCoalesce(t, () => (null)),otherAsset:_nullishCoalesce(o, () => (null)),isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${x==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.i,{toggle:I,side:"base",asset:t,isPlacingOrder:s||O}),_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.h,{side:"base",asset:_nullishCoalesce(t, () => (null)),otherAsset:_nullishCoalesce(o, () => (null)),isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.i,{toggle:I,side:"base",asset:t,isPlacingOrder:s||O}),_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.h,{side:"base",asset:_nullishCoalesce(t, () => (null)),otherAsset:_nullishCoalesce(o, () => (null)),isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "span",{className:"mono text-xs",style:{color:"var(--widget-muted-foreground)"},children:Te}),m&&_!==null&&_>0&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Pe,disabled:s,className:"flex items-center rounded-full px-2 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 transition-colors bg-(--widget-primary) text-(--widget-primary-foreground) hover:bg-(--widget-foreground) hover:text-(--widget-card)",children:"Max"})]})]})}),_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center justify-center px-1",children:me?_jsxruntime.jsx.call(void 0, "div",{className:"flex h-8 w-8 items-center justify-center opacity-20",children:_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"\u2192"})}):_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Ae,"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:"\u2194"})})}),_jsxruntime.jsx.call(void 0, "div",{className:`relative flex flex-col gap-1 p-3 rounded-lg overflow-hidden ${K?"h-[380px]":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)"},children:K?v==="quoteChainSelection"?_jsxruntime.jsx.call(void 0, _chunkXZRXVBSBcjs.a,{toggle:_nullishCoalesce(h, () => (P)),side:"quote",onChainSelect:X}):_jsxruntime.jsx.call(void 0, _chunkHTWUZKYOcjs.a,{toggle:_nullishCoalesce(h, () => (P)),side:"quote",otherAsset:t,onMoreChainsClick:qe,selectedChainFilter:D}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[Q?T?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${x==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.i,{toggle:W,side:"quote",asset:o,isPlacingOrder:s||N}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.h,{side:"quote",asset:_nullishCoalesce(o, () => (null)),otherAsset:_nullishCoalesce(t, () => (null)),isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${x==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.i,{toggle:W,side:"quote",asset:o,isPlacingOrder:s||N}),_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.h,{side:"quote",asset:_nullishCoalesce(o, () => (null)),otherAsset:_nullishCoalesce(t, () => (null)),isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.i,{toggle:W,side:"quote",asset:o,isPlacingOrder:s||N}),_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.h,{side:"quote",asset:_nullishCoalesce(o, () => (null)),otherAsset:_nullishCoalesce(t, () => (null)),isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "span",{className:"mono text-xs",style:{color:"var(--widget-muted-foreground)"},children:Re}),Oe&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:ke,disabled:s,className:"flex items-center rounded-full px-2 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 transition-colors text-(--widget-muted-foreground) hover:bg-(--widget-secondary)",children:"Clear"})]})]})})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-row items-center w-full overflow-hidden px-4",style:{borderTop:M?"1px solid var(--widget-border)":"none",maxHeight:M?"60px":"0px",opacity:M?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 ${Y?"px-0":"px-4"} py-4`,children:m&&t&&o&&i&&i>0?_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.v,{base:t,baseAmount:i,quote:o,quoteAmount:_nullishCoalesce(u, () => (0)),userAddress:m,isWrappingPair:a,isUnwrappingPair:l,isBaseGasToken:we,isQuoteGasToken:ve,reviewActionProps:Se,reviewState:C,setReviewState:he,trackedOrderHash:y,setTrackedOrderHash:E,onSwapComplete:ue,onSwapInitiated:ce,onOrderSubmitted:Ce,onStaleQuoteRestart:ye,txStatus:z}):!m&&pe?_jsxruntime.jsx.call(void 0, "button",{onClick:()=>be(),className:"w-full py-3 text-sm font-medium cursor-pointer transition-opacity hover:opacity-80",style:Z,children:"Connect Wallet"}):_jsxruntime.jsx.call(void 0, "button",{disabled:!0,className:"w-full py-3 text-sm font-medium transition-colors disabled:opacity-40 cursor-not-allowed",style:Z,children:m?"Enter Amount":"Connect Wallet"})})]})},rt= exports.default =$e;exports.default = rt;
@@ -1,2 +0,0 @@
1
- "use client";
2
- "use client";import{e as ae,g as ne,h as b,i as h,j as re,v as le,w as de}from"./chunk-XYF2YBR3.js";import{a as ce}from"./chunk-4LJJMEOG.js";import{a as ue}from"./chunk-FDQKBTWP.js";import"./chunk-OPN7WCJR.js";import{c as l,f as ie}from"./chunk-726CI6GC.js";import{P as U,X as se,b as te}from"./chunk-EW2OR6CJ.js";import{a as oe}from"./chunk-46H44R7V.js";import"./chunk-73CB2I7U.js";import{useCallback as f,useEffect as pe,useMemo as Ge,useRef as me,useState as V}from"react";import{useShallow as Le}from"zustand/react/shallow";import{Fragment as P,jsx as e,jsxs as t}from"react/jsx-runtime";var ge=()=>{},_e=({onSwapComplete:fe,onSwapInitiated:xe,onBackToSwap:H,onMoreChainsClick:Je})=>{let{web3ConnectionType:Ke,hasConnectHandler:ve,lockBase:O,lockQuote:T,disableInverting:we,swapButtonVariant:q,tokenDisplay:j,tokenBadgeOrientation:y,widgetType:be,assetMenuVariant:he}=te(),E=j==="pill"||j==="ghost",N=be==="compact",{baseToken:d,quoteToken:c,baseAmount:a,quoteAmount:n,isBaseGasToken:Se,isQuoteGasToken:ye,isWrappingPair:u,isUnwrappingPair:p,baseBalance:w,setBaseAmount:R,setQuoteAmount:g,swapTokens:D,clearForm:z}=ie(),{handleInputChange:F,ensureForParams:G,clear:C,refresh:L,liquidityError:Ne,routingError:Ce}=ae(),{address:x}=oe(),{openConnectModal:ke}=ne(),{isRecipientInputOpen:I,txStatus:_,view:v,selectedChainFilterChainId:Ae}=l(Le(i=>({isRecipientInputOpen:i.isRecipientInputOpen,txStatus:i.txStatus,view:i.view,selectedChainFilterChainId:i.selectedChainFilterChainId??null}))),[k,Pe]=V(null),[A,J]=V(null),Oe=me(!1),r=!1,Te=Ge(()=>!d||!c||typeof a!="number"||!n||!x||parseFloat(w.formatted)<a?null:{base:d,quote:c,baseAmount:a,quoteAmount:n,userAddress:x},[d,c,a,n,x,w.formatted]),qe=f(i=>{J(i),l.getState().startTracking(i)},[]),Re=f(()=>{Oe.current=!0,L()},[L]);pe(()=>{if(k===null&&!(!d||!c)){if(!a||a<=0){F({amount:null,inputToken:d,outputToken:c,setOutputAmount:g});return}if(u||p){g(a);return}F({amount:a,inputToken:d,outputToken:c,setOutputAmount:g})}},[k,a,d,c,u,p,F,g]);let K=a&&n&&parseFloat(n.toString())?parseFloat(a.toString())/parseFloat(n.toString()):0,M=f(()=>{l.getState().setView("baseSelection")},[]),$=f(()=>{l.getState().setView("quoteSelection")},[]),Fe=f(()=>{D(),g(null)},[D,g]),Ie=f(()=>{if(!w.formatted||!d||!c)return;let i=parseFloat(w.formatted);if(!i||i<=0)return;let m=i*.9999999999;u||p?(R(m),g(m),C()):(R(m),g(null),G({inputToken:d,outputToken:c,inputAmount:m.toString(),setOutputAmount:S=>g(S)}))},[w.formatted,d,c,u,p,R,g,C,G]),Me=f(()=>{C(),z()},[C,z]),X=w.formatted?parseFloat(w.formatted):null,$e=!!(a||n),s=d,o=c,We=s?.price&&a?`$${(s.price*a).toFixed(2)}`:"$0.00",Be=o?.price&&n?`$${(o.price*n).toFixed(2)}`:"$0.00",Qe=!!(s&&o&&a&&n),Ue=Ne||Ce,Y=k==="trackingTx"&&!!A&&!!s&&!!o&&!!a&&!!n,W=he==="split",B=W&&(v==="baseSelection"||v==="quoteSelection"||v==="baseChainSelection"||v==="quoteChainSelection"),Q=v==="baseSelection"||v==="baseChainSelection"?"base":"quote",Ve=Q==="base"?o:s,Z=me(null),[He,je]=V(380);pe(()=>{if(!W)return;let i=Z.current;if(!i)return;let m=new ResizeObserver(S=>{for(let ze of S)je(ze.contentRect.height)});return m.observe(i),()=>m.disconnect()},[W]);let Ee=f(i=>{let S=l.getState().view==="baseChainSelection"?"base":"quote";l.getState().setChainFilter({chainId:i,side:S}),l.getState().pushRecentChain(i),l.getState().transitionToView(S==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),De=f(()=>{let i=l.getState().view;i==="baseSelection"?l.getState().transitionToView("baseChainSelection","chainSelection"):i==="quoteSelection"&&l.getState().transitionToView("quoteChainSelection","chainSelection")},[]),ee={backgroundColor:q==="default"?"var(--widget-primary)":"transparent",color:q==="default"?"var(--widget-primary-foreground)":"var(--widget-primary)",border:q!=="default"?"1px solid var(--widget-primary)":"none",borderRadius:"var(--widget-radius)"};return t("div",{className:"flex flex-row w-full",children:[t("div",{ref:Z,className:"flex flex-col flex-1 min-w-0",style:{borderRight:"1px solid var(--widget-border)"},children:[Y&&A&&s&&o&&a&&n?e("div",{className:"flex-1 min-h-0 overflow-hidden",children:e(de,{orderHash:A,base:s,quote:o,baseAmount:a,quoteAmount:n,status:_})}):t(P,{children:[t("div",{className:`relative ${N?"px-4 pt-3 pb-1":"px-4 pt-4 pb-2"}`,style:{borderBottom:"1px solid var(--widget-border)"},children:[E?N?t("div",{className:`flex items-center gap-2 ${y==="right"?"flex-row-reverse":"flex-row"}`,children:[e(h,{toggle:M,side:"base",asset:s,isPlacingOrder:r||O}),e("div",{className:"flex-1 min-w-0",children:e(b,{side:"base",asset:s??null,otherAsset:o??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})})]}):t("div",{className:`flex flex-col ${y==="right"?"items-end":"items-start"}`,children:[e(h,{toggle:M,side:"base",asset:s,isPlacingOrder:r||O}),e(b,{side:"base",asset:s??null,otherAsset:o??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}):t(P,{children:[e(h,{toggle:M,side:"base",asset:s,isPlacingOrder:r||O}),e(b,{side:"base",asset:s??null,otherAsset:o??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}),t("div",{className:"mb-1 flex w-full flex-row items-center justify-between",children:[e("p",{className:"mono text-sm",style:{color:"var(--widget-muted-foreground)"},children:We}),x&&X!==null&&X>0&&e("button",{type:"button",onClick:Ie,disabled:r,className:"absolute bottom-3 right-4 flex items-center rounded-full px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 bg-(--widget-primary) text-(--widget-primary-foreground) hover:bg-(--widget-foreground) hover:text-(--widget-card) transition-colors",children:"Max"})]})]}),!we&&e("div",{className:"flex justify-center -my-4 relative z-10",children:t("button",{type:"button",onClick:Fe,"aria-label":"Swap input and output tokens",className:"flex h-8 w-8 items-center justify-center rounded-full cursor-pointer bg-(--widget-card) text-(--widget-muted-foreground) hover:bg-(--widget-secondary) hover:text-(--widget-foreground) transition-colors",style:{border:"1px solid var(--widget-border)"},children:[e("span",{className:"text-2xs",children:"\u2191"}),e("span",{className:"text-2xs",children:"\u2193"})]})}),t("div",{className:`relative ${N?"px-4 pt-4 pb-1":"px-4 pt-6 pb-2"}`,children:[E?N?t("div",{className:`flex items-center gap-2 ${y==="right"?"flex-row-reverse":"flex-row"}`,children:[e(h,{toggle:$,side:"quote",asset:o,isPlacingOrder:r||T}),e("div",{className:"flex-1 min-w-0",children:e(b,{side:"quote",asset:o??null,otherAsset:s??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})})]}):t("div",{className:`flex flex-col ${y==="right"?"items-end":"items-start"}`,children:[e(h,{toggle:$,side:"quote",asset:o,isPlacingOrder:r||T}),e(b,{side:"quote",asset:o??null,otherAsset:s??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}):t(P,{children:[e(h,{toggle:$,side:"quote",asset:o,isPlacingOrder:r||T}),e(b,{side:"quote",asset:o??null,otherAsset:s??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}),t("div",{className:"flex w-full flex-row items-center justify-between",children:[e("p",{className:"mono text-sm",style:{color:"var(--widget-muted-foreground)"},children:Be}),$e&&e("button",{type:"button",onClick:Me,disabled:r,className:"absolute bottom-2 right-4 flex items-center rounded-full px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 text-(--widget-muted-foreground) hover:bg-(--widget-secondary) transition-colors",children:"Clear"})]})]})]}),e("div",{className:"flex flex-row items-center w-full overflow-hidden",style:{borderTop:I?"1px solid var(--widget-border)":"none",maxHeight:I?"60px":"0px",opacity:I?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:e(re,{})}),e("div",{className:`relative ${Y?"px-0":"px-4"} py-4`,children:x&&s&&o&&a&&a>0?e(le,{base:s,baseAmount:a,quote:o,quoteAmount:n??0,userAddress:x,isWrappingPair:u,isUnwrappingPair:p,isBaseGasToken:Se,isQuoteGasToken:ye,reviewActionProps:Te,reviewState:k,setReviewState:Pe,trackedOrderHash:A,setTrackedOrderHash:J,onSwapComplete:fe,onSwapInitiated:xe,onOrderSubmitted:qe,onStaleQuoteRestart:Re,txStatus:_}):!x&&ve?e("button",{onClick:()=>ke(),className:"w-full py-3 text-sm font-medium cursor-pointer transition-opacity hover:opacity-80",style:ee,children:"Connect Wallet"}):e("button",{disabled:!0,className:"w-full py-3 text-sm font-medium transition-colors disabled:opacity-40 cursor-not-allowed",style:ee,children:x?"Enter Amount":"Connect Wallet"})})]}),e("div",{className:`flex flex-col transition-all duration-300 ${B?"flex-1 min-w-0":"w-48 shrink-0"}`,style:{backgroundColor:"var(--widget-background)",...B?{height:`${He}px`}:{}},children:B?e("div",{className:"flex flex-col overflow-hidden p-2",style:{height:"100%"},children:v==="baseChainSelection"||v==="quoteChainSelection"?e(ue,{toggle:H??ge,side:Q,onChainSelect:Ee}):e(ce,{toggle:H??ge,side:Q,otherAsset:Ve,onMoreChainsClick:De,selectedChainFilter:Ae})}):t("div",{className:"flex flex-col gap-3 px-4 py-4",children:[e("span",{className:"text-2xs uppercase tracking-wider font-medium",style:{color:"var(--widget-muted-foreground)"},children:"Quote Details"}),Qe&&s&&o?t(P,{children:[t("div",{className:"flex flex-col gap-0.5",children:[e("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Rate"}),t("div",{className:"flex items-center gap-1",children:[e(U,{asset:o,size:"3xs",noChain:!0}),t("span",{className:"font-mono text-xs uppercase",children:["1 ",o.symbol]})]}),e("div",{className:"flex items-center gap-1 pl-4",children:t("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:["= ",K.toFixed(6)]})}),t("div",{className:"flex items-center gap-1 pl-4",children:[e(U,{asset:s,size:"3xs",noChain:!0}),e("span",{className:"font-mono text-xs uppercase",children:s.symbol})]})]}),t("div",{className:"flex flex-col gap-2",style:{borderTop:"1px solid var(--widget-border)",paddingTop:"0.5rem"},children:[t("div",{className:"flex justify-between items-center",children:[e("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"USD Value"}),t("span",{className:"font-mono text-xs",children:["$",s.price?(s.price*K*parseFloat(n.toString())).toFixed(2):"\u2014"]})]}),t("div",{className:"flex justify-between items-center",children:[e("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Order Type"}),e("span",{className:"text-2xs font-mono",style:{color:"var(--widget-foreground)"},children:"RFQ"})]}),t("div",{className:"flex justify-between items-center",children:[e("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Fill"}),e("span",{className:"text-2xs",style:{color:"var(--widget-primary)"},children:"Exact"})]}),s.chainId!==o.chainId&&t("div",{className:"flex justify-between items-center",children:[e("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Route"}),e("span",{className:"text-2xs font-mono",children:"Cross-chain"})]})]})]}):Ue?t("div",{className:"flex flex-col gap-1",children:[e(se,{className:"h-6 w-6",style:{color:"var(--widget-destructive)"}}),e("span",{className:"text-2xs",style:{color:"var(--widget-destructive)"},children:"Quote not found"})]}):t("div",{className:"flex flex-col gap-2 mt-2",children:[[...Array(4)].map((i,m)=>e("div",{className:"h-3 rounded animate-pulse",style:{backgroundColor:"var(--widget-muted)",width:m%2===0?"80%":"60%",opacity:.5}},m)),e("span",{className:"text-2xs mt-1",style:{color:"var(--widget-muted-foreground)",opacity:.5},children:"Enter an amount"})]})]})})]})},gt=_e;export{gt as default};
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
2
- "use client";var _chunkMCT3UZTPcjs = require('./chunk-MCT3UZTP.cjs');var _chunkHTWUZKYOcjs = require('./chunk-HTWUZKYO.cjs');var _chunkXZRXVBSBcjs = require('./chunk-XZRXVBSB.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 _shallow = require('zustand/react/shallow');var _jsxruntime = require('react/jsx-runtime');var ge=()=>{},_e=({onSwapComplete:fe,onSwapInitiated:xe,onBackToSwap:H,onMoreChainsClick:Je})=>{let{web3ConnectionType:Ke,hasConnectHandler:ve,lockBase:O,lockQuote:T,disableInverting:we,swapButtonVariant:q,tokenDisplay:j,tokenBadgeOrientation:y,widgetType:be,assetMenuVariant:he}=_chunkLXEKOQAGcjs.b.call(void 0, ),E=j==="pill"||j==="ghost",N=be==="compact",{baseToken:d,quoteToken:c,baseAmount:a,quoteAmount:n,isBaseGasToken:Se,isQuoteGasToken:ye,isWrappingPair:u,isUnwrappingPair:p,baseBalance:w,setBaseAmount:R,setQuoteAmount:g,swapTokens:D,clearForm:z}=_chunkUZWGYG2Scjs.f.call(void 0, ),{handleInputChange:F,ensureForParams:G,clear:C,refresh:L,liquidityError:Ne,routingError:Ce}=_chunkMCT3UZTPcjs.e.call(void 0, ),{address:x}=_chunk34N36GUDcjs.a.call(void 0, ),{openConnectModal:ke}=_chunkMCT3UZTPcjs.g.call(void 0, ),{isRecipientInputOpen:I,txStatus:_,view:v,selectedChainFilterChainId:Ae}=_chunkUZWGYG2Scjs.c.call(void 0, _shallow.useShallow.call(void 0, i=>({isRecipientInputOpen:i.isRecipientInputOpen,txStatus:i.txStatus,view:i.view,selectedChainFilterChainId:_nullishCoalesce(i.selectedChainFilterChainId, () => (null))}))),[k,Pe]=_react.useState.call(void 0, null),[A,J]=_react.useState.call(void 0, null),Oe=_react.useRef.call(void 0, !1),r=!1,Te=_react.useMemo.call(void 0, ()=>!d||!c||typeof a!="number"||!n||!x||parseFloat(w.formatted)<a?null:{base:d,quote:c,baseAmount:a,quoteAmount:n,userAddress:x},[d,c,a,n,x,w.formatted]),qe=_react.useCallback.call(void 0, i=>{J(i),_chunkUZWGYG2Scjs.c.getState().startTracking(i)},[]),Re=_react.useCallback.call(void 0, ()=>{Oe.current=!0,L()},[L]);_react.useEffect.call(void 0, ()=>{if(k===null&&!(!d||!c)){if(!a||a<=0){F({amount:null,inputToken:d,outputToken:c,setOutputAmount:g});return}if(u||p){g(a);return}F({amount:a,inputToken:d,outputToken:c,setOutputAmount:g})}},[k,a,d,c,u,p,F,g]);let K=a&&n&&parseFloat(n.toString())?parseFloat(a.toString())/parseFloat(n.toString()):0,M=_react.useCallback.call(void 0, ()=>{_chunkUZWGYG2Scjs.c.getState().setView("baseSelection")},[]),$=_react.useCallback.call(void 0, ()=>{_chunkUZWGYG2Scjs.c.getState().setView("quoteSelection")},[]),Fe=_react.useCallback.call(void 0, ()=>{D(),g(null)},[D,g]),Ie=_react.useCallback.call(void 0, ()=>{if(!w.formatted||!d||!c)return;let i=parseFloat(w.formatted);if(!i||i<=0)return;let m=i*.9999999999;u||p?(R(m),g(m),C()):(R(m),g(null),G({inputToken:d,outputToken:c,inputAmount:m.toString(),setOutputAmount:S=>g(S)}))},[w.formatted,d,c,u,p,R,g,C,G]),Me=_react.useCallback.call(void 0, ()=>{C(),z()},[C,z]),X=w.formatted?parseFloat(w.formatted):null,$e=!!(a||n),s=d,o=c,We=_optionalChain([s, 'optionalAccess', _2 => _2.price])&&a?`$${(s.price*a).toFixed(2)}`:"$0.00",Be=_optionalChain([o, 'optionalAccess', _3 => _3.price])&&n?`$${(o.price*n).toFixed(2)}`:"$0.00",Qe=!!(s&&o&&a&&n),Ue=Ne||Ce,Y=k==="trackingTx"&&!!A&&!!s&&!!o&&!!a&&!!n,W=he==="split",B=W&&(v==="baseSelection"||v==="quoteSelection"||v==="baseChainSelection"||v==="quoteChainSelection"),Q=v==="baseSelection"||v==="baseChainSelection"?"base":"quote",Ve=Q==="base"?o:s,Z=_react.useRef.call(void 0, null),[He,je]=_react.useState.call(void 0, 380);_react.useEffect.call(void 0, ()=>{if(!W)return;let i=Z.current;if(!i)return;let m=new ResizeObserver(S=>{for(let ze of S)je(ze.contentRect.height)});return m.observe(i),()=>m.disconnect()},[W]);let Ee=_react.useCallback.call(void 0, i=>{let S=_chunkUZWGYG2Scjs.c.getState().view==="baseChainSelection"?"base":"quote";_chunkUZWGYG2Scjs.c.getState().setChainFilter({chainId:i,side:S}),_chunkUZWGYG2Scjs.c.getState().pushRecentChain(i),_chunkUZWGYG2Scjs.c.getState().transitionToView(S==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),De=_react.useCallback.call(void 0, ()=>{let i=_chunkUZWGYG2Scjs.c.getState().view;i==="baseSelection"?_chunkUZWGYG2Scjs.c.getState().transitionToView("baseChainSelection","chainSelection"):i==="quoteSelection"&&_chunkUZWGYG2Scjs.c.getState().transitionToView("quoteChainSelection","chainSelection")},[]),ee={backgroundColor:q==="default"?"var(--widget-primary)":"transparent",color:q==="default"?"var(--widget-primary-foreground)":"var(--widget-primary)",border:q!=="default"?"1px solid var(--widget-primary)":"none",borderRadius:"var(--widget-radius)"};return _jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row w-full",children:[_jsxruntime.jsxs.call(void 0, "div",{ref:Z,className:"flex flex-col flex-1 min-w-0",style:{borderRight:"1px solid var(--widget-border)"},children:[Y&&A&&s&&o&&a&&n?_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-h-0 overflow-hidden",children:_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.w,{orderHash:A,base:s,quote:o,baseAmount:a,quoteAmount:n,status:_})}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "div",{className:`relative ${N?"px-4 pt-3 pb-1":"px-4 pt-4 pb-2"}`,style:{borderBottom:"1px solid var(--widget-border)"},children:[E?N?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${y==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.i,{toggle:M,side:"base",asset:s,isPlacingOrder:r||O}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.h,{side:"base",asset:_nullishCoalesce(s, () => (null)),otherAsset:_nullishCoalesce(o, () => (null)),isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${y==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.i,{toggle:M,side:"base",asset:s,isPlacingOrder:r||O}),_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.h,{side:"base",asset:_nullishCoalesce(s, () => (null)),otherAsset:_nullishCoalesce(o, () => (null)),isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.i,{toggle:M,side:"base",asset:s,isPlacingOrder:r||O}),_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.h,{side:"base",asset:_nullishCoalesce(s, () => (null)),otherAsset:_nullishCoalesce(o, () => (null)),isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}),_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:We}),x&&X!==null&&X>0&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Ie,disabled:r,className:"absolute bottom-3 right-4 flex items-center rounded-full px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 bg-(--widget-primary) text-(--widget-primary-foreground) hover:bg-(--widget-foreground) hover:text-(--widget-card) transition-colors",children:"Max"})]})]}),!we&&_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:Fe,"aria-label":"Swap input and output tokens",className:"flex h-8 w-8 items-center justify-center rounded-full cursor-pointer bg-(--widget-card) text-(--widget-muted-foreground) hover:bg-(--widget-secondary) hover:text-(--widget-foreground) transition-colors",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 ${N?"px-4 pt-4 pb-1":"px-4 pt-6 pb-2"}`,children:[E?N?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${y==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.i,{toggle:$,side:"quote",asset:o,isPlacingOrder:r||T}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.h,{side:"quote",asset:_nullishCoalesce(o, () => (null)),otherAsset:_nullishCoalesce(s, () => (null)),isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${y==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.i,{toggle:$,side:"quote",asset:o,isPlacingOrder:r||T}),_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.h,{side:"quote",asset:_nullishCoalesce(o, () => (null)),otherAsset:_nullishCoalesce(s, () => (null)),isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.i,{toggle:$,side:"quote",asset:o,isPlacingOrder:r||T}),_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.h,{side:"quote",asset:_nullishCoalesce(o, () => (null)),otherAsset:_nullishCoalesce(s, () => (null)),isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}),_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:Be}),$e&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Me,disabled:r,className:"absolute bottom-2 right-4 flex items-center rounded-full px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 text-(--widget-muted-foreground) hover:bg-(--widget-secondary) transition-colors",children:"Clear"})]})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-row items-center w-full overflow-hidden",style:{borderTop:I?"1px solid var(--widget-border)":"none",maxHeight:I?"60px":"0px",opacity:I?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:`relative ${Y?"px-0":"px-4"} py-4`,children:x&&s&&o&&a&&a>0?_jsxruntime.jsx.call(void 0, _chunkMCT3UZTPcjs.v,{base:s,baseAmount:a,quote:o,quoteAmount:_nullishCoalesce(n, () => (0)),userAddress:x,isWrappingPair:u,isUnwrappingPair:p,isBaseGasToken:Se,isQuoteGasToken:ye,reviewActionProps:Te,reviewState:k,setReviewState:Pe,trackedOrderHash:A,setTrackedOrderHash:J,onSwapComplete:fe,onSwapInitiated:xe,onOrderSubmitted:qe,onStaleQuoteRestart:Re,txStatus:_}):!x&&ve?_jsxruntime.jsx.call(void 0, "button",{onClick:()=>ke(),className:"w-full py-3 text-sm font-medium cursor-pointer transition-opacity hover:opacity-80",style:ee,children:"Connect Wallet"}):_jsxruntime.jsx.call(void 0, "button",{disabled:!0,className:"w-full py-3 text-sm font-medium transition-colors disabled:opacity-40 cursor-not-allowed",style:ee,children:x?"Enter Amount":"Connect Wallet"})})]}),_jsxruntime.jsx.call(void 0, "div",{className:`flex flex-col transition-all duration-300 ${B?"flex-1 min-w-0":"w-48 shrink-0"}`,style:{backgroundColor:"var(--widget-background)",...B?{height:`${He}px`}:{}},children:B?_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col overflow-hidden p-2",style:{height:"100%"},children:v==="baseChainSelection"||v==="quoteChainSelection"?_jsxruntime.jsx.call(void 0, _chunkXZRXVBSBcjs.a,{toggle:_nullishCoalesce(H, () => (ge)),side:Q,onChainSelect:Ee}):_jsxruntime.jsx.call(void 0, _chunkHTWUZKYOcjs.a,{toggle:_nullishCoalesce(H, () => (ge)),side:Q,otherAsset:Ve,onMoreChainsClick:De,selectedChainFilter:Ae})}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-3 px-4 py-4",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs uppercase tracking-wider font-medium",style:{color:"var(--widget-muted-foreground)"},children:"Quote Details"}),Qe&&s&&o?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-0.5",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Rate"}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-1",children:[_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.P,{asset:o,size:"3xs",noChain:!0}),_jsxruntime.jsxs.call(void 0, "span",{className:"font-mono text-xs uppercase",children:["1 ",o.symbol]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center gap-1 pl-4",children:_jsxruntime.jsxs.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:["= ",K.toFixed(6)]})}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-1 pl-4",children:[_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.P,{asset:s,size:"3xs",noChain:!0}),_jsxruntime.jsx.call(void 0, "span",{className:"font-mono text-xs uppercase",children:s.symbol})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",style:{borderTop:"1px solid var(--widget-border)",paddingTop:"0.5rem"},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"USD Value"}),_jsxruntime.jsxs.call(void 0, "span",{className:"font-mono text-xs",children:["$",s.price?(s.price*K*parseFloat(n.toString())).toFixed(2):"\u2014"]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Order Type"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs font-mono",style:{color:"var(--widget-foreground)"},children:"RFQ"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Fill"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-primary)"},children:"Exact"})]}),s.chainId!==o.chainId&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Route"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs font-mono",children:"Cross-chain"})]})]})]}):Ue?_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.X,{className:"h-6 w-6",style:{color:"var(--widget-destructive)"}}),_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-destructive)"},children:"Quote not found"})]}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2 mt-2",children:[[...Array(4)].map((i,m)=>_jsxruntime.jsx.call(void 0, "div",{className:"h-3 rounded animate-pulse",style:{backgroundColor:"var(--widget-muted)",width:m%2===0?"80%":"60%",opacity:.5}},m)),_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs mt-1",style:{color:"var(--widget-muted-foreground)",opacity:.5},children:"Enter an amount"})]})]})})]})},gt= exports.default =_e;exports.default = gt;
@@ -1,2 +0,0 @@
1
- "use client";
2
- "use client";import{a as ve}from"./chunk-OPN7WCJR.js";import{c as E,f as se}from"./chunk-726CI6GC.js";import{F as Z,H as Q,I as X,L as J,O as Y,P as M,R as ee,S as te,_ as re,b as G,e as V,h as _,k as R,q,r as K}from"./chunk-EW2OR6CJ.js";import{a as B}from"./chunk-46H44R7V.js";import{b as ge}from"./chunk-73CB2I7U.js";import{useCallback as Me,useState as He}from"react";import{useDisconnect as Be}from"wagmi";import{useCallback as ye,useEffect as we,useMemo as D,useRef as he}from"react";function oe(e){let{address:s,isConnected:n}=B(),{chainDataMap:c}=X(),m=re(),{getToken:v,tokenRegistry:f}=Z(),{supportedInputTokens:p,supportedOutputTokens:w}=G(),l=D(()=>{if(!p.length&&!w.length)return[];let t=new Set,o=[];for(let x of[...p,...w]){let S=`${x.chainId}-${x.address.toLowerCase()}`;t.has(S)||(t.add(S),o.push(x))}return o},[p,w]),{balances:u,isLoading:d,isError:i,refetch:h}=J(s,m,{enabled:n&&e&&!!s,refetchOnWindowFocus:!1},l.length>0?l:void 0),L=D(()=>l.length?new Set(l.map(t=>`${t.chainId}-${t.address.toLowerCase()}`)):null,[l]),r=D(()=>!u||u.length===0?{}:u.filter(o=>!o.assetInfo||!o.balance||o.balance==="0"?!1:L?L.has(`${o.chainId}-${o.address.toLowerCase()}`):R(o.assetInfo)||f.length===0?!0:f.some(x=>x.address.toLowerCase()===o.address.toLowerCase()&&x.chainId===o.chainId)).reduce((o,x)=>{let S=String(x.chainId);return o[S]||(o[S]=[]),o[S].push({token:x.address,amount:x.balance,decimals:x.decimals,assetInfo:x.assetInfo}),o},{}),[u,f,L]),k=D(()=>!u||u.length===0?0:u.reduce((t,o)=>!o.assetInfo||o.decimals===void 0?t:t+parseFloat(o.balance)/10**o.decimals*(o.assetInfo.price||0),0),[u]),T=D(()=>m.length===0?{}:m.reduce((t,o)=>{let x=c[o],S=V(o);return t[o.toString()]={chainId:o,name:S?.displayName||x?.chainKey||`Chain ${o}`},t},{}),[m,c]),W=D(()=>f.map(t=>({address:t.address,chainId:t.chainId})),[f]),N=he(null);we(()=>()=>{N.current&&clearTimeout(N.current)},[]);let A=ye(()=>{N.current&&clearTimeout(N.current),N.current=setTimeout(()=>h(),2e3)},[h]);return{address:s,isConnected:n,groupedAssets:r,totalBalance:k,balancesLoading:d,balancesError:i,chains:T,getToken:v,useTokenWithLazyLoad:Q,tokenRegistry:W,refetchBalances:A}}var ae=ge(ve(),1);import{jsx as I,jsxs as $}from"react/jsx-runtime";var ne=({address:e,totalBalance:s,isLoading:n=!1})=>{let c=m=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(m);return I("div",{className:"p-2 w-full flex justify-center",children:$("div",{className:"relative w-full h-[140px] overflow-hidden",style:{borderRadius:"var(--widget-radius)",border:"1px var(--widget-border-style) var(--widget-border)"},children:[$("div",{className:"absolute inset-0 z-0",children:[I("img",{className:"w-full h-full object-cover opacity-60",src:(0,ae.makeGradient)(e),alt:"address gradient"}),I("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent"})]}),$("div",{className:"relative z-10 flex h-full flex-col justify-between p-3",children:[$("div",{children:[I("p",{className:"text-2xs uppercase mono",style:{color:"var(--widget-muted-foreground)",opacity:.7},children:"Token Balance:"}),n?I(te,{className:"h-8 w-28 bg-white/10 rounded mt-1"}):I("p",{className:"text-2xl font-bold mt-0.5",style:{color:"var(--widget-foreground)"},children:c(s)})]}),I("div",{className:"flex items-center",children:I(ee,{text:e,type:"address",children:I("p",{className:"mono text-2xs",style:{color:"var(--widget-foreground)",opacity:.7},children:e})})})]})]})})};import{useCallback as j,useMemo as le,useState as ke}from"react";import{useState as xe}from"react";import{jsx as H,jsxs as U}from"react/jsx-runtime";var ie=({asset:e,balanceAmount:s,balanceDecimals:n,price:c,onSelect:m,getToken:v,useTokenWithLazyLoad:f})=>{let[p,w]=xe(!1),l=n!==void 0?parseFloat(s)/10**n:0,d=f?.(e.chainId,e.address)?.token,i=c??null;return R(e)&&i==null&&(d?.price!=null?i=d.price:v&&(i=v(e.chainId,e.address)?.price??null)),H("div",{role:"button",tabIndex:0,className:"flex h-[52px] w-full flex-row items-center p-3 cursor-pointer transition-colors",style:{borderBottom:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:p?"var(--widget-secondary)":"transparent"},onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1),onClick:()=>m?.(e),onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),m?.(e))},children:U("div",{className:"flex h-full w-full flex-row items-center justify-between",children:[U("div",{className:"flex h-full flex-row items-center gap-2",children:[H(M,{asset:e,size:"sm"}),U("div",{className:"flex flex-col items-start",children:[H("p",{className:"text-sm font-medium uppercase",style:{color:"var(--widget-foreground)"},children:e.symbol}),l>0&&H("p",{className:"mono text-xs",style:{color:"var(--widget-muted-foreground)"},children:l.toFixed(4)})]})]}),H("p",{className:"text-sm font-medium",style:{color:"var(--widget-foreground)"},children:i!=null?`$${(i*l).toFixed(2)}`:"\u2014"})]})})};import{jsx as C,jsxs as z}from"react/jsx-runtime";var be=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}),Ne=_(),de=({groupedAssets:e,chains:s,tokenRegistry:n=[],getToken:c,useTokenWithLazyLoad:m,onAssetSelect:v})=>{let[f,p]=ke(new Set),w=j(r=>s?.[r]?.name||Ne[r]||`Chain ${r}`,[s]),l=le(()=>{let r=new Set;for(let k of n)r.add(`${k.chainId}-${k.address.toLowerCase()}`);return r},[n]),u=j(r=>r.decimals===void 0||!r.assetInfo?.price?0:parseFloat(r.amount)/10**r.decimals*r.assetInfo.price,[]),{filteredGroupedAssets:d,chainTotals:i}=le(()=>{let r=Object.entries(e).map(([W,N])=>{let A=N.filter(t=>t.assetInfo?R(t.assetInfo)?!0:l.size>0?l.has(`${t.assetInfo.chainId}-${t.assetInfo.address?.toLowerCase()??""}`):!0:!1);return[W,A]}).filter(([,W])=>W.length>0),k={};for(let[W,N]of r)k[W]=N.reduce((A,t)=>A+u(t),0);return{filteredGroupedAssets:[...r].sort((W,N)=>(k[N[0]]??0)-(k[W[0]]??0)),chainTotals:k}},[e,l,u]),h=j(r=>{p(k=>{let T=new Set(k);return T.has(r)?T.delete(r):T.add(r),T})},[]),L=r=>be.format(r);return d.length===0?C("div",{className:"flex items-center justify-center p-6",children:C("p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"No token balances found"})}):C("div",{className:"pb-2 pt-1",children:d.map(([r,k])=>{let T=parseInt(r),W=w(T),N=i[r]||0,A=f.has(r);return z("div",{className:"mx-2 mb-2",style:{border:"1px var(--widget-border-style) var(--widget-border)",borderRadius:"var(--widget-radius)",overflow:"hidden"},children:[z("button",{type:"button",onClick:()=>h(r),className:"flex w-full flex-row items-center justify-between p-2 cursor-pointer transition-colors hover:bg-(--widget-secondary)",style:{backgroundColor:"transparent"},children:[z("div",{className:"inline-flex flex-row items-center gap-2",children:[C(Y,{chain:T,size:"sm"}),C("p",{className:"text-sm font-medium capitalize",style:{color:"var(--widget-foreground)"},children:W})]}),z("div",{className:"flex items-center gap-2",children:[C("p",{className:"text-sm font-semibold",style:{color:"var(--widget-foreground)"},children:L(N)}),C("span",{className:`transition-transform duration-200 ${A?"rotate-180":""}`,style:{color:"var(--widget-muted-foreground)"},children:C("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:C("path",{d:"M2.5 4.5L6 8L9.5 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),C("div",{className:`overflow-hidden transition-all duration-200 ease-out ${A?"max-h-[2000px] opacity-100":"max-h-0 opacity-0"}`,children:C("div",{style:{borderTop:"1px var(--widget-border-style) var(--widget-border)"},children:k.map(t=>t.assetInfo?C(ie,{asset:t.assetInfo,balanceAmount:t.amount,balanceDecimals:t.decimals,price:t.assetInfo?.price??null,onSelect:v,getToken:c,useTokenWithLazyLoad:m},`${t.assetInfo.chainId}-${t.token}`):null)})})]},r)})})};import{useCallback as Se,useRef as Re,useState as De}from"react";function ce(e,s){return{orders:[],isLoading:!1,error:null,hasMore:!1,loadMore:async()=>{},totalOrders:0}}import{useState as Ce}from"react";import{jsx as a,jsxs as b}from"react/jsx-runtime";var We=()=>b("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[a("circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),a("path",{d:"M3 5.2L4.3 6.5L7 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Te=()=>b("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[a("circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),a("path",{d:"M3.5 3.5L6.5 6.5M6.5 3.5L3.5 6.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})]}),Le=()=>b("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[a("circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),a("path",{d:"M5 3V5.5L6.5 6.5",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round"})]}),ue=()=>b("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[a("circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),a("circle",{cx:"5",cy:"5",r:"1.5",fill:"currentColor"})]}),Ie=e=>{switch((e||"").toLowerCase()){case"completed":case"settled":case"success":case"swapped":case"swap":return{icon:a(We,{}),color:"var(--widget-primary)"};case"received":return{icon:a(ue,{}),color:"var(--widget-accent)"};case"failed":case"error":case"expired":return{icon:a(Te,{}),color:"var(--widget-destructive)"};case"pending":case"created":case"placed":return{icon:a(Le,{}),color:"var(--widget-muted-foreground)"};default:return{icon:a(ue,{}),color:"var(--widget-muted-foreground)"}}},Ae=e=>{switch((e||"").toLowerCase()){case"completed":case"settled":case"success":case"swapped":case"swap":return"color-mix(in srgb, var(--widget-primary) 5%, transparent)";case"failed":case"error":case"expired":return"color-mix(in srgb, var(--widget-destructive) 5%, transparent)";case"pending":case"created":case"placed":return"color-mix(in srgb, var(--widget-accent) 5%, transparent)";default:return"var(--widget-secondary)"}},P=(e,s)=>{try{let n=parseFloat(e||"0");if(isNaN(n)||n===0)return"0";let c=s?.decimals??18;return q(n/10**c)}catch{return"0"}},me=({order:e,baseToken:s,quoteToken:n})=>{let[c,m]=Ce(!1),v=e?.status||e?.eventType||"unknown",{icon:f,color:p}=Ie(v),l=(i=>{if(!i)return{date:"",time:""};let h=new Date(typeof i=="number"?i:Number(i)||i);return{date:h.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),time:h.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",timeZone:"UTC",hour12:!1})+" UTC"}})(e?.timestamp||e?.createdAt||""),u=s?{asset:s,symbol:s.symbol,amount:P(e?.inputAmount,s)}:{asset:null,symbol:(e?.inputToken||"").slice(0,6)+"...",amount:P(e?.inputAmount,null)},d=n?{asset:n,symbol:n.symbol,amount:P(e?.outputAmount,n)}:{asset:null,symbol:(e?.outputToken||"").slice(0,6)+"...",amount:P(e?.outputAmount,null)};return b("a",{href:e?.explorerUrl||"#",target:"_blank",rel:"noopener noreferrer",className:"group flex flex-col cursor-pointer transition-all duration-200 ease-in-out no-underline",style:{border:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:c?Ae(v):"transparent",marginBottom:"0.5rem",padding:"0.25rem"},onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),children:[b("div",{className:"flex flex-row items-center justify-between space-x-1",children:[b("div",{className:"flex flex-row items-center space-x-1",children:[a("div",{className:"-translate-y-px",style:{color:p},children:f}),a("p",{className:"text-2xs mono uppercase",style:{color:p},children:v})]}),b("div",{className:"flex flex-row items-center space-x-2",children:[b("span",{className:"text-2xs mono",style:{color:c?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:["\xAC ",K(e?.quoteId||e?.orderHash||"")]}),a("svg",{className:"w-2.5 -translate-y-px opacity-70 group-hover:rotate-[-45deg] group-hover:opacity-100 duration-200",style:{color:"var(--widget-foreground)"},viewBox:"0 0 684 684",fill:"none",children:a("path",{d:"M0.666687 384.667L519.92 384.667L281.627 622.96L342 683.333L683.333 342L342 0.666687L281.627 61.04L519.92 299.333L0.666687 299.333V384.667Z",fill:"currentColor"})})]})]}),b("div",{className:"flex flex-row items-center justify-between pr-2",style:{backgroundColor:c?"transparent":"var(--widget-secondary)"},children:[a("div",{className:"flex flex-col w-full h-full p-2",children:a("div",{className:"flex h-8 w-full items-center justify-between px-2",children:b("div",{className:"flex items-center space-x-1",children:[a(M,{asset:u.asset,size:"xs",className:"h-3 w-3"}),b("div",{className:"flex flex-col",children:[a("span",{className:"text-sm h-4",style:{color:"var(--widget-muted-foreground)"},children:u.amount}),a("span",{className:"text-xs",style:{color:"var(--widget-foreground)"},children:u.symbol})]}),a("span",{className:"px-1",style:{color:"var(--widget-muted-foreground)"},children:"\u2192"}),a(M,{asset:d.asset,size:"xs",className:"h-3 w-3"}),b("div",{className:"flex flex-col",children:[a("span",{className:"text-sm h-4",style:{color:"var(--widget-muted-foreground)"},children:d.amount}),a("span",{className:"text-xs",style:{color:"var(--widget-foreground)"},children:d.symbol})]})]})})}),b("div",{className:"flex flex-col items-end text-right shrink-0",children:[a("span",{className:"text-2xs mono whitespace-nowrap",style:{color:"var(--widget-muted-foreground)"},children:l.date}),l.time&&a("span",{className:"text-2xs mono whitespace-nowrap",style:{color:"var(--widget-muted-foreground)",opacity:.6},children:l.time})]})]})]})};import{Fragment as Fe,jsx as y,jsxs as O}from"react/jsx-runtime";var fe=()=>O("div",{className:"mt-2 flex flex-col",style:{height:"4rem",border:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:"var(--widget-secondary)"},children:[O("div",{className:"flex items-center space-x-2 p-2",children:[y("div",{className:"h-4 w-4 rounded",style:{backgroundColor:"var(--widget-muted)"}}),y("div",{className:"h-3 w-24 rounded",style:{backgroundColor:"var(--widget-muted)"}})]}),O("div",{className:"flex h-8 w-full items-center justify-between px-4",children:[y("div",{className:"flex items-center space-x-1",children:[4,16,10,4,16,10].map((e,s)=>y("div",{className:"h-3 rounded",style:{width:`${e*4}px`,backgroundColor:"var(--widget-muted)"}},s))}),y("div",{className:"h-3 w-10 rounded",style:{backgroundColor:"var(--widget-muted)"}})]})]}),pe=({isActive:e})=>{let{address:s}=B(),{orders:n,isLoading:c,error:m,hasMore:v,loadMore:f}=ce(s,e),[p,w]=De(!1),l=Re(null),u=Se(async d=>{let i=d.currentTarget;if(i.scrollTop+i.clientHeight>=i.scrollHeight-100&&!c&&!p&&v){w(!0);try{await f()}finally{w(!1)}}},[c,p,v,f]);return s?m?y("div",{className:"flex items-center justify-center p-4",children:y("p",{className:"text-sm",style:{color:"var(--widget-destructive)"},children:"Error loading activity"})}):y("div",{ref:l,className:"flex flex-col flex-1 min-h-0 overflow-y-auto p-2",onScroll:u,style:{backgroundColor:"transparent"},children:c?Array.from({length:5}).map((d,i)=>y(fe,{},i)):n.length===0?y("div",{className:"flex flex-col items-center justify-center h-full p-6",children:y("p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"No Activity"})}):O(Fe,{children:[n.map(d=>y(me,{order:d,baseToken:d.enrichedTokens?.base??null,quoteToken:d.enrichedTokens?.quote??null},d.orderHash)),p&&y(fe,{})]})}):y("div",{className:"flex items-center justify-center p-4",children:y("p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Connect your wallet to view activity"})})};import{Fragment as $e,jsx as g,jsxs as F}from"react/jsx-runtime";var Ee=()=>F("div",{className:"flex flex-col w-full h-full overflow-hidden",children:[g("div",{className:"p-2 w-full flex justify-center",children:g("div",{className:"relative w-full h-[140px] animate-pulse",style:{borderRadius:"var(--widget-radius)",border:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:"var(--widget-secondary)"}})}),g("div",{className:"px-2 flex flex-col gap-1.5 mt-1",children:[80,60,72,55,65].map((e,s)=>F("div",{className:"flex items-center justify-between py-1.5",children:[F("div",{className:"flex items-center gap-2",children:[g("div",{className:"h-6 w-6 rounded-full animate-pulse shrink-0",style:{backgroundColor:"var(--widget-secondary)"}}),g("div",{className:"h-3.5 animate-pulse",style:{width:`${e}px`,backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}})]}),g("div",{className:"h-3.5 w-14 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}})]},s))}),g("div",{className:"mt-auto shrink-0 p-2",style:{borderTop:"1px var(--widget-border-style) var(--widget-border)"},children:g("div",{className:"w-full animate-pulse",style:{height:"34px",backgroundColor:"var(--widget-secondary)",opacity:.35,borderRadius:"var(--widget-radius)"}})})]}),It=()=>{let e=E(L=>L.walletTab),[s,n]=He(!1),{disconnect:c}=Be(),{setQuoteToken:m}=se(),v=Me(async L=>{await m(L),E.getState().setView("swap")},[m]),{address:f,groupedAssets:p,totalBalance:w,balancesLoading:l,chains:u,getToken:d,useTokenWithLazyLoad:i,tokenRegistry:h}=oe(!0);return f?l&&e==="wallet"?g(Ee,{}):F("div",{className:"flex flex-col w-full h-full overflow-hidden",children:[F("div",{className:"flex-1 overflow-y-auto",style:{minHeight:0},children:[e==="wallet"&&F($e,{children:[g(ne,{address:f,totalBalance:w,isLoading:l}),g(de,{groupedAssets:p,chains:u,tokenRegistry:h,getToken:d,useTokenWithLazyLoad:i,onAssetSelect:v})]}),e==="activity"&&g(pe,{isActive:e==="activity"})]}),g("div",{className:"shrink-0 p-2",style:{borderTop:"1px var(--widget-border-style) var(--widget-border)"},children:g("button",{type:"button",onClick:()=>{c(),E.getState().setView("swap")},onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),className:"w-full py-2 text-xs mono uppercase cursor-pointer transition-colors",style:{backgroundColor:s?"var(--widget-destructive)":"transparent",color:s?"var(--widget-destructive-foreground)":"var(--widget-destructive)",border:"1px var(--widget-border-style) var(--widget-destructive)",borderRadius:"var(--widget-radius)"},children:"Sign Out"})})]}):g("div",{className:"flex flex-col items-center justify-center h-full p-4",children:g("p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Connect your wallet to view your portfolio"})})};export{It as WidgetWalletPanel};
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
2
- "use client";var _chunkKH57FLSTcjs = require('./chunk-KH57FLST.cjs');var _chunkUZWGYG2Scjs = require('./chunk-UZWGYG2S.cjs');var _chunkLXEKOQAGcjs = require('./chunk-LXEKOQAG.cjs');var _chunk34N36GUDcjs = require('./chunk-34N36GUD.cjs');var _chunkT3I3AJXVcjs = require('./chunk-T3I3AJXV.cjs');var _react = require('react');var _wagmi = require('wagmi');function oe(e){let{address:s,isConnected:n}=_chunk34N36GUDcjs.a.call(void 0, ),{chainDataMap:c}=_chunkLXEKOQAGcjs.I.call(void 0, ),m=_chunkLXEKOQAGcjs._.call(void 0, ),{getToken:v,tokenRegistry:f}=_chunkLXEKOQAGcjs.F.call(void 0, ),{supportedInputTokens:p,supportedOutputTokens:w}=_chunkLXEKOQAGcjs.b.call(void 0, ),l=_react.useMemo.call(void 0, ()=>{if(!p.length&&!w.length)return[];let t=new Set,o=[];for(let x of[...p,...w]){let S=`${x.chainId}-${x.address.toLowerCase()}`;t.has(S)||(t.add(S),o.push(x))}return o},[p,w]),{balances:u,isLoading:d,isError:i,refetch:h}=_chunkLXEKOQAGcjs.L.call(void 0, s,m,{enabled:n&&e&&!!s,refetchOnWindowFocus:!1},l.length>0?l:void 0),L=_react.useMemo.call(void 0, ()=>l.length?new Set(l.map(t=>`${t.chainId}-${t.address.toLowerCase()}`)):null,[l]),r=_react.useMemo.call(void 0, ()=>!u||u.length===0?{}:u.filter(o=>!o.assetInfo||!o.balance||o.balance==="0"?!1:L?L.has(`${o.chainId}-${o.address.toLowerCase()}`):_chunkLXEKOQAGcjs.k.call(void 0, o.assetInfo)||f.length===0?!0:f.some(x=>x.address.toLowerCase()===o.address.toLowerCase()&&x.chainId===o.chainId)).reduce((o,x)=>{let S=String(x.chainId);return o[S]||(o[S]=[]),o[S].push({token:x.address,amount:x.balance,decimals:x.decimals,assetInfo:x.assetInfo}),o},{}),[u,f,L]),k=_react.useMemo.call(void 0, ()=>!u||u.length===0?0:u.reduce((t,o)=>!o.assetInfo||o.decimals===void 0?t:t+parseFloat(o.balance)/10**o.decimals*(o.assetInfo.price||0),0),[u]),T=_react.useMemo.call(void 0, ()=>m.length===0?{}:m.reduce((t,o)=>{let x=c[o],S=_chunkLXEKOQAGcjs.e.call(void 0, o);return t[o.toString()]={chainId:o,name:_optionalChain([S, 'optionalAccess', _2 => _2.displayName])||_optionalChain([x, 'optionalAccess', _3 => _3.chainKey])||`Chain ${o}`},t},{}),[m,c]),W=_react.useMemo.call(void 0, ()=>f.map(t=>({address:t.address,chainId:t.chainId})),[f]),N=_react.useRef.call(void 0, null);_react.useEffect.call(void 0, ()=>()=>{N.current&&clearTimeout(N.current)},[]);let A=_react.useCallback.call(void 0, ()=>{N.current&&clearTimeout(N.current),N.current=setTimeout(()=>h(),2e3)},[h]);return{address:s,isConnected:n,groupedAssets:r,totalBalance:k,balancesLoading:d,balancesError:i,chains:T,getToken:v,useTokenWithLazyLoad:_chunkLXEKOQAGcjs.H,tokenRegistry:W,refetchBalances:A}}var ae=_chunkT3I3AJXVcjs.b.call(void 0, _chunkKH57FLSTcjs.a.call(void 0, ),1);var _jsxruntime = require('react/jsx-runtime');var ne=({address:e,totalBalance:s,isLoading:n=!1})=>{let c=m=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(m);return _jsxruntime.jsx.call(void 0, "div",{className:"p-2 w-full flex justify-center",children:_jsxruntime.jsxs.call(void 0, "div",{className:"relative w-full h-[140px] overflow-hidden",style:{borderRadius:"var(--widget-radius)",border:"1px var(--widget-border-style) var(--widget-border)"},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"absolute inset-0 z-0",children:[_jsxruntime.jsx.call(void 0, "img",{className:"w-full h-full object-cover opacity-60",src:(0,ae.makeGradient)(e),alt:"address gradient"}),_jsxruntime.jsx.call(void 0, "div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"relative z-10 flex h-full flex-col justify-between p-3",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-2xs uppercase mono",style:{color:"var(--widget-muted-foreground)",opacity:.7},children:"Token Balance:"}),n?_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.S,{className:"h-8 w-28 bg-white/10 rounded mt-1"}):_jsxruntime.jsx.call(void 0, "p",{className:"text-2xl font-bold mt-0.5",style:{color:"var(--widget-foreground)"},children:c(s)})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center",children:_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.R,{text:e,type:"address",children:_jsxruntime.jsx.call(void 0, "p",{className:"mono text-2xs",style:{color:"var(--widget-foreground)",opacity:.7},children:e})})})]})]})})};var ie=({asset:e,balanceAmount:s,balanceDecimals:n,price:c,onSelect:m,getToken:v,useTokenWithLazyLoad:f})=>{let[p,w]=_react.useState.call(void 0, !1),l=n!==void 0?parseFloat(s)/10**n:0,d=_optionalChain([f, 'optionalCall', _4 => _4(e.chainId,e.address), 'optionalAccess', _5 => _5.token]),i=_nullishCoalesce(c, () => (null));return _chunkLXEKOQAGcjs.k.call(void 0, e)&&i==null&&(_optionalChain([d, 'optionalAccess', _6 => _6.price])!=null?i=d.price:v&&(i=_nullishCoalesce(_optionalChain([v, 'call', _7 => _7(e.chainId,e.address), 'optionalAccess', _8 => _8.price]), () => (null)))),_jsxruntime.jsx.call(void 0, "div",{role:"button",tabIndex:0,className:"flex h-[52px] w-full flex-row items-center p-3 cursor-pointer transition-colors",style:{borderBottom:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:p?"var(--widget-secondary)":"transparent"},onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1),onClick:()=>_optionalChain([m, 'optionalCall', _9 => _9(e)]),onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),_optionalChain([m, 'optionalCall', _10 => _10(e)]))},children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full w-full flex-row items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full flex-row items-center gap-2",children:[_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.P,{asset:e,size:"sm"}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col items-start",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-medium uppercase",style:{color:"var(--widget-foreground)"},children:e.symbol}),l>0&&_jsxruntime.jsx.call(void 0, "p",{className:"mono text-xs",style:{color:"var(--widget-muted-foreground)"},children:l.toFixed(4)})]})]}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-medium",style:{color:"var(--widget-foreground)"},children:i!=null?`$${(i*l).toFixed(2)}`:"\u2014"})]})})};var be=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}),Ne=_chunkLXEKOQAGcjs.h.call(void 0, ),de=({groupedAssets:e,chains:s,tokenRegistry:n=[],getToken:c,useTokenWithLazyLoad:m,onAssetSelect:v})=>{let[f,p]=_react.useState.call(void 0, new Set),w=_react.useCallback.call(void 0, r=>_optionalChain([s, 'optionalAccess', _11 => _11[r], 'optionalAccess', _12 => _12.name])||Ne[r]||`Chain ${r}`,[s]),l=_react.useMemo.call(void 0, ()=>{let r=new Set;for(let k of n)r.add(`${k.chainId}-${k.address.toLowerCase()}`);return r},[n]),u=_react.useCallback.call(void 0, r=>r.decimals===void 0||!_optionalChain([r, 'access', _13 => _13.assetInfo, 'optionalAccess', _14 => _14.price])?0:parseFloat(r.amount)/10**r.decimals*r.assetInfo.price,[]),{filteredGroupedAssets:d,chainTotals:i}=_react.useMemo.call(void 0, ()=>{let r=Object.entries(e).map(([W,N])=>{let A=N.filter(t=>t.assetInfo?_chunkLXEKOQAGcjs.k.call(void 0, t.assetInfo)?!0:l.size>0?l.has(`${t.assetInfo.chainId}-${_nullishCoalesce(_optionalChain([t, 'access', _15 => _15.assetInfo, 'access', _16 => _16.address, 'optionalAccess', _17 => _17.toLowerCase, 'call', _18 => _18()]), () => (""))}`):!0:!1);return[W,A]}).filter(([,W])=>W.length>0),k={};for(let[W,N]of r)k[W]=N.reduce((A,t)=>A+u(t),0);return{filteredGroupedAssets:[...r].sort((W,N)=>(_nullishCoalesce(k[N[0]], () => (0)))-(_nullishCoalesce(k[W[0]], () => (0)))),chainTotals:k}},[e,l,u]),h=_react.useCallback.call(void 0, r=>{p(k=>{let T=new Set(k);return T.has(r)?T.delete(r):T.add(r),T})},[]),L=r=>be.format(r);return d.length===0?_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center justify-center p-6",children:_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"No token balances found"})}):_jsxruntime.jsx.call(void 0, "div",{className:"pb-2 pt-1",children:d.map(([r,k])=>{let T=parseInt(r),W=w(T),N=i[r]||0,A=f.has(r);return _jsxruntime.jsxs.call(void 0, "div",{className:"mx-2 mb-2",style:{border:"1px var(--widget-border-style) var(--widget-border)",borderRadius:"var(--widget-radius)",overflow:"hidden"},children:[_jsxruntime.jsxs.call(void 0, "button",{type:"button",onClick:()=>h(r),className:"flex w-full flex-row items-center justify-between p-2 cursor-pointer transition-colors hover:bg-(--widget-secondary)",style:{backgroundColor:"transparent"},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"inline-flex flex-row items-center gap-2",children:[_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.O,{chain:T,size:"sm"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-medium capitalize",style:{color:"var(--widget-foreground)"},children:W})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-semibold",style:{color:"var(--widget-foreground)"},children:L(N)}),_jsxruntime.jsx.call(void 0, "span",{className:`transition-transform duration-200 ${A?"rotate-180":""}`,style:{color:"var(--widget-muted-foreground)"},children:_jsxruntime.jsx.call(void 0, "svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:_jsxruntime.jsx.call(void 0, "path",{d:"M2.5 4.5L6 8L9.5 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:`overflow-hidden transition-all duration-200 ease-out ${A?"max-h-[2000px] opacity-100":"max-h-0 opacity-0"}`,children:_jsxruntime.jsx.call(void 0, "div",{style:{borderTop:"1px var(--widget-border-style) var(--widget-border)"},children:k.map(t=>t.assetInfo?_jsxruntime.jsx.call(void 0, ie,{asset:t.assetInfo,balanceAmount:t.amount,balanceDecimals:t.decimals,price:_nullishCoalesce(_optionalChain([t, 'access', _19 => _19.assetInfo, 'optionalAccess', _20 => _20.price]), () => (null)),onSelect:v,getToken:c,useTokenWithLazyLoad:m},`${t.assetInfo.chainId}-${t.token}`):null)})})]},r)})})};function ce(e,s){return{orders:[],isLoading:!1,error:null,hasMore:!1,loadMore:async()=>{},totalOrders:0}}var We=()=>_jsxruntime.jsxs.call(void 0, "svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[_jsxruntime.jsx.call(void 0, "circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),_jsxruntime.jsx.call(void 0, "path",{d:"M3 5.2L4.3 6.5L7 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Te=()=>_jsxruntime.jsxs.call(void 0, "svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[_jsxruntime.jsx.call(void 0, "circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),_jsxruntime.jsx.call(void 0, "path",{d:"M3.5 3.5L6.5 6.5M6.5 3.5L3.5 6.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})]}),Le=()=>_jsxruntime.jsxs.call(void 0, "svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[_jsxruntime.jsx.call(void 0, "circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),_jsxruntime.jsx.call(void 0, "path",{d:"M5 3V5.5L6.5 6.5",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round"})]}),ue=()=>_jsxruntime.jsxs.call(void 0, "svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[_jsxruntime.jsx.call(void 0, "circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),_jsxruntime.jsx.call(void 0, "circle",{cx:"5",cy:"5",r:"1.5",fill:"currentColor"})]}),Ie=e=>{switch((e||"").toLowerCase()){case"completed":case"settled":case"success":case"swapped":case"swap":return{icon:_jsxruntime.jsx.call(void 0, We,{}),color:"var(--widget-primary)"};case"received":return{icon:_jsxruntime.jsx.call(void 0, ue,{}),color:"var(--widget-accent)"};case"failed":case"error":case"expired":return{icon:_jsxruntime.jsx.call(void 0, Te,{}),color:"var(--widget-destructive)"};case"pending":case"created":case"placed":return{icon:_jsxruntime.jsx.call(void 0, Le,{}),color:"var(--widget-muted-foreground)"};default:return{icon:_jsxruntime.jsx.call(void 0, ue,{}),color:"var(--widget-muted-foreground)"}}},Ae=e=>{switch((e||"").toLowerCase()){case"completed":case"settled":case"success":case"swapped":case"swap":return"color-mix(in srgb, var(--widget-primary) 5%, transparent)";case"failed":case"error":case"expired":return"color-mix(in srgb, var(--widget-destructive) 5%, transparent)";case"pending":case"created":case"placed":return"color-mix(in srgb, var(--widget-accent) 5%, transparent)";default:return"var(--widget-secondary)"}},P=(e,s)=>{try{let n=parseFloat(e||"0");if(isNaN(n)||n===0)return"0";let c=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _21 => _21.decimals]), () => (18));return _chunkLXEKOQAGcjs.q.call(void 0, n/10**c)}catch (e2){return"0"}},me=({order:e,baseToken:s,quoteToken:n})=>{let[c,m]=_react.useState.call(void 0, !1),v=_optionalChain([e, 'optionalAccess', _22 => _22.status])||_optionalChain([e, 'optionalAccess', _23 => _23.eventType])||"unknown",{icon:f,color:p}=Ie(v),l=(i=>{if(!i)return{date:"",time:""};let h=new Date(typeof i=="number"?i:Number(i)||i);return{date:h.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),time:h.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",timeZone:"UTC",hour12:!1})+" UTC"}})(_optionalChain([e, 'optionalAccess', _24 => _24.timestamp])||_optionalChain([e, 'optionalAccess', _25 => _25.createdAt])||""),u=s?{asset:s,symbol:s.symbol,amount:P(_optionalChain([e, 'optionalAccess', _26 => _26.inputAmount]),s)}:{asset:null,symbol:(_optionalChain([e, 'optionalAccess', _27 => _27.inputToken])||"").slice(0,6)+"...",amount:P(_optionalChain([e, 'optionalAccess', _28 => _28.inputAmount]),null)},d=n?{asset:n,symbol:n.symbol,amount:P(_optionalChain([e, 'optionalAccess', _29 => _29.outputAmount]),n)}:{asset:null,symbol:(_optionalChain([e, 'optionalAccess', _30 => _30.outputToken])||"").slice(0,6)+"...",amount:P(_optionalChain([e, 'optionalAccess', _31 => _31.outputAmount]),null)};return _jsxruntime.jsxs.call(void 0, "a",{href:_optionalChain([e, 'optionalAccess', _32 => _32.explorerUrl])||"#",target:"_blank",rel:"noopener noreferrer",className:"group flex flex-col cursor-pointer transition-all duration-200 ease-in-out no-underline",style:{border:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:c?Ae(v):"transparent",marginBottom:"0.5rem",padding:"0.25rem"},onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center justify-between space-x-1",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center space-x-1",children:[_jsxruntime.jsx.call(void 0, "div",{className:"-translate-y-px",style:{color:p},children:f}),_jsxruntime.jsx.call(void 0, "p",{className:"text-2xs mono uppercase",style:{color:p},children:v})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center space-x-2",children:[_jsxruntime.jsxs.call(void 0, "span",{className:"text-2xs mono",style:{color:c?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:["\xAC ",_chunkLXEKOQAGcjs.r.call(void 0, _optionalChain([e, 'optionalAccess', _33 => _33.quoteId])||_optionalChain([e, 'optionalAccess', _34 => _34.orderHash])||"")]}),_jsxruntime.jsx.call(void 0, "svg",{className:"w-2.5 -translate-y-px opacity-70 group-hover:rotate-[-45deg] group-hover:opacity-100 duration-200",style:{color:"var(--widget-foreground)"},viewBox:"0 0 684 684",fill:"none",children:_jsxruntime.jsx.call(void 0, "path",{d:"M0.666687 384.667L519.92 384.667L281.627 622.96L342 683.333L683.333 342L342 0.666687L281.627 61.04L519.92 299.333L0.666687 299.333V384.667Z",fill:"currentColor"})})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center justify-between pr-2",style:{backgroundColor:c?"transparent":"var(--widget-secondary)"},children:[_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col w-full h-full p-2",children:_jsxruntime.jsx.call(void 0, "div",{className:"flex h-8 w-full items-center justify-between px-2",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center space-x-1",children:[_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.P,{asset:u.asset,size:"xs",className:"h-3 w-3"}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-sm h-4",style:{color:"var(--widget-muted-foreground)"},children:u.amount}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs",style:{color:"var(--widget-foreground)"},children:u.symbol})]}),_jsxruntime.jsx.call(void 0, "span",{className:"px-1",style:{color:"var(--widget-muted-foreground)"},children:"\u2192"}),_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.P,{asset:d.asset,size:"xs",className:"h-3 w-3"}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-sm h-4",style:{color:"var(--widget-muted-foreground)"},children:d.amount}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs",style:{color:"var(--widget-foreground)"},children:d.symbol})]})]})})}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col items-end text-right shrink-0",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs mono whitespace-nowrap",style:{color:"var(--widget-muted-foreground)"},children:l.date}),l.time&&_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs mono whitespace-nowrap",style:{color:"var(--widget-muted-foreground)",opacity:.6},children:l.time})]})]})]})};var fe=()=>_jsxruntime.jsxs.call(void 0, "div",{className:"mt-2 flex flex-col",style:{height:"4rem",border:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:"var(--widget-secondary)"},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center space-x-2 p-2",children:[_jsxruntime.jsx.call(void 0, "div",{className:"h-4 w-4 rounded",style:{backgroundColor:"var(--widget-muted)"}}),_jsxruntime.jsx.call(void 0, "div",{className:"h-3 w-24 rounded",style:{backgroundColor:"var(--widget-muted)"}})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-8 w-full items-center justify-between px-4",children:[_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center space-x-1",children:[4,16,10,4,16,10].map((e,s)=>_jsxruntime.jsx.call(void 0, "div",{className:"h-3 rounded",style:{width:`${e*4}px`,backgroundColor:"var(--widget-muted)"}},s))}),_jsxruntime.jsx.call(void 0, "div",{className:"h-3 w-10 rounded",style:{backgroundColor:"var(--widget-muted)"}})]})]}),pe=({isActive:e})=>{let{address:s}=_chunk34N36GUDcjs.a.call(void 0, ),{orders:n,isLoading:c,error:m,hasMore:v,loadMore:f}=ce(s,e),[p,w]=_react.useState.call(void 0, !1),l=_react.useRef.call(void 0, null),u=_react.useCallback.call(void 0, async d=>{let i=d.currentTarget;if(i.scrollTop+i.clientHeight>=i.scrollHeight-100&&!c&&!p&&v){w(!0);try{await f()}finally{w(!1)}}},[c,p,v,f]);return s?m?_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center justify-center p-4",children:_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",style:{color:"var(--widget-destructive)"},children:"Error loading activity"})}):_jsxruntime.jsx.call(void 0, "div",{ref:l,className:"flex flex-col flex-1 min-h-0 overflow-y-auto p-2",onScroll:u,style:{backgroundColor:"transparent"},children:c?Array.from({length:5}).map((d,i)=>_jsxruntime.jsx.call(void 0, fe,{},i)):n.length===0?_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col items-center justify-center h-full p-6",children:_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"No Activity"})}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[n.map(d=>_jsxruntime.jsx.call(void 0, me,{order:d,baseToken:_nullishCoalesce(_optionalChain([d, 'access', _35 => _35.enrichedTokens, 'optionalAccess', _36 => _36.base]), () => (null)),quoteToken:_nullishCoalesce(_optionalChain([d, 'access', _37 => _37.enrichedTokens, 'optionalAccess', _38 => _38.quote]), () => (null))},d.orderHash)),p&&_jsxruntime.jsx.call(void 0, fe,{})]})}):_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center justify-center p-4",children:_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Connect your wallet to view activity"})})};var Ee=()=>_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full h-full overflow-hidden",children:[_jsxruntime.jsx.call(void 0, "div",{className:"p-2 w-full flex justify-center",children:_jsxruntime.jsx.call(void 0, "div",{className:"relative w-full h-[140px] animate-pulse",style:{borderRadius:"var(--widget-radius)",border:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:"var(--widget-secondary)"}})}),_jsxruntime.jsx.call(void 0, "div",{className:"px-2 flex flex-col gap-1.5 mt-1",children:[80,60,72,55,65].map((e,s)=>_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between py-1.5",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, "div",{className:"h-6 w-6 rounded-full animate-pulse shrink-0",style:{backgroundColor:"var(--widget-secondary)"}}),_jsxruntime.jsx.call(void 0, "div",{className:"h-3.5 animate-pulse",style:{width:`${e}px`,backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}})]}),_jsxruntime.jsx.call(void 0, "div",{className:"h-3.5 w-14 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}})]},s))}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-auto shrink-0 p-2",style:{borderTop:"1px var(--widget-border-style) var(--widget-border)"},children:_jsxruntime.jsx.call(void 0, "div",{className:"w-full animate-pulse",style:{height:"34px",backgroundColor:"var(--widget-secondary)",opacity:.35,borderRadius:"var(--widget-radius)"}})})]}),It= exports.WidgetWalletPanel =()=>{let e=_chunkUZWGYG2Scjs.c.call(void 0, L=>L.walletTab),[s,n]=_react.useState.call(void 0, !1),{disconnect:c}=_wagmi.useDisconnect.call(void 0, ),{setQuoteToken:m}=_chunkUZWGYG2Scjs.f.call(void 0, ),v=_react.useCallback.call(void 0, async L=>{await m(L),_chunkUZWGYG2Scjs.c.getState().setView("swap")},[m]),{address:f,groupedAssets:p,totalBalance:w,balancesLoading:l,chains:u,getToken:d,useTokenWithLazyLoad:i,tokenRegistry:h}=oe(!0);return f?l&&e==="wallet"?_jsxruntime.jsx.call(void 0, Ee,{}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full h-full overflow-hidden",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex-1 overflow-y-auto",style:{minHeight:0},children:[e==="wallet"&&_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, ne,{address:f,totalBalance:w,isLoading:l}),_jsxruntime.jsx.call(void 0, de,{groupedAssets:p,chains:u,tokenRegistry:h,getToken:d,useTokenWithLazyLoad:i,onAssetSelect:v})]}),e==="activity"&&_jsxruntime.jsx.call(void 0, pe,{isActive:e==="activity"})]}),_jsxruntime.jsx.call(void 0, "div",{className:"shrink-0 p-2",style:{borderTop:"1px var(--widget-border-style) var(--widget-border)"},children:_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>{c(),_chunkUZWGYG2Scjs.c.getState().setView("swap")},onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),className:"w-full py-2 text-xs mono uppercase cursor-pointer transition-colors",style:{backgroundColor:s?"var(--widget-destructive)":"transparent",color:s?"var(--widget-destructive-foreground)":"var(--widget-destructive)",border:"1px var(--widget-border-style) var(--widget-destructive)",borderRadius:"var(--widget-radius)"},children:"Sign Out"})})]}):_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col items-center justify-center h-full p-4",children:_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Connect your wallet to view your portfolio"})})};exports.WidgetWalletPanel = It;
@@ -1,2 +0,0 @@
1
- "use client";
2
- import{e as g}from"./chunk-XYF2YBR3.js";import{f as y}from"./chunk-726CI6GC.js";import{P as m,X as f,b as w}from"./chunk-EW2OR6CJ.js";import E,{useEffect as $,useState as j}from"react";import{jsx as e,jsxs as t}from"react/jsx-runtime";function x(a){if(a===0)return"0";let o=Math.abs(a);return o>=1e4?a.toFixed(0):o>=1e3?a.toFixed(1):o>=100?a.toFixed(2):o>=1?a.toFixed(4):o>=.01?a.toFixed(6):a.toExponential(3)}var N=E.memo(()=>{let[a,o]=j(!1),{liquidityError:b,routingError:h}=g(),{baseAmount:r,baseToken:s,quoteAmount:l,quoteToken:i}=y(),{quoteLoaderVariant:p,widgetType:F}=w(),u=F==="compact",n=r&&l&&parseFloat(l.toString())?parseFloat(r.toString())/parseFloat(l.toString()):0,v=b||h,c=s&&i&&r&&parseFloat(r.toString())&&l;return $(()=>{p==="expanded"&&c&&o(!0)},[p,c]),p==="none"?null:p==="default"?e("div",{className:`relative box-border flex flex-row pt-1 h-8 w-full items-center${u?" justify-start overflow-x-auto":" justify-center"}`,children:e("div",{className:`flex h-full items-center${u?" min-w-max":" w-full overflow-hidden"}`,style:{color:"var(--widget-foreground)"},children:s&&i?r&&parseFloat(r.toString())?l?t("div",{className:"translate-y-px font-mono flex flex-row items-center gap-2 whitespace-nowrap",children:[t("div",{className:"flex flex-row items-center gap-1",children:[e(m,{asset:i,size:"3xs",noChain:!0,className:"mb-0.5"}),t("span",{className:"text-xs uppercase",children:["1 ",i?.symbol]})]}),e("span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:"="}),t("div",{className:"flex flex-row items-center gap-1",children:[e(m,{asset:s,size:"3xs",noChain:!0,className:"mb-0.5"}),t("span",{className:"text-xs uppercase",children:[x(n)," ",s?.symbol]})]}),e("span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:s?.price?`\u2248 $${(s.price*n).toFixed(2)}`:""})]}):v?t("div",{className:"flex h-full w-full flex-row pb-1 items-center justify-between",children:[e("p",{className:"text-xs",style:{color:"var(--widget-destructive)"},children:"Quote not found"}),e(f,{className:"h-8 w-8",style:{color:"var(--widget-destructive)"}})]}):t("div",{className:"flex h-full w-full flex-row pb-1 items-center justify-between",children:[e("p",{className:"text-xs",style:{color:"var(--widget-accent)"},children:"Searching For Quote"}),e(f,{className:"h-8 w-8",style:{color:"var(--widget-accent)"}})]}):e("div",{className:"text-xs pb-1",style:{color:"var(--widget-foreground)",opacity:.4},children:"Enter Amount"}):e("div",{className:"text-xs pb-1",style:{color:"var(--widget-foreground)",opacity:.4},children:"Enter Amount"})})}):t("div",{className:"flex flex-col w-full",children:[e("div",{className:`relative box-border flex flex-row pt-1 h-8 w-full items-center cursor-pointer${u?" overflow-x-auto":""}`,role:"button",tabIndex:0,onClick:()=>c&&o(d=>!d),onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),c&&o(S=>!S))},children:e("div",{className:`flex h-full items-center${u?" min-w-max overflow-x-auto":" w-full overflow-hidden"}`,style:{color:"var(--widget-foreground)"},children:s&&i?r&&parseFloat(r.toString())?l?t("div",{className:"translate-y-px font-mono flex w-full flex-row items-center justify-between",children:[t("div",{className:"flex flex-row items-center gap-2 whitespace-nowrap",children:[t("div",{className:"flex flex-row items-center gap-1",children:[e(m,{asset:i,size:"3xs",noChain:!0,className:"mb-0.5"}),t("span",{className:"text-xs uppercase",children:["1 ",i?.symbol]})]}),e("span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:"="}),t("div",{className:"flex flex-row items-center gap-1",children:[e(m,{asset:s,size:"3xs",noChain:!0,className:"mb-0.5"}),t("span",{className:"text-xs uppercase",children:[x(n)," ",s?.symbol]})]}),e("span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:s?.price?`\u2248 $${(s.price*n).toFixed(2)}`:""})]}),e("span",{className:"text-xs ml-2 transition-transform duration-200 shrink-0",style:{color:"var(--widget-muted-foreground)",transform:a?"rotate(180deg)":"rotate(0deg)",display:"inline-block"},children:"\u25BE"})]}):v?t("div",{className:"flex h-full w-full flex-row pb-1 items-center justify-between",children:[e("p",{className:"text-xs",style:{color:"var(--widget-destructive)"},children:"Quote not found"}),e(f,{className:"h-8 w-8",style:{color:"var(--widget-destructive)"}})]}):t("div",{className:"flex h-full w-full flex-row pb-1 items-center justify-between",children:[e("p",{className:"text-xs",style:{color:"var(--widget-accent)"},children:"Searching For Quote"}),e(f,{className:"h-8 w-8",style:{color:"var(--widget-accent)"}})]}):e("div",{className:"text-xs pb-1",style:{color:"var(--widget-foreground)",opacity:.4},children:"Enter Amount"}):e("div",{className:"text-xs pb-1",style:{color:"var(--widget-foreground)",opacity:.4},children:"Enter Amount"})})}),e("div",{className:"overflow-hidden transition-all duration-200",style:{maxHeight:a&&c?"80px":"0px",opacity:a&&c?1:0},children:t("div",{className:"flex flex-col gap-0.5 pb-1 font-mono",children:[t("div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[e("span",{children:"USD Value"}),t("span",{children:["$",s?.price&&l?(s.price*n*parseFloat(l.toString())).toFixed(2):"\u2014"]})]}),t("div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[e("span",{children:"Rate"}),e("span",{className:"uppercase",children:n>0?`${x(n)} ${s?.symbol??""}`:"\u2014"})]}),t("div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[e("span",{children:"Order Type"}),e("span",{children:"RFQ (Exact Fill)"})]})]})})]})});N.displayName="QuoteLoader";var R=N;export{R as a};
@@ -1,2 +0,0 @@
1
- "use client";
2
- import{c as p,f as re}from"./chunk-726CI6GC.js";import{F as Z,G as ee,H as te,L as se,O as ae,P as N,_ as ne,b as Y,g as K,k as A,w as x,x as J,z as X}from"./chunk-EW2OR6CJ.js";import{a as oe}from"./chunk-46H44R7V.js";import $,{useCallback as ie,useEffect as ke,useMemo as z}from"react";import{useShallow as Ae}from"zustand/react/shallow";import Ce from"react";import{jsx as I,jsxs as T}from"react/jsx-runtime";var H=Ce.memo(({asset:n,otherAsset:i,handleFormSelection:S,getToken:G})=>{let{token:g}=te(n.chainId,n.address),C=G(n.chainId,n.address),a=g||C||n.assetInfo;if(!a)return null;let f=a.price!=null&&n.decimals!==void 0?x(a,n.balance,n.decimals):null;return T("button",{type:"button",className:"w-full flex items-center justify-between p-3 cursor-pointer",style:{borderBottom:"1px solid var(--widget-border)"},onClick:()=>S(a,i),children:[T("div",{className:"flex items-center space-x-3 min-w-0 flex-1",children:[I(N,{asset:a,size:"md",className:"flex-shrink-0"}),T("div",{className:"flex flex-col items-start min-w-0 flex-1",children:[I("span",{className:"text-base font-medium",style:{color:"var(--widget-foreground)"},children:a.symbol.length>20?`${a.symbol.substring(0,20)}...`:a.symbol}),I("span",{className:"text-sm",style:{color:"var(--widget-foreground)",opacity:.6},children:a.name.length>20?`${a.name.substring(0,20)}...`:a.name})]})]}),T("div",{className:"flex flex-col items-end text-right flex-shrink-0",children:[I("span",{className:"text-xs font-mono",style:{color:"var(--widget-foreground)",opacity:.5},children:"Balance:"}),I("span",{className:"text-xs font-mono",style:{color:"var(--widget-foreground)"},children:f!=null?`$${f.toFixed(2)}`:"\u2014"})]})]},`${a.chainId}-${a.address}`)},(n,i)=>n.asset.address===i.asset.address&&n.asset.chainId===i.asset.chainId&&n.asset.balance===i.asset.balance&&n.asset.assetInfo?.price===i.asset.assetInfo?.price&&n.otherAsset.address===i.otherAsset.address);H.displayName="AssetSelectionBalanceItem";import{jsx as o,jsxs as m}from"react/jsx-runtime";var Ne=({toggle:n,side:i,otherAsset:S,containerHeight:G,onChainHover:g,onMoreChainsClick:C,selectedChainFilter:a})=>{let{address:_}=oe(),{assetSelectionSearch:f,assetSelectionChain:c,assetSelectionCategory:le,recentChainIds:W}=p(Ae(e=>({assetSelectionSearch:e.assetSelectionSearch,assetSelectionChain:e.assetSelectionChain,assetSelectionCategory:e.assetSelectionCategory,recentChainIds:e.recentChainIds}))),L=X(f,300),b=ne(),{supportedInputTokens:de,supportedOutputTokens:ce,supportedInputChains:ue,supportedOutputChains:me,inputSelectionSearch:fe,outputSelectionSearch:pe,showInputSelectionTokenBalances:he,showOutputSelectionTokenBalances:ge}=Y(),we=i==="base"?fe:pe,be=i==="base"?he:ge,{setBaseToken:q,setQuoteToken:V}=re(),y=i==="base"?de:ce,w=i==="base"?ue:me,B=w.length===1,v=z(()=>{if(y.length===0)return null;let e=new Set;for(let t of y)e.add(`${t.chainId}-${t.address.toLowerCase()}`);return e},[y]);ke(()=>{B?p.getState().setAssetSelectionChain(w[0]):a&&p.getState().setAssetSelectionChain(a)},[a,B,w]);let ye=$.useMemo(()=>{let r=w.length>0?new Set(w):null,s=K(b).filter(l=>!r||r.has(l.id)).map(l=>({chainId:l.id,name:l.displayName})),d=new Map(s.map(l=>[l.chainId,l])),u=[],h=new Set,Q=d.get(4326);Q&&(u.push(Q),h.add(4326));for(let l of W){if(u.length>=5)break;if(h.has(l))continue;let U=d.get(l);U&&(u.push(U),h.add(l))}for(let l of s){if(u.length>=5)break;h.has(l.chainId)||u.push(l)}return u},[b,W,w]),{enrichedTokens:M,isLoading:ve}=ee(c==="all"?"all":c),{tokenRegistry:j,getToken:D}=Z(),xe=z(()=>{let e=new Set;for(let t of j)e.add(`${t.chainId}-${t.address.toLowerCase()}`);return e},[j]),E=z(()=>v?M.filter(e=>v.has(`${e.chainId}-${e.address.toLowerCase()}`)):M,[M,v]),R=$.useMemo(()=>{if(!L)return E;let e=L.toLowerCase();return E.filter(t=>(t.symbol||"").toLowerCase().includes(e)||(t.name||"").toLowerCase().includes(e)||t.address.toLowerCase().includes(e))},[E,L]),O=$.useMemo(()=>{let e=c==="all"?(R||[]).filter(s=>b.includes(s.chainId)):R||[],t=new Set;return[...e.filter(s=>{let d=`${s.chainId}-${s.address.toLowerCase()}`;return t.has(d)?!1:(t.add(d),!0)})].sort((s,d)=>{let u=A(s),h=A(d);return u&&!h?-1:!u&&h?1:s.marketCap&&!d.marketCap?-1:!s.marketCap&&d.marketCap?1:!s.marketCap&&!d.marketCap?0:d.marketCap-s.marketCap})},[R,c,b]),{balances:k,isLoading:Ie}=se(_,b,void 0,y.length>0?y:void 0),P=$.useMemo(()=>{if(!k)return[];let e=c==="all"?k:k.filter(r=>r.chainId===c),t=new Set;return e.filter(r=>{let s=`${r.chainId}-${(r.address||"").toLowerCase()}`;return t.has(s)?!1:(t.add(s),!0)})},[k,c]),Se=ie(e=>{let t=e.target.value.toLowerCase(),r=J(t),s=p.getState();r?(s.setAssetSelectionSearch(r),s.setAssetSelectionAddressInput(r)):(s.setAssetSelectionAddressInput(""),s.setAssetSelectionSearch(t))},[]),F=ie(async e=>{i==="base"?await q(e):i==="quote"&&await V(e),n()},[n,i,q,V]);return m("div",{className:"w-full h-full flex flex-col pt-2.5",children:[!B&&m("div",{className:"flex flex-row justify-between py-1 flex-shrink-0 h-10",children:[o("button",{type:"button",className:"flex flex-row items-center w-full h-full px-2.5 whitespace-nowrap font-bold uppercase text-xs cursor-pointer",style:{backgroundColor:c==="all"&&!a?"var(--widget-primary)":"var(--widget-secondary)",color:c==="all"&&!a?"var(--widget-primary-foreground)":"var(--widget-secondary-foreground)",border:"1px solid var(--widget-border)",borderRadius:"var(--widget-radius) 0 0 var(--widget-radius)"},onClick:e=>{e.stopPropagation(),p.getState().setAssetSelectionChain("all")},onMouseEnter:()=>g?.("All Chains"),onMouseLeave:()=>g?.(null),children:"All"}),ye.map((e,t)=>o("button",{type:"button",className:"flex items-center justify-center px-2 w-full cursor-pointer",style:{backgroundColor:c===e.chainId?"var(--widget-primary)":"var(--widget-secondary)",color:c===e.chainId?"var(--widget-primary-foreground)":"var(--widget-secondary-foreground)",borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)",borderLeft:t===0?"none":"1px solid var(--widget-border)",borderRight:"1px solid var(--widget-border)"},onClick:r=>{r.stopPropagation(),p.getState().setAssetSelectionChain(e.chainId)},onMouseEnter:()=>g?.(e.name),onMouseLeave:()=>g?.(null),children:o("div",{className:"mb-px h-4 w-4",children:o(ae,{chain:e.chainId,size:"xs"})})},e.chainId)),C&&o("button",{type:"button",className:"flex flex-row cursor-pointer items-center w-full h-full px-2.5 whitespace-nowrap uppercase font-bold text-xs",style:{backgroundColor:"var(--widget-secondary)",color:"var(--widget-secondary-foreground)",border:"1px solid var(--widget-border)",borderRadius:"0 var(--widget-radius) var(--widget-radius) 0"},onClick:e=>{e.stopPropagation(),C()},children:"More"})]}),we&&o("div",{className:"flex-shrink-0",children:m("div",{className:"relative mt-1",children:[o("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 tokens by name, symbol, or address...",autoComplete:"off",value:f,onChange:Se}),f&&o("button",{type:"button",onClick:()=>p.getState().setAssetSelectionSearch(""),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"})]})}),m("div",{className:"flex-1 min-h-0 overflow-auto mt-2",style:{backgroundColor:"var(--widget-background)"},children:[be&&!Ie&&P.length>0&&!f&&le==="all"&&m("div",{children:[o("p",{className:"my-1 ml-4 text-xs",style:{color:"var(--widget-muted-foreground)"},children:"Your Tokens"}),P.filter(e=>e.assetInfo?v?v.has(`${e.assetInfo.chainId}-${e.assetInfo.address.toLowerCase()}`):A(e.assetInfo)||xe.has(`${e.assetInfo.chainId}-${e.assetInfo.address.toLowerCase()}`):!1).sort((e,t)=>{let r=D(e.chainId,e.address)||e.assetInfo,s=D(t.chainId,t.address)||t.assetInfo,d=r&&e.decimals!==void 0?x(r,e.balance,e.decimals):0;return(s&&t.decimals!==void 0?x(s,t.balance,t.decimals):0)-d}).map(e=>!e.assetInfo||!S?null:o(H,{asset:e,otherAsset:S,handleFormSelection:F,getToken:D},`${e.assetInfo.chainId}-${e.assetInfo.address}`))]}),o("p",{className:"my-2 ml-4 text-xs",style:{color:"var(--widget-muted-foreground)"},children:f?"Search Results":"Supported Tokens"}),ve?o("div",{className:"flex items-center justify-center p-8",children:o("span",{style:{color:"var(--widget-muted-foreground)"},children:"Loading tokens..."})}):O.length===0?o("div",{className:"px-4 py-3 text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Token Not Found"}):O.map(e=>m("div",{role:"button",tabIndex:0,className:"w-full flex items-center justify-between p-3 cursor-pointer",style:{borderBottom:"1px solid var(--widget-border)"},onClick:()=>F(e),onKeyDown:t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),F(e))},children:[m("div",{className:"flex items-center space-x-3 min-w-0 flex-1",children:[o(N,{asset:e,size:"md",className:"flex-shrink-0"}),m("div",{className:"flex flex-col items-start min-w-0 flex-1",children:[o("span",{className:"text-base font-medium truncate",style:{color:"var(--widget-foreground)"},children:(e.symbol||"").length>20?`${e.symbol.substring(0,20)}...`:e.symbol||"\u2014"}),o("span",{className:"text-sm truncate",style:{color:"var(--widget-muted-foreground)"},children:(e.name||"").length>20?`${e.name.substring(0,20)}...`:e.name||"\u2014"})]})]}),m("div",{className:"flex flex-col items-end text-right flex-shrink-0",children:[o("span",{className:"text-xs font-mono",style:{color:"var(--widget-foreground)"},children:e.price?`$${e.price>=999999?`${(e.price/1e6).toFixed(2)}M`:e.price.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:e.price<1?5:2})}`:"\u2014"}),m("span",{className:"text-xs font-mono",style:{color:"var(--widget-muted-foreground)"},children:[e.address?.slice(0,6),"...",e.address?.slice(-4)]})]})]},`${e.chainId}-${e.address}`))]})]})},Ue=Ne;export{Ue as a};
@@ -1,2 +0,0 @@
1
- "use client";
2
- import{D,E as y,M as H,e as g}from"./chunk-EW2OR6CJ.js";import{a as P}from"./chunk-46H44R7V.js";import{create as ee}from"zustand";import{useCallback as q,useEffect as te,useRef as ne}from"react";var x=ee()(n=>({baseToken:null,quoteToken:null,setBaseTokenDirect:e=>n({baseToken:e}),setQuoteTokenDirect:e=>n({quoteToken:e}),swapTokensDirect:()=>n(e=>({baseToken:e.quoteToken,quoteToken:e.baseToken}))}));function O(n){let{data:e,isLoading:c}=D(),o=x(),T=ne(!1),t=n?.defaultBaseToken??null,l=n?.defaultQuoteToken??null;te(()=>{if(!e||e.length===0||T.current)return;T.current=!0;let u=k=>e.find(m=>m.chainId===k.chainId&&m.address.toLowerCase()===k.address.toLowerCase())??null,r=t?u(t):null,p=l?u(l):null;r&&p&&r.chainId===p.chainId&&r.address.toLowerCase()===p.address.toLowerCase()?(o.setBaseTokenDirect(r),o.setQuoteTokenDirect(null)):(o.setBaseTokenDirect(r),o.setQuoteTokenDirect(p))},[e,t,l,o]);let h=q(u=>{if(!u){o.setBaseTokenDirect(null);return}let r=x.getState();r.quoteToken&&u.chainId===r.quoteToken.chainId&&u.address.toLowerCase()===r.quoteToken.address.toLowerCase()?o.swapTokensDirect():o.setBaseTokenDirect(u)},[o]),f=q(u=>{if(!u){o.setQuoteTokenDirect(null);return}let r=x.getState();r.baseToken&&u.chainId===r.baseToken.chainId&&u.address.toLowerCase()===r.baseToken.address.toLowerCase()?o.swapTokensDirect():o.setQuoteTokenDirect(u)},[o]),w=q(()=>{o.swapTokensDirect()},[o]);return{baseToken:o.baseToken,quoteToken:o.quoteToken,setBaseToken:h,setQuoteToken:f,swapTokens:w,isLoading:c}}import{create as se}from"zustand";var W=se()(n=>({view:"swap",isTransitioning:!1,transitionType:"navigation",selectedChainFilter:null,hoveredChainName:null,isRecipientInputOpen:!1,recipient:null,hasAllowanceError:!1,baseAmount:null,quoteAmount:null,isTrackingTx:!1,trackingOrderHash:null,txStatus:"pending",walletTab:"wallet",assetSelectionSearch:"",assetSelectionChain:"all",assetSelectionCategory:"all",assetSelectionAddressInput:"",recentChainIds:[],setView:e=>n({view:e,isTransitioning:!0,...e!=="wallet"&&{walletTab:"wallet"}}),setWalletTab:e=>n({walletTab:e}),setIsTransitioning:e=>n({isTransitioning:e}),transitionToView:(e,c="navigation")=>n({isTransitioning:!0,transitionType:c,view:e,...e!=="wallet"&&{walletTab:"wallet"}}),setChainFilter:e=>n({selectedChainFilter:e}),setHoveredChainName:e=>n({hoveredChainName:e}),toggleRecipientInput:()=>n(e=>({isRecipientInputOpen:!e.isRecipientInputOpen,recipient:e.isRecipientInputOpen?null:e.recipient})),setRecipient:e=>n({recipient:e}),setHasAllowanceError:e=>n({hasAllowanceError:e}),setBaseAmount:e=>n({baseAmount:e}),setQuoteAmount:e=>n({quoteAmount:e}),clearAmounts:()=>n({baseAmount:null,quoteAmount:null}),setIsTrackingTx:e=>n({isTrackingTx:e}),setTrackingOrderHash:e=>n({trackingOrderHash:e}),setTxStatus:e=>n({txStatus:e}),startTracking:e=>n({isTrackingTx:!0,trackingOrderHash:e,txStatus:"pending"}),stopTracking:()=>n({isTrackingTx:!1,trackingOrderHash:null,txStatus:"pending"}),setAssetSelectionSearch:e=>n({assetSelectionSearch:e}),setAssetSelectionChain:e=>n({assetSelectionChain:e}),setAssetSelectionCategory:e=>n({assetSelectionCategory:e}),setAssetSelectionAddressInput:e=>n({assetSelectionAddressInput:e}),pushRecentChain:e=>n(c=>{if(e===4326)return c;let T=c.recentChainIds.filter(t=>t!==e);return{recentChainIds:[e,...T].slice(0,3)}}),resetAssetSelection:()=>n({assetSelectionSearch:"",assetSelectionChain:"all",assetSelectionCategory:"all",assetSelectionAddressInput:""}),resetUI:()=>n({view:"swap",isTransitioning:!1,selectedChainFilter:null,hoveredChainName:null,isRecipientInputOpen:!1,recipient:null,hasAllowanceError:!1,baseAmount:null,quoteAmount:null,isTrackingTx:!1,trackingOrderHash:null,txStatus:"pending",walletTab:"wallet",assetSelectionSearch:"",assetSelectionChain:"all",assetSelectionCategory:"all",assetSelectionAddressInput:""})}));import{useCallback as S,useMemo as d}from"react";import{parseUnits as E}from"viem";import{useShallow as oe}from"zustand/react/shallow";var U=(n,e,c,o)=>{let{address:T}=P(),{baseToken:t,quoteToken:l,setBaseToken:h,setQuoteToken:f,swapTokens:w,isLoading:u}=O({defaultBaseToken:n,defaultQuoteToken:e}),{baseAmount:r,quoteAmount:p,setBaseAmount:k,setQuoteAmount:m,clearAmounts:F}=W(oe(s=>({baseAmount:s.baseAmount,quoteAmount:s.quoteAmount,setBaseAmount:s.setBaseAmount,setQuoteAmount:s.setQuoteAmount,clearAmounts:s.clearAmounts}))),{data:Q}=y(t?.address,t?.chainId),{data:R}=y(l?.address,l?.chainId),a=d(()=>{if(!t)return null;let s=Q?.price??t.price;return s===t.price?t:{...t,price:s}},[t,Q?.price]),i=d(()=>{if(!l)return null;let s=R?.price??l.price;return s===l.price?l:{...l,price:s}},[l,R?.price]),{baseBalance:A,quoteBalance:I,isLoading:L}=H(T,a,i),b=d(()=>!A||A.raw==="0"?null:A,[A]),C=d(()=>!I||I.raw==="0"?null:I,[I]),v=d(()=>{if(!a?.chainId)return!1;let s=g(a.chainId);return a.address.toLowerCase()===s?.gasToken.address?.toLowerCase()},[a]),B=d(()=>{if(!i?.chainId)return!1;let s=g(i.chainId);return i.address.toLowerCase()===s?.gasToken.address?.toLowerCase()},[i]),V=d(()=>{if(!v||!a?.chainId||!i||a.chainId!==i.chainId||a.chainId===988)return!1;let s=g(a.chainId);return i.address.toLowerCase()===s?.wrappedAsset.address?.toLowerCase()},[v,a,i]),G=d(()=>{if(!a?.chainId||!i||!B||a.chainId!==i.chainId||a.chainId===988)return!1;let s=g(a.chainId);return a.address.toLowerCase()===s?.wrappedAsset.address?.toLowerCase()},[a,i,B]),M=d(()=>({raw:b?.raw??"0",formatted:b?.formatted??"0"}),[b]),_=d(()=>({raw:C?.raw??"0",formatted:C?.formatted??"0"}),[C]),z=d(()=>!a||typeof r!="number"||a.decimals===void 0||a.decimals===null?null:E(r.toFixed(a.decimals),a.decimals).toString(),[a,r]),J=d(()=>!i||typeof p!="number"||i.decimals===void 0||i.decimals===null?null:E(p.toFixed(i.decimals),i.decimals).toString(),[i,p]),K=S(async s=>{h(s),m(null),c?.(s)},[h,m,c]),X=S(async s=>{f(s),o?.(s)},[f,o]),Y=S(s=>k(s),[k]),Z=S(s=>m(s),[m]),$=S(()=>{w(),l&&c?.(l),t&&o?.(t)},[w,t,l,c,o]),j=S(()=>F(),[F]);return{baseToken:a,baseAmount:r,quoteToken:i,quoteAmount:p,isBaseGasToken:v,isQuoteGasToken:B,isWrappingPair:V,isUnwrappingPair:G,baseBalance:M,quoteBalance:_,baseAmountRaw:z,quoteAmountRaw:J,isBaseBalanceLoading:L,isQuoteBalanceLoading:L,isRegistryLoading:u,setBaseToken:K,setQuoteToken:X,setBaseAmount:Y,setQuoteAmount:Z,swapTokens:$,clearForm:j}};import{createContext as ae,useContext as ie,useMemo as re}from"react";import{jsx as le}from"react/jsx-runtime";var N=ae(null),ye=({children:n,defaultBaseToken:e,defaultQuoteToken:c,onBaseTokenChange:o,onQuoteTokenChange:T})=>{let t=U(e,c,o,T),l=re(()=>t,[t.baseToken,t.quoteToken,t.baseAmount,t.quoteAmount,t.isBaseGasToken,t.isQuoteGasToken,t.isWrappingPair,t.isUnwrappingPair,t.baseBalance,t.quoteBalance,t.baseAmountRaw,t.quoteAmountRaw,t.isBaseBalanceLoading,t.isQuoteBalanceLoading,t.setBaseToken,t.setQuoteToken,t.setBaseAmount,t.setQuoteAmount,t.swapTokens,t.clearForm,t.isRegistryLoading]);return le(N.Provider,{value:l,children:n})},qe=()=>{let n=ie(N);if(!n)throw new Error("useSwapFormContext must be used within SwapFormProvider");return n};export{x as a,O as b,W as c,U as d,ye as e,qe as f};