package mapped;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import net.runelite.mapping.ObfuscatedName;
import net.runelite.mapping.ObfuscatedSignature;
import net.runelite.rs.api.RSGrandExchangeEvents;

@ObfuscatedName("ov")
public class GrandExchangeEvents implements RSGrandExchangeEvents {
   @ObfuscatedName("ah")
   public static Comparator GrandExchangeEvents_ageComparator;
   @ObfuscatedName("ar")
   public static Comparator GrandExchangeEvents_priceComparator;
   @ObfuscatedName("ao")
   public static Comparator GrandExchangeEvents_nameComparator;
   @ObfuscatedName("ab")
   public static Comparator GrandExchangeEvents_quantityComparator;
   @ObfuscatedName("ak")
   @ObfuscatedSignature(
      descriptor = "Lup;"
   )
   static IndexedSprite field4344;
   @ObfuscatedName("at")
   public final List events;

   static {
      GrandExchangeEvents_ageComparator = new GrandExchangeOfferAgeComparator();
      new GrandExchangeOfferWorldComparator();
      GrandExchangeEvents_priceComparator = new GrandExchangeOfferUnitPriceComparator();
      GrandExchangeEvents_nameComparator = new GrandExchangeOfferNameComparator();
      GrandExchangeEvents_quantityComparator = new GrandExchangeOfferTotalQuantityComparator();
   }

   @ObfuscatedSignature(
      descriptor = "(Luj;Z)V",
      garbageValue = "1"
   )
   public GrandExchangeEvents(Buffer var1, boolean var2) {
      int var3 = var1.readUnsignedShort_base();
      boolean var4 = var1.readUnsignedByte_base() == 1;
      byte var5;
      if(var4) {
         var5 = 1;
      } else {
         var5 = 0;
      }

      int var6 = var1.readUnsignedShort_base();
      this.events = new ArrayList(var6);

      for(int var7 = 0; var7 < var6; ++var7) {
         this.events.add(new GrandExchangeEvent(var1, var5, var3));
      }

   }

   @ObfuscatedName("at")
   @ObfuscatedSignature(
      descriptor = "(Ljava/util/Comparator;ZB)V",
      garbageValue = "1"
   )
   public void sort_base(Comparator var1, boolean var2) {
      if(var2) {
         Collections.sort(this.events, var1);
      } else {
         Collections.sort(this.events, Collections.reverseOrder(var1));
      }

   }
}
