@aori/mega-swap-widget 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AssetSelectionMenu-I53WKAWO.js +2 -0
- package/dist/AssetSelectionMenu-QVUV6BOC.cjs +2 -0
- package/dist/ChainSelectionMenu-O252URI3.cjs +2 -0
- package/dist/ChainSelectionMenu-TXGK72FH.js +2 -0
- package/dist/SwapFormHorizontal-72VZEZWP.js +2 -0
- package/dist/SwapFormHorizontal-MMVDC6GD.cjs +2 -0
- package/dist/SwapFormSplit-PQCNN45E.js +2 -0
- package/dist/SwapFormSplit-WBFUNXIC.cjs +2 -0
- package/dist/{WidgetWalletPanel-LKFDBFYR.cjs → WidgetWalletPanel-7TQ7PGCA.cjs} +1 -1
- package/dist/{WidgetWalletPanel-T5L5224H.js → WidgetWalletPanel-XOJZYWFF.js} +1 -1
- package/dist/WidgetWalletTradeHistory-5BGYCWLA.cjs +2 -0
- package/dist/WidgetWalletTradeHistory-5VQE4WGY.js +2 -0
- package/dist/chunk-3DUTGO4Q.js +2 -0
- package/dist/{chunk-3RAZPKY5.js → chunk-4AIDDZRO.js} +1 -1
- package/dist/{chunk-5WTODHGO.cjs → chunk-6EIIWGVO.cjs} +1 -1
- package/dist/{chunk-ZA7N764R.js → chunk-AV6C4H6H.js} +1 -1
- package/dist/chunk-BF4UK5A7.js +2 -0
- package/dist/chunk-CGCLB56N.cjs +2 -0
- package/dist/{chunk-ZKDVXDQF.cjs → chunk-H3GNDVMT.cjs} +1 -1
- package/dist/{chunk-ZWNDO5OZ.js → chunk-IF7S6ZES.js} +5 -5
- package/dist/{chunk-ZWGBVGLP.js → chunk-IZ7YHC7X.js} +1 -1
- package/dist/{chunk-TCAVGM6Y.cjs → chunk-JCH7AXAB.cjs} +1 -1
- package/dist/chunk-PD3AGQJP.cjs +2 -0
- package/dist/{chunk-SBQ3EQ2U.js → chunk-RF7FQVFX.js} +1 -1
- package/dist/{chunk-VI4ISTPB.js → chunk-TUAHO7RQ.js} +1 -1
- package/dist/{chunk-SE6JOLEM.cjs → chunk-TZYKUGNP.cjs} +4 -4
- package/dist/{chunk-4CM44UII.cjs → chunk-URXRRWEJ.cjs} +1 -1
- package/dist/chunk-VGYWFUHR.cjs +2 -0
- package/dist/{chunk-52HJQZWW.cjs → chunk-WUSQH743.cjs} +1 -1
- package/dist/chunk-WV4DWRNY.js +2 -0
- package/dist/index.cjs +2 -2
- package/dist/index.css +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/dist/AssetSelectionMenu-KOJBN3OR.js +0 -2
- package/dist/AssetSelectionMenu-M7HHUUWM.cjs +0 -2
- package/dist/ChainSelectionMenu-EJANKMWU.cjs +0 -2
- package/dist/ChainSelectionMenu-YCFDREZO.js +0 -2
- package/dist/SwapFormHorizontal-6YSJJM2S.cjs +0 -2
- package/dist/SwapFormHorizontal-E32W3PHA.js +0 -2
- package/dist/SwapFormSplit-6Y2B4VU3.cjs +0 -2
- package/dist/SwapFormSplit-M4YIQNAW.js +0 -2
- package/dist/WidgetWalletTradeHistory-PZLWJ2IK.js +0 -2
- package/dist/WidgetWalletTradeHistory-SDYMU4HL.cjs +0 -2
- package/dist/chunk-7QJJOVSV.js +0 -2
- package/dist/chunk-BJYKILHS.cjs +0 -2
- package/dist/chunk-EXGKQSDI.cjs +0 -2
- package/dist/chunk-GDIG4JLQ.cjs +0 -2
- package/dist/chunk-JVRQLJXZ.js +0 -2
- package/dist/chunk-ZFVYFTDI.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
|
+
"use client";var _chunk6EIIWGVOcjs = require('./chunk-6EIIWGVO.cjs');require('./chunk-H3GNDVMT.cjs');require('./chunk-PD3AGQJP.cjs');require('./chunk-JCH7AXAB.cjs');require('./chunk-TZYKUGNP.cjs');require('./chunk-34N36GUD.cjs');require('./chunk-T3I3AJXV.cjs');exports.default = _chunk6EIIWGVOcjs.a;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
|
+
"use client";var _chunkURXRRWEJcjs = require('./chunk-URXRRWEJ.cjs');require('./chunk-JCH7AXAB.cjs');require('./chunk-TZYKUGNP.cjs');require('./chunk-T3I3AJXV.cjs');exports.default = _chunkURXRRWEJcjs.a;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";import{a as le}from"./chunk-WV4DWRNY.js";import{e as se,g as re,h as f,i as w,j as de,k as ue,w as ce,x as pe}from"./chunk-3DUTGO4Q.js";import{a as Q}from"./chunk-IZ7YHC7X.js";import{a as ae}from"./chunk-RF7FQVFX.js";import{a as H}from"./chunk-AV6C4H6H.js";import"./chunk-OPN7WCJR.js";import{c as d,f as ne}from"./chunk-BF4UK5A7.js";import{b as oe}from"./chunk-TUAHO7RQ.js";import"./chunk-IF7S6ZES.js";import{a as ie}from"./chunk-46H44R7V.js";import"./chunk-73CB2I7U.js";import{useCallback as p,useEffect as Qe,useMemo as He,useRef as Ue,useState as me}from"react";import{useShallow as Ve}from"zustand/react/shallow";import{Fragment as N,jsx as e,jsxs as r}from"react/jsx-runtime";var O=()=>{},De=({onSwapComplete:ge,onSwapInitiated:fe,onBackToSwap:S,onMoreChainsClick:je})=>{let{web3ConnectionType:Ge,hasConnectHandler:we,lockBase:T,lockQuote:q,disableInverting:he,swapButtonVariant:R,tokenDisplay:U,tokenBadgeOrientation:C,widgetType:ve,assetMenuVariant:be}=oe(),{effectiveInputTokens:xe,effectiveOutputTokens:Se}=ae(),h=xe.length===1,v=Se.length===1,V=U==="pill"||U==="ghost",F=ve==="compact",{baseToken:t,quoteToken:o,baseAmount:i,quoteAmount:u,isBaseGasToken:Ce,isQuoteGasToken:ye,isWrappingPair:a,isUnwrappingPair:l,baseBalance:g,quoteBalance:ze,setBaseAmount:I,setQuoteAmount:c,swapTokens:D,clearForm:j}=ne(),{rfqQuote:Ee,status:Le,handleInputChange:M,ensureForParams:G,stop:_e,clear:y,refresh:z}=se(),{address:m}=ie(),{openConnectModal:ke}=re(),{isRecipientInputOpen:W,txStatus:E,view:b,selectedChainFilterChainId:L}=d(Ve(n=>({isRecipientInputOpen:n.isRecipientInputOpen,txStatus:n.txStatus,view:n.view,selectedChainFilterChainId:n.selectedChainFilter?.chainId??null}))),[k,Ae]=me(null),[A,_]=me(null),Pe=Ue(!1),s=!1,Oe=He(()=>!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]),Ne=p(n=>{_(n),d.getState().startTracking(n)},[]),Te=p(()=>{Pe.current=!0,z()},[z]);Qe(()=>{if(k===null&&!(!t||!o)){if(!i||i<=0){M({amount:null,inputToken:t,outputToken:o,setOutputAmount:c});return}if(a||l){c(i);return}M({amount:i,inputToken:t,outputToken:o,setOutputAmount:c})}},[k,i,t,o,a,l,M,c]);let B=p(()=>{d.getState().setView("baseSelection")},[]),$=p(()=>{d.getState().setView("quoteSelection")},[]),qe=p(()=>{D(),c(null)},[D,c]),Re=p(()=>{if(!g.formatted||!t||!o)return;let n=parseFloat(g.formatted);if(!n||n<=0)return;let x=n*.9999999999;a||l?(I(x),c(x),y()):(I(x),c(null),G({inputToken:t,outputToken:o,inputAmount:x.toString(),setOutputAmount:P=>c(P)}))},[g.formatted,t,o,a,l,I,c,y,G]),Fe=p(()=>{y(),j()},[y,j]),J=g.formatted?parseFloat(g.formatted):null,Ie=!!(i||u),K=be==="split",X=K&&(b==="baseSelection"||b==="baseChainSelection"),Y=K&&(b==="quoteSelection"||b==="quoteChainSelection"),Z=p(n=>{let P=d.getState().view==="baseChainSelection"?"base":"quote";d.getState().setChainFilter({chainId:n,side:P}),d.getState().pushRecentChain(n),d.getState().transitionToView(P==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),Me=p(()=>{d.getState().transitionToView("baseChainSelection","chainSelection")},[]),We=p(()=>{d.getState().transitionToView("quoteChainSelection","chainSelection")},[]),Be=t?.price&&i?`$${(t.price*i).toFixed(2)}`:"$0.00",$e=o?.price&&u?`$${(o.price*u).toFixed(2)}`:"$0.00",ee=k==="trackingTx"&&!!A&&!!t&&!!o&&!!i&&!!u,te={backgroundColor:R==="default"?"var(--widget-primary)":"transparent",color:R==="default"?"var(--widget-primary-foreground)":"var(--widget-primary)",border:R!=="default"?"1px solid var(--widget-primary)":"none",borderRadius:"var(--widget-radius)"};return r("div",{className:"flex flex-col w-full",children:[ee&&A&&t&&o&&i&&u?e("div",{className:"flex-1 min-h-0 overflow-hidden",children:e(pe,{orderHash:A,base:t,quote:o,baseAmount:i,quoteAmount:u,status:E})}):r("div",{className:`grid grid-cols-[1fr_auto_1fr] items-stretch px-4 ${F?"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 ${X?"h-[380px]":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)"},children:X?b==="baseChainSelection"?e(H,{toggle:S??O,side:"base",onChainSelect:Z}):e(Q,{toggle:S??O,side:"base",otherAsset:o,onMoreChainsClick:Me,selectedChainFilter:L}):r(N,{children:[V?F?r("div",{className:`flex items-center gap-2 ${C==="right"?"flex-row-reverse":"flex-row"}`,children:[e(w,{toggle:B,side:"base",asset:t,isPlacingOrder:s||T||h,hideDropdown:h}),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 ${C==="right"?"items-end":"items-start"}`,children:[e(w,{toggle:B,side:"base",asset:t,isPlacingOrder:s||T||h,hideDropdown:h}),e(f,{side:"base",asset:t??null,otherAsset:o??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}):r(N,{children:[e(w,{toggle:B,side:"base",asset:t,isPlacingOrder:s||T||h,hideDropdown:h}),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:Be}),m&&J!==null&&J>0&&e("button",{type:"button",onClick:Re,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:he?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:qe,"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(ue,{className:"w-3.5 h-3.5"})})}),e("div",{className:`relative flex flex-col gap-1 p-3 rounded-lg overflow-hidden ${Y?"h-[380px]":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)"},children:Y?b==="quoteChainSelection"?e(H,{toggle:S??O,side:"quote",onChainSelect:Z}):e(Q,{toggle:S??O,side:"quote",otherAsset:t,onMoreChainsClick:We,selectedChainFilter:L}):r(N,{children:[V?F?r("div",{className:`flex items-center gap-2 ${C==="right"?"flex-row-reverse":"flex-row"}`,children:[e(w,{toggle:$,side:"quote",asset:o,isPlacingOrder:s||q||v,hideDropdown:v}),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 ${C==="right"?"items-end":"items-start"}`,children:[e(w,{toggle:$,side:"quote",asset:o,isPlacingOrder:s||q||v,hideDropdown:v}),e(f,{side:"quote",asset:o??null,otherAsset:t??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}):r(N,{children:[e(w,{toggle:$,side:"quote",asset:o,isPlacingOrder:s||q||v,hideDropdown:v}),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:$e}),Ie&&e("button",{type:"button",onClick:Fe,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:W?"1px solid var(--widget-border)":"none",maxHeight:W?"60px":"0px",opacity:W?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:e(de,{})}),e("div",{className:"px-4",style:{borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"},children:e(le,{})}),e("div",{className:`relative ${ee?"px-0":"px-4"} py-4`,children:m&&t&&o&&i&&i>0?e(ce,{base:t,baseAmount:i,quote:o,quoteAmount:u??0,userAddress:m,isWrappingPair:a,isUnwrappingPair:l,isBaseGasToken:Ce,isQuoteGasToken:ye,reviewActionProps:Oe,reviewState:k,setReviewState:Ae,trackedOrderHash:A,setTrackedOrderHash:_,onSwapComplete:ge,onSwapInitiated:fe,onOrderSubmitted:Ne,onStaleQuoteRestart:Te,txStatus:E}):!m&&we?e("button",{onClick:()=>ke(),className:"w-full py-3 text-sm font-medium cursor-pointer transition-opacity hover:opacity-80",style:te,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:te,children:m?"Enter Amount":"Connect Wallet"})})]})},gt=De;export{gt as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
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 _chunkCGCLB56Ncjs = require('./chunk-CGCLB56N.cjs');var _chunkVGYWFUHRcjs = require('./chunk-VGYWFUHR.cjs');var _chunk6EIIWGVOcjs = require('./chunk-6EIIWGVO.cjs');var _chunkH3GNDVMTcjs = require('./chunk-H3GNDVMT.cjs');var _chunkURXRRWEJcjs = require('./chunk-URXRRWEJ.cjs');require('./chunk-KH57FLST.cjs');var _chunkPD3AGQJPcjs = require('./chunk-PD3AGQJP.cjs');var _chunkJCH7AXABcjs = require('./chunk-JCH7AXAB.cjs');require('./chunk-TZYKUGNP.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 O=()=>{},De=({onSwapComplete:ge,onSwapInitiated:fe,onBackToSwap:S,onMoreChainsClick:je})=>{let{web3ConnectionType:Ge,hasConnectHandler:we,lockBase:T,lockQuote:q,disableInverting:he,swapButtonVariant:R,tokenDisplay:U,tokenBadgeOrientation:C,widgetType:ve,assetMenuVariant:be}=_chunkJCH7AXABcjs.b.call(void 0, ),{effectiveInputTokens:xe,effectiveOutputTokens:Se}=_chunkH3GNDVMTcjs.a.call(void 0, ),h=xe.length===1,v=Se.length===1,V=U==="pill"||U==="ghost",F=ve==="compact",{baseToken:t,quoteToken:o,baseAmount:i,quoteAmount:u,isBaseGasToken:Ce,isQuoteGasToken:ye,isWrappingPair:a,isUnwrappingPair:l,baseBalance:g,quoteBalance:ze,setBaseAmount:I,setQuoteAmount:c,swapTokens:D,clearForm:j}=_chunkPD3AGQJPcjs.f.call(void 0, ),{rfqQuote:Ee,status:Le,handleInputChange:M,ensureForParams:G,stop:_e,clear:y,refresh:z}=_chunkVGYWFUHRcjs.e.call(void 0, ),{address:m}=_chunk34N36GUDcjs.a.call(void 0, ),{openConnectModal:ke}=_chunkVGYWFUHRcjs.g.call(void 0, ),{isRecipientInputOpen:W,txStatus:E,view:b,selectedChainFilterChainId:L}=_chunkPD3AGQJPcjs.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))}))),[k,Ae]=_react.useState.call(void 0, null),[A,_]=_react.useState.call(void 0, null),Pe=_react.useRef.call(void 0, !1),s=!1,Oe=_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]),Ne=_react.useCallback.call(void 0, n=>{_(n),_chunkPD3AGQJPcjs.c.getState().startTracking(n)},[]),Te=_react.useCallback.call(void 0, ()=>{Pe.current=!0,z()},[z]);_react.useEffect.call(void 0, ()=>{if(k===null&&!(!t||!o)){if(!i||i<=0){M({amount:null,inputToken:t,outputToken:o,setOutputAmount:c});return}if(a||l){c(i);return}M({amount:i,inputToken:t,outputToken:o,setOutputAmount:c})}},[k,i,t,o,a,l,M,c]);let B=_react.useCallback.call(void 0, ()=>{_chunkPD3AGQJPcjs.c.getState().setView("baseSelection")},[]),$=_react.useCallback.call(void 0, ()=>{_chunkPD3AGQJPcjs.c.getState().setView("quoteSelection")},[]),qe=_react.useCallback.call(void 0, ()=>{D(),c(null)},[D,c]),Re=_react.useCallback.call(void 0, ()=>{if(!g.formatted||!t||!o)return;let n=parseFloat(g.formatted);if(!n||n<=0)return;let x=n*.9999999999;a||l?(I(x),c(x),y()):(I(x),c(null),G({inputToken:t,outputToken:o,inputAmount:x.toString(),setOutputAmount:P=>c(P)}))},[g.formatted,t,o,a,l,I,c,y,G]),Fe=_react.useCallback.call(void 0, ()=>{y(),j()},[y,j]),J=g.formatted?parseFloat(g.formatted):null,Ie=!!(i||u),K=be==="split",X=K&&(b==="baseSelection"||b==="baseChainSelection"),Y=K&&(b==="quoteSelection"||b==="quoteChainSelection"),Z=_react.useCallback.call(void 0, n=>{let P=_chunkPD3AGQJPcjs.c.getState().view==="baseChainSelection"?"base":"quote";_chunkPD3AGQJPcjs.c.getState().setChainFilter({chainId:n,side:P}),_chunkPD3AGQJPcjs.c.getState().pushRecentChain(n),_chunkPD3AGQJPcjs.c.getState().transitionToView(P==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),Me=_react.useCallback.call(void 0, ()=>{_chunkPD3AGQJPcjs.c.getState().transitionToView("baseChainSelection","chainSelection")},[]),We=_react.useCallback.call(void 0, ()=>{_chunkPD3AGQJPcjs.c.getState().transitionToView("quoteChainSelection","chainSelection")},[]),Be=_optionalChain([t, 'optionalAccess', _4 => _4.price])&&i?`$${(t.price*i).toFixed(2)}`:"$0.00",$e=_optionalChain([o, 'optionalAccess', _5 => _5.price])&&u?`$${(o.price*u).toFixed(2)}`:"$0.00",ee=k==="trackingTx"&&!!A&&!!t&&!!o&&!!i&&!!u,te={backgroundColor:R==="default"?"var(--widget-primary)":"transparent",color:R==="default"?"var(--widget-primary-foreground)":"var(--widget-primary)",border:R!=="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:[ee&&A&&t&&o&&i&&u?_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-h-0 overflow-hidden",children:_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.x,{orderHash:A,base:t,quote:o,baseAmount:i,quoteAmount:u,status:E})}):_jsxruntime.jsxs.call(void 0, "div",{className:`grid grid-cols-[1fr_auto_1fr] items-stretch px-4 ${F?"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 ${X?"h-[380px]":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)"},children:X?b==="baseChainSelection"?_jsxruntime.jsx.call(void 0, _chunkURXRRWEJcjs.a,{toggle:_nullishCoalesce(S, () => (O)),side:"base",onChainSelect:Z}):_jsxruntime.jsx.call(void 0, _chunk6EIIWGVOcjs.a,{toggle:_nullishCoalesce(S, () => (O)),side:"base",otherAsset:o,onMoreChainsClick:Me,selectedChainFilter:L}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[V?F?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${C==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.i,{toggle:B,side:"base",asset:t,isPlacingOrder:s||T||h,hideDropdown:h}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.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 ${C==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.i,{toggle:B,side:"base",asset:t,isPlacingOrder:s||T||h,hideDropdown:h}),_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.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, _chunkVGYWFUHRcjs.i,{toggle:B,side:"base",asset:t,isPlacingOrder:s||T||h,hideDropdown:h}),_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.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:Be}),m&&J!==null&&J>0&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Re,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:he?_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:qe,"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, _chunkVGYWFUHRcjs.k,{className:"w-3.5 h-3.5"})})}),_jsxruntime.jsx.call(void 0, "div",{className:`relative flex flex-col gap-1 p-3 rounded-lg overflow-hidden ${Y?"h-[380px]":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)"},children:Y?b==="quoteChainSelection"?_jsxruntime.jsx.call(void 0, _chunkURXRRWEJcjs.a,{toggle:_nullishCoalesce(S, () => (O)),side:"quote",onChainSelect:Z}):_jsxruntime.jsx.call(void 0, _chunk6EIIWGVOcjs.a,{toggle:_nullishCoalesce(S, () => (O)),side:"quote",otherAsset:t,onMoreChainsClick:We,selectedChainFilter:L}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[V?F?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${C==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.i,{toggle:$,side:"quote",asset:o,isPlacingOrder:s||q||v,hideDropdown:v}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.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 ${C==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.i,{toggle:$,side:"quote",asset:o,isPlacingOrder:s||q||v,hideDropdown:v}),_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.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, _chunkVGYWFUHRcjs.i,{toggle:$,side:"quote",asset:o,isPlacingOrder:s||q||v,hideDropdown:v}),_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.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:$e}),Ie&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Fe,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:W?"1px solid var(--widget-border)":"none",maxHeight:W?"60px":"0px",opacity:W?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.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, _chunkCGCLB56Ncjs.a,{})}),_jsxruntime.jsx.call(void 0, "div",{className:`relative ${ee?"px-0":"px-4"} py-4`,children:m&&t&&o&&i&&i>0?_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.w,{base:t,baseAmount:i,quote:o,quoteAmount:_nullishCoalesce(u, () => (0)),userAddress:m,isWrappingPair:a,isUnwrappingPair:l,isBaseGasToken:Ce,isQuoteGasToken:ye,reviewActionProps:Oe,reviewState:k,setReviewState:Ae,trackedOrderHash:A,setTrackedOrderHash:_,onSwapComplete:ge,onSwapInitiated:fe,onOrderSubmitted:Ne,onStaleQuoteRestart:Te,txStatus:E}):!m&&we?_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:te,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:te,children:m?"Enter Amount":"Connect Wallet"})})]})},gt= exports.default =De;exports.default = gt;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";import{e as ne,g as le,h,i as b,j as ce,k as ue,w as pe,x as me}from"./chunk-3DUTGO4Q.js";import{a as ge}from"./chunk-IZ7YHC7X.js";import{a as de}from"./chunk-RF7FQVFX.js";import{a as fe}from"./chunk-AV6C4H6H.js";import"./chunk-OPN7WCJR.js";import{c as l,f as re}from"./chunk-BF4UK5A7.js";import{b as oe}from"./chunk-TUAHO7RQ.js";import{N as V,V as ie}from"./chunk-IF7S6ZES.js";import{a as ae}from"./chunk-46H44R7V.js";import"./chunk-73CB2I7U.js";import{useCallback as f,useEffect as ve,useMemo as Ye,useRef as xe,useState as H}from"react";import{useShallow as Ze}from"zustand/react/shallow";import{Fragment as O,jsx as e,jsxs as t}from"react/jsx-runtime";var we=()=>{},et=({onSwapComplete:he,onSwapInitiated:be,onBackToSwap:E,onMoreChainsClick:tt})=>{let{web3ConnectionType:st,hasConnectHandler:Se,lockBase:q,lockQuote:R,disableInverting:ye,swapButtonVariant:F,tokenDisplay:j,tokenBadgeOrientation:N,widgetType:Ce,assetMenuVariant:Ne}=oe(),{effectiveInputTokens:ke,effectiveOutputTokens:Ae}=de(),S=ke.length===1,y=Ae.length===1,z=j==="pill"||j==="ghost",k=Ce==="compact",{baseToken:d,quoteToken:c,baseAmount:i,quoteAmount:n,isBaseGasToken:Pe,isQuoteGasToken:Te,isWrappingPair:u,isUnwrappingPair:p,baseBalance:w,setBaseAmount:I,setQuoteAmount:g,swapTokens:G,clearForm:L}=re(),{handleInputChange:M,ensureForParams:_,clear:A,refresh:J,liquidityError:Oe,routingError:qe}=ne(),{address:v}=ae(),{openConnectModal:Re}=le(),{isRecipientInputOpen:$,txStatus:K,view:x,selectedChainFilterChainId:Fe}=l(Ze(a=>({isRecipientInputOpen:a.isRecipientInputOpen,txStatus:a.txStatus,view:a.view,selectedChainFilterChainId:a.selectedChainFilterChainId??null}))),[P,Ie]=H(null),[T,X]=H(null),Me=xe(!1),r=!1,$e=Ye(()=>!d||!c||typeof i!="number"||!n||!v||parseFloat(w.formatted)<i?null:{base:d,quote:c,baseAmount:i,quoteAmount:n,userAddress:v},[d,c,i,n,v,w.formatted]),We=f(a=>{X(a),l.getState().startTracking(a)},[]),Be=f(()=>{Me.current=!0,J()},[J]);ve(()=>{if(P===null&&!(!d||!c)){if(!i||i<=0){M({amount:null,inputToken:d,outputToken:c,setOutputAmount:g});return}if(u||p){g(i);return}M({amount:i,inputToken:d,outputToken:c,setOutputAmount:g})}},[P,i,d,c,u,p,M,g]);let Y=i&&n&&parseFloat(n.toString())?parseFloat(i.toString())/parseFloat(n.toString()):0,W=f(()=>{l.getState().setView("baseSelection")},[]),B=f(()=>{l.getState().setView("quoteSelection")},[]),Qe=f(()=>{G(),g(null)},[G,g]),De=f(()=>{if(!w.formatted||!d||!c)return;let a=parseFloat(w.formatted);if(!a||a<=0)return;let m=a*.9999999999;u||p?(I(m),g(m),A()):(I(m),g(null),_({inputToken:d,outputToken:c,inputAmount:m.toString(),setOutputAmount:C=>g(C)}))},[w.formatted,d,c,u,p,I,g,A,_]),Ue=f(()=>{A(),L()},[A,L]),Z=w.formatted?parseFloat(w.formatted):null,Ve=!!(i||n),s=d,o=c,He=s?.price&&i?`$${(s.price*i).toFixed(2)}`:"$0.00",Ee=o?.price&&n?`$${(o.price*n).toFixed(2)}`:"$0.00",je=!!(s&&o&&i&&n),ze=Oe||qe,ee=P==="trackingTx"&&!!T&&!!s&&!!o&&!!i&&!!n,Q=Ne==="split",D=Q&&(x==="baseSelection"||x==="quoteSelection"||x==="baseChainSelection"||x==="quoteChainSelection"),U=x==="baseSelection"||x==="baseChainSelection"?"base":"quote",Ge=U==="base"?o:s,te=xe(null),[Le,_e]=H(380);ve(()=>{if(!Q)return;let a=te.current;if(!a)return;let m=new ResizeObserver(C=>{for(let Xe of C)_e(Xe.contentRect.height)});return m.observe(a),()=>m.disconnect()},[Q]);let Je=f(a=>{let C=l.getState().view==="baseChainSelection"?"base":"quote";l.getState().setChainFilter({chainId:a,side:C}),l.getState().pushRecentChain(a),l.getState().transitionToView(C==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),Ke=f(()=>{let a=l.getState().view;a==="baseSelection"?l.getState().transitionToView("baseChainSelection","chainSelection"):a==="quoteSelection"&&l.getState().transitionToView("quoteChainSelection","chainSelection")},[]),se={backgroundColor:F==="default"?"var(--widget-primary)":"transparent",color:F==="default"?"var(--widget-primary-foreground)":"var(--widget-primary)",border:F!=="default"?"1px solid var(--widget-primary)":"none",borderRadius:"var(--widget-radius)"};return t("div",{className:"flex flex-row w-full",children:[t("div",{ref:te,className:"flex flex-col flex-1 min-w-0",style:{borderRight:"1px solid var(--widget-border)"},children:[ee&&T&&s&&o&&i&&n?e("div",{className:"flex-1 min-h-0 overflow-hidden",children:e(me,{orderHash:T,base:s,quote:o,baseAmount:i,quoteAmount:n,status:K})}):t(O,{children:[t("div",{className:`relative ${k?"px-4 pt-3 pb-1":"px-4 pt-4 pb-2"}`,style:{borderBottom:"1px solid var(--widget-border)"},children:[z?k?t("div",{className:`flex items-center gap-2 ${N==="right"?"flex-row-reverse":"flex-row"}`,children:[e(b,{toggle:W,side:"base",asset:s,isPlacingOrder:r||q||S,hideDropdown:S}),e("div",{className:"flex-1 min-w-0",children:e(h,{side:"base",asset:s??null,otherAsset:o??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})})]}):t("div",{className:`flex flex-col ${N==="right"?"items-end":"items-start"}`,children:[e(b,{toggle:W,side:"base",asset:s,isPlacingOrder:r||q||S,hideDropdown:S}),e(h,{side:"base",asset:s??null,otherAsset:o??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}):t(O,{children:[e(b,{toggle:W,side:"base",asset:s,isPlacingOrder:r||q||S,hideDropdown:S}),e(h,{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:He}),v&&Z!==null&&Z>0&&e("button",{type:"button",onClick:De,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"})]})]}),!ye&&e("div",{className:"flex justify-center -my-4 relative z-10",children:e("button",{type:"button",onClick:Qe,"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(ue,{className:"w-3.5 h-3.5"})})}),t("div",{className:`relative ${k?"px-4 pt-4 pb-1":"px-4 pt-6 pb-2"}`,children:[z?k?t("div",{className:`flex items-center gap-2 ${N==="right"?"flex-row-reverse":"flex-row"}`,children:[e(b,{toggle:B,side:"quote",asset:o,isPlacingOrder:r||R||y,hideDropdown:y}),e("div",{className:"flex-1 min-w-0",children:e(h,{side:"quote",asset:o??null,otherAsset:s??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})})]}):t("div",{className:`flex flex-col ${N==="right"?"items-end":"items-start"}`,children:[e(b,{toggle:B,side:"quote",asset:o,isPlacingOrder:r||R||y,hideDropdown:y}),e(h,{side:"quote",asset:o??null,otherAsset:s??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}):t(O,{children:[e(b,{toggle:B,side:"quote",asset:o,isPlacingOrder:r||R||y,hideDropdown:y}),e(h,{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:Ee}),Ve&&e("button",{type:"button",onClick:Ue,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:$?"1px solid var(--widget-border)":"none",maxHeight:$?"60px":"0px",opacity:$?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:e(ce,{})}),e("div",{className:`relative ${ee?"px-0":"px-4"} py-4`,children:v&&s&&o&&i&&i>0?e(pe,{base:s,baseAmount:i,quote:o,quoteAmount:n??0,userAddress:v,isWrappingPair:u,isUnwrappingPair:p,isBaseGasToken:Pe,isQuoteGasToken:Te,reviewActionProps:$e,reviewState:P,setReviewState:Ie,trackedOrderHash:T,setTrackedOrderHash:X,onSwapComplete:he,onSwapInitiated:be,onOrderSubmitted:We,onStaleQuoteRestart:Be,txStatus:K}):!v&&Se?e("button",{onClick:()=>Re(),className:"w-full py-3 text-sm font-medium cursor-pointer transition-opacity hover:opacity-80",style:se,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:se,children:v?"Enter Amount":"Connect Wallet"})})]}),e("div",{className:`flex flex-col transition-all duration-300 ${D?"flex-1 min-w-0":"w-48 shrink-0"}`,style:{backgroundColor:"var(--widget-background)",...D?{height:`${Le}px`}:{}},children:D?e("div",{className:"flex flex-col overflow-hidden p-2",style:{height:"100%"},children:x==="baseChainSelection"||x==="quoteChainSelection"?e(fe,{toggle:E??we,side:U,onChainSelect:Je}):e(ge,{toggle:E??we,side:U,otherAsset:Ge,onMoreChainsClick:Ke,selectedChainFilter:Fe})}):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"}),je&&s&&o?t(O,{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(V,{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:["= ",Y.toFixed(6)]})}),t("div",{className:"flex items-center gap-1 pl-4",children:[e(V,{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*Y*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"})]})]})]}):ze?t("div",{className:"flex flex-col gap-1",children:[e(ie,{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((a,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"})]})]})})]})},yt=et;export{yt as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
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 _chunkVGYWFUHRcjs = require('./chunk-VGYWFUHR.cjs');var _chunk6EIIWGVOcjs = require('./chunk-6EIIWGVO.cjs');var _chunkH3GNDVMTcjs = require('./chunk-H3GNDVMT.cjs');var _chunkURXRRWEJcjs = require('./chunk-URXRRWEJ.cjs');require('./chunk-KH57FLST.cjs');var _chunkPD3AGQJPcjs = require('./chunk-PD3AGQJP.cjs');var _chunkJCH7AXABcjs = require('./chunk-JCH7AXAB.cjs');var _chunkTZYKUGNPcjs = require('./chunk-TZYKUGNP.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 we=()=>{},et=({onSwapComplete:he,onSwapInitiated:be,onBackToSwap:E,onMoreChainsClick:tt})=>{let{web3ConnectionType:st,hasConnectHandler:Se,lockBase:q,lockQuote:R,disableInverting:ye,swapButtonVariant:F,tokenDisplay:j,tokenBadgeOrientation:N,widgetType:Ce,assetMenuVariant:Ne}=_chunkJCH7AXABcjs.b.call(void 0, ),{effectiveInputTokens:ke,effectiveOutputTokens:Ae}=_chunkH3GNDVMTcjs.a.call(void 0, ),S=ke.length===1,y=Ae.length===1,z=j==="pill"||j==="ghost",k=Ce==="compact",{baseToken:d,quoteToken:c,baseAmount:i,quoteAmount:n,isBaseGasToken:Pe,isQuoteGasToken:Te,isWrappingPair:u,isUnwrappingPair:p,baseBalance:w,setBaseAmount:I,setQuoteAmount:g,swapTokens:G,clearForm:L}=_chunkPD3AGQJPcjs.f.call(void 0, ),{handleInputChange:M,ensureForParams:_,clear:A,refresh:J,liquidityError:Oe,routingError:qe}=_chunkVGYWFUHRcjs.e.call(void 0, ),{address:v}=_chunk34N36GUDcjs.a.call(void 0, ),{openConnectModal:Re}=_chunkVGYWFUHRcjs.g.call(void 0, ),{isRecipientInputOpen:$,txStatus:K,view:x,selectedChainFilterChainId:Fe}=_chunkPD3AGQJPcjs.c.call(void 0, _shallow.useShallow.call(void 0, a=>({isRecipientInputOpen:a.isRecipientInputOpen,txStatus:a.txStatus,view:a.view,selectedChainFilterChainId:_nullishCoalesce(a.selectedChainFilterChainId, () => (null))}))),[P,Ie]=_react.useState.call(void 0, null),[T,X]=_react.useState.call(void 0, null),Me=_react.useRef.call(void 0, !1),r=!1,$e=_react.useMemo.call(void 0, ()=>!d||!c||typeof i!="number"||!n||!v||parseFloat(w.formatted)<i?null:{base:d,quote:c,baseAmount:i,quoteAmount:n,userAddress:v},[d,c,i,n,v,w.formatted]),We=_react.useCallback.call(void 0, a=>{X(a),_chunkPD3AGQJPcjs.c.getState().startTracking(a)},[]),Be=_react.useCallback.call(void 0, ()=>{Me.current=!0,J()},[J]);_react.useEffect.call(void 0, ()=>{if(P===null&&!(!d||!c)){if(!i||i<=0){M({amount:null,inputToken:d,outputToken:c,setOutputAmount:g});return}if(u||p){g(i);return}M({amount:i,inputToken:d,outputToken:c,setOutputAmount:g})}},[P,i,d,c,u,p,M,g]);let Y=i&&n&&parseFloat(n.toString())?parseFloat(i.toString())/parseFloat(n.toString()):0,W=_react.useCallback.call(void 0, ()=>{_chunkPD3AGQJPcjs.c.getState().setView("baseSelection")},[]),B=_react.useCallback.call(void 0, ()=>{_chunkPD3AGQJPcjs.c.getState().setView("quoteSelection")},[]),Qe=_react.useCallback.call(void 0, ()=>{G(),g(null)},[G,g]),De=_react.useCallback.call(void 0, ()=>{if(!w.formatted||!d||!c)return;let a=parseFloat(w.formatted);if(!a||a<=0)return;let m=a*.9999999999;u||p?(I(m),g(m),A()):(I(m),g(null),_({inputToken:d,outputToken:c,inputAmount:m.toString(),setOutputAmount:C=>g(C)}))},[w.formatted,d,c,u,p,I,g,A,_]),Ue=_react.useCallback.call(void 0, ()=>{A(),L()},[A,L]),Z=w.formatted?parseFloat(w.formatted):null,Ve=!!(i||n),s=d,o=c,He=_optionalChain([s, 'optionalAccess', _2 => _2.price])&&i?`$${(s.price*i).toFixed(2)}`:"$0.00",Ee=_optionalChain([o, 'optionalAccess', _3 => _3.price])&&n?`$${(o.price*n).toFixed(2)}`:"$0.00",je=!!(s&&o&&i&&n),ze=Oe||qe,ee=P==="trackingTx"&&!!T&&!!s&&!!o&&!!i&&!!n,Q=Ne==="split",D=Q&&(x==="baseSelection"||x==="quoteSelection"||x==="baseChainSelection"||x==="quoteChainSelection"),U=x==="baseSelection"||x==="baseChainSelection"?"base":"quote",Ge=U==="base"?o:s,te=_react.useRef.call(void 0, null),[Le,_e]=_react.useState.call(void 0, 380);_react.useEffect.call(void 0, ()=>{if(!Q)return;let a=te.current;if(!a)return;let m=new ResizeObserver(C=>{for(let Xe of C)_e(Xe.contentRect.height)});return m.observe(a),()=>m.disconnect()},[Q]);let Je=_react.useCallback.call(void 0, a=>{let C=_chunkPD3AGQJPcjs.c.getState().view==="baseChainSelection"?"base":"quote";_chunkPD3AGQJPcjs.c.getState().setChainFilter({chainId:a,side:C}),_chunkPD3AGQJPcjs.c.getState().pushRecentChain(a),_chunkPD3AGQJPcjs.c.getState().transitionToView(C==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),Ke=_react.useCallback.call(void 0, ()=>{let a=_chunkPD3AGQJPcjs.c.getState().view;a==="baseSelection"?_chunkPD3AGQJPcjs.c.getState().transitionToView("baseChainSelection","chainSelection"):a==="quoteSelection"&&_chunkPD3AGQJPcjs.c.getState().transitionToView("quoteChainSelection","chainSelection")},[]),se={backgroundColor:F==="default"?"var(--widget-primary)":"transparent",color:F==="default"?"var(--widget-primary-foreground)":"var(--widget-primary)",border:F!=="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:te,className:"flex flex-col flex-1 min-w-0",style:{borderRight:"1px solid var(--widget-border)"},children:[ee&&T&&s&&o&&i&&n?_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-h-0 overflow-hidden",children:_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.x,{orderHash:T,base:s,quote:o,baseAmount:i,quoteAmount:n,status:K})}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "div",{className:`relative ${k?"px-4 pt-3 pb-1":"px-4 pt-4 pb-2"}`,style:{borderBottom:"1px solid var(--widget-border)"},children:[z?k?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${N==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.i,{toggle:W,side:"base",asset:s,isPlacingOrder:r||q||S,hideDropdown:S}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.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 ${N==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.i,{toggle:W,side:"base",asset:s,isPlacingOrder:r||q||S,hideDropdown:S}),_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.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, _chunkVGYWFUHRcjs.i,{toggle:W,side:"base",asset:s,isPlacingOrder:r||q||S,hideDropdown:S}),_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.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:He}),v&&Z!==null&&Z>0&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:De,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"})]})]}),!ye&&_jsxruntime.jsx.call(void 0, "div",{className:"flex justify-center -my-4 relative z-10",children:_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Qe,"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, _chunkVGYWFUHRcjs.k,{className:"w-3.5 h-3.5"})})}),_jsxruntime.jsxs.call(void 0, "div",{className:`relative ${k?"px-4 pt-4 pb-1":"px-4 pt-6 pb-2"}`,children:[z?k?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${N==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.i,{toggle:B,side:"quote",asset:o,isPlacingOrder:r||R||y,hideDropdown:y}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.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 ${N==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.i,{toggle:B,side:"quote",asset:o,isPlacingOrder:r||R||y,hideDropdown:y}),_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.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, _chunkVGYWFUHRcjs.i,{toggle:B,side:"quote",asset:o,isPlacingOrder:r||R||y,hideDropdown:y}),_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.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:Ee}),Ve&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Ue,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:$?"1px solid var(--widget-border)":"none",maxHeight:$?"60px":"0px",opacity:$?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.j,{})}),_jsxruntime.jsx.call(void 0, "div",{className:`relative ${ee?"px-0":"px-4"} py-4`,children:v&&s&&o&&i&&i>0?_jsxruntime.jsx.call(void 0, _chunkVGYWFUHRcjs.w,{base:s,baseAmount:i,quote:o,quoteAmount:_nullishCoalesce(n, () => (0)),userAddress:v,isWrappingPair:u,isUnwrappingPair:p,isBaseGasToken:Pe,isQuoteGasToken:Te,reviewActionProps:$e,reviewState:P,setReviewState:Ie,trackedOrderHash:T,setTrackedOrderHash:X,onSwapComplete:he,onSwapInitiated:be,onOrderSubmitted:We,onStaleQuoteRestart:Be,txStatus:K}):!v&&Se?_jsxruntime.jsx.call(void 0, "button",{onClick:()=>Re(),className:"w-full py-3 text-sm font-medium cursor-pointer transition-opacity hover:opacity-80",style:se,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:se,children:v?"Enter Amount":"Connect Wallet"})})]}),_jsxruntime.jsx.call(void 0, "div",{className:`flex flex-col transition-all duration-300 ${D?"flex-1 min-w-0":"w-48 shrink-0"}`,style:{backgroundColor:"var(--widget-background)",...D?{height:`${Le}px`}:{}},children:D?_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col overflow-hidden p-2",style:{height:"100%"},children:x==="baseChainSelection"||x==="quoteChainSelection"?_jsxruntime.jsx.call(void 0, _chunkURXRRWEJcjs.a,{toggle:_nullishCoalesce(E, () => (we)),side:U,onChainSelect:Je}):_jsxruntime.jsx.call(void 0, _chunk6EIIWGVOcjs.a,{toggle:_nullishCoalesce(E, () => (we)),side:U,otherAsset:Ge,onMoreChainsClick:Ke,selectedChainFilter:Fe})}):_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"}),je&&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, _chunkTZYKUGNPcjs.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:["= ",Y.toFixed(6)]})}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-1 pl-4",children:[_jsxruntime.jsx.call(void 0, _chunkTZYKUGNPcjs.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*Y*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"})]})]})]}):ze?_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, _chunkTZYKUGNPcjs.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((a,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"})]})]})})]})},yt= exports.default =et;exports.default = yt;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
|
|
2
|
-
"use client";var _chunkKH57FLSTcjs = require('./chunk-KH57FLST.cjs');var _chunkBJYKILHScjs = require('./chunk-BJYKILHS.cjs');var _chunkTCAVGM6Ycjs = require('./chunk-TCAVGM6Y.cjs');var _chunk52HJQZWWcjs = require('./chunk-52HJQZWW.cjs');var _chunkSE6JOLEMcjs = require('./chunk-SE6JOLEM.cjs');var _chunk34N36GUDcjs = require('./chunk-34N36GUD.cjs');var _chunkT3I3AJXVcjs = require('./chunk-T3I3AJXV.cjs');var _react = require('react');var _wagmi = require('wagmi');function Y(s){let{address:n,isConnected:c}=_chunk34N36GUDcjs.a.call(void 0, ),{chainDataMap:y}=_chunkSE6JOLEMcjs.G.call(void 0, ),i=_chunkTCAVGM6Ycjs.c.call(void 0, ),{getToken:W,tokenRegistry:f}=_chunkSE6JOLEMcjs.D.call(void 0, ),{supportedInputTokens:x,supportedOutputTokens:w}=_chunkTCAVGM6Ycjs.b.call(void 0, ),a=_react.useMemo.call(void 0, ()=>{if(!x.length&&!w.length)return[];let e=new Set,r=[];for(let d of[...x,...w]){let T=`${d.chainId}-${d.address.toLowerCase()}`;e.has(T)||(e.add(T),r.push(d))}return r},[x,w]),{balances:l,isLoading:k,isError:g,refetch:h}=_chunkSE6JOLEMcjs.J.call(void 0, n,i,{enabled:c&&s&&!!n,refetchOnWindowFocus:!1},a.length>0?a:void 0),N=_react.useMemo.call(void 0, ()=>a.length?new Set(a.map(e=>`${e.chainId}-${e.address.toLowerCase()}`)):null,[a]),t=_react.useMemo.call(void 0, ()=>!l||l.length===0?{}:l.filter(r=>!r.assetInfo||!r.balance||r.balance==="0"?!1:N?N.has(`${r.chainId}-${r.address.toLowerCase()}`):_chunkSE6JOLEMcjs.i.call(void 0, r.assetInfo)||f.length===0?!0:f.some(d=>d.address.toLowerCase()===r.address.toLowerCase()&&d.chainId===r.chainId)).reduce((r,d)=>{let T=String(d.chainId);return r[T]||(r[T]=[]),r[T].push({token:d.address,amount:d.balance,decimals:d.decimals,assetInfo:d.assetInfo}),r},{}),[l,f,N]),u=_react.useMemo.call(void 0, ()=>!l||l.length===0?0:l.reduce((e,r)=>!r.assetInfo||r.decimals===void 0?e:e+parseFloat(r.balance)/10**r.decimals*(r.assetInfo.price||0),0),[l]),b=_react.useMemo.call(void 0, ()=>i.length===0?{}:i.reduce((e,r)=>{let d=y[r],T=_chunkSE6JOLEMcjs.c.call(void 0, r);return e[r.toString()]={chainId:r,name:_optionalChain([T, 'optionalAccess', _2 => _2.displayName])||_optionalChain([d, 'optionalAccess', _3 => _3.chainKey])||`Chain ${r}`},e},{}),[i,y]),v=_react.useMemo.call(void 0, ()=>f.map(e=>({address:e.address,chainId:e.chainId})),[f]),m=_react.useRef.call(void 0, null);_react.useEffect.call(void 0, ()=>()=>{m.current&&clearTimeout(m.current)},[]);let I=_react.useCallback.call(void 0, ()=>{m.current&&clearTimeout(m.current),m.current=setTimeout(()=>h(),2e3)},[h]);return{address:n,isConnected:c,groupedAssets:t,totalBalance:u,balancesLoading:k,balancesError:g,chains:b,getToken:W,useTokenWithLazyLoad:_chunkSE6JOLEMcjs.F,tokenRegistry:v,refetchBalances:I}}var Z=_chunkT3I3AJXVcjs.b.call(void 0, _chunkKH57FLSTcjs.a.call(void 0, ),1);var _jsxruntime = require('react/jsx-runtime');var ee=({address:s,totalBalance:n,isLoading:c=!1})=>{let y=i=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(i);return _jsxruntime.jsx.call(void 0, "div",{className:"p-2 w-full flex justify-center",children:_jsxruntime.jsxs.call(void 0, "div",{className:"relative w-full h-[140px] overflow-hidden",style:{borderRadius:"var(--widget-radius)",border:"1px var(--widget-border-style) var(--widget-border)"},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"absolute inset-0 z-0",children:[_jsxruntime.jsx.call(void 0, "img",{className:"w-full h-full object-cover opacity-60",src:(0,Z.makeGradient)(s),alt:"address gradient"}),_jsxruntime.jsx.call(void 0, "div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"relative z-10 flex h-full flex-col justify-between p-3",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-2xs uppercase mono",style:{color:"var(--widget-muted-foreground)",opacity:.7},children:"Token Balance:"}),c?_jsxruntime.jsx.call(void 0, _chunkSE6JOLEMcjs.Q,{className:"h-8 w-28 bg-white/10 rounded mt-1"}):_jsxruntime.jsx.call(void 0, "p",{className:"text-2xl font-bold mt-0.5",style:{color:"var(--widget-foreground)"},children:y(n)})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center",children:_jsxruntime.jsx.call(void 0, _chunkSE6JOLEMcjs.P,{text:s,type:"address",children:_jsxruntime.jsx.call(void 0, "p",{className:"mono text-2xs",style:{color:"var(--widget-foreground)",opacity:.7},children:s})})})]})]})})};var te=({asset:s,balanceAmount:n,balanceDecimals:c,price:y,onSelect:i,getToken:W,useTokenWithLazyLoad:f})=>{let[x,w]=_react.useState.call(void 0, !1),a=c!==void 0?parseFloat(n)/10**c:0,k=_optionalChain([f, 'optionalCall', _4 => _4(s.chainId,s.address), 'optionalAccess', _5 => _5.token]),g=_nullishCoalesce(y, () => (null));return _chunkSE6JOLEMcjs.i.call(void 0, s)&&g==null&&(_optionalChain([k, 'optionalAccess', _6 => _6.price])!=null?g=k.price:W&&(g=_nullishCoalesce(_optionalChain([W, 'call', _7 => _7(s.chainId,s.address), 'optionalAccess', _8 => _8.price]), () => (null)))),_jsxruntime.jsx.call(void 0, "div",{role:"button",tabIndex:0,className:"flex h-[52px] w-full flex-row items-center p-3 cursor-pointer transition-colors",style:{borderBottom:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:x?"var(--widget-secondary)":"transparent"},onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1),onClick:()=>_optionalChain([i, 'optionalCall', _9 => _9(s)]),onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),_optionalChain([i, 'optionalCall', _10 => _10(s)]))},children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full w-full flex-row items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full flex-row items-center gap-2",children:[_jsxruntime.jsx.call(void 0, _chunkSE6JOLEMcjs.N,{asset:s,size:"sm"}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col items-start",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-medium uppercase",style:{color:"var(--widget-foreground)"},children:s.symbol}),a>0&&_jsxruntime.jsx.call(void 0, "p",{className:"mono text-xs",style:{color:"var(--widget-muted-foreground)"},children:a.toFixed(4)})]})]}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-medium",style:{color:"var(--widget-foreground)"},children:g!=null?`$${(g*a).toFixed(2)}`:"\u2014"})]})})};var ce=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}),me=_chunkSE6JOLEMcjs.f.call(void 0, ),se=({groupedAssets:s,chains:n,tokenRegistry:c=[],getToken:y,useTokenWithLazyLoad:i,onAssetSelect:W})=>{let[f,x]=_react.useState.call(void 0, new Set),w=_react.useCallback.call(void 0, t=>_optionalChain([n, 'optionalAccess', _11 => _11[t], 'optionalAccess', _12 => _12.name])||me[t]||`Chain ${t}`,[n]),a=_react.useMemo.call(void 0, ()=>{let t=new Set;for(let u of c)t.add(`${u.chainId}-${u.address.toLowerCase()}`);return t},[c]),l=_react.useCallback.call(void 0, t=>t.decimals===void 0||!_optionalChain([t, 'access', _13 => _13.assetInfo, 'optionalAccess', _14 => _14.price])?0:parseFloat(t.amount)/10**t.decimals*t.assetInfo.price,[]),{filteredGroupedAssets:k,chainTotals:g}=_react.useMemo.call(void 0, ()=>{let t=Object.entries(s).map(([v,m])=>{let I=m.filter(e=>e.assetInfo?_chunkSE6JOLEMcjs.i.call(void 0, e.assetInfo)?!0:a.size>0?a.has(`${e.assetInfo.chainId}-${_nullishCoalesce(_optionalChain([e, 'access', _15 => _15.assetInfo, 'access', _16 => _16.address, 'optionalAccess', _17 => _17.toLowerCase, 'call', _18 => _18()]), () => (""))}`):!0:!1);return[v,I]}).filter(([,v])=>v.length>0),u={};for(let[v,m]of t)u[v]=m.reduce((I,e)=>I+l(e),0);return{filteredGroupedAssets:[...t].sort((v,m)=>(_nullishCoalesce(u[m[0]], () => (0)))-(_nullishCoalesce(u[v[0]], () => (0)))),chainTotals:u}},[s,a,l]),h=_react.useCallback.call(void 0, t=>{x(u=>{let b=new Set(u);return b.has(t)?b.delete(t):b.add(t),b})},[]),N=t=>ce.format(t);return k.length===0?_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center justify-center p-6",children:_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"No token balances found"})}):_jsxruntime.jsx.call(void 0, "div",{className:"pb-2 pt-1",children:k.map(([t,u])=>{let b=parseInt(t),v=w(b),m=g[t]||0,I=f.has(t);return _jsxruntime.jsxs.call(void 0, "div",{className:"mx-2 mb-2",style:{border:"1px var(--widget-border-style) var(--widget-border)",borderRadius:"var(--widget-radius)",overflow:"hidden"},children:[_jsxruntime.jsxs.call(void 0, "button",{type:"button",onClick:()=>h(t),className:"flex w-full flex-row items-center justify-between p-2 cursor-pointer transition-colors hover:bg-(--widget-secondary)",style:{backgroundColor:"transparent"},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"inline-flex flex-row items-center gap-2",children:[_jsxruntime.jsx.call(void 0, _chunkSE6JOLEMcjs.M,{chain:b,size:"sm"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-medium capitalize",style:{color:"var(--widget-foreground)"},children:v})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-semibold",style:{color:"var(--widget-foreground)"},children:N(m)}),_jsxruntime.jsx.call(void 0, "span",{className:`transition-transform duration-200 ${I?"rotate-180":""}`,style:{color:"var(--widget-muted-foreground)"},children:_jsxruntime.jsx.call(void 0, "svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:_jsxruntime.jsx.call(void 0, "path",{d:"M2.5 4.5L6 8L9.5 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:`overflow-hidden transition-all duration-200 ease-out ${I?"max-h-[2000px] opacity-100":"max-h-0 opacity-0"}`,children:_jsxruntime.jsx.call(void 0, "div",{style:{borderTop:"1px var(--widget-border-style) var(--widget-border)"},children:u.map(e=>e.assetInfo?_jsxruntime.jsx.call(void 0, te,{asset:e.assetInfo,balanceAmount:e.amount,balanceDecimals:e.decimals,price:_nullishCoalesce(_optionalChain([e, 'access', _19 => _19.assetInfo, 'optionalAccess', _20 => _20.price]), () => (null)),onSelect:W,getToken:y,useTokenWithLazyLoad:i},`${e.assetInfo.chainId}-${e.token}`):null)})})]},t)})})};var ve=()=>_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full h-full overflow-hidden",children:[_jsxruntime.jsx.call(void 0, "div",{className:"p-2 w-full flex justify-center",children:_jsxruntime.jsx.call(void 0, "div",{className:"relative w-full h-[140px] animate-pulse",style:{borderRadius:"var(--widget-radius)",border:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:"var(--widget-secondary)"}})}),_jsxruntime.jsx.call(void 0, "div",{className:"px-2 flex flex-col gap-1.5 mt-1",children:[80,60,72,55,65].map((s,n)=>_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between py-1.5",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, "div",{className:"h-6 w-6 rounded-full animate-pulse shrink-0",style:{backgroundColor:"var(--widget-secondary)"}}),_jsxruntime.jsx.call(void 0, "div",{className:"h-3.5 animate-pulse",style:{width:`${s}px`,backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}})]}),_jsxruntime.jsx.call(void 0, "div",{className:"h-3.5 w-14 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}})]},n))}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-auto shrink-0 p-2",style:{borderTop:"1px var(--widget-border-style) var(--widget-border)"},children:_jsxruntime.jsx.call(void 0, "div",{className:"w-full animate-pulse",style:{height:"34px",backgroundColor:"var(--widget-secondary)",opacity:.35,borderRadius:"var(--widget-radius)"}})})]}),_e= exports.WidgetWalletPanel =()=>{let s=_chunkBJYKILHScjs.c.call(void 0, N=>N.walletTab),[n,c]=_react.useState.call(void 0, !1),{disconnect:y}=_wagmi.useDisconnect.call(void 0, ),{setQuoteToken:i}=_chunkBJYKILHScjs.f.call(void 0, ),W=_react.useCallback.call(void 0, async N=>{await i(N),_chunkBJYKILHScjs.c.getState().setView("swap")},[i]),{address:f,groupedAssets:x,totalBalance:w,balancesLoading:a,chains:l,getToken:k,useTokenWithLazyLoad:g,tokenRegistry:h}=Y(!0);return f?a&&s==="wallet"?_jsxruntime.jsx.call(void 0, ve,{}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full h-full overflow-hidden",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex-1 overflow-y-auto",style:{minHeight:0},children:[s==="wallet"&&_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, ee,{address:f,totalBalance:w,isLoading:a}),_jsxruntime.jsx.call(void 0, se,{groupedAssets:x,chains:l,tokenRegistry:h,getToken:k,useTokenWithLazyLoad:g,onAssetSelect:W})]}),s==="activity"&&_jsxruntime.jsx.call(void 0, _chunk52HJQZWWcjs.a,{isActive:s==="activity"})]}),_jsxruntime.jsx.call(void 0, "div",{className:"shrink-0 p-2",style:{borderTop:"1px var(--widget-border-style) var(--widget-border)"},children:_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>{y(),_chunkBJYKILHScjs.c.getState().setView("swap")},onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),className:"w-full py-2 text-xs mono uppercase cursor-pointer transition-colors",style:{backgroundColor:n?"var(--widget-destructive)":"transparent",color:n?"var(--widget-destructive-foreground)":"var(--widget-destructive)",border:"1px var(--widget-border-style) var(--widget-destructive)",borderRadius:"var(--widget-radius)"},children:"Sign Out"})})]}):_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col items-center justify-center h-full p-4",children:_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Connect your wallet to view your portfolio"})})};exports.WidgetWalletPanel = _e;
|
|
2
|
+
"use client";var _chunkKH57FLSTcjs = require('./chunk-KH57FLST.cjs');var _chunkPD3AGQJPcjs = require('./chunk-PD3AGQJP.cjs');var _chunkJCH7AXABcjs = require('./chunk-JCH7AXAB.cjs');var _chunkWUSQH743cjs = require('./chunk-WUSQH743.cjs');var _chunkTZYKUGNPcjs = require('./chunk-TZYKUGNP.cjs');var _chunk34N36GUDcjs = require('./chunk-34N36GUD.cjs');var _chunkT3I3AJXVcjs = require('./chunk-T3I3AJXV.cjs');var _react = require('react');var _wagmi = require('wagmi');function Y(s){let{address:n,isConnected:c}=_chunk34N36GUDcjs.a.call(void 0, ),{chainDataMap:y}=_chunkTZYKUGNPcjs.G.call(void 0, ),i=_chunkJCH7AXABcjs.c.call(void 0, ),{getToken:W,tokenRegistry:f}=_chunkTZYKUGNPcjs.B.call(void 0, ),{supportedInputTokens:x,supportedOutputTokens:w}=_chunkJCH7AXABcjs.b.call(void 0, ),a=_react.useMemo.call(void 0, ()=>{if(!x.length&&!w.length)return[];let e=new Set,r=[];for(let d of[...x,...w]){let T=`${d.chainId}-${d.address.toLowerCase()}`;e.has(T)||(e.add(T),r.push(d))}return r},[x,w]),{balances:l,isLoading:k,isError:g,refetch:h}=_chunkTZYKUGNPcjs.J.call(void 0, n,i,{enabled:c&&s&&!!n,refetchOnWindowFocus:!1},a.length>0?a:void 0),N=_react.useMemo.call(void 0, ()=>a.length?new Set(a.map(e=>`${e.chainId}-${e.address.toLowerCase()}`)):null,[a]),t=_react.useMemo.call(void 0, ()=>!l||l.length===0?{}:l.filter(r=>!r.assetInfo||!r.balance||r.balance==="0"?!1:N?N.has(`${r.chainId}-${r.address.toLowerCase()}`):_chunkTZYKUGNPcjs.i.call(void 0, r.assetInfo)||f.length===0?!0:f.some(d=>d.address.toLowerCase()===r.address.toLowerCase()&&d.chainId===r.chainId)).reduce((r,d)=>{let T=String(d.chainId);return r[T]||(r[T]=[]),r[T].push({token:d.address,amount:d.balance,decimals:d.decimals,assetInfo:d.assetInfo}),r},{}),[l,f,N]),u=_react.useMemo.call(void 0, ()=>!l||l.length===0?0:l.reduce((e,r)=>!r.assetInfo||r.decimals===void 0?e:e+parseFloat(r.balance)/10**r.decimals*(r.assetInfo.price||0),0),[l]),b=_react.useMemo.call(void 0, ()=>i.length===0?{}:i.reduce((e,r)=>{let d=y[r],T=_chunkTZYKUGNPcjs.c.call(void 0, r);return e[r.toString()]={chainId:r,name:_optionalChain([T, 'optionalAccess', _2 => _2.displayName])||_optionalChain([d, 'optionalAccess', _3 => _3.chainKey])||`Chain ${r}`},e},{}),[i,y]),v=_react.useMemo.call(void 0, ()=>f.map(e=>({address:e.address,chainId:e.chainId})),[f]),m=_react.useRef.call(void 0, null);_react.useEffect.call(void 0, ()=>()=>{m.current&&clearTimeout(m.current)},[]);let I=_react.useCallback.call(void 0, ()=>{m.current&&clearTimeout(m.current),m.current=setTimeout(()=>h(),2e3)},[h]);return{address:n,isConnected:c,groupedAssets:t,totalBalance:u,balancesLoading:k,balancesError:g,chains:b,getToken:W,useTokenWithLazyLoad:_chunkTZYKUGNPcjs.D,tokenRegistry:v,refetchBalances:I}}var Z=_chunkT3I3AJXVcjs.b.call(void 0, _chunkKH57FLSTcjs.a.call(void 0, ),1);var _jsxruntime = require('react/jsx-runtime');var ee=({address:s,totalBalance:n,isLoading:c=!1})=>{let y=i=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(i);return _jsxruntime.jsx.call(void 0, "div",{className:"p-2 w-full flex justify-center",children:_jsxruntime.jsxs.call(void 0, "div",{className:"relative w-full h-[140px] overflow-hidden",style:{borderRadius:"var(--widget-radius)",border:"1px var(--widget-border-style) var(--widget-border)"},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"absolute inset-0 z-0",children:[_jsxruntime.jsx.call(void 0, "img",{className:"w-full h-full object-cover opacity-60",src:(0,Z.makeGradient)(s),alt:"address gradient"}),_jsxruntime.jsx.call(void 0, "div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"relative z-10 flex h-full flex-col justify-between p-3",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-2xs uppercase mono",style:{color:"var(--widget-muted-foreground)",opacity:.7},children:"Token Balance:"}),c?_jsxruntime.jsx.call(void 0, _chunkTZYKUGNPcjs.Q,{className:"h-8 w-28 bg-white/10 rounded mt-1"}):_jsxruntime.jsx.call(void 0, "p",{className:"text-2xl font-bold mt-0.5",style:{color:"var(--widget-foreground)"},children:y(n)})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center",children:_jsxruntime.jsx.call(void 0, _chunkTZYKUGNPcjs.P,{text:s,type:"address",children:_jsxruntime.jsx.call(void 0, "p",{className:"mono text-2xs",style:{color:"var(--widget-foreground)",opacity:.7},children:s})})})]})]})})};var te=({asset:s,balanceAmount:n,balanceDecimals:c,price:y,onSelect:i,getToken:W,useTokenWithLazyLoad:f})=>{let[x,w]=_react.useState.call(void 0, !1),a=c!==void 0?parseFloat(n)/10**c:0,k=_optionalChain([f, 'optionalCall', _4 => _4(s.chainId,s.address), 'optionalAccess', _5 => _5.token]),g=_nullishCoalesce(y, () => (null));return _chunkTZYKUGNPcjs.i.call(void 0, s)&&g==null&&(_optionalChain([k, 'optionalAccess', _6 => _6.price])!=null?g=k.price:W&&(g=_nullishCoalesce(_optionalChain([W, 'call', _7 => _7(s.chainId,s.address), 'optionalAccess', _8 => _8.price]), () => (null)))),_jsxruntime.jsx.call(void 0, "div",{role:"button",tabIndex:0,className:"flex h-[52px] w-full flex-row items-center p-3 cursor-pointer transition-colors",style:{borderBottom:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:x?"var(--widget-secondary)":"transparent"},onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1),onClick:()=>_optionalChain([i, 'optionalCall', _9 => _9(s)]),onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),_optionalChain([i, 'optionalCall', _10 => _10(s)]))},children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full w-full flex-row items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full flex-row items-center gap-2",children:[_jsxruntime.jsx.call(void 0, _chunkTZYKUGNPcjs.N,{asset:s,size:"sm"}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col items-start",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-medium uppercase",style:{color:"var(--widget-foreground)"},children:s.symbol}),a>0&&_jsxruntime.jsx.call(void 0, "p",{className:"mono text-xs",style:{color:"var(--widget-muted-foreground)"},children:a.toFixed(4)})]})]}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-medium",style:{color:"var(--widget-foreground)"},children:g!=null?`$${(g*a).toFixed(2)}`:"\u2014"})]})})};var ce=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}),me=_chunkTZYKUGNPcjs.f.call(void 0, ),se=({groupedAssets:s,chains:n,tokenRegistry:c=[],getToken:y,useTokenWithLazyLoad:i,onAssetSelect:W})=>{let[f,x]=_react.useState.call(void 0, new Set),w=_react.useCallback.call(void 0, t=>_optionalChain([n, 'optionalAccess', _11 => _11[t], 'optionalAccess', _12 => _12.name])||me[t]||`Chain ${t}`,[n]),a=_react.useMemo.call(void 0, ()=>{let t=new Set;for(let u of c)t.add(`${u.chainId}-${u.address.toLowerCase()}`);return t},[c]),l=_react.useCallback.call(void 0, t=>t.decimals===void 0||!_optionalChain([t, 'access', _13 => _13.assetInfo, 'optionalAccess', _14 => _14.price])?0:parseFloat(t.amount)/10**t.decimals*t.assetInfo.price,[]),{filteredGroupedAssets:k,chainTotals:g}=_react.useMemo.call(void 0, ()=>{let t=Object.entries(s).map(([v,m])=>{let I=m.filter(e=>e.assetInfo?_chunkTZYKUGNPcjs.i.call(void 0, e.assetInfo)?!0:a.size>0?a.has(`${e.assetInfo.chainId}-${_nullishCoalesce(_optionalChain([e, 'access', _15 => _15.assetInfo, 'access', _16 => _16.address, 'optionalAccess', _17 => _17.toLowerCase, 'call', _18 => _18()]), () => (""))}`):!0:!1);return[v,I]}).filter(([,v])=>v.length>0),u={};for(let[v,m]of t)u[v]=m.reduce((I,e)=>I+l(e),0);return{filteredGroupedAssets:[...t].sort((v,m)=>(_nullishCoalesce(u[m[0]], () => (0)))-(_nullishCoalesce(u[v[0]], () => (0)))),chainTotals:u}},[s,a,l]),h=_react.useCallback.call(void 0, t=>{x(u=>{let b=new Set(u);return b.has(t)?b.delete(t):b.add(t),b})},[]),N=t=>ce.format(t);return k.length===0?_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center justify-center p-6",children:_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"No token balances found"})}):_jsxruntime.jsx.call(void 0, "div",{className:"pb-2 pt-1",children:k.map(([t,u])=>{let b=parseInt(t),v=w(b),m=g[t]||0,I=f.has(t);return _jsxruntime.jsxs.call(void 0, "div",{className:"mx-2 mb-2",style:{border:"1px var(--widget-border-style) var(--widget-border)",borderRadius:"var(--widget-radius)",overflow:"hidden"},children:[_jsxruntime.jsxs.call(void 0, "button",{type:"button",onClick:()=>h(t),className:"flex w-full flex-row items-center justify-between p-2 cursor-pointer transition-colors hover:bg-(--widget-secondary)",style:{backgroundColor:"transparent"},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"inline-flex flex-row items-center gap-2",children:[_jsxruntime.jsx.call(void 0, _chunkTZYKUGNPcjs.M,{chain:b,size:"sm"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-medium capitalize",style:{color:"var(--widget-foreground)"},children:v})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-semibold",style:{color:"var(--widget-foreground)"},children:N(m)}),_jsxruntime.jsx.call(void 0, "span",{className:`transition-transform duration-200 ${I?"rotate-180":""}`,style:{color:"var(--widget-muted-foreground)"},children:_jsxruntime.jsx.call(void 0, "svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:_jsxruntime.jsx.call(void 0, "path",{d:"M2.5 4.5L6 8L9.5 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:`overflow-hidden transition-all duration-200 ease-out ${I?"max-h-[2000px] opacity-100":"max-h-0 opacity-0"}`,children:_jsxruntime.jsx.call(void 0, "div",{style:{borderTop:"1px var(--widget-border-style) var(--widget-border)"},children:u.map(e=>e.assetInfo?_jsxruntime.jsx.call(void 0, te,{asset:e.assetInfo,balanceAmount:e.amount,balanceDecimals:e.decimals,price:_nullishCoalesce(_optionalChain([e, 'access', _19 => _19.assetInfo, 'optionalAccess', _20 => _20.price]), () => (null)),onSelect:W,getToken:y,useTokenWithLazyLoad:i},`${e.assetInfo.chainId}-${e.token}`):null)})})]},t)})})};var ve=()=>_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full h-full overflow-hidden",children:[_jsxruntime.jsx.call(void 0, "div",{className:"p-2 w-full flex justify-center",children:_jsxruntime.jsx.call(void 0, "div",{className:"relative w-full h-[140px] animate-pulse",style:{borderRadius:"var(--widget-radius)",border:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:"var(--widget-secondary)"}})}),_jsxruntime.jsx.call(void 0, "div",{className:"px-2 flex flex-col gap-1.5 mt-1",children:[80,60,72,55,65].map((s,n)=>_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between py-1.5",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, "div",{className:"h-6 w-6 rounded-full animate-pulse shrink-0",style:{backgroundColor:"var(--widget-secondary)"}}),_jsxruntime.jsx.call(void 0, "div",{className:"h-3.5 animate-pulse",style:{width:`${s}px`,backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}})]}),_jsxruntime.jsx.call(void 0, "div",{className:"h-3.5 w-14 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}})]},n))}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-auto shrink-0 p-2",style:{borderTop:"1px var(--widget-border-style) var(--widget-border)"},children:_jsxruntime.jsx.call(void 0, "div",{className:"w-full animate-pulse",style:{height:"34px",backgroundColor:"var(--widget-secondary)",opacity:.35,borderRadius:"var(--widget-radius)"}})})]}),_e= exports.WidgetWalletPanel =()=>{let s=_chunkPD3AGQJPcjs.c.call(void 0, N=>N.walletTab),[n,c]=_react.useState.call(void 0, !1),{disconnect:y}=_wagmi.useDisconnect.call(void 0, ),{setQuoteToken:i}=_chunkPD3AGQJPcjs.f.call(void 0, ),W=_react.useCallback.call(void 0, async N=>{await i(N),_chunkPD3AGQJPcjs.c.getState().setView("swap")},[i]),{address:f,groupedAssets:x,totalBalance:w,balancesLoading:a,chains:l,getToken:k,useTokenWithLazyLoad:g,tokenRegistry:h}=Y(!0);return f?a&&s==="wallet"?_jsxruntime.jsx.call(void 0, ve,{}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full h-full overflow-hidden",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex-1 overflow-y-auto",style:{minHeight:0},children:[s==="wallet"&&_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, ee,{address:f,totalBalance:w,isLoading:a}),_jsxruntime.jsx.call(void 0, se,{groupedAssets:x,chains:l,tokenRegistry:h,getToken:k,useTokenWithLazyLoad:g,onAssetSelect:W})]}),s==="activity"&&_jsxruntime.jsx.call(void 0, _chunkWUSQH743cjs.a,{isActive:s==="activity"})]}),_jsxruntime.jsx.call(void 0, "div",{className:"shrink-0 p-2",style:{borderTop:"1px var(--widget-border-style) var(--widget-border)"},children:_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>{y(),_chunkPD3AGQJPcjs.c.getState().setView("swap")},onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),className:"w-full py-2 text-xs mono uppercase cursor-pointer transition-colors",style:{backgroundColor:n?"var(--widget-destructive)":"transparent",color:n?"var(--widget-destructive-foreground)":"var(--widget-destructive)",border:"1px var(--widget-border-style) var(--widget-destructive)",borderRadius:"var(--widget-radius)"},children:"Sign Out"})})]}):_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col items-center justify-center h-full p-4",children:_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Connect your wallet to view your portfolio"})})};exports.WidgetWalletPanel = _e;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use client";import{a as oe}from"./chunk-OPN7WCJR.js";import{c as F,f as J}from"./chunk-7QJJOVSV.js";import{b as B,c as q}from"./chunk-VI4ISTPB.js";import{a as X}from"./chunk-3RAZPKY5.js";import{D as j,F as G,G as H,J as O,M as U,N as V,P as K,Q,c as E,f as M,i as S}from"./chunk-ZWNDO5OZ.js";import{a as _}from"./chunk-46H44R7V.js";import{b as ae}from"./chunk-73CB2I7U.js";import{useCallback as fe,useState as pe}from"react";import{useDisconnect as ge}from"wagmi";import{useCallback as ne,useEffect as ie,useMemo as L,useRef as le}from"react";function Y(s){let{address:n,isConnected:c}=_(),{chainDataMap:y}=H(),i=q(),{getToken:W,tokenRegistry:f}=j(),{supportedInputTokens:x,supportedOutputTokens:w}=B(),a=L(()=>{if(!x.length&&!w.length)return[];let e=new Set,r=[];for(let d of[...x,...w]){let T=`${d.chainId}-${d.address.toLowerCase()}`;e.has(T)||(e.add(T),r.push(d))}return r},[x,w]),{balances:l,isLoading:k,isError:g,refetch:h}=O(n,i,{enabled:c&&s&&!!n,refetchOnWindowFocus:!1},a.length>0?a:void 0),N=L(()=>a.length?new Set(a.map(e=>`${e.chainId}-${e.address.toLowerCase()}`)):null,[a]),t=L(()=>!l||l.length===0?{}:l.filter(r=>!r.assetInfo||!r.balance||r.balance==="0"?!1:N?N.has(`${r.chainId}-${r.address.toLowerCase()}`):S(r.assetInfo)||f.length===0?!0:f.some(d=>d.address.toLowerCase()===r.address.toLowerCase()&&d.chainId===r.chainId)).reduce((r,d)=>{let T=String(d.chainId);return r[T]||(r[T]=[]),r[T].push({token:d.address,amount:d.balance,decimals:d.decimals,assetInfo:d.assetInfo}),r},{}),[l,f,N]),u=L(()=>!l||l.length===0?0:l.reduce((e,r)=>!r.assetInfo||r.decimals===void 0?e:e+parseFloat(r.balance)/10**r.decimals*(r.assetInfo.price||0),0),[l]),b=L(()=>i.length===0?{}:i.reduce((e,r)=>{let d=y[r],T=E(r);return e[r.toString()]={chainId:r,name:T?.displayName||d?.chainKey||`Chain ${r}`},e},{}),[i,y]),v=L(()=>f.map(e=>({address:e.address,chainId:e.chainId})),[f]),m=le(null);ie(()=>()=>{m.current&&clearTimeout(m.current)},[]);let I=ne(()=>{m.current&&clearTimeout(m.current),m.current=setTimeout(()=>h(),2e3)},[h]);return{address:n,isConnected:c,groupedAssets:t,totalBalance:u,balancesLoading:k,balancesError:g,chains:b,getToken:W,useTokenWithLazyLoad:G,tokenRegistry:v,refetchBalances:I}}var Z=ae(oe(),1);import{jsx as C,jsxs as $}from"react/jsx-runtime";var ee=({address:s,totalBalance:n,isLoading:c=!1})=>{let y=i=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(i);return C("div",{className:"p-2 w-full flex justify-center",children:$("div",{className:"relative w-full h-[140px] overflow-hidden",style:{borderRadius:"var(--widget-radius)",border:"1px var(--widget-border-style) var(--widget-border)"},children:[$("div",{className:"absolute inset-0 z-0",children:[C("img",{className:"w-full h-full object-cover opacity-60",src:(0,Z.makeGradient)(s),alt:"address gradient"}),C("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent"})]}),$("div",{className:"relative z-10 flex h-full flex-col justify-between p-3",children:[$("div",{children:[C("p",{className:"text-2xs uppercase mono",style:{color:"var(--widget-muted-foreground)",opacity:.7},children:"Token Balance:"}),c?C(Q,{className:"h-8 w-28 bg-white/10 rounded mt-1"}):C("p",{className:"text-2xl font-bold mt-0.5",style:{color:"var(--widget-foreground)"},children:y(n)})]}),C("div",{className:"flex items-center",children:C(K,{text:s,type:"address",children:C("p",{className:"mono text-2xs",style:{color:"var(--widget-foreground)",opacity:.7},children:s})})})]})]})})};import{useCallback as P,useMemo as re,useState as ue}from"react";import{useState as de}from"react";import{jsx as R,jsxs as z}from"react/jsx-runtime";var te=({asset:s,balanceAmount:n,balanceDecimals:c,price:y,onSelect:i,getToken:W,useTokenWithLazyLoad:f})=>{let[x,w]=de(!1),a=c!==void 0?parseFloat(n)/10**c:0,k=f?.(s.chainId,s.address)?.token,g=y??null;return S(s)&&g==null&&(k?.price!=null?g=k.price:W&&(g=W(s.chainId,s.address)?.price??null)),R("div",{role:"button",tabIndex:0,className:"flex h-[52px] w-full flex-row items-center p-3 cursor-pointer transition-colors",style:{borderBottom:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:x?"var(--widget-secondary)":"transparent"},onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1),onClick:()=>i?.(s),onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),i?.(s))},children:z("div",{className:"flex h-full w-full flex-row items-center justify-between",children:[z("div",{className:"flex h-full flex-row items-center gap-2",children:[R(V,{asset:s,size:"sm"}),z("div",{className:"flex flex-col items-start",children:[R("p",{className:"text-sm font-medium uppercase",style:{color:"var(--widget-foreground)"},children:s.symbol}),a>0&&R("p",{className:"mono text-xs",style:{color:"var(--widget-muted-foreground)"},children:a.toFixed(4)})]})]}),R("p",{className:"text-sm font-medium",style:{color:"var(--widget-foreground)"},children:g!=null?`$${(g*a).toFixed(2)}`:"\u2014"})]})})};import{jsx as p,jsxs as D}from"react/jsx-runtime";var ce=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}),me=M(),se=({groupedAssets:s,chains:n,tokenRegistry:c=[],getToken:y,useTokenWithLazyLoad:i,onAssetSelect:W})=>{let[f,x]=ue(new Set),w=P(t=>n?.[t]?.name||me[t]||`Chain ${t}`,[n]),a=re(()=>{let t=new Set;for(let u of c)t.add(`${u.chainId}-${u.address.toLowerCase()}`);return t},[c]),l=P(t=>t.decimals===void 0||!t.assetInfo?.price?0:parseFloat(t.amount)/10**t.decimals*t.assetInfo.price,[]),{filteredGroupedAssets:k,chainTotals:g}=re(()=>{let t=Object.entries(s).map(([v,m])=>{let I=m.filter(e=>e.assetInfo?S(e.assetInfo)?!0:a.size>0?a.has(`${e.assetInfo.chainId}-${e.assetInfo.address?.toLowerCase()??""}`):!0:!1);return[v,I]}).filter(([,v])=>v.length>0),u={};for(let[v,m]of t)u[v]=m.reduce((I,e)=>I+l(e),0);return{filteredGroupedAssets:[...t].sort((v,m)=>(u[m[0]]??0)-(u[v[0]]??0)),chainTotals:u}},[s,a,l]),h=P(t=>{x(u=>{let b=new Set(u);return b.has(t)?b.delete(t):b.add(t),b})},[]),N=t=>ce.format(t);return k.length===0?p("div",{className:"flex items-center justify-center p-6",children:p("p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"No token balances found"})}):p("div",{className:"pb-2 pt-1",children:k.map(([t,u])=>{let b=parseInt(t),v=w(b),m=g[t]||0,I=f.has(t);return D("div",{className:"mx-2 mb-2",style:{border:"1px var(--widget-border-style) var(--widget-border)",borderRadius:"var(--widget-radius)",overflow:"hidden"},children:[D("button",{type:"button",onClick:()=>h(t),className:"flex w-full flex-row items-center justify-between p-2 cursor-pointer transition-colors hover:bg-(--widget-secondary)",style:{backgroundColor:"transparent"},children:[D("div",{className:"inline-flex flex-row items-center gap-2",children:[p(U,{chain:b,size:"sm"}),p("p",{className:"text-sm font-medium capitalize",style:{color:"var(--widget-foreground)"},children:v})]}),D("div",{className:"flex items-center gap-2",children:[p("p",{className:"text-sm font-semibold",style:{color:"var(--widget-foreground)"},children:N(m)}),p("span",{className:`transition-transform duration-200 ${I?"rotate-180":""}`,style:{color:"var(--widget-muted-foreground)"},children:p("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:p("path",{d:"M2.5 4.5L6 8L9.5 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),p("div",{className:`overflow-hidden transition-all duration-200 ease-out ${I?"max-h-[2000px] opacity-100":"max-h-0 opacity-0"}`,children:p("div",{style:{borderTop:"1px var(--widget-border-style) var(--widget-border)"},children:u.map(e=>e.assetInfo?p(te,{asset:e.assetInfo,balanceAmount:e.amount,balanceDecimals:e.decimals,price:e.assetInfo?.price??null,onSelect:W,getToken:y,useTokenWithLazyLoad:i},`${e.assetInfo.chainId}-${e.token}`):null)})})]},t)})})};import{Fragment as ye,jsx as o,jsxs as A}from"react/jsx-runtime";var ve=()=>A("div",{className:"flex flex-col w-full h-full overflow-hidden",children:[o("div",{className:"p-2 w-full flex justify-center",children:o("div",{className:"relative w-full h-[140px] animate-pulse",style:{borderRadius:"var(--widget-radius)",border:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:"var(--widget-secondary)"}})}),o("div",{className:"px-2 flex flex-col gap-1.5 mt-1",children:[80,60,72,55,65].map((s,n)=>A("div",{className:"flex items-center justify-between py-1.5",children:[A("div",{className:"flex items-center gap-2",children:[o("div",{className:"h-6 w-6 rounded-full animate-pulse shrink-0",style:{backgroundColor:"var(--widget-secondary)"}}),o("div",{className:"h-3.5 animate-pulse",style:{width:`${s}px`,backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}})]}),o("div",{className:"h-3.5 w-14 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}})]},n))}),o("div",{className:"mt-auto shrink-0 p-2",style:{borderTop:"1px var(--widget-border-style) var(--widget-border)"},children:o("div",{className:"w-full animate-pulse",style:{height:"34px",backgroundColor:"var(--widget-secondary)",opacity:.35,borderRadius:"var(--widget-radius)"}})})]}),_e=()=>{let s=F(N=>N.walletTab),[n,c]=pe(!1),{disconnect:y}=ge(),{setQuoteToken:i}=J(),W=fe(async N=>{await i(N),F.getState().setView("swap")},[i]),{address:f,groupedAssets:x,totalBalance:w,balancesLoading:a,chains:l,getToken:k,useTokenWithLazyLoad:g,tokenRegistry:h}=Y(!0);return f?a&&s==="wallet"?o(ve,{}):A("div",{className:"flex flex-col w-full h-full overflow-hidden",children:[A("div",{className:"flex-1 overflow-y-auto",style:{minHeight:0},children:[s==="wallet"&&A(ye,{children:[o(ee,{address:f,totalBalance:w,isLoading:a}),o(se,{groupedAssets:x,chains:l,tokenRegistry:h,getToken:k,useTokenWithLazyLoad:g,onAssetSelect:W})]}),s==="activity"&&o(X,{isActive:s==="activity"})]}),o("div",{className:"shrink-0 p-2",style:{borderTop:"1px var(--widget-border-style) var(--widget-border)"},children:o("button",{type:"button",onClick:()=>{y(),F.getState().setView("swap")},onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),className:"w-full py-2 text-xs mono uppercase cursor-pointer transition-colors",style:{backgroundColor:n?"var(--widget-destructive)":"transparent",color:n?"var(--widget-destructive-foreground)":"var(--widget-destructive)",border:"1px var(--widget-border-style) var(--widget-destructive)",borderRadius:"var(--widget-radius)"},children:"Sign Out"})})]}):o("div",{className:"flex flex-col items-center justify-center h-full p-4",children:o("p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Connect your wallet to view your portfolio"})})};export{_e as WidgetWalletPanel};
|
|
2
|
+
"use client";import{a as oe}from"./chunk-OPN7WCJR.js";import{c as F,f as J}from"./chunk-BF4UK5A7.js";import{b as B,c as q}from"./chunk-TUAHO7RQ.js";import{a as X}from"./chunk-4AIDDZRO.js";import{B as j,D as G,G as H,J as O,M as U,N as V,P as K,Q,c as E,f as M,i as S}from"./chunk-IF7S6ZES.js";import{a as _}from"./chunk-46H44R7V.js";import{b as ae}from"./chunk-73CB2I7U.js";import{useCallback as fe,useState as pe}from"react";import{useDisconnect as ge}from"wagmi";import{useCallback as ne,useEffect as ie,useMemo as L,useRef as le}from"react";function Y(s){let{address:n,isConnected:c}=_(),{chainDataMap:y}=H(),i=q(),{getToken:W,tokenRegistry:f}=j(),{supportedInputTokens:x,supportedOutputTokens:w}=B(),a=L(()=>{if(!x.length&&!w.length)return[];let e=new Set,r=[];for(let d of[...x,...w]){let T=`${d.chainId}-${d.address.toLowerCase()}`;e.has(T)||(e.add(T),r.push(d))}return r},[x,w]),{balances:l,isLoading:k,isError:g,refetch:h}=O(n,i,{enabled:c&&s&&!!n,refetchOnWindowFocus:!1},a.length>0?a:void 0),N=L(()=>a.length?new Set(a.map(e=>`${e.chainId}-${e.address.toLowerCase()}`)):null,[a]),t=L(()=>!l||l.length===0?{}:l.filter(r=>!r.assetInfo||!r.balance||r.balance==="0"?!1:N?N.has(`${r.chainId}-${r.address.toLowerCase()}`):S(r.assetInfo)||f.length===0?!0:f.some(d=>d.address.toLowerCase()===r.address.toLowerCase()&&d.chainId===r.chainId)).reduce((r,d)=>{let T=String(d.chainId);return r[T]||(r[T]=[]),r[T].push({token:d.address,amount:d.balance,decimals:d.decimals,assetInfo:d.assetInfo}),r},{}),[l,f,N]),u=L(()=>!l||l.length===0?0:l.reduce((e,r)=>!r.assetInfo||r.decimals===void 0?e:e+parseFloat(r.balance)/10**r.decimals*(r.assetInfo.price||0),0),[l]),b=L(()=>i.length===0?{}:i.reduce((e,r)=>{let d=y[r],T=E(r);return e[r.toString()]={chainId:r,name:T?.displayName||d?.chainKey||`Chain ${r}`},e},{}),[i,y]),v=L(()=>f.map(e=>({address:e.address,chainId:e.chainId})),[f]),m=le(null);ie(()=>()=>{m.current&&clearTimeout(m.current)},[]);let I=ne(()=>{m.current&&clearTimeout(m.current),m.current=setTimeout(()=>h(),2e3)},[h]);return{address:n,isConnected:c,groupedAssets:t,totalBalance:u,balancesLoading:k,balancesError:g,chains:b,getToken:W,useTokenWithLazyLoad:G,tokenRegistry:v,refetchBalances:I}}var Z=ae(oe(),1);import{jsx as C,jsxs as $}from"react/jsx-runtime";var ee=({address:s,totalBalance:n,isLoading:c=!1})=>{let y=i=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(i);return C("div",{className:"p-2 w-full flex justify-center",children:$("div",{className:"relative w-full h-[140px] overflow-hidden",style:{borderRadius:"var(--widget-radius)",border:"1px var(--widget-border-style) var(--widget-border)"},children:[$("div",{className:"absolute inset-0 z-0",children:[C("img",{className:"w-full h-full object-cover opacity-60",src:(0,Z.makeGradient)(s),alt:"address gradient"}),C("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent"})]}),$("div",{className:"relative z-10 flex h-full flex-col justify-between p-3",children:[$("div",{children:[C("p",{className:"text-2xs uppercase mono",style:{color:"var(--widget-muted-foreground)",opacity:.7},children:"Token Balance:"}),c?C(Q,{className:"h-8 w-28 bg-white/10 rounded mt-1"}):C("p",{className:"text-2xl font-bold mt-0.5",style:{color:"var(--widget-foreground)"},children:y(n)})]}),C("div",{className:"flex items-center",children:C(K,{text:s,type:"address",children:C("p",{className:"mono text-2xs",style:{color:"var(--widget-foreground)",opacity:.7},children:s})})})]})]})})};import{useCallback as P,useMemo as re,useState as ue}from"react";import{useState as de}from"react";import{jsx as R,jsxs as z}from"react/jsx-runtime";var te=({asset:s,balanceAmount:n,balanceDecimals:c,price:y,onSelect:i,getToken:W,useTokenWithLazyLoad:f})=>{let[x,w]=de(!1),a=c!==void 0?parseFloat(n)/10**c:0,k=f?.(s.chainId,s.address)?.token,g=y??null;return S(s)&&g==null&&(k?.price!=null?g=k.price:W&&(g=W(s.chainId,s.address)?.price??null)),R("div",{role:"button",tabIndex:0,className:"flex h-[52px] w-full flex-row items-center p-3 cursor-pointer transition-colors",style:{borderBottom:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:x?"var(--widget-secondary)":"transparent"},onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1),onClick:()=>i?.(s),onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),i?.(s))},children:z("div",{className:"flex h-full w-full flex-row items-center justify-between",children:[z("div",{className:"flex h-full flex-row items-center gap-2",children:[R(V,{asset:s,size:"sm"}),z("div",{className:"flex flex-col items-start",children:[R("p",{className:"text-sm font-medium uppercase",style:{color:"var(--widget-foreground)"},children:s.symbol}),a>0&&R("p",{className:"mono text-xs",style:{color:"var(--widget-muted-foreground)"},children:a.toFixed(4)})]})]}),R("p",{className:"text-sm font-medium",style:{color:"var(--widget-foreground)"},children:g!=null?`$${(g*a).toFixed(2)}`:"\u2014"})]})})};import{jsx as p,jsxs as D}from"react/jsx-runtime";var ce=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}),me=M(),se=({groupedAssets:s,chains:n,tokenRegistry:c=[],getToken:y,useTokenWithLazyLoad:i,onAssetSelect:W})=>{let[f,x]=ue(new Set),w=P(t=>n?.[t]?.name||me[t]||`Chain ${t}`,[n]),a=re(()=>{let t=new Set;for(let u of c)t.add(`${u.chainId}-${u.address.toLowerCase()}`);return t},[c]),l=P(t=>t.decimals===void 0||!t.assetInfo?.price?0:parseFloat(t.amount)/10**t.decimals*t.assetInfo.price,[]),{filteredGroupedAssets:k,chainTotals:g}=re(()=>{let t=Object.entries(s).map(([v,m])=>{let I=m.filter(e=>e.assetInfo?S(e.assetInfo)?!0:a.size>0?a.has(`${e.assetInfo.chainId}-${e.assetInfo.address?.toLowerCase()??""}`):!0:!1);return[v,I]}).filter(([,v])=>v.length>0),u={};for(let[v,m]of t)u[v]=m.reduce((I,e)=>I+l(e),0);return{filteredGroupedAssets:[...t].sort((v,m)=>(u[m[0]]??0)-(u[v[0]]??0)),chainTotals:u}},[s,a,l]),h=P(t=>{x(u=>{let b=new Set(u);return b.has(t)?b.delete(t):b.add(t),b})},[]),N=t=>ce.format(t);return k.length===0?p("div",{className:"flex items-center justify-center p-6",children:p("p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"No token balances found"})}):p("div",{className:"pb-2 pt-1",children:k.map(([t,u])=>{let b=parseInt(t),v=w(b),m=g[t]||0,I=f.has(t);return D("div",{className:"mx-2 mb-2",style:{border:"1px var(--widget-border-style) var(--widget-border)",borderRadius:"var(--widget-radius)",overflow:"hidden"},children:[D("button",{type:"button",onClick:()=>h(t),className:"flex w-full flex-row items-center justify-between p-2 cursor-pointer transition-colors hover:bg-(--widget-secondary)",style:{backgroundColor:"transparent"},children:[D("div",{className:"inline-flex flex-row items-center gap-2",children:[p(U,{chain:b,size:"sm"}),p("p",{className:"text-sm font-medium capitalize",style:{color:"var(--widget-foreground)"},children:v})]}),D("div",{className:"flex items-center gap-2",children:[p("p",{className:"text-sm font-semibold",style:{color:"var(--widget-foreground)"},children:N(m)}),p("span",{className:`transition-transform duration-200 ${I?"rotate-180":""}`,style:{color:"var(--widget-muted-foreground)"},children:p("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:p("path",{d:"M2.5 4.5L6 8L9.5 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),p("div",{className:`overflow-hidden transition-all duration-200 ease-out ${I?"max-h-[2000px] opacity-100":"max-h-0 opacity-0"}`,children:p("div",{style:{borderTop:"1px var(--widget-border-style) var(--widget-border)"},children:u.map(e=>e.assetInfo?p(te,{asset:e.assetInfo,balanceAmount:e.amount,balanceDecimals:e.decimals,price:e.assetInfo?.price??null,onSelect:W,getToken:y,useTokenWithLazyLoad:i},`${e.assetInfo.chainId}-${e.token}`):null)})})]},t)})})};import{Fragment as ye,jsx as o,jsxs as A}from"react/jsx-runtime";var ve=()=>A("div",{className:"flex flex-col w-full h-full overflow-hidden",children:[o("div",{className:"p-2 w-full flex justify-center",children:o("div",{className:"relative w-full h-[140px] animate-pulse",style:{borderRadius:"var(--widget-radius)",border:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:"var(--widget-secondary)"}})}),o("div",{className:"px-2 flex flex-col gap-1.5 mt-1",children:[80,60,72,55,65].map((s,n)=>A("div",{className:"flex items-center justify-between py-1.5",children:[A("div",{className:"flex items-center gap-2",children:[o("div",{className:"h-6 w-6 rounded-full animate-pulse shrink-0",style:{backgroundColor:"var(--widget-secondary)"}}),o("div",{className:"h-3.5 animate-pulse",style:{width:`${s}px`,backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}})]}),o("div",{className:"h-3.5 w-14 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}})]},n))}),o("div",{className:"mt-auto shrink-0 p-2",style:{borderTop:"1px var(--widget-border-style) var(--widget-border)"},children:o("div",{className:"w-full animate-pulse",style:{height:"34px",backgroundColor:"var(--widget-secondary)",opacity:.35,borderRadius:"var(--widget-radius)"}})})]}),_e=()=>{let s=F(N=>N.walletTab),[n,c]=pe(!1),{disconnect:y}=ge(),{setQuoteToken:i}=J(),W=fe(async N=>{await i(N),F.getState().setView("swap")},[i]),{address:f,groupedAssets:x,totalBalance:w,balancesLoading:a,chains:l,getToken:k,useTokenWithLazyLoad:g,tokenRegistry:h}=Y(!0);return f?a&&s==="wallet"?o(ve,{}):A("div",{className:"flex flex-col w-full h-full overflow-hidden",children:[A("div",{className:"flex-1 overflow-y-auto",style:{minHeight:0},children:[s==="wallet"&&A(ye,{children:[o(ee,{address:f,totalBalance:w,isLoading:a}),o(se,{groupedAssets:x,chains:l,tokenRegistry:h,getToken:k,useTokenWithLazyLoad:g,onAssetSelect:W})]}),s==="activity"&&o(X,{isActive:s==="activity"})]}),o("div",{className:"shrink-0 p-2",style:{borderTop:"1px var(--widget-border-style) var(--widget-border)"},children:o("button",{type:"button",onClick:()=>{y(),F.getState().setView("swap")},onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),className:"w-full py-2 text-xs mono uppercase cursor-pointer transition-colors",style:{backgroundColor:n?"var(--widget-destructive)":"transparent",color:n?"var(--widget-destructive-foreground)":"var(--widget-destructive)",border:"1px var(--widget-border-style) var(--widget-destructive)",borderRadius:"var(--widget-radius)"},children:"Sign Out"})})]}):o("div",{className:"flex flex-col items-center justify-center h-full p-4",children:o("p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Connect your wallet to view your portfolio"})})};export{_e as WidgetWalletPanel};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
|
+
"use client";var _chunkWUSQH743cjs = require('./chunk-WUSQH743.cjs');require('./chunk-TZYKUGNP.cjs');require('./chunk-34N36GUD.cjs');require('./chunk-T3I3AJXV.cjs');exports.WidgetWalletTradeHistory = _chunkWUSQH743cjs.a;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{a as Sr}from"./chunk-OPN7WCJR.js";import{c as ae,f as Ie}from"./chunk-BF4UK5A7.js";import{b as Ae,c as It}from"./chunk-TUAHO7RQ.js";import{E as rt,F as nt,H as kt,I as st,M as we,N as re,O as Y,R as he,S as Nt,T as We,U as H,W as Et,X as De,a as Fe,c as z,h as Ct,k as ke,m as Ne,o as Ee,q as St,r as se,s as Tt,t as et,v as tt,w as Rt,x as At}from"./chunk-IF7S6ZES.js";import{a as oe}from"./chunk-46H44R7V.js";import{b as Cr}from"./chunk-73CB2I7U.js";import{useQueryClient as Tr}from"@tanstack/react-query";import{useCallback as Rr,useEffect as Pt,useRef as Ot}from"react";function Ar(e){if(e.length===0)return 5e3;let l=Math.max(...e.map(s=>z(s)?.blockTimeMs??2e3));return Math.min(5e3,Math.max(1e3,l*2+1e3))}var kr=()=>{let{address:e}=oe(),t=It(),r=Tr(),c=Ot(null),l=Ot(!0),s=Rr(a=>{if(!e)return;let y=[...new Set(a.tokens.map(d=>d.asset.chainId))],g=Ar(y);c.current&&(clearTimeout(c.current),c.current=null),c.current=setTimeout(async()=>{if(c.current=null,!!l.current)try{let d=a.tokens.map(w=>({chainId:w.asset.chainId,tokenAddress:w.asset.address})),o=await kt(e,d);if(o.balances.length===0)return;if(a.tokens.length>=2){let w=a.tokens[0].asset,u=a.tokens[1].asset,h=st.swap(e,w.chainId,w.address,u.chainId,u.address);r.setQueryData(h,o)}let n=st.bulk(e,t),v=r.getQueryData(n);if(v){let w=v.balances.map(u=>o.balances.find(f=>f.chainId===u.chainId&&f.token.toLowerCase()===u.token.toLowerCase())??u);for(let u of o.balances)w.some(h=>h.chainId===u.chainId&&h.token.toLowerCase()===u.token.toLowerCase())||w.push(u);for(let u of a.tokens)if(!o.balances.some(f=>f.chainId===u.asset.chainId&&f.token.toLowerCase()===u.asset.address.toLowerCase())){let f=w.findIndex(i=>i.chainId===u.asset.chainId&&i.token.toLowerCase()===u.asset.address.toLowerCase());f!==-1&&(w[f]={...w[f],balance:"0",shiftedBalance:"0"})}r.setQueryData(n,{balances:w})}}catch{}},g)},[e,t,r]);return Pt(()=>(l.current=!0,()=>{l.current=!1,c.current&&(clearTimeout(c.current),c.current=null)}),[]),{triggerBalanceUpdate:s}},ot=class extends EventTarget{emit(t){this.dispatchEvent(new CustomEvent("balance-update",{detail:t}))}},at=new ot,Oe=()=>e=>at.emit(e),as=()=>{let{triggerBalanceUpdate:e}=kr();Pt(()=>{let t=r=>{e(r.detail)};return at.addEventListener("balance-update",t),()=>at.removeEventListener("balance-update",t)},[e])};import{createContext as Nr,useCallback as de,useContext as Er,useEffect as $t,useMemo as Ir,useRef as ie,useState as be}from"react";import{formatUnits as Or,parseUnits as Pr}from"viem";import{jsx as Wr}from"react/jsx-runtime";var Mt=Nr(void 0),Ut=1e4,$r=3e4,Ur=1e3,Mr=2;function Lr(e){return e.find(r=>r.routeSteps?.[0]?.type==="AORI_V1")??e[0]}var fs=({children:e,recipient:t})=>{let{address:r}=oe(),c=t||r,[l,s]=be("idle"),[a,y]=be("idle"),[g,d]=be(null),[o,n]=be(null),[v,w]=be(!1),[u,h]=be(!1),[f,i]=be(!1),p=ie(null),x=ie(null),m=ie(null),k=ie(null),P=ie(null),S=ie(0),U=ie(0),L=ie(0),N=ie(!1),E=ie(new Map),A=de(()=>{m.current&&clearTimeout(m.current),k.current&&clearTimeout(k.current),P.current&&clearTimeout(P.current),m.current=null,k.current=null,P.current=null},[]),M=de(()=>{A(),p.current=null,S.current=0,s(()=>N.current?"fresh":"idle")},[A]),V=de(()=>{M(),x.current=null,d(null),n(null),w(!1),h(!1),i(!1),E.current.clear(),s("idle"),y("idle")},[M]),ce=de(C=>{if(!C)return;k.current&&clearTimeout(k.current);let T=Math.max(0,C+$r-Date.now());k.current=setTimeout(()=>{s($=>$==="idle"?"idle":"stale")},T)},[]),K=de(async(C,T)=>{let{inputToken:$,outputToken:O,inputAmount:q,setOutputAmount:Z}=C;if(!$||!O||!q||parseFloat(q)<=0||Date.now()-(U.current||0)<Ut-10)return;let _e=++S.current;try{if(!$?.decimals||!O?.decimals)return;let j=nt($.chainId)||z($.chainId)?.key||"",le=nt(O.chainId)||z(O.chainId)?.key||"";if(!j||!le)throw new Error("Unknown chain");let ee=Pr(q.toString(),$.decimals).toString(),Te={srcChainKey:j,dstChainKey:le,srcTokenAddress:tt($.address),dstTokenAddress:tt(O.address),amount:ee,srcWalletAddress:r||"0x0000000000000000000000000000000000000000",dstWalletAddress:c||r||"0x0000000000000000000000000000000000000000",options:{amountType:"EXACT_SRC_AMOUNT",feeTolerance:{type:"PERCENT",amount:2}}};U.current=Date.now();let te=await fetch(`${ke()}/quotes`,{method:"POST",headers:Ne(),body:JSON.stringify(Te),signal:AbortSignal.timeout(15e3)});if(!te.ok){let Re=(await te.json().catch(()=>({})))?.message||te.statusText;throw Object.assign(new Error(Re),{status:te.status})}let ne=await te.json();if(_e!==S.current||p.current!==T)return;let Ue=ne.quotes??[],ue=Lr(Ue);if(!ue)throw Object.assign(new Error("No quotes returned"),{emptyQuotes:!0});let Ze=Number(Or(St(ue.dstAmount),O.decimals));typeof Z=="function"&&Z(Ze),ue._receivedAt=Date.now(),d(ue),n(null),w(!1),s("fresh"),ce(ue._receivedAt),T&&E.current.delete(T)}catch(j){if(_e!==S.current||p.current!==T)return;let le=j?.status,ee=j instanceof Error?j.message:"",Te=!!j?.emptyQuotes;if((le===400||Te||ee.includes("Quote request failed"))&&T){let ne=(E.current.get(T)||0)+1;if(E.current.set(T,ne),ne>=Mr){h(!0),A(),p.current=null;return}}if(ee.toLowerCase().includes("order cap exceeded")){i(!0),A(),p.current=null;return}if(ee.toLowerCase().includes("insufficient executor balance")){w(!0),A(),p.current=null;return}n(j instanceof Error?j.message:"Unknown error")}},[r,c,ce,A]),D=de((C,T)=>{A(),x.current=C,U.current=0,E.current.delete(T),w(!1),h(!1),i(!1),n(null),s("polling");let $=async()=>{p.current===T&&(await K(C,T),p.current===T&&(m.current=setTimeout($,Ut)))};$()},[A,K]),I=de(C=>{if(!C?.inputToken||!C?.outputToken||!C?.inputAmount||parseFloat(C.inputAmount)<=0){M();return}let T=x.current;if(T&&T.inputToken?.address===C.inputToken?.address&&T.inputToken?.chainId===C.inputToken?.chainId&&T.outputToken?.address===C.outputToken?.address&&T.outputToken?.chainId===C.outputToken?.chainId&&T.inputAmount===C.inputAmount&&p.current)return;let O=Date.now();if(O-L.current<100)return;L.current=O;let q=`${Date.now()}-${Math.random().toString(36).slice(2)}`;p.current=q,D(C,q)},[D,M]),F=de(({amount:C,inputToken:T,outputToken:$,setOutputAmount:O})=>{O(null),P.current&&clearTimeout(P.current),!C||C===0?(y("idle"),M(),d(null),n(null),w(!1),h(!1),i(!1)):(y("typing"),M(),d(null),w(!1),h(!1),i(!1),n(null),P.current=setTimeout(()=>{y("settled"),T&&$&&C>0&&I({inputToken:T,outputToken:$,inputAmount:C.toString(),setOutputAmount:O})},Ur))},[M,I]),B=de(()=>{let C=x.current;if(!C)return;d(null);let T=`${Date.now()}-${Math.random().toString(36).slice(2)}`;p.current=T,s("refreshing"),typeof C.setOutputAmount=="function"&&C.setOutputAmount(null),D(C,T)},[D]);$t(()=>{N.current=!!g},[g]),$t(()=>()=>A(),[A]);let X=Ir(()=>({status:l,inputState:a,rfqQuote:g,error:o,liquidityError:v,routingError:u,sizeCapError:f,ensureForParams:I,stop:M,refresh:B,clear:V,handleInputChange:F}),[l,a,g,o,v,u,f,I,M,B,V,F]);return Wr(Mt.Provider,{value:X,children:e})},Be=()=>{let e=Er(Mt);if(e===void 0)throw new Error("useRfq must be used within an RfqProvider");return e};import{createContext as Dr,useContext as Vr}from"react";var _r=Dr({openConnectModal:()=>{}}),ys=()=>Vr(_r);import{useCallback as it,useEffect as Pe,useRef as ze,useState as ct}from"react";import{jsx as $e,jsxs as zr}from"react/jsx-runtime";var Fr=20,Br=({side:e,asset:t,otherAsset:r,isPlacingOrder:c,isWrappingPair:l,isUnwrappingPair:s})=>{let{baseAmount:a,quoteAmount:y,setBaseAmount:g,setQuoteAmount:d}=Ie(),{amountInputVariant:o,hideAmountInputSymbol:n,widgetType:v}=Ae(),w=v==="compact",[u,h]=e==="base"?[g,d]:[d,g],f=!t||e==="quote"||c,i=w?32:o==="default"?64:32,[p,x]=ct(i),[m,k]=ct(""),P=ze(null),S=ze(null),U=ze(null),L=ze(null),N="USD",E=e==="base"?a:y,[A,M]=ct(!1),V=it(()=>{if(o!=="default"){x(i);return}if(!P.current||!S.current||!U.current)return;let D=P.current.offsetWidth,I=20,F=i;for(;F>20&&(S.current.style.fontSize=`${F}px`,U.current.style.fontSize=`${F}px`,!(S.current.offsetWidth+U.current.offsetWidth+I<=D));)F-=1;x(F)},[o,i]),ce=it(D=>{D.key==="."&&m.includes(".")&&D.preventDefault()},[m]),K=it(D=>{let I=D.target.value;if(I==="."&&(I="0."),!/^\d*\.?\d*$/.test(I)||(I.match(/\./g)||[]).length>1)return;if(I.length>1&&I[0]==="0"&&I[1]!=="."&&(I=I.replace(/^0+/,"")||"0"),t?.decimals!==void 0&&I.includes(".")){let[,B]=I.split(".");if(B&&B.length>t.decimals)return}if(I.length>Fr)return;k(I);let F=parseFloat(I);I!==m&&(I===""||I==="0."||I.endsWith(".")?(u(null),e==="base"&&h(null)):!Number.isNaN(F)&&F>=0&&u(F),e==="base"&&d(null),(s||l)&&d(F||0))},[m,u,e,d,t?.decimals,h,s,l]);return Pe(()=>{let D=B=>{if(B===null)return"";let X=t?.decimals;if(X===void 0)return"";let C=B.toString();if(/e/i.test(C)&&(C=Number(B).toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:X})),C.includes(".")){let[T,$]=C.split("."),O=$.slice(0,X);return O?`${T}.${O}`:T}return C};if(E===null){m==="0."||m!==""&&m.endsWith(".")||k("");return}if(!f&&(m.endsWith(".")||m.match(/\.\d*0$/)||m==="0"||m==="0.")&&m!=="")return;let F=parseFloat(m)||0;(m===""||Math.abs(F-E)>1e-10)&&k(D(E))},[E,t?.decimals,m,f]),Pe(()=>{V()},[m,V]),Pe(()=>{M(!0)},[]),Pe(()=>{A&&V()},[A,V]),Pe(()=>{S.current&&L.current&&(L.current.style.width=`${S.current.offsetWidth}px`)},[m]),Pe(()=>{if(!A)return;let D=new ResizeObserver(()=>{A&&V()});return P.current&&D.observe(P.current),()=>D.disconnect()},[A,V]),$e("div",{ref:P,style:{fontSize:`${p}px`,transition:"font-size 0.05s ease-in-out"},className:`mt-2 box-border flex ${w?o==="normal"?"h-12 my-1":"h-10 my-0.5":o==="normal"?"h-12 my-1":"h-20 my-1"} w-full flex-row items-center ${f?"cursor-default":"cursor-text"}`,onClick:()=>L.current?.focus(),children:zr("div",{className:"relative flex w-full items-center",children:[$e("label",{htmlFor:`${e}Amount`,className:"sr-only",children:e==="base"?"Input token amount":"Output token amount"}),$e("input",{ref:L,type:"text",inputMode:"decimal",placeholder:"0",autoComplete:"off",id:`${e}Amount`,value:m,onWheel:D=>D.target.blur(),onKeyDown:ce,onChange:K,style:{transition:"width 0.15s ease-in-out",color:"var(--widget-foreground)",WebkitTextFillColor:"var(--widget-foreground)",opacity:f?.4:1},className:"flex min-w-[45px] whitespace-nowrap bg-transparent placeholder:opacity-50",disabled:f}),$e("span",{style:{transition:"width 0.15s ease-in-out"},ref:S,className:"pointer-events-none absolute flex whitespace-nowrap invisible",children:m||0}),!n&&o!=="normal"&&$e("span",{ref:U,className:"ml-2 font-light uppercase",style:{color:"var(--widget-foreground)",opacity:.5,fontSize:`${p}px`},children:t?.symbol?t.symbol.length>6?`${t.symbol.slice(0,6)}...`:t.symbol:N}),(n||o==="normal")&&$e("span",{ref:U,className:"hidden"})]})})},Ts=Br;import{Fragment as lt,jsx as W,jsxs as pe}from"react/jsx-runtime";var qr=({toggle:e,side:t,asset:r,isPlacingOrder:c,hideDropdown:l})=>{let{baseBalance:s,quoteBalance:a}=Ie(),{tokenDisplay:y,tokenBadgeOrientation:g,widgetType:d}=Ae(),o=d==="compact",n=o?"h-10":"h-12",v=o?"h-10 w-10":"h-12 w-12",w=t==="base"?s.formatted?(()=>{let h=parseFloat(s.formatted);return h>=1e8?Ee(h):h.toFixed(3)})():void 0:a.formatted?(()=>{let h=parseFloat(a.formatted);return h>=1e8?Ee(h):h.toFixed(3)})():void 0,u={role:"button",tabIndex:c?-1:0,"aria-disabled":c,"aria-label":`Select ${t==="base"?"input":"output"} token${r?`: ${r.symbol}`:""}`,onClick:c?void 0:e,onKeyDown:c?void 0:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),e())}};return y==="pill"?W("div",{...u,className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-full cursor-pointer transition-colors ${g==="right"?"ml-auto":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-secondary)",color:"var(--widget-secondary-foreground)"},children:r?pe(lt,{children:[W(we,{chain:r.chainId,size:"xs"}),W(re,{className:"rounded-full",asset:r,size:"xxs",noChain:!0}),W("span",{className:"text-xs font-medium uppercase",children:r.symbol}),!l&&W(We,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]}):pe(lt,{children:[W("span",{className:"text-xs opacity-70",children:"Select"}),!l&&W(We,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]})}):y==="ghost"?pe("div",{...u,className:"inline-flex items-center gap-1.5 cursor-pointer transition-opacity hover:opacity-70 py-1",style:{color:"var(--widget-foreground)"},children:[r?pe(lt,{children:[W(we,{chain:r.chainId,size:"xs"}),W(re,{className:"rounded-full",asset:r,size:"xxs",noChain:!0}),W("span",{className:"text-sm font-medium uppercase",children:r.symbol})]}):W("span",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Select token"}),!l&&W(We,{className:"w-1.5 opacity-50"})]}):W("div",{...u,className:`relative ${n} w-full cursor-pointer text-xl duration-100 ease-linear`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-secondary)",borderTopLeftRadius:"9999px",borderBottomLeftRadius:"9999px",borderTopRightRadius:"var(--widget-radius)",borderBottomRightRadius:"var(--widget-radius)"},children:W("div",{className:"relative flex h-full w-full flex-row items-center",children:r?pe("div",{className:"relative flex h-full w-full flex-row items-center",children:[W("div",{className:`${v} pl-px flex items-center justify-center`,children:W(re,{className:"rounded-full",asset:r,size:"md"})}),pe("div",{className:"flex h-full w-full flex-row items-center justify-between pl-1.5 pr-7",children:[pe("div",{className:"flex h-full flex-col justify-center",children:[W("p",{className:"text-sm font-medium uppercase",style:{color:"var(--widget-secondary-foreground)"},children:r.symbol}),pe("span",{className:"text-2xs font-mono",style:{color:"var(--widget-secondary-foreground)",opacity:.6},children:[r.address?.slice(0,6),"...",r.address?.slice(-4)]})]}),w!==void 0&&pe("div",{className:"flex flex-col text-right",children:[W("p",{className:"text-2xs",style:{color:"var(--widget-secondary-foreground)",opacity:.5},children:"Balance"}),W("span",{className:"font-mono text-xs tabular-nums",style:{color:"var(--widget-secondary-foreground)"},children:w})]})]}),!l&&W(We,{className:"absolute right-3 top-1/2 w-1.5 translate-y-[-50%]",style:{color:"var(--widget-secondary-foreground)",opacity:.6}})]}):W("div",{className:"flex h-full w-full items-center justify-center",children:W("span",{className:"text-sm",style:{color:"var(--widget-secondary-foreground)",opacity:.7},children:"Select token"})})})})},Is=qr;var Wt=Cr(Sr(),1);import{useState as qe,useEffect as Qe}from"react";import{jsx as G,jsxs as Lt}from"react/jsx-runtime";var Qr=()=>{let[e,t]=qe(null),[r,c]=qe(""),l=At(r,1e3),[s,a]=qe(!1),[y,g]=qe("");Qe(()=>{ae.getState().setRecipient(e)},[e]),Qe(()=>{c(e||"")},[e]);let d=n=>{let v=n.target.value;s&&(a(!1),g(""),t(null)),c(v),v===""&&t(null)};Qe(()=>{l===""||!l?(a(!1),g(""),t(null)):Rt(l)?(a(!1),g(""),t(l)):(a(!0),g("Invalid wallet address..."),t(null),c(""))},[l]),Qe(()=>{if(s){let n=setTimeout(()=>{t(null),c(""),a(!1),g("")},2e3);return()=>clearTimeout(n)}},[s]);let o=()=>{t(null),c(""),a(!1),g("")};return G("div",{className:"w-full",children:Lt("div",{className:"relative flex flex-row items-center",children:[G("input",{type:"password",style:{display:"none"},"aria-hidden":"true",tabIndex:-1}),G("label",{htmlFor:"recipient-address",className:"sr-only",children:"Recipient wallet address"}),G("div",{className:"absolute left-3 flex h-6 w-6 items-end justify-center overflow-hidden rounded-full",style:{backgroundColor:"var(--widget-secondary)"},children:e&&!s?G("img",{className:"h-full w-full rounded-full object-cover",src:(0,Wt.makeGradient)(e),alt:"Recipient avatar"}):G(Nt,{className:"h-5 w-5",style:{color:s?"var(--widget-destructive)":"var(--widget-muted-foreground)"}})}),G("div",{className:"absolute left-12 top-1.5 -translate-y-1 text-xs font-medium opacity-60",style:{color:s?"var(--widget-destructive)":"var(--widget-muted-foreground)"},"aria-hidden":"true",children:"To:"}),G("input",{id:"recipient-address",className:"mono block h-10 w-full items-center pl-12 pt-4 pr-8 text-xs",style:{backgroundColor:s?"color-mix(in srgb, var(--widget-destructive) 10%, transparent)":"transparent",color:s?"var(--widget-destructive)":"var(--widget-foreground)",outline:"none",opacity:s?.9:1},placeholder:s?y:"Enter recipient address...",value:r,onChange:d,spellCheck:!1,"aria-invalid":s,"aria-describedby":s?"recipient-error":void 0}),s&&G("span",{id:"recipient-error",className:"sr-only",children:y}),e&&!s&&Lt("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 cursor-pointer flex items-center justify-center h-4 w-4 rounded-full transition-colors hover:[color:var(--widget-destructive)]",style:{color:"var(--widget-muted-foreground)"},onClick:o,"aria-label":"Clear recipient",children:[G("svg",{className:"h-2.5 w-2.5",viewBox:"0 -0.5 21 21",fill:"none",children:G("g",{fill:"currentColor",fillRule:"evenodd",children:G("polygon",{points:"375.0183 90 384 98.554 382.48065 100 373.5 91.446 364.5183 100 363 98.554 371.98065 90 363 81.446 364.5183 80 373.5 88.554 382.48065 80 384 81.446",transform:"translate(-363 -80)"})})}),G("span",{className:"sr-only",children:"Clear recipient"})]})]})})},Ws=Qr;import{jsx as Dt,jsxs as jr}from"react/jsx-runtime";function _s(e){return jr("svg",{width:"485",height:"484",viewBox:"0 0 485 484",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[Dt("path",{d:"M265.974 52.8127C270.567 50.9299 273.227 53.6338 275.917 56.1595C301.879 80.5364 327.828 104.927 353.786 129.308C380.101 154.024 406.44 178.715 432.721 203.467C436.002 206.557 440.744 209.272 438.226 215.021C435.865 220.415 430.758 219.123 426.424 219.124C305.965 219.169 185.506 219.163 65.0464 219.166C53.0995 219.166 49.0676 215.225 49.0125 203.316C48.9563 191.154 48.9813 178.991 48.9973 166.829C49.0119 155.717 53.3581 151.358 64.4131 151.358C127.892 151.357 191.37 151.364 254.849 151.368C262.591 151.368 262.645 151.344 262.588 143.559C262.388 116.237 262.191 88.914 261.918 61.5922C261.883 58.0834 262.161 54.9042 265.974 52.8127Z",fill:"currentColor"}),Dt("path",{d:"M80.5649 300.432C71.3447 291.747 62.4175 283.264 53.4064 274.87C50.4552 272.122 47.8959 269.327 49.7894 264.946C51.6154 260.72 55.4624 260.923 59.1682 260.923C164.476 260.927 269.785 260.932 375.093 260.935C391.422 260.935 407.752 260.9 424.081 260.933C434.679 260.955 438.994 265.286 439.015 275.854C439.04 288.517 439.048 301.181 439.013 313.845C438.985 324.225 434.466 328.73 424.01 328.732C360.359 328.741 296.707 328.729 233.056 328.714C225.392 328.713 225.368 328.686 225.426 336.583C225.628 363.741 225.815 390.9 226.101 418.057C226.142 421.935 225.905 425.512 221.852 427.329C217.686 429.197 214.934 426.578 212.212 424.02C172.068 386.302 131.922 348.587 91.7738 310.874C88.1374 307.459 84.4753 304.07 80.5649 300.432Z",fill:"currentColor"})]})}var Hr=["SUCCEEDED","FAILED","COMPLETED","CANCELLED"];async function Vt(e,t,r={}){let{onStatusChange:c,onComplete:l,onError:s,interval:a=4e3,timeout:y=3e5,txHash:g,signal:d}=r,o=null,n=Date.now(),v=0,w=8,u=null,h=g?`?txHash=${g}`:"";return new Promise((f,i)=>{let p=async()=>{try{if(d?.aborted){u&&clearTimeout(u),i(new DOMException("Polling aborted","AbortError"));return}if(Date.now()-n>y){u&&clearTimeout(u);let P=new Error("Order status polling timed out");s?.(P),i(P);return}let x=await fetch(`${t}/status/${e}${h}`,{headers:Ne(),signal:d});if(x.status===404){u=setTimeout(p,a);return}if(!x.ok)throw new Error(`Failed to fetch order status: ${await x.text()}`);let m=await x.json();if(!m||typeof m!="object"||!m.status)throw new Error(`Invalid status response format: ${JSON.stringify(m)}`);v=0;let k=m.status.toUpperCase();if(k!==o&&(o=k,c?.(m)),Hr.includes(k)){u&&clearTimeout(u),l?.(m),f(m);return}u=setTimeout(p,a)}catch(x){if(x instanceof Error&&x.name==="AbortError"){u&&clearTimeout(u),i(x);return}if(++v>=w){u&&clearTimeout(u);let m=x instanceof Error?x:new Error(String(x));s?.(m),i(m);return}u=setTimeout(p,a)}};p()})}import{useCallback as je,useEffect as Gr,useRef as He}from"react";function _t(e){let t=e.toUpperCase();return t==="SUCCEEDED"||t==="COMPLETED"?"completed":t==="FAILED"?"failed":t==="CANCELLED"?"cancelled":t==="PROCESSING"?"received":"pending"}var Ft=e=>{let t=He(new Map),r=He(new Map),c=He(new Map),l=He(0),s=je(()=>++l.current,[]),{address:a}=oe(),y=Oe(),g=je((n,v)=>{if(t.current.get(n))return;v&&r.current.set(n,v),t.current.set(n,!0);let w=l.current,u=new AbortController;c.current.set(n,u);let h=v?.baseToken?.chainId===1;Vt(n,ke(),{interval:h?1e3:500,timeout:3e5,signal:u.signal,onStatusChange:f=>{if(!f?.status)return;let i=_t(f.status);if(e?.(n,i,f.explorerUrl),i==="completed"&&a){let p=r.current.get(n);if(p&&(p.baseToken||p.quoteToken)){let x=[];p.baseToken&&x.push({asset:p.baseToken,userAddress:a}),p.quoteToken&&x.push({asset:p.quoteToken,userAddress:a}),y({type:"swap",tokens:x})}}["completed","failed","cancelled"].includes(i)&&(t.current.delete(n),r.current.delete(n)),w!==l.current&&(t.current.delete(n),r.current.delete(n))},onComplete:f=>{f?.status&&e?.(n,_t(f.status),f.explorerUrl),t.current.delete(n),r.current.delete(n)},onError:()=>{t.current.delete(n),r.current.delete(n)}}).catch(f=>{f instanceof Error&&f.name==="AbortError"||(t.current.delete(n),r.current.delete(n),c.current.delete(n))})},[a,y,e]),d=je(n=>{let v=c.current.get(n);v&&(v.abort(),c.current.delete(n)),s(),t.current.delete(n),r.current.delete(n)},[s]),o=je(()=>{for(let n of c.current.values())n.abort();c.current.clear(),s(),t.current.clear(),r.current.clear()},[s]);return Gr(()=>()=>o(),[o]),{startPolling:g,stopPolling:d,stopAllPolling:o,isPolling:n=>t.current.has(n)}};import{createContext as Kr,useContext as Xr}from"react";var Yr=Kr({registerTransaction:()=>{},enabled:!1}),Bt=()=>Xr(Yr);import{signTypedData as Jr}from"viem/actions";function qt(e){return e instanceof Error?e.name==="UserRejectedRequestError"||e.message.includes("User rejected")||e.message.includes("rejected")||e.message.includes("denied")||e.message.includes("cancelled")||e.message.includes("canceled"):!1}async function zt(e){if(e.chain?.id)return e.chain.id;let t=e.getChainId?.();return t!=null?await t:null}var Zr=async(e,t)=>{try{if(await zt(e)===t)return!0;if(e.request)await e.request({method:"wallet_switchEthereumChain",params:[{chainId:`0x${t.toString(16)}`}]});else if(e.switchChain)await e.switchChain({id:t});else if(e.send)await e.send("wallet_switchEthereumChain",[{chainId:`0x${t.toString(16)}`}]);else throw new Error("Wallet doesn't support chain switching");return await zt(e)===t}catch(r){throw qt(r)?new Error("User rejected the chain switch request"):new Error(`Please switch your wallet to the required network (Chain ID: ${t})`)}},Qt=async e=>{let{quote:t,signatureStep:r,userAddress:c,walletClient:l}=e;if(!l)throw new Error("Wallet client not available");if(r.type!=="SIGNATURE"||!r.signature?.typedData)throw new Error("Invalid signature step");try{let s=r.signature.typedData,a={...s.message};for(let o of["inputAmount","outputAmount","startTime","endTime"])a[o]!=null&&(a[o]=BigInt(a[o]));let y=s.domain;if(y.chainId!=null){let o=Number(y.chainId);await Zr(l,o)}let g=await Jr(l,{account:c,domain:y,types:s.types,primaryType:s.primaryType,message:a}),d=await fetch(`${ke()}/submit-signature`,{method:"POST",headers:Ne(),body:JSON.stringify({quoteId:t.id,signatures:[g]})});if(!d.ok){let o=await d.json().catch(()=>({}));throw new Error(o?.message||`Submit failed: ${d.status}`)}return{quoteId:t.id,signature:g}}catch(s){throw qt(s)?new Error("User rejected the signing request"):s instanceof Error&&s.message.includes("chain")?new Error("Chain switching failed. Please manually switch to the correct network."):s}};var jt="vt_submitted_quotes";var ut=()=>{try{let e=localStorage.getItem(jt);return e?JSON.parse(e):[]}catch{return[]}},Ht=e=>{try{localStorage.setItem(jt,JSON.stringify(e))}catch{}},en=e=>{let t=Date.now(),r=typeof e=="string"?new Date(e).getTime():e>9999999999?e:e*1e3;return t<r+3e4},tn=e=>ut().some(t=>t.quoteId===e),Gt=(e,t)=>tn(e)?{canSubmit:!1,reason:"Order already submitted"}:en(t)?{canSubmit:!0}:{canSubmit:!1,reason:"Quote has expired"},Kt=(e,t)=>{let r=typeof t=="string"?new Date(t).getTime():t,c=ut();c.push({quoteId:e,submittedAt:Date.now(),createdAt:r}),Ht(c)},Xt=()=>{let e=ut(),t=Date.now(),r=300*1e3,c=e.filter(l=>t-l.submittedAt<r);c.length!==e.length&&Ht(c)};import{useMutation as rn}from"@tanstack/react-query";import{waitForTransactionReceipt as nn}from"@wagmi/core";import{wethAbi as sn}from"abitype/abis";import{useConfig as on}from"wagmi";function Yt(){let e=on();return rn({mutationFn:async({chainId:t,accountAddress:r,amountRaw:c,writeContractAsync:l})=>{let s=z(t);if(!s)throw new Error(`No wrapping contract for chain ${t}`);let a=s.wrappedAsset.address,y=await l({abi:sn,functionName:"withdraw",address:a,account:r,args:[c],chainId:t});if((await nn(e,{hash:y,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Unwrap transaction did not get successful receipt");return{success:!0,hash:y}}})}import{useMutation as an}from"@tanstack/react-query";import{waitForTransactionReceipt as cn}from"@wagmi/core";import{wethAbi as ln}from"abitype/abis";import{useConfig as un}from"wagmi";function Jt(){let e=un();return an({mutationFn:async({chainId:t,accountAddress:r,amountRaw:c,writeContractAsync:l})=>{let s=z(t);if(!s)throw new Error(`No wrapping contract for chain ${t}`);let a=s.wrappedAsset.address,y=await l({abi:ln,functionName:"deposit",address:a,account:r,value:c,chainId:t});if((await cn(e,{hash:y,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Wrap transaction did not get successful receipt");return{success:!0,hash:y}}})}import{useCallback as fe,useEffect as Se,useRef as yr,useState as jn}from"react";import{useChainId as Hn}from"wagmi";import{useCallback as Zt,useRef as dn}from"react";function er(){let{registerTransaction:e,enabled:t}=Bt(),r=dn(new Set),c=Zt((s,a)=>{!t||r.current.has(s)||(r.current.add(s),e(s,a))},[t,e]),l=Zt((s,a)=>{!t||r.current.has(s)||(r.current.add(s),e(s,a))},[t,e]);return{trackOrderTransaction:c,trackNativeTransaction:l,txTrackingEnabled:t}}import{useEffect as tr,useState as pn,useCallback as rr,useRef as dt}from"react";import{useAccount as mn,useChainId as fn,useSwitchChain as gn}from"wagmi";import{jsx as ye,jsxs as pt}from"react/jsx-runtime";var wn=15e3,Ge="chain",hn=({needsChainSwitch:e,requiredChain:t,reviewState:r,goToNextStep:c,cancel:l})=>{let s=se(Ge,r),[a,y]=pn("pending"),g=dt(!1),d=dt(!1),o=dt(null),n=fn(),{switchChainAsync:v}=gn(),{status:w,isReconnecting:u}=mn(),h=rr(()=>{o.current&&(clearTimeout(o.current),o.current=null)},[]),f=rr(async()=>{if(!(g.current||d.current||w!=="connected"||u)){g.current=!0,d.current=!0,y("pending"),o.current=setTimeout(()=>{g.current&&(y("error"),g.current=!1)},wn);try{await v({chainId:t.chainId}),h(),y("success"),c(Ge,r)}catch{h(),y("error")}finally{g.current=!1}}},[v,w,u,t.chainId,c,r,h]);tr(()=>{g.current||d.current||r===Ge&&a==="pending"&&w==="connected"&&!u&&(e&&n!==t.chainId?f():(y("success"),c(Ge,r)))},[r,a,e,n,t.chainId,w,u,f,c]),tr(()=>()=>h(),[h]);let i=()=>{a==="error"&&(d.current=!1,y("pending"))},p=!s&&a==="error",x=!s&&(a==="pending"||a==="error"),m=p?"var(--widget-status-failed)":"var(--widget-primary)";return pt("div",{className:"flex w-full flex-row justify-between space-x-3",children:[ye("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${p?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${m} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${m} 20%, transparent)`,color:m,borderRadius:"var(--widget-radius)"},onClick:p?i:void 0,children:pt("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[ye(we,{chain:t.chainId,size:"xs"}),ye("p",{className:"whitespace-nowrap",children:p?"Retry Switch":`Switch to ${t.name}`}),ye("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),pt("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!s&&a==="pending"&&ye(H,{size:"5"}),(s||a==="success")&&ye(Y,{className:"h-8 w-8"}),p&&ye(he,{className:"h-[12px] w-[12px]"})]})]})}),x&&ye("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:l,children:"Cancel"})]})},nr=hn;import{waitForTransactionReceipt as bn}from"@wagmi/core";import{useCallback as Ke,useEffect as Xe,useState as xn,useRef as cr}from"react";import{useAccount as Cn,useConfig as Sn,useSendTransaction as Tn,useSwitchChain as Rn,useWalletClient as An}from"wagmi";import{useEffect as sr,useRef as or,useState as ar}from"react";import{jsx as vn}from"react/jsx-runtime";var yn=({startTime:e,onExpired:t})=>{let[r,c]=ar(30),[l,s]=ar(!1),a=or(!1),y=or(t);y.current=t,sr(()=>{a.current=!1},[e]),sr(()=>{let d=()=>{let n=Date.now(),w=(e>9999999999?e:e*1e3)+30*1e3,u=Math.max(0,w-n),h=Math.floor(u/1e3);if(h<=0){c(0),a.current||(a.current=!0,s(!0),y.current());return}c(h),s(!1)};if(l)return;d();let o=setInterval(d,1e3);return()=>clearInterval(o)},[e,l]);let g=d=>{let o=Math.floor(d/60),n=d%60;return`${o.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`};return l?null:vn("span",{className:"text-xs font-mono",children:g(r)})},ir=yn;import{jsx as me,jsxs as mt}from"react/jsx-runtime";function kn(e){return e.name==="UserRejectedRequestError"||e.message.includes("User rejected")||e.message.includes("rejected")||e.message.includes("denied")||e.message.includes("cancelled")||e.message.includes("canceled")}var ve="signingOrder";async function Nn(e,t,r,c,l){let s=e.transaction?.encoded,a=s?.to??e.to,y=s?.data??e.data,g=s?.value??e.value;if(!a)throw new Error('Transaction step missing "to" address');let d=s?.chainId,o=e.chainKey||l,n=d||(o?rt(o):void 0);if(!n)throw new Error(`Unknown chain: ${o}`);let v=Ct()[n],w=await r({account:t,chain:v,to:a,data:y||"0x",value:BigInt(g||"0")});return await bn(c,{hash:w,chainId:n}),w}var En=({base:e,baseAmount:t,quote:r,quoteAmount:c,userAddress:l,reviewState:s,goToNextStep:a,cancel:y,isWrappingPair:g,isUnwrappingPair:d,restartSigningFlow:o,onSwapInitiated:n,onOrderSubmitted:v,onSwapComplete:w,startPolling:u,trackNativeTransaction:h})=>{let f=se(ve,s),[i,p]=xn("idle"),x=cr(!1),m=cr(null),k=Sn(),{isReconnecting:P}=Cn(),{rfqQuote:S,stop:U,refresh:L}=Be(),{data:N}=An({chainId:e.chainId}),{switchChain:E}=Rn(),{sendTransactionAsync:A}=Tn(),M=S?._receivedAt??0,V=Ke(()=>M?Date.now()>=M+30*1e3:!1,[M]),ce=Ke(async()=>{if(x.current||!["idle","error"].includes(i))return;if(!S?.id||!S?._receivedAt){p("error");return}if(!Gt(S.id,S._receivedAt).canSubmit){p("stale");return}x.current=!0;try{if(!N)throw new Error("Wallet client not available");Xt();let T=S.userSteps??[],$;for(let O of T)if(O.type==="TRANSACTION"){p("submitting");let q=O.chainKey||S.srcChainKey,Z=q?rt(q):void 0;Z&&N.chain?.id!==Z&&(await E({chainId:Z}),await new Promise(Ve=>setTimeout(Ve,800))),$=await Nn(O,l,A,k,S.srcChainKey),h($,O.description||`Tx on ${q}`)}else O.type==="SIGNATURE"&&(p("signing"),await Qt({quote:S,signatureStep:O,userAddress:l,walletClient:N}));Kt(S.id,S._receivedAt),v?.(S.id),u(S.id,{baseToken:e,quoteToken:r}),n?.(),U(),p("success"),a(ve,s),w?.(S.id)}catch(T){T instanceof Error&&kn(T)?(m.current=null,p("idle")):p("error")}finally{x.current=!1}},[i,S,N,e,r,l,U,u,a,s,w,E,A,n,v,h,k]);Xe(()=>{if(s===ve&&U(),f&&i!=="success"){p("success"),a(ve,s);return}if(i==="success"){a(ve,s);return}if(s===ve&&i==="idle"&&!S?.id){p("refreshingQuote"),L();return}if(s===ve&&i==="idle"&&N&&!x.current&&!P){let C=S?.id||null;C&&m.current!==C&&(m.current=C,ce())}},[f,s,i,N,P,ce,a,S?.id,L,U]),Xe(()=>{i==="refreshingQuote"&&S?.id&&p("idle")},[i,S?.id]),Xe(()=>{s!==ve&&(m.current=null)},[s]),Xe(()=>{let C=setInterval(()=>{V()&&!x.current&&i!=="submitting"&&i!=="success"&&p("stale")},1e3);return()=>clearInterval(C)},[V,i]);let K=()=>{i==="error"&&!x.current&&(m.current=null,p("idle"))},D=Ke(()=>{m.current=null,p("refreshingQuote"),L()},[L]),I=Ke(()=>{o?o(!0):y()},[o,y]),F=()=>i==="error"?"Retry swap":i==="signing"?"Sign Swap Order":i==="submitting"?"Submitting...":i==="refreshingQuote"?"Refreshing Quote...":i==="stale"?"Quote Stale":"Sign & Submit",B=!f&&(i==="error"||i==="stale"),X=B?"var(--widget-status-failed)":"var(--widget-primary)";return mt("div",{className:"flex w-full flex-row justify-between space-x-3",children:[me("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${B?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${X} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${X} 20%, transparent)`,color:X,borderRadius:"var(--widget-radius)"},onClick:!f&&i==="error"?K:i==="stale"?I:void 0,children:mt("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[me(re,{asset:e,size:"xs",noChain:!0}),me("p",{className:"whitespace-nowrap",children:F()}),me("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),M>0&&i!=="success"&&i!=="error"&&i!=="stale"&&me(ir,{startTime:M,onExpired:()=>p("stale")}),mt("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!f&&(i==="idle"||i==="signing"||i==="submitting"||i==="refreshingQuote")&&me(H,{size:"5"}),(f||i==="success")&&me(Y,{className:"h-8 w-8"}),!f&&(i==="error"||i==="stale")&&me(he,{className:"h-[12px] w-[12px]"})]})]})}),!f&&i==="error"&&me("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:y,children:"Cancel"})]})},lr=En;import{useEffect as In}from"react";import{jsx as J,jsxs as $n}from"react/jsx-runtime";var On="trackingTx",ur={pending:{icon:J(H,{size:"5"}),buttonText:"Trade Pending",showNewSwap:!1,statusVar:"var(--widget-primary)",clickable:!1},received:{icon:J(H,{size:"5"}),buttonText:"Trade Received",showNewSwap:!1,statusVar:"var(--widget-primary)",clickable:!1},completed:{icon:J(Y,{}),buttonText:"Continue Swapping",showNewSwap:!0,statusVar:"var(--widget-status-completed)",clickable:!0},failed:{icon:J(De,{}),buttonText:"Retry Swap",showNewSwap:!0,statusVar:"var(--widget-status-failed)",clickable:!0},cancelled:{icon:J(De,{}),buttonText:"Continue Swapping",showNewSwap:!0,statusVar:"var(--widget-status-failed)",clickable:!0}},Pn=({orderHash:e,base:t,quote:r,baseAmount:c,quoteAmount:l,reviewState:s,onNewSwap:a,onRetry:y,status:g})=>{let d=se(On,s),o=ur[g]||ur.pending;In(()=>{if(g==="completed"){let w=setTimeout(a,5e3);return()=>clearTimeout(w)}},[g,a]);let n=()=>{g==="failed"?y():o.showNewSwap&&a()},v=o.statusVar;return J("div",{className:"flex flex-row justify-between space-x-3 w-full px-4",children:J("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${o.clickable?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${v} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${v} 20%, transparent)`,color:v,borderRadius:"var(--widget-radius)"},onClick:o.showNewSwap?n:void 0,children:$n("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[J("div",{className:"flex h-6 w-6 items-center justify-center rounded-full",children:o.icon}),J("p",{className:"whitespace-nowrap",children:o.buttonText}),J("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),o.showNewSwap&&J("div",{className:"flex h-6 w-6 items-center justify-center",children:J(Et,{})})]})})})},dr=Pn;import{useCallback as pr,useEffect as mr,useState as Un,useRef as ft}from"react";import{parseUnits as Mn}from"viem";import{useAccount as Ln,useWriteContract as Wn}from"wagmi";import{jsx as xe,jsxs as gt}from"react/jsx-runtime";var Dn=15e3,Ye="unwrapping",Vn=({needsToUnwrap:e,amount:t,chainId:r,token:c,reviewState:l,setReviewState:s,goToNextStep:a,cancel:y,delayedClose:g})=>{let d=se(Ye,l),[o,n]=Un("idle"),v=Yt(),{writeContractAsync:w}=Wn(),{address:u}=oe(),h=Oe(),f=ft(!1),i=ft(!1),p=ft(null),{status:x}=Ln(),m=pr(()=>{p.current&&(clearTimeout(p.current),p.current=null)},[]),k=pr(async()=>{if(!(f.current||i.current||!u||x!=="connected")){f.current=!0,i.current=!0,n("pending"),p.current=setTimeout(()=>{f.current&&(n("error"),f.current=!1)},Dn);try{let N=z(r);if(!N)throw new Error(`No config for chain ${r}`);let E=N.wrappedAsset.decimals??N.nativeAsset.decimals,A=Mn(t.toString(),E);await v.mutateAsync({chainId:r,accountAddress:u,amountRaw:A,writeContractAsync:w});let M={symbol:N.nativeAsset.symbol,name:N.nativeAsset.name,address:Fe,decimals:N.nativeAsset.decimals,chainId:r},V={symbol:N.wrappedAsset.symbol,name:N.wrappedAsset.name,address:N.wrappedAsset.address,decimals:N.wrappedAsset.decimals,chainId:r};h({type:"unwrap",tokens:[{asset:M,userAddress:u},{asset:V,userAddress:u}]}),m(),n("success"),a(Ye,l),await g()}catch{m(),n("error")}finally{f.current=!1}}},[u,x,r,t,v,w,h,a,l,g,m]);mr(()=>{f.current||i.current||l===Ye&&o==="idle"&&x==="connected"&&(e?k():(n("success"),a(Ye,l)))},[l,o,e,x,k,a]),mr(()=>()=>m(),[m]);let P=()=>{o==="error"&&(i.current=!1,n("idle"))},S=!d&&o==="error",U=!d&&(o==="pending"||o==="idle"||o==="error"),L=S?"var(--widget-status-failed)":"var(--widget-primary)";return gt("div",{className:"flex w-full flex-row justify-between space-x-3",children:[xe("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${S?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${L} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${L} 20%, transparent)`,color:L,borderRadius:"var(--widget-radius)"},onClick:S?P:void 0,children:gt("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[xe("p",{className:"whitespace-nowrap",children:S?"Retry Unwrap":c?`Unwrap ${c.symbol}`:"Unwrap Native Token"}),xe("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),gt("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!d&&(o==="pending"||o==="idle")&&xe(H,{size:"5"}),(d||o==="success")&&xe(Y,{className:"h-8 w-8"}),S&&xe(he,{className:"h-[12px] w-[12px]"})]})]})}),U&&xe("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:y,children:"Cancel"})]})},fr=Vn;import{useCallback as gr,useEffect as wr,useState as _n,useRef as wt}from"react";import{parseUnits as Fn}from"viem";import{useAccount as Bn,useWriteContract as zn}from"wagmi";import{jsx as Ce,jsxs as ht}from"react/jsx-runtime";var qn=15e3,Je="wrapping",Qn=({needsToWrap:e,amount:t,chainId:r,token:c,reviewState:l,setReviewState:s,goToNextStep:a,cancel:y,delayedClose:g,isWrappingPair:d})=>{let o=se(Je,l),[n,v]=_n("idle"),w=Jt(),{writeContractAsync:u}=zn(),{address:h}=oe(),f=Oe(),i=wt(!1),p=wt(!1),x=wt(null),{status:m}=Bn(),k=gr(()=>{x.current&&(clearTimeout(x.current),x.current=null)},[]),P=gr(async()=>{if(!(i.current||p.current||!h||m!=="connected")){i.current=!0,p.current=!0,v("pending"),x.current=setTimeout(()=>{i.current&&(v("error"),i.current=!1)},qn);try{let E=z(r);if(!E)throw new Error(`No config for chain ${r}`);let A=Fn(t.toString(),E.nativeAsset.decimals);await w.mutateAsync({chainId:r,accountAddress:h,amountRaw:A,writeContractAsync:u});let M={symbol:E.nativeAsset.symbol,name:E.nativeAsset.name,address:Fe,decimals:E.nativeAsset.decimals,chainId:r},V={symbol:E.wrappedAsset.symbol,name:E.wrappedAsset.name,address:E.wrappedAsset.address,decimals:E.wrappedAsset.decimals,chainId:r};f({type:"wrap",tokens:[{asset:M,userAddress:h},{asset:V,userAddress:h}]}),k(),v("success"),a(Je,l),d&&await g()}catch{k(),v("error")}finally{i.current=!1}}},[h,m,r,t,w,u,f,a,l,g,d,k]);wr(()=>{i.current||p.current||l===Je&&n==="idle"&&m==="connected"&&(e?P():(v("success"),a(Je,l)))},[l,n,e,m,P,a]),wr(()=>()=>k(),[k]);let S=()=>{n==="error"&&(p.current=!1,v("idle"))},U=!o&&n==="error",L=!o&&(n==="pending"||n==="idle"||n==="error"),N=U?"var(--widget-status-failed)":"var(--widget-primary)";return ht("div",{className:"flex w-full flex-row justify-between space-x-3",children:[Ce("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${U?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${N} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${N} 20%, transparent)`,color:N,borderRadius:"var(--widget-radius)"},onClick:U?S:void 0,children:ht("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[Ce("p",{className:"whitespace-nowrap",children:U?"Retry Wrap":c?`Wrap ${c.symbol}`:"Wrap Native Token"}),Ce("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),ht("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!o&&(n==="pending"||n==="idle")&&Ce(H,{size:"5"}),(o||n==="success")&&Ce(Y,{className:"h-8 w-8"}),U&&Ce(he,{className:"h-[12px] w-[12px]"})]})]})}),L&&Ce("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:y,children:"Cancel"})]})},hr=Qn;import{jsx as Q,jsxs as Gn}from"react/jsx-runtime";var Oa=({base:e,baseAmount:t,quote:r,quoteAmount:c,userAddress:l,isWrappingPair:s,isUnwrappingPair:a,isBaseGasToken:y,isQuoteGasToken:g,reviewActionProps:d,reviewState:o,setReviewState:n,trackedOrderHash:v,setTrackedOrderHash:w,txStatus:u,onSwapComplete:h,onSwapInitiated:f,onOrderSubmitted:i,onStaleQuoteRestart:p,setExitHandler:x,setRetryHandler:m})=>{let{rfqQuote:k,status:P,liquidityError:S,routingError:U,sizeCapError:L,stop:N,clear:E}=Be(),{clearForm:A}=Ie(),M=Hn(),{swapButtonVariant:V,widgetType:ce}=Ae(),K=ce==="compact",{trackOrderTransaction:D,trackNativeTransaction:I}=er(),{startPolling:F}=Ft((_,ge,Le)=>{ae.getState().setTxStatus(ge),Le&&ae.getState().setExplorerUrl(Le),ge==="completed"&&D(_,`Swap ${e.symbol} \u2192 ${r.symbol}`)}),[B,X]=jn(!1),C=yr(!1),T=yr(null),$=s,O=a,q=!s&&!a,Z=M!==e?.chainId&&($||O||q),Ve=z(e.chainId),_e={chainId:e.chainId,name:Ve?.displayName??`Chain ${e.chainId}`},j=fe((_,ge)=>{if(ge!==_)return;if(_==="chain"){if($){n("wrapping");return}if(O){n("unwrapping");return}n("signingOrder");return}if(_==="signingOrder"){n("trackingTx");return}if(_==="wrapping"){if(!s){n("signingOrder");return}n("wrapSuccess");return}if(_==="unwrapping"){n("wrapSuccess");return}let Le=Tt(_);Le&&n(Le)},[n,s,$,O,q]),le=fe(()=>Z?"chain":$?"wrapping":O?"unwrapping":q?"signingOrder":null,[Z,$,O,q]),ee=fe(()=>{n(null),A()},[A,n]),Te=fe(async()=>{n("wrapSuccess");for(let _=0;_<3;_++)await et(700);ee()},[ee,n]),te=fe(async()=>{E(),n("cancelled");for(let _=0;_<3;_++)await et(500);ee()},[E,ee,n]),ne=fe(()=>{v&&(ae.getState().stopTracking(),n(null),w(null),A())},[v,n,w,A]),Ue=fe(()=>{n(null),w(null),C.current=!0,p?.()},[n,w,p]),ue=fe(()=>{d&&n(le())},[le,d,n]),Ze=fe((_=!1)=>{_?(C.current=!0,n(null),p?.()):(n(null),T.current=setTimeout(()=>{d&&(n(le()),X(!1))},100))},[n,d,le,p]);Se(()=>{o!==null&&N()},[o,N]),Se(()=>{o!==null&&B&&X(!1)},[o,B]),Se(()=>{x?.(ne)},[x,ne]),Se(()=>(ae.getState().setExitHandler(ne),()=>ae.getState().setExitHandler(null)),[ne]),Se(()=>{m?.(Ue)},[m,Ue]),Se(()=>()=>{T.current&&clearTimeout(T.current)},[]),Se(()=>{C.current&&P==="fresh"&&k?.id&&(C.current=!1,n("signingOrder"))},[P,k?.id,n]);let Me=_=>{if(!_)return{backgroundColor:V==="default"?"var(--widget-muted)":"transparent",color:"var(--widget-muted-foreground)",border:V!=="default"?"1px solid var(--widget-border)":"none",borderRadius:"var(--widget-radius)"};switch(V){case"outline":return{backgroundColor:"transparent",color:"var(--widget-primary)",border:"1px solid var(--widget-primary)",borderRadius:"var(--widget-radius)"};case"ghost":return{backgroundColor:"transparent",color:"var(--widget-primary)",border:"none",borderRadius:"var(--widget-radius)"};default:return{backgroundColor:"var(--widget-primary)",color:"var(--widget-primary-foreground)",borderRadius:"var(--widget-radius)"}}},Re=`w-full ${K?"py-2":"py-3"} text-sm font-medium transition-colors cursor-pointer mt-1`;if(o===null&&!s&&!a){if(B)return Q("button",{className:Re,disabled:!0,style:{...Me(!1),opacity:.6,cursor:"not-allowed"},children:"Getting fresh quote..."});let _=()=>S?"Insufficient Liquidity":U?"Route Not Available":L?"Size Cap Exceeded":!k&&P==="polling"?"Getting Quote...":k?"Swap":"Enter Amount",ge=!!d;return Q("button",{onClick:ge?ue:void 0,disabled:!ge,className:`${Re} disabled:opacity-40 disabled:cursor-not-allowed`,style:Me(ge),children:_()})}return o===null&&a?Q("button",{onClick:d?ue:void 0,disabled:!d,className:`${Re} disabled:opacity-40 disabled:cursor-not-allowed`,style:Me(!!d),children:"Unwrap"}):o===null&&s?Q("button",{onClick:d?ue:void 0,disabled:!d,className:`${Re} disabled:opacity-40 disabled:cursor-not-allowed`,style:Me(!!d),children:"Wrap"}):o==="success"?Q("div",{className:"flex flex-col gap-2 w-full",children:Q("button",{className:`w-full ${K?"py-2":"py-3"} text-sm font-medium cursor-default`,style:{backgroundColor:"color-mix(in srgb, var(--widget-status-completed) 15%, transparent)",color:"var(--widget-status-completed)",border:"1px solid color-mix(in srgb, var(--widget-status-completed) 20%, transparent)",borderRadius:"var(--widget-radius)"},children:"Order Placed"})}):o==="wrapSuccess"?Q("div",{className:"flex flex-col gap-2 w-full",children:Q("button",{className:`w-full ${K?"py-2":"py-3"} text-sm font-medium cursor-default`,style:{backgroundColor:"color-mix(in srgb, var(--widget-status-completed) 15%, transparent)",color:"var(--widget-status-completed)",border:"1px solid color-mix(in srgb, var(--widget-status-completed) 20%, transparent)",borderRadius:"var(--widget-radius)"},children:s?"Wrapped Successfully":"Unwrapped Successfully"})}):o==="cancelled"?Q("div",{className:"flex flex-col gap-2 w-full",children:Q("button",{onClick:ee,className:`w-full ${K?"py-2":"py-3"} text-sm font-medium cursor-pointer`,style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 15%, transparent)",color:"var(--widget-status-failed)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",borderRadius:"var(--widget-radius)"},children:"Order Cancelled"})}):Gn("div",{className:"flex w-full",children:[o==="chain"&&Z&&Q(nr,{requiredChain:_e,needsChainSwitch:Z&&M!==e.chainId,reviewState:o,goToNextStep:j,cancel:te}),o==="wrapping"&&$&&Q(hr,{needsToWrap:$,amount:t,chainId:e.chainId,token:e,reviewState:o,setReviewState:n,goToNextStep:j,cancel:te,delayedClose:Te,isWrappingPair:s}),o==="unwrapping"&&O&&Q(fr,{needsToUnwrap:O,amount:t,chainId:e.chainId,token:e,reviewState:o,setReviewState:n,goToNextStep:j,cancel:te,delayedClose:Te}),o==="signingOrder"&&q&&Q(lr,{base:e,baseAmount:t,quote:r,quoteAmount:c,userAddress:l,reviewState:o,goToNextStep:j,cancel:te,restartSigningFlow:Ze,onSwapInitiated:f,onOrderSubmitted:i,isWrappingPair:s,isUnwrappingPair:a,onSwapComplete:h,startPolling:F,trackNativeTransaction:I}),o==="trackingTx"&&v&&Q(dr,{orderHash:v,base:e,quote:r,baseAmount:t,quoteAmount:c,reviewState:o,status:u,onNewSwap:ne,onRetry:Ue}),o&&!["chain","wrapping","unwrapping","approval","signingOrder","trackingTx","success","wrapSuccess","cancelled"].includes(o)&&Q("button",{disabled:!0,className:`w-full ${K?"py-2":"py-3"} text-sm font-medium`,style:{backgroundColor:"var(--widget-muted)",color:"var(--widget-muted-foreground)",borderRadius:"var(--widget-radius)"},children:"Processing..."})]})};import{useState as yt,useCallback as Kn,useRef as vt,useEffect as bt}from"react";import{useShallow as Xn}from"zustand/react/shallow";import{jsx as b,jsxs as R}from"react/jsx-runtime";var vr={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)"},Yn=({status:e})=>{let t=vr[e]??vr.pending;switch(e){case"completed":return b(Y,{className:"h-6 w-6"});case"failed":case"cancelled":return b(De,{className:"h-6 w-6"});default:return b(H,{size:"5",color:t})}};function Jn(e){if(e===0)return"0";let t=Math.abs(e);return t>=1e4?e.toFixed(0):t>=1e3?e.toFixed(1):t>=100?e.toFixed(2):t>=1?e.toFixed(4):t>=.01?e.toFixed(6):e.toExponential(3)}function br(e){try{let t=new URL(e).pathname.split("/"),r=t[t.length-1];return r&&r.startsWith("0x")?r:null}catch{return null}}function xr(e){let t=e.length;return t<=4?36:t<=6?32:t<=8?28:24}var xt=()=>R("svg",{className:"w-3 h-3 shrink-0",style:{color:"var(--widget-muted-foreground)"},viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b("path",{d:"M18 13V19C18 20.1046 17.1046 21 16 21H5C3.89543 21 3 20.1046 3 19V8C3 6.89543 3.89543 6 5 6H11",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),b("path",{d:"M15 3H21V9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),b("path",{d:"M10 14L21 3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Zn=()=>R("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 195 321",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[b("path",{fillRule:"evenodd",d:"M195,189C195,207.02,195,225.04,194.7,243.21C193.68,244.78,192.9,246.17,192.25,247.63C189.71,253.38,187.74,259.46,184.6,264.86C169.44,290.97,147.86,309.46,118.54,318.86C116.44,319.55,114.72,320.27,113,321C97.65,321,82.29,321,66.36,320.66C64.21,319.86,62.64,319.4,60.77,318.73C34.51,310.12,15.56,293.82,4.22,268.85C3.68,267.66,2.1,266.94,1,266C1,242.31,1,218.62,1.29,194.79C2.84,192.16,4.11,189.7,5.34,187.22C18.42,160.94,39.89,144.07,66.64,133.63C76.92,129.62,87.87,127.33,98.67,124.2C97.79,123.24,96.8,121.93,95.59,120.86C85.84,112.3,75.95,103.89,66.3,95.21C55.93,85.86,45.02,76.96,35.71,66.63C21.14,50.5,20.04,23.08,45.41,9.57C50.08,7.08,55.12,5.26,59.93,3.03C60.76,2.64,61.32,1.69,62,1C86.69,1,111.38,1,136.23,1.32C138.04,2.32,139.67,3.01,141.32,3.67C147.64,6.19,154.12,8.39,160.26,11.32C166.83,14.45,172.19,19.18,175.44,25.95C179.39,34.19,178.09,43.36,172.05,49.56C165.75,56.03,157.21,57.8,148.78,52.89C142.4,49.17,136.86,43.96,131.1,39.23C122.63,32.28,115.05,23.88,105.74,18.38C87.78,7.76,68.84,9.07,51.16,19.53C38.68,26.91,36.37,41.4,45.53,52.71C50.38,58.69,56.45,64,62.83,68.36C87.15,84.99,111.86,101.05,136.34,117.44C162.56,135,183.88,156.57,193.26,187.79C193.42,188.32,194.4,188.6,195,189ZM77.06,146.49C61.39,155.71,51.27,169.26,45.93,186.5C39.48,207.32,39.44,228.5,42.93,249.76C45.84,267.48,53.16,282.95,66.59,295.39C83.82,311.34,108.85,312.86,127.37,298.41C138.98,289.35,146.05,277.03,149.48,263.04C161.53,213.92,148.4,171.97,112.16,137.05C111.13,136.06,108.71,135.6,107.31,136.05C97.38,139.22,87.54,142.7,77.06,146.49Z"}),b("path",{d:"M118.83,199C121.61,197.69,122.77,198.41,122.77,201.27C122.71,217.43,122.78,233.58,122.65,249.73C122.65,250.83,121.43,251.92,120.77,253.01C119.97,252.05,118.63,251.17,118.45,250.1C116.32,237.7,113.36,235.12,100.61,235.02C98.12,235,95.62,234.98,93.12,235.01C81.26,235.16,77.72,238.3,75.94,249.84C75.74,251.15,74.39,252.28,73.57,253.49C73.11,253.23,72.64,252.98,72.17,252.73C72.17,234.81,72.17,216.88,72.17,198.96C72.49,198.62,72.81,198.28,73.13,197.93C74.09,198.95,75.72,199.85,75.92,201C78.13,213.8,80.95,216.26,94.05,216.3C97.38,216.31,100.72,216.44,104.04,216.27C113.28,215.79,117.15,212.05,118.22,202.81C118.35,201.65,118.47,200.49,118.83,199Z"})]}),es=({orderHash:e,base:t,quote:r,baseAmount:c,quoteAmount:l,status:s})=>{let[a,y]=yt(!1),[g,d]=yt(!0),o=vt(null),n=vt(Date.now()),[v,w]=yt(null),u=vt(null),{isRecipientInputOpen:h,recipient:f,explorerUrl:i}=ae(Xn(A=>({isRecipientInputOpen:A.isRecipientInputOpen,recipient:A.recipient,explorerUrl:A.explorerUrl})));bt(()=>{s==="received"&&(o.current=Date.now())},[s]),bt(()=>{if(s==="completed"&&!v){let A=o.current||n.current;w((Date.now()-A)/1e3)}},[s,v]),bt(()=>()=>{u.current&&clearTimeout(u.current)},[]);let p=Kn(()=>{if(!navigator.clipboard?.writeText)return;let A=i?br(i)??e:e;navigator.clipboard.writeText(A).then(()=>{y(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>y(!1),2e3)}).catch(()=>{})},[e,i]),x=Ee(c),m=Ee(l),k=s==="completed"||s==="failed"||s==="cancelled",P=!k,S=c&&l?c/l:0,U=z(t.chainId)?.displayName??`Chain ${t.chainId}`,L=z(r.chainId)?.displayName??`Chain ${r.chainId}`,N=i?br(i)??e:e,E=`${N.slice(0,6)} \u2026 ${N.slice(-4)}`;return R("div",{className:"relative w-full flex flex-col",children:[R("div",{className:"mx-4 mt-2",style:{backgroundColor:"var(--widget-secondary)"},children:[b("div",{className:"p-5",children:R("div",{className:"flex items-center justify-between",children:[R("div",{children:[R("div",{className:"flex items-center gap-3 mb-3",children:[b(re,{asset:t,size:"lg",noChain:!0}),R("div",{children:[b("p",{className:"text-lg font-medium uppercase",style:{color:"var(--widget-foreground)"},children:t.symbol}),b("p",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:t.name})]})]}),R("div",{className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1",style:{backgroundColor:"color-mix(in srgb, var(--widget-muted-foreground) 20%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-muted-foreground) 30%, transparent)"},children:[b(we,{chain:t.chainId,size:"xs"}),b("span",{className:"text-xs pt-0.5",style:{color:"var(--widget-secondary-foreground)",opacity:.5},children:U})]})]}),R("div",{className:"text-right",children:[b("p",{className:"font-light tracking-tight mono",style:{color:"var(--widget-foreground)",fontSize:`${xr(x)}px`,transition:"font-size 0.1s ease-out"},children:x}),t.price&&R("p",{className:"text-xs mt-1 mono",style:{color:"var(--widget-muted-foreground)"},children:["$",(t.price*c).toFixed(2)]})]})]})}),R("div",{className:"relative",children:[b("div",{style:{borderTop:"1px solid var(--widget-border)"}}),b("div",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",children:b("div",{className:"w-10 h-10 rounded-full flex items-center justify-center",style:{backgroundColor:"var(--widget-secondary)",border:"1px solid var(--widget-border)"},children:b(Yn,{status:s})})})]}),b("div",{className:"p-5",children:R("div",{className:"flex items-center justify-between",children:[R("div",{children:[R("div",{className:"flex items-center gap-3 mb-3",children:[b(re,{asset:r,size:"lg",noChain:!0}),R("div",{children:[b("p",{className:"text-lg font-medium uppercase",style:{color:"var(--widget-foreground)"},children:r.symbol}),b("p",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:r.name})]})]}),R("div",{className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1",style:{backgroundColor:"color-mix(in srgb, var(--widget-muted-foreground) 20%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-muted-foreground) 30%, transparent)"},children:[b(we,{chain:r.chainId,size:"xs"}),b("span",{className:"text-xs pt-0.5",style:{color:"var(--widget-secondary-foreground)",opacity:.5},children:L})]})]}),R("div",{className:"text-right",children:[b("p",{className:"font-light tracking-tight mono",style:{color:"var(--widget-foreground)",fontSize:`${xr(m)}px`,transition:"font-size 0.1s ease-out"},children:m}),r.price&&R("p",{className:"text-xs mt-1 mono",style:{color:"var(--widget-muted-foreground)"},children:["$",(r.price*l).toFixed(2)]})]})]})})]}),h&&f&&b("div",{className:"mx-4 mt-2 px-5 pb-2",children:R("div",{className:"flex items-center gap-2 p-2 rounded-full",style:{backgroundColor:"var(--widget-secondary)"},children:[b("div",{className:"flex h-5 w-5 items-center justify-center overflow-hidden rounded-full",style:{backgroundColor:"var(--widget-muted)"},children:b("span",{className:"text-2xs",children:"\u{1F464}"})}),b("span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:"To:"}),R("span",{className:"text-xs mono",style:{color:"var(--widget-foreground)"},children:[f.slice(0,6),"...",f.slice(-4)]})]})}),b("div",{className:"px-4 pt-4",children:R("div",{style:{borderTop:"1px solid var(--widget-border)"},className:"pt-3",children:[R("button",{type:"button",onClick:()=>d(!g),className:"w-full flex items-center justify-between font-mono text-xs py-1 cursor-pointer transition-colors",children:[R("div",{className:"flex items-center gap-1",children:[b(re,{asset:r,size:"3xs",noChain:!0,className:"mb-0.5"}),R("span",{className:"uppercase",style:{color:"var(--widget-foreground)"},children:["1 ",r.symbol]}),b("span",{style:{color:"var(--widget-muted-foreground)"},children:"="}),b(re,{asset:t,size:"3xs",noChain:!0,className:"mb-0.5"}),R("span",{className:"uppercase",style:{color:"var(--widget-foreground)"},children:[Jn(S)," ",t.symbol]}),t.price&&R("span",{style:{color:"var(--widget-muted-foreground)"},children:["\u2248 $",(t.price*S).toFixed(2)]})]}),b("span",{className:"ml-2 transition-transform duration-200",style:{color:"var(--widget-muted-foreground)",transform:g?"rotate(0deg)":"rotate(180deg)",display:"inline-block"},children:"\u25BE"})]}),b("div",{className:"overflow-hidden transition-all duration-200",style:{maxHeight:g?"200px":"0px",opacity:g?1:0},children:R("div",{className:"space-y-1 pt-2 mt-1 font-mono",style:{borderTop:"1px solid var(--widget-border)"},children:[R("div",{className:"flex items-center justify-between text-2xs",children:[b("span",{style:{color:"var(--widget-muted-foreground)"},children:"USD Value"}),R("span",{style:{color:"var(--widget-secondary-foreground)",opacity:.5},children:["$",t.price?(t.price*c).toFixed(2):"\u2014"]})]}),R("div",{className:"flex items-center justify-between text-2xs",children:[b("span",{style:{color:"var(--widget-muted-foreground)"},children:"Order Type"}),b("span",{style:{color:"var(--widget-secondary-foreground)",opacity:.5},children:"RFQ (Exact Fill)"})]}),R("div",{className:"flex items-center justify-between text-2xs",children:[b("span",{style:{color:"var(--widget-muted-foreground)"},children:"Transaction"}),i?R("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 transition-colors hover:opacity-80",style:{color:"var(--widget-secondary-foreground)",opacity:.5},children:[b("span",{children:a?"Copied!":E}),b(xt,{})]}):R("button",{type:"button",onClick:p,className:"flex items-center gap-1 cursor-pointer transition-colors",style:{color:"var(--widget-secondary-foreground)",opacity:.5},children:[b("span",{children:a?"Copied!":E}),b(xt,{})]})]}),R("div",{className:"flex items-center justify-between text-2xs",children:[b("span",{style:{color:"var(--widget-muted-foreground)"},children:k?"Speed":"Est. Time"}),b("span",{style:{color:"var(--widget-secondary-foreground)",opacity:.5},children:v?`${v.toFixed(2)}s`:"\u2014"})]}),R("div",{className:"flex items-center justify-between text-2xs",children:[b("span",{style:{color:"var(--widget-muted-foreground)"},children:"Route"}),R("a",{href:"https://www.aori.io/scan",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 transition-colors hover:opacity-80",style:{color:"var(--widget-secondary-foreground)",opacity:.5},children:[b(Zn,{}),"Aori",b(xt,{})]})]})]})}),b("div",{className:"mt-2",style:{borderBottom:"1px solid var(--widget-border)"}})]})})]})},Va=es;export{kr as a,Oe as b,as as c,fs as d,Be as e,_r as f,ys as g,Ts as h,Is as i,Ws as j,_s as k,Vt as l,Ft as m,Bt as n,Zr as o,Qt as p,en as q,Gt as r,Kt as s,Xt as t,Yt as u,Jt as v,Oa as w,Va as x};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{
|
|
2
|
+
import{B as E,E as N,N as A,o as R,p as W}from"./chunk-IF7S6ZES.js";import{a as S}from"./chunk-46H44R7V.js";import{useCallback as se,useRef as oe,useState as ne}from"react";import{useCallback as M,useEffect as Q,useMemo as Z,useRef as z,useState as w}from"react";var O="https://api.aori.io",b=50,G=100,D="0xFAfDdbb3FC7688494971a79cc65DCa3EF82079E7",U="megaeth";function K(e,s){let o=N(e.inputChain),r=N(e.outputChain),u=o?s(o,e.inputToken)??null:null,c=r?s(r,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:u,quote:c}}}function P(e,s){let{getToken:o}=E(),[r,u]=w([]),[c,f]=w(!1),[p,h]=w(null),[d,m]=w(b),n=z(null),i=M(async()=>{if(!e)return;n.current?.abort();let g=new AbortController;n.current=g,f(!0),h(null);try{let y={offerer:e,limit:String(G),page:"0"},[L,I]=await Promise.all([fetch(`${O}/data/query?${new URLSearchParams({...y,inputChain:U,inputToken:D})}`,{signal:g.signal}),fetch(`${O}/data/query?${new URLSearchParams({...y,outputChain:U,outputToken:D})}`,{signal:g.signal})]),_=L?.ok?await L.json():null,$=I?.ok?await I.json():null,H=new Set,C=[];for(let x of[..._?.orders??[],...$?.orders??[]])H.has(x.orderHash)||(H.add(x.orderHash),C.push(x));C.sort((x,V)=>V.timestamp-x.timestamp),u(C),m(b)}catch(y){if(y?.name==="AbortError")return;h(y?.message??"Failed to load order history")}finally{g.signal.aborted||f(!1)}},[e]);Q(()=>{if(!s||!e){u([]),m(b);return}return i(),()=>n.current?.abort()},[s,e,i]);let v=d<r.length,q=M(async()=>{v&&m(g=>Math.min(g+b,r.length))},[v,r.length]);return{orders:Z(()=>r.slice(0,d).map(g=>K(g,o)),[r,d,o]),isLoading:c,error:p,hasMore:v,loadMore:q,totalOrders:r.length}}import{useState as X}from"react";import{jsx as t,jsxs as l}from"react/jsx-runtime";var J=()=>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"})]}),Y=()=>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"})]}),ee=()=>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"})]}),F=()=>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"})]}),te=e=>{switch((e||"").toLowerCase()){case"completed":case"settled":case"success":case"swapped":case"swap":return{icon:t(J,{}),color:"var(--widget-primary)"};case"received":return{icon:t(F,{}),color:"var(--widget-accent)"};case"failed":case"error":case"expired":return{icon:t(Y,{}),color:"var(--widget-destructive)"};case"pending":case"created":case"placed":return{icon:t(ee,{}),color:"var(--widget-muted-foreground)"};default:return{icon:t(F,{}),color:"var(--widget-muted-foreground)"}}},re=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,s)=>{try{let o=parseFloat(e||"0");if(isNaN(o)||o===0)return"0";let r=s?.decimals??18;return R(o/10**r)}catch{return"0"}},B=({order:e,baseToken:s,quoteToken:o})=>{let[r,u]=X(!1),c=e?.status||e?.eventType||"unknown",{icon:f,color:p}=te(c),d=(i=>{if(!i)return{date:"",time:""};let v=new Date(typeof i=="number"?i:Number(i)||i);return{date:v.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),time:v.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",timeZone:"UTC",hour12:!1})+" UTC"}})(e?.timestamp||e?.createdAt||""),m=s?{asset:s,symbol:s.symbol,amount:k(e?.inputAmount,s)}:{asset:null,symbol:(e?.inputToken||"").slice(0,6)+"...",amount:k(e?.inputAmount,null)},n=o?{asset:o,symbol:o.symbol,amount:k(e?.outputAmount,o)}:{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:r?re(c):"transparent",marginBottom:"0.5rem",padding:"0.25rem"},onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!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:p},children:f}),t("p",{className:"text-2xs mono uppercase",style:{color:p},children:c})]}),l("div",{className:"flex flex-row items-center space-x-2",children:[l("span",{className:"text-2xs mono",style:{color:r?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:["\xAC ",W(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:r?"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(A,{asset:m.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:m.amount}),t("span",{className:"text-xs",style:{color:"var(--widget-foreground)"},children:m.symbol})]}),t("span",{className:"px-1",style:{color:"var(--widget-muted-foreground)"},children:"\u2192"}),t(A,{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:d.date}),d.time&&t("span",{className:"text-2xs mono whitespace-nowrap",style:{color:"var(--widget-muted-foreground)",opacity:.6},children:d.time})]})]})]})};import{Fragment as ae,jsx as a,jsxs as T}from"react/jsx-runtime";var j=()=>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,s)=>a("div",{className:"h-3 rounded",style:{width:`${e*4}px`,backgroundColor:"var(--widget-muted)"}},s))}),a("div",{className:"h-3 w-10 rounded",style:{backgroundColor:"var(--widget-muted)"}})]})]}),be=({isActive:e})=>{let{address:s}=S(),{orders:o,isLoading:r,error:u,hasMore:c,loadMore:f}=P(s,e),[p,h]=ne(!1),d=oe(null),m=se(async n=>{let i=n.currentTarget;if(i.scrollTop+i.clientHeight>=i.scrollHeight-100&&!r&&!p&&c){h(!0);try{await f()}finally{h(!1)}}},[r,p,c,f]);return s?u?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:d,className:"flex flex-col flex-1 min-h-0 overflow-y-auto p-2",onScroll:m,style:{backgroundColor:"transparent"},children:r?Array.from({length:5}).map((n,i)=>a(j,{},i)):o.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(ae,{children:[o.map(n=>a(B,{order:n,baseToken:n.enrichedTokens?.base??null,quoteToken:n.enrichedTokens?.quote??null},n.orderHash)),p&&a(j,{})]})}):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{be as a};
|