package com.sistemasolton.itranvias;

import kotlin.Metadata;
import kotlin.collections.ArraysKt;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.ranges.RangesKt;
import kotlin.text.StringsKt;
import kotlinx.coroutines.CoroutineDispatcher;
import kotlinx.coroutines.Dispatchers;

/* JADX INFO: compiled from: CardRepositoryImpl.kt */
/* JADX INFO: loaded from: classes2.dex */
@Metadata(d1 = {"\u00000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\u0012\n\u0000\b\u0007\u0018\u00002\u00020\u0001B\u0011\u0012\b\b\u0002\u0010\u0002\u001a\u00020\u0003¢\u0006\u0004\b\u0004\u0010\u0005J\u001e\u0010\u0006\u001a\b\u0012\u0004\u0012\u00020\b0\u00072\u0006\u0010\t\u001a\u00020\nH\u0096@¢\u0006\u0004\b\u000b\u0010\fJ\u0010\u0010\r\u001a\u00020\u000e2\u0006\u0010\u000f\u001a\u00020\u0010H\u0002R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u0011"}, d2 = {"Lcom/sistemasolton/itranvias/CardRepositoryImpl;", "Lcom/sistemasolton/itranvias/CardRepository;", "dispatcher", "Lkotlinx/coroutines/CoroutineDispatcher;", "<init>", "(Lkotlinx/coroutines/CoroutineDispatcher;)V", "getCard", "Lkotlin/Result;", "Lcom/sistemasolton/itranvias/MainActivity$CardData;", "tag", "Landroid/nfc/Tag;", "getCard-gIAlu-s", "(Landroid/nfc/Tag;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "getCardId", "", "transportNetworkResponse", "", "composeApp_release"}, k = 1, mv = {2, 1, 0}, xi = 48)
public final class CardRepositoryImpl implements CardRepository {
    public static final int $stable = 8;
    private final CoroutineDispatcher dispatcher;

    public CardRepositoryImpl() {
        this(null, 1, 0 == true ? 1 : 0);
    }

    public CardRepositoryImpl(CoroutineDispatcher dispatcher) {
        Intrinsics.checkNotNullParameter(dispatcher, "dispatcher");
        this.dispatcher = dispatcher;
    }

    public /* synthetic */ CardRepositoryImpl(CoroutineDispatcher coroutineDispatcher, int i, DefaultConstructorMarker defaultConstructorMarker) {
        this((i & 1) != 0 ? Dispatchers.getIO() : coroutineDispatcher);
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0014  */
    @Override // com.sistemasolton.itranvias.CardRepository
    /* JADX INFO: renamed from: getCard-gIAlu-s */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public java.lang.Object mo7881getCardgIAlus(android.nfc.Tag r6, kotlin.coroutines.Continuation<? super kotlin.Result<com.sistemasolton.itranvias.MainActivity.CardData>> r7) {
        /*
            r5 = this;
            boolean r0 = r7 instanceof com.sistemasolton.itranvias.CardRepositoryImpl$getCard$1
            if (r0 == 0) goto L14
            r0 = r7
            com.sistemasolton.itranvias.CardRepositoryImpl$getCard$1 r0 = (com.sistemasolton.itranvias.CardRepositoryImpl$getCard$1) r0
            int r1 = r0.label
            r2 = -2147483648(0xffffffff80000000, float:-0.0)
            r1 = r1 & r2
            if (r1 == 0) goto L14
            int r7 = r0.label
            int r7 = r7 - r2
            r0.label = r7
            goto L19
        L14:
            com.sistemasolton.itranvias.CardRepositoryImpl$getCard$1 r0 = new com.sistemasolton.itranvias.CardRepositoryImpl$getCard$1
            r0.<init>(r5, r7)
        L19:
            java.lang.Object r7 = r0.result
            java.lang.Object r1 = kotlin.coroutines.intrinsics.IntrinsicsKt.getCOROUTINE_SUSPENDED()
            int r2 = r0.label
            r3 = 1
            if (r2 == 0) goto L32
            if (r2 != r3) goto L2a
            kotlin.ResultKt.throwOnFailure(r7)
            goto L4a
        L2a:
            java.lang.IllegalStateException r6 = new java.lang.IllegalStateException
            java.lang.String r7 = "call to 'resume' before 'invoke' with coroutine"
            r6.<init>(r7)
            throw r6
        L32:
            kotlin.ResultKt.throwOnFailure(r7)
            kotlinx.coroutines.CoroutineDispatcher r7 = r5.dispatcher
            kotlin.coroutines.CoroutineContext r7 = (kotlin.coroutines.CoroutineContext) r7
            com.sistemasolton.itranvias.CardRepositoryImpl$getCard$2 r2 = new com.sistemasolton.itranvias.CardRepositoryImpl$getCard$2
            r4 = 0
            r2.<init>(r6, r5, r4)
            kotlin.jvm.functions.Function2 r2 = (kotlin.jvm.functions.Function2) r2
            r0.label = r3
            java.lang.Object r7 = kotlinx.coroutines.BuildersKt.withContext(r7, r2, r0)
            if (r7 != r1) goto L4a
            return r1
        L4a:
            kotlin.Result r7 = (kotlin.Result) r7
            java.lang.Object r6 = r7.getValue()
            return r6
        */
        throw new UnsupportedOperationException("Method not decompiled: com.sistemasolton.itranvias.CardRepositoryImpl.mo7881getCardgIAlus(android.nfc.Tag, kotlin.coroutines.Continuation):java.lang.Object");
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final String getCardId(byte[] transportNetworkResponse) {
        String str;
        String strPanToIep;
        byte[] bArrSliceArray = ArraysKt.sliceArray(transportNetworkResponse, RangesKt.until(2, transportNetworkResponse.length - 2));
        String strBcdToDecString = CardRepositoryImplKt.bcdToDecString(bArrSliceArray);
        String strSubstring = strBcdToDecString.substring(6, 8);
        Intrinsics.checkNotNullExpressionValue(strSubstring, "substring(...)");
        if (Intrinsics.areEqual(strSubstring, "04") || !StringsKt.startsWith$default(strBcdToDecString, "987020", false, 2, (Object) null)) {
            String strSubstring2 = strBcdToDecString.substring(6, 8);
            Intrinsics.checkNotNullExpressionValue(strSubstring2, "substring(...)");
            str = !Intrinsics.areEqual(strSubstring2, "04") ? "00" : null;
        } else {
            str = "01";
        }
        if (str != null && (strPanToIep = CardRepositoryImplKt.panToIep(bArrSliceArray, str)) != null) {
            strBcdToDecString = strPanToIep;
        }
        return CardRepositoryImplKt.groupEvery$default(CardRepositoryImplKt.maskFirstNChars(strBcdToDecString, 8), 4, null, 2, null);
    }
}