@aori/mega-swap-widget 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +9 -1
  2. package/dist/AssetSelectionMenu-4E576X3D.cjs +2 -0
  3. package/dist/AssetSelectionMenu-ZFY7XFRX.js +2 -0
  4. package/dist/ChainSelectionMenu-SKXLHK3S.js +2 -0
  5. package/dist/ChainSelectionMenu-VU3SIBVL.cjs +2 -0
  6. package/dist/{SwapFormHorizontal-XMZKEAIL.js → SwapFormHorizontal-GI4X7ISS.js} +1 -1
  7. package/dist/{SwapFormHorizontal-ACRBI6GC.cjs → SwapFormHorizontal-V557YBX2.cjs} +1 -1
  8. package/dist/{SwapFormSplit-SOC2XMBW.js → SwapFormSplit-52RBMJIO.js} +1 -1
  9. package/dist/{SwapFormSplit-XHAGOXQX.cjs → SwapFormSplit-PQCS3BPT.cjs} +1 -1
  10. package/dist/{WidgetWalletPanel-KZFLFLUD.js → WidgetWalletPanel-XYV3YL4I.js} +1 -1
  11. package/dist/{WidgetWalletPanel-FQDNFYFL.cjs → WidgetWalletPanel-YBMN5KZH.cjs} +1 -1
  12. package/dist/{chunk-F7IECVJU.js → chunk-4BQRVCQR.js} +1 -1
  13. package/dist/{chunk-Z2BLIAFE.js → chunk-4LJJMEOG.js} +1 -1
  14. package/dist/{chunk-JSWDMAZQ.js → chunk-726CI6GC.js} +1 -1
  15. package/dist/{chunk-XUTR7YYC.cjs → chunk-DUIRZSBV.cjs} +1 -1
  16. package/dist/{chunk-CHDFHEPH.js → chunk-EW2OR6CJ.js} +1 -1
  17. package/dist/{chunk-TWJY6EY4.js → chunk-FDQKBTWP.js} +1 -1
  18. package/dist/{chunk-E44WNKS4.cjs → chunk-HTWUZKYO.cjs} +1 -1
  19. package/dist/{chunk-BX3KCZRT.cjs → chunk-LXEKOQAG.cjs} +1 -1
  20. package/dist/{chunk-NQ4QSGGF.cjs → chunk-MCT3UZTP.cjs} +1 -1
  21. package/dist/{chunk-537OMWA3.cjs → chunk-UZWGYG2S.cjs} +1 -1
  22. package/dist/{chunk-4XEJKRRM.js → chunk-XYF2YBR3.js} +1 -1
  23. package/dist/{chunk-C3X6NJIB.cjs → chunk-XZRXVBSB.cjs} +1 -1
  24. package/dist/index.cjs +2 -2
  25. package/dist/index.js +1 -1
  26. package/package.json +1 -1
  27. package/dist/AssetSelectionMenu-INISSBWT.js +0 -2
  28. package/dist/AssetSelectionMenu-ZT2PDBHV.cjs +0 -2
  29. package/dist/ChainSelectionMenu-N65VG257.js +0 -2
  30. package/dist/ChainSelectionMenu-URYJUECJ.cjs +0 -2
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import{a as Je}from"./chunk-F7IECVJU.js";import{a as mt,b as ht,c as Pe,d as Ie,e as ue,f as Ze,g as ae,h as oe,i as ne,j as Xe,k as xt,l as kt,m as St,n as Ct,o as Tt,p as Rt,q as Wt,r as Nt,s as At,t as Pt,u as It,v as et,w as tt}from"./chunk-4XEJKRRM.js";import"./chunk-OPN7WCJR.js";import{a as vt,b as bt,c as n,d as yt,e as Oe,f as fe}from"./chunk-JSWDMAZQ.js";import{A as Ye,F as Te,N as Ge,a as Ue,b as ge,d as je,f as $e,i as De,l as Qe,n as _e,p as Ke}from"./chunk-CHDFHEPH.js";import{a as _}from"./chunk-46H44R7V.js";import"./chunk-73CB2I7U.js";import Xt,{useMemo as gt}from"react";import{Suspense as de,lazy as pe,useCallback as me,useEffect as Re,useRef as qe,useState as nt}from"react";import{useShallow as Ut}from"zustand/react/shallow";import{useCallback as se,useEffect as Ot,useMemo as zt,useRef as Mt,useState as it}from"react";import{useShallow as Bt}from"zustand/react/shallow";import{Fragment as ze,jsx as l,jsxs as A}from"react/jsx-runtime";var qt=({onSwapComplete:e,onSwapInitiated:t})=>{let{web3ConnectionType:c,hasConnectHandler:a,lockBase:s,lockQuote:b,disableInverting:k,tokenDisplay:N,tokenBadgeOrientation:W,widgetType:w}=ge(),S=N==="pill"||N==="ghost",C=w==="compact",I=C?"px-4 pt-3 pb-1":"px-4 pt-4 pb-2",O=C?"px-4 pt-4 pb-1":"px-4 pt-6 pb-2",{baseToken:r,quoteToken:i,baseAmount:d,quoteAmount:T,isBaseGasToken:X,isQuoteGasToken:L,isWrappingPair:u,isUnwrappingPair:g,baseBalance:m,quoteBalance:Y,setBaseAmount:R,setQuoteAmount:h,swapTokens:U,clearForm:M}=fe(),{rfqQuote:j,status:G,handleInputChange:H,ensureForParams:B,stop:z,clear:q,refresh:v}=ue(),{address:x}=_(),{openConnectModal:Z}=ae(),{isRecipientInputOpen:E,txStatus:$}=n(Bt(o=>({isRecipientInputOpen:o.isRecipientInputOpen,txStatus:o.txStatus}))),[D,ee]=it(null),[Q,te]=it(null),ie=Mt(!1),y=!1,J=zt(()=>!r||!i||typeof d!="number"||!T||!x||parseFloat(m.formatted)<d?null:{base:r,quote:i,baseAmount:d,quoteAmount:T,userAddress:x},[r,i,d,T,x,m.formatted]),ve=se(o=>{te(o),n.getState().startTracking(o)},[]),be=se(()=>{ie.current=!0,v()},[v]);Ot(()=>{if(D===null&&!(!r||!i)){if(!d||d<=0){H({amount:null,inputToken:r,outputToken:i,setOutputAmount:h});return}if(u||g){h(d);return}H({amount:d,inputToken:r,outputToken:i,setOutputAmount:h})}},[D,d,r,i,u,g,H,h]);let le=se(()=>{n.getState().setView("baseSelection")},[]),ye=se(()=>{n.getState().setView("quoteSelection")},[]),xe=se(()=>{U(),h(null)},[U,h]),ce=se(()=>{if(!m.formatted||!r||!i)return;let o=parseFloat(m.formatted);if(!o||o<=0)return;let V=o*.9999999999;u||g?(R(V),h(V),q()):(R(V),h(null),B({inputToken:r,outputToken:i,inputAmount:V.toString(),setOutputAmount:re=>h(re)}))},[m.formatted,r,i,u,g,R,h,q,B]),Ne=se(()=>{q(),M()},[q,M]),we=m.formatted?parseFloat(m.formatted):null,ke=!!(d||T),Se=r?.price&&d?`$${(r.price*d).toFixed(2)}`:"$0.00",Ae=i?.price&&T?`$${(i.price*T).toFixed(2)}`:"$0.00",Ce=D==="trackingTx"&&!!Q&&!!r&&!!i&&!!d&&!!T;return A("div",{className:"flex flex-col w-full",children:[Ce&&Q&&r&&i&&d&&T?l("div",{className:"overflow-hidden",children:l(tt,{orderHash:Q,base:r,quote:i,baseAmount:d,quoteAmount:T,status:$})}):A(ze,{children:[A("div",{className:`relative ${I}`,style:{borderBottom:"1px solid var(--widget-border)"},children:[S?C?A("div",{className:`flex items-center gap-2 mb-2 ${W==="right"?"flex-row-reverse":"flex-row"}`,children:[l(ne,{toggle:le,side:"base",asset:r,isPlacingOrder:y||s}),l("div",{className:"flex-1 min-w-0",children:l(oe,{side:"base",asset:r??null,otherAsset:i??null,isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})})]}):A("div",{className:`flex flex-col ${W==="right"?"items-end":"items-start"}`,children:[l(ne,{toggle:le,side:"base",asset:r,isPlacingOrder:y||s}),l(oe,{side:"base",asset:r??null,otherAsset:i??null,isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})]}):A(ze,{children:[l(ne,{toggle:le,side:"base",asset:r,isPlacingOrder:y||s}),l(oe,{side:"base",asset:r??null,otherAsset:i??null,isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})]}),A("div",{className:"mb-1 flex w-full flex-row items-center justify-between",children:[l("p",{className:"mono text-sm",style:{color:"var(--widget-muted-foreground)"},children:Se}),x&&we!==null&&we>0&&l("button",{type:"button",onClick:ce,disabled:y,className:"absolute bottom-3 right-4 flex items-center px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-colors bg-(--widget-primary) text-(--widget-primary-foreground) hover:bg-(--widget-foreground) hover:text-(--widget-card)",style:{borderRadius:"var(--widget-radius)"},children:"Max"})]})]}),!k&&l("div",{className:"flex justify-center -my-4 relative z-10",children:A("button",{type:"button",onClick:xe,"aria-label":"Swap input and output tokens",className:"flex h-8 w-8 items-center justify-center rounded-full cursor-pointer transition-colors bg-(--widget-card) text-(--widget-muted-foreground) hover:bg-(--widget-secondary) hover:text-(--widget-foreground)",style:{border:"1px solid var(--widget-border)"},children:[l("span",{className:"text-2xs",children:"\u2191"}),l("span",{className:"text-2xs",children:"\u2193"})]})}),A("div",{className:`relative ${O}`,children:[S?C?A("div",{className:`flex items-center gap-2 ${W==="right"?"flex-row-reverse":"flex-row"}`,children:[l(ne,{toggle:ye,side:"quote",asset:i,isPlacingOrder:y||b}),l("div",{className:"flex-1 min-w-0",children:l(oe,{side:"quote",asset:i??null,otherAsset:r??null,isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})})]}):A("div",{className:`flex flex-col ${W==="right"?"items-end":"items-start"}`,children:[l(ne,{toggle:ye,side:"quote",asset:i,isPlacingOrder:y||b}),l(oe,{side:"quote",asset:i??null,otherAsset:r??null,isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})]}):A(ze,{children:[l(ne,{toggle:ye,side:"quote",asset:i,isPlacingOrder:y||b}),l(oe,{side:"quote",asset:i??null,otherAsset:r??null,isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})]}),A("div",{className:"flex w-full flex-row items-center justify-between",children:[l("p",{className:"mono text-sm",style:{color:"var(--widget-muted-foreground)"},children:Ae}),ke&&l("button",{type:"button",onClick:Ne,disabled:y,className:"absolute bottom-2 right-4 flex items-center px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-colors text-(--widget-muted-foreground) hover:bg-(--widget-secondary)",style:{borderRadius:"var(--widget-radius)"},children:"Clear"})]})]}),l("div",{className:"flex flex-row items-center w-full overflow-hidden",style:{borderTop:E?"1px solid var(--widget-border)":"none",maxHeight:E?"60px":"0px",opacity:E?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:l(Xe,{})}),l("div",{className:"px-4",style:{borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"},children:l(Je,{})})]}),l("div",{className:`relative ${Ce?"px-0":"px-4"} ${C?"py-2":"py-4"}`,children:x&&r&&i&&d&&d>0?l(et,{base:r,baseAmount:d,quote:i,quoteAmount:T??0,userAddress:x,isWrappingPair:u,isUnwrappingPair:g,isBaseGasToken:X,isQuoteGasToken:L,reviewActionProps:J,reviewState:D,setReviewState:ee,trackedOrderHash:Q,setTrackedOrderHash:te,onSwapComplete:e,onSwapInitiated:t,onOrderSubmitted:ve,onStaleQuoteRestart:be,txStatus:$}):!x&&a?l("button",{onClick:()=>Z(),className:`w-full ${C?"py-2":"py-3"} text-sm font-medium cursor-pointer transition-opacity hover:opacity-80`,style:{backgroundColor:"var(--widget-primary)",color:"var(--widget-primary-foreground)",borderRadius:"var(--widget-radius)"},children:"Connect Wallet"}):l("button",{disabled:!0,className:`w-full ${C?"py-2":"py-3"} text-sm font-medium transition-colors disabled:opacity-40 cursor-not-allowed`,style:{backgroundColor:"var(--widget-primary)",color:"var(--widget-primary-foreground)",borderRadius:"var(--widget-radius)"},children:x?"Enter Amount":"Connect Wallet"})})]})},rt=qt;import{jsx as P,jsxs as Me}from"react/jsx-runtime";var at=()=>Me("div",{className:"flex flex-col w-full",children:[Me("div",{className:"relative px-4 pt-4 pb-2",style:{borderBottom:"1px solid var(--widget-border)"},children:[P("div",{className:"h-12 w-full animate-pulse",style:{backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}}),P("div",{className:"mt-2 h-20 w-2/3 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}}),P("div",{className:"mt-1 mb-1 flex w-full items-center justify-between",children:P("div",{className:"h-4 w-12 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.4,borderRadius:"0.25rem"}})})]}),P("div",{className:"flex justify-center -my-4 relative z-10",children:P("div",{className:"h-8 w-8",style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)",borderRadius:"9999px"}})}),Me("div",{className:"relative px-4 pt-6 pb-2",children:[P("div",{className:"h-12 w-full animate-pulse",style:{backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}}),P("div",{className:"mt-2 h-20 w-2/3 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}}),P("div",{className:"mt-1 mb-1 flex w-full items-center justify-between",children:P("div",{className:"h-4 w-12 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.4,borderRadius:"0.25rem"}})})]}),P("div",{className:"px-4",style:{height:"28px",borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"}}),P("div",{className:"relative px-4 py-4",children:P("div",{className:"w-full animate-pulse",style:{height:"44px",backgroundColor:"var(--widget-secondary)",borderRadius:"var(--widget-radius)",opacity:.6}})})]});import{useEffect as Et,useState as ot}from"react";import{useShallow as Ft}from"zustand/react/shallow";import{Fragment as Lt,jsx as f,jsxs as F}from"react/jsx-runtime";var Ht=({targetText:e,isError:t})=>{let{displayText:c,suffix:a,characterColors:s}=Ye(e,t);return F(Lt,{children:[c.split("").map((b,k)=>f("span",{style:s[k]?{color:"var(--widget-destructive)"}:void 0,children:b},k)),f("span",{style:{color:t?"var(--widget-destructive)":"var(--widget-muted-foreground)",opacity:t?.5:1},children:a})]})},Vt=({headerText:e,onBackClick:t,isSameChain:c,isWrappingPair:a,isUnwrappingPair:s,hasLowLiquidity:b,hasInsufficientLiquidity:k,hasRoutingError:N,hasSizeCapError:W})=>{let w=n(v=>v.view),{isRecipientInputOpen:S,hasAllowanceError:C,hoveredChainName:I,isTrackingTx:O,txStatus:r,walletTab:i}=n(Ft(v=>({isRecipientInputOpen:v.isRecipientInputOpen,hasAllowanceError:v.hasAllowanceError,hoveredChainName:v.hoveredChainName,isTrackingTx:v.isTrackingTx,txStatus:v.txStatus,walletTab:v.walletTab}))),{web3ConnectionType:d,swapHeaderVariant:T,customWalletUI:X,walletButtonEnabled:L}=ge(),{isConnected:u}=_(),{openAccountModal:g}=ae(),[m,Y]=ot(!1);Et(()=>Y(!0),[]);let[R,h]=ot(!1),U=`${w}-${R}-${S}-${I||"none"}`,j=(()=>{if(O&&r)switch(r){case"pending":return"Trade Pending";case"received":return"Trade Received";case"completed":return"Trade Filled";case"failed":return"Trade Failed";case"cancelled":return"Trade Cancelled";default:return"Processing Trade"}if(I&&(w==="baseSelection"||w==="quoteSelection"||w==="baseChainSelection"||w==="quoteChainSelection"))return I;if(w==="swap"&&R)return S?"Remove Custom Recipient":"Add Custom Recipient";switch(w){case"wallet":return"Wallet";case"baseSelection":return"Select Source Token";case"quoteSelection":return"Select Destination Token";case"baseChainSelection":return"Select Source Chain";case"quoteChainSelection":return"Select Destination Chain";default:if(w==="swap"){if(C&&!a&&!s)return"Allowance check failed";if(W&&!a&&!s)return"Size limit exceeded";if(k&&!a&&!s)return"Insufficient Liquidity";if(N&&!a&&!s)return"Route Not Found";if(b&&!a&&!s)return"High Price Impact"}return c&&!a&&!s?"Swap":a?"Wrap":s?"Unwrap":e}})(),G=!O&&w==="swap"&&!R&&(C&&!a&&!s||W&&!a&&!s||k&&!a&&!s||N&&!a&&!s||b&&!a&&!s),H={pending:"var(--widget-status-pending)",received:"var(--widget-status-received)",completed:"var(--widget-status-completed)",failed:"var(--widget-status-failed)",cancelled:"var(--widget-status-failed)"},B=()=>!O||!r?null:H[r]??null,z=()=>O?null:w==="swap"?F("div",{className:"flex items-center gap-2",children:[L&&m&&d==="custom"&&u&&f("button",{onClick:()=>{X==="provider"&&g?g():n.getState().setView("wallet")},"aria-label":"Open wallet",className:"size-4 -translate-y-0.5 flex cursor-pointer items-center justify-center rounded-full transition-colors text-(--widget-muted-foreground) opacity-60 hover:text-(--widget-foreground) hover:opacity-100",children:F("svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f("rect",{x:"2",y:"5",width:"20",height:"15",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),f("path",{d:"M16 12C16 11.4477 16.4477 11 17 11H21V13H17C16.4477 13 16 12.5523 16 12Z",fill:"currentColor"}),f("path",{d:"M2 9H22",stroke:"currentColor",strokeWidth:"1.5"})]})}),L&&m&&d==="standalone"&&u&&g&&f("button",{onClick:()=>g(),"aria-label":"Open account",className:"size-4 -translate-y-0.5 flex cursor-pointer items-center justify-center rounded-full transition-colors text-(--widget-muted-foreground) opacity-60 hover:text-(--widget-foreground) hover:opacity-100",children:F("svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f("rect",{x:"2",y:"5",width:"20",height:"15",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),f("path",{d:"M16 12C16 11.4477 16.4477 11 17 11H21V13H17C16.4477 13 16 12.5523 16 12Z",fill:"currentColor"}),f("path",{d:"M2 9H22",stroke:"currentColor",strokeWidth:"1.5"})]})}),f("button",{onClick:()=>n.getState().toggleRecipientInput(),onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),"aria-label":S?"Remove custom recipient":"Add custom recipient",className:`size-4 -translate-y-0.5 flex cursor-pointer items-center justify-center rounded-full transition-colors hover:text-(--widget-foreground) hover:opacity-100 ${S?"text-(--widget-destructive) opacity-80":"text-(--widget-muted-foreground) opacity-60"}`,children:F("svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f("path",{d:"M2 7.75C1.58579 7.75 1.25 8.08579 1.25 8.5C1.25 8.91421 1.58579 9.25 2 9.25V7.75ZM2 8.5V9.25H13.5V8.5V7.75H2V8.5Z",fill:"currentColor"}),f("path",{d:"M6 16.5H8",stroke:"currentColor",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"butt",strokeLinejoin:"miter"}),f("path",{d:"M10.5 16.5H14.5",stroke:"currentColor",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"butt",strokeLinejoin:"miter"}),f("path",{d:"M22 12.03V16.11C22 20.5 22 20.5 17.56 20.5H6.44C2 20.5 2 20.5 2 16.11V7.89C2 3.5 2 3.5 6.44 3.5H13.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"miter"}),F("g",{style:{transform:`rotate(${S?"45deg":"0deg"})`,transformOrigin:"18.75px 6.75px",transition:"transform 150ms ease-out"},children:[f("path",{d:"M15 6.75H22.5",stroke:"currentColor",strokeWidth:"1.5"}),f("path",{d:"M18.75 10.5V3",stroke:"currentColor",strokeWidth:"1.5"})]})]})})]}):F("button",{onClick:()=>t?t():n.getState().setView("swap"),className:"flex cursor-pointer items-center justify-center whitespace-nowrap h-6 transition-colors text-(--widget-muted-foreground) opacity-70 hover:text-(--widget-foreground) hover:opacity-100",children:[f("span",{className:"pr-1",children:"\u2190"}),f("span",{className:"text-sm",children:"Back"})]}),q=B();return T==="none"?null:F("div",{className:"w-full pt-3 px-2 mono text-base flex flex-row justify-between h-6 shrink-0",children:[w==="wallet"?F("div",{className:"flex items-center gap-1 mono uppercase -translate-y-0.5 text-xs",children:[F("button",{type:"button",onClick:()=>n.getState().setWalletTab("wallet"),className:"cursor-pointer transition-colors",style:{color:i==="wallet"?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:[f("span",{style:{color:"var(--widget-muted-foreground)"},children:">> "}),f("span",{children:"Wallet"})]}),f("span",{style:{color:"var(--widget-foreground)",opacity:.4},children:">>"}),f("button",{type:"button",onClick:()=>n.getState().setWalletTab("activity"),className:"cursor-pointer transition-colors",style:{color:i==="activity"?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:"Activity"})]}):F("div",{className:"mono uppercase -translate-y-0.5 text-xs flex items-center",children:[f("span",{className:"mr-1.5",style:{color:"var(--widget-muted-foreground)",opacity:.4},children:">> "}),f("span",{className:"relative",style:{color:q||"var(--widget-foreground)"},children:f(Ht,{targetText:j,isError:G??!1})},U)]}),f("div",{className:"flex flex-row items-center",children:z()})]})},Be=Vt;import{Fragment as Kt,jsx as p,jsxs as We}from"react/jsx-runtime";var st=pe(()=>import("./AssetSelectionMenu-INISSBWT.js")),dt=pe(()=>import("./ChainSelectionMenu-N65VG257.js")),jt=pe(()=>import("./SwapFormHorizontal-XMZKEAIL.js")),$t=pe(()=>import("./SwapFormSplit-SOC2XMBW.js")),Dt=pe(()=>import("./WidgetWalletPanel-KZFLFLUD.js").then(e=>({default:e.WidgetWalletPanel}))),Qt=pe(()=>import("./WalletPlaceholderPanel-Z4JCFCNV.js").then(e=>({default:e.WalletPlaceholderPanel}))),_t=({onSwapComplete:e,cardStyles:t,cardWidth:c})=>{let{baseToken:a,quoteToken:s,baseAmount:b,quoteAmount:k,isWrappingPair:N,isUnwrappingPair:W,isRegistryLoading:w}=fe(),{liquidityError:S,routingError:C,sizeCapError:I,stop:O,clear:r}=ue(),i=n(o=>o.view),{isTransitioning:d,isRecipientInputOpen:T,recipient:X,selectedChainFilterChainId:L}=n(Ut(o=>({isTransitioning:o.isTransitioning,isRecipientInputOpen:o.isRecipientInputOpen,recipient:o.recipient,selectedChainFilterChainId:o.selectedChainFilter?.chainId??null}))),u=qe(null),g=qe(null),[m,Y]=nt(null);Pe(),Re(()=>()=>{u.current&&clearTimeout(u.current),g.current&&clearTimeout(g.current)},[]),Re(()=>{n.getState().resetUI()},[]),Re(()=>{if(d)return u.current=setTimeout(()=>{n.getState().setIsTransitioning(!1),u.current=null},20),()=>{u.current&&(clearTimeout(u.current),u.current=null)}},[d]);let R=me((o,V="navigation")=>{g.current&&(clearTimeout(g.current),g.current=null,Y(null)),n.getState().view!=="swap"&&o!=="swap"?(n.getState().setView(o),n.getState().setIsTransitioning(!1)):n.getState().transitionToView(o,V)},[]),h=me(()=>{u.current&&(clearTimeout(u.current),u.current=null),g.current&&(clearTimeout(g.current),g.current=null);let o=n.getState().view;Y(o),n.getState().setChainFilter(null),n.getState().setView("swap"),n.getState().setIsTransitioning(!1),n.getState().resetAssetSelection(),g.current=setTimeout(()=>{Y(null),g.current=null},200)},[]),U=me(o=>{let re=i==="baseChainSelection"?"base":"quote";n.getState().setChainFilter({chainId:o,side:re}),n.getState().pushRecentChain(o),R(re==="base"?"baseSelection":"quoteSelection","chainSelection")},[i,R]),M=me(()=>{let o=n.getState().view;o==="baseSelection"?R("baseChainSelection","chainSelection"):o==="quoteSelection"&&R("quoteChainSelection","chainSelection")},[R]),j=me(()=>{O(),r()},[O,r]),G=a&&s?a.chainId===s.chainId:!0,H=()=>{switch(i){case"wallet":return"Wallet";case"baseSelection":return"Select Input Token";case"quoteSelection":return"Select Output Token";case"baseChainSelection":case"quoteChainSelection":return"Select Chain";default:return"Swap"}},{assetMenuVariant:B,widgetType:z,customWalletUI:q}=ge(),v=i==="baseSelection"||i==="quoteSelection",x=i==="baseChainSelection"||i==="quoteChainSelection",Z=B==="split"&&(z==="default"||z==="compact"),E=B==="split"&&(z==="horizontal"||z==="split"),$=B==="default",D=i==="swap"||v||x||i==="wallet",ee=m==="baseSelection"||m==="quoteSelection",Q=m==="baseChainSelection"||m==="quoteChainSelection",te=v||ee,ie=x||Q,y=v&&!d,J=x&&!d,ve=v?i:m,be=ve==="baseSelection"?"base":"quote",le=ve==="baseSelection"?s:a,xe=(x?i:m)==="baseChainSelection"?"base":"quote",ce=o=>({backgroundColor:"var(--widget-background)",opacity:o?1:0,transform:o?"translateY(0)":"translateY(6px)",transition:"opacity 200ms ease-in-out, transform 200ms ease-in-out"}),Ne=$&&(v||x||i==="wallet"||m!=null),we=w?p(at,{}):z==="horizontal"?p(de,{fallback:null,children:p(jt,{onSwapComplete:e,onSwapInitiated:j,onBackToSwap:E?h:void 0,onMoreChainsClick:E?M:void 0})}):z==="split"?p(de,{fallback:null,children:p($t,{onSwapComplete:e,onSwapInitiated:j,onBackToSwap:E?h:void 0,onMoreChainsClick:E?M:void 0})}):p(rt,{onSwapComplete:e,onSwapInitiated:j}),ke=t??{},Se=qe(null),[Ae,Ce]=nt(420);return Re(()=>{if(!Z)return;let o=Se.current;if(!o)return;let V=new ResizeObserver(re=>{for(let ft of re)Ce(ft.contentRect.height)});return V.observe(o),()=>V.disconnect()},[Z]),Z?We(Kt,{children:[We("div",{ref:Se,className:"flex flex-col w-full overflow-hidden transition-colors duration-300",style:{flex:"1 1 0",minWidth:0,...ke},children:[p(Be,{headerText:"Swap",onBackClick:h,isSameChain:G,isWrappingPair:N,isUnwrappingPair:W,hasLowLiquidity:S,hasInsufficientLiquidity:S,hasRoutingError:C,hasSizeCapError:I}),p("div",{className:"overflow-hidden",children:we})]}),(te||ie)&&p("div",{className:"flex flex-col overflow-hidden shrink-0",style:{width:c,height:`${Ae}px`,...ke,...ce((v||x)&&!d)},children:v||ee?p(de,{fallback:null,children:p(st,{toggle:h,side:be,otherAsset:le,onMoreChainsClick:M,selectedChainFilter:L})}):p(de,{fallback:null,children:p(dt,{toggle:h,side:xe,onChainSelect:U})})})]}):We("div",{className:"flex flex-col w-full",style:{overflow:"hidden",position:"relative"},children:[p(Be,{headerText:H(),onBackClick:h,isSameChain:G,isWrappingPair:N,isUnwrappingPair:W,hasLowLiquidity:S,hasInsufficientLiquidity:S,hasRoutingError:C,hasSizeCapError:I}),We("div",{className:"relative overflow-hidden",children:[D&&p("div",{className:"overflow-hidden",style:Ne?{pointerEvents:"none"}:void 0,children:we}),(i==="wallet"||m==="wallet")&&p("div",{className:"absolute inset-0 overflow-hidden",style:ce(i==="wallet"&&!d),children:p(de,{fallback:null,children:q==="none"?p(Qt,{}):p(Dt,{})})}),$&&te&&p("div",{className:"absolute inset-0 overflow-hidden",style:ce(y),children:p(de,{fallback:null,children:p(st,{toggle:h,side:be,otherAsset:le,onMoreChainsClick:M,selectedChainFilter:L})})}),$&&ie&&p("div",{className:"absolute inset-0 overflow-hidden",style:ce(J),children:p(de,{fallback:null,children:p(dt,{toggle:h,side:xe,onChainSelect:U})})})]})]})},lt=({onSwapComplete:e,defaultBaseToken:t,defaultQuoteToken:c,onBaseTokenChange:a,onQuoteTokenChange:s,cardStyles:b,cardWidth:k})=>{let{address:N}=_(),W=n(w=>w.recipient);return p(Oe,{defaultBaseToken:t,defaultQuoteToken:c,onBaseTokenChange:a,onQuoteTokenChange:s,children:p(Ie,{recipient:W,children:p(_t,{onSwapComplete:e,cardStyles:b,cardWidth:k})})})};import{createContext as Yt,useContext as Gt}from"react";var Ee={background:"#ffffff",foreground:"#0a0a0a",card:"#ffffff","card-foreground":"#0a0a0a",popover:"#ffffff","popover-foreground":"#0a0a0a",primary:"#171717","primary-foreground":"#fafafa",secondary:"#f5f5f5","secondary-foreground":"#171717",muted:"#f5f5f5","muted-foreground":"#737373",accent:"#f5f5f5","accent-foreground":"#171717",destructive:"#e7000b","destructive-foreground":"#ffffff",border:"#e5e5e5",input:"#e5e5e5",ring:"#a1a1a1",radius:"0.625rem","border-style":"dotted","status-pending":"#a1a1aa","status-received":"#f59e0b","status-completed":"#10b981","status-failed":"#ef4444"},he={background:"#0a0a0a",foreground:"#fafafa",card:"#171717","card-foreground":"#fafafa",popover:"#262626","popover-foreground":"#fafafa",primary:"#e5e5e5","primary-foreground":"#171717",secondary:"#262626","secondary-foreground":"#fafafa",muted:"#262626","muted-foreground":"#a1a1a1",accent:"#404040","accent-foreground":"#fafafa",destructive:"#ff6467","destructive-foreground":"#fafafa",border:"#282828",input:"#343434",ring:"#737373",radius:"0.625rem","border-style":"dotted","status-pending":"#a1a1aa","status-received":"#fbbf24","status-completed":"#2dd4bf","status-failed":"#fb7185"};function Fe(e){let t={"--widget-background":e.background,"--widget-foreground":e.foreground,"--widget-card":e.card,"--widget-card-foreground":e["card-foreground"],"--widget-popover":e.popover,"--widget-popover-foreground":e["popover-foreground"],"--widget-primary":e.primary,"--widget-primary-foreground":e["primary-foreground"],"--widget-secondary":e.secondary,"--widget-secondary-foreground":e["secondary-foreground"],"--widget-muted":e.muted,"--widget-muted-foreground":e["muted-foreground"],"--widget-accent":e.accent,"--widget-accent-foreground":e["accent-foreground"],"--widget-destructive":e.destructive,"--widget-destructive-foreground":e["destructive-foreground"],"--widget-border":e.border,"--widget-input":e.input,"--widget-ring":e.ring,"--widget-radius":e.radius,"--widget-border-style":e["border-style"]||"dotted"};return t["--widget-font-sans"]=e["font-sans"]||"inherit",t["--widget-font-mono"]=e["font-mono"]||"inherit",t["--widget-shadow-color"]=e["shadow-color"]||"oklch(0 0 0)",t["--widget-shadow-opacity"]=e["shadow-opacity"]||"0.1",t["--widget-shadow-blur"]=e["shadow-blur"]||"3px",t["--widget-shadow-spread"]=e["shadow-spread"]||"0px",t["--widget-shadow-offset-x"]=e["shadow-offset-x"]||"0",t["--widget-shadow-offset-y"]=e["shadow-offset-y"]||"1px",t["--widget-letter-spacing"]=e["letter-spacing"]||"normal",t["--widget-status-pending"]=e["status-pending"]||"#a1a1aa",t["--widget-status-received"]=e["status-received"]||"#fbbf24",t["--widget-status-completed"]=e["status-completed"]||"#2dd4bf",t["--widget-status-failed"]=e["status-failed"]||"#fb7185",t}import{jsx as Jt}from"react/jsx-runtime";var ct=Yt(he);function He({theme:e,children:t}){return Jt(ct.Provider,{value:e,children:t})}function Zt(){return Gt(ct)}import{jsx as K,jsxs as wt}from"react/jsx-runtime";var ei=[],ti=[],ii=[],pt=[],ri=`
2
+ import{a as Je}from"./chunk-4BQRVCQR.js";import{a as mt,b as ht,c as Pe,d as Ie,e as ue,f as Ze,g as ae,h as oe,i as ne,j as Xe,k as xt,l as kt,m as St,n as Ct,o as Tt,p as Rt,q as Wt,r as Nt,s as At,t as Pt,u as It,v as et,w as tt}from"./chunk-XYF2YBR3.js";import"./chunk-OPN7WCJR.js";import{a as vt,b as bt,c as n,d as yt,e as Oe,f as fe}from"./chunk-726CI6GC.js";import{A as Ye,F as Te,N as Ge,a as Ue,b as ge,d as je,f as $e,i as De,l as Qe,n as _e,p as Ke}from"./chunk-EW2OR6CJ.js";import{a as _}from"./chunk-46H44R7V.js";import"./chunk-73CB2I7U.js";import Xt,{useMemo as gt}from"react";import{Suspense as de,lazy as pe,useCallback as me,useEffect as Re,useRef as qe,useState as nt}from"react";import{useShallow as Ut}from"zustand/react/shallow";import{useCallback as se,useEffect as Ot,useMemo as zt,useRef as Mt,useState as it}from"react";import{useShallow as Bt}from"zustand/react/shallow";import{Fragment as ze,jsx as l,jsxs as A}from"react/jsx-runtime";var qt=({onSwapComplete:e,onSwapInitiated:t})=>{let{web3ConnectionType:c,hasConnectHandler:a,lockBase:s,lockQuote:b,disableInverting:k,tokenDisplay:N,tokenBadgeOrientation:W,widgetType:w}=ge(),S=N==="pill"||N==="ghost",C=w==="compact",I=C?"px-4 pt-3 pb-1":"px-4 pt-4 pb-2",O=C?"px-4 pt-4 pb-1":"px-4 pt-6 pb-2",{baseToken:r,quoteToken:i,baseAmount:d,quoteAmount:T,isBaseGasToken:X,isQuoteGasToken:L,isWrappingPair:u,isUnwrappingPair:g,baseBalance:m,quoteBalance:Y,setBaseAmount:R,setQuoteAmount:h,swapTokens:U,clearForm:M}=fe(),{rfqQuote:j,status:G,handleInputChange:H,ensureForParams:B,stop:z,clear:q,refresh:v}=ue(),{address:x}=_(),{openConnectModal:Z}=ae(),{isRecipientInputOpen:E,txStatus:$}=n(Bt(o=>({isRecipientInputOpen:o.isRecipientInputOpen,txStatus:o.txStatus}))),[D,ee]=it(null),[Q,te]=it(null),ie=Mt(!1),y=!1,J=zt(()=>!r||!i||typeof d!="number"||!T||!x||parseFloat(m.formatted)<d?null:{base:r,quote:i,baseAmount:d,quoteAmount:T,userAddress:x},[r,i,d,T,x,m.formatted]),ve=se(o=>{te(o),n.getState().startTracking(o)},[]),be=se(()=>{ie.current=!0,v()},[v]);Ot(()=>{if(D===null&&!(!r||!i)){if(!d||d<=0){H({amount:null,inputToken:r,outputToken:i,setOutputAmount:h});return}if(u||g){h(d);return}H({amount:d,inputToken:r,outputToken:i,setOutputAmount:h})}},[D,d,r,i,u,g,H,h]);let le=se(()=>{n.getState().setView("baseSelection")},[]),ye=se(()=>{n.getState().setView("quoteSelection")},[]),xe=se(()=>{U(),h(null)},[U,h]),ce=se(()=>{if(!m.formatted||!r||!i)return;let o=parseFloat(m.formatted);if(!o||o<=0)return;let V=o*.9999999999;u||g?(R(V),h(V),q()):(R(V),h(null),B({inputToken:r,outputToken:i,inputAmount:V.toString(),setOutputAmount:re=>h(re)}))},[m.formatted,r,i,u,g,R,h,q,B]),Ne=se(()=>{q(),M()},[q,M]),we=m.formatted?parseFloat(m.formatted):null,ke=!!(d||T),Se=r?.price&&d?`$${(r.price*d).toFixed(2)}`:"$0.00",Ae=i?.price&&T?`$${(i.price*T).toFixed(2)}`:"$0.00",Ce=D==="trackingTx"&&!!Q&&!!r&&!!i&&!!d&&!!T;return A("div",{className:"flex flex-col w-full",children:[Ce&&Q&&r&&i&&d&&T?l("div",{className:"overflow-hidden",children:l(tt,{orderHash:Q,base:r,quote:i,baseAmount:d,quoteAmount:T,status:$})}):A(ze,{children:[A("div",{className:`relative ${I}`,style:{borderBottom:"1px solid var(--widget-border)"},children:[S?C?A("div",{className:`flex items-center gap-2 mb-2 ${W==="right"?"flex-row-reverse":"flex-row"}`,children:[l(ne,{toggle:le,side:"base",asset:r,isPlacingOrder:y||s}),l("div",{className:"flex-1 min-w-0",children:l(oe,{side:"base",asset:r??null,otherAsset:i??null,isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})})]}):A("div",{className:`flex flex-col ${W==="right"?"items-end":"items-start"}`,children:[l(ne,{toggle:le,side:"base",asset:r,isPlacingOrder:y||s}),l(oe,{side:"base",asset:r??null,otherAsset:i??null,isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})]}):A(ze,{children:[l(ne,{toggle:le,side:"base",asset:r,isPlacingOrder:y||s}),l(oe,{side:"base",asset:r??null,otherAsset:i??null,isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})]}),A("div",{className:"mb-1 flex w-full flex-row items-center justify-between",children:[l("p",{className:"mono text-sm",style:{color:"var(--widget-muted-foreground)"},children:Se}),x&&we!==null&&we>0&&l("button",{type:"button",onClick:ce,disabled:y,className:"absolute bottom-3 right-4 flex items-center px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-colors bg-(--widget-primary) text-(--widget-primary-foreground) hover:bg-(--widget-foreground) hover:text-(--widget-card)",style:{borderRadius:"var(--widget-radius)"},children:"Max"})]})]}),!k&&l("div",{className:"flex justify-center -my-4 relative z-10",children:A("button",{type:"button",onClick:xe,"aria-label":"Swap input and output tokens",className:"flex h-8 w-8 items-center justify-center rounded-full cursor-pointer transition-colors bg-(--widget-card) text-(--widget-muted-foreground) hover:bg-(--widget-secondary) hover:text-(--widget-foreground)",style:{border:"1px solid var(--widget-border)"},children:[l("span",{className:"text-2xs",children:"\u2191"}),l("span",{className:"text-2xs",children:"\u2193"})]})}),A("div",{className:`relative ${O}`,children:[S?C?A("div",{className:`flex items-center gap-2 ${W==="right"?"flex-row-reverse":"flex-row"}`,children:[l(ne,{toggle:ye,side:"quote",asset:i,isPlacingOrder:y||b}),l("div",{className:"flex-1 min-w-0",children:l(oe,{side:"quote",asset:i??null,otherAsset:r??null,isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})})]}):A("div",{className:`flex flex-col ${W==="right"?"items-end":"items-start"}`,children:[l(ne,{toggle:ye,side:"quote",asset:i,isPlacingOrder:y||b}),l(oe,{side:"quote",asset:i??null,otherAsset:r??null,isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})]}):A(ze,{children:[l(ne,{toggle:ye,side:"quote",asset:i,isPlacingOrder:y||b}),l(oe,{side:"quote",asset:i??null,otherAsset:r??null,isPlacingOrder:y,isWrappingPair:u,isUnwrappingPair:g})]}),A("div",{className:"flex w-full flex-row items-center justify-between",children:[l("p",{className:"mono text-sm",style:{color:"var(--widget-muted-foreground)"},children:Ae}),ke&&l("button",{type:"button",onClick:Ne,disabled:y,className:"absolute bottom-2 right-4 flex items-center px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-colors text-(--widget-muted-foreground) hover:bg-(--widget-secondary)",style:{borderRadius:"var(--widget-radius)"},children:"Clear"})]})]}),l("div",{className:"flex flex-row items-center w-full overflow-hidden",style:{borderTop:E?"1px solid var(--widget-border)":"none",maxHeight:E?"60px":"0px",opacity:E?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:l(Xe,{})}),l("div",{className:"px-4",style:{borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"},children:l(Je,{})})]}),l("div",{className:`relative ${Ce?"px-0":"px-4"} ${C?"py-2":"py-4"}`,children:x&&r&&i&&d&&d>0?l(et,{base:r,baseAmount:d,quote:i,quoteAmount:T??0,userAddress:x,isWrappingPair:u,isUnwrappingPair:g,isBaseGasToken:X,isQuoteGasToken:L,reviewActionProps:J,reviewState:D,setReviewState:ee,trackedOrderHash:Q,setTrackedOrderHash:te,onSwapComplete:e,onSwapInitiated:t,onOrderSubmitted:ve,onStaleQuoteRestart:be,txStatus:$}):!x&&a?l("button",{onClick:()=>Z(),className:`w-full ${C?"py-2":"py-3"} text-sm font-medium cursor-pointer transition-opacity hover:opacity-80`,style:{backgroundColor:"var(--widget-primary)",color:"var(--widget-primary-foreground)",borderRadius:"var(--widget-radius)"},children:"Connect Wallet"}):l("button",{disabled:!0,className:`w-full ${C?"py-2":"py-3"} text-sm font-medium transition-colors disabled:opacity-40 cursor-not-allowed`,style:{backgroundColor:"var(--widget-primary)",color:"var(--widget-primary-foreground)",borderRadius:"var(--widget-radius)"},children:x?"Enter Amount":"Connect Wallet"})})]})},rt=qt;import{jsx as P,jsxs as Me}from"react/jsx-runtime";var at=()=>Me("div",{className:"flex flex-col w-full",children:[Me("div",{className:"relative px-4 pt-4 pb-2",style:{borderBottom:"1px solid var(--widget-border)"},children:[P("div",{className:"h-12 w-full animate-pulse",style:{backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}}),P("div",{className:"mt-2 h-20 w-2/3 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}}),P("div",{className:"mt-1 mb-1 flex w-full items-center justify-between",children:P("div",{className:"h-4 w-12 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.4,borderRadius:"0.25rem"}})})]}),P("div",{className:"flex justify-center -my-4 relative z-10",children:P("div",{className:"h-8 w-8",style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)",borderRadius:"9999px"}})}),Me("div",{className:"relative px-4 pt-6 pb-2",children:[P("div",{className:"h-12 w-full animate-pulse",style:{backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}}),P("div",{className:"mt-2 h-20 w-2/3 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}}),P("div",{className:"mt-1 mb-1 flex w-full items-center justify-between",children:P("div",{className:"h-4 w-12 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.4,borderRadius:"0.25rem"}})})]}),P("div",{className:"px-4",style:{height:"28px",borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"}}),P("div",{className:"relative px-4 py-4",children:P("div",{className:"w-full animate-pulse",style:{height:"44px",backgroundColor:"var(--widget-secondary)",borderRadius:"var(--widget-radius)",opacity:.6}})})]});import{useEffect as Et,useState as ot}from"react";import{useShallow as Ft}from"zustand/react/shallow";import{Fragment as Lt,jsx as f,jsxs as F}from"react/jsx-runtime";var Ht=({targetText:e,isError:t})=>{let{displayText:c,suffix:a,characterColors:s}=Ye(e,t);return F(Lt,{children:[c.split("").map((b,k)=>f("span",{style:s[k]?{color:"var(--widget-destructive)"}:void 0,children:b},k)),f("span",{style:{color:t?"var(--widget-destructive)":"var(--widget-muted-foreground)",opacity:t?.5:1},children:a})]})},Vt=({headerText:e,onBackClick:t,isSameChain:c,isWrappingPair:a,isUnwrappingPair:s,hasLowLiquidity:b,hasInsufficientLiquidity:k,hasRoutingError:N,hasSizeCapError:W})=>{let w=n(v=>v.view),{isRecipientInputOpen:S,hasAllowanceError:C,hoveredChainName:I,isTrackingTx:O,txStatus:r,walletTab:i}=n(Ft(v=>({isRecipientInputOpen:v.isRecipientInputOpen,hasAllowanceError:v.hasAllowanceError,hoveredChainName:v.hoveredChainName,isTrackingTx:v.isTrackingTx,txStatus:v.txStatus,walletTab:v.walletTab}))),{web3ConnectionType:d,swapHeaderVariant:T,customWalletUI:X,walletButtonEnabled:L}=ge(),{isConnected:u}=_(),{openAccountModal:g}=ae(),[m,Y]=ot(!1);Et(()=>Y(!0),[]);let[R,h]=ot(!1),U=`${w}-${R}-${S}-${I||"none"}`,j=(()=>{if(O&&r)switch(r){case"pending":return"Trade Pending";case"received":return"Trade Received";case"completed":return"Trade Filled";case"failed":return"Trade Failed";case"cancelled":return"Trade Cancelled";default:return"Processing Trade"}if(I&&(w==="baseSelection"||w==="quoteSelection"||w==="baseChainSelection"||w==="quoteChainSelection"))return I;if(w==="swap"&&R)return S?"Remove Custom Recipient":"Add Custom Recipient";switch(w){case"wallet":return"Wallet";case"baseSelection":return"Select Source Token";case"quoteSelection":return"Select Destination Token";case"baseChainSelection":return"Select Source Chain";case"quoteChainSelection":return"Select Destination Chain";default:if(w==="swap"){if(C&&!a&&!s)return"Allowance check failed";if(W&&!a&&!s)return"Size limit exceeded";if(k&&!a&&!s)return"Insufficient Liquidity";if(N&&!a&&!s)return"Route Not Found";if(b&&!a&&!s)return"High Price Impact"}return c&&!a&&!s?"Swap":a?"Wrap":s?"Unwrap":e}})(),G=!O&&w==="swap"&&!R&&(C&&!a&&!s||W&&!a&&!s||k&&!a&&!s||N&&!a&&!s||b&&!a&&!s),H={pending:"var(--widget-status-pending)",received:"var(--widget-status-received)",completed:"var(--widget-status-completed)",failed:"var(--widget-status-failed)",cancelled:"var(--widget-status-failed)"},B=()=>!O||!r?null:H[r]??null,z=()=>O?null:w==="swap"?F("div",{className:"flex items-center gap-2",children:[L&&m&&d==="custom"&&u&&f("button",{onClick:()=>{X==="provider"&&g?g():n.getState().setView("wallet")},"aria-label":"Open wallet",className:"size-4 -translate-y-0.5 flex cursor-pointer items-center justify-center rounded-full transition-colors text-(--widget-muted-foreground) opacity-60 hover:text-(--widget-foreground) hover:opacity-100",children:F("svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f("rect",{x:"2",y:"5",width:"20",height:"15",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),f("path",{d:"M16 12C16 11.4477 16.4477 11 17 11H21V13H17C16.4477 13 16 12.5523 16 12Z",fill:"currentColor"}),f("path",{d:"M2 9H22",stroke:"currentColor",strokeWidth:"1.5"})]})}),L&&m&&d==="standalone"&&u&&g&&f("button",{onClick:()=>g(),"aria-label":"Open account",className:"size-4 -translate-y-0.5 flex cursor-pointer items-center justify-center rounded-full transition-colors text-(--widget-muted-foreground) opacity-60 hover:text-(--widget-foreground) hover:opacity-100",children:F("svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f("rect",{x:"2",y:"5",width:"20",height:"15",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),f("path",{d:"M16 12C16 11.4477 16.4477 11 17 11H21V13H17C16.4477 13 16 12.5523 16 12Z",fill:"currentColor"}),f("path",{d:"M2 9H22",stroke:"currentColor",strokeWidth:"1.5"})]})}),f("button",{onClick:()=>n.getState().toggleRecipientInput(),onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),"aria-label":S?"Remove custom recipient":"Add custom recipient",className:`size-4 -translate-y-0.5 flex cursor-pointer items-center justify-center rounded-full transition-colors hover:text-(--widget-foreground) hover:opacity-100 ${S?"text-(--widget-destructive) opacity-80":"text-(--widget-muted-foreground) opacity-60"}`,children:F("svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f("path",{d:"M2 7.75C1.58579 7.75 1.25 8.08579 1.25 8.5C1.25 8.91421 1.58579 9.25 2 9.25V7.75ZM2 8.5V9.25H13.5V8.5V7.75H2V8.5Z",fill:"currentColor"}),f("path",{d:"M6 16.5H8",stroke:"currentColor",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"butt",strokeLinejoin:"miter"}),f("path",{d:"M10.5 16.5H14.5",stroke:"currentColor",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"butt",strokeLinejoin:"miter"}),f("path",{d:"M22 12.03V16.11C22 20.5 22 20.5 17.56 20.5H6.44C2 20.5 2 20.5 2 16.11V7.89C2 3.5 2 3.5 6.44 3.5H13.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"miter"}),F("g",{style:{transform:`rotate(${S?"45deg":"0deg"})`,transformOrigin:"18.75px 6.75px",transition:"transform 150ms ease-out"},children:[f("path",{d:"M15 6.75H22.5",stroke:"currentColor",strokeWidth:"1.5"}),f("path",{d:"M18.75 10.5V3",stroke:"currentColor",strokeWidth:"1.5"})]})]})})]}):F("button",{onClick:()=>t?t():n.getState().setView("swap"),className:"flex cursor-pointer items-center justify-center whitespace-nowrap h-6 transition-colors text-(--widget-muted-foreground) opacity-70 hover:text-(--widget-foreground) hover:opacity-100",children:[f("span",{className:"pr-1",children:"\u2190"}),f("span",{className:"text-sm",children:"Back"})]}),q=B();return T==="none"?null:F("div",{className:"w-full pt-3 px-2 mono text-base flex flex-row justify-between h-6 shrink-0",children:[w==="wallet"?F("div",{className:"flex items-center gap-1 mono uppercase -translate-y-0.5 text-xs",children:[F("button",{type:"button",onClick:()=>n.getState().setWalletTab("wallet"),className:"cursor-pointer transition-colors",style:{color:i==="wallet"?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:[f("span",{style:{color:"var(--widget-muted-foreground)"},children:">> "}),f("span",{children:"Wallet"})]}),f("span",{style:{color:"var(--widget-foreground)",opacity:.4},children:">>"}),f("button",{type:"button",onClick:()=>n.getState().setWalletTab("activity"),className:"cursor-pointer transition-colors",style:{color:i==="activity"?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:"Activity"})]}):F("div",{className:"mono uppercase -translate-y-0.5 text-xs flex items-center",children:[f("span",{className:"mr-1.5",style:{color:"var(--widget-muted-foreground)",opacity:.4},children:">> "}),f("span",{className:"relative",style:{color:q||"var(--widget-foreground)"},children:f(Ht,{targetText:j,isError:G??!1})},U)]}),f("div",{className:"flex flex-row items-center",children:z()})]})},Be=Vt;import{Fragment as Kt,jsx as p,jsxs as We}from"react/jsx-runtime";var st=pe(()=>import("./AssetSelectionMenu-ZFY7XFRX.js")),dt=pe(()=>import("./ChainSelectionMenu-SKXLHK3S.js")),jt=pe(()=>import("./SwapFormHorizontal-GI4X7ISS.js")),$t=pe(()=>import("./SwapFormSplit-52RBMJIO.js")),Dt=pe(()=>import("./WidgetWalletPanel-XYV3YL4I.js").then(e=>({default:e.WidgetWalletPanel}))),Qt=pe(()=>import("./WalletPlaceholderPanel-Z4JCFCNV.js").then(e=>({default:e.WalletPlaceholderPanel}))),_t=({onSwapComplete:e,cardStyles:t,cardWidth:c})=>{let{baseToken:a,quoteToken:s,baseAmount:b,quoteAmount:k,isWrappingPair:N,isUnwrappingPair:W,isRegistryLoading:w}=fe(),{liquidityError:S,routingError:C,sizeCapError:I,stop:O,clear:r}=ue(),i=n(o=>o.view),{isTransitioning:d,isRecipientInputOpen:T,recipient:X,selectedChainFilterChainId:L}=n(Ut(o=>({isTransitioning:o.isTransitioning,isRecipientInputOpen:o.isRecipientInputOpen,recipient:o.recipient,selectedChainFilterChainId:o.selectedChainFilter?.chainId??null}))),u=qe(null),g=qe(null),[m,Y]=nt(null);Pe(),Re(()=>()=>{u.current&&clearTimeout(u.current),g.current&&clearTimeout(g.current)},[]),Re(()=>{n.getState().resetUI()},[]),Re(()=>{if(d)return u.current=setTimeout(()=>{n.getState().setIsTransitioning(!1),u.current=null},20),()=>{u.current&&(clearTimeout(u.current),u.current=null)}},[d]);let R=me((o,V="navigation")=>{g.current&&(clearTimeout(g.current),g.current=null,Y(null)),n.getState().view!=="swap"&&o!=="swap"?(n.getState().setView(o),n.getState().setIsTransitioning(!1)):n.getState().transitionToView(o,V)},[]),h=me(()=>{u.current&&(clearTimeout(u.current),u.current=null),g.current&&(clearTimeout(g.current),g.current=null);let o=n.getState().view;Y(o),n.getState().setChainFilter(null),n.getState().setView("swap"),n.getState().setIsTransitioning(!1),n.getState().resetAssetSelection(),g.current=setTimeout(()=>{Y(null),g.current=null},200)},[]),U=me(o=>{let re=i==="baseChainSelection"?"base":"quote";n.getState().setChainFilter({chainId:o,side:re}),n.getState().pushRecentChain(o),R(re==="base"?"baseSelection":"quoteSelection","chainSelection")},[i,R]),M=me(()=>{let o=n.getState().view;o==="baseSelection"?R("baseChainSelection","chainSelection"):o==="quoteSelection"&&R("quoteChainSelection","chainSelection")},[R]),j=me(()=>{O(),r()},[O,r]),G=a&&s?a.chainId===s.chainId:!0,H=()=>{switch(i){case"wallet":return"Wallet";case"baseSelection":return"Select Input Token";case"quoteSelection":return"Select Output Token";case"baseChainSelection":case"quoteChainSelection":return"Select Chain";default:return"Swap"}},{assetMenuVariant:B,widgetType:z,customWalletUI:q}=ge(),v=i==="baseSelection"||i==="quoteSelection",x=i==="baseChainSelection"||i==="quoteChainSelection",Z=B==="split"&&(z==="default"||z==="compact"),E=B==="split"&&(z==="horizontal"||z==="split"),$=B==="default",D=i==="swap"||v||x||i==="wallet",ee=m==="baseSelection"||m==="quoteSelection",Q=m==="baseChainSelection"||m==="quoteChainSelection",te=v||ee,ie=x||Q,y=v&&!d,J=x&&!d,ve=v?i:m,be=ve==="baseSelection"?"base":"quote",le=ve==="baseSelection"?s:a,xe=(x?i:m)==="baseChainSelection"?"base":"quote",ce=o=>({backgroundColor:"var(--widget-background)",opacity:o?1:0,transform:o?"translateY(0)":"translateY(6px)",transition:"opacity 200ms ease-in-out, transform 200ms ease-in-out"}),Ne=$&&(v||x||i==="wallet"||m!=null),we=w?p(at,{}):z==="horizontal"?p(de,{fallback:null,children:p(jt,{onSwapComplete:e,onSwapInitiated:j,onBackToSwap:E?h:void 0,onMoreChainsClick:E?M:void 0})}):z==="split"?p(de,{fallback:null,children:p($t,{onSwapComplete:e,onSwapInitiated:j,onBackToSwap:E?h:void 0,onMoreChainsClick:E?M:void 0})}):p(rt,{onSwapComplete:e,onSwapInitiated:j}),ke=t??{},Se=qe(null),[Ae,Ce]=nt(420);return Re(()=>{if(!Z)return;let o=Se.current;if(!o)return;let V=new ResizeObserver(re=>{for(let ft of re)Ce(ft.contentRect.height)});return V.observe(o),()=>V.disconnect()},[Z]),Z?We(Kt,{children:[We("div",{ref:Se,className:"flex flex-col w-full overflow-hidden transition-colors duration-300",style:{flex:"1 1 0",minWidth:0,...ke},children:[p(Be,{headerText:"Swap",onBackClick:h,isSameChain:G,isWrappingPair:N,isUnwrappingPair:W,hasLowLiquidity:S,hasInsufficientLiquidity:S,hasRoutingError:C,hasSizeCapError:I}),p("div",{className:"overflow-hidden",children:we})]}),(te||ie)&&p("div",{className:"flex flex-col overflow-hidden shrink-0",style:{width:c,height:`${Ae}px`,...ke,...ce((v||x)&&!d)},children:v||ee?p(de,{fallback:null,children:p(st,{toggle:h,side:be,otherAsset:le,onMoreChainsClick:M,selectedChainFilter:L})}):p(de,{fallback:null,children:p(dt,{toggle:h,side:xe,onChainSelect:U})})})]}):We("div",{className:"flex flex-col w-full",style:{overflow:"hidden",position:"relative"},children:[p(Be,{headerText:H(),onBackClick:h,isSameChain:G,isWrappingPair:N,isUnwrappingPair:W,hasLowLiquidity:S,hasInsufficientLiquidity:S,hasRoutingError:C,hasSizeCapError:I}),We("div",{className:"relative overflow-hidden",children:[D&&p("div",{className:"overflow-hidden",style:Ne?{pointerEvents:"none"}:void 0,children:we}),(i==="wallet"||m==="wallet")&&p("div",{className:"absolute inset-0 overflow-hidden",style:ce(i==="wallet"&&!d),children:p(de,{fallback:null,children:q==="none"?p(Qt,{}):p(Dt,{})})}),$&&te&&p("div",{className:"absolute inset-0 overflow-hidden",style:ce(y),children:p(de,{fallback:null,children:p(st,{toggle:h,side:be,otherAsset:le,onMoreChainsClick:M,selectedChainFilter:L})})}),$&&ie&&p("div",{className:"absolute inset-0 overflow-hidden",style:ce(J),children:p(de,{fallback:null,children:p(dt,{toggle:h,side:xe,onChainSelect:U})})})]})]})},lt=({onSwapComplete:e,defaultBaseToken:t,defaultQuoteToken:c,onBaseTokenChange:a,onQuoteTokenChange:s,cardStyles:b,cardWidth:k})=>{let{address:N}=_(),W=n(w=>w.recipient);return p(Oe,{defaultBaseToken:t,defaultQuoteToken:c,onBaseTokenChange:a,onQuoteTokenChange:s,children:p(Ie,{recipient:W,children:p(_t,{onSwapComplete:e,cardStyles:b,cardWidth:k})})})};import{createContext as Yt,useContext as Gt}from"react";var Ee={background:"#ffffff",foreground:"#0a0a0a",card:"#ffffff","card-foreground":"#0a0a0a",popover:"#ffffff","popover-foreground":"#0a0a0a",primary:"#171717","primary-foreground":"#fafafa",secondary:"#f5f5f5","secondary-foreground":"#171717",muted:"#f5f5f5","muted-foreground":"#737373",accent:"#f5f5f5","accent-foreground":"#171717",destructive:"#e7000b","destructive-foreground":"#ffffff",border:"#e5e5e5",input:"#e5e5e5",ring:"#a1a1a1",radius:"0.625rem","border-style":"dotted","status-pending":"#a1a1aa","status-received":"#f59e0b","status-completed":"#10b981","status-failed":"#ef4444"},he={background:"#0a0a0a",foreground:"#fafafa",card:"#171717","card-foreground":"#fafafa",popover:"#262626","popover-foreground":"#fafafa",primary:"#e5e5e5","primary-foreground":"#171717",secondary:"#262626","secondary-foreground":"#fafafa",muted:"#262626","muted-foreground":"#a1a1a1",accent:"#404040","accent-foreground":"#fafafa",destructive:"#ff6467","destructive-foreground":"#fafafa",border:"#282828",input:"#343434",ring:"#737373",radius:"0.625rem","border-style":"dotted","status-pending":"#a1a1aa","status-received":"#fbbf24","status-completed":"#2dd4bf","status-failed":"#fb7185"};function Fe(e){let t={"--widget-background":e.background,"--widget-foreground":e.foreground,"--widget-card":e.card,"--widget-card-foreground":e["card-foreground"],"--widget-popover":e.popover,"--widget-popover-foreground":e["popover-foreground"],"--widget-primary":e.primary,"--widget-primary-foreground":e["primary-foreground"],"--widget-secondary":e.secondary,"--widget-secondary-foreground":e["secondary-foreground"],"--widget-muted":e.muted,"--widget-muted-foreground":e["muted-foreground"],"--widget-accent":e.accent,"--widget-accent-foreground":e["accent-foreground"],"--widget-destructive":e.destructive,"--widget-destructive-foreground":e["destructive-foreground"],"--widget-border":e.border,"--widget-input":e.input,"--widget-ring":e.ring,"--widget-radius":e.radius,"--widget-border-style":e["border-style"]||"dotted"};return t["--widget-font-sans"]=e["font-sans"]||"inherit",t["--widget-font-mono"]=e["font-mono"]||"inherit",t["--widget-shadow-color"]=e["shadow-color"]||"oklch(0 0 0)",t["--widget-shadow-opacity"]=e["shadow-opacity"]||"0.1",t["--widget-shadow-blur"]=e["shadow-blur"]||"3px",t["--widget-shadow-spread"]=e["shadow-spread"]||"0px",t["--widget-shadow-offset-x"]=e["shadow-offset-x"]||"0",t["--widget-shadow-offset-y"]=e["shadow-offset-y"]||"1px",t["--widget-letter-spacing"]=e["letter-spacing"]||"normal",t["--widget-status-pending"]=e["status-pending"]||"#a1a1aa",t["--widget-status-received"]=e["status-received"]||"#fbbf24",t["--widget-status-completed"]=e["status-completed"]||"#2dd4bf",t["--widget-status-failed"]=e["status-failed"]||"#fb7185",t}import{jsx as Jt}from"react/jsx-runtime";var ct=Yt(he);function He({theme:e,children:t}){return Jt(ct.Provider,{value:e,children:t})}function Zt(){return Gt(ct)}import{jsx as K,jsxs as wt}from"react/jsx-runtime";var ei=[],ti=[],ii=[],pt=[],ri=`
3
3
  .aori-widget .text-2xs { font-size: 0.75rem; }
4
4
  .aori-widget .text-3xs { font-size: 0.68rem; }
5
5
  .aori-widget ::-webkit-scrollbar { width: 0px; height: 0px; display: none; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aori/mega-swap-widget",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Embeddable cross-chain swap widget powered by Aori",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -1,2 +0,0 @@
1
- "use client";
2
- "use client";import{a}from"./chunk-Z2BLIAFE.js";import"./chunk-JSWDMAZQ.js";import"./chunk-CHDFHEPH.js";import"./chunk-46H44R7V.js";import"./chunk-73CB2I7U.js";export{a as default};
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
- "use client";var _chunkE44WNKS4cjs = require('./chunk-E44WNKS4.cjs');require('./chunk-537OMWA3.cjs');require('./chunk-BX3KCZRT.cjs');require('./chunk-34N36GUD.cjs');require('./chunk-T3I3AJXV.cjs');exports.default = _chunkE44WNKS4cjs.a;
@@ -1,2 +0,0 @@
1
- "use client";
2
- "use client";import{a}from"./chunk-TWJY6EY4.js";import"./chunk-CHDFHEPH.js";import"./chunk-73CB2I7U.js";export{a as default};
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
- "use client";var _chunkC3X6NJIBcjs = require('./chunk-C3X6NJIB.cjs');require('./chunk-BX3KCZRT.cjs');require('./chunk-T3I3AJXV.cjs');exports.default = _chunkC3X6NJIBcjs.a;