"use strict";function parseTransactionMetadata(t){if(!t)return{};if("string"==typeof t)try{let a=t;isValidJSON(a)||(a=unescapeString(a));let r=JSON.parse(a);if("string"==typeof r)try{r=JSON.parse(r.trim())}catch(t){console_1.logger.error("WALLET","Error parsing transaction metadata on second attempt",t);return{}}return r}catch(t){console_1.logger.error("WALLET","Error parsing transaction metadata on first attempt",t);return{}}return t||{}}function parseMetadataAndMapChainToXt(t){const a=parseTransactionMetadata(t);return{metadata:a,xtChain:mapToXtNetwork(a.chain)}}function mapToXtNetwork(t){if(!t)return null;return{TRC20:"Tron",TRX:"Tron",ERC20:"Ethereum",ETH:"Ethereum",BEP20:"BNB Smart Chain",BSC:"BNB Smart Chain",BNB:"BNB Smart Chain",POLYGON:"Polygon",MATIC:"Polygon",ARBITRUM:"ARB",ARB:"ARB",OPTIMISM:"OPT",OPT:"OPT",AVAX:"AVAX C-Chain",AVALANCHE:"AVAX C-Chain",SOL:"SOL-SOL",SOLANA:"SOL-SOL",BTC:"Bitcoin",BITCOIN:"Bitcoin",LTC:"Litecoin",LITECOIN:"Litecoin",DOGE:"Dogecoin",DOGECOIN:"Dogecoin",BASE:"BASE",ETC:"Ethereum Classic",BCH:"Bitcoin Cash"}[t.toUpperCase()]||null}function isValidJSON(t){try{JSON.parse(t);return!0}catch(t){return!1}}function unescapeString(t){return t.replace(/\\"/g,'"').replace(/\\\\/g,"\\")}Object.defineProperty(exports,"__esModule",{value:!0});exports.parseTransactionMetadata=parseTransactionMetadata;exports.parseMetadataAndMapChainToXt=parseMetadataAndMapChainToXt;exports.mapToXtNetwork=mapToXtNetwork;const console_1=require("@b/utils/console");