/**
 * tdesign v0.46.4
 * (c) 2022 tdesign
 * @license MIT
 */

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { Loading } from '../loading/index.js';
import props from './props.js';
import { renderContent, renderTNodeJSX } from '../utils/render-tnode.js';
import Ripple from '../utils/ripple.js';
import { getKeepAnimationMixins, getClassPrefixMixins } from '../config-provider/config-receiver.js';
import mixins from '../utils/mixins.js';
import '../loading/loading.js';
import '../loading/icon/gradient.js';
import '../_common/js/loading/circle-adapter.js';
import '../_common/js/utils/set-style.js';
import '../_common/js/utils/helper.js';
import '@babel/runtime/helpers/toConsumableArray';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/helpers/slicedToArray';
import '../utils/dom.js';
import 'vue';
import 'raf';
import 'lodash/isString';
import '../utils/easing.js';
import '../utils/transfer-dom.js';
import '../loading/props.js';
import '../utils/withInstall.js';
import 'lodash/capitalize';
import './style/index.js';
import '../loading/type.js';
import '../loading/plugin.js';
import '../config.js';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import 'lodash/merge';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '../config-provider/type.js';
import '@babel/runtime/helpers/typeof';
import 'lodash/camelCase';
import 'lodash/kebabCase';

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 keepAnimationMixins = getKeepAnimationMixins();
var classPrefixMixins = getClassPrefixMixins("button");
var TButton = mixins(keepAnimationMixins, classPrefixMixins).extend({
  name: "TButton",
  props: props,
  directives: {
    ripple: Ripple
  },
  render: function render(h) {
    var _ref,
        _this = this;

    var buttonContent = renderContent(this, "default", "content");
    var icon = this.loading ? h(Loading, {
      "attrs": {
        "inheritColor": true
      }
    }) : renderTNodeJSX(this, "icon");
    var disabled = this.disabled || this.loading;
    var theme = this.theme;

    if (!this.theme) {
      if (this.variant === "base") {
        theme = "primary";
      } else {
        theme = "default";
      }
    }

    var buttonClass = ["".concat(this.componentName), this.commonSizeClassName[this.size], "".concat(this.componentName, "--variant-").concat(this.variant), "".concat(this.componentName, "--theme-").concat(theme), (_ref = {}, _defineProperty(_ref, this.commonStatusClassName.disabled, this.disabled), _defineProperty(_ref, this.commonStatusClassName.loading, this.loading), _defineProperty(_ref, "".concat(this.componentName, "--shape-").concat(this.shape), this.shape !== "rectangle"), _defineProperty(_ref, "".concat(this.componentName, "--ghost"), this.ghost), _defineProperty(_ref, this.commonSizeClassName.block, this.block), _ref)];
    buttonContent = buttonContent ? h("span", {
      "class": "".concat(this.componentName, "__text")
    }, [buttonContent]) : "";

    if (icon) {
      buttonContent = [icon, buttonContent];
    }

    var on = _objectSpread({}, this.$listeners);

    if (typeof this.onClick === "function") {
      on.click = this.onClick;
    }

    var buttonAttrs = {
      type: this.type,
      disabled: disabled,
      href: this.href
    };

    var renderTag = function renderTag() {
      if (!_this.tag && _this.href) return "a";
      return _this.tag || "button";
    };

    return h(renderTag(), {
      "class": buttonClass,
      attrs: buttonAttrs,
      on: on,
      directives: [{
        name: "ripple",
        value: this.keepAnimation.ripple
      }]
    }, [buttonContent]);
  }
});

export { TButton as default };
//# sourceMappingURL=button.js.map
