package com.ss.android.ugc.aweme.web.jsbridge;

import X.0CB;
import X.0CH;
import X.6Is;
import X.C0865KKi;
import X.C1009KPw;
import X.C2071Kms;
import X.FIu;
import X.KGO;
import X.KPB;
import X.M12;
import android.content.Context;
import android.os.Bundle;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.fe.base.BaseCommonJavaMethod;
import kotlin.h.b.n;
import org.json.JSONObject;

public final class OpenAuthPageMethod extends BaseCommonJavaMethod implements 6Is, KPB {
    public static final KGO Companion = new KGO((byte) 0);
    public final C0865KKi jsBridge;
    public FIu mIReturn;

    static {
        Covode.recordClassIndex(124449);
    }

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

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public OpenAuthPageMethod(C0865KKi kKi) {
        super(kKi);
        M12.LIZ((Object) kKi);
        this.jsBridge = kKi;
    }

    public final void onClick(String str) {
        JSONObject jSONObject = new JSONObject();
        JSONObject jSONObject2 = new JSONObject();
        jSONObject2.put("ticket", str);
        jSONObject.put("code", 1);
        jSONObject.put("response", jSONObject2);
        FIu fIu = this.mIReturn;
        if (fIu != null) {
            fIu.LIZ(jSONObject);
        }
    }

    public final void onError(String str, String str2) {
        JSONObject jSONObject = new JSONObject();
        jSONObject.put("code", 0);
        jSONObject.put("errorCode", str);
        jSONObject.put("errorMsg", str2);
        FIu fIu = this.mIReturn;
        if (fIu != null) {
            fIu.LIZ(jSONObject);
        }
    }

    public final void handle(JSONObject jSONObject, FIu fIu) {
        String str;
        String str2;
        String str3;
        this.mIReturn = fIu;
        C2071Kms kms = (C2071Kms) LIZIZ().LIZ(C2071Kms.class);
        if (kms != null) {
            JSONObject jSONObject2 = new JSONObject();
            jSONObject2.put("type", "jsb");
            jSONObject2.put("bridge_name", "jumpOpenAuthPage");
            jSONObject2.put("bridge_access", "true");
            jSONObject2.put("stage", "open_jsb_auth");
            kms.LIZ("open_jsb_monitor", "open_jsb_invoke", jSONObject2, (JSONObject) null, (JSONObject) null);
        }
        String str4 = null;
        if (jSONObject != null) {
            str = jSONObject.getString("client_key");
            jSONObject.getString("response_type");
            str2 = jSONObject.getString("scope");
            str3 = jSONObject.getString("state");
            str4 = jSONObject.getString("redirect_uri");
        } else {
            str = null;
            str2 = null;
            str3 = null;
        }
        C1009KPw kPw = new C1009KPw();
        kPw.LJII = str2;
        kPw.LIZ = str3;
        kPw.LJFF = "wap_to_native";
        kPw.LIZIZ = str4;
        Bundle bundle = new Bundle();
        kPw.toBundle(bundle);
        bundle.putString("_bytedance_params_client_key", str);
        bundle.putString("__bytedance_base_caller_version", "1");
        Context actContext = getActContext();
        n.LIZIZ(actContext, "");
        bundle.putString("_bytedance_params_type_caller_package", actContext.getPackageName());
        bundle.putString("_aweme_params_enter_from_flag", "ENTER_FROM_INNER_WEB");
    }
}
