function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
var _excluded = ["children", "className"],
  _excluded2 = ["icon"];
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import React, { memo } from 'react';
import { Dropdown } from 'antd';
import classNames from 'classnames';
import { Button } from '@pisell/materials';
import { locales } from '@pisell/utils';
var PREFIX = 'payment-result-toast-v2';
/**
 * V2 Toast 底部操作按钮。
 *
 * 视觉对齐 sale detail 底部按钮（深底 + 主色描边 + 圆角 + 图标 + 粗体白字）。
 * 由于 Toast 经游离容器渲染、脱离 app 的 antd 主题，按钮外观改由本地 less 显式实现
 * （见 PaymentResultToastV2.less 的 __action-btn）。
 *
 * 功能（onClick / menuData）沿用 generateActionButtons 产出，点击行为与旧 toast 完全一致。
 */
var ActionButtons = /*#__PURE__*/memo(function (_ref) {
  var _ref$buttonGroupList = _ref.buttonGroupList,
    buttonGroupList = _ref$buttonGroupList === void 0 ? [] : _ref$buttonGroupList,
    tone = _ref.tone;
  if (!buttonGroupList.length) return null;
  var isDanger = tone === 'error';
  return /*#__PURE__*/React.createElement("div", {
    className: "".concat(PREFIX, "__action-bar")
  }, buttonGroupList.map(function (row, rowIndex) {
    return /*#__PURE__*/React.createElement("div", {
      key: rowIndex,
      className: "".concat(PREFIX, "__action-row")
    }, row.map(function (item, index) {
      var _item$isMore = item.isMore,
        isMore = _item$isMore === void 0 ? false : _item$isMore,
        _item$id = item.id,
        id = _item$id === void 0 ? "".concat(rowIndex, "-").concat(index) : _item$id,
        _item$menuData = item.menuData,
        menuData = _item$menuData === void 0 ? [] : _item$menuData,
        buttonProps = item.buttonProps;

      // 去掉旧 demo 全局 className，统一用 V2 自有样式；保留语义 primary。
      var _ref2 = buttonProps || {},
        children = _ref2.children,
        className = _ref2.className,
        restButtonProps = _objectWithoutProperties(_ref2, _excluded);
      var isPrimary = typeof className === 'string' && className.includes('primary-button');
      var btnClassName = classNames("".concat(PREFIX, "__action-btn"), _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(PREFIX, "__action-btn--more"), isMore), "".concat(PREFIX, "__action-btn--grow"), !isMore), "".concat(PREFIX, "__action-btn--primary"), isPrimary), "".concat(PREFIX, "__action-btn--danger"), isDanger));
      if (isMore) {
        // More 按钮：文字按钮（对齐图示），不显示 dots 图标，保留下拉菜单
        var _icon = restButtonProps.icon,
          moreRest = _objectWithoutProperties(restButtonProps, _excluded2);
        var moreChildren = children !== null && children !== void 0 ? children : locales.getText('payment.result.more');
        return /*#__PURE__*/React.createElement(Dropdown, {
          key: id,
          menu: {
            items: menuData
          },
          trigger: ['click']
        }, /*#__PURE__*/React.createElement(Button, _extends({}, moreRest, {
          className: btnClassName
        }), moreChildren));
      }
      return /*#__PURE__*/React.createElement(Button, _extends({
        key: id
      }, restButtonProps, {
        className: btnClassName
      }), children);
    }));
  }));
});
ActionButtons.displayName = 'PaymentResultToastV2ActionButtons';
export default ActionButtons;