package com.google.android.gms.internal.ads;

import java.io.IOException;
import java.nio.charset.Charset;

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final Charset f16233a = Charset.forName("UTF-8");

    public static int a(m92 m92Var) throws IOException {
        if (!(m92Var instanceof p92)) {
            throw new IOException("invalid key id: not a JSON primitive");
        }
        if (!(m92Var.g().f15315a instanceof Number)) {
            throw new IOException("invalid key id: not a JSON number");
        }
        Number numberH = m92Var.g().h();
        try {
            if (!(numberH instanceof zzhiz)) {
                throw new IllegalArgumentException("does not contain a parsed number.");
            }
            long j10 = Long.parseLong(numberH.toString());
            if (j10 > 4294967295L || j10 < -2147483648L) {
                throw new IOException("invalid key id");
            }
            return (int) j10;
        } catch (NumberFormatException e10) {
            throw new IOException(e10);
        }
    }
}
