package com.twitter.frigate.pushservice.params

import com.twitter.finagle.stats.StatsReceiver
import com.twitter.frigate.common.util.{FeatureSwitchParams => Common}
import com.twitter.frigate.pushservice.params.{PushFeatureSwitchParams => Pushservice}
import com.twitter.logging.Logger
import com.twitter.servo.decider.DeciderGateBuilder
import com.twitter.timelines.configapi.BaseConfigBuilder
import com.twitter.timelines.configapi.FeatureSwitchOverrideUtil
import com.twitter.timelines.configapi.decider.DeciderUtils

case class PushFeatureSwitches(
  deciderGateBuilder: DeciderGateBuilder,
  statsReceiver: StatsReceiver) {

  private[this] val logger = Logger(classOf[PushFeatureSwitches])
  private[this] val stat = statsReceiver.scope("PushFeatureSwitches")

  private val booleanDeciderOverrides = DeciderUtils.getBooleanDeciderOverrides(
    deciderGateBuilder,
    PushParams.DisableAllRelevanceParam,
    PushParams.DisableHeavyRankingParam,
    PushParams.RestrictLightRankingParam,
    PushParams.UTEGTweetCandidateSourceParam,
    PushParams.EnableWritesToNotificationServiceParam,
    PushParams.EnableWritesToNotificationServiceForAllEmployeesParam,
    PushParams.EnableWritesToNotificationServiceForEveryoneParam,
    PushParams.EnablePromptFeedbackFatigueResponseNoPredicate,
    PushParams.EarlyBirdSCBasedCandidatesParam,
    PushParams.MRTweetFavRecsParam,
    PushParams.MRTweetRetweetRecsParam,
    PushParams.EnablePushSendEventBus,
    PushParams.DisableMlInFilteringParam,
    PushParams.DownSampleLightRankingScribeCandidatesParam,
    PushParams.EnableMrRequestScribing,
    PushParams.EnableHighQualityCandidateScoresScribing,
    PushParams.EnablePnegMultimodalPredictionForF1Tweets,
    PushParams.EnableScribeOonFavScoreForF1Tweets,
    PushParams.EnableMrUserSemanticCoreFeaturesHydration,
    PushParams.EnableMrUserSemanticCoreNoZeroFeaturesHydration,
    PushParams.EnableHtlOfflineUserAggregatesExtendedHydration,
    PushParams.EnableNerErgFeatureHydration,
    PushParams.EnableDaysSinceRecentResurrectionFeatureHydration,
    PushParams.EnableUserPastAggregatesFeatureHydration,
    PushParams.EnableMrUserSimclusterV2020FeaturesHydration,
    PushParams.EnableMrUserSimclusterV2020NoZeroFeaturesHydration,
    PushParams.EnableTopicEngagementRealTimeAggregatesFeatureHydration,
    PushParams.EnableUserTopicAggregatesFeatureHydration,
    PushParams.EnableHtlUserAuthorRTAFeaturesFromFeatureStoreHydration,
    PushParams.EnableDurationSinceLastVisitFeatures,
    PushParams.EnableTweetAnnotationFeaturesHydration,
    PushParams.EnableSpaceVisibilityLibraryFiltering,
    PushParams.EnableUserTopicFollowFeatureSetHydration,
    PushParams.EnableOnboardingNewUserFeatureSetHydration,
    PushParams.EnableMrUserAuthorSparseContFeatureSetHydration,
    PushParams.EnableMrUserTopicSparseContFeatureSetHydration,
    PushParams.EnableUserPenguinLanguageFeatureSetHydration,
    PushParams.EnableMrUserHashspaceEmbeddingFeatureHydration,
    PushParams.EnableMrUserEngagedTweetTokensFeatureHydration,
    PushParams.EnableMrCandidateTweetTokensFeatureHydration,
    PushParams.EnableMrTweetSentimentFeatureHydration,
    PushParams.EnableMrTweetAuthorAggregatesFeatureHydration,
    PushParams.EnableUserGeoFeatureSetHydration,
    PushParams.EnableAuthorGeoFeatureSetHydration,
    PushParams.EnableTwHINUserEngagementFeaturesHydration,
    PushParams.EnableTwHINUserFollowFeaturesHydration,
    PushParams.EnableTwHINAuthorFollowFeaturesHydration,
    PushParams.EnableAuthorFollowTwhinEmbeddingFeatureHydration,
    PushParams.RampupUserGeoFeatureSetHydration,
    PushParams.RampupAuthorGeoFeatureSetHydration,
    PushParams.EnablePredicateDetailedInfoScribing,
    PushParams.EnablePushCapInfoScribing,
    PushParams.EnableUserSignalLanguageFeatureHydration,
    PushParams.EnableUserPreferredLanguageFeatureHydration,
    PushParams.PopGeoCandidatesDecider,
    PushParams.TrendsCandidateDecider,
    PushParams.EnableInsTrafficDecider,
    PushParams.EnableModelBasedPushcapAssignments,
    PushParams.TripGeoTweetCandidatesDecider,
    PushParams.ContentRecommenderMixerAdaptorDecider,
    PushParams.GenericCandidateAdaptorDecider,
    PushParams.TripGeoTweetContentMixerDarkTrafficDecider,
    PushParams.EnableIsTweetTranslatableCheck,
    PushParams.EnableMrTweetSimClusterFeatureHydration,
    PushParams.EnableTwistlyAggregatesFeatureHydration,
    PushParams.EnableTweetTwHINFavFeatureHydration,
    PushParams.EnableRealGraphV2FeatureHydration,
    PushParams.EnableTweetBeTFeatureHydration,
    PushParams.EnableMrOfflineUserTweetTopicAggregateHydration,
    PushParams.EnableMrOfflineUserTweetSimClusterAggregateHydration,
    PushParams.EnableUserSendTimeFeatureHydration,
    PushParams.EnableMrUserUtcSendTimeAggregateFeaturesHydration,
    PushParams.EnableMrUserLocalSendTimeAggregateFeaturesHydration,
    PushParams.EnableBqmlReportModelPredictionForF1Tweets,
    PushParams.EnableUserTwhinEmbeddingFeatureHydration,
    PushParams.EnableScribingMLFeaturesAsDataRecord,
    PushParams.EnableAuthorVerifiedFeatureHydration,
    PushParams.EnableAuthorCreatorSubscriptionFeatureHydration,
    PushParams.EnableDirectHydrationForUserFeatures
  )

  private val intFeatureSwitchOverrides = FeatureSwitchOverrideUtil.getBoundedIntFSOverrides(
    Pushservice.SportsMaxNumberOfPushesInIntervalPerEvent,
    Pushservice.SportsMaxNumberOfPushesInInterval,
    Pushservice.PushMixerMaxResults,
    Pushservice.MaxTrendTweetNotificationsInDuration,
    Pushservice.MaxRecommendedTrendsToQuery,
    Pushservice.NumberOfMaxEarlybirdInNetworkCandidatesParam,
    Pushservice.NumberOfMaxCandidatesToBatchInRFPHTakeStep,
    Pushservice.MaxMrPushSends24HoursParam,
    Pushservice.MaxMrPushSends24HoursNtabOnlyUsersParam,
    Pushservice.NumberOfMaxCrMixerCandidatesParam,
    Pushservice.RestrictStepSize,
    Pushservice.MagicFanoutRankErgThresholdHeavy,
    Pushservice.MagicFanoutRankErgThresholdNonHeavy,
    Pushservice.MagicFanoutRelaxedEventIdFatigueIntervalInHours,
    Pushservice.NumberOfMaxUTEGCandidatesQueriedParam,
    Pushservice.HTLVisitFatigueTime,
    Pushservice.MaxOnboardingPushInInterval,
    Pushservice.MaxTopTweetsByGeoPushGivenInterval,
    Pushservice.MaxHighQualityTweetsPushGivenInterval,
    Pushservice.MaxTopTweetsByGeoCandidatesToTake,
    Pushservice.SpaceRecsRealgraphThreshold,
    Pushservice.SpaceRecsGlobalPushLimit,
    Pushservice.OptoutExptPushCapParam,
    Pushservice.MaxTopTweetImpressionsNotifications,
    Pushservice.TopTweetImpressionsMinRequired,
    Pushservice.TopTweetImpressionsThreshold,
    Pushservice.TopTweetImpressionsOriginalTweetsNumDaysSearch,
    Pushservice.TopTweetImpressionsMinNumOriginalTweets,
    Pushservice.TopTweetImpressionsMaxFavoritesPerTweet,
    Pushservice.TopTweetImpressionsTotalInboundFavoritesLimit,
    Pushservice.TopTweetImpressionsTotalFavoritesLimitNumDaysSearch,
    Pushservice.TopTweetImpressionsRecentTweetsByAuthorStoreMaxResults,
    Pushservice.ANNEfQuery,
    Pushservice.NumberOfMaxMrModelingBasedCandidates,
    Pushservice.ThresholdOfFavMrModelingBasedCandidates,
    Pushservice.LightRankingNumberOfCandidatesParam,
    Pushservice.NumberOfDeTopicTweetCandidates,
    Pushservice.NumberOfMaxDeTopicTweetCandidatesReturned,
    Pushservice.OverrideNotificationsMaxNumOfSlots,
    Pushservice.OverrideNotificationsMaxCountForNTab,
    Pushservice.MFMaxNumberOfPushesInInterval,
    Pushservice.SpacesTopKSimClusterCount,
    Pushservice.SpaceRecsSimClusterUserMinimumFollowerCount,
    Pushservice.OONSpaceRecsPushLimit,
    Pushservice.MagicFanoutRealgraphRankThreshold,
    Pushservice.CustomizedPushCapOffset,
    Pushservice.NumberOfF1CandidatesThresholdForOONBackfill,
    Pushservice.MinimumAllowedAuthorAccountAgeInHours,
    Pushservice.RestrictedMinModelPushcap,
    Pushservice.ListRecommendationsGeoHashLength,
    Pushservice.ListRecommendationsSubscriberCount,
    Pushservice.MaxListRecommendationsPushGivenInterval,
    Pushservice.SendTimeByUserHistoryMaxOpenedThreshold,
    Pushservice.SendTimeByUserHistoryNoSendsHours,
    Pushservice.SendTimeByUserHistoryQuickSendBeforeHours,
    Pushservice.SendTimeByUserHistoryQuickSendAfterHours,
    Pushservice.SendTimeByUserHistoryQuickSendMinDurationInMinute,
    Pushservice.SendTimeByUserHistoryNoSendMinDuration,
    Pushservice.F1EmojiCopyNumOfPushesFatigue,
    Pushservice.OonEmojiCopyNumOfPushesFatigue,
    Pushservice.TripTweetMaxTotalCandidates,
    Pushservice.InlineFeedbackSubstitutePosition,
    Pushservice.HighQualityCandidatesNumberOfCandidates,
    Pushservice.HighQualityCandidatesMinNumOfCandidatesToFallback,
    Pushservice.ProductLaunchMaxNumberOfPushesInInterval,
    Pushservice.CreatorSubscriptionPushMaxNumberOfPushesInInterval,
    Pushservice.NewCreatorPushMaxNumberOfPushesInInterval,
    Pushservice.TweetReplytoLikeRatioReplyCountThreshold,
    Pushservice.MaxExploreVideoTweets,
  )

  private val doubleFeatureSwitchOverrides =
    FeatureSwitchOverrideUtil.getBoundedDoubleFSOverrides(
      Pushservice.PercentileThresholdCohort1,
      Pushservice.PercentileThresholdCohort2,
      Pushservice.PercentileThresholdCohort3,
      Pushservice.PercentileThresholdCohort4,
      Pushservice.PercentileThresholdCohort5,
      Pushservice.PercentileThresholdCohort6,
      Pushservice.PnsfwTweetTextThreshold,
      Pushservice.PnsfwTweetTextBucketingThreshold,
      Pushservice.PnsfwTweetMediaThreshold,
      Pushservice.PnsfwTweetImageThreshold,
      Pushservice.PnsfwQuoteTweetThreshold,
      Pushservice.PnsfwTweetMediaBucketingThreshold,
      Pushservice.AgathaCalibratedNSFWThreshold,
      Pushservice.AgathaCalibratedNSFWThresholdForMrTwistly,
      Pushservice.AgathaTextNSFWThreshold,
      Pushservice.AgathaTextNSFWThresholdForMrTwistly,
      Pushservice.AgathaCalibratedNSFWBucketThreshold,
      Pushservice.AgathaTextNSFWBucketThreshold,
      Pushservice.BucketOptoutThresholdParam,
      Pushservice.TweetMediaSensitiveCategoryThresholdParam,
      Pushservice.CandidateGenerationModelCosineThreshold,
      Pushservice.MrModelingBasedCandidatesTopicScoreThreshold,
      Pushservice.HashspaceCandidatesTopicScoreThreshold,
      Pushservice.FrsTweetCandidatesTopicScoreThreshold,
      Pushservice.TopicProofTweetCandidatesTopicScoreThreshold,
      Pushservice.SpacesTargetingSimClusterDotProductThreshold,
      Pushservice.SautOonWithMediaTweetLengthThresholdParam,
      Pushservice.NonSautOonWithMediaTweetLengthThresholdParam,
      Pushservice.SautOonWithoutMediaTweetLengthThresholdParam,
      Pushservice.NonSautOonWithoutMediaTweetLengthThresholdParam,
      Pushservice.ArgfOonWithMediaTweetWordLengthThresholdParam,
      Pushservice.EsfthOonWithMediaTweetWordLengthThresholdParam,
      Pushservice.BqmlQualityModelPredicateThresholdParam,
      Pushservice.LightRankingScribeCandidatesDownSamplingParam,
      Pushservice.QualityUprankingBoostForHeavyRankingParam,
      Pushservice.QualityUprankingSigmoidBiasForHeavyRankingParam,
      Pushservice.QualityUprankingSigmoidWeightForHeavyRankingParam,
      Pushservice.QualityUprankingLinearBarForHeavyRankingParam,
      Pushservice.QualityUprankingBoostForHighQualityProducersParam,
      Pushservice.QualityUprankingDownboostForLowQualityProducersParam,
      Pushservice.BqmlHealthModelPredicateFilterThresholdParam,
      Pushservice.BqmlHealthModelPredicateBucketThresholdParam,
      Pushservice.PNegMultimodalPredicateModelThresholdParam,
      Pushservice.PNegMultimodalPredicateBucketThresholdParam,
      Pushservice.SeeLessOftenF1TriggerF1PushCapWeight,
      Pushservice.SeeLessOftenF1TriggerNonF1PushCapWeight,
      Pushservice.SeeLessOftenNonF1TriggerF1PushCapWeight,
      Pushservice.SeeLessOftenNonF1TriggerNonF1PushCapWeight,
      Pushservice.SeeLessOftenTripHqTweetTriggerF1PushCapWeight,
      Pushservice.SeeLessOftenTripHqTweetTriggerNonF1PushCapWeight,
      Pushservice.SeeLessOftenTripHqTweetTriggerTripHqTweetPushCapWeight,
      Pushservice.SeeLessOftenNtabOnlyNotifUserPushCapWeight,
      Pushservice.PromptFeedbackF1TriggerF1PushCapWeight,
      Pushservice.PromptFeedbackF1TriggerNonF1PushCapWeight,
      Pushservice.PromptFeedbackNonF1TriggerF1PushCapWeight,
      Pushservice.PromptFeedbackNonF1TriggerNonF1PushCapWeight,
      Pushservice.InlineFeedbackF1TriggerF1PushCapWeight,
      Pushservice.InlineFeedbackF1TriggerNonF1PushCapWeight,
      Pushservice.InlineFeedbackNonF1TriggerF1PushCapWeight,
      Pushservice.InlineFeedbackNonF1TriggerNonF1PushCapWeight,
      Pushservice.TweetNtabDislikeCountThresholdParam,
      Pushservice.TweetNtabDislikeRateThresholdParam,
      Pushservice.TweetNtabDislikeCountThresholdForMrTwistlyParam,
      Pushservice.TweetNtabDislikeRateThresholdForMrTwistlyParam,
      Pushservice.TweetNtabDislikeCountBucketThresholdParam,
      Pushservice.MinAuthorSendsThresholdParam,
      Pushservice.MinTweetSendsThresholdParam,
      Pushservice.AuthorDislikeRateThresholdParam,
      Pushservice.AuthorReportRateThresholdParam,
      Pushservice.FavOverSendThresholdParam,
      Pushservice.SpreadControlRatioParam,
      Pushservice.TweetQTtoNtabClickRatioThresholdParam,
      Pushservice.TweetReplytoLikeRatioThresholdLowerBound,
      Pushservice.TweetReplytoLikeRatioThresholdUpperBound,
      Pushservice.AuthorSensitiveMediaFilteringThreshold,
      Pushservice.AuthorSensitiveMediaFilteringThresholdForMrTwistly,
      Pushservice.MrRequestScribingEpsGreedyExplorationRatio,
      Pushservice.SeeLessOftenTopicTriggerTopicPushCapWeight,
      Pushservice.SeeLessOftenTopicTriggerF1PushCapWeight,
      Pushservice.SeeLessOftenTopicTriggerOONPushCapWeight,
      Pushservice.SeeLessOftenF1TriggerTopicPushCapWeight,
      Pushservice.SeeLessOftenOONTriggerTopicPushCapWeight,
      Pushservice.SeeLessOftenDefaultPushCapWeight,
      Pushservice.OverrideMaxSlotFnWeight,
      Pushservice.QualityPredicateExplicitThresholdParam,
      Pushservice.AuthorSensitiveScoreWeightInReranking,
      Pushservice.BigFilteringThresholdParam,
      Pushservice.NsfwScoreThresholdForF1Copy,
      Pushservice.NsfwScoreThresholdForOONCopy,
      Pushservice.HighOONCThresholdForCopy,
      Pushservice.LowOONCThresholdForCopy,
      Pushservice.UserDeviceLanguageThresholdParam,
      Pushservice.UserInferredLanguageThresholdParam,
      Pushservice.SpammyTweetOonThreshold,
      Pushservice.SpammyTweetInThreshold,
      Pushservice.SpammyTweetBucketingThreshold,
      Pushservice.NumFollowerThresholdForHealthAndQualityFilters,
      Pushservice.NumFollowerThresholdForHealthAndQualityFiltersPreranking,
      Pushservice.SoftRankFactorForSubscriptionCreators,
      Pushservice.MagicFanoutSimClusterDotProductHeavyUserThreshold,
      Pushservice.MagicFanoutSimClusterDotProductNonHeavyUserThreshold
    )

  private val doubleSeqFeatureSwitchOverrides =
    FeatureSwitchOverrideUtil.getDoubleSeqFSOverrides(
      Pushservice.MfGridSearchThresholdsCohort1,
      Pushservice.MfGridSearchThresholdsCohort2,
      Pushservice.MfGridSearchThresholdsCohort3,
      Pushservice.MfGridSearchThresholdsCohort4,
      Pushservice.MfGridSearchThresholdsCohort5,
      Pushservice.MfGridSearchThresholdsCohort6,
      Pushservice.MrPercentileGridSearchThresholdsCohort1,
      Pushservice.MrPercentileGridSearchThresholdsCohort2,
      Pushservice.MrPercentileGridSearchThresholdsCohort3,
      Pushservice.MrPercentileGridSearchThresholdsCohort4,
      Pushservice.MrPercentileGridSearchThresholdsCohort5,
      Pushservice.MrPercentileGridSearchThresholdsCohort6,
      Pushservice.GlobalOptoutThresholdParam,
      Pushservice.BucketOptoutSlotThresholdParam,
      Pushservice.BqmlQualityModelBucketThresholdListParam,
      Pushservice.SeeLessOftenListOfDayKnobs,
      Pushservice.SeeLessOftenListOfPushCapWeightKnobs,
      Pushservice.SeeLessOftenListOfPowerKnobs,
      Pushservice.PromptFeedbackListOfDayKnobs,
      Pushservice.PromptFeedbackListOfPushCapWeightKnobs,
      Pushservice.PromptFeedbackListOfPowerKnobs,
      Pushservice.InlineFeedbackListOfDayKnobs,
      Pushservice.InlineFeedbackListOfPushCapWeightKnobs,
      Pushservice.InlineFeedbackListOfPowerKnobs,
      Pushservice.OverrideMaxSlotFnPushCapKnobs,
      Pushservice.OverrideMaxSlotFnPowerKnobs,
      Pushservice.OverrideMaxSlotFnPushCapKnobs,
      Pushservice.MagicRecsRelevanceScoreRange,
      Pushservice.MagicFanoutRelevanceScoreRange,
      Pushservice.MultilingualPnsfwTweetTextBucketingThreshold,
      Pushservice.MultilingualPnsfwTweetTextFilteringThreshold,
    )

  private val booleanFeatureSwitchOverrides = FeatureSwitchOverrideUtil.getBooleanFSOverrides(
    Pushservice.EnablePushRecommendationsParam,
    Pushservice.DisableHeavyRankingModelFSParam,
    Pushservice.EnablePushMixerReplacingAllSources,
    Pushservice.EnablePushMixerReplacingAllSourcesWithControl,
    Pushservice.EnablePushMixerReplacingAllSourcesWithExtra,
    Pushservice.EnablePushMixerSource,
    Common.EnableScheduledSpaceSpeakers,
    Common.EnableScheduledSpaceSubscribers,
    Pushservice.MagicFanoutNewsUserGeneratedEventsEnable,
    Pushservice.MagicFanoutSkipAccountCountryPredicate,
    Pushservice.MagicFanoutNewsEnableDescriptionCopy,
    Pushservice.EnableF1TriggerSeeLessOftenFatigue,
    Pushservice.EnableNonF1TriggerSeeLessOftenFatigue,
    Pushservice.AdjustTripHqTweetTriggeredNtabCaretClickFatigue,
    Pushservice.EnableCuratedTrendTweets,
    Pushservice.EnableNonCuratedTrendTweets,
    Pushservice.DisableMlInFilteringFeatureSwitchParam,
    Pushservice.EnableTopicCopyForMF,
    Pushservice.EnableTopicCopyForImplicitTopics,
    Pushservice.EnableRestrictStep,
    Pushservice.EnableHighPriorityPush,
    Pushservice.BoostCandidatesFromSubscriptionCreators,
    Pushservice.SoftRankCandidatesFromSubscriptionCreators,
    Pushservice.EnableNewMROONCopyForPush,
    Pushservice.EnableQueryAuthorMediaRepresentationStore,
    Pushservice.EnableProfanityFilterParam,
    Pushservice.EnableAbuseStrikeTop2PercentFilterSimCluster,
    Pushservice.EnableAbuseStrikeTop1PercentFilterSimCluster,
    Pushservice.EnableAbuseStrikeTop05PercentFilterSimCluster,
    Pushservice.EnableAgathaUserHealthModelPredicate,
    Pushservice.PnsfwTweetMediaFilterOonOnly,
    Pushservice.EnableHealthSignalStorePnsfwTweetTextPredicate,
    Pushservice.EnableHealthSignalStoreMultilingualPnsfwTweetTextPredicate,
    Pushservice.DisableHealthFiltersForCrMixerCandidates,
    Pushservice.EnableOverrideNotificationsForAndroid,
    Pushservice.EnableOverrideNotificationsForIos,
    Pushservice.EnableMrRequestScribingForTargetFiltering,
    Pushservice.EnableMrRequestScribingForCandidateFiltering,
    Pushservice.EnableMrRequestScribingWithFeatureHydrating,
    Pushservice.EnableFlattenMrRequestScribing,
    Pushservice.EnableMrRequestScribingForEpsGreedyExploration,
    Pushservice.EnableMrRequestScribingDismissScore,
    Pushservice.EnableMrRequestScribingBigFilteringSupervisedScores,
    Pushservice.EnableMrRequestScribingBigFilteringRLScores,
    Pushservice.EnableEventPrimaryMediaAndroid,
    Pushservice.EnableEventSquareMediaIosMagicFanoutNewsEvent,
    Pushservice.EnableEventSquareMediaAndroid,
    Pushservice.EnableMagicFanoutNewsForYouNtabCopy,
    Pushservice.EnableMfGeoTargeting,
    Pushservice.EnableRuxLandingPage,
    Pushservice.EnableNTabRuxLandingPage,
    Pushservice.EnableGraduallyRampUpNotification,
    Pushservice.EnableOnboardingPushes,
    Pushservice.EnableAddressBookPush,
    Pushservice.EnableCompleteOnboardingPush,
    Pushservice.EnableOverrideNotificationsSmartPushConfigForAndroid,
    Pushservice.DisableOnboardingPushFatigue,
    Pushservice.EnableTopTweetsByGeoCandidates,
    Pushservice.BackfillRankTopTweetsByGeoCandidates,
    Pushservice.PopGeoTweetEnableAggressiveThresholds,
    Pushservice.EnableMrMinDurationSinceMrPushFatigue,
    Pushservice.EnableF1FromProtectedTweetAuthors,
    Pushservice.MagicFanoutEnableCustomTargetingNewsEvent,
    Pushservice.EnableSafeUserTweetTweetypieStore,
    Pushservice.EnableMrMinDurationSinceMrPushFatigue,
    Pushservice.EnableHydratingOnlineMRHistoryFeatures,
    Common.SpaceRecsEnableHostNotifs,
    Common.SpaceRecsEnableSpeakerNotifs,
    Common.SpaceRecsEnableListenerNotifs,
    Common.EnableMagicFanoutProductLaunch,
    Pushservice.EnableTopTweetsByGeoCandidatesForDormantUsers,
    Pushservice.EnableOverrideNotificationsScoreBasedOverride,
    Pushservice.EnableOverrideNotificationsMultipleTargetIds,
    Pushservice.EnableMinDurationModifier,
    Pushservice.EnableMinDurationModifierV2,
    Pushservice.EnableMinDurationModifierByUserHistory,
    Pushservice.EnableQueryUserOpenedHistory,
    Pushservice.EnableRandomHourForQuickSend,
    Pushservice.EnableFrsCandidates,
    Pushservice.EnableFrsTweetCandidatesTopicSetting,
    Pushservice.EnableFrsTweetCandidatesTopicAnnotation,
    Pushservice.EnableFrsTweetCandidatesTopicCopy,
    Pushservice.EnableCandidateGenerationModelParam,
    Pushservice.EnableOverrideForSportsCandidates,
    Pushservice.EnableEventIdBasedOverrideForSportsCandidates,
    Pushservice.EnableMrModelingBasedCandidates,
    Pushservice.EnableMrModelingBasedCandidatesTopicSetting,
    Pushservice.EnableMrModelingBasedCandidatesTopicAnnotation,
    Pushservice.EnableMrModelingBasedCandidatesTopicCopy,
    Pushservice.EnableResultFromFrsCandidates,
    Pushservice.EnableHashspaceCandidates,
    Pushservice.EnableHashspaceCandidatesTopicSetting,
    Pushservice.EnableHashspaceCandidatesTopicAnnotation,
    Pushservice.EnableHashspaceCandidatesTopicCopy,
    Pushservice.EnableResultFromHashspaceCandidates,
    Pushservice.EnableDownRankOfNewUserPlaybookTopicFollowPush,
    Pushservice.EnableDownRankOfNewUserPlaybookTopicTweetPush,
    Pushservice.EnableTopTweetImpressionsNotification,
    Pushservice.EnableLightRankingParam,
    Pushservice.EnableRandomBaselineLightRankingParam,
    Pushservice.EnableQualityUprankingForHeavyRankingParam,
    Pushservice.EnableQualityUprankingCrtScoreStatsForHeavyRankingParam,
    Pushservice.EnableProducersQualityBoostingForHeavyRankingParam,
    Pushservice.EnableMrScribingMLFeaturesAsFeatureMapForStaging,
    Pushservice.EnableMrTweetSentimentFeatureHydrationFS,
    Pushservice.EnableTimelineHealthSignalHydration,
    Pushservice.EnableTopicEngagementRealTimeAggregatesFS,
    Pushservice.EnableMrUserSemanticCoreFeatureForExpt,
    Pushservice.EnableHydratingRealGraphTargetUserFeatures,
    Pushservice.EnableHydratingUserDurationSinceLastVisitFeatures,
    Pushservice.EnableRealGraphUserAuthorAndSocialContxtFeatureHydration,
    Pushservice.EnableUserTopicAggregatesFS,
    Pushservice.EnableTimelineHealthSignalHydrationForModelTraining,
    Pushservice.EnableMrUserSocialContextAggregateFeatureHydration,
    Pushservice.EnableMrUserSemanticCoreAggregateFeatureHydration,
    Pushservice.EnableMrUserCandidateSparseOfflineAggregateFeatureHydration,
    Pushservice.EnableMrUserCandidateOfflineAggregateFeatureHydration,
    Pushservice.EnableMrUserCandidateOfflineCompactAggregateFeatureHydration,
    Pushservice.EnableMrUserAuthorOfflineAggregateFeatureHydration,
    Pushservice.EnableMrUserAuthorOfflineCompactAggregateFeatureHydration,
    Pushservice.EnableMrUserOfflineCompactAggregateFeatureHydration,
    Pushservice.EnableMrUserSimcluster2020AggregateFeatureHydration,
    Pushservice.EnableMrUserOfflineAggregateFeatureHydration,
    Pushservice.EnableBqmlQualityModelPredicateParam,
    Pushservice.EnableBqmlQualityModelScoreHistogramParam,
    Pushservice.EnableBqmlHealthModelPredicateParam,
    Pushservice.EnableBqmlHealthModelPredictionForInNetworkCandidatesParam,
    Pushservice.EnableBqmlHealthModelScoreHistogramParam,
    Pushservice.EnablePNegMultimodalPredicateParam,
    Pushservice.EnableNegativeKeywordsPredicateParam,
    Pushservice.EnableTweetAuthorAggregatesFeatureHydrationParam,
    Pushservice.OonTweetLengthPredicateUpdatedMediaLogic,
    Pushservice.OonTweetLengthPredicateUpdatedQuoteTweetLogic,
    Pushservice.OonTweetLengthPredicateMoreStrictForUndefinedLanguages,
    Pushservice.EnablePrerankingTweetLengthPredicate,
    Pushservice.EnableDeTopicTweetCandidates,
    Pushservice.EnableDeTopicTweetCandidateResults,
    Pushservice.EnableDeTopicTweetCandidatesCustomTopics,
    Pushservice.EnableDeTopicTweetCandidatesCustomLanguages,
    Pushservice.EnableMrTweetSimClusterFeatureHydrationFS,
    Pushservice.DisableOutNetworkTweetCandidatesFS,
    Pushservice.EnableLaunchVideosInImmersiveExplore,
    Pushservice.EnableStoringNtabGenericNotifKey,
    Pushservice.EnableDeletingNtabTimeline,
    Pushservice.EnableOverrideNotificationsNSlots,
    Pushservice.EnableNslotsForOverrideOnNtab,
    Pushservice.EnableOverrideMaxSlotFn,
    Pushservice.EnableTargetIdInSmartPushPayloadForMagicFanoutSportsEvent,
    Pushservice.EnableOverrideIdNTabRequest,
    Pushservice.EnableOverrideForSpaces,
    Pushservice.EnableTopicProofTweetRecs,
    Pushservice.EnableHealthFiltersForTopicProofTweet,
    Pushservice.EnableTargetIdsInSmartPushPayload,
    Pushservice.EnableSecondaryAccountPredicateMF,
    Pushservice.EnableInlineVideo,
    Pushservice.EnableAutoplayForInlineVideo,
    Pushservice.EnableOONGeneratedInlineActions,
    Pushservice.EnableInlineFeedbackOnPush,
    Pushservice.UseInlineActionsV1,
    Pushservice.UseInlineActionsV2,
    Pushservice.EnableFeaturedSpacesOON,
    Pushservice.CheckFeaturedSpaceOON,
    Pushservice.EnableGeoTargetingForSpaces,
    Pushservice.EnableEmployeeOnlySpaceNotifications,
    Pushservice.EnableSpacesTtlForNtab,
    Pushservice.EnableCustomThreadIdForOverride,
    Pushservice.EnableSimClusterTargetingSpaces,
    Pushservice.TargetInInlineActionAppVisitFatigue,
    Pushservice.EnableInlineActionAppVisitFatigue,
    Pushservice.EnableThresholdOfFavMrModelingBasedCandidates,
    Pushservice.HydrateMrUserSimclusterV2020InModelingBasedCG,
    Pushservice.HydrateMrUserSemanticCoreInModelingBasedCG,
    Pushservice.HydrateOnboardingInModelingBasedCG,
    Pushservice.HydrateTopicFollowInModelingBasedCG,
    Pushservice.HydrateMrUserTopicInModelingBasedCG,
    Pushservice.HydrateMrUserAuthorInModelingBasedCG,
    Pushservice.HydrateUserPenguinLanguageInModelingBasedCG,
    Pushservice.EnableMrUserEngagedTweetTokensFeature,
    Pushservice.HydrateMrUserHashspaceEmbeddingInModelingBasedCG,
    Pushservice.HydrateUseGeoInModelingBasedCG,
    Pushservice.EnableSpaceCohostJoinEvent,
    Pushservice.EnableOONFilteringBasedOnUserSettings,
    Pushservice.EnableContFnF1TriggerSeeLessOftenFatigue,
    Pushservice.EnableContFnNonF1TriggerSeeLessOftenFatigue,
    Pushservice.EnableContFnF1TriggerPromptFeedbackFatigue,
    Pushservice.EnableContFnNonF1TriggerPromptFeedbackFatigue,
    Pushservice.EnableContFnF1TriggerInlineFeedbackFatigue,
    Pushservice.EnableContFnNonF1TriggerInlineFeedbackFatigue,
    Pushservice.UseInlineDislikeForFatigue,
    Pushservice.UseInlineDismissForFatigue,
    Pushservice.UseInlineSeeLessForFatigue,
    Pushservice.UseInlineNotRelevantForFatigue,
    Pushservice.GPEnableCustomMagicFanoutCricketFatigue,
    Pushservice.IncludeRelevanceScoreInIbis2Payload,
    Pushservice.BypassGlobalSpacePushCapForSoftDeviceFollow,
    Pushservice.EnableCountryCodeBackoffTopTweetsByGeo,
    Pushservice.EnableNewCreatorPush,
    Pushservice.EnableCreatorSubscriptionPush,
    Pushservice.EnableInsSender,
    Pushservice.EnableOptoutAdjustedPushcap,
    Pushservice.EnableOONBackfillBasedOnF1Candidates,
    Pushservice.EnableVFInTweetypie,
    Pushservice.EnablePushPresentationVerifiedSymbol,
    Pushservice.EnableHighPrioritySportsPush,
    Pushservice.EnableSearchURLRedirectForSportsFanout,
    Pushservice.EnableScoreFanoutNotification,
    Pushservice.EnableExplicitPushCap,
    Pushservice.EnableNsfwTokenBasedFiltering,
    Pushservice.EnableRestrictedMinModelPushcap,
    Pushservice.EnableGenericCRTBasedFatiguePredicate,
    Pushservice.EnableCopyFeaturesForF1,
    Pushservice.EnableEmojiInF1Copy,
    Pushservice.EnableTargetInF1Copy,
    Pushservice.EnableCopyFeaturesForOon,
    Pushservice.EnableEmojiInOonCopy,
    Pushservice.EnableTargetInOonCopy,
    Pushservice.EnableF1CopyBody,
    Pushservice.EnableOONCopyBody,
    Pushservice.EnableIosCopyBodyTruncate,
    Pushservice.EnableHTLBasedFatigueBasicRule,
    Pushservice.EnableTargetAndEmojiSplitFatigue,
    Pushservice.EnableNsfwCopy,
    Pushservice.EnableOONCopyBody,
    Pushservice.EnableTweetDynamicInlineActions,
    Pushservice.EnablePushcapRefactor,
    Pushservice.BigFilteringEnableHistogramsParam,
    Pushservice.EnableTweetTranslation,
    Pushservice.TripTweetCandidateReturnEnable,
    Pushservice.EnableSocialContextForRetweet,
    Pushservice.EnableEmptyBody,
    Pushservice.EnableLocalViralTweets,
    Pushservice.EnableExploreVideoTweets,
    Pushservice.EnableDynamicInlineActionsForDesktopWeb,
    Pushservice.EnableDynamicInlineActionsForMobileWeb,
    Pushservice.EnableNTabEntriesForSportsEventNotifications,
    Pushservice.EnableNTabFacePileForSportsEventNotifications,
    Pushservice.DisableIsTargetBlueVerifiedPredicate,
    Pushservice.EnableNTabEntriesForProductLaunchNotifications,
    Pushservice.DisableIsTargetLegacyVerifiedPredicate,
    Pushservice.EnableNTabOverrideForSportsEventNotifications,
    Pushservice.EnableOONCBasedCopy,
    Pushservice.HighQualityCandidatesEnableCandidateSource,
    Pushservice.HighQualityCandidatesEnableFallback,
    Pushservice.EnableTweetLanguageFilter,
    Pushservice.EnableListRecommendations,
    Pushservice.EnableIDSListRecommendations,
    Pushservice.EnablePopGeoListRecommendations,
    Pushservice.SkipLanguageFilterForMediaTweets,
    Pushservice.EnableSpammyTweetFilter,
    Pushservice.EnableTweetPushToHomeAndroid,
    Pushservice.EnableTweetPushToHomeiOS,
    Pushservice.EnableBoundedFeatureSetForSocialContext,
    Pushservice.EnableStpBoundedFeatureSetForUserSocialContext,
    Pushservice.EnableCoreUserHistoryBoundedFeatureSetForSocialContext,
    Pushservice.SkipPostRankingFilters,
    Pushservice.MRWebHoldbackParam,
    Pushservice.EnableIsTargetSuperFollowCreatorPredicate
  )

  private val longSeqFeatureSwitchOverrides =
    FeatureSwitchOverrideUtil.getLongSeqFSOverrides(
      Pushservice.MagicFanoutEventAllowlistToSkipAccountCountryPredicate
    )

  private val longSetFeatureSwitchOverrides =
    FeatureSwitchOverrideUtil.getLongSetFSOverrides(
      Pushservice.ListOfAdhocIdsForStatsTracking
    )

  private val stringSeqFeatureSwitchOverrides =
    FeatureSwitchOverrideUtil.getStringSeqFSOverrides(
      Pushservice.ListOfCrtsForOpenApp,
      Pushservice.ListOfCrtsToUpRank,
      Pushservice.OONCandidatesDisabledCrTagParam,
      Pushservice.ListOfCrtsToDownRank,
      Pushservice.MagicFanoutDenyListedCountries,
      Pushservice.GlobalOptoutModelParam,
      Pushservice.BqmlQualityModelBucketModelIdListParam,
      Pushservice.CommonRecommendationTypeDenyListPushHoldbacks,
      Pushservice.TargetLevelFeatureListForMrRequestScribing,
      Pushservice.MagicFanoutSportsEventDenyListedCountries,
      Pushservice.MultilingualPnsfwTweetTextSupportedLanguages,
      Pushservice.NegativeKeywordsPredicateDenylist,
      Pushservice.TripTweetCandidateSourceIds,
      Pushservice.NsfwTokensParam,
      Pushservice.HighQualityCandidatesFallbackSourceIds
    )

  private val intSeqFeatureSwitchOverrides =
    FeatureSwitchOverrideUtil.getIntSeqFSOverrides(
      Pushservice.BucketOptoutSlotPushcapParam,
      Pushservice.GeoHashLengthList,
      Pushservice.MinDurationModifierStartHourList,
      Pushservice.MinDurationModifierEndHourList,
      Pushservice.MinDurationTimeModifierConst
    )

  private val enumFeatureSwitchOverrides = FeatureSwitchOverrideUtil.getEnumFSOverrides(
    stat,
    logger,
    Pushservice.MRBoldTitleFavoriteAndRetweetParam,
    Pushservice.QualityUprankingTransformTypeParam,
    Pushservice.QualityPredicateIdParam,
    Pushservice.BigFilteringNormalizationTypeIdParam,
    Common.PushcapModelType,
    Common.MFCricketTargetingPredicate,
    Pushservice.RankingFunctionForTopTweetsByGeo,
    Pushservice.TopTweetsByGeoCombinationParam,
    Pushservice.PopGeoTweetVersionParam,
    Pushservice.SubtextInAndroidPushHeaderParam,
    Pushservice.HighOONCTweetFormat,
    Pushservice.LowOONCTweetFormat,
  )

  private val enumSeqFeatureSwitchOverrides = FeatureSwitchOverrideUtil.getEnumSeqFSOverrides(
    stat,
    logger,
    Pushservice.OONTweetDynamicInlineActionsList,
    Pushservice.TweetDynamicInlineActionsList,
    Pushservice.TweetDynamicInlineActionsListForWeb,
    Pushservice.HighQualityCandidatesEnableGroups,
    Pushservice.HighQualityCandidatesFallbackEnabledGroups,
    Pushservice.OONCandidatesDisabledCrtGroupParam,
    Pushservice.MultilingualPnsfwTweetTextBucketingModelList,
  )

  private val stringFeatureSwitchOverrides = FeatureSwitchOverrideUtil.getStringFSOverrides(
    Common.PushcapModelPredictionVersion,
    Pushservice.WeightedOpenOrNtabClickRankingModelParam,
    Pushservice.WeightedOpenOrNtabClickFilteringModelParam,
    Pushservice.BucketOptoutModelParam,
    Pushservice.ScoringFuncForTopTweetsByGeo,
    Pushservice.LightRankingModelTypeParam,
    Pushservice.BigFilteringSupervisedSendingModelParam,
    Pushservice.BigFilteringSupervisedWithoutSendingModelParam,
    Pushservice.BigFilteringRLSendingModelParam,
    Pushservice.BigFilteringRLWithoutSendingModelParam,
    Pushservice.BqmlQualityModelTypeParam,
    Pushservice.BqmlHealthModelTypeParam,
    Pushservice.QualityUprankingModelTypeParam,
    Pushservice.SearchURLRedirectForSportsFanout,
    Pushservice.LocalViralTweetsBucket,
    Pushservice.HighQualityCandidatesHeavyRankingModel,
    Pushservice.HighQualityCandidatesNonPersonalizedQualityCnnModel,
    Pushservice.HighQualityCandidatesBqmlNsfwModel,
    Pushservice.HighQualityCandidatesBqmlReportModel,
    Pushservice.ProductLaunchLandingPageDeepLink,
    Pushservice.ProductLaunchTapThrough,
    Pushservice.TweetLanguageFeatureNameParam
  )

  private val durationFeatureSwitchOverrides =
    FeatureSwitchOverrideUtil.getBoundedDurationFSOverrides(
      Common.NumberOfDaysToFilterMRForSeeLessOften,
      Common.NumberOfDaysToReducePushCapForSeeLessOften,
      Pushservice.NumberOfDaysToFilterForSeeLessOftenForF1TriggerF1,
      Pushservice.NumberOfDaysToReducePushCapForSeeLessOftenForF1TriggerF1,
      Pushservice.NumberOfDaysToFilterForSeeLessOftenForF1TriggerNonF1,
      Pushservice.NumberOfDaysToReducePushCapForSeeLessOftenForF1TriggerNonF1,
      Pushservice.NumberOfDaysToFilterForSeeLessOftenForNonF1TriggerF1,
      Pushservice.NumberOfDaysToReducePushCapForSeeLessOftenForNonF1TriggerF1,
      Pushservice.NumberOfDaysToFilterForSeeLessOftenForNonF1TriggerNonF1,
      Pushservice.NumberOfDaysToReducePushCapForSeeLessOftenForNonF1TriggerNonF1,
      Pushservice.TrendTweetNotificationsFatigueDuration,
      Pushservice.MinDurationSincePushParam,
      Pushservice.MFMinIntervalFatigue,
      Pushservice.SimclusterBasedCandidateMaxTweetAgeParam,
      Pushservice.DetopicBasedCandidateMaxTweetAgeParam,
      Pushservice.F1CandidateMaxTweetAgeParam,
      Pushservice.MaxTweetAgeParam,
      Pushservice.ModelingBasedCandidateMaxTweetAgeParam,
      Pushservice.GeoPopTweetMaxAgeInHours,
      Pushservice.MinDurationSincePushParam,
      Pushservice.GraduallyRampUpPhaseDurationDays,
      Pushservice.MrMinDurationSincePushForOnboardingPushes,
      Pushservice.FatigueForOnboardingPushes,
      Pushservice.FrigateHistoryOtherNotificationWriteTtl,
      Pushservice.FrigateHistoryTweetNotificationWriteTtl,
      Pushservice.TopTweetsByGeoPushInterval,
      Pushservice.HighQualityTweetsPushInterval,
      Pushservice.MrMinDurationSincePushForTopTweetsByGeoPushes,
      Pushservice.TimeSinceLastLoginForGeoPopTweetPush,
      Pushservice.NewUserPlaybookAllowedLastLoginHours,
      Pushservice.SpaceRecsAppFatigueDuration,
      Pushservice.OONSpaceRecsFatigueDuration,
      Pushservice.SpaceRecsFatigueMinIntervalDuration,
      Pushservice.SpaceRecsGlobalFatigueDuration,
      Pushservice.MinimumTimeSinceLastLoginForGeoPopTweetPush,
      Pushservice.MinFatigueDurationSinceLastHTLVisit,
      Pushservice.LastHTLVisitBasedNonFatigueWindow,
      Pushservice.SpaceNotificationsTTLDurationForNTab,
      Pushservice.OverrideNotificationsLookbackDurationForOverrideInfo,
      Pushservice.OverrideNotificationsLookbackDurationForImpressionId,
      Pushservice.OverrideNotificationsLookbackDurationForNTab,
      Pushservice.TopTweetImpressionsNotificationInterval,
      Pushservice.TopTweetImpressionsFatigueMinIntervalDuration,
      Pushservice.MFPushIntervalInHours,
      Pushservice.InlineActionAppVisitFatigue,
      Pushservice.SpaceParticipantHistoryLastActiveThreshold,
      Pushservice.SportsMinIntervalFatigue,
      Pushservice.SportsPushIntervalInHours,
      Pushservice.SportsMinIntervalFatiguePerEvent,
      Pushservice.SportsPushIntervalInHoursPerEvent,
      Pushservice.TargetNtabOnlyCapFatigueIntervalHours,
      Pushservice.TargetPushCapFatigueIntervalHours,
      Pushservice.CopyFeaturesHistoryLookbackDuration,
      Pushservice.F1EmojiCopyFatigueDuration,
      Pushservice.F1TargetCopyFatigueDuration,
      Pushservice.OonEmojiCopyFatigueDuration,
      Pushservice.OonTargetCopyFatigueDuration,
      Pushservice.ProductLaunchPushIntervalInHours,
      Pushservice.ExploreVideoTweetAgeParam,
      Pushservice.ListRecommendationsPushInterval,
      Pushservice.ProductLaunchMinIntervalFatigue,
      Pushservice.NewCreatorPushIntervalInHours,
      Pushservice.NewCreatorPushMinIntervalFatigue,
      Pushservice.CreatorSubscriptionPushIntervalInHours,
      Pushservice.CreatorSubscriptionPushhMinIntervalFatigue
    )

  private[params] val allFeatureSwitchOverrides =
    booleanDeciderOverrides ++
      booleanFeatureSwitchOverrides ++
      intFeatureSwitchOverrides ++
      doubleFeatureSwitchOverrides ++
      doubleSeqFeatureSwitchOverrides ++
      enumFeatureSwitchOverrides ++
      stringSeqFeatureSwitchOverrides ++
      stringFeatureSwitchOverrides ++
      durationFeatureSwitchOverrides ++
      intSeqFeatureSwitchOverrides ++
      longSeqFeatureSwitchOverrides ++
      enumSeqFeatureSwitchOverrides ++
      longSetFeatureSwitchOverrides

  val config = BaseConfigBuilder(allFeatureSwitchOverrides).build()
}
