import { createElementVNode, defineComponent, useSlots, ref, computed, openBlock, createBlock, Transition, unref, withCtx, withDirectives, normalizeClass, resolveDynamicComponent, createElementBlock, createCommentVNode, renderSlot, createTextVNode, toDisplayString, Fragment, createVNode, vShow } from 'vue';
import { ElIcon } from '../../icon/index.mjs';
import '../../../utils/index.mjs';
import '../../../hooks/index.mjs';
import { alertProps, alertEmits } from './alert2.mjs';
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
import { TypeComponents, TypeComponentsMap } from '../../../utils/vue/icon.mjs';
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';

const _hoisted_1 = {
  key: 1,
  xmlns: "http://www.w3.org/2000/svg",
  viewBox: "0 0 17 17"
};
const _hoisted_2 = /* @__PURE__ */ createElementVNode("circle", {
  cx: "7.99503",
  cy: "7.99497",
  r: "7.335",
  fill: "#currentColor"
}, null, -1);
const _hoisted_3 = /* @__PURE__ */ createElementVNode("ellipse", {
  cx: "7.99479",
  cy: "4.33998",
  rx: "0.84",
  ry: "0.839979",
  fill: "white"
}, null, -1);
const _hoisted_4 = /* @__PURE__ */ createElementVNode("rect", {
  x: "7.2948",
  y: "6.39328",
  width: "1.4",
  height: "6.20002",
  rx: "0.7",
  fill: "white"
}, null, -1);
const _hoisted_5 = [
  _hoisted_2,
  _hoisted_3,
  _hoisted_4
];
const __default__ = defineComponent({
  name: "ElAlert"
});
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: alertProps,
  emits: alertEmits,
  setup(__props, { emit }) {
    const props = __props;
    const { Close } = TypeComponents;
    const slots = useSlots();
    const ns = useNamespace("alert");
    const visible = ref(true);
    const iconComponent = computed(() => TypeComponentsMap[props.type]);
    const iconClass = computed(() => [
      ns.e("icon"),
      { [ns.is("big")]: !!props.description || !!slots.default }
    ]);
    const isShowIcon = computed(() => {
      return { [ns.is("show-icon")]: props.showIcon };
    });
    const isBoldTitle = computed(() => {
      return { [ns.is("bold")]: props.description || slots.default };
    });
    const close = (evt) => {
      visible.value = false;
      emit("close", evt);
    };
    return (_ctx, _cache) => {
      return openBlock(), createBlock(Transition, {
        name: unref(ns).b("fade"),
        persisted: ""
      }, {
        default: withCtx(() => [
          withDirectives(createElementVNode("div", {
            class: normalizeClass([
              unref(ns).b(),
              unref(ns).m(_ctx.type),
              unref(ns).m(_ctx.size),
              unref(ns).is("center", _ctx.center),
              unref(ns).is("border", _ctx.border),
              unref(ns).is(_ctx.effect)
            ]),
            role: "alert"
          }, [
            createElementVNode("div", {
              class: normalizeClass(unref(ns).e("content"))
            }, [
              createElementVNode("div", {
                class: normalizeClass(unref(ns).e("title-content"))
              }, [
                _ctx.showIcon && unref(iconComponent) ? (openBlock(), createBlock(unref(ElIcon), {
                  key: 0,
                  class: normalizeClass(unref(iconClass))
                }, {
                  default: withCtx(() => [
                    _ctx.type !== "primary" ? (openBlock(), createBlock(resolveDynamicComponent(unref(iconComponent)), { key: 0 })) : (openBlock(), createElementBlock("svg", _hoisted_1, _hoisted_5))
                  ]),
                  _: 1
                }, 8, ["class"])) : createCommentVNode("v-if", true),
                _ctx.title || _ctx.$slots.title ? (openBlock(), createElementBlock("div", {
                  key: 1,
                  class: normalizeClass([unref(ns).e("title-text"), unref(isBoldTitle)])
                }, [
                  renderSlot(_ctx.$slots, "title", {}, () => [
                    createTextVNode(toDisplayString(_ctx.title), 1)
                  ])
                ], 2)) : createCommentVNode("v-if", true)
              ], 2),
              _ctx.$slots.default || _ctx.description ? (openBlock(), createElementBlock("p", {
                key: 0,
                class: normalizeClass([unref(ns).e("description"), unref(isShowIcon)])
              }, [
                renderSlot(_ctx.$slots, "default", {}, () => [
                  createTextVNode(toDisplayString(_ctx.description), 1)
                ])
              ], 2)) : createCommentVNode("v-if", true),
              _ctx.closable ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
                _ctx.closeText ? (openBlock(), createElementBlock("div", {
                  key: 0,
                  class: normalizeClass([
                    unref(ns).e("close-btn"),
                    unref(ns).is("customed"),
                    { [unref(ns).is("big")]: !!props.description || !!unref(slots).default }
                  ]),
                  onClick: close
                }, toDisplayString(_ctx.closeText), 3)) : (openBlock(), createBlock(unref(ElIcon), {
                  key: 1,
                  class: normalizeClass([
                    unref(ns).e("close-btn"),
                    { [unref(ns).is("big")]: !!props.description || !!unref(slots).default }
                  ]),
                  onClick: close
                }, {
                  default: withCtx(() => [
                    createVNode(unref(Close))
                  ]),
                  _: 1
                }, 8, ["class"]))
              ], 64)) : createCommentVNode("v-if", true)
            ], 2)
          ], 2), [
            [vShow, visible.value]
          ])
        ]),
        _: 3
      }, 8, ["name"]);
    };
  }
});
var Alert = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/Users/judai/code/d-element-plus/packages/components/alert/src/alert.vue"]]);

export { Alert as default };
//# sourceMappingURL=alert.mjs.map
