import '../../../networks_sdk.dart';
import '../../../networks_sdk_method_channel.dart';
import '../../../networks_sdk_platform_interface.dart';
import '../../data/datasources/networks_sdk_method_channel_datasource.dart';
import '../../data/repositories/networks_sdk_repository_impl.dart';
import 'networks_sdk_core.dart';
import 'networks_sdk_api_impl.dart';

/// SDK Wiring - builds all SDK components
class NetworksSdkWiring
{
  /// Builds the HTTP API
  static NetworksSdkApi buildApi() {

    // platform instance（method channel）
    final platform = NetworksSdkPlatform.instance;
    if (platform is MethodChannelNetworksSdk) {
      // platform.init(); // or defer to NotificationApiImpl.init
    }

    // data layer
    final ds =  NetworksSdkMethodChannelDataSource(platform);
    final repo =  NetworksSdkRepositoryImpl(ds);
    final core =  NetworksSdkCore(platform: platform, repo: repo,);

    return NetworksSdkApiImpl(core: core);
  }

  /// Builds the messaging API (WebSocket)
  static NetworksMessagingApi buildMessagingApi() {
    return NetworksMessagingApiImpl();
  }

  /// Builds the default SDK instance (HTTP API)
  /// Use [buildMessagingApi()] separately for messaging features
  static NetworksSdkApi build() => buildApi();
}
