import { canMethodHaveBody as m } from "@scalar/helpers/http/can-method-have-body";
import { getResolvedRef as r } from "@scalar/workspace-store/helpers/get-resolved-ref";
import { isElectron as y } from "../../../../libs/electron.js";
const l = "2.37.0", T = "application/json", C = "*/*", a = (n, s, o) => ({
  name: n,
  defaultValue: s,
  isOverridden: o.has(n.toLowerCase())
}), b = ({
  method: n,
  operation: s,
  exampleKey: o,
  hideDisabledHeaders: p = !1
}) => {
  const c = new Set(
    s.parameters?.filter((e) => r(e).in === "header").map((e) => r(e).name.toLowerCase()) ?? []
  ), f = s["x-scalar-disable-parameters"]?.["default-headers"]?.[o] ?? {}, t = [], d = r(s.requestBody);
  if (m(n)) {
    const e = d?.["x-scalar-selected-content-type"]?.[o] ?? Object.keys(d?.content ?? {})[0] ?? T;
    e !== "none" && t.push(a("Content-Type", e, c));
  }
  const i = Object.keys(s.responses ?? {}).find((e) => e.startsWith("2")), u = i ? r(s.responses[i]) : null, h = Object.keys(u?.content ?? {}).join(", ") || C;
  return t.push(a("Accept", h, c)), y() && l && t.push(a("User-Agent", `Scalar/${l}`, c)), p ? t.filter((e) => f[e.name.toLowerCase()] !== !0) : t;
};
export {
  b as getDefaultHeaders
};
