import { defineComponent, ref, useId, computed, createBlock, openBlock, unref, withCtx, createVNode, createElementBlock, createCommentVNode, renderSlot } from "vue";
import _sfc_main$1 from "../../../Lazy/Lazy.vue.js";
import ShowMoreButton from "../../../ShowMoreButton.vue.js";
import _sfc_main$2 from "./TagSection.vue.js";
import SectionContainer from "../../../Section/SectionContainer.vue.js";
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "ModernLayout",
  props: {
    tag: {},
    moreThanOneTag: { type: Boolean },
    isLoading: { type: Boolean },
    isCollapsed: { type: Boolean },
    eventBus: {}
  },
  setup(__props) {
    const sectionContainerRef = ref();
    const contentsRef = ref();
    const headerId = useId();
    const moreThanOneDefaultTag = computed(
      () => __props.moreThanOneTag || __props.tag?.title !== "default" || __props.tag?.description !== ""
    );
    const hasChildren = computed(() => (__props.tag?.children?.length ?? 0) > 0);
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(SectionContainer), {
        ref_key: "sectionContainerRef",
        ref: sectionContainerRef,
        "aria-labelledby": unref(headerId),
        class: "tag-section-container",
        role: "region"
      }, {
        default: withCtx(() => [
          createVNode(_sfc_main$1, {
            id: _ctx.tag.id
          }, {
            default: withCtx(() => [
              moreThanOneDefaultTag.value ? (openBlock(), createBlock(_sfc_main$2, {
                key: 0,
                eventBus: _ctx.eventBus,
                headerId: unref(headerId),
                isCollapsed: _ctx.isCollapsed,
                isLoading: _ctx.isLoading,
                tag: _ctx.tag
              }, null, 8, ["eventBus", "headerId", "isCollapsed", "isLoading", "tag"])) : createCommentVNode("", true),
              _ctx.isCollapsed && _ctx.moreThanOneTag && hasChildren.value ? (openBlock(), createBlock(ShowMoreButton, {
                key: 1,
                id: _ctx.tag.id,
                "aria-label": `Show all ${_ctx.tag.title} endpoints`,
                onClick: _cache[0] || (_cache[0] = () => _ctx.eventBus?.emit("toggle:nav-item", { id: _ctx.tag.id, open: true }))
              }, null, 8, ["id", "aria-label"])) : createCommentVNode("", true)
            ]),
            _: 1
          }, 8, ["id"]),
          !(_ctx.isCollapsed && _ctx.moreThanOneTag) ? (openBlock(), createElementBlock("div", {
            key: 0,
            ref_key: "contentsRef",
            ref: contentsRef,
            class: "contents"
          }, [
            renderSlot(_ctx.$slots, "default", {}, void 0, true)
          ], 512)) : createCommentVNode("", true)
        ]),
        _: 3
      }, 8, ["aria-labelledby"]);
    };
  }
});
export {
  _sfc_main as default
};
