'use strict';

var KHVGLVR5_cjs = require('./KHVGLVR5.cjs');
var initia_js = require('@initia/initia.js');
var stellarSdk = require('@stellar/stellar-sdk');
var bs58 = require('bs58');
var commonChainModel = require('@layerzerolabs/common-chain-model');
var commonEncodingUtils = require('@layerzerolabs/common-encoding-utils');
var commonTon = require('@layerzerolabs/common-ton');
var layerzeroDefinitions = require('@layerzerolabs/layerzero-definitions');
var staticChainInfo = require('@layerzerolabs/static-chain-info');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var bs58__default = /*#__PURE__*/_interopDefault(bs58);

// src/addressParser.ts
KHVGLVR5_cjs.init_cjs_shims();
var AddressEncoding = /* @__PURE__ */ (function(AddressEncoding2) {
  AddressEncoding2["HEX"] = "hex";
  AddressEncoding2["BASE58"] = "base58";
  AddressEncoding2["TON"] = "ton";
  AddressEncoding2["INITIA"] = "initia";
  AddressEncoding2["STELLAR"] = "stellar";
  return AddressEncoding2;
})({});
function addressParser(chainName) {
  if (chainName === layerzeroDefinitions.ChainName.TON) return tonAddressParser(chainName);
  if (chainName === layerzeroDefinitions.ChainName.SOLANA) return base58AddressParser(chainName);
  if (chainName === layerzeroDefinitions.ChainName.INITIA) return initiaAddressParser(chainName);
  if (chainName === layerzeroDefinitions.ChainName.STELLAR) return stellarAddressParser(chainName);
  if (chainName === layerzeroDefinitions.ChainName.STARKNET) return starknetAddressParser(chainName);
  return hexAddressParser(chainName);
}
KHVGLVR5_cjs.__name(addressParser, "addressParser");
(function(addressParser2) {
  addressParser2.normalizedToUnpaddedString = (address) => {
    return address.toString();
  };
  addressParser2.normalizedToBigInt = (address) => {
    return BigInt(address);
  };
  addressParser2.parseNative = (nativeAddress) => {
    return addressParser2(nativeAddress.chainName).parseNative(nativeAddress.nativeAddress);
  };
})(addressParser || (addressParser = {}));
function assertNative(nativeAddress, expectedChainName) {
  if (!addressParser(expectedChainName).validateNative(nativeAddress)) {
    throw new Error('Cannot convert: "' + nativeAddress + '" - The native address does not match the expected format for the chain: ' + expectedChainName);
  }
}
KHVGLVR5_cjs.__name(assertNative, "assertNative");
var getAddress = /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
  return typeof nativeAddress === "object" ? nativeAddress.nativeAddress : nativeAddress;
}, "getAddress");
var tonAddressParser = /* @__PURE__ */ KHVGLVR5_cjs.__name((chainName) => {
  return {
    validateNative: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) {
        return false;
      }
      try {
        commonTon.parseTonAddress(nativeAddress);
        return true;
      } catch {
        return false;
      }
    }, "validateNative"),
    normalizedToNative: /* @__PURE__ */ KHVGLVR5_cjs.__name((address) => {
      if (address === void 0) return void 0;
      const numericalValue = addressParser.normalizedToBigInt(address);
      return {
        // FIXME this is wrong
        nativeAddress: commonTon.bigintToAddress(numericalValue).toString(),
        chainName
      };
    }, "normalizedToNative"),
    normalizedToNativeString: /* @__PURE__ */ KHVGLVR5_cjs.__name((address) => {
      if (address === void 0) return void 0;
      return addressParser(chainName).normalizedToNative(address).nativeAddress;
    }, "normalizedToNativeString"),
    nativeToNormalized: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) return void 0;
      const address = getAddress(nativeAddress);
      assertNative(address, chainName);
      return commonChainModel.normalizeHex(commonTon.addressToHex(address));
    }, "nativeToNormalized"),
    nativeToBytes32Hex: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) return void 0;
      return commonEncodingUtils.hexZeroPad(addressParser(chainName).nativeToNormalized(nativeAddress), 32);
    }, "nativeToBytes32Hex"),
    nativeToBytes: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) return void 0;
      return commonEncodingUtils.hexToBytes(addressParser(chainName).nativeToBytes32Hex(nativeAddress));
    }, "nativeToBytes"),
    nativeToBytes32: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) return void 0;
      return commonEncodingUtils.hexToBytes(addressParser(chainName).nativeToBytes32Hex(nativeAddress));
    }, "nativeToBytes32"),
    normalizedToBytes32Hex: /* @__PURE__ */ KHVGLVR5_cjs.__name((address) => {
      if (address === void 0) return void 0;
      return commonEncodingUtils.hexZeroPad(address, 32);
    }, "normalizedToBytes32Hex"),
    normalizedToBytes32: /* @__PURE__ */ KHVGLVR5_cjs.__name((address) => {
      if (address === void 0) return void 0;
      return commonEncodingUtils.hexToBytes(addressParser(chainName).normalizedToBytes32Hex(address));
    }, "normalizedToBytes32"),
    bytes32ToNormalized: /* @__PURE__ */ KHVGLVR5_cjs.__name((bytes32Hex) => {
      if (bytes32Hex === void 0) return void 0;
      return commonChainModel.normalizeHex(bytes32Hex);
    }, "bytes32ToNormalized"),
    parseNative: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      assertNative(nativeAddress, chainName);
      return addressParser(chainName).nativeToNormalized(nativeAddress);
    }, "parseNative"),
    parseNativeToUnpaddedHex: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      return addressParser(chainName).parseNative(nativeAddress);
    }, "parseNativeToUnpaddedHex"),
    tonToNormalized: /* @__PURE__ */ KHVGLVR5_cjs.__name((tonAddress) => {
      return addressParser(chainName).parseNative(commonTon.addressToHex(tonAddress));
    }, "tonToNormalized"),
    encoding: "ton"
  };
}, "tonAddressParser");
var initiaAddressParser = /* @__PURE__ */ KHVGLVR5_cjs.__name((chainName) => {
  return {
    validateNative: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) {
        return false;
      }
      try {
        return commonEncodingUtils.isHexString(nativeAddress) || /^(init)1(['qpzry9x8gf2tvdw0s3jn54khce6mua7l]{38,66})$/.test(nativeAddress);
      } catch {
        return false;
      }
    }, "validateNative"),
    normalizedToNative: /* @__PURE__ */ KHVGLVR5_cjs.__name((address) => {
      if (address === void 0) {
        return void 0;
      }
      return {
        nativeAddress: initia_js.AccAddress.fromHex(address),
        chainName
      };
    }, "normalizedToNative"),
    normalizedToNativeString: /* @__PURE__ */ KHVGLVR5_cjs.__name((address) => {
      if (address === void 0) return void 0;
      return addressParser(chainName).normalizedToNative(address).nativeAddress;
    }, "normalizedToNativeString"),
    nativeToNormalized: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) return void 0;
      const address = getAddress(nativeAddress);
      assertNative(address, chainName);
      if (commonEncodingUtils.isHexString(address)) {
        return commonChainModel.normalizeHex(address);
      }
      return commonChainModel.normalizeHex(initia_js.AccAddress.toHex(nativeAddress.toString()));
    }, "nativeToNormalized"),
    nativeToBytes32Hex: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) return void 0;
      return commonEncodingUtils.hexZeroPad(addressParser(chainName).nativeToNormalized(nativeAddress), 32);
    }, "nativeToBytes32Hex"),
    nativeToBytes: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) return void 0;
      return commonEncodingUtils.hexToBytes(addressParser(chainName).nativeToBytes32Hex(nativeAddress));
    }, "nativeToBytes"),
    nativeToBytes32: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) return void 0;
      return commonEncodingUtils.hexToBytes(addressParser(chainName).nativeToBytes32Hex(nativeAddress));
    }, "nativeToBytes32"),
    normalizedToBytes32Hex: /* @__PURE__ */ KHVGLVR5_cjs.__name((address) => {
      if (address === void 0) return void 0;
      return commonEncodingUtils.hexZeroPad(address, 32);
    }, "normalizedToBytes32Hex"),
    normalizedToBytes32: /* @__PURE__ */ KHVGLVR5_cjs.__name((address) => {
      if (address === void 0) return void 0;
      return commonEncodingUtils.hexToBytes(addressParser(chainName).normalizedToBytes32Hex(address));
    }, "normalizedToBytes32"),
    bytes32ToNormalized: /* @__PURE__ */ KHVGLVR5_cjs.__name((bytes32Hex) => {
      if (bytes32Hex === void 0) return void 0;
      return commonChainModel.normalizeHex(bytes32Hex);
    }, "bytes32ToNormalized"),
    parseNative: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      assertNative(nativeAddress, chainName);
      return addressParser(chainName).nativeToNormalized(nativeAddress);
    }, "parseNative"),
    parseNativeToUnpaddedHex: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      return addressParser(chainName).parseNative(nativeAddress);
    }, "parseNativeToUnpaddedHex"),
    encoding: "initia"
  };
}, "initiaAddressParser");
var base58AddressParser = /* @__PURE__ */ KHVGLVR5_cjs.__name((chainName) => {
  return {
    validateNative: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) return false;
      return commonEncodingUtils.isBase58(nativeAddress);
    }, "validateNative"),
    normalizedToNative: /* @__PURE__ */ KHVGLVR5_cjs.__name((address) => {
      if (address === void 0) return void 0;
      return {
        nativeAddress: bs58__default.default.encode(commonEncodingUtils.hexToBytes(address)),
        chainName
      };
    }, "normalizedToNative"),
    normalizedToNativeString: /* @__PURE__ */ KHVGLVR5_cjs.__name((address) => {
      if (address === void 0) return void 0;
      return addressParser(chainName).normalizedToNative(address).nativeAddress;
    }, "normalizedToNativeString"),
    nativeToNormalized: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) return void 0;
      const address = getAddress(nativeAddress);
      assertNative(address, chainName);
      const hex = commonEncodingUtils.bytesToHexPrefixed(bs58__default.default.decode(address));
      return commonChainModel.normalizeHex(hex);
    }, "nativeToNormalized"),
    nativeToBytes32Hex: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) return void 0;
      return commonEncodingUtils.hexZeroPad(addressParser(chainName).nativeToNormalized(nativeAddress), 32);
    }, "nativeToBytes32Hex"),
    nativeToBytes: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) return void 0;
      const address = getAddress(nativeAddress);
      assertNative(address, chainName);
      return bs58__default.default.decode(address);
    }, "nativeToBytes"),
    nativeToBytes32: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) return void 0;
      return commonEncodingUtils.hexToBytes(addressParser(chainName).nativeToBytes32Hex(nativeAddress));
    }, "nativeToBytes32"),
    normalizedToBytes32Hex: /* @__PURE__ */ KHVGLVR5_cjs.__name((address) => {
      if (address === void 0) return void 0;
      return commonEncodingUtils.hexZeroPad(address, 32);
    }, "normalizedToBytes32Hex"),
    normalizedToBytes32: /* @__PURE__ */ KHVGLVR5_cjs.__name((address) => {
      if (address === void 0) return void 0;
      return commonEncodingUtils.hexToBytes(addressParser(chainName).normalizedToBytes32Hex(address));
    }, "normalizedToBytes32"),
    bytes32ToNormalized: /* @__PURE__ */ KHVGLVR5_cjs.__name((bytes32Hex) => {
      if (bytes32Hex === void 0) return void 0;
      return commonChainModel.normalizeHex(bytes32Hex);
    }, "bytes32ToNormalized"),
    parseNative: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      assertNative(nativeAddress, chainName);
      return addressParser(chainName).nativeToNormalized(nativeAddress);
    }, "parseNative"),
    parseNativeToUnpaddedHex: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      return addressParser(chainName).parseNative(nativeAddress);
    }, "parseNativeToUnpaddedHex"),
    encoding: "base58"
  };
}, "base58AddressParser");
var hexAddressParser = /* @__PURE__ */ KHVGLVR5_cjs.__name((chainName) => {
  return {
    validateNative: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) return false;
      return commonEncodingUtils.isHexString(nativeAddress);
    }, "validateNative"),
    normalizedToNative: /* @__PURE__ */ KHVGLVR5_cjs.__name((address) => {
      if (address === void 0) return void 0;
      const nativeByteLength = staticChainInfo.StaticChainConfigs.getAddressSizeInBytes(chainName);
      return {
        // we could have EIP-55 here, but omitted for now
        nativeAddress: commonEncodingUtils.hexZeroPad(address, nativeByteLength),
        chainName
      };
    }, "normalizedToNative"),
    normalizedToNativeString: /* @__PURE__ */ KHVGLVR5_cjs.__name((address) => {
      if (address === void 0) return void 0;
      const nativeByteLength = staticChainInfo.StaticChainConfigs.getAddressSizeInBytes(chainName);
      return commonEncodingUtils.hexZeroPad(address, nativeByteLength);
    }, "normalizedToNativeString"),
    nativeToNormalized: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) return void 0;
      const address = getAddress(nativeAddress);
      assertNative(address, chainName);
      return commonChainModel.normalizeHex(address);
    }, "nativeToNormalized"),
    nativeToBytes: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) return void 0;
      const address = getAddress(nativeAddress);
      assertNative(address, chainName);
      return commonEncodingUtils.hexToBytes(address);
    }, "nativeToBytes"),
    nativeToBytes32Hex: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) return void 0;
      const address = getAddress(nativeAddress);
      assertNative(address, chainName);
      return commonEncodingUtils.hexZeroPad(address, 32);
    }, "nativeToBytes32Hex"),
    nativeToBytes32: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) return void 0;
      return commonEncodingUtils.hexToBytes(addressParser(chainName).nativeToBytes32Hex(nativeAddress));
    }, "nativeToBytes32"),
    normalizedToBytes32Hex: /* @__PURE__ */ KHVGLVR5_cjs.__name((address) => {
      if (address === void 0) return void 0;
      return commonEncodingUtils.hexZeroPad(address, 32);
    }, "normalizedToBytes32Hex"),
    normalizedToBytes32: /* @__PURE__ */ KHVGLVR5_cjs.__name((address) => {
      if (address === void 0) return void 0;
      return commonEncodingUtils.hexToBytes(addressParser(chainName).normalizedToBytes32Hex(address));
    }, "normalizedToBytes32"),
    bytes32ToNormalized: /* @__PURE__ */ KHVGLVR5_cjs.__name((bytes32Hex) => {
      if (bytes32Hex === void 0) return void 0;
      return commonChainModel.normalizeHex(bytes32Hex);
    }, "bytes32ToNormalized"),
    parseNative: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (chainName === layerzeroDefinitions.ChainName.TRON && nativeAddress) {
        nativeAddress = nativeAddress.startsWith("41") ? `0x${nativeAddress.slice(2)}` : nativeAddress;
      }
      assertNative(nativeAddress, chainName);
      return addressParser(chainName).nativeToNormalized(nativeAddress);
    }, "parseNative"),
    parseNativeToUnpaddedHex: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      return addressParser(chainName).parseNative(nativeAddress);
    }, "parseNativeToUnpaddedHex"),
    encoding: "hex"
  };
}, "hexAddressParser");
var BYTES32_HEX_LENGTH = 64;
var hexToStellarNative = /* @__PURE__ */ KHVGLVR5_cjs.__name((address) => {
  if (!address || !address.startsWith("0x") || !commonEncodingUtils.isHexString(address)) return address;
  const hexPayload = address.slice(2);
  if (hexPayload.length !== BYTES32_HEX_LENGTH) {
    throw new Error(`Stellar hex address must be exactly 32 bytes (${BYTES32_HEX_LENGTH} hex chars), got ${hexPayload.length}: ${address}`);
  }
  const raw = Buffer.from(hexPayload, "hex");
  return stellarSdk.StrKey.encodeContract(raw);
}, "hexToStellarNative");
var stellarAddressParser = /* @__PURE__ */ KHVGLVR5_cjs.__name((chainName) => {
  const isValidStellarAddress = /* @__PURE__ */ KHVGLVR5_cjs.__name((address) => {
    if (!address) return false;
    return stellarSdk.StrKey.isValidEd25519PublicKey(address) || stellarSdk.StrKey.isValidContract(address) || stellarSdk.StrKey.isValidMed25519PublicKey(address) || stellarSdk.StrKey.isValidLiquidityPool(address) || stellarSdk.StrKey.isValidClaimableBalance(address) || stellarSdk.StrKey.isValidSignedPayload(address);
  }, "isValidStellarAddress");
  const stellarTextEncoder = new TextEncoder();
  const stellarAsciiToNormalized = /* @__PURE__ */ KHVGLVR5_cjs.__name((address) => {
    const bytes = stellarTextEncoder.encode(address);
    return commonChainModel.normalizeHex(commonEncodingUtils.bytesToHexPrefixed(bytes));
  }, "stellarAsciiToNormalized");
  const stellarTextDecoder = new TextDecoder();
  const normalizedToStellarAscii = /* @__PURE__ */ KHVGLVR5_cjs.__name((normalizedHex) => {
    const bytes = commonEncodingUtils.hexToBytes(normalizedHex);
    return stellarTextDecoder.decode(bytes);
  }, "normalizedToStellarAscii");
  return {
    validateNative: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) return false;
      return isValidStellarAddress(nativeAddress);
    }, "validateNative"),
    normalizedToNative: /* @__PURE__ */ KHVGLVR5_cjs.__name((address) => {
      if (address === void 0) return void 0;
      const stellarAddress = normalizedToStellarAscii(address);
      return {
        nativeAddress: stellarAddress,
        chainName
      };
    }, "normalizedToNative"),
    normalizedToNativeString: /* @__PURE__ */ KHVGLVR5_cjs.__name((address) => {
      if (address === void 0) return void 0;
      return normalizedToStellarAscii(address);
    }, "normalizedToNativeString"),
    nativeToNormalized: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) return void 0;
      const address = getAddress(nativeAddress);
      assertNative(address, chainName);
      return stellarAsciiToNormalized(address);
    }, "nativeToNormalized"),
    nativeToBytes32Hex: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) return void 0;
      const address = getAddress(nativeAddress);
      assertNative(address, chainName);
      let rawBytes;
      if (stellarSdk.StrKey.isValidEd25519PublicKey(address)) {
        rawBytes = stellarSdk.StrKey.decodeEd25519PublicKey(address);
      } else if (stellarSdk.StrKey.isValidContract(address)) {
        rawBytes = stellarSdk.StrKey.decodeContract(address);
      } else if (stellarSdk.StrKey.isValidLiquidityPool(address)) {
        rawBytes = stellarSdk.StrKey.decodeLiquidityPool(address);
      } else if (stellarSdk.StrKey.isValidClaimableBalance(address)) {
        const fullBytes = stellarSdk.StrKey.decodeClaimableBalance(address);
        rawBytes = fullBytes.subarray(1);
      } else if (stellarSdk.StrKey.isValidMed25519PublicKey(address)) {
        throw new Error("nativeToBytes32 is not supported for Stellar muxed addresses (M...)");
      } else if (stellarSdk.StrKey.isValidSignedPayload(address)) {
        throw new Error("nativeToBytes32 is not supported for Stellar signed payload addresses (P...)");
      } else {
        throw new Error(`Unknown Stellar address type: ${address}`);
      }
      return commonEncodingUtils.bytesToHexPrefixed(rawBytes);
    }, "nativeToBytes32Hex"),
    nativeToBytes: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) return void 0;
      const address = getAddress(nativeAddress);
      assertNative(address, chainName);
      return stellarTextEncoder.encode(address);
    }, "nativeToBytes"),
    nativeToBytes32: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) return void 0;
      const hex = addressParser(chainName).nativeToBytes32Hex(nativeAddress);
      return commonEncodingUtils.hexToBytes(hex);
    }, "nativeToBytes32"),
    normalizedToBytes32Hex: /* @__PURE__ */ KHVGLVR5_cjs.__name((address) => {
      if (address === void 0) return void 0;
      return addressParser(chainName).nativeToBytes32Hex(addressParser(chainName).normalizedToNativeString(address));
    }, "normalizedToBytes32Hex"),
    normalizedToBytes32: /* @__PURE__ */ KHVGLVR5_cjs.__name((address) => {
      if (address === void 0) return void 0;
      return commonEncodingUtils.hexToBytes(addressParser(chainName).normalizedToBytes32Hex(address));
    }, "normalizedToBytes32"),
    bytes32ToNormalized: /* @__PURE__ */ KHVGLVR5_cjs.__name((bytes32Hex) => {
      if (bytes32Hex === void 0) return void 0;
      return stellarAsciiToNormalized(stellarSdk.StrKey.encodeContract(Buffer.from(commonEncodingUtils.hexToBytes(bytes32Hex))));
    }, "bytes32ToNormalized"),
    parseNative: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      nativeAddress = hexToStellarNative(nativeAddress);
      assertNative(nativeAddress, chainName);
      return addressParser(chainName).nativeToNormalized(nativeAddress);
    }, "parseNative"),
    parseNativeToUnpaddedHex: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      nativeAddress = hexToStellarNative(nativeAddress);
      assertNative(nativeAddress, chainName);
      const normalized = addressParser(chainName).nativeToNormalized(nativeAddress);
      return normalized;
    }, "parseNativeToUnpaddedHex"),
    encoding: "stellar"
  };
}, "stellarAddressParser");
var starknetAddressParser = /* @__PURE__ */ KHVGLVR5_cjs.__name((chainName) => {
  return {
    ...hexAddressParser(chainName),
    validateNative: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) return false;
      return commonEncodingUtils.isHexString(nativeAddress);
    }, "validateNative"),
    parseNative: /* @__PURE__ */ KHVGLVR5_cjs.__name((nativeAddress) => {
      if (nativeAddress === void 0) return void 0;
      nativeAddress = `0x${BigInt(nativeAddress).toString(16)}`;
      assertNative(nativeAddress, chainName);
      return addressParser(chainName).nativeToNormalized(nativeAddress);
    }, "parseNative"),
    normalizedToNative: /* @__PURE__ */ KHVGLVR5_cjs.__name((address) => {
      if (address === void 0) return void 0;
      return {
        nativeAddress: address,
        chainName
      };
    }, "normalizedToNative"),
    normalizedToNativeString: /* @__PURE__ */ KHVGLVR5_cjs.__name((address) => {
      if (address === void 0) return void 0;
      return address;
    }, "normalizedToNativeString")
  };
}, "starknetAddressParser");

exports.AddressEncoding = AddressEncoding;
exports.addressParser = addressParser;
exports.base58AddressParser = base58AddressParser;
exports.hexAddressParser = hexAddressParser;
exports.initiaAddressParser = initiaAddressParser;
exports.starknetAddressParser = starknetAddressParser;
exports.stellarAddressParser = stellarAddressParser;
exports.tonAddressParser = tonAddressParser;
//# sourceMappingURL=X46YPLVF.cjs.map
//# sourceMappingURL=X46YPLVF.cjs.map