what-the-bank/sources/com/airbnb/deeplinkdispatch/TreeNode.java

179 lines
6.7 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.airbnb.deeplinkdispatch;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
import o.C14861gab;
import o.C14881gav;
import o.C14957gcv;
import o.InterfaceC14894gbR;
import o.gaY;
import o.gdP;
import o.gdZ;
/* loaded from: classes.dex */
public class TreeNode {
private final Set<TreeNode> children;
private final String id;
private UriMatch match;
private final NodeMetadata metadata;
public TreeNode(String str, NodeMetadata nodeMetadata) {
C14957gcv.e(str, "");
C14957gcv.e(nodeMetadata, "");
this.id = str;
this.metadata = nodeMetadata;
this.children = new LinkedHashSet();
}
public final void setMatch(UriMatch uriMatch) {
if (this.match == null) {
this.match = uriMatch;
return;
}
StringBuilder sb = new StringBuilder("Ambiguous URI. Same match for two URIs (");
sb.append(this.match);
sb.append(" vs ");
sb.append(uriMatch);
sb.append(')');
throw new IllegalStateException(sb.toString().toString());
}
public final TreeNode addNode(TreeNode treeNode) {
C14957gcv.e(treeNode, "");
if (this.children.add(treeNode)) {
return treeNode;
}
for (TreeNode treeNode2 : this.children) {
if (C14957gcv.b(treeNode2, treeNode)) {
return treeNode2;
}
}
throw new NoSuchElementException("Collection contains no element matching the predicate.");
}
public final String serializedId() {
if (this.metadata.isConfigurablePathSegment) {
String id = getId();
String d = gdZ.d(id, UrlTreeKt.configurablePathSegmentPrefix, id);
return gdZ.c(d, UrlTreeKt.configurablePathSegmentSuffix, d);
}
return getId();
}
/* renamed from: toUByteArray-TcUX1vc, reason: not valid java name */
public final byte[] m16toUByteArrayTcUX1vc() {
List<C14861gab> generateChildrenByteArrays = generateChildrenByteArrays();
byte[] bytes = serializedId().getBytes(gdP.a);
C14957gcv.c(bytes, "");
byte[] copyOf = Arrays.copyOf(bytes, bytes.length);
C14957gcv.c(copyOf, "");
C14957gcv.e(copyOf, "");
byte[] matchByteArray = UrlTreeKt.matchByteArray(this.match);
byte[] m14generateHeaderWWbRO58 = m14generateHeaderWWbRO58(this.metadata, copyOf, matchByteArray, generateChildrenByteArrays);
byte[] bArr = new byte[m12arrayLength7fH4Lao(generateChildrenByteArrays, copyOf, matchByteArray, m14generateHeaderWWbRO58)];
C14957gcv.e(bArr, "");
int length = m14generateHeaderWWbRO58.length;
C14957gcv.e(m14generateHeaderWWbRO58, "");
C14957gcv.e(bArr, "");
System.arraycopy(m14generateHeaderWWbRO58, 0, bArr, 0, length);
int m13copyIntoPositionwl1WTbA = m13copyIntoPositionwl1WTbA(matchByteArray, bArr, m13copyIntoPositionwl1WTbA(copyOf, bArr, m14generateHeaderWWbRO58.length));
Iterator<C14861gab> it = generateChildrenByteArrays.iterator();
while (it.hasNext()) {
m13copyIntoPositionwl1WTbA = m13copyIntoPositionwl1WTbA(it.next().c, bArr, m13copyIntoPositionwl1WTbA);
}
return bArr;
}
private final List<C14861gab> generateChildrenByteArrays() {
Set<TreeNode> set = this.children;
InterfaceC14894gbR[] interfaceC14894gbRArr = {TreeNode$generateChildrenByteArrays$1.INSTANCE, TreeNode$generateChildrenByteArrays$2.INSTANCE, TreeNode$generateChildrenByteArrays$3.INSTANCE};
C14957gcv.e(interfaceC14894gbRArr, "");
List a = C14881gav.a((Iterable) set, (Comparator) new gaY.RVV(interfaceC14894gbRArr));
C14957gcv.e(a, "");
ArrayList arrayList = new ArrayList(a instanceof Collection ? a.size() : 10);
Iterator it = a.iterator();
while (it.hasNext()) {
arrayList.add(new C14861gab(((TreeNode) it.next()).m16toUByteArrayTcUX1vc()));
}
return arrayList;
}
/* JADX WARN: Multi-variable type inference failed */
/* renamed from: generateHeader-WWbRO58$default, reason: not valid java name */
static /* synthetic */ byte[] m15generateHeaderWWbRO58$default(TreeNode treeNode, NodeMetadata nodeMetadata, byte[] bArr, byte[] bArr2, List list, int i, Object obj) {
if (obj != null) {
throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: generateHeader-WWbRO58");
}
if ((i & 8) != 0) {
list = null;
}
return treeNode.m14generateHeaderWWbRO58(nodeMetadata, bArr, bArr2, list);
}
/* renamed from: generateHeader-WWbRO58, reason: not valid java name */
private final byte[] m14generateHeaderWWbRO58(NodeMetadata nodeMetadata, byte[] bArr, byte[] bArr2, List<C14861gab> list) {
int i;
if (list == null) {
i = 0;
} else {
Iterator<T> it = list.iterator();
i = 0;
while (it.hasNext()) {
i += ((C14861gab) it.next()).c.length;
}
}
byte[] bArr3 = new byte[9];
C14957gcv.e(bArr3, "");
bArr3[0] = nodeMetadata.getMetadata();
UrlTreeKt.m18writeUShortAtHFnTLD8(bArr3, 1, (short) bArr.length);
UrlTreeKt.m18writeUShortAtHFnTLD8(bArr3, 3, (short) bArr2.length);
UrlTreeKt.m17writeUIntAtGxOs86I(bArr3, 5, i);
return bArr3;
}
/* renamed from: arrayLength-7fH4Lao, reason: not valid java name */
private final int m12arrayLength7fH4Lao(List<C14861gab> list, byte[] bArr, byte[] bArr2, byte[] bArr3) {
int length = bArr3.length;
int length2 = bArr.length;
int length3 = bArr2.length;
Iterator<T> it = list.iterator();
int i = 0;
while (it.hasNext()) {
i += ((C14861gab) it.next()).c.length;
}
return length + length2 + length3 + i;
}
/* renamed from: copyIntoPosition-wl1WTbA, reason: not valid java name */
private final int m13copyIntoPositionwl1WTbA(byte[] bArr, byte[] bArr2, int i) {
int length = bArr.length;
C14957gcv.e(bArr, "");
C14957gcv.e(bArr2, "");
System.arraycopy(bArr, 0, bArr2, i, length);
return i + bArr.length;
}
public final NodeMetadata getMetadata$deeplinkdispatch_base() {
return this.metadata;
}
public final UriMatch getMatch() {
return this.match;
}
public String getId() {
return this.id;
}
public final Set<TreeNode> getChildren() {
return this.children;
}
}