package com.google.android.play.core.assetpacks; import java.util.Arrays; /* loaded from: classes2.dex */ final class g2 { /* renamed from: a, reason: collision with root package name */ private byte[] f4891a = new byte[4096]; /* renamed from: b, reason: collision with root package name */ private int f4892b; /* renamed from: c, reason: collision with root package name */ private long f4893c; /* renamed from: d, reason: collision with root package name */ private long f4894d; /* renamed from: e, reason: collision with root package name */ private int f4895e; /* renamed from: f, reason: collision with root package name */ private int f4896f; /* renamed from: g, reason: collision with root package name */ private int f4897g; /* renamed from: h, reason: collision with root package name */ private boolean f4898h; /* renamed from: i, reason: collision with root package name */ private String f4899i; public g2() { d(); } private final int e(int i10, byte[] bArr, int i11, int i12) { int i13 = this.f4892b; if (i13 >= i10) { return 0; } int min = Math.min(i12, i10 - i13); System.arraycopy(bArr, i11, this.f4891a, this.f4892b, min); int i14 = this.f4892b + min; this.f4892b = i14; if (i14 < i10) { return -1; } return min; } public final int a() { return this.f4896f; } public final int b(byte[] bArr, int i10, int i11) { int e10 = e(30, bArr, i10, i11); if (e10 == -1) { return -1; } if (this.f4893c == -1) { long b10 = n0.b(this.f4891a, 0); this.f4893c = b10; if (b10 == 67324752) { this.f4898h = false; this.f4894d = n0.b(this.f4891a, 18); this.f4897g = n0.a(this.f4891a, 8); this.f4895e = n0.a(this.f4891a, 26); int a10 = this.f4895e + 30 + n0.a(this.f4891a, 28); this.f4896f = a10; int length = this.f4891a.length; if (length < a10) { do { length += length; } while (length < a10); this.f4891a = Arrays.copyOf(this.f4891a, length); } } else { this.f4898h = true; } } int e11 = e(this.f4896f, bArr, i10 + e10, i11 - e10); if (e11 == -1) { return -1; } int i12 = e10 + e11; if (!this.f4898h && this.f4899i == null) { this.f4899i = new String(this.f4891a, 30, this.f4895e); } return i12; } public final h3 c() { int i10 = this.f4892b; int i11 = this.f4896f; if (i10 < i11) { return new m0(this.f4899i, this.f4894d, this.f4897g, true, this.f4898h, Arrays.copyOf(this.f4891a, i10)); } m0 m0Var = new m0(this.f4899i, this.f4894d, this.f4897g, false, this.f4898h, Arrays.copyOf(this.f4891a, i11)); d(); return m0Var; } public final void d() { this.f4892b = 0; this.f4895e = -1; this.f4893c = -1L; this.f4898h = false; this.f4896f = 30; this.f4894d = -1L; this.f4897g = -1; this.f4899i = null; } }