package com.google.android.gms.fido.fido2.api.common;

import android.os.Parcel;
import android.os.Parcelable;
import android.os.ResultReceiver;
import androidx.media3.extractor.text.ttml.TtmlNode;
import com.google.android.gms.common.internal.Objects;
import com.google.android.gms.common.internal.Preconditions;
import com.google.android.gms.common.internal.safeparcel.SafeParcelWriter;
import com.google.android.gms.common.internal.safeparcel.SafeParcelable;
import com.google.android.gms.common.internal.safeparcel.SafeParcelableSerializer;
import com.google.android.gms.common.util.Base64Utils;
import com.google.android.gms.fido.u2f.api.common.ClientData;
import com.google.android.gms.internal.fido.zzia;
import defpackage.rq6;
import defpackage.vo6;
import defpackage.vw2;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes2.dex */
@SafeParcelable.Class(creator = "PublicKeyCredentialRequestOptionsCreator")
@SafeParcelable.Reserved({1})
public class PublicKeyCredentialRequestOptions extends RequestOptions {

    @vo6
    public static final Parcelable.Creator<PublicKeyCredentialRequestOptions> CREATOR = new zzar();

    @vo6
    @SafeParcelable.Field(getter = "getChallenge", id = 2)
    private final byte[] zza;

    @rq6
    @SafeParcelable.Field(getter = "getTimeoutSeconds", id = 3)
    private final Double zzb;

    @vo6
    @SafeParcelable.Field(getter = "getRpId", id = 4)
    private final String zzc;

    @rq6
    @SafeParcelable.Field(getter = "getAllowList", id = 5)
    private final List zzd;

    @rq6
    @SafeParcelable.Field(getter = "getRequestId", id = 6)
    private final Integer zze;

    @rq6
    @SafeParcelable.Field(getter = "getTokenBinding", id = 7)
    private final TokenBinding zzf;

    @rq6
    @SafeParcelable.Field(getter = "getUserVerificationAsString", id = 8, type = "java.lang.String")
    private final UserVerificationRequirement zzg;

    @rq6
    @SafeParcelable.Field(getter = "getAuthenticationExtensions", id = 9)
    private final AuthenticationExtensions zzh;

    @rq6
    @SafeParcelable.Field(getter = "getLongRequestId", id = 10)
    private final Long zzi;

    @rq6
    @SafeParcelable.Field(getter = "getResultReceiver", id = 12)
    private ResultReceiver zzj;

    public static final class Builder {
        private byte[] zza;
        private Double zzb;
        private String zzc;
        private List zzd;
        private Integer zze;
        private TokenBinding zzf;
        private UserVerificationRequirement zzg;
        private AuthenticationExtensions zzh;
        private Long zzi;
        private ResultReceiver zzj;

        public Builder() {
        }

        @vo6
        public PublicKeyCredentialRequestOptions build() {
            byte[] bArr = this.zza;
            Double d = this.zzb;
            String str = this.zzc;
            List list = this.zzd;
            Integer num = this.zze;
            TokenBinding tokenBinding = this.zzf;
            UserVerificationRequirement userVerificationRequirement = this.zzg;
            return new PublicKeyCredentialRequestOptions(bArr, d, str, list, num, tokenBinding, userVerificationRequirement == null ? null : userVerificationRequirement.toString(), this.zzh, this.zzi, null, this.zzj);
        }

        @vo6
        public Builder setAllowList(@rq6 List<PublicKeyCredentialDescriptor> list) {
            this.zzd = list;
            return this;
        }

        @vo6
        public Builder setAuthenticationExtensions(@rq6 AuthenticationExtensions authenticationExtensions) {
            this.zzh = authenticationExtensions;
            return this;
        }

        @vo6
        public Builder setChallenge(@vo6 byte[] bArr) {
            this.zza = (byte[]) Preconditions.checkNotNull(bArr);
            return this;
        }

        @vo6
        public Builder setRequestId(@rq6 Integer num) {
            this.zze = num;
            return this;
        }

        @vo6
        public Builder setRpId(@vo6 String str) {
            this.zzc = (String) Preconditions.checkNotNull(str);
            return this;
        }

        @vo6
        public Builder setTimeoutSeconds(@rq6 Double d) {
            this.zzb = d;
            return this;
        }

        @vo6
        public Builder setTokenBinding(@rq6 TokenBinding tokenBinding) {
            this.zzf = tokenBinding;
            return this;
        }

        @vo6
        public final Builder zza(@rq6 Long l) {
            this.zzi = l;
            return this;
        }

        @vo6
        public final Builder zzb(@rq6 ResultReceiver resultReceiver) {
            this.zzj = null;
            return this;
        }

        @vo6
        public final Builder zzc(@rq6 UserVerificationRequirement userVerificationRequirement) {
            this.zzg = userVerificationRequirement;
            return this;
        }

        public Builder(@rq6 PublicKeyCredentialRequestOptions publicKeyCredentialRequestOptions) {
            if (publicKeyCredentialRequestOptions != null) {
                this.zza = publicKeyCredentialRequestOptions.getChallenge();
                this.zzb = publicKeyCredentialRequestOptions.getTimeoutSeconds();
                this.zzc = publicKeyCredentialRequestOptions.getRpId();
                this.zzd = publicKeyCredentialRequestOptions.getAllowList();
                this.zze = publicKeyCredentialRequestOptions.getRequestId();
                this.zzf = publicKeyCredentialRequestOptions.getTokenBinding();
                this.zzg = publicKeyCredentialRequestOptions.zzb();
                this.zzh = publicKeyCredentialRequestOptions.getAuthenticationExtensions();
                this.zzi = publicKeyCredentialRequestOptions.zzc();
                this.zzj = publicKeyCredentialRequestOptions.zza();
            }
        }
    }

    @SafeParcelable.Constructor
    public PublicKeyCredentialRequestOptions(@vo6 @SafeParcelable.Param(id = 2) byte[] bArr, @rq6 @SafeParcelable.Param(id = 3) Double d, @vo6 @SafeParcelable.Param(id = 4) String str, @rq6 @SafeParcelable.Param(id = 5) List list, @rq6 @SafeParcelable.Param(id = 6) Integer num, @rq6 @SafeParcelable.Param(id = 7) TokenBinding tokenBinding, @rq6 @SafeParcelable.Param(id = 8) String str2, @rq6 @SafeParcelable.Param(id = 9) AuthenticationExtensions authenticationExtensions, @rq6 @SafeParcelable.Param(id = 10) Long l, @rq6 @SafeParcelable.Param(id = 11) String str3, @rq6 @SafeParcelable.Param(id = 12) ResultReceiver resultReceiver) {
        this.zzj = resultReceiver;
        if (str3 == null || !zzia.zzc()) {
            this.zza = (byte[]) Preconditions.checkNotNull(bArr);
            this.zzb = d;
            this.zzc = (String) Preconditions.checkNotNull(str);
            this.zzd = list;
            this.zze = num;
            this.zzf = tokenBinding;
            this.zzi = l;
            if (str2 != null) {
                try {
                    this.zzg = UserVerificationRequirement.fromString(str2);
                } catch (zzbc e) {
                    throw new IllegalArgumentException(e);
                }
            } else {
                this.zzg = null;
            }
            this.zzh = authenticationExtensions;
            return;
        }
        try {
            JSONObject jSONObject = new JSONObject(str3);
            Builder builder = new Builder();
            builder.setChallenge(Base64Utils.decodeUrlSafeNoPadding(jSONObject.getString(ClientData.KEY_CHALLENGE)));
            if (jSONObject.has("timeout")) {
                builder.setTimeoutSeconds(Double.valueOf(jSONObject.getDouble("timeout") / 1000.0d));
            } else if (jSONObject.has("timeoutSeconds")) {
                builder.setTimeoutSeconds(Double.valueOf(jSONObject.getDouble("timeoutSeconds")));
            }
            builder.setRpId(jSONObject.getString("rpId"));
            JSONArray jSONArray = jSONObject.has("allowList") ? jSONObject.getJSONArray("allowList") : jSONObject.has("allowCredentials") ? jSONObject.getJSONArray("allowCredentials") : null;
            if (jSONArray != null) {
                ArrayList arrayList = new ArrayList();
                for (int i = 0; i < jSONArray.length(); i++) {
                    arrayList.add(PublicKeyCredentialDescriptor.zza(jSONArray.getJSONObject(i)));
                }
                builder.setAllowList(arrayList);
            }
            if (jSONObject.has("requestId")) {
                builder.setRequestId(Integer.valueOf(jSONObject.getInt("requestId")));
            }
            if (jSONObject.has("tokenBinding")) {
                JSONObject jSONObject2 = jSONObject.getJSONObject("tokenBinding");
                builder.setTokenBinding(new TokenBinding(jSONObject2.getString("status"), jSONObject2.has(TtmlNode.ATTR_ID) ? jSONObject2.getString(TtmlNode.ATTR_ID) : null));
            }
            if (jSONObject.has("userVerification")) {
                builder.zzc(UserVerificationRequirement.fromString(jSONObject.getString("userVerification")));
            }
            if (jSONObject.has("authenticationExtensions")) {
                builder.setAuthenticationExtensions(AuthenticationExtensions.zza(jSONObject.getJSONObject("authenticationExtensions")));
            } else if (jSONObject.has("extensions")) {
                builder.setAuthenticationExtensions(AuthenticationExtensions.zza(jSONObject.getJSONObject("extensions")));
            }
            if (jSONObject.has("longRequestId")) {
                builder.zza(Long.valueOf(jSONObject.getLong("longRequestId")));
            }
            PublicKeyCredentialRequestOptions publicKeyCredentialRequestOptionsBuild = builder.build();
            this.zza = publicKeyCredentialRequestOptionsBuild.zza;
            this.zzb = publicKeyCredentialRequestOptionsBuild.zzb;
            this.zzc = publicKeyCredentialRequestOptionsBuild.zzc;
            this.zzd = publicKeyCredentialRequestOptionsBuild.zzd;
            this.zze = publicKeyCredentialRequestOptionsBuild.zze;
            this.zzf = publicKeyCredentialRequestOptionsBuild.zzf;
            this.zzg = publicKeyCredentialRequestOptionsBuild.zzg;
            this.zzh = publicKeyCredentialRequestOptionsBuild.zzh;
            this.zzi = publicKeyCredentialRequestOptionsBuild.zzi;
        } catch (zzbc e2) {
            e = e2;
            throw new IllegalArgumentException(e);
        } catch (JSONException e3) {
            e = e3;
            throw new IllegalArgumentException(e);
        }
    }

    @vo6
    public static PublicKeyCredentialRequestOptions deserializeFromBytes(@rq6 byte[] bArr) {
        return (PublicKeyCredentialRequestOptions) SafeParcelableSerializer.deserializeFromBytes(bArr, CREATOR);
    }

    public boolean equals(@vo6 Object obj) {
        List list;
        List list2;
        if (!(obj instanceof PublicKeyCredentialRequestOptions)) {
            return false;
        }
        PublicKeyCredentialRequestOptions publicKeyCredentialRequestOptions = (PublicKeyCredentialRequestOptions) obj;
        return Arrays.equals(this.zza, publicKeyCredentialRequestOptions.zza) && Objects.equal(this.zzb, publicKeyCredentialRequestOptions.zzb) && Objects.equal(this.zzc, publicKeyCredentialRequestOptions.zzc) && (((list = this.zzd) == null && publicKeyCredentialRequestOptions.zzd == null) || (list != null && (list2 = publicKeyCredentialRequestOptions.zzd) != null && list.containsAll(list2) && publicKeyCredentialRequestOptions.zzd.containsAll(this.zzd))) && Objects.equal(this.zze, publicKeyCredentialRequestOptions.zze) && Objects.equal(this.zzf, publicKeyCredentialRequestOptions.zzf) && Objects.equal(this.zzg, publicKeyCredentialRequestOptions.zzg) && Objects.equal(this.zzh, publicKeyCredentialRequestOptions.zzh) && Objects.equal(this.zzi, publicKeyCredentialRequestOptions.zzi);
    }

    @rq6
    public List<PublicKeyCredentialDescriptor> getAllowList() {
        return this.zzd;
    }

    @Override // com.google.android.gms.fido.fido2.api.common.RequestOptions
    @rq6
    public AuthenticationExtensions getAuthenticationExtensions() {
        return this.zzh;
    }

    @Override // com.google.android.gms.fido.fido2.api.common.RequestOptions
    @vo6
    public byte[] getChallenge() {
        return this.zza;
    }

    @Override // com.google.android.gms.fido.fido2.api.common.RequestOptions
    @rq6
    public Integer getRequestId() {
        return this.zze;
    }

    @vo6
    public String getRpId() {
        return this.zzc;
    }

    @Override // com.google.android.gms.fido.fido2.api.common.RequestOptions
    @rq6
    public Double getTimeoutSeconds() {
        return this.zzb;
    }

    @Override // com.google.android.gms.fido.fido2.api.common.RequestOptions
    @rq6
    public TokenBinding getTokenBinding() {
        return this.zzf;
    }

    public int hashCode() {
        return Objects.hashCode(Integer.valueOf(Arrays.hashCode(this.zza)), this.zzb, this.zzc, this.zzd, this.zze, this.zzf, this.zzg, this.zzh, this.zzi);
    }

    @Override // com.google.android.gms.fido.fido2.api.common.RequestOptions
    @vo6
    public byte[] serializeToBytes() {
        if (!zzia.zzd()) {
            return SafeParcelableSerializer.serializeToBytes(this);
        }
        Builder builder = new Builder(this);
        builder.zzb(null);
        return SafeParcelableSerializer.serializeToBytes(builder.build());
    }

    @vo6
    public final String toString() {
        AuthenticationExtensions authenticationExtensions = this.zzh;
        UserVerificationRequirement userVerificationRequirement = this.zzg;
        TokenBinding tokenBinding = this.zzf;
        List list = this.zzd;
        String strEncodeUrlSafeNoPadding = Base64Utils.encodeUrlSafeNoPadding(this.zza);
        String strValueOf = String.valueOf(list);
        String strValueOf2 = String.valueOf(tokenBinding);
        String strValueOf3 = String.valueOf(userVerificationRequirement);
        String strValueOf4 = String.valueOf(authenticationExtensions);
        StringBuilder sbS = vw2.s("PublicKeyCredentialRequestOptions{\n challenge=", strEncodeUrlSafeNoPadding, ", \n timeoutSeconds=");
        sbS.append(this.zzb);
        sbS.append(", \n rpId='");
        vw2.aa(sbS, this.zzc, "', \n allowList=", strValueOf, ", \n requestId=");
        sbS.append(this.zze);
        sbS.append(", \n tokenBinding=");
        sbS.append(strValueOf2);
        sbS.append(", \n userVerification=");
        vw2.aa(sbS, strValueOf3, ", \n authenticationExtensions=", strValueOf4, ", \n longRequestId=");
        sbS.append(this.zzi);
        sbS.append("}");
        return sbS.toString();
    }

    @Override // android.os.Parcelable
    public void writeToParcel(@vo6 Parcel parcel, int i) {
        int iBeginObjectHeader = SafeParcelWriter.beginObjectHeader(parcel);
        SafeParcelWriter.writeByteArray(parcel, 2, getChallenge(), false);
        SafeParcelWriter.writeDoubleObject(parcel, 3, getTimeoutSeconds(), false);
        SafeParcelWriter.writeString(parcel, 4, getRpId(), false);
        SafeParcelWriter.writeTypedList(parcel, 5, getAllowList(), false);
        SafeParcelWriter.writeIntegerObject(parcel, 6, getRequestId(), false);
        SafeParcelWriter.writeParcelable(parcel, 7, getTokenBinding(), i, false);
        UserVerificationRequirement userVerificationRequirement = this.zzg;
        SafeParcelWriter.writeString(parcel, 8, userVerificationRequirement == null ? null : userVerificationRequirement.toString(), false);
        SafeParcelWriter.writeParcelable(parcel, 9, getAuthenticationExtensions(), i, false);
        SafeParcelWriter.writeLongObject(parcel, 10, this.zzi, false);
        SafeParcelWriter.writeString(parcel, 11, null, false);
        SafeParcelWriter.writeParcelable(parcel, 12, this.zzj, i, false);
        SafeParcelWriter.finishObjectHeader(parcel, iBeginObjectHeader);
    }

    @rq6
    public final ResultReceiver zza() {
        return this.zzj;
    }

    @rq6
    public final UserVerificationRequirement zzb() {
        return this.zzg;
    }

    @rq6
    public final Long zzc() {
        return this.zzi;
    }
}
