package com.ss.android.ugc.aweme.discover.ui.search.jsbridge.bullet;

import X.0CB;
import X.0CH;
import X.0HH;
import X.4UQ;
import X.6Is;
import X.7hA;
import X.KT7;
import X.M12;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.bullet.bridge.BaseBridgeMethod;
import com.ss.android.ugc.aweme.discover.model.ISearchHistoryManager;
import com.ss.android.ugc.aweme.discover.model.SearchHistory;
import com.ss.android.ugc.aweme.discover.model.SearchHistoryManager;
import java.util.ArrayList;
import java.util.List;
import kotlin.h.b.n;
import org.json.JSONArray;
import org.json.JSONObject;

public final class GetSearchHistoryMethod extends BaseBridgeMethod implements 6Is {
    public final String LIZIZ = "getSearchHistory";

    static {
        Covode.recordClassIndex(65914);
    }

    public final void onStateChanged(0CH r1, 0CB r2) {
        GetSearchHistoryMethod.super.onStateChanged(r1, r2);
    }

    public final String LIZLLL() {
        return this.LIZIZ;
    }

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public GetSearchHistoryMethod(KT7 kt7) {
        super(kt7);
        M12.LIZ(kt7);
    }

    public final void LIZ(JSONObject jSONObject, 4UQ r7) {
        M12.LIZ(jSONObject, r7);
        try {
            ISearchHistoryManager inst = SearchHistoryManager.inst(jSONObject.optString("enterFrom"));
            ArrayList<SearchHistory> arrayList = new ArrayList<>();
            n.LIZIZ(inst, "");
            List<SearchHistory> searchHistory = inst.getSearchHistory();
            n.LIZIZ(searchHistory, "");
            arrayList.addAll(searchHistory);
            JSONArray jSONArray = new JSONArray();
            for (SearchHistory searchHistory2 : arrayList) {
                JSONObject jSONObject2 = new JSONObject();
                jSONObject2.put("word", searchHistory2.keyword);
                jSONArray.put(jSONObject2);
            }
            JSONObject jSONObject3 = new JSONObject();
            jSONObject3.put("history_list", jSONArray);
            r7.LIZ(jSONObject3);
        } catch (Exception e) {
            7hA.LIZ.LIZ(e, "GetSearchHistoryMethod");
            r7.LIZ(0, e.getMessage());
            0HH.LIZ(e);
        }
    }
}
