package com.bytedance.ies.sdk.widgets;

import X.059;
import X.05h;
import X.05k;
import X.0CB;
import X.0CH;
import X.0CN;
import X.0HH;
import X.2Pr;
import X.2cN;
import X.2tK;
import X.6Is;
import X.C4046H5b;
import X.C4049H5e;
import X.C4050H5f;
import X.C4053H5i;
import X.CEi;
import X.LsC;
import X.PgU;
import X.PjC;
import android.content.Context;
import android.content.res.Resources;
import android.util.Log;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.sdk.datachannel.DataChannel;
import com.bytedance.ies.sdk.widgets.LayeredElementContext;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

public abstract class LayeredElementManager<T extends LayeredElementContext> implements PropertyResolver, 6Is {
    public final boolean isLocalTest = LayeredElementConfiguration.INSTANCE.getDebug();
    public final SparseArray<AnimationInfo> mAnimationInfoArray = new SparseArray<>();
    public AnimationListener mAnimationListener;
    public final Map<Integer, ChainResolver> mChainResolvers = new HashMap();
    public final DataChannel mDataChannel;
    public final List<2cN> mDisposables = new LinkedList();
    public final Map<Integer, ElementSpec> mElements = new HashMap();
    public final SparseArray<List<Integer>> mGroupElements = new SparseArray<>();
    public final 059<GroupHolderConstraintElement> mGroupHolderConstraintElements = new 059<>();
    public final SparseArray<C4050H5f> mGroups = new SparseArray<>();
    public final Map<WidgetHiddenChangedSceneObserver, Integer> mHiddenChangedObserverElementMap = new HashMap();
    public final SparseArray<List<WidgetHiddenChangedSceneObserver>> mHiddenChangedObservers = new SparseArray<>();
    public int mLayerIndex;
    public final C4049H5e mLayeredConstraintLayout;
    public final T mLayeredElementContext;
    public final 0CH mLifecycleOwner;
    public final Ordering mOrdering = new Ordering();
    public final Map<Integer, SpacingResolver> mSpacingResolvers = new HashMap();
    public final List<XmlViewHolderConstraintElement> mXmlViewHolderConstraintElements = new ArrayList();

    static {
        Covode.recordClassIndex(30508);
    }

    public abstract <V> PgU<V> createRxObservable(Class<V> cls);

    public abstract <V> PjC<V, V> createRxTransformer();

    public abstract T onCreateLayeredElementContext(Context context, ViewGroup viewGroup, DataChannel dataChannel);

    public void onStateChanged(0CH r2, 0CB r3) {
        if (r3 == 0CB.ON_DESTROY) {
            onDestroy();
        }
    }

    public T getLayeredElementContext() {
        return this.mLayeredElementContext;
    }

    private void reorder() {
        for (XmlViewHolderConstraintElement next : this.mXmlViewHolderConstraintElements) {
            if (!(next.getView() instanceof C4046H5b) && !(next.getView() instanceof 05k)) {
                this.mLayeredConstraintLayout.bringChildToFront(next.getView());
            }
        }
    }

    private void resolveGuidelineIfNeeded() {
        if (LayeredElementConfiguration.INSTANCE.getGuidelineIndicatorEnabled()) {
            ArrayList arrayList = new ArrayList();
            int childCount = this.mLayeredConstraintLayout.getChildCount();
            for (int i = 0; i < childCount; i++) {
                if (this.mLayeredConstraintLayout.getChildAt(i) instanceof C4046H5b) {
                    arrayList.add(this.mLayeredConstraintLayout.getChildAt(i));
                }
            }
            int size = arrayList.size();
            int[] iArr = new int[size];
            for (int i2 = 0; i2 < size; i2++) {
                iArr[i2] = ((View) arrayList.get(i2)).getId();
            }
            05k h5i = new C4053H5i(this.mLayeredConstraintLayout.getContext());
            05h layeredConstraintLayout$LayoutParams = new LayeredConstraintLayout$LayoutParams(0, 0);
            layeredConstraintLayout$LayoutParams.startToStart = 0;
            layeredConstraintLayout$LayoutParams.endToEnd = 0;
            layeredConstraintLayout$LayoutParams.topToTop = 0;
            layeredConstraintLayout$LayoutParams.bottomToBottom = 0;
            layeredConstraintLayout$LayoutParams.setLayer(this.mLayerIndex);
            layeredConstraintLayout$LayoutParams.setOrder(this.mOrdering.requestOrder(this.mLayerIndex));
            h5i.setReferencedIds(iArr);
            this.mLayeredConstraintLayout.addView(h5i, layeredConstraintLayout$LayoutParams);
        }
    }

    public void finishRegistration() {
        reorder();
        resolveGuidelineIfNeeded();
        int size = this.mGroupElements.size();
        for (int i = 0; i < size; i++) {
            int keyAt = this.mGroupElements.keyAt(i);
            List valueAt = this.mGroupElements.valueAt(i);
            int[] iArr = new int[valueAt.size()];
            for (int i2 = 0; i2 < valueAt.size(); i2++) {
                iArr[i2] = ((Integer) valueAt.get(i2)).intValue();
            }
            this.mGroups.get(keyAt).setReferencedIds(iArr);
        }
    }

    @0CN(LIZ = 0CB.ON_DESTROY)
    public void onDestroy() {
        for (ElementSpec next : this.mElements.values()) {
            if (!next.getSceneObservers().isEmpty()) {
                ConstraintProperty constraintPropertyById = getConstraintPropertyById(next.getId());
                for (SceneObserver next2 : next.getSceneObservers()) {
                    if (constraintPropertyById != null) {
                        next2.dispose(this.mLayeredElementContext, constraintPropertyById);
                    }
                }
            }
            next.dispose();
        }
        this.mAnimationInfoArray.clear();
        for (2cN next3 : this.mDisposables) {
            if (!next3.isDisposed()) {
                next3.dispose();
            }
        }
        this.mDisposables.clear();
        this.mChainResolvers.clear();
        this.mSpacingResolvers.clear();
    }

    public void setAnimationListener(AnimationListener animationListener) {
        this.mAnimationListener = animationListener;
    }

    public void notifyHideAnimationEnd(int i) {
        AnimationListener animationListener = this.mAnimationListener;
        if (animationListener != null) {
            animationListener.onHideAnimationEnd(i);
        }
    }

    public void notifyHideAnimationStart(int i) {
        AnimationListener animationListener = this.mAnimationListener;
        if (animationListener != null) {
            animationListener.onHideAnimationStart(i);
        }
    }

    public void notifyShowAnimationEnd(int i) {
        AnimationListener animationListener = this.mAnimationListener;
        if (animationListener != null) {
            animationListener.onShowAnimationEnd(i);
        }
    }

    public void notifyShowAnimationStart(int i) {
        AnimationListener animationListener = this.mAnimationListener;
        if (animationListener != null) {
            animationListener.onShowAnimationStart(i);
        }
    }

    public void cancelHideAnimation(int i) {
        AnimationInfo animationInfo = this.mAnimationInfoArray.get(i);
        if (animationInfo != null) {
            animationInfo.cancelHideAnimation();
        }
    }

    public void cancelShowAnimation(int i) {
        AnimationInfo animationInfo = this.mAnimationInfoArray.get(i);
        if (animationInfo != null) {
            animationInfo.cancelShowAnimation();
        }
    }

    public <E extends ElementSpec> E getElementById(int i) {
        return (ElementSpec) MapCompat.getOrDefault(this.mElements, Integer.valueOf(i), null);
    }

    public void animateHide(int i) {
        AnimationInfo animationInfo = this.mAnimationInfoArray.get(i);
        if (animationInfo != null) {
            animationInfo.animateHide();
            return;
        }
        notifyHideAnimationStart(i);
        notifyHideAnimationEnd(i);
    }

    public void animateShow(int i) {
        AnimationInfo animationInfo = this.mAnimationInfoArray.get(i);
        if (animationInfo != null) {
            animationInfo.animateShow();
            return;
        }
        notifyShowAnimationStart(i);
        notifyShowAnimationEnd(i);
    }

    public boolean detachView(int i) {
        ConstraintElement constraintElement = (ConstraintElement) this.mGroupHolderConstraintElements.LIZ(i, (Object) null);
        if (!(constraintElement instanceof LayeredPlaceholderElement)) {
            return false;
        }
        ((LayeredPlaceholderElement) constraintElement).onDetachView();
        return true;
    }

    public void downElement(int i) {
        ConstraintProperty constraintPropertyById = getConstraintPropertyById(i);
        if (constraintPropertyById != null) {
            constraintPropertyById.layer((constraintPropertyById.layer() - this.mLayerIndex) - 1);
            constraintPropertyById.apply();
            this.mLayeredConstraintLayout.detach(constraintPropertyById.mView);
            this.mLayeredConstraintLayout.attach(constraintPropertyById.mView);
            this.mLayeredConstraintLayout.requestLayout();
            this.mLayeredConstraintLayout.invalidate();
        }
    }

    public float getResolvedAlpha(int i) {
        GroupHolderConstraintElement groupHolderConstraintElement = (GroupHolderConstraintElement) this.mGroupHolderConstraintElements.LIZ(i, (Object) null);
        float f = groupHolderConstraintElement.getConstraintProperty().mAlpha;
        List<C4050H5f> groups = groupHolderConstraintElement.getGroups();
        if (groups != null && !groups.isEmpty()) {
            Iterator<C4050H5f> it = groups.iterator();
            while (it.hasNext()) {
                f *= it.next().getAlpha();
            }
        }
        return f;
    }

    public float getResolvedTranslationX(int i) {
        GroupHolderConstraintElement groupHolderConstraintElement = (GroupHolderConstraintElement) this.mGroupHolderConstraintElements.LIZ(i, (Object) null);
        List<C4050H5f> groups = groupHolderConstraintElement.getGroups();
        float f = groupHolderConstraintElement.getConstraintProperty().mTranslationX;
        if (groups != null && !groups.isEmpty()) {
            for (C4050H5f transformedTranslationX : groups) {
                f += transformedTranslationX.getTransformedTranslationX(groupHolderConstraintElement.getConstraintProperty().mView);
            }
        }
        return f;
    }

    public float getResolvedTranslationY(int i) {
        GroupHolderConstraintElement groupHolderConstraintElement = (GroupHolderConstraintElement) this.mGroupHolderConstraintElements.LIZ(i, (Object) null);
        List<C4050H5f> groups = groupHolderConstraintElement.getGroups();
        float f = groupHolderConstraintElement.getConstraintProperty().mTranslationY;
        if (groups != null && !groups.isEmpty()) {
            for (C4050H5f transformedTranslationY : groups) {
                f += transformedTranslationY.getTransformedTranslationY(groupHolderConstraintElement.getConstraintProperty().mView);
            }
        }
        return f;
    }

    public int getResolvedVisibility(int i) {
        GroupHolderConstraintElement groupHolderConstraintElement = (GroupHolderConstraintElement) this.mGroupHolderConstraintElements.LIZ(i, (Object) null);
        List<C4050H5f> groups = groupHolderConstraintElement.getGroups();
        int i2 = groupHolderConstraintElement.getConstraintProperty().mVisibility;
        if (groups != null && !groups.isEmpty()) {
            for (C4050H5f visibility : groups) {
                if (visibility.getVisibility() == 8) {
                    return 8;
                }
            }
        }
        return i2;
    }

    public void registerGroups(MultiElementSpec multiElementSpec) {
        if (multiElementSpec != null && !multiElementSpec.getElements().isEmpty()) {
            for (ElementSpec registerGroup : multiElementSpec.getElements()) {
                registerGroup(registerGroup);
            }
        }
    }

    public void upElement(int i) {
        ConstraintProperty constraintPropertyById = getConstraintPropertyById(i);
        if (constraintPropertyById != null) {
            constraintPropertyById.layer(constraintPropertyById.layer() + this.mLayerIndex + 1);
            constraintPropertyById.apply();
            this.mLayeredConstraintLayout.detach(constraintPropertyById.mView);
            this.mLayeredConstraintLayout.attach(constraintPropertyById.mView);
            this.mLayeredConstraintLayout.requestLayout();
            this.mLayeredConstraintLayout.invalidate();
        }
    }

    public ConstraintProperty getConstraintPropertyById(int i) {
        GroupHolderConstraintElement groupHolderConstraintElement = (GroupHolderConstraintElement) this.mGroupHolderConstraintElements.LIZ(i, (Object) null);
        if (groupHolderConstraintElement != null) {
            return groupHolderConstraintElement.getConstraintProperty();
        }
        if (!this.isLocalTest) {
            try {
                LsC<Throwable, 2Pr> sladarReporter = LayeredElementConfiguration.INSTANCE.getSladarReporter();
                sladarReporter.invoke(new IllegalStateException("id is null" + this.mLayeredConstraintLayout.getContext().getResources().getResourceEntryName(i) + Log.getStackTraceString(new Throwable())));
            } catch (Resources.NotFoundException unused) {
            }
            return null;
        }
        throw new NullPointerException("mGroupHolderConstraintElements.get(id) is null -- id is" + this.mLayeredConstraintLayout.getContext().getResources().getResourceEntryName(i));
    }

    /* JADX WARNING: type inference failed for: r2v0, types: [android.view.View, java.lang.Object, X.H5f] */
    public void registerGroup(ElementSpec elementSpec) {
        View findViewById = this.mLayeredConstraintLayout.findViewById(elementSpec.getId());
        if (findViewById != null) {
            this.mLayeredConstraintLayout.removeView(findViewById);
        }
        ? h5f = new C4050H5f(this.mLayeredConstraintLayout.getContext());
        h5f.setId(elementSpec.getId());
        h5f.setPropertyResolver(this);
        this.mLayeredConstraintLayout.addView(h5f);
        this.mGroups.put(elementSpec.getId(), h5f);
        LayeredElement layeredElement = new LayeredElement(h5f, (PropertyResolver) null);
        this.mGroupHolderConstraintElements.LIZIZ(elementSpec.getId(), layeredElement);
        this.mElements.put(Integer.valueOf(elementSpec.getId()), elementSpec);
        for (SceneObserver addSceneObserver : elementSpec.getSceneObservers()) {
            addSceneObserver(elementSpec.getId(), addSceneObserver);
        }
        elementSpec.attach(layeredElement.getConstraintProperty());
    }

    /* JADX WARNING: type inference failed for: r2v7, types: [android.view.ViewGroup$LayoutParams, com.bytedance.ies.sdk.widgets.LayeredConstraintLayout$LayoutParams] */
    public void registerLayer(LayerSpec layerSpec) {
        GroupHolderConstraintElement groupHolderConstraintElement;
        GroupHolderConstraintElement groupHolderConstraintElement2;
        List<ElementSpec> elements = layerSpec.getElements();
        if (!elements.isEmpty()) {
            for (ElementSpec next : elements) {
                if (!this.isLocalTest || this.mGroupHolderConstraintElements.LJ(next.getId()) < 0) {
                    View findViewById = this.mLayeredConstraintLayout.findViewById(next.getId());
                    if (findViewById != null) {
                        ? r2 = (LayeredConstraintLayout$LayoutParams) findViewById.getLayoutParams();
                        r2.setLayer(this.mLayerIndex);
                        r2.setOrder(this.mOrdering.requestOrder(this.mLayerIndex));
                        findViewById.setLayoutParams(r2);
                        if (findViewById instanceof CEi) {
                            groupHolderConstraintElement2 = new LayeredPlaceholderElement(findViewById, this.mLayeredConstraintLayout, this, next.getConstraintWidget());
                        } else {
                            groupHolderConstraintElement2 = new LayeredElement(findViewById, this);
                        }
                        this.mXmlViewHolderConstraintElements.add(groupHolderConstraintElement2);
                        this.mGroupHolderConstraintElements.LIZIZ(next.getId(), groupHolderConstraintElement2);
                        this.mElements.put(Integer.valueOf(next.getId()), next);
                        next.attach(groupHolderConstraintElement2.getConstraintProperty());
                        groupHolderConstraintElement = groupHolderConstraintElement2;
                    } else if (!this.isLocalTest) {
                        LayerInfoHolderElement layerInfoHolderElement = new LayerInfoHolderElement(next.getId(), this.mLayeredConstraintLayout, this);
                        layerInfoHolderElement.getLayerInfo().setLayer(this.mLayerIndex);
                        layerInfoHolderElement.getLayerInfo().setOrder(this.mOrdering.requestOrder(this.mLayerIndex));
                        this.mGroupHolderConstraintElements.LIZIZ(next.getId(), layerInfoHolderElement);
                        this.mElements.put(Integer.valueOf(next.getId()), next);
                        groupHolderConstraintElement = layerInfoHolderElement;
                    } else {
                        throw new IllegalStateException(0HH.LIZ("You mast declare id %s in xml", new Object[]{this.mLayeredConstraintLayout.getContext().getResources().getResourceEntryName(next.getId())}));
                    }
                    for (SceneObserver addSceneObserver : next.getSceneObservers()) {
                        addSceneObserver(next.getId(), addSceneObserver);
                    }
                    if (next instanceof GroupableElementSpec) {
                        for (Integer intValue : ((GroupableElementSpec) next).getGroupIds()) {
                            int intValue2 = intValue.intValue();
                            C4050H5f h5f = this.mGroups.get(intValue2);
                            if (h5f != null) {
                                groupHolderConstraintElement.addGroup(h5f);
                            }
                            List list = this.mGroupElements.get(intValue2);
                            if (list == null) {
                                list = new ArrayList();
                                this.mGroupElements.put(intValue2, list);
                            }
                            list.add(Integer.valueOf(next.getId()));
                        }
                    }
                    if (next.getAnimation() != null) {
                        this.mAnimationInfoArray.put(next.getId(), next.getAnimation());
                    }
                } else {
                    throw new IllegalStateException("Duplicate element, " + this.mLayeredElementContext.getContext().getResources().getResourceEntryName(next.getId()) + " already exist.");
                }
            }
            this.mLayerIndex++;
        }
    }

    private <V> void handleRxBusSceneObserver(int i, RxBusSceneObserver<V> rxBusSceneObserver) {
        this.mDisposables.add(createRxObservable(rxBusSceneObserver.getType()).LIZ(createRxTransformer()).LIZLLL(new LayeredElementManager$$Lambda$2(this, i, rxBusSceneObserver)));
    }

    public void addSceneObserver(int i, SceneObserver sceneObserver) {
        if (sceneObserver instanceof DataChannelSceneObserver) {
            handleDataChannelSceneObserver(i, (DataChannelSceneObserver) sceneObserver);
        } else if (sceneObserver instanceof RxBusSceneObserver) {
            handleRxBusSceneObserver(i, (RxBusSceneObserver) sceneObserver);
        } else if (sceneObserver instanceof WidgetHiddenChangedSceneObserver) {
            handleWidgetHiddenChangedSceneObserver(i, (WidgetHiddenChangedSceneObserver) sceneObserver);
        }
    }

    private <O, V extends 2tK<O>> void handleDataChannelSceneObserver(int i, DataChannelSceneObserver<O, V> dataChannelSceneObserver) {
        if (dataChannelSceneObserver.isSticky()) {
            this.mDataChannel.LIZIZ(this.mLifecycleOwner, dataChannelSceneObserver.getType(), new LayeredElementManager$$Lambda$0(this, i, dataChannelSceneObserver));
        } else {
            this.mDataChannel.LIZ(this.mLifecycleOwner, dataChannelSceneObserver.getType(), new LayeredElementManager$$Lambda$1(this, i, dataChannelSceneObserver));
        }
    }

    private void handleWidgetHiddenChangedSceneObserver(int i, WidgetHiddenChangedSceneObserver widgetHiddenChangedSceneObserver) {
        int id = widgetHiddenChangedSceneObserver.getId();
        List list = this.mHiddenChangedObservers.get(id);
        if (list == null) {
            list = new LinkedList();
            this.mHiddenChangedObservers.put(id, list);
        }
        list.add(widgetHiddenChangedSceneObserver);
        this.mHiddenChangedObserverElementMap.put(widgetHiddenChangedSceneObserver, Integer.valueOf(i));
    }

    public void attachView(int i, View view) {
        ConstraintElement constraintElement = (ConstraintElement) this.mGroupHolderConstraintElements.LIZ(i, (Object) null);
        if (constraintElement instanceof LayeredPlaceholderElement) {
            ((LayeredPlaceholderElement) constraintElement).onAttachView(view);
        } else if (this.isLocalTest) {
            throw new IllegalStateException("LayeredPlaceholderElement not found, have you registered the layer info for " + this.mLayeredElementContext.getContext().getResources().getResourceEntryName(i));
        }
    }

    public void onHiddenChanged(int i, boolean z) {
        ChainResolver chainResolver = (ChainResolver) MapCompat.getOrDefault(this.mChainResolvers, Integer.valueOf(i), null);
        if (chainResolver != null) {
            int[] ids = chainResolver.getIds();
            ArrayList arrayList = new ArrayList();
            for (int constraintPropertyById : ids) {
                ConstraintProperty constraintPropertyById2 = getConstraintPropertyById(constraintPropertyById);
                if (constraintPropertyById2 != null) {
                    arrayList.add(constraintPropertyById2);
                }
            }
            chainResolver.resolveChain(arrayList);
        }
        SpacingResolver spacingResolver = (SpacingResolver) MapCompat.getOrDefault(this.mSpacingResolvers, Integer.valueOf(i), null);
        if (spacingResolver != null) {
            int[] ids2 = spacingResolver.getIds();
            ArrayList arrayList2 = new ArrayList();
            for (int constraintPropertyById3 : ids2) {
                ConstraintProperty constraintPropertyById4 = getConstraintPropertyById(constraintPropertyById3);
                if (constraintPropertyById4 != null) {
                    arrayList2.add(constraintPropertyById4);
                }
            }
            spacingResolver.resolveSpacing(arrayList2);
        }
    }

    public void onWidgetHiddenChanged(int i, boolean z) {
        List<WidgetHiddenChangedSceneObserver> list = this.mHiddenChangedObservers.get(i);
        if (list != null && !list.isEmpty()) {
            for (WidgetHiddenChangedSceneObserver widgetHiddenChangedSceneObserver : list) {
                int intValue = ((Integer) MapCompat.getOrDefault(this.mHiddenChangedObserverElementMap, widgetHiddenChangedSceneObserver, -1)).intValue();
                if (intValue != -1) {
                    widgetHiddenChangedSceneObserver.onHiddenChanged(this.mLayeredElementContext, ((GroupHolderConstraintElement) this.mGroupHolderConstraintElements.LIZ(intValue, (Object) null)).getConstraintProperty(), z);
                }
            }
        }
        onHiddenChanged(i, z);
    }

    public static class MapCompat {
        static {
            Covode.recordClassIndex(30512);
        }

        public static <K, V> V getOrDefault(Map<K, V> map, K k, V v) {
            V v2 = map.get(k);
            if (v2 != null || map.containsKey(k)) {
                return v2;
            }
            return v;
        }
    }

    public final /* synthetic */ 2Pr lambda$handleDataChannelSceneObserver$0$LayeredElementManager(int i, DataChannelSceneObserver dataChannelSceneObserver, Object obj) {
        ConstraintProperty constraintPropertyById = getConstraintPropertyById(i);
        if (constraintPropertyById != null) {
            dataChannelSceneObserver.onEvent(this.mLayeredElementContext, constraintPropertyById, obj);
        }
        return 2Pr.LIZ;
    }

    public final /* synthetic */ 2Pr lambda$handleDataChannelSceneObserver$1$LayeredElementManager(int i, DataChannelSceneObserver dataChannelSceneObserver, Object obj) {
        ConstraintProperty constraintPropertyById = getConstraintPropertyById(i);
        if (constraintPropertyById != null) {
            dataChannelSceneObserver.onEvent(this.mLayeredElementContext, constraintPropertyById, obj);
        }
        return 2Pr.LIZ;
    }

    public final /* synthetic */ void lambda$handleRxBusSceneObserver$2$LayeredElementManager(int i, RxBusSceneObserver rxBusSceneObserver, Object obj) {
        ConstraintProperty constraintPropertyById = getConstraintPropertyById(i);
        if (constraintPropertyById != null) {
            rxBusSceneObserver.onEvent(this.mLayeredElementContext, constraintPropertyById, obj);
        }
    }

    public void attachView(int i, View view, 05h r5) {
        ConstraintElement constraintElement = (ConstraintElement) this.mGroupHolderConstraintElements.LIZ(i, (Object) null);
        if (constraintElement instanceof LayerInfoHolderElement) {
            ((LayerInfoHolderElement) constraintElement).onAttachView(view, r5);
        }
    }

    public void registerSpacingResolver(int i, int i2, int... iArr) {
        if (iArr != null && iArr.length != 0) {
            SpacingResolver spacingResolver = new SpacingResolver(this.mLayeredElementContext, i, i2, iArr);
            for (int valueOf : iArr) {
                this.mSpacingResolvers.put(Integer.valueOf(valueOf), spacingResolver);
            }
        }
    }

    /* JADX WARNING: type inference failed for: r4v0, types: [X.H5e, android.view.ViewGroup] */
    /* JADX WARNING: Unknown variable types count: 1 */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public LayeredElementManager(android.content.Context r2, X.0CH r3, X.C4049H5e r4, com.bytedance.ies.sdk.datachannel.DataChannel r5) {
        /*
            r1 = this;
            r1.<init>()
            com.bytedance.ies.sdk.widgets.Ordering r0 = new com.bytedance.ies.sdk.widgets.Ordering
            r0.<init>()
            r1.mOrdering = r0
            X.059 r0 = new X.059
            r0.<init>()
            r1.mGroupHolderConstraintElements = r0
            java.util.HashMap r0 = new java.util.HashMap
            r0.<init>()
            r1.mElements = r0
            android.util.SparseArray r0 = new android.util.SparseArray
            r0.<init>()
            r1.mGroups = r0
            android.util.SparseArray r0 = new android.util.SparseArray
            r0.<init>()
            r1.mGroupElements = r0
            java.util.LinkedList r0 = new java.util.LinkedList
            r0.<init>()
            r1.mDisposables = r0
            android.util.SparseArray r0 = new android.util.SparseArray
            r0.<init>()
            r1.mHiddenChangedObservers = r0
            java.util.HashMap r0 = new java.util.HashMap
            r0.<init>()
            r1.mHiddenChangedObserverElementMap = r0
            java.util.HashMap r0 = new java.util.HashMap
            r0.<init>()
            r1.mChainResolvers = r0
            java.util.HashMap r0 = new java.util.HashMap
            r0.<init>()
            r1.mSpacingResolvers = r0
            android.util.SparseArray r0 = new android.util.SparseArray
            r0.<init>()
            r1.mAnimationInfoArray = r0
            java.util.ArrayList r0 = new java.util.ArrayList
            r0.<init>()
            r1.mXmlViewHolderConstraintElements = r0
            com.bytedance.ies.sdk.widgets.LayeredElementConfiguration r0 = com.bytedance.ies.sdk.widgets.LayeredElementConfiguration.INSTANCE
            boolean r0 = r0.getDebug()
            r1.isLocalTest = r0
            r1.mLifecycleOwner = r3
            r1.mLayeredConstraintLayout = r4
            r1.mDataChannel = r5
            X.0CD r0 = r3.getLifecycle()
            r0.LIZ(r1)
            com.bytedance.ies.sdk.widgets.LayeredElementContext r0 = r1.onCreateLayeredElementContext(r2, r4, r5)
            r1.mLayeredElementContext = r0
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.bytedance.ies.sdk.widgets.LayeredElementManager.<init>(android.content.Context, X.0CH, X.H5e, com.bytedance.ies.sdk.datachannel.DataChannel):void");
    }

    public void registerHorizontalChain(int i, int i2, int i3, int i4, int... iArr) {
        int[] iArr2 = iArr;
        if (iArr2 != null && iArr2.length != 0) {
            ChainResolver chainResolver = new ChainResolver(i, i2, i3, i4, iArr2);
            for (int valueOf : iArr2) {
                this.mChainResolvers.put(Integer.valueOf(valueOf), chainResolver);
            }
        }
    }
}
