package com.bytedance.lobby.instagram;

import X.1hK;
import X.99w;
import X.9As;
import X.C5659M8s;
import X.C5667M9a;
import X.M7B;
import X.MA0;
import android.content.Intent;
import android.os.Bundle;
import com.bytedance.covode.number.Covode;
import com.bytedance.lobby.auth.AuthResult;
import com.bytedance.lobby.internal.LobbyCore;
import com.bytedance.lobby.internal.LobbyViewModel;

public class InstagramAuth extends InstagramProvider<AuthResult> implements C5667M9a {
    public static final boolean LIZ = 99w.LIZ;
    public LobbyViewModel LIZIZ;

    public final void LIZ() {
    }

    public final void LIZ(int i) {
    }

    public final String LIZIZ() {
        return null;
    }

    static {
        Covode.recordClassIndex(35487);
    }

    public InstagramAuth(MA0 ma0) {
        super(LobbyCore.getApplication(), ma0);
    }

    public static String LIZ(Intent intent, String str) {
        try {
            return intent.getStringExtra(str);
        } catch (Exception unused) {
            return null;
        }
    }

    public final void LIZIZ(1hK r3, Bundle bundle) {
        9As.LIZ(this.LIZIZ, this.LIZJ.LIZIZ);
    }

    public final void LIZ(1hK r8, Bundle bundle) {
        this.LIZIZ = LobbyViewModel.LIZ(r8);
        if (!J_()) {
            9As.LIZ(this.LIZIZ, "instagram", 1);
            return;
        }
        String str = this.LIZJ.LIZJ;
        String string = this.LIZJ.LIZLLL.getString("ig_login_auth_url");
        String string2 = this.LIZJ.LIZLLL.getString("ig_redirect_url");
        String string3 = this.LIZJ.LIZLLL.getString("ig_scope", "basic");
        String string4 = this.LIZJ.LIZLLL.getString("ig_response_type", "code");
        Intent intent = new Intent(r8, InstagramAuthActivity.class);
        intent.putExtra("client_id", str);
        intent.putExtra("login_auth_url", string);
        intent.putExtra("redirect_url", string2);
        intent.putExtra("response_type", string4);
        intent.putExtra("scope", string3);
        r8.startActivityForResult(intent, 458);
    }

    public final void LIZ(1hK r8, int i, int i2, Intent intent) {
        C5659M8s m8s = new C5659M8s(this.LIZJ.LIZIZ, 1);
        if (intent == null) {
            m8s.LIZ = false;
            m8s.LIZIZ = new M7B(1, "No intent data received after launching InstagramAuthActivity", "redirect_and_get_token");
            this.LIZIZ.LIZIZ(m8s.LIZ());
            return;
        }
        if (i2 == -1) {
            String LIZ2 = LIZ(intent, "ig_result_error_info");
            String LIZ3 = LIZ(intent, "error_stage");
            m8s.LIZ = false;
            m8s.LIZIZ = new M7B(4, LIZ2, LIZ3);
        } else if (i2 == 0) {
            String LIZ4 = LIZ(intent, "ig_result_error_info");
            String LIZ5 = LIZ(intent, "error_stage");
            m8s.LIZ = false;
            m8s.LIZIZ = new M7B(3, LIZ4, LIZ5);
        } else if (i2 != 1) {
            m8s.LIZ = false;
            m8s.LIZIZ = new M7B(7, "Unidentified result code in InstagramAuthActivity", "redirect_and_get_token");
        } else {
            Bundle bundle = new Bundle();
            bundle.putString("code", LIZ(intent, "ig_result_code"));
            m8s.LIZ = true;
            m8s.LJIIIZ = bundle;
        }
        this.LIZIZ.LIZIZ(m8s.LIZ());
    }
}
