import { defineComponent as T, computed as g, resolveComponent as b, createElementBlock as W, openBlock as i, Fragment as B, renderList as L, createBlock as t, unref as n, withCtx as u, createCommentVNode as k, createVNode as E } from "vue";
import { getCurrentIndex as G } from "./get-current-index.js";
import { useNavState as z } from "../../../hooks/useNavState.js";
import N from "../../Lazy/Lazy.vue2.js";
import $ from "../../Section/SectionContainer.vue.js";
import w from "../../../features/Operation/Operation.vue.js";
import V from "../Tags/Tag.vue.js";
const J = /* @__PURE__ */ T({
  __name: "TraversedEntry",
  props: {
    level: { default: 0 },
    rootIndex: {},
    entries: {},
    document: {},
    config: {},
    clientOptions: {},
    activeCollection: {},
    activeServer: {},
    store: {}
  },
  setup(r, { expose: C }) {
    const l = (e) => "isGroup" in e && e.isGroup, v = (e) => "tag" in e && !l(e), O = (e) => "operation" in e, s = (e) => "webhook" in e, I = (e) => "isWebhooks" in e && !!e.isWebhooks, d = g(() => r.level === 0), { hash: S } = z(), a = g(() => d.value ? r.rootIndex : G(S.value, r.entries)), m = (e, c) => l(e) ? null : c < a.value ? "prev" : c > a.value + 2 ? "after" : null;
    return C({
      currentIndex: a
    }), (e, c) => {
      const p = b("TraversedEntry", !0);
      return i(!0), W(B, null, L(e.entries, (o, f) => (i(), t(n(N), {
        key: o.id,
        id: o.id,
        prev: m(o, f) === "prev",
        isLazy: !!m(o, f)
      }, {
        default: u(() => [
          O(o) || s(o) ? (i(), t(n($), {
            key: 0,
            omit: !d.value
          }, {
            default: u(() => [
              E(n(w), {
                path: s(o) ? o.name : o.path,
                method: o.method,
                id: o.id,
                document: e.document,
                collection: e.activeCollection,
                clientOptions: e.clientOptions,
                config: e.config,
                store: e.store,
                server: e.activeServer,
                isWebhook: s(o)
              }, null, 8, ["path", "method", "id", "document", "collection", "clientOptions", "config", "store", "server", "isWebhook"])
            ]),
            _: 2
          }, 1032, ["omit"])) : I(o) || v(o) ? (i(), t(n(V), {
            key: 1,
            tag: o,
            layout: e.config.layout,
            moreThanOneTag: e.entries.filter(v).length > 1
          }, {
            default: u(() => {
              var h;
              return [
                "children" in o && ((h = o.children) != null && h.length) ? (i(), t(p, {
                  key: 0,
                  level: e.level + 1,
                  entries: o.children,
                  activeCollection: e.activeCollection,
                  activeServer: e.activeServer,
                  clientOptions: e.clientOptions,
                  rootIndex: e.rootIndex,
                  config: e.config,
                  document: e.document,
                  store: e.store
                }, null, 8, ["level", "entries", "activeCollection", "activeServer", "clientOptions", "rootIndex", "config", "document", "store"])) : k("", !0)
              ];
            }),
            _: 2
          }, 1032, ["tag", "layout", "moreThanOneTag"])) : l(o) ? (i(), t(p, {
            key: 2,
            level: e.level + 1,
            rootIndex: e.rootIndex,
            entries: o.children || [],
            activeCollection: e.activeCollection,
            activeServer: e.activeServer,
            clientOptions: e.clientOptions,
            config: e.config,
            document: e.document,
            store: e.store
          }, null, 8, ["level", "rootIndex", "entries", "activeCollection", "activeServer", "clientOptions", "config", "document", "store"])) : k("", !0)
        ]),
        _: 2
      }, 1032, ["id", "prev", "isLazy"]))), 128);
    };
  }
});
export {
  J as default
};
