import{w as t,p as e,q as s}from"./index-HPMvGIkW.js";function r(r){const{requestUrl:n,httpStatus:o,responseContentType:a,responseBodySnippet:p,error:i}=r,c="string"==typeof a&&a.toLowerCase().includes("text/html");t(t=>{t.setTag("api_call",!0),t.setTag("http_status",String(o)),t.setExtras({request_url:n,response_content_type:a,html_fallback_suspeito:c,response_body_snippet:p}),i instanceof Error?e(i):s(`apiFetch falhou: ${n} (${o})`,"error")})}async function n(t,e){const s=function(t){try{if("string"==typeof t)return t;if(t instanceof URL)return t.toString();if(t instanceof Request)return t.url}catch{}return String(t)}(t);let n;try{n=await fetch(t,e)}catch(o){throw r({requestUrl:s,httpStatus:"sem-resposta",responseContentType:null,error:o}),o}if(n.status>=500){const t=n.headers.get("content-type");let e;try{e=(await n.clone().text()).slice(0,500)}catch{e=void 0}r({requestUrl:s,httpStatus:n.status,responseContentType:t,responseBodySnippet:e})}return n}export{n as a};