import 'package:cipher_guard_sdk/src/presentation/facade/cipher_guard_sdk_api.dart';
import 'package:cipher_guard_sdk/src/presentation/wiring/cipher_guard_sdk_core.dart';
import 'package:cipher_guard_sdk/src/data/datasources/encryption_flutter_service.dart';
import 'package:cipher_guard_sdk/src/data/repositories/encryption_repository_impl.dart';
import 'package:cipher_guard_sdk/src/presentation/wiring/cipher_guard_sdk_api_impl.dart';

/// SDK 依賴注入容器
/// 負責組裝所有依賴
/// 使用 Flutter 本地加密服務，無需原生平台處理加密邏輯
class CipherGuardSdkWiring {
  /// 構建 SDK 實例
  static CipherGuardSdkApi build() {
    // 1. 創建 Flutter 加密服務
    final flutterService = EncryptionFlutterService();

    // 2. 創建 Repository (使用 Flutter 服務)
    final repository = EncryptionRepositoryImpl(flutterService);

    // 3. 創建 Platform (保留用於獲取版本等簡單信息)
    final platform = _CipherGuardPlatformImpl();

    // 4. 創建 Core
    final core = CipherGuardSdkCore(
      encryptionRepo: repository,
      platform: platform,
    );

    // 5. 返回 API 實作
    return CipherGuardSdkApiImpl(core: core);
  }
}

/// Platform 實作
class _CipherGuardPlatformImpl implements CipherGuardPlatform {
  _CipherGuardPlatformImpl();

  @override
  Future<String?> getPlatformVersion() async {
    return 'Flutter Native'; // 所有加密邏輯現在都在 Flutter 端執行
  }
}

