package com.ss.android.ugc.aweme.discover.api;

import X.0Gp;
import X.2XC;
import X.6tJ;
import X.8qj;
import X.AVG;
import X.C3302STa;
import X.F5c;
import X.FLu;
import X.IUu;
import X.JLr;
import X.JMA;
import X.JMB;
import X.K3I;
import X.LeH;
import X.M12;
import X.PSr;
import X.PUu;
import X.PUw;
import X.PV0;
import X.PgU;
import X.PhE;
import X.PlI;
import X.SL2;
import X.SSH;
import X.SSI;
import X.SSK;
import X.SU0;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.ugc.aweme.network.RetrofitFactory;
import com.ss.android.ugc.aweme.app.api.Api;
import com.ss.android.ugc.aweme.discover.model.SearchMix;
import com.ss.android.ugc.aweme.discover.model.SearchMusicList;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import kotlin.h.b.n;

public final class SearchApiNew {
    public static final String LIZ;
    public static final 2XC LIZIZ;
    public static final int LIZJ = 1;
    public static final Set<String> LIZLLL = new LinkedHashSet();
    public static final SearchApiNew LJ = new SearchApiNew();

    public interface RealApi {
        public static final SSH LIZ = SSH.LIZIZ;

        static {
            Covode.recordClassIndex(64448);
        }

        @JMA(LIZ = "/aweme/v1/search/videosug/")
        PgU<K3I> fetchFeedDetailWords(@PUw(LIZ = "aweme_id") String str, @PUw(LIZ = "source") String str2);

        @IUu(LIZ = "/aweme/v1/search/horizontal/loadmore/")
        @6tJ
        PgU<String> horizontalLoadmore(@PUu(LIZ = "search_id") String str, @PUu(LIZ = "query") String str2, @PUu(LIZ = "backtrace") String str3, @PUu(LIZ = "log_id") String str4, @PUu(LIZ = "token_type") String str5, @PUu(LIZ = "cursor") long j);

        @IUu(LIZ = "/aweme/v1/search/item/")
        @6tJ
        JLr<SearchMix> searchFeedList(@PUu(LIZ = "keyword") String str, @PUu(LIZ = "offset") long j, @PUu(LIZ = "count") int i, @PUu(LIZ = "source") String str2, @PUu(LIZ = "search_source") String str3, @PUu(LIZ = "hot_search") int i2, @PUu(LIZ = "search_id") String str4, @PUu(LIZ = "last_search_id") String str5, @PUu(LIZ = "query_correct_type") int i3, @PUu(LIZ = "is_filter_search") int i4, @PUu(LIZ = "sort_type") int i5, @PUu(LIZ = "publish_time") int i6, @PUu(LIZ = "enter_from") String str6, @PUu(LIZ = "search_channel") String str7, @PUu(LIZ = "show_results_source") String str8, @PUu(LIZ = "search_context") String str9, @PV0 LinkedHashMap<String, Integer> linkedHashMap);

        @6tJ
        @IUu(LIZ = "/aweme/v1/general/search/single/")
        @FLu(LIZ = 3)
        0Gp<C3302STa> searchMTMixFeedList(@PUu(LIZ = "keyword") String str, @PUu(LIZ = "offset") int i, @PUu(LIZ = "count") int i2, @PUu(LIZ = "enter_from") String str2, @PUu(LIZ = "search_source") String str3, @PUu(LIZ = "hot_search") int i3, @PUu(LIZ = "search_id") String str4, @PUu(LIZ = "last_search_id") String str5, @PUu(LIZ = "query_correct_type") int i4, @PUu(LIZ = "multi_mod") int i5, @PUu(LIZ = "sug_user_id") String str6, @PUu(LIZ = "is_rich_sug") String str7, @PUu(LIZ = "is_filter_search") int i6, @PUu(LIZ = "publish_time") int i7, @PUu(LIZ = "sort_type") int i8, @PUu(LIZ = "backtrace") String str8, @PUu(LIZ = "original_query") String str9, @PUu(LIZ = "words_type") String str10, @PUu(LIZ = "search_context") String str11, @PUu(LIZ = "ad_user_agent") String str12, @PUu(LIZ = "trending_event_id") String str13, @PUu(LIZ = "auto_play_user_video") int i9, @PUu(LIZ = "preset_queries_loaded") int i10, @PUu(LIZ = "in_preset_queries") int i11, @PV0 LinkedHashMap<String, Integer> linkedHashMap, @PUu(LIZ = "from_group_id") String str14, @PUu(LIZ = "research_filter_type") String str15);

        @6tJ
        @IUu(LIZ = "/aweme/v1/general/search/stream/")
        @8qj
        @FLu(LIZ = 3)
        0Gp<PSr<C3302STa>> searchMTMixFeedListByChunk(@PUu(LIZ = "keyword") String str, @PUu(LIZ = "offset") int i, @PUu(LIZ = "count") int i2, @PUu(LIZ = "enter_from") String str2, @PUu(LIZ = "search_source") String str3, @PUu(LIZ = "hot_search") int i3, @PUu(LIZ = "search_id") String str4, @PUu(LIZ = "last_search_id") String str5, @PUu(LIZ = "query_correct_type") int i4, @PUu(LIZ = "multi_mod") int i5, @PUu(LIZ = "sug_user_id") String str6, @PUu(LIZ = "is_rich_sug") String str7, @PUu(LIZ = "is_filter_search") int i6, @PUu(LIZ = "publish_time") int i7, @PUu(LIZ = "sort_type") int i8, @PUu(LIZ = "original_query") String str8, @PUu(LIZ = "ad_user_agent") String str9, @PUu(LIZ = "trending_event_id") String str10, @PUu(LIZ = "search_context") String str11, @PUu(LIZ = "backtrace") String str12, @PUu(LIZ = "words_type") String str13, @PUu(LIZ = "auto_play_user_video") int i9, @PUu(LIZ = "preset_queries_loaded") int i10, @PUu(LIZ = "in_preset_queries") int i11, @PV0 LinkedHashMap<String, Integer> linkedHashMap, @PUu(LIZ = "from_group_id") String str14, @PUu(LIZ = "research_filter_type") String str15);

        @IUu(LIZ = "/aweme/v1/music/search/")
        @6tJ
        PgU<SearchMusicList> searchMusicList(@PUu(LIZ = "cursor") long j, @PUu(LIZ = "keyword") String str, @PUu(LIZ = "count") int i, @PUu(LIZ = "hot_search") int i2, @PUu(LIZ = "search_id") String str2, @PUu(LIZ = "query_correct_type") int i3, @PUu(LIZ = "is_author_search") int i4, @PUu(LIZ = "is_filter_search") int i5, @PUu(LIZ = "filter_by") int i6, @PUu(LIZ = "sort_type") int i7, @PV0 LinkedHashMap<String, Integer> linkedHashMap);
    }

    static {
        Covode.recordClassIndex(64447);
        String str = Api.LIZLLL;
        LIZ = str;
        LIZIZ = RetrofitFactory.LIZ().LIZ(str);
    }

    public final PgU<SearchMusicList> LIZ(SSK ssk) {
        boolean z;
        int i;
        int i2;
        LinkedHashMap linkedHashMap;
        SSK ssk2 = ssk;
        M12.LIZ(ssk2);
        try {
            RealApi realApi = SSH.LIZ;
            long j = ssk2.LJIIIIZZ;
            String str = ssk2.LIZ;
            int i3 = ssk2.LJIIIZ;
            int i4 = ssk2.LJ;
            String str2 = ssk2.LJI;
            int i5 = ssk2.LJFF;
            int i6 = ssk2.LJIILLIIL;
            AVG avg = ssk2.LJIIJJI;
            if (avg != null) {
                z = avg.isDefaultOption();
            } else {
                z = true;
            }
            int i7 = 0;
            if (!z) {
                i = 1;
            } else {
                i = 0;
            }
            AVG avg2 = ssk2.LJIIJJI;
            if (avg2 != null) {
                i2 = avg2.getFilterBy();
            } else {
                i2 = 0;
            }
            AVG avg3 = ssk2.LJIIJJI;
            if (avg3 != null) {
                i7 = avg3.getSortType();
            }
            AVG avg4 = ssk2.LJIIJJI;
            if (avg4 == null || (linkedHashMap = avg4.activityToFieldMap()) == null) {
                linkedHashMap = new LinkedHashMap();
            }
            return realApi.searchMusicList(j, str, i3, i4, str2, i5, i6, i, i2, i7, linkedHashMap);
        } catch (ExecutionException e) {
            RuntimeException compatibleException = JMB.getCompatibleException(e);
            n.LIZIZ(compatibleException, "");
            throw compatibleException;
        }
    }

    public final PgU<C3302STa> LIZ(SSK ssk, int i, int i2, C3302STa sTa) {
        0Gp<C3302STa> r2;
        SSK ssk2 = ssk;
        M12.LIZ(ssk2);
        if (sTa != null) {
            r2 = sTa.LJI;
            sTa.LJI = null;
        } else {
            r2 = null;
        }
        PgU<C3302STa> LIZIZ2 = PgU.LIZ(new SU0(i, r2, ssk2, i2, new LeH())).LIZLLL(new F5c(sTa)).LIZLLL(SSI.LIZ).LIZLLL(SL2.LIZ).LIZIZ(PhE.LIZIZ(PlI.LIZJ));
        n.LIZIZ(LIZIZ2, "");
        return LIZIZ2;
    }
}
