"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const style = require("../../../utils/dom/style.js");
const index = require("../../../hooks/use-locale/index.js");
const index$1 = require("../../../hooks/use-namespace/index.js");
const index$3 = require("../../icon/index.js");
const index$2 = require("../../tooltip/index.js");
const index$4 = require("../../button/index.js");
const popconfirm = require("./popconfirm.js");
const Vue = require("vue");
var popconfirm_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ Vue.defineComponent({
  name: "ElPopconfirm",
  __name: "popconfirm",
  props: popconfirm.popconfirmProps,
  emits: popconfirm.popconfirmEmits,
  setup(__props, { expose: __expose, emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const { t } = index.useLocale();
    const ns = index$1.useNamespace("popconfirm");
    const tooltipRef = Vue.ref();
    const rootRef = Vue.ref();
    const popperRef = Vue.computed(() => {
      var _a;
      return (_a = Vue.unref(tooltipRef)) == null ? void 0 : _a.popperRef;
    });
    const showPopper = () => {
      var _a, _b;
      (_b = (_a = rootRef.value) == null ? void 0 : _a.focus) == null ? void 0 : _b.call(_a);
    };
    const hidePopper = () => {
      var _a, _b;
      (_b = (_a = tooltipRef.value) == null ? void 0 : _a.onClose) == null ? void 0 : _b.call(_a);
    };
    const style$1 = Vue.computed(() => {
      return { width: style.addUnit(props.width) };
    });
    const confirm = (e) => {
      emit("confirm", e);
      hidePopper();
    };
    const cancel = (e) => {
      emit("cancel", e);
      hidePopper();
    };
    const finalConfirmButtonText = Vue.computed(() => props.confirmButtonText || t("el.popconfirm.confirmButtonText"));
    const finalCancelButtonText = Vue.computed(() => props.cancelButtonText || t("el.popconfirm.cancelButtonText"));
    __expose({
      popperRef,
      hide: hidePopper
    });
    return (_ctx, _cache) => {
      return Vue.openBlock(), Vue.createBlock(Vue.unref(index$2.ElTooltip), Vue.mergeProps({
        ref_key: "tooltipRef",
        ref: tooltipRef,
        trigger: "click",
        effect: __props.effect
      }, _ctx.$attrs, {
        "virtual-triggering": __props.virtualTriggering,
        "virtual-ref": __props.virtualRef,
        "popper-class": `${Vue.unref(ns).namespace.value}-popover`,
        "popper-style": style$1.value,
        teleported: __props.teleported,
        "fallback-placements": [
          "bottom",
          "top",
          "right",
          "left"
        ],
        "hide-after": __props.hideAfter,
        persistent: __props.persistent,
        loop: "",
        onShow: showPopper
      }), {
        content: Vue.withCtx(() => [Vue.createElementVNode("div", {
          ref_key: "rootRef",
          ref: rootRef,
          tabindex: "-1",
          class: Vue.normalizeClass(Vue.unref(ns).b())
        }, [Vue.createElementVNode("div", { class: Vue.normalizeClass(Vue.unref(ns).e("main")) }, [!__props.hideIcon && __props.icon ? (Vue.openBlock(), Vue.createBlock(Vue.unref(index$3.ElIcon), {
          key: 0,
          class: Vue.normalizeClass(Vue.unref(ns).e("icon")),
          style: Vue.normalizeStyle({ color: __props.iconColor })
        }, {
          default: Vue.withCtx(() => [(Vue.openBlock(), Vue.createBlock(Vue.resolveDynamicComponent(__props.icon)))]),
          _: 1
        }, 8, ["class", "style"])) : Vue.createCommentVNode("v-if", true), Vue.createTextVNode(" " + Vue.toDisplayString(__props.title), 1)], 2), Vue.createElementVNode("div", { class: Vue.normalizeClass(Vue.unref(ns).e("action")) }, [Vue.renderSlot(_ctx.$slots, "actions", {
          confirm,
          cancel
        }, () => [Vue.createVNode(Vue.unref(index$4.ElButton), {
          size: "small",
          type: __props.cancelButtonType === "text" ? "" : __props.cancelButtonType,
          text: __props.cancelButtonType === "text",
          onClick: cancel
        }, {
          default: Vue.withCtx(() => [Vue.createTextVNode(Vue.toDisplayString(finalCancelButtonText.value), 1)]),
          _: 1
        }, 8, ["type", "text"]), Vue.createVNode(Vue.unref(index$4.ElButton), {
          size: "small",
          type: __props.confirmButtonType === "text" ? "" : __props.confirmButtonType,
          text: __props.confirmButtonType === "text",
          onClick: confirm
        }, {
          default: Vue.withCtx(() => [Vue.createTextVNode(Vue.toDisplayString(finalConfirmButtonText.value), 1)]),
          _: 1
        }, 8, ["type", "text"])])], 2)], 2)]),
        default: Vue.withCtx(() => [_ctx.$slots.reference ? Vue.renderSlot(_ctx.$slots, "reference", { key: 0 }) : Vue.createCommentVNode("v-if", true)]),
        _: 3
      }, 16, [
        "effect",
        "virtual-triggering",
        "virtual-ref",
        "popper-class",
        "popper-style",
        "teleported",
        "hide-after",
        "persistent"
      ]);
    };
  }
});
exports.default = popconfirm_vue_vue_type_script_setup_true_lang_default;
