import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:im_app/app/di/db_provider.dart';
import 'package:im_app/data/repositories/chat_bot_repository_impl.dart';
import 'package:im_app/domain/entities/chat_bot.dart';
import 'package:im_app/domain/repositories/chat_bot_repository.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'chat_bot_provider.g.dart';

// ── Repository ────────────────────────────────────────────────────────────────

/// 聊天机器人仓储 Provider
final chatBotRepositoryProvider = Provider<ChatBotRepository>((ref) {
  return ChatBotRepositoryImpl(ref.watch(storageSdkProvider));
});

// ── Streams ───────────────────────────────────────────────────────────────────

/// 监听所有聊天机器人
@riverpod
Stream<List<ChatBot>> allChatBots(Ref ref) {
  return ref.watch(chatBotRepositoryProvider).watchAllChatBots();
}

/// 监听指定聊天机器人
@riverpod
Stream<ChatBot?> chatBot(Ref ref, int id) {
  return ref.watch(chatBotRepositoryProvider).watchChatBot(id);
}
