package com.tapjoy.internal; import com.mbridge.msdk.playercommon.exoplayer2.extractor.ts.PsExtractor; /* loaded from: classes4.dex */ public final class o0 extends u0 { public o0() { super(3); } @Override // com.tapjoy.internal.u0 public final Object a(v0 v0Var) { return v0Var.a.b(v0Var.a()); } @Override // com.tapjoy.internal.u0 public final void a(w0 w0Var, Object obj) { char charAt; String str = (String) obj; l lVar = w0Var.a; int length = str.length(); if (length >= 0) { if (length > str.length()) { throw new IllegalArgumentException("endIndex > string.length: " + length + " > " + str.length()); } int i = 0; while (i < length) { char charAt2 = str.charAt(i); if (charAt2 < 128) { b1 a = lVar.a(1); byte[] bArr = a.a; int i2 = a.c - i; int min = Math.min(length, 8192 - i2); int i3 = i + 1; bArr[i + i2] = (byte) charAt2; while (true) { i = i3; if (i >= min || (charAt = str.charAt(i)) >= 128) { break; } i3 = i + 1; bArr[i + i2] = (byte) charAt; } int i4 = a.c; int i5 = (i2 + i) - i4; a.c = i4 + i5; lVar.b += i5; } else { if (charAt2 < 2048) { lVar.b((charAt2 >> 6) | PsExtractor.AUDIO_STREAM); lVar.b((charAt2 & '?') | 128); } else if (charAt2 >= 55296 && charAt2 <= 57343) { int i6 = i + 1; char charAt3 = i6 < length ? str.charAt(i6) : (char) 0; if (charAt2 <= 56319 && charAt3 >= 56320 && charAt3 <= 57343) { int i7 = (((charAt2 & 10239) << 10) | (9215 & charAt3)) + 65536; lVar.b((i7 >> 18) | PsExtractor.VIDEO_STREAM_MASK); lVar.b(((i7 >> 12) & 63) | 128); lVar.b(((i7 >> 6) & 63) | 128); lVar.b((i7 & 63) | 128); i += 2; } else { lVar.b(63); i = i6; } } else { lVar.b((charAt2 >> '\f') | 224); lVar.b(((charAt2 >> 6) & 63) | 128); lVar.b((charAt2 & '?') | 128); } i++; } } return; } throw new IllegalArgumentException("endIndex < beginIndex: " + length + " < 0"); } @Override // com.tapjoy.internal.u0 public final int a(Object obj) { int i; String str = (String) obj; int length = str.length(); int i2 = 0; int i3 = 0; while (i2 < length) { char charAt = str.charAt(i2); if (charAt >= 128) { if (charAt < 2048) { i3 += 2; } else if (charAt < 55296 || charAt > 57343) { i3 += 3; } else if (charAt <= 56319 && (i = i2 + 1) < length && str.charAt(i) >= 56320 && str.charAt(i) <= 57343) { i3 += 4; i2 = i; } i2++; } i3++; i2++; } return i3; } }