package o;

import java.io.EOFException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.util.Arrays;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.Ff, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public class C0135Ff implements Serializable, Comparable {

    /* renamed from: o, reason: collision with root package name */
    public static final C0135Ff f122o = new C0135Ff(new byte[0]);
    private static final long serialVersionUID = 1;
    public final byte[] l;
    public transient int m;
    public transient String n;

    public C0135Ff(byte[] bArr) {
        this.l = bArr;
    }

    public static int e(C0135Ff c0135Ff, C0135Ff c0135Ff2) {
        c0135Ff.getClass();
        return c0135Ff.d(0, c0135Ff2.f());
    }

    public static /* synthetic */ C0135Ff l(C0135Ff c0135Ff, int i, int i2, int i3) {
        if ((i3 & 1) != 0) {
            i = 0;
        }
        if ((i3 & 2) != 0) {
            i2 = -1234567890;
        }
        return c0135Ff.k(i, i2);
    }

    private final void readObject(ObjectInputStream objectInputStream) throws IllegalAccessException, NoSuchFieldException, IOException, SecurityException, IllegalArgumentException {
        int i = objectInputStream.readInt();
        if (i < 0) {
            throw new IllegalArgumentException(AbstractC0126Ew.j(i, "byteCount < 0: ").toString());
        }
        byte[] bArr = new byte[i];
        int i2 = 0;
        while (i2 < i) {
            int i3 = objectInputStream.read(bArr, i2, i - i2);
            if (i3 == -1) {
                throw new EOFException();
            }
            i2 += i3;
        }
        C0135Ff c0135Ff = new C0135Ff(bArr);
        Field declaredField = C0135Ff.class.getDeclaredField("l");
        declaredField.setAccessible(true);
        declaredField.set(this, c0135Ff.l);
    }

    private final void writeObject(ObjectOutputStream objectOutputStream) throws IOException {
        objectOutputStream.writeInt(this.l.length);
        objectOutputStream.write(this.l);
    }

    @Override // java.lang.Comparable
    /* renamed from: a, reason: merged with bridge method [inline-methods] */
    public final int compareTo(C0135Ff c0135Ff) {
        int iB = b();
        int iB2 = c0135Ff.b();
        int iMin = Math.min(iB, iB2);
        for (int i = 0; i < iMin; i++) {
            int iG = g(i) & 255;
            int iG2 = c0135Ff.g(i) & 255;
            if (iG != iG2) {
                return iG < iG2 ? -1 : 1;
            }
        }
        if (iB == iB2) {
            return 0;
        }
        return iB < iB2 ? -1 : 1;
    }

    public int b() {
        return this.l.length;
    }

    public String c() {
        byte[] bArr = this.l;
        char[] cArr = new char[bArr.length * 2];
        int i = 0;
        for (byte b : bArr) {
            int i2 = i + 1;
            char[] cArr2 = C1884mi0.c;
            cArr[i] = cArr2[(b >> 4) & 15];
            i += 2;
            cArr[i2] = cArr2[b & 15];
        }
        return new String(cArr);
    }

    public int d(int i, byte[] bArr) {
        int length = this.l.length - bArr.length;
        int iMax = Math.max(i, 0);
        if (iMax > length) {
            return -1;
        }
        while (!F3.d(this.l, iMax, bArr, 0, bArr.length)) {
            if (iMax == length) {
                return -1;
            }
            iMax++;
        }
        return iMax;
    }

    public boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (obj instanceof C0135Ff) {
            C0135Ff c0135Ff = (C0135Ff) obj;
            int iB = c0135Ff.b();
            byte[] bArr = this.l;
            if (iB == bArr.length && c0135Ff.j(bArr, 0, 0, bArr.length)) {
                return true;
            }
        }
        return false;
    }

    public byte[] f() {
        return this.l;
    }

    public byte g(int i) {
        return this.l[i];
    }

    public int h(byte[] bArr) {
        for (int iMin = Math.min(b(), this.l.length - bArr.length); -1 < iMin; iMin--) {
            if (F3.d(this.l, iMin, bArr, 0, bArr.length)) {
                return iMin;
            }
        }
        return -1;
    }

    public int hashCode() {
        int i = this.m;
        if (i != 0) {
            return i;
        }
        int iHashCode = Arrays.hashCode(this.l);
        this.m = iHashCode;
        return iHashCode;
    }

    public boolean i(int i, C0135Ff c0135Ff, int i2) {
        return c0135Ff.j(this.l, 0, i, i2);
    }

    public boolean j(byte[] bArr, int i, int i2, int i3) {
        if (i < 0) {
            return false;
        }
        byte[] bArr2 = this.l;
        return i <= bArr2.length - i3 && i2 >= 0 && i2 <= bArr.length - i3 && F3.d(bArr2, i, bArr, i2, i3);
    }

    public C0135Ff k(int i, int i2) {
        if (i2 == -1234567890) {
            i2 = b();
        }
        if (i < 0) {
            throw new IllegalArgumentException("beginIndex < 0");
        }
        byte[] bArr = this.l;
        if (i2 > bArr.length) {
            throw new IllegalArgumentException(AbstractC2462sn.m(new StringBuilder("endIndex > length("), this.l.length, ')').toString());
        }
        if (i2 - i < 0) {
            throw new IllegalArgumentException("endIndex < beginIndex");
        }
        if (i == 0 && i2 == bArr.length) {
            return this;
        }
        AbstractC2461sm0.d(i2, bArr.length);
        return new C0135Ff(Arrays.copyOfRange(bArr, i, i2));
    }

    public C0135Ff m() {
        int i = 0;
        while (true) {
            byte[] bArr = this.l;
            if (i >= bArr.length) {
                return this;
            }
            byte b = bArr[i];
            if (b >= 65 && b <= 90) {
                byte[] bArrCopyOf = Arrays.copyOf(bArr, bArr.length);
                bArrCopyOf[i] = (byte) (b + 32);
                for (int i2 = i + 1; i2 < bArrCopyOf.length; i2++) {
                    byte b2 = bArrCopyOf[i2];
                    if (b2 >= 65 && b2 <= 90) {
                        bArrCopyOf[i2] = (byte) (b2 + 32);
                    }
                }
                return new C0135Ff(bArrCopyOf);
            }
            i++;
        }
    }

    public final String n() {
        String str = this.n;
        if (str != null) {
            return str;
        }
        String str2 = new String(f(), AbstractC2355rh.a);
        this.n = str2;
        return str2;
    }

    public void o(C0732af c0732af, int i) {
        c0732af.z(i, this.l);
    }

    public String toString() {
        C0135Ff c0135Ff;
        byte b;
        int i;
        byte[] bArr = this.l;
        if (bArr.length == 0) {
            return "[size=0]";
        }
        int length = bArr.length;
        int i2 = 0;
        int i3 = 0;
        int i4 = 0;
        loop0: while (true) {
            if (i2 >= length) {
                break;
            }
            byte b2 = bArr[i2];
            if (b2 >= 0) {
                int i5 = i4 + 1;
                if (i4 == 64) {
                    break;
                }
                if ((b2 != 10 && b2 != 13 && ((b2 >= 0 && b2 < 32) || (Byte.MAX_VALUE <= b2 && b2 < 160))) || b2 == 65533) {
                    break;
                }
                i3 += b2 < 65536 ? 1 : 2;
                i2++;
                while (true) {
                    i4 = i5;
                    if (i2 < length && (b = bArr[i2]) >= 0) {
                        i2++;
                        i5 = i4 + 1;
                        if (i4 == 64) {
                            break loop0;
                        }
                        if ((b != 10 && b != 13 && ((b >= 0 && b < 32) || (Byte.MAX_VALUE <= b && b < 160))) || b == 65533) {
                            break loop0;
                        }
                        i3 += b < 65536 ? 1 : 2;
                    } else {
                        break;
                    }
                }
            } else if ((b2 >> 5) == -2) {
                int i6 = i2 + 1;
                if (length > i6) {
                    byte b3 = bArr[i6];
                    if ((b3 & 192) == 128) {
                        int i7 = (b3 ^ 3968) ^ (b2 << 6);
                        if (i7 >= 128) {
                            i = i4 + 1;
                            if (i4 == 64) {
                                break;
                            }
                            if ((i7 != 10 && i7 != 13 && ((i7 >= 0 && i7 < 32) || (127 <= i7 && i7 < 160))) || i7 == 65533) {
                                break;
                            }
                            i3 += i7 < 65536 ? 1 : 2;
                            i2 += 2;
                            i4 = i;
                        } else if (i4 != 64) {
                            break;
                        }
                    } else if (i4 != 64) {
                        break;
                    }
                } else if (i4 != 64) {
                    break;
                }
            } else if ((b2 >> 4) == -2) {
                int i8 = i2 + 2;
                if (length > i8) {
                    byte b4 = bArr[i2 + 1];
                    if ((b4 & 192) == 128) {
                        byte b5 = bArr[i8];
                        if ((b5 & 192) == 128) {
                            int i9 = ((b5 ^ (-123008)) ^ (b4 << 6)) ^ (b2 << 12);
                            if (i9 < 2048) {
                                if (i4 != 64) {
                                    break;
                                }
                            } else if (55296 > i9 || i9 >= 57344) {
                                i = i4 + 1;
                                if (i4 == 64) {
                                    break;
                                }
                                if ((i9 != 10 && i9 != 13 && ((i9 >= 0 && i9 < 32) || (127 <= i9 && i9 < 160))) || i9 == 65533) {
                                    break;
                                }
                                i3 += i9 < 65536 ? 1 : 2;
                                i2 += 3;
                                i4 = i;
                            } else if (i4 != 64) {
                                break;
                            }
                        } else if (i4 != 64) {
                            break;
                        }
                    } else if (i4 != 64) {
                        break;
                    }
                } else if (i4 != 64) {
                    break;
                }
            } else if ((b2 >> 3) == -2) {
                int i10 = i2 + 3;
                if (length > i10) {
                    byte b6 = bArr[i2 + 1];
                    if ((b6 & 192) == 128) {
                        byte b7 = bArr[i2 + 2];
                        if ((b7 & 192) == 128) {
                            byte b8 = bArr[i10];
                            if ((b8 & 192) == 128) {
                                int i11 = (((b8 ^ 3678080) ^ (b7 << 6)) ^ (b6 << 12)) ^ (b2 << 18);
                                if (i11 > 1114111) {
                                    if (i4 != 64) {
                                        break;
                                    }
                                } else if (55296 > i11 || i11 >= 57344) {
                                    if (i11 >= 65536) {
                                        i = i4 + 1;
                                        if (i4 == 64) {
                                            break;
                                        }
                                        if ((i11 != 10 && i11 != 13 && ((i11 >= 0 && i11 < 32) || (127 <= i11 && i11 < 160))) || i11 == 65533) {
                                            break;
                                        }
                                        i3 += i11 < 65536 ? 1 : 2;
                                        i2 += 4;
                                        i4 = i;
                                    } else if (i4 != 64) {
                                        break;
                                    }
                                } else if (i4 != 64) {
                                    break;
                                }
                            } else if (i4 != 64) {
                                break;
                            }
                        } else if (i4 != 64) {
                            break;
                        }
                    } else if (i4 != 64) {
                        break;
                    }
                } else if (i4 != 64) {
                    break;
                }
            } else if (i4 != 64) {
                break;
            }
        }
        i3 = -1;
        if (i3 != -1) {
            String strN = n();
            String strK = AbstractC1299gb0.K(AbstractC1299gb0.K(AbstractC1299gb0.K(strN.substring(0, i3), "\\", "\\\\"), "\n", "\\n"), "\r", "\\r");
            if (i3 >= strN.length()) {
                return "[text=" + strK + ']';
            }
            return "[size=" + this.l.length + " text=" + strK + "…]";
        }
        if (this.l.length <= 64) {
            return "[hex=" + c() + ']';
        }
        StringBuilder sb = new StringBuilder("[size=");
        sb.append(this.l.length);
        sb.append(" hex=");
        byte[] bArr2 = this.l;
        if (64 > bArr2.length) {
            throw new IllegalArgumentException(AbstractC2462sn.m(new StringBuilder("endIndex > length("), this.l.length, ')').toString());
        }
        if (64 == bArr2.length) {
            c0135Ff = this;
        } else {
            AbstractC2461sm0.d(64, bArr2.length);
            c0135Ff = new C0135Ff(Arrays.copyOfRange(bArr2, 0, 64));
        }
        sb.append(c0135Ff.c());
        sb.append("…]");
        return sb.toString();
    }
}
