content: package androidx.core.view;
  
  import android.animation.Animator;
  import android.animation.AnimatorListenerAdapter;
  import android.animation.ValueAnimator;
  import android.os.Build;
  import android.view.View;
  import android.view.ViewGroup;
  import android.view.WindowInsets;
  import android.view.WindowInsetsAnimation;
  import android.view.animation.DecelerateInterpolator;
  import android.view.animation.Interpolator;
  import androidx.core.R;
  import androidx.core.graphics.Insets;
  import androidx.core.view.WindowInsetsCompat;
  import java.lang.annotation.Retention;
  import java.lang.annotation.RetentionPolicy;
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Objects;
  
  public final class WindowInsetsAnimationCompat {
      private static final boolean DEBUG = false;
      private static final String TAG = "WindowInsetsAnimCompat";
      private Impl mImpl;
  
      public static final class BoundsCompat {
          private final Insets mLowerBound;
          private final Insets mUpperBound;
  
          private BoundsCompat(WindowInsetsAnimation.Bounds bounds) {
              this.mLowerBound = Impl30.getLowerBounds(bounds);
              this.mUpperBound = Impl30.getHigherBounds(bounds);
          }
  
          public BoundsCompat(Insets lowerBound, Insets upperBound) {
              this.mLowerBound = lowerBound;
              this.mUpperBound = upperBound;
          }
  
          public static BoundsCompat toBoundsCompat(WindowInsetsAnimation.Bounds bounds) {
              return new BoundsCompat(bounds);
          }
  
          public Insets getLowerBound() {
              return this.mLowerBound;
          }
  
          public Insets getUpperBound() {
              return this.mUpperBound;
          }
  
          public BoundsCompat inset(Insets insets) {
              return new BoundsCompat(WindowInsetsCompat.insetInsets(this.mLowerBound, insets.left, insets.top, insets.right, insets.bottom), WindowInsetsCompat.insetInsets(this.mUpperBound, insets.left, insets.top, insets.right, insets.bottom));
          }
  
          public WindowInsetsAnimation.Bounds toBounds() {
              return Impl30.createPlatformBounds(this);
          }
  
          public String toString() {
              return "Bounds{lower=" + this.mLowerBound + " upper=" + this.mUpperBound + "}";
          }
      }
  
      public static abstract class Callback {
          public static final int DISPATCH_MODE_CONTINUE_ON_SUBTREE = 1;
          public static final int DISPATCH_MODE_STOP = 0;
          WindowInsets mDispachedInsets;
          private final int mDispatchMode;
  
          @Retention(RetentionPolicy.SOURCE)
          public @interface DispatchMode {
          }
  
          public Callback(int dispatchMode) {
              this.mDispatchMode = dispatchMode;
          }
  
          public final int getDispatchMode() {
              return this.mDispatchMode;
          }
  
          public void onEnd(WindowInsetsAnimationCompat animation) {
          }
  
          public void onPrepare(WindowInsetsAnimationCompat animation) {
          }
  
          public abstract WindowInsetsCompat onProgress(WindowInsetsCompat windowInsetsCompat, List<WindowInsetsAnimationCompat> list);
  
          public BoundsCompat onStart(WindowInsetsAnimationCompat animation, BoundsCompat bounds) {
              return bounds;
          }
      }
  
      private static class Impl {
          private float mAlpha;
          private final long mDurationMillis;
          private float mFraction;
          private final Interpolator mInterpolator;
          private final int mTypeMask;
  
          Impl(int typeMask, Interpolator interpolator, long durationMillis) {
              this.mTypeMask = typeMask;
              this.mInterpolator = interpolator;
              this.mDurationMillis = durationMillis;
          }
  
          public float getAlpha() {
              return this.mAlpha;
          }
  
          public long getDurationMillis() {
              return this.mDurationMillis;
          }
  
          public float getFraction() {
              return this.mFraction;
          }
  
          public float getInterpolatedFraction() {
              Interpolator interpolator = this.mInterpolator;
              return interpolator != null ? interpolator.getInterpolation(this.mFraction) : this.mFraction;
          }
  
          public Interpolator getInterpolator() {
              return this.mInterpolator;
          }
  
          public int getTypeMask() {
              return this.mTypeMask;
          }
  
          public void setAlpha(float alpha) {
              this.mAlpha = alpha;
          }
  
          public void setFraction(float fraction) {
              this.mFraction = fraction;
          }
      }
  
      private static class Impl21 extends Impl {
  
          private static class Impl21OnApplyWindowInsetsListener implements View.OnApplyWindowInsetsListener {
              private static final int COMPAT_ANIMATION_DURATION = 160;
              final Callback mCallback;
              private WindowInsetsCompat mLastInsets;
  
              Impl21OnApplyWindowInsetsListener(View view, Callback callback) {
                  this.mCallback = callback;
                  WindowInsetsCompat rootWindowInsets = ViewCompat.getRootWindowInsets(view);
                  this.mLastInsets = rootWindowInsets != null ? new WindowInsetsCompat.Builder(rootWindowInsets).build() : null;
              }
  
              public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
                  final View view = v;
                  WindowInsets windowInsets = insets;
                  if (!v.isLaidOut()) {
                      this.mLastInsets = WindowInsetsCompat.toWindowInsetsCompat(windowInsets, view);
                      return Impl21.forwardToViewIfNeeded(v, insets);
                  }
                  WindowInsetsCompat windowInsetsCompat = WindowInsetsCompat.toWindowInsetsCompat(windowInsets, view);
                  if (this.mLastInsets == null) {
                      this.mLastInsets = ViewCompat.getRootWindowInsets(v);
                  }
                  if (this.mLastInsets == null) {
                      this.mLastInsets = windowInsetsCompat;
                      return Impl21.forwardToViewIfNeeded(v, insets);
                  }
                  Callback callback = Impl21.getCallback(v);
                  if (callback != null && Objects.equals(callback.mDispachedInsets, windowInsets)) {
                      return Impl21.forwardToViewIfNeeded(v, insets);
                  }
                  int buildAnimationMask = Impl21.buildAnimationMask(windowInsetsCompat, this.mLastInsets);
                  if (buildAnimationMask == 0) {
                      return Impl21.forwardToViewIfNeeded(v, insets);
                  }
                  WindowInsetsCompat windowInsetsCompat2 = this.mLastInsets;
                  final WindowInsetsAnimationCompat windowInsetsAnimationCompat = new WindowInsetsAnimationCompat(buildAnimationMask, new DecelerateInterpolator(), 160);
                  windowInsetsAnimationCompat.setFraction(0.0f);
                  ValueAnimator duration = ValueAnimator.ofFloat(new float[]{0.0f, 1.0f}).setDuration(windowInsetsAnimationCompat.getDurationMillis());
                  BoundsCompat computeAnimationBounds = Impl21.computeAnimationBounds(windowInsetsCompat, windowInsetsCompat2, buildAnimationMask);
                  Impl21.dispatchOnPrepare(view, windowInsetsAnimationCompat, windowInsets, false);
                  final WindowInsetsAnimationCompat windowInsetsAnimationCompat2 = windowInsetsAnimationCompat;
                  final WindowInsetsCompat windowInsetsCompat3 = windowInsetsCompat;
                  final WindowInsetsCompat windowInsetsCompat4 = windowInsetsCompat2;
                  final int i = buildAnimationMask;
                  AnonymousClass1 r9 = r0;
                  final View view2 = v;
                  AnonymousClass1 r0 = new ValueAnimator.AnimatorUpdateListener() {
                      public void onAnimationUpdate(ValueAnimator animator) {
                          windowInsetsAnimationCompat2.setFraction(animator.getAnimatedFraction());
                          Impl21.dispatchOnProgress(view2, Impl21.interpolateInsets(windowInsetsCompat3, windowInsetsCompat4, windowInsetsAnimationCompat2.getInterpolatedFraction(), i), Collections.singletonList(windowInsetsAnimationCompat2));
                      }
                  };
                  duration.addUpdateListener(r9);
                  duration.addListener(new AnimatorListenerAdapter() {
                      public void onAnimationEnd(Animator animator) {
                          windowInsetsAnimationCompat.setFraction(1.0f);
                          Impl21.dispatchOnEnd(view, windowInsetsAnimationCompat);
                      }
                  });
                  final View view3 = v;
                  final WindowInsetsAnimationCompat windowInsetsAnimationCompat3 = windowInsetsAnimationCompat;
                  final BoundsCompat boundsCompat = computeAnimationBounds;
                  final ValueAnimator valueAnimator = duration;
                  OneShotPreDrawListener.add(view, new Runnable() {
                      public void run() {
                          Impl21.dispatchOnStart(view3, windowInsetsAnimationCompat3, boundsCompat);
                          valueAnimator.start();
                      }
                  });
                  this.mLastInsets = windowInsetsCompat;
                  return Impl21.forwardToViewIfNeeded(v, insets);
              }
          }
  
          Impl21(int typeMask, Interpolator interpolator, long durationMillis) {
              super(typeMask, interpolator, durationMillis);
          }
  
          static int buildAnimationMask(WindowInsetsCompat targetInsets, WindowInsetsCompat currentInsets) {
              int i = 0;
              for (int i2 = 1; i2 <= 256; i2 <<= 1) {
                  if (!targetInsets.getInsets(i2).equals(currentInsets.getInsets(i2))) {
                      i |= i2;
                  }
              }
              return i;
          }
  
          static BoundsCompat computeAnimationBounds(WindowInsetsCompat targetInsets, WindowInsetsCompat startingInsets, int mask) {
              Insets insets = targetInsets.getInsets(mask);
              Insets insets2 = startingInsets.getInsets(mask);
              return new BoundsCompat(Insets.of(Math.min(insets.left, insets2.left), Math.min(insets.top, insets2.top), Math.min(insets.right, insets2.right), Math.min(insets.bottom, insets2.bottom)), Insets.of(Math.max(insets.left, insets2.left), Math.max(insets.top, insets2.top), Math.max(insets.right, insets2.right), Math.max(insets.bottom, insets2.bottom)));
          }
  
          private static View.OnApplyWindowInsetsListener createProxyListener(View view, Callback callback) {
              return new Impl21OnApplyWindowInsetsListener(view, callback);
          }
  
          static void dispatchOnEnd(View v, WindowInsetsAnimationCompat anim) {
              Callback callback = getCallback(v);
              if (callback != null) {
                  callback.onEnd(anim);
                  if (callback.getDispatchMode() == 0) {
                      return;
                  }
              }
              if (v instanceof ViewGroup) {
                  ViewGroup viewGroup = (ViewGroup) v;
                  for (int i = 0; i < viewGroup.getChildCount(); i++) {
                      dispatchOnEnd(viewGroup.getChildAt(i), anim);
                  }
              }
          }
  
          static void dispatchOnPrepare(View v, WindowInsetsAnimationCompat anim, WindowInsets insets, boolean stopDispatch) {
              Callback callback = getCallback(v);
              if (callback != null) {
                  callback.mDispachedInsets = insets;
                  if (!stopDispatch) {
                      callback.onPrepare(anim);
                      stopDispatch = callback.getDispatchMode() == 0;
                  }
              }
              if (v instanceof ViewGroup) {
                  ViewGroup viewGroup = (ViewGroup) v;
                  for (int i = 0; i < viewGroup.getChildCount(); i++) {
                      dispatchOnPrepare(viewGroup.getChildAt(i), anim, insets, stopDispatch);
                  }
              }
          }
  
          static void dispatchOnProgress(View v, WindowInsetsCompat interpolateInsets, List<WindowInsetsAnimationCompat> list) {
              Callback callback = getCallback(v);
              WindowInsetsCompat windowInsetsCompat = interpolateInsets;
              if (callback != null) {
                  windowInsetsCompat = callback.onProgress(windowInsetsCompat, list);
                  if (callback.getDispatchMode() == 0) {
                      return;
                  }
              }
              if (v instanceof ViewGroup) {
                  ViewGroup viewGroup = (ViewGroup) v;
                  for (int i = 0; i < viewGroup.getChildCount(); i++) {
                      dispatchOnProgress(viewGroup.getChildAt(i), windowInsetsCompat, list);
                  }
              }
          }
  
          static void dispatchOnStart(View v, WindowInsetsAnimationCompat anim, BoundsCompat animationBounds) {
              Callback callback = getCallback(v);
              if (callback != null) {
                  callback.onStart(anim, animationBounds);
                  if (callback.getDispatchMode() == 0) {
                      return;
                  }
              }
              if (v instanceof ViewGroup) {
                  ViewGroup viewGroup = (ViewGroup) v;
                  for (int i = 0; i < viewGroup.getChildCount(); i++) {
                      dispatchOnStart(viewGroup.getChildAt(i), anim, animationBounds);
                  }
              }
          }
  
          static WindowInsets forwardToViewIfNeeded(View v, WindowInsets insets) {
              return v.getTag(R.id.tag_on_apply_window_listener) != null ? insets : v.onApplyWindowInsets(insets);
          }
  
          static Callback getCallback(View child) {
              Object tag = child.getTag(R.id.tag_window_insets_animation_callback);
              if (tag instanceof Impl21OnApplyWindowInsetsListener) {
                  return ((Impl21OnApplyWindowInsetsListener) tag).mCallback;
              }
              return null;
          }
  
          static WindowInsetsCompat interpolateInsets(WindowInsetsCompat target, WindowInsetsCompat starting, float fraction, int typeMask) {
              WindowInsetsCompat.Builder builder = new WindowInsetsCompat.Builder(target);
              for (int i = 1; i <= 256; i <<= 1) {
                  if ((typeMask & i) == 0) {
                      builder.setInsets(i, target.getInsets(i));
                  } else {
                      Insets insets = target.getInsets(i);
                      Insets insets2 = starting.getInsets(i);
                      builder.setInsets(i, WindowInsetsCompat.insetInsets(insets, (int) (((double) (((float) (insets.left - insets2.left)) * (1.0f - fraction))) + 0.5d), (int) (((double) (((float) (insets.top - insets2.top)) * (1.0f - fraction))) + 0.5d), (int) (((double) (((float) (insets.right - insets2.right)) * (1.0f - fraction))) + 0.5d), (int) (((double) (((float) (insets.bottom - insets2.bottom)) * (1.0f - fraction))) + 0.5d)));
                  }
              }
              return builder.build();
          }
  
          static void setCallback(View view, Callback callback) {
              Object tag = view.getTag(R.id.tag_on_apply_window_listener);
              if (callback == null) {
                  view.setTag(R.id.tag_window_insets_animation_callback, (Object) null);
                  if (tag == null) {
                      view.setOnApplyWindowInsetsListener((View.OnApplyWindowInsetsListener) null);
                      return;
                  }
                  return;
              }
              View.OnApplyWindowInsetsListener createProxyListener = createProxyListener(view, callback);
              view.setTag(R.id.tag_window_insets_animation_callback, createProxyListener);
              if (tag == null) {
                  view.setOnApplyWindowInsetsListener(createProxyListener);
              }
          }
      }
  
      private static class Impl30 extends Impl {
          private final WindowInsetsAnimation mWrapped;
  
          private static class ProxyCallback extends WindowInsetsAnimation.Callback {
              private final HashMap<WindowInsetsAnimation, WindowInsetsAnimationCompat> mAnimations = new HashMap<>();
              private final Callback mCompat;
              private List<WindowInsetsAnimationCompat> mRORunningAnimations;
              private ArrayList<WindowInsetsAnimationCompat> mTmpRunningAnimations;
  
              ProxyCallback(Callback compat) {
                  super(compat.getDispatchMode());
                  this.mCompat = compat;
              }
  
              private WindowInsetsAnimationCompat getWindowInsetsAnimationCompat(WindowInsetsAnimation animation) {
                  WindowInsetsAnimationCompat windowInsetsAnimationCompat = this.mAnimations.get(animation);
                  if (windowInsetsAnimationCompat != null) {
                      return windowInsetsAnimationCompat;
                  }
                  WindowInsetsAnimationCompat windowInsetsAnimationCompat2 = WindowInsetsAnimationCompat.toWindowInsetsAnimationCompat(animation);
                  this.mAnimations.put(animation, windowInsetsAnimationCompat2);
                  return windowInsetsAnimationCompat2;
              }
  
              public void onEnd(WindowInsetsAnimation animation) {
                  this.mCompat.onEnd(getWindowInsetsAnimationCompat(animation));
                  this.mAnimations.remove(animation);
              }
  
              public void onPrepare(WindowInsetsAnimation animation) {
                  this.mCompat.onPrepare(getWindowInsetsAnimationCompat(animation));
              }
  
              public WindowInsets onProgress(WindowInsets insets, List<WindowInsetsAnimation> list) {
                  ArrayList<WindowInsetsAnimationCompat> arrayList = this.mTmpRunningAnimations;
                  if (arrayList == null) {
                      ArrayList<WindowInsetsAnimationCompat> arrayList2 = new ArrayList<>(list.size());
                      this.mTmpRunningAnimations = arrayList2;
                      this.mRORunningAnimations = Collections.unmodifiableList(arrayList2);
                  } else {
                      arrayList.clear();
                  }
                  for (int size = list.size() - 1; size >= 0; size--) {
                      WindowInsetsAnimation windowInsetsAnimation = list.get(size);
                      WindowInsetsAnimationCompat windowInsetsAnimationCompat = getWindowInsetsAnimationCompat(windowInsetsAnimation);
                      windowInsetsAnimationCompat.setFraction(windowInsetsAnimation.getFraction());
                      this.mTmpRunningAnimations.add(windowInsetsAnimationCompat);
                  }
                  return this.mCompat.onProgress(WindowInsetsCompat.toWindowInsetsCompat(insets), this.mRORunningAnimations).toWindowInsets();
              }
  
              public WindowInsetsAnimation.Bounds onStart(WindowInsetsAnimation animation, WindowInsetsAnimation.Bounds bounds) {
                  return this.mCompat.onStart(getWindowInsetsAnimationCompat(animation), BoundsCompat.toBoundsCompat(bounds)).toBounds();
              }
          }
  
          Impl30(int typeMask, Interpolator interpolator, long durationMillis) {
              this(new WindowInsetsAnimation(typeMask, interpolator, durationMillis));
          }
  
          Impl30(WindowInsetsAnimation wrapped) {
              super(0, (Interpolator) null, 0);
              this.mWrapped = wrapped;
          }
  
          public static WindowInsetsAnimation.Bounds createPlatformBounds(BoundsCompat bounds) {
              return new WindowInsetsAnimation.Bounds(bounds.getLowerBound().toPlatformInsets(), bounds.getUpperBound().toPlatformInsets());
          }
  
          public static Insets getHigherBounds(WindowInsetsAnimation.Bounds bounds) {
              return Insets.toCompatInsets(bounds.getUpperBound());
          }
  
          public static Insets getLowerBounds(WindowInsetsAnimation.Bounds bounds) {
              return Insets.toCompatInsets(bounds.getLowerBound());
          }
  
          public static void setCallback(View view, Callback callback) {
              view.setWindowInsetsAnimationCallback(callback != null ? new ProxyCallback(callback) : null);
          }
  
          public long getDurationMillis() {
              return this.mWrapped.getDurationMillis();
          }
  
          public float getFraction() {
              return this.mWrapped.getFraction();
          }
  
          public float getInterpolatedFraction() {
              return this.mWrapped.getInterpolatedFraction();
          }
  
          public Interpolator getInterpolator() {
              return this.mWrapped.getInterpolator();
          }
  
          public int getTypeMask() {
              return this.mWrapped.getTypeMask();
          }
  
          public void setFraction(float fraction) {
              this.mWrapped.setFraction(fraction);
          }
      }
  
      public WindowInsetsAnimationCompat(int typeMask, Interpolator interpolator, long durationMillis) {
          if (Build.VERSION.SDK_INT >= 30) {
              this.mImpl = new Impl30(typeMask, interpolator, durationMillis);
          } else if (Build.VERSION.SDK_INT >= 21) {
              this.mImpl = new Impl21(typeMask, interpolator, durationMillis);
          } else {
              this.mImpl = new Impl(0, interpolator, durationMillis);
          }
      }
  
      private WindowInsetsAnimationCompat(WindowInsetsAnimation animation) {
          this(0, (Interpolator) null, 0);
          if (Build.VERSION.SDK_INT >= 30) {
              this.mImpl = new Impl30(animation);
          }
      }
  
      static void setCallback(View view, Callback callback) {
          if (Build.VERSION.SDK_INT >= 30) {
              Impl30.setCallback(view, callback);
          } else if (Build.VERSION.SDK_INT >= 21) {
              Impl21.setCallback(view, callback);
          }
      }
  
      static WindowInsetsAnimationCompat toWindowInsetsAnimationCompat(WindowInsetsAnimation windowInsetsAnimation) {
          return new WindowInsetsAnimationCompat(windowInsetsAnimation);
      }
  
      public float getAlpha() {
          return this.mImpl.getAlpha();
      }
  
      public long getDurationMillis() {
          return this.mImpl.getDurationMillis();
      }
  
      public float getFraction() {
          return this.mImpl.getFraction();
      }
  
      public float getInterpolatedFraction() {
          return this.mImpl.getInterpolatedFraction();
      }
  
      public Interpolator getInterpolator() {
          return this.mImpl.getInterpolator();
      }
  
      public int getTypeMask() {
          return this.mImpl.getTypeMask();
      }
  
      public void setAlpha(float alpha) {
          this.mImpl.setAlpha(alpha);
      }
  
      public void setFraction(float fraction) {
          this.mImpl.setFraction(fraction);
      }
  }
  