package com.seewo.remote.e.c;

import com.cvte.vman.R;
import com.seewo.sdk.model.SDKKeyboardCode;
import e.c.d.f;
import e.c.d.o;
import io.netty.channel.ChannelHandlerContext;
import java.nio.ByteBuffer;

/* JADX INFO: compiled from: ITranslator.java */
/* JADX INFO: loaded from: classes.dex */
public abstract class c {
    private byte[] a(String str) {
        byte[] bArr = new byte[5];
        if (str.length() > 5) {
            return bArr;
        }
        int length = 5 - str.length();
        for (int i2 = 0; i2 < length; i2++) {
            bArr[i2] = 48;
        }
        for (int i3 = 0; i3 < str.length(); i3++) {
            bArr[length + i3] = (byte) str.charAt(i3);
        }
        return bArr;
    }

    private static byte[] e(byte b) {
        int iG = g();
        return new byte[]{b, (byte) ((iG / 10) + 48), (byte) ((iG % 10) + 48)};
    }

    public static int g() {
        int iF = f.a.f();
        if (e.c.e.f.b.f() && com.seewo.remote.d.b.b().a().getResources().getBoolean(R.bool.support_default_id)) {
            if (iF != 0) {
                return iF;
            }
        } else if (!e.c.e.f.b.j() || !com.seewo.remote.d.b.b().a().getResources().getBoolean(R.bool.support_default_id) || iF != 0) {
            return iF;
        }
        return 1;
    }

    public byte[] b(byte[] bArr) {
        byte[] bArr2 = (byte[]) bArr.clone();
        if (bArr2.length != 11) {
            return new byte[0];
        }
        byte[] bArrA = a(o.a.b().split(":")[0]);
        System.arraycopy(bArrA, 0, bArr2, 5, bArrA.length);
        return bArr2;
    }

    protected byte[] c(int i2) {
        int i3 = i2 / 100;
        int i4 = i2 % 100;
        int i5 = i4 / 10;
        int i6 = i4 % 10;
        return (i3 == 0 && i5 == 0) ? new byte[]{(byte) (i6 + 48)} : i3 == 0 ? new byte[]{(byte) (i5 + 48), (byte) (i6 + 48)} : new byte[]{(byte) (i3 + 48), (byte) (i5 + 48), (byte) (i6 + 48)};
    }

    protected byte[] d(int i2) {
        int i3 = i2 / 100;
        int i4 = i2 % 100;
        return new byte[]{(byte) (i3 + 48), (byte) ((i4 / 10) + 48), (byte) ((i4 % 10) + 48)};
    }

    protected int f(byte b, byte b2) {
        int i2 = b - 48;
        int i3 = b2 - 48;
        if (i2 < 0 || i2 > 9 || i3 < 0 || i3 > 9) {
            return -1;
        }
        return (i2 * 10) + i3;
    }

    public int h(byte b) {
        return b - 48;
    }

    public byte[] i(byte[] bArr) {
        byte[] bArr2 = (byte[]) bArr.clone();
        if (bArr2.length != 11) {
            return new byte[0];
        }
        byte[] bArrA = a(o.a.f().split(":")[0]);
        System.arraycopy(bArrA, 0, bArr2, 5, bArrA.length);
        return bArr2;
    }

    public abstract com.seewo.remote.e.f.a j(byte[] bArr);

    public int k(byte b, byte b2) {
        return (h(b) * 10) + h(b2);
    }

    public int l(byte b, byte b2, byte b3) {
        return (h(b) * 100) + k(b2, b3);
    }

    public abstract boolean m(ChannelHandlerContext channelHandlerContext, byte[] bArr);

    protected boolean n(int i2) {
        return i2 <= 99 && i2 >= 1;
    }

    public byte[] o(boolean z) {
        ByteBuffer byteBufferAllocate = ByteBuffer.allocate(5);
        byteBufferAllocate.put(e(SDKKeyboardCode.FUNCTION_KEY_BOARD_SINGLE_QUOTE_MARK));
        byteBufferAllocate.put(z ? SDKKeyboardCode.FUNCTION_KEY_BOARD_TAB : SDKKeyboardCode.FUNCTION_KEY_BOARD_MINUS);
        byteBufferAllocate.put(SDKKeyboardCode.FUNCTION_KEY_BOARD_J);
        return byteBufferAllocate.array();
    }
}
