package com.google.firebase.firestore.model.mutation;

import com.google.firebase.Timestamp;
import com.google.firebase.firestore.model.Values;
import e4.C1973c;
import e4.C1975d;
import e4.G0;
import e4.H0;
import java.util.Collections;
import java.util.List;

/* JADX INFO: loaded from: classes3.dex */
public abstract class ArrayTransformOperation implements TransformOperation {
    private final List<H0> elements;

    public static class Remove extends ArrayTransformOperation {
        public Remove(List<H0> list) {
            super(list);
        }

        @Override // com.google.firebase.firestore.model.mutation.ArrayTransformOperation
        public H0 apply(H0 h0) {
            C1973c c1973cCoercedFieldValuesArray = ArrayTransformOperation.coercedFieldValuesArray(h0);
            for (H0 h02 : getElements()) {
                int i6 = 0;
                while (i6 < c1973cCoercedFieldValuesArray.f()) {
                    if (Values.equals(c1973cCoercedFieldValuesArray.e(i6), h02)) {
                        c1973cCoercedFieldValuesArray.h(i6);
                    } else {
                        i6++;
                    }
                }
            }
            G0 g0C = H0.C();
            g0C.d(c1973cCoercedFieldValuesArray);
            return (H0) g0C.m359build();
        }
    }

    public static class Union extends ArrayTransformOperation {
        public Union(List<H0> list) {
            super(list);
        }

        @Override // com.google.firebase.firestore.model.mutation.ArrayTransformOperation
        public H0 apply(H0 h0) {
            C1973c c1973cCoercedFieldValuesArray = ArrayTransformOperation.coercedFieldValuesArray(h0);
            for (H0 h02 : getElements()) {
                if (!Values.contains(c1973cCoercedFieldValuesArray, h02)) {
                    c1973cCoercedFieldValuesArray.d(h02);
                }
            }
            G0 g0C = H0.C();
            g0C.d(c1973cCoercedFieldValuesArray);
            return (H0) g0C.m359build();
        }
    }

    public ArrayTransformOperation(List<H0> list) {
        this.elements = Collections.unmodifiableList(list);
    }

    public static C1973c coercedFieldValuesArray(H0 h0) {
        return Values.isArray(h0) ? (C1973c) h0.q().m367toBuilder() : C1975d.l();
    }

    public abstract H0 apply(H0 h0);

    @Override // com.google.firebase.firestore.model.mutation.TransformOperation
    public H0 applyToLocalView(H0 h0, Timestamp timestamp) {
        return apply(h0);
    }

    @Override // com.google.firebase.firestore.model.mutation.TransformOperation
    public H0 applyToRemoteDocument(H0 h0, H0 h02) {
        return apply(h0);
    }

    @Override // com.google.firebase.firestore.model.mutation.TransformOperation
    public H0 computeBaseValue(H0 h0) {
        return null;
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        return this.elements.equals(((ArrayTransformOperation) obj).elements);
    }

    public List<H0> getElements() {
        return this.elements;
    }

    public int hashCode() {
        return this.elements.hashCode() + (getClass().hashCode() * 31);
    }
}
