/**
 * ldesign v0.4.6
 * (c) 2023 ldesign
 * @license MIT
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var helper = require('../_chunks/dep-c3e1ffac.js');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var iconsVue = require('@ldesign/icons-vue');
var utils_mixins = require('../utils/mixins.js');
var configProvider_configReceiver = require('../config-provider/config-receiver.js');
var popup_index = require('../popup/index.js');
var utils_renderTnode = require('../utils/render-tnode.js');
var utils_event = require('../utils/event.js');
var dialog_actions = require('../dialog/actions.js');
var popconfirm_props = require('./props.js');
require('vue');
require('lodash/mergeWith');
require('../config-provider/context.js');
require('lodash/merge');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('@babel/runtime/helpers/typeof');
require('../_chunks/dep-7c884501.js');
require('dayjs');
require('../utils/map-props.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('../utils/withInstall.js');
require('lodash/capitalize');
require('../popup/popup.js');
require('@popperjs/core');
require('../utils/dom.js');
require('raf');
require('lodash/isString');
require('../utils/easing.js');
require('../utils/helper.js');
require('@babel/runtime/helpers/slicedToArray');
require('lodash/camelCase');
require('../_common/js/utils/set-style.js');
require('../popup/props.js');
require('../popup/container.js');
require('lodash/isFunction');
require('../popup/utils.js');
require('../popup/trigger.js');
require('../popup/plugin.js');
require('@vue/composition-api');
require('lodash/kebabCase');
require('lodash/isObject');
require('../button/index.js');
require('../button/button.js');
require('../loading/index.js');
require('../loading/directive.js');
require('lodash/mapKeys');
require('lodash/isEqual');
require('../loading/plugin.js');
require('../config.js');
require('../loading/loading.js');
require('../utils/transfer-dom.js');
require('../loading/props.js');
require('../loading/icon/gradient.js');
require('../_common/js/loading/circle-adapter.js');
require('../_common/js/utils/helper.js');
require('@babel/runtime/helpers/toConsumableArray');
require('lodash/isNull');
require('lodash/isUndefined');
require('lodash/isNumber');
require('lodash/isArray');
require('../utils/ripple.js');
require('../button/props.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var _Popconfirm = utils_mixins["default"](dialog_actions["default"], configProvider_configReceiver["default"]("popconfirm"), configProvider_configReceiver.getGlobalIconMixins()).extend({
  name: "TPopconfirm",
  props: _objectSpread({}, popconfirm_props["default"]),
  model: {
    prop: "visible",
    event: "visible-change"
  },
  computed: {
    themeIcon: function themeIcon() {
      var _this$useGlobalIcon = this.useGlobalIcon({
          InfoCircleFilledIcon: iconsVue.InfoCircleFilledIcon,
          ErrorCircleFilledIcon: iconsVue.ErrorCircleFilledIcon
        }),
        InfoCircleFilledIcon = _this$useGlobalIcon.InfoCircleFilledIcon,
        ErrorCircleFilledIcon = _this$useGlobalIcon.ErrorCircleFilledIcon;
      var iconMap = {
        "default": InfoCircleFilledIcon,
        warning: ErrorCircleFilledIcon,
        danger: ErrorCircleFilledIcon
      };
      return iconMap[this.theme];
    },
    iconCls: function iconCls() {
      var theme = this.theme || "default";
      return "".concat(this.componentName, "__icon--").concat(theme);
    },
    innerPopupProps: function innerPopupProps() {
      return _objectSpread({
        showArrow: this.showArrow,
        overlayClassName: [this.componentName, "".concat(this.componentName, "__popup--").concat(this.theme || "default")],
        trigger: "click",
        destroyOnClose: this.destroyOnClose,
        placement: this.placement
      }, this.popupProps);
    }
  },
  methods: {
    cancelBtnAction: function cancelBtnAction(e) {
      utils_event.emitEvent(this, "cancel", {
        e: e
      });
      var cancelContext = {
        e: e,
        trigger: "cancel"
      };
      utils_event.emitEvent(this, "visible-change", false, cancelContext);
    },
    confirmBtnAction: function confirmBtnAction(e) {
      utils_event.emitEvent(this, "confirm", {
        e: e
      });
      var confirmContext = {
        e: e,
        trigger: "confirm"
      };
      utils_event.emitEvent(this, "visible-change", false, confirmContext);
    },
    renderIcon: function renderIcon() {
      var h = this.$createElement;
      var Icon = this.themeIcon;
      return utils_renderTnode.renderTNodeJSXDefault(this, "icon", h(Icon, {
        "class": this.iconCls
      }));
    },
    onPopupVisibleChange: function onPopupVisibleChange(val, context) {
      this.$emit("visible-change", val, context);
      this.onVisibleChange && this.onVisibleChange(val, context);
    }
  },
  render: function render() {
    var h = arguments[0];
    var triggerElement = utils_renderTnode.renderContent(this, "default", "triggerElement");
    var cancelBtn = this.getCancelBtn({
      cancelBtn: this.cancelBtn,
      globalCancel: this.global.cancel,
      size: "small",
      className: "".concat(this.componentName, "__cancel")
    });
    var confirmBtn = this.getConfirmBtn({
      theme: this.theme,
      confirmBtn: this.confirmBtn,
      globalConfirm: this.global.confirm,
      size: "small",
      globalConfirmBtnTheme: this.global.confirmBtnTheme,
      className: "".concat(this.componentName, "__confirm")
    });
    return h(popup_index.Popup, helper.helper([{
      "ref": "popup",
      "attrs": {
        "visible": this.visible
      }
    }, {
      "props": this.innerPopupProps
    }, {}, {
      "on": {
        "visible-change": this.onPopupVisibleChange
      }
    }]), [h("template", {
      "slot": "content",
      "attrs": {
        "role": "popconfirm"
      }
    }, [h("div", {
      "class": "".concat(this.componentName, "__content")
    }, [h("div", {
      "class": "".concat(this.componentName, "__body")
    }, [this.renderIcon(), h("div", {
      "class": "".concat(this.componentName, "__inner")
    }, [utils_renderTnode.renderTNodeJSX(this, "content")])]), Boolean(cancelBtn || confirmBtn) && h("div", {
      "class": "".concat(this.componentName, "__buttons")
    }, [cancelBtn, confirmBtn])])]), triggerElement]);
  }
});

exports["default"] = _Popconfirm;
//# sourceMappingURL=popconfirm.js.map
