"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 event = require("../../../../@vxe-ui/core/es/src/event.js");
const index_esm = require("../../../../@vxe-ui/core/es/index.esm.js");
const icon = require("../../../../@vxe-ui/core/es/src/icon.js");
const VxeAlertComponent = comp.defineVxeComponent({
  name: "VxeAlert",
  props: {
    title: {
      type: [String, Number],
      default: () => config.getConfig().alert.title
    },
    content: [String, Number],
    status: String,
    showIcon: Boolean,
    showClose: Boolean,
    icon: {
      type: String,
      default: () => config.getConfig().alert.icon
    }
  },
  emits: [
    "close"
  ],
  setup(props, context) {
    const { emit, slots } = context;
    const xID = XEUtils.uniqueId();
    const refElem = vue.ref();
    const reactData = vue.reactive({});
    const refMaps = {
      refElem
    };
    const computeMaps = {};
    const $xeAlert = {
      xID,
      props,
      context,
      reactData,
      getRefMaps: () => refMaps,
      getComputeMaps: () => computeMaps
    };
    const alertMethods = {
      dispatchEvent(type, params, evnt) {
        emit(type, event.createEvent(evnt, { $alert: $xeAlert }, params));
      }
    };
    const closeEvent = (evnt) => {
      alertMethods.dispatchEvent("close", {}, evnt);
    };
    const alertPrivateMethods = {};
    Object.assign($xeAlert, alertMethods, alertPrivateMethods);
    const renderVN = () => {
      const { status, content, icon: icon$1, title, showIcon, showClose } = props;
      const defaultSlot = slots.default;
      const titleSlot = slots.title;
      const iconSlot = slots.icon;
      return vue.h("div", {
        ref: refElem,
        class: ["vxe-alert", {
          [`theme--${status}`]: status
        }]
      }, [
        iconSlot || showIcon && status || icon$1 ? vue.h("div", {
          class: "vxe-alert--icon"
        }, iconSlot ? vn.getSlotVNs(iconSlot({})) : [
          vue.h("i", {
            class: icon$1 || icon.getIcon()[`ALERT_${status === null || status === void 0 ? void 0 : status.toUpperCase()}`]
          })
        ]) : index_esm.renderEmptyElement(),
        vue.h("div", {
          class: "vxe-alert--body"
        }, [
          titleSlot || title ? vue.h("div", {
            class: "vxe-alert--title"
          }, titleSlot ? vn.getSlotVNs(titleSlot({})) : XEUtils.toValueString(title)) : index_esm.renderEmptyElement(),
          vue.h("div", {
            class: "vxe-alert--content"
          }, defaultSlot ? vn.getSlotVNs(defaultSlot({})) : XEUtils.toValueString(content))
        ]),
        showClose ? vue.h("div", {
          class: "vxe-alert--close-btn",
          onClick: closeEvent
        }, [
          vue.h("i", {
            class: icon.getIcon().ALERT_CLOSE
          })
        ]) : index_esm.renderEmptyElement()
      ]);
    };
    $xeAlert.renderVN = renderVN;
    return $xeAlert;
  },
  render() {
    return this.renderVN();
  }
});
exports.default = VxeAlertComponent;
