@aori/mega-swap-widget 0.1.9 → 0.1.11

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.
@@ -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 _chunk46JMXEHJcjs = require('./chunk-46JMXEHJ.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}=_chunk46JMXEHJcjs.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)}};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{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";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,_e as n,Gt as o,an as p,Yt as q,cn as r,er as s,tr as t,rr as u,nr as v,sr as w,Ha as x,ri as y};
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } 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; } var _class;"use client";
2
- var _chunkREBGSW5Kcjs = require('./chunk-REBGSW5K.cjs');var _chunkSGTI7NXZcjs = require('./chunk-SGTI7NXZ.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 _react2 = _interopRequireDefault(_react);var _shallow = require('zustand/react/shallow');var _jsxruntime = require('react/jsx-runtime');var Yt=new Set([10,8453,42161,534352,59144,324]),Zt=4e-4,Jt=.003;async function Xt(e){let t=Yt.has(e)?Zt:Jt;try{let b=await _chunkK3RTTHBScjs.H.call(void 0, e).getGasPrice()*350000n*3n/2n,W=Number(b)/1e18;return Math.max(W,t)}catch (e2){return t}}var ei=({onSwapComplete:e,onSwapInitiated:t})=>{let{web3ConnectionType:l,hasConnectHandler:r,lockBase:o,lockQuote:f,disableInverting:b,tokenDisplay:W,tokenBadgeOrientation:B,widgetType:y}=_chunkD7GULMHEcjs.b.call(void 0, ),{effectiveInputTokens:x,effectiveOutputTokens:E}=_chunkTWVI6PZScjs.a.call(void 0, ),P=x.length===1,O=E.length===1,q=W==="pill"||W==="ghost",C=y==="compact",Q=C?"px-4 pt-3 pb-1":"px-4 pt-4 pb-2",p=C?"px-4 pt-4 pb-1":"px-4 pt-6 pb-2",{baseToken:i,quoteToken:a,baseAmount:w,quoteAmount:k,isBaseGasToken:m,isQuoteGasToken:I,isWrappingPair:g,isUnwrappingPair:S,baseBalance:N,quoteBalance:L,setBaseAmount:U,setQuoteAmount:v,swapTokens:_,clearForm:H}=_chunkPSCWQFVYcjs.e.call(void 0, ),{rfqQuote:G,status:V,handleInputChange:h,ensureForParams:de,stop:D,clear:z,refresh:K}=_chunkSGTI7NXZcjs.e.call(void 0, ),{address:M}=_chunk34N36GUDcjs.a.call(void 0, ),{openConnectModal:te}=_chunkSGTI7NXZcjs.g.call(void 0, ),{isRecipientInputOpen:ie,txStatus:re}=_chunkD7GULMHEcjs.d.call(void 0, _shallow.useShallow.call(void 0, R=>({isRecipientInputOpen:R.isRecipientInputOpen,txStatus:R.txStatus}))),[T,le]=_react.useState.call(void 0, null),[$,ae]=_react.useState.call(void 0, null),oe=_react.useRef.call(void 0, !1),A=!1,he=V==="polling"||G!==null||T!==null,fe=_react.useRef.call(void 0, "");_react.useEffect.call(void 0, ()=>{let R=`${_optionalChain([i, 'optionalAccess', _2 => _2.address])}-${_optionalChain([i, 'optionalAccess', _3 => _3.chainId])}|${_optionalChain([a, 'optionalAccess', _4 => _4.address])}-${_optionalChain([a, 'optionalAccess', _5 => _5.chainId])}`;fe.current&&fe.current!==R&&(T!==null||G!==null||V==="polling")&&(le(null),ae(null),z(),H()),fe.current=R},[_optionalChain([i, 'optionalAccess', _6 => _6.address]),_optionalChain([i, 'optionalAccess', _7 => _7.chainId]),_optionalChain([a, 'optionalAccess', _8 => _8.address]),_optionalChain([a, 'optionalAccess', _9 => _9.chainId]),T,G,V,z,H]);let Me=_react.useRef.call(void 0, !1),[Ce,ne]=_react.useState.call(void 0, 1);_react.useEffect.call(void 0, ()=>{let R=T==="trackingTx"&&!!$&&!!i&&!!a&&!!w&&!!k;if(Me.current!==R){ne(0);let Z=setTimeout(()=>ne(1),50);return Me.current=R,()=>clearTimeout(Z)}},[T,$,i,a,w,k]);let Te=_react.useRef.call(void 0, T),[Re,ve]=_react.useState.call(void 0, 1);_react.useEffect.call(void 0, ()=>{if(Te.current!==T){ve(0);let R=setTimeout(()=>ve(1),50);return Te.current=T,()=>clearTimeout(R)}},[T]);let Ie=_react.useMemo.call(void 0, ()=>!i||!a||typeof w!="number"||!k||!M||parseFloat(N.formatted)<w?null:{base:i,quote:a,baseAmount:w,quoteAmount:k,userAddress:M},[i,a,w,k,M,N.formatted]),Be=_react.useCallback.call(void 0, R=>{ae(R),_chunkD7GULMHEcjs.d.getState().startTracking(R)},[]),Ee=_react.useCallback.call(void 0, ()=>{oe.current=!0,K()},[K]);_react.useEffect.call(void 0, ()=>{if(T===null&&!(!i||!a)){if(!w||w<=0){h({amount:null,inputToken:i,outputToken:a,setOutputAmount:v});return}if(g||S){v(w);return}h({amount:w,inputToken:i,outputToken:a,setOutputAmount:v})}},[T,w,i,a,g,S,h,v]);let c=_react.useCallback.call(void 0, ()=>{_chunkD7GULMHEcjs.d.getState().setView("baseSelection")},[]),Y=_react.useCallback.call(void 0, ()=>{_chunkD7GULMHEcjs.d.getState().setView("quoteSelection")},[]),ce=_react.useCallback.call(void 0, ()=>{_(),v(null)},[_,v]),qe=_react.useCallback.call(void 0, async()=>{if(!N.formatted||!i||!a)return;let R=parseFloat(N.formatted);if(!R||R<=0)return;let Z;if(m){let Le=await Xt(i.chainId);if(Z=Math.max(0,R-Le),Z<=0)return}else Z=R*.9999999999;g||S?(U(Z),v(Z),z()):(U(Z),v(null),de({inputToken:i,outputToken:a,inputAmount:Z.toString(),setOutputAmount:Le=>v(Le)}))},[N.formatted,i,a,m,g,S,U,v,z,de]),Nt=_react.useCallback.call(void 0, ()=>{z(),H()},[z,H]),Je=N.formatted?parseFloat(N.formatted):null,At=!!(w||k),Wt=_optionalChain([i, 'optionalAccess', _10 => _10.price])&&w?`$${(i.price*w).toFixed(2)}`:"$0.00",Pt=_optionalChain([a, 'optionalAccess', _11 => _11.price])&&k?`$${(a.price*k).toFixed(2)}`:"$0.00",Xe=T==="trackingTx"&&!!$&&!!i&&!!a&&!!w&&!!k;return _jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full",children:[_jsxruntime.jsx.call(void 0, "div",{style:{opacity:Ce,transition:"opacity 0.3s ease-out"},children:Xe&&$&&i&&a&&w&&k?_jsxruntime.jsx.call(void 0, "div",{className:"overflow-hidden",children:_jsxruntime.jsx.call(void 0, _chunkSGTI7NXZcjs.x,{orderHash:$,base:i,quote:a,baseAmount:w,quoteAmount:k,status:re})}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "div",{className:`relative ${Q}`,style:{borderBottom:"1px solid var(--widget-border)"},children:[q?C?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 mb-2 ${B==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkSGTI7NXZcjs.i,{toggle:c,side:"base",asset:i,isPlacingOrder:A||o||P,hideDropdown:P}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkSGTI7NXZcjs.h,{side:"base",asset:_nullishCoalesce(i, () => (null)),otherAsset:_nullishCoalesce(a, () => (null)),isPlacingOrder:A,isWrappingPair:g,isUnwrappingPair:S})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${B==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkSGTI7NXZcjs.i,{toggle:c,side:"base",asset:i,isPlacingOrder:A||o||P,hideDropdown:P}),_jsxruntime.jsx.call(void 0, _chunkSGTI7NXZcjs.h,{side:"base",asset:_nullishCoalesce(i, () => (null)),otherAsset:_nullishCoalesce(a, () => (null)),isPlacingOrder:A,isWrappingPair:g,isUnwrappingPair:S})]}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkSGTI7NXZcjs.i,{toggle:c,side:"base",asset:i,isPlacingOrder:A||o||P,hideDropdown:P}),_jsxruntime.jsx.call(void 0, _chunkSGTI7NXZcjs.h,{side:"base",asset:_nullishCoalesce(i, () => (null)),otherAsset:_nullishCoalesce(a, () => (null)),isPlacingOrder:A,isWrappingPair:g,isUnwrappingPair:S})]}),_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:Wt}),M&&Je!==null&&Je>0&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:qe,disabled:A,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"})]})]}),!b&&_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:ce,disabled:he,"aria-label":"Swap input and output tokens",className:`flex h-8 w-8 items-center justify-center rounded-full transition-colors bg-(--widget-card) ${he?"cursor-not-allowed opacity-40 pointer-events-none":"cursor-pointer 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, _chunkSGTI7NXZcjs.k,{className:"w-3.5 h-3.5"})})}),_jsxruntime.jsxs.call(void 0, "div",{className:`relative ${p}`,children:[q?C?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${B==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkSGTI7NXZcjs.i,{toggle:Y,side:"quote",asset:a,isPlacingOrder:A||f||O,hideDropdown:O}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkSGTI7NXZcjs.h,{side:"quote",asset:_nullishCoalesce(a, () => (null)),otherAsset:_nullishCoalesce(i, () => (null)),isPlacingOrder:A,isWrappingPair:g,isUnwrappingPair:S})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${B==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkSGTI7NXZcjs.i,{toggle:Y,side:"quote",asset:a,isPlacingOrder:A||f||O,hideDropdown:O}),_jsxruntime.jsx.call(void 0, _chunkSGTI7NXZcjs.h,{side:"quote",asset:_nullishCoalesce(a, () => (null)),otherAsset:_nullishCoalesce(i, () => (null)),isPlacingOrder:A,isWrappingPair:g,isUnwrappingPair:S})]}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkSGTI7NXZcjs.i,{toggle:Y,side:"quote",asset:a,isPlacingOrder:A||f||O,hideDropdown:O}),_jsxruntime.jsx.call(void 0, _chunkSGTI7NXZcjs.h,{side:"quote",asset:_nullishCoalesce(a, () => (null)),otherAsset:_nullishCoalesce(i, () => (null)),isPlacingOrder:A,isWrappingPair:g,isUnwrappingPair:S})]}),_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:Pt}),At&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Nt,disabled:A,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"})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-row items-center w-full overflow-hidden",style:{borderTop:ie?"1px solid var(--widget-border)":"none",maxHeight:ie?"60px":"0px",opacity:ie?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:_jsxruntime.jsx.call(void 0, _chunkSGTI7NXZcjs.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, _chunkREBGSW5Kcjs.a,{})})]})}),_jsxruntime.jsx.call(void 0, "div",{className:`relative ${Xe?"px-0 pb-4":"px-4"} ${C?"py-2":"py-4"}`,style:{opacity:Re,transition:"opacity 0.3s ease-out"},children:M&&i&&a&&w&&w>0?_jsxruntime.jsx.call(void 0, _chunkSGTI7NXZcjs.w,{base:i,baseAmount:w,quote:a,quoteAmount:_nullishCoalesce(k, () => (0)),userAddress:M,isWrappingPair:g,isUnwrappingPair:S,isBaseGasToken:m,isQuoteGasToken:I,reviewActionProps:Ie,reviewState:T,setReviewState:le,trackedOrderHash:$,setTrackedOrderHash:ae,onSwapComplete:e,onSwapInitiated:t,onOrderSubmitted:Be,onStaleQuoteRestart:Ee,txStatus:re}):!M&&r?_jsxruntime.jsx.call(void 0, "button",{onClick:()=>te(),className:`w-full ${C?"py-2":"py-3"} text-sm font-sans 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"}):_jsxruntime.jsx.call(void 0, "button",{disabled:!0,className:`w-full ${C?"py-2":"py-3"} text-sm font-sans 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:M?"Enter Amount":"Connect Wallet"})})]})},ht=ei;var vt=()=>_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"relative px-4 pt-4 pb-2",style:{borderBottom:"1px solid var(--widget-border)"},children:[_jsxruntime.jsx.call(void 0, "div",{className:"h-12 w-full animate-pulse",style:{backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-2 h-20 w-2/3 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-1 mb-1 flex w-full items-center justify-between",children:_jsxruntime.jsx.call(void 0, "div",{className:"h-4 w-12 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.4,borderRadius:"0.25rem"}})})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex justify-center -my-4 relative z-10",children:_jsxruntime.jsx.call(void 0, "div",{className:"h-8 w-8",style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)",borderRadius:"9999px"}})}),_jsxruntime.jsxs.call(void 0, "div",{className:"relative px-4 pt-6 pb-2",children:[_jsxruntime.jsx.call(void 0, "div",{className:"h-12 w-full animate-pulse",style:{backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-2 h-20 w-2/3 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-1 mb-1 flex w-full items-center justify-between",children:_jsxruntime.jsx.call(void 0, "div",{className:"h-4 w-12 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.4,borderRadius:"0.25rem"}})})]}),_jsxruntime.jsx.call(void 0, "div",{className:"px-4",style:{height:"28px",borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"}}),_jsxruntime.jsx.call(void 0, "div",{className:"relative px-4 py-4",children:_jsxruntime.jsx.call(void 0, "div",{className:"w-full animate-pulse",style:{height:"44px",backgroundColor:"var(--widget-secondary)",borderRadius:"var(--widget-radius)",opacity:.6}})})]});var ri=({targetText:e,isError:t})=>{let{displayText:l,suffix:r,characterColors:o}=_chunkK3RTTHBScjs.y.call(void 0, e,t);return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[l.split("").map((f,b)=>_jsxruntime.jsx.call(void 0, "span",{style:o[b]?{color:"var(--widget-destructive)"}:void 0,children:f},b)),_jsxruntime.jsx.call(void 0, "span",{style:{color:t?"var(--widget-destructive)":"var(--widget-muted-foreground)",opacity:t?.5:1},children:r})]})},ai=({headerText:e,onBackClick:t,isSameChain:l,isWrappingPair:r,isUnwrappingPair:o,hasLowLiquidity:f,hasInsufficientLiquidity:b,hasRoutingError:W,hasSizeCapError:B,hasInsufficientBalance:y})=>{let x=_chunkD7GULMHEcjs.d.call(void 0, h=>h.view),{isRecipientInputOpen:E,hasAllowanceError:P,hoveredChainName:O,isTrackingTx:q,txStatus:C,walletTab:Q}=_chunkD7GULMHEcjs.d.call(void 0, _shallow.useShallow.call(void 0, h=>({isRecipientInputOpen:h.isRecipientInputOpen,hasAllowanceError:h.hasAllowanceError,hoveredChainName:h.hoveredChainName,isTrackingTx:h.isTrackingTx,txStatus:h.txStatus,walletTab:h.walletTab}))),{swapHeaderVariant:p,walletButtonEnabled:i}=_chunkD7GULMHEcjs.b.call(void 0, ),{isConnected:a}=_chunk34N36GUDcjs.a.call(void 0, ),[w,k]=_react.useState.call(void 0, !1);_react.useEffect.call(void 0, ()=>k(!0),[]);let[m,I]=_react.useState.call(void 0, !1),[g,S]=_react.useState.call(void 0, !1),N=`${x}-${m}-${g}-${E}-${O||"none"}`,U=(()=>{if(q&&C)switch(C){case"pending":return"Trade Pending";case"received":return"Trade Received";case"completed":return"Trade Filled";case"failed":return"Trade Failed";case"cancelled":return"Trade Cancelled";default:return"Processing Trade"}if(O&&(x==="baseSelection"||x==="quoteSelection"||x==="baseChainSelection"||x==="quoteChainSelection"))return O;if(x==="swap"&&g)return"View Transaction History";if(x==="swap"&&m)return E?"Remove Custom Recipient":"Add Custom Recipient";switch(x){case"wallet":return"Wallet";case"activity":return"Activity";case"baseSelection":return"Select Source Token";case"quoteSelection":return"Select Destination Token";case"baseChainSelection":return"Select Source Chain";case"quoteChainSelection":return"Select Destination Chain";default:if(x==="swap"){if(P&&!r&&!o)return"Allowance check failed";if(B&&!r&&!o)return"Size limit exceeded";if(b&&!r&&!o)return"Insufficient Liquidity";if(W&&!r&&!o)return"Route Not Found";if(f&&!r&&!o)return"High Price Impact";if(y&&!r&&!o)return"Insufficient Balance"}return l&&!r&&!o?"Swap":r?"Wrap":o?"Unwrap":e}})(),v=!q&&x==="swap"&&!m&&(P&&!r&&!o||B&&!r&&!o||b&&!r&&!o||W&&!r&&!o||f&&!r&&!o||y&&!r&&!o),_={pending:"var(--widget-primary)",received:"var(--widget-primary)",completed:"var(--widget-status-completed)",failed:"var(--widget-status-failed)",cancelled:"var(--widget-status-failed)"},H=()=>!q||!C?null:_nullishCoalesce(_[C], () => (null)),G=()=>q?_jsxruntime.jsx.call(void 0, "button",{onClick:()=>_optionalChain([_chunkD7GULMHEcjs.d, 'access', _12 => _12.getState, 'call', _13 => _13(), 'access', _14 => _14.exitHandler, 'optionalCall', _15 => _15()]),"aria-label":"Close trade status",className:"size-4 -translate-y-0.5 flex cursor-pointer items-center justify-center transition-colors text-(--widget-muted-foreground) opacity-60 hover:text-(--widget-foreground) hover:opacity-100",children:_jsxruntime.jsxs.call(void 0, "svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M18 6L6 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),_jsxruntime.jsx.call(void 0, "path",{d:"M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}):x==="swap"?_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[i&&w&&a&&_jsxruntime.jsx.call(void 0, "button",{onClick:()=>_chunkD7GULMHEcjs.d.getState().setView("activity"),onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1),"aria-label":"Open activity",className:"size-4 -translate-y-0.5 flex cursor-pointer items-center justify-center rounded-full transition-colors text-(--widget-muted-foreground) opacity-60 hover:text-(--widget-foreground) hover:opacity-100",children:_jsxruntime.jsxs.call(void 0, "svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M12 8V12L14.5 14.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),_jsxruntime.jsx.call(void 0, "path",{d:"M3.05 11A9 9 0 1 1 3.05 13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),_jsxruntime.jsx.call(void 0, "path",{d:"M1 7.5L3.05 11L6.5 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),_jsxruntime.jsx.call(void 0, "button",{onClick:()=>_chunkD7GULMHEcjs.d.getState().toggleRecipientInput(),onMouseEnter:()=>I(!0),onMouseLeave:()=>I(!1),"aria-label":E?"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 ${E?"text-(--widget-destructive) opacity-80":"text-(--widget-muted-foreground) opacity-60"}`,children:_jsxruntime.jsxs.call(void 0, "svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "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"}),_jsxruntime.jsx.call(void 0, "path",{d:"M6 16.5H8",stroke:"currentColor",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"butt",strokeLinejoin:"miter"}),_jsxruntime.jsx.call(void 0, "path",{d:"M10.5 16.5H14.5",stroke:"currentColor",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"butt",strokeLinejoin:"miter"}),_jsxruntime.jsx.call(void 0, "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"}),_jsxruntime.jsxs.call(void 0, "g",{style:{transform:`rotate(${E?"45deg":"0deg"})`,transformOrigin:"18.75px 6.75px",transition:"transform 150ms ease-out"},children:[_jsxruntime.jsx.call(void 0, "path",{d:"M15 6.75H22.5",stroke:"currentColor",strokeWidth:"1.5"}),_jsxruntime.jsx.call(void 0, "path",{d:"M18.75 10.5V3",stroke:"currentColor",strokeWidth:"1.5"})]})]})})]}):_jsxruntime.jsxs.call(void 0, "button",{onClick:()=>t?t():_chunkD7GULMHEcjs.d.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:[_jsxruntime.jsx.call(void 0, "span",{className:"pr-1",children:"\u2190"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",children:"Back"})]}),V=H();return p==="none"?null:_jsxruntime.jsxs.call(void 0, "div",{className:"w-full pt-3 px-2 font-sans text-base flex flex-row justify-between h-6 shrink-0",children:[x==="wallet"?_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-1 font-sans uppercase -translate-y-0.5 text-xs",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>_chunkD7GULMHEcjs.d.getState().setWalletTab("wallet"),className:"cursor-pointer transition-colors",style:{color:Q==="wallet"?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:_jsxruntime.jsx.call(void 0, "span",{children:"Wallet"})}),_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>_chunkD7GULMHEcjs.d.getState().setWalletTab("activity"),className:"cursor-pointer transition-colors",style:{color:Q==="activity"?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:"Activity"})]}):_jsxruntime.jsx.call(void 0, "div",{className:"font-sans uppercase -translate-y-0.5 text-xs flex items-center",children:_jsxruntime.jsx.call(void 0, "span",{className:"relative",style:{color:V||"var(--widget-foreground)"},children:_jsxruntime.jsx.call(void 0, ri,{targetText:U,isError:_nullishCoalesce(v, () => (!1))})},N)}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-row items-center",children:G()})]})},_e=ai;var yt=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./AssetSelectionMenu-TPSIEBBB.cjs")))),xt=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./ChainSelectionMenu-UNMEPKRI.cjs")))),si=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./SwapFormHorizontal-B2H57CEQ.cjs")))),di=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./SwapFormSplit-LB6JXG4G.cjs")))),li=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./WidgetWalletPanel-HH26O3HT.cjs"))).then(e=>({default:e.WidgetWalletPanel}))),ci=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./WalletPlaceholderPanel-TTONBBI4.cjs"))).then(e=>({default:e.WalletPlaceholderPanel}))),gi=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./WidgetWalletTradeHistory-NL23HIOJ.cjs"))).then(e=>({default:e.WidgetWalletTradeHistory}))),pi=({onSwapComplete:e,cardStyles:t,cardWidth:l})=>{let{baseToken:r,quoteToken:o,baseAmount:f,quoteAmount:b,baseBalance:W,isWrappingPair:B,isUnwrappingPair:y,isRegistryLoading:x}=_chunkPSCWQFVYcjs.e.call(void 0, ),{liquidityError:E,routingError:P,sizeCapError:O,stop:q,clear:C}=_chunkSGTI7NXZcjs.e.call(void 0, ),Q=!!(f&&W.formatted&&parseFloat(W.formatted)<f),p=_chunkD7GULMHEcjs.d.call(void 0, c=>c.view),{isTransitioning:i,isRecipientInputOpen:a,recipient:w,selectedChainFilterChainId:k}=_chunkD7GULMHEcjs.d.call(void 0, _shallow.useShallow.call(void 0, c=>({isTransitioning:c.isTransitioning,isRecipientInputOpen:c.isRecipientInputOpen,recipient:c.recipient,selectedChainFilterChainId:_nullishCoalesce(_optionalChain([c, 'access', _16 => _16.selectedChainFilter, 'optionalAccess', _17 => _17.chainId]), () => (null))}))),m=_react.useRef.call(void 0, null),I=_react.useRef.call(void 0, null),[g,S]=_react.useState.call(void 0, null);_chunkSGTI7NXZcjs.c.call(void 0, ),_react.useEffect.call(void 0, ()=>()=>{m.current&&clearTimeout(m.current),I.current&&clearTimeout(I.current)},[]),_react.useEffect.call(void 0, ()=>{_chunkD7GULMHEcjs.d.getState().resetUI()},[]),_react.useEffect.call(void 0, ()=>{if(i)return m.current=setTimeout(()=>{_chunkD7GULMHEcjs.d.getState().setIsTransitioning(!1),m.current=null},20),()=>{m.current&&(clearTimeout(m.current),m.current=null)}},[i]);let N=_react.useCallback.call(void 0, (c,Y="navigation")=>{I.current&&(clearTimeout(I.current),I.current=null,S(null)),_chunkD7GULMHEcjs.d.getState().view!=="swap"&&c!=="swap"?(_chunkD7GULMHEcjs.d.getState().setView(c),_chunkD7GULMHEcjs.d.getState().setIsTransitioning(!1)):_chunkD7GULMHEcjs.d.getState().transitionToView(c,Y)},[]),L=_react.useCallback.call(void 0, ()=>{m.current&&(clearTimeout(m.current),m.current=null),I.current&&(clearTimeout(I.current),I.current=null);let c=_chunkD7GULMHEcjs.d.getState().view;S(c),_chunkD7GULMHEcjs.d.getState().setChainFilter(null),_chunkD7GULMHEcjs.d.getState().setView("swap"),_chunkD7GULMHEcjs.d.getState().setIsTransitioning(!1),_chunkD7GULMHEcjs.d.getState().resetAssetSelection(),I.current=setTimeout(()=>{S(null),I.current=null},200)},[]),U=_react.useCallback.call(void 0, c=>{let ce=p==="baseChainSelection"?"base":"quote";_chunkD7GULMHEcjs.d.getState().setChainFilter({chainId:c,side:ce}),_chunkD7GULMHEcjs.d.getState().pushRecentChain(c),N(ce==="base"?"baseSelection":"quoteSelection","chainSelection")},[p,N]),v=_react.useCallback.call(void 0, ()=>{let c=_chunkD7GULMHEcjs.d.getState().view;c==="baseSelection"?N("baseChainSelection","chainSelection"):c==="quoteSelection"&&N("quoteChainSelection","chainSelection")},[N]),_=_react.useCallback.call(void 0, ()=>{q(),C()},[q,C]),H=r&&o?r.chainId===o.chainId:!0,G=()=>{switch(p){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:V,widgetType:h,customWalletUI:de}=_chunkD7GULMHEcjs.b.call(void 0, ),D=p==="baseSelection"||p==="quoteSelection",z=p==="baseChainSelection"||p==="quoteChainSelection",K=V==="split"&&(h==="default"||h==="compact"),M=V==="split"&&(h==="horizontal"||h==="split"),te=V==="default",ie=p==="swap"||D||z||p==="wallet"||p==="activity",re=g==="baseSelection"||g==="quoteSelection",T=g==="baseChainSelection"||g==="quoteChainSelection",le=D||re,$=z||T,ae=D&&!i,oe=z&&!i,A=D?p:g,he=A==="baseSelection"?"base":"quote",fe=A==="baseSelection"?o:r,Ce=(z?p:g)==="baseChainSelection"?"base":"quote",ne=c=>({backgroundColor:"var(--widget-background)",opacity:c?1:0,transform:c?"translateY(0)":"translateY(6px)",transition:"opacity 200ms ease-in-out, transform 200ms ease-in-out"}),Te=te&&(D||z||p==="wallet"||p==="activity"||g!=null),Re=x?_jsxruntime.jsx.call(void 0, vt,{}):h==="horizontal"?_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, si,{onSwapComplete:e,onSwapInitiated:_,onBackToSwap:M?L:void 0,onMoreChainsClick:M?v:void 0})}):h==="split"?_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, di,{onSwapComplete:e,onSwapInitiated:_,onBackToSwap:M?L:void 0,onMoreChainsClick:M?v:void 0})}):_jsxruntime.jsx.call(void 0, ht,{onSwapComplete:e,onSwapInitiated:_}),ve=_nullishCoalesce(t, () => ({})),Ie=_react.useRef.call(void 0, null),[Be,Ee]=_react.useState.call(void 0, 420);return _react.useEffect.call(void 0, ()=>{if(!K)return;let c=Ie.current;if(!c)return;let Y=new ResizeObserver(ce=>{for(let qe of ce)Ee(qe.contentRect.height)});return Y.observe(c),()=>Y.disconnect()},[K]),K?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "div",{ref:Ie,className:"flex flex-col w-full overflow-hidden transition-colors duration-300",style:{flex:"1 1 0",minWidth:0,...ve},children:[_jsxruntime.jsx.call(void 0, _e,{headerText:"Swap",onBackClick:L,isSameChain:H,isWrappingPair:B,isUnwrappingPair:y,hasLowLiquidity:E,hasInsufficientLiquidity:E,hasRoutingError:P,hasSizeCapError:O,hasInsufficientBalance:Q}),_jsxruntime.jsx.call(void 0, "div",{className:"overflow-hidden",children:Re})]}),(le||$)&&_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col overflow-hidden shrink-0",style:{width:l,height:`${Be}px`,...ve,...ne((D||z)&&!i)},children:D||re?_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, yt,{toggle:L,side:he,otherAsset:fe,onMoreChainsClick:v,selectedChainFilter:k})}):_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, xt,{toggle:L,side:Ce,onChainSelect:U})})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full",style:{overflow:"hidden",position:"relative"},children:[_jsxruntime.jsx.call(void 0, _e,{headerText:G(),onBackClick:L,isSameChain:H,isWrappingPair:B,isUnwrappingPair:y,hasLowLiquidity:E,hasInsufficientLiquidity:E,hasRoutingError:P,hasSizeCapError:O,hasInsufficientBalance:Q}),_jsxruntime.jsxs.call(void 0, "div",{className:"relative overflow-hidden",children:[ie&&_jsxruntime.jsx.call(void 0, "div",{className:"overflow-hidden",style:Te?{pointerEvents:"none"}:void 0,children:Re}),(p==="wallet"||g==="wallet")&&_jsxruntime.jsx.call(void 0, "div",{className:"absolute inset-0 overflow-hidden z-20",style:ne(p==="wallet"&&!i),children:_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:de==="none"?_jsxruntime.jsx.call(void 0, ci,{}):_jsxruntime.jsx.call(void 0, li,{})})}),(p==="activity"||g==="activity")&&_jsxruntime.jsx.call(void 0, "div",{className:"absolute inset-0 overflow-y-auto z-20",style:ne(p==="activity"&&!i),children:_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, gi,{isActive:p==="activity"})})}),te&&le&&_jsxruntime.jsx.call(void 0, "div",{className:"absolute inset-0 overflow-hidden z-20",style:ne(ae),children:_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, yt,{toggle:L,side:he,otherAsset:fe,onMoreChainsClick:v,selectedChainFilter:k})})}),te&&$&&_jsxruntime.jsx.call(void 0, "div",{className:"absolute inset-0 overflow-hidden z-20",style:ne(oe),children:_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, xt,{toggle:L,side:Ce,onChainSelect:U})})})]})]})},kt=({onSwapComplete:e,defaultBaseToken:t,defaultQuoteToken:l,onBaseTokenChange:r,onQuoteTokenChange:o,cardStyles:f,cardWidth:b})=>{let{address:W}=_chunk34N36GUDcjs.a.call(void 0, ),B=_chunkD7GULMHEcjs.d.call(void 0, y=>y.recipient);return _jsxruntime.jsx.call(void 0, _chunkPSCWQFVYcjs.d,{defaultBaseToken:t,defaultQuoteToken:l,onBaseTokenChange:r,onQuoteTokenChange:o,children:_jsxruntime.jsx.call(void 0, _chunkSGTI7NXZcjs.d,{recipient:B,children:_jsxruntime.jsx.call(void 0, pi,{onSwapComplete:e,cardStyles:f,cardWidth:b})})})};var Qe={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"},Se= exports.defaultDarkTheme ={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 Ge(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}var St=_react.createContext.call(void 0, Se);function Ke({theme:e,children:t}){return _jsxruntime.jsx.call(void 0, St.Provider,{value:e,children:t})}function mi(){return _react.useContext.call(void 0, St)}var bi=[],yi=[],xi=[],Tt=[],ki=[],Si=[],Ci=`
2
+ var _chunkXTJC3IX6cjs = require('./chunk-XTJC3IX6.cjs');var _chunk46JMXEHJcjs = require('./chunk-46JMXEHJ.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 _react2 = _interopRequireDefault(_react);var _shallow = require('zustand/react/shallow');var _jsxruntime = require('react/jsx-runtime');var Jt=new Set([10,8453,42161,534352,59144,324]),Xt=4e-4,ei=.003;async function ti(e){let t=Jt.has(e)?Xt:ei;try{let u=await _chunkK3RTTHBScjs.H.call(void 0, e).getGasPrice()*350000n*3n/2n,M=Number(u)/1e18;return Math.max(M,t)}catch (e2){return t}}var ii=({onSwapSubmitted:e,onSwapComplete:t,onSwapInitiated:d})=>{let{web3ConnectionType:o,hasConnectHandler:n,lockBase:h,lockQuote:u,disableInverting:M,tokenDisplay:F,tokenBadgeOrientation:z,widgetType:c}=_chunkD7GULMHEcjs.b.call(void 0, ),{effectiveInputTokens:H,effectiveOutputTokens:V}=_chunkTWVI6PZScjs.a.call(void 0, ),T=H.length===1,I=V.length===1,E=F==="pill"||F==="ghost",A=c==="compact",K=A?"px-4 pt-3 pb-1":"px-4 pt-4 pb-2",w=A?"px-4 pt-4 pb-1":"px-4 pt-6 pb-2",{baseToken:i,quoteToken:r,baseAmount:f,quoteAmount:b,isBaseGasToken:v,isQuoteGasToken:R,isWrappingPair:p,isUnwrappingPair:S,baseBalance:W,quoteBalance:B,setBaseAmount:U,setQuoteAmount:y,swapTokens:_,clearForm:D}=_chunkPSCWQFVYcjs.e.call(void 0, ),{rfqQuote:G,status:x,handleInputChange:q,ensureForParams:le,stop:Q,clear:P,refresh:Y}=_chunk46JMXEHJcjs.e.call(void 0, ),{address:O}=_chunk34N36GUDcjs.a.call(void 0, ),{openConnectModal:ie}=_chunk46JMXEHJcjs.g.call(void 0, ),{isRecipientInputOpen:re,txStatus:ae}=_chunkD7GULMHEcjs.d.call(void 0, _shallow.useShallow.call(void 0, C=>({isRecipientInputOpen:C.isRecipientInputOpen,txStatus:C.txStatus}))),[k,ce]=_react.useState.call(void 0, null),[$,oe]=_react.useState.call(void 0, null),ne=_react.useRef.call(void 0, !1),N=!1,ve=x==="polling"||G!==null||k!==null,me=_react.useRef.call(void 0, "");_react.useEffect.call(void 0, ()=>{let C=`${_optionalChain([i, 'optionalAccess', _2 => _2.address])}-${_optionalChain([i, 'optionalAccess', _3 => _3.chainId])}|${_optionalChain([r, 'optionalAccess', _4 => _4.address])}-${_optionalChain([r, 'optionalAccess', _5 => _5.chainId])}`;me.current&&me.current!==C&&(k!==null||G!==null||x==="polling")&&(ce(null),oe(null),P(),D()),me.current=C},[_optionalChain([i, 'optionalAccess', _6 => _6.address]),_optionalChain([i, 'optionalAccess', _7 => _7.chainId]),_optionalChain([r, 'optionalAccess', _8 => _8.address]),_optionalChain([r, 'optionalAccess', _9 => _9.chainId]),k,G,x,P,D]);let Be=_react.useRef.call(void 0, !1),[Te,se]=_react.useState.call(void 0, 1);_react.useEffect.call(void 0, ()=>{let C=k==="trackingTx"&&!!$&&!!i&&!!r&&!!f&&!!b;if(Be.current!==C){se(0);let J=setTimeout(()=>se(1),50);return Be.current=C,()=>clearTimeout(J)}},[k,$,i,r,f,b]);let Ie=_react.useRef.call(void 0, k),[Re,be]=_react.useState.call(void 0, 1);_react.useEffect.call(void 0, ()=>{if(Ie.current!==k){be(0);let C=setTimeout(()=>be(1),50);return Ie.current=k,()=>clearTimeout(C)}},[k]);let Ne=_react.useMemo.call(void 0, ()=>!i||!r||typeof f!="number"||!b||!O||parseFloat(W.formatted)<f?null:{base:i,quote:r,baseAmount:f,quoteAmount:b,userAddress:O},[i,r,f,b,O,W.formatted]),Ee=_react.useCallback.call(void 0, C=>{oe(C),_chunkD7GULMHEcjs.d.getState().startTracking(C)},[]),qe=_react.useCallback.call(void 0, ()=>{ne.current=!0,Y()},[Y]);_react.useEffect.call(void 0, ()=>{if(k===null&&!(!i||!r)){if(!f||f<=0){q({amount:null,inputToken:i,outputToken:r,setOutputAmount:y});return}if(p||S){y(f);return}q({amount:f,inputToken:i,outputToken:r,setOutputAmount:y})}},[k,f,i,r,p,S,q,y]);let g=_react.useCallback.call(void 0, ()=>{_chunkD7GULMHEcjs.d.getState().setView("baseSelection")},[]),Z=_react.useCallback.call(void 0, ()=>{_chunkD7GULMHEcjs.d.getState().setView("quoteSelection")},[]),ge=_react.useCallback.call(void 0, ()=>{_(),y(null)},[_,y]),Le=_react.useCallback.call(void 0, async()=>{if(!W.formatted||!i||!r)return;let C=parseFloat(W.formatted);if(!C||C<=0)return;let J;if(v){let Fe=await ti(i.chainId);if(J=Math.max(0,C-Fe),J<=0)return}else J=C*.9999999999;p||S?(U(J),y(J),P()):(U(J),y(null),le({inputToken:i,outputToken:r,inputAmount:J.toString(),setOutputAmount:Fe=>y(Fe)}))},[W.formatted,i,r,v,p,S,U,y,P,le]),At=_react.useCallback.call(void 0, ()=>{P(),D()},[P,D]),Xe=W.formatted?parseFloat(W.formatted):null,Wt=!!(f||b),Pt=_optionalChain([i, 'optionalAccess', _10 => _10.price])&&f?`$${(i.price*f).toFixed(2)}`:"$0.00",Ot=_optionalChain([r, 'optionalAccess', _11 => _11.price])&&b?`$${(r.price*b).toFixed(2)}`:"$0.00",et=k==="trackingTx"&&!!$&&!!i&&!!r&&!!f&&!!b;return _jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full",children:[_jsxruntime.jsx.call(void 0, "div",{style:{opacity:Te,transition:"opacity 0.3s ease-out"},children:et&&$&&i&&r&&f&&b?_jsxruntime.jsx.call(void 0, "div",{className:"overflow-hidden",children:_jsxruntime.jsx.call(void 0, _chunk46JMXEHJcjs.y,{orderHash:$,base:i,quote:r,baseAmount:f,quoteAmount:b,status:ae})}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "div",{className:`relative ${K}`,style:{borderBottom:"1px solid var(--widget-border)"},children:[E?A?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 mb-2 ${z==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunk46JMXEHJcjs.i,{toggle:g,side:"base",asset:i,isPlacingOrder:N||h||T,hideDropdown:T}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunk46JMXEHJcjs.h,{side:"base",asset:_nullishCoalesce(i, () => (null)),otherAsset:_nullishCoalesce(r, () => (null)),isPlacingOrder:N,isWrappingPair:p,isUnwrappingPair:S})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${z==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunk46JMXEHJcjs.i,{toggle:g,side:"base",asset:i,isPlacingOrder:N||h||T,hideDropdown:T}),_jsxruntime.jsx.call(void 0, _chunk46JMXEHJcjs.h,{side:"base",asset:_nullishCoalesce(i, () => (null)),otherAsset:_nullishCoalesce(r, () => (null)),isPlacingOrder:N,isWrappingPair:p,isUnwrappingPair:S})]}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunk46JMXEHJcjs.i,{toggle:g,side:"base",asset:i,isPlacingOrder:N||h||T,hideDropdown:T}),_jsxruntime.jsx.call(void 0, _chunk46JMXEHJcjs.h,{side:"base",asset:_nullishCoalesce(i, () => (null)),otherAsset:_nullishCoalesce(r, () => (null)),isPlacingOrder:N,isWrappingPair:p,isUnwrappingPair:S})]}),_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:Pt}),O&&Xe!==null&&Xe>0&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Le,disabled:N,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"})]})]}),!M&&_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:ge,disabled:ve,"aria-label":"Swap input and output tokens",className:`flex h-8 w-8 items-center justify-center rounded-full transition-colors bg-(--widget-card) ${ve?"cursor-not-allowed opacity-40 pointer-events-none":"cursor-pointer 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, _chunk46JMXEHJcjs.k,{className:"w-3.5 h-3.5"})})}),_jsxruntime.jsxs.call(void 0, "div",{className:`relative ${w}`,children:[E?A?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${z==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunk46JMXEHJcjs.i,{toggle:Z,side:"quote",asset:r,isPlacingOrder:N||u||I,hideDropdown:I}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunk46JMXEHJcjs.h,{side:"quote",asset:_nullishCoalesce(r, () => (null)),otherAsset:_nullishCoalesce(i, () => (null)),isPlacingOrder:N,isWrappingPair:p,isUnwrappingPair:S})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${z==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunk46JMXEHJcjs.i,{toggle:Z,side:"quote",asset:r,isPlacingOrder:N||u||I,hideDropdown:I}),_jsxruntime.jsx.call(void 0, _chunk46JMXEHJcjs.h,{side:"quote",asset:_nullishCoalesce(r, () => (null)),otherAsset:_nullishCoalesce(i, () => (null)),isPlacingOrder:N,isWrappingPair:p,isUnwrappingPair:S})]}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunk46JMXEHJcjs.i,{toggle:Z,side:"quote",asset:r,isPlacingOrder:N||u||I,hideDropdown:I}),_jsxruntime.jsx.call(void 0, _chunk46JMXEHJcjs.h,{side:"quote",asset:_nullishCoalesce(r, () => (null)),otherAsset:_nullishCoalesce(i, () => (null)),isPlacingOrder:N,isWrappingPair:p,isUnwrappingPair:S})]}),_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:Ot}),Wt&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:At,disabled:N,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"})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-row items-center w-full overflow-hidden",style:{borderTop:re?"1px solid var(--widget-border)":"none",maxHeight:re?"60px":"0px",opacity:re?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:_jsxruntime.jsx.call(void 0, _chunk46JMXEHJcjs.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, _chunkXTJC3IX6cjs.a,{})})]})}),_jsxruntime.jsx.call(void 0, "div",{className:`relative ${et?"px-0 pb-4":"px-4"} ${A?"py-2":"py-4"}`,style:{opacity:Re,transition:"opacity 0.3s ease-out"},children:O&&i&&r&&f&&f>0?_jsxruntime.jsx.call(void 0, _chunk46JMXEHJcjs.x,{base:i,baseAmount:f,quote:r,quoteAmount:_nullishCoalesce(b, () => (0)),userAddress:O,isWrappingPair:p,isUnwrappingPair:S,isBaseGasToken:v,isQuoteGasToken:R,reviewActionProps:Ne,reviewState:k,setReviewState:ce,trackedOrderHash:$,setTrackedOrderHash:oe,onSwapSubmitted:e,onSwapComplete:t,onSwapInitiated:d,onOrderSubmitted:Ee,onStaleQuoteRestart:qe,txStatus:ae}):!O&&n?_jsxruntime.jsx.call(void 0, "button",{onClick:()=>ie(),className:`w-full ${A?"py-2":"py-3"} text-sm font-sans 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"}):_jsxruntime.jsx.call(void 0, "button",{disabled:!0,className:`w-full ${A?"py-2":"py-3"} text-sm font-sans font-medium transition-colors disabled:opacity-40 cursor-not-allowed`,style:{backgroundColor:"var(--widget-primary)",color:"var(--widget-primary-foreground)",borderRadius:"var(--widget-radius)"},children:O?"Enter Amount":"Connect Wallet"})})]})},vt=ii;var bt=()=>_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"relative px-4 pt-4 pb-2",style:{borderBottom:"1px solid var(--widget-border)"},children:[_jsxruntime.jsx.call(void 0, "div",{className:"h-12 w-full animate-pulse",style:{backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-2 h-20 w-2/3 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-1 mb-1 flex w-full items-center justify-between",children:_jsxruntime.jsx.call(void 0, "div",{className:"h-4 w-12 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.4,borderRadius:"0.25rem"}})})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex justify-center -my-4 relative z-10",children:_jsxruntime.jsx.call(void 0, "div",{className:"h-8 w-8",style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)",borderRadius:"9999px"}})}),_jsxruntime.jsxs.call(void 0, "div",{className:"relative px-4 pt-6 pb-2",children:[_jsxruntime.jsx.call(void 0, "div",{className:"h-12 w-full animate-pulse",style:{backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-2 h-20 w-2/3 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-1 mb-1 flex w-full items-center justify-between",children:_jsxruntime.jsx.call(void 0, "div",{className:"h-4 w-12 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.4,borderRadius:"0.25rem"}})})]}),_jsxruntime.jsx.call(void 0, "div",{className:"px-4",style:{height:"28px",borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"}}),_jsxruntime.jsx.call(void 0, "div",{className:"relative px-4 py-4",children:_jsxruntime.jsx.call(void 0, "div",{className:"w-full animate-pulse",style:{height:"44px",backgroundColor:"var(--widget-secondary)",borderRadius:"var(--widget-radius)",opacity:.6}})})]});var oi=({targetText:e,isError:t})=>{let{displayText:d,suffix:o,characterColors:n}=_chunkK3RTTHBScjs.y.call(void 0, e,t);return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[d.split("").map((h,u)=>_jsxruntime.jsx.call(void 0, "span",{style:n[u]?{color:"var(--widget-destructive)"}:void 0,children:h},u)),_jsxruntime.jsx.call(void 0, "span",{style:{color:t?"var(--widget-destructive)":"var(--widget-muted-foreground)",opacity:t?.5:1},children:o})]})},ni=({headerText:e,onBackClick:t,isSameChain:d,isWrappingPair:o,isUnwrappingPair:n,hasLowLiquidity:h,hasInsufficientLiquidity:u,hasRoutingError:M,hasSizeCapError:F,hasInsufficientBalance:z})=>{let c=_chunkD7GULMHEcjs.d.call(void 0, x=>x.view),{isRecipientInputOpen:H,hasAllowanceError:V,hoveredChainName:T,isTrackingTx:I,txStatus:E,walletTab:A}=_chunkD7GULMHEcjs.d.call(void 0, _shallow.useShallow.call(void 0, x=>({isRecipientInputOpen:x.isRecipientInputOpen,hasAllowanceError:x.hasAllowanceError,hoveredChainName:x.hoveredChainName,isTrackingTx:x.isTrackingTx,txStatus:x.txStatus,walletTab:x.walletTab}))),{swapHeaderVariant:K,walletButtonEnabled:w}=_chunkD7GULMHEcjs.b.call(void 0, ),{isConnected:i}=_chunk34N36GUDcjs.a.call(void 0, ),[r,f]=_react.useState.call(void 0, !1);_react.useEffect.call(void 0, ()=>f(!0),[]);let[b,v]=_react.useState.call(void 0, !1),[R,p]=_react.useState.call(void 0, !1),S=`${c}-${b}-${R}-${H}-${T||"none"}`,B=(()=>{if(I&&E)switch(E){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(T&&(c==="baseSelection"||c==="quoteSelection"||c==="baseChainSelection"||c==="quoteChainSelection"))return T;if(c==="swap"&&R)return"View Transaction History";if(c==="swap"&&b)return H?"Remove Custom Recipient":"Add Custom Recipient";switch(c){case"wallet":return"Wallet";case"activity":return"Activity";case"baseSelection":return"Select Source Token";case"quoteSelection":return"Select Destination Token";case"baseChainSelection":return"Select Source Chain";case"quoteChainSelection":return"Select Destination Chain";default:if(c==="swap"){if(V&&!o&&!n)return"Allowance check failed";if(F&&!o&&!n)return"Size limit exceeded";if(u&&!o&&!n)return"Insufficient Liquidity";if(M&&!o&&!n)return"Route Not Found";if(h&&!o&&!n)return"High Price Impact";if(z&&!o&&!n)return"Insufficient Balance"}return d&&!o&&!n?"Swap":o?"Wrap":n?"Unwrap":e}})(),U=!I&&c==="swap"&&!b&&(V&&!o&&!n||F&&!o&&!n||u&&!o&&!n||M&&!o&&!n||h&&!o&&!n||z&&!o&&!n),y={pending:"var(--widget-primary)",received:"var(--widget-primary)",completed:"var(--widget-status-completed)",failed:"var(--widget-status-failed)",cancelled:"var(--widget-status-failed)"},_=()=>!I||!E?null:_nullishCoalesce(y[E], () => (null)),D=()=>I?_jsxruntime.jsx.call(void 0, "button",{onClick:()=>_optionalChain([_chunkD7GULMHEcjs.d, 'access', _12 => _12.getState, 'call', _13 => _13(), 'access', _14 => _14.exitHandler, 'optionalCall', _15 => _15()]),"aria-label":"Close trade status",className:"size-4 -translate-y-0.5 flex cursor-pointer items-center justify-center transition-colors text-(--widget-muted-foreground) opacity-60 hover:text-(--widget-foreground) hover:opacity-100",children:_jsxruntime.jsxs.call(void 0, "svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M18 6L6 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),_jsxruntime.jsx.call(void 0, "path",{d:"M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}):c==="swap"?_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[w&&r&&i&&_jsxruntime.jsx.call(void 0, "button",{onClick:()=>_chunkD7GULMHEcjs.d.getState().setView("activity"),onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),"aria-label":"Open activity",className:"size-4 -translate-y-0.5 flex cursor-pointer items-center justify-center rounded-full transition-colors text-(--widget-muted-foreground) opacity-60 hover:text-(--widget-foreground) hover:opacity-100",children:_jsxruntime.jsxs.call(void 0, "svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M12 8V12L14.5 14.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),_jsxruntime.jsx.call(void 0, "path",{d:"M3.05 11A9 9 0 1 1 3.05 13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),_jsxruntime.jsx.call(void 0, "path",{d:"M1 7.5L3.05 11L6.5 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),_jsxruntime.jsx.call(void 0, "button",{onClick:()=>_chunkD7GULMHEcjs.d.getState().toggleRecipientInput(),onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),"aria-label":H?"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 ${H?"text-(--widget-destructive) opacity-80":"text-(--widget-muted-foreground) opacity-60"}`,children:_jsxruntime.jsxs.call(void 0, "svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "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"}),_jsxruntime.jsx.call(void 0, "path",{d:"M6 16.5H8",stroke:"currentColor",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"butt",strokeLinejoin:"miter"}),_jsxruntime.jsx.call(void 0, "path",{d:"M10.5 16.5H14.5",stroke:"currentColor",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"butt",strokeLinejoin:"miter"}),_jsxruntime.jsx.call(void 0, "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"}),_jsxruntime.jsxs.call(void 0, "g",{style:{transform:`rotate(${H?"45deg":"0deg"})`,transformOrigin:"18.75px 6.75px",transition:"transform 150ms ease-out"},children:[_jsxruntime.jsx.call(void 0, "path",{d:"M15 6.75H22.5",stroke:"currentColor",strokeWidth:"1.5"}),_jsxruntime.jsx.call(void 0, "path",{d:"M18.75 10.5V3",stroke:"currentColor",strokeWidth:"1.5"})]})]})})]}):_jsxruntime.jsxs.call(void 0, "button",{onClick:()=>t?t():_chunkD7GULMHEcjs.d.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:[_jsxruntime.jsx.call(void 0, "span",{className:"pr-1",children:"\u2190"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",children:"Back"})]}),G=_();return K==="none"?null:_jsxruntime.jsxs.call(void 0, "div",{className:"w-full pt-3 px-2 font-sans text-base flex flex-row justify-between h-6 shrink-0",children:[c==="wallet"?_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-1 font-sans uppercase -translate-y-0.5 text-xs",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>_chunkD7GULMHEcjs.d.getState().setWalletTab("wallet"),className:"cursor-pointer transition-colors",style:{color:A==="wallet"?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:_jsxruntime.jsx.call(void 0, "span",{children:"Wallet"})}),_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>_chunkD7GULMHEcjs.d.getState().setWalletTab("activity"),className:"cursor-pointer transition-colors",style:{color:A==="activity"?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:"Activity"})]}):_jsxruntime.jsx.call(void 0, "div",{className:"font-sans uppercase -translate-y-0.5 text-xs flex items-center",children:_jsxruntime.jsx.call(void 0, "span",{className:"relative",style:{color:G||"var(--widget-foreground)"},children:_jsxruntime.jsx.call(void 0, oi,{targetText:B,isError:_nullishCoalesce(U, () => (!1))})},S)}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-row items-center",children:D()})]})},_e=ni;var xt=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./AssetSelectionMenu-TPSIEBBB.cjs")))),St=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./ChainSelectionMenu-UNMEPKRI.cjs")))),li=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./SwapFormHorizontal-WBAPDDJF.cjs")))),ci=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./SwapFormSplit-I2HXRXPP.cjs")))),gi=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./WidgetWalletPanel-HH26O3HT.cjs"))).then(e=>({default:e.WidgetWalletPanel}))),pi=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./WalletPlaceholderPanel-TTONBBI4.cjs"))).then(e=>({default:e.WalletPlaceholderPanel}))),wi=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./WidgetWalletTradeHistory-NL23HIOJ.cjs"))).then(e=>({default:e.WidgetWalletTradeHistory}))),ui=({onSwapSubmitted:e,onSwapComplete:t,cardStyles:d,cardWidth:o})=>{let{baseToken:n,quoteToken:h,baseAmount:u,quoteAmount:M,baseBalance:F,isWrappingPair:z,isUnwrappingPair:c,isRegistryLoading:H}=_chunkPSCWQFVYcjs.e.call(void 0, ),{liquidityError:V,routingError:T,sizeCapError:I,stop:E,clear:A}=_chunk46JMXEHJcjs.e.call(void 0, ),K=!!(u&&F.formatted&&parseFloat(F.formatted)<u),w=_chunkD7GULMHEcjs.d.call(void 0, g=>g.view),{isTransitioning:i,isRecipientInputOpen:r,recipient:f,selectedChainFilterChainId:b}=_chunkD7GULMHEcjs.d.call(void 0, _shallow.useShallow.call(void 0, g=>({isTransitioning:g.isTransitioning,isRecipientInputOpen:g.isRecipientInputOpen,recipient:g.recipient,selectedChainFilterChainId:_nullishCoalesce(_optionalChain([g, 'access', _16 => _16.selectedChainFilter, 'optionalAccess', _17 => _17.chainId]), () => (null))}))),v=_react.useRef.call(void 0, null),R=_react.useRef.call(void 0, null),[p,S]=_react.useState.call(void 0, null);_chunk46JMXEHJcjs.c.call(void 0, ),_react.useEffect.call(void 0, ()=>()=>{v.current&&clearTimeout(v.current),R.current&&clearTimeout(R.current)},[]),_react.useEffect.call(void 0, ()=>{_chunkD7GULMHEcjs.d.getState().resetUI()},[]),_react.useEffect.call(void 0, ()=>{if(i)return v.current=setTimeout(()=>{_chunkD7GULMHEcjs.d.getState().setIsTransitioning(!1),v.current=null},20),()=>{v.current&&(clearTimeout(v.current),v.current=null)}},[i]);let W=_react.useCallback.call(void 0, (g,Z="navigation")=>{R.current&&(clearTimeout(R.current),R.current=null,S(null)),_chunkD7GULMHEcjs.d.getState().view!=="swap"&&g!=="swap"?(_chunkD7GULMHEcjs.d.getState().setView(g),_chunkD7GULMHEcjs.d.getState().setIsTransitioning(!1)):_chunkD7GULMHEcjs.d.getState().transitionToView(g,Z)},[]),B=_react.useCallback.call(void 0, ()=>{v.current&&(clearTimeout(v.current),v.current=null),R.current&&(clearTimeout(R.current),R.current=null);let g=_chunkD7GULMHEcjs.d.getState().view;S(g),_chunkD7GULMHEcjs.d.getState().setChainFilter(null),_chunkD7GULMHEcjs.d.getState().setView("swap"),_chunkD7GULMHEcjs.d.getState().setIsTransitioning(!1),_chunkD7GULMHEcjs.d.getState().resetAssetSelection(),R.current=setTimeout(()=>{S(null),R.current=null},200)},[]),U=_react.useCallback.call(void 0, g=>{let ge=w==="baseChainSelection"?"base":"quote";_chunkD7GULMHEcjs.d.getState().setChainFilter({chainId:g,side:ge}),_chunkD7GULMHEcjs.d.getState().pushRecentChain(g),W(ge==="base"?"baseSelection":"quoteSelection","chainSelection")},[w,W]),y=_react.useCallback.call(void 0, ()=>{let g=_chunkD7GULMHEcjs.d.getState().view;g==="baseSelection"?W("baseChainSelection","chainSelection"):g==="quoteSelection"&&W("quoteChainSelection","chainSelection")},[W]),_=_react.useCallback.call(void 0, ()=>{E(),A()},[E,A]),D=n&&h?n.chainId===h.chainId:!0,G=()=>{switch(w){case"wallet":return"Wallet";case"baseSelection":return"Select Input Token";case"quoteSelection":return"Select Output Token";case"baseChainSelection":case"quoteChainSelection":return"Select Chain";default:return"Swap"}},{assetMenuVariant:x,widgetType:q,customWalletUI:le}=_chunkD7GULMHEcjs.b.call(void 0, ),Q=w==="baseSelection"||w==="quoteSelection",P=w==="baseChainSelection"||w==="quoteChainSelection",Y=x==="split"&&(q==="default"||q==="compact"),O=x==="split"&&(q==="horizontal"||q==="split"),ie=x==="default",re=w==="swap"||Q||P||w==="wallet"||w==="activity",ae=p==="baseSelection"||p==="quoteSelection",k=p==="baseChainSelection"||p==="quoteChainSelection",ce=Q||ae,$=P||k,oe=Q&&!i,ne=P&&!i,N=Q?w:p,ve=N==="baseSelection"?"base":"quote",me=N==="baseSelection"?h:n,Te=(P?w:p)==="baseChainSelection"?"base":"quote",se=g=>({backgroundColor:"var(--widget-background)",opacity:g?1:0,transform:g?"translateY(0)":"translateY(6px)",transition:"opacity 200ms ease-in-out, transform 200ms ease-in-out"}),Ie=ie&&(Q||P||w==="wallet"||w==="activity"||p!=null),Re=H?_jsxruntime.jsx.call(void 0, bt,{}):q==="horizontal"?_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, li,{onSwapSubmitted:e,onSwapComplete:t,onSwapInitiated:_,onBackToSwap:O?B:void 0,onMoreChainsClick:O?y:void 0})}):q==="split"?_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, ci,{onSwapSubmitted:e,onSwapComplete:t,onSwapInitiated:_,onBackToSwap:O?B:void 0,onMoreChainsClick:O?y:void 0})}):_jsxruntime.jsx.call(void 0, vt,{onSwapSubmitted:e,onSwapComplete:t,onSwapInitiated:_}),be=_nullishCoalesce(d, () => ({})),Ne=_react.useRef.call(void 0, null),[Ee,qe]=_react.useState.call(void 0, 420);return _react.useEffect.call(void 0, ()=>{if(!Y)return;let g=Ne.current;if(!g)return;let Z=new ResizeObserver(ge=>{for(let Le of ge)qe(Le.contentRect.height)});return Z.observe(g),()=>Z.disconnect()},[Y]),Y?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "div",{ref:Ne,className:"flex flex-col w-full overflow-hidden transition-colors duration-300",style:{flex:"1 1 0",minWidth:0,...be},children:[_jsxruntime.jsx.call(void 0, _e,{headerText:"Swap",onBackClick:B,isSameChain:D,isWrappingPair:z,isUnwrappingPair:c,hasLowLiquidity:V,hasInsufficientLiquidity:V,hasRoutingError:T,hasSizeCapError:I,hasInsufficientBalance:K}),_jsxruntime.jsx.call(void 0, "div",{className:"overflow-hidden",children:Re})]}),(ce||$)&&_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col overflow-hidden shrink-0",style:{width:o,height:`${Ee}px`,...be,...se((Q||P)&&!i)},children:Q||ae?_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, xt,{toggle:B,side:ve,otherAsset:me,onMoreChainsClick:y,selectedChainFilter:b})}):_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, St,{toggle:B,side:Te,onChainSelect:U})})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full",style:{overflow:"hidden",position:"relative"},children:[_jsxruntime.jsx.call(void 0, _e,{headerText:G(),onBackClick:B,isSameChain:D,isWrappingPair:z,isUnwrappingPair:c,hasLowLiquidity:V,hasInsufficientLiquidity:V,hasRoutingError:T,hasSizeCapError:I,hasInsufficientBalance:K}),_jsxruntime.jsxs.call(void 0, "div",{className:"relative overflow-hidden",children:[re&&_jsxruntime.jsx.call(void 0, "div",{className:"overflow-hidden",style:Ie?{pointerEvents:"none"}:void 0,children:Re}),(w==="wallet"||p==="wallet")&&_jsxruntime.jsx.call(void 0, "div",{className:"absolute inset-0 overflow-hidden z-20",style:se(w==="wallet"&&!i),children:_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:le==="none"?_jsxruntime.jsx.call(void 0, pi,{}):_jsxruntime.jsx.call(void 0, gi,{})})}),(w==="activity"||p==="activity")&&_jsxruntime.jsx.call(void 0, "div",{className:"absolute inset-0 overflow-y-auto z-20",style:se(w==="activity"&&!i),children:_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, wi,{isActive:w==="activity"})})}),ie&&ce&&_jsxruntime.jsx.call(void 0, "div",{className:"absolute inset-0 overflow-hidden z-20",style:se(oe),children:_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, xt,{toggle:B,side:ve,otherAsset:me,onMoreChainsClick:y,selectedChainFilter:b})})}),ie&&$&&_jsxruntime.jsx.call(void 0, "div",{className:"absolute inset-0 overflow-hidden z-20",style:se(ne),children:_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, St,{toggle:B,side:Te,onChainSelect:U})})})]})]})},kt=({onSwapSubmitted:e,onSwapComplete:t,defaultBaseToken:d,defaultQuoteToken:o,onBaseTokenChange:n,onQuoteTokenChange:h,cardStyles:u,cardWidth:M})=>{let{address:F}=_chunk34N36GUDcjs.a.call(void 0, ),z=_chunkD7GULMHEcjs.d.call(void 0, c=>c.recipient);return _jsxruntime.jsx.call(void 0, _chunkPSCWQFVYcjs.d,{defaultBaseToken:d,defaultQuoteToken:o,onBaseTokenChange:n,onQuoteTokenChange:h,children:_jsxruntime.jsx.call(void 0, _chunk46JMXEHJcjs.d,{recipient:z,children:_jsxruntime.jsx.call(void 0, ui,{onSwapSubmitted:e,onSwapComplete:t,cardStyles:u,cardWidth:M})})})};var Ge={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"},Ce= exports.defaultDarkTheme ={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 Ke(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}var Ct=_react.createContext.call(void 0, Ce);function Ye({theme:e,children:t}){return _jsxruntime.jsx.call(void 0, Ct.Provider,{value:e,children:t})}function vi(){return _react.useContext.call(void 0, Ct)}var xi=[],Si=[],ki=[],It=[],Ci=[],Ti=[],Ii=`
3
3
  .aori-widget .text-2xs { font-size: 0.75rem; }
4
4
  .aori-widget .text-3xs { font-size: 0.68rem; }
5
5
  .aori-widget ::-webkit-scrollbar { width: 0px; height: 0px; display: none; }
@@ -7,4 +7,4 @@ var _chunkREBGSW5Kcjs = require('./chunk-REBGSW5K.cjs');var _chunkSGTI7NXZcjs =
7
7
  .aori-widget input:focus, .aori-widget input:focus-visible,
8
8
  .aori-widget button:focus, .aori-widget button:focus-visible,
9
9
  .aori-widget select:focus, .aori-widget select:focus-visible { outline: none; }
10
- `,Ye= (_class =class extends _react2.default.Component{constructor(...args) { super(...args); _class.prototype.__init.call(this); }__init() {this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?_jsxruntime.jsxs.call(void 0, "div",{style:{padding:"1.5rem",textAlign:"center",color:"var(--widget-foreground, #888)",fontFamily:"system-ui, sans-serif"},children:[_jsxruntime.jsx.call(void 0, "p",{style:{margin:"0 0 0.75rem",fontSize:"0.875rem"},children:"Something went wrong."}),_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>this.setState({hasError:!1}),style:{padding:"0.375rem 1rem",fontSize:"0.8125rem",cursor:"pointer",border:"1px solid currentColor",borderRadius:"0.25rem",background:"transparent",color:"inherit"},children:"Retry"})]}):this.props.children}}, _class);function Ti(e){let t=e.theme.mode==="light"?Qe:Se,l=e.theme.mode==="light"?e.theme.light:e.theme.dark;return l?{...t,...l}:t}function Ri({config:e,className:t,onSwapComplete:l,onBaseTokenChange:r,onQuoteTokenChange:o,onRequestConnect:f,onRequestAccount:b,customWalletUI:W="builtin"}){_chunkK3RTTHBScjs.l.call(void 0, e.apiKey),_chunkK3RTTHBScjs.n.call(void 0, e.rpcOverrides),_chunkK3RTTHBScjs.j.call(void 0, e.vtApiBaseUrl);let B=Ti(e),y=_nullishCoalesce(_optionalChain([e, 'access', _18 => _18.appearance, 'optionalAccess', _19 => _19.widgetType]), () => ("default")),x=_nullishCoalesce(_optionalChain([e, 'access', _20 => _20.appearance, 'optionalAccess', _21 => _21.tokenDisplay]), () => ("default")),E=_nullishCoalesce(_optionalChain([e, 'access', _22 => _22.appearance, 'optionalAccess', _23 => _23.tokenBadgeOrientation]), () => ("left")),P=_nullishCoalesce(_optionalChain([e, 'access', _24 => _24.appearance, 'optionalAccess', _25 => _25.assetMenuVariant]), () => ("default")),O=_nullishCoalesce(_optionalChain([e, 'access', _26 => _26.appearance, 'optionalAccess', _27 => _27.amountInputVariant]), () => ("default")),q=_nullishCoalesce(_optionalChain([e, 'access', _28 => _28.appearance, 'optionalAccess', _29 => _29.hideAmountInputSymbol]), () => (!1)),C=_nullishCoalesce(_optionalChain([e, 'access', _30 => _30.appearance, 'optionalAccess', _31 => _31.swapButtonVariant]), () => ("default")),Q=_nullishCoalesce(_optionalChain([e, 'access', _32 => _32.appearance, 'optionalAccess', _33 => _33.swapHeaderVariant]), () => ("default")),p=_nullishCoalesce(_optionalChain([e, 'access', _34 => _34.appearance, 'optionalAccess', _35 => _35.quoteLoaderVariant]), () => ("default")),i=_nullishCoalesce(_optionalChain([e, 'access', _36 => _36.appearance, 'optionalAccess', _37 => _37.walletButtonEnabled]), () => (!0)),a=_nullishCoalesce(_optionalChain([e, 'access', _38 => _38.appearance, 'optionalAccess', _39 => _39.fillContainer]), () => (!1)),w=_nullishCoalesce(_optionalChain([e, 'access', _40 => _40.appearance, 'optionalAccess', _41 => _41.hideBorder]), () => (!1)),k=Ge(B),m=P==="split"&&(y==="default"||y==="compact"),I=_chunkD7GULMHEcjs.d.call(void 0, oe=>oe.view==="baseSelection"||oe.view==="quoteSelection"||oe.view==="baseChainSelection"||oe.view==="quoteChainSelection"),g=y==="compact"?"22rem":"24rem",N=m?{maxWidth:I?y==="compact"?"46rem":"49rem":g,transition:"max-width 0.3s ease",height:"auto",overflow:"visible",display:"flex",gap:"1rem",alignItems:"stretch",backgroundColor:"transparent",border:"none",borderRadius:0,boxShadow:"none",padding:0}:{width:"100%",...a?{}:{maxWidth:y==="split"||y==="horizontal"?"48rem":y==="compact"?"22rem":"24rem"},height:"auto",overflow:"hidden"},L={boxSizing:"border-box",backgroundColor:"var(--widget-background)",color:"var(--widget-foreground)",borderRadius:"var(--widget-radius)",...w?{border:"none"}:{borderWidth:"1px",borderStyle:"var(--widget-border-style)",borderColor:"var(--widget-border)"},boxShadow:"var(--widget-shadow-offset-x) var(--widget-shadow-offset-y) var(--widget-shadow-blur) var(--widget-shadow-spread) color-mix(in srgb, var(--widget-shadow-color) calc(var(--widget-shadow-opacity) * 100%), transparent)",padding:"0.25rem 0.5rem",paddingTop:"0.25rem"},U=_nullishCoalesce(_optionalChain([e, 'access', _42 => _42.tokens, 'optionalAccess', _43 => _43.enabledChains]), () => (bi)),v=_nullishCoalesce(_optionalChain([e, 'access', _44 => _44.tokens, 'optionalAccess', _45 => _45.supportedInputTokens]), () => (yi)),_=_nullishCoalesce(_optionalChain([e, 'access', _46 => _46.tokens, 'optionalAccess', _47 => _47.supportedOutputTokens]), () => (xi)),H=_nullishCoalesce(_optionalChain([e, 'access', _48 => _48.tokens, 'optionalAccess', _49 => _49.supportedInputChains]), () => (Tt)),G=_nullishCoalesce(_optionalChain([e, 'access', _50 => _50.tokens, 'optionalAccess', _51 => _51.supportedOutputChains]), () => (Tt)),V=_nullishCoalesce(_optionalChain([e, 'access', _52 => _52.tokens, 'optionalAccess', _53 => _53.prioritizedInputTokens]), () => (ki)),h=_nullishCoalesce(_optionalChain([e, 'access', _54 => _54.tokens, 'optionalAccess', _55 => _55.prioritizedInputChains]), () => (Si)),de=_nullishCoalesce(_optionalChain([e, 'access', _56 => _56.tokens, 'optionalAccess', _57 => _57.inputSelectionSearch]), () => (!0)),D=_nullishCoalesce(_optionalChain([e, 'access', _58 => _58.tokens, 'optionalAccess', _59 => _59.outputSelectionSearch]), () => (!0)),z=_nullishCoalesce(_optionalChain([e, 'access', _60 => _60.tokens, 'optionalAccess', _61 => _61.showInputSelectionTokenBalances]), () => (!0)),K=_nullishCoalesce(_optionalChain([e, 'access', _62 => _62.tokens, 'optionalAccess', _63 => _63.showOutputSelectionTokenBalances]), () => (!0)),M=_nullishCoalesce(_optionalChain([e, 'access', _64 => _64.tokens, 'optionalAccess', _65 => _65.lockBase]), () => (!1)),te=_nullishCoalesce(_optionalChain([e, 'access', _66 => _66.tokens, 'optionalAccess', _67 => _67.lockQuote]), () => (!1)),ie=_nullishCoalesce(_optionalChain([e, 'access', _68 => _68.tokens, 'optionalAccess', _69 => _69.disableInverting]), () => (!1)),re=_nullishCoalesce(_optionalChain([e, 'access', _70 => _70.settings, 'optionalAccess', _71 => _71.defaultSlippage]), () => (.01)),T=!!f,le=_react.useMemo.call(void 0, ()=>({apiKey:e.apiKey,web3ConnectionType:"custom",enabledChains:U,supportedInputTokens:v,supportedOutputTokens:_,supportedInputChains:H,supportedOutputChains:G,prioritizedInputTokens:V,prioritizedInputChains:h,inputSelectionSearch:de,outputSelectionSearch:D,showInputSelectionTokenBalances:z,showOutputSelectionTokenBalances:K,lockBase:M,lockQuote:te,disableInverting:ie,defaultSlippage:re,widgetType:y,tokenDisplay:x,tokenBadgeOrientation:E,assetMenuVariant:P,amountInputVariant:O,hideAmountInputSymbol:q,swapButtonVariant:C,swapHeaderVariant:Q,quoteLoaderVariant:p,walletButtonEnabled:i,hasConnectHandler:T,customWalletUI:W}),[e.apiKey,U,v,_,H,G,V,h,de,D,z,K,M,te,ie,re,y,x,E,P,O,q,C,Q,p,i,T,W]),$=_react.useMemo.call(void 0, ()=>f?{openConnectModal:f,openAccountModal:b}:null,[f,b]),ae=_jsxruntime.jsx.call(void 0, _chunkK3RTTHBScjs.M,{children:_jsxruntime.jsx.call(void 0, _chunkD7GULMHEcjs.a.Provider,{value:le,children:_jsxruntime.jsx.call(void 0, Ke,{theme:B,children:_jsxruntime.jsxs.call(void 0, "div",{className:`aori-widget${t?` ${t}`:""}`,style:{...k,"--font-sans":"var(--widget-font-sans)","--font-mono":"var(--widget-font-mono)",fontFamily:"var(--widget-font-sans)",letterSpacing:"var(--widget-letter-spacing)",width:"100%",...N,position:"relative",...m?{}:L},children:[_jsxruntime.jsx.call(void 0, "style",{dangerouslySetInnerHTML:{__html:Ci}}),_jsxruntime.jsx.call(void 0, Ye,{children:_jsxruntime.jsx.call(void 0, kt,{onSwapComplete:l,defaultBaseToken:_optionalChain([e, 'access', _72 => _72.tokens, 'optionalAccess', _73 => _73.defaultBase]),defaultQuoteToken:_optionalChain([e, 'access', _74 => _74.tokens, 'optionalAccess', _75 => _75.defaultQuote]),onBaseTokenChange:r,onQuoteTokenChange:o,cardStyles:m?L:void 0,cardWidth:m?g:void 0})})]})})})});return $?_jsxruntime.jsx.call(void 0, _chunkSGTI7NXZcjs.f.Provider,{value:$,children:ae}):ae}function Ii(){let{openConnectModal:e}=_chunkSGTI7NXZcjs.g.call(void 0, ),{isConnected:t,address:l}=_chunk34N36GUDcjs.a.call(void 0, ),r=t&&l?`${l.slice(0,6)}...${l.slice(-4)}`:"Connect";return _jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>e(),className:"h-8 cursor-pointer px-3 text-xs font-bold uppercase tracking-wide transition-colors duration-150 border border-border rounded-sm bg-card text-foreground hover:bg-secondary hover:border-foreground/20",children:r})}var _wagmi = require('wagmi');function Wi(e){let t=Object.entries(_chunkK3RTTHBScjs.b);return Object.fromEntries(t.map(([l,r])=>{let o=_optionalChain([e, 'optionalAccess', _76 => _76[Number(l)]]),f=o?Array.isArray(o)?o:[o]:[],b=f.length>0?[...f,...r.rpcUrls]:r.rpcUrls;return[l,b.length>1?_wagmi.fallback.call(void 0, b.map(W=>_wagmi.http.call(void 0, W,{batch:{batchSize:50,wait:50}}))):_wagmi.http.call(void 0, b[0],{batch:{batchSize:50,wait:50}})]}))}var Pi=_chunkK3RTTHBScjs.d.call(void 0, ).map(e=>e.wagmiChain);var Oi=e=>{let{tokenRegistry:t,isLoadingRegistry:l,error:r}=_chunkK3RTTHBScjs.B.call(void 0, );return{tokens:_react.useMemo.call(void 0, ()=>t.filter(f=>f.chainId===e),[t,e]),isLoading:l,error:r}},zi= exports.useIsTokenSupported =(e,t)=>{let{tokenRegistry:l}=_chunkK3RTTHBScjs.B.call(void 0, );return _react.useMemo.call(void 0, ()=>!e||!l.length?!1:l.some(r=>r.address.toLowerCase()===e.toLowerCase()&&r.chainId===t),[l,e,t])},Mi= exports.useTokenByAddress =(e,t)=>{let{getToken:l}=_chunkK3RTTHBScjs.B.call(void 0, );return _react.useMemo.call(void 0, ()=>{if(!(!e||!t))return l(t,e)},[l,e,t])},Zr=_chunkK3RTTHBScjs.g.call(void 0, );exports.ChainSwitch = _chunkSGTI7NXZcjs.o; exports.ConnectButton = Ii; exports.RfqProvider = _chunkSGTI7NXZcjs.d; exports.SignSwap = _chunkSGTI7NXZcjs.p; exports.SwapFormProvider = _chunkPSCWQFVYcjs.d; exports.SwapWidget = Ri; exports.WidgetThemeProvider = Ke; exports.buildTransports = Wi; exports.canSubmitOrder = _chunkSGTI7NXZcjs.r; exports.cleanupOldSubmissions = _chunkSGTI7NXZcjs.t; exports.defaultDarkTheme = Se; exports.defaultLightTheme = Qe; exports.isQuoteFresh = _chunkSGTI7NXZcjs.q; exports.markOrderAsSubmitted = _chunkSGTI7NXZcjs.s; exports.pollOrderStatus = _chunkSGTI7NXZcjs.l; exports.themeToCSS = Ge; exports.useBalanceEventListener = _chunkSGTI7NXZcjs.a; exports.useBalanceEventSubscription = _chunkSGTI7NXZcjs.c; exports.useEmitBalanceEvent = _chunkSGTI7NXZcjs.b; exports.useIsTokenSupported = zi; exports.useOrderStatusPolling = _chunkSGTI7NXZcjs.m; exports.useRfq = _chunkSGTI7NXZcjs.e; exports.useSwapForm = _chunkPSCWQFVYcjs.c; exports.useSwapFormContext = _chunkPSCWQFVYcjs.e; exports.useTokenByAddress = Mi; exports.useTokenSelection = _chunkPSCWQFVYcjs.b; exports.useTokenSelectionStore = _chunkPSCWQFVYcjs.a; exports.useTokensForChain = Oi; exports.useTransactionRegistry = _chunkSGTI7NXZcjs.n; exports.useUnwrapToken = _chunkSGTI7NXZcjs.u; exports.useWalletModal = _chunkSGTI7NXZcjs.g; exports.useWalletState = _chunk34N36GUDcjs.a; exports.useWidgetSwapUIStore = _chunkD7GULMHEcjs.d; exports.useWidgetTheme = mi; exports.useWrapToken = _chunkSGTI7NXZcjs.v; exports.wagmiChains = Pi;
10
+ `,Ze= (_class =class extends _react2.default.Component{constructor(...args) { super(...args); _class.prototype.__init.call(this); }__init() {this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?_jsxruntime.jsxs.call(void 0, "div",{style:{padding:"1.5rem",textAlign:"center",color:"var(--widget-foreground, #888)",fontFamily:"system-ui, sans-serif"},children:[_jsxruntime.jsx.call(void 0, "p",{style:{margin:"0 0 0.75rem",fontSize:"0.875rem"},children:"Something went wrong."}),_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>this.setState({hasError:!1}),style:{padding:"0.375rem 1rem",fontSize:"0.8125rem",cursor:"pointer",border:"1px solid currentColor",borderRadius:"0.25rem",background:"transparent",color:"inherit"},children:"Retry"})]}):this.props.children}}, _class);function Ri(e){let t=e.theme.mode==="light"?Ge:Ce,d=e.theme.mode==="light"?e.theme.light:e.theme.dark;return d?{...t,...d}:t}function Ni({config:e,className:t,onSwapSubmitted:d,onSwapComplete:o,onBaseTokenChange:n,onQuoteTokenChange:h,onRequestConnect:u,onRequestAccount:M,customWalletUI:F="builtin"}){_chunkK3RTTHBScjs.l.call(void 0, e.apiKey),_chunkK3RTTHBScjs.n.call(void 0, e.rpcOverrides),_chunkK3RTTHBScjs.j.call(void 0, e.vtApiBaseUrl);let z=Ri(e),c=_nullishCoalesce(_optionalChain([e, 'access', _18 => _18.appearance, 'optionalAccess', _19 => _19.widgetType]), () => ("default")),H=_nullishCoalesce(_optionalChain([e, 'access', _20 => _20.appearance, 'optionalAccess', _21 => _21.tokenDisplay]), () => ("default")),V=_nullishCoalesce(_optionalChain([e, 'access', _22 => _22.appearance, 'optionalAccess', _23 => _23.tokenBadgeOrientation]), () => ("left")),T=_nullishCoalesce(_optionalChain([e, 'access', _24 => _24.appearance, 'optionalAccess', _25 => _25.assetMenuVariant]), () => ("default")),I=_nullishCoalesce(_optionalChain([e, 'access', _26 => _26.appearance, 'optionalAccess', _27 => _27.amountInputVariant]), () => ("default")),E=_nullishCoalesce(_optionalChain([e, 'access', _28 => _28.appearance, 'optionalAccess', _29 => _29.hideAmountInputSymbol]), () => (!1)),A=_nullishCoalesce(_optionalChain([e, 'access', _30 => _30.appearance, 'optionalAccess', _31 => _31.swapButtonVariant]), () => ("default")),K=_nullishCoalesce(_optionalChain([e, 'access', _32 => _32.appearance, 'optionalAccess', _33 => _33.swapHeaderVariant]), () => ("default")),w=_nullishCoalesce(_optionalChain([e, 'access', _34 => _34.appearance, 'optionalAccess', _35 => _35.quoteLoaderVariant]), () => ("default")),i=_nullishCoalesce(_optionalChain([e, 'access', _36 => _36.appearance, 'optionalAccess', _37 => _37.walletButtonEnabled]), () => (!0)),r=_nullishCoalesce(_optionalChain([e, 'access', _38 => _38.appearance, 'optionalAccess', _39 => _39.fillContainer]), () => (!1)),f=_nullishCoalesce(_optionalChain([e, 'access', _40 => _40.appearance, 'optionalAccess', _41 => _41.hideBorder]), () => (!1)),b=Ke(z),v=T==="split"&&(c==="default"||c==="compact"),R=_chunkD7GULMHEcjs.d.call(void 0, ne=>ne.view==="baseSelection"||ne.view==="quoteSelection"||ne.view==="baseChainSelection"||ne.view==="quoteChainSelection"),p=c==="compact"?"22rem":"24rem",W=v?{maxWidth:R?c==="compact"?"46rem":"49rem":p,transition:"max-width 0.3s ease",height:"auto",overflow:"visible",display:"flex",gap:"1rem",alignItems:"stretch",backgroundColor:"transparent",border:"none",borderRadius:0,boxShadow:"none",padding:0}:{width:"100%",...r?{}:{maxWidth:c==="split"||c==="horizontal"?"48rem":c==="compact"?"22rem":"24rem"},height:"auto",overflow:"hidden"},B={boxSizing:"border-box",backgroundColor:"var(--widget-background)",color:"var(--widget-foreground)",borderRadius:"var(--widget-radius)",...f?{border:"none"}:{borderWidth:"1px",borderStyle:"var(--widget-border-style)",borderColor:"var(--widget-border)"},boxShadow:"var(--widget-shadow-offset-x) var(--widget-shadow-offset-y) var(--widget-shadow-blur) var(--widget-shadow-spread) color-mix(in srgb, var(--widget-shadow-color) calc(var(--widget-shadow-opacity) * 100%), transparent)",padding:"0.25rem 0.5rem",paddingTop:"0.25rem"},U=_nullishCoalesce(_optionalChain([e, 'access', _42 => _42.tokens, 'optionalAccess', _43 => _43.enabledChains]), () => (xi)),y=_nullishCoalesce(_optionalChain([e, 'access', _44 => _44.tokens, 'optionalAccess', _45 => _45.supportedInputTokens]), () => (Si)),_=_nullishCoalesce(_optionalChain([e, 'access', _46 => _46.tokens, 'optionalAccess', _47 => _47.supportedOutputTokens]), () => (ki)),D=_nullishCoalesce(_optionalChain([e, 'access', _48 => _48.tokens, 'optionalAccess', _49 => _49.supportedInputChains]), () => (It)),G=_nullishCoalesce(_optionalChain([e, 'access', _50 => _50.tokens, 'optionalAccess', _51 => _51.supportedOutputChains]), () => (It)),x=_nullishCoalesce(_optionalChain([e, 'access', _52 => _52.tokens, 'optionalAccess', _53 => _53.prioritizedInputTokens]), () => (Ci)),q=_nullishCoalesce(_optionalChain([e, 'access', _54 => _54.tokens, 'optionalAccess', _55 => _55.prioritizedInputChains]), () => (Ti)),le=_nullishCoalesce(_optionalChain([e, 'access', _56 => _56.tokens, 'optionalAccess', _57 => _57.inputSelectionSearch]), () => (!0)),Q=_nullishCoalesce(_optionalChain([e, 'access', _58 => _58.tokens, 'optionalAccess', _59 => _59.outputSelectionSearch]), () => (!0)),P=_nullishCoalesce(_optionalChain([e, 'access', _60 => _60.tokens, 'optionalAccess', _61 => _61.showInputSelectionTokenBalances]), () => (!0)),Y=_nullishCoalesce(_optionalChain([e, 'access', _62 => _62.tokens, 'optionalAccess', _63 => _63.showOutputSelectionTokenBalances]), () => (!0)),O=_nullishCoalesce(_optionalChain([e, 'access', _64 => _64.tokens, 'optionalAccess', _65 => _65.lockBase]), () => (!1)),ie=_nullishCoalesce(_optionalChain([e, 'access', _66 => _66.tokens, 'optionalAccess', _67 => _67.lockQuote]), () => (!1)),re=_nullishCoalesce(_optionalChain([e, 'access', _68 => _68.tokens, 'optionalAccess', _69 => _69.disableInverting]), () => (!1)),ae=_nullishCoalesce(_optionalChain([e, 'access', _70 => _70.settings, 'optionalAccess', _71 => _71.defaultSlippage]), () => (.01)),k=!!u,ce=_react.useMemo.call(void 0, ()=>({apiKey:e.apiKey,web3ConnectionType:"custom",enabledChains:U,supportedInputTokens:y,supportedOutputTokens:_,supportedInputChains:D,supportedOutputChains:G,prioritizedInputTokens:x,prioritizedInputChains:q,inputSelectionSearch:le,outputSelectionSearch:Q,showInputSelectionTokenBalances:P,showOutputSelectionTokenBalances:Y,lockBase:O,lockQuote:ie,disableInverting:re,defaultSlippage:ae,widgetType:c,tokenDisplay:H,tokenBadgeOrientation:V,assetMenuVariant:T,amountInputVariant:I,hideAmountInputSymbol:E,swapButtonVariant:A,swapHeaderVariant:K,quoteLoaderVariant:w,walletButtonEnabled:i,hasConnectHandler:k,customWalletUI:F}),[e.apiKey,U,y,_,D,G,x,q,le,Q,P,Y,O,ie,re,ae,c,H,V,T,I,E,A,K,w,i,k,F]),$=_react.useMemo.call(void 0, ()=>u?{openConnectModal:u,openAccountModal:M}:null,[u,M]),oe=_jsxruntime.jsx.call(void 0, _chunkK3RTTHBScjs.M,{children:_jsxruntime.jsx.call(void 0, _chunkD7GULMHEcjs.a.Provider,{value:ce,children:_jsxruntime.jsx.call(void 0, Ye,{theme:z,children:_jsxruntime.jsxs.call(void 0, "div",{className:`aori-widget${t?` ${t}`:""}`,style:{...b,"--font-sans":"var(--widget-font-sans)","--font-mono":"var(--widget-font-mono)",fontFamily:"var(--widget-font-sans)",letterSpacing:"var(--widget-letter-spacing)",width:"100%",...W,position:"relative",...v?{}:B},children:[_jsxruntime.jsx.call(void 0, "style",{dangerouslySetInnerHTML:{__html:Ii}}),_jsxruntime.jsx.call(void 0, Ze,{children:_jsxruntime.jsx.call(void 0, kt,{onSwapSubmitted:d,onSwapComplete:o,defaultBaseToken:_optionalChain([e, 'access', _72 => _72.tokens, 'optionalAccess', _73 => _73.defaultBase]),defaultQuoteToken:_optionalChain([e, 'access', _74 => _74.tokens, 'optionalAccess', _75 => _75.defaultQuote]),onBaseTokenChange:n,onQuoteTokenChange:h,cardStyles:v?B:void 0,cardWidth:v?p:void 0})})]})})})});return $?_jsxruntime.jsx.call(void 0, _chunk46JMXEHJcjs.f.Provider,{value:$,children:oe}):oe}function Ai(){let{openConnectModal:e}=_chunk46JMXEHJcjs.g.call(void 0, ),{isConnected:t,address:d}=_chunk34N36GUDcjs.a.call(void 0, ),o=t&&d?`${d.slice(0,6)}...${d.slice(-4)}`:"Connect";return _jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>e(),className:"h-8 cursor-pointer px-3 text-xs font-bold uppercase tracking-wide transition-colors duration-150 border border-border rounded-sm bg-card text-foreground hover:bg-secondary hover:border-foreground/20",children:o})}var _wagmi = require('wagmi');function Oi(e){let t=Object.entries(_chunkK3RTTHBScjs.b);return Object.fromEntries(t.map(([d,o])=>{let n=_optionalChain([e, 'optionalAccess', _76 => _76[Number(d)]]),h=n?Array.isArray(n)?n:[n]:[],u=h.length>0?[...h,...o.rpcUrls]:o.rpcUrls;return[d,u.length>1?_wagmi.fallback.call(void 0, u.map(M=>_wagmi.http.call(void 0, M,{batch:{batchSize:50,wait:50}}))):_wagmi.http.call(void 0, u[0],{batch:{batchSize:50,wait:50}})]}))}var zi=_chunkK3RTTHBScjs.d.call(void 0, ).map(e=>e.wagmiChain);var Mi=e=>{let{tokenRegistry:t,isLoadingRegistry:d,error:o}=_chunkK3RTTHBScjs.B.call(void 0, );return{tokens:_react.useMemo.call(void 0, ()=>t.filter(h=>h.chainId===e),[t,e]),isLoading:d,error:o}},Bi= exports.useIsTokenSupported =(e,t)=>{let{tokenRegistry:d}=_chunkK3RTTHBScjs.B.call(void 0, );return _react.useMemo.call(void 0, ()=>!e||!d.length?!1:d.some(o=>o.address.toLowerCase()===e.toLowerCase()&&o.chainId===t),[d,e,t])},Ei= exports.useTokenByAddress =(e,t)=>{let{getToken:d}=_chunkK3RTTHBScjs.B.call(void 0, );return _react.useMemo.call(void 0, ()=>{if(!(!e||!t))return d(t,e)},[d,e,t])},Xr=_chunkK3RTTHBScjs.g.call(void 0, );exports.ChainSwitch = _chunk46JMXEHJcjs.p; exports.ConnectButton = Ai; exports.RfqProvider = _chunk46JMXEHJcjs.d; exports.SignSwap = _chunk46JMXEHJcjs.q; exports.SwapFormProvider = _chunkPSCWQFVYcjs.d; exports.SwapWidget = Ni; exports.WidgetThemeProvider = Ye; exports.buildTransports = Oi; exports.canSubmitOrder = _chunk46JMXEHJcjs.s; exports.cleanupOldSubmissions = _chunk46JMXEHJcjs.u; exports.defaultDarkTheme = Ce; exports.defaultLightTheme = Ge; exports.isQuoteFresh = _chunk46JMXEHJcjs.r; exports.markOrderAsSubmitted = _chunk46JMXEHJcjs.t; exports.parseExplorerHash = _chunk46JMXEHJcjs.n; exports.pollOrderStatus = _chunk46JMXEHJcjs.l; exports.themeToCSS = Ke; exports.useBalanceEventListener = _chunk46JMXEHJcjs.a; exports.useBalanceEventSubscription = _chunk46JMXEHJcjs.c; exports.useEmitBalanceEvent = _chunk46JMXEHJcjs.b; exports.useIsTokenSupported = Bi; exports.useOrderStatusPolling = _chunk46JMXEHJcjs.m; exports.useRfq = _chunk46JMXEHJcjs.e; exports.useSwapForm = _chunkPSCWQFVYcjs.c; exports.useSwapFormContext = _chunkPSCWQFVYcjs.e; exports.useTokenByAddress = Ei; exports.useTokenSelection = _chunkPSCWQFVYcjs.b; exports.useTokenSelectionStore = _chunkPSCWQFVYcjs.a; exports.useTokensForChain = Mi; exports.useTransactionRegistry = _chunk46JMXEHJcjs.o; exports.useUnwrapToken = _chunk46JMXEHJcjs.v; exports.useWalletModal = _chunk46JMXEHJcjs.g; exports.useWalletState = _chunk34N36GUDcjs.a; exports.useWidgetSwapUIStore = _chunkD7GULMHEcjs.d; exports.useWidgetTheme = vi; exports.useWrapToken = _chunk46JMXEHJcjs.w; exports.wagmiChains = zi;
package/dist/index.d.cts CHANGED
@@ -8,6 +8,36 @@ import { Chain } from 'wagmi/chains';
8
8
  import * as zustand from 'zustand';
9
9
  import * as _tanstack_react_query from '@tanstack/react-query';
10
10
 
11
+ declare function parseExplorerHash(url: string): string | null;
12
+ interface AoriOrderDetails {
13
+ orderHash: string;
14
+ offerer: string;
15
+ recipient: string;
16
+ inputToken: string;
17
+ inputAmount: string;
18
+ inputChain: string;
19
+ inputTokenValueUsd: string;
20
+ outputToken: string;
21
+ outputAmount: string;
22
+ outputChain: string;
23
+ outputTokenValueUsd: string;
24
+ startTime: number;
25
+ endTime: number;
26
+ timestamp: number;
27
+ srcTx: string | null;
28
+ dstTx: string | null;
29
+ events: Array<{
30
+ event: string;
31
+ timestamp: number;
32
+ }>;
33
+ }
34
+ interface SwapCompleteData {
35
+ quoteId: string;
36
+ aoriOrderHash: string;
37
+ explorerUrl: string;
38
+ details: AoriOrderDetails;
39
+ }
40
+
11
41
  interface Asset {
12
42
  symbol: string;
13
43
  address: string;
@@ -157,14 +187,15 @@ interface AoriSwapWidgetConfig {
157
187
  interface SwapWidgetProps {
158
188
  config: AoriSwapWidgetConfig;
159
189
  className?: string;
160
- onSwapComplete?: (orderHash: string) => void;
190
+ onSwapSubmitted?: (quoteId: string) => void;
191
+ onSwapComplete?: (data: SwapCompleteData) => void;
161
192
  onBaseTokenChange?: (token: Asset) => void;
162
193
  onQuoteTokenChange?: (token: Asset) => void;
163
194
  onRequestConnect?: () => void;
164
195
  onRequestAccount?: () => void;
165
196
  customWalletUI?: 'builtin' | 'none' | 'provider';
166
197
  }
167
- declare function SwapWidget({ config, className, onSwapComplete, onBaseTokenChange, onQuoteTokenChange, onRequestConnect, onRequestAccount, customWalletUI, }: SwapWidgetProps): react_jsx_runtime.JSX.Element;
198
+ declare function SwapWidget({ config, className, onSwapSubmitted, onSwapComplete, onBaseTokenChange, onQuoteTokenChange, onRequestConnect, onRequestAccount, customWalletUI, }: SwapWidgetProps): react_jsx_runtime.JSX.Element;
168
199
 
169
200
  declare function ConnectButton(): react_jsx_runtime.JSX.Element;
170
201
 
@@ -563,4 +594,4 @@ declare function useUnwrapToken(): _tanstack_react_query.UseMutationResult<{
563
594
  hash: `0x${string}`;
564
595
  }, Error, UnwrapTokenParams, unknown>;
565
596
 
566
- export { type AoriSwapWidgetConfig, type Asset, ChainSwitch, ConnectButton, type EnrichedBalance, type PollOrderStatusOptions, type ReviewOrderStep, RfqProvider, SignSwap, type SupportedChainId, SwapFormProvider, SwapWidget, type SwapWidgetProps, type ToastStatus, type TokenRegistryAsset, type TransitionType, type WidgetTheme, WidgetThemeProvider, type WidgetView, buildTransports, canSubmitOrder, cleanupOldSubmissions, defaultDarkTheme, defaultLightTheme, isQuoteFresh, markOrderAsSubmitted, pollOrderStatus, themeToCSS, useBalanceEventListener, useBalanceEventSubscription, useEmitBalanceEvent, useIsTokenSupported, useOrderStatusPolling, useRfq, useSwapForm, useSwapFormContext, useTokenByAddress, useTokenSelection, useTokenSelectionStore, useTokensForChain, useTransactionRegistry, useUnwrapToken, useWalletModal, useWalletState, useWidgetSwapUIStore, useWidgetTheme, useWrapToken, wagmiChains };
597
+ export { type AoriOrderDetails, type AoriSwapWidgetConfig, type Asset, ChainSwitch, ConnectButton, type EnrichedBalance, type PollOrderStatusOptions, type ReviewOrderStep, RfqProvider, SignSwap, type SupportedChainId, type SwapCompleteData, SwapFormProvider, SwapWidget, type SwapWidgetProps, type ToastStatus, type TokenRegistryAsset, type TransitionType, type WidgetTheme, WidgetThemeProvider, type WidgetView, buildTransports, canSubmitOrder, cleanupOldSubmissions, defaultDarkTheme, defaultLightTheme, isQuoteFresh, markOrderAsSubmitted, parseExplorerHash, pollOrderStatus, themeToCSS, useBalanceEventListener, useBalanceEventSubscription, useEmitBalanceEvent, useIsTokenSupported, useOrderStatusPolling, useRfq, useSwapForm, useSwapFormContext, useTokenByAddress, useTokenSelection, useTokenSelectionStore, useTokensForChain, useTransactionRegistry, useUnwrapToken, useWalletModal, useWalletState, useWidgetSwapUIStore, useWidgetTheme, useWrapToken, wagmiChains };