@orbs-network/spot-react 1.1.28 → 1.1.30

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(M,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):(M=typeof globalThis<"u"?globalThis:M||self,H(M.SpotReact={},M.jsxRuntime,M.React))})(this,(function(M,H,F){"use strict";var ic=Object.defineProperty;var Hs=M=>{throw TypeError(M)};var ac=(M,H,F)=>H in M?ic(M,H,{enumerable:!0,configurable:!0,writable:!0,value:F}):M[H]=F;var Dn=(M,H,F)=>ac(M,typeof H!="symbol"?H+"":H,F),Ar=(M,H,F)=>H.has(M)||Hs("Cannot "+F);var l=(M,H,F)=>(Ar(M,H,"read from private field"),F?F.call(M):H.get(M)),N=(M,H,F)=>H.has(M)?Hs("Cannot add the same private member more than once"):H instanceof WeakSet?H.add(M):H.set(M,F),_=(M,H,F,_t)=>(Ar(M,H,"write to private field"),_t?_t.call(M,F):H.set(M,F),F),$=(M,H,F)=>(Ar(M,H,"access private method"),F);var On=(M,H,F,_t)=>({set _(ce){_(M,H,ce,F)},get _(){return l(M,H,_t)}});var Ke,xt,Is,St,at,qt,Ms,Kt,ot,Ht,ks,vt,_s,Ft,Wt,ke,Pt,he,rn,Dt,Le,Je,Bs,ve,X,sn,Te,Ot,Qt,Ve,ct,an,$t,jt,It,Mt,ut,zt,ee,dn,Er,br,Tr,wr,Cr,xr,Sr,Ws,Us,on,He,we,kt,We,pt,Rs,Ge,Ne,cn,Ls,Xe,dt,Fe,Ze,Ye,In,vr,Ns,Qe,qs,se,lt,ft,Vt,Gt,ht,Xt,Zt,Ks;function _t(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=_t(F),j={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"}},Qs=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"}]'),$s=[{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"}]}],js=Qs;var z=(e=>(e.TWAP="TWAP",e.LIMIT="LIMIT",e.STOP_LOSS="STOP_LOSS",e.TAKE_PROFIT="TAKE_PROFIT",e))(z||{}),pe=(e=>(e.Open="OPEN",e.Cancelled="CANCELLED",e.Completed="COMPLETED",e.Expired="EXPIRED",e))(pe||{}),Fr=(e=>(e.All="ALL",e.Open="OPEN",e.Cancelled="CANCELLED",e.Completed="COMPLETED",e.Expired="EXPIRED",e))(Fr||{}),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||{}),Be=(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))(Be||{}),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}},Mn={version:"2.6.1"},Pr="https://order-sink-dev.orbs.network",ln="https://order-sink.orbs.network",Dr="https://order-sink-v2.orbs.network",fn=Mn.version.split(".")[0],zs=e=>{const t=Number(fn)>=2;return e?Pr:t?Dr:ln},Vs=e=>{const t=Number(fn)>=2;return e?[Pr]:t?[Dr,ln]:[ln]},Gs={[Be.Thena]:"0xB75218ba5A99bF57Fd02556B70F05A4A0f1Dbe67"},Xs=({endpoint:e,exchange:t,partner:n})=>e===ln&&n&&Gs[n]||t,kn=300*1e3,hn=1440*60*60*1e3,Or=300*1e3,Zs=new Date(kn).getMinutes(),_n=e=>`https://hub.orbs.network/api/private/project_cm7nb67z86nyr01z12gs0fxpf/subgraphs/orbs-twap-${e}/prod/gn`,Ue="https://hub.orbs.network/api/apikey/subgraphs/id",Ys={[ye.eth.id]:`${Ue}/Bf7bvMYcJbDAvYWJmhMpHZ4cpFjqzkhK6GXXEpnPRq6`,[ye.bsc.id]:`${Ue}/4NfXEi8rreQsnAr4aJ45RLCKgnjcWX46Lbt9SadiCcz6`,[ye.poly.id]:`${Ue}/3PyRPWSvDnMowGbeBy7aNsvUkD5ZuxdXQw2RdJq4NdXi`,[ye.arb.id]:`${Ue}/83bpQexEaqBjHaQbKoFTbtvCXuo5RudRkfLgtRUYqo2c`,[ye.base.id]:`${Ue}/DFhaPQb3HATXkpsWNZw3gydYHehLBVEDiSk4iBdZJyps`,[ye.sei.id]:`${Ue}/5zjzRnURzoddyFSZBw5E5NAM3oBgPq3NasTYbtMk6EL6`,[ye.linea.id]:`${Ue}/6VsNPEYfFLPZCqdMMDadoXQjLHWJdjEwiD768GAtb7j6`,[ye.sonic.id]:`${Ue}/DtBr6a5vsoDd2oAXdPszcn4gLgrr1XC68Q3AJQKXnNLV`,[ye.ftm.id]:`${Ue}/DdRo1pmJkrJC9fjsjEBWnNE1uqrbh7Diz4tVKd7rfupp`,[ye.katana.id]:`${Ue}/CGi9sDFMQcnBwF3C3NoCFqnaE34sssbgwPLTwiskSXmW`,[ye.avax.id]:`${Ue}/FxZ1vMwE5Xy1qvKvZENUMz4vhW8Sh4vXJf9Vp7o17pTx`,[ye.bera.id]:_n("berachain"),[ye.flare.id]:_n("flare"),[ye.cronosZkEvm.id]:_n("cronos-zkevm")},Js=["0x0000000000000000000000000000000000000000","0x0000000000000000000000000000000000001010","0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE","0x000000000000000000000000000000000000dEaD","0x000000000000000000000000000000000000800A","0x000000000000000000000000000000000000800a"],Ir="115792089237316195423570985008687907853269984665640564039457584007913129639935",Ae=e=>`${e.name}_${e.chainId}`,ei={[Ae(j.SushiArb)]:["0x846F2B29ef314bF3D667981b4ffdADc5B858312a","0x08c41f5D1C844061f6D952E25827eeAA576c6536"],[Ae(j.SushiBase)]:["0x846F2B29ef314bF3D667981b4ffdADc5B858312a","0x08c41f5D1C844061f6D952E25827eeAA576c6536"],[Ae(j.SushiEth)]:["0xc55943Fa6509004B2903ED8F8ab7347BfC47D0bA","0x08c41f5D1C844061f6D952E25827eeAA576c6536"],[Ae(j.PancakeSwap)]:["0xb2BAFe188faD927240038cC4FfF2d771d8A58905","0xE2a0c3b9aD19A18c4bBa7fffBe5bC1b0E58Db1CE"],[Ae(j.PancakeSwapArbitrum)]:["0xE20167871dB616DdfFD0Fd870d9bC068C350DD1F","0x807488ADAD033e95C438F998277bE654152594dc"],[Ae(j.PancakeSwapBase)]:["0x10ed1F36e4eBE76E161c9AADDa20BE841bc0082c","0x3A9df3eE209b802D0337383f5abCe3204d623588"],[Ae(j.PancakeSwapLinea)]:["0x3A9df3eE209b802D0337383f5abCe3204d623588"],[Ae(j.QuickSwap)]:["0x26D0ec4Be402BCE03AAa8aAf0CF67e9428ba54eF"],[Ae(j.Thena)]:["0xc2aBC02acd77Bb2407efA22348dA9afC8B375290"],[Ae(j.Lynex)]:["0x72e3e1fD5D2Ee2F1C2Eb695206D490a1D45C3835"],[Ae(j.DragonSwap)]:["0x101e1B65Bb516FB5f4547C80BAe0b51f1b8D7a22"],[Ae(j.SpookySwapSonic)]:["0xAd97B770ad64aE47fc7d64B3bD820dCDbF9ff7DA"],[Ae(j.SpookySwap)]:["0x3924d62219483015f982b160d48c0fa5Fd436Cba"],[Ae(j.SwapX)]:["0xE5012eBDe5e26EE3Ea41992154731a03023CF274"]},Bn={unit:Pe.Minutes,value:Zs},ti="RePermitWitnessTransferFrom",ni={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"}]},ri="https://www.orbs.com/dtwap-and-dlimit-faq/",si="https://www.orbs.com/dtwap-and-dlimit-faq/#dSLTP",ii="https://raw.githubusercontent.com/orbs-network/twap-ui/master/logo/orbslogo.svg",ai="https://www.orbs.com/",oi="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 ci="-5",ui="10",di="-10",li="5";var fi=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Un=Math.ceil,De=Math.floor,xe="[BigNumber Error] ",Mr=xe+"Number primitive has more than 15 significant digits: ",Re=1e14,W=14,Rn=9007199254740991,Ln=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],et=1e7,le=1e9;function kr(e){var t,n,r,s=P.prototype={constructor:P,toString:null,valueOf:null},i=new P(1),o=20,d=4,h=-7,f=21,C=-1e7,E=1e7,x=!1,v=1,O=0,I={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},k="0123456789abcdefghijklmnopqrstuvwxyz",B=!0;function P(a,c){var u,A,m,y,w,p,g,T,b=this;if(!(b instanceof P))return new P(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<C?b.c=[b.e=0]:(b.e=a.e,b.c=a.c.slice());return}if((p=typeof a=="number")&&a*0==0){if(b.s=1/a<0?(a=-a,-1):1,a===~~a){for(y=0,w=a;w>=10;w/=10,y++);y>E?b.c=b.e=null:(b.e=y,b.c=[a]);return}T=String(a)}else{if(!fi.test(T=String(a)))return r(b,T,p);b.s=T.charCodeAt(0)==45?(T=T.slice(1),-1):1}(y=T.indexOf("."))>-1&&(T=T.replace(".","")),(w=T.search(/e/i))>0?(y<0&&(y=w),y+=+T.slice(w+1),T=T.substring(0,w)):y<0&&(y=T.length)}else{if(ne(c,2,k.length,"Base"),c==10&&B)return b=new P(a),Y(b,o+b.e+1,d);if(T=String(a),p=typeof a=="number"){if(a*0!=0)return r(b,T,p,c);if(b.s=1/a<0?(T=T.slice(1),-1):1,P.DEBUG&&T.replace(/^0\.0*|\./,"").length>15)throw Error(Mr+a)}else b.s=T.charCodeAt(0)===45?(T=T.slice(1),-1):1;for(u=k.slice(0,c),y=w=0,g=T.length;w<g;w++)if(u.indexOf(A=T.charAt(w))<0){if(A=="."){if(w>y){y=g;continue}}else if(!m&&(T==T.toUpperCase()&&(T=T.toLowerCase())||T==T.toLowerCase()&&(T=T.toUpperCase()))){m=!0,w=-1,y=0;continue}return r(b,String(a),p,c)}p=!1,T=n(T,c,10,b.s),(y=T.indexOf("."))>-1?T=T.replace(".",""):y=T.length}for(w=0;T.charCodeAt(w)===48;w++);for(g=T.length;T.charCodeAt(--g)===48;);if(T=T.slice(w,++g)){if(g-=w,p&&P.DEBUG&&g>15&&(a>Rn||a!==De(a)))throw Error(Mr+b.s*a);if((y=y-w-1)>E)b.c=b.e=null;else if(y<C)b.c=[b.e=0];else{if(b.e=y,b.c=[],w=(y+1)%W,y<0&&(w+=W),w<g){for(w&&b.c.push(+T.slice(0,w)),g-=W;w<g;)b.c.push(+T.slice(w,w+=W));w=W-(T=T.slice(w)).length}else w-=g;for(;w--;T+="0");b.c.push(+T)}}else b.c=[b.e=0]}P.clone=kr,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(a){var c,u;if(a!=null)if(typeof a=="object"){if(a.hasOwnProperty(c="DECIMAL_PLACES")&&(u=a[c],ne(u,0,le,c),o=u),a.hasOwnProperty(c="ROUNDING_MODE")&&(u=a[c],ne(u,0,8,c),d=u),a.hasOwnProperty(c="EXPONENTIAL_AT")&&(u=a[c],u&&u.pop?(ne(u[0],-le,0,c),ne(u[1],0,le,c),h=u[0],f=u[1]):(ne(u,-le,le,c),h=-(f=u<0?-u:u))),a.hasOwnProperty(c="RANGE"))if(u=a[c],u&&u.pop)ne(u[0],-le,-1,c),ne(u[1],1,le,c),C=u[0],E=u[1];else if(ne(u,-le,le,c),u)C=-(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],ne(u,0,9,c),v=u),a.hasOwnProperty(c="POW_PRECISION")&&(u=a[c],ne(u,0,le,c),O=u),a.hasOwnProperty(c="FORMAT"))if(u=a[c],typeof u=="object")I=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",k=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:[C,E],CRYPTO:x,MODULO_MODE:v,POW_PRECISION:O,FORMAT:I,ALPHABET:k}},P.isBigNumber=function(a){if(!a||a._isBigNumber!==!0)return!1;if(!P.DEBUG)return!0;var c,u,A=a.c,m=a.e,y=a.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>=Re||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(xe+"Invalid BigNumber: "+a)},P.maximum=P.max=function(){return U(arguments,-1)},P.minimum=P.min=function(){return U(arguments,1)},P.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 A,m,y,w,p,g=0,T=[],b=new P(i);if(u==null?u=o:ne(u,0,le),w=Un(u/W),x)if(crypto.getRandomValues){for(A=crypto.getRandomValues(new Uint32Array(w*=2));g<w;)p=A[g]*131072+(A[g+1]>>>11),p>=9e15?(m=crypto.getRandomValues(new Uint32Array(2)),A[g]=m[0],A[g+1]=m[1]):(T.push(p%1e14),g+=2);g=w/2}else if(crypto.randomBytes){for(A=crypto.randomBytes(w*=7);g<w;)p=(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],p>=9e15?crypto.randomBytes(7).copy(A,g):(T.push(p%1e14),g+=7);g=w/7}else throw x=!1,Error(xe+"crypto unavailable");if(!x)for(;g<w;)p=c(),p<9e15&&(T[g++]=p%1e14);for(w=T[--g],u%=W,w&&u&&(p=Ln[W-u],T[g]=De(w/p)*p);T[g]===0;T.pop(),g--);if(g<0)T=[y=0];else{for(y=-1;T[0]===0;T.splice(0,1),y-=W);for(g=1,p=T[0];p>=10;p/=10,g++);g<W&&(y-=W-g)}return b.e=y,b.c=T,b}})(),P.sum=function(){for(var a=1,c=arguments,u=new P(c[0]);a<c.length;)u=u.plus(c[a++]);return u},n=(function(){var a="0123456789";function c(u,A,m,y){for(var w,p=[0],g,T=0,b=u.length;T<b;){for(g=p.length;g--;p[g]*=A);for(p[0]+=y.indexOf(u.charAt(T++)),w=0;w<p.length;w++)p[w]>m-1&&(p[w+1]==null&&(p[w+1]=0),p[w+1]+=p[w]/m|0,p[w]%=m)}return p.reverse()}return function(u,A,m,y,w){var p,g,T,b,D,R,L,G,ie=u.indexOf("."),de=o,J=d;for(ie>=0&&(b=O,O=0,u=u.replace(".",""),G=new P(A),R=G.pow(u.length-ie),O=b,G.c=c(je(Ie(R.c),R.e,"0"),10,m,a),G.e=G.c.length),L=c(u,A,m,w?(p=k,a):(p=a,k)),T=b=L.length;L[--b]==0;L.pop());if(!L[0])return p.charAt(0);if(ie<0?--T:(R.c=L,R.e=T,R.s=y,R=t(R,G,de,J,m),L=R.c,D=R.r,T=R.e),g=T+de+1,ie=L[g],b=m/2,D=D||g<0||L[g+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[g-1]&1||J==(R.s<0?8:7)),g<1||!L[0])u=D?je(p.charAt(1),-de,p.charAt(0)):p.charAt(0);else{if(L.length=g,D)for(--m;++L[--g]>m;)L[g]=0,g||(++T,L=[1].concat(L));for(b=L.length;!L[--b];);for(ie=0,u="";ie<=b;u+=p.charAt(L[ie++]));u=je(u,T,p.charAt(0))}return u}})(),t=(function(){function a(A,m,y){var w,p,g,T,b=0,D=A.length,R=m%et,L=m/et|0;for(A=A.slice();D--;)g=A[D]%et,T=A[D]/et|0,w=L*g+T*R,p=R*g+w%et*et+b,b=(p/y|0)+(w/et|0)+L*T,A[D]=p%y;return b&&(A=[b].concat(A)),A}function c(A,m,y,w){var p,g;if(y!=w)g=y>w?1:-1;else for(p=g=0;p<y;p++)if(A[p]!=m[p]){g=A[p]>m[p]?1:-1;break}return g}function u(A,m,y,w){for(var p=0;y--;)A[y]-=p,p=A[y]<m[y]?1:0,A[y]=p*w+A[y]-m[y];for(;!A[0]&&A.length>1;A.splice(0,1));}return function(A,m,y,w,p){var g,T,b,D,R,L,G,ie,de,J,te,ge,Pn,yr,gr,$e,un,_e=A.s==m.s?1:-1,Ce=A.c,ae=m.c;if(!Ce||!Ce[0]||!ae||!ae[0])return new P(!A.s||!m.s||(Ce?ae&&Ce[0]==ae[0]:!ae)?NaN:Ce&&Ce[0]==0||!ae?_e*0:_e/0);for(ie=new P(_e),de=ie.c=[],T=A.e-m.e,_e=y+T+1,p||(p=Re,T=Oe(A.e/W)-Oe(m.e/W),_e=_e/W|0),b=0;ae[b]==(Ce[b]||0);b++);if(ae[b]>(Ce[b]||0)&&T--,_e<0)de.push(1),D=!0;else{for(yr=Ce.length,$e=ae.length,b=0,_e+=2,R=De(p/(ae[0]+1)),R>1&&(ae=a(ae,R,p),Ce=a(Ce,R,p),$e=ae.length,yr=Ce.length),Pn=$e,J=Ce.slice(0,$e),te=J.length;te<$e;J[te++]=0);un=ae.slice(),un=[0].concat(un),gr=ae[0],ae[1]>=p/2&&gr++;do{if(R=0,g=c(ae,J,$e,te),g<0){if(ge=J[0],$e!=te&&(ge=ge*p+(J[1]||0)),R=De(ge/gr),R>1)for(R>=p&&(R=p-1),L=a(ae,R,p),G=L.length,te=J.length;c(L,J,G,te)==1;)R--,u(L,$e<G?un:ae,G,p),G=L.length,g=1;else R==0&&(g=R=1),L=ae.slice(),G=L.length;if(G<te&&(L=[0].concat(L)),u(J,L,te,p),te=J.length,g==-1)for(;c(ae,J,$e,te)<1;)R++,u(J,$e<te?un:ae,te,p),te=J.length}else g===0&&(R++,J=[0]);de[b++]=R,J[0]?J[te++]=Ce[Pn]||0:(J=[Ce[Pn]],te=1)}while((Pn++<yr||J[0]!=null)&&_e--);D=J[0]!=null,de[0]||de.splice(0,1)}if(p==Re){for(b=1,_e=de[0];_e>=10;_e/=10,b++);Y(ie,y+(ie.e=b+T*W-1)+1,w,D)}else ie.e=T,ie.r=+D;return ie}})();function K(a,c,u,A){var m,y,w,p,g;if(u==null?u=d:ne(u,0,8),!a.c)return a.toString();if(m=a.c[0],w=a.e,c==null)g=Ie(a.c),g=A==1||A==2&&(w<=h||w>=f)?mn(g,w):je(g,w,"0");else if(a=Y(new P(a),c,u),y=a.e,g=Ie(a.c),p=g.length,A==1||A==2&&(c<=y||y<=h)){for(;p<c;g+="0",p++);g=mn(g,y)}else if(c-=w+(A===2&&y>w),g=je(g,y,"0"),y+1>p){if(--c>0)for(g+=".";c--;g+="0");}else if(c+=y-p,c>0)for(y+1==p&&(g+=".");c--;g+="0");return a.s<0&&m?"-"+g:g}function U(a,c){for(var u,A,m=1,y=new P(a[0]);m<a.length;m++)A=new P(a[m]),(!A.s||(u=mt(y,A))===c||u===0&&y.s===c)&&(y=A);return y}function Z(a,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)>E?a.c=a.e=null:u<C?a.c=[a.e=0]:(a.e=u,a.c=c),a}r=(function(){var a=/^(-?)0([xbo])(?=\w[\w.]*$)/i,c=/^([^.]+)\.$/,u=/^\.([^.]+)$/,A=/^-?(Infinity|NaN)$/,m=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(y,w,p,g){var T,b=p?w:w.replace(m,"");if(A.test(b))y.s=isNaN(b)?null:b<0?-1:1;else{if(!p&&(b=b.replace(a,function(D,R,L){return T=(L=L.toLowerCase())=="x"?16:L=="b"?2:8,!g||g==T?R:D}),g&&(T=g,b=b.replace(c,"$1").replace(u,"0.$1")),w!=b))return new P(b,T);if(P.DEBUG)throw Error(xe+"Not a"+(g?" base "+g:"")+" number: "+w);y.s=null}y.c=y.e=null}})();function Y(a,c,u,A){var m,y,w,p,g,T,b,D=a.c,R=Ln;if(D){e:{for(m=1,p=D[0];p>=10;p/=10,m++);if(y=c-m,y<0)y+=W,w=c,g=D[T=0],b=De(g/R[m-w-1]%10);else if(T=Un((y+1)/W),T>=D.length)if(A){for(;D.length<=T;D.push(0));g=b=0,m=1,y%=W,w=y-W+1}else break e;else{for(g=p=D[T],m=1;p>=10;p/=10,m++);y%=W,w=y-W+m,b=w<0?0:De(g/R[m-w-1]%10)}if(A=A||c<0||D[T+1]!=null||(w<0?g:g%R[m-w-1]),A=u<4?(b||A)&&(u==0||u==(a.s<0?3:2)):b>5||b==5&&(u==4||A||u==6&&(y>0?w>0?g/R[m-w]:0:D[T-1])%10&1||u==(a.s<0?8:7)),c<1||!D[0])return D.length=0,A?(c-=a.e+1,D[0]=R[(W-c%W)%W],a.e=-c||0):D[0]=a.e=0,a;if(y==0?(D.length=T,p=1,T--):(D.length=T+1,p=R[W-y],D[T]=w>0?De(g/R[m-w]%R[w])*p:0),A)for(;;)if(T==0){for(y=1,w=D[0];w>=10;w/=10,y++);for(w=D[0]+=p,p=1;w>=10;w/=10,p++);y!=p&&(a.e++,D[0]==Re&&(D[0]=1));break}else{if(D[T]+=p,D[T]!=Re)break;D[T--]=0,p=1}for(y=D.length;D[--y]===0;D.pop());}a.e>E?a.c=a.e=null:a.e<C&&(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?mn(c,u):je(c,u,"0"),a.s<0?"-"+c:c)}return s.absoluteValue=s.abs=function(){var a=new P(this);return a.s<0&&(a.s=1),a},s.comparedTo=function(a,c){return mt(this,new P(a,c))},s.decimalPlaces=s.dp=function(a,c){var u,A,m,y=this;if(a!=null)return ne(a,0,le),c==null?c=d:ne(c,0,8),Y(new P(y),a+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(a,c){return t(this,new P(a,c),o,d)},s.dividedToIntegerBy=s.idiv=function(a,c){return t(this,new P(a,c),0,1)},s.exponentiatedBy=s.pow=function(a,c){var u,A,m,y,w,p,g,T,b,D=this;if(a=new P(a),a.c&&!a.isInteger())throw Error(xe+"Exponent not an integer: "+oe(a));if(c!=null&&(c=new P(c)),p=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 P(Math.pow(+oe(D),p?a.s*(2-pn(a)):+oe(a))),c?b.mod(c):b;if(g=a.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(a.e>9&&(D.e>0||D.e<-1||(D.e==0?D.c[0]>1||p&&D.c[1]>=24e7:D.c[0]<8e13||p&&D.c[0]<=9999975e7)))return y=D.s<0&&pn(a)?-0:0,D.e>-1&&(y=1/y),new P(g?1/y:y);O&&(y=Un(O/W+2))}for(p?(u=new P(.5),g&&(a.s=1),T=pn(a)):(m=Math.abs(+oe(a)),T=m%2),b=new P(i);;){if(T){if(b=b.times(D),!b.c)break;y?b.c.length>y&&(b.c.length=y):A&&(b=b.mod(c))}if(m){if(m=De(m/2),m===0)break;T=m%2}else if(a=a.times(u),Y(a,a.e+1,1),a.e>14)T=pn(a);else{if(m=+oe(a),m===0)break;T=m%2}D=D.times(D),y?D.c&&D.c.length>y&&(D.c.length=y):A&&(D=D.mod(c))}return A?b:(g&&(b=i.div(b)),c?b.mod(c):y?Y(b,O,d,w):b)},s.integerValue=function(a){var c=new P(this);return a==null?a=d:ne(a,0,8),Y(c,c.e+1,a)},s.isEqualTo=s.eq=function(a,c){return mt(this,new P(a,c))===0},s.isFinite=function(){return!!this.c},s.isGreaterThan=s.gt=function(a,c){return mt(this,new P(a,c))>0},s.isGreaterThanOrEqualTo=s.gte=function(a,c){return(c=mt(this,new P(a,c)))===1||c===0},s.isInteger=function(){return!!this.c&&Oe(this.e/W)>this.c.length-2},s.isLessThan=s.lt=function(a,c){return mt(this,new P(a,c))<0},s.isLessThanOrEqualTo=s.lte=function(a,c){return(c=mt(this,new P(a,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(a,c){var u,A,m,y,w=this,p=w.s;if(a=new P(a,c),c=a.s,!p||!c)return new P(NaN);if(p!=c)return a.s=-c,w.plus(a);var g=w.e/W,T=a.e/W,b=w.c,D=a.c;if(!g||!T){if(!b||!D)return b?(a.s=-c,a):new P(D?w:NaN);if(!b[0]||!D[0])return D[0]?(a.s=-c,a):new P(b[0]?w:d==3?-0:0)}if(g=Oe(g),T=Oe(T),b=b.slice(),p=g-T){for((y=p<0)?(p=-p,m=b):(T=g,m=D),m.reverse(),c=p;c--;m.push(0));m.reverse()}else for(A=(y=(p=b.length)<(c=D.length))?p:c,p=c=0;c<A;c++)if(b[c]!=D[c]){y=b[c]<D[c];break}if(y&&(m=b,b=D,D=m,a.s=-a.s),c=(A=D.length)-(u=b.length),c>0)for(;c--;b[u++]=0);for(c=Re-1;A>p;){if(b[--A]<D[A]){for(u=A;u&&!b[--u];b[u]=c);--b[u],b[A]+=Re}b[A]-=D[A]}for(;b[0]==0;b.splice(0,1),--T);return b[0]?Z(a,b,T):(a.s=d==3?-1:1,a.c=[a.e=0],a)},s.modulo=s.mod=function(a,c){var u,A,m=this;return a=new P(a,c),!m.c||!a.s||a.c&&!a.c[0]?new P(NaN):!a.c||m.c&&!m.c[0]?new P(m):(v==9?(A=a.s,a.s=1,u=t(m,a,0,3),a.s=A,u.s*=A):u=t(m,a,0,v),a=m.minus(u.times(a)),!a.c[0]&&v==1&&(a.s=m.s),a)},s.multipliedBy=s.times=function(a,c){var u,A,m,y,w,p,g,T,b,D,R,L,G,ie,de,J=this,te=J.c,ge=(a=new P(a,c)).c;if(!te||!ge||!te[0]||!ge[0])return!J.s||!a.s||te&&!te[0]&&!ge||ge&&!ge[0]&&!te?a.c=a.e=a.s=null:(a.s*=J.s,!te||!ge?a.c=a.e=null:(a.c=[0],a.e=0)),a;for(A=Oe(J.e/W)+Oe(a.e/W),a.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(ie=Re,de=et,m=D;--m>=0;){for(u=0,R=ge[m]%de,L=ge[m]/de|0,w=g,y=m+w;y>m;)T=te[--w]%de,b=te[w]/de|0,p=L*T+b*R,T=R*T+p%de*de+G[y]+u,u=(T/ie|0)+(p/de|0)+L*b,G[y--]=T%ie;G[y]=u}return u?++A:G.splice(0,1),Z(a,G,A)},s.negated=function(){var a=new P(this);return a.s=-a.s||null,a},s.plus=function(a,c){var u,A=this,m=A.s;if(a=new P(a,c),c=a.s,!m||!c)return new P(NaN);if(m!=c)return a.s=-c,A.minus(a);var y=A.e/W,w=a.e/W,p=A.c,g=a.c;if(!y||!w){if(!p||!g)return new P(m/0);if(!p[0]||!g[0])return g[0]?a:new P(p[0]?A:m*0)}if(y=Oe(y),w=Oe(w),p=p.slice(),m=y-w){for(m>0?(w=y,u=g):(m=-m,u=p),u.reverse();m--;u.push(0));u.reverse()}for(m=p.length,c=g.length,m-c<0&&(u=g,g=p,p=u,c=m),m=0;c;)m=(p[--c]=p[c]+g[c]+m)/Re|0,p[c]=Re===p[c]?0:p[c]%Re;return m&&(p=[m].concat(p),++w),Z(a,p,w)},s.precision=s.sd=function(a,c){var u,A,m,y=this;if(a!=null&&a!==!!a)return ne(a,1,le),c==null?c=d:ne(c,0,8),Y(new P(y),a,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 a&&y.e+1>A&&(A=y.e+1),A},s.shiftedBy=function(a){return ne(a,-Rn,Rn),this.times("1e"+a)},s.squareRoot=s.sqrt=function(){var a,c,u,A,m,y=this,w=y.c,p=y.s,g=y.e,T=o+4,b=new P("0.5");if(p!==1||!w||!w[0])return new P(!p||p<0&&(!w||w[0])?NaN:w?y:1/0);if(p=Math.sqrt(+oe(y)),p==0||p==1/0?(c=Ie(w),(c.length+g)%2==0&&(c+="0"),p=Math.sqrt(+c),g=Oe((g+1)/2)-(g<0||g%2),p==1/0?c="5e"+g:(c=p.toExponential(),c=c.slice(0,c.indexOf("e")+1)+g),u=new P(c)):u=new P(p+""),u.c[0]){for(g=u.e,p=g+T,p<3&&(p=0);;)if(m=u,u=b.times(m.plus(t(y,m,T,1))),Ie(m.c).slice(0,p)===(c=Ie(u.c)).slice(0,p))if(u.e<g&&--p,c=c.slice(p-3,p+1),c=="9999"||!A&&c=="4999"){if(!A&&(Y(m,m.e+o+2,0),m.times(m).eq(y))){u=m;break}T+=4,p+=4,A=1}else{(!+c||!+c.slice(1)&&c.charAt(0)=="5")&&(Y(u,u.e+o+2,1),a=!u.times(u).eq(y));break}}return Y(u,u.e+o+1,d,a)},s.toExponential=function(a,c){return a!=null&&(ne(a,0,le),a++),K(this,a,c,1)},s.toFixed=function(a,c){return a!=null&&(ne(a,0,le),a=a+this.e+1),K(this,a,c)},s.toFormat=function(a,c,u){var A,m=this;if(u==null)a!=null&&c&&typeof c=="object"?(u=c,c=null):a&&typeof a=="object"?(u=a,a=c=null):u=I;else if(typeof u!="object")throw Error(xe+"Argument not an object: "+u);if(A=m.toFixed(a,c),m.c){var y,w=A.split("."),p=+u.groupSize,g=+u.secondaryGroupSize,T=u.groupSeparator||"",b=w[0],D=w[1],R=m.s<0,L=R?b.slice(1):b,G=L.length;if(g&&(y=p,p=g,g=y,G-=y),p>0&&G>0){for(y=G%p||p,b=L.substr(0,y);y<G;y+=p)b+=T+L.substr(y,p);g>0&&(b+=T+L.slice(y)),R&&(b="-"+b)}A=D?b+(u.decimalSeparator||"")+((g=+u.fractionGroupSize)?D.replace(new RegExp("\\d{"+g+"}\\B","g"),"$&"+(u.fractionGroupSeparator||"")):D):b}return(u.prefix||"")+A+(u.suffix||"")},s.toFraction=function(a){var c,u,A,m,y,w,p,g,T,b,D,R,L=this,G=L.c;if(a!=null&&(p=new P(a),!p.isInteger()&&(p.c||p.s!==1)||p.lt(i)))throw Error(xe+"Argument "+(p.isInteger()?"out of range: ":"not an integer: ")+oe(p));if(!G)return new P(L);for(c=new P(i),T=u=new P(i),A=g=new P(i),R=Ie(G),y=c.e=R.length-L.e-1,c.c[0]=Ln[(w=y%W)<0?W+w:w],a=!a||p.comparedTo(c)>0?y>0?c:T:p,w=E,E=1/0,p=new P(R),g.c[0]=0;b=t(p,c,0,1),m=u.plus(b.times(A)),m.comparedTo(a)!=1;)u=A,A=m,T=g.plus(b.times(m=T)),g=m,c=p.minus(b.times(m=c)),p=m;return m=t(a.minus(u),A,0,1),g=g.plus(m.times(T)),u=u.plus(m.times(A)),g.s=T.s=L.s,y=y*2,D=t(T,A,y,d).minus(L).abs().comparedTo(t(g,u,y,d).minus(L).abs())<1?[T,A]:[g,u],E=w,D},s.toNumber=function(){return+oe(this)},s.toPrecision=function(a,c){return a!=null&&ne(a,1,le),K(this,a,c,2)},s.toString=function(a){var c,u=this,A=u.s,m=u.e;return m===null?A?(c="Infinity",A<0&&(c="-"+c)):c="NaN":(a==null?c=m<=h||m>=f?mn(Ie(u.c),m):je(Ie(u.c),m,"0"):a===10&&B?(u=Y(new P(u),o+m+1,d),c=je(Ie(u.c),u.e,"0")):(ne(a,2,k.length,"Base"),c=n(je(Ie(u.c),m,"0"),10,a,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,i=e[0]+"";r<s;){for(t=e[r++]+"",n=W-t.length;n--;t="0"+t);i+=t}for(s=i.length;i.charCodeAt(--s)===48;);return i.slice(0,s+1||1)}function mt(e,t){var n,r,s=e.c,i=t.c,o=e.s,d=t.s,h=e.e,f=t.e;if(!o||!d)return null;if(n=s&&!s[0],r=i&&!i[0],n||r)return n?r?0:-d:o;if(o!=d)return o;if(n=o<0,r=h==f,!s||!i)return r?0:!s^n?1:-1;if(!r)return h>f^n?1:-1;for(d=(h=s.length)<(f=i.length)?h:f,o=0;o<d;o++)if(s[o]!=i[o])return s[o]>i[o]^n?1:-1;return h==f?0:h>f^n?1:-1}function ne(e,t,n,r){if(e<t||e>n||e!==De(e))throw Error(xe+(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 mn(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function je(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 S=kr();function hi(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 pi={1:{adapter:{Odos:"0x1ae80D14C52F82c09a54C423e6f9D5Fb737089C8",Sushi:"0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c"},dex:{sushiswap:{type:"default",solver:"Sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"}}},10:{adapter:{Odos:"0xc7Ec90152fd5A6210570cb04C4Ab099Bdac352af"},dex:{}},14:{adapter:{SparkDex:"0x00c7617C471Ef69124464CEc318a3b8CC90aE9A7"},dex:{spark:{type:"default",solver:"SparkDex",router:"0x0f3D8a38D4c74afBebc2c42695642f0e3acb15D3",adapter:"0x00c7617C471Ef69124464CEc318a3b8CC90aE9A7",fee:"0xaeA8C3e1a129A77686E115b1a46D9aD8405F7D2b"}}},56:{adapter:{Odos:"0x6c17cc2984A87BD8b002c6E3C08dBB8c8Eb89E48",Orbs:"0xaf3532dca7b4a75cD06671614C093e9e8fb5b1F2"},dex:{thena:{type:"default",solver:"Odos",router:"0x89b8AA89FDd0507a99d334CBe3C808fAFC7d850E",adapter:"0x9E61dEabe996236814c28eC69ab2A7405cB6f03E",fee:"0x15eBc8b5b3877512FFF23650188694A9a8891FAc"},pancake:{type:"p2",solver:"Orbs",router:"0xd9C500DfF816a1Da21A48A732d3498Bf09dc9AEB",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0x52Ed96B1AEd25818B6A284b063b055488E012b73",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},newera:{type:"default",solver:"Odos",router:"0x89b8AA89FDd0507a99d334CBe3C808fAFC7d850E",adapter:"0x6236a466CE5c368DC6686d69cAcf5561196B76ef",fee:"0x4E7454909eB6D539111D56b50d68897E933D2d11"}}},137:{adapter:{Odos:"0x5628D7383b42E14E83DA310de3e7E04E6b025418",Paraswap:"0x179C4b8e982b5F1365d36CC8d0c1CEB621B7198D"},dex:{quick:{type:"paraswap",solver:"Paraswap",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0x727e1CbA41Ff1ff11C32fa43DAb499b4317A1b65",fee:"0xd207DC6a6dA88f27c8DB78201F974161b1d84b1f"},teafi:{type:"paraswap",solver:"Paraswap",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0xF710D67C783D2C14671EC1c61B0683DCb996F5c3",fee:"0x04Ff96e2c4D62b5771795d307AD679a25b3D2D50"}}},143:{adapter:{OpenOcean:"0xc7f07C830e22FCA94bF52F38C6707F9D396c6172",Kyber:"0x6f4e5b8d7F6b037c62277992c39E7834D7C04596"},dex:{yowie:{type:"default",solver:"OpenOcean",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xCA84Ab5a5A5bf2cff6AC0C835eF049365D13c6cB",fee:"0x6AF3eE77A3A3257777F5649aFa611b4C7Fd975Ef"},pangolin:{type:"default",solver:"Kyber",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xf42106eBf985bF49b39eba0114F57FA05e7B52eD",fee:"0xde92da99D188Ceb54A11ec711EF52D808A6260B5"}}},146:{adapter:{Odos:"0x0123695379045f9db515E6a77d8154959B94B599",OpenOcean:"0xc7f07C830e22FCA94bF52F38C6707F9D396c6172",Magpie:"0x4914efb617fEa2Fd7529fdb365854Fd8f17bCBDE"},dex:{spooky:{type:"default",solver:"Magpie",router:"0x20f6ee51340adeed01a59b0e65cb3703f3dc860c",adapter:"0x0F6533Fd45D13ad6AAa364023d6c05eCB2d3Ac2E",fee:"0x840Df4684B35BC68BcdA3F6707A3c82A0D662f8b"},swapx:{type:"default",solver:"OpenOcean",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xa7AE3ABf86C81cCEFEd6bE77045F2a32660c1B1c",fee:"0x6E03f7BC0f141894612AA017796096399623895F"},shadow:{type:"default",solver:"Magpie",router:"0x20f6ee51340adeed01a59b0e65cb3703f3dc860c",adapter:"0x39b024E187e5f35fea05953fECB9314a97de3d94",fee:"0xb9e3751fAF3187E1bC468E56a707a8A91754460e"}}},1329:{adapter:{DragonSwap:"0x1e84A9f30607959d2d8b1a04171ef7D9522Ef502",OpenOcean:"0xc7f07C830e22FCA94bF52F38C6707F9D396c6172"},dex:{dragon:{type:"default",solver:"DragonSwap",router:"0x11DA6463D6Cb5a03411Dbf5ab6f6bc3997Ac7428",adapter:"0x1e84A9f30607959d2d8b1a04171ef7D9522Ef502",fee:"0x0dc1E0525202b32e89bA78ed55b1e5cEdB751334"},nami:{type:"default",solver:"OpenOcean",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xba56F9A7865d430c8293851D576b5728Ca711ff5",fee:"0xeB58450e23632003f013568703F54446070E2E80"}}},5e3:{adapter:{Odos:"0x3a0fA0f95ea07026c5f84D8d3444Dd6E15AE1874"},dex:{}},8453:{adapter:{Odos:"0x1c947387AFC3435135e3da51ccEAB20eD5377DeA",Orbs:"0x917b492557957f5dD3e69c04c8E1Ac3d6948c022",Kyber:"0x6f4e5b8d7F6b037c62277992c39E7834D7C04596",TrebleSwap:"0x6f4938535879c668A797F2a6e9B912c54f9D43Cf",Sushi:"0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c"},dex:{pancake:{type:"p2",solver:"Orbs",router:"0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},quick:{type:"default",solver:"Kyber",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"}}},42161:{adapter:{Odos:"0x419faf03F5661e0F0471eF9D7935f09534ffc50F",Paraswap:"0x179C4b8e982b5F1365d36CC8d0c1CEB621B7198D",Orbs:"0x917b492557957f5dD3e69c04c8E1Ac3d6948c022",Sushi:"0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c"},dex:{arbidex:{type:"default",solver:"Odos",router:"0xa669e7A0d4b3e4Fa48af2dE86BD4CD7126Be4e13",adapter:"0xaA66173674F4331e7e672899B3E6aB1190450898",fee:"0xa0c11852f8A44e32F9EC10AD25986A53842f72Ca"},ramses:{type:"paraswap",solver:"Paraswap",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0xf075352f43cd15bA51B0957A4465223EDf6b4Cd8",fee:"0xB5BaCB60ECDa0bEF809B2A26eC9B4B926835D7af"},omni:{type:"paraswap",solver:"Paraswap",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0x41c925E8E4fC65136BDf5322824E0D8c20c4824e",fee:"0xba5291526c30B097E9F1Fd1Be301E2ab6E0782aa"},chronos:{type:"default",solver:"Odos",router:"0x19cEeAd7105607Cd444F5ad10dd51356436095a1",adapter:"0x6a6b8975d1b131EFd0a9b536766EE7E5d4a16CF2",fee:"0x5729af83240EFecAa18eafaAE82961c2DD045Dbe"},pancake:{type:"p2",solver:"Orbs",router:"0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},sushiswap:{type:"default",solver:"Sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"}}},43114:{adapter:{Odos:"0x533dA659Ef4C2C1d4c98420e1dbe9C68D8538f50",Kyber:"0x6f4e5b8d7F6b037c62277992c39E7834D7C04596"},dex:{blackhole:{type:"default",solver:"Kyber",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xccdF1D6ce95FeC0F842197470CE8969A678B0A04",fee:"0x7f8B62520D9B5DA0ED517cc36e8dcb2a356f1928"},pangolin:{type:"default",solver:"Kyber",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xf42106eBf985bF49b39eba0114F57FA05e7B52eD",fee:"0xde92da99D188Ceb54A11ec711EF52D808A6260B5"}}},59144:{adapter:{Odos:"0xA58A55AC39b47504A63993A91B78544158862e61",Orbs:"0x917b492557957f5dD3e69c04c8E1Ac3d6948c022",OpenOcean:"0xd2e68b1d1C5DBB2D6cC396c10C55017e01309C37"},dex:{pancake:{type:"p2",solver:"Orbs",router:"0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},lynex:{type:"default",solver:"OpenOcean",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xd8bC1FF79a642e8D7Fbd0711374F287202fBb3AA",fee:"0xcb36ed1B1BfAD8F7FC9651f52d21f04A68677423"}}},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",utilaAdapter:"0x7671291910b559d7a05ab73ee31dd714d9c6e7b065c9496338bf427182ae5145",utilaFee:"0x46f797cddb221ecf6279b56f52e2f6360cd721ef95bd5a17dd0ffceffaaf7fd6"},dex:{agent:{type:"universal",adapter:"0x0002BeFB46587d460AcEA9B2792c4A4c67B9cADa",fee:"0x0006d9557Ac9Af4f31962896299ba4FaBDaB9fEE"},utila:{type:"universal",adapter:"0x000ADa14B2ECF45Da6Cf1B33dE34e05231E9C76f",fee:"0x000FEee351263c82501a4dF5f699a8b630ac7f36"}}}};var Nn,_r;function mi(){if(_r)return Nn;_r=1;const e=pi,t=i=>hi(`./out/${i}.sol/${i}.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(i){var d;if(!i)return;const o=e[i];if(o)return{...((d=e["*"])==null?void 0:d.adapter)??{},...o.adapter??{}}}function s(i,o){if(!i)return;const{dex:d,salt:h,...f}=e["*"]??{},C=e[i];if(!C)return;const{dex:E,salt:x,...v}=C,O={...f,...v},I=o==null?void 0:o.trim();if(!I)return O;const k=d==null?void 0:d[I],B=E==null?void 0:E[I];if(!(!k&&!B))return{...O,...k,...B}}return Nn={config:s,adapters:r,abis:n,raw:e},Nn}var Br=mi();const Bt=(e,t)=>{if(!e||!t)return"";const n=S(10).pow(e||0);return S(t).times(n).idiv(n).div(n).toFixed()};S(0),S(1),S(10),S(1e18);function yt(e,t){return e==t||e.toLowerCase()==t.toLowerCase()}const Ut=e=>!!Js.find(t=>yt(t,e||""));function yi(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,gi=e=>!e||e==="NaN"?"0":S(e).decimalPlaces(0).toFixed(),At=e=>Object.values(ye).find(t=>t.id===e),Ai=e=>{if(!e)return;const t=e.map(i=>Ae(i)),n=Object.entries(ei).filter(([i])=>t.includes(i)).flatMap(([,i])=>i),r=e.map(i=>i.exchangeAddress),s=new Set([...r,...n].map(i=>i.toLowerCase()));return Array.from(s)},qn=(e,t)=>e.version===1?(e.fillDelay||0)*1e3+vi(t):(e.fillDelay||0)*1e3,yn=e=>typeof window>"u"?null:new URLSearchParams(window.location.search).get(e),Ur=e=>Nr().filter(t=>t.name===e).map(t=>t.chainId),Kn=(e="",t="",n=18,r=18)=>{if(!S(e||0).gt(0)||!S(t||0).gt(0))return"";const s=Bt(n,e),i=Bt(r,t);return S(i).div(s).toFixed()},Rr=(e,t,n)=>{if(e.type===V.TWAP_MARKET)return"";const r=Bt(t,e.srcAmountPerTrade),s=Bt(n,e.dstMinAmountPerTrade);return S(s).div(r).toFixed()},Lr=(e,t,n)=>{if(e.type===V.TWAP_MARKET)return"";const r=Bt(t,e.srcAmountPerTrade),s=Bt(n,e.triggerPricePerTrade);return S(s).div(r).toFixed()},Ei=(e,t,n)=>{if(!e||!t||!n)return;const r=S(e).times(t),s=S(10).pow(n);return r.div(s).toFixed(0)},bi=(e,t,n,r)=>{if(n||!r||!e||!t)return S(0).toString();const s=S(e).times(S(t)),i=S(10).pow(r),o=s.div(i);return S.max(1,o).integerValue(S.ROUND_FLOOR).toFixed(0)},Ti=(e,t,n,r)=>{if(e===z.TWAP||e===z.LIMIT)return"0";if(!r||!t||!n)return;const s=S(t).times(S(n)),i=S(10).pow(r),o=s.div(i);return S.max(1,o).integerValue(S.ROUND_FLOOR).toFixed(0)||"0"},wi=(e,t,n,r)=>{const s=gt(n)*2*t,i=yn(Yt.DURATION),o=yi(i?Number(i):s);return i?{unit:o,value:Number(S(Number(i)/o).toFixed(2))}:r||(e===z.LIMIT?{unit:Pe.Days,value:7}:e===z.STOP_LOSS||e===z.TAKE_PROFIT?{unit:Pe.Days,value:1}:{unit:o,value:Number(S(s/o).toFixed(2))})},Ci=(e,t,n)=>t!==z.TWAP?1:n!==void 0?n:Math.max(1,Math.ceil(e/2)),xi=(e,t,n)=>{if(!e||!t||!n)return 1;const s=S(t).times(e).div(n).integerValue(S.ROUND_FLOOR).toNumber();return Math.max(1,s)},Si=(e,t)=>e+gt(t)+6e4,vi=e=>e.bidDelaySeconds*1e3*2,Fi=(e="",t=0)=>!e||!t?"0":S(e).div(t).integerValue(S.ROUND_FLOOR).toFixed(0),Pi=(e,t)=>({isError:!(e.unit===Bn.unit&&e.value===Bn.value)&&gt(e)*t>hn,value:Math.floor(hn/t)}),Di=(e="",t="",n)=>{if(n===z.STOP_LOSS)return{isError:S(t||0).gte(S(e||0)),value:e}},Oi=(e="",t="",n)=>{if(n===z.TAKE_PROFIT)return{isError:S(t||0).lte(S(e||0)),value:e}},Ii=(e="",t="",n=!1,r)=>{if(!n&&r===z.STOP_LOSS)return{isError:S(t||0).gte(S(e||0)),value:e}},Mi=(e="",t="",n=!1,r)=>{if(!n&&r===z.TAKE_PROFIT)return{isError:S(t||0).gte(S(e||0)),value:e}},ki=(e,t)=>e===z.STOP_LOSS||e===z.TAKE_PROFIT?{isError:gt(t)>5184e6,value:5184e6}:{isError:gt(t)>hn,value:hn},_i=e=>({isError:gt(e)<Or,value:Or}),Bi=e=>({isError:gt(e)<kn,value:kn}),Ui=(e,t,n)=>({isError:S(t||0).multipliedBy(e||0).isLessThan(n),value:n}),Ri=(e,t,n)=>({isError:n===z.TWAP&&S(e).isGreaterThan(t),value:t}),Li=(e,t)=>{if(e===Be.Pancake)switch(t){case 56:return j.PancakeSwap;case 42161:return j.PancakeSwapArbitrum;case 8453:return j.PancakeSwapBase;case 59144:return j.PancakeSwapLinea;default:return j.PancakeSwap}if(e===Be.Sushiswap)switch(t){case 1:return j.SushiEth;case 42161:return j.SushiArb;case 8453:return j.SushiBase;case 747474:return j.SushiKatana;default:return j.SushiEth}if(e===Be.Quick)switch(t){case 137:return j.QuickSwap;case 8453:return j.QuickSwapBase;default:return j.QuickSwap}if(e===Be.Thena)switch(t){case 56:return j.Thena;default:return j.Thena}if(e===Be.Spooky)switch(t){case 250:return j.SpookySwap;case 146:return j.SpookySwapSonic;default:return j.SpookySwap}if(e===Be.Lynex)switch(t){case 59144:return j.Lynex;default:return j.Lynex}if(e===Be.Swapx)switch(t){case 146:return j.SwapX;default:return j.SwapX}if(e===Be.Blackhole)switch(t){case 43114:return j.BlackholeAvax;default:return j.BlackholeAvax}},Hn=(e,t=0)=>{const{abi:n,...r}=Br.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:Li(e,t)}},Nr=()=>{var n;const e=Br.raw,t=((n=e["*"])==null?void 0:n.dex)??{};return Object.entries(e).filter(([r])=>r!=="*").flatMap(([r,s])=>{const i={...t,...(s==null?void 0:s.dex)??{}};return!i||typeof i!="object"?[]:Object.entries(i).map(([o])=>({chainId:Number(r),name:o,config:Hn(o,Number(r))}))}).sort((r,s)=>r.name.localeCompare(s.name))},qr=e=>{const t=yn(Yt.MIN_CHUNK_SIZE_USD);return t?parseInt(t):e},Ni=({marketPrice:e,typedInputAmount:t,srcUsd1Token:n,marketPriceLoading:r,triggerPriceError:s,limitPriceError:i,tradesError:o,fillDelayError:d,durationError:h,balanceError:f,minTradeSizeError:C})=>{if(!yn(Yt.IGNORE_ERRORS)&&!(S(e||0).isZero()||S(t||0).isZero()||S(n||"0").isZero()||r))return C||s||i||o||d||h||f},qi=(e,t)=>{const n=Date.now().toString(),r=parseInt((e/1e3).toFixed(0)),s=gi(t/1e3),i=yn(Yt.FRESHNESS),o=i?parseInt(i):60;return{nonce:n,epoch:r,deadline:s,freshness:o}},Kr=({chainId:e,srcToken:t,dstToken:n,srcAmount:r,deadlineMillis:s,fillDelayMillis:i,slippage:o,account:d,srcAmountPerTrade:h,dstMinAmountPerTrade:f="0",triggerAmountPerTrade:C="0",config:E,module:x})=>{const{nonce:v,epoch:O,deadline:I,freshness:k}=qi(i,s),B=Math.floor(Date.now()/1e3).toString(),P=f,K=x===z.STOP_LOSS?C:"0",U=x===z.TAKE_PROFIT?C:"0",Z={permitted:{token:t,amount:r},spender:E.reactor,nonce:v,deadline:I,witness:{reactor:E.reactor,executor:E.executor,exchange:{adapter:E.adapter,ref:E.fee,share:0,data:"0x"},swapper:d,nonce:v,start:B,deadline:I,chainid:e,exclusivity:0,epoch:O,slippage:o,freshness:k,input:{token:t,amount:h,maxAmount:r},output:{token:n,limit:S(P||0).toFixed(),triggerLower:S(K||0).toFixed(),triggerUpper:S(U||0).toFixed(),recipient:d}}};return{domain:{name:"RePermit",version:"1",chainId:e,verifyingContract:E.repermit},order:Z,types:ni,primaryType:ti}},Ki=`https://bi.orbs.network/putes/twap-ui-${.7}`;let Wn="unknown";function Hi(e){Wn=e}function Qn(){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 Wi=(e,t,n)=>{var r,s,i,o,d,h,f,C,E;return{spotVersion:Mn.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:((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:((C=e.twapConfig)==null?void 0:C.exchangeType)||"",pathfinderKey:((E=e.twapConfig)==null?void 0:E.pathfinderKey)||""}},Hr=async e=>{try{await fetch(Ki,{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(){Dn(this,"timeout");Dn(this,"config");Dn(this,"data",{_id:Qn()})}async updateAndSend(t={},n=!1,r){try{this.data={...this.data,...t},n?(await Hr(this.data),r==null||r()):(clearTimeout(this.timeout),this.timeout=setTimeout(()=>{Hr(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:i,fromTokenAmount:o,srcChunkAmount:d,minDstAmountOutPerTrade:h="",triggerPricePerTrade:f="",deadline:C,fillDelay:E,slippage:x,isMarketOrder:v,chunksAmount:O}){this.updateAndSend({toTokenAddress:i.address,toTokenSymbol:i.symbol,fromTokenAddress:s.address,fromTokenSymbol:s.symbol,fromTokenAmount:o,chunksAmount:O,srcChunkAmount:d,minDstAmountOutPerTrade:h,triggerPricePerTrade:f,deadline:C,fillDelay:E,slippage:x,chainId:n,walletAddress:t,module:r,orderType:v?"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:Qn(),action:"module-import",uiVersion:Wn,...Wi(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:Qn(),action:"reset",uiVersion:Wn,origin:this.data.origin,spotVersion:Mn.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 fe=new Qi,$i=e=>{var f;const t=S(e.order.witness.output.limit||0).gt(1),{stop:n,triggerLower:r,triggerUpper:s}=e.order.witness.output,i=S(n||0).eq(Ir),o=i||S(s||0).gt(0),d=!i&&S(n||0).gt(0)||S(r||0).gt(0),h=((f=e.metadata.chunks)==null?void 0:f.length)||S(e.order.witness.input.maxAmount).div(S(e.order.witness.input.amount)).toNumber();return o?t?V.TAKE_PROFIT_LIMIT:V.TAKE_PROFIT_MARKET:d?t?V.STOP_LOSS_LIMIT:V.STOP_LOSS_MARKET:t?h>1&&t?V.TWAP_LIMIT:t?V.LIMIT:V.TWAP_MARKET:V.TWAP_MARKET},ji=e=>{var s;const t=((s=e.metadata.chunks)==null?void 0:s.filter(i=>i.status==="success").length)||0,n=e.metadata.expectedChunks||0,r=S(t).dividedBy(n).toNumber();return r>=.99?100:r<=0?0:Number((r*100).toFixed(2))},zi=(e,t)=>e.metadata.status==="completed"||t>=99?pe.Completed:["pending","eligible"].includes(e.metadata.status)?pe.Open:e.metadata.description.toLowerCase()==="cancelled by contract"?pe.Cancelled:pe.Expired,Vi=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}))},Gi=(e,t)=>{var r;const n=e.length;return n>=t&&((r=e[n-1])==null?void 0:r.timestamp)||0},Xi=e=>S(e.metadata.displayOnlyInputTokenPriceUSD).dividedBy(1e18).toFixed(),$n=e=>Number(e.order.witness.output.limit)===1?"":e.order.witness.output.limit,Zi=e=>{const{triggerLower:t="0",triggerUpper:n="0"}=e.order.witness.output,r=$n(e),s=e.metadata.expectedChunks||1,i=S(n||0).gt(0);return{dstMinAmountPerTrade:r,triggerPricePerTrade:i?n:t,dstMinAmountTotal:S(r).multipliedBy(s).toFixed()}},Yi=e=>{const t=$n(e),n=S(e.order.witness.output.stop||0).eq(Ir),r=e.metadata.expectedChunks||1;return{dstMinAmountPerTrade:n?"":t,triggerPricePerTrade:n?t:S(e.order.witness.output.stop||"").toFixed(),dstMinAmountTotal:n?"":S(t).multipliedBy(r).toFixed()}},Ji=e=>Number(fn)>=2?Zi(e):Yi(e),Wr=e=>{const t=ji(e),n=$n(e),r=e.metadata.expectedChunks||1,s=Vi(e),i=$i(e);return{id:e.hash,hash:e.hash,version:2,type:i,maker:e.order.witness.swapper,progress:t,srcAmountFilled:s.reduce((o,d)=>o.plus(d.inAmount),new S(0)).toFixed()||"",dstAmountFilled:s.reduce((o,d)=>o.plus(d.outAmount),new S(0)).toFixed()||"",fills:s,srcTokenAddress:e.order.witness.input.token,dstTokenAddress:e.order.witness.output.token,orderDollarValueIn:Xi(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:S(n||0).lte(1),chainId:e.order.witness.chainid,filledOrderTimestamp:Gi(s,r),status:zi(e,t),repermitDigest:e.metadata.repermitDigest,isTriggerPrice:i===V.TAKE_PROFIT_MARKET||i===V.TAKE_PROFIT_LIMIT||i===V.STOP_LOSS_LIMIT||i===V.STOP_LOSS_MARKET,rawOrder:e,...Ji(e)}},ea=async({chainId:e,signal:t,account:n,exchange:r,partner:s,isDev:i=!1})=>{try{if(!n)return[];const o=Vs(i),d=new Map;return(await Promise.all(o.map(async f=>{try{const C=Xs({endpoint:f,exchange:r,partner:s}),E=C?`&exchange=${C}`:"",v=await(await fetch(`${f}/orders?swapper=${n}&chainId=${e}${E}`,{signal:t})).json();if(!v||!Array.isArray(v.orders))return[];const O=[];for(const I of v.orders)try{O.push(Wr(I))}catch{continue}return O}catch{return[]}}))).flat().forEach(f=>{d.has(f.id)||d.set(f.id,f)}),Array.from(d.values())}catch{return[]}},Qr=async(e,t,n=!1)=>{try{const r={signature:t,order:e,status:"pending"};fe.onCreateOrderRequest();const s=await fetch(`${zs(n)}/orders/new`,{method:"POST",body:JSON.stringify(r)}),i=await s.json().catch(()=>({}));if(!s.ok||!(i!=null&&i.success)){const d=(i==null?void 0:i.message)??s.statusText??"Request failed",h=(i==null?void 0:i.code)??s.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=Wr(i.signedOrder);return fe.onCreateOrderSuccess(o.id),o}catch(r){throw fe.onCreateOrderError(r),console.error(r),r}},ze=(e,t)=>e&&e.length?e.map(t||(n=>`${n}`)):void 0,ta=e=>{if(e)return Ys[e]},jn=async({chainId:e,buildQuery:t,extractResults:n,signal:r,retries:s=1,limit:i=1e3,page:o})=>{const d=ta(e);if(!d)throw new oa;const h=async E=>{let x=0;for(;x<=s;)try{const v=await fetch(d,{method:"POST",body:JSON.stringify({query:E}),signal:r,headers:{"Content-Type":"application/json"}});if(!v.ok)throw new Error(`HTTP error: ${v.status}`);const O=await v.json();if(O.errors)throw new Error(O.errors[0].message);return n(O)}catch(v){if(x===s)throw v;await new Promise(O=>setTimeout(O,500*2**x)),x++}return[]};let f=0;const C=[];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 C}}if(C.push(...x),x.length<i)break;f++}return C},$r=e=>e.map(t=>({inAmount:t.srcAmountIn,outAmount:t.dstAmountOut,timestamp:t.timestamp,txHash:t.transactionHash})),jr=(e,t)=>{const n=S(e||0).gt(1);return!n&&t===1?V.TWAP_MARKET:t>1&&n?V.TWAP_LIMIT:n?V.LIMIT:V.TWAP_MARKET},na=(e,t,n,r)=>{var x;const s=$r(n||[]),i=new S(e.ask_srcAmount||0).div(e.ask_srcBidAmount).integerValue(S.ROUND_FLOOR).toNumber(),d=(n==null?void 0:n.length)===i?(x=n==null?void 0:n[(n==null?void 0:n.length)-1])==null?void 0:x.timestamp:void 0,h=s.reduce((v,O)=>v.plus(O.inAmount),new S(0)).toFixed(),f=s.reduce((v,O)=>v.plus(O.outAmount),new S(0)).toFixed(),C=zr(e.ask_srcAmount,h),E=jr(e.ask_dstMinAmount,i);return{repermitDigest:"",version:1,isTriggerPrice:!1,id:e.Contract_id.toString(),hash:"",type:jr(e.ask_dstMinAmount,i),srcTokenAddress:e.ask_srcToken,dstTokenAddress:e.ask_dstToken,exchangeAddress:e.exchange,twapAddress:e.twapAddress,maker:e.maker,progress:C,dstAmountFilled:f,srcAmountFilled:h,orderDollarValueIn:S(e.dollarValueIn||0).toFixed(6),srcAmount:e.ask_srcAmount,dstMinAmountTotal:S(e.ask_dstMinAmount).multipliedBy(i).toString(),fills:s,fillDelay:e.ask_fillDelay,deadline:e.ask_deadline*1e3,createdAt:new Date(e.timestamp).getTime(),dstMinAmountPerTrade:S(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:r,rawOrder:e}},ra=e=>{var E;if(!e)return"";const t=ze(e.accounts,x=>`"${x.toLowerCase()}"`),n=ze(Ai(e.configs),x=>`"${x.toLowerCase()}"`),r=ze(e.inTokenSymbols,x=>`"${x.toUpperCase()}"`),s=ze(e.outTokenSymbols,x=>`"${x.toUpperCase()}"`),i=ze(e.inTokenAddresses,x=>`"${x.toLowerCase()}"`),o=ze(e.outTokenAddresses,x=>`"${x.toLowerCase()}"`),d=ze(e.transactionHashes,x=>`"${x.toLowerCase()}"`),h=ze(e.orderIds,x=>`"${x}"`),f=n!=null&&n.length?"":ze((E=e.configs)==null?void 0:E.map(x=>x.twapAddress),x=>`"${x.toLowerCase()}"`),C=e.minDollarValueIn;return[n?`exchange_in: [${n.join(", ")}]`:"",f?`twapAddress_in: [${f.join(", ")}]`:"",t?`maker_in: [${t.join(", ")}]`:"",d?`transactionHash_in: [${d.join(", ")}]`:"",h?`Contract_id_in: [${h.join(", ")}]`:"",C?`dollarValueIn_gte: ${C}`:"",r?`srcTokenSymbol_in: [${r.join(", ")}]`:"",s?`dstTokenSymbol_in: [${s.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 sa({chainId:e,signal:t,page:n,limit:r,filters:s}){const i=r||1e3,o=ra(s);return await jn({chainId:e,signal:t,limit:i,page:n,buildQuery:(h,f)=>`
1
+ (function(I,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):(I=typeof globalThis<"u"?globalThis:I||self,H(I.SpotReact={},I.jsxRuntime,I.React))})(this,(function(I,H,F){"use strict";var cc=Object.defineProperty;var zs=I=>{throw TypeError(I)};var uc=(I,H,F)=>H in I?cc(I,H,{enumerable:!0,configurable:!0,writable:!0,value:F}):I[H]=F;var On=(I,H,F)=>uc(I,typeof H!="symbol"?H+"":H,F),Er=(I,H,F)=>H.has(I)||zs("Cannot "+F);var l=(I,H,F)=>(Er(I,H,"read from private field"),F?F.call(I):H.get(I)),N=(I,H,F)=>H.has(I)?zs("Cannot add the same private member more than once"):H instanceof WeakSet?H.add(I):H.set(I,F),_=(I,H,F,Bt)=>(Er(I,H,"write to private field"),Bt?Bt.call(I,F):H.set(I,F),F),z=(I,H,F)=>(Er(I,H,"access private method"),F);var In=(I,H,F,Bt)=>({set _(ce){_(I,H,ce,F)},get _(){return l(I,H,Bt)}});var He,xt,_s,vt,ot,Kt,Bs,Ht,ct,Wt,Us,Ft,Rs,Pt,Qt,ke,Dt,he,rn,Ot,Le,et,Ls,ve,Y,sn,Te,It,zt,Ge,ut,an,$t,jt,Mt,kt,dt,Vt,ee,dn,br,Tr,wr,Cr,Sr,xr,vr,$s,Ns,on,We,we,_t,Qe,mt,qs,Xe,Ne,cn,Ks,Ze,lt,Fe,Ye,Je,Mn,Fr,Hs,ze,Ws,se,ft,ht,Gt,Xt,pt,Zt,Yt,Qs;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(F),$={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"}},js=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"}]'),Vs=[{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"}]}],Gs=js;var j=(e=>(e.TWAP="TWAP",e.LIMIT="LIMIT",e.STOP_LOSS="STOP_LOSS",e.TAKE_PROFIT="TAKE_PROFIT",e))(j||{}),pe=(e=>(e.Open="OPEN",e.Cancelled="CANCELLED",e.Completed="COMPLETED",e.Expired="EXPIRED",e))(pe||{}),Pr=(e=>(e.All="ALL",e.Open="OPEN",e.Cancelled="CANCELLED",e.Completed="COMPLETED",e.Expired="EXPIRED",e))(Pr||{}),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||{}),X=(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))(X||{}),Be=(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.Utila="utila",e))(Be||{}),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}},kn={version:"2.6.1"},Dr="https://order-sink-dev.orbs.network",ln="https://order-sink.orbs.network",Or="https://order-sink-v2.orbs.network",fn=kn.version.split(".")[0],Xs=e=>{const t=Number(fn)>=2;return e?Dr:t?Or:ln},Zs=e=>{const t=Number(fn)>=2;return e?[Dr]:t?[Or,ln]:[ln]},Ys={[Be.Thena]:"0xB75218ba5A99bF57Fd02556B70F05A4A0f1Dbe67"},Js=({endpoint:e,exchange:t,partner:n})=>e===ln&&n&&Ys[n]||t,_n=300*1e3,hn=1440*60*60*1e3,Ir=300*1e3,ei=new Date(_n).getMinutes(),Bn=e=>`https://hub.orbs.network/api/private/project_cm7nb67z86nyr01z12gs0fxpf/subgraphs/orbs-twap-${e}/prod/gn`,Ue="https://hub.orbs.network/api/apikey/subgraphs/id",ti={[ye.eth.id]:`${Ue}/Bf7bvMYcJbDAvYWJmhMpHZ4cpFjqzkhK6GXXEpnPRq6`,[ye.bsc.id]:`${Ue}/4NfXEi8rreQsnAr4aJ45RLCKgnjcWX46Lbt9SadiCcz6`,[ye.poly.id]:`${Ue}/3PyRPWSvDnMowGbeBy7aNsvUkD5ZuxdXQw2RdJq4NdXi`,[ye.arb.id]:`${Ue}/83bpQexEaqBjHaQbKoFTbtvCXuo5RudRkfLgtRUYqo2c`,[ye.base.id]:`${Ue}/DFhaPQb3HATXkpsWNZw3gydYHehLBVEDiSk4iBdZJyps`,[ye.sei.id]:`${Ue}/5zjzRnURzoddyFSZBw5E5NAM3oBgPq3NasTYbtMk6EL6`,[ye.linea.id]:`${Ue}/6VsNPEYfFLPZCqdMMDadoXQjLHWJdjEwiD768GAtb7j6`,[ye.sonic.id]:`${Ue}/DtBr6a5vsoDd2oAXdPszcn4gLgrr1XC68Q3AJQKXnNLV`,[ye.ftm.id]:`${Ue}/DdRo1pmJkrJC9fjsjEBWnNE1uqrbh7Diz4tVKd7rfupp`,[ye.katana.id]:`${Ue}/CGi9sDFMQcnBwF3C3NoCFqnaE34sssbgwPLTwiskSXmW`,[ye.avax.id]:`${Ue}/FxZ1vMwE5Xy1qvKvZENUMz4vhW8Sh4vXJf9Vp7o17pTx`,[ye.bera.id]:Bn("berachain"),[ye.flare.id]:Bn("flare"),[ye.cronosZkEvm.id]:Bn("cronos-zkevm")},ni=["0x0000000000000000000000000000000000000000","0x0000000000000000000000000000000000001010","0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE","0x000000000000000000000000000000000000dEaD","0x000000000000000000000000000000000000800A","0x000000000000000000000000000000000000800a"],Mr="115792089237316195423570985008687907853269984665640564039457584007913129639935",Ae=e=>`${e.name}_${e.chainId}`,ri={[Ae($.SushiArb)]:["0x846F2B29ef314bF3D667981b4ffdADc5B858312a","0x08c41f5D1C844061f6D952E25827eeAA576c6536"],[Ae($.SushiBase)]:["0x846F2B29ef314bF3D667981b4ffdADc5B858312a","0x08c41f5D1C844061f6D952E25827eeAA576c6536"],[Ae($.SushiEth)]:["0xc55943Fa6509004B2903ED8F8ab7347BfC47D0bA","0x08c41f5D1C844061f6D952E25827eeAA576c6536"],[Ae($.PancakeSwap)]:["0xb2BAFe188faD927240038cC4FfF2d771d8A58905","0xE2a0c3b9aD19A18c4bBa7fffBe5bC1b0E58Db1CE"],[Ae($.PancakeSwapArbitrum)]:["0xE20167871dB616DdfFD0Fd870d9bC068C350DD1F","0x807488ADAD033e95C438F998277bE654152594dc"],[Ae($.PancakeSwapBase)]:["0x10ed1F36e4eBE76E161c9AADDa20BE841bc0082c","0x3A9df3eE209b802D0337383f5abCe3204d623588"],[Ae($.PancakeSwapLinea)]:["0x3A9df3eE209b802D0337383f5abCe3204d623588"],[Ae($.QuickSwap)]:["0x26D0ec4Be402BCE03AAa8aAf0CF67e9428ba54eF"],[Ae($.Thena)]:["0xc2aBC02acd77Bb2407efA22348dA9afC8B375290"],[Ae($.Lynex)]:["0x72e3e1fD5D2Ee2F1C2Eb695206D490a1D45C3835"],[Ae($.DragonSwap)]:["0x101e1B65Bb516FB5f4547C80BAe0b51f1b8D7a22"],[Ae($.SpookySwapSonic)]:["0xAd97B770ad64aE47fc7d64B3bD820dCDbF9ff7DA"],[Ae($.SpookySwap)]:["0x3924d62219483015f982b160d48c0fa5Fd436Cba"],[Ae($.SwapX)]:["0xE5012eBDe5e26EE3Ea41992154731a03023CF274"]},Un={unit:Pe.Minutes,value:ei},si="RePermitWitnessTransferFrom",ii={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"}]},ai="https://www.orbs.com/dtwap-and-dlimit-faq/",oi="https://www.orbs.com/dtwap-and-dlimit-faq/#dSLTP",ci="https://raw.githubusercontent.com/orbs-network/twap-ui/master/logo/orbslogo.svg",ui="https://www.orbs.com/",di="https://www.orbs.com/dtwap-dlimit-disclaimer";var Jt=(e=>(e.FRESHNESS="freshness",e.MIN_CHUNK_SIZE_USD="minChunkSizeUsd",e.ENV="env",e.DURATION="duration",e.IGNORE_ERRORS="ignore-errors",e))(Jt||{});const li="-5",fi="10",hi="-10",pi="5";var mi=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Rn=Math.ceil,De=Math.floor,Se="[BigNumber Error] ",kr=Se+"Number primitive has more than 15 significant digits: ",Re=1e14,W=14,Ln=9007199254740991,Nn=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],tt=1e7,le=1e9;function _r(e){var t,n,r,s=P.prototype={constructor:P,toString:null,valueOf:null},i=new P(1),o=20,u=4,f=-7,h=21,C=-1e7,E=1e7,T=!1,x=1,O=0,M={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},B="0123456789abcdefghijklmnopqrstuvwxyz",k=!0;function P(a,c){var d,A,m,y,S,p,g,w,b=this;if(!(b instanceof P))return new P(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<C?b.c=[b.e=0]:(b.e=a.e,b.c=a.c.slice());return}if((p=typeof a=="number")&&a*0==0){if(b.s=1/a<0?(a=-a,-1):1,a===~~a){for(y=0,S=a;S>=10;S/=10,y++);y>E?b.c=b.e=null:(b.e=y,b.c=[a]);return}w=String(a)}else{if(!mi.test(w=String(a)))return r(b,w,p);b.s=w.charCodeAt(0)==45?(w=w.slice(1),-1):1}(y=w.indexOf("."))>-1&&(w=w.replace(".","")),(S=w.search(/e/i))>0?(y<0&&(y=S),y+=+w.slice(S+1),w=w.substring(0,S)):y<0&&(y=w.length)}else{if(ne(c,2,B.length,"Base"),c==10&&k)return b=new P(a),G(b,o+b.e+1,u);if(w=String(a),p=typeof a=="number"){if(a*0!=0)return r(b,w,p,c);if(b.s=1/a<0?(w=w.slice(1),-1):1,P.DEBUG&&w.replace(/^0\.0*|\./,"").length>15)throw Error(kr+a)}else b.s=w.charCodeAt(0)===45?(w=w.slice(1),-1):1;for(d=B.slice(0,c),y=S=0,g=w.length;S<g;S++)if(d.indexOf(A=w.charAt(S))<0){if(A=="."){if(S>y){y=g;continue}}else if(!m&&(w==w.toUpperCase()&&(w=w.toLowerCase())||w==w.toLowerCase()&&(w=w.toUpperCase()))){m=!0,S=-1,y=0;continue}return r(b,String(a),p,c)}p=!1,w=n(w,c,10,b.s),(y=w.indexOf("."))>-1?w=w.replace(".",""):y=w.length}for(S=0;w.charCodeAt(S)===48;S++);for(g=w.length;w.charCodeAt(--g)===48;);if(w=w.slice(S,++g)){if(g-=S,p&&P.DEBUG&&g>15&&(a>Ln||a!==De(a)))throw Error(kr+b.s*a);if((y=y-S-1)>E)b.c=b.e=null;else if(y<C)b.c=[b.e=0];else{if(b.e=y,b.c=[],S=(y+1)%W,y<0&&(S+=W),S<g){for(S&&b.c.push(+w.slice(0,S)),g-=W;S<g;)b.c.push(+w.slice(S,S+=W));S=W-(w=w.slice(S)).length}else S-=g;for(;S--;w+="0");b.c.push(+w)}}else b.c=[b.e=0]}P.clone=_r,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(a){var c,d;if(a!=null)if(typeof a=="object"){if(a.hasOwnProperty(c="DECIMAL_PLACES")&&(d=a[c],ne(d,0,le,c),o=d),a.hasOwnProperty(c="ROUNDING_MODE")&&(d=a[c],ne(d,0,8,c),u=d),a.hasOwnProperty(c="EXPONENTIAL_AT")&&(d=a[c],d&&d.pop?(ne(d[0],-le,0,c),ne(d[1],0,le,c),f=d[0],h=d[1]):(ne(d,-le,le,c),f=-(h=d<0?-d:d))),a.hasOwnProperty(c="RANGE"))if(d=a[c],d&&d.pop)ne(d[0],-le,-1,c),ne(d[1],1,le,c),C=d[0],E=d[1];else if(ne(d,-le,le,c),d)C=-(E=d<0?-d:d);else throw Error(Se+c+" cannot be zero: "+d);if(a.hasOwnProperty(c="CRYPTO"))if(d=a[c],d===!!d)if(d)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))T=d;else throw T=!d,Error(Se+"crypto unavailable");else T=d;else throw Error(Se+c+" not true or false: "+d);if(a.hasOwnProperty(c="MODULO_MODE")&&(d=a[c],ne(d,0,9,c),x=d),a.hasOwnProperty(c="POW_PRECISION")&&(d=a[c],ne(d,0,le,c),O=d),a.hasOwnProperty(c="FORMAT"))if(d=a[c],typeof d=="object")M=d;else throw Error(Se+c+" not an object: "+d);if(a.hasOwnProperty(c="ALPHABET"))if(d=a[c],typeof d=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(d))k=d.slice(0,10)=="0123456789",B=d;else throw Error(Se+c+" invalid: "+d)}else throw Error(Se+"Object expected: "+a);return{DECIMAL_PLACES:o,ROUNDING_MODE:u,EXPONENTIAL_AT:[f,h],RANGE:[C,E],CRYPTO:T,MODULO_MODE:x,POW_PRECISION:O,FORMAT:M,ALPHABET:B}},P.isBigNumber=function(a){if(!a||a._isBigNumber!==!0)return!1;if(!P.DEBUG)return!0;var c,d,A=a.c,m=a.e,y=a.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(d=A[c],d<0||d>=Re||d!==De(d))break e;if(d!==0)return!0}}}else if(A===null&&m===null&&(y===null||y===1||y===-1))return!0;throw Error(Se+"Invalid BigNumber: "+a)},P.maximum=P.max=function(){return U(arguments,-1)},P.minimum=P.min=function(){return U(arguments,1)},P.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(d){var A,m,y,S,p,g=0,w=[],b=new P(i);if(d==null?d=o:ne(d,0,le),S=Rn(d/W),T)if(crypto.getRandomValues){for(A=crypto.getRandomValues(new Uint32Array(S*=2));g<S;)p=A[g]*131072+(A[g+1]>>>11),p>=9e15?(m=crypto.getRandomValues(new Uint32Array(2)),A[g]=m[0],A[g+1]=m[1]):(w.push(p%1e14),g+=2);g=S/2}else if(crypto.randomBytes){for(A=crypto.randomBytes(S*=7);g<S;)p=(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],p>=9e15?crypto.randomBytes(7).copy(A,g):(w.push(p%1e14),g+=7);g=S/7}else throw T=!1,Error(Se+"crypto unavailable");if(!T)for(;g<S;)p=c(),p<9e15&&(w[g++]=p%1e14);for(S=w[--g],d%=W,S&&d&&(p=Nn[W-d],w[g]=De(S/p)*p);w[g]===0;w.pop(),g--);if(g<0)w=[y=0];else{for(y=-1;w[0]===0;w.splice(0,1),y-=W);for(g=1,p=w[0];p>=10;p/=10,g++);g<W&&(y-=W-g)}return b.e=y,b.c=w,b}})(),P.sum=function(){for(var a=1,c=arguments,d=new P(c[0]);a<c.length;)d=d.plus(c[a++]);return d},n=(function(){var a="0123456789";function c(d,A,m,y){for(var S,p=[0],g,w=0,b=d.length;w<b;){for(g=p.length;g--;p[g]*=A);for(p[0]+=y.indexOf(d.charAt(w++)),S=0;S<p.length;S++)p[S]>m-1&&(p[S+1]==null&&(p[S+1]=0),p[S+1]+=p[S]/m|0,p[S]%=m)}return p.reverse()}return function(d,A,m,y,S){var p,g,w,b,D,R,L,Z,ie=d.indexOf("."),de=o,J=u;for(ie>=0&&(b=O,O=0,d=d.replace(".",""),Z=new P(A),R=Z.pow(d.length-ie),O=b,Z.c=c(je(Ie(R.c),R.e,"0"),10,m,a),Z.e=Z.c.length),L=c(d,A,m,S?(p=B,a):(p=a,B)),w=b=L.length;L[--b]==0;L.pop());if(!L[0])return p.charAt(0);if(ie<0?--w:(R.c=L,R.e=w,R.s=y,R=t(R,Z,de,J,m),L=R.c,D=R.r,w=R.e),g=w+de+1,ie=L[g],b=m/2,D=D||g<0||L[g+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[g-1]&1||J==(R.s<0?8:7)),g<1||!L[0])d=D?je(p.charAt(1),-de,p.charAt(0)):p.charAt(0);else{if(L.length=g,D)for(--m;++L[--g]>m;)L[g]=0,g||(++w,L=[1].concat(L));for(b=L.length;!L[--b];);for(ie=0,d="";ie<=b;d+=p.charAt(L[ie++]));d=je(d,w,p.charAt(0))}return d}})(),t=(function(){function a(A,m,y){var S,p,g,w,b=0,D=A.length,R=m%tt,L=m/tt|0;for(A=A.slice();D--;)g=A[D]%tt,w=A[D]/tt|0,S=L*g+w*R,p=R*g+S%tt*tt+b,b=(p/y|0)+(S/tt|0)+L*w,A[D]=p%y;return b&&(A=[b].concat(A)),A}function c(A,m,y,S){var p,g;if(y!=S)g=y>S?1:-1;else for(p=g=0;p<y;p++)if(A[p]!=m[p]){g=A[p]>m[p]?1:-1;break}return g}function d(A,m,y,S){for(var p=0;y--;)A[y]-=p,p=A[y]<m[y]?1:0,A[y]=p*S+A[y]-m[y];for(;!A[0]&&A.length>1;A.splice(0,1));}return function(A,m,y,S,p){var g,w,b,D,R,L,Z,ie,de,J,te,ge,Dn,gr,Ar,$e,un,_e=A.s==m.s?1:-1,Ce=A.c,ae=m.c;if(!Ce||!Ce[0]||!ae||!ae[0])return new P(!A.s||!m.s||(Ce?ae&&Ce[0]==ae[0]:!ae)?NaN:Ce&&Ce[0]==0||!ae?_e*0:_e/0);for(ie=new P(_e),de=ie.c=[],w=A.e-m.e,_e=y+w+1,p||(p=Re,w=Oe(A.e/W)-Oe(m.e/W),_e=_e/W|0),b=0;ae[b]==(Ce[b]||0);b++);if(ae[b]>(Ce[b]||0)&&w--,_e<0)de.push(1),D=!0;else{for(gr=Ce.length,$e=ae.length,b=0,_e+=2,R=De(p/(ae[0]+1)),R>1&&(ae=a(ae,R,p),Ce=a(Ce,R,p),$e=ae.length,gr=Ce.length),Dn=$e,J=Ce.slice(0,$e),te=J.length;te<$e;J[te++]=0);un=ae.slice(),un=[0].concat(un),Ar=ae[0],ae[1]>=p/2&&Ar++;do{if(R=0,g=c(ae,J,$e,te),g<0){if(ge=J[0],$e!=te&&(ge=ge*p+(J[1]||0)),R=De(ge/Ar),R>1)for(R>=p&&(R=p-1),L=a(ae,R,p),Z=L.length,te=J.length;c(L,J,Z,te)==1;)R--,d(L,$e<Z?un:ae,Z,p),Z=L.length,g=1;else R==0&&(g=R=1),L=ae.slice(),Z=L.length;if(Z<te&&(L=[0].concat(L)),d(J,L,te,p),te=J.length,g==-1)for(;c(ae,J,$e,te)<1;)R++,d(J,$e<te?un:ae,te,p),te=J.length}else g===0&&(R++,J=[0]);de[b++]=R,J[0]?J[te++]=Ce[Dn]||0:(J=[Ce[Dn]],te=1)}while((Dn++<gr||J[0]!=null)&&_e--);D=J[0]!=null,de[0]||de.splice(0,1)}if(p==Re){for(b=1,_e=de[0];_e>=10;_e/=10,b++);G(ie,y+(ie.e=b+w*W-1)+1,S,D)}else ie.e=w,ie.r=+D;return ie}})();function K(a,c,d,A){var m,y,S,p,g;if(d==null?d=u:ne(d,0,8),!a.c)return a.toString();if(m=a.c[0],S=a.e,c==null)g=Ie(a.c),g=A==1||A==2&&(S<=f||S>=h)?mn(g,S):je(g,S,"0");else if(a=G(new P(a),c,d),y=a.e,g=Ie(a.c),p=g.length,A==1||A==2&&(c<=y||y<=f)){for(;p<c;g+="0",p++);g=mn(g,y)}else if(c-=S+(A===2&&y>S),g=je(g,y,"0"),y+1>p){if(--c>0)for(g+=".";c--;g+="0");}else if(c+=y-p,c>0)for(y+1==p&&(g+=".");c--;g+="0");return a.s<0&&m?"-"+g:g}function U(a,c){for(var d,A,m=1,y=new P(a[0]);m<a.length;m++)A=new P(a[m]),(!A.s||(d=yt(y,A))===c||d===0&&y.s===c)&&(y=A);return y}function V(a,c,d){for(var A=1,m=c.length;!c[--m];c.pop());for(m=c[0];m>=10;m/=10,A++);return(d=A+d*W-1)>E?a.c=a.e=null:d<C?a.c=[a.e=0]:(a.e=d,a.c=c),a}r=(function(){var a=/^(-?)0([xbo])(?=\w[\w.]*$)/i,c=/^([^.]+)\.$/,d=/^\.([^.]+)$/,A=/^-?(Infinity|NaN)$/,m=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(y,S,p,g){var w,b=p?S:S.replace(m,"");if(A.test(b))y.s=isNaN(b)?null:b<0?-1:1;else{if(!p&&(b=b.replace(a,function(D,R,L){return w=(L=L.toLowerCase())=="x"?16:L=="b"?2:8,!g||g==w?R:D}),g&&(w=g,b=b.replace(c,"$1").replace(d,"0.$1")),S!=b))return new P(b,w);if(P.DEBUG)throw Error(Se+"Not a"+(g?" base "+g:"")+" number: "+S);y.s=null}y.c=y.e=null}})();function G(a,c,d,A){var m,y,S,p,g,w,b,D=a.c,R=Nn;if(D){e:{for(m=1,p=D[0];p>=10;p/=10,m++);if(y=c-m,y<0)y+=W,S=c,g=D[w=0],b=De(g/R[m-S-1]%10);else if(w=Rn((y+1)/W),w>=D.length)if(A){for(;D.length<=w;D.push(0));g=b=0,m=1,y%=W,S=y-W+1}else break e;else{for(g=p=D[w],m=1;p>=10;p/=10,m++);y%=W,S=y-W+m,b=S<0?0:De(g/R[m-S-1]%10)}if(A=A||c<0||D[w+1]!=null||(S<0?g:g%R[m-S-1]),A=d<4?(b||A)&&(d==0||d==(a.s<0?3:2)):b>5||b==5&&(d==4||A||d==6&&(y>0?S>0?g/R[m-S]:0:D[w-1])%10&1||d==(a.s<0?8:7)),c<1||!D[0])return D.length=0,A?(c-=a.e+1,D[0]=R[(W-c%W)%W],a.e=-c||0):D[0]=a.e=0,a;if(y==0?(D.length=w,p=1,w--):(D.length=w+1,p=R[W-y],D[w]=S>0?De(g/R[m-S]%R[S])*p:0),A)for(;;)if(w==0){for(y=1,S=D[0];S>=10;S/=10,y++);for(S=D[0]+=p,p=1;S>=10;S/=10,p++);y!=p&&(a.e++,D[0]==Re&&(D[0]=1));break}else{if(D[w]+=p,D[w]!=Re)break;D[w--]=0,p=1}for(y=D.length;D[--y]===0;D.pop());}a.e>E?a.c=a.e=null:a.e<C&&(a.c=[a.e=0])}return a}function oe(a){var c,d=a.e;return d===null?a.toString():(c=Ie(a.c),c=d<=f||d>=h?mn(c,d):je(c,d,"0"),a.s<0?"-"+c:c)}return s.absoluteValue=s.abs=function(){var a=new P(this);return a.s<0&&(a.s=1),a},s.comparedTo=function(a,c){return yt(this,new P(a,c))},s.decimalPlaces=s.dp=function(a,c){var d,A,m,y=this;if(a!=null)return ne(a,0,le),c==null?c=u:ne(c,0,8),G(new P(y),a+y.e+1,c);if(!(d=y.c))return null;if(A=((m=d.length-1)-Oe(this.e/W))*W,m=d[m])for(;m%10==0;m/=10,A--);return A<0&&(A=0),A},s.dividedBy=s.div=function(a,c){return t(this,new P(a,c),o,u)},s.dividedToIntegerBy=s.idiv=function(a,c){return t(this,new P(a,c),0,1)},s.exponentiatedBy=s.pow=function(a,c){var d,A,m,y,S,p,g,w,b,D=this;if(a=new P(a),a.c&&!a.isInteger())throw Error(Se+"Exponent not an integer: "+oe(a));if(c!=null&&(c=new P(c)),p=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 P(Math.pow(+oe(D),p?a.s*(2-pn(a)):+oe(a))),c?b.mod(c):b;if(g=a.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(a.e>9&&(D.e>0||D.e<-1||(D.e==0?D.c[0]>1||p&&D.c[1]>=24e7:D.c[0]<8e13||p&&D.c[0]<=9999975e7)))return y=D.s<0&&pn(a)?-0:0,D.e>-1&&(y=1/y),new P(g?1/y:y);O&&(y=Rn(O/W+2))}for(p?(d=new P(.5),g&&(a.s=1),w=pn(a)):(m=Math.abs(+oe(a)),w=m%2),b=new P(i);;){if(w){if(b=b.times(D),!b.c)break;y?b.c.length>y&&(b.c.length=y):A&&(b=b.mod(c))}if(m){if(m=De(m/2),m===0)break;w=m%2}else if(a=a.times(d),G(a,a.e+1,1),a.e>14)w=pn(a);else{if(m=+oe(a),m===0)break;w=m%2}D=D.times(D),y?D.c&&D.c.length>y&&(D.c.length=y):A&&(D=D.mod(c))}return A?b:(g&&(b=i.div(b)),c?b.mod(c):y?G(b,O,u,S):b)},s.integerValue=function(a){var c=new P(this);return a==null?a=u:ne(a,0,8),G(c,c.e+1,a)},s.isEqualTo=s.eq=function(a,c){return yt(this,new P(a,c))===0},s.isFinite=function(){return!!this.c},s.isGreaterThan=s.gt=function(a,c){return yt(this,new P(a,c))>0},s.isGreaterThanOrEqualTo=s.gte=function(a,c){return(c=yt(this,new P(a,c)))===1||c===0},s.isInteger=function(){return!!this.c&&Oe(this.e/W)>this.c.length-2},s.isLessThan=s.lt=function(a,c){return yt(this,new P(a,c))<0},s.isLessThanOrEqualTo=s.lte=function(a,c){return(c=yt(this,new P(a,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(a,c){var d,A,m,y,S=this,p=S.s;if(a=new P(a,c),c=a.s,!p||!c)return new P(NaN);if(p!=c)return a.s=-c,S.plus(a);var g=S.e/W,w=a.e/W,b=S.c,D=a.c;if(!g||!w){if(!b||!D)return b?(a.s=-c,a):new P(D?S:NaN);if(!b[0]||!D[0])return D[0]?(a.s=-c,a):new P(b[0]?S:u==3?-0:0)}if(g=Oe(g),w=Oe(w),b=b.slice(),p=g-w){for((y=p<0)?(p=-p,m=b):(w=g,m=D),m.reverse(),c=p;c--;m.push(0));m.reverse()}else for(A=(y=(p=b.length)<(c=D.length))?p:c,p=c=0;c<A;c++)if(b[c]!=D[c]){y=b[c]<D[c];break}if(y&&(m=b,b=D,D=m,a.s=-a.s),c=(A=D.length)-(d=b.length),c>0)for(;c--;b[d++]=0);for(c=Re-1;A>p;){if(b[--A]<D[A]){for(d=A;d&&!b[--d];b[d]=c);--b[d],b[A]+=Re}b[A]-=D[A]}for(;b[0]==0;b.splice(0,1),--w);return b[0]?V(a,b,w):(a.s=u==3?-1:1,a.c=[a.e=0],a)},s.modulo=s.mod=function(a,c){var d,A,m=this;return a=new P(a,c),!m.c||!a.s||a.c&&!a.c[0]?new P(NaN):!a.c||m.c&&!m.c[0]?new P(m):(x==9?(A=a.s,a.s=1,d=t(m,a,0,3),a.s=A,d.s*=A):d=t(m,a,0,x),a=m.minus(d.times(a)),!a.c[0]&&x==1&&(a.s=m.s),a)},s.multipliedBy=s.times=function(a,c){var d,A,m,y,S,p,g,w,b,D,R,L,Z,ie,de,J=this,te=J.c,ge=(a=new P(a,c)).c;if(!te||!ge||!te[0]||!ge[0])return!J.s||!a.s||te&&!te[0]&&!ge||ge&&!ge[0]&&!te?a.c=a.e=a.s=null:(a.s*=J.s,!te||!ge?a.c=a.e=null:(a.c=[0],a.e=0)),a;for(A=Oe(J.e/W)+Oe(a.e/W),a.s*=J.s,g=te.length,D=ge.length,g<D&&(Z=te,te=ge,ge=Z,m=g,g=D,D=m),m=g+D,Z=[];m--;Z.push(0));for(ie=Re,de=tt,m=D;--m>=0;){for(d=0,R=ge[m]%de,L=ge[m]/de|0,S=g,y=m+S;y>m;)w=te[--S]%de,b=te[S]/de|0,p=L*w+b*R,w=R*w+p%de*de+Z[y]+d,d=(w/ie|0)+(p/de|0)+L*b,Z[y--]=w%ie;Z[y]=d}return d?++A:Z.splice(0,1),V(a,Z,A)},s.negated=function(){var a=new P(this);return a.s=-a.s||null,a},s.plus=function(a,c){var d,A=this,m=A.s;if(a=new P(a,c),c=a.s,!m||!c)return new P(NaN);if(m!=c)return a.s=-c,A.minus(a);var y=A.e/W,S=a.e/W,p=A.c,g=a.c;if(!y||!S){if(!p||!g)return new P(m/0);if(!p[0]||!g[0])return g[0]?a:new P(p[0]?A:m*0)}if(y=Oe(y),S=Oe(S),p=p.slice(),m=y-S){for(m>0?(S=y,d=g):(m=-m,d=p),d.reverse();m--;d.push(0));d.reverse()}for(m=p.length,c=g.length,m-c<0&&(d=g,g=p,p=d,c=m),m=0;c;)m=(p[--c]=p[c]+g[c]+m)/Re|0,p[c]=Re===p[c]?0:p[c]%Re;return m&&(p=[m].concat(p),++S),V(a,p,S)},s.precision=s.sd=function(a,c){var d,A,m,y=this;if(a!=null&&a!==!!a)return ne(a,1,le),c==null?c=u:ne(c,0,8),G(new P(y),a,c);if(!(d=y.c))return null;if(m=d.length-1,A=m*W+1,m=d[m]){for(;m%10==0;m/=10,A--);for(m=d[0];m>=10;m/=10,A++);}return a&&y.e+1>A&&(A=y.e+1),A},s.shiftedBy=function(a){return ne(a,-Ln,Ln),this.times("1e"+a)},s.squareRoot=s.sqrt=function(){var a,c,d,A,m,y=this,S=y.c,p=y.s,g=y.e,w=o+4,b=new P("0.5");if(p!==1||!S||!S[0])return new P(!p||p<0&&(!S||S[0])?NaN:S?y:1/0);if(p=Math.sqrt(+oe(y)),p==0||p==1/0?(c=Ie(S),(c.length+g)%2==0&&(c+="0"),p=Math.sqrt(+c),g=Oe((g+1)/2)-(g<0||g%2),p==1/0?c="5e"+g:(c=p.toExponential(),c=c.slice(0,c.indexOf("e")+1)+g),d=new P(c)):d=new P(p+""),d.c[0]){for(g=d.e,p=g+w,p<3&&(p=0);;)if(m=d,d=b.times(m.plus(t(y,m,w,1))),Ie(m.c).slice(0,p)===(c=Ie(d.c)).slice(0,p))if(d.e<g&&--p,c=c.slice(p-3,p+1),c=="9999"||!A&&c=="4999"){if(!A&&(G(m,m.e+o+2,0),m.times(m).eq(y))){d=m;break}w+=4,p+=4,A=1}else{(!+c||!+c.slice(1)&&c.charAt(0)=="5")&&(G(d,d.e+o+2,1),a=!d.times(d).eq(y));break}}return G(d,d.e+o+1,u,a)},s.toExponential=function(a,c){return a!=null&&(ne(a,0,le),a++),K(this,a,c,1)},s.toFixed=function(a,c){return a!=null&&(ne(a,0,le),a=a+this.e+1),K(this,a,c)},s.toFormat=function(a,c,d){var A,m=this;if(d==null)a!=null&&c&&typeof c=="object"?(d=c,c=null):a&&typeof a=="object"?(d=a,a=c=null):d=M;else if(typeof d!="object")throw Error(Se+"Argument not an object: "+d);if(A=m.toFixed(a,c),m.c){var y,S=A.split("."),p=+d.groupSize,g=+d.secondaryGroupSize,w=d.groupSeparator||"",b=S[0],D=S[1],R=m.s<0,L=R?b.slice(1):b,Z=L.length;if(g&&(y=p,p=g,g=y,Z-=y),p>0&&Z>0){for(y=Z%p||p,b=L.substr(0,y);y<Z;y+=p)b+=w+L.substr(y,p);g>0&&(b+=w+L.slice(y)),R&&(b="-"+b)}A=D?b+(d.decimalSeparator||"")+((g=+d.fractionGroupSize)?D.replace(new RegExp("\\d{"+g+"}\\B","g"),"$&"+(d.fractionGroupSeparator||"")):D):b}return(d.prefix||"")+A+(d.suffix||"")},s.toFraction=function(a){var c,d,A,m,y,S,p,g,w,b,D,R,L=this,Z=L.c;if(a!=null&&(p=new P(a),!p.isInteger()&&(p.c||p.s!==1)||p.lt(i)))throw Error(Se+"Argument "+(p.isInteger()?"out of range: ":"not an integer: ")+oe(p));if(!Z)return new P(L);for(c=new P(i),w=d=new P(i),A=g=new P(i),R=Ie(Z),y=c.e=R.length-L.e-1,c.c[0]=Nn[(S=y%W)<0?W+S:S],a=!a||p.comparedTo(c)>0?y>0?c:w:p,S=E,E=1/0,p=new P(R),g.c[0]=0;b=t(p,c,0,1),m=d.plus(b.times(A)),m.comparedTo(a)!=1;)d=A,A=m,w=g.plus(b.times(m=w)),g=m,c=p.minus(b.times(m=c)),p=m;return m=t(a.minus(d),A,0,1),g=g.plus(m.times(w)),d=d.plus(m.times(A)),g.s=w.s=L.s,y=y*2,D=t(w,A,y,u).minus(L).abs().comparedTo(t(g,d,y,u).minus(L).abs())<1?[w,A]:[g,d],E=S,D},s.toNumber=function(){return+oe(this)},s.toPrecision=function(a,c){return a!=null&&ne(a,1,le),K(this,a,c,2)},s.toString=function(a){var c,d=this,A=d.s,m=d.e;return m===null?A?(c="Infinity",A<0&&(c="-"+c)):c="NaN":(a==null?c=m<=f||m>=h?mn(Ie(d.c),m):je(Ie(d.c),m,"0"):a===10&&k?(d=G(new P(d),o+m+1,u),c=je(Ie(d.c),d.e,"0")):(ne(a,2,B.length,"Base"),c=n(je(Ie(d.c),m,"0"),10,a,A,!0)),A<0&&d.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,i=e[0]+"";r<s;){for(t=e[r++]+"",n=W-t.length;n--;t="0"+t);i+=t}for(s=i.length;i.charCodeAt(--s)===48;);return i.slice(0,s+1||1)}function yt(e,t){var n,r,s=e.c,i=t.c,o=e.s,u=t.s,f=e.e,h=t.e;if(!o||!u)return null;if(n=s&&!s[0],r=i&&!i[0],n||r)return n?r?0:-u:o;if(o!=u)return o;if(n=o<0,r=f==h,!s||!i)return r?0:!s^n?1:-1;if(!r)return f>h^n?1:-1;for(u=(f=s.length)<(h=i.length)?f:h,o=0;o<u;o++)if(s[o]!=i[o])return s[o]>i[o]^n?1:-1;return f==h?0:f>h^n?1:-1}function ne(e,t,n,r){if(e<t||e>n||e!==De(e))throw Error(Se+(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 mn(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function je(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 v=_r();function yi(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 gi={1:{adapter:{Odos:"0x1ae80D14C52F82c09a54C423e6f9D5Fb737089C8",Sushi:"0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c"},dex:{sushiswap:{type:"default",solver:"Sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"}}},10:{adapter:{Odos:"0xc7Ec90152fd5A6210570cb04C4Ab099Bdac352af"},dex:{}},14:{adapter:{SparkDex:"0x00c7617C471Ef69124464CEc318a3b8CC90aE9A7"},dex:{spark:{type:"default",solver:"SparkDex",router:"0x0f3D8a38D4c74afBebc2c42695642f0e3acb15D3",adapter:"0x00c7617C471Ef69124464CEc318a3b8CC90aE9A7",fee:"0xaeA8C3e1a129A77686E115b1a46D9aD8405F7D2b"}}},56:{adapter:{Odos:"0x6c17cc2984A87BD8b002c6E3C08dBB8c8Eb89E48",Orbs:"0xaf3532dca7b4a75cD06671614C093e9e8fb5b1F2"},dex:{thena:{type:"default",solver:"Odos",router:"0x89b8AA89FDd0507a99d334CBe3C808fAFC7d850E",adapter:"0x9E61dEabe996236814c28eC69ab2A7405cB6f03E",fee:"0x15eBc8b5b3877512FFF23650188694A9a8891FAc"},pancake:{type:"p2",solver:"Orbs",router:"0xd9C500DfF816a1Da21A48A732d3498Bf09dc9AEB",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0x52Ed96B1AEd25818B6A284b063b055488E012b73",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},newera:{type:"default",solver:"Odos",router:"0x89b8AA89FDd0507a99d334CBe3C808fAFC7d850E",adapter:"0x6236a466CE5c368DC6686d69cAcf5561196B76ef",fee:"0x4E7454909eB6D539111D56b50d68897E933D2d11"}}},137:{adapter:{Odos:"0x5628D7383b42E14E83DA310de3e7E04E6b025418",Paraswap:"0x179C4b8e982b5F1365d36CC8d0c1CEB621B7198D"},dex:{quick:{type:"paraswap",solver:"Paraswap",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0x727e1CbA41Ff1ff11C32fa43DAb499b4317A1b65",fee:"0xd207DC6a6dA88f27c8DB78201F974161b1d84b1f"},teafi:{type:"paraswap",solver:"Paraswap",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0xF710D67C783D2C14671EC1c61B0683DCb996F5c3",fee:"0x04Ff96e2c4D62b5771795d307AD679a25b3D2D50"}}},143:{adapter:{OpenOcean:"0xc7f07C830e22FCA94bF52F38C6707F9D396c6172",Kyber:"0x6f4e5b8d7F6b037c62277992c39E7834D7C04596"},dex:{yowie:{type:"default",solver:"OpenOcean",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xCA84Ab5a5A5bf2cff6AC0C835eF049365D13c6cB",fee:"0x6AF3eE77A3A3257777F5649aFa611b4C7Fd975Ef"},pangolin:{type:"default",solver:"Kyber",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xf42106eBf985bF49b39eba0114F57FA05e7B52eD",fee:"0xde92da99D188Ceb54A11ec711EF52D808A6260B5"}}},146:{adapter:{Odos:"0x0123695379045f9db515E6a77d8154959B94B599",OpenOcean:"0xc7f07C830e22FCA94bF52F38C6707F9D396c6172",Magpie:"0x4914efb617fEa2Fd7529fdb365854Fd8f17bCBDE"},dex:{spooky:{type:"default",solver:"Magpie",router:"0x20f6ee51340adeed01a59b0e65cb3703f3dc860c",adapter:"0x0F6533Fd45D13ad6AAa364023d6c05eCB2d3Ac2E",fee:"0x840Df4684B35BC68BcdA3F6707A3c82A0D662f8b"},swapx:{type:"default",solver:"OpenOcean",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xa7AE3ABf86C81cCEFEd6bE77045F2a32660c1B1c",fee:"0x6E03f7BC0f141894612AA017796096399623895F"},shadow:{type:"default",solver:"Magpie",router:"0x20f6ee51340adeed01a59b0e65cb3703f3dc860c",adapter:"0x39b024E187e5f35fea05953fECB9314a97de3d94",fee:"0xb9e3751fAF3187E1bC468E56a707a8A91754460e"}}},1329:{adapter:{DragonSwap:"0x1e84A9f30607959d2d8b1a04171ef7D9522Ef502",OpenOcean:"0xc7f07C830e22FCA94bF52F38C6707F9D396c6172"},dex:{dragon:{type:"default",solver:"DragonSwap",router:"0x11DA6463D6Cb5a03411Dbf5ab6f6bc3997Ac7428",adapter:"0x1e84A9f30607959d2d8b1a04171ef7D9522Ef502",fee:"0x0dc1E0525202b32e89bA78ed55b1e5cEdB751334"},nami:{type:"default",solver:"OpenOcean",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xba56F9A7865d430c8293851D576b5728Ca711ff5",fee:"0xeB58450e23632003f013568703F54446070E2E80"}}},5e3:{adapter:{Odos:"0x3a0fA0f95ea07026c5f84D8d3444Dd6E15AE1874"},dex:{}},8453:{adapter:{Odos:"0x1c947387AFC3435135e3da51ccEAB20eD5377DeA",Orbs:"0x917b492557957f5dD3e69c04c8E1Ac3d6948c022",Kyber:"0x6f4e5b8d7F6b037c62277992c39E7834D7C04596",TrebleSwap:"0x6f4938535879c668A797F2a6e9B912c54f9D43Cf",Sushi:"0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c"},dex:{pancake:{type:"p2",solver:"Orbs",router:"0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},quick:{type:"default",solver:"Kyber",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"}}},42161:{adapter:{Odos:"0x419faf03F5661e0F0471eF9D7935f09534ffc50F",Paraswap:"0x179C4b8e982b5F1365d36CC8d0c1CEB621B7198D",Orbs:"0x917b492557957f5dD3e69c04c8E1Ac3d6948c022",Sushi:"0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c"},dex:{arbidex:{type:"default",solver:"Odos",router:"0xa669e7A0d4b3e4Fa48af2dE86BD4CD7126Be4e13",adapter:"0xaA66173674F4331e7e672899B3E6aB1190450898",fee:"0xa0c11852f8A44e32F9EC10AD25986A53842f72Ca"},ramses:{type:"paraswap",solver:"Paraswap",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0xf075352f43cd15bA51B0957A4465223EDf6b4Cd8",fee:"0xB5BaCB60ECDa0bEF809B2A26eC9B4B926835D7af"},omni:{type:"paraswap",solver:"Paraswap",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0x41c925E8E4fC65136BDf5322824E0D8c20c4824e",fee:"0xba5291526c30B097E9F1Fd1Be301E2ab6E0782aa"},chronos:{type:"default",solver:"Odos",router:"0x19cEeAd7105607Cd444F5ad10dd51356436095a1",adapter:"0x6a6b8975d1b131EFd0a9b536766EE7E5d4a16CF2",fee:"0x5729af83240EFecAa18eafaAE82961c2DD045Dbe"},pancake:{type:"p2",solver:"Orbs",router:"0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},sushiswap:{type:"default",solver:"Sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"}}},43114:{adapter:{Odos:"0x533dA659Ef4C2C1d4c98420e1dbe9C68D8538f50",Kyber:"0x6f4e5b8d7F6b037c62277992c39E7834D7C04596"},dex:{blackhole:{type:"default",solver:"Kyber",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xccdF1D6ce95FeC0F842197470CE8969A678B0A04",fee:"0x7f8B62520D9B5DA0ED517cc36e8dcb2a356f1928"},pangolin:{type:"default",solver:"Kyber",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xf42106eBf985bF49b39eba0114F57FA05e7B52eD",fee:"0xde92da99D188Ceb54A11ec711EF52D808A6260B5"}}},59144:{adapter:{Odos:"0xA58A55AC39b47504A63993A91B78544158862e61",Orbs:"0x917b492557957f5dD3e69c04c8E1Ac3d6948c022",OpenOcean:"0xd2e68b1d1C5DBB2D6cC396c10C55017e01309C37"},dex:{pancake:{type:"p2",solver:"Orbs",router:"0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},lynex:{type:"default",solver:"OpenOcean",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xd8bC1FF79a642e8D7Fbd0711374F287202fBb3AA",fee:"0xcb36ed1B1BfAD8F7FC9651f52d21f04A68677423"}}},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",utilaAdapter:"0x7671291910b559d7a05ab73ee31dd714d9c6e7b065c9496338bf427182ae5145",utilaFee:"0x46f797cddb221ecf6279b56f52e2f6360cd721ef95bd5a17dd0ffceffaaf7fd6"},dex:{agent:{type:"universal",adapter:"0x0002BeFB46587d460AcEA9B2792c4A4c67B9cADa",fee:"0x0006d9557Ac9Af4f31962896299ba4FaBDaB9fEE"},utila:{type:"universal",adapter:"0x000ADa14B2ECF45Da6Cf1B33dE34e05231E9C76f",fee:"0x000FEee351263c82501a4dF5f699a8b630ac7f36"}}}};var qn,Br;function Ai(){if(Br)return qn;Br=1;const e=gi,t=i=>yi(`./out/${i}.sol/${i}.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(i){var u;if(!i)return;const o=e[i];if(o)return{...((u=e["*"])==null?void 0:u.adapter)??{},...o.adapter??{}}}function s(i,o){if(!i)return;const{dex:u,salt:f,...h}=e["*"]??{},C=e[i];if(!C)return;const{dex:E,salt:T,...x}=C,O={...h,...x},M=o==null?void 0:o.trim();if(!M)return O;const B=u==null?void 0:u[M],k=E==null?void 0:E[M];if(!(!B&&!k))return{...O,...B,...k}}return qn={config:s,adapters:r,abis:n,raw:e},qn}var Ur=Ai();const Ut=(e,t)=>{if(!e||!t)return"";const n=v(10).pow(e||0);return v(t).times(n).idiv(n).div(n).toFixed()};v(0),v(1),v(10),v(1e18);function gt(e,t){return e==t||e.toLowerCase()==t.toLowerCase()}const Rt=e=>!!ni.find(t=>gt(t,e||""));function Ei(e){return[Pe.Years,Pe.Months,Pe.Weeks,Pe.Days,Pe.Hours,Pe.Minutes].find(n=>n<=e)||Pe.Minutes}const At=e=>e?e.value*e.unit:0,bi=e=>!e||e==="NaN"?"0":v(e).decimalPlaces(0).toFixed(),Et=e=>Object.values(ye).find(t=>t.id===e),Ti=e=>{if(!e)return;const t=e.map(i=>Ae(i)),n=Object.entries(ri).filter(([i])=>t.includes(i)).flatMap(([,i])=>i),r=e.map(i=>i.exchangeAddress),s=new Set([...r,...n].map(i=>i.toLowerCase()));return Array.from(s)},Kn=(e,t)=>e.version===1?(e.fillDelay||0)*1e3+Di(t):(e.fillDelay||0)*1e3,yn=e=>typeof window>"u"?null:new URLSearchParams(window.location.search).get(e),Rr=e=>qr().filter(t=>t.name===e).map(t=>t.chainId),Hn=(e="",t="",n=18,r=18)=>{if(!v(e||0).gt(0)||!v(t||0).gt(0))return"";const s=Ut(n,e),i=Ut(r,t);return v(i).div(s).toFixed()},Lr=(e,t,n)=>{if(e.type===X.TWAP_MARKET)return"";const r=Ut(t,e.srcAmountPerTrade),s=Ut(n,e.dstMinAmountPerTrade);return v(s).div(r).toFixed()},Nr=(e,t,n)=>{if(e.type===X.TWAP_MARKET)return"";const r=Ut(t,e.srcAmountPerTrade),s=Ut(n,e.triggerPricePerTrade);return v(s).div(r).toFixed()},wi=(e,t,n)=>{if(!e||!t||!n)return;const r=v(e).times(t),s=v(10).pow(n);return r.div(s).toFixed(0)},Ci=(e,t,n,r)=>{if(n||!r||!e||!t)return v(0).toString();const s=v(e).times(v(t)),i=v(10).pow(r),o=s.div(i);return v.max(1,o).integerValue(v.ROUND_FLOOR).toFixed(0)},Si=(e,t,n,r)=>{if(e===j.TWAP||e===j.LIMIT)return"0";if(!r||!t||!n)return;const s=v(t).times(v(n)),i=v(10).pow(r),o=s.div(i);return v.max(1,o).integerValue(v.ROUND_FLOOR).toFixed(0)||"0"},xi=(e,t,n,r)=>{const s=At(n)*2*t,i=yn(Jt.DURATION),o=Ei(i?Number(i):s);return i?{unit:o,value:Number(v(Number(i)/o).toFixed(2))}:r||(e===j.LIMIT?{unit:Pe.Days,value:7}:e===j.STOP_LOSS||e===j.TAKE_PROFIT?{unit:Pe.Days,value:1}:{unit:o,value:Number(v(s/o).toFixed(2))})},vi=(e,t,n)=>t!==j.TWAP?1:n!==void 0?n:Math.max(1,Math.ceil(e/2)),Fi=(e,t,n)=>{if(!e||!t||!n)return 1;const s=v(t).times(e).div(n).integerValue(v.ROUND_FLOOR).toNumber();return Math.max(1,s)},Pi=(e,t)=>e+At(t)+6e4,Di=e=>e.bidDelaySeconds*1e3*2,Oi=(e="",t=0)=>!e||!t?"0":v(e).div(t).integerValue(v.ROUND_FLOOR).toFixed(0),Ii=(e,t)=>({isError:!(e.unit===Un.unit&&e.value===Un.value)&&At(e)*t>hn,value:Math.floor(hn/t)}),Mi=(e="",t="",n)=>{if(n===j.STOP_LOSS)return{isError:v(t||0).gte(v(e||0)),value:e}},ki=(e="",t="",n)=>{if(n===j.TAKE_PROFIT)return{isError:v(t||0).lte(v(e||0)),value:e}},_i=(e="",t="",n=!1,r)=>{if(!n&&r===j.STOP_LOSS)return{isError:v(t||0).gte(v(e||0)),value:e}},Bi=(e="",t="",n=!1,r)=>{if(!n&&r===j.TAKE_PROFIT)return{isError:v(t||0).gte(v(e||0)),value:e}},Ui=(e,t)=>e===j.STOP_LOSS||e===j.TAKE_PROFIT?{isError:At(t)>5184e6,value:5184e6}:{isError:At(t)>hn,value:hn},Ri=e=>({isError:At(e)<Ir,value:Ir}),Li=e=>({isError:At(e)<_n,value:_n}),Ni=(e,t,n)=>({isError:v(t||0).multipliedBy(e||0).isLessThan(n),value:n}),qi=(e,t,n)=>({isError:n===j.TWAP&&v(e).isGreaterThan(t),value:t}),Ki=(e,t)=>{if(e===Be.Pancake)switch(t){case 56:return $.PancakeSwap;case 42161:return $.PancakeSwapArbitrum;case 8453:return $.PancakeSwapBase;case 59144:return $.PancakeSwapLinea;default:return $.PancakeSwap}if(e===Be.Sushiswap)switch(t){case 1:return $.SushiEth;case 42161:return $.SushiArb;case 8453:return $.SushiBase;case 747474:return $.SushiKatana;default:return $.SushiEth}if(e===Be.Quick)switch(t){case 137:return $.QuickSwap;case 8453:return $.QuickSwapBase;default:return $.QuickSwap}if(e===Be.Thena)switch(t){case 56:return $.Thena;default:return $.Thena}if(e===Be.Spooky)switch(t){case 250:return $.SpookySwap;case 146:return $.SpookySwapSonic;default:return $.SpookySwap}if(e===Be.Lynex)switch(t){case 59144:return $.Lynex;default:return $.Lynex}if(e===Be.Swapx)switch(t){case 146:return $.SwapX;default:return $.SwapX}if(e===Be.Blackhole)switch(t){case 43114:return $.BlackholeAvax;default:return $.BlackholeAvax}},Wn=(e,t=0)=>{const{abi:n,...r}=Ur.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:Ki(e,t)}},qr=()=>{var n;const e=Ur.raw,t=((n=e["*"])==null?void 0:n.dex)??{};return Object.entries(e).filter(([r])=>r!=="*").flatMap(([r,s])=>{const i={...t,...(s==null?void 0:s.dex)??{}};return!i||typeof i!="object"?[]:Object.entries(i).map(([o])=>({chainId:Number(r),name:o,config:Wn(o,Number(r))}))}).sort((r,s)=>r.name.localeCompare(s.name))},Kr=e=>{const t=yn(Jt.MIN_CHUNK_SIZE_USD);return t?parseInt(t):e},Hi=({marketPrice:e,typedInputAmount:t,srcUsd1Token:n,marketPriceLoading:r,triggerPriceError:s,limitPriceError:i,tradesError:o,fillDelayError:u,durationError:f,balanceError:h,minTradeSizeError:C})=>{if(!yn(Jt.IGNORE_ERRORS)&&!(v(e||0).isZero()||v(t||0).isZero()||v(n||"0").isZero()||r))return C||s||i||o||u||f||h},Wi=(e,t)=>{const n=Date.now().toString(),r=parseInt((e/1e3).toFixed(0)),s=bi(t/1e3),i=yn(Jt.FRESHNESS),o=i?parseInt(i):60;return{nonce:n,epoch:r,deadline:s,freshness:o}},Hr=({chainId:e,srcToken:t,dstToken:n,srcAmount:r,deadlineMillis:s,fillDelayMillis:i,slippage:o,account:u,srcAmountPerTrade:f,dstMinAmountPerTrade:h="0",triggerAmountPerTrade:C="0",config:E,module:T})=>{const{nonce:x,epoch:O,deadline:M,freshness:B}=Wi(i,s),k=Math.floor(Date.now()/1e3).toString(),P=h,K=T===j.STOP_LOSS?C:"0",U=T===j.TAKE_PROFIT?C:"0",V={permitted:{token:t,amount:r},spender:E.reactor,nonce:x,deadline:M,witness:{reactor:E.reactor,executor:E.executor,exchange:{adapter:E.adapter,ref:E.fee,share:0,data:"0x"},swapper:u,nonce:x,start:k,deadline:M,chainid:e,exclusivity:0,epoch:O,slippage:o,freshness:B,input:{token:t,amount:f,maxAmount:r},output:{token:n,limit:v(P||0).toFixed(),triggerLower:v(K||0).toFixed(),triggerUpper:v(U||0).toFixed(),recipient:u}}};return{domain:{name:"RePermit",version:"1",chainId:e,verifyingContract:E.repermit},order:V,types:ii,primaryType:si}},Qi=`https://bi.orbs.network/putes/twap-ui-${.7}`;let Qn="unknown";function zi(e){Qn=e}function zn(){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 $i=(e,t,n)=>{var r,s,i,o,u,f,h,C,E;return{spotVersion:kn.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:((i=e.twapConfig)==null?void 0:i.twapAddress)||"",lensAddress:((o=e.twapConfig)==null?void 0:o.lensAddress)||"",bidDelaySeconds:((u=e.twapConfig)==null?void 0:u.bidDelaySeconds)||0,minChunkSizeUsd:t,name:((f=e.twapConfig)==null?void 0:f.name)||"",exchangeAddress:((h=e.twapConfig)==null?void 0:h.exchangeAddress)||"",exchangeType:((C=e.twapConfig)==null?void 0:C.exchangeType)||"",pathfinderKey:((E=e.twapConfig)==null?void 0:E.pathfinderKey)||""}},Wr=async e=>{try{await fetch(Qi,{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 ji{constructor(){On(this,"timeout");On(this,"config");On(this,"data",{_id:zn()})}async updateAndSend(t={},n=!1,r){try{this.data={...this.data,...t},n?(await Wr(this.data),r==null||r()):(clearTimeout(this.timeout),this.timeout=setTimeout(()=>{Wr(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:i,fromTokenAmount:o,srcChunkAmount:u,minDstAmountOutPerTrade:f="",triggerPricePerTrade:h="",deadline:C,fillDelay:E,slippage:T,isMarketOrder:x,chunksAmount:O}){this.updateAndSend({toTokenAddress:i.address,toTokenSymbol:i.symbol,fromTokenAddress:s.address,fromTokenSymbol:s.symbol,fromTokenAmount:o,chunksAmount:O,srcChunkAmount:u,minDstAmountOutPerTrade:f,triggerPricePerTrade:h,deadline:C,fillDelay:E,slippage:T,chainId:n,walletAddress:t,module:r,orderType:x?"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:zn(),action:"module-import",uiVersion:Qn,...$i(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:zn(),action:"reset",uiVersion:Qn,origin:this.data.origin,spotVersion:kn.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 fe=new ji,Vi=e=>{var h;const t=v(e.order.witness.output.limit||0).gt(1),{stop:n,triggerLower:r,triggerUpper:s}=e.order.witness.output,i=v(n||0).eq(Mr),o=i||v(s||0).gt(0),u=!i&&v(n||0).gt(0)||v(r||0).gt(0),f=((h=e.metadata.chunks)==null?void 0:h.length)||v(e.order.witness.input.maxAmount).div(v(e.order.witness.input.amount)).toNumber();return o?t?X.TAKE_PROFIT_LIMIT:X.TAKE_PROFIT_MARKET:u?t?X.STOP_LOSS_LIMIT:X.STOP_LOSS_MARKET:t?f>1&&t?X.TWAP_LIMIT:t?X.LIMIT:X.TWAP_MARKET:X.TWAP_MARKET},Gi=e=>{var s;const t=((s=e.metadata.chunks)==null?void 0:s.filter(i=>i.status==="success").length)||0,n=e.metadata.expectedChunks||0,r=v(t).dividedBy(n).toNumber();return r>=.99?100:r<=0?0:Number((r*100).toFixed(2))},Xi=(e,t)=>e.metadata.status==="completed"||t>=99?pe.Completed:["pending","eligible"].includes(e.metadata.status)?pe.Open:e.metadata.description.toLowerCase()==="cancelled by contract"?pe.Cancelled:pe.Expired,Zi=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}))},Yi=(e,t)=>{var r;const n=e.length;return n>=t&&((r=e[n-1])==null?void 0:r.timestamp)||0},Ji=e=>v(e.metadata.displayOnlyInputTokenPriceUSD).dividedBy(1e18).toFixed(),$n=e=>Number(e.order.witness.output.limit)===1?"":e.order.witness.output.limit,ea=e=>{const{triggerLower:t="0",triggerUpper:n="0"}=e.order.witness.output,r=$n(e),s=e.metadata.expectedChunks||1,i=v(n||0).gt(0);return{dstMinAmountPerTrade:r,triggerPricePerTrade:i?n:t,dstMinAmountTotal:v(r).multipliedBy(s).toFixed()}},ta=e=>{const t=$n(e),n=v(e.order.witness.output.stop||0).eq(Mr),r=e.metadata.expectedChunks||1;return{dstMinAmountPerTrade:n?"":t,triggerPricePerTrade:n?t:v(e.order.witness.output.stop||"").toFixed(),dstMinAmountTotal:n?"":v(t).multipliedBy(r).toFixed()}},na=e=>Number(fn)>=2?ea(e):ta(e),Qr=e=>{const t=Gi(e),n=$n(e),r=e.metadata.expectedChunks||1,s=Zi(e),i=Vi(e);return{id:e.hash,hash:e.hash,version:2,type:i,maker:e.order.witness.swapper,progress:t,srcAmountFilled:s.reduce((o,u)=>o.plus(u.inAmount),new v(0)).toFixed()||"",dstAmountFilled:s.reduce((o,u)=>o.plus(u.outAmount),new v(0)).toFixed()||"",fills:s,srcTokenAddress:e.order.witness.input.token,dstTokenAddress:e.order.witness.output.token,orderDollarValueIn:Ji(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:v(n||0).lte(1),chainId:e.order.witness.chainid,filledOrderTimestamp:Yi(s,r),status:Xi(e,t),repermitDigest:e.metadata.repermitDigest,isTriggerPrice:i===X.TAKE_PROFIT_MARKET||i===X.TAKE_PROFIT_LIMIT||i===X.STOP_LOSS_LIMIT||i===X.STOP_LOSS_MARKET,rawOrder:e,...na(e)}},ra=async({chainId:e,signal:t,account:n,exchange:r,partner:s,isDev:i=!1})=>{try{if(!n)return[];const o=Zs(i),u=new Map;return(await Promise.all(o.map(async h=>{try{const C=Js({endpoint:h,exchange:r,partner:s}),E=C?`&exchange=${C}`:"",x=await(await fetch(`${h}/orders?swapper=${n}&chainId=${e}${E}`,{signal:t})).json();if(!x||!Array.isArray(x.orders))return[];const O=[];for(const M of x.orders)try{O.push(Qr(M))}catch{continue}return O}catch{return[]}}))).flat().forEach(h=>{u.has(h.id)||u.set(h.id,h)}),Array.from(u.values())}catch{return[]}},zr=async(e,t,n=!1)=>{try{const r={signature:t,order:e,status:"pending"};fe.onCreateOrderRequest();const s=await fetch(`${Xs(n)}/orders/new`,{method:"POST",body:JSON.stringify(r)}),i=await s.json().catch(()=>({}));if(!s.ok||!(i!=null&&i.success)){const u=(i==null?void 0:i.message)??s.statusText??"Request failed",f=(i==null?void 0:i.code)??s.status;throw new Error(`error:${u}, code:${f}`)}if(!i.signedOrder||typeof i.signedOrder!="object")throw new Error("Invalid API response: missing signedOrder");const o=Qr(i.signedOrder);return fe.onCreateOrderSuccess(o.id),o}catch(r){throw fe.onCreateOrderError(r),console.error(r),r}},Ve=(e,t)=>e&&e.length?e.map(t||(n=>`${n}`)):void 0,sa=e=>{if(e)return ti[e]},jn=async({chainId:e,buildQuery:t,extractResults:n,signal:r,retries:s=1,limit:i=1e3,page:o})=>{const u=sa(e);if(!u)throw new da;const f=async E=>{let T=0;for(;T<=s;)try{const x=await fetch(u,{method:"POST",body:JSON.stringify({query:E}),signal:r,headers:{"Content-Type":"application/json"}});if(!x.ok)throw new Error(`HTTP error: ${x.status}`);const O=await x.json();if(O.errors)throw new Error(O.errors[0].message);return n(O)}catch(x){if(T===s)throw x;await new Promise(O=>setTimeout(O,500*2**T)),T++}return[]};let h=0;const C=[];if(o!==void 0){const E=t(o,i);try{return await f(E)}catch{console.warn(`Page ${o} failed, retrying one final time...`);try{return await f(E)}catch{return[]}}}for(;;){const E=t(h,i);let T;try{T=await f(E)}catch{console.warn(`Page ${h} failed, retrying one final time...`);try{T=await f(E)}catch{return C}}if(C.push(...T),T.length<i)break;h++}return C},$r=e=>e.map(t=>({inAmount:t.srcAmountIn,outAmount:t.dstAmountOut,timestamp:t.timestamp,txHash:t.transactionHash})),jr=(e,t)=>{const n=v(e||0).gt(1);return!n&&t===1?X.TWAP_MARKET:t>1&&n?X.TWAP_LIMIT:n?X.LIMIT:X.TWAP_MARKET},ia=(e,t,n,r)=>{var T;const s=$r(n||[]),i=new v(e.ask_srcAmount||0).div(e.ask_srcBidAmount).integerValue(v.ROUND_FLOOR).toNumber(),u=(n==null?void 0:n.length)===i?(T=n==null?void 0:n[(n==null?void 0:n.length)-1])==null?void 0:T.timestamp:void 0,f=s.reduce((x,O)=>x.plus(O.inAmount),new v(0)).toFixed(),h=s.reduce((x,O)=>x.plus(O.outAmount),new v(0)).toFixed(),C=Vr(e.ask_srcAmount,f),E=jr(e.ask_dstMinAmount,i);return{repermitDigest:"",version:1,isTriggerPrice:!1,id:e.Contract_id.toString(),hash:"",type:jr(e.ask_dstMinAmount,i),srcTokenAddress:e.ask_srcToken,dstTokenAddress:e.ask_dstToken,exchangeAddress:e.exchange,twapAddress:e.twapAddress,maker:e.maker,progress:C,dstAmountFilled:h,srcAmountFilled:f,orderDollarValueIn:v(e.dollarValueIn||0).toFixed(6),srcAmount:e.ask_srcAmount,dstMinAmountTotal:v(e.ask_dstMinAmount).multipliedBy(i).toString(),fills:s,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:[X.TWAP_MARKET].includes(E),chainId:t,filledOrderTimestamp:u||0,status:r,rawOrder:e}},aa=e=>{var E;if(!e)return"";const t=Ve(e.accounts,T=>`"${T.toLowerCase()}"`),n=Ve(Ti(e.configs),T=>`"${T.toLowerCase()}"`),r=Ve(e.inTokenSymbols,T=>`"${T.toUpperCase()}"`),s=Ve(e.outTokenSymbols,T=>`"${T.toUpperCase()}"`),i=Ve(e.inTokenAddresses,T=>`"${T.toLowerCase()}"`),o=Ve(e.outTokenAddresses,T=>`"${T.toLowerCase()}"`),u=Ve(e.transactionHashes,T=>`"${T.toLowerCase()}"`),f=Ve(e.orderIds,T=>`"${T}"`),h=n!=null&&n.length?"":Ve((E=e.configs)==null?void 0:E.map(T=>T.twapAddress),T=>`"${T.toLowerCase()}"`),C=e.minDollarValueIn;return[n?`exchange_in: [${n.join(", ")}]`:"",h?`twapAddress_in: [${h.join(", ")}]`:"",t?`maker_in: [${t.join(", ")}]`:"",u?`transactionHash_in: [${u.join(", ")}]`:"",f?`Contract_id_in: [${f.join(", ")}]`:"",C?`dollarValueIn_gte: ${C}`:"",r?`srcTokenSymbol_in: [${r.join(", ")}]`:"",s?`dstTokenSymbol_in: [${s.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 oa({chainId:e,signal:t,page:n,limit:r,filters:s}){const i=r||1e3,o=aa(s);return await jn({chainId:e,signal:t,limit:i,page:n,buildQuery:(f,h)=>`
2
2
  {
3
3
  orderCreateds(
4
4
  ${o?`where: { ${o} }`:""},
5
- first: ${f},
6
- skip: ${h*f},
5
+ first: ${h},
6
+ skip: ${f*h},
7
7
  orderBy: timestamp,
8
8
  orderDirection: desc,
9
9
  ) {
@@ -32,11 +32,11 @@
32
32
  transactionHash
33
33
  }
34
34
  }
35
- `,extractResults:h=>{var f;return((f=h.data)==null?void 0:f.orderCreateds)||[]}})}const ia=async({chainId:e,orders:t,signal:n})=>{if(t.length===0)return[];const r=zn(t.map(d=>d.Contract_id.toString()));if(!r.length)return[];const i=`where: { twapId_in: [${r.map(d=>`"${d}"`).join(", ")}]}`;return await jn({chainId:e,signal:n,limit:1e3,buildQuery:(d,h)=>`
35
+ `,extractResults:f=>{var h;return((h=f.data)==null?void 0:h.orderCreateds)||[]}})}const ca=async({chainId:e,orders:t,signal:n})=>{if(t.length===0)return[];const r=Vn(t.map(u=>u.Contract_id.toString()));if(!r.length)return[];const i=`where: { twapId_in: [${r.map(u=>`"${u}"`).join(", ")}]}`;return await jn({chainId:e,signal:n,limit:1e3,buildQuery:(u,f)=>`
36
36
  {
37
37
  statusNews(
38
- first: ${h},
39
- skip: ${d*h},
38
+ first: ${f},
39
+ skip: ${u*f},
40
40
  ${i}
41
41
  ) {
42
42
  twapId
@@ -44,9 +44,9 @@
44
44
  status
45
45
  }
46
46
  }
47
- `,extractResults:d=>{var h;return((h=d.data)==null?void 0:h.statusNews)||[]}})};function zn(e){return Array.from(new Set(e))}const aa=async({chainId:e,orders:t,signal:n})=>{const r=zn(t.map(E=>E.Contract_id)),s=zn(t.map(E=>E.twapAddress)).filter(Boolean);if(r.length===0)return[];const i=r.join(", "),o=s.map(E=>`"${E}"`).join(", "),d=s.length?`twapAddress_in: [${o}]`:"",f=`where: { ${[`TWAP_id_in: [${i}]`,d].filter(Boolean).join(", ")} }`;return await jn({chainId:e,signal:n,limit:1e3,buildQuery:(E,x)=>`
47
+ `,extractResults:u=>{var f;return((f=u.data)==null?void 0:f.statusNews)||[]}})};function Vn(e){return Array.from(new Set(e))}const ua=async({chainId:e,orders:t,signal:n})=>{const r=Vn(t.map(E=>E.Contract_id)),s=Vn(t.map(E=>E.twapAddress)).filter(Boolean);if(r.length===0)return[];const i=r.join(", "),o=s.map(E=>`"${E}"`).join(", "),u=s.length?`twapAddress_in: [${o}]`:"",h=`where: { ${[`TWAP_id_in: [${i}]`,u].filter(Boolean).join(", ")} }`;return await jn({chainId:e,signal:n,limit:1e3,buildQuery:(E,T)=>`
48
48
  {
49
- orderFilleds(first: ${x}, orderBy: timestamp, skip: ${E*x}, ${f}) {
49
+ orderFilleds(first: ${T}, orderBy: timestamp, skip: ${E*T}, ${h}) {
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(v=>({...v,timestamp:new Date(v.timestamp).getTime()}))}})};class oa extends Error{constructor(){super("No graph endpoint found"),this.name="NoGraphEndpointError"}}const ca=async({chainId:e,signal:t,page:n,limit:r,filters:s})=>{try{const i=await sa({chainId:e,signal:t,page:n,limit:r,filters:s}),[o,d]=await Promise.all([aa({chainId:e,orders:i,signal:t}),ia({chainId:e,orders:i,signal:t})]),h=i.map(C=>{const E=o==null?void 0:o.filter(x=>x.TWAP_id===Number(C.Contract_id)&&yt(x.exchange,C.exchange)&&yt(x.twapAddress,C.twapAddress));return na(C,e,E,ua(C,E||[],d))}).sort((C,E)=>E.createdAt-C.createdAt),f=new Set;return h.filter(C=>f.has(C.id)?!1:(f.add(C.id),!0))}catch{return[]}},ua=(e,t,n)=>{var d;const r=(d=n==null?void 0:n.find(h=>h.twapId===e.Contract_id.toString()&&yt(h.twapAddress,e.twapAddress)))==null?void 0:d.status,i=$r(t).reduce((h,f)=>h.plus(f.inAmount),new S(0)).toFixed(),o=zr(e.ask_srcAmount,i);return da(o,e.ask_deadline*1e3,r)},zr=(e,t)=>{if(!t||!e)return 0;const n=S(t).dividedBy(e).toNumber();return n>=.99?100:n<=0?0:Number((n*100).toFixed(2))},da=(e,t,n)=>e===100?pe.Completed:n==="CANCELLED"?pe.Cancelled:n==="COMPLETED"?pe.Completed:t>Date.now()?pe.Open:pe.Expired,la=async({signal:e,page:t,chainId:n,limit:r,config:s,account:i,isDev:o=!1})=>(await Promise.all([s?ca({chainId:n,signal:e,page:t,limit:r,filters:{accounts:[i],configs:s.twapConfig?[s.twapConfig]:[]}}):Promise.resolve([]),ea({chainId:n,signal:e,account:i,exchange:s==null?void 0:s.adapter,partner:s==null?void 0:s.partner,isDev:o})]).then(([f,C])=>[...f,...C])).sort((f,C)=>C.createdAt-f.createdAt),fa={version:"1.1.28"},Vr=e=>{let t;const n=new Set,r=(f,C)=>{const E=typeof f=="function"?f(t):f;if(!Object.is(E,t)){const x=t;t=C??(typeof E!="object"||E===null)?E:Object.assign({},t,E),n.forEach(v=>v(t,x))}},s=()=>t,d={setState:r,getState:s,getInitialState:()=>h,subscribe:f=>(n.add(f),()=>n.delete(f))},h=t=e(r,s,d);return d},ha=(e=>e?Vr(e):Vr),pa=e=>e;function ma(e,t=pa){const n=F.useSyncExternalStore(e.subscribe,F.useCallback(()=>t(e.getState()),[e,t]),F.useCallback(()=>t(e.getInitialState()),[e,t]));return F.useDebugValue(n),n}const Gr=e=>{const t=ha(e),n=r=>ma(t,r);return Object.assign(n,t),n},ya=(e=>e?Gr(e):Gr),gn={},Xr={currentTime:Date.now(),cancelOrders:{},swapExecutions:[gn],swapExecutionIndex:0},Q=ya((e,t)=>({state:Xr,updateState:n=>e(r=>({state:{...r.state,...n}})),updateSwapExecutionAtIndex:(n,r)=>e(s=>{const i=[...s.state.swapExecutions];return i[n]={...i[n]??gn,...r},{state:{...s.state,swapExecutions:i}}}),resetSwapExecutionAtIndex:()=>e(n=>{const r=[...n.state.swapExecutions];return r[n.state.swapExecutionIndex]=gn,{state:{...n.state,swapExecutions:r}}}),resetState:()=>{const n=t().state;e({state:{...Xr,currentTime:Date.now(),isMarketOrder:n.isMarketOrder,swapExecutions:[...n.swapExecutions,gn],swapExecutionIndex:n.swapExecutionIndex+1}})}}));var Se=(e=>(e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILED=3]="FAILED",e))(Se||{}),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||S(e).isNaN()?"":S(e).multipliedBy(S(10).pow(t)).toFixed(0),Ee=(e,t)=>{try{return!t||!e||S(e).isNaN()?"":S(e).dividedBy(S(10).pow(t)).toFixed()}catch(n){return console.error(n),""}},ga=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}},Vn=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"))},Zr=(e,t)=>{const n=At(t);return n&&Ut(e.address)?n.wToken:e};function Gn(e){return e?e/864e5:0}function An(e){return e?e/6e4:0}const Aa=(e,t)=>e?V.TWAP_MARKET:t===1?V.LIMIT:V.TWAP_LIMIT,Xn=(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)||"")},Zn=(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}`},Yn=(e,t)=>F.useMemo(()=>Et(t,e),[e,t]),en=(e,t)=>F.useMemo(()=>Ee(t,e),[e,t]),En=()=>{const{chainId:e}=q();return F.useMemo(()=>At(e),[e])},Ea=e=>{const t=En();return F.useMemo(()=>{if(!(!e||!t))return Rt(e,t.id)},[e,t])},nt=(e,t)=>F.useMemo(()=>!e||!t||S(e||"0").isZero()||S(t||"0").isZero()?"":S(e||"0").times(t).toFixed(),[e,t]),ba=()=>{const{srcToken:e,dstToken:t,chainId:n}=q();return F.useMemo(()=>Xn(e,t,n),[e,t,n])},Ta=()=>{const{srcToken:e,dstToken:t,chainId:n}=q();return F.useMemo(()=>Zn(e,t,n),[e,t,n])},wa=()=>{const e=ba(),t=Ta();return e||t},rt=()=>{const{srcToken:e,typedInputAmount:t}=q();return{amount:Yn(e==null?void 0:e.decimals,t),amountUI:t,error:S(t||0).isZero()?"enterAmount":void 0}},Ca=(e,t)=>{const{module:n,srcUsd1Token:r,marketPrice:s,minChunkSizeUsd:i,typedInputAmount:o}=q();return F.useMemo(()=>{if(S(o||"0").isZero()||!s||S(r||"0").isZero())return;if(!e)return{type:me.MIN_CHUNKS,value:1,args:{minChunks:"1"}};const{isError:d}=Ri(e,t,n);if(d)return{type:me.MAX_CHUNKS,value:t,args:{maxChunks:`${t}`}};const{isError:h,value:f}=Ui(o||"",r||"",i||0);if(h)return{type:me.MIN_TRADE_SIZE,value:f,args:{minTradeSize:`${f}`}}},[e,t,n,o,r,i,s])},qe=()=>{const{srcToken:e,srcUsd1Token:t,module:n,minChunkSizeUsd:r}=q(),s=Q(O=>O.state.typedChunks),i=Q(O=>O.updateState),{amount:o,amountUI:d}=rt(),h=F.useMemo(()=>xi(d||"",t||"",r||0),[d,t,r]),f=F.useMemo(()=>Ci(h,n,s),[h,s,n]),C=F.useCallback(O=>i({typedChunks:O}),[i]),E=F.useMemo(()=>Fi(o||"",f),[o,f]),x=en(e==null?void 0:e.decimals,E),v=F.useMemo(()=>t?S(x||"0").times(t||0).toString():"0",[x,t]);return{totalTrades:f,maxTrades:h,amountPerTradeUI:x,amountPerTrade:E,amountPerTradeUsd:v,onChange:C,error:Ca(f,h)}},xa=()=>{const{srcToken:e,dstToken:t}=q(),{onChange:n,totalTrades:r,amountPerTradeUsd:s,amountPerTradeUI:i,error:o,maxTrades:d,amountPerTrade:h}=qe();return{error:o,maxTrades:d,totalTrades:r,amountPerTradeUI:i,amountPerTrade:h,onChange:n,amountPerTradeUsd:s,fromToken:e,toToken:t}},Yr=e=>{const t=Gn(e);if(t>=1)return`${t.toFixed(t%1?1:0)} ${t===1?"day":"days"}`;const n=An(e)/60;if(n>=1)return`${n.toFixed(n%1?1:0)} ${n===1?"hour":"hours"}`;const r=An(e);return`${r.toFixed(r%1?1:0)} ${r===1?"minute":"minutes"}`},Sa=e=>{const{totalTrades:t}=qe(),{marketPrice:n,typedInputAmount:r}=q(),s=F.useMemo(()=>{const{isError:o,value:d}=Bi(e);if(!(!o||S(r||"0").isZero()||!n))return{type:me.MIN_FILL_DELAY,value:d,args:{fillDelay:Yr(d)}}},[e,r,n]),i=F.useMemo(()=>{const{isError:o,value:d}=Pi(e,t);if(!(!o||S(r||"0").isZero()||!n))return{type:me.MAX_FILL_DELAY,value:d,args:{fillDelay:Yr(d)}}},[e,r,n,t]);return s||i},Lt=()=>{const{callbacks:e}=q(),t=Q(i=>i.state.typedFillDelay),n=Q(i=>i.updateState),r=F.useMemo(()=>t||Bn,[t]),s=Sa(r);return{fillDelay:r,onChange:F.useCallback(i=>{var o;n({typedFillDelay:i}),(o=e==null?void 0:e.onFillDelayChange)==null||o.call(e,i)},[n,e]),error:s,milliseconds:r.unit*r.value}},va=()=>{const{onChange:e,fillDelay:t,error:n}=Lt(),r=F.useCallback(i=>e({unit:t.unit,value:Number(i)}),[e,t]),s=F.useCallback(i=>e({unit:i,value:t.value}),[e,t]);return{onInputChange:r,onUnitSelect:s,onChange:e,milliseconds:t.unit*t.value,fillDelay:t,error:n}},Fa=e=>{const{module:t,marketPrice:n}=q();return F.useMemo(()=>{const r=ki(t,e),s=_i(e);if(n){if(r.isError)return{type:me.MAX_ORDER_DURATION,value:r.value,args:{duration:`${Math.floor(Gn(r.value)).toFixed(0)} days`}};if(s.isError)return{type:me.MIN_ORDER_DURATION,value:s.value,args:{duration:`${Math.floor(An(s.value)).toFixed(0)} minutes`}}}},[e,t,n])},Jn=()=>{const{module:e,callbacks:t}=q(),n=Q(h=>h.state.typedDuration),r=Q(h=>h.updateState),s=qe().totalTrades,i=Lt().fillDelay,o=F.useMemo(()=>wi(e,s,i,n),[s,i,n,e]),d=Fa(o);return{duration:o,setDuration:F.useCallback(h=>{var f;r({typedDuration:h}),(f=t==null?void 0:t.onDurationChange)==null||f.call(t,h)},[r,t]),error:d}},Pa=()=>{const{duration:e,setDuration:t,error:n}=Jn(),r=F.useCallback(i=>{t({unit:e.unit,value:Number(i)})},[t,e]),s=F.useCallback(i=>{t({unit:i,value:e.value})},[t,e]);return{duration:e,onChange:t,milliseconds:e.unit*e.value,onInputChange:r,onUnitSelect:s,error:n}},Da=()=>{const{module:e}=q();return F.useMemo(()=>e===z.STOP_LOSS?ci:ui,[e])},er=()=>{const{module:e}=q(),t=Q(n=>n.state.isMarketOrder);return F.useMemo(()=>e!==z.STOP_LOSS&&e!==z.TAKE_PROFIT||t?void 0:e===z.STOP_LOSS?di:li,[e,t])},bn=()=>{const{srcToken:e,dstToken:t,marketPriceLoading:n}=q(),r=Q(f=>f.updateState),s=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:F.useCallback(()=>{i!==void 0&&r({typedTriggerPrice:S(1).div(i).toFixed()}),o!==void 0&&r({typedLimitPrice:S(1).div(o).toFixed()}),r({isInvertedTrade:!s})},[r,s,i,o,n]),isInverted:s,fromToken:s?t:e,toToken:s?e:t,isMarketPrice:d}},Jr=({typedValue:e,tokenDecimals:t=18,initialPrice:n="0",percentage:r,setValue:s,setPercentage:i})=>{const{srcUsd1Token:o,dstUsd1Token:d}=q(),{isInverted:h}=bn(),f=F.useMemo(()=>S((()=>{if(e!==void 0){const k=h?S(e).isZero()?S(0):S(1).div(e):S(e);return Et(k.toFixed(),t)}if(r!==void 0&&S(n||"0").gt(0)&&!S(n||"0").isNaN()){const k=S(n||"0"),B=S(r||0).div(100);return k.plus(k.multipliedBy(B)).decimalPlaces(0).toFixed()}return S(n).gt(0)?n:""})()).decimalPlaces(0).toFixed(),[e,r,t,n,h]),C=F.useCallback(I=>{s(I),i(null)},[s,i]),E=F.useCallback(I=>{s(void 0),i(I)},[s,i]),x=F.useMemo(()=>{if(!n||S(n).isZero())return"";if(r!=null)return r;if(f){const I=S(n),B=S(f).minus(I).div(I).multipliedBy(100).decimalPlaces(2).toString();return S(B||"0").isZero()?"":B}return""},[f,n,r]),v=F.useMemo(()=>{let I="";if(e!==void 0)I=e;else{const k=Ee(f,t);if(S(k||"0").isZero())return"";I=h?S(1).div(k).toFixed():k}return I},[e,t,f,h]),O=nt(h?o:d,v||"0");return{amount:S(f).isNaN()?"":f,amountUI:S(v).isNaN()?"":v,selectedPercentage:x,onChange:C,onPercentageChange:E,isInverted:h,usd:S(O).isNaN()?"":O,isTypedValue:e!==void 0}},Oa=(e="")=>{const{module:t,marketPrice:n,typedInputAmount:r}=q();return F.useMemo(()=>{if(S(r||"0").isZero()||!n||t!==z.STOP_LOSS&&t!==z.TAKE_PROFIT)return;const s=Di(n||"",e||"",t);if(s!=null&&s.isError)return{type:me.STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE,value:s.value};const i=Oi(n||"",e||"",t);if(i!=null&&i.isError)return{type:me.TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE,value:i.value};if(!e||S(e||0).isZero())return{type:me.EMPTY_TRIGGER_PRICE,value:e}},[n,e,t,r])},Ia=e=>{const{srcToken:t,dstToken:n,module:r,dstUsd1Token:s}=q(),i=qe().amountPerTrade,o=Q(f=>f.state.isMarketOrder),d=F.useMemo(()=>Ti(r,i,e,(t==null?void 0:t.decimals)||0),[e,i,o,t==null?void 0:t.decimals,r]),h=en((n==null?void 0:n.decimals)||0,d);return{amount:d,amountUI:h,usd:nt(h,s)}},bt=()=>{const{dstToken:e,marketPrice:t,module:n,callbacks:r}=q(),s=Q(O=>O.updateState),i=Da(),o=Q(O=>O.state.triggerPricePercent),d=o===void 0?i:o,h=n===z.STOP_LOSS||n===z.TAKE_PROFIT,f=Jr({typedValue:Q(O=>O.state.typedTriggerPrice),percentage:d,tokenDecimals:(e==null?void 0:e.decimals)||18,initialPrice:h?t:void 0,setValue:F.useCallback(O=>{var I;s({typedTriggerPrice:O}),(I=r==null?void 0:r.onTriggerPriceChange)==null||I.call(r,O||"")},[s,r]),setPercentage:F.useCallback(O=>{var I;s({triggerPricePercent:O}),(I=r==null?void 0:r.onTriggerPricePercentChange)==null||I.call(r,O||"")},[s,r])}),C=Oa(f.amount),{amount:E,amountUI:x,usd:v}=Ia(f.amount);return F.useMemo(()=>({...f,error:C,pricePerChunk:E,pricePerChunkUI:x,pricePerChunkUsd:v}),[f,C,E,x,v])},Ma=e=>{const{module:t,marketPrice:n,typedInputAmount:r}=q(),{amount:s}=bt(),i=Q(o=>o.state.isMarketOrder);return F.useMemo(()=>{if(S(r||"0").isZero()||!s||!n)return;const o=Ii(s,e,i,t),d=Mi(s,e,i,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&&S(e||0).isZero())return{type:me.MISSING_LIMIT_PRICE,value:e||""}},[e,s,t,i,r,n])},Tn=()=>{const{dstToken:e,marketPrice:t,callbacks:n}=q(),r=Q(f=>f.updateState),s=er(),i=Q(f=>f.state.limitPricePercent),o=i===void 0?s:i,d=Jr({typedValue:Q(f=>f.state.typedLimitPrice),percentage:o,tokenDecimals:(e==null?void 0:e.decimals)||18,initialPrice:t,setValue:F.useCallback(f=>{var C;r({typedLimitPrice:f}),(C=n==null?void 0:n.onLimitPriceChange)==null||C.call(n,f||"")},[r,n]),setPercentage:F.useCallback(f=>{var C;r({limitPricePercent:f}),(C=n==null?void 0:n.onLimitPricePercentChange)==null||C.call(n,f||"")},[r,n])}),h=Ma(d.amount);return F.useMemo(()=>({...d,error:h}),[d,h])},ka=()=>{const{module:e}=q(),t=Q(d=>d.updateState),n=Q(d=>d.state.isMarketOrder),r=er(),s=Q(d=>d.state.triggerPricePercent)||0,i=e===z.LIMIT,o=F.useCallback(()=>{!n&&e===z.STOP_LOSS&&t({limitPricePercent:r}),t({isMarketOrder:!n})},[t,s,e,n,r]);return{isLimitPrice:!n,toggleLimitPrice:o,hide:i}},_a=()=>{const{module:e,marketPriceLoading:t,srcToken:n,dstToken:r}=q(),{amount:s,amountUI:i,onChange:o,onPercentageChange:d,usd:h,selectedPercentage:f,error:C,isTypedValue:E}=Tn(),x=Q(K=>K.updateState),v=er(),{isLimitPrice:O,toggleLimitPrice:I}=ka(),{fromToken:k,toToken:B}=bn(),P=F.useCallback(()=>{x({typedLimitPrice:void 0}),x({limitPricePercent:v})},[x,e,v]);return{price:s,priceUI:i,error:C,onInputChange:o,onPercentageChange:d,onReset:P,usd:h,srcToken:n,dstToken:r,invertedSrcToken:k,invertedDstToken:B,percentage:f,isLoading:t,isLimitPrice:O,toggleLimitPrice:I,isTypedValue:E}},Ba=()=>{const{marketPrice:e,marketPriceLoading:t,srcToken:n,dstToken:r}=q(),{amount:s,amountUI:i,onChange:o,onPercentageChange:d,usd:h,selectedPercentage:f,error:C,pricePerChunk:E,pricePerChunkUI:x,pricePerChunkUsd:v,isTypedValue:O}=bt(),I=Q(K=>K.updateState),{fromToken:k,toToken:B}=bn(),P=F.useCallback(()=>{I({triggerPricePercent:void 0,typedTriggerPrice:void 0})},[I]);return{price:s,priceUI:i,amountPerChunk:E,amountPerChunkUI:x,amountPerChunkUsd:v,error:C,onInputChange:o,onPercentageChange:d,percentage:f,onReset:P,usd:h,srcToken:n,dstToken:r,invertedSrcToken:k,invertedDstToken:B,isLoading:t||!e,isTypedValue:O}},es=()=>{const{module:e,marketPrice:t}=q(),n=Tn().amount,r=bt().amount,s=Q(i=>i.state.isMarketOrder);return e===z.LIMIT||!s?n||"":e===z.STOP_LOSS||e===z.TAKE_PROFIT?r||"":t||""},wn=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:n}=q(),r=es(),s=rt().amount,i=F.useMemo(()=>Ei(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,i);return{amount:i,amountUI:o,usd:nt(o,n)}},tr=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:n}=q(),r=es(),s=qe().amountPerTrade,i=Q(h=>h.state.isMarketOrder),o=F.useMemo(()=>bi(s,r,!!i,(e==null?void 0:e.decimals)||0),[s,r,i,e==null?void 0:e.decimals]),d=en(t==null?void 0:t.decimals,o);return{amount:o,amountUI:d,usd:nt(d,n)}},Ua=()=>{const{typedInputAmount:e,marketPriceLoading:t,dstToken:n}=q(),{amountUI:r,usd:s}=wn(),o=wa()?e:r,d=Yn(n==null?void 0:n.decimals,o);return{value:o,valueWei:d,isLoading:t,usd:s}},Ra=()=>{const e=Q(s=>s.state.isMarketOrder),{module:t}=q(),n=F.useMemo(()=>{if(e&&t===z.STOP_LOSS)return Jt.TRIGGER_MARKET_PRICE},[e,t]),r=F.useMemo(()=>{if(!(t!==z.LIMIT&&t!==z.TWAP))return e?Jt.MARKET_PRICE:Jt.LIMIT_PRICE},[e,t]);return n||r},La=()=>{const{minChunkSizeUsd:e,typedInputAmount:t,srcUsd1Token:n}=q(),r=nt(t,n);return F.useMemo(()=>S(e).gt(S(r||"0"))?{type:me.MIN_TRADE_SIZE_ERROR,value:e}:void 0,[e,r])};function ts(){const{marketPrice:e,marketPriceLoading:t,typedInputAmount:n,srcUsd1Token:r,srcBalance:s,chainId:i}=q(),{error:o}=bt(),{error:d}=Tn(),{error:h}=qe(),{error:f}=Lt(),{error:C}=Jn(),E=La(),x=rt().amount,v=F.useMemo(()=>{if(s&&S(x).gt(s))return{type:me.INSUFFICIENT_BALANCE,value:s||""}},[s,x,i]);return F.useMemo(()=>Ni({marketPrice:e,typedInputAmount:n,srcUsd1Token:r,marketPriceLoading:t,triggerPriceError:o,limitPriceError:d,tradesError:h,fillDelayError:f,durationError:C,balanceError:v,minTradeSizeError:E}),[e,t,n,o,d,h,f,C,v,r,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(){}},Na={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},qa=(Is=class{constructor(){N(this,Ke,Na);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,Is),Tt=new qa;function Ka(e){setTimeout(e,0)}var wt=typeof window>"u"||"Deno"in globalThis;function be(){}function Ha(e,t){return typeof e=="function"?e(t):e}function nr(e){return typeof e=="number"&&e>=0&&e!==1/0}function ns(e,t){return Math.max(e+(t||0)-Date.now(),0)}function st(e,t){return typeof e=="function"?e(t):e}function Me(e,t){return typeof e=="function"?e(t):e}function rs(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:i,queryKey:o,stale:d}=e;if(o){if(r){if(t.queryHash!==rr(o,t.options))return!1}else if(!tn(t.queryKey,o))return!1}if(n!=="all"){const h=t.isActive();if(n==="active"&&!h||n==="inactive"&&h)return!1}return!(typeof d=="boolean"&&t.isStale()!==d||s&&s!==t.state.fetchStatus||i&&!i(t))}function ss(e,t){const{exact:n,status:r,predicate:s,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Ct(t.options.mutationKey)!==Ct(i))return!1}else if(!tn(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function rr(e,t){return((t==null?void 0:t.queryKeyHashFn)||Ct)(e)}function Ct(e){return JSON.stringify(e,(t,n)=>ir(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 Wa=Object.prototype.hasOwnProperty;function sr(e,t){if(e===t)return e;const n=is(e)&&is(t);if(!n&&!(ir(e)&&ir(t)))return t;const s=(n?e:Object.keys(e)).length,i=n?t:Object.keys(t),o=i.length,d=n?new Array(o):{};let h=0;for(let f=0;f<o;f++){const C=n?f:i[f],E=e[C],x=t[C];if(E===x){d[C]=E,(n?f<s:Wa.call(e,C))&&h++;continue}if(E===null||x===null||typeof E!="object"||typeof x!="object"){d[C]=x;continue}const v=sr(E,x);d[C]=v,v===E&&h++}return s===o&&h===s?e:d}function Cn(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 is(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ir(e){if(!as(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!as(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function as(e){return Object.prototype.toString.call(e)==="[object Object]"}function Qa(e){return new Promise(t=>{Tt.setTimeout(t,e)})}function ar(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 sr(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 sr(e,t)}return t}function $a(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function ja(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var xn=Symbol();function os(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===xn&&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===xn?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function cs(e,t){return typeof e=="function"?e(...t):!!e}var za=(Ms=class extends Nt{constructor(){super();N(this,St);N(this,at);N(this,qt);_(this,qt,t=>{if(!wt&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}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 n;_(this,qt,t),(n=l(this,at))==null||n.call(this),_(this,at,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){l(this,St)!==t&&(_(this,St,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof l(this,St)=="boolean"?l(this,St):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},St=new WeakMap,at=new WeakMap,qt=new WeakMap,Ms),or=new za;function cr(){let e,t;const n=new Promise((s,i)=>{e=s,t=i});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 Va=Ka;function Ga(){let e=[],t=0,n=d=>{d()},r=d=>{d()},s=Va;const i=d=>{t?e.push(d):s(()=>{n(d)})},o=()=>{const d=e;e=[],d.length&&s(()=>{r(()=>{d.forEach(h=>{n(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=>{n=d},setBatchNotifyFunction:d=>{r=d},setScheduler:d=>{s=d}}}var ue=Ga(),Xa=(ks=class extends Nt{constructor(){super();N(this,Kt,!0);N(this,ot);N(this,Ht);_(this,Ht,t=>{if(!wt&&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),_(this,ot,void 0))}setEventListener(t){var n;_(this,Ht,t),(n=l(this,ot))==null||n.call(this),_(this,ot,t(this.setOnline.bind(this)))}setOnline(t){l(this,Kt)!==t&&(_(this,Kt,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return l(this,Kt)}},Kt=new WeakMap,ot=new WeakMap,Ht=new WeakMap,ks),Sn=new Xa;function Za(e){return Math.min(1e3*2**e,3e4)}function us(e){return(e??"online")==="online"?Sn.isOnline():!0}var ur=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function ds(e){let t=!1,n=0,r;const s=cr(),i=()=>s.status!=="pending",o=I=>{var k;if(!i()){const B=new ur(I);x(B),(k=e.onCancel)==null||k.call(e,B)}},d=()=>{t=!0},h=()=>{t=!1},f=()=>or.isFocused()&&(e.networkMode==="always"||Sn.isOnline())&&e.canRun(),C=()=>us(e.networkMode)&&e.canRun(),E=I=>{i()||(r==null||r(),s.resolve(I))},x=I=>{i()||(r==null||r(),s.reject(I))},v=()=>new Promise(I=>{var k;r=B=>{(i()||f())&&I(B)},(k=e.onPause)==null||k.call(e)}).then(()=>{var I;r=void 0,i()||(I=e.onContinue)==null||I.call(e)}),O=()=>{if(i())return;let I;const k=n===0?e.initialPromise:void 0;try{I=k??e.fn()}catch(B){I=Promise.reject(B)}Promise.resolve(I).then(E).catch(B=>{var Y;if(i())return;const P=e.retry??(wt?0:3),K=e.retryDelay??Za,U=typeof K=="function"?K(n,B):K,Z=P===!0||typeof P=="number"&&n<P||typeof P=="function"&&P(n,B);if(t||!Z){x(B);return}n++,(Y=e.onFail)==null||Y.call(e,n,B),Qa(U).then(()=>f()?void 0:v()).then(()=>{t?x(B):O()})})};return{promise:s,status:()=>s.status,cancel:o,continue:()=>(r==null||r(),s),cancelRetry:d,continueRetry:h,canStart:C,start:()=>(C()?O():v().then(O),s)}}var ls=(_s=class{constructor(){N(this,vt)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),nr(this.gcTime)&&_(this,vt,Tt.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(wt?1/0:300*1e3))}clearGcTimeout(){l(this,vt)&&(Tt.clearTimeout(l(this,vt)),_(this,vt,void 0))}},vt=new WeakMap,_s),Ya=(Bs=class extends ls{constructor(t){super();N(this,Le);N(this,Ft);N(this,Wt);N(this,ke);N(this,Pt);N(this,he);N(this,rn);N(this,Dt);_(this,Dt,!1),_(this,rn,t.defaultOptions),this.setOptions(t.options),this.observers=[],_(this,Pt,t.client),_(this,ke,l(this,Pt).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,_(this,Ft,ps(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,he))==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=ps(this.options);n.data!==void 0&&(this.setState(hs(n.data,n.dataUpdatedAt)),_(this,Ft,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&l(this,ke).remove(this)}setData(t,n){const r=ar(this.state.data,t,this.options);return $(this,Le,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){$(this,Le,Je).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,s;const n=(r=l(this,he))==null?void 0:r.promise;return(s=l(this,he))==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=>Me(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===xn||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:!ns(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=l(this,he))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=l(this,he))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),l(this,ke).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,he)&&(l(this,Dt)?l(this,he).cancel({revert:!0}):l(this,he).cancelRetry()),this.scheduleGc()),l(this,ke).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||$(this,Le,Je).call(this,{type:"invalidate"})}async fetch(t,n){var h,f,C,E,x,v,O,I,k,B,P,K;if(this.state.fetchStatus!=="idle"&&((h=l(this,he))==null?void 0:h.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(l(this,he))return l(this,he).continueRetry(),l(this,he).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:()=>(_(this,Dt,!0),r.signal)})},i=()=>{const U=os(this.options,n),Y=(()=>{const oe={client:l(this,Pt),queryKey:this.queryKey,meta:this.meta};return s(oe),oe})();return _(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:i};return s(U),U})();(f=this.options.behavior)==null||f.onFetch(d,this),_(this,Wt,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((C=d.fetchOptions)==null?void 0:C.meta))&&$(this,Le,Je).call(this,{type:"fetch",meta:(E=d.fetchOptions)==null?void 0:E.meta}),_(this,he,ds({initialPromise:n==null?void 0:n.initialPromise,fn:d.fetchFn,onCancel:U=>{U instanceof ur&&U.revert&&this.setState({...l(this,Wt),fetchStatus:"idle"}),r.abort()},onFail:(U,Z)=>{$(this,Le,Je).call(this,{type:"failed",failureCount:U,error:Z})},onPause:()=>{$(this,Le,Je).call(this,{type:"pause"})},onContinue:()=>{$(this,Le,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,he).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),(v=(x=l(this,ke).config).onSuccess)==null||v.call(x,U,this),(I=(O=l(this,ke).config).onSettled)==null||I.call(O,U,this.state.error,this),U}catch(U){if(U instanceof ur){if(U.silent)return l(this,he).promise;if(U.revert){if(this.state.data===void 0)throw U;return this.state.data}}throw $(this,Le,Je).call(this,{type:"error",error:U}),(B=(k=l(this,ke).config).onError)==null||B.call(k,U,this),(K=(P=l(this,ke).config).onSettled)==null||K.call(P,this.state.data,U,this),U}finally{this.scheduleGc()}}},Ft=new WeakMap,Wt=new WeakMap,ke=new WeakMap,Pt=new WeakMap,he=new WeakMap,rn=new WeakMap,Dt=new WeakMap,Le=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,...fs(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...hs(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return _(this,Wt,t.manual?s:void 0),s;case"error":const i=t.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,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,ke).notify({query:this,type:"updated",action:t})})},Bs);function fs(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:us(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function hs(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function ps(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 Ja=(Us=class extends Nt{constructor(t,n){super();N(this,ee);N(this,ve);N(this,X);N(this,sn);N(this,Te);N(this,Ot);N(this,Qt);N(this,Ve);N(this,ct);N(this,an);N(this,$t);N(this,jt);N(this,It);N(this,Mt);N(this,ut);N(this,zt,new Set);this.options=n,_(this,ve,t),_(this,ct,null),_(this,Ve,cr()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(l(this,X).addObserver(this),ms(l(this,X),this.options)?$(this,ee,dn).call(this):this.updateResult(),$(this,ee,wr).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return dr(l(this,X),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return dr(l(this,X),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,$(this,ee,Cr).call(this),$(this,ee,xr).call(this),l(this,X).removeObserver(this)}setOptions(t){const n=this.options,r=l(this,X);if(this.options=l(this,ve).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Me(this.options.enabled,l(this,X))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");$(this,ee,Sr).call(this),l(this,X).setOptions(this.options),n._defaulted&&!Cn(this.options,n)&&l(this,ve).getQueryCache().notify({type:"observerOptionsUpdated",query:l(this,X),observer:this});const s=this.hasListeners();s&&ys(l(this,X),r,this.options,n)&&$(this,ee,dn).call(this),this.updateResult(),s&&(l(this,X)!==r||Me(this.options.enabled,l(this,X))!==Me(n.enabled,l(this,X))||st(this.options.staleTime,l(this,X))!==st(n.staleTime,l(this,X)))&&$(this,ee,Er).call(this);const i=$(this,ee,br).call(this);s&&(l(this,X)!==r||Me(this.options.enabled,l(this,X))!==Me(n.enabled,l(this,X))||i!==l(this,ut))&&$(this,ee,Tr).call(this,i)}getOptimisticResult(t){const n=l(this,ve).getQueryCache().build(l(this,ve),t),r=this.createResult(n,t);return to(this,r)&&(_(this,Te,r),_(this,Qt,this.options),_(this,Ot,l(this,X).state)),r}getCurrentResult(){return l(this,Te)}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,zt).add(t)}getCurrentQuery(){return l(this,X)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=l(this,ve).defaultQueryOptions(t),r=l(this,ve).getQueryCache().build(l(this,ve),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return $(this,ee,dn).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),l(this,Te)))}createResult(t,n){var c;const r=l(this,X),s=this.options,i=l(this,Te),o=l(this,Ot),d=l(this,Qt),f=t!==r?t.state:l(this,sn),{state:C}=t;let E={...C},x=!1,v;if(n._optimisticResults){const u=this.hasListeners(),A=!u&&ms(t,n),m=u&&ys(t,r,n,s);(A||m)&&(E={...E,...fs(C.data,t.options)}),n._optimisticResults==="isRestoring"&&(E.fetchStatus="idle")}let{error:O,errorUpdatedAt:I,status:k}=E;v=E.data;let B=!1;if(n.placeholderData!==void 0&&v===void 0&&k==="pending"){let u;i!=null&&i.isPlaceholderData&&n.placeholderData===(d==null?void 0:d.placeholderData)?(u=i.data,B=!0):u=typeof n.placeholderData=="function"?n.placeholderData((c=l(this,jt))==null?void 0:c.state.data,l(this,jt)):n.placeholderData,u!==void 0&&(k="success",v=ar(i==null?void 0:i.data,u,n),x=!0)}if(n.select&&v!==void 0&&!B)if(i&&v===(o==null?void 0:o.data)&&n.select===l(this,an))v=l(this,$t);else try{_(this,an,n.select),v=n.select(v),v=ar(i==null?void 0:i.data,v,n),_(this,$t,v),_(this,ct,null)}catch(u){_(this,ct,u)}l(this,ct)&&(O=l(this,ct),v=l(this,$t),I=Date.now(),k="error");const P=E.fetchStatus==="fetching",K=k==="pending",U=k==="error",Z=K&&P,Y=v!==void 0,a={status:k,fetchStatus:E.fetchStatus,isPending:K,isSuccess:k==="success",isError:U,isInitialLoading:Z,isLoading:Z,data:v,dataUpdatedAt:E.dataUpdatedAt,error:O,errorUpdatedAt:I,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:P,isRefetching:P&&!K,isLoadingError:U&&!Y,isPaused:E.fetchStatus==="paused",isPlaceholderData:x,isRefetchError:U&&Y,isStale:lr(t,n),refetch:this.refetch,promise:l(this,Ve),isEnabled:Me(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const u=y=>{a.status==="error"?y.reject(a.error):a.data!==void 0&&y.resolve(a.data)},A=()=>{const y=_(this,Ve,a.promise=cr());u(y)},m=l(this,Ve);switch(m.status){case"pending":t.queryHash===r.queryHash&&u(m);break;case"fulfilled":(a.status==="error"||a.data!==m.value)&&A();break;case"rejected":(a.status!=="error"||a.error!==m.reason)&&A();break}}return a}updateResult(){const t=l(this,Te),n=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,jt,l(this,X)),Cn(n,t))return;_(this,Te,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!l(this,zt).size)return!0;const o=new Set(i??l(this,zt));return this.options.throwOnError&&o.add("error"),Object.keys(l(this,Te)).some(d=>{const h=d;return l(this,Te)[h]!==t[h]&&o.has(h)})};$(this,ee,Ws).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&$(this,ee,wr).call(this)}},ve=new WeakMap,X=new WeakMap,sn=new WeakMap,Te=new WeakMap,Ot=new WeakMap,Qt=new WeakMap,Ve=new WeakMap,ct=new WeakMap,an=new WeakMap,$t=new WeakMap,jt=new WeakMap,It=new WeakMap,Mt=new WeakMap,ut=new WeakMap,zt=new WeakMap,ee=new WeakSet,dn=function(t){$(this,ee,Sr).call(this);let n=l(this,X).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(be)),n},Er=function(){$(this,ee,Cr).call(this);const t=st(this.options.staleTime,l(this,X));if(wt||l(this,Te).isStale||!nr(t))return;const r=ns(l(this,Te).dataUpdatedAt,t)+1;_(this,It,Tt.setTimeout(()=>{l(this,Te).isStale||this.updateResult()},r))},br=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(l(this,X)):this.options.refetchInterval)??!1},Tr=function(t){$(this,ee,xr).call(this),_(this,ut,t),!(wt||Me(this.options.enabled,l(this,X))===!1||!nr(l(this,ut))||l(this,ut)===0)&&_(this,Mt,Tt.setInterval(()=>{(this.options.refetchIntervalInBackground||or.isFocused())&&$(this,ee,dn).call(this)},l(this,ut)))},wr=function(){$(this,ee,Er).call(this),$(this,ee,Tr).call(this,$(this,ee,br).call(this))},Cr=function(){l(this,It)&&(Tt.clearTimeout(l(this,It)),_(this,It,void 0))},xr=function(){l(this,Mt)&&(Tt.clearInterval(l(this,Mt)),_(this,Mt,void 0))},Sr=function(){const t=l(this,ve).getQueryCache().build(l(this,ve),this.options);if(t===l(this,X))return;const n=l(this,X);_(this,X,t),_(this,sn,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},Ws=function(t){ue.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(l(this,Te))}),l(this,ve).getQueryCache().notify({query:l(this,X),type:"observerResultsUpdated"})})},Us);function eo(e,t){return Me(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function ms(e,t){return eo(e,t)||e.state.data!==void 0&&dr(e,t,t.refetchOnMount)}function dr(e,t,n){if(Me(t.enabled,e)!==!1&&st(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&lr(e,t)}return!1}function ys(e,t,n,r){return(e!==t||Me(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&lr(e,n)}function lr(e,t){return Me(t.enabled,e)!==!1&&e.isStaleByTime(st(t.staleTime,e))}function to(e,t){return!Cn(e.getCurrentResult(),t)}function gs(e){return{onFetch:(t,n)=>{var C,E,x,v,O;const r=t.options,s=(x=(E=(C=t.fetchOptions)==null?void 0:C.meta)==null?void 0:E.fetchMore)==null?void 0:x.direction,i=((v=t.state.data)==null?void 0:v.pages)||[],o=((O=t.state.data)==null?void 0:O.pageParams)||[];let d={pages:[],pageParams:[]},h=0;const f=async()=>{let I=!1;const k=K=>{Object.defineProperty(K,"signal",{enumerable:!0,get:()=>(t.signal.aborted?I=!0:t.signal.addEventListener("abort",()=>{I=!0}),t.signal)})},B=os(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 k(A),A})(),a=await B(oe),{maxPages:c}=t.options,u=Z?ja:$a;return{pages:u(K.pages,a,c),pageParams:u(K.pageParams,U,c)}};if(s&&i.length){const K=s==="backward",U=K?no:As,Z={pages:i,pageParams:o},Y=U(r,Z);d=await P(Z,Y,K)}else{const K=e??i.length;do{const U=h===0?o[0]??r.initialPageParam:As(r,d);if(h>0&&U==null)break;d=await P(d,U),h++}while(h<K)}return d};t.options.persister?t.fetchFn=()=>{var I,k;return(k=(I=t.options).persister)==null?void 0:k.call(I,f,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=f}}}function As(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 no(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 ro=(Rs=class extends ls{constructor(t){super();N(this,We);N(this,on);N(this,He);N(this,we);N(this,kt);_(this,on,t.client),this.mutationId=t.mutationId,_(this,we,t.mutationCache),_(this,He,[]),this.state=t.state||Es(),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,we).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){_(this,He,l(this,He).filter(n=>n!==t)),this.scheduleGc(),l(this,we).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){l(this,He).length||(this.state.status==="pending"?this.scheduleGc():l(this,we).remove(this))}continue(){var t;return((t=l(this,kt))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,d,h,f,C,E,x,v,O,I,k,B,P,K,U,Z,Y,oe,a,c;const n=()=>{$(this,We,pt).call(this,{type:"continue"})},r={client:l(this,on),meta:this.options.meta,mutationKey:this.options.mutationKey};_(this,kt,ds({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(u,A)=>{$(this,We,pt).call(this,{type:"failed",failureCount:u,error:A})},onPause:()=>{$(this,We,pt).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>l(this,we).canRun(this)}));const s=this.state.status==="pending",i=!l(this,kt).canStart();try{if(s)n();else{$(this,We,pt).call(this,{type:"pending",variables:t,isPaused:i}),await((d=(o=l(this,we).config).onMutate)==null?void 0:d.call(o,t,this,r));const A=await((f=(h=this.options).onMutate)==null?void 0:f.call(h,t,r));A!==this.state.context&&$(this,We,pt).call(this,{type:"pending",context:A,variables:t,isPaused:i})}const u=await l(this,kt).start();return await((E=(C=l(this,we).config).onSuccess)==null?void 0:E.call(C,u,t,this.state.context,this,r)),await((v=(x=this.options).onSuccess)==null?void 0:v.call(x,u,t,this.state.context,r)),await((I=(O=l(this,we).config).onSettled)==null?void 0:I.call(O,u,null,this.state.variables,this.state.context,this,r)),await((B=(k=this.options).onSettled)==null?void 0:B.call(k,u,null,t,this.state.context,r)),$(this,We,pt).call(this,{type:"success",data:u}),u}catch(u){try{throw await((K=(P=l(this,we).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,we).config).onSettled)==null?void 0:oe.call(Y,void 0,u,this.state.variables,this.state.context,this,r)),await((c=(a=this.options).onSettled)==null?void 0:c.call(a,void 0,u,t,this.state.context,r)),u}finally{$(this,We,pt).call(this,{type:"error",error:u})}}finally{l(this,we).runNext(this)}}},on=new WeakMap,He=new WeakMap,we=new WeakMap,kt=new WeakMap,We=new WeakSet,pt=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,we).notify({mutation:this,type:"updated",action:t})})},Rs);function Es(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var so=(Ls=class extends Nt{constructor(t={}){super();N(this,Ge);N(this,Ne);N(this,cn);this.config=t,_(this,Ge,new Set),_(this,Ne,new Map),_(this,cn,0)}build(t,n,r){const s=new ro({client:t,mutationCache:this,mutationId:++On(this,cn)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){l(this,Ge).add(t);const n=vn(t);if(typeof n=="string"){const r=l(this,Ne).get(n);r?r.push(t):l(this,Ne).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(l(this,Ge).delete(t)){const n=vn(t);if(typeof n=="string"){const r=l(this,Ne).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,Ne).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=vn(t);if(typeof n=="string"){const r=l(this,Ne).get(n),s=r==null?void 0:r.find(i=>i.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const n=vn(t);if(typeof n=="string"){const s=(r=l(this,Ne).get(n))==null?void 0:r.find(i=>i!==t&&i.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,Ne).clear()})}getAll(){return Array.from(l(this,Ge))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>ss(n,r))}findAll(t={}){return this.getAll().filter(n=>ss(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,Ne=new WeakMap,cn=new WeakMap,Ls);function vn(e){var t;return(t=e.options.scope)==null?void 0:t.id}var io=(Ns=class extends Nt{constructor(t,n){super();N(this,Ye);N(this,Xe);N(this,dt);N(this,Fe);N(this,Ze);_(this,Xe,t),this.setOptions(n),this.bindMethods(),$(this,Ye,In).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),Cn(this.options,n)||l(this,Xe).getMutationCache().notify({type:"observerOptionsUpdated",mutation:l(this,Fe),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&Ct(n.mutationKey)!==Ct(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){$(this,Ye,In).call(this),$(this,Ye,vr).call(this,t)}getCurrentResult(){return l(this,dt)}reset(){var t;(t=l(this,Fe))==null||t.removeObserver(this),_(this,Fe,void 0),$(this,Ye,In).call(this),$(this,Ye,vr).call(this)}mutate(t,n){var r;return _(this,Ze,n),(r=l(this,Fe))==null||r.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,In=function(){var n;const t=((n=l(this,Fe))==null?void 0:n.state)??Es();_(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})},vr=function(t){ue.batch(()=>{var n,r,s,i,o,d,h,f;if(l(this,Ze)&&this.hasListeners()){const C=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"?((r=(n=l(this,Ze)).onSuccess)==null||r.call(n,t.data,C,E,x),(i=(s=l(this,Ze)).onSettled)==null||i.call(s,t.data,null,C,E,x)):(t==null?void 0:t.type)==="error"&&((d=(o=l(this,Ze)).onError)==null||d.call(o,t.error,C,E,x),(f=(h=l(this,Ze)).onSettled)==null||f.call(h,void 0,t.error,C,E,x))}this.listeners.forEach(C=>{C(l(this,dt))})})},Ns),ao=(qs=class extends Nt{constructor(t={}){super();N(this,Qe);this.config=t,_(this,Qe,new Map)}build(t,n,r){const s=n.queryKey,i=n.queryHash??rr(s,n);let o=this.get(i);return o||(o=new Ya({client:t,queryKey:s,queryHash:i,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=>rs(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>rs(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,qs),oo=(Ks=class{constructor(e={}){N(this,se);N(this,lt);N(this,ft);N(this,Vt);N(this,Gt);N(this,ht);N(this,Xt);N(this,Zt);_(this,se,e.queryCache||new ao),_(this,lt,e.mutationCache||new so),_(this,ft,e.defaultOptions||{}),_(this,Vt,new Map),_(this,Gt,new Map),_(this,ht,0)}mount(){On(this,ht)._++,l(this,ht)===1&&(_(this,Xt,or.subscribe(async e=>{e&&(await this.resumePausedMutations(),l(this,se).onFocus())})),_(this,Zt,Sn.subscribe(async e=>{e&&(await this.resumePausedMutations(),l(this,se).onOnline())})))}unmount(){var e,t;On(this,ht)._--,l(this,ht)===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,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),i=s==null?void 0:s.state.data,o=Ha(t,i);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 i=s.fetch(void 0,n);return n.throwOnError||(i=i.catch(be)),s.state.fetchStatus==="paused"?Promise.resolve():i}));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=gs(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(be).catch(be)}ensureInfiniteQueryData(e){return e.behavior=gs(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Sn.isOnline()?l(this,lt).resumePausedMutations():Promise.resolve()}getQueryCache(){return l(this,se)}getMutationCache(){return l(this,lt)}getDefaultOptions(){return l(this,ft)}setDefaultOptions(e){_(this,ft,e)}setQueryDefaults(e,t){l(this,Vt).set(Ct(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(Ct(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,ft).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=rr(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===xn&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...l(this,ft).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,ft=new WeakMap,Vt=new WeakMap,Gt=new WeakMap,ht=new WeakMap,Xt=new WeakMap,Zt=new WeakMap,Ks),bs=ce.createContext(void 0),fr=e=>{const t=ce.useContext(bs);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},co=({client:e,children:t})=>(ce.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),H.jsx(bs.Provider,{value:e,children:t})),Ts=ce.createContext(!1),uo=()=>ce.useContext(Ts);Ts.Provider;function lo(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var fo=ce.createContext(lo()),ho=()=>ce.useContext(fo),po=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},mo=e=>{ce.useEffect(()=>{e.clearReset()},[e])},yo=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||cs(n,[e.error,r])),go=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))}},Ao=(e,t)=>e.isLoading&&e.isFetching&&!t,Eo=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,ws=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function bo(e,t,n){var E,x,v,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=uo(),s=ho(),i=fr(),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=r?"isRestoring":"optimistic",go(o),po(o,s),mo(s);const d=!i.getQueryCache().get(o.queryHash),[h]=ce.useState(()=>new t(i,o)),f=h.getOptimisticResult(o),C=!r&&e.subscribed!==!1;if(ce.useSyncExternalStore(ce.useCallback(k=>{const B=C?h.subscribe(ue.batchCalls(k)):be;return h.updateResult(),B},[h,C]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),ce.useEffect(()=>{h.setOptions(o)},[o,h]),Eo(o,f))throw ws(o,h,s);if(yo({result:f,errorResetBoundary:s,throwOnError:o.throwOnError,query:i.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw f.error;if((O=(v=i.getDefaultOptions().queries)==null?void 0:v._experimental_afterQuery)==null||O.call(v,o,f),o.experimental_prefetchInRender&&!wt&&Ao(f,r)){const k=d?ws(o,h,s):(I=i.getQueryCache().get(o.queryHash))==null?void 0:I.promise;k==null||k.catch(be).finally(()=>{h.updateResult()})}return o.notifyOnChangeProps?f:h.trackResult(f)}function To(e,t){return bo(e,Ja)}function it(e,t){const n=fr(),[r]=ce.useState(()=>new io(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()),i=ce.useCallback((o,d)=>{r.mutate(o,d).catch(be)},[r]);if(s.error&&cs(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:i,mutateAsync:s.mutate}}const nn=()=>{const e=Q(i=>i.state.swapExecutionIndex),t=Q(i=>i.state.swapExecutions[i.state.swapExecutionIndex]??{}),n=Q(i=>i.updateSwapExecutionAtIndex),r=Q(i=>i.resetSwapExecutionAtIndex),s=F.useCallback(i=>n(e,i),[n,e]);return F.useMemo(()=>({...t,update:s,resetSwap:r}),[t,s,r])},wo=2e4,Co=()=>{const{module:e}=q(),t=Q(n=>n.state.isMarketOrder);return F.useMemo(()=>e===z.TWAP?t?V.TWAP_MARKET:V.TWAP_LIMIT:e===z.LIMIT?V.LIMIT:e===z.STOP_LOSS?t?V.STOP_LOSS_MARKET:V.STOP_LOSS_LIMIT:e===z.TAKE_PROFIT?t?V.TAKE_PROFIT_MARKET:V.TAKE_PROFIT_LIMIT:V.TWAP_MARKET,[e,t])},Cs=()=>{const{account:e,config:t,chainId:n,isDev:r}=q();return F.useMemo(()=>["useTwapOrderHistoryManager",e,t==null?void 0:t.adapter,t==null?void 0:t.partner,n,r],[e,t,n,r])},xo=()=>{const{callbacks:e}=q(),t=fr(),n=Cs();return F.useCallback(r=>{var d;const s=t.getQueryData(n);let i=!1;const o=[];s&&s.filter(h=>h.version===2).forEach(h=>{var C;const f=r.find(E=>E.id===h.id);f&&f.progress!==h.progress&&(i=!0,o.push(f),f.status===pe.Completed&&((C=e==null?void 0:e.onOrderFilled)==null||C.call(e,f)))}),i&&((d=e==null?void 0:e.onOrdersProgressUpdate)==null||d.call(e,o))},[t,n,e])},hr=()=>{const{account:e,config:t,chainId:n,isDev:r}=q(),s=Cs(),i=xo();return To({refetchInterval:wo,refetchOnWindowFocus:!0,retry:!1,staleTime:1/0,queryKey:s,queryFn:async({signal:d})=>{if(!e||!n||!t)return[];const h=await la({signal:d,chainId:n,config:t,account:e,isDev:r});return i(h),h.map(f=>t!=null&&t.twapConfig?{...f,fillDelayMillis:qn(f,t.twapConfig)}:f)}})},So=(e,t,n)=>F.useMemo(()=>{if(!(!e||!t||!n||n!=null&&n.isMarketPrice))return Rr(n,e==null?void 0:e.decimals,t==null?void 0:t.decimals)},[n,e,t]),vo=(e,t,n)=>F.useMemo(()=>{if(!(!e||!t||!n))return Lr(n,e.decimals,t.decimals)},[n,e,t]),Fo=(e,t,n)=>F.useMemo(()=>{if(!(!e||!t||!n))return Kn(n.srcAmountFilled,n.dstAmountFilled,e.decimals,t.decimals)},[n,e,t]),Fn=(e,t)=>[...e.filter(r=>r.status===t)].sort((r,s)=>s.createdAt-r.createdAt),Po=()=>{const{data:e,isLoading:t,refetch:n,isRefetching:r}=hr(),s=F.useCallback(()=>n().then(i=>i.data),[n]);return F.useMemo(()=>({orders:{all:e??[],open:Fn(e??[],pe.Open),completed:Fn(e??[],pe.Completed),cancelled:Fn(e??[],pe.Cancelled),expired:Fn(e??[],pe.Expired)},isLoading:t,isRefetching:r,refetchOrders:s}),[e,t,r,s])},pr=()=>{const e=Q(n=>n.state.currentTime),t=Jn().duration;return F.useMemo(()=>Si(e,t),[e,t])},xs=()=>{const{srcToken:e,dstToken:t,account:n,chainId:r,slippage:s,config:i,module:o,fees:d}=q(),{amount:h}=rt(),{amountPerTrade:f,totalTrades:C}=qe(),E=pr(),{amount:x}=tr(),{pricePerChunk:v}=bt(),{milliseconds:O}=Lt();return F.useMemo(()=>{var I;return Kr({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:h,deadlineMillis:E,fillDelayMillis:!C||C===1?0:O,slippage:s*100,account:n,srcAmountPerTrade:f,dstMinAmountPerTrade:x,triggerAmountPerTrade:v,config:i,module:o})},[e,t,n,r,s,i,o,h,f,C,O,x,v,d])};function Do(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 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 Oo=()=>{var i;const{account:e,walletInteractions:t,callbacks:n,chainId:r}=q(),s=(i=En())==null?void 0:i.wToken;return it({mutationFn:async({onHash:o,srcAmountWei:d})=>{var f,C;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletInteractions");if(!s)throw new Error("tokenAddress is not defined");fe.onWrapRequest();const h=await t.wrapNativeToken(d);return(f=n==null?void 0:n.onWrapRequest)==null||f.call(n),o==null||o(h),fe.onWrapSuccess(h),(C=n==null?void 0:n.onWrapSuccess)==null||C.call(n,{txHash:h,explorerUrl:Rt(h,r),amount:Ee(d,s.decimals)}),h},onError:o=>{throw fe.onWrapError(o),o}})},Ss=()=>{const{account:e,walletInteractions:t,chainId:n,callbacks:r,isDev:s}=q(),i=xs(),{refetch:o}=hr();return it({mutationFn:async()=>{var I,k,B,P;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletInteractions");if(!n)throw new Error("missing chainId");const{order:d,domain:h,types:f,primaryType:C}=i;fe.onSignOrderRequest(d);let E;try{E=await t.signOrder({domain:h,types:f,primaryType:C,message:d,account:e})}catch(K){throw(I=r==null?void 0:r.onSignOrderError)==null||I.call(r,K),fe.onSignOrderError(K),K}fe.onSignOrderSuccess(E),(k=r==null?void 0:r.onSignOrderSuccess)==null||k.call(r,E);const x=Do(E),v={v:`0x${x.v.toString(16)}`,r:x.r,s:x.s};(B=r==null?void 0:r.onSignOrderRequest)==null||B.call(r);const O=await Qr(d,v,s);return(P=r==null?void 0:r.onOrderCreated)==null||P.call(r,O),await o(),O}})},vs=()=>{const{account:e,walletInteractions:t,config:n}=q();return it({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 i=await t.getAllowance({tokenAddress:r,spenderAddress:n.repermit}),o=S(i||"0").lt(S(s).toString());return{allowance:i,approvalRequired:o}}})},Io=()=>{const{account:e,walletInteractions:t,config:n,chainId:r,callbacks:s}=q(),{mutateAsync:i}=vs();return it({onError:o=>{fe.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(!n)throw new Error("missing config");fe.onApproveRequest();const f=await t.approveToken({tokenAddress:o.address,amount:h,spenderAddress:n.repermit});if(!f)throw new Error("failed to approve token");(E=s==null?void 0:s.onApproveRequest)==null||E.call(s),d(f);let C=!1;for(let v=0;v<3;v++){const{approvalRequired:O}=await i({tokenAddress:o.address,srcAmountWei:h});if(!O){C=!0;break}v<2&&await new Promise(I=>setTimeout(I,3e3))}if(!C)throw new Error(`Insufficient ${o.symbol} allowance to perform the swap. Please approve the token first.`);return fe.onApproveSuccess(f),(x=s==null?void 0:s.onApproveSuccess)==null||x.call(s,{txHash:f,explorerUrl:Rt(f,r),token:o,amount:Ee(h,o.decimals)}),f}})},Mo=()=>{const{account:e,chainId:t,srcToken:n,dstToken:r,module:s,slippage:i}=q(),o=bt(),d=rt().amount,h=qe().amountPerTrade,f=pr(),C=qe().totalTrades,E=Lt().fillDelay,x=tr().amount,v=Q(O=>O.state.isMarketOrder);return it({mutationFn:async()=>{fe.onRequestOrder({account:e,chainId:t,module:s,srcToken:n,dstToken:r,fromTokenAmount:d,srcChunkAmount:h,triggerPricePerTrade:o.pricePerChunk,deadline:f,fillDelay:E.unit*E.value,minDstAmountOutPerTrade:x,slippage:i,isMarketOrder:v||!1,chunksAmount:C})}})};function ko(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 Fs=()=>{const{srcToken:e,dstToken:t,chainId:n,callbacks:r,marketPrice:s}=q(),i=Io().mutateAsync,o=Oo().mutateAsync,d=Ss().mutateAsync,{mutateAsync:h}=vs(),{update:f}=nn(),{amount:C}=rt(),E=Mo().mutate;return it({mutationFn:async()=>{var v,O;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(!n)throw new Error("missing chainId");const I=Zr(e,n);f({allowanceLoading:!0,wrapTxHash:void 0,approveTxHash:void 0,acceptedMarketPrice:s,acceptedSrcAmount:C,srcToken:e,dstToken:t,pendingSteps:[]});const{approvalRequired:k}=await h({tokenAddress:I.address,srcAmountWei:C});let B=0,P=1;x&&P++,k&&P++,f({totalSteps:P,stepIndex:B,allowanceLoading:!1,hasApproval:!k,status:Se.LOADING}),E();let K=[];x&&K.push(tt.WRAP),k&&K.push(tt.APPROVE),K.push(tt.CREATE),f({pendingSteps:K}),x&&(f({step:tt.WRAP}),await o({onHash:Z=>f({wrapTxHash:Z}),srcAmountWei:C}),B++,f({stepIndex:B})),k&&(f({step:tt.APPROVE}),await i({token:I,onHash:Z=>f({approveTxHash:Z}),srcAmountWei:C}),B++,f({stepIndex:B})),f({step:tt.CREATE});const U=await d();return f({status:Se.SUCCESS,orderId:U.id}),U}catch(I){if(Vn(I))(v=r==null?void 0:r.onSubmitOrderRejected)==null||v.call(r),f({step:void 0,status:void 0,stepIndex:void 0,error:I});else{const k=ko(I);(O=r==null?void 0:r.onSubmitOrderFailed)==null||O.call(r,k),f({status:Se.FAILED,parsedError:k,error:I})}throw I}}})},_o=()=>{const e=nn(),{srcToken:t,dstToken:n}=q(),r=Fs(),s=Q(f=>f.resetState),i=F.useCallback(()=>r.mutateAsync(),[r]),{update:o,resetSwap:d,...h}=e;return F.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:n,onSubmit:i,resetState:s,resetCurrentSwap:d,isLoading:(e==null?void 0:e.status)===Se.LOADING,isSuccess:(e==null?void 0:e.status)===Se.SUCCESS,isFailed:(e==null?void 0:e.status)===Se.FAILED,confirmButtonLoading:h.allowanceLoading}),[i,h,s,d,t,n])},Bo=()=>{const{marketPrice:e,srcToken:t,dstToken:n,marketPriceLoading:r,srcBalance:s,srcUsd1Token:i,noLiquidity:o,typedInputAmount:d}=q(),h=r||S(i||"0").isZero()||s===void 0||S(e||"0").isZero(),f=!!(t&&n&&d&&h),E=!!(ts()||o||f||S(d||"0").isZero()||!t||!n);return F.useMemo(()=>({disabled:E,loading:f}),[E,f])},Uo=()=>{const{srcUsd1Token:e,dstUsd1Token:t}=q(),n=rt().amountUI,r=wn().amountUI,s=nt(n,e),i=nt(r,t);return{srcAmountUsd:s,dstAmountUsd:i}},Ro=()=>{const{fees:e,dstToken:t,dstUsd1Token:n}=q(),{amountUI:r}=wn(),s=F.useMemo(()=>!e||!r?"":S(r).multipliedBy(e).dividedBy(100).toFixed(),[r,e]),i=Yn((t==null?void 0:t.decimals)||0,s);return{amountUI:s,amount:i,percent:e,usd:nt(s,n)}},Lo=e=>{const t=F.useMemo(()=>!e.minDestAmountPerTrade||!e.totalTrades?"":S(e.minDestAmountPerTrade).multipliedBy(e.totalTrades).decimalPlaces(0).toFixed(),[e.minDestAmountPerTrade,e.totalTrades]),n=F.useMemo(()=>!e.minDestAmountPerTradeUI||!e.totalTrades?"":S(e.minDestAmountPerTradeUI).multipliedBy(e.totalTrades).toFixed(),[e.minDestAmountPerTradeUI,e.totalTrades]),r=F.useMemo(()=>!e.minDestAmountPerTradeUsd||!e.totalTrades?"":S(e.minDestAmountPerTradeUsd).multipliedBy(e.totalTrades).decimalPlaces(2).toFixed(),[e.minDestAmountPerTradeUsd,e.totalTrades]);return F.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])},No=()=>{const{config:e}=q();return F.useMemo(()=>({spender:e.repermit}),[e])},qo=()=>{const{srcToken:e,dstToken:t,account:n,marketPrice:r}=q(),{spender:s}=No(),{amount:i}=rt(),{amount:o,amountUI:d,usd:h}=Tn(),{amountPerTrade:f,amountPerTradeUI:C,amountPerTradeUsd:E,totalTrades:x}=qe(),v=pr(),{amount:O,amountUI:I,usd:k}=tr(),{amountUI:B,amount:P,usd:K}=bt(),{milliseconds:U}=Lt(),{amount:Z,amountUI:Y}=wn(),{srcAmountUsd:oe,dstAmountUsd:a}=Uo(),{amount:c,amountUI:u,percent:A,usd:m}=Ro(),y=xs(),w=Q(G=>G.state.isMarketOrder),p=Q(G=>G.state.currentTime),g=nn(),T=Co(),b=g.acceptedSrcAmount||i,D=Ee(r,(t==null?void 0:t.decimals)||0),R=F.useMemo(()=>T===V.TAKE_PROFIT_MARKET||T===V.TAKE_PROFIT_LIMIT||T===V.STOP_LOSS_LIMIT||T===V.STOP_LOSS_MARKET,[T]),L=Lo({srcToken:e,dstToken:t,account:n,orderType:T,createdAt:p,deadline:v,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:w?void 0:o,limitPriceUI:w?void 0:d,limitPriceUsd:w?void 0:h,srcAmountPerTrade:f,srcAmountPerTradeUI:C,srcAmountPerTradeUsd:E,minDestAmountPerTrade:O,minDestAmountPerTradeUI:I,minDestAmountPerTradeUsd:k,triggerPrice:P,triggerPriceUI:B,triggerPriceUsd:K});return F.useMemo(()=>({...L,feesAmountUI:u,feesAmount:c,feesUsd:m||"",feesPercentage:A,rePermitData:y,isTriggerPrice:R,isMarketOrder:w,marketPrice:r,marketPriceUi:D,spender:s}),[L,u,c,m,A,y,R,w,r,D,s])},Ko=()=>{const{supportedChains:e}=q();return F.useMemo(()=>e,[e])},Ho=60,Ps=()=>{const{refetch:e}=hr();return it({mutationFn:async t=>{var n;for(let r=0;r<Ho;r++){const s=(n=await e())==null?void 0:n.data;if(!s)throw new Error("orders not found");const i=s.find(o=>o.id===t);if((i==null?void 0:i.status)===pe.Cancelled)return;await new Promise(o=>setTimeout(o,1e3))}throw new Error("Timed out waiting for order cancellation to be confirmed")}})},Wo=()=>{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:i}=q(),o=Ps().mutateAsync,{cancelOrders:d,setCancelOrder:h,clearCancelOrder:f}=Wo(),{mutateAsync:C}=it({mutationFn:async()=>{var O,I,k;if(!t||!n||!r)throw new Error("missing required parameters");if(!e)throw new Error("order is required");const v=e.id;try{(O=s==null?void 0:s.onCancelOrderRequest)==null||O.call(s,e),h(v,{status:Se.LOADING}),fe.onCancelOrderRequest([e.version===1?e.id.toString():e.hash],e.version);const B=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?js:$s});if(!B)throw new Error("failed to cancel order");return fe.onCancelOrderSuccess(B),await o(e.id),(I=s==null?void 0:s.onCancelOrderSuccess)==null||I.call(s,{order:e,txHash:B,explorerUrl:Rt(B,i)}),h(v,{status:Se.SUCCESS,txHash:B}),B}catch(B){console.error("cancel order error",B),(k=s==null?void 0:s.onCancelOrderFailed)==null||k.call(s,B),Vn(B)?f(v):(h(v,{status:Se.FAILED,error:B.message}),fe.onCancelOrderError(B))}}}),E=F.useMemo(()=>{const v=d[(e==null?void 0:e.id)||""];return{isLoading:(v==null?void 0:v.status)===Se.LOADING,isSuccess:(v==null?void 0:v.status)===Se.SUCCESS,isError:(v==null?void 0:v.status)===Se.FAILED,error:v==null?void 0:v.error,txHash:v==null?void 0:v.txHash}},[d,e==null?void 0:e.id]),x=F.useCallback(async()=>C(),[C]);return F.useMemo(()=>({cancelOrder:x,...E}),[x,E])},Ds=F.createContext(null),$o=({children:e})=>{const t=xa(),n=Pa(),r=va(),s=_a(),i=Ba(),o=bn(),d=Ua(),h=Ra(),f=ts(),C=Bo(),E=qo(),x=Po(),v=_o(),O=Ko(),I=Ps(),{module:k}=q(),B={tradesAmountPanel:t,durationPanel:n,fillDelayPanel:r,limitPricePanel:s,triggerPricePanel:i,pricePanel:o,dstTokenPanel:d,disclaimerPanel:h,inputError:f,submitOrderButton:C,derivedFormData:E,orderHistoryPanel:x,orderExecutionPanel:v,supportedChains:O,refetchUntilStatusSynced:I,module:k};return H.jsx(Ds.Provider,{value:B,children:e})},jo=()=>{const e=F.useContext(Ds);if(e===null)throw new Error("useSpot must be used within SpotProvider");return e},zo=F.createContext(null),mr={didCatch:!1,error:null};class Vo extends F.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=mr}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var n,r,s=arguments.length,i=new Array(s),o=0;o<s;o++)i[o]=arguments[o];(n=(r=this.props).onReset)===null||n===void 0||n.call(r,{args:i,reason:"imperative-api"}),this.setState(mr)}}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&&Go(t.resetKeys,s)){var i,o;(i=(o=this.props).onReset)===null||i===void 0||i.call(o,{next:s,prev:t.resetKeys,reason:"keys"}),this.setState(mr)}}render(){const{children:t,fallbackRender:n,FallbackComponent:r,fallback:s}=this.props,{didCatch:i,error:o}=this.state;let d=t;if(i){const h={error:o,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")d=n(h);else if(r)d=F.createElement(r,h);else if(s!==void 0)d=s;else throw o}return F.createElement(zo.Provider,{value:{didCatch:i,error:o,resetErrorBoundary:this.resetErrorBoundary}},d)}}function Go(){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 Xo=()=>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 Zo({children:e}){return H.jsx(Vo,{FallbackComponent:Xo,onError:t=>fe.onCrash(t),children:H.jsx(H.Fragment,{children:e})})}const Os=F.createContext(null),Yo=new oo({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),Jo=e=>{var r,s,i;const t=Q(o=>o.updateState),n=Q(o=>o.state.isMarketOrder);return F.useEffect(()=>{const o=setInterval(()=>{t({currentTime:Date.now()})},6e4);return()=>clearInterval(o)},[t]),F.useEffect(()=>{var d,h,f,C,E,x,v,O,I,k,B,P,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:(C=(f=e.overrides)==null?void 0:f.state)==null?void 0:C.chunks,typedFillDelay:(x=(E=e.overrides)==null?void 0:E.state)==null?void 0:x.fillDelay,typedDuration:(O=(v=e.overrides)==null?void 0:v.state)==null?void 0:O.duration,typedLimitPrice:(k=(I=e.overrides)==null?void 0:I.state)==null?void 0:k.limitPrice,typedTriggerPrice:(P=(B=e.overrides)==null?void 0:B.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]),F.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})},[(s=e.srcToken)==null?void 0:s.address,(i=e.dstToken)==null?void 0:i.address]),F.useEffect(()=>{e.module===z.LIMIT&&t({isMarketOrder:!1})},[e.module]),F.useEffect(()=>{n&&t({isInvertedTrade:!1})},[n]),F.useEffect(()=>{t({typedChunks:void 0})},[e.typedInputAmount]),null},ec=({marketReferencePrice:e,srcToken:t,dstToken:n,chainId:r,typedInputAmount:s})=>F.useMemo(()=>{if(Xn(t,n,r)||Zn(t,n,r))return{isLoading:!1,noLiquidity:!1,value:Et(s||"0",t==null?void 0:t.decimals)};if(S(e.value||0).isZero()||S(s||0).isZero())return e;const i=S(e.value||0).dividedBy(s||0).decimalPlaces(0).toFixed();return{...e,value:i}},[e,s,t,n,r]),tc=e=>{const t=nn(),n=F.useMemo(()=>Ur(e.partner),[e.partner]),r=F.useMemo(()=>{const d=n[0];return e.chainId&&n.includes(e.chainId)?e.chainId:d},[e.chainId,n]),s=F.useMemo(()=>Hn(e.partner,r),[e.partner,r]),i=ec(e),o=F.useMemo(()=>qr(e.minChunkSizeUsd),[e.minChunkSizeUsd]);return F.useEffect(()=>{fe.init(s,o,r)},[s,r,o]),H.jsxs(Os.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: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(Jo,{...e}),H.jsx($o,{children:H.jsx(Zo,{children:e.children})})]})},nc=e=>H.jsx(co,{client:Yo,children:H.jsx(tc,{...e})}),q=()=>{const e=F.useContext(Os);if(e===null)throw new Error("useSpotContext must be used within SpotProvider");return e},rc=(e,t,n)=>{const r=En();return F.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:Kn(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])},sc=(e,t,n)=>{const{config:r}=q(),s=So(t,n,e),i=vo(t,n,e),o=Fo(t,n,e),d=F.useMemo(()=>e?e.version===2?e.fillDelay:r.twapConfig?qn(e,r.twapConfig):0:0,[e,r]),h=rc(e==null?void 0:e.fills,t,n)??[];return F.useMemo(()=>{if(e!=null&&e.id)return{original:e,fills:h,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(i,n==null?void 0:n.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,n==null?void 0:n.decimals),progress:e.progress,executionPrice:Et(o,n==null?void 0:n.decimals),executionPriceUI:o,version:e.version}},[e,h,t,n,d,s,i,o])};Hi(fa.version),M.DISCLAIMER_URL=oi,M.Disclaimer=Jt,M.InputErrors=me,M.Module=z,M.ORBS_LOGO=ii,M.ORBS_SLTP_FAQ_URL=si,M.ORBS_TWAP_FAQ_URL=ri,M.ORBS_WEBSITE_URL=ai,M.OrderFilter=Fr,M.OrderStatus=pe,M.OrderType=V,M.Partners=Be,M.SPOT_VERSION=fn,M.SpotProvider=nc,M.Steps=tt,M.SwapStatus=Se,M.TimeUnit=Pe,M.buildRePermitOrderData=Kr,M.ensureWrappedToken=Zr,M.eqIgnoreCase=yt,M.getConfig=Hn,M.getExplorerUrl=Rt,M.getMinChunkSizeUsd=qr,M.getNetwork=At,M.getOrderExecutionRate=Kn,M.getOrderFillDelayMillis=qn,M.getOrderLimitPriceRate=Rr,M.getOrderType=Aa,M.getPartnerChains=Ur,M.getPartners=Nr,M.getTriggerPriceRate=Lr,M.isNativeAddress=Ut,M.isTxRejected=Vn,M.millisToDays=Gn,M.millisToMinutes=An,M.networks=ye,M.parseError=ga,M.shouldUnwrapOnly=Zn,M.shouldWrapOnly=Xn,M.submitOrder=Qr,M.toAmountUi=Ee,M.toAmountWei=Et,M.useAmountUi=en,M.useCancelOrder=Qo,M.useDerivedHistoryOrder=sc,M.useExplorerLink=Ea,M.useNetwork=En,M.useSignOrder=Ss,M.useSpot=jo,M.useSubmitOrder=Fs,M.useSwapExecution=nn,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})}));
64
+ `,extractResults:E=>{var T;return(((T=E.data)==null?void 0:T.orderFilleds)||[]).map(x=>({...x,timestamp:new Date(x.timestamp).getTime()}))}})};class da extends Error{constructor(){super("No graph endpoint found"),this.name="NoGraphEndpointError"}}const la=async({chainId:e,signal:t,page:n,limit:r,filters:s})=>{try{const i=await oa({chainId:e,signal:t,page:n,limit:r,filters:s}),[o,u]=await Promise.all([ua({chainId:e,orders:i,signal:t}),ca({chainId:e,orders:i,signal:t})]),f=i.map(C=>{const E=o==null?void 0:o.filter(T=>T.TWAP_id===Number(C.Contract_id)&&gt(T.exchange,C.exchange)&&gt(T.twapAddress,C.twapAddress));return ia(C,e,E,fa(C,E||[],u))}).sort((C,E)=>E.createdAt-C.createdAt),h=new Set;return f.filter(C=>h.has(C.id)?!1:(h.add(C.id),!0))}catch{return[]}},fa=(e,t,n)=>{var u;const r=(u=n==null?void 0:n.find(f=>f.twapId===e.Contract_id.toString()&&gt(f.twapAddress,e.twapAddress)))==null?void 0:u.status,i=$r(t).reduce((f,h)=>f.plus(h.inAmount),new v(0)).toFixed(),o=Vr(e.ask_srcAmount,i);return ha(o,e.ask_deadline*1e3,r)},Vr=(e,t)=>{if(!t||!e)return 0;const n=v(t).dividedBy(e).toNumber();return n>=.99?100:n<=0?0:Number((n*100).toFixed(2))},ha=(e,t,n)=>e===100?pe.Completed:n==="CANCELLED"?pe.Cancelled:n==="COMPLETED"?pe.Completed:t>Date.now()?pe.Open:pe.Expired,pa=async({signal:e,page:t,chainId:n,limit:r,config:s,account:i,isDev:o=!1})=>(await Promise.all([s?la({chainId:n,signal:e,page:t,limit:r,filters:{accounts:[i],configs:s.twapConfig?[s.twapConfig]:[]}}):Promise.resolve([]),ra({chainId:n,signal:e,account:i,exchange:s==null?void 0:s.adapter,partner:s==null?void 0:s.partner,isDev:o})]).then(([h,C])=>[...h,...C])).sort((h,C)=>C.createdAt-h.createdAt),ma={version:"1.1.30"},Gr=e=>{let t;const n=new Set,r=(h,C)=>{const E=typeof h=="function"?h(t):h;if(!Object.is(E,t)){const T=t;t=C??(typeof E!="object"||E===null)?E:Object.assign({},t,E),n.forEach(x=>x(t,T))}},s=()=>t,u={setState:r,getState:s,getInitialState:()=>f,subscribe:h=>(n.add(h),()=>n.delete(h))},f=t=e(r,s,u);return u},ya=(e=>e?Gr(e):Gr),ga=e=>e;function Aa(e,t=ga){const n=F.useSyncExternalStore(e.subscribe,F.useCallback(()=>t(e.getState()),[e,t]),F.useCallback(()=>t(e.getInitialState()),[e,t]));return F.useDebugValue(n),n}const Xr=e=>{const t=ya(e),n=r=>Aa(t,r);return Object.assign(n,t),n},Ea=(e=>e?Xr(e):Xr),gn={},Zr={currentTime:Date.now(),cancelOrders:{},swapExecutions:[gn],swapExecutionIndex:0},Q=Ea((e,t)=>({state:Zr,updateState:n=>e(r=>({state:{...r.state,...n}})),updateSwapExecutionAtIndex:(n,r)=>e(s=>{const i=[...s.state.swapExecutions];return i[n]={...i[n]??gn,...r},{state:{...s.state,swapExecutions:i}}}),resetSwapExecutionAtIndex:()=>e(n=>{const r=[...n.state.swapExecutions];return r[n.state.swapExecutionIndex]=gn,{state:{...n.state,swapExecutions:r}}}),resetState:()=>{const n=t().state;e({state:{...Zr,currentTime:Date.now(),isMarketOrder:n.isMarketOrder,swapExecutions:[...n.swapExecutions,gn],swapExecutionIndex:n.swapExecutionIndex+1}})}}));var xe=(e=>(e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILED=3]="FAILED",e))(xe||{}),en=(e=>(e.TRIGGER_MARKET_PRICE="triggerMarketPriceDisclaimer",e.MARKET_PRICE="marketOrderDisclaimer",e.LIMIT_PRICE="limitOrderDisclaimer",e))(en||{}),nt=(e=>(e.WRAP="wrap",e.APPROVE="approve",e.CREATE="create",e))(nt||{});const rt=(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(n){return console.error(n),""}},ba=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}},Gn=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"))},Yr=(e,t)=>{const n=Et(t);return n&&Rt(e.address)?n.wToken:e};function Xn(e){return e?e/864e5:0}function An(e){return e?e/6e4:0}const Ta=(e,t)=>e?X.TWAP_MARKET:t===1?X.LIMIT:X.TWAP_LIMIT,Zn=(e,t,n)=>{const r=Et(n);return Rt((e==null?void 0:e.address)||"")&&gt((t==null?void 0:t.address)||"",(r==null?void 0:r.wToken.address)||"")},Yn=(e,t,n)=>{const r=Et(n);return gt((e==null?void 0:e.address)||"",(r==null?void 0:r.wToken.address)||"")&&Rt((t==null?void 0:t.address)||"")},Lt=(e,t)=>{if(!t)return"";const n=Et(t);return`${n==null?void 0:n.explorer}/tx/${e}`},Jn=(e,t)=>F.useMemo(()=>rt(t,e),[e,t]),bt=(e,t)=>F.useMemo(()=>Ee(t,e),[e,t]),En=()=>{const{chainId:e}=q();return F.useMemo(()=>Et(e),[e])},wa=e=>{const t=En();return F.useMemo(()=>{if(!(!e||!t))return Lt(e,t.id)},[e,t])},qe=(e,t)=>F.useMemo(()=>!e||!t||v(e||"0").isZero()||v(t||"0").isZero()?"":v(e||"0").times(t).toFixed(),[e,t]),Ca=()=>{const{srcToken:e,dstToken:t,chainId:n}=q();return F.useMemo(()=>Zn(e,t,n),[e,t,n])},Sa=()=>{const{srcToken:e,dstToken:t,chainId:n}=q();return F.useMemo(()=>Yn(e,t,n),[e,t,n])},xa=()=>{const e=Ca(),t=Sa();return e||t},st=()=>{const{srcToken:e,typedInputAmount:t}=q();return{amount:Jn(e==null?void 0:e.decimals,t),amountUI:t,error:v(t||0).isZero()?"enterAmount":void 0}},va=(e,t)=>{const{module:n,srcUsd1Token:r,marketPrice:s,minChunkSizeUsd:i,typedInputAmount:o}=q();return F.useMemo(()=>{if(v(o||"0").isZero()||!s||v(r||"0").isZero())return;if(!e)return{type:me.MIN_CHUNKS,value:1,args:{minChunks:"1"}};const{isError:u}=qi(e,t,n);if(u)return{type:me.MAX_CHUNKS,value:t,args:{maxChunks:`${t}`}};const{isError:f,value:h}=Ni(o||"",r||"",i||0);if(f)return{type:me.MIN_TRADE_SIZE,value:h,args:{minTradeSize:`${h}`}}},[e,t,n,o,r,i,s])},Ke=()=>{const{srcToken:e,srcUsd1Token:t,module:n,minChunkSizeUsd:r}=q(),s=Q(O=>O.state.typedChunks),i=Q(O=>O.updateState),{amount:o,amountUI:u}=st(),f=F.useMemo(()=>Fi(u||"",t||"",r||0),[u,t,r]),h=F.useMemo(()=>vi(f,n,s),[f,s,n]),C=F.useCallback(O=>i({typedChunks:O}),[i]),E=F.useMemo(()=>Oi(o||"",h),[o,h]),T=bt(e==null?void 0:e.decimals,E),x=F.useMemo(()=>t?v(T||"0").times(t||0).toString():"0",[T,t]);return{totalTrades:h,maxTrades:f,amountPerTradeUI:T,amountPerTrade:E,amountPerTradeUsd:x,onChange:C,error:va(h,f)}},Fa=()=>{const{srcToken:e,dstToken:t}=q(),{onChange:n,totalTrades:r,amountPerTradeUsd:s,amountPerTradeUI:i,error:o,maxTrades:u,amountPerTrade:f}=Ke();return{error:o,maxTrades:u,totalTrades:r,amountPerTradeUI:i,amountPerTrade:f,onChange:n,amountPerTradeUsd:s,fromToken:e,toToken:t}},Jr=e=>{const t=Xn(e);if(t>=1)return`${t.toFixed(t%1?1:0)} ${t===1?"day":"days"}`;const n=An(e)/60;if(n>=1)return`${n.toFixed(n%1?1:0)} ${n===1?"hour":"hours"}`;const r=An(e);return`${r.toFixed(r%1?1:0)} ${r===1?"minute":"minutes"}`},Pa=e=>{const{totalTrades:t}=Ke(),{marketPrice:n,typedInputAmount:r}=q(),s=F.useMemo(()=>{const{isError:o,value:u}=Li(e);if(!(!o||v(r||"0").isZero()||!n))return{type:me.MIN_FILL_DELAY,value:u,args:{fillDelay:Jr(u)}}},[e,r,n]),i=F.useMemo(()=>{const{isError:o,value:u}=Ii(e,t);if(!(!o||v(r||"0").isZero()||!n))return{type:me.MAX_FILL_DELAY,value:u,args:{fillDelay:Jr(u)}}},[e,r,n,t]);return s||i},Nt=()=>{const{callbacks:e}=q(),t=Q(i=>i.state.typedFillDelay),n=Q(i=>i.updateState),r=F.useMemo(()=>t||Un,[t]),s=Pa(r);return{fillDelay:r,onChange:F.useCallback(i=>{var o;n({typedFillDelay:i}),(o=e==null?void 0:e.onFillDelayChange)==null||o.call(e,i)},[n,e]),error:s,milliseconds:r.unit*r.value}},Da=()=>{const{onChange:e,fillDelay:t,error:n}=Nt(),r=F.useCallback(i=>e({unit:t.unit,value:Number(i)}),[e,t]),s=F.useCallback(i=>e({unit:i,value:t.value}),[e,t]);return{onInputChange:r,onUnitSelect:s,onChange:e,milliseconds:t.unit*t.value,fillDelay:t,error:n}},Oa=e=>{const{module:t,marketPrice:n}=q();return F.useMemo(()=>{const r=Ui(t,e),s=Ri(e);if(n){if(r.isError)return{type:me.MAX_ORDER_DURATION,value:r.value,args:{duration:`${Math.floor(Xn(r.value)).toFixed(0)} days`}};if(s.isError)return{type:me.MIN_ORDER_DURATION,value:s.value,args:{duration:`${Math.floor(An(s.value)).toFixed(0)} minutes`}}}},[e,t,n])},er=()=>{const{module:e,callbacks:t}=q(),n=Q(f=>f.state.typedDuration),r=Q(f=>f.updateState),s=Ke().totalTrades,i=Nt().fillDelay,o=F.useMemo(()=>xi(e,s,i,n),[s,i,n,e]),u=Oa(o);return{duration:o,setDuration:F.useCallback(f=>{var h;r({typedDuration:f}),(h=t==null?void 0:t.onDurationChange)==null||h.call(t,f)},[r,t]),error:u}},Ia=()=>{const{duration:e,setDuration:t,error:n}=er(),r=F.useCallback(i=>{t({unit:e.unit,value:Number(i)})},[t,e]),s=F.useCallback(i=>{t({unit:i,value:e.value})},[t,e]);return{duration:e,onChange:t,milliseconds:e.unit*e.value,onInputChange:r,onUnitSelect:s,error:n}},Ma=()=>{const{module:e}=q();return F.useMemo(()=>e===j.STOP_LOSS?li:fi,[e])},tr=()=>{const{module:e}=q(),t=Q(n=>n.state.isMarketOrder);return F.useMemo(()=>e!==j.STOP_LOSS&&e!==j.TAKE_PROFIT||t?void 0:e===j.STOP_LOSS?hi:pi,[e,t])},es=e=>{if(e===void 0||e==="")return e;const t=v(e);return t.isNaN()||t.isZero()?"0":v(1).div(t).toFixed()},bn=()=>{const{srcToken:e,dstToken:t}=q(),n=Q(f=>f.updateState),r=Q(f=>f.state.isInvertedTrade),s=Q(f=>f.state.typedTriggerPrice),i=Q(f=>f.state.typedLimitPrice),o=Q(f=>f.state.isMarketOrder);return{onInvert:F.useCallback(()=>{n({isInvertedTrade:!r,...s!==void 0?{typedTriggerPrice:es(s)}:{},...i!==void 0?{typedLimitPrice:es(i)}:{}})},[n,r,s,i]),isInverted:r,fromToken:r?t:e,toToken:r?e:t,isMarketPrice:o}},Tn=e=>e?v(e).isNaN()?"":e:"",ts=({amount:e,typedValue:t,amountDecimals:n=18,invertedAmountDecimals:r=18,amountUsd:s,invertedAmountUsd:i,isInverted:o})=>{const u=F.useMemo(()=>{if(t!==void 0)return Tn(t);const C=Ee(e,n);return!C||v(C||"0").isZero()?"":o?v(1).div(C).toFixed():C},[e,n,o,t]),f=F.useMemo(()=>u?Tn(o?rt(u,r):e):"",[e,u,r,o]),h=qe(u||"0",o?i:s);return{amount:f,amountUI:u,usd:Tn(h)}},ns=({typedValue:e,tokenDecimals:t=18,initialPrice:n="0",percentage:r,setValue:s,setPercentage:i})=>{const{isInverted:o}=bn(),u=F.useMemo(()=>v((()=>{if(e!==void 0){const T=o?v(e).isZero()?v(0):v(1).div(e):v(e);return rt(T.toFixed(),t)}if(r!==void 0&&v(n||"0").gt(0)&&!v(n||"0").isNaN()){const T=v(n||"0"),x=v(r||0).div(100);return T.plus(T.multipliedBy(x)).decimalPlaces(0).toFixed()}return v(n).gt(0)?n:""})()).decimalPlaces(0).toFixed(),[e,r,t,n,o]),f=F.useCallback(E=>{s(E),i(null)},[s,i]),h=F.useCallback(E=>{s(void 0),i(E)},[s,i]),C=F.useMemo(()=>{if(!n||v(n).isZero())return"";if(r!=null)return r;if(u){const E=v(n),x=v(u).minus(E).div(E).multipliedBy(100).decimalPlaces(2).toString();return v(x||"0").isZero()?"":x}return""},[u,n,r]);return{amount:v(u).isNaN()?"":u,typedValue:e,selectedPercentage:C,onChange:f,onPercentageChange:h,isTypedValue:e!==void 0}},ka=(e="")=>{const{module:t,marketPrice:n,typedInputAmount:r}=q();return F.useMemo(()=>{if(v(r||"0").isZero()||!n||t!==j.STOP_LOSS&&t!==j.TAKE_PROFIT)return;const s=Mi(n||"",e||"",t);if(s!=null&&s.isError)return{type:me.STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE,value:s.value};const i=ki(n||"",e||"",t);if(i!=null&&i.isError)return{type:me.TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE,value:i.value};if(!e||v(e||0).isZero())return{type:me.EMPTY_TRIGGER_PRICE,value:e}},[n,e,t,r])},_a=e=>{const{srcToken:t,dstToken:n,module:r,dstUsd1Token:s}=q(),i=Ke().amountPerTrade,o=Q(h=>h.state.isMarketOrder),u=F.useMemo(()=>Si(r,i,e,(t==null?void 0:t.decimals)||0),[e,i,o,t==null?void 0:t.decimals,r]),f=bt((n==null?void 0:n.decimals)||0,u);return{amount:u,amountUI:f,usd:qe(f,s)}},Tt=()=>{const{dstToken:e,dstUsd1Token:t,marketPrice:n,module:r,callbacks:s}=q(),i=Q(k=>k.updateState),o=Ma(),u=Q(k=>k.state.triggerPricePercent),f=u===void 0?o:u,h=r===j.STOP_LOSS||r===j.TAKE_PROFIT,C=ns({typedValue:Q(k=>k.state.typedTriggerPrice),percentage:f,tokenDecimals:(e==null?void 0:e.decimals)||18,initialPrice:h?n:void 0,setValue:F.useCallback(k=>{var P;i({typedTriggerPrice:k}),(P=s==null?void 0:s.onTriggerPriceChange)==null||P.call(s,k||"")},[i,s]),setPercentage:F.useCallback(k=>{var P;i({triggerPricePercent:k}),(P=s==null?void 0:s.onTriggerPricePercentChange)==null||P.call(s,k||"")},[i,s])}),E=ka(C.amount),T=bt((e==null?void 0:e.decimals)||18,C.amount),x=qe(T,t),{amount:O,amountUI:M,usd:B}=_a(C.amount);return F.useMemo(()=>({...C,amountUI:v(T).isNaN()?"":T,usd:v(x).isNaN()?"":x,error:E,pricePerChunk:O,pricePerChunkUI:M,pricePerChunkUsd:B}),[C,T,x,E,O,M,B])},Ba=e=>{const{module:t,marketPrice:n,typedInputAmount:r}=q(),{amount:s}=Tt(),i=Q(o=>o.state.isMarketOrder);return F.useMemo(()=>{if(v(r||"0").isZero()||!s||!n)return;const o=_i(s,e,i,t),u=Bi(s,e,i,t);if(o!=null&&o.isError)return{type:me.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,value:o.value};if(u!=null&&u.isError)return{type:me.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,value:u.value};if(e&&v(e||0).isZero())return{type:me.MISSING_LIMIT_PRICE,value:e||""}},[e,s,t,i,r,n])},wn=()=>{const{dstToken:e,dstUsd1Token:t,marketPrice:n,callbacks:r}=q(),s=Q(T=>T.updateState),i=tr(),o=Q(T=>T.state.limitPricePercent),u=o===void 0?i:o,f=ns({typedValue:Q(T=>T.state.typedLimitPrice),percentage:u,tokenDecimals:(e==null?void 0:e.decimals)||18,initialPrice:n,setValue:F.useCallback(T=>{var x;s({typedLimitPrice:T}),(x=r==null?void 0:r.onLimitPriceChange)==null||x.call(r,T||"")},[s,r]),setPercentage:F.useCallback(T=>{var x;s({limitPricePercent:T}),(x=r==null?void 0:r.onLimitPricePercentChange)==null||x.call(r,T||"")},[s,r])}),h=Ba(f.amount),C=bt((e==null?void 0:e.decimals)||18,f.amount),E=qe(C,t);return F.useMemo(()=>({...f,amountUI:v(C).isNaN()?"":C,usd:v(E).isNaN()?"":E,error:h}),[f,C,E,h])},Ua=()=>{const{module:e}=q(),t=Q(u=>u.updateState),n=Q(u=>u.state.isMarketOrder),r=tr(),s=Q(u=>u.state.triggerPricePercent)||0,i=e===j.LIMIT,o=F.useCallback(()=>{!n&&e===j.STOP_LOSS&&t({limitPricePercent:r}),t({isMarketOrder:!n})},[t,s,e,n,r]);return{isLimitPrice:!n,toggleLimitPrice:o,hide:i}},Ra=()=>{const{module:e,marketPriceLoading:t,srcToken:n,dstToken:r,srcUsd1Token:s,dstUsd1Token:i}=q(),{amount:o,typedValue:u,onChange:f,onPercentageChange:h,selectedPercentage:C,error:E,isTypedValue:T}=wn(),x=Q(G=>G.updateState),O=tr(),{isLimitPrice:M,toggleLimitPrice:B}=Ua(),{fromToken:k,toToken:P,isInverted:K}=bn(),U=ts({amount:o,typedValue:u,amountDecimals:(r==null?void 0:r.decimals)||18,invertedAmountDecimals:(n==null?void 0:n.decimals)||18,amountUsd:i,invertedAmountUsd:s,isInverted:K}),V=F.useCallback(()=>{x({typedLimitPrice:void 0}),x({limitPricePercent:O})},[x,e,O]);return{price:U.amount,priceUI:U.amountUI,error:E,onInputChange:f,onPercentageChange:h,onReset:V,usd:U.usd,srcToken:n,dstToken:r,invertedSrcToken:k,invertedDstToken:P,percentage:C,isLoading:t,isLimitPrice:M,toggleLimitPrice:B,isTypedValue:T}},La=()=>{const{marketPrice:e,marketPriceLoading:t,srcToken:n,dstToken:r,srcUsd1Token:s,dstUsd1Token:i}=q(),{amount:o,typedValue:u,onChange:f,onPercentageChange:h,selectedPercentage:C,error:E,pricePerChunk:T,pricePerChunkUI:x,pricePerChunkUsd:O,isTypedValue:M}=Tt(),B=Q(G=>G.updateState),{fromToken:k,toToken:P,isInverted:K}=bn(),U=ts({amount:o,typedValue:u,amountDecimals:(r==null?void 0:r.decimals)||18,invertedAmountDecimals:(n==null?void 0:n.decimals)||18,amountUsd:i,invertedAmountUsd:s,isInverted:K}),V=F.useCallback(()=>{B({triggerPricePercent:void 0,typedTriggerPrice:void 0})},[B]);return{price:U.amount,priceUI:U.amountUI,amountPerChunk:T,amountPerChunkUI:x,amountPerChunkUsd:O,error:E,onInputChange:f,onPercentageChange:h,percentage:C,onReset:V,usd:U.usd,srcToken:n,dstToken:r,invertedSrcToken:k,invertedDstToken:P,isLoading:t||!e,isTypedValue:M}},rs=()=>{const{module:e,marketPrice:t}=q(),n=wn().amount,r=Tt().amount,s=Q(i=>i.state.isMarketOrder);return e===j.LIMIT||!s?n||"":e===j.STOP_LOSS||e===j.TAKE_PROFIT?r||"":t||""},Cn=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:n}=q(),r=rs(),s=st().amount,i=F.useMemo(()=>wi(s||"",r,(e==null?void 0:e.decimals)||0),[s,r,e==null?void 0:e.decimals]),o=bt(t==null?void 0:t.decimals,i);return{amount:i,amountUI:o,usd:qe(o,n)}},nr=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:n}=q(),r=rs(),s=Ke().amountPerTrade,i=Q(f=>f.state.isMarketOrder),o=F.useMemo(()=>Ci(s,r,!!i,(e==null?void 0:e.decimals)||0),[s,r,i,e==null?void 0:e.decimals]),u=bt(t==null?void 0:t.decimals,o);return{amount:o,amountUI:u,usd:qe(u,n)}},Na=()=>{const{typedInputAmount:e,marketPriceLoading:t,dstToken:n}=q(),{amountUI:r,usd:s}=Cn(),o=xa()?e:r,u=Jn(n==null?void 0:n.decimals,o);return{value:o,valueWei:u,isLoading:t,usd:s}},qa=()=>{const e=Q(s=>s.state.isMarketOrder),{module:t}=q(),n=F.useMemo(()=>{if(e&&t===j.STOP_LOSS)return en.TRIGGER_MARKET_PRICE},[e,t]),r=F.useMemo(()=>{if(!(t!==j.LIMIT&&t!==j.TWAP))return e?en.MARKET_PRICE:en.LIMIT_PRICE},[e,t]);return n||r},Ka=()=>{const{minChunkSizeUsd:e,typedInputAmount:t,srcUsd1Token:n}=q(),r=qe(t,n);return F.useMemo(()=>v(e).gt(v(r||"0"))?{type:me.MIN_TRADE_SIZE_ERROR,value:e}:void 0,[e,r])};function ss(){const{marketPrice:e,marketPriceLoading:t,typedInputAmount:n,srcUsd1Token:r,srcBalance:s,chainId:i}=q(),{error:o}=Tt(),{error:u}=wn(),{error:f}=Ke(),{error:h}=Nt(),{error:C}=er(),E=Ka(),T=st().amount,x=F.useMemo(()=>{if(s&&v(T).gt(s))return{type:me.INSUFFICIENT_BALANCE,value:s||""}},[s,T,i]);return F.useMemo(()=>Hi({marketPrice:e,typedInputAmount:n,srcUsd1Token:r,marketPriceLoading:t,triggerPriceError:o,limitPriceError:u,tradesError:f,fillDelayError:h,durationError:C,balanceError:x,minTradeSizeError:E}),[e,t,n,o,u,f,h,C,x,r,E])}var qt=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(){}},Ha={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Wa=(_s=class{constructor(){N(this,He,Ha);N(this,xt,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&l(this,xt)&&e!==l(this,He)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:l(this,He),provider:e}),_(this,He,e),process.env.NODE_ENV!=="production"&&_(this,xt,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&_(this,xt,!0),l(this,He).setTimeout(e,t)}clearTimeout(e){l(this,He).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&_(this,xt,!0),l(this,He).setInterval(e,t)}clearInterval(e){l(this,He).clearInterval(e)}},He=new WeakMap,xt=new WeakMap,_s),wt=new Wa;function Qa(e){setTimeout(e,0)}var Ct=typeof window>"u"||"Deno"in globalThis;function be(){}function za(e,t){return typeof e=="function"?e(t):e}function rr(e){return typeof e=="number"&&e>=0&&e!==1/0}function is(e,t){return Math.max(e+(t||0)-Date.now(),0)}function it(e,t){return typeof e=="function"?e(t):e}function Me(e,t){return typeof e=="function"?e(t):e}function as(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:i,queryKey:o,stale:u}=e;if(o){if(r){if(t.queryHash!==sr(o,t.options))return!1}else if(!tn(t.queryKey,o))return!1}if(n!=="all"){const f=t.isActive();if(n==="active"&&!f||n==="inactive"&&f)return!1}return!(typeof u=="boolean"&&t.isStale()!==u||s&&s!==t.state.fetchStatus||i&&!i(t))}function os(e,t){const{exact:n,status:r,predicate:s,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(St(t.options.mutationKey)!==St(i))return!1}else if(!tn(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function sr(e,t){return((t==null?void 0:t.queryKeyHashFn)||St)(e)}function St(e){return JSON.stringify(e,(t,n)=>ar(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 $a=Object.prototype.hasOwnProperty;function ir(e,t){if(e===t)return e;const n=cs(e)&&cs(t);if(!n&&!(ar(e)&&ar(t)))return t;const s=(n?e:Object.keys(e)).length,i=n?t:Object.keys(t),o=i.length,u=n?new Array(o):{};let f=0;for(let h=0;h<o;h++){const C=n?h:i[h],E=e[C],T=t[C];if(E===T){u[C]=E,(n?h<s:$a.call(e,C))&&f++;continue}if(E===null||T===null||typeof E!="object"||typeof T!="object"){u[C]=T;continue}const x=ir(E,T);u[C]=x,x===E&&f++}return s===o&&f===s?e:u}function Sn(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 cs(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ar(e){if(!us(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!us(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function us(e){return Object.prototype.toString.call(e)==="[object Object]"}function ja(e){return new Promise(t=>{wt.setTimeout(t,e)})}function or(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 ir(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 ir(e,t)}return t}function Va(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Ga(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var xn=Symbol();function ds(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===xn&&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===xn?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function ls(e,t){return typeof e=="function"?e(...t):!!e}var Xa=(Bs=class extends qt{constructor(){super();N(this,vt);N(this,ot);N(this,Kt);_(this,Kt,t=>{if(!Ct&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){l(this,ot)||this.setEventListener(l(this,Kt))}onUnsubscribe(){var t;this.hasListeners()||((t=l(this,ot))==null||t.call(this),_(this,ot,void 0))}setEventListener(t){var n;_(this,Kt,t),(n=l(this,ot))==null||n.call(this),_(this,ot,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){l(this,vt)!==t&&(_(this,vt,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(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,ot=new WeakMap,Kt=new WeakMap,Bs),cr=new Xa;function ur(){let e,t;const n=new Promise((s,i)=>{e=s,t=i});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 Za=Qa;function Ya(){let e=[],t=0,n=u=>{u()},r=u=>{u()},s=Za;const i=u=>{t?e.push(u):s(()=>{n(u)})},o=()=>{const u=e;e=[],u.length&&s(()=>{r(()=>{u.forEach(f=>{n(f)})})})};return{batch:u=>{let f;t++;try{f=u()}finally{t--,t||o()}return f},batchCalls:u=>(...f)=>{i(()=>{u(...f)})},schedule:i,setNotifyFunction:u=>{n=u},setBatchNotifyFunction:u=>{r=u},setScheduler:u=>{s=u}}}var ue=Ya(),Ja=(Us=class extends qt{constructor(){super();N(this,Ht,!0);N(this,ct);N(this,Wt);_(this,Wt,t=>{if(!Ct&&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,ct)||this.setEventListener(l(this,Wt))}onUnsubscribe(){var t;this.hasListeners()||((t=l(this,ct))==null||t.call(this),_(this,ct,void 0))}setEventListener(t){var n;_(this,Wt,t),(n=l(this,ct))==null||n.call(this),_(this,ct,t(this.setOnline.bind(this)))}setOnline(t){l(this,Ht)!==t&&(_(this,Ht,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return l(this,Ht)}},Ht=new WeakMap,ct=new WeakMap,Wt=new WeakMap,Us),vn=new Ja;function eo(e){return Math.min(1e3*2**e,3e4)}function fs(e){return(e??"online")==="online"?vn.isOnline():!0}var dr=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function hs(e){let t=!1,n=0,r;const s=ur(),i=()=>s.status!=="pending",o=M=>{var B;if(!i()){const k=new dr(M);T(k),(B=e.onCancel)==null||B.call(e,k)}},u=()=>{t=!0},f=()=>{t=!1},h=()=>cr.isFocused()&&(e.networkMode==="always"||vn.isOnline())&&e.canRun(),C=()=>fs(e.networkMode)&&e.canRun(),E=M=>{i()||(r==null||r(),s.resolve(M))},T=M=>{i()||(r==null||r(),s.reject(M))},x=()=>new Promise(M=>{var B;r=k=>{(i()||h())&&M(k)},(B=e.onPause)==null||B.call(e)}).then(()=>{var M;r=void 0,i()||(M=e.onContinue)==null||M.call(e)}),O=()=>{if(i())return;let M;const B=n===0?e.initialPromise:void 0;try{M=B??e.fn()}catch(k){M=Promise.reject(k)}Promise.resolve(M).then(E).catch(k=>{var G;if(i())return;const P=e.retry??(Ct?0:3),K=e.retryDelay??eo,U=typeof K=="function"?K(n,k):K,V=P===!0||typeof P=="number"&&n<P||typeof P=="function"&&P(n,k);if(t||!V){T(k);return}n++,(G=e.onFail)==null||G.call(e,n,k),ja(U).then(()=>h()?void 0:x()).then(()=>{t?T(k):O()})})};return{promise:s,status:()=>s.status,cancel:o,continue:()=>(r==null||r(),s),cancelRetry:u,continueRetry:f,canStart:C,start:()=>(C()?O():x().then(O),s)}}var ps=(Rs=class{constructor(){N(this,Ft)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),rr(this.gcTime)&&_(this,Ft,wt.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Ct?1/0:300*1e3))}clearGcTimeout(){l(this,Ft)&&(wt.clearTimeout(l(this,Ft)),_(this,Ft,void 0))}},Ft=new WeakMap,Rs),to=(Ls=class extends ps{constructor(t){super();N(this,Le);N(this,Pt);N(this,Qt);N(this,ke);N(this,Dt);N(this,he);N(this,rn);N(this,Ot);_(this,Ot,!1),_(this,rn,t.defaultOptions),this.setOptions(t.options),this.observers=[],_(this,Dt,t.client),_(this,ke,l(this,Dt).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,_(this,Pt,gs(this.options)),this.state=t.state??l(this,Pt),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=l(this,he))==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=gs(this.options);n.data!==void 0&&(this.setState(ys(n.data,n.dataUpdatedAt)),_(this,Pt,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&l(this,ke).remove(this)}setData(t,n){const r=or(this.state.data,t,this.options);return z(this,Le,et).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){z(this,Le,et).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,s;const n=(r=l(this,he))==null?void 0:r.promise;return(s=l(this,he))==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,Pt))}isActive(){return this.observers.some(t=>Me(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===xn||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>it(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:!is(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=l(this,he))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=l(this,he))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),l(this,ke).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,he)&&(l(this,Ot)?l(this,he).cancel({revert:!0}):l(this,he).cancelRetry()),this.scheduleGc()),l(this,ke).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||z(this,Le,et).call(this,{type:"invalidate"})}async fetch(t,n){var f,h,C,E,T,x,O,M,B,k,P,K;if(this.state.fetchStatus!=="idle"&&((f=l(this,he))==null?void 0:f.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(l(this,he))return l(this,he).continueRetry(),l(this,he).promise}if(t&&this.setOptions(t),!this.options.queryFn){const U=this.observers.find(V=>V.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:()=>(_(this,Ot,!0),r.signal)})},i=()=>{const U=ds(this.options,n),G=(()=>{const oe={client:l(this,Dt),queryKey:this.queryKey,meta:this.meta};return s(oe),oe})();return _(this,Ot,!1),this.options.persister?this.options.persister(U,G,this):U(G)},u=(()=>{const U={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:l(this,Dt),state:this.state,fetchFn:i};return s(U),U})();(h=this.options.behavior)==null||h.onFetch(u,this),_(this,Qt,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((C=u.fetchOptions)==null?void 0:C.meta))&&z(this,Le,et).call(this,{type:"fetch",meta:(E=u.fetchOptions)==null?void 0:E.meta}),_(this,he,hs({initialPromise:n==null?void 0:n.initialPromise,fn:u.fetchFn,onCancel:U=>{U instanceof dr&&U.revert&&this.setState({...l(this,Qt),fetchStatus:"idle"}),r.abort()},onFail:(U,V)=>{z(this,Le,et).call(this,{type:"failed",failureCount:U,error:V})},onPause:()=>{z(this,Le,et).call(this,{type:"pause"})},onContinue:()=>{z(this,Le,et).call(this,{type:"continue"})},retry:u.options.retry,retryDelay:u.options.retryDelay,networkMode:u.options.networkMode,canRun:()=>!0}));try{const U=await l(this,he).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),(x=(T=l(this,ke).config).onSuccess)==null||x.call(T,U,this),(M=(O=l(this,ke).config).onSettled)==null||M.call(O,U,this.state.error,this),U}catch(U){if(U instanceof dr){if(U.silent)return l(this,he).promise;if(U.revert){if(this.state.data===void 0)throw U;return this.state.data}}throw z(this,Le,et).call(this,{type:"error",error:U}),(k=(B=l(this,ke).config).onError)==null||k.call(B,U,this),(K=(P=l(this,ke).config).onSettled)==null||K.call(P,this.state.data,U,this),U}finally{this.scheduleGc()}}},Pt=new WeakMap,Qt=new WeakMap,ke=new WeakMap,Dt=new WeakMap,he=new WeakMap,rn=new WeakMap,Ot=new WeakMap,Le=new WeakSet,et=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,...ms(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...ys(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return _(this,Qt,t.manual?s:void 0),s;case"error":const i=t.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,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,ke).notify({query:this,type:"updated",action:t})})},Ls);function ms(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:fs(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function ys(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function gs(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 no=(Ns=class extends qt{constructor(t,n){super();N(this,ee);N(this,ve);N(this,Y);N(this,sn);N(this,Te);N(this,It);N(this,zt);N(this,Ge);N(this,ut);N(this,an);N(this,$t);N(this,jt);N(this,Mt);N(this,kt);N(this,dt);N(this,Vt,new Set);this.options=n,_(this,ve,t),_(this,ut,null),_(this,Ge,ur()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(l(this,Y).addObserver(this),As(l(this,Y),this.options)?z(this,ee,dn).call(this):this.updateResult(),z(this,ee,Cr).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return lr(l(this,Y),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return lr(l(this,Y),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,z(this,ee,Sr).call(this),z(this,ee,xr).call(this),l(this,Y).removeObserver(this)}setOptions(t){const n=this.options,r=l(this,Y);if(this.options=l(this,ve).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Me(this.options.enabled,l(this,Y))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");z(this,ee,vr).call(this),l(this,Y).setOptions(this.options),n._defaulted&&!Sn(this.options,n)&&l(this,ve).getQueryCache().notify({type:"observerOptionsUpdated",query:l(this,Y),observer:this});const s=this.hasListeners();s&&Es(l(this,Y),r,this.options,n)&&z(this,ee,dn).call(this),this.updateResult(),s&&(l(this,Y)!==r||Me(this.options.enabled,l(this,Y))!==Me(n.enabled,l(this,Y))||it(this.options.staleTime,l(this,Y))!==it(n.staleTime,l(this,Y)))&&z(this,ee,br).call(this);const i=z(this,ee,Tr).call(this);s&&(l(this,Y)!==r||Me(this.options.enabled,l(this,Y))!==Me(n.enabled,l(this,Y))||i!==l(this,dt))&&z(this,ee,wr).call(this,i)}getOptimisticResult(t){const n=l(this,ve).getQueryCache().build(l(this,ve),t),r=this.createResult(n,t);return so(this,r)&&(_(this,Te,r),_(this,zt,this.options),_(this,It,l(this,Y).state)),r}getCurrentResult(){return l(this,Te)}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,Ge).status==="pending"&&l(this,Ge).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(t){l(this,Vt).add(t)}getCurrentQuery(){return l(this,Y)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=l(this,ve).defaultQueryOptions(t),r=l(this,ve).getQueryCache().build(l(this,ve),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return z(this,ee,dn).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),l(this,Te)))}createResult(t,n){var c;const r=l(this,Y),s=this.options,i=l(this,Te),o=l(this,It),u=l(this,zt),h=t!==r?t.state:l(this,sn),{state:C}=t;let E={...C},T=!1,x;if(n._optimisticResults){const d=this.hasListeners(),A=!d&&As(t,n),m=d&&Es(t,r,n,s);(A||m)&&(E={...E,...ms(C.data,t.options)}),n._optimisticResults==="isRestoring"&&(E.fetchStatus="idle")}let{error:O,errorUpdatedAt:M,status:B}=E;x=E.data;let k=!1;if(n.placeholderData!==void 0&&x===void 0&&B==="pending"){let d;i!=null&&i.isPlaceholderData&&n.placeholderData===(u==null?void 0:u.placeholderData)?(d=i.data,k=!0):d=typeof n.placeholderData=="function"?n.placeholderData((c=l(this,jt))==null?void 0:c.state.data,l(this,jt)):n.placeholderData,d!==void 0&&(B="success",x=or(i==null?void 0:i.data,d,n),T=!0)}if(n.select&&x!==void 0&&!k)if(i&&x===(o==null?void 0:o.data)&&n.select===l(this,an))x=l(this,$t);else try{_(this,an,n.select),x=n.select(x),x=or(i==null?void 0:i.data,x,n),_(this,$t,x),_(this,ut,null)}catch(d){_(this,ut,d)}l(this,ut)&&(O=l(this,ut),x=l(this,$t),M=Date.now(),B="error");const P=E.fetchStatus==="fetching",K=B==="pending",U=B==="error",V=K&&P,G=x!==void 0,a={status:B,fetchStatus:E.fetchStatus,isPending:K,isSuccess:B==="success",isError:U,isInitialLoading:V,isLoading:V,data:x,dataUpdatedAt:E.dataUpdatedAt,error:O,errorUpdatedAt:M,failureCount:E.fetchFailureCount,failureReason:E.fetchFailureReason,errorUpdateCount:E.errorUpdateCount,isFetched:E.dataUpdateCount>0||E.errorUpdateCount>0,isFetchedAfterMount:E.dataUpdateCount>h.dataUpdateCount||E.errorUpdateCount>h.errorUpdateCount,isFetching:P,isRefetching:P&&!K,isLoadingError:U&&!G,isPaused:E.fetchStatus==="paused",isPlaceholderData:T,isRefetchError:U&&G,isStale:fr(t,n),refetch:this.refetch,promise:l(this,Ge),isEnabled:Me(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const d=y=>{a.status==="error"?y.reject(a.error):a.data!==void 0&&y.resolve(a.data)},A=()=>{const y=_(this,Ge,a.promise=ur());d(y)},m=l(this,Ge);switch(m.status){case"pending":t.queryHash===r.queryHash&&d(m);break;case"fulfilled":(a.status==="error"||a.data!==m.value)&&A();break;case"rejected":(a.status!=="error"||a.error!==m.reason)&&A();break}}return a}updateResult(){const t=l(this,Te),n=this.createResult(l(this,Y),this.options);if(_(this,It,l(this,Y).state),_(this,zt,this.options),l(this,It).data!==void 0&&_(this,jt,l(this,Y)),Sn(n,t))return;_(this,Te,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!l(this,Vt).size)return!0;const o=new Set(i??l(this,Vt));return this.options.throwOnError&&o.add("error"),Object.keys(l(this,Te)).some(u=>{const f=u;return l(this,Te)[f]!==t[f]&&o.has(f)})};z(this,ee,$s).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&z(this,ee,Cr).call(this)}},ve=new WeakMap,Y=new WeakMap,sn=new WeakMap,Te=new WeakMap,It=new WeakMap,zt=new WeakMap,Ge=new WeakMap,ut=new WeakMap,an=new WeakMap,$t=new WeakMap,jt=new WeakMap,Mt=new WeakMap,kt=new WeakMap,dt=new WeakMap,Vt=new WeakMap,ee=new WeakSet,dn=function(t){z(this,ee,vr).call(this);let n=l(this,Y).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(be)),n},br=function(){z(this,ee,Sr).call(this);const t=it(this.options.staleTime,l(this,Y));if(Ct||l(this,Te).isStale||!rr(t))return;const r=is(l(this,Te).dataUpdatedAt,t)+1;_(this,Mt,wt.setTimeout(()=>{l(this,Te).isStale||this.updateResult()},r))},Tr=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(l(this,Y)):this.options.refetchInterval)??!1},wr=function(t){z(this,ee,xr).call(this),_(this,dt,t),!(Ct||Me(this.options.enabled,l(this,Y))===!1||!rr(l(this,dt))||l(this,dt)===0)&&_(this,kt,wt.setInterval(()=>{(this.options.refetchIntervalInBackground||cr.isFocused())&&z(this,ee,dn).call(this)},l(this,dt)))},Cr=function(){z(this,ee,br).call(this),z(this,ee,wr).call(this,z(this,ee,Tr).call(this))},Sr=function(){l(this,Mt)&&(wt.clearTimeout(l(this,Mt)),_(this,Mt,void 0))},xr=function(){l(this,kt)&&(wt.clearInterval(l(this,kt)),_(this,kt,void 0))},vr=function(){const t=l(this,ve).getQueryCache().build(l(this,ve),this.options);if(t===l(this,Y))return;const n=l(this,Y);_(this,Y,t),_(this,sn,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},$s=function(t){ue.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(l(this,Te))}),l(this,ve).getQueryCache().notify({query:l(this,Y),type:"observerResultsUpdated"})})},Ns);function ro(e,t){return Me(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function As(e,t){return ro(e,t)||e.state.data!==void 0&&lr(e,t,t.refetchOnMount)}function lr(e,t,n){if(Me(t.enabled,e)!==!1&&it(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&fr(e,t)}return!1}function Es(e,t,n,r){return(e!==t||Me(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&fr(e,n)}function fr(e,t){return Me(t.enabled,e)!==!1&&e.isStaleByTime(it(t.staleTime,e))}function so(e,t){return!Sn(e.getCurrentResult(),t)}function bs(e){return{onFetch:(t,n)=>{var C,E,T,x,O;const r=t.options,s=(T=(E=(C=t.fetchOptions)==null?void 0:C.meta)==null?void 0:E.fetchMore)==null?void 0:T.direction,i=((x=t.state.data)==null?void 0:x.pages)||[],o=((O=t.state.data)==null?void 0:O.pageParams)||[];let u={pages:[],pageParams:[]},f=0;const h=async()=>{let M=!1;const B=K=>{Object.defineProperty(K,"signal",{enumerable:!0,get:()=>(t.signal.aborted?M=!0:t.signal.addEventListener("abort",()=>{M=!0}),t.signal)})},k=ds(t.options,t.fetchOptions),P=async(K,U,V)=>{if(M)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:V?"backward":"forward",meta:t.options.meta};return B(A),A})(),a=await k(oe),{maxPages:c}=t.options,d=V?Ga:Va;return{pages:d(K.pages,a,c),pageParams:d(K.pageParams,U,c)}};if(s&&i.length){const K=s==="backward",U=K?io:Ts,V={pages:i,pageParams:o},G=U(r,V);u=await P(V,G,K)}else{const K=e??i.length;do{const U=f===0?o[0]??r.initialPageParam:Ts(r,u);if(f>0&&U==null)break;u=await P(u,U),f++}while(f<K)}return u};t.options.persister?t.fetchFn=()=>{var M,B;return(B=(M=t.options).persister)==null?void 0:B.call(M,h,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=h}}}function Ts(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 io(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 ao=(qs=class extends ps{constructor(t){super();N(this,Qe);N(this,on);N(this,We);N(this,we);N(this,_t);_(this,on,t.client),this.mutationId=t.mutationId,_(this,we,t.mutationCache),_(this,We,[]),this.state=t.state||ws(),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,We).includes(t)||(l(this,We).push(t),this.clearGcTimeout(),l(this,we).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){_(this,We,l(this,We).filter(n=>n!==t)),this.scheduleGc(),l(this,we).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){l(this,We).length||(this.state.status==="pending"?this.scheduleGc():l(this,we).remove(this))}continue(){var t;return((t=l(this,_t))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,u,f,h,C,E,T,x,O,M,B,k,P,K,U,V,G,oe,a,c;const n=()=>{z(this,Qe,mt).call(this,{type:"continue"})},r={client:l(this,on),meta:this.options.meta,mutationKey:this.options.mutationKey};_(this,_t,hs({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(d,A)=>{z(this,Qe,mt).call(this,{type:"failed",failureCount:d,error:A})},onPause:()=>{z(this,Qe,mt).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>l(this,we).canRun(this)}));const s=this.state.status==="pending",i=!l(this,_t).canStart();try{if(s)n();else{z(this,Qe,mt).call(this,{type:"pending",variables:t,isPaused:i}),await((u=(o=l(this,we).config).onMutate)==null?void 0:u.call(o,t,this,r));const A=await((h=(f=this.options).onMutate)==null?void 0:h.call(f,t,r));A!==this.state.context&&z(this,Qe,mt).call(this,{type:"pending",context:A,variables:t,isPaused:i})}const d=await l(this,_t).start();return await((E=(C=l(this,we).config).onSuccess)==null?void 0:E.call(C,d,t,this.state.context,this,r)),await((x=(T=this.options).onSuccess)==null?void 0:x.call(T,d,t,this.state.context,r)),await((M=(O=l(this,we).config).onSettled)==null?void 0:M.call(O,d,null,this.state.variables,this.state.context,this,r)),await((k=(B=this.options).onSettled)==null?void 0:k.call(B,d,null,t,this.state.context,r)),z(this,Qe,mt).call(this,{type:"success",data:d}),d}catch(d){try{throw await((K=(P=l(this,we).config).onError)==null?void 0:K.call(P,d,t,this.state.context,this,r)),await((V=(U=this.options).onError)==null?void 0:V.call(U,d,t,this.state.context,r)),await((oe=(G=l(this,we).config).onSettled)==null?void 0:oe.call(G,void 0,d,this.state.variables,this.state.context,this,r)),await((c=(a=this.options).onSettled)==null?void 0:c.call(a,void 0,d,t,this.state.context,r)),d}finally{z(this,Qe,mt).call(this,{type:"error",error:d})}}finally{l(this,we).runNext(this)}}},on=new WeakMap,We=new WeakMap,we=new WeakMap,_t=new WeakMap,Qe=new WeakSet,mt=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,We).forEach(r=>{r.onMutationUpdate(t)}),l(this,we).notify({mutation:this,type:"updated",action:t})})},qs);function ws(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var oo=(Ks=class extends qt{constructor(t={}){super();N(this,Xe);N(this,Ne);N(this,cn);this.config=t,_(this,Xe,new Set),_(this,Ne,new Map),_(this,cn,0)}build(t,n,r){const s=new ao({client:t,mutationCache:this,mutationId:++In(this,cn)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){l(this,Xe).add(t);const n=Fn(t);if(typeof n=="string"){const r=l(this,Ne).get(n);r?r.push(t):l(this,Ne).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(l(this,Xe).delete(t)){const n=Fn(t);if(typeof n=="string"){const r=l(this,Ne).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,Ne).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Fn(t);if(typeof n=="string"){const r=l(this,Ne).get(n),s=r==null?void 0:r.find(i=>i.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const n=Fn(t);if(typeof n=="string"){const s=(r=l(this,Ne).get(n))==null?void 0:r.find(i=>i!==t&&i.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){ue.batch(()=>{l(this,Xe).forEach(t=>{this.notify({type:"removed",mutation:t})}),l(this,Xe).clear(),l(this,Ne).clear()})}getAll(){return Array.from(l(this,Xe))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>os(n,r))}findAll(t={}){return this.getAll().filter(n=>os(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))))}},Xe=new WeakMap,Ne=new WeakMap,cn=new WeakMap,Ks);function Fn(e){var t;return(t=e.options.scope)==null?void 0:t.id}var co=(Hs=class extends qt{constructor(t,n){super();N(this,Je);N(this,Ze);N(this,lt);N(this,Fe);N(this,Ye);_(this,Ze,t),this.setOptions(n),this.bindMethods(),z(this,Je,Mn).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,Ze).defaultMutationOptions(t),Sn(this.options,n)||l(this,Ze).getMutationCache().notify({type:"observerOptionsUpdated",mutation:l(this,Fe),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&St(n.mutationKey)!==St(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){z(this,Je,Mn).call(this),z(this,Je,Fr).call(this,t)}getCurrentResult(){return l(this,lt)}reset(){var t;(t=l(this,Fe))==null||t.removeObserver(this),_(this,Fe,void 0),z(this,Je,Mn).call(this),z(this,Je,Fr).call(this)}mutate(t,n){var r;return _(this,Ye,n),(r=l(this,Fe))==null||r.removeObserver(this),_(this,Fe,l(this,Ze).getMutationCache().build(l(this,Ze),this.options)),l(this,Fe).addObserver(this),l(this,Fe).execute(t)}},Ze=new WeakMap,lt=new WeakMap,Fe=new WeakMap,Ye=new WeakMap,Je=new WeakSet,Mn=function(){var n;const t=((n=l(this,Fe))==null?void 0:n.state)??ws();_(this,lt,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},Fr=function(t){ue.batch(()=>{var n,r,s,i,o,u,f,h;if(l(this,Ye)&&this.hasListeners()){const C=l(this,lt).variables,E=l(this,lt).context,T={client:l(this,Ze),meta:this.options.meta,mutationKey:this.options.mutationKey};(t==null?void 0:t.type)==="success"?((r=(n=l(this,Ye)).onSuccess)==null||r.call(n,t.data,C,E,T),(i=(s=l(this,Ye)).onSettled)==null||i.call(s,t.data,null,C,E,T)):(t==null?void 0:t.type)==="error"&&((u=(o=l(this,Ye)).onError)==null||u.call(o,t.error,C,E,T),(h=(f=l(this,Ye)).onSettled)==null||h.call(f,void 0,t.error,C,E,T))}this.listeners.forEach(C=>{C(l(this,lt))})})},Hs),uo=(Ws=class extends qt{constructor(t={}){super();N(this,ze);this.config=t,_(this,ze,new Map)}build(t,n,r){const s=n.queryKey,i=n.queryHash??sr(s,n);let o=this.get(i);return o||(o=new to({client:t,queryKey:s,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(o)),o}add(t){l(this,ze).has(t.queryHash)||(l(this,ze).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=l(this,ze).get(t.queryHash);n&&(t.destroy(),n===t&&l(this,ze).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ue.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return l(this,ze).get(t)}getAll(){return[...l(this,ze).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>as(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>as(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()})})}},ze=new WeakMap,Ws),lo=(Qs=class{constructor(e={}){N(this,se);N(this,ft);N(this,ht);N(this,Gt);N(this,Xt);N(this,pt);N(this,Zt);N(this,Yt);_(this,se,e.queryCache||new uo),_(this,ft,e.mutationCache||new oo),_(this,ht,e.defaultOptions||{}),_(this,Gt,new Map),_(this,Xt,new Map),_(this,pt,0)}mount(){In(this,pt)._++,l(this,pt)===1&&(_(this,Zt,cr.subscribe(async e=>{e&&(await this.resumePausedMutations(),l(this,se).onFocus())})),_(this,Yt,vn.subscribe(async e=>{e&&(await this.resumePausedMutations(),l(this,se).onOnline())})))}unmount(){var e,t;In(this,pt)._--,l(this,pt)===0&&((e=l(this,Zt))==null||e.call(this),_(this,Zt,void 0),(t=l(this,Yt))==null||t.call(this),_(this,Yt,void 0))}isFetching(e){return l(this,se).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return l(this,ft).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(it(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),i=s==null?void 0:s.state.data,o=za(t,i);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 i=s.fetch(void 0,n);return n.throwOnError||(i=i.catch(be)),s.state.fetchStatus==="paused"?Promise.resolve():i}));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(it(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=bs(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(be).catch(be)}ensureInfiniteQueryData(e){return e.behavior=bs(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return vn.isOnline()?l(this,ft).resumePausedMutations():Promise.resolve()}getQueryCache(){return l(this,se)}getMutationCache(){return l(this,ft)}getDefaultOptions(){return l(this,ht)}setDefaultOptions(e){_(this,ht,e)}setQueryDefaults(e,t){l(this,Gt).set(St(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...l(this,Gt).values()],n={};return t.forEach(r=>{tn(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){l(this,Xt).set(St(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...l(this,Xt).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,ht).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=sr(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===xn&&(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,se).clear(),l(this,ft).clear()}},se=new WeakMap,ft=new WeakMap,ht=new WeakMap,Gt=new WeakMap,Xt=new WeakMap,pt=new WeakMap,Zt=new WeakMap,Yt=new WeakMap,Qs),Cs=ce.createContext(void 0),hr=e=>{const t=ce.useContext(Cs);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},fo=({client:e,children:t})=>(ce.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),H.jsx(Cs.Provider,{value:e,children:t})),Ss=ce.createContext(!1),ho=()=>ce.useContext(Ss);Ss.Provider;function po(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var mo=ce.createContext(po()),yo=()=>ce.useContext(mo),go=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},Ao=e=>{ce.useEffect(()=>{e.clearReset()},[e])},Eo=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||ls(n,[e.error,r])),bo=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))}},To=(e,t)=>e.isLoading&&e.isFetching&&!t,wo=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,xs=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Co(e,t,n){var E,T,x,O,M;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=ho(),s=yo(),i=hr(),o=i.defaultQueryOptions(e);(T=(E=i.getDefaultOptions().queries)==null?void 0:E._experimental_beforeQuery)==null||T.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=r?"isRestoring":"optimistic",bo(o),go(o,s),Ao(s);const u=!i.getQueryCache().get(o.queryHash),[f]=ce.useState(()=>new t(i,o)),h=f.getOptimisticResult(o),C=!r&&e.subscribed!==!1;if(ce.useSyncExternalStore(ce.useCallback(B=>{const k=C?f.subscribe(ue.batchCalls(B)):be;return f.updateResult(),k},[f,C]),()=>f.getCurrentResult(),()=>f.getCurrentResult()),ce.useEffect(()=>{f.setOptions(o)},[o,f]),wo(o,h))throw xs(o,f,s);if(Eo({result:h,errorResetBoundary:s,throwOnError:o.throwOnError,query:i.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw h.error;if((O=(x=i.getDefaultOptions().queries)==null?void 0:x._experimental_afterQuery)==null||O.call(x,o,h),o.experimental_prefetchInRender&&!Ct&&To(h,r)){const B=u?xs(o,f,s):(M=i.getQueryCache().get(o.queryHash))==null?void 0:M.promise;B==null||B.catch(be).finally(()=>{f.updateResult()})}return o.notifyOnChangeProps?h:f.trackResult(h)}function So(e,t){return Co(e,no)}function at(e,t){const n=hr(),[r]=ce.useState(()=>new co(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()),i=ce.useCallback((o,u)=>{r.mutate(o,u).catch(be)},[r]);if(s.error&&ls(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:i,mutateAsync:s.mutate}}const nn=()=>{const e=Q(i=>i.state.swapExecutionIndex),t=Q(i=>i.state.swapExecutions[i.state.swapExecutionIndex]??{}),n=Q(i=>i.updateSwapExecutionAtIndex),r=Q(i=>i.resetSwapExecutionAtIndex),s=F.useCallback(i=>n(e,i),[n,e]);return F.useMemo(()=>({...t,update:s,resetSwap:r}),[t,s,r])},xo=2e4,vo=()=>{const{module:e}=q(),t=Q(n=>n.state.isMarketOrder);return F.useMemo(()=>e===j.TWAP?t?X.TWAP_MARKET:X.TWAP_LIMIT:e===j.LIMIT?X.LIMIT:e===j.STOP_LOSS?t?X.STOP_LOSS_MARKET:X.STOP_LOSS_LIMIT:e===j.TAKE_PROFIT?t?X.TAKE_PROFIT_MARKET:X.TAKE_PROFIT_LIMIT:X.TWAP_MARKET,[e,t])},vs=()=>{const{account:e,config:t,chainId:n,isDev:r}=q();return F.useMemo(()=>["useTwapOrderHistoryManager",e,t==null?void 0:t.adapter,t==null?void 0:t.partner,n,r],[e,t,n,r])},Fo=()=>{const{callbacks:e}=q(),t=hr(),n=vs();return F.useCallback(r=>{var u;const s=t.getQueryData(n);let i=!1;const o=[];s&&s.filter(f=>f.version===2).forEach(f=>{var C;const h=r.find(E=>E.id===f.id);h&&h.progress!==f.progress&&(i=!0,o.push(h),h.status===pe.Completed&&((C=e==null?void 0:e.onOrderFilled)==null||C.call(e,h)))}),i&&((u=e==null?void 0:e.onOrdersProgressUpdate)==null||u.call(e,o))},[t,n,e])},pr=()=>{const{account:e,config:t,chainId:n,isDev:r}=q(),s=vs(),i=Fo();return So({refetchInterval:xo,refetchOnWindowFocus:!0,retry:!1,staleTime:1/0,queryKey:s,queryFn:async({signal:u})=>{if(!e||!n||!t)return[];const f=await pa({signal:u,chainId:n,config:t,account:e,isDev:r});return i(f),f.map(h=>t!=null&&t.twapConfig?{...h,fillDelayMillis:Kn(h,t.twapConfig)}:h)}})},Po=(e,t,n)=>F.useMemo(()=>{if(!(!e||!t||!n||n!=null&&n.isMarketPrice))return Lr(n,e==null?void 0:e.decimals,t==null?void 0:t.decimals)},[n,e,t]),Do=(e,t,n)=>F.useMemo(()=>{if(!(!e||!t||!n))return Nr(n,e.decimals,t.decimals)},[n,e,t]),Oo=(e,t,n)=>F.useMemo(()=>{if(!(!e||!t||!n))return Hn(n.srcAmountFilled,n.dstAmountFilled,e.decimals,t.decimals)},[n,e,t]),Pn=(e,t)=>[...e.filter(r=>r.status===t)].sort((r,s)=>s.createdAt-r.createdAt),Io=()=>{const{data:e,isLoading:t,refetch:n,isRefetching:r}=pr(),s=F.useCallback(()=>n().then(i=>i.data),[n]);return F.useMemo(()=>({orders:{all:e??[],open:Pn(e??[],pe.Open),completed:Pn(e??[],pe.Completed),cancelled:Pn(e??[],pe.Cancelled),expired:Pn(e??[],pe.Expired)},isLoading:t,isRefetching:r,refetchOrders:s}),[e,t,r,s])},mr=()=>{const e=Q(n=>n.state.currentTime),t=er().duration;return F.useMemo(()=>Pi(e,t),[e,t])},Fs=()=>{const{srcToken:e,dstToken:t,account:n,chainId:r,slippage:s,config:i,module:o,fees:u}=q(),{amount:f}=st(),{amountPerTrade:h,totalTrades:C}=Ke(),E=mr(),{amount:T}=nr(),{pricePerChunk:x}=Tt(),{milliseconds:O}=Nt();return F.useMemo(()=>{var M;return Hr({chainId:r,srcToken:Rt((e==null?void 0:e.address)||"")?((M=Et(r))==null?void 0:M.wToken.address)||"":(e==null?void 0:e.address)||"",dstToken:(t==null?void 0:t.address)||"",srcAmount:f,deadlineMillis:E,fillDelayMillis:!C||C===1?0:O,slippage:s*100,account:n,srcAmountPerTrade:h,dstMinAmountPerTrade:T,triggerAmountPerTrade:x,config:i,module:o})},[e,t,n,r,s,i,o,f,h,C,O,T,x,u])};function Mo(e){const t=e.slice(2);if(t.length===128){const i=`0x${t.slice(0,64)}`,o=parseInt(t.charAt(64),16),u=(o>>3)+27,f=`0x${(o&7).toString(16)}${t.slice(65,128)}`;return{r:i,s:f,v:u}}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 ko=()=>{var i;const{account:e,walletInteractions:t,callbacks:n,chainId:r}=q(),s=(i=En())==null?void 0:i.wToken;return at({mutationFn:async({onHash:o,srcAmountWei:u})=>{var h,C;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletInteractions");if(!s)throw new Error("tokenAddress is not defined");fe.onWrapRequest();const f=await t.wrapNativeToken(u);return(h=n==null?void 0:n.onWrapRequest)==null||h.call(n),o==null||o(f),fe.onWrapSuccess(f),(C=n==null?void 0:n.onWrapSuccess)==null||C.call(n,{txHash:f,explorerUrl:Lt(f,r),amount:Ee(u,s.decimals)}),f},onError:o=>{throw fe.onWrapError(o),o}})},Ps=()=>{const{account:e,walletInteractions:t,chainId:n,callbacks:r,isDev:s}=q(),i=Fs(),{refetch:o}=pr();return at({mutationFn:async()=>{var M,B,k,P;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletInteractions");if(!n)throw new Error("missing chainId");const{order:u,domain:f,types:h,primaryType:C}=i;fe.onSignOrderRequest(u);let E;try{E=await t.signOrder({domain:f,types:h,primaryType:C,message:u,account:e})}catch(K){throw(M=r==null?void 0:r.onSignOrderError)==null||M.call(r,K),fe.onSignOrderError(K),K}fe.onSignOrderSuccess(E),(B=r==null?void 0:r.onSignOrderSuccess)==null||B.call(r,E);const T=Mo(E),x={v:`0x${T.v.toString(16)}`,r:T.r,s:T.s};(k=r==null?void 0:r.onSignOrderRequest)==null||k.call(r);const O=await zr(u,x,s);return(P=r==null?void 0:r.onOrderCreated)==null||P.call(r,O),await o(),O}})},Ds=()=>{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 i=await t.getAllowance({tokenAddress:r,spenderAddress:n.repermit}),o=v(i||"0").lt(v(s).toString());return{allowance:i,approvalRequired:o}}})},_o=()=>{const{account:e,walletInteractions:t,config:n,chainId:r,callbacks:s}=q(),{mutateAsync:i}=Ds();return at({onError:o=>{fe.onApproveError(o)},mutationFn:async({token:o,onHash:u,srcAmountWei:f})=>{var E,T;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletInteractions");if(!n)throw new Error("missing config");fe.onApproveRequest();const h=await t.approveToken({tokenAddress:o.address,amount:f,spenderAddress:n.repermit});if(!h)throw new Error("failed to approve token");(E=s==null?void 0:s.onApproveRequest)==null||E.call(s),u(h);let C=!1;for(let x=0;x<3;x++){const{approvalRequired:O}=await i({tokenAddress:o.address,srcAmountWei:f});if(!O){C=!0;break}x<2&&await new Promise(M=>setTimeout(M,3e3))}if(!C)throw new Error(`Insufficient ${o.symbol} allowance to perform the swap. Please approve the token first.`);return fe.onApproveSuccess(h),(T=s==null?void 0:s.onApproveSuccess)==null||T.call(s,{txHash:h,explorerUrl:Lt(h,r),token:o,amount:Ee(f,o.decimals)}),h}})},Bo=()=>{const{account:e,chainId:t,srcToken:n,dstToken:r,module:s,slippage:i}=q(),o=Tt(),u=st().amount,f=Ke().amountPerTrade,h=mr(),C=Ke().totalTrades,E=Nt().fillDelay,T=nr().amount,x=Q(O=>O.state.isMarketOrder);return at({mutationFn:async()=>{fe.onRequestOrder({account:e,chainId:t,module:s,srcToken:n,dstToken:r,fromTokenAmount:u,srcChunkAmount:f,triggerPricePerTrade:o.pricePerChunk,deadline:h,fillDelay:E.unit*E.value,minDstAmountOutPerTrade:T,slippage:i,isMarketOrder:x||!1,chunksAmount:C})}})};function Uo(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 Os=()=>{const{srcToken:e,dstToken:t,chainId:n,callbacks:r,marketPrice:s}=q(),i=_o().mutateAsync,o=ko().mutateAsync,u=Ps().mutateAsync,{mutateAsync:f}=Ds(),{update:h}=nn(),{amount:C}=st(),E=Bo().mutate;return at({mutationFn:async()=>{var x,O;const T=Rt((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 M=Yr(e,n);h({allowanceLoading:!0,wrapTxHash:void 0,approveTxHash:void 0,acceptedMarketPrice:s,acceptedSrcAmount:C,srcToken:e,dstToken:t,pendingSteps:[]});const{approvalRequired:B}=await f({tokenAddress:M.address,srcAmountWei:C});let k=0,P=1;T&&P++,B&&P++,h({totalSteps:P,stepIndex:k,allowanceLoading:!1,hasApproval:!B,status:xe.LOADING}),E();let K=[];T&&K.push(nt.WRAP),B&&K.push(nt.APPROVE),K.push(nt.CREATE),h({pendingSteps:K}),T&&(h({step:nt.WRAP}),await o({onHash:V=>h({wrapTxHash:V}),srcAmountWei:C}),k++,h({stepIndex:k})),B&&(h({step:nt.APPROVE}),await i({token:M,onHash:V=>h({approveTxHash:V}),srcAmountWei:C}),k++,h({stepIndex:k})),h({step:nt.CREATE});const U=await u();return h({status:xe.SUCCESS,orderId:U.id}),U}catch(M){if(Gn(M))(x=r==null?void 0:r.onSubmitOrderRejected)==null||x.call(r),h({step:void 0,status:void 0,stepIndex:void 0,error:M});else{const B=Uo(M);(O=r==null?void 0:r.onSubmitOrderFailed)==null||O.call(r,B),h({status:xe.FAILED,parsedError:B,error:M})}throw M}}})},Ro=()=>{const e=nn(),{srcToken:t,dstToken:n}=q(),r=Os(),s=Q(h=>h.resetState),i=F.useCallback(()=>r.mutateAsync(),[r]),{update:o,resetSwap:u,...f}=e;return F.useMemo(()=>({status:f.status,parsedError:f.parsedError,error:f.error,step:f.step,stepIndex:f.stepIndex,approveTxHash:f.approveTxHash,wrapTxHash:f.wrapTxHash,totalSteps:f.totalSteps,pendingSteps:f.pendingSteps,srcToken:t,dstToken:n,onSubmit:i,resetState:s,resetCurrentSwap:u,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:f.allowanceLoading}),[i,f,s,u,t,n])},Lo=()=>{const{marketPrice:e,srcToken:t,dstToken:n,marketPriceLoading:r,srcBalance:s,srcUsd1Token:i,noLiquidity:o,typedInputAmount:u}=q(),f=r||v(i||"0").isZero()||s===void 0||v(e||"0").isZero(),h=!!(t&&n&&u&&f),E=!!(ss()||o||h||v(u||"0").isZero()||!t||!n);return F.useMemo(()=>({disabled:E,loading:h}),[E,h])},No=()=>{const{srcUsd1Token:e,dstUsd1Token:t}=q(),n=st().amountUI,r=Cn().amountUI,s=qe(n,e),i=qe(r,t);return{srcAmountUsd:s,dstAmountUsd:i}},qo=()=>{const{fees:e,dstToken:t,dstUsd1Token:n}=q(),{amountUI:r}=Cn(),s=F.useMemo(()=>!e||!r?"":v(r).multipliedBy(e).dividedBy(100).toFixed(),[r,e]),i=Jn((t==null?void 0:t.decimals)||0,s);return{amountUI:s,amount:i,percent:e,usd:qe(s,n)}},Ko=e=>{const t=F.useMemo(()=>!e.minDestAmountPerTrade||!e.totalTrades?"":v(e.minDestAmountPerTrade).multipliedBy(e.totalTrades).decimalPlaces(0).toFixed(),[e.minDestAmountPerTrade,e.totalTrades]),n=F.useMemo(()=>!e.minDestAmountPerTradeUI||!e.totalTrades?"":v(e.minDestAmountPerTradeUI).multipliedBy(e.totalTrades).toFixed(),[e.minDestAmountPerTradeUI,e.totalTrades]),r=F.useMemo(()=>!e.minDestAmountPerTradeUsd||!e.totalTrades?"":v(e.minDestAmountPerTradeUsd).multipliedBy(e.totalTrades).decimalPlaces(2).toFixed(),[e.minDestAmountPerTradeUsd,e.totalTrades]);return F.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])},Ho=()=>{const{config:e}=q();return F.useMemo(()=>({spender:e.repermit}),[e])},Wo=()=>{const{srcToken:e,dstToken:t,account:n,marketPrice:r}=q(),{spender:s}=Ho(),{amount:i}=st(),{amount:o,amountUI:u,usd:f}=wn(),{amountPerTrade:h,amountPerTradeUI:C,amountPerTradeUsd:E,totalTrades:T}=Ke(),x=mr(),{amount:O,amountUI:M,usd:B}=nr(),{amountUI:k,amount:P,usd:K}=Tt(),{milliseconds:U}=Nt(),{amount:V,amountUI:G}=Cn(),{srcAmountUsd:oe,dstAmountUsd:a}=No(),{amount:c,amountUI:d,percent:A,usd:m}=qo(),y=Fs(),S=Q(Z=>Z.state.isMarketOrder),p=Q(Z=>Z.state.currentTime),g=nn(),w=vo(),b=g.acceptedSrcAmount||i,D=Ee(r,(t==null?void 0:t.decimals)||0),R=F.useMemo(()=>w===X.TAKE_PROFIT_MARKET||w===X.TAKE_PROFIT_LIMIT||w===X.STOP_LOSS_LIMIT||w===X.STOP_LOSS_MARKET,[w]),L=Ko({srcToken:e,dstToken:t,account:n,orderType:w,createdAt:p,deadline:x,totalTrades:T,tradeInterval:U,srcAmount:b,srcAmountUI:Ee(b,(e==null?void 0:e.decimals)||0),srcAmountUsd:oe,dstAmount:V,dstAmountUI:G,dstAmountUsd:a,limitPrice:S?void 0:o,limitPriceUI:S?void 0:u,limitPriceUsd:S?void 0:f,srcAmountPerTrade:h,srcAmountPerTradeUI:C,srcAmountPerTradeUsd:E,minDestAmountPerTrade:O,minDestAmountPerTradeUI:M,minDestAmountPerTradeUsd:B,triggerPrice:P,triggerPriceUI:k,triggerPriceUsd:K});return F.useMemo(()=>({...L,feesAmountUI:d,feesAmount:c,feesUsd:m||"",feesPercentage:A,rePermitData:y,isTriggerPrice:R,isMarketOrder:S,marketPrice:r,marketPriceUi:D,spender:s}),[L,d,c,m,A,y,R,S,r,D,s])},Qo=()=>{const{supportedChains:e}=q();return F.useMemo(()=>e,[e])},zo=60,Is=()=>{const{refetch:e}=pr();return at({mutationFn:async t=>{var n;for(let r=0;r<zo;r++){const s=(n=await e())==null?void 0:n.data;if(!s)throw new Error("orders not found");const i=s.find(o=>o.id===t);if((i==null?void 0:i.status)===pe.Cancelled)return;await new Promise(o=>setTimeout(o,1e3))}throw new Error("Timed out waiting for order cancellation to be confirmed")}})},$o=()=>{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})}}},jo=e=>{const{account:t,walletInteractions:n,config:r,callbacks:s,chainId:i}=q(),o=Is().mutateAsync,{cancelOrders:u,setCancelOrder:f,clearCancelOrder:h}=$o(),{mutateAsync:C}=at({mutationFn:async()=>{var O,M,B;if(!t||!n||!r)throw new Error("missing required parameters");if(!e)throw new Error("order is required");const x=e.id;try{(O=s==null?void 0:s.onCancelOrderRequest)==null||O.call(s,e),f(x,{status:xe.LOADING}),fe.onCancelOrderRequest([e.version===1?e.id.toString():e.hash],e.version);const k=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?Gs:Vs});if(!k)throw new Error("failed to cancel order");return fe.onCancelOrderSuccess(k),await o(e.id),(M=s==null?void 0:s.onCancelOrderSuccess)==null||M.call(s,{order:e,txHash:k,explorerUrl:Lt(k,i)}),f(x,{status:xe.SUCCESS,txHash:k}),k}catch(k){console.error("cancel order error",k),(B=s==null?void 0:s.onCancelOrderFailed)==null||B.call(s,k),Gn(k)?h(x):(f(x,{status:xe.FAILED,error:k.message}),fe.onCancelOrderError(k))}}}),E=F.useMemo(()=>{const x=u[(e==null?void 0:e.id)||""];return{isLoading:(x==null?void 0:x.status)===xe.LOADING,isSuccess:(x==null?void 0:x.status)===xe.SUCCESS,isError:(x==null?void 0:x.status)===xe.FAILED,error:x==null?void 0:x.error,txHash:x==null?void 0:x.txHash}},[u,e==null?void 0:e.id]),T=F.useCallback(async()=>C(),[C]);return F.useMemo(()=>({cancelOrder:T,...E}),[T,E])},Ms=F.createContext(null),Vo=({children:e})=>{const t=Fa(),n=Ia(),r=Da(),s=Ra(),i=La(),o=bn(),u=Na(),f=qa(),h=ss(),C=Lo(),E=Wo(),T=Io(),x=Ro(),O=Qo(),M=Is(),{module:B}=q(),k={tradesAmountPanel:t,durationPanel:n,fillDelayPanel:r,limitPricePanel:s,triggerPricePanel:i,pricePanel:o,dstTokenPanel:u,disclaimerPanel:f,inputError:h,submitOrderButton:C,derivedFormData:E,orderHistoryPanel:T,orderExecutionPanel:x,supportedChains:O,refetchUntilStatusSynced:M,module:B};return H.jsx(Ms.Provider,{value:k,children:e})},Go=()=>{const e=F.useContext(Ms);if(e===null)throw new Error("useSpot must be used within SpotProvider");return e},Xo=F.createContext(null),yr={didCatch:!1,error:null};class Zo extends F.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=yr}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var n,r,s=arguments.length,i=new Array(s),o=0;o<s;o++)i[o]=arguments[o];(n=(r=this.props).onReset)===null||n===void 0||n.call(r,{args:i,reason:"imperative-api"}),this.setState(yr)}}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&&Yo(t.resetKeys,s)){var i,o;(i=(o=this.props).onReset)===null||i===void 0||i.call(o,{next:s,prev:t.resetKeys,reason:"keys"}),this.setState(yr)}}render(){const{children:t,fallbackRender:n,FallbackComponent:r,fallback:s}=this.props,{didCatch:i,error:o}=this.state;let u=t;if(i){const f={error:o,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")u=n(f);else if(r)u=F.createElement(r,f);else if(s!==void 0)u=s;else throw o}return F.createElement(Xo.Provider,{value:{didCatch:i,error:o,resetErrorBoundary:this.resetErrorBoundary}},u)}}function Yo(){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 Jo=()=>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 ec({children:e}){return H.jsx(Zo,{FallbackComponent:Jo,onError:t=>fe.onCrash(t),children:H.jsx(H.Fragment,{children:e})})}const ks=F.createContext(null),tc=new lo({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),nc=e=>{var r,s,i;const t=Q(o=>o.updateState),n=Q(o=>o.state.isMarketOrder);return F.useEffect(()=>{const o=setInterval(()=>{t({currentTime:Date.now()})},6e4);return()=>clearInterval(o)},[t]),F.useEffect(()=>{var u,f,h,C,E,T,x,O,M,B,k,P,K,U,V,G;const o=(f=(u=e.overrides)==null?void 0:u.state)==null?void 0:f.isMarketOrder;o!==void 0&&t({isMarketOrder:o}),t({typedChunks:(C=(h=e.overrides)==null?void 0:h.state)==null?void 0:C.chunks,typedFillDelay:(T=(E=e.overrides)==null?void 0:E.state)==null?void 0:T.fillDelay,typedDuration:(O=(x=e.overrides)==null?void 0:x.state)==null?void 0:O.duration,typedLimitPrice:(B=(M=e.overrides)==null?void 0:M.state)==null?void 0:B.limitPrice,typedTriggerPrice:(P=(k=e.overrides)==null?void 0:k.state)==null?void 0:P.triggerPrice,triggerPricePercent:(U=(K=e.overrides)==null?void 0:K.state)==null?void 0:U.triggerPricePercent,limitPricePercent:(G=(V=e.overrides)==null?void 0:V.state)==null?void 0:G.limitPricePercent})},[(r=e.overrides)==null?void 0:r.state,e.module]),F.useEffect(()=>{var o,u,f,h;t({typedLimitPrice:(u=(o=e.overrides)==null?void 0:o.state)==null?void 0:u.limitPrice,typedTriggerPrice:(h=(f=e.overrides)==null?void 0:f.state)==null?void 0:h.triggerPrice,triggerPricePercent:void 0,limitPricePercent:void 0})},[(s=e.srcToken)==null?void 0:s.address,(i=e.dstToken)==null?void 0:i.address]),F.useEffect(()=>{e.module===j.LIMIT&&t({isMarketOrder:!1})},[e.module]),F.useEffect(()=>{n&&t({isInvertedTrade:!1})},[n]),F.useEffect(()=>{t({typedChunks:void 0})},[e.typedInputAmount]),null},rc=({marketReferencePrice:e,srcToken:t,dstToken:n,chainId:r,typedInputAmount:s})=>F.useMemo(()=>{if(Zn(t,n,r)||Yn(t,n,r))return{isLoading:!1,noLiquidity:!1,value:rt(s||"0",t==null?void 0:t.decimals)};if(v(e.value||0).isZero()||v(s||0).isZero())return e;const i=v(e.value||0).dividedBy(s||0).decimalPlaces(0).toFixed();return{...e,value:i}},[e,s,t,n,r]),sc=e=>{const t=nn(),n=F.useMemo(()=>Rr(e.partner),[e.partner]),r=F.useMemo(()=>{const u=n[0];return e.chainId&&n.includes(e.chainId)?e.chainId:u},[e.chainId,n]),s=F.useMemo(()=>Wn(e.partner,r),[e.partner,r]),i=rc(e),o=F.useMemo(()=>Kr(e.minChunkSizeUsd),[e.minChunkSizeUsd]);return F.useEffect(()=>{fe.init(s,o,r)},[s,r,o]),H.jsxs(ks.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: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(nc,{...e}),H.jsx(Vo,{children:H.jsx(ec,{children:e.children})})]})},ic=e=>H.jsx(fo,{client:tc,children:H.jsx(sc,{...e})}),q=()=>{const e=F.useContext(ks);if(e===null)throw new Error("useSpotContext must be used within SpotProvider");return e},ac=(e,t,n)=>{const r=En();return F.useMemo(()=>e==null?void 0:e.map(s=>({rawFill: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:Lt(s.txHash,r==null?void 0:r.id),executionRate:Hn(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])},oc=(e,t,n)=>{const{config:r}=q(),s=Po(t,n,e),i=Do(t,n,e),o=Oo(t,n,e),u=F.useMemo(()=>e?e.version===2?e.fillDelay:r.twapConfig?Kn(e,r.twapConfig):0:0,[e,r]),f=ac(e==null?void 0:e.fills,t,n)??[];return F.useMemo(()=>{if(e!=null&&e.id)return{original:e,fills:f,srcToken:t,dstToken:n,orderType:e.type,createdAt:e.createdAt,deadline:e.deadline||0,totalTrades:e.totalTradesAmount||0,tradeInterval:u,recipient:e.maker||"",srcAmount:e.srcAmount||"",srcAmountUI:Ee(e.srcAmount,t==null?void 0:t.decimals),limitPrice:rt(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:rt(i,n==null?void 0:n.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,n==null?void 0:n.decimals),progress:e.progress,executionPrice:rt(o,n==null?void 0:n.decimals),executionPriceUI:o,version:e.version}},[e,f,t,n,u,s,i,o])};zi(ma.version),I.DISCLAIMER_URL=di,I.Disclaimer=en,I.InputErrors=me,I.Module=j,I.ORBS_LOGO=ci,I.ORBS_SLTP_FAQ_URL=oi,I.ORBS_TWAP_FAQ_URL=ai,I.ORBS_WEBSITE_URL=ui,I.OrderFilter=Pr,I.OrderStatus=pe,I.OrderType=X,I.Partners=Be,I.SPOT_VERSION=fn,I.SpotProvider=ic,I.Steps=nt,I.SwapStatus=xe,I.TimeUnit=Pe,I.buildRePermitOrderData=Hr,I.ensureWrappedToken=Yr,I.eqIgnoreCase=gt,I.getConfig=Wn,I.getExplorerUrl=Lt,I.getMinChunkSizeUsd=Kr,I.getNetwork=Et,I.getOrderExecutionRate=Hn,I.getOrderFillDelayMillis=Kn,I.getOrderLimitPriceRate=Lr,I.getOrderType=Ta,I.getPartnerChains=Rr,I.getPartners=qr,I.getTriggerPriceRate=Nr,I.isNativeAddress=Rt,I.isTxRejected=Gn,I.millisToDays=Xn,I.millisToMinutes=An,I.networks=ye,I.parseError=ba,I.shouldUnwrapOnly=Yn,I.shouldWrapOnly=Zn,I.submitOrder=zr,I.toAmountUi=Ee,I.toAmountWei=rt,I.useAmountUi=bt,I.useCancelOrder=jo,I.useDerivedHistoryOrder=oc,I.useExplorerLink=wa,I.useNetwork=En,I.useSignOrder=Ps,I.useSpot=Go,I.useSubmitOrder=Os,I.useSwapExecution=nn,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})}));