package com.apiguard3.internal;

import android.os.Process;
import android.os.SystemClock;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import android.util.Pair;
import android.view.ViewConfiguration;
import com.apiguard3.internal.getState;
import com.apiguard3.internal.log;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;

public final class pushMinPayload implements log {
    public static char[] addHeader = {'i', 'd', 't', 's', ':', 'j', 'k', 'l', 'm'};
    public static int method = 1;
    public static int newBuilder;
    public static char url = 3;
    public String AGRequest;
    public volatile boolean AGRequest$Builder;
    public log.getBody getBody;
    public int getHeaders;
    public RB<Pair<String, Number>> getMethod;
    public long getUrl;

    static {
        Covode.recordClassIndex(2466);
    }

    public pushMinPayload() {
        this((byte) 0);
    }

    public final String AGRequest() {
        int i = method + 97;
        int i2 = i % 128;
        newBuilder = i2;
        int i3 = i % 2;
        String str = this.AGRequest;
        int i4 = i2 + 21;
        method = i4 % 128;
        int i5 = i4 % 2;
        return str;
    }

    public final void getBody() {
        boolean z;
        int i = method + 105;
        newBuilder = i % 128;
        if (i % 2 == 0) {
            z = false;
        } else {
            z = true;
        }
        this.AGRequest$Builder = z;
        int i2 = newBuilder + 113;
        method = i2 % 128;
        int i3 = i2 % 2;
    }

    public final void getHeaders() {
        int i = method + 81;
        newBuilder = i % 128;
        int i2 = i % 2;
        this.AGRequest$Builder = true;
        int i3 = method + 77;
        newBuilder = i3 % 128;
        int i4 = i3 % 2;
    }

    public final int getMethod() {
        int i = method + 121;
        newBuilder = i % 128;
        if (i % 2 == 0) {
            return this.getHeaders;
        }
        return this.getHeaders;
    }

    public final long url() {
        int i = newBuilder + 91;
        int i2 = i % 128;
        method = i2;
        int i3 = i % 2;
        long j = this.getUrl;
        int i4 = i2 + 71;
        newBuilder = i4 % 128;
        int i5 = i4 % 2;
        return j;
    }

    public final String getUrl() {
        JSONArray jSONArray = new JSONArray();
        Iterator<Pair<String, Number>> it = AGRequest(false).iterator();
        int i = newBuilder + 113;
        method = i % 128;
        while (true) {
            int i2 = i % 2;
            if (!it.hasNext()) {
                return jSONArray.toString();
            }
            Pair next = it.next();
            JSONObject jSONObject = new JSONObject();
            jSONObject.put(getMethod("\u0001\u0002", (byte) (((Process.getThreadPriority(0) + 20) >> 6) + 51), (ViewConfiguration.getJumpTapTimeout() >> 16) + 2).intern(), next.first);
            jSONObject.put(getMethod("\u0000\u0005", (byte) ((ViewConfiguration.getMinimumFlingVelocity() >> 16) + 35), TextUtils.indexOf("", "", 0) + 2).intern(), next.second);
            jSONArray.put(jSONObject);
            i = newBuilder + 123;
            method = i % 128;
        }
    }

    public final void getUrl(log.getBody getbody) {
        int i = newBuilder + 113;
        int i2 = i % 128;
        method = i2;
        int i3 = i % 2;
        this.getBody = getbody;
        int i4 = i2 + 67;
        newBuilder = i4 % 128;
        int i5 = i4 % 2;
    }

    public pushMinPayload(byte b) {
        this.AGRequest = getState.getHeaders.getHeaders.AGRequest();
        this.getHeaders = 0;
        this.getUrl = 0;
        this.getBody = log.getBody.getHeaders;
        this.AGRequest$Builder = false;
        this.getMethod = new RB<>(20);
        this.getBody = log.getBody.getHeaders;
    }

    public final void getHeaders(APIGuard$Callback aPIGuard$Callback) {
        if (!this.AGRequest$Builder) {
            int i = method + 111;
            newBuilder = i % 128;
            int i2 = i % 2;
            if (aPIGuard$Callback.getMethod.compareTo(this.getBody) <= 0) {
                getBody(aPIGuard$Callback.AGRequest, aPIGuard$Callback.getBody, aPIGuard$Callback.getUrl);
                int i3 = newBuilder + 95;
                method = i3 % 128;
                int i4 = i3 % 2;
            }
        }
    }

    public final synchronized List<Pair<String, Number>> AGRequest(boolean z) {
        boolean z2;
        RB<Pair<String, Number>> rb;
        MethodCollector.i(16552);
        List<Pair<String, Number>> url2 = this.getMethod.getUrl();
        Collections.reverse(url2);
        boolean z3 = false;
        if (z) {
            int i = method + 121;
            newBuilder = i % 128;
            if (i % 2 == 0) {
                z2 = true;
            } else {
                z2 = false;
            }
            if (!z2) {
                rb = this.getMethod;
            } else {
                rb = this.getMethod;
            }
            rb.getBody();
        }
        int i2 = method + 99;
        newBuilder = i2 % 128;
        if (i2 % 2 != 0) {
            z3 = true;
        }
        if (!z3) {
            MethodCollector.o(16552);
            return url2;
        }
        MethodCollector.o(16552);
        return url2;
    }

    private synchronized void getBody(String str, String str2, long j) {
        String str3;
        int i;
        MethodCollector.i(16709);
        StringBuilder sb = new StringBuilder();
        if (str2 == null) {
            str3 = "";
        } else {
            int i2 = method + 43;
            newBuilder = i2 % 128;
            int i3 = i2 % 2;
            str3 = str2;
        }
        String str4 = "";
        if (!TextUtils.isEmpty(str)) {
            if (this.getBody.compareTo(log.getBody.getUrl) < 0) {
                i = 100;
            } else {
                int i4 = method + 109;
                newBuilder = i4 % 128;
                int i5 = i4 % 2;
                i = 300;
            }
            if (str.length() > i) {
                str = str.substring(str.length() - i);
                int i6 = newBuilder + 81;
                method = i6 % 128;
                int i7 = i6 % 2;
            }
            str4 = str;
        }
        String str5 = "";
        if (!TextUtils.isEmpty(str4) && !TextUtils.isEmpty(str3)) {
            str5 = getMethod("", (byte) (205 - PhoneNumberUtils.toaFromString("")), (SystemClock.uptimeMillis() > 0 ? 1 : (SystemClock.uptimeMillis() == 0 ? 0 : -1))).intern();
        }
        sb.append(str3);
        sb.append(str5);
        sb.append(str4);
        String obj = sb.toString();
        if (TextUtils.isEmpty(obj)) {
            MethodCollector.o(16709);
            return;
        }
        this.getMethod.getHeaders(new Pair(obj, Long.valueOf(j)));
        if (!str2.equals(this.AGRequest)) {
            this.getHeaders = 1;
            this.AGRequest = str2;
        } else {
            this.getHeaders++;
            int i8 = newBuilder + 11;
            method = i8 % 128;
            int i9 = i8 % 2;
        }
        this.getUrl = j;
        MethodCollector.o(16709);
    }

    /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r11v1, resolved type: java.lang.String} */
    /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r11v3, resolved type: char[]} */
    /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r11v4, resolved type: java.lang.String} */
    /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r11v5, resolved type: java.lang.String} */
    /* JADX WARNING: Code restructure failed: missing block: B:33:0x00e3, code lost:
        throw new java.lang.NullPointerException("hashCode");
     */
    /* JADX WARNING: Multi-variable type inference failed */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static java.lang.String getMethod(java.lang.String r11, byte r12, int r13) {
        /*
            int r0 = newBuilder
            int r1 = r0 + 125
            int r0 = r1 % 128
            method = r0
            int r0 = r1 % 2
            r4 = 0
            r5 = 1
            if (r0 == 0) goto L_0x00db
            if (r11 == 0) goto L_0x001e
            char[] r11 = r11.toCharArray()
            int r0 = newBuilder
            int r1 = r0 + 33
            int r0 = r1 % 128
            method = r0
            int r0 = r1 % 2
        L_0x001e:
            char[] r11 = (char[]) r11
            char[] r10 = addHeader
            char r3 = url
            char[] r2 = new char[r13]
            int r0 = r13 % 2
            if (r0 != 0) goto L_0x00c1
        L_0x002a:
            if (r13 <= r5) goto L_0x00d5
        L_0x002c:
            if (r4 >= r13) goto L_0x00d5
            char r6 = r11[r4]
            int r9 = r4 + 1
            char r5 = r11[r9]
            if (r6 == r5) goto L_0x0098
            int r8 = com.apiguard3.internal.setNextClusterForwardId.AGRequest(r6, r3)
            int r7 = com.apiguard3.internal.setNextClusterForwardId.getBody(r6, r3)
            int r6 = com.apiguard3.internal.setNextClusterForwardId.AGRequest(r5, r3)
            int r5 = com.apiguard3.internal.setNextClusterForwardId.getBody(r5, r3)
            r1 = 25
            if (r7 == r5) goto L_0x0095
            r0 = 59
        L_0x004c:
            if (r0 == r1) goto L_0x007c
            if (r8 != r6) goto L_0x006b
            int r0 = com.apiguard3.internal.setNextClusterForwardId.getHeaders(r7, r3)
            int r1 = com.apiguard3.internal.setNextClusterForwardId.getHeaders(r5, r3)
            int r0 = com.apiguard3.internal.setNextClusterForwardId.getBody(r8, r0, r3)
            int r1 = com.apiguard3.internal.setNextClusterForwardId.getBody(r6, r1, r3)
            char r0 = r10[r0]
            r2[r4] = r0
            char r0 = r10[r1]
            r2[r9] = r0
        L_0x0068:
            int r4 = r4 + 2
            goto L_0x002c
        L_0x006b:
            int r0 = com.apiguard3.internal.setNextClusterForwardId.getBody(r8, r5, r3)
            int r1 = com.apiguard3.internal.setNextClusterForwardId.getBody(r6, r7, r3)
            char r0 = r10[r0]
            r2[r4] = r0
            char r0 = r10[r1]
            r2[r9] = r0
            goto L_0x0068
        L_0x007c:
            int r0 = com.apiguard3.internal.setNextClusterForwardId.getHeaders(r8, r3)
            int r1 = com.apiguard3.internal.setNextClusterForwardId.getHeaders(r6, r3)
            int r0 = com.apiguard3.internal.setNextClusterForwardId.getBody(r0, r7, r3)
            int r1 = com.apiguard3.internal.setNextClusterForwardId.getBody(r1, r5, r3)
            char r0 = r10[r0]
            r2[r4] = r0
            char r0 = r10[r1]
            r2[r9] = r0
            goto L_0x0068
        L_0x0095:
            r0 = 25
            goto L_0x004c
        L_0x0098:
            int r0 = method
            int r1 = r0 + 31
            int r0 = r1 % 128
            newBuilder = r0
            int r0 = r1 % 2
            r1 = 50
            if (r0 != 0) goto L_0x00b5
            r0 = 50
        L_0x00a8:
            if (r0 == r1) goto L_0x00b8
            int r6 = r6 << r12
            char r0 = (char) r6
            r2[r4] = r0
            int r1 = r4 >>> 1
            int r5 = r5 / r12
            char r0 = (char) r5
            r2[r1] = r0
            goto L_0x0068
        L_0x00b5:
            r0 = 17
            goto L_0x00a8
        L_0x00b8:
            int r6 = r6 - r12
            char r0 = (char) r6
            r2[r4] = r0
            int r5 = r5 - r12
            char r0 = (char) r5
            r2[r9] = r0
            goto L_0x0068
        L_0x00c1:
            int r0 = newBuilder
            int r1 = r0 + 5
            int r0 = r1 % 128
            method = r0
            int r0 = r1 % 2
            int r13 = r13 + -1
            char r0 = r11[r13]
            int r0 = r0 - r12
            char r0 = (char) r0
            r2[r13] = r0
            goto L_0x002a
        L_0x00d5:
            java.lang.String r0 = new java.lang.String
            r0.<init>(r2)
            return r0
        L_0x00db:
            r0 = 0
            java.lang.String r1 = "hashCode"
            java.lang.NullPointerException r0 = new java.lang.NullPointerException     // Catch:{ all -> 0x00e4 }
            r0.<init>(r1)     // Catch:{ all -> 0x00e4 }
            throw r0     // Catch:{ all -> 0x00e4 }
        L_0x00e4:
            r0 = move-exception
            throw r0
        */
        throw new UnsupportedOperationException("Method not decompiled: com.apiguard3.internal.pushMinPayload.getMethod(java.lang.String, byte, int):java.lang.String");
    }
}
