// src/config/index.ts
var DEFAULT_ENGINE_URL = "https://api.one23.io";
var DEFAULT_CLIENT_ID = "one_pk_e8f647bfa643fdcfaa3a23f760488e49be09f929296eed4a6c399d437d907f60";
var config = null;
function initOneSDK(options) {
  const engineUrl = options.oneEngineUrl || DEFAULT_ENGINE_URL;
  const clientId = options.oneClientId || DEFAULT_CLIENT_ID;
  config = {
    ...options,
    oneEngineUrl: engineUrl,
    oneClientId: clientId
  };
}
function getConfig() {
  if (!config) {
    throw new Error("ONE SDK not initialized. Call initOneSDK() first.");
  }
  return config;
}
function isInitialized() {
  return config !== null;
}
function getEngineUrl() {
  return config?.oneEngineUrl || process.env.NEXT_PUBLIC_ONE_ENGINE_URL || DEFAULT_ENGINE_URL;
}
var chainsCache = null;
var chainsCacheTimestamp = 0;
var CACHE_TTL = 5 * 60 * 1e3;
async function fetchChains(options) {
  const engineUrl = getEngineUrl();
  const params = new URLSearchParams();
  if (options?.category) params.set("category", options.category);
  if (options?.smartWallet) params.set("smartWallet", "true");
  if (options?.limit) params.set("limit", options.limit.toString());
  const response = await fetch(`${engineUrl}/v1/chains?${params}`);
  const data = await response.json();
  if (!data.success) {
    throw new Error(data.error?.message || "Failed to fetch chains");
  }
  return data.data.chains.map((chain) => ({
    id: chain.id,
    name: chain.name,
    shortName: chain.shortName || chain.slug || chain.name.toLowerCase(),
    icon: getChainIcon(chain.id),
    nativeCurrency: chain.nativeCurrency,
    rpcUrls: Array.isArray(chain.rpc) ? chain.rpc : [chain.rpc],
    blockExplorerUrls: chain.blockExplorer ? [chain.blockExplorer] : [],
    testnet: chain.testnet
  }));
}
async function getChains() {
  const now = Date.now();
  if (chainsCache && now - chainsCacheTimestamp < CACHE_TTL) {
    return chainsCache;
  }
  chainsCache = await fetchChains({ limit: 200 });
  chainsCacheTimestamp = now;
  return chainsCache;
}
async function getChainById(chainId) {
  const chains = await getChains();
  return chains.find((c) => c.id === chainId);
}
async function getChainByName(name) {
  const chains = await getChains();
  const lowerName = name.toLowerCase();
  return chains.find(
    (c) => c.name.toLowerCase() === lowerName || c.shortName.toLowerCase() === lowerName
  );
}
async function getRecommendedChains() {
  return fetchChains({ category: "recommended", limit: 10 });
}
async function getSmartWalletChains() {
  return fetchChains({ smartWallet: true, limit: 50 });
}
var CHAIN_IDS = {
  ETHEREUM: 1,
  POLYGON: 137,
  BSC: 56,
  ARBITRUM: 42161,
  OPTIMISM: 10,
  BASE: 8453,
  AVALANCHE: 43114,
  ZKSYNC: 324,
  LINEA: 59144,
  SCROLL: 534352,
  BLAST: 81457,
  // Testnets
  SEPOLIA: 11155111,
  BASE_SEPOLIA: 84532,
  ARBITRUM_SEPOLIA: 421614
};
var DEFAULT_CHAIN_ID = CHAIN_IDS.BASE;
var CHAIN_ICONS = {
  1: "\u229F",
  // Ethereum
  137: "\u{1F7E3}",
  // Polygon
  56: "\u{1F7E1}",
  // BSC
  42161: "\u{1F535}",
  // Arbitrum
  10: "\u{1F534}",
  // Optimism
  8453: "\u{1F537}",
  // Base
  43114: "\u{1F53A}",
  // Avalanche
  324: "\u26A1",
  // zkSync
  59144: "\u{1F539}",
  // Linea
  534352: "\u{1F4DC}"
  // Scroll
};
function getChainIcon(chainId) {
  return CHAIN_ICONS[chainId] || "\u{1F517}";
}
var TOKEN_NAMES = {
  ETH: "Ethereum",
  BTC: "Bitcoin",
  BNB: "BNB",
  MATIC: "Polygon",
  POL: "Polygon",
  AVAX: "Avalanche",
  USDT: "Tether",
  USDC: "USD Coin",
  DAI: "Dai",
  WBTC: "Wrapped Bitcoin",
  WETH: "Wrapped Ether",
  ARB: "Arbitrum",
  OP: "Optimism",
  LINK: "Chainlink",
  UNI: "Uniswap",
  AAVE: "Aave",
  CRV: "Curve",
  MKR: "Maker",
  SNX: "Synthetix",
  COMP: "Compound",
  SUSHI: "SushiSwap",
  YFI: "Yearn Finance",
  SOL: "Solana",
  DOT: "Polkadot",
  ATOM: "Cosmos",
  NEAR: "Near Protocol"
};
var COINGECKO_IDS = {
  ETH: "ethereum",
  BTC: "bitcoin",
  BNB: "binancecoin",
  MATIC: "matic-network",
  POL: "matic-network",
  AVAX: "avalanche-2",
  USDT: "tether",
  USDC: "usd-coin",
  DAI: "dai",
  WBTC: "wrapped-bitcoin",
  WETH: "weth",
  ARB: "arbitrum",
  OP: "optimism",
  LINK: "chainlink",
  UNI: "uniswap",
  AAVE: "aave",
  SOL: "solana"
};
var CHAIN_CONFIGS = {
  ethereum: {
    id: 1,
    name: "Ethereum",
    shortName: "ETH",
    icon: "\u229F",
    nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
    rpcUrls: ["https://ethereum.rpc.thirdweb.com"],
    blockExplorerUrls: ["https://etherscan.io"],
    testnet: false
  },
  polygon: {
    id: 137,
    name: "Polygon",
    shortName: "MATIC",
    icon: "\u{1F7E3}",
    nativeCurrency: { name: "POL", symbol: "POL", decimals: 18 },
    rpcUrls: ["https://polygon.rpc.thirdweb.com"],
    blockExplorerUrls: ["https://polygonscan.com"],
    testnet: false
  },
  base: {
    id: 8453,
    name: "Base",
    shortName: "BASE",
    icon: "\u{1F537}",
    nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
    rpcUrls: ["https://base.rpc.thirdweb.com"],
    blockExplorerUrls: ["https://basescan.org"],
    testnet: false
  },
  arbitrum: {
    id: 42161,
    name: "Arbitrum One",
    shortName: "ARB",
    icon: "\u{1F535}",
    nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
    rpcUrls: ["https://arbitrum.rpc.thirdweb.com"],
    blockExplorerUrls: ["https://arbiscan.io"],
    testnet: false
  },
  optimism: {
    id: 10,
    name: "Optimism",
    shortName: "OP",
    icon: "\u{1F534}",
    nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
    rpcUrls: ["https://optimism.rpc.thirdweb.com"],
    blockExplorerUrls: ["https://optimistic.etherscan.io"],
    testnet: false
  }
};
var SUPPORTED_CHAINS = Object.keys(CHAIN_CONFIGS);
function getChainConfig(chain) {
  return CHAIN_CONFIGS[chain.toLowerCase()];
}

export { CHAIN_CONFIGS, CHAIN_IDS, COINGECKO_IDS, DEFAULT_CHAIN_ID, SUPPORTED_CHAINS, TOKEN_NAMES, fetchChains, getChainById, getChainByName, getChainConfig, getChains, getConfig, getEngineUrl, getRecommendedChains, getSmartWalletChains, initOneSDK, isInitialized };
//# sourceMappingURL=index.mjs.map
//# sourceMappingURL=index.mjs.map