{
  "version": 3,
  "sources": ["../../../src/apiCalls/utils/axiosInstance.ts"],
  "sourcesContent": ["import { buildAxiosFetch } from '@lifeomic/axios-fetch';\nimport axios, { AxiosRequestConfig, AxiosResponse } from 'axios';\n\ntype RequestInit = {\n  method?: string;\n  headers?: Record<string, string>;\n  body?: string;\n  [key: string]: any;\n};\n\n// Needs to be used because an async call made after cross-window user interaction makes the dapp unresponsive\n\nconst fetch = buildAxiosFetch(axios);\n\nconst getFormattedAxiosResponse = async <T>(response: Response, config?: T) => {\n  if (!response.ok) {\n    throw new Error(`HTTP error! Status: ${response.status}`);\n  }\n\n  // Clone the response to be able to read it twice (for status and data)\n  const clonedResponse = response.clone();\n\n  // Parse the JSON body asynchronously\n  const jsonPromise = clonedResponse.json();\n\n  // Return the standardized response object\n  const [responseData] = await Promise.all([jsonPromise]);\n  return {\n    data: responseData,\n    status: response.status,\n    statusText: response.statusText,\n    headers: response.headers,\n    config\n  };\n};\n\nasync function customGet<T = any, R = AxiosResponse<T, any>, D = any>(\n  url: string,\n  config?: AxiosRequestConfig<D> | undefined\n): Promise<R> {\n  try {\n    const response = await fetch(url, config as RequestInit);\n    if (!response.ok) {\n      throw new Error(`HTTP error! Status: ${response.status}`);\n    }\n\n    return getFormattedAxiosResponse(response, config) as unknown as Promise<R>;\n  } catch (error) {\n    console.error('Fetch Error:', error);\n    throw error;\n  }\n}\n\n/*\n// Implement post and patch methods only if needed\nasync function customPost<T = any, R = AxiosResponse<T, any>, D = any>(\n  url: string,\n  data?: D,\n  config?: AxiosRequestConfig<D> | undefined\n): Promise<R> {\n  try {\n    const response = await fetch(url, {\n      method: 'POST',\n      body: data ? JSON.stringify(data) : undefined,\n      headers: {\n        'Content-Type': 'application/json',\n        ...(config?.headers || {})\n      },\n      ...config\n    } as RequestInit);\n\n    return getFormattedAxiosResponse(response, config) as unknown as Promise<R>;\n  } catch (error) {\n    console.error('Fetch Error:', error);\n    throw error;\n  }\n}\n\nasync function customPatch<T = any, R = AxiosResponse<T, any>, D = any>(\n  url: string,\n  data?: D,\n  config?: AxiosRequestConfig<D> | undefined\n): Promise<R> {\n  try {\n    const response = await fetch(url, {\n      method: 'PATCH',\n      body: data ? JSON.stringify(data) : undefined,\n      headers: config?.headers || {},\n      ...config\n    } as RequestInit);\n\n    if (!response.ok) {\n      throw new Error(`HTTP error! Status: ${response.status}`);\n    }\n\n    return getFormattedAxiosResponse(response, config) as unknown as Promise<R>;\n  } catch (error) {\n    console.error('Fetch Error:', error);\n    throw error;\n  }\n}\naxiosInstance.post = customPost;\naxiosInstance.patch = customPatch;\n*/\n\nconst axiosInstance = axios.create();\naxiosInstance.get = customGet;\n\nexport { axiosInstance };\n"],
  "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,iCAChCC,EAAyD,oBAWzD,MAAMC,KAAQ,mBAAgB,EAAAC,OAAK,EAE7BC,EAA4B,MAAUC,EAAoBC,IAAe,CAC7E,GAAI,CAACD,EAAS,GACZ,MAAM,IAAI,MAAM,uBAAuBA,EAAS,MAAM,EAAE,EAO1D,MAAME,EAHiBF,EAAS,MAAM,EAGH,KAAK,EAGlC,CAACG,CAAY,EAAI,MAAM,QAAQ,IAAI,CAACD,CAAW,CAAC,EACtD,MAAO,CACL,KAAMC,EACN,OAAQH,EAAS,OACjB,WAAYA,EAAS,WACrB,QAASA,EAAS,QAClB,OAAAC,CACF,CACF,EAEA,eAAeG,EACbC,EACAJ,EACY,CACZ,GAAI,CACF,MAAMD,EAAW,MAAMH,EAAMQ,EAAKJ,CAAqB,EACvD,GAAI,CAACD,EAAS,GACZ,MAAM,IAAI,MAAM,uBAAuBA,EAAS,MAAM,EAAE,EAG1D,OAAOD,EAA0BC,EAAUC,CAAM,CACnD,OAASK,EAAO,CACd,cAAQ,MAAM,eAAgBA,CAAK,EAC7BA,CACR,CACF,CAsDA,MAAMb,EAAgB,EAAAK,QAAM,OAAO,EACnCL,EAAc,IAAMW",
  "names": ["axiosInstance_exports", "__export", "axiosInstance", "__toCommonJS", "import_axios_fetch", "import_axios", "fetch", "axios", "getFormattedAxiosResponse", "response", "config", "jsonPromise", "responseData", "customGet", "url", "error"]
}
