"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 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 VxeBadgeComponent = comp.defineVxeComponent({
  name: "VxeBadge",
  props: {
    count: [String, Number],
    dot: Boolean,
    content: [String, Number],
    size: {
      type: String,
      default: () => config.getConfig().badge.size || config.getConfig().size
    }
  },
  emits: [],
  setup(props, context) {
    const { emit, slots } = context;
    const xID = XEUtils.uniqueId();
    const refElem = vue.ref();
    const { computeSize } = useFns.useSize(props);
    const reactData = vue.reactive({});
    const refMaps = {
      refElem
    };
    const computeCountNum = vue.computed(() => {
      const { count } = props;
      return count ? XEUtils.toNumber(count) : 0;
    });
    const computeMaps = {};
    const $xeBadge = {
      xID,
      props,
      context,
      reactData,
      getRefMaps: () => refMaps,
      getComputeMaps: () => computeMaps
    };
    const dispatchEvent = (type, params, evnt) => {
      emit(type, event.createEvent(evnt, { $badge: $xeBadge }, params));
    };
    const collapsePaneMethods = {
      dispatchEvent
    };
    const collapsePanePrivateMethods = {};
    Object.assign($xeBadge, collapsePaneMethods, collapsePanePrivateMethods);
    const renderVN = () => {
      const { dot, content } = props;
      const vSize = computeSize.value;
      const countNum = computeCountNum.value;
      const defaultSlot = slots.default;
      return vue.h("div", {
        ref: refElem,
        class: ["vxe-badge", {
          [`size--${vSize}`]: vSize,
          "is--dot": dot
        }]
      }, [
        defaultSlot || content ? vue.h("div", {
          class: "vxe-badge--content"
        }, defaultSlot ? defaultSlot({}) : `${content || ""}`) : [],
        countNum ? vue.h("span", {
          class: "vxe-badge--count"
        }, countNum > 99 ? "99+" : `${countNum}`) : index_esm.renderEmptyElement()
      ]);
    };
    $xeBadge.renderVN = renderVN;
    return $xeBadge;
  },
  render() {
    return this.renderVN();
  }
});
exports.default = VxeBadgeComponent;
