const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`./caseInsensitive.utils.cjs`),r=require(`../../constants/token-data/ERC20Registry.cjs`);require(`../../constants/token-data/index.cjs`);const i=require(`../web3/etherFunctions.cjs`),a=require(`../../data-structures/custom-token-registry/CustomTokenRegistry.cjs`),o=require(`./amounts.utils.cjs`),s=require(`../../constants/tokens.constants.cjs`);var c=e=>{let t=r.getERC20Registry(e),n=a.customTokenRegistry.getCustomTokens(e);return[...t,...n]},l=(e,t,n)=>(n??c(t))?.find(t=>e===void 0?!1:t.erc20TokenAddress.toLowerCase()===e.toLowerCase()),u=(e,t)=>{let n=l(e.erc20TokenAddress,t);return n?{...e,name:n.name,symbol:n.symbol,logoURI:n.logoURI,decimals:n.decimals}:e},d=(e,t)=>c(t)?.find(t=>e===void 0?!1:t.symbol.toLowerCase()===e.toLowerCase()),f=e=>{let t=e.reduce((e,{amount:t,token:n,nftIds:r})=>{let i=n.erc20TokenAddress.toLowerCase();return e[i]?e[i].amount+=t:e[i]={amount:t,token:n,nftIds:r},e},{});return Object.values(t)},p=e=>f(e).map(({amount:e,token:t,nftIds:n})=>{if(e===0n)return;let r=e>0n?`+`:`-`,a=Number(i.getAmountInToken(t,e));return{token:t,amount:`${r}${o.fixDecimalsAmount(a>0?a:-a)}`,nftIds:n}}).filter(e=>!!e),m=e=>e.nftTokenType===t.TokenType.ERC721||e.nftTokenType===t.TokenType.ERC1155||e.nftTokenType===t.TokenType.MetaplexNFT||e.nftTokenType===t.TokenType.Token2022NFT||e.nftTokenType===t.TokenType.CompressedNFT,h=n=>n.chainId===e.chainIds.arcTestnet&&n.erc20TokenAddress===t.zeroAddress,g=(e,t)=>{let n=t.toLowerCase();return e.symbol.toLowerCase().includes(n)||e.name.toLowerCase().includes(n)||e.erc20TokenAddress.toLowerCase().startsWith(n)},_=e=>s.chainNativeTokenSymbol[e.chainId]===e.symbol,v=e=>{let t=e.filter(_),n=e.filter(e=>!_(e)&&s.PopularTokenSymbols.some(t=>t===e.symbol)),r=e.filter(e=>!_(e)&&!s.PopularTokenSymbols.some(t=>t===e.symbol)),i=n.sort((e,t)=>e.symbol.localeCompare(t.symbol,`en-US`)),a=r.sort((e,t)=>e.symbol.localeCompare(t.symbol,`en-US`));return[...t,...i,...a]},y=(e,t)=>e.find(e=>n.caseInsensitiveEqual(e.symbol,t));exports.aggregateTokenChanges=f,exports.findTokenBySymbolFromTokenList=y,exports.formatTokenChangesList=p,exports.getERC20Token=l,exports.getERC20TokenBySymbol=d,exports.getErc20TokensForChain=c,exports.isArcNativeToken=h,exports.isNFTToken=m,exports.overlayTokenWithRegistryData=u,exports.searchCompareFunction=g,exports.sortTokens=v;