@aori/mega-swap-widget 0.1.0 → 0.1.1
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/LICENSE +5 -12
- package/dist/AssetSelectionMenu-INISSBWT.js +2 -0
- package/dist/AssetSelectionMenu-ZT2PDBHV.cjs +2 -0
- package/dist/ChainSelectionMenu-N65VG257.js +2 -0
- package/dist/ChainSelectionMenu-URYJUECJ.cjs +2 -0
- package/dist/SwapFormHorizontal-ACRBI6GC.cjs +2 -0
- package/dist/SwapFormHorizontal-XMZKEAIL.js +2 -0
- package/dist/SwapFormSplit-SOC2XMBW.js +2 -0
- package/dist/SwapFormSplit-XHAGOXQX.cjs +2 -0
- package/dist/WalletPlaceholderPanel-TTONBBI4.cjs +2 -0
- package/dist/WalletPlaceholderPanel-Z4JCFCNV.js +2 -0
- package/dist/WidgetWalletPanel-FQDNFYFL.cjs +2 -0
- package/dist/WidgetWalletPanel-KZFLFLUD.js +2 -0
- package/dist/chunk-34N36GUD.cjs +2 -0
- package/dist/chunk-46H44R7V.js +2 -0
- package/dist/chunk-4XEJKRRM.js +2 -0
- package/dist/chunk-537OMWA3.cjs +2 -0
- package/dist/chunk-73CB2I7U.js +2 -0
- package/dist/chunk-BX3KCZRT.cjs +27 -0
- package/dist/chunk-C3X6NJIB.cjs +2 -0
- package/dist/chunk-CHDFHEPH.js +27 -0
- package/dist/chunk-E44WNKS4.cjs +2 -0
- package/dist/chunk-F7IECVJU.js +2 -0
- package/dist/chunk-JSWDMAZQ.js +2 -0
- package/dist/chunk-KH57FLST.cjs +57 -0
- package/dist/chunk-NQ4QSGGF.cjs +2 -0
- package/dist/chunk-OPN7WCJR.js +57 -0
- package/dist/chunk-T3I3AJXV.cjs +2 -0
- package/dist/chunk-TWJY6EY4.js +2 -0
- package/dist/chunk-XUTR7YYC.cjs +2 -0
- package/dist/chunk-Z2BLIAFE.js +2 -0
- package/dist/index.cjs +2 -1772
- package/dist/index.css +1 -1423
- package/dist/index.js +2 -1772
- package/package.json +2 -22
- package/dist/AssetSelectionMenu-Y3EB32BT.cjs +0 -13
- package/dist/AssetSelectionMenu-Y3EB32BT.cjs.map +0 -1
- package/dist/AssetSelectionMenu-ZRG42UCZ.js +0 -13
- package/dist/AssetSelectionMenu-ZRG42UCZ.js.map +0 -1
- package/dist/ChainSelectionMenu-FBAPPFKI.cjs +0 -11
- package/dist/ChainSelectionMenu-FBAPPFKI.cjs.map +0 -1
- package/dist/ChainSelectionMenu-QO3H4TNR.js +0 -11
- package/dist/ChainSelectionMenu-QO3H4TNR.js.map +0 -1
- package/dist/SwapFormHorizontal-JDJUDFNX.js +0 -573
- package/dist/SwapFormHorizontal-JDJUDFNX.js.map +0 -1
- package/dist/SwapFormHorizontal-WG3Z3CFT.cjs +0 -573
- package/dist/SwapFormHorizontal-WG3Z3CFT.cjs.map +0 -1
- package/dist/SwapFormSplit-7CHTPLEQ.js +0 -441
- package/dist/SwapFormSplit-7CHTPLEQ.js.map +0 -1
- package/dist/SwapFormSplit-VDDIRQUQ.cjs +0 -441
- package/dist/SwapFormSplit-VDDIRQUQ.cjs.map +0 -1
- package/dist/WalletPlaceholderPanel-7YDQ4FT6.js +0 -57
- package/dist/WalletPlaceholderPanel-7YDQ4FT6.js.map +0 -1
- package/dist/WalletPlaceholderPanel-FZ6XIAMF.cjs +0 -57
- package/dist/WalletPlaceholderPanel-FZ6XIAMF.cjs.map +0 -1
- package/dist/WidgetWalletPanel-D7I5TAU3.js +0 -789
- package/dist/WidgetWalletPanel-D7I5TAU3.js.map +0 -1
- package/dist/WidgetWalletPanel-T7H6FGVN.cjs +0 -789
- package/dist/WidgetWalletPanel-T7H6FGVN.cjs.map +0 -1
- package/dist/chunk-3E6RNP2D.cjs +0 -389
- package/dist/chunk-3E6RNP2D.cjs.map +0 -1
- package/dist/chunk-5TH6MFQD.cjs +0 -122
- package/dist/chunk-5TH6MFQD.cjs.map +0 -1
- package/dist/chunk-5XSCUUOW.js +0 -101
- package/dist/chunk-5XSCUUOW.js.map +0 -1
- package/dist/chunk-6Q7MSCKS.js +0 -2199
- package/dist/chunk-6Q7MSCKS.js.map +0 -1
- package/dist/chunk-6XB5R4GF.cjs +0 -368
- package/dist/chunk-6XB5R4GF.cjs.map +0 -1
- package/dist/chunk-6YLNOZ7P.js +0 -389
- package/dist/chunk-6YLNOZ7P.js.map +0 -1
- package/dist/chunk-7AWG6OWF.js +0 -27
- package/dist/chunk-7AWG6OWF.js.map +0 -1
- package/dist/chunk-ARMW5POL.js +0 -3082
- package/dist/chunk-ARMW5POL.js.map +0 -1
- package/dist/chunk-B3ILUJ7G.cjs +0 -101
- package/dist/chunk-B3ILUJ7G.cjs.map +0 -1
- package/dist/chunk-GGM3MDFM.js +0 -32
- package/dist/chunk-GGM3MDFM.js.map +0 -1
- package/dist/chunk-GZUTUD5O.cjs +0 -2199
- package/dist/chunk-GZUTUD5O.cjs.map +0 -1
- package/dist/chunk-HXOGJSAI.cjs +0 -3082
- package/dist/chunk-HXOGJSAI.cjs.map +0 -1
- package/dist/chunk-LTA7IG3J.js +0 -122
- package/dist/chunk-LTA7IG3J.js.map +0 -1
- package/dist/chunk-NBJPKJBC.cjs +0 -32
- package/dist/chunk-NBJPKJBC.cjs.map +0 -1
- package/dist/chunk-PGYOJ5RB.cjs +0 -27
- package/dist/chunk-PGYOJ5RB.cjs.map +0 -1
- package/dist/chunk-QHW27RMH.js +0 -199
- package/dist/chunk-QHW27RMH.js.map +0 -1
- package/dist/chunk-TMC4SUEV.js +0 -368
- package/dist/chunk-TMC4SUEV.js.map +0 -1
- package/dist/chunk-XQINW7QP.cjs +0 -199
- package/dist/chunk-XQINW7QP.cjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.css.map +0 -1
- package/dist/index.js.map +0 -1
package/LICENSE
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
Copyright (c) 2025 Aori. All rights reserved.
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
of
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
3
|
+
UNLICENSED — This software and associated documentation files (the "Software")
|
|
4
|
+
are proprietary and confidential. No part of the Software may be reproduced,
|
|
5
|
+
distributed, transmitted, sublicensed, or sold without the prior written
|
|
6
|
+
permission of the copyright holder.
|
|
14
7
|
|
|
15
8
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
9
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
|
+
"use client";var _chunkE44WNKS4cjs = require('./chunk-E44WNKS4.cjs');require('./chunk-537OMWA3.cjs');require('./chunk-BX3KCZRT.cjs');require('./chunk-34N36GUD.cjs');require('./chunk-T3I3AJXV.cjs');exports.default = _chunkE44WNKS4cjs.a;
|
|
@@ -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 _chunkXUTR7YYCcjs = require('./chunk-XUTR7YYC.cjs');var _chunkNQ4QSGGFcjs = require('./chunk-NQ4QSGGF.cjs');var _chunkE44WNKS4cjs = require('./chunk-E44WNKS4.cjs');var _chunkC3X6NJIBcjs = require('./chunk-C3X6NJIB.cjs');require('./chunk-KH57FLST.cjs');var _chunk537OMWA3cjs = require('./chunk-537OMWA3.cjs');var _chunkBX3KCZRTcjs = require('./chunk-BX3KCZRT.cjs');var _chunk34N36GUDcjs = require('./chunk-34N36GUD.cjs');require('./chunk-T3I3AJXV.cjs');var _react = require('react');var _shallow = require('zustand/react/shallow');var _jsxruntime = require('react/jsx-runtime');var P=()=>{},$e=({onSwapComplete:ue,onSwapInitiated:ce,onBackToSwap:h,onMoreChainsClick:Be})=>{let{web3ConnectionType:He,hasConnectHandler:pe,lockBase:O,lockQuote:N,disableInverting:me,swapButtonVariant:q,tokenDisplay:H,tokenBadgeOrientation:x,widgetType:ge,assetMenuVariant:fe}=_chunkBX3KCZRTcjs.b.call(void 0, ),Q=H==="pill"||H==="ghost",T=ge==="compact",{baseToken:t,quoteToken:o,baseAmount:i,quoteAmount:u,isBaseGasToken:we,isQuoteGasToken:ve,isWrappingPair:a,isUnwrappingPair:l,baseBalance:g,quoteBalance:Qe,setBaseAmount:R,setQuoteAmount:c,swapTokens:U,clearForm:V}=_chunk537OMWA3cjs.f.call(void 0, ),{rfqQuote:Ue,status:Ve,handleInputChange:F,ensureForParams:j,stop:je,clear:S,refresh:G}=_chunkNQ4QSGGFcjs.e.call(void 0, ),{address:m}=_chunk34N36GUDcjs.a.call(void 0, ),{openConnectModal:be}=_chunkNQ4QSGGFcjs.g.call(void 0, ),{isRecipientInputOpen:M,txStatus:z,view:v,selectedChainFilterChainId:D}=_chunk537OMWA3cjs.c.call(void 0, _shallow.useShallow.call(void 0, n=>({isRecipientInputOpen:n.isRecipientInputOpen,txStatus:n.txStatus,view:n.view,selectedChainFilterChainId:_nullishCoalesce(_optionalChain([n, 'access', _2 => _2.selectedChainFilter, 'optionalAccess', _3 => _3.chainId]), () => (null))}))),[C,he]=_react.useState.call(void 0, null),[y,E]=_react.useState.call(void 0, null),xe=_react.useRef.call(void 0, !1),s=!1,Se=_react.useMemo.call(void 0, ()=>!t||!o||typeof i!="number"||!u||!m||parseFloat(g.formatted)<i?null:{base:t,quote:o,baseAmount:i,quoteAmount:u,userAddress:m},[t,o,i,u,m,g.formatted]),Ce=_react.useCallback.call(void 0, n=>{E(n),_chunk537OMWA3cjs.c.getState().startTracking(n)},[]),ye=_react.useCallback.call(void 0, ()=>{xe.current=!0,G()},[G]);_react.useEffect.call(void 0, ()=>{if(C===null&&!(!t||!o)){if(!i||i<=0){F({amount:null,inputToken:t,outputToken:o,setOutputAmount:c});return}if(a||l){c(i);return}F({amount:i,inputToken:t,outputToken:o,setOutputAmount:c})}},[C,i,t,o,a,l,F,c]);let I=_react.useCallback.call(void 0, ()=>{_chunk537OMWA3cjs.c.getState().setView("baseSelection")},[]),W=_react.useCallback.call(void 0, ()=>{_chunk537OMWA3cjs.c.getState().setView("quoteSelection")},[]),Ae=_react.useCallback.call(void 0, ()=>{U(),c(null)},[U,c]),Pe=_react.useCallback.call(void 0, ()=>{if(!g.formatted||!t||!o)return;let n=parseFloat(g.formatted);if(!n||n<=0)return;let b=n*.9999999999;a||l?(R(b),c(b),S()):(R(b),c(null),j({inputToken:t,outputToken:o,inputAmount:b.toString(),setOutputAmount:A=>c(A)}))},[g.formatted,t,o,a,l,R,c,S,j]),ke=_react.useCallback.call(void 0, ()=>{S(),V()},[S,V]),_=g.formatted?parseFloat(g.formatted):null,Oe=!!(i||u),L=fe==="split",J=L&&(v==="baseSelection"||v==="baseChainSelection"),K=L&&(v==="quoteSelection"||v==="quoteChainSelection"),X=_react.useCallback.call(void 0, n=>{let A=_chunk537OMWA3cjs.c.getState().view==="baseChainSelection"?"base":"quote";_chunk537OMWA3cjs.c.getState().setChainFilter({chainId:n,side:A}),_chunk537OMWA3cjs.c.getState().pushRecentChain(n),_chunk537OMWA3cjs.c.getState().transitionToView(A==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),Ne=_react.useCallback.call(void 0, ()=>{_chunk537OMWA3cjs.c.getState().transitionToView("baseChainSelection","chainSelection")},[]),qe=_react.useCallback.call(void 0, ()=>{_chunk537OMWA3cjs.c.getState().transitionToView("quoteChainSelection","chainSelection")},[]),Te=_optionalChain([t, 'optionalAccess', _4 => _4.price])&&i?`$${(t.price*i).toFixed(2)}`:"$0.00",Re=_optionalChain([o, 'optionalAccess', _5 => _5.price])&&u?`$${(o.price*u).toFixed(2)}`:"$0.00",Y=C==="trackingTx"&&!!y&&!!t&&!!o&&!!i&&!!u,Z={backgroundColor:q==="default"?"var(--widget-primary)":"transparent",color:q==="default"?"var(--widget-primary-foreground)":"var(--widget-primary)",border:q!=="default"?"1px solid var(--widget-primary)":"none",borderRadius:"var(--widget-radius)"};return _jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full",children:[Y&&y&&t&&o&&i&&u?_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-h-0 overflow-hidden",children:_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.w,{orderHash:y,base:t,quote:o,baseAmount:i,quoteAmount:u,status:z})}):_jsxruntime.jsxs.call(void 0, "div",{className:`grid grid-cols-[1fr_auto_1fr] items-stretch px-4 ${T?"pt-3 pb-1":"pt-4 pb-2"} gap-2`,children:[_jsxruntime.jsx.call(void 0, "div",{className:`relative flex flex-col gap-1 p-3 rounded-lg overflow-hidden ${J?"h-[380px]":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)"},children:J?v==="baseChainSelection"?_jsxruntime.jsx.call(void 0, _chunkC3X6NJIBcjs.a,{toggle:_nullishCoalesce(h, () => (P)),side:"base",onChainSelect:X}):_jsxruntime.jsx.call(void 0, _chunkE44WNKS4cjs.a,{toggle:_nullishCoalesce(h, () => (P)),side:"base",otherAsset:o,onMoreChainsClick:Ne,selectedChainFilter:D}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[Q?T?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${x==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.i,{toggle:I,side:"base",asset:t,isPlacingOrder:s||O}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.h,{side:"base",asset:_nullishCoalesce(t, () => (null)),otherAsset:_nullishCoalesce(o, () => (null)),isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${x==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.i,{toggle:I,side:"base",asset:t,isPlacingOrder:s||O}),_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.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, _chunkNQ4QSGGFcjs.i,{toggle:I,side:"base",asset:t,isPlacingOrder:s||O}),_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.h,{side:"base",asset:_nullishCoalesce(t, () => (null)),otherAsset:_nullishCoalesce(o, () => (null)),isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "span",{className:"mono text-xs",style:{color:"var(--widget-muted-foreground)"},children:Te}),m&&_!==null&&_>0&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Pe,disabled:s,className:"flex items-center rounded-full px-2 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 transition-colors bg-(--widget-primary) text-(--widget-primary-foreground) hover:bg-(--widget-foreground) hover:text-(--widget-card)",children:"Max"})]})]})}),_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center justify-center px-1",children:me?_jsxruntime.jsx.call(void 0, "div",{className:"flex h-8 w-8 items-center justify-center opacity-20",children:_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"\u2192"})}):_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Ae,"aria-label":"Swap input and output tokens",className:"flex h-8 w-8 items-center justify-center rounded-full cursor-pointer transition-colors bg-(--widget-card) text-(--widget-muted-foreground) hover:bg-(--widget-secondary) hover:text-(--widget-foreground)",style:{border:"1px solid var(--widget-border)"},children:_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",children:"\u2194"})})}),_jsxruntime.jsx.call(void 0, "div",{className:`relative flex flex-col gap-1 p-3 rounded-lg overflow-hidden ${K?"h-[380px]":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)"},children:K?v==="quoteChainSelection"?_jsxruntime.jsx.call(void 0, _chunkC3X6NJIBcjs.a,{toggle:_nullishCoalesce(h, () => (P)),side:"quote",onChainSelect:X}):_jsxruntime.jsx.call(void 0, _chunkE44WNKS4cjs.a,{toggle:_nullishCoalesce(h, () => (P)),side:"quote",otherAsset:t,onMoreChainsClick:qe,selectedChainFilter:D}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[Q?T?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${x==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.i,{toggle:W,side:"quote",asset:o,isPlacingOrder:s||N}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.h,{side:"quote",asset:_nullishCoalesce(o, () => (null)),otherAsset:_nullishCoalesce(t, () => (null)),isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${x==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.i,{toggle:W,side:"quote",asset:o,isPlacingOrder:s||N}),_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.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, _chunkNQ4QSGGFcjs.i,{toggle:W,side:"quote",asset:o,isPlacingOrder:s||N}),_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.h,{side:"quote",asset:_nullishCoalesce(o, () => (null)),otherAsset:_nullishCoalesce(t, () => (null)),isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "span",{className:"mono text-xs",style:{color:"var(--widget-muted-foreground)"},children:Re}),Oe&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:ke,disabled:s,className:"flex items-center rounded-full px-2 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 transition-colors text-(--widget-muted-foreground) hover:bg-(--widget-secondary)",children:"Clear"})]})]})})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-row items-center w-full overflow-hidden px-4",style:{borderTop:M?"1px solid var(--widget-border)":"none",maxHeight:M?"60px":"0px",opacity:M?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.j,{})}),_jsxruntime.jsx.call(void 0, "div",{className:"px-4",style:{borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"},children:_jsxruntime.jsx.call(void 0, _chunkXUTR7YYCcjs.a,{})}),_jsxruntime.jsx.call(void 0, "div",{className:`relative ${Y?"px-0":"px-4"} py-4`,children:m&&t&&o&&i&&i>0?_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.v,{base:t,baseAmount:i,quote:o,quoteAmount:_nullishCoalesce(u, () => (0)),userAddress:m,isWrappingPair:a,isUnwrappingPair:l,isBaseGasToken:we,isQuoteGasToken:ve,reviewActionProps:Se,reviewState:C,setReviewState:he,trackedOrderHash:y,setTrackedOrderHash:E,onSwapComplete:ue,onSwapInitiated:ce,onOrderSubmitted:Ce,onStaleQuoteRestart:ye,txStatus:z}):!m&&pe?_jsxruntime.jsx.call(void 0, "button",{onClick:()=>be(),className:"w-full py-3 text-sm font-medium cursor-pointer transition-opacity hover:opacity-80",style:Z,children:"Connect Wallet"}):_jsxruntime.jsx.call(void 0, "button",{disabled:!0,className:"w-full py-3 text-sm font-medium transition-colors disabled:opacity-40 cursor-not-allowed",style:Z,children:m?"Enter Amount":"Connect Wallet"})})]})},rt= exports.default =$e;exports.default = rt;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";import{a as ne}from"./chunk-F7IECVJU.js";import{e as oe,g as se,h as f,i as w,j as re,v as ae,w as le}from"./chunk-4XEJKRRM.js";import{a as $}from"./chunk-Z2BLIAFE.js";import{a as B}from"./chunk-TWJY6EY4.js";import"./chunk-OPN7WCJR.js";import{c as d,f as ie}from"./chunk-JSWDMAZQ.js";import{b as ee}from"./chunk-CHDFHEPH.js";import{a as te}from"./chunk-46H44R7V.js";import"./chunk-73CB2I7U.js";import{useCallback as p,useEffect as Fe,useMemo as Me,useRef as Ie,useState as de}from"react";import{useShallow as We}from"zustand/react/shallow";import{Fragment as k,jsx as e,jsxs as r}from"react/jsx-runtime";var P=()=>{},$e=({onSwapComplete:ue,onSwapInitiated:ce,onBackToSwap:h,onMoreChainsClick:Be})=>{let{web3ConnectionType:He,hasConnectHandler:pe,lockBase:O,lockQuote:N,disableInverting:me,swapButtonVariant:q,tokenDisplay:H,tokenBadgeOrientation:x,widgetType:ge,assetMenuVariant:fe}=ee(),Q=H==="pill"||H==="ghost",T=ge==="compact",{baseToken:t,quoteToken:o,baseAmount:i,quoteAmount:u,isBaseGasToken:we,isQuoteGasToken:ve,isWrappingPair:a,isUnwrappingPair:l,baseBalance:g,quoteBalance:Qe,setBaseAmount:R,setQuoteAmount:c,swapTokens:U,clearForm:V}=ie(),{rfqQuote:Ue,status:Ve,handleInputChange:F,ensureForParams:j,stop:je,clear:S,refresh:G}=oe(),{address:m}=te(),{openConnectModal:be}=se(),{isRecipientInputOpen:M,txStatus:z,view:v,selectedChainFilterChainId:D}=d(We(n=>({isRecipientInputOpen:n.isRecipientInputOpen,txStatus:n.txStatus,view:n.view,selectedChainFilterChainId:n.selectedChainFilter?.chainId??null}))),[C,he]=de(null),[y,E]=de(null),xe=Ie(!1),s=!1,Se=Me(()=>!t||!o||typeof i!="number"||!u||!m||parseFloat(g.formatted)<i?null:{base:t,quote:o,baseAmount:i,quoteAmount:u,userAddress:m},[t,o,i,u,m,g.formatted]),Ce=p(n=>{E(n),d.getState().startTracking(n)},[]),ye=p(()=>{xe.current=!0,G()},[G]);Fe(()=>{if(C===null&&!(!t||!o)){if(!i||i<=0){F({amount:null,inputToken:t,outputToken:o,setOutputAmount:c});return}if(a||l){c(i);return}F({amount:i,inputToken:t,outputToken:o,setOutputAmount:c})}},[C,i,t,o,a,l,F,c]);let I=p(()=>{d.getState().setView("baseSelection")},[]),W=p(()=>{d.getState().setView("quoteSelection")},[]),Ae=p(()=>{U(),c(null)},[U,c]),Pe=p(()=>{if(!g.formatted||!t||!o)return;let n=parseFloat(g.formatted);if(!n||n<=0)return;let b=n*.9999999999;a||l?(R(b),c(b),S()):(R(b),c(null),j({inputToken:t,outputToken:o,inputAmount:b.toString(),setOutputAmount:A=>c(A)}))},[g.formatted,t,o,a,l,R,c,S,j]),ke=p(()=>{S(),V()},[S,V]),_=g.formatted?parseFloat(g.formatted):null,Oe=!!(i||u),L=fe==="split",J=L&&(v==="baseSelection"||v==="baseChainSelection"),K=L&&(v==="quoteSelection"||v==="quoteChainSelection"),X=p(n=>{let A=d.getState().view==="baseChainSelection"?"base":"quote";d.getState().setChainFilter({chainId:n,side:A}),d.getState().pushRecentChain(n),d.getState().transitionToView(A==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),Ne=p(()=>{d.getState().transitionToView("baseChainSelection","chainSelection")},[]),qe=p(()=>{d.getState().transitionToView("quoteChainSelection","chainSelection")},[]),Te=t?.price&&i?`$${(t.price*i).toFixed(2)}`:"$0.00",Re=o?.price&&u?`$${(o.price*u).toFixed(2)}`:"$0.00",Y=C==="trackingTx"&&!!y&&!!t&&!!o&&!!i&&!!u,Z={backgroundColor:q==="default"?"var(--widget-primary)":"transparent",color:q==="default"?"var(--widget-primary-foreground)":"var(--widget-primary)",border:q!=="default"?"1px solid var(--widget-primary)":"none",borderRadius:"var(--widget-radius)"};return r("div",{className:"flex flex-col w-full",children:[Y&&y&&t&&o&&i&&u?e("div",{className:"flex-1 min-h-0 overflow-hidden",children:e(le,{orderHash:y,base:t,quote:o,baseAmount:i,quoteAmount:u,status:z})}):r("div",{className:`grid grid-cols-[1fr_auto_1fr] items-stretch px-4 ${T?"pt-3 pb-1":"pt-4 pb-2"} gap-2`,children:[e("div",{className:`relative flex flex-col gap-1 p-3 rounded-lg overflow-hidden ${J?"h-[380px]":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)"},children:J?v==="baseChainSelection"?e(B,{toggle:h??P,side:"base",onChainSelect:X}):e($,{toggle:h??P,side:"base",otherAsset:o,onMoreChainsClick:Ne,selectedChainFilter:D}):r(k,{children:[Q?T?r("div",{className:`flex items-center gap-2 ${x==="right"?"flex-row-reverse":"flex-row"}`,children:[e(w,{toggle:I,side:"base",asset:t,isPlacingOrder:s||O}),e("div",{className:"flex-1 min-w-0",children:e(f,{side:"base",asset:t??null,otherAsset:o??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})})]}):r("div",{className:`flex flex-col ${x==="right"?"items-end":"items-start"}`,children:[e(w,{toggle:I,side:"base",asset:t,isPlacingOrder:s||O}),e(f,{side:"base",asset:t??null,otherAsset:o??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}):r(k,{children:[e(w,{toggle:I,side:"base",asset:t,isPlacingOrder:s||O}),e(f,{side:"base",asset:t??null,otherAsset:o??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}),r("div",{className:"flex items-center justify-between",children:[e("span",{className:"mono text-xs",style:{color:"var(--widget-muted-foreground)"},children:Te}),m&&_!==null&&_>0&&e("button",{type:"button",onClick:Pe,disabled:s,className:"flex items-center rounded-full px-2 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 transition-colors bg-(--widget-primary) text-(--widget-primary-foreground) hover:bg-(--widget-foreground) hover:text-(--widget-card)",children:"Max"})]})]})}),e("div",{className:"flex items-center justify-center px-1",children:me?e("div",{className:"flex h-8 w-8 items-center justify-center opacity-20",children:e("span",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"\u2192"})}):e("button",{type:"button",onClick:Ae,"aria-label":"Swap input and output tokens",className:"flex h-8 w-8 items-center justify-center rounded-full cursor-pointer transition-colors bg-(--widget-card) text-(--widget-muted-foreground) hover:bg-(--widget-secondary) hover:text-(--widget-foreground)",style:{border:"1px solid var(--widget-border)"},children:e("span",{className:"text-2xs",children:"\u2194"})})}),e("div",{className:`relative flex flex-col gap-1 p-3 rounded-lg overflow-hidden ${K?"h-[380px]":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)"},children:K?v==="quoteChainSelection"?e(B,{toggle:h??P,side:"quote",onChainSelect:X}):e($,{toggle:h??P,side:"quote",otherAsset:t,onMoreChainsClick:qe,selectedChainFilter:D}):r(k,{children:[Q?T?r("div",{className:`flex items-center gap-2 ${x==="right"?"flex-row-reverse":"flex-row"}`,children:[e(w,{toggle:W,side:"quote",asset:o,isPlacingOrder:s||N}),e("div",{className:"flex-1 min-w-0",children:e(f,{side:"quote",asset:o??null,otherAsset:t??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})})]}):r("div",{className:`flex flex-col ${x==="right"?"items-end":"items-start"}`,children:[e(w,{toggle:W,side:"quote",asset:o,isPlacingOrder:s||N}),e(f,{side:"quote",asset:o??null,otherAsset:t??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}):r(k,{children:[e(w,{toggle:W,side:"quote",asset:o,isPlacingOrder:s||N}),e(f,{side:"quote",asset:o??null,otherAsset:t??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}),r("div",{className:"flex items-center justify-between",children:[e("span",{className:"mono text-xs",style:{color:"var(--widget-muted-foreground)"},children:Re}),Oe&&e("button",{type:"button",onClick:ke,disabled:s,className:"flex items-center rounded-full px-2 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 transition-colors text-(--widget-muted-foreground) hover:bg-(--widget-secondary)",children:"Clear"})]})]})})]}),e("div",{className:"flex flex-row items-center w-full overflow-hidden px-4",style:{borderTop:M?"1px solid var(--widget-border)":"none",maxHeight:M?"60px":"0px",opacity:M?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:e(re,{})}),e("div",{className:"px-4",style:{borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"},children:e(ne,{})}),e("div",{className:`relative ${Y?"px-0":"px-4"} py-4`,children:m&&t&&o&&i&&i>0?e(ae,{base:t,baseAmount:i,quote:o,quoteAmount:u??0,userAddress:m,isWrappingPair:a,isUnwrappingPair:l,isBaseGasToken:we,isQuoteGasToken:ve,reviewActionProps:Se,reviewState:C,setReviewState:he,trackedOrderHash:y,setTrackedOrderHash:E,onSwapComplete:ue,onSwapInitiated:ce,onOrderSubmitted:Ce,onStaleQuoteRestart:ye,txStatus:z}):!m&&pe?e("button",{onClick:()=>be(),className:"w-full py-3 text-sm font-medium cursor-pointer transition-opacity hover:opacity-80",style:Z,children:"Connect Wallet"}):e("button",{disabled:!0,className:"w-full py-3 text-sm font-medium transition-colors disabled:opacity-40 cursor-not-allowed",style:Z,children:m?"Enter Amount":"Connect Wallet"})})]})},rt=$e;export{rt as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";import{e as ae,g as ne,h as b,i as h,j as re,v as le,w as de}from"./chunk-4XEJKRRM.js";import{a as ce}from"./chunk-Z2BLIAFE.js";import{a as ue}from"./chunk-TWJY6EY4.js";import"./chunk-OPN7WCJR.js";import{c as l,f as ie}from"./chunk-JSWDMAZQ.js";import{P as U,X as se,b as te}from"./chunk-CHDFHEPH.js";import{a as oe}from"./chunk-46H44R7V.js";import"./chunk-73CB2I7U.js";import{useCallback as f,useEffect as pe,useMemo as Ge,useRef as me,useState as V}from"react";import{useShallow as Le}from"zustand/react/shallow";import{Fragment as P,jsx as e,jsxs as t}from"react/jsx-runtime";var ge=()=>{},_e=({onSwapComplete:fe,onSwapInitiated:xe,onBackToSwap:H,onMoreChainsClick:Je})=>{let{web3ConnectionType:Ke,hasConnectHandler:ve,lockBase:O,lockQuote:T,disableInverting:we,swapButtonVariant:q,tokenDisplay:j,tokenBadgeOrientation:y,widgetType:be,assetMenuVariant:he}=te(),E=j==="pill"||j==="ghost",N=be==="compact",{baseToken:d,quoteToken:c,baseAmount:a,quoteAmount:n,isBaseGasToken:Se,isQuoteGasToken:ye,isWrappingPair:u,isUnwrappingPair:p,baseBalance:w,setBaseAmount:R,setQuoteAmount:g,swapTokens:D,clearForm:z}=ie(),{handleInputChange:F,ensureForParams:G,clear:C,refresh:L,liquidityError:Ne,routingError:Ce}=ae(),{address:x}=oe(),{openConnectModal:ke}=ne(),{isRecipientInputOpen:I,txStatus:_,view:v,selectedChainFilterChainId:Ae}=l(Le(i=>({isRecipientInputOpen:i.isRecipientInputOpen,txStatus:i.txStatus,view:i.view,selectedChainFilterChainId:i.selectedChainFilterChainId??null}))),[k,Pe]=V(null),[A,J]=V(null),Oe=me(!1),r=!1,Te=Ge(()=>!d||!c||typeof a!="number"||!n||!x||parseFloat(w.formatted)<a?null:{base:d,quote:c,baseAmount:a,quoteAmount:n,userAddress:x},[d,c,a,n,x,w.formatted]),qe=f(i=>{J(i),l.getState().startTracking(i)},[]),Re=f(()=>{Oe.current=!0,L()},[L]);pe(()=>{if(k===null&&!(!d||!c)){if(!a||a<=0){F({amount:null,inputToken:d,outputToken:c,setOutputAmount:g});return}if(u||p){g(a);return}F({amount:a,inputToken:d,outputToken:c,setOutputAmount:g})}},[k,a,d,c,u,p,F,g]);let K=a&&n&&parseFloat(n.toString())?parseFloat(a.toString())/parseFloat(n.toString()):0,M=f(()=>{l.getState().setView("baseSelection")},[]),$=f(()=>{l.getState().setView("quoteSelection")},[]),Fe=f(()=>{D(),g(null)},[D,g]),Ie=f(()=>{if(!w.formatted||!d||!c)return;let i=parseFloat(w.formatted);if(!i||i<=0)return;let m=i*.9999999999;u||p?(R(m),g(m),C()):(R(m),g(null),G({inputToken:d,outputToken:c,inputAmount:m.toString(),setOutputAmount:S=>g(S)}))},[w.formatted,d,c,u,p,R,g,C,G]),Me=f(()=>{C(),z()},[C,z]),X=w.formatted?parseFloat(w.formatted):null,$e=!!(a||n),s=d,o=c,We=s?.price&&a?`$${(s.price*a).toFixed(2)}`:"$0.00",Be=o?.price&&n?`$${(o.price*n).toFixed(2)}`:"$0.00",Qe=!!(s&&o&&a&&n),Ue=Ne||Ce,Y=k==="trackingTx"&&!!A&&!!s&&!!o&&!!a&&!!n,W=he==="split",B=W&&(v==="baseSelection"||v==="quoteSelection"||v==="baseChainSelection"||v==="quoteChainSelection"),Q=v==="baseSelection"||v==="baseChainSelection"?"base":"quote",Ve=Q==="base"?o:s,Z=me(null),[He,je]=V(380);pe(()=>{if(!W)return;let i=Z.current;if(!i)return;let m=new ResizeObserver(S=>{for(let ze of S)je(ze.contentRect.height)});return m.observe(i),()=>m.disconnect()},[W]);let Ee=f(i=>{let S=l.getState().view==="baseChainSelection"?"base":"quote";l.getState().setChainFilter({chainId:i,side:S}),l.getState().pushRecentChain(i),l.getState().transitionToView(S==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),De=f(()=>{let i=l.getState().view;i==="baseSelection"?l.getState().transitionToView("baseChainSelection","chainSelection"):i==="quoteSelection"&&l.getState().transitionToView("quoteChainSelection","chainSelection")},[]),ee={backgroundColor:q==="default"?"var(--widget-primary)":"transparent",color:q==="default"?"var(--widget-primary-foreground)":"var(--widget-primary)",border:q!=="default"?"1px solid var(--widget-primary)":"none",borderRadius:"var(--widget-radius)"};return t("div",{className:"flex flex-row w-full",children:[t("div",{ref:Z,className:"flex flex-col flex-1 min-w-0",style:{borderRight:"1px solid var(--widget-border)"},children:[Y&&A&&s&&o&&a&&n?e("div",{className:"flex-1 min-h-0 overflow-hidden",children:e(de,{orderHash:A,base:s,quote:o,baseAmount:a,quoteAmount:n,status:_})}):t(P,{children:[t("div",{className:`relative ${N?"px-4 pt-3 pb-1":"px-4 pt-4 pb-2"}`,style:{borderBottom:"1px solid var(--widget-border)"},children:[E?N?t("div",{className:`flex items-center gap-2 ${y==="right"?"flex-row-reverse":"flex-row"}`,children:[e(h,{toggle:M,side:"base",asset:s,isPlacingOrder:r||O}),e("div",{className:"flex-1 min-w-0",children:e(b,{side:"base",asset:s??null,otherAsset:o??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})})]}):t("div",{className:`flex flex-col ${y==="right"?"items-end":"items-start"}`,children:[e(h,{toggle:M,side:"base",asset:s,isPlacingOrder:r||O}),e(b,{side:"base",asset:s??null,otherAsset:o??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}):t(P,{children:[e(h,{toggle:M,side:"base",asset:s,isPlacingOrder:r||O}),e(b,{side:"base",asset:s??null,otherAsset:o??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}),t("div",{className:"mb-1 flex w-full flex-row items-center justify-between",children:[e("p",{className:"mono text-sm",style:{color:"var(--widget-muted-foreground)"},children:We}),x&&X!==null&&X>0&&e("button",{type:"button",onClick:Ie,disabled:r,className:"absolute bottom-3 right-4 flex items-center rounded-full px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 bg-(--widget-primary) text-(--widget-primary-foreground) hover:bg-(--widget-foreground) hover:text-(--widget-card) transition-colors",children:"Max"})]})]}),!we&&e("div",{className:"flex justify-center -my-4 relative z-10",children:t("button",{type:"button",onClick:Fe,"aria-label":"Swap input and output tokens",className:"flex h-8 w-8 items-center justify-center rounded-full cursor-pointer bg-(--widget-card) text-(--widget-muted-foreground) hover:bg-(--widget-secondary) hover:text-(--widget-foreground) transition-colors",style:{border:"1px solid var(--widget-border)"},children:[e("span",{className:"text-2xs",children:"\u2191"}),e("span",{className:"text-2xs",children:"\u2193"})]})}),t("div",{className:`relative ${N?"px-4 pt-4 pb-1":"px-4 pt-6 pb-2"}`,children:[E?N?t("div",{className:`flex items-center gap-2 ${y==="right"?"flex-row-reverse":"flex-row"}`,children:[e(h,{toggle:$,side:"quote",asset:o,isPlacingOrder:r||T}),e("div",{className:"flex-1 min-w-0",children:e(b,{side:"quote",asset:o??null,otherAsset:s??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})})]}):t("div",{className:`flex flex-col ${y==="right"?"items-end":"items-start"}`,children:[e(h,{toggle:$,side:"quote",asset:o,isPlacingOrder:r||T}),e(b,{side:"quote",asset:o??null,otherAsset:s??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}):t(P,{children:[e(h,{toggle:$,side:"quote",asset:o,isPlacingOrder:r||T}),e(b,{side:"quote",asset:o??null,otherAsset:s??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}),t("div",{className:"flex w-full flex-row items-center justify-between",children:[e("p",{className:"mono text-sm",style:{color:"var(--widget-muted-foreground)"},children:Be}),$e&&e("button",{type:"button",onClick:Me,disabled:r,className:"absolute bottom-2 right-4 flex items-center rounded-full px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 text-(--widget-muted-foreground) hover:bg-(--widget-secondary) transition-colors",children:"Clear"})]})]})]}),e("div",{className:"flex flex-row items-center w-full overflow-hidden",style:{borderTop:I?"1px solid var(--widget-border)":"none",maxHeight:I?"60px":"0px",opacity:I?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:e(re,{})}),e("div",{className:`relative ${Y?"px-0":"px-4"} py-4`,children:x&&s&&o&&a&&a>0?e(le,{base:s,baseAmount:a,quote:o,quoteAmount:n??0,userAddress:x,isWrappingPair:u,isUnwrappingPair:p,isBaseGasToken:Se,isQuoteGasToken:ye,reviewActionProps:Te,reviewState:k,setReviewState:Pe,trackedOrderHash:A,setTrackedOrderHash:J,onSwapComplete:fe,onSwapInitiated:xe,onOrderSubmitted:qe,onStaleQuoteRestart:Re,txStatus:_}):!x&&ve?e("button",{onClick:()=>ke(),className:"w-full py-3 text-sm font-medium cursor-pointer transition-opacity hover:opacity-80",style:ee,children:"Connect Wallet"}):e("button",{disabled:!0,className:"w-full py-3 text-sm font-medium transition-colors disabled:opacity-40 cursor-not-allowed",style:ee,children:x?"Enter Amount":"Connect Wallet"})})]}),e("div",{className:`flex flex-col transition-all duration-300 ${B?"flex-1 min-w-0":"w-48 shrink-0"}`,style:{backgroundColor:"var(--widget-background)",...B?{height:`${He}px`}:{}},children:B?e("div",{className:"flex flex-col overflow-hidden p-2",style:{height:"100%"},children:v==="baseChainSelection"||v==="quoteChainSelection"?e(ue,{toggle:H??ge,side:Q,onChainSelect:Ee}):e(ce,{toggle:H??ge,side:Q,otherAsset:Ve,onMoreChainsClick:De,selectedChainFilter:Ae})}):t("div",{className:"flex flex-col gap-3 px-4 py-4",children:[e("span",{className:"text-2xs uppercase tracking-wider font-medium",style:{color:"var(--widget-muted-foreground)"},children:"Quote Details"}),Qe&&s&&o?t(P,{children:[t("div",{className:"flex flex-col gap-0.5",children:[e("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Rate"}),t("div",{className:"flex items-center gap-1",children:[e(U,{asset:o,size:"3xs",noChain:!0}),t("span",{className:"font-mono text-xs uppercase",children:["1 ",o.symbol]})]}),e("div",{className:"flex items-center gap-1 pl-4",children:t("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:["= ",K.toFixed(6)]})}),t("div",{className:"flex items-center gap-1 pl-4",children:[e(U,{asset:s,size:"3xs",noChain:!0}),e("span",{className:"font-mono text-xs uppercase",children:s.symbol})]})]}),t("div",{className:"flex flex-col gap-2",style:{borderTop:"1px solid var(--widget-border)",paddingTop:"0.5rem"},children:[t("div",{className:"flex justify-between items-center",children:[e("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"USD Value"}),t("span",{className:"font-mono text-xs",children:["$",s.price?(s.price*K*parseFloat(n.toString())).toFixed(2):"\u2014"]})]}),t("div",{className:"flex justify-between items-center",children:[e("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Order Type"}),e("span",{className:"text-2xs font-mono",style:{color:"var(--widget-foreground)"},children:"RFQ"})]}),t("div",{className:"flex justify-between items-center",children:[e("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Fill"}),e("span",{className:"text-2xs",style:{color:"var(--widget-primary)"},children:"Exact"})]}),s.chainId!==o.chainId&&t("div",{className:"flex justify-between items-center",children:[e("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Route"}),e("span",{className:"text-2xs font-mono",children:"Cross-chain"})]})]})]}):Ue?t("div",{className:"flex flex-col gap-1",children:[e(se,{className:"h-6 w-6",style:{color:"var(--widget-destructive)"}}),e("span",{className:"text-2xs",style:{color:"var(--widget-destructive)"},children:"Quote not found"})]}):t("div",{className:"flex flex-col gap-2 mt-2",children:[[...Array(4)].map((i,m)=>e("div",{className:"h-3 rounded animate-pulse",style:{backgroundColor:"var(--widget-muted)",width:m%2===0?"80%":"60%",opacity:.5}},m)),e("span",{className:"text-2xs mt-1",style:{color:"var(--widget-muted-foreground)",opacity:.5},children:"Enter an amount"})]})]})})]})},gt=_e;export{gt as default};
|
|
@@ -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 _chunkNQ4QSGGFcjs = require('./chunk-NQ4QSGGF.cjs');var _chunkE44WNKS4cjs = require('./chunk-E44WNKS4.cjs');var _chunkC3X6NJIBcjs = require('./chunk-C3X6NJIB.cjs');require('./chunk-KH57FLST.cjs');var _chunk537OMWA3cjs = require('./chunk-537OMWA3.cjs');var _chunkBX3KCZRTcjs = require('./chunk-BX3KCZRT.cjs');var _chunk34N36GUDcjs = require('./chunk-34N36GUD.cjs');require('./chunk-T3I3AJXV.cjs');var _react = require('react');var _shallow = require('zustand/react/shallow');var _jsxruntime = require('react/jsx-runtime');var ge=()=>{},_e=({onSwapComplete:fe,onSwapInitiated:xe,onBackToSwap:H,onMoreChainsClick:Je})=>{let{web3ConnectionType:Ke,hasConnectHandler:ve,lockBase:O,lockQuote:T,disableInverting:we,swapButtonVariant:q,tokenDisplay:j,tokenBadgeOrientation:y,widgetType:be,assetMenuVariant:he}=_chunkBX3KCZRTcjs.b.call(void 0, ),E=j==="pill"||j==="ghost",N=be==="compact",{baseToken:d,quoteToken:c,baseAmount:a,quoteAmount:n,isBaseGasToken:Se,isQuoteGasToken:ye,isWrappingPair:u,isUnwrappingPair:p,baseBalance:w,setBaseAmount:R,setQuoteAmount:g,swapTokens:D,clearForm:z}=_chunk537OMWA3cjs.f.call(void 0, ),{handleInputChange:F,ensureForParams:G,clear:C,refresh:L,liquidityError:Ne,routingError:Ce}=_chunkNQ4QSGGFcjs.e.call(void 0, ),{address:x}=_chunk34N36GUDcjs.a.call(void 0, ),{openConnectModal:ke}=_chunkNQ4QSGGFcjs.g.call(void 0, ),{isRecipientInputOpen:I,txStatus:_,view:v,selectedChainFilterChainId:Ae}=_chunk537OMWA3cjs.c.call(void 0, _shallow.useShallow.call(void 0, i=>({isRecipientInputOpen:i.isRecipientInputOpen,txStatus:i.txStatus,view:i.view,selectedChainFilterChainId:_nullishCoalesce(i.selectedChainFilterChainId, () => (null))}))),[k,Pe]=_react.useState.call(void 0, null),[A,J]=_react.useState.call(void 0, null),Oe=_react.useRef.call(void 0, !1),r=!1,Te=_react.useMemo.call(void 0, ()=>!d||!c||typeof a!="number"||!n||!x||parseFloat(w.formatted)<a?null:{base:d,quote:c,baseAmount:a,quoteAmount:n,userAddress:x},[d,c,a,n,x,w.formatted]),qe=_react.useCallback.call(void 0, i=>{J(i),_chunk537OMWA3cjs.c.getState().startTracking(i)},[]),Re=_react.useCallback.call(void 0, ()=>{Oe.current=!0,L()},[L]);_react.useEffect.call(void 0, ()=>{if(k===null&&!(!d||!c)){if(!a||a<=0){F({amount:null,inputToken:d,outputToken:c,setOutputAmount:g});return}if(u||p){g(a);return}F({amount:a,inputToken:d,outputToken:c,setOutputAmount:g})}},[k,a,d,c,u,p,F,g]);let K=a&&n&&parseFloat(n.toString())?parseFloat(a.toString())/parseFloat(n.toString()):0,M=_react.useCallback.call(void 0, ()=>{_chunk537OMWA3cjs.c.getState().setView("baseSelection")},[]),$=_react.useCallback.call(void 0, ()=>{_chunk537OMWA3cjs.c.getState().setView("quoteSelection")},[]),Fe=_react.useCallback.call(void 0, ()=>{D(),g(null)},[D,g]),Ie=_react.useCallback.call(void 0, ()=>{if(!w.formatted||!d||!c)return;let i=parseFloat(w.formatted);if(!i||i<=0)return;let m=i*.9999999999;u||p?(R(m),g(m),C()):(R(m),g(null),G({inputToken:d,outputToken:c,inputAmount:m.toString(),setOutputAmount:S=>g(S)}))},[w.formatted,d,c,u,p,R,g,C,G]),Me=_react.useCallback.call(void 0, ()=>{C(),z()},[C,z]),X=w.formatted?parseFloat(w.formatted):null,$e=!!(a||n),s=d,o=c,We=_optionalChain([s, 'optionalAccess', _2 => _2.price])&&a?`$${(s.price*a).toFixed(2)}`:"$0.00",Be=_optionalChain([o, 'optionalAccess', _3 => _3.price])&&n?`$${(o.price*n).toFixed(2)}`:"$0.00",Qe=!!(s&&o&&a&&n),Ue=Ne||Ce,Y=k==="trackingTx"&&!!A&&!!s&&!!o&&!!a&&!!n,W=he==="split",B=W&&(v==="baseSelection"||v==="quoteSelection"||v==="baseChainSelection"||v==="quoteChainSelection"),Q=v==="baseSelection"||v==="baseChainSelection"?"base":"quote",Ve=Q==="base"?o:s,Z=_react.useRef.call(void 0, null),[He,je]=_react.useState.call(void 0, 380);_react.useEffect.call(void 0, ()=>{if(!W)return;let i=Z.current;if(!i)return;let m=new ResizeObserver(S=>{for(let ze of S)je(ze.contentRect.height)});return m.observe(i),()=>m.disconnect()},[W]);let Ee=_react.useCallback.call(void 0, i=>{let S=_chunk537OMWA3cjs.c.getState().view==="baseChainSelection"?"base":"quote";_chunk537OMWA3cjs.c.getState().setChainFilter({chainId:i,side:S}),_chunk537OMWA3cjs.c.getState().pushRecentChain(i),_chunk537OMWA3cjs.c.getState().transitionToView(S==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),De=_react.useCallback.call(void 0, ()=>{let i=_chunk537OMWA3cjs.c.getState().view;i==="baseSelection"?_chunk537OMWA3cjs.c.getState().transitionToView("baseChainSelection","chainSelection"):i==="quoteSelection"&&_chunk537OMWA3cjs.c.getState().transitionToView("quoteChainSelection","chainSelection")},[]),ee={backgroundColor:q==="default"?"var(--widget-primary)":"transparent",color:q==="default"?"var(--widget-primary-foreground)":"var(--widget-primary)",border:q!=="default"?"1px solid var(--widget-primary)":"none",borderRadius:"var(--widget-radius)"};return _jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row w-full",children:[_jsxruntime.jsxs.call(void 0, "div",{ref:Z,className:"flex flex-col flex-1 min-w-0",style:{borderRight:"1px solid var(--widget-border)"},children:[Y&&A&&s&&o&&a&&n?_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-h-0 overflow-hidden",children:_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.w,{orderHash:A,base:s,quote:o,baseAmount:a,quoteAmount:n,status:_})}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "div",{className:`relative ${N?"px-4 pt-3 pb-1":"px-4 pt-4 pb-2"}`,style:{borderBottom:"1px solid var(--widget-border)"},children:[E?N?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${y==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.i,{toggle:M,side:"base",asset:s,isPlacingOrder:r||O}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.h,{side:"base",asset:_nullishCoalesce(s, () => (null)),otherAsset:_nullishCoalesce(o, () => (null)),isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${y==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.i,{toggle:M,side:"base",asset:s,isPlacingOrder:r||O}),_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.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, _chunkNQ4QSGGFcjs.i,{toggle:M,side:"base",asset:s,isPlacingOrder:r||O}),_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.h,{side:"base",asset:_nullishCoalesce(s, () => (null)),otherAsset:_nullishCoalesce(o, () => (null)),isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mb-1 flex w-full flex-row items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"mono text-sm",style:{color:"var(--widget-muted-foreground)"},children:We}),x&&X!==null&&X>0&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Ie,disabled:r,className:"absolute bottom-3 right-4 flex items-center rounded-full px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 bg-(--widget-primary) text-(--widget-primary-foreground) hover:bg-(--widget-foreground) hover:text-(--widget-card) transition-colors",children:"Max"})]})]}),!we&&_jsxruntime.jsx.call(void 0, "div",{className:"flex justify-center -my-4 relative z-10",children:_jsxruntime.jsxs.call(void 0, "button",{type:"button",onClick:Fe,"aria-label":"Swap input and output tokens",className:"flex h-8 w-8 items-center justify-center rounded-full cursor-pointer bg-(--widget-card) text-(--widget-muted-foreground) hover:bg-(--widget-secondary) hover:text-(--widget-foreground) transition-colors",style:{border:"1px solid var(--widget-border)"},children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",children:"\u2191"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",children:"\u2193"})]})}),_jsxruntime.jsxs.call(void 0, "div",{className:`relative ${N?"px-4 pt-4 pb-1":"px-4 pt-6 pb-2"}`,children:[E?N?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${y==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.i,{toggle:$,side:"quote",asset:o,isPlacingOrder:r||T}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.h,{side:"quote",asset:_nullishCoalesce(o, () => (null)),otherAsset:_nullishCoalesce(s, () => (null)),isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${y==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.i,{toggle:$,side:"quote",asset:o,isPlacingOrder:r||T}),_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.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, _chunkNQ4QSGGFcjs.i,{toggle:$,side:"quote",asset:o,isPlacingOrder:r||T}),_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.h,{side:"quote",asset:_nullishCoalesce(o, () => (null)),otherAsset:_nullishCoalesce(s, () => (null)),isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full flex-row items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"mono text-sm",style:{color:"var(--widget-muted-foreground)"},children:Be}),$e&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Me,disabled:r,className:"absolute bottom-2 right-4 flex items-center rounded-full px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 text-(--widget-muted-foreground) hover:bg-(--widget-secondary) transition-colors",children:"Clear"})]})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-row items-center w-full overflow-hidden",style:{borderTop:I?"1px solid var(--widget-border)":"none",maxHeight:I?"60px":"0px",opacity:I?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.j,{})}),_jsxruntime.jsx.call(void 0, "div",{className:`relative ${Y?"px-0":"px-4"} py-4`,children:x&&s&&o&&a&&a>0?_jsxruntime.jsx.call(void 0, _chunkNQ4QSGGFcjs.v,{base:s,baseAmount:a,quote:o,quoteAmount:_nullishCoalesce(n, () => (0)),userAddress:x,isWrappingPair:u,isUnwrappingPair:p,isBaseGasToken:Se,isQuoteGasToken:ye,reviewActionProps:Te,reviewState:k,setReviewState:Pe,trackedOrderHash:A,setTrackedOrderHash:J,onSwapComplete:fe,onSwapInitiated:xe,onOrderSubmitted:qe,onStaleQuoteRestart:Re,txStatus:_}):!x&&ve?_jsxruntime.jsx.call(void 0, "button",{onClick:()=>ke(),className:"w-full py-3 text-sm font-medium cursor-pointer transition-opacity hover:opacity-80",style:ee,children:"Connect Wallet"}):_jsxruntime.jsx.call(void 0, "button",{disabled:!0,className:"w-full py-3 text-sm font-medium transition-colors disabled:opacity-40 cursor-not-allowed",style:ee,children:x?"Enter Amount":"Connect Wallet"})})]}),_jsxruntime.jsx.call(void 0, "div",{className:`flex flex-col transition-all duration-300 ${B?"flex-1 min-w-0":"w-48 shrink-0"}`,style:{backgroundColor:"var(--widget-background)",...B?{height:`${He}px`}:{}},children:B?_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col overflow-hidden p-2",style:{height:"100%"},children:v==="baseChainSelection"||v==="quoteChainSelection"?_jsxruntime.jsx.call(void 0, _chunkC3X6NJIBcjs.a,{toggle:_nullishCoalesce(H, () => (ge)),side:Q,onChainSelect:Ee}):_jsxruntime.jsx.call(void 0, _chunkE44WNKS4cjs.a,{toggle:_nullishCoalesce(H, () => (ge)),side:Q,otherAsset:Ve,onMoreChainsClick:De,selectedChainFilter:Ae})}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-3 px-4 py-4",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs uppercase tracking-wider font-medium",style:{color:"var(--widget-muted-foreground)"},children:"Quote Details"}),Qe&&s&&o?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-0.5",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Rate"}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-1",children:[_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.P,{asset:o,size:"3xs",noChain:!0}),_jsxruntime.jsxs.call(void 0, "span",{className:"font-mono text-xs uppercase",children:["1 ",o.symbol]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center gap-1 pl-4",children:_jsxruntime.jsxs.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:["= ",K.toFixed(6)]})}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-1 pl-4",children:[_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.P,{asset:s,size:"3xs",noChain:!0}),_jsxruntime.jsx.call(void 0, "span",{className:"font-mono text-xs uppercase",children:s.symbol})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",style:{borderTop:"1px solid var(--widget-border)",paddingTop:"0.5rem"},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"USD Value"}),_jsxruntime.jsxs.call(void 0, "span",{className:"font-mono text-xs",children:["$",s.price?(s.price*K*parseFloat(n.toString())).toFixed(2):"\u2014"]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Order Type"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs font-mono",style:{color:"var(--widget-foreground)"},children:"RFQ"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Fill"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-primary)"},children:"Exact"})]}),s.chainId!==o.chainId&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Route"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs font-mono",children:"Cross-chain"})]})]})]}):Ue?_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.X,{className:"h-6 w-6",style:{color:"var(--widget-destructive)"}}),_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-destructive)"},children:"Quote not found"})]}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2 mt-2",children:[[...Array(4)].map((i,m)=>_jsxruntime.jsx.call(void 0, "div",{className:"h-3 rounded animate-pulse",style:{backgroundColor:"var(--widget-muted)",width:m%2===0?"80%":"60%",opacity:.5}},m)),_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs mt-1",style:{color:"var(--widget-muted-foreground)",opacity:.5},children:"Enter an amount"})]})]})})]})},gt= exports.default =_e;exports.default = gt;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
|
+
"use client";var _chunk34N36GUDcjs = require('./chunk-34N36GUD.cjs');require('./chunk-T3I3AJXV.cjs');var _wagmi = require('wagmi');var _jsxruntime = require('react/jsx-runtime');var i=()=>{let{disconnect:r}=_wagmi.useDisconnect.call(void 0, ),{address:s}=_chunk34N36GUDcjs.a.call(void 0, );return _jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col h-full w-full",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex-1 flex flex-col items-center justify-center p-6 gap-3 text-center",children:[_jsxruntime.jsxs.call(void 0, "svg",{className:"size-8",viewBox:"0 0 24 24",fill:"none",style:{color:"var(--widget-muted-foreground)",opacity:.5},children:[_jsxruntime.jsx.call(void 0, "rect",{x:"2",y:"3",width:"20",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 2"}),_jsxruntime.jsx.call(void 0, "path",{d:"M8 12h8M12 8v8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-medium",style:{color:"var(--widget-foreground)"},children:"Your custom components live here"})]}),s&&_jsxruntime.jsx.call(void 0, "div",{className:"px-4 pb-4",children:_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>r(),className:"w-full py-2.5 text-xs font-medium cursor-pointer transition-colors",style:{backgroundColor:"var(--widget-secondary)",color:"var(--widget-secondary-foreground)",borderRadius:"var(--widget-radius)"},children:"Disconnect"})})]})};exports.WalletPlaceholderPanel = i;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";import{a as o}from"./chunk-46H44R7V.js";import"./chunk-73CB2I7U.js";import{useDisconnect as l}from"wagmi";import{jsx as e,jsxs as t}from"react/jsx-runtime";var i=()=>{let{disconnect:r}=l(),{address:s}=o();return t("div",{className:"flex flex-col h-full w-full",children:[t("div",{className:"flex-1 flex flex-col items-center justify-center p-6 gap-3 text-center",children:[t("svg",{className:"size-8",viewBox:"0 0 24 24",fill:"none",style:{color:"var(--widget-muted-foreground)",opacity:.5},children:[e("rect",{x:"2",y:"3",width:"20",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 2"}),e("path",{d:"M8 12h8M12 8v8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),e("p",{className:"text-sm font-medium",style:{color:"var(--widget-foreground)"},children:"Your custom components live here"})]}),s&&e("div",{className:"px-4 pb-4",children:e("button",{type:"button",onClick:()=>r(),className:"w-full py-2.5 text-xs font-medium cursor-pointer transition-colors",style:{backgroundColor:"var(--widget-secondary)",color:"var(--widget-secondary-foreground)",borderRadius:"var(--widget-radius)"},children:"Disconnect"})})]})};export{i as WalletPlaceholderPanel};
|
|
@@ -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 _chunkKH57FLSTcjs = require('./chunk-KH57FLST.cjs');var _chunk537OMWA3cjs = require('./chunk-537OMWA3.cjs');var _chunkBX3KCZRTcjs = require('./chunk-BX3KCZRT.cjs');var _chunk34N36GUDcjs = require('./chunk-34N36GUD.cjs');var _chunkT3I3AJXVcjs = require('./chunk-T3I3AJXV.cjs');var _react = require('react');var _wagmi = require('wagmi');function oe(e){let{address:s,isConnected:n}=_chunk34N36GUDcjs.a.call(void 0, ),{chainDataMap:c}=_chunkBX3KCZRTcjs.I.call(void 0, ),m=_chunkBX3KCZRTcjs._.call(void 0, ),{getToken:v,tokenRegistry:f}=_chunkBX3KCZRTcjs.F.call(void 0, ),{supportedInputTokens:p,supportedOutputTokens:w}=_chunkBX3KCZRTcjs.b.call(void 0, ),l=_react.useMemo.call(void 0, ()=>{if(!p.length&&!w.length)return[];let t=new Set,o=[];for(let x of[...p,...w]){let S=`${x.chainId}-${x.address.toLowerCase()}`;t.has(S)||(t.add(S),o.push(x))}return o},[p,w]),{balances:u,isLoading:d,isError:i,refetch:h}=_chunkBX3KCZRTcjs.L.call(void 0, s,m,{enabled:n&&e&&!!s,refetchOnWindowFocus:!1},l.length>0?l:void 0),L=_react.useMemo.call(void 0, ()=>l.length?new Set(l.map(t=>`${t.chainId}-${t.address.toLowerCase()}`)):null,[l]),r=_react.useMemo.call(void 0, ()=>!u||u.length===0?{}:u.filter(o=>!o.assetInfo||!o.balance||o.balance==="0"?!1:L?L.has(`${o.chainId}-${o.address.toLowerCase()}`):_chunkBX3KCZRTcjs.k.call(void 0, o.assetInfo)||f.length===0?!0:f.some(x=>x.address.toLowerCase()===o.address.toLowerCase()&&x.chainId===o.chainId)).reduce((o,x)=>{let S=String(x.chainId);return o[S]||(o[S]=[]),o[S].push({token:x.address,amount:x.balance,decimals:x.decimals,assetInfo:x.assetInfo}),o},{}),[u,f,L]),k=_react.useMemo.call(void 0, ()=>!u||u.length===0?0:u.reduce((t,o)=>!o.assetInfo||o.decimals===void 0?t:t+parseFloat(o.balance)/10**o.decimals*(o.assetInfo.price||0),0),[u]),T=_react.useMemo.call(void 0, ()=>m.length===0?{}:m.reduce((t,o)=>{let x=c[o],S=_chunkBX3KCZRTcjs.e.call(void 0, o);return t[o.toString()]={chainId:o,name:_optionalChain([S, 'optionalAccess', _2 => _2.displayName])||_optionalChain([x, 'optionalAccess', _3 => _3.chainKey])||`Chain ${o}`},t},{}),[m,c]),W=_react.useMemo.call(void 0, ()=>f.map(t=>({address:t.address,chainId:t.chainId})),[f]),N=_react.useRef.call(void 0, null);_react.useEffect.call(void 0, ()=>()=>{N.current&&clearTimeout(N.current)},[]);let A=_react.useCallback.call(void 0, ()=>{N.current&&clearTimeout(N.current),N.current=setTimeout(()=>h(),2e3)},[h]);return{address:s,isConnected:n,groupedAssets:r,totalBalance:k,balancesLoading:d,balancesError:i,chains:T,getToken:v,useTokenWithLazyLoad:_chunkBX3KCZRTcjs.H,tokenRegistry:W,refetchBalances:A}}var ae=_chunkT3I3AJXVcjs.b.call(void 0, _chunkKH57FLSTcjs.a.call(void 0, ),1);var _jsxruntime = require('react/jsx-runtime');var ne=({address:e,totalBalance:s,isLoading:n=!1})=>{let c=m=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(m);return _jsxruntime.jsx.call(void 0, "div",{className:"p-2 w-full flex justify-center",children:_jsxruntime.jsxs.call(void 0, "div",{className:"relative w-full h-[140px] overflow-hidden",style:{borderRadius:"var(--widget-radius)",border:"1px var(--widget-border-style) var(--widget-border)"},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"absolute inset-0 z-0",children:[_jsxruntime.jsx.call(void 0, "img",{className:"w-full h-full object-cover opacity-60",src:(0,ae.makeGradient)(e),alt:"address gradient"}),_jsxruntime.jsx.call(void 0, "div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"relative z-10 flex h-full flex-col justify-between p-3",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-2xs uppercase mono",style:{color:"var(--widget-muted-foreground)",opacity:.7},children:"Token Balance:"}),n?_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.S,{className:"h-8 w-28 bg-white/10 rounded mt-1"}):_jsxruntime.jsx.call(void 0, "p",{className:"text-2xl font-bold mt-0.5",style:{color:"var(--widget-foreground)"},children:c(s)})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center",children:_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.R,{text:e,type:"address",children:_jsxruntime.jsx.call(void 0, "p",{className:"mono text-2xs",style:{color:"var(--widget-foreground)",opacity:.7},children:e})})})]})]})})};var ie=({asset:e,balanceAmount:s,balanceDecimals:n,price:c,onSelect:m,getToken:v,useTokenWithLazyLoad:f})=>{let[p,w]=_react.useState.call(void 0, !1),l=n!==void 0?parseFloat(s)/10**n:0,d=_optionalChain([f, 'optionalCall', _4 => _4(e.chainId,e.address), 'optionalAccess', _5 => _5.token]),i=_nullishCoalesce(c, () => (null));return _chunkBX3KCZRTcjs.k.call(void 0, e)&&i==null&&(_optionalChain([d, 'optionalAccess', _6 => _6.price])!=null?i=d.price:v&&(i=_nullishCoalesce(_optionalChain([v, 'call', _7 => _7(e.chainId,e.address), 'optionalAccess', _8 => _8.price]), () => (null)))),_jsxruntime.jsx.call(void 0, "div",{role:"button",tabIndex:0,className:"flex h-[52px] w-full flex-row items-center p-3 cursor-pointer transition-colors",style:{borderBottom:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:p?"var(--widget-secondary)":"transparent"},onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1),onClick:()=>_optionalChain([m, 'optionalCall', _9 => _9(e)]),onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),_optionalChain([m, 'optionalCall', _10 => _10(e)]))},children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full w-full flex-row items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full flex-row items-center gap-2",children:[_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.P,{asset:e,size:"sm"}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col items-start",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-medium uppercase",style:{color:"var(--widget-foreground)"},children:e.symbol}),l>0&&_jsxruntime.jsx.call(void 0, "p",{className:"mono text-xs",style:{color:"var(--widget-muted-foreground)"},children:l.toFixed(4)})]})]}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-medium",style:{color:"var(--widget-foreground)"},children:i!=null?`$${(i*l).toFixed(2)}`:"\u2014"})]})})};var be=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}),Ne=_chunkBX3KCZRTcjs.h.call(void 0, ),de=({groupedAssets:e,chains:s,tokenRegistry:n=[],getToken:c,useTokenWithLazyLoad:m,onAssetSelect:v})=>{let[f,p]=_react.useState.call(void 0, new Set),w=_react.useCallback.call(void 0, r=>_optionalChain([s, 'optionalAccess', _11 => _11[r], 'optionalAccess', _12 => _12.name])||Ne[r]||`Chain ${r}`,[s]),l=_react.useMemo.call(void 0, ()=>{let r=new Set;for(let k of n)r.add(`${k.chainId}-${k.address.toLowerCase()}`);return r},[n]),u=_react.useCallback.call(void 0, r=>r.decimals===void 0||!_optionalChain([r, 'access', _13 => _13.assetInfo, 'optionalAccess', _14 => _14.price])?0:parseFloat(r.amount)/10**r.decimals*r.assetInfo.price,[]),{filteredGroupedAssets:d,chainTotals:i}=_react.useMemo.call(void 0, ()=>{let r=Object.entries(e).map(([W,N])=>{let A=N.filter(t=>t.assetInfo?_chunkBX3KCZRTcjs.k.call(void 0, t.assetInfo)?!0:l.size>0?l.has(`${t.assetInfo.chainId}-${_nullishCoalesce(_optionalChain([t, 'access', _15 => _15.assetInfo, 'access', _16 => _16.address, 'optionalAccess', _17 => _17.toLowerCase, 'call', _18 => _18()]), () => (""))}`):!0:!1);return[W,A]}).filter(([,W])=>W.length>0),k={};for(let[W,N]of r)k[W]=N.reduce((A,t)=>A+u(t),0);return{filteredGroupedAssets:[...r].sort((W,N)=>(_nullishCoalesce(k[N[0]], () => (0)))-(_nullishCoalesce(k[W[0]], () => (0)))),chainTotals:k}},[e,l,u]),h=_react.useCallback.call(void 0, r=>{p(k=>{let T=new Set(k);return T.has(r)?T.delete(r):T.add(r),T})},[]),L=r=>be.format(r);return d.length===0?_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center justify-center p-6",children:_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"No token balances found"})}):_jsxruntime.jsx.call(void 0, "div",{className:"pb-2 pt-1",children:d.map(([r,k])=>{let T=parseInt(r),W=w(T),N=i[r]||0,A=f.has(r);return _jsxruntime.jsxs.call(void 0, "div",{className:"mx-2 mb-2",style:{border:"1px var(--widget-border-style) var(--widget-border)",borderRadius:"var(--widget-radius)",overflow:"hidden"},children:[_jsxruntime.jsxs.call(void 0, "button",{type:"button",onClick:()=>h(r),className:"flex w-full flex-row items-center justify-between p-2 cursor-pointer transition-colors hover:bg-(--widget-secondary)",style:{backgroundColor:"transparent"},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"inline-flex flex-row items-center gap-2",children:[_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.O,{chain:T,size:"sm"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-medium capitalize",style:{color:"var(--widget-foreground)"},children:W})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-semibold",style:{color:"var(--widget-foreground)"},children:L(N)}),_jsxruntime.jsx.call(void 0, "span",{className:`transition-transform duration-200 ${A?"rotate-180":""}`,style:{color:"var(--widget-muted-foreground)"},children:_jsxruntime.jsx.call(void 0, "svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:_jsxruntime.jsx.call(void 0, "path",{d:"M2.5 4.5L6 8L9.5 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:`overflow-hidden transition-all duration-200 ease-out ${A?"max-h-[2000px] opacity-100":"max-h-0 opacity-0"}`,children:_jsxruntime.jsx.call(void 0, "div",{style:{borderTop:"1px var(--widget-border-style) var(--widget-border)"},children:k.map(t=>t.assetInfo?_jsxruntime.jsx.call(void 0, ie,{asset:t.assetInfo,balanceAmount:t.amount,balanceDecimals:t.decimals,price:_nullishCoalesce(_optionalChain([t, 'access', _19 => _19.assetInfo, 'optionalAccess', _20 => _20.price]), () => (null)),onSelect:v,getToken:c,useTokenWithLazyLoad:m},`${t.assetInfo.chainId}-${t.token}`):null)})})]},r)})})};function ce(e,s){return{orders:[],isLoading:!1,error:null,hasMore:!1,loadMore:async()=>{},totalOrders:0}}var We=()=>_jsxruntime.jsxs.call(void 0, "svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[_jsxruntime.jsx.call(void 0, "circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),_jsxruntime.jsx.call(void 0, "path",{d:"M3 5.2L4.3 6.5L7 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Te=()=>_jsxruntime.jsxs.call(void 0, "svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[_jsxruntime.jsx.call(void 0, "circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),_jsxruntime.jsx.call(void 0, "path",{d:"M3.5 3.5L6.5 6.5M6.5 3.5L3.5 6.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})]}),Le=()=>_jsxruntime.jsxs.call(void 0, "svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[_jsxruntime.jsx.call(void 0, "circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),_jsxruntime.jsx.call(void 0, "path",{d:"M5 3V5.5L6.5 6.5",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round"})]}),ue=()=>_jsxruntime.jsxs.call(void 0, "svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[_jsxruntime.jsx.call(void 0, "circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),_jsxruntime.jsx.call(void 0, "circle",{cx:"5",cy:"5",r:"1.5",fill:"currentColor"})]}),Ie=e=>{switch((e||"").toLowerCase()){case"completed":case"settled":case"success":case"swapped":case"swap":return{icon:_jsxruntime.jsx.call(void 0, We,{}),color:"var(--widget-primary)"};case"received":return{icon:_jsxruntime.jsx.call(void 0, ue,{}),color:"var(--widget-accent)"};case"failed":case"error":case"expired":return{icon:_jsxruntime.jsx.call(void 0, Te,{}),color:"var(--widget-destructive)"};case"pending":case"created":case"placed":return{icon:_jsxruntime.jsx.call(void 0, Le,{}),color:"var(--widget-muted-foreground)"};default:return{icon:_jsxruntime.jsx.call(void 0, ue,{}),color:"var(--widget-muted-foreground)"}}},Ae=e=>{switch((e||"").toLowerCase()){case"completed":case"settled":case"success":case"swapped":case"swap":return"color-mix(in srgb, var(--widget-primary) 5%, transparent)";case"failed":case"error":case"expired":return"color-mix(in srgb, var(--widget-destructive) 5%, transparent)";case"pending":case"created":case"placed":return"color-mix(in srgb, var(--widget-accent) 5%, transparent)";default:return"var(--widget-secondary)"}},P=(e,s)=>{try{let n=parseFloat(e||"0");if(isNaN(n)||n===0)return"0";let c=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _21 => _21.decimals]), () => (18));return _chunkBX3KCZRTcjs.q.call(void 0, n/10**c)}catch (e2){return"0"}},me=({order:e,baseToken:s,quoteToken:n})=>{let[c,m]=_react.useState.call(void 0, !1),v=_optionalChain([e, 'optionalAccess', _22 => _22.status])||_optionalChain([e, 'optionalAccess', _23 => _23.eventType])||"unknown",{icon:f,color:p}=Ie(v),l=(i=>{if(!i)return{date:"",time:""};let h=new Date(typeof i=="number"?i:Number(i)||i);return{date:h.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),time:h.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",timeZone:"UTC",hour12:!1})+" UTC"}})(_optionalChain([e, 'optionalAccess', _24 => _24.timestamp])||_optionalChain([e, 'optionalAccess', _25 => _25.createdAt])||""),u=s?{asset:s,symbol:s.symbol,amount:P(_optionalChain([e, 'optionalAccess', _26 => _26.inputAmount]),s)}:{asset:null,symbol:(_optionalChain([e, 'optionalAccess', _27 => _27.inputToken])||"").slice(0,6)+"...",amount:P(_optionalChain([e, 'optionalAccess', _28 => _28.inputAmount]),null)},d=n?{asset:n,symbol:n.symbol,amount:P(_optionalChain([e, 'optionalAccess', _29 => _29.outputAmount]),n)}:{asset:null,symbol:(_optionalChain([e, 'optionalAccess', _30 => _30.outputToken])||"").slice(0,6)+"...",amount:P(_optionalChain([e, 'optionalAccess', _31 => _31.outputAmount]),null)};return _jsxruntime.jsxs.call(void 0, "a",{href:_optionalChain([e, 'optionalAccess', _32 => _32.explorerUrl])||"#",target:"_blank",rel:"noopener noreferrer",className:"group flex flex-col cursor-pointer transition-all duration-200 ease-in-out no-underline",style:{border:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:c?Ae(v):"transparent",marginBottom:"0.5rem",padding:"0.25rem"},onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center justify-between space-x-1",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center space-x-1",children:[_jsxruntime.jsx.call(void 0, "div",{className:"-translate-y-px",style:{color:p},children:f}),_jsxruntime.jsx.call(void 0, "p",{className:"text-2xs mono uppercase",style:{color:p},children:v})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center space-x-2",children:[_jsxruntime.jsxs.call(void 0, "span",{className:"text-2xs mono",style:{color:c?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:["\xAC ",_chunkBX3KCZRTcjs.r.call(void 0, _optionalChain([e, 'optionalAccess', _33 => _33.quoteId])||_optionalChain([e, 'optionalAccess', _34 => _34.orderHash])||"")]}),_jsxruntime.jsx.call(void 0, "svg",{className:"w-2.5 -translate-y-px opacity-70 group-hover:rotate-[-45deg] group-hover:opacity-100 duration-200",style:{color:"var(--widget-foreground)"},viewBox:"0 0 684 684",fill:"none",children:_jsxruntime.jsx.call(void 0, "path",{d:"M0.666687 384.667L519.92 384.667L281.627 622.96L342 683.333L683.333 342L342 0.666687L281.627 61.04L519.92 299.333L0.666687 299.333V384.667Z",fill:"currentColor"})})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center justify-between pr-2",style:{backgroundColor:c?"transparent":"var(--widget-secondary)"},children:[_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col w-full h-full p-2",children:_jsxruntime.jsx.call(void 0, "div",{className:"flex h-8 w-full items-center justify-between px-2",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center space-x-1",children:[_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.P,{asset:u.asset,size:"xs",className:"h-3 w-3"}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-sm h-4",style:{color:"var(--widget-muted-foreground)"},children:u.amount}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs",style:{color:"var(--widget-foreground)"},children:u.symbol})]}),_jsxruntime.jsx.call(void 0, "span",{className:"px-1",style:{color:"var(--widget-muted-foreground)"},children:"\u2192"}),_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.P,{asset:d.asset,size:"xs",className:"h-3 w-3"}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-sm h-4",style:{color:"var(--widget-muted-foreground)"},children:d.amount}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs",style:{color:"var(--widget-foreground)"},children:d.symbol})]})]})})}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col items-end text-right shrink-0",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs mono whitespace-nowrap",style:{color:"var(--widget-muted-foreground)"},children:l.date}),l.time&&_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs mono whitespace-nowrap",style:{color:"var(--widget-muted-foreground)",opacity:.6},children:l.time})]})]})]})};var fe=()=>_jsxruntime.jsxs.call(void 0, "div",{className:"mt-2 flex flex-col",style:{height:"4rem",border:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:"var(--widget-secondary)"},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center space-x-2 p-2",children:[_jsxruntime.jsx.call(void 0, "div",{className:"h-4 w-4 rounded",style:{backgroundColor:"var(--widget-muted)"}}),_jsxruntime.jsx.call(void 0, "div",{className:"h-3 w-24 rounded",style:{backgroundColor:"var(--widget-muted)"}})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-8 w-full items-center justify-between px-4",children:[_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center space-x-1",children:[4,16,10,4,16,10].map((e,s)=>_jsxruntime.jsx.call(void 0, "div",{className:"h-3 rounded",style:{width:`${e*4}px`,backgroundColor:"var(--widget-muted)"}},s))}),_jsxruntime.jsx.call(void 0, "div",{className:"h-3 w-10 rounded",style:{backgroundColor:"var(--widget-muted)"}})]})]}),pe=({isActive:e})=>{let{address:s}=_chunk34N36GUDcjs.a.call(void 0, ),{orders:n,isLoading:c,error:m,hasMore:v,loadMore:f}=ce(s,e),[p,w]=_react.useState.call(void 0, !1),l=_react.useRef.call(void 0, null),u=_react.useCallback.call(void 0, async d=>{let i=d.currentTarget;if(i.scrollTop+i.clientHeight>=i.scrollHeight-100&&!c&&!p&&v){w(!0);try{await f()}finally{w(!1)}}},[c,p,v,f]);return s?m?_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center justify-center p-4",children:_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",style:{color:"var(--widget-destructive)"},children:"Error loading activity"})}):_jsxruntime.jsx.call(void 0, "div",{ref:l,className:"flex flex-col flex-1 min-h-0 overflow-y-auto p-2",onScroll:u,style:{backgroundColor:"transparent"},children:c?Array.from({length:5}).map((d,i)=>_jsxruntime.jsx.call(void 0, fe,{},i)):n.length===0?_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col items-center justify-center h-full p-6",children:_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"No Activity"})}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[n.map(d=>_jsxruntime.jsx.call(void 0, me,{order:d,baseToken:_nullishCoalesce(_optionalChain([d, 'access', _35 => _35.enrichedTokens, 'optionalAccess', _36 => _36.base]), () => (null)),quoteToken:_nullishCoalesce(_optionalChain([d, 'access', _37 => _37.enrichedTokens, 'optionalAccess', _38 => _38.quote]), () => (null))},d.orderHash)),p&&_jsxruntime.jsx.call(void 0, fe,{})]})}):_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center justify-center p-4",children:_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Connect your wallet to view activity"})})};var Ee=()=>_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full h-full overflow-hidden",children:[_jsxruntime.jsx.call(void 0, "div",{className:"p-2 w-full flex justify-center",children:_jsxruntime.jsx.call(void 0, "div",{className:"relative w-full h-[140px] animate-pulse",style:{borderRadius:"var(--widget-radius)",border:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:"var(--widget-secondary)"}})}),_jsxruntime.jsx.call(void 0, "div",{className:"px-2 flex flex-col gap-1.5 mt-1",children:[80,60,72,55,65].map((e,s)=>_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between py-1.5",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, "div",{className:"h-6 w-6 rounded-full animate-pulse shrink-0",style:{backgroundColor:"var(--widget-secondary)"}}),_jsxruntime.jsx.call(void 0, "div",{className:"h-3.5 animate-pulse",style:{width:`${e}px`,backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}})]}),_jsxruntime.jsx.call(void 0, "div",{className:"h-3.5 w-14 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}})]},s))}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-auto shrink-0 p-2",style:{borderTop:"1px var(--widget-border-style) var(--widget-border)"},children:_jsxruntime.jsx.call(void 0, "div",{className:"w-full animate-pulse",style:{height:"34px",backgroundColor:"var(--widget-secondary)",opacity:.35,borderRadius:"var(--widget-radius)"}})})]}),It= exports.WidgetWalletPanel =()=>{let e=_chunk537OMWA3cjs.c.call(void 0, L=>L.walletTab),[s,n]=_react.useState.call(void 0, !1),{disconnect:c}=_wagmi.useDisconnect.call(void 0, ),{setQuoteToken:m}=_chunk537OMWA3cjs.f.call(void 0, ),v=_react.useCallback.call(void 0, async L=>{await m(L),_chunk537OMWA3cjs.c.getState().setView("swap")},[m]),{address:f,groupedAssets:p,totalBalance:w,balancesLoading:l,chains:u,getToken:d,useTokenWithLazyLoad:i,tokenRegistry:h}=oe(!0);return f?l&&e==="wallet"?_jsxruntime.jsx.call(void 0, Ee,{}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full h-full overflow-hidden",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex-1 overflow-y-auto",style:{minHeight:0},children:[e==="wallet"&&_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, ne,{address:f,totalBalance:w,isLoading:l}),_jsxruntime.jsx.call(void 0, de,{groupedAssets:p,chains:u,tokenRegistry:h,getToken:d,useTokenWithLazyLoad:i,onAssetSelect:v})]}),e==="activity"&&_jsxruntime.jsx.call(void 0, pe,{isActive:e==="activity"})]}),_jsxruntime.jsx.call(void 0, "div",{className:"shrink-0 p-2",style:{borderTop:"1px var(--widget-border-style) var(--widget-border)"},children:_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>{c(),_chunk537OMWA3cjs.c.getState().setView("swap")},onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),className:"w-full py-2 text-xs mono uppercase cursor-pointer transition-colors",style:{backgroundColor:s?"var(--widget-destructive)":"transparent",color:s?"var(--widget-destructive-foreground)":"var(--widget-destructive)",border:"1px var(--widget-border-style) var(--widget-destructive)",borderRadius:"var(--widget-radius)"},children:"Sign Out"})})]}):_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col items-center justify-center h-full p-4",children:_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Connect your wallet to view your portfolio"})})};exports.WidgetWalletPanel = It;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";import{a as ve}from"./chunk-OPN7WCJR.js";import{c as E,f as se}from"./chunk-JSWDMAZQ.js";import{F as Z,H as Q,I as X,L as J,O as Y,P as M,R as ee,S as te,_ as re,b as G,e as V,h as _,k as R,q,r as K}from"./chunk-CHDFHEPH.js";import{a as B}from"./chunk-46H44R7V.js";import{b as ge}from"./chunk-73CB2I7U.js";import{useCallback as Me,useState as He}from"react";import{useDisconnect as Be}from"wagmi";import{useCallback as ye,useEffect as we,useMemo as D,useRef as he}from"react";function oe(e){let{address:s,isConnected:n}=B(),{chainDataMap:c}=X(),m=re(),{getToken:v,tokenRegistry:f}=Z(),{supportedInputTokens:p,supportedOutputTokens:w}=G(),l=D(()=>{if(!p.length&&!w.length)return[];let t=new Set,o=[];for(let x of[...p,...w]){let S=`${x.chainId}-${x.address.toLowerCase()}`;t.has(S)||(t.add(S),o.push(x))}return o},[p,w]),{balances:u,isLoading:d,isError:i,refetch:h}=J(s,m,{enabled:n&&e&&!!s,refetchOnWindowFocus:!1},l.length>0?l:void 0),L=D(()=>l.length?new Set(l.map(t=>`${t.chainId}-${t.address.toLowerCase()}`)):null,[l]),r=D(()=>!u||u.length===0?{}:u.filter(o=>!o.assetInfo||!o.balance||o.balance==="0"?!1:L?L.has(`${o.chainId}-${o.address.toLowerCase()}`):R(o.assetInfo)||f.length===0?!0:f.some(x=>x.address.toLowerCase()===o.address.toLowerCase()&&x.chainId===o.chainId)).reduce((o,x)=>{let S=String(x.chainId);return o[S]||(o[S]=[]),o[S].push({token:x.address,amount:x.balance,decimals:x.decimals,assetInfo:x.assetInfo}),o},{}),[u,f,L]),k=D(()=>!u||u.length===0?0:u.reduce((t,o)=>!o.assetInfo||o.decimals===void 0?t:t+parseFloat(o.balance)/10**o.decimals*(o.assetInfo.price||0),0),[u]),T=D(()=>m.length===0?{}:m.reduce((t,o)=>{let x=c[o],S=V(o);return t[o.toString()]={chainId:o,name:S?.displayName||x?.chainKey||`Chain ${o}`},t},{}),[m,c]),W=D(()=>f.map(t=>({address:t.address,chainId:t.chainId})),[f]),N=he(null);we(()=>()=>{N.current&&clearTimeout(N.current)},[]);let A=ye(()=>{N.current&&clearTimeout(N.current),N.current=setTimeout(()=>h(),2e3)},[h]);return{address:s,isConnected:n,groupedAssets:r,totalBalance:k,balancesLoading:d,balancesError:i,chains:T,getToken:v,useTokenWithLazyLoad:Q,tokenRegistry:W,refetchBalances:A}}var ae=ge(ve(),1);import{jsx as I,jsxs as $}from"react/jsx-runtime";var ne=({address:e,totalBalance:s,isLoading:n=!1})=>{let c=m=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(m);return I("div",{className:"p-2 w-full flex justify-center",children:$("div",{className:"relative w-full h-[140px] overflow-hidden",style:{borderRadius:"var(--widget-radius)",border:"1px var(--widget-border-style) var(--widget-border)"},children:[$("div",{className:"absolute inset-0 z-0",children:[I("img",{className:"w-full h-full object-cover opacity-60",src:(0,ae.makeGradient)(e),alt:"address gradient"}),I("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent"})]}),$("div",{className:"relative z-10 flex h-full flex-col justify-between p-3",children:[$("div",{children:[I("p",{className:"text-2xs uppercase mono",style:{color:"var(--widget-muted-foreground)",opacity:.7},children:"Token Balance:"}),n?I(te,{className:"h-8 w-28 bg-white/10 rounded mt-1"}):I("p",{className:"text-2xl font-bold mt-0.5",style:{color:"var(--widget-foreground)"},children:c(s)})]}),I("div",{className:"flex items-center",children:I(ee,{text:e,type:"address",children:I("p",{className:"mono text-2xs",style:{color:"var(--widget-foreground)",opacity:.7},children:e})})})]})]})})};import{useCallback as j,useMemo as le,useState as ke}from"react";import{useState as xe}from"react";import{jsx as H,jsxs as U}from"react/jsx-runtime";var ie=({asset:e,balanceAmount:s,balanceDecimals:n,price:c,onSelect:m,getToken:v,useTokenWithLazyLoad:f})=>{let[p,w]=xe(!1),l=n!==void 0?parseFloat(s)/10**n:0,d=f?.(e.chainId,e.address)?.token,i=c??null;return R(e)&&i==null&&(d?.price!=null?i=d.price:v&&(i=v(e.chainId,e.address)?.price??null)),H("div",{role:"button",tabIndex:0,className:"flex h-[52px] w-full flex-row items-center p-3 cursor-pointer transition-colors",style:{borderBottom:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:p?"var(--widget-secondary)":"transparent"},onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1),onClick:()=>m?.(e),onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),m?.(e))},children:U("div",{className:"flex h-full w-full flex-row items-center justify-between",children:[U("div",{className:"flex h-full flex-row items-center gap-2",children:[H(M,{asset:e,size:"sm"}),U("div",{className:"flex flex-col items-start",children:[H("p",{className:"text-sm font-medium uppercase",style:{color:"var(--widget-foreground)"},children:e.symbol}),l>0&&H("p",{className:"mono text-xs",style:{color:"var(--widget-muted-foreground)"},children:l.toFixed(4)})]})]}),H("p",{className:"text-sm font-medium",style:{color:"var(--widget-foreground)"},children:i!=null?`$${(i*l).toFixed(2)}`:"\u2014"})]})})};import{jsx as C,jsxs as z}from"react/jsx-runtime";var be=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}),Ne=_(),de=({groupedAssets:e,chains:s,tokenRegistry:n=[],getToken:c,useTokenWithLazyLoad:m,onAssetSelect:v})=>{let[f,p]=ke(new Set),w=j(r=>s?.[r]?.name||Ne[r]||`Chain ${r}`,[s]),l=le(()=>{let r=new Set;for(let k of n)r.add(`${k.chainId}-${k.address.toLowerCase()}`);return r},[n]),u=j(r=>r.decimals===void 0||!r.assetInfo?.price?0:parseFloat(r.amount)/10**r.decimals*r.assetInfo.price,[]),{filteredGroupedAssets:d,chainTotals:i}=le(()=>{let r=Object.entries(e).map(([W,N])=>{let A=N.filter(t=>t.assetInfo?R(t.assetInfo)?!0:l.size>0?l.has(`${t.assetInfo.chainId}-${t.assetInfo.address?.toLowerCase()??""}`):!0:!1);return[W,A]}).filter(([,W])=>W.length>0),k={};for(let[W,N]of r)k[W]=N.reduce((A,t)=>A+u(t),0);return{filteredGroupedAssets:[...r].sort((W,N)=>(k[N[0]]??0)-(k[W[0]]??0)),chainTotals:k}},[e,l,u]),h=j(r=>{p(k=>{let T=new Set(k);return T.has(r)?T.delete(r):T.add(r),T})},[]),L=r=>be.format(r);return d.length===0?C("div",{className:"flex items-center justify-center p-6",children:C("p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"No token balances found"})}):C("div",{className:"pb-2 pt-1",children:d.map(([r,k])=>{let T=parseInt(r),W=w(T),N=i[r]||0,A=f.has(r);return z("div",{className:"mx-2 mb-2",style:{border:"1px var(--widget-border-style) var(--widget-border)",borderRadius:"var(--widget-radius)",overflow:"hidden"},children:[z("button",{type:"button",onClick:()=>h(r),className:"flex w-full flex-row items-center justify-between p-2 cursor-pointer transition-colors hover:bg-(--widget-secondary)",style:{backgroundColor:"transparent"},children:[z("div",{className:"inline-flex flex-row items-center gap-2",children:[C(Y,{chain:T,size:"sm"}),C("p",{className:"text-sm font-medium capitalize",style:{color:"var(--widget-foreground)"},children:W})]}),z("div",{className:"flex items-center gap-2",children:[C("p",{className:"text-sm font-semibold",style:{color:"var(--widget-foreground)"},children:L(N)}),C("span",{className:`transition-transform duration-200 ${A?"rotate-180":""}`,style:{color:"var(--widget-muted-foreground)"},children:C("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:C("path",{d:"M2.5 4.5L6 8L9.5 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),C("div",{className:`overflow-hidden transition-all duration-200 ease-out ${A?"max-h-[2000px] opacity-100":"max-h-0 opacity-0"}`,children:C("div",{style:{borderTop:"1px var(--widget-border-style) var(--widget-border)"},children:k.map(t=>t.assetInfo?C(ie,{asset:t.assetInfo,balanceAmount:t.amount,balanceDecimals:t.decimals,price:t.assetInfo?.price??null,onSelect:v,getToken:c,useTokenWithLazyLoad:m},`${t.assetInfo.chainId}-${t.token}`):null)})})]},r)})})};import{useCallback as Se,useRef as Re,useState as De}from"react";function ce(e,s){return{orders:[],isLoading:!1,error:null,hasMore:!1,loadMore:async()=>{},totalOrders:0}}import{useState as Ce}from"react";import{jsx as a,jsxs as b}from"react/jsx-runtime";var We=()=>b("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[a("circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),a("path",{d:"M3 5.2L4.3 6.5L7 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Te=()=>b("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[a("circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),a("path",{d:"M3.5 3.5L6.5 6.5M6.5 3.5L3.5 6.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})]}),Le=()=>b("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[a("circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),a("path",{d:"M5 3V5.5L6.5 6.5",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round"})]}),ue=()=>b("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[a("circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),a("circle",{cx:"5",cy:"5",r:"1.5",fill:"currentColor"})]}),Ie=e=>{switch((e||"").toLowerCase()){case"completed":case"settled":case"success":case"swapped":case"swap":return{icon:a(We,{}),color:"var(--widget-primary)"};case"received":return{icon:a(ue,{}),color:"var(--widget-accent)"};case"failed":case"error":case"expired":return{icon:a(Te,{}),color:"var(--widget-destructive)"};case"pending":case"created":case"placed":return{icon:a(Le,{}),color:"var(--widget-muted-foreground)"};default:return{icon:a(ue,{}),color:"var(--widget-muted-foreground)"}}},Ae=e=>{switch((e||"").toLowerCase()){case"completed":case"settled":case"success":case"swapped":case"swap":return"color-mix(in srgb, var(--widget-primary) 5%, transparent)";case"failed":case"error":case"expired":return"color-mix(in srgb, var(--widget-destructive) 5%, transparent)";case"pending":case"created":case"placed":return"color-mix(in srgb, var(--widget-accent) 5%, transparent)";default:return"var(--widget-secondary)"}},P=(e,s)=>{try{let n=parseFloat(e||"0");if(isNaN(n)||n===0)return"0";let c=s?.decimals??18;return q(n/10**c)}catch{return"0"}},me=({order:e,baseToken:s,quoteToken:n})=>{let[c,m]=Ce(!1),v=e?.status||e?.eventType||"unknown",{icon:f,color:p}=Ie(v),l=(i=>{if(!i)return{date:"",time:""};let h=new Date(typeof i=="number"?i:Number(i)||i);return{date:h.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),time:h.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",timeZone:"UTC",hour12:!1})+" UTC"}})(e?.timestamp||e?.createdAt||""),u=s?{asset:s,symbol:s.symbol,amount:P(e?.inputAmount,s)}:{asset:null,symbol:(e?.inputToken||"").slice(0,6)+"...",amount:P(e?.inputAmount,null)},d=n?{asset:n,symbol:n.symbol,amount:P(e?.outputAmount,n)}:{asset:null,symbol:(e?.outputToken||"").slice(0,6)+"...",amount:P(e?.outputAmount,null)};return b("a",{href:e?.explorerUrl||"#",target:"_blank",rel:"noopener noreferrer",className:"group flex flex-col cursor-pointer transition-all duration-200 ease-in-out no-underline",style:{border:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:c?Ae(v):"transparent",marginBottom:"0.5rem",padding:"0.25rem"},onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),children:[b("div",{className:"flex flex-row items-center justify-between space-x-1",children:[b("div",{className:"flex flex-row items-center space-x-1",children:[a("div",{className:"-translate-y-px",style:{color:p},children:f}),a("p",{className:"text-2xs mono uppercase",style:{color:p},children:v})]}),b("div",{className:"flex flex-row items-center space-x-2",children:[b("span",{className:"text-2xs mono",style:{color:c?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:["\xAC ",K(e?.quoteId||e?.orderHash||"")]}),a("svg",{className:"w-2.5 -translate-y-px opacity-70 group-hover:rotate-[-45deg] group-hover:opacity-100 duration-200",style:{color:"var(--widget-foreground)"},viewBox:"0 0 684 684",fill:"none",children:a("path",{d:"M0.666687 384.667L519.92 384.667L281.627 622.96L342 683.333L683.333 342L342 0.666687L281.627 61.04L519.92 299.333L0.666687 299.333V384.667Z",fill:"currentColor"})})]})]}),b("div",{className:"flex flex-row items-center justify-between pr-2",style:{backgroundColor:c?"transparent":"var(--widget-secondary)"},children:[a("div",{className:"flex flex-col w-full h-full p-2",children:a("div",{className:"flex h-8 w-full items-center justify-between px-2",children:b("div",{className:"flex items-center space-x-1",children:[a(M,{asset:u.asset,size:"xs",className:"h-3 w-3"}),b("div",{className:"flex flex-col",children:[a("span",{className:"text-sm h-4",style:{color:"var(--widget-muted-foreground)"},children:u.amount}),a("span",{className:"text-xs",style:{color:"var(--widget-foreground)"},children:u.symbol})]}),a("span",{className:"px-1",style:{color:"var(--widget-muted-foreground)"},children:"\u2192"}),a(M,{asset:d.asset,size:"xs",className:"h-3 w-3"}),b("div",{className:"flex flex-col",children:[a("span",{className:"text-sm h-4",style:{color:"var(--widget-muted-foreground)"},children:d.amount}),a("span",{className:"text-xs",style:{color:"var(--widget-foreground)"},children:d.symbol})]})]})})}),b("div",{className:"flex flex-col items-end text-right shrink-0",children:[a("span",{className:"text-2xs mono whitespace-nowrap",style:{color:"var(--widget-muted-foreground)"},children:l.date}),l.time&&a("span",{className:"text-2xs mono whitespace-nowrap",style:{color:"var(--widget-muted-foreground)",opacity:.6},children:l.time})]})]})]})};import{Fragment as Fe,jsx as y,jsxs as O}from"react/jsx-runtime";var fe=()=>O("div",{className:"mt-2 flex flex-col",style:{height:"4rem",border:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:"var(--widget-secondary)"},children:[O("div",{className:"flex items-center space-x-2 p-2",children:[y("div",{className:"h-4 w-4 rounded",style:{backgroundColor:"var(--widget-muted)"}}),y("div",{className:"h-3 w-24 rounded",style:{backgroundColor:"var(--widget-muted)"}})]}),O("div",{className:"flex h-8 w-full items-center justify-between px-4",children:[y("div",{className:"flex items-center space-x-1",children:[4,16,10,4,16,10].map((e,s)=>y("div",{className:"h-3 rounded",style:{width:`${e*4}px`,backgroundColor:"var(--widget-muted)"}},s))}),y("div",{className:"h-3 w-10 rounded",style:{backgroundColor:"var(--widget-muted)"}})]})]}),pe=({isActive:e})=>{let{address:s}=B(),{orders:n,isLoading:c,error:m,hasMore:v,loadMore:f}=ce(s,e),[p,w]=De(!1),l=Re(null),u=Se(async d=>{let i=d.currentTarget;if(i.scrollTop+i.clientHeight>=i.scrollHeight-100&&!c&&!p&&v){w(!0);try{await f()}finally{w(!1)}}},[c,p,v,f]);return s?m?y("div",{className:"flex items-center justify-center p-4",children:y("p",{className:"text-sm",style:{color:"var(--widget-destructive)"},children:"Error loading activity"})}):y("div",{ref:l,className:"flex flex-col flex-1 min-h-0 overflow-y-auto p-2",onScroll:u,style:{backgroundColor:"transparent"},children:c?Array.from({length:5}).map((d,i)=>y(fe,{},i)):n.length===0?y("div",{className:"flex flex-col items-center justify-center h-full p-6",children:y("p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"No Activity"})}):O(Fe,{children:[n.map(d=>y(me,{order:d,baseToken:d.enrichedTokens?.base??null,quoteToken:d.enrichedTokens?.quote??null},d.orderHash)),p&&y(fe,{})]})}):y("div",{className:"flex items-center justify-center p-4",children:y("p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Connect your wallet to view activity"})})};import{Fragment as $e,jsx as g,jsxs as F}from"react/jsx-runtime";var Ee=()=>F("div",{className:"flex flex-col w-full h-full overflow-hidden",children:[g("div",{className:"p-2 w-full flex justify-center",children:g("div",{className:"relative w-full h-[140px] animate-pulse",style:{borderRadius:"var(--widget-radius)",border:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:"var(--widget-secondary)"}})}),g("div",{className:"px-2 flex flex-col gap-1.5 mt-1",children:[80,60,72,55,65].map((e,s)=>F("div",{className:"flex items-center justify-between py-1.5",children:[F("div",{className:"flex items-center gap-2",children:[g("div",{className:"h-6 w-6 rounded-full animate-pulse shrink-0",style:{backgroundColor:"var(--widget-secondary)"}}),g("div",{className:"h-3.5 animate-pulse",style:{width:`${e}px`,backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}})]}),g("div",{className:"h-3.5 w-14 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}})]},s))}),g("div",{className:"mt-auto shrink-0 p-2",style:{borderTop:"1px var(--widget-border-style) var(--widget-border)"},children:g("div",{className:"w-full animate-pulse",style:{height:"34px",backgroundColor:"var(--widget-secondary)",opacity:.35,borderRadius:"var(--widget-radius)"}})})]}),It=()=>{let e=E(L=>L.walletTab),[s,n]=He(!1),{disconnect:c}=Be(),{setQuoteToken:m}=se(),v=Me(async L=>{await m(L),E.getState().setView("swap")},[m]),{address:f,groupedAssets:p,totalBalance:w,balancesLoading:l,chains:u,getToken:d,useTokenWithLazyLoad:i,tokenRegistry:h}=oe(!0);return f?l&&e==="wallet"?g(Ee,{}):F("div",{className:"flex flex-col w-full h-full overflow-hidden",children:[F("div",{className:"flex-1 overflow-y-auto",style:{minHeight:0},children:[e==="wallet"&&F($e,{children:[g(ne,{address:f,totalBalance:w,isLoading:l}),g(de,{groupedAssets:p,chains:u,tokenRegistry:h,getToken:d,useTokenWithLazyLoad:i,onAssetSelect:v})]}),e==="activity"&&g(pe,{isActive:e==="activity"})]}),g("div",{className:"shrink-0 p-2",style:{borderTop:"1px var(--widget-border-style) var(--widget-border)"},children:g("button",{type:"button",onClick:()=>{c(),E.getState().setView("swap")},onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),className:"w-full py-2 text-xs mono uppercase cursor-pointer transition-colors",style:{backgroundColor:s?"var(--widget-destructive)":"transparent",color:s?"var(--widget-destructive-foreground)":"var(--widget-destructive)",border:"1px var(--widget-border-style) var(--widget-destructive)",borderRadius:"var(--widget-radius)"},children:"Sign Out"})})]}):g("div",{className:"flex flex-col items-center justify-center h-full p-4",children:g("p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Connect your wallet to view your portfolio"})})};export{It as WidgetWalletPanel};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
|
+
var _react = require('react');var _wagmi = require('wagmi');function r(){let[e,t]=_react.useState.call(void 0, !1);return _react.useEffect.call(void 0, ()=>{t(!0)},[]),e}function a(){let e=r(),{address:t,isConnected:n,isConnecting:o,isReconnecting:s}=_wagmi.useAccount.call(void 0, );return{mounted:e,address:t,isConnected:n,isLoading:o||s}}exports.a = a;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{useEffect as u,useState as c}from"react";import{useAccount as i}from"wagmi";function r(){let[e,t]=c(!1);return u(()=>{t(!0)},[]),e}function a(){let e=r(),{address:t,isConnected:n,isConnecting:o,isReconnecting:s}=i();return{mounted:e,address:t,isConnected:n,isLoading:o||s}}export{a};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{a as vr}from"./chunk-OPN7WCJR.js";import{c as he,f as Ne}from"./chunk-JSWDMAZQ.js";import{B as tt,C as rt,J as Rt,K as nt,O as Me,P as ce,Q as Y,T as ge,U as At,V as De,W as G,Y as kt,Z as We,_ as Nt,b as Te,c as _e,e as j,j as vt,m as Re,o as Ae,q as ke,s as xt,t as re,u as Ct,v as Ze,x as et,y as St,z as Tt}from"./chunk-CHDFHEPH.js";import{a as ne}from"./chunk-46H44R7V.js";import{b as yr}from"./chunk-73CB2I7U.js";import{useQueryClient as xr}from"@tanstack/react-query";import{useCallback as Cr,useEffect as It,useRef as Et}from"react";function Sr(e){if(e.length===0)return 5e3;let u=Math.max(...e.map(r=>j(r)?.blockTimeMs??2e3));return Math.min(5e3,Math.max(1e3,u*2+1e3))}var Tr=()=>{let{address:e}=ne(),t=Nt(),s=xr(),l=Et(null),u=Et(!0),r=Cr(a=>{if(!e)return;let h=[...new Set(a.tokens.map(p=>p.asset.chainId))],b=Sr(h);l.current&&(clearTimeout(l.current),l.current=null),l.current=setTimeout(async()=>{if(l.current=null,!!u.current)try{let p=a.tokens.map(f=>({chainId:f.asset.chainId,tokenAddress:f.asset.address})),i=await Rt(e,p);if(i.balances.length===0)return;if(a.tokens.length>=2){let f=a.tokens[0].asset,c=a.tokens[1].asset,x=nt.swap(e,f.chainId,f.address,c.chainId,c.address);s.setQueryData(x,i)}let n=nt.bulk(e,t),w=s.getQueryData(n);if(w){let f=w.balances.map(c=>i.balances.find(g=>g.chainId===c.chainId&&g.token.toLowerCase()===c.token.toLowerCase())??c);for(let c of i.balances)f.some(x=>x.chainId===c.chainId&&x.token.toLowerCase()===c.token.toLowerCase())||f.push(c);for(let c of a.tokens)if(!i.balances.some(g=>g.chainId===c.asset.chainId&&g.token.toLowerCase()===c.asset.address.toLowerCase())){let g=f.findIndex(o=>o.chainId===c.asset.chainId&&o.token.toLowerCase()===c.asset.address.toLowerCase());g!==-1&&(f[g]={...f[g],balance:"0",shiftedBalance:"0"})}s.setQueryData(n,{balances:f})}}catch{}},b)},[e,t,s]);return It(()=>(u.current=!0,()=>{u.current=!1,l.current&&(clearTimeout(l.current),l.current=null)}),[]),{triggerBalanceUpdate:r}},st=class extends EventTarget{emit(t){this.dispatchEvent(new CustomEvent("balance-update",{detail:t}))}},ot=new st,Ee=()=>e=>ot.emit(e),ts=()=>{let{triggerBalanceUpdate:e}=Tr();It(()=>{let t=s=>{e(s.detail)};return ot.addEventListener("balance-update",t),()=>ot.removeEventListener("balance-update",t)},[e])};import{createContext as Rr,useCallback as le,useContext as Ar,useEffect as Ot,useMemo as kr,useRef as se,useState as ye}from"react";import{formatUnits as Nr,parseUnits as Er}from"viem";import{jsx as Ur}from"react/jsx-runtime";var $t=Rr(void 0),Pt=1e4,Ir=3e4,Or=1e3,Pr=2;function $r(e){return e.find(s=>s.routeSteps?.[0]?.type==="AORI_V1")??e[0]}var ls=({children:e,recipient:t})=>{let{address:s}=ne(),l=t||s,[u,r]=ye("idle"),[a,h]=ye("idle"),[b,p]=ye(null),[i,n]=ye(null),[w,f]=ye(!1),[c,x]=ye(!1),[g,o]=ye(!1),m=se(null),y=se(null),d=se(null),T=se(null),P=se(null),C=se(0),$=se(0),L=se(0),N=se(!1),E=se(new Map),I=le(()=>{d.current&&clearTimeout(d.current),T.current&&clearTimeout(T.current),P.current&&clearTimeout(P.current),d.current=null,T.current=null,P.current=null},[]),U=le(()=>{I(),m.current=null,C.current=0,r(()=>N.current?"fresh":"idle")},[I]),B=le(()=>{U(),y.current=null,p(null),n(null),f(!1),x(!1),o(!1),E.current.clear(),r("idle"),h("idle")},[U]),oe=le(v=>{if(!v)return;T.current&&clearTimeout(T.current);let S=Math.max(0,v+Ir-Date.now());T.current=setTimeout(()=>{r(O=>O==="idle"?"idle":"stale")},S)},[]),H=le(async(v,S)=>{let{inputToken:O,outputToken:A,inputAmount:q,setOutputAmount:Z}=v;if(!O||!A||!q||parseFloat(q)<=0||Date.now()-($.current||0)<Pt-10)return;let Be=++C.current;try{if(!O?.decimals||!A?.decimals)return;let z=rt(O.chainId)||j(O.chainId)?.key||"",ie=rt(A.chainId)||j(A.chainId)?.key||"";if(!z||!ie)throw new Error("Unknown chain");let ee=Er(q.toString(),O.decimals).toString(),Ce={srcChainKey:z,dstChainKey:ie,srcTokenAddress:et(O.address),dstTokenAddress:et(A.address),amount:ee,srcWalletAddress:s||"0x0000000000000000000000000000000000000000",dstWalletAddress:l||s||"0x0000000000000000000000000000000000000000",options:{amountType:"EXACT_SRC_AMOUNT",feeTolerance:{type:"PERCENT",amount:2}}};$.current=Date.now();let te=await fetch(`${Re()}/quotes`,{method:"POST",headers:Ae(),body:JSON.stringify(Ce),signal:AbortSignal.timeout(15e3)});if(!te.ok){let Se=(await te.json().catch(()=>({})))?.message||te.statusText;throw Object.assign(new Error(Se),{status:te.status})}let me=await te.json();if(Be!==C.current||m.current!==S)return;let $e=me.quotes??[],ae=$r($e);if(!ae)throw Object.assign(new Error("No quotes returned"),{emptyQuotes:!0});let Je=Number(Nr(xt(ae.dstAmount),A.decimals));typeof Z=="function"&&Z(Je),ae._receivedAt=Date.now(),p(ae),n(null),f(!1),r("fresh"),oe(ae._receivedAt),S&&E.current.delete(S)}catch(z){if(Be!==C.current||m.current!==S)return;let ie=z?.status,ee=z instanceof Error?z.message:"",Ce=!!z?.emptyQuotes;if((ie===400||Ce||ee.includes("Quote request failed"))&&S){let me=(E.current.get(S)||0)+1;if(E.current.set(S,me),me>=Pr){x(!0),I(),m.current=null;return}}if(ee.toLowerCase().includes("order cap exceeded")){o(!0),I(),m.current=null;return}if(ee.toLowerCase().includes("insufficient executor balance")){f(!0),I(),m.current=null;return}n(z instanceof Error?z.message:"Unknown error")}},[s,l,oe,I]),W=le((v,S)=>{I(),y.current=v,$.current=0,E.current.delete(S),f(!1),x(!1),o(!1),n(null),r("polling");let O=async()=>{m.current===S&&(await H(v,S),m.current===S&&(d.current=setTimeout(O,Pt)))};O()},[I,H]),R=le(v=>{if(!v?.inputToken||!v?.outputToken||!v?.inputAmount||parseFloat(v.inputAmount)<=0){U();return}let S=y.current;if(S&&S.inputToken?.address===v.inputToken?.address&&S.inputToken?.chainId===v.inputToken?.chainId&&S.outputToken?.address===v.outputToken?.address&&S.outputToken?.chainId===v.outputToken?.chainId&&S.inputAmount===v.inputAmount&&m.current)return;let A=Date.now();if(A-L.current<100)return;L.current=A;let q=`${Date.now()}-${Math.random().toString(36).slice(2)}`;m.current=q,W(v,q)},[W,U]),V=le(({amount:v,inputToken:S,outputToken:O,setOutputAmount:A})=>{A(null),P.current&&clearTimeout(P.current),!v||v===0?(h("idle"),U(),p(null),n(null),f(!1),x(!1),o(!1)):(h("typing"),U(),p(null),f(!1),x(!1),o(!1),n(null),P.current=setTimeout(()=>{h("settled"),S&&O&&v>0&&R({inputToken:S,outputToken:O,inputAmount:v.toString(),setOutputAmount:A})},Or))},[U,R]),F=le(()=>{let v=y.current;if(!v)return;p(null);let S=`${Date.now()}-${Math.random().toString(36).slice(2)}`;m.current=S,r("refreshing"),typeof v.setOutputAmount=="function"&&v.setOutputAmount(null),W(v,S)},[W]);Ot(()=>{N.current=!!b},[b]),Ot(()=>()=>I(),[I]);let X=kr(()=>({status:u,inputState:a,rfqQuote:b,error:i,liquidityError:w,routingError:c,sizeCapError:g,ensureForParams:R,stop:U,refresh:F,clear:B,handleInputChange:V}),[u,a,b,i,w,c,g,R,U,F,B,V]);return Ur($t.Provider,{value:X,children:e})},Ve=()=>{let e=Ar($t);if(e===void 0)throw new Error("useRfq must be used within an RfqProvider");return e};import{createContext as Mr,useContext as Dr}from"react";var Wr=Mr({openConnectModal:()=>{}}),ms=()=>Dr(Wr);import{useCallback as it,useEffect as Ie,useRef as Fe,useState as at}from"react";import{jsx as Oe,jsxs as _r}from"react/jsx-runtime";var Lr=20,Br=({side:e,asset:t,otherAsset:s,isPlacingOrder:l,isWrappingPair:u,isUnwrappingPair:r})=>{let{baseAmount:a,quoteAmount:h,setBaseAmount:b,setQuoteAmount:p}=Ne(),{amountInputVariant:i,hideAmountInputSymbol:n,widgetType:w}=Te(),f=w==="compact",[c,x]=e==="base"?[b,p]:[p,b],g=!t||e==="quote"||l,o=f?32:i==="default"?64:32,[m,y]=at(o),[d,T]=at(""),P=Fe(null),C=Fe(null),$=Fe(null),L=Fe(null),N="USD",E=e==="base"?a:h,[I,U]=at(!1),B=it(()=>{if(i!=="default"){y(o);return}if(!P.current||!C.current||!$.current)return;let W=P.current.offsetWidth,R=20,V=o;for(;V>20&&(C.current.style.fontSize=`${V}px`,$.current.style.fontSize=`${V}px`,!(C.current.offsetWidth+$.current.offsetWidth+R<=W));)V-=1;y(V)},[i,o]),oe=it(W=>{W.key==="."&&d.includes(".")&&W.preventDefault()},[d]),H=it(W=>{let R=W.target.value;if(R==="."&&(R="0."),!/^\d*\.?\d*$/.test(R)||(R.match(/\./g)||[]).length>1)return;if(R.length>1&&R[0]==="0"&&R[1]!=="."&&(R=R.replace(/^0+/,"")||"0"),t?.decimals!==void 0&&R.includes(".")){let[,F]=R.split(".");if(F&&F.length>t.decimals)return}if(R.length>Lr)return;T(R);let V=parseFloat(R);R!==d&&(R===""||R==="0."||R.endsWith(".")?(c(null),e==="base"&&x(null)):!Number.isNaN(V)&&V>=0&&c(V),e==="base"&&p(null),(r||u)&&p(V||0))},[d,c,e,p,t?.decimals,x,r,u]);return Ie(()=>{let W=F=>{if(F===null)return"";let X=t?.decimals;if(X===void 0)return"";let v=F.toString();if(/e/i.test(v)&&(v=Number(F).toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:X})),v.includes(".")){let[S,O]=v.split("."),A=O.slice(0,X);return A?`${S}.${A}`:S}return v};if(E===null){d==="0."||d!==""&&d.endsWith(".")||T("");return}if(!g&&(d.endsWith(".")||d.match(/\.\d*0$/)||d==="0"||d==="0.")&&d!=="")return;let V=parseFloat(d)||0;(d===""||Math.abs(V-E)>1e-10)&&T(W(E))},[E,t?.decimals,d,g]),Ie(()=>{B()},[d,B]),Ie(()=>{U(!0)},[]),Ie(()=>{I&&B()},[I,B]),Ie(()=>{C.current&&L.current&&(L.current.style.width=`${C.current.offsetWidth}px`)},[d]),Ie(()=>{if(!I)return;let W=new ResizeObserver(()=>{I&&B()});return P.current&&W.observe(P.current),()=>W.disconnect()},[I,B]),Oe("div",{ref:P,style:{fontSize:`${m}px`,transition:"font-size 0.05s ease-in-out"},className:`mt-2 box-border flex ${f?i==="normal"?"h-12 my-1":"h-10 my-0.5":i==="normal"?"h-12 my-1":"h-20 my-1"} w-full flex-row items-center ${g?"cursor-default":"cursor-text"}`,onClick:()=>L.current?.focus(),children:_r("div",{className:"relative flex w-full items-center",children:[Oe("label",{htmlFor:`${e}Amount`,className:"sr-only",children:e==="base"?"Input token amount":"Output token amount"}),Oe("input",{ref:L,type:"text",inputMode:"decimal",placeholder:"0",autoComplete:"off",id:`${e}Amount`,value:d,onWheel:W=>W.target.blur(),onKeyDown:oe,onChange:H,style:{transition:"width 0.15s ease-in-out",color:"var(--widget-foreground)",WebkitTextFillColor:"var(--widget-foreground)",opacity:g?.4:1},className:"flex min-w-[45px] whitespace-nowrap bg-transparent placeholder:opacity-50",disabled:g}),Oe("span",{style:{transition:"width 0.15s ease-in-out"},ref:C,className:"pointer-events-none absolute flex whitespace-nowrap invisible",children:d||0}),!n&&i!=="normal"&&Oe("span",{ref:$,className:"ml-2 font-light uppercase",style:{color:"var(--widget-foreground)",opacity:.5,fontSize:`${m}px`},children:t?.symbol?t.symbol.length>6?`${t.symbol.slice(0,6)}...`:t.symbol:N}),(n||i==="normal")&&Oe("span",{ref:$,className:"hidden"})]})})},ys=Br;import{Fragment as ct,jsx as D,jsxs as ue}from"react/jsx-runtime";var Vr=({toggle:e,side:t,asset:s,isPlacingOrder:l})=>{let{baseBalance:u,quoteBalance:r}=Ne(),{tokenDisplay:a,tokenBadgeOrientation:h,widgetType:b}=Te(),p=b==="compact",i=p?"h-10":"h-12",n=p?"h-10 w-10":"h-12 w-12",w=t==="base"?u.formatted?(()=>{let c=parseFloat(u.formatted);return c>=1e8?ke(c):c.toFixed(3)})():void 0:r.formatted?(()=>{let c=parseFloat(r.formatted);return c>=1e8?ke(c):c.toFixed(3)})():void 0,f={role:"button",tabIndex:l?-1:0,"aria-disabled":l,"aria-label":`Select ${t==="base"?"input":"output"} token${s?`: ${s.symbol}`:""}`,onClick:l?void 0:e,onKeyDown:l?void 0:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),e())}};return a==="pill"?D("div",{...f,className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-full cursor-pointer transition-colors ${h==="right"?"ml-auto":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-secondary)",color:"var(--widget-secondary-foreground)"},children:s?ue(ct,{children:[D(Me,{chain:s.chainId,size:"xs"}),D(ce,{className:"rounded-full",asset:s,size:"xxs",noChain:!0}),D("span",{className:"text-xs font-medium uppercase",children:s.symbol}),D(De,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]}):ue(ct,{children:[D("span",{className:"text-xs opacity-70",children:"Select"}),D(De,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]})}):a==="ghost"?ue("div",{...f,className:"inline-flex items-center gap-1.5 cursor-pointer transition-opacity hover:opacity-70 py-1",style:{color:"var(--widget-foreground)"},children:[s?ue(ct,{children:[D(Me,{chain:s.chainId,size:"xs"}),D(ce,{className:"rounded-full",asset:s,size:"xxs",noChain:!0}),D("span",{className:"text-sm font-medium uppercase",children:s.symbol})]}):D("span",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Select token"}),D(De,{className:"w-1.5 opacity-50"})]}):D("div",{...f,className:`relative ${i} w-full cursor-pointer text-xl duration-100 ease-linear`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-secondary)",borderTopLeftRadius:"9999px",borderBottomLeftRadius:"9999px",borderTopRightRadius:"var(--widget-radius)",borderBottomRightRadius:"var(--widget-radius)"},children:D("div",{className:"relative flex h-full w-full flex-row items-center",children:s?ue("div",{className:"relative flex h-full w-full flex-row items-center",children:[D("div",{className:`${n} pl-px flex items-center justify-center`,children:D(ce,{className:"rounded-full",asset:s,size:"md"})}),ue("div",{className:"flex h-full w-full flex-row items-center justify-between pl-1.5 pr-7",children:[ue("div",{className:"flex h-full flex-col justify-center",children:[D("p",{className:"text-sm font-medium uppercase",style:{color:"var(--widget-secondary-foreground)"},children:s.symbol}),ue("span",{className:"text-2xs font-mono",style:{color:"var(--widget-secondary-foreground)",opacity:.6},children:[s.address?.slice(0,6),"...",s.address?.slice(-4)]})]}),w!==void 0&&ue("div",{className:"flex flex-col text-right",children:[D("p",{className:"text-2xs",style:{color:"var(--widget-secondary-foreground)",opacity:.5},children:"Balance"}),D("span",{className:"font-mono text-xs tabular-nums",style:{color:"var(--widget-secondary-foreground)"},children:w})]})]}),D(De,{className:"absolute right-3 top-1/2 w-1.5 translate-y-[-50%]",style:{color:"var(--widget-secondary-foreground)",opacity:.6}})]}):D("div",{className:"flex h-full w-full items-center justify-center",children:D("span",{className:"text-sm",style:{color:"var(--widget-secondary-foreground)",opacity:.7},children:"Select token"})})})})},Rs=Vr;var Mt=yr(vr(),1);import{useState as qe,useEffect as Qe}from"react";import{jsx as K,jsxs as Ut}from"react/jsx-runtime";var Fr=()=>{let[e,t]=qe(null),[s,l]=qe(""),u=Tt(s,1e3),[r,a]=qe(!1),[h,b]=qe("");Qe(()=>{he.getState().setRecipient(e)},[e]),Qe(()=>{l(e||"")},[e]);let p=n=>{let w=n.target.value;r&&(a(!1),b(""),t(null)),l(w),w===""&&t(null)};Qe(()=>{u===""||!u?(a(!1),b(""),t(null)):St(u)?(a(!1),b(""),t(u)):(a(!0),b("Invalid wallet address..."),t(null),l(""))},[u]),Qe(()=>{if(r){let n=setTimeout(()=>{t(null),l(""),a(!1),b("")},2e3);return()=>clearTimeout(n)}},[r]);let i=()=>{t(null),l(""),a(!1),b("")};return K("div",{className:"w-full",children:Ut("div",{className:"relative flex flex-row items-center",children:[K("input",{type:"password",style:{display:"none"},"aria-hidden":"true",tabIndex:-1}),K("label",{htmlFor:"recipient-address",className:"sr-only",children:"Recipient wallet address"}),K("div",{className:"absolute left-3 flex h-6 w-6 items-end justify-center overflow-hidden rounded-full",style:{backgroundColor:"var(--widget-secondary)"},children:e&&!r?K("img",{className:"h-full w-full rounded-full object-cover",src:(0,Mt.makeGradient)(e),alt:"Recipient avatar"}):K(At,{className:"h-5 w-5",style:{color:r?"var(--widget-destructive)":"var(--widget-muted-foreground)"}})}),K("div",{className:"absolute left-12 top-1.5 -translate-y-1 text-xs font-medium opacity-60",style:{color:r?"var(--widget-destructive)":"var(--widget-muted-foreground)"},"aria-hidden":"true",children:"To:"}),K("input",{id:"recipient-address",className:"mono block h-10 w-full items-center pl-12 pt-4 pr-8 text-xs",style:{backgroundColor:r?"color-mix(in srgb, var(--widget-destructive) 10%, transparent)":"transparent",color:r?"var(--widget-destructive)":"var(--widget-foreground)",outline:"none",opacity:r?.9:1},placeholder:r?h:"Enter recipient address...",value:s,onChange:p,spellCheck:!1,"aria-invalid":r,"aria-describedby":r?"recipient-error":void 0}),r&&K("span",{id:"recipient-error",className:"sr-only",children:h}),e&&!r&&Ut("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 cursor-pointer flex items-center justify-center h-4 w-4 rounded-full transition-colors hover:[color:var(--widget-destructive)]",style:{color:"var(--widget-muted-foreground)"},onClick:i,"aria-label":"Clear recipient",children:[K("svg",{className:"h-2.5 w-2.5",viewBox:"0 -0.5 21 21",fill:"none",children:K("g",{fill:"currentColor",fillRule:"evenodd",children:K("polygon",{points:"375.0183 90 384 98.554 382.48065 100 373.5 91.446 364.5183 100 363 98.554 371.98065 90 363 81.446 364.5183 80 373.5 88.554 382.48065 80 384 81.446",transform:"translate(-363 -80)"})})}),K("span",{className:"sr-only",children:"Clear recipient"})]})]})})},Ps=Fr;var qr=["SUCCEEDED","FAILED","COMPLETED","CANCELLED"];async function Dt(e,t,s={}){let{onStatusChange:l,onComplete:u,onError:r,interval:a=4e3,timeout:h=3e5,txHash:b,signal:p}=s,i=null,n=Date.now(),w=0,f=8,c=null,x=b?`?txHash=${b}`:"";return new Promise((g,o)=>{let m=async()=>{try{if(p?.aborted){c&&clearTimeout(c),o(new DOMException("Polling aborted","AbortError"));return}if(Date.now()-n>h){c&&clearTimeout(c);let P=new Error("Order status polling timed out");r?.(P),o(P);return}let y=await fetch(`${t}/status/${e}${x}`,{headers:Ae(),signal:p});if(y.status===404){c=setTimeout(m,a);return}if(!y.ok)throw new Error(`Failed to fetch order status: ${await y.text()}`);let d=await y.json();if(!d||typeof d!="object"||!d.status)throw new Error(`Invalid status response format: ${JSON.stringify(d)}`);w=0;let T=d.status.toUpperCase();if(T!==i&&(i=T,l?.(d)),qr.includes(T)){c&&clearTimeout(c),u?.(d),g(d);return}c=setTimeout(m,a)}catch(y){if(y instanceof Error&&y.name==="AbortError"){c&&clearTimeout(c),o(y);return}if(++w>=f){c&&clearTimeout(c);let d=y instanceof Error?y:new Error(String(y));r?.(d),o(d);return}c=setTimeout(m,a)}};m()})}import{useCallback as je,useEffect as Qr,useRef as ze}from"react";function Wt(e){let t=e.toUpperCase();return t==="SUCCEEDED"||t==="COMPLETED"?"completed":t==="FAILED"?"failed":t==="CANCELLED"?"cancelled":t==="PROCESSING"?"received":"pending"}var Lt=e=>{let t=ze(new Map),s=ze(new Map),l=ze(new Map),u=ze(0),r=je(()=>++u.current,[]),{address:a}=ne(),h=Ee(),b=je((n,w)=>{if(t.current.get(n))return;w&&s.current.set(n,w),t.current.set(n,!0);let f=u.current,c=new AbortController;l.current.set(n,c);let x=w?.baseToken?.chainId===1;Dt(n,Re(),{interval:x?1e3:500,timeout:3e5,signal:c.signal,onStatusChange:g=>{if(!g?.status)return;let o=Wt(g.status);if(e?.(n,o),o==="completed"&&a){let m=s.current.get(n);if(m&&(m.baseToken||m.quoteToken)){let y=[];m.baseToken&&y.push({asset:m.baseToken,userAddress:a}),m.quoteToken&&y.push({asset:m.quoteToken,userAddress:a}),h({type:"swap",tokens:y})}}["completed","failed","cancelled"].includes(o)&&(t.current.delete(n),s.current.delete(n)),f!==u.current&&(t.current.delete(n),s.current.delete(n))},onComplete:g=>{g?.status&&e?.(n,Wt(g.status)),t.current.delete(n),s.current.delete(n)},onError:()=>{t.current.delete(n),s.current.delete(n)}}).catch(g=>{g instanceof Error&&g.name==="AbortError"||(t.current.delete(n),s.current.delete(n),l.current.delete(n))})},[a,h,e]),p=je(n=>{let w=l.current.get(n);w&&(w.abort(),l.current.delete(n)),r(),t.current.delete(n),s.current.delete(n)},[r]),i=je(()=>{for(let n of l.current.values())n.abort();l.current.clear(),r(),t.current.clear(),s.current.clear()},[r]);return Qr(()=>()=>i(),[i]),{startPolling:b,stopPolling:p,stopAllPolling:i,isPolling:n=>t.current.has(n)}};import{createContext as jr,useContext as zr}from"react";var Gr=jr({registerTransaction:()=>{},enabled:!1}),Bt=()=>zr(Gr);import{signTypedData as Kr}from"viem/actions";function Vt(e){return e instanceof Error?e.name==="UserRejectedRequestError"||e.message.includes("User rejected")||e.message.includes("rejected")||e.message.includes("denied")||e.message.includes("cancelled")||e.message.includes("canceled"):!1}async function _t(e){if(e.chain?.id)return e.chain.id;let t=e.getChainId?.();return t!=null?await t:null}var Hr=async(e,t)=>{try{if(await _t(e)===t)return!0;if(e.request)await e.request({method:"wallet_switchEthereumChain",params:[{chainId:`0x${t.toString(16)}`}]});else if(e.switchChain)await e.switchChain({id:t});else if(e.send)await e.send("wallet_switchEthereumChain",[{chainId:`0x${t.toString(16)}`}]);else throw new Error("Wallet doesn't support chain switching");return await _t(e)===t}catch(s){throw Vt(s)?new Error("User rejected the chain switch request"):new Error(`Please switch your wallet to the required network (Chain ID: ${t})`)}},Ft=async e=>{let{quote:t,signatureStep:s,userAddress:l,walletClient:u}=e;if(!u)throw new Error("Wallet client not available");if(s.type!=="SIGNATURE"||!s.signature?.typedData)throw new Error("Invalid signature step");try{let r=s.signature.typedData,a={...r.message};for(let i of["inputAmount","outputAmount","startTime","endTime"])a[i]!=null&&(a[i]=BigInt(a[i]));let h=r.domain;if(h.chainId!=null){let i=Number(h.chainId);await Hr(u,i)}let b=await Kr(u,{account:l,domain:h,types:r.types,primaryType:r.primaryType,message:a}),p=await fetch(`${Re()}/submit-signature`,{method:"POST",headers:Ae(),body:JSON.stringify({quoteId:t.id,signatures:[b]})});if(!p.ok){let i=await p.json().catch(()=>({}));throw new Error(i?.message||`Submit failed: ${p.status}`)}return{quoteId:t.id,signature:b}}catch(r){throw Vt(r)?new Error("User rejected the signing request"):r instanceof Error&&r.message.includes("chain")?new Error("Chain switching failed. Please manually switch to the correct network."):r}};var qt="vt_submitted_quotes";var lt=()=>{try{let e=localStorage.getItem(qt);return e?JSON.parse(e):[]}catch{return[]}},Qt=e=>{try{localStorage.setItem(qt,JSON.stringify(e))}catch{}},Xr=e=>{let t=Date.now(),s=typeof e=="string"?new Date(e).getTime():e>9999999999?e:e*1e3;return t<s+3e4},Yr=e=>lt().some(t=>t.quoteId===e),jt=(e,t)=>Yr(e)?{canSubmit:!1,reason:"Order already submitted"}:Xr(t)?{canSubmit:!0}:{canSubmit:!1,reason:"Quote has expired"},zt=(e,t)=>{let s=typeof t=="string"?new Date(t).getTime():t,l=lt();l.push({quoteId:e,submittedAt:Date.now(),createdAt:s}),Qt(l)},Gt=()=>{let e=lt(),t=Date.now(),s=300*1e3,l=e.filter(u=>t-u.submittedAt<s);l.length!==e.length&&Qt(l)};import{useMutation as Jr}from"@tanstack/react-query";import{waitForTransactionReceipt as Zr}from"@wagmi/core";import{wethAbi as en}from"abitype/abis";import{useConfig as tn}from"wagmi";function Kt(){let e=tn();return Jr({mutationFn:async({chainId:t,accountAddress:s,amountRaw:l,writeContractAsync:u})=>{let r=j(t);if(!r)throw new Error(`No wrapping contract for chain ${t}`);let a=r.wrappedAsset.address,h=await u({abi:en,functionName:"withdraw",address:a,account:s,args:[l],chainId:t});if((await Zr(e,{hash:h,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Unwrap transaction did not get successful receipt");return{success:!0,hash:h}}})}import{useMutation as rn}from"@tanstack/react-query";import{waitForTransactionReceipt as nn}from"@wagmi/core";import{wethAbi as sn}from"abitype/abis";import{useConfig as on}from"wagmi";function Ht(){let e=on();return rn({mutationFn:async({chainId:t,accountAddress:s,amountRaw:l,writeContractAsync:u})=>{let r=j(t);if(!r)throw new Error(`No wrapping contract for chain ${t}`);let a=r.wrappedAsset.address,h=await u({abi:sn,functionName:"deposit",address:a,account:s,value:l,chainId:t});if((await nn(e,{hash:h,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Wrap transaction did not get successful receipt");return{success:!0,hash:h}}})}import{useCallback as pe,useEffect as Pe,useRef as gr,useState as Fn}from"react";import{useChainId as qn}from"wagmi";import{useCallback as Xt,useRef as an}from"react";function Yt(){let{registerTransaction:e,enabled:t}=Bt(),s=an(new Set),l=Xt((r,a)=>{!t||s.current.has(r)||(s.current.add(r),e(r,a))},[t,e]),u=Xt((r,a)=>{!t||s.current.has(r)||(s.current.add(r),e(r,a))},[t,e]);return{trackOrderTransaction:l,trackNativeTransaction:u,txTrackingEnabled:t}}import{useEffect as Jt,useState as cn,useCallback as Zt,useRef as ut}from"react";import{useAccount as ln,useChainId as un,useSwitchChain as dn}from"wagmi";import{jsx as we,jsxs as dt}from"react/jsx-runtime";var pn=15e3,Ge="chain",mn=({needsChainSwitch:e,requiredChain:t,reviewState:s,goToNextStep:l,cancel:u})=>{let r=re(Ge,s),[a,h]=cn("pending"),b=ut(!1),p=ut(!1),i=ut(null),n=un(),{switchChainAsync:w}=dn(),{status:f,isReconnecting:c}=ln(),x=Zt(()=>{i.current&&(clearTimeout(i.current),i.current=null)},[]),g=Zt(async()=>{if(!(b.current||p.current||f!=="connected"||c)){b.current=!0,p.current=!0,h("pending"),i.current=setTimeout(()=>{b.current&&(h("error"),b.current=!1)},pn);try{await w({chainId:t.chainId}),x(),h("success"),l(Ge,s)}catch{x(),h("error")}finally{b.current=!1}}},[w,f,c,t.chainId,l,s,x]);Jt(()=>{b.current||p.current||s===Ge&&a==="pending"&&f==="connected"&&!c&&(e&&n!==t.chainId?g():(h("success"),l(Ge,s)))},[s,a,e,n,t.chainId,f,c,g,l]),Jt(()=>()=>x(),[x]);let o=()=>{a==="error"&&(p.current=!1,h("pending"))},m=!r&&a==="error",y=!r&&(a==="pending"||a==="error"),d=m?"var(--widget-status-failed)":"var(--widget-status-pending)";return dt("div",{className:"flex w-full flex-row justify-between space-x-3",children:[we("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${m?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${d} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${d} 20%, transparent)`,color:d,borderRadius:"var(--widget-radius)"},onClick:m?o:void 0,children:dt("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[we(Me,{chain:t.chainId,size:"xs"}),we("p",{className:"whitespace-nowrap",children:m?"Retry Switch":`Switch to ${t.name}`}),we("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),dt("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!r&&a==="pending"&&we(G,{size:"5"}),(r||a==="success")&&we(Y,{className:"h-8 w-8"}),m&&we(ge,{className:"h-[12px] w-[12px]"})]})]})}),y&&we("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:u,children:"Cancel"})]})},er=mn;import{waitForTransactionReceipt as wn}from"@wagmi/core";import{useCallback as Ke,useEffect as He,useState as bn,useRef as or}from"react";import{useAccount as hn,useConfig as yn,useSendTransaction as vn,useSwitchChain as xn,useWalletClient as Cn}from"wagmi";import{useEffect as tr,useRef as rr,useState as nr}from"react";import{jsx as gn}from"react/jsx-runtime";var fn=({startTime:e,onExpired:t})=>{let[s,l]=nr(30),[u,r]=nr(!1),a=rr(!1),h=rr(t);h.current=t,tr(()=>{a.current=!1},[e]),tr(()=>{let p=()=>{let n=Date.now(),f=(e>9999999999?e:e*1e3)+30*1e3,c=Math.max(0,f-n),x=Math.floor(c/1e3);if(x<=0){l(0),a.current||(a.current=!0,r(!0),h.current());return}l(x),r(!1)};if(u)return;p();let i=setInterval(p,1e3);return()=>clearInterval(i)},[e,u]);let b=p=>{let i=Math.floor(p/60),n=p%60;return`${i.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`};return u?null:gn("span",{className:"text-xs font-mono",children:b(s)})},sr=fn;import{jsx as de,jsxs as pt}from"react/jsx-runtime";function Sn(e){return e.name==="UserRejectedRequestError"||e.message.includes("User rejected")||e.message.includes("rejected")||e.message.includes("denied")||e.message.includes("cancelled")||e.message.includes("canceled")}var be="signingOrder";async function Tn(e,t,s,l,u){let r=e.transaction?.encoded,a=r?.to??e.to,h=r?.data??e.data,b=r?.value??e.value;if(!a)throw new Error('Transaction step missing "to" address');let p=r?.chainId,i=e.chainKey||u,n=p||(i?tt(i):void 0);if(!n)throw new Error(`Unknown chain: ${i}`);let w=vt()[n],f=await s({account:t,chain:w,to:a,data:h||"0x",value:BigInt(b||"0")});return await wn(l,{hash:f,chainId:n}),f}var Rn=({base:e,baseAmount:t,quote:s,quoteAmount:l,userAddress:u,reviewState:r,goToNextStep:a,cancel:h,isWrappingPair:b,isUnwrappingPair:p,restartSigningFlow:i,onSwapInitiated:n,onOrderSubmitted:w,onSwapComplete:f,startPolling:c,trackNativeTransaction:x})=>{let g=re(be,r),[o,m]=bn("idle"),y=or(!1),d=or(null),T=yn(),{isReconnecting:P}=hn(),{rfqQuote:C,stop:$,refresh:L}=Ve(),{data:N}=Cn({chainId:e.chainId}),{switchChain:E}=xn(),{sendTransactionAsync:I}=vn(),U=C?._receivedAt??0,B=Ke(()=>U?Date.now()>=U+30*1e3:!1,[U]),oe=Ke(async()=>{if(y.current||!["idle","error"].includes(o))return;if(!C?.id||!C?._receivedAt){m("error");return}if(!jt(C.id,C._receivedAt).canSubmit){m("stale");return}y.current=!0;try{if(!N)throw new Error("Wallet client not available");Gt();let S=C.userSteps??[],O;for(let A of S)if(A.type==="TRANSACTION"){m("submitting");let q=A.chainKey||C.srcChainKey,Z=q?tt(q):void 0;Z&&N.chain?.id!==Z&&(await E({chainId:Z}),await new Promise(Le=>setTimeout(Le,800))),O=await Tn(A,u,I,T,C.srcChainKey),x(O,A.description||`Tx on ${q}`)}else A.type==="SIGNATURE"&&(m("signing"),await Ft({quote:C,signatureStep:A,userAddress:u,walletClient:N}));zt(C.id,C._receivedAt),w?.(C.id),c(C.id,{baseToken:e,quoteToken:s}),n?.(),$(),m("success"),a(be,r),f?.(C.id)}catch(S){S instanceof Error&&Sn(S)?(d.current=null,m("idle")):m("error")}finally{y.current=!1}},[o,C,N,e,s,u,$,c,a,r,f,E,I,n,w,x,T]);He(()=>{if(r===be&&$(),g&&o!=="success"){m("success"),a(be,r);return}if(o==="success"){a(be,r);return}if(r===be&&o==="idle"&&!C?.id){m("refreshingQuote"),L();return}if(r===be&&o==="idle"&&N&&!y.current&&!P){let v=C?.id||null;v&&d.current!==v&&(d.current=v,oe())}},[g,r,o,N,P,oe,a,C?.id,L,$]),He(()=>{o==="refreshingQuote"&&C?.id&&m("idle")},[o,C?.id]),He(()=>{r!==be&&(d.current=null)},[r]),He(()=>{let v=setInterval(()=>{B()&&!y.current&&o!=="submitting"&&o!=="success"&&m("stale")},1e3);return()=>clearInterval(v)},[B,o]);let H=()=>{o==="error"&&!y.current&&(d.current=null,m("idle"))},W=Ke(()=>{d.current=null,m("refreshingQuote"),L()},[L]),R=Ke(()=>{i?i(!0):h()},[i,h]),V=()=>o==="error"?"Retry swap":o==="signing"?"Sign Swap Order":o==="submitting"?"Submitting...":o==="refreshingQuote"?"Refreshing Quote...":o==="stale"?"Quote Stale":"Sign & Submit",F=!g&&(o==="error"||o==="stale"),X=F?"var(--widget-status-failed)":"var(--widget-status-pending)";return pt("div",{className:"flex w-full flex-row justify-between space-x-3",children:[de("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${F?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${X} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${X} 20%, transparent)`,color:X,borderRadius:"var(--widget-radius)"},onClick:!g&&o==="error"?H:o==="stale"?R:void 0,children:pt("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[de(ce,{asset:e,size:"xs",noChain:!0}),de("p",{className:"whitespace-nowrap",children:V()}),de("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),U>0&&o!=="success"&&o!=="error"&&o!=="stale"&&de(sr,{startTime:U,onExpired:()=>m("stale")}),pt("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!g&&(o==="idle"||o==="signing"||o==="submitting"||o==="refreshingQuote")&&de(G,{size:"5"}),(g||o==="success")&&de(Y,{className:"h-8 w-8"}),!g&&(o==="error"||o==="stale")&&de(ge,{className:"h-[12px] w-[12px]"})]})]})}),!g&&o==="error"&&de("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:h,children:"Cancel"})]})},ir=Rn;import{useEffect as An}from"react";import{jsx as J,jsxs as En}from"react/jsx-runtime";var kn="trackingTx",ar={pending:{icon:J(G,{size:"5"}),buttonText:"Trade Pending",showNewSwap:!1,statusVar:"var(--widget-status-pending)",clickable:!1},received:{icon:J(G,{size:"5"}),buttonText:"Trade Received",showNewSwap:!1,statusVar:"var(--widget-status-received)",clickable:!1},completed:{icon:J(Y,{}),buttonText:"Continue Swapping",showNewSwap:!0,statusVar:"var(--widget-status-completed)",clickable:!0},failed:{icon:J(We,{}),buttonText:"Retry Swap",showNewSwap:!0,statusVar:"var(--widget-status-failed)",clickable:!0},cancelled:{icon:J(We,{}),buttonText:"Continue Swapping",showNewSwap:!0,statusVar:"var(--widget-status-failed)",clickable:!0}},Nn=({orderHash:e,base:t,quote:s,baseAmount:l,quoteAmount:u,reviewState:r,onNewSwap:a,onRetry:h,status:b})=>{let p=re(kn,r),i=ar[b]||ar.pending;An(()=>{if(b==="completed"){let f=setTimeout(a,5e3);return()=>clearTimeout(f)}},[b,a]);let n=()=>{b==="failed"?h():i.showNewSwap&&a()},w=i.statusVar;return J("div",{className:"flex flex-row justify-between space-x-3 w-full",children:J("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${i.clickable?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${w} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${w} 20%, transparent)`,color:w,borderRadius:"var(--widget-radius)"},onClick:i.showNewSwap?n:void 0,children:En("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[J("div",{className:"flex h-6 w-6 items-center justify-center rounded-full",children:i.icon}),J("p",{className:"whitespace-nowrap",children:i.buttonText}),J("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),i.showNewSwap&&J("div",{className:"flex h-6 w-6 items-center justify-center",children:J(kt,{})})]})})})},cr=Nn;import{useCallback as lr,useEffect as ur,useState as In,useRef as mt}from"react";import{parseUnits as On}from"viem";import{useAccount as Pn,useWriteContract as $n}from"wagmi";import{jsx as ve,jsxs as ft}from"react/jsx-runtime";var Un=15e3,Xe="unwrapping",Mn=({needsToUnwrap:e,amount:t,chainId:s,token:l,reviewState:u,setReviewState:r,goToNextStep:a,cancel:h,delayedClose:b})=>{let p=re(Xe,u),[i,n]=In("idle"),w=Kt(),{writeContractAsync:f}=$n(),{address:c}=ne(),x=Ee(),g=mt(!1),o=mt(!1),m=mt(null),{status:y}=Pn(),d=lr(()=>{m.current&&(clearTimeout(m.current),m.current=null)},[]),T=lr(async()=>{if(!(g.current||o.current||!c||y!=="connected")){g.current=!0,o.current=!0,n("pending"),m.current=setTimeout(()=>{g.current&&(n("error"),g.current=!1)},Un);try{let N=j(s);if(!N)throw new Error(`No config for chain ${s}`);let E=N.wrappedAsset.decimals??N.nativeAsset.decimals,I=On(t.toString(),E);await w.mutateAsync({chainId:s,accountAddress:c,amountRaw:I,writeContractAsync:f});let U={symbol:N.nativeAsset.symbol,name:N.nativeAsset.name,address:_e,decimals:N.nativeAsset.decimals,chainId:s},B={symbol:N.wrappedAsset.symbol,name:N.wrappedAsset.name,address:N.wrappedAsset.address,decimals:N.wrappedAsset.decimals,chainId:s};x({type:"unwrap",tokens:[{asset:U,userAddress:c},{asset:B,userAddress:c}]}),d(),n("success"),a(Xe,u),await b()}catch{d(),n("error")}finally{g.current=!1}}},[c,y,s,t,w,f,x,a,u,b,d]);ur(()=>{g.current||o.current||u===Xe&&i==="idle"&&y==="connected"&&(e?T():(n("success"),a(Xe,u)))},[u,i,e,y,T,a]),ur(()=>()=>d(),[d]);let P=()=>{i==="error"&&(o.current=!1,n("idle"))},C=!p&&i==="error",$=!p&&(i==="pending"||i==="idle"||i==="error"),L=C?"var(--widget-status-failed)":"var(--widget-status-pending)";return ft("div",{className:"flex w-full flex-row justify-between space-x-3",children:[ve("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${C?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${L} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${L} 20%, transparent)`,color:L,borderRadius:"var(--widget-radius)"},onClick:C?P:void 0,children:ft("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[ve("p",{className:"whitespace-nowrap",children:C?"Retry Unwrap":l?`Unwrap ${l.symbol}`:"Unwrap Native Token"}),ve("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),ft("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!p&&(i==="pending"||i==="idle")&&ve(G,{size:"5"}),(p||i==="success")&&ve(Y,{className:"h-8 w-8"}),C&&ve(ge,{className:"h-[12px] w-[12px]"})]})]})}),$&&ve("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:h,children:"Cancel"})]})},dr=Mn;import{useCallback as pr,useEffect as mr,useState as Dn,useRef as gt}from"react";import{parseUnits as Wn}from"viem";import{useAccount as Ln,useWriteContract as Bn}from"wagmi";import{jsx as xe,jsxs as wt}from"react/jsx-runtime";var _n=15e3,Ye="wrapping",Vn=({needsToWrap:e,amount:t,chainId:s,token:l,reviewState:u,setReviewState:r,goToNextStep:a,cancel:h,delayedClose:b,isWrappingPair:p})=>{let i=re(Ye,u),[n,w]=Dn("idle"),f=Ht(),{writeContractAsync:c}=Bn(),{address:x}=ne(),g=Ee(),o=gt(!1),m=gt(!1),y=gt(null),{status:d}=Ln(),T=pr(()=>{y.current&&(clearTimeout(y.current),y.current=null)},[]),P=pr(async()=>{if(!(o.current||m.current||!x||d!=="connected")){o.current=!0,m.current=!0,w("pending"),y.current=setTimeout(()=>{o.current&&(w("error"),o.current=!1)},_n);try{let E=j(s);if(!E)throw new Error(`No config for chain ${s}`);let I=Wn(t.toString(),E.nativeAsset.decimals);await f.mutateAsync({chainId:s,accountAddress:x,amountRaw:I,writeContractAsync:c});let U={symbol:E.nativeAsset.symbol,name:E.nativeAsset.name,address:_e,decimals:E.nativeAsset.decimals,chainId:s},B={symbol:E.wrappedAsset.symbol,name:E.wrappedAsset.name,address:E.wrappedAsset.address,decimals:E.wrappedAsset.decimals,chainId:s};g({type:"wrap",tokens:[{asset:U,userAddress:x},{asset:B,userAddress:x}]}),T(),w("success"),a(Ye,u),p&&await b()}catch{T(),w("error")}finally{o.current=!1}}},[x,d,s,t,f,c,g,a,u,b,p,T]);mr(()=>{o.current||m.current||u===Ye&&n==="idle"&&d==="connected"&&(e?P():(w("success"),a(Ye,u)))},[u,n,e,d,P,a]),mr(()=>()=>T(),[T]);let C=()=>{n==="error"&&(m.current=!1,w("idle"))},$=!i&&n==="error",L=!i&&(n==="pending"||n==="idle"||n==="error"),N=$?"var(--widget-status-failed)":"var(--widget-status-pending)";return wt("div",{className:"flex w-full flex-row justify-between space-x-3",children:[xe("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${$?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${N} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${N} 20%, transparent)`,color:N,borderRadius:"var(--widget-radius)"},onClick:$?C:void 0,children:wt("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[xe("p",{className:"whitespace-nowrap",children:$?"Retry Wrap":l?`Wrap ${l.symbol}`:"Wrap Native Token"}),xe("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),wt("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!i&&(n==="pending"||n==="idle")&&xe(G,{size:"5"}),(i||n==="success")&&xe(Y,{className:"h-8 w-8"}),$&&xe(ge,{className:"h-[12px] w-[12px]"})]})]})}),L&&xe("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:h,children:"Cancel"})]})},fr=Vn;import{jsx as Q,jsxs as Qn}from"react/jsx-runtime";var Si=({base:e,baseAmount:t,quote:s,quoteAmount:l,userAddress:u,isWrappingPair:r,isUnwrappingPair:a,isBaseGasToken:h,isQuoteGasToken:b,reviewActionProps:p,reviewState:i,setReviewState:n,trackedOrderHash:w,setTrackedOrderHash:f,txStatus:c,onSwapComplete:x,onSwapInitiated:g,onOrderSubmitted:o,onStaleQuoteRestart:m,setExitHandler:y,setRetryHandler:d})=>{let{rfqQuote:T,status:P,liquidityError:C,routingError:$,sizeCapError:L,stop:N,clear:E}=Ve(),{clearForm:I}=Ne(),U=qn(),{swapButtonVariant:B,widgetType:oe}=Te(),H=oe==="compact",{trackOrderTransaction:W,trackNativeTransaction:R}=Yt(),{startPolling:V}=Lt((_,fe)=>{he.getState().setTxStatus(fe),fe==="completed"&&W(_,`Swap ${e.symbol} \u2192 ${s.symbol}`)}),[F,X]=Fn(!1),v=gr(!1),S=gr(null),O=r,A=a,q=!r&&!a,Z=U!==e?.chainId&&(O||A||q),Le=j(e.chainId),Be={chainId:e.chainId,name:Le?.displayName??`Chain ${e.chainId}`},z=pe((_,fe)=>{if(fe!==_)return;if(_==="chain"){if(O){n("wrapping");return}if(A){n("unwrapping");return}n("signingOrder");return}if(_==="signingOrder"){n("trackingTx");return}if(_==="wrapping"){if(!r){n("signingOrder");return}n("wrapSuccess");return}if(_==="unwrapping"){n("wrapSuccess");return}let yt=Ct(_);yt&&n(yt)},[n,r,O,A,q]),ie=pe(()=>Z?"chain":O?"wrapping":A?"unwrapping":q?"signingOrder":null,[Z,O,A,q]),ee=pe(()=>{n(null),I()},[I,n]),Ce=pe(async()=>{n("wrapSuccess");for(let _=0;_<3;_++)await Ze(700);ee()},[ee,n]),te=pe(async()=>{E(),n("cancelled");for(let _=0;_<3;_++)await Ze(500);ee()},[E,ee,n]),me=pe(()=>{w&&(he.getState().stopTracking(),n(null),f(null),I())},[w,n,f,I]),$e=pe(()=>{n(null),f(null),v.current=!0,m?.()},[n,f,m]),ae=pe(()=>{p&&n(ie())},[ie,p,n]),Je=pe((_=!1)=>{_?(v.current=!0,n(null),m?.()):(n(null),S.current=setTimeout(()=>{p&&(n(ie()),X(!1))},100))},[n,p,ie,m]);Pe(()=>{i!==null&&N()},[i,N]),Pe(()=>{i!==null&&F&&X(!1)},[i,F]),Pe(()=>{y?.(me)},[y,me]),Pe(()=>{d?.($e)},[d,$e]),Pe(()=>()=>{S.current&&clearTimeout(S.current)},[]),Pe(()=>{v.current&&P==="fresh"&&T?.id&&(v.current=!1,n("signingOrder"))},[P,T?.id,n]);let Ue=_=>{if(!_)return{backgroundColor:B==="default"?"var(--widget-muted)":"transparent",color:"var(--widget-muted-foreground)",border:B!=="default"?"1px solid var(--widget-border)":"none",borderRadius:"var(--widget-radius)"};switch(B){case"outline":return{backgroundColor:"transparent",color:"var(--widget-primary)",border:"1px solid var(--widget-primary)",borderRadius:"var(--widget-radius)"};case"ghost":return{backgroundColor:"transparent",color:"var(--widget-primary)",border:"none",borderRadius:"var(--widget-radius)"};default:return{backgroundColor:"var(--widget-primary)",color:"var(--widget-primary-foreground)",borderRadius:"var(--widget-radius)"}}},Se=`w-full ${H?"py-2":"py-3"} text-sm font-medium transition-colors cursor-pointer mt-1`;if(i===null&&!r&&!a){if(F)return Q("button",{className:Se,disabled:!0,style:{...Ue(!1),opacity:.6,cursor:"not-allowed"},children:"Getting fresh quote..."});let _=()=>C?"Insufficient Liquidity":$?"Route Not Available":L?"Size Cap Exceeded":!T&&P==="polling"?"Getting Quote...":T?"Swap":"Enter Amount",fe=!!p;return Q("button",{onClick:fe?ae:void 0,disabled:!fe,className:`${Se} disabled:opacity-40 disabled:cursor-not-allowed`,style:Ue(fe),children:_()})}return i===null&&a?Q("button",{onClick:p?ae:void 0,disabled:!p,className:`${Se} disabled:opacity-40 disabled:cursor-not-allowed`,style:Ue(!!p),children:"Unwrap"}):i===null&&r?Q("button",{onClick:p?ae:void 0,disabled:!p,className:`${Se} disabled:opacity-40 disabled:cursor-not-allowed`,style:Ue(!!p),children:"Wrap"}):i==="success"?Q("div",{className:"flex flex-col gap-2 w-full",children:Q("button",{className:`w-full ${H?"py-2":"py-3"} text-sm font-medium cursor-default`,style:{backgroundColor:"color-mix(in srgb, var(--widget-status-completed) 15%, transparent)",color:"var(--widget-status-completed)",border:"1px solid color-mix(in srgb, var(--widget-status-completed) 20%, transparent)",borderRadius:"var(--widget-radius)"},children:"Order Placed"})}):i==="wrapSuccess"?Q("div",{className:"flex flex-col gap-2 w-full",children:Q("button",{className:`w-full ${H?"py-2":"py-3"} text-sm font-medium cursor-default`,style:{backgroundColor:"color-mix(in srgb, var(--widget-status-completed) 15%, transparent)",color:"var(--widget-status-completed)",border:"1px solid color-mix(in srgb, var(--widget-status-completed) 20%, transparent)",borderRadius:"var(--widget-radius)"},children:r?"Wrapped Successfully":"Unwrapped Successfully"})}):i==="cancelled"?Q("div",{className:"flex flex-col gap-2 w-full",children:Q("button",{onClick:ee,className:`w-full ${H?"py-2":"py-3"} text-sm font-medium cursor-pointer`,style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 15%, transparent)",color:"var(--widget-status-failed)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",borderRadius:"var(--widget-radius)"},children:"Order Cancelled"})}):Qn("div",{className:"flex w-full",children:[i==="chain"&&Z&&Q(er,{requiredChain:Be,needsChainSwitch:Z&&U!==e.chainId,reviewState:i,goToNextStep:z,cancel:te}),i==="wrapping"&&O&&Q(fr,{needsToWrap:O,amount:t,chainId:e.chainId,token:e,reviewState:i,setReviewState:n,goToNextStep:z,cancel:te,delayedClose:Ce,isWrappingPair:r}),i==="unwrapping"&&A&&Q(dr,{needsToUnwrap:A,amount:t,chainId:e.chainId,token:e,reviewState:i,setReviewState:n,goToNextStep:z,cancel:te,delayedClose:Ce}),i==="signingOrder"&&q&&Q(ir,{base:e,baseAmount:t,quote:s,quoteAmount:l,userAddress:u,reviewState:i,goToNextStep:z,cancel:te,restartSigningFlow:Je,onSwapInitiated:g,onOrderSubmitted:o,isWrappingPair:r,isUnwrappingPair:a,onSwapComplete:x,startPolling:V,trackNativeTransaction:R}),i==="trackingTx"&&w&&Q(cr,{orderHash:w,base:e,quote:s,baseAmount:t,quoteAmount:l,reviewState:i,status:c,onNewSwap:me,onRetry:$e}),i&&!["chain","wrapping","unwrapping","approval","signingOrder","trackingTx","success","wrapSuccess","cancelled"].includes(i)&&Q("button",{disabled:!0,className:`w-full ${H?"py-2":"py-3"} text-sm font-medium`,style:{backgroundColor:"var(--widget-muted)",color:"var(--widget-muted-foreground)",borderRadius:"var(--widget-radius)"},children:"Processing..."})]})};import{useState as wr,useCallback as jn,useRef as bt,useEffect as ht}from"react";import{useShallow as zn}from"zustand/react/shallow";import{jsx as k,jsxs as M}from"react/jsx-runtime";var br={pending:"var(--widget-status-pending)",received:"var(--widget-status-received)",completed:"var(--widget-status-completed)",failed:"var(--widget-status-failed)",cancelled:"var(--widget-status-failed)"},hr={pending:{title:"Trade Pending",subtitle:"Submitting to network"},received:{title:"Trade Received",subtitle:"Processing settlement"},completed:{title:"Trade Filled",subtitle:"Settlement complete"},failed:{title:"Trade Failed",subtitle:"Settlement unsuccessful"},cancelled:{title:"Trade Cancelled",subtitle:"Order was cancelled"}};function Gn(e){let t=br[e]??br.pending;return{textColor:t,bgColor:`color-mix(in srgb, ${t} 15%, transparent)`,borderColor:`color-mix(in srgb, ${t} 20%, transparent)`,cardBgColor:`color-mix(in srgb, ${t} 8%, transparent)`,cardBorderColor:`color-mix(in srgb, ${t} 15%, transparent)`,iconBgColor:`color-mix(in srgb, ${t} 12%, transparent)`,iconBorderColor:`color-mix(in srgb, ${t} 15%, transparent)`}}var Kn=({status:e})=>{switch(e){case"completed":return k(Y,{});case"failed":case"cancelled":return k(We,{});default:return k(G,{size:"10"})}},Hn=({orderHash:e,base:t,quote:s,baseAmount:l,quoteAmount:u,status:r})=>{let[a,h]=wr(!1),b=bt(null),p=bt(Date.now()),[i,n]=wr(null),w=bt(null),{isRecipientInputOpen:f,recipient:c}=he(zn(d=>({isRecipientInputOpen:d.isRecipientInputOpen,recipient:d.recipient})));ht(()=>{r==="received"&&(b.current=Date.now())},[r]),ht(()=>{if(r==="completed"&&!i){let d=b.current||p.current;n((Date.now()-d)/1e3)}},[r,i]),ht(()=>()=>{w.current&&clearTimeout(w.current)},[]);let x=jn(()=>{navigator.clipboard?.writeText&&navigator.clipboard.writeText(e).then(()=>{h(!0),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>h(!1),2e3)}).catch(()=>{})},[e]),g=hr[r]??hr.pending,o=Gn(r),m=ke(l),y=ke(u);return k("div",{className:"relative w-full h-full overflow-hidden flex flex-col",style:{backgroundColor:o.bgColor,border:`1px var(--widget-border-style) ${o.borderColor}`,backdropFilter:"blur(8px)"},children:M("div",{className:"relative z-10 px-3 pt-5 pb-3 flex-1 flex flex-col",children:[k("div",{className:"flex items-center justify-center mb-2",children:M("div",{className:"flex flex-col items-center gap-1 text-center",children:[k("div",{className:"flex h-10 w-10 items-center justify-center rounded-full border",style:{backgroundColor:o.iconBgColor,borderColor:o.iconBorderColor},children:k("div",{className:"h-7 w-7 flex items-center justify-center",children:k(Kn,{status:r})})}),M("div",{children:[k("h3",{className:"text-xl font-bold",style:{color:o.textColor},children:g.title}),k("p",{className:"text-2xs uppercase tracking-wider",style:{color:o.textColor,opacity:.6},children:g.subtitle})]})]})}),k("div",{className:"flex-1 flex flex-col justify-center",children:M("div",{className:"space-y-1.5",children:[M("div",{className:"flex items-center justify-between backdrop-blur-sm p-2.5 border transition-all duration-300",style:{backgroundColor:o.cardBgColor,borderColor:o.cardBorderColor},children:[M("div",{className:"flex items-center gap-2.5",children:[k(ce,{asset:t,size:"sm"}),M("div",{children:[k("div",{className:"text-sm font-bold",style:{color:o.textColor},children:t.symbol}),k("div",{className:"text-2xs",style:{color:o.textColor,opacity:.5},children:t.name})]})]}),M("div",{className:"text-right",children:[k("div",{className:"text-lg font-bold mono",style:{color:o.textColor},children:m}),t.price&&M("div",{className:"text-2xs mono",style:{color:o.textColor,opacity:.5},children:["$",(t.price*l).toFixed(2)]})]})]}),k("div",{className:"flex justify-center pb-0.5 pt-1",children:k("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border",style:{backgroundColor:o.cardBgColor,borderColor:o.cardBorderColor},children:k("span",{className:"text-base",style:{color:o.textColor},children:"\u2193"})})}),M("div",{className:"flex items-center justify-between backdrop-blur-sm p-2.5 border transition-all duration-300",style:{backgroundColor:o.cardBgColor,borderColor:o.cardBorderColor},children:[M("div",{className:"flex items-center gap-2.5",children:[k(ce,{asset:s,size:"sm"}),M("div",{children:[k("div",{className:"text-sm font-bold",style:{color:o.textColor},children:s.symbol}),k("div",{className:"text-2xs",style:{color:o.textColor,opacity:.5},children:s.name})]})]}),M("div",{className:"text-right",children:[k("div",{className:"text-lg font-bold mono",style:{color:o.textColor},children:y}),s.price&&M("div",{className:"text-2xs mono",style:{color:o.textColor,opacity:.5},children:["$",(s.price*u).toFixed(2)]})]})]}),f&&c&&M("div",{className:"mt-1.5",children:[k("div",{className:"text-2xs mb-0.5 uppercase tracking-wider font-medium",style:{color:o.textColor,opacity:.5},children:"Recipient"}),k("div",{className:"flex items-center backdrop-blur-sm p-2 border transition-all duration-300",style:{backgroundColor:o.cardBgColor,borderColor:o.cardBorderColor},children:M("div",{className:"flex items-center gap-2",children:[k("div",{className:"flex h-5 w-5 items-center justify-center overflow-hidden rounded-full",style:{backgroundColor:o.iconBgColor},children:k("span",{className:"text-2xs",children:"\u{1F464}"})}),M("div",{className:"flex flex-col",children:[k("div",{className:"text-2xs",style:{color:o.textColor,opacity:.5},children:"To:"}),M("div",{className:"text-xs mono",style:{color:o.textColor},children:[c.slice(0,6),"...",c.slice(-4)]})]})]})})]})]})}),M("div",{className:"mt-3 pt-2.5 space-y-1.5",style:{borderTop:`1px solid ${o.cardBorderColor}`},children:[M("div",{role:"button",tabIndex:0,onClick:x,onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),x())},className:"flex items-center justify-between cursor-pointer group hover:opacity-80 transition-opacity",children:[k("div",{className:"text-xs uppercase tracking-wider font-medium",style:{color:o.textColor,opacity:.5},children:a?"Copied!":r==="completed"||r==="failed"||r==="cancelled"?"Order Hash":r==="received"?"Received":"Pending"}),M("div",{className:"text-xs mono transition-colors",style:{color:o.textColor},children:[e.slice(0,6),"...",e.slice(-4)]})]}),r==="completed"&&i?M("div",{className:"flex items-center justify-between",children:[k("div",{className:"text-xs uppercase tracking-wider font-medium",style:{color:o.textColor,opacity:.5},children:"Speed"}),M("div",{className:"text-base font-bold mono",style:{color:o.textColor},children:[i.toFixed(2),"s"]})]}):k("div",{className:"h-5"})]})]})})},Oi=Hn;export{Tr as a,Ee as b,ts as c,ls as d,Ve as e,Wr as f,ms as g,ys as h,Rs as i,Ps as j,Dt as k,Lt as l,Bt as m,Hr as n,Ft as o,Xr as p,jt as q,zt as r,Gt as s,Kt as t,Ht as u,Si as v,Oi as w};
|
|
@@ -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
|
+
var _chunkBX3KCZRTcjs = require('./chunk-BX3KCZRT.cjs');var _chunk34N36GUDcjs = require('./chunk-34N36GUD.cjs');var _zustand = require('zustand');var _react = require('react');var x=_zustand.create.call(void 0, )(n=>({baseToken:null,quoteToken:null,setBaseTokenDirect:e=>n({baseToken:e}),setQuoteTokenDirect:e=>n({quoteToken:e}),swapTokensDirect:()=>n(e=>({baseToken:e.quoteToken,quoteToken:e.baseToken}))}));function O(n){let{data:e,isLoading:c}=_chunkBX3KCZRTcjs.D.call(void 0, ),o=x(),T=_react.useRef.call(void 0, !1),t=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _2 => _2.defaultBaseToken]), () => (null)),l=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _3 => _3.defaultQuoteToken]), () => (null));_react.useEffect.call(void 0, ()=>{if(!e||e.length===0||T.current)return;T.current=!0;let u=k=>_nullishCoalesce(e.find(m=>m.chainId===k.chainId&&m.address.toLowerCase()===k.address.toLowerCase()), () => (null)),r=t?u(t):null,p=l?u(l):null;r&&p&&r.chainId===p.chainId&&r.address.toLowerCase()===p.address.toLowerCase()?(o.setBaseTokenDirect(r),o.setQuoteTokenDirect(null)):(o.setBaseTokenDirect(r),o.setQuoteTokenDirect(p))},[e,t,l,o]);let h=_react.useCallback.call(void 0, u=>{if(!u){o.setBaseTokenDirect(null);return}let r=x.getState();r.quoteToken&&u.chainId===r.quoteToken.chainId&&u.address.toLowerCase()===r.quoteToken.address.toLowerCase()?o.swapTokensDirect():o.setBaseTokenDirect(u)},[o]),f=_react.useCallback.call(void 0, u=>{if(!u){o.setQuoteTokenDirect(null);return}let r=x.getState();r.baseToken&&u.chainId===r.baseToken.chainId&&u.address.toLowerCase()===r.baseToken.address.toLowerCase()?o.swapTokensDirect():o.setQuoteTokenDirect(u)},[o]),w=_react.useCallback.call(void 0, ()=>{o.swapTokensDirect()},[o]);return{baseToken:o.baseToken,quoteToken:o.quoteToken,setBaseToken:h,setQuoteToken:f,swapTokens:w,isLoading:c}}var W=_zustand.create.call(void 0, )(n=>({view:"swap",isTransitioning:!1,transitionType:"navigation",selectedChainFilter:null,hoveredChainName:null,isRecipientInputOpen:!1,recipient:null,hasAllowanceError:!1,baseAmount:null,quoteAmount:null,isTrackingTx:!1,trackingOrderHash:null,txStatus:"pending",walletTab:"wallet",assetSelectionSearch:"",assetSelectionChain:"all",assetSelectionCategory:"all",assetSelectionAddressInput:"",recentChainIds:[],setView:e=>n({view:e,isTransitioning:!0,...e!=="wallet"&&{walletTab:"wallet"}}),setWalletTab:e=>n({walletTab:e}),setIsTransitioning:e=>n({isTransitioning:e}),transitionToView:(e,c="navigation")=>n({isTransitioning:!0,transitionType:c,view:e,...e!=="wallet"&&{walletTab:"wallet"}}),setChainFilter:e=>n({selectedChainFilter:e}),setHoveredChainName:e=>n({hoveredChainName:e}),toggleRecipientInput:()=>n(e=>({isRecipientInputOpen:!e.isRecipientInputOpen,recipient:e.isRecipientInputOpen?null:e.recipient})),setRecipient:e=>n({recipient:e}),setHasAllowanceError:e=>n({hasAllowanceError:e}),setBaseAmount:e=>n({baseAmount:e}),setQuoteAmount:e=>n({quoteAmount:e}),clearAmounts:()=>n({baseAmount:null,quoteAmount:null}),setIsTrackingTx:e=>n({isTrackingTx:e}),setTrackingOrderHash:e=>n({trackingOrderHash:e}),setTxStatus:e=>n({txStatus:e}),startTracking:e=>n({isTrackingTx:!0,trackingOrderHash:e,txStatus:"pending"}),stopTracking:()=>n({isTrackingTx:!1,trackingOrderHash:null,txStatus:"pending"}),setAssetSelectionSearch:e=>n({assetSelectionSearch:e}),setAssetSelectionChain:e=>n({assetSelectionChain:e}),setAssetSelectionCategory:e=>n({assetSelectionCategory:e}),setAssetSelectionAddressInput:e=>n({assetSelectionAddressInput:e}),pushRecentChain:e=>n(c=>{if(e===4326)return c;let T=c.recentChainIds.filter(t=>t!==e);return{recentChainIds:[e,...T].slice(0,3)}}),resetAssetSelection:()=>n({assetSelectionSearch:"",assetSelectionChain:"all",assetSelectionCategory:"all",assetSelectionAddressInput:""}),resetUI:()=>n({view:"swap",isTransitioning:!1,selectedChainFilter:null,hoveredChainName:null,isRecipientInputOpen:!1,recipient:null,hasAllowanceError:!1,baseAmount:null,quoteAmount:null,isTrackingTx:!1,trackingOrderHash:null,txStatus:"pending",walletTab:"wallet",assetSelectionSearch:"",assetSelectionChain:"all",assetSelectionCategory:"all",assetSelectionAddressInput:""})}));var _viem = require('viem');var _shallow = require('zustand/react/shallow');var U=(n,e,c,o)=>{let{address:T}=_chunk34N36GUDcjs.a.call(void 0, ),{baseToken:t,quoteToken:l,setBaseToken:h,setQuoteToken:f,swapTokens:w,isLoading:u}=O({defaultBaseToken:n,defaultQuoteToken:e}),{baseAmount:r,quoteAmount:p,setBaseAmount:k,setQuoteAmount:m,clearAmounts:F}=W(_shallow.useShallow.call(void 0, s=>({baseAmount:s.baseAmount,quoteAmount:s.quoteAmount,setBaseAmount:s.setBaseAmount,setQuoteAmount:s.setQuoteAmount,clearAmounts:s.clearAmounts}))),{data:Q}=_chunkBX3KCZRTcjs.E.call(void 0, _optionalChain([t, 'optionalAccess', _4 => _4.address]),_optionalChain([t, 'optionalAccess', _5 => _5.chainId])),{data:R}=_chunkBX3KCZRTcjs.E.call(void 0, _optionalChain([l, 'optionalAccess', _6 => _6.address]),_optionalChain([l, 'optionalAccess', _7 => _7.chainId])),a=_react.useMemo.call(void 0, ()=>{if(!t)return null;let s=_nullishCoalesce(_optionalChain([Q, 'optionalAccess', _8 => _8.price]), () => (t.price));return s===t.price?t:{...t,price:s}},[t,_optionalChain([Q, 'optionalAccess', _9 => _9.price])]),i=_react.useMemo.call(void 0, ()=>{if(!l)return null;let s=_nullishCoalesce(_optionalChain([R, 'optionalAccess', _10 => _10.price]), () => (l.price));return s===l.price?l:{...l,price:s}},[l,_optionalChain([R, 'optionalAccess', _11 => _11.price])]),{baseBalance:A,quoteBalance:I,isLoading:L}=_chunkBX3KCZRTcjs.M.call(void 0, T,a,i),b=_react.useMemo.call(void 0, ()=>!A||A.raw==="0"?null:A,[A]),C=_react.useMemo.call(void 0, ()=>!I||I.raw==="0"?null:I,[I]),v=_react.useMemo.call(void 0, ()=>{if(!_optionalChain([a, 'optionalAccess', _12 => _12.chainId]))return!1;let s=_chunkBX3KCZRTcjs.e.call(void 0, a.chainId);return a.address.toLowerCase()===_optionalChain([s, 'optionalAccess', _13 => _13.gasToken, 'access', _14 => _14.address, 'optionalAccess', _15 => _15.toLowerCase, 'call', _16 => _16()])},[a]),B=_react.useMemo.call(void 0, ()=>{if(!_optionalChain([i, 'optionalAccess', _17 => _17.chainId]))return!1;let s=_chunkBX3KCZRTcjs.e.call(void 0, i.chainId);return i.address.toLowerCase()===_optionalChain([s, 'optionalAccess', _18 => _18.gasToken, 'access', _19 => _19.address, 'optionalAccess', _20 => _20.toLowerCase, 'call', _21 => _21()])},[i]),V=_react.useMemo.call(void 0, ()=>{if(!v||!_optionalChain([a, 'optionalAccess', _22 => _22.chainId])||!i||a.chainId!==i.chainId||a.chainId===988)return!1;let s=_chunkBX3KCZRTcjs.e.call(void 0, a.chainId);return i.address.toLowerCase()===_optionalChain([s, 'optionalAccess', _23 => _23.wrappedAsset, 'access', _24 => _24.address, 'optionalAccess', _25 => _25.toLowerCase, 'call', _26 => _26()])},[v,a,i]),G=_react.useMemo.call(void 0, ()=>{if(!_optionalChain([a, 'optionalAccess', _27 => _27.chainId])||!i||!B||a.chainId!==i.chainId||a.chainId===988)return!1;let s=_chunkBX3KCZRTcjs.e.call(void 0, a.chainId);return a.address.toLowerCase()===_optionalChain([s, 'optionalAccess', _28 => _28.wrappedAsset, 'access', _29 => _29.address, 'optionalAccess', _30 => _30.toLowerCase, 'call', _31 => _31()])},[a,i,B]),M=_react.useMemo.call(void 0, ()=>({raw:_nullishCoalesce(_optionalChain([b, 'optionalAccess', _32 => _32.raw]), () => ("0")),formatted:_nullishCoalesce(_optionalChain([b, 'optionalAccess', _33 => _33.formatted]), () => ("0"))}),[b]),_=_react.useMemo.call(void 0, ()=>({raw:_nullishCoalesce(_optionalChain([C, 'optionalAccess', _34 => _34.raw]), () => ("0")),formatted:_nullishCoalesce(_optionalChain([C, 'optionalAccess', _35 => _35.formatted]), () => ("0"))}),[C]),z=_react.useMemo.call(void 0, ()=>!a||typeof r!="number"||a.decimals===void 0||a.decimals===null?null:_viem.parseUnits.call(void 0, r.toFixed(a.decimals),a.decimals).toString(),[a,r]),J=_react.useMemo.call(void 0, ()=>!i||typeof p!="number"||i.decimals===void 0||i.decimals===null?null:_viem.parseUnits.call(void 0, p.toFixed(i.decimals),i.decimals).toString(),[i,p]),K=_react.useCallback.call(void 0, async s=>{h(s),m(null),_optionalChain([c, 'optionalCall', _36 => _36(s)])},[h,m,c]),X=_react.useCallback.call(void 0, async s=>{f(s),_optionalChain([o, 'optionalCall', _37 => _37(s)])},[f,o]),Y=_react.useCallback.call(void 0, s=>k(s),[k]),Z=_react.useCallback.call(void 0, s=>m(s),[m]),$=_react.useCallback.call(void 0, ()=>{w(),l&&_optionalChain([c, 'optionalCall', _38 => _38(l)]),t&&_optionalChain([o, 'optionalCall', _39 => _39(t)])},[w,t,l,c,o]),j=_react.useCallback.call(void 0, ()=>F(),[F]);return{baseToken:a,baseAmount:r,quoteToken:i,quoteAmount:p,isBaseGasToken:v,isQuoteGasToken:B,isWrappingPair:V,isUnwrappingPair:G,baseBalance:M,quoteBalance:_,baseAmountRaw:z,quoteAmountRaw:J,isBaseBalanceLoading:L,isQuoteBalanceLoading:L,isRegistryLoading:u,setBaseToken:K,setQuoteToken:X,setBaseAmount:Y,setQuoteAmount:Z,swapTokens:$,clearForm:j}};var _jsxruntime = require('react/jsx-runtime');var N=_react.createContext.call(void 0, null),ye= exports.e =({children:n,defaultBaseToken:e,defaultQuoteToken:c,onBaseTokenChange:o,onQuoteTokenChange:T})=>{let t=U(e,c,o,T),l=_react.useMemo.call(void 0, ()=>t,[t.baseToken,t.quoteToken,t.baseAmount,t.quoteAmount,t.isBaseGasToken,t.isQuoteGasToken,t.isWrappingPair,t.isUnwrappingPair,t.baseBalance,t.quoteBalance,t.baseAmountRaw,t.quoteAmountRaw,t.isBaseBalanceLoading,t.isQuoteBalanceLoading,t.setBaseToken,t.setQuoteToken,t.setBaseAmount,t.setQuoteAmount,t.swapTokens,t.clearForm,t.isRegistryLoading]);return _jsxruntime.jsx.call(void 0, N.Provider,{value:l,children:n})},qe= exports.f =()=>{let n=_react.useContext.call(void 0, N);if(!n)throw new Error("useSwapFormContext must be used within SwapFormProvider");return n};exports.a = x; exports.b = O; exports.c = W; exports.d = U; exports.e = ye; exports.f = qe;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var g=Object.create;var f=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var m=(b,a)=>()=>(a||b((a={exports:{}}).exports,a),a.exports);var l=(b,a,c,e)=>{if(a&&typeof a=="object"||typeof a=="function")for(let d of i(a))!k.call(b,d)&&d!==c&&f(b,d,{get:()=>a[d],enumerable:!(e=h(a,d))||e.enumerable});return b};var n=(b,a,c)=>(c=b!=null?g(j(b)):{},l(a||!b||!b.__esModule?f(c,"default",{value:b,enumerable:!0}):c,b));export{m as a,n as b};
|