@aori/mega-swap-widget 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +169 -1
- package/dist/SwapFormHorizontal-HXRKT2W2.js +2 -0
- package/dist/SwapFormHorizontal-MIUSJOXE.cjs +2 -0
- package/dist/SwapFormSplit-AXIKKPX2.cjs +2 -0
- package/dist/SwapFormSplit-ZJFN67TU.js +2 -0
- package/dist/{chunk-REBGSW5K.cjs → chunk-G34KXH2I.cjs} +1 -1
- package/dist/chunk-RCUE37DZ.js +2 -0
- package/dist/{chunk-PTFMMTWV.js → chunk-RYGNYBSW.js} +1 -1
- package/dist/chunk-XLUXVPIK.cjs +2 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +32 -2
- package/dist/index.d.ts +32 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/dist/SwapFormHorizontal-B2H57CEQ.cjs +0 -2
- package/dist/SwapFormHorizontal-FUJVIFJH.js +0 -2
- package/dist/SwapFormSplit-LB6JXG4G.cjs +0 -2
- package/dist/SwapFormSplit-YBU2HQXF.js +0 -2
- package/dist/chunk-PU5KXI4P.js +0 -2
- package/dist/chunk-SGTI7NXZ.cjs +0 -2
package/README.md
CHANGED
|
@@ -322,11 +322,179 @@ MEGAETH_RPC_URL=https://your-megaeth-rpc.example.com
|
|
|
322
322
|
| `customWalletUI` | `'none' \| 'provider'` | `'provider'` | `'provider'` wires into your wallet modals via callbacks; `'none'` hides all wallet UI |
|
|
323
323
|
| `onRequestConnect` | `() => void` | — | Open the host app's connect modal |
|
|
324
324
|
| `onRequestAccount` | `() => void` | — | Open the host app's account modal |
|
|
325
|
-
| `
|
|
325
|
+
| `onSwapSubmitted` | `(quoteId: string) => void` | — | Fires immediately after the user's signing/transaction steps complete and the order is submitted to the Aori backend. `quoteId` is the VT quote ID for tracking. |
|
|
326
|
+
| `onSwapComplete` | `(data: SwapCompleteData) => void` | — | Fires when polling confirms the swap is settled on-chain. Returns `{ quoteId, aoriOrderHash, explorerUrl, details }` where `details` is the full Aori `/data/details` response. |
|
|
326
327
|
| `onBaseTokenChange` | `(token: Asset) => void` | — | Callback when the base token changes |
|
|
327
328
|
| `onQuoteTokenChange` | `(token: Asset) => void` | — | Callback when the quote token changes |
|
|
328
329
|
| `className` | `string` | — | Additional CSS class on the root element |
|
|
329
330
|
|
|
331
|
+
### Swap Lifecycle Hooks Example
|
|
332
|
+
|
|
333
|
+
Use `onSwapSubmitted` to know when the order hits the Aori backend, and `onSwapComplete` to get the full details once it settles on-chain:
|
|
334
|
+
|
|
335
|
+
```tsx
|
|
336
|
+
<SwapWidget
|
|
337
|
+
config={aoriConfig}
|
|
338
|
+
onSwapSubmitted={(quoteId) => {
|
|
339
|
+
// Fires immediately after the user signs and the order is submitted.
|
|
340
|
+
// quoteId is the VT quote ID — use it to track the order or just wait for onSwapComplete.
|
|
341
|
+
}}
|
|
342
|
+
onSwapComplete={({ aoriOrderHash, explorerUrl, details }) => {
|
|
343
|
+
// Fires when polling confirms the swap is settled on-chain.
|
|
344
|
+
// details is the full response from https://api.aori.io/data/details/${aoriOrderHash}
|
|
345
|
+
|
|
346
|
+
// Redirect to a confirmation page
|
|
347
|
+
router.push(`/confirmation?order=${aoriOrderHash}`);
|
|
348
|
+
|
|
349
|
+
// Or persist to your own tx history
|
|
350
|
+
const getEventTime = (type: string) =>
|
|
351
|
+
details.events.find(e => e.event === type)?.timestamp ?? null;
|
|
352
|
+
|
|
353
|
+
addToHistory({
|
|
354
|
+
orderHash: aoriOrderHash,
|
|
355
|
+
explorerUrl,
|
|
356
|
+
inputAmount: details.inputAmount,
|
|
357
|
+
inputChain: details.inputChain,
|
|
358
|
+
outputAmount: details.outputAmount,
|
|
359
|
+
outputChain: details.outputChain,
|
|
360
|
+
srcTx: details.srcTx,
|
|
361
|
+
dstTx: details.dstTx,
|
|
362
|
+
// individual event timestamps — use these to show status progression in your UI
|
|
363
|
+
createdAt: getEventTime('created'),
|
|
364
|
+
receivedAt: getEventTime('received'),
|
|
365
|
+
completedAt: getEventTime('completed'),
|
|
366
|
+
failedAt: getEventTime('failed'),
|
|
367
|
+
canceledAt: getEventTime('cancelled'),
|
|
368
|
+
});
|
|
369
|
+
}}
|
|
370
|
+
/>
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
The `SwapCompleteData` type:
|
|
374
|
+
|
|
375
|
+
```ts
|
|
376
|
+
interface SwapCompleteData {
|
|
377
|
+
quoteId: string; // VT quote ID (same value as onSwapSubmitted)
|
|
378
|
+
aoriOrderHash: string; // Aori order hash, parsed from explorerUrl
|
|
379
|
+
explorerUrl: string; // https://aoriscan.io/order/0x...
|
|
380
|
+
details: AoriOrderDetails;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
interface AoriOrderDetails {
|
|
384
|
+
orderHash: string;
|
|
385
|
+
offerer: string;
|
|
386
|
+
recipient: string;
|
|
387
|
+
inputToken: string;
|
|
388
|
+
inputAmount: string;
|
|
389
|
+
inputChain: string;
|
|
390
|
+
inputTokenValueUsd: string;
|
|
391
|
+
outputToken: string;
|
|
392
|
+
outputAmount: string;
|
|
393
|
+
outputChain: string;
|
|
394
|
+
outputTokenValueUsd: string;
|
|
395
|
+
startTime: number;
|
|
396
|
+
endTime: number;
|
|
397
|
+
timestamp: number;
|
|
398
|
+
srcTx: string | null;
|
|
399
|
+
dstTx: string | null;
|
|
400
|
+
events: Array<{
|
|
401
|
+
event: string; // 'created' | 'received' | 'completed' | 'failed' | 'cancelled'
|
|
402
|
+
timestamp: number;
|
|
403
|
+
}>;
|
|
404
|
+
}
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### What You Can Build With These Hooks
|
|
408
|
+
|
|
409
|
+
The data from `onSwapComplete` is generic — you decide what to do with it. Some examples:
|
|
410
|
+
|
|
411
|
+
- **Tx history component** — render a live list of swaps with status, amounts, and links
|
|
412
|
+
- **Confirmation page** — redirect to a dedicated page after settlement with order details
|
|
413
|
+
- **Custom notification** — show a toast, modal, or banner with the swap result
|
|
414
|
+
- **Analytics** — send swap events to your own backend or analytics pipeline
|
|
415
|
+
- **Order detail page** — use `aoriOrderHash` to link to or render a full order breakdown
|
|
416
|
+
- **Just the data** — store it in state, context, or your DB and use it however your app needs
|
|
417
|
+
|
|
418
|
+
The hooks don't dictate any UI. They hand you the data at the right moment — you wire it into whatever component or flow makes sense for your app.
|
|
419
|
+
|
|
420
|
+
### Building a Live Tx History
|
|
421
|
+
|
|
422
|
+
One common pattern — use both hooks together to maintain a live list. `onSwapSubmitted` adds a pending entry immediately, `onSwapComplete` updates it in-place once settled:
|
|
423
|
+
|
|
424
|
+
```tsx
|
|
425
|
+
const [history, setHistory] = useState([]);
|
|
426
|
+
|
|
427
|
+
const addOrUpdate = (quoteId, patch) =>
|
|
428
|
+
setHistory(prev => {
|
|
429
|
+
const exists = prev.find(e => e.quoteId === quoteId);
|
|
430
|
+
if (exists) return prev.map(e => e.quoteId === quoteId ? { ...e, ...patch } : e);
|
|
431
|
+
return [...prev, { quoteId, status: 'pending', orderHash: null, ...patch }];
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
<SwapWidget
|
|
435
|
+
config={aoriConfig}
|
|
436
|
+
onSwapSubmitted={(quoteId) => {
|
|
437
|
+
addOrUpdate(quoteId, { status: 'pending' });
|
|
438
|
+
}}
|
|
439
|
+
onSwapComplete={({ quoteId, aoriOrderHash, explorerUrl, details }) => {
|
|
440
|
+
const getEventTime = (type) =>
|
|
441
|
+
details.events.find(e => e.event === type)?.timestamp ?? null;
|
|
442
|
+
|
|
443
|
+
addOrUpdate(quoteId, {
|
|
444
|
+
status: getEventTime('failed') ? 'failed' : 'completed',
|
|
445
|
+
orderHash: aoriOrderHash,
|
|
446
|
+
explorerUrl,
|
|
447
|
+
inputAmount: details.inputAmount,
|
|
448
|
+
inputChain: details.inputChain,
|
|
449
|
+
outputAmount: details.outputAmount,
|
|
450
|
+
outputChain: details.outputChain,
|
|
451
|
+
srcTx: details.srcTx,
|
|
452
|
+
dstTx: details.dstTx,
|
|
453
|
+
createdAt: getEventTime('created'),
|
|
454
|
+
receivedAt: getEventTime('received'),
|
|
455
|
+
completedAt: getEventTime('completed'),
|
|
456
|
+
failedAt: getEventTime('failed'),
|
|
457
|
+
});
|
|
458
|
+
}}
|
|
459
|
+
/>
|
|
460
|
+
|
|
461
|
+
// Render history however you like
|
|
462
|
+
{history.map(tx => <TxRow key={tx.quoteId} tx={tx} />)}
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
This gives you a real-time list that:
|
|
466
|
+
- Shows "pending" the instant the user submits
|
|
467
|
+
- Updates to "completed" or "failed" once on-chain settlement confirms
|
|
468
|
+
- Has all the data needed to render amounts, chains, tx links, and a status timeline
|
|
469
|
+
|
|
470
|
+
### Fetching Order History Outside the Hook
|
|
471
|
+
|
|
472
|
+
The `onSwapComplete` hook only captures swaps from the current session. To load a wallet's full order history — on mount, for a tx history page, etc. — use the Aori API directly with the connected wallet address.
|
|
473
|
+
|
|
474
|
+
**Query all orders for a wallet** ([`/data/query`](https://docs.aori.io/reference/query)):
|
|
475
|
+
|
|
476
|
+
```ts
|
|
477
|
+
const res = await fetch(
|
|
478
|
+
`https://api.aori.io/data/query?offerer=[connected_wallet_address]&page=0&limit=100&sortBy=createdAt_desc`
|
|
479
|
+
);
|
|
480
|
+
const { orders, pagination } = await res.json();
|
|
481
|
+
// orders is an array of summarised order objects with srcTx, dstTx, amounts, chains, status
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
**Get full details for a specific order** ([`/data/details`](https://docs.aori.io/reference/details)):
|
|
485
|
+
|
|
486
|
+
```ts
|
|
487
|
+
const res = await fetch(`https://api.aori.io/data/details/${orderHash}`);
|
|
488
|
+
const details = await res.json();
|
|
489
|
+
// Full event history, tx hashes, block numbers, timestamps
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
The recommended pattern for a tx history feature:
|
|
493
|
+
|
|
494
|
+
- **On swap completion** — write to your own state/DB via `onSwapComplete`
|
|
495
|
+
- **On page load** — fetch historical orders from `/data/query?offerer=${address}` to backfill swaps from past sessions
|
|
496
|
+
- **On detail view** — fetch `/data/details/${orderHash}` for the full event timeline of a specific order
|
|
497
|
+
|
|
330
498
|
## Configuration
|
|
331
499
|
|
|
332
500
|
See [`AoriSwapWidgetConfig`](./src/config/types.ts) for the full type. Only non-default values need to be specified.
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";import{a as le}from"./chunk-RYGNYBSW.js";import{e as se,g as re,h as f,i as w,j as de,k as ue,w as ce,x as pe}from"./chunk-RCUE37DZ.js";import{a as Q}from"./chunk-UR3Q7FG5.js";import{a as H}from"./chunk-IKTTT66M.js";import{a as ae}from"./chunk-UHG7ZIWD.js";import"./chunk-OPN7WCJR.js";import{e as ne}from"./chunk-YO5D6L5W.js";import{b as oe,d}from"./chunk-GPT4NHM5.js";import"./chunk-QAOZRRSH.js";import{a as ie}from"./chunk-46H44R7V.js";import"./chunk-73CB2I7U.js";import{useCallback as p,useEffect as He,useMemo as Ue,useRef as De,useState as me}from"react";import{useShallow as Ve}from"zustand/react/shallow";import{Fragment as q,jsx as e,jsxs as r}from"react/jsx-runtime";var O=()=>{},je=({onSwapSubmitted:ge,onSwapComplete:fe,onSwapInitiated:we,onBackToSwap:x,onMoreChainsClick:Ee})=>{let{web3ConnectionType:Ge,hasConnectHandler:he,lockBase:N,lockQuote:T,disableInverting:ve,swapButtonVariant:I,tokenDisplay:U,tokenBadgeOrientation:C,widgetType:be,assetMenuVariant:Se}=oe(),{effectiveInputTokens:xe,effectiveOutputTokens:Ce}=ae(),h=xe.length===1,v=Ce.length===1,D=U==="pill"||U==="ghost",R=be==="compact",{baseToken:t,quoteToken:o,baseAmount:i,quoteAmount:u,isBaseGasToken:ye,isQuoteGasToken:ke,isWrappingPair:a,isUnwrappingPair:l,baseBalance:g,quoteBalance:ze,setBaseAmount:F,setQuoteAmount:c,swapTokens:V,clearForm:j}=ne(),{rfqQuote:Le,status:_e,handleInputChange:M,ensureForParams:E,stop:Je,clear:y,refresh:G}=se(),{address:m}=ie(),{openConnectModal:Ae}=re(),{isRecipientInputOpen:W,txStatus:z,view:b,selectedChainFilterChainId:L}=d(Ve(n=>({isRecipientInputOpen:n.isRecipientInputOpen,txStatus:n.txStatus,view:n.view,selectedChainFilterChainId:n.selectedChainFilter?.chainId??null}))),[k,Pe]=me(null),[A,_]=me(null),Oe=De(!1),s=!1,qe=Ue(()=>!t||!o||typeof i!="number"||!u||!m||parseFloat(g.formatted)<i?null:{base:t,quote:o,baseAmount:i,quoteAmount:u,userAddress:m},[t,o,i,u,m,g.formatted]),Ne=p(n=>{_(n),d.getState().startTracking(n)},[]),Te=p(()=>{Oe.current=!0,G()},[G]);He(()=>{if(k===null&&!(!t||!o)){if(!i||i<=0){M({amount:null,inputToken:t,outputToken:o,setOutputAmount:c});return}if(a||l){c(i);return}M({amount:i,inputToken:t,outputToken:o,setOutputAmount:c})}},[k,i,t,o,a,l,M,c]);let B=p(()=>{d.getState().setView("baseSelection")},[]),$=p(()=>{d.getState().setView("quoteSelection")},[]),Ie=p(()=>{V(),c(null)},[V,c]),Re=p(()=>{if(!g.formatted||!t||!o)return;let n=parseFloat(g.formatted);if(!n||n<=0)return;let S=n*.9999999999;a||l?(F(S),c(S),y()):(F(S),c(null),E({inputToken:t,outputToken:o,inputAmount:S.toString(),setOutputAmount:P=>c(P)}))},[g.formatted,t,o,a,l,F,c,y,E]),Fe=p(()=>{y(),j()},[y,j]),J=g.formatted?parseFloat(g.formatted):null,Me=!!(i||u),K=Se==="split",X=K&&(b==="baseSelection"||b==="baseChainSelection"),Y=K&&(b==="quoteSelection"||b==="quoteChainSelection"),Z=p(n=>{let P=d.getState().view==="baseChainSelection"?"base":"quote";d.getState().setChainFilter({chainId:n,side:P}),d.getState().pushRecentChain(n),d.getState().transitionToView(P==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),We=p(()=>{d.getState().transitionToView("baseChainSelection","chainSelection")},[]),Be=p(()=>{d.getState().transitionToView("quoteChainSelection","chainSelection")},[]),$e=t?.price&&i?`$${(t.price*i).toFixed(2)}`:"$0.00",Qe=o?.price&&u?`$${(o.price*u).toFixed(2)}`:"$0.00",ee=k==="trackingTx"&&!!A&&!!t&&!!o&&!!i&&!!u,te={backgroundColor:I==="default"?"var(--widget-primary)":"transparent",color:I==="default"?"var(--widget-primary-foreground)":"var(--widget-primary)",border:I!=="default"?"1px solid var(--widget-primary)":"none",borderRadius:"var(--widget-radius)"};return r("div",{className:"flex flex-col w-full",children:[ee&&A&&t&&o&&i&&u?e("div",{className:"flex-1 min-h-0 overflow-hidden",children:e(pe,{orderHash:A,base:t,quote:o,baseAmount:i,quoteAmount:u,status:z})}):r("div",{className:`grid grid-cols-[1fr_auto_1fr] items-stretch px-4 ${R?"pt-3 pb-1":"pt-4 pb-2"} gap-2`,children:[e("div",{className:`relative flex flex-col gap-1 p-3 rounded-lg overflow-hidden ${X?"h-[380px]":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)"},children:X?b==="baseChainSelection"?e(H,{toggle:x??O,side:"base",onChainSelect:Z}):e(Q,{toggle:x??O,side:"base",otherAsset:o,onMoreChainsClick:We,selectedChainFilter:L}):r(q,{children:[D?R?r("div",{className:`flex items-center gap-2 ${C==="right"?"flex-row-reverse":"flex-row"}`,children:[e(w,{toggle:B,side:"base",asset:t,isPlacingOrder:s||N||h,hideDropdown:h}),e("div",{className:"flex-1 min-w-0",children:e(f,{side:"base",asset:t??null,otherAsset:o??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})})]}):r("div",{className:`flex flex-col ${C==="right"?"items-end":"items-start"}`,children:[e(w,{toggle:B,side:"base",asset:t,isPlacingOrder:s||N||h,hideDropdown:h}),e(f,{side:"base",asset:t??null,otherAsset:o??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}):r(q,{children:[e(w,{toggle:B,side:"base",asset:t,isPlacingOrder:s||N||h,hideDropdown:h}),e(f,{side:"base",asset:t??null,otherAsset:o??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}),r("div",{className:"flex items-center justify-between",children:[e("span",{className:"font-sans text-xs",style:{color:"var(--widget-muted-foreground)"},children:$e}),m&&J!==null&&J>0&&e("button",{type:"button",onClick:Re,disabled:s,className:"flex items-center rounded-full px-2 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 transition-colors bg-(--widget-primary) text-(--widget-primary-foreground) hover:bg-(--widget-foreground) hover:text-(--widget-card)",children:"Max"})]})]})}),e("div",{className:"flex items-center justify-center px-1",children:ve?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:Ie,"aria-label":"Swap input and output tokens",className:"flex h-8 w-8 items-center justify-center rounded-full cursor-pointer transition-colors bg-(--widget-card) text-(--widget-muted-foreground) hover:bg-(--widget-secondary) hover:text-(--widget-foreground)",style:{border:"1px solid var(--widget-border)"},children:e(ue,{className:"w-3.5 h-3.5"})})}),e("div",{className:`relative flex flex-col gap-1 p-3 rounded-lg overflow-hidden ${Y?"h-[380px]":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)"},children:Y?b==="quoteChainSelection"?e(H,{toggle:x??O,side:"quote",onChainSelect:Z}):e(Q,{toggle:x??O,side:"quote",otherAsset:t,onMoreChainsClick:Be,selectedChainFilter:L}):r(q,{children:[D?R?r("div",{className:`flex items-center gap-2 ${C==="right"?"flex-row-reverse":"flex-row"}`,children:[e(w,{toggle:$,side:"quote",asset:o,isPlacingOrder:s||T||v,hideDropdown:v}),e("div",{className:"flex-1 min-w-0",children:e(f,{side:"quote",asset:o??null,otherAsset:t??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})})]}):r("div",{className:`flex flex-col ${C==="right"?"items-end":"items-start"}`,children:[e(w,{toggle:$,side:"quote",asset:o,isPlacingOrder:s||T||v,hideDropdown:v}),e(f,{side:"quote",asset:o??null,otherAsset:t??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}):r(q,{children:[e(w,{toggle:$,side:"quote",asset:o,isPlacingOrder:s||T||v,hideDropdown:v}),e(f,{side:"quote",asset:o??null,otherAsset:t??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}),r("div",{className:"flex items-center justify-between",children:[e("span",{className:"font-sans text-xs",style:{color:"var(--widget-muted-foreground)"},children:Qe}),Me&&e("button",{type:"button",onClick:Fe,disabled:s,className:"flex items-center rounded-full px-2 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 transition-colors text-(--widget-muted-foreground) hover:bg-(--widget-secondary)",children:"Clear"})]})]})})]}),e("div",{className:"flex flex-row items-center w-full overflow-hidden px-4",style:{borderTop:W?"1px solid var(--widget-border)":"none",maxHeight:W?"60px":"0px",opacity:W?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:e(de,{})}),e("div",{className:"px-4",style:{borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"},children:e(le,{})}),e("div",{className:`relative ${ee?"px-0":"px-4"} py-4`,children:m&&t&&o&&i&&i>0?e(ce,{base:t,baseAmount:i,quote:o,quoteAmount:u??0,userAddress:m,isWrappingPair:a,isUnwrappingPair:l,isBaseGasToken:ye,isQuoteGasToken:ke,reviewActionProps:qe,reviewState:k,setReviewState:Pe,trackedOrderHash:A,setTrackedOrderHash:_,onSwapSubmitted:ge,onSwapComplete:fe,onSwapInitiated:we,onOrderSubmitted:Ne,onStaleQuoteRestart:Te,txStatus:z}):!m&&he?e("button",{onClick:()=>Ae(),className:"w-full py-3 text-sm font-medium cursor-pointer transition-opacity hover:opacity-80",style:te,children:"Connect Wallet"}):e("button",{disabled:!0,className:"w-full py-3 text-sm font-medium transition-colors disabled:opacity-40 cursor-not-allowed",style:te,children:m?"Enter Amount":"Connect Wallet"})})]})},ft=je;export{ft 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 _chunkG34KXH2Icjs = require('./chunk-G34KXH2I.cjs');var _chunkXLUXVPIKcjs = require('./chunk-XLUXVPIK.cjs');var _chunkEKSQTNKScjs = require('./chunk-EKSQTNKS.cjs');var _chunkWZCWYOCNcjs = require('./chunk-WZCWYOCN.cjs');var _chunkTWVI6PZScjs = require('./chunk-TWVI6PZS.cjs');require('./chunk-KH57FLST.cjs');var _chunkPSCWQFVYcjs = require('./chunk-PSCWQFVY.cjs');var _chunkD7GULMHEcjs = require('./chunk-D7GULMHE.cjs');require('./chunk-K3RTTHBS.cjs');var _chunk34N36GUDcjs = require('./chunk-34N36GUD.cjs');require('./chunk-T3I3AJXV.cjs');var _react = require('react');var _shallow = require('zustand/react/shallow');var _jsxruntime = require('react/jsx-runtime');var O=()=>{},je=({onSwapSubmitted:ge,onSwapComplete:fe,onSwapInitiated:we,onBackToSwap:x,onMoreChainsClick:Ee})=>{let{web3ConnectionType:Ge,hasConnectHandler:he,lockBase:N,lockQuote:T,disableInverting:ve,swapButtonVariant:I,tokenDisplay:U,tokenBadgeOrientation:C,widgetType:be,assetMenuVariant:Se}=_chunkD7GULMHEcjs.b.call(void 0, ),{effectiveInputTokens:xe,effectiveOutputTokens:Ce}=_chunkTWVI6PZScjs.a.call(void 0, ),h=xe.length===1,v=Ce.length===1,D=U==="pill"||U==="ghost",R=be==="compact",{baseToken:t,quoteToken:o,baseAmount:i,quoteAmount:u,isBaseGasToken:ye,isQuoteGasToken:ke,isWrappingPair:a,isUnwrappingPair:l,baseBalance:g,quoteBalance:ze,setBaseAmount:F,setQuoteAmount:c,swapTokens:V,clearForm:j}=_chunkPSCWQFVYcjs.e.call(void 0, ),{rfqQuote:Le,status:_e,handleInputChange:M,ensureForParams:E,stop:Je,clear:y,refresh:G}=_chunkXLUXVPIKcjs.e.call(void 0, ),{address:m}=_chunk34N36GUDcjs.a.call(void 0, ),{openConnectModal:Ae}=_chunkXLUXVPIKcjs.g.call(void 0, ),{isRecipientInputOpen:W,txStatus:z,view:b,selectedChainFilterChainId:L}=_chunkD7GULMHEcjs.d.call(void 0, _shallow.useShallow.call(void 0, n=>({isRecipientInputOpen:n.isRecipientInputOpen,txStatus:n.txStatus,view:n.view,selectedChainFilterChainId:_nullishCoalesce(_optionalChain([n, 'access', _2 => _2.selectedChainFilter, 'optionalAccess', _3 => _3.chainId]), () => (null))}))),[k,Pe]=_react.useState.call(void 0, null),[A,_]=_react.useState.call(void 0, null),Oe=_react.useRef.call(void 0, !1),s=!1,qe=_react.useMemo.call(void 0, ()=>!t||!o||typeof i!="number"||!u||!m||parseFloat(g.formatted)<i?null:{base:t,quote:o,baseAmount:i,quoteAmount:u,userAddress:m},[t,o,i,u,m,g.formatted]),Ne=_react.useCallback.call(void 0, n=>{_(n),_chunkD7GULMHEcjs.d.getState().startTracking(n)},[]),Te=_react.useCallback.call(void 0, ()=>{Oe.current=!0,G()},[G]);_react.useEffect.call(void 0, ()=>{if(k===null&&!(!t||!o)){if(!i||i<=0){M({amount:null,inputToken:t,outputToken:o,setOutputAmount:c});return}if(a||l){c(i);return}M({amount:i,inputToken:t,outputToken:o,setOutputAmount:c})}},[k,i,t,o,a,l,M,c]);let B=_react.useCallback.call(void 0, ()=>{_chunkD7GULMHEcjs.d.getState().setView("baseSelection")},[]),$=_react.useCallback.call(void 0, ()=>{_chunkD7GULMHEcjs.d.getState().setView("quoteSelection")},[]),Ie=_react.useCallback.call(void 0, ()=>{V(),c(null)},[V,c]),Re=_react.useCallback.call(void 0, ()=>{if(!g.formatted||!t||!o)return;let n=parseFloat(g.formatted);if(!n||n<=0)return;let S=n*.9999999999;a||l?(F(S),c(S),y()):(F(S),c(null),E({inputToken:t,outputToken:o,inputAmount:S.toString(),setOutputAmount:P=>c(P)}))},[g.formatted,t,o,a,l,F,c,y,E]),Fe=_react.useCallback.call(void 0, ()=>{y(),j()},[y,j]),J=g.formatted?parseFloat(g.formatted):null,Me=!!(i||u),K=Se==="split",X=K&&(b==="baseSelection"||b==="baseChainSelection"),Y=K&&(b==="quoteSelection"||b==="quoteChainSelection"),Z=_react.useCallback.call(void 0, n=>{let P=_chunkD7GULMHEcjs.d.getState().view==="baseChainSelection"?"base":"quote";_chunkD7GULMHEcjs.d.getState().setChainFilter({chainId:n,side:P}),_chunkD7GULMHEcjs.d.getState().pushRecentChain(n),_chunkD7GULMHEcjs.d.getState().transitionToView(P==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),We=_react.useCallback.call(void 0, ()=>{_chunkD7GULMHEcjs.d.getState().transitionToView("baseChainSelection","chainSelection")},[]),Be=_react.useCallback.call(void 0, ()=>{_chunkD7GULMHEcjs.d.getState().transitionToView("quoteChainSelection","chainSelection")},[]),$e=_optionalChain([t, 'optionalAccess', _4 => _4.price])&&i?`$${(t.price*i).toFixed(2)}`:"$0.00",Qe=_optionalChain([o, 'optionalAccess', _5 => _5.price])&&u?`$${(o.price*u).toFixed(2)}`:"$0.00",ee=k==="trackingTx"&&!!A&&!!t&&!!o&&!!i&&!!u,te={backgroundColor:I==="default"?"var(--widget-primary)":"transparent",color:I==="default"?"var(--widget-primary-foreground)":"var(--widget-primary)",border:I!=="default"?"1px solid var(--widget-primary)":"none",borderRadius:"var(--widget-radius)"};return _jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full",children:[ee&&A&&t&&o&&i&&u?_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-h-0 overflow-hidden",children:_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.x,{orderHash:A,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 ${R?"pt-3 pb-1":"pt-4 pb-2"} gap-2`,children:[_jsxruntime.jsx.call(void 0, "div",{className:`relative flex flex-col gap-1 p-3 rounded-lg overflow-hidden ${X?"h-[380px]":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)"},children:X?b==="baseChainSelection"?_jsxruntime.jsx.call(void 0, _chunkWZCWYOCNcjs.a,{toggle:_nullishCoalesce(x, () => (O)),side:"base",onChainSelect:Z}):_jsxruntime.jsx.call(void 0, _chunkEKSQTNKScjs.a,{toggle:_nullishCoalesce(x, () => (O)),side:"base",otherAsset:o,onMoreChainsClick:We,selectedChainFilter:L}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[D?R?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${C==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.i,{toggle:B,side:"base",asset:t,isPlacingOrder:s||N||h,hideDropdown:h}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.h,{side:"base",asset:_nullishCoalesce(t, () => (null)),otherAsset:_nullishCoalesce(o, () => (null)),isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${C==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.i,{toggle:B,side:"base",asset:t,isPlacingOrder:s||N||h,hideDropdown:h}),_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.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, _chunkXLUXVPIKcjs.i,{toggle:B,side:"base",asset:t,isPlacingOrder:s||N||h,hideDropdown:h}),_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.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:"font-sans text-xs",style:{color:"var(--widget-muted-foreground)"},children:$e}),m&&J!==null&&J>0&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Re,disabled:s,className:"flex items-center rounded-full px-2 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 transition-colors bg-(--widget-primary) text-(--widget-primary-foreground) hover:bg-(--widget-foreground) hover:text-(--widget-card)",children:"Max"})]})]})}),_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center justify-center px-1",children:ve?_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:Ie,"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, _chunkXLUXVPIKcjs.k,{className:"w-3.5 h-3.5"})})}),_jsxruntime.jsx.call(void 0, "div",{className:`relative flex flex-col gap-1 p-3 rounded-lg overflow-hidden ${Y?"h-[380px]":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)"},children:Y?b==="quoteChainSelection"?_jsxruntime.jsx.call(void 0, _chunkWZCWYOCNcjs.a,{toggle:_nullishCoalesce(x, () => (O)),side:"quote",onChainSelect:Z}):_jsxruntime.jsx.call(void 0, _chunkEKSQTNKScjs.a,{toggle:_nullishCoalesce(x, () => (O)),side:"quote",otherAsset:t,onMoreChainsClick:Be,selectedChainFilter:L}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[D?R?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${C==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.i,{toggle:$,side:"quote",asset:o,isPlacingOrder:s||T||v,hideDropdown:v}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.h,{side:"quote",asset:_nullishCoalesce(o, () => (null)),otherAsset:_nullishCoalesce(t, () => (null)),isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${C==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.i,{toggle:$,side:"quote",asset:o,isPlacingOrder:s||T||v,hideDropdown:v}),_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.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, _chunkXLUXVPIKcjs.i,{toggle:$,side:"quote",asset:o,isPlacingOrder:s||T||v,hideDropdown:v}),_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.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:"font-sans text-xs",style:{color:"var(--widget-muted-foreground)"},children:Qe}),Me&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Fe,disabled:s,className:"flex items-center rounded-full px-2 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 transition-colors text-(--widget-muted-foreground) hover:bg-(--widget-secondary)",children:"Clear"})]})]})})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-row items-center w-full overflow-hidden px-4",style:{borderTop:W?"1px solid var(--widget-border)":"none",maxHeight:W?"60px":"0px",opacity:W?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.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, _chunkG34KXH2Icjs.a,{})}),_jsxruntime.jsx.call(void 0, "div",{className:`relative ${ee?"px-0":"px-4"} py-4`,children:m&&t&&o&&i&&i>0?_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.w,{base:t,baseAmount:i,quote:o,quoteAmount:_nullishCoalesce(u, () => (0)),userAddress:m,isWrappingPair:a,isUnwrappingPair:l,isBaseGasToken:ye,isQuoteGasToken:ke,reviewActionProps:qe,reviewState:k,setReviewState:Pe,trackedOrderHash:A,setTrackedOrderHash:_,onSwapSubmitted:ge,onSwapComplete:fe,onSwapInitiated:we,onOrderSubmitted:Ne,onStaleQuoteRestart:Te,txStatus:z}):!m&&he?_jsxruntime.jsx.call(void 0, "button",{onClick:()=>Ae(),className:"w-full py-3 text-sm font-medium cursor-pointer transition-opacity hover:opacity-80",style:te,children:"Connect Wallet"}):_jsxruntime.jsx.call(void 0, "button",{disabled:!0,className:"w-full py-3 text-sm font-medium transition-colors disabled:opacity-40 cursor-not-allowed",style:te,children:m?"Enter Amount":"Connect Wallet"})})]})},ft= exports.default =je;exports.default = ft;
|
|
@@ -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 _chunkXLUXVPIKcjs = require('./chunk-XLUXVPIK.cjs');var _chunkEKSQTNKScjs = require('./chunk-EKSQTNKS.cjs');var _chunkWZCWYOCNcjs = require('./chunk-WZCWYOCN.cjs');var _chunkTWVI6PZScjs = require('./chunk-TWVI6PZS.cjs');require('./chunk-KH57FLST.cjs');var _chunkPSCWQFVYcjs = require('./chunk-PSCWQFVY.cjs');var _chunkD7GULMHEcjs = require('./chunk-D7GULMHE.cjs');var _chunkK3RTTHBScjs = require('./chunk-K3RTTHBS.cjs');var _chunk34N36GUDcjs = require('./chunk-34N36GUD.cjs');require('./chunk-T3I3AJXV.cjs');var _react = require('react');var _shallow = require('zustand/react/shallow');var _jsxruntime = require('react/jsx-runtime');var we=()=>{},tt=({onSwapSubmitted:he,onSwapComplete:be,onSwapInitiated:Se,onBackToSwap:E,onMoreChainsClick:st})=>{let{web3ConnectionType:ot,hasConnectHandler:ye,lockBase:q,lockQuote:R,disableInverting:Ce,swapButtonVariant:F,tokenDisplay:j,tokenBadgeOrientation:N,widgetType:Ne,assetMenuVariant:ke}=_chunkD7GULMHEcjs.b.call(void 0, ),{effectiveInputTokens:Ae,effectiveOutputTokens:Pe}=_chunkTWVI6PZScjs.a.call(void 0, ),S=Ae.length===1,y=Pe.length===1,z=j==="pill"||j==="ghost",k=Ne==="compact",{baseToken:d,quoteToken:c,baseAmount:a,quoteAmount:n,isBaseGasToken:Te,isQuoteGasToken:Oe,isWrappingPair:u,isUnwrappingPair:p,baseBalance:w,setBaseAmount:I,setQuoteAmount:g,swapTokens:G,clearForm:L}=_chunkPSCWQFVYcjs.e.call(void 0, ),{handleInputChange:M,ensureForParams:_,clear:A,refresh:J,liquidityError:qe,routingError:Re}=_chunkXLUXVPIKcjs.e.call(void 0, ),{address:v}=_chunk34N36GUDcjs.a.call(void 0, ),{openConnectModal:Fe}=_chunkXLUXVPIKcjs.g.call(void 0, ),{isRecipientInputOpen:$,txStatus:K,view:x,selectedChainFilterChainId:Ie}=_chunkD7GULMHEcjs.d.call(void 0, _shallow.useShallow.call(void 0, i=>({isRecipientInputOpen:i.isRecipientInputOpen,txStatus:i.txStatus,view:i.view,selectedChainFilterChainId:_nullishCoalesce(i.selectedChainFilterChainId, () => (null))}))),[P,Me]=_react.useState.call(void 0, null),[T,X]=_react.useState.call(void 0, null),$e=_react.useRef.call(void 0, !1),r=!1,We=_react.useMemo.call(void 0, ()=>!d||!c||typeof a!="number"||!n||!v||parseFloat(w.formatted)<a?null:{base:d,quote:c,baseAmount:a,quoteAmount:n,userAddress:v},[d,c,a,n,v,w.formatted]),Be=_react.useCallback.call(void 0, i=>{X(i),_chunkD7GULMHEcjs.d.getState().startTracking(i)},[]),De=_react.useCallback.call(void 0, ()=>{$e.current=!0,J()},[J]);_react.useEffect.call(void 0, ()=>{if(P===null&&!(!d||!c)){if(!a||a<=0){M({amount:null,inputToken:d,outputToken:c,setOutputAmount:g});return}if(u||p){g(a);return}M({amount:a,inputToken:d,outputToken:c,setOutputAmount:g})}},[P,a,d,c,u,p,M,g]);let Y=a&&n&&parseFloat(n.toString())?parseFloat(a.toString())/parseFloat(n.toString()):0,W=_react.useCallback.call(void 0, ()=>{_chunkD7GULMHEcjs.d.getState().setView("baseSelection")},[]),B=_react.useCallback.call(void 0, ()=>{_chunkD7GULMHEcjs.d.getState().setView("quoteSelection")},[]),Qe=_react.useCallback.call(void 0, ()=>{G(),g(null)},[G,g]),Ue=_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?(I(m),g(m),A()):(I(m),g(null),_({inputToken:d,outputToken:c,inputAmount:m.toString(),setOutputAmount:C=>g(C)}))},[w.formatted,d,c,u,p,I,g,A,_]),Ve=_react.useCallback.call(void 0, ()=>{A(),L()},[A,L]),Z=w.formatted?parseFloat(w.formatted):null,He=!!(a||n),s=d,o=c,Ee=_optionalChain([s, 'optionalAccess', _2 => _2.price])&&a?`$${(s.price*a).toFixed(2)}`:"$0.00",je=_optionalChain([o, 'optionalAccess', _3 => _3.price])&&n?`$${(o.price*n).toFixed(2)}`:"$0.00",ze=!!(s&&o&&a&&n),Ge=qe||Re,ee=P==="trackingTx"&&!!T&&!!s&&!!o&&!!a&&!!n,D=ke==="split",Q=D&&(x==="baseSelection"||x==="quoteSelection"||x==="baseChainSelection"||x==="quoteChainSelection"),U=x==="baseSelection"||x==="baseChainSelection"?"base":"quote",Le=U==="base"?o:s,te=_react.useRef.call(void 0, null),[_e,Je]=_react.useState.call(void 0, 380);_react.useEffect.call(void 0, ()=>{if(!D)return;let i=te.current;if(!i)return;let m=new ResizeObserver(C=>{for(let Ye of C)Je(Ye.contentRect.height)});return m.observe(i),()=>m.disconnect()},[D]);let Ke=_react.useCallback.call(void 0, i=>{let C=_chunkD7GULMHEcjs.d.getState().view==="baseChainSelection"?"base":"quote";_chunkD7GULMHEcjs.d.getState().setChainFilter({chainId:i,side:C}),_chunkD7GULMHEcjs.d.getState().pushRecentChain(i),_chunkD7GULMHEcjs.d.getState().transitionToView(C==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),Xe=_react.useCallback.call(void 0, ()=>{let i=_chunkD7GULMHEcjs.d.getState().view;i==="baseSelection"?_chunkD7GULMHEcjs.d.getState().transitionToView("baseChainSelection","chainSelection"):i==="quoteSelection"&&_chunkD7GULMHEcjs.d.getState().transitionToView("quoteChainSelection","chainSelection")},[]),se={backgroundColor:F==="default"?"var(--widget-primary)":"transparent",color:F==="default"?"var(--widget-primary-foreground)":"var(--widget-primary)",border:F!=="default"?"1px solid var(--widget-primary)":"none",borderRadius:"var(--widget-radius)"};return _jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row w-full",children:[_jsxruntime.jsxs.call(void 0, "div",{ref:te,className:"flex flex-col flex-1 min-w-0",style:{borderRight:"1px solid var(--widget-border)"},children:[ee&&T&&s&&o&&a&&n?_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-h-0 overflow-hidden",children:_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.x,{orderHash:T,base:s,quote:o,baseAmount:a,quoteAmount:n,status:K})}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "div",{className:`relative ${k?"px-4 pt-3 pb-1":"px-4 pt-4 pb-2"}`,style:{borderBottom:"1px solid var(--widget-border)"},children:[z?k?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${N==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.i,{toggle:W,side:"base",asset:s,isPlacingOrder:r||q||S,hideDropdown:S}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.h,{side:"base",asset:_nullishCoalesce(s, () => (null)),otherAsset:_nullishCoalesce(o, () => (null)),isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${N==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.i,{toggle:W,side:"base",asset:s,isPlacingOrder:r||q||S,hideDropdown:S}),_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.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, _chunkXLUXVPIKcjs.i,{toggle:W,side:"base",asset:s,isPlacingOrder:r||q||S,hideDropdown:S}),_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.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:"font-sans text-sm",style:{color:"var(--widget-muted-foreground)"},children:Ee}),v&&Z!==null&&Z>0&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Ue,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"})]})]}),!Ce&&_jsxruntime.jsx.call(void 0, "div",{className:"flex justify-center -my-4 relative z-10",children:_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Qe,"aria-label":"Swap input and output tokens",className:"flex h-8 w-8 items-center justify-center rounded-full cursor-pointer bg-(--widget-card) text-(--widget-muted-foreground) hover:bg-(--widget-secondary) hover:text-(--widget-foreground) transition-colors",style:{border:"1px solid var(--widget-border)"},children:_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.k,{className:"w-3.5 h-3.5"})})}),_jsxruntime.jsxs.call(void 0, "div",{className:`relative ${k?"px-4 pt-4 pb-1":"px-4 pt-6 pb-2"}`,children:[z?k?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${N==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.i,{toggle:B,side:"quote",asset:o,isPlacingOrder:r||R||y,hideDropdown:y}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.h,{side:"quote",asset:_nullishCoalesce(o, () => (null)),otherAsset:_nullishCoalesce(s, () => (null)),isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${N==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.i,{toggle:B,side:"quote",asset:o,isPlacingOrder:r||R||y,hideDropdown:y}),_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.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, _chunkXLUXVPIKcjs.i,{toggle:B,side:"quote",asset:o,isPlacingOrder:r||R||y,hideDropdown:y}),_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.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:"font-sans text-sm",style:{color:"var(--widget-muted-foreground)"},children:je}),He&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Ve,disabled:r,className:"absolute bottom-2 right-4 flex items-center rounded-full px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 text-(--widget-muted-foreground) hover:bg-(--widget-secondary) transition-colors",children:"Clear"})]})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-row items-center w-full overflow-hidden",style:{borderTop:$?"1px solid var(--widget-border)":"none",maxHeight:$?"60px":"0px",opacity:$?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.j,{})}),_jsxruntime.jsx.call(void 0, "div",{className:`relative ${ee?"px-0":"px-4"} py-4`,children:v&&s&&o&&a&&a>0?_jsxruntime.jsx.call(void 0, _chunkXLUXVPIKcjs.w,{base:s,baseAmount:a,quote:o,quoteAmount:_nullishCoalesce(n, () => (0)),userAddress:v,isWrappingPair:u,isUnwrappingPair:p,isBaseGasToken:Te,isQuoteGasToken:Oe,reviewActionProps:We,reviewState:P,setReviewState:Me,trackedOrderHash:T,setTrackedOrderHash:X,onSwapSubmitted:he,onSwapComplete:be,onSwapInitiated:Se,onOrderSubmitted:Be,onStaleQuoteRestart:De,txStatus:K}):!v&&ye?_jsxruntime.jsx.call(void 0, "button",{onClick:()=>Fe(),className:"w-full py-3 text-sm font-medium cursor-pointer transition-opacity hover:opacity-80",style:se,children:"Connect Wallet"}):_jsxruntime.jsx.call(void 0, "button",{disabled:!0,className:"w-full py-3 text-sm font-medium transition-colors disabled:opacity-40 cursor-not-allowed",style:se,children:v?"Enter Amount":"Connect Wallet"})})]}),_jsxruntime.jsx.call(void 0, "div",{className:`flex flex-col transition-all duration-300 ${Q?"flex-1 min-w-0":"w-48 shrink-0"}`,style:{backgroundColor:"var(--widget-background)",...Q?{height:`${_e}px`}:{}},children:Q?_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col overflow-hidden p-2",style:{height:"100%"},children:x==="baseChainSelection"||x==="quoteChainSelection"?_jsxruntime.jsx.call(void 0, _chunkWZCWYOCNcjs.a,{toggle:_nullishCoalesce(E, () => (we)),side:U,onChainSelect:Ke}):_jsxruntime.jsx.call(void 0, _chunkEKSQTNKScjs.a,{toggle:_nullishCoalesce(E, () => (we)),side:U,otherAsset:Le,onMoreChainsClick:Xe,selectedChainFilter:Ie})}):_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"}),ze&&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, _chunkK3RTTHBScjs.O,{asset:o,size:"3xs",noChain:!0}),_jsxruntime.jsxs.call(void 0, "span",{className:"font-sans text-xs uppercase",children:["1 ",o.symbol]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center gap-1 pl-4",children:_jsxruntime.jsxs.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:["= ",Y.toFixed(6)]})}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-1 pl-4",children:[_jsxruntime.jsx.call(void 0, _chunkK3RTTHBScjs.O,{asset:s,size:"3xs",noChain:!0}),_jsxruntime.jsx.call(void 0, "span",{className:"font-sans 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-sans text-xs",children:["$",s.price?(s.price*Y*parseFloat(n.toString())).toFixed(2):"\u2014"]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Order Type"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs font-sans",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-sans",children:"Cross-chain"})]})]})]}):Ge?_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, _chunkK3RTTHBScjs.W,{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"})]})]})})]})},Ct= exports.default =tt;exports.default = Ct;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";import{e as ne,g as le,h,i as b,j as ce,k as ue,w as pe,x as me}from"./chunk-RCUE37DZ.js";import{a as ge}from"./chunk-UR3Q7FG5.js";import{a as fe}from"./chunk-IKTTT66M.js";import{a as de}from"./chunk-UHG7ZIWD.js";import"./chunk-OPN7WCJR.js";import{e as re}from"./chunk-YO5D6L5W.js";import{b as oe,d as l}from"./chunk-GPT4NHM5.js";import{O as V,W as ae}from"./chunk-QAOZRRSH.js";import{a as ie}from"./chunk-46H44R7V.js";import"./chunk-73CB2I7U.js";import{useCallback as f,useEffect as ve,useMemo as Ze,useRef as xe,useState as H}from"react";import{useShallow as et}from"zustand/react/shallow";import{Fragment as O,jsx as e,jsxs as t}from"react/jsx-runtime";var we=()=>{},tt=({onSwapSubmitted:he,onSwapComplete:be,onSwapInitiated:Se,onBackToSwap:E,onMoreChainsClick:st})=>{let{web3ConnectionType:ot,hasConnectHandler:ye,lockBase:q,lockQuote:R,disableInverting:Ce,swapButtonVariant:F,tokenDisplay:j,tokenBadgeOrientation:N,widgetType:Ne,assetMenuVariant:ke}=oe(),{effectiveInputTokens:Ae,effectiveOutputTokens:Pe}=de(),S=Ae.length===1,y=Pe.length===1,z=j==="pill"||j==="ghost",k=Ne==="compact",{baseToken:d,quoteToken:c,baseAmount:a,quoteAmount:n,isBaseGasToken:Te,isQuoteGasToken:Oe,isWrappingPair:u,isUnwrappingPair:p,baseBalance:w,setBaseAmount:I,setQuoteAmount:g,swapTokens:G,clearForm:L}=re(),{handleInputChange:M,ensureForParams:_,clear:A,refresh:J,liquidityError:qe,routingError:Re}=ne(),{address:v}=ie(),{openConnectModal:Fe}=le(),{isRecipientInputOpen:$,txStatus:K,view:x,selectedChainFilterChainId:Ie}=l(et(i=>({isRecipientInputOpen:i.isRecipientInputOpen,txStatus:i.txStatus,view:i.view,selectedChainFilterChainId:i.selectedChainFilterChainId??null}))),[P,Me]=H(null),[T,X]=H(null),$e=xe(!1),r=!1,We=Ze(()=>!d||!c||typeof a!="number"||!n||!v||parseFloat(w.formatted)<a?null:{base:d,quote:c,baseAmount:a,quoteAmount:n,userAddress:v},[d,c,a,n,v,w.formatted]),Be=f(i=>{X(i),l.getState().startTracking(i)},[]),De=f(()=>{$e.current=!0,J()},[J]);ve(()=>{if(P===null&&!(!d||!c)){if(!a||a<=0){M({amount:null,inputToken:d,outputToken:c,setOutputAmount:g});return}if(u||p){g(a);return}M({amount:a,inputToken:d,outputToken:c,setOutputAmount:g})}},[P,a,d,c,u,p,M,g]);let Y=a&&n&&parseFloat(n.toString())?parseFloat(a.toString())/parseFloat(n.toString()):0,W=f(()=>{l.getState().setView("baseSelection")},[]),B=f(()=>{l.getState().setView("quoteSelection")},[]),Qe=f(()=>{G(),g(null)},[G,g]),Ue=f(()=>{if(!w.formatted||!d||!c)return;let i=parseFloat(w.formatted);if(!i||i<=0)return;let m=i*.9999999999;u||p?(I(m),g(m),A()):(I(m),g(null),_({inputToken:d,outputToken:c,inputAmount:m.toString(),setOutputAmount:C=>g(C)}))},[w.formatted,d,c,u,p,I,g,A,_]),Ve=f(()=>{A(),L()},[A,L]),Z=w.formatted?parseFloat(w.formatted):null,He=!!(a||n),s=d,o=c,Ee=s?.price&&a?`$${(s.price*a).toFixed(2)}`:"$0.00",je=o?.price&&n?`$${(o.price*n).toFixed(2)}`:"$0.00",ze=!!(s&&o&&a&&n),Ge=qe||Re,ee=P==="trackingTx"&&!!T&&!!s&&!!o&&!!a&&!!n,D=ke==="split",Q=D&&(x==="baseSelection"||x==="quoteSelection"||x==="baseChainSelection"||x==="quoteChainSelection"),U=x==="baseSelection"||x==="baseChainSelection"?"base":"quote",Le=U==="base"?o:s,te=xe(null),[_e,Je]=H(380);ve(()=>{if(!D)return;let i=te.current;if(!i)return;let m=new ResizeObserver(C=>{for(let Ye of C)Je(Ye.contentRect.height)});return m.observe(i),()=>m.disconnect()},[D]);let Ke=f(i=>{let C=l.getState().view==="baseChainSelection"?"base":"quote";l.getState().setChainFilter({chainId:i,side:C}),l.getState().pushRecentChain(i),l.getState().transitionToView(C==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),Xe=f(()=>{let i=l.getState().view;i==="baseSelection"?l.getState().transitionToView("baseChainSelection","chainSelection"):i==="quoteSelection"&&l.getState().transitionToView("quoteChainSelection","chainSelection")},[]),se={backgroundColor:F==="default"?"var(--widget-primary)":"transparent",color:F==="default"?"var(--widget-primary-foreground)":"var(--widget-primary)",border:F!=="default"?"1px solid var(--widget-primary)":"none",borderRadius:"var(--widget-radius)"};return t("div",{className:"flex flex-row w-full",children:[t("div",{ref:te,className:"flex flex-col flex-1 min-w-0",style:{borderRight:"1px solid var(--widget-border)"},children:[ee&&T&&s&&o&&a&&n?e("div",{className:"flex-1 min-h-0 overflow-hidden",children:e(me,{orderHash:T,base:s,quote:o,baseAmount:a,quoteAmount:n,status:K})}):t(O,{children:[t("div",{className:`relative ${k?"px-4 pt-3 pb-1":"px-4 pt-4 pb-2"}`,style:{borderBottom:"1px solid var(--widget-border)"},children:[z?k?t("div",{className:`flex items-center gap-2 ${N==="right"?"flex-row-reverse":"flex-row"}`,children:[e(b,{toggle:W,side:"base",asset:s,isPlacingOrder:r||q||S,hideDropdown:S}),e("div",{className:"flex-1 min-w-0",children:e(h,{side:"base",asset:s??null,otherAsset:o??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})})]}):t("div",{className:`flex flex-col ${N==="right"?"items-end":"items-start"}`,children:[e(b,{toggle:W,side:"base",asset:s,isPlacingOrder:r||q||S,hideDropdown:S}),e(h,{side:"base",asset:s??null,otherAsset:o??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}):t(O,{children:[e(b,{toggle:W,side:"base",asset:s,isPlacingOrder:r||q||S,hideDropdown:S}),e(h,{side:"base",asset:s??null,otherAsset:o??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}),t("div",{className:"mb-1 flex w-full flex-row items-center justify-between",children:[e("p",{className:"font-sans text-sm",style:{color:"var(--widget-muted-foreground)"},children:Ee}),v&&Z!==null&&Z>0&&e("button",{type:"button",onClick:Ue,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"})]})]}),!Ce&&e("div",{className:"flex justify-center -my-4 relative z-10",children:e("button",{type:"button",onClick:Qe,"aria-label":"Swap input and output tokens",className:"flex h-8 w-8 items-center justify-center rounded-full cursor-pointer bg-(--widget-card) text-(--widget-muted-foreground) hover:bg-(--widget-secondary) hover:text-(--widget-foreground) transition-colors",style:{border:"1px solid var(--widget-border)"},children:e(ue,{className:"w-3.5 h-3.5"})})}),t("div",{className:`relative ${k?"px-4 pt-4 pb-1":"px-4 pt-6 pb-2"}`,children:[z?k?t("div",{className:`flex items-center gap-2 ${N==="right"?"flex-row-reverse":"flex-row"}`,children:[e(b,{toggle:B,side:"quote",asset:o,isPlacingOrder:r||R||y,hideDropdown:y}),e("div",{className:"flex-1 min-w-0",children:e(h,{side:"quote",asset:o??null,otherAsset:s??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})})]}):t("div",{className:`flex flex-col ${N==="right"?"items-end":"items-start"}`,children:[e(b,{toggle:B,side:"quote",asset:o,isPlacingOrder:r||R||y,hideDropdown:y}),e(h,{side:"quote",asset:o??null,otherAsset:s??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}):t(O,{children:[e(b,{toggle:B,side:"quote",asset:o,isPlacingOrder:r||R||y,hideDropdown:y}),e(h,{side:"quote",asset:o??null,otherAsset:s??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}),t("div",{className:"flex w-full flex-row items-center justify-between",children:[e("p",{className:"font-sans text-sm",style:{color:"var(--widget-muted-foreground)"},children:je}),He&&e("button",{type:"button",onClick:Ve,disabled:r,className:"absolute bottom-2 right-4 flex items-center rounded-full px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 text-(--widget-muted-foreground) hover:bg-(--widget-secondary) transition-colors",children:"Clear"})]})]})]}),e("div",{className:"flex flex-row items-center w-full overflow-hidden",style:{borderTop:$?"1px solid var(--widget-border)":"none",maxHeight:$?"60px":"0px",opacity:$?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:e(ce,{})}),e("div",{className:`relative ${ee?"px-0":"px-4"} py-4`,children:v&&s&&o&&a&&a>0?e(pe,{base:s,baseAmount:a,quote:o,quoteAmount:n??0,userAddress:v,isWrappingPair:u,isUnwrappingPair:p,isBaseGasToken:Te,isQuoteGasToken:Oe,reviewActionProps:We,reviewState:P,setReviewState:Me,trackedOrderHash:T,setTrackedOrderHash:X,onSwapSubmitted:he,onSwapComplete:be,onSwapInitiated:Se,onOrderSubmitted:Be,onStaleQuoteRestart:De,txStatus:K}):!v&&ye?e("button",{onClick:()=>Fe(),className:"w-full py-3 text-sm font-medium cursor-pointer transition-opacity hover:opacity-80",style:se,children:"Connect Wallet"}):e("button",{disabled:!0,className:"w-full py-3 text-sm font-medium transition-colors disabled:opacity-40 cursor-not-allowed",style:se,children:v?"Enter Amount":"Connect Wallet"})})]}),e("div",{className:`flex flex-col transition-all duration-300 ${Q?"flex-1 min-w-0":"w-48 shrink-0"}`,style:{backgroundColor:"var(--widget-background)",...Q?{height:`${_e}px`}:{}},children:Q?e("div",{className:"flex flex-col overflow-hidden p-2",style:{height:"100%"},children:x==="baseChainSelection"||x==="quoteChainSelection"?e(fe,{toggle:E??we,side:U,onChainSelect:Ke}):e(ge,{toggle:E??we,side:U,otherAsset:Le,onMoreChainsClick:Xe,selectedChainFilter:Ie})}):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"}),ze&&s&&o?t(O,{children:[t("div",{className:"flex flex-col gap-0.5",children:[e("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Rate"}),t("div",{className:"flex items-center gap-1",children:[e(V,{asset:o,size:"3xs",noChain:!0}),t("span",{className:"font-sans text-xs uppercase",children:["1 ",o.symbol]})]}),e("div",{className:"flex items-center gap-1 pl-4",children:t("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:["= ",Y.toFixed(6)]})}),t("div",{className:"flex items-center gap-1 pl-4",children:[e(V,{asset:s,size:"3xs",noChain:!0}),e("span",{className:"font-sans 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-sans text-xs",children:["$",s.price?(s.price*Y*parseFloat(n.toString())).toFixed(2):"\u2014"]})]}),t("div",{className:"flex justify-between items-center",children:[e("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Order Type"}),e("span",{className:"text-2xs font-sans",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-sans",children:"Cross-chain"})]})]})]}):Ge?t("div",{className:"flex flex-col gap-1",children:[e(ae,{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"})]})]})})]})},Ct=tt;export{Ct as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _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 _chunkSGTI7NXZcjs = require('./chunk-SGTI7NXZ.cjs');var _chunkPSCWQFVYcjs = require('./chunk-PSCWQFVY.cjs');var _chunkD7GULMHEcjs = require('./chunk-D7GULMHE.cjs');var _chunkK3RTTHBScjs = require('./chunk-K3RTTHBS.cjs');var _react = require('react'); var _react2 = _interopRequireDefault(_react);var _jsxruntime = require('react/jsx-runtime');var I=()=>_jsxruntime.jsxs.call(void 0, "svg",{className:"w-3 h-3 shrink-0",style:{color:"var(--widget-secondary-foreground)"},viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M18 13V19C18 20.1046 17.1046 21 16 21H5C3.89543 21 3 20.1046 3 19V8C3 6.89543 3.89543 6 5 6H11",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),_jsxruntime.jsx.call(void 0, "path",{d:"M15 3H21V9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),_jsxruntime.jsx.call(void 0, "path",{d:"M10 14L21 3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Q=()=>_jsxruntime.jsxs.call(void 0, "svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 195 321",fill:"var(--widget-secondary-foreground)",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "path",{fillRule:"evenodd",d:"M195,189C195,207.02,195,225.04,194.7,243.21C193.68,244.78,192.9,246.17,192.25,247.63C189.71,253.38,187.74,259.46,184.6,264.86C169.44,290.97,147.86,309.46,118.54,318.86C116.44,319.55,114.72,320.27,113,321C97.65,321,82.29,321,66.36,320.66C64.21,319.86,62.64,319.4,60.77,318.73C34.51,310.12,15.56,293.82,4.22,268.85C3.68,267.66,2.1,266.94,1,266C1,242.31,1,218.62,1.29,194.79C2.84,192.16,4.11,189.7,5.34,187.22C18.42,160.94,39.89,144.07,66.64,133.63C76.92,129.62,87.87,127.33,98.67,124.2C97.79,123.24,96.8,121.93,95.59,120.86C85.84,112.3,75.95,103.89,66.3,95.21C55.93,85.86,45.02,76.96,35.71,66.63C21.14,50.5,20.04,23.08,45.41,9.57C50.08,7.08,55.12,5.26,59.93,3.03C60.76,2.64,61.32,1.69,62,1C86.69,1,111.38,1,136.23,1.32C138.04,2.32,139.67,3.01,141.32,3.67C147.64,6.19,154.12,8.39,160.26,11.32C166.83,14.45,172.19,19.18,175.44,25.95C179.39,34.19,178.09,43.36,172.05,49.56C165.75,56.03,157.21,57.8,148.78,52.89C142.4,49.17,136.86,43.96,131.1,39.23C122.63,32.28,115.05,23.88,105.74,18.38C87.78,7.76,68.84,9.07,51.16,19.53C38.68,26.91,36.37,41.4,45.53,52.71C50.38,58.69,56.45,64,62.83,68.36C87.15,84.99,111.86,101.05,136.34,117.44C162.56,135,183.88,156.57,193.26,187.79C193.42,188.32,194.4,188.6,195,189ZM77.06,146.49C61.39,155.71,51.27,169.26,45.93,186.5C39.48,207.32,39.44,228.5,42.93,249.76C45.84,267.48,53.16,282.95,66.59,295.39C83.82,311.34,108.85,312.86,127.37,298.41C138.98,289.35,146.05,277.03,149.48,263.04C161.53,213.92,148.4,171.97,112.16,137.05C111.13,136.06,108.71,135.6,107.31,136.05C97.38,139.22,87.54,142.7,77.06,146.49Z"}),_jsxruntime.jsx.call(void 0, "path",{d:"M118.83,199C121.61,197.69,122.77,198.41,122.77,201.27C122.71,217.43,122.78,233.58,122.65,249.73C122.65,250.83,121.43,251.92,120.77,253.01C119.97,252.05,118.63,251.17,118.45,250.1C116.32,237.7,113.36,235.12,100.61,235.02C98.12,235,95.62,234.98,93.12,235.01C81.26,235.16,77.72,238.3,75.94,249.84C75.74,251.15,74.39,252.28,73.57,253.49C73.11,253.23,72.64,252.98,72.17,252.73C72.17,234.81,72.17,216.88,72.17,198.96C72.49,198.62,72.81,198.28,73.13,197.93C74.09,198.95,75.72,199.85,75.92,201C78.13,213.8,80.95,216.26,94.05,216.3C97.38,216.31,100.72,216.44,104.04,216.27C113.28,215.79,117.15,212.05,118.22,202.81C118.35,201.65,118.47,200.49,118.83,199Z"})]});function N(o){if(o===0)return"0";let a=Math.abs(o);return a>=1e4?o.toFixed(0):a>=1e3?o.toFixed(1):a>=100?o.toFixed(2):a>=1?o.toFixed(4):a>=.01?o.toFixed(6):o.toExponential(3)}var b=_react2.default.memo(()=>{let[o,a]=_react.useState.call(void 0, !1),{liquidityError:k,routingError:F}=_chunkSGTI7NXZcjs.e.call(void 0, ),{baseAmount:n,baseToken:s,quoteAmount:i,quoteToken:r}=_chunkPSCWQFVYcjs.e.call(void 0, ),{quoteLoaderVariant:f,widgetType:E}=_chunkD7GULMHEcjs.b.call(void 0, ),p=E==="compact",d=n&&i&&parseFloat(i.toString())?parseFloat(n.toString())/parseFloat(i.toString()):0,j=s&&r&&s.chainId!==r.chainId,v=s?_nullishCoalesce(_optionalChain([_chunkK3RTTHBScjs.c.call(void 0, s.chainId), 'optionalAccess', _ => _.estimatedTimeMs]), () => (0)):0,S=r?_nullishCoalesce(_optionalChain([_chunkK3RTTHBScjs.c.call(void 0, r.chainId), 'optionalAccess', _2 => _2.estimatedTimeMs]), () => (0)):0,w=(j?v+S:v)/1e3,g=k||F,l=s&&r&&n&&parseFloat(n.toString())&&i;return _react.useEffect.call(void 0, ()=>{f==="expanded"&&l&&a(!0)},[f,l]),f==="none"?null:f==="default"?_jsxruntime.jsx.call(void 0, "div",{className:`relative box-border flex flex-row h-8 w-full items-center${p?" justify-start overflow-x-auto":" justify-center"}`,children:_jsxruntime.jsx.call(void 0, "div",{className:`flex h-full items-center${p?" min-w-max":" w-full overflow-hidden"}`,style:{color:"var(--widget-foreground)"},children:s&&r?n&&parseFloat(n.toString())?i?_jsxruntime.jsxs.call(void 0, "div",{className:"translate-y-px font-sans flex flex-row items-center gap-2 whitespace-nowrap",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center gap-1",children:[_jsxruntime.jsx.call(void 0, _chunkK3RTTHBScjs.O,{asset:r,size:"3xs",noChain:!0,className:"mb-0.5"}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:["1 ",_optionalChain([r, 'optionalAccess', _3 => _3.symbol])]})]}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:"="}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center gap-1",children:[_jsxruntime.jsx.call(void 0, _chunkK3RTTHBScjs.O,{asset:s,size:"3xs",noChain:!0,className:"mb-0.5"}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:[N(d)," ",_optionalChain([s, 'optionalAccess', _4 => _4.symbol])]})]}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:_optionalChain([s, 'optionalAccess', _5 => _5.price])?`\u2248 $${(s.price*d).toFixed(2)}`:""})]}):g?_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full w-full flex-row pb-1 items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-xs",style:{color:"var(--widget-destructive)"},children:"Quote not found"}),_jsxruntime.jsx.call(void 0, _chunkK3RTTHBScjs.W,{className:"h-8 w-8",style:{color:"var(--widget-destructive)"}})]}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full w-full flex-row pb-1 items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-xs",style:{color:"var(--widget-accent)"},children:"Searching For Quote"}),_jsxruntime.jsx.call(void 0, _chunkK3RTTHBScjs.W,{className:"h-8 w-8",style:{color:"var(--widget-accent)"}})]}):_jsxruntime.jsx.call(void 0, "div",{className:"text-xs pb-1",style:{color:"var(--widget-muted-foreground)"},children:"Enter Amount"}):_jsxruntime.jsx.call(void 0, "div",{className:"text-xs pb-1",style:{color:"var(--widget-muted-foreground)"},children:"Enter Amount"})})}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full",children:[_jsxruntime.jsx.call(void 0, "div",{className:`relative box-border flex flex-row pt-1 h-8 w-full items-center cursor-pointer${p?" overflow-x-auto":""}`,role:"button",tabIndex:0,onClick:()=>l&&a(c=>!c),onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),l&&a(L=>!L))},children:_jsxruntime.jsx.call(void 0, "div",{className:`flex h-full items-center${p?" min-w-max overflow-x-auto":" w-full overflow-hidden"}`,style:{color:"var(--widget-foreground)"},children:s&&r?n&&parseFloat(n.toString())?i?_jsxruntime.jsxs.call(void 0, "div",{className:"translate-y-px font-sans flex w-full flex-row items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center gap-2 whitespace-nowrap",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center gap-1",children:[_jsxruntime.jsx.call(void 0, _chunkK3RTTHBScjs.O,{asset:r,size:"3xs",noChain:!0,className:"mb-0.5"}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:["1 ",_optionalChain([r, 'optionalAccess', _6 => _6.symbol])]})]}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:"="}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center gap-1",children:[_jsxruntime.jsx.call(void 0, _chunkK3RTTHBScjs.O,{asset:s,size:"3xs",noChain:!0,className:"mb-0.5"}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:[N(d)," ",_optionalChain([s, 'optionalAccess', _7 => _7.symbol])]})]}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:_optionalChain([s, 'optionalAccess', _8 => _8.price])?`\u2248 $${(s.price*d).toFixed(2)}`:""})]}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs ml-2 transition-transform duration-200 shrink-0",style:{color:"var(--widget-muted-foreground)",transform:o?"rotate(180deg)":"rotate(0deg)",display:"inline-block"},children:"\u25BE"})]}):g?_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full w-full flex-row pb-1 items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-xs",style:{color:"var(--widget-destructive)"},children:"Quote not found"}),_jsxruntime.jsx.call(void 0, _chunkK3RTTHBScjs.W,{className:"h-8 w-8",style:{color:"var(--widget-destructive)"}})]}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full w-full flex-row pb-1 items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-xs",style:{color:"var(--widget-accent)"},children:"Searching For Quote"}),_jsxruntime.jsx.call(void 0, _chunkK3RTTHBScjs.W,{className:"h-8 w-8",style:{color:"var(--widget-accent)"}})]}):_jsxruntime.jsx.call(void 0, "div",{className:"text-xs pb-1",style:{color:"var(--widget-muted-foreground)"},children:"Enter Amount"}):_jsxruntime.jsx.call(void 0, "div",{className:"text-xs pb-1",style:{color:"var(--widget-muted-foreground)"},children:"Enter Amount"})})}),_jsxruntime.jsx.call(void 0, "div",{className:"overflow-hidden transition-all duration-200",style:{maxHeight:o&&l?"120px":"0px",opacity:o&&l?1:0},children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1 pb-1.5 font-sans",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:"USD Value"}),_jsxruntime.jsxs.call(void 0, "span",{style:{color:"var(--widget-secondary-foreground)"},children:["$",_optionalChain([s, 'optionalAccess', _9 => _9.price])&&i?(s.price*d*parseFloat(i.toString())).toFixed(2):"\u2014"]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:"Estimated Time"}),_jsxruntime.jsx.call(void 0, "span",{style:{color:"var(--widget-secondary-foreground)"},children:w>0?`${w.toFixed(2)}s`:"\u2014"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:"Order Type"}),_jsxruntime.jsx.call(void 0, "span",{style:{color:"var(--widget-secondary-foreground)"},children:"RFQ (Limit)"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:"Route"}),_jsxruntime.jsxs.call(void 0, "a",{href:"https://www.aori.io",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 transition-colors hover:opacity-80",style:{color:"var(--widget-secondary-foreground)"},children:[_jsxruntime.jsx.call(void 0, Q,{}),"Aori",_jsxruntime.jsx.call(void 0, I,{})]})]})]})})]})});b.displayName="QuoteLoader";var D=b;exports.a = D;
|
|
2
|
+
var _chunkXLUXVPIKcjs = require('./chunk-XLUXVPIK.cjs');var _chunkPSCWQFVYcjs = require('./chunk-PSCWQFVY.cjs');var _chunkD7GULMHEcjs = require('./chunk-D7GULMHE.cjs');var _chunkK3RTTHBScjs = require('./chunk-K3RTTHBS.cjs');var _react = require('react'); var _react2 = _interopRequireDefault(_react);var _jsxruntime = require('react/jsx-runtime');var I=()=>_jsxruntime.jsxs.call(void 0, "svg",{className:"w-3 h-3 shrink-0",style:{color:"var(--widget-secondary-foreground)"},viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M18 13V19C18 20.1046 17.1046 21 16 21H5C3.89543 21 3 20.1046 3 19V8C3 6.89543 3.89543 6 5 6H11",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),_jsxruntime.jsx.call(void 0, "path",{d:"M15 3H21V9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),_jsxruntime.jsx.call(void 0, "path",{d:"M10 14L21 3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Q=()=>_jsxruntime.jsxs.call(void 0, "svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 195 321",fill:"var(--widget-secondary-foreground)",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "path",{fillRule:"evenodd",d:"M195,189C195,207.02,195,225.04,194.7,243.21C193.68,244.78,192.9,246.17,192.25,247.63C189.71,253.38,187.74,259.46,184.6,264.86C169.44,290.97,147.86,309.46,118.54,318.86C116.44,319.55,114.72,320.27,113,321C97.65,321,82.29,321,66.36,320.66C64.21,319.86,62.64,319.4,60.77,318.73C34.51,310.12,15.56,293.82,4.22,268.85C3.68,267.66,2.1,266.94,1,266C1,242.31,1,218.62,1.29,194.79C2.84,192.16,4.11,189.7,5.34,187.22C18.42,160.94,39.89,144.07,66.64,133.63C76.92,129.62,87.87,127.33,98.67,124.2C97.79,123.24,96.8,121.93,95.59,120.86C85.84,112.3,75.95,103.89,66.3,95.21C55.93,85.86,45.02,76.96,35.71,66.63C21.14,50.5,20.04,23.08,45.41,9.57C50.08,7.08,55.12,5.26,59.93,3.03C60.76,2.64,61.32,1.69,62,1C86.69,1,111.38,1,136.23,1.32C138.04,2.32,139.67,3.01,141.32,3.67C147.64,6.19,154.12,8.39,160.26,11.32C166.83,14.45,172.19,19.18,175.44,25.95C179.39,34.19,178.09,43.36,172.05,49.56C165.75,56.03,157.21,57.8,148.78,52.89C142.4,49.17,136.86,43.96,131.1,39.23C122.63,32.28,115.05,23.88,105.74,18.38C87.78,7.76,68.84,9.07,51.16,19.53C38.68,26.91,36.37,41.4,45.53,52.71C50.38,58.69,56.45,64,62.83,68.36C87.15,84.99,111.86,101.05,136.34,117.44C162.56,135,183.88,156.57,193.26,187.79C193.42,188.32,194.4,188.6,195,189ZM77.06,146.49C61.39,155.71,51.27,169.26,45.93,186.5C39.48,207.32,39.44,228.5,42.93,249.76C45.84,267.48,53.16,282.95,66.59,295.39C83.82,311.34,108.85,312.86,127.37,298.41C138.98,289.35,146.05,277.03,149.48,263.04C161.53,213.92,148.4,171.97,112.16,137.05C111.13,136.06,108.71,135.6,107.31,136.05C97.38,139.22,87.54,142.7,77.06,146.49Z"}),_jsxruntime.jsx.call(void 0, "path",{d:"M118.83,199C121.61,197.69,122.77,198.41,122.77,201.27C122.71,217.43,122.78,233.58,122.65,249.73C122.65,250.83,121.43,251.92,120.77,253.01C119.97,252.05,118.63,251.17,118.45,250.1C116.32,237.7,113.36,235.12,100.61,235.02C98.12,235,95.62,234.98,93.12,235.01C81.26,235.16,77.72,238.3,75.94,249.84C75.74,251.15,74.39,252.28,73.57,253.49C73.11,253.23,72.64,252.98,72.17,252.73C72.17,234.81,72.17,216.88,72.17,198.96C72.49,198.62,72.81,198.28,73.13,197.93C74.09,198.95,75.72,199.85,75.92,201C78.13,213.8,80.95,216.26,94.05,216.3C97.38,216.31,100.72,216.44,104.04,216.27C113.28,215.79,117.15,212.05,118.22,202.81C118.35,201.65,118.47,200.49,118.83,199Z"})]});function N(o){if(o===0)return"0";let a=Math.abs(o);return a>=1e4?o.toFixed(0):a>=1e3?o.toFixed(1):a>=100?o.toFixed(2):a>=1?o.toFixed(4):a>=.01?o.toFixed(6):o.toExponential(3)}var b=_react2.default.memo(()=>{let[o,a]=_react.useState.call(void 0, !1),{liquidityError:k,routingError:F}=_chunkXLUXVPIKcjs.e.call(void 0, ),{baseAmount:n,baseToken:s,quoteAmount:i,quoteToken:r}=_chunkPSCWQFVYcjs.e.call(void 0, ),{quoteLoaderVariant:f,widgetType:E}=_chunkD7GULMHEcjs.b.call(void 0, ),p=E==="compact",d=n&&i&&parseFloat(i.toString())?parseFloat(n.toString())/parseFloat(i.toString()):0,j=s&&r&&s.chainId!==r.chainId,v=s?_nullishCoalesce(_optionalChain([_chunkK3RTTHBScjs.c.call(void 0, s.chainId), 'optionalAccess', _ => _.estimatedTimeMs]), () => (0)):0,S=r?_nullishCoalesce(_optionalChain([_chunkK3RTTHBScjs.c.call(void 0, r.chainId), 'optionalAccess', _2 => _2.estimatedTimeMs]), () => (0)):0,w=(j?v+S:v)/1e3,g=k||F,l=s&&r&&n&&parseFloat(n.toString())&&i;return _react.useEffect.call(void 0, ()=>{f==="expanded"&&l&&a(!0)},[f,l]),f==="none"?null:f==="default"?_jsxruntime.jsx.call(void 0, "div",{className:`relative box-border flex flex-row h-8 w-full items-center${p?" justify-start overflow-x-auto":" justify-center"}`,children:_jsxruntime.jsx.call(void 0, "div",{className:`flex h-full items-center${p?" min-w-max":" w-full overflow-hidden"}`,style:{color:"var(--widget-foreground)"},children:s&&r?n&&parseFloat(n.toString())?i?_jsxruntime.jsxs.call(void 0, "div",{className:"translate-y-px font-sans flex flex-row items-center gap-2 whitespace-nowrap",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center gap-1",children:[_jsxruntime.jsx.call(void 0, _chunkK3RTTHBScjs.O,{asset:r,size:"3xs",noChain:!0,className:"mb-0.5"}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:["1 ",_optionalChain([r, 'optionalAccess', _3 => _3.symbol])]})]}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:"="}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center gap-1",children:[_jsxruntime.jsx.call(void 0, _chunkK3RTTHBScjs.O,{asset:s,size:"3xs",noChain:!0,className:"mb-0.5"}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:[N(d)," ",_optionalChain([s, 'optionalAccess', _4 => _4.symbol])]})]}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:_optionalChain([s, 'optionalAccess', _5 => _5.price])?`\u2248 $${(s.price*d).toFixed(2)}`:""})]}):g?_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full w-full flex-row pb-1 items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-xs",style:{color:"var(--widget-destructive)"},children:"Quote not found"}),_jsxruntime.jsx.call(void 0, _chunkK3RTTHBScjs.W,{className:"h-8 w-8",style:{color:"var(--widget-destructive)"}})]}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full w-full flex-row pb-1 items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-xs",style:{color:"var(--widget-accent)"},children:"Searching For Quote"}),_jsxruntime.jsx.call(void 0, _chunkK3RTTHBScjs.W,{className:"h-8 w-8",style:{color:"var(--widget-accent)"}})]}):_jsxruntime.jsx.call(void 0, "div",{className:"text-xs pb-1",style:{color:"var(--widget-muted-foreground)"},children:"Enter Amount"}):_jsxruntime.jsx.call(void 0, "div",{className:"text-xs pb-1",style:{color:"var(--widget-muted-foreground)"},children:"Enter Amount"})})}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full",children:[_jsxruntime.jsx.call(void 0, "div",{className:`relative box-border flex flex-row pt-1 h-8 w-full items-center cursor-pointer${p?" overflow-x-auto":""}`,role:"button",tabIndex:0,onClick:()=>l&&a(c=>!c),onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),l&&a(L=>!L))},children:_jsxruntime.jsx.call(void 0, "div",{className:`flex h-full items-center${p?" min-w-max overflow-x-auto":" w-full overflow-hidden"}`,style:{color:"var(--widget-foreground)"},children:s&&r?n&&parseFloat(n.toString())?i?_jsxruntime.jsxs.call(void 0, "div",{className:"translate-y-px font-sans flex w-full flex-row items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center gap-2 whitespace-nowrap",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center gap-1",children:[_jsxruntime.jsx.call(void 0, _chunkK3RTTHBScjs.O,{asset:r,size:"3xs",noChain:!0,className:"mb-0.5"}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:["1 ",_optionalChain([r, 'optionalAccess', _6 => _6.symbol])]})]}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:"="}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center gap-1",children:[_jsxruntime.jsx.call(void 0, _chunkK3RTTHBScjs.O,{asset:s,size:"3xs",noChain:!0,className:"mb-0.5"}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:[N(d)," ",_optionalChain([s, 'optionalAccess', _7 => _7.symbol])]})]}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:_optionalChain([s, 'optionalAccess', _8 => _8.price])?`\u2248 $${(s.price*d).toFixed(2)}`:""})]}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs ml-2 transition-transform duration-200 shrink-0",style:{color:"var(--widget-muted-foreground)",transform:o?"rotate(180deg)":"rotate(0deg)",display:"inline-block"},children:"\u25BE"})]}):g?_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full w-full flex-row pb-1 items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-xs",style:{color:"var(--widget-destructive)"},children:"Quote not found"}),_jsxruntime.jsx.call(void 0, _chunkK3RTTHBScjs.W,{className:"h-8 w-8",style:{color:"var(--widget-destructive)"}})]}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full w-full flex-row pb-1 items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-xs",style:{color:"var(--widget-accent)"},children:"Searching For Quote"}),_jsxruntime.jsx.call(void 0, _chunkK3RTTHBScjs.W,{className:"h-8 w-8",style:{color:"var(--widget-accent)"}})]}):_jsxruntime.jsx.call(void 0, "div",{className:"text-xs pb-1",style:{color:"var(--widget-muted-foreground)"},children:"Enter Amount"}):_jsxruntime.jsx.call(void 0, "div",{className:"text-xs pb-1",style:{color:"var(--widget-muted-foreground)"},children:"Enter Amount"})})}),_jsxruntime.jsx.call(void 0, "div",{className:"overflow-hidden transition-all duration-200",style:{maxHeight:o&&l?"120px":"0px",opacity:o&&l?1:0},children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1 pb-1.5 font-sans",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:"USD Value"}),_jsxruntime.jsxs.call(void 0, "span",{style:{color:"var(--widget-secondary-foreground)"},children:["$",_optionalChain([s, 'optionalAccess', _9 => _9.price])&&i?(s.price*d*parseFloat(i.toString())).toFixed(2):"\u2014"]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:"Estimated Time"}),_jsxruntime.jsx.call(void 0, "span",{style:{color:"var(--widget-secondary-foreground)"},children:w>0?`${w.toFixed(2)}s`:"\u2014"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:"Order Type"}),_jsxruntime.jsx.call(void 0, "span",{style:{color:"var(--widget-secondary-foreground)"},children:"RFQ (Limit)"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:"Route"}),_jsxruntime.jsxs.call(void 0, "a",{href:"https://www.aori.io",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 transition-colors hover:opacity-80",style:{color:"var(--widget-secondary-foreground)"},children:[_jsxruntime.jsx.call(void 0, Q,{}),"Aori",_jsxruntime.jsx.call(void 0, I,{})]})]})]})})]})});b.displayName="QuoteLoader";var D=b;exports.a = D;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{a as Ir}from"./chunk-OPN7WCJR.js";import{e as Ue}from"./chunk-YO5D6L5W.js";import{b as Ie,c as Lt,d as ee}from"./chunk-GPT4NHM5.js";import{E as Qe,F as it,H as Pt,I as $t,J as ct,N as ye,O as re,P as Z,S as be,T as Ut,U as We,V as X,X as Mt,Y as Fe,a as qe,c as q,h as st,k as Oe,m as Pe,o as $e,q as Nt,r as se,s as Et,t as ot,v as at,w as It,x as Ot}from"./chunk-QAOZRRSH.js";import{a as oe}from"./chunk-46H44R7V.js";import{b as Er}from"./chunk-73CB2I7U.js";import{useQueryClient as Or}from"@tanstack/react-query";import{useCallback as Pr,useEffect as Vt,useRef as Dt}from"react";function $r(e){if(e.length===0)return 5e3;let l=Math.max(...e.map(s=>q(s)?.blockTimeMs??2e3));return Math.min(5e3,Math.max(1e3,l*2+1e3))}var Ur=()=>{let{address:e}=oe(),t=Lt(),n=Or(),c=Dt(null),l=Dt(!0),s=Pr(a=>{if(!e)return;let v=[...new Set(a.tokens.map(d=>d.asset.chainId))],p=$r(v);c.current&&(clearTimeout(c.current),c.current=null),c.current=setTimeout(async()=>{if(c.current=null,!!l.current)try{let d=a.tokens.map(w=>({chainId:w.asset.chainId,tokenAddress:w.asset.address})),o=await $t(e,d);if(o.balances.length===0)return;if(a.tokens.length>=2){let w=a.tokens[0].asset,u=a.tokens[1].asset,h=ct.swap(e,w.chainId,w.address,u.chainId,u.address);n.setQueryData(h,o)}let r=ct.bulk(e,t),y=n.getQueryData(r);if(y){let w=y.balances.map(u=>o.balances.find(m=>m.chainId===u.chainId&&m.token.toLowerCase()===u.token.toLowerCase())??u);for(let u of o.balances)w.some(h=>h.chainId===u.chainId&&h.token.toLowerCase()===u.token.toLowerCase())||w.push(u);for(let u of a.tokens)if(!o.balances.some(m=>m.chainId===u.asset.chainId&&m.token.toLowerCase()===u.asset.address.toLowerCase())){let m=w.findIndex(i=>i.chainId===u.asset.chainId&&i.token.toLowerCase()===u.asset.address.toLowerCase());m!==-1&&(w[m]={...w[m],balance:"0",shiftedBalance:"0"})}n.setQueryData(r,{balances:w})}}catch{}},p)},[e,t,n]);return Vt(()=>(l.current=!0,()=>{l.current=!1,c.current&&(clearTimeout(c.current),c.current=null)}),[]),{triggerBalanceUpdate:s}},lt=class extends EventTarget{emit(t){this.dispatchEvent(new CustomEvent("balance-update",{detail:t}))}},ut=new lt,Me=()=>e=>ut.emit(e),gs=()=>{let{triggerBalanceUpdate:e}=Ur();Vt(()=>{let t=n=>{e(n.detail)};return ut.addEventListener("balance-update",t),()=>ut.removeEventListener("balance-update",t)},[e])};import{createContext as Mr,useCallback as pe,useContext as Lr,useEffect as Wt,useMemo as Dr,useRef as ae,useState as Re}from"react";import{formatUnits as Vr,parseUnits as Wr}from"viem";import{jsx as Qr}from"react/jsx-runtime";var _t=Mr(void 0),Ft=1e4,Fr=3e4,_r=1e3,Br=2;function qr(e){return e.find(n=>n.routeSteps?.[0]?.type==="AORI_V1")??e[0]}var Ss=({children:e,recipient:t})=>{let{address:n}=oe(),c=t||n,[l,s]=Re("idle"),[a,v]=Re("idle"),[p,d]=Re(null),[o,r]=Re(null),[y,w]=Re(!1),[u,h]=Re(!1),[m,i]=Re(!1),g=ae(null),x=ae(null),f=ae(null),k=ae(null),O=ae(null),C=ae(0),M=ae(0),D=ae(0),E=ae(!1),I=ae(new Map),P=pe(()=>{f.current&&clearTimeout(f.current),k.current&&clearTimeout(k.current),O.current&&clearTimeout(O.current),f.current=null,k.current=null,O.current=null},[]),$=pe(()=>{P(),g.current=null,C.current=0,s(()=>E.current?"fresh":"idle")},[P]),W=pe(()=>{$(),x.current=null,d(null),r(null),w(!1),h(!1),i(!1),I.current.clear(),s("idle"),v("idle")},[$]),H=pe(S=>{if(!S)return;k.current&&clearTimeout(k.current);let R=Math.max(0,S+Fr-Date.now());k.current=setTimeout(()=>{s(L=>L==="idle"?"idle":"stale")},R)},[]),te=pe(async(S,R)=>{let{inputToken:L,outputToken:N,inputAmount:B,setOutputAmount:J}=S;if(!L||!N||!B||parseFloat(B)<=0||Date.now()-(M.current||0)<Ft-10)return;let Se=++C.current;try{if(!L?.decimals||!N?.decimals)return;let K=it(L.chainId)||q(L.chainId)?.key||"",ie=it(N.chainId)||q(N.chainId)?.key||"";if(!K||!ie)throw new Error("Unknown chain");let ne=Wr(B.toString(),L.decimals).toString(),ce={srcChainKey:K,dstChainKey:ie,srcTokenAddress:at(L.address),dstTokenAddress:at(N.address),amount:ne,srcWalletAddress:n||"0x0000000000000000000000000000000000000000",dstWalletAddress:c||n||"0x0000000000000000000000000000000000000000",options:{amountType:"EXACT_SRC_AMOUNT",feeTolerance:{type:"PERCENT",amount:2}}};M.current=Date.now();let le=await fetch(`${Oe()}/quotes`,{method:"POST",headers:Pe(),body:JSON.stringify(ce),signal:AbortSignal.timeout(15e3)});if(!le.ok){let Ee=(await le.json().catch(()=>({})))?.message||le.statusText;throw Object.assign(new Error(Ee),{status:le.status})}let ue=await le.json();if(Se!==C.current||g.current!==R)return;let Te=ue.quotes??[],de=qr(Te);if(!de)throw Object.assign(new Error("No quotes returned"),{emptyQuotes:!0});let Ve=Number(Vr(Nt(de.dstAmount),N.decimals));typeof J=="function"&&J(Ve),de._receivedAt=Date.now(),d(de),r(null),w(!1),s("fresh"),H(de._receivedAt),R&&I.current.delete(R)}catch(K){if(Se!==C.current||g.current!==R)return;let ie=K?.status,ne=K instanceof Error?K.message:"",ce=!!K?.emptyQuotes;if((ie===400||ce||ne.includes("Quote request failed"))&&R){let ue=(I.current.get(R)||0)+1;if(I.current.set(R,ue),ue>=Br){h(!0),P(),g.current=null;return}}if(ne.toLowerCase().includes("order cap exceeded")){i(!0),P(),g.current=null;return}if(ne.toLowerCase().includes("insufficient executor balance")){w(!0),P(),g.current=null;return}r(K instanceof Error?K.message:"Unknown error")}},[n,c,H,P]),U=pe((S,R)=>{P(),x.current=S,M.current=0,I.current.delete(R),w(!1),h(!1),i(!1),r(null),s("polling");let L=async()=>{g.current===R&&(await te(S,R),g.current===R&&(f.current=setTimeout(L,Ft)))};L()},[P,te]),T=pe(S=>{if(!S?.inputToken||!S?.outputToken||!S?.inputAmount||parseFloat(S.inputAmount)<=0){$();return}let R=x.current;if(R&&R.inputToken?.address===S.inputToken?.address&&R.inputToken?.chainId===S.inputToken?.chainId&&R.outputToken?.address===S.outputToken?.address&&R.outputToken?.chainId===S.outputToken?.chainId&&R.inputAmount===S.inputAmount&&g.current)return;let N=Date.now();if(N-D.current<100)return;D.current=N;let B=`${Date.now()}-${Math.random().toString(36).slice(2)}`;g.current=B,U(S,B)},[U,$]),_=pe(({amount:S,inputToken:R,outputToken:L,setOutputAmount:N})=>{N(null),O.current&&clearTimeout(O.current),!S||S===0?(v("idle"),$(),d(null),r(null),w(!1),h(!1),i(!1)):(v("typing"),$(),d(null),w(!1),h(!1),i(!1),r(null),O.current=setTimeout(()=>{v("settled"),R&&L&&S>0&&T({inputToken:R,outputToken:L,inputAmount:S.toString(),setOutputAmount:N})},_r))},[$,T]),Q=pe(()=>{let S=x.current;if(!S)return;d(null);let R=`${Date.now()}-${Math.random().toString(36).slice(2)}`;g.current=R,s("refreshing"),typeof S.setOutputAmount=="function"&&S.setOutputAmount(null),U(S,R)},[U]);Wt(()=>{E.current=!!p},[p]),Wt(()=>()=>P(),[P]);let G=Dr(()=>({status:l,inputState:a,rfqQuote:p,error:o,liquidityError:y,routingError:u,sizeCapError:m,ensureForParams:T,stop:$,refresh:Q,clear:W,handleInputChange:_}),[l,a,p,o,y,u,m,T,$,Q,W,_]);return Qr(_t.Provider,{value:G,children:e})},ze=()=>{let e=Lr(_t);if(e===void 0)throw new Error("useRfq must be used within an RfqProvider");return e};import{createContext as zr,useContext as jr}from"react";var Hr=zr({openConnectModal:()=>{}}),ks=()=>jr(Hr);import{useCallback as dt,useEffect as Le,useRef as je,useState as pt}from"react";import{jsx as De,jsxs as Xr}from"react/jsx-runtime";var Gr=20,Kr=({side:e,asset:t,otherAsset:n,isPlacingOrder:c,isWrappingPair:l,isUnwrappingPair:s})=>{let{baseAmount:a,quoteAmount:v,setBaseAmount:p,setQuoteAmount:d}=Ue(),{amountInputVariant:o,hideAmountInputSymbol:r,widgetType:y}=Ie(),w=y==="compact",[u,h]=e==="base"?[p,d]:[d,p],m=!t||e==="quote"||c,i=w?32:o==="default"?64:32,[g,x]=pt(i),[f,k]=pt(""),O=je(null),C=je(null),M=je(null),D=je(null),E="USD",I=e==="base"?a:v,[P,$]=pt(!1),W=dt(()=>{if(o!=="default"){x(i);return}if(!O.current||!C.current||!M.current)return;let U=O.current.offsetWidth,T=20,_=i;for(;_>20&&(C.current.style.fontSize=`${_}px`,M.current.style.fontSize=`${_}px`,!(C.current.offsetWidth+M.current.offsetWidth+T<=U));)_-=1;x(_)},[o,i]),H=dt(U=>{U.key==="."&&f.includes(".")&&U.preventDefault()},[f]),te=dt(U=>{let T=U.target.value;if(T==="."&&(T="0."),!/^\d*\.?\d*$/.test(T)||(T.match(/\./g)||[]).length>1)return;if(T.length>1&&T[0]==="0"&&T[1]!=="."&&(T=T.replace(/^0+/,"")||"0"),t?.decimals!==void 0&&T.includes(".")){let[,Q]=T.split(".");if(Q&&Q.length>t.decimals)return}if(T.length>Gr)return;k(T);let _=parseFloat(T);T!==f&&(T===""||T==="0."||T.endsWith(".")?(u(null),e==="base"&&h(null)):!Number.isNaN(_)&&_>=0&&u(_),e==="base"&&d(null),(s||l)&&d(_||0))},[f,u,e,d,t?.decimals,h,s,l]);return Le(()=>{let U=Q=>{if(Q===null)return"";let G=t?.decimals;if(G===void 0)return"";let S=Q.toString();if(/e/i.test(S)&&(S=Number(Q).toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:G})),S.includes(".")){let[R,L]=S.split("."),N=L.slice(0,G);return N?`${R}.${N}`:R}return S};if(I===null){f==="0."||f!==""&&f.endsWith(".")||k("");return}if(!m&&(f.endsWith(".")||f.match(/\.\d*0$/)||f==="0"||f==="0.")&&f!=="")return;let _=parseFloat(f)||0;(f===""||Math.abs(_-I)>1e-10)&&k(U(I))},[I,t?.decimals,f,m]),Le(()=>{W()},[f,W]),Le(()=>{$(!0)},[]),Le(()=>{P&&W()},[P,W]),Le(()=>{C.current&&D.current&&(D.current.style.width=`${C.current.offsetWidth}px`)},[f]),Le(()=>{if(!P)return;let U=new ResizeObserver(()=>{P&&W()});return O.current&&U.observe(O.current),()=>U.disconnect()},[P,W]),De("div",{ref:O,style:{fontSize:`${g}px`,transition:"font-size 0.05s ease-in-out"},className:`mt-2 box-border font-sans flex ${w?o==="normal"?"h-12 my-1":"h-10 my-0.5":o==="normal"?"h-12 my-1":"h-20 my-1"} w-full flex-row items-center ${m?"cursor-default":"cursor-text"}`,onClick:()=>D.current?.focus(),children:Xr("div",{className:"relative flex w-full items-center",children:[De("label",{htmlFor:`${e}Amount`,className:"sr-only",children:e==="base"?"Input token amount":"Output token amount"}),De("input",{ref:D,type:"text",inputMode:"decimal",placeholder:"0",autoComplete:"off",id:`${e}Amount`,value:f,onWheel:U=>U.target.blur(),onKeyDown:H,onChange:te,style:{transition:"width 0.15s ease-in-out",color:"var(--widget-foreground)",WebkitTextFillColor:"var(--widget-foreground)",opacity:1},className:"flex min-w-[45px] whitespace-nowrap bg-transparent placeholder:opacity-50 font-sans font-thin",disabled:m}),De("span",{style:{transition:"width 0.15s ease-in-out"},ref:C,className:"pointer-events-none absolute flex whitespace-nowrap invisible",children:f||0}),!r&&o!=="normal"&&De("span",{ref:M,className:"ml-2 font-thin uppercase",style:{color:"var(--widget-foreground)",opacity:.5,fontSize:`${g}px`},children:t?.symbol?t.symbol.length>6?`${t.symbol.slice(0,6)}...`:t.symbol:E}),(r||o==="normal")&&De("span",{ref:M,className:"hidden"})]})})},$s=Kr;import{Fragment as ft,jsx as V,jsxs as fe}from"react/jsx-runtime";var Yr=({toggle:e,side:t,asset:n,isPlacingOrder:c,hideDropdown:l})=>{let{baseBalance:s,quoteBalance:a}=Ue(),{tokenDisplay:v,tokenBadgeOrientation:p,widgetType:d}=Ie(),o=d==="compact",r=o?"h-10":"h-13",y=o?"h-10 w-10":"h-13 w-13",w=t==="base"?s.formatted?(()=>{let h=parseFloat(s.formatted);return h>=1e4?$e(h):h.toFixed(4)})():void 0:a.formatted?(()=>{let h=parseFloat(a.formatted);return h>=1e4?$e(h):h.toFixed(4)})():void 0,u={role:"button",tabIndex:c?-1:0,"aria-disabled":c,"aria-label":`Select ${t==="base"?"input":"output"} token${n?`: ${n.symbol}`:""}`,onClick:c?void 0:e,onKeyDown:c?void 0:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),e())}};return v==="pill"?V("div",{...u,className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-full cursor-pointer transition-colors ${p==="right"?"ml-auto":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-secondary)",color:"var(--widget-secondary-foreground)"},children:n?fe(ft,{children:[V(ye,{chain:n.chainId,size:"xs"}),V(re,{className:"rounded-full",asset:n,size:"xxs",noChain:!0}),V("span",{className:"text-xs font-thin uppercase",children:n.symbol}),!l&&V(We,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]}):fe(ft,{children:[V("span",{className:"text-xs opacity-70",children:"Select"}),!l&&V(We,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]})}):v==="ghost"?fe("div",{...u,className:"inline-flex items-center gap-1.5 cursor-pointer transition-opacity hover:opacity-70 py-1",style:{color:"var(--widget-foreground)"},children:[n?fe(ft,{children:[V(ye,{chain:n.chainId,size:"xs"}),V(re,{className:"rounded-full",asset:n,size:"xxs",noChain:!0}),V("span",{className:"text-sm font-thin uppercase",children:n.symbol})]}):V("span",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Select token"}),!l&&V(We,{className:"w-1.5 opacity-50"})]}):V("div",{...u,className:`relative ${r} 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:V("div",{className:"relative flex h-full w-full flex-row items-center",children:n?fe("div",{className:"relative flex h-full w-full flex-row items-center",children:[V("div",{className:`${y} pl-px flex items-center justify-center`,children:V(re,{className:"rounded-full",asset:n,size:"lg"})}),fe("div",{className:"flex h-full w-full flex-row items-center justify-between pl-2.5 pr-7",children:[fe("div",{className:"flex h-full flex-col justify-center gap-0.5",children:[V("p",{className:"text-base font-thin uppercase",style:{color:"var(--widget-secondary-foreground)"},children:n.symbol}),fe("span",{className:"text-xs font-sans",style:{color:"var(--widget-muted-foreground)"},children:[n.address?.slice(0,6),"...",n.address?.slice(-4)]})]}),w!==void 0&&fe("div",{className:"flex flex-col text-right",children:[V("p",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Balance"}),V("span",{className:"font-sans text-xs tabular-nums",style:{color:"var(--widget-foreground)",opacity:.5},children:w})]})]}),!l&&V(We,{className:"absolute right-3 top-1/2 w-1.5 translate-y-[-50%]",style:{color:"var(--widget-secondary-foreground)",opacity:.6}})]}):V("div",{className:"flex h-full w-full items-center justify-center",children:V("span",{className:"text-sm",style:{color:"var(--widget-secondary-foreground)",opacity:.7},children:"Select token"})})})})},Ws=Yr;var qt=Er(Ir(),1);import{useState as He,useEffect as Ge}from"react";import{jsx as Y,jsxs as Bt}from"react/jsx-runtime";var Jr=()=>{let[e,t]=He(null),[n,c]=He(""),l=Ot(n,1e3),[s,a]=He(!1),[v,p]=He("");Ge(()=>{ee.getState().setRecipient(e)},[e]),Ge(()=>{c(e||"")},[e]);let d=r=>{let y=r.target.value;s&&(a(!1),p(""),t(null)),c(y),y===""&&t(null)};Ge(()=>{l===""||!l?(a(!1),p(""),t(null)):It(l)?(a(!1),p(""),t(l)):(a(!0),p("Invalid wallet address..."),t(null),c(""))},[l]),Ge(()=>{if(s){let r=setTimeout(()=>{t(null),c(""),a(!1),p("")},2e3);return()=>clearTimeout(r)}},[s]);let o=()=>{t(null),c(""),a(!1),p("")};return Y("div",{className:"w-full",children:Bt("div",{className:"relative flex flex-row items-center",children:[Y("input",{type:"password",style:{display:"none"},"aria-hidden":"true",tabIndex:-1}),Y("label",{htmlFor:"recipient-address",className:"sr-only",children:"Recipient wallet address"}),Y("div",{className:"absolute left-3 flex h-6 w-6 items-end justify-center overflow-hidden rounded-full",style:{backgroundColor:"var(--widget-secondary)"},children:e&&!s?Y("img",{className:"h-full w-full rounded-full object-cover",src:(0,qt.makeGradient)(e),alt:"Recipient avatar"}):Y(Ut,{className:"h-5 w-5",style:{color:s?"var(--widget-destructive)":"var(--widget-muted-foreground)"}})}),Y("div",{className:"absolute left-12 top-1.5 -translate-y-1 text-xs font-medium opacity-60",style:{color:s?"var(--widget-destructive)":"var(--widget-muted-foreground)"},"aria-hidden":"true",children:"To:"}),Y("input",{id:"recipient-address",className:"font-sans block h-10 w-full items-center pl-12 pt-4 pr-8 text-xs",style:{backgroundColor:s?"color-mix(in srgb, var(--widget-destructive) 10%, transparent)":"transparent",color:s?"var(--widget-destructive)":"var(--widget-foreground)",outline:"none",opacity:s?.9:1},placeholder:s?v:"Enter recipient address...",value:n,onChange:d,spellCheck:!1,"aria-invalid":s,"aria-describedby":s?"recipient-error":void 0}),s&&Y("span",{id:"recipient-error",className:"sr-only",children:v}),e&&!s&&Bt("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 cursor-pointer flex items-center justify-center h-4 w-4 rounded-full transition-colors hover:[color:var(--widget-destructive)]",style:{color:"var(--widget-muted-foreground)"},onClick:o,"aria-label":"Clear recipient",children:[Y("svg",{className:"h-2.5 w-2.5",viewBox:"0 -0.5 21 21",fill:"none",children:Y("g",{fill:"currentColor",fillRule:"evenodd",children:Y("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)"})})}),Y("span",{className:"sr-only",children:"Clear recipient"})]})]})})},js=Jr;import{jsx as Qt,jsxs as Zr}from"react/jsx-runtime";function Ks(e){return Zr("svg",{width:"485",height:"484",viewBox:"0 0 485 484",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[Qt("path",{d:"M265.974 52.8127C270.567 50.9299 273.227 53.6338 275.917 56.1595C301.879 80.5364 327.828 104.927 353.786 129.308C380.101 154.024 406.44 178.715 432.721 203.467C436.002 206.557 440.744 209.272 438.226 215.021C435.865 220.415 430.758 219.123 426.424 219.124C305.965 219.169 185.506 219.163 65.0464 219.166C53.0995 219.166 49.0676 215.225 49.0125 203.316C48.9563 191.154 48.9813 178.991 48.9973 166.829C49.0119 155.717 53.3581 151.358 64.4131 151.358C127.892 151.357 191.37 151.364 254.849 151.368C262.591 151.368 262.645 151.344 262.588 143.559C262.388 116.237 262.191 88.914 261.918 61.5922C261.883 58.0834 262.161 54.9042 265.974 52.8127Z",fill:"currentColor"}),Qt("path",{d:"M80.5649 300.432C71.3447 291.747 62.4175 283.264 53.4064 274.87C50.4552 272.122 47.8959 269.327 49.7894 264.946C51.6154 260.72 55.4624 260.923 59.1682 260.923C164.476 260.927 269.785 260.932 375.093 260.935C391.422 260.935 407.752 260.9 424.081 260.933C434.679 260.955 438.994 265.286 439.015 275.854C439.04 288.517 439.048 301.181 439.013 313.845C438.985 324.225 434.466 328.73 424.01 328.732C360.359 328.741 296.707 328.729 233.056 328.714C225.392 328.713 225.368 328.686 225.426 336.583C225.628 363.741 225.815 390.9 226.101 418.057C226.142 421.935 225.905 425.512 221.852 427.329C217.686 429.197 214.934 426.578 212.212 424.02C172.068 386.302 131.922 348.587 91.7738 310.874C88.1374 307.459 84.4753 304.07 80.5649 300.432Z",fill:"currentColor"})]})}var en=["SUCCEEDED","FAILED","COMPLETED","CANCELLED"];async function zt(e,t,n={}){let{onStatusChange:c,onComplete:l,onError:s,interval:a=4e3,timeout:v=3e5,txHash:p,signal:d}=n,o=null,r=Date.now(),y=0,w=8,u=null,h=p?`?txHash=${p}`:"";return new Promise((m,i)=>{let g=async()=>{try{if(d?.aborted){u&&clearTimeout(u),i(new DOMException("Polling aborted","AbortError"));return}if(Date.now()-r>v){u&&clearTimeout(u);let O=new Error("Order status polling timed out");s?.(O),i(O);return}let x=await fetch(`${t}/status/${e}${h}`,{headers:Pe(),signal:d});if(x.status===404){u=setTimeout(g,a);return}if(!x.ok)throw new Error(`Failed to fetch order status: ${await x.text()}`);let f=await x.json();if(!f||typeof f!="object"||!f.status)throw new Error(`Invalid status response format: ${JSON.stringify(f)}`);y=0;let k=f.status.toUpperCase();if(k!==o&&(o=k,c?.(f)),en.includes(k)){u&&clearTimeout(u),l?.(f),m(f);return}u=setTimeout(g,a)}catch(x){if(x instanceof Error&&x.name==="AbortError"){u&&clearTimeout(u),i(x);return}if(++y>=w){u&&clearTimeout(u);let f=x instanceof Error?x:new Error(String(x));s?.(f),i(f);return}u=setTimeout(g,a)}};g()})}import{useCallback as Ke,useEffect as tn,useRef as Xe}from"react";function jt(e){let t=e.toUpperCase();return t==="SUCCEEDED"||t==="COMPLETED"?"completed":t==="FAILED"?"failed":t==="CANCELLED"?"cancelled":t==="PROCESSING"?"received":"pending"}var Ht=e=>{let t=Xe(new Map),n=Xe(new Map),c=Xe(new Map),l=Xe(0),s=Ke(()=>++l.current,[]),{address:a}=oe(),v=Me(),p=Ke((r,y)=>{if(t.current.get(r))return;y&&n.current.set(r,y),t.current.set(r,!0);let w=l.current,u=new AbortController;c.current.set(r,u);let h=y?.baseToken?.chainId===1;zt(r,Oe(),{interval:h?1e3:500,timeout:3e5,signal:u.signal,onStatusChange:m=>{if(!m?.status)return;let i=jt(m.status);if(e?.(r,i,m.explorerUrl),i==="completed"&&a){let g=n.current.get(r);if(g&&(g.baseToken||g.quoteToken)){let x=[];g.baseToken&&x.push({asset:g.baseToken,userAddress:a}),g.quoteToken&&x.push({asset:g.quoteToken,userAddress:a}),v({type:"swap",tokens:x})}}["completed","failed","cancelled"].includes(i)&&(t.current.delete(r),n.current.delete(r)),w!==l.current&&(t.current.delete(r),n.current.delete(r))},onComplete:m=>{m?.status&&e?.(r,jt(m.status),m.explorerUrl),t.current.delete(r),n.current.delete(r)},onError:()=>{t.current.delete(r),n.current.delete(r)}}).catch(m=>{m instanceof Error&&m.name==="AbortError"||(t.current.delete(r),n.current.delete(r),c.current.delete(r))})},[a,v,e]),d=Ke(r=>{let y=c.current.get(r);y&&(y.abort(),c.current.delete(r)),s(),t.current.delete(r),n.current.delete(r)},[s]),o=Ke(()=>{for(let r of c.current.values())r.abort();c.current.clear(),s(),t.current.clear(),n.current.clear()},[s]);return tn(()=>()=>o(),[o]),{startPolling:p,stopPolling:d,stopAllPolling:o,isPolling:r=>t.current.has(r)}};import{createContext as rn,useContext as nn}from"react";var sn=rn({registerTransaction:()=>{},enabled:!1}),Gt=()=>nn(sn);import{signTypedData as on}from"viem/actions";function Xt(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 Kt(e){if(e.chain?.id)return e.chain.id;let t=e.getChainId?.();return t!=null?await t:null}var an=async(e,t)=>{try{if(await Kt(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 Kt(e)===t}catch(n){throw Xt(n)?new Error("User rejected the chain switch request"):new Error(`Please switch your wallet to the required network (Chain ID: ${t})`)}},Yt=async e=>{let{quote:t,signatureStep:n,userAddress:c,walletClient:l}=e;if(!l)throw new Error("Wallet client not available");if(n.type!=="SIGNATURE"||!n.signature?.typedData)throw new Error("Invalid signature step");try{let s=n.signature.typedData,a={...s.message};for(let o of["inputAmount","outputAmount","startTime","endTime"])a[o]!=null&&(a[o]=BigInt(a[o]));let v=s.domain;if(v.chainId!=null){let o=Number(v.chainId);await an(l,o)}let p=await on(l,{account:c,domain:v,types:s.types,primaryType:s.primaryType,message:a}),d=await fetch(`${Oe()}/submit-signature`,{method:"POST",headers:Pe(),body:JSON.stringify({quoteId:t.id,signatures:[p]})});if(!d.ok){let o=await d.json().catch(()=>({}));throw new Error(o?.message||`Submit failed: ${d.status}`)}return{quoteId:t.id,signature:p}}catch(s){throw Xt(s)?new Error("User rejected the signing request"):s instanceof Error&&s.message.includes("chain")?new Error("Chain switching failed. Please manually switch to the correct network."):s}};var Jt="vt_submitted_quotes";var mt=()=>{try{let e=localStorage.getItem(Jt);return e?JSON.parse(e):[]}catch{return[]}},Zt=e=>{try{localStorage.setItem(Jt,JSON.stringify(e))}catch{}},cn=e=>{let t=Date.now(),n=typeof e=="string"?new Date(e).getTime():e>9999999999?e:e*1e3;return t<n+3e4},ln=e=>mt().some(t=>t.quoteId===e),er=(e,t)=>ln(e)?{canSubmit:!1,reason:"Order already submitted"}:cn(t)?{canSubmit:!0}:{canSubmit:!1,reason:"Quote has expired"},tr=(e,t)=>{let n=typeof t=="string"?new Date(t).getTime():t,c=mt();c.push({quoteId:e,submittedAt:Date.now(),createdAt:n}),Zt(c)},rr=()=>{let e=mt(),t=Date.now(),n=300*1e3,c=e.filter(l=>t-l.submittedAt<n);c.length!==e.length&&Zt(c)};import{useMutation as un}from"@tanstack/react-query";import{waitForTransactionReceipt as dn}from"@wagmi/core";import{wethAbi as pn}from"abitype/abis";import{useConfig as fn}from"wagmi";function nr(){let e=fn();return un({mutationFn:async({chainId:t,accountAddress:n,amountRaw:c,writeContractAsync:l})=>{let s=q(t);if(!s)throw new Error(`No wrapping contract for chain ${t}`);let a=s.wrappedAsset.address,v=await l({abi:pn,functionName:"withdraw",address:a,account:n,args:[c],chainId:t});if((await dn(e,{hash:v,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Unwrap transaction did not get successful receipt");return{success:!0,hash:v}}})}import{useMutation as mn}from"@tanstack/react-query";import{waitForTransactionReceipt as gn}from"@wagmi/core";import{wethAbi as wn}from"abitype/abis";import{useConfig as hn}from"wagmi";function sr(){let e=hn();return mn({mutationFn:async({chainId:t,accountAddress:n,amountRaw:c,writeContractAsync:l})=>{let s=q(t);if(!s)throw new Error(`No wrapping contract for chain ${t}`);let a=s.wrappedAsset.address,v=await l({abi:wn,functionName:"deposit",address:a,account:n,value:c,chainId:t});if((await gn(e,{hash:v,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Wrap transaction did not get successful receipt");return{success:!0,hash:v}}})}import{useCallback as ge,useEffect as Ne,useRef as Ar,useState as ts}from"react";import{useChainId as rs}from"wagmi";function _e(e){try{let t=new URL(e).pathname.split("/"),n=t[t.length-1];return n&&n.startsWith("0x")?n:null}catch{return null}}import{useCallback as or,useRef as vn}from"react";function ar(){let{registerTransaction:e,enabled:t}=Gt(),n=vn(new Set),c=or((s,a)=>{!t||n.current.has(s)||(n.current.add(s),e(s,a))},[t,e]),l=or((s,a)=>{!t||n.current.has(s)||(n.current.add(s),e(s,a))},[t,e]);return{trackOrderTransaction:c,trackNativeTransaction:l,txTrackingEnabled:t}}import{useEffect as ir,useState as yn,useCallback as cr,useRef as gt}from"react";import{useAccount as bn,useChainId as xn,useSwitchChain as Cn}from"wagmi";import{jsx as xe,jsxs as wt}from"react/jsx-runtime";var Sn=15e3,Ye="chain",Tn=({needsChainSwitch:e,requiredChain:t,reviewState:n,goToNextStep:c,cancel:l})=>{let s=se(Ye,n),[a,v]=yn("pending"),p=gt(!1),d=gt(!1),o=gt(null),r=xn(),{switchChainAsync:y}=Cn(),{status:w,isReconnecting:u}=bn(),h=cr(()=>{o.current&&(clearTimeout(o.current),o.current=null)},[]),m=cr(async()=>{if(!(p.current||d.current||w!=="connected"||u)){p.current=!0,d.current=!0,v("pending"),o.current=setTimeout(()=>{p.current&&(v("error"),p.current=!1)},Sn);try{await y({chainId:t.chainId}),h(),v("success"),c(Ye,n)}catch{h(),v("error")}finally{p.current=!1}}},[y,w,u,t.chainId,c,n,h]);ir(()=>{p.current||d.current||n===Ye&&a==="pending"&&w==="connected"&&!u&&(e&&r!==t.chainId?m():(v("success"),c(Ye,n)))},[n,a,e,r,t.chainId,w,u,m,c]),ir(()=>()=>h(),[h]);let i=()=>{a==="error"&&(d.current=!1,v("pending"))},g=!s&&a==="error",x=!s&&(a==="pending"||a==="error"),f=g?"var(--widget-status-failed)":"var(--widget-primary)";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-sans font-medium transition duration-150 ${g?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${f} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${f} 20%, transparent)`,color:f,borderRadius:"var(--widget-radius)"},onClick:g?i:void 0,children:wt("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[xe(ye,{chain:t.chainId,size:"xs"}),xe("p",{className:"whitespace-nowrap",children:g?"Retry Switch":`Switch to ${t.name}`}),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:[!s&&a==="pending"&&xe(X,{size:"5"}),(s||a==="success")&&xe(Z,{className:"h-8 w-8"}),g&&xe(be,{className:"h-[12px] w-[12px]"})]})]})}),x&&xe("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-sans font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:l,children:"Cancel"})]})},lr=Tn;import{waitForTransactionReceipt as gr}from"@wagmi/core";import{useCallback as Je,useEffect as Ze,useState as kn,useRef as mr}from"react";import{erc20Abi as ht,decodeFunctionData as Nn,encodeFunctionData as En}from"viem";import{useAccount as In,useConfig as On,useSendTransaction as Pn,useSwitchChain as $n,useWalletClient as Un}from"wagmi";import{useEffect as ur,useRef as dr,useState as pr}from"react";import{jsx as An}from"react/jsx-runtime";var Rn=({startTime:e,onExpired:t})=>{let[n,c]=pr(30),[l,s]=pr(!1),a=dr(!1),v=dr(t);v.current=t,ur(()=>{a.current=!1},[e]),ur(()=>{let d=()=>{let r=Date.now(),w=(e>9999999999?e:e*1e3)+30*1e3,u=Math.max(0,w-r),h=Math.floor(u/1e3);if(h<=0){c(0),a.current||(a.current=!0,s(!0),v.current());return}c(h),s(!1)};if(l)return;d();let o=setInterval(d,1e3);return()=>clearInterval(o)},[e,l]);let p=d=>{let o=Math.floor(d/60),r=d%60;return`${o.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`};return l?null:An("span",{className:"text-xs font-sans",children:p(n)})},fr=Rn;import{jsx as me,jsxs as vt}from"react/jsx-runtime";function Mn(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 Ce="signingOrder";async function Ln(e,t,n,c,l){let s=e.transaction?.encoded,a=s?.to??e.to,v=s?.data??e.data,p=s?.value??e.value;if(!a)throw new Error('Transaction step missing "to" address');let d=s?.chainId,o=e.chainKey||l,r=d||(o?Qe(o):void 0);if(!r)throw new Error(`Unknown chain: ${o}`);let y=st()[r],w=await n({account:t,chain:y,to:a,data:v||"0x",value:BigInt(p||"0")});return await gr(c,{hash:w,chainId:r}),w}async function Dn(e,t,n,c,l){let s=e.transaction?.encoded,a=s?.to??e.to,v=s?.data??e.data;if(!(!a||!v))try{let{args:p}=Nn({abi:ht,data:v});if(!p||p.length<2)return;let d=p[0],o=e.chainKey||l.srcChainKey,r=s?.chainId||(o?Qe(o):void 0);if(!r)return;if(await Pt(r).readContract({address:a,abi:ht,functionName:"allowance",args:[t,d]})>0n){let u=En({abi:ht,functionName:"approve",args:[d,0n]}),h=st()[r],m=await n({account:t,chain:h,to:a,data:u,value:0n});await gr(c,{hash:m,chainId:r})}}catch{}}var Vn=({base:e,baseAmount:t,quote:n,quoteAmount:c,userAddress:l,reviewState:s,goToNextStep:a,cancel:v,isWrappingPair:p,isUnwrappingPair:d,restartSigningFlow:o,onSwapInitiated:r,onOrderSubmitted:y,onSwapSubmitted:w,startPolling:u,trackNativeTransaction:h})=>{let m=se(Ce,s),[i,g]=kn("idle"),x=mr(!1),f=mr(null),k=On(),{isReconnecting:O}=In(),{rfqQuote:C,stop:M,refresh:D}=ze(),{data:E}=Un({chainId:e.chainId}),{switchChain:I}=$n(),{sendTransactionAsync:P}=Pn(),$=C?._receivedAt??0,W=Je(()=>$?Date.now()>=$+30*1e3:!1,[$]),H=Je(async()=>{if(x.current||i!=="idle")return;if(!C?.id||!C?._receivedAt){g("error");return}if(!er(C.id,C._receivedAt).canSubmit){g("stale");return}x.current=!0;try{if(!E)throw new Error("Wallet client not available");rr();let R=C.userSteps??[],L;for(let N of R)if(N.type==="TRANSACTION"){g("submitting");let B=N.chainKey||C.srcChainKey,J=B?Qe(B):void 0;J&&E.chain?.id!==J&&(await I({chainId:J}),await new Promise(K=>setTimeout(K,800)));let we=(N.transaction?.encoded?.to??N.to)?.toLowerCase(),Se=C.srcToken?.address?.toLowerCase();we&&Se&&we===Se&&await Dn(N,l,P,k,C),L=await Ln(N,l,P,k,C.srcChainKey),h(L,N.description||`Tx on ${B}`)}else N.type==="SIGNATURE"&&(g("signing"),await Yt({quote:C,signatureStep:N,userAddress:l,walletClient:E}));tr(C.id,C._receivedAt),y?.(C.id),u(C.id,{baseToken:e,quoteToken:n}),r?.(),M(),g("success"),a(Ce,s),w?.(C.id)}catch(R){R instanceof Error&&Mn(R),g("error")}finally{x.current=!1}},[i,C,E,e,n,l,M,u,a,s,w,I,P,r,y,h,k]);Ze(()=>{if(s===Ce&&M(),m&&i!=="success"){g("success"),a(Ce,s);return}if(i==="success"){a(Ce,s);return}if(s===Ce&&i==="idle"&&!C?.id){g("refreshingQuote"),D();return}if(s===Ce&&i==="idle"&&E&&!x.current&&!O){let S=C?.id||null;S&&f.current!==S&&(f.current=S,H())}},[m,s,i,E,O,H,a,C?.id,D,M]),Ze(()=>{i==="refreshingQuote"&&C?.id&&g("idle")},[i,C?.id]),Ze(()=>{s!==Ce&&(f.current=null)},[s]),Ze(()=>{let S=setInterval(()=>{W()&&!x.current&&i!=="submitting"&&i!=="success"&&g("stale")},1e3);return()=>clearInterval(S)},[W,i]);let te=()=>{i==="error"&&!x.current&&(f.current=null,g("idle"))},U=Je(()=>{f.current=null,g("refreshingQuote"),D()},[D]),T=Je(()=>{o?o(!0):v()},[o,v]),_=()=>i==="error"?"Retry swap":i==="signing"?"Sign Swap Order":i==="submitting"?"Submitting...":i==="refreshingQuote"?"Refreshing Quote...":i==="stale"?"Quote Stale":"Sign & Submit",Q=!m&&(i==="error"||i==="stale"),G=Q?"var(--widget-status-failed)":"var(--widget-primary)";return vt("div",{className:"flex w-full flex-row justify-between space-x-3",children:[me("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${Q?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${G} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${G} 20%, transparent)`,color:G,borderRadius:"var(--widget-radius)"},onClick:!m&&i==="error"?te:i==="stale"?T:void 0,children:vt("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[me(re,{asset:e,size:"xs",noChain:!0}),me("p",{className:"whitespace-nowrap",children:_()}),me("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),$>0&&i!=="success"&&i!=="error"&&i!=="stale"&&me(fr,{startTime:$,onExpired:()=>g("stale")}),vt("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!m&&(i==="idle"||i==="signing"||i==="submitting"||i==="refreshingQuote")&&me(X,{size:"5"}),(m||i==="success")&&me(Z,{className:"h-8 w-8"}),!m&&(i==="error"||i==="stale")&&me(be,{className:"h-[12px] w-[12px]"})]})]})}),!m&&(i==="error"||i==="stale")&&me("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-sans 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:v,children:"Cancel"})]})},wr=Vn;import{useEffect as Wn}from"react";import{jsx as z,jsxs as yr}from"react/jsx-runtime";var Fn=()=>yr("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[z("path",{d:"M18 13V19C18 20.1046 17.1046 21 16 21H5C3.89543 21 3 20.1046 3 19V8C3 6.89543 3.89543 6 5 6H11",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),z("path",{d:"M15 3H21V9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),z("path",{d:"M10 14L21 3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),_n="trackingTx",hr={pending:{icon:z(X,{size:"5"}),buttonText:"Trade Pending",showNewSwap:!1,statusVar:"var(--widget-primary)",clickable:!1},received:{icon:z(X,{size:"5"}),buttonText:"Trade Received",showNewSwap:!1,statusVar:"var(--widget-primary)",clickable:!1},completed:{icon:z(Z,{className:"h-5 w-5"}),buttonText:"View Transaction",showNewSwap:!1,statusVar:"var(--widget-status-completed)",clickable:!0},failed:{icon:z(Fe,{}),buttonText:"Retry Swap",showNewSwap:!0,statusVar:"var(--widget-status-failed)",clickable:!0},cancelled:{icon:z(Fe,{}),buttonText:"View Transaction",showNewSwap:!1,statusVar:"var(--widget-status-failed)",clickable:!0}},Bn=({orderHash:e,base:t,quote:n,baseAmount:c,quoteAmount:l,reviewState:s,onNewSwap:a,onRetry:v,status:p})=>{let d=se(_n,s),o=hr[p]||hr.pending,r=ee(u=>u.explorerUrl);Wn(()=>{if(p==="completed"){let u=setTimeout(a,15e3);return()=>clearTimeout(u)}},[p,a]);let y=()=>{p==="failed"?v():(p==="completed"||p==="cancelled")&&r&&window.open(r,"_blank","noopener,noreferrer")},w=o.statusVar;return z("div",{className:"flex flex-row justify-between space-x-3 w-full px-4",children:z("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${o.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:o.clickable?y:void 0,children:yr("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[z("div",{className:"flex h-6 w-6 items-center justify-center rounded-full overflow-hidden shrink-0",children:o.icon}),z("p",{className:"whitespace-nowrap",children:o.buttonText}),z("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),o.clickable&&z("div",{className:"flex h-6 w-6 items-center justify-center",children:p==="failed"?z(Mt,{}):z(Fn,{})})]})})})},vr=Bn;import{useCallback as br,useEffect as xr,useState as qn,useRef as yt}from"react";import{parseUnits as Qn}from"viem";import{useAccount as zn,useWriteContract as jn}from"wagmi";import{jsx as Ae,jsxs as bt}from"react/jsx-runtime";var Hn=15e3,et="unwrapping",Gn=({needsToUnwrap:e,amount:t,chainId:n,token:c,reviewState:l,setReviewState:s,goToNextStep:a,cancel:v,delayedClose:p})=>{let d=se(et,l),[o,r]=qn("idle"),y=nr(),{writeContractAsync:w}=jn(),{address:u}=oe(),h=Me(),m=yt(!1),i=yt(!1),g=yt(null),{status:x}=zn(),f=br(()=>{g.current&&(clearTimeout(g.current),g.current=null)},[]),k=br(async()=>{if(!(m.current||i.current||!u||x!=="connected")){m.current=!0,i.current=!0,r("pending"),g.current=setTimeout(()=>{m.current&&(r("error"),m.current=!1)},Hn);try{let E=q(n);if(!E)throw new Error(`No config for chain ${n}`);let I=E.wrappedAsset.decimals??E.nativeAsset.decimals,P=Qn(t.toString(),I);await y.mutateAsync({chainId:n,accountAddress:u,amountRaw:P,writeContractAsync:w});let $={symbol:E.nativeAsset.symbol,name:E.nativeAsset.name,address:qe,decimals:E.nativeAsset.decimals,chainId:n},W={symbol:E.wrappedAsset.symbol,name:E.wrappedAsset.name,address:E.wrappedAsset.address,decimals:E.wrappedAsset.decimals,chainId:n};h({type:"unwrap",tokens:[{asset:$,userAddress:u},{asset:W,userAddress:u}]}),f(),r("success"),a(et,l),await p()}catch{f(),r("error")}finally{m.current=!1}}},[u,x,n,t,y,w,h,a,l,p,f]);xr(()=>{m.current||i.current||l===et&&o==="idle"&&x==="connected"&&(e?k():(r("success"),a(et,l)))},[l,o,e,x,k,a]),xr(()=>()=>f(),[f]);let O=()=>{o==="error"&&(i.current=!1,r("idle"))},C=!d&&o==="error",M=!d&&(o==="pending"||o==="idle"||o==="error"),D=C?"var(--widget-status-failed)":"var(--widget-primary)";return bt("div",{className:"flex w-full flex-row justify-between space-x-3",children:[Ae("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${C?"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:C?O:void 0,children:bt("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[Ae("p",{className:"whitespace-nowrap",children:C?"Retry Unwrap":c?`Unwrap ${c.symbol}`:"Unwrap Native Token"}),Ae("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),bt("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!d&&(o==="pending"||o==="idle")&&Ae(X,{size:"5"}),(d||o==="success")&&Ae(Z,{className:"h-8 w-8"}),C&&Ae(be,{className:"h-[12px] w-[12px]"})]})]})}),M&&Ae("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-sans 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:v,children:"Cancel"})]})},Cr=Gn;import{useCallback as Sr,useEffect as Tr,useState as Kn,useRef as xt}from"react";import{parseUnits as Xn}from"viem";import{useAccount as Yn,useWriteContract as Jn}from"wagmi";import{jsx as ke,jsxs as Ct}from"react/jsx-runtime";var Zn=15e3,tt="wrapping",es=({needsToWrap:e,amount:t,chainId:n,token:c,reviewState:l,setReviewState:s,goToNextStep:a,cancel:v,delayedClose:p,isWrappingPair:d})=>{let o=se(tt,l),[r,y]=Kn("idle"),w=sr(),{writeContractAsync:u}=Jn(),{address:h}=oe(),m=Me(),i=xt(!1),g=xt(!1),x=xt(null),{status:f}=Yn(),k=Sr(()=>{x.current&&(clearTimeout(x.current),x.current=null)},[]),O=Sr(async()=>{if(!(i.current||g.current||!h||f!=="connected")){i.current=!0,g.current=!0,y("pending"),x.current=setTimeout(()=>{i.current&&(y("error"),i.current=!1)},Zn);try{let I=q(n);if(!I)throw new Error(`No config for chain ${n}`);let P=Xn(t.toString(),I.nativeAsset.decimals);await w.mutateAsync({chainId:n,accountAddress:h,amountRaw:P,writeContractAsync:u});let $={symbol:I.nativeAsset.symbol,name:I.nativeAsset.name,address:qe,decimals:I.nativeAsset.decimals,chainId:n},W={symbol:I.wrappedAsset.symbol,name:I.wrappedAsset.name,address:I.wrappedAsset.address,decimals:I.wrappedAsset.decimals,chainId:n};m({type:"wrap",tokens:[{asset:$,userAddress:h},{asset:W,userAddress:h}]}),k(),y("success"),a(tt,l),d&&await p()}catch{k(),y("error")}finally{i.current=!1}}},[h,f,n,t,w,u,m,a,l,p,d,k]);Tr(()=>{i.current||g.current||l===tt&&r==="idle"&&f==="connected"&&(e?O():(y("success"),a(tt,l)))},[l,r,e,f,O,a]),Tr(()=>()=>k(),[k]);let C=()=>{r==="error"&&(g.current=!1,y("idle"))},M=!o&&r==="error",D=!o&&(r==="pending"||r==="idle"||r==="error"),E=M?"var(--widget-status-failed)":"var(--widget-primary)";return Ct("div",{className:"flex w-full flex-row justify-between space-x-3",children:[ke("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${M?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${E} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${E} 20%, transparent)`,color:E,borderRadius:"var(--widget-radius)"},onClick:M?C:void 0,children:Ct("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[ke("p",{className:"whitespace-nowrap",children:M?"Retry Wrap":c?`Wrap ${c.symbol}`:"Wrap Native Token"}),ke("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),Ct("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!o&&(r==="pending"||r==="idle")&&ke(X,{size:"5"}),(o||r==="success")&&ke(Z,{className:"h-8 w-8"}),M&&ke(be,{className:"h-[12px] w-[12px]"})]})]})}),D&&ke("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-sans 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:v,children:"Cancel"})]})},Rr=es;import{jsx as j,jsxs as ns}from"react/jsx-runtime";var Ha=({base:e,baseAmount:t,quote:n,quoteAmount:c,userAddress:l,isWrappingPair:s,isUnwrappingPair:a,isBaseGasToken:v,isQuoteGasToken:p,reviewActionProps:d,reviewState:o,setReviewState:r,trackedOrderHash:y,setTrackedOrderHash:w,txStatus:u,onSwapSubmitted:h,onSwapComplete:m,onSwapInitiated:i,onOrderSubmitted:g,onStaleQuoteRestart:x,setExitHandler:f,setRetryHandler:k})=>{let{rfqQuote:O,status:C,liquidityError:M,routingError:D,sizeCapError:E,stop:I,clear:P}=ze(),{clearForm:$}=Ue(),W=rs(),{swapButtonVariant:H,widgetType:te}=Ie(),U=te==="compact",{trackOrderTransaction:T,trackNativeTransaction:_}=ar(),{startPolling:Q}=Ht((F,he,ve)=>{if(ee.getState().setTxStatus(he),ve&&ee.getState().setExplorerUrl(ve),he==="completed"&&(T(F,`Swap ${e.symbol} \u2192 ${n.symbol}`),ve)){let rt=_e(ve);rt&&fetch(`https://api.aori.io/data/details/${rt}`).then(nt=>nt.json()).then(nt=>m?.({quoteId:F,aoriOrderHash:rt,explorerUrl:ve,details:nt})).catch(()=>{})}}),[G,S]=ts(!1),R=Ar(!1),L=Ar(null),N=s,B=a,J=!s&&!a,we=W!==e?.chainId&&(N||B||J),Se=q(e.chainId),K={chainId:e.chainId,name:Se?.displayName??`Chain ${e.chainId}`},ie=ge((F,he)=>{if(he!==F)return;if(F==="chain"){if(N){r("wrapping");return}if(B){r("unwrapping");return}r("signingOrder");return}if(F==="signingOrder"){r("trackingTx");return}if(F==="wrapping"){if(!s){r("signingOrder");return}r("wrapSuccess");return}if(F==="unwrapping"){r("wrapSuccess");return}let ve=Et(F);ve&&r(ve)},[r,s,N,B,J]),ne=ge(()=>we?"chain":N?"wrapping":B?"unwrapping":J?"signingOrder":null,[we,N,B,J]),ce=ge(()=>{r(null),$()},[$,r]),le=ge(async()=>{r("wrapSuccess");for(let F=0;F<3;F++)await ot(700);ce()},[ce,r]),ue=ge(async()=>{P(),r("cancelled");for(let F=0;F<3;F++)await ot(500);ce()},[P,ce,r]),Te=ge(()=>{y&&(ee.getState().stopTracking(),r(null),w(null),$())},[y,r,w,$]),de=ge(()=>{r(null),w(null),R.current=!0,x?.()},[r,w,x]),Ve=ge(()=>{d&&r(ne())},[ne,d,r]),kt=ge((F=!1)=>{F?(R.current=!0,r(null),x?.()):(r(null),L.current=setTimeout(()=>{d&&(r(ne()),S(!1))},100))},[r,d,ne,x]);Ne(()=>{o!==null&&I()},[o,I]),Ne(()=>{o!==null&&G&&S(!1)},[o,G]),Ne(()=>{f?.(Te)},[f,Te]),Ne(()=>(ee.getState().setExitHandler(Te),()=>ee.getState().setExitHandler(null)),[Te]),Ne(()=>{k?.(de)},[k,de]),Ne(()=>()=>{L.current&&clearTimeout(L.current)},[]),Ne(()=>{R.current&&C==="fresh"&&O?.id&&(R.current=!1,r("signingOrder"))},[C,O?.id,r]);let Ee=F=>{if(!F)return{backgroundColor:H==="default"?"var(--widget-muted)":"transparent",color:"var(--widget-muted-foreground)",border:H!=="default"?"1px solid var(--widget-border)":"none",borderRadius:"var(--widget-radius)"};switch(H){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)"}}},Be=`w-full ${U?"py-2":"py-3"} text-sm font-sans font-medium transition-colors cursor-pointer mt-1`;if(o===null&&!s&&!a){if(G)return j("button",{className:Be,disabled:!0,style:{...Ee(!1),opacity:.6,cursor:"not-allowed"},children:"Getting fresh quote..."});let F=()=>M?"Insufficient Liquidity":D?"Route Not Available":E?"Size Cap Exceeded":!O&&C==="polling"?"Getting Quote...":O?"Swap":"Enter Amount",he=!!d;return j("button",{onClick:he?Ve:void 0,disabled:!he,className:`${Be} disabled:opacity-40 disabled:cursor-not-allowed`,style:Ee(he),children:F()})}return o===null&&a?j("button",{onClick:d?Ve:void 0,disabled:!d,className:`${Be} disabled:opacity-40 disabled:cursor-not-allowed`,style:Ee(!!d),children:"Unwrap"}):o===null&&s?j("button",{onClick:d?Ve:void 0,disabled:!d,className:`${Be} disabled:opacity-40 disabled:cursor-not-allowed`,style:Ee(!!d),children:"Wrap"}):o==="success"?j("div",{className:"flex flex-col gap-2 w-full",children:j("button",{className:`w-full ${U?"py-2":"py-3"} text-sm font-sans font-medium cursor-default`,style:{backgroundColor:"color-mix(in srgb, var(--widget-status-completed) 15%, transparent)",color:"var(--widget-status-completed)",border:"1px solid color-mix(in srgb, var(--widget-status-completed) 20%, transparent)",borderRadius:"var(--widget-radius)"},children:"Order Placed"})}):o==="wrapSuccess"?j("div",{className:"flex flex-col gap-2 w-full",children:j("button",{className:`w-full ${U?"py-2":"py-3"} text-sm font-sans font-medium cursor-default`,style:{backgroundColor:"color-mix(in srgb, var(--widget-status-completed) 15%, transparent)",color:"var(--widget-status-completed)",border:"1px solid color-mix(in srgb, var(--widget-status-completed) 20%, transparent)",borderRadius:"var(--widget-radius)"},children:s?"Wrapped Successfully":"Unwrapped Successfully"})}):o==="cancelled"?j("div",{className:"flex flex-col gap-2 w-full",children:j("button",{onClick:ce,className:`w-full ${U?"py-2":"py-3"} text-sm font-sans 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"})}):ns("div",{className:"flex w-full",children:[o==="chain"&&we&&j(lr,{requiredChain:K,needsChainSwitch:we&&W!==e.chainId,reviewState:o,goToNextStep:ie,cancel:ue}),o==="wrapping"&&N&&j(Rr,{needsToWrap:N,amount:t,chainId:e.chainId,token:e,reviewState:o,setReviewState:r,goToNextStep:ie,cancel:ue,delayedClose:le,isWrappingPair:s}),o==="unwrapping"&&B&&j(Cr,{needsToUnwrap:B,amount:t,chainId:e.chainId,token:e,reviewState:o,setReviewState:r,goToNextStep:ie,cancel:ue,delayedClose:le}),o==="signingOrder"&&J&&j(wr,{base:e,baseAmount:t,quote:n,quoteAmount:c,userAddress:l,reviewState:o,goToNextStep:ie,cancel:ue,restartSigningFlow:kt,onSwapInitiated:i,onOrderSubmitted:g,isWrappingPair:s,isUnwrappingPair:a,onSwapSubmitted:h,startPolling:Q,trackNativeTransaction:_}),o==="trackingTx"&&y&&j(vr,{orderHash:y,base:e,quote:n,baseAmount:t,quoteAmount:c,reviewState:o,status:u,onNewSwap:Te,onRetry:de}),o&&!["chain","wrapping","unwrapping","approval","signingOrder","trackingTx","success","wrapSuccess","cancelled"].includes(o)&&j("button",{disabled:!0,className:`w-full ${U?"py-2":"py-3"} text-sm font-sans font-medium`,style:{backgroundColor:"var(--widget-muted)",color:"var(--widget-muted-foreground)",borderRadius:"var(--widget-radius)"},children:"Processing..."})]})};import{useState as St,useCallback as ss,useRef as Tt,useEffect as Rt}from"react";import{useShallow as os}from"zustand/react/shallow";import{jsx as b,jsxs as A}from"react/jsx-runtime";var kr={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)"},as=({status:e})=>{let t=kr[e]??kr.pending;switch(e){case"completed":return b(Z,{className:"h-6 w-6"});case"failed":case"cancelled":return b(Fe,{className:"h-6 w-6"});default:return b(X,{size:"5",color:t})}};function is(e){if(e===0)return"0";let t=Math.abs(e);return t>=1e4?e.toFixed(0):t>=1e3?e.toFixed(1):t>=100?e.toFixed(2):t>=1?e.toFixed(4):t>=.01?e.toFixed(6):e.toExponential(3)}function Nr(e){let t=e.length;return t<=4?48:t<=6?40:t<=8?34:28}var At=()=>A("svg",{className:"w-3 h-3 shrink-0",style:{color:"var(--widget-secondary-foreground)"},viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b("path",{d:"M18 13V19C18 20.1046 17.1046 21 16 21H5C3.89543 21 3 20.1046 3 19V8C3 6.89543 3.89543 6 5 6H11",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),b("path",{d:"M15 3H21V9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),b("path",{d:"M10 14L21 3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),cs=()=>A("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 195 321",fill:"var(--widget-secondary-foreground)",xmlns:"http://www.w3.org/2000/svg",children:[b("path",{fillRule:"evenodd",d:"M195,189C195,207.02,195,225.04,194.7,243.21C193.68,244.78,192.9,246.17,192.25,247.63C189.71,253.38,187.74,259.46,184.6,264.86C169.44,290.97,147.86,309.46,118.54,318.86C116.44,319.55,114.72,320.27,113,321C97.65,321,82.29,321,66.36,320.66C64.21,319.86,62.64,319.4,60.77,318.73C34.51,310.12,15.56,293.82,4.22,268.85C3.68,267.66,2.1,266.94,1,266C1,242.31,1,218.62,1.29,194.79C2.84,192.16,4.11,189.7,5.34,187.22C18.42,160.94,39.89,144.07,66.64,133.63C76.92,129.62,87.87,127.33,98.67,124.2C97.79,123.24,96.8,121.93,95.59,120.86C85.84,112.3,75.95,103.89,66.3,95.21C55.93,85.86,45.02,76.96,35.71,66.63C21.14,50.5,20.04,23.08,45.41,9.57C50.08,7.08,55.12,5.26,59.93,3.03C60.76,2.64,61.32,1.69,62,1C86.69,1,111.38,1,136.23,1.32C138.04,2.32,139.67,3.01,141.32,3.67C147.64,6.19,154.12,8.39,160.26,11.32C166.83,14.45,172.19,19.18,175.44,25.95C179.39,34.19,178.09,43.36,172.05,49.56C165.75,56.03,157.21,57.8,148.78,52.89C142.4,49.17,136.86,43.96,131.1,39.23C122.63,32.28,115.05,23.88,105.74,18.38C87.78,7.76,68.84,9.07,51.16,19.53C38.68,26.91,36.37,41.4,45.53,52.71C50.38,58.69,56.45,64,62.83,68.36C87.15,84.99,111.86,101.05,136.34,117.44C162.56,135,183.88,156.57,193.26,187.79C193.42,188.32,194.4,188.6,195,189ZM77.06,146.49C61.39,155.71,51.27,169.26,45.93,186.5C39.48,207.32,39.44,228.5,42.93,249.76C45.84,267.48,53.16,282.95,66.59,295.39C83.82,311.34,108.85,312.86,127.37,298.41C138.98,289.35,146.05,277.03,149.48,263.04C161.53,213.92,148.4,171.97,112.16,137.05C111.13,136.06,108.71,135.6,107.31,136.05C97.38,139.22,87.54,142.7,77.06,146.49Z"}),b("path",{d:"M118.83,199C121.61,197.69,122.77,198.41,122.77,201.27C122.71,217.43,122.78,233.58,122.65,249.73C122.65,250.83,121.43,251.92,120.77,253.01C119.97,252.05,118.63,251.17,118.45,250.1C116.32,237.7,113.36,235.12,100.61,235.02C98.12,235,95.62,234.98,93.12,235.01C81.26,235.16,77.72,238.3,75.94,249.84C75.74,251.15,74.39,252.28,73.57,253.49C73.11,253.23,72.64,252.98,72.17,252.73C72.17,234.81,72.17,216.88,72.17,198.96C72.49,198.62,72.81,198.28,73.13,197.93C74.09,198.95,75.72,199.85,75.92,201C78.13,213.8,80.95,216.26,94.05,216.3C97.38,216.31,100.72,216.44,104.04,216.27C113.28,215.79,117.15,212.05,118.22,202.81C118.35,201.65,118.47,200.49,118.83,199Z"})]}),ls=({orderHash:e,base:t,quote:n,baseAmount:c,quoteAmount:l,status:s})=>{let[a,v]=St(!1),[p,d]=St(!0),o=Tt(null),r=Tt(Date.now()),[y,w]=St(null),u=Tt(null),{isRecipientInputOpen:h,recipient:m,explorerUrl:i}=ee(os(T=>({isRecipientInputOpen:T.isRecipientInputOpen,recipient:T.recipient,explorerUrl:T.explorerUrl})));Rt(()=>{s==="received"&&(o.current=Date.now())},[s]),Rt(()=>{if(s==="completed"&&!y){let T=o.current||r.current;w((Date.now()-T)/1e3)}},[s,y]),Rt(()=>()=>{u.current&&clearTimeout(u.current)},[]);let g=ss(()=>{if(!navigator.clipboard?.writeText)return;let T=i?_e(i)??e:e;navigator.clipboard.writeText(T).then(()=>{v(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>v(!1),2e3)}).catch(()=>{})},[e,i]),x=$e(c),f=$e(l),k=s==="completed"||s==="failed"||s==="cancelled",O=!k,C=c&&l?c/l:0,M=q(t.chainId),D=q(n.chainId),E=M?.displayName??`Chain ${t.chainId}`,I=D?.displayName??`Chain ${n.chainId}`,P=t.chainId!==n.chainId,$=M?.estimatedTimeMs??0,W=D?.estimatedTimeMs??0,H=(P?$+W:$)/1e3,te=i?_e(i)??e:e,U=`${te.slice(0,6)} \u2026 ${te.slice(-4)}`;return A("div",{className:"relative w-full flex flex-col",children:[A("div",{className:"mx-4 mt-2",style:{backgroundColor:"var(--widget-secondary)"},children:[b("div",{className:"p-5",children:A("div",{className:"flex items-center justify-between",children:[A("div",{children:[A("div",{className:"flex items-center gap-3 mb-3",children:[b(re,{asset:t,size:"md",noChain:!0}),A("div",{children:[b("p",{className:"text-xl font-thin uppercase",style:{color:"var(--widget-foreground)"},children:t.symbol}),b("p",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:t.name})]})]}),A("div",{className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1",style:{backgroundColor:"color-mix(in srgb, var(--widget-muted-foreground) 20%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-muted-foreground) 30%, transparent)"},children:[b(ye,{chain:t.chainId,size:"xs"}),b("span",{className:"text-xs pt-0.5",style:{color:"var(--widget-muted-foreground)"},children:E})]})]}),A("div",{className:"text-right",children:[b("p",{className:"font-thin tracking-tight font-sans",style:{color:"var(--widget-foreground)",fontSize:`${Nr(x)}px`,transition:"font-size 0.1s ease-out"},children:x}),t.price&&A("p",{className:"text-xs mt-1 font-sans",style:{color:"var(--widget-muted-foreground)"},children:["$",(t.price*c).toFixed(2)]})]})]})}),A("div",{className:"relative",children:[b("div",{style:{borderTop:"1px solid var(--widget-border)"}}),b("div",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",children:b("div",{className:"w-10 h-10 rounded-full flex items-center justify-center",style:{backgroundColor:"var(--widget-secondary)",border:"1px solid var(--widget-border)"},children:b(as,{status:s})})})]}),b("div",{className:"p-5",children:A("div",{className:"flex items-center justify-between",children:[A("div",{children:[A("div",{className:"flex items-center gap-3 mb-3",children:[b(re,{asset:n,size:"md",noChain:!0}),A("div",{children:[b("p",{className:"text-xl font-thin uppercase",style:{color:"var(--widget-foreground)"},children:n.symbol}),b("p",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:n.name})]})]}),A("div",{className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1",style:{backgroundColor:"color-mix(in srgb, var(--widget-muted-foreground) 20%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-muted-foreground) 30%, transparent)"},children:[b(ye,{chain:n.chainId,size:"xs"}),b("span",{className:"text-xs pt-0.5",style:{color:"var(--widget-muted-foreground)"},children:I})]})]}),A("div",{className:"text-right",children:[b("p",{className:"font-thin tracking-tight font-sans",style:{color:"var(--widget-foreground)",fontSize:`${Nr(f)}px`,transition:"font-size 0.1s ease-out"},children:f}),n.price&&A("p",{className:"text-xs mt-1 font-sans",style:{color:"var(--widget-muted-foreground)"},children:["$",(n.price*l).toFixed(2)]})]})]})})]}),h&&m&&b("div",{className:"mx-4 mt-2 px-5 pb-2",children:A("div",{className:"flex items-center gap-2 p-2 rounded-full",style:{backgroundColor:"var(--widget-secondary)"},children:[b("div",{className:"flex h-5 w-5 items-center justify-center overflow-hidden rounded-full",style:{backgroundColor:"var(--widget-muted)"},children:b("span",{className:"text-2xs",children:"\u{1F464}"})}),b("span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:"To:"}),A("span",{className:"text-xs font-sans",style:{color:"var(--widget-foreground)"},children:[m.slice(0,6),"...",m.slice(-4)]})]})}),A("div",{className:"px-4 mt-4",style:{borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"},children:[b("div",{className:"relative box-border flex flex-row h-8 w-full items-center cursor-pointer",role:"button",tabIndex:0,onClick:()=>d(!p),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),d(!p))},children:b("div",{className:"flex h-full items-center w-full overflow-hidden",style:{color:"var(--widget-muted-foreground)"},children:A("div",{className:"translate-y-px font-sans flex w-full flex-row items-center justify-between",children:[A("div",{className:"flex flex-row items-center gap-2 whitespace-nowrap",children:[A("div",{className:"flex flex-row items-center gap-1",children:[b(re,{asset:n,size:"3xs",noChain:!0,className:"mb-0.5"}),A("span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:["1 ",n.symbol]})]}),b("span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:"="}),A("div",{className:"flex flex-row items-center gap-1",children:[b(re,{asset:t,size:"3xs",noChain:!0,className:"mb-0.5"}),A("span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:[is(C)," ",t.symbol]})]}),b("span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:t.price?`\u2248 $${(t.price*C).toFixed(2)}`:""})]}),b("span",{className:"text-xs ml-2 transition-transform duration-200 shrink-0",style:{color:"var(--widget-muted-foreground)",transform:p?"rotate(180deg)":"rotate(0deg)",display:"inline-block"},children:"\u25BE"})]})})}),b("div",{className:"overflow-hidden transition-all duration-200",style:{maxHeight:p?"200px":"0px",opacity:p?1:0},children:A("div",{className:"flex flex-col gap-1 pb-1.5 font-sans",children:[A("div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[b("span",{children:"USD Value"}),A("span",{style:{color:"var(--widget-secondary-foreground)"},children:["$",t.price?(t.price*c).toFixed(2):"\u2014"]})]}),A("div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[b("span",{style:{color:"var(--widget-muted-foreground)"},children:"Order Type"}),b("span",{style:{color:"var(--widget-secondary-foreground)"},children:"RFQ (Limit)"})]}),A("div",{className:"flex justify-between items-center text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[b("span",{children:"Transaction"}),i?A("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 transition-colors hover:opacity-80",style:{color:"var(--widget-secondary-foreground)"},children:[b("span",{children:a?"Copied!":U}),b(At,{})]}):A("button",{type:"button",onClick:g,className:"flex items-center gap-1 cursor-pointer transition-colors",style:{color:"var(--widget-secondary-foreground)"},children:[b("span",{style:{color:"var(--widget-secondary-foreground)"},children:a?"Copied!":U}),b(At,{})]})]}),A("div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[b("span",{children:k?"Speed":"Est. Time"}),b("span",{style:{color:"var(--widget-secondary-foreground)"},children:y?`${y.toFixed(2)}s`:H>0?`~${H}s`:"\u2014"})]}),A("div",{className:"flex justify-between items-center text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[b("span",{children:"Route"}),A("a",{href:"https://www.aori.io",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 transition-colors hover:opacity-80",style:{color:"var(--widget-secondary-foreground)"},children:[b(cs,{}),"Aori",b(At,{})]})]})]})})]})]})},ri=ls;export{Ur as a,Me as b,gs as c,Ss as d,ze as e,Hr as f,ks as g,$s as h,Ws as i,js as j,Ks as k,zt as l,Ht as m,Gt as n,an as o,Yt as p,cn as q,er as r,tr as s,rr as t,nr as u,sr as v,Ha as w,ri as x};
|