'use client'
'use strict';

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

var _tslib = require('../../../../../_virtual/_tslib.cjs');
var utils = require('@dynamic-labs/utils');
require('@dynamic-labs-sdk/client/core');
require('@dynamic-labs/sdk-api-core');
require('react');
require('eventemitter3');
require('@dynamic-labs-sdk/client');
var ApiEndpoint = require('../../../config/ApiEndpoint.cjs');
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 getMinAuthToken = require('../../../client/extension/functions/getMinAuthToken/getMinAuthToken.cjs');
require('@dynamic-labs/multi-wallet');
require('react-international-phone');
require('../../../store/state/nonce/nonce.cjs');
require('@dynamic-labs-wallet/browser-wallet-client');
var randomString = require('../../../utils/functions/randomString/randomString.cjs');
require('@dynamic-labs/locale');
require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
require('../../../utils/functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');

/**
 * Fetch the curated Aleo token price list for the given network. The
 * endpoint returns every curated token regardless of balance, so this
 * works as the price source for the Shielded balance tab — which never
 * goes through the multichain `/accountBalances` pipeline.
 *
 * Auth + base URL mirror the OpenAPI-generated `sdkApi`. We don't go
 * through `sdkApi` here because this endpoint isn't in the OpenAPI
 * surface yet; a manual fetch keeps the dynamic-auth side small and
 * focused, and the auth token / device-fingerprint headers are still
 * picked up via `getApiHeaders` + `getMinAuthToken`.
 */
const getAleoCuratedPrices = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ environmentId, network, }) {
    var _b, _c;
    const basePath = ApiEndpoint.getBaseUrl();
    if (!basePath)
        return [];
    // `basePath` already includes the `/api/v0` prefix (set on the
    //  generated `Configuration().basePath`), so this path is just the
    //  relative SDK route.
    const url = `${basePath}/sdk/${encodeURIComponent(environmentId)}/chains/aleo/prices?network=${encodeURIComponent(network)}`;
    const headers = Object.assign({ 'Content-Type': 'application/json', 'x-dyn-request-id': randomString.randomString(50) }, getApiHeaders.getApiHeaders());
    const jwt = getMinAuthToken.getMinAuthToken();
    if (jwt) {
        headers.Authorization = `Bearer ${jwt}`;
    }
    const response = yield utils.FetchService.fetch(url, {
        headers,
        method: 'GET',
    });
    if (!response.ok) {
        throw new Error(`getAleoCuratedPrices: ${response.status} ${response.statusText}`);
    }
    const data = (yield response.json());
    return (_c = (_b = data === null || data === void 0 ? void 0 : data.result) === null || _b === void 0 ? void 0 : _b.prices) !== null && _c !== void 0 ? _c : [];
});

exports.getAleoCuratedPrices = getAleoCuratedPrices;
