import { _ as _typeof } from '../_verture/typeof-498dd2b1.js';
import { _ as _slicedToArray } from '../_verture/slicedToArray-76060636.js';
import { _ as __rest } from '../_verture/tslib.es6-55ed4bd2.js';
import { jsx, jsxs } from 'react/jsx-runtime';
import { useRef, useState, useEffect } from 'react';
import clsx from 'clsx';
import LoadingOutlined from '@iam-com/icons/LoadingF';
import Forbid from '@iam-com/icons/Forbid';
import { Tooltip } from '../Tooltip/index.js';
import Down from '@iam-com/icons/Down';
import { $ as $prefixCls } from '../_verture/constant-66aa48a1.js';
import { s as styleInject } from '../_verture/style-inject.es-300983ab.js';
import { D as Dropdown } from '../_verture/index-fac03ce3.js';
import { u as useFormatMessage } from '../_verture/useFormatMessage-703f8b20.js';
import '../_verture/unsupportedIterableToArray-cb478f24.js';
import 'rc-tooltip';
import 'rc-tooltip/lib/placements';
import 'rc-dropdown';
import '../_verture/usePopupContainer-87febeb9.js';
import 'dayjs';
import '@iam-com/lib';
import '@para-ui/core/GlobalContext';

var en = {
  moreActions: 'More actions'
};

var zh = {
  moreActions: '更多操作'
};

var localeJson = {
  zh: zh,
  en: en
};

var css_248z = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/10/21 下午5:16\n* @description\n*/\n/**\n* @author Hanz\n* @date 2021/10/20 下午2:08\n* @description color\n*/\n@keyframes buttonLoadingSpin {\n  0% {\n    transform: rotate(0);\n  }\n  100% {\n    transform: rotate(360deg);\n  }\n}\n.paraui-v3-button {\n  border: 0;\n  cursor: pointer;\n  display: inline-flex;\n  outline: 0;\n  position: relative;\n  align-items: center;\n  user-select: none;\n  vertical-align: middle;\n  justify-content: center;\n  text-decoration: none;\n  background-color: transparent;\n  appearance: none;\n  -webkit-tap-highlight-color: transparent;\n  padding: 0 16px;\n  line-height: 1.5715;\n  border-radius: 4px;\n  font-family: -apple-system, BlinkMacSystemFont, Helvetica Neue, PingFang SC, Microsoft YaHei, Source Han Sans SC, Noto Sans CJK SC, WenQuanYi Micro Hei, sans-serif;\n  font-size: 14px;\n  font-weight: 400;\n  white-space: nowrap;\n  color: rgb(255, 255, 255);\n  box-sizing: border-box;\n  letter-spacing: 0.02857em;\n  transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, border 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\n}\n.paraui-v3-button .button-label {\n  width: 100%;\n  display: inherit;\n  align-items: inherit;\n  justify-content: inherit;\n}\n.paraui-v3-button .button-icon {\n  display: inherit;\n  margin-right: 4px;\n}\n.paraui-v3-button .button-icon svg {\n  color: inherit;\n  font-size: 16px;\n}\n.paraui-v3-button .button-icon-end {\n  margin-right: 0;\n  margin-left: 4px;\n}\n.paraui-v3-button .button-icon-loading {\n  animation: buttonLoadingSpin 1s infinite linear;\n}\n.paraui-v3-button-loading {\n  pointer-events: none;\n}\n.paraui-v3-button-contained {\n  color: rgb(255, 255, 255);\n  background-color: rgb(54, 102, 214);\n  border: 1px solid rgb(54, 102, 214);\n}\n.paraui-v3-button-contained:hover {\n  background-color: rgba(54, 102, 214, 0.8);\n  border: 1px solid rgba(255, 255, 255, 0);\n}\n.paraui-v3-button-contained.paraui-v3-button-link-disabled {\n  color: rgba(46, 55, 67, 0.4);\n  background-color: rgba(171, 176, 185, 0.12);\n  border: 1px solid rgba(171, 176, 185, 0.4);\n  cursor: default;\n  pointer-events: none;\n}\n.paraui-v3-button-contained.paraui-v3-button-link-disabled:hover {\n  background-color: rgba(171, 176, 185, 0.12);\n}\n.paraui-v3-button-contained[disabled] {\n  color: rgba(46, 55, 67, 0.4);\n  background-color: rgba(171, 176, 185, 0.12);\n  border: 1px solid rgba(171, 176, 185, 0.4);\n  cursor: default;\n  pointer-events: none;\n}\n.paraui-v3-button-contained[disabled]:hover {\n  background-color: rgba(171, 176, 185, 0.12);\n}\n.paraui-v3-button-contained.paraui-v3-button-dangerous {\n  background-color: rgb(235, 96, 84);\n  border: 1px solid rgb(235, 96, 84);\n}\n.paraui-v3-button-contained.paraui-v3-button-dangerous:hover {\n  background-color: rgba(235, 96, 84, 0.8);\n  border: 1px solid rgba(255, 255, 255, 0);\n}\n.paraui-v3-button-outlined {\n  color: rgba(46, 55, 67, 0.7);\n  background-color: rgb(255, 255, 255);\n  border: 1px solid rgba(171, 176, 185, 0.4);\n}\n.paraui-v3-button-outlined:hover {\n  color: rgb(54, 102, 214);\n  border-color: rgba(54, 102, 214, 0.2);\n  background-color: rgb(255, 255, 255);\n}\n.paraui-v3-button-outlined.paraui-v3-button-link-disabled {\n  color: rgba(46, 55, 67, 0.4);\n  background-color: rgba(171, 176, 185, 0.12);\n  border: 1px solid rgba(171, 176, 185, 0.4);\n  cursor: default;\n  pointer-events: none;\n}\n.paraui-v3-button-outlined.paraui-v3-button-link-disabled:hover {\n  background-color: rgba(171, 176, 185, 0.12);\n}\n.paraui-v3-button-outlined[disabled] {\n  color: rgba(46, 55, 67, 0.4);\n  background-color: rgba(171, 176, 185, 0.12);\n  border: 1px solid rgba(171, 176, 185, 0.4);\n  cursor: default;\n  pointer-events: none;\n}\n.paraui-v3-button-outlined[disabled]:hover {\n  background-color: rgba(171, 176, 185, 0.12);\n}\n.paraui-v3-button-outlined.paraui-v3-button-dangerous {\n  color: rgb(235, 96, 84);\n  border-color: rgb(235, 96, 84);\n}\n.paraui-v3-button-outlined.paraui-v3-button-dangerous:hover {\n  color: rgb(235, 96, 84);\n  border-color: rgba(235, 96, 84, 0.8);\n}\n.paraui-v3-button-text {\n  color: rgb(54, 102, 214);\n  background-color: transparent;\n  border: none;\n}\n.paraui-v3-button-text:hover {\n  color: rgba(54, 102, 214, 0.8);\n  background-color: transparent;\n}\n.paraui-v3-button-text.paraui-v3-button-link-disabled {\n  color: rgba(46, 55, 67, 0.4);\n  background-color: rgba(171, 176, 185, 0.12);\n  border: 1px solid rgba(171, 176, 185, 0.4);\n  cursor: default;\n  pointer-events: none;\n}\n.paraui-v3-button-text.paraui-v3-button-link-disabled:hover {\n  background-color: rgba(171, 176, 185, 0.12);\n}\n.paraui-v3-button-text[disabled] {\n  color: rgba(46, 55, 67, 0.4);\n  background-color: transparent;\n  border: none;\n  pointer-events: none;\n}\n.paraui-v3-button-text[disabled]:hover {\n  background-color: transparent;\n}\n.paraui-v3-button-text.paraui-v3-button-dangerous {\n  color: rgb(235, 96, 84);\n}\n.paraui-v3-button-text.paraui-v3-button-dangerous:hover {\n  color: rgba(235, 96, 84, 0.8);\n}\n.paraui-v3-button-large {\n  height: 36px;\n}\n.paraui-v3-button-medium {\n  height: 32px;\n}\n.paraui-v3-button-small {\n  height: 28px;\n}\n.paraui-v3-button--disabled {\n  display: inline-block;\n}\n\n.paraui-v3-icon-button {\n  flex: 0 0 auto;\n  overflow: visible;\n  text-align: center;\n  transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\n  padding: 0;\n  border-radius: 4px;\n}\n.paraui-v3-icon-button-loading {\n  pointer-events: none;\n}\n.paraui-v3-icon-button-loading .button-loading-icon {\n  display: inline-flex;\n  animation: buttonLoadingSpin 1s infinite linear;\n}\n.paraui-v3-icon-button svg {\n  color: inherit;\n  font-size: 16px;\n}\n.paraui-v3-icon-button-contained {\n  color: rgb(255, 255, 255);\n  background-color: rgb(54, 102, 214);\n}\n.paraui-v3-icon-button-contained:hover {\n  background-color: rgba(54, 102, 214, 0.8);\n  box-shadow: none;\n}\n.paraui-v3-icon-button-contained.paraui-v3-button-link-disabled {\n  color: rgba(46, 55, 67, 0.4);\n  background-color: rgba(171, 176, 185, 0.12);\n  border: 1px solid rgba(171, 176, 185, 0.4);\n  cursor: default;\n  pointer-events: none;\n}\n.paraui-v3-icon-button-contained.paraui-v3-button-link-disabled:hover {\n  background-color: rgba(171, 176, 185, 0.12);\n}\n.paraui-v3-icon-button-contained[disabled] {\n  color: rgba(46, 55, 67, 0.4);\n  background-color: rgba(171, 176, 185, 0.12);\n  border: 1px solid rgba(171, 176, 185, 0.4);\n  cursor: default;\n  pointer-events: none;\n}\n.paraui-v3-icon-button-contained[disabled]:hover {\n  background-color: rgba(171, 176, 185, 0.12);\n}\n.paraui-v3-icon-button-contained.paraui-v3-icon-button-dangerous {\n  background-color: rgb(235, 96, 84);\n}\n.paraui-v3-icon-button-contained.paraui-v3-icon-button-dangerous:hover {\n  background-color: rgba(235, 96, 84, 0.8);\n}\n.paraui-v3-icon-button-outlined {\n  color: rgba(46, 55, 67, 0.7);\n  background-color: rgb(255, 255, 255);\n  border: 1px solid rgba(171, 176, 185, 0.4);\n}\n.paraui-v3-icon-button-outlined:hover {\n  color: rgb(54, 102, 214);\n  border-color: rgba(54, 102, 214, 0.2);\n  box-shadow: none;\n  background-color: rgb(255, 255, 255);\n}\n.paraui-v3-icon-button-outlined.paraui-v3-button-link-disabled {\n  color: rgba(46, 55, 67, 0.4);\n  background-color: rgba(171, 176, 185, 0.12);\n  border: 1px solid rgba(171, 176, 185, 0.4);\n  cursor: default;\n  pointer-events: none;\n}\n.paraui-v3-icon-button-outlined.paraui-v3-button-link-disabled:hover {\n  background-color: rgba(171, 176, 185, 0.12);\n}\n.paraui-v3-icon-button-outlined[disabled] {\n  color: rgba(46, 55, 67, 0.4);\n  background-color: rgba(171, 176, 185, 0.12);\n  border: 1px solid rgba(171, 176, 185, 0.4);\n  cursor: default;\n  pointer-events: none;\n}\n.paraui-v3-icon-button-outlined[disabled]:hover {\n  background-color: rgba(171, 176, 185, 0.12);\n}\n.paraui-v3-icon-button-outlined.paraui-v3-icon-button-dangerous {\n  color: rgb(235, 96, 84);\n  border-color: rgb(235, 96, 84);\n}\n.paraui-v3-icon-button-outlined.paraui-v3-icon-button-dangerous:hover {\n  color: rgb(235, 96, 84);\n  border-color: rgba(235, 96, 84, 0.8);\n}\n.paraui-v3-icon-button-text {\n  color: rgb(54, 102, 214);\n}\n.paraui-v3-icon-button-text:hover {\n  color: rgba(54, 102, 214, 0.8);\n  background-color: transparent;\n}\n.paraui-v3-icon-button-text.paraui-v3-button-link-disabled {\n  pointer-events: none;\n  color: rgba(46, 55, 67, 0.4);\n}\n.paraui-v3-icon-button-text.paraui-v3-button-link-disabled:hover {\n  background-color: transparent;\n}\n.paraui-v3-icon-button-text[disabled] {\n  color: rgba(46, 55, 67, 0.4);\n  pointer-events: none;\n}\n.paraui-v3-icon-button-text[disabled]:hover {\n  background-color: transparent;\n}\n.paraui-v3-icon-button-text.paraui-v3-icon-button-dangerous {\n  color: rgb(235, 96, 84);\n}\n.paraui-v3-icon-button-text.paraui-v3-icon-button-dangerous:hover {\n  color: rgba(235, 96, 84, 0.8);\n}\n.paraui-v3-icon-button-text.paraui-v3-icon-button-large {\n  width: auto;\n  height: auto;\n}\n.paraui-v3-icon-button-text.paraui-v3-icon-button-large svg {\n  font-size: 28px;\n}\n.paraui-v3-icon-button-text.paraui-v3-icon-button-medium {\n  width: auto;\n  height: auto;\n}\n.paraui-v3-icon-button-text.paraui-v3-icon-button-medium svg {\n  font-size: 24px;\n}\n.paraui-v3-icon-button-text.paraui-v3-icon-button-small {\n  width: auto;\n  height: auto;\n}\n.paraui-v3-icon-button-text.paraui-v3-icon-button-small svg {\n  font-size: 20px;\n}\n.paraui-v3-icon-button-large {\n  width: 36px;\n  height: 36px;\n}\n.paraui-v3-icon-button-medium {\n  width: 32px;\n  height: 32px;\n}\n.paraui-v3-icon-button-small {\n  width: 28px;\n  height: 28px;\n}\n\n.paraui-v3-button-split {\n  display: inline-block;\n}\n.paraui-v3-button-split .paraui-v3-button-split--active {\n  color: rgb(54, 102, 214);\n}\n.paraui-v3-button-split-list {\n  padding: 8px 0;\n  border-radius: 4px;\n  background-color: rgb(255, 255, 255);\n}\n.paraui-v3-button-split-list ul .split-li {\n  padding: 11px 12px;\n  color: rgb(46, 55, 67);\n  font-size: 14px;\n  line-height: 1;\n  cursor: pointer;\n  transition: background-color 0.3s, color 0.3s;\n}\n.paraui-v3-button-split-list ul .split-li:hover {\n  background-color: rgba(171, 176, 185, 0.12);\n}\n.paraui-v3-button-split-list ul .split-li.split-li--active {\n  color: rgb(54, 102, 214);\n}\n.paraui-v3-button-split-list ul .split-li.split-li--active:hover {\n  background-color: rgba(171, 176, 185, 0.12);\n}\n.paraui-v3-button-split-list ul .split-li.split-li--hover:active {\n  color: rgb(54, 102, 214);\n}\n.paraui-v3-button-split-list ul .split-li.split-li--hover:hover {\n  background-color: rgba(171, 176, 185, 0.12);\n  color: rgb(54, 102, 214);\n}\n.paraui-v3-button-split-list ul .split-li.split-li--disabled {\n  color: rgba(46, 55, 67, 0.4);\n  cursor: not-allowed;\n}\n.paraui-v3-button-split-list ul .split-li.split-li--disabled:hover {\n  background-color: rgb(255, 255, 255);\n}\n.paraui-v3-button-split-list ul .split-li-group:not(:first-child) {\n  position: relative;\n  margin-top: 16px;\n}\n.paraui-v3-button-split-list ul .split-li-group:not(:first-child):before {\n  content: \"\";\n  position: absolute;\n  top: -8px;\n  left: 8px;\n  right: 8px;\n  border-top: 1px solid rgba(171, 176, 185, 0.2);\n}";
styleInject(css_248z);

//分体式按钮
function SplitButton(props) {
  var buttonText = props.buttonText,
    _props$options = props.options,
    options = _props$options === void 0 ? [] : _props$options,
    className = props.className,
    style = props.style,
    _props$disabled = props.disabled,
    disabled = _props$disabled === void 0 ? false : _props$disabled,
    onClick = props.onClick,
    optionRender = props.optionRender,
    _props$placement = props.placement,
    placement = _props$placement === void 0 ? 'bottomRight' : _props$placement,
    buttonProps = props.buttonProps,
    _props$iconButton = props.iconButton,
    iconButton = _props$iconButton === void 0 ? false : _props$iconButton,
    popperStyle = props.popperStyle,
    _props$popperClassNam = props.popperClassName,
    popperClassName = _props$popperClassNam === void 0 ? '' : _props$popperClassNam,
    getPopupContainer = props.getPopupContainer;
  var intl = useFormatMessage('Button', localeJson);
  var btnRef = useRef();
  // const [selectedIndex, setSelectedIndex] = useState<number | string>();
  // button click
  var handleButtonClick = function handleButtonClick(opt, index, event) {
    var _a;
    if (opt.disabled) {
      event.stopPropagation();
      return;
    }
    // setSelectedIndex(index);
    (_a = btnRef.current) === null || _a === void 0 ? void 0 : _a.classList.remove("".concat($prefixCls, "-button-split--active"));
    onClick === null || onClick === void 0 ? void 0 : onClick(opt, event);
  };
  //渲染按钮列表
  var renderButtonList = function renderButtonList() {
    //分组列表
    var generateLiGroup = function generateLiGroup(opt, index) {
      return jsx("li", Object.assign({
        className: 'split-li-group'
      }, {
        children: opt.map(function (gItem, gIndex) {
          var idx = "".concat(index, "-").concat(gIndex);
          return jsx("div", Object.assign({
            className: clsx('split-li',
            //  idx === selectedIndex && 'split-li--active',
            gItem.disabled ? 'split-li--disabled' : 'split-li--hover'),
            onClick: function onClick(evt) {
              return handleButtonClick(gItem, idx, evt);
            }
          }, {
            children: (optionRender === null || optionRender === void 0 ? void 0 : optionRender(gItem)) || gItem.label
          }), idx);
        })
      }), index);
    };
    return jsx("div", Object.assign({
      className: "".concat($prefixCls, "-button-split-list")
    }, {
      children: jsx("ul", {
        children: options.map(function (opt, index) {
          if (Array.isArray(opt)) {
            //分组
            return generateLiGroup(opt, index);
          }
          return jsx("li", Object.assign({
            className: clsx('split-li',
            // index === selectedIndex && 'split-li--active',
            opt.disabled ? 'split-li--disabled' : 'split-li--hover'),
            onClick: function onClick(evt) {
              return handleButtonClick(opt, index, evt);
            }
          }, {
            children: (optionRender === null || optionRender === void 0 ? void 0 : optionRender(opt)) || opt.label
          }), index);
        })
      })
    }));
  };
  //渲染button
  var renderButton = function renderButton() {
    if (iconButton) {
      return jsx(Button.IconButton, Object.assign({
        variant: 'text',
        size: "small",
        disabled: disabled
      }, buttonProps, {
        children: buttonText !== null && buttonText !== void 0 ? buttonText : intl({
          id: 'moreActions'
        })
      }));
    }
    return jsx(Button, Object.assign({
      variant: 'outlined',
      size: 'large',
      startIcon: jsx(Down, {}),
      disabled: disabled
    }, buttonProps, {
      children: buttonText !== null && buttonText !== void 0 ? buttonText : intl({
        id: 'moreActions'
      })
    }));
  };
  return jsx("div", Object.assign({
    className: clsx("".concat($prefixCls, "-button-split"), className),
    style: style
  }, {
    children: jsx(Dropdown, Object.assign({
      overlay: renderButtonList(),
      placement: placement,
      overlayStyle: popperStyle,
      overlayClassName: popperClassName,
      getPopupContainer: getPopupContainer
    }, {
      children: renderButton()
    }))
  }));
}

//按钮
var InternalButton = function InternalButton(props) {
  var _props$variant = props.variant,
    variant = _props$variant === void 0 ? 'contained' : _props$variant,
    _props$size = props.size,
    size = _props$size === void 0 ? 'large' : _props$size,
    className = props.className,
    _props$disabled = props.disabled,
    disabled = _props$disabled === void 0 ? false : _props$disabled,
    children = props.children,
    startIcon = props.startIcon,
    endIcon = props.endIcon,
    _props$loading = props.loading,
    loading = _props$loading === void 0 ? false : _props$loading,
    _props$toolTipTitle = props.toolTipTitle,
    toolTipTitle = _props$toolTipTitle === void 0 ? '' : _props$toolTipTitle,
    TooltipProps = props.TooltipProps,
    _props$danger = props.danger,
    danger = _props$danger === void 0 ? false : _props$danger,
    href = props.href,
    target = props.target,
    restProps = __rest(props, ["variant", "size", "className", "disabled", "children", "startIcon", "endIcon", "loading", "toolTipTitle", "TooltipProps", "danger", "href", "target"]);
  var _useState = useState(false),
    _useState2 = _slicedToArray(_useState, 2),
    hasLoading = _useState2[0],
    setHasLoading = _useState2[1];
  var isLinkBtn = ('href' in props);
  //cls
  var makeCls = function makeCls() {
    return clsx("".concat($prefixCls, "-button"), className, "".concat($prefixCls, "-button-").concat(variant), "".concat($prefixCls, "-button-").concat(size), hasLoading && "".concat($prefixCls, "-button-loading"), danger && !disabled && "".concat($prefixCls, "-button-dangerous"), isLinkBtn && "".concat($prefixCls, "-button-link"), isLinkBtn && disabled && "".concat($prefixCls, "-button-link-disabled"));
  };
  //渲染按钮图标
  var renderBtnIcon = function renderBtnIcon(pos) {
    if (!hasLoading) {
      if (pos === 'start' && startIcon) return jsx("span", Object.assign({
        className: 'button-icon'
      }, {
        children: startIcon
      }));
      if (pos === 'end' && endIcon) return jsx("span", Object.assign({
        className: 'button-icon button-icon-end'
      }, {
        children: endIcon
      }));
      return null;
    }
    if (_typeof(loading) === 'object') {
      var delay = loading.delay || 0;
      setTimeout(function () {
        return setHasLoading(false);
      }, delay);
    }
    if (pos === 'start') return jsx("span", Object.assign({
      className: 'button-icon button-icon-loading'
    }, {
      children: jsx(LoadingOutlined, {})
    }));
    return null;
  };
  //tooltip title
  var generateTooltipTitle = function generateTooltipTitle() {
    if (disabled && toolTipTitle) {
      var svgObj = {
        marginRight: '4px',
        fontSize: '11px',
        color: 'inherit'
      };
      return jsxs("span", {
        children: [jsx(Forbid, {
          style: svgObj
        }), toolTipTitle]
      });
    }
    return toolTipTitle;
  };
  //按钮
  var renderButton = function renderButton() {
    if (isLinkBtn) {
      return jsxs("a", Object.assign({}, restProps, {
        href: href,
        target: target,
        className: makeCls()
      }, {
        children: [renderBtnIcon('start'), children && jsx("span", Object.assign({
          className: 'button-label'
        }, {
          children: children
        })), renderBtnIcon('end')]
      }));
    }
    return jsxs("button", Object.assign({}, restProps, {
      disabled: disabled,
      type: "button",
      className: makeCls()
    }, {
      children: [renderBtnIcon('start'), children && jsx("span", Object.assign({
        className: 'button-label'
      }, {
        children: children
      })), renderBtnIcon('end')]
    }));
  };
  useEffect(function () {
    setHasLoading(!!loading);
  }, [loading]);
  return disabled && toolTipTitle ? jsx(Tooltip, Object.assign({
    arrow: false,
    placement: 'bottom'
  }, TooltipProps, {
    title: generateTooltipTitle()
  }, {
    children: jsx("span", Object.assign({
      className: "".concat($prefixCls, "-button--disabled")
    }, {
      children: renderButton()
    }))
  })) : renderButton();
};
//icon button
var IconButton = function IconButton(props) {
  var _props$variant2 = props.variant,
    variant = _props$variant2 === void 0 ? 'contained' : _props$variant2,
    _props$size2 = props.size,
    size = _props$size2 === void 0 ? 'large' : _props$size2,
    _props$toolTipTitle2 = props.toolTipTitle,
    toolTipTitle = _props$toolTipTitle2 === void 0 ? '' : _props$toolTipTitle2,
    children = props.children,
    className = props.className,
    _props$disabled2 = props.disabled,
    disabled = _props$disabled2 === void 0 ? false : _props$disabled2,
    _props$loading2 = props.loading,
    loading = _props$loading2 === void 0 ? false : _props$loading2,
    TooltipProps = props.TooltipProps,
    _props$danger2 = props.danger,
    danger = _props$danger2 === void 0 ? false : _props$danger2,
    href = props.href,
    target = props.target,
    restProps = __rest(props, ["variant", "size", "toolTipTitle", "children", "className", "disabled", "loading", "TooltipProps", "danger", "href", "target"]);
  var _useState3 = useState(false),
    _useState4 = _slicedToArray(_useState3, 2),
    hasLoading = _useState4[0],
    setHasLoading = _useState4[1];
  var isLinkBtn = ('href' in props);
  //cls
  var makeCls = function makeCls() {
    return clsx("".concat($prefixCls, "-button ").concat($prefixCls, "-icon-button"), className, "".concat($prefixCls, "-icon-button-").concat(variant), "".concat($prefixCls, "-icon-button-").concat(size), hasLoading && "".concat($prefixCls, "-icon-button-loading"), danger && !disabled && "".concat($prefixCls, "-icon-button-dangerous"), isLinkBtn && "".concat($prefixCls, "-button-link"), isLinkBtn && disabled && "".concat($prefixCls, "-button-link-disabled"));
  };
  //tooltip title
  var generateTooltipTitle = function generateTooltipTitle() {
    if (disabled && toolTipTitle) {
      var svgObj = {
        marginRight: '4px',
        fontSize: '11px',
        color: 'inherit'
      };
      return jsxs("span", {
        children: [jsx(Forbid, {
          style: svgObj
        }), toolTipTitle]
      });
    }
    return toolTipTitle;
  };
  //渲染图标
  var renderIcon = function renderIcon() {
    if (!hasLoading) return children;
    if (_typeof(loading) === 'object') {
      var delay = loading.delay || 0;
      setTimeout(function () {
        return setHasLoading(false);
      }, delay);
    }
    return jsx("span", Object.assign({
      className: 'button-loading-icon'
    }, {
      children: jsx(LoadingOutlined, {})
    }));
  };
  //icon button
  var renderIconButton = function renderIconButton() {
    if (isLinkBtn) {
      return jsx("a", Object.assign({}, restProps, {
        href: href,
        target: target,
        className: makeCls()
      }, {
        children: renderIcon()
      }));
    }
    return jsx("button", Object.assign({}, restProps, {
      disabled: disabled,
      type: "button",
      className: makeCls()
    }, {
      children: renderIcon()
    }));
  };
  useEffect(function () {
    setHasLoading(!!loading);
  }, [loading]);
  return !!toolTipTitle ? jsx(Tooltip, Object.assign({
    arrow: false,
    placement: 'bottom'
  }, TooltipProps, {
    title: generateTooltipTitle()
  }, {
    children: disabled ? jsx("span", Object.assign({
      className: "".concat($prefixCls, "-button--disabled")
    }, {
      children: renderIconButton()
    })) : renderIconButton()
  }), +hasLoading) : renderIconButton();
};
var Button = InternalButton;
Button.IconButton = IconButton;
Button.SplitButton = SplitButton;

export { Button, Button as default };
