/**
 * ldesign v0.2.14
 * (c) 2022/11/2 16:16 built by swimly
 * @license MIT
 */

import { h as helper } from '../../../_chunks/dep-29915b8e.js';
import Vue from 'vue';
import isString from 'lodash/isString';
import isObject from 'lodash/isObject';
import { renderLNodeJSX } from '../../../utils/render-node.js';
import { Button } from '../../button/index.js';
import 'lodash';
import '../../../utils/with-install.js';
import '../../../config.js';
import '../../button/button.js';
import '@ldesign/icons-vue';
import '../../loading/index.js';
import '../../loading/loading.js';
import '../../../utils/dom.js';
import 'raf';
import '../../../_chunks/dep-70c789e5.js';
import '../../../_chunks/dep-5210251b.js';
import '../../../utils/easing.js';
import '../../../utils/transfer-dom.js';
import '../../config-provider/config-receiver.js';
import 'lodash/mergeWith';
import '../../config-provider/context.js';
import '../../../_chunks/dep-def4c2ce.js';
import '../../../utils/mixins.js';
import '../../loading/props.js';
import '../../loading/icon/gradient.js';
import '../../../_chunks/dep-eb467ddf.js';
import '../../../_chunks/dep-cf772670.js';
import '../../../_chunks/dep-47d77fc8.js';
import '../../loading/plugin.js';
import '../../../utils/ripple.js';
import '../../button/props.js';

var ActionMixin = Vue.extend({
  methods: {
    getConfirmBtn(options) {
      const h = this.$createElement;
      const {
        confirmBtn,
        className
      } = options;
      if (confirmBtn === null) return null;
      if (confirmBtn && this.$scopedSlots.confirmBtn) console.warn("Both $props.confirmBtn and $scopedSlots.confirmBtn exist, $props.confirmBtn is preferred.");
      const defaultButtonProps = this.getDefaultConfirmBtnProps(options);
      if (!confirmBtn && !this.$scopedSlots.confirmBtn) return h(Button, helper([{
        "class": className
      }, {
        "props": {
          ...defaultButtonProps
        }
      }]));
      if (confirmBtn && ["string", "object"].includes(typeof confirmBtn)) return this.getButtonByProps(confirmBtn, defaultButtonProps, className);
      return renderLNodeJSX(this, "confirmBtn");
    },
    getCancelBtn(options) {
      const h = this.$createElement;
      const {
        cancelBtn,
        className
      } = options;
      if (cancelBtn === null) return null;
      if (cancelBtn && this.$scopedSlots.cancelBtn) console.warn("Both $props.cancelBtn and $scopedSlots.cancelBtn exist, $props.cancelBtn is preferred.");
      const defaultButtonProps = this.getDefaultCancelBtnProps(options);
      if (!cancelBtn && !this.$scopedSlots.cancelBtn) return h(Button, helper([{
        "class": className
      }, {
        "props": {
          ...defaultButtonProps
        }
      }]));
      if (cancelBtn && ["string", "object"].includes(typeof cancelBtn)) return this.getButtonByProps(cancelBtn, defaultButtonProps);
      return renderLNodeJSX(this, "cancelBtn");
    },
    getButtonByProps(button, defaultButton, className) {
      const h = this.$createElement;
      let newOptions = defaultButton;
      if (isString(button)) newOptions.content = button;else if (isObject(button)) newOptions = {
        ...newOptions,
        ...button
      };
      return h(Button, helper([{
        "class": className
      }, {
        "props": newOptions
      }]));
    },
    confirmBtnAction(e) {},
    cancelBtnAction(e) {},
    getDefaultConfirmBtnProps(options) {
      const {
        globalConfirm,
        theme,
        globalConfirmBtnTheme
      } = options;
      const defaultTheme = (globalConfirmBtnTheme === null || globalConfirmBtnTheme === void 0 ? void 0 : globalConfirmBtnTheme[theme]) || "primary";
      let props = {
        theme: defaultTheme,
        content: "\u786E\u5B9A",
        size: options.size,
        onClick: e => {
          this.confirmBtnAction(e);
        }
      };
      if (isString(globalConfirm)) props.content = globalConfirm;else if (isObject(globalConfirm)) props = {
        ...props,
        ...globalConfirm
      };
      return props;
    },
    getDefaultCancelBtnProps(options) {
      const {
        globalCancel
      } = options;
      let props = {
        theme: "default",
        content: "\u53D6\u6D88",
        size: options.size,
        onClick: e => {
          this.cancelBtnAction(e);
        }
      };
      if (isString(globalCancel)) props.content = globalCancel;else if (isObject(globalCancel)) props = {
        ...props,
        ...globalCancel
      };
      return props;
    }
  }
});

export { ActionMixin as default };
//# sourceMappingURL=action.js.map
