package mapped;

import java.util.ArrayList;
import java.util.List;
import net.runelite.api.clan.ClanMember;
import net.runelite.api.clan.ClanRank;
import net.runelite.api.clan.ClanTitle;
import net.runelite.mapping.ObfuscatedGetter;
import net.runelite.mapping.ObfuscatedName;
import net.runelite.mapping.ObfuscatedSignature;
import net.runelite.rs.api.RSClanSettings;

@ObfuscatedName("fc")
public class ClanSettings implements RSClanSettings {
   // $FF: synthetic field
   public static final boolean $assertionsDisabled;
   @ObfuscatedName("ah")
   boolean useHashes;
   @ObfuscatedName("ar")
   boolean useNames;
   @ObfuscatedName("ao")
   @ObfuscatedGetter(
      longValue = 6267051267450243407L
   )
   long field1722;
   @ObfuscatedName("ab")
   @ObfuscatedGetter(
      intValue = -753632835
   )
   public int field1701;
   @ObfuscatedName("au")
   public String name;
   @ObfuscatedName("aa")
   @ObfuscatedGetter(
      intValue = 1520903843
   )
   int field1720;
   @ObfuscatedName("ac")
   public boolean allowGuests;
   @ObfuscatedName("al")
   public byte field1705;
   @ObfuscatedName("az")
   public byte field1706;
   @ObfuscatedName("ap")
   public byte field1707;
   @ObfuscatedName("av")
   public byte field1708;
   @ObfuscatedName("ax")
   @ObfuscatedGetter(
      intValue = -2054003043
   )
   public int memberCount;
   @ObfuscatedName("as")
   long[] memberHashes;
   @ObfuscatedName("ay")
   public byte[] memberRanks;
   @ObfuscatedName("ak")
   int[] sortedMembers;
   @ObfuscatedName("aj")
   int[] field1713;
   @ObfuscatedName("am")
   public int[] field1723;
   @ObfuscatedName("aq")
   public boolean[] field1698;
   @ObfuscatedName("ai")
   @ObfuscatedGetter(
      intValue = 1045056595
   )
   public int currentOwner;
   @ObfuscatedName("aw")
   @ObfuscatedGetter(
      intValue = -358083271
   )
   public int field1717;
   @ObfuscatedName("ae")
   @ObfuscatedGetter(
      intValue = 943007671
   )
   public int bannedMemberCount;
   @ObfuscatedName("an")
   long[] bannedMemberHashes;
   @ObfuscatedName("ag")
   public String[] memberNames;
   @ObfuscatedName("ad")
   public String[] bannedMemberNames;
   @ObfuscatedName("af")
   @ObfuscatedSignature(
      descriptor = "Ltz;"
   )
   IterableNodeHashTable parameters;

   static {
      $assertionsDisabled = !ClanSettings.class.desiredAssertionStatus();
   }

   @ObfuscatedSignature(
      descriptor = "(Luj;)V"
   )
   public ClanSettings(Buffer var1) {
      this.field1701 = 0;
      this.name = null;
      this.field1720 = 0;
      this.currentOwner = -1;
      this.field1717 = -1;
      this.method3340(var1);
   }

   @ObfuscatedName("at")
   @ObfuscatedSignature(
      descriptor = "(IB)V",
      garbageValue = "95"
   )
   void method3383_base(int var1) {
      if(this.useHashes) {
         if(this.memberHashes != null) {
            System.arraycopy(this.memberHashes, 0, this.memberHashes = new long[var1], 0, this.memberCount);
         } else {
            this.memberHashes = new long[var1];
         }
      }

      if(this.useNames) {
         if(this.memberNames != null) {
            System.arraycopy(this.memberNames, 0, this.memberNames = new String[var1], 0, this.memberCount);
         } else {
            this.memberNames = new String[var1];
         }
      }

      if(this.memberRanks != null) {
         System.arraycopy(this.memberRanks, 0, this.memberRanks = new byte[var1], 0, this.memberCount);
      } else {
         this.memberRanks = new byte[var1];
      }

      if(this.field1713 != null) {
         System.arraycopy(this.field1713, 0, this.field1713 = new int[var1], 0, this.memberCount);
      } else {
         this.field1713 = new int[var1];
      }

      if(this.field1723 != null) {
         System.arraycopy(this.field1723, 0, this.field1723 = new int[var1], 0, this.memberCount);
      } else {
         this.field1723 = new int[var1];
      }

      if(this.field1698 != null) {
         System.arraycopy(this.field1698, 0, this.field1698 = new boolean[var1], 0, this.memberCount);
      } else {
         this.field1698 = new boolean[var1];
      }

   }

   @ObfuscatedName("ah")
   @ObfuscatedSignature(
      descriptor = "(II)V",
      garbageValue = "-1189145621"
   )
   void method3322_base(int var1) {
      if(this.useHashes) {
         if(this.bannedMemberHashes != null) {
            System.arraycopy(this.bannedMemberHashes, 0, this.bannedMemberHashes = new long[var1], 0, this.bannedMemberCount);
         } else {
            this.bannedMemberHashes = new long[var1];
         }
      }

      if(this.useNames) {
         if(this.bannedMemberNames != null) {
            System.arraycopy(this.bannedMemberNames, 0, this.bannedMemberNames = new String[var1], 0, this.bannedMemberCount);
         } else {
            this.bannedMemberNames = new String[var1];
         }
      }

   }

   @ObfuscatedName("ar")
   @ObfuscatedSignature(
      descriptor = "(Ljava/lang/String;B)I",
      garbageValue = "1"
   )
   public int method3323_base(String var1) {
      if(var1 != null && var1.length() != 0) {
         for(int var2 = 0; var2 < this.memberCount; ++var2) {
            if(this.memberNames[var2].equals(var1)) {
               return var2;
            }
         }

         return -1;
      } else {
         return -1;
      }
   }

   @ObfuscatedName("ao")
   @ObfuscatedSignature(
      descriptor = "(IIII)I",
      garbageValue = "1718718774"
   )
   public int method3341_base(int var1, int var2, int var3) {
      int var4 = var3 == 31?-1:(1 << var3 + 1) - 1;
      return (this.field1713[var1] & var4) >>> var2;
   }

   @ObfuscatedName("ab")
   @ObfuscatedSignature(
      descriptor = "(II)Ljava/lang/Integer;",
      garbageValue = "2128934080"
   )
   public Integer getTitleGroupValue_base(int var1) {
      if(this.parameters == null) {
         return null;
      } else {
         Node var2 = this.parameters.get((long)var1);
         return var2 != null && var2 instanceof IntegerNode?new Integer(((IntegerNode)var2).integer):null;
      }
   }

   @ObfuscatedName("au")
   @ObfuscatedSignature(
      descriptor = "(I)[I",
      garbageValue = "-672366104"
   )
   public int[] getSortedMembers_base() {
      if(this.sortedMembers == null) {
         String[] var1 = new String[this.memberCount];
         this.sortedMembers = new int[this.memberCount];

         for(int var2 = 0; var2 < this.memberCount; this.sortedMembers[var2] = var2++) {
            var1[var2] = this.memberNames[var2];
            if(var1[var2] != null) {
               var1[var2] = var1[var2].toLowerCase();
            }
         }

         int[] var3 = this.sortedMembers;
         class475.method8597_base(var1, var3, 0, var1.length - 1);
      }

      return this.sortedMembers;
   }

   @ObfuscatedName("aa")
   @ObfuscatedSignature(
      descriptor = "(JLjava/lang/String;II)V",
      garbageValue = "613838614"
   )
   void method3327_base(long var1, String var3, int var4) {
      if(var3 != null && var3.length() == 0) {
         var3 = null;
      }

      if(var1 > 0L != this.useHashes) {
         throw new RuntimeException("");
      } else if(var3 != null != this.useNames) {
         throw new RuntimeException("");
      } else {
         if(var1 > 0L && (this.memberHashes == null || this.memberCount >= this.memberHashes.length) || var3 != null && (this.memberNames == null || this.memberCount >= this.memberNames.length)) {
            this.method3383_base(this.memberCount + 5);
         }

         if(this.memberHashes != null) {
            this.memberHashes[this.memberCount] = var1;
         }

         if(this.memberNames != null) {
            this.memberNames[this.memberCount] = var3;
         }

         if(this.currentOwner == -1) {
            this.currentOwner = this.memberCount;
            this.memberRanks[this.memberCount] = 126;
         } else {
            this.memberRanks[this.memberCount] = 0;
         }

         this.field1713[this.memberCount] = 0;
         this.field1723[this.memberCount] = var4;
         this.field1698[this.memberCount] = false;
         ++this.memberCount;
         this.sortedMembers = null;
      }
   }

   @ObfuscatedName("ac")
   @ObfuscatedSignature(
      descriptor = "(II)V",
      garbageValue = "2072484175"
   )
   void method3328_base(int var1) {
      if(var1 >= 0 && var1 < this.memberCount) {
         --this.memberCount;
         this.sortedMembers = null;
         if(this.memberCount == 0) {
            this.memberHashes = null;
            this.memberNames = null;
            this.memberRanks = null;
            this.field1713 = null;
            this.field1723 = null;
            this.field1698 = null;
            this.currentOwner = -1;
            this.field1717 = -1;
         } else {
            System.arraycopy(this.memberRanks, var1 + 1, this.memberRanks, var1, this.memberCount - var1);
            System.arraycopy(this.field1713, var1 + 1, this.field1713, var1, this.memberCount - var1);
            System.arraycopy(this.field1723, var1 + 1, this.field1723, var1, this.memberCount - var1);
            System.arraycopy(this.field1698, var1 + 1, this.field1698, var1, this.memberCount - var1);
            if(this.memberHashes != null) {
               System.arraycopy(this.memberHashes, var1 + 1, this.memberHashes, var1, this.memberCount - var1);
            }

            if(this.memberNames != null) {
               System.arraycopy(this.memberNames, var1 + 1, this.memberNames, var1, this.memberCount - var1);
            }

            this.updateOwner_base();
         }

      } else {
         throw new RuntimeException("");
      }
   }

   @ObfuscatedName("al")
   @ObfuscatedSignature(
      descriptor = "(B)V",
      garbageValue = "-7"
   )
   void updateOwner_base() {
      if(this.memberCount == 0) {
         this.currentOwner = -1;
         this.field1717 = -1;
      } else {
         this.currentOwner = -1;
         this.field1717 = -1;
         int var1 = 0;
         byte var2 = this.memberRanks[0];

         for(int var3 = 1; var3 < this.memberCount; ++var3) {
            if(this.memberRanks[var3] > var2) {
               if(var2 == 125) {
                  this.field1717 = var1;
               }

               var1 = var3;
               var2 = this.memberRanks[var3];
            } else if(this.field1717 == -1 && this.memberRanks[var3] == 125) {
               this.field1717 = var3;
            }
         }

         this.currentOwner = var1;
         if(this.currentOwner != -1) {
            this.memberRanks[this.currentOwner] = 126;
         }

      }
   }

   @ObfuscatedName("az")
   @ObfuscatedSignature(
      descriptor = "(JLjava/lang/String;I)V",
      garbageValue = "-1952730404"
   )
   void method3358_base(long var1, String var3) {
      if(var3 != null && var3.length() == 0) {
         var3 = null;
      }

      if(this.useHashes != var1 > 0L) {
         throw new RuntimeException("");
      } else if(this.useNames != (var3 != null)) {
         throw new RuntimeException("");
      } else {
         if(var1 > 0L && (this.bannedMemberHashes == null || this.bannedMemberCount >= this.bannedMemberHashes.length) || var3 != null && (this.bannedMemberNames == null || this.bannedMemberCount >= this.bannedMemberNames.length)) {
            this.method3322_base(this.bannedMemberCount + 5);
         }

         if(this.bannedMemberHashes != null) {
            this.bannedMemberHashes[this.bannedMemberCount] = var1;
         }

         if(this.bannedMemberNames != null) {
            this.bannedMemberNames[this.bannedMemberCount] = var3;
         }

         ++this.bannedMemberCount;
      }
   }

   @ObfuscatedName("ap")
   @ObfuscatedSignature(
      descriptor = "(II)V",
      garbageValue = "-1253930747"
   )
   void method3338_base(int var1) {
      --this.bannedMemberCount;
      if(this.bannedMemberCount == 0) {
         this.bannedMemberHashes = null;
         this.bannedMemberNames = null;
      } else {
         if(this.bannedMemberHashes != null) {
            System.arraycopy(this.bannedMemberHashes, var1 + 1, this.bannedMemberHashes, var1, this.bannedMemberCount - var1);
         }

         if(this.bannedMemberNames != null) {
            System.arraycopy(this.bannedMemberNames, var1 + 1, this.bannedMemberNames, var1, this.bannedMemberCount - var1);
         }
      }

   }

   @ObfuscatedName("av")
   @ObfuscatedSignature(
      descriptor = "(IBB)I",
      garbageValue = "-88"
   )
   int method3379_base(int var1, byte var2) {
      if(var2 != 126 && var2 != 127) {
         if(this.currentOwner == var1 && (this.field1717 == -1 || this.memberRanks[this.field1717] < 125)) {
            return -1;
         } else if(this.memberRanks[var1] == var2) {
            return -1;
         } else {
            this.memberRanks[var1] = var2;
            this.updateOwner_base();
            return var1;
         }
      } else {
         return -1;
      }
   }

   @ObfuscatedName("ax")
   @ObfuscatedSignature(
      descriptor = "(IB)Z",
      garbageValue = "7"
   )
   boolean method3366_base(int var1) {
      if(this.currentOwner != var1 && this.memberRanks[var1] != 126) {
         this.memberRanks[this.currentOwner] = 125;
         this.field1717 = this.currentOwner;
         this.memberRanks[var1] = 126;
         this.currentOwner = var1;
         return true;
      } else {
         return false;
      }
   }

   @ObfuscatedName("as")
   @ObfuscatedSignature(
      descriptor = "(IZI)I",
      garbageValue = "-1328118008"
   )
   int method3334_base(int var1, boolean var2) {
      if(this.field1698[var1] == var2) {
         return -1;
      } else {
         this.field1698[var1] = var2;
         return var1;
      }
   }

   @ObfuscatedName("ay")
   @ObfuscatedSignature(
      descriptor = "(IIIII)I",
      garbageValue = "2048454468"
   )
   int method3335_base(int var1, int var2, int var3, int var4) {
      int var5 = (1 << var3) - 1;
      int var6 = var4 == 31?-1:(1 << var4 + 1) - 1;
      int var7 = var6 ^ var5;
      var2 <<= var3;
      var2 &= var7;
      int var8 = this.field1713[var1];
      if((var8 & var7) == var2) {
         return -1;
      } else {
         var8 &= ~var7;
         this.field1713[var1] = var8 | var2;
         return var1;
      }
   }

   @ObfuscatedName("ak")
   @ObfuscatedSignature(
      descriptor = "(III)Z",
      garbageValue = "2056023373"
   )
   boolean method3336_base(int var1, int var2) {
      if(this.parameters != null) {
         Node var3 = this.parameters.get((long)var1);
         if(var3 != null) {
            if(var3 instanceof IntegerNode) {
               IntegerNode var4 = (IntegerNode)var3;
               if(var2 == var4.integer) {
                  return false;
               }

               var4.integer = var2;
               return true;
            }

            var3.remove_base();
         }
      } else {
         this.parameters = new IterableNodeHashTable(4);
      }

      this.parameters.put(new IntegerNode(var2), (long)var1);
      return true;
   }

   @ObfuscatedName("aj")
   @ObfuscatedSignature(
      descriptor = "(IIIII)Z",
      garbageValue = "-303137716"
   )
   boolean method3337_base(int var1, int var2, int var3, int var4) {
      int var5 = (1 << var3) - 1;
      int var6 = var4 == 31?-1:(1 << var4 + 1) - 1;
      int var7 = var6 ^ var5;
      var2 <<= var3;
      var2 &= var7;
      if(this.parameters != null) {
         Node var8 = this.parameters.get((long)var1);
         if(var8 != null) {
            if(var8 instanceof IntegerNode) {
               IntegerNode var9 = (IntegerNode)var8;
               if((var9.integer & var7) == var2) {
                  return false;
               }

               var9.integer &= ~var7;
               var9.integer |= var2;
               return true;
            }

            var8.remove_base();
         }
      } else {
         this.parameters = new IterableNodeHashTable(4);
      }

      this.parameters.put(new IntegerNode(var2), (long)var1);
      return true;
   }

   @ObfuscatedName("am")
   boolean method3330_base(int var1, long var2) {
      if(this.parameters != null) {
         Node var4 = this.parameters.get((long)var1);
         if(var4 != null) {
            if(var4 instanceof class482) {
               class482 var5 = (class482)var4;
               if(var5.field4845 == var2) {
                  return false;
               }

               var5.field4845 = var2;
               return true;
            }

            var4.remove_base();
         }
      } else {
         this.parameters = new IterableNodeHashTable(4);
      }

      this.parameters.put(new class482(var2), (long)var1);
      return true;
   }

   @ObfuscatedName("aq")
   @ObfuscatedSignature(
      descriptor = "(ILjava/lang/String;I)Z",
      garbageValue = "-1755861280"
   )
   boolean method3365_base(int var1, String var2) {
      if(var2 == null) {
         var2 = "";
      } else if(var2.length() > 80) {
         var2 = var2.substring(0, 80);
      }

      if(this.parameters != null) {
         Node var3 = this.parameters.get((long)var1);
         if(var3 != null) {
            if(var3 instanceof ObjectNode) {
               ObjectNode var4 = (ObjectNode)var3;
               if(var4.obj instanceof String) {
                  if(var2.equals(var4.obj)) {
                     return false;
                  }

                  var4.remove_base();
                  this.parameters.put(new ObjectNode(var2), var4.key);
                  return true;
               }
            }

            var3.remove_base();
         }
      } else {
         this.parameters = new IterableNodeHashTable(4);
      }

      this.parameters.put(new ObjectNode(var2), (long)var1);
      return true;
   }

   @ObfuscatedName("ai")
   @ObfuscatedSignature(
      descriptor = "(Luj;B)V",
      garbageValue = "-1"
   )
   void method3340(Buffer var1) {
      int var2 = var1.readUnsignedByte_base();
      if(var2 >= 1 && var2 <= 6) {
         int var3 = var1.readUnsignedByte_base();
         if((var3 & 1) != 0) {
            this.useHashes = true;
         }

         if((var3 & 2) != 0) {
            this.useNames = true;
         }

         if(!this.useHashes) {
            this.memberHashes = null;
            this.bannedMemberHashes = null;
         }

         if(!this.useNames) {
            this.memberNames = null;
            this.bannedMemberNames = null;
         }

         this.field1701 = var1.readInt_base();
         this.field1720 = var1.readInt_base();
         if(var2 <= 3 && this.field1720 != 0) {
            this.field1720 += 16912800;
         }

         this.memberCount = var1.readUnsignedShort_base();
         this.bannedMemberCount = var1.readUnsignedByte_base();
         this.name = var1.readStringCp1252NullTerminated_base();
         if(var2 >= 4) {
            var1.readInt_base();
         }

         this.allowGuests = var1.readUnsignedByte_base() == 1;
         this.field1705 = var1.readByte_base();
         this.field1706 = var1.readByte_base();
         this.field1707 = var1.readByte_base();
         this.field1708 = var1.readByte_base();
         int var4;
         if(this.memberCount > 0) {
            if(this.useHashes && (this.memberHashes == null || this.memberHashes.length < this.memberCount)) {
               this.memberHashes = new long[this.memberCount];
            }

            if(this.useNames && (this.memberNames == null || this.memberNames.length < this.memberCount)) {
               this.memberNames = new String[this.memberCount];
            }

            if(this.memberRanks == null || this.memberRanks.length < this.memberCount) {
               this.memberRanks = new byte[this.memberCount];
            }

            if(this.field1713 == null || this.field1713.length < this.memberCount) {
               this.field1713 = new int[this.memberCount];
            }

            if(this.field1723 == null || this.field1723.length < this.memberCount) {
               this.field1723 = new int[this.memberCount];
            }

            if(this.field1698 == null || this.field1698.length < this.memberCount) {
               this.field1698 = new boolean[this.memberCount];
            }

            for(var4 = 0; var4 < this.memberCount; ++var4) {
               if(this.useHashes) {
                  this.memberHashes[var4] = var1.readLong_base();
               }

               if(this.useNames) {
                  this.memberNames[var4] = var1.readStringCp1252NullTerminatedOrNull_base();
               }

               this.memberRanks[var4] = var1.readByte_base();
               if(var2 >= 2) {
                  this.field1713[var4] = var1.readInt_base();
               }

               if(var2 >= 5) {
                  this.field1723[var4] = var1.readUnsignedShort_base();
               } else {
                  this.field1723[var4] = 0;
               }

               if(var2 >= 6) {
                  this.field1698[var4] = var1.readUnsignedByte_base() == 1;
               } else {
                  this.field1698[var4] = false;
               }
            }

            this.updateOwner_base();
         }

         if(this.bannedMemberCount > 0) {
            if(this.useHashes && (this.bannedMemberHashes == null || this.bannedMemberHashes.length < this.bannedMemberCount)) {
               this.bannedMemberHashes = new long[this.bannedMemberCount];
            }

            if(this.useNames && (this.bannedMemberNames == null || this.bannedMemberNames.length < this.bannedMemberCount)) {
               this.bannedMemberNames = new String[this.bannedMemberCount];
            }

            for(var4 = 0; var4 < this.bannedMemberCount; ++var4) {
               if(this.useHashes) {
                  this.bannedMemberHashes[var4] = var1.readLong_base();
               }

               if(this.useNames) {
                  this.bannedMemberNames[var4] = var1.readStringCp1252NullTerminatedOrNull_base();
               }
            }
         }

         if(var2 >= 3) {
            var4 = var1.readUnsignedShort_base();
            if(var4 > 0) {
               this.parameters = new IterableNodeHashTable(var4 < 16?class184.method3680_base(var4):16);

               while(var4-- > 0) {
                  int var5 = var1.readInt_base();
                  int var6 = var5 & 1073741823;
                  int var7 = var5 >>> 30;
                  if(var7 == 0) {
                     int var8 = var1.readInt_base();
                     this.parameters.put(new IntegerNode(var8), (long)var6);
                  } else if(var7 == 1) {
                     long var10 = var1.readLong_base();
                     this.parameters.put(new class482(var10), (long)var6);
                  } else if(var7 == 2) {
                     String var12 = var1.readStringCp1252NullTerminated_base();
                     this.parameters.put(new ObjectNode(var12), (long)var6);
                  }
               }
            }
         }

      } else {
         throw new RuntimeException("" + var2);
      }
   }

   public int getMemberCount() {
      return this.memberCount;
   }

   public Integer getTitleGroupValue(int var1) {
      return this.getTitleGroupValue_base(var1);
   }

   public String[] getMemberNames() {
      return this.memberNames;
   }

   public int[] getSortedMembers() {
      return this.getSortedMembers_base();
   }

   public int getTitle(int var1, int var2, int var3) {
      Integer var4 = this.getTitleGroupValue(var1);
      int var5 = var4 == null?-1:var4.intValue();
      int var6 = 31 - var3;
      return var5 << var6 >>> var6 + var2;
   }

   public List getMembers() {
      int var1 = this.getMemberCount();
      ArrayList var2 = new ArrayList(var1);

      for(int var3 = 0; var3 < var1; ++var3) {
         var2.add((ClanMember)SpriteMask.client.runeliteClanMember(this, var3));
      }

      return var2;
   }

   public ClanMember findMember(String var1) {
      var1 = var1.replace(" ", " ").toLowerCase();
      String[] var2 = this.getMemberNames();
      int[] var3 = this.getSortedMembers();
      int var4 = 0;
      int var5 = var3.length - 1;

      while(var4 <= var5) {
         int var6 = var4 + var5 >>> 1;
         int var7 = var3[var6];
         String var8 = var2[var7];
         int var9 = var8.toLowerCase().compareTo(var1);
         if(var9 < 0) {
            var4 = var6 + 1;
         } else {
            if(var9 == 0) {
               return (ClanMember)SpriteMask.client.runeliteClanMember(this, var7);
            }

            var5 = var6 - 1;
         }
      }

      return null;
   }

   public ClanTitle titleForRank(ClanRank var1) {
      if(!$assertionsDisabled && !SpriteMask.client.isClientThread()) {
         throw new AssertionError("titleForRank must be called on client thread");
      } else {
         int var2;
         if(var1 == ClanRank.JMOD) {
            var2 = -5;
         } else if(var1 == ClanRank.OWNER) {
            var2 = -4;
         } else if(var1 == ClanRank.DEPUTY_OWNER) {
            var2 = -3;
         } else if(var1 == ClanRank.ADMINISTRATOR) {
            var2 = -2;
         } else if(var1 == ClanRank.GUEST) {
            var2 = -1;
         } else if(var1 == ClanRank.CLAN_RANK_1) {
            var2 = this.getTitle(1, 0, 9);
         } else if(var1 == ClanRank.CLAN_RANK_2) {
            var2 = this.getTitle(1, 10, 19);
         } else if(var1 == ClanRank.CLAN_RANK_3) {
            var2 = this.getTitle(1, 20, 29);
         } else if(var1 == ClanRank.CLAN_RANK_4) {
            var2 = this.getTitle(2, 0, 9);
         } else if(var1 == ClanRank.CLAN_RANK_5) {
            var2 = this.getTitle(2, 10, 19);
         } else if(var1 == ClanRank.CLAN_RANK_6) {
            var2 = this.getTitle(2, 20, 29);
         } else if(var1 == ClanRank.CLAN_RANK_7) {
            var2 = this.getTitle(3, 0, 9);
         } else if(var1 == ClanRank.CLAN_RANK_8) {
            var2 = this.getTitle(3, 10, 19);
         } else if(var1 == ClanRank.CLAN_RANK_9) {
            var2 = this.getTitle(3, 20, 29);
         } else if(var1 == ClanRank.CLAN_RANK_10) {
            var2 = this.getTitle(4, 0, 9);
         } else if(var1 == ClanRank.CLAN_RANK_11) {
            var2 = this.getTitle(4, 10, 19);
         } else if(var1 == ClanRank.CLAN_RANK_12) {
            var2 = this.getTitle(4, 20, 29);
         } else if(var1 == ClanRank.CLAN_RANK_13) {
            var2 = this.getTitle(5, 0, 9);
         } else {
            if(var1 != ClanRank.CLAN_RANK_14) {
               throw new IllegalStateException("Unexpected value: " + var1);
            }

            var2 = this.getTitle(5, 10, 19);
         }

         if(var2 == 1023) {
            return null;
         } else {
            net.runelite.api.EnumComposition var3 = SpriteMask.client.getEnum(3797);
            String var4 = var3.getStringValue(var2);
            return var4.isEmpty()?null:new ClanTitle(var2, var4);
         }
      }
   }

   public String getName() {
      return this.name;
   }

   public byte[] getMemberRanks() {
      return this.memberRanks;
   }

   @ObfuscatedName("ar")
   @ObfuscatedSignature(
      descriptor = "(Lri;FFFI)F",
      garbageValue = "-584068586"
   )
   static float method3387_base(class464 var0, float var1, float var2, float var3) {
      float var4 = WorldMapID.method4936_base(var0.field4786, var0.field4787, var1);
      if(Math.abs(var4) < class127.field1484) {
         return var1;
      } else {
         float var5 = WorldMapID.method4936_base(var0.field4786, var0.field4787, var2);
         if(Math.abs(var5) < class127.field1484) {
            return var2;
         } else {
            float var6 = 0.0F;
            float var7 = 0.0F;
            float var8 = 0.0F;
            float var13 = 0.0F;
            boolean var14 = true;
            boolean var15 = false;

            do {
               var15 = false;
               if(var14) {
                  var6 = var1;
                  var13 = var4;
                  var7 = var2 - var1;
                  var8 = var7;
                  var14 = false;
               }

               if(Math.abs(var13) < Math.abs(var5)) {
                  var1 = var2;
                  var2 = var6;
                  var6 = var1;
                  var4 = var5;
                  var5 = var13;
                  var13 = var4;
               }

               float var16 = class127.field1485 * Math.abs(var2) + 0.5F * var3;
               float var17 = (var6 - var2) * 0.5F;
               boolean var18 = Math.abs(var17) > var16 && var5 != 0.0F;
               if(var18) {
                  if(Math.abs(var8) >= var16 && Math.abs(var4) > Math.abs(var5)) {
                     float var12 = var5 / var4;
                     float var9;
                     float var10;
                     if(var6 == var1) {
                        var9 = var12 * var17 * 2.0F;
                        var10 = 1.0F - var12;
                     } else {
                        var10 = var4 / var13;
                        float var11 = var5 / var13;
                        var9 = (var17 * 2.0F * var10 * (var10 - var11) - (var2 - var1) * (var11 - 1.0F)) * var12;
                        var10 = (var12 - 1.0F) * (var11 - 1.0F) * (var10 - 1.0F);
                     }

                     if((double)var9 > 0.0D) {
                        var10 = -var10;
                     } else {
                        var9 = -var9;
                     }

                     var12 = var8;
                     var8 = var7;
                     if(var9 * 2.0F < var17 * 3.0F * var10 - Math.abs(var16 * var10) && var9 < Math.abs(var12 * 0.5F * var10)) {
                        var7 = var9 / var10;
                     } else {
                        var7 = var17;
                        var8 = var17;
                     }
                  } else {
                     var7 = var17;
                     var8 = var17;
                  }

                  var1 = var2;
                  var4 = var5;
                  if(Math.abs(var7) > var16) {
                     var2 += var7;
                  } else if((double)var17 > 0.0D) {
                     var2 += var16;
                  } else {
                     var2 -= var16;
                  }

                  var5 = WorldMapID.method4936_base(var0.field4786, var0.field4787, var2);
                  if((double)(var5 * (var13 / Math.abs(var13))) > 0.0D) {
                     var14 = true;
                     var15 = true;
                  } else {
                     var15 = true;
                  }
               }
            } while(var15);

            return var2;
         }
      }
   }

   @ObfuscatedName("ki")
   @ObfuscatedSignature(
      descriptor = "(IIS)V",
      garbageValue = "25188"
   )
   static final void updateItemPile_base(int var0, int var1) {
      NodeDeque var2 = Client.groundItems[ItemLayer.Client_plane][var0][var1];
      if(var2 == null) {
         class36.scene.removeGroundItemPile_base(ItemLayer.Client_plane, var0, var1);
      } else {
         long var3 = -99999999L;
         TileItem var5 = null;

         TileItem var6;
         for(var6 = (TileItem)var2.method7265(); var6 != null; var6 = (TileItem)var2.method7235()) {
            ItemComposition var7 = class214.method4226(var6.id);
            long var8 = (long)var7.price;
            if(var7.isStackable == 1) {
               var8 *= var6.quantity < Integer.MAX_VALUE?(long)(var6.quantity + 1):(long)var6.quantity;
            }

            if(var8 > var3) {
               var3 = var8;
               var5 = var6;
            }
         }

         if(var5 == null) {
            class36.scene.removeGroundItemPile_base(ItemLayer.Client_plane, var0, var1);
         } else {
            var2.method7261(var5);
            TileItem var12 = null;
            TileItem var11 = null;

            for(var6 = (TileItem)var2.method7265(); var6 != null; var6 = (TileItem)var2.method7235()) {
               if(var6.id != var5.id) {
                  if(var12 == null) {
                     var12 = var6;
                  }

                  if(var6.id != var12.id && var11 == null) {
                     var11 = var6;
                  }
               }
            }

            long var9 = Player.calculateTag_base(var0, var1, 3, false, 0);
            class36.scene.method5331(ItemLayer.Client_plane, var0, var1, WorldMapDecorationType.getTileHeight_base(var0 * 128 + 64, var1 * 128 + 64, ItemLayer.Client_plane), var5, var9, var12, var11);
         }
      }
   }

   @ObfuscatedName("ko")
   @ObfuscatedSignature(
      descriptor = "(B)V",
      garbageValue = "1"
   )
   static final void method3333_base() {
      int var0 = FriendSystem.menuX;
      int var1 = class60.menuY;
      int var2 = class428.menuWidth;
      int var3 = class515.menuHeight;
      int var4 = 6116423;
      Rasterizer2D.Rasterizer2D_fillRectangle_base(var0, var1, var2, var3, var4);
      Rasterizer2D.Rasterizer2D_fillRectangle_base(var0 + 1, var1 + 1, var2 - 2, 16, 0);
      Rasterizer2D.Rasterizer2D_drawRectangle_base(var0 + 1, var1 + 18, var2 - 2, var3 - 19, 0);
      GrandExchangeOfferTotalQuantityComparator.fontBold12.draw_base("Choose Option", var0 + 3, var1 + 14, var4, -1);
      int var5 = MouseHandler.MouseHandler_x;
      int var6 = MouseHandler.MouseHandler_y;

      for(int var7 = 0; var7 < Client.menuOptionsCount; ++var7) {
         int var8 = var1 + (Client.menuOptionsCount - 1 - var7) * 15 + 31;
         int var9 = 16777215;
         if(var5 > var0 && var5 < var2 + var0 && var6 > var8 - 13 && var6 < var8 + 3) {
            var9 = 16776960;
         }

         Font var10 = GrandExchangeOfferTotalQuantityComparator.fontBold12;
         String var11;
         if(var7 < 0) {
            var11 = "";
         } else if(Client.menuTargets[var7].length() > 0) {
            var11 = Client.menuActions[var7] + " " + Client.menuTargets[var7];
         } else {
            var11 = Client.menuActions[var7];
         }

         var10.draw_base(var11, var0 + 3, var8, var9, 0);
      }

      SoundSystem.method867_base(FriendSystem.menuX, class60.menuY, class428.menuWidth, class515.menuHeight);
   }
}
