"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 vn = require("../../ui/src/vn.js");
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");
const VxeTipComponent = comp.defineVxeComponent({
  name: "VxeTip",
  props: {
    title: {
      type: [String, Number],
      default: () => config.getConfig().tip.title
    },
    content: [String, Number],
    status: String,
    icon: {
      type: String,
      default: () => config.getConfig().tip.icon
    },
    /**
     * 权限码
     */
    permissionCode: [String, Number],
    size: {
      type: String,
      default: () => config.getConfig().tip.size || config.getConfig().size
    }
  },
  emits: [],
  setup(props, context) {
    const { slots, emit } = context;
    const xID = XEUtils.uniqueId();
    const { computeSize } = useFns.useSize(props);
    const { computePermissionInfo } = useFns.usePermission(props);
    const refElem = vue.ref();
    const reactData = vue.reactive({});
    const refMaps = {
      refElem
    };
    const computeMaps = {};
    const $xeTip = {
      xID,
      props,
      context,
      reactData,
      getRefMaps: () => refMaps,
      getComputeMaps: () => computeMaps
    };
    const dispatchEvent = (type, params, evnt) => {
      emit(type, event.createEvent(evnt, { $tip: $xeTip }, params));
    };
    const tipMethods = {
      dispatchEvent
    };
    const tipPrivateMethods = {};
    Object.assign($xeTip, tipMethods, tipPrivateMethods);
    const renderVN = () => {
      const { status, content, icon, title } = props;
      const defaultSlot = slots.default;
      const titleSlot = slots.title;
      const iconSlot = slots.icon;
      const permissionInfo = computePermissionInfo.value;
      const vSize = computeSize.value;
      if (!permissionInfo.visible) {
        return index_esm.renderEmptyElement();
      }
      return vue.h("div", {
        ref: refElem,
        class: ["vxe-tip", {
          [`size--${vSize}`]: vSize,
          [`theme--${status}`]: status,
          "has--title": !!(titleSlot || title)
        }]
      }, [
        iconSlot || icon ? vue.h("div", {
          class: "vxe-tip--icon"
        }, iconSlot ? vn.getSlotVNs(iconSlot({})) : [
          vue.h("i", {
            class: icon
          })
        ]) : index_esm.renderEmptyElement(),
        vue.h("div", {
          class: "vxe-tip--body"
        }, [
          titleSlot || title ? vue.h("div", {
            class: "vxe-tip--title"
          }, titleSlot ? vn.getSlotVNs(titleSlot({})) : XEUtils.toValueString(title)) : index_esm.renderEmptyElement(),
          vue.h("div", {
            class: "vxe-tip--content"
          }, defaultSlot ? vn.getSlotVNs(defaultSlot({})) : XEUtils.toValueString(content))
        ])
      ]);
    };
    $xeTip.renderVN = renderVN;
    return $xeTip;
  },
  render() {
    return this.renderVN();
  }
});
exports.default = VxeTipComponent;
