import { defineComponent, useSlots, ref, computed, h, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot } from 'vue';
import { MeSvgIcon } from '../../svg-icon/index.mjs';
import { ElButton } from 'element-plus';

"use strict";
const __default__ = defineComponent({
  name: "me-icon-button"
});
var script = /* @__PURE__ */ 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 = useSlots();
    const props = __props;
    const loading = ref(false);
    const getIcon = computed(() => {
      const { icon } = props;
      const res = icon ? h(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 openBlock(), createBlock(unref(ElButton), mergeProps({
        class: ["me-icon-button", { "not-default-slot": !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: withCtx(() => [
          renderSlot(_ctx.$slots, "default")
        ]),
        _: 3
        /* FORWARDED */
      }, 16, ["class", "icon", "loading", "style", "text"]);
    };
  }
});

export { script as default };
//# sourceMappingURL=icon-button.vue2.mjs.map
