package androidx.compose.ui.node; import androidx.compose.ui.geometry.Offset; import androidx.compose.ui.geometry.OffsetKt; import androidx.compose.ui.layout.AlignmentLine; import androidx.compose.ui.layout.AlignmentLineKt; import androidx.compose.ui.layout.HorizontalAlignmentLine; import java.util.HashMap; import java.util.Map; import java.util.Set; import kotlin.Metadata; import kotlin.Unit; import kotlin.collections.MapsKt; import kotlin.jvm.functions.Function1; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.jvm.internal.Intrinsics; import kotlin.math.MathKt; /* compiled from: LayoutNodeAlignmentLines.kt */ @Metadata(d1 = {"\u0000P\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010%\n\u0002\u0018\u0002\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0010\u000b\n\u0002\b\u0019\n\u0002\u0010$\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0002\b\n\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\b0\u0018\u00002\u00020\u0001B\u000f\b\u0004\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J \u0010*\u001a\u00020+2\u0006\u0010,\u001a\u00020\u00072\u0006\u0010-\u001a\u00020\b2\u0006\u0010.\u001a\u00020'H\u0002J\u0012\u0010/\u001a\u000e\u0012\u0004\u0012\u00020\u0007\u0012\u0004\u0012\u00020\b0&J\u0006\u00100\u001a\u00020+J\u0006\u00101\u001a\u00020+J\u0006\u00102\u001a\u00020+J\r\u00103\u001a\u00020+H\u0000¢\u0006\u0002\b4J!\u00105\u001a\u000206*\u00020'2\u0006\u00107\u001a\u000206H$ø\u0001\u0000ø\u0001\u0001¢\u0006\u0004\b8\u00109J\u0014\u0010:\u001a\u00020\b*\u00020'2\u0006\u0010,\u001a\u00020\u0007H$R\u001a\u0010\u0005\u001a\u000e\u0012\u0004\u0012\u00020\u0007\u0012\u0004\u0012\u00020\b0\u0006X\u0082\u0004¢\u0006\u0002\n\u0000R\u0011\u0010\u0002\u001a\u00020\u0003¢\u0006\b\n\u0000\u001a\u0004\b\t\u0010\nR\u001a\u0010\u000b\u001a\u00020\fX\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\r\u0010\u000e\"\u0004\b\u000f\u0010\u0010R\u001a\u0010\u0011\u001a\u00020\fX\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0012\u0010\u000e\"\u0004\b\u0013\u0010\u0010R\u0014\u0010\u0014\u001a\u00020\f8@X\u0080\u0004¢\u0006\u0006\u001a\u0004\b\u0015\u0010\u000eR\u0010\u0010\u0016\u001a\u0004\u0018\u00010\u0003X\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010\u0017\u001a\u00020\f8@X\u0080\u0004¢\u0006\u0006\u001a\u0004\b\u0018\u0010\u000eR\u001a\u0010\u0019\u001a\u00020\fX\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u001a\u0010\u000e\"\u0004\b\u001b\u0010\u0010R\u001a\u0010\u001c\u001a\u00020\fX\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u001d\u0010\u000e\"\u0004\b\u001e\u0010\u0010R\u001a\u0010\u001f\u001a\u00020\fX\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b \u0010\u000e\"\u0004\b!\u0010\u0010R\u001a\u0010\"\u001a\u00020\fX\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b#\u0010\u000e\"\u0004\b$\u0010\u0010R\"\u0010%\u001a\u000e\u0012\u0004\u0012\u00020\u0007\u0012\u0004\u0012\u00020\b0&*\u00020'X¤\u0004¢\u0006\u0006\u001a\u0004\b(\u0010)\u0082\u0001\u0002;<\u0082\u0002\u000b\n\u0005\b¡\u001e0\u0001\n\u0002\b\u0019¨\u0006="}, d2 = {"Landroidx/compose/ui/node/AlignmentLines;", "", "alignmentLinesOwner", "Landroidx/compose/ui/node/AlignmentLinesOwner;", "(Landroidx/compose/ui/node/AlignmentLinesOwner;)V", "alignmentLineMap", "", "Landroidx/compose/ui/layout/AlignmentLine;", "", "getAlignmentLinesOwner", "()Landroidx/compose/ui/node/AlignmentLinesOwner;", "dirty", "", "getDirty$ui_release", "()Z", "setDirty$ui_release", "(Z)V", "previousUsedDuringParentLayout", "getPreviousUsedDuringParentLayout$ui_release", "setPreviousUsedDuringParentLayout$ui_release", "queried", "getQueried$ui_release", "queryOwner", "required", "getRequired$ui_release", "usedByModifierLayout", "getUsedByModifierLayout$ui_release", "setUsedByModifierLayout$ui_release", "usedByModifierMeasurement", "getUsedByModifierMeasurement$ui_release", "setUsedByModifierMeasurement$ui_release", "usedDuringParentLayout", "getUsedDuringParentLayout$ui_release", "setUsedDuringParentLayout$ui_release", "usedDuringParentMeasurement", "getUsedDuringParentMeasurement$ui_release", "setUsedDuringParentMeasurement$ui_release", "alignmentLinesMap", "", "Landroidx/compose/ui/node/NodeCoordinator;", "getAlignmentLinesMap", "(Landroidx/compose/ui/node/NodeCoordinator;)Ljava/util/Map;", "addAlignmentLine", "", "alignmentLine", "initialPosition", "initialCoordinator", "getLastCalculation", "onAlignmentsChanged", "recalculate", "recalculateQueryOwner", "reset", "reset$ui_release", "calculatePositionInParent", "Landroidx/compose/ui/geometry/Offset;", "position", "calculatePositionInParent-R5De75A", "(Landroidx/compose/ui/node/NodeCoordinator;J)J", "getPositionFor", "Landroidx/compose/ui/node/LayoutNodeAlignmentLines;", "Landroidx/compose/ui/node/LookaheadAlignmentLines;", "ui_release"}, k = 1, mv = {1, 8, 0}, xi = 48) /* loaded from: classes.dex */ public abstract class AlignmentLines { private final Map alignmentLineMap; private final AlignmentLinesOwner alignmentLinesOwner; private boolean dirty; private boolean previousUsedDuringParentLayout; private AlignmentLinesOwner queryOwner; private boolean usedByModifierLayout; private boolean usedByModifierMeasurement; private boolean usedDuringParentLayout; private boolean usedDuringParentMeasurement; public /* synthetic */ AlignmentLines(AlignmentLinesOwner alignmentLinesOwner, DefaultConstructorMarker defaultConstructorMarker) { this(alignmentLinesOwner); } /* renamed from: calculatePositionInParent-R5De75A, reason: not valid java name */ protected abstract long mo3973calculatePositionInParentR5De75A(NodeCoordinator nodeCoordinator, long j); /* JADX INFO: Access modifiers changed from: protected */ public abstract Map getAlignmentLinesMap(NodeCoordinator nodeCoordinator); public final AlignmentLinesOwner getAlignmentLinesOwner() { return this.alignmentLinesOwner; } /* renamed from: getDirty$ui_release, reason: from getter */ public final boolean getDirty() { return this.dirty; } public final Map getLastCalculation() { return this.alignmentLineMap; } /* JADX INFO: Access modifiers changed from: protected */ public abstract int getPositionFor(NodeCoordinator nodeCoordinator, AlignmentLine alignmentLine); /* renamed from: getPreviousUsedDuringParentLayout$ui_release, reason: from getter */ public final boolean getPreviousUsedDuringParentLayout() { return this.previousUsedDuringParentLayout; } public final boolean getQueried$ui_release() { return this.usedDuringParentMeasurement || this.previousUsedDuringParentLayout || this.usedByModifierMeasurement || this.usedByModifierLayout; } /* renamed from: getUsedByModifierLayout$ui_release, reason: from getter */ public final boolean getUsedByModifierLayout() { return this.usedByModifierLayout; } /* renamed from: getUsedByModifierMeasurement$ui_release, reason: from getter */ public final boolean getUsedByModifierMeasurement() { return this.usedByModifierMeasurement; } /* renamed from: getUsedDuringParentLayout$ui_release, reason: from getter */ public final boolean getUsedDuringParentLayout() { return this.usedDuringParentLayout; } /* renamed from: getUsedDuringParentMeasurement$ui_release, reason: from getter */ public final boolean getUsedDuringParentMeasurement() { return this.usedDuringParentMeasurement; } public final void reset$ui_release() { this.dirty = true; this.usedDuringParentMeasurement = false; this.previousUsedDuringParentLayout = false; this.usedDuringParentLayout = false; this.usedByModifierMeasurement = false; this.usedByModifierLayout = false; this.queryOwner = null; } public final void setDirty$ui_release(boolean z) { this.dirty = z; } public final void setPreviousUsedDuringParentLayout$ui_release(boolean z) { this.previousUsedDuringParentLayout = z; } public final void setUsedByModifierLayout$ui_release(boolean z) { this.usedByModifierLayout = z; } public final void setUsedByModifierMeasurement$ui_release(boolean z) { this.usedByModifierMeasurement = z; } public final void setUsedDuringParentLayout$ui_release(boolean z) { this.usedDuringParentLayout = z; } public final void setUsedDuringParentMeasurement$ui_release(boolean z) { this.usedDuringParentMeasurement = z; } private AlignmentLines(AlignmentLinesOwner alignmentLinesOwner) { this.alignmentLinesOwner = alignmentLinesOwner; this.dirty = true; this.alignmentLineMap = new HashMap(); } public final boolean getRequired$ui_release() { recalculateQueryOwner(); return this.queryOwner != null; } public final void recalculateQueryOwner() { AlignmentLinesOwner alignmentLinesOwner; AlignmentLines alignmentLines; AlignmentLines alignmentLines2; if (getQueried$ui_release()) { alignmentLinesOwner = this.alignmentLinesOwner; } else { AlignmentLinesOwner parentAlignmentLinesOwner = this.alignmentLinesOwner.getParentAlignmentLinesOwner(); if (parentAlignmentLinesOwner == null) { return; } alignmentLinesOwner = parentAlignmentLinesOwner.getAlignmentLines().queryOwner; if (alignmentLinesOwner == null || !alignmentLinesOwner.getAlignmentLines().getQueried$ui_release()) { AlignmentLinesOwner alignmentLinesOwner2 = this.queryOwner; if (alignmentLinesOwner2 == null || alignmentLinesOwner2.getAlignmentLines().getQueried$ui_release()) { return; } AlignmentLinesOwner parentAlignmentLinesOwner2 = alignmentLinesOwner2.getParentAlignmentLinesOwner(); if (parentAlignmentLinesOwner2 != null && (alignmentLines2 = parentAlignmentLinesOwner2.getAlignmentLines()) != null) { alignmentLines2.recalculateQueryOwner(); } AlignmentLinesOwner parentAlignmentLinesOwner3 = alignmentLinesOwner2.getParentAlignmentLinesOwner(); alignmentLinesOwner = (parentAlignmentLinesOwner3 == null || (alignmentLines = parentAlignmentLinesOwner3.getAlignmentLines()) == null) ? null : alignmentLines.queryOwner; } } this.queryOwner = alignmentLinesOwner; } /* JADX INFO: Access modifiers changed from: private */ public final void addAlignmentLine(AlignmentLine alignmentLine, int initialPosition, NodeCoordinator initialCoordinator) { int roundToInt; float f = initialPosition; long Offset = OffsetKt.Offset(f, f); while (true) { Offset = mo3973calculatePositionInParentR5De75A(initialCoordinator, Offset); initialCoordinator = initialCoordinator.getWrappedBy(); Intrinsics.checkNotNull(initialCoordinator); if (Intrinsics.areEqual(initialCoordinator, this.alignmentLinesOwner.getInnerCoordinator())) { break; } else if (getAlignmentLinesMap(initialCoordinator).containsKey(alignmentLine)) { float positionFor = getPositionFor(initialCoordinator, alignmentLine); Offset = OffsetKt.Offset(positionFor, positionFor); } } if (alignmentLine instanceof HorizontalAlignmentLine) { roundToInt = MathKt.roundToInt(Offset.m2401getYimpl(Offset)); } else { roundToInt = MathKt.roundToInt(Offset.m2400getXimpl(Offset)); } Map map = this.alignmentLineMap; if (map.containsKey(alignmentLine)) { roundToInt = AlignmentLineKt.merge(alignmentLine, ((Number) MapsKt.getValue(this.alignmentLineMap, alignmentLine)).intValue(), roundToInt); } map.put(alignmentLine, Integer.valueOf(roundToInt)); } public final void recalculate() { this.alignmentLineMap.clear(); this.alignmentLinesOwner.forEachChildAlignmentLinesOwner(new Function1() { // from class: androidx.compose.ui.node.AlignmentLines$recalculate$1 /* JADX INFO: Access modifiers changed from: package-private */ { super(1); } @Override // kotlin.jvm.functions.Function1 public /* bridge */ /* synthetic */ Unit invoke(AlignmentLinesOwner alignmentLinesOwner) { invoke2(alignmentLinesOwner); return Unit.INSTANCE; } /* renamed from: invoke, reason: avoid collision after fix types in other method */ public final void invoke2(AlignmentLinesOwner childOwner) { Map map; Intrinsics.checkNotNullParameter(childOwner, "childOwner"); if (childOwner.isPlaced()) { if (childOwner.getAlignmentLines().getDirty()) { childOwner.layoutChildren(); } map = childOwner.getAlignmentLines().alignmentLineMap; AlignmentLines alignmentLines = AlignmentLines.this; for (Map.Entry entry : map.entrySet()) { alignmentLines.addAlignmentLine((AlignmentLine) entry.getKey(), ((Number) entry.getValue()).intValue(), childOwner.getInnerCoordinator()); } NodeCoordinator wrappedBy = childOwner.getInnerCoordinator().getWrappedBy(); Intrinsics.checkNotNull(wrappedBy); while (!Intrinsics.areEqual(wrappedBy, AlignmentLines.this.getAlignmentLinesOwner().getInnerCoordinator())) { Set keySet = AlignmentLines.this.getAlignmentLinesMap(wrappedBy).keySet(); AlignmentLines alignmentLines2 = AlignmentLines.this; for (AlignmentLine alignmentLine : keySet) { alignmentLines2.addAlignmentLine(alignmentLine, alignmentLines2.getPositionFor(wrappedBy, alignmentLine), wrappedBy); } wrappedBy = wrappedBy.getWrappedBy(); Intrinsics.checkNotNull(wrappedBy); } } } }); this.alignmentLineMap.putAll(getAlignmentLinesMap(this.alignmentLinesOwner.getInnerCoordinator())); this.dirty = false; } public final void onAlignmentsChanged() { this.dirty = true; AlignmentLinesOwner parentAlignmentLinesOwner = this.alignmentLinesOwner.getParentAlignmentLinesOwner(); if (parentAlignmentLinesOwner == null) { return; } if (this.usedDuringParentMeasurement) { parentAlignmentLinesOwner.requestMeasure(); } else if (this.previousUsedDuringParentLayout || this.usedDuringParentLayout) { parentAlignmentLinesOwner.requestLayout(); } if (this.usedByModifierMeasurement) { this.alignmentLinesOwner.requestMeasure(); } if (this.usedByModifierLayout) { this.alignmentLinesOwner.requestLayout(); } parentAlignmentLinesOwner.getAlignmentLines().onAlignmentsChanged(); } }