import 'package:flashlink/pigeons/core_api.g.dart' as pigeon;

import 'base_core_api.dart';

/// Android/iOS 实现 - 使用 Pigeon 生成的 CoreApi
class MobileCoreApi implements BaseCoreApi {
  MobileCoreApi._();

  /// 内部构造方法，供 BaseCoreApi 工厂使用
  factory MobileCoreApi.create() => MobileCoreApi._();

  final pigeon.CoreApi _coreApi = pigeon.CoreApi();

  @override
  Future<String?> getApps() => _coreApi.getApps();

  @override
  Future<String?> getSystemLocale() => _coreApi.getSystemLocale();

  @override
  Future<bool?> connect(
    String sessionId,
    int socksPort,
    String tunnelConfig,
    String configJson,
    int remainTime,
    bool isCountdown,
    List<String> allowVpnApps,
    List<String> disallowVpnApps,
    String accessToken,
    String aesKey,
    String aesIv,
    int locationId,
    String locationCode,
    List<String> baseUrls,
    String params,
    int peekTimeInterval,
  ) {
    return _coreApi.connect(
      sessionId,
      socksPort,
      tunnelConfig,
      configJson,
      remainTime,
      isCountdown,
      allowVpnApps,
      disallowVpnApps,
      accessToken,
      aesKey,
      aesIv,
      locationId,
      locationCode,
      baseUrls,
      params,
      peekTimeInterval,
    );
  }

  @override
  Future<bool?> disconnect() => _coreApi.disconnect();

  @override
  Future<String?> getRemoteIp() => _coreApi.getRemoteIp();

  @override
  Future<String?> getAdvertisingId() => _coreApi.getAdvertisingId();

  @override
  Future<bool?> moveTaskToBack() => _coreApi.moveTaskToBack();

  @override
  Future<bool?> isConnected() => _coreApi.isConnected();

  @override
  Future<String?> getSimInfo() => _coreApi.getSimInfo();

  @override
  Future<String?> getChannel() => _coreApi.getChannel();

  @override
  Future<void> openPackage(String packageName) =>
      _coreApi.openPackage(packageName);
}
