'use client'
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _tslib = require('../../../../../_virtual/_tslib.cjs');
var ApiEndpoint = require('../../../config/ApiEndpoint.cjs');
require('@dynamic-labs-sdk/client/core');
require('@dynamic-labs/sdk-api-core');
require('react');
require('eventemitter3');
require('@dynamic-labs/utils');
require('@dynamic-labs-sdk/client');
require('@dynamic-labs/iconic');
require('@dynamic-labs/wallet-connector-core');
require('react/jsx-runtime');
require('../../../context/ViewContext/ViewContext.cjs');
require('../../../shared/logger.cjs');
require('@dynamic-labs/wallet-book');
require('../../../utils/constants/colors.cjs');
require('../../../utils/constants/values.cjs');
require('../../../shared/consts/index.cjs');
var getApiHeaders = require('../../../client/extension/hooks/useInitializeSdkClient/getApiHeaders/getApiHeaders.cjs');
require('../../../events/dynamicEvents.cjs');
var api = require('../api.cjs');

const getMoonPayCurrencies = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ chain, environmentId, networkId, }) {
    var _b;
    const params = new URLSearchParams({ chain });
    if (networkId) {
        params.set('networkId', networkId);
    }
    const response = yield fetch(`${ApiEndpoint.getBaseUrl()}/sdk/${environmentId}/onramps/moonpay/currencies?${params}`, {
        headers: Object.assign({ 'Content-Type': 'application/json' }, getApiHeaders.getApiHeaders()),
    });
    if (!response.ok) {
        throw new Error('Failed to fetch MoonPay currencies');
    }
    const data = yield response.json();
    return (_b = data.currencies) !== null && _b !== void 0 ? _b : [];
});
const getOnrampProviders = (_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ chain, environmentId, networkId, token, tokenAmount, walletAddress, currency, includeDisabled, merchantName, }) {
    const { onramps } = yield api.sdkApi().getSupportedOnramps({
        chain,
        currency,
        environmentId,
        includeDisabled,
        merchantName,
        networkId: networkId ? String(networkId) : undefined,
        token,
        tokenAmount,
        walletAddress,
    });
    return onramps !== null && onramps !== void 0 ? onramps : [];
});

exports.getMoonPayCurrencies = getMoonPayCurrencies;
exports.getOnrampProviders = getOnrampProviders;
