content: package androidx.appcompat.view.menu;
  
  import android.content.Context;
  import android.view.MenuItem;
  import android.view.SubMenu;
  import androidx.collection.SimpleArrayMap;
  import androidx.core.internal.view.SupportMenuItem;
  import androidx.core.internal.view.SupportSubMenu;
  
  abstract class BaseMenuWrapper {
      final Context mContext;
      private SimpleArrayMap<SupportMenuItem, MenuItem> mMenuItems;
      private SimpleArrayMap<SupportSubMenu, SubMenu> mSubMenus;
  
      BaseMenuWrapper(Context context) {
          this.mContext = context;
      }
  
      /* access modifiers changed from: package-private */
      public final MenuItem getMenuItemWrapper(MenuItem menuItem) {
          if (!(menuItem instanceof SupportMenuItem)) {
              return menuItem;
          }
          SupportMenuItem supportMenuItem = (SupportMenuItem) menuItem;
          if (this.mMenuItems == null) {
              this.mMenuItems = new SimpleArrayMap<>();
          }
          MenuItem menuItem2 = this.mMenuItems.get(supportMenuItem);
          if (menuItem2 != null) {
              return menuItem2;
          }
          MenuItemWrapperICS menuItemWrapperICS = new MenuItemWrapperICS(this.mContext, supportMenuItem);
          this.mMenuItems.put(supportMenuItem, menuItemWrapperICS);
          return menuItemWrapperICS;
      }
  
      /* access modifiers changed from: package-private */
      public final SubMenu getSubMenuWrapper(SubMenu subMenu) {
          if (!(subMenu instanceof SupportSubMenu)) {
              return subMenu;
          }
          SupportSubMenu supportSubMenu = (SupportSubMenu) subMenu;
          if (this.mSubMenus == null) {
              this.mSubMenus = new SimpleArrayMap<>();
          }
          SubMenu subMenu2 = this.mSubMenus.get(supportSubMenu);
          if (subMenu2 != null) {
              return subMenu2;
          }
          SubMenuWrapperICS subMenuWrapperICS = new SubMenuWrapperICS(this.mContext, supportSubMenu);
          this.mSubMenus.put(supportSubMenu, subMenuWrapperICS);
          return subMenuWrapperICS;
      }
  
      /* access modifiers changed from: package-private */
      public final void internalClear() {
          SimpleArrayMap<SupportMenuItem, MenuItem> simpleArrayMap = this.mMenuItems;
          if (simpleArrayMap != null) {
              simpleArrayMap.clear();
          }
          SimpleArrayMap<SupportSubMenu, SubMenu> simpleArrayMap2 = this.mSubMenus;
          if (simpleArrayMap2 != null) {
              simpleArrayMap2.clear();
          }
      }
  
      /* access modifiers changed from: package-private */
      public final void internalRemoveGroup(int groupId) {
          if (this.mMenuItems != null) {
              int i = 0;
              while (i < this.mMenuItems.size()) {
                  if (this.mMenuItems.keyAt(i).getGroupId() == groupId) {
                      this.mMenuItems.removeAt(i);
                      i--;
                  }
                  i++;
              }
          }
      }
  
      /* access modifiers changed from: package-private */
      public final void internalRemoveItem(int id) {
          if (this.mMenuItems != null) {
              for (int i = 0; i < this.mMenuItems.size(); i++) {
                  if (this.mMenuItems.keyAt(i).getItemId() == id) {
                      this.mMenuItems.removeAt(i);
                      return;
                  }
              }
          }
      }
  }
  