package d.s0;

import d.a0;
import d.d0;
import d.i0;
import d.w;
import d.y;

/* JADX INFO: compiled from: UStrings.kt */
/* JADX INFO: loaded from: classes.dex */
@d.n
public final class u {
    public static final byte a(String str) {
        d.n0.c.s.e(str, "<this>");
        w wVarB = b(str);
        if (wVarB != null) {
            return wVarB.f();
        }
        p.g(str);
        throw new d.h();
    }

    public static final w b(String str) {
        d.n0.c.s.e(str, "<this>");
        return c(str, 10);
    }

    public static final w c(String str, int i) {
        d.n0.c.s.e(str, "<this>");
        y yVarF = f(str, i);
        if (yVarF == null) {
            return null;
        }
        int iF = yVarF.f();
        if (i0.a(iF, y.b(255)) > 0) {
            return null;
        }
        return w.a(w.b((byte) iF));
    }

    public static final int d(String str) {
        d.n0.c.s.e(str, "<this>");
        y yVarE = e(str);
        if (yVarE != null) {
            return yVarE.f();
        }
        p.g(str);
        throw new d.h();
    }

    public static final y e(String str) {
        d.n0.c.s.e(str, "<this>");
        return f(str, 10);
    }

    public static final y f(String str, int i) {
        d.n0.c.s.e(str, "<this>");
        b.a(i);
        int length = str.length();
        if (length == 0) {
            return null;
        }
        int i2 = 0;
        char cCharAt = str.charAt(0);
        int i3 = 1;
        if (d.n0.c.s.f(cCharAt, 48) >= 0) {
            i3 = 0;
        } else if (length == 1 || cCharAt != '+') {
            return null;
        }
        int iB = y.b(i);
        int iB2 = 119304647;
        while (i3 < length) {
            int iB3 = b.b(str.charAt(i3), i);
            if (iB3 < 0) {
                return null;
            }
            if (i0.a(i2, iB2) > 0) {
                if (iB2 == 119304647) {
                    iB2 = i0.b(-1, iB);
                    if (i0.a(i2, iB2) > 0) {
                    }
                }
                return null;
            }
            int iB4 = y.b(i2 * iB);
            int iB5 = y.b(y.b(iB3) + iB4);
            if (i0.a(iB5, iB4) < 0) {
                return null;
            }
            i3++;
            i2 = iB5;
        }
        return y.a(i2);
    }

    public static final long g(String str) {
        d.n0.c.s.e(str, "<this>");
        a0 a0VarH = h(str);
        if (a0VarH != null) {
            return a0VarH.f();
        }
        p.g(str);
        throw new d.h();
    }

    public static final a0 h(String str) {
        d.n0.c.s.e(str, "<this>");
        return i(str, 10);
    }

    public static final a0 i(String str, int i) {
        d.n0.c.s.e(str, "<this>");
        b.a(i);
        int length = str.length();
        if (length == 0) {
            return null;
        }
        long j = -1;
        int i2 = 0;
        char cCharAt = str.charAt(0);
        if (d.n0.c.s.f(cCharAt, 48) < 0) {
            if (length == 1 || cCharAt != '+') {
                return null;
            }
            i2 = 1;
        }
        long jB = a0.b(i);
        long j2 = 0;
        long jD = 512409557603043100L;
        while (i2 < length) {
            int iB = b.b(str.charAt(i2), i);
            if (iB < 0) {
                return null;
            }
            if (i0.c(j2, jD) > 0) {
                if (jD == 512409557603043100L) {
                    jD = i0.d(j, jB);
                    if (i0.c(j2, jD) > 0) {
                    }
                }
                return null;
            }
            long jB2 = a0.b(j2 * jB);
            long jB3 = a0.b(a0.b(((long) y.b(iB)) & 4294967295L) + jB2);
            if (i0.c(jB3, jB2) < 0) {
                return null;
            }
            i2++;
            j2 = jB3;
            j = -1;
        }
        return a0.a(j2);
    }

    public static final short j(String str) {
        d.n0.c.s.e(str, "<this>");
        d0 d0VarK = k(str);
        if (d0VarK != null) {
            return d0VarK.f();
        }
        p.g(str);
        throw new d.h();
    }

    public static final d0 k(String str) {
        d.n0.c.s.e(str, "<this>");
        return l(str, 10);
    }

    public static final d0 l(String str, int i) {
        d.n0.c.s.e(str, "<this>");
        y yVarF = f(str, i);
        if (yVarF == null) {
            return null;
        }
        int iF = yVarF.f();
        if (i0.a(iF, y.b(65535)) > 0) {
            return null;
        }
        return d0.a(d0.b((short) iF));
    }
}
