"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 VxeTabPaneComponent = comp.defineVxeComponent({
  name: "VxeTabPane",
  props: {
    title: [String, Number],
    name: [String, Number],
    icon: String,
    titleWidth: [String, Number],
    titleAlign: [String, Number],
    preload: Boolean,
    permissionCode: [String, Number]
  },
  emits: [],
  setup(props, context) {
    const { slots, emit } = context;
    const xID = XEUtils.uniqueId();
    const refElem = vue.ref();
    const $xeTabs = vue.inject("$xeTabs", null);
    const reactData = vue.reactive({});
    const tabConfig = vue.reactive({
      id: xID,
      title: props.title,
      name: props.name,
      icon: props.icon,
      titleWidth: props.titleWidth,
      titleAlign: props.titleAlign,
      preload: props.preload,
      permissionCode: props.permissionCode,
      slots
    });
    const refMaps = {
      refElem
    };
    const computeMaps = {};
    const $xeTabPane = {
      xID,
      props,
      context,
      reactData,
      getRefMaps: () => refMaps,
      getComputeMaps: () => computeMaps
    };
    const dispatchEvent = (type, params, evnt) => {
      emit(type, event.createEvent(evnt, { $tabPane: $xeTabPane }, params));
    };
    const tabPaneMethods = {
      dispatchEvent
    };
    const tabPanePrivateMethods = {};
    Object.assign($xeTabPane, tabPaneMethods, tabPanePrivateMethods);
    vue.watch(() => props.title, (val) => {
      tabConfig.title = val;
    });
    vue.watch(() => props.name, (val) => {
      tabConfig.name = val;
    });
    vue.watch(() => props.icon, (val) => {
      tabConfig.icon = val;
    });
    vue.watch(() => props.permissionCode, (val) => {
      tabConfig.permissionCode = val;
    });
    vue.onMounted(() => {
      const elem = refElem.value;
      if ($xeTabs && elem) {
        util.assembleTabItem($xeTabs, elem, tabConfig);
      }
    });
    vue.onUnmounted(() => {
      if ($xeTabs) {
        util.destroyTabItem($xeTabs, tabConfig);
      }
    });
    const renderVN = () => {
      return vue.h("div", {
        ref: refElem
      }, []);
    };
    $xeTabPane.renderVN = renderVN;
    return $xeTabPane;
  },
  render() {
    return this.renderVN();
  }
});
exports.default = VxeTabPaneComponent;
