var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/sdk/api/index.ts
var api_exports = {};
__export(api_exports, {
  RestApiService: () => RestApiService
});
module.exports = __toCommonJS(api_exports);

// src/sdk/api/restApi.service.ts
var import_cross_fetch = __toESM(require("cross-fetch"));
var import_qs = __toESM(require("qs"));

// src/sdk/api/constants.ts
var BACKEND_API_ENDPOINT = "https://rpc.etherspot.io/data-api";

// src/sdk/api/restApi.service.ts
var RestApiService = class {
  async makeRequest(endpoint, method = "GET", queryParams = {}, body = null) {
    const queryString = import_qs.default.stringify(this.buildQueryParams(queryParams), { indices: false });
    const url = new URL(`${BACKEND_API_ENDPOINT}/${endpoint}?${queryString}`);
    const requestOptions = {
      method,
      headers: {
        "Content-Type": "application/json"
      },
      body: body ? JSON.stringify(body) : null
    };
    try {
      const response = await (0, import_cross_fetch.default)(url.toString(), requestOptions);
      const data = await response.json();
      if (!response.ok) {
        if (response.status === 403) {
          throw new Error("Invalid API Key");
        }
        throw new Error(data.message || data.error || "Request failed");
      }
      return data;
    } catch (error) {
      throw new Error(error.message || "Something went wrong");
    }
  }
  buildQueryParams(params) {
    const queryParams = {};
    for (const key in params) {
      if (params.hasOwnProperty(key) && params[key] !== void 0 && params[key] !== null) {
        queryParams[key] = params[key];
      }
    }
    return queryParams;
  }
};
//# sourceMappingURL=index.js.map