import { httpMethods as a } from "@scalar/helpers/http/http-methods";
import { getTag as m } from "./get-tag.js";
const x = (r, s, e = "Unknown", c, f, h) => {
  var t;
  const i = h({ ...r, method: s, path: e }, c), n = (t = r.summary) != null && t.trim() ? r.summary : e;
  return f.set(i, n), {
    id: i,
    title: n,
    path: e,
    method: s,
    operation: r
  };
}, O = (r, s, e, c) => {
  Object.entries(r.paths ?? {}).forEach(([f, h]) => {
    Object.entries(h ?? {}).forEach(([n, t]) => {
      var l, E;
      if (!(t["x-internal"] || t["x-scalar-ignore"] || !a.has(n)))
        if ((l = t.tags) != null && l.length)
          t.tags.forEach((u) => {
            var g;
            const { tag: y } = m(s, u);
            (g = s.get(u)) == null || g.entries.push(x(t, n, f, y, e, c));
          });
        else {
          const { tag: u } = m(s, "default");
          (E = s.get("default")) == null || E.entries.push(x(t, n, f, u, e, c));
        }
    });
  });
};
export {
  O as traversePaths
};
