package com.google.firebase.messaging;

import android.text.TextUtils;
import androidx.annotation.Nullable;
import java.util.Arrays;
import java.util.regex.Pattern;

/* JADX INFO: loaded from: classes2.dex */
public final class g0 {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final Pattern f24173d = Pattern.compile("[a-zA-Z0-9-_.~%]{1,900}");

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final String f24174a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final String f24175b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final String f24176c;

    public g0(String str, String str2) {
        String strSubstring;
        if (str2 == null || !str2.startsWith("/topics/")) {
            strSubstring = str2;
        } else {
            String.format("Format /topics/topic-name is deprecated. Only 'topic-name' should be used in %s.", str);
            strSubstring = str2.substring(8);
        }
        if (strSubstring == null || !f24173d.matcher(strSubstring).matches()) {
            throw new IllegalArgumentException(String.format("Invalid topic name: %s does not match the allowed format %s.", strSubstring, "[a-zA-Z0-9-_.~%]{1,900}"));
        }
        this.f24174a = strSubstring;
        this.f24175b = str;
        this.f24176c = defpackage.e.j(str, "!", str2);
    }

    @Nullable
    public static g0 from(String str) {
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        String[] strArrSplit = str.split("!", -1);
        if (strArrSplit.length != 2) {
            return null;
        }
        return new g0(strArrSplit[0], strArrSplit[1]);
    }

    public boolean equals(@Nullable Object obj) {
        if (!(obj instanceof g0)) {
            return false;
        }
        g0 g0Var = (g0) obj;
        return this.f24174a.equals(g0Var.f24174a) && this.f24175b.equals(g0Var.f24175b);
    }

    public final int hashCode() {
        return Arrays.hashCode(new Object[]{this.f24175b, this.f24174a});
    }
}
