package f0; import d0.g0.t; import d0.g0.w; import d0.z.d.m; import f0.e0.c; import java.util.concurrent.TimeUnit; import kotlin.TypeCastException; import kotlin.jvm.internal.DefaultConstructorMarker; import okhttp3.Headers; /* compiled from: CacheControl.kt */ /* loaded from: classes3.dex */ public final class d { public static final a a = new a(null); /* renamed from: b reason: collision with root package name */ public final boolean f3576b; public final boolean c; public final int d; public final int e; public final boolean f; public final boolean g; public final boolean h; public final int i; public final int j; public final boolean k; public final boolean l; public final boolean m; public String n; /* compiled from: CacheControl.kt */ /* loaded from: classes3.dex */ public static final class a { public a(DefaultConstructorMarker defaultConstructorMarker) { } public final int a(String str, String str2, int i) { int length = str.length(); while (i < length) { if (w.contains$default((CharSequence) str2, str.charAt(i), false, 2, (Object) null)) { return i; } i++; } return str.length(); } /* JADX WARN: Removed duplicated region for block: B:14:0x004a */ /* JADX WARN: Removed duplicated region for block: B:44:0x0104 */ /* JADX WARN: Removed duplicated region for block: B:45:0x0108 */ /* Code decompiled incorrectly, please refer to instructions dump. */ public final d b(Headers headers) { int i; String str; Headers headers2 = headers; m.checkParameterIsNotNull(headers2, "headers"); int size = headers.size(); boolean z2 = true; int i2 = 0; boolean z3 = true; String str2 = null; boolean z4 = false; boolean z5 = false; int i3 = -1; int i4 = -1; boolean z6 = false; boolean z7 = false; boolean z8 = false; int i5 = -1; int i6 = -1; boolean z9 = false; boolean z10 = false; boolean z11 = false; while (i2 < size) { String d = headers2.d(i2); String g = headers2.g(i2); if (t.equals(d, "Cache-Control", z2)) { if (str2 == null) { str2 = g; i = 0; while (i < g.length()) { int a = a(g, "=,;", i); String substring = g.substring(i, a); m.checkExpressionValueIsNotNull(substring, "(this as java.lang.Strin…ing(startIndex, endIndex)"); if (substring != null) { String obj = w.trim(substring).toString(); if (a != g.length()) { z3 = z3; if (!(g.charAt(a) == ',' || g.charAt(a) == ';')) { int i7 = a + 1; byte[] bArr = c.a; m.checkParameterIsNotNull(g, "$this$indexOfNonWhitespace"); int length = g.length(); while (true) { if (i7 < length) { char charAt = g.charAt(i7); if (charAt != ' ' && charAt != '\t') { break; } i7++; length = length; } else { i7 = g.length(); break; } } if (i7 >= g.length() || g.charAt(i7) != '\"') { int a2 = a(g, ",;", i7); String substring2 = g.substring(i7, a2); m.checkExpressionValueIsNotNull(substring2, "(this as java.lang.Strin…ing(startIndex, endIndex)"); if (substring2 != null) { str = w.trim(substring2).toString(); i = a2; } else { throw new TypeCastException("null cannot be cast to non-null type kotlin.CharSequence"); } } else { int i8 = i7 + 1; int indexOf$default = w.indexOf$default((CharSequence) g, '\"', i8, false, 4, (Object) null); str = g.substring(i8, indexOf$default); m.checkExpressionValueIsNotNull(str, "(this as java.lang.Strin…ing(startIndex, endIndex)"); i = indexOf$default + 1; } z2 = true; if (!t.equals("no-cache", obj, true)) { z4 = true; } else if (t.equals("no-store", obj, true)) { z5 = true; } else if (t.equals("max-age", obj, true)) { i3 = c.B(str, -1); } else if (t.equals("s-maxage", obj, true)) { i4 = c.B(str, -1); } else if (t.equals("private", obj, true)) { z6 = true; } else if (t.equals("public", obj, true)) { z7 = true; } else if (t.equals("must-revalidate", obj, true)) { z8 = true; } else if (t.equals("max-stale", obj, true)) { i5 = c.B(str, Integer.MAX_VALUE); } else if (t.equals("min-fresh", obj, true)) { i6 = c.B(str, -1); } else if (t.equals("only-if-cached", obj, true)) { z9 = true; } else if (t.equals("no-transform", obj, true)) { z10 = true; } else if (t.equals("immutable", obj, true)) { z11 = true; } size = size; } } else { z3 = z3; } i = a + 1; str = null; z2 = true; if (!t.equals("no-cache", obj, true)) { } size = size; } else { throw new TypeCastException("null cannot be cast to non-null type kotlin.CharSequence"); } } size = size; i2++; headers2 = headers; } } else if (!t.equals(d, "Pragma", z2)) { size = size; i2++; headers2 = headers; } z3 = false; i = 0; while (i < g.length()) { } size = size; i2++; headers2 = headers; } return new d(z4, z5, i3, i4, z6, z7, z8, i5, i6, z9, z10, z11, !z3 ? null : str2, null); } } static { TimeUnit timeUnit = TimeUnit.SECONDS; m.checkParameterIsNotNull(timeUnit, "timeUnit"); timeUnit.toSeconds(Integer.MAX_VALUE); } public d(boolean z2, boolean z3, int i, int i2, boolean z4, boolean z5, boolean z6, int i3, int i4, boolean z7, boolean z8, boolean z9, String str, DefaultConstructorMarker defaultConstructorMarker) { this.f3576b = z2; this.c = z3; this.d = i; this.e = i2; this.f = z4; this.g = z5; this.h = z6; this.i = i3; this.j = i4; this.k = z7; this.l = z8; this.m = z9; this.n = str; } public String toString() { String str = this.n; if (str != null) { return str; } StringBuilder sb = new StringBuilder(); if (this.f3576b) { sb.append("no-cache, "); } if (this.c) { sb.append("no-store, "); } if (this.d != -1) { sb.append("max-age="); sb.append(this.d); sb.append(", "); } if (this.e != -1) { sb.append("s-maxage="); sb.append(this.e); sb.append(", "); } if (this.f) { sb.append("private, "); } if (this.g) { sb.append("public, "); } if (this.h) { sb.append("must-revalidate, "); } if (this.i != -1) { sb.append("max-stale="); sb.append(this.i); sb.append(", "); } if (this.j != -1) { sb.append("min-fresh="); sb.append(this.j); sb.append(", "); } if (this.k) { sb.append("only-if-cached, "); } if (this.l) { sb.append("no-transform, "); } if (this.m) { sb.append("immutable, "); } if (sb.length() == 0) { return ""; } sb.delete(sb.length() - 2, sb.length()); String sb2 = sb.toString(); m.checkExpressionValueIsNotNull(sb2, "StringBuilder().apply(builderAction).toString()"); this.n = sb2; return sb2; } }