import { observable } from "../_vendor/@legendapp/state/index.js";
const streamingStore$ = observable({
  // 当前流式传输的聊天会话 ID
  currentChatId: null,
  // 当前流式传输的消息 ID
  currentMessageId: null,
  // 是否正在进行流式传输
  isStreaming: false
});
const streamingComputed$ = observable({
  // 是否有活跃的流式传输（正在传输且有消息ID）
  hasActiveStream: () => {
    return streamingStore$.isStreaming.get() && streamingStore$.currentMessageId.get() !== null;
  },
  // 获取完整的流式传输状态信息
  streamingStatus: () => {
    return {
      isStreaming: streamingStore$.isStreaming.get(),
      currentMessageId: streamingStore$.currentMessageId.get(),
      currentChatId: streamingStore$.currentChatId.get()
    };
  }
});
const streamingActions = {
  // 开始流式传输
  startStreaming: (messageId, chatId) => {
    streamingStore$.isStreaming.set(true);
    streamingStore$.currentMessageId.set(messageId);
    streamingStore$.currentChatId.set(chatId);
  },
  // 停止流式传输
  stopStreaming: () => {
    streamingStore$.isStreaming.set(false);
    streamingStore$.currentMessageId.set(null);
    streamingStore$.currentChatId.set(null);
  },
  // 设置流式传输状态（通用方法）
  // ❌ 未使用
  setStreamingState: (isStreaming, messageId, chatId) => {
    streamingStore$.isStreaming.set(isStreaming);
    streamingStore$.currentMessageId.set(messageId || null);
    streamingStore$.currentChatId.set(chatId || null);
  },
  // 更新当前流式传输的消息ID
  // 当消息类型变化导致消息分离时，需要更新到新的消息ID
  updateCurrentMessageId: (newMessageId) => {
    if (streamingStore$.isStreaming.get()) {
      streamingStore$.currentMessageId.set(newMessageId);
    }
  }
};
export {
  streamingActions,
  streamingComputed$,
  streamingStore$
};
//# sourceMappingURL=streaming-store.js.map
