package com.dss.ups.sp51a.ble.utils;

import g.h.a.i;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import kotlin.Metadata;
import kotlin.collections.j;
import kotlin.jvm.internal.o;
import kotlin.reflect.w.internal.y0.n.c2.c;

/* JADX INFO: loaded from: classes.dex */
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000.\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0010\u0012\n\u0000\n\u0002\u0010\b\n\u0002\b\u0004\n\u0002\u0010\u0005\n\u0002\b\u0003\n\u0002\u0010 \n\u0002\b\u0004\n\u0002\u0010\u000e\n\u0002\b\u0006\bÆ\u0002\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0016\u0010\u0017J\u001d\u0010\u0006\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0005\u001a\u00020\u0004¢\u0006\u0004\b\u0006\u0010\u0007J\u001d\u0010\b\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0005\u001a\u00020\u0004¢\u0006\u0004\b\b\u0010\u0007J\u0015\u0010\u000b\u001a\u00020\u00042\u0006\u0010\n\u001a\u00020\t¢\u0006\u0004\b\u000b\u0010\fJ\u001b\u0010\u000e\u001a\b\u0012\u0004\u0012\u00020\u00040\r2\u0006\u0010\u0003\u001a\u00020\u0002¢\u0006\u0004\b\u000e\u0010\u000fJ\u001b\u0010\u0010\u001a\u00020\u00022\f\u0010\u0003\u001a\b\u0012\u0004\u0012\u00020\u00040\r¢\u0006\u0004\b\u0010\u0010\u0011J\u0015\u0010\u0014\u001a\u00020\u00042\u0006\u0010\u0013\u001a\u00020\u0012¢\u0006\u0004\b\u0014\u0010\u0015¨\u0006\u0018"}, d2 = {"Lcom/dss/ups/sp51a/ble/utils/BitUtils;", "", "", "bytes", "", "offset", "readU16", "([BI)I", "readU8", "", "byte", "byteToInt", "(B)I", "", "byteArrayToIntList", "([B)Ljava/util/List;", "intListToByteArray", "(Ljava/util/List;)[B", "", "uuid", "shortIdFromUuid", "(Ljava/lang/String;)I", "<init>", "()V", "lib_release"}, k = 1, mv = {1, 5, 1})
public final class BitUtils {
    public static final BitUtils INSTANCE = new BitUtils();

    private BitUtils() {
    }

    public final List<Integer> byteArrayToIntList(byte[] bytes) {
        o.f(bytes, "bytes");
        ArrayList arrayList = new ArrayList(bytes.length);
        for (byte b2 : bytes) {
            arrayList.add(Integer.valueOf(INSTANCE.byteToInt(b2)));
        }
        return j.i0(arrayList);
    }

    public final int byteToInt(byte b2) {
        return b2 < 0 ? b2 + 256 : b2;
    }

    public final byte[] intListToByteArray(List<Integer> bytes) {
        o.f(bytes, "bytes");
        ArrayList arrayList = new ArrayList(i.H(bytes, 10));
        Iterator<T> it = bytes.iterator();
        while (it.hasNext()) {
            arrayList.add(Byte.valueOf((byte) ((Number) it.next()).intValue()));
        }
        return j.f0(arrayList);
    }

    public final int readU16(byte[] bytes, int offset) {
        o.f(bytes, "bytes");
        return readU8(bytes, offset + 1) | (readU8(bytes, offset) << 8);
    }

    public final int readU8(byte[] bytes, int offset) {
        o.f(bytes, "bytes");
        return byteToInt(bytes[offset]);
    }

    public final int shortIdFromUuid(String uuid) {
        o.f(uuid, "uuid");
        String str = (String) kotlin.text.j.G(uuid, new String[]{"-"}, false, 0, 6).get(0);
        c.r(16);
        return Integer.parseInt(str, 16);
    }
}
