'use strict';

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

var vue = require('vue');
var index = require('../../svg-icon/index.js');
var elementPlus = require('element-plus');

"use strict";
const __default__ = vue.defineComponent({
  name: "me-icon-button"
});
var script = /* @__PURE__ */ vue.defineComponent({
  ...__default__,
  props: {
    icon: { type: String, required: false, default: "" },
    click: { type: Function, required: false },
    color: { type: String, required: false },
    iconSize: { type: Number, required: false },
    hover: { type: Boolean, required: false },
    hoverColor: { type: String, required: false, default: "#f2f3f5" }
  },
  setup(__props, { expose: __expose }) {
    const slots = vue.useSlots();
    const props = __props;
    const loading = vue.ref(false);
    const getIcon = vue.computed(() => {
      const { icon } = props;
      const res = icon ? vue.h(index.MeSvgIcon, { name: props.icon, color: props.color, size2: props.iconSize }) : void 0;
      return res;
    });
    const onClick = () => {
      const { click } = props;
      if (click) {
        const clickRes = click();
        if (clickRes instanceof Promise) {
          loading.value = true;
          clickRes.finally(() => {
            loading.value = false;
          });
        }
      }
    };
    __expose({ click: onClick });
    return (_ctx, _cache) => {
      return vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElButton), vue.mergeProps({
        class: ["me-icon-button", { "not-default-slot": !vue.unref(slots)["default"] }],
        icon: getIcon.value,
        loading: loading.value
      }, _ctx.$attrs, {
        onClick,
        style: { fontSize: __props.iconSize + "px", "--hover-color": __props.hoverColor },
        text: __props.hover
      }), {
        default: vue.withCtx(() => [
          vue.renderSlot(_ctx.$slots, "default")
        ]),
        _: 3
        /* FORWARDED */
      }, 16, ["class", "icon", "loading", "style", "text"]);
    };
  }
});

exports.default = script;
//# sourceMappingURL=icon-button.vue2.js.map
