import { defineComponent as y, ref as m, useId as C, computed as T, createBlock as l, openBlock as o, unref as t, withCtx as u, createVNode as k, createElementBlock as b, createCommentVNode as s, renderSlot as S, nextTick as B } from "vue";
import v from "../../ShowMoreButton.vue.js";
import { useNavState as I } from "../../../hooks/useNavState.js";
import O from "./TagSection.vue.js";
import { useSidebar as $ } from "../../../features/sidebar/hooks/useSidebar.js";
import w from "../../Section/SectionContainer.vue.js";
import R from "../../Lazy/Lazy.vue2.js";
const E = /* @__PURE__ */ y({
  __name: "ModernLayout",
  props: {
    tag: {},
    moreThanOneTag: { type: Boolean }
  },
  setup(n) {
    const c = m(), d = m(), f = C(), { collapsedSidebarItems: g } = $(), { hash: r } = I(), p = T(
      () => {
        var e, a;
        return n.moreThanOneTag || ((e = n.tag) == null ? void 0 : e.title) !== "default" || ((a = n.tag) == null ? void 0 : a.tag.description) !== "";
      }
    );
    async function h() {
      var e, a;
      await B(), (a = (e = d.value) == null ? void 0 : e.querySelector("button")) == null || a.focus();
    }
    const i = (e) => !g[e];
    return (e, a) => (o(), l(t(w), {
      ref_key: "sectionContainerRef",
      ref: c,
      "aria-labelledby": t(f),
      class: "tag-section-container",
      role: "region"
    }, {
      default: u(() => [
        k(t(R), {
          id: `modern-tag-${e.tag.id}`,
          isLazy: !!t(r) && t(r) !== e.tag.id && t(r).startsWith(e.tag.id)
        }, {
          default: u(() => [
            p.value ? (o(), l(O, {
              key: 0,
              headerId: t(f),
              isCollapsed: i(e.tag.id),
              tag: e.tag
            }, null, 8, ["headerId", "isCollapsed", "tag"])) : s("", !0),
            i(e.tag.id) && e.moreThanOneTag ? (o(), l(v, {
              key: 1,
              id: e.tag.id,
              "aria-label": `Show all ${e.tag.title} endpoints`,
              onClick: h
            }, null, 8, ["id", "aria-label"])) : s("", !0)
          ]),
          _: 1
        }, 8, ["id", "isLazy"]),
        i(e.tag.id) && e.moreThanOneTag ? s("", !0) : (o(), b("div", {
          key: 0,
          ref_key: "contentsRef",
          ref: d,
          class: "contents"
        }, [
          S(e.$slots, "default", {}, void 0, !0)
        ], 512))
      ]),
      _: 3
    }, 8, ["aria-labelledby"]));
  }
});
export {
  E as default
};
