"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 util = require("./util.js");
const XEUtils = require("xe-utils");
const event = require("../../../../@vxe-ui/core/es/src/event.js");
const VxeSplitPaneComponent = comp.defineVxeComponent({
  name: "VxeSplitterPanel",
  props: {
    name: [Number, String],
    width: [Number, String],
    height: [Number, String],
    minWidth: {
      type: [Number, String],
      default: () => null
    },
    minHeight: {
      type: [Number, String],
      default: () => null
    },
    // 已废弃
    showAction: Boolean
  },
  emits: [],
  setup(props, context) {
    const { emit, slots } = context;
    const xID = XEUtils.uniqueId();
    const $xeSplitter = vue.inject("$xeSplitter", null);
    const refElem = vue.ref();
    const paneConfig = vue.reactive({
      id: xID,
      name: props.name,
      width: props.width,
      height: props.height,
      minWidth: props.minWidth,
      minHeight: props.minHeight,
      showAction: props.showAction,
      isExpand: true,
      renderWidth: 0,
      resizeWidth: 0,
      foldWidth: 0,
      renderHeight: 0,
      resizeHeight: 0,
      foldHeight: 0,
      slots
    });
    const reactData = vue.reactive({});
    const internalData = {};
    const computeMaps = {};
    const refMaps = {
      refElem
    };
    const $xeSplitterItem = {
      xID,
      props,
      context,
      reactData,
      internalData,
      getRefMaps: () => refMaps,
      getComputeMaps: () => computeMaps
    };
    const dispatchEvent = (type, params, evnt) => {
      emit(type, event.createEvent(evnt, { $splitterPanel: $xeSplitterItem }, params));
    };
    const splitterPanelMethods = {
      dispatchEvent
    };
    const splitterPanelPrivateMethods = {};
    Object.assign($xeSplitterItem, splitterPanelMethods, splitterPanelPrivateMethods);
    const renderVN = () => {
      return vue.h("div", {
        ref: refElem
      });
    };
    vue.watch(() => props.name, (val) => {
      paneConfig.name = val;
    });
    vue.watch(() => props.width, (val) => {
      paneConfig.width = val;
    });
    vue.watch(() => props.height, (val) => {
      paneConfig.height = val;
    });
    vue.watch(() => props.minWidth, (val) => {
      paneConfig.minWidth = val;
    });
    vue.watch(() => props.minHeight, (val) => {
      paneConfig.minHeight = val;
    });
    vue.watch(() => props.showAction, (val) => {
      paneConfig.showAction = val;
    });
    vue.onMounted(() => {
      const elem = refElem.value;
      if ($xeSplitter && elem) {
        util.assembleSplitterItem($xeSplitter, elem, paneConfig);
      }
    });
    vue.onUnmounted(() => {
      if ($xeSplitter) {
        util.destroySplitterItem($xeSplitter, paneConfig);
      }
    });
    vue.provide("$xeSplitterItem", $xeSplitterItem);
    $xeSplitterItem.renderVN = renderVN;
    return $xeSplitterItem;
  },
  render() {
    return this.renderVN();
  }
});
exports.default = VxeSplitPaneComponent;
