content: package com.google.android.material.bottomsheet;
  
  import android.app.Dialog;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.FrameLayout;
  import androidx.appcompat.app.AppCompatDialogFragment;
  import com.google.android.material.bottomsheet.BottomSheetBehavior;
  
  public class BottomSheetDialogFragment extends AppCompatDialogFragment {
      private boolean waitingForDismissAllowingStateLoss;
  
      private class BottomSheetDismissCallback extends BottomSheetBehavior.BottomSheetCallback {
          private BottomSheetDismissCallback() {
          }
  
          public void onSlide(View bottomSheet, float slideOffset) {
          }
  
          public void onStateChanged(View bottomSheet, int newState) {
              if (newState == 5) {
                  BottomSheetDialogFragment.this.dismissAfterAnimation();
              }
          }
      }
  
      /* access modifiers changed from: private */
      public void dismissAfterAnimation() {
          if (this.waitingForDismissAllowingStateLoss) {
              super.dismissAllowingStateLoss();
          } else {
              super.dismiss();
          }
      }
  
      private void dismissWithAnimation(BottomSheetBehavior<?> bottomSheetBehavior, boolean allowingStateLoss) {
          this.waitingForDismissAllowingStateLoss = allowingStateLoss;
          if (bottomSheetBehavior.getState() == 5) {
              dismissAfterAnimation();
              return;
          }
          if (getDialog() instanceof BottomSheetDialog) {
              ((BottomSheetDialog) getDialog()).removeDefaultCallback();
          }
          bottomSheetBehavior.addBottomSheetCallback(new BottomSheetDismissCallback());
          bottomSheetBehavior.setState(5);
      }
  
      private boolean tryDismissWithAnimation(boolean allowingStateLoss) {
          Dialog dialog = getDialog();
          if (!(dialog instanceof BottomSheetDialog)) {
              return false;
          }
          BottomSheetDialog bottomSheetDialog = (BottomSheetDialog) dialog;
          BottomSheetBehavior<FrameLayout> behavior = bottomSheetDialog.getBehavior();
          if (!behavior.isHideable() || !bottomSheetDialog.getDismissWithAnimation()) {
              return false;
          }
          dismissWithAnimation(behavior, allowingStateLoss);
          return true;
      }
  
      public void dismiss() {
          if (!tryDismissWithAnimation(false)) {
              super.dismiss();
          }
      }
  
      public void dismissAllowingStateLoss() {
          if (!tryDismissWithAnimation(true)) {
              super.dismissAllowingStateLoss();
          }
      }
  
      public Dialog onCreateDialog(Bundle savedInstanceState) {
          return new BottomSheetDialog(getContext(), getTheme());
      }
  }
  