import { defineComponent, defineAsyncComponent, ref, onMounted, watch, nextTick, resolveComponent, openBlock, createBlock, withCtx, unref, createElementBlock, Fragment, renderList, renderSlot, mergeProps, createVNode } from 'vue';
import { useRoute } from 'vue-router';
import { storeToRefs } from 'pinia';
import '../../../../stores/index.mjs';
import '../../../../utils/index.mjs';
import { useThemeConfig } from '../../../../stores/themeConfig.mjs';
import { NextLoading } from '../../../../utils/loading.mjs';

var _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "defaults",
  setup(__props) {
    const LayoutAside = defineAsyncComponent(() => import('../component/aside.vue.mjs'));
    const LayoutHeader = defineAsyncComponent(() => import('../component/header.vue.mjs'));
    const LayoutMain = defineAsyncComponent(() => import('../component/main.vue.mjs'));
    const layoutScrollbarRef = ref("");
    const layoutMainRef = ref();
    const route = useRoute();
    const storesThemeConfig = useThemeConfig();
    const { themeConfig } = storeToRefs(storesThemeConfig);
    const updateScrollbar = () => {
      layoutScrollbarRef.value.update();
      layoutMainRef.value.layoutMainScrollbarRef.update();
    };
    const initScrollBarHeight = () => {
      nextTick(() => {
        setTimeout(() => {
          updateScrollbar();
          layoutScrollbarRef.value.wrapRef.scrollTop = 0;
          if (layoutMainRef.value != void 0) layoutMainRef.value.layoutMainScrollbarRef.wrapRef.scrollTop = 0;
        }, 500);
      });
    };
    onMounted(() => {
      initScrollBarHeight();
      NextLoading.done(600);
    });
    watch(
      () => route.path,
      () => {
        initScrollBarHeight();
      }
    );
    watch(
      () => [themeConfig.value.isTagsview, themeConfig.value.isFixedHeader],
      () => {
        nextTick(() => {
          updateScrollbar();
        });
      },
      {
        deep: true
      }
    );
    return (_ctx, _cache) => {
      const _component_el_scrollbar = resolveComponent("el-scrollbar");
      const _component_el_container = resolveComponent("el-container");
      return openBlock(), createBlock(_component_el_container, { class: "layout-container" }, {
        default: withCtx(() => [
          !_ctx.$slots.aside ? (openBlock(), createBlock(unref(LayoutAside), { key: 0 }, {
            default: withCtx(() => [
              (openBlock(true), createElementBlock(
                Fragment,
                null,
                renderList(_ctx.$slots, (_, name) => {
                  return renderSlot(_ctx.$slots, name, mergeProps({
                    key: name,
                    ref_for: true
                  }, _ctx.$slots[name].props || {}));
                }),
                128
                /* KEYED_FRAGMENT */
              ))
            ]),
            _: 3
            /* FORWARDED */
          })) : renderSlot(_ctx.$slots, "aside", { key: 1 }),
          createVNode(_component_el_container, { class: "layout-container-view h100" }, {
            default: withCtx(() => [
              createVNode(
                _component_el_scrollbar,
                {
                  ref_key: "layoutScrollbarRef",
                  ref: layoutScrollbarRef,
                  class: "layout-backtop"
                },
                {
                  default: withCtx(() => [
                    !_ctx.$slots.header ? (openBlock(), createBlock(unref(LayoutHeader), { key: 0 }, {
                      default: withCtx(() => [
                        (openBlock(true), createElementBlock(
                          Fragment,
                          null,
                          renderList(_ctx.$slots, (_, name) => {
                            return renderSlot(_ctx.$slots, name, mergeProps({
                              key: name,
                              ref_for: true
                            }, _ctx.$slots[name].props || {}));
                          }),
                          128
                          /* KEYED_FRAGMENT */
                        ))
                      ]),
                      _: 3
                      /* FORWARDED */
                    })) : renderSlot(_ctx.$slots, "header", { key: 1 }),
                    !_ctx.$slots.main ? (openBlock(), createBlock(
                      unref(LayoutMain),
                      {
                        key: 2,
                        ref_key: "layoutMainRef",
                        ref: layoutMainRef
                      },
                      {
                        default: withCtx(() => [
                          (openBlock(true), createElementBlock(
                            Fragment,
                            null,
                            renderList(_ctx.$slots, (_, name) => {
                              return renderSlot(_ctx.$slots, name, mergeProps({
                                key: name,
                                ref_for: true
                              }, _ctx.$slots[name].props || {}));
                            }),
                            128
                            /* KEYED_FRAGMENT */
                          ))
                        ]),
                        _: 3
                        /* FORWARDED */
                      },
                      512
                      /* NEED_PATCH */
                    )) : renderSlot(_ctx.$slots, "main", { key: 3 })
                  ]),
                  _: 3
                  /* FORWARDED */
                },
                512
                /* NEED_PATCH */
              )
            ]),
            _: 3
            /* FORWARDED */
          })
        ]),
        _: 3
        /* FORWARDED */
      });
    };
  }
});

export { _sfc_main as default };
