package com.google.android.m4b.maps.bh;

import android.util.Pair;
import com.google.android.m4b.maps.aw.f;
import com.google.android.m4b.maps.bc.af;
import com.google.android.m4b.maps.bc.ba;
import com.google.android.m4b.maps.be.j;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;

public final class a
{
  private int a;
  private boolean b;
  private int c;
  private final LinkedHashSet<ba> d = Sets.newLinkedHashSet();
  private final LinkedHashSet<ba> e = Sets.newLinkedHashSet();
  private Iterator<ba> f;
  private final a g;
  private final LinkedList<Pair<ba, Boolean>> h = Lists.newLinkedList();
  private f i;
  private af j;
  private long k = 0L;
  private long l;
  private byte m = 4;
  private boolean n;
  private Map<ba, b> o = Maps.newHashMap();
  private Set<ba> p = Sets.newHashSet();
  private b q;

  public a(int paramInt1, int paramInt2, boolean paramBoolean1, boolean paramBoolean2)
  {
    this.a = paramInt1;
    this.g = new a(paramBoolean2);
    this.b = paramBoolean1;
    this.c = paramInt2;
  }

  private b b(b paramb, boolean paramBoolean)
  {
    int i1 = 1;
    b localb;
    long l1;
    try
    {
      boolean bool1 = a(paramb);
      localb = null;
      if (!bool1);
      while (true)
      {
        return localb;
        l1 = paramb.c;
        if (this.m == 0)
        {
          boolean bool5 = l1 < this.q.c;
          localb = null;
          if (!bool5)
          {
            this.m = 1;
            e();
            paramBoolean = false;
          }
        }
        else
        {
          if ((paramBoolean) && (paramb != this.q))
          {
            this.d.remove(paramb.a);
            this.p.add(paramb.a);
          }
          if (this.m != i1)
            break label238;
          boolean bool4 = l1 < this.k;
          localb = null;
          if (!bool4)
            if ((this.p.size() + this.d.size() < this.c) && (this.f.hasNext()))
            {
              localb = new b((ba)this.f.next(), d(), Boolean.TRUE.booleanValue());
            }
            else
            {
              if (!this.n)
                break;
              this.m = 4;
              localb = null;
            }
        }
      }
    }
    finally
    {
    }
    this.m = 2;
    this.g.a();
    label238: if (this.p.size() < this.c);
    while (true)
    {
      if (i1 == 0)
      {
        this.m = 4;
        localb = null;
        break;
      }
      if (this.m == 2)
      {
        if (!this.d.isEmpty())
        {
          boolean bool3 = paramb.c < this.k;
          localb = null;
          if (bool3)
            break;
          localb = null;
          if (i1 == 0)
            break;
          localb = this.g.a(paramBoolean);
          break;
        }
        l1 = this.k;
        this.m = 3;
      }
      int i2 = this.m;
      localb = null;
      if (i2 != 3)
        break;
      boolean bool2 = l1 < this.k;
      localb = null;
      if (bool2)
        break;
      if ((!this.h.isEmpty()) && (i1 != 0))
      {
        Pair localPair = (Pair)this.h.remove(0);
        localb = new b((ba)localPair.first, d(), ((Boolean)localPair.second).booleanValue());
        break;
      }
      this.m = 4;
      localb = null;
      break;
      i1 = 0;
    }
  }

  private long d()
  {
    long l1 = 1L + this.k;
    this.k = l1;
    return l1;
  }

  private void e()
  {
    LinkedHashSet localLinkedHashSet;
    try
    {
      this.o.clear();
      this.e.clear();
      this.p.clear();
      if (!this.b)
        break label132;
      localLinkedHashSet = Sets.newLinkedHashSet();
      Iterator localIterator1 = this.d.iterator();
      while (localIterator1.hasNext())
        localLinkedHashSet.add(((ba)localIterator1.next()).a());
    }
    finally
    {
    }
    com.google.android.m4b.maps.aw.b.a(this.i, this.a, localLinkedHashSet, this.j, 8, this.e);
    if (this.n)
      this.e.addAll(this.i.a(2, this.j));
    while (true)
    {
      label132: this.f = this.e.iterator();
      return;
      ArrayList localArrayList = Lists.newArrayList(this.e);
      Collections.reverse(localArrayList);
      Iterator localIterator2 = localArrayList.iterator();
      while (localIterator2.hasNext())
      {
        ba localba2 = (ba)localIterator2.next();
        this.h.add(0, Pair.create(localba2, Boolean.FALSE));
      }
      Iterator localIterator3 = this.e.iterator();
      int i1 = -1;
      while (localIterator3.hasNext())
      {
        ba localba1 = (ba)localIterator3.next();
        if (i1 == -1)
          i1 = localba1.b();
        else if (i1 != localba1.b())
          localIterator3.remove();
      }
    }
  }

  public final b a(b paramb, boolean paramBoolean)
  {
    try
    {
      boolean bool2;
      do
      {
        boolean bool1;
        do
        {
          paramb = b(paramb, paramBoolean);
          if (paramb == null)
            break label99;
          b localb = (b)this.o.get(paramb.a);
          if (localb == null)
            break;
          bool1 = localb.b;
          paramBoolean = false;
        }
        while (!bool1);
        bool2 = paramb.b;
        paramBoolean = false;
      }
      while (bool2);
      this.o.put(paramb.a, paramb);
      if (!paramb.b)
        this.p.add(paramb.a);
      label99: return paramb;
    }
    finally
    {
    }
  }

  public final void a()
  {
    try
    {
      if (!this.n)
        this.m = 4;
      return;
    }
    finally
    {
      localObject = finally;
      throw localObject;
    }
  }

  public final void a(f paramf, af paramaf, List<ba> paramList, Set<ba> paramSet1, Set<ba> paramSet2, boolean paramBoolean)
  {
    try
    {
      this.m = 0;
      this.l = d();
      this.i = paramf;
      this.j = paramaf;
      this.q = new b(j.d, d(), Boolean.TRUE.booleanValue());
      this.d.clear();
      this.d.addAll(paramList);
      this.h.clear();
      if (paramSet1 != null)
      {
        Iterator localIterator1 = paramSet1.iterator();
        while (localIterator1.hasNext())
        {
          ba localba2 = (ba)localIterator1.next();
          this.h.add(Pair.create(localba2, Boolean.TRUE));
        }
      }
    }
    finally
    {
    }
    if (paramSet2 != null)
    {
      Iterator localIterator2 = paramSet2.iterator();
      while (localIterator2.hasNext())
      {
        ba localba1 = (ba)localIterator2.next();
        this.h.add(Pair.create(localba1, Boolean.FALSE));
      }
    }
    this.n = paramBoolean;
  }

  public final boolean a(b paramb)
  {
    if (paramb != null);
    try
    {
      if (paramb.c >= this.l)
      {
        boolean bool2 = c();
        if (!bool2)
        {
          bool1 = true;
          return bool1;
        }
      }
      boolean bool1 = false;
    }
    finally
    {
    }
  }

  public final b b()
  {
    try
    {
      b localb = this.q;
      return localb;
    }
    finally
    {
      localObject = finally;
      throw localObject;
    }
  }

  public final boolean c()
  {
    try
    {
      int i1 = this.m;
      if (i1 == 4)
      {
        bool = true;
        return bool;
      }
      boolean bool = false;
    }
    finally
    {
    }
  }

  final class a
  {
    private boolean a;
    private int b = 0;
    private ba c;
    private LinkedHashSet<ba> d = Sets.newLinkedHashSet();
    private LinkedHashSet<ba> e = Sets.newLinkedHashSet();
    private Iterator<ba> f;

    public a(boolean arg2)
    {
      boolean bool;
      this.a = bool;
    }

    public final b a(boolean paramBoolean)
    {
      if ((this.c != null) && (this.b < a.c(a.this)))
      {
        if (!paramBoolean)
        {
          ba localba2 = a.e(a.this).a(this.c, a.d(a.this));
          if (localba2 != null)
            this.e.add(localba2);
        }
        if ((!this.f.hasNext()) && (!this.e.isEmpty()))
        {
          this.b = (1 + this.b);
          LinkedHashSet localLinkedHashSet = this.d;
          this.d = this.e;
          this.e = localLinkedHashSet;
          this.e.clear();
          this.f = this.d.iterator();
        }
      }
      if (!this.f.hasNext())
        return null;
      this.c = ((ba)this.f.next());
      ba localba1 = this.c;
      long l = a.b(a.this);
      if ((!this.a) && (this.b != 0));
      for (boolean bool = true; ; bool = false)
        return new b(localba1, l, bool);
    }

    public final void a()
    {
      this.b = 0;
      this.d.clear();
      this.e.clear();
      this.c = null;
      this.d.addAll(a.a(a.this));
      this.f = this.d.iterator();
    }
  }
}

/* Location:           C:\Documents and Settings\Cesar Cabello Cea\Mis documentos\Downloads\apk-downloader\com.ikea.kompis-6_dex2jar.jar
 * Qualified Name:     com.google.android.m4b.maps.bh.a
 * JD-Core Version:    0.6.2
 */