import { extractRequestBody as p, createParameterMap as s } from "../../../libs/openapi.js";
function c(i) {
  const o = [];
  function e(d) {
    d.forEach((t) => {
      h(t, o), "children" in t && t.children && e(t.children);
    });
  }
  return e(i), o;
}
function h(i, o) {
  if ("operation" in i) {
    const e = p(i.operation) || s(i.operation), d = typeof e != "boolean" ? e : null;
    o.push({
      type: "operation",
      title: i.title,
      href: `#${i.id}`,
      id: i.operation.operationId,
      description: i.operation.description || "",
      method: i.method,
      path: i.path,
      body: d || "",
      entry: i
    });
    return;
  }
  if ("webhook" in i) {
    o.push({
      type: "webhook",
      title: i.title,
      href: `#${i.id}`,
      description: "Webhook",
      method: i.method,
      body: i.webhook.description || "",
      entry: i
    });
    return;
  }
  if ("schema" in i) {
    const e = "description" in i.schema && typeof i.schema.description == "string" ? i.schema.description : "";
    o.push({
      type: "model",
      title: i.title,
      href: `#${i.id}`,
      description: "Model",
      body: e,
      entry: i
    });
    return;
  }
  if ("tag" in i) {
    o.push({
      title: i.title,
      href: `#${i.id}`,
      description: i.tag.description || "",
      type: "tag",
      body: "",
      entry: i
    });
    return;
  }
  if ("isGroup" in i) {
    o.push({
      title: i.title,
      href: `#${i.id}`,
      description: "Tag Group",
      type: "tag",
      body: "",
      entry: i
    });
    return;
  }
  if ("isWebhooks" in i) {
    o.push({
      type: "heading",
      title: "Webhooks",
      href: `#${i.id}`,
      description: "Heading",
      body: "",
      entry: i
    });
    return;
  }
  if (i.title === "Models") {
    o.push({
      type: "heading",
      title: "Models",
      href: `#${i.id}`,
      description: "Heading",
      body: "",
      entry: i
    });
    return;
  }
  if (i.title) {
    o.push({
      type: "heading",
      title: i.title ?? "",
      description: "Description",
      href: `#${i.id}`,
      body: "",
      entry: i
    });
    return;
  }
}
export {
  c as createSearchIndex
};
