"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const messageTypeDetector = require("./message-type-detector.cjs");
const core = require("../types/core.cjs");
function mapChunkTypeToContentType(chunkType) {
  return messageTypeDetector.messageTypeDetector.mapBackendType(chunkType);
}
function detectMessageContentType(content, language) {
  return messageTypeDetector.messageTypeDetector.detectMessageType(content);
}
function enhanceMessage(message, language) {
  if (message.role !== "assistant" || message.contentType) {
    return message;
  }
  const contentType = detectMessageContentType(message.content);
  return {
    ...message,
    contentType
  };
}
function createEnhancedMessage(message, language) {
  const now = (/* @__PURE__ */ new Date()).toISOString();
  const completeMessage = {
    content: "",
    role: core.Role.Assistant,
    status: core.Status.Completed,
    timestamp: now,
    createdAt: now,
    version: 1,
    ...message,
    // 覆盖默认值
    id: message.id
    // 确保 id 总是存在
  };
  if (completeMessage.role === core.Role.Assistant && !completeMessage.contentType && completeMessage.content) {
    completeMessage.contentType = detectMessageContentType(completeMessage.content);
  }
  return completeMessage;
}
exports.createEnhancedMessage = createEnhancedMessage;
exports.detectMessageContentType = detectMessageContentType;
exports.enhanceMessage = enhanceMessage;
exports.mapChunkTypeToContentType = mapChunkTypeToContentType;
//# sourceMappingURL=message-utils.cjs.map
