"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const vue = require("vue");
const comp = require("../../ui/src/comp.js");
require("../../ui/index.js");
const index = require("../../loading/index.js");
const index$1 = require("../../backtop/index.js");
const XEUtils = require("xe-utils");
const config = require("../../../../@vxe-ui/core/es/src/config.js");
const useFns = require("../../../../@vxe-ui/core/es/src/useFns.js");
const event = require("../../../../@vxe-ui/core/es/src/event.js");
const index_esm = require("../../../../@vxe-ui/core/es/index.esm.js");
function createInternalData() {
  return {};
}
function createReactData() {
  return {};
}
const VxeLayoutBodyComponent = comp.defineVxeComponent({
  name: "VxeLayoutBody",
  props: {
    loading: Boolean,
    padding: Boolean,
    showBacktop: {
      type: Boolean,
      default: () => config.getConfig().layoutBody.showBacktop
    },
    backtopConfig: Object,
    size: {
      type: String,
      default: () => config.getConfig().layoutBody.size || config.getConfig().size
    }
  },
  emits: [],
  setup(props, context) {
    const { slots, emit } = context;
    const xID = XEUtils.uniqueId();
    const backtopId = `vxe_layout_body_backtop_${xID}`;
    const refElem = vue.ref();
    const { computeSize } = useFns.useSize(props);
    const internalData = createInternalData();
    const reactData = vue.reactive(createReactData());
    const refMaps = {
      refElem
    };
    const computeBacktopOpts = vue.computed(() => {
      return Object.assign({}, config.getConfig().layoutBody.backtopConfig, props.backtopConfig, {
        target: "#" + backtopId
      });
    });
    const computeMaps = {
      computeSize
    };
    const $xeLayoutBody = {
      xID,
      props,
      context,
      internalData,
      reactData,
      getRefMaps: () => refMaps,
      getComputeMaps: () => computeMaps
    };
    const dispatchEvent = (type, params, evnt) => {
      emit(type, event.createEvent(evnt, { $layoutBody: $xeLayoutBody }, params));
    };
    const layoutBodyMethods = {
      dispatchEvent
    };
    const layoutBodyPrivateMethods = {};
    Object.assign($xeLayoutBody, layoutBodyMethods, layoutBodyPrivateMethods);
    const renderVN = () => {
      const { loading, padding, showBacktop } = props;
      const backtopOpts = computeBacktopOpts.value;
      const vSize = computeSize.value;
      const defaultSlot = slots.default;
      const backtopSlot = slots.backtop;
      const backtopTopSlot = slots.backtopTop || slots["backtop-top"];
      const backtopBottomSlot = slots.backtopBottom || slots["backtop-bottom"];
      const backtopScopeSlots = {};
      if (backtopSlot) {
        backtopScopeSlots.default = backtopSlot;
      }
      if (backtopTopSlot) {
        backtopScopeSlots.top = backtopTopSlot;
      }
      if (backtopBottomSlot) {
        backtopScopeSlots.bottom = backtopBottomSlot;
      }
      return vue.h("div", {
        ref: refElem,
        class: ["vxe-layout-body", {
          [`size--${vSize}`]: vSize,
          "is--loading": loading,
          "is--padding": padding
        }]
      }, [
        vue.h("div", {
          id: showBacktop ? backtopId : "",
          class: "vxe-layout-body--inner"
        }, defaultSlot ? defaultSlot({}) : []),
        /**
         * 加载中
         */
        vue.h(index.VxeLoading, {
          class: "vxe-list-view--loading",
          modelValue: loading
        }),
        /**
         * 回到顶部
         */
        showBacktop ? vue.h(index$1.VxeBacktop, backtopOpts, backtopScopeSlots) : index_esm.renderEmptyElement()
      ]);
    };
    $xeLayoutBody.renderVN = renderVN;
    return $xeLayoutBody;
  },
  render() {
    return this.renderVN();
  }
});
exports.default = VxeLayoutBodyComponent;
