'use strict';

var messageList = require('@mastra/core/agent/message-list');

// src/convert-messages.ts
function isSystemReminderUIMessage(message) {
  if (message.metadata?.systemReminder || message.metadata?.dynamicAgentsMdReminder) {
    return true;
  }
  if (message.role !== "user") {
    return false;
  }
  if (Array.isArray(message.parts)) {
    return message.parts.some(
      (part) => part.type === "text" && typeof part.text === "string" && part.text.includes("<system-reminder")
    );
  }
  return typeof message.content === "string" && message.content.includes("<system-reminder");
}
function filterSystemReminderUIMessages(messages) {
  return messages.filter((message) => !isSystemReminderUIMessage(message));
}
function toAISdkMessages(messages, options = {}) {
  const list = new messageList.MessageList().add(messages, `memory`);
  if (options.version === "v6") {
    return filterSystemReminderUIMessages(list.get.all.aiV6.ui());
  }
  return filterSystemReminderUIMessages(list.get.all.aiV5.ui());
}
function toAISdkV5Messages(messages) {
  return filterSystemReminderUIMessages(toAISdkMessages(messages));
}
function toAISdkV4Messages(messages) {
  return filterSystemReminderUIMessages(new messageList.MessageList().add(messages, `memory`).get.all.aiV4.ui());
}

exports.toAISdkMessages = toAISdkMessages;
exports.toAISdkV4Messages = toAISdkV4Messages;
exports.toAISdkV5Messages = toAISdkV5Messages;
//# sourceMappingURL=ui.cjs.map
//# sourceMappingURL=ui.cjs.map