"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const vue = require("vue");
const comp = require("../../ui/src/comp.js");
const XEUtils = require("xe-utils");
require("../../ui/index.js");
const util = require("./util.js");
const event = require("../../../../@vxe-ui/core/es/src/event.js");
const VxeCollapsePaneComponent = comp.defineVxeComponent({
  name: "VxeCollapsePane",
  props: {
    title: [String, Number],
    name: [String, Number],
    icon: String,
    preload: Boolean,
    permissionCode: [String, Number]
  },
  emits: [],
  setup(props, context) {
    const { emit, slots } = context;
    const xID = XEUtils.uniqueId();
    const $xeCollapse = vue.inject("$xeCollapse", null);
    const refElem = vue.ref();
    const reactData = vue.reactive({});
    const collapseConfig = vue.reactive({
      id: xID,
      title: props.title,
      name: props.name,
      icon: props.icon,
      preload: props.preload,
      permissionCode: props.permissionCode,
      slots
    });
    const refMaps = {
      refElem
    };
    const computeMaps = {};
    const $xeCollapsePane = {
      xID,
      props,
      context,
      reactData,
      getRefMaps: () => refMaps,
      getComputeMaps: () => computeMaps
    };
    const dispatchEvent = (type, params, evnt) => {
      emit(type, event.createEvent(evnt, { $collapsePane: $xeCollapsePane }, params));
    };
    const collapsePaneMethods = {
      dispatchEvent
    };
    const collapsePanePrivateMethods = {};
    Object.assign($xeCollapsePane, collapsePaneMethods, collapsePanePrivateMethods);
    const renderVN = () => {
      return vue.h("div", {
        ref: refElem
      }, []);
    };
    vue.watch(() => props.title, (val) => {
      collapseConfig.title = val;
    });
    vue.watch(() => props.name, (val) => {
      collapseConfig.name = val;
    });
    vue.watch(() => props.icon, (val) => {
      collapseConfig.icon = val;
    });
    vue.watch(() => props.permissionCode, (val) => {
      collapseConfig.permissionCode = val;
    });
    vue.onMounted(() => {
      const elem = refElem.value;
      if ($xeCollapse && elem) {
        util.assembleCollapseItem($xeCollapse, elem, collapseConfig);
      }
    });
    vue.onUnmounted(() => {
      if ($xeCollapse) {
        util.destroyCollapseItem($xeCollapse, collapseConfig);
      }
    });
    $xeCollapsePane.renderVN = renderVN;
    return $xeCollapsePane;
  },
  render() {
    return this.renderVN();
  }
});
exports.default = VxeCollapsePaneComponent;
