'use strict';

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

var vue = require('vue');
var index$1 = require('../../icon/index.js');
require('../../../hooks/index.js');
var useButton = require('./use-button.js');
var button = require('./button.js');
var buttonCustom = require('./button-custom.js');
var pluginVue_exportHelper = require('../../../../_virtual/plugin-vue_export-helper.js');
var index = require('../../../hooks/use-namespace/index.js');

const _hoisted_1 = ["aria-disabled", "disabled", "autofocus", "type"];
const __default__ = vue.defineComponent({
  name: "ElButton"
});
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  ...__default__,
  props: button.buttonProps,
  emits: button.buttonEmits,
  setup(__props, { expose, emit }) {
    const props = __props;
    const buttonStyle = buttonCustom.useButtonCustomStyle(props);
    const ns = index.useNamespace("button");
    const { _ref, _size, _type, _link, _disabled, shouldAddSpace, handleClick } = useButton.useButton(props, emit);
    expose({
      ref: _ref,
      size: _size,
      type: _type,
      disabled: _disabled,
      shouldAddSpace
    });
    return (_ctx, _cache) => {
      const _directive_http_loading = vue.resolveDirective("http-loading");
      return vue.withDirectives((vue.openBlock(), vue.createElementBlock("button", {
        ref_key: "_ref",
        ref: _ref,
        class: vue.normalizeClass([
          vue.unref(ns).b(),
          vue.unref(ns).m(vue.unref(_type)),
          vue.unref(ns).m(vue.unref(_size)),
          vue.unref(ns).is("disabled", vue.unref(_disabled)),
          vue.unref(ns).is("border", _ctx.border),
          vue.unref(ns).is("loading", _ctx.loading),
          vue.unref(ns).is("plain", _ctx.plain),
          vue.unref(ns).is("round", _ctx.round),
          vue.unref(ns).is("circle", _ctx.circle),
          vue.unref(ns).is("text", _ctx.text),
          vue.unref(ns).is("link", vue.unref(_link)),
          vue.unref(ns).is("has-bg", _ctx.bg)
        ]),
        "aria-disabled": vue.unref(_disabled) || _ctx.loading,
        disabled: vue.unref(_disabled) || _ctx.loading,
        autofocus: _ctx.autofocus,
        type: _ctx.nativeType,
        style: vue.normalizeStyle(vue.unref(buttonStyle)),
        onClick: _cache[0] || (_cache[0] = (...args) => vue.unref(handleClick) && vue.unref(handleClick)(...args))
      }, [
        _ctx.$slots.loading ? vue.renderSlot(_ctx.$slots, "loading", { key: 0 }) : vue.createCommentVNode("v-if", true),
        vue.withDirectives(vue.createVNode(vue.unref(index$1.ElIcon), {
          "data-business-loading-icon": "",
          class: vue.normalizeClass(vue.unref(ns).is("loading")),
          size: "16"
        }, {
          default: vue.withCtx(() => [
            (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.loadingIcon)))
          ]),
          _: 1
        }, 8, ["class"]), [
          [vue.vShow, _ctx.loading && !_ctx.$slots.loading && _ctx.showLoading]
        ]),
        !_ctx.loading && (_ctx.icon || _ctx.$slots.icon) && _ctx.showLoading ? (vue.openBlock(), vue.createBlock(vue.unref(index$1.ElIcon), {
          key: 1,
          size: "16"
        }, {
          default: vue.withCtx(() => [
            _ctx.icon ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.icon), { key: 0 })) : vue.renderSlot(_ctx.$slots, "icon", { key: 1 })
          ]),
          _: 3
        })) : vue.createCommentVNode("v-if", true),
        _ctx.$slots.default ? (vue.openBlock(), vue.createElementBlock("span", {
          key: 2,
          style: vue.normalizeStyle({
            marginLeft: _ctx.loading && !_ctx.$slots.loading || !_ctx.loading && (_ctx.icon || _ctx.$slots.icon) ? "4px" : "0"
          }),
          class: vue.normalizeClass({ [vue.unref(ns).em("text", "expand")]: vue.unref(shouldAddSpace) })
        }, [
          vue.renderSlot(_ctx.$slots, "default")
        ], 6)) : vue.createCommentVNode("v-if", true)
      ], 14, _hoisted_1)), [
        [_directive_http_loading, _ctx.loadingGroup, _ctx.loadingType]
      ]);
    };
  }
});
var Button = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "/home/kimihiro/workfiles/dingdandao/element-plus/packages/components/button/src/button.vue"]]);

exports["default"] = Button;
//# sourceMappingURL=button2.js.map
