import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:flutter/foundation.dart';

import 'privacy_terms.dart';
import 'skip_geo.dart';
part 'app_config.freezed.dart';
part 'app_config.g.dart';

@freezed
class AppConfig with _$AppConfig {
  const factory AppConfig({
    List<String>? apiIps,
    List<String>? apiUrls,
    List<String>? routerApiUrls,
    List<String>? appStatUrls,
    List<String>? assetUrls,
    List<String>? logFileUploadUrls,
    List<String>? realityApiUrls,
    List<String>? realityAppStatUrls,
    List<String>? realityLogFileUploadUrls,
    bool? autoPing,
    int? autoPingInterval,
    List<String>? backupApiUrls,
    int? cacheDataEffectiveDays,
    List<Contacts>? contacts,
    List<Contacts>? follows,
    List<String>? providers,
    List<int>? signalThresholds,
    List<int>? packetLossThresholds,
    SkipGeo? skipGeo,
    List<SpeedTestTargetList>? speedTestTargetList,
    String? websiteUrl,
    bool? visitorDisabled, // 游客模式
    PrivacyTerms? privacyAgreement,
    String? email,
    List<String>? blackPkgs,
    List<String>? whitePkgs,
    int? accelerationSampleCount,
    int? minAccelerationSampleCount,
    int? connectionWarningThreshold,
    String? connectiveTestUrl,
    List<String>? disabledLogModules,
    String? realTimeDbPath,
    int? boostTimeInterval,
    int? pingDisplayMode,
    int? peekTimeInterval,
    bool? enableAd,
    int? adTimeoutDuration,
    int? reportActiveInterval,
    int? serverTime,
  }) = _AppConfig;

  factory AppConfig.fromJson(Map<String, Object?> json) =>
      _$AppConfigFromJson(json);
}

@freezed
class Contacts with _$Contacts {
  const factory Contacts({String? title, String? url}) = _Contacts;

  factory Contacts.fromJson(Map<String, Object?> json) =>
      _$ContactsFromJson(json);
}

@freezed
class SpeedTestTargetList with _$SpeedTestTargetList {
  const factory SpeedTestTargetList({String? title, String? url}) =
      _SpeedTestTargetList;

  factory SpeedTestTargetList.fromJson(Map<String, Object?> json) =>
      _$SpeedTestTargetListFromJson(json);
}
