package J2;

import V.C0629x;
import a1.AbstractC0958a;
import java.lang.Character;
import java.text.BreakIterator;
import java.util.Locale;
import x4.AbstractC3250p;

/* JADX INFO: loaded from: classes.dex */
public class L implements M {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f3281a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public int f3282b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public int f3283c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public Object f3284d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public Object f3285e;

    public /* synthetic */ L(int i6) {
        this.f3281a = i6;
    }

    public static boolean w(int i6) {
        return i6 == 32 || i6 == 10 || i6 == 13 || i6 == 9;
    }

    public E A() {
        float fZ = z();
        if (Float.isNaN(fZ)) {
            return null;
        }
        int iE = E();
        return iE == 0 ? new E(fZ, 1) : new E(fZ, iE);
    }

    public String B() {
        if (n()) {
            return null;
        }
        int i6 = this.f3282b;
        String str = (String) this.f3284d;
        char cCharAt = str.charAt(i6);
        if (cCharAt != '\'' && cCharAt != '\"') {
            return null;
        }
        int iG = g();
        while (iG != -1 && iG != cCharAt) {
            iG = g();
        }
        if (iG == -1) {
            this.f3282b = i6;
            return null;
        }
        int i7 = this.f3282b;
        this.f3282b = i7 + 1;
        return str.substring(i6 + 1, i7);
    }

    public String C() {
        return D(' ', false);
    }

    public String D(char c6, boolean z6) {
        if (n()) {
            return null;
        }
        int i6 = this.f3282b;
        String str = (String) this.f3284d;
        char cCharAt = str.charAt(i6);
        if ((!z6 && w(cCharAt)) || cCharAt == c6) {
            return null;
        }
        int i7 = this.f3282b;
        int iG = g();
        while (iG != -1 && iG != c6 && (z6 || !w(iG))) {
            iG = g();
        }
        return str.substring(i7, this.f3282b);
    }

    public int E() {
        if (n()) {
            return 0;
        }
        int i6 = this.f3282b;
        String str = (String) this.f3284d;
        if (str.charAt(i6) == '%') {
            this.f3282b++;
            return 9;
        }
        int i7 = this.f3282b;
        if (i7 > this.f3283c - 2) {
            return 0;
        }
        try {
            int iZ = A0.a.z(str.substring(i7, i7 + 2).toLowerCase(Locale.US));
            this.f3282b += 2;
            return iZ;
        } catch (IllegalArgumentException unused) {
            return 0;
        }
    }

    public float F() {
        I();
        int i6 = this.f3282b;
        int i7 = this.f3283c;
        C0425p c0425p = (C0425p) this.f3285e;
        float fA = c0425p.a(i6, i7, (String) this.f3284d);
        if (!Float.isNaN(fA)) {
            this.f3282b = c0425p.f3418a;
        }
        return fA;
    }

    public int G(int i6) {
        h(i6);
        int iPreceding = ((BreakIterator) this.f3285e).preceding(i6);
        return (u(iPreceding) && q(iPreceding) && !t(iPreceding)) ? G(iPreceding) : iPreceding;
    }

    public void H(int i6, int i7, String str) {
        if (i6 > i7) {
            AbstractC0958a.a("start index must be less than or equal to end index: " + i6 + " > " + i7);
        }
        if (i6 < 0) {
            AbstractC0958a.a("start must be non-negative, but was " + i6);
        }
        C0629x c0629x = (C0629x) this.f3285e;
        if (c0629x == null) {
            int iMax = Math.max(255, str.length() + 128);
            char[] cArr = new char[iMax];
            int iMin = Math.min(i6, 64);
            int iMin2 = Math.min(((String) this.f3284d).length() - i7, 64);
            String str2 = (String) this.f3284d;
            int i8 = i6 - iMin;
            kotlin.jvm.internal.o.f(str2, "null cannot be cast to non-null type java.lang.String");
            str2.getChars(i8, i6, cArr, 0);
            String str3 = (String) this.f3284d;
            int i9 = iMax - iMin2;
            int i10 = iMin2 + i7;
            kotlin.jvm.internal.o.f(str3, "null cannot be cast to non-null type java.lang.String");
            str3.getChars(i7, i10, cArr, i9);
            str.getChars(0, str.length(), cArr, iMin);
            int length = str.length() + iMin;
            C0629x c0629x2 = new C0629x(1);
            c0629x2.f7177b = iMax;
            c0629x2.f7180e = cArr;
            c0629x2.f7178c = length;
            c0629x2.f7179d = i9;
            this.f3285e = c0629x2;
            this.f3282b = i8;
            this.f3283c = i10;
            return;
        }
        int i11 = this.f3282b;
        int i12 = i6 - i11;
        int i13 = i7 - i11;
        if (i12 < 0 || i13 > c0629x.f7177b - c0629x.e()) {
            this.f3284d = toString();
            this.f3285e = null;
            this.f3282b = -1;
            this.f3283c = -1;
            H(i6, i7, str);
            return;
        }
        int length2 = str.length() - (i13 - i12);
        if (length2 > c0629x.e()) {
            int iE = length2 - c0629x.e();
            int i14 = c0629x.f7177b;
            do {
                i14 *= 2;
            } while (i14 - c0629x.f7177b < iE);
            char[] cArr2 = new char[i14];
            AbstractC3250p.z((char[]) c0629x.f7180e, cArr2, 0, 0, c0629x.f7178c);
            int i15 = c0629x.f7177b;
            int i16 = c0629x.f7179d;
            int i17 = i15 - i16;
            int i18 = i14 - i17;
            AbstractC3250p.z((char[]) c0629x.f7180e, cArr2, i18, i16, i17 + i16);
            c0629x.f7180e = cArr2;
            c0629x.f7177b = i14;
            c0629x.f7179d = i18;
        }
        int i19 = c0629x.f7178c;
        if (i12 < i19 && i13 <= i19) {
            int i20 = i19 - i13;
            char[] cArr3 = (char[]) c0629x.f7180e;
            AbstractC3250p.z(cArr3, cArr3, c0629x.f7179d - i20, i13, i19);
            c0629x.f7178c = i12;
            c0629x.f7179d -= i20;
        } else if (i12 >= i19 || i13 < i19) {
            int iE2 = c0629x.e() + i12;
            int iE3 = c0629x.e() + i13;
            int i21 = c0629x.f7179d;
            char[] cArr4 = (char[]) c0629x.f7180e;
            AbstractC3250p.z(cArr4, cArr4, c0629x.f7178c, i21, iE2);
            c0629x.f7178c += iE2 - i21;
            c0629x.f7179d = iE3;
        } else {
            c0629x.f7179d = c0629x.e() + i13;
            c0629x.f7178c = i12;
        }
        str.getChars(0, str.length(), (char[]) c0629x.f7180e, c0629x.f7178c);
        c0629x.f7178c = str.length() + c0629x.f7178c;
    }

    public boolean I() {
        J();
        int i6 = this.f3282b;
        if (i6 == this.f3283c || ((String) this.f3284d).charAt(i6) != ',') {
            return false;
        }
        this.f3282b++;
        J();
        return true;
    }

    public void J() {
        while (true) {
            int i6 = this.f3282b;
            if (i6 >= this.f3283c || !w(((String) this.f3284d).charAt(i6))) {
                return;
            } else {
                this.f3282b++;
            }
        }
    }

    @Override // J2.M
    public void a(float f6, float f7, float f8, float f9) {
        f((byte) 3);
        m(4);
        float[] fArr = (float[]) this.f3285e;
        int i6 = this.f3283c;
        int i7 = i6 + 1;
        this.f3283c = i7;
        fArr[i6] = f6;
        int i8 = i6 + 2;
        this.f3283c = i8;
        fArr[i7] = f7;
        int i9 = i6 + 3;
        this.f3283c = i9;
        fArr[i8] = f8;
        this.f3283c = i6 + 4;
        fArr[i9] = f9;
    }

    @Override // J2.M
    public void b(float f6, float f7) {
        f((byte) 0);
        m(2);
        float[] fArr = (float[]) this.f3285e;
        int i6 = this.f3283c;
        int i7 = i6 + 1;
        this.f3283c = i7;
        fArr[i6] = f6;
        this.f3283c = i6 + 2;
        fArr[i7] = f7;
    }

    @Override // J2.M
    public void c(float f6, float f7, float f8, float f9, float f10, float f11) {
        f((byte) 2);
        m(6);
        float[] fArr = (float[]) this.f3285e;
        int i6 = this.f3283c;
        int i7 = i6 + 1;
        this.f3283c = i7;
        fArr[i6] = f6;
        int i8 = i6 + 2;
        this.f3283c = i8;
        fArr[i7] = f7;
        int i9 = i6 + 3;
        this.f3283c = i9;
        fArr[i8] = f8;
        int i10 = i6 + 4;
        this.f3283c = i10;
        fArr[i9] = f9;
        int i11 = i6 + 5;
        this.f3283c = i11;
        fArr[i10] = f10;
        this.f3283c = i6 + 6;
        fArr[i11] = f11;
    }

    @Override // J2.M
    public void close() {
        f((byte) 8);
    }

    @Override // J2.M
    public void d(float f6, float f7, float f8, boolean z6, boolean z7, float f9, float f10) {
        f((byte) ((z6 ? 2 : 0) | 4 | (z7 ? 1 : 0)));
        m(5);
        float[] fArr = (float[]) this.f3285e;
        int i6 = this.f3283c;
        int i7 = i6 + 1;
        this.f3283c = i7;
        fArr[i6] = f6;
        int i8 = i6 + 2;
        this.f3283c = i8;
        fArr[i7] = f7;
        int i9 = i6 + 3;
        this.f3283c = i9;
        fArr[i8] = f8;
        int i10 = i6 + 4;
        this.f3283c = i10;
        fArr[i9] = f9;
        this.f3283c = i6 + 5;
        fArr[i10] = f10;
    }

    @Override // J2.M
    public void e(float f6, float f7) {
        f((byte) 1);
        m(2);
        float[] fArr = (float[]) this.f3285e;
        int i6 = this.f3283c;
        int i7 = i6 + 1;
        this.f3283c = i7;
        fArr[i6] = f6;
        this.f3283c = i6 + 2;
        fArr[i7] = f7;
    }

    public void f(byte b5) {
        int i6 = this.f3282b;
        byte[] bArr = (byte[]) this.f3284d;
        if (i6 == bArr.length) {
            byte[] bArr2 = new byte[bArr.length * 2];
            System.arraycopy(bArr, 0, bArr2, 0, bArr.length);
            this.f3284d = bArr2;
        }
        byte[] bArr3 = (byte[]) this.f3284d;
        int i7 = this.f3282b;
        this.f3282b = i7 + 1;
        bArr3[i7] = b5;
    }

    public int g() {
        int i6 = this.f3282b;
        int i7 = this.f3283c;
        if (i6 == i7) {
            return -1;
        }
        int i8 = i6 + 1;
        this.f3282b = i8;
        if (i8 < i7) {
            return ((String) this.f3284d).charAt(i8);
        }
        return -1;
    }

    public void h(int i6) {
        boolean z6 = false;
        int i7 = this.f3282b;
        int i8 = this.f3283c;
        if (i6 <= i8 && i7 <= i6) {
            z6 = true;
        }
        if (z6) {
            return;
        }
        StringBuilder sbQ = com.google.android.recaptcha.internal.a.q(i6, i7, "Invalid offset: ", ". Valid range is [", " , ");
        sbQ.append(i8);
        sbQ.append(']');
        AbstractC0958a.a(sbQ.toString());
    }

    public Boolean i(Object obj) {
        if (obj == null) {
            return null;
        }
        I();
        int i6 = this.f3282b;
        if (i6 == this.f3283c) {
            return null;
        }
        char cCharAt = ((String) this.f3284d).charAt(i6);
        if (cCharAt != '0' && cCharAt != '1') {
            return null;
        }
        this.f3282b++;
        return Boolean.valueOf(cCharAt == '1');
    }

    public float j(float f6) {
        if (Float.isNaN(f6)) {
            return Float.NaN;
        }
        I();
        return z();
    }

    public boolean k(char c6) {
        int i6 = this.f3282b;
        boolean z6 = i6 < this.f3283c && ((String) this.f3284d).charAt(i6) == c6;
        if (z6) {
            this.f3282b++;
        }
        return z6;
    }

    public boolean l(String str) {
        int length = str.length();
        int i6 = this.f3282b;
        boolean z6 = i6 <= this.f3283c - length && ((String) this.f3284d).substring(i6, i6 + length).equals(str);
        if (z6) {
            this.f3282b += length;
        }
        return z6;
    }

    public void m(int i6) {
        float[] fArr = (float[]) this.f3285e;
        if (fArr.length < this.f3283c + i6) {
            float[] fArr2 = new float[fArr.length * 2];
            System.arraycopy(fArr, 0, fArr2, 0, fArr.length);
            this.f3285e = fArr2;
        }
    }

    public boolean n() {
        return this.f3282b == this.f3283c;
    }

    public void o(M m6) {
        int i6 = 0;
        for (int i7 = 0; i7 < this.f3282b; i7++) {
            byte b5 = ((byte[]) this.f3284d)[i7];
            if (b5 == 0) {
                float[] fArr = (float[]) this.f3285e;
                int i8 = i6 + 1;
                float f6 = fArr[i6];
                i6 += 2;
                m6.b(f6, fArr[i8]);
            } else if (b5 == 1) {
                float[] fArr2 = (float[]) this.f3285e;
                int i9 = i6 + 1;
                float f7 = fArr2[i6];
                i6 += 2;
                m6.e(f7, fArr2[i9]);
            } else if (b5 == 2) {
                float[] fArr3 = (float[]) this.f3285e;
                m6.c(fArr3[i6], fArr3[i6 + 1], fArr3[i6 + 2], fArr3[i6 + 3], fArr3[i6 + 4], fArr3[i6 + 5]);
                i6 += 6;
            } else if (b5 == 3) {
                float[] fArr4 = (float[]) this.f3285e;
                float f8 = fArr4[i6];
                float f9 = fArr4[i6 + 1];
                int i10 = i6 + 3;
                float f10 = fArr4[i6 + 2];
                i6 += 4;
                m6.a(f8, f9, f10, fArr4[i10]);
            } else if (b5 != 8) {
                boolean z6 = (b5 & 2) != 0;
                boolean z7 = (b5 & 1) != 0;
                float[] fArr5 = (float[]) this.f3285e;
                m6.d(fArr5[i6], fArr5[i6 + 1], fArr5[i6 + 2], z6, z7, fArr5[i6 + 3], fArr5[i6 + 4]);
                i6 += 5;
            } else {
                m6.close();
            }
        }
    }

    public int p() {
        C0629x c0629x = (C0629x) this.f3285e;
        if (c0629x == null) {
            return ((String) this.f3284d).length();
        }
        return (c0629x.f7177b - c0629x.e()) + (((String) this.f3284d).length() - (this.f3283c - this.f3282b));
    }

    public boolean q(int i6) {
        int i7 = this.f3282b + 1;
        if (i6 > this.f3283c || i7 > i6) {
            return false;
        }
        CharSequence charSequence = (CharSequence) this.f3284d;
        if (!Character.isLetterOrDigit(Character.codePointBefore(charSequence, i6))) {
            int i8 = i6 - 1;
            if (!Character.isSurrogate(charSequence.charAt(i8))) {
                if (!T1.h.d()) {
                    return false;
                }
                T1.h hVarA = T1.h.a();
                if (hVarA.c() != 1 || hVarA.b(charSequence, i8) == -1) {
                    return false;
                }
            }
        }
        return true;
    }

    public boolean r(int i6) {
        int i7 = this.f3282b + 1;
        if (i6 > this.f3283c || i7 > i6) {
            return false;
        }
        return android.support.v4.media.session.b.x(Character.codePointBefore((CharSequence) this.f3284d, i6));
    }

    public boolean s(int i6) {
        h(i6);
        if (!((BreakIterator) this.f3285e).isBoundary(i6)) {
            return false;
        }
        if (u(i6) && u(i6 - 1) && u(i6 + 1)) {
            return false;
        }
        return i6 <= 0 || i6 >= ((CharSequence) this.f3284d).length() - 1 || !(t(i6) || t(i6 + 1));
    }

    public boolean t(int i6) {
        int i7 = i6 - 1;
        CharSequence charSequence = (CharSequence) this.f3284d;
        Character.UnicodeBlock unicodeBlockOf = Character.UnicodeBlock.of(charSequence.charAt(i7));
        Character.UnicodeBlock unicodeBlock = Character.UnicodeBlock.HIRAGANA;
        if (kotlin.jvm.internal.o.c(unicodeBlockOf, unicodeBlock) && kotlin.jvm.internal.o.c(Character.UnicodeBlock.of(charSequence.charAt(i6)), Character.UnicodeBlock.KATAKANA)) {
            return true;
        }
        return kotlin.jvm.internal.o.c(Character.UnicodeBlock.of(charSequence.charAt(i6)), unicodeBlock) && kotlin.jvm.internal.o.c(Character.UnicodeBlock.of(charSequence.charAt(i7)), Character.UnicodeBlock.KATAKANA);
    }

    public String toString() {
        switch (this.f3281a) {
            case 3:
                C0629x c0629x = (C0629x) this.f3285e;
                if (c0629x == null) {
                    return (String) this.f3284d;
                }
                StringBuilder sb = new StringBuilder();
                sb.append((CharSequence) this.f3284d, 0, this.f3282b);
                sb.append((char[]) c0629x.f7180e, 0, c0629x.f7178c);
                char[] cArr = (char[]) c0629x.f7180e;
                int i6 = c0629x.f7179d;
                sb.append(cArr, i6, c0629x.f7177b - i6);
                String str = (String) this.f3284d;
                sb.append((CharSequence) str, this.f3283c, str.length());
                return sb.toString();
            default:
                return super.toString();
        }
    }

    public boolean u(int i6) {
        if (i6 >= this.f3283c || this.f3282b > i6) {
            return false;
        }
        CharSequence charSequence = (CharSequence) this.f3284d;
        if (!Character.isLetterOrDigit(Character.codePointAt(charSequence, i6)) && !Character.isSurrogate(charSequence.charAt(i6))) {
            if (!T1.h.d()) {
                return false;
            }
            T1.h hVarA = T1.h.a();
            if (hVarA.c() != 1 || hVarA.b(charSequence, i6) == -1) {
                return false;
            }
        }
        return true;
    }

    public boolean v(int i6) {
        if (i6 >= this.f3283c || this.f3282b > i6) {
            return false;
        }
        return android.support.v4.media.session.b.x(Character.codePointAt((CharSequence) this.f3284d, i6));
    }

    public int x(int i6) {
        h(i6);
        int iFollowing = ((BreakIterator) this.f3285e).following(i6);
        return (u(iFollowing + (-1)) && u(iFollowing) && !t(iFollowing)) ? x(iFollowing) : iFollowing;
    }

    public Integer y() {
        int i6 = this.f3282b;
        if (i6 == this.f3283c) {
            return null;
        }
        this.f3282b = i6 + 1;
        return Integer.valueOf(((String) this.f3284d).charAt(i6));
    }

    public float z() {
        int i6 = this.f3282b;
        int i7 = this.f3283c;
        C0425p c0425p = (C0425p) this.f3285e;
        float fA = c0425p.a(i6, i7, (String) this.f3284d);
        if (!Float.isNaN(fA)) {
            this.f3282b = c0425p.f3418a;
        }
        return fA;
    }

    public L(CharSequence charSequence, int i6, Locale locale) {
        this.f3281a = 2;
        this.f3284d = charSequence;
        if (charSequence.length() < 0) {
            AbstractC0958a.a("input start index is outside the CharSequence");
        }
        if (i6 < 0 || i6 > charSequence.length()) {
            AbstractC0958a.a("input end index is outside the CharSequence");
        }
        BreakIterator wordInstance = BreakIterator.getWordInstance(locale);
        this.f3285e = wordInstance;
        this.f3282b = Math.max(0, -50);
        this.f3283c = Math.min(charSequence.length(), i6 + 50);
        wordInstance.setText(new U0.b(charSequence, i6));
    }

    public L(String str) {
        this.f3281a = 1;
        this.f3282b = 0;
        this.f3283c = 0;
        this.f3285e = new C0425p();
        String strTrim = str.trim();
        this.f3284d = strTrim;
        this.f3283c = strTrim.length();
    }
}
