@orbs-network/spot-react 1.1.23 → 1.1.25

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,9 +1,9 @@
1
- (function(k,H){typeof exports=="object"&&typeof module<"u"?H(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],H):(k=typeof globalThis<"u"?globalThis:k||self,H(k.SpotReact={},k.jsxRuntime,k.React))})(this,(function(k,H,P){"use strict";var tc=Object.defineProperty;var Kn=k=>{throw TypeError(k)};var rc=(k,H,P)=>H in k?tc(k,H,{enumerable:!0,configurable:!0,writable:!0,value:P}):k[H]=P;var Pr=(k,H,P)=>rc(k,typeof H!="symbol"?H+"":H,P),ps=(k,H,P)=>H.has(k)||Kn("Cannot "+P);var l=(k,H,P)=>(ps(k,H,"read from private field"),P?P.call(k):H.get(k)),N=(k,H,P)=>H.has(k)?Kn("Cannot add the same private member more than once"):H instanceof WeakSet?H.add(k):H.set(k,P),_=(k,H,P,_t)=>(ps(k,H,"write to private field"),_t?_t.call(k,P):H.set(k,P),P),z=(k,H,P)=>(ps(k,H,"access private method"),P);var Fr=(k,H,P,_t)=>({set _(ce){_(k,H,ce,P)},get _(){return l(k,H,_t)}});var Ke,xt,On,vt,at,qt,In,Kt,ot,Ht,kn,Pt,Mn,Ft,Wt,Me,Tt,fe,sr,Dt,Re,Je,_n,Pe,X,nr,we,Ot,Qt,Ve,ct,ir,jt,zt,It,kt,ut,$t,ee,ur,gs,As,ys,Es,bs,ws,Cs,Hn,Bn,ar,He,Ce,Mt,We,mt,Un,Ge,Le,or,Rn,Xe,dt,Fe,Ze,Ye,Tr,Ss,Ln,Qe,Nn,ne,lt,ht,Vt,Gt,ft,Xt,Zt,qn;function _t(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const ce=_t(P),$={SpookySwap:{chainName:"ftm",chainId:250,twapVersion:4,twapAddress:"0xd3B290FEB04E353d1821bc0a12397FdEa9a846C0",lensAddress:"0x0221EfDF1Fd3212AF87F23cceB7693a65fAF1d7f",takers:["0xDF406A27C58a8Cd6Fd43e143339bCE131216a913","0x504f6E10173249dD22491829D98862Cf81DeF79E"],bidDelaySeconds:60,minChunkSizeUsd:10,name:"SpookySwap",partner:"Orbs:TWAP:SpookySwap",exchangeAddress:"0xdF7CCd5fc7077E9de5f27a7b7bfDC837c82f8496",exchangeType:"ExchangeV2",pathfinderKey:""},SpookySwapSonic:{chainName:"sonic",chainId:146,twapVersion:4,twapAddress:"0x8963992816b4EafE5a22b7DB2A99513c18be9afA",lensAddress:"0x67e631F71232D63AcA98a2D5E9B2Bce5FCc39d5D",takers:["0xDF406A27C58a8Cd6Fd43e143339bCE131216a913","0x504f6E10173249dD22491829D98862Cf81DeF79E"],bidDelaySeconds:60,minChunkSizeUsd:10,name:"SpookySwapSonic",partner:"Orbs:TWAP:SpookySwap",exchangeAddress:"0x6699bE3aF75e5c1B807b1031dBde6dA9A67739F3",exchangeType:"ExchangeV2",pathfinderKey:""},QuickSwap:{chainName:"poly",chainId:137,twapVersion:4,twapAddress:"0x688C027B0f7FaCeFcBa73e472900d28c12C5bDF4",lensAddress:"0xe0D4E736fc76af7C256ae7652c8c1e850bfb7849",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:10,name:"QuickSwap",partner:"Orbs:TWAP:QuickSwap",exchangeAddress:"0x8FCc245209bE85C49D738D0CE5613F74E5d91E86",exchangeType:"ParaswapExchange",pathfinderKey:"QuickSwap,QuickSwapV3"},QuickSwapBase:{chainName:"base",chainId:8453,twapVersion:4,twapAddress:"0xc918bdC47264687796Cd54FE362FaC4f8b99Eb55",lensAddress:"0x6313188c1909b161074D62E43105faC9B756A23e",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:10,name:"QuickSwap",partner:"Orbs:TWAP:QuickSwap",exchangeAddress:"0xb7a3d74895bfd3aff6780525e36d79fcf26a895f",exchangeType:"ExchangeV2",pathfinderKey:""},Thena:{chainName:"bsc",chainId:56,twapVersion:4,twapAddress:"0xa6F7444D2b92Aa9F94a2165c77aAF2B671e63994",lensAddress:"0xEdB0c077fa87Fb21d050c619FF426798f8Fc1264",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"Thena",partner:"Orbs:TWAP:Thena",exchangeAddress:"0x2B2fABDbfa4a15da0d351F947C14F4520db0bDc1",exchangeType:"ExchangeV2",pathfinderKey:"43,47"},PancakeSwap:{chainName:"bsc",chainId:56,twapVersion:4,twapAddress:"0xa6F7444D2b92Aa9F94a2165c77aAF2B671e63994",lensAddress:"0xEdB0c077fa87Fb21d050c619FF426798f8Fc1264",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"PancakeSwap",partner:"Orbs:TWAP:PancakeSwap",exchangeAddress:"0x1A2bb6B75D58b740d88413ef4840D6fa3F637940",exchangeType:"P2Exchange",pathfinderKey:""},PancakeSwapArbitrum:{chainName:"arb",chainId:42161,twapVersion:4,twapAddress:"0x0B94dcC0EA2d1ee33Ab064DaC252de980a941eF3",lensAddress:"0x549e1fc9a47FCc0C5C2EbdfF31254cc49fF7164e",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"PancakeSwap",partner:"Orbs:TWAP:PancakeSwap",exchangeAddress:"0xb37cB9A058c03081Ae6EF934313588cD53d408e7",exchangeType:"P2Exchange",pathfinderKey:""},PancakeSwapBase:{chainName:"base",chainId:8453,twapVersion:4,twapAddress:"0xc918bdC47264687796Cd54FE362FaC4f8b99Eb55",lensAddress:"0x6313188c1909b161074D62E43105faC9B756A23e",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"PancakeSwap",partner:"Orbs:TWAP:PancakeSwap",exchangeAddress:"0xb37cB9A058c03081Ae6EF934313588cD53d408e7",exchangeType:"P2Exchange",pathfinderKey:""},PancakeSwapLinea:{chainName:"linea",chainId:59144,twapVersion:4,twapAddress:"0x48423e62acbfEF7779b5b4a5E7d6Fbd39E623d78",lensAddress:"0xe84CaEc86eCF3f0AB4267dC6130D9a5510e73DFb",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:100,name:"PancakeSwap",partner:"Orbs:TWAP:PancakeSwap",exchangeAddress:"0xb37cB9A058c03081Ae6EF934313588cD53d408e7",exchangeType:"P2Exchange",pathfinderKey:""},Lynex:{chainName:"linea",chainId:59144,twapVersion:4,twapAddress:"0x48423e62acbfEF7779b5b4a5E7d6Fbd39E623d78",lensAddress:"0xe84CaEc86eCF3f0AB4267dC6130D9a5510e73DFb",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:100,name:"Lynex",partner:"Orbs:TWAP:Lynex",exchangeAddress:"0x04C06C96d7D19977156016DD408B5992af0570a2",exchangeType:"ExchangeV2",pathfinderKey:"19,18"},SushiArb:{chainName:"arb",chainId:42161,twapVersion:4,twapAddress:"0x0B94dcC0EA2d1ee33Ab064DaC252de980a941eF3",lensAddress:"0x549e1fc9a47FCc0C5C2EbdfF31254cc49fF7164e",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"SushiArb",partner:"Orbs:TWAP:Sushi",exchangeAddress:"0x04eB53119079FA779492720D1EfeAEBF0aF2e5ad",exchangeType:"ExchangeV2",pathfinderKey:""},SushiBase:{chainName:"base",chainId:8453,twapVersion:4,twapAddress:"0xc918bdC47264687796Cd54FE362FaC4f8b99Eb55",lensAddress:"0x6313188c1909b161074D62E43105faC9B756A23e",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"SushiBase",partner:"Orbs:TWAP:Sushi",exchangeAddress:"0x04eB53119079FA779492720D1EfeAEBF0aF2e5ad",exchangeType:"ExchangeV2",pathfinderKey:""},SushiEth:{chainName:"eth",chainId:1,twapVersion:4,twapAddress:"0xb1ed8BCAD1EaC8a1DF0764700472391800D12946",lensAddress:"0x0967f448c4d4dbd14c355E635AE9CbF68cc44A60",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:200,name:"SushiEth",partner:"Orbs:TWAP:Sushi",exchangeAddress:"0x04eB53119079FA779492720D1EfeAEBF0aF2e5ad",exchangeType:"ExchangeV2",pathfinderKey:""},SushiKatana:{chainName:"katana",chainId:747474,twapVersion:4,twapAddress:"0xf2d96E7BE676153d202e1453804E2749923C7c5b",lensAddress:"0x1579EED0527781B1A748043AA1f59a3858Ace4a7",takers:["0xF74437A3Fc45a518640828E5D6A3E8c9A9BbDC3a","0x07A6C715063e94c0D95e809efefFCbF4EBEdfD55"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"SushiKatana",partner:"Orbs:TWAP:Sushi",exchangeAddress:"0x92209481507e6B2d14C9b5b70Ed287024177220E",exchangeType:"ExchangeV2",pathfinderKey:""},DragonSwap:{chainId:1329,name:"DragonSwap"},SwapX:{chainName:"sonic",chainId:146,twapVersion:4,twapAddress:"0x8963992816b4EafE5a22b7DB2A99513c18be9afA",lensAddress:"0x67e631F71232D63AcA98a2D5E9B2Bce5FCc39d5D",takers:["0xDF406A27C58a8Cd6Fd43e143339bCE131216a913","0x504f6E10173249dD22491829D98862Cf81DeF79E"],bidDelaySeconds:60,minChunkSizeUsd:10,name:"SwapX",partner:"Orbs:TWAP:SwapX",exchangeAddress:"0xDA902994b7F7a1ecDd8De02E4a17dbFF2E6F67b7",exchangeType:"ExchangeV2",pathfinderKey:""},BlackholeAvax:{chainName:"avax",chainId:43114,twapVersion:4,twapAddress:"0xf77Ad005aBF7e31f669ce89a6568B2f39Ca92cDe",lensAddress:"0x48466B82Ce1575c5c9eCa168ac1090048dD47fA3",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"BlackholeAvax",partner:"Orbs:TWAP:BlackholeAvax",exchangeAddress:"0xb7A3d74895bFD3Aff6780525e36D79FCf26a895F",exchangeType:"ExchangeV2"}};var j=(e=>(e.TWAP="TWAP",e.LIMIT="LIMIT",e.STOP_LOSS="STOP_LOSS",e.TAKE_PROFIT="TAKE_PROFIT",e))(j||{}),me=(e=>(e.Open="OPEN",e.Cancelled="CANCELLED",e.Completed="COMPLETED",e.Expired="EXPIRED",e))(me||{}),xs=(e=>(e.All="ALL",e.Open="OPEN",e.Cancelled="CANCELLED",e.Completed="COMPLETED",e.Expired="EXPIRED",e))(xs||{}),Te=(e=>(e[e.Minutes=6e4]="Minutes",e[e.Hours=36e5]="Hours",e[e.Weeks=6048e5]="Weeks",e[e.Days=864e5]="Days",e[e.Months=2592e6]="Months",e[e.Years=31536e6]="Years",e))(Te||{}),V=(e=>(e.LIMIT="limit",e.TWAP_LIMIT="twap-limit",e.TWAP_MARKET="twap-market",e.TAKE_PROFIT_MARKET="take-profit-market",e.TAKE_PROFIT_LIMIT="take-profit-limit",e.STOP_LOSS_LIMIT="stop-loss-limit",e.STOP_LOSS_MARKET="stop-loss-market",e))(V||{}),Ne=(e=>(e.Arbidex="arbidex",e.Blackhole="blackhole",e.Chronos="chronos",e.Dragon="dragon",e.Kodiak="kodiak",e.Lynex="lynex",e.Nami="nami",e.Newera="newera",e.Omni="omni",e.Pancake="pancake",e.Quick="quick",e.Ramses="ramses",e.Shadow="shadow",e.Spark="spark",e.Spooky="spooky",e.Swapx="swapx",e.Teafi="teafi",e.Thena="thena",e.Yowie="yowie",e.Pangolin="pangolin",e.Sushiswap="sushiswap",e.Agent="agent",e))(Ne||{}),pe=(e=>(e.EMPTY_LIMIT_PRICE="emptyLimitPrice",e.MAX_CHUNKS="maxChunksError",e.MIN_CHUNKS="minChunksError",e.MIN_TRADE_SIZE="minTradeSizeError",e.MAX_FILL_DELAY="maxFillDelayError",e.MIN_FILL_DELAY="minFillDelayError",e.MAX_ORDER_DURATION="maxDurationError",e.MIN_ORDER_DURATION="minDurationError",e.MISSING_LIMIT_PRICE="missingLimitPrice",e.STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE="StopLossTriggerPriceError",e.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE="triggerLimitPriceError",e.TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE="TakeProfitTriggerPriceError",e.EMPTY_TRIGGER_PRICE="emptyTriggerPrice",e.INSUFFICIENT_BALANCE="insufficientFunds",e.MAX_ORDER_SIZE="maxOrderSize",e.MIN_TRADE_SIZE_ERROR="minTradeSizeError",e))(pe||{});const se="0x0000000000000000000000000000000000000000",ge={eth:{id:1,name:"Ethereum",shortname:"eth",native:{address:se,symbol:"ETH",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg"},wToken:{symbol:"WETH",address:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://eth.llamarpc.com",logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg",explorer:"https://etherscan.io",eip1559:!0},bsc:{id:56,name:"BinanceSmartChain",shortname:"bsc",native:{address:se,symbol:"BNB",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/1839.png"},wToken:{symbol:"WBNB",address:"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/1839.png"},publicRpcUrl:"https://bsc-dataseed.binance.org",logoUrl:"https://app.1inch.io/assets/images/network-logos/bsc_2.svg",explorer:"https://bscscan.com",eip1559:!1},poly:{id:137,name:"Polygon",shortname:"poly",native:{address:se,symbol:"POL",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/64x64/28321.png"},wToken:{symbol:"WPOL",address:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270.png"},publicRpcUrl:"https://polygon-rpc.com",logoUrl:"https://app.1inch.io/assets/images/network-logos/polygon.svg",explorer:"https://polygonscan.com",eip1559:!0},arb:{id:42161,name:"Arbitrum",shortname:"arb",native:{address:se,symbol:"ETH",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg"},wToken:{symbol:"WETH",address:"0x82af49447d8a07e3bd95bd0d56f35241523fbab1",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://arb1.arbitrum.io/rpc",logoUrl:"https://app.1inch.io/assets/images/network-logos/arbitrum.svg",explorer:"https://arbiscan.io",eip1559:!0},sei:{id:1329,name:"Sei",shortname:"sei",native:{address:se,symbol:"SEI",decimals:18,logoUrl:"https://assets.coingecko.com/coins/images/28205/standard/Sei_Logo_-_Transparent.png"},wToken:{symbol:"WSEI",address:"0xE30feDd158A2e3b13e9badaeABaFc5516e95e8C7",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://evm-rpc.sei-apis.com",logoUrl:"https://assets.coingecko.com/coins/images/28205/standard/Sei_Logo_-_Transparent.png",explorer:"https://seitrace.com",eip1559:!1},avax:{id:43114,name:"Avalanche",shortname:"avax",native:{address:se,symbol:"AVAX",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/avalanche.svg"},wToken:{symbol:"WAVAX",address:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7.png"},publicRpcUrl:"https://api.avax.network/ext/bc/C/rpc",logoUrl:"https://app.1inch.io/assets/images/network-logos/avalanche.svg",explorer:"https://snowtrace.io",eip1559:!0},ftm:{id:250,name:"Fantom",shortname:"ftm",native:{address:se,symbol:"FTM",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/fantom.svg"},wToken:{symbol:"WFTM",address:"0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0x4e15361fd6b4bb609fa63c81a2be19d873717870.png"},publicRpcUrl:"https://rpc.ftm.tools",logoUrl:"https://app.1inch.io/assets/images/network-logos/fantom.svg",explorer:"https://ftmscan.com",eip1559:!0},base:{id:8453,name:"Base",shortname:"base",native:{address:se,symbol:"ETH",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/1027.png"},wToken:{symbol:"WETH",address:"0x4200000000000000000000000000000000000006",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://mainnet.base.org",logoUrl:"https://app.1inch.io/assets/images/network-logos/base.svg",explorer:"https://basescan.org",eip1559:!1},linea:{id:59144,name:"Linea",shortname:"linea",native:{address:se,symbol:"ETH",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg"},wToken:{symbol:"WETH",address:"0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://rpc.linea.build",logoUrl:"https://lineascan.build/images/logo.svg",explorer:"https://lineascan.build",eip1559:!1},zksync:{id:324,name:"zksync",shortname:"zksync",native:{address:se,symbol:"ETH",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg"},wToken:{symbol:"WETH",address:"0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://mainnet.era.zksync.io",logoUrl:"https://raw.githubusercontent.com/matter-labs/zksync/0a4ca2145a0c95b5bafa84c2f095c644907a8825/zkSyncLogo.svg",explorer:"https://explorer.zksync.io/",eip1559:!0},zkevm:{id:1101,name:"zkevm",shortname:"zkevm",native:{address:se,symbol:"ETH",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg"},wToken:{symbol:"WETH",address:"0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://zkevm-rpc.com",logoUrl:"https://user-images.githubusercontent.com/18598517/235932702-bc47eae5-d672-4dd9-9da2-8ea8f51a93f3.png",explorer:"https://zkevm.polygonscan.com/",eip1559:!0},manta:{id:169,name:"manta",shortname:"manta",native:{address:se,symbol:"ETH",decimals:18,logoUrl:"https://icons.llamao.fi/icons/chains/rsz_manta.jpg"},wToken:{symbol:"WETH",address:"0x0Dc808adcE2099A9F62AA87D9670745AbA741746",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://pacific-rpc.manta.network/http",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_manta.jpg",explorer:"https://manta.socialscan.io/",eip1559:!0},blast:{id:81457,name:"blast",shortname:"blast",native:{address:se,symbol:"ETH",decimals:18,logoUrl:"https://icons.llamao.fi/icons/chains/rsz_blast"},wToken:{symbol:"WETH",address:"0x4300000000000000000000000000000000000004",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://rpc.ankr.com/blast",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_blast",explorer:"https://blastscan.io/",eip1559:!0},sonic:{id:146,name:"sonic",shortname:"sonic",native:{address:se,symbol:"S",decimals:18,logoUrl:"https://icons.llamao.fi/icons/chains/rsz_sonic"},wToken:{symbol:"WS",address:"0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38",decimals:18,logoUrl:"https://icons.llamao.fi/icons/chains/rsz_sonic"},publicRpcUrl:"https://rpc.soniclabs.com",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_sonic",explorer:"https://www.sonicscan.org/",eip1559:!0},scroll:{id:534352,name:"scroll",shortname:"scroll",native:{address:se,symbol:"ETH",decimals:18,logoUrl:"https://icons.llamao.fi/icons/chains/rsz_scroll"},wToken:{symbol:"WETH",address:"0x5300000000000000000000000000000000000004",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://scroll-rpc.publicnode.com",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_scroll",explorer:"https://scrollscan.com/",eip1559:!0},zircuit:{id:48900,name:"Zircuit",shortname:"zircuit",native:{address:se,symbol:"ETH",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg"},wToken:{symbol:"WETH",address:"0x4200000000000000000000000000000000000006",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://zircuit-mainnet.drpc.org",logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg",explorer:"https://explorer.zircuit.com/",eip1559:!0},flare:{id:14,name:"flare",shortname:"flare",native:{address:se,symbol:"FLR",decimals:18,logoUrl:"https://icons.llamao.fi/icons/chains/rsz_flare?w=48&h=48"},wToken:{symbol:"WFLR",address:"0x1D80c49BbBCd1C0911346656B529DF9E5c2F783d",decimals:18,logoUrl:"https://res.cloudinary.com/sparkdex/image/upload/q_100/v1/website-assets/coins/wflr?_a=DATAg1AAZAA0"},publicRpcUrl:"https://flare.network",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_flare?w=48&h=48",explorer:"https://flarescan.com",eip1559:!0},cronosZkEvm:{id:388,name:"Cronos zkEVM",shortname:"cronosZkEvm",native:{address:"0x000000000000000000000000000000000000800a",symbol:"zkCRO",decimals:18,logoUrl:"https://cryptologos.cc/logos/cronos-cro-logo.png"},wToken:{symbol:"wzkCRO",address:"0xC1bF55EE54E16229d9b369a5502Bfe5fC9F20b6d",decimals:18,logoUrl:"https://cryptologos.cc/logos/cronos-cro-logo.png"},publicRpcUrl:"https://rpc.zkevm.cronos.org",logoUrl:"https://cryptologos.cc/logos/cronos-cro-logo.png",explorer:"https://explorer.zkevm.cronos.org",eip1559:!0},katana:{id:747474,name:"Katana",shortname:"katana",native:{address:se,symbol:"ETH",decimals:18,logoUrl:"https://katana.network/assets/katana-logo.svg"},wToken:{symbol:"WETH",address:"0xee7d8bcfb72bc1880d0cf19822eb0a2e6577ab62",decimals:18,logoUrl:"https://katana.network/assets/weth-logo.svg"},publicRpcUrl:"https://rpc.katanarpc.com",logoUrl:"https://katana.network/assets/katana-logo.svg",explorer:"https://explorer.katana.garden",eip1559:!0},bera:{id:80094,name:"Bera",shortname:"bera",native:{address:se,symbol:"BERA",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/24647.png"},wToken:{symbol:"WBERA",address:"0x6969696969696969696969696969696969696969",decimals:18,logoUrl:"https://berascan.com/token/images/wrappedbera_ofc_64.png"},publicRpcUrl:"wss://rpc.berachain-apis.com",logoUrl:"https://katana.network/assets/katana-logo.svg",explorer:"https://berascan.com",eip1559:!0},monad:{id:143,name:"Monad",shortname:"monad",native:{address:se,symbol:"MONAD",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/30495.png"},wToken:{symbol:"WMON",address:"0x3bd359c1119da7da1d913d1c4d2b7c461115433a",decimals:18,logoUrl:"https://assets.coingecko.com/coins/images/70784/standard/wmon.png?1766028904"},publicRpcUrl:"https://monad-mainnet.drpc.org",logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/30495.png",explorer:"https://monad.network",eip1559:!0},optimism:{id:10,name:"Optimism",shortname:"optimism",native:{address:se,symbol:"ETH",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/11840.png"},wToken:{symbol:"WETH",address:"0x4200000000000000000000000000000000000006",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/2396.png"},publicRpcUrl:"https://optimism.blockscout.com",logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/11840.png",explorer:"https://optimistic.etherscan.io",eip1559:!0},mantle:{id:5e3,name:"Mantle",shortname:"mantle",native:{address:se,symbol:"MNT",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/27075.png"},wToken:{symbol:"WMNT",address:"0x78c1b0c915c4faa5fffa6cabf0219da63d7f4cb8",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/27614.png"},publicRpcUrl:"https://rpc.mantle.xyz",logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/27075.png",explorer:"https://mantlescan.xyz",eip1559:!0}},Dr={version:"2.4.1"},Wn="https://order-sink-dev.orbs.network",Qn="https://order-sink.orbs.network",jn="https://order-sink-v2.orbs.network",dr=Dr.version.split(".")[0],vs=e=>{const t=Number(dr)>=2;return e?Wn:t?jn:Qn},Or=300*1e3,lr=1440*60*60*1e3,Ps=300*1e3,zn=new Date(Or).getMinutes(),Ir=e=>`https://hub.orbs.network/api/private/project_cm7nb67z86nyr01z12gs0fxpf/subgraphs/orbs-twap-${e}/prod/gn`,Be="https://hub.orbs.network/api/apikey/subgraphs/id",$n={[ge.eth.id]:`${Be}/Bf7bvMYcJbDAvYWJmhMpHZ4cpFjqzkhK6GXXEpnPRq6`,[ge.bsc.id]:`${Be}/4NfXEi8rreQsnAr4aJ45RLCKgnjcWX46Lbt9SadiCcz6`,[ge.poly.id]:`${Be}/3PyRPWSvDnMowGbeBy7aNsvUkD5ZuxdXQw2RdJq4NdXi`,[ge.arb.id]:`${Be}/83bpQexEaqBjHaQbKoFTbtvCXuo5RudRkfLgtRUYqo2c`,[ge.base.id]:`${Be}/DFhaPQb3HATXkpsWNZw3gydYHehLBVEDiSk4iBdZJyps`,[ge.sei.id]:`${Be}/5zjzRnURzoddyFSZBw5E5NAM3oBgPq3NasTYbtMk6EL6`,[ge.linea.id]:`${Be}/6VsNPEYfFLPZCqdMMDadoXQjLHWJdjEwiD768GAtb7j6`,[ge.sonic.id]:`${Be}/DtBr6a5vsoDd2oAXdPszcn4gLgrr1XC68Q3AJQKXnNLV`,[ge.ftm.id]:`${Be}/DdRo1pmJkrJC9fjsjEBWnNE1uqrbh7Diz4tVKd7rfupp`,[ge.katana.id]:`${Be}/CGi9sDFMQcnBwF3C3NoCFqnaE34sssbgwPLTwiskSXmW`,[ge.avax.id]:`${Be}/FxZ1vMwE5Xy1qvKvZENUMz4vhW8Sh4vXJf9Vp7o17pTx`,[ge.bera.id]:Ir("berachain"),[ge.flare.id]:Ir("flare"),[ge.cronosZkEvm.id]:Ir("cronos-zkevm")},Vn=["0x0000000000000000000000000000000000000000","0x0000000000000000000000000000000000001010","0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE","0x000000000000000000000000000000000000dEaD","0x000000000000000000000000000000000000800A","0x000000000000000000000000000000000000800a"],kr="115792089237316195423570985008687907853269984665640564039457584007913129639935",ye=e=>`${e.name}_${e.chainId}`,Gn={[ye($.SushiArb)]:["0x846F2B29ef314bF3D667981b4ffdADc5B858312a","0x08c41f5D1C844061f6D952E25827eeAA576c6536"],[ye($.SushiBase)]:["0x846F2B29ef314bF3D667981b4ffdADc5B858312a","0x08c41f5D1C844061f6D952E25827eeAA576c6536"],[ye($.SushiEth)]:["0xc55943Fa6509004B2903ED8F8ab7347BfC47D0bA","0x08c41f5D1C844061f6D952E25827eeAA576c6536"],[ye($.PancakeSwap)]:["0xb2BAFe188faD927240038cC4FfF2d771d8A58905","0xE2a0c3b9aD19A18c4bBa7fffBe5bC1b0E58Db1CE"],[ye($.PancakeSwapArbitrum)]:["0xE20167871dB616DdfFD0Fd870d9bC068C350DD1F","0x807488ADAD033e95C438F998277bE654152594dc"],[ye($.PancakeSwapBase)]:["0x10ed1F36e4eBE76E161c9AADDa20BE841bc0082c","0x3A9df3eE209b802D0337383f5abCe3204d623588"],[ye($.PancakeSwapLinea)]:["0x3A9df3eE209b802D0337383f5abCe3204d623588"],[ye($.QuickSwap)]:["0x26D0ec4Be402BCE03AAa8aAf0CF67e9428ba54eF"],[ye($.Thena)]:["0xc2aBC02acd77Bb2407efA22348dA9afC8B375290"],[ye($.Lynex)]:["0x72e3e1fD5D2Ee2F1C2Eb695206D490a1D45C3835"],[ye($.DragonSwap)]:["0x101e1B65Bb516FB5f4547C80BAe0b51f1b8D7a22"],[ye($.SpookySwapSonic)]:["0xAd97B770ad64aE47fc7d64B3bD820dCDbF9ff7DA"],[ye($.SpookySwap)]:["0x3924d62219483015f982b160d48c0fa5Fd436Cba"],[ye($.SwapX)]:["0xE5012eBDe5e26EE3Ea41992154731a03023CF274"]},Mr={unit:Te.Minutes,value:zn},Fs="RePermitWitnessTransferFrom",Xn={RePermitWitnessTransferFrom:[{name:"permitted",type:"TokenPermissions"},{name:"spender",type:"address"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"},{name:"witness",type:"Order"}],Exchange:[{name:"adapter",type:"address"},{name:"ref",type:"address"},{name:"share",type:"uint32"},{name:"data",type:"bytes"}],Input:[{name:"token",type:"address"},{name:"amount",type:"uint256"},{name:"maxAmount",type:"uint256"}],Order:[{name:"reactor",type:"address"},{name:"executor",type:"address"},{name:"exchange",type:"Exchange"},{name:"swapper",type:"address"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"},{name:"chainid",type:"uint256"},{name:"exclusivity",type:"uint32"},{name:"epoch",type:"uint32"},{name:"slippage",type:"uint32"},{name:"freshness",type:"uint32"},{name:"input",type:"Input"},{name:"output",type:"Output"}],Output:[{name:"token",type:"address"},{name:"limit",type:"uint256"},{name:"stop",type:"uint256"},{name:"recipient",type:"address"}],TokenPermissions:[{name:"token",type:"address"},{name:"amount",type:"uint256"}]},Zn={RePermitWitnessTransferFrom:[{name:"permitted",type:"TokenPermissions"},{name:"spender",type:"address"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"},{name:"witness",type:"Order"}],Exchange:[{name:"adapter",type:"address"},{name:"ref",type:"address"},{name:"share",type:"uint32"},{name:"data",type:"bytes"}],Input:[{name:"token",type:"address"},{name:"amount",type:"uint256"},{name:"maxAmount",type:"uint256"}],Order:[{name:"reactor",type:"address"},{name:"executor",type:"address"},{name:"exchange",type:"Exchange"},{name:"swapper",type:"address"},{name:"nonce",type:"uint256"},{name:"start",type:"uint256"},{name:"deadline",type:"uint256"},{name:"chainid",type:"uint256"},{name:"exclusivity",type:"uint32"},{name:"epoch",type:"uint32"},{name:"slippage",type:"uint32"},{name:"freshness",type:"uint32"},{name:"input",type:"Input"},{name:"output",type:"Output"}],Output:[{name:"token",type:"address"},{name:"limit",type:"uint256"},{name:"triggerLower",type:"uint256"},{name:"triggerUpper",type:"uint256"},{name:"recipient",type:"address"}],TokenPermissions:[{name:"token",type:"address"},{name:"amount",type:"uint256"}]},Yn="https://www.orbs.com/dtwap-and-dlimit-faq/",Jn="https://www.orbs.com/dtwap-and-dlimit-faq/#dSLTP",ei="https://raw.githubusercontent.com/orbs-network/twap-ui/master/logo/orbslogo.svg",ti="https://www.orbs.com/",ri="https://www.orbs.com/dtwap-dlimit-disclaimer";var Yt=(e=>(e.FRESHNESS="freshness",e.MIN_CHUNK_SIZE_USD="minChunkSizeUsd",e.ENV="env",e.DURATION="duration",e.IGNORE_ERRORS="ignore-errors",e))(Yt||{});const si="-5",ni="10",ii="-10",ai="5";var oi=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,_r=Math.ceil,De=Math.floor,xe="[BigNumber Error] ",Ts=xe+"Number primitive has more than 15 significant digits: ",Ue=1e14,W=14,Br=9007199254740991,Ur=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],et=1e7,le=1e9;function Ds(e){var t,r,s,n=T.prototype={constructor:T,toString:null,valueOf:null},i=new T(1),o=20,d=4,h=-7,f=21,S=-1e7,E=1e7,x=!1,F=1,I=0,O={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},M="0123456789abcdefghijklmnopqrstuvwxyz",B=!0;function T(a,c){var u,y,p,g,C,m,A,w,b=this;if(!(b instanceof T))return new T(a,c);if(c==null){if(a&&a._isBigNumber===!0){b.s=a.s,!a.c||a.e>E?b.c=b.e=null:a.e<S?b.c=[b.e=0]:(b.e=a.e,b.c=a.c.slice());return}if((m=typeof a=="number")&&a*0==0){if(b.s=1/a<0?(a=-a,-1):1,a===~~a){for(g=0,C=a;C>=10;C/=10,g++);g>E?b.c=b.e=null:(b.e=g,b.c=[a]);return}w=String(a)}else{if(!oi.test(w=String(a)))return s(b,w,m);b.s=w.charCodeAt(0)==45?(w=w.slice(1),-1):1}(g=w.indexOf("."))>-1&&(w=w.replace(".","")),(C=w.search(/e/i))>0?(g<0&&(g=C),g+=+w.slice(C+1),w=w.substring(0,C)):g<0&&(g=w.length)}else{if(re(c,2,M.length,"Base"),c==10&&B)return b=new T(a),Y(b,o+b.e+1,d);if(w=String(a),m=typeof a=="number"){if(a*0!=0)return s(b,w,m,c);if(b.s=1/a<0?(w=w.slice(1),-1):1,T.DEBUG&&w.replace(/^0\.0*|\./,"").length>15)throw Error(Ts+a)}else b.s=w.charCodeAt(0)===45?(w=w.slice(1),-1):1;for(u=M.slice(0,c),g=C=0,A=w.length;C<A;C++)if(u.indexOf(y=w.charAt(C))<0){if(y=="."){if(C>g){g=A;continue}}else if(!p&&(w==w.toUpperCase()&&(w=w.toLowerCase())||w==w.toLowerCase()&&(w=w.toUpperCase()))){p=!0,C=-1,g=0;continue}return s(b,String(a),m,c)}m=!1,w=r(w,c,10,b.s),(g=w.indexOf("."))>-1?w=w.replace(".",""):g=w.length}for(C=0;w.charCodeAt(C)===48;C++);for(A=w.length;w.charCodeAt(--A)===48;);if(w=w.slice(C,++A)){if(A-=C,m&&T.DEBUG&&A>15&&(a>Br||a!==De(a)))throw Error(Ts+b.s*a);if((g=g-C-1)>E)b.c=b.e=null;else if(g<S)b.c=[b.e=0];else{if(b.e=g,b.c=[],C=(g+1)%W,g<0&&(C+=W),C<A){for(C&&b.c.push(+w.slice(0,C)),A-=W;C<A;)b.c.push(+w.slice(C,C+=W));C=W-(w=w.slice(C)).length}else C-=A;for(;C--;w+="0");b.c.push(+w)}}else b.c=[b.e=0]}T.clone=Ds,T.ROUND_UP=0,T.ROUND_DOWN=1,T.ROUND_CEIL=2,T.ROUND_FLOOR=3,T.ROUND_HALF_UP=4,T.ROUND_HALF_DOWN=5,T.ROUND_HALF_EVEN=6,T.ROUND_HALF_CEIL=7,T.ROUND_HALF_FLOOR=8,T.EUCLID=9,T.config=T.set=function(a){var c,u;if(a!=null)if(typeof a=="object"){if(a.hasOwnProperty(c="DECIMAL_PLACES")&&(u=a[c],re(u,0,le,c),o=u),a.hasOwnProperty(c="ROUNDING_MODE")&&(u=a[c],re(u,0,8,c),d=u),a.hasOwnProperty(c="EXPONENTIAL_AT")&&(u=a[c],u&&u.pop?(re(u[0],-le,0,c),re(u[1],0,le,c),h=u[0],f=u[1]):(re(u,-le,le,c),h=-(f=u<0?-u:u))),a.hasOwnProperty(c="RANGE"))if(u=a[c],u&&u.pop)re(u[0],-le,-1,c),re(u[1],1,le,c),S=u[0],E=u[1];else if(re(u,-le,le,c),u)S=-(E=u<0?-u:u);else throw Error(xe+c+" cannot be zero: "+u);if(a.hasOwnProperty(c="CRYPTO"))if(u=a[c],u===!!u)if(u)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))x=u;else throw x=!u,Error(xe+"crypto unavailable");else x=u;else throw Error(xe+c+" not true or false: "+u);if(a.hasOwnProperty(c="MODULO_MODE")&&(u=a[c],re(u,0,9,c),F=u),a.hasOwnProperty(c="POW_PRECISION")&&(u=a[c],re(u,0,le,c),I=u),a.hasOwnProperty(c="FORMAT"))if(u=a[c],typeof u=="object")O=u;else throw Error(xe+c+" not an object: "+u);if(a.hasOwnProperty(c="ALPHABET"))if(u=a[c],typeof u=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(u))B=u.slice(0,10)=="0123456789",M=u;else throw Error(xe+c+" invalid: "+u)}else throw Error(xe+"Object expected: "+a);return{DECIMAL_PLACES:o,ROUNDING_MODE:d,EXPONENTIAL_AT:[h,f],RANGE:[S,E],CRYPTO:x,MODULO_MODE:F,POW_PRECISION:I,FORMAT:O,ALPHABET:M}},T.isBigNumber=function(a){if(!a||a._isBigNumber!==!0)return!1;if(!T.DEBUG)return!0;var c,u,y=a.c,p=a.e,g=a.s;e:if({}.toString.call(y)=="[object Array]"){if((g===1||g===-1)&&p>=-le&&p<=le&&p===De(p)){if(y[0]===0){if(p===0&&y.length===1)return!0;break e}if(c=(p+1)%W,c<1&&(c+=W),String(y[0]).length==c){for(c=0;c<y.length;c++)if(u=y[c],u<0||u>=Ue||u!==De(u))break e;if(u!==0)return!0}}}else if(y===null&&p===null&&(g===null||g===1||g===-1))return!0;throw Error(xe+"Invalid BigNumber: "+a)},T.maximum=T.max=function(){return U(arguments,-1)},T.minimum=T.min=function(){return U(arguments,1)},T.random=(function(){var a=9007199254740992,c=Math.random()*a&2097151?function(){return De(Math.random()*a)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(u){var y,p,g,C,m,A=0,w=[],b=new T(i);if(u==null?u=o:re(u,0,le),C=_r(u/W),x)if(crypto.getRandomValues){for(y=crypto.getRandomValues(new Uint32Array(C*=2));A<C;)m=y[A]*131072+(y[A+1]>>>11),m>=9e15?(p=crypto.getRandomValues(new Uint32Array(2)),y[A]=p[0],y[A+1]=p[1]):(w.push(m%1e14),A+=2);A=C/2}else if(crypto.randomBytes){for(y=crypto.randomBytes(C*=7);A<C;)m=(y[A]&31)*281474976710656+y[A+1]*1099511627776+y[A+2]*4294967296+y[A+3]*16777216+(y[A+4]<<16)+(y[A+5]<<8)+y[A+6],m>=9e15?crypto.randomBytes(7).copy(y,A):(w.push(m%1e14),A+=7);A=C/7}else throw x=!1,Error(xe+"crypto unavailable");if(!x)for(;A<C;)m=c(),m<9e15&&(w[A++]=m%1e14);for(C=w[--A],u%=W,C&&u&&(m=Ur[W-u],w[A]=De(C/m)*m);w[A]===0;w.pop(),A--);if(A<0)w=[g=0];else{for(g=-1;w[0]===0;w.splice(0,1),g-=W);for(A=1,m=w[0];m>=10;m/=10,A++);A<W&&(g-=W-A)}return b.e=g,b.c=w,b}})(),T.sum=function(){for(var a=1,c=arguments,u=new T(c[0]);a<c.length;)u=u.plus(c[a++]);return u},r=(function(){var a="0123456789";function c(u,y,p,g){for(var C,m=[0],A,w=0,b=u.length;w<b;){for(A=m.length;A--;m[A]*=y);for(m[0]+=g.indexOf(u.charAt(w++)),C=0;C<m.length;C++)m[C]>p-1&&(m[C+1]==null&&(m[C+1]=0),m[C+1]+=m[C]/p|0,m[C]%=p)}return m.reverse()}return function(u,y,p,g,C){var m,A,w,b,D,R,L,G,ie=u.indexOf("."),de=o,J=d;for(ie>=0&&(b=I,I=0,u=u.replace(".",""),G=new T(y),R=G.pow(u.length-ie),I=b,G.c=c(ze(Ie(R.c),R.e,"0"),10,p,a),G.e=G.c.length),L=c(u,y,p,C?(m=M,a):(m=a,M)),w=b=L.length;L[--b]==0;L.pop());if(!L[0])return m.charAt(0);if(ie<0?--w:(R.c=L,R.e=w,R.s=g,R=t(R,G,de,J,p),L=R.c,D=R.r,w=R.e),A=w+de+1,ie=L[A],b=p/2,D=D||A<0||L[A+1]!=null,D=J<4?(ie!=null||D)&&(J==0||J==(R.s<0?3:2)):ie>b||ie==b&&(J==4||D||J==6&&L[A-1]&1||J==(R.s<0?8:7)),A<1||!L[0])u=D?ze(m.charAt(1),-de,m.charAt(0)):m.charAt(0);else{if(L.length=A,D)for(--p;++L[--A]>p;)L[A]=0,A||(++w,L=[1].concat(L));for(b=L.length;!L[--b];);for(ie=0,u="";ie<=b;u+=m.charAt(L[ie++]));u=ze(u,w,m.charAt(0))}return u}})(),t=(function(){function a(y,p,g){var C,m,A,w,b=0,D=y.length,R=p%et,L=p/et|0;for(y=y.slice();D--;)A=y[D]%et,w=y[D]/et|0,C=L*A+w*R,m=R*A+C%et*et+b,b=(m/g|0)+(C/et|0)+L*w,y[D]=m%g;return b&&(y=[b].concat(y)),y}function c(y,p,g,C){var m,A;if(g!=C)A=g>C?1:-1;else for(m=A=0;m<g;m++)if(y[m]!=p[m]){A=y[m]>p[m]?1:-1;break}return A}function u(y,p,g,C){for(var m=0;g--;)y[g]-=m,m=y[g]<p[g]?1:0,y[g]=m*C+y[g]-p[g];for(;!y[0]&&y.length>1;y.splice(0,1));}return function(y,p,g,C,m){var A,w,b,D,R,L,G,ie,de,J,te,Ae,vr,fs,ms,je,cr,_e=y.s==p.s?1:-1,Se=y.c,ae=p.c;if(!Se||!Se[0]||!ae||!ae[0])return new T(!y.s||!p.s||(Se?ae&&Se[0]==ae[0]:!ae)?NaN:Se&&Se[0]==0||!ae?_e*0:_e/0);for(ie=new T(_e),de=ie.c=[],w=y.e-p.e,_e=g+w+1,m||(m=Ue,w=Oe(y.e/W)-Oe(p.e/W),_e=_e/W|0),b=0;ae[b]==(Se[b]||0);b++);if(ae[b]>(Se[b]||0)&&w--,_e<0)de.push(1),D=!0;else{for(fs=Se.length,je=ae.length,b=0,_e+=2,R=De(m/(ae[0]+1)),R>1&&(ae=a(ae,R,m),Se=a(Se,R,m),je=ae.length,fs=Se.length),vr=je,J=Se.slice(0,je),te=J.length;te<je;J[te++]=0);cr=ae.slice(),cr=[0].concat(cr),ms=ae[0],ae[1]>=m/2&&ms++;do{if(R=0,A=c(ae,J,je,te),A<0){if(Ae=J[0],je!=te&&(Ae=Ae*m+(J[1]||0)),R=De(Ae/ms),R>1)for(R>=m&&(R=m-1),L=a(ae,R,m),G=L.length,te=J.length;c(L,J,G,te)==1;)R--,u(L,je<G?cr:ae,G,m),G=L.length,A=1;else R==0&&(A=R=1),L=ae.slice(),G=L.length;if(G<te&&(L=[0].concat(L)),u(J,L,te,m),te=J.length,A==-1)for(;c(ae,J,je,te)<1;)R++,u(J,je<te?cr:ae,te,m),te=J.length}else A===0&&(R++,J=[0]);de[b++]=R,J[0]?J[te++]=Se[vr]||0:(J=[Se[vr]],te=1)}while((vr++<fs||J[0]!=null)&&_e--);D=J[0]!=null,de[0]||de.splice(0,1)}if(m==Ue){for(b=1,_e=de[0];_e>=10;_e/=10,b++);Y(ie,g+(ie.e=b+w*W-1)+1,C,D)}else ie.e=w,ie.r=+D;return ie}})();function K(a,c,u,y){var p,g,C,m,A;if(u==null?u=d:re(u,0,8),!a.c)return a.toString();if(p=a.c[0],C=a.e,c==null)A=Ie(a.c),A=y==1||y==2&&(C<=h||C>=f)?fr(A,C):ze(A,C,"0");else if(a=Y(new T(a),c,u),g=a.e,A=Ie(a.c),m=A.length,y==1||y==2&&(c<=g||g<=h)){for(;m<c;A+="0",m++);A=fr(A,g)}else if(c-=C+(y===2&&g>C),A=ze(A,g,"0"),g+1>m){if(--c>0)for(A+=".";c--;A+="0");}else if(c+=g-m,c>0)for(g+1==m&&(A+=".");c--;A+="0");return a.s<0&&p?"-"+A:A}function U(a,c){for(var u,y,p=1,g=new T(a[0]);p<a.length;p++)y=new T(a[p]),(!y.s||(u=pt(g,y))===c||u===0&&g.s===c)&&(g=y);return g}function Z(a,c,u){for(var y=1,p=c.length;!c[--p];c.pop());for(p=c[0];p>=10;p/=10,y++);return(u=y+u*W-1)>E?a.c=a.e=null:u<S?a.c=[a.e=0]:(a.e=u,a.c=c),a}s=(function(){var a=/^(-?)0([xbo])(?=\w[\w.]*$)/i,c=/^([^.]+)\.$/,u=/^\.([^.]+)$/,y=/^-?(Infinity|NaN)$/,p=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(g,C,m,A){var w,b=m?C:C.replace(p,"");if(y.test(b))g.s=isNaN(b)?null:b<0?-1:1;else{if(!m&&(b=b.replace(a,function(D,R,L){return w=(L=L.toLowerCase())=="x"?16:L=="b"?2:8,!A||A==w?R:D}),A&&(w=A,b=b.replace(c,"$1").replace(u,"0.$1")),C!=b))return new T(b,w);if(T.DEBUG)throw Error(xe+"Not a"+(A?" base "+A:"")+" number: "+C);g.s=null}g.c=g.e=null}})();function Y(a,c,u,y){var p,g,C,m,A,w,b,D=a.c,R=Ur;if(D){e:{for(p=1,m=D[0];m>=10;m/=10,p++);if(g=c-p,g<0)g+=W,C=c,A=D[w=0],b=De(A/R[p-C-1]%10);else if(w=_r((g+1)/W),w>=D.length)if(y){for(;D.length<=w;D.push(0));A=b=0,p=1,g%=W,C=g-W+1}else break e;else{for(A=m=D[w],p=1;m>=10;m/=10,p++);g%=W,C=g-W+p,b=C<0?0:De(A/R[p-C-1]%10)}if(y=y||c<0||D[w+1]!=null||(C<0?A:A%R[p-C-1]),y=u<4?(b||y)&&(u==0||u==(a.s<0?3:2)):b>5||b==5&&(u==4||y||u==6&&(g>0?C>0?A/R[p-C]:0:D[w-1])%10&1||u==(a.s<0?8:7)),c<1||!D[0])return D.length=0,y?(c-=a.e+1,D[0]=R[(W-c%W)%W],a.e=-c||0):D[0]=a.e=0,a;if(g==0?(D.length=w,m=1,w--):(D.length=w+1,m=R[W-g],D[w]=C>0?De(A/R[p-C]%R[C])*m:0),y)for(;;)if(w==0){for(g=1,C=D[0];C>=10;C/=10,g++);for(C=D[0]+=m,m=1;C>=10;C/=10,m++);g!=m&&(a.e++,D[0]==Ue&&(D[0]=1));break}else{if(D[w]+=m,D[w]!=Ue)break;D[w--]=0,m=1}for(g=D.length;D[--g]===0;D.pop());}a.e>E?a.c=a.e=null:a.e<S&&(a.c=[a.e=0])}return a}function oe(a){var c,u=a.e;return u===null?a.toString():(c=Ie(a.c),c=u<=h||u>=f?fr(c,u):ze(c,u,"0"),a.s<0?"-"+c:c)}return n.absoluteValue=n.abs=function(){var a=new T(this);return a.s<0&&(a.s=1),a},n.comparedTo=function(a,c){return pt(this,new T(a,c))},n.decimalPlaces=n.dp=function(a,c){var u,y,p,g=this;if(a!=null)return re(a,0,le),c==null?c=d:re(c,0,8),Y(new T(g),a+g.e+1,c);if(!(u=g.c))return null;if(y=((p=u.length-1)-Oe(this.e/W))*W,p=u[p])for(;p%10==0;p/=10,y--);return y<0&&(y=0),y},n.dividedBy=n.div=function(a,c){return t(this,new T(a,c),o,d)},n.dividedToIntegerBy=n.idiv=function(a,c){return t(this,new T(a,c),0,1)},n.exponentiatedBy=n.pow=function(a,c){var u,y,p,g,C,m,A,w,b,D=this;if(a=new T(a),a.c&&!a.isInteger())throw Error(xe+"Exponent not an integer: "+oe(a));if(c!=null&&(c=new T(c)),m=a.e>14,!D.c||!D.c[0]||D.c[0]==1&&!D.e&&D.c.length==1||!a.c||!a.c[0])return b=new T(Math.pow(+oe(D),m?a.s*(2-hr(a)):+oe(a))),c?b.mod(c):b;if(A=a.s<0,c){if(c.c?!c.c[0]:!c.s)return new T(NaN);y=!A&&D.isInteger()&&c.isInteger(),y&&(D=D.mod(c))}else{if(a.e>9&&(D.e>0||D.e<-1||(D.e==0?D.c[0]>1||m&&D.c[1]>=24e7:D.c[0]<8e13||m&&D.c[0]<=9999975e7)))return g=D.s<0&&hr(a)?-0:0,D.e>-1&&(g=1/g),new T(A?1/g:g);I&&(g=_r(I/W+2))}for(m?(u=new T(.5),A&&(a.s=1),w=hr(a)):(p=Math.abs(+oe(a)),w=p%2),b=new T(i);;){if(w){if(b=b.times(D),!b.c)break;g?b.c.length>g&&(b.c.length=g):y&&(b=b.mod(c))}if(p){if(p=De(p/2),p===0)break;w=p%2}else if(a=a.times(u),Y(a,a.e+1,1),a.e>14)w=hr(a);else{if(p=+oe(a),p===0)break;w=p%2}D=D.times(D),g?D.c&&D.c.length>g&&(D.c.length=g):y&&(D=D.mod(c))}return y?b:(A&&(b=i.div(b)),c?b.mod(c):g?Y(b,I,d,C):b)},n.integerValue=function(a){var c=new T(this);return a==null?a=d:re(a,0,8),Y(c,c.e+1,a)},n.isEqualTo=n.eq=function(a,c){return pt(this,new T(a,c))===0},n.isFinite=function(){return!!this.c},n.isGreaterThan=n.gt=function(a,c){return pt(this,new T(a,c))>0},n.isGreaterThanOrEqualTo=n.gte=function(a,c){return(c=pt(this,new T(a,c)))===1||c===0},n.isInteger=function(){return!!this.c&&Oe(this.e/W)>this.c.length-2},n.isLessThan=n.lt=function(a,c){return pt(this,new T(a,c))<0},n.isLessThanOrEqualTo=n.lte=function(a,c){return(c=pt(this,new T(a,c)))===-1||c===0},n.isNaN=function(){return!this.s},n.isNegative=function(){return this.s<0},n.isPositive=function(){return this.s>0},n.isZero=function(){return!!this.c&&this.c[0]==0},n.minus=function(a,c){var u,y,p,g,C=this,m=C.s;if(a=new T(a,c),c=a.s,!m||!c)return new T(NaN);if(m!=c)return a.s=-c,C.plus(a);var A=C.e/W,w=a.e/W,b=C.c,D=a.c;if(!A||!w){if(!b||!D)return b?(a.s=-c,a):new T(D?C:NaN);if(!b[0]||!D[0])return D[0]?(a.s=-c,a):new T(b[0]?C:d==3?-0:0)}if(A=Oe(A),w=Oe(w),b=b.slice(),m=A-w){for((g=m<0)?(m=-m,p=b):(w=A,p=D),p.reverse(),c=m;c--;p.push(0));p.reverse()}else for(y=(g=(m=b.length)<(c=D.length))?m:c,m=c=0;c<y;c++)if(b[c]!=D[c]){g=b[c]<D[c];break}if(g&&(p=b,b=D,D=p,a.s=-a.s),c=(y=D.length)-(u=b.length),c>0)for(;c--;b[u++]=0);for(c=Ue-1;y>m;){if(b[--y]<D[y]){for(u=y;u&&!b[--u];b[u]=c);--b[u],b[y]+=Ue}b[y]-=D[y]}for(;b[0]==0;b.splice(0,1),--w);return b[0]?Z(a,b,w):(a.s=d==3?-1:1,a.c=[a.e=0],a)},n.modulo=n.mod=function(a,c){var u,y,p=this;return a=new T(a,c),!p.c||!a.s||a.c&&!a.c[0]?new T(NaN):!a.c||p.c&&!p.c[0]?new T(p):(F==9?(y=a.s,a.s=1,u=t(p,a,0,3),a.s=y,u.s*=y):u=t(p,a,0,F),a=p.minus(u.times(a)),!a.c[0]&&F==1&&(a.s=p.s),a)},n.multipliedBy=n.times=function(a,c){var u,y,p,g,C,m,A,w,b,D,R,L,G,ie,de,J=this,te=J.c,Ae=(a=new T(a,c)).c;if(!te||!Ae||!te[0]||!Ae[0])return!J.s||!a.s||te&&!te[0]&&!Ae||Ae&&!Ae[0]&&!te?a.c=a.e=a.s=null:(a.s*=J.s,!te||!Ae?a.c=a.e=null:(a.c=[0],a.e=0)),a;for(y=Oe(J.e/W)+Oe(a.e/W),a.s*=J.s,A=te.length,D=Ae.length,A<D&&(G=te,te=Ae,Ae=G,p=A,A=D,D=p),p=A+D,G=[];p--;G.push(0));for(ie=Ue,de=et,p=D;--p>=0;){for(u=0,R=Ae[p]%de,L=Ae[p]/de|0,C=A,g=p+C;g>p;)w=te[--C]%de,b=te[C]/de|0,m=L*w+b*R,w=R*w+m%de*de+G[g]+u,u=(w/ie|0)+(m/de|0)+L*b,G[g--]=w%ie;G[g]=u}return u?++y:G.splice(0,1),Z(a,G,y)},n.negated=function(){var a=new T(this);return a.s=-a.s||null,a},n.plus=function(a,c){var u,y=this,p=y.s;if(a=new T(a,c),c=a.s,!p||!c)return new T(NaN);if(p!=c)return a.s=-c,y.minus(a);var g=y.e/W,C=a.e/W,m=y.c,A=a.c;if(!g||!C){if(!m||!A)return new T(p/0);if(!m[0]||!A[0])return A[0]?a:new T(m[0]?y:p*0)}if(g=Oe(g),C=Oe(C),m=m.slice(),p=g-C){for(p>0?(C=g,u=A):(p=-p,u=m),u.reverse();p--;u.push(0));u.reverse()}for(p=m.length,c=A.length,p-c<0&&(u=A,A=m,m=u,c=p),p=0;c;)p=(m[--c]=m[c]+A[c]+p)/Ue|0,m[c]=Ue===m[c]?0:m[c]%Ue;return p&&(m=[p].concat(m),++C),Z(a,m,C)},n.precision=n.sd=function(a,c){var u,y,p,g=this;if(a!=null&&a!==!!a)return re(a,1,le),c==null?c=d:re(c,0,8),Y(new T(g),a,c);if(!(u=g.c))return null;if(p=u.length-1,y=p*W+1,p=u[p]){for(;p%10==0;p/=10,y--);for(p=u[0];p>=10;p/=10,y++);}return a&&g.e+1>y&&(y=g.e+1),y},n.shiftedBy=function(a){return re(a,-Br,Br),this.times("1e"+a)},n.squareRoot=n.sqrt=function(){var a,c,u,y,p,g=this,C=g.c,m=g.s,A=g.e,w=o+4,b=new T("0.5");if(m!==1||!C||!C[0])return new T(!m||m<0&&(!C||C[0])?NaN:C?g:1/0);if(m=Math.sqrt(+oe(g)),m==0||m==1/0?(c=Ie(C),(c.length+A)%2==0&&(c+="0"),m=Math.sqrt(+c),A=Oe((A+1)/2)-(A<0||A%2),m==1/0?c="5e"+A:(c=m.toExponential(),c=c.slice(0,c.indexOf("e")+1)+A),u=new T(c)):u=new T(m+""),u.c[0]){for(A=u.e,m=A+w,m<3&&(m=0);;)if(p=u,u=b.times(p.plus(t(g,p,w,1))),Ie(p.c).slice(0,m)===(c=Ie(u.c)).slice(0,m))if(u.e<A&&--m,c=c.slice(m-3,m+1),c=="9999"||!y&&c=="4999"){if(!y&&(Y(p,p.e+o+2,0),p.times(p).eq(g))){u=p;break}w+=4,m+=4,y=1}else{(!+c||!+c.slice(1)&&c.charAt(0)=="5")&&(Y(u,u.e+o+2,1),a=!u.times(u).eq(g));break}}return Y(u,u.e+o+1,d,a)},n.toExponential=function(a,c){return a!=null&&(re(a,0,le),a++),K(this,a,c,1)},n.toFixed=function(a,c){return a!=null&&(re(a,0,le),a=a+this.e+1),K(this,a,c)},n.toFormat=function(a,c,u){var y,p=this;if(u==null)a!=null&&c&&typeof c=="object"?(u=c,c=null):a&&typeof a=="object"?(u=a,a=c=null):u=O;else if(typeof u!="object")throw Error(xe+"Argument not an object: "+u);if(y=p.toFixed(a,c),p.c){var g,C=y.split("."),m=+u.groupSize,A=+u.secondaryGroupSize,w=u.groupSeparator||"",b=C[0],D=C[1],R=p.s<0,L=R?b.slice(1):b,G=L.length;if(A&&(g=m,m=A,A=g,G-=g),m>0&&G>0){for(g=G%m||m,b=L.substr(0,g);g<G;g+=m)b+=w+L.substr(g,m);A>0&&(b+=w+L.slice(g)),R&&(b="-"+b)}y=D?b+(u.decimalSeparator||"")+((A=+u.fractionGroupSize)?D.replace(new RegExp("\\d{"+A+"}\\B","g"),"$&"+(u.fractionGroupSeparator||"")):D):b}return(u.prefix||"")+y+(u.suffix||"")},n.toFraction=function(a){var c,u,y,p,g,C,m,A,w,b,D,R,L=this,G=L.c;if(a!=null&&(m=new T(a),!m.isInteger()&&(m.c||m.s!==1)||m.lt(i)))throw Error(xe+"Argument "+(m.isInteger()?"out of range: ":"not an integer: ")+oe(m));if(!G)return new T(L);for(c=new T(i),w=u=new T(i),y=A=new T(i),R=Ie(G),g=c.e=R.length-L.e-1,c.c[0]=Ur[(C=g%W)<0?W+C:C],a=!a||m.comparedTo(c)>0?g>0?c:w:m,C=E,E=1/0,m=new T(R),A.c[0]=0;b=t(m,c,0,1),p=u.plus(b.times(y)),p.comparedTo(a)!=1;)u=y,y=p,w=A.plus(b.times(p=w)),A=p,c=m.minus(b.times(p=c)),m=p;return p=t(a.minus(u),y,0,1),A=A.plus(p.times(w)),u=u.plus(p.times(y)),A.s=w.s=L.s,g=g*2,D=t(w,y,g,d).minus(L).abs().comparedTo(t(A,u,g,d).minus(L).abs())<1?[w,y]:[A,u],E=C,D},n.toNumber=function(){return+oe(this)},n.toPrecision=function(a,c){return a!=null&&re(a,1,le),K(this,a,c,2)},n.toString=function(a){var c,u=this,y=u.s,p=u.e;return p===null?y?(c="Infinity",y<0&&(c="-"+c)):c="NaN":(a==null?c=p<=h||p>=f?fr(Ie(u.c),p):ze(Ie(u.c),p,"0"):a===10&&B?(u=Y(new T(u),o+p+1,d),c=ze(Ie(u.c),u.e,"0")):(re(a,2,M.length,"Base"),c=r(ze(Ie(u.c),p,"0"),10,a,y,!0)),y<0&&u.c[0]&&(c="-"+c)),c},n.valueOf=n.toJSON=function(){return oe(this)},n._isBigNumber=!0,n[Symbol.toStringTag]="BigNumber",n[Symbol.for("nodejs.util.inspect.custom")]=n.valueOf,e!=null&&T.set(e),T}function Oe(e){var t=e|0;return e>0||e===t?t:t-1}function Ie(e){for(var t,r,s=1,n=e.length,i=e[0]+"";s<n;){for(t=e[s++]+"",r=W-t.length;r--;t="0"+t);i+=t}for(n=i.length;i.charCodeAt(--n)===48;);return i.slice(0,n+1||1)}function pt(e,t){var r,s,n=e.c,i=t.c,o=e.s,d=t.s,h=e.e,f=t.e;if(!o||!d)return null;if(r=n&&!n[0],s=i&&!i[0],r||s)return r?s?0:-d:o;if(o!=d)return o;if(r=o<0,s=h==f,!n||!i)return s?0:!n^r?1:-1;if(!s)return h>f^r?1:-1;for(d=(h=n.length)<(f=i.length)?h:f,o=0;o<d;o++)if(n[o]!=i[o])return n[o]>i[o]^r?1:-1;return h==f?0:h>f^r?1:-1}function re(e,t,r,s){if(e<t||e>r||e!==De(e))throw Error(xe+(s||"Argument")+(typeof e=="number"?e<t||e>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function hr(e){var t=e.c.length-1;return Oe(e.e/W)==t&&e.c[t]%2!=0}function fr(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function ze(e,t,r){var s,n;if(t<0){for(n=r+".";++t;n+=r);e=n+e}else if(s=e.length,++t>s){for(n=r,t-=s;--t;n+=r);e+=n}else t<s&&(e=e.slice(0,t)+"."+e.slice(t));return e}var v=Ds();function ci(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}const ui={1:{dex:{agent:{type:"default:odos-v2",router:"0xCf5540fFFCdC3d510B18bFcA6d2b9987b0772559",adapter:"0xC1bB4d5071Fe7109ae2D67AE05826A3fe9116cfc",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"},sushiswap:{type:"default:sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"}}},10:{dex:{agent:{type:"default:odos-v2",router:"0xCa423977156BB05b13A2BA3b76Bc5419E2fE9680",adapter:"0xC5Aea83Fdd94A19fB2ce0B7207939C52825D3D3B",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"}}},14:{dex:{spark:{type:"default:spark",router:"0x0f3D8a38D4c74afBebc2c42695642f0e3acb15D3",adapter:"0x00c7617C471Ef69124464CEc318a3b8CC90aE9A7",fee:"0xaeA8C3e1a129A77686E115b1a46D9aD8405F7D2b"}}},56:{dex:{agent:{type:"default:odos-v2",router:"0x89b8AA89FDd0507a99d334CBe3C808fAFC7d850E",adapter:"0x67Feba015c968c76cCB2EEabf197b4578640BE2C",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"},thena:{type:"default:odos-v2",router:"0x89b8AA89FDd0507a99d334CBe3C808fAFC7d850E",adapter:"0x9E61dEabe996236814c28eC69ab2A7405cB6f03E",fee:"0x15eBc8b5b3877512FFF23650188694A9a8891FAc"},pancake:{type:"p2:pancakeswap-v2",router:"0xd9C500DfF816a1Da21A48A732d3498Bf09dc9AEB",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0x52Ed96B1AEd25818B6A284b063b055488E012b73",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},newera:{type:"default:odos-v2",router:"0x89b8AA89FDd0507a99d334CBe3C808fAFC7d850E",adapter:"0x6236a466CE5c368DC6686d69cAcf5561196B76ef",fee:"0x4E7454909eB6D539111D56b50d68897E933D2d11"}}},137:{dex:{agent:{type:"default:odos-v2",router:"0x4E3288c9ca110bCC82bf38F09A7b425c095d92Bf",adapter:"0x75A3d70Fa6d054d31C896b9Cf8AB06b1c1B829B8",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"},quick:{type:"paraswap:paraswap-v5",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0x727e1CbA41Ff1ff11C32fa43DAb499b4317A1b65",fee:"0xd207DC6a6dA88f27c8DB78201F974161b1d84b1f"},teafi:{type:"paraswap:paraswap-v5",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0xF710D67C783D2C14671EC1c61B0683DCb996F5c3",fee:"0x04Ff96e2c4D62b5771795d307AD679a25b3D2D50"}}},143:{dex:{yowie:{type:"default:openocean-v2",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xCA84Ab5a5A5bf2cff6AC0C835eF049365D13c6cB",fee:"0x6AF3eE77A3A3257777F5649aFa611b4C7Fd975Ef"},pangolin:{type:"default:kyber-v2",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xf42106eBf985bF49b39eba0114F57FA05e7B52eD",fee:"0xde92da99D188Ceb54A11ec711EF52D808A6260B5"}}},146:{dex:{agent:{type:"default:odos-v2",router:"0xaC041Df48dF9791B0654f1Dbbf2CC8450C5f2e9D",adapter:"0x58fD209C81D84739BaD9c72C082350d67E713EEa",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"},spooky:{type:"default:magpie-v3",router:"0xc325856e5585823aaC0D1Fd46c35c608D95E65A9",adapter:"0x56083Eb47d4d7d520F4d2b4a0DC98BE56bb98068",fee:"0x840Df4684B35BC68BcdA3F6707A3c82A0D662f8b"},swapx:{type:"default:openocean-v2",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xa7AE3ABf86C81cCEFEd6bE77045F2a32660c1B1c",fee:"0x6E03f7BC0f141894612AA017796096399623895F"},shadow:{type:"default:magpie-v3",router:"0xc325856e5585823aaC0D1Fd46c35c608D95E65A9",adapter:"0x1adEE94aBa11F19981130F77a1B2620b67e4409A",fee:"0xb9e3751fAF3187E1bC468E56a707a8A91754460e"}}},1329:{dex:{dragon:{type:"default:dragon",router:"0x11DA6463D6Cb5a03411Dbf5ab6f6bc3997Ac7428",adapter:"0x1e84A9f30607959d2d8b1a04171ef7D9522Ef502",fee:"0x0dc1E0525202b32e89bA78ed55b1e5cEdB751334"},nami:{type:"default:openocean-v2",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xba56F9A7865d430c8293851D576b5728Ca711ff5",fee:"0xeB58450e23632003f013568703F54446070E2E80"}}},5e3:{dex:{agent:{type:"default:odos-v2",router:"0xD9F4e85489aDCD0bAF0Cd63b4231c6af58c26745",adapter:"0x9571D46B5A5AAb749E5aCd698D8F20814C7B23D3",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"}}},8453:{dex:{agent:{type:"default:odos-v2",router:"0x19cEeAd7105607Cd444F5ad10dd51356436095a1",adapter:"0x5906C4dD71D5afFe1a8f0215409E912eB5d593AD",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"},pancake:{type:"p2:pancakeswap-v2",router:"0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},quick:{type:"default:kyber-v2",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0x0438644898F69bfF1018Cb01a81877D14d3e6493",fee:"0xd207DC6a6dA88f27c8DB78201F974161b1d84b1f"},trebleswap:{type:"default:trebleswap",router:"0x347539D82A14C0A3a89769f1024774A545a151ac",adapter:"0x6f4938535879c668A797F2a6e9B912c54f9D43Cf",fee:"0x15fc883d7DF4e681Ddb9E43e7B1D8c61d4fC162C"},sushiswap:{type:"default:sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"}}},42161:{dex:{agent:{type:"default:odos-v2",router:"0xa669e7A0d4b3e4Fa48af2dE86BD4CD7126Be4e13",adapter:"0x026B8977319F67078e932a08feAcB59182B5380f",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"},arbidex:{type:"default:odos-v2",router:"0xa669e7A0d4b3e4Fa48af2dE86BD4CD7126Be4e13",adapter:"0xaA66173674F4331e7e672899B3E6aB1190450898",fee:"0xa0c11852f8A44e32F9EC10AD25986A53842f72Ca"},ramses:{type:"paraswap:paraswap-v5",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0xf075352f43cd15bA51B0957A4465223EDf6b4Cd8",fee:"0xB5BaCB60ECDa0bEF809B2A26eC9B4B926835D7af"},omni:{type:"paraswap:paraswap-v5",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0x41c925E8E4fC65136BDf5322824E0D8c20c4824e",fee:"0xba5291526c30B097E9F1Fd1Be301E2ab6E0782aa"},chronos:{type:"default:odos-v2",router:"0x19cEeAd7105607Cd444F5ad10dd51356436095a1",adapter:"0x6a6b8975d1b131EFd0a9b536766EE7E5d4a16CF2",fee:"0x5729af83240EFecAa18eafaAE82961c2DD045Dbe"},pancake:{type:"p2:pancakeswap-v2",router:"0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},sushiswap:{type:"default:sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"}}},43114:{dex:{agent:{type:"default:odos-v2",router:"0x88de50B233052e4Fb783d4F6db78Cc34fEa3e9FC",adapter:"0x4F48041842827823D3750399eCa2832fC2E29201",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"},blackhole:{type:"default:kyber-v2",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xccdF1D6ce95FeC0F842197470CE8969A678B0A04",fee:"0x7f8B62520D9B5DA0ED517cc36e8dcb2a356f1928"},pangolin:{type:"default:kyber-v2",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xf42106eBf985bF49b39eba0114F57FA05e7B52eD",fee:"0xde92da99D188Ceb54A11ec711EF52D808A6260B5"}}},59144:{dex:{agent:{type:"default:odos-v2",router:"0x2d8879046f1559E53eb052E949e9544bCB72f414",adapter:"0x55E4da2cd634729064bEb294EC682Dc94f5c3f24",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"},pancake:{type:"p2:pancakeswap-v2",router:"0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},lynex:{type:"default:openocean",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xd8bC1FF79a642e8D7Fbd0711374F287202fBb3AA",fee:"0xcb36ed1B1BfAD8F7FC9651f52d21f04A68677423"}}},80094:{dex:{kodiak:{type:"default:kodiak",router:"0x43Dac637c4383f91B4368041E7A8687da3806Cae",adapter:"0xcB16237c88A859d46Ae850B97d7D1bdECF482C06",fee:"0xBA47Ec15aFbCF6e7e9F52900632049530bB6bAe4"}}},747474:{dex:{sushiswap:{type:"default:sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"}}},"*":{wm:"0x0005d5cE0dB57e5BE3b2b8b6FeB75f0ccd015000",repermit:"0x00002a9C4D9497df5Bd31768eC5d30eEf5405000",cosigner:"0x000ECFa392ecDEfEE6e2a5C095d39B7A32f1E000",reactor:"0x000000b33fE4fB9d999Dd684F79b110731c3d000",executor:"0x000642A0966d9bd49870D9519f76b5cf823f3000",refinery:"0x000E474c0D7084EAA35A501035E73269f4b009A5",salt:{wm:"0xc9b46eae42dfeba3222a0315bf682f33cd5cc9d60c9625642e88406f8415f152",repermit:"0x4871dc9008e605821ea9677b65ea2a60ffb774afb31e0dcaea2e192880096be7",cosigner:"0x1117fe6f4e25c9380d10b2b3314a1e9b33e5f65ba0e55e0c63d0640db0dd60a2",reactor:"0xec73677f3a465a9755d4c9eab9509b59a24613fdb8b78719682930373e9876f5",executor:"0x9abc67d936f79e493f1f14050c2f6adb87ec208ff7aaae2e7ae788a7cb4796d7",refinery:"0x9746de29f1dd31b2c8460d71e92a7aefa34911130e61f274f37776e598c48bec"}}};var Rr,Os;function di(){if(Os)return Rr;Os=1;const e=ui,t=n=>ci(`./out/${n}.sol/${n}.abi.json`),r=()=>({wm:t("WM"),repermit:t("RePermit"),reactor:t("OrderReactor"),executor:t("Executor"),refinery:t("Refinery"),settler:t("Settler"),adapter:t("DefaultDexAdapter")});function s(n,i){if(!n)return;const{dex:o,...d}=e["*"]??{},h=e[n];if(!h)return;const{dex:f,...S}=h;if(!(i!=null&&i.trim()))return{...d,...S};const E=f==null?void 0:f[i];if(E)return{...d,...S,...E}}return Rr={config:s,abis:r,raw:e},Rr}var Is=di();const Bt=(e,t)=>{if(!e||!t)return"";const r=v(10).pow(e||0);return v(t).times(r).idiv(r).div(r).toFixed()};v(0),v(1),v(10),v(1e18);function gt(e,t){return e==t||e.toLowerCase()==t.toLowerCase()}const Ut=e=>!!Vn.find(t=>gt(t,e||""));function li(e){return[Te.Years,Te.Months,Te.Weeks,Te.Days,Te.Hours,Te.Minutes].find(r=>r<=e)||Te.Minutes}const At=e=>e?e.value*e.unit:0,hi=e=>!e||e==="NaN"?"0":v(e).decimalPlaces(0).toFixed(),yt=e=>Object.values(ge).find(t=>t.id===e),fi=e=>{if(!e)return;const t=e.map(i=>ye(i)),r=Object.entries(Gn).filter(([i])=>t.includes(i)).flatMap(([,i])=>i),s=e.map(i=>i.exchangeAddress),n=new Set([...s,...r].map(i=>i.toLowerCase()));return Array.from(n)},Lr=(e,t)=>e.version===1?(e.fillDelay||0)*1e3+wi(t):(e.fillDelay||0)*1e3,mr=e=>typeof window>"u"?null:new URLSearchParams(window.location.search).get(e),ks=e=>Bs().filter(t=>t.name===e).map(t=>t.chainId),Nr=(e="",t="",r=18,s=18)=>{if(!v(e||0).gt(0)||!v(t||0).gt(0))return"";const n=Bt(r,e),i=Bt(s,t);return v(i).div(n).toFixed()},Ms=(e,t,r)=>{if(e.type===V.TWAP_MARKET)return"";const s=Bt(t,e.srcAmountPerTrade),n=Bt(r,e.dstMinAmountPerTrade);return v(n).div(s).toFixed()},_s=(e,t,r)=>{if(e.type===V.TWAP_MARKET)return"";const s=Bt(t,e.srcAmountPerTrade),n=Bt(r,e.triggerPricePerTrade);return v(n).div(s).toFixed()},mi=(e,t,r)=>{if(!e||!t||!r)return;const s=v(e).times(t),n=v(10).pow(r);return s.div(n).toFixed(0)},pi=(e,t,r,s)=>{if(r||!s||!e||!t)return v(0).toString();const n=v(e).times(v(t)),i=v(10).pow(s),o=n.div(i);return v.max(1,o).integerValue(v.ROUND_FLOOR).toFixed(0)},gi=(e,t,r,s)=>{if(e===j.TWAP||e===j.LIMIT)return"0";if(!s||!t||!r)return;const n=v(t).times(v(r)),i=v(10).pow(s),o=n.div(i);return v.max(1,o).integerValue(v.ROUND_FLOOR).toFixed(0)||"0"},Ai=(e,t,r,s)=>{const n=At(r)*2*t,i=mr(Yt.DURATION),o=li(i?Number(i):n);return i?{unit:o,value:Number(v(Number(i)/o).toFixed(2))}:s||(e===j.LIMIT?{unit:Te.Days,value:7}:e===j.STOP_LOSS||e===j.TAKE_PROFIT?{unit:Te.Days,value:1}:{unit:o,value:Number(v(n/o).toFixed(2))})},yi=(e,t,r)=>t!==j.TWAP?1:r!==void 0?r:Math.max(1,Math.ceil(e/2)),Ei=(e,t,r)=>{if(!e||!t||!r)return 1;const n=v(t).times(e).div(r).integerValue(v.ROUND_FLOOR).toNumber();return Math.max(1,n)},bi=(e,t)=>e+At(t)+6e4,wi=e=>e.bidDelaySeconds*1e3*2,Ci=(e="",t=0)=>!e||!t?"0":v(e).div(t).integerValue(v.ROUND_FLOOR).toFixed(0),Si=(e,t)=>({isError:!(e.unit===Mr.unit&&e.value===Mr.value)&&At(e)*t>lr,value:Math.floor(lr/t)}),xi=(e="",t="",r)=>{if(r===j.STOP_LOSS)return{isError:v(t||0).gte(v(e||0)),value:e}},vi=(e="",t="",r)=>{if(r===j.TAKE_PROFIT)return{isError:v(t||0).lte(v(e||0)),value:e}},Pi=(e="",t="",r=!1,s)=>{if(!r&&s===j.STOP_LOSS)return{isError:v(t||0).gte(v(e||0)),value:e}},Fi=(e="",t="",r=!1,s)=>{if(!r&&s===j.TAKE_PROFIT)return{isError:v(t||0).gte(v(e||0)),value:e}},Ti=(e,t)=>e===j.STOP_LOSS||e===j.TAKE_PROFIT?{isError:At(t)>5184e6,value:5184e6}:{isError:At(t)>lr,value:lr},Di=e=>({isError:At(e)<Ps,value:Ps}),Oi=e=>({isError:At(e)<Or,value:Or}),Ii=(e,t,r)=>({isError:v(t||0).multipliedBy(e||0).isLessThan(r),value:r}),ki=(e,t,r)=>({isError:r===j.TWAP&&v(e).isGreaterThan(t),value:t}),Mi=(e,t)=>{if(e===Ne.Pancake)switch(t){case 56:return $.PancakeSwap;case 42161:return $.PancakeSwapArbitrum;case 8453:return $.PancakeSwapBase;case 59144:return $.PancakeSwapLinea;default:return $.PancakeSwap}if(e===Ne.Sushiswap)switch(t){case 1:return $.SushiEth;case 42161:return $.SushiArb;case 8453:return $.SushiBase;case 747474:return $.SushiKatana;default:return $.SushiEth}if(e===Ne.Quick)switch(t){case 137:return $.QuickSwap;case 8453:return $.QuickSwapBase;default:return $.QuickSwap}if(e===Ne.Thena)switch(t){case 56:return $.Thena;default:return $.Thena}if(e===Ne.Spooky)switch(t){case 250:return $.SpookySwap;case 146:return $.SpookySwapSonic;default:return $.SpookySwap}if(e===Ne.Lynex)switch(t){case 59144:return $.Lynex;default:return $.Lynex}if(e===Ne.Swapx)switch(t){case 146:return $.SwapX;default:return $.SwapX}if(e===Ne.Blackhole)switch(t){case 43114:return $.BlackholeAvax;default:return $.BlackholeAvax}},qr=(e,t=0)=>{const{abi:r,...s}=Is.config(t,e);if(!s.reactor)throw new Error(`Missing config for partner "${e}" on chain ${t}: reactor address not found`);return{...s,partner:e,twapConfig:Mi(e,t)}},Bs=()=>{const e=Is.raw;return Object.entries(e).filter(([t])=>t!=="*").flatMap(([t,r])=>{const s=r==null?void 0:r.dex;return!s||typeof s!="object"?[]:Object.entries(s).map(([n])=>({chainId:Number(t),name:n,config:qr(n,Number(t))}))}).sort((t,r)=>t.name.localeCompare(r.name))},Us=e=>{const t=mr(Yt.MIN_CHUNK_SIZE_USD);return t?parseInt(t):e},_i=({marketPrice:e,typedInputAmount:t,srcUsd1Token:r,marketPriceLoading:s,triggerPriceError:n,limitPriceError:i,tradesError:o,fillDelayError:d,durationError:h,balanceError:f,minTradeSizeError:S})=>{if(!mr(Yt.IGNORE_ERRORS)&&!(v(e||0).isZero()||v(t||0).isZero()||v(r||"0").isZero()||s))return S||n||i||o||d||h||f},Rs=(e,t)=>{const r=Date.now().toString(),s=parseInt((e/1e3).toFixed(0)),n=hi(t/1e3),i=mr(Yt.FRESHNESS),o=i?parseInt(i):60;return{nonce:r,epoch:s,deadline:n,freshness:o}},Bi=({chainId:e,srcToken:t,dstToken:r,srcAmount:s,deadlineMillis:n,fillDelayMillis:i,slippage:o,account:d,srcAmountPerTrade:h,dstMinAmountPerTrade:f="0",triggerAmountPerTrade:S="0",config:E,module:x})=>{const{nonce:F,epoch:I,deadline:O,freshness:M}=Rs(i,n),B=x===j.TAKE_PROFIT?kr:S,T=x===j.TAKE_PROFIT?S:f,K={permitted:{token:t,amount:s},spender:E.reactor,nonce:F,deadline:O,witness:{reactor:E.reactor,executor:E.executor,exchange:{adapter:E.adapter,ref:E.fee,share:0,data:"0x"},swapper:d,nonce:F,deadline:O,chainid:e,exclusivity:0,epoch:I,slippage:o,freshness:M,input:{token:t,amount:h,maxAmount:s},output:{token:r,limit:v(T||0).toFixed(),stop:v(B||0).toFixed(),recipient:d}}};return{domain:{name:"RePermit",version:"1",chainId:e,verifyingContract:E.repermit},order:K,types:Xn,primaryType:Fs}},Ui=({chainId:e,srcToken:t,dstToken:r,srcAmount:s,deadlineMillis:n,fillDelayMillis:i,slippage:o,account:d,srcAmountPerTrade:h,dstMinAmountPerTrade:f="0",triggerAmountPerTrade:S="0",config:E,module:x})=>{const{nonce:F,epoch:I,deadline:O,freshness:M}=Rs(i,n),B=Math.floor(Date.now()/1e3).toString(),T=f,K=x===j.STOP_LOSS?S:"0",U=x===j.TAKE_PROFIT?S:"0",Z={permitted:{token:t,amount:s},spender:E.reactor,nonce:F,deadline:O,witness:{reactor:E.reactor,executor:E.executor,exchange:{adapter:E.adapter,ref:E.fee,share:0,data:"0x"},swapper:d,nonce:F,start:B,deadline:O,chainid:e,exclusivity:0,epoch:I,slippage:o,freshness:M,input:{token:t,amount:h,maxAmount:s},output:{token:r,limit:v(T||0).toFixed(),triggerLower:v(K||0).toFixed(),triggerUpper:v(U||0).toFixed(),recipient:d}}};return{domain:{name:"RePermit",version:"1",chainId:e,verifyingContract:E.repermit},order:Z,types:Zn,primaryType:Fs}},Ls=e=>Number(dr)>=2?Ui(e):Bi(e),Ri=`https://bi.orbs.network/putes/twap-ui-${.7}`;let Kr="unknown";function Li(e){Kr=e}function Hr(){const e=Math.random().toString(36).substring(2,16),t=Math.random().toString(36).substring(2,16),r=Date.now().toString(36);return`id_${e+t+r}`}const Ni=(e,t,r)=>{var s,n,i,o,d,h,f,S,E;return{spotVersion:Dr.version,partner:e.partner,adapter:e.adapter,cosigner:e.cosigner,executor:e.executor,fee:e.fee,reactor:e.reactor,refinery:e.refinery,repermit:e.repermit,router:e.router,type:e.type,wm:e.wm,chainName:((s=e.twapConfig)==null?void 0:s.chainName)||"",chainId:r||0,twapVersion:((n=e.twapConfig)==null?void 0:n.twapVersion)||0,twapAddress:((i=e.twapConfig)==null?void 0:i.twapAddress)||"",lensAddress:((o=e.twapConfig)==null?void 0:o.lensAddress)||"",bidDelaySeconds:((d=e.twapConfig)==null?void 0:d.bidDelaySeconds)||0,minChunkSizeUsd:t,name:((h=e.twapConfig)==null?void 0:h.name)||"",exchangeAddress:((f=e.twapConfig)==null?void 0:f.exchangeAddress)||"",exchangeType:((S=e.twapConfig)==null?void 0:S.exchangeType)||"",pathfinderKey:((E=e.twapConfig)==null?void 0:E.pathfinderKey)||""}},Ns=async e=>{try{await fetch(Ri,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)}).then()}catch(t){console.error("Failed to send BI",t)}};class qi{constructor(){Pr(this,"timeout");Pr(this,"config");Pr(this,"data",{_id:Hr()})}async updateAndSend(t={},r=!1,s){try{this.data={...this.data,...t},r?(await Ns(this.data),s==null||s()):(clearTimeout(this.timeout),this.timeout=setTimeout(()=>{Ns(this.data),s==null||s()},1e3))}catch(n){console.error("Failed to update and send BI",n)}}onCancelOrderRequest(t,r){this.updateAndSend({cancelOrderIdsV1:r===1?t:void 0,cancelOrderIdsV2:r===2?t:void 0,action:"cancel order",cancelOrderSuccess:!1,cancelOrderTxHash:void 0,actionError:void 0})}onCancelOrderSuccess(t){this.updateAndSend({cancelOrderTxHash:t,cancelOrderSuccess:!0})}onCancelOrderError(t){this.onTxError(t)}onWrapSuccess(t){this.updateAndSend({wrapTxHash:t})}onWrapRequest(){this.updateAndSend({action:"wrap"})}onWrapError(t){this.onTxError(t)}onApproveRequest(){this.updateAndSend({action:"approve"})}onApproveSuccess(t){this.updateAndSend({approvalTxHash:t})}onApproveError(t){this.onTxError(t)}onCrash(t){var r;this.updateAndSend({action:"crash",actionError:((r=t==null?void 0:t.message)==null?void 0:r.toLowerCase())||(t==null?void 0:t.toLowerCase())})}onTxError(t){var s;const r=((s=t==null?void 0:t.message)==null?void 0:s.toLowerCase())||(t==null?void 0:t.toLowerCase());this.updateAndSend({actionError:r})}onRequestOrder({account:t,chainId:r,module:s,srcToken:n,dstToken:i,fromTokenAmount:o,srcChunkAmount:d,minDstAmountOutPerTrade:h="",triggerPricePerTrade:f="",deadline:S,fillDelay:E,slippage:x,isMarketOrder:F,chunksAmount:I}){this.updateAndSend({toTokenAddress:i.address,toTokenSymbol:i.symbol,fromTokenAddress:n.address,fromTokenSymbol:n.symbol,fromTokenAmount:o,chunksAmount:I,srcChunkAmount:d,minDstAmountOutPerTrade:h,triggerPricePerTrade:f,deadline:S,fillDelay:E,slippage:x,chainId:r,walletAddress:t,module:s,orderType:F?"market":"limit",actionError:void 0})}onSignOrderRequest(t){this.updateAndSend({action:"sign order",order:t})}onSignOrderError(t){this.onTxError(t)}onSignOrderSuccess(t){this.updateAndSend({action:"sign order",signature:t})}init(t,r,s){var n;this.config=t,s!==((n=this.data)==null?void 0:n.chainId)&&(this.data={_id:Hr(),action:"module-import",uiVersion:Kr,...Ni(t,r,s),origin:window.location.origin},this.updateAndSend(this.data))}onCreateOrderError(t){this.onTxError(t)}onCreateOrderRequest(){this.updateAndSend({action:"create order"})}async onCreateOrderSuccess(t){this.updateAndSend({orderHash:t,orderSuccess:!0},void 0,()=>{this.data={_id:Hr(),action:"reset",uiVersion:Kr,origin:this.data.origin,spotVersion:Dr.version,partner:this.data.partner,adapter:this.data.adapter,cosigner:this.data.cosigner,executor:this.data.executor,fee:this.data.fee,reactor:this.data.reactor,refinery:this.data.refinery,repermit:this.data.repermit,router:this.data.router,type:this.data.type,wm:this.data.wm,chainName:this.data.chainName||"",chainId:this.data.chainId||0,twapVersion:this.data.twapVersion||0,twapAddress:this.data.twapAddress||"",lensAddress:this.data.lensAddress||"",bidDelaySeconds:this.data.bidDelaySeconds||0,minChunkSizeUsd:this.data.minChunkSizeUsd||0,name:this.data.name||"",exchangeAddress:this.data.exchangeAddress||"",exchangeType:this.data.exchangeType||"",pathfinderKey:this.data.pathfinderKey||""}})}onLoad(){this.updateAndSend({action:"module-import",origin:window.location.origin})}}const he=new qi,Ki=e=>{var d;const t=v(e.order.witness.output.limit||0).gt(1),r=e.order.witness.output.stop,s=e.order.witness.output.triggerUpper,n=v(r||0).eq(kr)||v(s||0).gt(0),i=v(r||0).gt(0),o=((d=e.metadata.chunks)==null?void 0:d.length)||v(e.order.witness.input.maxAmount).div(v(e.order.witness.input.amount)).toNumber();return n?t?V.TAKE_PROFIT_LIMIT:V.TAKE_PROFIT_MARKET:i?t?V.STOP_LOSS_LIMIT:V.STOP_LOSS_MARKET:t?o>1&&t?V.TWAP_LIMIT:t?V.LIMIT:V.TWAP_MARKET:V.TWAP_MARKET},Hi=e=>{var n;const t=((n=e.metadata.chunks)==null?void 0:n.filter(i=>i.status==="success").length)||0,r=e.metadata.expectedChunks||0,s=v(t).dividedBy(r).toNumber();return s>=.99?100:s<=0?0:Number((s*100).toFixed(2))},Wi=(e,t)=>e.metadata.status==="completed"||t>=99?me.Completed:["pending","eligible"].includes(e.metadata.status)?me.Open:e.metadata.description.toLowerCase()==="cancelled by contract"?me.Cancelled:me.Expired,Qi=e=>{var r;return(((r=e.metadata.chunks)==null?void 0:r.filter(s=>s.status==="success"))||[]).map(s=>({inAmount:s.inAmount,outAmount:s.outAmount,timestamp:new Date(s.timestamp).getTime(),txHash:s.txHash}))},ji=(e,t)=>{var s;const r=e.length;return r>=t&&((s=e[r-1])==null?void 0:s.timestamp)||0},zi=e=>v(e.metadata.displayOnlyInputTokenPriceUSD).dividedBy(1e18).toFixed(),Wr=e=>Number(e.order.witness.output.limit)===1?"":e.order.witness.output.limit,$i=e=>{const{triggerLower:t="0",triggerUpper:r="0"}=e.order.witness.output,s=Wr(e),n=e.metadata.expectedChunks||1,i=v(r||0).gt(0);return{dstMinAmountPerTrade:s,triggerPricePerTrade:i?r:t,dstMinAmountTotal:v(s).multipliedBy(n).toFixed()}},Vi=e=>{const t=Wr(e),r=v(e.order.witness.output.stop||0).eq(kr),s=e.metadata.expectedChunks||1;return{dstMinAmountPerTrade:r?"":t,triggerPricePerTrade:r?t:v(e.order.witness.output.stop||"").toFixed(),dstMinAmountTotal:r?"":v(t).multipliedBy(s).toFixed()}},Gi=e=>Number(dr)>=2?$i(e):Vi(e),qs=e=>{const t=Hi(e),r=Wr(e),s=e.metadata.expectedChunks||1,n=Qi(e),i=Ki(e);return{id:e.hash,hash:e.hash,version:2,type:i,maker:e.order.witness.swapper,progress:t,srcAmountFilled:n.reduce((o,d)=>o.plus(d.inAmount),new v(0)).toFixed()||"",dstAmountFilled:n.reduce((o,d)=>o.plus(d.outAmount),new v(0)).toFixed()||"",fills:n,srcTokenAddress:e.order.witness.input.token,dstTokenAddress:e.order.witness.output.token,orderDollarValueIn:zi(e),fillDelay:e.order.witness.epoch*1e3,deadline:Number(e.order.deadline)*1e3,createdAt:new Date(e.timestamp).getTime(),srcAmount:e.order.witness.input.maxAmount,srcAmountPerTrade:e.order.witness.input.amount,totalTradesAmount:s,isMarketPrice:v(r||0).lte(1),chainId:e.order.witness.chainid,filledOrderTimestamp:ji(n,s),status:Wi(e,t),isTriggerPrice:i===V.TAKE_PROFIT_MARKET||i===V.TAKE_PROFIT_LIMIT||i===V.STOP_LOSS_LIMIT||i===V.STOP_LOSS_MARKET,rawOrder:e,...Gi(e)}},Xi=async({chainId:e,signal:t,account:r,exchange:s,isDev:n=!1})=>{try{if(!r)return[];const i=s?`&exchange=${s}`:"",d=await(await fetch(`${vs(n)}/orders?swapper=${r}&chainId=${e}${i}`,{signal:t})).json();return!d||!Array.isArray(d.orders)?[]:d.orders.map(qs)}catch{return[]}},Ks=async(e,t,r=!1)=>{try{const s={signature:t,order:e,status:"pending"};he.onCreateOrderRequest();const n=await fetch(`${vs(r)}/orders/new`,{method:"POST",body:JSON.stringify(s)}),i=await n.json().catch(()=>({}));if(!n.ok||!(i!=null&&i.success)){const d=(i==null?void 0:i.message)??n.statusText??"Request failed",h=(i==null?void 0:i.code)??n.status;throw new Error(`error:${d}, code:${h}`)}if(!i.signedOrder||typeof i.signedOrder!="object")throw new Error("Invalid API response: missing signedOrder");const o=qs(i.signedOrder);return he.onCreateOrderSuccess(o.id),o}catch(s){throw he.onCreateOrderError(s),console.error(s),s}},$e=(e,t)=>e&&e.length?e.map(t||(r=>`${r}`)):void 0,Zi=e=>{if(e)return $n[e]},Qr=async({chainId:e,buildQuery:t,extractResults:r,signal:s,retries:n=1,limit:i=1e3,page:o})=>{const d=Zi(e);if(!d)throw new sa;const h=async E=>{let x=0;for(;x<=n;)try{const F=await fetch(d,{method:"POST",body:JSON.stringify({query:E}),signal:s,headers:{"Content-Type":"application/json"}});if(!F.ok)throw new Error(`HTTP error: ${F.status}`);const I=await F.json();if(I.errors)throw new Error(I.errors[0].message);return r(I)}catch(F){if(x===n)throw F;await new Promise(I=>setTimeout(I,500*2**x)),x++}return[]};let f=0;const S=[];if(o!==void 0){const E=t(o,i);try{return await h(E)}catch{console.warn(`Page ${o} failed, retrying one final time...`);try{return await h(E)}catch{return[]}}}for(;;){const E=t(f,i);let x;try{x=await h(E)}catch{console.warn(`Page ${f} failed, retrying one final time...`);try{x=await h(E)}catch{return S}}if(S.push(...x),x.length<i)break;f++}return S},Hs=e=>e.map(t=>({inAmount:t.srcAmountIn,outAmount:t.dstAmountOut,timestamp:t.timestamp,txHash:t.transactionHash})),Ws=(e,t)=>{const r=v(e||0).gt(1);return!r&&t===1?V.TWAP_MARKET:t>1&&r?V.TWAP_LIMIT:r?V.LIMIT:V.TWAP_MARKET},Yi=(e,t,r,s)=>{var x;const n=Hs(r||[]),i=new v(e.ask_srcAmount||0).div(e.ask_srcBidAmount).integerValue(v.ROUND_FLOOR).toNumber(),d=(r==null?void 0:r.length)===i?(x=r==null?void 0:r[(r==null?void 0:r.length)-1])==null?void 0:x.timestamp:void 0,h=n.reduce((F,I)=>F.plus(I.inAmount),new v(0)).toFixed(),f=n.reduce((F,I)=>F.plus(I.outAmount),new v(0)).toFixed(),S=Qs(e.ask_srcAmount,h),E=Ws(e.ask_dstMinAmount,i);return{version:1,isTriggerPrice:!1,id:e.Contract_id.toString(),hash:"",type:Ws(e.ask_dstMinAmount,i),srcTokenAddress:e.ask_srcToken,dstTokenAddress:e.ask_dstToken,exchangeAddress:e.exchange,twapAddress:e.twapAddress,maker:e.maker,progress:S,dstAmountFilled:f,srcAmountFilled:h,orderDollarValueIn:v(e.dollarValueIn||0).toFixed(6),srcAmount:e.ask_srcAmount,dstMinAmountTotal:v(e.ask_dstMinAmount).multipliedBy(i).toString(),fills:n,fillDelay:e.ask_fillDelay,deadline:e.ask_deadline*1e3,createdAt:new Date(e.timestamp).getTime(),dstMinAmountPerTrade:v(e.ask_dstMinAmount).eq(1)?"":e.ask_dstMinAmount,triggerPricePerTrade:"",srcAmountPerTrade:e.ask_srcBidAmount,txHash:e.transactionHash,totalTradesAmount:i,isMarketPrice:[V.TWAP_MARKET].includes(E),chainId:t,filledOrderTimestamp:d||0,status:s,rawOrder:e}},Ji=e=>{var E;if(!e)return"";const t=$e(e.accounts,x=>`"${x.toLowerCase()}"`),r=$e(fi(e.configs),x=>`"${x.toLowerCase()}"`),s=$e(e.inTokenSymbols,x=>`"${x.toUpperCase()}"`),n=$e(e.outTokenSymbols,x=>`"${x.toUpperCase()}"`),i=$e(e.inTokenAddresses,x=>`"${x.toLowerCase()}"`),o=$e(e.outTokenAddresses,x=>`"${x.toLowerCase()}"`),d=$e(e.transactionHashes,x=>`"${x.toLowerCase()}"`),h=$e(e.orderIds,x=>`"${x}"`),f=r!=null&&r.length?"":$e((E=e.configs)==null?void 0:E.map(x=>x.twapAddress),x=>`"${x.toLowerCase()}"`),S=e.minDollarValueIn;return[r?`exchange_in: [${r.join(", ")}]`:"",f?`twapAddress_in: [${f.join(", ")}]`:"",t?`maker_in: [${t.join(", ")}]`:"",d?`transactionHash_in: [${d.join(", ")}]`:"",h?`Contract_id_in: [${h.join(", ")}]`:"",S?`dollarValueIn_gte: ${S}`:"",s?`srcTokenSymbol_in: [${s.join(", ")}]`:"",n?`dstTokenSymbol_in: [${n.join(", ")}]`:"",i?`srcTokenAddress_in: [${i.join(", ")}]`:"",o?`dstTokenAddress_in: [${o.join(", ")}]`:"",e!=null&&e.startDate?`blockTimestamp_gte: ${e.startDate}`:"",e!=null&&e.endDate?`blockTimestamp_lte: ${e.endDate}`:"",(e==null?void 0:e.orderType)==="limit"?"ask_dstMinAmount_gt: 1":"",(e==null?void 0:e.orderType)==="market"?"ask_dstMinAmount_lte: 1":""].filter(Boolean).join(", ")};async function ea({chainId:e,signal:t,page:r,limit:s,filters:n}){const i=s||1e3,o=Ji(n);return await Qr({chainId:e,signal:t,limit:i,page:r,buildQuery:(h,f)=>`
1
+ (function(k,H){typeof exports=="object"&&typeof module<"u"?H(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],H):(k=typeof globalThis<"u"?globalThis:k||self,H(k.SpotReact={},k.jsxRuntime,k.React))})(this,(function(k,H,S){"use strict";var tc=Object.defineProperty;var Ns=k=>{throw TypeError(k)};var nc=(k,H,S)=>H in k?tc(k,H,{enumerable:!0,configurable:!0,writable:!0,value:S}):k[H]=S;var Sn=(k,H,S)=>nc(k,typeof H!="symbol"?H+"":H,S),mr=(k,H,S)=>H.has(k)||Ns("Cannot "+S);var l=(k,H,S)=>(mr(k,H,"read from private field"),S?S.call(k):H.get(k)),N=(k,H,S)=>H.has(k)?Ns("Cannot add the same private member more than once"):H instanceof WeakSet?H.add(k):H.set(k,S),B=(k,H,S,Bt)=>(mr(k,H,"write to private field"),Bt?Bt.call(k,S):H.set(k,S),S),j=(k,H,S)=>(mr(k,H,"access private method"),S);var Fn=(k,H,S,Bt)=>({set _(ce){B(k,H,ce,S)},get _(){return l(k,H,Bt)}});var Ke,vt,Ps,xt,it,qt,Ds,Kt,ot,Ht,Os,St,Is,Ft,Wt,Me,Pt,fe,rn,Dt,Re,Je,ks,Se,X,sn,Ce,Ot,Qt,Ve,ct,an,jt,zt,It,kt,ut,$t,ee,dn,yr,gr,Ar,Er,br,Cr,Tr,qs,Ms,on,He,Te,Mt,We,ht,Bs,Ge,Le,cn,_s,Xe,dt,Fe,Ze,Ye,Pn,wr,Us,Qe,Rs,se,lt,pt,Vt,Gt,ft,Xt,Zt,Ls;function Bt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const ce=Bt(S),z={SpookySwap:{chainName:"ftm",chainId:250,twapVersion:4,twapAddress:"0xd3B290FEB04E353d1821bc0a12397FdEa9a846C0",lensAddress:"0x0221EfDF1Fd3212AF87F23cceB7693a65fAF1d7f",takers:["0xDF406A27C58a8Cd6Fd43e143339bCE131216a913","0x504f6E10173249dD22491829D98862Cf81DeF79E"],bidDelaySeconds:60,minChunkSizeUsd:10,name:"SpookySwap",partner:"Orbs:TWAP:SpookySwap",exchangeAddress:"0xdF7CCd5fc7077E9de5f27a7b7bfDC837c82f8496",exchangeType:"ExchangeV2",pathfinderKey:""},SpookySwapSonic:{chainName:"sonic",chainId:146,twapVersion:4,twapAddress:"0x8963992816b4EafE5a22b7DB2A99513c18be9afA",lensAddress:"0x67e631F71232D63AcA98a2D5E9B2Bce5FCc39d5D",takers:["0xDF406A27C58a8Cd6Fd43e143339bCE131216a913","0x504f6E10173249dD22491829D98862Cf81DeF79E"],bidDelaySeconds:60,minChunkSizeUsd:10,name:"SpookySwapSonic",partner:"Orbs:TWAP:SpookySwap",exchangeAddress:"0x6699bE3aF75e5c1B807b1031dBde6dA9A67739F3",exchangeType:"ExchangeV2",pathfinderKey:""},QuickSwap:{chainName:"poly",chainId:137,twapVersion:4,twapAddress:"0x688C027B0f7FaCeFcBa73e472900d28c12C5bDF4",lensAddress:"0xe0D4E736fc76af7C256ae7652c8c1e850bfb7849",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:10,name:"QuickSwap",partner:"Orbs:TWAP:QuickSwap",exchangeAddress:"0x8FCc245209bE85C49D738D0CE5613F74E5d91E86",exchangeType:"ParaswapExchange",pathfinderKey:"QuickSwap,QuickSwapV3"},QuickSwapBase:{chainName:"base",chainId:8453,twapVersion:4,twapAddress:"0xc918bdC47264687796Cd54FE362FaC4f8b99Eb55",lensAddress:"0x6313188c1909b161074D62E43105faC9B756A23e",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:10,name:"QuickSwap",partner:"Orbs:TWAP:QuickSwap",exchangeAddress:"0xb7a3d74895bfd3aff6780525e36d79fcf26a895f",exchangeType:"ExchangeV2",pathfinderKey:""},Thena:{chainName:"bsc",chainId:56,twapVersion:4,twapAddress:"0xa6F7444D2b92Aa9F94a2165c77aAF2B671e63994",lensAddress:"0xEdB0c077fa87Fb21d050c619FF426798f8Fc1264",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"Thena",partner:"Orbs:TWAP:Thena",exchangeAddress:"0x2B2fABDbfa4a15da0d351F947C14F4520db0bDc1",exchangeType:"ExchangeV2",pathfinderKey:"43,47"},PancakeSwap:{chainName:"bsc",chainId:56,twapVersion:4,twapAddress:"0xa6F7444D2b92Aa9F94a2165c77aAF2B671e63994",lensAddress:"0xEdB0c077fa87Fb21d050c619FF426798f8Fc1264",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"PancakeSwap",partner:"Orbs:TWAP:PancakeSwap",exchangeAddress:"0x1A2bb6B75D58b740d88413ef4840D6fa3F637940",exchangeType:"P2Exchange",pathfinderKey:""},PancakeSwapArbitrum:{chainName:"arb",chainId:42161,twapVersion:4,twapAddress:"0x0B94dcC0EA2d1ee33Ab064DaC252de980a941eF3",lensAddress:"0x549e1fc9a47FCc0C5C2EbdfF31254cc49fF7164e",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"PancakeSwap",partner:"Orbs:TWAP:PancakeSwap",exchangeAddress:"0xb37cB9A058c03081Ae6EF934313588cD53d408e7",exchangeType:"P2Exchange",pathfinderKey:""},PancakeSwapBase:{chainName:"base",chainId:8453,twapVersion:4,twapAddress:"0xc918bdC47264687796Cd54FE362FaC4f8b99Eb55",lensAddress:"0x6313188c1909b161074D62E43105faC9B756A23e",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"PancakeSwap",partner:"Orbs:TWAP:PancakeSwap",exchangeAddress:"0xb37cB9A058c03081Ae6EF934313588cD53d408e7",exchangeType:"P2Exchange",pathfinderKey:""},PancakeSwapLinea:{chainName:"linea",chainId:59144,twapVersion:4,twapAddress:"0x48423e62acbfEF7779b5b4a5E7d6Fbd39E623d78",lensAddress:"0xe84CaEc86eCF3f0AB4267dC6130D9a5510e73DFb",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:100,name:"PancakeSwap",partner:"Orbs:TWAP:PancakeSwap",exchangeAddress:"0xb37cB9A058c03081Ae6EF934313588cD53d408e7",exchangeType:"P2Exchange",pathfinderKey:""},Lynex:{chainName:"linea",chainId:59144,twapVersion:4,twapAddress:"0x48423e62acbfEF7779b5b4a5E7d6Fbd39E623d78",lensAddress:"0xe84CaEc86eCF3f0AB4267dC6130D9a5510e73DFb",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:100,name:"Lynex",partner:"Orbs:TWAP:Lynex",exchangeAddress:"0x04C06C96d7D19977156016DD408B5992af0570a2",exchangeType:"ExchangeV2",pathfinderKey:"19,18"},SushiArb:{chainName:"arb",chainId:42161,twapVersion:4,twapAddress:"0x0B94dcC0EA2d1ee33Ab064DaC252de980a941eF3",lensAddress:"0x549e1fc9a47FCc0C5C2EbdfF31254cc49fF7164e",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"SushiArb",partner:"Orbs:TWAP:Sushi",exchangeAddress:"0x04eB53119079FA779492720D1EfeAEBF0aF2e5ad",exchangeType:"ExchangeV2",pathfinderKey:""},SushiBase:{chainName:"base",chainId:8453,twapVersion:4,twapAddress:"0xc918bdC47264687796Cd54FE362FaC4f8b99Eb55",lensAddress:"0x6313188c1909b161074D62E43105faC9B756A23e",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"SushiBase",partner:"Orbs:TWAP:Sushi",exchangeAddress:"0x04eB53119079FA779492720D1EfeAEBF0aF2e5ad",exchangeType:"ExchangeV2",pathfinderKey:""},SushiEth:{chainName:"eth",chainId:1,twapVersion:4,twapAddress:"0xb1ed8BCAD1EaC8a1DF0764700472391800D12946",lensAddress:"0x0967f448c4d4dbd14c355E635AE9CbF68cc44A60",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:200,name:"SushiEth",partner:"Orbs:TWAP:Sushi",exchangeAddress:"0x04eB53119079FA779492720D1EfeAEBF0aF2e5ad",exchangeType:"ExchangeV2",pathfinderKey:""},SushiKatana:{chainName:"katana",chainId:747474,twapVersion:4,twapAddress:"0xf2d96E7BE676153d202e1453804E2749923C7c5b",lensAddress:"0x1579EED0527781B1A748043AA1f59a3858Ace4a7",takers:["0xF74437A3Fc45a518640828E5D6A3E8c9A9BbDC3a","0x07A6C715063e94c0D95e809efefFCbF4EBEdfD55"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"SushiKatana",partner:"Orbs:TWAP:Sushi",exchangeAddress:"0x92209481507e6B2d14C9b5b70Ed287024177220E",exchangeType:"ExchangeV2",pathfinderKey:""},DragonSwap:{chainId:1329,name:"DragonSwap"},SwapX:{chainName:"sonic",chainId:146,twapVersion:4,twapAddress:"0x8963992816b4EafE5a22b7DB2A99513c18be9afA",lensAddress:"0x67e631F71232D63AcA98a2D5E9B2Bce5FCc39d5D",takers:["0xDF406A27C58a8Cd6Fd43e143339bCE131216a913","0x504f6E10173249dD22491829D98862Cf81DeF79E"],bidDelaySeconds:60,minChunkSizeUsd:10,name:"SwapX",partner:"Orbs:TWAP:SwapX",exchangeAddress:"0xDA902994b7F7a1ecDd8De02E4a17dbFF2E6F67b7",exchangeType:"ExchangeV2",pathfinderKey:""},BlackholeAvax:{chainName:"avax",chainId:43114,twapVersion:4,twapAddress:"0xf77Ad005aBF7e31f669ce89a6568B2f39Ca92cDe",lensAddress:"0x48466B82Ce1575c5c9eCa168ac1090048dD47fA3",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"BlackholeAvax",partner:"Orbs:TWAP:BlackholeAvax",exchangeAddress:"0xb7A3d74895bFD3Aff6780525e36D79FCf26a895F",exchangeType:"ExchangeV2"}},Ks=JSON.parse('[{"inputs":[{"internalType":"address","name":"_iweth","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"id","type":"uint64"},{"indexed":true,"internalType":"address","name":"maker","type":"address"},{"indexed":true,"internalType":"address","name":"exchange","type":"address"},{"indexed":false,"internalType":"uint32","name":"slippagePercent","type":"uint32"},{"components":[{"internalType":"uint32","name":"time","type":"uint32"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"address","name":"exchange","type":"address"},{"internalType":"uint256","name":"dstAmount","type":"uint256"},{"internalType":"uint256","name":"dstFee","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"indexed":false,"internalType":"struct OrderLib.Bid","name":"bid","type":"tuple"}],"name":"OrderBid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"id","type":"uint64"},{"indexed":true,"internalType":"address","name":"maker","type":"address"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"OrderCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"id","type":"uint64"},{"indexed":true,"internalType":"address","name":"maker","type":"address"},{"indexed":true,"internalType":"address","name":"exchange","type":"address"},{"indexed":false,"internalType":"address","name":"taker","type":"address"}],"name":"OrderCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"id","type":"uint64"},{"indexed":true,"internalType":"address","name":"maker","type":"address"},{"indexed":true,"internalType":"address","name":"exchange","type":"address"},{"components":[{"internalType":"address","name":"exchange","type":"address"},{"internalType":"address","name":"srcToken","type":"address"},{"internalType":"address","name":"dstToken","type":"address"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"srcBidAmount","type":"uint256"},{"internalType":"uint256","name":"dstMinAmount","type":"uint256"},{"internalType":"uint32","name":"deadline","type":"uint32"},{"internalType":"uint32","name":"bidDelay","type":"uint32"},{"internalType":"uint32","name":"fillDelay","type":"uint32"},{"internalType":"bytes","name":"data","type":"bytes"}],"indexed":false,"internalType":"struct OrderLib.Ask","name":"ask","type":"tuple"}],"name":"OrderCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"id","type":"uint64"},{"indexed":true,"internalType":"address","name":"maker","type":"address"},{"indexed":true,"internalType":"address","name":"exchange","type":"address"},{"indexed":false,"internalType":"address","name":"taker","type":"address"},{"indexed":false,"internalType":"uint256","name":"srcAmountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"dstAmountOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"dstFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"srcFilledAmount","type":"uint256"}],"name":"OrderFilled","type":"event"},{"inputs":[],"name":"MIN_BID_DELAY_SECONDS","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_OUTBID_PERCENT","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PERCENT_BASE","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STALE_BID_SECONDS","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STATUS_CANCELED","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STATUS_COMPLETED","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"exchange","type":"address"},{"internalType":"address","name":"srcToken","type":"address"},{"internalType":"address","name":"dstToken","type":"address"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"srcBidAmount","type":"uint256"},{"internalType":"uint256","name":"dstMinAmount","type":"uint256"},{"internalType":"uint32","name":"deadline","type":"uint32"},{"internalType":"uint32","name":"bidDelay","type":"uint32"},{"internalType":"uint32","name":"fillDelay","type":"uint32"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct OrderLib.Ask","name":"_ask","type":"tuple"}],"name":"ask","outputs":[{"internalType":"uint64","name":"id","type":"uint64"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"id","type":"uint64"},{"internalType":"address","name":"exchange","type":"address"},{"internalType":"uint256","name":"dstFee","type":"uint256"},{"internalType":"uint32","name":"slippagePercent","type":"uint32"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"bid","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"book","outputs":[{"internalType":"uint64","name":"id","type":"uint64"},{"internalType":"uint32","name":"status","type":"uint32"},{"internalType":"uint32","name":"time","type":"uint32"},{"internalType":"uint32","name":"filledTime","type":"uint32"},{"internalType":"uint256","name":"srcFilledAmount","type":"uint256"},{"internalType":"address","name":"maker","type":"address"},{"components":[{"internalType":"address","name":"exchange","type":"address"},{"internalType":"address","name":"srcToken","type":"address"},{"internalType":"address","name":"dstToken","type":"address"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"srcBidAmount","type":"uint256"},{"internalType":"uint256","name":"dstMinAmount","type":"uint256"},{"internalType":"uint32","name":"deadline","type":"uint32"},{"internalType":"uint32","name":"bidDelay","type":"uint32"},{"internalType":"uint32","name":"fillDelay","type":"uint32"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct OrderLib.Ask","name":"ask","type":"tuple"},{"components":[{"internalType":"uint32","name":"time","type":"uint32"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"address","name":"exchange","type":"address"},{"internalType":"uint256","name":"dstAmount","type":"uint256"},{"internalType":"uint256","name":"dstFee","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct OrderLib.Bid","name":"bid","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"id","type":"uint64"}],"name":"cancel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"id","type":"uint64"}],"name":"fill","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"iweth","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"length","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"makerOrders","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"id","type":"uint64"}],"name":"order","outputs":[{"components":[{"internalType":"uint64","name":"id","type":"uint64"},{"internalType":"uint32","name":"status","type":"uint32"},{"internalType":"uint32","name":"time","type":"uint32"},{"internalType":"uint32","name":"filledTime","type":"uint32"},{"internalType":"uint256","name":"srcFilledAmount","type":"uint256"},{"internalType":"address","name":"maker","type":"address"},{"components":[{"internalType":"address","name":"exchange","type":"address"},{"internalType":"address","name":"srcToken","type":"address"},{"internalType":"address","name":"dstToken","type":"address"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"srcBidAmount","type":"uint256"},{"internalType":"uint256","name":"dstMinAmount","type":"uint256"},{"internalType":"uint32","name":"deadline","type":"uint32"},{"internalType":"uint32","name":"bidDelay","type":"uint32"},{"internalType":"uint32","name":"fillDelay","type":"uint32"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct OrderLib.Ask","name":"ask","type":"tuple"},{"components":[{"internalType":"uint32","name":"time","type":"uint32"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"address","name":"exchange","type":"address"},{"internalType":"uint256","name":"dstAmount","type":"uint256"},{"internalType":"uint256","name":"dstFee","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct OrderLib.Bid","name":"bid","type":"tuple"}],"internalType":"struct OrderLib.Order","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"maker","type":"address"}],"name":"orderIdsByMaker","outputs":[{"internalType":"uint64[]","name":"","type":"uint64[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"id","type":"uint64"}],"name":"prune","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"status","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]'),Hs=[{type:"constructor",inputs:[],stateMutability:"nonpayable"},{type:"function",name:"DOMAIN_SEPARATOR",inputs:[],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"cancel",inputs:[{name:"digests",type:"bytes32[]",internalType:"bytes32[]"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"eip712Domain",inputs:[],outputs:[{name:"fields",type:"bytes1",internalType:"bytes1"},{name:"name",type:"string",internalType:"string"},{name:"version",type:"string",internalType:"string"},{name:"chainId",type:"uint256",internalType:"uint256"},{name:"verifyingContract",type:"address",internalType:"address"},{name:"salt",type:"bytes32",internalType:"bytes32"},{name:"extensions",type:"uint256[]",internalType:"uint256[]"}],stateMutability:"view"},{type:"function",name:"hashTypedData",inputs:[{name:"structHash",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"digest",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"repermitWitnessTransferFrom",inputs:[{name:"permit",type:"tuple",internalType:"struct RePermitLib.RePermitTransferFrom",components:[{name:"permitted",type:"tuple",internalType:"struct RePermitLib.TokenPermissions",components:[{name:"token",type:"address",internalType:"address"},{name:"amount",type:"uint256",internalType:"uint256"}]},{name:"nonce",type:"uint256",internalType:"uint256"},{name:"deadline",type:"uint256",internalType:"uint256"}]},{name:"request",type:"tuple",internalType:"struct RePermitLib.TransferRequest",components:[{name:"to",type:"address",internalType:"address"},{name:"amount",type:"uint256",internalType:"uint256"}]},{name:"signer",type:"address",internalType:"address"},{name:"witness",type:"bytes32",internalType:"bytes32"},{name:"witnessTypeString",type:"string",internalType:"string"},{name:"signature",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"spent",inputs:[{name:"",type:"address",internalType:"address"},{name:"",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"event",name:"Cancel",inputs:[{name:"signer",type:"address",indexed:!0,internalType:"address"},{name:"digest",type:"bytes32",indexed:!1,internalType:"bytes32"}],anonymous:!1},{type:"event",name:"EIP712DomainChanged",inputs:[],anonymous:!1},{type:"event",name:"Spend",inputs:[{name:"signer",type:"address",indexed:!0,internalType:"address"},{name:"permitHash",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"token",type:"address",indexed:!0,internalType:"address"},{name:"to",type:"address",indexed:!1,internalType:"address"},{name:"amount",type:"uint256",indexed:!1,internalType:"uint256"},{name:"totalSpent",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"error",name:"Canceled",inputs:[]},{type:"error",name:"Expired",inputs:[]},{type:"error",name:"InsufficientAllowance",inputs:[]},{type:"error",name:"InvalidShortString",inputs:[]},{type:"error",name:"InvalidSignature",inputs:[]},{type:"error",name:"SafeERC20FailedOperation",inputs:[{name:"token",type:"address",internalType:"address"}]},{type:"error",name:"StringTooLong",inputs:[{name:"str",type:"string",internalType:"string"}]}],Ws=Ks;var $=(e=>(e.TWAP="TWAP",e.LIMIT="LIMIT",e.STOP_LOSS="STOP_LOSS",e.TAKE_PROFIT="TAKE_PROFIT",e))($||{}),he=(e=>(e.Open="OPEN",e.Cancelled="CANCELLED",e.Completed="COMPLETED",e.Expired="EXPIRED",e))(he||{}),vr=(e=>(e.All="ALL",e.Open="OPEN",e.Cancelled="CANCELLED",e.Completed="COMPLETED",e.Expired="EXPIRED",e))(vr||{}),Pe=(e=>(e[e.Minutes=6e4]="Minutes",e[e.Hours=36e5]="Hours",e[e.Weeks=6048e5]="Weeks",e[e.Days=864e5]="Days",e[e.Months=2592e6]="Months",e[e.Years=31536e6]="Years",e))(Pe||{}),V=(e=>(e.LIMIT="limit",e.TWAP_LIMIT="twap-limit",e.TWAP_MARKET="twap-market",e.TAKE_PROFIT_MARKET="take-profit-market",e.TAKE_PROFIT_LIMIT="take-profit-limit",e.STOP_LOSS_LIMIT="stop-loss-limit",e.STOP_LOSS_MARKET="stop-loss-market",e))(V||{}),Ne=(e=>(e.Arbidex="arbidex",e.Blackhole="blackhole",e.Chronos="chronos",e.Dragon="dragon",e.Kodiak="kodiak",e.Lynex="lynex",e.Nami="nami",e.Newera="newera",e.Omni="omni",e.Pancake="pancake",e.Quick="quick",e.Ramses="ramses",e.Shadow="shadow",e.Spark="spark",e.Spooky="spooky",e.Swapx="swapx",e.Teafi="teafi",e.Thena="thena",e.Yowie="yowie",e.Pangolin="pangolin",e.Sushiswap="sushiswap",e.Agent="agent",e))(Ne||{}),me=(e=>(e.EMPTY_LIMIT_PRICE="emptyLimitPrice",e.MAX_CHUNKS="maxChunksError",e.MIN_CHUNKS="minChunksError",e.MIN_TRADE_SIZE="minTradeSizeError",e.MAX_FILL_DELAY="maxFillDelayError",e.MIN_FILL_DELAY="minFillDelayError",e.MAX_ORDER_DURATION="maxDurationError",e.MIN_ORDER_DURATION="minDurationError",e.MISSING_LIMIT_PRICE="missingLimitPrice",e.STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE="StopLossTriggerPriceError",e.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE="triggerLimitPriceError",e.TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE="TakeProfitTriggerPriceError",e.EMPTY_TRIGGER_PRICE="emptyTriggerPrice",e.INSUFFICIENT_BALANCE="insufficientFunds",e.MAX_ORDER_SIZE="maxOrderSize",e.MIN_TRADE_SIZE_ERROR="minTradeSizeError",e))(me||{});const re="0x0000000000000000000000000000000000000000",ye={eth:{id:1,name:"Ethereum",shortname:"eth",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg"},wToken:{symbol:"WETH",address:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://eth.llamarpc.com",logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg",explorer:"https://etherscan.io",eip1559:!0},bsc:{id:56,name:"BinanceSmartChain",shortname:"bsc",native:{address:re,symbol:"BNB",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/1839.png"},wToken:{symbol:"WBNB",address:"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/1839.png"},publicRpcUrl:"https://bsc-dataseed.binance.org",logoUrl:"https://app.1inch.io/assets/images/network-logos/bsc_2.svg",explorer:"https://bscscan.com",eip1559:!1},poly:{id:137,name:"Polygon",shortname:"poly",native:{address:re,symbol:"POL",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/64x64/28321.png"},wToken:{symbol:"WPOL",address:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270.png"},publicRpcUrl:"https://polygon-rpc.com",logoUrl:"https://app.1inch.io/assets/images/network-logos/polygon.svg",explorer:"https://polygonscan.com",eip1559:!0},arb:{id:42161,name:"Arbitrum",shortname:"arb",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg"},wToken:{symbol:"WETH",address:"0x82af49447d8a07e3bd95bd0d56f35241523fbab1",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://arb1.arbitrum.io/rpc",logoUrl:"https://app.1inch.io/assets/images/network-logos/arbitrum.svg",explorer:"https://arbiscan.io",eip1559:!0},sei:{id:1329,name:"Sei",shortname:"sei",native:{address:re,symbol:"SEI",decimals:18,logoUrl:"https://assets.coingecko.com/coins/images/28205/standard/Sei_Logo_-_Transparent.png"},wToken:{symbol:"WSEI",address:"0xE30feDd158A2e3b13e9badaeABaFc5516e95e8C7",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://evm-rpc.sei-apis.com",logoUrl:"https://assets.coingecko.com/coins/images/28205/standard/Sei_Logo_-_Transparent.png",explorer:"https://seitrace.com",eip1559:!1},avax:{id:43114,name:"Avalanche",shortname:"avax",native:{address:re,symbol:"AVAX",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/avalanche.svg"},wToken:{symbol:"WAVAX",address:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7.png"},publicRpcUrl:"https://api.avax.network/ext/bc/C/rpc",logoUrl:"https://app.1inch.io/assets/images/network-logos/avalanche.svg",explorer:"https://snowtrace.io",eip1559:!0},ftm:{id:250,name:"Fantom",shortname:"ftm",native:{address:re,symbol:"FTM",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/fantom.svg"},wToken:{symbol:"WFTM",address:"0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0x4e15361fd6b4bb609fa63c81a2be19d873717870.png"},publicRpcUrl:"https://rpc.ftm.tools",logoUrl:"https://app.1inch.io/assets/images/network-logos/fantom.svg",explorer:"https://ftmscan.com",eip1559:!0},base:{id:8453,name:"Base",shortname:"base",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/1027.png"},wToken:{symbol:"WETH",address:"0x4200000000000000000000000000000000000006",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://mainnet.base.org",logoUrl:"https://app.1inch.io/assets/images/network-logos/base.svg",explorer:"https://basescan.org",eip1559:!1},linea:{id:59144,name:"Linea",shortname:"linea",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg"},wToken:{symbol:"WETH",address:"0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://rpc.linea.build",logoUrl:"https://lineascan.build/images/logo.svg",explorer:"https://lineascan.build",eip1559:!1},zksync:{id:324,name:"zksync",shortname:"zksync",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg"},wToken:{symbol:"WETH",address:"0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://mainnet.era.zksync.io",logoUrl:"https://raw.githubusercontent.com/matter-labs/zksync/0a4ca2145a0c95b5bafa84c2f095c644907a8825/zkSyncLogo.svg",explorer:"https://explorer.zksync.io/",eip1559:!0},zkevm:{id:1101,name:"zkevm",shortname:"zkevm",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg"},wToken:{symbol:"WETH",address:"0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://zkevm-rpc.com",logoUrl:"https://user-images.githubusercontent.com/18598517/235932702-bc47eae5-d672-4dd9-9da2-8ea8f51a93f3.png",explorer:"https://zkevm.polygonscan.com/",eip1559:!0},manta:{id:169,name:"manta",shortname:"manta",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://icons.llamao.fi/icons/chains/rsz_manta.jpg"},wToken:{symbol:"WETH",address:"0x0Dc808adcE2099A9F62AA87D9670745AbA741746",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://pacific-rpc.manta.network/http",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_manta.jpg",explorer:"https://manta.socialscan.io/",eip1559:!0},blast:{id:81457,name:"blast",shortname:"blast",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://icons.llamao.fi/icons/chains/rsz_blast"},wToken:{symbol:"WETH",address:"0x4300000000000000000000000000000000000004",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://rpc.ankr.com/blast",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_blast",explorer:"https://blastscan.io/",eip1559:!0},sonic:{id:146,name:"sonic",shortname:"sonic",native:{address:re,symbol:"S",decimals:18,logoUrl:"https://icons.llamao.fi/icons/chains/rsz_sonic"},wToken:{symbol:"WS",address:"0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38",decimals:18,logoUrl:"https://icons.llamao.fi/icons/chains/rsz_sonic"},publicRpcUrl:"https://rpc.soniclabs.com",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_sonic",explorer:"https://www.sonicscan.org/",eip1559:!0},scroll:{id:534352,name:"scroll",shortname:"scroll",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://icons.llamao.fi/icons/chains/rsz_scroll"},wToken:{symbol:"WETH",address:"0x5300000000000000000000000000000000000004",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://scroll-rpc.publicnode.com",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_scroll",explorer:"https://scrollscan.com/",eip1559:!0},zircuit:{id:48900,name:"Zircuit",shortname:"zircuit",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg"},wToken:{symbol:"WETH",address:"0x4200000000000000000000000000000000000006",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://zircuit-mainnet.drpc.org",logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg",explorer:"https://explorer.zircuit.com/",eip1559:!0},flare:{id:14,name:"flare",shortname:"flare",native:{address:re,symbol:"FLR",decimals:18,logoUrl:"https://icons.llamao.fi/icons/chains/rsz_flare?w=48&h=48"},wToken:{symbol:"WFLR",address:"0x1D80c49BbBCd1C0911346656B529DF9E5c2F783d",decimals:18,logoUrl:"https://res.cloudinary.com/sparkdex/image/upload/q_100/v1/website-assets/coins/wflr?_a=DATAg1AAZAA0"},publicRpcUrl:"https://flare.network",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_flare?w=48&h=48",explorer:"https://flarescan.com",eip1559:!0},cronosZkEvm:{id:388,name:"Cronos zkEVM",shortname:"cronosZkEvm",native:{address:"0x000000000000000000000000000000000000800a",symbol:"zkCRO",decimals:18,logoUrl:"https://cryptologos.cc/logos/cronos-cro-logo.png"},wToken:{symbol:"wzkCRO",address:"0xC1bF55EE54E16229d9b369a5502Bfe5fC9F20b6d",decimals:18,logoUrl:"https://cryptologos.cc/logos/cronos-cro-logo.png"},publicRpcUrl:"https://rpc.zkevm.cronos.org",logoUrl:"https://cryptologos.cc/logos/cronos-cro-logo.png",explorer:"https://explorer.zkevm.cronos.org",eip1559:!0},katana:{id:747474,name:"Katana",shortname:"katana",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://katana.network/assets/katana-logo.svg"},wToken:{symbol:"WETH",address:"0xee7d8bcfb72bc1880d0cf19822eb0a2e6577ab62",decimals:18,logoUrl:"https://katana.network/assets/weth-logo.svg"},publicRpcUrl:"https://rpc.katanarpc.com",logoUrl:"https://katana.network/assets/katana-logo.svg",explorer:"https://explorer.katana.garden",eip1559:!0},bera:{id:80094,name:"Bera",shortname:"bera",native:{address:re,symbol:"BERA",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/24647.png"},wToken:{symbol:"WBERA",address:"0x6969696969696969696969696969696969696969",decimals:18,logoUrl:"https://berascan.com/token/images/wrappedbera_ofc_64.png"},publicRpcUrl:"wss://rpc.berachain-apis.com",logoUrl:"https://katana.network/assets/katana-logo.svg",explorer:"https://berascan.com",eip1559:!0},monad:{id:143,name:"Monad",shortname:"monad",native:{address:re,symbol:"MONAD",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/30495.png"},wToken:{symbol:"WMON",address:"0x3bd359c1119da7da1d913d1c4d2b7c461115433a",decimals:18,logoUrl:"https://assets.coingecko.com/coins/images/70784/standard/wmon.png?1766028904"},publicRpcUrl:"https://monad-mainnet.drpc.org",logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/30495.png",explorer:"https://monad.network",eip1559:!0},optimism:{id:10,name:"Optimism",shortname:"optimism",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/11840.png"},wToken:{symbol:"WETH",address:"0x4200000000000000000000000000000000000006",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/2396.png"},publicRpcUrl:"https://optimism.blockscout.com",logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/11840.png",explorer:"https://optimistic.etherscan.io",eip1559:!0},mantle:{id:5e3,name:"Mantle",shortname:"mantle",native:{address:re,symbol:"MNT",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/27075.png"},wToken:{symbol:"WMNT",address:"0x78c1b0c915c4faa5fffa6cabf0219da63d7f4cb8",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/27614.png"},publicRpcUrl:"https://rpc.mantle.xyz",logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/27075.png",explorer:"https://mantlescan.xyz",eip1559:!0}},Dn={version:"2.5.3"},Qs="https://order-sink-dev.orbs.network",js="https://order-sink.orbs.network",zs="https://order-sink-v2.orbs.network",On=Dn.version.split(".")[0],xr=e=>{const t=Number(On)>=2;return e?Qs:t?zs:js},In=300*1e3,ln=1440*60*60*1e3,Sr=300*1e3,$s=new Date(In).getMinutes(),kn=e=>`https://hub.orbs.network/api/private/project_cm7nb67z86nyr01z12gs0fxpf/subgraphs/orbs-twap-${e}/prod/gn`,_e="https://hub.orbs.network/api/apikey/subgraphs/id",Vs={[ye.eth.id]:`${_e}/Bf7bvMYcJbDAvYWJmhMpHZ4cpFjqzkhK6GXXEpnPRq6`,[ye.bsc.id]:`${_e}/4NfXEi8rreQsnAr4aJ45RLCKgnjcWX46Lbt9SadiCcz6`,[ye.poly.id]:`${_e}/3PyRPWSvDnMowGbeBy7aNsvUkD5ZuxdXQw2RdJq4NdXi`,[ye.arb.id]:`${_e}/83bpQexEaqBjHaQbKoFTbtvCXuo5RudRkfLgtRUYqo2c`,[ye.base.id]:`${_e}/DFhaPQb3HATXkpsWNZw3gydYHehLBVEDiSk4iBdZJyps`,[ye.sei.id]:`${_e}/5zjzRnURzoddyFSZBw5E5NAM3oBgPq3NasTYbtMk6EL6`,[ye.linea.id]:`${_e}/6VsNPEYfFLPZCqdMMDadoXQjLHWJdjEwiD768GAtb7j6`,[ye.sonic.id]:`${_e}/DtBr6a5vsoDd2oAXdPszcn4gLgrr1XC68Q3AJQKXnNLV`,[ye.ftm.id]:`${_e}/DdRo1pmJkrJC9fjsjEBWnNE1uqrbh7Diz4tVKd7rfupp`,[ye.katana.id]:`${_e}/CGi9sDFMQcnBwF3C3NoCFqnaE34sssbgwPLTwiskSXmW`,[ye.avax.id]:`${_e}/FxZ1vMwE5Xy1qvKvZENUMz4vhW8Sh4vXJf9Vp7o17pTx`,[ye.bera.id]:kn("berachain"),[ye.flare.id]:kn("flare"),[ye.cronosZkEvm.id]:kn("cronos-zkevm")},Gs=["0x0000000000000000000000000000000000000000","0x0000000000000000000000000000000000001010","0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE","0x000000000000000000000000000000000000dEaD","0x000000000000000000000000000000000000800A","0x000000000000000000000000000000000000800a"],Fr="115792089237316195423570985008687907853269984665640564039457584007913129639935",Ae=e=>`${e.name}_${e.chainId}`,Xs={[Ae(z.SushiArb)]:["0x846F2B29ef314bF3D667981b4ffdADc5B858312a","0x08c41f5D1C844061f6D952E25827eeAA576c6536"],[Ae(z.SushiBase)]:["0x846F2B29ef314bF3D667981b4ffdADc5B858312a","0x08c41f5D1C844061f6D952E25827eeAA576c6536"],[Ae(z.SushiEth)]:["0xc55943Fa6509004B2903ED8F8ab7347BfC47D0bA","0x08c41f5D1C844061f6D952E25827eeAA576c6536"],[Ae(z.PancakeSwap)]:["0xb2BAFe188faD927240038cC4FfF2d771d8A58905","0xE2a0c3b9aD19A18c4bBa7fffBe5bC1b0E58Db1CE"],[Ae(z.PancakeSwapArbitrum)]:["0xE20167871dB616DdfFD0Fd870d9bC068C350DD1F","0x807488ADAD033e95C438F998277bE654152594dc"],[Ae(z.PancakeSwapBase)]:["0x10ed1F36e4eBE76E161c9AADDa20BE841bc0082c","0x3A9df3eE209b802D0337383f5abCe3204d623588"],[Ae(z.PancakeSwapLinea)]:["0x3A9df3eE209b802D0337383f5abCe3204d623588"],[Ae(z.QuickSwap)]:["0x26D0ec4Be402BCE03AAa8aAf0CF67e9428ba54eF"],[Ae(z.Thena)]:["0xc2aBC02acd77Bb2407efA22348dA9afC8B375290"],[Ae(z.Lynex)]:["0x72e3e1fD5D2Ee2F1C2Eb695206D490a1D45C3835"],[Ae(z.DragonSwap)]:["0x101e1B65Bb516FB5f4547C80BAe0b51f1b8D7a22"],[Ae(z.SpookySwapSonic)]:["0xAd97B770ad64aE47fc7d64B3bD820dCDbF9ff7DA"],[Ae(z.SpookySwap)]:["0x3924d62219483015f982b160d48c0fa5Fd436Cba"],[Ae(z.SwapX)]:["0xE5012eBDe5e26EE3Ea41992154731a03023CF274"]},Mn={unit:Pe.Minutes,value:$s},Zs="RePermitWitnessTransferFrom",Ys={RePermitWitnessTransferFrom:[{name:"permitted",type:"TokenPermissions"},{name:"spender",type:"address"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"},{name:"witness",type:"Order"}],Exchange:[{name:"adapter",type:"address"},{name:"ref",type:"address"},{name:"share",type:"uint32"},{name:"data",type:"bytes"}],Input:[{name:"token",type:"address"},{name:"amount",type:"uint256"},{name:"maxAmount",type:"uint256"}],Order:[{name:"reactor",type:"address"},{name:"executor",type:"address"},{name:"exchange",type:"Exchange"},{name:"swapper",type:"address"},{name:"nonce",type:"uint256"},{name:"start",type:"uint256"},{name:"deadline",type:"uint256"},{name:"chainid",type:"uint256"},{name:"exclusivity",type:"uint32"},{name:"epoch",type:"uint32"},{name:"slippage",type:"uint32"},{name:"freshness",type:"uint32"},{name:"input",type:"Input"},{name:"output",type:"Output"}],Output:[{name:"token",type:"address"},{name:"limit",type:"uint256"},{name:"triggerLower",type:"uint256"},{name:"triggerUpper",type:"uint256"},{name:"recipient",type:"address"}],TokenPermissions:[{name:"token",type:"address"},{name:"amount",type:"uint256"}]},Js="https://www.orbs.com/dtwap-and-dlimit-faq/",ea="https://www.orbs.com/dtwap-and-dlimit-faq/#dSLTP",ta="https://raw.githubusercontent.com/orbs-network/twap-ui/master/logo/orbslogo.svg",na="https://www.orbs.com/",ra="https://www.orbs.com/dtwap-dlimit-disclaimer";var Yt=(e=>(e.FRESHNESS="freshness",e.MIN_CHUNK_SIZE_USD="minChunkSizeUsd",e.ENV="env",e.DURATION="duration",e.IGNORE_ERRORS="ignore-errors",e))(Yt||{});const sa="-5",aa="10",ia="-10",oa="5";var ca=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Bn=Math.ceil,De=Math.floor,ve="[BigNumber Error] ",Pr=ve+"Number primitive has more than 15 significant digits: ",Ue=1e14,W=14,_n=9007199254740991,Un=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],et=1e7,le=1e9;function Dr(e){var t,n,r,s=P.prototype={constructor:P,toString:null,valueOf:null},a=new P(1),o=20,d=4,p=-7,f=21,w=-1e7,C=1e7,v=!1,F=1,O=0,I={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},M="0123456789abcdefghijklmnopqrstuvwxyz",_=!0;function P(i,c){var u,A,m,y,T,h,g,b,E=this;if(!(E instanceof P))return new P(i,c);if(c==null){if(i&&i._isBigNumber===!0){E.s=i.s,!i.c||i.e>C?E.c=E.e=null:i.e<w?E.c=[E.e=0]:(E.e=i.e,E.c=i.c.slice());return}if((h=typeof i=="number")&&i*0==0){if(E.s=1/i<0?(i=-i,-1):1,i===~~i){for(y=0,T=i;T>=10;T/=10,y++);y>C?E.c=E.e=null:(E.e=y,E.c=[i]);return}b=String(i)}else{if(!ca.test(b=String(i)))return r(E,b,h);E.s=b.charCodeAt(0)==45?(b=b.slice(1),-1):1}(y=b.indexOf("."))>-1&&(b=b.replace(".","")),(T=b.search(/e/i))>0?(y<0&&(y=T),y+=+b.slice(T+1),b=b.substring(0,T)):y<0&&(y=b.length)}else{if(ne(c,2,M.length,"Base"),c==10&&_)return E=new P(i),Y(E,o+E.e+1,d);if(b=String(i),h=typeof i=="number"){if(i*0!=0)return r(E,b,h,c);if(E.s=1/i<0?(b=b.slice(1),-1):1,P.DEBUG&&b.replace(/^0\.0*|\./,"").length>15)throw Error(Pr+i)}else E.s=b.charCodeAt(0)===45?(b=b.slice(1),-1):1;for(u=M.slice(0,c),y=T=0,g=b.length;T<g;T++)if(u.indexOf(A=b.charAt(T))<0){if(A=="."){if(T>y){y=g;continue}}else if(!m&&(b==b.toUpperCase()&&(b=b.toLowerCase())||b==b.toLowerCase()&&(b=b.toUpperCase()))){m=!0,T=-1,y=0;continue}return r(E,String(i),h,c)}h=!1,b=n(b,c,10,E.s),(y=b.indexOf("."))>-1?b=b.replace(".",""):y=b.length}for(T=0;b.charCodeAt(T)===48;T++);for(g=b.length;b.charCodeAt(--g)===48;);if(b=b.slice(T,++g)){if(g-=T,h&&P.DEBUG&&g>15&&(i>_n||i!==De(i)))throw Error(Pr+E.s*i);if((y=y-T-1)>C)E.c=E.e=null;else if(y<w)E.c=[E.e=0];else{if(E.e=y,E.c=[],T=(y+1)%W,y<0&&(T+=W),T<g){for(T&&E.c.push(+b.slice(0,T)),g-=W;T<g;)E.c.push(+b.slice(T,T+=W));T=W-(b=b.slice(T)).length}else T-=g;for(;T--;b+="0");E.c.push(+b)}}else E.c=[E.e=0]}P.clone=Dr,P.ROUND_UP=0,P.ROUND_DOWN=1,P.ROUND_CEIL=2,P.ROUND_FLOOR=3,P.ROUND_HALF_UP=4,P.ROUND_HALF_DOWN=5,P.ROUND_HALF_EVEN=6,P.ROUND_HALF_CEIL=7,P.ROUND_HALF_FLOOR=8,P.EUCLID=9,P.config=P.set=function(i){var c,u;if(i!=null)if(typeof i=="object"){if(i.hasOwnProperty(c="DECIMAL_PLACES")&&(u=i[c],ne(u,0,le,c),o=u),i.hasOwnProperty(c="ROUNDING_MODE")&&(u=i[c],ne(u,0,8,c),d=u),i.hasOwnProperty(c="EXPONENTIAL_AT")&&(u=i[c],u&&u.pop?(ne(u[0],-le,0,c),ne(u[1],0,le,c),p=u[0],f=u[1]):(ne(u,-le,le,c),p=-(f=u<0?-u:u))),i.hasOwnProperty(c="RANGE"))if(u=i[c],u&&u.pop)ne(u[0],-le,-1,c),ne(u[1],1,le,c),w=u[0],C=u[1];else if(ne(u,-le,le,c),u)w=-(C=u<0?-u:u);else throw Error(ve+c+" cannot be zero: "+u);if(i.hasOwnProperty(c="CRYPTO"))if(u=i[c],u===!!u)if(u)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))v=u;else throw v=!u,Error(ve+"crypto unavailable");else v=u;else throw Error(ve+c+" not true or false: "+u);if(i.hasOwnProperty(c="MODULO_MODE")&&(u=i[c],ne(u,0,9,c),F=u),i.hasOwnProperty(c="POW_PRECISION")&&(u=i[c],ne(u,0,le,c),O=u),i.hasOwnProperty(c="FORMAT"))if(u=i[c],typeof u=="object")I=u;else throw Error(ve+c+" not an object: "+u);if(i.hasOwnProperty(c="ALPHABET"))if(u=i[c],typeof u=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(u))_=u.slice(0,10)=="0123456789",M=u;else throw Error(ve+c+" invalid: "+u)}else throw Error(ve+"Object expected: "+i);return{DECIMAL_PLACES:o,ROUNDING_MODE:d,EXPONENTIAL_AT:[p,f],RANGE:[w,C],CRYPTO:v,MODULO_MODE:F,POW_PRECISION:O,FORMAT:I,ALPHABET:M}},P.isBigNumber=function(i){if(!i||i._isBigNumber!==!0)return!1;if(!P.DEBUG)return!0;var c,u,A=i.c,m=i.e,y=i.s;e:if({}.toString.call(A)=="[object Array]"){if((y===1||y===-1)&&m>=-le&&m<=le&&m===De(m)){if(A[0]===0){if(m===0&&A.length===1)return!0;break e}if(c=(m+1)%W,c<1&&(c+=W),String(A[0]).length==c){for(c=0;c<A.length;c++)if(u=A[c],u<0||u>=Ue||u!==De(u))break e;if(u!==0)return!0}}}else if(A===null&&m===null&&(y===null||y===1||y===-1))return!0;throw Error(ve+"Invalid BigNumber: "+i)},P.maximum=P.max=function(){return U(arguments,-1)},P.minimum=P.min=function(){return U(arguments,1)},P.random=(function(){var i=9007199254740992,c=Math.random()*i&2097151?function(){return De(Math.random()*i)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(u){var A,m,y,T,h,g=0,b=[],E=new P(a);if(u==null?u=o:ne(u,0,le),T=Bn(u/W),v)if(crypto.getRandomValues){for(A=crypto.getRandomValues(new Uint32Array(T*=2));g<T;)h=A[g]*131072+(A[g+1]>>>11),h>=9e15?(m=crypto.getRandomValues(new Uint32Array(2)),A[g]=m[0],A[g+1]=m[1]):(b.push(h%1e14),g+=2);g=T/2}else if(crypto.randomBytes){for(A=crypto.randomBytes(T*=7);g<T;)h=(A[g]&31)*281474976710656+A[g+1]*1099511627776+A[g+2]*4294967296+A[g+3]*16777216+(A[g+4]<<16)+(A[g+5]<<8)+A[g+6],h>=9e15?crypto.randomBytes(7).copy(A,g):(b.push(h%1e14),g+=7);g=T/7}else throw v=!1,Error(ve+"crypto unavailable");if(!v)for(;g<T;)h=c(),h<9e15&&(b[g++]=h%1e14);for(T=b[--g],u%=W,T&&u&&(h=Un[W-u],b[g]=De(T/h)*h);b[g]===0;b.pop(),g--);if(g<0)b=[y=0];else{for(y=-1;b[0]===0;b.splice(0,1),y-=W);for(g=1,h=b[0];h>=10;h/=10,g++);g<W&&(y-=W-g)}return E.e=y,E.c=b,E}})(),P.sum=function(){for(var i=1,c=arguments,u=new P(c[0]);i<c.length;)u=u.plus(c[i++]);return u},n=(function(){var i="0123456789";function c(u,A,m,y){for(var T,h=[0],g,b=0,E=u.length;b<E;){for(g=h.length;g--;h[g]*=A);for(h[0]+=y.indexOf(u.charAt(b++)),T=0;T<h.length;T++)h[T]>m-1&&(h[T+1]==null&&(h[T+1]=0),h[T+1]+=h[T]/m|0,h[T]%=m)}return h.reverse()}return function(u,A,m,y,T){var h,g,b,E,D,R,L,G,ae=u.indexOf("."),de=o,J=d;for(ae>=0&&(E=O,O=0,u=u.replace(".",""),G=new P(A),R=G.pow(u.length-ae),O=E,G.c=c(ze(Ie(R.c),R.e,"0"),10,m,i),G.e=G.c.length),L=c(u,A,m,T?(h=M,i):(h=i,M)),b=E=L.length;L[--E]==0;L.pop());if(!L[0])return h.charAt(0);if(ae<0?--b:(R.c=L,R.e=b,R.s=y,R=t(R,G,de,J,m),L=R.c,D=R.r,b=R.e),g=b+de+1,ae=L[g],E=m/2,D=D||g<0||L[g+1]!=null,D=J<4?(ae!=null||D)&&(J==0||J==(R.s<0?3:2)):ae>E||ae==E&&(J==4||D||J==6&&L[g-1]&1||J==(R.s<0?8:7)),g<1||!L[0])u=D?ze(h.charAt(1),-de,h.charAt(0)):h.charAt(0);else{if(L.length=g,D)for(--m;++L[--g]>m;)L[g]=0,g||(++b,L=[1].concat(L));for(E=L.length;!L[--E];);for(ae=0,u="";ae<=E;u+=h.charAt(L[ae++]));u=ze(u,b,h.charAt(0))}return u}})(),t=(function(){function i(A,m,y){var T,h,g,b,E=0,D=A.length,R=m%et,L=m/et|0;for(A=A.slice();D--;)g=A[D]%et,b=A[D]/et|0,T=L*g+b*R,h=R*g+T%et*et+E,E=(h/y|0)+(T/et|0)+L*b,A[D]=h%y;return E&&(A=[E].concat(A)),A}function c(A,m,y,T){var h,g;if(y!=T)g=y>T?1:-1;else for(h=g=0;h<y;h++)if(A[h]!=m[h]){g=A[h]>m[h]?1:-1;break}return g}function u(A,m,y,T){for(var h=0;y--;)A[y]-=h,h=A[y]<m[y]?1:0,A[y]=h*T+A[y]-m[y];for(;!A[0]&&A.length>1;A.splice(0,1));}return function(A,m,y,T,h){var g,b,E,D,R,L,G,ae,de,J,te,ge,xn,fr,hr,je,un,Be=A.s==m.s?1:-1,we=A.c,ie=m.c;if(!we||!we[0]||!ie||!ie[0])return new P(!A.s||!m.s||(we?ie&&we[0]==ie[0]:!ie)?NaN:we&&we[0]==0||!ie?Be*0:Be/0);for(ae=new P(Be),de=ae.c=[],b=A.e-m.e,Be=y+b+1,h||(h=Ue,b=Oe(A.e/W)-Oe(m.e/W),Be=Be/W|0),E=0;ie[E]==(we[E]||0);E++);if(ie[E]>(we[E]||0)&&b--,Be<0)de.push(1),D=!0;else{for(fr=we.length,je=ie.length,E=0,Be+=2,R=De(h/(ie[0]+1)),R>1&&(ie=i(ie,R,h),we=i(we,R,h),je=ie.length,fr=we.length),xn=je,J=we.slice(0,je),te=J.length;te<je;J[te++]=0);un=ie.slice(),un=[0].concat(un),hr=ie[0],ie[1]>=h/2&&hr++;do{if(R=0,g=c(ie,J,je,te),g<0){if(ge=J[0],je!=te&&(ge=ge*h+(J[1]||0)),R=De(ge/hr),R>1)for(R>=h&&(R=h-1),L=i(ie,R,h),G=L.length,te=J.length;c(L,J,G,te)==1;)R--,u(L,je<G?un:ie,G,h),G=L.length,g=1;else R==0&&(g=R=1),L=ie.slice(),G=L.length;if(G<te&&(L=[0].concat(L)),u(J,L,te,h),te=J.length,g==-1)for(;c(ie,J,je,te)<1;)R++,u(J,je<te?un:ie,te,h),te=J.length}else g===0&&(R++,J=[0]);de[E++]=R,J[0]?J[te++]=we[xn]||0:(J=[we[xn]],te=1)}while((xn++<fr||J[0]!=null)&&Be--);D=J[0]!=null,de[0]||de.splice(0,1)}if(h==Ue){for(E=1,Be=de[0];Be>=10;Be/=10,E++);Y(ae,y+(ae.e=E+b*W-1)+1,T,D)}else ae.e=b,ae.r=+D;return ae}})();function K(i,c,u,A){var m,y,T,h,g;if(u==null?u=d:ne(u,0,8),!i.c)return i.toString();if(m=i.c[0],T=i.e,c==null)g=Ie(i.c),g=A==1||A==2&&(T<=p||T>=f)?fn(g,T):ze(g,T,"0");else if(i=Y(new P(i),c,u),y=i.e,g=Ie(i.c),h=g.length,A==1||A==2&&(c<=y||y<=p)){for(;h<c;g+="0",h++);g=fn(g,y)}else if(c-=T+(A===2&&y>T),g=ze(g,y,"0"),y+1>h){if(--c>0)for(g+=".";c--;g+="0");}else if(c+=y-h,c>0)for(y+1==h&&(g+=".");c--;g+="0");return i.s<0&&m?"-"+g:g}function U(i,c){for(var u,A,m=1,y=new P(i[0]);m<i.length;m++)A=new P(i[m]),(!A.s||(u=mt(y,A))===c||u===0&&y.s===c)&&(y=A);return y}function Z(i,c,u){for(var A=1,m=c.length;!c[--m];c.pop());for(m=c[0];m>=10;m/=10,A++);return(u=A+u*W-1)>C?i.c=i.e=null:u<w?i.c=[i.e=0]:(i.e=u,i.c=c),i}r=(function(){var i=/^(-?)0([xbo])(?=\w[\w.]*$)/i,c=/^([^.]+)\.$/,u=/^\.([^.]+)$/,A=/^-?(Infinity|NaN)$/,m=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(y,T,h,g){var b,E=h?T:T.replace(m,"");if(A.test(E))y.s=isNaN(E)?null:E<0?-1:1;else{if(!h&&(E=E.replace(i,function(D,R,L){return b=(L=L.toLowerCase())=="x"?16:L=="b"?2:8,!g||g==b?R:D}),g&&(b=g,E=E.replace(c,"$1").replace(u,"0.$1")),T!=E))return new P(E,b);if(P.DEBUG)throw Error(ve+"Not a"+(g?" base "+g:"")+" number: "+T);y.s=null}y.c=y.e=null}})();function Y(i,c,u,A){var m,y,T,h,g,b,E,D=i.c,R=Un;if(D){e:{for(m=1,h=D[0];h>=10;h/=10,m++);if(y=c-m,y<0)y+=W,T=c,g=D[b=0],E=De(g/R[m-T-1]%10);else if(b=Bn((y+1)/W),b>=D.length)if(A){for(;D.length<=b;D.push(0));g=E=0,m=1,y%=W,T=y-W+1}else break e;else{for(g=h=D[b],m=1;h>=10;h/=10,m++);y%=W,T=y-W+m,E=T<0?0:De(g/R[m-T-1]%10)}if(A=A||c<0||D[b+1]!=null||(T<0?g:g%R[m-T-1]),A=u<4?(E||A)&&(u==0||u==(i.s<0?3:2)):E>5||E==5&&(u==4||A||u==6&&(y>0?T>0?g/R[m-T]:0:D[b-1])%10&1||u==(i.s<0?8:7)),c<1||!D[0])return D.length=0,A?(c-=i.e+1,D[0]=R[(W-c%W)%W],i.e=-c||0):D[0]=i.e=0,i;if(y==0?(D.length=b,h=1,b--):(D.length=b+1,h=R[W-y],D[b]=T>0?De(g/R[m-T]%R[T])*h:0),A)for(;;)if(b==0){for(y=1,T=D[0];T>=10;T/=10,y++);for(T=D[0]+=h,h=1;T>=10;T/=10,h++);y!=h&&(i.e++,D[0]==Ue&&(D[0]=1));break}else{if(D[b]+=h,D[b]!=Ue)break;D[b--]=0,h=1}for(y=D.length;D[--y]===0;D.pop());}i.e>C?i.c=i.e=null:i.e<w&&(i.c=[i.e=0])}return i}function oe(i){var c,u=i.e;return u===null?i.toString():(c=Ie(i.c),c=u<=p||u>=f?fn(c,u):ze(c,u,"0"),i.s<0?"-"+c:c)}return s.absoluteValue=s.abs=function(){var i=new P(this);return i.s<0&&(i.s=1),i},s.comparedTo=function(i,c){return mt(this,new P(i,c))},s.decimalPlaces=s.dp=function(i,c){var u,A,m,y=this;if(i!=null)return ne(i,0,le),c==null?c=d:ne(c,0,8),Y(new P(y),i+y.e+1,c);if(!(u=y.c))return null;if(A=((m=u.length-1)-Oe(this.e/W))*W,m=u[m])for(;m%10==0;m/=10,A--);return A<0&&(A=0),A},s.dividedBy=s.div=function(i,c){return t(this,new P(i,c),o,d)},s.dividedToIntegerBy=s.idiv=function(i,c){return t(this,new P(i,c),0,1)},s.exponentiatedBy=s.pow=function(i,c){var u,A,m,y,T,h,g,b,E,D=this;if(i=new P(i),i.c&&!i.isInteger())throw Error(ve+"Exponent not an integer: "+oe(i));if(c!=null&&(c=new P(c)),h=i.e>14,!D.c||!D.c[0]||D.c[0]==1&&!D.e&&D.c.length==1||!i.c||!i.c[0])return E=new P(Math.pow(+oe(D),h?i.s*(2-pn(i)):+oe(i))),c?E.mod(c):E;if(g=i.s<0,c){if(c.c?!c.c[0]:!c.s)return new P(NaN);A=!g&&D.isInteger()&&c.isInteger(),A&&(D=D.mod(c))}else{if(i.e>9&&(D.e>0||D.e<-1||(D.e==0?D.c[0]>1||h&&D.c[1]>=24e7:D.c[0]<8e13||h&&D.c[0]<=9999975e7)))return y=D.s<0&&pn(i)?-0:0,D.e>-1&&(y=1/y),new P(g?1/y:y);O&&(y=Bn(O/W+2))}for(h?(u=new P(.5),g&&(i.s=1),b=pn(i)):(m=Math.abs(+oe(i)),b=m%2),E=new P(a);;){if(b){if(E=E.times(D),!E.c)break;y?E.c.length>y&&(E.c.length=y):A&&(E=E.mod(c))}if(m){if(m=De(m/2),m===0)break;b=m%2}else if(i=i.times(u),Y(i,i.e+1,1),i.e>14)b=pn(i);else{if(m=+oe(i),m===0)break;b=m%2}D=D.times(D),y?D.c&&D.c.length>y&&(D.c.length=y):A&&(D=D.mod(c))}return A?E:(g&&(E=a.div(E)),c?E.mod(c):y?Y(E,O,d,T):E)},s.integerValue=function(i){var c=new P(this);return i==null?i=d:ne(i,0,8),Y(c,c.e+1,i)},s.isEqualTo=s.eq=function(i,c){return mt(this,new P(i,c))===0},s.isFinite=function(){return!!this.c},s.isGreaterThan=s.gt=function(i,c){return mt(this,new P(i,c))>0},s.isGreaterThanOrEqualTo=s.gte=function(i,c){return(c=mt(this,new P(i,c)))===1||c===0},s.isInteger=function(){return!!this.c&&Oe(this.e/W)>this.c.length-2},s.isLessThan=s.lt=function(i,c){return mt(this,new P(i,c))<0},s.isLessThanOrEqualTo=s.lte=function(i,c){return(c=mt(this,new P(i,c)))===-1||c===0},s.isNaN=function(){return!this.s},s.isNegative=function(){return this.s<0},s.isPositive=function(){return this.s>0},s.isZero=function(){return!!this.c&&this.c[0]==0},s.minus=function(i,c){var u,A,m,y,T=this,h=T.s;if(i=new P(i,c),c=i.s,!h||!c)return new P(NaN);if(h!=c)return i.s=-c,T.plus(i);var g=T.e/W,b=i.e/W,E=T.c,D=i.c;if(!g||!b){if(!E||!D)return E?(i.s=-c,i):new P(D?T:NaN);if(!E[0]||!D[0])return D[0]?(i.s=-c,i):new P(E[0]?T:d==3?-0:0)}if(g=Oe(g),b=Oe(b),E=E.slice(),h=g-b){for((y=h<0)?(h=-h,m=E):(b=g,m=D),m.reverse(),c=h;c--;m.push(0));m.reverse()}else for(A=(y=(h=E.length)<(c=D.length))?h:c,h=c=0;c<A;c++)if(E[c]!=D[c]){y=E[c]<D[c];break}if(y&&(m=E,E=D,D=m,i.s=-i.s),c=(A=D.length)-(u=E.length),c>0)for(;c--;E[u++]=0);for(c=Ue-1;A>h;){if(E[--A]<D[A]){for(u=A;u&&!E[--u];E[u]=c);--E[u],E[A]+=Ue}E[A]-=D[A]}for(;E[0]==0;E.splice(0,1),--b);return E[0]?Z(i,E,b):(i.s=d==3?-1:1,i.c=[i.e=0],i)},s.modulo=s.mod=function(i,c){var u,A,m=this;return i=new P(i,c),!m.c||!i.s||i.c&&!i.c[0]?new P(NaN):!i.c||m.c&&!m.c[0]?new P(m):(F==9?(A=i.s,i.s=1,u=t(m,i,0,3),i.s=A,u.s*=A):u=t(m,i,0,F),i=m.minus(u.times(i)),!i.c[0]&&F==1&&(i.s=m.s),i)},s.multipliedBy=s.times=function(i,c){var u,A,m,y,T,h,g,b,E,D,R,L,G,ae,de,J=this,te=J.c,ge=(i=new P(i,c)).c;if(!te||!ge||!te[0]||!ge[0])return!J.s||!i.s||te&&!te[0]&&!ge||ge&&!ge[0]&&!te?i.c=i.e=i.s=null:(i.s*=J.s,!te||!ge?i.c=i.e=null:(i.c=[0],i.e=0)),i;for(A=Oe(J.e/W)+Oe(i.e/W),i.s*=J.s,g=te.length,D=ge.length,g<D&&(G=te,te=ge,ge=G,m=g,g=D,D=m),m=g+D,G=[];m--;G.push(0));for(ae=Ue,de=et,m=D;--m>=0;){for(u=0,R=ge[m]%de,L=ge[m]/de|0,T=g,y=m+T;y>m;)b=te[--T]%de,E=te[T]/de|0,h=L*b+E*R,b=R*b+h%de*de+G[y]+u,u=(b/ae|0)+(h/de|0)+L*E,G[y--]=b%ae;G[y]=u}return u?++A:G.splice(0,1),Z(i,G,A)},s.negated=function(){var i=new P(this);return i.s=-i.s||null,i},s.plus=function(i,c){var u,A=this,m=A.s;if(i=new P(i,c),c=i.s,!m||!c)return new P(NaN);if(m!=c)return i.s=-c,A.minus(i);var y=A.e/W,T=i.e/W,h=A.c,g=i.c;if(!y||!T){if(!h||!g)return new P(m/0);if(!h[0]||!g[0])return g[0]?i:new P(h[0]?A:m*0)}if(y=Oe(y),T=Oe(T),h=h.slice(),m=y-T){for(m>0?(T=y,u=g):(m=-m,u=h),u.reverse();m--;u.push(0));u.reverse()}for(m=h.length,c=g.length,m-c<0&&(u=g,g=h,h=u,c=m),m=0;c;)m=(h[--c]=h[c]+g[c]+m)/Ue|0,h[c]=Ue===h[c]?0:h[c]%Ue;return m&&(h=[m].concat(h),++T),Z(i,h,T)},s.precision=s.sd=function(i,c){var u,A,m,y=this;if(i!=null&&i!==!!i)return ne(i,1,le),c==null?c=d:ne(c,0,8),Y(new P(y),i,c);if(!(u=y.c))return null;if(m=u.length-1,A=m*W+1,m=u[m]){for(;m%10==0;m/=10,A--);for(m=u[0];m>=10;m/=10,A++);}return i&&y.e+1>A&&(A=y.e+1),A},s.shiftedBy=function(i){return ne(i,-_n,_n),this.times("1e"+i)},s.squareRoot=s.sqrt=function(){var i,c,u,A,m,y=this,T=y.c,h=y.s,g=y.e,b=o+4,E=new P("0.5");if(h!==1||!T||!T[0])return new P(!h||h<0&&(!T||T[0])?NaN:T?y:1/0);if(h=Math.sqrt(+oe(y)),h==0||h==1/0?(c=Ie(T),(c.length+g)%2==0&&(c+="0"),h=Math.sqrt(+c),g=Oe((g+1)/2)-(g<0||g%2),h==1/0?c="5e"+g:(c=h.toExponential(),c=c.slice(0,c.indexOf("e")+1)+g),u=new P(c)):u=new P(h+""),u.c[0]){for(g=u.e,h=g+b,h<3&&(h=0);;)if(m=u,u=E.times(m.plus(t(y,m,b,1))),Ie(m.c).slice(0,h)===(c=Ie(u.c)).slice(0,h))if(u.e<g&&--h,c=c.slice(h-3,h+1),c=="9999"||!A&&c=="4999"){if(!A&&(Y(m,m.e+o+2,0),m.times(m).eq(y))){u=m;break}b+=4,h+=4,A=1}else{(!+c||!+c.slice(1)&&c.charAt(0)=="5")&&(Y(u,u.e+o+2,1),i=!u.times(u).eq(y));break}}return Y(u,u.e+o+1,d,i)},s.toExponential=function(i,c){return i!=null&&(ne(i,0,le),i++),K(this,i,c,1)},s.toFixed=function(i,c){return i!=null&&(ne(i,0,le),i=i+this.e+1),K(this,i,c)},s.toFormat=function(i,c,u){var A,m=this;if(u==null)i!=null&&c&&typeof c=="object"?(u=c,c=null):i&&typeof i=="object"?(u=i,i=c=null):u=I;else if(typeof u!="object")throw Error(ve+"Argument not an object: "+u);if(A=m.toFixed(i,c),m.c){var y,T=A.split("."),h=+u.groupSize,g=+u.secondaryGroupSize,b=u.groupSeparator||"",E=T[0],D=T[1],R=m.s<0,L=R?E.slice(1):E,G=L.length;if(g&&(y=h,h=g,g=y,G-=y),h>0&&G>0){for(y=G%h||h,E=L.substr(0,y);y<G;y+=h)E+=b+L.substr(y,h);g>0&&(E+=b+L.slice(y)),R&&(E="-"+E)}A=D?E+(u.decimalSeparator||"")+((g=+u.fractionGroupSize)?D.replace(new RegExp("\\d{"+g+"}\\B","g"),"$&"+(u.fractionGroupSeparator||"")):D):E}return(u.prefix||"")+A+(u.suffix||"")},s.toFraction=function(i){var c,u,A,m,y,T,h,g,b,E,D,R,L=this,G=L.c;if(i!=null&&(h=new P(i),!h.isInteger()&&(h.c||h.s!==1)||h.lt(a)))throw Error(ve+"Argument "+(h.isInteger()?"out of range: ":"not an integer: ")+oe(h));if(!G)return new P(L);for(c=new P(a),b=u=new P(a),A=g=new P(a),R=Ie(G),y=c.e=R.length-L.e-1,c.c[0]=Un[(T=y%W)<0?W+T:T],i=!i||h.comparedTo(c)>0?y>0?c:b:h,T=C,C=1/0,h=new P(R),g.c[0]=0;E=t(h,c,0,1),m=u.plus(E.times(A)),m.comparedTo(i)!=1;)u=A,A=m,b=g.plus(E.times(m=b)),g=m,c=h.minus(E.times(m=c)),h=m;return m=t(i.minus(u),A,0,1),g=g.plus(m.times(b)),u=u.plus(m.times(A)),g.s=b.s=L.s,y=y*2,D=t(b,A,y,d).minus(L).abs().comparedTo(t(g,u,y,d).minus(L).abs())<1?[b,A]:[g,u],C=T,D},s.toNumber=function(){return+oe(this)},s.toPrecision=function(i,c){return i!=null&&ne(i,1,le),K(this,i,c,2)},s.toString=function(i){var c,u=this,A=u.s,m=u.e;return m===null?A?(c="Infinity",A<0&&(c="-"+c)):c="NaN":(i==null?c=m<=p||m>=f?fn(Ie(u.c),m):ze(Ie(u.c),m,"0"):i===10&&_?(u=Y(new P(u),o+m+1,d),c=ze(Ie(u.c),u.e,"0")):(ne(i,2,M.length,"Base"),c=n(ze(Ie(u.c),m,"0"),10,i,A,!0)),A<0&&u.c[0]&&(c="-"+c)),c},s.valueOf=s.toJSON=function(){return oe(this)},s._isBigNumber=!0,s[Symbol.toStringTag]="BigNumber",s[Symbol.for("nodejs.util.inspect.custom")]=s.valueOf,e!=null&&P.set(e),P}function Oe(e){var t=e|0;return e>0||e===t?t:t-1}function Ie(e){for(var t,n,r=1,s=e.length,a=e[0]+"";r<s;){for(t=e[r++]+"",n=W-t.length;n--;t="0"+t);a+=t}for(s=a.length;a.charCodeAt(--s)===48;);return a.slice(0,s+1||1)}function mt(e,t){var n,r,s=e.c,a=t.c,o=e.s,d=t.s,p=e.e,f=t.e;if(!o||!d)return null;if(n=s&&!s[0],r=a&&!a[0],n||r)return n?r?0:-d:o;if(o!=d)return o;if(n=o<0,r=p==f,!s||!a)return r?0:!s^n?1:-1;if(!r)return p>f^n?1:-1;for(d=(p=s.length)<(f=a.length)?p:f,o=0;o<d;o++)if(s[o]!=a[o])return s[o]>a[o]^n?1:-1;return p==f?0:p>f^n?1:-1}function ne(e,t,n,r){if(e<t||e>n||e!==De(e))throw Error(ve+(r||"Argument")+(typeof e=="number"?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function pn(e){var t=e.c.length-1;return Oe(e.e/W)==t&&e.c[t]%2!=0}function fn(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function ze(e,t,n){var r,s;if(t<0){for(s=n+".";++t;s+=n);e=s+e}else if(r=e.length,++t>r){for(s=n,t-=r;--t;s+=n);e+=s}else t<r&&(e=e.slice(0,t)+"."+e.slice(t));return e}var x=Dr();function ua(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}const da={1:{adapter:{"odos-v2":"0x1ae80D14C52F82c09a54C423e6f9D5Fb737089C8",sushi:"0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c"},dex:{sushiswap:{type:"default",solver:"sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"},agent:{type:"default",solver:"odos-v2",router:"0xCf5540fFFCdC3d510B18bFcA6d2b9987b0772559",adapter:"0xC1bB4d5071Fe7109ae2D67AE05826A3fe9116cfc",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"}}},10:{adapter:{"odos-v2":"0xc7Ec90152fd5A6210570cb04C4Ab099Bdac352af"},dex:{agent:{type:"default",solver:"odos-v2",router:"0xCa423977156BB05b13A2BA3b76Bc5419E2fE9680",adapter:"0xC5Aea83Fdd94A19fB2ce0B7207939C52825D3D3B",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"}}},14:{adapter:{spark:"0x00c7617C471Ef69124464CEc318a3b8CC90aE9A7"},dex:{spark:{type:"default",solver:"spark",router:"0x0f3D8a38D4c74afBebc2c42695642f0e3acb15D3",adapter:"0x00c7617C471Ef69124464CEc318a3b8CC90aE9A7",fee:"0xaeA8C3e1a129A77686E115b1a46D9aD8405F7D2b"}}},56:{adapter:{"odos-v2":"0x6c17cc2984A87BD8b002c6E3C08dBB8c8Eb89E48","pancakeswap-v2":"0xaf3532dca7b4a75cD06671614C093e9e8fb5b1F2"},dex:{thena:{type:"default",solver:"odos-v2",router:"0x89b8AA89FDd0507a99d334CBe3C808fAFC7d850E",adapter:"0x9E61dEabe996236814c28eC69ab2A7405cB6f03E",fee:"0x15eBc8b5b3877512FFF23650188694A9a8891FAc"},pancake:{type:"p2",solver:"pancakeswap-v2",router:"0xd9C500DfF816a1Da21A48A732d3498Bf09dc9AEB",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0x52Ed96B1AEd25818B6A284b063b055488E012b73",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},newera:{type:"default",solver:"odos-v2",router:"0x89b8AA89FDd0507a99d334CBe3C808fAFC7d850E",adapter:"0x6236a466CE5c368DC6686d69cAcf5561196B76ef",fee:"0x4E7454909eB6D539111D56b50d68897E933D2d11"},agent:{type:"default",solver:"odos-v2",router:"0x89b8AA89FDd0507a99d334CBe3C808fAFC7d850E",adapter:"0x67Feba015c968c76cCB2EEabf197b4578640BE2C",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"}}},137:{adapter:{"odos-v2":"0x5628D7383b42E14E83DA310de3e7E04E6b025418","paraswap-v5":"0x179C4b8e982b5F1365d36CC8d0c1CEB621B7198D"},dex:{quick:{type:"paraswap",solver:"paraswap-v5",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0x727e1CbA41Ff1ff11C32fa43DAb499b4317A1b65",fee:"0xd207DC6a6dA88f27c8DB78201F974161b1d84b1f"},teafi:{type:"paraswap",solver:"paraswap-v5",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0xF710D67C783D2C14671EC1c61B0683DCb996F5c3",fee:"0x04Ff96e2c4D62b5771795d307AD679a25b3D2D50"},agent:{type:"default",solver:"odos-v2",router:"0x4E3288c9ca110bCC82bf38F09A7b425c095d92Bf",adapter:"0x75A3d70Fa6d054d31C896b9Cf8AB06b1c1B829B8",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"}}},143:{adapter:{"openocean-v2":"0xc7f07C830e22FCA94bF52F38C6707F9D396c6172","kyber-v2":"0x6f4e5b8d7F6b037c62277992c39E7834D7C04596"},dex:{yowie:{type:"default",solver:"openocean-v2",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xCA84Ab5a5A5bf2cff6AC0C835eF049365D13c6cB",fee:"0x6AF3eE77A3A3257777F5649aFa611b4C7Fd975Ef"},pangolin:{type:"default",solver:"kyber-v2",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xf42106eBf985bF49b39eba0114F57FA05e7B52eD",fee:"0xde92da99D188Ceb54A11ec711EF52D808A6260B5"}}},146:{adapter:{"odos-v2":"0x0123695379045f9db515E6a77d8154959B94B599","magpie-v3":"0xa5AB087b39dAf175650EFB4F7B8E977C1585a662","openocean-v2":"0xc7f07C830e22FCA94bF52F38C6707F9D396c6172"},dex:{spooky:{type:"default",solver:"magpie-v3",router:"0xc325856e5585823aaC0D1Fd46c35c608D95E65A9",adapter:"0x56083Eb47d4d7d520F4d2b4a0DC98BE56bb98068",fee:"0x840Df4684B35BC68BcdA3F6707A3c82A0D662f8b"},swapx:{type:"default",solver:"openocean-v2",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xa7AE3ABf86C81cCEFEd6bE77045F2a32660c1B1c",fee:"0x6E03f7BC0f141894612AA017796096399623895F"},shadow:{type:"default",solver:"magpie-v3",router:"0xc325856e5585823aaC0D1Fd46c35c608D95E65A9",adapter:"0x1adEE94aBa11F19981130F77a1B2620b67e4409A",fee:"0xb9e3751fAF3187E1bC468E56a707a8A91754460e"},agent:{type:"default",solver:"openocean-v2",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xD87ee28806bc0060789C4789F123647f4Df25A6C",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"}}},1329:{adapter:{dragon:"0x1e84A9f30607959d2d8b1a04171ef7D9522Ef502","openocean-v2":"0xc7f07C830e22FCA94bF52F38C6707F9D396c6172"},dex:{dragon:{type:"default",solver:"dragon",router:"0x11DA6463D6Cb5a03411Dbf5ab6f6bc3997Ac7428",adapter:"0x1e84A9f30607959d2d8b1a04171ef7D9522Ef502",fee:"0x0dc1E0525202b32e89bA78ed55b1e5cEdB751334"},nami:{type:"default",solver:"openocean-v2",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xba56F9A7865d430c8293851D576b5728Ca711ff5",fee:"0xeB58450e23632003f013568703F54446070E2E80"}}},5e3:{adapter:{"odos-v2":"0x3a0fA0f95ea07026c5f84D8d3444Dd6E15AE1874"},dex:{agent:{type:"default",solver:"odos-v2",router:"0xD9F4e85489aDCD0bAF0Cd63b4231c6af58c26745",adapter:"0x9571D46B5A5AAb749E5aCd698D8F20814C7B23D3",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"}}},8453:{adapter:{"odos-v2":"0x1c947387AFC3435135e3da51ccEAB20eD5377DeA","pancakeswap-v2":"0x917b492557957f5dD3e69c04c8E1Ac3d6948c022","kyber-v2":"0x6f4e5b8d7F6b037c62277992c39E7834D7C04596",trebleswap:"0x6f4938535879c668A797F2a6e9B912c54f9D43Cf",sushi:"0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c"},dex:{pancake:{type:"p2",solver:"pancakeswap-v2",router:"0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},quick:{type:"default",solver:"kyber-v2",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0x0438644898F69bfF1018Cb01a81877D14d3e6493",fee:"0xd207DC6a6dA88f27c8DB78201F974161b1d84b1f"},trebleswap:{type:"default",solver:"trebleswap",router:"0x347539D82A14C0A3a89769f1024774A545a151ac",adapter:"0x6f4938535879c668A797F2a6e9B912c54f9D43Cf",fee:"0x15fc883d7DF4e681Ddb9E43e7B1D8c61d4fC162C"},sushiswap:{type:"default",solver:"sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"},agent:{type:"default",solver:"kyber-v2",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xc64d6E64A713EfbbCcB14413479c56461F9c0b77",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"}}},42161:{adapter:{"odos-v2":"0x419faf03F5661e0F0471eF9D7935f09534ffc50F","paraswap-v5":"0x179C4b8e982b5F1365d36CC8d0c1CEB621B7198D","pancakeswap-v2":"0x917b492557957f5dD3e69c04c8E1Ac3d6948c022",sushi:"0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c"},dex:{arbidex:{type:"default",solver:"odos-v2",router:"0xa669e7A0d4b3e4Fa48af2dE86BD4CD7126Be4e13",adapter:"0xaA66173674F4331e7e672899B3E6aB1190450898",fee:"0xa0c11852f8A44e32F9EC10AD25986A53842f72Ca"},ramses:{type:"paraswap",solver:"paraswap-v5",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0xf075352f43cd15bA51B0957A4465223EDf6b4Cd8",fee:"0xB5BaCB60ECDa0bEF809B2A26eC9B4B926835D7af"},omni:{type:"paraswap",solver:"paraswap-v5",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0x41c925E8E4fC65136BDf5322824E0D8c20c4824e",fee:"0xba5291526c30B097E9F1Fd1Be301E2ab6E0782aa"},chronos:{type:"default",solver:"odos-v2",router:"0x19cEeAd7105607Cd444F5ad10dd51356436095a1",adapter:"0x6a6b8975d1b131EFd0a9b536766EE7E5d4a16CF2",fee:"0x5729af83240EFecAa18eafaAE82961c2DD045Dbe"},pancake:{type:"p2",solver:"pancakeswap-v2",router:"0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},sushiswap:{type:"default",solver:"sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"},agent:{type:"paraswap",solver:"paraswap-v5",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0x6F1002141Fcb5d3A3aA8b12A49e6e7DCE5661ae9",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"}}},43114:{adapter:{"odos-v2":"0x533dA659Ef4C2C1d4c98420e1dbe9C68D8538f50","kyber-v2":"0x6f4e5b8d7F6b037c62277992c39E7834D7C04596"},dex:{blackhole:{type:"default",solver:"kyber-v2",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xccdF1D6ce95FeC0F842197470CE8969A678B0A04",fee:"0x7f8B62520D9B5DA0ED517cc36e8dcb2a356f1928"},pangolin:{type:"default",solver:"kyber-v2",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xf42106eBf985bF49b39eba0114F57FA05e7B52eD",fee:"0xde92da99D188Ceb54A11ec711EF52D808A6260B5"},agent:{type:"default",solver:"kyber-v2",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xc64d6E64A713EfbbCcB14413479c56461F9c0b77",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"}}},59144:{adapter:{"odos-v2":"0xA58A55AC39b47504A63993A91B78544158862e61","pancakeswap-v2":"0x917b492557957f5dD3e69c04c8E1Ac3d6948c022",openocean:"0xd2e68b1d1C5DBB2D6cC396c10C55017e01309C37"},dex:{pancake:{type:"p2",solver:"pancakeswap-v2",router:"0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},lynex:{type:"default",solver:"openocean",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xd8bC1FF79a642e8D7Fbd0711374F287202fBb3AA",fee:"0xcb36ed1B1BfAD8F7FC9651f52d21f04A68677423"},agent:{type:"default",solver:"odos-v2",router:"0x2d8879046f1559E53eb052E949e9544bCB72f414",adapter:"0x55E4da2cd634729064bEb294EC682Dc94f5c3f24",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"}}},80094:{adapter:{kodiak:"0xcB16237c88A859d46Ae850B97d7D1bdECF482C06"},dex:{kodiak:{type:"default",solver:"kodiak",router:"0x43Dac637c4383f91B4368041E7A8687da3806Cae",adapter:"0xcB16237c88A859d46Ae850B97d7D1bdECF482C06",fee:"0xBA47Ec15aFbCF6e7e9F52900632049530bB6bAe4"}}},747474:{adapter:{sushi:"0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c"},dex:{sushiswap:{type:"default",solver:"sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"}}},"*":{wm:"0x0005d5cE0dB57e5BE3b2b8b6FeB75f0ccd015000",repermit:"0x00002a9C4D9497df5Bd31768eC5d30eEf5405000",cosigner:"0x000ECFa392ecDEfEE6e2a5C095d39B7A32f1E000",reactor:"0x000000b33fE4fB9d999Dd684F79b110731c3d000",executor:"0x000642A0966d9bd49870D9519f76b5cf823f3000",refinery:"0x000E474c0D7084EAA35A501035E73269f4b009A5",salt:{wm:"0xc9b46eae42dfeba3222a0315bf682f33cd5cc9d60c9625642e88406f8415f152",repermit:"0x4871dc9008e605821ea9677b65ea2a60ffb774afb31e0dcaea2e192880096be7",cosigner:"0x1117fe6f4e25c9380d10b2b3314a1e9b33e5f65ba0e55e0c63d0640db0dd60a2",reactor:"0xec73677f3a465a9755d4c9eab9509b59a24613fdb8b78719682930373e9876f5",executor:"0x9abc67d936f79e493f1f14050c2f6adb87ec208ff7aaae2e7ae788a7cb4796d7",refinery:"0x9746de29f1dd31b2c8460d71e92a7aefa34911130e61f274f37776e598c48bec",agentAdapter:"0xf6d54cf6a0619f1fb8e1ded91d4c23e7bb9f498c56735fb0c7669423c766219f",agentFee:"0x151234279af18acc113f70463977058efa2e598b5bfc0c106c75fd638d344c0a"},dex:{agent:{type:"universal",adapter:"0x0002BeFB46587d460AcEA9B2792c4A4c67B9cADa",fee:"0x0006d9557Ac9Af4f31962896299ba4FaBDaB9fEE"}}}};var Rn,Or;function la(){if(Or)return Rn;Or=1;const e=da,t=s=>ua(`./out/${s}.sol/${s}.abi.json`),n=()=>({wm:t("WM"),repermit:t("RePermit"),reactor:t("OrderReactor"),executor:t("Executor"),refinery:t("Refinery"),settler:t("Settler"),adapter:t("DefaultDexAdapter")});function r(s,a){if(!s)return;const{dex:o,salt:d,...p}=e["*"]??{},f=e[s];if(!f)return;const{dex:w,salt:C,...v}=f,F={...p,...v},O=a==null?void 0:a.trim();if(!O)return F;const I=o==null?void 0:o[O],M=w==null?void 0:w[O];if(!(!I&&!M))return{...F,...I,...M}}return Rn={config:r,abis:n,raw:e},Rn}var Ir=la();const _t=(e,t)=>{if(!e||!t)return"";const n=x(10).pow(e||0);return x(t).times(n).idiv(n).div(n).toFixed()};x(0),x(1),x(10),x(1e18);function yt(e,t){return e==t||e.toLowerCase()==t.toLowerCase()}const Ut=e=>!!Gs.find(t=>yt(t,e||""));function pa(e){return[Pe.Years,Pe.Months,Pe.Weeks,Pe.Days,Pe.Hours,Pe.Minutes].find(n=>n<=e)||Pe.Minutes}const gt=e=>e?e.value*e.unit:0,fa=e=>!e||e==="NaN"?"0":x(e).decimalPlaces(0).toFixed(),At=e=>Object.values(ye).find(t=>t.id===e),ha=e=>{if(!e)return;const t=e.map(a=>Ae(a)),n=Object.entries(Xs).filter(([a])=>t.includes(a)).flatMap(([,a])=>a),r=e.map(a=>a.exchangeAddress),s=new Set([...r,...n].map(a=>a.toLowerCase()));return Array.from(s)},Ln=(e,t)=>e.version===1?(e.fillDelay||0)*1e3+Ta(t):(e.fillDelay||0)*1e3,hn=e=>typeof window>"u"?null:new URLSearchParams(window.location.search).get(e),kr=e=>_r().filter(t=>t.name===e).map(t=>t.chainId),Nn=(e="",t="",n=18,r=18)=>{if(!x(e||0).gt(0)||!x(t||0).gt(0))return"";const s=_t(n,e),a=_t(r,t);return x(a).div(s).toFixed()},Mr=(e,t,n)=>{if(e.type===V.TWAP_MARKET)return"";const r=_t(t,e.srcAmountPerTrade),s=_t(n,e.dstMinAmountPerTrade);return x(s).div(r).toFixed()},Br=(e,t,n)=>{if(e.type===V.TWAP_MARKET)return"";const r=_t(t,e.srcAmountPerTrade),s=_t(n,e.triggerPricePerTrade);return x(s).div(r).toFixed()},ma=(e,t,n)=>{if(!e||!t||!n)return;const r=x(e).times(t),s=x(10).pow(n);return r.div(s).toFixed(0)},ya=(e,t,n,r)=>{if(n||!r||!e||!t)return x(0).toString();const s=x(e).times(x(t)),a=x(10).pow(r),o=s.div(a);return x.max(1,o).integerValue(x.ROUND_FLOOR).toFixed(0)},ga=(e,t,n,r)=>{if(e===$.TWAP||e===$.LIMIT)return"0";if(!r||!t||!n)return;const s=x(t).times(x(n)),a=x(10).pow(r),o=s.div(a);return x.max(1,o).integerValue(x.ROUND_FLOOR).toFixed(0)||"0"},Aa=(e,t,n,r)=>{const s=gt(n)*2*t,a=hn(Yt.DURATION),o=pa(a?Number(a):s);return a?{unit:o,value:Number(x(Number(a)/o).toFixed(2))}:r||(e===$.LIMIT?{unit:Pe.Days,value:7}:e===$.STOP_LOSS||e===$.TAKE_PROFIT?{unit:Pe.Days,value:1}:{unit:o,value:Number(x(s/o).toFixed(2))})},Ea=(e,t,n)=>t!==$.TWAP?1:n!==void 0?n:Math.max(1,Math.ceil(e/2)),ba=(e,t,n)=>{if(!e||!t||!n)return 1;const s=x(t).times(e).div(n).integerValue(x.ROUND_FLOOR).toNumber();return Math.max(1,s)},Ca=(e,t)=>e+gt(t)+6e4,Ta=e=>e.bidDelaySeconds*1e3*2,wa=(e="",t=0)=>!e||!t?"0":x(e).div(t).integerValue(x.ROUND_FLOOR).toFixed(0),va=(e,t)=>({isError:!(e.unit===Mn.unit&&e.value===Mn.value)&&gt(e)*t>ln,value:Math.floor(ln/t)}),xa=(e="",t="",n)=>{if(n===$.STOP_LOSS)return{isError:x(t||0).gte(x(e||0)),value:e}},Sa=(e="",t="",n)=>{if(n===$.TAKE_PROFIT)return{isError:x(t||0).lte(x(e||0)),value:e}},Fa=(e="",t="",n=!1,r)=>{if(!n&&r===$.STOP_LOSS)return{isError:x(t||0).gte(x(e||0)),value:e}},Pa=(e="",t="",n=!1,r)=>{if(!n&&r===$.TAKE_PROFIT)return{isError:x(t||0).gte(x(e||0)),value:e}},Da=(e,t)=>e===$.STOP_LOSS||e===$.TAKE_PROFIT?{isError:gt(t)>5184e6,value:5184e6}:{isError:gt(t)>ln,value:ln},Oa=e=>({isError:gt(e)<Sr,value:Sr}),Ia=e=>({isError:gt(e)<In,value:In}),ka=(e,t,n)=>({isError:x(t||0).multipliedBy(e||0).isLessThan(n),value:n}),Ma=(e,t,n)=>({isError:n===$.TWAP&&x(e).isGreaterThan(t),value:t}),Ba=(e,t)=>{if(e===Ne.Pancake)switch(t){case 56:return z.PancakeSwap;case 42161:return z.PancakeSwapArbitrum;case 8453:return z.PancakeSwapBase;case 59144:return z.PancakeSwapLinea;default:return z.PancakeSwap}if(e===Ne.Sushiswap)switch(t){case 1:return z.SushiEth;case 42161:return z.SushiArb;case 8453:return z.SushiBase;case 747474:return z.SushiKatana;default:return z.SushiEth}if(e===Ne.Quick)switch(t){case 137:return z.QuickSwap;case 8453:return z.QuickSwapBase;default:return z.QuickSwap}if(e===Ne.Thena)switch(t){case 56:return z.Thena;default:return z.Thena}if(e===Ne.Spooky)switch(t){case 250:return z.SpookySwap;case 146:return z.SpookySwapSonic;default:return z.SpookySwap}if(e===Ne.Lynex)switch(t){case 59144:return z.Lynex;default:return z.Lynex}if(e===Ne.Swapx)switch(t){case 146:return z.SwapX;default:return z.SwapX}if(e===Ne.Blackhole)switch(t){case 43114:return z.BlackholeAvax;default:return z.BlackholeAvax}},qn=(e,t=0)=>{const{abi:n,...r}=Ir.config(t,e);if(!r.reactor)throw new Error(`Missing config for partner "${e}" on chain ${t}: reactor address not found`);return{...r,partner:e,twapConfig:Ba(e,t)}},_r=()=>{const e=Ir.raw;return Object.entries(e).filter(([t])=>t!=="*").flatMap(([t,n])=>{const r=n==null?void 0:n.dex;return!r||typeof r!="object"?[]:Object.entries(r).map(([s])=>({chainId:Number(t),name:s,config:qn(s,Number(t))}))}).sort((t,n)=>t.name.localeCompare(n.name))},Ur=e=>{const t=hn(Yt.MIN_CHUNK_SIZE_USD);return t?parseInt(t):e},_a=({marketPrice:e,typedInputAmount:t,srcUsd1Token:n,marketPriceLoading:r,triggerPriceError:s,limitPriceError:a,tradesError:o,fillDelayError:d,durationError:p,balanceError:f,minTradeSizeError:w})=>{if(!hn(Yt.IGNORE_ERRORS)&&!(x(e||0).isZero()||x(t||0).isZero()||x(n||"0").isZero()||r))return w||s||a||o||d||p||f},Ua=(e,t)=>{const n=Date.now().toString(),r=parseInt((e/1e3).toFixed(0)),s=fa(t/1e3),a=hn(Yt.FRESHNESS),o=a?parseInt(a):60;return{nonce:n,epoch:r,deadline:s,freshness:o}},Rr=({chainId:e,srcToken:t,dstToken:n,srcAmount:r,deadlineMillis:s,fillDelayMillis:a,slippage:o,account:d,srcAmountPerTrade:p,dstMinAmountPerTrade:f="0",triggerAmountPerTrade:w="0",config:C,module:v})=>{const{nonce:F,epoch:O,deadline:I,freshness:M}=Ua(a,s),_=Math.floor(Date.now()/1e3).toString(),P=f,K=v===$.STOP_LOSS?w:"0",U=v===$.TAKE_PROFIT?w:"0",Z={permitted:{token:t,amount:r},spender:C.reactor,nonce:F,deadline:I,witness:{reactor:C.reactor,executor:C.executor,exchange:{adapter:C.adapter,ref:C.fee,share:0,data:"0x"},swapper:d,nonce:F,start:_,deadline:I,chainid:e,exclusivity:0,epoch:O,slippage:o,freshness:M,input:{token:t,amount:p,maxAmount:r},output:{token:n,limit:x(P||0).toFixed(),triggerLower:x(K||0).toFixed(),triggerUpper:x(U||0).toFixed(),recipient:d}}};return{domain:{name:"RePermit",version:"1",chainId:e,verifyingContract:C.repermit},order:Z,types:Ys,primaryType:Zs}},Ra=`https://bi.orbs.network/putes/twap-ui-${.7}`;let Kn="unknown";function La(e){Kn=e}function Hn(){const e=Math.random().toString(36).substring(2,16),t=Math.random().toString(36).substring(2,16),n=Date.now().toString(36);return`id_${e+t+n}`}const Na=(e,t,n)=>{var r,s,a,o,d,p,f,w,C;return{spotVersion:Dn.version,partner:e.partner,adapter:e.adapter,cosigner:e.cosigner,executor:e.executor,fee:e.fee,reactor:e.reactor,refinery:e.refinery,repermit:e.repermit,router:e.router,type:e.type,wm:e.wm,chainName:((r=e.twapConfig)==null?void 0:r.chainName)||"",chainId:n||0,twapVersion:((s=e.twapConfig)==null?void 0:s.twapVersion)||0,twapAddress:((a=e.twapConfig)==null?void 0:a.twapAddress)||"",lensAddress:((o=e.twapConfig)==null?void 0:o.lensAddress)||"",bidDelaySeconds:((d=e.twapConfig)==null?void 0:d.bidDelaySeconds)||0,minChunkSizeUsd:t,name:((p=e.twapConfig)==null?void 0:p.name)||"",exchangeAddress:((f=e.twapConfig)==null?void 0:f.exchangeAddress)||"",exchangeType:((w=e.twapConfig)==null?void 0:w.exchangeType)||"",pathfinderKey:((C=e.twapConfig)==null?void 0:C.pathfinderKey)||""}},Lr=async e=>{try{await fetch(Ra,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)}).then()}catch(t){console.error("Failed to send BI",t)}};class qa{constructor(){Sn(this,"timeout");Sn(this,"config");Sn(this,"data",{_id:Hn()})}async updateAndSend(t={},n=!1,r){try{this.data={...this.data,...t},n?(await Lr(this.data),r==null||r()):(clearTimeout(this.timeout),this.timeout=setTimeout(()=>{Lr(this.data),r==null||r()},1e3))}catch(s){console.error("Failed to update and send BI",s)}}onCancelOrderRequest(t,n){this.updateAndSend({cancelOrderIdsV1:n===1?t:void 0,cancelOrderIdsV2:n===2?t:void 0,action:"cancel order",cancelOrderSuccess:!1,cancelOrderTxHash:void 0,actionError:void 0})}onCancelOrderSuccess(t){this.updateAndSend({cancelOrderTxHash:t,cancelOrderSuccess:!0})}onCancelOrderError(t){this.onTxError(t)}onWrapSuccess(t){this.updateAndSend({wrapTxHash:t})}onWrapRequest(){this.updateAndSend({action:"wrap"})}onWrapError(t){this.onTxError(t)}onApproveRequest(){this.updateAndSend({action:"approve"})}onApproveSuccess(t){this.updateAndSend({approvalTxHash:t})}onApproveError(t){this.onTxError(t)}onCrash(t){var n;this.updateAndSend({action:"crash",actionError:((n=t==null?void 0:t.message)==null?void 0:n.toLowerCase())||(t==null?void 0:t.toLowerCase())})}onTxError(t){var r;const n=((r=t==null?void 0:t.message)==null?void 0:r.toLowerCase())||(t==null?void 0:t.toLowerCase());this.updateAndSend({actionError:n})}onRequestOrder({account:t,chainId:n,module:r,srcToken:s,dstToken:a,fromTokenAmount:o,srcChunkAmount:d,minDstAmountOutPerTrade:p="",triggerPricePerTrade:f="",deadline:w,fillDelay:C,slippage:v,isMarketOrder:F,chunksAmount:O}){this.updateAndSend({toTokenAddress:a.address,toTokenSymbol:a.symbol,fromTokenAddress:s.address,fromTokenSymbol:s.symbol,fromTokenAmount:o,chunksAmount:O,srcChunkAmount:d,minDstAmountOutPerTrade:p,triggerPricePerTrade:f,deadline:w,fillDelay:C,slippage:v,chainId:n,walletAddress:t,module:r,orderType:F?"market":"limit",actionError:void 0})}onSignOrderRequest(t){this.updateAndSend({action:"sign order",order:t})}onSignOrderError(t){this.onTxError(t)}onSignOrderSuccess(t){this.updateAndSend({action:"sign order",signature:t})}init(t,n,r){var s;this.config=t,r!==((s=this.data)==null?void 0:s.chainId)&&(this.data={_id:Hn(),action:"module-import",uiVersion:Kn,...Na(t,n,r),origin:window.location.origin},this.updateAndSend(this.data))}onCreateOrderError(t){this.onTxError(t)}onCreateOrderRequest(){this.updateAndSend({action:"create order"})}async onCreateOrderSuccess(t){this.updateAndSend({orderHash:t,orderSuccess:!0},void 0,()=>{this.data={_id:Hn(),action:"reset",uiVersion:Kn,origin:this.data.origin,spotVersion:Dn.version,partner:this.data.partner,adapter:this.data.adapter,cosigner:this.data.cosigner,executor:this.data.executor,fee:this.data.fee,reactor:this.data.reactor,refinery:this.data.refinery,repermit:this.data.repermit,router:this.data.router,type:this.data.type,wm:this.data.wm,chainName:this.data.chainName||"",chainId:this.data.chainId||0,twapVersion:this.data.twapVersion||0,twapAddress:this.data.twapAddress||"",lensAddress:this.data.lensAddress||"",bidDelaySeconds:this.data.bidDelaySeconds||0,minChunkSizeUsd:this.data.minChunkSizeUsd||0,name:this.data.name||"",exchangeAddress:this.data.exchangeAddress||"",exchangeType:this.data.exchangeType||"",pathfinderKey:this.data.pathfinderKey||""}})}onLoad(){this.updateAndSend({action:"module-import",origin:window.location.origin})}}const pe=new qa,Ka=e=>{var d;const t=x(e.order.witness.output.limit||0).gt(1),n=e.order.witness.output.stop,r=e.order.witness.output.triggerUpper,s=x(n||0).eq(Fr)||x(r||0).gt(0),a=x(n||0).gt(0),o=((d=e.metadata.chunks)==null?void 0:d.length)||x(e.order.witness.input.maxAmount).div(x(e.order.witness.input.amount)).toNumber();return s?t?V.TAKE_PROFIT_LIMIT:V.TAKE_PROFIT_MARKET:a?t?V.STOP_LOSS_LIMIT:V.STOP_LOSS_MARKET:t?o>1&&t?V.TWAP_LIMIT:t?V.LIMIT:V.TWAP_MARKET:V.TWAP_MARKET},Ha=e=>{var s;const t=((s=e.metadata.chunks)==null?void 0:s.filter(a=>a.status==="success").length)||0,n=e.metadata.expectedChunks||0,r=x(t).dividedBy(n).toNumber();return r>=.99?100:r<=0?0:Number((r*100).toFixed(2))},Wa=(e,t)=>e.metadata.status==="completed"||t>=99?he.Completed:["pending","eligible"].includes(e.metadata.status)?he.Open:e.metadata.description.toLowerCase()==="cancelled by contract"?he.Cancelled:he.Expired,Qa=e=>{var n;return(((n=e.metadata.chunks)==null?void 0:n.filter(r=>r.status==="success"))||[]).map(r=>({inAmount:r.inAmount,outAmount:r.outAmount,timestamp:new Date(r.timestamp).getTime(),txHash:r.txHash}))},ja=(e,t)=>{var r;const n=e.length;return n>=t&&((r=e[n-1])==null?void 0:r.timestamp)||0},za=e=>x(e.metadata.displayOnlyInputTokenPriceUSD).dividedBy(1e18).toFixed(),Wn=e=>Number(e.order.witness.output.limit)===1?"":e.order.witness.output.limit,$a=e=>{const{triggerLower:t="0",triggerUpper:n="0"}=e.order.witness.output,r=Wn(e),s=e.metadata.expectedChunks||1,a=x(n||0).gt(0);return{dstMinAmountPerTrade:r,triggerPricePerTrade:a?n:t,dstMinAmountTotal:x(r).multipliedBy(s).toFixed()}},Va=e=>{const t=Wn(e),n=x(e.order.witness.output.stop||0).eq(Fr),r=e.metadata.expectedChunks||1;return{dstMinAmountPerTrade:n?"":t,triggerPricePerTrade:n?t:x(e.order.witness.output.stop||"").toFixed(),dstMinAmountTotal:n?"":x(t).multipliedBy(r).toFixed()}},Ga=e=>Number(On)>=2?$a(e):Va(e),Nr=e=>{const t=Ha(e),n=Wn(e),r=e.metadata.expectedChunks||1,s=Qa(e),a=Ka(e);return{id:e.hash,hash:e.hash,version:2,type:a,maker:e.order.witness.swapper,progress:t,srcAmountFilled:s.reduce((o,d)=>o.plus(d.inAmount),new x(0)).toFixed()||"",dstAmountFilled:s.reduce((o,d)=>o.plus(d.outAmount),new x(0)).toFixed()||"",fills:s,srcTokenAddress:e.order.witness.input.token,dstTokenAddress:e.order.witness.output.token,orderDollarValueIn:za(e),fillDelay:e.order.witness.epoch*1e3,deadline:Number(e.order.deadline)*1e3,createdAt:new Date(e.timestamp).getTime(),srcAmount:e.order.witness.input.maxAmount,srcAmountPerTrade:e.order.witness.input.amount,totalTradesAmount:r,isMarketPrice:x(n||0).lte(1),chainId:e.order.witness.chainid,filledOrderTimestamp:ja(s,r),status:Wa(e,t),repermitDigest:e.metadata.repermitDigest,isTriggerPrice:a===V.TAKE_PROFIT_MARKET||a===V.TAKE_PROFIT_LIMIT||a===V.STOP_LOSS_LIMIT||a===V.STOP_LOSS_MARKET,rawOrder:e,...Ga(e)}},Xa=async({chainId:e,signal:t,account:n,exchange:r,isDev:s=!1})=>{try{if(!n)return[];const a=r?`&exchange=${r}`:"",d=await(await fetch(`${xr(s)}/orders?swapper=${n}&chainId=${e}${a}`,{signal:t})).json();return!d||!Array.isArray(d.orders)?[]:(console.log(d.orders),d.orders.map(Nr))}catch{return[]}},qr=async(e,t,n=!1)=>{try{const r={signature:t,order:e,status:"pending"};pe.onCreateOrderRequest();const s=await fetch(`${xr(n)}/orders/new`,{method:"POST",body:JSON.stringify(r)}),a=await s.json().catch(()=>({}));if(!s.ok||!(a!=null&&a.success)){const d=(a==null?void 0:a.message)??s.statusText??"Request failed",p=(a==null?void 0:a.code)??s.status;throw new Error(`error:${d}, code:${p}`)}if(!a.signedOrder||typeof a.signedOrder!="object")throw new Error("Invalid API response: missing signedOrder");const o=Nr(a.signedOrder);return pe.onCreateOrderSuccess(o.id),o}catch(r){throw pe.onCreateOrderError(r),console.error(r),r}},$e=(e,t)=>e&&e.length?e.map(t||(n=>`${n}`)):void 0,Za=e=>{if(e)return Vs[e]},Qn=async({chainId:e,buildQuery:t,extractResults:n,signal:r,retries:s=1,limit:a=1e3,page:o})=>{const d=Za(e);if(!d)throw new ri;const p=async C=>{let v=0;for(;v<=s;)try{const F=await fetch(d,{method:"POST",body:JSON.stringify({query:C}),signal:r,headers:{"Content-Type":"application/json"}});if(!F.ok)throw new Error(`HTTP error: ${F.status}`);const O=await F.json();if(O.errors)throw new Error(O.errors[0].message);return n(O)}catch(F){if(v===s)throw F;await new Promise(O=>setTimeout(O,500*2**v)),v++}return[]};let f=0;const w=[];if(o!==void 0){const C=t(o,a);try{return await p(C)}catch{console.warn(`Page ${o} failed, retrying one final time...`);try{return await p(C)}catch{return[]}}}for(;;){const C=t(f,a);let v;try{v=await p(C)}catch{console.warn(`Page ${f} failed, retrying one final time...`);try{v=await p(C)}catch{return w}}if(w.push(...v),v.length<a)break;f++}return w},Kr=e=>e.map(t=>({inAmount:t.srcAmountIn,outAmount:t.dstAmountOut,timestamp:t.timestamp,txHash:t.transactionHash})),Hr=(e,t)=>{const n=x(e||0).gt(1);return!n&&t===1?V.TWAP_MARKET:t>1&&n?V.TWAP_LIMIT:n?V.LIMIT:V.TWAP_MARKET},Ya=(e,t,n,r)=>{var v;const s=Kr(n||[]),a=new x(e.ask_srcAmount||0).div(e.ask_srcBidAmount).integerValue(x.ROUND_FLOOR).toNumber(),d=(n==null?void 0:n.length)===a?(v=n==null?void 0:n[(n==null?void 0:n.length)-1])==null?void 0:v.timestamp:void 0,p=s.reduce((F,O)=>F.plus(O.inAmount),new x(0)).toFixed(),f=s.reduce((F,O)=>F.plus(O.outAmount),new x(0)).toFixed(),w=Wr(e.ask_srcAmount,p),C=Hr(e.ask_dstMinAmount,a);return{repermitDigest:"",version:1,isTriggerPrice:!1,id:e.Contract_id.toString(),hash:"",type:Hr(e.ask_dstMinAmount,a),srcTokenAddress:e.ask_srcToken,dstTokenAddress:e.ask_dstToken,exchangeAddress:e.exchange,twapAddress:e.twapAddress,maker:e.maker,progress:w,dstAmountFilled:f,srcAmountFilled:p,orderDollarValueIn:x(e.dollarValueIn||0).toFixed(6),srcAmount:e.ask_srcAmount,dstMinAmountTotal:x(e.ask_dstMinAmount).multipliedBy(a).toString(),fills:s,fillDelay:e.ask_fillDelay,deadline:e.ask_deadline*1e3,createdAt:new Date(e.timestamp).getTime(),dstMinAmountPerTrade:x(e.ask_dstMinAmount).eq(1)?"":e.ask_dstMinAmount,triggerPricePerTrade:"",srcAmountPerTrade:e.ask_srcBidAmount,txHash:e.transactionHash,totalTradesAmount:a,isMarketPrice:[V.TWAP_MARKET].includes(C),chainId:t,filledOrderTimestamp:d||0,status:r,rawOrder:e}},Ja=e=>{var C;if(!e)return"";const t=$e(e.accounts,v=>`"${v.toLowerCase()}"`),n=$e(ha(e.configs),v=>`"${v.toLowerCase()}"`),r=$e(e.inTokenSymbols,v=>`"${v.toUpperCase()}"`),s=$e(e.outTokenSymbols,v=>`"${v.toUpperCase()}"`),a=$e(e.inTokenAddresses,v=>`"${v.toLowerCase()}"`),o=$e(e.outTokenAddresses,v=>`"${v.toLowerCase()}"`),d=$e(e.transactionHashes,v=>`"${v.toLowerCase()}"`),p=$e(e.orderIds,v=>`"${v}"`),f=n!=null&&n.length?"":$e((C=e.configs)==null?void 0:C.map(v=>v.twapAddress),v=>`"${v.toLowerCase()}"`),w=e.minDollarValueIn;return[n?`exchange_in: [${n.join(", ")}]`:"",f?`twapAddress_in: [${f.join(", ")}]`:"",t?`maker_in: [${t.join(", ")}]`:"",d?`transactionHash_in: [${d.join(", ")}]`:"",p?`Contract_id_in: [${p.join(", ")}]`:"",w?`dollarValueIn_gte: ${w}`:"",r?`srcTokenSymbol_in: [${r.join(", ")}]`:"",s?`dstTokenSymbol_in: [${s.join(", ")}]`:"",a?`srcTokenAddress_in: [${a.join(", ")}]`:"",o?`dstTokenAddress_in: [${o.join(", ")}]`:"",e!=null&&e.startDate?`blockTimestamp_gte: ${e.startDate}`:"",e!=null&&e.endDate?`blockTimestamp_lte: ${e.endDate}`:"",(e==null?void 0:e.orderType)==="limit"?"ask_dstMinAmount_gt: 1":"",(e==null?void 0:e.orderType)==="market"?"ask_dstMinAmount_lte: 1":""].filter(Boolean).join(", ")};async function ei({chainId:e,signal:t,page:n,limit:r,filters:s}){const a=r||1e3,o=Ja(s);return await Qn({chainId:e,signal:t,limit:a,page:n,buildQuery:(p,f)=>`
2
2
  {
3
3
  orderCreateds(
4
4
  ${o?`where: { ${o} }`:""},
5
5
  first: ${f},
6
- skip: ${h*f},
6
+ skip: ${p*f},
7
7
  orderBy: timestamp,
8
8
  orderDirection: desc,
9
9
  ) {
@@ -32,21 +32,21 @@
32
32
  transactionHash
33
33
  }
34
34
  }
35
- `,extractResults:h=>{var f;return((f=h.data)==null?void 0:f.orderCreateds)||[]}})}const ta=async({chainId:e,orders:t,signal:r})=>{if(t.length===0)return[];const s=jr(t.map(d=>d.Contract_id.toString()));if(!s.length)return[];const i=`where: { twapId_in: [${s.map(d=>`"${d}"`).join(", ")}]}`;return await Qr({chainId:e,signal:r,limit:1e3,buildQuery:(d,h)=>`
35
+ `,extractResults:p=>{var f;return((f=p.data)==null?void 0:f.orderCreateds)||[]}})}const ti=async({chainId:e,orders:t,signal:n})=>{if(t.length===0)return[];const r=jn(t.map(d=>d.Contract_id.toString()));if(!r.length)return[];const a=`where: { twapId_in: [${r.map(d=>`"${d}"`).join(", ")}]}`;return await Qn({chainId:e,signal:n,limit:1e3,buildQuery:(d,p)=>`
36
36
  {
37
37
  statusNews(
38
- first: ${h},
39
- skip: ${d*h},
40
- ${i}
38
+ first: ${p},
39
+ skip: ${d*p},
40
+ ${a}
41
41
  ) {
42
42
  twapId
43
43
  twapAddress
44
44
  status
45
45
  }
46
46
  }
47
- `,extractResults:d=>{var h;return((h=d.data)==null?void 0:h.statusNews)||[]}})};function jr(e){return Array.from(new Set(e))}const ra=async({chainId:e,orders:t,signal:r})=>{const s=jr(t.map(E=>E.Contract_id)),n=jr(t.map(E=>E.twapAddress)).filter(Boolean);if(s.length===0)return[];const i=s.join(", "),o=n.map(E=>`"${E}"`).join(", "),d=n.length?`twapAddress_in: [${o}]`:"",f=`where: { ${[`TWAP_id_in: [${i}]`,d].filter(Boolean).join(", ")} }`;return await Qr({chainId:e,signal:r,limit:1e3,buildQuery:(E,x)=>`
47
+ `,extractResults:d=>{var p;return((p=d.data)==null?void 0:p.statusNews)||[]}})};function jn(e){return Array.from(new Set(e))}const ni=async({chainId:e,orders:t,signal:n})=>{const r=jn(t.map(C=>C.Contract_id)),s=jn(t.map(C=>C.twapAddress)).filter(Boolean);if(r.length===0)return[];const a=r.join(", "),o=s.map(C=>`"${C}"`).join(", "),d=s.length?`twapAddress_in: [${o}]`:"",f=`where: { ${[`TWAP_id_in: [${a}]`,d].filter(Boolean).join(", ")} }`;return await Qn({chainId:e,signal:n,limit:1e3,buildQuery:(C,v)=>`
48
48
  {
49
- orderFilleds(first: ${x}, orderBy: timestamp, skip: ${E*x}, ${f}) {
49
+ orderFilleds(first: ${v}, orderBy: timestamp, skip: ${C*v}, ${f}) {
50
50
  id
51
51
  dstAmountOut
52
52
  dstFee
@@ -61,4 +61,4 @@
61
61
  dollarValueOut
62
62
  }
63
63
  }
64
- `,extractResults:E=>{var x;return(((x=E.data)==null?void 0:x.orderFilleds)||[]).map(F=>({...F,timestamp:new Date(F.timestamp).getTime()}))}})};class sa extends Error{constructor(){super("No graph endpoint found"),this.name="NoGraphEndpointError"}}const na=async({chainId:e,signal:t,page:r,limit:s,filters:n})=>{try{const i=await ea({chainId:e,signal:t,page:r,limit:s,filters:n}),[o,d]=await Promise.all([ra({chainId:e,orders:i,signal:t}),ta({chainId:e,orders:i,signal:t})]),h=i.map(S=>{const E=o==null?void 0:o.filter(x=>x.TWAP_id===Number(S.Contract_id)&&gt(x.exchange,S.exchange)&&gt(x.twapAddress,S.twapAddress));return Yi(S,e,E,ia(S,E||[],d))}).sort((S,E)=>E.createdAt-S.createdAt),f=new Set;return h.filter(S=>f.has(S.id)?!1:(f.add(S.id),!0))}catch{return[]}},ia=(e,t,r)=>{var d;const s=(d=r==null?void 0:r.find(h=>h.twapId===e.Contract_id.toString()&&gt(h.twapAddress,e.twapAddress)))==null?void 0:d.status,i=Hs(t).reduce((h,f)=>h.plus(f.inAmount),new v(0)).toFixed(),o=Qs(e.ask_srcAmount,i);return aa(o,e.ask_deadline*1e3,s)},Qs=(e,t)=>{if(!t||!e)return 0;const r=v(t).dividedBy(e).toNumber();return r>=.99?100:r<=0?0:Number((r*100).toFixed(2))},aa=(e,t,r)=>e===100?me.Completed:r==="CANCELLED"?me.Cancelled:r==="COMPLETED"?me.Completed:t>Date.now()?me.Open:me.Expired,oa=async({signal:e,page:t,chainId:r,limit:s,config:n,account:i,isDev:o=!1})=>(await Promise.all([n?na({chainId:r,signal:e,page:t,limit:s,filters:{accounts:[i],configs:n.twapConfig?[n.twapConfig]:[]}}):Promise.resolve([]),Xi({chainId:r,signal:e,account:i,exchange:n==null?void 0:n.adapter,isDev:o})]).then(([f,S])=>[...f,...S])).sort((f,S)=>S.createdAt-f.createdAt),ca={version:"1.1.23"},js=e=>{let t;const r=new Set,s=(f,S)=>{const E=typeof f=="function"?f(t):f;if(!Object.is(E,t)){const x=t;t=S??(typeof E!="object"||E===null)?E:Object.assign({},t,E),r.forEach(F=>F(t,x))}},n=()=>t,d={setState:s,getState:n,getInitialState:()=>h,subscribe:f=>(r.add(f),()=>r.delete(f))},h=t=e(s,n,d);return d},ua=(e=>e?js(e):js),da=e=>e;function la(e,t=da){const r=P.useSyncExternalStore(e.subscribe,P.useCallback(()=>t(e.getState()),[e,t]),P.useCallback(()=>t(e.getInitialState()),[e,t]));return P.useDebugValue(r),r}const zs=e=>{const t=ua(e),r=s=>la(t,s);return Object.assign(r,t),r},ha=(e=>e?zs(e):zs),pr={},$s={currentTime:Date.now(),cancelOrders:{},swapExecutions:[pr],swapExecutionIndex:0},Q=ha((e,t)=>({state:$s,updateState:r=>e(s=>({state:{...s.state,...r}})),updateSwapExecutionAtIndex:(r,s)=>e(n=>{const i=[...n.state.swapExecutions];return i[r]={...i[r]??pr,...s},{state:{...n.state,swapExecutions:i}}}),resetSwapExecutionAtIndex:()=>e(r=>{const s=[...r.state.swapExecutions];return s[r.state.swapExecutionIndex]=pr,{state:{...r.state,swapExecutions:s}}}),resetState:()=>{const r=t().state;e({state:{...$s,currentTime:Date.now(),isMarketOrder:r.isMarketOrder,swapExecutions:[...r.swapExecutions,pr],swapExecutionIndex:r.swapExecutionIndex+1}})}}));var ve=(e=>(e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILED=3]="FAILED",e))(ve||{}),Jt=(e=>(e.TRIGGER_MARKET_PRICE="triggerMarketPriceDisclaimer",e.MARKET_PRICE="marketOrderDisclaimer",e.LIMIT_PRICE="limitOrderDisclaimer",e))(Jt||{}),tt=(e=>(e.WRAP="wrap",e.APPROVE="approve",e.CREATE="create",e))(tt||{});const Et=(e,t)=>!t||!e||v(e).isNaN()?"":v(e).multipliedBy(v(10).pow(t)).toFixed(0),Ee=(e,t)=>{try{return!t||!e||v(e).isNaN()?"":v(e).dividedBy(v(10).pow(t)).toFixed()}catch(r){return console.error(r),""}},fa=e=>{const t="An error occurred.";if(!e||!e.message)return t;try{return e.message.toLowerCase().includes("rejected")?"Transaction Rejected":t}catch{return t}},zr=e=>{var t,r,s,n;if(e!=null&&e.message)return((r=(t=e.message)==null?void 0:t.toLowerCase())==null?void 0:r.includes("rejected"))||((n=(s=e.message)==null?void 0:s.toLowerCase())==null?void 0:n.includes("denied"))},Vs=(e,t)=>{const r=yt(t);return r&&Ut(e.address)?r.wToken:e};function Gs(e){return e?e/864e5:0}function Xs(e){return e?e/6e4:0}const ma=(e,t)=>e?V.TWAP_MARKET:t===1?V.LIMIT:V.TWAP_LIMIT,$r=(e,t,r)=>{const s=yt(r);return Ut((e==null?void 0:e.address)||"")&&gt((t==null?void 0:t.address)||"",(s==null?void 0:s.wToken.address)||"")},Vr=(e,t,r)=>{const s=yt(r);return gt((e==null?void 0:e.address)||"",(s==null?void 0:s.wToken.address)||"")&&Ut((t==null?void 0:t.address)||"")},Rt=(e,t)=>{if(!t)return"";const r=yt(t);return`${r==null?void 0:r.explorer}/tx/${e}`},Gr=(e,t)=>P.useMemo(()=>Et(t,e),[e,t]),er=(e,t)=>P.useMemo(()=>Ee(t,e),[e,t]),gr=()=>{const{chainId:e}=q();return P.useMemo(()=>yt(e),[e])},pa=e=>{const t=gr();return P.useMemo(()=>{if(!(!e||!t))return Rt(e,t.id)},[e,t])},rt=(e,t)=>P.useMemo(()=>!e||!t||v(e||"0").isZero()||v(t||"0").isZero()?"":v(e||"0").times(t).toFixed(),[e,t]),ga=()=>{const{srcToken:e,dstToken:t,chainId:r}=q();return P.useMemo(()=>$r(e,t,r),[e,t,r])},Aa=()=>{const{srcToken:e,dstToken:t,chainId:r}=q();return P.useMemo(()=>Vr(e,t,r),[e,t,r])},ya=()=>{const e=ga(),t=Aa();return e||t},st=()=>{const{srcToken:e,typedInputAmount:t}=q();return{amount:Gr(e==null?void 0:e.decimals,t),amountUI:t,error:v(t||0).isZero()?"enterAmount":void 0}},Ea=(e,t)=>{const{module:r,srcUsd1Token:s,marketPrice:n,minChunkSizeUsd:i,typedInputAmount:o}=q();return P.useMemo(()=>{if(v(o||"0").isZero()||!n||v(s||"0").isZero())return;if(!e)return{type:pe.MIN_CHUNKS,value:1,args:{minChunks:"1"}};const{isError:d}=ki(e,t,r);if(d)return{type:pe.MAX_CHUNKS,value:t,args:{maxChunks:`${t}`}};const{isError:h,value:f}=Ii(o||"",s||"",i||0);if(h)return{type:pe.MIN_TRADE_SIZE,value:f,args:{minTradeSize:`${f}`}}},[e,t,r,o,s,i,n])},qe=()=>{const{srcToken:e,srcUsd1Token:t,module:r,minChunkSizeUsd:s}=q(),n=Q(I=>I.state.typedChunks),i=Q(I=>I.updateState),{amount:o,amountUI:d}=st(),h=P.useMemo(()=>Ei(d||"",t||"",s||0),[d,t,s]),f=P.useMemo(()=>yi(h,r,n),[h,n,r]),S=P.useCallback(I=>i({typedChunks:I}),[i]),E=P.useMemo(()=>Ci(o||"",f),[o,f]),x=er(e==null?void 0:e.decimals,E),F=P.useMemo(()=>t?v(x||"0").times(t||0).toString():"0",[x,t]);return{totalTrades:f,maxTrades:h,amountPerTradeUI:x,amountPerTrade:E,amountPerTradeUsd:F,onChange:S,error:Ea(f,h)}},ba=()=>{const{srcToken:e,dstToken:t}=q(),{onChange:r,totalTrades:s,amountPerTradeUsd:n,amountPerTradeUI:i,error:o,maxTrades:d,amountPerTrade:h}=qe();return{error:o,maxTrades:d,totalTrades:s,amountPerTradeUI:i,amountPerTrade:h,onChange:r,amountPerTradeUsd:n,fromToken:e,toToken:t}},wa=e=>{const{totalTrades:t}=qe(),{marketPrice:r,typedInputAmount:s}=q(),n=P.useMemo(()=>{const{isError:o,value:d}=Oi(e);if(!(!o||v(s||"0").isZero()||!r))return{type:pe.MIN_FILL_DELAY,value:d}},[e,s,r]),i=P.useMemo(()=>{const{isError:o,value:d}=Si(e,t);if(!(!o||v(s||"0").isZero()||!r))return{type:pe.MAX_FILL_DELAY,value:d}},[e,s,r,t]);return n||i},Lt=()=>{const{callbacks:e}=q(),t=Q(i=>i.state.typedFillDelay),r=Q(i=>i.updateState),s=P.useMemo(()=>t||Mr,[t]),n=wa(s);return{fillDelay:s,onChange:P.useCallback(i=>{var o;r({typedFillDelay:i}),(o=e==null?void 0:e.onFillDelayChange)==null||o.call(e,i)},[r,e]),error:n,milliseconds:s.unit*s.value}},Ca=()=>{const{onChange:e,fillDelay:t,error:r}=Lt(),s=P.useCallback(i=>e({unit:t.unit,value:Number(i)}),[e,t]),n=P.useCallback(i=>e({unit:i,value:t.value}),[e,t]);return{onInputChange:s,onUnitSelect:n,onChange:e,milliseconds:t.unit*t.value,fillDelay:t,error:r}},Sa=e=>{const{module:t,marketPrice:r}=q();return P.useMemo(()=>{const s=Ti(t,e),n=Di(e);if(r){if(s.isError)return{type:pe.MAX_ORDER_DURATION,value:s.value,args:{duration:`${Math.floor(Gs(s.value)).toFixed(0)} days`}};if(n.isError)return{type:pe.MIN_ORDER_DURATION,value:n.value,args:{duration:`${Math.floor(Xs(n.value)).toFixed(0)} minutes`}}}},[e,t,r])},Xr=()=>{const{module:e,callbacks:t}=q(),r=Q(h=>h.state.typedDuration),s=Q(h=>h.updateState),n=qe().totalTrades,i=Lt().fillDelay,o=P.useMemo(()=>Ai(e,n,i,r),[n,i,r,e]),d=Sa(o);return{duration:o,setDuration:P.useCallback(h=>{var f;s({typedDuration:h}),(f=t==null?void 0:t.onDurationChange)==null||f.call(t,h)},[s,t]),error:d}},xa=()=>{const{duration:e,setDuration:t,error:r}=Xr(),s=P.useCallback(i=>{t({unit:e.unit,value:Number(i)})},[t,e]),n=P.useCallback(i=>{t({unit:i,value:e.value})},[t,e]);return{duration:e,onChange:t,milliseconds:e.unit*e.value,onInputChange:s,onUnitSelect:n,error:r}},va=()=>{const{module:e}=q();return P.useMemo(()=>e===j.STOP_LOSS?si:ni,[e])},Zr=()=>{const{module:e}=q(),t=Q(r=>r.state.isMarketOrder);return P.useMemo(()=>e!==j.STOP_LOSS&&e!==j.TAKE_PROFIT||t?void 0:e===j.STOP_LOSS?ii:ai,[e,t])},Ar=()=>{const{srcToken:e,dstToken:t,marketPriceLoading:r}=q(),s=Q(f=>f.updateState),n=Q(f=>f.state.isInvertedTrade),i=Q(f=>f.state.typedTriggerPrice),o=Q(f=>f.state.typedLimitPrice),d=Q(f=>f.state.isMarketOrder);return{onInvert:P.useCallback(()=>{i!==void 0&&s({typedTriggerPrice:v(1).div(i).toFixed()}),o!==void 0&&s({typedLimitPrice:v(1).div(o).toFixed()}),s({isInvertedTrade:!n})},[s,n,i,o,r]),isInverted:n,fromToken:n?t:e,toToken:n?e:t,isMarketPrice:d}},Zs=({typedValue:e,tokenDecimals:t=18,initialPrice:r="0",percentage:s,setValue:n,setPercentage:i})=>{const{srcUsd1Token:o,dstUsd1Token:d}=q(),{isInverted:h}=Ar(),f=P.useMemo(()=>v((()=>{if(e!==void 0){const M=h?v(e).isZero()?v(0):v(1).div(e):v(e);return Et(M.toFixed(),t)}if(s!==void 0&&v(r||"0").gt(0)&&!v(r||"0").isNaN()){const M=v(r||"0"),B=v(s||0).div(100);return M.plus(M.multipliedBy(B)).decimalPlaces(0).toFixed()}return v(r).gt(0)?r:""})()).decimalPlaces(0).toFixed(),[e,s,t,r,h]),S=P.useCallback(O=>{n(O),i(null)},[n,i]),E=P.useCallback(O=>{n(void 0),i(O)},[n,i]),x=P.useMemo(()=>{if(!r||v(r).isZero())return"";if(s!=null)return s;if(f){const O=v(r),B=v(f).minus(O).div(O).multipliedBy(100).decimalPlaces(2).toString();return v(B||"0").isZero()?"":B}return""},[f,r,s]),F=P.useMemo(()=>{let O="";if(e!==void 0)O=e;else{const M=Ee(f,t);if(v(M||"0").isZero())return"";O=h?v(1).div(M).toFixed():M}return O},[e,t,f,h]),I=rt(h?o:d,F||"0");return{amount:v(f).isNaN()?"":f,amountUI:v(F).isNaN()?"":F,selectedPercentage:x,onChange:S,onPercentageChange:E,isInverted:h,usd:v(I).isNaN()?"":I,isTypedValue:e!==void 0}},Pa=(e="")=>{const{module:t,marketPrice:r,typedInputAmount:s}=q();return P.useMemo(()=>{if(v(s||"0").isZero()||!r||t!==j.STOP_LOSS&&t!==j.TAKE_PROFIT)return;const n=xi(r||"",e||"",t);if(n!=null&&n.isError)return{type:pe.STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE,value:n.value};const i=vi(r||"",e||"",t);if(i!=null&&i.isError)return{type:pe.TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE,value:i.value};if(!e||v(e||0).isZero())return{type:pe.EMPTY_TRIGGER_PRICE,value:e}},[r,e,t,s])},Fa=e=>{const{srcToken:t,dstToken:r,module:s,dstUsd1Token:n}=q(),i=qe().amountPerTrade,o=Q(f=>f.state.isMarketOrder),d=P.useMemo(()=>gi(s,i,e,(t==null?void 0:t.decimals)||0),[e,i,o,t==null?void 0:t.decimals,s]),h=er((r==null?void 0:r.decimals)||0,d);return{amount:d,amountUI:h,usd:rt(h,n)}},bt=()=>{const{dstToken:e,marketPrice:t,module:r,callbacks:s}=q(),n=Q(I=>I.updateState),i=va(),o=Q(I=>I.state.triggerPricePercent),d=o===void 0?i:o,h=r===j.STOP_LOSS||r===j.TAKE_PROFIT,f=Zs({typedValue:Q(I=>I.state.typedTriggerPrice),percentage:d,tokenDecimals:(e==null?void 0:e.decimals)||18,initialPrice:h?t:void 0,setValue:P.useCallback(I=>{var O;n({typedTriggerPrice:I}),(O=s==null?void 0:s.onTriggerPriceChange)==null||O.call(s,I||"")},[n,s]),setPercentage:P.useCallback(I=>{var O;n({triggerPricePercent:I}),(O=s==null?void 0:s.onTriggerPricePercentChange)==null||O.call(s,I||"")},[n,s])}),S=Pa(f.amount),{amount:E,amountUI:x,usd:F}=Fa(f.amount);return P.useMemo(()=>({...f,error:S,pricePerChunk:E,pricePerChunkUI:x,pricePerChunkUsd:F}),[f,S,E,x,F])},Ta=e=>{const{module:t,marketPrice:r,typedInputAmount:s}=q(),{amount:n}=bt(),i=Q(o=>o.state.isMarketOrder);return P.useMemo(()=>{if(v(s||"0").isZero()||!n||!r)return;const o=Pi(n,e,i,t),d=Fi(n,e,i,t);if(o!=null&&o.isError)return{type:pe.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,value:o.value};if(d!=null&&d.isError)return{type:pe.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,value:d.value};if(e&&v(e||0).isZero())return{type:pe.MISSING_LIMIT_PRICE,value:e||""}},[e,n,t,i,s,r])},yr=()=>{const{dstToken:e,marketPrice:t,callbacks:r}=q(),s=Q(f=>f.updateState),n=Zr(),i=Q(f=>f.state.limitPricePercent),o=i===void 0?n:i,d=Zs({typedValue:Q(f=>f.state.typedLimitPrice),percentage:o,tokenDecimals:(e==null?void 0:e.decimals)||18,initialPrice:t,setValue:P.useCallback(f=>{var S;s({typedLimitPrice:f}),(S=r==null?void 0:r.onLimitPriceChange)==null||S.call(r,f||"")},[s,r]),setPercentage:P.useCallback(f=>{var S;s({limitPricePercent:f}),(S=r==null?void 0:r.onLimitPricePercentChange)==null||S.call(r,f||"")},[s,r])}),h=Ta(d.amount);return P.useMemo(()=>({...d,error:h}),[d,h])},Da=()=>{const{module:e}=q(),t=Q(d=>d.updateState),r=Q(d=>d.state.isMarketOrder),s=Zr(),n=Q(d=>d.state.triggerPricePercent)||0,i=e===j.LIMIT,o=P.useCallback(()=>{!r&&e===j.STOP_LOSS&&t({limitPricePercent:s}),t({isMarketOrder:!r})},[t,n,e,r,s]);return{isLimitPrice:!r,toggleLimitPrice:o,hide:i}},Oa=()=>{const{module:e,marketPriceLoading:t,srcToken:r,dstToken:s}=q(),{amount:n,amountUI:i,onChange:o,onPercentageChange:d,usd:h,selectedPercentage:f,error:S,isTypedValue:E}=yr(),x=Q(K=>K.updateState),F=Zr(),{isLimitPrice:I,toggleLimitPrice:O}=Da(),{fromToken:M,toToken:B}=Ar(),T=P.useCallback(()=>{x({typedLimitPrice:void 0}),x({limitPricePercent:F})},[x,e,F]);return{price:n,priceUI:i,error:S,onInputChange:o,onPercentageChange:d,onReset:T,usd:h,srcToken:r,dstToken:s,invertedSrcToken:M,invertedDstToken:B,percentage:f,isLoading:t,isLimitPrice:I,toggleLimitPrice:O,isTypedValue:E}},Ia=()=>{const{marketPrice:e,marketPriceLoading:t,srcToken:r,dstToken:s}=q(),{amount:n,amountUI:i,onChange:o,onPercentageChange:d,usd:h,selectedPercentage:f,error:S,pricePerChunk:E,pricePerChunkUI:x,pricePerChunkUsd:F,isTypedValue:I}=bt(),O=Q(K=>K.updateState),{fromToken:M,toToken:B}=Ar(),T=P.useCallback(()=>{O({triggerPricePercent:void 0,typedTriggerPrice:void 0})},[O]);return{price:n,priceUI:i,amountPerChunk:E,amountPerChunkUI:x,amountPerChunkUsd:F,error:S,onInputChange:o,onPercentageChange:d,percentage:f,onReset:T,usd:h,srcToken:r,dstToken:s,invertedSrcToken:M,invertedDstToken:B,isLoading:t||!e,isTypedValue:I}},Ys=()=>{const{module:e,marketPrice:t}=q(),r=yr().amount,s=bt().amount,n=Q(i=>i.state.isMarketOrder);return e===j.LIMIT||!n?r||"":e===j.STOP_LOSS||e===j.TAKE_PROFIT?s||"":t||""},Er=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:r}=q(),s=Ys(),n=st().amount,i=P.useMemo(()=>mi(n||"",s,(e==null?void 0:e.decimals)||0),[n,s,e==null?void 0:e.decimals]),o=er(t==null?void 0:t.decimals,i);return{amount:i,amountUI:o,usd:rt(o,r)}},Yr=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:r}=q(),s=Ys(),n=qe().amountPerTrade,i=Q(h=>h.state.isMarketOrder),o=P.useMemo(()=>pi(n,s,!!i,(e==null?void 0:e.decimals)||0),[n,s,i,e==null?void 0:e.decimals]),d=er(t==null?void 0:t.decimals,o);return{amount:o,amountUI:d,usd:rt(d,r)}},ka=()=>{const{typedInputAmount:e,marketPriceLoading:t,dstToken:r}=q(),{amountUI:s,usd:n}=Er(),o=ya()?e:s,d=Gr(r==null?void 0:r.decimals,o);return{value:o,valueWei:d,isLoading:t,usd:n}},Ma=()=>{const e=Q(n=>n.state.isMarketOrder),{module:t}=q(),r=P.useMemo(()=>{if(e&&t===j.STOP_LOSS)return Jt.TRIGGER_MARKET_PRICE},[e,t]),s=P.useMemo(()=>{if(!(t!==j.LIMIT&&t!==j.TWAP))return e?Jt.MARKET_PRICE:Jt.LIMIT_PRICE},[e,t]);return r||s},_a=()=>{const{minChunkSizeUsd:e,typedInputAmount:t,srcUsd1Token:r}=q(),s=rt(t,r);return P.useMemo(()=>v(e).gt(v(s||"0"))?{type:pe.MIN_TRADE_SIZE_ERROR,value:e}:void 0,[e,s])};function Js(){const{marketPrice:e,marketPriceLoading:t,typedInputAmount:r,srcUsd1Token:s,srcBalance:n,chainId:i}=q(),{error:o}=bt(),{error:d}=yr(),{error:h}=qe(),{error:f}=Lt(),{error:S}=Xr(),E=_a(),x=st().amount,F=P.useMemo(()=>{if(n&&v(x).gt(n))return{type:pe.INSUFFICIENT_BALANCE,value:n||""}},[n,x,i]);return P.useMemo(()=>_i({marketPrice:e,typedInputAmount:r,srcUsd1Token:s,marketPriceLoading:t,triggerPriceError:o,limitPriceError:d,tradesError:h,fillDelayError:f,durationError:S,balanceError:F,minTradeSizeError:E}),[e,t,r,o,d,h,f,S,F,s,E])}var Nt=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Ba={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Ua=(On=class{constructor(){N(this,Ke,Ba);N(this,xt,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&l(this,xt)&&e!==l(this,Ke)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:l(this,Ke),provider:e}),_(this,Ke,e),process.env.NODE_ENV!=="production"&&_(this,xt,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&_(this,xt,!0),l(this,Ke).setTimeout(e,t)}clearTimeout(e){l(this,Ke).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&_(this,xt,!0),l(this,Ke).setInterval(e,t)}clearInterval(e){l(this,Ke).clearInterval(e)}},Ke=new WeakMap,xt=new WeakMap,On),wt=new Ua;function Ra(e){setTimeout(e,0)}var Ct=typeof window>"u"||"Deno"in globalThis;function be(){}function La(e,t){return typeof e=="function"?e(t):e}function Jr(e){return typeof e=="number"&&e>=0&&e!==1/0}function en(e,t){return Math.max(e+(t||0)-Date.now(),0)}function nt(e,t){return typeof e=="function"?e(t):e}function ke(e,t){return typeof e=="function"?e(t):e}function tn(e,t){const{type:r="all",exact:s,fetchStatus:n,predicate:i,queryKey:o,stale:d}=e;if(o){if(s){if(t.queryHash!==es(o,t.options))return!1}else if(!tr(t.queryKey,o))return!1}if(r!=="all"){const h=t.isActive();if(r==="active"&&!h||r==="inactive"&&h)return!1}return!(typeof d=="boolean"&&t.isStale()!==d||n&&n!==t.state.fetchStatus||i&&!i(t))}function rn(e,t){const{exact:r,status:s,predicate:n,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(r){if(St(t.options.mutationKey)!==St(i))return!1}else if(!tr(t.options.mutationKey,i))return!1}return!(s&&t.state.status!==s||n&&!n(t))}function es(e,t){return((t==null?void 0:t.queryKeyHashFn)||St)(e)}function St(e){return JSON.stringify(e,(t,r)=>rs(r)?Object.keys(r).sort().reduce((s,n)=>(s[n]=r[n],s),{}):r)}function tr(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>tr(e[r],t[r])):!1}var Na=Object.prototype.hasOwnProperty;function ts(e,t){if(e===t)return e;const r=sn(e)&&sn(t);if(!r&&!(rs(e)&&rs(t)))return t;const n=(r?e:Object.keys(e)).length,i=r?t:Object.keys(t),o=i.length,d=r?new Array(o):{};let h=0;for(let f=0;f<o;f++){const S=r?f:i[f],E=e[S],x=t[S];if(E===x){d[S]=E,(r?f<n:Na.call(e,S))&&h++;continue}if(E===null||x===null||typeof E!="object"||typeof x!="object"){d[S]=x;continue}const F=ts(E,x);d[S]=F,F===E&&h++}return n===o&&h===n?e:d}function br(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}function sn(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function rs(e){if(!nn(e))return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(!nn(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function nn(e){return Object.prototype.toString.call(e)==="[object Object]"}function qa(e){return new Promise(t=>{wt.setTimeout(t,e)})}function ss(e,t,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(e,t);if(r.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return ts(e,t)}catch(s){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${s}`),s}return ts(e,t)}return t}function Ka(e,t,r=0){const s=[...e,t];return r&&s.length>r?s.slice(1):s}function Ha(e,t,r=0){const s=[t,...e];return r&&s.length>r?s.slice(0,-1):s}var wr=Symbol();function an(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===wr&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===wr?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function on(e,t){return typeof e=="function"?e(...t):!!e}var Wa=(In=class extends Nt{constructor(){super();N(this,vt);N(this,at);N(this,qt);_(this,qt,t=>{if(!Ct&&window.addEventListener){const r=()=>t();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){l(this,at)||this.setEventListener(l(this,qt))}onUnsubscribe(){var t;this.hasListeners()||((t=l(this,at))==null||t.call(this),_(this,at,void 0))}setEventListener(t){var r;_(this,qt,t),(r=l(this,at))==null||r.call(this),_(this,at,t(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()}))}setFocused(t){l(this,vt)!==t&&(_(this,vt,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(r=>{r(t)})}isFocused(){var t;return typeof l(this,vt)=="boolean"?l(this,vt):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},vt=new WeakMap,at=new WeakMap,qt=new WeakMap,In),ns=new Wa;function is(){let e,t;const r=new Promise((n,i)=>{e=n,t=i});r.status="pending",r.catch(()=>{});function s(n){Object.assign(r,n),delete r.resolve,delete r.reject}return r.resolve=n=>{s({status:"fulfilled",value:n}),e(n)},r.reject=n=>{s({status:"rejected",reason:n}),t(n)},r}var Qa=Ra;function ja(){let e=[],t=0,r=d=>{d()},s=d=>{d()},n=Qa;const i=d=>{t?e.push(d):n(()=>{r(d)})},o=()=>{const d=e;e=[],d.length&&n(()=>{s(()=>{d.forEach(h=>{r(h)})})})};return{batch:d=>{let h;t++;try{h=d()}finally{t--,t||o()}return h},batchCalls:d=>(...h)=>{i(()=>{d(...h)})},schedule:i,setNotifyFunction:d=>{r=d},setBatchNotifyFunction:d=>{s=d},setScheduler:d=>{n=d}}}var ue=ja(),za=(kn=class extends Nt{constructor(){super();N(this,Kt,!0);N(this,ot);N(this,Ht);_(this,Ht,t=>{if(!Ct&&window.addEventListener){const r=()=>t(!0),s=()=>t(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",s)}}})}onSubscribe(){l(this,ot)||this.setEventListener(l(this,Ht))}onUnsubscribe(){var t;this.hasListeners()||((t=l(this,ot))==null||t.call(this),_(this,ot,void 0))}setEventListener(t){var r;_(this,Ht,t),(r=l(this,ot))==null||r.call(this),_(this,ot,t(this.setOnline.bind(this)))}setOnline(t){l(this,Kt)!==t&&(_(this,Kt,t),this.listeners.forEach(s=>{s(t)}))}isOnline(){return l(this,Kt)}},Kt=new WeakMap,ot=new WeakMap,Ht=new WeakMap,kn),Cr=new za;function $a(e){return Math.min(1e3*2**e,3e4)}function cn(e){return(e??"online")==="online"?Cr.isOnline():!0}var as=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function un(e){let t=!1,r=0,s;const n=is(),i=()=>n.status!=="pending",o=O=>{var M;if(!i()){const B=new as(O);x(B),(M=e.onCancel)==null||M.call(e,B)}},d=()=>{t=!0},h=()=>{t=!1},f=()=>ns.isFocused()&&(e.networkMode==="always"||Cr.isOnline())&&e.canRun(),S=()=>cn(e.networkMode)&&e.canRun(),E=O=>{i()||(s==null||s(),n.resolve(O))},x=O=>{i()||(s==null||s(),n.reject(O))},F=()=>new Promise(O=>{var M;s=B=>{(i()||f())&&O(B)},(M=e.onPause)==null||M.call(e)}).then(()=>{var O;s=void 0,i()||(O=e.onContinue)==null||O.call(e)}),I=()=>{if(i())return;let O;const M=r===0?e.initialPromise:void 0;try{O=M??e.fn()}catch(B){O=Promise.reject(B)}Promise.resolve(O).then(E).catch(B=>{var Y;if(i())return;const T=e.retry??(Ct?0:3),K=e.retryDelay??$a,U=typeof K=="function"?K(r,B):K,Z=T===!0||typeof T=="number"&&r<T||typeof T=="function"&&T(r,B);if(t||!Z){x(B);return}r++,(Y=e.onFail)==null||Y.call(e,r,B),qa(U).then(()=>f()?void 0:F()).then(()=>{t?x(B):I()})})};return{promise:n,status:()=>n.status,cancel:o,continue:()=>(s==null||s(),n),cancelRetry:d,continueRetry:h,canStart:S,start:()=>(S()?I():F().then(I),n)}}var dn=(Mn=class{constructor(){N(this,Pt)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Jr(this.gcTime)&&_(this,Pt,wt.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Ct?1/0:300*1e3))}clearGcTimeout(){l(this,Pt)&&(wt.clearTimeout(l(this,Pt)),_(this,Pt,void 0))}},Pt=new WeakMap,Mn),Va=(_n=class extends dn{constructor(t){super();N(this,Re);N(this,Ft);N(this,Wt);N(this,Me);N(this,Tt);N(this,fe);N(this,sr);N(this,Dt);_(this,Dt,!1),_(this,sr,t.defaultOptions),this.setOptions(t.options),this.observers=[],_(this,Tt,t.client),_(this,Me,l(this,Tt).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,_(this,Ft,fn(this.options)),this.state=t.state??l(this,Ft),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=l(this,fe))==null?void 0:t.promise}setOptions(t){if(this.options={...l(this,sr),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const r=fn(this.options);r.data!==void 0&&(this.setState(hn(r.data,r.dataUpdatedAt)),_(this,Ft,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&l(this,Me).remove(this)}setData(t,r){const s=ss(this.state.data,t,this.options);return z(this,Re,Je).call(this,{data:s,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),s}setState(t,r){z(this,Re,Je).call(this,{type:"setState",state:t,setStateOptions:r})}cancel(t){var s,n;const r=(s=l(this,fe))==null?void 0:s.promise;return(n=l(this,fe))==null||n.cancel(t),r?r.then(be).catch(be):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(l(this,Ft))}isActive(){return this.observers.some(t=>ke(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===wr||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>nt(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!en(this.state.dataUpdatedAt,t)}onFocus(){var r;const t=this.observers.find(s=>s.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(r=l(this,fe))==null||r.continue()}onOnline(){var r;const t=this.observers.find(s=>s.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(r=l(this,fe))==null||r.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),l(this,Me).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(r=>r!==t),this.observers.length||(l(this,fe)&&(l(this,Dt)?l(this,fe).cancel({revert:!0}):l(this,fe).cancelRetry()),this.scheduleGc()),l(this,Me).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||z(this,Re,Je).call(this,{type:"invalidate"})}async fetch(t,r){var h,f,S,E,x,F,I,O,M,B,T,K;if(this.state.fetchStatus!=="idle"&&((h=l(this,fe))==null?void 0:h.status())!=="rejected"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(l(this,fe))return l(this,fe).continueRetry(),l(this,fe).promise}if(t&&this.setOptions(t),!this.options.queryFn){const U=this.observers.find(Z=>Z.options.queryFn);U&&this.setOptions(U.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const s=new AbortController,n=U=>{Object.defineProperty(U,"signal",{enumerable:!0,get:()=>(_(this,Dt,!0),s.signal)})},i=()=>{const U=an(this.options,r),Y=(()=>{const oe={client:l(this,Tt),queryKey:this.queryKey,meta:this.meta};return n(oe),oe})();return _(this,Dt,!1),this.options.persister?this.options.persister(U,Y,this):U(Y)},d=(()=>{const U={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:l(this,Tt),state:this.state,fetchFn:i};return n(U),U})();(f=this.options.behavior)==null||f.onFetch(d,this),_(this,Wt,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((S=d.fetchOptions)==null?void 0:S.meta))&&z(this,Re,Je).call(this,{type:"fetch",meta:(E=d.fetchOptions)==null?void 0:E.meta}),_(this,fe,un({initialPromise:r==null?void 0:r.initialPromise,fn:d.fetchFn,onCancel:U=>{U instanceof as&&U.revert&&this.setState({...l(this,Wt),fetchStatus:"idle"}),s.abort()},onFail:(U,Z)=>{z(this,Re,Je).call(this,{type:"failed",failureCount:U,error:Z})},onPause:()=>{z(this,Re,Je).call(this,{type:"pause"})},onContinue:()=>{z(this,Re,Je).call(this,{type:"continue"})},retry:d.options.retry,retryDelay:d.options.retryDelay,networkMode:d.options.networkMode,canRun:()=>!0}));try{const U=await l(this,fe).start();if(U===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(U),(F=(x=l(this,Me).config).onSuccess)==null||F.call(x,U,this),(O=(I=l(this,Me).config).onSettled)==null||O.call(I,U,this.state.error,this),U}catch(U){if(U instanceof as){if(U.silent)return l(this,fe).promise;if(U.revert){if(this.state.data===void 0)throw U;return this.state.data}}throw z(this,Re,Je).call(this,{type:"error",error:U}),(B=(M=l(this,Me).config).onError)==null||B.call(M,U,this),(K=(T=l(this,Me).config).onSettled)==null||K.call(T,this.state.data,U,this),U}finally{this.scheduleGc()}}},Ft=new WeakMap,Wt=new WeakMap,Me=new WeakMap,Tt=new WeakMap,fe=new WeakMap,sr=new WeakMap,Dt=new WeakMap,Re=new WeakSet,Je=function(t){const r=s=>{switch(t.type){case"failed":return{...s,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,...ln(s.data,this.options),fetchMeta:t.meta??null};case"success":const n={...s,...hn(t.data,t.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return _(this,Wt,t.manual?n:void 0),n;case"error":const i=t.error;return{...s,error:i,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...t.state}}};this.state=r(this.state),ue.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),l(this,Me).notify({query:this,type:"updated",action:t})})},_n);function ln(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:cn(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function hn(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function fn(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,s=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var Ga=(Bn=class extends Nt{constructor(t,r){super();N(this,ee);N(this,Pe);N(this,X);N(this,nr);N(this,we);N(this,Ot);N(this,Qt);N(this,Ve);N(this,ct);N(this,ir);N(this,jt);N(this,zt);N(this,It);N(this,kt);N(this,ut);N(this,$t,new Set);this.options=r,_(this,Pe,t),_(this,ct,null),_(this,Ve,is()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(l(this,X).addObserver(this),mn(l(this,X),this.options)?z(this,ee,ur).call(this):this.updateResult(),z(this,ee,Es).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return os(l(this,X),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return os(l(this,X),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,z(this,ee,bs).call(this),z(this,ee,ws).call(this),l(this,X).removeObserver(this)}setOptions(t){const r=this.options,s=l(this,X);if(this.options=l(this,Pe).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ke(this.options.enabled,l(this,X))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");z(this,ee,Cs).call(this),l(this,X).setOptions(this.options),r._defaulted&&!br(this.options,r)&&l(this,Pe).getQueryCache().notify({type:"observerOptionsUpdated",query:l(this,X),observer:this});const n=this.hasListeners();n&&pn(l(this,X),s,this.options,r)&&z(this,ee,ur).call(this),this.updateResult(),n&&(l(this,X)!==s||ke(this.options.enabled,l(this,X))!==ke(r.enabled,l(this,X))||nt(this.options.staleTime,l(this,X))!==nt(r.staleTime,l(this,X)))&&z(this,ee,gs).call(this);const i=z(this,ee,As).call(this);n&&(l(this,X)!==s||ke(this.options.enabled,l(this,X))!==ke(r.enabled,l(this,X))||i!==l(this,ut))&&z(this,ee,ys).call(this,i)}getOptimisticResult(t){const r=l(this,Pe).getQueryCache().build(l(this,Pe),t),s=this.createResult(r,t);return Za(this,s)&&(_(this,we,s),_(this,Qt,this.options),_(this,Ot,l(this,X).state)),s}getCurrentResult(){return l(this,we)}trackResult(t,r){return new Proxy(t,{get:(s,n)=>(this.trackProp(n),r==null||r(n),n==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&l(this,Ve).status==="pending"&&l(this,Ve).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,n))})}trackProp(t){l(this,$t).add(t)}getCurrentQuery(){return l(this,X)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const r=l(this,Pe).defaultQueryOptions(t),s=l(this,Pe).getQueryCache().build(l(this,Pe),r);return s.fetch().then(()=>this.createResult(s,r))}fetch(t){return z(this,ee,ur).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),l(this,we)))}createResult(t,r){var c;const s=l(this,X),n=this.options,i=l(this,we),o=l(this,Ot),d=l(this,Qt),f=t!==s?t.state:l(this,nr),{state:S}=t;let E={...S},x=!1,F;if(r._optimisticResults){const u=this.hasListeners(),y=!u&&mn(t,r),p=u&&pn(t,s,r,n);(y||p)&&(E={...E,...ln(S.data,t.options)}),r._optimisticResults==="isRestoring"&&(E.fetchStatus="idle")}let{error:I,errorUpdatedAt:O,status:M}=E;F=E.data;let B=!1;if(r.placeholderData!==void 0&&F===void 0&&M==="pending"){let u;i!=null&&i.isPlaceholderData&&r.placeholderData===(d==null?void 0:d.placeholderData)?(u=i.data,B=!0):u=typeof r.placeholderData=="function"?r.placeholderData((c=l(this,zt))==null?void 0:c.state.data,l(this,zt)):r.placeholderData,u!==void 0&&(M="success",F=ss(i==null?void 0:i.data,u,r),x=!0)}if(r.select&&F!==void 0&&!B)if(i&&F===(o==null?void 0:o.data)&&r.select===l(this,ir))F=l(this,jt);else try{_(this,ir,r.select),F=r.select(F),F=ss(i==null?void 0:i.data,F,r),_(this,jt,F),_(this,ct,null)}catch(u){_(this,ct,u)}l(this,ct)&&(I=l(this,ct),F=l(this,jt),O=Date.now(),M="error");const T=E.fetchStatus==="fetching",K=M==="pending",U=M==="error",Z=K&&T,Y=F!==void 0,a={status:M,fetchStatus:E.fetchStatus,isPending:K,isSuccess:M==="success",isError:U,isInitialLoading:Z,isLoading:Z,data:F,dataUpdatedAt:E.dataUpdatedAt,error:I,errorUpdatedAt:O,failureCount:E.fetchFailureCount,failureReason:E.fetchFailureReason,errorUpdateCount:E.errorUpdateCount,isFetched:E.dataUpdateCount>0||E.errorUpdateCount>0,isFetchedAfterMount:E.dataUpdateCount>f.dataUpdateCount||E.errorUpdateCount>f.errorUpdateCount,isFetching:T,isRefetching:T&&!K,isLoadingError:U&&!Y,isPaused:E.fetchStatus==="paused",isPlaceholderData:x,isRefetchError:U&&Y,isStale:cs(t,r),refetch:this.refetch,promise:l(this,Ve),isEnabled:ke(r.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const u=g=>{a.status==="error"?g.reject(a.error):a.data!==void 0&&g.resolve(a.data)},y=()=>{const g=_(this,Ve,a.promise=is());u(g)},p=l(this,Ve);switch(p.status){case"pending":t.queryHash===s.queryHash&&u(p);break;case"fulfilled":(a.status==="error"||a.data!==p.value)&&y();break;case"rejected":(a.status!=="error"||a.error!==p.reason)&&y();break}}return a}updateResult(){const t=l(this,we),r=this.createResult(l(this,X),this.options);if(_(this,Ot,l(this,X).state),_(this,Qt,this.options),l(this,Ot).data!==void 0&&_(this,zt,l(this,X)),br(r,t))return;_(this,we,r);const s=()=>{if(!t)return!0;const{notifyOnChangeProps:n}=this.options,i=typeof n=="function"?n():n;if(i==="all"||!i&&!l(this,$t).size)return!0;const o=new Set(i??l(this,$t));return this.options.throwOnError&&o.add("error"),Object.keys(l(this,we)).some(d=>{const h=d;return l(this,we)[h]!==t[h]&&o.has(h)})};z(this,ee,Hn).call(this,{listeners:s()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&z(this,ee,Es).call(this)}},Pe=new WeakMap,X=new WeakMap,nr=new WeakMap,we=new WeakMap,Ot=new WeakMap,Qt=new WeakMap,Ve=new WeakMap,ct=new WeakMap,ir=new WeakMap,jt=new WeakMap,zt=new WeakMap,It=new WeakMap,kt=new WeakMap,ut=new WeakMap,$t=new WeakMap,ee=new WeakSet,ur=function(t){z(this,ee,Cs).call(this);let r=l(this,X).fetch(this.options,t);return t!=null&&t.throwOnError||(r=r.catch(be)),r},gs=function(){z(this,ee,bs).call(this);const t=nt(this.options.staleTime,l(this,X));if(Ct||l(this,we).isStale||!Jr(t))return;const s=en(l(this,we).dataUpdatedAt,t)+1;_(this,It,wt.setTimeout(()=>{l(this,we).isStale||this.updateResult()},s))},As=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(l(this,X)):this.options.refetchInterval)??!1},ys=function(t){z(this,ee,ws).call(this),_(this,ut,t),!(Ct||ke(this.options.enabled,l(this,X))===!1||!Jr(l(this,ut))||l(this,ut)===0)&&_(this,kt,wt.setInterval(()=>{(this.options.refetchIntervalInBackground||ns.isFocused())&&z(this,ee,ur).call(this)},l(this,ut)))},Es=function(){z(this,ee,gs).call(this),z(this,ee,ys).call(this,z(this,ee,As).call(this))},bs=function(){l(this,It)&&(wt.clearTimeout(l(this,It)),_(this,It,void 0))},ws=function(){l(this,kt)&&(wt.clearInterval(l(this,kt)),_(this,kt,void 0))},Cs=function(){const t=l(this,Pe).getQueryCache().build(l(this,Pe),this.options);if(t===l(this,X))return;const r=l(this,X);_(this,X,t),_(this,nr,t.state),this.hasListeners()&&(r==null||r.removeObserver(this),t.addObserver(this))},Hn=function(t){ue.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(l(this,we))}),l(this,Pe).getQueryCache().notify({query:l(this,X),type:"observerResultsUpdated"})})},Bn);function Xa(e,t){return ke(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function mn(e,t){return Xa(e,t)||e.state.data!==void 0&&os(e,t,t.refetchOnMount)}function os(e,t,r){if(ke(t.enabled,e)!==!1&&nt(t.staleTime,e)!=="static"){const s=typeof r=="function"?r(e):r;return s==="always"||s!==!1&&cs(e,t)}return!1}function pn(e,t,r,s){return(e!==t||ke(s.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&cs(e,r)}function cs(e,t){return ke(t.enabled,e)!==!1&&e.isStaleByTime(nt(t.staleTime,e))}function Za(e,t){return!br(e.getCurrentResult(),t)}function gn(e){return{onFetch:(t,r)=>{var S,E,x,F,I;const s=t.options,n=(x=(E=(S=t.fetchOptions)==null?void 0:S.meta)==null?void 0:E.fetchMore)==null?void 0:x.direction,i=((F=t.state.data)==null?void 0:F.pages)||[],o=((I=t.state.data)==null?void 0:I.pageParams)||[];let d={pages:[],pageParams:[]},h=0;const f=async()=>{let O=!1;const M=K=>{Object.defineProperty(K,"signal",{enumerable:!0,get:()=>(t.signal.aborted?O=!0:t.signal.addEventListener("abort",()=>{O=!0}),t.signal)})},B=an(t.options,t.fetchOptions),T=async(K,U,Z)=>{if(O)return Promise.reject();if(U==null&&K.pages.length)return Promise.resolve(K);const oe=(()=>{const y={client:t.client,queryKey:t.queryKey,pageParam:U,direction:Z?"backward":"forward",meta:t.options.meta};return M(y),y})(),a=await B(oe),{maxPages:c}=t.options,u=Z?Ha:Ka;return{pages:u(K.pages,a,c),pageParams:u(K.pageParams,U,c)}};if(n&&i.length){const K=n==="backward",U=K?Ya:An,Z={pages:i,pageParams:o},Y=U(s,Z);d=await T(Z,Y,K)}else{const K=e??i.length;do{const U=h===0?o[0]??s.initialPageParam:An(s,d);if(h>0&&U==null)break;d=await T(d,U),h++}while(h<K)}return d};t.options.persister?t.fetchFn=()=>{var O,M;return(M=(O=t.options).persister)==null?void 0:M.call(O,f,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r)}:t.fetchFn=f}}}function An(e,{pages:t,pageParams:r}){const s=t.length-1;return t.length>0?e.getNextPageParam(t[s],t,r[s],r):void 0}function Ya(e,{pages:t,pageParams:r}){var s;return t.length>0?(s=e.getPreviousPageParam)==null?void 0:s.call(e,t[0],t,r[0],r):void 0}var Ja=(Un=class extends dn{constructor(t){super();N(this,We);N(this,ar);N(this,He);N(this,Ce);N(this,Mt);_(this,ar,t.client),this.mutationId=t.mutationId,_(this,Ce,t.mutationCache),_(this,He,[]),this.state=t.state||yn(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){l(this,He).includes(t)||(l(this,He).push(t),this.clearGcTimeout(),l(this,Ce).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){_(this,He,l(this,He).filter(r=>r!==t)),this.scheduleGc(),l(this,Ce).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){l(this,He).length||(this.state.status==="pending"?this.scheduleGc():l(this,Ce).remove(this))}continue(){var t;return((t=l(this,Mt))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,d,h,f,S,E,x,F,I,O,M,B,T,K,U,Z,Y,oe,a,c;const r=()=>{z(this,We,mt).call(this,{type:"continue"})},s={client:l(this,ar),meta:this.options.meta,mutationKey:this.options.mutationKey};_(this,Mt,un({fn:()=>this.options.mutationFn?this.options.mutationFn(t,s):Promise.reject(new Error("No mutationFn found")),onFail:(u,y)=>{z(this,We,mt).call(this,{type:"failed",failureCount:u,error:y})},onPause:()=>{z(this,We,mt).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>l(this,Ce).canRun(this)}));const n=this.state.status==="pending",i=!l(this,Mt).canStart();try{if(n)r();else{z(this,We,mt).call(this,{type:"pending",variables:t,isPaused:i}),await((d=(o=l(this,Ce).config).onMutate)==null?void 0:d.call(o,t,this,s));const y=await((f=(h=this.options).onMutate)==null?void 0:f.call(h,t,s));y!==this.state.context&&z(this,We,mt).call(this,{type:"pending",context:y,variables:t,isPaused:i})}const u=await l(this,Mt).start();return await((E=(S=l(this,Ce).config).onSuccess)==null?void 0:E.call(S,u,t,this.state.context,this,s)),await((F=(x=this.options).onSuccess)==null?void 0:F.call(x,u,t,this.state.context,s)),await((O=(I=l(this,Ce).config).onSettled)==null?void 0:O.call(I,u,null,this.state.variables,this.state.context,this,s)),await((B=(M=this.options).onSettled)==null?void 0:B.call(M,u,null,t,this.state.context,s)),z(this,We,mt).call(this,{type:"success",data:u}),u}catch(u){try{throw await((K=(T=l(this,Ce).config).onError)==null?void 0:K.call(T,u,t,this.state.context,this,s)),await((Z=(U=this.options).onError)==null?void 0:Z.call(U,u,t,this.state.context,s)),await((oe=(Y=l(this,Ce).config).onSettled)==null?void 0:oe.call(Y,void 0,u,this.state.variables,this.state.context,this,s)),await((c=(a=this.options).onSettled)==null?void 0:c.call(a,void 0,u,t,this.state.context,s)),u}finally{z(this,We,mt).call(this,{type:"error",error:u})}}finally{l(this,Ce).runNext(this)}}},ar=new WeakMap,He=new WeakMap,Ce=new WeakMap,Mt=new WeakMap,We=new WeakSet,mt=function(t){const r=s=>{switch(t.type){case"failed":return{...s,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"pending":return{...s,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...s,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:t.error,failureCount:s.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=r(this.state),ue.batch(()=>{l(this,He).forEach(s=>{s.onMutationUpdate(t)}),l(this,Ce).notify({mutation:this,type:"updated",action:t})})},Un);function yn(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var eo=(Rn=class extends Nt{constructor(t={}){super();N(this,Ge);N(this,Le);N(this,or);this.config=t,_(this,Ge,new Set),_(this,Le,new Map),_(this,or,0)}build(t,r,s){const n=new Ja({client:t,mutationCache:this,mutationId:++Fr(this,or)._,options:t.defaultMutationOptions(r),state:s});return this.add(n),n}add(t){l(this,Ge).add(t);const r=Sr(t);if(typeof r=="string"){const s=l(this,Le).get(r);s?s.push(t):l(this,Le).set(r,[t])}this.notify({type:"added",mutation:t})}remove(t){if(l(this,Ge).delete(t)){const r=Sr(t);if(typeof r=="string"){const s=l(this,Le).get(r);if(s)if(s.length>1){const n=s.indexOf(t);n!==-1&&s.splice(n,1)}else s[0]===t&&l(this,Le).delete(r)}}this.notify({type:"removed",mutation:t})}canRun(t){const r=Sr(t);if(typeof r=="string"){const s=l(this,Le).get(r),n=s==null?void 0:s.find(i=>i.state.status==="pending");return!n||n===t}else return!0}runNext(t){var s;const r=Sr(t);if(typeof r=="string"){const n=(s=l(this,Le).get(r))==null?void 0:s.find(i=>i!==t&&i.state.isPaused);return(n==null?void 0:n.continue())??Promise.resolve()}else return Promise.resolve()}clear(){ue.batch(()=>{l(this,Ge).forEach(t=>{this.notify({type:"removed",mutation:t})}),l(this,Ge).clear(),l(this,Le).clear()})}getAll(){return Array.from(l(this,Ge))}find(t){const r={exact:!0,...t};return this.getAll().find(s=>rn(r,s))}findAll(t={}){return this.getAll().filter(r=>rn(t,r))}notify(t){ue.batch(()=>{this.listeners.forEach(r=>{r(t)})})}resumePausedMutations(){const t=this.getAll().filter(r=>r.state.isPaused);return ue.batch(()=>Promise.all(t.map(r=>r.continue().catch(be))))}},Ge=new WeakMap,Le=new WeakMap,or=new WeakMap,Rn);function Sr(e){var t;return(t=e.options.scope)==null?void 0:t.id}var to=(Ln=class extends Nt{constructor(t,r){super();N(this,Ye);N(this,Xe);N(this,dt);N(this,Fe);N(this,Ze);_(this,Xe,t),this.setOptions(r),this.bindMethods(),z(this,Ye,Tr).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var s;const r=this.options;this.options=l(this,Xe).defaultMutationOptions(t),br(this.options,r)||l(this,Xe).getMutationCache().notify({type:"observerOptionsUpdated",mutation:l(this,Fe),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&St(r.mutationKey)!==St(this.options.mutationKey)?this.reset():((s=l(this,Fe))==null?void 0:s.state.status)==="pending"&&l(this,Fe).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=l(this,Fe))==null||t.removeObserver(this)}onMutationUpdate(t){z(this,Ye,Tr).call(this),z(this,Ye,Ss).call(this,t)}getCurrentResult(){return l(this,dt)}reset(){var t;(t=l(this,Fe))==null||t.removeObserver(this),_(this,Fe,void 0),z(this,Ye,Tr).call(this),z(this,Ye,Ss).call(this)}mutate(t,r){var s;return _(this,Ze,r),(s=l(this,Fe))==null||s.removeObserver(this),_(this,Fe,l(this,Xe).getMutationCache().build(l(this,Xe),this.options)),l(this,Fe).addObserver(this),l(this,Fe).execute(t)}},Xe=new WeakMap,dt=new WeakMap,Fe=new WeakMap,Ze=new WeakMap,Ye=new WeakSet,Tr=function(){var r;const t=((r=l(this,Fe))==null?void 0:r.state)??yn();_(this,dt,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},Ss=function(t){ue.batch(()=>{var r,s,n,i,o,d,h,f;if(l(this,Ze)&&this.hasListeners()){const S=l(this,dt).variables,E=l(this,dt).context,x={client:l(this,Xe),meta:this.options.meta,mutationKey:this.options.mutationKey};(t==null?void 0:t.type)==="success"?((s=(r=l(this,Ze)).onSuccess)==null||s.call(r,t.data,S,E,x),(i=(n=l(this,Ze)).onSettled)==null||i.call(n,t.data,null,S,E,x)):(t==null?void 0:t.type)==="error"&&((d=(o=l(this,Ze)).onError)==null||d.call(o,t.error,S,E,x),(f=(h=l(this,Ze)).onSettled)==null||f.call(h,void 0,t.error,S,E,x))}this.listeners.forEach(S=>{S(l(this,dt))})})},Ln),ro=(Nn=class extends Nt{constructor(t={}){super();N(this,Qe);this.config=t,_(this,Qe,new Map)}build(t,r,s){const n=r.queryKey,i=r.queryHash??es(n,r);let o=this.get(i);return o||(o=new Va({client:t,queryKey:n,queryHash:i,options:t.defaultQueryOptions(r),state:s,defaultOptions:t.getQueryDefaults(n)}),this.add(o)),o}add(t){l(this,Qe).has(t.queryHash)||(l(this,Qe).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const r=l(this,Qe).get(t.queryHash);r&&(t.destroy(),r===t&&l(this,Qe).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ue.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return l(this,Qe).get(t)}getAll(){return[...l(this,Qe).values()]}find(t){const r={exact:!0,...t};return this.getAll().find(s=>tn(r,s))}findAll(t={}){const r=this.getAll();return Object.keys(t).length>0?r.filter(s=>tn(t,s)):r}notify(t){ue.batch(()=>{this.listeners.forEach(r=>{r(t)})})}onFocus(){ue.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ue.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Qe=new WeakMap,Nn),so=(qn=class{constructor(e={}){N(this,ne);N(this,lt);N(this,ht);N(this,Vt);N(this,Gt);N(this,ft);N(this,Xt);N(this,Zt);_(this,ne,e.queryCache||new ro),_(this,lt,e.mutationCache||new eo),_(this,ht,e.defaultOptions||{}),_(this,Vt,new Map),_(this,Gt,new Map),_(this,ft,0)}mount(){Fr(this,ft)._++,l(this,ft)===1&&(_(this,Xt,ns.subscribe(async e=>{e&&(await this.resumePausedMutations(),l(this,ne).onFocus())})),_(this,Zt,Cr.subscribe(async e=>{e&&(await this.resumePausedMutations(),l(this,ne).onOnline())})))}unmount(){var e,t;Fr(this,ft)._--,l(this,ft)===0&&((e=l(this,Xt))==null||e.call(this),_(this,Xt,void 0),(t=l(this,Zt))==null||t.call(this),_(this,Zt,void 0))}isFetching(e){return l(this,ne).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return l(this,lt).findAll({...e,status:"pending"}).length}getQueryData(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=l(this,ne).get(t.queryHash))==null?void 0:r.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),r=l(this,ne).build(this,t),s=r.state.data;return s===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(nt(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(s))}getQueriesData(e){return l(this,ne).findAll(e).map(({queryKey:t,state:r})=>{const s=r.data;return[t,s]})}setQueryData(e,t,r){const s=this.defaultQueryOptions({queryKey:e}),n=l(this,ne).get(s.queryHash),i=n==null?void 0:n.state.data,o=La(t,i);if(o!==void 0)return l(this,ne).build(this,s).setData(o,{...r,manual:!0})}setQueriesData(e,t,r){return ue.batch(()=>l(this,ne).findAll(e).map(({queryKey:s})=>[s,this.setQueryData(s,t,r)]))}getQueryState(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=l(this,ne).get(t.queryHash))==null?void 0:r.state}removeQueries(e){const t=l(this,ne);ue.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){const r=l(this,ne);return ue.batch(()=>(r.findAll(e).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const r={revert:!0,...t},s=ue.batch(()=>l(this,ne).findAll(e).map(n=>n.cancel(r)));return Promise.all(s).then(be).catch(be)}invalidateQueries(e,t={}){return ue.batch(()=>(l(this,ne).findAll(e).forEach(r=>{r.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const r={...t,cancelRefetch:t.cancelRefetch??!0},s=ue.batch(()=>l(this,ne).findAll(e).filter(n=>!n.isDisabled()&&!n.isStatic()).map(n=>{let i=n.fetch(void 0,r);return r.throwOnError||(i=i.catch(be)),n.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(s).then(be)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const r=l(this,ne).build(this,t);return r.isStaleByTime(nt(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(be).catch(be)}fetchInfiniteQuery(e){return e.behavior=gn(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(be).catch(be)}ensureInfiniteQueryData(e){return e.behavior=gn(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Cr.isOnline()?l(this,lt).resumePausedMutations():Promise.resolve()}getQueryCache(){return l(this,ne)}getMutationCache(){return l(this,lt)}getDefaultOptions(){return l(this,ht)}setDefaultOptions(e){_(this,ht,e)}setQueryDefaults(e,t){l(this,Vt).set(St(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...l(this,Vt).values()],r={};return t.forEach(s=>{tr(e,s.queryKey)&&Object.assign(r,s.defaultOptions)}),r}setMutationDefaults(e,t){l(this,Gt).set(St(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...l(this,Gt).values()],r={};return t.forEach(s=>{tr(e,s.mutationKey)&&Object.assign(r,s.defaultOptions)}),r}defaultQueryOptions(e){if(e._defaulted)return e;const t={...l(this,ht).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=es(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===wr&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...l(this,ht).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){l(this,ne).clear(),l(this,lt).clear()}},ne=new WeakMap,lt=new WeakMap,ht=new WeakMap,Vt=new WeakMap,Gt=new WeakMap,ft=new WeakMap,Xt=new WeakMap,Zt=new WeakMap,qn),En=ce.createContext(void 0),us=e=>{const t=ce.useContext(En);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},no=({client:e,children:t})=>(ce.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),H.jsx(En.Provider,{value:e,children:t})),bn=ce.createContext(!1),io=()=>ce.useContext(bn);bn.Provider;function ao(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var oo=ce.createContext(ao()),co=()=>ce.useContext(oo),uo=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},lo=e=>{ce.useEffect(()=>{e.clearReset()},[e])},ho=({result:e,errorResetBoundary:t,throwOnError:r,query:s,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&s&&(n&&e.data===void 0||on(r,[e.error,s])),fo=e=>{if(e.suspense){const r=n=>n==="static"?n:Math.max(n??1e3,1e3),s=e.staleTime;e.staleTime=typeof s=="function"?(...n)=>r(s(...n)):r(s),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},mo=(e,t)=>e.isLoading&&e.isFetching&&!t,po=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,wn=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function go(e,t,r){var E,x,F,I,O;if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const s=io(),n=co(),i=us(),o=i.defaultQueryOptions(e);(x=(E=i.getDefaultOptions().queries)==null?void 0:E._experimental_beforeQuery)==null||x.call(E,o),process.env.NODE_ENV!=="production"&&(o.queryFn||console.error(`[${o.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),o._optimisticResults=s?"isRestoring":"optimistic",fo(o),uo(o,n),lo(n);const d=!i.getQueryCache().get(o.queryHash),[h]=ce.useState(()=>new t(i,o)),f=h.getOptimisticResult(o),S=!s&&e.subscribed!==!1;if(ce.useSyncExternalStore(ce.useCallback(M=>{const B=S?h.subscribe(ue.batchCalls(M)):be;return h.updateResult(),B},[h,S]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),ce.useEffect(()=>{h.setOptions(o)},[o,h]),po(o,f))throw wn(o,h,n);if(ho({result:f,errorResetBoundary:n,throwOnError:o.throwOnError,query:i.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw f.error;if((I=(F=i.getDefaultOptions().queries)==null?void 0:F._experimental_afterQuery)==null||I.call(F,o,f),o.experimental_prefetchInRender&&!Ct&&mo(f,s)){const M=d?wn(o,h,n):(O=i.getQueryCache().get(o.queryHash))==null?void 0:O.promise;M==null||M.catch(be).finally(()=>{h.updateResult()})}return o.notifyOnChangeProps?f:h.trackResult(f)}function Ao(e,t){return go(e,Ga)}function it(e,t){const r=us(),[s]=ce.useState(()=>new to(r,e));ce.useEffect(()=>{s.setOptions(e)},[s,e]);const n=ce.useSyncExternalStore(ce.useCallback(o=>s.subscribe(ue.batchCalls(o)),[s]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),i=ce.useCallback((o,d)=>{s.mutate(o,d).catch(be)},[s]);if(n.error&&on(s.options.throwOnError,[n.error]))throw n.error;return{...n,mutate:i,mutateAsync:n.mutate}}const rr=()=>{const e=Q(i=>i.state.swapExecutionIndex),t=Q(i=>i.state.swapExecutions[i.state.swapExecutionIndex]??{}),r=Q(i=>i.updateSwapExecutionAtIndex),s=Q(i=>i.resetSwapExecutionAtIndex),n=P.useCallback(i=>r(e,i),[r,e]);return P.useMemo(()=>({...t,update:n,resetSwap:s}),[t,n,s])},yo=2e4,Eo=()=>{const{module:e}=q(),t=Q(r=>r.state.isMarketOrder);return P.useMemo(()=>e===j.TWAP?t?V.TWAP_MARKET:V.TWAP_LIMIT:e===j.LIMIT?V.LIMIT:e===j.STOP_LOSS?t?V.STOP_LOSS_MARKET:V.STOP_LOSS_LIMIT:e===j.TAKE_PROFIT?t?V.TAKE_PROFIT_MARKET:V.TAKE_PROFIT_LIMIT:V.TWAP_MARKET,[e,t])},Cn=()=>{const{account:e,config:t,chainId:r,isDev:s}=q();return P.useMemo(()=>["useTwapOrderHistoryManager",e,t==null?void 0:t.adapter,r,s],[e,t,r,s])},bo=()=>{const{callbacks:e}=q(),t=us(),r=Cn();return P.useCallback(s=>{var d;const n=t.getQueryData(r);let i=!1;const o=[];n&&n.filter(h=>h.version===2).forEach(h=>{var S;const f=s.find(E=>E.id===h.id);f&&f.progress!==h.progress&&(i=!0,o.push(f),f.status===me.Completed&&((S=e==null?void 0:e.onOrderFilled)==null||S.call(e,f)))}),i&&((d=e==null?void 0:e.onOrdersProgressUpdate)==null||d.call(e,o))},[t,r,e])},ds=()=>{const{account:e,config:t,chainId:r,isDev:s}=q(),n=Cn(),i=bo();return Ao({refetchInterval:yo,refetchOnWindowFocus:!0,retry:!1,staleTime:1/0,queryKey:n,queryFn:async({signal:d})=>{if(!e||!r||!t)return[];const h=await oa({signal:d,chainId:r,config:t,account:e,isDev:s});return i(h),h.map(f=>t!=null&&t.twapConfig?{...f,fillDelayMillis:Lr(f,t.twapConfig)}:f)}})},wo=(e,t,r)=>P.useMemo(()=>{if(!(!e||!t||!r||r!=null&&r.isMarketPrice))return Ms(r,e==null?void 0:e.decimals,t==null?void 0:t.decimals)},[r,e,t]),Co=(e,t,r)=>P.useMemo(()=>{if(!(!e||!t||!r))return _s(r,e.decimals,t.decimals)},[r,e,t]),So=(e,t,r)=>P.useMemo(()=>{if(!(!e||!t||!r))return Nr(r.srcAmountFilled,r.dstAmountFilled,e.decimals,t.decimals)},[r,e,t]),xr=(e,t)=>[...e.filter(s=>s.status===t)].sort((s,n)=>n.createdAt-s.createdAt),xo=()=>{const{data:e,isLoading:t,refetch:r,isRefetching:s}=ds(),n=P.useCallback(()=>r().then(i=>i.data),[r]);return P.useMemo(()=>({orders:{all:e??[],open:xr(e??[],me.Open),completed:xr(e??[],me.Completed),cancelled:xr(e??[],me.Cancelled),expired:xr(e??[],me.Expired)},isLoading:t,isRefetching:s,refetchOrders:n}),[e,t,s,n])},ls=()=>{const e=Q(r=>r.state.currentTime),t=Xr().duration;return P.useMemo(()=>bi(e,t),[e,t])},Sn=()=>{const{srcToken:e,dstToken:t,account:r,chainId:s,slippage:n,config:i,module:o,fees:d}=q(),{amount:h}=st(),{amountPerTrade:f,totalTrades:S}=qe(),E=ls(),{amount:x}=Yr(),{pricePerChunk:F}=bt(),{milliseconds:I}=Lt();return P.useMemo(()=>{var O;return Ls({chainId:s,srcToken:Ut((e==null?void 0:e.address)||"")?((O=yt(s))==null?void 0:O.wToken.address)||"":(e==null?void 0:e.address)||"",dstToken:(t==null?void 0:t.address)||"",srcAmount:h,deadlineMillis:E,fillDelayMillis:!S||S===1?0:I,slippage:n*100,account:r,srcAmountPerTrade:f,dstMinAmountPerTrade:x,triggerAmountPerTrade:F,config:i,module:o})},[e,t,r,s,n,i,o,h,f,S,I,x,F,d])};function vo(e){const t=e.slice(2);if(t.length===128){const i=`0x${t.slice(0,64)}`,o=parseInt(t.charAt(64),16),d=(o>>3)+27,h=`0x${(o&7).toString(16)}${t.slice(65,128)}`;return{r:i,s:h,v:d}}const r=`0x${t.slice(0,64)}`,s=`0x${t.slice(64,128)}`,n=parseInt(t.slice(128,130),16);return{r,s,v:n}}const Po=()=>{var i;const{account:e,walletInteractions:t,callbacks:r,chainId:s}=q(),n=(i=gr())==null?void 0:i.wToken;return it({mutationFn:async({onHash:o,srcAmountWei:d})=>{var f,S;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletInteractions");if(!n)throw new Error("tokenAddress is not defined");he.onWrapRequest();const h=await t.wrapNativeToken(d);return(f=r==null?void 0:r.onWrapRequest)==null||f.call(r),o==null||o(h),he.onWrapSuccess(h),(S=r==null?void 0:r.onWrapSuccess)==null||S.call(r,{txHash:h,explorerUrl:Rt(h,s),amount:Ee(d,n.decimals)}),h},onError:o=>{throw he.onWrapError(o),o}})},xn=()=>{const{account:e,walletInteractions:t,chainId:r,callbacks:s}=q(),n=Sn(),{refetch:i}=ds();return it({mutationFn:async()=>{var I,O,M,B;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletInteractions");if(!r)throw new Error("missing chainId");const{order:o,domain:d,types:h,primaryType:f}=n;he.onSignOrderRequest(o);let S;try{S=await t.signOrder({domain:d,types:h,primaryType:f,message:o,account:e})}catch(T){throw(I=s==null?void 0:s.onSignOrderError)==null||I.call(s,T),he.onSignOrderError(T),T}he.onSignOrderSuccess(S),(O=s==null?void 0:s.onSignOrderSuccess)==null||O.call(s,S);const E=vo(S),x={v:`0x${E.v.toString(16)}`,r:E.r,s:E.s};(M=s==null?void 0:s.onSignOrderRequest)==null||M.call(s);const F=await Ks(o,x);return(B=s==null?void 0:s.onOrderCreated)==null||B.call(s,F),await i(),F}})},vn=()=>{const{account:e,walletInteractions:t,config:r}=q();return it({mutationFn:async({tokenAddress:s,srcAmountWei:n})=>{if(!t)throw new Error("missing walletInteractions");if(!e)throw new Error("missing account");if(!r)throw new Error("missing config");const i=await t.getAllowance({tokenAddress:s,spenderAddress:r.repermit}),o=v(i||"0").lt(v(n).toString());return{allowance:i,approvalRequired:o}}})},Fo=()=>{const{account:e,walletInteractions:t,config:r,chainId:s,callbacks:n}=q(),{mutateAsync:i}=vn();return it({onError:o=>{he.onApproveError(o)},mutationFn:async({token:o,onHash:d,srcAmountWei:h})=>{var E,x;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletInteractions");if(!r)throw new Error("missing config");he.onApproveRequest();const f=await t.approveToken({tokenAddress:o.address,amount:h,spenderAddress:r.repermit});if(!f)throw new Error("failed to approve token");(E=n==null?void 0:n.onApproveRequest)==null||E.call(n),d(f);let S=!1;for(let F=0;F<3;F++){const{approvalRequired:I}=await i({tokenAddress:o.address,srcAmountWei:h});if(!I){S=!0;break}F<2&&await new Promise(O=>setTimeout(O,3e3))}if(!S)throw new Error(`Insufficient ${o.symbol} allowance to perform the swap. Please approve the token first.`);return he.onApproveSuccess(f),(x=n==null?void 0:n.onApproveSuccess)==null||x.call(n,{txHash:f,explorerUrl:Rt(f,s),token:o,amount:Ee(h,o.decimals)}),f}})},To=()=>{const{account:e,chainId:t,srcToken:r,dstToken:s,module:n,slippage:i}=q(),o=bt(),d=st().amount,h=qe().amountPerTrade,f=ls(),S=qe().totalTrades,E=Lt().fillDelay,x=Yr().amount,F=Q(I=>I.state.isMarketOrder);return it({mutationFn:async()=>{he.onRequestOrder({account:e,chainId:t,module:n,srcToken:r,dstToken:s,fromTokenAmount:d,srcChunkAmount:h,triggerPricePerTrade:o.pricePerChunk,deadline:f,fillDelay:E.unit*E.value,minDstAmountOutPerTrade:x,slippage:i,isMarketOrder:F||!1,chunksAmount:S})}})};function Do(e){const t=e.message,r=t.match(/,\s*code\s*:\s*(\d+)/i);return{message:t.replace(/^error\s*:/i,"").replace(/,\s*code\s*:\s*\d+/i,"").trim()||"",code:r?Number(r[1]):0}}const Pn=()=>{const{srcToken:e,dstToken:t,chainId:r,callbacks:s,marketPrice:n}=q(),i=Fo().mutateAsync,o=Po().mutateAsync,d=xn().mutateAsync,{mutateAsync:h}=vn(),{update:f}=rr(),{amount:S}=st(),E=To().mutate;return it({mutationFn:async()=>{var F,I;const x=Ut((e==null?void 0:e.address)||" ");try{if(!e)throw new Error("missing srcToken");if(!t)throw new Error("missing dstToken");if(!r)throw new Error("missing chainId");const O=Vs(e,r);f({allowanceLoading:!0,wrapTxHash:void 0,approveTxHash:void 0,acceptedMarketPrice:n,acceptedSrcAmount:S,srcToken:e,dstToken:t,pendingSteps:[]});const{approvalRequired:M}=await h({tokenAddress:O.address,srcAmountWei:S});let B=0,T=1;x&&T++,M&&T++,f({totalSteps:T,stepIndex:B,allowanceLoading:!1,hasApproval:!M,status:ve.LOADING}),E();let K=[];x&&K.push(tt.WRAP),M&&K.push(tt.APPROVE),K.push(tt.CREATE),f({pendingSteps:K}),x&&(f({step:tt.WRAP}),await o({onHash:Z=>f({wrapTxHash:Z}),srcAmountWei:S}),B++,f({stepIndex:B})),M&&(f({step:tt.APPROVE}),await i({token:O,onHash:Z=>f({approveTxHash:Z}),srcAmountWei:S}),B++,f({stepIndex:B})),f({step:tt.CREATE});const U=await d();return f({status:ve.SUCCESS,orderId:U.id}),U}catch(O){if(zr(O))(F=s==null?void 0:s.onSubmitOrderRejected)==null||F.call(s),f({step:void 0,status:void 0,stepIndex:void 0,error:O});else{const M=Do(O);(I=s==null?void 0:s.onSubmitOrderFailed)==null||I.call(s,M),f({status:ve.FAILED,parsedError:M,error:O})}throw O}}})},Oo=()=>{const e=rr(),{srcToken:t,dstToken:r}=q(),s=Pn(),n=Q(f=>f.resetState),i=P.useCallback(()=>s.mutateAsync(),[s]),{update:o,resetSwap:d,...h}=e;return P.useMemo(()=>({status:h.status,parsedError:h.parsedError,error:h.error,step:h.step,stepIndex:h.stepIndex,approveTxHash:h.approveTxHash,wrapTxHash:h.wrapTxHash,totalSteps:h.totalSteps,pendingSteps:h.pendingSteps,srcToken:t,dstToken:r,onSubmit:i,resetState:n,resetCurrentSwap:d,isLoading:(e==null?void 0:e.status)===ve.LOADING,isSuccess:(e==null?void 0:e.status)===ve.SUCCESS,isFailed:(e==null?void 0:e.status)===ve.FAILED,confirmButtonLoading:h.allowanceLoading}),[i,h,n,d,t,r])},Io=()=>{const{marketPrice:e,srcToken:t,dstToken:r,marketPriceLoading:s,srcBalance:n,srcUsd1Token:i,noLiquidity:o,typedInputAmount:d}=q(),h=s||v(i||"0").isZero()||n===void 0||v(e||"0").isZero(),f=!!(t&&r&&d&&h),E=!!(Js()||o||f||v(d||"0").isZero()||!t||!r);return P.useMemo(()=>({disabled:E,loading:f}),[E,f])},ko=()=>{const{srcUsd1Token:e,dstUsd1Token:t}=q(),r=st().amountUI,s=Er().amountUI,n=rt(r,e),i=rt(s,t);return{srcAmountUsd:n,dstAmountUsd:i}},Mo=()=>{const{fees:e,dstToken:t,dstUsd1Token:r}=q(),{amountUI:s}=Er(),n=P.useMemo(()=>!e||!s?"":v(s).multipliedBy(e).dividedBy(100).toFixed(),[s,e]),i=Gr((t==null?void 0:t.decimals)||0,n);return{amountUI:n,amount:i,percent:e,usd:rt(n,r)}},_o=e=>{const t=P.useMemo(()=>!e.minDestAmountPerTrade||!e.totalTrades?"":v(e.minDestAmountPerTrade).multipliedBy(e.totalTrades).decimalPlaces(0).toFixed(),[e.minDestAmountPerTrade,e.totalTrades]),r=P.useMemo(()=>!e.minDestAmountPerTradeUI||!e.totalTrades?"":v(e.minDestAmountPerTradeUI).multipliedBy(e.totalTrades).toFixed(),[e.minDestAmountPerTradeUI,e.totalTrades]),s=P.useMemo(()=>!e.minDestAmountPerTradeUsd||!e.totalTrades?"":v(e.minDestAmountPerTradeUsd).multipliedBy(e.totalTrades).decimalPlaces(2).toFixed(),[e.minDestAmountPerTradeUsd,e.totalTrades]);return P.useMemo(()=>({srcToken:e.srcToken,dstToken:e.dstToken,orderType:e.orderType,createdAt:e.createdAt||0,deadline:e.deadline||0,totalTrades:e.totalTrades||0,tradeInterval:e.tradeInterval||0,recipient:e.account||"",srcAmount:e.srcAmount||"",srcAmountUI:e.srcAmountUI||"",srcAmountUsd:e.srcAmountUsd||"",dstAmount:e.dstAmount||"",dstAmountUI:e.dstAmountUI||"",dstAmountUsd:e.dstAmountUsd||"",limitPrice:e.limitPrice||"",limitPriceUI:e.limitPriceUI||"",limitPriceUsd:e.limitPriceUsd||"",sizePerTrade:e.srcAmountPerTrade||"",sizePerTradeUI:e.srcAmountPerTradeUI||"",sizePerTradeUsd:e.srcAmountPerTradeUsd,minDestAmountPerTrade:e.minDestAmountPerTrade||"",minDestAmountPerTradeUI:e.minDestAmountPerTradeUI||"",minDestAmountPerTradeUsd:e.minDestAmountPerTradeUsd,dstMinAmount:t,dstMinAmountUI:r,dstMinAmountUsd:s,triggerPrice:e.triggerPrice||"",triggerPriceUI:e.triggerPriceUI||"",triggerPriceUsd:e.triggerPriceUsd}),[e.srcToken,e.dstToken,e.orderType,e.createdAt,e.deadline,e.totalTrades,e.tradeInterval,e.account,e.srcAmount,e.srcAmountUI,e.srcAmountUsd,e.dstAmount,e.dstAmountUI,e.dstAmountUsd,e.limitPrice,e.limitPriceUI,e.limitPriceUsd,e.srcAmountPerTrade,e.srcAmountPerTradeUI,e.srcAmountPerTradeUsd,e.minDestAmountPerTrade,e.minDestAmountPerTradeUI,e.minDestAmountPerTradeUsd,t,r,s,e.triggerPrice,e.triggerPriceUI,e.triggerPriceUsd])},Bo=()=>{const{config:e}=q();return P.useMemo(()=>({spender:e.repermit}),[e])},Uo=()=>{const{srcToken:e,dstToken:t,account:r,marketPrice:s}=q(),{spender:n}=Bo(),{amount:i}=st(),{amount:o,amountUI:d,usd:h}=yr(),{amountPerTrade:f,amountPerTradeUI:S,amountPerTradeUsd:E,totalTrades:x}=qe(),F=ls(),{amount:I,amountUI:O,usd:M}=Yr(),{amountUI:B,amount:T,usd:K}=bt(),{milliseconds:U}=Lt(),{amount:Z,amountUI:Y}=Er(),{srcAmountUsd:oe,dstAmountUsd:a}=ko(),{amount:c,amountUI:u,percent:y,usd:p}=Mo(),g=Sn(),C=Q(G=>G.state.isMarketOrder),m=Q(G=>G.state.currentTime),A=rr(),w=Eo(),b=A.acceptedSrcAmount||i,D=Ee(s,(t==null?void 0:t.decimals)||0),R=P.useMemo(()=>w===V.TAKE_PROFIT_MARKET||w===V.TAKE_PROFIT_LIMIT||w===V.STOP_LOSS_LIMIT||w===V.STOP_LOSS_MARKET,[w]),L=_o({srcToken:e,dstToken:t,account:r,orderType:w,createdAt:m,deadline:F,totalTrades:x,tradeInterval:U,srcAmount:b,srcAmountUI:Ee(b,(e==null?void 0:e.decimals)||0),srcAmountUsd:oe,dstAmount:Z,dstAmountUI:Y,dstAmountUsd:a,limitPrice:C?void 0:o,limitPriceUI:C?void 0:d,limitPriceUsd:C?void 0:h,srcAmountPerTrade:f,srcAmountPerTradeUI:S,srcAmountPerTradeUsd:E,minDestAmountPerTrade:I,minDestAmountPerTradeUI:O,minDestAmountPerTradeUsd:M,triggerPrice:T,triggerPriceUI:B,triggerPriceUsd:K});return P.useMemo(()=>({...L,feesAmountUI:u,feesAmount:c,feesUsd:p||"",feesPercentage:y,rePermitData:g,isTriggerPrice:R,isMarketOrder:C,marketPrice:s,marketPriceUi:D,spender:n}),[L,u,c,p,y,g,R,C,s,D,n])},Ro=()=>{const{supportedChains:e}=q();return P.useMemo(()=>e,[e])},Lo=60,Fn=()=>{const{refetch:e}=ds();return it({mutationFn:async t=>{var r;for(let s=0;s<Lo;s++){const n=(r=await e())==null?void 0:r.data;if(!n)throw new Error("orders not found");const i=n.find(o=>o.id===t);if((i==null?void 0:i.status)===me.Cancelled)return;await new Promise(o=>setTimeout(o,1e3))}throw new Error("Timed out waiting for order cancellation to be confirmed")}})},No=()=>{const e=Q(r=>r.updateState),t=Q(r=>r.state.cancelOrders);return{cancelOrders:t,setCancelOrder:(r,s)=>{e({cancelOrders:{...t,[r]:s}})},clearCancelOrder:r=>{const{[r]:s,...n}=t;e({cancelOrders:n})}}},qo=e=>{const{account:t,walletInteractions:r,config:s,callbacks:n,chainId:i}=q(),o=Fn().mutateAsync,{cancelOrders:d,setCancelOrder:h,clearCancelOrder:f}=No(),{mutateAsync:S}=it({mutationFn:async()=>{var I,O,M;if(!t||!r||!s)throw new Error("missing required parameters");if(!e)throw new Error("order is required");const F=e.id;try{(I=n==null?void 0:n.onCancelOrderRequest)==null||I.call(n,e),h(F,{status:ve.LOADING}),he.onCancelOrderRequest([e.version===1?e.id.toString():e.hash],e.version);const B=await r.cancelOrder({order:e,contractAddress:e.version===1?e.twapAddress:s.repermit,args:e.version===1?[e.id]:[[e.hash]]});if(!B)throw new Error("failed to cancel order");return he.onCancelOrderSuccess(B),await o(e.id),(O=n==null?void 0:n.onCancelOrderSuccess)==null||O.call(n,{order:e,txHash:B,explorerUrl:Rt(B,i)}),h(F,{status:ve.SUCCESS,txHash:B}),B}catch(B){console.error("cancel order error",B),(M=n==null?void 0:n.onCancelOrderFailed)==null||M.call(n,B),zr(B)?f(F):(h(F,{status:ve.FAILED,error:B.message}),he.onCancelOrderError(B))}}}),E=P.useMemo(()=>{const F=d[(e==null?void 0:e.id)||""];return{isLoading:(F==null?void 0:F.status)===ve.LOADING,isSuccess:(F==null?void 0:F.status)===ve.SUCCESS,isError:(F==null?void 0:F.status)===ve.FAILED,error:F==null?void 0:F.error,txHash:F==null?void 0:F.txHash}},[d,e==null?void 0:e.id]),x=P.useCallback(async()=>S(),[S]);return P.useMemo(()=>({cancelOrder:x,...E}),[x,E])},Tn=P.createContext(null),Ko=({children:e})=>{const t=ba(),r=xa(),s=Ca(),n=Oa(),i=Ia(),o=Ar(),d=ka(),h=Ma(),f=Js(),S=Io(),E=Uo(),x=xo(),F=Oo(),I=Ro(),O=Fn(),{module:M}=q(),B={tradesAmountPanel:t,durationPanel:r,fillDelayPanel:s,limitPricePanel:n,triggerPricePanel:i,pricePanel:o,dstTokenPanel:d,disclaimerPanel:h,inputError:f,submitOrderButton:S,derivedFormData:E,orderHistoryPanel:x,orderExecutionPanel:F,supportedChains:I,refetchUntilStatusSynced:O,module:M};return H.jsx(Tn.Provider,{value:B,children:e})},Ho=()=>{const e=P.useContext(Tn);if(e===null)throw new Error("useSpot must be used within SpotProvider");return e},Wo=P.createContext(null),hs={didCatch:!1,error:null};class Qo extends P.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=hs}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var r,s,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];(r=(s=this.props).onReset)===null||r===void 0||r.call(s,{args:i,reason:"imperative-api"}),this.setState(hs)}}componentDidCatch(t,r){var s,n;(s=(n=this.props).onError)===null||s===void 0||s.call(n,t,r)}componentDidUpdate(t,r){const{didCatch:s}=this.state,{resetKeys:n}=this.props;if(s&&r.error!==null&&jo(t.resetKeys,n)){var i,o;(i=(o=this.props).onReset)===null||i===void 0||i.call(o,{next:n,prev:t.resetKeys,reason:"keys"}),this.setState(hs)}}render(){const{children:t,fallbackRender:r,FallbackComponent:s,fallback:n}=this.props,{didCatch:i,error:o}=this.state;let d=t;if(i){const h={error:o,resetErrorBoundary:this.resetErrorBoundary};if(typeof r=="function")d=r(h);else if(s)d=P.createElement(s,h);else if(n!==void 0)d=n;else throw o}return P.createElement(Wo.Provider,{value:{didCatch:i,error:o,resetErrorBoundary:this.resetErrorBoundary}},d)}}function jo(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((r,s)=>!Object.is(r,t[s]))}const zo=()=>H.jsx("div",{className:"twap-error-fallback",children:H.jsx("p",{style:{fontSize:20,fontWeight:600,textAlign:"center",width:"100%",marginTop:40},children:"Something went wrong"})});function $o({children:e}){return H.jsx(Qo,{FallbackComponent:zo,onError:t=>he.onCrash(t),children:H.jsx(H.Fragment,{children:e})})}const Dn=P.createContext(null),Vo=new so({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),Go=e=>{var s,n,i;const t=Q(o=>o.updateState),r=Q(o=>o.state.isMarketOrder);return P.useEffect(()=>{const o=setInterval(()=>{t({currentTime:Date.now()})},6e4);return()=>clearInterval(o)},[t]),P.useEffect(()=>{var d,h,f,S,E,x,F,I,O,M,B,T,K,U,Z,Y;const o=(h=(d=e.overrides)==null?void 0:d.state)==null?void 0:h.isMarketOrder;o!==void 0&&t({isMarketOrder:o}),t({typedChunks:(S=(f=e.overrides)==null?void 0:f.state)==null?void 0:S.chunks,typedFillDelay:(x=(E=e.overrides)==null?void 0:E.state)==null?void 0:x.fillDelay,typedDuration:(I=(F=e.overrides)==null?void 0:F.state)==null?void 0:I.duration,typedLimitPrice:(M=(O=e.overrides)==null?void 0:O.state)==null?void 0:M.limitPrice,typedTriggerPrice:(T=(B=e.overrides)==null?void 0:B.state)==null?void 0:T.triggerPrice,triggerPricePercent:(U=(K=e.overrides)==null?void 0:K.state)==null?void 0:U.triggerPricePercent,limitPricePercent:(Y=(Z=e.overrides)==null?void 0:Z.state)==null?void 0:Y.limitPricePercent})},[(s=e.overrides)==null?void 0:s.state,e.module]),P.useEffect(()=>{var o,d,h,f;t({typedLimitPrice:(d=(o=e.overrides)==null?void 0:o.state)==null?void 0:d.limitPrice,typedTriggerPrice:(f=(h=e.overrides)==null?void 0:h.state)==null?void 0:f.triggerPrice,triggerPricePercent:void 0,limitPricePercent:void 0})},[(n=e.srcToken)==null?void 0:n.address,(i=e.dstToken)==null?void 0:i.address]),P.useEffect(()=>{e.module===j.LIMIT&&t({isMarketOrder:!1})},[e.module]),P.useEffect(()=>{r&&t({isInvertedTrade:!1})},[r]),P.useEffect(()=>{t({typedChunks:void 0})},[e.typedInputAmount]),null},Xo=({marketReferencePrice:e,srcToken:t,dstToken:r,chainId:s,typedInputAmount:n})=>P.useMemo(()=>{if($r(t,r,s)||Vr(t,r,s))return{isLoading:!1,noLiquidity:!1,value:Et(n||"0",t==null?void 0:t.decimals)};if(v(e.value||0).isZero()||v(n||0).isZero())return e;const i=v(e.value||0).dividedBy(n||0).decimalPlaces(0).toFixed();return{...e,value:i}},[e,n,t,r,s]),Zo=e=>{const t=rr(),r=P.useMemo(()=>ks(e.partner),[e.partner]),s=P.useMemo(()=>{const d=r[0];return e.chainId&&r.includes(e.chainId)?e.chainId:d},[e.chainId,r]),n=P.useMemo(()=>qr(e.partner,s),[e.partner,s]),i=Xo(e),o=P.useMemo(()=>Us(e.minChunkSizeUsd),[e.minChunkSizeUsd]);return P.useEffect(()=>{he.init(n,o,s)},[n,s,o]),H.jsxs(Dn.Provider,{value:{typedInputAmount:e.typedInputAmount,minChunkSizeUsd:o,account:e.account,walletInteractions:e.walletInteractions,marketPrice:t.acceptedMarketPrice||i.value,marketPriceLoading:!t.acceptedMarketPrice&&i.isLoading,noLiquidity:!t.acceptedMarketPrice&&i.noLiquidity,config:n,slippage:e.priceProtection,supportedChains:r,chainId:s,partner:e.partner,module:e.module,fees:e.fees||0,overrides:e.overrides,callbacks:e.callbacks,srcUsd1Token:e.srcUsd1Token,dstUsd1Token:e.dstUsd1Token,srcBalance:e.srcBalance,dstBalance:e.dstBalance,srcToken:t.srcToken||e.srcToken,dstToken:t.dstToken||e.dstToken,isDev:e.isDev},children:[H.jsx(Go,{...e}),H.jsx(Ko,{children:H.jsx($o,{children:e.children})})]})},Yo=e=>H.jsx(no,{client:Vo,children:H.jsx(Zo,{...e})}),q=()=>{const e=P.useContext(Dn);if(e===null)throw new Error("useSpotContext must be used within SpotProvider");return e},Jo=(e,t,r)=>{const s=gr();return P.useMemo(()=>e==null?void 0:e.map(n=>({srcToken:t,dstToken:r,srcAmount:Ee(n.inAmount,t==null?void 0:t.decimals),dstAmount:Ee(n.outAmount,r==null?void 0:r.decimals),timestamp:n.timestamp,txHash:n.txHash,explorerUrl:Rt(n.txHash,s==null?void 0:s.id),executionRate:Nr(n.inAmount,n.outAmount,t==null?void 0:t.decimals,r==null?void 0:r.decimals)})).filter(n=>n.srcToken!==void 0&&n.dstToken!==void 0),[e,t,r,s])},ec=(e,t,r)=>{const{config:s}=q(),n=wo(t,r,e),i=Co(t,r,e),o=So(t,r,e),d=P.useMemo(()=>e?e.version===2?e.fillDelay:s.twapConfig?Lr(e,s.twapConfig):0:0,[e,s]),h=Jo(e==null?void 0:e.fills,t,r)??[];return P.useMemo(()=>{if(e!=null&&e.id)return{original:e,fills:h,srcToken:t,dstToken:r,orderType:e.type,createdAt:e.createdAt,deadline:e.deadline||0,totalTrades:e.totalTradesAmount||0,tradeInterval:d,recipient:e.maker||"",srcAmount:e.srcAmount||"",srcAmountUI:Ee(e.srcAmount,t==null?void 0:t.decimals),limitPrice:Et(n,r==null?void 0:r.decimals),limitPriceUI:n||"",sizePerTrade:e.srcAmountPerTrade||"",sizePerTradeUI:Ee(e.srcAmountPerTrade,t==null?void 0:t.decimals),minDestAmountPerTrade:e.dstMinAmountPerTrade||"",minDestAmountPerTradeUI:Ee(e.dstMinAmountPerTrade,r==null?void 0:r.decimals),dstMinAmount:e.dstMinAmountTotal,dstMinAmountUI:Ee(e.dstMinAmountTotal,r==null?void 0:r.decimals),triggerPrice:Et(i,r==null?void 0:r.decimals),triggerPriceUI:i||"",id:e.id,amountInFilled:e.srcAmountFilled,amountInFilledUI:Ee(e.srcAmountFilled,t==null?void 0:t.decimals),amountOutFilled:e.dstAmountFilled,amountOutFilledUI:Ee(e.dstAmountFilled,r==null?void 0:r.decimals),progress:e.progress,executionPrice:Et(o,r==null?void 0:r.decimals),executionPriceUI:o,version:e.version}},[e,h,t,r,d,n,i,o])};Li(ca.version),k.DISCLAIMER_URL=ri,k.Disclaimer=Jt,k.InputErrors=pe,k.Module=j,k.ORBS_LOGO=ei,k.ORBS_SLTP_FAQ_URL=Jn,k.ORBS_TWAP_FAQ_URL=Yn,k.ORBS_WEBSITE_URL=ti,k.OrderFilter=xs,k.OrderStatus=me,k.OrderType=V,k.Partners=Ne,k.SPOT_VERSION=dr,k.SpotProvider=Yo,k.Steps=tt,k.SwapStatus=ve,k.TimeUnit=Te,k.buildRePermitOrderData=Ls,k.ensureWrappedToken=Vs,k.eqIgnoreCase=gt,k.getConfig=qr,k.getExplorerUrl=Rt,k.getMinChunkSizeUsd=Us,k.getNetwork=yt,k.getOrderExecutionRate=Nr,k.getOrderFillDelayMillis=Lr,k.getOrderLimitPriceRate=Ms,k.getOrderType=ma,k.getPartnerChains=ks,k.getPartners=Bs,k.getTriggerPriceRate=_s,k.isNativeAddress=Ut,k.isTxRejected=zr,k.millisToDays=Gs,k.millisToMinutes=Xs,k.networks=ge,k.parseError=fa,k.shouldUnwrapOnly=Vr,k.shouldWrapOnly=$r,k.submitOrder=Ks,k.toAmountUi=Ee,k.toAmountWei=Et,k.useAmountUi=er,k.useCancelOrder=qo,k.useDerivedHistoryOrder=ec,k.useExplorerLink=pa,k.useNetwork=gr,k.useSignOrder=xn,k.useSpot=Ho,k.useSubmitOrder=Pn,k.useSwapExecution=rr,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})}));
64
+ `,extractResults:C=>{var v;return(((v=C.data)==null?void 0:v.orderFilleds)||[]).map(F=>({...F,timestamp:new Date(F.timestamp).getTime()}))}})};class ri extends Error{constructor(){super("No graph endpoint found"),this.name="NoGraphEndpointError"}}const si=async({chainId:e,signal:t,page:n,limit:r,filters:s})=>{try{const a=await ei({chainId:e,signal:t,page:n,limit:r,filters:s}),[o,d]=await Promise.all([ni({chainId:e,orders:a,signal:t}),ti({chainId:e,orders:a,signal:t})]),p=a.map(w=>{const C=o==null?void 0:o.filter(v=>v.TWAP_id===Number(w.Contract_id)&&yt(v.exchange,w.exchange)&&yt(v.twapAddress,w.twapAddress));return Ya(w,e,C,ai(w,C||[],d))}).sort((w,C)=>C.createdAt-w.createdAt),f=new Set;return p.filter(w=>f.has(w.id)?!1:(f.add(w.id),!0))}catch{return[]}},ai=(e,t,n)=>{var d;const r=(d=n==null?void 0:n.find(p=>p.twapId===e.Contract_id.toString()&&yt(p.twapAddress,e.twapAddress)))==null?void 0:d.status,a=Kr(t).reduce((p,f)=>p.plus(f.inAmount),new x(0)).toFixed(),o=Wr(e.ask_srcAmount,a);return ii(o,e.ask_deadline*1e3,r)},Wr=(e,t)=>{if(!t||!e)return 0;const n=x(t).dividedBy(e).toNumber();return n>=.99?100:n<=0?0:Number((n*100).toFixed(2))},ii=(e,t,n)=>e===100?he.Completed:n==="CANCELLED"?he.Cancelled:n==="COMPLETED"?he.Completed:t>Date.now()?he.Open:he.Expired,oi=async({signal:e,page:t,chainId:n,limit:r,config:s,account:a,isDev:o=!1})=>(await Promise.all([s?si({chainId:n,signal:e,page:t,limit:r,filters:{accounts:[a],configs:s.twapConfig?[s.twapConfig]:[]}}):Promise.resolve([]),Xa({chainId:n,signal:e,account:a,exchange:s==null?void 0:s.adapter,isDev:o})]).then(([f,w])=>[...f,...w])).sort((f,w)=>w.createdAt-f.createdAt),ci={version:"1.1.25"},Qr=e=>{let t;const n=new Set,r=(f,w)=>{const C=typeof f=="function"?f(t):f;if(!Object.is(C,t)){const v=t;t=w??(typeof C!="object"||C===null)?C:Object.assign({},t,C),n.forEach(F=>F(t,v))}},s=()=>t,d={setState:r,getState:s,getInitialState:()=>p,subscribe:f=>(n.add(f),()=>n.delete(f))},p=t=e(r,s,d);return d},ui=(e=>e?Qr(e):Qr),di=e=>e;function li(e,t=di){const n=S.useSyncExternalStore(e.subscribe,S.useCallback(()=>t(e.getState()),[e,t]),S.useCallback(()=>t(e.getInitialState()),[e,t]));return S.useDebugValue(n),n}const jr=e=>{const t=ui(e),n=r=>li(t,r);return Object.assign(n,t),n},pi=(e=>e?jr(e):jr),mn={},zr={currentTime:Date.now(),cancelOrders:{},swapExecutions:[mn],swapExecutionIndex:0},Q=pi((e,t)=>({state:zr,updateState:n=>e(r=>({state:{...r.state,...n}})),updateSwapExecutionAtIndex:(n,r)=>e(s=>{const a=[...s.state.swapExecutions];return a[n]={...a[n]??mn,...r},{state:{...s.state,swapExecutions:a}}}),resetSwapExecutionAtIndex:()=>e(n=>{const r=[...n.state.swapExecutions];return r[n.state.swapExecutionIndex]=mn,{state:{...n.state,swapExecutions:r}}}),resetState:()=>{const n=t().state;e({state:{...zr,currentTime:Date.now(),isMarketOrder:n.isMarketOrder,swapExecutions:[...n.swapExecutions,mn],swapExecutionIndex:n.swapExecutionIndex+1}})}}));var xe=(e=>(e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILED=3]="FAILED",e))(xe||{}),Jt=(e=>(e.TRIGGER_MARKET_PRICE="triggerMarketPriceDisclaimer",e.MARKET_PRICE="marketOrderDisclaimer",e.LIMIT_PRICE="limitOrderDisclaimer",e))(Jt||{}),tt=(e=>(e.WRAP="wrap",e.APPROVE="approve",e.CREATE="create",e))(tt||{});const Et=(e,t)=>!t||!e||x(e).isNaN()?"":x(e).multipliedBy(x(10).pow(t)).toFixed(0),Ee=(e,t)=>{try{return!t||!e||x(e).isNaN()?"":x(e).dividedBy(x(10).pow(t)).toFixed()}catch(n){return console.error(n),""}},fi=e=>{const t="An error occurred.";if(!e||!e.message)return t;try{return e.message.toLowerCase().includes("rejected")?"Transaction Rejected":t}catch{return t}},zn=e=>{var t,n,r,s;if(e!=null&&e.message)return((n=(t=e.message)==null?void 0:t.toLowerCase())==null?void 0:n.includes("rejected"))||((s=(r=e.message)==null?void 0:r.toLowerCase())==null?void 0:s.includes("denied"))},$r=(e,t)=>{const n=At(t);return n&&Ut(e.address)?n.wToken:e};function Vr(e){return e?e/864e5:0}function Gr(e){return e?e/6e4:0}const hi=(e,t)=>e?V.TWAP_MARKET:t===1?V.LIMIT:V.TWAP_LIMIT,$n=(e,t,n)=>{const r=At(n);return Ut((e==null?void 0:e.address)||"")&&yt((t==null?void 0:t.address)||"",(r==null?void 0:r.wToken.address)||"")},Vn=(e,t,n)=>{const r=At(n);return yt((e==null?void 0:e.address)||"",(r==null?void 0:r.wToken.address)||"")&&Ut((t==null?void 0:t.address)||"")},Rt=(e,t)=>{if(!t)return"";const n=At(t);return`${n==null?void 0:n.explorer}/tx/${e}`},Gn=(e,t)=>S.useMemo(()=>Et(t,e),[e,t]),en=(e,t)=>S.useMemo(()=>Ee(t,e),[e,t]),yn=()=>{const{chainId:e}=q();return S.useMemo(()=>At(e),[e])},mi=e=>{const t=yn();return S.useMemo(()=>{if(!(!e||!t))return Rt(e,t.id)},[e,t])},nt=(e,t)=>S.useMemo(()=>!e||!t||x(e||"0").isZero()||x(t||"0").isZero()?"":x(e||"0").times(t).toFixed(),[e,t]),yi=()=>{const{srcToken:e,dstToken:t,chainId:n}=q();return S.useMemo(()=>$n(e,t,n),[e,t,n])},gi=()=>{const{srcToken:e,dstToken:t,chainId:n}=q();return S.useMemo(()=>Vn(e,t,n),[e,t,n])},Ai=()=>{const e=yi(),t=gi();return e||t},rt=()=>{const{srcToken:e,typedInputAmount:t}=q();return{amount:Gn(e==null?void 0:e.decimals,t),amountUI:t,error:x(t||0).isZero()?"enterAmount":void 0}},Ei=(e,t)=>{const{module:n,srcUsd1Token:r,marketPrice:s,minChunkSizeUsd:a,typedInputAmount:o}=q();return S.useMemo(()=>{if(x(o||"0").isZero()||!s||x(r||"0").isZero())return;if(!e)return{type:me.MIN_CHUNKS,value:1,args:{minChunks:"1"}};const{isError:d}=Ma(e,t,n);if(d)return{type:me.MAX_CHUNKS,value:t,args:{maxChunks:`${t}`}};const{isError:p,value:f}=ka(o||"",r||"",a||0);if(p)return{type:me.MIN_TRADE_SIZE,value:f,args:{minTradeSize:`${f}`}}},[e,t,n,o,r,a,s])},qe=()=>{const{srcToken:e,srcUsd1Token:t,module:n,minChunkSizeUsd:r}=q(),s=Q(O=>O.state.typedChunks),a=Q(O=>O.updateState),{amount:o,amountUI:d}=rt(),p=S.useMemo(()=>ba(d||"",t||"",r||0),[d,t,r]),f=S.useMemo(()=>Ea(p,n,s),[p,s,n]),w=S.useCallback(O=>a({typedChunks:O}),[a]),C=S.useMemo(()=>wa(o||"",f),[o,f]),v=en(e==null?void 0:e.decimals,C),F=S.useMemo(()=>t?x(v||"0").times(t||0).toString():"0",[v,t]);return{totalTrades:f,maxTrades:p,amountPerTradeUI:v,amountPerTrade:C,amountPerTradeUsd:F,onChange:w,error:Ei(f,p)}},bi=()=>{const{srcToken:e,dstToken:t}=q(),{onChange:n,totalTrades:r,amountPerTradeUsd:s,amountPerTradeUI:a,error:o,maxTrades:d,amountPerTrade:p}=qe();return{error:o,maxTrades:d,totalTrades:r,amountPerTradeUI:a,amountPerTrade:p,onChange:n,amountPerTradeUsd:s,fromToken:e,toToken:t}},Ci=e=>{const{totalTrades:t}=qe(),{marketPrice:n,typedInputAmount:r}=q(),s=S.useMemo(()=>{const{isError:o,value:d}=Ia(e);if(!(!o||x(r||"0").isZero()||!n))return{type:me.MIN_FILL_DELAY,value:d}},[e,r,n]),a=S.useMemo(()=>{const{isError:o,value:d}=va(e,t);if(!(!o||x(r||"0").isZero()||!n))return{type:me.MAX_FILL_DELAY,value:d}},[e,r,n,t]);return s||a},Lt=()=>{const{callbacks:e}=q(),t=Q(a=>a.state.typedFillDelay),n=Q(a=>a.updateState),r=S.useMemo(()=>t||Mn,[t]),s=Ci(r);return{fillDelay:r,onChange:S.useCallback(a=>{var o;n({typedFillDelay:a}),(o=e==null?void 0:e.onFillDelayChange)==null||o.call(e,a)},[n,e]),error:s,milliseconds:r.unit*r.value}},Ti=()=>{const{onChange:e,fillDelay:t,error:n}=Lt(),r=S.useCallback(a=>e({unit:t.unit,value:Number(a)}),[e,t]),s=S.useCallback(a=>e({unit:a,value:t.value}),[e,t]);return{onInputChange:r,onUnitSelect:s,onChange:e,milliseconds:t.unit*t.value,fillDelay:t,error:n}},wi=e=>{const{module:t,marketPrice:n}=q();return S.useMemo(()=>{const r=Da(t,e),s=Oa(e);if(n){if(r.isError)return{type:me.MAX_ORDER_DURATION,value:r.value,args:{duration:`${Math.floor(Vr(r.value)).toFixed(0)} days`}};if(s.isError)return{type:me.MIN_ORDER_DURATION,value:s.value,args:{duration:`${Math.floor(Gr(s.value)).toFixed(0)} minutes`}}}},[e,t,n])},Xn=()=>{const{module:e,callbacks:t}=q(),n=Q(p=>p.state.typedDuration),r=Q(p=>p.updateState),s=qe().totalTrades,a=Lt().fillDelay,o=S.useMemo(()=>Aa(e,s,a,n),[s,a,n,e]),d=wi(o);return{duration:o,setDuration:S.useCallback(p=>{var f;r({typedDuration:p}),(f=t==null?void 0:t.onDurationChange)==null||f.call(t,p)},[r,t]),error:d}},vi=()=>{const{duration:e,setDuration:t,error:n}=Xn(),r=S.useCallback(a=>{t({unit:e.unit,value:Number(a)})},[t,e]),s=S.useCallback(a=>{t({unit:a,value:e.value})},[t,e]);return{duration:e,onChange:t,milliseconds:e.unit*e.value,onInputChange:r,onUnitSelect:s,error:n}},xi=()=>{const{module:e}=q();return S.useMemo(()=>e===$.STOP_LOSS?sa:aa,[e])},Zn=()=>{const{module:e}=q(),t=Q(n=>n.state.isMarketOrder);return S.useMemo(()=>e!==$.STOP_LOSS&&e!==$.TAKE_PROFIT||t?void 0:e===$.STOP_LOSS?ia:oa,[e,t])},gn=()=>{const{srcToken:e,dstToken:t,marketPriceLoading:n}=q(),r=Q(f=>f.updateState),s=Q(f=>f.state.isInvertedTrade),a=Q(f=>f.state.typedTriggerPrice),o=Q(f=>f.state.typedLimitPrice),d=Q(f=>f.state.isMarketOrder);return{onInvert:S.useCallback(()=>{a!==void 0&&r({typedTriggerPrice:x(1).div(a).toFixed()}),o!==void 0&&r({typedLimitPrice:x(1).div(o).toFixed()}),r({isInvertedTrade:!s})},[r,s,a,o,n]),isInverted:s,fromToken:s?t:e,toToken:s?e:t,isMarketPrice:d}},Xr=({typedValue:e,tokenDecimals:t=18,initialPrice:n="0",percentage:r,setValue:s,setPercentage:a})=>{const{srcUsd1Token:o,dstUsd1Token:d}=q(),{isInverted:p}=gn(),f=S.useMemo(()=>x((()=>{if(e!==void 0){const M=p?x(e).isZero()?x(0):x(1).div(e):x(e);return Et(M.toFixed(),t)}if(r!==void 0&&x(n||"0").gt(0)&&!x(n||"0").isNaN()){const M=x(n||"0"),_=x(r||0).div(100);return M.plus(M.multipliedBy(_)).decimalPlaces(0).toFixed()}return x(n).gt(0)?n:""})()).decimalPlaces(0).toFixed(),[e,r,t,n,p]),w=S.useCallback(I=>{s(I),a(null)},[s,a]),C=S.useCallback(I=>{s(void 0),a(I)},[s,a]),v=S.useMemo(()=>{if(!n||x(n).isZero())return"";if(r!=null)return r;if(f){const I=x(n),_=x(f).minus(I).div(I).multipliedBy(100).decimalPlaces(2).toString();return x(_||"0").isZero()?"":_}return""},[f,n,r]),F=S.useMemo(()=>{let I="";if(e!==void 0)I=e;else{const M=Ee(f,t);if(x(M||"0").isZero())return"";I=p?x(1).div(M).toFixed():M}return I},[e,t,f,p]),O=nt(p?o:d,F||"0");return{amount:x(f).isNaN()?"":f,amountUI:x(F).isNaN()?"":F,selectedPercentage:v,onChange:w,onPercentageChange:C,isInverted:p,usd:x(O).isNaN()?"":O,isTypedValue:e!==void 0}},Si=(e="")=>{const{module:t,marketPrice:n,typedInputAmount:r}=q();return S.useMemo(()=>{if(x(r||"0").isZero()||!n||t!==$.STOP_LOSS&&t!==$.TAKE_PROFIT)return;const s=xa(n||"",e||"",t);if(s!=null&&s.isError)return{type:me.STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE,value:s.value};const a=Sa(n||"",e||"",t);if(a!=null&&a.isError)return{type:me.TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE,value:a.value};if(!e||x(e||0).isZero())return{type:me.EMPTY_TRIGGER_PRICE,value:e}},[n,e,t,r])},Fi=e=>{const{srcToken:t,dstToken:n,module:r,dstUsd1Token:s}=q(),a=qe().amountPerTrade,o=Q(f=>f.state.isMarketOrder),d=S.useMemo(()=>ga(r,a,e,(t==null?void 0:t.decimals)||0),[e,a,o,t==null?void 0:t.decimals,r]),p=en((n==null?void 0:n.decimals)||0,d);return{amount:d,amountUI:p,usd:nt(p,s)}},bt=()=>{const{dstToken:e,marketPrice:t,module:n,callbacks:r}=q(),s=Q(O=>O.updateState),a=xi(),o=Q(O=>O.state.triggerPricePercent),d=o===void 0?a:o,p=n===$.STOP_LOSS||n===$.TAKE_PROFIT,f=Xr({typedValue:Q(O=>O.state.typedTriggerPrice),percentage:d,tokenDecimals:(e==null?void 0:e.decimals)||18,initialPrice:p?t:void 0,setValue:S.useCallback(O=>{var I;s({typedTriggerPrice:O}),(I=r==null?void 0:r.onTriggerPriceChange)==null||I.call(r,O||"")},[s,r]),setPercentage:S.useCallback(O=>{var I;s({triggerPricePercent:O}),(I=r==null?void 0:r.onTriggerPricePercentChange)==null||I.call(r,O||"")},[s,r])}),w=Si(f.amount),{amount:C,amountUI:v,usd:F}=Fi(f.amount);return S.useMemo(()=>({...f,error:w,pricePerChunk:C,pricePerChunkUI:v,pricePerChunkUsd:F}),[f,w,C,v,F])},Pi=e=>{const{module:t,marketPrice:n,typedInputAmount:r}=q(),{amount:s}=bt(),a=Q(o=>o.state.isMarketOrder);return S.useMemo(()=>{if(x(r||"0").isZero()||!s||!n)return;const o=Fa(s,e,a,t),d=Pa(s,e,a,t);if(o!=null&&o.isError)return{type:me.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,value:o.value};if(d!=null&&d.isError)return{type:me.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,value:d.value};if(e&&x(e||0).isZero())return{type:me.MISSING_LIMIT_PRICE,value:e||""}},[e,s,t,a,r,n])},An=()=>{const{dstToken:e,marketPrice:t,callbacks:n}=q(),r=Q(f=>f.updateState),s=Zn(),a=Q(f=>f.state.limitPricePercent),o=a===void 0?s:a,d=Xr({typedValue:Q(f=>f.state.typedLimitPrice),percentage:o,tokenDecimals:(e==null?void 0:e.decimals)||18,initialPrice:t,setValue:S.useCallback(f=>{var w;r({typedLimitPrice:f}),(w=n==null?void 0:n.onLimitPriceChange)==null||w.call(n,f||"")},[r,n]),setPercentage:S.useCallback(f=>{var w;r({limitPricePercent:f}),(w=n==null?void 0:n.onLimitPricePercentChange)==null||w.call(n,f||"")},[r,n])}),p=Pi(d.amount);return S.useMemo(()=>({...d,error:p}),[d,p])},Di=()=>{const{module:e}=q(),t=Q(d=>d.updateState),n=Q(d=>d.state.isMarketOrder),r=Zn(),s=Q(d=>d.state.triggerPricePercent)||0,a=e===$.LIMIT,o=S.useCallback(()=>{!n&&e===$.STOP_LOSS&&t({limitPricePercent:r}),t({isMarketOrder:!n})},[t,s,e,n,r]);return{isLimitPrice:!n,toggleLimitPrice:o,hide:a}},Oi=()=>{const{module:e,marketPriceLoading:t,srcToken:n,dstToken:r}=q(),{amount:s,amountUI:a,onChange:o,onPercentageChange:d,usd:p,selectedPercentage:f,error:w,isTypedValue:C}=An(),v=Q(K=>K.updateState),F=Zn(),{isLimitPrice:O,toggleLimitPrice:I}=Di(),{fromToken:M,toToken:_}=gn(),P=S.useCallback(()=>{v({typedLimitPrice:void 0}),v({limitPricePercent:F})},[v,e,F]);return{price:s,priceUI:a,error:w,onInputChange:o,onPercentageChange:d,onReset:P,usd:p,srcToken:n,dstToken:r,invertedSrcToken:M,invertedDstToken:_,percentage:f,isLoading:t,isLimitPrice:O,toggleLimitPrice:I,isTypedValue:C}},Ii=()=>{const{marketPrice:e,marketPriceLoading:t,srcToken:n,dstToken:r}=q(),{amount:s,amountUI:a,onChange:o,onPercentageChange:d,usd:p,selectedPercentage:f,error:w,pricePerChunk:C,pricePerChunkUI:v,pricePerChunkUsd:F,isTypedValue:O}=bt(),I=Q(K=>K.updateState),{fromToken:M,toToken:_}=gn(),P=S.useCallback(()=>{I({triggerPricePercent:void 0,typedTriggerPrice:void 0})},[I]);return{price:s,priceUI:a,amountPerChunk:C,amountPerChunkUI:v,amountPerChunkUsd:F,error:w,onInputChange:o,onPercentageChange:d,percentage:f,onReset:P,usd:p,srcToken:n,dstToken:r,invertedSrcToken:M,invertedDstToken:_,isLoading:t||!e,isTypedValue:O}},Zr=()=>{const{module:e,marketPrice:t}=q(),n=An().amount,r=bt().amount,s=Q(a=>a.state.isMarketOrder);return e===$.LIMIT||!s?n||"":e===$.STOP_LOSS||e===$.TAKE_PROFIT?r||"":t||""},En=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:n}=q(),r=Zr(),s=rt().amount,a=S.useMemo(()=>ma(s||"",r,(e==null?void 0:e.decimals)||0),[s,r,e==null?void 0:e.decimals]),o=en(t==null?void 0:t.decimals,a);return{amount:a,amountUI:o,usd:nt(o,n)}},Yn=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:n}=q(),r=Zr(),s=qe().amountPerTrade,a=Q(p=>p.state.isMarketOrder),o=S.useMemo(()=>ya(s,r,!!a,(e==null?void 0:e.decimals)||0),[s,r,a,e==null?void 0:e.decimals]),d=en(t==null?void 0:t.decimals,o);return{amount:o,amountUI:d,usd:nt(d,n)}},ki=()=>{const{typedInputAmount:e,marketPriceLoading:t,dstToken:n}=q(),{amountUI:r,usd:s}=En(),o=Ai()?e:r,d=Gn(n==null?void 0:n.decimals,o);return{value:o,valueWei:d,isLoading:t,usd:s}},Mi=()=>{const e=Q(s=>s.state.isMarketOrder),{module:t}=q(),n=S.useMemo(()=>{if(e&&t===$.STOP_LOSS)return Jt.TRIGGER_MARKET_PRICE},[e,t]),r=S.useMemo(()=>{if(!(t!==$.LIMIT&&t!==$.TWAP))return e?Jt.MARKET_PRICE:Jt.LIMIT_PRICE},[e,t]);return n||r},Bi=()=>{const{minChunkSizeUsd:e,typedInputAmount:t,srcUsd1Token:n}=q(),r=nt(t,n);return S.useMemo(()=>x(e).gt(x(r||"0"))?{type:me.MIN_TRADE_SIZE_ERROR,value:e}:void 0,[e,r])};function Yr(){const{marketPrice:e,marketPriceLoading:t,typedInputAmount:n,srcUsd1Token:r,srcBalance:s,chainId:a}=q(),{error:o}=bt(),{error:d}=An(),{error:p}=qe(),{error:f}=Lt(),{error:w}=Xn(),C=Bi(),v=rt().amount,F=S.useMemo(()=>{if(s&&x(v).gt(s))return{type:me.INSUFFICIENT_BALANCE,value:s||""}},[s,v,a]);return S.useMemo(()=>_a({marketPrice:e,typedInputAmount:n,srcUsd1Token:r,marketPriceLoading:t,triggerPriceError:o,limitPriceError:d,tradesError:p,fillDelayError:f,durationError:w,balanceError:F,minTradeSizeError:C}),[e,t,n,o,d,p,f,w,F,r,C])}var Nt=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},_i={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Ui=(Ps=class{constructor(){N(this,Ke,_i);N(this,vt,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&l(this,vt)&&e!==l(this,Ke)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:l(this,Ke),provider:e}),B(this,Ke,e),process.env.NODE_ENV!=="production"&&B(this,vt,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&B(this,vt,!0),l(this,Ke).setTimeout(e,t)}clearTimeout(e){l(this,Ke).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&B(this,vt,!0),l(this,Ke).setInterval(e,t)}clearInterval(e){l(this,Ke).clearInterval(e)}},Ke=new WeakMap,vt=new WeakMap,Ps),Ct=new Ui;function Ri(e){setTimeout(e,0)}var Tt=typeof window>"u"||"Deno"in globalThis;function be(){}function Li(e,t){return typeof e=="function"?e(t):e}function Jn(e){return typeof e=="number"&&e>=0&&e!==1/0}function Jr(e,t){return Math.max(e+(t||0)-Date.now(),0)}function st(e,t){return typeof e=="function"?e(t):e}function ke(e,t){return typeof e=="function"?e(t):e}function es(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:a,queryKey:o,stale:d}=e;if(o){if(r){if(t.queryHash!==er(o,t.options))return!1}else if(!tn(t.queryKey,o))return!1}if(n!=="all"){const p=t.isActive();if(n==="active"&&!p||n==="inactive"&&p)return!1}return!(typeof d=="boolean"&&t.isStale()!==d||s&&s!==t.state.fetchStatus||a&&!a(t))}function ts(e,t){const{exact:n,status:r,predicate:s,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(wt(t.options.mutationKey)!==wt(a))return!1}else if(!tn(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function er(e,t){return((t==null?void 0:t.queryKeyHashFn)||wt)(e)}function wt(e){return JSON.stringify(e,(t,n)=>nr(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function tn(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>tn(e[n],t[n])):!1}var Ni=Object.prototype.hasOwnProperty;function tr(e,t){if(e===t)return e;const n=ns(e)&&ns(t);if(!n&&!(nr(e)&&nr(t)))return t;const s=(n?e:Object.keys(e)).length,a=n?t:Object.keys(t),o=a.length,d=n?new Array(o):{};let p=0;for(let f=0;f<o;f++){const w=n?f:a[f],C=e[w],v=t[w];if(C===v){d[w]=C,(n?f<s:Ni.call(e,w))&&p++;continue}if(C===null||v===null||typeof C!="object"||typeof v!="object"){d[w]=v;continue}const F=tr(C,v);d[w]=F,F===C&&p++}return s===o&&p===s?e:d}function bn(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function ns(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function nr(e){if(!rs(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!rs(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function rs(e){return Object.prototype.toString.call(e)==="[object Object]"}function qi(e){return new Promise(t=>{Ct.setTimeout(t,e)})}function rr(e,t,n){if(typeof n.structuralSharing=="function")return n.structuralSharing(e,t);if(n.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return tr(e,t)}catch(r){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${r}`),r}return tr(e,t)}return t}function Ki(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Hi(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Cn=Symbol();function ss(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Cn&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Cn?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function as(e,t){return typeof e=="function"?e(...t):!!e}var Wi=(Ds=class extends Nt{constructor(){super();N(this,xt);N(this,it);N(this,qt);B(this,qt,t=>{if(!Tt&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){l(this,it)||this.setEventListener(l(this,qt))}onUnsubscribe(){var t;this.hasListeners()||((t=l(this,it))==null||t.call(this),B(this,it,void 0))}setEventListener(t){var n;B(this,qt,t),(n=l(this,it))==null||n.call(this),B(this,it,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){l(this,xt)!==t&&(B(this,xt,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof l(this,xt)=="boolean"?l(this,xt):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},xt=new WeakMap,it=new WeakMap,qt=new WeakMap,Ds),sr=new Wi;function ar(){let e,t;const n=new Promise((s,a)=>{e=s,t=a});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}var Qi=Ri;function ji(){let e=[],t=0,n=d=>{d()},r=d=>{d()},s=Qi;const a=d=>{t?e.push(d):s(()=>{n(d)})},o=()=>{const d=e;e=[],d.length&&s(()=>{r(()=>{d.forEach(p=>{n(p)})})})};return{batch:d=>{let p;t++;try{p=d()}finally{t--,t||o()}return p},batchCalls:d=>(...p)=>{a(()=>{d(...p)})},schedule:a,setNotifyFunction:d=>{n=d},setBatchNotifyFunction:d=>{r=d},setScheduler:d=>{s=d}}}var ue=ji(),zi=(Os=class extends Nt{constructor(){super();N(this,Kt,!0);N(this,ot);N(this,Ht);B(this,Ht,t=>{if(!Tt&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){l(this,ot)||this.setEventListener(l(this,Ht))}onUnsubscribe(){var t;this.hasListeners()||((t=l(this,ot))==null||t.call(this),B(this,ot,void 0))}setEventListener(t){var n;B(this,Ht,t),(n=l(this,ot))==null||n.call(this),B(this,ot,t(this.setOnline.bind(this)))}setOnline(t){l(this,Kt)!==t&&(B(this,Kt,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return l(this,Kt)}},Kt=new WeakMap,ot=new WeakMap,Ht=new WeakMap,Os),Tn=new zi;function $i(e){return Math.min(1e3*2**e,3e4)}function is(e){return(e??"online")==="online"?Tn.isOnline():!0}var ir=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function os(e){let t=!1,n=0,r;const s=ar(),a=()=>s.status!=="pending",o=I=>{var M;if(!a()){const _=new ir(I);v(_),(M=e.onCancel)==null||M.call(e,_)}},d=()=>{t=!0},p=()=>{t=!1},f=()=>sr.isFocused()&&(e.networkMode==="always"||Tn.isOnline())&&e.canRun(),w=()=>is(e.networkMode)&&e.canRun(),C=I=>{a()||(r==null||r(),s.resolve(I))},v=I=>{a()||(r==null||r(),s.reject(I))},F=()=>new Promise(I=>{var M;r=_=>{(a()||f())&&I(_)},(M=e.onPause)==null||M.call(e)}).then(()=>{var I;r=void 0,a()||(I=e.onContinue)==null||I.call(e)}),O=()=>{if(a())return;let I;const M=n===0?e.initialPromise:void 0;try{I=M??e.fn()}catch(_){I=Promise.reject(_)}Promise.resolve(I).then(C).catch(_=>{var Y;if(a())return;const P=e.retry??(Tt?0:3),K=e.retryDelay??$i,U=typeof K=="function"?K(n,_):K,Z=P===!0||typeof P=="number"&&n<P||typeof P=="function"&&P(n,_);if(t||!Z){v(_);return}n++,(Y=e.onFail)==null||Y.call(e,n,_),qi(U).then(()=>f()?void 0:F()).then(()=>{t?v(_):O()})})};return{promise:s,status:()=>s.status,cancel:o,continue:()=>(r==null||r(),s),cancelRetry:d,continueRetry:p,canStart:w,start:()=>(w()?O():F().then(O),s)}}var cs=(Is=class{constructor(){N(this,St)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Jn(this.gcTime)&&B(this,St,Ct.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Tt?1/0:300*1e3))}clearGcTimeout(){l(this,St)&&(Ct.clearTimeout(l(this,St)),B(this,St,void 0))}},St=new WeakMap,Is),Vi=(ks=class extends cs{constructor(t){super();N(this,Re);N(this,Ft);N(this,Wt);N(this,Me);N(this,Pt);N(this,fe);N(this,rn);N(this,Dt);B(this,Dt,!1),B(this,rn,t.defaultOptions),this.setOptions(t.options),this.observers=[],B(this,Pt,t.client),B(this,Me,l(this,Pt).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,B(this,Ft,ls(this.options)),this.state=t.state??l(this,Ft),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=l(this,fe))==null?void 0:t.promise}setOptions(t){if(this.options={...l(this,rn),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=ls(this.options);n.data!==void 0&&(this.setState(ds(n.data,n.dataUpdatedAt)),B(this,Ft,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&l(this,Me).remove(this)}setData(t,n){const r=rr(this.state.data,t,this.options);return j(this,Re,Je).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){j(this,Re,Je).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,s;const n=(r=l(this,fe))==null?void 0:r.promise;return(s=l(this,fe))==null||s.cancel(t),n?n.then(be).catch(be):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(l(this,Ft))}isActive(){return this.observers.some(t=>ke(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Cn||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>st(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!Jr(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=l(this,fe))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=l(this,fe))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),l(this,Me).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(l(this,fe)&&(l(this,Dt)?l(this,fe).cancel({revert:!0}):l(this,fe).cancelRetry()),this.scheduleGc()),l(this,Me).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||j(this,Re,Je).call(this,{type:"invalidate"})}async fetch(t,n){var p,f,w,C,v,F,O,I,M,_,P,K;if(this.state.fetchStatus!=="idle"&&((p=l(this,fe))==null?void 0:p.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(l(this,fe))return l(this,fe).continueRetry(),l(this,fe).promise}if(t&&this.setOptions(t),!this.options.queryFn){const U=this.observers.find(Z=>Z.options.queryFn);U&&this.setOptions(U.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,s=U=>{Object.defineProperty(U,"signal",{enumerable:!0,get:()=>(B(this,Dt,!0),r.signal)})},a=()=>{const U=ss(this.options,n),Y=(()=>{const oe={client:l(this,Pt),queryKey:this.queryKey,meta:this.meta};return s(oe),oe})();return B(this,Dt,!1),this.options.persister?this.options.persister(U,Y,this):U(Y)},d=(()=>{const U={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:l(this,Pt),state:this.state,fetchFn:a};return s(U),U})();(f=this.options.behavior)==null||f.onFetch(d,this),B(this,Wt,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((w=d.fetchOptions)==null?void 0:w.meta))&&j(this,Re,Je).call(this,{type:"fetch",meta:(C=d.fetchOptions)==null?void 0:C.meta}),B(this,fe,os({initialPromise:n==null?void 0:n.initialPromise,fn:d.fetchFn,onCancel:U=>{U instanceof ir&&U.revert&&this.setState({...l(this,Wt),fetchStatus:"idle"}),r.abort()},onFail:(U,Z)=>{j(this,Re,Je).call(this,{type:"failed",failureCount:U,error:Z})},onPause:()=>{j(this,Re,Je).call(this,{type:"pause"})},onContinue:()=>{j(this,Re,Je).call(this,{type:"continue"})},retry:d.options.retry,retryDelay:d.options.retryDelay,networkMode:d.options.networkMode,canRun:()=>!0}));try{const U=await l(this,fe).start();if(U===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(U),(F=(v=l(this,Me).config).onSuccess)==null||F.call(v,U,this),(I=(O=l(this,Me).config).onSettled)==null||I.call(O,U,this.state.error,this),U}catch(U){if(U instanceof ir){if(U.silent)return l(this,fe).promise;if(U.revert){if(this.state.data===void 0)throw U;return this.state.data}}throw j(this,Re,Je).call(this,{type:"error",error:U}),(_=(M=l(this,Me).config).onError)==null||_.call(M,U,this),(K=(P=l(this,Me).config).onSettled)==null||K.call(P,this.state.data,U,this),U}finally{this.scheduleGc()}}},Ft=new WeakMap,Wt=new WeakMap,Me=new WeakMap,Pt=new WeakMap,fe=new WeakMap,rn=new WeakMap,Dt=new WeakMap,Re=new WeakSet,Je=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...us(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...ds(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return B(this,Wt,t.manual?s:void 0),s;case"error":const a=t.error;return{...r,error:a,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),ue.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),l(this,Me).notify({query:this,type:"updated",action:t})})},ks);function us(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:is(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function ds(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function ls(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Gi=(Ms=class extends Nt{constructor(t,n){super();N(this,ee);N(this,Se);N(this,X);N(this,sn);N(this,Ce);N(this,Ot);N(this,Qt);N(this,Ve);N(this,ct);N(this,an);N(this,jt);N(this,zt);N(this,It);N(this,kt);N(this,ut);N(this,$t,new Set);this.options=n,B(this,Se,t),B(this,ct,null),B(this,Ve,ar()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(l(this,X).addObserver(this),ps(l(this,X),this.options)?j(this,ee,dn).call(this):this.updateResult(),j(this,ee,Er).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return or(l(this,X),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return or(l(this,X),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,j(this,ee,br).call(this),j(this,ee,Cr).call(this),l(this,X).removeObserver(this)}setOptions(t){const n=this.options,r=l(this,X);if(this.options=l(this,Se).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ke(this.options.enabled,l(this,X))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");j(this,ee,Tr).call(this),l(this,X).setOptions(this.options),n._defaulted&&!bn(this.options,n)&&l(this,Se).getQueryCache().notify({type:"observerOptionsUpdated",query:l(this,X),observer:this});const s=this.hasListeners();s&&fs(l(this,X),r,this.options,n)&&j(this,ee,dn).call(this),this.updateResult(),s&&(l(this,X)!==r||ke(this.options.enabled,l(this,X))!==ke(n.enabled,l(this,X))||st(this.options.staleTime,l(this,X))!==st(n.staleTime,l(this,X)))&&j(this,ee,yr).call(this);const a=j(this,ee,gr).call(this);s&&(l(this,X)!==r||ke(this.options.enabled,l(this,X))!==ke(n.enabled,l(this,X))||a!==l(this,ut))&&j(this,ee,Ar).call(this,a)}getOptimisticResult(t){const n=l(this,Se).getQueryCache().build(l(this,Se),t),r=this.createResult(n,t);return Zi(this,r)&&(B(this,Ce,r),B(this,Qt,this.options),B(this,Ot,l(this,X).state)),r}getCurrentResult(){return l(this,Ce)}trackResult(t,n){return new Proxy(t,{get:(r,s)=>(this.trackProp(s),n==null||n(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&l(this,Ve).status==="pending"&&l(this,Ve).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(t){l(this,$t).add(t)}getCurrentQuery(){return l(this,X)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=l(this,Se).defaultQueryOptions(t),r=l(this,Se).getQueryCache().build(l(this,Se),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return j(this,ee,dn).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),l(this,Ce)))}createResult(t,n){var c;const r=l(this,X),s=this.options,a=l(this,Ce),o=l(this,Ot),d=l(this,Qt),f=t!==r?t.state:l(this,sn),{state:w}=t;let C={...w},v=!1,F;if(n._optimisticResults){const u=this.hasListeners(),A=!u&&ps(t,n),m=u&&fs(t,r,n,s);(A||m)&&(C={...C,...us(w.data,t.options)}),n._optimisticResults==="isRestoring"&&(C.fetchStatus="idle")}let{error:O,errorUpdatedAt:I,status:M}=C;F=C.data;let _=!1;if(n.placeholderData!==void 0&&F===void 0&&M==="pending"){let u;a!=null&&a.isPlaceholderData&&n.placeholderData===(d==null?void 0:d.placeholderData)?(u=a.data,_=!0):u=typeof n.placeholderData=="function"?n.placeholderData((c=l(this,zt))==null?void 0:c.state.data,l(this,zt)):n.placeholderData,u!==void 0&&(M="success",F=rr(a==null?void 0:a.data,u,n),v=!0)}if(n.select&&F!==void 0&&!_)if(a&&F===(o==null?void 0:o.data)&&n.select===l(this,an))F=l(this,jt);else try{B(this,an,n.select),F=n.select(F),F=rr(a==null?void 0:a.data,F,n),B(this,jt,F),B(this,ct,null)}catch(u){B(this,ct,u)}l(this,ct)&&(O=l(this,ct),F=l(this,jt),I=Date.now(),M="error");const P=C.fetchStatus==="fetching",K=M==="pending",U=M==="error",Z=K&&P,Y=F!==void 0,i={status:M,fetchStatus:C.fetchStatus,isPending:K,isSuccess:M==="success",isError:U,isInitialLoading:Z,isLoading:Z,data:F,dataUpdatedAt:C.dataUpdatedAt,error:O,errorUpdatedAt:I,failureCount:C.fetchFailureCount,failureReason:C.fetchFailureReason,errorUpdateCount:C.errorUpdateCount,isFetched:C.dataUpdateCount>0||C.errorUpdateCount>0,isFetchedAfterMount:C.dataUpdateCount>f.dataUpdateCount||C.errorUpdateCount>f.errorUpdateCount,isFetching:P,isRefetching:P&&!K,isLoadingError:U&&!Y,isPaused:C.fetchStatus==="paused",isPlaceholderData:v,isRefetchError:U&&Y,isStale:cr(t,n),refetch:this.refetch,promise:l(this,Ve),isEnabled:ke(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const u=y=>{i.status==="error"?y.reject(i.error):i.data!==void 0&&y.resolve(i.data)},A=()=>{const y=B(this,Ve,i.promise=ar());u(y)},m=l(this,Ve);switch(m.status){case"pending":t.queryHash===r.queryHash&&u(m);break;case"fulfilled":(i.status==="error"||i.data!==m.value)&&A();break;case"rejected":(i.status!=="error"||i.error!==m.reason)&&A();break}}return i}updateResult(){const t=l(this,Ce),n=this.createResult(l(this,X),this.options);if(B(this,Ot,l(this,X).state),B(this,Qt,this.options),l(this,Ot).data!==void 0&&B(this,zt,l(this,X)),bn(n,t))return;B(this,Ce,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!l(this,$t).size)return!0;const o=new Set(a??l(this,$t));return this.options.throwOnError&&o.add("error"),Object.keys(l(this,Ce)).some(d=>{const p=d;return l(this,Ce)[p]!==t[p]&&o.has(p)})};j(this,ee,qs).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&j(this,ee,Er).call(this)}},Se=new WeakMap,X=new WeakMap,sn=new WeakMap,Ce=new WeakMap,Ot=new WeakMap,Qt=new WeakMap,Ve=new WeakMap,ct=new WeakMap,an=new WeakMap,jt=new WeakMap,zt=new WeakMap,It=new WeakMap,kt=new WeakMap,ut=new WeakMap,$t=new WeakMap,ee=new WeakSet,dn=function(t){j(this,ee,Tr).call(this);let n=l(this,X).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(be)),n},yr=function(){j(this,ee,br).call(this);const t=st(this.options.staleTime,l(this,X));if(Tt||l(this,Ce).isStale||!Jn(t))return;const r=Jr(l(this,Ce).dataUpdatedAt,t)+1;B(this,It,Ct.setTimeout(()=>{l(this,Ce).isStale||this.updateResult()},r))},gr=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(l(this,X)):this.options.refetchInterval)??!1},Ar=function(t){j(this,ee,Cr).call(this),B(this,ut,t),!(Tt||ke(this.options.enabled,l(this,X))===!1||!Jn(l(this,ut))||l(this,ut)===0)&&B(this,kt,Ct.setInterval(()=>{(this.options.refetchIntervalInBackground||sr.isFocused())&&j(this,ee,dn).call(this)},l(this,ut)))},Er=function(){j(this,ee,yr).call(this),j(this,ee,Ar).call(this,j(this,ee,gr).call(this))},br=function(){l(this,It)&&(Ct.clearTimeout(l(this,It)),B(this,It,void 0))},Cr=function(){l(this,kt)&&(Ct.clearInterval(l(this,kt)),B(this,kt,void 0))},Tr=function(){const t=l(this,Se).getQueryCache().build(l(this,Se),this.options);if(t===l(this,X))return;const n=l(this,X);B(this,X,t),B(this,sn,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},qs=function(t){ue.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(l(this,Ce))}),l(this,Se).getQueryCache().notify({query:l(this,X),type:"observerResultsUpdated"})})},Ms);function Xi(e,t){return ke(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function ps(e,t){return Xi(e,t)||e.state.data!==void 0&&or(e,t,t.refetchOnMount)}function or(e,t,n){if(ke(t.enabled,e)!==!1&&st(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&cr(e,t)}return!1}function fs(e,t,n,r){return(e!==t||ke(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&cr(e,n)}function cr(e,t){return ke(t.enabled,e)!==!1&&e.isStaleByTime(st(t.staleTime,e))}function Zi(e,t){return!bn(e.getCurrentResult(),t)}function hs(e){return{onFetch:(t,n)=>{var w,C,v,F,O;const r=t.options,s=(v=(C=(w=t.fetchOptions)==null?void 0:w.meta)==null?void 0:C.fetchMore)==null?void 0:v.direction,a=((F=t.state.data)==null?void 0:F.pages)||[],o=((O=t.state.data)==null?void 0:O.pageParams)||[];let d={pages:[],pageParams:[]},p=0;const f=async()=>{let I=!1;const M=K=>{Object.defineProperty(K,"signal",{enumerable:!0,get:()=>(t.signal.aborted?I=!0:t.signal.addEventListener("abort",()=>{I=!0}),t.signal)})},_=ss(t.options,t.fetchOptions),P=async(K,U,Z)=>{if(I)return Promise.reject();if(U==null&&K.pages.length)return Promise.resolve(K);const oe=(()=>{const A={client:t.client,queryKey:t.queryKey,pageParam:U,direction:Z?"backward":"forward",meta:t.options.meta};return M(A),A})(),i=await _(oe),{maxPages:c}=t.options,u=Z?Hi:Ki;return{pages:u(K.pages,i,c),pageParams:u(K.pageParams,U,c)}};if(s&&a.length){const K=s==="backward",U=K?Yi:ms,Z={pages:a,pageParams:o},Y=U(r,Z);d=await P(Z,Y,K)}else{const K=e??a.length;do{const U=p===0?o[0]??r.initialPageParam:ms(r,d);if(p>0&&U==null)break;d=await P(d,U),p++}while(p<K)}return d};t.options.persister?t.fetchFn=()=>{var I,M;return(M=(I=t.options).persister)==null?void 0:M.call(I,f,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=f}}}function ms(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Yi(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var Ji=(Bs=class extends cs{constructor(t){super();N(this,We);N(this,on);N(this,He);N(this,Te);N(this,Mt);B(this,on,t.client),this.mutationId=t.mutationId,B(this,Te,t.mutationCache),B(this,He,[]),this.state=t.state||ys(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){l(this,He).includes(t)||(l(this,He).push(t),this.clearGcTimeout(),l(this,Te).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){B(this,He,l(this,He).filter(n=>n!==t)),this.scheduleGc(),l(this,Te).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){l(this,He).length||(this.state.status==="pending"?this.scheduleGc():l(this,Te).remove(this))}continue(){var t;return((t=l(this,Mt))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,d,p,f,w,C,v,F,O,I,M,_,P,K,U,Z,Y,oe,i,c;const n=()=>{j(this,We,ht).call(this,{type:"continue"})},r={client:l(this,on),meta:this.options.meta,mutationKey:this.options.mutationKey};B(this,Mt,os({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(u,A)=>{j(this,We,ht).call(this,{type:"failed",failureCount:u,error:A})},onPause:()=>{j(this,We,ht).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>l(this,Te).canRun(this)}));const s=this.state.status==="pending",a=!l(this,Mt).canStart();try{if(s)n();else{j(this,We,ht).call(this,{type:"pending",variables:t,isPaused:a}),await((d=(o=l(this,Te).config).onMutate)==null?void 0:d.call(o,t,this,r));const A=await((f=(p=this.options).onMutate)==null?void 0:f.call(p,t,r));A!==this.state.context&&j(this,We,ht).call(this,{type:"pending",context:A,variables:t,isPaused:a})}const u=await l(this,Mt).start();return await((C=(w=l(this,Te).config).onSuccess)==null?void 0:C.call(w,u,t,this.state.context,this,r)),await((F=(v=this.options).onSuccess)==null?void 0:F.call(v,u,t,this.state.context,r)),await((I=(O=l(this,Te).config).onSettled)==null?void 0:I.call(O,u,null,this.state.variables,this.state.context,this,r)),await((_=(M=this.options).onSettled)==null?void 0:_.call(M,u,null,t,this.state.context,r)),j(this,We,ht).call(this,{type:"success",data:u}),u}catch(u){try{throw await((K=(P=l(this,Te).config).onError)==null?void 0:K.call(P,u,t,this.state.context,this,r)),await((Z=(U=this.options).onError)==null?void 0:Z.call(U,u,t,this.state.context,r)),await((oe=(Y=l(this,Te).config).onSettled)==null?void 0:oe.call(Y,void 0,u,this.state.variables,this.state.context,this,r)),await((c=(i=this.options).onSettled)==null?void 0:c.call(i,void 0,u,t,this.state.context,r)),u}finally{j(this,We,ht).call(this,{type:"error",error:u})}}finally{l(this,Te).runNext(this)}}},on=new WeakMap,He=new WeakMap,Te=new WeakMap,Mt=new WeakMap,We=new WeakSet,ht=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),ue.batch(()=>{l(this,He).forEach(r=>{r.onMutationUpdate(t)}),l(this,Te).notify({mutation:this,type:"updated",action:t})})},Bs);function ys(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var eo=(_s=class extends Nt{constructor(t={}){super();N(this,Ge);N(this,Le);N(this,cn);this.config=t,B(this,Ge,new Set),B(this,Le,new Map),B(this,cn,0)}build(t,n,r){const s=new Ji({client:t,mutationCache:this,mutationId:++Fn(this,cn)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){l(this,Ge).add(t);const n=wn(t);if(typeof n=="string"){const r=l(this,Le).get(n);r?r.push(t):l(this,Le).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(l(this,Ge).delete(t)){const n=wn(t);if(typeof n=="string"){const r=l(this,Le).get(n);if(r)if(r.length>1){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&l(this,Le).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=wn(t);if(typeof n=="string"){const r=l(this,Le).get(n),s=r==null?void 0:r.find(a=>a.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const n=wn(t);if(typeof n=="string"){const s=(r=l(this,Le).get(n))==null?void 0:r.find(a=>a!==t&&a.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){ue.batch(()=>{l(this,Ge).forEach(t=>{this.notify({type:"removed",mutation:t})}),l(this,Ge).clear(),l(this,Le).clear()})}getAll(){return Array.from(l(this,Ge))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>ts(n,r))}findAll(t={}){return this.getAll().filter(n=>ts(t,n))}notify(t){ue.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return ue.batch(()=>Promise.all(t.map(n=>n.continue().catch(be))))}},Ge=new WeakMap,Le=new WeakMap,cn=new WeakMap,_s);function wn(e){var t;return(t=e.options.scope)==null?void 0:t.id}var to=(Us=class extends Nt{constructor(t,n){super();N(this,Ye);N(this,Xe);N(this,dt);N(this,Fe);N(this,Ze);B(this,Xe,t),this.setOptions(n),this.bindMethods(),j(this,Ye,Pn).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var r;const n=this.options;this.options=l(this,Xe).defaultMutationOptions(t),bn(this.options,n)||l(this,Xe).getMutationCache().notify({type:"observerOptionsUpdated",mutation:l(this,Fe),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&wt(n.mutationKey)!==wt(this.options.mutationKey)?this.reset():((r=l(this,Fe))==null?void 0:r.state.status)==="pending"&&l(this,Fe).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=l(this,Fe))==null||t.removeObserver(this)}onMutationUpdate(t){j(this,Ye,Pn).call(this),j(this,Ye,wr).call(this,t)}getCurrentResult(){return l(this,dt)}reset(){var t;(t=l(this,Fe))==null||t.removeObserver(this),B(this,Fe,void 0),j(this,Ye,Pn).call(this),j(this,Ye,wr).call(this)}mutate(t,n){var r;return B(this,Ze,n),(r=l(this,Fe))==null||r.removeObserver(this),B(this,Fe,l(this,Xe).getMutationCache().build(l(this,Xe),this.options)),l(this,Fe).addObserver(this),l(this,Fe).execute(t)}},Xe=new WeakMap,dt=new WeakMap,Fe=new WeakMap,Ze=new WeakMap,Ye=new WeakSet,Pn=function(){var n;const t=((n=l(this,Fe))==null?void 0:n.state)??ys();B(this,dt,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},wr=function(t){ue.batch(()=>{var n,r,s,a,o,d,p,f;if(l(this,Ze)&&this.hasListeners()){const w=l(this,dt).variables,C=l(this,dt).context,v={client:l(this,Xe),meta:this.options.meta,mutationKey:this.options.mutationKey};(t==null?void 0:t.type)==="success"?((r=(n=l(this,Ze)).onSuccess)==null||r.call(n,t.data,w,C,v),(a=(s=l(this,Ze)).onSettled)==null||a.call(s,t.data,null,w,C,v)):(t==null?void 0:t.type)==="error"&&((d=(o=l(this,Ze)).onError)==null||d.call(o,t.error,w,C,v),(f=(p=l(this,Ze)).onSettled)==null||f.call(p,void 0,t.error,w,C,v))}this.listeners.forEach(w=>{w(l(this,dt))})})},Us),no=(Rs=class extends Nt{constructor(t={}){super();N(this,Qe);this.config=t,B(this,Qe,new Map)}build(t,n,r){const s=n.queryKey,a=n.queryHash??er(s,n);let o=this.get(a);return o||(o=new Vi({client:t,queryKey:s,queryHash:a,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(o)),o}add(t){l(this,Qe).has(t.queryHash)||(l(this,Qe).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=l(this,Qe).get(t.queryHash);n&&(t.destroy(),n===t&&l(this,Qe).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ue.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return l(this,Qe).get(t)}getAll(){return[...l(this,Qe).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>es(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>es(t,r)):n}notify(t){ue.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){ue.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ue.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Qe=new WeakMap,Rs),ro=(Ls=class{constructor(e={}){N(this,se);N(this,lt);N(this,pt);N(this,Vt);N(this,Gt);N(this,ft);N(this,Xt);N(this,Zt);B(this,se,e.queryCache||new no),B(this,lt,e.mutationCache||new eo),B(this,pt,e.defaultOptions||{}),B(this,Vt,new Map),B(this,Gt,new Map),B(this,ft,0)}mount(){Fn(this,ft)._++,l(this,ft)===1&&(B(this,Xt,sr.subscribe(async e=>{e&&(await this.resumePausedMutations(),l(this,se).onFocus())})),B(this,Zt,Tn.subscribe(async e=>{e&&(await this.resumePausedMutations(),l(this,se).onOnline())})))}unmount(){var e,t;Fn(this,ft)._--,l(this,ft)===0&&((e=l(this,Xt))==null||e.call(this),B(this,Xt,void 0),(t=l(this,Zt))==null||t.call(this),B(this,Zt,void 0))}isFetching(e){return l(this,se).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return l(this,lt).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=l(this,se).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=l(this,se).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(st(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return l(this,se).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),s=l(this,se).get(r.queryHash),a=s==null?void 0:s.state.data,o=Li(t,a);if(o!==void 0)return l(this,se).build(this,r).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return ue.batch(()=>l(this,se).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=l(this,se).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=l(this,se);ue.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=l(this,se);return ue.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=ue.batch(()=>l(this,se).findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(be).catch(be)}invalidateQueries(e,t={}){return ue.batch(()=>(l(this,se).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=ue.batch(()=>l(this,se).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let a=s.fetch(void 0,n);return n.throwOnError||(a=a.catch(be)),s.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(be)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=l(this,se).build(this,t);return n.isStaleByTime(st(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(be).catch(be)}fetchInfiniteQuery(e){return e.behavior=hs(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(be).catch(be)}ensureInfiniteQueryData(e){return e.behavior=hs(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Tn.isOnline()?l(this,lt).resumePausedMutations():Promise.resolve()}getQueryCache(){return l(this,se)}getMutationCache(){return l(this,lt)}getDefaultOptions(){return l(this,pt)}setDefaultOptions(e){B(this,pt,e)}setQueryDefaults(e,t){l(this,Vt).set(wt(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...l(this,Vt).values()],n={};return t.forEach(r=>{tn(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){l(this,Gt).set(wt(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...l(this,Gt).values()],n={};return t.forEach(r=>{tn(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...l(this,pt).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=er(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Cn&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...l(this,pt).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){l(this,se).clear(),l(this,lt).clear()}},se=new WeakMap,lt=new WeakMap,pt=new WeakMap,Vt=new WeakMap,Gt=new WeakMap,ft=new WeakMap,Xt=new WeakMap,Zt=new WeakMap,Ls),gs=ce.createContext(void 0),ur=e=>{const t=ce.useContext(gs);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},so=({client:e,children:t})=>(ce.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),H.jsx(gs.Provider,{value:e,children:t})),As=ce.createContext(!1),ao=()=>ce.useContext(As);As.Provider;function io(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var oo=ce.createContext(io()),co=()=>ce.useContext(oo),uo=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},lo=e=>{ce.useEffect(()=>{e.clearReset()},[e])},po=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||as(n,[e.error,r])),fo=e=>{if(e.suspense){const n=s=>s==="static"?s:Math.max(s??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...s)=>n(r(...s)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},ho=(e,t)=>e.isLoading&&e.isFetching&&!t,mo=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Es=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function yo(e,t,n){var C,v,F,O,I;if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const r=ao(),s=co(),a=ur(),o=a.defaultQueryOptions(e);(v=(C=a.getDefaultOptions().queries)==null?void 0:C._experimental_beforeQuery)==null||v.call(C,o),process.env.NODE_ENV!=="production"&&(o.queryFn||console.error(`[${o.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),o._optimisticResults=r?"isRestoring":"optimistic",fo(o),uo(o,s),lo(s);const d=!a.getQueryCache().get(o.queryHash),[p]=ce.useState(()=>new t(a,o)),f=p.getOptimisticResult(o),w=!r&&e.subscribed!==!1;if(ce.useSyncExternalStore(ce.useCallback(M=>{const _=w?p.subscribe(ue.batchCalls(M)):be;return p.updateResult(),_},[p,w]),()=>p.getCurrentResult(),()=>p.getCurrentResult()),ce.useEffect(()=>{p.setOptions(o)},[o,p]),mo(o,f))throw Es(o,p,s);if(po({result:f,errorResetBoundary:s,throwOnError:o.throwOnError,query:a.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw f.error;if((O=(F=a.getDefaultOptions().queries)==null?void 0:F._experimental_afterQuery)==null||O.call(F,o,f),o.experimental_prefetchInRender&&!Tt&&ho(f,r)){const M=d?Es(o,p,s):(I=a.getQueryCache().get(o.queryHash))==null?void 0:I.promise;M==null||M.catch(be).finally(()=>{p.updateResult()})}return o.notifyOnChangeProps?f:p.trackResult(f)}function go(e,t){return yo(e,Gi)}function at(e,t){const n=ur(),[r]=ce.useState(()=>new to(n,e));ce.useEffect(()=>{r.setOptions(e)},[r,e]);const s=ce.useSyncExternalStore(ce.useCallback(o=>r.subscribe(ue.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=ce.useCallback((o,d)=>{r.mutate(o,d).catch(be)},[r]);if(s.error&&as(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:a,mutateAsync:s.mutate}}const nn=()=>{const e=Q(a=>a.state.swapExecutionIndex),t=Q(a=>a.state.swapExecutions[a.state.swapExecutionIndex]??{}),n=Q(a=>a.updateSwapExecutionAtIndex),r=Q(a=>a.resetSwapExecutionAtIndex),s=S.useCallback(a=>n(e,a),[n,e]);return S.useMemo(()=>({...t,update:s,resetSwap:r}),[t,s,r])},Ao=2e4,Eo=()=>{const{module:e}=q(),t=Q(n=>n.state.isMarketOrder);return S.useMemo(()=>e===$.TWAP?t?V.TWAP_MARKET:V.TWAP_LIMIT:e===$.LIMIT?V.LIMIT:e===$.STOP_LOSS?t?V.STOP_LOSS_MARKET:V.STOP_LOSS_LIMIT:e===$.TAKE_PROFIT?t?V.TAKE_PROFIT_MARKET:V.TAKE_PROFIT_LIMIT:V.TWAP_MARKET,[e,t])},bs=()=>{const{account:e,config:t,chainId:n,isDev:r}=q();return S.useMemo(()=>["useTwapOrderHistoryManager",e,t==null?void 0:t.adapter,n,r],[e,t,n,r])},bo=()=>{const{callbacks:e}=q(),t=ur(),n=bs();return S.useCallback(r=>{var d;const s=t.getQueryData(n);let a=!1;const o=[];s&&s.filter(p=>p.version===2).forEach(p=>{var w;const f=r.find(C=>C.id===p.id);f&&f.progress!==p.progress&&(a=!0,o.push(f),f.status===he.Completed&&((w=e==null?void 0:e.onOrderFilled)==null||w.call(e,f)))}),a&&((d=e==null?void 0:e.onOrdersProgressUpdate)==null||d.call(e,o))},[t,n,e])},dr=()=>{const{account:e,config:t,chainId:n,isDev:r}=q(),s=bs(),a=bo();return go({refetchInterval:Ao,refetchOnWindowFocus:!0,retry:!1,staleTime:1/0,queryKey:s,queryFn:async({signal:d})=>{if(!e||!n||!t)return[];const p=await oi({signal:d,chainId:n,config:t,account:e,isDev:r});return a(p),p.map(f=>t!=null&&t.twapConfig?{...f,fillDelayMillis:Ln(f,t.twapConfig)}:f)}})},Co=(e,t,n)=>S.useMemo(()=>{if(!(!e||!t||!n||n!=null&&n.isMarketPrice))return Mr(n,e==null?void 0:e.decimals,t==null?void 0:t.decimals)},[n,e,t]),To=(e,t,n)=>S.useMemo(()=>{if(!(!e||!t||!n))return Br(n,e.decimals,t.decimals)},[n,e,t]),wo=(e,t,n)=>S.useMemo(()=>{if(!(!e||!t||!n))return Nn(n.srcAmountFilled,n.dstAmountFilled,e.decimals,t.decimals)},[n,e,t]),vn=(e,t)=>[...e.filter(r=>r.status===t)].sort((r,s)=>s.createdAt-r.createdAt),vo=()=>{const{data:e,isLoading:t,refetch:n,isRefetching:r}=dr(),s=S.useCallback(()=>n().then(a=>a.data),[n]);return S.useMemo(()=>({orders:{all:e??[],open:vn(e??[],he.Open),completed:vn(e??[],he.Completed),cancelled:vn(e??[],he.Cancelled),expired:vn(e??[],he.Expired)},isLoading:t,isRefetching:r,refetchOrders:s}),[e,t,r,s])},lr=()=>{const e=Q(n=>n.state.currentTime),t=Xn().duration;return S.useMemo(()=>Ca(e,t),[e,t])},Cs=()=>{const{srcToken:e,dstToken:t,account:n,chainId:r,slippage:s,config:a,module:o,fees:d}=q(),{amount:p}=rt(),{amountPerTrade:f,totalTrades:w}=qe(),C=lr(),{amount:v}=Yn(),{pricePerChunk:F}=bt(),{milliseconds:O}=Lt();return S.useMemo(()=>{var I;return Rr({chainId:r,srcToken:Ut((e==null?void 0:e.address)||"")?((I=At(r))==null?void 0:I.wToken.address)||"":(e==null?void 0:e.address)||"",dstToken:(t==null?void 0:t.address)||"",srcAmount:p,deadlineMillis:C,fillDelayMillis:!w||w===1?0:O,slippage:s*100,account:n,srcAmountPerTrade:f,dstMinAmountPerTrade:v,triggerAmountPerTrade:F,config:a,module:o})},[e,t,n,r,s,a,o,p,f,w,O,v,F,d])};function xo(e){const t=e.slice(2);if(t.length===128){const a=`0x${t.slice(0,64)}`,o=parseInt(t.charAt(64),16),d=(o>>3)+27,p=`0x${(o&7).toString(16)}${t.slice(65,128)}`;return{r:a,s:p,v:d}}const n=`0x${t.slice(0,64)}`,r=`0x${t.slice(64,128)}`,s=parseInt(t.slice(128,130),16);return{r:n,s:r,v:s}}const So=()=>{var a;const{account:e,walletInteractions:t,callbacks:n,chainId:r}=q(),s=(a=yn())==null?void 0:a.wToken;return at({mutationFn:async({onHash:o,srcAmountWei:d})=>{var f,w;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletInteractions");if(!s)throw new Error("tokenAddress is not defined");pe.onWrapRequest();const p=await t.wrapNativeToken(d);return(f=n==null?void 0:n.onWrapRequest)==null||f.call(n),o==null||o(p),pe.onWrapSuccess(p),(w=n==null?void 0:n.onWrapSuccess)==null||w.call(n,{txHash:p,explorerUrl:Rt(p,r),amount:Ee(d,s.decimals)}),p},onError:o=>{throw pe.onWrapError(o),o}})},Ts=()=>{const{account:e,walletInteractions:t,chainId:n,callbacks:r}=q(),s=Cs(),{refetch:a}=dr();return at({mutationFn:async()=>{var O,I,M,_;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletInteractions");if(!n)throw new Error("missing chainId");const{order:o,domain:d,types:p,primaryType:f}=s;pe.onSignOrderRequest(o);let w;try{w=await t.signOrder({domain:d,types:p,primaryType:f,message:o,account:e})}catch(P){throw(O=r==null?void 0:r.onSignOrderError)==null||O.call(r,P),pe.onSignOrderError(P),P}pe.onSignOrderSuccess(w),(I=r==null?void 0:r.onSignOrderSuccess)==null||I.call(r,w);const C=xo(w),v={v:`0x${C.v.toString(16)}`,r:C.r,s:C.s};(M=r==null?void 0:r.onSignOrderRequest)==null||M.call(r);const F=await qr(o,v);return(_=r==null?void 0:r.onOrderCreated)==null||_.call(r,F),await a(),F}})},ws=()=>{const{account:e,walletInteractions:t,config:n}=q();return at({mutationFn:async({tokenAddress:r,srcAmountWei:s})=>{if(!t)throw new Error("missing walletInteractions");if(!e)throw new Error("missing account");if(!n)throw new Error("missing config");const a=await t.getAllowance({tokenAddress:r,spenderAddress:n.repermit}),o=x(a||"0").lt(x(s).toString());return{allowance:a,approvalRequired:o}}})},Fo=()=>{const{account:e,walletInteractions:t,config:n,chainId:r,callbacks:s}=q(),{mutateAsync:a}=ws();return at({onError:o=>{pe.onApproveError(o)},mutationFn:async({token:o,onHash:d,srcAmountWei:p})=>{var C,v;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletInteractions");if(!n)throw new Error("missing config");pe.onApproveRequest();const f=await t.approveToken({tokenAddress:o.address,amount:p,spenderAddress:n.repermit});if(!f)throw new Error("failed to approve token");(C=s==null?void 0:s.onApproveRequest)==null||C.call(s),d(f);let w=!1;for(let F=0;F<3;F++){const{approvalRequired:O}=await a({tokenAddress:o.address,srcAmountWei:p});if(!O){w=!0;break}F<2&&await new Promise(I=>setTimeout(I,3e3))}if(!w)throw new Error(`Insufficient ${o.symbol} allowance to perform the swap. Please approve the token first.`);return pe.onApproveSuccess(f),(v=s==null?void 0:s.onApproveSuccess)==null||v.call(s,{txHash:f,explorerUrl:Rt(f,r),token:o,amount:Ee(p,o.decimals)}),f}})},Po=()=>{const{account:e,chainId:t,srcToken:n,dstToken:r,module:s,slippage:a}=q(),o=bt(),d=rt().amount,p=qe().amountPerTrade,f=lr(),w=qe().totalTrades,C=Lt().fillDelay,v=Yn().amount,F=Q(O=>O.state.isMarketOrder);return at({mutationFn:async()=>{pe.onRequestOrder({account:e,chainId:t,module:s,srcToken:n,dstToken:r,fromTokenAmount:d,srcChunkAmount:p,triggerPricePerTrade:o.pricePerChunk,deadline:f,fillDelay:C.unit*C.value,minDstAmountOutPerTrade:v,slippage:a,isMarketOrder:F||!1,chunksAmount:w})}})};function Do(e){const t=e.message,n=t.match(/,\s*code\s*:\s*(\d+)/i);return{message:t.replace(/^error\s*:/i,"").replace(/,\s*code\s*:\s*\d+/i,"").trim()||"",code:n?Number(n[1]):0}}const vs=()=>{const{srcToken:e,dstToken:t,chainId:n,callbacks:r,marketPrice:s}=q(),a=Fo().mutateAsync,o=So().mutateAsync,d=Ts().mutateAsync,{mutateAsync:p}=ws(),{update:f}=nn(),{amount:w}=rt(),C=Po().mutate;return at({mutationFn:async()=>{var F,O;const v=Ut((e==null?void 0:e.address)||" ");try{if(!e)throw new Error("missing srcToken");if(!t)throw new Error("missing dstToken");if(!n)throw new Error("missing chainId");const I=$r(e,n);f({allowanceLoading:!0,wrapTxHash:void 0,approveTxHash:void 0,acceptedMarketPrice:s,acceptedSrcAmount:w,srcToken:e,dstToken:t,pendingSteps:[]});const{approvalRequired:M}=await p({tokenAddress:I.address,srcAmountWei:w});let _=0,P=1;v&&P++,M&&P++,f({totalSteps:P,stepIndex:_,allowanceLoading:!1,hasApproval:!M,status:xe.LOADING}),C();let K=[];v&&K.push(tt.WRAP),M&&K.push(tt.APPROVE),K.push(tt.CREATE),f({pendingSteps:K}),v&&(f({step:tt.WRAP}),await o({onHash:Z=>f({wrapTxHash:Z}),srcAmountWei:w}),_++,f({stepIndex:_})),M&&(f({step:tt.APPROVE}),await a({token:I,onHash:Z=>f({approveTxHash:Z}),srcAmountWei:w}),_++,f({stepIndex:_})),f({step:tt.CREATE});const U=await d();return f({status:xe.SUCCESS,orderId:U.id}),U}catch(I){if(zn(I))(F=r==null?void 0:r.onSubmitOrderRejected)==null||F.call(r),f({step:void 0,status:void 0,stepIndex:void 0,error:I});else{const M=Do(I);(O=r==null?void 0:r.onSubmitOrderFailed)==null||O.call(r,M),f({status:xe.FAILED,parsedError:M,error:I})}throw I}}})},Oo=()=>{const e=nn(),{srcToken:t,dstToken:n}=q(),r=vs(),s=Q(f=>f.resetState),a=S.useCallback(()=>r.mutateAsync(),[r]),{update:o,resetSwap:d,...p}=e;return S.useMemo(()=>({status:p.status,parsedError:p.parsedError,error:p.error,step:p.step,stepIndex:p.stepIndex,approveTxHash:p.approveTxHash,wrapTxHash:p.wrapTxHash,totalSteps:p.totalSteps,pendingSteps:p.pendingSteps,srcToken:t,dstToken:n,onSubmit:a,resetState:s,resetCurrentSwap:d,isLoading:(e==null?void 0:e.status)===xe.LOADING,isSuccess:(e==null?void 0:e.status)===xe.SUCCESS,isFailed:(e==null?void 0:e.status)===xe.FAILED,confirmButtonLoading:p.allowanceLoading}),[a,p,s,d,t,n])},Io=()=>{const{marketPrice:e,srcToken:t,dstToken:n,marketPriceLoading:r,srcBalance:s,srcUsd1Token:a,noLiquidity:o,typedInputAmount:d}=q(),p=r||x(a||"0").isZero()||s===void 0||x(e||"0").isZero(),f=!!(t&&n&&d&&p),C=!!(Yr()||o||f||x(d||"0").isZero()||!t||!n);return S.useMemo(()=>({disabled:C,loading:f}),[C,f])},ko=()=>{const{srcUsd1Token:e,dstUsd1Token:t}=q(),n=rt().amountUI,r=En().amountUI,s=nt(n,e),a=nt(r,t);return{srcAmountUsd:s,dstAmountUsd:a}},Mo=()=>{const{fees:e,dstToken:t,dstUsd1Token:n}=q(),{amountUI:r}=En(),s=S.useMemo(()=>!e||!r?"":x(r).multipliedBy(e).dividedBy(100).toFixed(),[r,e]),a=Gn((t==null?void 0:t.decimals)||0,s);return{amountUI:s,amount:a,percent:e,usd:nt(s,n)}},Bo=e=>{const t=S.useMemo(()=>!e.minDestAmountPerTrade||!e.totalTrades?"":x(e.minDestAmountPerTrade).multipliedBy(e.totalTrades).decimalPlaces(0).toFixed(),[e.minDestAmountPerTrade,e.totalTrades]),n=S.useMemo(()=>!e.minDestAmountPerTradeUI||!e.totalTrades?"":x(e.minDestAmountPerTradeUI).multipliedBy(e.totalTrades).toFixed(),[e.minDestAmountPerTradeUI,e.totalTrades]),r=S.useMemo(()=>!e.minDestAmountPerTradeUsd||!e.totalTrades?"":x(e.minDestAmountPerTradeUsd).multipliedBy(e.totalTrades).decimalPlaces(2).toFixed(),[e.minDestAmountPerTradeUsd,e.totalTrades]);return S.useMemo(()=>({srcToken:e.srcToken,dstToken:e.dstToken,orderType:e.orderType,createdAt:e.createdAt||0,deadline:e.deadline||0,totalTrades:e.totalTrades||0,tradeInterval:e.tradeInterval||0,recipient:e.account||"",srcAmount:e.srcAmount||"",srcAmountUI:e.srcAmountUI||"",srcAmountUsd:e.srcAmountUsd||"",dstAmount:e.dstAmount||"",dstAmountUI:e.dstAmountUI||"",dstAmountUsd:e.dstAmountUsd||"",limitPrice:e.limitPrice||"",limitPriceUI:e.limitPriceUI||"",limitPriceUsd:e.limitPriceUsd||"",sizePerTrade:e.srcAmountPerTrade||"",sizePerTradeUI:e.srcAmountPerTradeUI||"",sizePerTradeUsd:e.srcAmountPerTradeUsd,minDestAmountPerTrade:e.minDestAmountPerTrade||"",minDestAmountPerTradeUI:e.minDestAmountPerTradeUI||"",minDestAmountPerTradeUsd:e.minDestAmountPerTradeUsd,dstMinAmount:t,dstMinAmountUI:n,dstMinAmountUsd:r,triggerPrice:e.triggerPrice||"",triggerPriceUI:e.triggerPriceUI||"",triggerPriceUsd:e.triggerPriceUsd}),[e.srcToken,e.dstToken,e.orderType,e.createdAt,e.deadline,e.totalTrades,e.tradeInterval,e.account,e.srcAmount,e.srcAmountUI,e.srcAmountUsd,e.dstAmount,e.dstAmountUI,e.dstAmountUsd,e.limitPrice,e.limitPriceUI,e.limitPriceUsd,e.srcAmountPerTrade,e.srcAmountPerTradeUI,e.srcAmountPerTradeUsd,e.minDestAmountPerTrade,e.minDestAmountPerTradeUI,e.minDestAmountPerTradeUsd,t,n,r,e.triggerPrice,e.triggerPriceUI,e.triggerPriceUsd])},_o=()=>{const{config:e}=q();return S.useMemo(()=>({spender:e.repermit}),[e])},Uo=()=>{const{srcToken:e,dstToken:t,account:n,marketPrice:r}=q(),{spender:s}=_o(),{amount:a}=rt(),{amount:o,amountUI:d,usd:p}=An(),{amountPerTrade:f,amountPerTradeUI:w,amountPerTradeUsd:C,totalTrades:v}=qe(),F=lr(),{amount:O,amountUI:I,usd:M}=Yn(),{amountUI:_,amount:P,usd:K}=bt(),{milliseconds:U}=Lt(),{amount:Z,amountUI:Y}=En(),{srcAmountUsd:oe,dstAmountUsd:i}=ko(),{amount:c,amountUI:u,percent:A,usd:m}=Mo(),y=Cs(),T=Q(G=>G.state.isMarketOrder),h=Q(G=>G.state.currentTime),g=nn(),b=Eo(),E=g.acceptedSrcAmount||a,D=Ee(r,(t==null?void 0:t.decimals)||0),R=S.useMemo(()=>b===V.TAKE_PROFIT_MARKET||b===V.TAKE_PROFIT_LIMIT||b===V.STOP_LOSS_LIMIT||b===V.STOP_LOSS_MARKET,[b]),L=Bo({srcToken:e,dstToken:t,account:n,orderType:b,createdAt:h,deadline:F,totalTrades:v,tradeInterval:U,srcAmount:E,srcAmountUI:Ee(E,(e==null?void 0:e.decimals)||0),srcAmountUsd:oe,dstAmount:Z,dstAmountUI:Y,dstAmountUsd:i,limitPrice:T?void 0:o,limitPriceUI:T?void 0:d,limitPriceUsd:T?void 0:p,srcAmountPerTrade:f,srcAmountPerTradeUI:w,srcAmountPerTradeUsd:C,minDestAmountPerTrade:O,minDestAmountPerTradeUI:I,minDestAmountPerTradeUsd:M,triggerPrice:P,triggerPriceUI:_,triggerPriceUsd:K});return S.useMemo(()=>({...L,feesAmountUI:u,feesAmount:c,feesUsd:m||"",feesPercentage:A,rePermitData:y,isTriggerPrice:R,isMarketOrder:T,marketPrice:r,marketPriceUi:D,spender:s}),[L,u,c,m,A,y,R,T,r,D,s])},Ro=()=>{const{supportedChains:e}=q();return S.useMemo(()=>e,[e])},Lo=60,xs=()=>{const{refetch:e}=dr();return at({mutationFn:async t=>{var n;for(let r=0;r<Lo;r++){const s=(n=await e())==null?void 0:n.data;if(!s)throw new Error("orders not found");const a=s.find(o=>o.id===t);if((a==null?void 0:a.status)===he.Cancelled)return;await new Promise(o=>setTimeout(o,1e3))}throw new Error("Timed out waiting for order cancellation to be confirmed")}})},No=()=>{const e=Q(n=>n.updateState),t=Q(n=>n.state.cancelOrders);return{cancelOrders:t,setCancelOrder:(n,r)=>{e({cancelOrders:{...t,[n]:r}})},clearCancelOrder:n=>{const{[n]:r,...s}=t;e({cancelOrders:s})}}},qo=e=>{const{account:t,walletInteractions:n,config:r,callbacks:s,chainId:a}=q(),o=xs().mutateAsync,{cancelOrders:d,setCancelOrder:p,clearCancelOrder:f}=No(),{mutateAsync:w}=at({mutationFn:async()=>{var O,I,M;if(!t||!n||!r)throw new Error("missing required parameters");if(!e)throw new Error("order is required");const F=e.id;try{(O=s==null?void 0:s.onCancelOrderRequest)==null||O.call(s,e),p(F,{status:xe.LOADING}),pe.onCancelOrderRequest([e.version===1?e.id.toString():e.hash],e.version);const _=await n.cancelOrder({order:e,contractAddress:e.version===1?e.twapAddress:r.repermit,args:e.version===1?[e.id]:[[e.repermitDigest]],abi:e.version===1?Ws:Hs});if(!_)throw new Error("failed to cancel order");return pe.onCancelOrderSuccess(_),await o(e.id),(I=s==null?void 0:s.onCancelOrderSuccess)==null||I.call(s,{order:e,txHash:_,explorerUrl:Rt(_,a)}),p(F,{status:xe.SUCCESS,txHash:_}),_}catch(_){console.error("cancel order error",_),(M=s==null?void 0:s.onCancelOrderFailed)==null||M.call(s,_),zn(_)?f(F):(p(F,{status:xe.FAILED,error:_.message}),pe.onCancelOrderError(_))}}}),C=S.useMemo(()=>{const F=d[(e==null?void 0:e.id)||""];return{isLoading:(F==null?void 0:F.status)===xe.LOADING,isSuccess:(F==null?void 0:F.status)===xe.SUCCESS,isError:(F==null?void 0:F.status)===xe.FAILED,error:F==null?void 0:F.error,txHash:F==null?void 0:F.txHash}},[d,e==null?void 0:e.id]),v=S.useCallback(async()=>w(),[w]);return S.useMemo(()=>({cancelOrder:v,...C}),[v,C])},Ss=S.createContext(null),Ko=({children:e})=>{const t=bi(),n=vi(),r=Ti(),s=Oi(),a=Ii(),o=gn(),d=ki(),p=Mi(),f=Yr(),w=Io(),C=Uo(),v=vo(),F=Oo(),O=Ro(),I=xs(),{module:M}=q(),_={tradesAmountPanel:t,durationPanel:n,fillDelayPanel:r,limitPricePanel:s,triggerPricePanel:a,pricePanel:o,dstTokenPanel:d,disclaimerPanel:p,inputError:f,submitOrderButton:w,derivedFormData:C,orderHistoryPanel:v,orderExecutionPanel:F,supportedChains:O,refetchUntilStatusSynced:I,module:M};return H.jsx(Ss.Provider,{value:_,children:e})},Ho=()=>{const e=S.useContext(Ss);if(e===null)throw new Error("useSpot must be used within SpotProvider");return e},Wo=S.createContext(null),pr={didCatch:!1,error:null};class Qo extends S.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=pr}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var n,r,s=arguments.length,a=new Array(s),o=0;o<s;o++)a[o]=arguments[o];(n=(r=this.props).onReset)===null||n===void 0||n.call(r,{args:a,reason:"imperative-api"}),this.setState(pr)}}componentDidCatch(t,n){var r,s;(r=(s=this.props).onError)===null||r===void 0||r.call(s,t,n)}componentDidUpdate(t,n){const{didCatch:r}=this.state,{resetKeys:s}=this.props;if(r&&n.error!==null&&jo(t.resetKeys,s)){var a,o;(a=(o=this.props).onReset)===null||a===void 0||a.call(o,{next:s,prev:t.resetKeys,reason:"keys"}),this.setState(pr)}}render(){const{children:t,fallbackRender:n,FallbackComponent:r,fallback:s}=this.props,{didCatch:a,error:o}=this.state;let d=t;if(a){const p={error:o,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")d=n(p);else if(r)d=S.createElement(r,p);else if(s!==void 0)d=s;else throw o}return S.createElement(Wo.Provider,{value:{didCatch:a,error:o,resetErrorBoundary:this.resetErrorBoundary}},d)}}function jo(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((n,r)=>!Object.is(n,t[r]))}const zo=()=>H.jsx("div",{className:"twap-error-fallback",children:H.jsx("p",{style:{fontSize:20,fontWeight:600,textAlign:"center",width:"100%",marginTop:40},children:"Something went wrong"})});function $o({children:e}){return H.jsx(Qo,{FallbackComponent:zo,onError:t=>pe.onCrash(t),children:H.jsx(H.Fragment,{children:e})})}const Fs=S.createContext(null),Vo=new ro({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),Go=e=>{var r,s,a;const t=Q(o=>o.updateState),n=Q(o=>o.state.isMarketOrder);return S.useEffect(()=>{const o=setInterval(()=>{t({currentTime:Date.now()})},6e4);return()=>clearInterval(o)},[t]),S.useEffect(()=>{var d,p,f,w,C,v,F,O,I,M,_,P,K,U,Z,Y;const o=(p=(d=e.overrides)==null?void 0:d.state)==null?void 0:p.isMarketOrder;o!==void 0&&t({isMarketOrder:o}),t({typedChunks:(w=(f=e.overrides)==null?void 0:f.state)==null?void 0:w.chunks,typedFillDelay:(v=(C=e.overrides)==null?void 0:C.state)==null?void 0:v.fillDelay,typedDuration:(O=(F=e.overrides)==null?void 0:F.state)==null?void 0:O.duration,typedLimitPrice:(M=(I=e.overrides)==null?void 0:I.state)==null?void 0:M.limitPrice,typedTriggerPrice:(P=(_=e.overrides)==null?void 0:_.state)==null?void 0:P.triggerPrice,triggerPricePercent:(U=(K=e.overrides)==null?void 0:K.state)==null?void 0:U.triggerPricePercent,limitPricePercent:(Y=(Z=e.overrides)==null?void 0:Z.state)==null?void 0:Y.limitPricePercent})},[(r=e.overrides)==null?void 0:r.state,e.module]),S.useEffect(()=>{var o,d,p,f;t({typedLimitPrice:(d=(o=e.overrides)==null?void 0:o.state)==null?void 0:d.limitPrice,typedTriggerPrice:(f=(p=e.overrides)==null?void 0:p.state)==null?void 0:f.triggerPrice,triggerPricePercent:void 0,limitPricePercent:void 0})},[(s=e.srcToken)==null?void 0:s.address,(a=e.dstToken)==null?void 0:a.address]),S.useEffect(()=>{e.module===$.LIMIT&&t({isMarketOrder:!1})},[e.module]),S.useEffect(()=>{n&&t({isInvertedTrade:!1})},[n]),S.useEffect(()=>{t({typedChunks:void 0})},[e.typedInputAmount]),null},Xo=({marketReferencePrice:e,srcToken:t,dstToken:n,chainId:r,typedInputAmount:s})=>S.useMemo(()=>{if($n(t,n,r)||Vn(t,n,r))return{isLoading:!1,noLiquidity:!1,value:Et(s||"0",t==null?void 0:t.decimals)};if(x(e.value||0).isZero()||x(s||0).isZero())return e;const a=x(e.value||0).dividedBy(s||0).decimalPlaces(0).toFixed();return{...e,value:a}},[e,s,t,n,r]),Zo=e=>{const t=nn(),n=S.useMemo(()=>kr(e.partner),[e.partner]),r=S.useMemo(()=>{const d=n[0];return e.chainId&&n.includes(e.chainId)?e.chainId:d},[e.chainId,n]),s=S.useMemo(()=>qn(e.partner,r),[e.partner,r]),a=Xo(e),o=S.useMemo(()=>Ur(e.minChunkSizeUsd),[e.minChunkSizeUsd]);return S.useEffect(()=>{pe.init(s,o,r)},[s,r,o]),H.jsxs(Fs.Provider,{value:{typedInputAmount:e.typedInputAmount,minChunkSizeUsd:o,account:e.account,walletInteractions:e.walletInteractions,marketPrice:t.acceptedMarketPrice||a.value,marketPriceLoading:!t.acceptedMarketPrice&&a.isLoading,noLiquidity:!t.acceptedMarketPrice&&a.noLiquidity,config:s,slippage:e.priceProtection,supportedChains:n,chainId:r,partner:e.partner,module:e.module,fees:e.fees||0,overrides:e.overrides,callbacks:e.callbacks,srcUsd1Token:e.srcUsd1Token,dstUsd1Token:e.dstUsd1Token,srcBalance:e.srcBalance,dstBalance:e.dstBalance,srcToken:t.srcToken||e.srcToken,dstToken:t.dstToken||e.dstToken,isDev:e.isDev},children:[H.jsx(Go,{...e}),H.jsx(Ko,{children:H.jsx($o,{children:e.children})})]})},Yo=e=>H.jsx(so,{client:Vo,children:H.jsx(Zo,{...e})}),q=()=>{const e=S.useContext(Fs);if(e===null)throw new Error("useSpotContext must be used within SpotProvider");return e},Jo=(e,t,n)=>{const r=yn();return S.useMemo(()=>e==null?void 0:e.map(s=>({srcToken:t,dstToken:n,srcAmount:Ee(s.inAmount,t==null?void 0:t.decimals),dstAmount:Ee(s.outAmount,n==null?void 0:n.decimals),timestamp:s.timestamp,txHash:s.txHash,explorerUrl:Rt(s.txHash,r==null?void 0:r.id),executionRate:Nn(s.inAmount,s.outAmount,t==null?void 0:t.decimals,n==null?void 0:n.decimals)})).filter(s=>s.srcToken!==void 0&&s.dstToken!==void 0),[e,t,n,r])},ec=(e,t,n)=>{const{config:r}=q(),s=Co(t,n,e),a=To(t,n,e),o=wo(t,n,e),d=S.useMemo(()=>e?e.version===2?e.fillDelay:r.twapConfig?Ln(e,r.twapConfig):0:0,[e,r]),p=Jo(e==null?void 0:e.fills,t,n)??[];return S.useMemo(()=>{if(e!=null&&e.id)return{original:e,fills:p,srcToken:t,dstToken:n,orderType:e.type,createdAt:e.createdAt,deadline:e.deadline||0,totalTrades:e.totalTradesAmount||0,tradeInterval:d,recipient:e.maker||"",srcAmount:e.srcAmount||"",srcAmountUI:Ee(e.srcAmount,t==null?void 0:t.decimals),limitPrice:Et(s,n==null?void 0:n.decimals),limitPriceUI:s||"",sizePerTrade:e.srcAmountPerTrade||"",sizePerTradeUI:Ee(e.srcAmountPerTrade,t==null?void 0:t.decimals),minDestAmountPerTrade:e.dstMinAmountPerTrade||"",minDestAmountPerTradeUI:Ee(e.dstMinAmountPerTrade,n==null?void 0:n.decimals),dstMinAmount:e.dstMinAmountTotal,dstMinAmountUI:Ee(e.dstMinAmountTotal,n==null?void 0:n.decimals),triggerPrice:Et(a,n==null?void 0:n.decimals),triggerPriceUI:a||"",id:e.id,amountInFilled:e.srcAmountFilled,amountInFilledUI:Ee(e.srcAmountFilled,t==null?void 0:t.decimals),amountOutFilled:e.dstAmountFilled,amountOutFilledUI:Ee(e.dstAmountFilled,n==null?void 0:n.decimals),progress:e.progress,executionPrice:Et(o,n==null?void 0:n.decimals),executionPriceUI:o,version:e.version}},[e,p,t,n,d,s,a,o])};La(ci.version),k.DISCLAIMER_URL=ra,k.Disclaimer=Jt,k.InputErrors=me,k.Module=$,k.ORBS_LOGO=ta,k.ORBS_SLTP_FAQ_URL=ea,k.ORBS_TWAP_FAQ_URL=Js,k.ORBS_WEBSITE_URL=na,k.OrderFilter=vr,k.OrderStatus=he,k.OrderType=V,k.Partners=Ne,k.SPOT_VERSION=On,k.SpotProvider=Yo,k.Steps=tt,k.SwapStatus=xe,k.TimeUnit=Pe,k.buildRePermitOrderData=Rr,k.ensureWrappedToken=$r,k.eqIgnoreCase=yt,k.getConfig=qn,k.getExplorerUrl=Rt,k.getMinChunkSizeUsd=Ur,k.getNetwork=At,k.getOrderExecutionRate=Nn,k.getOrderFillDelayMillis=Ln,k.getOrderLimitPriceRate=Mr,k.getOrderType=hi,k.getPartnerChains=kr,k.getPartners=_r,k.getTriggerPriceRate=Br,k.isNativeAddress=Ut,k.isTxRejected=zn,k.millisToDays=Vr,k.millisToMinutes=Gr,k.networks=ye,k.parseError=fi,k.shouldUnwrapOnly=Vn,k.shouldWrapOnly=$n,k.submitOrder=qr,k.toAmountUi=Ee,k.toAmountWei=Et,k.useAmountUi=en,k.useCancelOrder=qo,k.useDerivedHistoryOrder=ec,k.useExplorerLink=mi,k.useNetwork=yn,k.useSignOrder=Ts,k.useSpot=Ho,k.useSubmitOrder=vs,k.useSwapExecution=nn,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})}));