@aori/mega-swap-widget 0.1.3 → 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.
- package/README.md +31 -0
- package/dist/AssetSelectionMenu-KOJBN3OR.js +2 -0
- package/dist/AssetSelectionMenu-M7HHUUWM.cjs +2 -0
- package/dist/ChainSelectionMenu-EJANKMWU.cjs +2 -0
- package/dist/ChainSelectionMenu-YCFDREZO.js +2 -0
- package/dist/SwapFormHorizontal-6YSJJM2S.cjs +2 -0
- package/dist/SwapFormHorizontal-E32W3PHA.js +2 -0
- package/dist/SwapFormSplit-6Y2B4VU3.cjs +2 -0
- package/dist/SwapFormSplit-M4YIQNAW.js +2 -0
- package/dist/{WidgetWalletPanel-5H3BVAXR.cjs → WidgetWalletPanel-LKFDBFYR.cjs} +1 -1
- package/dist/{WidgetWalletPanel-43R52FTI.js → WidgetWalletPanel-T5L5224H.js} +1 -1
- package/dist/WidgetWalletTradeHistory-PZLWJ2IK.js +2 -0
- package/dist/WidgetWalletTradeHistory-SDYMU4HL.cjs +2 -0
- package/dist/chunk-3RAZPKY5.js +2 -0
- package/dist/{chunk-3FVOOU2E.cjs → chunk-4CM44UII.cjs} +1 -1
- package/dist/chunk-52HJQZWW.cjs +2 -0
- package/dist/chunk-5WTODHGO.cjs +2 -0
- package/dist/chunk-7QJJOVSV.js +2 -0
- package/dist/chunk-BJYKILHS.cjs +2 -0
- package/dist/{chunk-XLIAXB6G.cjs → chunk-EXGKQSDI.cjs} +1 -1
- package/dist/chunk-GDIG4JLQ.cjs +2 -0
- package/dist/chunk-JVRQLJXZ.js +2 -0
- package/dist/chunk-SBQ3EQ2U.js +2 -0
- package/dist/{chunk-6CVCMRAL.cjs → chunk-SE6JOLEM.cjs} +1 -1
- package/dist/{chunk-6KEQ2NDQ.cjs → chunk-TCAVGM6Y.cjs} +1 -1
- package/dist/{chunk-OIE7DWV7.js → chunk-VI4ISTPB.js} +1 -1
- package/dist/{chunk-PCI6C7N4.js → chunk-ZA7N764R.js} +1 -1
- package/dist/{chunk-IRK2XRZH.js → chunk-ZFVYFTDI.js} +1 -1
- package/dist/chunk-ZKDVXDQF.cjs +2 -0
- package/dist/chunk-ZWGBVGLP.js +2 -0
- package/dist/{chunk-35CBCDGI.js → chunk-ZWNDO5OZ.js} +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.css +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/dist/AssetSelectionMenu-QAYGXIZN.cjs +0 -2
- package/dist/AssetSelectionMenu-XUE3KY7F.js +0 -2
- package/dist/ChainSelectionMenu-73IHIGGD.cjs +0 -2
- package/dist/ChainSelectionMenu-IFRFS3IB.js +0 -2
- package/dist/SwapFormHorizontal-MGK4QJBZ.js +0 -2
- package/dist/SwapFormHorizontal-PNSM7UFE.cjs +0 -2
- package/dist/SwapFormSplit-GLQEEJSQ.js +0 -2
- package/dist/SwapFormSplit-MT5WGEMG.cjs +0 -2
- package/dist/WidgetWalletTradeHistory-CW34HAHS.cjs +0 -2
- package/dist/WidgetWalletTradeHistory-QXIWCKMB.js +0 -2
- package/dist/chunk-2QYGEJLV.js +0 -2
- package/dist/chunk-6JPANU3S.js +0 -2
- package/dist/chunk-7MGPLHPI.cjs +0 -2
- package/dist/chunk-A3P6SA6P.cjs +0 -2
- package/dist/chunk-MNP2YHUY.js +0 -2
- package/dist/chunk-S2KAWPNR.js +0 -2
- package/dist/chunk-X7THKL37.cjs +0 -2
- package/dist/chunk-YQLGWDSC.cjs +0 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{a as Je}from"./chunk-IRK2XRZH.js";import{a as mt,b as vt,c as Pe,d as Ie,e as we,f as Ze,g as fe,h as ne,i as se,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-S2KAWPNR.js";import"./chunk-OPN7WCJR.js";import{a as ht,b as bt,c as n,d as yt,e as Oe,f as ue}from"./chunk-2QYGEJLV.js";import{a as Ue,b as ge}from"./chunk-OIE7DWV7.js";import{D as Te,L as Ge,b as $e,d as je,g as De,j as Qe,l as _e,n as Ke,y as Ye}from"./chunk-35CBCDGI.js";import{a as Q}from"./chunk-46H44R7V.js";import"./chunk-73CB2I7U.js";import ei,{useMemo as gt}from"react";import{Suspense as X,lazy as le,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 de,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 P}from"react/jsx-runtime";var qt=({onSwapComplete:e,onSwapInitiated:i})=>{let{web3ConnectionType:g,hasConnectHandler:a,lockBase:s,lockQuote:h,disableInverting:k,tokenDisplay:W,tokenBadgeOrientation:R,widgetType:w}=ge(),S=W==="pill"||W==="ghost",C=w==="compact",O=C?"px-4 pt-3 pb-1":"px-4 pt-4 pb-2",z=C?"px-4 pt-4 pb-1":"px-4 pt-6 pb-2",{baseToken:r,quoteToken:t,baseAmount:d,quoteAmount:T,isBaseGasToken:ee,isQuoteGasToken:K,isWrappingPair:u,isUnwrappingPair:p,baseBalance:f,quoteBalance:Y,setBaseAmount:N,setQuoteAmount:v,swapTokens:V,clearForm:M}=ue(),{rfqQuote:L,status:G,handleInputChange:q,ensureForParams:y,stop:E,clear:U,refresh:A}=we(),{address:x}=Q(),{openConnectModal:Z}=fe(),{isRecipientInputOpen:B,txStatus:$}=n(Bt(o=>({isRecipientInputOpen:o.isRecipientInputOpen,txStatus:o.txStatus}))),[j,te]=it(null),[D,ie]=it(null),re=Mt(!1),b=!1,J=zt(()=>!r||!t||typeof d!="number"||!T||!x||parseFloat(f.formatted)<d?null:{base:r,quote:t,baseAmount:d,quoteAmount:T,userAddress:x},[r,t,d,T,x,f.formatted]),he=de(o=>{ie(o),n.getState().startTracking(o)},[]),be=de(()=>{re.current=!0,A()},[A]);Ot(()=>{if(j===null&&!(!r||!t)){if(!d||d<=0){q({amount:null,inputToken:r,outputToken:t,setOutputAmount:v});return}if(u||p){v(d);return}q({amount:d,inputToken:r,outputToken:t,setOutputAmount:v})}},[j,d,r,t,u,p,q,v]);let ce=de(()=>{n.getState().setView("baseSelection")},[]),ye=de(()=>{n.getState().setView("quoteSelection")},[]),xe=de(()=>{V(),v(null)},[V,v]),ae=de(()=>{if(!f.formatted||!r||!t)return;let o=parseFloat(f.formatted);if(!o||o<=0)return;let F=o*.9999999999;u||p?(N(F),v(F),U()):(N(F),v(null),y({inputToken:r,outputToken:t,inputAmount:F.toString(),setOutputAmount:oe=>v(oe)}))},[f.formatted,r,t,u,p,N,v,U,y]),Ne=de(()=>{U(),M()},[U,M]),pe=f.formatted?parseFloat(f.formatted):null,ke=!!(d||T),Se=r?.price&&d?`$${(r.price*d).toFixed(2)}`:"$0.00",Ae=t?.price&&T?`$${(t.price*T).toFixed(2)}`:"$0.00",Ce=j==="trackingTx"&&!!D&&!!r&&!!t&&!!d&&!!T;return P("div",{className:"flex flex-col w-full",children:[Ce&&D&&r&&t&&d&&T?l("div",{className:"overflow-hidden",children:l(tt,{orderHash:D,base:r,quote:t,baseAmount:d,quoteAmount:T,status:$})}):P(ze,{children:[P("div",{className:`relative ${O}`,style:{borderBottom:"1px solid var(--widget-border)"},children:[S?C?P("div",{className:`flex items-center gap-2 mb-2 ${R==="right"?"flex-row-reverse":"flex-row"}`,children:[l(se,{toggle:ce,side:"base",asset:r,isPlacingOrder:b||s}),l("div",{className:"flex-1 min-w-0",children:l(ne,{side:"base",asset:r??null,otherAsset:t??null,isPlacingOrder:b,isWrappingPair:u,isUnwrappingPair:p})})]}):P("div",{className:`flex flex-col ${R==="right"?"items-end":"items-start"}`,children:[l(se,{toggle:ce,side:"base",asset:r,isPlacingOrder:b||s}),l(ne,{side:"base",asset:r??null,otherAsset:t??null,isPlacingOrder:b,isWrappingPair:u,isUnwrappingPair:p})]}):P(ze,{children:[l(se,{toggle:ce,side:"base",asset:r,isPlacingOrder:b||s}),l(ne,{side:"base",asset:r??null,otherAsset:t??null,isPlacingOrder:b,isWrappingPair:u,isUnwrappingPair:p})]}),P("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&&pe!==null&&pe>0&&l("button",{type:"button",onClick:ae,disabled:b,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:P("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"})]})}),P("div",{className:`relative ${z}`,children:[S?C?P("div",{className:`flex items-center gap-2 ${R==="right"?"flex-row-reverse":"flex-row"}`,children:[l(se,{toggle:ye,side:"quote",asset:t,isPlacingOrder:b||h}),l("div",{className:"flex-1 min-w-0",children:l(ne,{side:"quote",asset:t??null,otherAsset:r??null,isPlacingOrder:b,isWrappingPair:u,isUnwrappingPair:p})})]}):P("div",{className:`flex flex-col ${R==="right"?"items-end":"items-start"}`,children:[l(se,{toggle:ye,side:"quote",asset:t,isPlacingOrder:b||h}),l(ne,{side:"quote",asset:t??null,otherAsset:r??null,isPlacingOrder:b,isWrappingPair:u,isUnwrappingPair:p})]}):P(ze,{children:[l(se,{toggle:ye,side:"quote",asset:t,isPlacingOrder:b||h}),l(ne,{side:"quote",asset:t??null,otherAsset:r??null,isPlacingOrder:b,isWrappingPair:u,isUnwrappingPair:p})]}),P("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:b,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:B?"1px solid var(--widget-border)":"none",maxHeight:B?"60px":"0px",opacity:B?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&&t&&d&&d>0?l(et,{base:r,baseAmount:d,quote:t,quoteAmount:T??0,userAddress:x,isWrappingPair:u,isUnwrappingPair:p,isBaseGasToken:ee,isQuoteGasToken:K,reviewActionProps:J,reviewState:j,setReviewState:te,trackedOrderHash:D,setTrackedOrderHash:ie,onSwapComplete:e,onSwapInitiated:i,onOrderSubmitted:he,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 I,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:[I("div",{className:"h-12 w-full animate-pulse",style:{backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}}),I("div",{className:"mt-2 h-20 w-2/3 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}}),I("div",{className:"mt-1 mb-1 flex w-full items-center justify-between",children:I("div",{className:"h-4 w-12 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.4,borderRadius:"0.25rem"}})})]}),I("div",{className:"flex justify-center -my-4 relative z-10",children:I("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:[I("div",{className:"h-12 w-full animate-pulse",style:{backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}}),I("div",{className:"mt-2 h-20 w-2/3 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}}),I("div",{className:"mt-1 mb-1 flex w-full items-center justify-between",children:I("div",{className:"h-4 w-12 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.4,borderRadius:"0.25rem"}})})]}),I("div",{className:"px-4",style:{height:"28px",borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"}}),I("div",{className:"relative px-4 py-4",children:I("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 m,jsxs as H}from"react/jsx-runtime";var Ht=({targetText:e,isError:i})=>{let{displayText:g,suffix:a,characterColors:s}=Ye(e,i);return H(Lt,{children:[g.split("").map((h,k)=>m("span",{style:s[k]?{color:"var(--widget-destructive)"}:void 0,children:h},k)),m("span",{style:{color:i?"var(--widget-destructive)":"var(--widget-muted-foreground)",opacity:i?.5:1},children:a})]})},Vt=({headerText:e,onBackClick:i,isSameChain:g,isWrappingPair:a,isUnwrappingPair:s,hasLowLiquidity:h,hasInsufficientLiquidity:k,hasRoutingError:W,hasSizeCapError:R})=>{let w=n(y=>y.view),{isRecipientInputOpen:S,hasAllowanceError:C,hoveredChainName:O,isTrackingTx:z,txStatus:r,walletTab:t}=n(Ft(y=>({isRecipientInputOpen:y.isRecipientInputOpen,hasAllowanceError:y.hasAllowanceError,hoveredChainName:y.hoveredChainName,isTrackingTx:y.isTrackingTx,txStatus:y.txStatus,walletTab:y.walletTab}))),{swapHeaderVariant:d,walletButtonEnabled:T}=ge(),{isConnected:ee}=Q(),[K,u]=ot(!1);Et(()=>u(!0),[]);let[p,f]=ot(!1),Y=`${w}-${p}-${S}-${O||"none"}`,v=(()=>{if(z&&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(O&&(w==="baseSelection"||w==="quoteSelection"||w==="baseChainSelection"||w==="quoteChainSelection"))return O;if(w==="swap"&&p)return S?"Remove Custom Recipient":"Add Custom Recipient";switch(w){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(w==="swap"){if(C&&!a&&!s)return"Allowance check failed";if(R&&!a&&!s)return"Size limit exceeded";if(k&&!a&&!s)return"Insufficient Liquidity";if(W&&!a&&!s)return"Route Not Found";if(h&&!a&&!s)return"High Price Impact"}return g&&!a&&!s?"Swap":a?"Wrap":s?"Unwrap":e}})(),V=!z&&w==="swap"&&!p&&(C&&!a&&!s||R&&!a&&!s||k&&!a&&!s||W&&!a&&!s||h&&!a&&!s),M={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)"},L=()=>!z||!r?null:M[r]??null,G=()=>z?null:w==="swap"?H("div",{className:"flex items-center gap-2",children:[T&&K&&ee&&m("button",{onClick:()=>n.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:H("svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[m("rect",{x:"2",y:"5",width:"20",height:"15",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),m("path",{d:"M16 12C16 11.4477 16.4477 11 17 11H21V13H17C16.4477 13 16 12.5523 16 12Z",fill:"currentColor"}),m("path",{d:"M2 9H22",stroke:"currentColor",strokeWidth:"1.5"})]})}),m("button",{onClick:()=>n.getState().toggleRecipientInput(),onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!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:H("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"}),H("g",{style:{transform:`rotate(${S?"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"})]})]})})]}):H("button",{onClick:()=>i?i():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:[m("span",{className:"pr-1",children:"\u2190"}),m("span",{className:"text-sm",children:"Back"})]}),q=L();return d==="none"?null:H("div",{className:"w-full pt-3 px-2 mono text-base flex flex-row justify-between h-6 shrink-0",children:[w==="wallet"?H("div",{className:"flex items-center gap-1 mono uppercase -translate-y-0.5 text-xs",children:[H("button",{type:"button",onClick:()=>n.getState().setWalletTab("wallet"),className:"cursor-pointer transition-colors",style:{color:t==="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:()=>n.getState().setWalletTab("activity"),className:"cursor-pointer transition-colors",style:{color:t==="activity"?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:"Activity"})]}):H("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(Ht,{targetText:v,isError:V??!1})},Y)]}),m("div",{className:"flex flex-row items-center",children:G()})]})},Be=Vt;import{Fragment as Yt,jsx as c,jsxs as We}from"react/jsx-runtime";var st=le(()=>import("./AssetSelectionMenu-XUE3KY7F.js")),dt=le(()=>import("./ChainSelectionMenu-IFRFS3IB.js")),$t=le(()=>import("./SwapFormHorizontal-MGK4QJBZ.js")),jt=le(()=>import("./SwapFormSplit-GLQEEJSQ.js")),Dt=le(()=>import("./WidgetWalletPanel-43R52FTI.js").then(e=>({default:e.WidgetWalletPanel}))),Qt=le(()=>import("./WalletPlaceholderPanel-Z4JCFCNV.js").then(e=>({default:e.WalletPlaceholderPanel}))),_t=le(()=>import("./WidgetWalletTradeHistory-QXIWCKMB.js").then(e=>({default:e.WidgetWalletTradeHistory}))),Kt=({onSwapComplete:e,cardStyles:i,cardWidth:g})=>{let{baseToken:a,quoteToken:s,baseAmount:h,quoteAmount:k,isWrappingPair:W,isUnwrappingPair:R,isRegistryLoading:w}=ue(),{liquidityError:S,routingError:C,sizeCapError:O,stop:z,clear:r}=we(),t=n(o=>o.view),{isTransitioning:d,isRecipientInputOpen:T,recipient:ee,selectedChainFilterChainId:K}=n(Ut(o=>({isTransitioning:o.isTransitioning,isRecipientInputOpen:o.isRecipientInputOpen,recipient:o.recipient,selectedChainFilterChainId:o.selectedChainFilter?.chainId??null}))),u=qe(null),p=qe(null),[f,Y]=nt(null);Pe(),Re(()=>()=>{u.current&&clearTimeout(u.current),p.current&&clearTimeout(p.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 N=me((o,F="navigation")=>{p.current&&(clearTimeout(p.current),p.current=null,Y(null)),n.getState().view!=="swap"&&o!=="swap"?(n.getState().setView(o),n.getState().setIsTransitioning(!1)):n.getState().transitionToView(o,F)},[]),v=me(()=>{u.current&&(clearTimeout(u.current),u.current=null),p.current&&(clearTimeout(p.current),p.current=null);let o=n.getState().view;Y(o),n.getState().setChainFilter(null),n.getState().setView("swap"),n.getState().setIsTransitioning(!1),n.getState().resetAssetSelection(),p.current=setTimeout(()=>{Y(null),p.current=null},200)},[]),V=me(o=>{let oe=t==="baseChainSelection"?"base":"quote";n.getState().setChainFilter({chainId:o,side:oe}),n.getState().pushRecentChain(o),N(oe==="base"?"baseSelection":"quoteSelection","chainSelection")},[t,N]),M=me(()=>{let o=n.getState().view;o==="baseSelection"?N("baseChainSelection","chainSelection"):o==="quoteSelection"&&N("quoteChainSelection","chainSelection")},[N]),L=me(()=>{z(),r()},[z,r]),G=a&&s?a.chainId===s.chainId:!0,q=()=>{switch(t){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:y,widgetType:E,customWalletUI:U}=ge(),A=t==="baseSelection"||t==="quoteSelection",x=t==="baseChainSelection"||t==="quoteChainSelection",Z=y==="split"&&(E==="default"||E==="compact"),B=y==="split"&&(E==="horizontal"||E==="split"),$=y==="default",j=t==="swap"||A||x||t==="wallet"||t==="activity",te=f==="baseSelection"||f==="quoteSelection",D=f==="baseChainSelection"||f==="quoteChainSelection",ie=A||te,re=x||D,b=A&&!d,J=x&&!d,he=A?t:f,be=he==="baseSelection"?"base":"quote",ce=he==="baseSelection"?s:a,xe=(x?t:f)==="baseChainSelection"?"base":"quote",ae=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=$&&(A||x||t==="wallet"||t==="activity"||f!=null),pe=w?c(at,{}):E==="horizontal"?c(X,{fallback:null,children:c($t,{onSwapComplete:e,onSwapInitiated:L,onBackToSwap:B?v:void 0,onMoreChainsClick:B?M:void 0})}):E==="split"?c(X,{fallback:null,children:c(jt,{onSwapComplete:e,onSwapInitiated:L,onBackToSwap:B?v:void 0,onMoreChainsClick:B?M:void 0})}):c(rt,{onSwapComplete:e,onSwapInitiated:L}),ke=i??{},Se=qe(null),[Ae,Ce]=nt(420);return Re(()=>{if(!Z)return;let o=Se.current;if(!o)return;let F=new ResizeObserver(oe=>{for(let ft of oe)Ce(ft.contentRect.height)});return F.observe(o),()=>F.disconnect()},[Z]),Z?We(Yt,{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:[c(Be,{headerText:"Swap",onBackClick:v,isSameChain:G,isWrappingPair:W,isUnwrappingPair:R,hasLowLiquidity:S,hasInsufficientLiquidity:S,hasRoutingError:C,hasSizeCapError:O}),c("div",{className:"overflow-hidden",children:pe})]}),(ie||re)&&c("div",{className:"flex flex-col overflow-hidden shrink-0",style:{width:g,height:`${Ae}px`,...ke,...ae((A||x)&&!d)},children:A||te?c(X,{fallback:null,children:c(st,{toggle:v,side:be,otherAsset:ce,onMoreChainsClick:M,selectedChainFilter:K})}):c(X,{fallback:null,children:c(dt,{toggle:v,side:xe,onChainSelect:V})})})]}):We("div",{className:"flex flex-col w-full",style:{overflow:"hidden",position:"relative"},children:[c(Be,{headerText:q(),onBackClick:v,isSameChain:G,isWrappingPair:W,isUnwrappingPair:R,hasLowLiquidity:S,hasInsufficientLiquidity:S,hasRoutingError:C,hasSizeCapError:O}),We("div",{className:"relative overflow-hidden",children:[j&&c("div",{className:"overflow-hidden",style:Ne?{pointerEvents:"none"}:void 0,children:pe}),(t==="wallet"||f==="wallet")&&c("div",{className:"absolute inset-0 overflow-hidden",style:ae(t==="wallet"&&!d),children:c(X,{fallback:null,children:U==="none"?c(Qt,{}):c(Dt,{})})}),(t==="activity"||f==="activity")&&c("div",{className:"absolute inset-0 overflow-y-auto",style:ae(t==="activity"&&!d),children:c(X,{fallback:null,children:c(_t,{isActive:t==="activity"})})}),$&&ie&&c("div",{className:"absolute inset-0 overflow-hidden",style:ae(b),children:c(X,{fallback:null,children:c(st,{toggle:v,side:be,otherAsset:ce,onMoreChainsClick:M,selectedChainFilter:K})})}),$&&re&&c("div",{className:"absolute inset-0 overflow-hidden",style:ae(J),children:c(X,{fallback:null,children:c(dt,{toggle:v,side:xe,onChainSelect:V})})})]})]})},lt=({onSwapComplete:e,defaultBaseToken:i,defaultQuoteToken:g,onBaseTokenChange:a,onQuoteTokenChange:s,cardStyles:h,cardWidth:k})=>{let{address:W}=Q(),R=n(w=>w.recipient);return c(Oe,{defaultBaseToken:i,defaultQuoteToken:g,onBaseTokenChange:a,onQuoteTokenChange:s,children:c(Ie,{recipient:R,children:c(Kt,{onSwapComplete:e,cardStyles:h,cardWidth:k})})})};import{createContext as Gt,useContext as Zt}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"},ve={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 i={"--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 i["--widget-font-sans"]=e["font-sans"]||"inherit",i["--widget-font-mono"]=e["font-mono"]||"inherit",i["--widget-shadow-color"]=e["shadow-color"]||"oklch(0 0 0)",i["--widget-shadow-opacity"]=e["shadow-opacity"]||"0.1",i["--widget-shadow-blur"]=e["shadow-blur"]||"3px",i["--widget-shadow-spread"]=e["shadow-spread"]||"0px",i["--widget-shadow-offset-x"]=e["shadow-offset-x"]||"0",i["--widget-shadow-offset-y"]=e["shadow-offset-y"]||"1px",i["--widget-letter-spacing"]=e["letter-spacing"]||"normal",i["--widget-status-pending"]=e["status-pending"]||"#a1a1aa",i["--widget-status-received"]=e["status-received"]||"#fbbf24",i["--widget-status-completed"]=e["status-completed"]||"#2dd4bf",i["--widget-status-failed"]=e["status-failed"]||"#fb7185",i}import{jsx as Xt}from"react/jsx-runtime";var ct=Gt(ve);function He({theme:e,children:i}){return Xt(ct.Provider,{value:e,children:i})}function Jt(){return Zt(ct)}import{jsx as _,jsxs as wt}from"react/jsx-runtime";var ti=[],ii=[],ri=[],pt=[],ai=`
|
|
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-IRK2XRZH.js";import{a as mt,b as vt,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
|
-
`,
|
|
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,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
|
-
"use client";var _chunkYQLGWDSCcjs = require('./chunk-YQLGWDSC.cjs');require('./chunk-X7THKL37.cjs');require('./chunk-6KEQ2NDQ.cjs');require('./chunk-6CVCMRAL.cjs');require('./chunk-34N36GUD.cjs');require('./chunk-T3I3AJXV.cjs');exports.default = _chunkYQLGWDSCcjs.a;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
|
-
"use client";var _chunk3FVOOU2Ecjs = require('./chunk-3FVOOU2E.cjs');require('./chunk-6KEQ2NDQ.cjs');require('./chunk-6CVCMRAL.cjs');require('./chunk-T3I3AJXV.cjs');exports.default = _chunk3FVOOU2Ecjs.a;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use client";import{a as ne}from"./chunk-IRK2XRZH.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-S2KAWPNR.js";import{a as $}from"./chunk-MNP2YHUY.js";import{a as B}from"./chunk-PCI6C7N4.js";import"./chunk-OPN7WCJR.js";import{c as d,f as ie}from"./chunk-2QYGEJLV.js";import{b as ee}from"./chunk-OIE7DWV7.js";import"./chunk-35CBCDGI.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 _chunkXLIAXB6Gcjs = require('./chunk-XLIAXB6G.cjs');var _chunk7MGPLHPIcjs = require('./chunk-7MGPLHPI.cjs');var _chunkYQLGWDSCcjs = require('./chunk-YQLGWDSC.cjs');var _chunk3FVOOU2Ecjs = require('./chunk-3FVOOU2E.cjs');require('./chunk-KH57FLST.cjs');var _chunkX7THKL37cjs = require('./chunk-X7THKL37.cjs');var _chunk6KEQ2NDQcjs = require('./chunk-6KEQ2NDQ.cjs');require('./chunk-6CVCMRAL.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}=_chunk6KEQ2NDQcjs.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}=_chunkX7THKL37cjs.f.call(void 0, ),{rfqQuote:Ue,status:Ve,handleInputChange:F,ensureForParams:j,stop:je,clear:S,refresh:G}=_chunk7MGPLHPIcjs.e.call(void 0, ),{address:m}=_chunk34N36GUDcjs.a.call(void 0, ),{openConnectModal:be}=_chunk7MGPLHPIcjs.g.call(void 0, ),{isRecipientInputOpen:M,txStatus:z,view:v,selectedChainFilterChainId:D}=_chunkX7THKL37cjs.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),_chunkX7THKL37cjs.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, ()=>{_chunkX7THKL37cjs.c.getState().setView("baseSelection")},[]),W=_react.useCallback.call(void 0, ()=>{_chunkX7THKL37cjs.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=_chunkX7THKL37cjs.c.getState().view==="baseChainSelection"?"base":"quote";_chunkX7THKL37cjs.c.getState().setChainFilter({chainId:n,side:A}),_chunkX7THKL37cjs.c.getState().pushRecentChain(n),_chunkX7THKL37cjs.c.getState().transitionToView(A==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),Ne=_react.useCallback.call(void 0, ()=>{_chunkX7THKL37cjs.c.getState().transitionToView("baseChainSelection","chainSelection")},[]),qe=_react.useCallback.call(void 0, ()=>{_chunkX7THKL37cjs.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, _chunk7MGPLHPIcjs.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, _chunk3FVOOU2Ecjs.a,{toggle:_nullishCoalesce(h, () => (P)),side:"base",onChainSelect:X}):_jsxruntime.jsx.call(void 0, _chunkYQLGWDSCcjs.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, _chunk7MGPLHPIcjs.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, _chunk7MGPLHPIcjs.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, _chunk7MGPLHPIcjs.i,{toggle:I,side:"base",asset:t,isPlacingOrder:s||O}),_jsxruntime.jsx.call(void 0, _chunk7MGPLHPIcjs.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, _chunk7MGPLHPIcjs.i,{toggle:I,side:"base",asset:t,isPlacingOrder:s||O}),_jsxruntime.jsx.call(void 0, _chunk7MGPLHPIcjs.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, _chunk3FVOOU2Ecjs.a,{toggle:_nullishCoalesce(h, () => (P)),side:"quote",onChainSelect:X}):_jsxruntime.jsx.call(void 0, _chunkYQLGWDSCcjs.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, _chunk7MGPLHPIcjs.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, _chunk7MGPLHPIcjs.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, _chunk7MGPLHPIcjs.i,{toggle:W,side:"quote",asset:o,isPlacingOrder:s||N}),_jsxruntime.jsx.call(void 0, _chunk7MGPLHPIcjs.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, _chunk7MGPLHPIcjs.i,{toggle:W,side:"quote",asset:o,isPlacingOrder:s||N}),_jsxruntime.jsx.call(void 0, _chunk7MGPLHPIcjs.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, _chunk7MGPLHPIcjs.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, _chunkXLIAXB6Gcjs.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, _chunk7MGPLHPIcjs.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-S2KAWPNR.js";import{a as ce}from"./chunk-MNP2YHUY.js";import{a as ue}from"./chunk-PCI6C7N4.js";import"./chunk-OPN7WCJR.js";import{c as l,f as ie}from"./chunk-2QYGEJLV.js";import{b as te}from"./chunk-OIE7DWV7.js";import{N as U,V as se}from"./chunk-35CBCDGI.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 _chunk7MGPLHPIcjs = require('./chunk-7MGPLHPI.cjs');var _chunkYQLGWDSCcjs = require('./chunk-YQLGWDSC.cjs');var _chunk3FVOOU2Ecjs = require('./chunk-3FVOOU2E.cjs');require('./chunk-KH57FLST.cjs');var _chunkX7THKL37cjs = require('./chunk-X7THKL37.cjs');var _chunk6KEQ2NDQcjs = require('./chunk-6KEQ2NDQ.cjs');var _chunk6CVCMRALcjs = require('./chunk-6CVCMRAL.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}=_chunk6KEQ2NDQcjs.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}=_chunkX7THKL37cjs.f.call(void 0, ),{handleInputChange:F,ensureForParams:G,clear:C,refresh:L,liquidityError:Ne,routingError:Ce}=_chunk7MGPLHPIcjs.e.call(void 0, ),{address:x}=_chunk34N36GUDcjs.a.call(void 0, ),{openConnectModal:ke}=_chunk7MGPLHPIcjs.g.call(void 0, ),{isRecipientInputOpen:I,txStatus:_,view:v,selectedChainFilterChainId:Ae}=_chunkX7THKL37cjs.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),_chunkX7THKL37cjs.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, ()=>{_chunkX7THKL37cjs.c.getState().setView("baseSelection")},[]),$=_react.useCallback.call(void 0, ()=>{_chunkX7THKL37cjs.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=_chunkX7THKL37cjs.c.getState().view==="baseChainSelection"?"base":"quote";_chunkX7THKL37cjs.c.getState().setChainFilter({chainId:i,side:S}),_chunkX7THKL37cjs.c.getState().pushRecentChain(i),_chunkX7THKL37cjs.c.getState().transitionToView(S==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),De=_react.useCallback.call(void 0, ()=>{let i=_chunkX7THKL37cjs.c.getState().view;i==="baseSelection"?_chunkX7THKL37cjs.c.getState().transitionToView("baseChainSelection","chainSelection"):i==="quoteSelection"&&_chunkX7THKL37cjs.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, _chunk7MGPLHPIcjs.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, _chunk7MGPLHPIcjs.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, _chunk7MGPLHPIcjs.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, _chunk7MGPLHPIcjs.i,{toggle:M,side:"base",asset:s,isPlacingOrder:r||O}),_jsxruntime.jsx.call(void 0, _chunk7MGPLHPIcjs.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, _chunk7MGPLHPIcjs.i,{toggle:M,side:"base",asset:s,isPlacingOrder:r||O}),_jsxruntime.jsx.call(void 0, _chunk7MGPLHPIcjs.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, _chunk7MGPLHPIcjs.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, _chunk7MGPLHPIcjs.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, _chunk7MGPLHPIcjs.i,{toggle:$,side:"quote",asset:o,isPlacingOrder:r||T}),_jsxruntime.jsx.call(void 0, _chunk7MGPLHPIcjs.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, _chunk7MGPLHPIcjs.i,{toggle:$,side:"quote",asset:o,isPlacingOrder:r||T}),_jsxruntime.jsx.call(void 0, _chunk7MGPLHPIcjs.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, _chunk7MGPLHPIcjs.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, _chunk7MGPLHPIcjs.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, _chunk3FVOOU2Ecjs.a,{toggle:_nullishCoalesce(H, () => (ge)),side:Q,onChainSelect:Ee}):_jsxruntime.jsx.call(void 0, _chunkYQLGWDSCcjs.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, _chunk6CVCMRALcjs.N,{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, _chunk6CVCMRALcjs.N,{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, _chunk6CVCMRALcjs.V,{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 strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
|
-
"use client";var _chunkA3P6SA6Pcjs = require('./chunk-A3P6SA6P.cjs');require('./chunk-6CVCMRAL.cjs');require('./chunk-34N36GUD.cjs');require('./chunk-T3I3AJXV.cjs');exports.WidgetWalletTradeHistory = _chunkA3P6SA6Pcjs.a;
|
package/dist/chunk-2QYGEJLV.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import{B as D,C as B,K as H,c as g}from"./chunk-35CBCDGI.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}=B(t?.address,t?.chainId),{data:R}=B(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]),y=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||!y||a.chainId!==i.chainId||a.chainId===988)return!1;let s=g(a.chainId);return a.address.toLowerCase()===s?.wrappedAsset.address?.toLowerCase()},[a,i,y]),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:y,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),Be=({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,Be as e,qe as f};
|
package/dist/chunk-6JPANU3S.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import{D as S,N as W,o as H,p as O,z as L}from"./chunk-35CBCDGI.js";import{a as E}from"./chunk-46H44R7V.js";import{useCallback as ee,useRef as te,useState as re}from"react";import{useCallback as M,useEffect as q,useMemo as $,useRef as V,useState as v}from"react";var _="https://api.aori.io",Z=50;function z(e,r){let s=L(e.inputChain),o=L(e.outputChain),d=s?r(s,e.inputToken)??null:null,c=o?r(o,e.outputToken)??null:null;return{orderHash:e.orderHash,quoteId:e.orderHash,status:e.status.toLowerCase(),eventType:e.status.toLowerCase(),inputToken:e.inputToken,inputAmount:e.inputAmount,inputChain:e.inputChain,outputToken:e.outputToken,outputAmount:e.outputAmount,outputChain:e.outputChain,timestamp:e.timestamp,createdAt:e.startTime,srcTx:e.srcTx,dstTx:e.dstTx,explorerUrl:`https://aoriscan.io/order/${e.orderHash}`,enrichedTokens:{base:d,quote:c}}}function P(e,r){let{getToken:s}=S(),[o,d]=v([]),[c,g]=v(!1),[m,f]=v(null),[u,p]=v(1),[n,i]=v(1),[h,I]=v(0),C=V(null),y=M(async(x,R)=>{if(!e)return;C.current?.abort();let N=new AbortController;C.current=N,R||g(!0),f(null);try{let w=new URLSearchParams({offerer:e,limit:String(Z),page:String(x)}),A=await fetch(`${_}/data/query?${w}`,{signal:N.signal});if(!A.ok)throw new Error(`API error: ${A.status}`);let b=await A.json();d(j=>R?[...j,...b.orders]:b.orders),i(b.pagination.totalPages),I(b.pagination.totalRecords),p(x)}catch(w){if(w?.name==="AbortError")return;f(w?.message??"Failed to load order history")}finally{N.signal.aborted||g(!1)}},[e]);q(()=>{if(!r||!e){d([]),p(1),i(1),I(0);return}return y(1,!1),()=>C.current?.abort()},[r,e,y]);let F=M(async()=>{u>=n||c||await y(u+1,!0)},[u,n,c,y]);return{orders:$(()=>o.map(x=>z(x,s)),[o,s]),isLoading:c,error:m,hasMore:u<n,loadMore:F,totalOrders:h}}import{useState as Q}from"react";import{jsx as t,jsxs as l}from"react/jsx-runtime";var G=()=>l("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[t("circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),t("path",{d:"M3 5.2L4.3 6.5L7 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]}),K=()=>l("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[t("circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),t("path",{d:"M3.5 3.5L6.5 6.5M6.5 3.5L3.5 6.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})]}),X=()=>l("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[t("circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),t("path",{d:"M5 3V5.5L6.5 6.5",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round"})]}),U=()=>l("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[t("circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),t("circle",{cx:"5",cy:"5",r:"1.5",fill:"currentColor"})]}),J=e=>{switch((e||"").toLowerCase()){case"completed":case"settled":case"success":case"swapped":case"swap":return{icon:t(G,{}),color:"var(--widget-primary)"};case"received":return{icon:t(U,{}),color:"var(--widget-accent)"};case"failed":case"error":case"expired":return{icon:t(K,{}),color:"var(--widget-destructive)"};case"pending":case"created":case"placed":return{icon:t(X,{}),color:"var(--widget-muted-foreground)"};default:return{icon:t(U,{}),color:"var(--widget-muted-foreground)"}}},Y=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)"}},k=(e,r)=>{try{let s=parseFloat(e||"0");if(isNaN(s)||s===0)return"0";let o=r?.decimals??18;return H(s/10**o)}catch{return"0"}},D=({order:e,baseToken:r,quoteToken:s})=>{let[o,d]=Q(!1),c=e?.status||e?.eventType||"unknown",{icon:g,color:m}=J(c),u=(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||""),p=r?{asset:r,symbol:r.symbol,amount:k(e?.inputAmount,r)}:{asset:null,symbol:(e?.inputToken||"").slice(0,6)+"...",amount:k(e?.inputAmount,null)},n=s?{asset:s,symbol:s.symbol,amount:k(e?.outputAmount,s)}:{asset:null,symbol:(e?.outputToken||"").slice(0,6)+"...",amount:k(e?.outputAmount,null)};return l("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:o?Y(c):"transparent",marginBottom:"0.5rem",padding:"0.25rem"},onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[l("div",{className:"flex flex-row items-center justify-between space-x-1",children:[l("div",{className:"flex flex-row items-center space-x-1",children:[t("div",{className:"-translate-y-px",style:{color:m},children:g}),t("p",{className:"text-2xs mono uppercase",style:{color:m},children:c})]}),l("div",{className:"flex flex-row items-center space-x-2",children:[l("span",{className:"text-2xs mono",style:{color:o?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:["\xAC ",O(e?.quoteId||e?.orderHash||"")]}),t("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:t("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"})})]})]}),l("div",{className:"flex flex-row items-center justify-between pr-2",style:{backgroundColor:o?"transparent":"var(--widget-secondary)"},children:[t("div",{className:"flex flex-col w-full h-full p-2",children:t("div",{className:"flex h-8 w-full items-center justify-between px-2",children:l("div",{className:"flex items-center space-x-1",children:[t(W,{asset:p.asset,size:"xs",className:"h-3 w-3"}),l("div",{className:"flex flex-col",children:[t("span",{className:"text-sm h-4",style:{color:"var(--widget-muted-foreground)"},children:p.amount}),t("span",{className:"text-xs",style:{color:"var(--widget-foreground)"},children:p.symbol})]}),t("span",{className:"px-1",style:{color:"var(--widget-muted-foreground)"},children:"\u2192"}),t(W,{asset:n.asset,size:"xs",className:"h-3 w-3"}),l("div",{className:"flex flex-col",children:[t("span",{className:"text-sm h-4",style:{color:"var(--widget-muted-foreground)"},children:n.amount}),t("span",{className:"text-xs",style:{color:"var(--widget-foreground)"},children:n.symbol})]})]})})}),l("div",{className:"flex flex-col items-end text-right shrink-0",children:[t("span",{className:"text-2xs mono whitespace-nowrap",style:{color:"var(--widget-muted-foreground)"},children:u.date}),u.time&&t("span",{className:"text-2xs mono whitespace-nowrap",style:{color:"var(--widget-muted-foreground)",opacity:.6},children:u.time})]})]})]})};import{Fragment as se,jsx as a,jsxs as T}from"react/jsx-runtime";var B=()=>T("div",{className:"mt-2 flex flex-col",style:{height:"4rem",border:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:"var(--widget-secondary)"},children:[T("div",{className:"flex items-center space-x-2 p-2",children:[a("div",{className:"h-4 w-4 rounded",style:{backgroundColor:"var(--widget-muted)"}}),a("div",{className:"h-3 w-24 rounded",style:{backgroundColor:"var(--widget-muted)"}})]}),T("div",{className:"flex h-8 w-full items-center justify-between px-4",children:[a("div",{className:"flex items-center space-x-1",children:[4,16,10,4,16,10].map((e,r)=>a("div",{className:"h-3 rounded",style:{width:`${e*4}px`,backgroundColor:"var(--widget-muted)"}},r))}),a("div",{className:"h-3 w-10 rounded",style:{backgroundColor:"var(--widget-muted)"}})]})]}),ye=({isActive:e})=>{let{address:r}=E(),{orders:s,isLoading:o,error:d,hasMore:c,loadMore:g}=P(r,e),[m,f]=re(!1),u=te(null),p=ee(async n=>{let i=n.currentTarget;if(i.scrollTop+i.clientHeight>=i.scrollHeight-100&&!o&&!m&&c){f(!0);try{await g()}finally{f(!1)}}},[o,m,c,g]);return r?d?a("div",{className:"flex items-center justify-center p-4",children:a("p",{className:"text-sm",style:{color:"var(--widget-destructive)"},children:"Error loading activity"})}):a("div",{ref:u,className:"flex flex-col flex-1 min-h-0 overflow-y-auto p-2",onScroll:p,style:{backgroundColor:"transparent"},children:o?Array.from({length:5}).map((n,i)=>a(B,{},i)):s.length===0?a("div",{className:"flex flex-col items-center justify-center h-full p-6",children:a("p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"No Activity"})}):T(se,{children:[s.map(n=>a(D,{order:n,baseToken:n.enrichedTokens?.base??null,quoteToken:n.enrichedTokens?.quote??null},n.orderHash)),m&&a(B,{})]})}):a("div",{className:"flex items-center justify-center p-4",children:a("p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Connect your wallet to view activity"})})};export{ye as a};
|