var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/hooks/usePaymentLogger.ts
var usePaymentLogger_exports = {};
__export(usePaymentLogger_exports, {
  default: () => usePaymentLogger_default
});
module.exports = __toCommonJS(usePaymentLogger_exports);
var import_react = require("react");
var import_utils = require("@pisell/utils");
var import_ahooks = require("ahooks");
var usePaymentLogger = (options) => {
  const { orderId, step = "unknown" } = options;
  const logs = (0, import_react.useRef)([]);
  const addLog = (0, import_ahooks.useMemoizedFn)((logData) => {
    logs.current.push({
      key: logData.key,
      value: logData.value
    });
  });
  const sendLogs = (0, import_ahooks.useMemoizedFn)((title = "支付日志", err) => {
    const content = [
      {
        key: "title",
        value: title
      },
      ...logs.current
    ];
    if (err) {
      content.push(
        ...[
          { key: "错误信息", value: (err == null ? void 0 : err.message) || "未知错误" },
          { key: "错误堆栈", value: (err == null ? void 0 : err.stack) || "无堆栈信息" },
          { key: "错误类型", value: (err == null ? void 0 : err.name) || "未知错误类型" }
        ]
      );
    }
    const formatLogs = content.map((item) => ({
      key: item.key,
      value: JSON.stringify(item.value)
    }));
    (0, import_utils.sendWarningLog)({
      title: `h5支付step${step}:${orderId}`,
      content: formatLogs
    });
  });
  return {
    logs,
    addLog,
    sendLogs
  };
};
var usePaymentLogger_default = usePaymentLogger;
