/**
 * ldesign v0.2.2
 * (c) 2022年9月20日 swimly
 * @license MIT
 */

import { h as helper } from '../../chunks/helper.js';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { InfoCircleFilledIcon, ErrorCircleFilledIcon } from '@ldesign/icons-vue';
import mixins from '../../utils/mixins.js';
import getConfigReceiverMixins, { getGlobalIconMixins } from '../config-provider/config-receiver.js';
import { Popup } from '../popup/index.js';
import props from './props.js';
import { renderLNodeJSXDefault, renderContent, renderLNodeJSX } from '../../utils/render-node.js';
import { emitEvent } from '../../utils/event.js';
import ActionMixin from '../dialog/mixins/action.js';
import '../../chunks/_commonjsHelpers.js';
import 'vue';
import 'lodash/mergeWith';
import 'lodash';
import '../config-provider/context.js';
import '../../chunks/zh_CN.js';
import '../config-provider/type.js';
import '../popup/popup.js';
import '@babel/runtime/helpers/typeof';
import '@popperjs/core';
import '../../chunks/set-style.js';
import '../../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../../utils/easing.js';
import '../../utils/helper.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/helpers/slicedToArray';
import 'lodash/camelCase';
import '../popup/props.js';
import '../popup/container.js';
import 'lodash/kebabCase';
import '../../utils/map-props.js';
import '../../utils/with-install.js';
import '../../config.js';
import '../popup/style/css.js';
import '../popup/type.js';
import 'lodash/isObject';
import '../button/index.js';
import '../button/button.js';
import '../loading/index.js';
import '../loading/loading.js';
import '../loading/icon/gradient.js';
import '../../chunks/defineProperty-28395935.js';
import '../../chunks/helper2.js';
import '@babel/runtime/helpers/toConsumableArray';
import '../../utils/transfer-dom.js';
import '../loading/props.js';
import '../loading/style/css.js';
import '../loading/type.js';
import '../loading/plugin.js';
import '../button/props.js';
import '../../utils/ripple.js';
import '../button/style/css.js';
import '../button/type.js';

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(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 = mixins(ActionMixin, getConfigReceiverMixins("popconfirm"), getGlobalIconMixins()).extend({
  name: "LPopconfirm",
  props: _objectSpread({}, props),
  components: {
    LPopup: Popup
  },
  model: {
    prop: "visible",
    event: "visible-change"
  },
  computed: {
    themeIcon: function themeIcon() {
      var _this$useGlobalIcon = this.useGlobalIcon({
        InfoCircleFilledIcon: InfoCircleFilledIcon,
        ErrorCircleFilledIcon: ErrorCircleFilledIcon
      }),
          InfoCircleFilledIcon$1 = _this$useGlobalIcon.InfoCircleFilledIcon,
          ErrorCircleFilledIcon$1 = _this$useGlobalIcon.ErrorCircleFilledIcon;

      var iconMap = {
        "default": InfoCircleFilledIcon$1,
        warning: ErrorCircleFilledIcon$1,
        danger: ErrorCircleFilledIcon$1
      };
      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) {
      emitEvent(this, "cancel", {
        e: e
      });
      var cancelContext = {
        e: e,
        trigger: "cancel"
      };
      emitEvent(this, "visible-change", false, cancelContext);
    },
    confirmBtnAction: function confirmBtnAction(e) {
      emitEvent(this, "confirm", {
        e: e
      });
      var confirmContext = {
        e: e,
        trigger: "confirm"
      };
      emitEvent(this, "visible-change", false, confirmContext);
    },
    renderIcon: function renderIcon() {
      var h = this.$createElement;
      var LIcon = this.themeIcon;
      return renderLNodeJSXDefault(this, "icon", h(LIcon, {
        "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 = 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("l-popup", 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")
    }, [renderLNodeJSX(this, "content")])]), Boolean(cancelBtn || confirmBtn) && h("div", {
      "class": "".concat(this.componentName, "__buttons")
    }, [cancelBtn, confirmBtn])])]), triggerElement]);
  }
});

export { _Popconfirm as default };
//# sourceMappingURL=popconfirm.js.map
