package androidx.compose.foundation.lazy.grid; import androidx.compose.foundation.layout.Arrangement; import androidx.compose.ui.unit.Constraints; import androidx.compose.ui.unit.Density; import androidx.compose.ui.unit.LayoutDirection; import java.util.ArrayList; import java.util.List; import kotlin.Metadata; import kotlin.collections.ArraysKt; import kotlin.collections.CollectionsKt; import kotlin.jvm.functions.Function1; import kotlin.ranges.IntRange; import kotlin.ranges.RangesKt; /* compiled from: LazyGridMeasure.kt */ @Metadata(d1 = {"\u0000\u0086\u0001\n\u0000\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010!\n\u0000\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0010\u0007\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\u001aP\u0010\u0000\u001a\b\u0012\u0004\u0012\u00020\u00020\u00012\f\u0010\u0003\u001a\b\u0012\u0004\u0012\u00020\u00040\u00012\u0006\u0010\u0005\u001a\u00020\u00062\u0012\u0010\u0007\u001a\u000e\u0012\u0004\u0012\u00020\u0004\u0012\u0004\u0012\u00020\t0\b2\u0012\u0010\n\u001a\u000e\u0012\u0004\u0012\u00020\u0004\u0012\u0004\u0012\u00020\u000b0\bH\u0083\bø\u0001\u0000\u001a\u008c\u0001\u0010\f\u001a\b\u0012\u0004\u0012\u00020\u00020\r2\f\u0010\u000e\u001a\b\u0012\u0004\u0012\u00020\u000f0\u00012\f\u0010\u0010\u001a\b\u0012\u0004\u0012\u00020\u00020\u00012\f\u0010\u0011\u001a\b\u0012\u0004\u0012\u00020\u00020\u00012\u0006\u0010\u0012\u001a\u00020\u00042\u0006\u0010\u0013\u001a\u00020\u00042\u0006\u0010\u0014\u001a\u00020\u00042\u0006\u0010\u0015\u001a\u00020\u00042\u0006\u0010\u0016\u001a\u00020\u00042\u0006\u0010\u0017\u001a\u00020\u000b2\b\u0010\u0018\u001a\u0004\u0018\u00010\u00192\b\u0010\u001a\u001a\u0004\u0018\u00010\u001b2\u0006\u0010\u001c\u001a\u00020\u000b2\u0006\u0010\u001d\u001a\u00020\u001eH\u0002\u001aè\u0001\u0010\u001f\u001a\u00020 2\u0006\u0010!\u001a\u00020\u00042\u0006\u0010\"\u001a\u00020#2\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010$\u001a\u00020\u00042\u0006\u0010%\u001a\u00020\u00042\u0006\u0010&\u001a\u00020\u00042\u0006\u0010'\u001a\u00020\u00042\u0006\u0010(\u001a\u00020\u00042\u0006\u0010)\u001a\u00020\u00042\u0006\u0010*\u001a\u00020+2\u0006\u0010,\u001a\u00020\t2\u0006\u0010\u0017\u001a\u00020\u000b2\b\u0010\u0018\u001a\u0004\u0018\u00010\u00192\b\u0010\u001a\u001a\u0004\u0018\u00010\u001b2\u0006\u0010\u001c\u001a\u00020\u000b2\u0006\u0010\u001d\u001a\u00020\u001e2\u0006\u0010-\u001a\u00020.2\u0006\u0010/\u001a\u0002002\f\u0010\u0003\u001a\b\u0012\u0004\u0012\u00020\u00040\u00012/\u00101\u001a+\u0012\u0004\u0012\u00020\u0004\u0012\u0004\u0012\u00020\u0004\u0012\u0015\u0012\u0013\u0012\u0004\u0012\u000203\u0012\u0004\u0012\u0002040\b¢\u0006\u0002\b5\u0012\u0004\u0012\u00020602H\u0000ø\u0001\u0001ø\u0001\u0000¢\u0006\u0004\b7\u00108\u0082\u0002\u000b\n\u0002\b\u0019\n\u0005\b¡\u001e0\u0001¨\u00069"}, d2 = {"calculateExtraItems", "", "Landroidx/compose/foundation/lazy/grid/LazyGridMeasuredItem;", "pinnedItems", "", "measuredItemProvider", "Landroidx/compose/foundation/lazy/grid/LazyGridMeasuredItemProvider;", "itemConstraints", "Lkotlin/Function1;", "Landroidx/compose/ui/unit/Constraints;", "filter", "", "calculateItemsOffsets", "", "lines", "Landroidx/compose/foundation/lazy/grid/LazyGridMeasuredLine;", "itemsBefore", "itemsAfter", "layoutWidth", "layoutHeight", "finalMainAxisOffset", "maxOffset", "firstLineScrollOffset", "isVertical", "verticalArrangement", "Landroidx/compose/foundation/layout/Arrangement$Vertical;", "horizontalArrangement", "Landroidx/compose/foundation/layout/Arrangement$Horizontal;", "reverseLayout", "density", "Landroidx/compose/ui/unit/Density;", "measureLazyGrid", "Landroidx/compose/foundation/lazy/grid/LazyGridMeasureResult;", "itemsCount", "measuredLineProvider", "Landroidx/compose/foundation/lazy/grid/LazyGridMeasuredLineProvider;", "mainAxisAvailableSize", "beforeContentPadding", "afterContentPadding", "spaceBetweenLines", "firstVisibleLineIndex", "firstVisibleLineScrollOffset", "scrollToBeConsumed", "", "constraints", "placementAnimator", "Landroidx/compose/foundation/lazy/grid/LazyGridItemPlacementAnimator;", "spanLayoutProvider", "Landroidx/compose/foundation/lazy/grid/LazyGridSpanLayoutProvider;", "layout", "Lkotlin/Function3;", "Landroidx/compose/ui/layout/Placeable$PlacementScope;", "", "Lkotlin/ExtensionFunctionType;", "Landroidx/compose/ui/layout/MeasureResult;", "measureLazyGrid-ZRKPzZ8", "(ILandroidx/compose/foundation/lazy/grid/LazyGridMeasuredLineProvider;Landroidx/compose/foundation/lazy/grid/LazyGridMeasuredItemProvider;IIIIIIFJZLandroidx/compose/foundation/layout/Arrangement$Vertical;Landroidx/compose/foundation/layout/Arrangement$Horizontal;ZLandroidx/compose/ui/unit/Density;Landroidx/compose/foundation/lazy/grid/LazyGridItemPlacementAnimator;Landroidx/compose/foundation/lazy/grid/LazyGridSpanLayoutProvider;Ljava/util/List;Lkotlin/jvm/functions/Function3;)Landroidx/compose/foundation/lazy/grid/LazyGridMeasureResult;", "foundation_release"}, k = 2, mv = {1, 8, 0}, xi = 48) /* loaded from: classes.dex */ public final class LazyGridMeasureKt { private static final int calculateItemsOffsets$reverseAware(int i, boolean z, int i2) { return !z ? i : (i2 - i) - 1; } /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Removed duplicated region for block: B:149:0x03d0 */ /* JADX WARN: Removed duplicated region for block: B:53:0x019b */ /* renamed from: measureLazyGrid-ZRKPzZ8, reason: not valid java name */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public static final androidx.compose.foundation.lazy.grid.LazyGridMeasureResult m625measureLazyGridZRKPzZ8(int r36, androidx.compose.foundation.lazy.grid.LazyGridMeasuredLineProvider r37, androidx.compose.foundation.lazy.grid.LazyGridMeasuredItemProvider r38, int r39, int r40, int r41, int r42, int r43, int r44, float r45, long r46, boolean r48, androidx.compose.foundation.layout.Arrangement.Vertical r49, androidx.compose.foundation.layout.Arrangement.Horizontal r50, boolean r51, androidx.compose.ui.unit.Density r52, androidx.compose.foundation.lazy.grid.LazyGridItemPlacementAnimator r53, androidx.compose.foundation.lazy.grid.LazyGridSpanLayoutProvider r54, java.util.List r55, kotlin.jvm.functions.Function3, ? extends androidx.compose.ui.layout.MeasureResult> r56) { /* Method dump skipped, instructions count: 1006 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: androidx.compose.foundation.lazy.grid.LazyGridMeasureKt.m625measureLazyGridZRKPzZ8(int, androidx.compose.foundation.lazy.grid.LazyGridMeasuredLineProvider, androidx.compose.foundation.lazy.grid.LazyGridMeasuredItemProvider, int, int, int, int, int, int, float, long, boolean, androidx.compose.foundation.layout.Arrangement$Vertical, androidx.compose.foundation.layout.Arrangement$Horizontal, boolean, androidx.compose.ui.unit.Density, androidx.compose.foundation.lazy.grid.LazyGridItemPlacementAnimator, androidx.compose.foundation.lazy.grid.LazyGridSpanLayoutProvider, java.util.List, kotlin.jvm.functions.Function3):androidx.compose.foundation.lazy.grid.LazyGridMeasureResult"); } private static final List calculateItemsOffsets(List list, List list2, List list3, int i, int i2, int i3, int i4, int i5, boolean z, Arrangement.Vertical vertical, Arrangement.Horizontal horizontal, boolean z2, Density density) { int i6 = z ? i2 : i; boolean z3 = i3 < Math.min(i6, i4); if (z3 && i5 != 0) { throw new IllegalStateException("Check failed.".toString()); } int size = list.size(); int i7 = 0; for (int i8 = 0; i8 < size; i8++) { i7 += list.get(i8).getItems().length; } ArrayList arrayList = new ArrayList(i7); if (z3) { if (!list2.isEmpty() || !list3.isEmpty()) { throw new IllegalArgumentException("Failed requirement.".toString()); } int size2 = list.size(); int[] iArr = new int[size2]; for (int i9 = 0; i9 < size2; i9++) { iArr[i9] = list.get(calculateItemsOffsets$reverseAware(i9, z2, size2)).getMainAxisSize(); } int[] iArr2 = new int[size2]; for (int i10 = 0; i10 < size2; i10++) { iArr2[i10] = 0; } if (z) { if (vertical == null) { throw new IllegalArgumentException("Required value was null.".toString()); } vertical.arrange(density, i6, iArr, iArr2); } else { if (horizontal == null) { throw new IllegalArgumentException("Required value was null.".toString()); } horizontal.arrange(density, i6, iArr, LayoutDirection.Ltr, iArr2); } IntRange indices = ArraysKt.getIndices(iArr2); if (z2) { indices = RangesKt.reversed(indices); } int first = indices.getFirst(); int last = indices.getLast(); int step = indices.getStep(); if ((step > 0 && first <= last) || (step < 0 && last <= first)) { while (true) { int i11 = iArr2[first]; LazyGridMeasuredLine lazyGridMeasuredLine = list.get(calculateItemsOffsets$reverseAware(first, z2, size2)); if (z2) { i11 = (i6 - i11) - lazyGridMeasuredLine.getMainAxisSize(); } CollectionsKt.addAll(arrayList, lazyGridMeasuredLine.position(i11, i, i2)); if (first == last) { break; } first += step; } } } else { int size3 = list2.size(); int i12 = i5; int i13 = 0; while (i13 < size3) { LazyGridMeasuredItem lazyGridMeasuredItem = list2.get(i13); int mainAxisSizeWithSpacings = i12 - lazyGridMeasuredItem.getMainAxisSizeWithSpacings(); lazyGridMeasuredItem.position(mainAxisSizeWithSpacings, 0, i, i2, (r16 & 16) != 0 ? -1 : 0, (r16 & 32) != 0 ? -1 : 0); arrayList.add(lazyGridMeasuredItem); i13++; i12 = mainAxisSizeWithSpacings; } int size4 = list.size(); int i14 = i5; for (int i15 = 0; i15 < size4; i15++) { LazyGridMeasuredLine lazyGridMeasuredLine2 = list.get(i15); CollectionsKt.addAll(arrayList, lazyGridMeasuredLine2.position(i14, i, i2)); i14 += lazyGridMeasuredLine2.getMainAxisSizeWithSpacings(); } int i16 = i14; int i17 = 0; for (int size5 = list3.size(); i17 < size5; size5 = size5) { LazyGridMeasuredItem lazyGridMeasuredItem2 = list3.get(i17); lazyGridMeasuredItem2.position(i16, 0, i, i2, (r16 & 16) != 0 ? -1 : 0, (r16 & 32) != 0 ? -1 : 0); arrayList.add(lazyGridMeasuredItem2); i16 += lazyGridMeasuredItem2.getMainAxisSizeWithSpacings(); i17++; } } return arrayList; } private static final List calculateExtraItems(List list, LazyGridMeasuredItemProvider lazyGridMeasuredItemProvider, Function1 function1, Function1 function12) { int size = list.size(); ArrayList arrayList = null; for (int i = 0; i < size; i++) { int intValue = list.get(i).intValue(); if (function12.invoke(Integer.valueOf(intValue)).booleanValue()) { LazyGridMeasuredItem m628getAndMeasure3p2s80s$default = LazyGridMeasuredItemProvider.m628getAndMeasure3p2s80s$default(lazyGridMeasuredItemProvider, intValue, 0, function1.invoke(Integer.valueOf(intValue)).getValue(), 2, null); if (arrayList == null) { arrayList = new ArrayList(); } arrayList.add(m628getAndMeasure3p2s80s$default); } } return arrayList == null ? CollectionsKt.emptyList() : arrayList; } }