const f = (c, e, i = !1) => new Promise((n, a) => {
  fetch(c, {
    headers: {
      Accept: "application/json",
      "Content-Type": "application/json"
    },
    method: "POST",
    body: JSON.stringify(e)
  }).then(
    function(t) {
      t.status !== 200 && a(t), i && n(t.blob()), t.json().then(function(o) {
        n(o);
      }).catch(() => n(t.status));
    }
  ).catch(function(t) {
    a(t);
  });
}), p = async (c, e = {}, i = !1) => {
  try {
    const { headers: n, ...a } = e, t = await fetch(c, {
      headers: {
        Accept: "application/json",
        "Content-Type": "application/json",
        ...n
      },
      ...a
    });
    if (!t.ok)
      throw t;
    const o = await t.json();
    if (i) {
      const s = {};
      return t.headers.forEach((r, h) => {
        s[h] = r;
      }), { data: o, meta: s };
    }
    return o;
  } catch (n) {
    throw n;
  }
};
export {
  p as get,
  f as post
};
