LINE.apk(点击下载) / x1.java


package q3;

import dm3.l;
import dm3.p;
import em3.q;
import em3.s;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CopyOnWriteArrayList;
import km3.f;
import kotlin.NoWhenBranchMatchedException;
import kotlin.ResultKt;
import kotlin.Unit;
import q3.b;
import q3.f0;
import q3.i0;
import q3.n1;
import q3.t0;
import q3.v2;
import ul3.d;
import um3.c0;
import um3.h0;
import wl3.e;
import wl3.i;
import xm3.g;
import xm3.h;
import xm3.i1;
import xm3.p1;

public abstract class x1<T> {

    /* renamed from: a  reason: collision with root package name */
    public final r f130707a;

    /* renamed from: b  reason: collision with root package name */
    public final c0 f130708b;

    /* renamed from: c  reason: collision with root package name */
    public n1<T> f130709c = ((n1<T>) n1.f130488f);

    /* renamed from: d  reason: collision with root package name */
    public t2 f130710d;

    /* renamed from: e  reason: collision with root package name */
    public final n0 f130711e;

    /* renamed from: f  reason: collision with root package name */
    public final CopyOnWriteArrayList<dm3.a<Unit>> f130712f;

    /* renamed from: g  reason: collision with root package name */
    public final n2 f130713g;

    /* renamed from: h  reason: collision with root package name */
    public volatile boolean f130714h;

    /* renamed from: i  reason: collision with root package name */
    public volatile int f130715i;

    /* renamed from: j  reason: collision with root package name */
    public final c f130716j;

    /* renamed from: k  reason: collision with root package name */
    public final g<n> f130717k;

    /* renamed from: l  reason: collision with root package name */
    public final i1<Unit> f130718l;

    public static final class a extends s implements dm3.a<Unit> {

        /* renamed from: b  reason: collision with root package name */
        public final /* synthetic */ x1<T> f130719b;

        /* JADX INFO: super call moved to the top of the method (can break code semantics) */
        public a(x1<T> x1Var) {
            super(0);
            this.f130719b = x1Var;
        }

        /* Return type fixed from 'java.lang.Object' to match base method */
        @Override // dm3.a
        public Unit invoke() {
            i1<Unit> i1Var = this.f130719b.f130718l;
            Unit unit = Unit.INSTANCE;
            i1Var.d(unit);
            return unit;
        }
    }

    @e(c = "androidx.paging.PagingDataDiffer$collectFrom$2", f = "PagingDataDiffer.kt", l = {467}, m = "invokeSuspend")
    public static final class b extends i implements l<d<? super Unit>, Object> {

        /* renamed from: b  reason: collision with root package name */
        public int f130720b;

        /* renamed from: c  reason: collision with root package name */
        public final /* synthetic */ x1<T> f130721c;

        /* renamed from: d  reason: collision with root package name */
        public final /* synthetic */ s1<T> f130722d;

        @e(c = "androidx.paging.PagingDataDiffer$collectFrom$2$1$1", f = "PagingDataDiffer.kt", l = {151, 193}, m = "invokeSuspend")
        public static final class a extends i implements p<h0, d<? super Unit>, Object> {

            /* renamed from: b  reason: collision with root package name */
            public Object f130723b;

            /* renamed from: c  reason: collision with root package name */
            public Object f130724c;

            /* renamed from: d  reason: collision with root package name */
            public int f130725d;

            /* renamed from: e  reason: collision with root package name */
            public final /* synthetic */ t0<T> f130726e;

            /* renamed from: f  reason: collision with root package name */
            public final /* synthetic */ x1<T> f130727f;

            /* renamed from: q3.x1$b$a$a  reason: collision with other inner class name */
            public static final class C2415a extends s implements dm3.a<Unit> {

                /* renamed from: b  reason: collision with root package name */
                public final /* synthetic */ x1<T> f130728b;

                /* renamed from: c  reason: collision with root package name */
                public final /* synthetic */ n1<T> f130729c;

                /* renamed from: d  reason: collision with root package name */
                public final /* synthetic */ em3.h0 f130730d;

                /* JADX INFO: super call moved to the top of the method (can break code semantics) */
                public C2415a(x1<T> x1Var, n1<T> n1Var, em3.h0 h0Var) {
                    super(0);
                    this.f130728b = x1Var;
                    this.f130729c = n1Var;
                    this.f130730d = h0Var;
                }

                /* Return type fixed from 'java.lang.Object' to match base method */
                @Override // dm3.a
                public Unit invoke() {
                    this.f130728b.f130709c = this.f130729c;
                    this.f130730d.f68709b = true;
                    return Unit.INSTANCE;
                }
            }

            /* JADX INFO: super call moved to the top of the method (can break code semantics) */
            public a(t0<T> t0Var, x1<T> x1Var, d<? super a> dVar) {
                super(2, dVar);
                this.f130726e = t0Var;
                this.f130727f = x1Var;
            }

            @Override // wl3.a
            public final d<Unit> create(Object obj, d<?> dVar) {
                return new a(this.f130726e, this.f130727f, dVar);
            }

            /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object, java.lang.Object] */
            @Override // dm3.p
            public Object invoke(h0 h0Var, d<? super Unit> dVar) {
                return new a(this.f130726e, this.f130727f, dVar).invokeSuspend(Unit.INSTANCE);
            }

            /* JADX WARNING: Removed duplicated region for block: B:128:0x02f9 A[LOOP:1: B:126:0x02f3->B:128:0x02f9, LOOP_END] */
            /* JADX WARNING: Removed duplicated region for block: B:35:0x00f1  */
            /* JADX WARNING: Removed duplicated region for block: B:53:0x0197  */
            /* JADX WARNING: Removed duplicated region for block: B:83:0x0241  */
            /* JADX WARNING: Removed duplicated region for block: B:86:0x024b  */
            @Override // wl3.a
            public final Object invokeSuspend(Object obj) {
                Iterator<T> it3;
                t0<T> t0Var;
                t0<T> t0Var2;
                boolean z14;
                n1 n1Var;
                em3.h0 h0Var;
                vl3.a aVar = vl3.a.COROUTINE_SUSPENDED;
                int i14 = this.f130725d;
                boolean z15 = true;
                if (i14 == 0) {
                    ResultKt.throwOnFailure(obj);
                    t0<T> t0Var3 = this.f130726e;
                    if (!(t0Var3 instanceof t0.b) || ((t0.b) t0Var3).f130584a != j0.REFRESH) {
                        if (((b.a) this.f130727f).f130151m.f130146e) {
                            this.f130725d = 2;
                            if (z2.e.h(this) == aVar) {
                                return aVar;
                            }
                        }
                        x1<T> x1Var = this.f130727f;
                        n1<T> n1Var2 = x1Var.f130709c;
                        t0Var = this.f130726e;
                        c cVar = x1Var.f130716j;
                        Objects.requireNonNull(n1Var2);
                        q.f(t0Var, "pageEvent");
                        q.f(cVar, "callback");
                        if (!(t0Var instanceof t0.b)) {
                        }
                        if (this.f130726e instanceof t0.a) {
                        }
                        t0Var2 = this.f130726e;
                        if (t0Var2 instanceof t0.b) {
                        }
                        t0<T> t0Var4 = this.f130726e;
                        it3 = this.f130727f.f130712f.iterator();
                        while (it3.hasNext()) {
                        }
                        return Unit.INSTANCE;
                    }
                    this.f130727f.f130714h = false;
                    n1Var = new n1((t0.b) this.f130726e);
                    em3.h0 h0Var2 = new em3.h0();
                    x1<T> x1Var2 = this.f130727f;
                    n1<T> n1Var3 = x1Var2.f130709c;
                    int i15 = x1Var2.f130715i;
                    C2415a aVar2 = new C2415a(this.f130727f, n1Var, h0Var2);
                    this.f130723b = n1Var;
                    this.f130724c = h0Var2;
                    this.f130725d = 1;
                    Object c14 = x1Var2.c(n1Var3, n1Var, i15, aVar2, this);
                    if (c14 == aVar) {
                        return aVar;
                    }
                    h0Var = h0Var2;
                    obj = c14;
                } else if (i14 == 1) {
                    h0Var = (em3.h0) this.f130724c;
                    n1Var = (n1) this.f130723b;
                    ResultKt.throwOnFailure(obj);
                } else if (i14 == 2) {
                    ResultKt.throwOnFailure(obj);
                    x1<T> x1Var3 = this.f130727f;
                    n1<T> n1Var22 = x1Var3.f130709c;
                    t0Var = this.f130726e;
                    c cVar2 = x1Var3.f130716j;
                    Objects.requireNonNull(n1Var22);
                    q.f(t0Var, "pageEvent");
                    q.f(cVar2, "callback");
                    if (!(t0Var instanceof t0.b)) {
                        t0.b bVar = (t0.b) t0Var;
                        int g14 = n1Var22.g(bVar.f130585b);
                        int size = n1Var22.getSize();
                        int i16 = n1.c.$EnumSwitchMapping$0[bVar.f130584a.ordinal()];
                        if (i16 != 1) {
                            if (i16 == 2) {
                                int min = Math.min(n1Var22.f130491c, g14);
                                int i17 = g14 - min;
                                n1Var22.f130489a.addAll(0, bVar.f130585b);
                                n1Var22.f130490b += g14;
                                n1Var22.f130491c = bVar.f130586c;
                                cVar2.c(n1Var22.f130491c - min, min);
                                cVar2.a(0, i17);
                                int size2 = (n1Var22.getSize() - size) - i17;
                                if (size2 > 0) {
                                    cVar2.a(0, size2);
                                } else if (size2 < 0) {
                                    cVar2.b(0, -size2);
                                }
                            } else if (i16 == 3) {
                                int min2 = Math.min(n1Var22.f130492d, g14);
                                int i18 = n1Var22.f130491c + n1Var22.f130490b;
                                int i19 = g14 - min2;
                                List<s2<T>> list = n1Var22.f130489a;
                                list.addAll(list.size(), bVar.f130585b);
                                n1Var22.f130490b += g14;
                                n1Var22.f130492d = bVar.f130587d;
                                cVar2.c(i18, min2);
                                cVar2.a(i18 + min2, i19);
                                int size3 = (n1Var22.getSize() - size) - i19;
                                if (size3 > 0) {
                                    cVar2.a(n1Var22.getSize() - size3, size3);
                                } else if (size3 < 0) {
                                    cVar2.b(n1Var22.getSize(), -size3);
                                }
                            }
                            cVar2.e(bVar.f130588e, bVar.f130589f);
                        } else {
                            throw new IllegalArgumentException();
                        }
                    } else if (t0Var instanceof t0.a) {
                        t0.a aVar3 = (t0.a) t0Var;
                        int size4 = n1Var22.getSize();
                        j0 j0Var = aVar3.f130578a;
                        j0 j0Var2 = j0.PREPEND;
                        if (j0Var == j0Var2) {
                            int i24 = n1Var22.f130491c;
                            n1Var22.f130490b -= n1Var22.f(new f(aVar3.f130579b, aVar3.f130580c));
                            n1Var22.f130491c = aVar3.f130581d;
                            int size5 = n1Var22.getSize() - size4;
                            if (size5 > 0) {
                                cVar2.a(0, size5);
                            } else if (size5 < 0) {
                                cVar2.b(0, -size5);
                            }
                            int max = Math.max(0, i24 + size5);
                            int i25 = aVar3.f130581d - max;
                            if (i25 > 0) {
                                cVar2.c(max, i25);
                            }
                            cVar2.d(j0Var2, false, f0.c.f130306c);
                        } else {
                            int i26 = n1Var22.f130492d;
                            n1Var22.f130490b -= n1Var22.f(new f(aVar3.f130579b, aVar3.f130580c));
                            n1Var22.f130492d = aVar3.f130581d;
                            int size6 = n1Var22.getSize() - size4;
                            if (size6 > 0) {
                                cVar2.a(size4, size6);
                            } else if (size6 < 0) {
                                cVar2.b(size4 + size6, -size6);
                            }
                            int min3 = aVar3.f130581d - (i26 - (size6 < 0 ? Math.min(i26, -size6) : 0));
                            if (min3 > 0) {
                                cVar2.c(n1Var22.getSize() - aVar3.f130581d, min3);
                            }
                            cVar2.d(j0.APPEND, false, f0.c.f130306c);
                        }
                    } else if (t0Var instanceof t0.c) {
                        t0.c cVar3 = (t0.c) t0Var;
                        cVar2.e(cVar3.f130604a, cVar3.f130605b);
                    }
                    if (this.f130726e instanceof t0.a) {
                        this.f130727f.f130714h = false;
                    }
                    t0Var2 = this.f130726e;
                    if (t0Var2 instanceof t0.b) {
                        i0 i0Var = this.f130727f.f130711e.f130483f;
                        boolean z16 = (((t0.b) t0Var2).f130584a != j0.PREPEND || !i0Var.f130394b.f130302a) && (((t0.b) t0Var2).f130584a != j0.APPEND || !i0Var.f130395c.f130302a);
                        List<s2<T>> list2 = ((t0.b) t0Var2).f130585b;
                        if (!(list2 instanceof Collection) || !list2.isEmpty()) {
                            Iterator<T> it4 = list2.iterator();
                            while (true) {
                                if (it4.hasNext()) {
                                    if (!it4.next().f130561b.isEmpty()) {
                                        z14 = false;
                                        break;
                                    }
                                } else {
                                    break;
                                }
                            }
                        }
                        z14 = true;
                        if (!z16) {
                            this.f130727f.f130714h = false;
                        } else if (this.f130727f.f130714h || z14) {
                            if (!z14) {
                                int i27 = this.f130727f.f130715i;
                                x1<T> x1Var4 = this.f130727f;
                                if (i27 >= x1Var4.f130709c.f130491c) {
                                    int i28 = x1Var4.f130715i;
                                    n1<T> n1Var4 = this.f130727f.f130709c;
                                    if (i28 <= n1Var4.f130491c + n1Var4.f130490b) {
                                        z15 = false;
                                    }
                                }
                            }
                            if (z15) {
                                x1<T> x1Var5 = this.f130727f;
                                t2 t2Var = x1Var5.f130710d;
                                if (t2Var != null) {
                                    t2Var.a(x1Var5.f130709c.e(x1Var5.f130715i));
                                }
                            } else {
                                this.f130727f.f130714h = false;
                            }
                        }
                    }
                    t0<T> t0Var42 = this.f130726e;
                    if ((t0Var42 instanceof t0.b) || (t0Var42 instanceof t0.a)) {
                        it3 = this.f130727f.f130712f.iterator();
                        while (it3.hasNext()) {
                            it3.next().invoke();
                        }
                    }
                    return Unit.INSTANCE;
                } else {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                Integer num = (Integer) obj;
                if (h0Var.f68709b) {
                    x1<T> x1Var6 = this.f130727f;
                    t0<T> t0Var5 = this.f130726e;
                    x1Var6.b(((t0.b) t0Var5).f130588e, ((t0.b) t0Var5).f130589f);
                    if (num == null) {
                        t2 t2Var2 = this.f130727f.f130710d;
                        if (t2Var2 != null) {
                            int i29 = n1Var.f130490b / 2;
                            t2Var2.a(new v2.b(i29, i29, n1Var.i(), n1Var.j()));
                        }
                    } else {
                        this.f130727f.f130715i = num.intValue();
                        t2 t2Var3 = this.f130727f.f130710d;
                        if (t2Var3 != null) {
                            t2Var3.a(n1Var.e(num.intValue()));
                        }
                    }
                    t0<T> t0Var422 = this.f130726e;
                    it3 = this.f130727f.f130712f.iterator();
                    while (it3.hasNext()) {
                    }
                    return Unit.INSTANCE;
                }
                throw new IllegalStateException("Missing call to onListPresentable after new list was presented. If you are seeing this exception, it is generally an indication of an issue with Paging. Please file a bug so we can fix it at: https://issuetracker.google.com/issues/new?component=413106".toString());
            }
        }

        /* renamed from: q3.x1$b$b  reason: collision with other inner class name */
        public static final class C2416b implements h<t0<T>> {

            /* renamed from: b  reason: collision with root package name */
            public final /* synthetic */ x1 f130731b;

            public C2416b(x1 x1Var) {
                this.f130731b = x1Var;
            }

            @Override // xm3.h
            public Object a(t0<T> t0Var, d<? super Unit> dVar) {
                x1 x1Var = this.f130731b;
                Object g14 = um3.g.g(x1Var.f130708b, new a(t0Var, x1Var, null), dVar);
                if (g14 == vl3.a.COROUTINE_SUSPENDED) {
                    return g14;
                }
                return Unit.INSTANCE;
            }
        }

        /* JADX INFO: super call moved to the top of the method (can break code semantics) */
        public b(x1<T> x1Var, s1<T> s1Var, d<? super b> dVar) {
            super(1, dVar);
            this.f130721c = x1Var;
            this.f130722d = s1Var;
        }

        @Override // wl3.a
        public final d<Unit> create(d<?> dVar) {
            return new b(this.f130721c, this.f130722d, dVar);
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
        @Override // dm3.l
        public Object invoke(d<? super Unit> dVar) {
            return new b(this.f130721c, this.f130722d, dVar).invokeSuspend(Unit.INSTANCE);
        }

        @Override // wl3.a
        public final Object invokeSuspend(Object obj) {
            vl3.a aVar = vl3.a.COROUTINE_SUSPENDED;
            int i14 = this.f130720b;
            if (i14 == 0) {
                ResultKt.throwOnFailure(obj);
                x1<T> x1Var = this.f130721c;
                s1<T> s1Var = this.f130722d;
                x1Var.f130710d = s1Var.f130557b;
                g<t0<T>> gVar = s1Var.f130556a;
                C2416b bVar = new C2416b(x1Var);
                this.f130720b = 1;
                if (gVar.b(bVar, this) == aVar) {
                    return aVar;
                }
            } else if (i14 == 1) {
                ResultKt.throwOnFailure(obj);
            } else {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            return Unit.INSTANCE;
        }
    }

    public static final class c implements n1.b {

        /* renamed from: a  reason: collision with root package name */
        public final /* synthetic */ x1<T> f130732a;

        public c(x1<T> x1Var) {
            this.f130732a = x1Var;
        }

        @Override // q3.n1.b
        public void a(int i14, int i15) {
            this.f130732a.f130707a.a(i14, i15);
        }

        @Override // q3.n1.b
        public void b(int i14, int i15) {
            this.f130732a.f130707a.b(i14, i15);
        }

        @Override // q3.n1.b
        public void c(int i14, int i15) {
            this.f130732a.f130707a.c(i14, i15);
        }

        @Override // q3.n1.b
        public void d(j0 j0Var, boolean z14, f0 f0Var) {
            f0 f0Var2;
            i0 i0Var;
            q.f(j0Var, "loadType");
            n0 n0Var = this.f130732a.f130711e;
            Objects.requireNonNull(n0Var);
            i0 i0Var2 = z14 ? n0Var.f130484g : n0Var.f130483f;
            if (i0Var2 == null) {
                f0Var2 = null;
            } else {
                int i14 = i0.a.$EnumSwitchMapping$0[j0Var.ordinal()];
                if (i14 == 1) {
                    f0Var2 = i0Var2.f130395c;
                } else if (i14 == 2) {
                    f0Var2 = i0Var2.f130394b;
                } else if (i14 == 3) {
                    f0Var2 = i0Var2.f130393a;
                } else {
                    throw new NoWhenBranchMatchedException();
                }
            }
            if (!q.b(f0Var2, f0Var)) {
                n0 n0Var2 = this.f130732a.f130711e;
                Objects.requireNonNull(n0Var2);
                n0Var2.f130478a = true;
                if (z14) {
                    i0 i0Var3 = n0Var2.f130484g;
                    if (i0Var3 == null) {
                        i0 i0Var4 = i0.f130391d;
                        i0Var = i0.f130392e;
                    } else {
                        i0Var = i0Var3;
                    }
                    i0 b14 = i0Var.b(j0Var, f0Var);
                    n0Var2.f130484g = b14;
                    q.b(b14, i0Var3);
                } else {
                    i0 i0Var5 = n0Var2.f130483f;
                    i0 b15 = i0Var5.b(j0Var, f0Var);
                    n0Var2.f130483f = b15;
                    q.b(b15, i0Var5);
                }
                n0Var2.c();
            }
        }

        @Override // q3.n1.b
        public void e(i0 i0Var, i0 i0Var2) {
            q.f(i0Var, "source");
            this.f130732a.b(i0Var, i0Var2);
        }
    }

    public x1(r rVar, c0 c0Var) {
        q.f(rVar, "differCallback");
        q.f(c0Var, "mainDispatcher");
        this.f130707a = rVar;
        this.f130708b = c0Var;
        n1.a aVar = n1.f130487e;
        n0 n0Var = new n0();
        this.f130711e = n0Var;
        CopyOnWriteArrayList<dm3.a<Unit>> copyOnWriteArrayList = new CopyOnWriteArrayList<>();
        this.f130712f = copyOnWriteArrayList;
        this.f130713g = new n2(false, 1);
        this.f130716j = new c(this);
        this.f130717k = n0Var.f130486i;
        this.f130718l = p1.a(0, 64, wm3.d.DROP_OLDEST);
        copyOnWriteArrayList.add(new a(this));
    }

    public final Object a(s1<T> s1Var, d<? super Unit> dVar) {
        Object a14 = this.f130713g.a(0, new b(this, s1Var, null), dVar);
        if (a14 == vl3.a.COROUTINE_SUSPENDED) {
            return a14;
        }
        return Unit.INSTANCE;
    }

    public final void b(i0 i0Var, i0 i0Var2) {
        q.f(i0Var, "source");
        if (!q.b(this.f130711e.f130483f, i0Var) || !q.b(this.f130711e.f130484g, i0Var2)) {
            n0 n0Var = this.f130711e;
            Objects.requireNonNull(n0Var);
            n0Var.f130478a = true;
            n0Var.f130483f = i0Var;
            n0Var.f130484g = i0Var2;
            n0Var.c();
        }
    }

    public abstract Object c(q0<T> q0Var, q0<T> q0Var2, int i14, dm3.a<Unit> aVar, d<? super Integer> dVar);
}